]> git.ipfire.org Git - thirdparty/grsecurity-scrape.git/blob - test/grsecurity-2.9.1-3.9.4-201306011536.patch
Auto commit, 1 new patch{es}.
[thirdparty/grsecurity-scrape.git] / test / grsecurity-2.9.1-3.9.4-201306011536.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/crash_dump_64.c b/arch/x86/kernel/crash_dump_64.c
17729 index afa64ad..dce67dd 100644
17730 --- a/arch/x86/kernel/crash_dump_64.c
17731 +++ b/arch/x86/kernel/crash_dump_64.c
17732 @@ -36,7 +36,7 @@ ssize_t copy_oldmem_page(unsigned long pfn, char *buf,
17733 return -ENOMEM;
17734
17735 if (userbuf) {
17736 - if (copy_to_user(buf, vaddr + offset, csize)) {
17737 + if (copy_to_user((char __force_user *)buf, vaddr + offset, csize)) {
17738 iounmap(vaddr);
17739 return -EFAULT;
17740 }
17741 diff --git a/arch/x86/kernel/doublefault_32.c b/arch/x86/kernel/doublefault_32.c
17742 index 37250fe..bf2ec74 100644
17743 --- a/arch/x86/kernel/doublefault_32.c
17744 +++ b/arch/x86/kernel/doublefault_32.c
17745 @@ -11,7 +11,7 @@
17746
17747 #define DOUBLEFAULT_STACKSIZE (1024)
17748 static unsigned long doublefault_stack[DOUBLEFAULT_STACKSIZE];
17749 -#define STACK_START (unsigned long)(doublefault_stack+DOUBLEFAULT_STACKSIZE)
17750 +#define STACK_START (unsigned long)(doublefault_stack+DOUBLEFAULT_STACKSIZE-2)
17751
17752 #define ptr_ok(x) ((x) > PAGE_OFFSET && (x) < PAGE_OFFSET + MAXMEM)
17753
17754 @@ -21,7 +21,7 @@ static void doublefault_fn(void)
17755 unsigned long gdt, tss;
17756
17757 store_gdt(&gdt_desc);
17758 - gdt = gdt_desc.address;
17759 + gdt = (unsigned long)gdt_desc.address;
17760
17761 printk(KERN_EMERG "PANIC: double fault, gdt at %08lx [%d bytes]\n", gdt, gdt_desc.size);
17762
17763 @@ -58,10 +58,10 @@ struct tss_struct doublefault_tss __cacheline_aligned = {
17764 /* 0x2 bit is always set */
17765 .flags = X86_EFLAGS_SF | 0x2,
17766 .sp = STACK_START,
17767 - .es = __USER_DS,
17768 + .es = __KERNEL_DS,
17769 .cs = __KERNEL_CS,
17770 .ss = __KERNEL_DS,
17771 - .ds = __USER_DS,
17772 + .ds = __KERNEL_DS,
17773 .fs = __KERNEL_PERCPU,
17774
17775 .__cr3 = __pa_nodebug(swapper_pg_dir),
17776 diff --git a/arch/x86/kernel/dumpstack.c b/arch/x86/kernel/dumpstack.c
17777 index c8797d5..c605e53 100644
17778 --- a/arch/x86/kernel/dumpstack.c
17779 +++ b/arch/x86/kernel/dumpstack.c
17780 @@ -2,6 +2,9 @@
17781 * Copyright (C) 1991, 1992 Linus Torvalds
17782 * Copyright (C) 2000, 2001, 2002 Andi Kleen, SuSE Labs
17783 */
17784 +#ifdef CONFIG_GRKERNSEC_HIDESYM
17785 +#define __INCLUDED_BY_HIDESYM 1
17786 +#endif
17787 #include <linux/kallsyms.h>
17788 #include <linux/kprobes.h>
17789 #include <linux/uaccess.h>
17790 @@ -35,16 +38,14 @@ void printk_address(unsigned long address, int reliable)
17791 static void
17792 print_ftrace_graph_addr(unsigned long addr, void *data,
17793 const struct stacktrace_ops *ops,
17794 - struct thread_info *tinfo, int *graph)
17795 + struct task_struct *task, int *graph)
17796 {
17797 - struct task_struct *task;
17798 unsigned long ret_addr;
17799 int index;
17800
17801 if (addr != (unsigned long)return_to_handler)
17802 return;
17803
17804 - task = tinfo->task;
17805 index = task->curr_ret_stack;
17806
17807 if (!task->ret_stack || index < *graph)
17808 @@ -61,7 +62,7 @@ print_ftrace_graph_addr(unsigned long addr, void *data,
17809 static inline void
17810 print_ftrace_graph_addr(unsigned long addr, void *data,
17811 const struct stacktrace_ops *ops,
17812 - struct thread_info *tinfo, int *graph)
17813 + struct task_struct *task, int *graph)
17814 { }
17815 #endif
17816
17817 @@ -72,10 +73,8 @@ print_ftrace_graph_addr(unsigned long addr, void *data,
17818 * severe exception (double fault, nmi, stack fault, debug, mce) hardware stack
17819 */
17820
17821 -static inline int valid_stack_ptr(struct thread_info *tinfo,
17822 - void *p, unsigned int size, void *end)
17823 +static inline int valid_stack_ptr(void *t, void *p, unsigned int size, void *end)
17824 {
17825 - void *t = tinfo;
17826 if (end) {
17827 if (p < end && p >= (end-THREAD_SIZE))
17828 return 1;
17829 @@ -86,14 +85,14 @@ static inline int valid_stack_ptr(struct thread_info *tinfo,
17830 }
17831
17832 unsigned long
17833 -print_context_stack(struct thread_info *tinfo,
17834 +print_context_stack(struct task_struct *task, void *stack_start,
17835 unsigned long *stack, unsigned long bp,
17836 const struct stacktrace_ops *ops, void *data,
17837 unsigned long *end, int *graph)
17838 {
17839 struct stack_frame *frame = (struct stack_frame *)bp;
17840
17841 - while (valid_stack_ptr(tinfo, stack, sizeof(*stack), end)) {
17842 + while (valid_stack_ptr(stack_start, stack, sizeof(*stack), end)) {
17843 unsigned long addr;
17844
17845 addr = *stack;
17846 @@ -105,7 +104,7 @@ print_context_stack(struct thread_info *tinfo,
17847 } else {
17848 ops->address(data, addr, 0);
17849 }
17850 - print_ftrace_graph_addr(addr, data, ops, tinfo, graph);
17851 + print_ftrace_graph_addr(addr, data, ops, task, graph);
17852 }
17853 stack++;
17854 }
17855 @@ -114,7 +113,7 @@ print_context_stack(struct thread_info *tinfo,
17856 EXPORT_SYMBOL_GPL(print_context_stack);
17857
17858 unsigned long
17859 -print_context_stack_bp(struct thread_info *tinfo,
17860 +print_context_stack_bp(struct task_struct *task, void *stack_start,
17861 unsigned long *stack, unsigned long bp,
17862 const struct stacktrace_ops *ops, void *data,
17863 unsigned long *end, int *graph)
17864 @@ -122,7 +121,7 @@ print_context_stack_bp(struct thread_info *tinfo,
17865 struct stack_frame *frame = (struct stack_frame *)bp;
17866 unsigned long *ret_addr = &frame->return_address;
17867
17868 - while (valid_stack_ptr(tinfo, ret_addr, sizeof(*ret_addr), end)) {
17869 + while (valid_stack_ptr(stack_start, ret_addr, sizeof(*ret_addr), end)) {
17870 unsigned long addr = *ret_addr;
17871
17872 if (!__kernel_text_address(addr))
17873 @@ -131,7 +130,7 @@ print_context_stack_bp(struct thread_info *tinfo,
17874 ops->address(data, addr, 1);
17875 frame = frame->next_frame;
17876 ret_addr = &frame->return_address;
17877 - print_ftrace_graph_addr(addr, data, ops, tinfo, graph);
17878 + print_ftrace_graph_addr(addr, data, ops, task, graph);
17879 }
17880
17881 return (unsigned long)frame;
17882 @@ -189,7 +188,7 @@ void dump_stack(void)
17883
17884 bp = stack_frame(current, NULL);
17885 printk("Pid: %d, comm: %.20s %s %s %.*s\n",
17886 - current->pid, current->comm, print_tainted(),
17887 + task_pid_nr(current), current->comm, print_tainted(),
17888 init_utsname()->release,
17889 (int)strcspn(init_utsname()->version, " "),
17890 init_utsname()->version);
17891 @@ -225,6 +224,8 @@ unsigned __kprobes long oops_begin(void)
17892 }
17893 EXPORT_SYMBOL_GPL(oops_begin);
17894
17895 +extern void gr_handle_kernel_exploit(void);
17896 +
17897 void __kprobes oops_end(unsigned long flags, struct pt_regs *regs, int signr)
17898 {
17899 if (regs && kexec_should_crash(current))
17900 @@ -246,7 +247,10 @@ void __kprobes oops_end(unsigned long flags, struct pt_regs *regs, int signr)
17901 panic("Fatal exception in interrupt");
17902 if (panic_on_oops)
17903 panic("Fatal exception");
17904 - do_exit(signr);
17905 +
17906 + gr_handle_kernel_exploit();
17907 +
17908 + do_group_exit(signr);
17909 }
17910
17911 int __kprobes __die(const char *str, struct pt_regs *regs, long err)
17912 @@ -274,7 +278,7 @@ int __kprobes __die(const char *str, struct pt_regs *regs, long err)
17913 print_modules();
17914 show_regs(regs);
17915 #ifdef CONFIG_X86_32
17916 - if (user_mode_vm(regs)) {
17917 + if (user_mode(regs)) {
17918 sp = regs->sp;
17919 ss = regs->ss & 0xffff;
17920 } else {
17921 @@ -302,7 +306,7 @@ void die(const char *str, struct pt_regs *regs, long err)
17922 unsigned long flags = oops_begin();
17923 int sig = SIGSEGV;
17924
17925 - if (!user_mode_vm(regs))
17926 + if (!user_mode(regs))
17927 report_bug(regs->ip, regs);
17928
17929 if (__die(str, regs, err))
17930 diff --git a/arch/x86/kernel/dumpstack_32.c b/arch/x86/kernel/dumpstack_32.c
17931 index 1038a41..db2c12b 100644
17932 --- a/arch/x86/kernel/dumpstack_32.c
17933 +++ b/arch/x86/kernel/dumpstack_32.c
17934 @@ -38,15 +38,13 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
17935 bp = stack_frame(task, regs);
17936
17937 for (;;) {
17938 - struct thread_info *context;
17939 + void *stack_start = (void *)((unsigned long)stack & ~(THREAD_SIZE-1));
17940
17941 - context = (struct thread_info *)
17942 - ((unsigned long)stack & (~(THREAD_SIZE - 1)));
17943 - bp = ops->walk_stack(context, stack, bp, ops, data, NULL, &graph);
17944 + bp = ops->walk_stack(task, stack_start, stack, bp, ops, data, NULL, &graph);
17945
17946 - stack = (unsigned long *)context->previous_esp;
17947 - if (!stack)
17948 + if (stack_start == task_stack_page(task))
17949 break;
17950 + stack = *(unsigned long **)stack_start;
17951 if (ops->stack(data, "IRQ") < 0)
17952 break;
17953 touch_nmi_watchdog();
17954 @@ -86,7 +84,7 @@ void show_regs(struct pt_regs *regs)
17955 {
17956 int i;
17957
17958 - __show_regs(regs, !user_mode_vm(regs));
17959 + __show_regs(regs, !user_mode(regs));
17960
17961 pr_emerg("Process %.*s (pid: %d, ti=%p task=%p task.ti=%p)\n",
17962 TASK_COMM_LEN, current->comm, task_pid_nr(current),
17963 @@ -95,21 +93,22 @@ void show_regs(struct pt_regs *regs)
17964 * When in-kernel, we also print out the stack and code at the
17965 * time of the fault..
17966 */
17967 - if (!user_mode_vm(regs)) {
17968 + if (!user_mode(regs)) {
17969 unsigned int code_prologue = code_bytes * 43 / 64;
17970 unsigned int code_len = code_bytes;
17971 unsigned char c;
17972 u8 *ip;
17973 + unsigned long cs_base = get_desc_base(&get_cpu_gdt_table(0)[(0xffff & regs->cs) >> 3]);
17974
17975 pr_emerg("Stack:\n");
17976 show_stack_log_lvl(NULL, regs, &regs->sp, 0, KERN_EMERG);
17977
17978 pr_emerg("Code:");
17979
17980 - ip = (u8 *)regs->ip - code_prologue;
17981 + ip = (u8 *)regs->ip - code_prologue + cs_base;
17982 if (ip < (u8 *)PAGE_OFFSET || probe_kernel_address(ip, c)) {
17983 /* try starting at IP */
17984 - ip = (u8 *)regs->ip;
17985 + ip = (u8 *)regs->ip + cs_base;
17986 code_len = code_len - code_prologue + 1;
17987 }
17988 for (i = 0; i < code_len; i++, ip++) {
17989 @@ -118,7 +117,7 @@ void show_regs(struct pt_regs *regs)
17990 pr_cont(" Bad EIP value.");
17991 break;
17992 }
17993 - if (ip == (u8 *)regs->ip)
17994 + if (ip == (u8 *)regs->ip + cs_base)
17995 pr_cont(" <%02x>", c);
17996 else
17997 pr_cont(" %02x", c);
17998 @@ -131,6 +130,7 @@ int is_valid_bugaddr(unsigned long ip)
17999 {
18000 unsigned short ud2;
18001
18002 + ip = ktla_ktva(ip);
18003 if (ip < PAGE_OFFSET)
18004 return 0;
18005 if (probe_kernel_address((unsigned short *)ip, ud2))
18006 @@ -138,3 +138,15 @@ int is_valid_bugaddr(unsigned long ip)
18007
18008 return ud2 == 0x0b0f;
18009 }
18010 +
18011 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
18012 +void pax_check_alloca(unsigned long size)
18013 +{
18014 + unsigned long sp = (unsigned long)&sp, stack_left;
18015 +
18016 + /* all kernel stacks are of the same size */
18017 + stack_left = sp & (THREAD_SIZE - 1);
18018 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
18019 +}
18020 +EXPORT_SYMBOL(pax_check_alloca);
18021 +#endif
18022 diff --git a/arch/x86/kernel/dumpstack_64.c b/arch/x86/kernel/dumpstack_64.c
18023 index b653675..51cc8c0 100644
18024 --- a/arch/x86/kernel/dumpstack_64.c
18025 +++ b/arch/x86/kernel/dumpstack_64.c
18026 @@ -119,9 +119,9 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18027 unsigned long *irq_stack_end =
18028 (unsigned long *)per_cpu(irq_stack_ptr, cpu);
18029 unsigned used = 0;
18030 - struct thread_info *tinfo;
18031 int graph = 0;
18032 unsigned long dummy;
18033 + void *stack_start;
18034
18035 if (!task)
18036 task = current;
18037 @@ -142,10 +142,10 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18038 * current stack address. If the stacks consist of nested
18039 * exceptions
18040 */
18041 - tinfo = task_thread_info(task);
18042 for (;;) {
18043 char *id;
18044 unsigned long *estack_end;
18045 +
18046 estack_end = in_exception_stack(cpu, (unsigned long)stack,
18047 &used, &id);
18048
18049 @@ -153,7 +153,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18050 if (ops->stack(data, id) < 0)
18051 break;
18052
18053 - bp = ops->walk_stack(tinfo, stack, bp, ops,
18054 + bp = ops->walk_stack(task, estack_end - EXCEPTION_STKSZ, stack, bp, ops,
18055 data, estack_end, &graph);
18056 ops->stack(data, "<EOE>");
18057 /*
18058 @@ -161,6 +161,8 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18059 * second-to-last pointer (index -2 to end) in the
18060 * exception stack:
18061 */
18062 + if ((u16)estack_end[-1] != __KERNEL_DS)
18063 + goto out;
18064 stack = (unsigned long *) estack_end[-2];
18065 continue;
18066 }
18067 @@ -172,7 +174,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18068 if (in_irq_stack(stack, irq_stack, irq_stack_end)) {
18069 if (ops->stack(data, "IRQ") < 0)
18070 break;
18071 - bp = ops->walk_stack(tinfo, stack, bp,
18072 + bp = ops->walk_stack(task, irq_stack, stack, bp,
18073 ops, data, irq_stack_end, &graph);
18074 /*
18075 * We link to the next stack (which would be
18076 @@ -191,7 +193,9 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18077 /*
18078 * This handles the process stack:
18079 */
18080 - bp = ops->walk_stack(tinfo, stack, bp, ops, data, NULL, &graph);
18081 + stack_start = (void *)((unsigned long)stack & ~(THREAD_SIZE-1));
18082 + bp = ops->walk_stack(task, stack_start, stack, bp, ops, data, NULL, &graph);
18083 +out:
18084 put_cpu();
18085 }
18086 EXPORT_SYMBOL(dump_trace);
18087 @@ -249,7 +253,7 @@ void show_regs(struct pt_regs *regs)
18088 {
18089 int i;
18090 unsigned long sp;
18091 - const int cpu = smp_processor_id();
18092 + const int cpu = raw_smp_processor_id();
18093 struct task_struct *cur = current;
18094
18095 sp = regs->sp;
18096 @@ -304,3 +308,50 @@ int is_valid_bugaddr(unsigned long ip)
18097
18098 return ud2 == 0x0b0f;
18099 }
18100 +
18101 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
18102 +void pax_check_alloca(unsigned long size)
18103 +{
18104 + unsigned long sp = (unsigned long)&sp, stack_start, stack_end;
18105 + unsigned cpu, used;
18106 + char *id;
18107 +
18108 + /* check the process stack first */
18109 + stack_start = (unsigned long)task_stack_page(current);
18110 + stack_end = stack_start + THREAD_SIZE;
18111 + if (likely(stack_start <= sp && sp < stack_end)) {
18112 + unsigned long stack_left = sp & (THREAD_SIZE - 1);
18113 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
18114 + return;
18115 + }
18116 +
18117 + cpu = get_cpu();
18118 +
18119 + /* check the irq stacks */
18120 + stack_end = (unsigned long)per_cpu(irq_stack_ptr, cpu);
18121 + stack_start = stack_end - IRQ_STACK_SIZE;
18122 + if (stack_start <= sp && sp < stack_end) {
18123 + unsigned long stack_left = sp & (IRQ_STACK_SIZE - 1);
18124 + put_cpu();
18125 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
18126 + return;
18127 + }
18128 +
18129 + /* check the exception stacks */
18130 + used = 0;
18131 + stack_end = (unsigned long)in_exception_stack(cpu, sp, &used, &id);
18132 + stack_start = stack_end - EXCEPTION_STKSZ;
18133 + if (stack_end && stack_start <= sp && sp < stack_end) {
18134 + unsigned long stack_left = sp & (EXCEPTION_STKSZ - 1);
18135 + put_cpu();
18136 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
18137 + return;
18138 + }
18139 +
18140 + put_cpu();
18141 +
18142 + /* unknown stack */
18143 + BUG();
18144 +}
18145 +EXPORT_SYMBOL(pax_check_alloca);
18146 +#endif
18147 diff --git a/arch/x86/kernel/early_printk.c b/arch/x86/kernel/early_printk.c
18148 index 9b9f18b..9fcaa04 100644
18149 --- a/arch/x86/kernel/early_printk.c
18150 +++ b/arch/x86/kernel/early_printk.c
18151 @@ -7,6 +7,7 @@
18152 #include <linux/pci_regs.h>
18153 #include <linux/pci_ids.h>
18154 #include <linux/errno.h>
18155 +#include <linux/sched.h>
18156 #include <asm/io.h>
18157 #include <asm/processor.h>
18158 #include <asm/fcntl.h>
18159 diff --git a/arch/x86/kernel/entry_32.S b/arch/x86/kernel/entry_32.S
18160 index 8f3e2de..934870f 100644
18161 --- a/arch/x86/kernel/entry_32.S
18162 +++ b/arch/x86/kernel/entry_32.S
18163 @@ -177,13 +177,153 @@
18164 /*CFI_REL_OFFSET gs, PT_GS*/
18165 .endm
18166 .macro SET_KERNEL_GS reg
18167 +
18168 +#ifdef CONFIG_CC_STACKPROTECTOR
18169 movl $(__KERNEL_STACK_CANARY), \reg
18170 +#elif defined(CONFIG_PAX_MEMORY_UDEREF)
18171 + movl $(__USER_DS), \reg
18172 +#else
18173 + xorl \reg, \reg
18174 +#endif
18175 +
18176 movl \reg, %gs
18177 .endm
18178
18179 #endif /* CONFIG_X86_32_LAZY_GS */
18180
18181 -.macro SAVE_ALL
18182 +.macro pax_enter_kernel
18183 +#ifdef CONFIG_PAX_KERNEXEC
18184 + call pax_enter_kernel
18185 +#endif
18186 +.endm
18187 +
18188 +.macro pax_exit_kernel
18189 +#ifdef CONFIG_PAX_KERNEXEC
18190 + call pax_exit_kernel
18191 +#endif
18192 +.endm
18193 +
18194 +#ifdef CONFIG_PAX_KERNEXEC
18195 +ENTRY(pax_enter_kernel)
18196 +#ifdef CONFIG_PARAVIRT
18197 + pushl %eax
18198 + pushl %ecx
18199 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0)
18200 + mov %eax, %esi
18201 +#else
18202 + mov %cr0, %esi
18203 +#endif
18204 + bts $16, %esi
18205 + jnc 1f
18206 + mov %cs, %esi
18207 + cmp $__KERNEL_CS, %esi
18208 + jz 3f
18209 + ljmp $__KERNEL_CS, $3f
18210 +1: ljmp $__KERNEXEC_KERNEL_CS, $2f
18211 +2:
18212 +#ifdef CONFIG_PARAVIRT
18213 + mov %esi, %eax
18214 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0)
18215 +#else
18216 + mov %esi, %cr0
18217 +#endif
18218 +3:
18219 +#ifdef CONFIG_PARAVIRT
18220 + popl %ecx
18221 + popl %eax
18222 +#endif
18223 + ret
18224 +ENDPROC(pax_enter_kernel)
18225 +
18226 +ENTRY(pax_exit_kernel)
18227 +#ifdef CONFIG_PARAVIRT
18228 + pushl %eax
18229 + pushl %ecx
18230 +#endif
18231 + mov %cs, %esi
18232 + cmp $__KERNEXEC_KERNEL_CS, %esi
18233 + jnz 2f
18234 +#ifdef CONFIG_PARAVIRT
18235 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0);
18236 + mov %eax, %esi
18237 +#else
18238 + mov %cr0, %esi
18239 +#endif
18240 + btr $16, %esi
18241 + ljmp $__KERNEL_CS, $1f
18242 +1:
18243 +#ifdef CONFIG_PARAVIRT
18244 + mov %esi, %eax
18245 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0);
18246 +#else
18247 + mov %esi, %cr0
18248 +#endif
18249 +2:
18250 +#ifdef CONFIG_PARAVIRT
18251 + popl %ecx
18252 + popl %eax
18253 +#endif
18254 + ret
18255 +ENDPROC(pax_exit_kernel)
18256 +#endif
18257 +
18258 +.macro pax_erase_kstack
18259 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
18260 + call pax_erase_kstack
18261 +#endif
18262 +.endm
18263 +
18264 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
18265 +/*
18266 + * ebp: thread_info
18267 + */
18268 +ENTRY(pax_erase_kstack)
18269 + pushl %edi
18270 + pushl %ecx
18271 + pushl %eax
18272 +
18273 + mov TI_lowest_stack(%ebp), %edi
18274 + mov $-0xBEEF, %eax
18275 + std
18276 +
18277 +1: mov %edi, %ecx
18278 + and $THREAD_SIZE_asm - 1, %ecx
18279 + shr $2, %ecx
18280 + repne scasl
18281 + jecxz 2f
18282 +
18283 + cmp $2*16, %ecx
18284 + jc 2f
18285 +
18286 + mov $2*16, %ecx
18287 + repe scasl
18288 + jecxz 2f
18289 + jne 1b
18290 +
18291 +2: cld
18292 + mov %esp, %ecx
18293 + sub %edi, %ecx
18294 +
18295 + cmp $THREAD_SIZE_asm, %ecx
18296 + jb 3f
18297 + ud2
18298 +3:
18299 +
18300 + shr $2, %ecx
18301 + rep stosl
18302 +
18303 + mov TI_task_thread_sp0(%ebp), %edi
18304 + sub $128, %edi
18305 + mov %edi, TI_lowest_stack(%ebp)
18306 +
18307 + popl %eax
18308 + popl %ecx
18309 + popl %edi
18310 + ret
18311 +ENDPROC(pax_erase_kstack)
18312 +#endif
18313 +
18314 +.macro __SAVE_ALL _DS
18315 cld
18316 PUSH_GS
18317 pushl_cfi %fs
18318 @@ -206,7 +346,7 @@
18319 CFI_REL_OFFSET ecx, 0
18320 pushl_cfi %ebx
18321 CFI_REL_OFFSET ebx, 0
18322 - movl $(__USER_DS), %edx
18323 + movl $\_DS, %edx
18324 movl %edx, %ds
18325 movl %edx, %es
18326 movl $(__KERNEL_PERCPU), %edx
18327 @@ -214,6 +354,15 @@
18328 SET_KERNEL_GS %edx
18329 .endm
18330
18331 +.macro SAVE_ALL
18332 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
18333 + __SAVE_ALL __KERNEL_DS
18334 + pax_enter_kernel
18335 +#else
18336 + __SAVE_ALL __USER_DS
18337 +#endif
18338 +.endm
18339 +
18340 .macro RESTORE_INT_REGS
18341 popl_cfi %ebx
18342 CFI_RESTORE ebx
18343 @@ -297,7 +446,7 @@ ENTRY(ret_from_fork)
18344 popfl_cfi
18345 jmp syscall_exit
18346 CFI_ENDPROC
18347 -END(ret_from_fork)
18348 +ENDPROC(ret_from_fork)
18349
18350 ENTRY(ret_from_kernel_thread)
18351 CFI_STARTPROC
18352 @@ -344,7 +493,15 @@ ret_from_intr:
18353 andl $SEGMENT_RPL_MASK, %eax
18354 #endif
18355 cmpl $USER_RPL, %eax
18356 +
18357 +#ifdef CONFIG_PAX_KERNEXEC
18358 + jae resume_userspace
18359 +
18360 + pax_exit_kernel
18361 + jmp resume_kernel
18362 +#else
18363 jb resume_kernel # not returning to v8086 or userspace
18364 +#endif
18365
18366 ENTRY(resume_userspace)
18367 LOCKDEP_SYS_EXIT
18368 @@ -356,8 +513,8 @@ ENTRY(resume_userspace)
18369 andl $_TIF_WORK_MASK, %ecx # is there any work to be done on
18370 # int/exception return?
18371 jne work_pending
18372 - jmp restore_all
18373 -END(ret_from_exception)
18374 + jmp restore_all_pax
18375 +ENDPROC(ret_from_exception)
18376
18377 #ifdef CONFIG_PREEMPT
18378 ENTRY(resume_kernel)
18379 @@ -372,7 +529,7 @@ need_resched:
18380 jz restore_all
18381 call preempt_schedule_irq
18382 jmp need_resched
18383 -END(resume_kernel)
18384 +ENDPROC(resume_kernel)
18385 #endif
18386 CFI_ENDPROC
18387 /*
18388 @@ -406,30 +563,45 @@ sysenter_past_esp:
18389 /*CFI_REL_OFFSET cs, 0*/
18390 /*
18391 * Push current_thread_info()->sysenter_return to the stack.
18392 - * A tiny bit of offset fixup is necessary - 4*4 means the 4 words
18393 - * pushed above; +8 corresponds to copy_thread's esp0 setting.
18394 */
18395 - pushl_cfi ((TI_sysenter_return)-THREAD_SIZE+8+4*4)(%esp)
18396 + pushl_cfi $0
18397 CFI_REL_OFFSET eip, 0
18398
18399 pushl_cfi %eax
18400 SAVE_ALL
18401 + GET_THREAD_INFO(%ebp)
18402 + movl TI_sysenter_return(%ebp),%ebp
18403 + movl %ebp,PT_EIP(%esp)
18404 ENABLE_INTERRUPTS(CLBR_NONE)
18405
18406 /*
18407 * Load the potential sixth argument from user stack.
18408 * Careful about security.
18409 */
18410 + movl PT_OLDESP(%esp),%ebp
18411 +
18412 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18413 + mov PT_OLDSS(%esp),%ds
18414 +1: movl %ds:(%ebp),%ebp
18415 + push %ss
18416 + pop %ds
18417 +#else
18418 cmpl $__PAGE_OFFSET-3,%ebp
18419 jae syscall_fault
18420 ASM_STAC
18421 1: movl (%ebp),%ebp
18422 ASM_CLAC
18423 +#endif
18424 +
18425 movl %ebp,PT_EBP(%esp)
18426 _ASM_EXTABLE(1b,syscall_fault)
18427
18428 GET_THREAD_INFO(%ebp)
18429
18430 +#ifdef CONFIG_PAX_RANDKSTACK
18431 + pax_erase_kstack
18432 +#endif
18433 +
18434 testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%ebp)
18435 jnz sysenter_audit
18436 sysenter_do_call:
18437 @@ -444,12 +616,24 @@ sysenter_do_call:
18438 testl $_TIF_ALLWORK_MASK, %ecx
18439 jne sysexit_audit
18440 sysenter_exit:
18441 +
18442 +#ifdef CONFIG_PAX_RANDKSTACK
18443 + pushl_cfi %eax
18444 + movl %esp, %eax
18445 + call pax_randomize_kstack
18446 + popl_cfi %eax
18447 +#endif
18448 +
18449 + pax_erase_kstack
18450 +
18451 /* if something modifies registers it must also disable sysexit */
18452 movl PT_EIP(%esp), %edx
18453 movl PT_OLDESP(%esp), %ecx
18454 xorl %ebp,%ebp
18455 TRACE_IRQS_ON
18456 1: mov PT_FS(%esp), %fs
18457 +2: mov PT_DS(%esp), %ds
18458 +3: mov PT_ES(%esp), %es
18459 PTGS_TO_GS
18460 ENABLE_INTERRUPTS_SYSEXIT
18461
18462 @@ -466,6 +650,9 @@ sysenter_audit:
18463 movl %eax,%edx /* 2nd arg: syscall number */
18464 movl $AUDIT_ARCH_I386,%eax /* 1st arg: audit arch */
18465 call __audit_syscall_entry
18466 +
18467 + pax_erase_kstack
18468 +
18469 pushl_cfi %ebx
18470 movl PT_EAX(%esp),%eax /* reload syscall number */
18471 jmp sysenter_do_call
18472 @@ -491,10 +678,16 @@ sysexit_audit:
18473
18474 CFI_ENDPROC
18475 .pushsection .fixup,"ax"
18476 -2: movl $0,PT_FS(%esp)
18477 +4: movl $0,PT_FS(%esp)
18478 + jmp 1b
18479 +5: movl $0,PT_DS(%esp)
18480 + jmp 1b
18481 +6: movl $0,PT_ES(%esp)
18482 jmp 1b
18483 .popsection
18484 - _ASM_EXTABLE(1b,2b)
18485 + _ASM_EXTABLE(1b,4b)
18486 + _ASM_EXTABLE(2b,5b)
18487 + _ASM_EXTABLE(3b,6b)
18488 PTGS_TO_GS_EX
18489 ENDPROC(ia32_sysenter_target)
18490
18491 @@ -509,6 +702,11 @@ ENTRY(system_call)
18492 pushl_cfi %eax # save orig_eax
18493 SAVE_ALL
18494 GET_THREAD_INFO(%ebp)
18495 +
18496 +#ifdef CONFIG_PAX_RANDKSTACK
18497 + pax_erase_kstack
18498 +#endif
18499 +
18500 # system call tracing in operation / emulation
18501 testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%ebp)
18502 jnz syscall_trace_entry
18503 @@ -527,6 +725,15 @@ syscall_exit:
18504 testl $_TIF_ALLWORK_MASK, %ecx # current->work
18505 jne syscall_exit_work
18506
18507 +restore_all_pax:
18508 +
18509 +#ifdef CONFIG_PAX_RANDKSTACK
18510 + movl %esp, %eax
18511 + call pax_randomize_kstack
18512 +#endif
18513 +
18514 + pax_erase_kstack
18515 +
18516 restore_all:
18517 TRACE_IRQS_IRET
18518 restore_all_notrace:
18519 @@ -583,14 +790,34 @@ ldt_ss:
18520 * compensating for the offset by changing to the ESPFIX segment with
18521 * a base address that matches for the difference.
18522 */
18523 -#define GDT_ESPFIX_SS PER_CPU_VAR(gdt_page) + (GDT_ENTRY_ESPFIX_SS * 8)
18524 +#define GDT_ESPFIX_SS (GDT_ENTRY_ESPFIX_SS * 8)(%ebx)
18525 mov %esp, %edx /* load kernel esp */
18526 mov PT_OLDESP(%esp), %eax /* load userspace esp */
18527 mov %dx, %ax /* eax: new kernel esp */
18528 sub %eax, %edx /* offset (low word is 0) */
18529 +#ifdef CONFIG_SMP
18530 + movl PER_CPU_VAR(cpu_number), %ebx
18531 + shll $PAGE_SHIFT_asm, %ebx
18532 + addl $cpu_gdt_table, %ebx
18533 +#else
18534 + movl $cpu_gdt_table, %ebx
18535 +#endif
18536 shr $16, %edx
18537 - mov %dl, GDT_ESPFIX_SS + 4 /* bits 16..23 */
18538 - mov %dh, GDT_ESPFIX_SS + 7 /* bits 24..31 */
18539 +
18540 +#ifdef CONFIG_PAX_KERNEXEC
18541 + mov %cr0, %esi
18542 + btr $16, %esi
18543 + mov %esi, %cr0
18544 +#endif
18545 +
18546 + mov %dl, 4 + GDT_ESPFIX_SS /* bits 16..23 */
18547 + mov %dh, 7 + GDT_ESPFIX_SS /* bits 24..31 */
18548 +
18549 +#ifdef CONFIG_PAX_KERNEXEC
18550 + bts $16, %esi
18551 + mov %esi, %cr0
18552 +#endif
18553 +
18554 pushl_cfi $__ESPFIX_SS
18555 pushl_cfi %eax /* new kernel esp */
18556 /* Disable interrupts, but do not irqtrace this section: we
18557 @@ -619,20 +846,18 @@ work_resched:
18558 movl TI_flags(%ebp), %ecx
18559 andl $_TIF_WORK_MASK, %ecx # is there any work to be done other
18560 # than syscall tracing?
18561 - jz restore_all
18562 + jz restore_all_pax
18563 testb $_TIF_NEED_RESCHED, %cl
18564 jnz work_resched
18565
18566 work_notifysig: # deal with pending signals and
18567 # notify-resume requests
18568 + movl %esp, %eax
18569 #ifdef CONFIG_VM86
18570 testl $X86_EFLAGS_VM, PT_EFLAGS(%esp)
18571 - movl %esp, %eax
18572 jne work_notifysig_v86 # returning to kernel-space or
18573 # vm86-space
18574 1:
18575 -#else
18576 - movl %esp, %eax
18577 #endif
18578 TRACE_IRQS_ON
18579 ENABLE_INTERRUPTS(CLBR_NONE)
18580 @@ -653,7 +878,7 @@ work_notifysig_v86:
18581 movl %eax, %esp
18582 jmp 1b
18583 #endif
18584 -END(work_pending)
18585 +ENDPROC(work_pending)
18586
18587 # perform syscall exit tracing
18588 ALIGN
18589 @@ -661,11 +886,14 @@ syscall_trace_entry:
18590 movl $-ENOSYS,PT_EAX(%esp)
18591 movl %esp, %eax
18592 call syscall_trace_enter
18593 +
18594 + pax_erase_kstack
18595 +
18596 /* What it returned is what we'll actually use. */
18597 cmpl $(NR_syscalls), %eax
18598 jnae syscall_call
18599 jmp syscall_exit
18600 -END(syscall_trace_entry)
18601 +ENDPROC(syscall_trace_entry)
18602
18603 # perform syscall exit tracing
18604 ALIGN
18605 @@ -678,21 +906,25 @@ syscall_exit_work:
18606 movl %esp, %eax
18607 call syscall_trace_leave
18608 jmp resume_userspace
18609 -END(syscall_exit_work)
18610 +ENDPROC(syscall_exit_work)
18611 CFI_ENDPROC
18612
18613 RING0_INT_FRAME # can't unwind into user space anyway
18614 syscall_fault:
18615 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18616 + push %ss
18617 + pop %ds
18618 +#endif
18619 ASM_CLAC
18620 GET_THREAD_INFO(%ebp)
18621 movl $-EFAULT,PT_EAX(%esp)
18622 jmp resume_userspace
18623 -END(syscall_fault)
18624 +ENDPROC(syscall_fault)
18625
18626 syscall_badsys:
18627 movl $-ENOSYS,PT_EAX(%esp)
18628 jmp resume_userspace
18629 -END(syscall_badsys)
18630 +ENDPROC(syscall_badsys)
18631 CFI_ENDPROC
18632 /*
18633 * End of kprobes section
18634 @@ -708,8 +940,15 @@ END(syscall_badsys)
18635 * normal stack and adjusts ESP with the matching offset.
18636 */
18637 /* fixup the stack */
18638 - mov GDT_ESPFIX_SS + 4, %al /* bits 16..23 */
18639 - mov GDT_ESPFIX_SS + 7, %ah /* bits 24..31 */
18640 +#ifdef CONFIG_SMP
18641 + movl PER_CPU_VAR(cpu_number), %ebx
18642 + shll $PAGE_SHIFT_asm, %ebx
18643 + addl $cpu_gdt_table, %ebx
18644 +#else
18645 + movl $cpu_gdt_table, %ebx
18646 +#endif
18647 + mov 4 + GDT_ESPFIX_SS, %al /* bits 16..23 */
18648 + mov 7 + GDT_ESPFIX_SS, %ah /* bits 24..31 */
18649 shl $16, %eax
18650 addl %esp, %eax /* the adjusted stack pointer */
18651 pushl_cfi $__KERNEL_DS
18652 @@ -762,7 +1001,7 @@ vector=vector+1
18653 .endr
18654 2: jmp common_interrupt
18655 .endr
18656 -END(irq_entries_start)
18657 +ENDPROC(irq_entries_start)
18658
18659 .previous
18660 END(interrupt)
18661 @@ -813,7 +1052,7 @@ ENTRY(coprocessor_error)
18662 pushl_cfi $do_coprocessor_error
18663 jmp error_code
18664 CFI_ENDPROC
18665 -END(coprocessor_error)
18666 +ENDPROC(coprocessor_error)
18667
18668 ENTRY(simd_coprocessor_error)
18669 RING0_INT_FRAME
18670 @@ -835,7 +1074,7 @@ ENTRY(simd_coprocessor_error)
18671 #endif
18672 jmp error_code
18673 CFI_ENDPROC
18674 -END(simd_coprocessor_error)
18675 +ENDPROC(simd_coprocessor_error)
18676
18677 ENTRY(device_not_available)
18678 RING0_INT_FRAME
18679 @@ -844,18 +1083,18 @@ ENTRY(device_not_available)
18680 pushl_cfi $do_device_not_available
18681 jmp error_code
18682 CFI_ENDPROC
18683 -END(device_not_available)
18684 +ENDPROC(device_not_available)
18685
18686 #ifdef CONFIG_PARAVIRT
18687 ENTRY(native_iret)
18688 iret
18689 _ASM_EXTABLE(native_iret, iret_exc)
18690 -END(native_iret)
18691 +ENDPROC(native_iret)
18692
18693 ENTRY(native_irq_enable_sysexit)
18694 sti
18695 sysexit
18696 -END(native_irq_enable_sysexit)
18697 +ENDPROC(native_irq_enable_sysexit)
18698 #endif
18699
18700 ENTRY(overflow)
18701 @@ -865,7 +1104,7 @@ ENTRY(overflow)
18702 pushl_cfi $do_overflow
18703 jmp error_code
18704 CFI_ENDPROC
18705 -END(overflow)
18706 +ENDPROC(overflow)
18707
18708 ENTRY(bounds)
18709 RING0_INT_FRAME
18710 @@ -874,7 +1113,7 @@ ENTRY(bounds)
18711 pushl_cfi $do_bounds
18712 jmp error_code
18713 CFI_ENDPROC
18714 -END(bounds)
18715 +ENDPROC(bounds)
18716
18717 ENTRY(invalid_op)
18718 RING0_INT_FRAME
18719 @@ -883,7 +1122,7 @@ ENTRY(invalid_op)
18720 pushl_cfi $do_invalid_op
18721 jmp error_code
18722 CFI_ENDPROC
18723 -END(invalid_op)
18724 +ENDPROC(invalid_op)
18725
18726 ENTRY(coprocessor_segment_overrun)
18727 RING0_INT_FRAME
18728 @@ -892,7 +1131,7 @@ ENTRY(coprocessor_segment_overrun)
18729 pushl_cfi $do_coprocessor_segment_overrun
18730 jmp error_code
18731 CFI_ENDPROC
18732 -END(coprocessor_segment_overrun)
18733 +ENDPROC(coprocessor_segment_overrun)
18734
18735 ENTRY(invalid_TSS)
18736 RING0_EC_FRAME
18737 @@ -900,7 +1139,7 @@ ENTRY(invalid_TSS)
18738 pushl_cfi $do_invalid_TSS
18739 jmp error_code
18740 CFI_ENDPROC
18741 -END(invalid_TSS)
18742 +ENDPROC(invalid_TSS)
18743
18744 ENTRY(segment_not_present)
18745 RING0_EC_FRAME
18746 @@ -908,7 +1147,7 @@ ENTRY(segment_not_present)
18747 pushl_cfi $do_segment_not_present
18748 jmp error_code
18749 CFI_ENDPROC
18750 -END(segment_not_present)
18751 +ENDPROC(segment_not_present)
18752
18753 ENTRY(stack_segment)
18754 RING0_EC_FRAME
18755 @@ -916,7 +1155,7 @@ ENTRY(stack_segment)
18756 pushl_cfi $do_stack_segment
18757 jmp error_code
18758 CFI_ENDPROC
18759 -END(stack_segment)
18760 +ENDPROC(stack_segment)
18761
18762 ENTRY(alignment_check)
18763 RING0_EC_FRAME
18764 @@ -924,7 +1163,7 @@ ENTRY(alignment_check)
18765 pushl_cfi $do_alignment_check
18766 jmp error_code
18767 CFI_ENDPROC
18768 -END(alignment_check)
18769 +ENDPROC(alignment_check)
18770
18771 ENTRY(divide_error)
18772 RING0_INT_FRAME
18773 @@ -933,7 +1172,7 @@ ENTRY(divide_error)
18774 pushl_cfi $do_divide_error
18775 jmp error_code
18776 CFI_ENDPROC
18777 -END(divide_error)
18778 +ENDPROC(divide_error)
18779
18780 #ifdef CONFIG_X86_MCE
18781 ENTRY(machine_check)
18782 @@ -943,7 +1182,7 @@ ENTRY(machine_check)
18783 pushl_cfi machine_check_vector
18784 jmp error_code
18785 CFI_ENDPROC
18786 -END(machine_check)
18787 +ENDPROC(machine_check)
18788 #endif
18789
18790 ENTRY(spurious_interrupt_bug)
18791 @@ -953,7 +1192,7 @@ ENTRY(spurious_interrupt_bug)
18792 pushl_cfi $do_spurious_interrupt_bug
18793 jmp error_code
18794 CFI_ENDPROC
18795 -END(spurious_interrupt_bug)
18796 +ENDPROC(spurious_interrupt_bug)
18797 /*
18798 * End of kprobes section
18799 */
18800 @@ -1063,7 +1302,7 @@ BUILD_INTERRUPT3(hyperv_callback_vector, HYPERVISOR_CALLBACK_VECTOR,
18801
18802 ENTRY(mcount)
18803 ret
18804 -END(mcount)
18805 +ENDPROC(mcount)
18806
18807 ENTRY(ftrace_caller)
18808 cmpl $0, function_trace_stop
18809 @@ -1096,7 +1335,7 @@ ftrace_graph_call:
18810 .globl ftrace_stub
18811 ftrace_stub:
18812 ret
18813 -END(ftrace_caller)
18814 +ENDPROC(ftrace_caller)
18815
18816 ENTRY(ftrace_regs_caller)
18817 pushf /* push flags before compare (in cs location) */
18818 @@ -1197,7 +1436,7 @@ trace:
18819 popl %ecx
18820 popl %eax
18821 jmp ftrace_stub
18822 -END(mcount)
18823 +ENDPROC(mcount)
18824 #endif /* CONFIG_DYNAMIC_FTRACE */
18825 #endif /* CONFIG_FUNCTION_TRACER */
18826
18827 @@ -1215,7 +1454,7 @@ ENTRY(ftrace_graph_caller)
18828 popl %ecx
18829 popl %eax
18830 ret
18831 -END(ftrace_graph_caller)
18832 +ENDPROC(ftrace_graph_caller)
18833
18834 .globl return_to_handler
18835 return_to_handler:
18836 @@ -1271,15 +1510,18 @@ error_code:
18837 movl $-1, PT_ORIG_EAX(%esp) # no syscall to restart
18838 REG_TO_PTGS %ecx
18839 SET_KERNEL_GS %ecx
18840 - movl $(__USER_DS), %ecx
18841 + movl $(__KERNEL_DS), %ecx
18842 movl %ecx, %ds
18843 movl %ecx, %es
18844 +
18845 + pax_enter_kernel
18846 +
18847 TRACE_IRQS_OFF
18848 movl %esp,%eax # pt_regs pointer
18849 call *%edi
18850 jmp ret_from_exception
18851 CFI_ENDPROC
18852 -END(page_fault)
18853 +ENDPROC(page_fault)
18854
18855 /*
18856 * Debug traps and NMI can happen at the one SYSENTER instruction
18857 @@ -1322,7 +1564,7 @@ debug_stack_correct:
18858 call do_debug
18859 jmp ret_from_exception
18860 CFI_ENDPROC
18861 -END(debug)
18862 +ENDPROC(debug)
18863
18864 /*
18865 * NMI is doubly nasty. It can happen _while_ we're handling
18866 @@ -1360,6 +1602,9 @@ nmi_stack_correct:
18867 xorl %edx,%edx # zero error code
18868 movl %esp,%eax # pt_regs pointer
18869 call do_nmi
18870 +
18871 + pax_exit_kernel
18872 +
18873 jmp restore_all_notrace
18874 CFI_ENDPROC
18875
18876 @@ -1396,12 +1641,15 @@ nmi_espfix_stack:
18877 FIXUP_ESPFIX_STACK # %eax == %esp
18878 xorl %edx,%edx # zero error code
18879 call do_nmi
18880 +
18881 + pax_exit_kernel
18882 +
18883 RESTORE_REGS
18884 lss 12+4(%esp), %esp # back to espfix stack
18885 CFI_ADJUST_CFA_OFFSET -24
18886 jmp irq_return
18887 CFI_ENDPROC
18888 -END(nmi)
18889 +ENDPROC(nmi)
18890
18891 ENTRY(int3)
18892 RING0_INT_FRAME
18893 @@ -1414,14 +1662,14 @@ ENTRY(int3)
18894 call do_int3
18895 jmp ret_from_exception
18896 CFI_ENDPROC
18897 -END(int3)
18898 +ENDPROC(int3)
18899
18900 ENTRY(general_protection)
18901 RING0_EC_FRAME
18902 pushl_cfi $do_general_protection
18903 jmp error_code
18904 CFI_ENDPROC
18905 -END(general_protection)
18906 +ENDPROC(general_protection)
18907
18908 #ifdef CONFIG_KVM_GUEST
18909 ENTRY(async_page_fault)
18910 @@ -1430,7 +1678,7 @@ ENTRY(async_page_fault)
18911 pushl_cfi $do_async_page_fault
18912 jmp error_code
18913 CFI_ENDPROC
18914 -END(async_page_fault)
18915 +ENDPROC(async_page_fault)
18916 #endif
18917
18918 /*
18919 diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
18920 index c1d01e6..5625dce 100644
18921 --- a/arch/x86/kernel/entry_64.S
18922 +++ b/arch/x86/kernel/entry_64.S
18923 @@ -59,6 +59,8 @@
18924 #include <asm/context_tracking.h>
18925 #include <asm/smap.h>
18926 #include <linux/err.h>
18927 +#include <asm/pgtable.h>
18928 +#include <asm/alternative-asm.h>
18929
18930 /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */
18931 #include <linux/elf-em.h>
18932 @@ -80,8 +82,9 @@
18933 #ifdef CONFIG_DYNAMIC_FTRACE
18934
18935 ENTRY(function_hook)
18936 + pax_force_retaddr
18937 retq
18938 -END(function_hook)
18939 +ENDPROC(function_hook)
18940
18941 /* skip is set if stack has been adjusted */
18942 .macro ftrace_caller_setup skip=0
18943 @@ -122,8 +125,9 @@ GLOBAL(ftrace_graph_call)
18944 #endif
18945
18946 GLOBAL(ftrace_stub)
18947 + pax_force_retaddr
18948 retq
18949 -END(ftrace_caller)
18950 +ENDPROC(ftrace_caller)
18951
18952 ENTRY(ftrace_regs_caller)
18953 /* Save the current flags before compare (in SS location)*/
18954 @@ -191,7 +195,7 @@ ftrace_restore_flags:
18955 popfq
18956 jmp ftrace_stub
18957
18958 -END(ftrace_regs_caller)
18959 +ENDPROC(ftrace_regs_caller)
18960
18961
18962 #else /* ! CONFIG_DYNAMIC_FTRACE */
18963 @@ -212,6 +216,7 @@ ENTRY(function_hook)
18964 #endif
18965
18966 GLOBAL(ftrace_stub)
18967 + pax_force_retaddr
18968 retq
18969
18970 trace:
18971 @@ -225,12 +230,13 @@ trace:
18972 #endif
18973 subq $MCOUNT_INSN_SIZE, %rdi
18974
18975 + pax_force_fptr ftrace_trace_function
18976 call *ftrace_trace_function
18977
18978 MCOUNT_RESTORE_FRAME
18979
18980 jmp ftrace_stub
18981 -END(function_hook)
18982 +ENDPROC(function_hook)
18983 #endif /* CONFIG_DYNAMIC_FTRACE */
18984 #endif /* CONFIG_FUNCTION_TRACER */
18985
18986 @@ -252,8 +258,9 @@ ENTRY(ftrace_graph_caller)
18987
18988 MCOUNT_RESTORE_FRAME
18989
18990 + pax_force_retaddr
18991 retq
18992 -END(ftrace_graph_caller)
18993 +ENDPROC(ftrace_graph_caller)
18994
18995 GLOBAL(return_to_handler)
18996 subq $24, %rsp
18997 @@ -269,7 +276,9 @@ GLOBAL(return_to_handler)
18998 movq 8(%rsp), %rdx
18999 movq (%rsp), %rax
19000 addq $24, %rsp
19001 + pax_force_fptr %rdi
19002 jmp *%rdi
19003 +ENDPROC(return_to_handler)
19004 #endif
19005
19006
19007 @@ -284,6 +293,282 @@ ENTRY(native_usergs_sysret64)
19008 ENDPROC(native_usergs_sysret64)
19009 #endif /* CONFIG_PARAVIRT */
19010
19011 + .macro ljmpq sel, off
19012 +#if defined(CONFIG_MPSC) || defined(CONFIG_MCORE2) || defined (CONFIG_MATOM)
19013 + .byte 0x48; ljmp *1234f(%rip)
19014 + .pushsection .rodata
19015 + .align 16
19016 + 1234: .quad \off; .word \sel
19017 + .popsection
19018 +#else
19019 + pushq $\sel
19020 + pushq $\off
19021 + lretq
19022 +#endif
19023 + .endm
19024 +
19025 + .macro pax_enter_kernel
19026 + pax_set_fptr_mask
19027 +#ifdef CONFIG_PAX_KERNEXEC
19028 + call pax_enter_kernel
19029 +#endif
19030 + .endm
19031 +
19032 + .macro pax_exit_kernel
19033 +#ifdef CONFIG_PAX_KERNEXEC
19034 + call pax_exit_kernel
19035 +#endif
19036 + .endm
19037 +
19038 +#ifdef CONFIG_PAX_KERNEXEC
19039 +ENTRY(pax_enter_kernel)
19040 + pushq %rdi
19041 +
19042 +#ifdef CONFIG_PARAVIRT
19043 + PV_SAVE_REGS(CLBR_RDI)
19044 +#endif
19045 +
19046 + GET_CR0_INTO_RDI
19047 + bts $16,%rdi
19048 + jnc 3f
19049 + mov %cs,%edi
19050 + cmp $__KERNEL_CS,%edi
19051 + jnz 2f
19052 +1:
19053 +
19054 +#ifdef CONFIG_PARAVIRT
19055 + PV_RESTORE_REGS(CLBR_RDI)
19056 +#endif
19057 +
19058 + popq %rdi
19059 + pax_force_retaddr
19060 + retq
19061 +
19062 +2: ljmpq __KERNEL_CS,1b
19063 +3: ljmpq __KERNEXEC_KERNEL_CS,4f
19064 +4: SET_RDI_INTO_CR0
19065 + jmp 1b
19066 +ENDPROC(pax_enter_kernel)
19067 +
19068 +ENTRY(pax_exit_kernel)
19069 + pushq %rdi
19070 +
19071 +#ifdef CONFIG_PARAVIRT
19072 + PV_SAVE_REGS(CLBR_RDI)
19073 +#endif
19074 +
19075 + mov %cs,%rdi
19076 + cmp $__KERNEXEC_KERNEL_CS,%edi
19077 + jz 2f
19078 + GET_CR0_INTO_RDI
19079 + bts $16,%rdi
19080 + jnc 4f
19081 +1:
19082 +
19083 +#ifdef CONFIG_PARAVIRT
19084 + PV_RESTORE_REGS(CLBR_RDI);
19085 +#endif
19086 +
19087 + popq %rdi
19088 + pax_force_retaddr
19089 + retq
19090 +
19091 +2: GET_CR0_INTO_RDI
19092 + btr $16,%rdi
19093 + jnc 4f
19094 + ljmpq __KERNEL_CS,3f
19095 +3: SET_RDI_INTO_CR0
19096 + jmp 1b
19097 +4: ud2
19098 + jmp 4b
19099 +ENDPROC(pax_exit_kernel)
19100 +#endif
19101 +
19102 + .macro pax_enter_kernel_user
19103 + pax_set_fptr_mask
19104 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19105 + call pax_enter_kernel_user
19106 +#endif
19107 + .endm
19108 +
19109 + .macro pax_exit_kernel_user
19110 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19111 + call pax_exit_kernel_user
19112 +#endif
19113 +#ifdef CONFIG_PAX_RANDKSTACK
19114 + pushq %rax
19115 + call pax_randomize_kstack
19116 + popq %rax
19117 +#endif
19118 + .endm
19119 +
19120 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19121 +ENTRY(pax_enter_kernel_user)
19122 + pushq %rdi
19123 + pushq %rbx
19124 +
19125 +#ifdef CONFIG_PARAVIRT
19126 + PV_SAVE_REGS(CLBR_RDI)
19127 +#endif
19128 +
19129 + GET_CR3_INTO_RDI
19130 + mov %rdi,%rbx
19131 + add $__START_KERNEL_map,%rbx
19132 + sub phys_base(%rip),%rbx
19133 +
19134 +#ifdef CONFIG_PARAVIRT
19135 + pushq %rdi
19136 + cmpl $0, pv_info+PARAVIRT_enabled
19137 + jz 1f
19138 + i = 0
19139 + .rept USER_PGD_PTRS
19140 + mov i*8(%rbx),%rsi
19141 + mov $0,%sil
19142 + lea i*8(%rbx),%rdi
19143 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_set_pgd_batched)
19144 + i = i + 1
19145 + .endr
19146 + jmp 2f
19147 +1:
19148 +#endif
19149 +
19150 + i = 0
19151 + .rept USER_PGD_PTRS
19152 + movb $0,i*8(%rbx)
19153 + i = i + 1
19154 + .endr
19155 +
19156 +#ifdef CONFIG_PARAVIRT
19157 +2: popq %rdi
19158 +#endif
19159 + SET_RDI_INTO_CR3
19160 +
19161 +#ifdef CONFIG_PAX_KERNEXEC
19162 + GET_CR0_INTO_RDI
19163 + bts $16,%rdi
19164 + SET_RDI_INTO_CR0
19165 +#endif
19166 +
19167 +#ifdef CONFIG_PARAVIRT
19168 + PV_RESTORE_REGS(CLBR_RDI)
19169 +#endif
19170 +
19171 + popq %rbx
19172 + popq %rdi
19173 + pax_force_retaddr
19174 + retq
19175 +ENDPROC(pax_enter_kernel_user)
19176 +
19177 +ENTRY(pax_exit_kernel_user)
19178 + push %rdi
19179 +
19180 +#ifdef CONFIG_PARAVIRT
19181 + pushq %rbx
19182 + PV_SAVE_REGS(CLBR_RDI)
19183 +#endif
19184 +
19185 +#ifdef CONFIG_PAX_KERNEXEC
19186 + GET_CR0_INTO_RDI
19187 + btr $16,%rdi
19188 + jnc 3f
19189 + SET_RDI_INTO_CR0
19190 +#endif
19191 +
19192 + GET_CR3_INTO_RDI
19193 + add $__START_KERNEL_map,%rdi
19194 + sub phys_base(%rip),%rdi
19195 +
19196 +#ifdef CONFIG_PARAVIRT
19197 + cmpl $0, pv_info+PARAVIRT_enabled
19198 + jz 1f
19199 + mov %rdi,%rbx
19200 + i = 0
19201 + .rept USER_PGD_PTRS
19202 + mov i*8(%rbx),%rsi
19203 + mov $0x67,%sil
19204 + lea i*8(%rbx),%rdi
19205 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_set_pgd_batched)
19206 + i = i + 1
19207 + .endr
19208 + jmp 2f
19209 +1:
19210 +#endif
19211 +
19212 + i = 0
19213 + .rept USER_PGD_PTRS
19214 + movb $0x67,i*8(%rdi)
19215 + i = i + 1
19216 + .endr
19217 +
19218 +#ifdef CONFIG_PARAVIRT
19219 +2: PV_RESTORE_REGS(CLBR_RDI)
19220 + popq %rbx
19221 +#endif
19222 +
19223 + popq %rdi
19224 + pax_force_retaddr
19225 + retq
19226 +3: ud2
19227 + jmp 3b
19228 +ENDPROC(pax_exit_kernel_user)
19229 +#endif
19230 +
19231 +.macro pax_erase_kstack
19232 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
19233 + call pax_erase_kstack
19234 +#endif
19235 +.endm
19236 +
19237 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
19238 +ENTRY(pax_erase_kstack)
19239 + pushq %rdi
19240 + pushq %rcx
19241 + pushq %rax
19242 + pushq %r11
19243 +
19244 + GET_THREAD_INFO(%r11)
19245 + mov TI_lowest_stack(%r11), %rdi
19246 + mov $-0xBEEF, %rax
19247 + std
19248 +
19249 +1: mov %edi, %ecx
19250 + and $THREAD_SIZE_asm - 1, %ecx
19251 + shr $3, %ecx
19252 + repne scasq
19253 + jecxz 2f
19254 +
19255 + cmp $2*8, %ecx
19256 + jc 2f
19257 +
19258 + mov $2*8, %ecx
19259 + repe scasq
19260 + jecxz 2f
19261 + jne 1b
19262 +
19263 +2: cld
19264 + mov %esp, %ecx
19265 + sub %edi, %ecx
19266 +
19267 + cmp $THREAD_SIZE_asm, %rcx
19268 + jb 3f
19269 + ud2
19270 +3:
19271 +
19272 + shr $3, %ecx
19273 + rep stosq
19274 +
19275 + mov TI_task_thread_sp0(%r11), %rdi
19276 + sub $256, %rdi
19277 + mov %rdi, TI_lowest_stack(%r11)
19278 +
19279 + popq %r11
19280 + popq %rax
19281 + popq %rcx
19282 + popq %rdi
19283 + pax_force_retaddr
19284 + ret
19285 +ENDPROC(pax_erase_kstack)
19286 +#endif
19287
19288 .macro TRACE_IRQS_IRETQ offset=ARGOFFSET
19289 #ifdef CONFIG_TRACE_IRQFLAGS
19290 @@ -375,8 +660,8 @@ ENDPROC(native_usergs_sysret64)
19291 .endm
19292
19293 .macro UNFAKE_STACK_FRAME
19294 - addq $8*6, %rsp
19295 - CFI_ADJUST_CFA_OFFSET -(6*8)
19296 + addq $8*6 + ARG_SKIP, %rsp
19297 + CFI_ADJUST_CFA_OFFSET -(6*8 + ARG_SKIP)
19298 .endm
19299
19300 /*
19301 @@ -463,7 +748,7 @@ ENDPROC(native_usergs_sysret64)
19302 movq %rsp, %rsi
19303
19304 leaq -RBP(%rsp),%rdi /* arg1 for handler */
19305 - testl $3, CS-RBP(%rsi)
19306 + testb $3, CS-RBP(%rsi)
19307 je 1f
19308 SWAPGS
19309 /*
19310 @@ -498,9 +783,10 @@ ENTRY(save_rest)
19311 movq_cfi r15, R15+16
19312 movq %r11, 8(%rsp) /* return address */
19313 FIXUP_TOP_OF_STACK %r11, 16
19314 + pax_force_retaddr
19315 ret
19316 CFI_ENDPROC
19317 -END(save_rest)
19318 +ENDPROC(save_rest)
19319
19320 /* save complete stack frame */
19321 .pushsection .kprobes.text, "ax"
19322 @@ -529,9 +815,10 @@ ENTRY(save_paranoid)
19323 js 1f /* negative -> in kernel */
19324 SWAPGS
19325 xorl %ebx,%ebx
19326 -1: ret
19327 +1: pax_force_retaddr_bts
19328 + ret
19329 CFI_ENDPROC
19330 -END(save_paranoid)
19331 +ENDPROC(save_paranoid)
19332 .popsection
19333
19334 /*
19335 @@ -553,7 +840,7 @@ ENTRY(ret_from_fork)
19336
19337 RESTORE_REST
19338
19339 - testl $3, CS-ARGOFFSET(%rsp) # from kernel_thread?
19340 + testb $3, CS-ARGOFFSET(%rsp) # from kernel_thread?
19341 jz 1f
19342
19343 testl $_TIF_IA32, TI_flags(%rcx) # 32-bit compat task needs IRET
19344 @@ -571,7 +858,7 @@ ENTRY(ret_from_fork)
19345 RESTORE_REST
19346 jmp int_ret_from_sys_call
19347 CFI_ENDPROC
19348 -END(ret_from_fork)
19349 +ENDPROC(ret_from_fork)
19350
19351 /*
19352 * System call entry. Up to 6 arguments in registers are supported.
19353 @@ -608,7 +895,7 @@ END(ret_from_fork)
19354 ENTRY(system_call)
19355 CFI_STARTPROC simple
19356 CFI_SIGNAL_FRAME
19357 - CFI_DEF_CFA rsp,KERNEL_STACK_OFFSET
19358 + CFI_DEF_CFA rsp,0
19359 CFI_REGISTER rip,rcx
19360 /*CFI_REGISTER rflags,r11*/
19361 SWAPGS_UNSAFE_STACK
19362 @@ -621,16 +908,23 @@ GLOBAL(system_call_after_swapgs)
19363
19364 movq %rsp,PER_CPU_VAR(old_rsp)
19365 movq PER_CPU_VAR(kernel_stack),%rsp
19366 + SAVE_ARGS 8*6,0
19367 + pax_enter_kernel_user
19368 +
19369 +#ifdef CONFIG_PAX_RANDKSTACK
19370 + pax_erase_kstack
19371 +#endif
19372 +
19373 /*
19374 * No need to follow this irqs off/on section - it's straight
19375 * and short:
19376 */
19377 ENABLE_INTERRUPTS(CLBR_NONE)
19378 - SAVE_ARGS 8,0
19379 movq %rax,ORIG_RAX-ARGOFFSET(%rsp)
19380 movq %rcx,RIP-ARGOFFSET(%rsp)
19381 CFI_REL_OFFSET rip,RIP-ARGOFFSET
19382 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
19383 + GET_THREAD_INFO(%rcx)
19384 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%rcx)
19385 jnz tracesys
19386 system_call_fastpath:
19387 #if __SYSCALL_MASK == ~0
19388 @@ -640,7 +934,7 @@ system_call_fastpath:
19389 cmpl $__NR_syscall_max,%eax
19390 #endif
19391 ja badsys
19392 - movq %r10,%rcx
19393 + movq R10-ARGOFFSET(%rsp),%rcx
19394 call *sys_call_table(,%rax,8) # XXX: rip relative
19395 movq %rax,RAX-ARGOFFSET(%rsp)
19396 /*
19397 @@ -654,10 +948,13 @@ sysret_check:
19398 LOCKDEP_SYS_EXIT
19399 DISABLE_INTERRUPTS(CLBR_NONE)
19400 TRACE_IRQS_OFF
19401 - movl TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET),%edx
19402 + GET_THREAD_INFO(%rcx)
19403 + movl TI_flags(%rcx),%edx
19404 andl %edi,%edx
19405 jnz sysret_careful
19406 CFI_REMEMBER_STATE
19407 + pax_exit_kernel_user
19408 + pax_erase_kstack
19409 /*
19410 * sysretq will re-enable interrupts:
19411 */
19412 @@ -709,14 +1006,18 @@ badsys:
19413 * jump back to the normal fast path.
19414 */
19415 auditsys:
19416 - movq %r10,%r9 /* 6th arg: 4th syscall arg */
19417 + movq R10-ARGOFFSET(%rsp),%r9 /* 6th arg: 4th syscall arg */
19418 movq %rdx,%r8 /* 5th arg: 3rd syscall arg */
19419 movq %rsi,%rcx /* 4th arg: 2nd syscall arg */
19420 movq %rdi,%rdx /* 3rd arg: 1st syscall arg */
19421 movq %rax,%rsi /* 2nd arg: syscall number */
19422 movl $AUDIT_ARCH_X86_64,%edi /* 1st arg: audit arch */
19423 call __audit_syscall_entry
19424 +
19425 + pax_erase_kstack
19426 +
19427 LOAD_ARGS 0 /* reload call-clobbered registers */
19428 + pax_set_fptr_mask
19429 jmp system_call_fastpath
19430
19431 /*
19432 @@ -737,7 +1038,7 @@ sysret_audit:
19433 /* Do syscall tracing */
19434 tracesys:
19435 #ifdef CONFIG_AUDITSYSCALL
19436 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
19437 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%rcx)
19438 jz auditsys
19439 #endif
19440 SAVE_REST
19441 @@ -745,12 +1046,16 @@ tracesys:
19442 FIXUP_TOP_OF_STACK %rdi
19443 movq %rsp,%rdi
19444 call syscall_trace_enter
19445 +
19446 + pax_erase_kstack
19447 +
19448 /*
19449 * Reload arg registers from stack in case ptrace changed them.
19450 * We don't reload %rax because syscall_trace_enter() returned
19451 * the value it wants us to use in the table lookup.
19452 */
19453 LOAD_ARGS ARGOFFSET, 1
19454 + pax_set_fptr_mask
19455 RESTORE_REST
19456 #if __SYSCALL_MASK == ~0
19457 cmpq $__NR_syscall_max,%rax
19458 @@ -759,7 +1064,7 @@ tracesys:
19459 cmpl $__NR_syscall_max,%eax
19460 #endif
19461 ja int_ret_from_sys_call /* RAX(%rsp) set to -ENOSYS above */
19462 - movq %r10,%rcx /* fixup for C */
19463 + movq R10-ARGOFFSET(%rsp),%rcx /* fixup for C */
19464 call *sys_call_table(,%rax,8)
19465 movq %rax,RAX-ARGOFFSET(%rsp)
19466 /* Use IRET because user could have changed frame */
19467 @@ -780,7 +1085,9 @@ GLOBAL(int_with_check)
19468 andl %edi,%edx
19469 jnz int_careful
19470 andl $~TS_COMPAT,TI_status(%rcx)
19471 - jmp retint_swapgs
19472 + pax_exit_kernel_user
19473 + pax_erase_kstack
19474 + jmp retint_swapgs_pax
19475
19476 /* Either reschedule or signal or syscall exit tracking needed. */
19477 /* First do a reschedule test. */
19478 @@ -826,7 +1133,7 @@ int_restore_rest:
19479 TRACE_IRQS_OFF
19480 jmp int_with_check
19481 CFI_ENDPROC
19482 -END(system_call)
19483 +ENDPROC(system_call)
19484
19485 .macro FORK_LIKE func
19486 ENTRY(stub_\func)
19487 @@ -839,9 +1146,10 @@ ENTRY(stub_\func)
19488 DEFAULT_FRAME 0 8 /* offset 8: return address */
19489 call sys_\func
19490 RESTORE_TOP_OF_STACK %r11, 8
19491 + pax_force_retaddr
19492 ret $REST_SKIP /* pop extended registers */
19493 CFI_ENDPROC
19494 -END(stub_\func)
19495 +ENDPROC(stub_\func)
19496 .endm
19497
19498 .macro FIXED_FRAME label,func
19499 @@ -851,9 +1159,10 @@ ENTRY(\label)
19500 FIXUP_TOP_OF_STACK %r11, 8-ARGOFFSET
19501 call \func
19502 RESTORE_TOP_OF_STACK %r11, 8-ARGOFFSET
19503 + pax_force_retaddr
19504 ret
19505 CFI_ENDPROC
19506 -END(\label)
19507 +ENDPROC(\label)
19508 .endm
19509
19510 FORK_LIKE clone
19511 @@ -870,9 +1179,10 @@ ENTRY(ptregscall_common)
19512 movq_cfi_restore R12+8, r12
19513 movq_cfi_restore RBP+8, rbp
19514 movq_cfi_restore RBX+8, rbx
19515 + pax_force_retaddr
19516 ret $REST_SKIP /* pop extended registers */
19517 CFI_ENDPROC
19518 -END(ptregscall_common)
19519 +ENDPROC(ptregscall_common)
19520
19521 ENTRY(stub_execve)
19522 CFI_STARTPROC
19523 @@ -885,7 +1195,7 @@ ENTRY(stub_execve)
19524 RESTORE_REST
19525 jmp int_ret_from_sys_call
19526 CFI_ENDPROC
19527 -END(stub_execve)
19528 +ENDPROC(stub_execve)
19529
19530 /*
19531 * sigreturn is special because it needs to restore all registers on return.
19532 @@ -902,7 +1212,7 @@ ENTRY(stub_rt_sigreturn)
19533 RESTORE_REST
19534 jmp int_ret_from_sys_call
19535 CFI_ENDPROC
19536 -END(stub_rt_sigreturn)
19537 +ENDPROC(stub_rt_sigreturn)
19538
19539 #ifdef CONFIG_X86_X32_ABI
19540 ENTRY(stub_x32_rt_sigreturn)
19541 @@ -916,7 +1226,7 @@ ENTRY(stub_x32_rt_sigreturn)
19542 RESTORE_REST
19543 jmp int_ret_from_sys_call
19544 CFI_ENDPROC
19545 -END(stub_x32_rt_sigreturn)
19546 +ENDPROC(stub_x32_rt_sigreturn)
19547
19548 ENTRY(stub_x32_execve)
19549 CFI_STARTPROC
19550 @@ -930,7 +1240,7 @@ ENTRY(stub_x32_execve)
19551 RESTORE_REST
19552 jmp int_ret_from_sys_call
19553 CFI_ENDPROC
19554 -END(stub_x32_execve)
19555 +ENDPROC(stub_x32_execve)
19556
19557 #endif
19558
19559 @@ -967,7 +1277,7 @@ vector=vector+1
19560 2: jmp common_interrupt
19561 .endr
19562 CFI_ENDPROC
19563 -END(irq_entries_start)
19564 +ENDPROC(irq_entries_start)
19565
19566 .previous
19567 END(interrupt)
19568 @@ -987,6 +1297,16 @@ END(interrupt)
19569 subq $ORIG_RAX-RBP, %rsp
19570 CFI_ADJUST_CFA_OFFSET ORIG_RAX-RBP
19571 SAVE_ARGS_IRQ
19572 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19573 + testb $3, CS(%rdi)
19574 + jnz 1f
19575 + pax_enter_kernel
19576 + jmp 2f
19577 +1: pax_enter_kernel_user
19578 +2:
19579 +#else
19580 + pax_enter_kernel
19581 +#endif
19582 call \func
19583 .endm
19584
19585 @@ -1019,7 +1339,7 @@ ret_from_intr:
19586
19587 exit_intr:
19588 GET_THREAD_INFO(%rcx)
19589 - testl $3,CS-ARGOFFSET(%rsp)
19590 + testb $3,CS-ARGOFFSET(%rsp)
19591 je retint_kernel
19592
19593 /* Interrupt came from user space */
19594 @@ -1041,12 +1361,16 @@ retint_swapgs: /* return to user-space */
19595 * The iretq could re-enable interrupts:
19596 */
19597 DISABLE_INTERRUPTS(CLBR_ANY)
19598 + pax_exit_kernel_user
19599 +retint_swapgs_pax:
19600 TRACE_IRQS_IRETQ
19601 SWAPGS
19602 jmp restore_args
19603
19604 retint_restore_args: /* return to kernel space */
19605 DISABLE_INTERRUPTS(CLBR_ANY)
19606 + pax_exit_kernel
19607 + pax_force_retaddr (RIP-ARGOFFSET)
19608 /*
19609 * The iretq could re-enable interrupts:
19610 */
19611 @@ -1129,7 +1453,7 @@ ENTRY(retint_kernel)
19612 #endif
19613
19614 CFI_ENDPROC
19615 -END(common_interrupt)
19616 +ENDPROC(common_interrupt)
19617 /*
19618 * End of kprobes section
19619 */
19620 @@ -1147,7 +1471,7 @@ ENTRY(\sym)
19621 interrupt \do_sym
19622 jmp ret_from_intr
19623 CFI_ENDPROC
19624 -END(\sym)
19625 +ENDPROC(\sym)
19626 .endm
19627
19628 #ifdef CONFIG_SMP
19629 @@ -1203,12 +1527,22 @@ ENTRY(\sym)
19630 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
19631 call error_entry
19632 DEFAULT_FRAME 0
19633 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19634 + testb $3, CS(%rsp)
19635 + jnz 1f
19636 + pax_enter_kernel
19637 + jmp 2f
19638 +1: pax_enter_kernel_user
19639 +2:
19640 +#else
19641 + pax_enter_kernel
19642 +#endif
19643 movq %rsp,%rdi /* pt_regs pointer */
19644 xorl %esi,%esi /* no error code */
19645 call \do_sym
19646 jmp error_exit /* %ebx: no swapgs flag */
19647 CFI_ENDPROC
19648 -END(\sym)
19649 +ENDPROC(\sym)
19650 .endm
19651
19652 .macro paranoidzeroentry sym do_sym
19653 @@ -1221,15 +1555,25 @@ ENTRY(\sym)
19654 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
19655 call save_paranoid
19656 TRACE_IRQS_OFF
19657 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19658 + testb $3, CS(%rsp)
19659 + jnz 1f
19660 + pax_enter_kernel
19661 + jmp 2f
19662 +1: pax_enter_kernel_user
19663 +2:
19664 +#else
19665 + pax_enter_kernel
19666 +#endif
19667 movq %rsp,%rdi /* pt_regs pointer */
19668 xorl %esi,%esi /* no error code */
19669 call \do_sym
19670 jmp paranoid_exit /* %ebx: no swapgs flag */
19671 CFI_ENDPROC
19672 -END(\sym)
19673 +ENDPROC(\sym)
19674 .endm
19675
19676 -#define INIT_TSS_IST(x) PER_CPU_VAR(init_tss) + (TSS_ist + ((x) - 1) * 8)
19677 +#define INIT_TSS_IST(x) (TSS_ist + ((x) - 1) * 8)(%r12)
19678 .macro paranoidzeroentry_ist sym do_sym ist
19679 ENTRY(\sym)
19680 INTR_FRAME
19681 @@ -1240,14 +1584,30 @@ ENTRY(\sym)
19682 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
19683 call save_paranoid
19684 TRACE_IRQS_OFF_DEBUG
19685 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19686 + testb $3, CS(%rsp)
19687 + jnz 1f
19688 + pax_enter_kernel
19689 + jmp 2f
19690 +1: pax_enter_kernel_user
19691 +2:
19692 +#else
19693 + pax_enter_kernel
19694 +#endif
19695 movq %rsp,%rdi /* pt_regs pointer */
19696 xorl %esi,%esi /* no error code */
19697 +#ifdef CONFIG_SMP
19698 + imul $TSS_size, PER_CPU_VAR(cpu_number), %r12d
19699 + lea init_tss(%r12), %r12
19700 +#else
19701 + lea init_tss(%rip), %r12
19702 +#endif
19703 subq $EXCEPTION_STKSZ, INIT_TSS_IST(\ist)
19704 call \do_sym
19705 addq $EXCEPTION_STKSZ, INIT_TSS_IST(\ist)
19706 jmp paranoid_exit /* %ebx: no swapgs flag */
19707 CFI_ENDPROC
19708 -END(\sym)
19709 +ENDPROC(\sym)
19710 .endm
19711
19712 .macro errorentry sym do_sym
19713 @@ -1259,13 +1619,23 @@ ENTRY(\sym)
19714 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
19715 call error_entry
19716 DEFAULT_FRAME 0
19717 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19718 + testb $3, CS(%rsp)
19719 + jnz 1f
19720 + pax_enter_kernel
19721 + jmp 2f
19722 +1: pax_enter_kernel_user
19723 +2:
19724 +#else
19725 + pax_enter_kernel
19726 +#endif
19727 movq %rsp,%rdi /* pt_regs pointer */
19728 movq ORIG_RAX(%rsp),%rsi /* get error code */
19729 movq $-1,ORIG_RAX(%rsp) /* no syscall to restart */
19730 call \do_sym
19731 jmp error_exit /* %ebx: no swapgs flag */
19732 CFI_ENDPROC
19733 -END(\sym)
19734 +ENDPROC(\sym)
19735 .endm
19736
19737 /* error code is on the stack already */
19738 @@ -1279,13 +1649,23 @@ ENTRY(\sym)
19739 call save_paranoid
19740 DEFAULT_FRAME 0
19741 TRACE_IRQS_OFF
19742 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19743 + testb $3, CS(%rsp)
19744 + jnz 1f
19745 + pax_enter_kernel
19746 + jmp 2f
19747 +1: pax_enter_kernel_user
19748 +2:
19749 +#else
19750 + pax_enter_kernel
19751 +#endif
19752 movq %rsp,%rdi /* pt_regs pointer */
19753 movq ORIG_RAX(%rsp),%rsi /* get error code */
19754 movq $-1,ORIG_RAX(%rsp) /* no syscall to restart */
19755 call \do_sym
19756 jmp paranoid_exit /* %ebx: no swapgs flag */
19757 CFI_ENDPROC
19758 -END(\sym)
19759 +ENDPROC(\sym)
19760 .endm
19761
19762 zeroentry divide_error do_divide_error
19763 @@ -1315,9 +1695,10 @@ gs_change:
19764 2: mfence /* workaround */
19765 SWAPGS
19766 popfq_cfi
19767 + pax_force_retaddr
19768 ret
19769 CFI_ENDPROC
19770 -END(native_load_gs_index)
19771 +ENDPROC(native_load_gs_index)
19772
19773 _ASM_EXTABLE(gs_change,bad_gs)
19774 .section .fixup,"ax"
19775 @@ -1345,9 +1726,10 @@ ENTRY(call_softirq)
19776 CFI_DEF_CFA_REGISTER rsp
19777 CFI_ADJUST_CFA_OFFSET -8
19778 decl PER_CPU_VAR(irq_count)
19779 + pax_force_retaddr
19780 ret
19781 CFI_ENDPROC
19782 -END(call_softirq)
19783 +ENDPROC(call_softirq)
19784
19785 #ifdef CONFIG_XEN
19786 zeroentry xen_hypervisor_callback xen_do_hypervisor_callback
19787 @@ -1385,7 +1767,7 @@ ENTRY(xen_do_hypervisor_callback) # do_hypervisor_callback(struct *pt_regs)
19788 decl PER_CPU_VAR(irq_count)
19789 jmp error_exit
19790 CFI_ENDPROC
19791 -END(xen_do_hypervisor_callback)
19792 +ENDPROC(xen_do_hypervisor_callback)
19793
19794 /*
19795 * Hypervisor uses this for application faults while it executes.
19796 @@ -1444,7 +1826,7 @@ ENTRY(xen_failsafe_callback)
19797 SAVE_ALL
19798 jmp error_exit
19799 CFI_ENDPROC
19800 -END(xen_failsafe_callback)
19801 +ENDPROC(xen_failsafe_callback)
19802
19803 apicinterrupt HYPERVISOR_CALLBACK_VECTOR \
19804 xen_hvm_callback_vector xen_evtchn_do_upcall
19805 @@ -1498,16 +1880,31 @@ ENTRY(paranoid_exit)
19806 TRACE_IRQS_OFF_DEBUG
19807 testl %ebx,%ebx /* swapgs needed? */
19808 jnz paranoid_restore
19809 - testl $3,CS(%rsp)
19810 + testb $3,CS(%rsp)
19811 jnz paranoid_userspace
19812 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19813 + pax_exit_kernel
19814 + TRACE_IRQS_IRETQ 0
19815 + SWAPGS_UNSAFE_STACK
19816 + RESTORE_ALL 8
19817 + pax_force_retaddr_bts
19818 + jmp irq_return
19819 +#endif
19820 paranoid_swapgs:
19821 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19822 + pax_exit_kernel_user
19823 +#else
19824 + pax_exit_kernel
19825 +#endif
19826 TRACE_IRQS_IRETQ 0
19827 SWAPGS_UNSAFE_STACK
19828 RESTORE_ALL 8
19829 jmp irq_return
19830 paranoid_restore:
19831 + pax_exit_kernel
19832 TRACE_IRQS_IRETQ_DEBUG 0
19833 RESTORE_ALL 8
19834 + pax_force_retaddr_bts
19835 jmp irq_return
19836 paranoid_userspace:
19837 GET_THREAD_INFO(%rcx)
19838 @@ -1536,7 +1933,7 @@ paranoid_schedule:
19839 TRACE_IRQS_OFF
19840 jmp paranoid_userspace
19841 CFI_ENDPROC
19842 -END(paranoid_exit)
19843 +ENDPROC(paranoid_exit)
19844
19845 /*
19846 * Exception entry point. This expects an error code/orig_rax on the stack.
19847 @@ -1563,12 +1960,13 @@ ENTRY(error_entry)
19848 movq_cfi r14, R14+8
19849 movq_cfi r15, R15+8
19850 xorl %ebx,%ebx
19851 - testl $3,CS+8(%rsp)
19852 + testb $3,CS+8(%rsp)
19853 je error_kernelspace
19854 error_swapgs:
19855 SWAPGS
19856 error_sti:
19857 TRACE_IRQS_OFF
19858 + pax_force_retaddr_bts
19859 ret
19860
19861 /*
19862 @@ -1595,7 +1993,7 @@ bstep_iret:
19863 movq %rcx,RIP+8(%rsp)
19864 jmp error_swapgs
19865 CFI_ENDPROC
19866 -END(error_entry)
19867 +ENDPROC(error_entry)
19868
19869
19870 /* ebx: no swapgs flag (1: don't need swapgs, 0: need it) */
19871 @@ -1615,7 +2013,7 @@ ENTRY(error_exit)
19872 jnz retint_careful
19873 jmp retint_swapgs
19874 CFI_ENDPROC
19875 -END(error_exit)
19876 +ENDPROC(error_exit)
19877
19878 /*
19879 * Test if a given stack is an NMI stack or not.
19880 @@ -1673,9 +2071,11 @@ ENTRY(nmi)
19881 * If %cs was not the kernel segment, then the NMI triggered in user
19882 * space, which means it is definitely not nested.
19883 */
19884 + cmpl $__KERNEXEC_KERNEL_CS, 16(%rsp)
19885 + je 1f
19886 cmpl $__KERNEL_CS, 16(%rsp)
19887 jne first_nmi
19888 -
19889 +1:
19890 /*
19891 * Check the special variable on the stack to see if NMIs are
19892 * executing.
19893 @@ -1709,8 +2109,7 @@ nested_nmi:
19894
19895 1:
19896 /* Set up the interrupted NMIs stack to jump to repeat_nmi */
19897 - leaq -1*8(%rsp), %rdx
19898 - movq %rdx, %rsp
19899 + subq $8, %rsp
19900 CFI_ADJUST_CFA_OFFSET 1*8
19901 leaq -10*8(%rsp), %rdx
19902 pushq_cfi $__KERNEL_DS
19903 @@ -1728,6 +2127,7 @@ nested_nmi_out:
19904 CFI_RESTORE rdx
19905
19906 /* No need to check faults here */
19907 + pax_force_retaddr_bts
19908 INTERRUPT_RETURN
19909
19910 CFI_RESTORE_STATE
19911 @@ -1844,6 +2244,17 @@ end_repeat_nmi:
19912 */
19913 movq %cr2, %r12
19914
19915 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19916 + testb $3, CS(%rsp)
19917 + jnz 1f
19918 + pax_enter_kernel
19919 + jmp 2f
19920 +1: pax_enter_kernel_user
19921 +2:
19922 +#else
19923 + pax_enter_kernel
19924 +#endif
19925 +
19926 /* paranoidentry do_nmi, 0; without TRACE_IRQS_OFF */
19927 movq %rsp,%rdi
19928 movq $-1,%rsi
19929 @@ -1859,23 +2270,34 @@ end_repeat_nmi:
19930 testl %ebx,%ebx /* swapgs needed? */
19931 jnz nmi_restore
19932 nmi_swapgs:
19933 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19934 + pax_exit_kernel_user
19935 +#else
19936 + pax_exit_kernel
19937 +#endif
19938 SWAPGS_UNSAFE_STACK
19939 + RESTORE_ALL 6*8
19940 + /* Clear the NMI executing stack variable */
19941 + movq $0, 5*8(%rsp)
19942 + jmp irq_return
19943 nmi_restore:
19944 + pax_exit_kernel
19945 /* Pop the extra iret frame at once */
19946 RESTORE_ALL 6*8
19947 + pax_force_retaddr_bts
19948
19949 /* Clear the NMI executing stack variable */
19950 movq $0, 5*8(%rsp)
19951 jmp irq_return
19952 CFI_ENDPROC
19953 -END(nmi)
19954 +ENDPROC(nmi)
19955
19956 ENTRY(ignore_sysret)
19957 CFI_STARTPROC
19958 mov $-ENOSYS,%eax
19959 sysret
19960 CFI_ENDPROC
19961 -END(ignore_sysret)
19962 +ENDPROC(ignore_sysret)
19963
19964 /*
19965 * End of kprobes section
19966 diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c
19967 index 42a392a..fbbd930 100644
19968 --- a/arch/x86/kernel/ftrace.c
19969 +++ b/arch/x86/kernel/ftrace.c
19970 @@ -105,6 +105,8 @@ ftrace_modify_code_direct(unsigned long ip, unsigned const char *old_code,
19971 {
19972 unsigned char replaced[MCOUNT_INSN_SIZE];
19973
19974 + ip = ktla_ktva(ip);
19975 +
19976 /*
19977 * Note: Due to modules and __init, code can
19978 * disappear and change, we need to protect against faulting
19979 @@ -227,7 +229,7 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
19980 unsigned char old[MCOUNT_INSN_SIZE], *new;
19981 int ret;
19982
19983 - memcpy(old, &ftrace_call, MCOUNT_INSN_SIZE);
19984 + memcpy(old, (void *)ktla_ktva((unsigned long)ftrace_call), MCOUNT_INSN_SIZE);
19985 new = ftrace_call_replace(ip, (unsigned long)func);
19986
19987 /* See comment above by declaration of modifying_ftrace_code */
19988 @@ -238,7 +240,7 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
19989 /* Also update the regs callback function */
19990 if (!ret) {
19991 ip = (unsigned long)(&ftrace_regs_call);
19992 - memcpy(old, &ftrace_regs_call, MCOUNT_INSN_SIZE);
19993 + memcpy(old, ktla_ktva((void *)&ftrace_regs_call), MCOUNT_INSN_SIZE);
19994 new = ftrace_call_replace(ip, (unsigned long)func);
19995 ret = ftrace_modify_code(ip, old, new);
19996 }
19997 @@ -279,7 +281,7 @@ static int ftrace_write(unsigned long ip, const char *val, int size)
19998 * kernel identity mapping to modify code.
19999 */
20000 if (within(ip, (unsigned long)_text, (unsigned long)_etext))
20001 - ip = (unsigned long)__va(__pa_symbol(ip));
20002 + ip = (unsigned long)__va(__pa_symbol(ktla_ktva(ip)));
20003
20004 return probe_kernel_write((void *)ip, val, size);
20005 }
20006 @@ -289,7 +291,7 @@ static int add_break(unsigned long ip, const char *old)
20007 unsigned char replaced[MCOUNT_INSN_SIZE];
20008 unsigned char brk = BREAKPOINT_INSTRUCTION;
20009
20010 - if (probe_kernel_read(replaced, (void *)ip, MCOUNT_INSN_SIZE))
20011 + if (probe_kernel_read(replaced, (void *)ktla_ktva(ip), MCOUNT_INSN_SIZE))
20012 return -EFAULT;
20013
20014 /* Make sure it is what we expect it to be */
20015 @@ -637,7 +639,7 @@ ftrace_modify_code(unsigned long ip, unsigned const char *old_code,
20016 return ret;
20017
20018 fail_update:
20019 - probe_kernel_write((void *)ip, &old_code[0], 1);
20020 + probe_kernel_write((void *)ktla_ktva(ip), &old_code[0], 1);
20021 goto out;
20022 }
20023
20024 @@ -670,6 +672,8 @@ static int ftrace_mod_jmp(unsigned long ip,
20025 {
20026 unsigned char code[MCOUNT_INSN_SIZE];
20027
20028 + ip = ktla_ktva(ip);
20029 +
20030 if (probe_kernel_read(code, (void *)ip, MCOUNT_INSN_SIZE))
20031 return -EFAULT;
20032
20033 diff --git a/arch/x86/kernel/head64.c b/arch/x86/kernel/head64.c
20034 index 8f3201d..aa860bf 100644
20035 --- a/arch/x86/kernel/head64.c
20036 +++ b/arch/x86/kernel/head64.c
20037 @@ -175,7 +175,6 @@ void __init x86_64_start_kernel(char * real_mode_data)
20038 if (console_loglevel == 10)
20039 early_printk("Kernel alive\n");
20040
20041 - clear_page(init_level4_pgt);
20042 /* set init_level4_pgt kernel high mapping*/
20043 init_level4_pgt[511] = early_level4_pgt[511];
20044
20045 diff --git a/arch/x86/kernel/head_32.S b/arch/x86/kernel/head_32.S
20046 index 73afd11..d1670f5 100644
20047 --- a/arch/x86/kernel/head_32.S
20048 +++ b/arch/x86/kernel/head_32.S
20049 @@ -26,6 +26,12 @@
20050 /* Physical address */
20051 #define pa(X) ((X) - __PAGE_OFFSET)
20052
20053 +#ifdef CONFIG_PAX_KERNEXEC
20054 +#define ta(X) (X)
20055 +#else
20056 +#define ta(X) ((X) - __PAGE_OFFSET)
20057 +#endif
20058 +
20059 /*
20060 * References to members of the new_cpu_data structure.
20061 */
20062 @@ -55,11 +61,7 @@
20063 * and small than max_low_pfn, otherwise will waste some page table entries
20064 */
20065
20066 -#if PTRS_PER_PMD > 1
20067 -#define PAGE_TABLE_SIZE(pages) (((pages) / PTRS_PER_PMD) + PTRS_PER_PGD)
20068 -#else
20069 -#define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PGD)
20070 -#endif
20071 +#define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PTE)
20072
20073 /* Number of possible pages in the lowmem region */
20074 LOWMEM_PAGES = (((1<<32) - __PAGE_OFFSET) >> PAGE_SHIFT)
20075 @@ -78,6 +80,12 @@ INIT_MAP_SIZE = PAGE_TABLE_SIZE(KERNEL_PAGES) * PAGE_SIZE
20076 RESERVE_BRK(pagetables, INIT_MAP_SIZE)
20077
20078 /*
20079 + * Real beginning of normal "text" segment
20080 + */
20081 +ENTRY(stext)
20082 +ENTRY(_stext)
20083 +
20084 +/*
20085 * 32-bit kernel entrypoint; only used by the boot CPU. On entry,
20086 * %esi points to the real-mode code as a 32-bit pointer.
20087 * CS and DS must be 4 GB flat segments, but we don't depend on
20088 @@ -85,6 +93,13 @@ RESERVE_BRK(pagetables, INIT_MAP_SIZE)
20089 * can.
20090 */
20091 __HEAD
20092 +
20093 +#ifdef CONFIG_PAX_KERNEXEC
20094 + jmp startup_32
20095 +/* PaX: fill first page in .text with int3 to catch NULL derefs in kernel mode */
20096 +.fill PAGE_SIZE-5,1,0xcc
20097 +#endif
20098 +
20099 ENTRY(startup_32)
20100 movl pa(stack_start),%ecx
20101
20102 @@ -106,6 +121,59 @@ ENTRY(startup_32)
20103 2:
20104 leal -__PAGE_OFFSET(%ecx),%esp
20105
20106 +#ifdef CONFIG_SMP
20107 + movl $pa(cpu_gdt_table),%edi
20108 + movl $__per_cpu_load,%eax
20109 + movw %ax,GDT_ENTRY_PERCPU * 8 + 2(%edi)
20110 + rorl $16,%eax
20111 + movb %al,GDT_ENTRY_PERCPU * 8 + 4(%edi)
20112 + movb %ah,GDT_ENTRY_PERCPU * 8 + 7(%edi)
20113 + movl $__per_cpu_end - 1,%eax
20114 + subl $__per_cpu_start,%eax
20115 + movw %ax,GDT_ENTRY_PERCPU * 8 + 0(%edi)
20116 +#endif
20117 +
20118 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20119 + movl $NR_CPUS,%ecx
20120 + movl $pa(cpu_gdt_table),%edi
20121 +1:
20122 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c09700),GDT_ENTRY_KERNEL_DS * 8 + 4(%edi)
20123 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c0fb00),GDT_ENTRY_DEFAULT_USER_CS * 8 + 4(%edi)
20124 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c0f300),GDT_ENTRY_DEFAULT_USER_DS * 8 + 4(%edi)
20125 + addl $PAGE_SIZE_asm,%edi
20126 + loop 1b
20127 +#endif
20128 +
20129 +#ifdef CONFIG_PAX_KERNEXEC
20130 + movl $pa(boot_gdt),%edi
20131 + movl $__LOAD_PHYSICAL_ADDR,%eax
20132 + movw %ax,GDT_ENTRY_BOOT_CS * 8 + 2(%edi)
20133 + rorl $16,%eax
20134 + movb %al,GDT_ENTRY_BOOT_CS * 8 + 4(%edi)
20135 + movb %ah,GDT_ENTRY_BOOT_CS * 8 + 7(%edi)
20136 + rorl $16,%eax
20137 +
20138 + ljmp $(__BOOT_CS),$1f
20139 +1:
20140 +
20141 + movl $NR_CPUS,%ecx
20142 + movl $pa(cpu_gdt_table),%edi
20143 + addl $__PAGE_OFFSET,%eax
20144 +1:
20145 + movb $0xc0,GDT_ENTRY_KERNEL_CS * 8 + 6(%edi)
20146 + movb $0xc0,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 6(%edi)
20147 + movw %ax,GDT_ENTRY_KERNEL_CS * 8 + 2(%edi)
20148 + movw %ax,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 2(%edi)
20149 + rorl $16,%eax
20150 + movb %al,GDT_ENTRY_KERNEL_CS * 8 + 4(%edi)
20151 + movb %al,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 4(%edi)
20152 + movb %ah,GDT_ENTRY_KERNEL_CS * 8 + 7(%edi)
20153 + movb %ah,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 7(%edi)
20154 + rorl $16,%eax
20155 + addl $PAGE_SIZE_asm,%edi
20156 + loop 1b
20157 +#endif
20158 +
20159 /*
20160 * Clear BSS first so that there are no surprises...
20161 */
20162 @@ -201,8 +269,11 @@ ENTRY(startup_32)
20163 movl %eax, pa(max_pfn_mapped)
20164
20165 /* Do early initialization of the fixmap area */
20166 - movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,%eax
20167 - movl %eax,pa(initial_pg_pmd+0x1000*KPMDS-8)
20168 +#ifdef CONFIG_COMPAT_VDSO
20169 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR+_PAGE_USER,pa(initial_pg_pmd+0x1000*KPMDS-8)
20170 +#else
20171 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,pa(initial_pg_pmd+0x1000*KPMDS-8)
20172 +#endif
20173 #else /* Not PAE */
20174
20175 page_pde_offset = (__PAGE_OFFSET >> 20);
20176 @@ -232,8 +303,11 @@ page_pde_offset = (__PAGE_OFFSET >> 20);
20177 movl %eax, pa(max_pfn_mapped)
20178
20179 /* Do early initialization of the fixmap area */
20180 - movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,%eax
20181 - movl %eax,pa(initial_page_table+0xffc)
20182 +#ifdef CONFIG_COMPAT_VDSO
20183 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR+_PAGE_USER,pa(initial_page_table+0xffc)
20184 +#else
20185 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,pa(initial_page_table+0xffc)
20186 +#endif
20187 #endif
20188
20189 #ifdef CONFIG_PARAVIRT
20190 @@ -247,9 +321,7 @@ page_pde_offset = (__PAGE_OFFSET >> 20);
20191 cmpl $num_subarch_entries, %eax
20192 jae bad_subarch
20193
20194 - movl pa(subarch_entries)(,%eax,4), %eax
20195 - subl $__PAGE_OFFSET, %eax
20196 - jmp *%eax
20197 + jmp *pa(subarch_entries)(,%eax,4)
20198
20199 bad_subarch:
20200 WEAK(lguest_entry)
20201 @@ -261,10 +333,10 @@ WEAK(xen_entry)
20202 __INITDATA
20203
20204 subarch_entries:
20205 - .long default_entry /* normal x86/PC */
20206 - .long lguest_entry /* lguest hypervisor */
20207 - .long xen_entry /* Xen hypervisor */
20208 - .long default_entry /* Moorestown MID */
20209 + .long ta(default_entry) /* normal x86/PC */
20210 + .long ta(lguest_entry) /* lguest hypervisor */
20211 + .long ta(xen_entry) /* Xen hypervisor */
20212 + .long ta(default_entry) /* Moorestown MID */
20213 num_subarch_entries = (. - subarch_entries) / 4
20214 .previous
20215 #else
20216 @@ -355,6 +427,7 @@ default_entry:
20217 movl pa(mmu_cr4_features),%eax
20218 movl %eax,%cr4
20219
20220 +#ifdef CONFIG_X86_PAE
20221 testb $X86_CR4_PAE, %al # check if PAE is enabled
20222 jz enable_paging
20223
20224 @@ -383,6 +456,9 @@ default_entry:
20225 /* Make changes effective */
20226 wrmsr
20227
20228 + btsl $_PAGE_BIT_NX-32,pa(__supported_pte_mask+4)
20229 +#endif
20230 +
20231 enable_paging:
20232
20233 /*
20234 @@ -451,14 +527,20 @@ is486:
20235 1: movl $(__KERNEL_DS),%eax # reload all the segment registers
20236 movl %eax,%ss # after changing gdt.
20237
20238 - movl $(__USER_DS),%eax # DS/ES contains default USER segment
20239 +# movl $(__KERNEL_DS),%eax # DS/ES contains default KERNEL segment
20240 movl %eax,%ds
20241 movl %eax,%es
20242
20243 movl $(__KERNEL_PERCPU), %eax
20244 movl %eax,%fs # set this cpu's percpu
20245
20246 +#ifdef CONFIG_CC_STACKPROTECTOR
20247 movl $(__KERNEL_STACK_CANARY),%eax
20248 +#elif defined(CONFIG_PAX_MEMORY_UDEREF)
20249 + movl $(__USER_DS),%eax
20250 +#else
20251 + xorl %eax,%eax
20252 +#endif
20253 movl %eax,%gs
20254
20255 xorl %eax,%eax # Clear LDT
20256 @@ -534,8 +616,11 @@ setup_once:
20257 * relocation. Manually set base address in stack canary
20258 * segment descriptor.
20259 */
20260 - movl $gdt_page,%eax
20261 + movl $cpu_gdt_table,%eax
20262 movl $stack_canary,%ecx
20263 +#ifdef CONFIG_SMP
20264 + addl $__per_cpu_load,%ecx
20265 +#endif
20266 movw %cx, 8 * GDT_ENTRY_STACK_CANARY + 2(%eax)
20267 shrl $16, %ecx
20268 movb %cl, 8 * GDT_ENTRY_STACK_CANARY + 4(%eax)
20269 @@ -566,7 +651,7 @@ ENDPROC(early_idt_handlers)
20270 /* This is global to keep gas from relaxing the jumps */
20271 ENTRY(early_idt_handler)
20272 cld
20273 - cmpl $2,%ss:early_recursion_flag
20274 + cmpl $1,%ss:early_recursion_flag
20275 je hlt_loop
20276 incl %ss:early_recursion_flag
20277
20278 @@ -604,8 +689,8 @@ ENTRY(early_idt_handler)
20279 pushl (20+6*4)(%esp) /* trapno */
20280 pushl $fault_msg
20281 call printk
20282 -#endif
20283 call dump_stack
20284 +#endif
20285 hlt_loop:
20286 hlt
20287 jmp hlt_loop
20288 @@ -624,8 +709,11 @@ ENDPROC(early_idt_handler)
20289 /* This is the default interrupt "handler" :-) */
20290 ALIGN
20291 ignore_int:
20292 - cld
20293 #ifdef CONFIG_PRINTK
20294 + cmpl $2,%ss:early_recursion_flag
20295 + je hlt_loop
20296 + incl %ss:early_recursion_flag
20297 + cld
20298 pushl %eax
20299 pushl %ecx
20300 pushl %edx
20301 @@ -634,9 +722,6 @@ ignore_int:
20302 movl $(__KERNEL_DS),%eax
20303 movl %eax,%ds
20304 movl %eax,%es
20305 - cmpl $2,early_recursion_flag
20306 - je hlt_loop
20307 - incl early_recursion_flag
20308 pushl 16(%esp)
20309 pushl 24(%esp)
20310 pushl 32(%esp)
20311 @@ -670,29 +755,43 @@ ENTRY(setup_once_ref)
20312 /*
20313 * BSS section
20314 */
20315 -__PAGE_ALIGNED_BSS
20316 - .align PAGE_SIZE
20317 #ifdef CONFIG_X86_PAE
20318 +.section .initial_pg_pmd,"a",@progbits
20319 initial_pg_pmd:
20320 .fill 1024*KPMDS,4,0
20321 #else
20322 +.section .initial_page_table,"a",@progbits
20323 ENTRY(initial_page_table)
20324 .fill 1024,4,0
20325 #endif
20326 +.section .initial_pg_fixmap,"a",@progbits
20327 initial_pg_fixmap:
20328 .fill 1024,4,0
20329 +.section .empty_zero_page,"a",@progbits
20330 ENTRY(empty_zero_page)
20331 .fill 4096,1,0
20332 +.section .swapper_pg_dir,"a",@progbits
20333 ENTRY(swapper_pg_dir)
20334 +#ifdef CONFIG_X86_PAE
20335 + .fill 4,8,0
20336 +#else
20337 .fill 1024,4,0
20338 +#endif
20339 +
20340 +/*
20341 + * The IDT has to be page-aligned to simplify the Pentium
20342 + * F0 0F bug workaround.. We have a special link segment
20343 + * for this.
20344 + */
20345 +.section .idt,"a",@progbits
20346 +ENTRY(idt_table)
20347 + .fill 256,8,0
20348
20349 /*
20350 * This starts the data section.
20351 */
20352 #ifdef CONFIG_X86_PAE
20353 -__PAGE_ALIGNED_DATA
20354 - /* Page-aligned for the benefit of paravirt? */
20355 - .align PAGE_SIZE
20356 +.section .initial_page_table,"a",@progbits
20357 ENTRY(initial_page_table)
20358 .long pa(initial_pg_pmd+PGD_IDENT_ATTR),0 /* low identity map */
20359 # if KPMDS == 3
20360 @@ -711,12 +810,20 @@ ENTRY(initial_page_table)
20361 # error "Kernel PMDs should be 1, 2 or 3"
20362 # endif
20363 .align PAGE_SIZE /* needs to be page-sized too */
20364 +
20365 +#ifdef CONFIG_PAX_PER_CPU_PGD
20366 +ENTRY(cpu_pgd)
20367 + .rept NR_CPUS
20368 + .fill 4,8,0
20369 + .endr
20370 +#endif
20371 +
20372 #endif
20373
20374 .data
20375 .balign 4
20376 ENTRY(stack_start)
20377 - .long init_thread_union+THREAD_SIZE
20378 + .long init_thread_union+THREAD_SIZE-8
20379
20380 __INITRODATA
20381 int_msg:
20382 @@ -744,7 +851,7 @@ fault_msg:
20383 * segment size, and 32-bit linear address value:
20384 */
20385
20386 - .data
20387 +.section .rodata,"a",@progbits
20388 .globl boot_gdt_descr
20389 .globl idt_descr
20390
20391 @@ -753,7 +860,7 @@ fault_msg:
20392 .word 0 # 32 bit align gdt_desc.address
20393 boot_gdt_descr:
20394 .word __BOOT_DS+7
20395 - .long boot_gdt - __PAGE_OFFSET
20396 + .long pa(boot_gdt)
20397
20398 .word 0 # 32-bit align idt_desc.address
20399 idt_descr:
20400 @@ -764,7 +871,7 @@ idt_descr:
20401 .word 0 # 32 bit align gdt_desc.address
20402 ENTRY(early_gdt_descr)
20403 .word GDT_ENTRIES*8-1
20404 - .long gdt_page /* Overwritten for secondary CPUs */
20405 + .long cpu_gdt_table /* Overwritten for secondary CPUs */
20406
20407 /*
20408 * The boot_gdt must mirror the equivalent in setup.S and is
20409 @@ -773,5 +880,65 @@ ENTRY(early_gdt_descr)
20410 .align L1_CACHE_BYTES
20411 ENTRY(boot_gdt)
20412 .fill GDT_ENTRY_BOOT_CS,8,0
20413 - .quad 0x00cf9a000000ffff /* kernel 4GB code at 0x00000000 */
20414 - .quad 0x00cf92000000ffff /* kernel 4GB data at 0x00000000 */
20415 + .quad 0x00cf9b000000ffff /* kernel 4GB code at 0x00000000 */
20416 + .quad 0x00cf93000000ffff /* kernel 4GB data at 0x00000000 */
20417 +
20418 + .align PAGE_SIZE_asm
20419 +ENTRY(cpu_gdt_table)
20420 + .rept NR_CPUS
20421 + .quad 0x0000000000000000 /* NULL descriptor */
20422 + .quad 0x0000000000000000 /* 0x0b reserved */
20423 + .quad 0x0000000000000000 /* 0x13 reserved */
20424 + .quad 0x0000000000000000 /* 0x1b reserved */
20425 +
20426 +#ifdef CONFIG_PAX_KERNEXEC
20427 + .quad 0x00cf9b000000ffff /* 0x20 alternate kernel 4GB code at 0x00000000 */
20428 +#else
20429 + .quad 0x0000000000000000 /* 0x20 unused */
20430 +#endif
20431 +
20432 + .quad 0x0000000000000000 /* 0x28 unused */
20433 + .quad 0x0000000000000000 /* 0x33 TLS entry 1 */
20434 + .quad 0x0000000000000000 /* 0x3b TLS entry 2 */
20435 + .quad 0x0000000000000000 /* 0x43 TLS entry 3 */
20436 + .quad 0x0000000000000000 /* 0x4b reserved */
20437 + .quad 0x0000000000000000 /* 0x53 reserved */
20438 + .quad 0x0000000000000000 /* 0x5b reserved */
20439 +
20440 + .quad 0x00cf9b000000ffff /* 0x60 kernel 4GB code at 0x00000000 */
20441 + .quad 0x00cf93000000ffff /* 0x68 kernel 4GB data at 0x00000000 */
20442 + .quad 0x00cffb000000ffff /* 0x73 user 4GB code at 0x00000000 */
20443 + .quad 0x00cff3000000ffff /* 0x7b user 4GB data at 0x00000000 */
20444 +
20445 + .quad 0x0000000000000000 /* 0x80 TSS descriptor */
20446 + .quad 0x0000000000000000 /* 0x88 LDT descriptor */
20447 +
20448 + /*
20449 + * Segments used for calling PnP BIOS have byte granularity.
20450 + * The code segments and data segments have fixed 64k limits,
20451 + * the transfer segment sizes are set at run time.
20452 + */
20453 + .quad 0x00409b000000ffff /* 0x90 32-bit code */
20454 + .quad 0x00009b000000ffff /* 0x98 16-bit code */
20455 + .quad 0x000093000000ffff /* 0xa0 16-bit data */
20456 + .quad 0x0000930000000000 /* 0xa8 16-bit data */
20457 + .quad 0x0000930000000000 /* 0xb0 16-bit data */
20458 +
20459 + /*
20460 + * The APM segments have byte granularity and their bases
20461 + * are set at run time. All have 64k limits.
20462 + */
20463 + .quad 0x00409b000000ffff /* 0xb8 APM CS code */
20464 + .quad 0x00009b000000ffff /* 0xc0 APM CS 16 code (16 bit) */
20465 + .quad 0x004093000000ffff /* 0xc8 APM DS data */
20466 +
20467 + .quad 0x00c0930000000000 /* 0xd0 - ESPFIX SS */
20468 + .quad 0x0040930000000000 /* 0xd8 - PERCPU */
20469 + .quad 0x0040910000000017 /* 0xe0 - STACK_CANARY */
20470 + .quad 0x0000000000000000 /* 0xe8 - PCIBIOS_CS */
20471 + .quad 0x0000000000000000 /* 0xf0 - PCIBIOS_DS */
20472 + .quad 0x0000000000000000 /* 0xf8 - GDT entry 31: double-fault TSS */
20473 +
20474 + /* Be sure this is zeroed to avoid false validations in Xen */
20475 + .fill PAGE_SIZE_asm - GDT_SIZE,1,0
20476 + .endr
20477 diff --git a/arch/x86/kernel/head_64.S b/arch/x86/kernel/head_64.S
20478 index 08f7e80..40cbed5 100644
20479 --- a/arch/x86/kernel/head_64.S
20480 +++ b/arch/x86/kernel/head_64.S
20481 @@ -20,6 +20,8 @@
20482 #include <asm/processor-flags.h>
20483 #include <asm/percpu.h>
20484 #include <asm/nops.h>
20485 +#include <asm/cpufeature.h>
20486 +#include <asm/alternative-asm.h>
20487
20488 #ifdef CONFIG_PARAVIRT
20489 #include <asm/asm-offsets.h>
20490 @@ -41,6 +43,12 @@ L4_PAGE_OFFSET = pgd_index(__PAGE_OFFSET)
20491 L3_PAGE_OFFSET = pud_index(__PAGE_OFFSET)
20492 L4_START_KERNEL = pgd_index(__START_KERNEL_map)
20493 L3_START_KERNEL = pud_index(__START_KERNEL_map)
20494 +L4_VMALLOC_START = pgd_index(VMALLOC_START)
20495 +L3_VMALLOC_START = pud_index(VMALLOC_START)
20496 +L4_VMALLOC_END = pgd_index(VMALLOC_END)
20497 +L3_VMALLOC_END = pud_index(VMALLOC_END)
20498 +L4_VMEMMAP_START = pgd_index(VMEMMAP_START)
20499 +L3_VMEMMAP_START = pud_index(VMEMMAP_START)
20500
20501 .text
20502 __HEAD
20503 @@ -89,11 +97,15 @@ startup_64:
20504 * Fixup the physical addresses in the page table
20505 */
20506 addq %rbp, early_level4_pgt + (L4_START_KERNEL*8)(%rip)
20507 + addq %rbp, init_level4_pgt + (L4_VMALLOC_START*8)(%rip)
20508 + addq %rbp, init_level4_pgt + (L4_VMALLOC_END*8)(%rip)
20509 + addq %rbp, init_level4_pgt + (L4_VMEMMAP_START*8)(%rip)
20510
20511 addq %rbp, level3_kernel_pgt + (510*8)(%rip)
20512 addq %rbp, level3_kernel_pgt + (511*8)(%rip)
20513
20514 addq %rbp, level2_fixmap_pgt + (506*8)(%rip)
20515 + addq %rbp, level2_fixmap_pgt + (507*8)(%rip)
20516
20517 /*
20518 * Set up the identity mapping for the switchover. These
20519 @@ -175,8 +187,8 @@ ENTRY(secondary_startup_64)
20520 movq $(init_level4_pgt - __START_KERNEL_map), %rax
20521 1:
20522
20523 - /* Enable PAE mode and PGE */
20524 - movl $(X86_CR4_PAE | X86_CR4_PGE), %ecx
20525 + /* Enable PAE mode and PSE/PGE */
20526 + movl $(X86_CR4_PSE | X86_CR4_PAE | X86_CR4_PGE), %ecx
20527 movq %rcx, %cr4
20528
20529 /* Setup early boot stage 4 level pagetables. */
20530 @@ -197,10 +209,18 @@ ENTRY(secondary_startup_64)
20531 movl $MSR_EFER, %ecx
20532 rdmsr
20533 btsl $_EFER_SCE, %eax /* Enable System Call */
20534 - btl $20,%edi /* No Execute supported? */
20535 + btl $(X86_FEATURE_NX & 31),%edi /* No Execute supported? */
20536 jnc 1f
20537 btsl $_EFER_NX, %eax
20538 btsq $_PAGE_BIT_NX,early_pmd_flags(%rip)
20539 + leaq init_level4_pgt(%rip), %rdi
20540 +#ifndef CONFIG_EFI
20541 + btsq $_PAGE_BIT_NX, 8*L4_PAGE_OFFSET(%rdi)
20542 +#endif
20543 + btsq $_PAGE_BIT_NX, 8*L4_VMALLOC_START(%rdi)
20544 + btsq $_PAGE_BIT_NX, 8*L4_VMALLOC_END(%rdi)
20545 + btsq $_PAGE_BIT_NX, 8*L4_VMEMMAP_START(%rdi)
20546 + btsq $_PAGE_BIT_NX, __supported_pte_mask(%rip)
20547 1: wrmsr /* Make changes effective */
20548
20549 /* Setup cr0 */
20550 @@ -280,6 +300,7 @@ ENTRY(secondary_startup_64)
20551 * REX.W + FF /5 JMP m16:64 Jump far, absolute indirect,
20552 * address given in m16:64.
20553 */
20554 + pax_set_fptr_mask
20555 movq initial_code(%rip),%rax
20556 pushq $0 # fake return address to stop unwinder
20557 pushq $__KERNEL_CS # set correct cs
20558 @@ -386,7 +407,7 @@ ENTRY(early_idt_handler)
20559 call dump_stack
20560 #ifdef CONFIG_KALLSYMS
20561 leaq early_idt_ripmsg(%rip),%rdi
20562 - movq 40(%rsp),%rsi # %rip again
20563 + movq 88(%rsp),%rsi # %rip again
20564 call __print_symbol
20565 #endif
20566 #endif /* EARLY_PRINTK */
20567 @@ -414,6 +435,7 @@ ENDPROC(early_idt_handler)
20568 early_recursion_flag:
20569 .long 0
20570
20571 + .section .rodata,"a",@progbits
20572 #ifdef CONFIG_EARLY_PRINTK
20573 early_idt_msg:
20574 .asciz "PANIC: early exception %02lx rip %lx:%lx error %lx cr2 %lx\n"
20575 @@ -443,27 +465,50 @@ NEXT_PAGE(early_dynamic_pgts)
20576
20577 .data
20578
20579 -#ifndef CONFIG_XEN
20580 NEXT_PAGE(init_level4_pgt)
20581 - .fill 512,8,0
20582 -#else
20583 -NEXT_PAGE(init_level4_pgt)
20584 - .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
20585 .org init_level4_pgt + L4_PAGE_OFFSET*8, 0
20586 .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
20587 + .org init_level4_pgt + L4_VMALLOC_START*8, 0
20588 + .quad level3_vmalloc_start_pgt - __START_KERNEL_map + _KERNPG_TABLE
20589 + .org init_level4_pgt + L4_VMALLOC_END*8, 0
20590 + .quad level3_vmalloc_end_pgt - __START_KERNEL_map + _KERNPG_TABLE
20591 + .org init_level4_pgt + L4_VMEMMAP_START*8, 0
20592 + .quad level3_vmemmap_pgt - __START_KERNEL_map + _KERNPG_TABLE
20593 .org init_level4_pgt + L4_START_KERNEL*8, 0
20594 /* (2^48-(2*1024*1024*1024))/(2^39) = 511 */
20595 .quad level3_kernel_pgt - __START_KERNEL_map + _PAGE_TABLE
20596
20597 +#ifdef CONFIG_PAX_PER_CPU_PGD
20598 +NEXT_PAGE(cpu_pgd)
20599 + .rept NR_CPUS
20600 + .fill 512,8,0
20601 + .endr
20602 +#endif
20603 +
20604 NEXT_PAGE(level3_ident_pgt)
20605 .quad level2_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
20606 +#ifdef CONFIG_XEN
20607 .fill 511, 8, 0
20608 +#else
20609 + .quad level2_ident_pgt + PAGE_SIZE - __START_KERNEL_map + _KERNPG_TABLE
20610 + .fill 510,8,0
20611 +#endif
20612 +
20613 +NEXT_PAGE(level3_vmalloc_start_pgt)
20614 + .fill 512,8,0
20615 +
20616 +NEXT_PAGE(level3_vmalloc_end_pgt)
20617 + .fill 512,8,0
20618 +
20619 +NEXT_PAGE(level3_vmemmap_pgt)
20620 + .fill L3_VMEMMAP_START,8,0
20621 + .quad level2_vmemmap_pgt - __START_KERNEL_map + _KERNPG_TABLE
20622 +
20623 NEXT_PAGE(level2_ident_pgt)
20624 - /* Since I easily can, map the first 1G.
20625 + /* Since I easily can, map the first 2G.
20626 * Don't set NX because code runs from these pages.
20627 */
20628 - PMDS(0, __PAGE_KERNEL_IDENT_LARGE_EXEC, PTRS_PER_PMD)
20629 -#endif
20630 + PMDS(0, __PAGE_KERNEL_IDENT_LARGE_EXEC, 2*PTRS_PER_PMD)
20631
20632 NEXT_PAGE(level3_kernel_pgt)
20633 .fill L3_START_KERNEL,8,0
20634 @@ -471,6 +516,9 @@ NEXT_PAGE(level3_kernel_pgt)
20635 .quad level2_kernel_pgt - __START_KERNEL_map + _KERNPG_TABLE
20636 .quad level2_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE
20637
20638 +NEXT_PAGE(level2_vmemmap_pgt)
20639 + .fill 512,8,0
20640 +
20641 NEXT_PAGE(level2_kernel_pgt)
20642 /*
20643 * 512 MB kernel mapping. We spend a full page on this pagetable
20644 @@ -486,38 +534,64 @@ NEXT_PAGE(level2_kernel_pgt)
20645 KERNEL_IMAGE_SIZE/PMD_SIZE)
20646
20647 NEXT_PAGE(level2_fixmap_pgt)
20648 - .fill 506,8,0
20649 - .quad level1_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE
20650 - /* 8MB reserved for vsyscalls + a 2MB hole = 4 + 1 entries */
20651 - .fill 5,8,0
20652 + .fill 507,8,0
20653 + .quad level1_vsyscall_pgt - __START_KERNEL_map + _PAGE_TABLE
20654 + /* 6MB reserved for vsyscalls + a 2MB hole = 3 + 1 entries */
20655 + .fill 4,8,0
20656
20657 -NEXT_PAGE(level1_fixmap_pgt)
20658 +NEXT_PAGE(level1_vsyscall_pgt)
20659 .fill 512,8,0
20660
20661 #undef PMDS
20662
20663 - .data
20664 + .align PAGE_SIZE
20665 +ENTRY(cpu_gdt_table)
20666 + .rept NR_CPUS
20667 + .quad 0x0000000000000000 /* NULL descriptor */
20668 + .quad 0x00cf9b000000ffff /* __KERNEL32_CS */
20669 + .quad 0x00af9b000000ffff /* __KERNEL_CS */
20670 + .quad 0x00cf93000000ffff /* __KERNEL_DS */
20671 + .quad 0x00cffb000000ffff /* __USER32_CS */
20672 + .quad 0x00cff3000000ffff /* __USER_DS, __USER32_DS */
20673 + .quad 0x00affb000000ffff /* __USER_CS */
20674 +
20675 +#ifdef CONFIG_PAX_KERNEXEC
20676 + .quad 0x00af9b000000ffff /* __KERNEXEC_KERNEL_CS */
20677 +#else
20678 + .quad 0x0 /* unused */
20679 +#endif
20680 +
20681 + .quad 0,0 /* TSS */
20682 + .quad 0,0 /* LDT */
20683 + .quad 0,0,0 /* three TLS descriptors */
20684 + .quad 0x0000f40000000000 /* node/CPU stored in limit */
20685 + /* asm/segment.h:GDT_ENTRIES must match this */
20686 +
20687 + /* zero the remaining page */
20688 + .fill PAGE_SIZE / 8 - GDT_ENTRIES,8,0
20689 + .endr
20690 +
20691 .align 16
20692 .globl early_gdt_descr
20693 early_gdt_descr:
20694 .word GDT_ENTRIES*8-1
20695 early_gdt_descr_base:
20696 - .quad INIT_PER_CPU_VAR(gdt_page)
20697 + .quad cpu_gdt_table
20698
20699 ENTRY(phys_base)
20700 /* This must match the first entry in level2_kernel_pgt */
20701 .quad 0x0000000000000000
20702
20703 #include "../../x86/xen/xen-head.S"
20704 -
20705 - .section .bss, "aw", @nobits
20706 +
20707 + .section .rodata,"a",@progbits
20708 .align L1_CACHE_BYTES
20709 ENTRY(idt_table)
20710 - .skip IDT_ENTRIES * 16
20711 + .fill 512,8,0
20712
20713 .align L1_CACHE_BYTES
20714 ENTRY(nmi_idt_table)
20715 - .skip IDT_ENTRIES * 16
20716 + .fill 512,8,0
20717
20718 __PAGE_ALIGNED_BSS
20719 NEXT_PAGE(empty_zero_page)
20720 diff --git a/arch/x86/kernel/i386_ksyms_32.c b/arch/x86/kernel/i386_ksyms_32.c
20721 index 0fa6912..37fce70 100644
20722 --- a/arch/x86/kernel/i386_ksyms_32.c
20723 +++ b/arch/x86/kernel/i386_ksyms_32.c
20724 @@ -20,8 +20,12 @@ extern void cmpxchg8b_emu(void);
20725 EXPORT_SYMBOL(cmpxchg8b_emu);
20726 #endif
20727
20728 +EXPORT_SYMBOL_GPL(cpu_gdt_table);
20729 +
20730 /* Networking helper routines. */
20731 EXPORT_SYMBOL(csum_partial_copy_generic);
20732 +EXPORT_SYMBOL(csum_partial_copy_generic_to_user);
20733 +EXPORT_SYMBOL(csum_partial_copy_generic_from_user);
20734
20735 EXPORT_SYMBOL(__get_user_1);
20736 EXPORT_SYMBOL(__get_user_2);
20737 @@ -37,3 +41,7 @@ EXPORT_SYMBOL(strstr);
20738
20739 EXPORT_SYMBOL(csum_partial);
20740 EXPORT_SYMBOL(empty_zero_page);
20741 +
20742 +#ifdef CONFIG_PAX_KERNEXEC
20743 +EXPORT_SYMBOL(__LOAD_PHYSICAL_ADDR);
20744 +#endif
20745 diff --git a/arch/x86/kernel/i387.c b/arch/x86/kernel/i387.c
20746 index 245a71d..89d9ce4 100644
20747 --- a/arch/x86/kernel/i387.c
20748 +++ b/arch/x86/kernel/i387.c
20749 @@ -55,7 +55,7 @@ static inline bool interrupted_kernel_fpu_idle(void)
20750 static inline bool interrupted_user_mode(void)
20751 {
20752 struct pt_regs *regs = get_irq_regs();
20753 - return regs && user_mode_vm(regs);
20754 + return regs && user_mode(regs);
20755 }
20756
20757 /*
20758 diff --git a/arch/x86/kernel/i8259.c b/arch/x86/kernel/i8259.c
20759 index 9a5c460..84868423 100644
20760 --- a/arch/x86/kernel/i8259.c
20761 +++ b/arch/x86/kernel/i8259.c
20762 @@ -110,7 +110,7 @@ static int i8259A_irq_pending(unsigned int irq)
20763 static void make_8259A_irq(unsigned int irq)
20764 {
20765 disable_irq_nosync(irq);
20766 - io_apic_irqs &= ~(1<<irq);
20767 + io_apic_irqs &= ~(1UL<<irq);
20768 irq_set_chip_and_handler_name(irq, &i8259A_chip, handle_level_irq,
20769 i8259A_chip.name);
20770 enable_irq(irq);
20771 @@ -209,7 +209,7 @@ spurious_8259A_irq:
20772 "spurious 8259A interrupt: IRQ%d.\n", irq);
20773 spurious_irq_mask |= irqmask;
20774 }
20775 - atomic_inc(&irq_err_count);
20776 + atomic_inc_unchecked(&irq_err_count);
20777 /*
20778 * Theoretically we do not have to handle this IRQ,
20779 * but in Linux this does not cause problems and is
20780 @@ -333,14 +333,16 @@ static void init_8259A(int auto_eoi)
20781 /* (slave's support for AEOI in flat mode is to be investigated) */
20782 outb_pic(SLAVE_ICW4_DEFAULT, PIC_SLAVE_IMR);
20783
20784 + pax_open_kernel();
20785 if (auto_eoi)
20786 /*
20787 * In AEOI mode we just have to mask the interrupt
20788 * when acking.
20789 */
20790 - i8259A_chip.irq_mask_ack = disable_8259A_irq;
20791 + *(void **)&i8259A_chip.irq_mask_ack = disable_8259A_irq;
20792 else
20793 - i8259A_chip.irq_mask_ack = mask_and_ack_8259A;
20794 + *(void **)&i8259A_chip.irq_mask_ack = mask_and_ack_8259A;
20795 + pax_close_kernel();
20796
20797 udelay(100); /* wait for 8259A to initialize */
20798
20799 diff --git a/arch/x86/kernel/io_delay.c b/arch/x86/kernel/io_delay.c
20800 index a979b5b..1d6db75 100644
20801 --- a/arch/x86/kernel/io_delay.c
20802 +++ b/arch/x86/kernel/io_delay.c
20803 @@ -58,7 +58,7 @@ static int __init dmi_io_delay_0xed_port(const struct dmi_system_id *id)
20804 * Quirk table for systems that misbehave (lock up, etc.) if port
20805 * 0x80 is used:
20806 */
20807 -static struct dmi_system_id __initdata io_delay_0xed_port_dmi_table[] = {
20808 +static const struct dmi_system_id __initconst io_delay_0xed_port_dmi_table[] = {
20809 {
20810 .callback = dmi_io_delay_0xed_port,
20811 .ident = "Compaq Presario V6000",
20812 diff --git a/arch/x86/kernel/ioport.c b/arch/x86/kernel/ioport.c
20813 index 4ddaf66..6292f4e 100644
20814 --- a/arch/x86/kernel/ioport.c
20815 +++ b/arch/x86/kernel/ioport.c
20816 @@ -6,6 +6,7 @@
20817 #include <linux/sched.h>
20818 #include <linux/kernel.h>
20819 #include <linux/capability.h>
20820 +#include <linux/security.h>
20821 #include <linux/errno.h>
20822 #include <linux/types.h>
20823 #include <linux/ioport.h>
20824 @@ -28,6 +29,12 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
20825
20826 if ((from + num <= from) || (from + num > IO_BITMAP_BITS))
20827 return -EINVAL;
20828 +#ifdef CONFIG_GRKERNSEC_IO
20829 + if (turn_on && grsec_disable_privio) {
20830 + gr_handle_ioperm();
20831 + return -EPERM;
20832 + }
20833 +#endif
20834 if (turn_on && !capable(CAP_SYS_RAWIO))
20835 return -EPERM;
20836
20837 @@ -54,7 +61,7 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
20838 * because the ->io_bitmap_max value must match the bitmap
20839 * contents:
20840 */
20841 - tss = &per_cpu(init_tss, get_cpu());
20842 + tss = init_tss + get_cpu();
20843
20844 if (turn_on)
20845 bitmap_clear(t->io_bitmap_ptr, from, num);
20846 @@ -103,6 +110,12 @@ SYSCALL_DEFINE1(iopl, unsigned int, level)
20847 return -EINVAL;
20848 /* Trying to gain more privileges? */
20849 if (level > old) {
20850 +#ifdef CONFIG_GRKERNSEC_IO
20851 + if (grsec_disable_privio) {
20852 + gr_handle_iopl();
20853 + return -EPERM;
20854 + }
20855 +#endif
20856 if (!capable(CAP_SYS_RAWIO))
20857 return -EPERM;
20858 }
20859 diff --git a/arch/x86/kernel/irq.c b/arch/x86/kernel/irq.c
20860 index 84b7789..e65e8be 100644
20861 --- a/arch/x86/kernel/irq.c
20862 +++ b/arch/x86/kernel/irq.c
20863 @@ -18,7 +18,7 @@
20864 #include <asm/mce.h>
20865 #include <asm/hw_irq.h>
20866
20867 -atomic_t irq_err_count;
20868 +atomic_unchecked_t irq_err_count;
20869
20870 /* Function pointer for generic interrupt vector handling */
20871 void (*x86_platform_ipi_callback)(void) = NULL;
20872 @@ -122,9 +122,9 @@ int arch_show_interrupts(struct seq_file *p, int prec)
20873 seq_printf(p, "%10u ", per_cpu(mce_poll_count, j));
20874 seq_printf(p, " Machine check polls\n");
20875 #endif
20876 - seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read(&irq_err_count));
20877 + seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read_unchecked(&irq_err_count));
20878 #if defined(CONFIG_X86_IO_APIC)
20879 - seq_printf(p, "%*s: %10u\n", prec, "MIS", atomic_read(&irq_mis_count));
20880 + seq_printf(p, "%*s: %10u\n", prec, "MIS", atomic_read_unchecked(&irq_mis_count));
20881 #endif
20882 return 0;
20883 }
20884 @@ -164,7 +164,7 @@ u64 arch_irq_stat_cpu(unsigned int cpu)
20885
20886 u64 arch_irq_stat(void)
20887 {
20888 - u64 sum = atomic_read(&irq_err_count);
20889 + u64 sum = atomic_read_unchecked(&irq_err_count);
20890 return sum;
20891 }
20892
20893 diff --git a/arch/x86/kernel/irq_32.c b/arch/x86/kernel/irq_32.c
20894 index 344faf8..355f60d 100644
20895 --- a/arch/x86/kernel/irq_32.c
20896 +++ b/arch/x86/kernel/irq_32.c
20897 @@ -39,7 +39,7 @@ static int check_stack_overflow(void)
20898 __asm__ __volatile__("andl %%esp,%0" :
20899 "=r" (sp) : "0" (THREAD_SIZE - 1));
20900
20901 - return sp < (sizeof(struct thread_info) + STACK_WARN);
20902 + return sp < STACK_WARN;
20903 }
20904
20905 static void print_stack_overflow(void)
20906 @@ -59,8 +59,8 @@ static inline void print_stack_overflow(void) { }
20907 * per-CPU IRQ handling contexts (thread information and stack)
20908 */
20909 union irq_ctx {
20910 - struct thread_info tinfo;
20911 - u32 stack[THREAD_SIZE/sizeof(u32)];
20912 + unsigned long previous_esp;
20913 + u32 stack[THREAD_SIZE/sizeof(u32)];
20914 } __attribute__((aligned(THREAD_SIZE)));
20915
20916 static DEFINE_PER_CPU(union irq_ctx *, hardirq_ctx);
20917 @@ -80,10 +80,9 @@ static void call_on_stack(void *func, void *stack)
20918 static inline int
20919 execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
20920 {
20921 - union irq_ctx *curctx, *irqctx;
20922 + union irq_ctx *irqctx;
20923 u32 *isp, arg1, arg2;
20924
20925 - curctx = (union irq_ctx *) current_thread_info();
20926 irqctx = __this_cpu_read(hardirq_ctx);
20927
20928 /*
20929 @@ -92,16 +91,16 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
20930 * handler) we can't do that and just have to keep using the
20931 * current stack (which is the irq stack already after all)
20932 */
20933 - if (unlikely(curctx == irqctx))
20934 + if (unlikely((void *)current_stack_pointer - (void *)irqctx < THREAD_SIZE))
20935 return 0;
20936
20937 /* build the stack frame on the IRQ stack */
20938 - isp = (u32 *) ((char *)irqctx + sizeof(*irqctx));
20939 - irqctx->tinfo.task = curctx->tinfo.task;
20940 - irqctx->tinfo.previous_esp = current_stack_pointer;
20941 + isp = (u32 *) ((char *)irqctx + sizeof(*irqctx) - 8);
20942 + irqctx->previous_esp = current_stack_pointer;
20943
20944 - /* Copy the preempt_count so that the [soft]irq checks work. */
20945 - irqctx->tinfo.preempt_count = curctx->tinfo.preempt_count;
20946 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20947 + __set_fs(MAKE_MM_SEG(0));
20948 +#endif
20949
20950 if (unlikely(overflow))
20951 call_on_stack(print_stack_overflow, isp);
20952 @@ -113,6 +112,11 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
20953 : "0" (irq), "1" (desc), "2" (isp),
20954 "D" (desc->handle_irq)
20955 : "memory", "cc", "ecx");
20956 +
20957 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20958 + __set_fs(current_thread_info()->addr_limit);
20959 +#endif
20960 +
20961 return 1;
20962 }
20963
20964 @@ -121,29 +125,14 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
20965 */
20966 void __cpuinit irq_ctx_init(int cpu)
20967 {
20968 - union irq_ctx *irqctx;
20969 -
20970 if (per_cpu(hardirq_ctx, cpu))
20971 return;
20972
20973 - irqctx = page_address(alloc_pages_node(cpu_to_node(cpu),
20974 - THREADINFO_GFP,
20975 - THREAD_SIZE_ORDER));
20976 - memset(&irqctx->tinfo, 0, sizeof(struct thread_info));
20977 - irqctx->tinfo.cpu = cpu;
20978 - irqctx->tinfo.preempt_count = HARDIRQ_OFFSET;
20979 - irqctx->tinfo.addr_limit = MAKE_MM_SEG(0);
20980 -
20981 - per_cpu(hardirq_ctx, cpu) = irqctx;
20982 -
20983 - irqctx = page_address(alloc_pages_node(cpu_to_node(cpu),
20984 - THREADINFO_GFP,
20985 - THREAD_SIZE_ORDER));
20986 - memset(&irqctx->tinfo, 0, sizeof(struct thread_info));
20987 - irqctx->tinfo.cpu = cpu;
20988 - irqctx->tinfo.addr_limit = MAKE_MM_SEG(0);
20989 -
20990 - per_cpu(softirq_ctx, cpu) = irqctx;
20991 + per_cpu(hardirq_ctx, cpu) = page_address(alloc_pages_node(cpu_to_node(cpu), THREADINFO_GFP, THREAD_SIZE_ORDER));
20992 + per_cpu(softirq_ctx, cpu) = page_address(alloc_pages_node(cpu_to_node(cpu), THREADINFO_GFP, THREAD_SIZE_ORDER));
20993 +
20994 + printk(KERN_DEBUG "CPU %u irqstacks, hard=%p soft=%p\n",
20995 + cpu, per_cpu(hardirq_ctx, cpu), per_cpu(softirq_ctx, cpu));
20996
20997 printk(KERN_DEBUG "CPU %u irqstacks, hard=%p soft=%p\n",
20998 cpu, per_cpu(hardirq_ctx, cpu), per_cpu(softirq_ctx, cpu));
20999 @@ -152,7 +141,6 @@ void __cpuinit irq_ctx_init(int cpu)
21000 asmlinkage void do_softirq(void)
21001 {
21002 unsigned long flags;
21003 - struct thread_info *curctx;
21004 union irq_ctx *irqctx;
21005 u32 *isp;
21006
21007 @@ -162,15 +150,22 @@ asmlinkage void do_softirq(void)
21008 local_irq_save(flags);
21009
21010 if (local_softirq_pending()) {
21011 - curctx = current_thread_info();
21012 irqctx = __this_cpu_read(softirq_ctx);
21013 - irqctx->tinfo.task = curctx->task;
21014 - irqctx->tinfo.previous_esp = current_stack_pointer;
21015 + irqctx->previous_esp = current_stack_pointer;
21016
21017 /* build the stack frame on the softirq stack */
21018 - isp = (u32 *) ((char *)irqctx + sizeof(*irqctx));
21019 + isp = (u32 *) ((char *)irqctx + sizeof(*irqctx) - 8);
21020 +
21021 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21022 + __set_fs(MAKE_MM_SEG(0));
21023 +#endif
21024
21025 call_on_stack(__do_softirq, isp);
21026 +
21027 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21028 + __set_fs(current_thread_info()->addr_limit);
21029 +#endif
21030 +
21031 /*
21032 * Shouldn't happen, we returned above if in_interrupt():
21033 */
21034 @@ -191,7 +186,7 @@ bool handle_irq(unsigned irq, struct pt_regs *regs)
21035 if (unlikely(!desc))
21036 return false;
21037
21038 - if (user_mode_vm(regs) || !execute_on_irq_stack(overflow, desc, irq)) {
21039 + if (user_mode(regs) || !execute_on_irq_stack(overflow, desc, irq)) {
21040 if (unlikely(overflow))
21041 print_stack_overflow();
21042 desc->handle_irq(irq, desc);
21043 diff --git a/arch/x86/kernel/irq_64.c b/arch/x86/kernel/irq_64.c
21044 index d04d3ec..ea4b374 100644
21045 --- a/arch/x86/kernel/irq_64.c
21046 +++ b/arch/x86/kernel/irq_64.c
21047 @@ -44,7 +44,7 @@ static inline void stack_overflow_check(struct pt_regs *regs)
21048 u64 estack_top, estack_bottom;
21049 u64 curbase = (u64)task_stack_page(current);
21050
21051 - if (user_mode_vm(regs))
21052 + if (user_mode(regs))
21053 return;
21054
21055 if (regs->sp >= curbase + sizeof(struct thread_info) +
21056 diff --git a/arch/x86/kernel/kdebugfs.c b/arch/x86/kernel/kdebugfs.c
21057 index dc1404b..bbc43e7 100644
21058 --- a/arch/x86/kernel/kdebugfs.c
21059 +++ b/arch/x86/kernel/kdebugfs.c
21060 @@ -27,7 +27,7 @@ struct setup_data_node {
21061 u32 len;
21062 };
21063
21064 -static ssize_t setup_data_read(struct file *file, char __user *user_buf,
21065 +static ssize_t __size_overflow(3) setup_data_read(struct file *file, char __user *user_buf,
21066 size_t count, loff_t *ppos)
21067 {
21068 struct setup_data_node *node = file->private_data;
21069 diff --git a/arch/x86/kernel/kgdb.c b/arch/x86/kernel/kgdb.c
21070 index 836f832..a8bda67 100644
21071 --- a/arch/x86/kernel/kgdb.c
21072 +++ b/arch/x86/kernel/kgdb.c
21073 @@ -127,11 +127,11 @@ char *dbg_get_reg(int regno, void *mem, struct pt_regs *regs)
21074 #ifdef CONFIG_X86_32
21075 switch (regno) {
21076 case GDB_SS:
21077 - if (!user_mode_vm(regs))
21078 + if (!user_mode(regs))
21079 *(unsigned long *)mem = __KERNEL_DS;
21080 break;
21081 case GDB_SP:
21082 - if (!user_mode_vm(regs))
21083 + if (!user_mode(regs))
21084 *(unsigned long *)mem = kernel_stack_pointer(regs);
21085 break;
21086 case GDB_GS:
21087 @@ -229,7 +229,10 @@ static void kgdb_correct_hw_break(void)
21088 bp->attr.bp_addr = breakinfo[breakno].addr;
21089 bp->attr.bp_len = breakinfo[breakno].len;
21090 bp->attr.bp_type = breakinfo[breakno].type;
21091 - info->address = breakinfo[breakno].addr;
21092 + if (breakinfo[breakno].type == X86_BREAKPOINT_EXECUTE)
21093 + info->address = ktla_ktva(breakinfo[breakno].addr);
21094 + else
21095 + info->address = breakinfo[breakno].addr;
21096 info->len = breakinfo[breakno].len;
21097 info->type = breakinfo[breakno].type;
21098 val = arch_install_hw_breakpoint(bp);
21099 @@ -476,12 +479,12 @@ int kgdb_arch_handle_exception(int e_vector, int signo, int err_code,
21100 case 'k':
21101 /* clear the trace bit */
21102 linux_regs->flags &= ~X86_EFLAGS_TF;
21103 - atomic_set(&kgdb_cpu_doing_single_step, -1);
21104 + atomic_set_unchecked(&kgdb_cpu_doing_single_step, -1);
21105
21106 /* set the trace bit if we're stepping */
21107 if (remcomInBuffer[0] == 's') {
21108 linux_regs->flags |= X86_EFLAGS_TF;
21109 - atomic_set(&kgdb_cpu_doing_single_step,
21110 + atomic_set_unchecked(&kgdb_cpu_doing_single_step,
21111 raw_smp_processor_id());
21112 }
21113
21114 @@ -546,7 +549,7 @@ static int __kgdb_notify(struct die_args *args, unsigned long cmd)
21115
21116 switch (cmd) {
21117 case DIE_DEBUG:
21118 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1) {
21119 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1) {
21120 if (user_mode(regs))
21121 return single_step_cont(regs, args);
21122 break;
21123 @@ -751,11 +754,11 @@ int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
21124 #endif /* CONFIG_DEBUG_RODATA */
21125
21126 bpt->type = BP_BREAKPOINT;
21127 - err = probe_kernel_read(bpt->saved_instr, (char *)bpt->bpt_addr,
21128 + err = probe_kernel_read(bpt->saved_instr, ktla_ktva((char *)bpt->bpt_addr),
21129 BREAK_INSTR_SIZE);
21130 if (err)
21131 return err;
21132 - err = probe_kernel_write((char *)bpt->bpt_addr,
21133 + err = probe_kernel_write(ktla_ktva((char *)bpt->bpt_addr),
21134 arch_kgdb_ops.gdb_bpt_instr, BREAK_INSTR_SIZE);
21135 #ifdef CONFIG_DEBUG_RODATA
21136 if (!err)
21137 @@ -768,7 +771,7 @@ int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
21138 return -EBUSY;
21139 text_poke((void *)bpt->bpt_addr, arch_kgdb_ops.gdb_bpt_instr,
21140 BREAK_INSTR_SIZE);
21141 - err = probe_kernel_read(opc, (char *)bpt->bpt_addr, BREAK_INSTR_SIZE);
21142 + err = probe_kernel_read(opc, ktla_ktva((char *)bpt->bpt_addr), BREAK_INSTR_SIZE);
21143 if (err)
21144 return err;
21145 if (memcmp(opc, arch_kgdb_ops.gdb_bpt_instr, BREAK_INSTR_SIZE))
21146 @@ -793,13 +796,13 @@ int kgdb_arch_remove_breakpoint(struct kgdb_bkpt *bpt)
21147 if (mutex_is_locked(&text_mutex))
21148 goto knl_write;
21149 text_poke((void *)bpt->bpt_addr, bpt->saved_instr, BREAK_INSTR_SIZE);
21150 - err = probe_kernel_read(opc, (char *)bpt->bpt_addr, BREAK_INSTR_SIZE);
21151 + err = probe_kernel_read(opc, ktla_ktva((char *)bpt->bpt_addr), BREAK_INSTR_SIZE);
21152 if (err || memcmp(opc, bpt->saved_instr, BREAK_INSTR_SIZE))
21153 goto knl_write;
21154 return err;
21155 knl_write:
21156 #endif /* CONFIG_DEBUG_RODATA */
21157 - return probe_kernel_write((char *)bpt->bpt_addr,
21158 + return probe_kernel_write(ktla_ktva((char *)bpt->bpt_addr),
21159 (char *)bpt->saved_instr, BREAK_INSTR_SIZE);
21160 }
21161
21162 diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c
21163 index 7bfe318..383d238 100644
21164 --- a/arch/x86/kernel/kprobes/core.c
21165 +++ b/arch/x86/kernel/kprobes/core.c
21166 @@ -119,9 +119,12 @@ static void __kprobes __synthesize_relative_insn(void *from, void *to, u8 op)
21167 s32 raddr;
21168 } __packed *insn;
21169
21170 - insn = (struct __arch_relative_insn *)from;
21171 + insn = (struct __arch_relative_insn *)ktla_ktva(from);
21172 +
21173 + pax_open_kernel();
21174 insn->raddr = (s32)((long)(to) - ((long)(from) + 5));
21175 insn->op = op;
21176 + pax_close_kernel();
21177 }
21178
21179 /* Insert a jump instruction at address 'from', which jumps to address 'to'.*/
21180 @@ -164,7 +167,7 @@ int __kprobes can_boost(kprobe_opcode_t *opcodes)
21181 kprobe_opcode_t opcode;
21182 kprobe_opcode_t *orig_opcodes = opcodes;
21183
21184 - if (search_exception_tables((unsigned long)opcodes))
21185 + if (search_exception_tables(ktva_ktla((unsigned long)opcodes)))
21186 return 0; /* Page fault may occur on this address. */
21187
21188 retry:
21189 @@ -238,9 +241,9 @@ __recover_probed_insn(kprobe_opcode_t *buf, unsigned long addr)
21190 * for the first byte, we can recover the original instruction
21191 * from it and kp->opcode.
21192 */
21193 - memcpy(buf, kp->addr, MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
21194 + memcpy(buf, ktla_ktva(kp->addr), MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
21195 buf[0] = kp->opcode;
21196 - return (unsigned long)buf;
21197 + return ktva_ktla((unsigned long)buf);
21198 }
21199
21200 /*
21201 @@ -332,7 +335,9 @@ int __kprobes __copy_instruction(u8 *dest, u8 *src)
21202 /* Another subsystem puts a breakpoint, failed to recover */
21203 if (insn.opcode.bytes[0] == BREAKPOINT_INSTRUCTION)
21204 return 0;
21205 + pax_open_kernel();
21206 memcpy(dest, insn.kaddr, insn.length);
21207 + pax_close_kernel();
21208
21209 #ifdef CONFIG_X86_64
21210 if (insn_rip_relative(&insn)) {
21211 @@ -355,7 +360,9 @@ int __kprobes __copy_instruction(u8 *dest, u8 *src)
21212 newdisp = (u8 *) src + (s64) insn.displacement.value - (u8 *) dest;
21213 BUG_ON((s64) (s32) newdisp != newdisp); /* Sanity check. */
21214 disp = (u8 *) dest + insn_offset_displacement(&insn);
21215 + pax_open_kernel();
21216 *(s32 *) disp = (s32) newdisp;
21217 + pax_close_kernel();
21218 }
21219 #endif
21220 return insn.length;
21221 @@ -488,7 +495,7 @@ setup_singlestep(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *k
21222 * nor set current_kprobe, because it doesn't use single
21223 * stepping.
21224 */
21225 - regs->ip = (unsigned long)p->ainsn.insn;
21226 + regs->ip = ktva_ktla((unsigned long)p->ainsn.insn);
21227 preempt_enable_no_resched();
21228 return;
21229 }
21230 @@ -505,9 +512,9 @@ setup_singlestep(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *k
21231 regs->flags &= ~X86_EFLAGS_IF;
21232 /* single step inline if the instruction is an int3 */
21233 if (p->opcode == BREAKPOINT_INSTRUCTION)
21234 - regs->ip = (unsigned long)p->addr;
21235 + regs->ip = ktla_ktva((unsigned long)p->addr);
21236 else
21237 - regs->ip = (unsigned long)p->ainsn.insn;
21238 + regs->ip = ktva_ktla((unsigned long)p->ainsn.insn);
21239 }
21240
21241 /*
21242 @@ -586,7 +593,7 @@ static int __kprobes kprobe_handler(struct pt_regs *regs)
21243 setup_singlestep(p, regs, kcb, 0);
21244 return 1;
21245 }
21246 - } else if (*addr != BREAKPOINT_INSTRUCTION) {
21247 + } else if (*(kprobe_opcode_t *)ktla_ktva((unsigned long)addr) != BREAKPOINT_INSTRUCTION) {
21248 /*
21249 * The breakpoint instruction was removed right
21250 * after we hit it. Another cpu has removed
21251 @@ -632,6 +639,9 @@ static void __used __kprobes kretprobe_trampoline_holder(void)
21252 " movq %rax, 152(%rsp)\n"
21253 RESTORE_REGS_STRING
21254 " popfq\n"
21255 +#ifdef KERNEXEC_PLUGIN
21256 + " btsq $63,(%rsp)\n"
21257 +#endif
21258 #else
21259 " pushf\n"
21260 SAVE_REGS_STRING
21261 @@ -769,7 +779,7 @@ static void __kprobes
21262 resume_execution(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *kcb)
21263 {
21264 unsigned long *tos = stack_addr(regs);
21265 - unsigned long copy_ip = (unsigned long)p->ainsn.insn;
21266 + unsigned long copy_ip = ktva_ktla((unsigned long)p->ainsn.insn);
21267 unsigned long orig_ip = (unsigned long)p->addr;
21268 kprobe_opcode_t *insn = p->ainsn.insn;
21269
21270 @@ -951,7 +961,7 @@ kprobe_exceptions_notify(struct notifier_block *self, unsigned long val, void *d
21271 struct die_args *args = data;
21272 int ret = NOTIFY_DONE;
21273
21274 - if (args->regs && user_mode_vm(args->regs))
21275 + if (args->regs && user_mode(args->regs))
21276 return ret;
21277
21278 switch (val) {
21279 diff --git a/arch/x86/kernel/kprobes/opt.c b/arch/x86/kernel/kprobes/opt.c
21280 index 76dc6f0..66bdfc3 100644
21281 --- a/arch/x86/kernel/kprobes/opt.c
21282 +++ b/arch/x86/kernel/kprobes/opt.c
21283 @@ -79,6 +79,7 @@ found:
21284 /* Insert a move instruction which sets a pointer to eax/rdi (1st arg). */
21285 static void __kprobes synthesize_set_arg1(kprobe_opcode_t *addr, unsigned long val)
21286 {
21287 + pax_open_kernel();
21288 #ifdef CONFIG_X86_64
21289 *addr++ = 0x48;
21290 *addr++ = 0xbf;
21291 @@ -86,6 +87,7 @@ static void __kprobes synthesize_set_arg1(kprobe_opcode_t *addr, unsigned long v
21292 *addr++ = 0xb8;
21293 #endif
21294 *(unsigned long *)addr = val;
21295 + pax_close_kernel();
21296 }
21297
21298 static void __used __kprobes kprobes_optinsn_template_holder(void)
21299 @@ -338,7 +340,7 @@ int __kprobes arch_prepare_optimized_kprobe(struct optimized_kprobe *op)
21300 * Verify if the address gap is in 2GB range, because this uses
21301 * a relative jump.
21302 */
21303 - rel = (long)op->optinsn.insn - (long)op->kp.addr + RELATIVEJUMP_SIZE;
21304 + rel = (long)op->optinsn.insn - ktla_ktva((long)op->kp.addr) + RELATIVEJUMP_SIZE;
21305 if (abs(rel) > 0x7fffffff)
21306 return -ERANGE;
21307
21308 @@ -353,16 +355,18 @@ int __kprobes arch_prepare_optimized_kprobe(struct optimized_kprobe *op)
21309 op->optinsn.size = ret;
21310
21311 /* Copy arch-dep-instance from template */
21312 - memcpy(buf, &optprobe_template_entry, TMPL_END_IDX);
21313 + pax_open_kernel();
21314 + memcpy(buf, ktla_ktva(&optprobe_template_entry), TMPL_END_IDX);
21315 + pax_close_kernel();
21316
21317 /* Set probe information */
21318 synthesize_set_arg1(buf + TMPL_MOVE_IDX, (unsigned long)op);
21319
21320 /* Set probe function call */
21321 - synthesize_relcall(buf + TMPL_CALL_IDX, optimized_callback);
21322 + synthesize_relcall(ktva_ktla(buf) + TMPL_CALL_IDX, optimized_callback);
21323
21324 /* Set returning jmp instruction at the tail of out-of-line buffer */
21325 - synthesize_reljump(buf + TMPL_END_IDX + op->optinsn.size,
21326 + synthesize_reljump(ktva_ktla(buf) + TMPL_END_IDX + op->optinsn.size,
21327 (u8 *)op->kp.addr + op->optinsn.size);
21328
21329 flush_icache_range((unsigned long) buf,
21330 @@ -385,7 +389,7 @@ static void __kprobes setup_optimize_kprobe(struct text_poke_param *tprm,
21331 ((long)op->kp.addr + RELATIVEJUMP_SIZE));
21332
21333 /* Backup instructions which will be replaced by jump address */
21334 - memcpy(op->optinsn.copied_insn, op->kp.addr + INT3_SIZE,
21335 + memcpy(op->optinsn.copied_insn, ktla_ktva(op->kp.addr) + INT3_SIZE,
21336 RELATIVE_ADDR_SIZE);
21337
21338 insn_buf[0] = RELATIVEJUMP_OPCODE;
21339 @@ -483,7 +487,7 @@ setup_detour_execution(struct kprobe *p, struct pt_regs *regs, int reenter)
21340 /* This kprobe is really able to run optimized path. */
21341 op = container_of(p, struct optimized_kprobe, kp);
21342 /* Detour through copied instructions */
21343 - regs->ip = (unsigned long)op->optinsn.insn + TMPL_END_IDX;
21344 + regs->ip = ktva_ktla((unsigned long)op->optinsn.insn) + TMPL_END_IDX;
21345 if (!reenter)
21346 reset_current_kprobe();
21347 preempt_enable_no_resched();
21348 diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c
21349 index b686a90..60d36fb 100644
21350 --- a/arch/x86/kernel/kvm.c
21351 +++ b/arch/x86/kernel/kvm.c
21352 @@ -453,7 +453,7 @@ static int __cpuinit kvm_cpu_notify(struct notifier_block *self,
21353 return NOTIFY_OK;
21354 }
21355
21356 -static struct notifier_block __cpuinitdata kvm_cpu_notifier = {
21357 +static struct notifier_block kvm_cpu_notifier = {
21358 .notifier_call = kvm_cpu_notify,
21359 };
21360 #endif
21361 diff --git a/arch/x86/kernel/ldt.c b/arch/x86/kernel/ldt.c
21362 index ebc9873..1b9724b 100644
21363 --- a/arch/x86/kernel/ldt.c
21364 +++ b/arch/x86/kernel/ldt.c
21365 @@ -66,13 +66,13 @@ static int alloc_ldt(mm_context_t *pc, int mincount, int reload)
21366 if (reload) {
21367 #ifdef CONFIG_SMP
21368 preempt_disable();
21369 - load_LDT(pc);
21370 + load_LDT_nolock(pc);
21371 if (!cpumask_equal(mm_cpumask(current->mm),
21372 cpumask_of(smp_processor_id())))
21373 smp_call_function(flush_ldt, current->mm, 1);
21374 preempt_enable();
21375 #else
21376 - load_LDT(pc);
21377 + load_LDT_nolock(pc);
21378 #endif
21379 }
21380 if (oldsize) {
21381 @@ -94,7 +94,7 @@ static inline int copy_ldt(mm_context_t *new, mm_context_t *old)
21382 return err;
21383
21384 for (i = 0; i < old->size; i++)
21385 - write_ldt_entry(new->ldt, i, old->ldt + i * LDT_ENTRY_SIZE);
21386 + write_ldt_entry(new->ldt, i, old->ldt + i);
21387 return 0;
21388 }
21389
21390 @@ -115,6 +115,24 @@ int init_new_context(struct task_struct *tsk, struct mm_struct *mm)
21391 retval = copy_ldt(&mm->context, &old_mm->context);
21392 mutex_unlock(&old_mm->context.lock);
21393 }
21394 +
21395 + if (tsk == current) {
21396 + mm->context.vdso = 0;
21397 +
21398 +#ifdef CONFIG_X86_32
21399 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
21400 + mm->context.user_cs_base = 0UL;
21401 + mm->context.user_cs_limit = ~0UL;
21402 +
21403 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
21404 + cpus_clear(mm->context.cpu_user_cs_mask);
21405 +#endif
21406 +
21407 +#endif
21408 +#endif
21409 +
21410 + }
21411 +
21412 return retval;
21413 }
21414
21415 @@ -229,6 +247,13 @@ static int write_ldt(void __user *ptr, unsigned long bytecount, int oldmode)
21416 }
21417 }
21418
21419 +#ifdef CONFIG_PAX_SEGMEXEC
21420 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (ldt_info.contents & MODIFY_LDT_CONTENTS_CODE)) {
21421 + error = -EINVAL;
21422 + goto out_unlock;
21423 + }
21424 +#endif
21425 +
21426 fill_ldt(&ldt, &ldt_info);
21427 if (oldmode)
21428 ldt.avl = 0;
21429 diff --git a/arch/x86/kernel/machine_kexec_32.c b/arch/x86/kernel/machine_kexec_32.c
21430 index 5b19e4d..6476a76 100644
21431 --- a/arch/x86/kernel/machine_kexec_32.c
21432 +++ b/arch/x86/kernel/machine_kexec_32.c
21433 @@ -26,7 +26,7 @@
21434 #include <asm/cacheflush.h>
21435 #include <asm/debugreg.h>
21436
21437 -static void set_idt(void *newidt, __u16 limit)
21438 +static void set_idt(struct desc_struct *newidt, __u16 limit)
21439 {
21440 struct desc_ptr curidt;
21441
21442 @@ -38,7 +38,7 @@ static void set_idt(void *newidt, __u16 limit)
21443 }
21444
21445
21446 -static void set_gdt(void *newgdt, __u16 limit)
21447 +static void set_gdt(struct desc_struct *newgdt, __u16 limit)
21448 {
21449 struct desc_ptr curgdt;
21450
21451 @@ -216,7 +216,7 @@ void machine_kexec(struct kimage *image)
21452 }
21453
21454 control_page = page_address(image->control_code_page);
21455 - memcpy(control_page, relocate_kernel, KEXEC_CONTROL_CODE_MAX_SIZE);
21456 + memcpy(control_page, (void *)ktla_ktva((unsigned long)relocate_kernel), KEXEC_CONTROL_CODE_MAX_SIZE);
21457
21458 relocate_kernel_ptr = control_page;
21459 page_list[PA_CONTROL_PAGE] = __pa(control_page);
21460 diff --git a/arch/x86/kernel/microcode_core.c b/arch/x86/kernel/microcode_core.c
21461 index 22db92b..d546bec 100644
21462 --- a/arch/x86/kernel/microcode_core.c
21463 +++ b/arch/x86/kernel/microcode_core.c
21464 @@ -513,7 +513,7 @@ mc_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu)
21465 return NOTIFY_OK;
21466 }
21467
21468 -static struct notifier_block __refdata mc_cpu_notifier = {
21469 +static struct notifier_block mc_cpu_notifier = {
21470 .notifier_call = mc_cpu_callback,
21471 };
21472
21473 diff --git a/arch/x86/kernel/microcode_intel.c b/arch/x86/kernel/microcode_intel.c
21474 index 5fb2ceb..3ae90bb 100644
21475 --- a/arch/x86/kernel/microcode_intel.c
21476 +++ b/arch/x86/kernel/microcode_intel.c
21477 @@ -293,13 +293,13 @@ static enum ucode_state request_microcode_fw(int cpu, struct device *device,
21478
21479 static int get_ucode_user(void *to, const void *from, size_t n)
21480 {
21481 - return copy_from_user(to, from, n);
21482 + return copy_from_user(to, (const void __force_user *)from, n);
21483 }
21484
21485 static enum ucode_state
21486 request_microcode_user(int cpu, const void __user *buf, size_t size)
21487 {
21488 - return generic_load_microcode(cpu, (void *)buf, size, &get_ucode_user);
21489 + return generic_load_microcode(cpu, (__force_kernel void *)buf, size, &get_ucode_user);
21490 }
21491
21492 static void microcode_fini_cpu(int cpu)
21493 diff --git a/arch/x86/kernel/module.c b/arch/x86/kernel/module.c
21494 index 216a4d7..228255a 100644
21495 --- a/arch/x86/kernel/module.c
21496 +++ b/arch/x86/kernel/module.c
21497 @@ -43,15 +43,60 @@ do { \
21498 } while (0)
21499 #endif
21500
21501 -void *module_alloc(unsigned long size)
21502 +static inline void *__module_alloc(unsigned long size, pgprot_t prot)
21503 {
21504 - if (PAGE_ALIGN(size) > MODULES_LEN)
21505 + if (!size || PAGE_ALIGN(size) > MODULES_LEN)
21506 return NULL;
21507 return __vmalloc_node_range(size, 1, MODULES_VADDR, MODULES_END,
21508 - GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL_EXEC,
21509 + GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, prot,
21510 -1, __builtin_return_address(0));
21511 }
21512
21513 +void *module_alloc(unsigned long size)
21514 +{
21515 +
21516 +#ifdef CONFIG_PAX_KERNEXEC
21517 + return __module_alloc(size, PAGE_KERNEL);
21518 +#else
21519 + return __module_alloc(size, PAGE_KERNEL_EXEC);
21520 +#endif
21521 +
21522 +}
21523 +
21524 +#ifdef CONFIG_PAX_KERNEXEC
21525 +#ifdef CONFIG_X86_32
21526 +void *module_alloc_exec(unsigned long size)
21527 +{
21528 + struct vm_struct *area;
21529 +
21530 + if (size == 0)
21531 + return NULL;
21532 +
21533 + area = __get_vm_area(size, VM_ALLOC, (unsigned long)&MODULES_EXEC_VADDR, (unsigned long)&MODULES_EXEC_END);
21534 + return area ? area->addr : NULL;
21535 +}
21536 +EXPORT_SYMBOL(module_alloc_exec);
21537 +
21538 +void module_free_exec(struct module *mod, void *module_region)
21539 +{
21540 + vunmap(module_region);
21541 +}
21542 +EXPORT_SYMBOL(module_free_exec);
21543 +#else
21544 +void module_free_exec(struct module *mod, void *module_region)
21545 +{
21546 + module_free(mod, module_region);
21547 +}
21548 +EXPORT_SYMBOL(module_free_exec);
21549 +
21550 +void *module_alloc_exec(unsigned long size)
21551 +{
21552 + return __module_alloc(size, PAGE_KERNEL_RX);
21553 +}
21554 +EXPORT_SYMBOL(module_alloc_exec);
21555 +#endif
21556 +#endif
21557 +
21558 #ifdef CONFIG_X86_32
21559 int apply_relocate(Elf32_Shdr *sechdrs,
21560 const char *strtab,
21561 @@ -62,14 +107,16 @@ int apply_relocate(Elf32_Shdr *sechdrs,
21562 unsigned int i;
21563 Elf32_Rel *rel = (void *)sechdrs[relsec].sh_addr;
21564 Elf32_Sym *sym;
21565 - uint32_t *location;
21566 + uint32_t *plocation, location;
21567
21568 DEBUGP("Applying relocate section %u to %u\n",
21569 relsec, sechdrs[relsec].sh_info);
21570 for (i = 0; i < sechdrs[relsec].sh_size / sizeof(*rel); i++) {
21571 /* This is where to make the change */
21572 - location = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr
21573 - + rel[i].r_offset;
21574 + plocation = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr + rel[i].r_offset;
21575 + location = (uint32_t)plocation;
21576 + if (sechdrs[sechdrs[relsec].sh_info].sh_flags & SHF_EXECINSTR)
21577 + plocation = ktla_ktva((void *)plocation);
21578 /* This is the symbol it is referring to. Note that all
21579 undefined symbols have been resolved. */
21580 sym = (Elf32_Sym *)sechdrs[symindex].sh_addr
21581 @@ -78,11 +125,15 @@ int apply_relocate(Elf32_Shdr *sechdrs,
21582 switch (ELF32_R_TYPE(rel[i].r_info)) {
21583 case R_386_32:
21584 /* We add the value into the location given */
21585 - *location += sym->st_value;
21586 + pax_open_kernel();
21587 + *plocation += sym->st_value;
21588 + pax_close_kernel();
21589 break;
21590 case R_386_PC32:
21591 /* Add the value, subtract its position */
21592 - *location += sym->st_value - (uint32_t)location;
21593 + pax_open_kernel();
21594 + *plocation += sym->st_value - location;
21595 + pax_close_kernel();
21596 break;
21597 default:
21598 pr_err("%s: Unknown relocation: %u\n",
21599 @@ -127,21 +178,30 @@ int apply_relocate_add(Elf64_Shdr *sechdrs,
21600 case R_X86_64_NONE:
21601 break;
21602 case R_X86_64_64:
21603 + pax_open_kernel();
21604 *(u64 *)loc = val;
21605 + pax_close_kernel();
21606 break;
21607 case R_X86_64_32:
21608 + pax_open_kernel();
21609 *(u32 *)loc = val;
21610 + pax_close_kernel();
21611 if (val != *(u32 *)loc)
21612 goto overflow;
21613 break;
21614 case R_X86_64_32S:
21615 + pax_open_kernel();
21616 *(s32 *)loc = val;
21617 + pax_close_kernel();
21618 if ((s64)val != *(s32 *)loc)
21619 goto overflow;
21620 break;
21621 case R_X86_64_PC32:
21622 val -= (u64)loc;
21623 + pax_open_kernel();
21624 *(u32 *)loc = val;
21625 + pax_close_kernel();
21626 +
21627 #if 0
21628 if ((s64)val != *(s32 *)loc)
21629 goto overflow;
21630 diff --git a/arch/x86/kernel/msr.c b/arch/x86/kernel/msr.c
21631 index ce13049..e2e9c3c 100644
21632 --- a/arch/x86/kernel/msr.c
21633 +++ b/arch/x86/kernel/msr.c
21634 @@ -233,7 +233,7 @@ static int __cpuinit msr_class_cpu_callback(struct notifier_block *nfb,
21635 return notifier_from_errno(err);
21636 }
21637
21638 -static struct notifier_block __refdata msr_class_cpu_notifier = {
21639 +static struct notifier_block msr_class_cpu_notifier = {
21640 .notifier_call = msr_class_cpu_callback,
21641 };
21642
21643 diff --git a/arch/x86/kernel/nmi.c b/arch/x86/kernel/nmi.c
21644 index 6030805..2d33f21 100644
21645 --- a/arch/x86/kernel/nmi.c
21646 +++ b/arch/x86/kernel/nmi.c
21647 @@ -105,7 +105,7 @@ static int __kprobes nmi_handle(unsigned int type, struct pt_regs *regs, bool b2
21648 return handled;
21649 }
21650
21651 -int __register_nmi_handler(unsigned int type, struct nmiaction *action)
21652 +int __register_nmi_handler(unsigned int type, const struct nmiaction *action)
21653 {
21654 struct nmi_desc *desc = nmi_to_desc(type);
21655 unsigned long flags;
21656 @@ -129,9 +129,9 @@ int __register_nmi_handler(unsigned int type, struct nmiaction *action)
21657 * event confuses some handlers (kdump uses this flag)
21658 */
21659 if (action->flags & NMI_FLAG_FIRST)
21660 - list_add_rcu(&action->list, &desc->head);
21661 + pax_list_add_rcu((struct list_head *)&action->list, &desc->head);
21662 else
21663 - list_add_tail_rcu(&action->list, &desc->head);
21664 + pax_list_add_tail_rcu((struct list_head *)&action->list, &desc->head);
21665
21666 spin_unlock_irqrestore(&desc->lock, flags);
21667 return 0;
21668 @@ -154,7 +154,7 @@ void unregister_nmi_handler(unsigned int type, const char *name)
21669 if (!strcmp(n->name, name)) {
21670 WARN(in_nmi(),
21671 "Trying to free NMI (%s) from NMI context!\n", n->name);
21672 - list_del_rcu(&n->list);
21673 + pax_list_del_rcu((struct list_head *)&n->list);
21674 break;
21675 }
21676 }
21677 @@ -479,6 +479,17 @@ static inline void nmi_nesting_postprocess(void)
21678 dotraplinkage notrace __kprobes void
21679 do_nmi(struct pt_regs *regs, long error_code)
21680 {
21681 +
21682 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
21683 + if (!user_mode(regs)) {
21684 + unsigned long cs = regs->cs & 0xFFFF;
21685 + unsigned long ip = ktva_ktla(regs->ip);
21686 +
21687 + if ((cs == __KERNEL_CS || cs == __KERNEXEC_KERNEL_CS) && ip <= (unsigned long)_etext)
21688 + regs->ip = ip;
21689 + }
21690 +#endif
21691 +
21692 nmi_nesting_preprocess(regs);
21693
21694 nmi_enter();
21695 diff --git a/arch/x86/kernel/nmi_selftest.c b/arch/x86/kernel/nmi_selftest.c
21696 index 6d9582e..f746287 100644
21697 --- a/arch/x86/kernel/nmi_selftest.c
21698 +++ b/arch/x86/kernel/nmi_selftest.c
21699 @@ -43,7 +43,7 @@ static void __init init_nmi_testsuite(void)
21700 {
21701 /* trap all the unknown NMIs we may generate */
21702 register_nmi_handler(NMI_UNKNOWN, nmi_unk_cb, 0, "nmi_selftest_unk",
21703 - __initdata);
21704 + __initconst);
21705 }
21706
21707 static void __init cleanup_nmi_testsuite(void)
21708 @@ -66,7 +66,7 @@ static void __init test_nmi_ipi(struct cpumask *mask)
21709 unsigned long timeout;
21710
21711 if (register_nmi_handler(NMI_LOCAL, test_nmi_ipi_callback,
21712 - NMI_FLAG_FIRST, "nmi_selftest", __initdata)) {
21713 + NMI_FLAG_FIRST, "nmi_selftest", __initconst)) {
21714 nmi_fail = FAILURE;
21715 return;
21716 }
21717 diff --git a/arch/x86/kernel/paravirt-spinlocks.c b/arch/x86/kernel/paravirt-spinlocks.c
21718 index 676b8c7..870ba04 100644
21719 --- a/arch/x86/kernel/paravirt-spinlocks.c
21720 +++ b/arch/x86/kernel/paravirt-spinlocks.c
21721 @@ -13,7 +13,7 @@ default_spin_lock_flags(arch_spinlock_t *lock, unsigned long flags)
21722 arch_spin_lock(lock);
21723 }
21724
21725 -struct pv_lock_ops pv_lock_ops = {
21726 +struct pv_lock_ops pv_lock_ops __read_only = {
21727 #ifdef CONFIG_SMP
21728 .spin_is_locked = __ticket_spin_is_locked,
21729 .spin_is_contended = __ticket_spin_is_contended,
21730 diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c
21731 index 8bfb335..c1463c6 100644
21732 --- a/arch/x86/kernel/paravirt.c
21733 +++ b/arch/x86/kernel/paravirt.c
21734 @@ -55,6 +55,9 @@ u64 _paravirt_ident_64(u64 x)
21735 {
21736 return x;
21737 }
21738 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
21739 +PV_CALLEE_SAVE_REGS_THUNK(_paravirt_ident_64);
21740 +#endif
21741
21742 void __init default_banner(void)
21743 {
21744 @@ -147,15 +150,19 @@ unsigned paravirt_patch_default(u8 type, u16 clobbers, void *insnbuf,
21745 if (opfunc == NULL)
21746 /* If there's no function, patch it with a ud2a (BUG) */
21747 ret = paravirt_patch_insns(insnbuf, len, ud2a, ud2a+sizeof(ud2a));
21748 - else if (opfunc == _paravirt_nop)
21749 + else if (opfunc == (void *)_paravirt_nop)
21750 /* If the operation is a nop, then nop the callsite */
21751 ret = paravirt_patch_nop();
21752
21753 /* identity functions just return their single argument */
21754 - else if (opfunc == _paravirt_ident_32)
21755 + else if (opfunc == (void *)_paravirt_ident_32)
21756 ret = paravirt_patch_ident_32(insnbuf, len);
21757 - else if (opfunc == _paravirt_ident_64)
21758 + else if (opfunc == (void *)_paravirt_ident_64)
21759 ret = paravirt_patch_ident_64(insnbuf, len);
21760 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
21761 + else if (opfunc == (void *)__raw_callee_save__paravirt_ident_64)
21762 + ret = paravirt_patch_ident_64(insnbuf, len);
21763 +#endif
21764
21765 else if (type == PARAVIRT_PATCH(pv_cpu_ops.iret) ||
21766 type == PARAVIRT_PATCH(pv_cpu_ops.irq_enable_sysexit) ||
21767 @@ -180,7 +187,7 @@ unsigned paravirt_patch_insns(void *insnbuf, unsigned len,
21768 if (insn_len > len || start == NULL)
21769 insn_len = len;
21770 else
21771 - memcpy(insnbuf, start, insn_len);
21772 + memcpy(insnbuf, ktla_ktva(start), insn_len);
21773
21774 return insn_len;
21775 }
21776 @@ -304,7 +311,7 @@ enum paravirt_lazy_mode paravirt_get_lazy_mode(void)
21777 return this_cpu_read(paravirt_lazy_mode);
21778 }
21779
21780 -struct pv_info pv_info = {
21781 +struct pv_info pv_info __read_only = {
21782 .name = "bare hardware",
21783 .paravirt_enabled = 0,
21784 .kernel_rpl = 0,
21785 @@ -315,16 +322,16 @@ struct pv_info pv_info = {
21786 #endif
21787 };
21788
21789 -struct pv_init_ops pv_init_ops = {
21790 +struct pv_init_ops pv_init_ops __read_only = {
21791 .patch = native_patch,
21792 };
21793
21794 -struct pv_time_ops pv_time_ops = {
21795 +struct pv_time_ops pv_time_ops __read_only = {
21796 .sched_clock = native_sched_clock,
21797 .steal_clock = native_steal_clock,
21798 };
21799
21800 -struct pv_irq_ops pv_irq_ops = {
21801 +struct pv_irq_ops pv_irq_ops __read_only = {
21802 .save_fl = __PV_IS_CALLEE_SAVE(native_save_fl),
21803 .restore_fl = __PV_IS_CALLEE_SAVE(native_restore_fl),
21804 .irq_disable = __PV_IS_CALLEE_SAVE(native_irq_disable),
21805 @@ -336,7 +343,7 @@ struct pv_irq_ops pv_irq_ops = {
21806 #endif
21807 };
21808
21809 -struct pv_cpu_ops pv_cpu_ops = {
21810 +struct pv_cpu_ops pv_cpu_ops __read_only = {
21811 .cpuid = native_cpuid,
21812 .get_debugreg = native_get_debugreg,
21813 .set_debugreg = native_set_debugreg,
21814 @@ -395,21 +402,26 @@ struct pv_cpu_ops pv_cpu_ops = {
21815 .end_context_switch = paravirt_nop,
21816 };
21817
21818 -struct pv_apic_ops pv_apic_ops = {
21819 +struct pv_apic_ops pv_apic_ops __read_only= {
21820 #ifdef CONFIG_X86_LOCAL_APIC
21821 .startup_ipi_hook = paravirt_nop,
21822 #endif
21823 };
21824
21825 -#if defined(CONFIG_X86_32) && !defined(CONFIG_X86_PAE)
21826 +#ifdef CONFIG_X86_32
21827 +#ifdef CONFIG_X86_PAE
21828 +/* 64-bit pagetable entries */
21829 +#define PTE_IDENT PV_CALLEE_SAVE(_paravirt_ident_64)
21830 +#else
21831 /* 32-bit pagetable entries */
21832 #define PTE_IDENT __PV_IS_CALLEE_SAVE(_paravirt_ident_32)
21833 +#endif
21834 #else
21835 /* 64-bit pagetable entries */
21836 #define PTE_IDENT __PV_IS_CALLEE_SAVE(_paravirt_ident_64)
21837 #endif
21838
21839 -struct pv_mmu_ops pv_mmu_ops = {
21840 +struct pv_mmu_ops pv_mmu_ops __read_only = {
21841
21842 .read_cr2 = native_read_cr2,
21843 .write_cr2 = native_write_cr2,
21844 @@ -459,6 +471,7 @@ struct pv_mmu_ops pv_mmu_ops = {
21845 .make_pud = PTE_IDENT,
21846
21847 .set_pgd = native_set_pgd,
21848 + .set_pgd_batched = native_set_pgd_batched,
21849 #endif
21850 #endif /* PAGETABLE_LEVELS >= 3 */
21851
21852 @@ -479,6 +492,12 @@ struct pv_mmu_ops pv_mmu_ops = {
21853 },
21854
21855 .set_fixmap = native_set_fixmap,
21856 +
21857 +#ifdef CONFIG_PAX_KERNEXEC
21858 + .pax_open_kernel = native_pax_open_kernel,
21859 + .pax_close_kernel = native_pax_close_kernel,
21860 +#endif
21861 +
21862 };
21863
21864 EXPORT_SYMBOL_GPL(pv_time_ops);
21865 diff --git a/arch/x86/kernel/pci-calgary_64.c b/arch/x86/kernel/pci-calgary_64.c
21866 index 299d493..2ccb0ee 100644
21867 --- a/arch/x86/kernel/pci-calgary_64.c
21868 +++ b/arch/x86/kernel/pci-calgary_64.c
21869 @@ -1339,7 +1339,7 @@ static void __init get_tce_space_from_tar(void)
21870 tce_space = be64_to_cpu(readq(target));
21871 tce_space = tce_space & TAR_SW_BITS;
21872
21873 - tce_space = tce_space & (~specified_table_size);
21874 + tce_space = tce_space & (~(unsigned long)specified_table_size);
21875 info->tce_space = (u64 *)__va(tce_space);
21876 }
21877 }
21878 diff --git a/arch/x86/kernel/pci-iommu_table.c b/arch/x86/kernel/pci-iommu_table.c
21879 index 35ccf75..7a15747 100644
21880 --- a/arch/x86/kernel/pci-iommu_table.c
21881 +++ b/arch/x86/kernel/pci-iommu_table.c
21882 @@ -2,7 +2,7 @@
21883 #include <asm/iommu_table.h>
21884 #include <linux/string.h>
21885 #include <linux/kallsyms.h>
21886 -
21887 +#include <linux/sched.h>
21888
21889 #define DEBUG 1
21890
21891 diff --git a/arch/x86/kernel/pci-swiotlb.c b/arch/x86/kernel/pci-swiotlb.c
21892 index 6c483ba..d10ce2f 100644
21893 --- a/arch/x86/kernel/pci-swiotlb.c
21894 +++ b/arch/x86/kernel/pci-swiotlb.c
21895 @@ -32,7 +32,7 @@ static void x86_swiotlb_free_coherent(struct device *dev, size_t size,
21896 void *vaddr, dma_addr_t dma_addr,
21897 struct dma_attrs *attrs)
21898 {
21899 - swiotlb_free_coherent(dev, size, vaddr, dma_addr);
21900 + swiotlb_free_coherent(dev, size, vaddr, dma_addr, attrs);
21901 }
21902
21903 static struct dma_map_ops swiotlb_dma_ops = {
21904 diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
21905 index 14ae100..752a4f6 100644
21906 --- a/arch/x86/kernel/process.c
21907 +++ b/arch/x86/kernel/process.c
21908 @@ -36,7 +36,8 @@
21909 * section. Since TSS's are completely CPU-local, we want them
21910 * on exact cacheline boundaries, to eliminate cacheline ping-pong.
21911 */
21912 -DEFINE_PER_CPU_SHARED_ALIGNED(struct tss_struct, init_tss) = INIT_TSS;
21913 +struct tss_struct init_tss[NR_CPUS] ____cacheline_internodealigned_in_smp = { [0 ... NR_CPUS-1] = INIT_TSS };
21914 +EXPORT_SYMBOL(init_tss);
21915
21916 #ifdef CONFIG_X86_64
21917 static DEFINE_PER_CPU(unsigned char, is_idle);
21918 @@ -92,7 +93,7 @@ void arch_task_cache_init(void)
21919 task_xstate_cachep =
21920 kmem_cache_create("task_xstate", xstate_size,
21921 __alignof__(union thread_xstate),
21922 - SLAB_PANIC | SLAB_NOTRACK, NULL);
21923 + SLAB_PANIC | SLAB_NOTRACK | SLAB_USERCOPY, NULL);
21924 }
21925
21926 /*
21927 @@ -105,7 +106,7 @@ void exit_thread(void)
21928 unsigned long *bp = t->io_bitmap_ptr;
21929
21930 if (bp) {
21931 - struct tss_struct *tss = &per_cpu(init_tss, get_cpu());
21932 + struct tss_struct *tss = init_tss + get_cpu();
21933
21934 t->io_bitmap_ptr = NULL;
21935 clear_thread_flag(TIF_IO_BITMAP);
21936 @@ -136,7 +137,7 @@ void show_regs_common(void)
21937 board = dmi_get_system_info(DMI_BOARD_NAME);
21938
21939 printk(KERN_DEFAULT "Pid: %d, comm: %.20s %s %s %.*s %s %s%s%s\n",
21940 - current->pid, current->comm, print_tainted(),
21941 + task_pid_nr(current), current->comm, print_tainted(),
21942 init_utsname()->release,
21943 (int)strcspn(init_utsname()->version, " "),
21944 init_utsname()->version,
21945 @@ -149,6 +150,9 @@ void flush_thread(void)
21946 {
21947 struct task_struct *tsk = current;
21948
21949 +#if defined(CONFIG_X86_32) && !defined(CONFIG_CC_STACKPROTECTOR) && !defined(CONFIG_PAX_MEMORY_UDEREF)
21950 + loadsegment(gs, 0);
21951 +#endif
21952 flush_ptrace_hw_breakpoint(tsk);
21953 memset(tsk->thread.tls_array, 0, sizeof(tsk->thread.tls_array));
21954 drop_init_fpu(tsk);
21955 @@ -295,7 +299,7 @@ static void __exit_idle(void)
21956 void exit_idle(void)
21957 {
21958 /* idle loop has pid 0 */
21959 - if (current->pid)
21960 + if (task_pid_nr(current))
21961 return;
21962 __exit_idle();
21963 }
21964 @@ -398,7 +402,7 @@ bool xen_set_default_idle(void)
21965 return ret;
21966 }
21967 #endif
21968 -void stop_this_cpu(void *dummy)
21969 +__noreturn void stop_this_cpu(void *dummy)
21970 {
21971 local_irq_disable();
21972 /*
21973 @@ -544,16 +548,37 @@ static int __init idle_setup(char *str)
21974 }
21975 early_param("idle", idle_setup);
21976
21977 -unsigned long arch_align_stack(unsigned long sp)
21978 +#ifdef CONFIG_PAX_RANDKSTACK
21979 +void pax_randomize_kstack(struct pt_regs *regs)
21980 {
21981 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
21982 - sp -= get_random_int() % 8192;
21983 - return sp & ~0xf;
21984 -}
21985 + struct thread_struct *thread = &current->thread;
21986 + unsigned long time;
21987
21988 -unsigned long arch_randomize_brk(struct mm_struct *mm)
21989 -{
21990 - unsigned long range_end = mm->brk + 0x02000000;
21991 - return randomize_range(mm->brk, range_end, 0) ? : mm->brk;
21992 -}
21993 + if (!randomize_va_space)
21994 + return;
21995 +
21996 + if (v8086_mode(regs))
21997 + return;
21998
21999 + rdtscl(time);
22000 +
22001 + /* P4 seems to return a 0 LSB, ignore it */
22002 +#ifdef CONFIG_MPENTIUM4
22003 + time &= 0x3EUL;
22004 + time <<= 2;
22005 +#elif defined(CONFIG_X86_64)
22006 + time &= 0xFUL;
22007 + time <<= 4;
22008 +#else
22009 + time &= 0x1FUL;
22010 + time <<= 3;
22011 +#endif
22012 +
22013 + thread->sp0 ^= time;
22014 + load_sp0(init_tss + smp_processor_id(), thread);
22015 +
22016 +#ifdef CONFIG_X86_64
22017 + this_cpu_write(kernel_stack, thread->sp0);
22018 +#endif
22019 +}
22020 +#endif
22021 diff --git a/arch/x86/kernel/process_32.c b/arch/x86/kernel/process_32.c
22022 index b5a8905..d9cacac 100644
22023 --- a/arch/x86/kernel/process_32.c
22024 +++ b/arch/x86/kernel/process_32.c
22025 @@ -65,6 +65,7 @@ asmlinkage void ret_from_kernel_thread(void) __asm__("ret_from_kernel_thread");
22026 unsigned long thread_saved_pc(struct task_struct *tsk)
22027 {
22028 return ((unsigned long *)tsk->thread.sp)[3];
22029 +//XXX return tsk->thread.eip;
22030 }
22031
22032 void __show_regs(struct pt_regs *regs, int all)
22033 @@ -74,21 +75,20 @@ void __show_regs(struct pt_regs *regs, int all)
22034 unsigned long sp;
22035 unsigned short ss, gs;
22036
22037 - if (user_mode_vm(regs)) {
22038 + if (user_mode(regs)) {
22039 sp = regs->sp;
22040 ss = regs->ss & 0xffff;
22041 - gs = get_user_gs(regs);
22042 } else {
22043 sp = kernel_stack_pointer(regs);
22044 savesegment(ss, ss);
22045 - savesegment(gs, gs);
22046 }
22047 + gs = get_user_gs(regs);
22048
22049 show_regs_common();
22050
22051 printk(KERN_DEFAULT "EIP: %04x:[<%08lx>] EFLAGS: %08lx CPU: %d\n",
22052 (u16)regs->cs, regs->ip, regs->flags,
22053 - smp_processor_id());
22054 + raw_smp_processor_id());
22055 print_symbol("EIP is at %s\n", regs->ip);
22056
22057 printk(KERN_DEFAULT "EAX: %08lx EBX: %08lx ECX: %08lx EDX: %08lx\n",
22058 @@ -130,20 +130,21 @@ void release_thread(struct task_struct *dead_task)
22059 int copy_thread(unsigned long clone_flags, unsigned long sp,
22060 unsigned long arg, struct task_struct *p)
22061 {
22062 - struct pt_regs *childregs = task_pt_regs(p);
22063 + struct pt_regs *childregs = task_stack_page(p) + THREAD_SIZE - sizeof(struct pt_regs) - 8;
22064 struct task_struct *tsk;
22065 int err;
22066
22067 p->thread.sp = (unsigned long) childregs;
22068 p->thread.sp0 = (unsigned long) (childregs+1);
22069 + p->tinfo.lowest_stack = (unsigned long)task_stack_page(p);
22070
22071 if (unlikely(p->flags & PF_KTHREAD)) {
22072 /* kernel thread */
22073 memset(childregs, 0, sizeof(struct pt_regs));
22074 p->thread.ip = (unsigned long) ret_from_kernel_thread;
22075 - task_user_gs(p) = __KERNEL_STACK_CANARY;
22076 - childregs->ds = __USER_DS;
22077 - childregs->es = __USER_DS;
22078 + savesegment(gs, childregs->gs);
22079 + childregs->ds = __KERNEL_DS;
22080 + childregs->es = __KERNEL_DS;
22081 childregs->fs = __KERNEL_PERCPU;
22082 childregs->bx = sp; /* function */
22083 childregs->bp = arg;
22084 @@ -250,7 +251,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22085 struct thread_struct *prev = &prev_p->thread,
22086 *next = &next_p->thread;
22087 int cpu = smp_processor_id();
22088 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
22089 + struct tss_struct *tss = init_tss + cpu;
22090 fpu_switch_t fpu;
22091
22092 /* never put a printk in __switch_to... printk() calls wake_up*() indirectly */
22093 @@ -274,6 +275,10 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22094 */
22095 lazy_save_gs(prev->gs);
22096
22097 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22098 + __set_fs(task_thread_info(next_p)->addr_limit);
22099 +#endif
22100 +
22101 /*
22102 * Load the per-thread Thread-Local Storage descriptor.
22103 */
22104 @@ -304,6 +309,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22105 */
22106 arch_end_context_switch(next_p);
22107
22108 + this_cpu_write(current_task, next_p);
22109 + this_cpu_write(current_tinfo, &next_p->tinfo);
22110 +
22111 /*
22112 * Restore %gs if needed (which is common)
22113 */
22114 @@ -312,8 +320,6 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22115
22116 switch_fpu_finish(next_p, fpu);
22117
22118 - this_cpu_write(current_task, next_p);
22119 -
22120 return prev_p;
22121 }
22122
22123 @@ -343,4 +349,3 @@ unsigned long get_wchan(struct task_struct *p)
22124 } while (count++ < 16);
22125 return 0;
22126 }
22127 -
22128 diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
22129 index 0f49677..fcbf88c 100644
22130 --- a/arch/x86/kernel/process_64.c
22131 +++ b/arch/x86/kernel/process_64.c
22132 @@ -152,10 +152,11 @@ int copy_thread(unsigned long clone_flags, unsigned long sp,
22133 struct pt_regs *childregs;
22134 struct task_struct *me = current;
22135
22136 - p->thread.sp0 = (unsigned long)task_stack_page(p) + THREAD_SIZE;
22137 + p->thread.sp0 = (unsigned long)task_stack_page(p) + THREAD_SIZE - 16;
22138 childregs = task_pt_regs(p);
22139 p->thread.sp = (unsigned long) childregs;
22140 p->thread.usersp = me->thread.usersp;
22141 + p->tinfo.lowest_stack = (unsigned long)task_stack_page(p);
22142 set_tsk_thread_flag(p, TIF_FORK);
22143 p->fpu_counter = 0;
22144 p->thread.io_bitmap_ptr = NULL;
22145 @@ -274,7 +275,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22146 struct thread_struct *prev = &prev_p->thread;
22147 struct thread_struct *next = &next_p->thread;
22148 int cpu = smp_processor_id();
22149 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
22150 + struct tss_struct *tss = init_tss + cpu;
22151 unsigned fsindex, gsindex;
22152 fpu_switch_t fpu;
22153
22154 @@ -356,10 +357,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22155 prev->usersp = this_cpu_read(old_rsp);
22156 this_cpu_write(old_rsp, next->usersp);
22157 this_cpu_write(current_task, next_p);
22158 + this_cpu_write(current_tinfo, &next_p->tinfo);
22159
22160 - this_cpu_write(kernel_stack,
22161 - (unsigned long)task_stack_page(next_p) +
22162 - THREAD_SIZE - KERNEL_STACK_OFFSET);
22163 + this_cpu_write(kernel_stack, next->sp0);
22164
22165 /*
22166 * Now maybe reload the debug registers and handle I/O bitmaps
22167 @@ -428,12 +428,11 @@ unsigned long get_wchan(struct task_struct *p)
22168 if (!p || p == current || p->state == TASK_RUNNING)
22169 return 0;
22170 stack = (unsigned long)task_stack_page(p);
22171 - if (p->thread.sp < stack || p->thread.sp >= stack+THREAD_SIZE)
22172 + if (p->thread.sp < stack || p->thread.sp > stack+THREAD_SIZE-16-sizeof(u64))
22173 return 0;
22174 fp = *(u64 *)(p->thread.sp);
22175 do {
22176 - if (fp < (unsigned long)stack ||
22177 - fp >= (unsigned long)stack+THREAD_SIZE)
22178 + if (fp < stack || fp > stack+THREAD_SIZE-16-sizeof(u64))
22179 return 0;
22180 ip = *(u64 *)(fp+8);
22181 if (!in_sched_functions(ip))
22182 diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c
22183 index 29a8120..a50b5ee 100644
22184 --- a/arch/x86/kernel/ptrace.c
22185 +++ b/arch/x86/kernel/ptrace.c
22186 @@ -184,14 +184,13 @@ unsigned long kernel_stack_pointer(struct pt_regs *regs)
22187 {
22188 unsigned long context = (unsigned long)regs & ~(THREAD_SIZE - 1);
22189 unsigned long sp = (unsigned long)&regs->sp;
22190 - struct thread_info *tinfo;
22191
22192 - if (context == (sp & ~(THREAD_SIZE - 1)))
22193 + if (context == ((sp + 8) & ~(THREAD_SIZE - 1)))
22194 return sp;
22195
22196 - tinfo = (struct thread_info *)context;
22197 - if (tinfo->previous_esp)
22198 - return tinfo->previous_esp;
22199 + sp = *(unsigned long *)context;
22200 + if (sp)
22201 + return sp;
22202
22203 return (unsigned long)regs;
22204 }
22205 @@ -588,7 +587,7 @@ static void ptrace_triggered(struct perf_event *bp,
22206 static unsigned long ptrace_get_dr7(struct perf_event *bp[])
22207 {
22208 int i;
22209 - int dr7 = 0;
22210 + unsigned long dr7 = 0;
22211 struct arch_hw_breakpoint *info;
22212
22213 for (i = 0; i < HBP_NUM; i++) {
22214 @@ -856,7 +855,7 @@ long arch_ptrace(struct task_struct *child, long request,
22215 unsigned long addr, unsigned long data)
22216 {
22217 int ret;
22218 - unsigned long __user *datap = (unsigned long __user *)data;
22219 + unsigned long __user *datap = (__force unsigned long __user *)data;
22220
22221 switch (request) {
22222 /* read the word at location addr in the USER area. */
22223 @@ -941,14 +940,14 @@ long arch_ptrace(struct task_struct *child, long request,
22224 if ((int) addr < 0)
22225 return -EIO;
22226 ret = do_get_thread_area(child, addr,
22227 - (struct user_desc __user *)data);
22228 + (__force struct user_desc __user *) data);
22229 break;
22230
22231 case PTRACE_SET_THREAD_AREA:
22232 if ((int) addr < 0)
22233 return -EIO;
22234 ret = do_set_thread_area(child, addr,
22235 - (struct user_desc __user *)data, 0);
22236 + (__force struct user_desc __user *) data, 0);
22237 break;
22238 #endif
22239
22240 @@ -1326,7 +1325,7 @@ long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
22241
22242 #ifdef CONFIG_X86_64
22243
22244 -static struct user_regset x86_64_regsets[] __read_mostly = {
22245 +static user_regset_no_const x86_64_regsets[] __read_only = {
22246 [REGSET_GENERAL] = {
22247 .core_note_type = NT_PRSTATUS,
22248 .n = sizeof(struct user_regs_struct) / sizeof(long),
22249 @@ -1367,7 +1366,7 @@ static const struct user_regset_view user_x86_64_view = {
22250 #endif /* CONFIG_X86_64 */
22251
22252 #if defined CONFIG_X86_32 || defined CONFIG_IA32_EMULATION
22253 -static struct user_regset x86_32_regsets[] __read_mostly = {
22254 +static user_regset_no_const x86_32_regsets[] __read_only = {
22255 [REGSET_GENERAL] = {
22256 .core_note_type = NT_PRSTATUS,
22257 .n = sizeof(struct user_regs_struct32) / sizeof(u32),
22258 @@ -1420,7 +1419,7 @@ static const struct user_regset_view user_x86_32_view = {
22259 */
22260 u64 xstate_fx_sw_bytes[USER_XSTATE_FX_SW_WORDS];
22261
22262 -void update_regset_xstate_info(unsigned int size, u64 xstate_mask)
22263 +void __init update_regset_xstate_info(unsigned int size, u64 xstate_mask)
22264 {
22265 #ifdef CONFIG_X86_64
22266 x86_64_regsets[REGSET_XSTATE].n = size / sizeof(u64);
22267 @@ -1455,7 +1454,7 @@ static void fill_sigtrap_info(struct task_struct *tsk,
22268 memset(info, 0, sizeof(*info));
22269 info->si_signo = SIGTRAP;
22270 info->si_code = si_code;
22271 - info->si_addr = user_mode_vm(regs) ? (void __user *)regs->ip : NULL;
22272 + info->si_addr = user_mode(regs) ? (__force void __user *)regs->ip : NULL;
22273 }
22274
22275 void user_single_step_siginfo(struct task_struct *tsk,
22276 @@ -1484,6 +1483,10 @@ void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs,
22277 # define IS_IA32 0
22278 #endif
22279
22280 +#ifdef CONFIG_GRKERNSEC_SETXID
22281 +extern void gr_delayed_cred_worker(void);
22282 +#endif
22283 +
22284 /*
22285 * We must return the syscall number to actually look up in the table.
22286 * This can be -1L to skip running any syscall at all.
22287 @@ -1494,6 +1497,11 @@ long syscall_trace_enter(struct pt_regs *regs)
22288
22289 user_exit();
22290
22291 +#ifdef CONFIG_GRKERNSEC_SETXID
22292 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
22293 + gr_delayed_cred_worker();
22294 +#endif
22295 +
22296 /*
22297 * If we stepped into a sysenter/syscall insn, it trapped in
22298 * kernel mode; do_debug() cleared TF and set TIF_SINGLESTEP.
22299 @@ -1549,6 +1557,11 @@ void syscall_trace_leave(struct pt_regs *regs)
22300 */
22301 user_exit();
22302
22303 +#ifdef CONFIG_GRKERNSEC_SETXID
22304 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
22305 + gr_delayed_cred_worker();
22306 +#endif
22307 +
22308 audit_syscall_exit(regs);
22309
22310 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
22311 diff --git a/arch/x86/kernel/pvclock.c b/arch/x86/kernel/pvclock.c
22312 index 2cb9470..ff1fd80 100644
22313 --- a/arch/x86/kernel/pvclock.c
22314 +++ b/arch/x86/kernel/pvclock.c
22315 @@ -43,11 +43,11 @@ unsigned long pvclock_tsc_khz(struct pvclock_vcpu_time_info *src)
22316 return pv_tsc_khz;
22317 }
22318
22319 -static atomic64_t last_value = ATOMIC64_INIT(0);
22320 +static atomic64_unchecked_t last_value = ATOMIC64_INIT(0);
22321
22322 void pvclock_resume(void)
22323 {
22324 - atomic64_set(&last_value, 0);
22325 + atomic64_set_unchecked(&last_value, 0);
22326 }
22327
22328 u8 pvclock_read_flags(struct pvclock_vcpu_time_info *src)
22329 @@ -92,11 +92,11 @@ cycle_t pvclock_clocksource_read(struct pvclock_vcpu_time_info *src)
22330 * updating at the same time, and one of them could be slightly behind,
22331 * making the assumption that last_value always go forward fail to hold.
22332 */
22333 - last = atomic64_read(&last_value);
22334 + last = atomic64_read_unchecked(&last_value);
22335 do {
22336 if (ret < last)
22337 return last;
22338 - last = atomic64_cmpxchg(&last_value, last, ret);
22339 + last = atomic64_cmpxchg_unchecked(&last_value, last, ret);
22340 } while (unlikely(last != ret));
22341
22342 return ret;
22343 diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c
22344 index 76fa1e9..abf09ea 100644
22345 --- a/arch/x86/kernel/reboot.c
22346 +++ b/arch/x86/kernel/reboot.c
22347 @@ -36,7 +36,7 @@ void (*pm_power_off)(void);
22348 EXPORT_SYMBOL(pm_power_off);
22349
22350 static const struct desc_ptr no_idt = {};
22351 -static int reboot_mode;
22352 +static unsigned short reboot_mode;
22353 enum reboot_type reboot_type = BOOT_ACPI;
22354 int reboot_force;
22355
22356 @@ -157,6 +157,11 @@ static int __init set_bios_reboot(const struct dmi_system_id *d)
22357
22358 void __noreturn machine_real_restart(unsigned int type)
22359 {
22360 +
22361 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF))
22362 + struct desc_struct *gdt;
22363 +#endif
22364 +
22365 local_irq_disable();
22366
22367 /*
22368 @@ -184,7 +189,29 @@ void __noreturn machine_real_restart(unsigned int type)
22369
22370 /* Jump to the identity-mapped low memory code */
22371 #ifdef CONFIG_X86_32
22372 - asm volatile("jmpl *%0" : :
22373 +
22374 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
22375 + gdt = get_cpu_gdt_table(smp_processor_id());
22376 + pax_open_kernel();
22377 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22378 + gdt[GDT_ENTRY_KERNEL_DS].type = 3;
22379 + gdt[GDT_ENTRY_KERNEL_DS].limit = 0xf;
22380 + loadsegment(ds, __KERNEL_DS);
22381 + loadsegment(es, __KERNEL_DS);
22382 + loadsegment(ss, __KERNEL_DS);
22383 +#endif
22384 +#ifdef CONFIG_PAX_KERNEXEC
22385 + gdt[GDT_ENTRY_KERNEL_CS].base0 = 0;
22386 + gdt[GDT_ENTRY_KERNEL_CS].base1 = 0;
22387 + gdt[GDT_ENTRY_KERNEL_CS].base2 = 0;
22388 + gdt[GDT_ENTRY_KERNEL_CS].limit0 = 0xffff;
22389 + gdt[GDT_ENTRY_KERNEL_CS].limit = 0xf;
22390 + gdt[GDT_ENTRY_KERNEL_CS].g = 1;
22391 +#endif
22392 + pax_close_kernel();
22393 +#endif
22394 +
22395 + asm volatile("ljmpl *%0" : :
22396 "rm" (real_mode_header->machine_real_restart_asm),
22397 "a" (type));
22398 #else
22399 @@ -531,7 +558,7 @@ void __attribute__((weak)) mach_reboot_fixups(void)
22400 * try to force a triple fault and then cycle between hitting the keyboard
22401 * controller and doing that
22402 */
22403 -static void native_machine_emergency_restart(void)
22404 +static void __noreturn native_machine_emergency_restart(void)
22405 {
22406 int i;
22407 int attempt = 0;
22408 @@ -654,13 +681,13 @@ void native_machine_shutdown(void)
22409 #endif
22410 }
22411
22412 -static void __machine_emergency_restart(int emergency)
22413 +static void __noreturn __machine_emergency_restart(int emergency)
22414 {
22415 reboot_emergency = emergency;
22416 machine_ops.emergency_restart();
22417 }
22418
22419 -static void native_machine_restart(char *__unused)
22420 +static void __noreturn native_machine_restart(char *__unused)
22421 {
22422 pr_notice("machine restart\n");
22423
22424 @@ -669,7 +696,7 @@ static void native_machine_restart(char *__unused)
22425 __machine_emergency_restart(0);
22426 }
22427
22428 -static void native_machine_halt(void)
22429 +static void __noreturn native_machine_halt(void)
22430 {
22431 /* Stop other cpus and apics */
22432 machine_shutdown();
22433 @@ -679,7 +706,7 @@ static void native_machine_halt(void)
22434 stop_this_cpu(NULL);
22435 }
22436
22437 -static void native_machine_power_off(void)
22438 +static void __noreturn native_machine_power_off(void)
22439 {
22440 if (pm_power_off) {
22441 if (!reboot_force)
22442 @@ -688,9 +715,10 @@ static void native_machine_power_off(void)
22443 }
22444 /* A fallback in case there is no PM info available */
22445 tboot_shutdown(TB_SHUTDOWN_HALT);
22446 + unreachable();
22447 }
22448
22449 -struct machine_ops machine_ops = {
22450 +struct machine_ops machine_ops __read_only = {
22451 .power_off = native_machine_power_off,
22452 .shutdown = native_machine_shutdown,
22453 .emergency_restart = native_machine_emergency_restart,
22454 diff --git a/arch/x86/kernel/relocate_kernel_64.S b/arch/x86/kernel/relocate_kernel_64.S
22455 index 7a6f3b3..bed145d7 100644
22456 --- a/arch/x86/kernel/relocate_kernel_64.S
22457 +++ b/arch/x86/kernel/relocate_kernel_64.S
22458 @@ -11,6 +11,7 @@
22459 #include <asm/kexec.h>
22460 #include <asm/processor-flags.h>
22461 #include <asm/pgtable_types.h>
22462 +#include <asm/alternative-asm.h>
22463
22464 /*
22465 * Must be relocatable PIC code callable as a C function
22466 @@ -160,13 +161,14 @@ identity_mapped:
22467 xorq %rbp, %rbp
22468 xorq %r8, %r8
22469 xorq %r9, %r9
22470 - xorq %r10, %r9
22471 + xorq %r10, %r10
22472 xorq %r11, %r11
22473 xorq %r12, %r12
22474 xorq %r13, %r13
22475 xorq %r14, %r14
22476 xorq %r15, %r15
22477
22478 + pax_force_retaddr 0, 1
22479 ret
22480
22481 1:
22482 diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
22483 index fae9134..b7d4a57 100644
22484 --- a/arch/x86/kernel/setup.c
22485 +++ b/arch/x86/kernel/setup.c
22486 @@ -111,6 +111,7 @@
22487 #include <asm/mce.h>
22488 #include <asm/alternative.h>
22489 #include <asm/prom.h>
22490 +#include <asm/boot.h>
22491
22492 /*
22493 * max_low_pfn_mapped: highest direct mapped pfn under 4GB
22494 @@ -447,7 +448,7 @@ static void __init parse_setup_data(void)
22495
22496 switch (data->type) {
22497 case SETUP_E820_EXT:
22498 - parse_e820_ext(data);
22499 + parse_e820_ext((struct setup_data __force_kernel *)data);
22500 break;
22501 case SETUP_DTB:
22502 add_dtb(pa_data);
22503 @@ -774,7 +775,7 @@ static void __init trim_bios_range(void)
22504 * area (640->1Mb) as ram even though it is not.
22505 * take them out.
22506 */
22507 - e820_remove_range(BIOS_BEGIN, BIOS_END - BIOS_BEGIN, E820_RAM, 1);
22508 + e820_remove_range(ISA_START_ADDRESS, ISA_END_ADDRESS - ISA_START_ADDRESS, E820_RAM, 1);
22509
22510 sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map);
22511 }
22512 @@ -844,8 +845,12 @@ static void __init trim_low_memory_range(void)
22513
22514 void __init setup_arch(char **cmdline_p)
22515 {
22516 +#ifdef CONFIG_X86_32
22517 + memblock_reserve(LOAD_PHYSICAL_ADDR, __pa_symbol(__bss_stop) - ____LOAD_PHYSICAL_ADDR);
22518 +#else
22519 memblock_reserve(__pa_symbol(_text),
22520 (unsigned long)__bss_stop - (unsigned long)_text);
22521 +#endif
22522
22523 early_reserve_initrd();
22524
22525 @@ -937,14 +942,14 @@ void __init setup_arch(char **cmdline_p)
22526
22527 if (!boot_params.hdr.root_flags)
22528 root_mountflags &= ~MS_RDONLY;
22529 - init_mm.start_code = (unsigned long) _text;
22530 - init_mm.end_code = (unsigned long) _etext;
22531 + init_mm.start_code = ktla_ktva((unsigned long) _text);
22532 + init_mm.end_code = ktla_ktva((unsigned long) _etext);
22533 init_mm.end_data = (unsigned long) _edata;
22534 init_mm.brk = _brk_end;
22535
22536 - code_resource.start = __pa_symbol(_text);
22537 - code_resource.end = __pa_symbol(_etext)-1;
22538 - data_resource.start = __pa_symbol(_etext);
22539 + code_resource.start = __pa_symbol(ktla_ktva(_text));
22540 + code_resource.end = __pa_symbol(ktla_ktva(_etext))-1;
22541 + data_resource.start = __pa_symbol(_sdata);
22542 data_resource.end = __pa_symbol(_edata)-1;
22543 bss_resource.start = __pa_symbol(__bss_start);
22544 bss_resource.end = __pa_symbol(__bss_stop)-1;
22545 diff --git a/arch/x86/kernel/setup_percpu.c b/arch/x86/kernel/setup_percpu.c
22546 index 5cdff03..80fa283 100644
22547 --- a/arch/x86/kernel/setup_percpu.c
22548 +++ b/arch/x86/kernel/setup_percpu.c
22549 @@ -21,19 +21,17 @@
22550 #include <asm/cpu.h>
22551 #include <asm/stackprotector.h>
22552
22553 -DEFINE_PER_CPU_READ_MOSTLY(int, cpu_number);
22554 +#ifdef CONFIG_SMP
22555 +DEFINE_PER_CPU_READ_MOSTLY(unsigned int, cpu_number);
22556 EXPORT_PER_CPU_SYMBOL(cpu_number);
22557 +#endif
22558
22559 -#ifdef CONFIG_X86_64
22560 #define BOOT_PERCPU_OFFSET ((unsigned long)__per_cpu_load)
22561 -#else
22562 -#define BOOT_PERCPU_OFFSET 0
22563 -#endif
22564
22565 DEFINE_PER_CPU(unsigned long, this_cpu_off) = BOOT_PERCPU_OFFSET;
22566 EXPORT_PER_CPU_SYMBOL(this_cpu_off);
22567
22568 -unsigned long __per_cpu_offset[NR_CPUS] __read_mostly = {
22569 +unsigned long __per_cpu_offset[NR_CPUS] __read_only = {
22570 [0 ... NR_CPUS-1] = BOOT_PERCPU_OFFSET,
22571 };
22572 EXPORT_SYMBOL(__per_cpu_offset);
22573 @@ -66,7 +64,7 @@ static bool __init pcpu_need_numa(void)
22574 {
22575 #ifdef CONFIG_NEED_MULTIPLE_NODES
22576 pg_data_t *last = NULL;
22577 - unsigned int cpu;
22578 + int cpu;
22579
22580 for_each_possible_cpu(cpu) {
22581 int node = early_cpu_to_node(cpu);
22582 @@ -155,10 +153,10 @@ static inline void setup_percpu_segment(int cpu)
22583 {
22584 #ifdef CONFIG_X86_32
22585 struct desc_struct gdt;
22586 + unsigned long base = per_cpu_offset(cpu);
22587
22588 - pack_descriptor(&gdt, per_cpu_offset(cpu), 0xFFFFF,
22589 - 0x2 | DESCTYPE_S, 0x8);
22590 - gdt.s = 1;
22591 + pack_descriptor(&gdt, base, (VMALLOC_END - base - 1) >> PAGE_SHIFT,
22592 + 0x83 | DESCTYPE_S, 0xC);
22593 write_gdt_entry(get_cpu_gdt_table(cpu),
22594 GDT_ENTRY_PERCPU, &gdt, DESCTYPE_S);
22595 #endif
22596 @@ -219,6 +217,11 @@ void __init setup_per_cpu_areas(void)
22597 /* alrighty, percpu areas up and running */
22598 delta = (unsigned long)pcpu_base_addr - (unsigned long)__per_cpu_start;
22599 for_each_possible_cpu(cpu) {
22600 +#ifdef CONFIG_CC_STACKPROTECTOR
22601 +#ifdef CONFIG_X86_32
22602 + unsigned long canary = per_cpu(stack_canary.canary, cpu);
22603 +#endif
22604 +#endif
22605 per_cpu_offset(cpu) = delta + pcpu_unit_offsets[cpu];
22606 per_cpu(this_cpu_off, cpu) = per_cpu_offset(cpu);
22607 per_cpu(cpu_number, cpu) = cpu;
22608 @@ -259,6 +262,12 @@ void __init setup_per_cpu_areas(void)
22609 */
22610 set_cpu_numa_node(cpu, early_cpu_to_node(cpu));
22611 #endif
22612 +#ifdef CONFIG_CC_STACKPROTECTOR
22613 +#ifdef CONFIG_X86_32
22614 + if (!cpu)
22615 + per_cpu(stack_canary.canary, cpu) = canary;
22616 +#endif
22617 +#endif
22618 /*
22619 * Up to this point, the boot CPU has been using .init.data
22620 * area. Reload any changed state for the boot CPU.
22621 diff --git a/arch/x86/kernel/signal.c b/arch/x86/kernel/signal.c
22622 index 6956299..f20beae 100644
22623 --- a/arch/x86/kernel/signal.c
22624 +++ b/arch/x86/kernel/signal.c
22625 @@ -196,7 +196,7 @@ static unsigned long align_sigframe(unsigned long sp)
22626 * Align the stack pointer according to the i386 ABI,
22627 * i.e. so that on function entry ((sp + 4) & 15) == 0.
22628 */
22629 - sp = ((sp + 4) & -16ul) - 4;
22630 + sp = ((sp - 12) & -16ul) - 4;
22631 #else /* !CONFIG_X86_32 */
22632 sp = round_down(sp, 16) - 8;
22633 #endif
22634 @@ -304,9 +304,9 @@ __setup_frame(int sig, struct ksignal *ksig, sigset_t *set,
22635 }
22636
22637 if (current->mm->context.vdso)
22638 - restorer = VDSO32_SYMBOL(current->mm->context.vdso, sigreturn);
22639 + restorer = (__force void __user *)VDSO32_SYMBOL(current->mm->context.vdso, sigreturn);
22640 else
22641 - restorer = &frame->retcode;
22642 + restorer = (void __user *)&frame->retcode;
22643 if (ksig->ka.sa.sa_flags & SA_RESTORER)
22644 restorer = ksig->ka.sa.sa_restorer;
22645
22646 @@ -320,7 +320,7 @@ __setup_frame(int sig, struct ksignal *ksig, sigset_t *set,
22647 * reasons and because gdb uses it as a signature to notice
22648 * signal handler stack frames.
22649 */
22650 - err |= __put_user(*((u64 *)&retcode), (u64 *)frame->retcode);
22651 + err |= __put_user(*((u64 *)&retcode), (u64 __user *)frame->retcode);
22652
22653 if (err)
22654 return -EFAULT;
22655 @@ -367,7 +367,10 @@ static int __setup_rt_frame(int sig, struct ksignal *ksig,
22656 err |= __save_altstack(&frame->uc.uc_stack, regs->sp);
22657
22658 /* Set up to return from userspace. */
22659 - restorer = VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
22660 + if (current->mm->context.vdso)
22661 + restorer = (__force void __user *)VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
22662 + else
22663 + restorer = (void __user *)&frame->retcode;
22664 if (ksig->ka.sa.sa_flags & SA_RESTORER)
22665 restorer = ksig->ka.sa.sa_restorer;
22666 put_user_ex(restorer, &frame->pretcode);
22667 @@ -379,7 +382,7 @@ static int __setup_rt_frame(int sig, struct ksignal *ksig,
22668 * reasons and because gdb uses it as a signature to notice
22669 * signal handler stack frames.
22670 */
22671 - put_user_ex(*((u64 *)&rt_retcode), (u64 *)frame->retcode);
22672 + put_user_ex(*((u64 *)&rt_retcode), (u64 __user *)frame->retcode);
22673 } put_user_catch(err);
22674
22675 err |= copy_siginfo_to_user(&frame->info, &ksig->info);
22676 @@ -615,7 +618,12 @@ setup_rt_frame(struct ksignal *ksig, struct pt_regs *regs)
22677 {
22678 int usig = signr_convert(ksig->sig);
22679 sigset_t *set = sigmask_to_save();
22680 - compat_sigset_t *cset = (compat_sigset_t *) set;
22681 + sigset_t sigcopy;
22682 + compat_sigset_t *cset;
22683 +
22684 + sigcopy = *set;
22685 +
22686 + cset = (compat_sigset_t *) &sigcopy;
22687
22688 /* Set up the stack frame */
22689 if (is_ia32_frame()) {
22690 @@ -626,7 +634,7 @@ setup_rt_frame(struct ksignal *ksig, struct pt_regs *regs)
22691 } else if (is_x32_frame()) {
22692 return x32_setup_rt_frame(ksig, cset, regs);
22693 } else {
22694 - return __setup_rt_frame(ksig->sig, ksig, set, regs);
22695 + return __setup_rt_frame(ksig->sig, ksig, &sigcopy, regs);
22696 }
22697 }
22698
22699 diff --git a/arch/x86/kernel/smp.c b/arch/x86/kernel/smp.c
22700 index 48d2b7d..90d328a 100644
22701 --- a/arch/x86/kernel/smp.c
22702 +++ b/arch/x86/kernel/smp.c
22703 @@ -285,7 +285,7 @@ static int __init nonmi_ipi_setup(char *str)
22704
22705 __setup("nonmi_ipi", nonmi_ipi_setup);
22706
22707 -struct smp_ops smp_ops = {
22708 +struct smp_ops smp_ops __read_only = {
22709 .smp_prepare_boot_cpu = native_smp_prepare_boot_cpu,
22710 .smp_prepare_cpus = native_smp_prepare_cpus,
22711 .smp_cpus_done = native_smp_cpus_done,
22712 diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
22713 index 9f190a2..90a0688 100644
22714 --- a/arch/x86/kernel/smpboot.c
22715 +++ b/arch/x86/kernel/smpboot.c
22716 @@ -748,6 +748,7 @@ static int __cpuinit do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
22717 idle->thread.sp = (unsigned long) (((struct pt_regs *)
22718 (THREAD_SIZE + task_stack_page(idle))) - 1);
22719 per_cpu(current_task, cpu) = idle;
22720 + per_cpu(current_tinfo, cpu) = &idle->tinfo;
22721
22722 #ifdef CONFIG_X86_32
22723 /* Stack for startup_32 can be just as for start_secondary onwards */
22724 @@ -755,11 +756,13 @@ static int __cpuinit do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
22725 #else
22726 clear_tsk_thread_flag(idle, TIF_FORK);
22727 initial_gs = per_cpu_offset(cpu);
22728 - per_cpu(kernel_stack, cpu) =
22729 - (unsigned long)task_stack_page(idle) -
22730 - KERNEL_STACK_OFFSET + THREAD_SIZE;
22731 + per_cpu(kernel_stack, cpu) = (unsigned long)task_stack_page(idle) - 16 + THREAD_SIZE;
22732 #endif
22733 +
22734 + pax_open_kernel();
22735 early_gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu);
22736 + pax_close_kernel();
22737 +
22738 initial_code = (unsigned long)start_secondary;
22739 stack_start = idle->thread.sp;
22740
22741 @@ -908,6 +911,15 @@ int __cpuinit native_cpu_up(unsigned int cpu, struct task_struct *tidle)
22742 /* the FPU context is blank, nobody can own it */
22743 __cpu_disable_lazy_restore(cpu);
22744
22745 +#ifdef CONFIG_PAX_PER_CPU_PGD
22746 + clone_pgd_range(get_cpu_pgd(cpu) + KERNEL_PGD_BOUNDARY,
22747 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
22748 + KERNEL_PGD_PTRS);
22749 +#endif
22750 +
22751 + /* the FPU context is blank, nobody can own it */
22752 + __cpu_disable_lazy_restore(cpu);
22753 +
22754 err = do_boot_cpu(apicid, cpu, tidle);
22755 if (err) {
22756 pr_debug("do_boot_cpu failed %d\n", err);
22757 diff --git a/arch/x86/kernel/step.c b/arch/x86/kernel/step.c
22758 index 9b4d51d..5d28b58 100644
22759 --- a/arch/x86/kernel/step.c
22760 +++ b/arch/x86/kernel/step.c
22761 @@ -27,10 +27,10 @@ unsigned long convert_ip_to_linear(struct task_struct *child, struct pt_regs *re
22762 struct desc_struct *desc;
22763 unsigned long base;
22764
22765 - seg &= ~7UL;
22766 + seg >>= 3;
22767
22768 mutex_lock(&child->mm->context.lock);
22769 - if (unlikely((seg >> 3) >= child->mm->context.size))
22770 + if (unlikely(seg >= child->mm->context.size))
22771 addr = -1L; /* bogus selector, access would fault */
22772 else {
22773 desc = child->mm->context.ldt + seg;
22774 @@ -42,7 +42,8 @@ unsigned long convert_ip_to_linear(struct task_struct *child, struct pt_regs *re
22775 addr += base;
22776 }
22777 mutex_unlock(&child->mm->context.lock);
22778 - }
22779 + } else if (seg == __KERNEL_CS || seg == __KERNEXEC_KERNEL_CS)
22780 + addr = ktla_ktva(addr);
22781
22782 return addr;
22783 }
22784 @@ -53,6 +54,9 @@ static int is_setting_trap_flag(struct task_struct *child, struct pt_regs *regs)
22785 unsigned char opcode[15];
22786 unsigned long addr = convert_ip_to_linear(child, regs);
22787
22788 + if (addr == -EINVAL)
22789 + return 0;
22790 +
22791 copied = access_process_vm(child, addr, opcode, sizeof(opcode), 0);
22792 for (i = 0; i < copied; i++) {
22793 switch (opcode[i]) {
22794 diff --git a/arch/x86/kernel/sys_i386_32.c b/arch/x86/kernel/sys_i386_32.c
22795 new file mode 100644
22796 index 0000000..207bec6
22797 --- /dev/null
22798 +++ b/arch/x86/kernel/sys_i386_32.c
22799 @@ -0,0 +1,250 @@
22800 +/*
22801 + * This file contains various random system calls that
22802 + * have a non-standard calling sequence on the Linux/i386
22803 + * platform.
22804 + */
22805 +
22806 +#include <linux/errno.h>
22807 +#include <linux/sched.h>
22808 +#include <linux/mm.h>
22809 +#include <linux/fs.h>
22810 +#include <linux/smp.h>
22811 +#include <linux/sem.h>
22812 +#include <linux/msg.h>
22813 +#include <linux/shm.h>
22814 +#include <linux/stat.h>
22815 +#include <linux/syscalls.h>
22816 +#include <linux/mman.h>
22817 +#include <linux/file.h>
22818 +#include <linux/utsname.h>
22819 +#include <linux/ipc.h>
22820 +
22821 +#include <linux/uaccess.h>
22822 +#include <linux/unistd.h>
22823 +
22824 +#include <asm/syscalls.h>
22825 +
22826 +int i386_mmap_check(unsigned long addr, unsigned long len, unsigned long flags)
22827 +{
22828 + unsigned long pax_task_size = TASK_SIZE;
22829 +
22830 +#ifdef CONFIG_PAX_SEGMEXEC
22831 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC)
22832 + pax_task_size = SEGMEXEC_TASK_SIZE;
22833 +#endif
22834 +
22835 + if (flags & MAP_FIXED)
22836 + if (len > pax_task_size || addr > pax_task_size - len)
22837 + return -EINVAL;
22838 +
22839 + return 0;
22840 +}
22841 +
22842 +unsigned long
22843 +arch_get_unmapped_area(struct file *filp, unsigned long addr,
22844 + unsigned long len, unsigned long pgoff, unsigned long flags)
22845 +{
22846 + struct mm_struct *mm = current->mm;
22847 + struct vm_area_struct *vma;
22848 + unsigned long start_addr, pax_task_size = TASK_SIZE;
22849 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
22850 +
22851 +#ifdef CONFIG_PAX_SEGMEXEC
22852 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
22853 + pax_task_size = SEGMEXEC_TASK_SIZE;
22854 +#endif
22855 +
22856 + pax_task_size -= PAGE_SIZE;
22857 +
22858 + if (len > pax_task_size)
22859 + return -ENOMEM;
22860 +
22861 + if (flags & MAP_FIXED)
22862 + return addr;
22863 +
22864 +#ifdef CONFIG_PAX_RANDMMAP
22865 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
22866 +#endif
22867 +
22868 + if (addr) {
22869 + addr = PAGE_ALIGN(addr);
22870 + if (pax_task_size - len >= addr) {
22871 + vma = find_vma(mm, addr);
22872 + if (check_heap_stack_gap(vma, addr, len, offset))
22873 + return addr;
22874 + }
22875 + }
22876 + if (len > mm->cached_hole_size) {
22877 + start_addr = addr = mm->free_area_cache;
22878 + } else {
22879 + start_addr = addr = mm->mmap_base;
22880 + mm->cached_hole_size = 0;
22881 + }
22882 +
22883 +#ifdef CONFIG_PAX_PAGEEXEC
22884 + if (!(__supported_pte_mask & _PAGE_NX) && (mm->pax_flags & MF_PAX_PAGEEXEC) && (flags & MAP_EXECUTABLE) && start_addr >= mm->mmap_base) {
22885 + start_addr = 0x00110000UL;
22886 +
22887 +#ifdef CONFIG_PAX_RANDMMAP
22888 + if (mm->pax_flags & MF_PAX_RANDMMAP)
22889 + start_addr += mm->delta_mmap & 0x03FFF000UL;
22890 +#endif
22891 +
22892 + if (mm->start_brk <= start_addr && start_addr < mm->mmap_base)
22893 + start_addr = addr = mm->mmap_base;
22894 + else
22895 + addr = start_addr;
22896 + }
22897 +#endif
22898 +
22899 +full_search:
22900 + for (vma = find_vma(mm, addr); ; vma = vma->vm_next) {
22901 + /* At this point: (!vma || addr < vma->vm_end). */
22902 + if (pax_task_size - len < addr) {
22903 + /*
22904 + * Start a new search - just in case we missed
22905 + * some holes.
22906 + */
22907 + if (start_addr != mm->mmap_base) {
22908 + start_addr = addr = mm->mmap_base;
22909 + mm->cached_hole_size = 0;
22910 + goto full_search;
22911 + }
22912 + return -ENOMEM;
22913 + }
22914 + if (check_heap_stack_gap(vma, addr, len, offset))
22915 + break;
22916 + if (addr + mm->cached_hole_size < vma->vm_start)
22917 + mm->cached_hole_size = vma->vm_start - addr;
22918 + addr = vma->vm_end;
22919 + if (mm->start_brk <= addr && addr < mm->mmap_base) {
22920 + start_addr = addr = mm->mmap_base;
22921 + mm->cached_hole_size = 0;
22922 + goto full_search;
22923 + }
22924 + }
22925 +
22926 + /*
22927 + * Remember the place where we stopped the search:
22928 + */
22929 + mm->free_area_cache = addr + len;
22930 + return addr;
22931 +}
22932 +
22933 +unsigned long
22934 +arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
22935 + const unsigned long len, const unsigned long pgoff,
22936 + const unsigned long flags)
22937 +{
22938 + struct vm_area_struct *vma;
22939 + struct mm_struct *mm = current->mm;
22940 + unsigned long base = mm->mmap_base, addr = addr0, pax_task_size = TASK_SIZE;
22941 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
22942 +
22943 +#ifdef CONFIG_PAX_SEGMEXEC
22944 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
22945 + pax_task_size = SEGMEXEC_TASK_SIZE;
22946 +#endif
22947 +
22948 + pax_task_size -= PAGE_SIZE;
22949 +
22950 + /* requested length too big for entire address space */
22951 + if (len > pax_task_size)
22952 + return -ENOMEM;
22953 +
22954 + if (flags & MAP_FIXED)
22955 + return addr;
22956 +
22957 +#ifdef CONFIG_PAX_PAGEEXEC
22958 + if (!(__supported_pte_mask & _PAGE_NX) && (mm->pax_flags & MF_PAX_PAGEEXEC) && (flags & MAP_EXECUTABLE))
22959 + goto bottomup;
22960 +#endif
22961 +
22962 +#ifdef CONFIG_PAX_RANDMMAP
22963 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
22964 +#endif
22965 +
22966 + /* requesting a specific address */
22967 + if (addr) {
22968 + addr = PAGE_ALIGN(addr);
22969 + if (pax_task_size - len >= addr) {
22970 + vma = find_vma(mm, addr);
22971 + if (check_heap_stack_gap(vma, addr, len, offset))
22972 + return addr;
22973 + }
22974 + }
22975 +
22976 + /* check if free_area_cache is useful for us */
22977 + if (len <= mm->cached_hole_size) {
22978 + mm->cached_hole_size = 0;
22979 + mm->free_area_cache = mm->mmap_base;
22980 + }
22981 +
22982 + /* either no address requested or can't fit in requested address hole */
22983 + addr = mm->free_area_cache;
22984 +
22985 + /* make sure it can fit in the remaining address space */
22986 + if (addr > len) {
22987 + vma = find_vma(mm, addr-len);
22988 + if (check_heap_stack_gap(vma, addr - len, len, offset))
22989 + /* remember the address as a hint for next time */
22990 + return (mm->free_area_cache = addr-len);
22991 + }
22992 +
22993 + if (mm->mmap_base < len)
22994 + goto bottomup;
22995 +
22996 + addr = mm->mmap_base-len;
22997 +
22998 + do {
22999 + /*
23000 + * Lookup failure means no vma is above this address,
23001 + * else if new region fits below vma->vm_start,
23002 + * return with success:
23003 + */
23004 + vma = find_vma(mm, addr);
23005 + if (check_heap_stack_gap(vma, addr, len, offset))
23006 + /* remember the address as a hint for next time */
23007 + return (mm->free_area_cache = addr);
23008 +
23009 + /* remember the largest hole we saw so far */
23010 + if (addr + mm->cached_hole_size < vma->vm_start)
23011 + mm->cached_hole_size = vma->vm_start - addr;
23012 +
23013 + /* try just below the current vma->vm_start */
23014 + addr = skip_heap_stack_gap(vma, len, offset);
23015 + } while (!IS_ERR_VALUE(addr));
23016 +
23017 +bottomup:
23018 + /*
23019 + * A failed mmap() very likely causes application failure,
23020 + * so fall back to the bottom-up function here. This scenario
23021 + * can happen with large stack limits and large mmap()
23022 + * allocations.
23023 + */
23024 +
23025 +#ifdef CONFIG_PAX_SEGMEXEC
23026 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
23027 + mm->mmap_base = SEGMEXEC_TASK_UNMAPPED_BASE;
23028 + else
23029 +#endif
23030 +
23031 + mm->mmap_base = TASK_UNMAPPED_BASE;
23032 +
23033 +#ifdef CONFIG_PAX_RANDMMAP
23034 + if (mm->pax_flags & MF_PAX_RANDMMAP)
23035 + mm->mmap_base += mm->delta_mmap;
23036 +#endif
23037 +
23038 + mm->free_area_cache = mm->mmap_base;
23039 + mm->cached_hole_size = ~0UL;
23040 + addr = arch_get_unmapped_area(filp, addr0, len, pgoff, flags);
23041 + /*
23042 + * Restore the topdown base:
23043 + */
23044 + mm->mmap_base = base;
23045 + mm->free_area_cache = base;
23046 + mm->cached_hole_size = ~0UL;
23047 +
23048 + return addr;
23049 +}
23050 diff --git a/arch/x86/kernel/sys_x86_64.c b/arch/x86/kernel/sys_x86_64.c
23051 index dbded5a..ace2781 100644
23052 --- a/arch/x86/kernel/sys_x86_64.c
23053 +++ b/arch/x86/kernel/sys_x86_64.c
23054 @@ -81,8 +81,8 @@ out:
23055 return error;
23056 }
23057
23058 -static void find_start_end(unsigned long flags, unsigned long *begin,
23059 - unsigned long *end)
23060 +static void find_start_end(struct mm_struct *mm, unsigned long flags,
23061 + unsigned long *begin, unsigned long *end)
23062 {
23063 if (!test_thread_flag(TIF_ADDR32) && (flags & MAP_32BIT)) {
23064 unsigned long new_begin;
23065 @@ -101,7 +101,7 @@ static void find_start_end(unsigned long flags, unsigned long *begin,
23066 *begin = new_begin;
23067 }
23068 } else {
23069 - *begin = TASK_UNMAPPED_BASE;
23070 + *begin = mm->mmap_base;
23071 *end = TASK_SIZE;
23072 }
23073 }
23074 @@ -114,20 +114,24 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
23075 struct vm_area_struct *vma;
23076 struct vm_unmapped_area_info info;
23077 unsigned long begin, end;
23078 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
23079
23080 if (flags & MAP_FIXED)
23081 return addr;
23082
23083 - find_start_end(flags, &begin, &end);
23084 + find_start_end(mm, flags, &begin, &end);
23085
23086 if (len > end)
23087 return -ENOMEM;
23088
23089 +#ifdef CONFIG_PAX_RANDMMAP
23090 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
23091 +#endif
23092 +
23093 if (addr) {
23094 addr = PAGE_ALIGN(addr);
23095 vma = find_vma(mm, addr);
23096 - if (end - len >= addr &&
23097 - (!vma || addr + len <= vma->vm_start))
23098 + if (end - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
23099 return addr;
23100 }
23101
23102 @@ -137,6 +141,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
23103 info.high_limit = end;
23104 info.align_mask = filp ? get_align_mask() : 0;
23105 info.align_offset = pgoff << PAGE_SHIFT;
23106 + info.threadstack_offset = offset;
23107 return vm_unmapped_area(&info);
23108 }
23109
23110 @@ -149,6 +154,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
23111 struct mm_struct *mm = current->mm;
23112 unsigned long addr = addr0;
23113 struct vm_unmapped_area_info info;
23114 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
23115
23116 /* requested length too big for entire address space */
23117 if (len > TASK_SIZE)
23118 @@ -161,12 +167,15 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
23119 if (!test_thread_flag(TIF_ADDR32) && (flags & MAP_32BIT))
23120 goto bottomup;
23121
23122 +#ifdef CONFIG_PAX_RANDMMAP
23123 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
23124 +#endif
23125 +
23126 /* requesting a specific address */
23127 if (addr) {
23128 addr = PAGE_ALIGN(addr);
23129 vma = find_vma(mm, addr);
23130 - if (TASK_SIZE - len >= addr &&
23131 - (!vma || addr + len <= vma->vm_start))
23132 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
23133 return addr;
23134 }
23135
23136 @@ -176,6 +185,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
23137 info.high_limit = mm->mmap_base;
23138 info.align_mask = filp ? get_align_mask() : 0;
23139 info.align_offset = pgoff << PAGE_SHIFT;
23140 + info.threadstack_offset = offset;
23141 addr = vm_unmapped_area(&info);
23142 if (!(addr & ~PAGE_MASK))
23143 return addr;
23144 diff --git a/arch/x86/kernel/tboot.c b/arch/x86/kernel/tboot.c
23145 index f84fe00..f41d9f1 100644
23146 --- a/arch/x86/kernel/tboot.c
23147 +++ b/arch/x86/kernel/tboot.c
23148 @@ -220,7 +220,7 @@ static int tboot_setup_sleep(void)
23149
23150 void tboot_shutdown(u32 shutdown_type)
23151 {
23152 - void (*shutdown)(void);
23153 + void (* __noreturn shutdown)(void);
23154
23155 if (!tboot_enabled())
23156 return;
23157 @@ -242,7 +242,7 @@ void tboot_shutdown(u32 shutdown_type)
23158
23159 switch_to_tboot_pt();
23160
23161 - shutdown = (void(*)(void))(unsigned long)tboot->shutdown_entry;
23162 + shutdown = (void *)tboot->shutdown_entry;
23163 shutdown();
23164
23165 /* should not reach here */
23166 @@ -300,7 +300,7 @@ static int tboot_sleep(u8 sleep_state, u32 pm1a_control, u32 pm1b_control)
23167 return 0;
23168 }
23169
23170 -static atomic_t ap_wfs_count;
23171 +static atomic_unchecked_t ap_wfs_count;
23172
23173 static int tboot_wait_for_aps(int num_aps)
23174 {
23175 @@ -324,16 +324,16 @@ static int __cpuinit tboot_cpu_callback(struct notifier_block *nfb,
23176 {
23177 switch (action) {
23178 case CPU_DYING:
23179 - atomic_inc(&ap_wfs_count);
23180 + atomic_inc_unchecked(&ap_wfs_count);
23181 if (num_online_cpus() == 1)
23182 - if (tboot_wait_for_aps(atomic_read(&ap_wfs_count)))
23183 + if (tboot_wait_for_aps(atomic_read_unchecked(&ap_wfs_count)))
23184 return NOTIFY_BAD;
23185 break;
23186 }
23187 return NOTIFY_OK;
23188 }
23189
23190 -static struct notifier_block tboot_cpu_notifier __cpuinitdata =
23191 +static struct notifier_block tboot_cpu_notifier =
23192 {
23193 .notifier_call = tboot_cpu_callback,
23194 };
23195 @@ -345,7 +345,7 @@ static __init int tboot_late_init(void)
23196
23197 tboot_create_trampoline();
23198
23199 - atomic_set(&ap_wfs_count, 0);
23200 + atomic_set_unchecked(&ap_wfs_count, 0);
23201 register_hotcpu_notifier(&tboot_cpu_notifier);
23202
23203 acpi_os_set_prepare_sleep(&tboot_sleep);
23204 diff --git a/arch/x86/kernel/time.c b/arch/x86/kernel/time.c
23205 index 24d3c91..d06b473 100644
23206 --- a/arch/x86/kernel/time.c
23207 +++ b/arch/x86/kernel/time.c
23208 @@ -30,9 +30,9 @@ unsigned long profile_pc(struct pt_regs *regs)
23209 {
23210 unsigned long pc = instruction_pointer(regs);
23211
23212 - if (!user_mode_vm(regs) && in_lock_functions(pc)) {
23213 + if (!user_mode(regs) && in_lock_functions(pc)) {
23214 #ifdef CONFIG_FRAME_POINTER
23215 - return *(unsigned long *)(regs->bp + sizeof(long));
23216 + return ktla_ktva(*(unsigned long *)(regs->bp + sizeof(long)));
23217 #else
23218 unsigned long *sp =
23219 (unsigned long *)kernel_stack_pointer(regs);
23220 @@ -41,11 +41,17 @@ unsigned long profile_pc(struct pt_regs *regs)
23221 * or above a saved flags. Eflags has bits 22-31 zero,
23222 * kernel addresses don't.
23223 */
23224 +
23225 +#ifdef CONFIG_PAX_KERNEXEC
23226 + return ktla_ktva(sp[0]);
23227 +#else
23228 if (sp[0] >> 22)
23229 return sp[0];
23230 if (sp[1] >> 22)
23231 return sp[1];
23232 #endif
23233 +
23234 +#endif
23235 }
23236 return pc;
23237 }
23238 diff --git a/arch/x86/kernel/tls.c b/arch/x86/kernel/tls.c
23239 index 9d9d2f9..cad418a 100644
23240 --- a/arch/x86/kernel/tls.c
23241 +++ b/arch/x86/kernel/tls.c
23242 @@ -84,6 +84,11 @@ int do_set_thread_area(struct task_struct *p, int idx,
23243 if (idx < GDT_ENTRY_TLS_MIN || idx > GDT_ENTRY_TLS_MAX)
23244 return -EINVAL;
23245
23246 +#ifdef CONFIG_PAX_SEGMEXEC
23247 + if ((p->mm->pax_flags & MF_PAX_SEGMEXEC) && (info.contents & MODIFY_LDT_CONTENTS_CODE))
23248 + return -EINVAL;
23249 +#endif
23250 +
23251 set_tls_desc(p, idx, &info, 1);
23252
23253 return 0;
23254 @@ -204,7 +209,7 @@ int regset_tls_set(struct task_struct *target, const struct user_regset *regset,
23255
23256 if (kbuf)
23257 info = kbuf;
23258 - else if (__copy_from_user(infobuf, ubuf, count))
23259 + else if (count > sizeof infobuf || __copy_from_user(infobuf, ubuf, count))
23260 return -EFAULT;
23261 else
23262 info = infobuf;
23263 diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
23264 index 68bda7a..3ec7bb7 100644
23265 --- a/arch/x86/kernel/traps.c
23266 +++ b/arch/x86/kernel/traps.c
23267 @@ -68,12 +68,6 @@
23268 #include <asm/setup.h>
23269
23270 asmlinkage int system_call(void);
23271 -
23272 -/*
23273 - * The IDT has to be page-aligned to simplify the Pentium
23274 - * F0 0F bug workaround.
23275 - */
23276 -gate_desc idt_table[NR_VECTORS] __page_aligned_data = { { { { 0, 0 } } }, };
23277 #endif
23278
23279 DECLARE_BITMAP(used_vectors, NR_VECTORS);
23280 @@ -106,11 +100,11 @@ static inline void preempt_conditional_cli(struct pt_regs *regs)
23281 }
23282
23283 static int __kprobes
23284 -do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
23285 +do_trap_no_signal(struct task_struct *tsk, int trapnr, const char *str,
23286 struct pt_regs *regs, long error_code)
23287 {
23288 #ifdef CONFIG_X86_32
23289 - if (regs->flags & X86_VM_MASK) {
23290 + if (v8086_mode(regs)) {
23291 /*
23292 * Traps 0, 1, 3, 4, and 5 should be forwarded to vm86.
23293 * On nmi (interrupt 2), do_trap should not be called.
23294 @@ -123,12 +117,24 @@ do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
23295 return -1;
23296 }
23297 #endif
23298 - if (!user_mode(regs)) {
23299 + if (!user_mode_novm(regs)) {
23300 if (!fixup_exception(regs)) {
23301 tsk->thread.error_code = error_code;
23302 tsk->thread.trap_nr = trapnr;
23303 +
23304 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
23305 + if (trapnr == 12 && ((regs->cs & 0xFFFF) == __KERNEL_CS || (regs->cs & 0xFFFF) == __KERNEXEC_KERNEL_CS))
23306 + str = "PAX: suspicious stack segment fault";
23307 +#endif
23308 +
23309 die(str, regs, error_code);
23310 }
23311 +
23312 +#ifdef CONFIG_PAX_REFCOUNT
23313 + if (trapnr == 4)
23314 + pax_report_refcount_overflow(regs);
23315 +#endif
23316 +
23317 return 0;
23318 }
23319
23320 @@ -136,7 +142,7 @@ do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
23321 }
23322
23323 static void __kprobes
23324 -do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
23325 +do_trap(int trapnr, int signr, const char *str, struct pt_regs *regs,
23326 long error_code, siginfo_t *info)
23327 {
23328 struct task_struct *tsk = current;
23329 @@ -160,7 +166,7 @@ do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
23330 if (show_unhandled_signals && unhandled_signal(tsk, signr) &&
23331 printk_ratelimit()) {
23332 pr_info("%s[%d] trap %s ip:%lx sp:%lx error:%lx",
23333 - tsk->comm, tsk->pid, str,
23334 + tsk->comm, task_pid_nr(tsk), str,
23335 regs->ip, regs->sp, error_code);
23336 print_vma_addr(" in ", regs->ip);
23337 pr_cont("\n");
23338 @@ -266,7 +272,7 @@ do_general_protection(struct pt_regs *regs, long error_code)
23339 conditional_sti(regs);
23340
23341 #ifdef CONFIG_X86_32
23342 - if (regs->flags & X86_VM_MASK) {
23343 + if (v8086_mode(regs)) {
23344 local_irq_enable();
23345 handle_vm86_fault((struct kernel_vm86_regs *) regs, error_code);
23346 goto exit;
23347 @@ -274,18 +280,42 @@ do_general_protection(struct pt_regs *regs, long error_code)
23348 #endif
23349
23350 tsk = current;
23351 - if (!user_mode(regs)) {
23352 + if (!user_mode_novm(regs)) {
23353 if (fixup_exception(regs))
23354 goto exit;
23355
23356 tsk->thread.error_code = error_code;
23357 tsk->thread.trap_nr = X86_TRAP_GP;
23358 if (notify_die(DIE_GPF, "general protection fault", regs, error_code,
23359 - X86_TRAP_GP, SIGSEGV) != NOTIFY_STOP)
23360 + X86_TRAP_GP, SIGSEGV) != NOTIFY_STOP) {
23361 +
23362 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
23363 + if ((regs->cs & 0xFFFF) == __KERNEL_CS || (regs->cs & 0xFFFF) == __KERNEXEC_KERNEL_CS)
23364 + die("PAX: suspicious general protection fault", regs, error_code);
23365 + else
23366 +#endif
23367 +
23368 die("general protection fault", regs, error_code);
23369 + }
23370 goto exit;
23371 }
23372
23373 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
23374 + if (!(__supported_pte_mask & _PAGE_NX) && tsk->mm && (tsk->mm->pax_flags & MF_PAX_PAGEEXEC)) {
23375 + struct mm_struct *mm = tsk->mm;
23376 + unsigned long limit;
23377 +
23378 + down_write(&mm->mmap_sem);
23379 + limit = mm->context.user_cs_limit;
23380 + if (limit < TASK_SIZE) {
23381 + track_exec_limit(mm, limit, TASK_SIZE, VM_EXEC);
23382 + up_write(&mm->mmap_sem);
23383 + return;
23384 + }
23385 + up_write(&mm->mmap_sem);
23386 + }
23387 +#endif
23388 +
23389 tsk->thread.error_code = error_code;
23390 tsk->thread.trap_nr = X86_TRAP_GP;
23391
23392 @@ -440,7 +470,7 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
23393 /* It's safe to allow irq's after DR6 has been saved */
23394 preempt_conditional_sti(regs);
23395
23396 - if (regs->flags & X86_VM_MASK) {
23397 + if (v8086_mode(regs)) {
23398 handle_vm86_trap((struct kernel_vm86_regs *) regs, error_code,
23399 X86_TRAP_DB);
23400 preempt_conditional_cli(regs);
23401 @@ -455,7 +485,7 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
23402 * We already checked v86 mode above, so we can check for kernel mode
23403 * by just checking the CPL of CS.
23404 */
23405 - if ((dr6 & DR_STEP) && !user_mode(regs)) {
23406 + if ((dr6 & DR_STEP) && !user_mode_novm(regs)) {
23407 tsk->thread.debugreg6 &= ~DR_STEP;
23408 set_tsk_thread_flag(tsk, TIF_SINGLESTEP);
23409 regs->flags &= ~X86_EFLAGS_TF;
23410 @@ -487,7 +517,7 @@ void math_error(struct pt_regs *regs, int error_code, int trapnr)
23411 return;
23412 conditional_sti(regs);
23413
23414 - if (!user_mode_vm(regs))
23415 + if (!user_mode(regs))
23416 {
23417 if (!fixup_exception(regs)) {
23418 task->thread.error_code = error_code;
23419 diff --git a/arch/x86/kernel/uprobes.c b/arch/x86/kernel/uprobes.c
23420 index 0ba4cfb..4596bec 100644
23421 --- a/arch/x86/kernel/uprobes.c
23422 +++ b/arch/x86/kernel/uprobes.c
23423 @@ -629,7 +629,7 @@ int arch_uprobe_exception_notify(struct notifier_block *self, unsigned long val,
23424 int ret = NOTIFY_DONE;
23425
23426 /* We are only interested in userspace traps */
23427 - if (regs && !user_mode_vm(regs))
23428 + if (regs && !user_mode(regs))
23429 return NOTIFY_DONE;
23430
23431 switch (val) {
23432 diff --git a/arch/x86/kernel/verify_cpu.S b/arch/x86/kernel/verify_cpu.S
23433 index b9242ba..50c5edd 100644
23434 --- a/arch/x86/kernel/verify_cpu.S
23435 +++ b/arch/x86/kernel/verify_cpu.S
23436 @@ -20,6 +20,7 @@
23437 * arch/x86/boot/compressed/head_64.S: Boot cpu verification
23438 * arch/x86/kernel/trampoline_64.S: secondary processor verification
23439 * arch/x86/kernel/head_32.S: processor startup
23440 + * arch/x86/kernel/acpi/realmode/wakeup.S: 32bit processor resume
23441 *
23442 * verify_cpu, returns the status of longmode and SSE in register %eax.
23443 * 0: Success 1: Failure
23444 diff --git a/arch/x86/kernel/vm86_32.c b/arch/x86/kernel/vm86_32.c
23445 index 3dbdd9c..888b14e 100644
23446 --- a/arch/x86/kernel/vm86_32.c
23447 +++ b/arch/x86/kernel/vm86_32.c
23448 @@ -44,6 +44,7 @@
23449 #include <linux/ptrace.h>
23450 #include <linux/audit.h>
23451 #include <linux/stddef.h>
23452 +#include <linux/grsecurity.h>
23453
23454 #include <asm/uaccess.h>
23455 #include <asm/io.h>
23456 @@ -150,7 +151,7 @@ struct pt_regs *save_v86_state(struct kernel_vm86_regs *regs)
23457 do_exit(SIGSEGV);
23458 }
23459
23460 - tss = &per_cpu(init_tss, get_cpu());
23461 + tss = init_tss + get_cpu();
23462 current->thread.sp0 = current->thread.saved_sp0;
23463 current->thread.sysenter_cs = __KERNEL_CS;
23464 load_sp0(tss, &current->thread);
23465 @@ -214,6 +215,14 @@ SYSCALL_DEFINE1(vm86old, struct vm86_struct __user *, v86)
23466
23467 if (tsk->thread.saved_sp0)
23468 goto out;
23469 +
23470 +#ifdef CONFIG_GRKERNSEC_VM86
23471 + if (!capable(CAP_SYS_RAWIO)) {
23472 + gr_handle_vm86();
23473 + goto out;
23474 + }
23475 +#endif
23476 +
23477 tmp = copy_vm86_regs_from_user(&info.regs, &v86->regs,
23478 offsetof(struct kernel_vm86_struct, vm86plus) -
23479 sizeof(info.regs));
23480 @@ -242,6 +251,14 @@ SYSCALL_DEFINE2(vm86, unsigned long, cmd, unsigned long, arg)
23481 int tmp, ret;
23482 struct vm86plus_struct __user *v86;
23483
23484 +#ifdef CONFIG_GRKERNSEC_VM86
23485 + if (!capable(CAP_SYS_RAWIO)) {
23486 + gr_handle_vm86();
23487 + ret = -EPERM;
23488 + goto out;
23489 + }
23490 +#endif
23491 +
23492 tsk = current;
23493 switch (cmd) {
23494 case VM86_REQUEST_IRQ:
23495 @@ -329,7 +346,7 @@ static void do_sys_vm86(struct kernel_vm86_struct *info, struct task_struct *tsk
23496 tsk->thread.saved_fs = info->regs32->fs;
23497 tsk->thread.saved_gs = get_user_gs(info->regs32);
23498
23499 - tss = &per_cpu(init_tss, get_cpu());
23500 + tss = init_tss + get_cpu();
23501 tsk->thread.sp0 = (unsigned long) &info->VM86_TSS_ESP0;
23502 if (cpu_has_sep)
23503 tsk->thread.sysenter_cs = 0;
23504 @@ -536,7 +553,7 @@ static void do_int(struct kernel_vm86_regs *regs, int i,
23505 goto cannot_handle;
23506 if (i == 0x21 && is_revectored(AH(regs), &KVM86->int21_revectored))
23507 goto cannot_handle;
23508 - intr_ptr = (unsigned long __user *) (i << 2);
23509 + intr_ptr = (__force unsigned long __user *) (i << 2);
23510 if (get_user(segoffs, intr_ptr))
23511 goto cannot_handle;
23512 if ((segoffs >> 16) == BIOSSEG)
23513 diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S
23514 index 22a1530..8fbaaad 100644
23515 --- a/arch/x86/kernel/vmlinux.lds.S
23516 +++ b/arch/x86/kernel/vmlinux.lds.S
23517 @@ -26,6 +26,13 @@
23518 #include <asm/page_types.h>
23519 #include <asm/cache.h>
23520 #include <asm/boot.h>
23521 +#include <asm/segment.h>
23522 +
23523 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
23524 +#define __KERNEL_TEXT_OFFSET (LOAD_OFFSET + ____LOAD_PHYSICAL_ADDR)
23525 +#else
23526 +#define __KERNEL_TEXT_OFFSET 0
23527 +#endif
23528
23529 #undef i386 /* in case the preprocessor is a 32bit one */
23530
23531 @@ -69,30 +76,43 @@ jiffies_64 = jiffies;
23532
23533 PHDRS {
23534 text PT_LOAD FLAGS(5); /* R_E */
23535 +#ifdef CONFIG_X86_32
23536 + module PT_LOAD FLAGS(5); /* R_E */
23537 +#endif
23538 +#ifdef CONFIG_XEN
23539 + rodata PT_LOAD FLAGS(5); /* R_E */
23540 +#else
23541 + rodata PT_LOAD FLAGS(4); /* R__ */
23542 +#endif
23543 data PT_LOAD FLAGS(6); /* RW_ */
23544 -#ifdef CONFIG_X86_64
23545 + init.begin PT_LOAD FLAGS(6); /* RW_ */
23546 #ifdef CONFIG_SMP
23547 percpu PT_LOAD FLAGS(6); /* RW_ */
23548 #endif
23549 + text.init PT_LOAD FLAGS(5); /* R_E */
23550 + text.exit PT_LOAD FLAGS(5); /* R_E */
23551 init PT_LOAD FLAGS(7); /* RWE */
23552 -#endif
23553 note PT_NOTE FLAGS(0); /* ___ */
23554 }
23555
23556 SECTIONS
23557 {
23558 #ifdef CONFIG_X86_32
23559 - . = LOAD_OFFSET + LOAD_PHYSICAL_ADDR;
23560 - phys_startup_32 = startup_32 - LOAD_OFFSET;
23561 + . = LOAD_OFFSET + ____LOAD_PHYSICAL_ADDR;
23562 #else
23563 - . = __START_KERNEL;
23564 - phys_startup_64 = startup_64 - LOAD_OFFSET;
23565 + . = __START_KERNEL;
23566 #endif
23567
23568 /* Text and read-only data */
23569 - .text : AT(ADDR(.text) - LOAD_OFFSET) {
23570 - _text = .;
23571 + .text (. - __KERNEL_TEXT_OFFSET): AT(ADDR(.text) - LOAD_OFFSET + __KERNEL_TEXT_OFFSET) {
23572 /* bootstrapping code */
23573 +#ifdef CONFIG_X86_32
23574 + phys_startup_32 = startup_32 - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
23575 +#else
23576 + phys_startup_64 = startup_64 - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
23577 +#endif
23578 + __LOAD_PHYSICAL_ADDR = . - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
23579 + _text = .;
23580 HEAD_TEXT
23581 #ifdef CONFIG_X86_32
23582 . = ALIGN(PAGE_SIZE);
23583 @@ -108,13 +128,48 @@ SECTIONS
23584 IRQENTRY_TEXT
23585 *(.fixup)
23586 *(.gnu.warning)
23587 - /* End of text section */
23588 - _etext = .;
23589 } :text = 0x9090
23590
23591 - NOTES :text :note
23592 + . += __KERNEL_TEXT_OFFSET;
23593
23594 - EXCEPTION_TABLE(16) :text = 0x9090
23595 +#ifdef CONFIG_X86_32
23596 + . = ALIGN(PAGE_SIZE);
23597 + .module.text : AT(ADDR(.module.text) - LOAD_OFFSET) {
23598 +
23599 +#if defined(CONFIG_PAX_KERNEXEC) && defined(CONFIG_MODULES)
23600 + MODULES_EXEC_VADDR = .;
23601 + BYTE(0)
23602 + . += (CONFIG_PAX_KERNEXEC_MODULE_TEXT * 1024 * 1024);
23603 + . = ALIGN(HPAGE_SIZE) - 1;
23604 + MODULES_EXEC_END = .;
23605 +#endif
23606 +
23607 + } :module
23608 +#endif
23609 +
23610 + .text.end : AT(ADDR(.text.end) - LOAD_OFFSET) {
23611 + /* End of text section */
23612 + BYTE(0)
23613 + _etext = . - __KERNEL_TEXT_OFFSET;
23614 + }
23615 +
23616 +#ifdef CONFIG_X86_32
23617 + . = ALIGN(PAGE_SIZE);
23618 + .rodata.page_aligned : AT(ADDR(.rodata.page_aligned) - LOAD_OFFSET) {
23619 + *(.idt)
23620 + . = ALIGN(PAGE_SIZE);
23621 + *(.empty_zero_page)
23622 + *(.initial_pg_fixmap)
23623 + *(.initial_pg_pmd)
23624 + *(.initial_page_table)
23625 + *(.swapper_pg_dir)
23626 + } :rodata
23627 +#endif
23628 +
23629 + . = ALIGN(PAGE_SIZE);
23630 + NOTES :rodata :note
23631 +
23632 + EXCEPTION_TABLE(16) :rodata
23633
23634 #if defined(CONFIG_DEBUG_RODATA)
23635 /* .text should occupy whole number of pages */
23636 @@ -126,16 +181,20 @@ SECTIONS
23637
23638 /* Data */
23639 .data : AT(ADDR(.data) - LOAD_OFFSET) {
23640 +
23641 +#ifdef CONFIG_PAX_KERNEXEC
23642 + . = ALIGN(HPAGE_SIZE);
23643 +#else
23644 + . = ALIGN(PAGE_SIZE);
23645 +#endif
23646 +
23647 /* Start of data section */
23648 _sdata = .;
23649
23650 /* init_task */
23651 INIT_TASK_DATA(THREAD_SIZE)
23652
23653 -#ifdef CONFIG_X86_32
23654 - /* 32 bit has nosave before _edata */
23655 NOSAVE_DATA
23656 -#endif
23657
23658 PAGE_ALIGNED_DATA(PAGE_SIZE)
23659
23660 @@ -176,12 +235,19 @@ SECTIONS
23661 #endif /* CONFIG_X86_64 */
23662
23663 /* Init code and data - will be freed after init */
23664 - . = ALIGN(PAGE_SIZE);
23665 .init.begin : AT(ADDR(.init.begin) - LOAD_OFFSET) {
23666 + BYTE(0)
23667 +
23668 +#ifdef CONFIG_PAX_KERNEXEC
23669 + . = ALIGN(HPAGE_SIZE);
23670 +#else
23671 + . = ALIGN(PAGE_SIZE);
23672 +#endif
23673 +
23674 __init_begin = .; /* paired with __init_end */
23675 - }
23676 + } :init.begin
23677
23678 -#if defined(CONFIG_X86_64) && defined(CONFIG_SMP)
23679 +#ifdef CONFIG_SMP
23680 /*
23681 * percpu offsets are zero-based on SMP. PERCPU_VADDR() changes the
23682 * output PHDR, so the next output section - .init.text - should
23683 @@ -190,12 +256,27 @@ SECTIONS
23684 PERCPU_VADDR(INTERNODE_CACHE_BYTES, 0, :percpu)
23685 #endif
23686
23687 - INIT_TEXT_SECTION(PAGE_SIZE)
23688 -#ifdef CONFIG_X86_64
23689 - :init
23690 -#endif
23691 + . = ALIGN(PAGE_SIZE);
23692 + init_begin = .;
23693 + .init.text (. - __KERNEL_TEXT_OFFSET): AT(init_begin - LOAD_OFFSET) {
23694 + VMLINUX_SYMBOL(_sinittext) = .;
23695 + INIT_TEXT
23696 + VMLINUX_SYMBOL(_einittext) = .;
23697 + . = ALIGN(PAGE_SIZE);
23698 + } :text.init
23699
23700 - INIT_DATA_SECTION(16)
23701 + /*
23702 + * .exit.text is discard at runtime, not link time, to deal with
23703 + * references from .altinstructions and .eh_frame
23704 + */
23705 + .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET + __KERNEL_TEXT_OFFSET) {
23706 + EXIT_TEXT
23707 + . = ALIGN(16);
23708 + } :text.exit
23709 + . = init_begin + SIZEOF(.init.text) + SIZEOF(.exit.text);
23710 +
23711 + . = ALIGN(PAGE_SIZE);
23712 + INIT_DATA_SECTION(16) :init
23713
23714 .x86_cpu_dev.init : AT(ADDR(.x86_cpu_dev.init) - LOAD_OFFSET) {
23715 __x86_cpu_dev_start = .;
23716 @@ -257,19 +338,12 @@ SECTIONS
23717 }
23718
23719 . = ALIGN(8);
23720 - /*
23721 - * .exit.text is discard at runtime, not link time, to deal with
23722 - * references from .altinstructions and .eh_frame
23723 - */
23724 - .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) {
23725 - EXIT_TEXT
23726 - }
23727
23728 .exit.data : AT(ADDR(.exit.data) - LOAD_OFFSET) {
23729 EXIT_DATA
23730 }
23731
23732 -#if !defined(CONFIG_X86_64) || !defined(CONFIG_SMP)
23733 +#ifndef CONFIG_SMP
23734 PERCPU_SECTION(INTERNODE_CACHE_BYTES)
23735 #endif
23736
23737 @@ -288,16 +362,10 @@ SECTIONS
23738 .smp_locks : AT(ADDR(.smp_locks) - LOAD_OFFSET) {
23739 __smp_locks = .;
23740 *(.smp_locks)
23741 - . = ALIGN(PAGE_SIZE);
23742 __smp_locks_end = .;
23743 + . = ALIGN(PAGE_SIZE);
23744 }
23745
23746 -#ifdef CONFIG_X86_64
23747 - .data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) {
23748 - NOSAVE_DATA
23749 - }
23750 -#endif
23751 -
23752 /* BSS */
23753 . = ALIGN(PAGE_SIZE);
23754 .bss : AT(ADDR(.bss) - LOAD_OFFSET) {
23755 @@ -313,6 +381,7 @@ SECTIONS
23756 __brk_base = .;
23757 . += 64 * 1024; /* 64k alignment slop space */
23758 *(.brk_reservation) /* areas brk users have reserved */
23759 + . = ALIGN(HPAGE_SIZE);
23760 __brk_limit = .;
23761 }
23762
23763 @@ -339,13 +408,12 @@ SECTIONS
23764 * for the boot processor.
23765 */
23766 #define INIT_PER_CPU(x) init_per_cpu__##x = x + __per_cpu_load
23767 -INIT_PER_CPU(gdt_page);
23768 INIT_PER_CPU(irq_stack_union);
23769
23770 /*
23771 * Build-time check on the image size:
23772 */
23773 -. = ASSERT((_end - _text <= KERNEL_IMAGE_SIZE),
23774 +. = ASSERT((_end - _text - __KERNEL_TEXT_OFFSET <= KERNEL_IMAGE_SIZE),
23775 "kernel image bigger than KERNEL_IMAGE_SIZE");
23776
23777 #ifdef CONFIG_SMP
23778 diff --git a/arch/x86/kernel/vsyscall_64.c b/arch/x86/kernel/vsyscall_64.c
23779 index 9a907a6..f83f921 100644
23780 --- a/arch/x86/kernel/vsyscall_64.c
23781 +++ b/arch/x86/kernel/vsyscall_64.c
23782 @@ -56,15 +56,13 @@
23783 DEFINE_VVAR(int, vgetcpu_mode);
23784 DEFINE_VVAR(struct vsyscall_gtod_data, vsyscall_gtod_data);
23785
23786 -static enum { EMULATE, NATIVE, NONE } vsyscall_mode = EMULATE;
23787 +static enum { EMULATE, NONE } vsyscall_mode = EMULATE;
23788
23789 static int __init vsyscall_setup(char *str)
23790 {
23791 if (str) {
23792 if (!strcmp("emulate", str))
23793 vsyscall_mode = EMULATE;
23794 - else if (!strcmp("native", str))
23795 - vsyscall_mode = NATIVE;
23796 else if (!strcmp("none", str))
23797 vsyscall_mode = NONE;
23798 else
23799 @@ -323,8 +321,7 @@ do_ret:
23800 return true;
23801
23802 sigsegv:
23803 - force_sig(SIGSEGV, current);
23804 - return true;
23805 + do_group_exit(SIGKILL);
23806 }
23807
23808 /*
23809 @@ -377,10 +374,7 @@ void __init map_vsyscall(void)
23810 extern char __vvar_page;
23811 unsigned long physaddr_vvar_page = __pa_symbol(&__vvar_page);
23812
23813 - __set_fixmap(VSYSCALL_FIRST_PAGE, physaddr_vsyscall,
23814 - vsyscall_mode == NATIVE
23815 - ? PAGE_KERNEL_VSYSCALL
23816 - : PAGE_KERNEL_VVAR);
23817 + __set_fixmap(VSYSCALL_FIRST_PAGE, physaddr_vsyscall, PAGE_KERNEL_VVAR);
23818 BUILD_BUG_ON((unsigned long)__fix_to_virt(VSYSCALL_FIRST_PAGE) !=
23819 (unsigned long)VSYSCALL_START);
23820
23821 diff --git a/arch/x86/kernel/x8664_ksyms_64.c b/arch/x86/kernel/x8664_ksyms_64.c
23822 index b014d94..6d6ca7b 100644
23823 --- a/arch/x86/kernel/x8664_ksyms_64.c
23824 +++ b/arch/x86/kernel/x8664_ksyms_64.c
23825 @@ -34,8 +34,6 @@ EXPORT_SYMBOL(copy_user_generic_string);
23826 EXPORT_SYMBOL(copy_user_generic_unrolled);
23827 EXPORT_SYMBOL(copy_user_enhanced_fast_string);
23828 EXPORT_SYMBOL(__copy_user_nocache);
23829 -EXPORT_SYMBOL(_copy_from_user);
23830 -EXPORT_SYMBOL(_copy_to_user);
23831
23832 EXPORT_SYMBOL(copy_page);
23833 EXPORT_SYMBOL(clear_page);
23834 diff --git a/arch/x86/kernel/x86_init.c b/arch/x86/kernel/x86_init.c
23835 index 45a14db..075bb9b 100644
23836 --- a/arch/x86/kernel/x86_init.c
23837 +++ b/arch/x86/kernel/x86_init.c
23838 @@ -85,7 +85,7 @@ struct x86_init_ops x86_init __initdata = {
23839 },
23840 };
23841
23842 -struct x86_cpuinit_ops x86_cpuinit __cpuinitdata = {
23843 +struct x86_cpuinit_ops x86_cpuinit __cpuinitconst = {
23844 .early_percpu_clock_init = x86_init_noop,
23845 .setup_percpu_clockev = setup_secondary_APIC_clock,
23846 };
23847 @@ -93,7 +93,7 @@ struct x86_cpuinit_ops x86_cpuinit __cpuinitdata = {
23848 static void default_nmi_init(void) { };
23849 static int default_i8042_detect(void) { return 1; };
23850
23851 -struct x86_platform_ops x86_platform = {
23852 +struct x86_platform_ops x86_platform __read_only = {
23853 .calibrate_tsc = native_calibrate_tsc,
23854 .get_wallclock = mach_get_cmos_time,
23855 .set_wallclock = mach_set_rtc_mmss,
23856 @@ -107,7 +107,7 @@ struct x86_platform_ops x86_platform = {
23857 };
23858
23859 EXPORT_SYMBOL_GPL(x86_platform);
23860 -struct x86_msi_ops x86_msi = {
23861 +struct x86_msi_ops x86_msi __read_only = {
23862 .setup_msi_irqs = native_setup_msi_irqs,
23863 .compose_msi_msg = native_compose_msi_msg,
23864 .teardown_msi_irq = native_teardown_msi_irq,
23865 @@ -116,7 +116,7 @@ struct x86_msi_ops x86_msi = {
23866 .setup_hpet_msi = default_setup_hpet_msi,
23867 };
23868
23869 -struct x86_io_apic_ops x86_io_apic_ops = {
23870 +struct x86_io_apic_ops x86_io_apic_ops __read_only = {
23871 .init = native_io_apic_init_mappings,
23872 .read = native_io_apic_read,
23873 .write = native_io_apic_write,
23874 diff --git a/arch/x86/kernel/xsave.c b/arch/x86/kernel/xsave.c
23875 index ada87a3..afea76d 100644
23876 --- a/arch/x86/kernel/xsave.c
23877 +++ b/arch/x86/kernel/xsave.c
23878 @@ -199,6 +199,7 @@ static inline int save_user_xstate(struct xsave_struct __user *buf)
23879 {
23880 int err;
23881
23882 + buf = (struct xsave_struct __user *)____m(buf);
23883 if (use_xsave())
23884 err = xsave_user(buf);
23885 else if (use_fxsr())
23886 @@ -311,6 +312,7 @@ sanitize_restored_xstate(struct task_struct *tsk,
23887 */
23888 static inline int restore_user_xstate(void __user *buf, u64 xbv, int fx_only)
23889 {
23890 + buf = (void __user *)____m(buf);
23891 if (use_xsave()) {
23892 if ((unsigned long)buf % 64 || fx_only) {
23893 u64 init_bv = pcntxt_mask & ~XSTATE_FPSSE;
23894 diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
23895 index a20ecb5..d0e2194 100644
23896 --- a/arch/x86/kvm/cpuid.c
23897 +++ b/arch/x86/kvm/cpuid.c
23898 @@ -124,15 +124,20 @@ int kvm_vcpu_ioctl_set_cpuid2(struct kvm_vcpu *vcpu,
23899 struct kvm_cpuid2 *cpuid,
23900 struct kvm_cpuid_entry2 __user *entries)
23901 {
23902 - int r;
23903 + int r, i;
23904
23905 r = -E2BIG;
23906 if (cpuid->nent > KVM_MAX_CPUID_ENTRIES)
23907 goto out;
23908 r = -EFAULT;
23909 - if (copy_from_user(&vcpu->arch.cpuid_entries, entries,
23910 - cpuid->nent * sizeof(struct kvm_cpuid_entry2)))
23911 + if (!access_ok(VERIFY_READ, entries, cpuid->nent * sizeof(struct kvm_cpuid_entry2)))
23912 goto out;
23913 + for (i = 0; i < cpuid->nent; ++i) {
23914 + struct kvm_cpuid_entry2 cpuid_entry;
23915 + if (__copy_from_user(&cpuid_entry, entries + i, sizeof(cpuid_entry)))
23916 + goto out;
23917 + vcpu->arch.cpuid_entries[i] = cpuid_entry;
23918 + }
23919 vcpu->arch.cpuid_nent = cpuid->nent;
23920 kvm_apic_set_version(vcpu);
23921 kvm_x86_ops->cpuid_update(vcpu);
23922 @@ -147,15 +152,19 @@ int kvm_vcpu_ioctl_get_cpuid2(struct kvm_vcpu *vcpu,
23923 struct kvm_cpuid2 *cpuid,
23924 struct kvm_cpuid_entry2 __user *entries)
23925 {
23926 - int r;
23927 + int r, i;
23928
23929 r = -E2BIG;
23930 if (cpuid->nent < vcpu->arch.cpuid_nent)
23931 goto out;
23932 r = -EFAULT;
23933 - if (copy_to_user(entries, &vcpu->arch.cpuid_entries,
23934 - vcpu->arch.cpuid_nent * sizeof(struct kvm_cpuid_entry2)))
23935 + if (!access_ok(VERIFY_WRITE, entries, vcpu->arch.cpuid_nent * sizeof(struct kvm_cpuid_entry2)))
23936 goto out;
23937 + for (i = 0; i < vcpu->arch.cpuid_nent; ++i) {
23938 + struct kvm_cpuid_entry2 cpuid_entry = vcpu->arch.cpuid_entries[i];
23939 + if (__copy_to_user(entries + i, &cpuid_entry, sizeof(cpuid_entry)))
23940 + goto out;
23941 + }
23942 return 0;
23943
23944 out:
23945 diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
23946 index 59622c9..f338414 100644
23947 --- a/arch/x86/kvm/emulate.c
23948 +++ b/arch/x86/kvm/emulate.c
23949 @@ -328,6 +328,7 @@ static void invalidate_registers(struct x86_emulate_ctxt *ctxt)
23950
23951 #define ____emulate_2op(ctxt, _op, _x, _y, _suffix, _dsttype) \
23952 do { \
23953 + unsigned long _tmp; \
23954 __asm__ __volatile__ ( \
23955 _PRE_EFLAGS("0", "4", "2") \
23956 _op _suffix " %"_x"3,%1; " \
23957 @@ -342,8 +343,6 @@ static void invalidate_registers(struct x86_emulate_ctxt *ctxt)
23958 /* Raw emulation: instruction has two explicit operands. */
23959 #define __emulate_2op_nobyte(ctxt,_op,_wx,_wy,_lx,_ly,_qx,_qy) \
23960 do { \
23961 - unsigned long _tmp; \
23962 - \
23963 switch ((ctxt)->dst.bytes) { \
23964 case 2: \
23965 ____emulate_2op(ctxt,_op,_wx,_wy,"w",u16); \
23966 @@ -359,7 +358,6 @@ static void invalidate_registers(struct x86_emulate_ctxt *ctxt)
23967
23968 #define __emulate_2op(ctxt,_op,_bx,_by,_wx,_wy,_lx,_ly,_qx,_qy) \
23969 do { \
23970 - unsigned long _tmp; \
23971 switch ((ctxt)->dst.bytes) { \
23972 case 1: \
23973 ____emulate_2op(ctxt,_op,_bx,_by,"b",u8); \
23974 diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
23975 index f77df1c..6f20690 100644
23976 --- a/arch/x86/kvm/lapic.c
23977 +++ b/arch/x86/kvm/lapic.c
23978 @@ -55,7 +55,7 @@
23979 #define APIC_BUS_CYCLE_NS 1
23980
23981 /* #define apic_debug(fmt,arg...) printk(KERN_WARNING fmt,##arg) */
23982 -#define apic_debug(fmt, arg...)
23983 +#define apic_debug(fmt, arg...) do {} while (0)
23984
23985 #define APIC_LVT_NUM 6
23986 /* 14 is the version for Xeon and Pentium 8.4.8*/
23987 diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h
23988 index 105dd5b..1b0ccc2 100644
23989 --- a/arch/x86/kvm/paging_tmpl.h
23990 +++ b/arch/x86/kvm/paging_tmpl.h
23991 @@ -208,7 +208,7 @@ retry_walk:
23992 if (unlikely(kvm_is_error_hva(host_addr)))
23993 goto error;
23994
23995 - ptep_user = (pt_element_t __user *)((void *)host_addr + offset);
23996 + ptep_user = (pt_element_t __force_user *)((void *)host_addr + offset);
23997 if (unlikely(__copy_from_user(&pte, ptep_user, sizeof(pte))))
23998 goto error;
23999 walker->ptep_user[walker->level - 1] = ptep_user;
24000 diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
24001 index e1b1ce2..f7b4b43 100644
24002 --- a/arch/x86/kvm/svm.c
24003 +++ b/arch/x86/kvm/svm.c
24004 @@ -3507,7 +3507,11 @@ static void reload_tss(struct kvm_vcpu *vcpu)
24005 int cpu = raw_smp_processor_id();
24006
24007 struct svm_cpu_data *sd = per_cpu(svm_data, cpu);
24008 +
24009 + pax_open_kernel();
24010 sd->tss_desc->type = 9; /* available 32/64-bit TSS */
24011 + pax_close_kernel();
24012 +
24013 load_TR_desc();
24014 }
24015
24016 @@ -3901,6 +3905,10 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu)
24017 #endif
24018 #endif
24019
24020 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
24021 + __set_fs(current_thread_info()->addr_limit);
24022 +#endif
24023 +
24024 reload_tss(vcpu);
24025
24026 local_irq_disable();
24027 diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
24028 index 0af1807..06912bb 100644
24029 --- a/arch/x86/kvm/vmx.c
24030 +++ b/arch/x86/kvm/vmx.c
24031 @@ -1184,12 +1184,12 @@ static void vmcs_write64(unsigned long field, u64 value)
24032 #endif
24033 }
24034
24035 -static void vmcs_clear_bits(unsigned long field, u32 mask)
24036 +static void vmcs_clear_bits(unsigned long field, unsigned long mask)
24037 {
24038 vmcs_writel(field, vmcs_readl(field) & ~mask);
24039 }
24040
24041 -static void vmcs_set_bits(unsigned long field, u32 mask)
24042 +static void vmcs_set_bits(unsigned long field, unsigned long mask)
24043 {
24044 vmcs_writel(field, vmcs_readl(field) | mask);
24045 }
24046 @@ -1390,7 +1390,11 @@ static void reload_tss(void)
24047 struct desc_struct *descs;
24048
24049 descs = (void *)gdt->address;
24050 +
24051 + pax_open_kernel();
24052 descs[GDT_ENTRY_TSS].type = 9; /* available TSS */
24053 + pax_close_kernel();
24054 +
24055 load_TR_desc();
24056 }
24057
24058 @@ -1614,6 +1618,10 @@ static void vmx_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
24059 vmcs_writel(HOST_TR_BASE, kvm_read_tr_base()); /* 22.2.4 */
24060 vmcs_writel(HOST_GDTR_BASE, gdt->address); /* 22.2.4 */
24061
24062 +#ifdef CONFIG_PAX_PER_CPU_PGD
24063 + vmcs_writel(HOST_CR3, read_cr3()); /* 22.2.3 FIXME: shadow tables */
24064 +#endif
24065 +
24066 rdmsrl(MSR_IA32_SYSENTER_ESP, sysenter_esp);
24067 vmcs_writel(HOST_IA32_SYSENTER_ESP, sysenter_esp); /* 22.2.3 */
24068 vmx->loaded_vmcs->cpu = cpu;
24069 @@ -2779,8 +2787,11 @@ static __init int hardware_setup(void)
24070 if (!cpu_has_vmx_flexpriority())
24071 flexpriority_enabled = 0;
24072
24073 - if (!cpu_has_vmx_tpr_shadow())
24074 - kvm_x86_ops->update_cr8_intercept = NULL;
24075 + if (!cpu_has_vmx_tpr_shadow()) {
24076 + pax_open_kernel();
24077 + *(void **)&kvm_x86_ops->update_cr8_intercept = NULL;
24078 + pax_close_kernel();
24079 + }
24080
24081 if (enable_ept && !cpu_has_vmx_ept_2m_page())
24082 kvm_disable_largepages();
24083 @@ -2792,10 +2803,12 @@ static __init int hardware_setup(void)
24084 !cpu_has_vmx_virtual_intr_delivery())
24085 enable_apicv_reg_vid = 0;
24086
24087 + pax_open_kernel();
24088 if (enable_apicv_reg_vid)
24089 - kvm_x86_ops->update_cr8_intercept = NULL;
24090 + *(void **)&kvm_x86_ops->update_cr8_intercept = NULL;
24091 else
24092 - kvm_x86_ops->hwapic_irr_update = NULL;
24093 + *(void **)&kvm_x86_ops->hwapic_irr_update = NULL;
24094 + pax_close_kernel();
24095
24096 if (nested)
24097 nested_vmx_setup_ctls_msrs();
24098 @@ -3883,7 +3896,10 @@ static void vmx_set_constant_host_state(void)
24099
24100 vmcs_writel(HOST_CR0, read_cr0() & ~X86_CR0_TS); /* 22.2.3 */
24101 vmcs_writel(HOST_CR4, read_cr4()); /* 22.2.3, 22.2.5 */
24102 +
24103 +#ifndef CONFIG_PAX_PER_CPU_PGD
24104 vmcs_writel(HOST_CR3, read_cr3()); /* 22.2.3 FIXME: shadow tables */
24105 +#endif
24106
24107 vmcs_write16(HOST_CS_SELECTOR, __KERNEL_CS); /* 22.2.4 */
24108 #ifdef CONFIG_X86_64
24109 @@ -3904,7 +3920,7 @@ static void vmx_set_constant_host_state(void)
24110 native_store_idt(&dt);
24111 vmcs_writel(HOST_IDTR_BASE, dt.address); /* 22.2.4 */
24112
24113 - vmcs_writel(HOST_RIP, vmx_return); /* 22.2.5 */
24114 + vmcs_writel(HOST_RIP, ktla_ktva(vmx_return)); /* 22.2.5 */
24115
24116 rdmsr(MSR_IA32_SYSENTER_CS, low32, high32);
24117 vmcs_write32(HOST_IA32_SYSENTER_CS, low32);
24118 @@ -6580,6 +6596,12 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
24119 "jmp 2f \n\t"
24120 "1: " __ex(ASM_VMX_VMRESUME) "\n\t"
24121 "2: "
24122 +
24123 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
24124 + "ljmp %[cs],$3f\n\t"
24125 + "3: "
24126 +#endif
24127 +
24128 /* Save guest registers, load host registers, keep flags */
24129 "mov %0, %c[wordsize](%%" _ASM_SP ") \n\t"
24130 "pop %0 \n\t"
24131 @@ -6632,6 +6654,11 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
24132 #endif
24133 [cr2]"i"(offsetof(struct vcpu_vmx, vcpu.arch.cr2)),
24134 [wordsize]"i"(sizeof(ulong))
24135 +
24136 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
24137 + ,[cs]"i"(__KERNEL_CS)
24138 +#endif
24139 +
24140 : "cc", "memory"
24141 #ifdef CONFIG_X86_64
24142 , "rax", "rbx", "rdi", "rsi"
24143 @@ -6645,7 +6672,7 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
24144 if (debugctlmsr)
24145 update_debugctlmsr(debugctlmsr);
24146
24147 -#ifndef CONFIG_X86_64
24148 +#ifdef CONFIG_X86_32
24149 /*
24150 * The sysexit path does not restore ds/es, so we must set them to
24151 * a reasonable value ourselves.
24152 @@ -6654,8 +6681,18 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
24153 * may be executed in interrupt context, which saves and restore segments
24154 * around it, nullifying its effect.
24155 */
24156 - loadsegment(ds, __USER_DS);
24157 - loadsegment(es, __USER_DS);
24158 + loadsegment(ds, __KERNEL_DS);
24159 + loadsegment(es, __KERNEL_DS);
24160 + loadsegment(ss, __KERNEL_DS);
24161 +
24162 +#ifdef CONFIG_PAX_KERNEXEC
24163 + loadsegment(fs, __KERNEL_PERCPU);
24164 +#endif
24165 +
24166 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24167 + __set_fs(current_thread_info()->addr_limit);
24168 +#endif
24169 +
24170 #endif
24171
24172 vcpu->arch.regs_avail = ~((1 << VCPU_REGS_RIP) | (1 << VCPU_REGS_RSP)
24173 diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
24174 index e172132..c3d3e27 100644
24175 --- a/arch/x86/kvm/x86.c
24176 +++ b/arch/x86/kvm/x86.c
24177 @@ -1686,8 +1686,8 @@ static int xen_hvm_config(struct kvm_vcpu *vcpu, u64 data)
24178 {
24179 struct kvm *kvm = vcpu->kvm;
24180 int lm = is_long_mode(vcpu);
24181 - u8 *blob_addr = lm ? (u8 *)(long)kvm->arch.xen_hvm_config.blob_addr_64
24182 - : (u8 *)(long)kvm->arch.xen_hvm_config.blob_addr_32;
24183 + u8 __user *blob_addr = lm ? (u8 __user *)(long)kvm->arch.xen_hvm_config.blob_addr_64
24184 + : (u8 __user *)(long)kvm->arch.xen_hvm_config.blob_addr_32;
24185 u8 blob_size = lm ? kvm->arch.xen_hvm_config.blob_size_64
24186 : kvm->arch.xen_hvm_config.blob_size_32;
24187 u32 page_num = data & ~PAGE_MASK;
24188 @@ -2567,6 +2567,8 @@ long kvm_arch_dev_ioctl(struct file *filp,
24189 if (n < msr_list.nmsrs)
24190 goto out;
24191 r = -EFAULT;
24192 + if (num_msrs_to_save > ARRAY_SIZE(msrs_to_save))
24193 + goto out;
24194 if (copy_to_user(user_msr_list->indices, &msrs_to_save,
24195 num_msrs_to_save * sizeof(u32)))
24196 goto out;
24197 @@ -2696,7 +2698,7 @@ static int kvm_vcpu_ioctl_set_lapic(struct kvm_vcpu *vcpu,
24198 static int kvm_vcpu_ioctl_interrupt(struct kvm_vcpu *vcpu,
24199 struct kvm_interrupt *irq)
24200 {
24201 - if (irq->irq < 0 || irq->irq >= KVM_NR_INTERRUPTS)
24202 + if (irq->irq >= KVM_NR_INTERRUPTS)
24203 return -EINVAL;
24204 if (irqchip_in_kernel(vcpu->kvm))
24205 return -ENXIO;
24206 @@ -5247,7 +5249,7 @@ static struct notifier_block pvclock_gtod_notifier = {
24207 };
24208 #endif
24209
24210 -int kvm_arch_init(void *opaque)
24211 +int kvm_arch_init(const void *opaque)
24212 {
24213 int r;
24214 struct kvm_x86_ops *ops = (struct kvm_x86_ops *)opaque;
24215 diff --git a/arch/x86/lguest/boot.c b/arch/x86/lguest/boot.c
24216 index 7114c63..a1018fc 100644
24217 --- a/arch/x86/lguest/boot.c
24218 +++ b/arch/x86/lguest/boot.c
24219 @@ -1201,9 +1201,10 @@ static __init int early_put_chars(u32 vtermno, const char *buf, int count)
24220 * Rebooting also tells the Host we're finished, but the RESTART flag tells the
24221 * Launcher to reboot us.
24222 */
24223 -static void lguest_restart(char *reason)
24224 +static __noreturn void lguest_restart(char *reason)
24225 {
24226 hcall(LHCALL_SHUTDOWN, __pa(reason), LGUEST_SHUTDOWN_RESTART, 0, 0);
24227 + BUG();
24228 }
24229
24230 /*G:050
24231 diff --git a/arch/x86/lib/atomic64_386_32.S b/arch/x86/lib/atomic64_386_32.S
24232 index 00933d5..3a64af9 100644
24233 --- a/arch/x86/lib/atomic64_386_32.S
24234 +++ b/arch/x86/lib/atomic64_386_32.S
24235 @@ -48,6 +48,10 @@ BEGIN(read)
24236 movl (v), %eax
24237 movl 4(v), %edx
24238 RET_ENDP
24239 +BEGIN(read_unchecked)
24240 + movl (v), %eax
24241 + movl 4(v), %edx
24242 +RET_ENDP
24243 #undef v
24244
24245 #define v %esi
24246 @@ -55,6 +59,10 @@ BEGIN(set)
24247 movl %ebx, (v)
24248 movl %ecx, 4(v)
24249 RET_ENDP
24250 +BEGIN(set_unchecked)
24251 + movl %ebx, (v)
24252 + movl %ecx, 4(v)
24253 +RET_ENDP
24254 #undef v
24255
24256 #define v %esi
24257 @@ -70,6 +78,20 @@ RET_ENDP
24258 BEGIN(add)
24259 addl %eax, (v)
24260 adcl %edx, 4(v)
24261 +
24262 +#ifdef CONFIG_PAX_REFCOUNT
24263 + jno 0f
24264 + subl %eax, (v)
24265 + sbbl %edx, 4(v)
24266 + int $4
24267 +0:
24268 + _ASM_EXTABLE(0b, 0b)
24269 +#endif
24270 +
24271 +RET_ENDP
24272 +BEGIN(add_unchecked)
24273 + addl %eax, (v)
24274 + adcl %edx, 4(v)
24275 RET_ENDP
24276 #undef v
24277
24278 @@ -77,6 +99,24 @@ RET_ENDP
24279 BEGIN(add_return)
24280 addl (v), %eax
24281 adcl 4(v), %edx
24282 +
24283 +#ifdef CONFIG_PAX_REFCOUNT
24284 + into
24285 +1234:
24286 + _ASM_EXTABLE(1234b, 2f)
24287 +#endif
24288 +
24289 + movl %eax, (v)
24290 + movl %edx, 4(v)
24291 +
24292 +#ifdef CONFIG_PAX_REFCOUNT
24293 +2:
24294 +#endif
24295 +
24296 +RET_ENDP
24297 +BEGIN(add_return_unchecked)
24298 + addl (v), %eax
24299 + adcl 4(v), %edx
24300 movl %eax, (v)
24301 movl %edx, 4(v)
24302 RET_ENDP
24303 @@ -86,6 +126,20 @@ RET_ENDP
24304 BEGIN(sub)
24305 subl %eax, (v)
24306 sbbl %edx, 4(v)
24307 +
24308 +#ifdef CONFIG_PAX_REFCOUNT
24309 + jno 0f
24310 + addl %eax, (v)
24311 + adcl %edx, 4(v)
24312 + int $4
24313 +0:
24314 + _ASM_EXTABLE(0b, 0b)
24315 +#endif
24316 +
24317 +RET_ENDP
24318 +BEGIN(sub_unchecked)
24319 + subl %eax, (v)
24320 + sbbl %edx, 4(v)
24321 RET_ENDP
24322 #undef v
24323
24324 @@ -96,6 +150,27 @@ BEGIN(sub_return)
24325 sbbl $0, %edx
24326 addl (v), %eax
24327 adcl 4(v), %edx
24328 +
24329 +#ifdef CONFIG_PAX_REFCOUNT
24330 + into
24331 +1234:
24332 + _ASM_EXTABLE(1234b, 2f)
24333 +#endif
24334 +
24335 + movl %eax, (v)
24336 + movl %edx, 4(v)
24337 +
24338 +#ifdef CONFIG_PAX_REFCOUNT
24339 +2:
24340 +#endif
24341 +
24342 +RET_ENDP
24343 +BEGIN(sub_return_unchecked)
24344 + negl %edx
24345 + negl %eax
24346 + sbbl $0, %edx
24347 + addl (v), %eax
24348 + adcl 4(v), %edx
24349 movl %eax, (v)
24350 movl %edx, 4(v)
24351 RET_ENDP
24352 @@ -105,6 +180,20 @@ RET_ENDP
24353 BEGIN(inc)
24354 addl $1, (v)
24355 adcl $0, 4(v)
24356 +
24357 +#ifdef CONFIG_PAX_REFCOUNT
24358 + jno 0f
24359 + subl $1, (v)
24360 + sbbl $0, 4(v)
24361 + int $4
24362 +0:
24363 + _ASM_EXTABLE(0b, 0b)
24364 +#endif
24365 +
24366 +RET_ENDP
24367 +BEGIN(inc_unchecked)
24368 + addl $1, (v)
24369 + adcl $0, 4(v)
24370 RET_ENDP
24371 #undef v
24372
24373 @@ -114,6 +203,26 @@ BEGIN(inc_return)
24374 movl 4(v), %edx
24375 addl $1, %eax
24376 adcl $0, %edx
24377 +
24378 +#ifdef CONFIG_PAX_REFCOUNT
24379 + into
24380 +1234:
24381 + _ASM_EXTABLE(1234b, 2f)
24382 +#endif
24383 +
24384 + movl %eax, (v)
24385 + movl %edx, 4(v)
24386 +
24387 +#ifdef CONFIG_PAX_REFCOUNT
24388 +2:
24389 +#endif
24390 +
24391 +RET_ENDP
24392 +BEGIN(inc_return_unchecked)
24393 + movl (v), %eax
24394 + movl 4(v), %edx
24395 + addl $1, %eax
24396 + adcl $0, %edx
24397 movl %eax, (v)
24398 movl %edx, 4(v)
24399 RET_ENDP
24400 @@ -123,6 +232,20 @@ RET_ENDP
24401 BEGIN(dec)
24402 subl $1, (v)
24403 sbbl $0, 4(v)
24404 +
24405 +#ifdef CONFIG_PAX_REFCOUNT
24406 + jno 0f
24407 + addl $1, (v)
24408 + adcl $0, 4(v)
24409 + int $4
24410 +0:
24411 + _ASM_EXTABLE(0b, 0b)
24412 +#endif
24413 +
24414 +RET_ENDP
24415 +BEGIN(dec_unchecked)
24416 + subl $1, (v)
24417 + sbbl $0, 4(v)
24418 RET_ENDP
24419 #undef v
24420
24421 @@ -132,6 +255,26 @@ BEGIN(dec_return)
24422 movl 4(v), %edx
24423 subl $1, %eax
24424 sbbl $0, %edx
24425 +
24426 +#ifdef CONFIG_PAX_REFCOUNT
24427 + into
24428 +1234:
24429 + _ASM_EXTABLE(1234b, 2f)
24430 +#endif
24431 +
24432 + movl %eax, (v)
24433 + movl %edx, 4(v)
24434 +
24435 +#ifdef CONFIG_PAX_REFCOUNT
24436 +2:
24437 +#endif
24438 +
24439 +RET_ENDP
24440 +BEGIN(dec_return_unchecked)
24441 + movl (v), %eax
24442 + movl 4(v), %edx
24443 + subl $1, %eax
24444 + sbbl $0, %edx
24445 movl %eax, (v)
24446 movl %edx, 4(v)
24447 RET_ENDP
24448 @@ -143,6 +286,13 @@ BEGIN(add_unless)
24449 adcl %edx, %edi
24450 addl (v), %eax
24451 adcl 4(v), %edx
24452 +
24453 +#ifdef CONFIG_PAX_REFCOUNT
24454 + into
24455 +1234:
24456 + _ASM_EXTABLE(1234b, 2f)
24457 +#endif
24458 +
24459 cmpl %eax, %ecx
24460 je 3f
24461 1:
24462 @@ -168,6 +318,13 @@ BEGIN(inc_not_zero)
24463 1:
24464 addl $1, %eax
24465 adcl $0, %edx
24466 +
24467 +#ifdef CONFIG_PAX_REFCOUNT
24468 + into
24469 +1234:
24470 + _ASM_EXTABLE(1234b, 2f)
24471 +#endif
24472 +
24473 movl %eax, (v)
24474 movl %edx, 4(v)
24475 movl $1, %eax
24476 @@ -186,6 +343,13 @@ BEGIN(dec_if_positive)
24477 movl 4(v), %edx
24478 subl $1, %eax
24479 sbbl $0, %edx
24480 +
24481 +#ifdef CONFIG_PAX_REFCOUNT
24482 + into
24483 +1234:
24484 + _ASM_EXTABLE(1234b, 1f)
24485 +#endif
24486 +
24487 js 1f
24488 movl %eax, (v)
24489 movl %edx, 4(v)
24490 diff --git a/arch/x86/lib/atomic64_cx8_32.S b/arch/x86/lib/atomic64_cx8_32.S
24491 index f5cc9eb..51fa319 100644
24492 --- a/arch/x86/lib/atomic64_cx8_32.S
24493 +++ b/arch/x86/lib/atomic64_cx8_32.S
24494 @@ -35,10 +35,20 @@ ENTRY(atomic64_read_cx8)
24495 CFI_STARTPROC
24496
24497 read64 %ecx
24498 + pax_force_retaddr
24499 ret
24500 CFI_ENDPROC
24501 ENDPROC(atomic64_read_cx8)
24502
24503 +ENTRY(atomic64_read_unchecked_cx8)
24504 + CFI_STARTPROC
24505 +
24506 + read64 %ecx
24507 + pax_force_retaddr
24508 + ret
24509 + CFI_ENDPROC
24510 +ENDPROC(atomic64_read_unchecked_cx8)
24511 +
24512 ENTRY(atomic64_set_cx8)
24513 CFI_STARTPROC
24514
24515 @@ -48,10 +58,25 @@ ENTRY(atomic64_set_cx8)
24516 cmpxchg8b (%esi)
24517 jne 1b
24518
24519 + pax_force_retaddr
24520 ret
24521 CFI_ENDPROC
24522 ENDPROC(atomic64_set_cx8)
24523
24524 +ENTRY(atomic64_set_unchecked_cx8)
24525 + CFI_STARTPROC
24526 +
24527 +1:
24528 +/* we don't need LOCK_PREFIX since aligned 64-bit writes
24529 + * are atomic on 586 and newer */
24530 + cmpxchg8b (%esi)
24531 + jne 1b
24532 +
24533 + pax_force_retaddr
24534 + ret
24535 + CFI_ENDPROC
24536 +ENDPROC(atomic64_set_unchecked_cx8)
24537 +
24538 ENTRY(atomic64_xchg_cx8)
24539 CFI_STARTPROC
24540
24541 @@ -60,12 +85,13 @@ ENTRY(atomic64_xchg_cx8)
24542 cmpxchg8b (%esi)
24543 jne 1b
24544
24545 + pax_force_retaddr
24546 ret
24547 CFI_ENDPROC
24548 ENDPROC(atomic64_xchg_cx8)
24549
24550 -.macro addsub_return func ins insc
24551 -ENTRY(atomic64_\func\()_return_cx8)
24552 +.macro addsub_return func ins insc unchecked=""
24553 +ENTRY(atomic64_\func\()_return\unchecked\()_cx8)
24554 CFI_STARTPROC
24555 SAVE ebp
24556 SAVE ebx
24557 @@ -82,27 +108,44 @@ ENTRY(atomic64_\func\()_return_cx8)
24558 movl %edx, %ecx
24559 \ins\()l %esi, %ebx
24560 \insc\()l %edi, %ecx
24561 +
24562 +.ifb \unchecked
24563 +#ifdef CONFIG_PAX_REFCOUNT
24564 + into
24565 +2:
24566 + _ASM_EXTABLE(2b, 3f)
24567 +#endif
24568 +.endif
24569 +
24570 LOCK_PREFIX
24571 cmpxchg8b (%ebp)
24572 jne 1b
24573 -
24574 -10:
24575 movl %ebx, %eax
24576 movl %ecx, %edx
24577 +
24578 +.ifb \unchecked
24579 +#ifdef CONFIG_PAX_REFCOUNT
24580 +3:
24581 +#endif
24582 +.endif
24583 +
24584 RESTORE edi
24585 RESTORE esi
24586 RESTORE ebx
24587 RESTORE ebp
24588 + pax_force_retaddr
24589 ret
24590 CFI_ENDPROC
24591 -ENDPROC(atomic64_\func\()_return_cx8)
24592 +ENDPROC(atomic64_\func\()_return\unchecked\()_cx8)
24593 .endm
24594
24595 addsub_return add add adc
24596 addsub_return sub sub sbb
24597 +addsub_return add add adc _unchecked
24598 +addsub_return sub sub sbb _unchecked
24599
24600 -.macro incdec_return func ins insc
24601 -ENTRY(atomic64_\func\()_return_cx8)
24602 +.macro incdec_return func ins insc unchecked=""
24603 +ENTRY(atomic64_\func\()_return\unchecked\()_cx8)
24604 CFI_STARTPROC
24605 SAVE ebx
24606
24607 @@ -112,21 +155,39 @@ ENTRY(atomic64_\func\()_return_cx8)
24608 movl %edx, %ecx
24609 \ins\()l $1, %ebx
24610 \insc\()l $0, %ecx
24611 +
24612 +.ifb \unchecked
24613 +#ifdef CONFIG_PAX_REFCOUNT
24614 + into
24615 +2:
24616 + _ASM_EXTABLE(2b, 3f)
24617 +#endif
24618 +.endif
24619 +
24620 LOCK_PREFIX
24621 cmpxchg8b (%esi)
24622 jne 1b
24623
24624 -10:
24625 movl %ebx, %eax
24626 movl %ecx, %edx
24627 +
24628 +.ifb \unchecked
24629 +#ifdef CONFIG_PAX_REFCOUNT
24630 +3:
24631 +#endif
24632 +.endif
24633 +
24634 RESTORE ebx
24635 + pax_force_retaddr
24636 ret
24637 CFI_ENDPROC
24638 -ENDPROC(atomic64_\func\()_return_cx8)
24639 +ENDPROC(atomic64_\func\()_return\unchecked\()_cx8)
24640 .endm
24641
24642 incdec_return inc add adc
24643 incdec_return dec sub sbb
24644 +incdec_return inc add adc _unchecked
24645 +incdec_return dec sub sbb _unchecked
24646
24647 ENTRY(atomic64_dec_if_positive_cx8)
24648 CFI_STARTPROC
24649 @@ -138,6 +199,13 @@ ENTRY(atomic64_dec_if_positive_cx8)
24650 movl %edx, %ecx
24651 subl $1, %ebx
24652 sbb $0, %ecx
24653 +
24654 +#ifdef CONFIG_PAX_REFCOUNT
24655 + into
24656 +1234:
24657 + _ASM_EXTABLE(1234b, 2f)
24658 +#endif
24659 +
24660 js 2f
24661 LOCK_PREFIX
24662 cmpxchg8b (%esi)
24663 @@ -147,6 +215,7 @@ ENTRY(atomic64_dec_if_positive_cx8)
24664 movl %ebx, %eax
24665 movl %ecx, %edx
24666 RESTORE ebx
24667 + pax_force_retaddr
24668 ret
24669 CFI_ENDPROC
24670 ENDPROC(atomic64_dec_if_positive_cx8)
24671 @@ -171,6 +240,13 @@ ENTRY(atomic64_add_unless_cx8)
24672 movl %edx, %ecx
24673 addl %ebp, %ebx
24674 adcl %edi, %ecx
24675 +
24676 +#ifdef CONFIG_PAX_REFCOUNT
24677 + into
24678 +1234:
24679 + _ASM_EXTABLE(1234b, 3f)
24680 +#endif
24681 +
24682 LOCK_PREFIX
24683 cmpxchg8b (%esi)
24684 jne 1b
24685 @@ -181,6 +257,7 @@ ENTRY(atomic64_add_unless_cx8)
24686 CFI_ADJUST_CFA_OFFSET -8
24687 RESTORE ebx
24688 RESTORE ebp
24689 + pax_force_retaddr
24690 ret
24691 4:
24692 cmpl %edx, 4(%esp)
24693 @@ -203,6 +280,13 @@ ENTRY(atomic64_inc_not_zero_cx8)
24694 xorl %ecx, %ecx
24695 addl $1, %ebx
24696 adcl %edx, %ecx
24697 +
24698 +#ifdef CONFIG_PAX_REFCOUNT
24699 + into
24700 +1234:
24701 + _ASM_EXTABLE(1234b, 3f)
24702 +#endif
24703 +
24704 LOCK_PREFIX
24705 cmpxchg8b (%esi)
24706 jne 1b
24707 @@ -210,6 +294,7 @@ ENTRY(atomic64_inc_not_zero_cx8)
24708 movl $1, %eax
24709 3:
24710 RESTORE ebx
24711 + pax_force_retaddr
24712 ret
24713 CFI_ENDPROC
24714 ENDPROC(atomic64_inc_not_zero_cx8)
24715 diff --git a/arch/x86/lib/checksum_32.S b/arch/x86/lib/checksum_32.S
24716 index 2af5df3..62b1a5a 100644
24717 --- a/arch/x86/lib/checksum_32.S
24718 +++ b/arch/x86/lib/checksum_32.S
24719 @@ -29,7 +29,8 @@
24720 #include <asm/dwarf2.h>
24721 #include <asm/errno.h>
24722 #include <asm/asm.h>
24723 -
24724 +#include <asm/segment.h>
24725 +
24726 /*
24727 * computes a partial checksum, e.g. for TCP/UDP fragments
24728 */
24729 @@ -293,9 +294,24 @@ unsigned int csum_partial_copy_generic (const char *src, char *dst,
24730
24731 #define ARGBASE 16
24732 #define FP 12
24733 -
24734 -ENTRY(csum_partial_copy_generic)
24735 +
24736 +ENTRY(csum_partial_copy_generic_to_user)
24737 CFI_STARTPROC
24738 +
24739 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24740 + pushl_cfi %gs
24741 + popl_cfi %es
24742 + jmp csum_partial_copy_generic
24743 +#endif
24744 +
24745 +ENTRY(csum_partial_copy_generic_from_user)
24746 +
24747 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24748 + pushl_cfi %gs
24749 + popl_cfi %ds
24750 +#endif
24751 +
24752 +ENTRY(csum_partial_copy_generic)
24753 subl $4,%esp
24754 CFI_ADJUST_CFA_OFFSET 4
24755 pushl_cfi %edi
24756 @@ -317,7 +333,7 @@ ENTRY(csum_partial_copy_generic)
24757 jmp 4f
24758 SRC(1: movw (%esi), %bx )
24759 addl $2, %esi
24760 -DST( movw %bx, (%edi) )
24761 +DST( movw %bx, %es:(%edi) )
24762 addl $2, %edi
24763 addw %bx, %ax
24764 adcl $0, %eax
24765 @@ -329,30 +345,30 @@ DST( movw %bx, (%edi) )
24766 SRC(1: movl (%esi), %ebx )
24767 SRC( movl 4(%esi), %edx )
24768 adcl %ebx, %eax
24769 -DST( movl %ebx, (%edi) )
24770 +DST( movl %ebx, %es:(%edi) )
24771 adcl %edx, %eax
24772 -DST( movl %edx, 4(%edi) )
24773 +DST( movl %edx, %es:4(%edi) )
24774
24775 SRC( movl 8(%esi), %ebx )
24776 SRC( movl 12(%esi), %edx )
24777 adcl %ebx, %eax
24778 -DST( movl %ebx, 8(%edi) )
24779 +DST( movl %ebx, %es:8(%edi) )
24780 adcl %edx, %eax
24781 -DST( movl %edx, 12(%edi) )
24782 +DST( movl %edx, %es:12(%edi) )
24783
24784 SRC( movl 16(%esi), %ebx )
24785 SRC( movl 20(%esi), %edx )
24786 adcl %ebx, %eax
24787 -DST( movl %ebx, 16(%edi) )
24788 +DST( movl %ebx, %es:16(%edi) )
24789 adcl %edx, %eax
24790 -DST( movl %edx, 20(%edi) )
24791 +DST( movl %edx, %es:20(%edi) )
24792
24793 SRC( movl 24(%esi), %ebx )
24794 SRC( movl 28(%esi), %edx )
24795 adcl %ebx, %eax
24796 -DST( movl %ebx, 24(%edi) )
24797 +DST( movl %ebx, %es:24(%edi) )
24798 adcl %edx, %eax
24799 -DST( movl %edx, 28(%edi) )
24800 +DST( movl %edx, %es:28(%edi) )
24801
24802 lea 32(%esi), %esi
24803 lea 32(%edi), %edi
24804 @@ -366,7 +382,7 @@ DST( movl %edx, 28(%edi) )
24805 shrl $2, %edx # This clears CF
24806 SRC(3: movl (%esi), %ebx )
24807 adcl %ebx, %eax
24808 -DST( movl %ebx, (%edi) )
24809 +DST( movl %ebx, %es:(%edi) )
24810 lea 4(%esi), %esi
24811 lea 4(%edi), %edi
24812 dec %edx
24813 @@ -378,12 +394,12 @@ DST( movl %ebx, (%edi) )
24814 jb 5f
24815 SRC( movw (%esi), %cx )
24816 leal 2(%esi), %esi
24817 -DST( movw %cx, (%edi) )
24818 +DST( movw %cx, %es:(%edi) )
24819 leal 2(%edi), %edi
24820 je 6f
24821 shll $16,%ecx
24822 SRC(5: movb (%esi), %cl )
24823 -DST( movb %cl, (%edi) )
24824 +DST( movb %cl, %es:(%edi) )
24825 6: addl %ecx, %eax
24826 adcl $0, %eax
24827 7:
24828 @@ -394,7 +410,7 @@ DST( movb %cl, (%edi) )
24829
24830 6001:
24831 movl ARGBASE+20(%esp), %ebx # src_err_ptr
24832 - movl $-EFAULT, (%ebx)
24833 + movl $-EFAULT, %ss:(%ebx)
24834
24835 # zero the complete destination - computing the rest
24836 # is too much work
24837 @@ -407,11 +423,15 @@ DST( movb %cl, (%edi) )
24838
24839 6002:
24840 movl ARGBASE+24(%esp), %ebx # dst_err_ptr
24841 - movl $-EFAULT,(%ebx)
24842 + movl $-EFAULT,%ss:(%ebx)
24843 jmp 5000b
24844
24845 .previous
24846
24847 + pushl_cfi %ss
24848 + popl_cfi %ds
24849 + pushl_cfi %ss
24850 + popl_cfi %es
24851 popl_cfi %ebx
24852 CFI_RESTORE ebx
24853 popl_cfi %esi
24854 @@ -421,26 +441,43 @@ DST( movb %cl, (%edi) )
24855 popl_cfi %ecx # equivalent to addl $4,%esp
24856 ret
24857 CFI_ENDPROC
24858 -ENDPROC(csum_partial_copy_generic)
24859 +ENDPROC(csum_partial_copy_generic_to_user)
24860
24861 #else
24862
24863 /* Version for PentiumII/PPro */
24864
24865 #define ROUND1(x) \
24866 + nop; nop; nop; \
24867 SRC(movl x(%esi), %ebx ) ; \
24868 addl %ebx, %eax ; \
24869 - DST(movl %ebx, x(%edi) ) ;
24870 + DST(movl %ebx, %es:x(%edi)) ;
24871
24872 #define ROUND(x) \
24873 + nop; nop; nop; \
24874 SRC(movl x(%esi), %ebx ) ; \
24875 adcl %ebx, %eax ; \
24876 - DST(movl %ebx, x(%edi) ) ;
24877 + DST(movl %ebx, %es:x(%edi)) ;
24878
24879 #define ARGBASE 12
24880 -
24881 -ENTRY(csum_partial_copy_generic)
24882 +
24883 +ENTRY(csum_partial_copy_generic_to_user)
24884 CFI_STARTPROC
24885 +
24886 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24887 + pushl_cfi %gs
24888 + popl_cfi %es
24889 + jmp csum_partial_copy_generic
24890 +#endif
24891 +
24892 +ENTRY(csum_partial_copy_generic_from_user)
24893 +
24894 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24895 + pushl_cfi %gs
24896 + popl_cfi %ds
24897 +#endif
24898 +
24899 +ENTRY(csum_partial_copy_generic)
24900 pushl_cfi %ebx
24901 CFI_REL_OFFSET ebx, 0
24902 pushl_cfi %edi
24903 @@ -461,7 +498,7 @@ ENTRY(csum_partial_copy_generic)
24904 subl %ebx, %edi
24905 lea -1(%esi),%edx
24906 andl $-32,%edx
24907 - lea 3f(%ebx,%ebx), %ebx
24908 + lea 3f(%ebx,%ebx,2), %ebx
24909 testl %esi, %esi
24910 jmp *%ebx
24911 1: addl $64,%esi
24912 @@ -482,19 +519,19 @@ ENTRY(csum_partial_copy_generic)
24913 jb 5f
24914 SRC( movw (%esi), %dx )
24915 leal 2(%esi), %esi
24916 -DST( movw %dx, (%edi) )
24917 +DST( movw %dx, %es:(%edi) )
24918 leal 2(%edi), %edi
24919 je 6f
24920 shll $16,%edx
24921 5:
24922 SRC( movb (%esi), %dl )
24923 -DST( movb %dl, (%edi) )
24924 +DST( movb %dl, %es:(%edi) )
24925 6: addl %edx, %eax
24926 adcl $0, %eax
24927 7:
24928 .section .fixup, "ax"
24929 6001: movl ARGBASE+20(%esp), %ebx # src_err_ptr
24930 - movl $-EFAULT, (%ebx)
24931 + movl $-EFAULT, %ss:(%ebx)
24932 # zero the complete destination (computing the rest is too much work)
24933 movl ARGBASE+8(%esp),%edi # dst
24934 movl ARGBASE+12(%esp),%ecx # len
24935 @@ -502,10 +539,17 @@ DST( movb %dl, (%edi) )
24936 rep; stosb
24937 jmp 7b
24938 6002: movl ARGBASE+24(%esp), %ebx # dst_err_ptr
24939 - movl $-EFAULT, (%ebx)
24940 + movl $-EFAULT, %ss:(%ebx)
24941 jmp 7b
24942 .previous
24943
24944 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24945 + pushl_cfi %ss
24946 + popl_cfi %ds
24947 + pushl_cfi %ss
24948 + popl_cfi %es
24949 +#endif
24950 +
24951 popl_cfi %esi
24952 CFI_RESTORE esi
24953 popl_cfi %edi
24954 @@ -514,7 +558,7 @@ DST( movb %dl, (%edi) )
24955 CFI_RESTORE ebx
24956 ret
24957 CFI_ENDPROC
24958 -ENDPROC(csum_partial_copy_generic)
24959 +ENDPROC(csum_partial_copy_generic_to_user)
24960
24961 #undef ROUND
24962 #undef ROUND1
24963 diff --git a/arch/x86/lib/clear_page_64.S b/arch/x86/lib/clear_page_64.S
24964 index f2145cf..cea889d 100644
24965 --- a/arch/x86/lib/clear_page_64.S
24966 +++ b/arch/x86/lib/clear_page_64.S
24967 @@ -11,6 +11,7 @@ ENTRY(clear_page_c)
24968 movl $4096/8,%ecx
24969 xorl %eax,%eax
24970 rep stosq
24971 + pax_force_retaddr
24972 ret
24973 CFI_ENDPROC
24974 ENDPROC(clear_page_c)
24975 @@ -20,6 +21,7 @@ ENTRY(clear_page_c_e)
24976 movl $4096,%ecx
24977 xorl %eax,%eax
24978 rep stosb
24979 + pax_force_retaddr
24980 ret
24981 CFI_ENDPROC
24982 ENDPROC(clear_page_c_e)
24983 @@ -43,6 +45,7 @@ ENTRY(clear_page)
24984 leaq 64(%rdi),%rdi
24985 jnz .Lloop
24986 nop
24987 + pax_force_retaddr
24988 ret
24989 CFI_ENDPROC
24990 .Lclear_page_end:
24991 @@ -58,7 +61,7 @@ ENDPROC(clear_page)
24992
24993 #include <asm/cpufeature.h>
24994
24995 - .section .altinstr_replacement,"ax"
24996 + .section .altinstr_replacement,"a"
24997 1: .byte 0xeb /* jmp <disp8> */
24998 .byte (clear_page_c - clear_page) - (2f - 1b) /* offset */
24999 2: .byte 0xeb /* jmp <disp8> */
25000 diff --git a/arch/x86/lib/cmpxchg16b_emu.S b/arch/x86/lib/cmpxchg16b_emu.S
25001 index 1e572c5..2a162cd 100644
25002 --- a/arch/x86/lib/cmpxchg16b_emu.S
25003 +++ b/arch/x86/lib/cmpxchg16b_emu.S
25004 @@ -53,11 +53,13 @@ this_cpu_cmpxchg16b_emu:
25005
25006 popf
25007 mov $1, %al
25008 + pax_force_retaddr
25009 ret
25010
25011 not_same:
25012 popf
25013 xor %al,%al
25014 + pax_force_retaddr
25015 ret
25016
25017 CFI_ENDPROC
25018 diff --git a/arch/x86/lib/copy_page_64.S b/arch/x86/lib/copy_page_64.S
25019 index 176cca6..1166c50 100644
25020 --- a/arch/x86/lib/copy_page_64.S
25021 +++ b/arch/x86/lib/copy_page_64.S
25022 @@ -9,6 +9,7 @@ copy_page_rep:
25023 CFI_STARTPROC
25024 movl $4096/8, %ecx
25025 rep movsq
25026 + pax_force_retaddr
25027 ret
25028 CFI_ENDPROC
25029 ENDPROC(copy_page_rep)
25030 @@ -20,12 +21,14 @@ ENDPROC(copy_page_rep)
25031
25032 ENTRY(copy_page)
25033 CFI_STARTPROC
25034 - subq $2*8, %rsp
25035 - CFI_ADJUST_CFA_OFFSET 2*8
25036 + subq $3*8, %rsp
25037 + CFI_ADJUST_CFA_OFFSET 3*8
25038 movq %rbx, (%rsp)
25039 CFI_REL_OFFSET rbx, 0
25040 movq %r12, 1*8(%rsp)
25041 CFI_REL_OFFSET r12, 1*8
25042 + movq %r13, 2*8(%rsp)
25043 + CFI_REL_OFFSET r13, 2*8
25044
25045 movl $(4096/64)-5, %ecx
25046 .p2align 4
25047 @@ -36,7 +39,7 @@ ENTRY(copy_page)
25048 movq 0x8*2(%rsi), %rdx
25049 movq 0x8*3(%rsi), %r8
25050 movq 0x8*4(%rsi), %r9
25051 - movq 0x8*5(%rsi), %r10
25052 + movq 0x8*5(%rsi), %r13
25053 movq 0x8*6(%rsi), %r11
25054 movq 0x8*7(%rsi), %r12
25055
25056 @@ -47,7 +50,7 @@ ENTRY(copy_page)
25057 movq %rdx, 0x8*2(%rdi)
25058 movq %r8, 0x8*3(%rdi)
25059 movq %r9, 0x8*4(%rdi)
25060 - movq %r10, 0x8*5(%rdi)
25061 + movq %r13, 0x8*5(%rdi)
25062 movq %r11, 0x8*6(%rdi)
25063 movq %r12, 0x8*7(%rdi)
25064
25065 @@ -66,7 +69,7 @@ ENTRY(copy_page)
25066 movq 0x8*2(%rsi), %rdx
25067 movq 0x8*3(%rsi), %r8
25068 movq 0x8*4(%rsi), %r9
25069 - movq 0x8*5(%rsi), %r10
25070 + movq 0x8*5(%rsi), %r13
25071 movq 0x8*6(%rsi), %r11
25072 movq 0x8*7(%rsi), %r12
25073
25074 @@ -75,7 +78,7 @@ ENTRY(copy_page)
25075 movq %rdx, 0x8*2(%rdi)
25076 movq %r8, 0x8*3(%rdi)
25077 movq %r9, 0x8*4(%rdi)
25078 - movq %r10, 0x8*5(%rdi)
25079 + movq %r13, 0x8*5(%rdi)
25080 movq %r11, 0x8*6(%rdi)
25081 movq %r12, 0x8*7(%rdi)
25082
25083 @@ -87,8 +90,11 @@ ENTRY(copy_page)
25084 CFI_RESTORE rbx
25085 movq 1*8(%rsp), %r12
25086 CFI_RESTORE r12
25087 - addq $2*8, %rsp
25088 - CFI_ADJUST_CFA_OFFSET -2*8
25089 + movq 2*8(%rsp), %r13
25090 + CFI_RESTORE r13
25091 + addq $3*8, %rsp
25092 + CFI_ADJUST_CFA_OFFSET -3*8
25093 + pax_force_retaddr
25094 ret
25095 .Lcopy_page_end:
25096 CFI_ENDPROC
25097 @@ -99,7 +105,7 @@ ENDPROC(copy_page)
25098
25099 #include <asm/cpufeature.h>
25100
25101 - .section .altinstr_replacement,"ax"
25102 + .section .altinstr_replacement,"a"
25103 1: .byte 0xeb /* jmp <disp8> */
25104 .byte (copy_page_rep - copy_page) - (2f - 1b) /* offset */
25105 2:
25106 diff --git a/arch/x86/lib/copy_user_64.S b/arch/x86/lib/copy_user_64.S
25107 index a30ca15..d25fab6 100644
25108 --- a/arch/x86/lib/copy_user_64.S
25109 +++ b/arch/x86/lib/copy_user_64.S
25110 @@ -18,6 +18,7 @@
25111 #include <asm/alternative-asm.h>
25112 #include <asm/asm.h>
25113 #include <asm/smap.h>
25114 +#include <asm/pgtable.h>
25115
25116 /*
25117 * By placing feature2 after feature1 in altinstructions section, we logically
25118 @@ -31,7 +32,7 @@
25119 .byte 0xe9 /* 32bit jump */
25120 .long \orig-1f /* by default jump to orig */
25121 1:
25122 - .section .altinstr_replacement,"ax"
25123 + .section .altinstr_replacement,"a"
25124 2: .byte 0xe9 /* near jump with 32bit immediate */
25125 .long \alt1-1b /* offset */ /* or alternatively to alt1 */
25126 3: .byte 0xe9 /* near jump with 32bit immediate */
25127 @@ -70,47 +71,20 @@
25128 #endif
25129 .endm
25130
25131 -/* Standard copy_to_user with segment limit checking */
25132 -ENTRY(_copy_to_user)
25133 - CFI_STARTPROC
25134 - GET_THREAD_INFO(%rax)
25135 - movq %rdi,%rcx
25136 - addq %rdx,%rcx
25137 - jc bad_to_user
25138 - cmpq TI_addr_limit(%rax),%rcx
25139 - ja bad_to_user
25140 - ALTERNATIVE_JUMP X86_FEATURE_REP_GOOD,X86_FEATURE_ERMS, \
25141 - copy_user_generic_unrolled,copy_user_generic_string, \
25142 - copy_user_enhanced_fast_string
25143 - CFI_ENDPROC
25144 -ENDPROC(_copy_to_user)
25145 -
25146 -/* Standard copy_from_user with segment limit checking */
25147 -ENTRY(_copy_from_user)
25148 - CFI_STARTPROC
25149 - GET_THREAD_INFO(%rax)
25150 - movq %rsi,%rcx
25151 - addq %rdx,%rcx
25152 - jc bad_from_user
25153 - cmpq TI_addr_limit(%rax),%rcx
25154 - ja bad_from_user
25155 - ALTERNATIVE_JUMP X86_FEATURE_REP_GOOD,X86_FEATURE_ERMS, \
25156 - copy_user_generic_unrolled,copy_user_generic_string, \
25157 - copy_user_enhanced_fast_string
25158 - CFI_ENDPROC
25159 -ENDPROC(_copy_from_user)
25160 -
25161 .section .fixup,"ax"
25162 /* must zero dest */
25163 ENTRY(bad_from_user)
25164 bad_from_user:
25165 CFI_STARTPROC
25166 + testl %edx,%edx
25167 + js bad_to_user
25168 movl %edx,%ecx
25169 xorl %eax,%eax
25170 rep
25171 stosb
25172 bad_to_user:
25173 movl %edx,%eax
25174 + pax_force_retaddr
25175 ret
25176 CFI_ENDPROC
25177 ENDPROC(bad_from_user)
25178 @@ -141,19 +115,19 @@ ENTRY(copy_user_generic_unrolled)
25179 jz 17f
25180 1: movq (%rsi),%r8
25181 2: movq 1*8(%rsi),%r9
25182 -3: movq 2*8(%rsi),%r10
25183 +3: movq 2*8(%rsi),%rax
25184 4: movq 3*8(%rsi),%r11
25185 5: movq %r8,(%rdi)
25186 6: movq %r9,1*8(%rdi)
25187 -7: movq %r10,2*8(%rdi)
25188 +7: movq %rax,2*8(%rdi)
25189 8: movq %r11,3*8(%rdi)
25190 9: movq 4*8(%rsi),%r8
25191 10: movq 5*8(%rsi),%r9
25192 -11: movq 6*8(%rsi),%r10
25193 +11: movq 6*8(%rsi),%rax
25194 12: movq 7*8(%rsi),%r11
25195 13: movq %r8,4*8(%rdi)
25196 14: movq %r9,5*8(%rdi)
25197 -15: movq %r10,6*8(%rdi)
25198 +15: movq %rax,6*8(%rdi)
25199 16: movq %r11,7*8(%rdi)
25200 leaq 64(%rsi),%rsi
25201 leaq 64(%rdi),%rdi
25202 @@ -180,6 +154,7 @@ ENTRY(copy_user_generic_unrolled)
25203 jnz 21b
25204 23: xor %eax,%eax
25205 ASM_CLAC
25206 + pax_force_retaddr
25207 ret
25208
25209 .section .fixup,"ax"
25210 @@ -251,6 +226,7 @@ ENTRY(copy_user_generic_string)
25211 movsb
25212 4: xorl %eax,%eax
25213 ASM_CLAC
25214 + pax_force_retaddr
25215 ret
25216
25217 .section .fixup,"ax"
25218 @@ -286,6 +262,7 @@ ENTRY(copy_user_enhanced_fast_string)
25219 movsb
25220 2: xorl %eax,%eax
25221 ASM_CLAC
25222 + pax_force_retaddr
25223 ret
25224
25225 .section .fixup,"ax"
25226 diff --git a/arch/x86/lib/copy_user_nocache_64.S b/arch/x86/lib/copy_user_nocache_64.S
25227 index 6a4f43c..f08b4a2 100644
25228 --- a/arch/x86/lib/copy_user_nocache_64.S
25229 +++ b/arch/x86/lib/copy_user_nocache_64.S
25230 @@ -8,6 +8,7 @@
25231
25232 #include <linux/linkage.h>
25233 #include <asm/dwarf2.h>
25234 +#include <asm/alternative-asm.h>
25235
25236 #define FIX_ALIGNMENT 1
25237
25238 @@ -16,6 +17,7 @@
25239 #include <asm/thread_info.h>
25240 #include <asm/asm.h>
25241 #include <asm/smap.h>
25242 +#include <asm/pgtable.h>
25243
25244 .macro ALIGN_DESTINATION
25245 #ifdef FIX_ALIGNMENT
25246 @@ -49,6 +51,15 @@
25247 */
25248 ENTRY(__copy_user_nocache)
25249 CFI_STARTPROC
25250 +
25251 +#ifdef CONFIG_PAX_MEMORY_UDEREF
25252 + mov pax_user_shadow_base,%rcx
25253 + cmp %rcx,%rsi
25254 + jae 1f
25255 + add %rcx,%rsi
25256 +1:
25257 +#endif
25258 +
25259 ASM_STAC
25260 cmpl $8,%edx
25261 jb 20f /* less then 8 bytes, go to byte copy loop */
25262 @@ -59,19 +70,19 @@ ENTRY(__copy_user_nocache)
25263 jz 17f
25264 1: movq (%rsi),%r8
25265 2: movq 1*8(%rsi),%r9
25266 -3: movq 2*8(%rsi),%r10
25267 +3: movq 2*8(%rsi),%rax
25268 4: movq 3*8(%rsi),%r11
25269 5: movnti %r8,(%rdi)
25270 6: movnti %r9,1*8(%rdi)
25271 -7: movnti %r10,2*8(%rdi)
25272 +7: movnti %rax,2*8(%rdi)
25273 8: movnti %r11,3*8(%rdi)
25274 9: movq 4*8(%rsi),%r8
25275 10: movq 5*8(%rsi),%r9
25276 -11: movq 6*8(%rsi),%r10
25277 +11: movq 6*8(%rsi),%rax
25278 12: movq 7*8(%rsi),%r11
25279 13: movnti %r8,4*8(%rdi)
25280 14: movnti %r9,5*8(%rdi)
25281 -15: movnti %r10,6*8(%rdi)
25282 +15: movnti %rax,6*8(%rdi)
25283 16: movnti %r11,7*8(%rdi)
25284 leaq 64(%rsi),%rsi
25285 leaq 64(%rdi),%rdi
25286 @@ -99,6 +110,7 @@ ENTRY(__copy_user_nocache)
25287 23: xorl %eax,%eax
25288 ASM_CLAC
25289 sfence
25290 + pax_force_retaddr
25291 ret
25292
25293 .section .fixup,"ax"
25294 diff --git a/arch/x86/lib/csum-copy_64.S b/arch/x86/lib/csum-copy_64.S
25295 index 2419d5f..953ee51 100644
25296 --- a/arch/x86/lib/csum-copy_64.S
25297 +++ b/arch/x86/lib/csum-copy_64.S
25298 @@ -9,6 +9,7 @@
25299 #include <asm/dwarf2.h>
25300 #include <asm/errno.h>
25301 #include <asm/asm.h>
25302 +#include <asm/alternative-asm.h>
25303
25304 /*
25305 * Checksum copy with exception handling.
25306 @@ -220,6 +221,7 @@ ENTRY(csum_partial_copy_generic)
25307 CFI_RESTORE rbp
25308 addq $7*8, %rsp
25309 CFI_ADJUST_CFA_OFFSET -7*8
25310 + pax_force_retaddr 0, 1
25311 ret
25312 CFI_RESTORE_STATE
25313
25314 diff --git a/arch/x86/lib/csum-wrappers_64.c b/arch/x86/lib/csum-wrappers_64.c
25315 index 25b7ae8..169fafc 100644
25316 --- a/arch/x86/lib/csum-wrappers_64.c
25317 +++ b/arch/x86/lib/csum-wrappers_64.c
25318 @@ -52,7 +52,7 @@ csum_partial_copy_from_user(const void __user *src, void *dst,
25319 len -= 2;
25320 }
25321 }
25322 - isum = csum_partial_copy_generic((__force const void *)src,
25323 + isum = csum_partial_copy_generic((const void __force_kernel *)____m(src),
25324 dst, len, isum, errp, NULL);
25325 if (unlikely(*errp))
25326 goto out_err;
25327 @@ -105,7 +105,7 @@ csum_partial_copy_to_user(const void *src, void __user *dst,
25328 }
25329
25330 *errp = 0;
25331 - return csum_partial_copy_generic(src, (void __force *)dst,
25332 + return csum_partial_copy_generic(src, (void __force_kernel *)____m(dst),
25333 len, isum, NULL, errp);
25334 }
25335 EXPORT_SYMBOL(csum_partial_copy_to_user);
25336 diff --git a/arch/x86/lib/getuser.S b/arch/x86/lib/getuser.S
25337 index a451235..79fb5cf 100644
25338 --- a/arch/x86/lib/getuser.S
25339 +++ b/arch/x86/lib/getuser.S
25340 @@ -33,17 +33,40 @@
25341 #include <asm/thread_info.h>
25342 #include <asm/asm.h>
25343 #include <asm/smap.h>
25344 +#include <asm/segment.h>
25345 +#include <asm/pgtable.h>
25346 +#include <asm/alternative-asm.h>
25347 +
25348 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
25349 +#define __copyuser_seg gs;
25350 +#else
25351 +#define __copyuser_seg
25352 +#endif
25353
25354 .text
25355 ENTRY(__get_user_1)
25356 CFI_STARTPROC
25357 +
25358 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
25359 GET_THREAD_INFO(%_ASM_DX)
25360 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
25361 jae bad_get_user
25362 ASM_STAC
25363 -1: movzbl (%_ASM_AX),%edx
25364 +
25365 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
25366 + mov pax_user_shadow_base,%_ASM_DX
25367 + cmp %_ASM_DX,%_ASM_AX
25368 + jae 1234f
25369 + add %_ASM_DX,%_ASM_AX
25370 +1234:
25371 +#endif
25372 +
25373 +#endif
25374 +
25375 +1: __copyuser_seg movzbl (%_ASM_AX),%edx
25376 xor %eax,%eax
25377 ASM_CLAC
25378 + pax_force_retaddr
25379 ret
25380 CFI_ENDPROC
25381 ENDPROC(__get_user_1)
25382 @@ -51,14 +74,28 @@ ENDPROC(__get_user_1)
25383 ENTRY(__get_user_2)
25384 CFI_STARTPROC
25385 add $1,%_ASM_AX
25386 +
25387 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
25388 jc bad_get_user
25389 GET_THREAD_INFO(%_ASM_DX)
25390 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
25391 jae bad_get_user
25392 ASM_STAC
25393 -2: movzwl -1(%_ASM_AX),%edx
25394 +
25395 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
25396 + mov pax_user_shadow_base,%_ASM_DX
25397 + cmp %_ASM_DX,%_ASM_AX
25398 + jae 1234f
25399 + add %_ASM_DX,%_ASM_AX
25400 +1234:
25401 +#endif
25402 +
25403 +#endif
25404 +
25405 +2: __copyuser_seg movzwl -1(%_ASM_AX),%edx
25406 xor %eax,%eax
25407 ASM_CLAC
25408 + pax_force_retaddr
25409 ret
25410 CFI_ENDPROC
25411 ENDPROC(__get_user_2)
25412 @@ -66,14 +103,28 @@ ENDPROC(__get_user_2)
25413 ENTRY(__get_user_4)
25414 CFI_STARTPROC
25415 add $3,%_ASM_AX
25416 +
25417 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
25418 jc bad_get_user
25419 GET_THREAD_INFO(%_ASM_DX)
25420 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
25421 jae bad_get_user
25422 ASM_STAC
25423 -3: movl -3(%_ASM_AX),%edx
25424 +
25425 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
25426 + mov pax_user_shadow_base,%_ASM_DX
25427 + cmp %_ASM_DX,%_ASM_AX
25428 + jae 1234f
25429 + add %_ASM_DX,%_ASM_AX
25430 +1234:
25431 +#endif
25432 +
25433 +#endif
25434 +
25435 +3: __copyuser_seg movl -3(%_ASM_AX),%edx
25436 xor %eax,%eax
25437 ASM_CLAC
25438 + pax_force_retaddr
25439 ret
25440 CFI_ENDPROC
25441 ENDPROC(__get_user_4)
25442 @@ -86,10 +137,20 @@ ENTRY(__get_user_8)
25443 GET_THREAD_INFO(%_ASM_DX)
25444 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
25445 jae bad_get_user
25446 +
25447 +#ifdef CONFIG_PAX_MEMORY_UDEREF
25448 + mov pax_user_shadow_base,%_ASM_DX
25449 + cmp %_ASM_DX,%_ASM_AX
25450 + jae 1234f
25451 + add %_ASM_DX,%_ASM_AX
25452 +1234:
25453 +#endif
25454 +
25455 ASM_STAC
25456 4: movq -7(%_ASM_AX),%rdx
25457 xor %eax,%eax
25458 ASM_CLAC
25459 + pax_force_retaddr
25460 ret
25461 #else
25462 add $7,%_ASM_AX
25463 @@ -102,6 +163,7 @@ ENTRY(__get_user_8)
25464 5: movl -3(%_ASM_AX),%ecx
25465 xor %eax,%eax
25466 ASM_CLAC
25467 + pax_force_retaddr
25468 ret
25469 #endif
25470 CFI_ENDPROC
25471 @@ -113,6 +175,7 @@ bad_get_user:
25472 xor %edx,%edx
25473 mov $(-EFAULT),%_ASM_AX
25474 ASM_CLAC
25475 + pax_force_retaddr
25476 ret
25477 CFI_ENDPROC
25478 END(bad_get_user)
25479 @@ -124,6 +187,7 @@ bad_get_user_8:
25480 xor %ecx,%ecx
25481 mov $(-EFAULT),%_ASM_AX
25482 ASM_CLAC
25483 + pax_force_retaddr
25484 ret
25485 CFI_ENDPROC
25486 END(bad_get_user_8)
25487 diff --git a/arch/x86/lib/insn.c b/arch/x86/lib/insn.c
25488 index 54fcffe..7be149e 100644
25489 --- a/arch/x86/lib/insn.c
25490 +++ b/arch/x86/lib/insn.c
25491 @@ -20,8 +20,10 @@
25492
25493 #ifdef __KERNEL__
25494 #include <linux/string.h>
25495 +#include <asm/pgtable_types.h>
25496 #else
25497 #include <string.h>
25498 +#define ktla_ktva(addr) addr
25499 #endif
25500 #include <asm/inat.h>
25501 #include <asm/insn.h>
25502 @@ -53,8 +55,8 @@
25503 void insn_init(struct insn *insn, const void *kaddr, int x86_64)
25504 {
25505 memset(insn, 0, sizeof(*insn));
25506 - insn->kaddr = kaddr;
25507 - insn->next_byte = kaddr;
25508 + insn->kaddr = ktla_ktva(kaddr);
25509 + insn->next_byte = ktla_ktva(kaddr);
25510 insn->x86_64 = x86_64 ? 1 : 0;
25511 insn->opnd_bytes = 4;
25512 if (x86_64)
25513 diff --git a/arch/x86/lib/iomap_copy_64.S b/arch/x86/lib/iomap_copy_64.S
25514 index 05a95e7..326f2fa 100644
25515 --- a/arch/x86/lib/iomap_copy_64.S
25516 +++ b/arch/x86/lib/iomap_copy_64.S
25517 @@ -17,6 +17,7 @@
25518
25519 #include <linux/linkage.h>
25520 #include <asm/dwarf2.h>
25521 +#include <asm/alternative-asm.h>
25522
25523 /*
25524 * override generic version in lib/iomap_copy.c
25525 @@ -25,6 +26,7 @@ ENTRY(__iowrite32_copy)
25526 CFI_STARTPROC
25527 movl %edx,%ecx
25528 rep movsd
25529 + pax_force_retaddr
25530 ret
25531 CFI_ENDPROC
25532 ENDPROC(__iowrite32_copy)
25533 diff --git a/arch/x86/lib/memcpy_64.S b/arch/x86/lib/memcpy_64.S
25534 index 1c273be..da9cc0e 100644
25535 --- a/arch/x86/lib/memcpy_64.S
25536 +++ b/arch/x86/lib/memcpy_64.S
25537 @@ -33,6 +33,7 @@
25538 rep movsq
25539 movl %edx, %ecx
25540 rep movsb
25541 + pax_force_retaddr
25542 ret
25543 .Lmemcpy_e:
25544 .previous
25545 @@ -49,6 +50,7 @@
25546 movq %rdi, %rax
25547 movq %rdx, %rcx
25548 rep movsb
25549 + pax_force_retaddr
25550 ret
25551 .Lmemcpy_e_e:
25552 .previous
25553 @@ -76,13 +78,13 @@ ENTRY(memcpy)
25554 */
25555 movq 0*8(%rsi), %r8
25556 movq 1*8(%rsi), %r9
25557 - movq 2*8(%rsi), %r10
25558 + movq 2*8(%rsi), %rcx
25559 movq 3*8(%rsi), %r11
25560 leaq 4*8(%rsi), %rsi
25561
25562 movq %r8, 0*8(%rdi)
25563 movq %r9, 1*8(%rdi)
25564 - movq %r10, 2*8(%rdi)
25565 + movq %rcx, 2*8(%rdi)
25566 movq %r11, 3*8(%rdi)
25567 leaq 4*8(%rdi), %rdi
25568 jae .Lcopy_forward_loop
25569 @@ -105,12 +107,12 @@ ENTRY(memcpy)
25570 subq $0x20, %rdx
25571 movq -1*8(%rsi), %r8
25572 movq -2*8(%rsi), %r9
25573 - movq -3*8(%rsi), %r10
25574 + movq -3*8(%rsi), %rcx
25575 movq -4*8(%rsi), %r11
25576 leaq -4*8(%rsi), %rsi
25577 movq %r8, -1*8(%rdi)
25578 movq %r9, -2*8(%rdi)
25579 - movq %r10, -3*8(%rdi)
25580 + movq %rcx, -3*8(%rdi)
25581 movq %r11, -4*8(%rdi)
25582 leaq -4*8(%rdi), %rdi
25583 jae .Lcopy_backward_loop
25584 @@ -130,12 +132,13 @@ ENTRY(memcpy)
25585 */
25586 movq 0*8(%rsi), %r8
25587 movq 1*8(%rsi), %r9
25588 - movq -2*8(%rsi, %rdx), %r10
25589 + movq -2*8(%rsi, %rdx), %rcx
25590 movq -1*8(%rsi, %rdx), %r11
25591 movq %r8, 0*8(%rdi)
25592 movq %r9, 1*8(%rdi)
25593 - movq %r10, -2*8(%rdi, %rdx)
25594 + movq %rcx, -2*8(%rdi, %rdx)
25595 movq %r11, -1*8(%rdi, %rdx)
25596 + pax_force_retaddr
25597 retq
25598 .p2align 4
25599 .Lless_16bytes:
25600 @@ -148,6 +151,7 @@ ENTRY(memcpy)
25601 movq -1*8(%rsi, %rdx), %r9
25602 movq %r8, 0*8(%rdi)
25603 movq %r9, -1*8(%rdi, %rdx)
25604 + pax_force_retaddr
25605 retq
25606 .p2align 4
25607 .Lless_8bytes:
25608 @@ -161,6 +165,7 @@ ENTRY(memcpy)
25609 movl -4(%rsi, %rdx), %r8d
25610 movl %ecx, (%rdi)
25611 movl %r8d, -4(%rdi, %rdx)
25612 + pax_force_retaddr
25613 retq
25614 .p2align 4
25615 .Lless_3bytes:
25616 @@ -179,6 +184,7 @@ ENTRY(memcpy)
25617 movb %cl, (%rdi)
25618
25619 .Lend:
25620 + pax_force_retaddr
25621 retq
25622 CFI_ENDPROC
25623 ENDPROC(memcpy)
25624 diff --git a/arch/x86/lib/memmove_64.S b/arch/x86/lib/memmove_64.S
25625 index ee16461..c39c199 100644
25626 --- a/arch/x86/lib/memmove_64.S
25627 +++ b/arch/x86/lib/memmove_64.S
25628 @@ -61,13 +61,13 @@ ENTRY(memmove)
25629 5:
25630 sub $0x20, %rdx
25631 movq 0*8(%rsi), %r11
25632 - movq 1*8(%rsi), %r10
25633 + movq 1*8(%rsi), %rcx
25634 movq 2*8(%rsi), %r9
25635 movq 3*8(%rsi), %r8
25636 leaq 4*8(%rsi), %rsi
25637
25638 movq %r11, 0*8(%rdi)
25639 - movq %r10, 1*8(%rdi)
25640 + movq %rcx, 1*8(%rdi)
25641 movq %r9, 2*8(%rdi)
25642 movq %r8, 3*8(%rdi)
25643 leaq 4*8(%rdi), %rdi
25644 @@ -81,10 +81,10 @@ ENTRY(memmove)
25645 4:
25646 movq %rdx, %rcx
25647 movq -8(%rsi, %rdx), %r11
25648 - lea -8(%rdi, %rdx), %r10
25649 + lea -8(%rdi, %rdx), %r9
25650 shrq $3, %rcx
25651 rep movsq
25652 - movq %r11, (%r10)
25653 + movq %r11, (%r9)
25654 jmp 13f
25655 .Lmemmove_end_forward:
25656
25657 @@ -95,14 +95,14 @@ ENTRY(memmove)
25658 7:
25659 movq %rdx, %rcx
25660 movq (%rsi), %r11
25661 - movq %rdi, %r10
25662 + movq %rdi, %r9
25663 leaq -8(%rsi, %rdx), %rsi
25664 leaq -8(%rdi, %rdx), %rdi
25665 shrq $3, %rcx
25666 std
25667 rep movsq
25668 cld
25669 - movq %r11, (%r10)
25670 + movq %r11, (%r9)
25671 jmp 13f
25672
25673 /*
25674 @@ -127,13 +127,13 @@ ENTRY(memmove)
25675 8:
25676 subq $0x20, %rdx
25677 movq -1*8(%rsi), %r11
25678 - movq -2*8(%rsi), %r10
25679 + movq -2*8(%rsi), %rcx
25680 movq -3*8(%rsi), %r9
25681 movq -4*8(%rsi), %r8
25682 leaq -4*8(%rsi), %rsi
25683
25684 movq %r11, -1*8(%rdi)
25685 - movq %r10, -2*8(%rdi)
25686 + movq %rcx, -2*8(%rdi)
25687 movq %r9, -3*8(%rdi)
25688 movq %r8, -4*8(%rdi)
25689 leaq -4*8(%rdi), %rdi
25690 @@ -151,11 +151,11 @@ ENTRY(memmove)
25691 * Move data from 16 bytes to 31 bytes.
25692 */
25693 movq 0*8(%rsi), %r11
25694 - movq 1*8(%rsi), %r10
25695 + movq 1*8(%rsi), %rcx
25696 movq -2*8(%rsi, %rdx), %r9
25697 movq -1*8(%rsi, %rdx), %r8
25698 movq %r11, 0*8(%rdi)
25699 - movq %r10, 1*8(%rdi)
25700 + movq %rcx, 1*8(%rdi)
25701 movq %r9, -2*8(%rdi, %rdx)
25702 movq %r8, -1*8(%rdi, %rdx)
25703 jmp 13f
25704 @@ -167,9 +167,9 @@ ENTRY(memmove)
25705 * Move data from 8 bytes to 15 bytes.
25706 */
25707 movq 0*8(%rsi), %r11
25708 - movq -1*8(%rsi, %rdx), %r10
25709 + movq -1*8(%rsi, %rdx), %r9
25710 movq %r11, 0*8(%rdi)
25711 - movq %r10, -1*8(%rdi, %rdx)
25712 + movq %r9, -1*8(%rdi, %rdx)
25713 jmp 13f
25714 10:
25715 cmpq $4, %rdx
25716 @@ -178,9 +178,9 @@ ENTRY(memmove)
25717 * Move data from 4 bytes to 7 bytes.
25718 */
25719 movl (%rsi), %r11d
25720 - movl -4(%rsi, %rdx), %r10d
25721 + movl -4(%rsi, %rdx), %r9d
25722 movl %r11d, (%rdi)
25723 - movl %r10d, -4(%rdi, %rdx)
25724 + movl %r9d, -4(%rdi, %rdx)
25725 jmp 13f
25726 11:
25727 cmp $2, %rdx
25728 @@ -189,9 +189,9 @@ ENTRY(memmove)
25729 * Move data from 2 bytes to 3 bytes.
25730 */
25731 movw (%rsi), %r11w
25732 - movw -2(%rsi, %rdx), %r10w
25733 + movw -2(%rsi, %rdx), %r9w
25734 movw %r11w, (%rdi)
25735 - movw %r10w, -2(%rdi, %rdx)
25736 + movw %r9w, -2(%rdi, %rdx)
25737 jmp 13f
25738 12:
25739 cmp $1, %rdx
25740 @@ -202,6 +202,7 @@ ENTRY(memmove)
25741 movb (%rsi), %r11b
25742 movb %r11b, (%rdi)
25743 13:
25744 + pax_force_retaddr
25745 retq
25746 CFI_ENDPROC
25747
25748 @@ -210,6 +211,7 @@ ENTRY(memmove)
25749 /* Forward moving data. */
25750 movq %rdx, %rcx
25751 rep movsb
25752 + pax_force_retaddr
25753 retq
25754 .Lmemmove_end_forward_efs:
25755 .previous
25756 diff --git a/arch/x86/lib/memset_64.S b/arch/x86/lib/memset_64.S
25757 index 2dcb380..963660a 100644
25758 --- a/arch/x86/lib/memset_64.S
25759 +++ b/arch/x86/lib/memset_64.S
25760 @@ -30,6 +30,7 @@
25761 movl %edx,%ecx
25762 rep stosb
25763 movq %r9,%rax
25764 + pax_force_retaddr
25765 ret
25766 .Lmemset_e:
25767 .previous
25768 @@ -52,6 +53,7 @@
25769 movq %rdx,%rcx
25770 rep stosb
25771 movq %r9,%rax
25772 + pax_force_retaddr
25773 ret
25774 .Lmemset_e_e:
25775 .previous
25776 @@ -59,7 +61,7 @@
25777 ENTRY(memset)
25778 ENTRY(__memset)
25779 CFI_STARTPROC
25780 - movq %rdi,%r10
25781 + movq %rdi,%r11
25782
25783 /* expand byte value */
25784 movzbl %sil,%ecx
25785 @@ -117,7 +119,8 @@ ENTRY(__memset)
25786 jnz .Lloop_1
25787
25788 .Lende:
25789 - movq %r10,%rax
25790 + movq %r11,%rax
25791 + pax_force_retaddr
25792 ret
25793
25794 CFI_RESTORE_STATE
25795 diff --git a/arch/x86/lib/mmx_32.c b/arch/x86/lib/mmx_32.c
25796 index c9f2d9b..e7fd2c0 100644
25797 --- a/arch/x86/lib/mmx_32.c
25798 +++ b/arch/x86/lib/mmx_32.c
25799 @@ -29,6 +29,7 @@ void *_mmx_memcpy(void *to, const void *from, size_t len)
25800 {
25801 void *p;
25802 int i;
25803 + unsigned long cr0;
25804
25805 if (unlikely(in_interrupt()))
25806 return __memcpy(to, from, len);
25807 @@ -39,44 +40,72 @@ void *_mmx_memcpy(void *to, const void *from, size_t len)
25808 kernel_fpu_begin();
25809
25810 __asm__ __volatile__ (
25811 - "1: prefetch (%0)\n" /* This set is 28 bytes */
25812 - " prefetch 64(%0)\n"
25813 - " prefetch 128(%0)\n"
25814 - " prefetch 192(%0)\n"
25815 - " prefetch 256(%0)\n"
25816 + "1: prefetch (%1)\n" /* This set is 28 bytes */
25817 + " prefetch 64(%1)\n"
25818 + " prefetch 128(%1)\n"
25819 + " prefetch 192(%1)\n"
25820 + " prefetch 256(%1)\n"
25821 "2: \n"
25822 ".section .fixup, \"ax\"\n"
25823 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
25824 + "3: \n"
25825 +
25826 +#ifdef CONFIG_PAX_KERNEXEC
25827 + " movl %%cr0, %0\n"
25828 + " movl %0, %%eax\n"
25829 + " andl $0xFFFEFFFF, %%eax\n"
25830 + " movl %%eax, %%cr0\n"
25831 +#endif
25832 +
25833 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
25834 +
25835 +#ifdef CONFIG_PAX_KERNEXEC
25836 + " movl %0, %%cr0\n"
25837 +#endif
25838 +
25839 " jmp 2b\n"
25840 ".previous\n"
25841 _ASM_EXTABLE(1b, 3b)
25842 - : : "r" (from));
25843 + : "=&r" (cr0) : "r" (from) : "ax");
25844
25845 for ( ; i > 5; i--) {
25846 __asm__ __volatile__ (
25847 - "1: prefetch 320(%0)\n"
25848 - "2: movq (%0), %%mm0\n"
25849 - " movq 8(%0), %%mm1\n"
25850 - " movq 16(%0), %%mm2\n"
25851 - " movq 24(%0), %%mm3\n"
25852 - " movq %%mm0, (%1)\n"
25853 - " movq %%mm1, 8(%1)\n"
25854 - " movq %%mm2, 16(%1)\n"
25855 - " movq %%mm3, 24(%1)\n"
25856 - " movq 32(%0), %%mm0\n"
25857 - " movq 40(%0), %%mm1\n"
25858 - " movq 48(%0), %%mm2\n"
25859 - " movq 56(%0), %%mm3\n"
25860 - " movq %%mm0, 32(%1)\n"
25861 - " movq %%mm1, 40(%1)\n"
25862 - " movq %%mm2, 48(%1)\n"
25863 - " movq %%mm3, 56(%1)\n"
25864 + "1: prefetch 320(%1)\n"
25865 + "2: movq (%1), %%mm0\n"
25866 + " movq 8(%1), %%mm1\n"
25867 + " movq 16(%1), %%mm2\n"
25868 + " movq 24(%1), %%mm3\n"
25869 + " movq %%mm0, (%2)\n"
25870 + " movq %%mm1, 8(%2)\n"
25871 + " movq %%mm2, 16(%2)\n"
25872 + " movq %%mm3, 24(%2)\n"
25873 + " movq 32(%1), %%mm0\n"
25874 + " movq 40(%1), %%mm1\n"
25875 + " movq 48(%1), %%mm2\n"
25876 + " movq 56(%1), %%mm3\n"
25877 + " movq %%mm0, 32(%2)\n"
25878 + " movq %%mm1, 40(%2)\n"
25879 + " movq %%mm2, 48(%2)\n"
25880 + " movq %%mm3, 56(%2)\n"
25881 ".section .fixup, \"ax\"\n"
25882 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
25883 + "3:\n"
25884 +
25885 +#ifdef CONFIG_PAX_KERNEXEC
25886 + " movl %%cr0, %0\n"
25887 + " movl %0, %%eax\n"
25888 + " andl $0xFFFEFFFF, %%eax\n"
25889 + " movl %%eax, %%cr0\n"
25890 +#endif
25891 +
25892 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
25893 +
25894 +#ifdef CONFIG_PAX_KERNEXEC
25895 + " movl %0, %%cr0\n"
25896 +#endif
25897 +
25898 " jmp 2b\n"
25899 ".previous\n"
25900 _ASM_EXTABLE(1b, 3b)
25901 - : : "r" (from), "r" (to) : "memory");
25902 + : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
25903
25904 from += 64;
25905 to += 64;
25906 @@ -158,6 +187,7 @@ static void fast_clear_page(void *page)
25907 static void fast_copy_page(void *to, void *from)
25908 {
25909 int i;
25910 + unsigned long cr0;
25911
25912 kernel_fpu_begin();
25913
25914 @@ -166,42 +196,70 @@ static void fast_copy_page(void *to, void *from)
25915 * but that is for later. -AV
25916 */
25917 __asm__ __volatile__(
25918 - "1: prefetch (%0)\n"
25919 - " prefetch 64(%0)\n"
25920 - " prefetch 128(%0)\n"
25921 - " prefetch 192(%0)\n"
25922 - " prefetch 256(%0)\n"
25923 + "1: prefetch (%1)\n"
25924 + " prefetch 64(%1)\n"
25925 + " prefetch 128(%1)\n"
25926 + " prefetch 192(%1)\n"
25927 + " prefetch 256(%1)\n"
25928 "2: \n"
25929 ".section .fixup, \"ax\"\n"
25930 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
25931 + "3: \n"
25932 +
25933 +#ifdef CONFIG_PAX_KERNEXEC
25934 + " movl %%cr0, %0\n"
25935 + " movl %0, %%eax\n"
25936 + " andl $0xFFFEFFFF, %%eax\n"
25937 + " movl %%eax, %%cr0\n"
25938 +#endif
25939 +
25940 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
25941 +
25942 +#ifdef CONFIG_PAX_KERNEXEC
25943 + " movl %0, %%cr0\n"
25944 +#endif
25945 +
25946 " jmp 2b\n"
25947 ".previous\n"
25948 - _ASM_EXTABLE(1b, 3b) : : "r" (from));
25949 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from) : "ax");
25950
25951 for (i = 0; i < (4096-320)/64; i++) {
25952 __asm__ __volatile__ (
25953 - "1: prefetch 320(%0)\n"
25954 - "2: movq (%0), %%mm0\n"
25955 - " movntq %%mm0, (%1)\n"
25956 - " movq 8(%0), %%mm1\n"
25957 - " movntq %%mm1, 8(%1)\n"
25958 - " movq 16(%0), %%mm2\n"
25959 - " movntq %%mm2, 16(%1)\n"
25960 - " movq 24(%0), %%mm3\n"
25961 - " movntq %%mm3, 24(%1)\n"
25962 - " movq 32(%0), %%mm4\n"
25963 - " movntq %%mm4, 32(%1)\n"
25964 - " movq 40(%0), %%mm5\n"
25965 - " movntq %%mm5, 40(%1)\n"
25966 - " movq 48(%0), %%mm6\n"
25967 - " movntq %%mm6, 48(%1)\n"
25968 - " movq 56(%0), %%mm7\n"
25969 - " movntq %%mm7, 56(%1)\n"
25970 + "1: prefetch 320(%1)\n"
25971 + "2: movq (%1), %%mm0\n"
25972 + " movntq %%mm0, (%2)\n"
25973 + " movq 8(%1), %%mm1\n"
25974 + " movntq %%mm1, 8(%2)\n"
25975 + " movq 16(%1), %%mm2\n"
25976 + " movntq %%mm2, 16(%2)\n"
25977 + " movq 24(%1), %%mm3\n"
25978 + " movntq %%mm3, 24(%2)\n"
25979 + " movq 32(%1), %%mm4\n"
25980 + " movntq %%mm4, 32(%2)\n"
25981 + " movq 40(%1), %%mm5\n"
25982 + " movntq %%mm5, 40(%2)\n"
25983 + " movq 48(%1), %%mm6\n"
25984 + " movntq %%mm6, 48(%2)\n"
25985 + " movq 56(%1), %%mm7\n"
25986 + " movntq %%mm7, 56(%2)\n"
25987 ".section .fixup, \"ax\"\n"
25988 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
25989 + "3:\n"
25990 +
25991 +#ifdef CONFIG_PAX_KERNEXEC
25992 + " movl %%cr0, %0\n"
25993 + " movl %0, %%eax\n"
25994 + " andl $0xFFFEFFFF, %%eax\n"
25995 + " movl %%eax, %%cr0\n"
25996 +#endif
25997 +
25998 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
25999 +
26000 +#ifdef CONFIG_PAX_KERNEXEC
26001 + " movl %0, %%cr0\n"
26002 +#endif
26003 +
26004 " jmp 2b\n"
26005 ".previous\n"
26006 - _ASM_EXTABLE(1b, 3b) : : "r" (from), "r" (to) : "memory");
26007 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
26008
26009 from += 64;
26010 to += 64;
26011 @@ -280,47 +338,76 @@ static void fast_clear_page(void *page)
26012 static void fast_copy_page(void *to, void *from)
26013 {
26014 int i;
26015 + unsigned long cr0;
26016
26017 kernel_fpu_begin();
26018
26019 __asm__ __volatile__ (
26020 - "1: prefetch (%0)\n"
26021 - " prefetch 64(%0)\n"
26022 - " prefetch 128(%0)\n"
26023 - " prefetch 192(%0)\n"
26024 - " prefetch 256(%0)\n"
26025 + "1: prefetch (%1)\n"
26026 + " prefetch 64(%1)\n"
26027 + " prefetch 128(%1)\n"
26028 + " prefetch 192(%1)\n"
26029 + " prefetch 256(%1)\n"
26030 "2: \n"
26031 ".section .fixup, \"ax\"\n"
26032 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
26033 + "3: \n"
26034 +
26035 +#ifdef CONFIG_PAX_KERNEXEC
26036 + " movl %%cr0, %0\n"
26037 + " movl %0, %%eax\n"
26038 + " andl $0xFFFEFFFF, %%eax\n"
26039 + " movl %%eax, %%cr0\n"
26040 +#endif
26041 +
26042 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
26043 +
26044 +#ifdef CONFIG_PAX_KERNEXEC
26045 + " movl %0, %%cr0\n"
26046 +#endif
26047 +
26048 " jmp 2b\n"
26049 ".previous\n"
26050 - _ASM_EXTABLE(1b, 3b) : : "r" (from));
26051 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from) : "ax");
26052
26053 for (i = 0; i < 4096/64; i++) {
26054 __asm__ __volatile__ (
26055 - "1: prefetch 320(%0)\n"
26056 - "2: movq (%0), %%mm0\n"
26057 - " movq 8(%0), %%mm1\n"
26058 - " movq 16(%0), %%mm2\n"
26059 - " movq 24(%0), %%mm3\n"
26060 - " movq %%mm0, (%1)\n"
26061 - " movq %%mm1, 8(%1)\n"
26062 - " movq %%mm2, 16(%1)\n"
26063 - " movq %%mm3, 24(%1)\n"
26064 - " movq 32(%0), %%mm0\n"
26065 - " movq 40(%0), %%mm1\n"
26066 - " movq 48(%0), %%mm2\n"
26067 - " movq 56(%0), %%mm3\n"
26068 - " movq %%mm0, 32(%1)\n"
26069 - " movq %%mm1, 40(%1)\n"
26070 - " movq %%mm2, 48(%1)\n"
26071 - " movq %%mm3, 56(%1)\n"
26072 + "1: prefetch 320(%1)\n"
26073 + "2: movq (%1), %%mm0\n"
26074 + " movq 8(%1), %%mm1\n"
26075 + " movq 16(%1), %%mm2\n"
26076 + " movq 24(%1), %%mm3\n"
26077 + " movq %%mm0, (%2)\n"
26078 + " movq %%mm1, 8(%2)\n"
26079 + " movq %%mm2, 16(%2)\n"
26080 + " movq %%mm3, 24(%2)\n"
26081 + " movq 32(%1), %%mm0\n"
26082 + " movq 40(%1), %%mm1\n"
26083 + " movq 48(%1), %%mm2\n"
26084 + " movq 56(%1), %%mm3\n"
26085 + " movq %%mm0, 32(%2)\n"
26086 + " movq %%mm1, 40(%2)\n"
26087 + " movq %%mm2, 48(%2)\n"
26088 + " movq %%mm3, 56(%2)\n"
26089 ".section .fixup, \"ax\"\n"
26090 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
26091 + "3:\n"
26092 +
26093 +#ifdef CONFIG_PAX_KERNEXEC
26094 + " movl %%cr0, %0\n"
26095 + " movl %0, %%eax\n"
26096 + " andl $0xFFFEFFFF, %%eax\n"
26097 + " movl %%eax, %%cr0\n"
26098 +#endif
26099 +
26100 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
26101 +
26102 +#ifdef CONFIG_PAX_KERNEXEC
26103 + " movl %0, %%cr0\n"
26104 +#endif
26105 +
26106 " jmp 2b\n"
26107 ".previous\n"
26108 _ASM_EXTABLE(1b, 3b)
26109 - : : "r" (from), "r" (to) : "memory");
26110 + : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
26111
26112 from += 64;
26113 to += 64;
26114 diff --git a/arch/x86/lib/msr-reg.S b/arch/x86/lib/msr-reg.S
26115 index f6d13ee..aca5f0b 100644
26116 --- a/arch/x86/lib/msr-reg.S
26117 +++ b/arch/x86/lib/msr-reg.S
26118 @@ -3,6 +3,7 @@
26119 #include <asm/dwarf2.h>
26120 #include <asm/asm.h>
26121 #include <asm/msr.h>
26122 +#include <asm/alternative-asm.h>
26123
26124 #ifdef CONFIG_X86_64
26125 /*
26126 @@ -16,7 +17,7 @@ ENTRY(\op\()_safe_regs)
26127 CFI_STARTPROC
26128 pushq_cfi %rbx
26129 pushq_cfi %rbp
26130 - movq %rdi, %r10 /* Save pointer */
26131 + movq %rdi, %r9 /* Save pointer */
26132 xorl %r11d, %r11d /* Return value */
26133 movl (%rdi), %eax
26134 movl 4(%rdi), %ecx
26135 @@ -27,16 +28,17 @@ ENTRY(\op\()_safe_regs)
26136 movl 28(%rdi), %edi
26137 CFI_REMEMBER_STATE
26138 1: \op
26139 -2: movl %eax, (%r10)
26140 +2: movl %eax, (%r9)
26141 movl %r11d, %eax /* Return value */
26142 - movl %ecx, 4(%r10)
26143 - movl %edx, 8(%r10)
26144 - movl %ebx, 12(%r10)
26145 - movl %ebp, 20(%r10)
26146 - movl %esi, 24(%r10)
26147 - movl %edi, 28(%r10)
26148 + movl %ecx, 4(%r9)
26149 + movl %edx, 8(%r9)
26150 + movl %ebx, 12(%r9)
26151 + movl %ebp, 20(%r9)
26152 + movl %esi, 24(%r9)
26153 + movl %edi, 28(%r9)
26154 popq_cfi %rbp
26155 popq_cfi %rbx
26156 + pax_force_retaddr
26157 ret
26158 3:
26159 CFI_RESTORE_STATE
26160 diff --git a/arch/x86/lib/putuser.S b/arch/x86/lib/putuser.S
26161 index fc6ba17..d4d989d 100644
26162 --- a/arch/x86/lib/putuser.S
26163 +++ b/arch/x86/lib/putuser.S
26164 @@ -16,7 +16,9 @@
26165 #include <asm/errno.h>
26166 #include <asm/asm.h>
26167 #include <asm/smap.h>
26168 -
26169 +#include <asm/segment.h>
26170 +#include <asm/pgtable.h>
26171 +#include <asm/alternative-asm.h>
26172
26173 /*
26174 * __put_user_X
26175 @@ -30,57 +32,125 @@
26176 * as they get called from within inline assembly.
26177 */
26178
26179 -#define ENTER CFI_STARTPROC ; \
26180 - GET_THREAD_INFO(%_ASM_BX)
26181 -#define EXIT ASM_CLAC ; \
26182 - ret ; \
26183 +#define ENTER CFI_STARTPROC
26184 +#define EXIT ASM_CLAC ; \
26185 + pax_force_retaddr ; \
26186 + ret ; \
26187 CFI_ENDPROC
26188
26189 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26190 +#define _DEST %_ASM_CX,%_ASM_BX
26191 +#else
26192 +#define _DEST %_ASM_CX
26193 +#endif
26194 +
26195 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
26196 +#define __copyuser_seg gs;
26197 +#else
26198 +#define __copyuser_seg
26199 +#endif
26200 +
26201 .text
26202 ENTRY(__put_user_1)
26203 ENTER
26204 +
26205 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
26206 + GET_THREAD_INFO(%_ASM_BX)
26207 cmp TI_addr_limit(%_ASM_BX),%_ASM_CX
26208 jae bad_put_user
26209 ASM_STAC
26210 -1: movb %al,(%_ASM_CX)
26211 +
26212 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26213 + mov pax_user_shadow_base,%_ASM_BX
26214 + cmp %_ASM_BX,%_ASM_CX
26215 + jb 1234f
26216 + xor %ebx,%ebx
26217 +1234:
26218 +#endif
26219 +
26220 +#endif
26221 +
26222 +1: __copyuser_seg movb %al,(_DEST)
26223 xor %eax,%eax
26224 EXIT
26225 ENDPROC(__put_user_1)
26226
26227 ENTRY(__put_user_2)
26228 ENTER
26229 +
26230 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
26231 + GET_THREAD_INFO(%_ASM_BX)
26232 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
26233 sub $1,%_ASM_BX
26234 cmp %_ASM_BX,%_ASM_CX
26235 jae bad_put_user
26236 ASM_STAC
26237 -2: movw %ax,(%_ASM_CX)
26238 +
26239 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26240 + mov pax_user_shadow_base,%_ASM_BX
26241 + cmp %_ASM_BX,%_ASM_CX
26242 + jb 1234f
26243 + xor %ebx,%ebx
26244 +1234:
26245 +#endif
26246 +
26247 +#endif
26248 +
26249 +2: __copyuser_seg movw %ax,(_DEST)
26250 xor %eax,%eax
26251 EXIT
26252 ENDPROC(__put_user_2)
26253
26254 ENTRY(__put_user_4)
26255 ENTER
26256 +
26257 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
26258 + GET_THREAD_INFO(%_ASM_BX)
26259 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
26260 sub $3,%_ASM_BX
26261 cmp %_ASM_BX,%_ASM_CX
26262 jae bad_put_user
26263 ASM_STAC
26264 -3: movl %eax,(%_ASM_CX)
26265 +
26266 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26267 + mov pax_user_shadow_base,%_ASM_BX
26268 + cmp %_ASM_BX,%_ASM_CX
26269 + jb 1234f
26270 + xor %ebx,%ebx
26271 +1234:
26272 +#endif
26273 +
26274 +#endif
26275 +
26276 +3: __copyuser_seg movl %eax,(_DEST)
26277 xor %eax,%eax
26278 EXIT
26279 ENDPROC(__put_user_4)
26280
26281 ENTRY(__put_user_8)
26282 ENTER
26283 +
26284 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
26285 + GET_THREAD_INFO(%_ASM_BX)
26286 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
26287 sub $7,%_ASM_BX
26288 cmp %_ASM_BX,%_ASM_CX
26289 jae bad_put_user
26290 ASM_STAC
26291 -4: mov %_ASM_AX,(%_ASM_CX)
26292 +
26293 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26294 + mov pax_user_shadow_base,%_ASM_BX
26295 + cmp %_ASM_BX,%_ASM_CX
26296 + jb 1234f
26297 + xor %ebx,%ebx
26298 +1234:
26299 +#endif
26300 +
26301 +#endif
26302 +
26303 +4: __copyuser_seg mov %_ASM_AX,(_DEST)
26304 #ifdef CONFIG_X86_32
26305 -5: movl %edx,4(%_ASM_CX)
26306 +5: __copyuser_seg movl %edx,4(_DEST)
26307 #endif
26308 xor %eax,%eax
26309 EXIT
26310 diff --git a/arch/x86/lib/rwlock.S b/arch/x86/lib/rwlock.S
26311 index 1cad221..de671ee 100644
26312 --- a/arch/x86/lib/rwlock.S
26313 +++ b/arch/x86/lib/rwlock.S
26314 @@ -16,13 +16,34 @@ ENTRY(__write_lock_failed)
26315 FRAME
26316 0: LOCK_PREFIX
26317 WRITE_LOCK_ADD($RW_LOCK_BIAS) (%__lock_ptr)
26318 +
26319 +#ifdef CONFIG_PAX_REFCOUNT
26320 + jno 1234f
26321 + LOCK_PREFIX
26322 + WRITE_LOCK_SUB($RW_LOCK_BIAS) (%__lock_ptr)
26323 + int $4
26324 +1234:
26325 + _ASM_EXTABLE(1234b, 1234b)
26326 +#endif
26327 +
26328 1: rep; nop
26329 cmpl $WRITE_LOCK_CMP, (%__lock_ptr)
26330 jne 1b
26331 LOCK_PREFIX
26332 WRITE_LOCK_SUB($RW_LOCK_BIAS) (%__lock_ptr)
26333 +
26334 +#ifdef CONFIG_PAX_REFCOUNT
26335 + jno 1234f
26336 + LOCK_PREFIX
26337 + WRITE_LOCK_ADD($RW_LOCK_BIAS) (%__lock_ptr)
26338 + int $4
26339 +1234:
26340 + _ASM_EXTABLE(1234b, 1234b)
26341 +#endif
26342 +
26343 jnz 0b
26344 ENDFRAME
26345 + pax_force_retaddr
26346 ret
26347 CFI_ENDPROC
26348 END(__write_lock_failed)
26349 @@ -32,13 +53,34 @@ ENTRY(__read_lock_failed)
26350 FRAME
26351 0: LOCK_PREFIX
26352 READ_LOCK_SIZE(inc) (%__lock_ptr)
26353 +
26354 +#ifdef CONFIG_PAX_REFCOUNT
26355 + jno 1234f
26356 + LOCK_PREFIX
26357 + READ_LOCK_SIZE(dec) (%__lock_ptr)
26358 + int $4
26359 +1234:
26360 + _ASM_EXTABLE(1234b, 1234b)
26361 +#endif
26362 +
26363 1: rep; nop
26364 READ_LOCK_SIZE(cmp) $1, (%__lock_ptr)
26365 js 1b
26366 LOCK_PREFIX
26367 READ_LOCK_SIZE(dec) (%__lock_ptr)
26368 +
26369 +#ifdef CONFIG_PAX_REFCOUNT
26370 + jno 1234f
26371 + LOCK_PREFIX
26372 + READ_LOCK_SIZE(inc) (%__lock_ptr)
26373 + int $4
26374 +1234:
26375 + _ASM_EXTABLE(1234b, 1234b)
26376 +#endif
26377 +
26378 js 0b
26379 ENDFRAME
26380 + pax_force_retaddr
26381 ret
26382 CFI_ENDPROC
26383 END(__read_lock_failed)
26384 diff --git a/arch/x86/lib/rwsem.S b/arch/x86/lib/rwsem.S
26385 index 5dff5f0..cadebf4 100644
26386 --- a/arch/x86/lib/rwsem.S
26387 +++ b/arch/x86/lib/rwsem.S
26388 @@ -94,6 +94,7 @@ ENTRY(call_rwsem_down_read_failed)
26389 __ASM_SIZE(pop,_cfi) %__ASM_REG(dx)
26390 CFI_RESTORE __ASM_REG(dx)
26391 restore_common_regs
26392 + pax_force_retaddr
26393 ret
26394 CFI_ENDPROC
26395 ENDPROC(call_rwsem_down_read_failed)
26396 @@ -104,6 +105,7 @@ ENTRY(call_rwsem_down_write_failed)
26397 movq %rax,%rdi
26398 call rwsem_down_write_failed
26399 restore_common_regs
26400 + pax_force_retaddr
26401 ret
26402 CFI_ENDPROC
26403 ENDPROC(call_rwsem_down_write_failed)
26404 @@ -117,7 +119,8 @@ ENTRY(call_rwsem_wake)
26405 movq %rax,%rdi
26406 call rwsem_wake
26407 restore_common_regs
26408 -1: ret
26409 +1: pax_force_retaddr
26410 + ret
26411 CFI_ENDPROC
26412 ENDPROC(call_rwsem_wake)
26413
26414 @@ -131,6 +134,7 @@ ENTRY(call_rwsem_downgrade_wake)
26415 __ASM_SIZE(pop,_cfi) %__ASM_REG(dx)
26416 CFI_RESTORE __ASM_REG(dx)
26417 restore_common_regs
26418 + pax_force_retaddr
26419 ret
26420 CFI_ENDPROC
26421 ENDPROC(call_rwsem_downgrade_wake)
26422 diff --git a/arch/x86/lib/thunk_64.S b/arch/x86/lib/thunk_64.S
26423 index a63efd6..ccecad8 100644
26424 --- a/arch/x86/lib/thunk_64.S
26425 +++ b/arch/x86/lib/thunk_64.S
26426 @@ -8,6 +8,7 @@
26427 #include <linux/linkage.h>
26428 #include <asm/dwarf2.h>
26429 #include <asm/calling.h>
26430 +#include <asm/alternative-asm.h>
26431
26432 /* rdi: arg1 ... normal C conventions. rax is saved/restored. */
26433 .macro THUNK name, func, put_ret_addr_in_rdi=0
26434 @@ -41,5 +42,6 @@
26435 SAVE_ARGS
26436 restore:
26437 RESTORE_ARGS
26438 + pax_force_retaddr
26439 ret
26440 CFI_ENDPROC
26441 diff --git a/arch/x86/lib/usercopy_32.c b/arch/x86/lib/usercopy_32.c
26442 index f0312d7..9c39d63 100644
26443 --- a/arch/x86/lib/usercopy_32.c
26444 +++ b/arch/x86/lib/usercopy_32.c
26445 @@ -42,11 +42,13 @@ do { \
26446 int __d0; \
26447 might_fault(); \
26448 __asm__ __volatile__( \
26449 + __COPYUSER_SET_ES \
26450 ASM_STAC "\n" \
26451 "0: rep; stosl\n" \
26452 " movl %2,%0\n" \
26453 "1: rep; stosb\n" \
26454 "2: " ASM_CLAC "\n" \
26455 + __COPYUSER_RESTORE_ES \
26456 ".section .fixup,\"ax\"\n" \
26457 "3: lea 0(%2,%0,4),%0\n" \
26458 " jmp 2b\n" \
26459 @@ -98,7 +100,7 @@ EXPORT_SYMBOL(__clear_user);
26460
26461 #ifdef CONFIG_X86_INTEL_USERCOPY
26462 static unsigned long
26463 -__copy_user_intel(void __user *to, const void *from, unsigned long size)
26464 +__generic_copy_to_user_intel(void __user *to, const void *from, unsigned long size)
26465 {
26466 int d0, d1;
26467 __asm__ __volatile__(
26468 @@ -110,36 +112,36 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
26469 " .align 2,0x90\n"
26470 "3: movl 0(%4), %%eax\n"
26471 "4: movl 4(%4), %%edx\n"
26472 - "5: movl %%eax, 0(%3)\n"
26473 - "6: movl %%edx, 4(%3)\n"
26474 + "5: "__copyuser_seg" movl %%eax, 0(%3)\n"
26475 + "6: "__copyuser_seg" movl %%edx, 4(%3)\n"
26476 "7: movl 8(%4), %%eax\n"
26477 "8: movl 12(%4),%%edx\n"
26478 - "9: movl %%eax, 8(%3)\n"
26479 - "10: movl %%edx, 12(%3)\n"
26480 + "9: "__copyuser_seg" movl %%eax, 8(%3)\n"
26481 + "10: "__copyuser_seg" movl %%edx, 12(%3)\n"
26482 "11: movl 16(%4), %%eax\n"
26483 "12: movl 20(%4), %%edx\n"
26484 - "13: movl %%eax, 16(%3)\n"
26485 - "14: movl %%edx, 20(%3)\n"
26486 + "13: "__copyuser_seg" movl %%eax, 16(%3)\n"
26487 + "14: "__copyuser_seg" movl %%edx, 20(%3)\n"
26488 "15: movl 24(%4), %%eax\n"
26489 "16: movl 28(%4), %%edx\n"
26490 - "17: movl %%eax, 24(%3)\n"
26491 - "18: movl %%edx, 28(%3)\n"
26492 + "17: "__copyuser_seg" movl %%eax, 24(%3)\n"
26493 + "18: "__copyuser_seg" movl %%edx, 28(%3)\n"
26494 "19: movl 32(%4), %%eax\n"
26495 "20: movl 36(%4), %%edx\n"
26496 - "21: movl %%eax, 32(%3)\n"
26497 - "22: movl %%edx, 36(%3)\n"
26498 + "21: "__copyuser_seg" movl %%eax, 32(%3)\n"
26499 + "22: "__copyuser_seg" movl %%edx, 36(%3)\n"
26500 "23: movl 40(%4), %%eax\n"
26501 "24: movl 44(%4), %%edx\n"
26502 - "25: movl %%eax, 40(%3)\n"
26503 - "26: movl %%edx, 44(%3)\n"
26504 + "25: "__copyuser_seg" movl %%eax, 40(%3)\n"
26505 + "26: "__copyuser_seg" movl %%edx, 44(%3)\n"
26506 "27: movl 48(%4), %%eax\n"
26507 "28: movl 52(%4), %%edx\n"
26508 - "29: movl %%eax, 48(%3)\n"
26509 - "30: movl %%edx, 52(%3)\n"
26510 + "29: "__copyuser_seg" movl %%eax, 48(%3)\n"
26511 + "30: "__copyuser_seg" movl %%edx, 52(%3)\n"
26512 "31: movl 56(%4), %%eax\n"
26513 "32: movl 60(%4), %%edx\n"
26514 - "33: movl %%eax, 56(%3)\n"
26515 - "34: movl %%edx, 60(%3)\n"
26516 + "33: "__copyuser_seg" movl %%eax, 56(%3)\n"
26517 + "34: "__copyuser_seg" movl %%edx, 60(%3)\n"
26518 " addl $-64, %0\n"
26519 " addl $64, %4\n"
26520 " addl $64, %3\n"
26521 @@ -149,10 +151,12 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
26522 " shrl $2, %0\n"
26523 " andl $3, %%eax\n"
26524 " cld\n"
26525 + __COPYUSER_SET_ES
26526 "99: rep; movsl\n"
26527 "36: movl %%eax, %0\n"
26528 "37: rep; movsb\n"
26529 "100:\n"
26530 + __COPYUSER_RESTORE_ES
26531 ".section .fixup,\"ax\"\n"
26532 "101: lea 0(%%eax,%0,4),%0\n"
26533 " jmp 100b\n"
26534 @@ -202,46 +206,150 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
26535 }
26536
26537 static unsigned long
26538 +__generic_copy_from_user_intel(void *to, const void __user *from, unsigned long size)
26539 +{
26540 + int d0, d1;
26541 + __asm__ __volatile__(
26542 + " .align 2,0x90\n"
26543 + "1: "__copyuser_seg" movl 32(%4), %%eax\n"
26544 + " cmpl $67, %0\n"
26545 + " jbe 3f\n"
26546 + "2: "__copyuser_seg" movl 64(%4), %%eax\n"
26547 + " .align 2,0x90\n"
26548 + "3: "__copyuser_seg" movl 0(%4), %%eax\n"
26549 + "4: "__copyuser_seg" movl 4(%4), %%edx\n"
26550 + "5: movl %%eax, 0(%3)\n"
26551 + "6: movl %%edx, 4(%3)\n"
26552 + "7: "__copyuser_seg" movl 8(%4), %%eax\n"
26553 + "8: "__copyuser_seg" movl 12(%4),%%edx\n"
26554 + "9: movl %%eax, 8(%3)\n"
26555 + "10: movl %%edx, 12(%3)\n"
26556 + "11: "__copyuser_seg" movl 16(%4), %%eax\n"
26557 + "12: "__copyuser_seg" movl 20(%4), %%edx\n"
26558 + "13: movl %%eax, 16(%3)\n"
26559 + "14: movl %%edx, 20(%3)\n"
26560 + "15: "__copyuser_seg" movl 24(%4), %%eax\n"
26561 + "16: "__copyuser_seg" movl 28(%4), %%edx\n"
26562 + "17: movl %%eax, 24(%3)\n"
26563 + "18: movl %%edx, 28(%3)\n"
26564 + "19: "__copyuser_seg" movl 32(%4), %%eax\n"
26565 + "20: "__copyuser_seg" movl 36(%4), %%edx\n"
26566 + "21: movl %%eax, 32(%3)\n"
26567 + "22: movl %%edx, 36(%3)\n"
26568 + "23: "__copyuser_seg" movl 40(%4), %%eax\n"
26569 + "24: "__copyuser_seg" movl 44(%4), %%edx\n"
26570 + "25: movl %%eax, 40(%3)\n"
26571 + "26: movl %%edx, 44(%3)\n"
26572 + "27: "__copyuser_seg" movl 48(%4), %%eax\n"
26573 + "28: "__copyuser_seg" movl 52(%4), %%edx\n"
26574 + "29: movl %%eax, 48(%3)\n"
26575 + "30: movl %%edx, 52(%3)\n"
26576 + "31: "__copyuser_seg" movl 56(%4), %%eax\n"
26577 + "32: "__copyuser_seg" movl 60(%4), %%edx\n"
26578 + "33: movl %%eax, 56(%3)\n"
26579 + "34: movl %%edx, 60(%3)\n"
26580 + " addl $-64, %0\n"
26581 + " addl $64, %4\n"
26582 + " addl $64, %3\n"
26583 + " cmpl $63, %0\n"
26584 + " ja 1b\n"
26585 + "35: movl %0, %%eax\n"
26586 + " shrl $2, %0\n"
26587 + " andl $3, %%eax\n"
26588 + " cld\n"
26589 + "99: rep; "__copyuser_seg" movsl\n"
26590 + "36: movl %%eax, %0\n"
26591 + "37: rep; "__copyuser_seg" movsb\n"
26592 + "100:\n"
26593 + ".section .fixup,\"ax\"\n"
26594 + "101: lea 0(%%eax,%0,4),%0\n"
26595 + " jmp 100b\n"
26596 + ".previous\n"
26597 + _ASM_EXTABLE(1b,100b)
26598 + _ASM_EXTABLE(2b,100b)
26599 + _ASM_EXTABLE(3b,100b)
26600 + _ASM_EXTABLE(4b,100b)
26601 + _ASM_EXTABLE(5b,100b)
26602 + _ASM_EXTABLE(6b,100b)
26603 + _ASM_EXTABLE(7b,100b)
26604 + _ASM_EXTABLE(8b,100b)
26605 + _ASM_EXTABLE(9b,100b)
26606 + _ASM_EXTABLE(10b,100b)
26607 + _ASM_EXTABLE(11b,100b)
26608 + _ASM_EXTABLE(12b,100b)
26609 + _ASM_EXTABLE(13b,100b)
26610 + _ASM_EXTABLE(14b,100b)
26611 + _ASM_EXTABLE(15b,100b)
26612 + _ASM_EXTABLE(16b,100b)
26613 + _ASM_EXTABLE(17b,100b)
26614 + _ASM_EXTABLE(18b,100b)
26615 + _ASM_EXTABLE(19b,100b)
26616 + _ASM_EXTABLE(20b,100b)
26617 + _ASM_EXTABLE(21b,100b)
26618 + _ASM_EXTABLE(22b,100b)
26619 + _ASM_EXTABLE(23b,100b)
26620 + _ASM_EXTABLE(24b,100b)
26621 + _ASM_EXTABLE(25b,100b)
26622 + _ASM_EXTABLE(26b,100b)
26623 + _ASM_EXTABLE(27b,100b)
26624 + _ASM_EXTABLE(28b,100b)
26625 + _ASM_EXTABLE(29b,100b)
26626 + _ASM_EXTABLE(30b,100b)
26627 + _ASM_EXTABLE(31b,100b)
26628 + _ASM_EXTABLE(32b,100b)
26629 + _ASM_EXTABLE(33b,100b)
26630 + _ASM_EXTABLE(34b,100b)
26631 + _ASM_EXTABLE(35b,100b)
26632 + _ASM_EXTABLE(36b,100b)
26633 + _ASM_EXTABLE(37b,100b)
26634 + _ASM_EXTABLE(99b,101b)
26635 + : "=&c"(size), "=&D" (d0), "=&S" (d1)
26636 + : "1"(to), "2"(from), "0"(size)
26637 + : "eax", "edx", "memory");
26638 + return size;
26639 +}
26640 +
26641 +static unsigned long __size_overflow(3)
26642 __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
26643 {
26644 int d0, d1;
26645 __asm__ __volatile__(
26646 " .align 2,0x90\n"
26647 - "0: movl 32(%4), %%eax\n"
26648 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
26649 " cmpl $67, %0\n"
26650 " jbe 2f\n"
26651 - "1: movl 64(%4), %%eax\n"
26652 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
26653 " .align 2,0x90\n"
26654 - "2: movl 0(%4), %%eax\n"
26655 - "21: movl 4(%4), %%edx\n"
26656 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
26657 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
26658 " movl %%eax, 0(%3)\n"
26659 " movl %%edx, 4(%3)\n"
26660 - "3: movl 8(%4), %%eax\n"
26661 - "31: movl 12(%4),%%edx\n"
26662 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
26663 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
26664 " movl %%eax, 8(%3)\n"
26665 " movl %%edx, 12(%3)\n"
26666 - "4: movl 16(%4), %%eax\n"
26667 - "41: movl 20(%4), %%edx\n"
26668 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
26669 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
26670 " movl %%eax, 16(%3)\n"
26671 " movl %%edx, 20(%3)\n"
26672 - "10: movl 24(%4), %%eax\n"
26673 - "51: movl 28(%4), %%edx\n"
26674 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
26675 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
26676 " movl %%eax, 24(%3)\n"
26677 " movl %%edx, 28(%3)\n"
26678 - "11: movl 32(%4), %%eax\n"
26679 - "61: movl 36(%4), %%edx\n"
26680 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
26681 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
26682 " movl %%eax, 32(%3)\n"
26683 " movl %%edx, 36(%3)\n"
26684 - "12: movl 40(%4), %%eax\n"
26685 - "71: movl 44(%4), %%edx\n"
26686 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
26687 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
26688 " movl %%eax, 40(%3)\n"
26689 " movl %%edx, 44(%3)\n"
26690 - "13: movl 48(%4), %%eax\n"
26691 - "81: movl 52(%4), %%edx\n"
26692 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
26693 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
26694 " movl %%eax, 48(%3)\n"
26695 " movl %%edx, 52(%3)\n"
26696 - "14: movl 56(%4), %%eax\n"
26697 - "91: movl 60(%4), %%edx\n"
26698 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
26699 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
26700 " movl %%eax, 56(%3)\n"
26701 " movl %%edx, 60(%3)\n"
26702 " addl $-64, %0\n"
26703 @@ -253,9 +361,9 @@ __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
26704 " shrl $2, %0\n"
26705 " andl $3, %%eax\n"
26706 " cld\n"
26707 - "6: rep; movsl\n"
26708 + "6: rep; "__copyuser_seg" movsl\n"
26709 " movl %%eax,%0\n"
26710 - "7: rep; movsb\n"
26711 + "7: rep; "__copyuser_seg" movsb\n"
26712 "8:\n"
26713 ".section .fixup,\"ax\"\n"
26714 "9: lea 0(%%eax,%0,4),%0\n"
26715 @@ -298,48 +406,48 @@ __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
26716 * hyoshiok@miraclelinux.com
26717 */
26718
26719 -static unsigned long __copy_user_zeroing_intel_nocache(void *to,
26720 +static unsigned long __size_overflow(3) __copy_user_zeroing_intel_nocache(void *to,
26721 const void __user *from, unsigned long size)
26722 {
26723 int d0, d1;
26724
26725 __asm__ __volatile__(
26726 " .align 2,0x90\n"
26727 - "0: movl 32(%4), %%eax\n"
26728 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
26729 " cmpl $67, %0\n"
26730 " jbe 2f\n"
26731 - "1: movl 64(%4), %%eax\n"
26732 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
26733 " .align 2,0x90\n"
26734 - "2: movl 0(%4), %%eax\n"
26735 - "21: movl 4(%4), %%edx\n"
26736 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
26737 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
26738 " movnti %%eax, 0(%3)\n"
26739 " movnti %%edx, 4(%3)\n"
26740 - "3: movl 8(%4), %%eax\n"
26741 - "31: movl 12(%4),%%edx\n"
26742 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
26743 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
26744 " movnti %%eax, 8(%3)\n"
26745 " movnti %%edx, 12(%3)\n"
26746 - "4: movl 16(%4), %%eax\n"
26747 - "41: movl 20(%4), %%edx\n"
26748 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
26749 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
26750 " movnti %%eax, 16(%3)\n"
26751 " movnti %%edx, 20(%3)\n"
26752 - "10: movl 24(%4), %%eax\n"
26753 - "51: movl 28(%4), %%edx\n"
26754 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
26755 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
26756 " movnti %%eax, 24(%3)\n"
26757 " movnti %%edx, 28(%3)\n"
26758 - "11: movl 32(%4), %%eax\n"
26759 - "61: movl 36(%4), %%edx\n"
26760 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
26761 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
26762 " movnti %%eax, 32(%3)\n"
26763 " movnti %%edx, 36(%3)\n"
26764 - "12: movl 40(%4), %%eax\n"
26765 - "71: movl 44(%4), %%edx\n"
26766 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
26767 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
26768 " movnti %%eax, 40(%3)\n"
26769 " movnti %%edx, 44(%3)\n"
26770 - "13: movl 48(%4), %%eax\n"
26771 - "81: movl 52(%4), %%edx\n"
26772 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
26773 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
26774 " movnti %%eax, 48(%3)\n"
26775 " movnti %%edx, 52(%3)\n"
26776 - "14: movl 56(%4), %%eax\n"
26777 - "91: movl 60(%4), %%edx\n"
26778 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
26779 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
26780 " movnti %%eax, 56(%3)\n"
26781 " movnti %%edx, 60(%3)\n"
26782 " addl $-64, %0\n"
26783 @@ -352,9 +460,9 @@ static unsigned long __copy_user_zeroing_intel_nocache(void *to,
26784 " shrl $2, %0\n"
26785 " andl $3, %%eax\n"
26786 " cld\n"
26787 - "6: rep; movsl\n"
26788 + "6: rep; "__copyuser_seg" movsl\n"
26789 " movl %%eax,%0\n"
26790 - "7: rep; movsb\n"
26791 + "7: rep; "__copyuser_seg" movsb\n"
26792 "8:\n"
26793 ".section .fixup,\"ax\"\n"
26794 "9: lea 0(%%eax,%0,4),%0\n"
26795 @@ -392,48 +500,48 @@ static unsigned long __copy_user_zeroing_intel_nocache(void *to,
26796 return size;
26797 }
26798
26799 -static unsigned long __copy_user_intel_nocache(void *to,
26800 +static unsigned long __size_overflow(3) __copy_user_intel_nocache(void *to,
26801 const void __user *from, unsigned long size)
26802 {
26803 int d0, d1;
26804
26805 __asm__ __volatile__(
26806 " .align 2,0x90\n"
26807 - "0: movl 32(%4), %%eax\n"
26808 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
26809 " cmpl $67, %0\n"
26810 " jbe 2f\n"
26811 - "1: movl 64(%4), %%eax\n"
26812 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
26813 " .align 2,0x90\n"
26814 - "2: movl 0(%4), %%eax\n"
26815 - "21: movl 4(%4), %%edx\n"
26816 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
26817 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
26818 " movnti %%eax, 0(%3)\n"
26819 " movnti %%edx, 4(%3)\n"
26820 - "3: movl 8(%4), %%eax\n"
26821 - "31: movl 12(%4),%%edx\n"
26822 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
26823 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
26824 " movnti %%eax, 8(%3)\n"
26825 " movnti %%edx, 12(%3)\n"
26826 - "4: movl 16(%4), %%eax\n"
26827 - "41: movl 20(%4), %%edx\n"
26828 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
26829 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
26830 " movnti %%eax, 16(%3)\n"
26831 " movnti %%edx, 20(%3)\n"
26832 - "10: movl 24(%4), %%eax\n"
26833 - "51: movl 28(%4), %%edx\n"
26834 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
26835 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
26836 " movnti %%eax, 24(%3)\n"
26837 " movnti %%edx, 28(%3)\n"
26838 - "11: movl 32(%4), %%eax\n"
26839 - "61: movl 36(%4), %%edx\n"
26840 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
26841 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
26842 " movnti %%eax, 32(%3)\n"
26843 " movnti %%edx, 36(%3)\n"
26844 - "12: movl 40(%4), %%eax\n"
26845 - "71: movl 44(%4), %%edx\n"
26846 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
26847 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
26848 " movnti %%eax, 40(%3)\n"
26849 " movnti %%edx, 44(%3)\n"
26850 - "13: movl 48(%4), %%eax\n"
26851 - "81: movl 52(%4), %%edx\n"
26852 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
26853 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
26854 " movnti %%eax, 48(%3)\n"
26855 " movnti %%edx, 52(%3)\n"
26856 - "14: movl 56(%4), %%eax\n"
26857 - "91: movl 60(%4), %%edx\n"
26858 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
26859 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
26860 " movnti %%eax, 56(%3)\n"
26861 " movnti %%edx, 60(%3)\n"
26862 " addl $-64, %0\n"
26863 @@ -446,9 +554,9 @@ static unsigned long __copy_user_intel_nocache(void *to,
26864 " shrl $2, %0\n"
26865 " andl $3, %%eax\n"
26866 " cld\n"
26867 - "6: rep; movsl\n"
26868 + "6: rep; "__copyuser_seg" movsl\n"
26869 " movl %%eax,%0\n"
26870 - "7: rep; movsb\n"
26871 + "7: rep; "__copyuser_seg" movsb\n"
26872 "8:\n"
26873 ".section .fixup,\"ax\"\n"
26874 "9: lea 0(%%eax,%0,4),%0\n"
26875 @@ -488,32 +596,36 @@ static unsigned long __copy_user_intel_nocache(void *to,
26876 */
26877 unsigned long __copy_user_zeroing_intel(void *to, const void __user *from,
26878 unsigned long size);
26879 -unsigned long __copy_user_intel(void __user *to, const void *from,
26880 +unsigned long __generic_copy_to_user_intel(void __user *to, const void *from,
26881 + unsigned long size);
26882 +unsigned long __generic_copy_from_user_intel(void *to, const void __user *from,
26883 unsigned long size);
26884 unsigned long __copy_user_zeroing_intel_nocache(void *to,
26885 const void __user *from, unsigned long size);
26886 #endif /* CONFIG_X86_INTEL_USERCOPY */
26887
26888 /* Generic arbitrary sized copy. */
26889 -#define __copy_user(to, from, size) \
26890 +#define __copy_user(to, from, size, prefix, set, restore) \
26891 do { \
26892 int __d0, __d1, __d2; \
26893 __asm__ __volatile__( \
26894 + set \
26895 " cmp $7,%0\n" \
26896 " jbe 1f\n" \
26897 " movl %1,%0\n" \
26898 " negl %0\n" \
26899 " andl $7,%0\n" \
26900 " subl %0,%3\n" \
26901 - "4: rep; movsb\n" \
26902 + "4: rep; "prefix"movsb\n" \
26903 " movl %3,%0\n" \
26904 " shrl $2,%0\n" \
26905 " andl $3,%3\n" \
26906 " .align 2,0x90\n" \
26907 - "0: rep; movsl\n" \
26908 + "0: rep; "prefix"movsl\n" \
26909 " movl %3,%0\n" \
26910 - "1: rep; movsb\n" \
26911 + "1: rep; "prefix"movsb\n" \
26912 "2:\n" \
26913 + restore \
26914 ".section .fixup,\"ax\"\n" \
26915 "5: addl %3,%0\n" \
26916 " jmp 2b\n" \
26917 @@ -538,14 +650,14 @@ do { \
26918 " negl %0\n" \
26919 " andl $7,%0\n" \
26920 " subl %0,%3\n" \
26921 - "4: rep; movsb\n" \
26922 + "4: rep; "__copyuser_seg"movsb\n" \
26923 " movl %3,%0\n" \
26924 " shrl $2,%0\n" \
26925 " andl $3,%3\n" \
26926 " .align 2,0x90\n" \
26927 - "0: rep; movsl\n" \
26928 + "0: rep; "__copyuser_seg"movsl\n" \
26929 " movl %3,%0\n" \
26930 - "1: rep; movsb\n" \
26931 + "1: rep; "__copyuser_seg"movsb\n" \
26932 "2:\n" \
26933 ".section .fixup,\"ax\"\n" \
26934 "5: addl %3,%0\n" \
26935 @@ -572,9 +684,9 @@ unsigned long __copy_to_user_ll(void __user *to, const void *from,
26936 {
26937 stac();
26938 if (movsl_is_ok(to, from, n))
26939 - __copy_user(to, from, n);
26940 + __copy_user(to, from, n, "", __COPYUSER_SET_ES, __COPYUSER_RESTORE_ES);
26941 else
26942 - n = __copy_user_intel(to, from, n);
26943 + n = __generic_copy_to_user_intel(to, from, n);
26944 clac();
26945 return n;
26946 }
26947 @@ -598,10 +710,9 @@ unsigned long __copy_from_user_ll_nozero(void *to, const void __user *from,
26948 {
26949 stac();
26950 if (movsl_is_ok(to, from, n))
26951 - __copy_user(to, from, n);
26952 + __copy_user(to, from, n, __copyuser_seg, "", "");
26953 else
26954 - n = __copy_user_intel((void __user *)to,
26955 - (const void *)from, n);
26956 + n = __generic_copy_from_user_intel(to, from, n);
26957 clac();
26958 return n;
26959 }
26960 @@ -632,66 +743,51 @@ unsigned long __copy_from_user_ll_nocache_nozero(void *to, const void __user *fr
26961 if (n > 64 && cpu_has_xmm2)
26962 n = __copy_user_intel_nocache(to, from, n);
26963 else
26964 - __copy_user(to, from, n);
26965 + __copy_user(to, from, n, __copyuser_seg, "", "");
26966 #else
26967 - __copy_user(to, from, n);
26968 + __copy_user(to, from, n, __copyuser_seg, "", "");
26969 #endif
26970 clac();
26971 return n;
26972 }
26973 EXPORT_SYMBOL(__copy_from_user_ll_nocache_nozero);
26974
26975 -/**
26976 - * copy_to_user: - Copy a block of data into user space.
26977 - * @to: Destination address, in user space.
26978 - * @from: Source address, in kernel space.
26979 - * @n: Number of bytes to copy.
26980 - *
26981 - * Context: User context only. This function may sleep.
26982 - *
26983 - * Copy data from kernel space to user space.
26984 - *
26985 - * Returns number of bytes that could not be copied.
26986 - * On success, this will be zero.
26987 - */
26988 -unsigned long
26989 -copy_to_user(void __user *to, const void *from, unsigned long n)
26990 -{
26991 - if (access_ok(VERIFY_WRITE, to, n))
26992 - n = __copy_to_user(to, from, n);
26993 - return n;
26994 -}
26995 -EXPORT_SYMBOL(copy_to_user);
26996 -
26997 -/**
26998 - * copy_from_user: - Copy a block of data from user space.
26999 - * @to: Destination address, in kernel space.
27000 - * @from: Source address, in user space.
27001 - * @n: Number of bytes to copy.
27002 - *
27003 - * Context: User context only. This function may sleep.
27004 - *
27005 - * Copy data from user space to kernel space.
27006 - *
27007 - * Returns number of bytes that could not be copied.
27008 - * On success, this will be zero.
27009 - *
27010 - * If some data could not be copied, this function will pad the copied
27011 - * data to the requested size using zero bytes.
27012 - */
27013 -unsigned long
27014 -_copy_from_user(void *to, const void __user *from, unsigned long n)
27015 -{
27016 - if (access_ok(VERIFY_READ, from, n))
27017 - n = __copy_from_user(to, from, n);
27018 - else
27019 - memset(to, 0, n);
27020 - return n;
27021 -}
27022 -EXPORT_SYMBOL(_copy_from_user);
27023 -
27024 void copy_from_user_overflow(void)
27025 {
27026 WARN(1, "Buffer overflow detected!\n");
27027 }
27028 EXPORT_SYMBOL(copy_from_user_overflow);
27029 +
27030 +void copy_to_user_overflow(void)
27031 +{
27032 + WARN(1, "Buffer overflow detected!\n");
27033 +}
27034 +EXPORT_SYMBOL(copy_to_user_overflow);
27035 +
27036 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27037 +void __set_fs(mm_segment_t x)
27038 +{
27039 + switch (x.seg) {
27040 + case 0:
27041 + loadsegment(gs, 0);
27042 + break;
27043 + case TASK_SIZE_MAX:
27044 + loadsegment(gs, __USER_DS);
27045 + break;
27046 + case -1UL:
27047 + loadsegment(gs, __KERNEL_DS);
27048 + break;
27049 + default:
27050 + BUG();
27051 + }
27052 + return;
27053 +}
27054 +EXPORT_SYMBOL(__set_fs);
27055 +
27056 +void set_fs(mm_segment_t x)
27057 +{
27058 + current_thread_info()->addr_limit = x;
27059 + __set_fs(x);
27060 +}
27061 +EXPORT_SYMBOL(set_fs);
27062 +#endif
27063 diff --git a/arch/x86/lib/usercopy_64.c b/arch/x86/lib/usercopy_64.c
27064 index 906fea3..ee8a097 100644
27065 --- a/arch/x86/lib/usercopy_64.c
27066 +++ b/arch/x86/lib/usercopy_64.c
27067 @@ -39,7 +39,7 @@ unsigned long __clear_user(void __user *addr, unsigned long size)
27068 _ASM_EXTABLE(0b,3b)
27069 _ASM_EXTABLE(1b,2b)
27070 : [size8] "=&c"(size), [dst] "=&D" (__d0)
27071 - : [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(addr),
27072 + : [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(____m(addr)),
27073 [zero] "r" (0UL), [eight] "r" (8UL));
27074 clac();
27075 return size;
27076 @@ -54,12 +54,11 @@ unsigned long clear_user(void __user *to, unsigned long n)
27077 }
27078 EXPORT_SYMBOL(clear_user);
27079
27080 -unsigned long copy_in_user(void __user *to, const void __user *from, unsigned len)
27081 +unsigned long copy_in_user(void __user *to, const void __user *from, unsigned long len)
27082 {
27083 - if (access_ok(VERIFY_WRITE, to, len) && access_ok(VERIFY_READ, from, len)) {
27084 - return copy_user_generic((__force void *)to, (__force void *)from, len);
27085 - }
27086 - return len;
27087 + if (access_ok(VERIFY_WRITE, to, len) && access_ok(VERIFY_READ, from, len))
27088 + return copy_user_generic((void __force_kernel *)____m(to), (void __force_kernel *)____m(from), len);
27089 + return len;
27090 }
27091 EXPORT_SYMBOL(copy_in_user);
27092
27093 @@ -69,7 +68,7 @@ EXPORT_SYMBOL(copy_in_user);
27094 * it is not necessary to optimize tail handling.
27095 */
27096 unsigned long
27097 -copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest)
27098 +copy_user_handle_tail(char __user *to, char __user *from, unsigned long len, unsigned zerorest)
27099 {
27100 char c;
27101 unsigned zero_len;
27102 @@ -87,3 +86,15 @@ copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest)
27103 clac();
27104 return len;
27105 }
27106 +
27107 +void copy_from_user_overflow(void)
27108 +{
27109 + WARN(1, "Buffer overflow detected!\n");
27110 +}
27111 +EXPORT_SYMBOL(copy_from_user_overflow);
27112 +
27113 +void copy_to_user_overflow(void)
27114 +{
27115 + WARN(1, "Buffer overflow detected!\n");
27116 +}
27117 +EXPORT_SYMBOL(copy_to_user_overflow);
27118 diff --git a/arch/x86/mm/extable.c b/arch/x86/mm/extable.c
27119 index 903ec1e..c4166b2 100644
27120 --- a/arch/x86/mm/extable.c
27121 +++ b/arch/x86/mm/extable.c
27122 @@ -6,12 +6,24 @@
27123 static inline unsigned long
27124 ex_insn_addr(const struct exception_table_entry *x)
27125 {
27126 - return (unsigned long)&x->insn + x->insn;
27127 + unsigned long reloc = 0;
27128 +
27129 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
27130 + reloc = ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
27131 +#endif
27132 +
27133 + return (unsigned long)&x->insn + x->insn + reloc;
27134 }
27135 static inline unsigned long
27136 ex_fixup_addr(const struct exception_table_entry *x)
27137 {
27138 - return (unsigned long)&x->fixup + x->fixup;
27139 + unsigned long reloc = 0;
27140 +
27141 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
27142 + reloc = ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
27143 +#endif
27144 +
27145 + return (unsigned long)&x->fixup + x->fixup + reloc;
27146 }
27147
27148 int fixup_exception(struct pt_regs *regs)
27149 @@ -20,7 +32,7 @@ int fixup_exception(struct pt_regs *regs)
27150 unsigned long new_ip;
27151
27152 #ifdef CONFIG_PNPBIOS
27153 - if (unlikely(SEGMENT_IS_PNP_CODE(regs->cs))) {
27154 + if (unlikely(!v8086_mode(regs) && SEGMENT_IS_PNP_CODE(regs->cs))) {
27155 extern u32 pnp_bios_fault_eip, pnp_bios_fault_esp;
27156 extern u32 pnp_bios_is_utter_crap;
27157 pnp_bios_is_utter_crap = 1;
27158 @@ -145,6 +157,13 @@ void sort_extable(struct exception_table_entry *start,
27159 i += 4;
27160 p->fixup -= i;
27161 i += 4;
27162 +
27163 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
27164 + BUILD_BUG_ON(!IS_ENABLED(CONFIG_BUILDTIME_EXTABLE_SORT));
27165 + p->insn -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
27166 + p->fixup -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
27167 +#endif
27168 +
27169 }
27170 }
27171
27172 diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
27173 index 0e88336..2bb9777 100644
27174 --- a/arch/x86/mm/fault.c
27175 +++ b/arch/x86/mm/fault.c
27176 @@ -13,12 +13,19 @@
27177 #include <linux/perf_event.h> /* perf_sw_event */
27178 #include <linux/hugetlb.h> /* hstate_index_to_shift */
27179 #include <linux/prefetch.h> /* prefetchw */
27180 +#include <linux/unistd.h>
27181 +#include <linux/compiler.h>
27182
27183 #include <asm/traps.h> /* dotraplinkage, ... */
27184 #include <asm/pgalloc.h> /* pgd_*(), ... */
27185 #include <asm/kmemcheck.h> /* kmemcheck_*(), ... */
27186 #include <asm/fixmap.h> /* VSYSCALL_START */
27187 #include <asm/context_tracking.h> /* exception_enter(), ... */
27188 +#include <asm/tlbflush.h>
27189 +
27190 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
27191 +#include <asm/stacktrace.h>
27192 +#endif
27193
27194 /*
27195 * Page fault error code bits:
27196 @@ -56,7 +63,7 @@ static inline int __kprobes notify_page_fault(struct pt_regs *regs)
27197 int ret = 0;
27198
27199 /* kprobe_running() needs smp_processor_id() */
27200 - if (kprobes_built_in() && !user_mode_vm(regs)) {
27201 + if (kprobes_built_in() && !user_mode(regs)) {
27202 preempt_disable();
27203 if (kprobe_running() && kprobe_fault_handler(regs, 14))
27204 ret = 1;
27205 @@ -117,7 +124,10 @@ check_prefetch_opcode(struct pt_regs *regs, unsigned char *instr,
27206 return !instr_lo || (instr_lo>>1) == 1;
27207 case 0x00:
27208 /* Prefetch instruction is 0x0F0D or 0x0F18 */
27209 - if (probe_kernel_address(instr, opcode))
27210 + if (user_mode(regs)) {
27211 + if (__copy_from_user_inatomic(&opcode, (unsigned char __force_user *)(instr), 1))
27212 + return 0;
27213 + } else if (probe_kernel_address(instr, opcode))
27214 return 0;
27215
27216 *prefetch = (instr_lo == 0xF) &&
27217 @@ -151,7 +161,10 @@ is_prefetch(struct pt_regs *regs, unsigned long error_code, unsigned long addr)
27218 while (instr < max_instr) {
27219 unsigned char opcode;
27220
27221 - if (probe_kernel_address(instr, opcode))
27222 + if (user_mode(regs)) {
27223 + if (__copy_from_user_inatomic(&opcode, (unsigned char __force_user *)(instr), 1))
27224 + break;
27225 + } else if (probe_kernel_address(instr, opcode))
27226 break;
27227
27228 instr++;
27229 @@ -182,6 +195,34 @@ force_sig_info_fault(int si_signo, int si_code, unsigned long address,
27230 force_sig_info(si_signo, &info, tsk);
27231 }
27232
27233 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
27234 +static bool pax_is_fetch_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address);
27235 +#endif
27236 +
27237 +#ifdef CONFIG_PAX_EMUTRAMP
27238 +static int pax_handle_fetch_fault(struct pt_regs *regs);
27239 +#endif
27240 +
27241 +#ifdef CONFIG_PAX_PAGEEXEC
27242 +static inline pmd_t * pax_get_pmd(struct mm_struct *mm, unsigned long address)
27243 +{
27244 + pgd_t *pgd;
27245 + pud_t *pud;
27246 + pmd_t *pmd;
27247 +
27248 + pgd = pgd_offset(mm, address);
27249 + if (!pgd_present(*pgd))
27250 + return NULL;
27251 + pud = pud_offset(pgd, address);
27252 + if (!pud_present(*pud))
27253 + return NULL;
27254 + pmd = pmd_offset(pud, address);
27255 + if (!pmd_present(*pmd))
27256 + return NULL;
27257 + return pmd;
27258 +}
27259 +#endif
27260 +
27261 DEFINE_SPINLOCK(pgd_lock);
27262 LIST_HEAD(pgd_list);
27263
27264 @@ -232,10 +273,22 @@ void vmalloc_sync_all(void)
27265 for (address = VMALLOC_START & PMD_MASK;
27266 address >= TASK_SIZE && address < FIXADDR_TOP;
27267 address += PMD_SIZE) {
27268 +
27269 +#ifdef CONFIG_PAX_PER_CPU_PGD
27270 + unsigned long cpu;
27271 +#else
27272 struct page *page;
27273 +#endif
27274
27275 spin_lock(&pgd_lock);
27276 +
27277 +#ifdef CONFIG_PAX_PER_CPU_PGD
27278 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
27279 + pgd_t *pgd = get_cpu_pgd(cpu);
27280 + pmd_t *ret;
27281 +#else
27282 list_for_each_entry(page, &pgd_list, lru) {
27283 + pgd_t *pgd;
27284 spinlock_t *pgt_lock;
27285 pmd_t *ret;
27286
27287 @@ -243,8 +296,14 @@ void vmalloc_sync_all(void)
27288 pgt_lock = &pgd_page_get_mm(page)->page_table_lock;
27289
27290 spin_lock(pgt_lock);
27291 - ret = vmalloc_sync_one(page_address(page), address);
27292 + pgd = page_address(page);
27293 +#endif
27294 +
27295 + ret = vmalloc_sync_one(pgd, address);
27296 +
27297 +#ifndef CONFIG_PAX_PER_CPU_PGD
27298 spin_unlock(pgt_lock);
27299 +#endif
27300
27301 if (!ret)
27302 break;
27303 @@ -278,6 +337,11 @@ static noinline __kprobes int vmalloc_fault(unsigned long address)
27304 * an interrupt in the middle of a task switch..
27305 */
27306 pgd_paddr = read_cr3();
27307 +
27308 +#ifdef CONFIG_PAX_PER_CPU_PGD
27309 + BUG_ON(__pa(get_cpu_pgd(smp_processor_id())) != (pgd_paddr & PHYSICAL_PAGE_MASK));
27310 +#endif
27311 +
27312 pmd_k = vmalloc_sync_one(__va(pgd_paddr), address);
27313 if (!pmd_k)
27314 return -1;
27315 @@ -373,7 +437,14 @@ static noinline __kprobes int vmalloc_fault(unsigned long address)
27316 * happen within a race in page table update. In the later
27317 * case just flush:
27318 */
27319 +
27320 +#ifdef CONFIG_PAX_PER_CPU_PGD
27321 + BUG_ON(__pa(get_cpu_pgd(smp_processor_id())) != (read_cr3() & PHYSICAL_PAGE_MASK));
27322 + pgd = pgd_offset_cpu(smp_processor_id(), address);
27323 +#else
27324 pgd = pgd_offset(current->active_mm, address);
27325 +#endif
27326 +
27327 pgd_ref = pgd_offset_k(address);
27328 if (pgd_none(*pgd_ref))
27329 return -1;
27330 @@ -543,7 +614,7 @@ static int is_errata93(struct pt_regs *regs, unsigned long address)
27331 static int is_errata100(struct pt_regs *regs, unsigned long address)
27332 {
27333 #ifdef CONFIG_X86_64
27334 - if ((regs->cs == __USER32_CS || (regs->cs & (1<<2))) && (address >> 32))
27335 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT)) && (address >> 32))
27336 return 1;
27337 #endif
27338 return 0;
27339 @@ -570,7 +641,7 @@ static int is_f00f_bug(struct pt_regs *regs, unsigned long address)
27340 }
27341
27342 static const char nx_warning[] = KERN_CRIT
27343 -"kernel tried to execute NX-protected page - exploit attempt? (uid: %d)\n";
27344 +"kernel tried to execute NX-protected page - exploit attempt? (uid: %d, task: %s, pid: %d)\n";
27345
27346 static void
27347 show_fault_oops(struct pt_regs *regs, unsigned long error_code,
27348 @@ -579,15 +650,27 @@ show_fault_oops(struct pt_regs *regs, unsigned long error_code,
27349 if (!oops_may_print())
27350 return;
27351
27352 - if (error_code & PF_INSTR) {
27353 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR)) {
27354 unsigned int level;
27355
27356 pte_t *pte = lookup_address(address, &level);
27357
27358 if (pte && pte_present(*pte) && !pte_exec(*pte))
27359 - printk(nx_warning, from_kuid(&init_user_ns, current_uid()));
27360 + printk(nx_warning, from_kuid_munged(&init_user_ns, current_uid()), current->comm, task_pid_nr(current));
27361 }
27362
27363 +#ifdef CONFIG_PAX_KERNEXEC
27364 + if (init_mm.start_code <= address && address < init_mm.end_code) {
27365 + if (current->signal->curr_ip)
27366 + printk(KERN_ERR "PAX: From %pI4: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n",
27367 + &current->signal->curr_ip, current->comm, task_pid_nr(current),
27368 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
27369 + else
27370 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n", current->comm, task_pid_nr(current),
27371 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
27372 + }
27373 +#endif
27374 +
27375 printk(KERN_ALERT "BUG: unable to handle kernel ");
27376 if (address < PAGE_SIZE)
27377 printk(KERN_CONT "NULL pointer dereference");
27378 @@ -750,6 +833,22 @@ __bad_area_nosemaphore(struct pt_regs *regs, unsigned long error_code,
27379 return;
27380 }
27381 #endif
27382 +
27383 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
27384 + if (pax_is_fetch_fault(regs, error_code, address)) {
27385 +
27386 +#ifdef CONFIG_PAX_EMUTRAMP
27387 + switch (pax_handle_fetch_fault(regs)) {
27388 + case 2:
27389 + return;
27390 + }
27391 +#endif
27392 +
27393 + pax_report_fault(regs, (void *)regs->ip, (void *)regs->sp);
27394 + do_group_exit(SIGKILL);
27395 + }
27396 +#endif
27397 +
27398 /* Kernel addresses are always protection faults: */
27399 if (address >= TASK_SIZE)
27400 error_code |= PF_PROT;
27401 @@ -835,7 +934,7 @@ do_sigbus(struct pt_regs *regs, unsigned long error_code, unsigned long address,
27402 if (fault & (VM_FAULT_HWPOISON|VM_FAULT_HWPOISON_LARGE)) {
27403 printk(KERN_ERR
27404 "MCE: Killing %s:%d due to hardware memory corruption fault at %lx\n",
27405 - tsk->comm, tsk->pid, address);
27406 + tsk->comm, task_pid_nr(tsk), address);
27407 code = BUS_MCEERR_AR;
27408 }
27409 #endif
27410 @@ -898,6 +997,99 @@ static int spurious_fault_check(unsigned long error_code, pte_t *pte)
27411 return 1;
27412 }
27413
27414 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
27415 +static int pax_handle_pageexec_fault(struct pt_regs *regs, struct mm_struct *mm, unsigned long address, unsigned long error_code)
27416 +{
27417 + pte_t *pte;
27418 + pmd_t *pmd;
27419 + spinlock_t *ptl;
27420 + unsigned char pte_mask;
27421 +
27422 + if ((__supported_pte_mask & _PAGE_NX) || (error_code & (PF_PROT|PF_USER)) != (PF_PROT|PF_USER) || v8086_mode(regs) ||
27423 + !(mm->pax_flags & MF_PAX_PAGEEXEC))
27424 + return 0;
27425 +
27426 + /* PaX: it's our fault, let's handle it if we can */
27427 +
27428 + /* PaX: take a look at read faults before acquiring any locks */
27429 + if (unlikely(!(error_code & PF_WRITE) && (regs->ip == address))) {
27430 + /* instruction fetch attempt from a protected page in user mode */
27431 + up_read(&mm->mmap_sem);
27432 +
27433 +#ifdef CONFIG_PAX_EMUTRAMP
27434 + switch (pax_handle_fetch_fault(regs)) {
27435 + case 2:
27436 + return 1;
27437 + }
27438 +#endif
27439 +
27440 + pax_report_fault(regs, (void *)regs->ip, (void *)regs->sp);
27441 + do_group_exit(SIGKILL);
27442 + }
27443 +
27444 + pmd = pax_get_pmd(mm, address);
27445 + if (unlikely(!pmd))
27446 + return 0;
27447 +
27448 + pte = pte_offset_map_lock(mm, pmd, address, &ptl);
27449 + if (unlikely(!(pte_val(*pte) & _PAGE_PRESENT) || pte_user(*pte))) {
27450 + pte_unmap_unlock(pte, ptl);
27451 + return 0;
27452 + }
27453 +
27454 + if (unlikely((error_code & PF_WRITE) && !pte_write(*pte))) {
27455 + /* write attempt to a protected page in user mode */
27456 + pte_unmap_unlock(pte, ptl);
27457 + return 0;
27458 + }
27459 +
27460 +#ifdef CONFIG_SMP
27461 + if (likely(address > get_limit(regs->cs) && cpu_isset(smp_processor_id(), mm->context.cpu_user_cs_mask)))
27462 +#else
27463 + if (likely(address > get_limit(regs->cs)))
27464 +#endif
27465 + {
27466 + set_pte(pte, pte_mkread(*pte));
27467 + __flush_tlb_one(address);
27468 + pte_unmap_unlock(pte, ptl);
27469 + up_read(&mm->mmap_sem);
27470 + return 1;
27471 + }
27472 +
27473 + pte_mask = _PAGE_ACCESSED | _PAGE_USER | ((error_code & PF_WRITE) << (_PAGE_BIT_DIRTY-1));
27474 +
27475 + /*
27476 + * PaX: fill DTLB with user rights and retry
27477 + */
27478 + __asm__ __volatile__ (
27479 + "orb %2,(%1)\n"
27480 +#if defined(CONFIG_M586) || defined(CONFIG_M586TSC)
27481 +/*
27482 + * PaX: let this uncommented 'invlpg' remind us on the behaviour of Intel's
27483 + * (and AMD's) TLBs. namely, they do not cache PTEs that would raise *any*
27484 + * page fault when examined during a TLB load attempt. this is true not only
27485 + * for PTEs holding a non-present entry but also present entries that will
27486 + * raise a page fault (such as those set up by PaX, or the copy-on-write
27487 + * mechanism). in effect it means that we do *not* need to flush the TLBs
27488 + * for our target pages since their PTEs are simply not in the TLBs at all.
27489 +
27490 + * the best thing in omitting it is that we gain around 15-20% speed in the
27491 + * fast path of the page fault handler and can get rid of tracing since we
27492 + * can no longer flush unintended entries.
27493 + */
27494 + "invlpg (%0)\n"
27495 +#endif
27496 + __copyuser_seg"testb $0,(%0)\n"
27497 + "xorb %3,(%1)\n"
27498 + :
27499 + : "r" (address), "r" (pte), "q" (pte_mask), "i" (_PAGE_USER)
27500 + : "memory", "cc");
27501 + pte_unmap_unlock(pte, ptl);
27502 + up_read(&mm->mmap_sem);
27503 + return 1;
27504 +}
27505 +#endif
27506 +
27507 /*
27508 * Handle a spurious fault caused by a stale TLB entry.
27509 *
27510 @@ -964,6 +1156,9 @@ int show_unhandled_signals = 1;
27511 static inline int
27512 access_error(unsigned long error_code, struct vm_area_struct *vma)
27513 {
27514 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR) && !(vma->vm_flags & VM_EXEC))
27515 + return 1;
27516 +
27517 if (error_code & PF_WRITE) {
27518 /* write, present and write, not present: */
27519 if (unlikely(!(vma->vm_flags & VM_WRITE)))
27520 @@ -992,7 +1187,7 @@ static inline bool smap_violation(int error_code, struct pt_regs *regs)
27521 if (error_code & PF_USER)
27522 return false;
27523
27524 - if (!user_mode_vm(regs) && (regs->flags & X86_EFLAGS_AC))
27525 + if (!user_mode(regs) && (regs->flags & X86_EFLAGS_AC))
27526 return false;
27527
27528 return true;
27529 @@ -1008,18 +1203,33 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code)
27530 {
27531 struct vm_area_struct *vma;
27532 struct task_struct *tsk;
27533 - unsigned long address;
27534 struct mm_struct *mm;
27535 int fault;
27536 int write = error_code & PF_WRITE;
27537 unsigned int flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE |
27538 (write ? FAULT_FLAG_WRITE : 0);
27539
27540 - tsk = current;
27541 - mm = tsk->mm;
27542 -
27543 /* Get the faulting address: */
27544 - address = read_cr2();
27545 + unsigned long address = read_cr2();
27546 +
27547 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
27548 + if (!user_mode(regs) && address < 2 * pax_user_shadow_base) {
27549 + if (!search_exception_tables(regs->ip)) {
27550 + printk(KERN_ERR "PAX: please report this to pageexec@freemail.hu\n");
27551 + bad_area_nosemaphore(regs, error_code, address);
27552 + return;
27553 + }
27554 + if (address < pax_user_shadow_base) {
27555 + printk(KERN_ERR "PAX: please report this to pageexec@freemail.hu\n");
27556 + printk(KERN_ERR "PAX: faulting IP: %pS\n", (void *)regs->ip);
27557 + show_trace_log_lvl(NULL, NULL, (void *)regs->sp, regs->bp, KERN_ERR);
27558 + } else
27559 + address -= pax_user_shadow_base;
27560 + }
27561 +#endif
27562 +
27563 + tsk = current;
27564 + mm = tsk->mm;
27565
27566 /*
27567 * Detect and handle instructions that would cause a page fault for
27568 @@ -1080,7 +1290,7 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code)
27569 * User-mode registers count as a user access even for any
27570 * potential system fault or CPU buglet:
27571 */
27572 - if (user_mode_vm(regs)) {
27573 + if (user_mode(regs)) {
27574 local_irq_enable();
27575 error_code |= PF_USER;
27576 } else {
27577 @@ -1142,6 +1352,11 @@ retry:
27578 might_sleep();
27579 }
27580
27581 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
27582 + if (pax_handle_pageexec_fault(regs, mm, address, error_code))
27583 + return;
27584 +#endif
27585 +
27586 vma = find_vma(mm, address);
27587 if (unlikely(!vma)) {
27588 bad_area(regs, error_code, address);
27589 @@ -1153,18 +1368,24 @@ retry:
27590 bad_area(regs, error_code, address);
27591 return;
27592 }
27593 - if (error_code & PF_USER) {
27594 - /*
27595 - * Accessing the stack below %sp is always a bug.
27596 - * The large cushion allows instructions like enter
27597 - * and pusha to work. ("enter $65535, $31" pushes
27598 - * 32 pointers and then decrements %sp by 65535.)
27599 - */
27600 - if (unlikely(address + 65536 + 32 * sizeof(unsigned long) < regs->sp)) {
27601 - bad_area(regs, error_code, address);
27602 - return;
27603 - }
27604 + /*
27605 + * Accessing the stack below %sp is always a bug.
27606 + * The large cushion allows instructions like enter
27607 + * and pusha to work. ("enter $65535, $31" pushes
27608 + * 32 pointers and then decrements %sp by 65535.)
27609 + */
27610 + if (unlikely(address + 65536 + 32 * sizeof(unsigned long) < task_pt_regs(tsk)->sp)) {
27611 + bad_area(regs, error_code, address);
27612 + return;
27613 }
27614 +
27615 +#ifdef CONFIG_PAX_SEGMEXEC
27616 + if (unlikely((mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_end - SEGMEXEC_TASK_SIZE - 1 < address - SEGMEXEC_TASK_SIZE - 1)) {
27617 + bad_area(regs, error_code, address);
27618 + return;
27619 + }
27620 +#endif
27621 +
27622 if (unlikely(expand_stack(vma, address))) {
27623 bad_area(regs, error_code, address);
27624 return;
27625 @@ -1228,3 +1449,292 @@ do_page_fault(struct pt_regs *regs, unsigned long error_code)
27626 __do_page_fault(regs, error_code);
27627 exception_exit(regs);
27628 }
27629 +
27630 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
27631 +static bool pax_is_fetch_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address)
27632 +{
27633 + struct mm_struct *mm = current->mm;
27634 + unsigned long ip = regs->ip;
27635 +
27636 + if (v8086_mode(regs))
27637 + ip = ((regs->cs & 0xffff) << 4) + (ip & 0xffff);
27638 +
27639 +#ifdef CONFIG_PAX_PAGEEXEC
27640 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
27641 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR))
27642 + return true;
27643 + if (!(error_code & (PF_PROT | PF_WRITE)) && ip == address)
27644 + return true;
27645 + return false;
27646 + }
27647 +#endif
27648 +
27649 +#ifdef CONFIG_PAX_SEGMEXEC
27650 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
27651 + if (!(error_code & (PF_PROT | PF_WRITE)) && (ip + SEGMEXEC_TASK_SIZE == address))
27652 + return true;
27653 + return false;
27654 + }
27655 +#endif
27656 +
27657 + return false;
27658 +}
27659 +#endif
27660 +
27661 +#ifdef CONFIG_PAX_EMUTRAMP
27662 +static int pax_handle_fetch_fault_32(struct pt_regs *regs)
27663 +{
27664 + int err;
27665 +
27666 + do { /* PaX: libffi trampoline emulation */
27667 + unsigned char mov, jmp;
27668 + unsigned int addr1, addr2;
27669 +
27670 +#ifdef CONFIG_X86_64
27671 + if ((regs->ip + 9) >> 32)
27672 + break;
27673 +#endif
27674 +
27675 + err = get_user(mov, (unsigned char __user *)regs->ip);
27676 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
27677 + err |= get_user(jmp, (unsigned char __user *)(regs->ip + 5));
27678 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
27679 +
27680 + if (err)
27681 + break;
27682 +
27683 + if (mov == 0xB8 && jmp == 0xE9) {
27684 + regs->ax = addr1;
27685 + regs->ip = (unsigned int)(regs->ip + addr2 + 10);
27686 + return 2;
27687 + }
27688 + } while (0);
27689 +
27690 + do { /* PaX: gcc trampoline emulation #1 */
27691 + unsigned char mov1, mov2;
27692 + unsigned short jmp;
27693 + unsigned int addr1, addr2;
27694 +
27695 +#ifdef CONFIG_X86_64
27696 + if ((regs->ip + 11) >> 32)
27697 + break;
27698 +#endif
27699 +
27700 + err = get_user(mov1, (unsigned char __user *)regs->ip);
27701 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
27702 + err |= get_user(mov2, (unsigned char __user *)(regs->ip + 5));
27703 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
27704 + err |= get_user(jmp, (unsigned short __user *)(regs->ip + 10));
27705 +
27706 + if (err)
27707 + break;
27708 +
27709 + if (mov1 == 0xB9 && mov2 == 0xB8 && jmp == 0xE0FF) {
27710 + regs->cx = addr1;
27711 + regs->ax = addr2;
27712 + regs->ip = addr2;
27713 + return 2;
27714 + }
27715 + } while (0);
27716 +
27717 + do { /* PaX: gcc trampoline emulation #2 */
27718 + unsigned char mov, jmp;
27719 + unsigned int addr1, addr2;
27720 +
27721 +#ifdef CONFIG_X86_64
27722 + if ((regs->ip + 9) >> 32)
27723 + break;
27724 +#endif
27725 +
27726 + err = get_user(mov, (unsigned char __user *)regs->ip);
27727 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
27728 + err |= get_user(jmp, (unsigned char __user *)(regs->ip + 5));
27729 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
27730 +
27731 + if (err)
27732 + break;
27733 +
27734 + if (mov == 0xB9 && jmp == 0xE9) {
27735 + regs->cx = addr1;
27736 + regs->ip = (unsigned int)(regs->ip + addr2 + 10);
27737 + return 2;
27738 + }
27739 + } while (0);
27740 +
27741 + return 1; /* PaX in action */
27742 +}
27743 +
27744 +#ifdef CONFIG_X86_64
27745 +static int pax_handle_fetch_fault_64(struct pt_regs *regs)
27746 +{
27747 + int err;
27748 +
27749 + do { /* PaX: libffi trampoline emulation */
27750 + unsigned short mov1, mov2, jmp1;
27751 + unsigned char stcclc, jmp2;
27752 + unsigned long addr1, addr2;
27753 +
27754 + err = get_user(mov1, (unsigned short __user *)regs->ip);
27755 + err |= get_user(addr1, (unsigned long __user *)(regs->ip + 2));
27756 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 10));
27757 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 12));
27758 + err |= get_user(stcclc, (unsigned char __user *)(regs->ip + 20));
27759 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 21));
27760 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 23));
27761 +
27762 + if (err)
27763 + break;
27764 +
27765 + if (mov1 == 0xBB49 && mov2 == 0xBA49 && (stcclc == 0xF8 || stcclc == 0xF9) && jmp1 == 0xFF49 && jmp2 == 0xE3) {
27766 + regs->r11 = addr1;
27767 + regs->r10 = addr2;
27768 + if (stcclc == 0xF8)
27769 + regs->flags &= ~X86_EFLAGS_CF;
27770 + else
27771 + regs->flags |= X86_EFLAGS_CF;
27772 + regs->ip = addr1;
27773 + return 2;
27774 + }
27775 + } while (0);
27776 +
27777 + do { /* PaX: gcc trampoline emulation #1 */
27778 + unsigned short mov1, mov2, jmp1;
27779 + unsigned char jmp2;
27780 + unsigned int addr1;
27781 + unsigned long addr2;
27782 +
27783 + err = get_user(mov1, (unsigned short __user *)regs->ip);
27784 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 2));
27785 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 6));
27786 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 8));
27787 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 16));
27788 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 18));
27789 +
27790 + if (err)
27791 + break;
27792 +
27793 + if (mov1 == 0xBB41 && mov2 == 0xBA49 && jmp1 == 0xFF49 && jmp2 == 0xE3) {
27794 + regs->r11 = addr1;
27795 + regs->r10 = addr2;
27796 + regs->ip = addr1;
27797 + return 2;
27798 + }
27799 + } while (0);
27800 +
27801 + do { /* PaX: gcc trampoline emulation #2 */
27802 + unsigned short mov1, mov2, jmp1;
27803 + unsigned char jmp2;
27804 + unsigned long addr1, addr2;
27805 +
27806 + err = get_user(mov1, (unsigned short __user *)regs->ip);
27807 + err |= get_user(addr1, (unsigned long __user *)(regs->ip + 2));
27808 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 10));
27809 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 12));
27810 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 20));
27811 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 22));
27812 +
27813 + if (err)
27814 + break;
27815 +
27816 + if (mov1 == 0xBB49 && mov2 == 0xBA49 && jmp1 == 0xFF49 && jmp2 == 0xE3) {
27817 + regs->r11 = addr1;
27818 + regs->r10 = addr2;
27819 + regs->ip = addr1;
27820 + return 2;
27821 + }
27822 + } while (0);
27823 +
27824 + return 1; /* PaX in action */
27825 +}
27826 +#endif
27827 +
27828 +/*
27829 + * PaX: decide what to do with offenders (regs->ip = fault address)
27830 + *
27831 + * returns 1 when task should be killed
27832 + * 2 when gcc trampoline was detected
27833 + */
27834 +static int pax_handle_fetch_fault(struct pt_regs *regs)
27835 +{
27836 + if (v8086_mode(regs))
27837 + return 1;
27838 +
27839 + if (!(current->mm->pax_flags & MF_PAX_EMUTRAMP))
27840 + return 1;
27841 +
27842 +#ifdef CONFIG_X86_32
27843 + return pax_handle_fetch_fault_32(regs);
27844 +#else
27845 + if (regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT))
27846 + return pax_handle_fetch_fault_32(regs);
27847 + else
27848 + return pax_handle_fetch_fault_64(regs);
27849 +#endif
27850 +}
27851 +#endif
27852 +
27853 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
27854 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
27855 +{
27856 + long i;
27857 +
27858 + printk(KERN_ERR "PAX: bytes at PC: ");
27859 + for (i = 0; i < 20; i++) {
27860 + unsigned char c;
27861 + if (get_user(c, (unsigned char __force_user *)pc+i))
27862 + printk(KERN_CONT "?? ");
27863 + else
27864 + printk(KERN_CONT "%02x ", c);
27865 + }
27866 + printk("\n");
27867 +
27868 + printk(KERN_ERR "PAX: bytes at SP-%lu: ", (unsigned long)sizeof(long));
27869 + for (i = -1; i < 80 / (long)sizeof(long); i++) {
27870 + unsigned long c;
27871 + if (get_user(c, (unsigned long __force_user *)sp+i)) {
27872 +#ifdef CONFIG_X86_32
27873 + printk(KERN_CONT "???????? ");
27874 +#else
27875 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT)))
27876 + printk(KERN_CONT "???????? ???????? ");
27877 + else
27878 + printk(KERN_CONT "???????????????? ");
27879 +#endif
27880 + } else {
27881 +#ifdef CONFIG_X86_64
27882 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT))) {
27883 + printk(KERN_CONT "%08x ", (unsigned int)c);
27884 + printk(KERN_CONT "%08x ", (unsigned int)(c >> 32));
27885 + } else
27886 +#endif
27887 + printk(KERN_CONT "%0*lx ", 2 * (int)sizeof(long), c);
27888 + }
27889 + }
27890 + printk("\n");
27891 +}
27892 +#endif
27893 +
27894 +/**
27895 + * probe_kernel_write(): safely attempt to write to a location
27896 + * @dst: address to write to
27897 + * @src: pointer to the data that shall be written
27898 + * @size: size of the data chunk
27899 + *
27900 + * Safely write to address @dst from the buffer at @src. If a kernel fault
27901 + * happens, handle that and return -EFAULT.
27902 + */
27903 +long notrace probe_kernel_write(void *dst, const void *src, size_t size)
27904 +{
27905 + long ret;
27906 + mm_segment_t old_fs = get_fs();
27907 +
27908 + set_fs(KERNEL_DS);
27909 + pagefault_disable();
27910 + pax_open_kernel();
27911 + ret = __copy_to_user_inatomic((void __force_user *)dst, src, size);
27912 + pax_close_kernel();
27913 + pagefault_enable();
27914 + set_fs(old_fs);
27915 +
27916 + return ret ? -EFAULT : 0;
27917 +}
27918 diff --git a/arch/x86/mm/gup.c b/arch/x86/mm/gup.c
27919 index dd74e46..7d26398 100644
27920 --- a/arch/x86/mm/gup.c
27921 +++ b/arch/x86/mm/gup.c
27922 @@ -255,7 +255,7 @@ int __get_user_pages_fast(unsigned long start, int nr_pages, int write,
27923 addr = start;
27924 len = (unsigned long) nr_pages << PAGE_SHIFT;
27925 end = start + len;
27926 - if (unlikely(!access_ok(write ? VERIFY_WRITE : VERIFY_READ,
27927 + if (unlikely(!__access_ok(write ? VERIFY_WRITE : VERIFY_READ,
27928 (void __user *)start, len)))
27929 return 0;
27930
27931 diff --git a/arch/x86/mm/highmem_32.c b/arch/x86/mm/highmem_32.c
27932 index 6f31ee5..8ee4164 100644
27933 --- a/arch/x86/mm/highmem_32.c
27934 +++ b/arch/x86/mm/highmem_32.c
27935 @@ -44,7 +44,11 @@ void *kmap_atomic_prot(struct page *page, pgprot_t prot)
27936 idx = type + KM_TYPE_NR*smp_processor_id();
27937 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
27938 BUG_ON(!pte_none(*(kmap_pte-idx)));
27939 +
27940 + pax_open_kernel();
27941 set_pte(kmap_pte-idx, mk_pte(page, prot));
27942 + pax_close_kernel();
27943 +
27944 arch_flush_lazy_mmu_mode();
27945
27946 return (void *)vaddr;
27947 diff --git a/arch/x86/mm/hugetlbpage.c b/arch/x86/mm/hugetlbpage.c
27948 index ae1aa71..d9bea75 100644
27949 --- a/arch/x86/mm/hugetlbpage.c
27950 +++ b/arch/x86/mm/hugetlbpage.c
27951 @@ -271,23 +271,30 @@ follow_huge_pud(struct mm_struct *mm, unsigned long address,
27952 #ifdef HAVE_ARCH_HUGETLB_UNMAPPED_AREA
27953 static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *file,
27954 unsigned long addr, unsigned long len,
27955 - unsigned long pgoff, unsigned long flags)
27956 + unsigned long pgoff, unsigned long flags, unsigned long offset)
27957 {
27958 struct hstate *h = hstate_file(file);
27959 struct vm_unmapped_area_info info;
27960 -
27961 +
27962 info.flags = 0;
27963 info.length = len;
27964 info.low_limit = TASK_UNMAPPED_BASE;
27965 +
27966 +#ifdef CONFIG_PAX_RANDMMAP
27967 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
27968 + info.low_limit += current->mm->delta_mmap;
27969 +#endif
27970 +
27971 info.high_limit = TASK_SIZE;
27972 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
27973 info.align_offset = 0;
27974 + info.threadstack_offset = offset;
27975 return vm_unmapped_area(&info);
27976 }
27977
27978 static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
27979 unsigned long addr0, unsigned long len,
27980 - unsigned long pgoff, unsigned long flags)
27981 + unsigned long pgoff, unsigned long flags, unsigned long offset)
27982 {
27983 struct hstate *h = hstate_file(file);
27984 struct vm_unmapped_area_info info;
27985 @@ -299,6 +306,7 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
27986 info.high_limit = current->mm->mmap_base;
27987 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
27988 info.align_offset = 0;
27989 + info.threadstack_offset = offset;
27990 addr = vm_unmapped_area(&info);
27991
27992 /*
27993 @@ -311,6 +319,12 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
27994 VM_BUG_ON(addr != -ENOMEM);
27995 info.flags = 0;
27996 info.low_limit = TASK_UNMAPPED_BASE;
27997 +
27998 +#ifdef CONFIG_PAX_RANDMMAP
27999 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
28000 + info.low_limit += current->mm->delta_mmap;
28001 +#endif
28002 +
28003 info.high_limit = TASK_SIZE;
28004 addr = vm_unmapped_area(&info);
28005 }
28006 @@ -325,10 +339,20 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
28007 struct hstate *h = hstate_file(file);
28008 struct mm_struct *mm = current->mm;
28009 struct vm_area_struct *vma;
28010 + unsigned long pax_task_size = TASK_SIZE;
28011 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
28012
28013 if (len & ~huge_page_mask(h))
28014 return -EINVAL;
28015 - if (len > TASK_SIZE)
28016 +
28017 +#ifdef CONFIG_PAX_SEGMEXEC
28018 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
28019 + pax_task_size = SEGMEXEC_TASK_SIZE;
28020 +#endif
28021 +
28022 + pax_task_size -= PAGE_SIZE;
28023 +
28024 + if (len > pax_task_size)
28025 return -ENOMEM;
28026
28027 if (flags & MAP_FIXED) {
28028 @@ -337,19 +361,22 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
28029 return addr;
28030 }
28031
28032 +#ifdef CONFIG_PAX_RANDMMAP
28033 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
28034 +#endif
28035 +
28036 if (addr) {
28037 addr = ALIGN(addr, huge_page_size(h));
28038 vma = find_vma(mm, addr);
28039 - if (TASK_SIZE - len >= addr &&
28040 - (!vma || addr + len <= vma->vm_start))
28041 + if (pax_task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
28042 return addr;
28043 }
28044 if (mm->get_unmapped_area == arch_get_unmapped_area)
28045 return hugetlb_get_unmapped_area_bottomup(file, addr, len,
28046 - pgoff, flags);
28047 + pgoff, flags, offset);
28048 else
28049 return hugetlb_get_unmapped_area_topdown(file, addr, len,
28050 - pgoff, flags);
28051 + pgoff, flags, offset);
28052 }
28053
28054 #endif /*HAVE_ARCH_HUGETLB_UNMAPPED_AREA*/
28055 diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
28056 index 59b7fc4..b1dd75f 100644
28057 --- a/arch/x86/mm/init.c
28058 +++ b/arch/x86/mm/init.c
28059 @@ -4,6 +4,7 @@
28060 #include <linux/swap.h>
28061 #include <linux/memblock.h>
28062 #include <linux/bootmem.h> /* for max_low_pfn */
28063 +#include <linux/tboot.h>
28064
28065 #include <asm/cacheflush.h>
28066 #include <asm/e820.h>
28067 @@ -17,6 +18,8 @@
28068 #include <asm/proto.h>
28069 #include <asm/dma.h> /* for MAX_DMA_PFN */
28070 #include <asm/microcode.h>
28071 +#include <asm/desc.h>
28072 +#include <asm/bios_ebda.h>
28073
28074 #include "mm_internal.h"
28075
28076 @@ -464,10 +467,40 @@ void __init init_mem_mapping(void)
28077 * Access has to be given to non-kernel-ram areas as well, these contain the PCI
28078 * mmio resources as well as potential bios/acpi data regions.
28079 */
28080 +
28081 +#ifdef CONFIG_GRKERNSEC_KMEM
28082 +static unsigned int ebda_start __read_only;
28083 +static unsigned int ebda_end __read_only;
28084 +#endif
28085 +
28086 int devmem_is_allowed(unsigned long pagenr)
28087 {
28088 - if (pagenr < 256)
28089 +#ifdef CONFIG_GRKERNSEC_KMEM
28090 + /* allow BDA */
28091 + if (!pagenr)
28092 return 1;
28093 + /* allow EBDA */
28094 + if (pagenr >= ebda_start && pagenr < ebda_end)
28095 + return 1;
28096 + /* if tboot is in use, allow access to its hardcoded serial log range */
28097 + if (tboot_enabled() && ((0x60000 >> PAGE_SHIFT) <= pagenr) && (pagenr < (0x68000 >> PAGE_SHIFT)))
28098 + return 1;
28099 +#else
28100 + if (!pagenr)
28101 + return 1;
28102 +#ifdef CONFIG_VM86
28103 + if (pagenr < (ISA_START_ADDRESS >> PAGE_SHIFT))
28104 + return 1;
28105 +#endif
28106 +#endif
28107 +
28108 + if ((ISA_START_ADDRESS >> PAGE_SHIFT) <= pagenr && pagenr < (ISA_END_ADDRESS >> PAGE_SHIFT))
28109 + return 1;
28110 +#ifdef CONFIG_GRKERNSEC_KMEM
28111 + /* throw out everything else below 1MB */
28112 + if (pagenr <= 256)
28113 + return 0;
28114 +#endif
28115 if (iomem_is_exclusive(pagenr << PAGE_SHIFT))
28116 return 0;
28117 if (!page_is_ram(pagenr))
28118 @@ -524,8 +557,117 @@ void free_init_pages(char *what, unsigned long begin, unsigned long end)
28119 #endif
28120 }
28121
28122 +#ifdef CONFIG_GRKERNSEC_KMEM
28123 +static inline void gr_init_ebda(void)
28124 +{
28125 + unsigned int ebda_addr;
28126 + unsigned int ebda_size = 0;
28127 +
28128 + ebda_addr = get_bios_ebda();
28129 + if (ebda_addr) {
28130 + ebda_size = *(unsigned char *)phys_to_virt(ebda_addr);
28131 + ebda_size <<= 10;
28132 + }
28133 + if (ebda_addr && ebda_size) {
28134 + ebda_start = ebda_addr >> PAGE_SHIFT;
28135 + ebda_end = min((unsigned int)PAGE_ALIGN(ebda_addr + ebda_size), (unsigned int)0xa0000) >> PAGE_SHIFT;
28136 + } else {
28137 + ebda_start = 0x9f000 >> PAGE_SHIFT;
28138 + ebda_end = 0xa0000 >> PAGE_SHIFT;
28139 + }
28140 +}
28141 +#else
28142 +static inline void gr_init_ebda(void) { }
28143 +#endif
28144 +
28145 void free_initmem(void)
28146 {
28147 +#ifdef CONFIG_PAX_KERNEXEC
28148 +#ifdef CONFIG_X86_32
28149 + /* PaX: limit KERNEL_CS to actual size */
28150 + unsigned long addr, limit;
28151 + struct desc_struct d;
28152 + int cpu;
28153 +#else
28154 + pgd_t *pgd;
28155 + pud_t *pud;
28156 + pmd_t *pmd;
28157 + unsigned long addr, end;
28158 +#endif
28159 +#endif
28160 +
28161 + gr_init_ebda();
28162 +
28163 +#ifdef CONFIG_PAX_KERNEXEC
28164 +#ifdef CONFIG_X86_32
28165 + limit = paravirt_enabled() ? ktva_ktla(0xffffffff) : (unsigned long)&_etext;
28166 + limit = (limit - 1UL) >> PAGE_SHIFT;
28167 +
28168 + memset(__LOAD_PHYSICAL_ADDR + PAGE_OFFSET, POISON_FREE_INITMEM, PAGE_SIZE);
28169 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
28170 + pack_descriptor(&d, get_desc_base(&get_cpu_gdt_table(cpu)[GDT_ENTRY_KERNEL_CS]), limit, 0x9B, 0xC);
28171 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_KERNEL_CS, &d, DESCTYPE_S);
28172 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_KERNEXEC_KERNEL_CS, &d, DESCTYPE_S);
28173 + }
28174 +
28175 + /* PaX: make KERNEL_CS read-only */
28176 + addr = PFN_ALIGN(ktla_ktva((unsigned long)&_text));
28177 + if (!paravirt_enabled())
28178 + set_memory_ro(addr, (PFN_ALIGN(_sdata) - addr) >> PAGE_SHIFT);
28179 +/*
28180 + for (addr = ktla_ktva((unsigned long)&_text); addr < (unsigned long)&_sdata; addr += PMD_SIZE) {
28181 + pgd = pgd_offset_k(addr);
28182 + pud = pud_offset(pgd, addr);
28183 + pmd = pmd_offset(pud, addr);
28184 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
28185 + }
28186 +*/
28187 +#ifdef CONFIG_X86_PAE
28188 + set_memory_nx(PFN_ALIGN(__init_begin), (PFN_ALIGN(__init_end) - PFN_ALIGN(__init_begin)) >> PAGE_SHIFT);
28189 +/*
28190 + for (addr = (unsigned long)&__init_begin; addr < (unsigned long)&__init_end; addr += PMD_SIZE) {
28191 + pgd = pgd_offset_k(addr);
28192 + pud = pud_offset(pgd, addr);
28193 + pmd = pmd_offset(pud, addr);
28194 + set_pmd(pmd, __pmd(pmd_val(*pmd) | (_PAGE_NX & __supported_pte_mask)));
28195 + }
28196 +*/
28197 +#endif
28198 +
28199 +#ifdef CONFIG_MODULES
28200 + set_memory_4k((unsigned long)MODULES_EXEC_VADDR, (MODULES_EXEC_END - MODULES_EXEC_VADDR) >> PAGE_SHIFT);
28201 +#endif
28202 +
28203 +#else
28204 + /* PaX: make kernel code/rodata read-only, rest non-executable */
28205 + for (addr = __START_KERNEL_map; addr < __START_KERNEL_map + KERNEL_IMAGE_SIZE; addr += PMD_SIZE) {
28206 + pgd = pgd_offset_k(addr);
28207 + pud = pud_offset(pgd, addr);
28208 + pmd = pmd_offset(pud, addr);
28209 + if (!pmd_present(*pmd))
28210 + continue;
28211 + if ((unsigned long)_text <= addr && addr < (unsigned long)_sdata)
28212 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
28213 + else
28214 + set_pmd(pmd, __pmd(pmd_val(*pmd) | (_PAGE_NX & __supported_pte_mask)));
28215 + }
28216 +
28217 + addr = (unsigned long)__va(__pa(__START_KERNEL_map));
28218 + end = addr + KERNEL_IMAGE_SIZE;
28219 + for (; addr < end; addr += PMD_SIZE) {
28220 + pgd = pgd_offset_k(addr);
28221 + pud = pud_offset(pgd, addr);
28222 + pmd = pmd_offset(pud, addr);
28223 + if (!pmd_present(*pmd))
28224 + continue;
28225 + if ((unsigned long)__va(__pa(_text)) <= addr && addr < (unsigned long)__va(__pa(_sdata)))
28226 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
28227 + }
28228 +#endif
28229 +
28230 + flush_tlb_all();
28231 +#endif
28232 +
28233 free_init_pages("unused kernel memory",
28234 (unsigned long)(&__init_begin),
28235 (unsigned long)(&__init_end));
28236 diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c
28237 index 2d19001..6a1046c 100644
28238 --- a/arch/x86/mm/init_32.c
28239 +++ b/arch/x86/mm/init_32.c
28240 @@ -62,33 +62,6 @@ static noinline int do_test_wp_bit(void);
28241 bool __read_mostly __vmalloc_start_set = false;
28242
28243 /*
28244 - * Creates a middle page table and puts a pointer to it in the
28245 - * given global directory entry. This only returns the gd entry
28246 - * in non-PAE compilation mode, since the middle layer is folded.
28247 - */
28248 -static pmd_t * __init one_md_table_init(pgd_t *pgd)
28249 -{
28250 - pud_t *pud;
28251 - pmd_t *pmd_table;
28252 -
28253 -#ifdef CONFIG_X86_PAE
28254 - if (!(pgd_val(*pgd) & _PAGE_PRESENT)) {
28255 - pmd_table = (pmd_t *)alloc_low_page();
28256 - paravirt_alloc_pmd(&init_mm, __pa(pmd_table) >> PAGE_SHIFT);
28257 - set_pgd(pgd, __pgd(__pa(pmd_table) | _PAGE_PRESENT));
28258 - pud = pud_offset(pgd, 0);
28259 - BUG_ON(pmd_table != pmd_offset(pud, 0));
28260 -
28261 - return pmd_table;
28262 - }
28263 -#endif
28264 - pud = pud_offset(pgd, 0);
28265 - pmd_table = pmd_offset(pud, 0);
28266 -
28267 - return pmd_table;
28268 -}
28269 -
28270 -/*
28271 * Create a page table and place a pointer to it in a middle page
28272 * directory entry:
28273 */
28274 @@ -98,13 +71,28 @@ static pte_t * __init one_page_table_init(pmd_t *pmd)
28275 pte_t *page_table = (pte_t *)alloc_low_page();
28276
28277 paravirt_alloc_pte(&init_mm, __pa(page_table) >> PAGE_SHIFT);
28278 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
28279 + set_pmd(pmd, __pmd(__pa(page_table) | _KERNPG_TABLE));
28280 +#else
28281 set_pmd(pmd, __pmd(__pa(page_table) | _PAGE_TABLE));
28282 +#endif
28283 BUG_ON(page_table != pte_offset_kernel(pmd, 0));
28284 }
28285
28286 return pte_offset_kernel(pmd, 0);
28287 }
28288
28289 +static pmd_t * __init one_md_table_init(pgd_t *pgd)
28290 +{
28291 + pud_t *pud;
28292 + pmd_t *pmd_table;
28293 +
28294 + pud = pud_offset(pgd, 0);
28295 + pmd_table = pmd_offset(pud, 0);
28296 +
28297 + return pmd_table;
28298 +}
28299 +
28300 pmd_t * __init populate_extra_pmd(unsigned long vaddr)
28301 {
28302 int pgd_idx = pgd_index(vaddr);
28303 @@ -208,6 +196,7 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
28304 int pgd_idx, pmd_idx;
28305 unsigned long vaddr;
28306 pgd_t *pgd;
28307 + pud_t *pud;
28308 pmd_t *pmd;
28309 pte_t *pte = NULL;
28310 unsigned long count = page_table_range_init_count(start, end);
28311 @@ -222,8 +211,13 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
28312 pgd = pgd_base + pgd_idx;
28313
28314 for ( ; (pgd_idx < PTRS_PER_PGD) && (vaddr != end); pgd++, pgd_idx++) {
28315 - pmd = one_md_table_init(pgd);
28316 - pmd = pmd + pmd_index(vaddr);
28317 + pud = pud_offset(pgd, vaddr);
28318 + pmd = pmd_offset(pud, vaddr);
28319 +
28320 +#ifdef CONFIG_X86_PAE
28321 + paravirt_alloc_pmd(&init_mm, __pa(pmd) >> PAGE_SHIFT);
28322 +#endif
28323 +
28324 for (; (pmd_idx < PTRS_PER_PMD) && (vaddr != end);
28325 pmd++, pmd_idx++) {
28326 pte = page_table_kmap_check(one_page_table_init(pmd),
28327 @@ -235,11 +229,20 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
28328 }
28329 }
28330
28331 -static inline int is_kernel_text(unsigned long addr)
28332 +static inline int is_kernel_text(unsigned long start, unsigned long end)
28333 {
28334 - if (addr >= (unsigned long)_text && addr <= (unsigned long)__init_end)
28335 - return 1;
28336 - return 0;
28337 + if ((start > ktla_ktva((unsigned long)_etext) ||
28338 + end <= ktla_ktva((unsigned long)_stext)) &&
28339 + (start > ktla_ktva((unsigned long)_einittext) ||
28340 + end <= ktla_ktva((unsigned long)_sinittext)) &&
28341 +
28342 +#ifdef CONFIG_ACPI_SLEEP
28343 + (start > (unsigned long)__va(acpi_wakeup_address) + 0x4000 || end <= (unsigned long)__va(acpi_wakeup_address)) &&
28344 +#endif
28345 +
28346 + (start > (unsigned long)__va(0xfffff) || end <= (unsigned long)__va(0xc0000)))
28347 + return 0;
28348 + return 1;
28349 }
28350
28351 /*
28352 @@ -256,9 +259,10 @@ kernel_physical_mapping_init(unsigned long start,
28353 unsigned long last_map_addr = end;
28354 unsigned long start_pfn, end_pfn;
28355 pgd_t *pgd_base = swapper_pg_dir;
28356 - int pgd_idx, pmd_idx, pte_ofs;
28357 + unsigned int pgd_idx, pmd_idx, pte_ofs;
28358 unsigned long pfn;
28359 pgd_t *pgd;
28360 + pud_t *pud;
28361 pmd_t *pmd;
28362 pte_t *pte;
28363 unsigned pages_2m, pages_4k;
28364 @@ -291,8 +295,13 @@ repeat:
28365 pfn = start_pfn;
28366 pgd_idx = pgd_index((pfn<<PAGE_SHIFT) + PAGE_OFFSET);
28367 pgd = pgd_base + pgd_idx;
28368 - for (; pgd_idx < PTRS_PER_PGD; pgd++, pgd_idx++) {
28369 - pmd = one_md_table_init(pgd);
28370 + for (; pgd_idx < PTRS_PER_PGD && pfn < max_low_pfn; pgd++, pgd_idx++) {
28371 + pud = pud_offset(pgd, 0);
28372 + pmd = pmd_offset(pud, 0);
28373 +
28374 +#ifdef CONFIG_X86_PAE
28375 + paravirt_alloc_pmd(&init_mm, __pa(pmd) >> PAGE_SHIFT);
28376 +#endif
28377
28378 if (pfn >= end_pfn)
28379 continue;
28380 @@ -304,14 +313,13 @@ repeat:
28381 #endif
28382 for (; pmd_idx < PTRS_PER_PMD && pfn < end_pfn;
28383 pmd++, pmd_idx++) {
28384 - unsigned int addr = pfn * PAGE_SIZE + PAGE_OFFSET;
28385 + unsigned long address = pfn * PAGE_SIZE + PAGE_OFFSET;
28386
28387 /*
28388 * Map with big pages if possible, otherwise
28389 * create normal page tables:
28390 */
28391 if (use_pse) {
28392 - unsigned int addr2;
28393 pgprot_t prot = PAGE_KERNEL_LARGE;
28394 /*
28395 * first pass will use the same initial
28396 @@ -322,11 +330,7 @@ repeat:
28397 _PAGE_PSE);
28398
28399 pfn &= PMD_MASK >> PAGE_SHIFT;
28400 - addr2 = (pfn + PTRS_PER_PTE-1) * PAGE_SIZE +
28401 - PAGE_OFFSET + PAGE_SIZE-1;
28402 -
28403 - if (is_kernel_text(addr) ||
28404 - is_kernel_text(addr2))
28405 + if (is_kernel_text(address, address + PMD_SIZE))
28406 prot = PAGE_KERNEL_LARGE_EXEC;
28407
28408 pages_2m++;
28409 @@ -343,7 +347,7 @@ repeat:
28410 pte_ofs = pte_index((pfn<<PAGE_SHIFT) + PAGE_OFFSET);
28411 pte += pte_ofs;
28412 for (; pte_ofs < PTRS_PER_PTE && pfn < end_pfn;
28413 - pte++, pfn++, pte_ofs++, addr += PAGE_SIZE) {
28414 + pte++, pfn++, pte_ofs++, address += PAGE_SIZE) {
28415 pgprot_t prot = PAGE_KERNEL;
28416 /*
28417 * first pass will use the same initial
28418 @@ -351,7 +355,7 @@ repeat:
28419 */
28420 pgprot_t init_prot = __pgprot(PTE_IDENT_ATTR);
28421
28422 - if (is_kernel_text(addr))
28423 + if (is_kernel_text(address, address + PAGE_SIZE))
28424 prot = PAGE_KERNEL_EXEC;
28425
28426 pages_4k++;
28427 @@ -482,7 +486,7 @@ void __init native_pagetable_init(void)
28428
28429 pud = pud_offset(pgd, va);
28430 pmd = pmd_offset(pud, va);
28431 - if (!pmd_present(*pmd))
28432 + if (!pmd_present(*pmd)) // PAX TODO || pmd_large(*pmd))
28433 break;
28434
28435 /* should not be large page here */
28436 @@ -540,12 +544,10 @@ void __init early_ioremap_page_table_range_init(void)
28437
28438 static void __init pagetable_init(void)
28439 {
28440 - pgd_t *pgd_base = swapper_pg_dir;
28441 -
28442 - permanent_kmaps_init(pgd_base);
28443 + permanent_kmaps_init(swapper_pg_dir);
28444 }
28445
28446 -pteval_t __supported_pte_mask __read_mostly = ~(_PAGE_NX | _PAGE_GLOBAL | _PAGE_IOMAP);
28447 +pteval_t __supported_pte_mask __read_only = ~(_PAGE_NX | _PAGE_GLOBAL | _PAGE_IOMAP);
28448 EXPORT_SYMBOL_GPL(__supported_pte_mask);
28449
28450 /* user-defined highmem size */
28451 @@ -752,6 +754,12 @@ void __init mem_init(void)
28452
28453 pci_iommu_alloc();
28454
28455 +#ifdef CONFIG_PAX_PER_CPU_PGD
28456 + clone_pgd_range(get_cpu_pgd(0) + KERNEL_PGD_BOUNDARY,
28457 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
28458 + KERNEL_PGD_PTRS);
28459 +#endif
28460 +
28461 #ifdef CONFIG_FLATMEM
28462 BUG_ON(!mem_map);
28463 #endif
28464 @@ -780,7 +788,7 @@ void __init mem_init(void)
28465 after_bootmem = 1;
28466
28467 codesize = (unsigned long) &_etext - (unsigned long) &_text;
28468 - datasize = (unsigned long) &_edata - (unsigned long) &_etext;
28469 + datasize = (unsigned long) &_edata - (unsigned long) &_sdata;
28470 initsize = (unsigned long) &__init_end - (unsigned long) &__init_begin;
28471
28472 printk(KERN_INFO "Memory: %luk/%luk available (%dk kernel code, "
28473 @@ -821,10 +829,10 @@ void __init mem_init(void)
28474 ((unsigned long)&__init_end -
28475 (unsigned long)&__init_begin) >> 10,
28476
28477 - (unsigned long)&_etext, (unsigned long)&_edata,
28478 - ((unsigned long)&_edata - (unsigned long)&_etext) >> 10,
28479 + (unsigned long)&_sdata, (unsigned long)&_edata,
28480 + ((unsigned long)&_edata - (unsigned long)&_sdata) >> 10,
28481
28482 - (unsigned long)&_text, (unsigned long)&_etext,
28483 + ktla_ktva((unsigned long)&_text), ktla_ktva((unsigned long)&_etext),
28484 ((unsigned long)&_etext - (unsigned long)&_text) >> 10);
28485
28486 /*
28487 @@ -914,6 +922,7 @@ void set_kernel_text_rw(void)
28488 if (!kernel_set_to_readonly)
28489 return;
28490
28491 + start = ktla_ktva(start);
28492 pr_debug("Set kernel text: %lx - %lx for read write\n",
28493 start, start+size);
28494
28495 @@ -928,6 +937,7 @@ void set_kernel_text_ro(void)
28496 if (!kernel_set_to_readonly)
28497 return;
28498
28499 + start = ktla_ktva(start);
28500 pr_debug("Set kernel text: %lx - %lx for read only\n",
28501 start, start+size);
28502
28503 @@ -956,6 +966,7 @@ void mark_rodata_ro(void)
28504 unsigned long start = PFN_ALIGN(_text);
28505 unsigned long size = PFN_ALIGN(_etext) - start;
28506
28507 + start = ktla_ktva(start);
28508 set_pages_ro(virt_to_page(start), size >> PAGE_SHIFT);
28509 printk(KERN_INFO "Write protecting the kernel text: %luk\n",
28510 size >> 10);
28511 diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
28512 index 474e28f..647dd12 100644
28513 --- a/arch/x86/mm/init_64.c
28514 +++ b/arch/x86/mm/init_64.c
28515 @@ -150,7 +150,7 @@ early_param("gbpages", parse_direct_gbpages_on);
28516 * around without checking the pgd every time.
28517 */
28518
28519 -pteval_t __supported_pte_mask __read_mostly = ~_PAGE_IOMAP;
28520 +pteval_t __supported_pte_mask __read_only = ~(_PAGE_NX | _PAGE_IOMAP);
28521 EXPORT_SYMBOL_GPL(__supported_pte_mask);
28522
28523 int force_personality32;
28524 @@ -183,12 +183,22 @@ void sync_global_pgds(unsigned long start, unsigned long end)
28525
28526 for (address = start; address <= end; address += PGDIR_SIZE) {
28527 const pgd_t *pgd_ref = pgd_offset_k(address);
28528 +
28529 +#ifdef CONFIG_PAX_PER_CPU_PGD
28530 + unsigned long cpu;
28531 +#else
28532 struct page *page;
28533 +#endif
28534
28535 if (pgd_none(*pgd_ref))
28536 continue;
28537
28538 spin_lock(&pgd_lock);
28539 +
28540 +#ifdef CONFIG_PAX_PER_CPU_PGD
28541 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
28542 + pgd_t *pgd = pgd_offset_cpu(cpu, address);
28543 +#else
28544 list_for_each_entry(page, &pgd_list, lru) {
28545 pgd_t *pgd;
28546 spinlock_t *pgt_lock;
28547 @@ -197,6 +207,7 @@ void sync_global_pgds(unsigned long start, unsigned long end)
28548 /* the pgt_lock only for Xen */
28549 pgt_lock = &pgd_page_get_mm(page)->page_table_lock;
28550 spin_lock(pgt_lock);
28551 +#endif
28552
28553 if (pgd_none(*pgd))
28554 set_pgd(pgd, *pgd_ref);
28555 @@ -204,7 +215,10 @@ void sync_global_pgds(unsigned long start, unsigned long end)
28556 BUG_ON(pgd_page_vaddr(*pgd)
28557 != pgd_page_vaddr(*pgd_ref));
28558
28559 +#ifndef CONFIG_PAX_PER_CPU_PGD
28560 spin_unlock(pgt_lock);
28561 +#endif
28562 +
28563 }
28564 spin_unlock(&pgd_lock);
28565 }
28566 @@ -237,7 +251,7 @@ static pud_t *fill_pud(pgd_t *pgd, unsigned long vaddr)
28567 {
28568 if (pgd_none(*pgd)) {
28569 pud_t *pud = (pud_t *)spp_getpage();
28570 - pgd_populate(&init_mm, pgd, pud);
28571 + pgd_populate_kernel(&init_mm, pgd, pud);
28572 if (pud != pud_offset(pgd, 0))
28573 printk(KERN_ERR "PAGETABLE BUG #00! %p <-> %p\n",
28574 pud, pud_offset(pgd, 0));
28575 @@ -249,7 +263,7 @@ static pmd_t *fill_pmd(pud_t *pud, unsigned long vaddr)
28576 {
28577 if (pud_none(*pud)) {
28578 pmd_t *pmd = (pmd_t *) spp_getpage();
28579 - pud_populate(&init_mm, pud, pmd);
28580 + pud_populate_kernel(&init_mm, pud, pmd);
28581 if (pmd != pmd_offset(pud, 0))
28582 printk(KERN_ERR "PAGETABLE BUG #01! %p <-> %p\n",
28583 pmd, pmd_offset(pud, 0));
28584 @@ -278,7 +292,9 @@ void set_pte_vaddr_pud(pud_t *pud_page, unsigned long vaddr, pte_t new_pte)
28585 pmd = fill_pmd(pud, vaddr);
28586 pte = fill_pte(pmd, vaddr);
28587
28588 + pax_open_kernel();
28589 set_pte(pte, new_pte);
28590 + pax_close_kernel();
28591
28592 /*
28593 * It's enough to flush this one mapping.
28594 @@ -337,14 +353,12 @@ static void __init __init_extra_mapping(unsigned long phys, unsigned long size,
28595 pgd = pgd_offset_k((unsigned long)__va(phys));
28596 if (pgd_none(*pgd)) {
28597 pud = (pud_t *) spp_getpage();
28598 - set_pgd(pgd, __pgd(__pa(pud) | _KERNPG_TABLE |
28599 - _PAGE_USER));
28600 + set_pgd(pgd, __pgd(__pa(pud) | _PAGE_TABLE));
28601 }
28602 pud = pud_offset(pgd, (unsigned long)__va(phys));
28603 if (pud_none(*pud)) {
28604 pmd = (pmd_t *) spp_getpage();
28605 - set_pud(pud, __pud(__pa(pmd) | _KERNPG_TABLE |
28606 - _PAGE_USER));
28607 + set_pud(pud, __pud(__pa(pmd) | _PAGE_TABLE));
28608 }
28609 pmd = pmd_offset(pud, phys);
28610 BUG_ON(!pmd_none(*pmd));
28611 @@ -585,7 +599,7 @@ phys_pud_init(pud_t *pud_page, unsigned long addr, unsigned long end,
28612 prot);
28613
28614 spin_lock(&init_mm.page_table_lock);
28615 - pud_populate(&init_mm, pud, pmd);
28616 + pud_populate_kernel(&init_mm, pud, pmd);
28617 spin_unlock(&init_mm.page_table_lock);
28618 }
28619 __flush_tlb_all();
28620 @@ -626,7 +640,7 @@ kernel_physical_mapping_init(unsigned long start,
28621 page_size_mask);
28622
28623 spin_lock(&init_mm.page_table_lock);
28624 - pgd_populate(&init_mm, pgd, pud);
28625 + pgd_populate_kernel(&init_mm, pgd, pud);
28626 spin_unlock(&init_mm.page_table_lock);
28627 pgd_changed = true;
28628 }
28629 @@ -1065,6 +1079,12 @@ void __init mem_init(void)
28630
28631 pci_iommu_alloc();
28632
28633 +#ifdef CONFIG_PAX_PER_CPU_PGD
28634 + clone_pgd_range(get_cpu_pgd(0) + KERNEL_PGD_BOUNDARY,
28635 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
28636 + KERNEL_PGD_PTRS);
28637 +#endif
28638 +
28639 /* clear_bss() already clear the empty_zero_page */
28640
28641 reservedpages = 0;
28642 @@ -1224,8 +1244,8 @@ int kern_addr_valid(unsigned long addr)
28643 static struct vm_area_struct gate_vma = {
28644 .vm_start = VSYSCALL_START,
28645 .vm_end = VSYSCALL_START + (VSYSCALL_MAPPED_PAGES * PAGE_SIZE),
28646 - .vm_page_prot = PAGE_READONLY_EXEC,
28647 - .vm_flags = VM_READ | VM_EXEC
28648 + .vm_page_prot = PAGE_READONLY,
28649 + .vm_flags = VM_READ
28650 };
28651
28652 struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
28653 @@ -1259,7 +1279,7 @@ int in_gate_area_no_mm(unsigned long addr)
28654
28655 const char *arch_vma_name(struct vm_area_struct *vma)
28656 {
28657 - if (vma->vm_mm && vma->vm_start == (long)vma->vm_mm->context.vdso)
28658 + if (vma->vm_mm && vma->vm_start == vma->vm_mm->context.vdso)
28659 return "[vdso]";
28660 if (vma == &gate_vma)
28661 return "[vsyscall]";
28662 diff --git a/arch/x86/mm/iomap_32.c b/arch/x86/mm/iomap_32.c
28663 index 7b179b4..6bd17777 100644
28664 --- a/arch/x86/mm/iomap_32.c
28665 +++ b/arch/x86/mm/iomap_32.c
28666 @@ -64,7 +64,11 @@ void *kmap_atomic_prot_pfn(unsigned long pfn, pgprot_t prot)
28667 type = kmap_atomic_idx_push();
28668 idx = type + KM_TYPE_NR * smp_processor_id();
28669 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
28670 +
28671 + pax_open_kernel();
28672 set_pte(kmap_pte - idx, pfn_pte(pfn, prot));
28673 + pax_close_kernel();
28674 +
28675 arch_flush_lazy_mmu_mode();
28676
28677 return (void *)vaddr;
28678 diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c
28679 index 78fe3f1..73b95e2 100644
28680 --- a/arch/x86/mm/ioremap.c
28681 +++ b/arch/x86/mm/ioremap.c
28682 @@ -97,7 +97,7 @@ static void __iomem *__ioremap_caller(resource_size_t phys_addr,
28683 for (pfn = phys_addr >> PAGE_SHIFT; pfn <= last_pfn; pfn++) {
28684 int is_ram = page_is_ram(pfn);
28685
28686 - if (is_ram && pfn_valid(pfn) && !PageReserved(pfn_to_page(pfn)))
28687 + if (is_ram && pfn_valid(pfn) && (pfn >= 0x100 || !PageReserved(pfn_to_page(pfn))))
28688 return NULL;
28689 WARN_ON_ONCE(is_ram);
28690 }
28691 @@ -256,7 +256,7 @@ EXPORT_SYMBOL(ioremap_prot);
28692 *
28693 * Caller must ensure there is only one unmapping for the same pointer.
28694 */
28695 -void iounmap(volatile void __iomem *addr)
28696 +void iounmap(const volatile void __iomem *addr)
28697 {
28698 struct vm_struct *p, *o;
28699
28700 @@ -315,6 +315,9 @@ void *xlate_dev_mem_ptr(unsigned long phys)
28701
28702 /* If page is RAM, we can use __va. Otherwise ioremap and unmap. */
28703 if (page_is_ram(start >> PAGE_SHIFT))
28704 +#ifdef CONFIG_HIGHMEM
28705 + if ((start >> PAGE_SHIFT) < max_low_pfn)
28706 +#endif
28707 return __va(phys);
28708
28709 addr = (void __force *)ioremap_cache(start, PAGE_SIZE);
28710 @@ -327,6 +330,9 @@ void *xlate_dev_mem_ptr(unsigned long phys)
28711 void unxlate_dev_mem_ptr(unsigned long phys, void *addr)
28712 {
28713 if (page_is_ram(phys >> PAGE_SHIFT))
28714 +#ifdef CONFIG_HIGHMEM
28715 + if ((phys >> PAGE_SHIFT) < max_low_pfn)
28716 +#endif
28717 return;
28718
28719 iounmap((void __iomem *)((unsigned long)addr & PAGE_MASK));
28720 @@ -344,7 +350,7 @@ static int __init early_ioremap_debug_setup(char *str)
28721 early_param("early_ioremap_debug", early_ioremap_debug_setup);
28722
28723 static __initdata int after_paging_init;
28724 -static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __page_aligned_bss;
28725 +static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __read_only __aligned(PAGE_SIZE);
28726
28727 static inline pmd_t * __init early_ioremap_pmd(unsigned long addr)
28728 {
28729 @@ -381,8 +387,7 @@ void __init early_ioremap_init(void)
28730 slot_virt[i] = __fix_to_virt(FIX_BTMAP_BEGIN - NR_FIX_BTMAPS*i);
28731
28732 pmd = early_ioremap_pmd(fix_to_virt(FIX_BTMAP_BEGIN));
28733 - memset(bm_pte, 0, sizeof(bm_pte));
28734 - pmd_populate_kernel(&init_mm, pmd, bm_pte);
28735 + pmd_populate_user(&init_mm, pmd, bm_pte);
28736
28737 /*
28738 * The boot-ioremap range spans multiple pmds, for which
28739 diff --git a/arch/x86/mm/kmemcheck/kmemcheck.c b/arch/x86/mm/kmemcheck/kmemcheck.c
28740 index d87dd6d..bf3fa66 100644
28741 --- a/arch/x86/mm/kmemcheck/kmemcheck.c
28742 +++ b/arch/x86/mm/kmemcheck/kmemcheck.c
28743 @@ -622,9 +622,9 @@ bool kmemcheck_fault(struct pt_regs *regs, unsigned long address,
28744 * memory (e.g. tracked pages)? For now, we need this to avoid
28745 * invoking kmemcheck for PnP BIOS calls.
28746 */
28747 - if (regs->flags & X86_VM_MASK)
28748 + if (v8086_mode(regs))
28749 return false;
28750 - if (regs->cs != __KERNEL_CS)
28751 + if (regs->cs != __KERNEL_CS && regs->cs != __KERNEXEC_KERNEL_CS)
28752 return false;
28753
28754 pte = kmemcheck_pte_lookup(address);
28755 diff --git a/arch/x86/mm/mmap.c b/arch/x86/mm/mmap.c
28756 index 845df68..1d8d29f 100644
28757 --- a/arch/x86/mm/mmap.c
28758 +++ b/arch/x86/mm/mmap.c
28759 @@ -52,7 +52,7 @@ static unsigned int stack_maxrandom_size(void)
28760 * Leave an at least ~128 MB hole with possible stack randomization.
28761 */
28762 #define MIN_GAP (128*1024*1024UL + stack_maxrandom_size())
28763 -#define MAX_GAP (TASK_SIZE/6*5)
28764 +#define MAX_GAP (pax_task_size/6*5)
28765
28766 static int mmap_is_legacy(void)
28767 {
28768 @@ -82,27 +82,40 @@ static unsigned long mmap_rnd(void)
28769 return rnd << PAGE_SHIFT;
28770 }
28771
28772 -static unsigned long mmap_base(void)
28773 +static unsigned long mmap_base(struct mm_struct *mm)
28774 {
28775 unsigned long gap = rlimit(RLIMIT_STACK);
28776 + unsigned long pax_task_size = TASK_SIZE;
28777 +
28778 +#ifdef CONFIG_PAX_SEGMEXEC
28779 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
28780 + pax_task_size = SEGMEXEC_TASK_SIZE;
28781 +#endif
28782
28783 if (gap < MIN_GAP)
28784 gap = MIN_GAP;
28785 else if (gap > MAX_GAP)
28786 gap = MAX_GAP;
28787
28788 - return PAGE_ALIGN(TASK_SIZE - gap - mmap_rnd());
28789 + return PAGE_ALIGN(pax_task_size - gap - mmap_rnd());
28790 }
28791
28792 /*
28793 * Bottom-up (legacy) layout on X86_32 did not support randomization, X86_64
28794 * does, but not when emulating X86_32
28795 */
28796 -static unsigned long mmap_legacy_base(void)
28797 +static unsigned long mmap_legacy_base(struct mm_struct *mm)
28798 {
28799 - if (mmap_is_ia32())
28800 + if (mmap_is_ia32()) {
28801 +
28802 +#ifdef CONFIG_PAX_SEGMEXEC
28803 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
28804 + return SEGMEXEC_TASK_UNMAPPED_BASE;
28805 + else
28806 +#endif
28807 +
28808 return TASK_UNMAPPED_BASE;
28809 - else
28810 + } else
28811 return TASK_UNMAPPED_BASE + mmap_rnd();
28812 }
28813
28814 @@ -113,11 +126,23 @@ static unsigned long mmap_legacy_base(void)
28815 void arch_pick_mmap_layout(struct mm_struct *mm)
28816 {
28817 if (mmap_is_legacy()) {
28818 - mm->mmap_base = mmap_legacy_base();
28819 + mm->mmap_base = mmap_legacy_base(mm);
28820 +
28821 +#ifdef CONFIG_PAX_RANDMMAP
28822 + if (mm->pax_flags & MF_PAX_RANDMMAP)
28823 + mm->mmap_base += mm->delta_mmap;
28824 +#endif
28825 +
28826 mm->get_unmapped_area = arch_get_unmapped_area;
28827 mm->unmap_area = arch_unmap_area;
28828 } else {
28829 - mm->mmap_base = mmap_base();
28830 + mm->mmap_base = mmap_base(mm);
28831 +
28832 +#ifdef CONFIG_PAX_RANDMMAP
28833 + if (mm->pax_flags & MF_PAX_RANDMMAP)
28834 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
28835 +#endif
28836 +
28837 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
28838 mm->unmap_area = arch_unmap_area_topdown;
28839 }
28840 diff --git a/arch/x86/mm/mmio-mod.c b/arch/x86/mm/mmio-mod.c
28841 index dc0b727..f612039 100644
28842 --- a/arch/x86/mm/mmio-mod.c
28843 +++ b/arch/x86/mm/mmio-mod.c
28844 @@ -194,7 +194,7 @@ static void pre(struct kmmio_probe *p, struct pt_regs *regs,
28845 break;
28846 default:
28847 {
28848 - unsigned char *ip = (unsigned char *)instptr;
28849 + unsigned char *ip = (unsigned char *)ktla_ktva(instptr);
28850 my_trace->opcode = MMIO_UNKNOWN_OP;
28851 my_trace->width = 0;
28852 my_trace->value = (*ip) << 16 | *(ip + 1) << 8 |
28853 @@ -234,7 +234,7 @@ static void post(struct kmmio_probe *p, unsigned long condition,
28854 static void ioremap_trace_core(resource_size_t offset, unsigned long size,
28855 void __iomem *addr)
28856 {
28857 - static atomic_t next_id;
28858 + static atomic_unchecked_t next_id;
28859 struct remap_trace *trace = kmalloc(sizeof(*trace), GFP_KERNEL);
28860 /* These are page-unaligned. */
28861 struct mmiotrace_map map = {
28862 @@ -258,7 +258,7 @@ static void ioremap_trace_core(resource_size_t offset, unsigned long size,
28863 .private = trace
28864 },
28865 .phys = offset,
28866 - .id = atomic_inc_return(&next_id)
28867 + .id = atomic_inc_return_unchecked(&next_id)
28868 };
28869 map.map_id = trace->id;
28870
28871 @@ -290,7 +290,7 @@ void mmiotrace_ioremap(resource_size_t offset, unsigned long size,
28872 ioremap_trace_core(offset, size, addr);
28873 }
28874
28875 -static void iounmap_trace_core(volatile void __iomem *addr)
28876 +static void iounmap_trace_core(const volatile void __iomem *addr)
28877 {
28878 struct mmiotrace_map map = {
28879 .phys = 0,
28880 @@ -328,7 +328,7 @@ not_enabled:
28881 }
28882 }
28883
28884 -void mmiotrace_iounmap(volatile void __iomem *addr)
28885 +void mmiotrace_iounmap(const volatile void __iomem *addr)
28886 {
28887 might_sleep();
28888 if (is_enabled()) /* recheck and proper locking in *_core() */
28889 diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c
28890 index 72fe01e..f1a8daa 100644
28891 --- a/arch/x86/mm/numa.c
28892 +++ b/arch/x86/mm/numa.c
28893 @@ -477,7 +477,7 @@ static bool __init numa_meminfo_cover_memory(const struct numa_meminfo *mi)
28894 return true;
28895 }
28896
28897 -static int __init numa_register_memblks(struct numa_meminfo *mi)
28898 +static int __init __intentional_overflow(-1) numa_register_memblks(struct numa_meminfo *mi)
28899 {
28900 unsigned long uninitialized_var(pfn_align);
28901 int i, nid;
28902 diff --git a/arch/x86/mm/pageattr-test.c b/arch/x86/mm/pageattr-test.c
28903 index 0e38951..4ca8458 100644
28904 --- a/arch/x86/mm/pageattr-test.c
28905 +++ b/arch/x86/mm/pageattr-test.c
28906 @@ -36,7 +36,7 @@ enum {
28907
28908 static int pte_testbit(pte_t pte)
28909 {
28910 - return pte_flags(pte) & _PAGE_UNUSED1;
28911 + return pte_flags(pte) & _PAGE_CPA_TEST;
28912 }
28913
28914 struct split_state {
28915 diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c
28916 index fb4e73e..43f7238 100644
28917 --- a/arch/x86/mm/pageattr.c
28918 +++ b/arch/x86/mm/pageattr.c
28919 @@ -261,7 +261,7 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
28920 */
28921 #ifdef CONFIG_PCI_BIOS
28922 if (pcibios_enabled && within(pfn, BIOS_BEGIN >> PAGE_SHIFT, BIOS_END >> PAGE_SHIFT))
28923 - pgprot_val(forbidden) |= _PAGE_NX;
28924 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
28925 #endif
28926
28927 /*
28928 @@ -269,9 +269,10 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
28929 * Does not cover __inittext since that is gone later on. On
28930 * 64bit we do not enforce !NX on the low mapping
28931 */
28932 - if (within(address, (unsigned long)_text, (unsigned long)_etext))
28933 - pgprot_val(forbidden) |= _PAGE_NX;
28934 + if (within(address, ktla_ktva((unsigned long)_text), ktla_ktva((unsigned long)_etext)))
28935 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
28936
28937 +#ifdef CONFIG_DEBUG_RODATA
28938 /*
28939 * The .rodata section needs to be read-only. Using the pfn
28940 * catches all aliases.
28941 @@ -279,6 +280,7 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
28942 if (within(pfn, __pa_symbol(__start_rodata) >> PAGE_SHIFT,
28943 __pa_symbol(__end_rodata) >> PAGE_SHIFT))
28944 pgprot_val(forbidden) |= _PAGE_RW;
28945 +#endif
28946
28947 #if defined(CONFIG_X86_64) && defined(CONFIG_DEBUG_RODATA)
28948 /*
28949 @@ -317,6 +319,13 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
28950 }
28951 #endif
28952
28953 +#ifdef CONFIG_PAX_KERNEXEC
28954 + if (within(pfn, __pa(ktla_ktva((unsigned long)&_text)), __pa((unsigned long)&_sdata))) {
28955 + pgprot_val(forbidden) |= _PAGE_RW;
28956 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
28957 + }
28958 +#endif
28959 +
28960 prot = __pgprot(pgprot_val(prot) & ~pgprot_val(forbidden));
28961
28962 return prot;
28963 @@ -400,23 +409,37 @@ EXPORT_SYMBOL_GPL(slow_virt_to_phys);
28964 static void __set_pmd_pte(pte_t *kpte, unsigned long address, pte_t pte)
28965 {
28966 /* change init_mm */
28967 + pax_open_kernel();
28968 set_pte_atomic(kpte, pte);
28969 +
28970 #ifdef CONFIG_X86_32
28971 if (!SHARED_KERNEL_PMD) {
28972 +
28973 +#ifdef CONFIG_PAX_PER_CPU_PGD
28974 + unsigned long cpu;
28975 +#else
28976 struct page *page;
28977 +#endif
28978
28979 +#ifdef CONFIG_PAX_PER_CPU_PGD
28980 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
28981 + pgd_t *pgd = get_cpu_pgd(cpu);
28982 +#else
28983 list_for_each_entry(page, &pgd_list, lru) {
28984 - pgd_t *pgd;
28985 + pgd_t *pgd = (pgd_t *)page_address(page);
28986 +#endif
28987 +
28988 pud_t *pud;
28989 pmd_t *pmd;
28990
28991 - pgd = (pgd_t *)page_address(page) + pgd_index(address);
28992 + pgd += pgd_index(address);
28993 pud = pud_offset(pgd, address);
28994 pmd = pmd_offset(pud, address);
28995 set_pte_atomic((pte_t *)pmd, pte);
28996 }
28997 }
28998 #endif
28999 + pax_close_kernel();
29000 }
29001
29002 static int
29003 diff --git a/arch/x86/mm/pat.c b/arch/x86/mm/pat.c
29004 index 6574388..87e9bef 100644
29005 --- a/arch/x86/mm/pat.c
29006 +++ b/arch/x86/mm/pat.c
29007 @@ -376,7 +376,7 @@ int free_memtype(u64 start, u64 end)
29008
29009 if (!entry) {
29010 printk(KERN_INFO "%s:%d freeing invalid memtype [mem %#010Lx-%#010Lx]\n",
29011 - current->comm, current->pid, start, end - 1);
29012 + current->comm, task_pid_nr(current), start, end - 1);
29013 return -EINVAL;
29014 }
29015
29016 @@ -506,8 +506,8 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
29017
29018 while (cursor < to) {
29019 if (!devmem_is_allowed(pfn)) {
29020 - printk(KERN_INFO "Program %s tried to access /dev/mem between [mem %#010Lx-%#010Lx]\n",
29021 - current->comm, from, to - 1);
29022 + printk(KERN_INFO "Program %s tried to access /dev/mem between [mem %#010Lx-%#010Lx] (%#010Lx)\n",
29023 + current->comm, from, to - 1, cursor);
29024 return 0;
29025 }
29026 cursor += PAGE_SIZE;
29027 @@ -577,7 +577,7 @@ int kernel_map_sync_memtype(u64 base, unsigned long size, unsigned long flags)
29028 if (ioremap_change_attr((unsigned long)__va(base), id_sz, flags) < 0) {
29029 printk(KERN_INFO "%s:%d ioremap_change_attr failed %s "
29030 "for [mem %#010Lx-%#010Lx]\n",
29031 - current->comm, current->pid,
29032 + current->comm, task_pid_nr(current),
29033 cattr_name(flags),
29034 base, (unsigned long long)(base + size-1));
29035 return -EINVAL;
29036 @@ -612,7 +612,7 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot,
29037 flags = lookup_memtype(paddr);
29038 if (want_flags != flags) {
29039 printk(KERN_WARNING "%s:%d map pfn RAM range req %s for [mem %#010Lx-%#010Lx], got %s\n",
29040 - current->comm, current->pid,
29041 + current->comm, task_pid_nr(current),
29042 cattr_name(want_flags),
29043 (unsigned long long)paddr,
29044 (unsigned long long)(paddr + size - 1),
29045 @@ -634,7 +634,7 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot,
29046 free_memtype(paddr, paddr + size);
29047 printk(KERN_ERR "%s:%d map pfn expected mapping type %s"
29048 " for [mem %#010Lx-%#010Lx], got %s\n",
29049 - current->comm, current->pid,
29050 + current->comm, task_pid_nr(current),
29051 cattr_name(want_flags),
29052 (unsigned long long)paddr,
29053 (unsigned long long)(paddr + size - 1),
29054 diff --git a/arch/x86/mm/pf_in.c b/arch/x86/mm/pf_in.c
29055 index 9f0614d..92ae64a 100644
29056 --- a/arch/x86/mm/pf_in.c
29057 +++ b/arch/x86/mm/pf_in.c
29058 @@ -148,7 +148,7 @@ enum reason_type get_ins_type(unsigned long ins_addr)
29059 int i;
29060 enum reason_type rv = OTHERS;
29061
29062 - p = (unsigned char *)ins_addr;
29063 + p = (unsigned char *)ktla_ktva(ins_addr);
29064 p += skip_prefix(p, &prf);
29065 p += get_opcode(p, &opcode);
29066
29067 @@ -168,7 +168,7 @@ static unsigned int get_ins_reg_width(unsigned long ins_addr)
29068 struct prefix_bits prf;
29069 int i;
29070
29071 - p = (unsigned char *)ins_addr;
29072 + p = (unsigned char *)ktla_ktva(ins_addr);
29073 p += skip_prefix(p, &prf);
29074 p += get_opcode(p, &opcode);
29075
29076 @@ -191,7 +191,7 @@ unsigned int get_ins_mem_width(unsigned long ins_addr)
29077 struct prefix_bits prf;
29078 int i;
29079
29080 - p = (unsigned char *)ins_addr;
29081 + p = (unsigned char *)ktla_ktva(ins_addr);
29082 p += skip_prefix(p, &prf);
29083 p += get_opcode(p, &opcode);
29084
29085 @@ -415,7 +415,7 @@ unsigned long get_ins_reg_val(unsigned long ins_addr, struct pt_regs *regs)
29086 struct prefix_bits prf;
29087 int i;
29088
29089 - p = (unsigned char *)ins_addr;
29090 + p = (unsigned char *)ktla_ktva(ins_addr);
29091 p += skip_prefix(p, &prf);
29092 p += get_opcode(p, &opcode);
29093 for (i = 0; i < ARRAY_SIZE(reg_rop); i++)
29094 @@ -470,7 +470,7 @@ unsigned long get_ins_imm_val(unsigned long ins_addr)
29095 struct prefix_bits prf;
29096 int i;
29097
29098 - p = (unsigned char *)ins_addr;
29099 + p = (unsigned char *)ktla_ktva(ins_addr);
29100 p += skip_prefix(p, &prf);
29101 p += get_opcode(p, &opcode);
29102 for (i = 0; i < ARRAY_SIZE(imm_wop); i++)
29103 diff --git a/arch/x86/mm/pgtable.c b/arch/x86/mm/pgtable.c
29104 index 17fda6a..489c74a 100644
29105 --- a/arch/x86/mm/pgtable.c
29106 +++ b/arch/x86/mm/pgtable.c
29107 @@ -91,10 +91,64 @@ static inline void pgd_list_del(pgd_t *pgd)
29108 list_del(&page->lru);
29109 }
29110
29111 -#define UNSHARED_PTRS_PER_PGD \
29112 - (SHARED_KERNEL_PMD ? KERNEL_PGD_BOUNDARY : PTRS_PER_PGD)
29113 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
29114 +pgdval_t clone_pgd_mask __read_only = ~_PAGE_PRESENT;
29115
29116 +void __shadow_user_pgds(pgd_t *dst, const pgd_t *src)
29117 +{
29118 + unsigned int count = USER_PGD_PTRS;
29119
29120 + while (count--)
29121 + *dst++ = __pgd((pgd_val(*src++) | (_PAGE_NX & __supported_pte_mask)) & ~_PAGE_USER);
29122 +}
29123 +#endif
29124 +
29125 +#ifdef CONFIG_PAX_PER_CPU_PGD
29126 +void __clone_user_pgds(pgd_t *dst, const pgd_t *src)
29127 +{
29128 + unsigned int count = USER_PGD_PTRS;
29129 +
29130 + while (count--) {
29131 + pgd_t pgd;
29132 +
29133 +#ifdef CONFIG_X86_64
29134 + pgd = __pgd(pgd_val(*src++) | _PAGE_USER);
29135 +#else
29136 + pgd = *src++;
29137 +#endif
29138 +
29139 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
29140 + pgd = __pgd(pgd_val(pgd) & clone_pgd_mask);
29141 +#endif
29142 +
29143 + *dst++ = pgd;
29144 + }
29145 +
29146 +}
29147 +#endif
29148 +
29149 +#ifdef CONFIG_X86_64
29150 +#define pxd_t pud_t
29151 +#define pyd_t pgd_t
29152 +#define paravirt_release_pxd(pfn) paravirt_release_pud(pfn)
29153 +#define pxd_free(mm, pud) pud_free((mm), (pud))
29154 +#define pyd_populate(mm, pgd, pud) pgd_populate((mm), (pgd), (pud))
29155 +#define pyd_offset(mm, address) pgd_offset((mm), (address))
29156 +#define PYD_SIZE PGDIR_SIZE
29157 +#else
29158 +#define pxd_t pmd_t
29159 +#define pyd_t pud_t
29160 +#define paravirt_release_pxd(pfn) paravirt_release_pmd(pfn)
29161 +#define pxd_free(mm, pud) pmd_free((mm), (pud))
29162 +#define pyd_populate(mm, pgd, pud) pud_populate((mm), (pgd), (pud))
29163 +#define pyd_offset(mm, address) pud_offset((mm), (address))
29164 +#define PYD_SIZE PUD_SIZE
29165 +#endif
29166 +
29167 +#ifdef CONFIG_PAX_PER_CPU_PGD
29168 +static inline void pgd_ctor(struct mm_struct *mm, pgd_t *pgd) {}
29169 +static inline void pgd_dtor(pgd_t *pgd) {}
29170 +#else
29171 static void pgd_set_mm(pgd_t *pgd, struct mm_struct *mm)
29172 {
29173 BUILD_BUG_ON(sizeof(virt_to_page(pgd)->index) < sizeof(mm));
29174 @@ -135,6 +189,7 @@ static void pgd_dtor(pgd_t *pgd)
29175 pgd_list_del(pgd);
29176 spin_unlock(&pgd_lock);
29177 }
29178 +#endif
29179
29180 /*
29181 * List of all pgd's needed for non-PAE so it can invalidate entries
29182 @@ -147,7 +202,7 @@ static void pgd_dtor(pgd_t *pgd)
29183 * -- nyc
29184 */
29185
29186 -#ifdef CONFIG_X86_PAE
29187 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
29188 /*
29189 * In PAE mode, we need to do a cr3 reload (=tlb flush) when
29190 * updating the top-level pagetable entries to guarantee the
29191 @@ -159,7 +214,7 @@ static void pgd_dtor(pgd_t *pgd)
29192 * not shared between pagetables (!SHARED_KERNEL_PMDS), we allocate
29193 * and initialize the kernel pmds here.
29194 */
29195 -#define PREALLOCATED_PMDS UNSHARED_PTRS_PER_PGD
29196 +#define PREALLOCATED_PXDS (SHARED_KERNEL_PMD ? KERNEL_PGD_BOUNDARY : PTRS_PER_PGD)
29197
29198 void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
29199 {
29200 @@ -177,36 +232,38 @@ void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
29201 */
29202 flush_tlb_mm(mm);
29203 }
29204 +#elif defined(CONFIG_X86_64) && defined(CONFIG_PAX_PER_CPU_PGD)
29205 +#define PREALLOCATED_PXDS USER_PGD_PTRS
29206 #else /* !CONFIG_X86_PAE */
29207
29208 /* No need to prepopulate any pagetable entries in non-PAE modes. */
29209 -#define PREALLOCATED_PMDS 0
29210 +#define PREALLOCATED_PXDS 0
29211
29212 #endif /* CONFIG_X86_PAE */
29213
29214 -static void free_pmds(pmd_t *pmds[])
29215 +static void free_pxds(pxd_t *pxds[])
29216 {
29217 int i;
29218
29219 - for(i = 0; i < PREALLOCATED_PMDS; i++)
29220 - if (pmds[i])
29221 - free_page((unsigned long)pmds[i]);
29222 + for(i = 0; i < PREALLOCATED_PXDS; i++)
29223 + if (pxds[i])
29224 + free_page((unsigned long)pxds[i]);
29225 }
29226
29227 -static int preallocate_pmds(pmd_t *pmds[])
29228 +static int preallocate_pxds(pxd_t *pxds[])
29229 {
29230 int i;
29231 bool failed = false;
29232
29233 - for(i = 0; i < PREALLOCATED_PMDS; i++) {
29234 - pmd_t *pmd = (pmd_t *)__get_free_page(PGALLOC_GFP);
29235 - if (pmd == NULL)
29236 + for(i = 0; i < PREALLOCATED_PXDS; i++) {
29237 + pxd_t *pxd = (pxd_t *)__get_free_page(PGALLOC_GFP);
29238 + if (pxd == NULL)
29239 failed = true;
29240 - pmds[i] = pmd;
29241 + pxds[i] = pxd;
29242 }
29243
29244 if (failed) {
29245 - free_pmds(pmds);
29246 + free_pxds(pxds);
29247 return -ENOMEM;
29248 }
29249
29250 @@ -219,51 +276,55 @@ static int preallocate_pmds(pmd_t *pmds[])
29251 * preallocate which never got a corresponding vma will need to be
29252 * freed manually.
29253 */
29254 -static void pgd_mop_up_pmds(struct mm_struct *mm, pgd_t *pgdp)
29255 +static void pgd_mop_up_pxds(struct mm_struct *mm, pgd_t *pgdp)
29256 {
29257 int i;
29258
29259 - for(i = 0; i < PREALLOCATED_PMDS; i++) {
29260 + for(i = 0; i < PREALLOCATED_PXDS; i++) {
29261 pgd_t pgd = pgdp[i];
29262
29263 if (pgd_val(pgd) != 0) {
29264 - pmd_t *pmd = (pmd_t *)pgd_page_vaddr(pgd);
29265 + pxd_t *pxd = (pxd_t *)pgd_page_vaddr(pgd);
29266
29267 - pgdp[i] = native_make_pgd(0);
29268 + set_pgd(pgdp + i, native_make_pgd(0));
29269
29270 - paravirt_release_pmd(pgd_val(pgd) >> PAGE_SHIFT);
29271 - pmd_free(mm, pmd);
29272 + paravirt_release_pxd(pgd_val(pgd) >> PAGE_SHIFT);
29273 + pxd_free(mm, pxd);
29274 }
29275 }
29276 }
29277
29278 -static void pgd_prepopulate_pmd(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmds[])
29279 +static void pgd_prepopulate_pxd(struct mm_struct *mm, pgd_t *pgd, pxd_t *pxds[])
29280 {
29281 - pud_t *pud;
29282 + pyd_t *pyd;
29283 unsigned long addr;
29284 int i;
29285
29286 - if (PREALLOCATED_PMDS == 0) /* Work around gcc-3.4.x bug */
29287 + if (PREALLOCATED_PXDS == 0) /* Work around gcc-3.4.x bug */
29288 return;
29289
29290 - pud = pud_offset(pgd, 0);
29291 +#ifdef CONFIG_X86_64
29292 + pyd = pyd_offset(mm, 0L);
29293 +#else
29294 + pyd = pyd_offset(pgd, 0L);
29295 +#endif
29296
29297 - for (addr = i = 0; i < PREALLOCATED_PMDS;
29298 - i++, pud++, addr += PUD_SIZE) {
29299 - pmd_t *pmd = pmds[i];
29300 + for (addr = i = 0; i < PREALLOCATED_PXDS;
29301 + i++, pyd++, addr += PYD_SIZE) {
29302 + pxd_t *pxd = pxds[i];
29303
29304 if (i >= KERNEL_PGD_BOUNDARY)
29305 - memcpy(pmd, (pmd_t *)pgd_page_vaddr(swapper_pg_dir[i]),
29306 - sizeof(pmd_t) * PTRS_PER_PMD);
29307 + memcpy(pxd, (pxd_t *)pgd_page_vaddr(swapper_pg_dir[i]),
29308 + sizeof(pxd_t) * PTRS_PER_PMD);
29309
29310 - pud_populate(mm, pud, pmd);
29311 + pyd_populate(mm, pyd, pxd);
29312 }
29313 }
29314
29315 pgd_t *pgd_alloc(struct mm_struct *mm)
29316 {
29317 pgd_t *pgd;
29318 - pmd_t *pmds[PREALLOCATED_PMDS];
29319 + pxd_t *pxds[PREALLOCATED_PXDS];
29320
29321 pgd = (pgd_t *)__get_free_page(PGALLOC_GFP);
29322
29323 @@ -272,11 +333,11 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
29324
29325 mm->pgd = pgd;
29326
29327 - if (preallocate_pmds(pmds) != 0)
29328 + if (preallocate_pxds(pxds) != 0)
29329 goto out_free_pgd;
29330
29331 if (paravirt_pgd_alloc(mm) != 0)
29332 - goto out_free_pmds;
29333 + goto out_free_pxds;
29334
29335 /*
29336 * Make sure that pre-populating the pmds is atomic with
29337 @@ -286,14 +347,14 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
29338 spin_lock(&pgd_lock);
29339
29340 pgd_ctor(mm, pgd);
29341 - pgd_prepopulate_pmd(mm, pgd, pmds);
29342 + pgd_prepopulate_pxd(mm, pgd, pxds);
29343
29344 spin_unlock(&pgd_lock);
29345
29346 return pgd;
29347
29348 -out_free_pmds:
29349 - free_pmds(pmds);
29350 +out_free_pxds:
29351 + free_pxds(pxds);
29352 out_free_pgd:
29353 free_page((unsigned long)pgd);
29354 out:
29355 @@ -302,7 +363,7 @@ out:
29356
29357 void pgd_free(struct mm_struct *mm, pgd_t *pgd)
29358 {
29359 - pgd_mop_up_pmds(mm, pgd);
29360 + pgd_mop_up_pxds(mm, pgd);
29361 pgd_dtor(pgd);
29362 paravirt_pgd_free(mm, pgd);
29363 free_page((unsigned long)pgd);
29364 diff --git a/arch/x86/mm/pgtable_32.c b/arch/x86/mm/pgtable_32.c
29365 index a69bcb8..19068ab 100644
29366 --- a/arch/x86/mm/pgtable_32.c
29367 +++ b/arch/x86/mm/pgtable_32.c
29368 @@ -47,10 +47,13 @@ void set_pte_vaddr(unsigned long vaddr, pte_t pteval)
29369 return;
29370 }
29371 pte = pte_offset_kernel(pmd, vaddr);
29372 +
29373 + pax_open_kernel();
29374 if (pte_val(pteval))
29375 set_pte_at(&init_mm, vaddr, pte, pteval);
29376 else
29377 pte_clear(&init_mm, vaddr, pte);
29378 + pax_close_kernel();
29379
29380 /*
29381 * It's enough to flush this one mapping.
29382 diff --git a/arch/x86/mm/physaddr.c b/arch/x86/mm/physaddr.c
29383 index e666cbb..61788c45 100644
29384 --- a/arch/x86/mm/physaddr.c
29385 +++ b/arch/x86/mm/physaddr.c
29386 @@ -10,7 +10,7 @@
29387 #ifdef CONFIG_X86_64
29388
29389 #ifdef CONFIG_DEBUG_VIRTUAL
29390 -unsigned long __phys_addr(unsigned long x)
29391 +unsigned long __intentional_overflow(-1) __phys_addr(unsigned long x)
29392 {
29393 unsigned long y = x - __START_KERNEL_map;
29394
29395 @@ -67,7 +67,7 @@ EXPORT_SYMBOL(__virt_addr_valid);
29396 #else
29397
29398 #ifdef CONFIG_DEBUG_VIRTUAL
29399 -unsigned long __phys_addr(unsigned long x)
29400 +unsigned long __intentional_overflow(-1) __phys_addr(unsigned long x)
29401 {
29402 unsigned long phys_addr = x - PAGE_OFFSET;
29403 /* VMALLOC_* aren't constants */
29404 diff --git a/arch/x86/mm/setup_nx.c b/arch/x86/mm/setup_nx.c
29405 index 410531d..0f16030 100644
29406 --- a/arch/x86/mm/setup_nx.c
29407 +++ b/arch/x86/mm/setup_nx.c
29408 @@ -5,8 +5,10 @@
29409 #include <asm/pgtable.h>
29410 #include <asm/proto.h>
29411
29412 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
29413 static int disable_nx __cpuinitdata;
29414
29415 +#ifndef CONFIG_PAX_PAGEEXEC
29416 /*
29417 * noexec = on|off
29418 *
29419 @@ -28,12 +30,17 @@ static int __init noexec_setup(char *str)
29420 return 0;
29421 }
29422 early_param("noexec", noexec_setup);
29423 +#endif
29424 +
29425 +#endif
29426
29427 void __cpuinit x86_configure_nx(void)
29428 {
29429 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
29430 if (cpu_has_nx && !disable_nx)
29431 __supported_pte_mask |= _PAGE_NX;
29432 else
29433 +#endif
29434 __supported_pte_mask &= ~_PAGE_NX;
29435 }
29436
29437 diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c
29438 index 282375f..e03a98f 100644
29439 --- a/arch/x86/mm/tlb.c
29440 +++ b/arch/x86/mm/tlb.c
29441 @@ -48,7 +48,11 @@ void leave_mm(int cpu)
29442 BUG();
29443 if (cpumask_test_cpu(cpu, mm_cpumask(active_mm))) {
29444 cpumask_clear_cpu(cpu, mm_cpumask(active_mm));
29445 +
29446 +#ifndef CONFIG_PAX_PER_CPU_PGD
29447 load_cr3(swapper_pg_dir);
29448 +#endif
29449 +
29450 }
29451 }
29452 EXPORT_SYMBOL_GPL(leave_mm);
29453 diff --git a/arch/x86/net/bpf_jit.S b/arch/x86/net/bpf_jit.S
29454 index 877b9a1..a8ecf42 100644
29455 --- a/arch/x86/net/bpf_jit.S
29456 +++ b/arch/x86/net/bpf_jit.S
29457 @@ -9,6 +9,7 @@
29458 */
29459 #include <linux/linkage.h>
29460 #include <asm/dwarf2.h>
29461 +#include <asm/alternative-asm.h>
29462
29463 /*
29464 * Calling convention :
29465 @@ -35,6 +36,7 @@ sk_load_word_positive_offset:
29466 jle bpf_slow_path_word
29467 mov (SKBDATA,%rsi),%eax
29468 bswap %eax /* ntohl() */
29469 + pax_force_retaddr
29470 ret
29471
29472 sk_load_half:
29473 @@ -52,6 +54,7 @@ sk_load_half_positive_offset:
29474 jle bpf_slow_path_half
29475 movzwl (SKBDATA,%rsi),%eax
29476 rol $8,%ax # ntohs()
29477 + pax_force_retaddr
29478 ret
29479
29480 sk_load_byte:
29481 @@ -66,6 +69,7 @@ sk_load_byte_positive_offset:
29482 cmp %esi,%r9d /* if (offset >= hlen) goto bpf_slow_path_byte */
29483 jle bpf_slow_path_byte
29484 movzbl (SKBDATA,%rsi),%eax
29485 + pax_force_retaddr
29486 ret
29487
29488 /**
29489 @@ -87,6 +91,7 @@ sk_load_byte_msh_positive_offset:
29490 movzbl (SKBDATA,%rsi),%ebx
29491 and $15,%bl
29492 shl $2,%bl
29493 + pax_force_retaddr
29494 ret
29495
29496 /* rsi contains offset and can be scratched */
29497 @@ -109,6 +114,7 @@ bpf_slow_path_word:
29498 js bpf_error
29499 mov -12(%rbp),%eax
29500 bswap %eax
29501 + pax_force_retaddr
29502 ret
29503
29504 bpf_slow_path_half:
29505 @@ -117,12 +123,14 @@ bpf_slow_path_half:
29506 mov -12(%rbp),%ax
29507 rol $8,%ax
29508 movzwl %ax,%eax
29509 + pax_force_retaddr
29510 ret
29511
29512 bpf_slow_path_byte:
29513 bpf_slow_path_common(1)
29514 js bpf_error
29515 movzbl -12(%rbp),%eax
29516 + pax_force_retaddr
29517 ret
29518
29519 bpf_slow_path_byte_msh:
29520 @@ -133,6 +141,7 @@ bpf_slow_path_byte_msh:
29521 and $15,%al
29522 shl $2,%al
29523 xchg %eax,%ebx
29524 + pax_force_retaddr
29525 ret
29526
29527 #define sk_negative_common(SIZE) \
29528 @@ -157,6 +166,7 @@ sk_load_word_negative_offset:
29529 sk_negative_common(4)
29530 mov (%rax), %eax
29531 bswap %eax
29532 + pax_force_retaddr
29533 ret
29534
29535 bpf_slow_path_half_neg:
29536 @@ -168,6 +178,7 @@ sk_load_half_negative_offset:
29537 mov (%rax),%ax
29538 rol $8,%ax
29539 movzwl %ax,%eax
29540 + pax_force_retaddr
29541 ret
29542
29543 bpf_slow_path_byte_neg:
29544 @@ -177,6 +188,7 @@ sk_load_byte_negative_offset:
29545 .globl sk_load_byte_negative_offset
29546 sk_negative_common(1)
29547 movzbl (%rax), %eax
29548 + pax_force_retaddr
29549 ret
29550
29551 bpf_slow_path_byte_msh_neg:
29552 @@ -190,6 +202,7 @@ sk_load_byte_msh_negative_offset:
29553 and $15,%al
29554 shl $2,%al
29555 xchg %eax,%ebx
29556 + pax_force_retaddr
29557 ret
29558
29559 bpf_error:
29560 @@ -197,4 +210,5 @@ bpf_error:
29561 xor %eax,%eax
29562 mov -8(%rbp),%rbx
29563 leaveq
29564 + pax_force_retaddr
29565 ret
29566 diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c
29567 index 3cbe4538..003d011 100644
29568 --- a/arch/x86/net/bpf_jit_comp.c
29569 +++ b/arch/x86/net/bpf_jit_comp.c
29570 @@ -12,6 +12,7 @@
29571 #include <linux/netdevice.h>
29572 #include <linux/filter.h>
29573 #include <linux/if_vlan.h>
29574 +#include <linux/random.h>
29575
29576 /*
29577 * Conventions :
29578 @@ -49,13 +50,90 @@ static inline u8 *emit_code(u8 *ptr, u32 bytes, unsigned int len)
29579 return ptr + len;
29580 }
29581
29582 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29583 +#define MAX_INSTR_CODE_SIZE 96
29584 +#else
29585 +#define MAX_INSTR_CODE_SIZE 64
29586 +#endif
29587 +
29588 #define EMIT(bytes, len) do { prog = emit_code(prog, bytes, len); } while (0)
29589
29590 #define EMIT1(b1) EMIT(b1, 1)
29591 #define EMIT2(b1, b2) EMIT((b1) + ((b2) << 8), 2)
29592 #define EMIT3(b1, b2, b3) EMIT((b1) + ((b2) << 8) + ((b3) << 16), 3)
29593 #define EMIT4(b1, b2, b3, b4) EMIT((b1) + ((b2) << 8) + ((b3) << 16) + ((b4) << 24), 4)
29594 +
29595 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29596 +/* original constant will appear in ecx */
29597 +#define DILUTE_CONST_SEQUENCE(_off, _key) \
29598 +do { \
29599 + /* mov ecx, randkey */ \
29600 + EMIT1(0xb9); \
29601 + EMIT(_key, 4); \
29602 + /* xor ecx, randkey ^ off */ \
29603 + EMIT2(0x81, 0xf1); \
29604 + EMIT((_key) ^ (_off), 4); \
29605 +} while (0)
29606 +
29607 +#define EMIT1_off32(b1, _off) \
29608 +do { \
29609 + switch (b1) { \
29610 + case 0x05: /* add eax, imm32 */ \
29611 + case 0x2d: /* sub eax, imm32 */ \
29612 + case 0x25: /* and eax, imm32 */ \
29613 + case 0x0d: /* or eax, imm32 */ \
29614 + case 0xb8: /* mov eax, imm32 */ \
29615 + case 0x35: /* xor eax, imm32 */ \
29616 + case 0x3d: /* cmp eax, imm32 */ \
29617 + case 0xa9: /* test eax, imm32 */ \
29618 + DILUTE_CONST_SEQUENCE(_off, randkey); \
29619 + EMIT2((b1) - 4, 0xc8); /* convert imm instruction to eax, ecx */\
29620 + break; \
29621 + case 0xbb: /* mov ebx, imm32 */ \
29622 + DILUTE_CONST_SEQUENCE(_off, randkey); \
29623 + /* mov ebx, ecx */ \
29624 + EMIT2(0x89, 0xcb); \
29625 + break; \
29626 + case 0xbe: /* mov esi, imm32 */ \
29627 + DILUTE_CONST_SEQUENCE(_off, randkey); \
29628 + /* mov esi, ecx */ \
29629 + EMIT2(0x89, 0xce); \
29630 + break; \
29631 + case 0xe8: /* call rel imm32, always to known funcs */ \
29632 + EMIT1(b1); \
29633 + EMIT(_off, 4); \
29634 + break; \
29635 + case 0xe9: /* jmp rel imm32 */ \
29636 + EMIT1(b1); \
29637 + EMIT(_off, 4); \
29638 + /* prevent fall-through, we're not called if off = 0 */ \
29639 + EMIT(0xcccccccc, 4); \
29640 + EMIT(0xcccccccc, 4); \
29641 + break; \
29642 + default: \
29643 + BUILD_BUG(); \
29644 + } \
29645 +} while (0)
29646 +
29647 +#define EMIT2_off32(b1, b2, _off) \
29648 +do { \
29649 + if ((b1) == 0x8d && (b2) == 0xb3) { /* lea esi, [rbx+imm32] */ \
29650 + EMIT2(0x8d, 0xb3); /* lea esi, [rbx+randkey] */ \
29651 + EMIT(randkey, 4); \
29652 + EMIT2(0x8d, 0xb6); /* lea esi, [esi+off-randkey] */ \
29653 + EMIT((_off) - randkey, 4); \
29654 + } else if ((b1) == 0x69 && (b2) == 0xc0) { /* imul eax, imm32 */\
29655 + DILUTE_CONST_SEQUENCE(_off, randkey); \
29656 + /* imul eax, ecx */ \
29657 + EMIT3(0x0f, 0xaf, 0xc1); \
29658 + } else { \
29659 + BUILD_BUG(); \
29660 + } \
29661 +} while (0)
29662 +#else
29663 #define EMIT1_off32(b1, off) do { EMIT1(b1); EMIT(off, 4);} while (0)
29664 +#define EMIT2_off32(b1, b2, off) do { EMIT2(b1, b2); EMIT(off, 4);} while (0)
29665 +#endif
29666
29667 #define CLEAR_A() EMIT2(0x31, 0xc0) /* xor %eax,%eax */
29668 #define CLEAR_X() EMIT2(0x31, 0xdb) /* xor %ebx,%ebx */
29669 @@ -90,6 +168,24 @@ do { \
29670 #define X86_JBE 0x76
29671 #define X86_JA 0x77
29672
29673 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29674 +#define APPEND_FLOW_VERIFY() \
29675 +do { \
29676 + /* mov ecx, randkey */ \
29677 + EMIT1(0xb9); \
29678 + EMIT(randkey, 4); \
29679 + /* cmp ecx, randkey */ \
29680 + EMIT2(0x81, 0xf9); \
29681 + EMIT(randkey, 4); \
29682 + /* jz after 8 int 3s */ \
29683 + EMIT2(0x74, 0x08); \
29684 + EMIT(0xcccccccc, 4); \
29685 + EMIT(0xcccccccc, 4); \
29686 +} while (0)
29687 +#else
29688 +#define APPEND_FLOW_VERIFY() do { } while (0)
29689 +#endif
29690 +
29691 #define EMIT_COND_JMP(op, offset) \
29692 do { \
29693 if (is_near(offset)) \
29694 @@ -97,6 +193,7 @@ do { \
29695 else { \
29696 EMIT2(0x0f, op + 0x10); \
29697 EMIT(offset, 4); /* jxx .+off32 */ \
29698 + APPEND_FLOW_VERIFY(); \
29699 } \
29700 } while (0)
29701
29702 @@ -121,6 +218,11 @@ static inline void bpf_flush_icache(void *start, void *end)
29703 set_fs(old_fs);
29704 }
29705
29706 +struct bpf_jit_work {
29707 + struct work_struct work;
29708 + void *image;
29709 +};
29710 +
29711 #define CHOOSE_LOAD_FUNC(K, func) \
29712 ((int)K < 0 ? ((int)K >= SKF_LL_OFF ? func##_negative_offset : func) : func##_positive_offset)
29713
29714 @@ -146,7 +248,7 @@ static int pkt_type_offset(void)
29715
29716 void bpf_jit_compile(struct sk_filter *fp)
29717 {
29718 - u8 temp[64];
29719 + u8 temp[MAX_INSTR_CODE_SIZE];
29720 u8 *prog;
29721 unsigned int proglen, oldproglen = 0;
29722 int ilen, i;
29723 @@ -159,6 +261,9 @@ void bpf_jit_compile(struct sk_filter *fp)
29724 unsigned int *addrs;
29725 const struct sock_filter *filter = fp->insns;
29726 int flen = fp->len;
29727 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29728 + unsigned int randkey;
29729 +#endif
29730
29731 if (!bpf_jit_enable)
29732 return;
29733 @@ -167,11 +272,19 @@ void bpf_jit_compile(struct sk_filter *fp)
29734 if (addrs == NULL)
29735 return;
29736
29737 + fp->work = kmalloc(sizeof(*fp->work), GFP_KERNEL);
29738 + if (!fp->work)
29739 + goto out;
29740 +
29741 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29742 + randkey = get_random_int();
29743 +#endif
29744 +
29745 /* Before first pass, make a rough estimation of addrs[]
29746 - * each bpf instruction is translated to less than 64 bytes
29747 + * each bpf instruction is translated to less than MAX_INSTR_CODE_SIZE bytes
29748 */
29749 for (proglen = 0, i = 0; i < flen; i++) {
29750 - proglen += 64;
29751 + proglen += MAX_INSTR_CODE_SIZE;
29752 addrs[i] = proglen;
29753 }
29754 cleanup_addr = proglen; /* epilogue address */
29755 @@ -282,10 +395,8 @@ void bpf_jit_compile(struct sk_filter *fp)
29756 case BPF_S_ALU_MUL_K: /* A *= K */
29757 if (is_imm8(K))
29758 EMIT3(0x6b, 0xc0, K); /* imul imm8,%eax,%eax */
29759 - else {
29760 - EMIT2(0x69, 0xc0); /* imul imm32,%eax */
29761 - EMIT(K, 4);
29762 - }
29763 + else
29764 + EMIT2_off32(0x69, 0xc0, K); /* imul imm32,%eax */
29765 break;
29766 case BPF_S_ALU_DIV_X: /* A /= X; */
29767 seen |= SEEN_XREG;
29768 @@ -325,13 +436,23 @@ void bpf_jit_compile(struct sk_filter *fp)
29769 break;
29770 case BPF_S_ALU_MOD_K: /* A %= K; */
29771 EMIT2(0x31, 0xd2); /* xor %edx,%edx */
29772 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29773 + DILUTE_CONST_SEQUENCE(K, randkey);
29774 +#else
29775 EMIT1(0xb9);EMIT(K, 4); /* mov imm32,%ecx */
29776 +#endif
29777 EMIT2(0xf7, 0xf1); /* div %ecx */
29778 EMIT2(0x89, 0xd0); /* mov %edx,%eax */
29779 break;
29780 case BPF_S_ALU_DIV_K: /* A = reciprocal_divide(A, K); */
29781 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29782 + DILUTE_CONST_SEQUENCE(K, randkey);
29783 + // imul rax, rcx
29784 + EMIT4(0x48, 0x0f, 0xaf, 0xc1);
29785 +#else
29786 EMIT3(0x48, 0x69, 0xc0); /* imul imm32,%rax,%rax */
29787 EMIT(K, 4);
29788 +#endif
29789 EMIT4(0x48, 0xc1, 0xe8, 0x20); /* shr $0x20,%rax */
29790 break;
29791 case BPF_S_ALU_AND_X:
29792 @@ -602,8 +723,7 @@ common_load_ind: seen |= SEEN_DATAREF | SEEN_XREG;
29793 if (is_imm8(K)) {
29794 EMIT3(0x8d, 0x73, K); /* lea imm8(%rbx), %esi */
29795 } else {
29796 - EMIT2(0x8d, 0xb3); /* lea imm32(%rbx),%esi */
29797 - EMIT(K, 4);
29798 + EMIT2_off32(0x8d, 0xb3, K); /* lea imm32(%rbx),%esi */
29799 }
29800 } else {
29801 EMIT2(0x89,0xde); /* mov %ebx,%esi */
29802 @@ -686,17 +806,18 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
29803 break;
29804 default:
29805 /* hmm, too complex filter, give up with jit compiler */
29806 - goto out;
29807 + goto error;
29808 }
29809 ilen = prog - temp;
29810 if (image) {
29811 if (unlikely(proglen + ilen > oldproglen)) {
29812 pr_err("bpb_jit_compile fatal error\n");
29813 - kfree(addrs);
29814 - module_free(NULL, image);
29815 - return;
29816 + module_free_exec(NULL, image);
29817 + goto error;
29818 }
29819 + pax_open_kernel();
29820 memcpy(image + proglen, temp, ilen);
29821 + pax_close_kernel();
29822 }
29823 proglen += ilen;
29824 addrs[i] = proglen;
29825 @@ -717,11 +838,9 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
29826 break;
29827 }
29828 if (proglen == oldproglen) {
29829 - image = module_alloc(max_t(unsigned int,
29830 - proglen,
29831 - sizeof(struct work_struct)));
29832 + image = module_alloc_exec(proglen);
29833 if (!image)
29834 - goto out;
29835 + goto error;
29836 }
29837 oldproglen = proglen;
29838 }
29839 @@ -737,7 +856,10 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
29840 bpf_flush_icache(image, image + proglen);
29841
29842 fp->bpf_func = (void *)image;
29843 - }
29844 + } else
29845 +error:
29846 + kfree(fp->work);
29847 +
29848 out:
29849 kfree(addrs);
29850 return;
29851 @@ -745,18 +867,20 @@ out:
29852
29853 static void jit_free_defer(struct work_struct *arg)
29854 {
29855 - module_free(NULL, arg);
29856 + module_free_exec(NULL, ((struct bpf_jit_work *)arg)->image);
29857 + kfree(arg);
29858 }
29859
29860 /* run from softirq, we must use a work_struct to call
29861 - * module_free() from process context
29862 + * module_free_exec() from process context
29863 */
29864 void bpf_jit_free(struct sk_filter *fp)
29865 {
29866 if (fp->bpf_func != sk_run_filter) {
29867 - struct work_struct *work = (struct work_struct *)fp->bpf_func;
29868 + struct work_struct *work = &fp->work->work;
29869
29870 INIT_WORK(work, jit_free_defer);
29871 + fp->work->image = fp->bpf_func;
29872 schedule_work(work);
29873 }
29874 }
29875 diff --git a/arch/x86/oprofile/backtrace.c b/arch/x86/oprofile/backtrace.c
29876 index d6aa6e8..266395a 100644
29877 --- a/arch/x86/oprofile/backtrace.c
29878 +++ b/arch/x86/oprofile/backtrace.c
29879 @@ -46,11 +46,11 @@ dump_user_backtrace_32(struct stack_frame_ia32 *head)
29880 struct stack_frame_ia32 *fp;
29881 unsigned long bytes;
29882
29883 - bytes = copy_from_user_nmi(bufhead, head, sizeof(bufhead));
29884 + bytes = copy_from_user_nmi(bufhead, (const char __force_user *)head, sizeof(bufhead));
29885 if (bytes != sizeof(bufhead))
29886 return NULL;
29887
29888 - fp = (struct stack_frame_ia32 *) compat_ptr(bufhead[0].next_frame);
29889 + fp = (struct stack_frame_ia32 __force_kernel *) compat_ptr(bufhead[0].next_frame);
29890
29891 oprofile_add_trace(bufhead[0].return_address);
29892
29893 @@ -92,7 +92,7 @@ static struct stack_frame *dump_user_backtrace(struct stack_frame *head)
29894 struct stack_frame bufhead[2];
29895 unsigned long bytes;
29896
29897 - bytes = copy_from_user_nmi(bufhead, head, sizeof(bufhead));
29898 + bytes = copy_from_user_nmi(bufhead, (const char __force_user *)head, sizeof(bufhead));
29899 if (bytes != sizeof(bufhead))
29900 return NULL;
29901
29902 @@ -111,7 +111,7 @@ x86_backtrace(struct pt_regs * const regs, unsigned int depth)
29903 {
29904 struct stack_frame *head = (struct stack_frame *)frame_pointer(regs);
29905
29906 - if (!user_mode_vm(regs)) {
29907 + if (!user_mode(regs)) {
29908 unsigned long stack = kernel_stack_pointer(regs);
29909 if (depth)
29910 dump_trace(NULL, regs, (unsigned long *)stack, 0,
29911 diff --git a/arch/x86/oprofile/nmi_int.c b/arch/x86/oprofile/nmi_int.c
29912 index 48768df..ba9143c 100644
29913 --- a/arch/x86/oprofile/nmi_int.c
29914 +++ b/arch/x86/oprofile/nmi_int.c
29915 @@ -23,6 +23,7 @@
29916 #include <asm/nmi.h>
29917 #include <asm/msr.h>
29918 #include <asm/apic.h>
29919 +#include <asm/pgtable.h>
29920
29921 #include "op_counter.h"
29922 #include "op_x86_model.h"
29923 @@ -774,8 +775,11 @@ int __init op_nmi_init(struct oprofile_operations *ops)
29924 if (ret)
29925 return ret;
29926
29927 - if (!model->num_virt_counters)
29928 - model->num_virt_counters = model->num_counters;
29929 + if (!model->num_virt_counters) {
29930 + pax_open_kernel();
29931 + *(unsigned int *)&model->num_virt_counters = model->num_counters;
29932 + pax_close_kernel();
29933 + }
29934
29935 mux_init(ops);
29936
29937 diff --git a/arch/x86/oprofile/op_model_amd.c b/arch/x86/oprofile/op_model_amd.c
29938 index b2b9443..be58856 100644
29939 --- a/arch/x86/oprofile/op_model_amd.c
29940 +++ b/arch/x86/oprofile/op_model_amd.c
29941 @@ -519,9 +519,11 @@ static int op_amd_init(struct oprofile_operations *ops)
29942 num_counters = AMD64_NUM_COUNTERS;
29943 }
29944
29945 - op_amd_spec.num_counters = num_counters;
29946 - op_amd_spec.num_controls = num_counters;
29947 - op_amd_spec.num_virt_counters = max(num_counters, NUM_VIRT_COUNTERS);
29948 + pax_open_kernel();
29949 + *(unsigned int *)&op_amd_spec.num_counters = num_counters;
29950 + *(unsigned int *)&op_amd_spec.num_controls = num_counters;
29951 + *(unsigned int *)&op_amd_spec.num_virt_counters = max(num_counters, NUM_VIRT_COUNTERS);
29952 + pax_close_kernel();
29953
29954 return 0;
29955 }
29956 diff --git a/arch/x86/oprofile/op_model_ppro.c b/arch/x86/oprofile/op_model_ppro.c
29957 index d90528e..0127e2b 100644
29958 --- a/arch/x86/oprofile/op_model_ppro.c
29959 +++ b/arch/x86/oprofile/op_model_ppro.c
29960 @@ -19,6 +19,7 @@
29961 #include <asm/msr.h>
29962 #include <asm/apic.h>
29963 #include <asm/nmi.h>
29964 +#include <asm/pgtable.h>
29965
29966 #include "op_x86_model.h"
29967 #include "op_counter.h"
29968 @@ -221,8 +222,10 @@ static void arch_perfmon_setup_counters(void)
29969
29970 num_counters = min((int)eax.split.num_counters, OP_MAX_COUNTER);
29971
29972 - op_arch_perfmon_spec.num_counters = num_counters;
29973 - op_arch_perfmon_spec.num_controls = num_counters;
29974 + pax_open_kernel();
29975 + *(unsigned int *)&op_arch_perfmon_spec.num_counters = num_counters;
29976 + *(unsigned int *)&op_arch_perfmon_spec.num_controls = num_counters;
29977 + pax_close_kernel();
29978 }
29979
29980 static int arch_perfmon_init(struct oprofile_operations *ignore)
29981 diff --git a/arch/x86/oprofile/op_x86_model.h b/arch/x86/oprofile/op_x86_model.h
29982 index 71e8a67..6a313bb 100644
29983 --- a/arch/x86/oprofile/op_x86_model.h
29984 +++ b/arch/x86/oprofile/op_x86_model.h
29985 @@ -52,7 +52,7 @@ struct op_x86_model_spec {
29986 void (*switch_ctrl)(struct op_x86_model_spec const *model,
29987 struct op_msrs const * const msrs);
29988 #endif
29989 -};
29990 +} __do_const;
29991
29992 struct op_counter_config;
29993
29994 diff --git a/arch/x86/pci/amd_bus.c b/arch/x86/pci/amd_bus.c
29995 index e9e6ed5..e47ae67 100644
29996 --- a/arch/x86/pci/amd_bus.c
29997 +++ b/arch/x86/pci/amd_bus.c
29998 @@ -337,7 +337,7 @@ static int __cpuinit amd_cpu_notify(struct notifier_block *self,
29999 return NOTIFY_OK;
30000 }
30001
30002 -static struct notifier_block __cpuinitdata amd_cpu_notifier = {
30003 +static struct notifier_block amd_cpu_notifier = {
30004 .notifier_call = amd_cpu_notify,
30005 };
30006
30007 diff --git a/arch/x86/pci/irq.c b/arch/x86/pci/irq.c
30008 index 372e9b8..e775a6c 100644
30009 --- a/arch/x86/pci/irq.c
30010 +++ b/arch/x86/pci/irq.c
30011 @@ -50,7 +50,7 @@ struct irq_router {
30012 struct irq_router_handler {
30013 u16 vendor;
30014 int (*probe)(struct irq_router *r, struct pci_dev *router, u16 device);
30015 -};
30016 +} __do_const;
30017
30018 int (*pcibios_enable_irq)(struct pci_dev *dev) = pirq_enable_irq;
30019 void (*pcibios_disable_irq)(struct pci_dev *dev) = NULL;
30020 @@ -794,7 +794,7 @@ static __init int pico_router_probe(struct irq_router *r, struct pci_dev *router
30021 return 0;
30022 }
30023
30024 -static __initdata struct irq_router_handler pirq_routers[] = {
30025 +static __initconst const struct irq_router_handler pirq_routers[] = {
30026 { PCI_VENDOR_ID_INTEL, intel_router_probe },
30027 { PCI_VENDOR_ID_AL, ali_router_probe },
30028 { PCI_VENDOR_ID_ITE, ite_router_probe },
30029 @@ -821,7 +821,7 @@ static struct pci_dev *pirq_router_dev;
30030 static void __init pirq_find_router(struct irq_router *r)
30031 {
30032 struct irq_routing_table *rt = pirq_table;
30033 - struct irq_router_handler *h;
30034 + const struct irq_router_handler *h;
30035
30036 #ifdef CONFIG_PCI_BIOS
30037 if (!rt->signature) {
30038 @@ -1094,7 +1094,7 @@ static int __init fix_acer_tm360_irqrouting(const struct dmi_system_id *d)
30039 return 0;
30040 }
30041
30042 -static struct dmi_system_id __initdata pciirq_dmi_table[] = {
30043 +static const struct dmi_system_id __initconst pciirq_dmi_table[] = {
30044 {
30045 .callback = fix_broken_hp_bios_irq9,
30046 .ident = "HP Pavilion N5400 Series Laptop",
30047 diff --git a/arch/x86/pci/mrst.c b/arch/x86/pci/mrst.c
30048 index 6eb18c4..20d83de 100644
30049 --- a/arch/x86/pci/mrst.c
30050 +++ b/arch/x86/pci/mrst.c
30051 @@ -238,7 +238,9 @@ int __init pci_mrst_init(void)
30052 printk(KERN_INFO "Intel MID platform detected, using MID PCI ops\n");
30053 pci_mmcfg_late_init();
30054 pcibios_enable_irq = mrst_pci_irq_enable;
30055 - pci_root_ops = pci_mrst_ops;
30056 + pax_open_kernel();
30057 + memcpy((void *)&pci_root_ops, &pci_mrst_ops, sizeof(pci_mrst_ops));
30058 + pax_close_kernel();
30059 pci_soc_mode = 1;
30060 /* Continue with standard init */
30061 return 1;
30062 diff --git a/arch/x86/pci/pcbios.c b/arch/x86/pci/pcbios.c
30063 index c77b24a..c979855 100644
30064 --- a/arch/x86/pci/pcbios.c
30065 +++ b/arch/x86/pci/pcbios.c
30066 @@ -79,7 +79,7 @@ union bios32 {
30067 static struct {
30068 unsigned long address;
30069 unsigned short segment;
30070 -} bios32_indirect = { 0, __KERNEL_CS };
30071 +} bios32_indirect __read_only = { 0, __PCIBIOS_CS };
30072
30073 /*
30074 * Returns the entry point for the given service, NULL on error
30075 @@ -92,37 +92,80 @@ static unsigned long bios32_service(unsigned long service)
30076 unsigned long length; /* %ecx */
30077 unsigned long entry; /* %edx */
30078 unsigned long flags;
30079 + struct desc_struct d, *gdt;
30080
30081 local_irq_save(flags);
30082 - __asm__("lcall *(%%edi); cld"
30083 +
30084 + gdt = get_cpu_gdt_table(smp_processor_id());
30085 +
30086 + pack_descriptor(&d, 0UL, 0xFFFFFUL, 0x9B, 0xC);
30087 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_CS, &d, DESCTYPE_S);
30088 + pack_descriptor(&d, 0UL, 0xFFFFFUL, 0x93, 0xC);
30089 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_DS, &d, DESCTYPE_S);
30090 +
30091 + __asm__("movw %w7, %%ds; lcall *(%%edi); push %%ss; pop %%ds; cld"
30092 : "=a" (return_code),
30093 "=b" (address),
30094 "=c" (length),
30095 "=d" (entry)
30096 : "0" (service),
30097 "1" (0),
30098 - "D" (&bios32_indirect));
30099 + "D" (&bios32_indirect),
30100 + "r"(__PCIBIOS_DS)
30101 + : "memory");
30102 +
30103 + pax_open_kernel();
30104 + gdt[GDT_ENTRY_PCIBIOS_CS].a = 0;
30105 + gdt[GDT_ENTRY_PCIBIOS_CS].b = 0;
30106 + gdt[GDT_ENTRY_PCIBIOS_DS].a = 0;
30107 + gdt[GDT_ENTRY_PCIBIOS_DS].b = 0;
30108 + pax_close_kernel();
30109 +
30110 local_irq_restore(flags);
30111
30112 switch (return_code) {
30113 - case 0:
30114 - return address + entry;
30115 - case 0x80: /* Not present */
30116 - printk(KERN_WARNING "bios32_service(0x%lx): not present\n", service);
30117 - return 0;
30118 - default: /* Shouldn't happen */
30119 - printk(KERN_WARNING "bios32_service(0x%lx): returned 0x%x -- BIOS bug!\n",
30120 - service, return_code);
30121 + case 0: {
30122 + int cpu;
30123 + unsigned char flags;
30124 +
30125 + printk(KERN_INFO "bios32_service: base:%08lx length:%08lx entry:%08lx\n", address, length, entry);
30126 + if (address >= 0xFFFF0 || length > 0x100000 - address || length <= entry) {
30127 + printk(KERN_WARNING "bios32_service: not valid\n");
30128 return 0;
30129 + }
30130 + address = address + PAGE_OFFSET;
30131 + length += 16UL; /* some BIOSs underreport this... */
30132 + flags = 4;
30133 + if (length >= 64*1024*1024) {
30134 + length >>= PAGE_SHIFT;
30135 + flags |= 8;
30136 + }
30137 +
30138 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
30139 + gdt = get_cpu_gdt_table(cpu);
30140 + pack_descriptor(&d, address, length, 0x9b, flags);
30141 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_CS, &d, DESCTYPE_S);
30142 + pack_descriptor(&d, address, length, 0x93, flags);
30143 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_DS, &d, DESCTYPE_S);
30144 + }
30145 + return entry;
30146 + }
30147 + case 0x80: /* Not present */
30148 + printk(KERN_WARNING "bios32_service(0x%lx): not present\n", service);
30149 + return 0;
30150 + default: /* Shouldn't happen */
30151 + printk(KERN_WARNING "bios32_service(0x%lx): returned 0x%x -- BIOS bug!\n",
30152 + service, return_code);
30153 + return 0;
30154 }
30155 }
30156
30157 static struct {
30158 unsigned long address;
30159 unsigned short segment;
30160 -} pci_indirect = { 0, __KERNEL_CS };
30161 +} pci_indirect __read_only = { 0, __PCIBIOS_CS };
30162
30163 -static int pci_bios_present;
30164 +static int pci_bios_present __read_only;
30165
30166 static int check_pcibios(void)
30167 {
30168 @@ -131,11 +174,13 @@ static int check_pcibios(void)
30169 unsigned long flags, pcibios_entry;
30170
30171 if ((pcibios_entry = bios32_service(PCI_SERVICE))) {
30172 - pci_indirect.address = pcibios_entry + PAGE_OFFSET;
30173 + pci_indirect.address = pcibios_entry;
30174
30175 local_irq_save(flags);
30176 - __asm__(
30177 - "lcall *(%%edi); cld\n\t"
30178 + __asm__("movw %w6, %%ds\n\t"
30179 + "lcall *%%ss:(%%edi); cld\n\t"
30180 + "push %%ss\n\t"
30181 + "pop %%ds\n\t"
30182 "jc 1f\n\t"
30183 "xor %%ah, %%ah\n"
30184 "1:"
30185 @@ -144,7 +189,8 @@ static int check_pcibios(void)
30186 "=b" (ebx),
30187 "=c" (ecx)
30188 : "1" (PCIBIOS_PCI_BIOS_PRESENT),
30189 - "D" (&pci_indirect)
30190 + "D" (&pci_indirect),
30191 + "r" (__PCIBIOS_DS)
30192 : "memory");
30193 local_irq_restore(flags);
30194
30195 @@ -189,7 +235,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30196
30197 switch (len) {
30198 case 1:
30199 - __asm__("lcall *(%%esi); cld\n\t"
30200 + __asm__("movw %w6, %%ds\n\t"
30201 + "lcall *%%ss:(%%esi); cld\n\t"
30202 + "push %%ss\n\t"
30203 + "pop %%ds\n\t"
30204 "jc 1f\n\t"
30205 "xor %%ah, %%ah\n"
30206 "1:"
30207 @@ -198,7 +247,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30208 : "1" (PCIBIOS_READ_CONFIG_BYTE),
30209 "b" (bx),
30210 "D" ((long)reg),
30211 - "S" (&pci_indirect));
30212 + "S" (&pci_indirect),
30213 + "r" (__PCIBIOS_DS));
30214 /*
30215 * Zero-extend the result beyond 8 bits, do not trust the
30216 * BIOS having done it:
30217 @@ -206,7 +256,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30218 *value &= 0xff;
30219 break;
30220 case 2:
30221 - __asm__("lcall *(%%esi); cld\n\t"
30222 + __asm__("movw %w6, %%ds\n\t"
30223 + "lcall *%%ss:(%%esi); cld\n\t"
30224 + "push %%ss\n\t"
30225 + "pop %%ds\n\t"
30226 "jc 1f\n\t"
30227 "xor %%ah, %%ah\n"
30228 "1:"
30229 @@ -215,7 +268,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30230 : "1" (PCIBIOS_READ_CONFIG_WORD),
30231 "b" (bx),
30232 "D" ((long)reg),
30233 - "S" (&pci_indirect));
30234 + "S" (&pci_indirect),
30235 + "r" (__PCIBIOS_DS));
30236 /*
30237 * Zero-extend the result beyond 16 bits, do not trust the
30238 * BIOS having done it:
30239 @@ -223,7 +277,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30240 *value &= 0xffff;
30241 break;
30242 case 4:
30243 - __asm__("lcall *(%%esi); cld\n\t"
30244 + __asm__("movw %w6, %%ds\n\t"
30245 + "lcall *%%ss:(%%esi); cld\n\t"
30246 + "push %%ss\n\t"
30247 + "pop %%ds\n\t"
30248 "jc 1f\n\t"
30249 "xor %%ah, %%ah\n"
30250 "1:"
30251 @@ -232,7 +289,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30252 : "1" (PCIBIOS_READ_CONFIG_DWORD),
30253 "b" (bx),
30254 "D" ((long)reg),
30255 - "S" (&pci_indirect));
30256 + "S" (&pci_indirect),
30257 + "r" (__PCIBIOS_DS));
30258 break;
30259 }
30260
30261 @@ -256,7 +314,10 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
30262
30263 switch (len) {
30264 case 1:
30265 - __asm__("lcall *(%%esi); cld\n\t"
30266 + __asm__("movw %w6, %%ds\n\t"
30267 + "lcall *%%ss:(%%esi); cld\n\t"
30268 + "push %%ss\n\t"
30269 + "pop %%ds\n\t"
30270 "jc 1f\n\t"
30271 "xor %%ah, %%ah\n"
30272 "1:"
30273 @@ -265,10 +326,14 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
30274 "c" (value),
30275 "b" (bx),
30276 "D" ((long)reg),
30277 - "S" (&pci_indirect));
30278 + "S" (&pci_indirect),
30279 + "r" (__PCIBIOS_DS));
30280 break;
30281 case 2:
30282 - __asm__("lcall *(%%esi); cld\n\t"
30283 + __asm__("movw %w6, %%ds\n\t"
30284 + "lcall *%%ss:(%%esi); cld\n\t"
30285 + "push %%ss\n\t"
30286 + "pop %%ds\n\t"
30287 "jc 1f\n\t"
30288 "xor %%ah, %%ah\n"
30289 "1:"
30290 @@ -277,10 +342,14 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
30291 "c" (value),
30292 "b" (bx),
30293 "D" ((long)reg),
30294 - "S" (&pci_indirect));
30295 + "S" (&pci_indirect),
30296 + "r" (__PCIBIOS_DS));
30297 break;
30298 case 4:
30299 - __asm__("lcall *(%%esi); cld\n\t"
30300 + __asm__("movw %w6, %%ds\n\t"
30301 + "lcall *%%ss:(%%esi); cld\n\t"
30302 + "push %%ss\n\t"
30303 + "pop %%ds\n\t"
30304 "jc 1f\n\t"
30305 "xor %%ah, %%ah\n"
30306 "1:"
30307 @@ -289,7 +358,8 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
30308 "c" (value),
30309 "b" (bx),
30310 "D" ((long)reg),
30311 - "S" (&pci_indirect));
30312 + "S" (&pci_indirect),
30313 + "r" (__PCIBIOS_DS));
30314 break;
30315 }
30316
30317 @@ -394,10 +464,13 @@ struct irq_routing_table * pcibios_get_irq_routing_table(void)
30318
30319 DBG("PCI: Fetching IRQ routing table... ");
30320 __asm__("push %%es\n\t"
30321 + "movw %w8, %%ds\n\t"
30322 "push %%ds\n\t"
30323 "pop %%es\n\t"
30324 - "lcall *(%%esi); cld\n\t"
30325 + "lcall *%%ss:(%%esi); cld\n\t"
30326 "pop %%es\n\t"
30327 + "push %%ss\n\t"
30328 + "pop %%ds\n"
30329 "jc 1f\n\t"
30330 "xor %%ah, %%ah\n"
30331 "1:"
30332 @@ -408,7 +481,8 @@ struct irq_routing_table * pcibios_get_irq_routing_table(void)
30333 "1" (0),
30334 "D" ((long) &opt),
30335 "S" (&pci_indirect),
30336 - "m" (opt)
30337 + "m" (opt),
30338 + "r" (__PCIBIOS_DS)
30339 : "memory");
30340 DBG("OK ret=%d, size=%d, map=%x\n", ret, opt.size, map);
30341 if (ret & 0xff00)
30342 @@ -432,7 +506,10 @@ int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq)
30343 {
30344 int ret;
30345
30346 - __asm__("lcall *(%%esi); cld\n\t"
30347 + __asm__("movw %w5, %%ds\n\t"
30348 + "lcall *%%ss:(%%esi); cld\n\t"
30349 + "push %%ss\n\t"
30350 + "pop %%ds\n"
30351 "jc 1f\n\t"
30352 "xor %%ah, %%ah\n"
30353 "1:"
30354 @@ -440,7 +517,8 @@ int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq)
30355 : "0" (PCIBIOS_SET_PCI_HW_INT),
30356 "b" ((dev->bus->number << 8) | dev->devfn),
30357 "c" ((irq << 8) | (pin + 10)),
30358 - "S" (&pci_indirect));
30359 + "S" (&pci_indirect),
30360 + "r" (__PCIBIOS_DS));
30361 return !(ret & 0xff00);
30362 }
30363 EXPORT_SYMBOL(pcibios_set_irq_routing);
30364 diff --git a/arch/x86/platform/efi/efi_32.c b/arch/x86/platform/efi/efi_32.c
30365 index 40e4469..1ab536e 100644
30366 --- a/arch/x86/platform/efi/efi_32.c
30367 +++ b/arch/x86/platform/efi/efi_32.c
30368 @@ -44,11 +44,22 @@ void efi_call_phys_prelog(void)
30369 {
30370 struct desc_ptr gdt_descr;
30371
30372 +#ifdef CONFIG_PAX_KERNEXEC
30373 + struct desc_struct d;
30374 +#endif
30375 +
30376 local_irq_save(efi_rt_eflags);
30377
30378 load_cr3(initial_page_table);
30379 __flush_tlb_all();
30380
30381 +#ifdef CONFIG_PAX_KERNEXEC
30382 + pack_descriptor(&d, 0, 0xFFFFF, 0x9B, 0xC);
30383 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_CS, &d, DESCTYPE_S);
30384 + pack_descriptor(&d, 0, 0xFFFFF, 0x93, 0xC);
30385 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_DS, &d, DESCTYPE_S);
30386 +#endif
30387 +
30388 gdt_descr.address = __pa(get_cpu_gdt_table(0));
30389 gdt_descr.size = GDT_SIZE - 1;
30390 load_gdt(&gdt_descr);
30391 @@ -58,6 +69,14 @@ void efi_call_phys_epilog(void)
30392 {
30393 struct desc_ptr gdt_descr;
30394
30395 +#ifdef CONFIG_PAX_KERNEXEC
30396 + struct desc_struct d;
30397 +
30398 + memset(&d, 0, sizeof d);
30399 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_CS, &d, DESCTYPE_S);
30400 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_DS, &d, DESCTYPE_S);
30401 +#endif
30402 +
30403 gdt_descr.address = (unsigned long)get_cpu_gdt_table(0);
30404 gdt_descr.size = GDT_SIZE - 1;
30405 load_gdt(&gdt_descr);
30406 diff --git a/arch/x86/platform/efi/efi_stub_32.S b/arch/x86/platform/efi/efi_stub_32.S
30407 index fbe66e6..eae5e38 100644
30408 --- a/arch/x86/platform/efi/efi_stub_32.S
30409 +++ b/arch/x86/platform/efi/efi_stub_32.S
30410 @@ -6,7 +6,9 @@
30411 */
30412
30413 #include <linux/linkage.h>
30414 +#include <linux/init.h>
30415 #include <asm/page_types.h>
30416 +#include <asm/segment.h>
30417
30418 /*
30419 * efi_call_phys(void *, ...) is a function with variable parameters.
30420 @@ -20,7 +22,7 @@
30421 * service functions will comply with gcc calling convention, too.
30422 */
30423
30424 -.text
30425 +__INIT
30426 ENTRY(efi_call_phys)
30427 /*
30428 * 0. The function can only be called in Linux kernel. So CS has been
30429 @@ -36,10 +38,24 @@ ENTRY(efi_call_phys)
30430 * The mapping of lower virtual memory has been created in prelog and
30431 * epilog.
30432 */
30433 - movl $1f, %edx
30434 - subl $__PAGE_OFFSET, %edx
30435 - jmp *%edx
30436 +#ifdef CONFIG_PAX_KERNEXEC
30437 + movl $(__KERNEXEC_EFI_DS), %edx
30438 + mov %edx, %ds
30439 + mov %edx, %es
30440 + mov %edx, %ss
30441 + addl $2f,(1f)
30442 + ljmp *(1f)
30443 +
30444 +__INITDATA
30445 +1: .long __LOAD_PHYSICAL_ADDR, __KERNEXEC_EFI_CS
30446 +.previous
30447 +
30448 +2:
30449 + subl $2b,(1b)
30450 +#else
30451 + jmp 1f-__PAGE_OFFSET
30452 1:
30453 +#endif
30454
30455 /*
30456 * 2. Now on the top of stack is the return
30457 @@ -47,14 +63,8 @@ ENTRY(efi_call_phys)
30458 * parameter 2, ..., param n. To make things easy, we save the return
30459 * address of efi_call_phys in a global variable.
30460 */
30461 - popl %edx
30462 - movl %edx, saved_return_addr
30463 - /* get the function pointer into ECX*/
30464 - popl %ecx
30465 - movl %ecx, efi_rt_function_ptr
30466 - movl $2f, %edx
30467 - subl $__PAGE_OFFSET, %edx
30468 - pushl %edx
30469 + popl (saved_return_addr)
30470 + popl (efi_rt_function_ptr)
30471
30472 /*
30473 * 3. Clear PG bit in %CR0.
30474 @@ -73,9 +83,8 @@ ENTRY(efi_call_phys)
30475 /*
30476 * 5. Call the physical function.
30477 */
30478 - jmp *%ecx
30479 + call *(efi_rt_function_ptr-__PAGE_OFFSET)
30480
30481 -2:
30482 /*
30483 * 6. After EFI runtime service returns, control will return to
30484 * following instruction. We'd better readjust stack pointer first.
30485 @@ -88,35 +97,36 @@ ENTRY(efi_call_phys)
30486 movl %cr0, %edx
30487 orl $0x80000000, %edx
30488 movl %edx, %cr0
30489 - jmp 1f
30490 -1:
30491 +
30492 /*
30493 * 8. Now restore the virtual mode from flat mode by
30494 * adding EIP with PAGE_OFFSET.
30495 */
30496 - movl $1f, %edx
30497 - jmp *%edx
30498 +#ifdef CONFIG_PAX_KERNEXEC
30499 + movl $(__KERNEL_DS), %edx
30500 + mov %edx, %ds
30501 + mov %edx, %es
30502 + mov %edx, %ss
30503 + ljmp $(__KERNEL_CS),$1f
30504 +#else
30505 + jmp 1f+__PAGE_OFFSET
30506 +#endif
30507 1:
30508
30509 /*
30510 * 9. Balance the stack. And because EAX contain the return value,
30511 * we'd better not clobber it.
30512 */
30513 - leal efi_rt_function_ptr, %edx
30514 - movl (%edx), %ecx
30515 - pushl %ecx
30516 + pushl (efi_rt_function_ptr)
30517
30518 /*
30519 - * 10. Push the saved return address onto the stack and return.
30520 + * 10. Return to the saved return address.
30521 */
30522 - leal saved_return_addr, %edx
30523 - movl (%edx), %ecx
30524 - pushl %ecx
30525 - ret
30526 + jmpl *(saved_return_addr)
30527 ENDPROC(efi_call_phys)
30528 .previous
30529
30530 -.data
30531 +__INITDATA
30532 saved_return_addr:
30533 .long 0
30534 efi_rt_function_ptr:
30535 diff --git a/arch/x86/platform/efi/efi_stub_64.S b/arch/x86/platform/efi/efi_stub_64.S
30536 index 4c07cca..2c8427d 100644
30537 --- a/arch/x86/platform/efi/efi_stub_64.S
30538 +++ b/arch/x86/platform/efi/efi_stub_64.S
30539 @@ -7,6 +7,7 @@
30540 */
30541
30542 #include <linux/linkage.h>
30543 +#include <asm/alternative-asm.h>
30544
30545 #define SAVE_XMM \
30546 mov %rsp, %rax; \
30547 @@ -40,6 +41,7 @@ ENTRY(efi_call0)
30548 call *%rdi
30549 addq $32, %rsp
30550 RESTORE_XMM
30551 + pax_force_retaddr 0, 1
30552 ret
30553 ENDPROC(efi_call0)
30554
30555 @@ -50,6 +52,7 @@ ENTRY(efi_call1)
30556 call *%rdi
30557 addq $32, %rsp
30558 RESTORE_XMM
30559 + pax_force_retaddr 0, 1
30560 ret
30561 ENDPROC(efi_call1)
30562
30563 @@ -60,6 +63,7 @@ ENTRY(efi_call2)
30564 call *%rdi
30565 addq $32, %rsp
30566 RESTORE_XMM
30567 + pax_force_retaddr 0, 1
30568 ret
30569 ENDPROC(efi_call2)
30570
30571 @@ -71,6 +75,7 @@ ENTRY(efi_call3)
30572 call *%rdi
30573 addq $32, %rsp
30574 RESTORE_XMM
30575 + pax_force_retaddr 0, 1
30576 ret
30577 ENDPROC(efi_call3)
30578
30579 @@ -83,6 +88,7 @@ ENTRY(efi_call4)
30580 call *%rdi
30581 addq $32, %rsp
30582 RESTORE_XMM
30583 + pax_force_retaddr 0, 1
30584 ret
30585 ENDPROC(efi_call4)
30586
30587 @@ -96,6 +102,7 @@ ENTRY(efi_call5)
30588 call *%rdi
30589 addq $48, %rsp
30590 RESTORE_XMM
30591 + pax_force_retaddr 0, 1
30592 ret
30593 ENDPROC(efi_call5)
30594
30595 @@ -112,5 +119,6 @@ ENTRY(efi_call6)
30596 call *%rdi
30597 addq $48, %rsp
30598 RESTORE_XMM
30599 + pax_force_retaddr 0, 1
30600 ret
30601 ENDPROC(efi_call6)
30602 diff --git a/arch/x86/platform/mrst/mrst.c b/arch/x86/platform/mrst/mrst.c
30603 index e31bcd8..f12dc46 100644
30604 --- a/arch/x86/platform/mrst/mrst.c
30605 +++ b/arch/x86/platform/mrst/mrst.c
30606 @@ -78,13 +78,15 @@ struct sfi_rtc_table_entry sfi_mrtc_array[SFI_MRTC_MAX];
30607 EXPORT_SYMBOL_GPL(sfi_mrtc_array);
30608 int sfi_mrtc_num;
30609
30610 -static void mrst_power_off(void)
30611 +static __noreturn void mrst_power_off(void)
30612 {
30613 + BUG();
30614 }
30615
30616 -static void mrst_reboot(void)
30617 +static __noreturn void mrst_reboot(void)
30618 {
30619 intel_scu_ipc_simple_command(IPCMSG_COLD_BOOT, 0);
30620 + BUG();
30621 }
30622
30623 /* parse all the mtimer info to a static mtimer array */
30624 diff --git a/arch/x86/platform/olpc/olpc_dt.c b/arch/x86/platform/olpc/olpc_dt.c
30625 index d6ee929..3637cb5 100644
30626 --- a/arch/x86/platform/olpc/olpc_dt.c
30627 +++ b/arch/x86/platform/olpc/olpc_dt.c
30628 @@ -156,7 +156,7 @@ void * __init prom_early_alloc(unsigned long size)
30629 return res;
30630 }
30631
30632 -static struct of_pdt_ops prom_olpc_ops __initdata = {
30633 +static struct of_pdt_ops prom_olpc_ops __initconst = {
30634 .nextprop = olpc_dt_nextprop,
30635 .getproplen = olpc_dt_getproplen,
30636 .getproperty = olpc_dt_getproperty,
30637 diff --git a/arch/x86/power/cpu.c b/arch/x86/power/cpu.c
30638 index 3c68768..07e82b8 100644
30639 --- a/arch/x86/power/cpu.c
30640 +++ b/arch/x86/power/cpu.c
30641 @@ -134,7 +134,7 @@ static void do_fpu_end(void)
30642 static void fix_processor_context(void)
30643 {
30644 int cpu = smp_processor_id();
30645 - struct tss_struct *t = &per_cpu(init_tss, cpu);
30646 + struct tss_struct *t = init_tss + cpu;
30647
30648 set_tss_desc(cpu, t); /*
30649 * This just modifies memory; should not be
30650 @@ -144,8 +144,6 @@ static void fix_processor_context(void)
30651 */
30652
30653 #ifdef CONFIG_X86_64
30654 - get_cpu_gdt_table(cpu)[GDT_ENTRY_TSS].type = 9;
30655 -
30656 syscall_init(); /* This sets MSR_*STAR and related */
30657 #endif
30658 load_TR_desc(); /* This does ltr */
30659 diff --git a/arch/x86/realmode/init.c b/arch/x86/realmode/init.c
30660 index a44f457..9140171 100644
30661 --- a/arch/x86/realmode/init.c
30662 +++ b/arch/x86/realmode/init.c
30663 @@ -70,7 +70,13 @@ void __init setup_real_mode(void)
30664 __va(real_mode_header->trampoline_header);
30665
30666 #ifdef CONFIG_X86_32
30667 - trampoline_header->start = __pa_symbol(startup_32_smp);
30668 + trampoline_header->start = __pa_symbol(ktla_ktva(startup_32_smp));
30669 +
30670 +#ifdef CONFIG_PAX_KERNEXEC
30671 + trampoline_header->start -= LOAD_PHYSICAL_ADDR;
30672 +#endif
30673 +
30674 + trampoline_header->boot_cs = __BOOT_CS;
30675 trampoline_header->gdt_limit = __BOOT_DS + 7;
30676 trampoline_header->gdt_base = __pa_symbol(boot_gdt);
30677 #else
30678 @@ -86,7 +92,7 @@ void __init setup_real_mode(void)
30679 *trampoline_cr4_features = read_cr4();
30680
30681 trampoline_pgd = (u64 *) __va(real_mode_header->trampoline_pgd);
30682 - trampoline_pgd[0] = init_level4_pgt[pgd_index(__PAGE_OFFSET)].pgd;
30683 + trampoline_pgd[0] = init_level4_pgt[pgd_index(__PAGE_OFFSET)].pgd & ~_PAGE_NX;
30684 trampoline_pgd[511] = init_level4_pgt[511].pgd;
30685 #endif
30686 }
30687 diff --git a/arch/x86/realmode/rm/Makefile b/arch/x86/realmode/rm/Makefile
30688 index 8869287..d577672 100644
30689 --- a/arch/x86/realmode/rm/Makefile
30690 +++ b/arch/x86/realmode/rm/Makefile
30691 @@ -78,5 +78,8 @@ KBUILD_CFLAGS := $(LINUXINCLUDE) -m32 -g -Os -D_SETUP -D__KERNEL__ -D_WAKEUP \
30692 $(call cc-option, -fno-unit-at-a-time)) \
30693 $(call cc-option, -fno-stack-protector) \
30694 $(call cc-option, -mpreferred-stack-boundary=2)
30695 +ifdef CONSTIFY_PLUGIN
30696 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
30697 +endif
30698 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
30699 GCOV_PROFILE := n
30700 diff --git a/arch/x86/realmode/rm/header.S b/arch/x86/realmode/rm/header.S
30701 index a28221d..93c40f1 100644
30702 --- a/arch/x86/realmode/rm/header.S
30703 +++ b/arch/x86/realmode/rm/header.S
30704 @@ -30,7 +30,9 @@ GLOBAL(real_mode_header)
30705 #endif
30706 /* APM/BIOS reboot */
30707 .long pa_machine_real_restart_asm
30708 -#ifdef CONFIG_X86_64
30709 +#ifdef CONFIG_X86_32
30710 + .long __KERNEL_CS
30711 +#else
30712 .long __KERNEL32_CS
30713 #endif
30714 END(real_mode_header)
30715 diff --git a/arch/x86/realmode/rm/trampoline_32.S b/arch/x86/realmode/rm/trampoline_32.S
30716 index c1b2791..f9e31c7 100644
30717 --- a/arch/x86/realmode/rm/trampoline_32.S
30718 +++ b/arch/x86/realmode/rm/trampoline_32.S
30719 @@ -25,6 +25,12 @@
30720 #include <asm/page_types.h>
30721 #include "realmode.h"
30722
30723 +#ifdef CONFIG_PAX_KERNEXEC
30724 +#define ta(X) (X)
30725 +#else
30726 +#define ta(X) (pa_ ## X)
30727 +#endif
30728 +
30729 .text
30730 .code16
30731
30732 @@ -39,8 +45,6 @@ ENTRY(trampoline_start)
30733
30734 cli # We should be safe anyway
30735
30736 - movl tr_start, %eax # where we need to go
30737 -
30738 movl $0xA5A5A5A5, trampoline_status
30739 # write marker for master knows we're running
30740
30741 @@ -56,7 +60,7 @@ ENTRY(trampoline_start)
30742 movw $1, %dx # protected mode (PE) bit
30743 lmsw %dx # into protected mode
30744
30745 - ljmpl $__BOOT_CS, $pa_startup_32
30746 + ljmpl *(trampoline_header)
30747
30748 .section ".text32","ax"
30749 .code32
30750 @@ -67,7 +71,7 @@ ENTRY(startup_32) # note: also used from wakeup_asm.S
30751 .balign 8
30752 GLOBAL(trampoline_header)
30753 tr_start: .space 4
30754 - tr_gdt_pad: .space 2
30755 + tr_boot_cs: .space 2
30756 tr_gdt: .space 6
30757 END(trampoline_header)
30758
30759 diff --git a/arch/x86/realmode/rm/trampoline_64.S b/arch/x86/realmode/rm/trampoline_64.S
30760 index bb360dc..3e5945f 100644
30761 --- a/arch/x86/realmode/rm/trampoline_64.S
30762 +++ b/arch/x86/realmode/rm/trampoline_64.S
30763 @@ -107,7 +107,7 @@ ENTRY(startup_32)
30764 wrmsr
30765
30766 # Enable paging and in turn activate Long Mode
30767 - movl $(X86_CR0_PG | X86_CR0_WP | X86_CR0_PE), %eax
30768 + movl $(X86_CR0_PG | X86_CR0_PE), %eax
30769 movl %eax, %cr0
30770
30771 /*
30772 diff --git a/arch/x86/tools/relocs.c b/arch/x86/tools/relocs.c
30773 index 79d67bd..c7e1b90 100644
30774 --- a/arch/x86/tools/relocs.c
30775 +++ b/arch/x86/tools/relocs.c
30776 @@ -12,10 +12,13 @@
30777 #include <regex.h>
30778 #include <tools/le_byteshift.h>
30779
30780 +#include "../../../include/generated/autoconf.h"
30781 +
30782 static void die(char *fmt, ...);
30783
30784 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
30785 static Elf32_Ehdr ehdr;
30786 +static Elf32_Phdr *phdr;
30787 static unsigned long reloc_count, reloc_idx;
30788 static unsigned long *relocs;
30789 static unsigned long reloc16_count, reloc16_idx;
30790 @@ -330,9 +333,39 @@ static void read_ehdr(FILE *fp)
30791 }
30792 }
30793
30794 +static void read_phdrs(FILE *fp)
30795 +{
30796 + unsigned int i;
30797 +
30798 + phdr = calloc(ehdr.e_phnum, sizeof(Elf32_Phdr));
30799 + if (!phdr) {
30800 + die("Unable to allocate %d program headers\n",
30801 + ehdr.e_phnum);
30802 + }
30803 + if (fseek(fp, ehdr.e_phoff, SEEK_SET) < 0) {
30804 + die("Seek to %d failed: %s\n",
30805 + ehdr.e_phoff, strerror(errno));
30806 + }
30807 + if (fread(phdr, sizeof(*phdr), ehdr.e_phnum, fp) != ehdr.e_phnum) {
30808 + die("Cannot read ELF program headers: %s\n",
30809 + strerror(errno));
30810 + }
30811 + for(i = 0; i < ehdr.e_phnum; i++) {
30812 + phdr[i].p_type = elf32_to_cpu(phdr[i].p_type);
30813 + phdr[i].p_offset = elf32_to_cpu(phdr[i].p_offset);
30814 + phdr[i].p_vaddr = elf32_to_cpu(phdr[i].p_vaddr);
30815 + phdr[i].p_paddr = elf32_to_cpu(phdr[i].p_paddr);
30816 + phdr[i].p_filesz = elf32_to_cpu(phdr[i].p_filesz);
30817 + phdr[i].p_memsz = elf32_to_cpu(phdr[i].p_memsz);
30818 + phdr[i].p_flags = elf32_to_cpu(phdr[i].p_flags);
30819 + phdr[i].p_align = elf32_to_cpu(phdr[i].p_align);
30820 + }
30821 +
30822 +}
30823 +
30824 static void read_shdrs(FILE *fp)
30825 {
30826 - int i;
30827 + unsigned int i;
30828 Elf32_Shdr shdr;
30829
30830 secs = calloc(ehdr.e_shnum, sizeof(struct section));
30831 @@ -367,7 +400,7 @@ static void read_shdrs(FILE *fp)
30832
30833 static void read_strtabs(FILE *fp)
30834 {
30835 - int i;
30836 + unsigned int i;
30837 for (i = 0; i < ehdr.e_shnum; i++) {
30838 struct section *sec = &secs[i];
30839 if (sec->shdr.sh_type != SHT_STRTAB) {
30840 @@ -392,7 +425,7 @@ static void read_strtabs(FILE *fp)
30841
30842 static void read_symtabs(FILE *fp)
30843 {
30844 - int i,j;
30845 + unsigned int i,j;
30846 for (i = 0; i < ehdr.e_shnum; i++) {
30847 struct section *sec = &secs[i];
30848 if (sec->shdr.sh_type != SHT_SYMTAB) {
30849 @@ -423,9 +456,11 @@ static void read_symtabs(FILE *fp)
30850 }
30851
30852
30853 -static void read_relocs(FILE *fp)
30854 +static void read_relocs(FILE *fp, int use_real_mode)
30855 {
30856 - int i,j;
30857 + unsigned int i,j;
30858 + uint32_t base;
30859 +
30860 for (i = 0; i < ehdr.e_shnum; i++) {
30861 struct section *sec = &secs[i];
30862 if (sec->shdr.sh_type != SHT_REL) {
30863 @@ -445,9 +480,22 @@ static void read_relocs(FILE *fp)
30864 die("Cannot read symbol table: %s\n",
30865 strerror(errno));
30866 }
30867 + base = 0;
30868 +
30869 +#ifdef CONFIG_X86_32
30870 + for (j = 0; !use_real_mode && j < ehdr.e_phnum; j++) {
30871 + if (phdr[j].p_type != PT_LOAD )
30872 + continue;
30873 + 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)
30874 + continue;
30875 + base = CONFIG_PAGE_OFFSET + phdr[j].p_paddr - phdr[j].p_vaddr;
30876 + break;
30877 + }
30878 +#endif
30879 +
30880 for (j = 0; j < sec->shdr.sh_size/sizeof(Elf32_Rel); j++) {
30881 Elf32_Rel *rel = &sec->reltab[j];
30882 - rel->r_offset = elf32_to_cpu(rel->r_offset);
30883 + rel->r_offset = elf32_to_cpu(rel->r_offset) + base;
30884 rel->r_info = elf32_to_cpu(rel->r_info);
30885 }
30886 }
30887 @@ -456,13 +504,13 @@ static void read_relocs(FILE *fp)
30888
30889 static void print_absolute_symbols(void)
30890 {
30891 - int i;
30892 + unsigned int i;
30893 printf("Absolute symbols\n");
30894 printf(" Num: Value Size Type Bind Visibility Name\n");
30895 for (i = 0; i < ehdr.e_shnum; i++) {
30896 struct section *sec = &secs[i];
30897 char *sym_strtab;
30898 - int j;
30899 + unsigned int j;
30900
30901 if (sec->shdr.sh_type != SHT_SYMTAB) {
30902 continue;
30903 @@ -489,14 +537,14 @@ static void print_absolute_symbols(void)
30904
30905 static void print_absolute_relocs(void)
30906 {
30907 - int i, printed = 0;
30908 + unsigned int i, printed = 0;
30909
30910 for (i = 0; i < ehdr.e_shnum; i++) {
30911 struct section *sec = &secs[i];
30912 struct section *sec_applies, *sec_symtab;
30913 char *sym_strtab;
30914 Elf32_Sym *sh_symtab;
30915 - int j;
30916 + unsigned int j;
30917 if (sec->shdr.sh_type != SHT_REL) {
30918 continue;
30919 }
30920 @@ -558,13 +606,13 @@ static void print_absolute_relocs(void)
30921 static void walk_relocs(void (*visit)(Elf32_Rel *rel, Elf32_Sym *sym),
30922 int use_real_mode)
30923 {
30924 - int i;
30925 + unsigned int i;
30926 /* Walk through the relocations */
30927 for (i = 0; i < ehdr.e_shnum; i++) {
30928 char *sym_strtab;
30929 Elf32_Sym *sh_symtab;
30930 struct section *sec_applies, *sec_symtab;
30931 - int j;
30932 + unsigned int j;
30933 struct section *sec = &secs[i];
30934
30935 if (sec->shdr.sh_type != SHT_REL) {
30936 @@ -588,6 +636,24 @@ static void walk_relocs(void (*visit)(Elf32_Rel *rel, Elf32_Sym *sym),
30937 sym = &sh_symtab[ELF32_R_SYM(rel->r_info)];
30938 r_type = ELF32_R_TYPE(rel->r_info);
30939
30940 + if (!use_real_mode) {
30941 + /* Don't relocate actual per-cpu variables, they are absolute indices, not addresses */
30942 + if (!strcmp(sec_name(sym->st_shndx), ".data..percpu") && strcmp(sym_name(sym_strtab, sym), "__per_cpu_load"))
30943 + continue;
30944 +
30945 +#if defined(CONFIG_PAX_KERNEXEC) && defined(CONFIG_X86_32)
30946 + /* Don't relocate actual code, they are relocated implicitly by the base address of KERNEL_CS */
30947 + if (!strcmp(sec_name(sym->st_shndx), ".text.end") && !strcmp(sym_name(sym_strtab, sym), "_etext"))
30948 + continue;
30949 + if (!strcmp(sec_name(sym->st_shndx), ".init.text"))
30950 + continue;
30951 + if (!strcmp(sec_name(sym->st_shndx), ".exit.text"))
30952 + continue;
30953 + if (!strcmp(sec_name(sym->st_shndx), ".text") && strcmp(sym_name(sym_strtab, sym), "__LOAD_PHYSICAL_ADDR"))
30954 + continue;
30955 +#endif
30956 + }
30957 +
30958 shn_abs = sym->st_shndx == SHN_ABS;
30959
30960 switch (r_type) {
30961 @@ -681,7 +747,7 @@ static int write32(unsigned int v, FILE *f)
30962
30963 static void emit_relocs(int as_text, int use_real_mode)
30964 {
30965 - int i;
30966 + unsigned int i;
30967 /* Count how many relocations I have and allocate space for them. */
30968 reloc_count = 0;
30969 walk_relocs(count_reloc, use_real_mode);
30970 @@ -808,10 +874,11 @@ int main(int argc, char **argv)
30971 fname, strerror(errno));
30972 }
30973 read_ehdr(fp);
30974 + read_phdrs(fp);
30975 read_shdrs(fp);
30976 read_strtabs(fp);
30977 read_symtabs(fp);
30978 - read_relocs(fp);
30979 + read_relocs(fp, use_real_mode);
30980 if (show_absolute_syms) {
30981 print_absolute_symbols();
30982 goto out;
30983 diff --git a/arch/x86/vdso/Makefile b/arch/x86/vdso/Makefile
30984 index fd14be1..e3c79c0 100644
30985 --- a/arch/x86/vdso/Makefile
30986 +++ b/arch/x86/vdso/Makefile
30987 @@ -181,7 +181,7 @@ quiet_cmd_vdso = VDSO $@
30988 -Wl,-T,$(filter %.lds,$^) $(filter %.o,$^) && \
30989 sh $(srctree)/$(src)/checkundef.sh '$(NM)' '$@'
30990
30991 -VDSO_LDFLAGS = -fPIC -shared $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
30992 +VDSO_LDFLAGS = -fPIC -shared -Wl,--no-undefined $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
30993 GCOV_PROFILE := n
30994
30995 #
30996 diff --git a/arch/x86/vdso/vdso32-setup.c b/arch/x86/vdso/vdso32-setup.c
30997 index 0faad64..39ef157 100644
30998 --- a/arch/x86/vdso/vdso32-setup.c
30999 +++ b/arch/x86/vdso/vdso32-setup.c
31000 @@ -25,6 +25,7 @@
31001 #include <asm/tlbflush.h>
31002 #include <asm/vdso.h>
31003 #include <asm/proto.h>
31004 +#include <asm/mman.h>
31005
31006 enum {
31007 VDSO_DISABLED = 0,
31008 @@ -226,7 +227,7 @@ static inline void map_compat_vdso(int map)
31009 void enable_sep_cpu(void)
31010 {
31011 int cpu = get_cpu();
31012 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
31013 + struct tss_struct *tss = init_tss + cpu;
31014
31015 if (!boot_cpu_has(X86_FEATURE_SEP)) {
31016 put_cpu();
31017 @@ -249,7 +250,7 @@ static int __init gate_vma_init(void)
31018 gate_vma.vm_start = FIXADDR_USER_START;
31019 gate_vma.vm_end = FIXADDR_USER_END;
31020 gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;
31021 - gate_vma.vm_page_prot = __P101;
31022 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
31023
31024 return 0;
31025 }
31026 @@ -330,14 +331,14 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
31027 if (compat)
31028 addr = VDSO_HIGH_BASE;
31029 else {
31030 - addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, 0);
31031 + addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, MAP_EXECUTABLE);
31032 if (IS_ERR_VALUE(addr)) {
31033 ret = addr;
31034 goto up_fail;
31035 }
31036 }
31037
31038 - current->mm->context.vdso = (void *)addr;
31039 + current->mm->context.vdso = addr;
31040
31041 if (compat_uses_vma || !compat) {
31042 /*
31043 @@ -353,11 +354,11 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
31044 }
31045
31046 current_thread_info()->sysenter_return =
31047 - VDSO32_SYMBOL(addr, SYSENTER_RETURN);
31048 + (__force void __user *)VDSO32_SYMBOL(addr, SYSENTER_RETURN);
31049
31050 up_fail:
31051 if (ret)
31052 - current->mm->context.vdso = NULL;
31053 + current->mm->context.vdso = 0;
31054
31055 up_write(&mm->mmap_sem);
31056
31057 @@ -404,8 +405,14 @@ __initcall(ia32_binfmt_init);
31058
31059 const char *arch_vma_name(struct vm_area_struct *vma)
31060 {
31061 - if (vma->vm_mm && vma->vm_start == (long)vma->vm_mm->context.vdso)
31062 + if (vma->vm_mm && vma->vm_start == vma->vm_mm->context.vdso)
31063 return "[vdso]";
31064 +
31065 +#ifdef CONFIG_PAX_SEGMEXEC
31066 + if (vma->vm_mm && vma->vm_mirror && vma->vm_mirror->vm_start == vma->vm_mm->context.vdso)
31067 + return "[vdso]";
31068 +#endif
31069 +
31070 return NULL;
31071 }
31072
31073 @@ -415,7 +422,7 @@ struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
31074 * Check to see if the corresponding task was created in compat vdso
31075 * mode.
31076 */
31077 - if (mm && mm->context.vdso == (void *)VDSO_HIGH_BASE)
31078 + if (mm && mm->context.vdso == VDSO_HIGH_BASE)
31079 return &gate_vma;
31080 return NULL;
31081 }
31082 diff --git a/arch/x86/vdso/vma.c b/arch/x86/vdso/vma.c
31083 index 431e875..cbb23f3 100644
31084 --- a/arch/x86/vdso/vma.c
31085 +++ b/arch/x86/vdso/vma.c
31086 @@ -16,8 +16,6 @@
31087 #include <asm/vdso.h>
31088 #include <asm/page.h>
31089
31090 -unsigned int __read_mostly vdso_enabled = 1;
31091 -
31092 extern char vdso_start[], vdso_end[];
31093 extern unsigned short vdso_sync_cpuid;
31094
31095 @@ -141,7 +139,6 @@ static unsigned long vdso_addr(unsigned long start, unsigned len)
31096 * unaligned here as a result of stack start randomization.
31097 */
31098 addr = PAGE_ALIGN(addr);
31099 - addr = align_vdso_addr(addr);
31100
31101 return addr;
31102 }
31103 @@ -154,30 +151,31 @@ static int setup_additional_pages(struct linux_binprm *bprm,
31104 unsigned size)
31105 {
31106 struct mm_struct *mm = current->mm;
31107 - unsigned long addr;
31108 + unsigned long addr = 0;
31109 int ret;
31110
31111 - if (!vdso_enabled)
31112 - return 0;
31113 -
31114 down_write(&mm->mmap_sem);
31115 +
31116 +#ifdef CONFIG_PAX_RANDMMAP
31117 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
31118 +#endif
31119 +
31120 addr = vdso_addr(mm->start_stack, size);
31121 + addr = align_vdso_addr(addr);
31122 addr = get_unmapped_area(NULL, addr, size, 0, 0);
31123 if (IS_ERR_VALUE(addr)) {
31124 ret = addr;
31125 goto up_fail;
31126 }
31127
31128 - current->mm->context.vdso = (void *)addr;
31129 + mm->context.vdso = addr;
31130
31131 ret = install_special_mapping(mm, addr, size,
31132 VM_READ|VM_EXEC|
31133 VM_MAYREAD|VM_MAYWRITE|VM_MAYEXEC,
31134 pages);
31135 - if (ret) {
31136 - current->mm->context.vdso = NULL;
31137 - goto up_fail;
31138 - }
31139 + if (ret)
31140 + mm->context.vdso = 0;
31141
31142 up_fail:
31143 up_write(&mm->mmap_sem);
31144 @@ -197,10 +195,3 @@ int x32_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
31145 vdsox32_size);
31146 }
31147 #endif
31148 -
31149 -static __init int vdso_setup(char *s)
31150 -{
31151 - vdso_enabled = simple_strtoul(s, NULL, 0);
31152 - return 0;
31153 -}
31154 -__setup("vdso=", vdso_setup);
31155 diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
31156 index cf95e19..17e9f50 100644
31157 --- a/arch/x86/xen/enlighten.c
31158 +++ b/arch/x86/xen/enlighten.c
31159 @@ -100,8 +100,6 @@ EXPORT_SYMBOL_GPL(xen_start_info);
31160
31161 struct shared_info xen_dummy_shared_info;
31162
31163 -void *xen_initial_gdt;
31164 -
31165 RESERVE_BRK(shared_info_page_brk, PAGE_SIZE);
31166 __read_mostly int xen_have_vector_callback;
31167 EXPORT_SYMBOL_GPL(xen_have_vector_callback);
31168 @@ -511,8 +509,7 @@ static void xen_load_gdt(const struct desc_ptr *dtr)
31169 {
31170 unsigned long va = dtr->address;
31171 unsigned int size = dtr->size + 1;
31172 - unsigned pages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
31173 - unsigned long frames[pages];
31174 + unsigned long frames[65536 / PAGE_SIZE];
31175 int f;
31176
31177 /*
31178 @@ -560,8 +557,7 @@ static void __init xen_load_gdt_boot(const struct desc_ptr *dtr)
31179 {
31180 unsigned long va = dtr->address;
31181 unsigned int size = dtr->size + 1;
31182 - unsigned pages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
31183 - unsigned long frames[pages];
31184 + unsigned long frames[(GDT_SIZE + PAGE_SIZE - 1) / PAGE_SIZE];
31185 int f;
31186
31187 /*
31188 @@ -569,7 +565,7 @@ static void __init xen_load_gdt_boot(const struct desc_ptr *dtr)
31189 * 8-byte entries, or 16 4k pages..
31190 */
31191
31192 - BUG_ON(size > 65536);
31193 + BUG_ON(size > GDT_SIZE);
31194 BUG_ON(va & ~PAGE_MASK);
31195
31196 for (f = 0; va < dtr->address + size; va += PAGE_SIZE, f++) {
31197 @@ -954,7 +950,7 @@ static u32 xen_safe_apic_wait_icr_idle(void)
31198 return 0;
31199 }
31200
31201 -static void set_xen_basic_apic_ops(void)
31202 +static void __init set_xen_basic_apic_ops(void)
31203 {
31204 apic->read = xen_apic_read;
31205 apic->write = xen_apic_write;
31206 @@ -1260,30 +1256,30 @@ static const struct pv_apic_ops xen_apic_ops __initconst = {
31207 #endif
31208 };
31209
31210 -static void xen_reboot(int reason)
31211 +static __noreturn void xen_reboot(int reason)
31212 {
31213 struct sched_shutdown r = { .reason = reason };
31214
31215 - if (HYPERVISOR_sched_op(SCHEDOP_shutdown, &r))
31216 - BUG();
31217 + HYPERVISOR_sched_op(SCHEDOP_shutdown, &r);
31218 + BUG();
31219 }
31220
31221 -static void xen_restart(char *msg)
31222 +static __noreturn void xen_restart(char *msg)
31223 {
31224 xen_reboot(SHUTDOWN_reboot);
31225 }
31226
31227 -static void xen_emergency_restart(void)
31228 +static __noreturn void xen_emergency_restart(void)
31229 {
31230 xen_reboot(SHUTDOWN_reboot);
31231 }
31232
31233 -static void xen_machine_halt(void)
31234 +static __noreturn void xen_machine_halt(void)
31235 {
31236 xen_reboot(SHUTDOWN_poweroff);
31237 }
31238
31239 -static void xen_machine_power_off(void)
31240 +static __noreturn void xen_machine_power_off(void)
31241 {
31242 if (pm_power_off)
31243 pm_power_off();
31244 @@ -1385,7 +1381,17 @@ asmlinkage void __init xen_start_kernel(void)
31245 __userpte_alloc_gfp &= ~__GFP_HIGHMEM;
31246
31247 /* Work out if we support NX */
31248 - x86_configure_nx();
31249 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
31250 + if ((cpuid_eax(0x80000000) & 0xffff0000) == 0x80000000 &&
31251 + (cpuid_edx(0x80000001) & (1U << (X86_FEATURE_NX & 31)))) {
31252 + unsigned l, h;
31253 +
31254 + __supported_pte_mask |= _PAGE_NX;
31255 + rdmsr(MSR_EFER, l, h);
31256 + l |= EFER_NX;
31257 + wrmsr(MSR_EFER, l, h);
31258 + }
31259 +#endif
31260
31261 xen_setup_features();
31262
31263 @@ -1416,13 +1422,6 @@ asmlinkage void __init xen_start_kernel(void)
31264
31265 machine_ops = xen_machine_ops;
31266
31267 - /*
31268 - * The only reliable way to retain the initial address of the
31269 - * percpu gdt_page is to remember it here, so we can go and
31270 - * mark it RW later, when the initial percpu area is freed.
31271 - */
31272 - xen_initial_gdt = &per_cpu(gdt_page, 0);
31273 -
31274 xen_smp_init();
31275
31276 #ifdef CONFIG_ACPI_NUMA
31277 @@ -1616,7 +1615,7 @@ static int __cpuinit xen_hvm_cpu_notify(struct notifier_block *self,
31278 return NOTIFY_OK;
31279 }
31280
31281 -static struct notifier_block xen_hvm_cpu_notifier __cpuinitdata = {
31282 +static struct notifier_block xen_hvm_cpu_notifier = {
31283 .notifier_call = xen_hvm_cpu_notify,
31284 };
31285
31286 diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
31287 index e006c18..b9a7d6c 100644
31288 --- a/arch/x86/xen/mmu.c
31289 +++ b/arch/x86/xen/mmu.c
31290 @@ -1894,6 +1894,9 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
31291 /* L3_k[510] -> level2_kernel_pgt
31292 * L3_i[511] -> level2_fixmap_pgt */
31293 convert_pfn_mfn(level3_kernel_pgt);
31294 + convert_pfn_mfn(level3_vmalloc_start_pgt);
31295 + convert_pfn_mfn(level3_vmalloc_end_pgt);
31296 + convert_pfn_mfn(level3_vmemmap_pgt);
31297
31298 /* We get [511][511] and have Xen's version of level2_kernel_pgt */
31299 l3 = m2v(pgd[pgd_index(__START_KERNEL_map)].pgd);
31300 @@ -1923,8 +1926,12 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
31301 set_page_prot(init_level4_pgt, PAGE_KERNEL_RO);
31302 set_page_prot(level3_ident_pgt, PAGE_KERNEL_RO);
31303 set_page_prot(level3_kernel_pgt, PAGE_KERNEL_RO);
31304 + set_page_prot(level3_vmalloc_start_pgt, PAGE_KERNEL_RO);
31305 + set_page_prot(level3_vmalloc_end_pgt, PAGE_KERNEL_RO);
31306 + set_page_prot(level3_vmemmap_pgt, PAGE_KERNEL_RO);
31307 set_page_prot(level3_user_vsyscall, PAGE_KERNEL_RO);
31308 set_page_prot(level2_ident_pgt, PAGE_KERNEL_RO);
31309 + set_page_prot(level2_vmemmap_pgt, PAGE_KERNEL_RO);
31310 set_page_prot(level2_kernel_pgt, PAGE_KERNEL_RO);
31311 set_page_prot(level2_fixmap_pgt, PAGE_KERNEL_RO);
31312
31313 @@ -2110,6 +2117,7 @@ static void __init xen_post_allocator_init(void)
31314 pv_mmu_ops.set_pud = xen_set_pud;
31315 #if PAGETABLE_LEVELS == 4
31316 pv_mmu_ops.set_pgd = xen_set_pgd;
31317 + pv_mmu_ops.set_pgd_batched = xen_set_pgd;
31318 #endif
31319
31320 /* This will work as long as patching hasn't happened yet
31321 @@ -2188,6 +2196,7 @@ static const struct pv_mmu_ops xen_mmu_ops __initconst = {
31322 .pud_val = PV_CALLEE_SAVE(xen_pud_val),
31323 .make_pud = PV_CALLEE_SAVE(xen_make_pud),
31324 .set_pgd = xen_set_pgd_hyper,
31325 + .set_pgd_batched = xen_set_pgd_hyper,
31326
31327 .alloc_pud = xen_alloc_pmd_init,
31328 .release_pud = xen_release_pmd_init,
31329 diff --git a/arch/x86/xen/smp.c b/arch/x86/xen/smp.c
31330 index 22c800a..8915f1e 100644
31331 --- a/arch/x86/xen/smp.c
31332 +++ b/arch/x86/xen/smp.c
31333 @@ -229,11 +229,6 @@ static void __init xen_smp_prepare_boot_cpu(void)
31334 {
31335 BUG_ON(smp_processor_id() != 0);
31336 native_smp_prepare_boot_cpu();
31337 -
31338 - /* We've switched to the "real" per-cpu gdt, so make sure the
31339 - old memory can be recycled */
31340 - make_lowmem_page_readwrite(xen_initial_gdt);
31341 -
31342 xen_filter_cpu_maps();
31343 xen_setup_vcpu_info_placement();
31344 }
31345 @@ -303,7 +298,7 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle)
31346 ctxt->user_regs.ss = __KERNEL_DS;
31347 #ifdef CONFIG_X86_32
31348 ctxt->user_regs.fs = __KERNEL_PERCPU;
31349 - ctxt->user_regs.gs = __KERNEL_STACK_CANARY;
31350 + savesegment(gs, ctxt->user_regs.gs);
31351 #else
31352 ctxt->gs_base_kernel = per_cpu_offset(cpu);
31353 #endif
31354 @@ -313,8 +308,8 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle)
31355
31356 {
31357 ctxt->user_regs.eflags = 0x1000; /* IOPL_RING1 */
31358 - ctxt->user_regs.ds = __USER_DS;
31359 - ctxt->user_regs.es = __USER_DS;
31360 + ctxt->user_regs.ds = __KERNEL_DS;
31361 + ctxt->user_regs.es = __KERNEL_DS;
31362
31363 xen_copy_trap_info(ctxt->trap_ctxt);
31364
31365 @@ -359,13 +354,12 @@ static int __cpuinit xen_cpu_up(unsigned int cpu, struct task_struct *idle)
31366 int rc;
31367
31368 per_cpu(current_task, cpu) = idle;
31369 + per_cpu(current_tinfo, cpu) = &idle->tinfo;
31370 #ifdef CONFIG_X86_32
31371 irq_ctx_init(cpu);
31372 #else
31373 clear_tsk_thread_flag(idle, TIF_FORK);
31374 - per_cpu(kernel_stack, cpu) =
31375 - (unsigned long)task_stack_page(idle) -
31376 - KERNEL_STACK_OFFSET + THREAD_SIZE;
31377 + per_cpu(kernel_stack, cpu) = (unsigned long)task_stack_page(idle) - 16 + THREAD_SIZE;
31378 #endif
31379 xen_setup_runstate_info(cpu);
31380 xen_setup_timer(cpu);
31381 @@ -634,7 +628,7 @@ static const struct smp_ops xen_smp_ops __initconst = {
31382
31383 void __init xen_smp_init(void)
31384 {
31385 - smp_ops = xen_smp_ops;
31386 + memcpy((void *)&smp_ops, &xen_smp_ops, sizeof smp_ops);
31387 xen_fill_possible_map();
31388 xen_init_spinlocks();
31389 }
31390 diff --git a/arch/x86/xen/xen-asm_32.S b/arch/x86/xen/xen-asm_32.S
31391 index 33ca6e4..0ded929 100644
31392 --- a/arch/x86/xen/xen-asm_32.S
31393 +++ b/arch/x86/xen/xen-asm_32.S
31394 @@ -84,14 +84,14 @@ ENTRY(xen_iret)
31395 ESP_OFFSET=4 # bytes pushed onto stack
31396
31397 /*
31398 - * Store vcpu_info pointer for easy access. Do it this way to
31399 - * avoid having to reload %fs
31400 + * Store vcpu_info pointer for easy access.
31401 */
31402 #ifdef CONFIG_SMP
31403 - GET_THREAD_INFO(%eax)
31404 - movl %ss:TI_cpu(%eax), %eax
31405 - movl %ss:__per_cpu_offset(,%eax,4), %eax
31406 - mov %ss:xen_vcpu(%eax), %eax
31407 + push %fs
31408 + mov $(__KERNEL_PERCPU), %eax
31409 + mov %eax, %fs
31410 + mov PER_CPU_VAR(xen_vcpu), %eax
31411 + pop %fs
31412 #else
31413 movl %ss:xen_vcpu, %eax
31414 #endif
31415 diff --git a/arch/x86/xen/xen-head.S b/arch/x86/xen/xen-head.S
31416 index 7faed58..ba4427c 100644
31417 --- a/arch/x86/xen/xen-head.S
31418 +++ b/arch/x86/xen/xen-head.S
31419 @@ -19,6 +19,17 @@ ENTRY(startup_xen)
31420 #ifdef CONFIG_X86_32
31421 mov %esi,xen_start_info
31422 mov $init_thread_union+THREAD_SIZE,%esp
31423 +#ifdef CONFIG_SMP
31424 + movl $cpu_gdt_table,%edi
31425 + movl $__per_cpu_load,%eax
31426 + movw %ax,__KERNEL_PERCPU + 2(%edi)
31427 + rorl $16,%eax
31428 + movb %al,__KERNEL_PERCPU + 4(%edi)
31429 + movb %ah,__KERNEL_PERCPU + 7(%edi)
31430 + movl $__per_cpu_end - 1,%eax
31431 + subl $__per_cpu_start,%eax
31432 + movw %ax,__KERNEL_PERCPU + 0(%edi)
31433 +#endif
31434 #else
31435 mov %rsi,xen_start_info
31436 mov $init_thread_union+THREAD_SIZE,%rsp
31437 diff --git a/arch/x86/xen/xen-ops.h b/arch/x86/xen/xen-ops.h
31438 index a95b417..b6dbd0b 100644
31439 --- a/arch/x86/xen/xen-ops.h
31440 +++ b/arch/x86/xen/xen-ops.h
31441 @@ -10,8 +10,6 @@
31442 extern const char xen_hypervisor_callback[];
31443 extern const char xen_failsafe_callback[];
31444
31445 -extern void *xen_initial_gdt;
31446 -
31447 struct trap_info;
31448 void xen_copy_trap_info(struct trap_info *traps);
31449
31450 diff --git a/arch/xtensa/variants/dc232b/include/variant/core.h b/arch/xtensa/variants/dc232b/include/variant/core.h
31451 index 525bd3d..ef888b1 100644
31452 --- a/arch/xtensa/variants/dc232b/include/variant/core.h
31453 +++ b/arch/xtensa/variants/dc232b/include/variant/core.h
31454 @@ -119,9 +119,9 @@
31455 ----------------------------------------------------------------------*/
31456
31457 #define XCHAL_ICACHE_LINESIZE 32 /* I-cache line size in bytes */
31458 -#define XCHAL_DCACHE_LINESIZE 32 /* D-cache line size in bytes */
31459 #define XCHAL_ICACHE_LINEWIDTH 5 /* log2(I line size in bytes) */
31460 #define XCHAL_DCACHE_LINEWIDTH 5 /* log2(D line size in bytes) */
31461 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
31462
31463 #define XCHAL_ICACHE_SIZE 16384 /* I-cache size in bytes or 0 */
31464 #define XCHAL_DCACHE_SIZE 16384 /* D-cache size in bytes or 0 */
31465 diff --git a/arch/xtensa/variants/fsf/include/variant/core.h b/arch/xtensa/variants/fsf/include/variant/core.h
31466 index 2f33760..835e50a 100644
31467 --- a/arch/xtensa/variants/fsf/include/variant/core.h
31468 +++ b/arch/xtensa/variants/fsf/include/variant/core.h
31469 @@ -11,6 +11,7 @@
31470 #ifndef _XTENSA_CORE_H
31471 #define _XTENSA_CORE_H
31472
31473 +#include <linux/const.h>
31474
31475 /****************************************************************************
31476 Parameters Useful for Any Code, USER or PRIVILEGED
31477 @@ -112,9 +113,9 @@
31478 ----------------------------------------------------------------------*/
31479
31480 #define XCHAL_ICACHE_LINESIZE 16 /* I-cache line size in bytes */
31481 -#define XCHAL_DCACHE_LINESIZE 16 /* D-cache line size in bytes */
31482 #define XCHAL_ICACHE_LINEWIDTH 4 /* log2(I line size in bytes) */
31483 #define XCHAL_DCACHE_LINEWIDTH 4 /* log2(D line size in bytes) */
31484 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
31485
31486 #define XCHAL_ICACHE_SIZE 8192 /* I-cache size in bytes or 0 */
31487 #define XCHAL_DCACHE_SIZE 8192 /* D-cache size in bytes or 0 */
31488 diff --git a/arch/xtensa/variants/s6000/include/variant/core.h b/arch/xtensa/variants/s6000/include/variant/core.h
31489 index af00795..2bb8105 100644
31490 --- a/arch/xtensa/variants/s6000/include/variant/core.h
31491 +++ b/arch/xtensa/variants/s6000/include/variant/core.h
31492 @@ -11,6 +11,7 @@
31493 #ifndef _XTENSA_CORE_CONFIGURATION_H
31494 #define _XTENSA_CORE_CONFIGURATION_H
31495
31496 +#include <linux/const.h>
31497
31498 /****************************************************************************
31499 Parameters Useful for Any Code, USER or PRIVILEGED
31500 @@ -118,9 +119,9 @@
31501 ----------------------------------------------------------------------*/
31502
31503 #define XCHAL_ICACHE_LINESIZE 16 /* I-cache line size in bytes */
31504 -#define XCHAL_DCACHE_LINESIZE 16 /* D-cache line size in bytes */
31505 #define XCHAL_ICACHE_LINEWIDTH 4 /* log2(I line size in bytes) */
31506 #define XCHAL_DCACHE_LINEWIDTH 4 /* log2(D line size in bytes) */
31507 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
31508
31509 #define XCHAL_ICACHE_SIZE 32768 /* I-cache size in bytes or 0 */
31510 #define XCHAL_DCACHE_SIZE 32768 /* D-cache size in bytes or 0 */
31511 diff --git a/block/blk-iopoll.c b/block/blk-iopoll.c
31512 index 58916af..eb9dbcf6 100644
31513 --- a/block/blk-iopoll.c
31514 +++ b/block/blk-iopoll.c
31515 @@ -77,7 +77,7 @@ void blk_iopoll_complete(struct blk_iopoll *iopoll)
31516 }
31517 EXPORT_SYMBOL(blk_iopoll_complete);
31518
31519 -static void blk_iopoll_softirq(struct softirq_action *h)
31520 +static void blk_iopoll_softirq(void)
31521 {
31522 struct list_head *list = &__get_cpu_var(blk_cpu_iopoll);
31523 int rearm = 0, budget = blk_iopoll_budget;
31524 @@ -209,7 +209,7 @@ static int __cpuinit blk_iopoll_cpu_notify(struct notifier_block *self,
31525 return NOTIFY_OK;
31526 }
31527
31528 -static struct notifier_block __cpuinitdata blk_iopoll_cpu_notifier = {
31529 +static struct notifier_block blk_iopoll_cpu_notifier = {
31530 .notifier_call = blk_iopoll_cpu_notify,
31531 };
31532
31533 diff --git a/block/blk-map.c b/block/blk-map.c
31534 index 623e1cd..ca1e109 100644
31535 --- a/block/blk-map.c
31536 +++ b/block/blk-map.c
31537 @@ -302,7 +302,7 @@ int blk_rq_map_kern(struct request_queue *q, struct request *rq, void *kbuf,
31538 if (!len || !kbuf)
31539 return -EINVAL;
31540
31541 - do_copy = !blk_rq_aligned(q, addr, len) || object_is_on_stack(kbuf);
31542 + do_copy = !blk_rq_aligned(q, addr, len) || object_starts_on_stack(kbuf);
31543 if (do_copy)
31544 bio = bio_copy_kern(q, kbuf, len, gfp_mask, reading);
31545 else
31546 diff --git a/block/blk-softirq.c b/block/blk-softirq.c
31547 index 467c8de..f3628c5 100644
31548 --- a/block/blk-softirq.c
31549 +++ b/block/blk-softirq.c
31550 @@ -18,7 +18,7 @@ static DEFINE_PER_CPU(struct list_head, blk_cpu_done);
31551 * Softirq action handler - move entries to local list and loop over them
31552 * while passing them to the queue registered handler.
31553 */
31554 -static void blk_done_softirq(struct softirq_action *h)
31555 +static void blk_done_softirq(void)
31556 {
31557 struct list_head *cpu_list, local_list;
31558
31559 @@ -98,7 +98,7 @@ static int __cpuinit blk_cpu_notify(struct notifier_block *self,
31560 return NOTIFY_OK;
31561 }
31562
31563 -static struct notifier_block __cpuinitdata blk_cpu_notifier = {
31564 +static struct notifier_block blk_cpu_notifier = {
31565 .notifier_call = blk_cpu_notify,
31566 };
31567
31568 diff --git a/block/bsg.c b/block/bsg.c
31569 index 420a5a9..23834aa 100644
31570 --- a/block/bsg.c
31571 +++ b/block/bsg.c
31572 @@ -176,16 +176,24 @@ static int blk_fill_sgv4_hdr_rq(struct request_queue *q, struct request *rq,
31573 struct sg_io_v4 *hdr, struct bsg_device *bd,
31574 fmode_t has_write_perm)
31575 {
31576 + unsigned char tmpcmd[sizeof(rq->__cmd)];
31577 + unsigned char *cmdptr;
31578 +
31579 if (hdr->request_len > BLK_MAX_CDB) {
31580 rq->cmd = kzalloc(hdr->request_len, GFP_KERNEL);
31581 if (!rq->cmd)
31582 return -ENOMEM;
31583 - }
31584 + cmdptr = rq->cmd;
31585 + } else
31586 + cmdptr = tmpcmd;
31587
31588 - if (copy_from_user(rq->cmd, (void __user *)(unsigned long)hdr->request,
31589 + if (copy_from_user(cmdptr, (void __user *)(unsigned long)hdr->request,
31590 hdr->request_len))
31591 return -EFAULT;
31592
31593 + if (cmdptr != rq->cmd)
31594 + memcpy(rq->cmd, cmdptr, hdr->request_len);
31595 +
31596 if (hdr->subprotocol == BSG_SUB_PROTOCOL_SCSI_CMD) {
31597 if (blk_verify_command(rq->cmd, has_write_perm))
31598 return -EPERM;
31599 diff --git a/block/compat_ioctl.c b/block/compat_ioctl.c
31600 index 7c668c8..db3521c 100644
31601 --- a/block/compat_ioctl.c
31602 +++ b/block/compat_ioctl.c
31603 @@ -340,7 +340,7 @@ static int compat_fd_ioctl(struct block_device *bdev, fmode_t mode,
31604 err |= __get_user(f->spec1, &uf->spec1);
31605 err |= __get_user(f->fmt_gap, &uf->fmt_gap);
31606 err |= __get_user(name, &uf->name);
31607 - f->name = compat_ptr(name);
31608 + f->name = (void __force_kernel *)compat_ptr(name);
31609 if (err) {
31610 err = -EFAULT;
31611 goto out;
31612 diff --git a/block/partitions/efi.c b/block/partitions/efi.c
31613 index ff5804e..a88acad 100644
31614 --- a/block/partitions/efi.c
31615 +++ b/block/partitions/efi.c
31616 @@ -234,14 +234,14 @@ static gpt_entry *alloc_read_gpt_entries(struct parsed_partitions *state,
31617 if (!gpt)
31618 return NULL;
31619
31620 + if (!le32_to_cpu(gpt->num_partition_entries))
31621 + return NULL;
31622 + pte = kcalloc(le32_to_cpu(gpt->num_partition_entries), le32_to_cpu(gpt->sizeof_partition_entry), GFP_KERNEL);
31623 + if (!pte)
31624 + return NULL;
31625 +
31626 count = le32_to_cpu(gpt->num_partition_entries) *
31627 le32_to_cpu(gpt->sizeof_partition_entry);
31628 - if (!count)
31629 - return NULL;
31630 - pte = kzalloc(count, GFP_KERNEL);
31631 - if (!pte)
31632 - return NULL;
31633 -
31634 if (read_lba(state, le64_to_cpu(gpt->partition_entry_lba),
31635 (u8 *) pte,
31636 count) < count) {
31637 diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c
31638 index 9a87daa..fb17486 100644
31639 --- a/block/scsi_ioctl.c
31640 +++ b/block/scsi_ioctl.c
31641 @@ -223,8 +223,20 @@ EXPORT_SYMBOL(blk_verify_command);
31642 static int blk_fill_sghdr_rq(struct request_queue *q, struct request *rq,
31643 struct sg_io_hdr *hdr, fmode_t mode)
31644 {
31645 - if (copy_from_user(rq->cmd, hdr->cmdp, hdr->cmd_len))
31646 + unsigned char tmpcmd[sizeof(rq->__cmd)];
31647 + unsigned char *cmdptr;
31648 +
31649 + if (rq->cmd != rq->__cmd)
31650 + cmdptr = rq->cmd;
31651 + else
31652 + cmdptr = tmpcmd;
31653 +
31654 + if (copy_from_user(cmdptr, hdr->cmdp, hdr->cmd_len))
31655 return -EFAULT;
31656 +
31657 + if (cmdptr != rq->cmd)
31658 + memcpy(rq->cmd, cmdptr, hdr->cmd_len);
31659 +
31660 if (blk_verify_command(rq->cmd, mode & FMODE_WRITE))
31661 return -EPERM;
31662
31663 @@ -433,6 +445,8 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
31664 int err;
31665 unsigned int in_len, out_len, bytes, opcode, cmdlen;
31666 char *buffer = NULL, sense[SCSI_SENSE_BUFFERSIZE];
31667 + unsigned char tmpcmd[sizeof(rq->__cmd)];
31668 + unsigned char *cmdptr;
31669
31670 if (!sic)
31671 return -EINVAL;
31672 @@ -466,9 +480,18 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
31673 */
31674 err = -EFAULT;
31675 rq->cmd_len = cmdlen;
31676 - if (copy_from_user(rq->cmd, sic->data, cmdlen))
31677 +
31678 + if (rq->cmd != rq->__cmd)
31679 + cmdptr = rq->cmd;
31680 + else
31681 + cmdptr = tmpcmd;
31682 +
31683 + if (copy_from_user(cmdptr, sic->data, cmdlen))
31684 goto error;
31685
31686 + if (rq->cmd != cmdptr)
31687 + memcpy(rq->cmd, cmdptr, cmdlen);
31688 +
31689 if (in_len && copy_from_user(buffer, sic->data + cmdlen, in_len))
31690 goto error;
31691
31692 diff --git a/crypto/cryptd.c b/crypto/cryptd.c
31693 index 7bdd61b..afec999 100644
31694 --- a/crypto/cryptd.c
31695 +++ b/crypto/cryptd.c
31696 @@ -63,7 +63,7 @@ struct cryptd_blkcipher_ctx {
31697
31698 struct cryptd_blkcipher_request_ctx {
31699 crypto_completion_t complete;
31700 -};
31701 +} __no_const;
31702
31703 struct cryptd_hash_ctx {
31704 struct crypto_shash *child;
31705 @@ -80,7 +80,7 @@ struct cryptd_aead_ctx {
31706
31707 struct cryptd_aead_request_ctx {
31708 crypto_completion_t complete;
31709 -};
31710 +} __no_const;
31711
31712 static void cryptd_queue_worker(struct work_struct *work);
31713
31714 diff --git a/drivers/acpi/apei/apei-internal.h b/drivers/acpi/apei/apei-internal.h
31715 index f220d64..d359ad6 100644
31716 --- a/drivers/acpi/apei/apei-internal.h
31717 +++ b/drivers/acpi/apei/apei-internal.h
31718 @@ -20,7 +20,7 @@ typedef int (*apei_exec_ins_func_t)(struct apei_exec_context *ctx,
31719 struct apei_exec_ins_type {
31720 u32 flags;
31721 apei_exec_ins_func_t run;
31722 -};
31723 +} __do_const;
31724
31725 struct apei_exec_context {
31726 u32 ip;
31727 diff --git a/drivers/acpi/apei/cper.c b/drivers/acpi/apei/cper.c
31728 index fefc2ca..12a535d 100644
31729 --- a/drivers/acpi/apei/cper.c
31730 +++ b/drivers/acpi/apei/cper.c
31731 @@ -39,12 +39,12 @@
31732 */
31733 u64 cper_next_record_id(void)
31734 {
31735 - static atomic64_t seq;
31736 + static atomic64_unchecked_t seq;
31737
31738 - if (!atomic64_read(&seq))
31739 - atomic64_set(&seq, ((u64)get_seconds()) << 32);
31740 + if (!atomic64_read_unchecked(&seq))
31741 + atomic64_set_unchecked(&seq, ((u64)get_seconds()) << 32);
31742
31743 - return atomic64_inc_return(&seq);
31744 + return atomic64_inc_return_unchecked(&seq);
31745 }
31746 EXPORT_SYMBOL_GPL(cper_next_record_id);
31747
31748 diff --git a/drivers/acpi/bgrt.c b/drivers/acpi/bgrt.c
31749 index be60399..778b33e8 100644
31750 --- a/drivers/acpi/bgrt.c
31751 +++ b/drivers/acpi/bgrt.c
31752 @@ -87,8 +87,10 @@ static int __init bgrt_init(void)
31753 return -ENODEV;
31754
31755 sysfs_bin_attr_init(&image_attr);
31756 - image_attr.private = bgrt_image;
31757 - image_attr.size = bgrt_image_size;
31758 + pax_open_kernel();
31759 + *(void **)&image_attr.private = bgrt_image;
31760 + *(size_t *)&image_attr.size = bgrt_image_size;
31761 + pax_close_kernel();
31762
31763 bgrt_kobj = kobject_create_and_add("bgrt", acpi_kobj);
31764 if (!bgrt_kobj)
31765 diff --git a/drivers/acpi/blacklist.c b/drivers/acpi/blacklist.c
31766 index cb96296..b81293b 100644
31767 --- a/drivers/acpi/blacklist.c
31768 +++ b/drivers/acpi/blacklist.c
31769 @@ -52,7 +52,7 @@ struct acpi_blacklist_item {
31770 u32 is_critical_error;
31771 };
31772
31773 -static struct dmi_system_id acpi_osi_dmi_table[] __initdata;
31774 +static const struct dmi_system_id acpi_osi_dmi_table[] __initconst;
31775
31776 /*
31777 * POLICY: If *anything* doesn't work, put it on the blacklist.
31778 @@ -193,7 +193,7 @@ static int __init dmi_disable_osi_win7(const struct dmi_system_id *d)
31779 return 0;
31780 }
31781
31782 -static struct dmi_system_id acpi_osi_dmi_table[] __initdata = {
31783 +static const struct dmi_system_id acpi_osi_dmi_table[] __initconst = {
31784 {
31785 .callback = dmi_disable_osi_vista,
31786 .ident = "Fujitsu Siemens",
31787 diff --git a/drivers/acpi/ec_sys.c b/drivers/acpi/ec_sys.c
31788 index 7586544..636a2f0 100644
31789 --- a/drivers/acpi/ec_sys.c
31790 +++ b/drivers/acpi/ec_sys.c
31791 @@ -12,6 +12,7 @@
31792 #include <linux/acpi.h>
31793 #include <linux/debugfs.h>
31794 #include <linux/module.h>
31795 +#include <linux/uaccess.h>
31796 #include "internal.h"
31797
31798 MODULE_AUTHOR("Thomas Renninger <trenn@suse.de>");
31799 @@ -34,7 +35,7 @@ static ssize_t acpi_ec_read_io(struct file *f, char __user *buf,
31800 * struct acpi_ec *ec = ((struct seq_file *)f->private_data)->private;
31801 */
31802 unsigned int size = EC_SPACE_SIZE;
31803 - u8 *data = (u8 *) buf;
31804 + u8 data;
31805 loff_t init_off = *off;
31806 int err = 0;
31807
31808 @@ -47,9 +48,11 @@ static ssize_t acpi_ec_read_io(struct file *f, char __user *buf,
31809 size = count;
31810
31811 while (size) {
31812 - err = ec_read(*off, &data[*off - init_off]);
31813 + err = ec_read(*off, &data);
31814 if (err)
31815 return err;
31816 + if (put_user(data, &buf[*off - init_off]))
31817 + return -EFAULT;
31818 *off += 1;
31819 size--;
31820 }
31821 @@ -65,7 +68,6 @@ static ssize_t acpi_ec_write_io(struct file *f, const char __user *buf,
31822
31823 unsigned int size = count;
31824 loff_t init_off = *off;
31825 - u8 *data = (u8 *) buf;
31826 int err = 0;
31827
31828 if (*off >= EC_SPACE_SIZE)
31829 @@ -76,7 +78,9 @@ static ssize_t acpi_ec_write_io(struct file *f, const char __user *buf,
31830 }
31831
31832 while (size) {
31833 - u8 byte_write = data[*off - init_off];
31834 + u8 byte_write;
31835 + if (get_user(byte_write, &buf[*off - init_off]))
31836 + return -EFAULT;
31837 err = ec_write(*off, byte_write);
31838 if (err)
31839 return err;
31840 diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
31841 index ee255c6..747c68b 100644
31842 --- a/drivers/acpi/processor_idle.c
31843 +++ b/drivers/acpi/processor_idle.c
31844 @@ -986,7 +986,7 @@ static int acpi_processor_setup_cpuidle_states(struct acpi_processor *pr)
31845 {
31846 int i, count = CPUIDLE_DRIVER_STATE_START;
31847 struct acpi_processor_cx *cx;
31848 - struct cpuidle_state *state;
31849 + cpuidle_state_no_const *state;
31850 struct cpuidle_driver *drv = &acpi_idle_driver;
31851
31852 if (!pr->flags.power_setup_done)
31853 diff --git a/drivers/acpi/sysfs.c b/drivers/acpi/sysfs.c
31854 index 41c0504..f8c0836 100644
31855 --- a/drivers/acpi/sysfs.c
31856 +++ b/drivers/acpi/sysfs.c
31857 @@ -420,11 +420,11 @@ static u32 num_counters;
31858 static struct attribute **all_attrs;
31859 static u32 acpi_gpe_count;
31860
31861 -static struct attribute_group interrupt_stats_attr_group = {
31862 +static attribute_group_no_const interrupt_stats_attr_group = {
31863 .name = "interrupts",
31864 };
31865
31866 -static struct kobj_attribute *counter_attrs;
31867 +static kobj_attribute_no_const *counter_attrs;
31868
31869 static void delete_gpe_attr_array(void)
31870 {
31871 diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c
31872 index 34c8216..f56c828 100644
31873 --- a/drivers/ata/libahci.c
31874 +++ b/drivers/ata/libahci.c
31875 @@ -1230,7 +1230,7 @@ int ahci_kick_engine(struct ata_port *ap)
31876 }
31877 EXPORT_SYMBOL_GPL(ahci_kick_engine);
31878
31879 -static int ahci_exec_polled_cmd(struct ata_port *ap, int pmp,
31880 +static int __intentional_overflow(-1) ahci_exec_polled_cmd(struct ata_port *ap, int pmp,
31881 struct ata_taskfile *tf, int is_cmd, u16 flags,
31882 unsigned long timeout_msec)
31883 {
31884 diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
31885 index 63c743b..0422dc6 100644
31886 --- a/drivers/ata/libata-core.c
31887 +++ b/drivers/ata/libata-core.c
31888 @@ -4786,7 +4786,7 @@ void ata_qc_free(struct ata_queued_cmd *qc)
31889 struct ata_port *ap;
31890 unsigned int tag;
31891
31892 - WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
31893 + BUG_ON(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
31894 ap = qc->ap;
31895
31896 qc->flags = 0;
31897 @@ -4802,7 +4802,7 @@ void __ata_qc_complete(struct ata_queued_cmd *qc)
31898 struct ata_port *ap;
31899 struct ata_link *link;
31900
31901 - WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
31902 + BUG_ON(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
31903 WARN_ON_ONCE(!(qc->flags & ATA_QCFLAG_ACTIVE));
31904 ap = qc->ap;
31905 link = qc->dev->link;
31906 @@ -5920,6 +5920,7 @@ static void ata_finalize_port_ops(struct ata_port_operations *ops)
31907 return;
31908
31909 spin_lock(&lock);
31910 + pax_open_kernel();
31911
31912 for (cur = ops->inherits; cur; cur = cur->inherits) {
31913 void **inherit = (void **)cur;
31914 @@ -5933,8 +5934,9 @@ static void ata_finalize_port_ops(struct ata_port_operations *ops)
31915 if (IS_ERR(*pp))
31916 *pp = NULL;
31917
31918 - ops->inherits = NULL;
31919 + *(struct ata_port_operations **)&ops->inherits = NULL;
31920
31921 + pax_close_kernel();
31922 spin_unlock(&lock);
31923 }
31924
31925 diff --git a/drivers/ata/pata_arasan_cf.c b/drivers/ata/pata_arasan_cf.c
31926 index 405022d..fb70e53 100644
31927 --- a/drivers/ata/pata_arasan_cf.c
31928 +++ b/drivers/ata/pata_arasan_cf.c
31929 @@ -864,7 +864,9 @@ static int arasan_cf_probe(struct platform_device *pdev)
31930 /* Handle platform specific quirks */
31931 if (pdata->quirk) {
31932 if (pdata->quirk & CF_BROKEN_PIO) {
31933 - ap->ops->set_piomode = NULL;
31934 + pax_open_kernel();
31935 + *(void **)&ap->ops->set_piomode = NULL;
31936 + pax_close_kernel();
31937 ap->pio_mask = 0;
31938 }
31939 if (pdata->quirk & CF_BROKEN_MWDMA)
31940 diff --git a/drivers/atm/adummy.c b/drivers/atm/adummy.c
31941 index f9b983a..887b9d8 100644
31942 --- a/drivers/atm/adummy.c
31943 +++ b/drivers/atm/adummy.c
31944 @@ -114,7 +114,7 @@ adummy_send(struct atm_vcc *vcc, struct sk_buff *skb)
31945 vcc->pop(vcc, skb);
31946 else
31947 dev_kfree_skb_any(skb);
31948 - atomic_inc(&vcc->stats->tx);
31949 + atomic_inc_unchecked(&vcc->stats->tx);
31950
31951 return 0;
31952 }
31953 diff --git a/drivers/atm/ambassador.c b/drivers/atm/ambassador.c
31954 index 77a7480..05cde58 100644
31955 --- a/drivers/atm/ambassador.c
31956 +++ b/drivers/atm/ambassador.c
31957 @@ -454,7 +454,7 @@ static void tx_complete (amb_dev * dev, tx_out * tx) {
31958 PRINTD (DBG_FLOW|DBG_TX, "tx_complete %p %p", dev, tx);
31959
31960 // VC layer stats
31961 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
31962 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
31963
31964 // free the descriptor
31965 kfree (tx_descr);
31966 @@ -495,7 +495,7 @@ static void rx_complete (amb_dev * dev, rx_out * rx) {
31967 dump_skb ("<<<", vc, skb);
31968
31969 // VC layer stats
31970 - atomic_inc(&atm_vcc->stats->rx);
31971 + atomic_inc_unchecked(&atm_vcc->stats->rx);
31972 __net_timestamp(skb);
31973 // end of our responsibility
31974 atm_vcc->push (atm_vcc, skb);
31975 @@ -510,7 +510,7 @@ static void rx_complete (amb_dev * dev, rx_out * rx) {
31976 } else {
31977 PRINTK (KERN_INFO, "dropped over-size frame");
31978 // should we count this?
31979 - atomic_inc(&atm_vcc->stats->rx_drop);
31980 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
31981 }
31982
31983 } else {
31984 @@ -1338,7 +1338,7 @@ static int amb_send (struct atm_vcc * atm_vcc, struct sk_buff * skb) {
31985 }
31986
31987 if (check_area (skb->data, skb->len)) {
31988 - atomic_inc(&atm_vcc->stats->tx_err);
31989 + atomic_inc_unchecked(&atm_vcc->stats->tx_err);
31990 return -ENOMEM; // ?
31991 }
31992
31993 diff --git a/drivers/atm/atmtcp.c b/drivers/atm/atmtcp.c
31994 index 0e3f8f9..765a7a5 100644
31995 --- a/drivers/atm/atmtcp.c
31996 +++ b/drivers/atm/atmtcp.c
31997 @@ -206,7 +206,7 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
31998 if (vcc->pop) vcc->pop(vcc,skb);
31999 else dev_kfree_skb(skb);
32000 if (dev_data) return 0;
32001 - atomic_inc(&vcc->stats->tx_err);
32002 + atomic_inc_unchecked(&vcc->stats->tx_err);
32003 return -ENOLINK;
32004 }
32005 size = skb->len+sizeof(struct atmtcp_hdr);
32006 @@ -214,7 +214,7 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
32007 if (!new_skb) {
32008 if (vcc->pop) vcc->pop(vcc,skb);
32009 else dev_kfree_skb(skb);
32010 - atomic_inc(&vcc->stats->tx_err);
32011 + atomic_inc_unchecked(&vcc->stats->tx_err);
32012 return -ENOBUFS;
32013 }
32014 hdr = (void *) skb_put(new_skb,sizeof(struct atmtcp_hdr));
32015 @@ -225,8 +225,8 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
32016 if (vcc->pop) vcc->pop(vcc,skb);
32017 else dev_kfree_skb(skb);
32018 out_vcc->push(out_vcc,new_skb);
32019 - atomic_inc(&vcc->stats->tx);
32020 - atomic_inc(&out_vcc->stats->rx);
32021 + atomic_inc_unchecked(&vcc->stats->tx);
32022 + atomic_inc_unchecked(&out_vcc->stats->rx);
32023 return 0;
32024 }
32025
32026 @@ -299,7 +299,7 @@ static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb)
32027 out_vcc = find_vcc(dev, ntohs(hdr->vpi), ntohs(hdr->vci));
32028 read_unlock(&vcc_sklist_lock);
32029 if (!out_vcc) {
32030 - atomic_inc(&vcc->stats->tx_err);
32031 + atomic_inc_unchecked(&vcc->stats->tx_err);
32032 goto done;
32033 }
32034 skb_pull(skb,sizeof(struct atmtcp_hdr));
32035 @@ -311,8 +311,8 @@ static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb)
32036 __net_timestamp(new_skb);
32037 skb_copy_from_linear_data(skb, skb_put(new_skb, skb->len), skb->len);
32038 out_vcc->push(out_vcc,new_skb);
32039 - atomic_inc(&vcc->stats->tx);
32040 - atomic_inc(&out_vcc->stats->rx);
32041 + atomic_inc_unchecked(&vcc->stats->tx);
32042 + atomic_inc_unchecked(&out_vcc->stats->rx);
32043 done:
32044 if (vcc->pop) vcc->pop(vcc,skb);
32045 else dev_kfree_skb(skb);
32046 diff --git a/drivers/atm/eni.c b/drivers/atm/eni.c
32047 index b1955ba..b179940 100644
32048 --- a/drivers/atm/eni.c
32049 +++ b/drivers/atm/eni.c
32050 @@ -522,7 +522,7 @@ static int rx_aal0(struct atm_vcc *vcc)
32051 DPRINTK(DEV_LABEL "(itf %d): trashing empty cell\n",
32052 vcc->dev->number);
32053 length = 0;
32054 - atomic_inc(&vcc->stats->rx_err);
32055 + atomic_inc_unchecked(&vcc->stats->rx_err);
32056 }
32057 else {
32058 length = ATM_CELL_SIZE-1; /* no HEC */
32059 @@ -577,7 +577,7 @@ static int rx_aal5(struct atm_vcc *vcc)
32060 size);
32061 }
32062 eff = length = 0;
32063 - atomic_inc(&vcc->stats->rx_err);
32064 + atomic_inc_unchecked(&vcc->stats->rx_err);
32065 }
32066 else {
32067 size = (descr & MID_RED_COUNT)*(ATM_CELL_PAYLOAD >> 2);
32068 @@ -594,7 +594,7 @@ static int rx_aal5(struct atm_vcc *vcc)
32069 "(VCI=%d,length=%ld,size=%ld (descr 0x%lx))\n",
32070 vcc->dev->number,vcc->vci,length,size << 2,descr);
32071 length = eff = 0;
32072 - atomic_inc(&vcc->stats->rx_err);
32073 + atomic_inc_unchecked(&vcc->stats->rx_err);
32074 }
32075 }
32076 skb = eff ? atm_alloc_charge(vcc,eff << 2,GFP_ATOMIC) : NULL;
32077 @@ -767,7 +767,7 @@ rx_dequeued++;
32078 vcc->push(vcc,skb);
32079 pushed++;
32080 }
32081 - atomic_inc(&vcc->stats->rx);
32082 + atomic_inc_unchecked(&vcc->stats->rx);
32083 }
32084 wake_up(&eni_dev->rx_wait);
32085 }
32086 @@ -1227,7 +1227,7 @@ static void dequeue_tx(struct atm_dev *dev)
32087 PCI_DMA_TODEVICE);
32088 if (vcc->pop) vcc->pop(vcc,skb);
32089 else dev_kfree_skb_irq(skb);
32090 - atomic_inc(&vcc->stats->tx);
32091 + atomic_inc_unchecked(&vcc->stats->tx);
32092 wake_up(&eni_dev->tx_wait);
32093 dma_complete++;
32094 }
32095 diff --git a/drivers/atm/firestream.c b/drivers/atm/firestream.c
32096 index b41c948..a002b17 100644
32097 --- a/drivers/atm/firestream.c
32098 +++ b/drivers/atm/firestream.c
32099 @@ -749,7 +749,7 @@ static void process_txdone_queue (struct fs_dev *dev, struct queue *q)
32100 }
32101 }
32102
32103 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
32104 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
32105
32106 fs_dprintk (FS_DEBUG_TXMEM, "i");
32107 fs_dprintk (FS_DEBUG_ALLOC, "Free t-skb: %p\n", skb);
32108 @@ -816,7 +816,7 @@ static void process_incoming (struct fs_dev *dev, struct queue *q)
32109 #endif
32110 skb_put (skb, qe->p1 & 0xffff);
32111 ATM_SKB(skb)->vcc = atm_vcc;
32112 - atomic_inc(&atm_vcc->stats->rx);
32113 + atomic_inc_unchecked(&atm_vcc->stats->rx);
32114 __net_timestamp(skb);
32115 fs_dprintk (FS_DEBUG_ALLOC, "Free rec-skb: %p (pushed)\n", skb);
32116 atm_vcc->push (atm_vcc, skb);
32117 @@ -837,12 +837,12 @@ static void process_incoming (struct fs_dev *dev, struct queue *q)
32118 kfree (pe);
32119 }
32120 if (atm_vcc)
32121 - atomic_inc(&atm_vcc->stats->rx_drop);
32122 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
32123 break;
32124 case 0x1f: /* Reassembly abort: no buffers. */
32125 /* Silently increment error counter. */
32126 if (atm_vcc)
32127 - atomic_inc(&atm_vcc->stats->rx_drop);
32128 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
32129 break;
32130 default: /* Hmm. Haven't written the code to handle the others yet... -- REW */
32131 printk (KERN_WARNING "Don't know what to do with RX status %x: %s.\n",
32132 diff --git a/drivers/atm/fore200e.c b/drivers/atm/fore200e.c
32133 index 204814e..cede831 100644
32134 --- a/drivers/atm/fore200e.c
32135 +++ b/drivers/atm/fore200e.c
32136 @@ -931,9 +931,9 @@ fore200e_tx_irq(struct fore200e* fore200e)
32137 #endif
32138 /* check error condition */
32139 if (*entry->status & STATUS_ERROR)
32140 - atomic_inc(&vcc->stats->tx_err);
32141 + atomic_inc_unchecked(&vcc->stats->tx_err);
32142 else
32143 - atomic_inc(&vcc->stats->tx);
32144 + atomic_inc_unchecked(&vcc->stats->tx);
32145 }
32146 }
32147
32148 @@ -1082,7 +1082,7 @@ fore200e_push_rpd(struct fore200e* fore200e, struct atm_vcc* vcc, struct rpd* rp
32149 if (skb == NULL) {
32150 DPRINTK(2, "unable to alloc new skb, rx PDU length = %d\n", pdu_len);
32151
32152 - atomic_inc(&vcc->stats->rx_drop);
32153 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32154 return -ENOMEM;
32155 }
32156
32157 @@ -1125,14 +1125,14 @@ fore200e_push_rpd(struct fore200e* fore200e, struct atm_vcc* vcc, struct rpd* rp
32158
32159 dev_kfree_skb_any(skb);
32160
32161 - atomic_inc(&vcc->stats->rx_drop);
32162 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32163 return -ENOMEM;
32164 }
32165
32166 ASSERT(atomic_read(&sk_atm(vcc)->sk_wmem_alloc) >= 0);
32167
32168 vcc->push(vcc, skb);
32169 - atomic_inc(&vcc->stats->rx);
32170 + atomic_inc_unchecked(&vcc->stats->rx);
32171
32172 ASSERT(atomic_read(&sk_atm(vcc)->sk_wmem_alloc) >= 0);
32173
32174 @@ -1210,7 +1210,7 @@ fore200e_rx_irq(struct fore200e* fore200e)
32175 DPRINTK(2, "damaged PDU on %d.%d.%d\n",
32176 fore200e->atm_dev->number,
32177 entry->rpd->atm_header.vpi, entry->rpd->atm_header.vci);
32178 - atomic_inc(&vcc->stats->rx_err);
32179 + atomic_inc_unchecked(&vcc->stats->rx_err);
32180 }
32181 }
32182
32183 @@ -1655,7 +1655,7 @@ fore200e_send(struct atm_vcc *vcc, struct sk_buff *skb)
32184 goto retry_here;
32185 }
32186
32187 - atomic_inc(&vcc->stats->tx_err);
32188 + atomic_inc_unchecked(&vcc->stats->tx_err);
32189
32190 fore200e->tx_sat++;
32191 DPRINTK(2, "tx queue of device %s is saturated, PDU dropped - heartbeat is %08x\n",
32192 diff --git a/drivers/atm/he.c b/drivers/atm/he.c
32193 index d689126..e78e412 100644
32194 --- a/drivers/atm/he.c
32195 +++ b/drivers/atm/he.c
32196 @@ -1698,7 +1698,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
32197
32198 if (RBRQ_HBUF_ERR(he_dev->rbrq_head)) {
32199 hprintk("HBUF_ERR! (cid 0x%x)\n", cid);
32200 - atomic_inc(&vcc->stats->rx_drop);
32201 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32202 goto return_host_buffers;
32203 }
32204
32205 @@ -1725,7 +1725,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
32206 RBRQ_LEN_ERR(he_dev->rbrq_head)
32207 ? "LEN_ERR" : "",
32208 vcc->vpi, vcc->vci);
32209 - atomic_inc(&vcc->stats->rx_err);
32210 + atomic_inc_unchecked(&vcc->stats->rx_err);
32211 goto return_host_buffers;
32212 }
32213
32214 @@ -1777,7 +1777,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
32215 vcc->push(vcc, skb);
32216 spin_lock(&he_dev->global_lock);
32217
32218 - atomic_inc(&vcc->stats->rx);
32219 + atomic_inc_unchecked(&vcc->stats->rx);
32220
32221 return_host_buffers:
32222 ++pdus_assembled;
32223 @@ -2103,7 +2103,7 @@ __enqueue_tpd(struct he_dev *he_dev, struct he_tpd *tpd, unsigned cid)
32224 tpd->vcc->pop(tpd->vcc, tpd->skb);
32225 else
32226 dev_kfree_skb_any(tpd->skb);
32227 - atomic_inc(&tpd->vcc->stats->tx_err);
32228 + atomic_inc_unchecked(&tpd->vcc->stats->tx_err);
32229 }
32230 pci_pool_free(he_dev->tpd_pool, tpd, TPD_ADDR(tpd->status));
32231 return;
32232 @@ -2515,7 +2515,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32233 vcc->pop(vcc, skb);
32234 else
32235 dev_kfree_skb_any(skb);
32236 - atomic_inc(&vcc->stats->tx_err);
32237 + atomic_inc_unchecked(&vcc->stats->tx_err);
32238 return -EINVAL;
32239 }
32240
32241 @@ -2526,7 +2526,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32242 vcc->pop(vcc, skb);
32243 else
32244 dev_kfree_skb_any(skb);
32245 - atomic_inc(&vcc->stats->tx_err);
32246 + atomic_inc_unchecked(&vcc->stats->tx_err);
32247 return -EINVAL;
32248 }
32249 #endif
32250 @@ -2538,7 +2538,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32251 vcc->pop(vcc, skb);
32252 else
32253 dev_kfree_skb_any(skb);
32254 - atomic_inc(&vcc->stats->tx_err);
32255 + atomic_inc_unchecked(&vcc->stats->tx_err);
32256 spin_unlock_irqrestore(&he_dev->global_lock, flags);
32257 return -ENOMEM;
32258 }
32259 @@ -2580,7 +2580,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32260 vcc->pop(vcc, skb);
32261 else
32262 dev_kfree_skb_any(skb);
32263 - atomic_inc(&vcc->stats->tx_err);
32264 + atomic_inc_unchecked(&vcc->stats->tx_err);
32265 spin_unlock_irqrestore(&he_dev->global_lock, flags);
32266 return -ENOMEM;
32267 }
32268 @@ -2611,7 +2611,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32269 __enqueue_tpd(he_dev, tpd, cid);
32270 spin_unlock_irqrestore(&he_dev->global_lock, flags);
32271
32272 - atomic_inc(&vcc->stats->tx);
32273 + atomic_inc_unchecked(&vcc->stats->tx);
32274
32275 return 0;
32276 }
32277 diff --git a/drivers/atm/horizon.c b/drivers/atm/horizon.c
32278 index 1dc0519..1aadaf7 100644
32279 --- a/drivers/atm/horizon.c
32280 +++ b/drivers/atm/horizon.c
32281 @@ -1034,7 +1034,7 @@ static void rx_schedule (hrz_dev * dev, int irq) {
32282 {
32283 struct atm_vcc * vcc = ATM_SKB(skb)->vcc;
32284 // VC layer stats
32285 - atomic_inc(&vcc->stats->rx);
32286 + atomic_inc_unchecked(&vcc->stats->rx);
32287 __net_timestamp(skb);
32288 // end of our responsibility
32289 vcc->push (vcc, skb);
32290 @@ -1186,7 +1186,7 @@ static void tx_schedule (hrz_dev * const dev, int irq) {
32291 dev->tx_iovec = NULL;
32292
32293 // VC layer stats
32294 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
32295 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
32296
32297 // free the skb
32298 hrz_kfree_skb (skb);
32299 diff --git a/drivers/atm/idt77252.c b/drivers/atm/idt77252.c
32300 index 272f009..a18ba55 100644
32301 --- a/drivers/atm/idt77252.c
32302 +++ b/drivers/atm/idt77252.c
32303 @@ -812,7 +812,7 @@ drain_scq(struct idt77252_dev *card, struct vc_map *vc)
32304 else
32305 dev_kfree_skb(skb);
32306
32307 - atomic_inc(&vcc->stats->tx);
32308 + atomic_inc_unchecked(&vcc->stats->tx);
32309 }
32310
32311 atomic_dec(&scq->used);
32312 @@ -1075,13 +1075,13 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32313 if ((sb = dev_alloc_skb(64)) == NULL) {
32314 printk("%s: Can't allocate buffers for aal0.\n",
32315 card->name);
32316 - atomic_add(i, &vcc->stats->rx_drop);
32317 + atomic_add_unchecked(i, &vcc->stats->rx_drop);
32318 break;
32319 }
32320 if (!atm_charge(vcc, sb->truesize)) {
32321 RXPRINTK("%s: atm_charge() dropped aal0 packets.\n",
32322 card->name);
32323 - atomic_add(i - 1, &vcc->stats->rx_drop);
32324 + atomic_add_unchecked(i - 1, &vcc->stats->rx_drop);
32325 dev_kfree_skb(sb);
32326 break;
32327 }
32328 @@ -1098,7 +1098,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32329 ATM_SKB(sb)->vcc = vcc;
32330 __net_timestamp(sb);
32331 vcc->push(vcc, sb);
32332 - atomic_inc(&vcc->stats->rx);
32333 + atomic_inc_unchecked(&vcc->stats->rx);
32334
32335 cell += ATM_CELL_PAYLOAD;
32336 }
32337 @@ -1135,13 +1135,13 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32338 "(CDC: %08x)\n",
32339 card->name, len, rpp->len, readl(SAR_REG_CDC));
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 (stat & SAR_RSQE_CRC) {
32346 RXPRINTK("%s: AAL5 CRC error.\n", card->name);
32347 recycle_rx_pool_skb(card, rpp);
32348 - atomic_inc(&vcc->stats->rx_err);
32349 + atomic_inc_unchecked(&vcc->stats->rx_err);
32350 return;
32351 }
32352 if (skb_queue_len(&rpp->queue) > 1) {
32353 @@ -1152,7 +1152,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32354 RXPRINTK("%s: Can't alloc RX skb.\n",
32355 card->name);
32356 recycle_rx_pool_skb(card, rpp);
32357 - atomic_inc(&vcc->stats->rx_err);
32358 + atomic_inc_unchecked(&vcc->stats->rx_err);
32359 return;
32360 }
32361 if (!atm_charge(vcc, skb->truesize)) {
32362 @@ -1171,7 +1171,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32363 __net_timestamp(skb);
32364
32365 vcc->push(vcc, skb);
32366 - atomic_inc(&vcc->stats->rx);
32367 + atomic_inc_unchecked(&vcc->stats->rx);
32368
32369 return;
32370 }
32371 @@ -1193,7 +1193,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32372 __net_timestamp(skb);
32373
32374 vcc->push(vcc, skb);
32375 - atomic_inc(&vcc->stats->rx);
32376 + atomic_inc_unchecked(&vcc->stats->rx);
32377
32378 if (skb->truesize > SAR_FB_SIZE_3)
32379 add_rx_skb(card, 3, SAR_FB_SIZE_3, 1);
32380 @@ -1304,14 +1304,14 @@ idt77252_rx_raw(struct idt77252_dev *card)
32381 if (vcc->qos.aal != ATM_AAL0) {
32382 RPRINTK("%s: raw cell for non AAL0 vc %u.%u\n",
32383 card->name, vpi, vci);
32384 - atomic_inc(&vcc->stats->rx_drop);
32385 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32386 goto drop;
32387 }
32388
32389 if ((sb = dev_alloc_skb(64)) == NULL) {
32390 printk("%s: Can't allocate buffers for AAL0.\n",
32391 card->name);
32392 - atomic_inc(&vcc->stats->rx_err);
32393 + atomic_inc_unchecked(&vcc->stats->rx_err);
32394 goto drop;
32395 }
32396
32397 @@ -1330,7 +1330,7 @@ idt77252_rx_raw(struct idt77252_dev *card)
32398 ATM_SKB(sb)->vcc = vcc;
32399 __net_timestamp(sb);
32400 vcc->push(vcc, sb);
32401 - atomic_inc(&vcc->stats->rx);
32402 + atomic_inc_unchecked(&vcc->stats->rx);
32403
32404 drop:
32405 skb_pull(queue, 64);
32406 @@ -1955,13 +1955,13 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
32407
32408 if (vc == NULL) {
32409 printk("%s: NULL connection in send().\n", card->name);
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 if (!test_bit(VCF_TX, &vc->flags)) {
32416 printk("%s: Trying to transmit on a non-tx VC.\n", card->name);
32417 - atomic_inc(&vcc->stats->tx_err);
32418 + atomic_inc_unchecked(&vcc->stats->tx_err);
32419 dev_kfree_skb(skb);
32420 return -EINVAL;
32421 }
32422 @@ -1973,14 +1973,14 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
32423 break;
32424 default:
32425 printk("%s: Unsupported AAL: %d\n", card->name, vcc->qos.aal);
32426 - atomic_inc(&vcc->stats->tx_err);
32427 + atomic_inc_unchecked(&vcc->stats->tx_err);
32428 dev_kfree_skb(skb);
32429 return -EINVAL;
32430 }
32431
32432 if (skb_shinfo(skb)->nr_frags != 0) {
32433 printk("%s: No scatter-gather yet.\n", card->name);
32434 - atomic_inc(&vcc->stats->tx_err);
32435 + atomic_inc_unchecked(&vcc->stats->tx_err);
32436 dev_kfree_skb(skb);
32437 return -EINVAL;
32438 }
32439 @@ -1988,7 +1988,7 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
32440
32441 err = queue_skb(card, vc, skb, oam);
32442 if (err) {
32443 - atomic_inc(&vcc->stats->tx_err);
32444 + atomic_inc_unchecked(&vcc->stats->tx_err);
32445 dev_kfree_skb(skb);
32446 return err;
32447 }
32448 @@ -2011,7 +2011,7 @@ idt77252_send_oam(struct atm_vcc *vcc, void *cell, int flags)
32449 skb = dev_alloc_skb(64);
32450 if (!skb) {
32451 printk("%s: Out of memory in send_oam().\n", card->name);
32452 - atomic_inc(&vcc->stats->tx_err);
32453 + atomic_inc_unchecked(&vcc->stats->tx_err);
32454 return -ENOMEM;
32455 }
32456 atomic_add(skb->truesize, &sk_atm(vcc)->sk_wmem_alloc);
32457 diff --git a/drivers/atm/iphase.c b/drivers/atm/iphase.c
32458 index 4217f29..88f547a 100644
32459 --- a/drivers/atm/iphase.c
32460 +++ b/drivers/atm/iphase.c
32461 @@ -1145,7 +1145,7 @@ static int rx_pkt(struct atm_dev *dev)
32462 status = (u_short) (buf_desc_ptr->desc_mode);
32463 if (status & (RX_CER | RX_PTE | RX_OFL))
32464 {
32465 - atomic_inc(&vcc->stats->rx_err);
32466 + atomic_inc_unchecked(&vcc->stats->rx_err);
32467 IF_ERR(printk("IA: bad packet, dropping it");)
32468 if (status & RX_CER) {
32469 IF_ERR(printk(" cause: packet CRC error\n");)
32470 @@ -1168,7 +1168,7 @@ static int rx_pkt(struct atm_dev *dev)
32471 len = dma_addr - buf_addr;
32472 if (len > iadev->rx_buf_sz) {
32473 printk("Over %d bytes sdu received, dropped!!!\n", iadev->rx_buf_sz);
32474 - atomic_inc(&vcc->stats->rx_err);
32475 + atomic_inc_unchecked(&vcc->stats->rx_err);
32476 goto out_free_desc;
32477 }
32478
32479 @@ -1318,7 +1318,7 @@ static void rx_dle_intr(struct atm_dev *dev)
32480 ia_vcc = INPH_IA_VCC(vcc);
32481 if (ia_vcc == NULL)
32482 {
32483 - atomic_inc(&vcc->stats->rx_err);
32484 + atomic_inc_unchecked(&vcc->stats->rx_err);
32485 atm_return(vcc, skb->truesize);
32486 dev_kfree_skb_any(skb);
32487 goto INCR_DLE;
32488 @@ -1330,7 +1330,7 @@ static void rx_dle_intr(struct atm_dev *dev)
32489 if ((length > iadev->rx_buf_sz) || (length >
32490 (skb->len - sizeof(struct cpcs_trailer))))
32491 {
32492 - atomic_inc(&vcc->stats->rx_err);
32493 + atomic_inc_unchecked(&vcc->stats->rx_err);
32494 IF_ERR(printk("rx_dle_intr: Bad AAL5 trailer %d (skb len %d)",
32495 length, skb->len);)
32496 atm_return(vcc, skb->truesize);
32497 @@ -1346,7 +1346,7 @@ static void rx_dle_intr(struct atm_dev *dev)
32498
32499 IF_RX(printk("rx_dle_intr: skb push");)
32500 vcc->push(vcc,skb);
32501 - atomic_inc(&vcc->stats->rx);
32502 + atomic_inc_unchecked(&vcc->stats->rx);
32503 iadev->rx_pkt_cnt++;
32504 }
32505 INCR_DLE:
32506 @@ -2826,15 +2826,15 @@ static int ia_ioctl(struct atm_dev *dev, unsigned int cmd, void __user *arg)
32507 {
32508 struct k_sonet_stats *stats;
32509 stats = &PRIV(_ia_dev[board])->sonet_stats;
32510 - printk("section_bip: %d\n", atomic_read(&stats->section_bip));
32511 - printk("line_bip : %d\n", atomic_read(&stats->line_bip));
32512 - printk("path_bip : %d\n", atomic_read(&stats->path_bip));
32513 - printk("line_febe : %d\n", atomic_read(&stats->line_febe));
32514 - printk("path_febe : %d\n", atomic_read(&stats->path_febe));
32515 - printk("corr_hcs : %d\n", atomic_read(&stats->corr_hcs));
32516 - printk("uncorr_hcs : %d\n", atomic_read(&stats->uncorr_hcs));
32517 - printk("tx_cells : %d\n", atomic_read(&stats->tx_cells));
32518 - printk("rx_cells : %d\n", atomic_read(&stats->rx_cells));
32519 + printk("section_bip: %d\n", atomic_read_unchecked(&stats->section_bip));
32520 + printk("line_bip : %d\n", atomic_read_unchecked(&stats->line_bip));
32521 + printk("path_bip : %d\n", atomic_read_unchecked(&stats->path_bip));
32522 + printk("line_febe : %d\n", atomic_read_unchecked(&stats->line_febe));
32523 + printk("path_febe : %d\n", atomic_read_unchecked(&stats->path_febe));
32524 + printk("corr_hcs : %d\n", atomic_read_unchecked(&stats->corr_hcs));
32525 + printk("uncorr_hcs : %d\n", atomic_read_unchecked(&stats->uncorr_hcs));
32526 + printk("tx_cells : %d\n", atomic_read_unchecked(&stats->tx_cells));
32527 + printk("rx_cells : %d\n", atomic_read_unchecked(&stats->rx_cells));
32528 }
32529 ia_cmds.status = 0;
32530 break;
32531 @@ -2939,7 +2939,7 @@ static int ia_pkt_tx (struct atm_vcc *vcc, struct sk_buff *skb) {
32532 if ((desc == 0) || (desc > iadev->num_tx_desc))
32533 {
32534 IF_ERR(printk(DEV_LABEL "invalid desc for send: %d\n", desc);)
32535 - atomic_inc(&vcc->stats->tx);
32536 + atomic_inc_unchecked(&vcc->stats->tx);
32537 if (vcc->pop)
32538 vcc->pop(vcc, skb);
32539 else
32540 @@ -3044,14 +3044,14 @@ static int ia_pkt_tx (struct atm_vcc *vcc, struct sk_buff *skb) {
32541 ATM_DESC(skb) = vcc->vci;
32542 skb_queue_tail(&iadev->tx_dma_q, skb);
32543
32544 - atomic_inc(&vcc->stats->tx);
32545 + atomic_inc_unchecked(&vcc->stats->tx);
32546 iadev->tx_pkt_cnt++;
32547 /* Increment transaction counter */
32548 writel(2, iadev->dma+IPHASE5575_TX_COUNTER);
32549
32550 #if 0
32551 /* add flow control logic */
32552 - if (atomic_read(&vcc->stats->tx) % 20 == 0) {
32553 + if (atomic_read_unchecked(&vcc->stats->tx) % 20 == 0) {
32554 if (iavcc->vc_desc_cnt > 10) {
32555 vcc->tx_quota = vcc->tx_quota * 3 / 4;
32556 printk("Tx1: vcc->tx_quota = %d \n", (u32)vcc->tx_quota );
32557 diff --git a/drivers/atm/lanai.c b/drivers/atm/lanai.c
32558 index fa7d701..1e404c7 100644
32559 --- a/drivers/atm/lanai.c
32560 +++ b/drivers/atm/lanai.c
32561 @@ -1303,7 +1303,7 @@ static void lanai_send_one_aal5(struct lanai_dev *lanai,
32562 vcc_tx_add_aal5_trailer(lvcc, skb->len, 0, 0);
32563 lanai_endtx(lanai, lvcc);
32564 lanai_free_skb(lvcc->tx.atmvcc, skb);
32565 - atomic_inc(&lvcc->tx.atmvcc->stats->tx);
32566 + atomic_inc_unchecked(&lvcc->tx.atmvcc->stats->tx);
32567 }
32568
32569 /* Try to fill the buffer - don't call unless there is backlog */
32570 @@ -1426,7 +1426,7 @@ static void vcc_rx_aal5(struct lanai_vcc *lvcc, int endptr)
32571 ATM_SKB(skb)->vcc = lvcc->rx.atmvcc;
32572 __net_timestamp(skb);
32573 lvcc->rx.atmvcc->push(lvcc->rx.atmvcc, skb);
32574 - atomic_inc(&lvcc->rx.atmvcc->stats->rx);
32575 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx);
32576 out:
32577 lvcc->rx.buf.ptr = end;
32578 cardvcc_write(lvcc, endptr, vcc_rxreadptr);
32579 @@ -1667,7 +1667,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
32580 DPRINTK("(itf %d) got RX service entry 0x%X for non-AAL5 "
32581 "vcc %d\n", lanai->number, (unsigned int) s, vci);
32582 lanai->stats.service_rxnotaal5++;
32583 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
32584 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
32585 return 0;
32586 }
32587 if (likely(!(s & (SERVICE_TRASH | SERVICE_STREAM | SERVICE_CRCERR)))) {
32588 @@ -1679,7 +1679,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
32589 int bytes;
32590 read_unlock(&vcc_sklist_lock);
32591 DPRINTK("got trashed rx pdu on vci %d\n", vci);
32592 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
32593 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
32594 lvcc->stats.x.aal5.service_trash++;
32595 bytes = (SERVICE_GET_END(s) * 16) -
32596 (((unsigned long) lvcc->rx.buf.ptr) -
32597 @@ -1691,7 +1691,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
32598 }
32599 if (s & SERVICE_STREAM) {
32600 read_unlock(&vcc_sklist_lock);
32601 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
32602 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
32603 lvcc->stats.x.aal5.service_stream++;
32604 printk(KERN_ERR DEV_LABEL "(itf %d): Got AAL5 stream "
32605 "PDU on VCI %d!\n", lanai->number, vci);
32606 @@ -1699,7 +1699,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
32607 return 0;
32608 }
32609 DPRINTK("got rx crc error on vci %d\n", vci);
32610 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
32611 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
32612 lvcc->stats.x.aal5.service_rxcrc++;
32613 lvcc->rx.buf.ptr = &lvcc->rx.buf.start[SERVICE_GET_END(s) * 4];
32614 cardvcc_write(lvcc, SERVICE_GET_END(s), vcc_rxreadptr);
32615 diff --git a/drivers/atm/nicstar.c b/drivers/atm/nicstar.c
32616 index 6587dc2..149833d 100644
32617 --- a/drivers/atm/nicstar.c
32618 +++ b/drivers/atm/nicstar.c
32619 @@ -1641,7 +1641,7 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
32620 if ((vc = (vc_map *) vcc->dev_data) == NULL) {
32621 printk("nicstar%d: vcc->dev_data == NULL on ns_send().\n",
32622 card->index);
32623 - atomic_inc(&vcc->stats->tx_err);
32624 + atomic_inc_unchecked(&vcc->stats->tx_err);
32625 dev_kfree_skb_any(skb);
32626 return -EINVAL;
32627 }
32628 @@ -1649,7 +1649,7 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
32629 if (!vc->tx) {
32630 printk("nicstar%d: Trying to transmit on a non-tx VC.\n",
32631 card->index);
32632 - atomic_inc(&vcc->stats->tx_err);
32633 + atomic_inc_unchecked(&vcc->stats->tx_err);
32634 dev_kfree_skb_any(skb);
32635 return -EINVAL;
32636 }
32637 @@ -1657,14 +1657,14 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
32638 if (vcc->qos.aal != ATM_AAL5 && vcc->qos.aal != ATM_AAL0) {
32639 printk("nicstar%d: Only AAL0 and AAL5 are supported.\n",
32640 card->index);
32641 - atomic_inc(&vcc->stats->tx_err);
32642 + atomic_inc_unchecked(&vcc->stats->tx_err);
32643 dev_kfree_skb_any(skb);
32644 return -EINVAL;
32645 }
32646
32647 if (skb_shinfo(skb)->nr_frags != 0) {
32648 printk("nicstar%d: No scatter-gather yet.\n", card->index);
32649 - atomic_inc(&vcc->stats->tx_err);
32650 + atomic_inc_unchecked(&vcc->stats->tx_err);
32651 dev_kfree_skb_any(skb);
32652 return -EINVAL;
32653 }
32654 @@ -1712,11 +1712,11 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
32655 }
32656
32657 if (push_scqe(card, vc, scq, &scqe, skb) != 0) {
32658 - atomic_inc(&vcc->stats->tx_err);
32659 + atomic_inc_unchecked(&vcc->stats->tx_err);
32660 dev_kfree_skb_any(skb);
32661 return -EIO;
32662 }
32663 - atomic_inc(&vcc->stats->tx);
32664 + atomic_inc_unchecked(&vcc->stats->tx);
32665
32666 return 0;
32667 }
32668 @@ -2033,14 +2033,14 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32669 printk
32670 ("nicstar%d: Can't allocate buffers for aal0.\n",
32671 card->index);
32672 - atomic_add(i, &vcc->stats->rx_drop);
32673 + atomic_add_unchecked(i, &vcc->stats->rx_drop);
32674 break;
32675 }
32676 if (!atm_charge(vcc, sb->truesize)) {
32677 RXPRINTK
32678 ("nicstar%d: atm_charge() dropped aal0 packets.\n",
32679 card->index);
32680 - atomic_add(i - 1, &vcc->stats->rx_drop); /* already increased by 1 */
32681 + atomic_add_unchecked(i - 1, &vcc->stats->rx_drop); /* already increased by 1 */
32682 dev_kfree_skb_any(sb);
32683 break;
32684 }
32685 @@ -2055,7 +2055,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32686 ATM_SKB(sb)->vcc = vcc;
32687 __net_timestamp(sb);
32688 vcc->push(vcc, sb);
32689 - atomic_inc(&vcc->stats->rx);
32690 + atomic_inc_unchecked(&vcc->stats->rx);
32691 cell += ATM_CELL_PAYLOAD;
32692 }
32693
32694 @@ -2072,7 +2072,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32695 if (iovb == NULL) {
32696 printk("nicstar%d: Out of iovec buffers.\n",
32697 card->index);
32698 - atomic_inc(&vcc->stats->rx_drop);
32699 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32700 recycle_rx_buf(card, skb);
32701 return;
32702 }
32703 @@ -2096,7 +2096,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32704 small or large buffer itself. */
32705 } else if (NS_PRV_IOVCNT(iovb) >= NS_MAX_IOVECS) {
32706 printk("nicstar%d: received too big AAL5 SDU.\n", card->index);
32707 - atomic_inc(&vcc->stats->rx_err);
32708 + atomic_inc_unchecked(&vcc->stats->rx_err);
32709 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
32710 NS_MAX_IOVECS);
32711 NS_PRV_IOVCNT(iovb) = 0;
32712 @@ -2116,7 +2116,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32713 ("nicstar%d: Expected a small buffer, and this is not one.\n",
32714 card->index);
32715 which_list(card, skb);
32716 - atomic_inc(&vcc->stats->rx_err);
32717 + atomic_inc_unchecked(&vcc->stats->rx_err);
32718 recycle_rx_buf(card, skb);
32719 vc->rx_iov = NULL;
32720 recycle_iov_buf(card, iovb);
32721 @@ -2129,7 +2129,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32722 ("nicstar%d: Expected a large buffer, and this is not one.\n",
32723 card->index);
32724 which_list(card, skb);
32725 - atomic_inc(&vcc->stats->rx_err);
32726 + atomic_inc_unchecked(&vcc->stats->rx_err);
32727 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
32728 NS_PRV_IOVCNT(iovb));
32729 vc->rx_iov = NULL;
32730 @@ -2152,7 +2152,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32731 printk(" - PDU size mismatch.\n");
32732 else
32733 printk(".\n");
32734 - atomic_inc(&vcc->stats->rx_err);
32735 + atomic_inc_unchecked(&vcc->stats->rx_err);
32736 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
32737 NS_PRV_IOVCNT(iovb));
32738 vc->rx_iov = NULL;
32739 @@ -2166,7 +2166,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32740 /* skb points to a small buffer */
32741 if (!atm_charge(vcc, skb->truesize)) {
32742 push_rxbufs(card, skb);
32743 - atomic_inc(&vcc->stats->rx_drop);
32744 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32745 } else {
32746 skb_put(skb, len);
32747 dequeue_sm_buf(card, skb);
32748 @@ -2176,7 +2176,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32749 ATM_SKB(skb)->vcc = vcc;
32750 __net_timestamp(skb);
32751 vcc->push(vcc, skb);
32752 - atomic_inc(&vcc->stats->rx);
32753 + atomic_inc_unchecked(&vcc->stats->rx);
32754 }
32755 } else if (NS_PRV_IOVCNT(iovb) == 2) { /* One small plus one large buffer */
32756 struct sk_buff *sb;
32757 @@ -2187,7 +2187,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32758 if (len <= NS_SMBUFSIZE) {
32759 if (!atm_charge(vcc, sb->truesize)) {
32760 push_rxbufs(card, sb);
32761 - atomic_inc(&vcc->stats->rx_drop);
32762 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32763 } else {
32764 skb_put(sb, len);
32765 dequeue_sm_buf(card, sb);
32766 @@ -2197,7 +2197,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32767 ATM_SKB(sb)->vcc = vcc;
32768 __net_timestamp(sb);
32769 vcc->push(vcc, sb);
32770 - atomic_inc(&vcc->stats->rx);
32771 + atomic_inc_unchecked(&vcc->stats->rx);
32772 }
32773
32774 push_rxbufs(card, skb);
32775 @@ -2206,7 +2206,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32776
32777 if (!atm_charge(vcc, skb->truesize)) {
32778 push_rxbufs(card, skb);
32779 - atomic_inc(&vcc->stats->rx_drop);
32780 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32781 } else {
32782 dequeue_lg_buf(card, skb);
32783 #ifdef NS_USE_DESTRUCTORS
32784 @@ -2219,7 +2219,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32785 ATM_SKB(skb)->vcc = vcc;
32786 __net_timestamp(skb);
32787 vcc->push(vcc, skb);
32788 - atomic_inc(&vcc->stats->rx);
32789 + atomic_inc_unchecked(&vcc->stats->rx);
32790 }
32791
32792 push_rxbufs(card, sb);
32793 @@ -2240,7 +2240,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32794 printk
32795 ("nicstar%d: Out of huge buffers.\n",
32796 card->index);
32797 - atomic_inc(&vcc->stats->rx_drop);
32798 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32799 recycle_iovec_rx_bufs(card,
32800 (struct iovec *)
32801 iovb->data,
32802 @@ -2291,7 +2291,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32803 card->hbpool.count++;
32804 } else
32805 dev_kfree_skb_any(hb);
32806 - atomic_inc(&vcc->stats->rx_drop);
32807 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32808 } else {
32809 /* Copy the small buffer to the huge buffer */
32810 sb = (struct sk_buff *)iov->iov_base;
32811 @@ -2328,7 +2328,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32812 #endif /* NS_USE_DESTRUCTORS */
32813 __net_timestamp(hb);
32814 vcc->push(vcc, hb);
32815 - atomic_inc(&vcc->stats->rx);
32816 + atomic_inc_unchecked(&vcc->stats->rx);
32817 }
32818 }
32819
32820 diff --git a/drivers/atm/solos-pci.c b/drivers/atm/solos-pci.c
32821 index 32784d1..4a8434a 100644
32822 --- a/drivers/atm/solos-pci.c
32823 +++ b/drivers/atm/solos-pci.c
32824 @@ -838,7 +838,7 @@ void solos_bh(unsigned long card_arg)
32825 }
32826 atm_charge(vcc, skb->truesize);
32827 vcc->push(vcc, skb);
32828 - atomic_inc(&vcc->stats->rx);
32829 + atomic_inc_unchecked(&vcc->stats->rx);
32830 break;
32831
32832 case PKT_STATUS:
32833 @@ -1116,7 +1116,7 @@ static uint32_t fpga_tx(struct solos_card *card)
32834 vcc = SKB_CB(oldskb)->vcc;
32835
32836 if (vcc) {
32837 - atomic_inc(&vcc->stats->tx);
32838 + atomic_inc_unchecked(&vcc->stats->tx);
32839 solos_pop(vcc, oldskb);
32840 } else {
32841 dev_kfree_skb_irq(oldskb);
32842 diff --git a/drivers/atm/suni.c b/drivers/atm/suni.c
32843 index 0215934..ce9f5b1 100644
32844 --- a/drivers/atm/suni.c
32845 +++ b/drivers/atm/suni.c
32846 @@ -49,8 +49,8 @@ static DEFINE_SPINLOCK(sunis_lock);
32847
32848
32849 #define ADD_LIMITED(s,v) \
32850 - atomic_add((v),&stats->s); \
32851 - if (atomic_read(&stats->s) < 0) atomic_set(&stats->s,INT_MAX);
32852 + atomic_add_unchecked((v),&stats->s); \
32853 + if (atomic_read_unchecked(&stats->s) < 0) atomic_set_unchecked(&stats->s,INT_MAX);
32854
32855
32856 static void suni_hz(unsigned long from_timer)
32857 diff --git a/drivers/atm/uPD98402.c b/drivers/atm/uPD98402.c
32858 index 5120a96..e2572bd 100644
32859 --- a/drivers/atm/uPD98402.c
32860 +++ b/drivers/atm/uPD98402.c
32861 @@ -42,7 +42,7 @@ static int fetch_stats(struct atm_dev *dev,struct sonet_stats __user *arg,int ze
32862 struct sonet_stats tmp;
32863 int error = 0;
32864
32865 - atomic_add(GET(HECCT),&PRIV(dev)->sonet_stats.uncorr_hcs);
32866 + atomic_add_unchecked(GET(HECCT),&PRIV(dev)->sonet_stats.uncorr_hcs);
32867 sonet_copy_stats(&PRIV(dev)->sonet_stats,&tmp);
32868 if (arg) error = copy_to_user(arg,&tmp,sizeof(tmp));
32869 if (zero && !error) {
32870 @@ -161,9 +161,9 @@ static int uPD98402_ioctl(struct atm_dev *dev,unsigned int cmd,void __user *arg)
32871
32872
32873 #define ADD_LIMITED(s,v) \
32874 - { atomic_add(GET(v),&PRIV(dev)->sonet_stats.s); \
32875 - if (atomic_read(&PRIV(dev)->sonet_stats.s) < 0) \
32876 - atomic_set(&PRIV(dev)->sonet_stats.s,INT_MAX); }
32877 + { atomic_add_unchecked(GET(v),&PRIV(dev)->sonet_stats.s); \
32878 + if (atomic_read_unchecked(&PRIV(dev)->sonet_stats.s) < 0) \
32879 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.s,INT_MAX); }
32880
32881
32882 static void stat_event(struct atm_dev *dev)
32883 @@ -194,7 +194,7 @@ static void uPD98402_int(struct atm_dev *dev)
32884 if (reason & uPD98402_INT_PFM) stat_event(dev);
32885 if (reason & uPD98402_INT_PCO) {
32886 (void) GET(PCOCR); /* clear interrupt cause */
32887 - atomic_add(GET(HECCT),
32888 + atomic_add_unchecked(GET(HECCT),
32889 &PRIV(dev)->sonet_stats.uncorr_hcs);
32890 }
32891 if ((reason & uPD98402_INT_RFO) &&
32892 @@ -222,9 +222,9 @@ static int uPD98402_start(struct atm_dev *dev)
32893 PUT(~(uPD98402_INT_PFM | uPD98402_INT_ALM | uPD98402_INT_RFO |
32894 uPD98402_INT_LOS),PIMR); /* enable them */
32895 (void) fetch_stats(dev,NULL,1); /* clear kernel counters */
32896 - atomic_set(&PRIV(dev)->sonet_stats.corr_hcs,-1);
32897 - atomic_set(&PRIV(dev)->sonet_stats.tx_cells,-1);
32898 - atomic_set(&PRIV(dev)->sonet_stats.rx_cells,-1);
32899 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.corr_hcs,-1);
32900 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.tx_cells,-1);
32901 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.rx_cells,-1);
32902 return 0;
32903 }
32904
32905 diff --git a/drivers/atm/zatm.c b/drivers/atm/zatm.c
32906 index 969c3c2..9b72956 100644
32907 --- a/drivers/atm/zatm.c
32908 +++ b/drivers/atm/zatm.c
32909 @@ -459,7 +459,7 @@ printk("dummy: 0x%08lx, 0x%08lx\n",dummy[0],dummy[1]);
32910 }
32911 if (!size) {
32912 dev_kfree_skb_irq(skb);
32913 - if (vcc) atomic_inc(&vcc->stats->rx_err);
32914 + if (vcc) atomic_inc_unchecked(&vcc->stats->rx_err);
32915 continue;
32916 }
32917 if (!atm_charge(vcc,skb->truesize)) {
32918 @@ -469,7 +469,7 @@ printk("dummy: 0x%08lx, 0x%08lx\n",dummy[0],dummy[1]);
32919 skb->len = size;
32920 ATM_SKB(skb)->vcc = vcc;
32921 vcc->push(vcc,skb);
32922 - atomic_inc(&vcc->stats->rx);
32923 + atomic_inc_unchecked(&vcc->stats->rx);
32924 }
32925 zout(pos & 0xffff,MTA(mbx));
32926 #if 0 /* probably a stupid idea */
32927 @@ -733,7 +733,7 @@ if (*ZATM_PRV_DSC(skb) != (uPD98401_TXPD_V | uPD98401_TXPD_DP |
32928 skb_queue_head(&zatm_vcc->backlog,skb);
32929 break;
32930 }
32931 - atomic_inc(&vcc->stats->tx);
32932 + atomic_inc_unchecked(&vcc->stats->tx);
32933 wake_up(&zatm_vcc->tx_wait);
32934 }
32935
32936 diff --git a/drivers/base/bus.c b/drivers/base/bus.c
32937 index 519865b..e540db3 100644
32938 --- a/drivers/base/bus.c
32939 +++ b/drivers/base/bus.c
32940 @@ -1163,7 +1163,7 @@ int subsys_interface_register(struct subsys_interface *sif)
32941 return -EINVAL;
32942
32943 mutex_lock(&subsys->p->mutex);
32944 - list_add_tail(&sif->node, &subsys->p->interfaces);
32945 + pax_list_add_tail((struct list_head *)&sif->node, &subsys->p->interfaces);
32946 if (sif->add_dev) {
32947 subsys_dev_iter_init(&iter, subsys, NULL, NULL);
32948 while ((dev = subsys_dev_iter_next(&iter)))
32949 @@ -1188,7 +1188,7 @@ void subsys_interface_unregister(struct subsys_interface *sif)
32950 subsys = sif->subsys;
32951
32952 mutex_lock(&subsys->p->mutex);
32953 - list_del_init(&sif->node);
32954 + pax_list_del_init((struct list_head *)&sif->node);
32955 if (sif->remove_dev) {
32956 subsys_dev_iter_init(&iter, subsys, NULL, NULL);
32957 while ((dev = subsys_dev_iter_next(&iter)))
32958 diff --git a/drivers/base/devtmpfs.c b/drivers/base/devtmpfs.c
32959 index 01fc5b0..917801f 100644
32960 --- a/drivers/base/devtmpfs.c
32961 +++ b/drivers/base/devtmpfs.c
32962 @@ -348,7 +348,7 @@ int devtmpfs_mount(const char *mntdir)
32963 if (!thread)
32964 return 0;
32965
32966 - err = sys_mount("devtmpfs", (char *)mntdir, "devtmpfs", MS_SILENT, NULL);
32967 + err = sys_mount((char __force_user *)"devtmpfs", (char __force_user *)mntdir, (char __force_user *)"devtmpfs", MS_SILENT, NULL);
32968 if (err)
32969 printk(KERN_INFO "devtmpfs: error mounting %i\n", err);
32970 else
32971 @@ -373,11 +373,11 @@ static int devtmpfsd(void *p)
32972 *err = sys_unshare(CLONE_NEWNS);
32973 if (*err)
32974 goto out;
32975 - *err = sys_mount("devtmpfs", "/", "devtmpfs", MS_SILENT, options);
32976 + *err = sys_mount((char __force_user *)"devtmpfs", (char __force_user *)"/", (char __force_user *)"devtmpfs", MS_SILENT, (char __force_user *)options);
32977 if (*err)
32978 goto out;
32979 - sys_chdir("/.."); /* will traverse into overmounted root */
32980 - sys_chroot(".");
32981 + sys_chdir((char __force_user *)"/.."); /* will traverse into overmounted root */
32982 + sys_chroot((char __force_user *)".");
32983 complete(&setup_done);
32984 while (1) {
32985 spin_lock(&req_lock);
32986 diff --git a/drivers/base/node.c b/drivers/base/node.c
32987 index fac124a..66bd4ab 100644
32988 --- a/drivers/base/node.c
32989 +++ b/drivers/base/node.c
32990 @@ -625,7 +625,7 @@ static ssize_t print_nodes_state(enum node_states state, char *buf)
32991 struct node_attr {
32992 struct device_attribute attr;
32993 enum node_states state;
32994 -};
32995 +} __do_const;
32996
32997 static ssize_t show_node_state(struct device *dev,
32998 struct device_attribute *attr, char *buf)
32999 diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
33000 index 9a6b05a..2fc8fb9 100644
33001 --- a/drivers/base/power/domain.c
33002 +++ b/drivers/base/power/domain.c
33003 @@ -1850,7 +1850,7 @@ int pm_genpd_attach_cpuidle(struct generic_pm_domain *genpd, int state)
33004 {
33005 struct cpuidle_driver *cpuidle_drv;
33006 struct gpd_cpu_data *cpu_data;
33007 - struct cpuidle_state *idle_state;
33008 + cpuidle_state_no_const *idle_state;
33009 int ret = 0;
33010
33011 if (IS_ERR_OR_NULL(genpd) || state < 0)
33012 @@ -1918,7 +1918,7 @@ int pm_genpd_name_attach_cpuidle(const char *name, int state)
33013 int pm_genpd_detach_cpuidle(struct generic_pm_domain *genpd)
33014 {
33015 struct gpd_cpu_data *cpu_data;
33016 - struct cpuidle_state *idle_state;
33017 + cpuidle_state_no_const *idle_state;
33018 int ret = 0;
33019
33020 if (IS_ERR_OR_NULL(genpd))
33021 diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c
33022 index 79715e7..df06b3b 100644
33023 --- a/drivers/base/power/wakeup.c
33024 +++ b/drivers/base/power/wakeup.c
33025 @@ -29,14 +29,14 @@ bool events_check_enabled __read_mostly;
33026 * They need to be modified together atomically, so it's better to use one
33027 * atomic variable to hold them both.
33028 */
33029 -static atomic_t combined_event_count = ATOMIC_INIT(0);
33030 +static atomic_unchecked_t combined_event_count = ATOMIC_INIT(0);
33031
33032 #define IN_PROGRESS_BITS (sizeof(int) * 4)
33033 #define MAX_IN_PROGRESS ((1 << IN_PROGRESS_BITS) - 1)
33034
33035 static void split_counters(unsigned int *cnt, unsigned int *inpr)
33036 {
33037 - unsigned int comb = atomic_read(&combined_event_count);
33038 + unsigned int comb = atomic_read_unchecked(&combined_event_count);
33039
33040 *cnt = (comb >> IN_PROGRESS_BITS);
33041 *inpr = comb & MAX_IN_PROGRESS;
33042 @@ -395,7 +395,7 @@ static void wakeup_source_activate(struct wakeup_source *ws)
33043 ws->start_prevent_time = ws->last_time;
33044
33045 /* Increment the counter of events in progress. */
33046 - cec = atomic_inc_return(&combined_event_count);
33047 + cec = atomic_inc_return_unchecked(&combined_event_count);
33048
33049 trace_wakeup_source_activate(ws->name, cec);
33050 }
33051 @@ -521,7 +521,7 @@ static void wakeup_source_deactivate(struct wakeup_source *ws)
33052 * Increment the counter of registered wakeup events and decrement the
33053 * couter of wakeup events in progress simultaneously.
33054 */
33055 - cec = atomic_add_return(MAX_IN_PROGRESS, &combined_event_count);
33056 + cec = atomic_add_return_unchecked(MAX_IN_PROGRESS, &combined_event_count);
33057 trace_wakeup_source_deactivate(ws->name, cec);
33058
33059 split_counters(&cnt, &inpr);
33060 diff --git a/drivers/base/syscore.c b/drivers/base/syscore.c
33061 index e8d11b6..7b1b36f 100644
33062 --- a/drivers/base/syscore.c
33063 +++ b/drivers/base/syscore.c
33064 @@ -21,7 +21,7 @@ static DEFINE_MUTEX(syscore_ops_lock);
33065 void register_syscore_ops(struct syscore_ops *ops)
33066 {
33067 mutex_lock(&syscore_ops_lock);
33068 - list_add_tail(&ops->node, &syscore_ops_list);
33069 + pax_list_add_tail((struct list_head *)&ops->node, &syscore_ops_list);
33070 mutex_unlock(&syscore_ops_lock);
33071 }
33072 EXPORT_SYMBOL_GPL(register_syscore_ops);
33073 @@ -33,7 +33,7 @@ EXPORT_SYMBOL_GPL(register_syscore_ops);
33074 void unregister_syscore_ops(struct syscore_ops *ops)
33075 {
33076 mutex_lock(&syscore_ops_lock);
33077 - list_del(&ops->node);
33078 + pax_list_del((struct list_head *)&ops->node);
33079 mutex_unlock(&syscore_ops_lock);
33080 }
33081 EXPORT_SYMBOL_GPL(unregister_syscore_ops);
33082 diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
33083 index 1c1b8e5..b7fc681 100644
33084 --- a/drivers/block/cciss.c
33085 +++ b/drivers/block/cciss.c
33086 @@ -1196,6 +1196,8 @@ static int cciss_ioctl32_passthru(struct block_device *bdev, fmode_t mode,
33087 int err;
33088 u32 cp;
33089
33090 + memset(&arg64, 0, sizeof(arg64));
33091 +
33092 err = 0;
33093 err |=
33094 copy_from_user(&arg64.LUN_info, &arg32->LUN_info,
33095 @@ -3005,7 +3007,7 @@ static void start_io(ctlr_info_t *h)
33096 while (!list_empty(&h->reqQ)) {
33097 c = list_entry(h->reqQ.next, CommandList_struct, list);
33098 /* can't do anything if fifo is full */
33099 - if ((h->access.fifo_full(h))) {
33100 + if ((h->access->fifo_full(h))) {
33101 dev_warn(&h->pdev->dev, "fifo full\n");
33102 break;
33103 }
33104 @@ -3015,7 +3017,7 @@ static void start_io(ctlr_info_t *h)
33105 h->Qdepth--;
33106
33107 /* Tell the controller execute command */
33108 - h->access.submit_command(h, c);
33109 + h->access->submit_command(h, c);
33110
33111 /* Put job onto the completed Q */
33112 addQ(&h->cmpQ, c);
33113 @@ -3441,17 +3443,17 @@ startio:
33114
33115 static inline unsigned long get_next_completion(ctlr_info_t *h)
33116 {
33117 - return h->access.command_completed(h);
33118 + return h->access->command_completed(h);
33119 }
33120
33121 static inline int interrupt_pending(ctlr_info_t *h)
33122 {
33123 - return h->access.intr_pending(h);
33124 + return h->access->intr_pending(h);
33125 }
33126
33127 static inline long interrupt_not_for_us(ctlr_info_t *h)
33128 {
33129 - return ((h->access.intr_pending(h) == 0) ||
33130 + return ((h->access->intr_pending(h) == 0) ||
33131 (h->interrupts_enabled == 0));
33132 }
33133
33134 @@ -3484,7 +3486,7 @@ static inline u32 next_command(ctlr_info_t *h)
33135 u32 a;
33136
33137 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant)))
33138 - return h->access.command_completed(h);
33139 + return h->access->command_completed(h);
33140
33141 if ((*(h->reply_pool_head) & 1) == (h->reply_pool_wraparound)) {
33142 a = *(h->reply_pool_head); /* Next cmd in ring buffer */
33143 @@ -4041,7 +4043,7 @@ static void cciss_put_controller_into_performant_mode(ctlr_info_t *h)
33144 trans_support & CFGTBL_Trans_use_short_tags);
33145
33146 /* Change the access methods to the performant access methods */
33147 - h->access = SA5_performant_access;
33148 + h->access = &SA5_performant_access;
33149 h->transMethod = CFGTBL_Trans_Performant;
33150
33151 return;
33152 @@ -4310,7 +4312,7 @@ static int cciss_pci_init(ctlr_info_t *h)
33153 if (prod_index < 0)
33154 return -ENODEV;
33155 h->product_name = products[prod_index].product_name;
33156 - h->access = *(products[prod_index].access);
33157 + h->access = products[prod_index].access;
33158
33159 if (cciss_board_disabled(h)) {
33160 dev_warn(&h->pdev->dev, "controller appears to be disabled\n");
33161 @@ -5032,7 +5034,7 @@ reinit_after_soft_reset:
33162 }
33163
33164 /* make sure the board interrupts are off */
33165 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
33166 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
33167 rc = cciss_request_irq(h, do_cciss_msix_intr, do_cciss_intx);
33168 if (rc)
33169 goto clean2;
33170 @@ -5082,7 +5084,7 @@ reinit_after_soft_reset:
33171 * fake ones to scoop up any residual completions.
33172 */
33173 spin_lock_irqsave(&h->lock, flags);
33174 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
33175 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
33176 spin_unlock_irqrestore(&h->lock, flags);
33177 free_irq(h->intr[h->intr_mode], h);
33178 rc = cciss_request_irq(h, cciss_msix_discard_completions,
33179 @@ -5102,9 +5104,9 @@ reinit_after_soft_reset:
33180 dev_info(&h->pdev->dev, "Board READY.\n");
33181 dev_info(&h->pdev->dev,
33182 "Waiting for stale completions to drain.\n");
33183 - h->access.set_intr_mask(h, CCISS_INTR_ON);
33184 + h->access->set_intr_mask(h, CCISS_INTR_ON);
33185 msleep(10000);
33186 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
33187 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
33188
33189 rc = controller_reset_failed(h->cfgtable);
33190 if (rc)
33191 @@ -5127,7 +5129,7 @@ reinit_after_soft_reset:
33192 cciss_scsi_setup(h);
33193
33194 /* Turn the interrupts on so we can service requests */
33195 - h->access.set_intr_mask(h, CCISS_INTR_ON);
33196 + h->access->set_intr_mask(h, CCISS_INTR_ON);
33197
33198 /* Get the firmware version */
33199 inq_buff = kzalloc(sizeof(InquiryData_struct), GFP_KERNEL);
33200 @@ -5199,7 +5201,7 @@ static void cciss_shutdown(struct pci_dev *pdev)
33201 kfree(flush_buf);
33202 if (return_code != IO_OK)
33203 dev_warn(&h->pdev->dev, "Error flushing cache\n");
33204 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
33205 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
33206 free_irq(h->intr[h->intr_mode], h);
33207 }
33208
33209 diff --git a/drivers/block/cciss.h b/drivers/block/cciss.h
33210 index 7fda30e..eb5dfe0 100644
33211 --- a/drivers/block/cciss.h
33212 +++ b/drivers/block/cciss.h
33213 @@ -101,7 +101,7 @@ struct ctlr_info
33214 /* information about each logical volume */
33215 drive_info_struct *drv[CISS_MAX_LUN];
33216
33217 - struct access_method access;
33218 + struct access_method *access;
33219
33220 /* queue and queue Info */
33221 struct list_head reqQ;
33222 diff --git a/drivers/block/cpqarray.c b/drivers/block/cpqarray.c
33223 index 3f08713..56a586a 100644
33224 --- a/drivers/block/cpqarray.c
33225 +++ b/drivers/block/cpqarray.c
33226 @@ -404,7 +404,7 @@ static int cpqarray_register_ctlr(int i, struct pci_dev *pdev)
33227 if (register_blkdev(COMPAQ_SMART2_MAJOR+i, hba[i]->devname)) {
33228 goto Enomem4;
33229 }
33230 - hba[i]->access.set_intr_mask(hba[i], 0);
33231 + hba[i]->access->set_intr_mask(hba[i], 0);
33232 if (request_irq(hba[i]->intr, do_ida_intr,
33233 IRQF_DISABLED|IRQF_SHARED, hba[i]->devname, hba[i]))
33234 {
33235 @@ -459,7 +459,7 @@ static int cpqarray_register_ctlr(int i, struct pci_dev *pdev)
33236 add_timer(&hba[i]->timer);
33237
33238 /* Enable IRQ now that spinlock and rate limit timer are set up */
33239 - hba[i]->access.set_intr_mask(hba[i], FIFO_NOT_EMPTY);
33240 + hba[i]->access->set_intr_mask(hba[i], FIFO_NOT_EMPTY);
33241
33242 for(j=0; j<NWD; j++) {
33243 struct gendisk *disk = ida_gendisk[i][j];
33244 @@ -694,7 +694,7 @@ DBGINFO(
33245 for(i=0; i<NR_PRODUCTS; i++) {
33246 if (board_id == products[i].board_id) {
33247 c->product_name = products[i].product_name;
33248 - c->access = *(products[i].access);
33249 + c->access = products[i].access;
33250 break;
33251 }
33252 }
33253 @@ -792,7 +792,7 @@ static int cpqarray_eisa_detect(void)
33254 hba[ctlr]->intr = intr;
33255 sprintf(hba[ctlr]->devname, "ida%d", nr_ctlr);
33256 hba[ctlr]->product_name = products[j].product_name;
33257 - hba[ctlr]->access = *(products[j].access);
33258 + hba[ctlr]->access = products[j].access;
33259 hba[ctlr]->ctlr = ctlr;
33260 hba[ctlr]->board_id = board_id;
33261 hba[ctlr]->pci_dev = NULL; /* not PCI */
33262 @@ -980,7 +980,7 @@ static void start_io(ctlr_info_t *h)
33263
33264 while((c = h->reqQ) != NULL) {
33265 /* Can't do anything if we're busy */
33266 - if (h->access.fifo_full(h) == 0)
33267 + if (h->access->fifo_full(h) == 0)
33268 return;
33269
33270 /* Get the first entry from the request Q */
33271 @@ -988,7 +988,7 @@ static void start_io(ctlr_info_t *h)
33272 h->Qdepth--;
33273
33274 /* Tell the controller to do our bidding */
33275 - h->access.submit_command(h, c);
33276 + h->access->submit_command(h, c);
33277
33278 /* Get onto the completion Q */
33279 addQ(&h->cmpQ, c);
33280 @@ -1050,7 +1050,7 @@ static irqreturn_t do_ida_intr(int irq, void *dev_id)
33281 unsigned long flags;
33282 __u32 a,a1;
33283
33284 - istat = h->access.intr_pending(h);
33285 + istat = h->access->intr_pending(h);
33286 /* Is this interrupt for us? */
33287 if (istat == 0)
33288 return IRQ_NONE;
33289 @@ -1061,7 +1061,7 @@ static irqreturn_t do_ida_intr(int irq, void *dev_id)
33290 */
33291 spin_lock_irqsave(IDA_LOCK(h->ctlr), flags);
33292 if (istat & FIFO_NOT_EMPTY) {
33293 - while((a = h->access.command_completed(h))) {
33294 + while((a = h->access->command_completed(h))) {
33295 a1 = a; a &= ~3;
33296 if ((c = h->cmpQ) == NULL)
33297 {
33298 @@ -1449,11 +1449,11 @@ static int sendcmd(
33299 /*
33300 * Disable interrupt
33301 */
33302 - info_p->access.set_intr_mask(info_p, 0);
33303 + info_p->access->set_intr_mask(info_p, 0);
33304 /* Make sure there is room in the command FIFO */
33305 /* Actually it should be completely empty at this time. */
33306 for (i = 200000; i > 0; i--) {
33307 - temp = info_p->access.fifo_full(info_p);
33308 + temp = info_p->access->fifo_full(info_p);
33309 if (temp != 0) {
33310 break;
33311 }
33312 @@ -1466,7 +1466,7 @@ DBG(
33313 /*
33314 * Send the cmd
33315 */
33316 - info_p->access.submit_command(info_p, c);
33317 + info_p->access->submit_command(info_p, c);
33318 complete = pollcomplete(ctlr);
33319
33320 pci_unmap_single(info_p->pci_dev, (dma_addr_t) c->req.sg[0].addr,
33321 @@ -1549,9 +1549,9 @@ static int revalidate_allvol(ctlr_info_t *host)
33322 * we check the new geometry. Then turn interrupts back on when
33323 * we're done.
33324 */
33325 - host->access.set_intr_mask(host, 0);
33326 + host->access->set_intr_mask(host, 0);
33327 getgeometry(ctlr);
33328 - host->access.set_intr_mask(host, FIFO_NOT_EMPTY);
33329 + host->access->set_intr_mask(host, FIFO_NOT_EMPTY);
33330
33331 for(i=0; i<NWD; i++) {
33332 struct gendisk *disk = ida_gendisk[ctlr][i];
33333 @@ -1591,7 +1591,7 @@ static int pollcomplete(int ctlr)
33334 /* Wait (up to 2 seconds) for a command to complete */
33335
33336 for (i = 200000; i > 0; i--) {
33337 - done = hba[ctlr]->access.command_completed(hba[ctlr]);
33338 + done = hba[ctlr]->access->command_completed(hba[ctlr]);
33339 if (done == 0) {
33340 udelay(10); /* a short fixed delay */
33341 } else
33342 diff --git a/drivers/block/cpqarray.h b/drivers/block/cpqarray.h
33343 index be73e9d..7fbf140 100644
33344 --- a/drivers/block/cpqarray.h
33345 +++ b/drivers/block/cpqarray.h
33346 @@ -99,7 +99,7 @@ struct ctlr_info {
33347 drv_info_t drv[NWD];
33348 struct proc_dir_entry *proc;
33349
33350 - struct access_method access;
33351 + struct access_method *access;
33352
33353 cmdlist_t *reqQ;
33354 cmdlist_t *cmpQ;
33355 diff --git a/drivers/block/drbd/drbd_int.h b/drivers/block/drbd/drbd_int.h
33356 index 6b51afa..17e1191 100644
33357 --- a/drivers/block/drbd/drbd_int.h
33358 +++ b/drivers/block/drbd/drbd_int.h
33359 @@ -582,7 +582,7 @@ struct drbd_epoch {
33360 struct drbd_tconn *tconn;
33361 struct list_head list;
33362 unsigned int barrier_nr;
33363 - atomic_t epoch_size; /* increased on every request added. */
33364 + atomic_unchecked_t epoch_size; /* increased on every request added. */
33365 atomic_t active; /* increased on every req. added, and dec on every finished. */
33366 unsigned long flags;
33367 };
33368 @@ -1011,7 +1011,7 @@ struct drbd_conf {
33369 int al_tr_cycle;
33370 int al_tr_pos; /* position of the next transaction in the journal */
33371 wait_queue_head_t seq_wait;
33372 - atomic_t packet_seq;
33373 + atomic_unchecked_t packet_seq;
33374 unsigned int peer_seq;
33375 spinlock_t peer_seq_lock;
33376 unsigned int minor;
33377 @@ -1527,7 +1527,7 @@ static inline int drbd_setsockopt(struct socket *sock, int level, int optname,
33378 char __user *uoptval;
33379 int err;
33380
33381 - uoptval = (char __user __force *)optval;
33382 + uoptval = (char __force_user *)optval;
33383
33384 set_fs(KERNEL_DS);
33385 if (level == SOL_SOCKET)
33386 diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c
33387 index 54d03d4..332f311 100644
33388 --- a/drivers/block/drbd/drbd_main.c
33389 +++ b/drivers/block/drbd/drbd_main.c
33390 @@ -1317,7 +1317,7 @@ static int _drbd_send_ack(struct drbd_conf *mdev, enum drbd_packet cmd,
33391 p->sector = sector;
33392 p->block_id = block_id;
33393 p->blksize = blksize;
33394 - p->seq_num = cpu_to_be32(atomic_inc_return(&mdev->packet_seq));
33395 + p->seq_num = cpu_to_be32(atomic_inc_return_unchecked(&mdev->packet_seq));
33396 return drbd_send_command(mdev, sock, cmd, sizeof(*p), NULL, 0);
33397 }
33398
33399 @@ -1619,7 +1619,7 @@ int drbd_send_dblock(struct drbd_conf *mdev, struct drbd_request *req)
33400 return -EIO;
33401 p->sector = cpu_to_be64(req->i.sector);
33402 p->block_id = (unsigned long)req;
33403 - p->seq_num = cpu_to_be32(atomic_inc_return(&mdev->packet_seq));
33404 + p->seq_num = cpu_to_be32(atomic_inc_return_unchecked(&mdev->packet_seq));
33405 dp_flags = bio_flags_to_wire(mdev, req->master_bio->bi_rw);
33406 if (mdev->state.conn >= C_SYNC_SOURCE &&
33407 mdev->state.conn <= C_PAUSED_SYNC_T)
33408 @@ -2574,8 +2574,8 @@ void conn_destroy(struct kref *kref)
33409 {
33410 struct drbd_tconn *tconn = container_of(kref, struct drbd_tconn, kref);
33411
33412 - if (atomic_read(&tconn->current_epoch->epoch_size) != 0)
33413 - conn_err(tconn, "epoch_size:%d\n", atomic_read(&tconn->current_epoch->epoch_size));
33414 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size) != 0)
33415 + conn_err(tconn, "epoch_size:%d\n", atomic_read_unchecked(&tconn->current_epoch->epoch_size));
33416 kfree(tconn->current_epoch);
33417
33418 idr_destroy(&tconn->volumes);
33419 diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c
33420 index 2f5fffd..b22a1ae 100644
33421 --- a/drivers/block/drbd/drbd_receiver.c
33422 +++ b/drivers/block/drbd/drbd_receiver.c
33423 @@ -833,7 +833,7 @@ int drbd_connected(struct drbd_conf *mdev)
33424 {
33425 int err;
33426
33427 - atomic_set(&mdev->packet_seq, 0);
33428 + atomic_set_unchecked(&mdev->packet_seq, 0);
33429 mdev->peer_seq = 0;
33430
33431 mdev->state_mutex = mdev->tconn->agreed_pro_version < 100 ?
33432 @@ -1191,7 +1191,7 @@ static enum finish_epoch drbd_may_finish_epoch(struct drbd_tconn *tconn,
33433 do {
33434 next_epoch = NULL;
33435
33436 - epoch_size = atomic_read(&epoch->epoch_size);
33437 + epoch_size = atomic_read_unchecked(&epoch->epoch_size);
33438
33439 switch (ev & ~EV_CLEANUP) {
33440 case EV_PUT:
33441 @@ -1231,7 +1231,7 @@ static enum finish_epoch drbd_may_finish_epoch(struct drbd_tconn *tconn,
33442 rv = FE_DESTROYED;
33443 } else {
33444 epoch->flags = 0;
33445 - atomic_set(&epoch->epoch_size, 0);
33446 + atomic_set_unchecked(&epoch->epoch_size, 0);
33447 /* atomic_set(&epoch->active, 0); is already zero */
33448 if (rv == FE_STILL_LIVE)
33449 rv = FE_RECYCLED;
33450 @@ -1449,7 +1449,7 @@ static int receive_Barrier(struct drbd_tconn *tconn, struct packet_info *pi)
33451 conn_wait_active_ee_empty(tconn);
33452 drbd_flush(tconn);
33453
33454 - if (atomic_read(&tconn->current_epoch->epoch_size)) {
33455 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size)) {
33456 epoch = kmalloc(sizeof(struct drbd_epoch), GFP_NOIO);
33457 if (epoch)
33458 break;
33459 @@ -1462,11 +1462,11 @@ static int receive_Barrier(struct drbd_tconn *tconn, struct packet_info *pi)
33460 }
33461
33462 epoch->flags = 0;
33463 - atomic_set(&epoch->epoch_size, 0);
33464 + atomic_set_unchecked(&epoch->epoch_size, 0);
33465 atomic_set(&epoch->active, 0);
33466
33467 spin_lock(&tconn->epoch_lock);
33468 - if (atomic_read(&tconn->current_epoch->epoch_size)) {
33469 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size)) {
33470 list_add(&epoch->list, &tconn->current_epoch->list);
33471 tconn->current_epoch = epoch;
33472 tconn->epochs++;
33473 @@ -2170,7 +2170,7 @@ static int receive_Data(struct drbd_tconn *tconn, struct packet_info *pi)
33474
33475 err = wait_for_and_update_peer_seq(mdev, peer_seq);
33476 drbd_send_ack_dp(mdev, P_NEG_ACK, p, pi->size);
33477 - atomic_inc(&tconn->current_epoch->epoch_size);
33478 + atomic_inc_unchecked(&tconn->current_epoch->epoch_size);
33479 err2 = drbd_drain_block(mdev, pi->size);
33480 if (!err)
33481 err = err2;
33482 @@ -2204,7 +2204,7 @@ static int receive_Data(struct drbd_tconn *tconn, struct packet_info *pi)
33483
33484 spin_lock(&tconn->epoch_lock);
33485 peer_req->epoch = tconn->current_epoch;
33486 - atomic_inc(&peer_req->epoch->epoch_size);
33487 + atomic_inc_unchecked(&peer_req->epoch->epoch_size);
33488 atomic_inc(&peer_req->epoch->active);
33489 spin_unlock(&tconn->epoch_lock);
33490
33491 @@ -4345,7 +4345,7 @@ struct data_cmd {
33492 int expect_payload;
33493 size_t pkt_size;
33494 int (*fn)(struct drbd_tconn *, struct packet_info *);
33495 -};
33496 +} __do_const;
33497
33498 static struct data_cmd drbd_cmd_handler[] = {
33499 [P_DATA] = { 1, sizeof(struct p_data), receive_Data },
33500 @@ -4465,7 +4465,7 @@ static void conn_disconnect(struct drbd_tconn *tconn)
33501 if (!list_empty(&tconn->current_epoch->list))
33502 conn_err(tconn, "ASSERTION FAILED: tconn->current_epoch->list not empty\n");
33503 /* ok, no more ee's on the fly, it is safe to reset the epoch_size */
33504 - atomic_set(&tconn->current_epoch->epoch_size, 0);
33505 + atomic_set_unchecked(&tconn->current_epoch->epoch_size, 0);
33506 tconn->send.seen_any_write_yet = false;
33507
33508 conn_info(tconn, "Connection closed\n");
33509 @@ -5221,7 +5221,7 @@ static int tconn_finish_peer_reqs(struct drbd_tconn *tconn)
33510 struct asender_cmd {
33511 size_t pkt_size;
33512 int (*fn)(struct drbd_tconn *tconn, struct packet_info *);
33513 -};
33514 +} __do_const;
33515
33516 static struct asender_cmd asender_tbl[] = {
33517 [P_PING] = { 0, got_Ping },
33518 diff --git a/drivers/block/loop.c b/drivers/block/loop.c
33519 index dfe7583..83768bb 100644
33520 --- a/drivers/block/loop.c
33521 +++ b/drivers/block/loop.c
33522 @@ -231,7 +231,7 @@ static int __do_lo_send_write(struct file *file,
33523 mm_segment_t old_fs = get_fs();
33524
33525 set_fs(get_ds());
33526 - bw = file->f_op->write(file, buf, len, &pos);
33527 + bw = file->f_op->write(file, (const char __force_user *)buf, len, &pos);
33528 set_fs(old_fs);
33529 if (likely(bw == len))
33530 return 0;
33531 diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
33532 index 2e7de7a..ed86dc0 100644
33533 --- a/drivers/block/pktcdvd.c
33534 +++ b/drivers/block/pktcdvd.c
33535 @@ -83,7 +83,7 @@
33536
33537 #define MAX_SPEED 0xffff
33538
33539 -#define ZONE(sector, pd) (((sector) + (pd)->offset) & ~((pd)->settings.size - 1))
33540 +#define ZONE(sector, pd) (((sector) + (pd)->offset) & ~((pd)->settings.size - 1UL))
33541
33542 static DEFINE_MUTEX(pktcdvd_mutex);
33543 static struct pktcdvd_device *pkt_devs[MAX_WRITERS];
33544 diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c
33545 index d620b44..587561e 100644
33546 --- a/drivers/cdrom/cdrom.c
33547 +++ b/drivers/cdrom/cdrom.c
33548 @@ -416,7 +416,6 @@ int register_cdrom(struct cdrom_device_info *cdi)
33549 ENSURE(reset, CDC_RESET);
33550 ENSURE(generic_packet, CDC_GENERIC_PACKET);
33551 cdi->mc_flags = 0;
33552 - cdo->n_minors = 0;
33553 cdi->options = CDO_USE_FFLAGS;
33554
33555 if (autoclose==1 && CDROM_CAN(CDC_CLOSE_TRAY))
33556 @@ -436,8 +435,11 @@ int register_cdrom(struct cdrom_device_info *cdi)
33557 else
33558 cdi->cdda_method = CDDA_OLD;
33559
33560 - if (!cdo->generic_packet)
33561 - cdo->generic_packet = cdrom_dummy_generic_packet;
33562 + if (!cdo->generic_packet) {
33563 + pax_open_kernel();
33564 + *(void **)&cdo->generic_packet = cdrom_dummy_generic_packet;
33565 + pax_close_kernel();
33566 + }
33567
33568 cdinfo(CD_REG_UNREG, "drive \"/dev/%s\" registered\n", cdi->name);
33569 mutex_lock(&cdrom_mutex);
33570 @@ -458,7 +460,6 @@ void unregister_cdrom(struct cdrom_device_info *cdi)
33571 if (cdi->exit)
33572 cdi->exit(cdi);
33573
33574 - cdi->ops->n_minors--;
33575 cdinfo(CD_REG_UNREG, "drive \"/dev/%s\" unregistered\n", cdi->name);
33576 }
33577
33578 diff --git a/drivers/cdrom/gdrom.c b/drivers/cdrom/gdrom.c
33579 index d59cdcb..11afddf 100644
33580 --- a/drivers/cdrom/gdrom.c
33581 +++ b/drivers/cdrom/gdrom.c
33582 @@ -491,7 +491,6 @@ static struct cdrom_device_ops gdrom_ops = {
33583 .audio_ioctl = gdrom_audio_ioctl,
33584 .capability = CDC_MULTI_SESSION | CDC_MEDIA_CHANGED |
33585 CDC_RESET | CDC_DRIVE_STATUS | CDC_CD_R,
33586 - .n_minors = 1,
33587 };
33588
33589 static int gdrom_bdops_open(struct block_device *bdev, fmode_t mode)
33590 diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
33591 index 3bb6fa3..34013fb 100644
33592 --- a/drivers/char/Kconfig
33593 +++ b/drivers/char/Kconfig
33594 @@ -8,7 +8,8 @@ source "drivers/tty/Kconfig"
33595
33596 config DEVKMEM
33597 bool "/dev/kmem virtual device support"
33598 - default y
33599 + default n
33600 + depends on !GRKERNSEC_KMEM
33601 help
33602 Say Y here if you want to support the /dev/kmem device. The
33603 /dev/kmem device is rarely used, but can be used for certain
33604 @@ -582,6 +583,7 @@ config DEVPORT
33605 bool
33606 depends on !M68K
33607 depends on ISA || PCI
33608 + depends on !GRKERNSEC_KMEM
33609 default y
33610
33611 source "drivers/s390/char/Kconfig"
33612 diff --git a/drivers/char/agp/compat_ioctl.c b/drivers/char/agp/compat_ioctl.c
33613 index a48e05b..6bac831 100644
33614 --- a/drivers/char/agp/compat_ioctl.c
33615 +++ b/drivers/char/agp/compat_ioctl.c
33616 @@ -108,7 +108,7 @@ static int compat_agpioc_reserve_wrap(struct agp_file_private *priv, void __user
33617 return -ENOMEM;
33618 }
33619
33620 - if (copy_from_user(usegment, (void __user *) ureserve.seg_list,
33621 + if (copy_from_user(usegment, (void __force_user *) ureserve.seg_list,
33622 sizeof(*usegment) * ureserve.seg_count)) {
33623 kfree(usegment);
33624 kfree(ksegment);
33625 diff --git a/drivers/char/agp/frontend.c b/drivers/char/agp/frontend.c
33626 index 2e04433..771f2cc 100644
33627 --- a/drivers/char/agp/frontend.c
33628 +++ b/drivers/char/agp/frontend.c
33629 @@ -817,7 +817,7 @@ static int agpioc_reserve_wrap(struct agp_file_private *priv, void __user *arg)
33630 if (copy_from_user(&reserve, arg, sizeof(struct agp_region)))
33631 return -EFAULT;
33632
33633 - if ((unsigned) reserve.seg_count >= ~0U/sizeof(struct agp_segment))
33634 + if ((unsigned) reserve.seg_count >= ~0U/sizeof(struct agp_segment_priv))
33635 return -EFAULT;
33636
33637 client = agp_find_client_by_pid(reserve.pid);
33638 @@ -847,7 +847,7 @@ static int agpioc_reserve_wrap(struct agp_file_private *priv, void __user *arg)
33639 if (segment == NULL)
33640 return -ENOMEM;
33641
33642 - if (copy_from_user(segment, (void __user *) reserve.seg_list,
33643 + if (copy_from_user(segment, (void __force_user *) reserve.seg_list,
33644 sizeof(struct agp_segment) * reserve.seg_count)) {
33645 kfree(segment);
33646 return -EFAULT;
33647 diff --git a/drivers/char/genrtc.c b/drivers/char/genrtc.c
33648 index 21cb980..f15107c 100644
33649 --- a/drivers/char/genrtc.c
33650 +++ b/drivers/char/genrtc.c
33651 @@ -272,6 +272,7 @@ static int gen_rtc_ioctl(struct file *file,
33652 switch (cmd) {
33653
33654 case RTC_PLL_GET:
33655 + memset(&pll, 0, sizeof(pll));
33656 if (get_rtc_pll(&pll))
33657 return -EINVAL;
33658 else
33659 diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c
33660 index d784650..e8bfd69 100644
33661 --- a/drivers/char/hpet.c
33662 +++ b/drivers/char/hpet.c
33663 @@ -559,7 +559,7 @@ static inline unsigned long hpet_time_div(struct hpets *hpets,
33664 }
33665
33666 static int
33667 -hpet_ioctl_common(struct hpet_dev *devp, int cmd, unsigned long arg,
33668 +hpet_ioctl_common(struct hpet_dev *devp, unsigned int cmd, unsigned long arg,
33669 struct hpet_info *info)
33670 {
33671 struct hpet_timer __iomem *timer;
33672 diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
33673 index 053201b0..8335cce 100644
33674 --- a/drivers/char/ipmi/ipmi_msghandler.c
33675 +++ b/drivers/char/ipmi/ipmi_msghandler.c
33676 @@ -420,7 +420,7 @@ struct ipmi_smi {
33677 struct proc_dir_entry *proc_dir;
33678 char proc_dir_name[10];
33679
33680 - atomic_t stats[IPMI_NUM_STATS];
33681 + atomic_unchecked_t stats[IPMI_NUM_STATS];
33682
33683 /*
33684 * run_to_completion duplicate of smb_info, smi_info
33685 @@ -453,9 +453,9 @@ static DEFINE_MUTEX(smi_watchers_mutex);
33686
33687
33688 #define ipmi_inc_stat(intf, stat) \
33689 - atomic_inc(&(intf)->stats[IPMI_STAT_ ## stat])
33690 + atomic_inc_unchecked(&(intf)->stats[IPMI_STAT_ ## stat])
33691 #define ipmi_get_stat(intf, stat) \
33692 - ((unsigned int) atomic_read(&(intf)->stats[IPMI_STAT_ ## stat]))
33693 + ((unsigned int) atomic_read_unchecked(&(intf)->stats[IPMI_STAT_ ## stat]))
33694
33695 static int is_lan_addr(struct ipmi_addr *addr)
33696 {
33697 @@ -2884,7 +2884,7 @@ int ipmi_register_smi(struct ipmi_smi_handlers *handlers,
33698 INIT_LIST_HEAD(&intf->cmd_rcvrs);
33699 init_waitqueue_head(&intf->waitq);
33700 for (i = 0; i < IPMI_NUM_STATS; i++)
33701 - atomic_set(&intf->stats[i], 0);
33702 + atomic_set_unchecked(&intf->stats[i], 0);
33703
33704 intf->proc_dir = NULL;
33705
33706 diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
33707 index 0ac9b45..6179fb5 100644
33708 --- a/drivers/char/ipmi/ipmi_si_intf.c
33709 +++ b/drivers/char/ipmi/ipmi_si_intf.c
33710 @@ -275,7 +275,7 @@ struct smi_info {
33711 unsigned char slave_addr;
33712
33713 /* Counters and things for the proc filesystem. */
33714 - atomic_t stats[SI_NUM_STATS];
33715 + atomic_unchecked_t stats[SI_NUM_STATS];
33716
33717 struct task_struct *thread;
33718
33719 @@ -284,9 +284,9 @@ struct smi_info {
33720 };
33721
33722 #define smi_inc_stat(smi, stat) \
33723 - atomic_inc(&(smi)->stats[SI_STAT_ ## stat])
33724 + atomic_inc_unchecked(&(smi)->stats[SI_STAT_ ## stat])
33725 #define smi_get_stat(smi, stat) \
33726 - ((unsigned int) atomic_read(&(smi)->stats[SI_STAT_ ## stat]))
33727 + ((unsigned int) atomic_read_unchecked(&(smi)->stats[SI_STAT_ ## stat]))
33728
33729 #define SI_MAX_PARMS 4
33730
33731 @@ -3254,7 +3254,7 @@ static int try_smi_init(struct smi_info *new_smi)
33732 atomic_set(&new_smi->req_events, 0);
33733 new_smi->run_to_completion = 0;
33734 for (i = 0; i < SI_NUM_STATS; i++)
33735 - atomic_set(&new_smi->stats[i], 0);
33736 + atomic_set_unchecked(&new_smi->stats[i], 0);
33737
33738 new_smi->interrupt_disabled = 1;
33739 atomic_set(&new_smi->stop_operation, 0);
33740 diff --git a/drivers/char/mem.c b/drivers/char/mem.c
33741 index 2c644af..d4d7f17 100644
33742 --- a/drivers/char/mem.c
33743 +++ b/drivers/char/mem.c
33744 @@ -18,6 +18,7 @@
33745 #include <linux/raw.h>
33746 #include <linux/tty.h>
33747 #include <linux/capability.h>
33748 +#include <linux/security.h>
33749 #include <linux/ptrace.h>
33750 #include <linux/device.h>
33751 #include <linux/highmem.h>
33752 @@ -37,6 +38,10 @@
33753
33754 #define DEVPORT_MINOR 4
33755
33756 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
33757 +extern const struct file_operations grsec_fops;
33758 +#endif
33759 +
33760 static inline unsigned long size_inside_page(unsigned long start,
33761 unsigned long size)
33762 {
33763 @@ -68,9 +73,13 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
33764
33765 while (cursor < to) {
33766 if (!devmem_is_allowed(pfn)) {
33767 +#ifdef CONFIG_GRKERNSEC_KMEM
33768 + gr_handle_mem_readwrite(from, to);
33769 +#else
33770 printk(KERN_INFO
33771 "Program %s tried to access /dev/mem between %Lx->%Lx.\n",
33772 current->comm, from, to);
33773 +#endif
33774 return 0;
33775 }
33776 cursor += PAGE_SIZE;
33777 @@ -78,6 +87,11 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
33778 }
33779 return 1;
33780 }
33781 +#elif defined(CONFIG_GRKERNSEC_KMEM)
33782 +static inline int range_is_allowed(unsigned long pfn, unsigned long size)
33783 +{
33784 + return 0;
33785 +}
33786 #else
33787 static inline int range_is_allowed(unsigned long pfn, unsigned long size)
33788 {
33789 @@ -120,6 +134,7 @@ static ssize_t read_mem(struct file *file, char __user *buf,
33790
33791 while (count > 0) {
33792 unsigned long remaining;
33793 + char *temp;
33794
33795 sz = size_inside_page(p, count);
33796
33797 @@ -135,7 +150,23 @@ static ssize_t read_mem(struct file *file, char __user *buf,
33798 if (!ptr)
33799 return -EFAULT;
33800
33801 - remaining = copy_to_user(buf, ptr, sz);
33802 +#ifdef CONFIG_PAX_USERCOPY
33803 + temp = kmalloc(sz, GFP_KERNEL|GFP_USERCOPY);
33804 + if (!temp) {
33805 + unxlate_dev_mem_ptr(p, ptr);
33806 + return -ENOMEM;
33807 + }
33808 + memcpy(temp, ptr, sz);
33809 +#else
33810 + temp = ptr;
33811 +#endif
33812 +
33813 + remaining = copy_to_user(buf, temp, sz);
33814 +
33815 +#ifdef CONFIG_PAX_USERCOPY
33816 + kfree(temp);
33817 +#endif
33818 +
33819 unxlate_dev_mem_ptr(p, ptr);
33820 if (remaining)
33821 return -EFAULT;
33822 @@ -378,7 +409,7 @@ static ssize_t read_oldmem(struct file *file, char __user *buf,
33823 else
33824 csize = count;
33825
33826 - rc = copy_oldmem_page(pfn, buf, csize, offset, 1);
33827 + rc = copy_oldmem_page(pfn, (char __force_kernel *)buf, csize, offset, 1);
33828 if (rc < 0)
33829 return rc;
33830 buf += csize;
33831 @@ -398,9 +429,8 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
33832 size_t count, loff_t *ppos)
33833 {
33834 unsigned long p = *ppos;
33835 - ssize_t low_count, read, sz;
33836 + ssize_t low_count, read, sz, err = 0;
33837 char *kbuf; /* k-addr because vread() takes vmlist_lock rwlock */
33838 - int err = 0;
33839
33840 read = 0;
33841 if (p < (unsigned long) high_memory) {
33842 @@ -422,6 +452,8 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
33843 }
33844 #endif
33845 while (low_count > 0) {
33846 + char *temp;
33847 +
33848 sz = size_inside_page(p, low_count);
33849
33850 /*
33851 @@ -431,7 +463,22 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
33852 */
33853 kbuf = xlate_dev_kmem_ptr((char *)p);
33854
33855 - if (copy_to_user(buf, kbuf, sz))
33856 +#ifdef CONFIG_PAX_USERCOPY
33857 + temp = kmalloc(sz, GFP_KERNEL|GFP_USERCOPY);
33858 + if (!temp)
33859 + return -ENOMEM;
33860 + memcpy(temp, kbuf, sz);
33861 +#else
33862 + temp = kbuf;
33863 +#endif
33864 +
33865 + err = copy_to_user(buf, temp, sz);
33866 +
33867 +#ifdef CONFIG_PAX_USERCOPY
33868 + kfree(temp);
33869 +#endif
33870 +
33871 + if (err)
33872 return -EFAULT;
33873 buf += sz;
33874 p += sz;
33875 @@ -833,6 +880,9 @@ static const struct memdev {
33876 #ifdef CONFIG_CRASH_DUMP
33877 [12] = { "oldmem", 0, &oldmem_fops, NULL },
33878 #endif
33879 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
33880 + [13] = { "grsec",S_IRUSR | S_IWUGO, &grsec_fops, NULL },
33881 +#endif
33882 };
33883
33884 static int memory_open(struct inode *inode, struct file *filp)
33885 diff --git a/drivers/char/nvram.c b/drivers/char/nvram.c
33886 index 9df78e2..01ba9ae 100644
33887 --- a/drivers/char/nvram.c
33888 +++ b/drivers/char/nvram.c
33889 @@ -247,7 +247,7 @@ static ssize_t nvram_read(struct file *file, char __user *buf,
33890
33891 spin_unlock_irq(&rtc_lock);
33892
33893 - if (copy_to_user(buf, contents, tmp - contents))
33894 + if (tmp - contents > sizeof(contents) || copy_to_user(buf, contents, tmp - contents))
33895 return -EFAULT;
33896
33897 *ppos = i;
33898 diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c
33899 index 5c5cc00..ac9edb7 100644
33900 --- a/drivers/char/pcmcia/synclink_cs.c
33901 +++ b/drivers/char/pcmcia/synclink_cs.c
33902 @@ -2345,9 +2345,9 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp)
33903
33904 if (debug_level >= DEBUG_LEVEL_INFO)
33905 printk("%s(%d):mgslpc_close(%s) entry, count=%d\n",
33906 - __FILE__, __LINE__, info->device_name, port->count);
33907 + __FILE__, __LINE__, info->device_name, atomic_read(&port->count));
33908
33909 - WARN_ON(!port->count);
33910 + WARN_ON(!atomic_read(&port->count));
33911
33912 if (tty_port_close_start(port, tty, filp) == 0)
33913 goto cleanup;
33914 @@ -2365,7 +2365,7 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp)
33915 cleanup:
33916 if (debug_level >= DEBUG_LEVEL_INFO)
33917 printk("%s(%d):mgslpc_close(%s) exit, count=%d\n", __FILE__, __LINE__,
33918 - tty->driver->name, port->count);
33919 + tty->driver->name, atomic_read(&port->count));
33920 }
33921
33922 /* Wait until the transmitter is empty.
33923 @@ -2507,7 +2507,7 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp)
33924
33925 if (debug_level >= DEBUG_LEVEL_INFO)
33926 printk("%s(%d):mgslpc_open(%s), old ref count = %d\n",
33927 - __FILE__, __LINE__, tty->driver->name, port->count);
33928 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
33929
33930 /* If port is closing, signal caller to try again */
33931 if (tty_hung_up_p(filp) || port->flags & ASYNC_CLOSING){
33932 @@ -2527,11 +2527,11 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp)
33933 goto cleanup;
33934 }
33935 spin_lock(&port->lock);
33936 - port->count++;
33937 + atomic_inc(&port->count);
33938 spin_unlock(&port->lock);
33939 spin_unlock_irqrestore(&info->netlock, flags);
33940
33941 - if (port->count == 1) {
33942 + if (atomic_read(&port->count) == 1) {
33943 /* 1st open on this device, init hardware */
33944 retval = startup(info, tty);
33945 if (retval < 0)
33946 @@ -3920,7 +3920,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
33947 unsigned short new_crctype;
33948
33949 /* return error if TTY interface open */
33950 - if (info->port.count)
33951 + if (atomic_read(&info->port.count))
33952 return -EBUSY;
33953
33954 switch (encoding)
33955 @@ -4024,7 +4024,7 @@ static int hdlcdev_open(struct net_device *dev)
33956
33957 /* arbitrate between network and tty opens */
33958 spin_lock_irqsave(&info->netlock, flags);
33959 - if (info->port.count != 0 || info->netcount != 0) {
33960 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
33961 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
33962 spin_unlock_irqrestore(&info->netlock, flags);
33963 return -EBUSY;
33964 @@ -4114,7 +4114,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
33965 printk("%s:hdlcdev_ioctl(%s)\n", __FILE__, dev->name);
33966
33967 /* return error if TTY interface open */
33968 - if (info->port.count)
33969 + if (atomic_read(&info->port.count))
33970 return -EBUSY;
33971
33972 if (cmd != SIOCWANDEV)
33973 diff --git a/drivers/char/random.c b/drivers/char/random.c
33974 index 32a6c57..98038d5 100644
33975 --- a/drivers/char/random.c
33976 +++ b/drivers/char/random.c
33977 @@ -272,8 +272,13 @@
33978 /*
33979 * Configuration information
33980 */
33981 +#ifdef CONFIG_GRKERNSEC_RANDNET
33982 +#define INPUT_POOL_WORDS 512
33983 +#define OUTPUT_POOL_WORDS 128
33984 +#else
33985 #define INPUT_POOL_WORDS 128
33986 #define OUTPUT_POOL_WORDS 32
33987 +#endif
33988 #define SEC_XFER_SIZE 512
33989 #define EXTRACT_SIZE 10
33990
33991 @@ -313,10 +318,17 @@ static struct poolinfo {
33992 int poolwords;
33993 int tap1, tap2, tap3, tap4, tap5;
33994 } poolinfo_table[] = {
33995 +#ifdef CONFIG_GRKERNSEC_RANDNET
33996 + /* x^512 + x^411 + x^308 + x^208 +x^104 + x + 1 -- 225 */
33997 + { 512, 411, 308, 208, 104, 1 },
33998 + /* x^128 + x^103 + x^76 + x^51 + x^25 + x + 1 -- 105 */
33999 + { 128, 103, 76, 51, 25, 1 },
34000 +#else
34001 /* x^128 + x^103 + x^76 + x^51 +x^25 + x + 1 -- 105 */
34002 { 128, 103, 76, 51, 25, 1 },
34003 /* x^32 + x^26 + x^20 + x^14 + x^7 + x + 1 -- 15 */
34004 { 32, 26, 20, 14, 7, 1 },
34005 +#endif
34006 #if 0
34007 /* x^2048 + x^1638 + x^1231 + x^819 + x^411 + x + 1 -- 115 */
34008 { 2048, 1638, 1231, 819, 411, 1 },
34009 @@ -524,8 +536,8 @@ static void _mix_pool_bytes(struct entropy_store *r, const void *in,
34010 input_rotate += i ? 7 : 14;
34011 }
34012
34013 - ACCESS_ONCE(r->input_rotate) = input_rotate;
34014 - ACCESS_ONCE(r->add_ptr) = i;
34015 + ACCESS_ONCE_RW(r->input_rotate) = input_rotate;
34016 + ACCESS_ONCE_RW(r->add_ptr) = i;
34017 smp_wmb();
34018
34019 if (out)
34020 @@ -865,16 +877,24 @@ static size_t account(struct entropy_store *r, size_t nbytes, int min,
34021 if (r->entropy_count / 8 < min + reserved) {
34022 nbytes = 0;
34023 } else {
34024 + int entropy_count, orig;
34025 +retry:
34026 + entropy_count = orig = ACCESS_ONCE(r->entropy_count);
34027 /* If limited, never pull more than available */
34028 - if (r->limit && nbytes + reserved >= r->entropy_count / 8)
34029 - nbytes = r->entropy_count/8 - reserved;
34030 + if (r->limit && nbytes + reserved >= entropy_count / 8)
34031 + nbytes = entropy_count/8 - reserved;
34032
34033 - if (r->entropy_count / 8 >= nbytes + reserved)
34034 - r->entropy_count -= nbytes*8;
34035 - else
34036 - r->entropy_count = reserved;
34037 + if (entropy_count / 8 >= nbytes + reserved) {
34038 + entropy_count -= nbytes*8;
34039 + if (cmpxchg(&r->entropy_count, orig, entropy_count) != orig)
34040 + goto retry;
34041 + } else {
34042 + entropy_count = reserved;
34043 + if (cmpxchg(&r->entropy_count, orig, entropy_count) != orig)
34044 + goto retry;
34045 + }
34046
34047 - if (r->entropy_count < random_write_wakeup_thresh)
34048 + if (entropy_count < random_write_wakeup_thresh)
34049 wakeup_write = 1;
34050 }
34051
34052 @@ -957,10 +977,23 @@ static ssize_t extract_entropy(struct entropy_store *r, void *buf,
34053 {
34054 ssize_t ret = 0, i;
34055 __u8 tmp[EXTRACT_SIZE];
34056 + unsigned long flags;
34057
34058 /* if last_data isn't primed, we need EXTRACT_SIZE extra bytes */
34059 - if (fips_enabled && !r->last_data_init)
34060 - nbytes += EXTRACT_SIZE;
34061 + if (fips_enabled) {
34062 + spin_lock_irqsave(&r->lock, flags);
34063 + if (!r->last_data_init) {
34064 + r->last_data_init = true;
34065 + spin_unlock_irqrestore(&r->lock, flags);
34066 + trace_extract_entropy(r->name, EXTRACT_SIZE,
34067 + r->entropy_count, _RET_IP_);
34068 + xfer_secondary_pool(r, EXTRACT_SIZE);
34069 + extract_buf(r, tmp);
34070 + spin_lock_irqsave(&r->lock, flags);
34071 + memcpy(r->last_data, tmp, EXTRACT_SIZE);
34072 + }
34073 + spin_unlock_irqrestore(&r->lock, flags);
34074 + }
34075
34076 trace_extract_entropy(r->name, nbytes, r->entropy_count, _RET_IP_);
34077 xfer_secondary_pool(r, nbytes);
34078 @@ -970,19 +1003,6 @@ static ssize_t extract_entropy(struct entropy_store *r, void *buf,
34079 extract_buf(r, tmp);
34080
34081 if (fips_enabled) {
34082 - unsigned long flags;
34083 -
34084 -
34085 - /* prime last_data value if need be, per fips 140-2 */
34086 - if (!r->last_data_init) {
34087 - spin_lock_irqsave(&r->lock, flags);
34088 - memcpy(r->last_data, tmp, EXTRACT_SIZE);
34089 - r->last_data_init = true;
34090 - nbytes -= EXTRACT_SIZE;
34091 - spin_unlock_irqrestore(&r->lock, flags);
34092 - extract_buf(r, tmp);
34093 - }
34094 -
34095 spin_lock_irqsave(&r->lock, flags);
34096 if (!memcmp(tmp, r->last_data, EXTRACT_SIZE))
34097 panic("Hardware RNG duplicated output!\n");
34098 @@ -1024,7 +1044,7 @@ static ssize_t extract_entropy_user(struct entropy_store *r, void __user *buf,
34099
34100 extract_buf(r, tmp);
34101 i = min_t(int, nbytes, EXTRACT_SIZE);
34102 - if (copy_to_user(buf, tmp, i)) {
34103 + if (i > sizeof(tmp) || copy_to_user(buf, tmp, i)) {
34104 ret = -EFAULT;
34105 break;
34106 }
34107 @@ -1360,7 +1380,7 @@ EXPORT_SYMBOL(generate_random_uuid);
34108 #include <linux/sysctl.h>
34109
34110 static int min_read_thresh = 8, min_write_thresh;
34111 -static int max_read_thresh = INPUT_POOL_WORDS * 32;
34112 +static int max_read_thresh = OUTPUT_POOL_WORDS * 32;
34113 static int max_write_thresh = INPUT_POOL_WORDS * 32;
34114 static char sysctl_bootid[16];
34115
34116 @@ -1376,7 +1396,7 @@ static char sysctl_bootid[16];
34117 static int proc_do_uuid(ctl_table *table, int write,
34118 void __user *buffer, size_t *lenp, loff_t *ppos)
34119 {
34120 - ctl_table fake_table;
34121 + ctl_table_no_const fake_table;
34122 unsigned char buf[64], tmp_uuid[16], *uuid;
34123
34124 uuid = table->data;
34125 diff --git a/drivers/char/sonypi.c b/drivers/char/sonypi.c
34126 index bf2349db..5456d53 100644
34127 --- a/drivers/char/sonypi.c
34128 +++ b/drivers/char/sonypi.c
34129 @@ -54,6 +54,7 @@
34130
34131 #include <asm/uaccess.h>
34132 #include <asm/io.h>
34133 +#include <asm/local.h>
34134
34135 #include <linux/sonypi.h>
34136
34137 @@ -490,7 +491,7 @@ static struct sonypi_device {
34138 spinlock_t fifo_lock;
34139 wait_queue_head_t fifo_proc_list;
34140 struct fasync_struct *fifo_async;
34141 - int open_count;
34142 + local_t open_count;
34143 int model;
34144 struct input_dev *input_jog_dev;
34145 struct input_dev *input_key_dev;
34146 @@ -897,7 +898,7 @@ static int sonypi_misc_fasync(int fd, struct file *filp, int on)
34147 static int sonypi_misc_release(struct inode *inode, struct file *file)
34148 {
34149 mutex_lock(&sonypi_device.lock);
34150 - sonypi_device.open_count--;
34151 + local_dec(&sonypi_device.open_count);
34152 mutex_unlock(&sonypi_device.lock);
34153 return 0;
34154 }
34155 @@ -906,9 +907,9 @@ static int sonypi_misc_open(struct inode *inode, struct file *file)
34156 {
34157 mutex_lock(&sonypi_device.lock);
34158 /* Flush input queue on first open */
34159 - if (!sonypi_device.open_count)
34160 + if (!local_read(&sonypi_device.open_count))
34161 kfifo_reset(&sonypi_device.fifo);
34162 - sonypi_device.open_count++;
34163 + local_inc(&sonypi_device.open_count);
34164 mutex_unlock(&sonypi_device.lock);
34165
34166 return 0;
34167 diff --git a/drivers/char/tpm/tpm_acpi.c b/drivers/char/tpm/tpm_acpi.c
34168 index 64420b3..5c40b56 100644
34169 --- a/drivers/char/tpm/tpm_acpi.c
34170 +++ b/drivers/char/tpm/tpm_acpi.c
34171 @@ -98,11 +98,12 @@ int read_log(struct tpm_bios_log *log)
34172 virt = acpi_os_map_memory(start, len);
34173 if (!virt) {
34174 kfree(log->bios_event_log);
34175 + log->bios_event_log = NULL;
34176 printk("%s: ERROR - Unable to map memory\n", __func__);
34177 return -EIO;
34178 }
34179
34180 - memcpy_fromio(log->bios_event_log, virt, len);
34181 + memcpy_fromio(log->bios_event_log, (const char __force_kernel *)virt, len);
34182
34183 acpi_os_unmap_memory(virt, len);
34184 return 0;
34185 diff --git a/drivers/char/tpm/tpm_eventlog.c b/drivers/char/tpm/tpm_eventlog.c
34186 index 84ddc55..1d32f1e 100644
34187 --- a/drivers/char/tpm/tpm_eventlog.c
34188 +++ b/drivers/char/tpm/tpm_eventlog.c
34189 @@ -95,7 +95,7 @@ static void *tpm_bios_measurements_start(struct seq_file *m, loff_t *pos)
34190 event = addr;
34191
34192 if ((event->event_type == 0 && event->event_size == 0) ||
34193 - ((addr + sizeof(struct tcpa_event) + event->event_size) >= limit))
34194 + (event->event_size >= limit - addr - sizeof(struct tcpa_event)))
34195 return NULL;
34196
34197 return addr;
34198 @@ -120,7 +120,7 @@ static void *tpm_bios_measurements_next(struct seq_file *m, void *v,
34199 return NULL;
34200
34201 if ((event->event_type == 0 && event->event_size == 0) ||
34202 - ((v + sizeof(struct tcpa_event) + event->event_size) >= limit))
34203 + (event->event_size >= limit - v - sizeof(struct tcpa_event)))
34204 return NULL;
34205
34206 (*pos)++;
34207 @@ -213,7 +213,8 @@ static int tpm_binary_bios_measurements_show(struct seq_file *m, void *v)
34208 int i;
34209
34210 for (i = 0; i < sizeof(struct tcpa_event) + event->event_size; i++)
34211 - seq_putc(m, data[i]);
34212 + if (!seq_putc(m, data[i]))
34213 + return -EFAULT;
34214
34215 return 0;
34216 }
34217 diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
34218 index ce5f3fc..e2d3e55 100644
34219 --- a/drivers/char/virtio_console.c
34220 +++ b/drivers/char/virtio_console.c
34221 @@ -679,7 +679,7 @@ static ssize_t fill_readbuf(struct port *port, char *out_buf, size_t out_count,
34222 if (to_user) {
34223 ssize_t ret;
34224
34225 - ret = copy_to_user(out_buf, buf->buf + buf->offset, out_count);
34226 + ret = copy_to_user((char __force_user *)out_buf, buf->buf + buf->offset, out_count);
34227 if (ret)
34228 return -EFAULT;
34229 } else {
34230 @@ -778,7 +778,7 @@ static ssize_t port_fops_read(struct file *filp, char __user *ubuf,
34231 if (!port_has_data(port) && !port->host_connected)
34232 return 0;
34233
34234 - return fill_readbuf(port, ubuf, count, true);
34235 + return fill_readbuf(port, (char __force_kernel *)ubuf, count, true);
34236 }
34237
34238 static int wait_port_writable(struct port *port, bool nonblock)
34239 diff --git a/drivers/clocksource/arm_arch_timer.c b/drivers/clocksource/arm_arch_timer.c
34240 index d7ad425..3e3f81f 100644
34241 --- a/drivers/clocksource/arm_arch_timer.c
34242 +++ b/drivers/clocksource/arm_arch_timer.c
34243 @@ -262,7 +262,7 @@ static int __cpuinit arch_timer_cpu_notify(struct notifier_block *self,
34244 return NOTIFY_OK;
34245 }
34246
34247 -static struct notifier_block arch_timer_cpu_nb __cpuinitdata = {
34248 +static struct notifier_block arch_timer_cpu_nb = {
34249 .notifier_call = arch_timer_cpu_notify,
34250 };
34251
34252 diff --git a/drivers/clocksource/metag_generic.c b/drivers/clocksource/metag_generic.c
34253 index ade7513..069445f 100644
34254 --- a/drivers/clocksource/metag_generic.c
34255 +++ b/drivers/clocksource/metag_generic.c
34256 @@ -169,7 +169,7 @@ static int __cpuinit arch_timer_cpu_notify(struct notifier_block *self,
34257 return NOTIFY_OK;
34258 }
34259
34260 -static struct notifier_block __cpuinitdata arch_timer_cpu_nb = {
34261 +static struct notifier_block arch_timer_cpu_nb = {
34262 .notifier_call = arch_timer_cpu_notify,
34263 };
34264
34265 diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c
34266 index 57a8774..545e993 100644
34267 --- a/drivers/cpufreq/acpi-cpufreq.c
34268 +++ b/drivers/cpufreq/acpi-cpufreq.c
34269 @@ -172,7 +172,7 @@ static ssize_t show_global_boost(struct kobject *kobj,
34270 return sprintf(buf, "%u\n", boost_enabled);
34271 }
34272
34273 -static struct global_attr global_boost = __ATTR(boost, 0644,
34274 +static global_attr_no_const global_boost = __ATTR(boost, 0644,
34275 show_global_boost,
34276 store_global_boost);
34277
34278 @@ -712,8 +712,11 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
34279 data->acpi_data = per_cpu_ptr(acpi_perf_data, cpu);
34280 per_cpu(acfreq_data, cpu) = data;
34281
34282 - if (cpu_has(c, X86_FEATURE_CONSTANT_TSC))
34283 - acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS;
34284 + if (cpu_has(c, X86_FEATURE_CONSTANT_TSC)) {
34285 + pax_open_kernel();
34286 + *(u8 *)&acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS;
34287 + pax_close_kernel();
34288 + }
34289
34290 result = acpi_processor_register_performance(data->acpi_data, cpu);
34291 if (result)
34292 @@ -839,7 +842,9 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
34293 policy->cur = acpi_cpufreq_guess_freq(data, policy->cpu);
34294 break;
34295 case ACPI_ADR_SPACE_FIXED_HARDWARE:
34296 - acpi_cpufreq_driver.get = get_cur_freq_on_cpu;
34297 + pax_open_kernel();
34298 + *(void **)&acpi_cpufreq_driver.get = get_cur_freq_on_cpu;
34299 + pax_close_kernel();
34300 policy->cur = get_cur_freq_on_cpu(cpu);
34301 break;
34302 default:
34303 @@ -850,8 +855,11 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
34304 acpi_processor_notify_smm(THIS_MODULE);
34305
34306 /* Check for APERF/MPERF support in hardware */
34307 - if (boot_cpu_has(X86_FEATURE_APERFMPERF))
34308 - acpi_cpufreq_driver.getavg = cpufreq_get_measured_perf;
34309 + if (boot_cpu_has(X86_FEATURE_APERFMPERF)) {
34310 + pax_open_kernel();
34311 + *(void **)&acpi_cpufreq_driver.getavg = cpufreq_get_measured_perf;
34312 + pax_close_kernel();
34313 + }
34314
34315 pr_debug("CPU%u - ACPI performance management activated.\n", cpu);
34316 for (i = 0; i < perf->state_count; i++)
34317 diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
34318 index b02824d..51e44aa 100644
34319 --- a/drivers/cpufreq/cpufreq.c
34320 +++ b/drivers/cpufreq/cpufreq.c
34321 @@ -1813,7 +1813,7 @@ static int __cpuinit cpufreq_cpu_callback(struct notifier_block *nfb,
34322 return NOTIFY_OK;
34323 }
34324
34325 -static struct notifier_block __refdata cpufreq_cpu_notifier = {
34326 +static struct notifier_block cpufreq_cpu_notifier = {
34327 .notifier_call = cpufreq_cpu_callback,
34328 };
34329
34330 @@ -1845,8 +1845,11 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data)
34331
34332 pr_debug("trying to register driver %s\n", driver_data->name);
34333
34334 - if (driver_data->setpolicy)
34335 - driver_data->flags |= CPUFREQ_CONST_LOOPS;
34336 + if (driver_data->setpolicy) {
34337 + pax_open_kernel();
34338 + *(u8 *)&driver_data->flags |= CPUFREQ_CONST_LOOPS;
34339 + pax_close_kernel();
34340 + }
34341
34342 spin_lock_irqsave(&cpufreq_driver_lock, flags);
34343 if (cpufreq_driver) {
34344 diff --git a/drivers/cpufreq/cpufreq_governor.c b/drivers/cpufreq/cpufreq_governor.c
34345 index 5a76086..0f4d394 100644
34346 --- a/drivers/cpufreq/cpufreq_governor.c
34347 +++ b/drivers/cpufreq/cpufreq_governor.c
34348 @@ -201,8 +201,8 @@ int cpufreq_governor_dbs(struct dbs_data *dbs_data,
34349 {
34350 struct od_cpu_dbs_info_s *od_dbs_info = NULL;
34351 struct cs_cpu_dbs_info_s *cs_dbs_info = NULL;
34352 - struct cs_ops *cs_ops = NULL;
34353 - struct od_ops *od_ops = NULL;
34354 + const struct cs_ops *cs_ops = NULL;
34355 + const struct od_ops *od_ops = NULL;
34356 struct od_dbs_tuners *od_tuners = dbs_data->tuners;
34357 struct cs_dbs_tuners *cs_tuners = dbs_data->tuners;
34358 struct cpu_dbs_common_info *cpu_cdbs;
34359 diff --git a/drivers/cpufreq/cpufreq_governor.h b/drivers/cpufreq/cpufreq_governor.h
34360 index cc4bd2f..ad142bc 100644
34361 --- a/drivers/cpufreq/cpufreq_governor.h
34362 +++ b/drivers/cpufreq/cpufreq_governor.h
34363 @@ -142,7 +142,7 @@ struct dbs_data {
34364 void (*gov_check_cpu)(int cpu, unsigned int load);
34365
34366 /* Governor specific ops, see below */
34367 - void *gov_ops;
34368 + const void *gov_ops;
34369 };
34370
34371 /* Governor specific ops, will be passed to dbs_data->gov_ops */
34372 diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c
34373 index bfd6273..e39dd63 100644
34374 --- a/drivers/cpufreq/cpufreq_stats.c
34375 +++ b/drivers/cpufreq/cpufreq_stats.c
34376 @@ -365,7 +365,7 @@ static int __cpuinit cpufreq_stat_cpu_callback(struct notifier_block *nfb,
34377 }
34378
34379 /* priority=1 so this will get called before cpufreq_remove_dev */
34380 -static struct notifier_block cpufreq_stat_cpu_notifier __refdata = {
34381 +static struct notifier_block cpufreq_stat_cpu_notifier = {
34382 .notifier_call = cpufreq_stat_cpu_callback,
34383 .priority = 1,
34384 };
34385 diff --git a/drivers/cpufreq/p4-clockmod.c b/drivers/cpufreq/p4-clockmod.c
34386 index 827629c9..0bc6a03 100644
34387 --- a/drivers/cpufreq/p4-clockmod.c
34388 +++ b/drivers/cpufreq/p4-clockmod.c
34389 @@ -167,10 +167,14 @@ static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c)
34390 case 0x0F: /* Core Duo */
34391 case 0x16: /* Celeron Core */
34392 case 0x1C: /* Atom */
34393 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34394 + pax_open_kernel();
34395 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34396 + pax_close_kernel();
34397 return speedstep_get_frequency(SPEEDSTEP_CPU_PCORE);
34398 case 0x0D: /* Pentium M (Dothan) */
34399 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34400 + pax_open_kernel();
34401 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34402 + pax_close_kernel();
34403 /* fall through */
34404 case 0x09: /* Pentium M (Banias) */
34405 return speedstep_get_frequency(SPEEDSTEP_CPU_PM);
34406 @@ -182,7 +186,9 @@ static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c)
34407
34408 /* on P-4s, the TSC runs with constant frequency independent whether
34409 * throttling is active or not. */
34410 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34411 + pax_open_kernel();
34412 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34413 + pax_close_kernel();
34414
34415 if (speedstep_detect_processor() == SPEEDSTEP_CPU_P4M) {
34416 printk(KERN_WARNING PFX "Warning: Pentium 4-M detected. "
34417 diff --git a/drivers/cpufreq/speedstep-centrino.c b/drivers/cpufreq/speedstep-centrino.c
34418 index 3a953d5..f5993f6 100644
34419 --- a/drivers/cpufreq/speedstep-centrino.c
34420 +++ b/drivers/cpufreq/speedstep-centrino.c
34421 @@ -353,8 +353,11 @@ static int centrino_cpu_init(struct cpufreq_policy *policy)
34422 !cpu_has(cpu, X86_FEATURE_EST))
34423 return -ENODEV;
34424
34425 - if (cpu_has(cpu, X86_FEATURE_CONSTANT_TSC))
34426 - centrino_driver.flags |= CPUFREQ_CONST_LOOPS;
34427 + if (cpu_has(cpu, X86_FEATURE_CONSTANT_TSC)) {
34428 + pax_open_kernel();
34429 + *(u8 *)&centrino_driver.flags |= CPUFREQ_CONST_LOOPS;
34430 + pax_close_kernel();
34431 + }
34432
34433 if (policy->cpu != 0)
34434 return -ENODEV;
34435 diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
34436 index eba6929..0f53baf 100644
34437 --- a/drivers/cpuidle/cpuidle.c
34438 +++ b/drivers/cpuidle/cpuidle.c
34439 @@ -277,7 +277,7 @@ static int poll_idle(struct cpuidle_device *dev,
34440
34441 static void poll_idle_init(struct cpuidle_driver *drv)
34442 {
34443 - struct cpuidle_state *state = &drv->states[0];
34444 + cpuidle_state_no_const *state = &drv->states[0];
34445
34446 snprintf(state->name, CPUIDLE_NAME_LEN, "POLL");
34447 snprintf(state->desc, CPUIDLE_DESC_LEN, "CPUIDLE CORE POLL IDLE");
34448 diff --git a/drivers/cpuidle/governor.c b/drivers/cpuidle/governor.c
34449 index ea2f8e7..70ac501 100644
34450 --- a/drivers/cpuidle/governor.c
34451 +++ b/drivers/cpuidle/governor.c
34452 @@ -87,7 +87,7 @@ int cpuidle_register_governor(struct cpuidle_governor *gov)
34453 mutex_lock(&cpuidle_lock);
34454 if (__cpuidle_find_governor(gov->name) == NULL) {
34455 ret = 0;
34456 - list_add_tail(&gov->governor_list, &cpuidle_governors);
34457 + pax_list_add_tail((struct list_head *)&gov->governor_list, &cpuidle_governors);
34458 if (!cpuidle_curr_governor ||
34459 cpuidle_curr_governor->rating < gov->rating)
34460 cpuidle_switch_governor(gov);
34461 @@ -135,7 +135,7 @@ void cpuidle_unregister_governor(struct cpuidle_governor *gov)
34462 new_gov = cpuidle_replace_governor(gov->rating);
34463 cpuidle_switch_governor(new_gov);
34464 }
34465 - list_del(&gov->governor_list);
34466 + pax_list_del((struct list_head *)&gov->governor_list);
34467 mutex_unlock(&cpuidle_lock);
34468 }
34469
34470 diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c
34471 index 428754a..8bdf9cc 100644
34472 --- a/drivers/cpuidle/sysfs.c
34473 +++ b/drivers/cpuidle/sysfs.c
34474 @@ -131,7 +131,7 @@ static struct attribute *cpuidle_switch_attrs[] = {
34475 NULL
34476 };
34477
34478 -static struct attribute_group cpuidle_attr_group = {
34479 +static attribute_group_no_const cpuidle_attr_group = {
34480 .attrs = cpuidle_default_attrs,
34481 .name = "cpuidle",
34482 };
34483 diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
34484 index 3b36797..289c16a 100644
34485 --- a/drivers/devfreq/devfreq.c
34486 +++ b/drivers/devfreq/devfreq.c
34487 @@ -588,7 +588,7 @@ int devfreq_add_governor(struct devfreq_governor *governor)
34488 goto err_out;
34489 }
34490
34491 - list_add(&governor->node, &devfreq_governor_list);
34492 + pax_list_add((struct list_head *)&governor->node, &devfreq_governor_list);
34493
34494 list_for_each_entry(devfreq, &devfreq_list, node) {
34495 int ret = 0;
34496 @@ -676,7 +676,7 @@ int devfreq_remove_governor(struct devfreq_governor *governor)
34497 }
34498 }
34499
34500 - list_del(&governor->node);
34501 + pax_list_del((struct list_head *)&governor->node);
34502 err_out:
34503 mutex_unlock(&devfreq_list_lock);
34504
34505 diff --git a/drivers/dma/sh/shdma.c b/drivers/dma/sh/shdma.c
34506 index b70709b..1d8d02a 100644
34507 --- a/drivers/dma/sh/shdma.c
34508 +++ b/drivers/dma/sh/shdma.c
34509 @@ -476,7 +476,7 @@ static int sh_dmae_nmi_handler(struct notifier_block *self,
34510 return ret;
34511 }
34512
34513 -static struct notifier_block sh_dmae_nmi_notifier __read_mostly = {
34514 +static struct notifier_block sh_dmae_nmi_notifier = {
34515 .notifier_call = sh_dmae_nmi_handler,
34516
34517 /* Run before NMI debug handler and KGDB */
34518 diff --git a/drivers/edac/edac_mc_sysfs.c b/drivers/edac/edac_mc_sysfs.c
34519 index 769d92e..a3dcc1e 100644
34520 --- a/drivers/edac/edac_mc_sysfs.c
34521 +++ b/drivers/edac/edac_mc_sysfs.c
34522 @@ -148,7 +148,7 @@ static const char *edac_caps[] = {
34523 struct dev_ch_attribute {
34524 struct device_attribute attr;
34525 int channel;
34526 -};
34527 +} __do_const;
34528
34529 #define DEVICE_CHANNEL(_name, _mode, _show, _store, _var) \
34530 struct dev_ch_attribute dev_attr_legacy_##_name = \
34531 @@ -1003,14 +1003,16 @@ int edac_create_sysfs_mci_device(struct mem_ctl_info *mci)
34532 }
34533
34534 if (mci->set_sdram_scrub_rate || mci->get_sdram_scrub_rate) {
34535 + pax_open_kernel();
34536 if (mci->get_sdram_scrub_rate) {
34537 - dev_attr_sdram_scrub_rate.attr.mode |= S_IRUGO;
34538 - dev_attr_sdram_scrub_rate.show = &mci_sdram_scrub_rate_show;
34539 + *(umode_t *)&dev_attr_sdram_scrub_rate.attr.mode |= S_IRUGO;
34540 + *(void **)&dev_attr_sdram_scrub_rate.show = &mci_sdram_scrub_rate_show;
34541 }
34542 if (mci->set_sdram_scrub_rate) {
34543 - dev_attr_sdram_scrub_rate.attr.mode |= S_IWUSR;
34544 - dev_attr_sdram_scrub_rate.store = &mci_sdram_scrub_rate_store;
34545 + *(umode_t *)&dev_attr_sdram_scrub_rate.attr.mode |= S_IWUSR;
34546 + *(void **)&dev_attr_sdram_scrub_rate.store = &mci_sdram_scrub_rate_store;
34547 }
34548 + pax_close_kernel();
34549 err = device_create_file(&mci->dev,
34550 &dev_attr_sdram_scrub_rate);
34551 if (err) {
34552 diff --git a/drivers/edac/edac_pci_sysfs.c b/drivers/edac/edac_pci_sysfs.c
34553 index e8658e4..22746d6 100644
34554 --- a/drivers/edac/edac_pci_sysfs.c
34555 +++ b/drivers/edac/edac_pci_sysfs.c
34556 @@ -26,8 +26,8 @@ static int edac_pci_log_pe = 1; /* log PCI parity errors */
34557 static int edac_pci_log_npe = 1; /* log PCI non-parity error errors */
34558 static int edac_pci_poll_msec = 1000; /* one second workq period */
34559
34560 -static atomic_t pci_parity_count = ATOMIC_INIT(0);
34561 -static atomic_t pci_nonparity_count = ATOMIC_INIT(0);
34562 +static atomic_unchecked_t pci_parity_count = ATOMIC_INIT(0);
34563 +static atomic_unchecked_t pci_nonparity_count = ATOMIC_INIT(0);
34564
34565 static struct kobject *edac_pci_top_main_kobj;
34566 static atomic_t edac_pci_sysfs_refcount = ATOMIC_INIT(0);
34567 @@ -235,7 +235,7 @@ struct edac_pci_dev_attribute {
34568 void *value;
34569 ssize_t(*show) (void *, char *);
34570 ssize_t(*store) (void *, const char *, size_t);
34571 -};
34572 +} __do_const;
34573
34574 /* Set of show/store abstract level functions for PCI Parity object */
34575 static ssize_t edac_pci_dev_show(struct kobject *kobj, struct attribute *attr,
34576 @@ -579,7 +579,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34577 edac_printk(KERN_CRIT, EDAC_PCI,
34578 "Signaled System Error on %s\n",
34579 pci_name(dev));
34580 - atomic_inc(&pci_nonparity_count);
34581 + atomic_inc_unchecked(&pci_nonparity_count);
34582 }
34583
34584 if (status & (PCI_STATUS_PARITY)) {
34585 @@ -587,7 +587,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34586 "Master Data Parity Error on %s\n",
34587 pci_name(dev));
34588
34589 - atomic_inc(&pci_parity_count);
34590 + atomic_inc_unchecked(&pci_parity_count);
34591 }
34592
34593 if (status & (PCI_STATUS_DETECTED_PARITY)) {
34594 @@ -595,7 +595,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34595 "Detected Parity Error on %s\n",
34596 pci_name(dev));
34597
34598 - atomic_inc(&pci_parity_count);
34599 + atomic_inc_unchecked(&pci_parity_count);
34600 }
34601 }
34602
34603 @@ -618,7 +618,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34604 edac_printk(KERN_CRIT, EDAC_PCI, "Bridge "
34605 "Signaled System Error on %s\n",
34606 pci_name(dev));
34607 - atomic_inc(&pci_nonparity_count);
34608 + atomic_inc_unchecked(&pci_nonparity_count);
34609 }
34610
34611 if (status & (PCI_STATUS_PARITY)) {
34612 @@ -626,7 +626,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34613 "Master Data Parity Error on "
34614 "%s\n", pci_name(dev));
34615
34616 - atomic_inc(&pci_parity_count);
34617 + atomic_inc_unchecked(&pci_parity_count);
34618 }
34619
34620 if (status & (PCI_STATUS_DETECTED_PARITY)) {
34621 @@ -634,7 +634,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34622 "Detected Parity Error on %s\n",
34623 pci_name(dev));
34624
34625 - atomic_inc(&pci_parity_count);
34626 + atomic_inc_unchecked(&pci_parity_count);
34627 }
34628 }
34629 }
34630 @@ -672,7 +672,7 @@ void edac_pci_do_parity_check(void)
34631 if (!check_pci_errors)
34632 return;
34633
34634 - before_count = atomic_read(&pci_parity_count);
34635 + before_count = atomic_read_unchecked(&pci_parity_count);
34636
34637 /* scan all PCI devices looking for a Parity Error on devices and
34638 * bridges.
34639 @@ -684,7 +684,7 @@ void edac_pci_do_parity_check(void)
34640 /* Only if operator has selected panic on PCI Error */
34641 if (edac_pci_get_panic_on_pe()) {
34642 /* If the count is different 'after' from 'before' */
34643 - if (before_count != atomic_read(&pci_parity_count))
34644 + if (before_count != atomic_read_unchecked(&pci_parity_count))
34645 panic("EDAC: PCI Parity Error");
34646 }
34647 }
34648 diff --git a/drivers/edac/mce_amd.h b/drivers/edac/mce_amd.h
34649 index 51b7e3a..aa8a3e8 100644
34650 --- a/drivers/edac/mce_amd.h
34651 +++ b/drivers/edac/mce_amd.h
34652 @@ -77,7 +77,7 @@ struct amd_decoder_ops {
34653 bool (*mc0_mce)(u16, u8);
34654 bool (*mc1_mce)(u16, u8);
34655 bool (*mc2_mce)(u16, u8);
34656 -};
34657 +} __no_const;
34658
34659 void amd_report_gart_errors(bool);
34660 void amd_register_ecc_decoder(void (*f)(int, struct mce *));
34661 diff --git a/drivers/firewire/core-card.c b/drivers/firewire/core-card.c
34662 index 57ea7f4..789e3c3 100644
34663 --- a/drivers/firewire/core-card.c
34664 +++ b/drivers/firewire/core-card.c
34665 @@ -680,7 +680,7 @@ EXPORT_SYMBOL_GPL(fw_card_release);
34666
34667 void fw_core_remove_card(struct fw_card *card)
34668 {
34669 - struct fw_card_driver dummy_driver = dummy_driver_template;
34670 + fw_card_driver_no_const dummy_driver = dummy_driver_template;
34671
34672 card->driver->update_phy_reg(card, 4,
34673 PHY_LINK_ACTIVE | PHY_CONTENDER, 0);
34674 diff --git a/drivers/firewire/core-cdev.c b/drivers/firewire/core-cdev.c
34675 index 27ac423..13573e8 100644
34676 --- a/drivers/firewire/core-cdev.c
34677 +++ b/drivers/firewire/core-cdev.c
34678 @@ -1366,8 +1366,7 @@ static int init_iso_resource(struct client *client,
34679 int ret;
34680
34681 if ((request->channels == 0 && request->bandwidth == 0) ||
34682 - request->bandwidth > BANDWIDTH_AVAILABLE_INITIAL ||
34683 - request->bandwidth < 0)
34684 + request->bandwidth > BANDWIDTH_AVAILABLE_INITIAL)
34685 return -EINVAL;
34686
34687 r = kmalloc(sizeof(*r), GFP_KERNEL);
34688 diff --git a/drivers/firewire/core-device.c b/drivers/firewire/core-device.c
34689 index 03ce7d9..b70f5da 100644
34690 --- a/drivers/firewire/core-device.c
34691 +++ b/drivers/firewire/core-device.c
34692 @@ -232,7 +232,7 @@ EXPORT_SYMBOL(fw_device_enable_phys_dma);
34693 struct config_rom_attribute {
34694 struct device_attribute attr;
34695 u32 key;
34696 -};
34697 +} __do_const;
34698
34699 static ssize_t show_immediate(struct device *dev,
34700 struct device_attribute *dattr, char *buf)
34701 diff --git a/drivers/firewire/core-transaction.c b/drivers/firewire/core-transaction.c
34702 index 28a94c7..58da63a 100644
34703 --- a/drivers/firewire/core-transaction.c
34704 +++ b/drivers/firewire/core-transaction.c
34705 @@ -38,6 +38,7 @@
34706 #include <linux/timer.h>
34707 #include <linux/types.h>
34708 #include <linux/workqueue.h>
34709 +#include <linux/sched.h>
34710
34711 #include <asm/byteorder.h>
34712
34713 diff --git a/drivers/firewire/core.h b/drivers/firewire/core.h
34714 index 515a42c..5ecf3ba 100644
34715 --- a/drivers/firewire/core.h
34716 +++ b/drivers/firewire/core.h
34717 @@ -111,6 +111,7 @@ struct fw_card_driver {
34718
34719 int (*stop_iso)(struct fw_iso_context *ctx);
34720 };
34721 +typedef struct fw_card_driver __no_const fw_card_driver_no_const;
34722
34723 void fw_card_initialize(struct fw_card *card,
34724 const struct fw_card_driver *driver, struct device *device);
34725 diff --git a/drivers/firmware/dmi-id.c b/drivers/firmware/dmi-id.c
34726 index 94a58a0..f5eba42 100644
34727 --- a/drivers/firmware/dmi-id.c
34728 +++ b/drivers/firmware/dmi-id.c
34729 @@ -16,7 +16,7 @@
34730 struct dmi_device_attribute{
34731 struct device_attribute dev_attr;
34732 int field;
34733 -};
34734 +} __do_const;
34735 #define to_dmi_dev_attr(_dev_attr) \
34736 container_of(_dev_attr, struct dmi_device_attribute, dev_attr)
34737
34738 diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c
34739 index 4cd392d..4b629e1 100644
34740 --- a/drivers/firmware/dmi_scan.c
34741 +++ b/drivers/firmware/dmi_scan.c
34742 @@ -490,11 +490,6 @@ void __init dmi_scan_machine(void)
34743 }
34744 }
34745 else {
34746 - /*
34747 - * no iounmap() for that ioremap(); it would be a no-op, but
34748 - * it's so early in setup that sucker gets confused into doing
34749 - * what it shouldn't if we actually call it.
34750 - */
34751 p = dmi_ioremap(0xF0000, 0x10000);
34752 if (p == NULL)
34753 goto error;
34754 @@ -769,7 +764,7 @@ int dmi_walk(void (*decode)(const struct dmi_header *, void *),
34755 if (buf == NULL)
34756 return -1;
34757
34758 - dmi_table(buf, dmi_len, dmi_num, decode, private_data);
34759 + dmi_table((char __force_kernel *)buf, dmi_len, dmi_num, decode, private_data);
34760
34761 iounmap(buf);
34762 return 0;
34763 diff --git a/drivers/firmware/efivars.c b/drivers/firmware/efivars.c
34764 index f4baa11..7970c3a 100644
34765 --- a/drivers/firmware/efivars.c
34766 +++ b/drivers/firmware/efivars.c
34767 @@ -139,7 +139,7 @@ struct efivar_attribute {
34768 };
34769
34770 static struct efivars __efivars;
34771 -static struct efivar_operations ops;
34772 +static efivar_operations_no_const ops __read_only;
34773
34774 #define PSTORE_EFI_ATTRIBUTES \
34775 (EFI_VARIABLE_NON_VOLATILE | \
34776 @@ -1844,7 +1844,7 @@ efivar_create_sysfs_entry(struct efivars *efivars,
34777 static int
34778 create_efivars_bin_attributes(struct efivars *efivars)
34779 {
34780 - struct bin_attribute *attr;
34781 + bin_attribute_no_const *attr;
34782 int error;
34783
34784 /* new_var */
34785 diff --git a/drivers/firmware/google/memconsole.c b/drivers/firmware/google/memconsole.c
34786 index 2a90ba6..07f3733 100644
34787 --- a/drivers/firmware/google/memconsole.c
34788 +++ b/drivers/firmware/google/memconsole.c
34789 @@ -147,7 +147,9 @@ static int __init memconsole_init(void)
34790 if (!found_memconsole())
34791 return -ENODEV;
34792
34793 - memconsole_bin_attr.size = memconsole_length;
34794 + pax_open_kernel();
34795 + *(size_t *)&memconsole_bin_attr.size = memconsole_length;
34796 + pax_close_kernel();
34797
34798 ret = sysfs_create_bin_file(firmware_kobj, &memconsole_bin_attr);
34799
34800 diff --git a/drivers/gpio/gpio-ich.c b/drivers/gpio/gpio-ich.c
34801 index de3c317..b7cd029 100644
34802 --- a/drivers/gpio/gpio-ich.c
34803 +++ b/drivers/gpio/gpio-ich.c
34804 @@ -69,7 +69,7 @@ struct ichx_desc {
34805 /* Some chipsets have quirks, let these use their own request/get */
34806 int (*request)(struct gpio_chip *chip, unsigned offset);
34807 int (*get)(struct gpio_chip *chip, unsigned offset);
34808 -};
34809 +} __do_const;
34810
34811 static struct {
34812 spinlock_t lock;
34813 diff --git a/drivers/gpio/gpio-vr41xx.c b/drivers/gpio/gpio-vr41xx.c
34814 index 9902732..64b62dd 100644
34815 --- a/drivers/gpio/gpio-vr41xx.c
34816 +++ b/drivers/gpio/gpio-vr41xx.c
34817 @@ -204,7 +204,7 @@ static int giu_get_irq(unsigned int irq)
34818 printk(KERN_ERR "spurious GIU interrupt: %04x(%04x),%04x(%04x)\n",
34819 maskl, pendl, maskh, pendh);
34820
34821 - atomic_inc(&irq_err_count);
34822 + atomic_inc_unchecked(&irq_err_count);
34823
34824 return -EINVAL;
34825 }
34826 diff --git a/drivers/gpu/drm/drm_crtc_helper.c b/drivers/gpu/drm/drm_crtc_helper.c
34827 index 7b2d378..cc947ea 100644
34828 --- a/drivers/gpu/drm/drm_crtc_helper.c
34829 +++ b/drivers/gpu/drm/drm_crtc_helper.c
34830 @@ -319,7 +319,7 @@ static bool drm_encoder_crtc_ok(struct drm_encoder *encoder,
34831 struct drm_crtc *tmp;
34832 int crtc_mask = 1;
34833
34834 - WARN(!crtc, "checking null crtc?\n");
34835 + BUG_ON(!crtc);
34836
34837 dev = crtc->dev;
34838
34839 diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
34840 index 25f91cd..a376f55 100644
34841 --- a/drivers/gpu/drm/drm_drv.c
34842 +++ b/drivers/gpu/drm/drm_drv.c
34843 @@ -306,7 +306,7 @@ module_exit(drm_core_exit);
34844 /**
34845 * Copy and IOCTL return string to user space
34846 */
34847 -static int drm_copy_field(char *buf, size_t *buf_len, const char *value)
34848 +static int drm_copy_field(char __user *buf, size_t *buf_len, const char *value)
34849 {
34850 int len;
34851
34852 @@ -376,7 +376,7 @@ long drm_ioctl(struct file *filp,
34853 struct drm_file *file_priv = filp->private_data;
34854 struct drm_device *dev;
34855 struct drm_ioctl_desc *ioctl;
34856 - drm_ioctl_t *func;
34857 + drm_ioctl_no_const_t func;
34858 unsigned int nr = DRM_IOCTL_NR(cmd);
34859 int retcode = -EINVAL;
34860 char stack_kdata[128];
34861 @@ -389,7 +389,7 @@ long drm_ioctl(struct file *filp,
34862 return -ENODEV;
34863
34864 atomic_inc(&dev->ioctl_count);
34865 - atomic_inc(&dev->counts[_DRM_STAT_IOCTLS]);
34866 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_IOCTLS]);
34867 ++file_priv->ioctl_count;
34868
34869 DRM_DEBUG("pid=%d, cmd=0x%02x, nr=0x%02x, dev 0x%lx, auth=%d\n",
34870 diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
34871 index 429e07d..e681a2c 100644
34872 --- a/drivers/gpu/drm/drm_fops.c
34873 +++ b/drivers/gpu/drm/drm_fops.c
34874 @@ -71,7 +71,7 @@ static int drm_setup(struct drm_device * dev)
34875 }
34876
34877 for (i = 0; i < ARRAY_SIZE(dev->counts); i++)
34878 - atomic_set(&dev->counts[i], 0);
34879 + atomic_set_unchecked(&dev->counts[i], 0);
34880
34881 dev->sigdata.lock = NULL;
34882
34883 @@ -135,7 +135,7 @@ int drm_open(struct inode *inode, struct file *filp)
34884 if (drm_device_is_unplugged(dev))
34885 return -ENODEV;
34886
34887 - if (!dev->open_count++)
34888 + if (local_inc_return(&dev->open_count) == 1)
34889 need_setup = 1;
34890 mutex_lock(&dev->struct_mutex);
34891 old_imapping = inode->i_mapping;
34892 @@ -151,7 +151,7 @@ int drm_open(struct inode *inode, struct file *filp)
34893 retcode = drm_open_helper(inode, filp, dev);
34894 if (retcode)
34895 goto err_undo;
34896 - atomic_inc(&dev->counts[_DRM_STAT_OPENS]);
34897 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_OPENS]);
34898 if (need_setup) {
34899 retcode = drm_setup(dev);
34900 if (retcode)
34901 @@ -166,7 +166,7 @@ err_undo:
34902 iput(container_of(dev->dev_mapping, struct inode, i_data));
34903 dev->dev_mapping = old_mapping;
34904 mutex_unlock(&dev->struct_mutex);
34905 - dev->open_count--;
34906 + local_dec(&dev->open_count);
34907 return retcode;
34908 }
34909 EXPORT_SYMBOL(drm_open);
34910 @@ -441,7 +441,7 @@ int drm_release(struct inode *inode, struct file *filp)
34911
34912 mutex_lock(&drm_global_mutex);
34913
34914 - DRM_DEBUG("open_count = %d\n", dev->open_count);
34915 + DRM_DEBUG("open_count = %ld\n", local_read(&dev->open_count));
34916
34917 if (dev->driver->preclose)
34918 dev->driver->preclose(dev, file_priv);
34919 @@ -450,10 +450,10 @@ int drm_release(struct inode *inode, struct file *filp)
34920 * Begin inline drm_release
34921 */
34922
34923 - DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %d\n",
34924 + DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %ld\n",
34925 task_pid_nr(current),
34926 (long)old_encode_dev(file_priv->minor->device),
34927 - dev->open_count);
34928 + local_read(&dev->open_count));
34929
34930 /* Release any auth tokens that might point to this file_priv,
34931 (do that under the drm_global_mutex) */
34932 @@ -550,8 +550,8 @@ int drm_release(struct inode *inode, struct file *filp)
34933 * End inline drm_release
34934 */
34935
34936 - atomic_inc(&dev->counts[_DRM_STAT_CLOSES]);
34937 - if (!--dev->open_count) {
34938 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_CLOSES]);
34939 + if (local_dec_and_test(&dev->open_count)) {
34940 if (atomic_read(&dev->ioctl_count)) {
34941 DRM_ERROR("Device busy: %d\n",
34942 atomic_read(&dev->ioctl_count));
34943 diff --git a/drivers/gpu/drm/drm_global.c b/drivers/gpu/drm/drm_global.c
34944 index f731116..629842c 100644
34945 --- a/drivers/gpu/drm/drm_global.c
34946 +++ b/drivers/gpu/drm/drm_global.c
34947 @@ -36,7 +36,7 @@
34948 struct drm_global_item {
34949 struct mutex mutex;
34950 void *object;
34951 - int refcount;
34952 + atomic_t refcount;
34953 };
34954
34955 static struct drm_global_item glob[DRM_GLOBAL_NUM];
34956 @@ -49,7 +49,7 @@ void drm_global_init(void)
34957 struct drm_global_item *item = &glob[i];
34958 mutex_init(&item->mutex);
34959 item->object = NULL;
34960 - item->refcount = 0;
34961 + atomic_set(&item->refcount, 0);
34962 }
34963 }
34964
34965 @@ -59,7 +59,7 @@ void drm_global_release(void)
34966 for (i = 0; i < DRM_GLOBAL_NUM; ++i) {
34967 struct drm_global_item *item = &glob[i];
34968 BUG_ON(item->object != NULL);
34969 - BUG_ON(item->refcount != 0);
34970 + BUG_ON(atomic_read(&item->refcount) != 0);
34971 }
34972 }
34973
34974 @@ -70,7 +70,7 @@ int drm_global_item_ref(struct drm_global_reference *ref)
34975 void *object;
34976
34977 mutex_lock(&item->mutex);
34978 - if (item->refcount == 0) {
34979 + if (atomic_read(&item->refcount) == 0) {
34980 item->object = kzalloc(ref->size, GFP_KERNEL);
34981 if (unlikely(item->object == NULL)) {
34982 ret = -ENOMEM;
34983 @@ -83,7 +83,7 @@ int drm_global_item_ref(struct drm_global_reference *ref)
34984 goto out_err;
34985
34986 }
34987 - ++item->refcount;
34988 + atomic_inc(&item->refcount);
34989 ref->object = item->object;
34990 object = item->object;
34991 mutex_unlock(&item->mutex);
34992 @@ -100,9 +100,9 @@ void drm_global_item_unref(struct drm_global_reference *ref)
34993 struct drm_global_item *item = &glob[ref->global_type];
34994
34995 mutex_lock(&item->mutex);
34996 - BUG_ON(item->refcount == 0);
34997 + BUG_ON(atomic_read(&item->refcount) == 0);
34998 BUG_ON(ref->object != item->object);
34999 - if (--item->refcount == 0) {
35000 + if (atomic_dec_and_test(&item->refcount)) {
35001 ref->release(ref);
35002 item->object = NULL;
35003 }
35004 diff --git a/drivers/gpu/drm/drm_info.c b/drivers/gpu/drm/drm_info.c
35005 index d4b20ce..77a8d41 100644
35006 --- a/drivers/gpu/drm/drm_info.c
35007 +++ b/drivers/gpu/drm/drm_info.c
35008 @@ -75,10 +75,14 @@ int drm_vm_info(struct seq_file *m, void *data)
35009 struct drm_local_map *map;
35010 struct drm_map_list *r_list;
35011
35012 - /* Hardcoded from _DRM_FRAME_BUFFER,
35013 - _DRM_REGISTERS, _DRM_SHM, _DRM_AGP, and
35014 - _DRM_SCATTER_GATHER and _DRM_CONSISTENT */
35015 - const char *types[] = { "FB", "REG", "SHM", "AGP", "SG", "PCI" };
35016 + static const char * const types[] = {
35017 + [_DRM_FRAME_BUFFER] = "FB",
35018 + [_DRM_REGISTERS] = "REG",
35019 + [_DRM_SHM] = "SHM",
35020 + [_DRM_AGP] = "AGP",
35021 + [_DRM_SCATTER_GATHER] = "SG",
35022 + [_DRM_CONSISTENT] = "PCI",
35023 + [_DRM_GEM] = "GEM" };
35024 const char *type;
35025 int i;
35026
35027 @@ -89,7 +93,7 @@ int drm_vm_info(struct seq_file *m, void *data)
35028 map = r_list->map;
35029 if (!map)
35030 continue;
35031 - if (map->type < 0 || map->type > 5)
35032 + if (map->type >= ARRAY_SIZE(types))
35033 type = "??";
35034 else
35035 type = types[map->type];
35036 @@ -253,7 +257,11 @@ int drm_vma_info(struct seq_file *m, void *data)
35037 vma->vm_flags & VM_MAYSHARE ? 's' : 'p',
35038 vma->vm_flags & VM_LOCKED ? 'l' : '-',
35039 vma->vm_flags & VM_IO ? 'i' : '-',
35040 +#ifdef CONFIG_GRKERNSEC_HIDESYM
35041 + 0);
35042 +#else
35043 vma->vm_pgoff);
35044 +#endif
35045
35046 #if defined(__i386__)
35047 pgprot = pgprot_val(vma->vm_page_prot);
35048 diff --git a/drivers/gpu/drm/drm_ioc32.c b/drivers/gpu/drm/drm_ioc32.c
35049 index 2f4c434..dd12cd2 100644
35050 --- a/drivers/gpu/drm/drm_ioc32.c
35051 +++ b/drivers/gpu/drm/drm_ioc32.c
35052 @@ -457,7 +457,7 @@ static int compat_drm_infobufs(struct file *file, unsigned int cmd,
35053 request = compat_alloc_user_space(nbytes);
35054 if (!access_ok(VERIFY_WRITE, request, nbytes))
35055 return -EFAULT;
35056 - list = (struct drm_buf_desc *) (request + 1);
35057 + list = (struct drm_buf_desc __user *) (request + 1);
35058
35059 if (__put_user(count, &request->count)
35060 || __put_user(list, &request->list))
35061 @@ -518,7 +518,7 @@ static int compat_drm_mapbufs(struct file *file, unsigned int cmd,
35062 request = compat_alloc_user_space(nbytes);
35063 if (!access_ok(VERIFY_WRITE, request, nbytes))
35064 return -EFAULT;
35065 - list = (struct drm_buf_pub *) (request + 1);
35066 + list = (struct drm_buf_pub __user *) (request + 1);
35067
35068 if (__put_user(count, &request->count)
35069 || __put_user(list, &request->list))
35070 @@ -1016,7 +1016,7 @@ static int compat_drm_wait_vblank(struct file *file, unsigned int cmd,
35071 return 0;
35072 }
35073
35074 -drm_ioctl_compat_t *drm_compat_ioctls[] = {
35075 +drm_ioctl_compat_t drm_compat_ioctls[] = {
35076 [DRM_IOCTL_NR(DRM_IOCTL_VERSION32)] = compat_drm_version,
35077 [DRM_IOCTL_NR(DRM_IOCTL_GET_UNIQUE32)] = compat_drm_getunique,
35078 [DRM_IOCTL_NR(DRM_IOCTL_GET_MAP32)] = compat_drm_getmap,
35079 @@ -1062,7 +1062,6 @@ drm_ioctl_compat_t *drm_compat_ioctls[] = {
35080 long drm_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
35081 {
35082 unsigned int nr = DRM_IOCTL_NR(cmd);
35083 - drm_ioctl_compat_t *fn;
35084 int ret;
35085
35086 /* Assume that ioctls without an explicit compat routine will just
35087 @@ -1072,10 +1071,8 @@ long drm_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
35088 if (nr >= ARRAY_SIZE(drm_compat_ioctls))
35089 return drm_ioctl(filp, cmd, arg);
35090
35091 - fn = drm_compat_ioctls[nr];
35092 -
35093 - if (fn != NULL)
35094 - ret = (*fn) (filp, cmd, arg);
35095 + if (drm_compat_ioctls[nr] != NULL)
35096 + ret = (*drm_compat_ioctls[nr]) (filp, cmd, arg);
35097 else
35098 ret = drm_ioctl(filp, cmd, arg);
35099
35100 diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
35101 index e77bd8b..1571b85 100644
35102 --- a/drivers/gpu/drm/drm_ioctl.c
35103 +++ b/drivers/gpu/drm/drm_ioctl.c
35104 @@ -252,7 +252,7 @@ int drm_getstats(struct drm_device *dev, void *data,
35105 stats->data[i].value =
35106 (file_priv->master->lock.hw_lock ? file_priv->master->lock.hw_lock->lock : 0);
35107 else
35108 - stats->data[i].value = atomic_read(&dev->counts[i]);
35109 + stats->data[i].value = atomic_read_unchecked(&dev->counts[i]);
35110 stats->data[i].type = dev->types[i];
35111 }
35112
35113 diff --git a/drivers/gpu/drm/drm_lock.c b/drivers/gpu/drm/drm_lock.c
35114 index d752c96..fe08455 100644
35115 --- a/drivers/gpu/drm/drm_lock.c
35116 +++ b/drivers/gpu/drm/drm_lock.c
35117 @@ -86,7 +86,7 @@ int drm_lock(struct drm_device *dev, void *data, struct drm_file *file_priv)
35118 if (drm_lock_take(&master->lock, lock->context)) {
35119 master->lock.file_priv = file_priv;
35120 master->lock.lock_time = jiffies;
35121 - atomic_inc(&dev->counts[_DRM_STAT_LOCKS]);
35122 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_LOCKS]);
35123 break; /* Got lock */
35124 }
35125
35126 @@ -157,7 +157,7 @@ int drm_unlock(struct drm_device *dev, void *data, struct drm_file *file_priv)
35127 return -EINVAL;
35128 }
35129
35130 - atomic_inc(&dev->counts[_DRM_STAT_UNLOCKS]);
35131 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_UNLOCKS]);
35132
35133 if (drm_lock_free(&master->lock, lock->context)) {
35134 /* FIXME: Should really bail out here. */
35135 diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c
35136 index 7d30802..42c6cbb 100644
35137 --- a/drivers/gpu/drm/drm_stub.c
35138 +++ b/drivers/gpu/drm/drm_stub.c
35139 @@ -501,7 +501,7 @@ void drm_unplug_dev(struct drm_device *dev)
35140
35141 drm_device_set_unplugged(dev);
35142
35143 - if (dev->open_count == 0) {
35144 + if (local_read(&dev->open_count) == 0) {
35145 drm_put_dev(dev);
35146 }
35147 mutex_unlock(&drm_global_mutex);
35148 diff --git a/drivers/gpu/drm/i810/i810_dma.c b/drivers/gpu/drm/i810/i810_dma.c
35149 index 004ecdf..db1f6e0 100644
35150 --- a/drivers/gpu/drm/i810/i810_dma.c
35151 +++ b/drivers/gpu/drm/i810/i810_dma.c
35152 @@ -945,8 +945,8 @@ static int i810_dma_vertex(struct drm_device *dev, void *data,
35153 dma->buflist[vertex->idx],
35154 vertex->discard, vertex->used);
35155
35156 - atomic_add(vertex->used, &dev->counts[_DRM_STAT_SECONDARY]);
35157 - atomic_inc(&dev->counts[_DRM_STAT_DMA]);
35158 + atomic_add_unchecked(vertex->used, &dev->counts[_DRM_STAT_SECONDARY]);
35159 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_DMA]);
35160 sarea_priv->last_enqueue = dev_priv->counter - 1;
35161 sarea_priv->last_dispatch = (int)hw_status[5];
35162
35163 @@ -1106,8 +1106,8 @@ static int i810_dma_mc(struct drm_device *dev, void *data,
35164 i810_dma_dispatch_mc(dev, dma->buflist[mc->idx], mc->used,
35165 mc->last_render);
35166
35167 - atomic_add(mc->used, &dev->counts[_DRM_STAT_SECONDARY]);
35168 - atomic_inc(&dev->counts[_DRM_STAT_DMA]);
35169 + atomic_add_unchecked(mc->used, &dev->counts[_DRM_STAT_SECONDARY]);
35170 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_DMA]);
35171 sarea_priv->last_enqueue = dev_priv->counter - 1;
35172 sarea_priv->last_dispatch = (int)hw_status[5];
35173
35174 diff --git a/drivers/gpu/drm/i810/i810_drv.h b/drivers/gpu/drm/i810/i810_drv.h
35175 index 6e0acad..93c8289 100644
35176 --- a/drivers/gpu/drm/i810/i810_drv.h
35177 +++ b/drivers/gpu/drm/i810/i810_drv.h
35178 @@ -108,8 +108,8 @@ typedef struct drm_i810_private {
35179 int page_flipping;
35180
35181 wait_queue_head_t irq_queue;
35182 - atomic_t irq_received;
35183 - atomic_t irq_emitted;
35184 + atomic_unchecked_t irq_received;
35185 + atomic_unchecked_t irq_emitted;
35186
35187 int front_offset;
35188 } drm_i810_private_t;
35189 diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
35190 index 7299ea4..5314487 100644
35191 --- a/drivers/gpu/drm/i915/i915_debugfs.c
35192 +++ b/drivers/gpu/drm/i915/i915_debugfs.c
35193 @@ -499,7 +499,7 @@ static int i915_interrupt_info(struct seq_file *m, void *data)
35194 I915_READ(GTIMR));
35195 }
35196 seq_printf(m, "Interrupts received: %d\n",
35197 - atomic_read(&dev_priv->irq_received));
35198 + atomic_read_unchecked(&dev_priv->irq_received));
35199 for_each_ring(ring, dev_priv, i) {
35200 if (IS_GEN6(dev) || IS_GEN7(dev)) {
35201 seq_printf(m,
35202 diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
35203 index 4fa6beb..f930fec 100644
35204 --- a/drivers/gpu/drm/i915/i915_dma.c
35205 +++ b/drivers/gpu/drm/i915/i915_dma.c
35206 @@ -1259,7 +1259,7 @@ static bool i915_switcheroo_can_switch(struct pci_dev *pdev)
35207 bool can_switch;
35208
35209 spin_lock(&dev->count_lock);
35210 - can_switch = (dev->open_count == 0);
35211 + can_switch = (local_read(&dev->open_count) == 0);
35212 spin_unlock(&dev->count_lock);
35213 return can_switch;
35214 }
35215 diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
35216 index ef99b1c..09ce7fb 100644
35217 --- a/drivers/gpu/drm/i915/i915_drv.h
35218 +++ b/drivers/gpu/drm/i915/i915_drv.h
35219 @@ -893,7 +893,7 @@ typedef struct drm_i915_private {
35220 drm_dma_handle_t *status_page_dmah;
35221 struct resource mch_res;
35222
35223 - atomic_t irq_received;
35224 + atomic_unchecked_t irq_received;
35225
35226 /* protects the irq masks */
35227 spinlock_t irq_lock;
35228 @@ -1775,7 +1775,7 @@ extern struct i2c_adapter *intel_gmbus_get_adapter(
35229 struct drm_i915_private *dev_priv, unsigned port);
35230 extern void intel_gmbus_set_speed(struct i2c_adapter *adapter, int speed);
35231 extern void intel_gmbus_force_bit(struct i2c_adapter *adapter, bool force_bit);
35232 -extern inline bool intel_gmbus_is_forced_bit(struct i2c_adapter *adapter)
35233 +static inline bool intel_gmbus_is_forced_bit(struct i2c_adapter *adapter)
35234 {
35235 return container_of(adapter, struct intel_gmbus, adapter)->force_bit;
35236 }
35237 diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
35238 index 9a48e1a..f0cbc3e 100644
35239 --- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c
35240 +++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
35241 @@ -729,9 +729,9 @@ i915_gem_check_execbuffer(struct drm_i915_gem_execbuffer2 *exec)
35242
35243 static int
35244 validate_exec_list(struct drm_i915_gem_exec_object2 *exec,
35245 - int count)
35246 + unsigned int count)
35247 {
35248 - int i;
35249 + unsigned int i;
35250 int relocs_total = 0;
35251 int relocs_max = INT_MAX / sizeof(struct drm_i915_gem_relocation_entry);
35252
35253 @@ -1195,7 +1195,7 @@ i915_gem_execbuffer2(struct drm_device *dev, void *data,
35254 return -ENOMEM;
35255 }
35256 ret = copy_from_user(exec2_list,
35257 - (struct drm_i915_relocation_entry __user *)
35258 + (struct drm_i915_gem_exec_object2 __user *)
35259 (uintptr_t) args->buffers_ptr,
35260 sizeof(*exec2_list) * args->buffer_count);
35261 if (ret != 0) {
35262 diff --git a/drivers/gpu/drm/i915/i915_ioc32.c b/drivers/gpu/drm/i915/i915_ioc32.c
35263 index 3c59584..500f2e9 100644
35264 --- a/drivers/gpu/drm/i915/i915_ioc32.c
35265 +++ b/drivers/gpu/drm/i915/i915_ioc32.c
35266 @@ -181,7 +181,7 @@ static int compat_i915_alloc(struct file *file, unsigned int cmd,
35267 (unsigned long)request);
35268 }
35269
35270 -static drm_ioctl_compat_t *i915_compat_ioctls[] = {
35271 +static drm_ioctl_compat_t i915_compat_ioctls[] = {
35272 [DRM_I915_BATCHBUFFER] = compat_i915_batchbuffer,
35273 [DRM_I915_CMDBUFFER] = compat_i915_cmdbuffer,
35274 [DRM_I915_GETPARAM] = compat_i915_getparam,
35275 @@ -202,18 +202,15 @@ static drm_ioctl_compat_t *i915_compat_ioctls[] = {
35276 long i915_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
35277 {
35278 unsigned int nr = DRM_IOCTL_NR(cmd);
35279 - drm_ioctl_compat_t *fn = NULL;
35280 int ret;
35281
35282 if (nr < DRM_COMMAND_BASE)
35283 return drm_compat_ioctl(filp, cmd, arg);
35284
35285 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(i915_compat_ioctls))
35286 - fn = i915_compat_ioctls[nr - DRM_COMMAND_BASE];
35287 -
35288 - if (fn != NULL)
35289 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(i915_compat_ioctls)) {
35290 + drm_ioctl_compat_t fn = i915_compat_ioctls[nr - DRM_COMMAND_BASE];
35291 ret = (*fn) (filp, cmd, arg);
35292 - else
35293 + } else
35294 ret = drm_ioctl(filp, cmd, arg);
35295
35296 return ret;
35297 diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
35298 index 3c7bb04..182e049 100644
35299 --- a/drivers/gpu/drm/i915/i915_irq.c
35300 +++ b/drivers/gpu/drm/i915/i915_irq.c
35301 @@ -549,7 +549,7 @@ static irqreturn_t valleyview_irq_handler(int irq, void *arg)
35302 int pipe;
35303 u32 pipe_stats[I915_MAX_PIPES];
35304
35305 - atomic_inc(&dev_priv->irq_received);
35306 + atomic_inc_unchecked(&dev_priv->irq_received);
35307
35308 while (true) {
35309 iir = I915_READ(VLV_IIR);
35310 @@ -705,7 +705,7 @@ static irqreturn_t ivybridge_irq_handler(int irq, void *arg)
35311 irqreturn_t ret = IRQ_NONE;
35312 int i;
35313
35314 - atomic_inc(&dev_priv->irq_received);
35315 + atomic_inc_unchecked(&dev_priv->irq_received);
35316
35317 /* disable master interrupt before clearing iir */
35318 de_ier = I915_READ(DEIER);
35319 @@ -791,7 +791,7 @@ static irqreturn_t ironlake_irq_handler(int irq, void *arg)
35320 int ret = IRQ_NONE;
35321 u32 de_iir, gt_iir, de_ier, pm_iir, sde_ier;
35322
35323 - atomic_inc(&dev_priv->irq_received);
35324 + atomic_inc_unchecked(&dev_priv->irq_received);
35325
35326 /* disable master interrupt before clearing iir */
35327 de_ier = I915_READ(DEIER);
35328 @@ -1886,7 +1886,7 @@ static void ironlake_irq_preinstall(struct drm_device *dev)
35329 {
35330 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35331
35332 - atomic_set(&dev_priv->irq_received, 0);
35333 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35334
35335 I915_WRITE(HWSTAM, 0xeffe);
35336
35337 @@ -1912,7 +1912,7 @@ static void valleyview_irq_preinstall(struct drm_device *dev)
35338 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35339 int pipe;
35340
35341 - atomic_set(&dev_priv->irq_received, 0);
35342 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35343
35344 /* VLV magic */
35345 I915_WRITE(VLV_IMR, 0);
35346 @@ -2208,7 +2208,7 @@ static void i8xx_irq_preinstall(struct drm_device * dev)
35347 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35348 int pipe;
35349
35350 - atomic_set(&dev_priv->irq_received, 0);
35351 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35352
35353 for_each_pipe(pipe)
35354 I915_WRITE(PIPESTAT(pipe), 0);
35355 @@ -2259,7 +2259,7 @@ static irqreturn_t i8xx_irq_handler(int irq, void *arg)
35356 I915_DISPLAY_PLANE_A_FLIP_PENDING_INTERRUPT |
35357 I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT;
35358
35359 - atomic_inc(&dev_priv->irq_received);
35360 + atomic_inc_unchecked(&dev_priv->irq_received);
35361
35362 iir = I915_READ16(IIR);
35363 if (iir == 0)
35364 @@ -2344,7 +2344,7 @@ static void i915_irq_preinstall(struct drm_device * dev)
35365 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35366 int pipe;
35367
35368 - atomic_set(&dev_priv->irq_received, 0);
35369 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35370
35371 if (I915_HAS_HOTPLUG(dev)) {
35372 I915_WRITE(PORT_HOTPLUG_EN, 0);
35373 @@ -2448,7 +2448,7 @@ static irqreturn_t i915_irq_handler(int irq, void *arg)
35374 };
35375 int pipe, ret = IRQ_NONE;
35376
35377 - atomic_inc(&dev_priv->irq_received);
35378 + atomic_inc_unchecked(&dev_priv->irq_received);
35379
35380 iir = I915_READ(IIR);
35381 do {
35382 @@ -2574,7 +2574,7 @@ static void i965_irq_preinstall(struct drm_device * dev)
35383 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35384 int pipe;
35385
35386 - atomic_set(&dev_priv->irq_received, 0);
35387 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35388
35389 I915_WRITE(PORT_HOTPLUG_EN, 0);
35390 I915_WRITE(PORT_HOTPLUG_STAT, I915_READ(PORT_HOTPLUG_STAT));
35391 @@ -2690,7 +2690,7 @@ static irqreturn_t i965_irq_handler(int irq, void *arg)
35392 int irq_received;
35393 int ret = IRQ_NONE, pipe;
35394
35395 - atomic_inc(&dev_priv->irq_received);
35396 + atomic_inc_unchecked(&dev_priv->irq_received);
35397
35398 iir = I915_READ(IIR);
35399
35400 diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
35401 index c2d173a..f4357cc 100644
35402 --- a/drivers/gpu/drm/i915/intel_display.c
35403 +++ b/drivers/gpu/drm/i915/intel_display.c
35404 @@ -8722,13 +8722,13 @@ struct intel_quirk {
35405 int subsystem_vendor;
35406 int subsystem_device;
35407 void (*hook)(struct drm_device *dev);
35408 -};
35409 +} __do_const;
35410
35411 /* For systems that don't have a meaningful PCI subdevice/subvendor ID */
35412 struct intel_dmi_quirk {
35413 void (*hook)(struct drm_device *dev);
35414 const struct dmi_system_id (*dmi_id_list)[];
35415 -};
35416 +} __do_const;
35417
35418 static int intel_dmi_reverse_brightness(const struct dmi_system_id *id)
35419 {
35420 @@ -8736,18 +8736,20 @@ static int intel_dmi_reverse_brightness(const struct dmi_system_id *id)
35421 return 1;
35422 }
35423
35424 -static const struct intel_dmi_quirk intel_dmi_quirks[] = {
35425 +static const struct dmi_system_id intel_dmi_quirks_table[] = {
35426 {
35427 - .dmi_id_list = &(const struct dmi_system_id[]) {
35428 - {
35429 - .callback = intel_dmi_reverse_brightness,
35430 - .ident = "NCR Corporation",
35431 - .matches = {DMI_MATCH(DMI_SYS_VENDOR, "NCR Corporation"),
35432 - DMI_MATCH(DMI_PRODUCT_NAME, ""),
35433 - },
35434 - },
35435 - { } /* terminating entry */
35436 + .callback = intel_dmi_reverse_brightness,
35437 + .ident = "NCR Corporation",
35438 + .matches = {DMI_MATCH(DMI_SYS_VENDOR, "NCR Corporation"),
35439 + DMI_MATCH(DMI_PRODUCT_NAME, ""),
35440 },
35441 + },
35442 + { } /* terminating entry */
35443 +};
35444 +
35445 +static const struct intel_dmi_quirk intel_dmi_quirks[] = {
35446 + {
35447 + .dmi_id_list = &intel_dmi_quirks_table,
35448 .hook = quirk_invert_brightness,
35449 },
35450 };
35451 diff --git a/drivers/gpu/drm/mga/mga_drv.h b/drivers/gpu/drm/mga/mga_drv.h
35452 index 54558a0..2d97005 100644
35453 --- a/drivers/gpu/drm/mga/mga_drv.h
35454 +++ b/drivers/gpu/drm/mga/mga_drv.h
35455 @@ -120,9 +120,9 @@ typedef struct drm_mga_private {
35456 u32 clear_cmd;
35457 u32 maccess;
35458
35459 - atomic_t vbl_received; /**< Number of vblanks received. */
35460 + atomic_unchecked_t vbl_received; /**< Number of vblanks received. */
35461 wait_queue_head_t fence_queue;
35462 - atomic_t last_fence_retired;
35463 + atomic_unchecked_t last_fence_retired;
35464 u32 next_fence_to_post;
35465
35466 unsigned int fb_cpp;
35467 diff --git a/drivers/gpu/drm/mga/mga_ioc32.c b/drivers/gpu/drm/mga/mga_ioc32.c
35468 index 709e90d..89a1c0d 100644
35469 --- a/drivers/gpu/drm/mga/mga_ioc32.c
35470 +++ b/drivers/gpu/drm/mga/mga_ioc32.c
35471 @@ -189,7 +189,7 @@ static int compat_mga_dma_bootstrap(struct file *file, unsigned int cmd,
35472 return 0;
35473 }
35474
35475 -drm_ioctl_compat_t *mga_compat_ioctls[] = {
35476 +drm_ioctl_compat_t mga_compat_ioctls[] = {
35477 [DRM_MGA_INIT] = compat_mga_init,
35478 [DRM_MGA_GETPARAM] = compat_mga_getparam,
35479 [DRM_MGA_DMA_BOOTSTRAP] = compat_mga_dma_bootstrap,
35480 @@ -207,18 +207,15 @@ drm_ioctl_compat_t *mga_compat_ioctls[] = {
35481 long mga_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
35482 {
35483 unsigned int nr = DRM_IOCTL_NR(cmd);
35484 - drm_ioctl_compat_t *fn = NULL;
35485 int ret;
35486
35487 if (nr < DRM_COMMAND_BASE)
35488 return drm_compat_ioctl(filp, cmd, arg);
35489
35490 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(mga_compat_ioctls))
35491 - fn = mga_compat_ioctls[nr - DRM_COMMAND_BASE];
35492 -
35493 - if (fn != NULL)
35494 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(mga_compat_ioctls)) {
35495 + drm_ioctl_compat_t fn = mga_compat_ioctls[nr - DRM_COMMAND_BASE];
35496 ret = (*fn) (filp, cmd, arg);
35497 - else
35498 + } else
35499 ret = drm_ioctl(filp, cmd, arg);
35500
35501 return ret;
35502 diff --git a/drivers/gpu/drm/mga/mga_irq.c b/drivers/gpu/drm/mga/mga_irq.c
35503 index 598c281..60d590e 100644
35504 --- a/drivers/gpu/drm/mga/mga_irq.c
35505 +++ b/drivers/gpu/drm/mga/mga_irq.c
35506 @@ -43,7 +43,7 @@ u32 mga_get_vblank_counter(struct drm_device *dev, int crtc)
35507 if (crtc != 0)
35508 return 0;
35509
35510 - return atomic_read(&dev_priv->vbl_received);
35511 + return atomic_read_unchecked(&dev_priv->vbl_received);
35512 }
35513
35514
35515 @@ -59,7 +59,7 @@ irqreturn_t mga_driver_irq_handler(DRM_IRQ_ARGS)
35516 /* VBLANK interrupt */
35517 if (status & MGA_VLINEPEN) {
35518 MGA_WRITE(MGA_ICLEAR, MGA_VLINEICLR);
35519 - atomic_inc(&dev_priv->vbl_received);
35520 + atomic_inc_unchecked(&dev_priv->vbl_received);
35521 drm_handle_vblank(dev, 0);
35522 handled = 1;
35523 }
35524 @@ -78,7 +78,7 @@ irqreturn_t mga_driver_irq_handler(DRM_IRQ_ARGS)
35525 if ((prim_start & ~0x03) != (prim_end & ~0x03))
35526 MGA_WRITE(MGA_PRIMEND, prim_end);
35527
35528 - atomic_inc(&dev_priv->last_fence_retired);
35529 + atomic_inc_unchecked(&dev_priv->last_fence_retired);
35530 DRM_WAKEUP(&dev_priv->fence_queue);
35531 handled = 1;
35532 }
35533 @@ -129,7 +129,7 @@ int mga_driver_fence_wait(struct drm_device *dev, unsigned int *sequence)
35534 * using fences.
35535 */
35536 DRM_WAIT_ON(ret, dev_priv->fence_queue, 3 * DRM_HZ,
35537 - (((cur_fence = atomic_read(&dev_priv->last_fence_retired))
35538 + (((cur_fence = atomic_read_unchecked(&dev_priv->last_fence_retired))
35539 - *sequence) <= (1 << 23)));
35540
35541 *sequence = cur_fence;
35542 diff --git a/drivers/gpu/drm/nouveau/nouveau_bios.c b/drivers/gpu/drm/nouveau/nouveau_bios.c
35543 index 50a6dd0..ea66ed8 100644
35544 --- a/drivers/gpu/drm/nouveau/nouveau_bios.c
35545 +++ b/drivers/gpu/drm/nouveau/nouveau_bios.c
35546 @@ -965,7 +965,7 @@ static int parse_bit_tmds_tbl_entry(struct drm_device *dev, struct nvbios *bios,
35547 struct bit_table {
35548 const char id;
35549 int (* const parse_fn)(struct drm_device *, struct nvbios *, struct bit_entry *);
35550 -};
35551 +} __no_const;
35552
35553 #define BIT_TABLE(id, funcid) ((struct bit_table){ id, parse_bit_##funcid##_tbl_entry })
35554
35555 diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.h b/drivers/gpu/drm/nouveau/nouveau_drm.h
35556 index 9c39baf..30a22be 100644
35557 --- a/drivers/gpu/drm/nouveau/nouveau_drm.h
35558 +++ b/drivers/gpu/drm/nouveau/nouveau_drm.h
35559 @@ -81,7 +81,7 @@ struct nouveau_drm {
35560 struct drm_global_reference mem_global_ref;
35561 struct ttm_bo_global_ref bo_global_ref;
35562 struct ttm_bo_device bdev;
35563 - atomic_t validate_sequence;
35564 + atomic_unchecked_t validate_sequence;
35565 int (*move)(struct nouveau_channel *,
35566 struct ttm_buffer_object *,
35567 struct ttm_mem_reg *, struct ttm_mem_reg *);
35568 diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c b/drivers/gpu/drm/nouveau/nouveau_gem.c
35569 index b4b4d0c..b7edc15 100644
35570 --- a/drivers/gpu/drm/nouveau/nouveau_gem.c
35571 +++ b/drivers/gpu/drm/nouveau/nouveau_gem.c
35572 @@ -322,7 +322,7 @@ validate_init(struct nouveau_channel *chan, struct drm_file *file_priv,
35573 int ret, i;
35574 struct nouveau_bo *res_bo = NULL;
35575
35576 - sequence = atomic_add_return(1, &drm->ttm.validate_sequence);
35577 + sequence = atomic_add_return_unchecked(1, &drm->ttm.validate_sequence);
35578 retry:
35579 if (++trycnt > 100000) {
35580 NV_ERROR(cli, "%s failed and gave up.\n", __func__);
35581 @@ -359,7 +359,7 @@ retry:
35582 if (ret) {
35583 validate_fini(op, NULL);
35584 if (unlikely(ret == -EAGAIN)) {
35585 - sequence = atomic_add_return(1, &drm->ttm.validate_sequence);
35586 + sequence = atomic_add_return_unchecked(1, &drm->ttm.validate_sequence);
35587 ret = ttm_bo_reserve_slowpath(&nvbo->bo, true,
35588 sequence);
35589 if (!ret)
35590 diff --git a/drivers/gpu/drm/nouveau/nouveau_ioc32.c b/drivers/gpu/drm/nouveau/nouveau_ioc32.c
35591 index 08214bc..9208577 100644
35592 --- a/drivers/gpu/drm/nouveau/nouveau_ioc32.c
35593 +++ b/drivers/gpu/drm/nouveau/nouveau_ioc32.c
35594 @@ -50,7 +50,7 @@ long nouveau_compat_ioctl(struct file *filp, unsigned int cmd,
35595 unsigned long arg)
35596 {
35597 unsigned int nr = DRM_IOCTL_NR(cmd);
35598 - drm_ioctl_compat_t *fn = NULL;
35599 + drm_ioctl_compat_t fn = NULL;
35600 int ret;
35601
35602 if (nr < DRM_COMMAND_BASE)
35603 diff --git a/drivers/gpu/drm/nouveau/nouveau_vga.c b/drivers/gpu/drm/nouveau/nouveau_vga.c
35604 index 25d3495..d81aaf6 100644
35605 --- a/drivers/gpu/drm/nouveau/nouveau_vga.c
35606 +++ b/drivers/gpu/drm/nouveau/nouveau_vga.c
35607 @@ -62,7 +62,7 @@ nouveau_switcheroo_can_switch(struct pci_dev *pdev)
35608 bool can_switch;
35609
35610 spin_lock(&dev->count_lock);
35611 - can_switch = (dev->open_count == 0);
35612 + can_switch = (local_read(&dev->open_count) == 0);
35613 spin_unlock(&dev->count_lock);
35614 return can_switch;
35615 }
35616 diff --git a/drivers/gpu/drm/r128/r128_cce.c b/drivers/gpu/drm/r128/r128_cce.c
35617 index d4660cf..70dbe65 100644
35618 --- a/drivers/gpu/drm/r128/r128_cce.c
35619 +++ b/drivers/gpu/drm/r128/r128_cce.c
35620 @@ -377,7 +377,7 @@ static int r128_do_init_cce(struct drm_device *dev, drm_r128_init_t *init)
35621
35622 /* GH: Simple idle check.
35623 */
35624 - atomic_set(&dev_priv->idle_count, 0);
35625 + atomic_set_unchecked(&dev_priv->idle_count, 0);
35626
35627 /* We don't support anything other than bus-mastering ring mode,
35628 * but the ring can be in either AGP or PCI space for the ring
35629 diff --git a/drivers/gpu/drm/r128/r128_drv.h b/drivers/gpu/drm/r128/r128_drv.h
35630 index 930c71b..499aded 100644
35631 --- a/drivers/gpu/drm/r128/r128_drv.h
35632 +++ b/drivers/gpu/drm/r128/r128_drv.h
35633 @@ -90,14 +90,14 @@ typedef struct drm_r128_private {
35634 int is_pci;
35635 unsigned long cce_buffers_offset;
35636
35637 - atomic_t idle_count;
35638 + atomic_unchecked_t idle_count;
35639
35640 int page_flipping;
35641 int current_page;
35642 u32 crtc_offset;
35643 u32 crtc_offset_cntl;
35644
35645 - atomic_t vbl_received;
35646 + atomic_unchecked_t vbl_received;
35647
35648 u32 color_fmt;
35649 unsigned int front_offset;
35650 diff --git a/drivers/gpu/drm/r128/r128_ioc32.c b/drivers/gpu/drm/r128/r128_ioc32.c
35651 index a954c54..9cc595c 100644
35652 --- a/drivers/gpu/drm/r128/r128_ioc32.c
35653 +++ b/drivers/gpu/drm/r128/r128_ioc32.c
35654 @@ -177,7 +177,7 @@ static int compat_r128_getparam(struct file *file, unsigned int cmd,
35655 return drm_ioctl(file, DRM_IOCTL_R128_GETPARAM, (unsigned long)getparam);
35656 }
35657
35658 -drm_ioctl_compat_t *r128_compat_ioctls[] = {
35659 +drm_ioctl_compat_t r128_compat_ioctls[] = {
35660 [DRM_R128_INIT] = compat_r128_init,
35661 [DRM_R128_DEPTH] = compat_r128_depth,
35662 [DRM_R128_STIPPLE] = compat_r128_stipple,
35663 @@ -196,18 +196,15 @@ drm_ioctl_compat_t *r128_compat_ioctls[] = {
35664 long r128_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
35665 {
35666 unsigned int nr = DRM_IOCTL_NR(cmd);
35667 - drm_ioctl_compat_t *fn = NULL;
35668 int ret;
35669
35670 if (nr < DRM_COMMAND_BASE)
35671 return drm_compat_ioctl(filp, cmd, arg);
35672
35673 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(r128_compat_ioctls))
35674 - fn = r128_compat_ioctls[nr - DRM_COMMAND_BASE];
35675 -
35676 - if (fn != NULL)
35677 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(r128_compat_ioctls)) {
35678 + drm_ioctl_compat_t fn = r128_compat_ioctls[nr - DRM_COMMAND_BASE];
35679 ret = (*fn) (filp, cmd, arg);
35680 - else
35681 + } else
35682 ret = drm_ioctl(filp, cmd, arg);
35683
35684 return ret;
35685 diff --git a/drivers/gpu/drm/r128/r128_irq.c b/drivers/gpu/drm/r128/r128_irq.c
35686 index 2ea4f09..d391371 100644
35687 --- a/drivers/gpu/drm/r128/r128_irq.c
35688 +++ b/drivers/gpu/drm/r128/r128_irq.c
35689 @@ -41,7 +41,7 @@ u32 r128_get_vblank_counter(struct drm_device *dev, int crtc)
35690 if (crtc != 0)
35691 return 0;
35692
35693 - return atomic_read(&dev_priv->vbl_received);
35694 + return atomic_read_unchecked(&dev_priv->vbl_received);
35695 }
35696
35697 irqreturn_t r128_driver_irq_handler(DRM_IRQ_ARGS)
35698 @@ -55,7 +55,7 @@ irqreturn_t r128_driver_irq_handler(DRM_IRQ_ARGS)
35699 /* VBLANK interrupt */
35700 if (status & R128_CRTC_VBLANK_INT) {
35701 R128_WRITE(R128_GEN_INT_STATUS, R128_CRTC_VBLANK_INT_AK);
35702 - atomic_inc(&dev_priv->vbl_received);
35703 + atomic_inc_unchecked(&dev_priv->vbl_received);
35704 drm_handle_vblank(dev, 0);
35705 return IRQ_HANDLED;
35706 }
35707 diff --git a/drivers/gpu/drm/r128/r128_state.c b/drivers/gpu/drm/r128/r128_state.c
35708 index 19bb7e6..de7e2a2 100644
35709 --- a/drivers/gpu/drm/r128/r128_state.c
35710 +++ b/drivers/gpu/drm/r128/r128_state.c
35711 @@ -320,10 +320,10 @@ static void r128_clear_box(drm_r128_private_t *dev_priv,
35712
35713 static void r128_cce_performance_boxes(drm_r128_private_t *dev_priv)
35714 {
35715 - if (atomic_read(&dev_priv->idle_count) == 0)
35716 + if (atomic_read_unchecked(&dev_priv->idle_count) == 0)
35717 r128_clear_box(dev_priv, 64, 4, 8, 8, 0, 255, 0);
35718 else
35719 - atomic_set(&dev_priv->idle_count, 0);
35720 + atomic_set_unchecked(&dev_priv->idle_count, 0);
35721 }
35722
35723 #endif
35724 diff --git a/drivers/gpu/drm/radeon/mkregtable.c b/drivers/gpu/drm/radeon/mkregtable.c
35725 index 5a82b6b..9e69c73 100644
35726 --- a/drivers/gpu/drm/radeon/mkregtable.c
35727 +++ b/drivers/gpu/drm/radeon/mkregtable.c
35728 @@ -637,14 +637,14 @@ static int parser_auth(struct table *t, const char *filename)
35729 regex_t mask_rex;
35730 regmatch_t match[4];
35731 char buf[1024];
35732 - size_t end;
35733 + long end;
35734 int len;
35735 int done = 0;
35736 int r;
35737 unsigned o;
35738 struct offset *offset;
35739 char last_reg_s[10];
35740 - int last_reg;
35741 + unsigned long last_reg;
35742
35743 if (regcomp
35744 (&mask_rex, "(0x[0-9a-fA-F]*) *([_a-zA-Z0-9]*)", REG_EXTENDED)) {
35745 diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c
35746 index 44b8034..cc722fd 100644
35747 --- a/drivers/gpu/drm/radeon/radeon_device.c
35748 +++ b/drivers/gpu/drm/radeon/radeon_device.c
35749 @@ -977,7 +977,7 @@ static bool radeon_switcheroo_can_switch(struct pci_dev *pdev)
35750 bool can_switch;
35751
35752 spin_lock(&dev->count_lock);
35753 - can_switch = (dev->open_count == 0);
35754 + can_switch = (local_read(&dev->open_count) == 0);
35755 spin_unlock(&dev->count_lock);
35756 return can_switch;
35757 }
35758 diff --git a/drivers/gpu/drm/radeon/radeon_drv.h b/drivers/gpu/drm/radeon/radeon_drv.h
35759 index b369d42..8dd04eb 100644
35760 --- a/drivers/gpu/drm/radeon/radeon_drv.h
35761 +++ b/drivers/gpu/drm/radeon/radeon_drv.h
35762 @@ -258,7 +258,7 @@ typedef struct drm_radeon_private {
35763
35764 /* SW interrupt */
35765 wait_queue_head_t swi_queue;
35766 - atomic_t swi_emitted;
35767 + atomic_unchecked_t swi_emitted;
35768 int vblank_crtc;
35769 uint32_t irq_enable_reg;
35770 uint32_t r500_disp_irq_reg;
35771 diff --git a/drivers/gpu/drm/radeon/radeon_ioc32.c b/drivers/gpu/drm/radeon/radeon_ioc32.c
35772 index c180df8..5fd8186 100644
35773 --- a/drivers/gpu/drm/radeon/radeon_ioc32.c
35774 +++ b/drivers/gpu/drm/radeon/radeon_ioc32.c
35775 @@ -358,7 +358,7 @@ static int compat_radeon_cp_setparam(struct file *file, unsigned int cmd,
35776 request = compat_alloc_user_space(sizeof(*request));
35777 if (!access_ok(VERIFY_WRITE, request, sizeof(*request))
35778 || __put_user(req32.param, &request->param)
35779 - || __put_user((void __user *)(unsigned long)req32.value,
35780 + || __put_user((unsigned long)req32.value,
35781 &request->value))
35782 return -EFAULT;
35783
35784 @@ -368,7 +368,7 @@ static int compat_radeon_cp_setparam(struct file *file, unsigned int cmd,
35785 #define compat_radeon_cp_setparam NULL
35786 #endif /* X86_64 || IA64 */
35787
35788 -static drm_ioctl_compat_t *radeon_compat_ioctls[] = {
35789 +static drm_ioctl_compat_t radeon_compat_ioctls[] = {
35790 [DRM_RADEON_CP_INIT] = compat_radeon_cp_init,
35791 [DRM_RADEON_CLEAR] = compat_radeon_cp_clear,
35792 [DRM_RADEON_STIPPLE] = compat_radeon_cp_stipple,
35793 @@ -393,18 +393,15 @@ static drm_ioctl_compat_t *radeon_compat_ioctls[] = {
35794 long radeon_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
35795 {
35796 unsigned int nr = DRM_IOCTL_NR(cmd);
35797 - drm_ioctl_compat_t *fn = NULL;
35798 int ret;
35799
35800 if (nr < DRM_COMMAND_BASE)
35801 return drm_compat_ioctl(filp, cmd, arg);
35802
35803 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(radeon_compat_ioctls))
35804 - fn = radeon_compat_ioctls[nr - DRM_COMMAND_BASE];
35805 -
35806 - if (fn != NULL)
35807 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(radeon_compat_ioctls)) {
35808 + drm_ioctl_compat_t fn = radeon_compat_ioctls[nr - DRM_COMMAND_BASE];
35809 ret = (*fn) (filp, cmd, arg);
35810 - else
35811 + } else
35812 ret = drm_ioctl(filp, cmd, arg);
35813
35814 return ret;
35815 diff --git a/drivers/gpu/drm/radeon/radeon_irq.c b/drivers/gpu/drm/radeon/radeon_irq.c
35816 index 8d68e97..9dcfed8 100644
35817 --- a/drivers/gpu/drm/radeon/radeon_irq.c
35818 +++ b/drivers/gpu/drm/radeon/radeon_irq.c
35819 @@ -226,8 +226,8 @@ static int radeon_emit_irq(struct drm_device * dev)
35820 unsigned int ret;
35821 RING_LOCALS;
35822
35823 - atomic_inc(&dev_priv->swi_emitted);
35824 - ret = atomic_read(&dev_priv->swi_emitted);
35825 + atomic_inc_unchecked(&dev_priv->swi_emitted);
35826 + ret = atomic_read_unchecked(&dev_priv->swi_emitted);
35827
35828 BEGIN_RING(4);
35829 OUT_RING_REG(RADEON_LAST_SWI_REG, ret);
35830 @@ -353,7 +353,7 @@ int radeon_driver_irq_postinstall(struct drm_device *dev)
35831 drm_radeon_private_t *dev_priv =
35832 (drm_radeon_private_t *) dev->dev_private;
35833
35834 - atomic_set(&dev_priv->swi_emitted, 0);
35835 + atomic_set_unchecked(&dev_priv->swi_emitted, 0);
35836 DRM_INIT_WAITQUEUE(&dev_priv->swi_queue);
35837
35838 dev->max_vblank_count = 0x001fffff;
35839 diff --git a/drivers/gpu/drm/radeon/radeon_state.c b/drivers/gpu/drm/radeon/radeon_state.c
35840 index 4d20910..6726b6d 100644
35841 --- a/drivers/gpu/drm/radeon/radeon_state.c
35842 +++ b/drivers/gpu/drm/radeon/radeon_state.c
35843 @@ -2168,7 +2168,7 @@ static int radeon_cp_clear(struct drm_device *dev, void *data, struct drm_file *
35844 if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS)
35845 sarea_priv->nbox = RADEON_NR_SAREA_CLIPRECTS;
35846
35847 - if (DRM_COPY_FROM_USER(&depth_boxes, clear->depth_boxes,
35848 + if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS || DRM_COPY_FROM_USER(&depth_boxes, clear->depth_boxes,
35849 sarea_priv->nbox * sizeof(depth_boxes[0])))
35850 return -EFAULT;
35851
35852 @@ -3031,7 +3031,7 @@ static int radeon_cp_getparam(struct drm_device *dev, void *data, struct drm_fil
35853 {
35854 drm_radeon_private_t *dev_priv = dev->dev_private;
35855 drm_radeon_getparam_t *param = data;
35856 - int value;
35857 + int value = 0;
35858
35859 DRM_DEBUG("pid=%d\n", DRM_CURRENTPID);
35860
35861 diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
35862 index 6c0ce89..66f6d65 100644
35863 --- a/drivers/gpu/drm/radeon/radeon_ttm.c
35864 +++ b/drivers/gpu/drm/radeon/radeon_ttm.c
35865 @@ -782,7 +782,7 @@ void radeon_ttm_set_active_vram_size(struct radeon_device *rdev, u64 size)
35866 man->size = size >> PAGE_SHIFT;
35867 }
35868
35869 -static struct vm_operations_struct radeon_ttm_vm_ops;
35870 +static vm_operations_struct_no_const radeon_ttm_vm_ops __read_only;
35871 static const struct vm_operations_struct *ttm_vm_ops = NULL;
35872
35873 static int radeon_ttm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
35874 @@ -823,8 +823,10 @@ int radeon_mmap(struct file *filp, struct vm_area_struct *vma)
35875 }
35876 if (unlikely(ttm_vm_ops == NULL)) {
35877 ttm_vm_ops = vma->vm_ops;
35878 + pax_open_kernel();
35879 radeon_ttm_vm_ops = *ttm_vm_ops;
35880 radeon_ttm_vm_ops.fault = &radeon_ttm_fault;
35881 + pax_close_kernel();
35882 }
35883 vma->vm_ops = &radeon_ttm_vm_ops;
35884 return 0;
35885 @@ -862,28 +864,33 @@ static int radeon_ttm_debugfs_init(struct radeon_device *rdev)
35886 sprintf(radeon_mem_types_names[i], "radeon_vram_mm");
35887 else
35888 sprintf(radeon_mem_types_names[i], "radeon_gtt_mm");
35889 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
35890 - radeon_mem_types_list[i].show = &radeon_mm_dump_table;
35891 - radeon_mem_types_list[i].driver_features = 0;
35892 + pax_open_kernel();
35893 + *(const char **)&radeon_mem_types_list[i].name = radeon_mem_types_names[i];
35894 + *(void **)&radeon_mem_types_list[i].show = &radeon_mm_dump_table;
35895 + *(u32 *)&radeon_mem_types_list[i].driver_features = 0;
35896 if (i == 0)
35897 - radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_VRAM].priv;
35898 + *(void **)&radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_VRAM].priv;
35899 else
35900 - radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_TT].priv;
35901 -
35902 + *(void **)&radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_TT].priv;
35903 + pax_close_kernel();
35904 }
35905 /* Add ttm page pool to debugfs */
35906 sprintf(radeon_mem_types_names[i], "ttm_page_pool");
35907 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
35908 - radeon_mem_types_list[i].show = &ttm_page_alloc_debugfs;
35909 - radeon_mem_types_list[i].driver_features = 0;
35910 - radeon_mem_types_list[i++].data = NULL;
35911 + pax_open_kernel();
35912 + *(const char **)&radeon_mem_types_list[i].name = radeon_mem_types_names[i];
35913 + *(void **)&radeon_mem_types_list[i].show = &ttm_page_alloc_debugfs;
35914 + *(u32 *)&radeon_mem_types_list[i].driver_features = 0;
35915 + *(void **)&radeon_mem_types_list[i++].data = NULL;
35916 + pax_close_kernel();
35917 #ifdef CONFIG_SWIOTLB
35918 if (swiotlb_nr_tbl()) {
35919 sprintf(radeon_mem_types_names[i], "ttm_dma_page_pool");
35920 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
35921 - radeon_mem_types_list[i].show = &ttm_dma_page_alloc_debugfs;
35922 - radeon_mem_types_list[i].driver_features = 0;
35923 - radeon_mem_types_list[i++].data = NULL;
35924 + pax_open_kernel();
35925 + *(const char **)&radeon_mem_types_list[i].name = radeon_mem_types_names[i];
35926 + *(void **)&radeon_mem_types_list[i].show = &ttm_dma_page_alloc_debugfs;
35927 + *(u32 *)&radeon_mem_types_list[i].driver_features = 0;
35928 + *(void **)&radeon_mem_types_list[i++].data = NULL;
35929 + pax_close_kernel();
35930 }
35931 #endif
35932 return radeon_debugfs_add_files(rdev, radeon_mem_types_list, i);
35933 diff --git a/drivers/gpu/drm/radeon/rs690.c b/drivers/gpu/drm/radeon/rs690.c
35934 index 5706d2a..17aedaa 100644
35935 --- a/drivers/gpu/drm/radeon/rs690.c
35936 +++ b/drivers/gpu/drm/radeon/rs690.c
35937 @@ -304,9 +304,11 @@ static void rs690_crtc_bandwidth_compute(struct radeon_device *rdev,
35938 if (rdev->pm.max_bandwidth.full > rdev->pm.sideport_bandwidth.full &&
35939 rdev->pm.sideport_bandwidth.full)
35940 rdev->pm.max_bandwidth = rdev->pm.sideport_bandwidth;
35941 - read_delay_latency.full = dfixed_const(370 * 800 * 1000);
35942 + read_delay_latency.full = dfixed_const(800 * 1000);
35943 read_delay_latency.full = dfixed_div(read_delay_latency,
35944 rdev->pm.igp_sideport_mclk);
35945 + a.full = dfixed_const(370);
35946 + read_delay_latency.full = dfixed_mul(read_delay_latency, a);
35947 } else {
35948 if (rdev->pm.max_bandwidth.full > rdev->pm.k8_bandwidth.full &&
35949 rdev->pm.k8_bandwidth.full)
35950 diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc.c b/drivers/gpu/drm/ttm/ttm_page_alloc.c
35951 index bd2a3b4..122d9ad 100644
35952 --- a/drivers/gpu/drm/ttm/ttm_page_alloc.c
35953 +++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c
35954 @@ -394,9 +394,9 @@ static int ttm_pool_get_num_unused_pages(void)
35955 static int ttm_pool_mm_shrink(struct shrinker *shrink,
35956 struct shrink_control *sc)
35957 {
35958 - static atomic_t start_pool = ATOMIC_INIT(0);
35959 + static atomic_unchecked_t start_pool = ATOMIC_INIT(0);
35960 unsigned i;
35961 - unsigned pool_offset = atomic_add_return(1, &start_pool);
35962 + unsigned pool_offset = atomic_add_return_unchecked(1, &start_pool);
35963 struct ttm_page_pool *pool;
35964 int shrink_pages = sc->nr_to_scan;
35965
35966 diff --git a/drivers/gpu/drm/udl/udl_fb.c b/drivers/gpu/drm/udl/udl_fb.c
35967 index 9f4be3d..cbc9fcc 100644
35968 --- a/drivers/gpu/drm/udl/udl_fb.c
35969 +++ b/drivers/gpu/drm/udl/udl_fb.c
35970 @@ -367,7 +367,6 @@ static int udl_fb_release(struct fb_info *info, int user)
35971 fb_deferred_io_cleanup(info);
35972 kfree(info->fbdefio);
35973 info->fbdefio = NULL;
35974 - info->fbops->fb_mmap = udl_fb_mmap;
35975 }
35976
35977 pr_warn("released /dev/fb%d user=%d count=%d\n",
35978 diff --git a/drivers/gpu/drm/via/via_drv.h b/drivers/gpu/drm/via/via_drv.h
35979 index 893a650..6190d3b 100644
35980 --- a/drivers/gpu/drm/via/via_drv.h
35981 +++ b/drivers/gpu/drm/via/via_drv.h
35982 @@ -51,7 +51,7 @@ typedef struct drm_via_ring_buffer {
35983 typedef uint32_t maskarray_t[5];
35984
35985 typedef struct drm_via_irq {
35986 - atomic_t irq_received;
35987 + atomic_unchecked_t irq_received;
35988 uint32_t pending_mask;
35989 uint32_t enable_mask;
35990 wait_queue_head_t irq_queue;
35991 @@ -75,7 +75,7 @@ typedef struct drm_via_private {
35992 struct timeval last_vblank;
35993 int last_vblank_valid;
35994 unsigned usec_per_vblank;
35995 - atomic_t vbl_received;
35996 + atomic_unchecked_t vbl_received;
35997 drm_via_state_t hc_state;
35998 char pci_buf[VIA_PCI_BUF_SIZE];
35999 const uint32_t *fire_offsets[VIA_FIRE_BUF_SIZE];
36000 diff --git a/drivers/gpu/drm/via/via_irq.c b/drivers/gpu/drm/via/via_irq.c
36001 index ac98964..5dbf512 100644
36002 --- a/drivers/gpu/drm/via/via_irq.c
36003 +++ b/drivers/gpu/drm/via/via_irq.c
36004 @@ -101,7 +101,7 @@ u32 via_get_vblank_counter(struct drm_device *dev, int crtc)
36005 if (crtc != 0)
36006 return 0;
36007
36008 - return atomic_read(&dev_priv->vbl_received);
36009 + return atomic_read_unchecked(&dev_priv->vbl_received);
36010 }
36011
36012 irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
36013 @@ -116,8 +116,8 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
36014
36015 status = VIA_READ(VIA_REG_INTERRUPT);
36016 if (status & VIA_IRQ_VBLANK_PENDING) {
36017 - atomic_inc(&dev_priv->vbl_received);
36018 - if (!(atomic_read(&dev_priv->vbl_received) & 0x0F)) {
36019 + atomic_inc_unchecked(&dev_priv->vbl_received);
36020 + if (!(atomic_read_unchecked(&dev_priv->vbl_received) & 0x0F)) {
36021 do_gettimeofday(&cur_vblank);
36022 if (dev_priv->last_vblank_valid) {
36023 dev_priv->usec_per_vblank =
36024 @@ -127,7 +127,7 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
36025 dev_priv->last_vblank = cur_vblank;
36026 dev_priv->last_vblank_valid = 1;
36027 }
36028 - if (!(atomic_read(&dev_priv->vbl_received) & 0xFF)) {
36029 + if (!(atomic_read_unchecked(&dev_priv->vbl_received) & 0xFF)) {
36030 DRM_DEBUG("US per vblank is: %u\n",
36031 dev_priv->usec_per_vblank);
36032 }
36033 @@ -137,7 +137,7 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
36034
36035 for (i = 0; i < dev_priv->num_irqs; ++i) {
36036 if (status & cur_irq->pending_mask) {
36037 - atomic_inc(&cur_irq->irq_received);
36038 + atomic_inc_unchecked(&cur_irq->irq_received);
36039 DRM_WAKEUP(&cur_irq->irq_queue);
36040 handled = 1;
36041 if (dev_priv->irq_map[drm_via_irq_dma0_td] == i)
36042 @@ -242,11 +242,11 @@ via_driver_irq_wait(struct drm_device *dev, unsigned int irq, int force_sequence
36043 DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * DRM_HZ,
36044 ((VIA_READ(masks[irq][2]) & masks[irq][3]) ==
36045 masks[irq][4]));
36046 - cur_irq_sequence = atomic_read(&cur_irq->irq_received);
36047 + cur_irq_sequence = atomic_read_unchecked(&cur_irq->irq_received);
36048 } else {
36049 DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * DRM_HZ,
36050 (((cur_irq_sequence =
36051 - atomic_read(&cur_irq->irq_received)) -
36052 + atomic_read_unchecked(&cur_irq->irq_received)) -
36053 *sequence) <= (1 << 23)));
36054 }
36055 *sequence = cur_irq_sequence;
36056 @@ -284,7 +284,7 @@ void via_driver_irq_preinstall(struct drm_device *dev)
36057 }
36058
36059 for (i = 0; i < dev_priv->num_irqs; ++i) {
36060 - atomic_set(&cur_irq->irq_received, 0);
36061 + atomic_set_unchecked(&cur_irq->irq_received, 0);
36062 cur_irq->enable_mask = dev_priv->irq_masks[i][0];
36063 cur_irq->pending_mask = dev_priv->irq_masks[i][1];
36064 DRM_INIT_WAITQUEUE(&cur_irq->irq_queue);
36065 @@ -366,7 +366,7 @@ int via_wait_irq(struct drm_device *dev, void *data, struct drm_file *file_priv)
36066 switch (irqwait->request.type & ~VIA_IRQ_FLAGS_MASK) {
36067 case VIA_IRQ_RELATIVE:
36068 irqwait->request.sequence +=
36069 - atomic_read(&cur_irq->irq_received);
36070 + atomic_read_unchecked(&cur_irq->irq_received);
36071 irqwait->request.type &= ~_DRM_VBLANK_RELATIVE;
36072 case VIA_IRQ_ABSOLUTE:
36073 break;
36074 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
36075 index 13aeda7..4a952d1 100644
36076 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
36077 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
36078 @@ -290,7 +290,7 @@ struct vmw_private {
36079 * Fencing and IRQs.
36080 */
36081
36082 - atomic_t marker_seq;
36083 + atomic_unchecked_t marker_seq;
36084 wait_queue_head_t fence_queue;
36085 wait_queue_head_t fifo_queue;
36086 int fence_queue_waiters; /* Protected by hw_mutex */
36087 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
36088 index 3eb1486..0a47ee9 100644
36089 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
36090 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
36091 @@ -137,7 +137,7 @@ int vmw_fifo_init(struct vmw_private *dev_priv, struct vmw_fifo_state *fifo)
36092 (unsigned int) min,
36093 (unsigned int) fifo->capabilities);
36094
36095 - atomic_set(&dev_priv->marker_seq, dev_priv->last_read_seqno);
36096 + atomic_set_unchecked(&dev_priv->marker_seq, dev_priv->last_read_seqno);
36097 iowrite32(dev_priv->last_read_seqno, fifo_mem + SVGA_FIFO_FENCE);
36098 vmw_marker_queue_init(&fifo->marker_queue);
36099 return vmw_fifo_send_fence(dev_priv, &dummy);
36100 @@ -355,7 +355,7 @@ void *vmw_fifo_reserve(struct vmw_private *dev_priv, uint32_t bytes)
36101 if (reserveable)
36102 iowrite32(bytes, fifo_mem +
36103 SVGA_FIFO_RESERVED);
36104 - return fifo_mem + (next_cmd >> 2);
36105 + return (__le32 __force_kernel *)fifo_mem + (next_cmd >> 2);
36106 } else {
36107 need_bounce = true;
36108 }
36109 @@ -475,7 +475,7 @@ int vmw_fifo_send_fence(struct vmw_private *dev_priv, uint32_t *seqno)
36110
36111 fm = vmw_fifo_reserve(dev_priv, bytes);
36112 if (unlikely(fm == NULL)) {
36113 - *seqno = atomic_read(&dev_priv->marker_seq);
36114 + *seqno = atomic_read_unchecked(&dev_priv->marker_seq);
36115 ret = -ENOMEM;
36116 (void)vmw_fallback_wait(dev_priv, false, true, *seqno,
36117 false, 3*HZ);
36118 @@ -483,7 +483,7 @@ int vmw_fifo_send_fence(struct vmw_private *dev_priv, uint32_t *seqno)
36119 }
36120
36121 do {
36122 - *seqno = atomic_add_return(1, &dev_priv->marker_seq);
36123 + *seqno = atomic_add_return_unchecked(1, &dev_priv->marker_seq);
36124 } while (*seqno == 0);
36125
36126 if (!(fifo_state->capabilities & SVGA_FIFO_CAP_FENCE)) {
36127 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c b/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
36128 index c509d40..3b640c3 100644
36129 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
36130 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
36131 @@ -138,7 +138,7 @@ int vmw_present_ioctl(struct drm_device *dev, void *data,
36132 int ret;
36133
36134 num_clips = arg->num_clips;
36135 - clips_ptr = (struct drm_vmw_rect *)(unsigned long)arg->clips_ptr;
36136 + clips_ptr = (struct drm_vmw_rect __user *)(unsigned long)arg->clips_ptr;
36137
36138 if (unlikely(num_clips == 0))
36139 return 0;
36140 @@ -222,7 +222,7 @@ int vmw_present_readback_ioctl(struct drm_device *dev, void *data,
36141 int ret;
36142
36143 num_clips = arg->num_clips;
36144 - clips_ptr = (struct drm_vmw_rect *)(unsigned long)arg->clips_ptr;
36145 + clips_ptr = (struct drm_vmw_rect __user *)(unsigned long)arg->clips_ptr;
36146
36147 if (unlikely(num_clips == 0))
36148 return 0;
36149 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c b/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
36150 index 4640adb..e1384ed 100644
36151 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
36152 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
36153 @@ -107,7 +107,7 @@ bool vmw_seqno_passed(struct vmw_private *dev_priv,
36154 * emitted. Then the fence is stale and signaled.
36155 */
36156
36157 - ret = ((atomic_read(&dev_priv->marker_seq) - seqno)
36158 + ret = ((atomic_read_unchecked(&dev_priv->marker_seq) - seqno)
36159 > VMW_FENCE_WRAP);
36160
36161 return ret;
36162 @@ -138,7 +138,7 @@ int vmw_fallback_wait(struct vmw_private *dev_priv,
36163
36164 if (fifo_idle)
36165 down_read(&fifo_state->rwsem);
36166 - signal_seq = atomic_read(&dev_priv->marker_seq);
36167 + signal_seq = atomic_read_unchecked(&dev_priv->marker_seq);
36168 ret = 0;
36169
36170 for (;;) {
36171 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c b/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
36172 index 8a8725c2..afed796 100644
36173 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
36174 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
36175 @@ -151,7 +151,7 @@ int vmw_wait_lag(struct vmw_private *dev_priv,
36176 while (!vmw_lag_lt(queue, us)) {
36177 spin_lock(&queue->lock);
36178 if (list_empty(&queue->head))
36179 - seqno = atomic_read(&dev_priv->marker_seq);
36180 + seqno = atomic_read_unchecked(&dev_priv->marker_seq);
36181 else {
36182 marker = list_first_entry(&queue->head,
36183 struct vmw_marker, head);
36184 diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
36185 index e6dbf09..3dd2540 100644
36186 --- a/drivers/hid/hid-core.c
36187 +++ b/drivers/hid/hid-core.c
36188 @@ -2268,7 +2268,7 @@ EXPORT_SYMBOL_GPL(hid_ignore);
36189
36190 int hid_add_device(struct hid_device *hdev)
36191 {
36192 - static atomic_t id = ATOMIC_INIT(0);
36193 + static atomic_unchecked_t id = ATOMIC_INIT(0);
36194 int ret;
36195
36196 if (WARN_ON(hdev->status & HID_STAT_ADDED))
36197 @@ -2302,7 +2302,7 @@ int hid_add_device(struct hid_device *hdev)
36198 /* XXX hack, any other cleaner solution after the driver core
36199 * is converted to allow more than 20 bytes as the device name? */
36200 dev_set_name(&hdev->dev, "%04X:%04X:%04X.%04X", hdev->bus,
36201 - hdev->vendor, hdev->product, atomic_inc_return(&id));
36202 + hdev->vendor, hdev->product, atomic_inc_return_unchecked(&id));
36203
36204 hid_debug_register(hdev, dev_name(&hdev->dev));
36205 ret = device_add(&hdev->dev);
36206 diff --git a/drivers/hid/hid-wiimote-debug.c b/drivers/hid/hid-wiimote-debug.c
36207 index 90124ff..3761764 100644
36208 --- a/drivers/hid/hid-wiimote-debug.c
36209 +++ b/drivers/hid/hid-wiimote-debug.c
36210 @@ -66,7 +66,7 @@ static ssize_t wiidebug_eeprom_read(struct file *f, char __user *u, size_t s,
36211 else if (size == 0)
36212 return -EIO;
36213
36214 - if (copy_to_user(u, buf, size))
36215 + if (size > sizeof(buf) || copy_to_user(u, buf, size))
36216 return -EFAULT;
36217
36218 *off += size;
36219 diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
36220 index 0b122f8..b1d8160 100644
36221 --- a/drivers/hv/channel.c
36222 +++ b/drivers/hv/channel.c
36223 @@ -394,8 +394,8 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer,
36224 int ret = 0;
36225 int t;
36226
36227 - next_gpadl_handle = atomic_read(&vmbus_connection.next_gpadl_handle);
36228 - atomic_inc(&vmbus_connection.next_gpadl_handle);
36229 + next_gpadl_handle = atomic_read_unchecked(&vmbus_connection.next_gpadl_handle);
36230 + atomic_inc_unchecked(&vmbus_connection.next_gpadl_handle);
36231
36232 ret = create_gpadl_header(kbuffer, size, &msginfo, &msgcount);
36233 if (ret)
36234 diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c
36235 index 7311589..861e9ef 100644
36236 --- a/drivers/hv/hv.c
36237 +++ b/drivers/hv/hv.c
36238 @@ -112,7 +112,7 @@ static u64 do_hypercall(u64 control, void *input, void *output)
36239 u64 output_address = (output) ? virt_to_phys(output) : 0;
36240 u32 output_address_hi = output_address >> 32;
36241 u32 output_address_lo = output_address & 0xFFFFFFFF;
36242 - void *hypercall_page = hv_context.hypercall_page;
36243 + void *hypercall_page = ktva_ktla(hv_context.hypercall_page);
36244
36245 __asm__ __volatile__ ("call *%8" : "=d"(hv_status_hi),
36246 "=a"(hv_status_lo) : "d" (control_hi),
36247 diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h
36248 index 12f2f9e..679603c 100644
36249 --- a/drivers/hv/hyperv_vmbus.h
36250 +++ b/drivers/hv/hyperv_vmbus.h
36251 @@ -591,7 +591,7 @@ enum vmbus_connect_state {
36252 struct vmbus_connection {
36253 enum vmbus_connect_state conn_state;
36254
36255 - atomic_t next_gpadl_handle;
36256 + atomic_unchecked_t next_gpadl_handle;
36257
36258 /*
36259 * Represents channel interrupts. Each bit position represents a
36260 diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
36261 index bf421e0..ce2c897 100644
36262 --- a/drivers/hv/vmbus_drv.c
36263 +++ b/drivers/hv/vmbus_drv.c
36264 @@ -668,10 +668,10 @@ int vmbus_device_register(struct hv_device *child_device_obj)
36265 {
36266 int ret = 0;
36267
36268 - static atomic_t device_num = ATOMIC_INIT(0);
36269 + static atomic_unchecked_t device_num = ATOMIC_INIT(0);
36270
36271 dev_set_name(&child_device_obj->device, "vmbus_0_%d",
36272 - atomic_inc_return(&device_num));
36273 + atomic_inc_return_unchecked(&device_num));
36274
36275 child_device_obj->device.bus = &hv_bus;
36276 child_device_obj->device.parent = &hv_acpi_dev->dev;
36277 diff --git a/drivers/hwmon/acpi_power_meter.c b/drivers/hwmon/acpi_power_meter.c
36278 index 6351aba..dc4aaf4 100644
36279 --- a/drivers/hwmon/acpi_power_meter.c
36280 +++ b/drivers/hwmon/acpi_power_meter.c
36281 @@ -117,7 +117,7 @@ struct sensor_template {
36282 struct device_attribute *devattr,
36283 const char *buf, size_t count);
36284 int index;
36285 -};
36286 +} __do_const;
36287
36288 /* Averaging interval */
36289 static int update_avg_interval(struct acpi_power_meter_resource *resource)
36290 @@ -629,7 +629,7 @@ static int register_attrs(struct acpi_power_meter_resource *resource,
36291 struct sensor_template *attrs)
36292 {
36293 struct device *dev = &resource->acpi_dev->dev;
36294 - struct sensor_device_attribute *sensors =
36295 + sensor_device_attribute_no_const *sensors =
36296 &resource->sensors[resource->num_sensors];
36297 int res = 0;
36298
36299 diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
36300 index b41baff..4953e4d 100644
36301 --- a/drivers/hwmon/applesmc.c
36302 +++ b/drivers/hwmon/applesmc.c
36303 @@ -1084,7 +1084,7 @@ static int applesmc_create_nodes(struct applesmc_node_group *groups, int num)
36304 {
36305 struct applesmc_node_group *grp;
36306 struct applesmc_dev_attr *node;
36307 - struct attribute *attr;
36308 + attribute_no_const *attr;
36309 int ret, i;
36310
36311 for (grp = groups; grp->format; grp++) {
36312 diff --git a/drivers/hwmon/asus_atk0110.c b/drivers/hwmon/asus_atk0110.c
36313 index b25c643..a13460d 100644
36314 --- a/drivers/hwmon/asus_atk0110.c
36315 +++ b/drivers/hwmon/asus_atk0110.c
36316 @@ -152,10 +152,10 @@ MODULE_DEVICE_TABLE(acpi, atk_ids);
36317 struct atk_sensor_data {
36318 struct list_head list;
36319 struct atk_data *data;
36320 - struct device_attribute label_attr;
36321 - struct device_attribute input_attr;
36322 - struct device_attribute limit1_attr;
36323 - struct device_attribute limit2_attr;
36324 + device_attribute_no_const label_attr;
36325 + device_attribute_no_const input_attr;
36326 + device_attribute_no_const limit1_attr;
36327 + device_attribute_no_const limit2_attr;
36328 char label_attr_name[ATTR_NAME_SIZE];
36329 char input_attr_name[ATTR_NAME_SIZE];
36330 char limit1_attr_name[ATTR_NAME_SIZE];
36331 @@ -275,7 +275,7 @@ static ssize_t atk_name_show(struct device *dev,
36332 static struct device_attribute atk_name_attr =
36333 __ATTR(name, 0444, atk_name_show, NULL);
36334
36335 -static void atk_init_attribute(struct device_attribute *attr, char *name,
36336 +static void atk_init_attribute(device_attribute_no_const *attr, char *name,
36337 sysfs_show_func show)
36338 {
36339 sysfs_attr_init(&attr->attr);
36340 diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c
36341 index 3f1e297..a6cafb5 100644
36342 --- a/drivers/hwmon/coretemp.c
36343 +++ b/drivers/hwmon/coretemp.c
36344 @@ -791,7 +791,7 @@ static int __cpuinit coretemp_cpu_callback(struct notifier_block *nfb,
36345 return NOTIFY_OK;
36346 }
36347
36348 -static struct notifier_block coretemp_cpu_notifier __refdata = {
36349 +static struct notifier_block coretemp_cpu_notifier = {
36350 .notifier_call = coretemp_cpu_callback,
36351 };
36352
36353 diff --git a/drivers/hwmon/ibmaem.c b/drivers/hwmon/ibmaem.c
36354 index a14f634..2916ee2 100644
36355 --- a/drivers/hwmon/ibmaem.c
36356 +++ b/drivers/hwmon/ibmaem.c
36357 @@ -925,7 +925,7 @@ static int aem_register_sensors(struct aem_data *data,
36358 struct aem_rw_sensor_template *rw)
36359 {
36360 struct device *dev = &data->pdev->dev;
36361 - struct sensor_device_attribute *sensors = data->sensors;
36362 + sensor_device_attribute_no_const *sensors = data->sensors;
36363 int err;
36364
36365 /* Set up read-only sensors */
36366 diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c
36367 index 9add6092..ee7ba3f 100644
36368 --- a/drivers/hwmon/pmbus/pmbus_core.c
36369 +++ b/drivers/hwmon/pmbus/pmbus_core.c
36370 @@ -781,7 +781,7 @@ static int pmbus_add_attribute(struct pmbus_data *data, struct attribute *attr)
36371 return 0;
36372 }
36373
36374 -static void pmbus_dev_attr_init(struct device_attribute *dev_attr,
36375 +static void pmbus_dev_attr_init(device_attribute_no_const *dev_attr,
36376 const char *name,
36377 umode_t mode,
36378 ssize_t (*show)(struct device *dev,
36379 @@ -798,7 +798,7 @@ static void pmbus_dev_attr_init(struct device_attribute *dev_attr,
36380 dev_attr->store = store;
36381 }
36382
36383 -static void pmbus_attr_init(struct sensor_device_attribute *a,
36384 +static void pmbus_attr_init(sensor_device_attribute_no_const *a,
36385 const char *name,
36386 umode_t mode,
36387 ssize_t (*show)(struct device *dev,
36388 @@ -820,7 +820,7 @@ static int pmbus_add_boolean(struct pmbus_data *data,
36389 u16 reg, u8 mask)
36390 {
36391 struct pmbus_boolean *boolean;
36392 - struct sensor_device_attribute *a;
36393 + sensor_device_attribute_no_const *a;
36394
36395 boolean = devm_kzalloc(data->dev, sizeof(*boolean), GFP_KERNEL);
36396 if (!boolean)
36397 @@ -845,7 +845,7 @@ static struct pmbus_sensor *pmbus_add_sensor(struct pmbus_data *data,
36398 bool update, bool readonly)
36399 {
36400 struct pmbus_sensor *sensor;
36401 - struct device_attribute *a;
36402 + device_attribute_no_const *a;
36403
36404 sensor = devm_kzalloc(data->dev, sizeof(*sensor), GFP_KERNEL);
36405 if (!sensor)
36406 @@ -876,7 +876,7 @@ static int pmbus_add_label(struct pmbus_data *data,
36407 const char *lstring, int index)
36408 {
36409 struct pmbus_label *label;
36410 - struct device_attribute *a;
36411 + device_attribute_no_const *a;
36412
36413 label = devm_kzalloc(data->dev, sizeof(*label), GFP_KERNEL);
36414 if (!label)
36415 diff --git a/drivers/hwmon/sht15.c b/drivers/hwmon/sht15.c
36416 index 2507f90..1645765 100644
36417 --- a/drivers/hwmon/sht15.c
36418 +++ b/drivers/hwmon/sht15.c
36419 @@ -169,7 +169,7 @@ struct sht15_data {
36420 int supply_uv;
36421 bool supply_uv_valid;
36422 struct work_struct update_supply_work;
36423 - atomic_t interrupt_handled;
36424 + atomic_unchecked_t interrupt_handled;
36425 };
36426
36427 /**
36428 @@ -542,13 +542,13 @@ static int sht15_measurement(struct sht15_data *data,
36429 ret = gpio_direction_input(data->pdata->gpio_data);
36430 if (ret)
36431 return ret;
36432 - atomic_set(&data->interrupt_handled, 0);
36433 + atomic_set_unchecked(&data->interrupt_handled, 0);
36434
36435 enable_irq(gpio_to_irq(data->pdata->gpio_data));
36436 if (gpio_get_value(data->pdata->gpio_data) == 0) {
36437 disable_irq_nosync(gpio_to_irq(data->pdata->gpio_data));
36438 /* Only relevant if the interrupt hasn't occurred. */
36439 - if (!atomic_read(&data->interrupt_handled))
36440 + if (!atomic_read_unchecked(&data->interrupt_handled))
36441 schedule_work(&data->read_work);
36442 }
36443 ret = wait_event_timeout(data->wait_queue,
36444 @@ -820,7 +820,7 @@ static irqreturn_t sht15_interrupt_fired(int irq, void *d)
36445
36446 /* First disable the interrupt */
36447 disable_irq_nosync(irq);
36448 - atomic_inc(&data->interrupt_handled);
36449 + atomic_inc_unchecked(&data->interrupt_handled);
36450 /* Then schedule a reading work struct */
36451 if (data->state != SHT15_READING_NOTHING)
36452 schedule_work(&data->read_work);
36453 @@ -842,11 +842,11 @@ static void sht15_bh_read_data(struct work_struct *work_s)
36454 * If not, then start the interrupt again - care here as could
36455 * have gone low in meantime so verify it hasn't!
36456 */
36457 - atomic_set(&data->interrupt_handled, 0);
36458 + atomic_set_unchecked(&data->interrupt_handled, 0);
36459 enable_irq(gpio_to_irq(data->pdata->gpio_data));
36460 /* If still not occurred or another handler was scheduled */
36461 if (gpio_get_value(data->pdata->gpio_data)
36462 - || atomic_read(&data->interrupt_handled))
36463 + || atomic_read_unchecked(&data->interrupt_handled))
36464 return;
36465 }
36466
36467 diff --git a/drivers/hwmon/via-cputemp.c b/drivers/hwmon/via-cputemp.c
36468 index 76f157b..9c0db1b 100644
36469 --- a/drivers/hwmon/via-cputemp.c
36470 +++ b/drivers/hwmon/via-cputemp.c
36471 @@ -296,7 +296,7 @@ static int __cpuinit via_cputemp_cpu_callback(struct notifier_block *nfb,
36472 return NOTIFY_OK;
36473 }
36474
36475 -static struct notifier_block via_cputemp_cpu_notifier __refdata = {
36476 +static struct notifier_block via_cputemp_cpu_notifier = {
36477 .notifier_call = via_cputemp_cpu_callback,
36478 };
36479
36480 diff --git a/drivers/i2c/busses/i2c-amd756-s4882.c b/drivers/i2c/busses/i2c-amd756-s4882.c
36481 index 378fcb5..5e91fa8 100644
36482 --- a/drivers/i2c/busses/i2c-amd756-s4882.c
36483 +++ b/drivers/i2c/busses/i2c-amd756-s4882.c
36484 @@ -43,7 +43,7 @@
36485 extern struct i2c_adapter amd756_smbus;
36486
36487 static struct i2c_adapter *s4882_adapter;
36488 -static struct i2c_algorithm *s4882_algo;
36489 +static i2c_algorithm_no_const *s4882_algo;
36490
36491 /* Wrapper access functions for multiplexed SMBus */
36492 static DEFINE_MUTEX(amd756_lock);
36493 diff --git a/drivers/i2c/busses/i2c-nforce2-s4985.c b/drivers/i2c/busses/i2c-nforce2-s4985.c
36494 index 29015eb..af2d8e9 100644
36495 --- a/drivers/i2c/busses/i2c-nforce2-s4985.c
36496 +++ b/drivers/i2c/busses/i2c-nforce2-s4985.c
36497 @@ -41,7 +41,7 @@
36498 extern struct i2c_adapter *nforce2_smbus;
36499
36500 static struct i2c_adapter *s4985_adapter;
36501 -static struct i2c_algorithm *s4985_algo;
36502 +static i2c_algorithm_no_const *s4985_algo;
36503
36504 /* Wrapper access functions for multiplexed SMBus */
36505 static DEFINE_MUTEX(nforce2_lock);
36506 diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c
36507 index c3ccdea..5b3dc1a 100644
36508 --- a/drivers/i2c/i2c-dev.c
36509 +++ b/drivers/i2c/i2c-dev.c
36510 @@ -271,7 +271,7 @@ static noinline int i2cdev_ioctl_rdrw(struct i2c_client *client,
36511 break;
36512 }
36513
36514 - data_ptrs[i] = (u8 __user *)rdwr_pa[i].buf;
36515 + data_ptrs[i] = (u8 __force_user *)rdwr_pa[i].buf;
36516 rdwr_pa[i].buf = memdup_user(data_ptrs[i], rdwr_pa[i].len);
36517 if (IS_ERR(rdwr_pa[i].buf)) {
36518 res = PTR_ERR(rdwr_pa[i].buf);
36519 diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
36520 index 8126824..55a2798 100644
36521 --- a/drivers/ide/ide-cd.c
36522 +++ b/drivers/ide/ide-cd.c
36523 @@ -768,7 +768,7 @@ static void cdrom_do_block_pc(ide_drive_t *drive, struct request *rq)
36524 alignment = queue_dma_alignment(q) | q->dma_pad_mask;
36525 if ((unsigned long)buf & alignment
36526 || blk_rq_bytes(rq) & q->dma_pad_mask
36527 - || object_is_on_stack(buf))
36528 + || object_starts_on_stack(buf))
36529 drive->dma = 0;
36530 }
36531 }
36532 diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
36533 index 8848f16..f8e6dd8 100644
36534 --- a/drivers/iio/industrialio-core.c
36535 +++ b/drivers/iio/industrialio-core.c
36536 @@ -506,7 +506,7 @@ static ssize_t iio_write_channel_info(struct device *dev,
36537 }
36538
36539 static
36540 -int __iio_device_attr_init(struct device_attribute *dev_attr,
36541 +int __iio_device_attr_init(device_attribute_no_const *dev_attr,
36542 const char *postfix,
36543 struct iio_chan_spec const *chan,
36544 ssize_t (*readfunc)(struct device *dev,
36545 diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
36546 index 784b97c..c9ceadf 100644
36547 --- a/drivers/infiniband/core/cm.c
36548 +++ b/drivers/infiniband/core/cm.c
36549 @@ -114,7 +114,7 @@ static char const counter_group_names[CM_COUNTER_GROUPS]
36550
36551 struct cm_counter_group {
36552 struct kobject obj;
36553 - atomic_long_t counter[CM_ATTR_COUNT];
36554 + atomic_long_unchecked_t counter[CM_ATTR_COUNT];
36555 };
36556
36557 struct cm_counter_attribute {
36558 @@ -1395,7 +1395,7 @@ static void cm_dup_req_handler(struct cm_work *work,
36559 struct ib_mad_send_buf *msg = NULL;
36560 int ret;
36561
36562 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36563 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36564 counter[CM_REQ_COUNTER]);
36565
36566 /* Quick state check to discard duplicate REQs. */
36567 @@ -1779,7 +1779,7 @@ static void cm_dup_rep_handler(struct cm_work *work)
36568 if (!cm_id_priv)
36569 return;
36570
36571 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36572 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36573 counter[CM_REP_COUNTER]);
36574 ret = cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg);
36575 if (ret)
36576 @@ -1946,7 +1946,7 @@ static int cm_rtu_handler(struct cm_work *work)
36577 if (cm_id_priv->id.state != IB_CM_REP_SENT &&
36578 cm_id_priv->id.state != IB_CM_MRA_REP_RCVD) {
36579 spin_unlock_irq(&cm_id_priv->lock);
36580 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36581 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36582 counter[CM_RTU_COUNTER]);
36583 goto out;
36584 }
36585 @@ -2129,7 +2129,7 @@ static int cm_dreq_handler(struct cm_work *work)
36586 cm_id_priv = cm_acquire_id(dreq_msg->remote_comm_id,
36587 dreq_msg->local_comm_id);
36588 if (!cm_id_priv) {
36589 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36590 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36591 counter[CM_DREQ_COUNTER]);
36592 cm_issue_drep(work->port, work->mad_recv_wc);
36593 return -EINVAL;
36594 @@ -2154,7 +2154,7 @@ static int cm_dreq_handler(struct cm_work *work)
36595 case IB_CM_MRA_REP_RCVD:
36596 break;
36597 case IB_CM_TIMEWAIT:
36598 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36599 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36600 counter[CM_DREQ_COUNTER]);
36601 if (cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg))
36602 goto unlock;
36603 @@ -2168,7 +2168,7 @@ static int cm_dreq_handler(struct cm_work *work)
36604 cm_free_msg(msg);
36605 goto deref;
36606 case IB_CM_DREQ_RCVD:
36607 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36608 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36609 counter[CM_DREQ_COUNTER]);
36610 goto unlock;
36611 default:
36612 @@ -2535,7 +2535,7 @@ static int cm_mra_handler(struct cm_work *work)
36613 ib_modify_mad(cm_id_priv->av.port->mad_agent,
36614 cm_id_priv->msg, timeout)) {
36615 if (cm_id_priv->id.lap_state == IB_CM_MRA_LAP_RCVD)
36616 - atomic_long_inc(&work->port->
36617 + atomic_long_inc_unchecked(&work->port->
36618 counter_group[CM_RECV_DUPLICATES].
36619 counter[CM_MRA_COUNTER]);
36620 goto out;
36621 @@ -2544,7 +2544,7 @@ static int cm_mra_handler(struct cm_work *work)
36622 break;
36623 case IB_CM_MRA_REQ_RCVD:
36624 case IB_CM_MRA_REP_RCVD:
36625 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36626 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36627 counter[CM_MRA_COUNTER]);
36628 /* fall through */
36629 default:
36630 @@ -2706,7 +2706,7 @@ static int cm_lap_handler(struct cm_work *work)
36631 case IB_CM_LAP_IDLE:
36632 break;
36633 case IB_CM_MRA_LAP_SENT:
36634 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36635 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36636 counter[CM_LAP_COUNTER]);
36637 if (cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg))
36638 goto unlock;
36639 @@ -2722,7 +2722,7 @@ static int cm_lap_handler(struct cm_work *work)
36640 cm_free_msg(msg);
36641 goto deref;
36642 case IB_CM_LAP_RCVD:
36643 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36644 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36645 counter[CM_LAP_COUNTER]);
36646 goto unlock;
36647 default:
36648 @@ -3006,7 +3006,7 @@ static int cm_sidr_req_handler(struct cm_work *work)
36649 cur_cm_id_priv = cm_insert_remote_sidr(cm_id_priv);
36650 if (cur_cm_id_priv) {
36651 spin_unlock_irq(&cm.lock);
36652 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36653 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36654 counter[CM_SIDR_REQ_COUNTER]);
36655 goto out; /* Duplicate message. */
36656 }
36657 @@ -3218,10 +3218,10 @@ static void cm_send_handler(struct ib_mad_agent *mad_agent,
36658 if (!msg->context[0] && (attr_index != CM_REJ_COUNTER))
36659 msg->retries = 1;
36660
36661 - atomic_long_add(1 + msg->retries,
36662 + atomic_long_add_unchecked(1 + msg->retries,
36663 &port->counter_group[CM_XMIT].counter[attr_index]);
36664 if (msg->retries)
36665 - atomic_long_add(msg->retries,
36666 + atomic_long_add_unchecked(msg->retries,
36667 &port->counter_group[CM_XMIT_RETRIES].
36668 counter[attr_index]);
36669
36670 @@ -3431,7 +3431,7 @@ static void cm_recv_handler(struct ib_mad_agent *mad_agent,
36671 }
36672
36673 attr_id = be16_to_cpu(mad_recv_wc->recv_buf.mad->mad_hdr.attr_id);
36674 - atomic_long_inc(&port->counter_group[CM_RECV].
36675 + atomic_long_inc_unchecked(&port->counter_group[CM_RECV].
36676 counter[attr_id - CM_ATTR_ID_OFFSET]);
36677
36678 work = kmalloc(sizeof *work + sizeof(struct ib_sa_path_rec) * paths,
36679 @@ -3636,7 +3636,7 @@ static ssize_t cm_show_counter(struct kobject *obj, struct attribute *attr,
36680 cm_attr = container_of(attr, struct cm_counter_attribute, attr);
36681
36682 return sprintf(buf, "%ld\n",
36683 - atomic_long_read(&group->counter[cm_attr->index]));
36684 + atomic_long_read_unchecked(&group->counter[cm_attr->index]));
36685 }
36686
36687 static const struct sysfs_ops cm_counter_ops = {
36688 diff --git a/drivers/infiniband/core/fmr_pool.c b/drivers/infiniband/core/fmr_pool.c
36689 index 9f5ad7c..588cd84 100644
36690 --- a/drivers/infiniband/core/fmr_pool.c
36691 +++ b/drivers/infiniband/core/fmr_pool.c
36692 @@ -98,8 +98,8 @@ struct ib_fmr_pool {
36693
36694 struct task_struct *thread;
36695
36696 - atomic_t req_ser;
36697 - atomic_t flush_ser;
36698 + atomic_unchecked_t req_ser;
36699 + atomic_unchecked_t flush_ser;
36700
36701 wait_queue_head_t force_wait;
36702 };
36703 @@ -179,10 +179,10 @@ static int ib_fmr_cleanup_thread(void *pool_ptr)
36704 struct ib_fmr_pool *pool = pool_ptr;
36705
36706 do {
36707 - if (atomic_read(&pool->flush_ser) - atomic_read(&pool->req_ser) < 0) {
36708 + if (atomic_read_unchecked(&pool->flush_ser) - atomic_read_unchecked(&pool->req_ser) < 0) {
36709 ib_fmr_batch_release(pool);
36710
36711 - atomic_inc(&pool->flush_ser);
36712 + atomic_inc_unchecked(&pool->flush_ser);
36713 wake_up_interruptible(&pool->force_wait);
36714
36715 if (pool->flush_function)
36716 @@ -190,7 +190,7 @@ static int ib_fmr_cleanup_thread(void *pool_ptr)
36717 }
36718
36719 set_current_state(TASK_INTERRUPTIBLE);
36720 - if (atomic_read(&pool->flush_ser) - atomic_read(&pool->req_ser) >= 0 &&
36721 + if (atomic_read_unchecked(&pool->flush_ser) - atomic_read_unchecked(&pool->req_ser) >= 0 &&
36722 !kthread_should_stop())
36723 schedule();
36724 __set_current_state(TASK_RUNNING);
36725 @@ -282,8 +282,8 @@ struct ib_fmr_pool *ib_create_fmr_pool(struct ib_pd *pd,
36726 pool->dirty_watermark = params->dirty_watermark;
36727 pool->dirty_len = 0;
36728 spin_lock_init(&pool->pool_lock);
36729 - atomic_set(&pool->req_ser, 0);
36730 - atomic_set(&pool->flush_ser, 0);
36731 + atomic_set_unchecked(&pool->req_ser, 0);
36732 + atomic_set_unchecked(&pool->flush_ser, 0);
36733 init_waitqueue_head(&pool->force_wait);
36734
36735 pool->thread = kthread_run(ib_fmr_cleanup_thread,
36736 @@ -411,11 +411,11 @@ int ib_flush_fmr_pool(struct ib_fmr_pool *pool)
36737 }
36738 spin_unlock_irq(&pool->pool_lock);
36739
36740 - serial = atomic_inc_return(&pool->req_ser);
36741 + serial = atomic_inc_return_unchecked(&pool->req_ser);
36742 wake_up_process(pool->thread);
36743
36744 if (wait_event_interruptible(pool->force_wait,
36745 - atomic_read(&pool->flush_ser) - serial >= 0))
36746 + atomic_read_unchecked(&pool->flush_ser) - serial >= 0))
36747 return -EINTR;
36748
36749 return 0;
36750 @@ -525,7 +525,7 @@ int ib_fmr_pool_unmap(struct ib_pool_fmr *fmr)
36751 } else {
36752 list_add_tail(&fmr->list, &pool->dirty_list);
36753 if (++pool->dirty_len >= pool->dirty_watermark) {
36754 - atomic_inc(&pool->req_ser);
36755 + atomic_inc_unchecked(&pool->req_ser);
36756 wake_up_process(pool->thread);
36757 }
36758 }
36759 diff --git a/drivers/infiniband/hw/cxgb4/mem.c b/drivers/infiniband/hw/cxgb4/mem.c
36760 index 903a92d..9262548 100644
36761 --- a/drivers/infiniband/hw/cxgb4/mem.c
36762 +++ b/drivers/infiniband/hw/cxgb4/mem.c
36763 @@ -122,7 +122,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,
36764 int err;
36765 struct fw_ri_tpte tpt;
36766 u32 stag_idx;
36767 - static atomic_t key;
36768 + static atomic_unchecked_t key;
36769
36770 if (c4iw_fatal_error(rdev))
36771 return -EIO;
36772 @@ -139,7 +139,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,
36773 if (rdev->stats.stag.cur > rdev->stats.stag.max)
36774 rdev->stats.stag.max = rdev->stats.stag.cur;
36775 mutex_unlock(&rdev->stats.lock);
36776 - *stag = (stag_idx << 8) | (atomic_inc_return(&key) & 0xff);
36777 + *stag = (stag_idx << 8) | (atomic_inc_return_unchecked(&key) & 0xff);
36778 }
36779 PDBG("%s stag_state 0x%0x type 0x%0x pdid 0x%0x, stag_idx 0x%x\n",
36780 __func__, stag_state, type, pdid, stag_idx);
36781 diff --git a/drivers/infiniband/hw/ipath/ipath_rc.c b/drivers/infiniband/hw/ipath/ipath_rc.c
36782 index 79b3dbc..96e5fcc 100644
36783 --- a/drivers/infiniband/hw/ipath/ipath_rc.c
36784 +++ b/drivers/infiniband/hw/ipath/ipath_rc.c
36785 @@ -1868,7 +1868,7 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
36786 struct ib_atomic_eth *ateth;
36787 struct ipath_ack_entry *e;
36788 u64 vaddr;
36789 - atomic64_t *maddr;
36790 + atomic64_unchecked_t *maddr;
36791 u64 sdata;
36792 u32 rkey;
36793 u8 next;
36794 @@ -1903,11 +1903,11 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
36795 IB_ACCESS_REMOTE_ATOMIC)))
36796 goto nack_acc_unlck;
36797 /* Perform atomic OP and save result. */
36798 - maddr = (atomic64_t *) qp->r_sge.sge.vaddr;
36799 + maddr = (atomic64_unchecked_t *) qp->r_sge.sge.vaddr;
36800 sdata = be64_to_cpu(ateth->swap_data);
36801 e = &qp->s_ack_queue[qp->r_head_ack_queue];
36802 e->atomic_data = (opcode == OP(FETCH_ADD)) ?
36803 - (u64) atomic64_add_return(sdata, maddr) - sdata :
36804 + (u64) atomic64_add_return_unchecked(sdata, maddr) - sdata :
36805 (u64) cmpxchg((u64 *) qp->r_sge.sge.vaddr,
36806 be64_to_cpu(ateth->compare_data),
36807 sdata);
36808 diff --git a/drivers/infiniband/hw/ipath/ipath_ruc.c b/drivers/infiniband/hw/ipath/ipath_ruc.c
36809 index 1f95bba..9530f87 100644
36810 --- a/drivers/infiniband/hw/ipath/ipath_ruc.c
36811 +++ b/drivers/infiniband/hw/ipath/ipath_ruc.c
36812 @@ -266,7 +266,7 @@ static void ipath_ruc_loopback(struct ipath_qp *sqp)
36813 unsigned long flags;
36814 struct ib_wc wc;
36815 u64 sdata;
36816 - atomic64_t *maddr;
36817 + atomic64_unchecked_t *maddr;
36818 enum ib_wc_status send_status;
36819
36820 /*
36821 @@ -382,11 +382,11 @@ again:
36822 IB_ACCESS_REMOTE_ATOMIC)))
36823 goto acc_err;
36824 /* Perform atomic OP and save result. */
36825 - maddr = (atomic64_t *) qp->r_sge.sge.vaddr;
36826 + maddr = (atomic64_unchecked_t *) qp->r_sge.sge.vaddr;
36827 sdata = wqe->wr.wr.atomic.compare_add;
36828 *(u64 *) sqp->s_sge.sge.vaddr =
36829 (wqe->wr.opcode == IB_WR_ATOMIC_FETCH_AND_ADD) ?
36830 - (u64) atomic64_add_return(sdata, maddr) - sdata :
36831 + (u64) atomic64_add_return_unchecked(sdata, maddr) - sdata :
36832 (u64) cmpxchg((u64 *) qp->r_sge.sge.vaddr,
36833 sdata, wqe->wr.wr.atomic.swap);
36834 goto send_comp;
36835 diff --git a/drivers/infiniband/hw/mthca/mthca_cmd.c b/drivers/infiniband/hw/mthca/mthca_cmd.c
36836 index 9d3e5c1..d9afe4a 100644
36837 --- a/drivers/infiniband/hw/mthca/mthca_cmd.c
36838 +++ b/drivers/infiniband/hw/mthca/mthca_cmd.c
36839 @@ -772,7 +772,7 @@ static void mthca_setup_cmd_doorbells(struct mthca_dev *dev, u64 base)
36840 mthca_dbg(dev, "Mapped doorbell page for posting FW commands\n");
36841 }
36842
36843 -int mthca_QUERY_FW(struct mthca_dev *dev)
36844 +int __intentional_overflow(-1) mthca_QUERY_FW(struct mthca_dev *dev)
36845 {
36846 struct mthca_mailbox *mailbox;
36847 u32 *outbox;
36848 diff --git a/drivers/infiniband/hw/mthca/mthca_mr.c b/drivers/infiniband/hw/mthca/mthca_mr.c
36849 index ed9a989..e0c5871 100644
36850 --- a/drivers/infiniband/hw/mthca/mthca_mr.c
36851 +++ b/drivers/infiniband/hw/mthca/mthca_mr.c
36852 @@ -426,7 +426,7 @@ static inline u32 adjust_key(struct mthca_dev *dev, u32 key)
36853 return key;
36854 }
36855
36856 -int mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift,
36857 +int __intentional_overflow(-1) mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift,
36858 u64 iova, u64 total_size, u32 access, struct mthca_mr *mr)
36859 {
36860 struct mthca_mailbox *mailbox;
36861 diff --git a/drivers/infiniband/hw/nes/nes.c b/drivers/infiniband/hw/nes/nes.c
36862 index 4291410..d2ab1fb 100644
36863 --- a/drivers/infiniband/hw/nes/nes.c
36864 +++ b/drivers/infiniband/hw/nes/nes.c
36865 @@ -98,7 +98,7 @@ MODULE_PARM_DESC(limit_maxrdreqsz, "Limit max read request size to 256 Bytes");
36866 LIST_HEAD(nes_adapter_list);
36867 static LIST_HEAD(nes_dev_list);
36868
36869 -atomic_t qps_destroyed;
36870 +atomic_unchecked_t qps_destroyed;
36871
36872 static unsigned int ee_flsh_adapter;
36873 static unsigned int sysfs_nonidx_addr;
36874 @@ -269,7 +269,7 @@ static void nes_cqp_rem_ref_callback(struct nes_device *nesdev, struct nes_cqp_r
36875 struct nes_qp *nesqp = cqp_request->cqp_callback_pointer;
36876 struct nes_adapter *nesadapter = nesdev->nesadapter;
36877
36878 - atomic_inc(&qps_destroyed);
36879 + atomic_inc_unchecked(&qps_destroyed);
36880
36881 /* Free the control structures */
36882
36883 diff --git a/drivers/infiniband/hw/nes/nes.h b/drivers/infiniband/hw/nes/nes.h
36884 index 33cc589..3bd6538 100644
36885 --- a/drivers/infiniband/hw/nes/nes.h
36886 +++ b/drivers/infiniband/hw/nes/nes.h
36887 @@ -177,17 +177,17 @@ extern unsigned int nes_debug_level;
36888 extern unsigned int wqm_quanta;
36889 extern struct list_head nes_adapter_list;
36890
36891 -extern atomic_t cm_connects;
36892 -extern atomic_t cm_accepts;
36893 -extern atomic_t cm_disconnects;
36894 -extern atomic_t cm_closes;
36895 -extern atomic_t cm_connecteds;
36896 -extern atomic_t cm_connect_reqs;
36897 -extern atomic_t cm_rejects;
36898 -extern atomic_t mod_qp_timouts;
36899 -extern atomic_t qps_created;
36900 -extern atomic_t qps_destroyed;
36901 -extern atomic_t sw_qps_destroyed;
36902 +extern atomic_unchecked_t cm_connects;
36903 +extern atomic_unchecked_t cm_accepts;
36904 +extern atomic_unchecked_t cm_disconnects;
36905 +extern atomic_unchecked_t cm_closes;
36906 +extern atomic_unchecked_t cm_connecteds;
36907 +extern atomic_unchecked_t cm_connect_reqs;
36908 +extern atomic_unchecked_t cm_rejects;
36909 +extern atomic_unchecked_t mod_qp_timouts;
36910 +extern atomic_unchecked_t qps_created;
36911 +extern atomic_unchecked_t qps_destroyed;
36912 +extern atomic_unchecked_t sw_qps_destroyed;
36913 extern u32 mh_detected;
36914 extern u32 mh_pauses_sent;
36915 extern u32 cm_packets_sent;
36916 @@ -196,16 +196,16 @@ extern u32 cm_packets_created;
36917 extern u32 cm_packets_received;
36918 extern u32 cm_packets_dropped;
36919 extern u32 cm_packets_retrans;
36920 -extern atomic_t cm_listens_created;
36921 -extern atomic_t cm_listens_destroyed;
36922 +extern atomic_unchecked_t cm_listens_created;
36923 +extern atomic_unchecked_t cm_listens_destroyed;
36924 extern u32 cm_backlog_drops;
36925 -extern atomic_t cm_loopbacks;
36926 -extern atomic_t cm_nodes_created;
36927 -extern atomic_t cm_nodes_destroyed;
36928 -extern atomic_t cm_accel_dropped_pkts;
36929 -extern atomic_t cm_resets_recvd;
36930 -extern atomic_t pau_qps_created;
36931 -extern atomic_t pau_qps_destroyed;
36932 +extern atomic_unchecked_t cm_loopbacks;
36933 +extern atomic_unchecked_t cm_nodes_created;
36934 +extern atomic_unchecked_t cm_nodes_destroyed;
36935 +extern atomic_unchecked_t cm_accel_dropped_pkts;
36936 +extern atomic_unchecked_t cm_resets_recvd;
36937 +extern atomic_unchecked_t pau_qps_created;
36938 +extern atomic_unchecked_t pau_qps_destroyed;
36939
36940 extern u32 int_mod_timer_init;
36941 extern u32 int_mod_cq_depth_256;
36942 diff --git a/drivers/infiniband/hw/nes/nes_cm.c b/drivers/infiniband/hw/nes/nes_cm.c
36943 index 24b9f1a..00fd004 100644
36944 --- a/drivers/infiniband/hw/nes/nes_cm.c
36945 +++ b/drivers/infiniband/hw/nes/nes_cm.c
36946 @@ -68,14 +68,14 @@ u32 cm_packets_dropped;
36947 u32 cm_packets_retrans;
36948 u32 cm_packets_created;
36949 u32 cm_packets_received;
36950 -atomic_t cm_listens_created;
36951 -atomic_t cm_listens_destroyed;
36952 +atomic_unchecked_t cm_listens_created;
36953 +atomic_unchecked_t cm_listens_destroyed;
36954 u32 cm_backlog_drops;
36955 -atomic_t cm_loopbacks;
36956 -atomic_t cm_nodes_created;
36957 -atomic_t cm_nodes_destroyed;
36958 -atomic_t cm_accel_dropped_pkts;
36959 -atomic_t cm_resets_recvd;
36960 +atomic_unchecked_t cm_loopbacks;
36961 +atomic_unchecked_t cm_nodes_created;
36962 +atomic_unchecked_t cm_nodes_destroyed;
36963 +atomic_unchecked_t cm_accel_dropped_pkts;
36964 +atomic_unchecked_t cm_resets_recvd;
36965
36966 static inline int mini_cm_accelerated(struct nes_cm_core *, struct nes_cm_node *);
36967 static struct nes_cm_listener *mini_cm_listen(struct nes_cm_core *, struct nes_vnic *, struct nes_cm_info *);
36968 @@ -148,13 +148,13 @@ static struct nes_cm_ops nes_cm_api = {
36969
36970 static struct nes_cm_core *g_cm_core;
36971
36972 -atomic_t cm_connects;
36973 -atomic_t cm_accepts;
36974 -atomic_t cm_disconnects;
36975 -atomic_t cm_closes;
36976 -atomic_t cm_connecteds;
36977 -atomic_t cm_connect_reqs;
36978 -atomic_t cm_rejects;
36979 +atomic_unchecked_t cm_connects;
36980 +atomic_unchecked_t cm_accepts;
36981 +atomic_unchecked_t cm_disconnects;
36982 +atomic_unchecked_t cm_closes;
36983 +atomic_unchecked_t cm_connecteds;
36984 +atomic_unchecked_t cm_connect_reqs;
36985 +atomic_unchecked_t cm_rejects;
36986
36987 int nes_add_ref_cm_node(struct nes_cm_node *cm_node)
36988 {
36989 @@ -1272,7 +1272,7 @@ static int mini_cm_dec_refcnt_listen(struct nes_cm_core *cm_core,
36990 kfree(listener);
36991 listener = NULL;
36992 ret = 0;
36993 - atomic_inc(&cm_listens_destroyed);
36994 + atomic_inc_unchecked(&cm_listens_destroyed);
36995 } else {
36996 spin_unlock_irqrestore(&cm_core->listen_list_lock, flags);
36997 }
36998 @@ -1466,7 +1466,7 @@ static struct nes_cm_node *make_cm_node(struct nes_cm_core *cm_core,
36999 cm_node->rem_mac);
37000
37001 add_hte_node(cm_core, cm_node);
37002 - atomic_inc(&cm_nodes_created);
37003 + atomic_inc_unchecked(&cm_nodes_created);
37004
37005 return cm_node;
37006 }
37007 @@ -1524,7 +1524,7 @@ static int rem_ref_cm_node(struct nes_cm_core *cm_core,
37008 }
37009
37010 atomic_dec(&cm_core->node_cnt);
37011 - atomic_inc(&cm_nodes_destroyed);
37012 + atomic_inc_unchecked(&cm_nodes_destroyed);
37013 nesqp = cm_node->nesqp;
37014 if (nesqp) {
37015 nesqp->cm_node = NULL;
37016 @@ -1588,7 +1588,7 @@ static int process_options(struct nes_cm_node *cm_node, u8 *optionsloc,
37017
37018 static void drop_packet(struct sk_buff *skb)
37019 {
37020 - atomic_inc(&cm_accel_dropped_pkts);
37021 + atomic_inc_unchecked(&cm_accel_dropped_pkts);
37022 dev_kfree_skb_any(skb);
37023 }
37024
37025 @@ -1651,7 +1651,7 @@ static void handle_rst_pkt(struct nes_cm_node *cm_node, struct sk_buff *skb,
37026 {
37027
37028 int reset = 0; /* whether to send reset in case of err.. */
37029 - atomic_inc(&cm_resets_recvd);
37030 + atomic_inc_unchecked(&cm_resets_recvd);
37031 nes_debug(NES_DBG_CM, "Received Reset, cm_node = %p, state = %u."
37032 " refcnt=%d\n", cm_node, cm_node->state,
37033 atomic_read(&cm_node->ref_count));
37034 @@ -2292,7 +2292,7 @@ static struct nes_cm_node *mini_cm_connect(struct nes_cm_core *cm_core,
37035 rem_ref_cm_node(cm_node->cm_core, cm_node);
37036 return NULL;
37037 }
37038 - atomic_inc(&cm_loopbacks);
37039 + atomic_inc_unchecked(&cm_loopbacks);
37040 loopbackremotenode->loopbackpartner = cm_node;
37041 loopbackremotenode->tcp_cntxt.rcv_wscale =
37042 NES_CM_DEFAULT_RCV_WND_SCALE;
37043 @@ -2567,7 +2567,7 @@ static int mini_cm_recv_pkt(struct nes_cm_core *cm_core,
37044 nes_queue_mgt_skbs(skb, nesvnic, cm_node->nesqp);
37045 else {
37046 rem_ref_cm_node(cm_core, cm_node);
37047 - atomic_inc(&cm_accel_dropped_pkts);
37048 + atomic_inc_unchecked(&cm_accel_dropped_pkts);
37049 dev_kfree_skb_any(skb);
37050 }
37051 break;
37052 @@ -2875,7 +2875,7 @@ static int nes_cm_disconn_true(struct nes_qp *nesqp)
37053
37054 if ((cm_id) && (cm_id->event_handler)) {
37055 if (issue_disconn) {
37056 - atomic_inc(&cm_disconnects);
37057 + atomic_inc_unchecked(&cm_disconnects);
37058 cm_event.event = IW_CM_EVENT_DISCONNECT;
37059 cm_event.status = disconn_status;
37060 cm_event.local_addr = cm_id->local_addr;
37061 @@ -2897,7 +2897,7 @@ static int nes_cm_disconn_true(struct nes_qp *nesqp)
37062 }
37063
37064 if (issue_close) {
37065 - atomic_inc(&cm_closes);
37066 + atomic_inc_unchecked(&cm_closes);
37067 nes_disconnect(nesqp, 1);
37068
37069 cm_id->provider_data = nesqp;
37070 @@ -3033,7 +3033,7 @@ int nes_accept(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
37071
37072 nes_debug(NES_DBG_CM, "QP%u, cm_node=%p, jiffies = %lu listener = %p\n",
37073 nesqp->hwqp.qp_id, cm_node, jiffies, cm_node->listener);
37074 - atomic_inc(&cm_accepts);
37075 + atomic_inc_unchecked(&cm_accepts);
37076
37077 nes_debug(NES_DBG_CM, "netdev refcnt = %u.\n",
37078 netdev_refcnt_read(nesvnic->netdev));
37079 @@ -3228,7 +3228,7 @@ int nes_reject(struct iw_cm_id *cm_id, const void *pdata, u8 pdata_len)
37080 struct nes_cm_core *cm_core;
37081 u8 *start_buff;
37082
37083 - atomic_inc(&cm_rejects);
37084 + atomic_inc_unchecked(&cm_rejects);
37085 cm_node = (struct nes_cm_node *)cm_id->provider_data;
37086 loopback = cm_node->loopbackpartner;
37087 cm_core = cm_node->cm_core;
37088 @@ -3288,7 +3288,7 @@ int nes_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
37089 ntohl(cm_id->local_addr.sin_addr.s_addr),
37090 ntohs(cm_id->local_addr.sin_port));
37091
37092 - atomic_inc(&cm_connects);
37093 + atomic_inc_unchecked(&cm_connects);
37094 nesqp->active_conn = 1;
37095
37096 /* cache the cm_id in the qp */
37097 @@ -3398,7 +3398,7 @@ int nes_create_listen(struct iw_cm_id *cm_id, int backlog)
37098 g_cm_core->api->stop_listener(g_cm_core, (void *)cm_node);
37099 return err;
37100 }
37101 - atomic_inc(&cm_listens_created);
37102 + atomic_inc_unchecked(&cm_listens_created);
37103 }
37104
37105 cm_id->add_ref(cm_id);
37106 @@ -3499,7 +3499,7 @@ static void cm_event_connected(struct nes_cm_event *event)
37107
37108 if (nesqp->destroyed)
37109 return;
37110 - atomic_inc(&cm_connecteds);
37111 + atomic_inc_unchecked(&cm_connecteds);
37112 nes_debug(NES_DBG_CM, "QP%u attempting to connect to 0x%08X:0x%04X on"
37113 " local port 0x%04X. jiffies = %lu.\n",
37114 nesqp->hwqp.qp_id,
37115 @@ -3679,7 +3679,7 @@ static void cm_event_reset(struct nes_cm_event *event)
37116
37117 cm_id->add_ref(cm_id);
37118 ret = cm_id->event_handler(cm_id, &cm_event);
37119 - atomic_inc(&cm_closes);
37120 + atomic_inc_unchecked(&cm_closes);
37121 cm_event.event = IW_CM_EVENT_CLOSE;
37122 cm_event.status = 0;
37123 cm_event.provider_data = cm_id->provider_data;
37124 @@ -3715,7 +3715,7 @@ static void cm_event_mpa_req(struct nes_cm_event *event)
37125 return;
37126 cm_id = cm_node->cm_id;
37127
37128 - atomic_inc(&cm_connect_reqs);
37129 + atomic_inc_unchecked(&cm_connect_reqs);
37130 nes_debug(NES_DBG_CM, "cm_node = %p - cm_id = %p, jiffies = %lu\n",
37131 cm_node, cm_id, jiffies);
37132
37133 @@ -3755,7 +3755,7 @@ static void cm_event_mpa_reject(struct nes_cm_event *event)
37134 return;
37135 cm_id = cm_node->cm_id;
37136
37137 - atomic_inc(&cm_connect_reqs);
37138 + atomic_inc_unchecked(&cm_connect_reqs);
37139 nes_debug(NES_DBG_CM, "cm_node = %p - cm_id = %p, jiffies = %lu\n",
37140 cm_node, cm_id, jiffies);
37141
37142 diff --git a/drivers/infiniband/hw/nes/nes_mgt.c b/drivers/infiniband/hw/nes/nes_mgt.c
37143 index 4166452..fc952c3 100644
37144 --- a/drivers/infiniband/hw/nes/nes_mgt.c
37145 +++ b/drivers/infiniband/hw/nes/nes_mgt.c
37146 @@ -40,8 +40,8 @@
37147 #include "nes.h"
37148 #include "nes_mgt.h"
37149
37150 -atomic_t pau_qps_created;
37151 -atomic_t pau_qps_destroyed;
37152 +atomic_unchecked_t pau_qps_created;
37153 +atomic_unchecked_t pau_qps_destroyed;
37154
37155 static void nes_replenish_mgt_rq(struct nes_vnic_mgt *mgtvnic)
37156 {
37157 @@ -621,7 +621,7 @@ void nes_destroy_pau_qp(struct nes_device *nesdev, struct nes_qp *nesqp)
37158 {
37159 struct sk_buff *skb;
37160 unsigned long flags;
37161 - atomic_inc(&pau_qps_destroyed);
37162 + atomic_inc_unchecked(&pau_qps_destroyed);
37163
37164 /* Free packets that have not yet been forwarded */
37165 /* Lock is acquired by skb_dequeue when removing the skb */
37166 @@ -810,7 +810,7 @@ static void nes_mgt_ce_handler(struct nes_device *nesdev, struct nes_hw_nic_cq *
37167 cq->cq_vbase[head].cqe_words[NES_NIC_CQE_HASH_RCVNXT]);
37168 skb_queue_head_init(&nesqp->pau_list);
37169 spin_lock_init(&nesqp->pau_lock);
37170 - atomic_inc(&pau_qps_created);
37171 + atomic_inc_unchecked(&pau_qps_created);
37172 nes_change_quad_hash(nesdev, mgtvnic->nesvnic, nesqp);
37173 }
37174
37175 diff --git a/drivers/infiniband/hw/nes/nes_nic.c b/drivers/infiniband/hw/nes/nes_nic.c
37176 index 85cf4d1..05d8e71 100644
37177 --- a/drivers/infiniband/hw/nes/nes_nic.c
37178 +++ b/drivers/infiniband/hw/nes/nes_nic.c
37179 @@ -1273,39 +1273,39 @@ static void nes_netdev_get_ethtool_stats(struct net_device *netdev,
37180 target_stat_values[++index] = mh_detected;
37181 target_stat_values[++index] = mh_pauses_sent;
37182 target_stat_values[++index] = nesvnic->endnode_ipv4_tcp_retransmits;
37183 - target_stat_values[++index] = atomic_read(&cm_connects);
37184 - target_stat_values[++index] = atomic_read(&cm_accepts);
37185 - target_stat_values[++index] = atomic_read(&cm_disconnects);
37186 - target_stat_values[++index] = atomic_read(&cm_connecteds);
37187 - target_stat_values[++index] = atomic_read(&cm_connect_reqs);
37188 - target_stat_values[++index] = atomic_read(&cm_rejects);
37189 - target_stat_values[++index] = atomic_read(&mod_qp_timouts);
37190 - target_stat_values[++index] = atomic_read(&qps_created);
37191 - target_stat_values[++index] = atomic_read(&sw_qps_destroyed);
37192 - target_stat_values[++index] = atomic_read(&qps_destroyed);
37193 - target_stat_values[++index] = atomic_read(&cm_closes);
37194 + target_stat_values[++index] = atomic_read_unchecked(&cm_connects);
37195 + target_stat_values[++index] = atomic_read_unchecked(&cm_accepts);
37196 + target_stat_values[++index] = atomic_read_unchecked(&cm_disconnects);
37197 + target_stat_values[++index] = atomic_read_unchecked(&cm_connecteds);
37198 + target_stat_values[++index] = atomic_read_unchecked(&cm_connect_reqs);
37199 + target_stat_values[++index] = atomic_read_unchecked(&cm_rejects);
37200 + target_stat_values[++index] = atomic_read_unchecked(&mod_qp_timouts);
37201 + target_stat_values[++index] = atomic_read_unchecked(&qps_created);
37202 + target_stat_values[++index] = atomic_read_unchecked(&sw_qps_destroyed);
37203 + target_stat_values[++index] = atomic_read_unchecked(&qps_destroyed);
37204 + target_stat_values[++index] = atomic_read_unchecked(&cm_closes);
37205 target_stat_values[++index] = cm_packets_sent;
37206 target_stat_values[++index] = cm_packets_bounced;
37207 target_stat_values[++index] = cm_packets_created;
37208 target_stat_values[++index] = cm_packets_received;
37209 target_stat_values[++index] = cm_packets_dropped;
37210 target_stat_values[++index] = cm_packets_retrans;
37211 - target_stat_values[++index] = atomic_read(&cm_listens_created);
37212 - target_stat_values[++index] = atomic_read(&cm_listens_destroyed);
37213 + target_stat_values[++index] = atomic_read_unchecked(&cm_listens_created);
37214 + target_stat_values[++index] = atomic_read_unchecked(&cm_listens_destroyed);
37215 target_stat_values[++index] = cm_backlog_drops;
37216 - target_stat_values[++index] = atomic_read(&cm_loopbacks);
37217 - target_stat_values[++index] = atomic_read(&cm_nodes_created);
37218 - target_stat_values[++index] = atomic_read(&cm_nodes_destroyed);
37219 - target_stat_values[++index] = atomic_read(&cm_accel_dropped_pkts);
37220 - target_stat_values[++index] = atomic_read(&cm_resets_recvd);
37221 + target_stat_values[++index] = atomic_read_unchecked(&cm_loopbacks);
37222 + target_stat_values[++index] = atomic_read_unchecked(&cm_nodes_created);
37223 + target_stat_values[++index] = atomic_read_unchecked(&cm_nodes_destroyed);
37224 + target_stat_values[++index] = atomic_read_unchecked(&cm_accel_dropped_pkts);
37225 + target_stat_values[++index] = atomic_read_unchecked(&cm_resets_recvd);
37226 target_stat_values[++index] = nesadapter->free_4kpbl;
37227 target_stat_values[++index] = nesadapter->free_256pbl;
37228 target_stat_values[++index] = int_mod_timer_init;
37229 target_stat_values[++index] = nesvnic->lro_mgr.stats.aggregated;
37230 target_stat_values[++index] = nesvnic->lro_mgr.stats.flushed;
37231 target_stat_values[++index] = nesvnic->lro_mgr.stats.no_desc;
37232 - target_stat_values[++index] = atomic_read(&pau_qps_created);
37233 - target_stat_values[++index] = atomic_read(&pau_qps_destroyed);
37234 + target_stat_values[++index] = atomic_read_unchecked(&pau_qps_created);
37235 + target_stat_values[++index] = atomic_read_unchecked(&pau_qps_destroyed);
37236 }
37237
37238 /**
37239 diff --git a/drivers/infiniband/hw/nes/nes_verbs.c b/drivers/infiniband/hw/nes/nes_verbs.c
37240 index 8f67fe2..8960859 100644
37241 --- a/drivers/infiniband/hw/nes/nes_verbs.c
37242 +++ b/drivers/infiniband/hw/nes/nes_verbs.c
37243 @@ -46,9 +46,9 @@
37244
37245 #include <rdma/ib_umem.h>
37246
37247 -atomic_t mod_qp_timouts;
37248 -atomic_t qps_created;
37249 -atomic_t sw_qps_destroyed;
37250 +atomic_unchecked_t mod_qp_timouts;
37251 +atomic_unchecked_t qps_created;
37252 +atomic_unchecked_t sw_qps_destroyed;
37253
37254 static void nes_unregister_ofa_device(struct nes_ib_device *nesibdev);
37255
37256 @@ -1134,7 +1134,7 @@ static struct ib_qp *nes_create_qp(struct ib_pd *ibpd,
37257 if (init_attr->create_flags)
37258 return ERR_PTR(-EINVAL);
37259
37260 - atomic_inc(&qps_created);
37261 + atomic_inc_unchecked(&qps_created);
37262 switch (init_attr->qp_type) {
37263 case IB_QPT_RC:
37264 if (nes_drv_opt & NES_DRV_OPT_NO_INLINE_DATA) {
37265 @@ -1465,7 +1465,7 @@ static int nes_destroy_qp(struct ib_qp *ibqp)
37266 struct iw_cm_event cm_event;
37267 int ret = 0;
37268
37269 - atomic_inc(&sw_qps_destroyed);
37270 + atomic_inc_unchecked(&sw_qps_destroyed);
37271 nesqp->destroyed = 1;
37272
37273 /* Blow away the connection if it exists. */
37274 diff --git a/drivers/infiniband/hw/qib/qib.h b/drivers/infiniband/hw/qib/qib.h
37275 index 4d11575..3e890e5 100644
37276 --- a/drivers/infiniband/hw/qib/qib.h
37277 +++ b/drivers/infiniband/hw/qib/qib.h
37278 @@ -51,6 +51,7 @@
37279 #include <linux/completion.h>
37280 #include <linux/kref.h>
37281 #include <linux/sched.h>
37282 +#include <linux/slab.h>
37283
37284 #include "qib_common.h"
37285 #include "qib_verbs.h"
37286 diff --git a/drivers/input/gameport/gameport.c b/drivers/input/gameport/gameport.c
37287 index da739d9..da1c7f4 100644
37288 --- a/drivers/input/gameport/gameport.c
37289 +++ b/drivers/input/gameport/gameport.c
37290 @@ -487,14 +487,14 @@ EXPORT_SYMBOL(gameport_set_phys);
37291 */
37292 static void gameport_init_port(struct gameport *gameport)
37293 {
37294 - static atomic_t gameport_no = ATOMIC_INIT(0);
37295 + static atomic_unchecked_t gameport_no = ATOMIC_INIT(0);
37296
37297 __module_get(THIS_MODULE);
37298
37299 mutex_init(&gameport->drv_mutex);
37300 device_initialize(&gameport->dev);
37301 dev_set_name(&gameport->dev, "gameport%lu",
37302 - (unsigned long)atomic_inc_return(&gameport_no) - 1);
37303 + (unsigned long)atomic_inc_return_unchecked(&gameport_no) - 1);
37304 gameport->dev.bus = &gameport_bus;
37305 gameport->dev.release = gameport_release_port;
37306 if (gameport->parent)
37307 diff --git a/drivers/input/input.c b/drivers/input/input.c
37308 index c044699..174d71a 100644
37309 --- a/drivers/input/input.c
37310 +++ b/drivers/input/input.c
37311 @@ -2019,7 +2019,7 @@ static void devm_input_device_unregister(struct device *dev, void *res)
37312 */
37313 int input_register_device(struct input_dev *dev)
37314 {
37315 - static atomic_t input_no = ATOMIC_INIT(0);
37316 + static atomic_unchecked_t input_no = ATOMIC_INIT(0);
37317 struct input_devres *devres = NULL;
37318 struct input_handler *handler;
37319 unsigned int packet_size;
37320 @@ -2074,7 +2074,7 @@ int input_register_device(struct input_dev *dev)
37321 dev->setkeycode = input_default_setkeycode;
37322
37323 dev_set_name(&dev->dev, "input%ld",
37324 - (unsigned long) atomic_inc_return(&input_no) - 1);
37325 + (unsigned long) atomic_inc_return_unchecked(&input_no) - 1);
37326
37327 error = device_add(&dev->dev);
37328 if (error)
37329 diff --git a/drivers/input/joystick/sidewinder.c b/drivers/input/joystick/sidewinder.c
37330 index 04c69af..5f92d00 100644
37331 --- a/drivers/input/joystick/sidewinder.c
37332 +++ b/drivers/input/joystick/sidewinder.c
37333 @@ -30,6 +30,7 @@
37334 #include <linux/kernel.h>
37335 #include <linux/module.h>
37336 #include <linux/slab.h>
37337 +#include <linux/sched.h>
37338 #include <linux/init.h>
37339 #include <linux/input.h>
37340 #include <linux/gameport.h>
37341 diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
37342 index d6cbfe9..6225402 100644
37343 --- a/drivers/input/joystick/xpad.c
37344 +++ b/drivers/input/joystick/xpad.c
37345 @@ -735,7 +735,7 @@ static void xpad_led_set(struct led_classdev *led_cdev,
37346
37347 static int xpad_led_probe(struct usb_xpad *xpad)
37348 {
37349 - static atomic_t led_seq = ATOMIC_INIT(0);
37350 + static atomic_unchecked_t led_seq = ATOMIC_INIT(0);
37351 long led_no;
37352 struct xpad_led *led;
37353 struct led_classdev *led_cdev;
37354 @@ -748,7 +748,7 @@ static int xpad_led_probe(struct usb_xpad *xpad)
37355 if (!led)
37356 return -ENOMEM;
37357
37358 - led_no = (long)atomic_inc_return(&led_seq) - 1;
37359 + led_no = (long)atomic_inc_return_unchecked(&led_seq) - 1;
37360
37361 snprintf(led->name, sizeof(led->name), "xpad%ld", led_no);
37362 led->xpad = xpad;
37363 diff --git a/drivers/input/mouse/psmouse.h b/drivers/input/mouse/psmouse.h
37364 index 2f0b39d..7370f13 100644
37365 --- a/drivers/input/mouse/psmouse.h
37366 +++ b/drivers/input/mouse/psmouse.h
37367 @@ -116,7 +116,7 @@ struct psmouse_attribute {
37368 ssize_t (*set)(struct psmouse *psmouse, void *data,
37369 const char *buf, size_t count);
37370 bool protect;
37371 -};
37372 +} __do_const;
37373 #define to_psmouse_attr(a) container_of((a), struct psmouse_attribute, dattr)
37374
37375 ssize_t psmouse_attr_show_helper(struct device *dev, struct device_attribute *attr,
37376 diff --git a/drivers/input/mousedev.c b/drivers/input/mousedev.c
37377 index 4c842c3..590b0bf 100644
37378 --- a/drivers/input/mousedev.c
37379 +++ b/drivers/input/mousedev.c
37380 @@ -738,7 +738,7 @@ static ssize_t mousedev_read(struct file *file, char __user *buffer,
37381
37382 spin_unlock_irq(&client->packet_lock);
37383
37384 - if (copy_to_user(buffer, data, count))
37385 + if (count > sizeof(data) || copy_to_user(buffer, data, count))
37386 return -EFAULT;
37387
37388 return count;
37389 diff --git a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c
37390 index 25fc597..558bf3b3 100644
37391 --- a/drivers/input/serio/serio.c
37392 +++ b/drivers/input/serio/serio.c
37393 @@ -496,7 +496,7 @@ static void serio_release_port(struct device *dev)
37394 */
37395 static void serio_init_port(struct serio *serio)
37396 {
37397 - static atomic_t serio_no = ATOMIC_INIT(0);
37398 + static atomic_unchecked_t serio_no = ATOMIC_INIT(0);
37399
37400 __module_get(THIS_MODULE);
37401
37402 @@ -507,7 +507,7 @@ static void serio_init_port(struct serio *serio)
37403 mutex_init(&serio->drv_mutex);
37404 device_initialize(&serio->dev);
37405 dev_set_name(&serio->dev, "serio%ld",
37406 - (long)atomic_inc_return(&serio_no) - 1);
37407 + (long)atomic_inc_return_unchecked(&serio_no) - 1);
37408 serio->dev.bus = &serio_bus;
37409 serio->dev.release = serio_release_port;
37410 serio->dev.groups = serio_device_attr_groups;
37411 diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
37412 index b972d43..8943713 100644
37413 --- a/drivers/iommu/iommu.c
37414 +++ b/drivers/iommu/iommu.c
37415 @@ -554,7 +554,7 @@ static struct notifier_block iommu_bus_nb = {
37416 static void iommu_bus_init(struct bus_type *bus, struct iommu_ops *ops)
37417 {
37418 bus_register_notifier(bus, &iommu_bus_nb);
37419 - bus_for_each_dev(bus, NULL, ops, add_iommu_group);
37420 + bus_for_each_dev(bus, NULL, (void *)ops, add_iommu_group);
37421 }
37422
37423 /**
37424 diff --git a/drivers/iommu/irq_remapping.c b/drivers/iommu/irq_remapping.c
37425 index 7c11ff3..5b2d7a7 100644
37426 --- a/drivers/iommu/irq_remapping.c
37427 +++ b/drivers/iommu/irq_remapping.c
37428 @@ -369,10 +369,12 @@ static void ir_print_prefix(struct irq_data *data, struct seq_file *p)
37429
37430 void irq_remap_modify_chip_defaults(struct irq_chip *chip)
37431 {
37432 - chip->irq_print_chip = ir_print_prefix;
37433 - chip->irq_ack = ir_ack_apic_edge;
37434 - chip->irq_eoi = ir_ack_apic_level;
37435 - chip->irq_set_affinity = x86_io_apic_ops.set_affinity;
37436 + pax_open_kernel();
37437 + *(void **)&chip->irq_print_chip = ir_print_prefix;
37438 + *(void **)&chip->irq_ack = ir_ack_apic_edge;
37439 + *(void **)&chip->irq_eoi = ir_ack_apic_level;
37440 + *(void **)&chip->irq_set_affinity = x86_io_apic_ops.set_affinity;
37441 + pax_close_kernel();
37442 }
37443
37444 bool setup_remapped_irq(int irq, struct irq_cfg *cfg, struct irq_chip *chip)
37445 diff --git a/drivers/irqchip/irq-gic.c b/drivers/irqchip/irq-gic.c
37446 index fc6aebf..762c5f5 100644
37447 --- a/drivers/irqchip/irq-gic.c
37448 +++ b/drivers/irqchip/irq-gic.c
37449 @@ -83,7 +83,7 @@ static u8 gic_cpu_map[NR_GIC_CPU_IF] __read_mostly;
37450 * Supported arch specific GIC irq extension.
37451 * Default make them NULL.
37452 */
37453 -struct irq_chip gic_arch_extn = {
37454 +irq_chip_no_const gic_arch_extn = {
37455 .irq_eoi = NULL,
37456 .irq_mask = NULL,
37457 .irq_unmask = NULL,
37458 @@ -332,7 +332,7 @@ static void gic_handle_cascade_irq(unsigned int irq, struct irq_desc *desc)
37459 chained_irq_exit(chip, desc);
37460 }
37461
37462 -static struct irq_chip gic_chip = {
37463 +static irq_chip_no_const gic_chip __read_only = {
37464 .name = "GIC",
37465 .irq_mask = gic_mask_irq,
37466 .irq_unmask = gic_unmask_irq,
37467 diff --git a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c
37468 index 89562a8..218999b 100644
37469 --- a/drivers/isdn/capi/capi.c
37470 +++ b/drivers/isdn/capi/capi.c
37471 @@ -81,8 +81,8 @@ struct capiminor {
37472
37473 struct capi20_appl *ap;
37474 u32 ncci;
37475 - atomic_t datahandle;
37476 - atomic_t msgid;
37477 + atomic_unchecked_t datahandle;
37478 + atomic_unchecked_t msgid;
37479
37480 struct tty_port port;
37481 int ttyinstop;
37482 @@ -391,7 +391,7 @@ gen_data_b3_resp_for(struct capiminor *mp, struct sk_buff *skb)
37483 capimsg_setu16(s, 2, mp->ap->applid);
37484 capimsg_setu8 (s, 4, CAPI_DATA_B3);
37485 capimsg_setu8 (s, 5, CAPI_RESP);
37486 - capimsg_setu16(s, 6, atomic_inc_return(&mp->msgid));
37487 + capimsg_setu16(s, 6, atomic_inc_return_unchecked(&mp->msgid));
37488 capimsg_setu32(s, 8, mp->ncci);
37489 capimsg_setu16(s, 12, datahandle);
37490 }
37491 @@ -512,14 +512,14 @@ static void handle_minor_send(struct capiminor *mp)
37492 mp->outbytes -= len;
37493 spin_unlock_bh(&mp->outlock);
37494
37495 - datahandle = atomic_inc_return(&mp->datahandle);
37496 + datahandle = atomic_inc_return_unchecked(&mp->datahandle);
37497 skb_push(skb, CAPI_DATA_B3_REQ_LEN);
37498 memset(skb->data, 0, CAPI_DATA_B3_REQ_LEN);
37499 capimsg_setu16(skb->data, 0, CAPI_DATA_B3_REQ_LEN);
37500 capimsg_setu16(skb->data, 2, mp->ap->applid);
37501 capimsg_setu8 (skb->data, 4, CAPI_DATA_B3);
37502 capimsg_setu8 (skb->data, 5, CAPI_REQ);
37503 - capimsg_setu16(skb->data, 6, atomic_inc_return(&mp->msgid));
37504 + capimsg_setu16(skb->data, 6, atomic_inc_return_unchecked(&mp->msgid));
37505 capimsg_setu32(skb->data, 8, mp->ncci); /* NCCI */
37506 capimsg_setu32(skb->data, 12, (u32)(long)skb->data);/* Data32 */
37507 capimsg_setu16(skb->data, 16, len); /* Data length */
37508 diff --git a/drivers/isdn/gigaset/interface.c b/drivers/isdn/gigaset/interface.c
37509 index e2b5396..c5486dc 100644
37510 --- a/drivers/isdn/gigaset/interface.c
37511 +++ b/drivers/isdn/gigaset/interface.c
37512 @@ -130,9 +130,9 @@ static int if_open(struct tty_struct *tty, struct file *filp)
37513 }
37514 tty->driver_data = cs;
37515
37516 - ++cs->port.count;
37517 + atomic_inc(&cs->port.count);
37518
37519 - if (cs->port.count == 1) {
37520 + if (atomic_read(&cs->port.count) == 1) {
37521 tty_port_tty_set(&cs->port, tty);
37522 cs->port.low_latency = 1;
37523 }
37524 @@ -156,9 +156,9 @@ static void if_close(struct tty_struct *tty, struct file *filp)
37525
37526 if (!cs->connected)
37527 gig_dbg(DEBUG_IF, "not connected"); /* nothing to do */
37528 - else if (!cs->port.count)
37529 + else if (!atomic_read(&cs->port.count))
37530 dev_warn(cs->dev, "%s: device not opened\n", __func__);
37531 - else if (!--cs->port.count)
37532 + else if (!atomic_dec_return(&cs->port.count))
37533 tty_port_tty_set(&cs->port, NULL);
37534
37535 mutex_unlock(&cs->mutex);
37536 diff --git a/drivers/isdn/hardware/avm/b1.c b/drivers/isdn/hardware/avm/b1.c
37537 index 821f7ac..28d4030 100644
37538 --- a/drivers/isdn/hardware/avm/b1.c
37539 +++ b/drivers/isdn/hardware/avm/b1.c
37540 @@ -176,7 +176,7 @@ int b1_load_t4file(avmcard *card, capiloaddatapart *t4file)
37541 }
37542 if (left) {
37543 if (t4file->user) {
37544 - if (copy_from_user(buf, dp, left))
37545 + if (left > sizeof buf || copy_from_user(buf, dp, left))
37546 return -EFAULT;
37547 } else {
37548 memcpy(buf, dp, left);
37549 @@ -224,7 +224,7 @@ int b1_load_config(avmcard *card, capiloaddatapart *config)
37550 }
37551 if (left) {
37552 if (config->user) {
37553 - if (copy_from_user(buf, dp, left))
37554 + if (left > sizeof buf || copy_from_user(buf, dp, left))
37555 return -EFAULT;
37556 } else {
37557 memcpy(buf, dp, left);
37558 diff --git a/drivers/isdn/i4l/isdn_tty.c b/drivers/isdn/i4l/isdn_tty.c
37559 index ebaebdf..acd4405 100644
37560 --- a/drivers/isdn/i4l/isdn_tty.c
37561 +++ b/drivers/isdn/i4l/isdn_tty.c
37562 @@ -1511,9 +1511,9 @@ isdn_tty_open(struct tty_struct *tty, struct file *filp)
37563
37564 #ifdef ISDN_DEBUG_MODEM_OPEN
37565 printk(KERN_DEBUG "isdn_tty_open %s, count = %d\n", tty->name,
37566 - port->count);
37567 + atomic_read(&port->count));
37568 #endif
37569 - port->count++;
37570 + atomic_inc(&port->count);
37571 port->tty = tty;
37572 /*
37573 * Start up serial port
37574 @@ -1557,7 +1557,7 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
37575 #endif
37576 return;
37577 }
37578 - if ((tty->count == 1) && (port->count != 1)) {
37579 + if ((tty->count == 1) && (atomic_read(&port->count) != 1)) {
37580 /*
37581 * Uh, oh. tty->count is 1, which means that the tty
37582 * structure will be freed. Info->count should always
37583 @@ -1566,15 +1566,15 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
37584 * serial port won't be shutdown.
37585 */
37586 printk(KERN_ERR "isdn_tty_close: bad port count; tty->count is 1, "
37587 - "info->count is %d\n", port->count);
37588 - port->count = 1;
37589 + "info->count is %d\n", atomic_read(&port->count));
37590 + atomic_set(&port->count, 1);
37591 }
37592 - if (--port->count < 0) {
37593 + if (atomic_dec_return(&port->count) < 0) {
37594 printk(KERN_ERR "isdn_tty_close: bad port count for ttyi%d: %d\n",
37595 - info->line, port->count);
37596 - port->count = 0;
37597 + info->line, atomic_read(&port->count));
37598 + atomic_set(&port->count, 0);
37599 }
37600 - if (port->count) {
37601 + if (atomic_read(&port->count)) {
37602 #ifdef ISDN_DEBUG_MODEM_OPEN
37603 printk(KERN_DEBUG "isdn_tty_close after info->count != 0\n");
37604 #endif
37605 @@ -1628,7 +1628,7 @@ isdn_tty_hangup(struct tty_struct *tty)
37606 if (isdn_tty_paranoia_check(info, tty->name, "isdn_tty_hangup"))
37607 return;
37608 isdn_tty_shutdown(info);
37609 - port->count = 0;
37610 + atomic_set(&port->count, 0);
37611 port->flags &= ~ASYNC_NORMAL_ACTIVE;
37612 port->tty = NULL;
37613 wake_up_interruptible(&port->open_wait);
37614 @@ -1973,7 +1973,7 @@ isdn_tty_find_icall(int di, int ch, setup_parm *setup)
37615 for (i = 0; i < ISDN_MAX_CHANNELS; i++) {
37616 modem_info *info = &dev->mdm.info[i];
37617
37618 - if (info->port.count == 0)
37619 + if (atomic_read(&info->port.count) == 0)
37620 continue;
37621 if ((info->emu.mdmreg[REG_SI1] & si2bit[si1]) && /* SI1 is matching */
37622 (info->emu.mdmreg[REG_SI2] == si2)) { /* SI2 is matching */
37623 diff --git a/drivers/isdn/icn/icn.c b/drivers/isdn/icn/icn.c
37624 index e74df7c..03a03ba 100644
37625 --- a/drivers/isdn/icn/icn.c
37626 +++ b/drivers/isdn/icn/icn.c
37627 @@ -1045,7 +1045,7 @@ icn_writecmd(const u_char *buf, int len, int user, icn_card *card)
37628 if (count > len)
37629 count = len;
37630 if (user) {
37631 - if (copy_from_user(msg, buf, count))
37632 + if (count > sizeof msg || copy_from_user(msg, buf, count))
37633 return -EFAULT;
37634 } else
37635 memcpy(msg, buf, count);
37636 diff --git a/drivers/leds/leds-clevo-mail.c b/drivers/leds/leds-clevo-mail.c
37637 index 6a8405d..0bd1c7e 100644
37638 --- a/drivers/leds/leds-clevo-mail.c
37639 +++ b/drivers/leds/leds-clevo-mail.c
37640 @@ -40,7 +40,7 @@ static int __init clevo_mail_led_dmi_callback(const struct dmi_system_id *id)
37641 * detected as working, but in reality it is not) as low as
37642 * possible.
37643 */
37644 -static struct dmi_system_id __initdata clevo_mail_led_dmi_table[] = {
37645 +static const struct dmi_system_id __initconst clevo_mail_led_dmi_table[] = {
37646 {
37647 .callback = clevo_mail_led_dmi_callback,
37648 .ident = "Clevo D410J",
37649 diff --git a/drivers/leds/leds-ss4200.c b/drivers/leds/leds-ss4200.c
37650 index 64e204e..c6bf189 100644
37651 --- a/drivers/leds/leds-ss4200.c
37652 +++ b/drivers/leds/leds-ss4200.c
37653 @@ -91,7 +91,7 @@ MODULE_PARM_DESC(nodetect, "Skip DMI-based hardware detection");
37654 * detected as working, but in reality it is not) as low as
37655 * possible.
37656 */
37657 -static struct dmi_system_id __initdata nas_led_whitelist[] = {
37658 +static const struct dmi_system_id __initconst nas_led_whitelist[] = {
37659 {
37660 .callback = ss4200_led_dmi_callback,
37661 .ident = "Intel SS4200-E",
37662 diff --git a/drivers/lguest/core.c b/drivers/lguest/core.c
37663 index a5ebc00..982886f 100644
37664 --- a/drivers/lguest/core.c
37665 +++ b/drivers/lguest/core.c
37666 @@ -92,9 +92,17 @@ static __init int map_switcher(void)
37667 * it's worked so far. The end address needs +1 because __get_vm_area
37668 * allocates an extra guard page, so we need space for that.
37669 */
37670 +
37671 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
37672 + switcher_vma = __get_vm_area(TOTAL_SWITCHER_PAGES * PAGE_SIZE,
37673 + VM_ALLOC | VM_KERNEXEC, SWITCHER_ADDR, SWITCHER_ADDR
37674 + + (TOTAL_SWITCHER_PAGES+1) * PAGE_SIZE);
37675 +#else
37676 switcher_vma = __get_vm_area(TOTAL_SWITCHER_PAGES * PAGE_SIZE,
37677 VM_ALLOC, SWITCHER_ADDR, SWITCHER_ADDR
37678 + (TOTAL_SWITCHER_PAGES+1) * PAGE_SIZE);
37679 +#endif
37680 +
37681 if (!switcher_vma) {
37682 err = -ENOMEM;
37683 printk("lguest: could not map switcher pages high\n");
37684 @@ -119,7 +127,7 @@ static __init int map_switcher(void)
37685 * Now the Switcher is mapped at the right address, we can't fail!
37686 * Copy in the compiled-in Switcher code (from x86/switcher_32.S).
37687 */
37688 - memcpy(switcher_vma->addr, start_switcher_text,
37689 + memcpy(switcher_vma->addr, ktla_ktva(start_switcher_text),
37690 end_switcher_text - start_switcher_text);
37691
37692 printk(KERN_INFO "lguest: mapped switcher at %p\n",
37693 diff --git a/drivers/lguest/page_tables.c b/drivers/lguest/page_tables.c
37694 index 3b62be16..e33134a 100644
37695 --- a/drivers/lguest/page_tables.c
37696 +++ b/drivers/lguest/page_tables.c
37697 @@ -532,7 +532,7 @@ void pin_page(struct lg_cpu *cpu, unsigned long vaddr)
37698 /*:*/
37699
37700 #ifdef CONFIG_X86_PAE
37701 -static void release_pmd(pmd_t *spmd)
37702 +static void __intentional_overflow(-1) release_pmd(pmd_t *spmd)
37703 {
37704 /* If the entry's not present, there's nothing to release. */
37705 if (pmd_flags(*spmd) & _PAGE_PRESENT) {
37706 diff --git a/drivers/lguest/x86/core.c b/drivers/lguest/x86/core.c
37707 index 4af12e1..0e89afe 100644
37708 --- a/drivers/lguest/x86/core.c
37709 +++ b/drivers/lguest/x86/core.c
37710 @@ -59,7 +59,7 @@ static struct {
37711 /* Offset from where switcher.S was compiled to where we've copied it */
37712 static unsigned long switcher_offset(void)
37713 {
37714 - return SWITCHER_ADDR - (unsigned long)start_switcher_text;
37715 + return SWITCHER_ADDR - (unsigned long)ktla_ktva(start_switcher_text);
37716 }
37717
37718 /* This cpu's struct lguest_pages. */
37719 @@ -100,7 +100,13 @@ static void copy_in_guest_info(struct lg_cpu *cpu, struct lguest_pages *pages)
37720 * These copies are pretty cheap, so we do them unconditionally: */
37721 /* Save the current Host top-level page directory.
37722 */
37723 +
37724 +#ifdef CONFIG_PAX_PER_CPU_PGD
37725 + pages->state.host_cr3 = read_cr3();
37726 +#else
37727 pages->state.host_cr3 = __pa(current->mm->pgd);
37728 +#endif
37729 +
37730 /*
37731 * Set up the Guest's page tables to see this CPU's pages (and no
37732 * other CPU's pages).
37733 @@ -476,7 +482,7 @@ void __init lguest_arch_host_init(void)
37734 * compiled-in switcher code and the high-mapped copy we just made.
37735 */
37736 for (i = 0; i < IDT_ENTRIES; i++)
37737 - default_idt_entries[i] += switcher_offset();
37738 + default_idt_entries[i] = ktla_ktva(default_idt_entries[i]) + switcher_offset();
37739
37740 /*
37741 * Set up the Switcher's per-cpu areas.
37742 @@ -559,7 +565,7 @@ void __init lguest_arch_host_init(void)
37743 * it will be undisturbed when we switch. To change %cs and jump we
37744 * need this structure to feed to Intel's "lcall" instruction.
37745 */
37746 - lguest_entry.offset = (long)switch_to_guest + switcher_offset();
37747 + lguest_entry.offset = (long)ktla_ktva(switch_to_guest) + switcher_offset();
37748 lguest_entry.segment = LGUEST_CS;
37749
37750 /*
37751 diff --git a/drivers/lguest/x86/switcher_32.S b/drivers/lguest/x86/switcher_32.S
37752 index 40634b0..4f5855e 100644
37753 --- a/drivers/lguest/x86/switcher_32.S
37754 +++ b/drivers/lguest/x86/switcher_32.S
37755 @@ -87,6 +87,7 @@
37756 #include <asm/page.h>
37757 #include <asm/segment.h>
37758 #include <asm/lguest.h>
37759 +#include <asm/processor-flags.h>
37760
37761 // We mark the start of the code to copy
37762 // It's placed in .text tho it's never run here
37763 @@ -149,6 +150,13 @@ ENTRY(switch_to_guest)
37764 // Changes type when we load it: damn Intel!
37765 // For after we switch over our page tables
37766 // That entry will be read-only: we'd crash.
37767 +
37768 +#ifdef CONFIG_PAX_KERNEXEC
37769 + mov %cr0, %edx
37770 + xor $X86_CR0_WP, %edx
37771 + mov %edx, %cr0
37772 +#endif
37773 +
37774 movl $(GDT_ENTRY_TSS*8), %edx
37775 ltr %dx
37776
37777 @@ -157,9 +165,15 @@ ENTRY(switch_to_guest)
37778 // Let's clear it again for our return.
37779 // The GDT descriptor of the Host
37780 // Points to the table after two "size" bytes
37781 - movl (LGUEST_PAGES_host_gdt_desc+2)(%eax), %edx
37782 + movl (LGUEST_PAGES_host_gdt_desc+2)(%eax), %eax
37783 // Clear "used" from type field (byte 5, bit 2)
37784 - andb $0xFD, (GDT_ENTRY_TSS*8 + 5)(%edx)
37785 + andb $0xFD, (GDT_ENTRY_TSS*8 + 5)(%eax)
37786 +
37787 +#ifdef CONFIG_PAX_KERNEXEC
37788 + mov %cr0, %eax
37789 + xor $X86_CR0_WP, %eax
37790 + mov %eax, %cr0
37791 +#endif
37792
37793 // Once our page table's switched, the Guest is live!
37794 // The Host fades as we run this final step.
37795 @@ -295,13 +309,12 @@ deliver_to_host:
37796 // I consulted gcc, and it gave
37797 // These instructions, which I gladly credit:
37798 leal (%edx,%ebx,8), %eax
37799 - movzwl (%eax),%edx
37800 - movl 4(%eax), %eax
37801 - xorw %ax, %ax
37802 - orl %eax, %edx
37803 + movl 4(%eax), %edx
37804 + movw (%eax), %dx
37805 // Now the address of the handler's in %edx
37806 // We call it now: its "iret" drops us home.
37807 - jmp *%edx
37808 + ljmp $__KERNEL_CS, $1f
37809 +1: jmp *%edx
37810
37811 // Every interrupt can come to us here
37812 // But we must truly tell each apart.
37813 diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
37814 index 4fd9d6a..834fa03 100644
37815 --- a/drivers/md/bitmap.c
37816 +++ b/drivers/md/bitmap.c
37817 @@ -1779,7 +1779,7 @@ void bitmap_status(struct seq_file *seq, struct bitmap *bitmap)
37818 chunk_kb ? "KB" : "B");
37819 if (bitmap->storage.file) {
37820 seq_printf(seq, ", file: ");
37821 - seq_path(seq, &bitmap->storage.file->f_path, " \t\n");
37822 + seq_path(seq, &bitmap->storage.file->f_path, " \t\n\\");
37823 }
37824
37825 seq_printf(seq, "\n");
37826 diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
37827 index aa04f02..2a1309e 100644
37828 --- a/drivers/md/dm-ioctl.c
37829 +++ b/drivers/md/dm-ioctl.c
37830 @@ -1694,7 +1694,7 @@ static int validate_params(uint cmd, struct dm_ioctl *param)
37831 cmd == DM_LIST_VERSIONS_CMD)
37832 return 0;
37833
37834 - if ((cmd == DM_DEV_CREATE_CMD)) {
37835 + if (cmd == DM_DEV_CREATE_CMD) {
37836 if (!*param->name) {
37837 DMWARN("name not supplied when creating device");
37838 return -EINVAL;
37839 diff --git a/drivers/md/dm-raid1.c b/drivers/md/dm-raid1.c
37840 index d053098..05cc375 100644
37841 --- a/drivers/md/dm-raid1.c
37842 +++ b/drivers/md/dm-raid1.c
37843 @@ -40,7 +40,7 @@ enum dm_raid1_error {
37844
37845 struct mirror {
37846 struct mirror_set *ms;
37847 - atomic_t error_count;
37848 + atomic_unchecked_t error_count;
37849 unsigned long error_type;
37850 struct dm_dev *dev;
37851 sector_t offset;
37852 @@ -186,7 +186,7 @@ static struct mirror *get_valid_mirror(struct mirror_set *ms)
37853 struct mirror *m;
37854
37855 for (m = ms->mirror; m < ms->mirror + ms->nr_mirrors; m++)
37856 - if (!atomic_read(&m->error_count))
37857 + if (!atomic_read_unchecked(&m->error_count))
37858 return m;
37859
37860 return NULL;
37861 @@ -218,7 +218,7 @@ static void fail_mirror(struct mirror *m, enum dm_raid1_error error_type)
37862 * simple way to tell if a device has encountered
37863 * errors.
37864 */
37865 - atomic_inc(&m->error_count);
37866 + atomic_inc_unchecked(&m->error_count);
37867
37868 if (test_and_set_bit(error_type, &m->error_type))
37869 return;
37870 @@ -409,7 +409,7 @@ static struct mirror *choose_mirror(struct mirror_set *ms, sector_t sector)
37871 struct mirror *m = get_default_mirror(ms);
37872
37873 do {
37874 - if (likely(!atomic_read(&m->error_count)))
37875 + if (likely(!atomic_read_unchecked(&m->error_count)))
37876 return m;
37877
37878 if (m-- == ms->mirror)
37879 @@ -423,7 +423,7 @@ static int default_ok(struct mirror *m)
37880 {
37881 struct mirror *default_mirror = get_default_mirror(m->ms);
37882
37883 - return !atomic_read(&default_mirror->error_count);
37884 + return !atomic_read_unchecked(&default_mirror->error_count);
37885 }
37886
37887 static int mirror_available(struct mirror_set *ms, struct bio *bio)
37888 @@ -560,7 +560,7 @@ static void do_reads(struct mirror_set *ms, struct bio_list *reads)
37889 */
37890 if (likely(region_in_sync(ms, region, 1)))
37891 m = choose_mirror(ms, bio->bi_sector);
37892 - else if (m && atomic_read(&m->error_count))
37893 + else if (m && atomic_read_unchecked(&m->error_count))
37894 m = NULL;
37895
37896 if (likely(m))
37897 @@ -927,7 +927,7 @@ static int get_mirror(struct mirror_set *ms, struct dm_target *ti,
37898 }
37899
37900 ms->mirror[mirror].ms = ms;
37901 - atomic_set(&(ms->mirror[mirror].error_count), 0);
37902 + atomic_set_unchecked(&(ms->mirror[mirror].error_count), 0);
37903 ms->mirror[mirror].error_type = 0;
37904 ms->mirror[mirror].offset = offset;
37905
37906 @@ -1340,7 +1340,7 @@ static void mirror_resume(struct dm_target *ti)
37907 */
37908 static char device_status_char(struct mirror *m)
37909 {
37910 - if (!atomic_read(&(m->error_count)))
37911 + if (!atomic_read_unchecked(&(m->error_count)))
37912 return 'A';
37913
37914 return (test_bit(DM_RAID1_FLUSH_ERROR, &(m->error_type))) ? 'F' :
37915 diff --git a/drivers/md/dm-stripe.c b/drivers/md/dm-stripe.c
37916 index 7b8b2b9..9c7d145 100644
37917 --- a/drivers/md/dm-stripe.c
37918 +++ b/drivers/md/dm-stripe.c
37919 @@ -20,7 +20,7 @@ struct stripe {
37920 struct dm_dev *dev;
37921 sector_t physical_start;
37922
37923 - atomic_t error_count;
37924 + atomic_unchecked_t error_count;
37925 };
37926
37927 struct stripe_c {
37928 @@ -185,7 +185,7 @@ static int stripe_ctr(struct dm_target *ti, unsigned int argc, char **argv)
37929 kfree(sc);
37930 return r;
37931 }
37932 - atomic_set(&(sc->stripe[i].error_count), 0);
37933 + atomic_set_unchecked(&(sc->stripe[i].error_count), 0);
37934 }
37935
37936 ti->private = sc;
37937 @@ -326,7 +326,7 @@ static void stripe_status(struct dm_target *ti, status_type_t type,
37938 DMEMIT("%d ", sc->stripes);
37939 for (i = 0; i < sc->stripes; i++) {
37940 DMEMIT("%s ", sc->stripe[i].dev->name);
37941 - buffer[i] = atomic_read(&(sc->stripe[i].error_count)) ?
37942 + buffer[i] = atomic_read_unchecked(&(sc->stripe[i].error_count)) ?
37943 'D' : 'A';
37944 }
37945 buffer[i] = '\0';
37946 @@ -371,8 +371,8 @@ static int stripe_end_io(struct dm_target *ti, struct bio *bio, int error)
37947 */
37948 for (i = 0; i < sc->stripes; i++)
37949 if (!strcmp(sc->stripe[i].dev->name, major_minor)) {
37950 - atomic_inc(&(sc->stripe[i].error_count));
37951 - if (atomic_read(&(sc->stripe[i].error_count)) <
37952 + atomic_inc_unchecked(&(sc->stripe[i].error_count));
37953 + if (atomic_read_unchecked(&(sc->stripe[i].error_count)) <
37954 DM_IO_ERROR_THRESHOLD)
37955 schedule_work(&sc->trigger_event);
37956 }
37957 diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
37958 index 1ff252a..ee384c1 100644
37959 --- a/drivers/md/dm-table.c
37960 +++ b/drivers/md/dm-table.c
37961 @@ -389,7 +389,7 @@ static int device_area_is_invalid(struct dm_target *ti, struct dm_dev *dev,
37962 if (!dev_size)
37963 return 0;
37964
37965 - if ((start >= dev_size) || (start + len > dev_size)) {
37966 + if ((start >= dev_size) || (len > dev_size - start)) {
37967 DMWARN("%s: %s too small for target: "
37968 "start=%llu, len=%llu, dev_size=%llu",
37969 dm_device_name(ti->table->md), bdevname(bdev, b),
37970 diff --git a/drivers/md/dm-thin-metadata.c b/drivers/md/dm-thin-metadata.c
37971 index 00cee02..b89a29d 100644
37972 --- a/drivers/md/dm-thin-metadata.c
37973 +++ b/drivers/md/dm-thin-metadata.c
37974 @@ -397,7 +397,7 @@ static void __setup_btree_details(struct dm_pool_metadata *pmd)
37975 {
37976 pmd->info.tm = pmd->tm;
37977 pmd->info.levels = 2;
37978 - pmd->info.value_type.context = pmd->data_sm;
37979 + pmd->info.value_type.context = (dm_space_map_no_const *)pmd->data_sm;
37980 pmd->info.value_type.size = sizeof(__le64);
37981 pmd->info.value_type.inc = data_block_inc;
37982 pmd->info.value_type.dec = data_block_dec;
37983 @@ -416,7 +416,7 @@ static void __setup_btree_details(struct dm_pool_metadata *pmd)
37984
37985 pmd->bl_info.tm = pmd->tm;
37986 pmd->bl_info.levels = 1;
37987 - pmd->bl_info.value_type.context = pmd->data_sm;
37988 + pmd->bl_info.value_type.context = (dm_space_map_no_const *)pmd->data_sm;
37989 pmd->bl_info.value_type.size = sizeof(__le64);
37990 pmd->bl_info.value_type.inc = data_block_inc;
37991 pmd->bl_info.value_type.dec = data_block_dec;
37992 diff --git a/drivers/md/dm.c b/drivers/md/dm.c
37993 index 9a0bdad..4df9543 100644
37994 --- a/drivers/md/dm.c
37995 +++ b/drivers/md/dm.c
37996 @@ -169,9 +169,9 @@ struct mapped_device {
37997 /*
37998 * Event handling.
37999 */
38000 - atomic_t event_nr;
38001 + atomic_unchecked_t event_nr;
38002 wait_queue_head_t eventq;
38003 - atomic_t uevent_seq;
38004 + atomic_unchecked_t uevent_seq;
38005 struct list_head uevent_list;
38006 spinlock_t uevent_lock; /* Protect access to uevent_list */
38007
38008 @@ -1879,8 +1879,8 @@ static struct mapped_device *alloc_dev(int minor)
38009 rwlock_init(&md->map_lock);
38010 atomic_set(&md->holders, 1);
38011 atomic_set(&md->open_count, 0);
38012 - atomic_set(&md->event_nr, 0);
38013 - atomic_set(&md->uevent_seq, 0);
38014 + atomic_set_unchecked(&md->event_nr, 0);
38015 + atomic_set_unchecked(&md->uevent_seq, 0);
38016 INIT_LIST_HEAD(&md->uevent_list);
38017 spin_lock_init(&md->uevent_lock);
38018
38019 @@ -2028,7 +2028,7 @@ static void event_callback(void *context)
38020
38021 dm_send_uevents(&uevents, &disk_to_dev(md->disk)->kobj);
38022
38023 - atomic_inc(&md->event_nr);
38024 + atomic_inc_unchecked(&md->event_nr);
38025 wake_up(&md->eventq);
38026 }
38027
38028 @@ -2685,18 +2685,18 @@ int dm_kobject_uevent(struct mapped_device *md, enum kobject_action action,
38029
38030 uint32_t dm_next_uevent_seq(struct mapped_device *md)
38031 {
38032 - return atomic_add_return(1, &md->uevent_seq);
38033 + return atomic_add_return_unchecked(1, &md->uevent_seq);
38034 }
38035
38036 uint32_t dm_get_event_nr(struct mapped_device *md)
38037 {
38038 - return atomic_read(&md->event_nr);
38039 + return atomic_read_unchecked(&md->event_nr);
38040 }
38041
38042 int dm_wait_event(struct mapped_device *md, int event_nr)
38043 {
38044 return wait_event_interruptible(md->eventq,
38045 - (event_nr != atomic_read(&md->event_nr)));
38046 + (event_nr != atomic_read_unchecked(&md->event_nr)));
38047 }
38048
38049 void dm_uevent_add(struct mapped_device *md, struct list_head *elist)
38050 diff --git a/drivers/md/md.c b/drivers/md/md.c
38051 index a4a93b9..4747b63 100644
38052 --- a/drivers/md/md.c
38053 +++ b/drivers/md/md.c
38054 @@ -240,10 +240,10 @@ EXPORT_SYMBOL_GPL(md_trim_bio);
38055 * start build, activate spare
38056 */
38057 static DECLARE_WAIT_QUEUE_HEAD(md_event_waiters);
38058 -static atomic_t md_event_count;
38059 +static atomic_unchecked_t md_event_count;
38060 void md_new_event(struct mddev *mddev)
38061 {
38062 - atomic_inc(&md_event_count);
38063 + atomic_inc_unchecked(&md_event_count);
38064 wake_up(&md_event_waiters);
38065 }
38066 EXPORT_SYMBOL_GPL(md_new_event);
38067 @@ -253,7 +253,7 @@ EXPORT_SYMBOL_GPL(md_new_event);
38068 */
38069 static void md_new_event_inintr(struct mddev *mddev)
38070 {
38071 - atomic_inc(&md_event_count);
38072 + atomic_inc_unchecked(&md_event_count);
38073 wake_up(&md_event_waiters);
38074 }
38075
38076 @@ -1507,7 +1507,7 @@ static int super_1_load(struct md_rdev *rdev, struct md_rdev *refdev, int minor_
38077 if ((le32_to_cpu(sb->feature_map) & MD_FEATURE_RESHAPE_ACTIVE) &&
38078 (le32_to_cpu(sb->feature_map) & MD_FEATURE_NEW_OFFSET))
38079 rdev->new_data_offset += (s32)le32_to_cpu(sb->new_offset);
38080 - atomic_set(&rdev->corrected_errors, le32_to_cpu(sb->cnt_corrected_read));
38081 + atomic_set_unchecked(&rdev->corrected_errors, le32_to_cpu(sb->cnt_corrected_read));
38082
38083 rdev->sb_size = le32_to_cpu(sb->max_dev) * 2 + 256;
38084 bmask = queue_logical_block_size(rdev->bdev->bd_disk->queue)-1;
38085 @@ -1751,7 +1751,7 @@ static void super_1_sync(struct mddev *mddev, struct md_rdev *rdev)
38086 else
38087 sb->resync_offset = cpu_to_le64(0);
38088
38089 - sb->cnt_corrected_read = cpu_to_le32(atomic_read(&rdev->corrected_errors));
38090 + sb->cnt_corrected_read = cpu_to_le32(atomic_read_unchecked(&rdev->corrected_errors));
38091
38092 sb->raid_disks = cpu_to_le32(mddev->raid_disks);
38093 sb->size = cpu_to_le64(mddev->dev_sectors);
38094 @@ -2751,7 +2751,7 @@ __ATTR(state, S_IRUGO|S_IWUSR, state_show, state_store);
38095 static ssize_t
38096 errors_show(struct md_rdev *rdev, char *page)
38097 {
38098 - return sprintf(page, "%d\n", atomic_read(&rdev->corrected_errors));
38099 + return sprintf(page, "%d\n", atomic_read_unchecked(&rdev->corrected_errors));
38100 }
38101
38102 static ssize_t
38103 @@ -2760,7 +2760,7 @@ errors_store(struct md_rdev *rdev, const char *buf, size_t len)
38104 char *e;
38105 unsigned long n = simple_strtoul(buf, &e, 10);
38106 if (*buf && (*e == 0 || *e == '\n')) {
38107 - atomic_set(&rdev->corrected_errors, n);
38108 + atomic_set_unchecked(&rdev->corrected_errors, n);
38109 return len;
38110 }
38111 return -EINVAL;
38112 @@ -3210,8 +3210,8 @@ int md_rdev_init(struct md_rdev *rdev)
38113 rdev->sb_loaded = 0;
38114 rdev->bb_page = NULL;
38115 atomic_set(&rdev->nr_pending, 0);
38116 - atomic_set(&rdev->read_errors, 0);
38117 - atomic_set(&rdev->corrected_errors, 0);
38118 + atomic_set_unchecked(&rdev->read_errors, 0);
38119 + atomic_set_unchecked(&rdev->corrected_errors, 0);
38120
38121 INIT_LIST_HEAD(&rdev->same_set);
38122 init_waitqueue_head(&rdev->blocked_wait);
38123 @@ -6994,7 +6994,7 @@ static int md_seq_show(struct seq_file *seq, void *v)
38124
38125 spin_unlock(&pers_lock);
38126 seq_printf(seq, "\n");
38127 - seq->poll_event = atomic_read(&md_event_count);
38128 + seq->poll_event = atomic_read_unchecked(&md_event_count);
38129 return 0;
38130 }
38131 if (v == (void*)2) {
38132 @@ -7097,7 +7097,7 @@ static int md_seq_open(struct inode *inode, struct file *file)
38133 return error;
38134
38135 seq = file->private_data;
38136 - seq->poll_event = atomic_read(&md_event_count);
38137 + seq->poll_event = atomic_read_unchecked(&md_event_count);
38138 return error;
38139 }
38140
38141 @@ -7111,7 +7111,7 @@ static unsigned int mdstat_poll(struct file *filp, poll_table *wait)
38142 /* always allow read */
38143 mask = POLLIN | POLLRDNORM;
38144
38145 - if (seq->poll_event != atomic_read(&md_event_count))
38146 + if (seq->poll_event != atomic_read_unchecked(&md_event_count))
38147 mask |= POLLERR | POLLPRI;
38148 return mask;
38149 }
38150 @@ -7155,7 +7155,7 @@ static int is_mddev_idle(struct mddev *mddev, int init)
38151 struct gendisk *disk = rdev->bdev->bd_contains->bd_disk;
38152 curr_events = (int)part_stat_read(&disk->part0, sectors[0]) +
38153 (int)part_stat_read(&disk->part0, sectors[1]) -
38154 - atomic_read(&disk->sync_io);
38155 + atomic_read_unchecked(&disk->sync_io);
38156 /* sync IO will cause sync_io to increase before the disk_stats
38157 * as sync_io is counted when a request starts, and
38158 * disk_stats is counted when it completes.
38159 diff --git a/drivers/md/md.h b/drivers/md/md.h
38160 index d90fb1a..4174a2b 100644
38161 --- a/drivers/md/md.h
38162 +++ b/drivers/md/md.h
38163 @@ -94,13 +94,13 @@ struct md_rdev {
38164 * only maintained for arrays that
38165 * support hot removal
38166 */
38167 - atomic_t read_errors; /* number of consecutive read errors that
38168 + atomic_unchecked_t read_errors; /* number of consecutive read errors that
38169 * we have tried to ignore.
38170 */
38171 struct timespec last_read_error; /* monotonic time since our
38172 * last read error
38173 */
38174 - atomic_t corrected_errors; /* number of corrected read errors,
38175 + atomic_unchecked_t corrected_errors; /* number of corrected read errors,
38176 * for reporting to userspace and storing
38177 * in superblock.
38178 */
38179 @@ -434,7 +434,7 @@ static inline void rdev_dec_pending(struct md_rdev *rdev, struct mddev *mddev)
38180
38181 static inline void md_sync_acct(struct block_device *bdev, unsigned long nr_sectors)
38182 {
38183 - atomic_add(nr_sectors, &bdev->bd_contains->bd_disk->sync_io);
38184 + atomic_add_unchecked(nr_sectors, &bdev->bd_contains->bd_disk->sync_io);
38185 }
38186
38187 struct md_personality
38188 diff --git a/drivers/md/persistent-data/dm-space-map.h b/drivers/md/persistent-data/dm-space-map.h
38189 index 1cbfc6b..56e1dbb 100644
38190 --- a/drivers/md/persistent-data/dm-space-map.h
38191 +++ b/drivers/md/persistent-data/dm-space-map.h
38192 @@ -60,6 +60,7 @@ struct dm_space_map {
38193 int (*root_size)(struct dm_space_map *sm, size_t *result);
38194 int (*copy_root)(struct dm_space_map *sm, void *copy_to_here_le, size_t len);
38195 };
38196 +typedef struct dm_space_map __no_const dm_space_map_no_const;
38197
38198 /*----------------------------------------------------------------*/
38199
38200 diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
38201 index 6af167f..40c25a1 100644
38202 --- a/drivers/md/raid1.c
38203 +++ b/drivers/md/raid1.c
38204 @@ -1826,7 +1826,7 @@ static int fix_sync_read_error(struct r1bio *r1_bio)
38205 if (r1_sync_page_io(rdev, sect, s,
38206 bio->bi_io_vec[idx].bv_page,
38207 READ) != 0)
38208 - atomic_add(s, &rdev->corrected_errors);
38209 + atomic_add_unchecked(s, &rdev->corrected_errors);
38210 }
38211 sectors -= s;
38212 sect += s;
38213 @@ -2048,7 +2048,7 @@ static void fix_read_error(struct r1conf *conf, int read_disk,
38214 test_bit(In_sync, &rdev->flags)) {
38215 if (r1_sync_page_io(rdev, sect, s,
38216 conf->tmppage, READ)) {
38217 - atomic_add(s, &rdev->corrected_errors);
38218 + atomic_add_unchecked(s, &rdev->corrected_errors);
38219 printk(KERN_INFO
38220 "md/raid1:%s: read error corrected "
38221 "(%d sectors at %llu on %s)\n",
38222 diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
38223 index 46c14e5..4db5966 100644
38224 --- a/drivers/md/raid10.c
38225 +++ b/drivers/md/raid10.c
38226 @@ -1932,7 +1932,7 @@ static void end_sync_read(struct bio *bio, int error)
38227 /* The write handler will notice the lack of
38228 * R10BIO_Uptodate and record any errors etc
38229 */
38230 - atomic_add(r10_bio->sectors,
38231 + atomic_add_unchecked(r10_bio->sectors,
38232 &conf->mirrors[d].rdev->corrected_errors);
38233
38234 /* for reconstruct, we always reschedule after a read.
38235 @@ -2281,7 +2281,7 @@ static void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev)
38236 {
38237 struct timespec cur_time_mon;
38238 unsigned long hours_since_last;
38239 - unsigned int read_errors = atomic_read(&rdev->read_errors);
38240 + unsigned int read_errors = atomic_read_unchecked(&rdev->read_errors);
38241
38242 ktime_get_ts(&cur_time_mon);
38243
38244 @@ -2303,9 +2303,9 @@ static void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev)
38245 * overflowing the shift of read_errors by hours_since_last.
38246 */
38247 if (hours_since_last >= 8 * sizeof(read_errors))
38248 - atomic_set(&rdev->read_errors, 0);
38249 + atomic_set_unchecked(&rdev->read_errors, 0);
38250 else
38251 - atomic_set(&rdev->read_errors, read_errors >> hours_since_last);
38252 + atomic_set_unchecked(&rdev->read_errors, read_errors >> hours_since_last);
38253 }
38254
38255 static int r10_sync_page_io(struct md_rdev *rdev, sector_t sector,
38256 @@ -2359,8 +2359,8 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
38257 return;
38258
38259 check_decay_read_errors(mddev, rdev);
38260 - atomic_inc(&rdev->read_errors);
38261 - if (atomic_read(&rdev->read_errors) > max_read_errors) {
38262 + atomic_inc_unchecked(&rdev->read_errors);
38263 + if (atomic_read_unchecked(&rdev->read_errors) > max_read_errors) {
38264 char b[BDEVNAME_SIZE];
38265 bdevname(rdev->bdev, b);
38266
38267 @@ -2368,7 +2368,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
38268 "md/raid10:%s: %s: Raid device exceeded "
38269 "read_error threshold [cur %d:max %d]\n",
38270 mdname(mddev), b,
38271 - atomic_read(&rdev->read_errors), max_read_errors);
38272 + atomic_read_unchecked(&rdev->read_errors), max_read_errors);
38273 printk(KERN_NOTICE
38274 "md/raid10:%s: %s: Failing raid device\n",
38275 mdname(mddev), b);
38276 @@ -2523,7 +2523,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
38277 sect +
38278 choose_data_offset(r10_bio, rdev)),
38279 bdevname(rdev->bdev, b));
38280 - atomic_add(s, &rdev->corrected_errors);
38281 + atomic_add_unchecked(s, &rdev->corrected_errors);
38282 }
38283
38284 rdev_dec_pending(rdev, mddev);
38285 diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
38286 index f4e87bf..0d4ad3f 100644
38287 --- a/drivers/md/raid5.c
38288 +++ b/drivers/md/raid5.c
38289 @@ -1763,21 +1763,21 @@ static void raid5_end_read_request(struct bio * bi, int error)
38290 mdname(conf->mddev), STRIPE_SECTORS,
38291 (unsigned long long)s,
38292 bdevname(rdev->bdev, b));
38293 - atomic_add(STRIPE_SECTORS, &rdev->corrected_errors);
38294 + atomic_add_unchecked(STRIPE_SECTORS, &rdev->corrected_errors);
38295 clear_bit(R5_ReadError, &sh->dev[i].flags);
38296 clear_bit(R5_ReWrite, &sh->dev[i].flags);
38297 } else if (test_bit(R5_ReadNoMerge, &sh->dev[i].flags))
38298 clear_bit(R5_ReadNoMerge, &sh->dev[i].flags);
38299
38300 - if (atomic_read(&rdev->read_errors))
38301 - atomic_set(&rdev->read_errors, 0);
38302 + if (atomic_read_unchecked(&rdev->read_errors))
38303 + atomic_set_unchecked(&rdev->read_errors, 0);
38304 } else {
38305 const char *bdn = bdevname(rdev->bdev, b);
38306 int retry = 0;
38307 int set_bad = 0;
38308
38309 clear_bit(R5_UPTODATE, &sh->dev[i].flags);
38310 - atomic_inc(&rdev->read_errors);
38311 + atomic_inc_unchecked(&rdev->read_errors);
38312 if (test_bit(R5_ReadRepl, &sh->dev[i].flags))
38313 printk_ratelimited(
38314 KERN_WARNING
38315 @@ -1805,7 +1805,7 @@ static void raid5_end_read_request(struct bio * bi, int error)
38316 mdname(conf->mddev),
38317 (unsigned long long)s,
38318 bdn);
38319 - } else if (atomic_read(&rdev->read_errors)
38320 + } else if (atomic_read_unchecked(&rdev->read_errors)
38321 > conf->max_nr_stripes)
38322 printk(KERN_WARNING
38323 "md/raid:%s: Too many read errors, failing device %s.\n",
38324 diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
38325 index 401ef64..836e563 100644
38326 --- a/drivers/media/dvb-core/dvbdev.c
38327 +++ b/drivers/media/dvb-core/dvbdev.c
38328 @@ -192,7 +192,7 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
38329 const struct dvb_device *template, void *priv, int type)
38330 {
38331 struct dvb_device *dvbdev;
38332 - struct file_operations *dvbdevfops;
38333 + file_operations_no_const *dvbdevfops;
38334 struct device *clsdev;
38335 int minor;
38336 int id;
38337 diff --git a/drivers/media/dvb-frontends/dib3000.h b/drivers/media/dvb-frontends/dib3000.h
38338 index 9b6c3bb..baeb5c7 100644
38339 --- a/drivers/media/dvb-frontends/dib3000.h
38340 +++ b/drivers/media/dvb-frontends/dib3000.h
38341 @@ -39,7 +39,7 @@ struct dib_fe_xfer_ops
38342 int (*fifo_ctrl)(struct dvb_frontend *fe, int onoff);
38343 int (*pid_ctrl)(struct dvb_frontend *fe, int index, int pid, int onoff);
38344 int (*tuner_pass_ctrl)(struct dvb_frontend *fe, int onoff, u8 pll_ctrl);
38345 -};
38346 +} __no_const;
38347
38348 #if IS_ENABLED(CONFIG_DVB_DIB3000MB)
38349 extern struct dvb_frontend* dib3000mb_attach(const struct dib3000_config* config,
38350 diff --git a/drivers/media/pci/cx88/cx88-video.c b/drivers/media/pci/cx88/cx88-video.c
38351 index bc78354..42c9459 100644
38352 --- a/drivers/media/pci/cx88/cx88-video.c
38353 +++ b/drivers/media/pci/cx88/cx88-video.c
38354 @@ -50,9 +50,9 @@ MODULE_VERSION(CX88_VERSION);
38355
38356 /* ------------------------------------------------------------------ */
38357
38358 -static unsigned int video_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38359 -static unsigned int vbi_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38360 -static unsigned int radio_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38361 +static int video_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38362 +static int vbi_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38363 +static int radio_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38364
38365 module_param_array(video_nr, int, NULL, 0444);
38366 module_param_array(vbi_nr, int, NULL, 0444);
38367 diff --git a/drivers/media/platform/omap/omap_vout.c b/drivers/media/platform/omap/omap_vout.c
38368 index 96c4a17..1305a79 100644
38369 --- a/drivers/media/platform/omap/omap_vout.c
38370 +++ b/drivers/media/platform/omap/omap_vout.c
38371 @@ -63,7 +63,6 @@ enum omap_vout_channels {
38372 OMAP_VIDEO2,
38373 };
38374
38375 -static struct videobuf_queue_ops video_vbq_ops;
38376 /* Variables configurable through module params*/
38377 static u32 video1_numbuffers = 3;
38378 static u32 video2_numbuffers = 3;
38379 @@ -1012,6 +1011,12 @@ static int omap_vout_open(struct file *file)
38380 {
38381 struct videobuf_queue *q;
38382 struct omap_vout_device *vout = NULL;
38383 + static struct videobuf_queue_ops video_vbq_ops = {
38384 + .buf_setup = omap_vout_buffer_setup,
38385 + .buf_prepare = omap_vout_buffer_prepare,
38386 + .buf_release = omap_vout_buffer_release,
38387 + .buf_queue = omap_vout_buffer_queue,
38388 + };
38389
38390 vout = video_drvdata(file);
38391 v4l2_dbg(1, debug, &vout->vid_dev->v4l2_dev, "Entering %s\n", __func__);
38392 @@ -1029,10 +1034,6 @@ static int omap_vout_open(struct file *file)
38393 vout->type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
38394
38395 q = &vout->vbq;
38396 - video_vbq_ops.buf_setup = omap_vout_buffer_setup;
38397 - video_vbq_ops.buf_prepare = omap_vout_buffer_prepare;
38398 - video_vbq_ops.buf_release = omap_vout_buffer_release;
38399 - video_vbq_ops.buf_queue = omap_vout_buffer_queue;
38400 spin_lock_init(&vout->vbq_lock);
38401
38402 videobuf_queue_dma_contig_init(q, &video_vbq_ops, q->dev,
38403 diff --git a/drivers/media/platform/s5p-tv/mixer.h b/drivers/media/platform/s5p-tv/mixer.h
38404 index 04e6490..2df65bf 100644
38405 --- a/drivers/media/platform/s5p-tv/mixer.h
38406 +++ b/drivers/media/platform/s5p-tv/mixer.h
38407 @@ -156,7 +156,7 @@ struct mxr_layer {
38408 /** layer index (unique identifier) */
38409 int idx;
38410 /** callbacks for layer methods */
38411 - struct mxr_layer_ops ops;
38412 + struct mxr_layer_ops *ops;
38413 /** format array */
38414 const struct mxr_format **fmt_array;
38415 /** size of format array */
38416 diff --git a/drivers/media/platform/s5p-tv/mixer_grp_layer.c b/drivers/media/platform/s5p-tv/mixer_grp_layer.c
38417 index b93a21f..2535195 100644
38418 --- a/drivers/media/platform/s5p-tv/mixer_grp_layer.c
38419 +++ b/drivers/media/platform/s5p-tv/mixer_grp_layer.c
38420 @@ -235,7 +235,7 @@ struct mxr_layer *mxr_graph_layer_create(struct mxr_device *mdev, int idx)
38421 {
38422 struct mxr_layer *layer;
38423 int ret;
38424 - struct mxr_layer_ops ops = {
38425 + static struct mxr_layer_ops ops = {
38426 .release = mxr_graph_layer_release,
38427 .buffer_set = mxr_graph_buffer_set,
38428 .stream_set = mxr_graph_stream_set,
38429 diff --git a/drivers/media/platform/s5p-tv/mixer_reg.c b/drivers/media/platform/s5p-tv/mixer_reg.c
38430 index b713403..53cb5ad 100644
38431 --- a/drivers/media/platform/s5p-tv/mixer_reg.c
38432 +++ b/drivers/media/platform/s5p-tv/mixer_reg.c
38433 @@ -276,7 +276,7 @@ static void mxr_irq_layer_handle(struct mxr_layer *layer)
38434 layer->update_buf = next;
38435 }
38436
38437 - layer->ops.buffer_set(layer, layer->update_buf);
38438 + layer->ops->buffer_set(layer, layer->update_buf);
38439
38440 if (done && done != layer->shadow_buf)
38441 vb2_buffer_done(&done->vb, VB2_BUF_STATE_DONE);
38442 diff --git a/drivers/media/platform/s5p-tv/mixer_video.c b/drivers/media/platform/s5p-tv/mixer_video.c
38443 index 82142a2..6de47e8 100644
38444 --- a/drivers/media/platform/s5p-tv/mixer_video.c
38445 +++ b/drivers/media/platform/s5p-tv/mixer_video.c
38446 @@ -209,7 +209,7 @@ static void mxr_layer_default_geo(struct mxr_layer *layer)
38447 layer->geo.src.height = layer->geo.src.full_height;
38448
38449 mxr_geometry_dump(mdev, &layer->geo);
38450 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
38451 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
38452 mxr_geometry_dump(mdev, &layer->geo);
38453 }
38454
38455 @@ -227,7 +227,7 @@ static void mxr_layer_update_output(struct mxr_layer *layer)
38456 layer->geo.dst.full_width = mbus_fmt.width;
38457 layer->geo.dst.full_height = mbus_fmt.height;
38458 layer->geo.dst.field = mbus_fmt.field;
38459 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
38460 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
38461
38462 mxr_geometry_dump(mdev, &layer->geo);
38463 }
38464 @@ -333,7 +333,7 @@ static int mxr_s_fmt(struct file *file, void *priv,
38465 /* set source size to highest accepted value */
38466 geo->src.full_width = max(geo->dst.full_width, pix->width);
38467 geo->src.full_height = max(geo->dst.full_height, pix->height);
38468 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
38469 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
38470 mxr_geometry_dump(mdev, &layer->geo);
38471 /* set cropping to total visible screen */
38472 geo->src.width = pix->width;
38473 @@ -341,12 +341,12 @@ static int mxr_s_fmt(struct file *file, void *priv,
38474 geo->src.x_offset = 0;
38475 geo->src.y_offset = 0;
38476 /* assure consistency of geometry */
38477 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_CROP, MXR_NO_OFFSET);
38478 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_CROP, MXR_NO_OFFSET);
38479 mxr_geometry_dump(mdev, &layer->geo);
38480 /* set full size to lowest possible value */
38481 geo->src.full_width = 0;
38482 geo->src.full_height = 0;
38483 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
38484 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
38485 mxr_geometry_dump(mdev, &layer->geo);
38486
38487 /* returning results */
38488 @@ -473,7 +473,7 @@ static int mxr_s_selection(struct file *file, void *fh,
38489 target->width = s->r.width;
38490 target->height = s->r.height;
38491
38492 - layer->ops.fix_geometry(layer, stage, s->flags);
38493 + layer->ops->fix_geometry(layer, stage, s->flags);
38494
38495 /* retrieve update selection rectangle */
38496 res.left = target->x_offset;
38497 @@ -938,13 +938,13 @@ static int start_streaming(struct vb2_queue *vq, unsigned int count)
38498 mxr_output_get(mdev);
38499
38500 mxr_layer_update_output(layer);
38501 - layer->ops.format_set(layer);
38502 + layer->ops->format_set(layer);
38503 /* enabling layer in hardware */
38504 spin_lock_irqsave(&layer->enq_slock, flags);
38505 layer->state = MXR_LAYER_STREAMING;
38506 spin_unlock_irqrestore(&layer->enq_slock, flags);
38507
38508 - layer->ops.stream_set(layer, MXR_ENABLE);
38509 + layer->ops->stream_set(layer, MXR_ENABLE);
38510 mxr_streamer_get(mdev);
38511
38512 return 0;
38513 @@ -1014,7 +1014,7 @@ static int stop_streaming(struct vb2_queue *vq)
38514 spin_unlock_irqrestore(&layer->enq_slock, flags);
38515
38516 /* disabling layer in hardware */
38517 - layer->ops.stream_set(layer, MXR_DISABLE);
38518 + layer->ops->stream_set(layer, MXR_DISABLE);
38519 /* remove one streamer */
38520 mxr_streamer_put(mdev);
38521 /* allow changes in output configuration */
38522 @@ -1053,8 +1053,8 @@ void mxr_base_layer_unregister(struct mxr_layer *layer)
38523
38524 void mxr_layer_release(struct mxr_layer *layer)
38525 {
38526 - if (layer->ops.release)
38527 - layer->ops.release(layer);
38528 + if (layer->ops->release)
38529 + layer->ops->release(layer);
38530 }
38531
38532 void mxr_base_layer_release(struct mxr_layer *layer)
38533 @@ -1080,7 +1080,7 @@ struct mxr_layer *mxr_base_layer_create(struct mxr_device *mdev,
38534
38535 layer->mdev = mdev;
38536 layer->idx = idx;
38537 - layer->ops = *ops;
38538 + layer->ops = ops;
38539
38540 spin_lock_init(&layer->enq_slock);
38541 INIT_LIST_HEAD(&layer->enq_list);
38542 diff --git a/drivers/media/platform/s5p-tv/mixer_vp_layer.c b/drivers/media/platform/s5p-tv/mixer_vp_layer.c
38543 index 3d13a63..da31bf1 100644
38544 --- a/drivers/media/platform/s5p-tv/mixer_vp_layer.c
38545 +++ b/drivers/media/platform/s5p-tv/mixer_vp_layer.c
38546 @@ -206,7 +206,7 @@ struct mxr_layer *mxr_vp_layer_create(struct mxr_device *mdev, int idx)
38547 {
38548 struct mxr_layer *layer;
38549 int ret;
38550 - struct mxr_layer_ops ops = {
38551 + static struct mxr_layer_ops ops = {
38552 .release = mxr_vp_layer_release,
38553 .buffer_set = mxr_vp_buffer_set,
38554 .stream_set = mxr_vp_stream_set,
38555 diff --git a/drivers/media/radio/radio-cadet.c b/drivers/media/radio/radio-cadet.c
38556 index 643d80a..56bb96b 100644
38557 --- a/drivers/media/radio/radio-cadet.c
38558 +++ b/drivers/media/radio/radio-cadet.c
38559 @@ -302,6 +302,8 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo
38560 unsigned char readbuf[RDS_BUFFER];
38561 int i = 0;
38562
38563 + if (count > RDS_BUFFER)
38564 + return -EFAULT;
38565 mutex_lock(&dev->lock);
38566 if (dev->rdsstat == 0)
38567 cadet_start_rds(dev);
38568 @@ -317,7 +319,7 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo
38569 while (i < count && dev->rdsin != dev->rdsout)
38570 readbuf[i++] = dev->rdsbuf[dev->rdsout++];
38571
38572 - if (i && copy_to_user(data, readbuf, i))
38573 + if (i > sizeof(readbuf) || copy_to_user(data, readbuf, i))
38574 i = -EFAULT;
38575 unlock:
38576 mutex_unlock(&dev->lock);
38577 diff --git a/drivers/media/usb/dvb-usb/cxusb.c b/drivers/media/usb/dvb-usb/cxusb.c
38578 index 3940bb0..fb3952a 100644
38579 --- a/drivers/media/usb/dvb-usb/cxusb.c
38580 +++ b/drivers/media/usb/dvb-usb/cxusb.c
38581 @@ -1068,7 +1068,7 @@ static struct dib0070_config dib7070p_dib0070_config = {
38582
38583 struct dib0700_adapter_state {
38584 int (*set_param_save) (struct dvb_frontend *);
38585 -};
38586 +} __no_const;
38587
38588 static int dib7070_set_param_override(struct dvb_frontend *fe)
38589 {
38590 diff --git a/drivers/media/usb/dvb-usb/dw2102.c b/drivers/media/usb/dvb-usb/dw2102.c
38591 index 9578a67..31aa652 100644
38592 --- a/drivers/media/usb/dvb-usb/dw2102.c
38593 +++ b/drivers/media/usb/dvb-usb/dw2102.c
38594 @@ -115,7 +115,7 @@ struct su3000_state {
38595
38596 struct s6x0_state {
38597 int (*old_set_voltage)(struct dvb_frontend *f, fe_sec_voltage_t v);
38598 -};
38599 +} __no_const;
38600
38601 /* debug */
38602 static int dvb_usb_dw2102_debug;
38603 diff --git a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
38604 index 7157af3..139e91a 100644
38605 --- a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
38606 +++ b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
38607 @@ -326,7 +326,7 @@ struct v4l2_buffer32 {
38608 __u32 reserved;
38609 };
38610
38611 -static int get_v4l2_plane32(struct v4l2_plane *up, struct v4l2_plane32 *up32,
38612 +static int get_v4l2_plane32(struct v4l2_plane __user *up, struct v4l2_plane32 __user *up32,
38613 enum v4l2_memory memory)
38614 {
38615 void __user *up_pln;
38616 @@ -355,7 +355,7 @@ static int get_v4l2_plane32(struct v4l2_plane *up, struct v4l2_plane32 *up32,
38617 return 0;
38618 }
38619
38620 -static int put_v4l2_plane32(struct v4l2_plane *up, struct v4l2_plane32 *up32,
38621 +static int put_v4l2_plane32(struct v4l2_plane __user *up, struct v4l2_plane32 __user *up32,
38622 enum v4l2_memory memory)
38623 {
38624 if (copy_in_user(up32, up, 2 * sizeof(__u32)) ||
38625 @@ -772,7 +772,7 @@ static int put_v4l2_subdev_edid32(struct v4l2_subdev_edid *kp, struct v4l2_subde
38626 put_user(kp->start_block, &up->start_block) ||
38627 put_user(kp->blocks, &up->blocks) ||
38628 put_user(tmp, &up->edid) ||
38629 - copy_to_user(kp->reserved, up->reserved, sizeof(kp->reserved)))
38630 + copy_to_user(up->reserved, kp->reserved, sizeof(kp->reserved)))
38631 return -EFAULT;
38632 return 0;
38633 }
38634 diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
38635 index aa6e7c7..cb5de87 100644
38636 --- a/drivers/media/v4l2-core/v4l2-ioctl.c
38637 +++ b/drivers/media/v4l2-core/v4l2-ioctl.c
38638 @@ -236,7 +236,7 @@ static void v4l_print_format(const void *arg, bool write_only)
38639 const struct v4l2_vbi_format *vbi;
38640 const struct v4l2_sliced_vbi_format *sliced;
38641 const struct v4l2_window *win;
38642 - const struct v4l2_clip *clip;
38643 + const struct v4l2_clip __user *pclip;
38644 unsigned i;
38645
38646 pr_cont("type=%s", prt_names(p->type, v4l2_type_names));
38647 @@ -284,12 +284,16 @@ static void v4l_print_format(const void *arg, bool write_only)
38648 win->w.left, win->w.top,
38649 prt_names(win->field, v4l2_field_names),
38650 win->chromakey, win->bitmap, win->global_alpha);
38651 - clip = win->clips;
38652 + pclip = win->clips;
38653 for (i = 0; i < win->clipcount; i++) {
38654 + struct v4l2_clip clip;
38655 +
38656 + if (copy_from_user(&clip, pclip, sizeof clip))
38657 + break;
38658 printk(KERN_DEBUG "clip %u: wxh=%dx%d, x,y=%d,%d\n",
38659 - i, clip->c.width, clip->c.height,
38660 - clip->c.left, clip->c.top);
38661 - clip = clip->next;
38662 + i, clip.c.width, clip.c.height,
38663 + clip.c.left, clip.c.top);
38664 + pclip = clip.next;
38665 }
38666 break;
38667 case V4L2_BUF_TYPE_VBI_CAPTURE:
38668 @@ -1923,7 +1927,8 @@ struct v4l2_ioctl_info {
38669 struct file *file, void *fh, void *p);
38670 } u;
38671 void (*debug)(const void *arg, bool write_only);
38672 -};
38673 +} __do_const;
38674 +typedef struct v4l2_ioctl_info __no_const v4l2_ioctl_info_no_const;
38675
38676 /* This control needs a priority check */
38677 #define INFO_FL_PRIO (1 << 0)
38678 @@ -2108,7 +2113,7 @@ static long __video_do_ioctl(struct file *file,
38679 struct video_device *vfd = video_devdata(file);
38680 const struct v4l2_ioctl_ops *ops = vfd->ioctl_ops;
38681 bool write_only = false;
38682 - struct v4l2_ioctl_info default_info;
38683 + v4l2_ioctl_info_no_const default_info;
38684 const struct v4l2_ioctl_info *info;
38685 void *fh = file->private_data;
38686 struct v4l2_fh *vfh = NULL;
38687 @@ -2193,7 +2198,7 @@ done:
38688 }
38689
38690 static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
38691 - void * __user *user_ptr, void ***kernel_ptr)
38692 + void __user **user_ptr, void ***kernel_ptr)
38693 {
38694 int ret = 0;
38695
38696 @@ -2209,7 +2214,7 @@ static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
38697 ret = -EINVAL;
38698 break;
38699 }
38700 - *user_ptr = (void __user *)buf->m.planes;
38701 + *user_ptr = (void __force_user *)buf->m.planes;
38702 *kernel_ptr = (void *)&buf->m.planes;
38703 *array_size = sizeof(struct v4l2_plane) * buf->length;
38704 ret = 1;
38705 @@ -2244,7 +2249,7 @@ static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
38706 ret = -EINVAL;
38707 break;
38708 }
38709 - *user_ptr = (void __user *)ctrls->controls;
38710 + *user_ptr = (void __force_user *)ctrls->controls;
38711 *kernel_ptr = (void *)&ctrls->controls;
38712 *array_size = sizeof(struct v4l2_ext_control)
38713 * ctrls->count;
38714 diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
38715 index fb69baa..3aeea2e 100644
38716 --- a/drivers/message/fusion/mptbase.c
38717 +++ b/drivers/message/fusion/mptbase.c
38718 @@ -6755,8 +6755,13 @@ static int mpt_iocinfo_proc_show(struct seq_file *m, void *v)
38719 seq_printf(m, " MaxChainDepth = 0x%02x frames\n", ioc->facts.MaxChainDepth);
38720 seq_printf(m, " MinBlockSize = 0x%02x bytes\n", 4*ioc->facts.BlockSize);
38721
38722 +#ifdef CONFIG_GRKERNSEC_HIDESYM
38723 + seq_printf(m, " RequestFrames @ 0x%p (Dma @ 0x%p)\n", NULL, NULL);
38724 +#else
38725 seq_printf(m, " RequestFrames @ 0x%p (Dma @ 0x%p)\n",
38726 (void *)ioc->req_frames, (void *)(ulong)ioc->req_frames_dma);
38727 +#endif
38728 +
38729 /*
38730 * Rounding UP to nearest 4-kB boundary here...
38731 */
38732 @@ -6769,7 +6774,11 @@ static int mpt_iocinfo_proc_show(struct seq_file *m, void *v)
38733 ioc->facts.GlobalCredits);
38734
38735 seq_printf(m, " Frames @ 0x%p (Dma @ 0x%p)\n",
38736 +#ifdef CONFIG_GRKERNSEC_HIDESYM
38737 + NULL, NULL);
38738 +#else
38739 (void *)ioc->alloc, (void *)(ulong)ioc->alloc_dma);
38740 +#endif
38741 sz = (ioc->reply_sz * ioc->reply_depth) + 128;
38742 seq_printf(m, " {CurRepSz=%d} x {CurRepDepth=%d} = %d bytes ^= 0x%x\n",
38743 ioc->reply_sz, ioc->reply_depth, ioc->reply_sz*ioc->reply_depth, sz);
38744 diff --git a/drivers/message/fusion/mptsas.c b/drivers/message/fusion/mptsas.c
38745 index fa43c39..daeb158 100644
38746 --- a/drivers/message/fusion/mptsas.c
38747 +++ b/drivers/message/fusion/mptsas.c
38748 @@ -446,6 +446,23 @@ mptsas_is_end_device(struct mptsas_devinfo * attached)
38749 return 0;
38750 }
38751
38752 +static inline void
38753 +mptsas_set_rphy(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_rphy *rphy)
38754 +{
38755 + if (phy_info->port_details) {
38756 + phy_info->port_details->rphy = rphy;
38757 + dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sas_rphy_add: rphy=%p\n",
38758 + ioc->name, rphy));
38759 + }
38760 +
38761 + if (rphy) {
38762 + dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
38763 + &rphy->dev, MYIOC_s_FMT "add:", ioc->name));
38764 + dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rphy=%p release=%p\n",
38765 + ioc->name, rphy, rphy->dev.release));
38766 + }
38767 +}
38768 +
38769 /* no mutex */
38770 static void
38771 mptsas_port_delete(MPT_ADAPTER *ioc, struct mptsas_portinfo_details * port_details)
38772 @@ -484,23 +501,6 @@ mptsas_get_rphy(struct mptsas_phyinfo *phy_info)
38773 return NULL;
38774 }
38775
38776 -static inline void
38777 -mptsas_set_rphy(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_rphy *rphy)
38778 -{
38779 - if (phy_info->port_details) {
38780 - phy_info->port_details->rphy = rphy;
38781 - dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sas_rphy_add: rphy=%p\n",
38782 - ioc->name, rphy));
38783 - }
38784 -
38785 - if (rphy) {
38786 - dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
38787 - &rphy->dev, MYIOC_s_FMT "add:", ioc->name));
38788 - dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rphy=%p release=%p\n",
38789 - ioc->name, rphy, rphy->dev.release));
38790 - }
38791 -}
38792 -
38793 static inline struct sas_port *
38794 mptsas_get_port(struct mptsas_phyinfo *phy_info)
38795 {
38796 diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c
38797 index 164afa7..b6b2e74 100644
38798 --- a/drivers/message/fusion/mptscsih.c
38799 +++ b/drivers/message/fusion/mptscsih.c
38800 @@ -1271,15 +1271,16 @@ mptscsih_info(struct Scsi_Host *SChost)
38801
38802 h = shost_priv(SChost);
38803
38804 - if (h) {
38805 - if (h->info_kbuf == NULL)
38806 - if ((h->info_kbuf = kmalloc(0x1000 /* 4Kb */, GFP_KERNEL)) == NULL)
38807 - return h->info_kbuf;
38808 - h->info_kbuf[0] = '\0';
38809 + if (!h)
38810 + return NULL;
38811
38812 - mpt_print_ioc_summary(h->ioc, h->info_kbuf, &size, 0, 0);
38813 - h->info_kbuf[size-1] = '\0';
38814 - }
38815 + if (h->info_kbuf == NULL)
38816 + if ((h->info_kbuf = kmalloc(0x1000 /* 4Kb */, GFP_KERNEL)) == NULL)
38817 + return h->info_kbuf;
38818 + h->info_kbuf[0] = '\0';
38819 +
38820 + mpt_print_ioc_summary(h->ioc, h->info_kbuf, &size, 0, 0);
38821 + h->info_kbuf[size-1] = '\0';
38822
38823 return h->info_kbuf;
38824 }
38825 diff --git a/drivers/message/i2o/i2o_proc.c b/drivers/message/i2o/i2o_proc.c
38826 index 8001aa6..b137580 100644
38827 --- a/drivers/message/i2o/i2o_proc.c
38828 +++ b/drivers/message/i2o/i2o_proc.c
38829 @@ -255,12 +255,6 @@ static char *scsi_devices[] = {
38830 "Array Controller Device"
38831 };
38832
38833 -static char *chtostr(char *tmp, u8 *chars, int n)
38834 -{
38835 - tmp[0] = 0;
38836 - return strncat(tmp, (char *)chars, n);
38837 -}
38838 -
38839 static int i2o_report_query_status(struct seq_file *seq, int block_status,
38840 char *group)
38841 {
38842 @@ -790,7 +784,6 @@ static int i2o_seq_show_ddm_table(struct seq_file *seq, void *v)
38843 } *result;
38844
38845 i2o_exec_execute_ddm_table ddm_table;
38846 - char tmp[28 + 1];
38847
38848 result = kmalloc(sizeof(*result), GFP_KERNEL);
38849 if (!result)
38850 @@ -825,8 +818,7 @@ static int i2o_seq_show_ddm_table(struct seq_file *seq, void *v)
38851
38852 seq_printf(seq, "%-#7x", ddm_table.i2o_vendor_id);
38853 seq_printf(seq, "%-#8x", ddm_table.module_id);
38854 - seq_printf(seq, "%-29s",
38855 - chtostr(tmp, ddm_table.module_name_version, 28));
38856 + seq_printf(seq, "%-.28s", ddm_table.module_name_version);
38857 seq_printf(seq, "%9d ", ddm_table.data_size);
38858 seq_printf(seq, "%8d", ddm_table.code_size);
38859
38860 @@ -893,7 +885,6 @@ static int i2o_seq_show_drivers_stored(struct seq_file *seq, void *v)
38861
38862 i2o_driver_result_table *result;
38863 i2o_driver_store_table *dst;
38864 - char tmp[28 + 1];
38865
38866 result = kmalloc(sizeof(i2o_driver_result_table), GFP_KERNEL);
38867 if (result == NULL)
38868 @@ -928,9 +919,8 @@ static int i2o_seq_show_drivers_stored(struct seq_file *seq, void *v)
38869
38870 seq_printf(seq, "%-#7x", dst->i2o_vendor_id);
38871 seq_printf(seq, "%-#8x", dst->module_id);
38872 - seq_printf(seq, "%-29s",
38873 - chtostr(tmp, dst->module_name_version, 28));
38874 - seq_printf(seq, "%-9s", chtostr(tmp, dst->date, 8));
38875 + seq_printf(seq, "%-.28s", dst->module_name_version);
38876 + seq_printf(seq, "%-.8s", dst->date);
38877 seq_printf(seq, "%8d ", dst->module_size);
38878 seq_printf(seq, "%8d ", dst->mpb_size);
38879 seq_printf(seq, "0x%04x", dst->module_flags);
38880 @@ -1250,7 +1240,6 @@ static int i2o_seq_show_dev_identity(struct seq_file *seq, void *v)
38881 // == (allow) 512d bytes (max)
38882 static u16 *work16 = (u16 *) work32;
38883 int token;
38884 - char tmp[16 + 1];
38885
38886 token = i2o_parm_field_get(d, 0xF100, -1, &work32, sizeof(work32));
38887
38888 @@ -1262,14 +1251,10 @@ static int i2o_seq_show_dev_identity(struct seq_file *seq, void *v)
38889 seq_printf(seq, "Device Class : %s\n", i2o_get_class_name(work16[0]));
38890 seq_printf(seq, "Owner TID : %0#5x\n", work16[2]);
38891 seq_printf(seq, "Parent TID : %0#5x\n", work16[3]);
38892 - seq_printf(seq, "Vendor info : %s\n",
38893 - chtostr(tmp, (u8 *) (work32 + 2), 16));
38894 - seq_printf(seq, "Product info : %s\n",
38895 - chtostr(tmp, (u8 *) (work32 + 6), 16));
38896 - seq_printf(seq, "Description : %s\n",
38897 - chtostr(tmp, (u8 *) (work32 + 10), 16));
38898 - seq_printf(seq, "Product rev. : %s\n",
38899 - chtostr(tmp, (u8 *) (work32 + 14), 8));
38900 + seq_printf(seq, "Vendor info : %.16s\n", (u8 *) (work32 + 2));
38901 + seq_printf(seq, "Product info : %.16s\n", (u8 *) (work32 + 6));
38902 + seq_printf(seq, "Description : %.16s\n", (u8 *) (work32 + 10));
38903 + seq_printf(seq, "Product rev. : %.8s\n", (u8 *) (work32 + 14));
38904
38905 seq_printf(seq, "Serial number : ");
38906 print_serial_number(seq, (u8 *) (work32 + 16),
38907 @@ -1306,8 +1291,6 @@ static int i2o_seq_show_ddm_identity(struct seq_file *seq, void *v)
38908 u8 pad[256]; // allow up to 256 byte (max) serial number
38909 } result;
38910
38911 - char tmp[24 + 1];
38912 -
38913 token = i2o_parm_field_get(d, 0xF101, -1, &result, sizeof(result));
38914
38915 if (token < 0) {
38916 @@ -1316,10 +1299,8 @@ static int i2o_seq_show_ddm_identity(struct seq_file *seq, void *v)
38917 }
38918
38919 seq_printf(seq, "Registering DDM TID : 0x%03x\n", result.ddm_tid);
38920 - seq_printf(seq, "Module name : %s\n",
38921 - chtostr(tmp, result.module_name, 24));
38922 - seq_printf(seq, "Module revision : %s\n",
38923 - chtostr(tmp, result.module_rev, 8));
38924 + seq_printf(seq, "Module name : %.24s\n", result.module_name);
38925 + seq_printf(seq, "Module revision : %.8s\n", result.module_rev);
38926
38927 seq_printf(seq, "Serial number : ");
38928 print_serial_number(seq, result.serial_number, sizeof(result) - 36);
38929 @@ -1343,8 +1324,6 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
38930 u8 instance_number[4];
38931 } result;
38932
38933 - char tmp[64 + 1];
38934 -
38935 token = i2o_parm_field_get(d, 0xF102, -1, &result, sizeof(result));
38936
38937 if (token < 0) {
38938 @@ -1352,14 +1331,10 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
38939 return 0;
38940 }
38941
38942 - seq_printf(seq, "Device name : %s\n",
38943 - chtostr(tmp, result.device_name, 64));
38944 - seq_printf(seq, "Service name : %s\n",
38945 - chtostr(tmp, result.service_name, 64));
38946 - seq_printf(seq, "Physical name : %s\n",
38947 - chtostr(tmp, result.physical_location, 64));
38948 - seq_printf(seq, "Instance number : %s\n",
38949 - chtostr(tmp, result.instance_number, 4));
38950 + seq_printf(seq, "Device name : %.64s\n", result.device_name);
38951 + seq_printf(seq, "Service name : %.64s\n", result.service_name);
38952 + seq_printf(seq, "Physical name : %.64s\n", result.physical_location);
38953 + seq_printf(seq, "Instance number : %.4s\n", result.instance_number);
38954
38955 return 0;
38956 }
38957 diff --git a/drivers/message/i2o/iop.c b/drivers/message/i2o/iop.c
38958 index a8c08f3..155fe3d 100644
38959 --- a/drivers/message/i2o/iop.c
38960 +++ b/drivers/message/i2o/iop.c
38961 @@ -111,10 +111,10 @@ u32 i2o_cntxt_list_add(struct i2o_controller * c, void *ptr)
38962
38963 spin_lock_irqsave(&c->context_list_lock, flags);
38964
38965 - if (unlikely(atomic_inc_and_test(&c->context_list_counter)))
38966 - atomic_inc(&c->context_list_counter);
38967 + if (unlikely(atomic_inc_and_test_unchecked(&c->context_list_counter)))
38968 + atomic_inc_unchecked(&c->context_list_counter);
38969
38970 - entry->context = atomic_read(&c->context_list_counter);
38971 + entry->context = atomic_read_unchecked(&c->context_list_counter);
38972
38973 list_add(&entry->list, &c->context_list);
38974
38975 @@ -1077,7 +1077,7 @@ struct i2o_controller *i2o_iop_alloc(void)
38976
38977 #if BITS_PER_LONG == 64
38978 spin_lock_init(&c->context_list_lock);
38979 - atomic_set(&c->context_list_counter, 0);
38980 + atomic_set_unchecked(&c->context_list_counter, 0);
38981 INIT_LIST_HEAD(&c->context_list);
38982 #endif
38983
38984 diff --git a/drivers/mfd/janz-cmodio.c b/drivers/mfd/janz-cmodio.c
38985 index 45ece11..8efa218 100644
38986 --- a/drivers/mfd/janz-cmodio.c
38987 +++ b/drivers/mfd/janz-cmodio.c
38988 @@ -13,6 +13,7 @@
38989
38990 #include <linux/kernel.h>
38991 #include <linux/module.h>
38992 +#include <linux/slab.h>
38993 #include <linux/init.h>
38994 #include <linux/pci.h>
38995 #include <linux/interrupt.h>
38996 diff --git a/drivers/mfd/twl4030-irq.c b/drivers/mfd/twl4030-irq.c
38997 index a5f9888..1c0ed56 100644
38998 --- a/drivers/mfd/twl4030-irq.c
38999 +++ b/drivers/mfd/twl4030-irq.c
39000 @@ -35,6 +35,7 @@
39001 #include <linux/of.h>
39002 #include <linux/irqdomain.h>
39003 #include <linux/i2c/twl.h>
39004 +#include <asm/pgtable.h>
39005
39006 #include "twl-core.h"
39007
39008 @@ -728,10 +729,12 @@ int twl4030_init_irq(struct device *dev, int irq_num)
39009 * Install an irq handler for each of the SIH modules;
39010 * clone dummy irq_chip since PIH can't *do* anything
39011 */
39012 - twl4030_irq_chip = dummy_irq_chip;
39013 - twl4030_irq_chip.name = "twl4030";
39014 + pax_open_kernel();
39015 + memcpy((void *)&twl4030_irq_chip, &dummy_irq_chip, sizeof twl4030_irq_chip);
39016 + *(const char **)&twl4030_irq_chip.name = "twl4030";
39017
39018 - twl4030_sih_irq_chip.irq_ack = dummy_irq_chip.irq_ack;
39019 + *(void **)&twl4030_sih_irq_chip.irq_ack = dummy_irq_chip.irq_ack;
39020 + pax_close_kernel();
39021
39022 for (i = irq_base; i < irq_end; i++) {
39023 irq_set_chip_and_handler(i, &twl4030_irq_chip,
39024 diff --git a/drivers/mfd/twl6030-irq.c b/drivers/mfd/twl6030-irq.c
39025 index 277a8db..0e0b754 100644
39026 --- a/drivers/mfd/twl6030-irq.c
39027 +++ b/drivers/mfd/twl6030-irq.c
39028 @@ -387,10 +387,12 @@ int twl6030_init_irq(struct device *dev, int irq_num)
39029 * install an irq handler for each of the modules;
39030 * clone dummy irq_chip since PIH can't *do* anything
39031 */
39032 - twl6030_irq_chip = dummy_irq_chip;
39033 - twl6030_irq_chip.name = "twl6030";
39034 - twl6030_irq_chip.irq_set_type = NULL;
39035 - twl6030_irq_chip.irq_set_wake = twl6030_irq_set_wake;
39036 + pax_open_kernel();
39037 + memcpy((void *)&twl6030_irq_chip, &dummy_irq_chip, sizeof twl6030_irq_chip);
39038 + *(const char **)&twl6030_irq_chip.name = "twl6030";
39039 + *(void **)&twl6030_irq_chip.irq_set_type = NULL;
39040 + *(void **)&twl6030_irq_chip.irq_set_wake = twl6030_irq_set_wake;
39041 + pax_close_kernel();
39042
39043 for (i = irq_base; i < irq_end; i++) {
39044 irq_set_chip_and_handler(i, &twl6030_irq_chip,
39045 diff --git a/drivers/misc/c2port/core.c b/drivers/misc/c2port/core.c
39046 index f32550a..e3e52a2 100644
39047 --- a/drivers/misc/c2port/core.c
39048 +++ b/drivers/misc/c2port/core.c
39049 @@ -920,7 +920,9 @@ struct c2port_device *c2port_device_register(char *name,
39050 mutex_init(&c2dev->mutex);
39051
39052 /* Create binary file */
39053 - c2port_bin_attrs.size = ops->blocks_num * ops->block_size;
39054 + pax_open_kernel();
39055 + *(size_t *)&c2port_bin_attrs.size = ops->blocks_num * ops->block_size;
39056 + pax_close_kernel();
39057 ret = device_create_bin_file(c2dev->dev, &c2port_bin_attrs);
39058 if (unlikely(ret))
39059 goto error_device_create_bin_file;
39060 diff --git a/drivers/misc/kgdbts.c b/drivers/misc/kgdbts.c
39061 index 36f5d52..32311c3 100644
39062 --- a/drivers/misc/kgdbts.c
39063 +++ b/drivers/misc/kgdbts.c
39064 @@ -834,7 +834,7 @@ static void run_plant_and_detach_test(int is_early)
39065 char before[BREAK_INSTR_SIZE];
39066 char after[BREAK_INSTR_SIZE];
39067
39068 - probe_kernel_read(before, (char *)kgdbts_break_test,
39069 + probe_kernel_read(before, ktla_ktva((char *)kgdbts_break_test),
39070 BREAK_INSTR_SIZE);
39071 init_simple_test();
39072 ts.tst = plant_and_detach_test;
39073 @@ -842,7 +842,7 @@ static void run_plant_and_detach_test(int is_early)
39074 /* Activate test with initial breakpoint */
39075 if (!is_early)
39076 kgdb_breakpoint();
39077 - probe_kernel_read(after, (char *)kgdbts_break_test,
39078 + probe_kernel_read(after, ktla_ktva((char *)kgdbts_break_test),
39079 BREAK_INSTR_SIZE);
39080 if (memcmp(before, after, BREAK_INSTR_SIZE)) {
39081 printk(KERN_CRIT "kgdbts: ERROR kgdb corrupted memory\n");
39082 diff --git a/drivers/misc/lis3lv02d/lis3lv02d.c b/drivers/misc/lis3lv02d/lis3lv02d.c
39083 index 4a87e5c..76bdf5c 100644
39084 --- a/drivers/misc/lis3lv02d/lis3lv02d.c
39085 +++ b/drivers/misc/lis3lv02d/lis3lv02d.c
39086 @@ -498,7 +498,7 @@ static irqreturn_t lis302dl_interrupt(int irq, void *data)
39087 * the lid is closed. This leads to interrupts as soon as a little move
39088 * is done.
39089 */
39090 - atomic_inc(&lis3->count);
39091 + atomic_inc_unchecked(&lis3->count);
39092
39093 wake_up_interruptible(&lis3->misc_wait);
39094 kill_fasync(&lis3->async_queue, SIGIO, POLL_IN);
39095 @@ -584,7 +584,7 @@ static int lis3lv02d_misc_open(struct inode *inode, struct file *file)
39096 if (lis3->pm_dev)
39097 pm_runtime_get_sync(lis3->pm_dev);
39098
39099 - atomic_set(&lis3->count, 0);
39100 + atomic_set_unchecked(&lis3->count, 0);
39101 return 0;
39102 }
39103
39104 @@ -617,7 +617,7 @@ static ssize_t lis3lv02d_misc_read(struct file *file, char __user *buf,
39105 add_wait_queue(&lis3->misc_wait, &wait);
39106 while (true) {
39107 set_current_state(TASK_INTERRUPTIBLE);
39108 - data = atomic_xchg(&lis3->count, 0);
39109 + data = atomic_xchg_unchecked(&lis3->count, 0);
39110 if (data)
39111 break;
39112
39113 @@ -658,7 +658,7 @@ static unsigned int lis3lv02d_misc_poll(struct file *file, poll_table *wait)
39114 struct lis3lv02d, miscdev);
39115
39116 poll_wait(file, &lis3->misc_wait, wait);
39117 - if (atomic_read(&lis3->count))
39118 + if (atomic_read_unchecked(&lis3->count))
39119 return POLLIN | POLLRDNORM;
39120 return 0;
39121 }
39122 diff --git a/drivers/misc/lis3lv02d/lis3lv02d.h b/drivers/misc/lis3lv02d/lis3lv02d.h
39123 index c439c82..1f20f57 100644
39124 --- a/drivers/misc/lis3lv02d/lis3lv02d.h
39125 +++ b/drivers/misc/lis3lv02d/lis3lv02d.h
39126 @@ -297,7 +297,7 @@ struct lis3lv02d {
39127 struct input_polled_dev *idev; /* input device */
39128 struct platform_device *pdev; /* platform device */
39129 struct regulator_bulk_data regulators[2];
39130 - atomic_t count; /* interrupt count after last read */
39131 + atomic_unchecked_t count; /* interrupt count after last read */
39132 union axis_conversion ac; /* hw -> logical axis */
39133 int mapped_btns[3];
39134
39135 diff --git a/drivers/misc/sgi-gru/gruhandles.c b/drivers/misc/sgi-gru/gruhandles.c
39136 index 2f30bad..c4c13d0 100644
39137 --- a/drivers/misc/sgi-gru/gruhandles.c
39138 +++ b/drivers/misc/sgi-gru/gruhandles.c
39139 @@ -44,8 +44,8 @@ static void update_mcs_stats(enum mcs_op op, unsigned long clks)
39140 unsigned long nsec;
39141
39142 nsec = CLKS2NSEC(clks);
39143 - atomic_long_inc(&mcs_op_statistics[op].count);
39144 - atomic_long_add(nsec, &mcs_op_statistics[op].total);
39145 + atomic_long_inc_unchecked(&mcs_op_statistics[op].count);
39146 + atomic_long_add_unchecked(nsec, &mcs_op_statistics[op].total);
39147 if (mcs_op_statistics[op].max < nsec)
39148 mcs_op_statistics[op].max = nsec;
39149 }
39150 diff --git a/drivers/misc/sgi-gru/gruprocfs.c b/drivers/misc/sgi-gru/gruprocfs.c
39151 index 950dbe9..eeef0f8 100644
39152 --- a/drivers/misc/sgi-gru/gruprocfs.c
39153 +++ b/drivers/misc/sgi-gru/gruprocfs.c
39154 @@ -32,9 +32,9 @@
39155
39156 #define printstat(s, f) printstat_val(s, &gru_stats.f, #f)
39157
39158 -static void printstat_val(struct seq_file *s, atomic_long_t *v, char *id)
39159 +static void printstat_val(struct seq_file *s, atomic_long_unchecked_t *v, char *id)
39160 {
39161 - unsigned long val = atomic_long_read(v);
39162 + unsigned long val = atomic_long_read_unchecked(v);
39163
39164 seq_printf(s, "%16lu %s\n", val, id);
39165 }
39166 @@ -134,8 +134,8 @@ static int mcs_statistics_show(struct seq_file *s, void *p)
39167
39168 seq_printf(s, "%-20s%12s%12s%12s\n", "#id", "count", "aver-clks", "max-clks");
39169 for (op = 0; op < mcsop_last; op++) {
39170 - count = atomic_long_read(&mcs_op_statistics[op].count);
39171 - total = atomic_long_read(&mcs_op_statistics[op].total);
39172 + count = atomic_long_read_unchecked(&mcs_op_statistics[op].count);
39173 + total = atomic_long_read_unchecked(&mcs_op_statistics[op].total);
39174 max = mcs_op_statistics[op].max;
39175 seq_printf(s, "%-20s%12ld%12ld%12ld\n", id[op], count,
39176 count ? total / count : 0, max);
39177 diff --git a/drivers/misc/sgi-gru/grutables.h b/drivers/misc/sgi-gru/grutables.h
39178 index 5c3ce24..4915ccb 100644
39179 --- a/drivers/misc/sgi-gru/grutables.h
39180 +++ b/drivers/misc/sgi-gru/grutables.h
39181 @@ -167,82 +167,82 @@ extern unsigned int gru_max_gids;
39182 * GRU statistics.
39183 */
39184 struct gru_stats_s {
39185 - atomic_long_t vdata_alloc;
39186 - atomic_long_t vdata_free;
39187 - atomic_long_t gts_alloc;
39188 - atomic_long_t gts_free;
39189 - atomic_long_t gms_alloc;
39190 - atomic_long_t gms_free;
39191 - atomic_long_t gts_double_allocate;
39192 - atomic_long_t assign_context;
39193 - atomic_long_t assign_context_failed;
39194 - atomic_long_t free_context;
39195 - atomic_long_t load_user_context;
39196 - atomic_long_t load_kernel_context;
39197 - atomic_long_t lock_kernel_context;
39198 - atomic_long_t unlock_kernel_context;
39199 - atomic_long_t steal_user_context;
39200 - atomic_long_t steal_kernel_context;
39201 - atomic_long_t steal_context_failed;
39202 - atomic_long_t nopfn;
39203 - atomic_long_t asid_new;
39204 - atomic_long_t asid_next;
39205 - atomic_long_t asid_wrap;
39206 - atomic_long_t asid_reuse;
39207 - atomic_long_t intr;
39208 - atomic_long_t intr_cbr;
39209 - atomic_long_t intr_tfh;
39210 - atomic_long_t intr_spurious;
39211 - atomic_long_t intr_mm_lock_failed;
39212 - atomic_long_t call_os;
39213 - atomic_long_t call_os_wait_queue;
39214 - atomic_long_t user_flush_tlb;
39215 - atomic_long_t user_unload_context;
39216 - atomic_long_t user_exception;
39217 - atomic_long_t set_context_option;
39218 - atomic_long_t check_context_retarget_intr;
39219 - atomic_long_t check_context_unload;
39220 - atomic_long_t tlb_dropin;
39221 - atomic_long_t tlb_preload_page;
39222 - atomic_long_t tlb_dropin_fail_no_asid;
39223 - atomic_long_t tlb_dropin_fail_upm;
39224 - atomic_long_t tlb_dropin_fail_invalid;
39225 - atomic_long_t tlb_dropin_fail_range_active;
39226 - atomic_long_t tlb_dropin_fail_idle;
39227 - atomic_long_t tlb_dropin_fail_fmm;
39228 - atomic_long_t tlb_dropin_fail_no_exception;
39229 - atomic_long_t tfh_stale_on_fault;
39230 - atomic_long_t mmu_invalidate_range;
39231 - atomic_long_t mmu_invalidate_page;
39232 - atomic_long_t flush_tlb;
39233 - atomic_long_t flush_tlb_gru;
39234 - atomic_long_t flush_tlb_gru_tgh;
39235 - atomic_long_t flush_tlb_gru_zero_asid;
39236 + atomic_long_unchecked_t vdata_alloc;
39237 + atomic_long_unchecked_t vdata_free;
39238 + atomic_long_unchecked_t gts_alloc;
39239 + atomic_long_unchecked_t gts_free;
39240 + atomic_long_unchecked_t gms_alloc;
39241 + atomic_long_unchecked_t gms_free;
39242 + atomic_long_unchecked_t gts_double_allocate;
39243 + atomic_long_unchecked_t assign_context;
39244 + atomic_long_unchecked_t assign_context_failed;
39245 + atomic_long_unchecked_t free_context;
39246 + atomic_long_unchecked_t load_user_context;
39247 + atomic_long_unchecked_t load_kernel_context;
39248 + atomic_long_unchecked_t lock_kernel_context;
39249 + atomic_long_unchecked_t unlock_kernel_context;
39250 + atomic_long_unchecked_t steal_user_context;
39251 + atomic_long_unchecked_t steal_kernel_context;
39252 + atomic_long_unchecked_t steal_context_failed;
39253 + atomic_long_unchecked_t nopfn;
39254 + atomic_long_unchecked_t asid_new;
39255 + atomic_long_unchecked_t asid_next;
39256 + atomic_long_unchecked_t asid_wrap;
39257 + atomic_long_unchecked_t asid_reuse;
39258 + atomic_long_unchecked_t intr;
39259 + atomic_long_unchecked_t intr_cbr;
39260 + atomic_long_unchecked_t intr_tfh;
39261 + atomic_long_unchecked_t intr_spurious;
39262 + atomic_long_unchecked_t intr_mm_lock_failed;
39263 + atomic_long_unchecked_t call_os;
39264 + atomic_long_unchecked_t call_os_wait_queue;
39265 + atomic_long_unchecked_t user_flush_tlb;
39266 + atomic_long_unchecked_t user_unload_context;
39267 + atomic_long_unchecked_t user_exception;
39268 + atomic_long_unchecked_t set_context_option;
39269 + atomic_long_unchecked_t check_context_retarget_intr;
39270 + atomic_long_unchecked_t check_context_unload;
39271 + atomic_long_unchecked_t tlb_dropin;
39272 + atomic_long_unchecked_t tlb_preload_page;
39273 + atomic_long_unchecked_t tlb_dropin_fail_no_asid;
39274 + atomic_long_unchecked_t tlb_dropin_fail_upm;
39275 + atomic_long_unchecked_t tlb_dropin_fail_invalid;
39276 + atomic_long_unchecked_t tlb_dropin_fail_range_active;
39277 + atomic_long_unchecked_t tlb_dropin_fail_idle;
39278 + atomic_long_unchecked_t tlb_dropin_fail_fmm;
39279 + atomic_long_unchecked_t tlb_dropin_fail_no_exception;
39280 + atomic_long_unchecked_t tfh_stale_on_fault;
39281 + atomic_long_unchecked_t mmu_invalidate_range;
39282 + atomic_long_unchecked_t mmu_invalidate_page;
39283 + atomic_long_unchecked_t flush_tlb;
39284 + atomic_long_unchecked_t flush_tlb_gru;
39285 + atomic_long_unchecked_t flush_tlb_gru_tgh;
39286 + atomic_long_unchecked_t flush_tlb_gru_zero_asid;
39287
39288 - atomic_long_t copy_gpa;
39289 - atomic_long_t read_gpa;
39290 + atomic_long_unchecked_t copy_gpa;
39291 + atomic_long_unchecked_t read_gpa;
39292
39293 - atomic_long_t mesq_receive;
39294 - atomic_long_t mesq_receive_none;
39295 - atomic_long_t mesq_send;
39296 - atomic_long_t mesq_send_failed;
39297 - atomic_long_t mesq_noop;
39298 - atomic_long_t mesq_send_unexpected_error;
39299 - atomic_long_t mesq_send_lb_overflow;
39300 - atomic_long_t mesq_send_qlimit_reached;
39301 - atomic_long_t mesq_send_amo_nacked;
39302 - atomic_long_t mesq_send_put_nacked;
39303 - atomic_long_t mesq_page_overflow;
39304 - atomic_long_t mesq_qf_locked;
39305 - atomic_long_t mesq_qf_noop_not_full;
39306 - atomic_long_t mesq_qf_switch_head_failed;
39307 - atomic_long_t mesq_qf_unexpected_error;
39308 - atomic_long_t mesq_noop_unexpected_error;
39309 - atomic_long_t mesq_noop_lb_overflow;
39310 - atomic_long_t mesq_noop_qlimit_reached;
39311 - atomic_long_t mesq_noop_amo_nacked;
39312 - atomic_long_t mesq_noop_put_nacked;
39313 - atomic_long_t mesq_noop_page_overflow;
39314 + atomic_long_unchecked_t mesq_receive;
39315 + atomic_long_unchecked_t mesq_receive_none;
39316 + atomic_long_unchecked_t mesq_send;
39317 + atomic_long_unchecked_t mesq_send_failed;
39318 + atomic_long_unchecked_t mesq_noop;
39319 + atomic_long_unchecked_t mesq_send_unexpected_error;
39320 + atomic_long_unchecked_t mesq_send_lb_overflow;
39321 + atomic_long_unchecked_t mesq_send_qlimit_reached;
39322 + atomic_long_unchecked_t mesq_send_amo_nacked;
39323 + atomic_long_unchecked_t mesq_send_put_nacked;
39324 + atomic_long_unchecked_t mesq_page_overflow;
39325 + atomic_long_unchecked_t mesq_qf_locked;
39326 + atomic_long_unchecked_t mesq_qf_noop_not_full;
39327 + atomic_long_unchecked_t mesq_qf_switch_head_failed;
39328 + atomic_long_unchecked_t mesq_qf_unexpected_error;
39329 + atomic_long_unchecked_t mesq_noop_unexpected_error;
39330 + atomic_long_unchecked_t mesq_noop_lb_overflow;
39331 + atomic_long_unchecked_t mesq_noop_qlimit_reached;
39332 + atomic_long_unchecked_t mesq_noop_amo_nacked;
39333 + atomic_long_unchecked_t mesq_noop_put_nacked;
39334 + atomic_long_unchecked_t mesq_noop_page_overflow;
39335
39336 };
39337
39338 @@ -251,8 +251,8 @@ enum mcs_op {cchop_allocate, cchop_start, cchop_interrupt, cchop_interrupt_sync,
39339 tghop_invalidate, mcsop_last};
39340
39341 struct mcs_op_statistic {
39342 - atomic_long_t count;
39343 - atomic_long_t total;
39344 + atomic_long_unchecked_t count;
39345 + atomic_long_unchecked_t total;
39346 unsigned long max;
39347 };
39348
39349 @@ -275,7 +275,7 @@ extern struct mcs_op_statistic mcs_op_statistics[mcsop_last];
39350
39351 #define STAT(id) do { \
39352 if (gru_options & OPT_STATS) \
39353 - atomic_long_inc(&gru_stats.id); \
39354 + atomic_long_inc_unchecked(&gru_stats.id); \
39355 } while (0)
39356
39357 #ifdef CONFIG_SGI_GRU_DEBUG
39358 diff --git a/drivers/misc/sgi-xp/xp.h b/drivers/misc/sgi-xp/xp.h
39359 index c862cd4..0d176fe 100644
39360 --- a/drivers/misc/sgi-xp/xp.h
39361 +++ b/drivers/misc/sgi-xp/xp.h
39362 @@ -288,7 +288,7 @@ struct xpc_interface {
39363 xpc_notify_func, void *);
39364 void (*received) (short, int, void *);
39365 enum xp_retval (*partid_to_nasids) (short, void *);
39366 -};
39367 +} __no_const;
39368
39369 extern struct xpc_interface xpc_interface;
39370
39371 diff --git a/drivers/misc/sgi-xp/xpc.h b/drivers/misc/sgi-xp/xpc.h
39372 index b94d5f7..7f494c5 100644
39373 --- a/drivers/misc/sgi-xp/xpc.h
39374 +++ b/drivers/misc/sgi-xp/xpc.h
39375 @@ -835,6 +835,7 @@ struct xpc_arch_operations {
39376 void (*received_payload) (struct xpc_channel *, void *);
39377 void (*notify_senders_of_disconnect) (struct xpc_channel *);
39378 };
39379 +typedef struct xpc_arch_operations __no_const xpc_arch_operations_no_const;
39380
39381 /* struct xpc_partition act_state values (for XPC HB) */
39382
39383 @@ -876,7 +877,7 @@ extern struct xpc_registration xpc_registrations[];
39384 /* found in xpc_main.c */
39385 extern struct device *xpc_part;
39386 extern struct device *xpc_chan;
39387 -extern struct xpc_arch_operations xpc_arch_ops;
39388 +extern xpc_arch_operations_no_const xpc_arch_ops;
39389 extern int xpc_disengage_timelimit;
39390 extern int xpc_disengage_timedout;
39391 extern int xpc_activate_IRQ_rcvd;
39392 diff --git a/drivers/misc/sgi-xp/xpc_main.c b/drivers/misc/sgi-xp/xpc_main.c
39393 index d971817..33bdca5 100644
39394 --- a/drivers/misc/sgi-xp/xpc_main.c
39395 +++ b/drivers/misc/sgi-xp/xpc_main.c
39396 @@ -166,7 +166,7 @@ static struct notifier_block xpc_die_notifier = {
39397 .notifier_call = xpc_system_die,
39398 };
39399
39400 -struct xpc_arch_operations xpc_arch_ops;
39401 +xpc_arch_operations_no_const xpc_arch_ops;
39402
39403 /*
39404 * Timer function to enforce the timelimit on the partition disengage.
39405 @@ -1210,7 +1210,7 @@ xpc_system_die(struct notifier_block *nb, unsigned long event, void *_die_args)
39406
39407 if (((die_args->trapnr == X86_TRAP_MF) ||
39408 (die_args->trapnr == X86_TRAP_XF)) &&
39409 - !user_mode_vm(die_args->regs))
39410 + !user_mode(die_args->regs))
39411 xpc_die_deactivate();
39412
39413 break;
39414 diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c
39415 index 49f04bc..65660c2 100644
39416 --- a/drivers/mmc/core/mmc_ops.c
39417 +++ b/drivers/mmc/core/mmc_ops.c
39418 @@ -247,7 +247,7 @@ mmc_send_cxd_data(struct mmc_card *card, struct mmc_host *host,
39419 void *data_buf;
39420 int is_on_stack;
39421
39422 - is_on_stack = object_is_on_stack(buf);
39423 + is_on_stack = object_starts_on_stack(buf);
39424 if (is_on_stack) {
39425 /*
39426 * dma onto stack is unsafe/nonportable, but callers to this
39427 diff --git a/drivers/mmc/host/dw_mmc.h b/drivers/mmc/host/dw_mmc.h
39428 index 53b8fd9..615b462 100644
39429 --- a/drivers/mmc/host/dw_mmc.h
39430 +++ b/drivers/mmc/host/dw_mmc.h
39431 @@ -205,5 +205,5 @@ struct dw_mci_drv_data {
39432 int (*parse_dt)(struct dw_mci *host);
39433 int (*setup_bus)(struct dw_mci *host,
39434 struct device_node *slot_np, u8 bus_width);
39435 -};
39436 +} __do_const;
39437 #endif /* _DW_MMC_H_ */
39438 diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c
39439 index 7363efe..681558e 100644
39440 --- a/drivers/mmc/host/sdhci-s3c.c
39441 +++ b/drivers/mmc/host/sdhci-s3c.c
39442 @@ -720,9 +720,11 @@ static int sdhci_s3c_probe(struct platform_device *pdev)
39443 * we can use overriding functions instead of default.
39444 */
39445 if (host->quirks & SDHCI_QUIRK_NONSTANDARD_CLOCK) {
39446 - sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock;
39447 - sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock;
39448 - sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock;
39449 + pax_open_kernel();
39450 + *(void **)&sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock;
39451 + *(void **)&sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock;
39452 + *(void **)&sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock;
39453 + pax_close_kernel();
39454 }
39455
39456 /* It supports additional host capabilities if needed */
39457 diff --git a/drivers/mtd/devices/doc2000.c b/drivers/mtd/devices/doc2000.c
39458 index a4eb8b5..8c0628f 100644
39459 --- a/drivers/mtd/devices/doc2000.c
39460 +++ b/drivers/mtd/devices/doc2000.c
39461 @@ -753,7 +753,7 @@ static int doc_write(struct mtd_info *mtd, loff_t to, size_t len,
39462
39463 /* The ECC will not be calculated correctly if less than 512 is written */
39464 /* DBB-
39465 - if (len != 0x200 && eccbuf)
39466 + if (len != 0x200)
39467 printk(KERN_WARNING
39468 "ECC needs a full sector write (adr: %lx size %lx)\n",
39469 (long) to, (long) len);
39470 diff --git a/drivers/mtd/nand/denali.c b/drivers/mtd/nand/denali.c
39471 index 0c8bb6b..6f35deb 100644
39472 --- a/drivers/mtd/nand/denali.c
39473 +++ b/drivers/mtd/nand/denali.c
39474 @@ -24,6 +24,7 @@
39475 #include <linux/slab.h>
39476 #include <linux/mtd/mtd.h>
39477 #include <linux/module.h>
39478 +#include <linux/slab.h>
39479
39480 #include "denali.h"
39481
39482 diff --git a/drivers/mtd/nftlmount.c b/drivers/mtd/nftlmount.c
39483 index 51b9d6a..52af9a7 100644
39484 --- a/drivers/mtd/nftlmount.c
39485 +++ b/drivers/mtd/nftlmount.c
39486 @@ -24,6 +24,7 @@
39487 #include <asm/errno.h>
39488 #include <linux/delay.h>
39489 #include <linux/slab.h>
39490 +#include <linux/sched.h>
39491 #include <linux/mtd/mtd.h>
39492 #include <linux/mtd/nand.h>
39493 #include <linux/mtd/nftl.h>
39494 diff --git a/drivers/mtd/sm_ftl.c b/drivers/mtd/sm_ftl.c
39495 index 8dd6ba5..419cc1d 100644
39496 --- a/drivers/mtd/sm_ftl.c
39497 +++ b/drivers/mtd/sm_ftl.c
39498 @@ -56,7 +56,7 @@ ssize_t sm_attr_show(struct device *dev, struct device_attribute *attr,
39499 #define SM_CIS_VENDOR_OFFSET 0x59
39500 struct attribute_group *sm_create_sysfs_attributes(struct sm_ftl *ftl)
39501 {
39502 - struct attribute_group *attr_group;
39503 + attribute_group_no_const *attr_group;
39504 struct attribute **attributes;
39505 struct sm_sysfs_attribute *vendor_attribute;
39506
39507 diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
39508 index dbbea0e..3f4a0b1 100644
39509 --- a/drivers/net/bonding/bond_main.c
39510 +++ b/drivers/net/bonding/bond_main.c
39511 @@ -4822,7 +4822,7 @@ static unsigned int bond_get_num_tx_queues(void)
39512 return tx_queues;
39513 }
39514
39515 -static struct rtnl_link_ops bond_link_ops __read_mostly = {
39516 +static struct rtnl_link_ops bond_link_ops = {
39517 .kind = "bond",
39518 .priv_size = sizeof(struct bonding),
39519 .setup = bond_setup,
39520 @@ -4947,8 +4947,8 @@ static void __exit bonding_exit(void)
39521
39522 bond_destroy_debugfs();
39523
39524 - rtnl_link_unregister(&bond_link_ops);
39525 unregister_pernet_subsys(&bond_net_ops);
39526 + rtnl_link_unregister(&bond_link_ops);
39527
39528 #ifdef CONFIG_NET_POLL_CONTROLLER
39529 /*
39530 diff --git a/drivers/net/ethernet/8390/ax88796.c b/drivers/net/ethernet/8390/ax88796.c
39531 index e1d2643..7f4133b 100644
39532 --- a/drivers/net/ethernet/8390/ax88796.c
39533 +++ b/drivers/net/ethernet/8390/ax88796.c
39534 @@ -872,9 +872,11 @@ static int ax_probe(struct platform_device *pdev)
39535 if (ax->plat->reg_offsets)
39536 ei_local->reg_offset = ax->plat->reg_offsets;
39537 else {
39538 + resource_size_t _mem_size = mem_size;
39539 + do_div(_mem_size, 0x18);
39540 ei_local->reg_offset = ax->reg_offsets;
39541 for (ret = 0; ret < 0x18; ret++)
39542 - ax->reg_offsets[ret] = (mem_size / 0x18) * ret;
39543 + ax->reg_offsets[ret] = _mem_size * ret;
39544 }
39545
39546 if (!request_mem_region(mem->start, mem_size, pdev->name)) {
39547 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
39548 index aee7671..3ca2651 100644
39549 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
39550 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
39551 @@ -1093,7 +1093,7 @@ static inline u8 bnx2x_get_path_func_num(struct bnx2x *bp)
39552 static inline void bnx2x_init_bp_objs(struct bnx2x *bp)
39553 {
39554 /* RX_MODE controlling object */
39555 - bnx2x_init_rx_mode_obj(bp, &bp->rx_mode_obj);
39556 + bnx2x_init_rx_mode_obj(bp);
39557
39558 /* multicast configuration controlling object */
39559 bnx2x_init_mcast_obj(bp, &bp->mcast_obj, bp->fp->cl_id, bp->fp->cid,
39560 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
39561 index 7306416..5fb7fb5 100644
39562 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
39563 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
39564 @@ -2381,15 +2381,14 @@ int bnx2x_config_rx_mode(struct bnx2x *bp,
39565 return rc;
39566 }
39567
39568 -void bnx2x_init_rx_mode_obj(struct bnx2x *bp,
39569 - struct bnx2x_rx_mode_obj *o)
39570 +void bnx2x_init_rx_mode_obj(struct bnx2x *bp)
39571 {
39572 if (CHIP_IS_E1x(bp)) {
39573 - o->wait_comp = bnx2x_empty_rx_mode_wait;
39574 - o->config_rx_mode = bnx2x_set_rx_mode_e1x;
39575 + bp->rx_mode_obj.wait_comp = bnx2x_empty_rx_mode_wait;
39576 + bp->rx_mode_obj.config_rx_mode = bnx2x_set_rx_mode_e1x;
39577 } else {
39578 - o->wait_comp = bnx2x_wait_rx_mode_comp_e2;
39579 - o->config_rx_mode = bnx2x_set_rx_mode_e2;
39580 + bp->rx_mode_obj.wait_comp = bnx2x_wait_rx_mode_comp_e2;
39581 + bp->rx_mode_obj.config_rx_mode = bnx2x_set_rx_mode_e2;
39582 }
39583 }
39584
39585 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
39586 index ff90760..08d8aed 100644
39587 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
39588 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
39589 @@ -1306,8 +1306,7 @@ int bnx2x_vlan_mac_move(struct bnx2x *bp,
39590
39591 /********************* RX MODE ****************/
39592
39593 -void bnx2x_init_rx_mode_obj(struct bnx2x *bp,
39594 - struct bnx2x_rx_mode_obj *o);
39595 +void bnx2x_init_rx_mode_obj(struct bnx2x *bp);
39596
39597 /**
39598 * bnx2x_config_rx_mode - Send and RX_MODE ramrod according to the provided parameters.
39599 diff --git a/drivers/net/ethernet/broadcom/tg3.h b/drivers/net/ethernet/broadcom/tg3.h
39600 index 8d7d4c2..95f7681 100644
39601 --- a/drivers/net/ethernet/broadcom/tg3.h
39602 +++ b/drivers/net/ethernet/broadcom/tg3.h
39603 @@ -147,6 +147,7 @@
39604 #define CHIPREV_ID_5750_A0 0x4000
39605 #define CHIPREV_ID_5750_A1 0x4001
39606 #define CHIPREV_ID_5750_A3 0x4003
39607 +#define CHIPREV_ID_5750_C1 0x4201
39608 #define CHIPREV_ID_5750_C2 0x4202
39609 #define CHIPREV_ID_5752_A0_HW 0x5000
39610 #define CHIPREV_ID_5752_A0 0x6000
39611 diff --git a/drivers/net/ethernet/chelsio/cxgb3/l2t.h b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
39612 index 8cffcdf..aadf043 100644
39613 --- a/drivers/net/ethernet/chelsio/cxgb3/l2t.h
39614 +++ b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
39615 @@ -87,7 +87,7 @@ typedef void (*arp_failure_handler_func)(struct t3cdev * dev,
39616 */
39617 struct l2t_skb_cb {
39618 arp_failure_handler_func arp_failure_handler;
39619 -};
39620 +} __no_const;
39621
39622 #define L2T_SKB_CB(skb) ((struct l2t_skb_cb *)(skb)->cb)
39623
39624 diff --git a/drivers/net/ethernet/dec/tulip/de4x5.c b/drivers/net/ethernet/dec/tulip/de4x5.c
39625 index 4c83003..2a2a5b9 100644
39626 --- a/drivers/net/ethernet/dec/tulip/de4x5.c
39627 +++ b/drivers/net/ethernet/dec/tulip/de4x5.c
39628 @@ -5388,7 +5388,7 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
39629 for (i=0; i<ETH_ALEN; i++) {
39630 tmp.addr[i] = dev->dev_addr[i];
39631 }
39632 - if (copy_to_user(ioc->data, tmp.addr, ioc->len)) return -EFAULT;
39633 + if (ioc->len > sizeof tmp.addr || copy_to_user(ioc->data, tmp.addr, ioc->len)) return -EFAULT;
39634 break;
39635
39636 case DE4X5_SET_HWADDR: /* Set the hardware address */
39637 @@ -5428,7 +5428,7 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
39638 spin_lock_irqsave(&lp->lock, flags);
39639 memcpy(&statbuf, &lp->pktStats, ioc->len);
39640 spin_unlock_irqrestore(&lp->lock, flags);
39641 - if (copy_to_user(ioc->data, &statbuf, ioc->len))
39642 + if (ioc->len > sizeof statbuf || copy_to_user(ioc->data, &statbuf, ioc->len))
39643 return -EFAULT;
39644 break;
39645 }
39646 diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c
39647 index 2886c9b..db71673 100644
39648 --- a/drivers/net/ethernet/emulex/benet/be_main.c
39649 +++ b/drivers/net/ethernet/emulex/benet/be_main.c
39650 @@ -455,7 +455,7 @@ static void accumulate_16bit_val(u32 *acc, u16 val)
39651
39652 if (wrapped)
39653 newacc += 65536;
39654 - ACCESS_ONCE(*acc) = newacc;
39655 + ACCESS_ONCE_RW(*acc) = newacc;
39656 }
39657
39658 void be_parse_stats(struct be_adapter *adapter)
39659 diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
39660 index 7c361d1..57e3ff1 100644
39661 --- a/drivers/net/ethernet/faraday/ftgmac100.c
39662 +++ b/drivers/net/ethernet/faraday/ftgmac100.c
39663 @@ -31,6 +31,8 @@
39664 #include <linux/netdevice.h>
39665 #include <linux/phy.h>
39666 #include <linux/platform_device.h>
39667 +#include <linux/interrupt.h>
39668 +#include <linux/irqreturn.h>
39669 #include <net/ip.h>
39670
39671 #include "ftgmac100.h"
39672 diff --git a/drivers/net/ethernet/faraday/ftmac100.c b/drivers/net/ethernet/faraday/ftmac100.c
39673 index b5ea8fb..bd25e9a 100644
39674 --- a/drivers/net/ethernet/faraday/ftmac100.c
39675 +++ b/drivers/net/ethernet/faraday/ftmac100.c
39676 @@ -31,6 +31,8 @@
39677 #include <linux/module.h>
39678 #include <linux/netdevice.h>
39679 #include <linux/platform_device.h>
39680 +#include <linux/interrupt.h>
39681 +#include <linux/irqreturn.h>
39682
39683 #include "ftmac100.h"
39684
39685 diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
39686 index 331987d..3be1135 100644
39687 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
39688 +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
39689 @@ -776,7 +776,7 @@ void ixgbe_ptp_start_cyclecounter(struct ixgbe_adapter *adapter)
39690 }
39691
39692 /* update the base incval used to calculate frequency adjustment */
39693 - ACCESS_ONCE(adapter->base_incval) = incval;
39694 + ACCESS_ONCE_RW(adapter->base_incval) = incval;
39695 smp_mb();
39696
39697 /* need lock to prevent incorrect read while modifying cyclecounter */
39698 diff --git a/drivers/net/ethernet/neterion/vxge/vxge-config.c b/drivers/net/ethernet/neterion/vxge/vxge-config.c
39699 index fbe5363..266b4e3 100644
39700 --- a/drivers/net/ethernet/neterion/vxge/vxge-config.c
39701 +++ b/drivers/net/ethernet/neterion/vxge/vxge-config.c
39702 @@ -3461,7 +3461,10 @@ __vxge_hw_fifo_create(struct __vxge_hw_vpath_handle *vp,
39703 struct __vxge_hw_fifo *fifo;
39704 struct vxge_hw_fifo_config *config;
39705 u32 txdl_size, txdl_per_memblock;
39706 - struct vxge_hw_mempool_cbs fifo_mp_callback;
39707 + static struct vxge_hw_mempool_cbs fifo_mp_callback = {
39708 + .item_func_alloc = __vxge_hw_fifo_mempool_item_alloc,
39709 + };
39710 +
39711 struct __vxge_hw_virtualpath *vpath;
39712
39713 if ((vp == NULL) || (attr == NULL)) {
39714 @@ -3544,8 +3547,6 @@ __vxge_hw_fifo_create(struct __vxge_hw_vpath_handle *vp,
39715 goto exit;
39716 }
39717
39718 - fifo_mp_callback.item_func_alloc = __vxge_hw_fifo_mempool_item_alloc;
39719 -
39720 fifo->mempool =
39721 __vxge_hw_mempool_create(vpath->hldev,
39722 fifo->config->memblock_size,
39723 diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
39724 index 5c033f2..7bbb0d8 100644
39725 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
39726 +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
39727 @@ -1894,7 +1894,9 @@ int qlcnic_83xx_config_default_opmode(struct qlcnic_adapter *adapter)
39728 op_mode = QLCRDX(ahw, QLC_83XX_DRV_OP_MODE);
39729
39730 if (op_mode == QLC_83XX_DEFAULT_OPMODE) {
39731 - adapter->nic_ops->init_driver = qlcnic_83xx_init_default_driver;
39732 + pax_open_kernel();
39733 + *(void **)&adapter->nic_ops->init_driver = qlcnic_83xx_init_default_driver;
39734 + pax_close_kernel();
39735 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
39736 } else {
39737 return -EIO;
39738 diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
39739 index b0c3de9..fc5857e 100644
39740 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
39741 +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
39742 @@ -200,15 +200,21 @@ int qlcnic_83xx_config_vnic_opmode(struct qlcnic_adapter *adapter)
39743 if (priv_level == QLCNIC_NON_PRIV_FUNC) {
39744 ahw->op_mode = QLCNIC_NON_PRIV_FUNC;
39745 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
39746 - nic_ops->init_driver = qlcnic_83xx_init_non_privileged_vnic;
39747 + pax_open_kernel();
39748 + *(void **)&nic_ops->init_driver = qlcnic_83xx_init_non_privileged_vnic;
39749 + pax_close_kernel();
39750 } else if (priv_level == QLCNIC_PRIV_FUNC) {
39751 ahw->op_mode = QLCNIC_PRIV_FUNC;
39752 ahw->idc.state_entry = qlcnic_83xx_idc_vnic_pf_entry;
39753 - nic_ops->init_driver = qlcnic_83xx_init_privileged_vnic;
39754 + pax_open_kernel();
39755 + *(void **)&nic_ops->init_driver = qlcnic_83xx_init_privileged_vnic;
39756 + pax_close_kernel();
39757 } else if (priv_level == QLCNIC_MGMT_FUNC) {
39758 ahw->op_mode = QLCNIC_MGMT_FUNC;
39759 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
39760 - nic_ops->init_driver = qlcnic_83xx_init_mgmt_vnic;
39761 + pax_open_kernel();
39762 + *(void **)&nic_ops->init_driver = qlcnic_83xx_init_mgmt_vnic;
39763 + pax_close_kernel();
39764 } else {
39765 return -EIO;
39766 }
39767 diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c
39768 index 15ba8c4..3f56838 100644
39769 --- a/drivers/net/ethernet/realtek/r8169.c
39770 +++ b/drivers/net/ethernet/realtek/r8169.c
39771 @@ -740,22 +740,22 @@ struct rtl8169_private {
39772 struct mdio_ops {
39773 void (*write)(struct rtl8169_private *, int, int);
39774 int (*read)(struct rtl8169_private *, int);
39775 - } mdio_ops;
39776 + } __no_const mdio_ops;
39777
39778 struct pll_power_ops {
39779 void (*down)(struct rtl8169_private *);
39780 void (*up)(struct rtl8169_private *);
39781 - } pll_power_ops;
39782 + } __no_const pll_power_ops;
39783
39784 struct jumbo_ops {
39785 void (*enable)(struct rtl8169_private *);
39786 void (*disable)(struct rtl8169_private *);
39787 - } jumbo_ops;
39788 + } __no_const jumbo_ops;
39789
39790 struct csi_ops {
39791 void (*write)(struct rtl8169_private *, int, int);
39792 u32 (*read)(struct rtl8169_private *, int);
39793 - } csi_ops;
39794 + } __no_const csi_ops;
39795
39796 int (*set_speed)(struct net_device *, u8 aneg, u16 sp, u8 dpx, u32 adv);
39797 int (*get_settings)(struct net_device *, struct ethtool_cmd *);
39798 diff --git a/drivers/net/ethernet/sfc/ptp.c b/drivers/net/ethernet/sfc/ptp.c
39799 index 3f93624..cf01144 100644
39800 --- a/drivers/net/ethernet/sfc/ptp.c
39801 +++ b/drivers/net/ethernet/sfc/ptp.c
39802 @@ -553,7 +553,7 @@ static int efx_ptp_synchronize(struct efx_nic *efx, unsigned int num_readings)
39803 (u32)((u64)ptp->start.dma_addr >> 32));
39804
39805 /* Clear flag that signals MC ready */
39806 - ACCESS_ONCE(*start) = 0;
39807 + ACCESS_ONCE_RW(*start) = 0;
39808 efx_mcdi_rpc_start(efx, MC_CMD_PTP, synch_buf,
39809 MC_CMD_PTP_IN_SYNCHRONIZE_LEN);
39810
39811 diff --git a/drivers/net/ethernet/stmicro/stmmac/mmc_core.c b/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
39812 index 50617c5..b13724c 100644
39813 --- a/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
39814 +++ b/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
39815 @@ -140,8 +140,8 @@ void dwmac_mmc_ctrl(void __iomem *ioaddr, unsigned int mode)
39816
39817 writel(value, ioaddr + MMC_CNTRL);
39818
39819 - pr_debug("stmmac: MMC ctrl register (offset 0x%x): 0x%08x\n",
39820 - MMC_CNTRL, value);
39821 +// pr_debug("stmmac: MMC ctrl register (offset 0x%x): 0x%08x\n",
39822 +// MMC_CNTRL, value);
39823 }
39824
39825 /* To mask all all interrupts.*/
39826 diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
39827 index e6fe0d8..2b7d752 100644
39828 --- a/drivers/net/hyperv/hyperv_net.h
39829 +++ b/drivers/net/hyperv/hyperv_net.h
39830 @@ -101,7 +101,7 @@ struct rndis_device {
39831
39832 enum rndis_device_state state;
39833 bool link_state;
39834 - atomic_t new_req_id;
39835 + atomic_unchecked_t new_req_id;
39836
39837 spinlock_t request_lock;
39838 struct list_head req_list;
39839 diff --git a/drivers/net/hyperv/rndis_filter.c b/drivers/net/hyperv/rndis_filter.c
39840 index 0775f0a..d4fb316 100644
39841 --- a/drivers/net/hyperv/rndis_filter.c
39842 +++ b/drivers/net/hyperv/rndis_filter.c
39843 @@ -104,7 +104,7 @@ static struct rndis_request *get_rndis_request(struct rndis_device *dev,
39844 * template
39845 */
39846 set = &rndis_msg->msg.set_req;
39847 - set->req_id = atomic_inc_return(&dev->new_req_id);
39848 + set->req_id = atomic_inc_return_unchecked(&dev->new_req_id);
39849
39850 /* Add to the request list */
39851 spin_lock_irqsave(&dev->request_lock, flags);
39852 @@ -752,7 +752,7 @@ static void rndis_filter_halt_device(struct rndis_device *dev)
39853
39854 /* Setup the rndis set */
39855 halt = &request->request_msg.msg.halt_req;
39856 - halt->req_id = atomic_inc_return(&dev->new_req_id);
39857 + halt->req_id = atomic_inc_return_unchecked(&dev->new_req_id);
39858
39859 /* Ignore return since this msg is optional. */
39860 rndis_filter_send_request(dev, request);
39861 diff --git a/drivers/net/ieee802154/fakehard.c b/drivers/net/ieee802154/fakehard.c
39862 index 8f1c256..a2991d1 100644
39863 --- a/drivers/net/ieee802154/fakehard.c
39864 +++ b/drivers/net/ieee802154/fakehard.c
39865 @@ -385,7 +385,7 @@ static int ieee802154fake_probe(struct platform_device *pdev)
39866 phy->transmit_power = 0xbf;
39867
39868 dev->netdev_ops = &fake_ops;
39869 - dev->ml_priv = &fake_mlme;
39870 + dev->ml_priv = (void *)&fake_mlme;
39871
39872 priv = netdev_priv(dev);
39873 priv->phy = phy;
39874 diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
39875 index 011062e..ada88e9 100644
39876 --- a/drivers/net/macvlan.c
39877 +++ b/drivers/net/macvlan.c
39878 @@ -892,13 +892,15 @@ static const struct nla_policy macvlan_policy[IFLA_MACVLAN_MAX + 1] = {
39879 int macvlan_link_register(struct rtnl_link_ops *ops)
39880 {
39881 /* common fields */
39882 - ops->priv_size = sizeof(struct macvlan_dev);
39883 - ops->validate = macvlan_validate;
39884 - ops->maxtype = IFLA_MACVLAN_MAX;
39885 - ops->policy = macvlan_policy;
39886 - ops->changelink = macvlan_changelink;
39887 - ops->get_size = macvlan_get_size;
39888 - ops->fill_info = macvlan_fill_info;
39889 + pax_open_kernel();
39890 + *(size_t *)&ops->priv_size = sizeof(struct macvlan_dev);
39891 + *(void **)&ops->validate = macvlan_validate;
39892 + *(int *)&ops->maxtype = IFLA_MACVLAN_MAX;
39893 + *(const void **)&ops->policy = macvlan_policy;
39894 + *(void **)&ops->changelink = macvlan_changelink;
39895 + *(void **)&ops->get_size = macvlan_get_size;
39896 + *(void **)&ops->fill_info = macvlan_fill_info;
39897 + pax_close_kernel();
39898
39899 return rtnl_link_register(ops);
39900 };
39901 @@ -954,7 +956,7 @@ static int macvlan_device_event(struct notifier_block *unused,
39902 return NOTIFY_DONE;
39903 }
39904
39905 -static struct notifier_block macvlan_notifier_block __read_mostly = {
39906 +static struct notifier_block macvlan_notifier_block = {
39907 .notifier_call = macvlan_device_event,
39908 };
39909
39910 diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c
39911 index a449439..1e468fe 100644
39912 --- a/drivers/net/macvtap.c
39913 +++ b/drivers/net/macvtap.c
39914 @@ -1090,7 +1090,7 @@ static int macvtap_device_event(struct notifier_block *unused,
39915 return NOTIFY_DONE;
39916 }
39917
39918 -static struct notifier_block macvtap_notifier_block __read_mostly = {
39919 +static struct notifier_block macvtap_notifier_block = {
39920 .notifier_call = macvtap_device_event,
39921 };
39922
39923 diff --git a/drivers/net/phy/mdio-bitbang.c b/drivers/net/phy/mdio-bitbang.c
39924 index daec9b0..6428fcb 100644
39925 --- a/drivers/net/phy/mdio-bitbang.c
39926 +++ b/drivers/net/phy/mdio-bitbang.c
39927 @@ -234,6 +234,7 @@ void free_mdio_bitbang(struct mii_bus *bus)
39928 struct mdiobb_ctrl *ctrl = bus->priv;
39929
39930 module_put(ctrl->ops->owner);
39931 + mdiobus_unregister(bus);
39932 mdiobus_free(bus);
39933 }
39934 EXPORT_SYMBOL(free_mdio_bitbang);
39935 diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c
39936 index 72ff14b..11d442d 100644
39937 --- a/drivers/net/ppp/ppp_generic.c
39938 +++ b/drivers/net/ppp/ppp_generic.c
39939 @@ -999,7 +999,6 @@ ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
39940 void __user *addr = (void __user *) ifr->ifr_ifru.ifru_data;
39941 struct ppp_stats stats;
39942 struct ppp_comp_stats cstats;
39943 - char *vers;
39944
39945 switch (cmd) {
39946 case SIOCGPPPSTATS:
39947 @@ -1021,8 +1020,7 @@ ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
39948 break;
39949
39950 case SIOCGPPPVER:
39951 - vers = PPP_VERSION;
39952 - if (copy_to_user(addr, vers, strlen(vers) + 1))
39953 + if (copy_to_user(addr, PPP_VERSION, sizeof(PPP_VERSION)))
39954 break;
39955 err = 0;
39956 break;
39957 diff --git a/drivers/net/slip/slhc.c b/drivers/net/slip/slhc.c
39958 index 1252d9c..80e660b 100644
39959 --- a/drivers/net/slip/slhc.c
39960 +++ b/drivers/net/slip/slhc.c
39961 @@ -488,7 +488,7 @@ slhc_uncompress(struct slcompress *comp, unsigned char *icp, int isize)
39962 register struct tcphdr *thp;
39963 register struct iphdr *ip;
39964 register struct cstate *cs;
39965 - int len, hdrlen;
39966 + long len, hdrlen;
39967 unsigned char *cp = icp;
39968
39969 /* We've got a compressed packet; read the change byte */
39970 diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c
39971 index bf34192..fba3500 100644
39972 --- a/drivers/net/team/team.c
39973 +++ b/drivers/net/team/team.c
39974 @@ -2668,7 +2668,7 @@ static int team_device_event(struct notifier_block *unused,
39975 return NOTIFY_DONE;
39976 }
39977
39978 -static struct notifier_block team_notifier_block __read_mostly = {
39979 +static struct notifier_block team_notifier_block = {
39980 .notifier_call = team_device_event,
39981 };
39982
39983 diff --git a/drivers/net/tun.c b/drivers/net/tun.c
39984 index 755fa9e..631fdce 100644
39985 --- a/drivers/net/tun.c
39986 +++ b/drivers/net/tun.c
39987 @@ -1841,7 +1841,7 @@ unlock:
39988 }
39989
39990 static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
39991 - unsigned long arg, int ifreq_len)
39992 + unsigned long arg, size_t ifreq_len)
39993 {
39994 struct tun_file *tfile = file->private_data;
39995 struct tun_struct *tun;
39996 @@ -1853,6 +1853,9 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
39997 int vnet_hdr_sz;
39998 int ret;
39999
40000 + if (ifreq_len > sizeof ifr)
40001 + return -EFAULT;
40002 +
40003 if (cmd == TUNSETIFF || cmd == TUNSETQUEUE || _IOC_TYPE(cmd) == 0x89) {
40004 if (copy_from_user(&ifr, argp, ifreq_len))
40005 return -EFAULT;
40006 diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
40007 index e2dd324..be92fcf 100644
40008 --- a/drivers/net/usb/hso.c
40009 +++ b/drivers/net/usb/hso.c
40010 @@ -71,7 +71,7 @@
40011 #include <asm/byteorder.h>
40012 #include <linux/serial_core.h>
40013 #include <linux/serial.h>
40014 -
40015 +#include <asm/local.h>
40016
40017 #define MOD_AUTHOR "Option Wireless"
40018 #define MOD_DESCRIPTION "USB High Speed Option driver"
40019 @@ -1180,7 +1180,7 @@ static void put_rxbuf_data_and_resubmit_ctrl_urb(struct hso_serial *serial)
40020 struct urb *urb;
40021
40022 urb = serial->rx_urb[0];
40023 - if (serial->port.count > 0) {
40024 + if (atomic_read(&serial->port.count) > 0) {
40025 count = put_rxbuf_data(urb, serial);
40026 if (count == -1)
40027 return;
40028 @@ -1216,7 +1216,7 @@ static void hso_std_serial_read_bulk_callback(struct urb *urb)
40029 DUMP1(urb->transfer_buffer, urb->actual_length);
40030
40031 /* Anyone listening? */
40032 - if (serial->port.count == 0)
40033 + if (atomic_read(&serial->port.count) == 0)
40034 return;
40035
40036 if (status == 0) {
40037 @@ -1298,8 +1298,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
40038 tty_port_tty_set(&serial->port, tty);
40039
40040 /* check for port already opened, if not set the termios */
40041 - serial->port.count++;
40042 - if (serial->port.count == 1) {
40043 + if (atomic_inc_return(&serial->port.count) == 1) {
40044 serial->rx_state = RX_IDLE;
40045 /* Force default termio settings */
40046 _hso_serial_set_termios(tty, NULL);
40047 @@ -1311,7 +1310,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
40048 result = hso_start_serial_device(serial->parent, GFP_KERNEL);
40049 if (result) {
40050 hso_stop_serial_device(serial->parent);
40051 - serial->port.count--;
40052 + atomic_dec(&serial->port.count);
40053 kref_put(&serial->parent->ref, hso_serial_ref_free);
40054 }
40055 } else {
40056 @@ -1348,10 +1347,10 @@ static void hso_serial_close(struct tty_struct *tty, struct file *filp)
40057
40058 /* reset the rts and dtr */
40059 /* do the actual close */
40060 - serial->port.count--;
40061 + atomic_dec(&serial->port.count);
40062
40063 - if (serial->port.count <= 0) {
40064 - serial->port.count = 0;
40065 + if (atomic_read(&serial->port.count) <= 0) {
40066 + atomic_set(&serial->port.count, 0);
40067 tty_port_tty_set(&serial->port, NULL);
40068 if (!usb_gone)
40069 hso_stop_serial_device(serial->parent);
40070 @@ -1427,7 +1426,7 @@ static void hso_serial_set_termios(struct tty_struct *tty, struct ktermios *old)
40071
40072 /* the actual setup */
40073 spin_lock_irqsave(&serial->serial_lock, flags);
40074 - if (serial->port.count)
40075 + if (atomic_read(&serial->port.count))
40076 _hso_serial_set_termios(tty, old);
40077 else
40078 tty->termios = *old;
40079 @@ -1886,7 +1885,7 @@ static void intr_callback(struct urb *urb)
40080 D1("Pending read interrupt on port %d\n", i);
40081 spin_lock(&serial->serial_lock);
40082 if (serial->rx_state == RX_IDLE &&
40083 - serial->port.count > 0) {
40084 + atomic_read(&serial->port.count) > 0) {
40085 /* Setup and send a ctrl req read on
40086 * port i */
40087 if (!serial->rx_urb_filled[0]) {
40088 @@ -3066,7 +3065,7 @@ static int hso_resume(struct usb_interface *iface)
40089 /* Start all serial ports */
40090 for (i = 0; i < HSO_SERIAL_TTY_MINORS; i++) {
40091 if (serial_table[i] && (serial_table[i]->interface == iface)) {
40092 - if (dev2ser(serial_table[i])->port.count) {
40093 + if (atomic_read(&dev2ser(serial_table[i])->port.count)) {
40094 result =
40095 hso_start_serial_device(serial_table[i], GFP_NOIO);
40096 hso_kick_transmit(dev2ser(serial_table[i]));
40097 diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
40098 index 7cee7a3..1eb9f3b 100644
40099 --- a/drivers/net/vxlan.c
40100 +++ b/drivers/net/vxlan.c
40101 @@ -1443,7 +1443,7 @@ nla_put_failure:
40102 return -EMSGSIZE;
40103 }
40104
40105 -static struct rtnl_link_ops vxlan_link_ops __read_mostly = {
40106 +static struct rtnl_link_ops vxlan_link_ops = {
40107 .kind = "vxlan",
40108 .maxtype = IFLA_VXLAN_MAX,
40109 .policy = vxlan_policy,
40110 diff --git a/drivers/net/wireless/at76c50x-usb.c b/drivers/net/wireless/at76c50x-usb.c
40111 index 5ac5f7a..5f82012 100644
40112 --- a/drivers/net/wireless/at76c50x-usb.c
40113 +++ b/drivers/net/wireless/at76c50x-usb.c
40114 @@ -353,7 +353,7 @@ static int at76_dfu_get_state(struct usb_device *udev, u8 *state)
40115 }
40116
40117 /* Convert timeout from the DFU status to jiffies */
40118 -static inline unsigned long at76_get_timeout(struct dfu_status *s)
40119 +static inline unsigned long __intentional_overflow(-1) at76_get_timeout(struct dfu_status *s)
40120 {
40121 return msecs_to_jiffies((s->poll_timeout[2] << 16)
40122 | (s->poll_timeout[1] << 8)
40123 diff --git a/drivers/net/wireless/ath/ath9k/ar9002_mac.c b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
40124 index 8d78253..bebbb68 100644
40125 --- a/drivers/net/wireless/ath/ath9k/ar9002_mac.c
40126 +++ b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
40127 @@ -184,8 +184,8 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40128 ads->ds_txstatus6 = ads->ds_txstatus7 = 0;
40129 ads->ds_txstatus8 = ads->ds_txstatus9 = 0;
40130
40131 - ACCESS_ONCE(ads->ds_link) = i->link;
40132 - ACCESS_ONCE(ads->ds_data) = i->buf_addr[0];
40133 + ACCESS_ONCE_RW(ads->ds_link) = i->link;
40134 + ACCESS_ONCE_RW(ads->ds_data) = i->buf_addr[0];
40135
40136 ctl1 = i->buf_len[0] | (i->is_last ? 0 : AR_TxMore);
40137 ctl6 = SM(i->keytype, AR_EncrType);
40138 @@ -199,26 +199,26 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40139
40140 if ((i->is_first || i->is_last) &&
40141 i->aggr != AGGR_BUF_MIDDLE && i->aggr != AGGR_BUF_LAST) {
40142 - ACCESS_ONCE(ads->ds_ctl2) = set11nTries(i->rates, 0)
40143 + ACCESS_ONCE_RW(ads->ds_ctl2) = set11nTries(i->rates, 0)
40144 | set11nTries(i->rates, 1)
40145 | set11nTries(i->rates, 2)
40146 | set11nTries(i->rates, 3)
40147 | (i->dur_update ? AR_DurUpdateEna : 0)
40148 | SM(0, AR_BurstDur);
40149
40150 - ACCESS_ONCE(ads->ds_ctl3) = set11nRate(i->rates, 0)
40151 + ACCESS_ONCE_RW(ads->ds_ctl3) = set11nRate(i->rates, 0)
40152 | set11nRate(i->rates, 1)
40153 | set11nRate(i->rates, 2)
40154 | set11nRate(i->rates, 3);
40155 } else {
40156 - ACCESS_ONCE(ads->ds_ctl2) = 0;
40157 - ACCESS_ONCE(ads->ds_ctl3) = 0;
40158 + ACCESS_ONCE_RW(ads->ds_ctl2) = 0;
40159 + ACCESS_ONCE_RW(ads->ds_ctl3) = 0;
40160 }
40161
40162 if (!i->is_first) {
40163 - ACCESS_ONCE(ads->ds_ctl0) = 0;
40164 - ACCESS_ONCE(ads->ds_ctl1) = ctl1;
40165 - ACCESS_ONCE(ads->ds_ctl6) = ctl6;
40166 + ACCESS_ONCE_RW(ads->ds_ctl0) = 0;
40167 + ACCESS_ONCE_RW(ads->ds_ctl1) = ctl1;
40168 + ACCESS_ONCE_RW(ads->ds_ctl6) = ctl6;
40169 return;
40170 }
40171
40172 @@ -243,7 +243,7 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40173 break;
40174 }
40175
40176 - ACCESS_ONCE(ads->ds_ctl0) = (i->pkt_len & AR_FrameLen)
40177 + ACCESS_ONCE_RW(ads->ds_ctl0) = (i->pkt_len & AR_FrameLen)
40178 | (i->flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
40179 | SM(i->txpower, AR_XmitPower)
40180 | (i->flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
40181 @@ -253,19 +253,19 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40182 | (i->flags & ATH9K_TXDESC_RTSENA ? AR_RTSEnable :
40183 (i->flags & ATH9K_TXDESC_CTSENA ? AR_CTSEnable : 0));
40184
40185 - ACCESS_ONCE(ads->ds_ctl1) = ctl1;
40186 - ACCESS_ONCE(ads->ds_ctl6) = ctl6;
40187 + ACCESS_ONCE_RW(ads->ds_ctl1) = ctl1;
40188 + ACCESS_ONCE_RW(ads->ds_ctl6) = ctl6;
40189
40190 if (i->aggr == AGGR_BUF_MIDDLE || i->aggr == AGGR_BUF_LAST)
40191 return;
40192
40193 - ACCESS_ONCE(ads->ds_ctl4) = set11nPktDurRTSCTS(i->rates, 0)
40194 + ACCESS_ONCE_RW(ads->ds_ctl4) = set11nPktDurRTSCTS(i->rates, 0)
40195 | set11nPktDurRTSCTS(i->rates, 1);
40196
40197 - ACCESS_ONCE(ads->ds_ctl5) = set11nPktDurRTSCTS(i->rates, 2)
40198 + ACCESS_ONCE_RW(ads->ds_ctl5) = set11nPktDurRTSCTS(i->rates, 2)
40199 | set11nPktDurRTSCTS(i->rates, 3);
40200
40201 - ACCESS_ONCE(ads->ds_ctl7) = set11nRateFlags(i->rates, 0)
40202 + ACCESS_ONCE_RW(ads->ds_ctl7) = set11nRateFlags(i->rates, 0)
40203 | set11nRateFlags(i->rates, 1)
40204 | set11nRateFlags(i->rates, 2)
40205 | set11nRateFlags(i->rates, 3)
40206 diff --git a/drivers/net/wireless/ath/ath9k/ar9003_mac.c b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
40207 index 301bf72..3f5654f 100644
40208 --- a/drivers/net/wireless/ath/ath9k/ar9003_mac.c
40209 +++ b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
40210 @@ -39,47 +39,47 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40211 (i->qcu << AR_TxQcuNum_S) | desc_len;
40212
40213 checksum += val;
40214 - ACCESS_ONCE(ads->info) = val;
40215 + ACCESS_ONCE_RW(ads->info) = val;
40216
40217 checksum += i->link;
40218 - ACCESS_ONCE(ads->link) = i->link;
40219 + ACCESS_ONCE_RW(ads->link) = i->link;
40220
40221 checksum += i->buf_addr[0];
40222 - ACCESS_ONCE(ads->data0) = i->buf_addr[0];
40223 + ACCESS_ONCE_RW(ads->data0) = i->buf_addr[0];
40224 checksum += i->buf_addr[1];
40225 - ACCESS_ONCE(ads->data1) = i->buf_addr[1];
40226 + ACCESS_ONCE_RW(ads->data1) = i->buf_addr[1];
40227 checksum += i->buf_addr[2];
40228 - ACCESS_ONCE(ads->data2) = i->buf_addr[2];
40229 + ACCESS_ONCE_RW(ads->data2) = i->buf_addr[2];
40230 checksum += i->buf_addr[3];
40231 - ACCESS_ONCE(ads->data3) = i->buf_addr[3];
40232 + ACCESS_ONCE_RW(ads->data3) = i->buf_addr[3];
40233
40234 checksum += (val = (i->buf_len[0] << AR_BufLen_S) & AR_BufLen);
40235 - ACCESS_ONCE(ads->ctl3) = val;
40236 + ACCESS_ONCE_RW(ads->ctl3) = val;
40237 checksum += (val = (i->buf_len[1] << AR_BufLen_S) & AR_BufLen);
40238 - ACCESS_ONCE(ads->ctl5) = val;
40239 + ACCESS_ONCE_RW(ads->ctl5) = val;
40240 checksum += (val = (i->buf_len[2] << AR_BufLen_S) & AR_BufLen);
40241 - ACCESS_ONCE(ads->ctl7) = val;
40242 + ACCESS_ONCE_RW(ads->ctl7) = val;
40243 checksum += (val = (i->buf_len[3] << AR_BufLen_S) & AR_BufLen);
40244 - ACCESS_ONCE(ads->ctl9) = val;
40245 + ACCESS_ONCE_RW(ads->ctl9) = val;
40246
40247 checksum = (u16) (((checksum & 0xffff) + (checksum >> 16)) & 0xffff);
40248 - ACCESS_ONCE(ads->ctl10) = checksum;
40249 + ACCESS_ONCE_RW(ads->ctl10) = checksum;
40250
40251 if (i->is_first || i->is_last) {
40252 - ACCESS_ONCE(ads->ctl13) = set11nTries(i->rates, 0)
40253 + ACCESS_ONCE_RW(ads->ctl13) = set11nTries(i->rates, 0)
40254 | set11nTries(i->rates, 1)
40255 | set11nTries(i->rates, 2)
40256 | set11nTries(i->rates, 3)
40257 | (i->dur_update ? AR_DurUpdateEna : 0)
40258 | SM(0, AR_BurstDur);
40259
40260 - ACCESS_ONCE(ads->ctl14) = set11nRate(i->rates, 0)
40261 + ACCESS_ONCE_RW(ads->ctl14) = set11nRate(i->rates, 0)
40262 | set11nRate(i->rates, 1)
40263 | set11nRate(i->rates, 2)
40264 | set11nRate(i->rates, 3);
40265 } else {
40266 - ACCESS_ONCE(ads->ctl13) = 0;
40267 - ACCESS_ONCE(ads->ctl14) = 0;
40268 + ACCESS_ONCE_RW(ads->ctl13) = 0;
40269 + ACCESS_ONCE_RW(ads->ctl14) = 0;
40270 }
40271
40272 ads->ctl20 = 0;
40273 @@ -89,17 +89,17 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40274
40275 ctl17 = SM(i->keytype, AR_EncrType);
40276 if (!i->is_first) {
40277 - ACCESS_ONCE(ads->ctl11) = 0;
40278 - ACCESS_ONCE(ads->ctl12) = i->is_last ? 0 : AR_TxMore;
40279 - ACCESS_ONCE(ads->ctl15) = 0;
40280 - ACCESS_ONCE(ads->ctl16) = 0;
40281 - ACCESS_ONCE(ads->ctl17) = ctl17;
40282 - ACCESS_ONCE(ads->ctl18) = 0;
40283 - ACCESS_ONCE(ads->ctl19) = 0;
40284 + ACCESS_ONCE_RW(ads->ctl11) = 0;
40285 + ACCESS_ONCE_RW(ads->ctl12) = i->is_last ? 0 : AR_TxMore;
40286 + ACCESS_ONCE_RW(ads->ctl15) = 0;
40287 + ACCESS_ONCE_RW(ads->ctl16) = 0;
40288 + ACCESS_ONCE_RW(ads->ctl17) = ctl17;
40289 + ACCESS_ONCE_RW(ads->ctl18) = 0;
40290 + ACCESS_ONCE_RW(ads->ctl19) = 0;
40291 return;
40292 }
40293
40294 - ACCESS_ONCE(ads->ctl11) = (i->pkt_len & AR_FrameLen)
40295 + ACCESS_ONCE_RW(ads->ctl11) = (i->pkt_len & AR_FrameLen)
40296 | (i->flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
40297 | SM(i->txpower, AR_XmitPower)
40298 | (i->flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
40299 @@ -135,22 +135,22 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40300 val = (i->flags & ATH9K_TXDESC_PAPRD) >> ATH9K_TXDESC_PAPRD_S;
40301 ctl12 |= SM(val, AR_PAPRDChainMask);
40302
40303 - ACCESS_ONCE(ads->ctl12) = ctl12;
40304 - ACCESS_ONCE(ads->ctl17) = ctl17;
40305 + ACCESS_ONCE_RW(ads->ctl12) = ctl12;
40306 + ACCESS_ONCE_RW(ads->ctl17) = ctl17;
40307
40308 - ACCESS_ONCE(ads->ctl15) = set11nPktDurRTSCTS(i->rates, 0)
40309 + ACCESS_ONCE_RW(ads->ctl15) = set11nPktDurRTSCTS(i->rates, 0)
40310 | set11nPktDurRTSCTS(i->rates, 1);
40311
40312 - ACCESS_ONCE(ads->ctl16) = set11nPktDurRTSCTS(i->rates, 2)
40313 + ACCESS_ONCE_RW(ads->ctl16) = set11nPktDurRTSCTS(i->rates, 2)
40314 | set11nPktDurRTSCTS(i->rates, 3);
40315
40316 - ACCESS_ONCE(ads->ctl18) = set11nRateFlags(i->rates, 0)
40317 + ACCESS_ONCE_RW(ads->ctl18) = set11nRateFlags(i->rates, 0)
40318 | set11nRateFlags(i->rates, 1)
40319 | set11nRateFlags(i->rates, 2)
40320 | set11nRateFlags(i->rates, 3)
40321 | SM(i->rtscts_rate, AR_RTSCTSRate);
40322
40323 - ACCESS_ONCE(ads->ctl19) = AR_Not_Sounding;
40324 + ACCESS_ONCE_RW(ads->ctl19) = AR_Not_Sounding;
40325 }
40326
40327 static u16 ar9003_calc_ptr_chksum(struct ar9003_txc *ads)
40328 diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h
40329 index 784e81c..349e01e 100644
40330 --- a/drivers/net/wireless/ath/ath9k/hw.h
40331 +++ b/drivers/net/wireless/ath/ath9k/hw.h
40332 @@ -653,7 +653,7 @@ struct ath_hw_private_ops {
40333
40334 /* ANI */
40335 void (*ani_cache_ini_regs)(struct ath_hw *ah);
40336 -};
40337 +} __no_const;
40338
40339 /**
40340 * struct ath_spec_scan - parameters for Atheros spectral scan
40341 @@ -722,7 +722,7 @@ struct ath_hw_ops {
40342 struct ath_spec_scan *param);
40343 void (*spectral_scan_trigger)(struct ath_hw *ah);
40344 void (*spectral_scan_wait)(struct ath_hw *ah);
40345 -};
40346 +} __no_const;
40347
40348 struct ath_nf_limits {
40349 s16 max;
40350 diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c
40351 index c353b5f..62aaca2 100644
40352 --- a/drivers/net/wireless/iwlegacy/3945-mac.c
40353 +++ b/drivers/net/wireless/iwlegacy/3945-mac.c
40354 @@ -3639,7 +3639,9 @@ il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
40355 */
40356 if (il3945_mod_params.disable_hw_scan) {
40357 D_INFO("Disabling hw_scan\n");
40358 - il3945_mac_ops.hw_scan = NULL;
40359 + pax_open_kernel();
40360 + *(void **)&il3945_mac_ops.hw_scan = NULL;
40361 + pax_close_kernel();
40362 }
40363
40364 D_INFO("*** LOAD DRIVER ***\n");
40365 diff --git a/drivers/net/wireless/iwlwifi/dvm/debugfs.c b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
40366 index 81d4071..f2071ea 100644
40367 --- a/drivers/net/wireless/iwlwifi/dvm/debugfs.c
40368 +++ b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
40369 @@ -203,7 +203,7 @@ static ssize_t iwl_dbgfs_sram_write(struct file *file,
40370 {
40371 struct iwl_priv *priv = file->private_data;
40372 char buf[64];
40373 - int buf_size;
40374 + size_t buf_size;
40375 u32 offset, len;
40376
40377 memset(buf, 0, sizeof(buf));
40378 @@ -473,7 +473,7 @@ static ssize_t iwl_dbgfs_rx_handlers_write(struct file *file,
40379 struct iwl_priv *priv = file->private_data;
40380
40381 char buf[8];
40382 - int buf_size;
40383 + size_t buf_size;
40384 u32 reset_flag;
40385
40386 memset(buf, 0, sizeof(buf));
40387 @@ -554,7 +554,7 @@ static ssize_t iwl_dbgfs_disable_ht40_write(struct file *file,
40388 {
40389 struct iwl_priv *priv = file->private_data;
40390 char buf[8];
40391 - int buf_size;
40392 + size_t buf_size;
40393 int ht40;
40394
40395 memset(buf, 0, sizeof(buf));
40396 @@ -606,7 +606,7 @@ static ssize_t iwl_dbgfs_sleep_level_override_write(struct file *file,
40397 {
40398 struct iwl_priv *priv = file->private_data;
40399 char buf[8];
40400 - int buf_size;
40401 + size_t buf_size;
40402 int value;
40403
40404 memset(buf, 0, sizeof(buf));
40405 @@ -1871,7 +1871,7 @@ static ssize_t iwl_dbgfs_clear_ucode_statistics_write(struct file *file,
40406 {
40407 struct iwl_priv *priv = file->private_data;
40408 char buf[8];
40409 - int buf_size;
40410 + size_t buf_size;
40411 int clear;
40412
40413 memset(buf, 0, sizeof(buf));
40414 @@ -1916,7 +1916,7 @@ static ssize_t iwl_dbgfs_ucode_tracing_write(struct file *file,
40415 {
40416 struct iwl_priv *priv = file->private_data;
40417 char buf[8];
40418 - int buf_size;
40419 + size_t buf_size;
40420 int trace;
40421
40422 memset(buf, 0, sizeof(buf));
40423 @@ -1987,7 +1987,7 @@ static ssize_t iwl_dbgfs_missed_beacon_write(struct file *file,
40424 {
40425 struct iwl_priv *priv = file->private_data;
40426 char buf[8];
40427 - int buf_size;
40428 + size_t buf_size;
40429 int missed;
40430
40431 memset(buf, 0, sizeof(buf));
40432 @@ -2028,7 +2028,7 @@ static ssize_t iwl_dbgfs_plcp_delta_write(struct file *file,
40433
40434 struct iwl_priv *priv = file->private_data;
40435 char buf[8];
40436 - int buf_size;
40437 + size_t buf_size;
40438 int plcp;
40439
40440 memset(buf, 0, sizeof(buf));
40441 @@ -2088,7 +2088,7 @@ static ssize_t iwl_dbgfs_txfifo_flush_write(struct file *file,
40442
40443 struct iwl_priv *priv = file->private_data;
40444 char buf[8];
40445 - int buf_size;
40446 + size_t buf_size;
40447 int flush;
40448
40449 memset(buf, 0, sizeof(buf));
40450 @@ -2178,7 +2178,7 @@ static ssize_t iwl_dbgfs_protection_mode_write(struct file *file,
40451
40452 struct iwl_priv *priv = file->private_data;
40453 char buf[8];
40454 - int buf_size;
40455 + size_t buf_size;
40456 int rts;
40457
40458 if (!priv->cfg->ht_params)
40459 @@ -2220,7 +2220,7 @@ static ssize_t iwl_dbgfs_echo_test_write(struct file *file,
40460 {
40461 struct iwl_priv *priv = file->private_data;
40462 char buf[8];
40463 - int buf_size;
40464 + size_t buf_size;
40465
40466 memset(buf, 0, sizeof(buf));
40467 buf_size = min(count, sizeof(buf) - 1);
40468 @@ -2256,7 +2256,7 @@ static ssize_t iwl_dbgfs_log_event_write(struct file *file,
40469 struct iwl_priv *priv = file->private_data;
40470 u32 event_log_flag;
40471 char buf[8];
40472 - int buf_size;
40473 + size_t buf_size;
40474
40475 /* check that the interface is up */
40476 if (!iwl_is_ready(priv))
40477 @@ -2310,7 +2310,7 @@ static ssize_t iwl_dbgfs_calib_disabled_write(struct file *file,
40478 struct iwl_priv *priv = file->private_data;
40479 char buf[8];
40480 u32 calib_disabled;
40481 - int buf_size;
40482 + size_t buf_size;
40483
40484 memset(buf, 0, sizeof(buf));
40485 buf_size = min(count, sizeof(buf) - 1);
40486 diff --git a/drivers/net/wireless/iwlwifi/pcie/trans.c b/drivers/net/wireless/iwlwifi/pcie/trans.c
40487 index 12c4f31..484d948 100644
40488 --- a/drivers/net/wireless/iwlwifi/pcie/trans.c
40489 +++ b/drivers/net/wireless/iwlwifi/pcie/trans.c
40490 @@ -1328,7 +1328,7 @@ static ssize_t iwl_dbgfs_interrupt_write(struct file *file,
40491 struct isr_statistics *isr_stats = &trans_pcie->isr_stats;
40492
40493 char buf[8];
40494 - int buf_size;
40495 + size_t buf_size;
40496 u32 reset_flag;
40497
40498 memset(buf, 0, sizeof(buf));
40499 @@ -1349,7 +1349,7 @@ static ssize_t iwl_dbgfs_csr_write(struct file *file,
40500 {
40501 struct iwl_trans *trans = file->private_data;
40502 char buf[8];
40503 - int buf_size;
40504 + size_t buf_size;
40505 int csr;
40506
40507 memset(buf, 0, sizeof(buf));
40508 diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
40509 index cffdf4f..7cefb69 100644
40510 --- a/drivers/net/wireless/mac80211_hwsim.c
40511 +++ b/drivers/net/wireless/mac80211_hwsim.c
40512 @@ -2144,25 +2144,19 @@ static int __init init_mac80211_hwsim(void)
40513
40514 if (channels > 1) {
40515 hwsim_if_comb.num_different_channels = channels;
40516 - mac80211_hwsim_ops.hw_scan = mac80211_hwsim_hw_scan;
40517 - mac80211_hwsim_ops.cancel_hw_scan =
40518 - mac80211_hwsim_cancel_hw_scan;
40519 - mac80211_hwsim_ops.sw_scan_start = NULL;
40520 - mac80211_hwsim_ops.sw_scan_complete = NULL;
40521 - mac80211_hwsim_ops.remain_on_channel =
40522 - mac80211_hwsim_roc;
40523 - mac80211_hwsim_ops.cancel_remain_on_channel =
40524 - mac80211_hwsim_croc;
40525 - mac80211_hwsim_ops.add_chanctx =
40526 - mac80211_hwsim_add_chanctx;
40527 - mac80211_hwsim_ops.remove_chanctx =
40528 - mac80211_hwsim_remove_chanctx;
40529 - mac80211_hwsim_ops.change_chanctx =
40530 - mac80211_hwsim_change_chanctx;
40531 - mac80211_hwsim_ops.assign_vif_chanctx =
40532 - mac80211_hwsim_assign_vif_chanctx;
40533 - mac80211_hwsim_ops.unassign_vif_chanctx =
40534 - mac80211_hwsim_unassign_vif_chanctx;
40535 + pax_open_kernel();
40536 + *(void **)&mac80211_hwsim_ops.hw_scan = mac80211_hwsim_hw_scan;
40537 + *(void **)&mac80211_hwsim_ops.cancel_hw_scan = mac80211_hwsim_cancel_hw_scan;
40538 + *(void **)&mac80211_hwsim_ops.sw_scan_start = NULL;
40539 + *(void **)&mac80211_hwsim_ops.sw_scan_complete = NULL;
40540 + *(void **)&mac80211_hwsim_ops.remain_on_channel = mac80211_hwsim_roc;
40541 + *(void **)&mac80211_hwsim_ops.cancel_remain_on_channel = mac80211_hwsim_croc;
40542 + *(void **)&mac80211_hwsim_ops.add_chanctx = mac80211_hwsim_add_chanctx;
40543 + *(void **)&mac80211_hwsim_ops.remove_chanctx = mac80211_hwsim_remove_chanctx;
40544 + *(void **)&mac80211_hwsim_ops.change_chanctx = mac80211_hwsim_change_chanctx;
40545 + *(void **)&mac80211_hwsim_ops.assign_vif_chanctx = mac80211_hwsim_assign_vif_chanctx;
40546 + *(void **)&mac80211_hwsim_ops.unassign_vif_chanctx = mac80211_hwsim_unassign_vif_chanctx;
40547 + pax_close_kernel();
40548 }
40549
40550 spin_lock_init(&hwsim_radio_lock);
40551 diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c
40552 index 525fd75..6c9f791 100644
40553 --- a/drivers/net/wireless/rndis_wlan.c
40554 +++ b/drivers/net/wireless/rndis_wlan.c
40555 @@ -1238,7 +1238,7 @@ static int set_rts_threshold(struct usbnet *usbdev, u32 rts_threshold)
40556
40557 netdev_dbg(usbdev->net, "%s(): %i\n", __func__, rts_threshold);
40558
40559 - if (rts_threshold < 0 || rts_threshold > 2347)
40560 + if (rts_threshold > 2347)
40561 rts_threshold = 2347;
40562
40563 tmp = cpu_to_le32(rts_threshold);
40564 diff --git a/drivers/net/wireless/rt2x00/rt2x00.h b/drivers/net/wireless/rt2x00/rt2x00.h
40565 index 086abb4..8279c30 100644
40566 --- a/drivers/net/wireless/rt2x00/rt2x00.h
40567 +++ b/drivers/net/wireless/rt2x00/rt2x00.h
40568 @@ -396,7 +396,7 @@ struct rt2x00_intf {
40569 * for hardware which doesn't support hardware
40570 * sequence counting.
40571 */
40572 - atomic_t seqno;
40573 + atomic_unchecked_t seqno;
40574 };
40575
40576 static inline struct rt2x00_intf* vif_to_intf(struct ieee80211_vif *vif)
40577 diff --git a/drivers/net/wireless/rt2x00/rt2x00queue.c b/drivers/net/wireless/rt2x00/rt2x00queue.c
40578 index 4d91795..62fccff 100644
40579 --- a/drivers/net/wireless/rt2x00/rt2x00queue.c
40580 +++ b/drivers/net/wireless/rt2x00/rt2x00queue.c
40581 @@ -251,9 +251,9 @@ static void rt2x00queue_create_tx_descriptor_seq(struct rt2x00_dev *rt2x00dev,
40582 * sequence counter given by mac80211.
40583 */
40584 if (test_bit(ENTRY_TXD_FIRST_FRAGMENT, &txdesc->flags))
40585 - seqno = atomic_add_return(0x10, &intf->seqno);
40586 + seqno = atomic_add_return_unchecked(0x10, &intf->seqno);
40587 else
40588 - seqno = atomic_read(&intf->seqno);
40589 + seqno = atomic_read_unchecked(&intf->seqno);
40590
40591 hdr->seq_ctrl &= cpu_to_le16(IEEE80211_SCTL_FRAG);
40592 hdr->seq_ctrl |= cpu_to_le16(seqno);
40593 diff --git a/drivers/net/wireless/ti/wl1251/sdio.c b/drivers/net/wireless/ti/wl1251/sdio.c
40594 index e57ee48..541cf6c 100644
40595 --- a/drivers/net/wireless/ti/wl1251/sdio.c
40596 +++ b/drivers/net/wireless/ti/wl1251/sdio.c
40597 @@ -269,13 +269,17 @@ static int wl1251_sdio_probe(struct sdio_func *func,
40598
40599 irq_set_irq_type(wl->irq, IRQ_TYPE_EDGE_RISING);
40600
40601 - wl1251_sdio_ops.enable_irq = wl1251_enable_line_irq;
40602 - wl1251_sdio_ops.disable_irq = wl1251_disable_line_irq;
40603 + pax_open_kernel();
40604 + *(void **)&wl1251_sdio_ops.enable_irq = wl1251_enable_line_irq;
40605 + *(void **)&wl1251_sdio_ops.disable_irq = wl1251_disable_line_irq;
40606 + pax_close_kernel();
40607
40608 wl1251_info("using dedicated interrupt line");
40609 } else {
40610 - wl1251_sdio_ops.enable_irq = wl1251_sdio_enable_irq;
40611 - wl1251_sdio_ops.disable_irq = wl1251_sdio_disable_irq;
40612 + pax_open_kernel();
40613 + *(void **)&wl1251_sdio_ops.enable_irq = wl1251_sdio_enable_irq;
40614 + *(void **)&wl1251_sdio_ops.disable_irq = wl1251_sdio_disable_irq;
40615 + pax_close_kernel();
40616
40617 wl1251_info("using SDIO interrupt");
40618 }
40619 diff --git a/drivers/net/wireless/ti/wl12xx/main.c b/drivers/net/wireless/ti/wl12xx/main.c
40620 index 09694e3..24ccec7 100644
40621 --- a/drivers/net/wireless/ti/wl12xx/main.c
40622 +++ b/drivers/net/wireless/ti/wl12xx/main.c
40623 @@ -656,7 +656,9 @@ static int wl12xx_identify_chip(struct wl1271 *wl)
40624 sizeof(wl->conf.mem));
40625
40626 /* read data preparation is only needed by wl127x */
40627 - wl->ops->prepare_read = wl127x_prepare_read;
40628 + pax_open_kernel();
40629 + *(void **)&wl->ops->prepare_read = wl127x_prepare_read;
40630 + pax_close_kernel();
40631
40632 wlcore_set_min_fw_ver(wl, WL127X_CHIP_VER,
40633 WL127X_IFTYPE_SR_VER, WL127X_MAJOR_SR_VER,
40634 @@ -681,7 +683,9 @@ static int wl12xx_identify_chip(struct wl1271 *wl)
40635 sizeof(wl->conf.mem));
40636
40637 /* read data preparation is only needed by wl127x */
40638 - wl->ops->prepare_read = wl127x_prepare_read;
40639 + pax_open_kernel();
40640 + *(void **)&wl->ops->prepare_read = wl127x_prepare_read;
40641 + pax_close_kernel();
40642
40643 wlcore_set_min_fw_ver(wl, WL127X_CHIP_VER,
40644 WL127X_IFTYPE_SR_VER, WL127X_MAJOR_SR_VER,
40645 diff --git a/drivers/net/wireless/ti/wl18xx/main.c b/drivers/net/wireless/ti/wl18xx/main.c
40646 index da3ef1b..4790b95 100644
40647 --- a/drivers/net/wireless/ti/wl18xx/main.c
40648 +++ b/drivers/net/wireless/ti/wl18xx/main.c
40649 @@ -1664,8 +1664,10 @@ static int wl18xx_setup(struct wl1271 *wl)
40650 }
40651
40652 if (!checksum_param) {
40653 - wl18xx_ops.set_rx_csum = NULL;
40654 - wl18xx_ops.init_vif = NULL;
40655 + pax_open_kernel();
40656 + *(void **)&wl18xx_ops.set_rx_csum = NULL;
40657 + *(void **)&wl18xx_ops.init_vif = NULL;
40658 + pax_close_kernel();
40659 }
40660
40661 /* Enable 11a Band only if we have 5G antennas */
40662 diff --git a/drivers/net/wireless/zd1211rw/zd_usb.c b/drivers/net/wireless/zd1211rw/zd_usb.c
40663 index 7ef0b4a..ff65c28 100644
40664 --- a/drivers/net/wireless/zd1211rw/zd_usb.c
40665 +++ b/drivers/net/wireless/zd1211rw/zd_usb.c
40666 @@ -386,7 +386,7 @@ static inline void handle_regs_int(struct urb *urb)
40667 {
40668 struct zd_usb *usb = urb->context;
40669 struct zd_usb_interrupt *intr = &usb->intr;
40670 - int len;
40671 + unsigned int len;
40672 u16 int_num;
40673
40674 ZD_ASSERT(in_interrupt());
40675 diff --git a/drivers/oprofile/buffer_sync.c b/drivers/oprofile/buffer_sync.c
40676 index d93b2b6..ae50401 100644
40677 --- a/drivers/oprofile/buffer_sync.c
40678 +++ b/drivers/oprofile/buffer_sync.c
40679 @@ -332,7 +332,7 @@ static void add_data(struct op_entry *entry, struct mm_struct *mm)
40680 if (cookie == NO_COOKIE)
40681 offset = pc;
40682 if (cookie == INVALID_COOKIE) {
40683 - atomic_inc(&oprofile_stats.sample_lost_no_mapping);
40684 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mapping);
40685 offset = pc;
40686 }
40687 if (cookie != last_cookie) {
40688 @@ -376,14 +376,14 @@ add_sample(struct mm_struct *mm, struct op_sample *s, int in_kernel)
40689 /* add userspace sample */
40690
40691 if (!mm) {
40692 - atomic_inc(&oprofile_stats.sample_lost_no_mm);
40693 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mm);
40694 return 0;
40695 }
40696
40697 cookie = lookup_dcookie(mm, s->eip, &offset);
40698
40699 if (cookie == INVALID_COOKIE) {
40700 - atomic_inc(&oprofile_stats.sample_lost_no_mapping);
40701 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mapping);
40702 return 0;
40703 }
40704
40705 @@ -552,7 +552,7 @@ void sync_buffer(int cpu)
40706 /* ignore backtraces if failed to add a sample */
40707 if (state == sb_bt_start) {
40708 state = sb_bt_ignore;
40709 - atomic_inc(&oprofile_stats.bt_lost_no_mapping);
40710 + atomic_inc_unchecked(&oprofile_stats.bt_lost_no_mapping);
40711 }
40712 }
40713 release_mm(mm);
40714 diff --git a/drivers/oprofile/event_buffer.c b/drivers/oprofile/event_buffer.c
40715 index c0cc4e7..44d4e54 100644
40716 --- a/drivers/oprofile/event_buffer.c
40717 +++ b/drivers/oprofile/event_buffer.c
40718 @@ -53,7 +53,7 @@ void add_event_entry(unsigned long value)
40719 }
40720
40721 if (buffer_pos == buffer_size) {
40722 - atomic_inc(&oprofile_stats.event_lost_overflow);
40723 + atomic_inc_unchecked(&oprofile_stats.event_lost_overflow);
40724 return;
40725 }
40726
40727 diff --git a/drivers/oprofile/oprof.c b/drivers/oprofile/oprof.c
40728 index ed2c3ec..deda85a 100644
40729 --- a/drivers/oprofile/oprof.c
40730 +++ b/drivers/oprofile/oprof.c
40731 @@ -110,7 +110,7 @@ static void switch_worker(struct work_struct *work)
40732 if (oprofile_ops.switch_events())
40733 return;
40734
40735 - atomic_inc(&oprofile_stats.multiplex_counter);
40736 + atomic_inc_unchecked(&oprofile_stats.multiplex_counter);
40737 start_switch_worker();
40738 }
40739
40740 diff --git a/drivers/oprofile/oprofile_files.c b/drivers/oprofile/oprofile_files.c
40741 index 84a208d..d61b0a1 100644
40742 --- a/drivers/oprofile/oprofile_files.c
40743 +++ b/drivers/oprofile/oprofile_files.c
40744 @@ -27,7 +27,7 @@ unsigned long oprofile_time_slice;
40745
40746 #ifdef CONFIG_OPROFILE_EVENT_MULTIPLEX
40747
40748 -static ssize_t timeout_read(struct file *file, char __user *buf,
40749 +static ssize_t __intentional_overflow(-1) timeout_read(struct file *file, char __user *buf,
40750 size_t count, loff_t *offset)
40751 {
40752 return oprofilefs_ulong_to_user(jiffies_to_msecs(oprofile_time_slice),
40753 diff --git a/drivers/oprofile/oprofile_stats.c b/drivers/oprofile/oprofile_stats.c
40754 index 917d28e..d62d981 100644
40755 --- a/drivers/oprofile/oprofile_stats.c
40756 +++ b/drivers/oprofile/oprofile_stats.c
40757 @@ -30,11 +30,11 @@ void oprofile_reset_stats(void)
40758 cpu_buf->sample_invalid_eip = 0;
40759 }
40760
40761 - atomic_set(&oprofile_stats.sample_lost_no_mm, 0);
40762 - atomic_set(&oprofile_stats.sample_lost_no_mapping, 0);
40763 - atomic_set(&oprofile_stats.event_lost_overflow, 0);
40764 - atomic_set(&oprofile_stats.bt_lost_no_mapping, 0);
40765 - atomic_set(&oprofile_stats.multiplex_counter, 0);
40766 + atomic_set_unchecked(&oprofile_stats.sample_lost_no_mm, 0);
40767 + atomic_set_unchecked(&oprofile_stats.sample_lost_no_mapping, 0);
40768 + atomic_set_unchecked(&oprofile_stats.event_lost_overflow, 0);
40769 + atomic_set_unchecked(&oprofile_stats.bt_lost_no_mapping, 0);
40770 + atomic_set_unchecked(&oprofile_stats.multiplex_counter, 0);
40771 }
40772
40773
40774 diff --git a/drivers/oprofile/oprofile_stats.h b/drivers/oprofile/oprofile_stats.h
40775 index 38b6fc0..b5cbfce 100644
40776 --- a/drivers/oprofile/oprofile_stats.h
40777 +++ b/drivers/oprofile/oprofile_stats.h
40778 @@ -13,11 +13,11 @@
40779 #include <linux/atomic.h>
40780
40781 struct oprofile_stat_struct {
40782 - atomic_t sample_lost_no_mm;
40783 - atomic_t sample_lost_no_mapping;
40784 - atomic_t bt_lost_no_mapping;
40785 - atomic_t event_lost_overflow;
40786 - atomic_t multiplex_counter;
40787 + atomic_unchecked_t sample_lost_no_mm;
40788 + atomic_unchecked_t sample_lost_no_mapping;
40789 + atomic_unchecked_t bt_lost_no_mapping;
40790 + atomic_unchecked_t event_lost_overflow;
40791 + atomic_unchecked_t multiplex_counter;
40792 };
40793
40794 extern struct oprofile_stat_struct oprofile_stats;
40795 diff --git a/drivers/oprofile/oprofilefs.c b/drivers/oprofile/oprofilefs.c
40796 index 7c12d9c..558bf3bb 100644
40797 --- a/drivers/oprofile/oprofilefs.c
40798 +++ b/drivers/oprofile/oprofilefs.c
40799 @@ -190,7 +190,7 @@ static const struct file_operations atomic_ro_fops = {
40800
40801
40802 int oprofilefs_create_ro_atomic(struct super_block *sb, struct dentry *root,
40803 - char const *name, atomic_t *val)
40804 + char const *name, atomic_unchecked_t *val)
40805 {
40806 return __oprofilefs_create_file(sb, root, name,
40807 &atomic_ro_fops, 0444, val);
40808 diff --git a/drivers/oprofile/timer_int.c b/drivers/oprofile/timer_int.c
40809 index 93404f7..4a313d8 100644
40810 --- a/drivers/oprofile/timer_int.c
40811 +++ b/drivers/oprofile/timer_int.c
40812 @@ -93,7 +93,7 @@ static int __cpuinit oprofile_cpu_notify(struct notifier_block *self,
40813 return NOTIFY_OK;
40814 }
40815
40816 -static struct notifier_block __refdata oprofile_cpu_notifier = {
40817 +static struct notifier_block oprofile_cpu_notifier = {
40818 .notifier_call = oprofile_cpu_notify,
40819 };
40820
40821 diff --git a/drivers/parport/procfs.c b/drivers/parport/procfs.c
40822 index 3f56bc0..707d642 100644
40823 --- a/drivers/parport/procfs.c
40824 +++ b/drivers/parport/procfs.c
40825 @@ -64,7 +64,7 @@ static int do_active_device(ctl_table *table, int write,
40826
40827 *ppos += len;
40828
40829 - return copy_to_user(result, buffer, len) ? -EFAULT : 0;
40830 + return (len > sizeof buffer || copy_to_user(result, buffer, len)) ? -EFAULT : 0;
40831 }
40832
40833 #ifdef CONFIG_PARPORT_1284
40834 @@ -106,7 +106,7 @@ static int do_autoprobe(ctl_table *table, int write,
40835
40836 *ppos += len;
40837
40838 - return copy_to_user (result, buffer, len) ? -EFAULT : 0;
40839 + return (len > sizeof buffer || copy_to_user (result, buffer, len)) ? -EFAULT : 0;
40840 }
40841 #endif /* IEEE1284.3 support. */
40842
40843 diff --git a/drivers/pci/hotplug/acpiphp_ibm.c b/drivers/pci/hotplug/acpiphp_ibm.c
40844 index c35e8ad..fc33beb 100644
40845 --- a/drivers/pci/hotplug/acpiphp_ibm.c
40846 +++ b/drivers/pci/hotplug/acpiphp_ibm.c
40847 @@ -464,7 +464,9 @@ static int __init ibm_acpiphp_init(void)
40848 goto init_cleanup;
40849 }
40850
40851 - ibm_apci_table_attr.size = ibm_get_table_from_acpi(NULL);
40852 + pax_open_kernel();
40853 + *(size_t *)&ibm_apci_table_attr.size = ibm_get_table_from_acpi(NULL);
40854 + pax_close_kernel();
40855 retval = sysfs_create_bin_file(sysdir, &ibm_apci_table_attr);
40856
40857 return retval;
40858 diff --git a/drivers/pci/hotplug/cpcihp_generic.c b/drivers/pci/hotplug/cpcihp_generic.c
40859 index a6a71c4..c91097b 100644
40860 --- a/drivers/pci/hotplug/cpcihp_generic.c
40861 +++ b/drivers/pci/hotplug/cpcihp_generic.c
40862 @@ -73,7 +73,6 @@ static u16 port;
40863 static unsigned int enum_bit;
40864 static u8 enum_mask;
40865
40866 -static struct cpci_hp_controller_ops generic_hpc_ops;
40867 static struct cpci_hp_controller generic_hpc;
40868
40869 static int __init validate_parameters(void)
40870 @@ -139,6 +138,10 @@ static int query_enum(void)
40871 return ((value & enum_mask) == enum_mask);
40872 }
40873
40874 +static struct cpci_hp_controller_ops generic_hpc_ops = {
40875 + .query_enum = query_enum,
40876 +};
40877 +
40878 static int __init cpcihp_generic_init(void)
40879 {
40880 int status;
40881 @@ -165,7 +168,6 @@ static int __init cpcihp_generic_init(void)
40882 pci_dev_put(dev);
40883
40884 memset(&generic_hpc, 0, sizeof (struct cpci_hp_controller));
40885 - generic_hpc_ops.query_enum = query_enum;
40886 generic_hpc.ops = &generic_hpc_ops;
40887
40888 status = cpci_hp_register_controller(&generic_hpc);
40889 diff --git a/drivers/pci/hotplug/cpcihp_zt5550.c b/drivers/pci/hotplug/cpcihp_zt5550.c
40890 index 449b4bb..257e2e8 100644
40891 --- a/drivers/pci/hotplug/cpcihp_zt5550.c
40892 +++ b/drivers/pci/hotplug/cpcihp_zt5550.c
40893 @@ -59,7 +59,6 @@
40894 /* local variables */
40895 static bool debug;
40896 static bool poll;
40897 -static struct cpci_hp_controller_ops zt5550_hpc_ops;
40898 static struct cpci_hp_controller zt5550_hpc;
40899
40900 /* Primary cPCI bus bridge device */
40901 @@ -205,6 +204,10 @@ static int zt5550_hc_disable_irq(void)
40902 return 0;
40903 }
40904
40905 +static struct cpci_hp_controller_ops zt5550_hpc_ops = {
40906 + .query_enum = zt5550_hc_query_enum,
40907 +};
40908 +
40909 static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
40910 {
40911 int status;
40912 @@ -216,16 +219,17 @@ static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id
40913 dbg("returned from zt5550_hc_config");
40914
40915 memset(&zt5550_hpc, 0, sizeof (struct cpci_hp_controller));
40916 - zt5550_hpc_ops.query_enum = zt5550_hc_query_enum;
40917 zt5550_hpc.ops = &zt5550_hpc_ops;
40918 if(!poll) {
40919 zt5550_hpc.irq = hc_dev->irq;
40920 zt5550_hpc.irq_flags = IRQF_SHARED;
40921 zt5550_hpc.dev_id = hc_dev;
40922
40923 - zt5550_hpc_ops.enable_irq = zt5550_hc_enable_irq;
40924 - zt5550_hpc_ops.disable_irq = zt5550_hc_disable_irq;
40925 - zt5550_hpc_ops.check_irq = zt5550_hc_check_irq;
40926 + pax_open_kernel();
40927 + *(void **)&zt5550_hpc_ops.enable_irq = zt5550_hc_enable_irq;
40928 + *(void **)&zt5550_hpc_ops.disable_irq = zt5550_hc_disable_irq;
40929 + *(void **)&zt5550_hpc_ops.check_irq = zt5550_hc_check_irq;
40930 + pax_open_kernel();
40931 } else {
40932 info("using ENUM# polling mode");
40933 }
40934 diff --git a/drivers/pci/hotplug/cpqphp_nvram.c b/drivers/pci/hotplug/cpqphp_nvram.c
40935 index 76ba8a1..20ca857 100644
40936 --- a/drivers/pci/hotplug/cpqphp_nvram.c
40937 +++ b/drivers/pci/hotplug/cpqphp_nvram.c
40938 @@ -428,9 +428,13 @@ static u32 store_HRT (void __iomem *rom_start)
40939
40940 void compaq_nvram_init (void __iomem *rom_start)
40941 {
40942 +
40943 +#ifndef CONFIG_PAX_KERNEXEC
40944 if (rom_start) {
40945 compaq_int15_entry_point = (rom_start + ROM_INT15_PHY_ADDR - ROM_PHY_ADDR);
40946 }
40947 +#endif
40948 +
40949 dbg("int15 entry = %p\n", compaq_int15_entry_point);
40950
40951 /* initialize our int15 lock */
40952 diff --git a/drivers/pci/hotplug/pci_hotplug_core.c b/drivers/pci/hotplug/pci_hotplug_core.c
40953 index 202f4a9..8ee47d0 100644
40954 --- a/drivers/pci/hotplug/pci_hotplug_core.c
40955 +++ b/drivers/pci/hotplug/pci_hotplug_core.c
40956 @@ -448,8 +448,10 @@ int __pci_hp_register(struct hotplug_slot *slot, struct pci_bus *bus,
40957 return -EINVAL;
40958 }
40959
40960 - slot->ops->owner = owner;
40961 - slot->ops->mod_name = mod_name;
40962 + pax_open_kernel();
40963 + *(struct module **)&slot->ops->owner = owner;
40964 + *(const char **)&slot->ops->mod_name = mod_name;
40965 + pax_close_kernel();
40966
40967 mutex_lock(&pci_hp_mutex);
40968 /*
40969 diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c
40970 index 7d72c5e..edce02c 100644
40971 --- a/drivers/pci/hotplug/pciehp_core.c
40972 +++ b/drivers/pci/hotplug/pciehp_core.c
40973 @@ -91,7 +91,7 @@ static int init_slot(struct controller *ctrl)
40974 struct slot *slot = ctrl->slot;
40975 struct hotplug_slot *hotplug = NULL;
40976 struct hotplug_slot_info *info = NULL;
40977 - struct hotplug_slot_ops *ops = NULL;
40978 + hotplug_slot_ops_no_const *ops = NULL;
40979 char name[SLOT_NAME_SIZE];
40980 int retval = -ENOMEM;
40981
40982 diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
40983 index 9c6e9bb..2916736 100644
40984 --- a/drivers/pci/pci-sysfs.c
40985 +++ b/drivers/pci/pci-sysfs.c
40986 @@ -1071,7 +1071,7 @@ static int pci_create_attr(struct pci_dev *pdev, int num, int write_combine)
40987 {
40988 /* allocate attribute structure, piggyback attribute name */
40989 int name_len = write_combine ? 13 : 10;
40990 - struct bin_attribute *res_attr;
40991 + bin_attribute_no_const *res_attr;
40992 int retval;
40993
40994 res_attr = kzalloc(sizeof(*res_attr) + name_len, GFP_ATOMIC);
40995 @@ -1256,7 +1256,7 @@ static struct device_attribute reset_attr = __ATTR(reset, 0200, NULL, reset_stor
40996 static int pci_create_capabilities_sysfs(struct pci_dev *dev)
40997 {
40998 int retval;
40999 - struct bin_attribute *attr;
41000 + bin_attribute_no_const *attr;
41001
41002 /* If the device has VPD, try to expose it in sysfs. */
41003 if (dev->vpd) {
41004 @@ -1303,7 +1303,7 @@ int __must_check pci_create_sysfs_dev_files (struct pci_dev *pdev)
41005 {
41006 int retval;
41007 int rom_size = 0;
41008 - struct bin_attribute *attr;
41009 + bin_attribute_no_const *attr;
41010
41011 if (!sysfs_initialized)
41012 return -EACCES;
41013 diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
41014 index 7346ee6..41520eb 100644
41015 --- a/drivers/pci/pci.h
41016 +++ b/drivers/pci/pci.h
41017 @@ -93,7 +93,7 @@ struct pci_vpd_ops {
41018 struct pci_vpd {
41019 unsigned int len;
41020 const struct pci_vpd_ops *ops;
41021 - struct bin_attribute *attr; /* descriptor for sysfs VPD entry */
41022 + bin_attribute_no_const *attr; /* descriptor for sysfs VPD entry */
41023 };
41024
41025 extern int pci_vpd_pci22_init(struct pci_dev *dev);
41026 diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c
41027 index d320df6..ca9a8f6 100644
41028 --- a/drivers/pci/pcie/aspm.c
41029 +++ b/drivers/pci/pcie/aspm.c
41030 @@ -27,9 +27,9 @@
41031 #define MODULE_PARAM_PREFIX "pcie_aspm."
41032
41033 /* Note: those are not register definitions */
41034 -#define ASPM_STATE_L0S_UP (1) /* Upstream direction L0s state */
41035 -#define ASPM_STATE_L0S_DW (2) /* Downstream direction L0s state */
41036 -#define ASPM_STATE_L1 (4) /* L1 state */
41037 +#define ASPM_STATE_L0S_UP (1U) /* Upstream direction L0s state */
41038 +#define ASPM_STATE_L0S_DW (2U) /* Downstream direction L0s state */
41039 +#define ASPM_STATE_L1 (4U) /* L1 state */
41040 #define ASPM_STATE_L0S (ASPM_STATE_L0S_UP | ASPM_STATE_L0S_DW)
41041 #define ASPM_STATE_ALL (ASPM_STATE_L0S | ASPM_STATE_L1)
41042
41043 diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
41044 index 5427787..8df273b 100644
41045 --- a/drivers/pci/probe.c
41046 +++ b/drivers/pci/probe.c
41047 @@ -173,7 +173,7 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type,
41048 struct pci_bus_region region;
41049 bool bar_too_big = false, bar_disabled = false;
41050
41051 - mask = type ? PCI_ROM_ADDRESS_MASK : ~0;
41052 + mask = type ? (u32)PCI_ROM_ADDRESS_MASK : ~0;
41053
41054 /* No printks while decoding is disabled! */
41055 if (!dev->mmio_always_on) {
41056 diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c
41057 index 0b00947..64f7c0a 100644
41058 --- a/drivers/pci/proc.c
41059 +++ b/drivers/pci/proc.c
41060 @@ -465,7 +465,16 @@ static const struct file_operations proc_bus_pci_dev_operations = {
41061 static int __init pci_proc_init(void)
41062 {
41063 struct pci_dev *dev = NULL;
41064 +
41065 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
41066 +#ifdef CONFIG_GRKERNSEC_PROC_USER
41067 + proc_bus_pci_dir = proc_mkdir_mode("bus/pci", S_IRUSR | S_IXUSR, NULL);
41068 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
41069 + proc_bus_pci_dir = proc_mkdir_mode("bus/pci", S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP, NULL);
41070 +#endif
41071 +#else
41072 proc_bus_pci_dir = proc_mkdir("bus/pci", NULL);
41073 +#endif
41074 proc_create("devices", 0, proc_bus_pci_dir,
41075 &proc_bus_pci_dev_operations);
41076 proc_initialized = 1;
41077 diff --git a/drivers/platform/x86/chromeos_laptop.c b/drivers/platform/x86/chromeos_laptop.c
41078 index 3e5b4497..dcdfb70 100644
41079 --- a/drivers/platform/x86/chromeos_laptop.c
41080 +++ b/drivers/platform/x86/chromeos_laptop.c
41081 @@ -301,7 +301,7 @@ static int __init setup_tsl2563_als(const struct dmi_system_id *id)
41082 return 0;
41083 }
41084
41085 -static struct dmi_system_id __initdata chromeos_laptop_dmi_table[] = {
41086 +static struct dmi_system_id __initconst chromeos_laptop_dmi_table[] = {
41087 {
41088 .ident = "Samsung Series 5 550 - Touchpad",
41089 .matches = {
41090 diff --git a/drivers/platform/x86/msi-laptop.c b/drivers/platform/x86/msi-laptop.c
41091 index 6b22938..bc9700e 100644
41092 --- a/drivers/platform/x86/msi-laptop.c
41093 +++ b/drivers/platform/x86/msi-laptop.c
41094 @@ -1000,12 +1000,14 @@ static int __init load_scm_model_init(struct platform_device *sdev)
41095
41096 if (!quirks->ec_read_only) {
41097 /* allow userland write sysfs file */
41098 - dev_attr_bluetooth.store = store_bluetooth;
41099 - dev_attr_wlan.store = store_wlan;
41100 - dev_attr_threeg.store = store_threeg;
41101 - dev_attr_bluetooth.attr.mode |= S_IWUSR;
41102 - dev_attr_wlan.attr.mode |= S_IWUSR;
41103 - dev_attr_threeg.attr.mode |= S_IWUSR;
41104 + pax_open_kernel();
41105 + *(void **)&dev_attr_bluetooth.store = store_bluetooth;
41106 + *(void **)&dev_attr_wlan.store = store_wlan;
41107 + *(void **)&dev_attr_threeg.store = store_threeg;
41108 + *(umode_t *)&dev_attr_bluetooth.attr.mode |= S_IWUSR;
41109 + *(umode_t *)&dev_attr_wlan.attr.mode |= S_IWUSR;
41110 + *(umode_t *)&dev_attr_threeg.attr.mode |= S_IWUSR;
41111 + pax_close_kernel();
41112 }
41113
41114 /* disable hardware control by fn key */
41115 diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
41116 index 14d4dce..b129917 100644
41117 --- a/drivers/platform/x86/sony-laptop.c
41118 +++ b/drivers/platform/x86/sony-laptop.c
41119 @@ -2465,7 +2465,7 @@ static void sony_nc_gfx_switch_cleanup(struct platform_device *pd)
41120 }
41121
41122 /* High speed charging function */
41123 -static struct device_attribute *hsc_handle;
41124 +static device_attribute_no_const *hsc_handle;
41125
41126 static ssize_t sony_nc_highspeed_charging_store(struct device *dev,
41127 struct device_attribute *attr,
41128 diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
41129 index edec135..59a24a3 100644
41130 --- a/drivers/platform/x86/thinkpad_acpi.c
41131 +++ b/drivers/platform/x86/thinkpad_acpi.c
41132 @@ -2093,7 +2093,7 @@ static int hotkey_mask_get(void)
41133 return 0;
41134 }
41135
41136 -void static hotkey_mask_warn_incomplete_mask(void)
41137 +static void hotkey_mask_warn_incomplete_mask(void)
41138 {
41139 /* log only what the user can fix... */
41140 const u32 wantedmask = hotkey_driver_mask &
41141 @@ -2324,11 +2324,6 @@ static void hotkey_read_nvram(struct tp_nvram_state *n, const u32 m)
41142 }
41143 }
41144
41145 -static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41146 - struct tp_nvram_state *newn,
41147 - const u32 event_mask)
41148 -{
41149 -
41150 #define TPACPI_COMPARE_KEY(__scancode, __member) \
41151 do { \
41152 if ((event_mask & (1 << __scancode)) && \
41153 @@ -2342,36 +2337,42 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41154 tpacpi_hotkey_send_key(__scancode); \
41155 } while (0)
41156
41157 - void issue_volchange(const unsigned int oldvol,
41158 - const unsigned int newvol)
41159 - {
41160 - unsigned int i = oldvol;
41161 +static void issue_volchange(const unsigned int oldvol,
41162 + const unsigned int newvol,
41163 + const u32 event_mask)
41164 +{
41165 + unsigned int i = oldvol;
41166
41167 - while (i > newvol) {
41168 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEDOWN);
41169 - i--;
41170 - }
41171 - while (i < newvol) {
41172 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
41173 - i++;
41174 - }
41175 + while (i > newvol) {
41176 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEDOWN);
41177 + i--;
41178 }
41179 + while (i < newvol) {
41180 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
41181 + i++;
41182 + }
41183 +}
41184
41185 - void issue_brightnesschange(const unsigned int oldbrt,
41186 - const unsigned int newbrt)
41187 - {
41188 - unsigned int i = oldbrt;
41189 +static void issue_brightnesschange(const unsigned int oldbrt,
41190 + const unsigned int newbrt,
41191 + const u32 event_mask)
41192 +{
41193 + unsigned int i = oldbrt;
41194
41195 - while (i > newbrt) {
41196 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNEND);
41197 - i--;
41198 - }
41199 - while (i < newbrt) {
41200 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
41201 - i++;
41202 - }
41203 + while (i > newbrt) {
41204 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNEND);
41205 + i--;
41206 + }
41207 + while (i < newbrt) {
41208 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
41209 + i++;
41210 }
41211 +}
41212
41213 +static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41214 + struct tp_nvram_state *newn,
41215 + const u32 event_mask)
41216 +{
41217 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_THINKPAD, thinkpad_toggle);
41218 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNSPACE, zoom_toggle);
41219 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNF7, display_toggle);
41220 @@ -2405,7 +2406,7 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41221 oldn->volume_level != newn->volume_level) {
41222 /* recently muted, or repeated mute keypress, or
41223 * multiple presses ending in mute */
41224 - issue_volchange(oldn->volume_level, newn->volume_level);
41225 + issue_volchange(oldn->volume_level, newn->volume_level, event_mask);
41226 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_MUTE);
41227 }
41228 } else {
41229 @@ -2415,7 +2416,7 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41230 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
41231 }
41232 if (oldn->volume_level != newn->volume_level) {
41233 - issue_volchange(oldn->volume_level, newn->volume_level);
41234 + issue_volchange(oldn->volume_level, newn->volume_level, event_mask);
41235 } else if (oldn->volume_toggle != newn->volume_toggle) {
41236 /* repeated vol up/down keypress at end of scale ? */
41237 if (newn->volume_level == 0)
41238 @@ -2428,7 +2429,8 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41239 /* handle brightness */
41240 if (oldn->brightness_level != newn->brightness_level) {
41241 issue_brightnesschange(oldn->brightness_level,
41242 - newn->brightness_level);
41243 + newn->brightness_level,
41244 + event_mask);
41245 } else if (oldn->brightness_toggle != newn->brightness_toggle) {
41246 /* repeated key presses that didn't change state */
41247 if (newn->brightness_level == 0)
41248 @@ -2437,10 +2439,10 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41249 && !tp_features.bright_unkfw)
41250 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
41251 }
41252 +}
41253
41254 #undef TPACPI_COMPARE_KEY
41255 #undef TPACPI_MAY_SEND_KEY
41256 -}
41257
41258 /*
41259 * Polling driver
41260 diff --git a/drivers/pnp/pnpbios/bioscalls.c b/drivers/pnp/pnpbios/bioscalls.c
41261 index 769d265..a3a05ca 100644
41262 --- a/drivers/pnp/pnpbios/bioscalls.c
41263 +++ b/drivers/pnp/pnpbios/bioscalls.c
41264 @@ -58,7 +58,7 @@ do { \
41265 set_desc_limit(&gdt[(selname) >> 3], (size) - 1); \
41266 } while(0)
41267
41268 -static struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4092,
41269 +static const struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4093,
41270 (unsigned long)__va(0x400UL), PAGE_SIZE - 0x400 - 1);
41271
41272 /*
41273 @@ -95,7 +95,10 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
41274
41275 cpu = get_cpu();
41276 save_desc_40 = get_cpu_gdt_table(cpu)[0x40 / 8];
41277 +
41278 + pax_open_kernel();
41279 get_cpu_gdt_table(cpu)[0x40 / 8] = bad_bios_desc;
41280 + pax_close_kernel();
41281
41282 /* On some boxes IRQ's during PnP BIOS calls are deadly. */
41283 spin_lock_irqsave(&pnp_bios_lock, flags);
41284 @@ -133,7 +136,10 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
41285 :"memory");
41286 spin_unlock_irqrestore(&pnp_bios_lock, flags);
41287
41288 + pax_open_kernel();
41289 get_cpu_gdt_table(cpu)[0x40 / 8] = save_desc_40;
41290 + pax_close_kernel();
41291 +
41292 put_cpu();
41293
41294 /* If we get here and this is set then the PnP BIOS faulted on us. */
41295 @@ -467,7 +473,7 @@ int pnp_bios_read_escd(char *data, u32 nvram_base)
41296 return status;
41297 }
41298
41299 -void pnpbios_calls_init(union pnp_bios_install_struct *header)
41300 +void __init pnpbios_calls_init(union pnp_bios_install_struct *header)
41301 {
41302 int i;
41303
41304 @@ -475,6 +481,8 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header)
41305 pnp_bios_callpoint.offset = header->fields.pm16offset;
41306 pnp_bios_callpoint.segment = PNP_CS16;
41307
41308 + pax_open_kernel();
41309 +
41310 for_each_possible_cpu(i) {
41311 struct desc_struct *gdt = get_cpu_gdt_table(i);
41312 if (!gdt)
41313 @@ -486,4 +494,6 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header)
41314 set_desc_base(&gdt[GDT_ENTRY_PNPBIOS_DS],
41315 (unsigned long)__va(header->fields.pm16dseg));
41316 }
41317 +
41318 + pax_close_kernel();
41319 }
41320 diff --git a/drivers/pnp/resource.c b/drivers/pnp/resource.c
41321 index 3e6db1c..1fbbdae 100644
41322 --- a/drivers/pnp/resource.c
41323 +++ b/drivers/pnp/resource.c
41324 @@ -360,7 +360,7 @@ int pnp_check_irq(struct pnp_dev *dev, struct resource *res)
41325 return 1;
41326
41327 /* check if the resource is valid */
41328 - if (*irq < 0 || *irq > 15)
41329 + if (*irq > 15)
41330 return 0;
41331
41332 /* check if the resource is reserved */
41333 @@ -424,7 +424,7 @@ int pnp_check_dma(struct pnp_dev *dev, struct resource *res)
41334 return 1;
41335
41336 /* check if the resource is valid */
41337 - if (*dma < 0 || *dma == 4 || *dma > 7)
41338 + if (*dma == 4 || *dma > 7)
41339 return 0;
41340
41341 /* check if the resource is reserved */
41342 diff --git a/drivers/power/pda_power.c b/drivers/power/pda_power.c
41343 index 7df7c5f..bd48c47 100644
41344 --- a/drivers/power/pda_power.c
41345 +++ b/drivers/power/pda_power.c
41346 @@ -37,7 +37,11 @@ static int polling;
41347
41348 #ifdef CONFIG_USB_OTG_UTILS
41349 static struct usb_phy *transceiver;
41350 -static struct notifier_block otg_nb;
41351 +static int otg_handle_notification(struct notifier_block *nb,
41352 + unsigned long event, void *unused);
41353 +static struct notifier_block otg_nb = {
41354 + .notifier_call = otg_handle_notification
41355 +};
41356 #endif
41357
41358 static struct regulator *ac_draw;
41359 @@ -369,7 +373,6 @@ static int pda_power_probe(struct platform_device *pdev)
41360
41361 #ifdef CONFIG_USB_OTG_UTILS
41362 if (!IS_ERR_OR_NULL(transceiver) && pdata->use_otg_notifier) {
41363 - otg_nb.notifier_call = otg_handle_notification;
41364 ret = usb_register_notifier(transceiver, &otg_nb);
41365 if (ret) {
41366 dev_err(dev, "failure to register otg notifier\n");
41367 diff --git a/drivers/power/power_supply.h b/drivers/power/power_supply.h
41368 index cc439fd..8fa30df 100644
41369 --- a/drivers/power/power_supply.h
41370 +++ b/drivers/power/power_supply.h
41371 @@ -16,12 +16,12 @@ struct power_supply;
41372
41373 #ifdef CONFIG_SYSFS
41374
41375 -extern void power_supply_init_attrs(struct device_type *dev_type);
41376 +extern void power_supply_init_attrs(void);
41377 extern int power_supply_uevent(struct device *dev, struct kobj_uevent_env *env);
41378
41379 #else
41380
41381 -static inline void power_supply_init_attrs(struct device_type *dev_type) {}
41382 +static inline void power_supply_init_attrs(void) {}
41383 #define power_supply_uevent NULL
41384
41385 #endif /* CONFIG_SYSFS */
41386 diff --git a/drivers/power/power_supply_core.c b/drivers/power/power_supply_core.c
41387 index 5deac43..608c5ff 100644
41388 --- a/drivers/power/power_supply_core.c
41389 +++ b/drivers/power/power_supply_core.c
41390 @@ -24,7 +24,10 @@
41391 struct class *power_supply_class;
41392 EXPORT_SYMBOL_GPL(power_supply_class);
41393
41394 -static struct device_type power_supply_dev_type;
41395 +extern const struct attribute_group *power_supply_attr_groups[];
41396 +static struct device_type power_supply_dev_type = {
41397 + .groups = power_supply_attr_groups,
41398 +};
41399
41400 static int __power_supply_changed_work(struct device *dev, void *data)
41401 {
41402 @@ -393,7 +396,7 @@ static int __init power_supply_class_init(void)
41403 return PTR_ERR(power_supply_class);
41404
41405 power_supply_class->dev_uevent = power_supply_uevent;
41406 - power_supply_init_attrs(&power_supply_dev_type);
41407 + power_supply_init_attrs();
41408
41409 return 0;
41410 }
41411 diff --git a/drivers/power/power_supply_sysfs.c b/drivers/power/power_supply_sysfs.c
41412 index 29178f7..c65f324 100644
41413 --- a/drivers/power/power_supply_sysfs.c
41414 +++ b/drivers/power/power_supply_sysfs.c
41415 @@ -230,17 +230,15 @@ static struct attribute_group power_supply_attr_group = {
41416 .is_visible = power_supply_attr_is_visible,
41417 };
41418
41419 -static const struct attribute_group *power_supply_attr_groups[] = {
41420 +const struct attribute_group *power_supply_attr_groups[] = {
41421 &power_supply_attr_group,
41422 NULL,
41423 };
41424
41425 -void power_supply_init_attrs(struct device_type *dev_type)
41426 +void power_supply_init_attrs(void)
41427 {
41428 int i;
41429
41430 - dev_type->groups = power_supply_attr_groups;
41431 -
41432 for (i = 0; i < ARRAY_SIZE(power_supply_attrs); i++)
41433 __power_supply_attrs[i] = &power_supply_attrs[i].attr;
41434 }
41435 diff --git a/drivers/regulator/max8660.c b/drivers/regulator/max8660.c
41436 index 4d7c635..9860196 100644
41437 --- a/drivers/regulator/max8660.c
41438 +++ b/drivers/regulator/max8660.c
41439 @@ -333,8 +333,10 @@ static int max8660_probe(struct i2c_client *client,
41440 max8660->shadow_regs[MAX8660_OVER1] = 5;
41441 } else {
41442 /* Otherwise devices can be toggled via software */
41443 - max8660_dcdc_ops.enable = max8660_dcdc_enable;
41444 - max8660_dcdc_ops.disable = max8660_dcdc_disable;
41445 + pax_open_kernel();
41446 + *(void **)&max8660_dcdc_ops.enable = max8660_dcdc_enable;
41447 + *(void **)&max8660_dcdc_ops.disable = max8660_dcdc_disable;
41448 + pax_close_kernel();
41449 }
41450
41451 /*
41452 diff --git a/drivers/regulator/max8973-regulator.c b/drivers/regulator/max8973-regulator.c
41453 index 9a8ea91..c483dd9 100644
41454 --- a/drivers/regulator/max8973-regulator.c
41455 +++ b/drivers/regulator/max8973-regulator.c
41456 @@ -401,9 +401,11 @@ static int max8973_probe(struct i2c_client *client,
41457 if (!pdata->enable_ext_control) {
41458 max->desc.enable_reg = MAX8973_VOUT;
41459 max->desc.enable_mask = MAX8973_VOUT_ENABLE;
41460 - max8973_dcdc_ops.enable = regulator_enable_regmap;
41461 - max8973_dcdc_ops.disable = regulator_disable_regmap;
41462 - max8973_dcdc_ops.is_enabled = regulator_is_enabled_regmap;
41463 + pax_open_kernel();
41464 + *(void **)&max8973_dcdc_ops.enable = regulator_enable_regmap;
41465 + *(void **)&max8973_dcdc_ops.disable = regulator_disable_regmap;
41466 + *(void **)&max8973_dcdc_ops.is_enabled = regulator_is_enabled_regmap;
41467 + pax_close_kernel();
41468 }
41469
41470 max->enable_external_control = pdata->enable_ext_control;
41471 diff --git a/drivers/regulator/mc13892-regulator.c b/drivers/regulator/mc13892-regulator.c
41472 index 9891aec..beb3083 100644
41473 --- a/drivers/regulator/mc13892-regulator.c
41474 +++ b/drivers/regulator/mc13892-regulator.c
41475 @@ -583,10 +583,12 @@ static int mc13892_regulator_probe(struct platform_device *pdev)
41476 }
41477 mc13xxx_unlock(mc13892);
41478
41479 - mc13892_regulators[MC13892_VCAM].desc.ops->set_mode
41480 + pax_open_kernel();
41481 + *(void **)&mc13892_regulators[MC13892_VCAM].desc.ops->set_mode
41482 = mc13892_vcam_set_mode;
41483 - mc13892_regulators[MC13892_VCAM].desc.ops->get_mode
41484 + *(void **)&mc13892_regulators[MC13892_VCAM].desc.ops->get_mode
41485 = mc13892_vcam_get_mode;
41486 + pax_close_kernel();
41487
41488 mc13xxx_data = mc13xxx_parse_regulators_dt(pdev, mc13892_regulators,
41489 ARRAY_SIZE(mc13892_regulators),
41490 diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c
41491 index cc5bea9..689f7d9 100644
41492 --- a/drivers/rtc/rtc-cmos.c
41493 +++ b/drivers/rtc/rtc-cmos.c
41494 @@ -724,7 +724,9 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq)
41495 hpet_rtc_timer_init();
41496
41497 /* export at least the first block of NVRAM */
41498 - nvram.size = address_space - NVRAM_OFFSET;
41499 + pax_open_kernel();
41500 + *(size_t *)&nvram.size = address_space - NVRAM_OFFSET;
41501 + pax_close_kernel();
41502 retval = sysfs_create_bin_file(&dev->kobj, &nvram);
41503 if (retval < 0) {
41504 dev_dbg(dev, "can't create nvram file? %d\n", retval);
41505 diff --git a/drivers/rtc/rtc-dev.c b/drivers/rtc/rtc-dev.c
41506 index d049393..bb20be0 100644
41507 --- a/drivers/rtc/rtc-dev.c
41508 +++ b/drivers/rtc/rtc-dev.c
41509 @@ -16,6 +16,7 @@
41510 #include <linux/module.h>
41511 #include <linux/rtc.h>
41512 #include <linux/sched.h>
41513 +#include <linux/grsecurity.h>
41514 #include "rtc-core.h"
41515
41516 static dev_t rtc_devt;
41517 @@ -347,6 +348,8 @@ static long rtc_dev_ioctl(struct file *file,
41518 if (copy_from_user(&tm, uarg, sizeof(tm)))
41519 return -EFAULT;
41520
41521 + gr_log_timechange();
41522 +
41523 return rtc_set_time(rtc, &tm);
41524
41525 case RTC_PIE_ON:
41526 diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
41527 index 970a236..3613169 100644
41528 --- a/drivers/rtc/rtc-ds1307.c
41529 +++ b/drivers/rtc/rtc-ds1307.c
41530 @@ -106,7 +106,7 @@ struct ds1307 {
41531 u8 offset; /* register's offset */
41532 u8 regs[11];
41533 u16 nvram_offset;
41534 - struct bin_attribute *nvram;
41535 + bin_attribute_no_const *nvram;
41536 enum ds_type type;
41537 unsigned long flags;
41538 #define HAS_NVRAM 0 /* bit 0 == sysfs file active */
41539 diff --git a/drivers/rtc/rtc-m48t59.c b/drivers/rtc/rtc-m48t59.c
41540 index 130f29a..6179d03 100644
41541 --- a/drivers/rtc/rtc-m48t59.c
41542 +++ b/drivers/rtc/rtc-m48t59.c
41543 @@ -482,7 +482,9 @@ static int m48t59_rtc_probe(struct platform_device *pdev)
41544 goto out;
41545 }
41546
41547 - m48t59_nvram_attr.size = pdata->offset;
41548 + pax_open_kernel();
41549 + *(size_t *)&m48t59_nvram_attr.size = pdata->offset;
41550 + pax_close_kernel();
41551
41552 ret = sysfs_create_bin_file(&pdev->dev.kobj, &m48t59_nvram_attr);
41553 if (ret) {
41554 diff --git a/drivers/scsi/bfa/bfa_fcpim.h b/drivers/scsi/bfa/bfa_fcpim.h
41555 index e693af6..2e525b6 100644
41556 --- a/drivers/scsi/bfa/bfa_fcpim.h
41557 +++ b/drivers/scsi/bfa/bfa_fcpim.h
41558 @@ -36,7 +36,7 @@ struct bfa_iotag_s {
41559
41560 struct bfa_itn_s {
41561 bfa_isr_func_t isr;
41562 -};
41563 +} __no_const;
41564
41565 void bfa_itn_create(struct bfa_s *bfa, struct bfa_rport_s *rport,
41566 void (*isr)(struct bfa_s *bfa, struct bfi_msg_s *m));
41567 diff --git a/drivers/scsi/bfa/bfa_ioc.h b/drivers/scsi/bfa/bfa_ioc.h
41568 index 23a90e7..9cf04ee 100644
41569 --- a/drivers/scsi/bfa/bfa_ioc.h
41570 +++ b/drivers/scsi/bfa/bfa_ioc.h
41571 @@ -258,7 +258,7 @@ struct bfa_ioc_cbfn_s {
41572 bfa_ioc_disable_cbfn_t disable_cbfn;
41573 bfa_ioc_hbfail_cbfn_t hbfail_cbfn;
41574 bfa_ioc_reset_cbfn_t reset_cbfn;
41575 -};
41576 +} __no_const;
41577
41578 /*
41579 * IOC event notification mechanism.
41580 @@ -346,7 +346,7 @@ struct bfa_ioc_hwif_s {
41581 void (*ioc_sync_ack) (struct bfa_ioc_s *ioc);
41582 bfa_boolean_t (*ioc_sync_complete) (struct bfa_ioc_s *ioc);
41583 bfa_boolean_t (*ioc_lpu_read_stat) (struct bfa_ioc_s *ioc);
41584 -};
41585 +} __no_const;
41586
41587 /*
41588 * Queue element to wait for room in request queue. FIFO order is
41589 diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
41590 index df0c3c7..b00e1d0 100644
41591 --- a/drivers/scsi/hosts.c
41592 +++ b/drivers/scsi/hosts.c
41593 @@ -42,7 +42,7 @@
41594 #include "scsi_logging.h"
41595
41596
41597 -static atomic_t scsi_host_next_hn = ATOMIC_INIT(0); /* host_no for next new host */
41598 +static atomic_unchecked_t scsi_host_next_hn = ATOMIC_INIT(0); /* host_no for next new host */
41599
41600
41601 static void scsi_host_cls_release(struct device *dev)
41602 @@ -361,7 +361,7 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize)
41603 * subtract one because we increment first then return, but we need to
41604 * know what the next host number was before increment
41605 */
41606 - shost->host_no = atomic_inc_return(&scsi_host_next_hn) - 1;
41607 + shost->host_no = atomic_inc_return_unchecked(&scsi_host_next_hn) - 1;
41608 shost->dma_channel = 0xff;
41609
41610 /* These three are default values which can be overridden */
41611 diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
41612 index 7f4f790..b75b92a 100644
41613 --- a/drivers/scsi/hpsa.c
41614 +++ b/drivers/scsi/hpsa.c
41615 @@ -554,7 +554,7 @@ static inline u32 next_command(struct ctlr_info *h, u8 q)
41616 unsigned long flags;
41617
41618 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant)))
41619 - return h->access.command_completed(h, q);
41620 + return h->access->command_completed(h, q);
41621
41622 if ((rq->head[rq->current_entry] & 1) == rq->wraparound) {
41623 a = rq->head[rq->current_entry];
41624 @@ -3422,7 +3422,7 @@ static void start_io(struct ctlr_info *h)
41625 while (!list_empty(&h->reqQ)) {
41626 c = list_entry(h->reqQ.next, struct CommandList, list);
41627 /* can't do anything if fifo is full */
41628 - if ((h->access.fifo_full(h))) {
41629 + if ((h->access->fifo_full(h))) {
41630 dev_warn(&h->pdev->dev, "fifo full\n");
41631 break;
41632 }
41633 @@ -3444,7 +3444,7 @@ static void start_io(struct ctlr_info *h)
41634
41635 /* Tell the controller execute command */
41636 spin_unlock_irqrestore(&h->lock, flags);
41637 - h->access.submit_command(h, c);
41638 + h->access->submit_command(h, c);
41639 spin_lock_irqsave(&h->lock, flags);
41640 }
41641 spin_unlock_irqrestore(&h->lock, flags);
41642 @@ -3452,17 +3452,17 @@ static void start_io(struct ctlr_info *h)
41643
41644 static inline unsigned long get_next_completion(struct ctlr_info *h, u8 q)
41645 {
41646 - return h->access.command_completed(h, q);
41647 + return h->access->command_completed(h, q);
41648 }
41649
41650 static inline bool interrupt_pending(struct ctlr_info *h)
41651 {
41652 - return h->access.intr_pending(h);
41653 + return h->access->intr_pending(h);
41654 }
41655
41656 static inline long interrupt_not_for_us(struct ctlr_info *h)
41657 {
41658 - return (h->access.intr_pending(h) == 0) ||
41659 + return (h->access->intr_pending(h) == 0) ||
41660 (h->interrupts_enabled == 0);
41661 }
41662
41663 @@ -4364,7 +4364,7 @@ static int hpsa_pci_init(struct ctlr_info *h)
41664 if (prod_index < 0)
41665 return -ENODEV;
41666 h->product_name = products[prod_index].product_name;
41667 - h->access = *(products[prod_index].access);
41668 + h->access = products[prod_index].access;
41669
41670 pci_disable_link_state(h->pdev, PCIE_LINK_STATE_L0S |
41671 PCIE_LINK_STATE_L1 | PCIE_LINK_STATE_CLKPM);
41672 @@ -4646,7 +4646,7 @@ static void controller_lockup_detected(struct ctlr_info *h)
41673
41674 assert_spin_locked(&lockup_detector_lock);
41675 remove_ctlr_from_lockup_detector_list(h);
41676 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
41677 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
41678 spin_lock_irqsave(&h->lock, flags);
41679 h->lockup_detected = readl(h->vaddr + SA5_SCRATCHPAD_OFFSET);
41680 spin_unlock_irqrestore(&h->lock, flags);
41681 @@ -4823,7 +4823,7 @@ reinit_after_soft_reset:
41682 }
41683
41684 /* make sure the board interrupts are off */
41685 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
41686 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
41687
41688 if (hpsa_request_irq(h, do_hpsa_intr_msi, do_hpsa_intr_intx))
41689 goto clean2;
41690 @@ -4857,7 +4857,7 @@ reinit_after_soft_reset:
41691 * fake ones to scoop up any residual completions.
41692 */
41693 spin_lock_irqsave(&h->lock, flags);
41694 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
41695 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
41696 spin_unlock_irqrestore(&h->lock, flags);
41697 free_irqs(h);
41698 rc = hpsa_request_irq(h, hpsa_msix_discard_completions,
41699 @@ -4876,9 +4876,9 @@ reinit_after_soft_reset:
41700 dev_info(&h->pdev->dev, "Board READY.\n");
41701 dev_info(&h->pdev->dev,
41702 "Waiting for stale completions to drain.\n");
41703 - h->access.set_intr_mask(h, HPSA_INTR_ON);
41704 + h->access->set_intr_mask(h, HPSA_INTR_ON);
41705 msleep(10000);
41706 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
41707 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
41708
41709 rc = controller_reset_failed(h->cfgtable);
41710 if (rc)
41711 @@ -4899,7 +4899,7 @@ reinit_after_soft_reset:
41712 }
41713
41714 /* Turn the interrupts on so we can service requests */
41715 - h->access.set_intr_mask(h, HPSA_INTR_ON);
41716 + h->access->set_intr_mask(h, HPSA_INTR_ON);
41717
41718 hpsa_hba_inquiry(h);
41719 hpsa_register_scsi(h); /* hook ourselves into SCSI subsystem */
41720 @@ -4954,7 +4954,7 @@ static void hpsa_shutdown(struct pci_dev *pdev)
41721 * To write all data in the battery backed cache to disks
41722 */
41723 hpsa_flush_cache(h);
41724 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
41725 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
41726 hpsa_free_irqs_and_disable_msix(h);
41727 }
41728
41729 @@ -5122,7 +5122,7 @@ static void hpsa_enter_performant_mode(struct ctlr_info *h, u32 use_short_tags)
41730 return;
41731 }
41732 /* Change the access methods to the performant access methods */
41733 - h->access = SA5_performant_access;
41734 + h->access = &SA5_performant_access;
41735 h->transMethod = CFGTBL_Trans_Performant;
41736 }
41737
41738 diff --git a/drivers/scsi/hpsa.h b/drivers/scsi/hpsa.h
41739 index 9816479..c5d4e97 100644
41740 --- a/drivers/scsi/hpsa.h
41741 +++ b/drivers/scsi/hpsa.h
41742 @@ -79,7 +79,7 @@ struct ctlr_info {
41743 unsigned int msix_vector;
41744 unsigned int msi_vector;
41745 int intr_mode; /* either PERF_MODE_INT or SIMPLE_MODE_INT */
41746 - struct access_method access;
41747 + struct access_method *access;
41748
41749 /* queue and queue Info */
41750 struct list_head reqQ;
41751 diff --git a/drivers/scsi/libfc/fc_exch.c b/drivers/scsi/libfc/fc_exch.c
41752 index c772d8d..35c362c 100644
41753 --- a/drivers/scsi/libfc/fc_exch.c
41754 +++ b/drivers/scsi/libfc/fc_exch.c
41755 @@ -100,12 +100,12 @@ struct fc_exch_mgr {
41756 u16 pool_max_index;
41757
41758 struct {
41759 - atomic_t no_free_exch;
41760 - atomic_t no_free_exch_xid;
41761 - atomic_t xid_not_found;
41762 - atomic_t xid_busy;
41763 - atomic_t seq_not_found;
41764 - atomic_t non_bls_resp;
41765 + atomic_unchecked_t no_free_exch;
41766 + atomic_unchecked_t no_free_exch_xid;
41767 + atomic_unchecked_t xid_not_found;
41768 + atomic_unchecked_t xid_busy;
41769 + atomic_unchecked_t seq_not_found;
41770 + atomic_unchecked_t non_bls_resp;
41771 } stats;
41772 };
41773
41774 @@ -725,7 +725,7 @@ static struct fc_exch *fc_exch_em_alloc(struct fc_lport *lport,
41775 /* allocate memory for exchange */
41776 ep = mempool_alloc(mp->ep_pool, GFP_ATOMIC);
41777 if (!ep) {
41778 - atomic_inc(&mp->stats.no_free_exch);
41779 + atomic_inc_unchecked(&mp->stats.no_free_exch);
41780 goto out;
41781 }
41782 memset(ep, 0, sizeof(*ep));
41783 @@ -786,7 +786,7 @@ out:
41784 return ep;
41785 err:
41786 spin_unlock_bh(&pool->lock);
41787 - atomic_inc(&mp->stats.no_free_exch_xid);
41788 + atomic_inc_unchecked(&mp->stats.no_free_exch_xid);
41789 mempool_free(ep, mp->ep_pool);
41790 return NULL;
41791 }
41792 @@ -929,7 +929,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
41793 xid = ntohs(fh->fh_ox_id); /* we originated exch */
41794 ep = fc_exch_find(mp, xid);
41795 if (!ep) {
41796 - atomic_inc(&mp->stats.xid_not_found);
41797 + atomic_inc_unchecked(&mp->stats.xid_not_found);
41798 reject = FC_RJT_OX_ID;
41799 goto out;
41800 }
41801 @@ -959,7 +959,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
41802 ep = fc_exch_find(mp, xid);
41803 if ((f_ctl & FC_FC_FIRST_SEQ) && fc_sof_is_init(fr_sof(fp))) {
41804 if (ep) {
41805 - atomic_inc(&mp->stats.xid_busy);
41806 + atomic_inc_unchecked(&mp->stats.xid_busy);
41807 reject = FC_RJT_RX_ID;
41808 goto rel;
41809 }
41810 @@ -970,7 +970,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
41811 }
41812 xid = ep->xid; /* get our XID */
41813 } else if (!ep) {
41814 - atomic_inc(&mp->stats.xid_not_found);
41815 + atomic_inc_unchecked(&mp->stats.xid_not_found);
41816 reject = FC_RJT_RX_ID; /* XID not found */
41817 goto out;
41818 }
41819 @@ -987,7 +987,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
41820 } else {
41821 sp = &ep->seq;
41822 if (sp->id != fh->fh_seq_id) {
41823 - atomic_inc(&mp->stats.seq_not_found);
41824 + atomic_inc_unchecked(&mp->stats.seq_not_found);
41825 if (f_ctl & FC_FC_END_SEQ) {
41826 /*
41827 * Update sequence_id based on incoming last
41828 @@ -1437,22 +1437,22 @@ static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
41829
41830 ep = fc_exch_find(mp, ntohs(fh->fh_ox_id));
41831 if (!ep) {
41832 - atomic_inc(&mp->stats.xid_not_found);
41833 + atomic_inc_unchecked(&mp->stats.xid_not_found);
41834 goto out;
41835 }
41836 if (ep->esb_stat & ESB_ST_COMPLETE) {
41837 - atomic_inc(&mp->stats.xid_not_found);
41838 + atomic_inc_unchecked(&mp->stats.xid_not_found);
41839 goto rel;
41840 }
41841 if (ep->rxid == FC_XID_UNKNOWN)
41842 ep->rxid = ntohs(fh->fh_rx_id);
41843 if (ep->sid != 0 && ep->sid != ntoh24(fh->fh_d_id)) {
41844 - atomic_inc(&mp->stats.xid_not_found);
41845 + atomic_inc_unchecked(&mp->stats.xid_not_found);
41846 goto rel;
41847 }
41848 if (ep->did != ntoh24(fh->fh_s_id) &&
41849 ep->did != FC_FID_FLOGI) {
41850 - atomic_inc(&mp->stats.xid_not_found);
41851 + atomic_inc_unchecked(&mp->stats.xid_not_found);
41852 goto rel;
41853 }
41854 sof = fr_sof(fp);
41855 @@ -1461,7 +1461,7 @@ static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
41856 sp->ssb_stat |= SSB_ST_RESP;
41857 sp->id = fh->fh_seq_id;
41858 } else if (sp->id != fh->fh_seq_id) {
41859 - atomic_inc(&mp->stats.seq_not_found);
41860 + atomic_inc_unchecked(&mp->stats.seq_not_found);
41861 goto rel;
41862 }
41863
41864 @@ -1525,9 +1525,9 @@ static void fc_exch_recv_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
41865 sp = fc_seq_lookup_orig(mp, fp); /* doesn't hold sequence */
41866
41867 if (!sp)
41868 - atomic_inc(&mp->stats.xid_not_found);
41869 + atomic_inc_unchecked(&mp->stats.xid_not_found);
41870 else
41871 - atomic_inc(&mp->stats.non_bls_resp);
41872 + atomic_inc_unchecked(&mp->stats.non_bls_resp);
41873
41874 fc_frame_free(fp);
41875 }
41876 @@ -2174,13 +2174,13 @@ void fc_exch_update_stats(struct fc_lport *lport)
41877
41878 list_for_each_entry(ema, &lport->ema_list, ema_list) {
41879 mp = ema->mp;
41880 - st->fc_no_free_exch += atomic_read(&mp->stats.no_free_exch);
41881 + st->fc_no_free_exch += atomic_read_unchecked(&mp->stats.no_free_exch);
41882 st->fc_no_free_exch_xid +=
41883 - atomic_read(&mp->stats.no_free_exch_xid);
41884 - st->fc_xid_not_found += atomic_read(&mp->stats.xid_not_found);
41885 - st->fc_xid_busy += atomic_read(&mp->stats.xid_busy);
41886 - st->fc_seq_not_found += atomic_read(&mp->stats.seq_not_found);
41887 - st->fc_non_bls_resp += atomic_read(&mp->stats.non_bls_resp);
41888 + atomic_read_unchecked(&mp->stats.no_free_exch_xid);
41889 + st->fc_xid_not_found += atomic_read_unchecked(&mp->stats.xid_not_found);
41890 + st->fc_xid_busy += atomic_read_unchecked(&mp->stats.xid_busy);
41891 + st->fc_seq_not_found += atomic_read_unchecked(&mp->stats.seq_not_found);
41892 + st->fc_non_bls_resp += atomic_read_unchecked(&mp->stats.non_bls_resp);
41893 }
41894 }
41895 EXPORT_SYMBOL(fc_exch_update_stats);
41896 diff --git a/drivers/scsi/libsas/sas_ata.c b/drivers/scsi/libsas/sas_ata.c
41897 index bdb81cd..d3c7c2c 100644
41898 --- a/drivers/scsi/libsas/sas_ata.c
41899 +++ b/drivers/scsi/libsas/sas_ata.c
41900 @@ -554,7 +554,7 @@ static struct ata_port_operations sas_sata_ops = {
41901 .postreset = ata_std_postreset,
41902 .error_handler = ata_std_error_handler,
41903 .post_internal_cmd = sas_ata_post_internal,
41904 - .qc_defer = ata_std_qc_defer,
41905 + .qc_defer = ata_std_qc_defer,
41906 .qc_prep = ata_noop_qc_prep,
41907 .qc_issue = sas_ata_qc_issue,
41908 .qc_fill_rtf = sas_ata_qc_fill_rtf,
41909 diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h
41910 index 7706c99..3b4fc0c 100644
41911 --- a/drivers/scsi/lpfc/lpfc.h
41912 +++ b/drivers/scsi/lpfc/lpfc.h
41913 @@ -424,7 +424,7 @@ struct lpfc_vport {
41914 struct dentry *debug_nodelist;
41915 struct dentry *vport_debugfs_root;
41916 struct lpfc_debugfs_trc *disc_trc;
41917 - atomic_t disc_trc_cnt;
41918 + atomic_unchecked_t disc_trc_cnt;
41919 #endif
41920 uint8_t stat_data_enabled;
41921 uint8_t stat_data_blocked;
41922 @@ -853,8 +853,8 @@ struct lpfc_hba {
41923 struct timer_list fabric_block_timer;
41924 unsigned long bit_flags;
41925 #define FABRIC_COMANDS_BLOCKED 0
41926 - atomic_t num_rsrc_err;
41927 - atomic_t num_cmd_success;
41928 + atomic_unchecked_t num_rsrc_err;
41929 + atomic_unchecked_t num_cmd_success;
41930 unsigned long last_rsrc_error_time;
41931 unsigned long last_ramp_down_time;
41932 unsigned long last_ramp_up_time;
41933 @@ -890,7 +890,7 @@ struct lpfc_hba {
41934
41935 struct dentry *debug_slow_ring_trc;
41936 struct lpfc_debugfs_trc *slow_ring_trc;
41937 - atomic_t slow_ring_trc_cnt;
41938 + atomic_unchecked_t slow_ring_trc_cnt;
41939 /* iDiag debugfs sub-directory */
41940 struct dentry *idiag_root;
41941 struct dentry *idiag_pci_cfg;
41942 diff --git a/drivers/scsi/lpfc/lpfc_debugfs.c b/drivers/scsi/lpfc/lpfc_debugfs.c
41943 index f63f5ff..de29189 100644
41944 --- a/drivers/scsi/lpfc/lpfc_debugfs.c
41945 +++ b/drivers/scsi/lpfc/lpfc_debugfs.c
41946 @@ -106,7 +106,7 @@ MODULE_PARM_DESC(lpfc_debugfs_mask_disc_trc,
41947
41948 #include <linux/debugfs.h>
41949
41950 -static atomic_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0);
41951 +static atomic_unchecked_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0);
41952 static unsigned long lpfc_debugfs_start_time = 0L;
41953
41954 /* iDiag */
41955 @@ -147,7 +147,7 @@ lpfc_debugfs_disc_trc_data(struct lpfc_vport *vport, char *buf, int size)
41956 lpfc_debugfs_enable = 0;
41957
41958 len = 0;
41959 - index = (atomic_read(&vport->disc_trc_cnt) + 1) &
41960 + index = (atomic_read_unchecked(&vport->disc_trc_cnt) + 1) &
41961 (lpfc_debugfs_max_disc_trc - 1);
41962 for (i = index; i < lpfc_debugfs_max_disc_trc; i++) {
41963 dtp = vport->disc_trc + i;
41964 @@ -213,7 +213,7 @@ lpfc_debugfs_slow_ring_trc_data(struct lpfc_hba *phba, char *buf, int size)
41965 lpfc_debugfs_enable = 0;
41966
41967 len = 0;
41968 - index = (atomic_read(&phba->slow_ring_trc_cnt) + 1) &
41969 + index = (atomic_read_unchecked(&phba->slow_ring_trc_cnt) + 1) &
41970 (lpfc_debugfs_max_slow_ring_trc - 1);
41971 for (i = index; i < lpfc_debugfs_max_slow_ring_trc; i++) {
41972 dtp = phba->slow_ring_trc + i;
41973 @@ -646,14 +646,14 @@ lpfc_debugfs_disc_trc(struct lpfc_vport *vport, int mask, char *fmt,
41974 !vport || !vport->disc_trc)
41975 return;
41976
41977 - index = atomic_inc_return(&vport->disc_trc_cnt) &
41978 + index = atomic_inc_return_unchecked(&vport->disc_trc_cnt) &
41979 (lpfc_debugfs_max_disc_trc - 1);
41980 dtp = vport->disc_trc + index;
41981 dtp->fmt = fmt;
41982 dtp->data1 = data1;
41983 dtp->data2 = data2;
41984 dtp->data3 = data3;
41985 - dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
41986 + dtp->seq_cnt = atomic_inc_return_unchecked(&lpfc_debugfs_seq_trc_cnt);
41987 dtp->jif = jiffies;
41988 #endif
41989 return;
41990 @@ -684,14 +684,14 @@ lpfc_debugfs_slow_ring_trc(struct lpfc_hba *phba, char *fmt,
41991 !phba || !phba->slow_ring_trc)
41992 return;
41993
41994 - index = atomic_inc_return(&phba->slow_ring_trc_cnt) &
41995 + index = atomic_inc_return_unchecked(&phba->slow_ring_trc_cnt) &
41996 (lpfc_debugfs_max_slow_ring_trc - 1);
41997 dtp = phba->slow_ring_trc + index;
41998 dtp->fmt = fmt;
41999 dtp->data1 = data1;
42000 dtp->data2 = data2;
42001 dtp->data3 = data3;
42002 - dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
42003 + dtp->seq_cnt = atomic_inc_return_unchecked(&lpfc_debugfs_seq_trc_cnt);
42004 dtp->jif = jiffies;
42005 #endif
42006 return;
42007 @@ -4182,7 +4182,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
42008 "slow_ring buffer\n");
42009 goto debug_failed;
42010 }
42011 - atomic_set(&phba->slow_ring_trc_cnt, 0);
42012 + atomic_set_unchecked(&phba->slow_ring_trc_cnt, 0);
42013 memset(phba->slow_ring_trc, 0,
42014 (sizeof(struct lpfc_debugfs_trc) *
42015 lpfc_debugfs_max_slow_ring_trc));
42016 @@ -4228,7 +4228,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
42017 "buffer\n");
42018 goto debug_failed;
42019 }
42020 - atomic_set(&vport->disc_trc_cnt, 0);
42021 + atomic_set_unchecked(&vport->disc_trc_cnt, 0);
42022
42023 snprintf(name, sizeof(name), "discovery_trace");
42024 vport->debug_disc_trc =
42025 diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
42026 index 314b4f6..7005d10 100644
42027 --- a/drivers/scsi/lpfc/lpfc_init.c
42028 +++ b/drivers/scsi/lpfc/lpfc_init.c
42029 @@ -10551,8 +10551,10 @@ lpfc_init(void)
42030 "misc_register returned with status %d", error);
42031
42032 if (lpfc_enable_npiv) {
42033 - lpfc_transport_functions.vport_create = lpfc_vport_create;
42034 - lpfc_transport_functions.vport_delete = lpfc_vport_delete;
42035 + pax_open_kernel();
42036 + *(void **)&lpfc_transport_functions.vport_create = lpfc_vport_create;
42037 + *(void **)&lpfc_transport_functions.vport_delete = lpfc_vport_delete;
42038 + pax_close_kernel();
42039 }
42040 lpfc_transport_template =
42041 fc_attach_transport(&lpfc_transport_functions);
42042 diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c
42043 index 98af07c..7625fb5 100644
42044 --- a/drivers/scsi/lpfc/lpfc_scsi.c
42045 +++ b/drivers/scsi/lpfc/lpfc_scsi.c
42046 @@ -325,7 +325,7 @@ lpfc_rampdown_queue_depth(struct lpfc_hba *phba)
42047 uint32_t evt_posted;
42048
42049 spin_lock_irqsave(&phba->hbalock, flags);
42050 - atomic_inc(&phba->num_rsrc_err);
42051 + atomic_inc_unchecked(&phba->num_rsrc_err);
42052 phba->last_rsrc_error_time = jiffies;
42053
42054 if ((phba->last_ramp_down_time + QUEUE_RAMP_DOWN_INTERVAL) > jiffies) {
42055 @@ -366,7 +366,7 @@ lpfc_rampup_queue_depth(struct lpfc_vport *vport,
42056 unsigned long flags;
42057 struct lpfc_hba *phba = vport->phba;
42058 uint32_t evt_posted;
42059 - atomic_inc(&phba->num_cmd_success);
42060 + atomic_inc_unchecked(&phba->num_cmd_success);
42061
42062 if (vport->cfg_lun_queue_depth <= queue_depth)
42063 return;
42064 @@ -410,8 +410,8 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
42065 unsigned long num_rsrc_err, num_cmd_success;
42066 int i;
42067
42068 - num_rsrc_err = atomic_read(&phba->num_rsrc_err);
42069 - num_cmd_success = atomic_read(&phba->num_cmd_success);
42070 + num_rsrc_err = atomic_read_unchecked(&phba->num_rsrc_err);
42071 + num_cmd_success = atomic_read_unchecked(&phba->num_cmd_success);
42072
42073 /*
42074 * The error and success command counters are global per
42075 @@ -439,8 +439,8 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
42076 }
42077 }
42078 lpfc_destroy_vport_work_array(phba, vports);
42079 - atomic_set(&phba->num_rsrc_err, 0);
42080 - atomic_set(&phba->num_cmd_success, 0);
42081 + atomic_set_unchecked(&phba->num_rsrc_err, 0);
42082 + atomic_set_unchecked(&phba->num_cmd_success, 0);
42083 }
42084
42085 /**
42086 @@ -474,8 +474,8 @@ lpfc_ramp_up_queue_handler(struct lpfc_hba *phba)
42087 }
42088 }
42089 lpfc_destroy_vport_work_array(phba, vports);
42090 - atomic_set(&phba->num_rsrc_err, 0);
42091 - atomic_set(&phba->num_cmd_success, 0);
42092 + atomic_set_unchecked(&phba->num_rsrc_err, 0);
42093 + atomic_set_unchecked(&phba->num_cmd_success, 0);
42094 }
42095
42096 /**
42097 diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c
42098 index b46f5e9..c4c4ccb 100644
42099 --- a/drivers/scsi/pmcraid.c
42100 +++ b/drivers/scsi/pmcraid.c
42101 @@ -200,8 +200,8 @@ static int pmcraid_slave_alloc(struct scsi_device *scsi_dev)
42102 res->scsi_dev = scsi_dev;
42103 scsi_dev->hostdata = res;
42104 res->change_detected = 0;
42105 - atomic_set(&res->read_failures, 0);
42106 - atomic_set(&res->write_failures, 0);
42107 + atomic_set_unchecked(&res->read_failures, 0);
42108 + atomic_set_unchecked(&res->write_failures, 0);
42109 rc = 0;
42110 }
42111 spin_unlock_irqrestore(&pinstance->resource_lock, lock_flags);
42112 @@ -2676,9 +2676,9 @@ static int pmcraid_error_handler(struct pmcraid_cmd *cmd)
42113
42114 /* If this was a SCSI read/write command keep count of errors */
42115 if (SCSI_CMD_TYPE(scsi_cmd->cmnd[0]) == SCSI_READ_CMD)
42116 - atomic_inc(&res->read_failures);
42117 + atomic_inc_unchecked(&res->read_failures);
42118 else if (SCSI_CMD_TYPE(scsi_cmd->cmnd[0]) == SCSI_WRITE_CMD)
42119 - atomic_inc(&res->write_failures);
42120 + atomic_inc_unchecked(&res->write_failures);
42121
42122 if (!RES_IS_GSCSI(res->cfg_entry) &&
42123 masked_ioasc != PMCRAID_IOASC_HW_DEVICE_BUS_STATUS_ERROR) {
42124 @@ -3534,7 +3534,7 @@ static int pmcraid_queuecommand_lck(
42125 * block of scsi_cmd which is re-used (e.g. cancel/abort), which uses
42126 * hrrq_id assigned here in queuecommand
42127 */
42128 - ioarcb->hrrq_id = atomic_add_return(1, &(pinstance->last_message_id)) %
42129 + ioarcb->hrrq_id = atomic_add_return_unchecked(1, &(pinstance->last_message_id)) %
42130 pinstance->num_hrrq;
42131 cmd->cmd_done = pmcraid_io_done;
42132
42133 @@ -3859,7 +3859,7 @@ static long pmcraid_ioctl_passthrough(
42134 * block of scsi_cmd which is re-used (e.g. cancel/abort), which uses
42135 * hrrq_id assigned here in queuecommand
42136 */
42137 - ioarcb->hrrq_id = atomic_add_return(1, &(pinstance->last_message_id)) %
42138 + ioarcb->hrrq_id = atomic_add_return_unchecked(1, &(pinstance->last_message_id)) %
42139 pinstance->num_hrrq;
42140
42141 if (request_size) {
42142 @@ -4497,7 +4497,7 @@ static void pmcraid_worker_function(struct work_struct *workp)
42143
42144 pinstance = container_of(workp, struct pmcraid_instance, worker_q);
42145 /* add resources only after host is added into system */
42146 - if (!atomic_read(&pinstance->expose_resources))
42147 + if (!atomic_read_unchecked(&pinstance->expose_resources))
42148 return;
42149
42150 fw_version = be16_to_cpu(pinstance->inq_data->fw_version);
42151 @@ -5324,8 +5324,8 @@ static int pmcraid_init_instance(struct pci_dev *pdev, struct Scsi_Host *host,
42152 init_waitqueue_head(&pinstance->reset_wait_q);
42153
42154 atomic_set(&pinstance->outstanding_cmds, 0);
42155 - atomic_set(&pinstance->last_message_id, 0);
42156 - atomic_set(&pinstance->expose_resources, 0);
42157 + atomic_set_unchecked(&pinstance->last_message_id, 0);
42158 + atomic_set_unchecked(&pinstance->expose_resources, 0);
42159
42160 INIT_LIST_HEAD(&pinstance->free_res_q);
42161 INIT_LIST_HEAD(&pinstance->used_res_q);
42162 @@ -6038,7 +6038,7 @@ static int pmcraid_probe(struct pci_dev *pdev,
42163 /* Schedule worker thread to handle CCN and take care of adding and
42164 * removing devices to OS
42165 */
42166 - atomic_set(&pinstance->expose_resources, 1);
42167 + atomic_set_unchecked(&pinstance->expose_resources, 1);
42168 schedule_work(&pinstance->worker_q);
42169 return rc;
42170
42171 diff --git a/drivers/scsi/pmcraid.h b/drivers/scsi/pmcraid.h
42172 index e1d150f..6c6df44 100644
42173 --- a/drivers/scsi/pmcraid.h
42174 +++ b/drivers/scsi/pmcraid.h
42175 @@ -748,7 +748,7 @@ struct pmcraid_instance {
42176 struct pmcraid_isr_param hrrq_vector[PMCRAID_NUM_MSIX_VECTORS];
42177
42178 /* Message id as filled in last fired IOARCB, used to identify HRRQ */
42179 - atomic_t last_message_id;
42180 + atomic_unchecked_t last_message_id;
42181
42182 /* configuration table */
42183 struct pmcraid_config_table *cfg_table;
42184 @@ -777,7 +777,7 @@ struct pmcraid_instance {
42185 atomic_t outstanding_cmds;
42186
42187 /* should add/delete resources to mid-layer now ?*/
42188 - atomic_t expose_resources;
42189 + atomic_unchecked_t expose_resources;
42190
42191
42192
42193 @@ -813,8 +813,8 @@ struct pmcraid_resource_entry {
42194 struct pmcraid_config_table_entry_ext cfg_entry_ext;
42195 };
42196 struct scsi_device *scsi_dev; /* Link scsi_device structure */
42197 - atomic_t read_failures; /* count of failed READ commands */
42198 - atomic_t write_failures; /* count of failed WRITE commands */
42199 + atomic_unchecked_t read_failures; /* count of failed READ commands */
42200 + atomic_unchecked_t write_failures; /* count of failed WRITE commands */
42201
42202 /* To indicate add/delete/modify during CCN */
42203 u8 change_detected;
42204 diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
42205 index b3db9dc..c3b1756 100644
42206 --- a/drivers/scsi/qla2xxx/qla_attr.c
42207 +++ b/drivers/scsi/qla2xxx/qla_attr.c
42208 @@ -1971,7 +1971,7 @@ qla24xx_vport_disable(struct fc_vport *fc_vport, bool disable)
42209 return 0;
42210 }
42211
42212 -struct fc_function_template qla2xxx_transport_functions = {
42213 +fc_function_template_no_const qla2xxx_transport_functions = {
42214
42215 .show_host_node_name = 1,
42216 .show_host_port_name = 1,
42217 @@ -2018,7 +2018,7 @@ struct fc_function_template qla2xxx_transport_functions = {
42218 .bsg_timeout = qla24xx_bsg_timeout,
42219 };
42220
42221 -struct fc_function_template qla2xxx_transport_vport_functions = {
42222 +fc_function_template_no_const qla2xxx_transport_vport_functions = {
42223
42224 .show_host_node_name = 1,
42225 .show_host_port_name = 1,
42226 diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h
42227 index b310fa9..b9b3944 100644
42228 --- a/drivers/scsi/qla2xxx/qla_gbl.h
42229 +++ b/drivers/scsi/qla2xxx/qla_gbl.h
42230 @@ -523,8 +523,8 @@ extern void qla2x00_get_sym_node_name(scsi_qla_host_t *, uint8_t *);
42231 struct device_attribute;
42232 extern struct device_attribute *qla2x00_host_attrs[];
42233 struct fc_function_template;
42234 -extern struct fc_function_template qla2xxx_transport_functions;
42235 -extern struct fc_function_template qla2xxx_transport_vport_functions;
42236 +extern fc_function_template_no_const qla2xxx_transport_functions;
42237 +extern fc_function_template_no_const qla2xxx_transport_vport_functions;
42238 extern void qla2x00_alloc_sysfs_attr(scsi_qla_host_t *);
42239 extern void qla2x00_free_sysfs_attr(scsi_qla_host_t *);
42240 extern void qla2x00_init_host_attr(scsi_qla_host_t *);
42241 diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
42242 index 2c6dd3d..e5ecd82 100644
42243 --- a/drivers/scsi/qla2xxx/qla_os.c
42244 +++ b/drivers/scsi/qla2xxx/qla_os.c
42245 @@ -1554,8 +1554,10 @@ qla2x00_config_dma_addressing(struct qla_hw_data *ha)
42246 !pci_set_consistent_dma_mask(ha->pdev, DMA_BIT_MASK(64))) {
42247 /* Ok, a 64bit DMA mask is applicable. */
42248 ha->flags.enable_64bit_addressing = 1;
42249 - ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64;
42250 - ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64;
42251 + pax_open_kernel();
42252 + *(void **)&ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64;
42253 + *(void **)&ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64;
42254 + pax_close_kernel();
42255 return;
42256 }
42257 }
42258 diff --git a/drivers/scsi/qla4xxx/ql4_def.h b/drivers/scsi/qla4xxx/ql4_def.h
42259 index 129f5dd..ade53e8 100644
42260 --- a/drivers/scsi/qla4xxx/ql4_def.h
42261 +++ b/drivers/scsi/qla4xxx/ql4_def.h
42262 @@ -275,7 +275,7 @@ struct ddb_entry {
42263 * (4000 only) */
42264 atomic_t relogin_timer; /* Max Time to wait for
42265 * relogin to complete */
42266 - atomic_t relogin_retry_count; /* Num of times relogin has been
42267 + atomic_unchecked_t relogin_retry_count; /* Num of times relogin has been
42268 * retried */
42269 uint32_t default_time2wait; /* Default Min time between
42270 * relogins (+aens) */
42271 diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
42272 index 6142729..b6a85c9 100644
42273 --- a/drivers/scsi/qla4xxx/ql4_os.c
42274 +++ b/drivers/scsi/qla4xxx/ql4_os.c
42275 @@ -2622,12 +2622,12 @@ static void qla4xxx_check_relogin_flash_ddb(struct iscsi_cls_session *cls_sess)
42276 */
42277 if (!iscsi_is_session_online(cls_sess)) {
42278 /* Reset retry relogin timer */
42279 - atomic_inc(&ddb_entry->relogin_retry_count);
42280 + atomic_inc_unchecked(&ddb_entry->relogin_retry_count);
42281 DEBUG2(ql4_printk(KERN_INFO, ha,
42282 "%s: index[%d] relogin timed out-retrying"
42283 " relogin (%d), retry (%d)\n", __func__,
42284 ddb_entry->fw_ddb_index,
42285 - atomic_read(&ddb_entry->relogin_retry_count),
42286 + atomic_read_unchecked(&ddb_entry->relogin_retry_count),
42287 ddb_entry->default_time2wait + 4));
42288 set_bit(DPC_RELOGIN_DEVICE, &ha->dpc_flags);
42289 atomic_set(&ddb_entry->retry_relogin_timer,
42290 @@ -4742,7 +4742,7 @@ static void qla4xxx_setup_flash_ddb_entry(struct scsi_qla_host *ha,
42291
42292 atomic_set(&ddb_entry->retry_relogin_timer, INVALID_ENTRY);
42293 atomic_set(&ddb_entry->relogin_timer, 0);
42294 - atomic_set(&ddb_entry->relogin_retry_count, 0);
42295 + atomic_set_unchecked(&ddb_entry->relogin_retry_count, 0);
42296 def_timeout = le16_to_cpu(ddb_entry->fw_ddb_entry.def_timeout);
42297 ddb_entry->default_relogin_timeout =
42298 (def_timeout > LOGIN_TOV) && (def_timeout < LOGIN_TOV * 10) ?
42299 diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
42300 index 2c0d0ec..4e8681a 100644
42301 --- a/drivers/scsi/scsi.c
42302 +++ b/drivers/scsi/scsi.c
42303 @@ -661,7 +661,7 @@ int scsi_dispatch_cmd(struct scsi_cmnd *cmd)
42304 unsigned long timeout;
42305 int rtn = 0;
42306
42307 - atomic_inc(&cmd->device->iorequest_cnt);
42308 + atomic_inc_unchecked(&cmd->device->iorequest_cnt);
42309
42310 /* check if the device is still usable */
42311 if (unlikely(cmd->device->sdev_state == SDEV_DEL)) {
42312 diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
42313 index c31187d..0ead8c3 100644
42314 --- a/drivers/scsi/scsi_lib.c
42315 +++ b/drivers/scsi/scsi_lib.c
42316 @@ -1459,7 +1459,7 @@ static void scsi_kill_request(struct request *req, struct request_queue *q)
42317 shost = sdev->host;
42318 scsi_init_cmd_errh(cmd);
42319 cmd->result = DID_NO_CONNECT << 16;
42320 - atomic_inc(&cmd->device->iorequest_cnt);
42321 + atomic_inc_unchecked(&cmd->device->iorequest_cnt);
42322
42323 /*
42324 * SCSI request completion path will do scsi_device_unbusy(),
42325 @@ -1485,9 +1485,9 @@ static void scsi_softirq_done(struct request *rq)
42326
42327 INIT_LIST_HEAD(&cmd->eh_entry);
42328
42329 - atomic_inc(&cmd->device->iodone_cnt);
42330 + atomic_inc_unchecked(&cmd->device->iodone_cnt);
42331 if (cmd->result)
42332 - atomic_inc(&cmd->device->ioerr_cnt);
42333 + atomic_inc_unchecked(&cmd->device->ioerr_cnt);
42334
42335 disposition = scsi_decide_disposition(cmd);
42336 if (disposition != SUCCESS &&
42337 diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
42338 index 931a7d9..0c2a754 100644
42339 --- a/drivers/scsi/scsi_sysfs.c
42340 +++ b/drivers/scsi/scsi_sysfs.c
42341 @@ -658,7 +658,7 @@ show_iostat_##field(struct device *dev, struct device_attribute *attr, \
42342 char *buf) \
42343 { \
42344 struct scsi_device *sdev = to_scsi_device(dev); \
42345 - unsigned long long count = atomic_read(&sdev->field); \
42346 + unsigned long long count = atomic_read_unchecked(&sdev->field); \
42347 return snprintf(buf, 20, "0x%llx\n", count); \
42348 } \
42349 static DEVICE_ATTR(field, S_IRUGO, show_iostat_##field, NULL)
42350 diff --git a/drivers/scsi/scsi_tgt_lib.c b/drivers/scsi/scsi_tgt_lib.c
42351 index 84a1fdf..693b0d6 100644
42352 --- a/drivers/scsi/scsi_tgt_lib.c
42353 +++ b/drivers/scsi/scsi_tgt_lib.c
42354 @@ -362,7 +362,7 @@ static int scsi_map_user_pages(struct scsi_tgt_cmd *tcmd, struct scsi_cmnd *cmd,
42355 int err;
42356
42357 dprintk("%lx %u\n", uaddr, len);
42358 - err = blk_rq_map_user(q, rq, NULL, (void *)uaddr, len, GFP_KERNEL);
42359 + err = blk_rq_map_user(q, rq, NULL, (void __user *)uaddr, len, GFP_KERNEL);
42360 if (err) {
42361 /*
42362 * TODO: need to fixup sg_tablesize, max_segment_size,
42363 diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c
42364 index e894ca7..de9d7660 100644
42365 --- a/drivers/scsi/scsi_transport_fc.c
42366 +++ b/drivers/scsi/scsi_transport_fc.c
42367 @@ -498,7 +498,7 @@ static DECLARE_TRANSPORT_CLASS(fc_vport_class,
42368 * Netlink Infrastructure
42369 */
42370
42371 -static atomic_t fc_event_seq;
42372 +static atomic_unchecked_t fc_event_seq;
42373
42374 /**
42375 * fc_get_event_number - Obtain the next sequential FC event number
42376 @@ -511,7 +511,7 @@ static atomic_t fc_event_seq;
42377 u32
42378 fc_get_event_number(void)
42379 {
42380 - return atomic_add_return(1, &fc_event_seq);
42381 + return atomic_add_return_unchecked(1, &fc_event_seq);
42382 }
42383 EXPORT_SYMBOL(fc_get_event_number);
42384
42385 @@ -659,7 +659,7 @@ static __init int fc_transport_init(void)
42386 {
42387 int error;
42388
42389 - atomic_set(&fc_event_seq, 0);
42390 + atomic_set_unchecked(&fc_event_seq, 0);
42391
42392 error = transport_class_register(&fc_host_class);
42393 if (error)
42394 @@ -849,7 +849,7 @@ static int fc_str_to_dev_loss(const char *buf, unsigned long *val)
42395 char *cp;
42396
42397 *val = simple_strtoul(buf, &cp, 0);
42398 - if ((*cp && (*cp != '\n')) || (*val < 0))
42399 + if (*cp && (*cp != '\n'))
42400 return -EINVAL;
42401 /*
42402 * Check for overflow; dev_loss_tmo is u32
42403 diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
42404 index 0a74b97..fa8d648 100644
42405 --- a/drivers/scsi/scsi_transport_iscsi.c
42406 +++ b/drivers/scsi/scsi_transport_iscsi.c
42407 @@ -79,7 +79,7 @@ struct iscsi_internal {
42408 struct transport_container session_cont;
42409 };
42410
42411 -static atomic_t iscsi_session_nr; /* sysfs session id for next new session */
42412 +static atomic_unchecked_t iscsi_session_nr; /* sysfs session id for next new session */
42413 static struct workqueue_struct *iscsi_eh_timer_workq;
42414
42415 static DEFINE_IDA(iscsi_sess_ida);
42416 @@ -1064,7 +1064,7 @@ int iscsi_add_session(struct iscsi_cls_session *session, unsigned int target_id)
42417 int err;
42418
42419 ihost = shost->shost_data;
42420 - session->sid = atomic_add_return(1, &iscsi_session_nr);
42421 + session->sid = atomic_add_return_unchecked(1, &iscsi_session_nr);
42422
42423 if (target_id == ISCSI_MAX_TARGET) {
42424 id = ida_simple_get(&iscsi_sess_ida, 0, 0, GFP_KERNEL);
42425 @@ -2955,7 +2955,7 @@ static __init int iscsi_transport_init(void)
42426 printk(KERN_INFO "Loading iSCSI transport class v%s.\n",
42427 ISCSI_TRANSPORT_VERSION);
42428
42429 - atomic_set(&iscsi_session_nr, 0);
42430 + atomic_set_unchecked(&iscsi_session_nr, 0);
42431
42432 err = class_register(&iscsi_transport_class);
42433 if (err)
42434 diff --git a/drivers/scsi/scsi_transport_srp.c b/drivers/scsi/scsi_transport_srp.c
42435 index f379c7f..e8fc69c 100644
42436 --- a/drivers/scsi/scsi_transport_srp.c
42437 +++ b/drivers/scsi/scsi_transport_srp.c
42438 @@ -33,7 +33,7 @@
42439 #include "scsi_transport_srp_internal.h"
42440
42441 struct srp_host_attrs {
42442 - atomic_t next_port_id;
42443 + atomic_unchecked_t next_port_id;
42444 };
42445 #define to_srp_host_attrs(host) ((struct srp_host_attrs *)(host)->shost_data)
42446
42447 @@ -61,7 +61,7 @@ static int srp_host_setup(struct transport_container *tc, struct device *dev,
42448 struct Scsi_Host *shost = dev_to_shost(dev);
42449 struct srp_host_attrs *srp_host = to_srp_host_attrs(shost);
42450
42451 - atomic_set(&srp_host->next_port_id, 0);
42452 + atomic_set_unchecked(&srp_host->next_port_id, 0);
42453 return 0;
42454 }
42455
42456 @@ -210,7 +210,7 @@ struct srp_rport *srp_rport_add(struct Scsi_Host *shost,
42457 memcpy(rport->port_id, ids->port_id, sizeof(rport->port_id));
42458 rport->roles = ids->roles;
42459
42460 - id = atomic_inc_return(&to_srp_host_attrs(shost)->next_port_id);
42461 + id = atomic_inc_return_unchecked(&to_srp_host_attrs(shost)->next_port_id);
42462 dev_set_name(&rport->dev, "port-%d:%d", shost->host_no, id);
42463
42464 transport_setup_device(&rport->dev);
42465 diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
42466 index 82910cc..7c350ad 100644
42467 --- a/drivers/scsi/sd.c
42468 +++ b/drivers/scsi/sd.c
42469 @@ -2929,7 +2929,7 @@ static int sd_probe(struct device *dev)
42470 sdkp->disk = gd;
42471 sdkp->index = index;
42472 atomic_set(&sdkp->openers, 0);
42473 - atomic_set(&sdkp->device->ioerr_cnt, 0);
42474 + atomic_set_unchecked(&sdkp->device->ioerr_cnt, 0);
42475
42476 if (!sdp->request_queue->rq_timeout) {
42477 if (sdp->type != TYPE_MOD)
42478 diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
42479 index 9f0c465..47194ee 100644
42480 --- a/drivers/scsi/sg.c
42481 +++ b/drivers/scsi/sg.c
42482 @@ -1101,7 +1101,7 @@ sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg)
42483 sdp->disk->disk_name,
42484 MKDEV(SCSI_GENERIC_MAJOR, sdp->index),
42485 NULL,
42486 - (char *)arg);
42487 + (char __user *)arg);
42488 case BLKTRACESTART:
42489 return blk_trace_startstop(sdp->device->request_queue, 1);
42490 case BLKTRACESTOP:
42491 diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
42492 index 004b10f..7c98d51 100644
42493 --- a/drivers/spi/spi.c
42494 +++ b/drivers/spi/spi.c
42495 @@ -1620,7 +1620,7 @@ int spi_bus_unlock(struct spi_master *master)
42496 EXPORT_SYMBOL_GPL(spi_bus_unlock);
42497
42498 /* portable code must never pass more than 32 bytes */
42499 -#define SPI_BUFSIZ max(32,SMP_CACHE_BYTES)
42500 +#define SPI_BUFSIZ max(32UL,SMP_CACHE_BYTES)
42501
42502 static u8 *buf;
42503
42504 diff --git a/drivers/staging/iio/iio_hwmon.c b/drivers/staging/iio/iio_hwmon.c
42505 index 93af756..a4bc5bf 100644
42506 --- a/drivers/staging/iio/iio_hwmon.c
42507 +++ b/drivers/staging/iio/iio_hwmon.c
42508 @@ -67,7 +67,7 @@ static int iio_hwmon_probe(struct platform_device *pdev)
42509 {
42510 struct device *dev = &pdev->dev;
42511 struct iio_hwmon_state *st;
42512 - struct sensor_device_attribute *a;
42513 + sensor_device_attribute_no_const *a;
42514 int ret, i;
42515 int in_i = 1, temp_i = 1, curr_i = 1;
42516 enum iio_chan_type type;
42517 diff --git a/drivers/staging/octeon/ethernet-rx.c b/drivers/staging/octeon/ethernet-rx.c
42518 index 34afc16..ffe44dd 100644
42519 --- a/drivers/staging/octeon/ethernet-rx.c
42520 +++ b/drivers/staging/octeon/ethernet-rx.c
42521 @@ -421,11 +421,11 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
42522 /* Increment RX stats for virtual ports */
42523 if (work->ipprt >= CVMX_PIP_NUM_INPUT_PORTS) {
42524 #ifdef CONFIG_64BIT
42525 - atomic64_add(1, (atomic64_t *)&priv->stats.rx_packets);
42526 - atomic64_add(skb->len, (atomic64_t *)&priv->stats.rx_bytes);
42527 + atomic64_add_unchecked(1, (atomic64_unchecked_t *)&priv->stats.rx_packets);
42528 + atomic64_add_unchecked(skb->len, (atomic64_unchecked_t *)&priv->stats.rx_bytes);
42529 #else
42530 - atomic_add(1, (atomic_t *)&priv->stats.rx_packets);
42531 - atomic_add(skb->len, (atomic_t *)&priv->stats.rx_bytes);
42532 + atomic_add_unchecked(1, (atomic_unchecked_t *)&priv->stats.rx_packets);
42533 + atomic_add_unchecked(skb->len, (atomic_unchecked_t *)&priv->stats.rx_bytes);
42534 #endif
42535 }
42536 netif_receive_skb(skb);
42537 @@ -437,9 +437,9 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
42538 dev->name);
42539 */
42540 #ifdef CONFIG_64BIT
42541 - atomic64_add(1, (atomic64_t *)&priv->stats.rx_dropped);
42542 + atomic64_unchecked_add(1, (atomic64_unchecked_t *)&priv->stats.rx_dropped);
42543 #else
42544 - atomic_add(1, (atomic_t *)&priv->stats.rx_dropped);
42545 + atomic_add_unchecked(1, (atomic_unchecked_t *)&priv->stats.rx_dropped);
42546 #endif
42547 dev_kfree_skb_irq(skb);
42548 }
42549 diff --git a/drivers/staging/octeon/ethernet.c b/drivers/staging/octeon/ethernet.c
42550 index c3a90e7..023619a 100644
42551 --- a/drivers/staging/octeon/ethernet.c
42552 +++ b/drivers/staging/octeon/ethernet.c
42553 @@ -252,11 +252,11 @@ static struct net_device_stats *cvm_oct_common_get_stats(struct net_device *dev)
42554 * since the RX tasklet also increments it.
42555 */
42556 #ifdef CONFIG_64BIT
42557 - atomic64_add(rx_status.dropped_packets,
42558 - (atomic64_t *)&priv->stats.rx_dropped);
42559 + atomic64_add_unchecked(rx_status.dropped_packets,
42560 + (atomic64_unchecked_t *)&priv->stats.rx_dropped);
42561 #else
42562 - atomic_add(rx_status.dropped_packets,
42563 - (atomic_t *)&priv->stats.rx_dropped);
42564 + atomic_add_unchecked(rx_status.dropped_packets,
42565 + (atomic_unchecked_t *)&priv->stats.rx_dropped);
42566 #endif
42567 }
42568
42569 diff --git a/drivers/staging/rtl8712/rtl871x_io.h b/drivers/staging/rtl8712/rtl871x_io.h
42570 index dc23395..cf7e9b1 100644
42571 --- a/drivers/staging/rtl8712/rtl871x_io.h
42572 +++ b/drivers/staging/rtl8712/rtl871x_io.h
42573 @@ -108,7 +108,7 @@ struct _io_ops {
42574 u8 *pmem);
42575 u32 (*_write_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt,
42576 u8 *pmem);
42577 -};
42578 +} __no_const;
42579
42580 struct io_req {
42581 struct list_head list;
42582 diff --git a/drivers/staging/sbe-2t3e3/netdev.c b/drivers/staging/sbe-2t3e3/netdev.c
42583 index 1f5088b..0e59820 100644
42584 --- a/drivers/staging/sbe-2t3e3/netdev.c
42585 +++ b/drivers/staging/sbe-2t3e3/netdev.c
42586 @@ -51,7 +51,7 @@ static int t3e3_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
42587 t3e3_if_config(sc, cmd_2t3e3, (char *)&param, &resp, &rlen);
42588
42589 if (rlen)
42590 - if (copy_to_user(data, &resp, rlen))
42591 + if (rlen > sizeof resp || copy_to_user(data, &resp, rlen))
42592 return -EFAULT;
42593
42594 return 0;
42595 diff --git a/drivers/staging/usbip/vhci.h b/drivers/staging/usbip/vhci.h
42596 index 5dddc4d..34fcb2f 100644
42597 --- a/drivers/staging/usbip/vhci.h
42598 +++ b/drivers/staging/usbip/vhci.h
42599 @@ -83,7 +83,7 @@ struct vhci_hcd {
42600 unsigned resuming:1;
42601 unsigned long re_timeout;
42602
42603 - atomic_t seqnum;
42604 + atomic_unchecked_t seqnum;
42605
42606 /*
42607 * NOTE:
42608 diff --git a/drivers/staging/usbip/vhci_hcd.c b/drivers/staging/usbip/vhci_hcd.c
42609 index f1ca084..7b5c0c3 100644
42610 --- a/drivers/staging/usbip/vhci_hcd.c
42611 +++ b/drivers/staging/usbip/vhci_hcd.c
42612 @@ -441,7 +441,7 @@ static void vhci_tx_urb(struct urb *urb)
42613
42614 spin_lock(&vdev->priv_lock);
42615
42616 - priv->seqnum = atomic_inc_return(&the_controller->seqnum);
42617 + priv->seqnum = atomic_inc_return_unchecked(&the_controller->seqnum);
42618 if (priv->seqnum == 0xffff)
42619 dev_info(&urb->dev->dev, "seqnum max\n");
42620
42621 @@ -687,7 +687,7 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
42622 return -ENOMEM;
42623 }
42624
42625 - unlink->seqnum = atomic_inc_return(&the_controller->seqnum);
42626 + unlink->seqnum = atomic_inc_return_unchecked(&the_controller->seqnum);
42627 if (unlink->seqnum == 0xffff)
42628 pr_info("seqnum max\n");
42629
42630 @@ -891,7 +891,7 @@ static int vhci_start(struct usb_hcd *hcd)
42631 vdev->rhport = rhport;
42632 }
42633
42634 - atomic_set(&vhci->seqnum, 0);
42635 + atomic_set_unchecked(&vhci->seqnum, 0);
42636 spin_lock_init(&vhci->lock);
42637
42638 hcd->power_budget = 0; /* no limit */
42639 diff --git a/drivers/staging/usbip/vhci_rx.c b/drivers/staging/usbip/vhci_rx.c
42640 index faf8e60..c46f8ab 100644
42641 --- a/drivers/staging/usbip/vhci_rx.c
42642 +++ b/drivers/staging/usbip/vhci_rx.c
42643 @@ -76,7 +76,7 @@ static void vhci_recv_ret_submit(struct vhci_device *vdev,
42644 if (!urb) {
42645 pr_err("cannot find a urb of seqnum %u\n", pdu->base.seqnum);
42646 pr_info("max seqnum %d\n",
42647 - atomic_read(&the_controller->seqnum));
42648 + atomic_read_unchecked(&the_controller->seqnum));
42649 usbip_event_add(ud, VDEV_EVENT_ERROR_TCP);
42650 return;
42651 }
42652 diff --git a/drivers/staging/vt6655/hostap.c b/drivers/staging/vt6655/hostap.c
42653 index 5f13890..36a044b 100644
42654 --- a/drivers/staging/vt6655/hostap.c
42655 +++ b/drivers/staging/vt6655/hostap.c
42656 @@ -73,14 +73,13 @@ static int msglevel =MSG_LEVEL_INFO;
42657 *
42658 */
42659
42660 +static net_device_ops_no_const apdev_netdev_ops;
42661 +
42662 static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
42663 {
42664 PSDevice apdev_priv;
42665 struct net_device *dev = pDevice->dev;
42666 int ret;
42667 - const struct net_device_ops apdev_netdev_ops = {
42668 - .ndo_start_xmit = pDevice->tx_80211,
42669 - };
42670
42671 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Enabling hostapd mode\n", dev->name);
42672
42673 @@ -92,6 +91,8 @@ static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
42674 *apdev_priv = *pDevice;
42675 memcpy(pDevice->apdev->dev_addr, dev->dev_addr, ETH_ALEN);
42676
42677 + /* only half broken now */
42678 + apdev_netdev_ops.ndo_start_xmit = pDevice->tx_80211;
42679 pDevice->apdev->netdev_ops = &apdev_netdev_ops;
42680
42681 pDevice->apdev->type = ARPHRD_IEEE80211;
42682 diff --git a/drivers/staging/vt6656/hostap.c b/drivers/staging/vt6656/hostap.c
42683 index bc5e9da..dacd556 100644
42684 --- a/drivers/staging/vt6656/hostap.c
42685 +++ b/drivers/staging/vt6656/hostap.c
42686 @@ -60,14 +60,13 @@ static int msglevel =MSG_LEVEL_INFO;
42687 *
42688 */
42689
42690 +static net_device_ops_no_const apdev_netdev_ops;
42691 +
42692 static int hostap_enable_hostapd(struct vnt_private *pDevice, int rtnl_locked)
42693 {
42694 struct vnt_private *apdev_priv;
42695 struct net_device *dev = pDevice->dev;
42696 int ret;
42697 - const struct net_device_ops apdev_netdev_ops = {
42698 - .ndo_start_xmit = pDevice->tx_80211,
42699 - };
42700
42701 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Enabling hostapd mode\n", dev->name);
42702
42703 @@ -79,6 +78,8 @@ static int hostap_enable_hostapd(struct vnt_private *pDevice, int rtnl_locked)
42704 *apdev_priv = *pDevice;
42705 memcpy(pDevice->apdev->dev_addr, dev->dev_addr, ETH_ALEN);
42706
42707 + /* only half broken now */
42708 + apdev_netdev_ops.ndo_start_xmit = pDevice->tx_80211;
42709 pDevice->apdev->netdev_ops = &apdev_netdev_ops;
42710
42711 pDevice->apdev->type = ARPHRD_IEEE80211;
42712 diff --git a/drivers/staging/zcache/tmem.c b/drivers/staging/zcache/tmem.c
42713 index a2b7e03..9ff4bbd 100644
42714 --- a/drivers/staging/zcache/tmem.c
42715 +++ b/drivers/staging/zcache/tmem.c
42716 @@ -50,7 +50,7 @@
42717 * A tmem host implementation must use this function to register callbacks
42718 * for memory allocation.
42719 */
42720 -static struct tmem_hostops tmem_hostops;
42721 +static tmem_hostops_no_const tmem_hostops;
42722
42723 static void tmem_objnode_tree_init(void);
42724
42725 @@ -64,7 +64,7 @@ void tmem_register_hostops(struct tmem_hostops *m)
42726 * A tmem host implementation must use this function to register
42727 * callbacks for a page-accessible memory (PAM) implementation.
42728 */
42729 -static struct tmem_pamops tmem_pamops;
42730 +static tmem_pamops_no_const tmem_pamops;
42731
42732 void tmem_register_pamops(struct tmem_pamops *m)
42733 {
42734 diff --git a/drivers/staging/zcache/tmem.h b/drivers/staging/zcache/tmem.h
42735 index adbe5a8..d387359 100644
42736 --- a/drivers/staging/zcache/tmem.h
42737 +++ b/drivers/staging/zcache/tmem.h
42738 @@ -226,6 +226,7 @@ struct tmem_pamops {
42739 int (*replace_in_obj)(void *, struct tmem_obj *);
42740 #endif
42741 };
42742 +typedef struct tmem_pamops __no_const tmem_pamops_no_const;
42743 extern void tmem_register_pamops(struct tmem_pamops *m);
42744
42745 /* memory allocation methods provided by the host implementation */
42746 @@ -235,6 +236,7 @@ struct tmem_hostops {
42747 struct tmem_objnode *(*objnode_alloc)(struct tmem_pool *);
42748 void (*objnode_free)(struct tmem_objnode *, struct tmem_pool *);
42749 };
42750 +typedef struct tmem_hostops __no_const tmem_hostops_no_const;
42751 extern void tmem_register_hostops(struct tmem_hostops *m);
42752
42753 /* core tmem accessor functions */
42754 diff --git a/drivers/target/iscsi/iscsi_target_parameters.c b/drivers/target/iscsi/iscsi_target_parameters.c
42755 index ca2be40..93ae910 100644
42756 --- a/drivers/target/iscsi/iscsi_target_parameters.c
42757 +++ b/drivers/target/iscsi/iscsi_target_parameters.c
42758 @@ -712,9 +712,9 @@ static int iscsi_add_notunderstood_response(
42759 }
42760 INIT_LIST_HEAD(&extra_response->er_list);
42761
42762 - strncpy(extra_response->key, key, strlen(key) + 1);
42763 - strncpy(extra_response->value, NOTUNDERSTOOD,
42764 - strlen(NOTUNDERSTOOD) + 1);
42765 + strlcpy(extra_response->key, key, sizeof(extra_response->key));
42766 + strlcpy(extra_response->value, NOTUNDERSTOOD,
42767 + sizeof(extra_response->value));
42768
42769 list_add_tail(&extra_response->er_list,
42770 &param_list->extra_response_list);
42771 @@ -1583,8 +1583,6 @@ int iscsi_decode_text_input(
42772
42773 if (phase & PHASE_SECURITY) {
42774 if (iscsi_check_for_auth_key(key) > 0) {
42775 - char *tmpptr = key + strlen(key);
42776 - *tmpptr = '=';
42777 kfree(tmpbuf);
42778 return 1;
42779 }
42780 diff --git a/drivers/target/iscsi/iscsi_target_parameters.h b/drivers/target/iscsi/iscsi_target_parameters.h
42781 index 1e1b750..2c536a0 100644
42782 --- a/drivers/target/iscsi/iscsi_target_parameters.h
42783 +++ b/drivers/target/iscsi/iscsi_target_parameters.h
42784 @@ -1,8 +1,10 @@
42785 #ifndef ISCSI_PARAMETERS_H
42786 #define ISCSI_PARAMETERS_H
42787
42788 +#include <scsi/iscsi_proto.h>
42789 +
42790 struct iscsi_extra_response {
42791 - char key[64];
42792 + char key[KEY_MAXLEN];
42793 char value[32];
42794 struct list_head er_list;
42795 } ____cacheline_aligned;
42796 diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c
42797 index 2e4d655..fd72e68 100644
42798 --- a/drivers/target/target_core_device.c
42799 +++ b/drivers/target/target_core_device.c
42800 @@ -1414,7 +1414,7 @@ struct se_device *target_alloc_device(struct se_hba *hba, const char *name)
42801 spin_lock_init(&dev->se_port_lock);
42802 spin_lock_init(&dev->se_tmr_lock);
42803 spin_lock_init(&dev->qf_cmd_lock);
42804 - atomic_set(&dev->dev_ordered_id, 0);
42805 + atomic_set_unchecked(&dev->dev_ordered_id, 0);
42806 INIT_LIST_HEAD(&dev->t10_wwn.t10_vpd_list);
42807 spin_lock_init(&dev->t10_wwn.t10_vpd_lock);
42808 INIT_LIST_HEAD(&dev->t10_pr.registration_list);
42809 diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
42810 index 0d46276..f327cab5 100644
42811 --- a/drivers/target/target_core_transport.c
42812 +++ b/drivers/target/target_core_transport.c
42813 @@ -1080,7 +1080,7 @@ transport_check_alloc_task_attr(struct se_cmd *cmd)
42814 * Used to determine when ORDERED commands should go from
42815 * Dormant to Active status.
42816 */
42817 - cmd->se_ordered_id = atomic_inc_return(&dev->dev_ordered_id);
42818 + cmd->se_ordered_id = atomic_inc_return_unchecked(&dev->dev_ordered_id);
42819 smp_mb__after_atomic_inc();
42820 pr_debug("Allocated se_ordered_id: %u for Task Attr: 0x%02x on %s\n",
42821 cmd->se_ordered_id, cmd->sam_task_attr,
42822 diff --git a/drivers/tty/cyclades.c b/drivers/tty/cyclades.c
42823 index 345bd0e..61d5375 100644
42824 --- a/drivers/tty/cyclades.c
42825 +++ b/drivers/tty/cyclades.c
42826 @@ -1576,10 +1576,10 @@ static int cy_open(struct tty_struct *tty, struct file *filp)
42827 printk(KERN_DEBUG "cyc:cy_open ttyC%d, count = %d\n", info->line,
42828 info->port.count);
42829 #endif
42830 - info->port.count++;
42831 + atomic_inc(&info->port.count);
42832 #ifdef CY_DEBUG_COUNT
42833 printk(KERN_DEBUG "cyc:cy_open (%d): incrementing count to %d\n",
42834 - current->pid, info->port.count);
42835 + current->pid, atomic_read(&info->port.count));
42836 #endif
42837
42838 /*
42839 @@ -3978,7 +3978,7 @@ static int cyclades_proc_show(struct seq_file *m, void *v)
42840 for (j = 0; j < cy_card[i].nports; j++) {
42841 info = &cy_card[i].ports[j];
42842
42843 - if (info->port.count) {
42844 + if (atomic_read(&info->port.count)) {
42845 /* XXX is the ldisc num worth this? */
42846 struct tty_struct *tty;
42847 struct tty_ldisc *ld;
42848 diff --git a/drivers/tty/hvc/hvc_console.c b/drivers/tty/hvc/hvc_console.c
42849 index eb255e8..f637a57 100644
42850 --- a/drivers/tty/hvc/hvc_console.c
42851 +++ b/drivers/tty/hvc/hvc_console.c
42852 @@ -338,7 +338,7 @@ static int hvc_open(struct tty_struct *tty, struct file * filp)
42853
42854 spin_lock_irqsave(&hp->port.lock, flags);
42855 /* Check and then increment for fast path open. */
42856 - if (hp->port.count++ > 0) {
42857 + if (atomic_inc_return(&hp->port.count) > 1) {
42858 spin_unlock_irqrestore(&hp->port.lock, flags);
42859 hvc_kick();
42860 return 0;
42861 @@ -388,7 +388,7 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
42862
42863 spin_lock_irqsave(&hp->port.lock, flags);
42864
42865 - if (--hp->port.count == 0) {
42866 + if (atomic_dec_return(&hp->port.count) == 0) {
42867 spin_unlock_irqrestore(&hp->port.lock, flags);
42868 /* We are done with the tty pointer now. */
42869 tty_port_tty_set(&hp->port, NULL);
42870 @@ -406,9 +406,9 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
42871 */
42872 tty_wait_until_sent_from_close(tty, HVC_CLOSE_WAIT);
42873 } else {
42874 - if (hp->port.count < 0)
42875 + if (atomic_read(&hp->port.count) < 0)
42876 printk(KERN_ERR "hvc_close %X: oops, count is %d\n",
42877 - hp->vtermno, hp->port.count);
42878 + hp->vtermno, atomic_read(&hp->port.count));
42879 spin_unlock_irqrestore(&hp->port.lock, flags);
42880 }
42881 }
42882 @@ -438,12 +438,12 @@ static void hvc_hangup(struct tty_struct *tty)
42883 * open->hangup case this can be called after the final close so prevent
42884 * that from happening for now.
42885 */
42886 - if (hp->port.count <= 0) {
42887 + if (atomic_read(&hp->port.count) <= 0) {
42888 spin_unlock_irqrestore(&hp->port.lock, flags);
42889 return;
42890 }
42891
42892 - hp->port.count = 0;
42893 + atomic_set(&hp->port.count, 0);
42894 spin_unlock_irqrestore(&hp->port.lock, flags);
42895 tty_port_tty_set(&hp->port, NULL);
42896
42897 @@ -491,7 +491,7 @@ static int hvc_write(struct tty_struct *tty, const unsigned char *buf, int count
42898 return -EPIPE;
42899
42900 /* FIXME what's this (unprotected) check for? */
42901 - if (hp->port.count <= 0)
42902 + if (atomic_read(&hp->port.count) <= 0)
42903 return -EIO;
42904
42905 spin_lock_irqsave(&hp->lock, flags);
42906 diff --git a/drivers/tty/hvc/hvcs.c b/drivers/tty/hvc/hvcs.c
42907 index 81e939e..95ead10 100644
42908 --- a/drivers/tty/hvc/hvcs.c
42909 +++ b/drivers/tty/hvc/hvcs.c
42910 @@ -83,6 +83,7 @@
42911 #include <asm/hvcserver.h>
42912 #include <asm/uaccess.h>
42913 #include <asm/vio.h>
42914 +#include <asm/local.h>
42915
42916 /*
42917 * 1.3.0 -> 1.3.1 In hvcs_open memset(..,0x00,..) instead of memset(..,0x3F,00).
42918 @@ -416,7 +417,7 @@ static ssize_t hvcs_vterm_state_store(struct device *dev, struct device_attribut
42919
42920 spin_lock_irqsave(&hvcsd->lock, flags);
42921
42922 - if (hvcsd->port.count > 0) {
42923 + if (atomic_read(&hvcsd->port.count) > 0) {
42924 spin_unlock_irqrestore(&hvcsd->lock, flags);
42925 printk(KERN_INFO "HVCS: vterm state unchanged. "
42926 "The hvcs device node is still in use.\n");
42927 @@ -1127,7 +1128,7 @@ static int hvcs_install(struct tty_driver *driver, struct tty_struct *tty)
42928 }
42929 }
42930
42931 - hvcsd->port.count = 0;
42932 + atomic_set(&hvcsd->port.count, 0);
42933 hvcsd->port.tty = tty;
42934 tty->driver_data = hvcsd;
42935
42936 @@ -1180,7 +1181,7 @@ static int hvcs_open(struct tty_struct *tty, struct file *filp)
42937 unsigned long flags;
42938
42939 spin_lock_irqsave(&hvcsd->lock, flags);
42940 - hvcsd->port.count++;
42941 + atomic_inc(&hvcsd->port.count);
42942 hvcsd->todo_mask |= HVCS_SCHED_READ;
42943 spin_unlock_irqrestore(&hvcsd->lock, flags);
42944
42945 @@ -1216,7 +1217,7 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp)
42946 hvcsd = tty->driver_data;
42947
42948 spin_lock_irqsave(&hvcsd->lock, flags);
42949 - if (--hvcsd->port.count == 0) {
42950 + if (atomic_dec_and_test(&hvcsd->port.count)) {
42951
42952 vio_disable_interrupts(hvcsd->vdev);
42953
42954 @@ -1241,10 +1242,10 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp)
42955
42956 free_irq(irq, hvcsd);
42957 return;
42958 - } else if (hvcsd->port.count < 0) {
42959 + } else if (atomic_read(&hvcsd->port.count) < 0) {
42960 printk(KERN_ERR "HVCS: vty-server@%X open_count: %d"
42961 " is missmanaged.\n",
42962 - hvcsd->vdev->unit_address, hvcsd->port.count);
42963 + hvcsd->vdev->unit_address, atomic_read(&hvcsd->port.count));
42964 }
42965
42966 spin_unlock_irqrestore(&hvcsd->lock, flags);
42967 @@ -1266,7 +1267,7 @@ static void hvcs_hangup(struct tty_struct * tty)
42968
42969 spin_lock_irqsave(&hvcsd->lock, flags);
42970 /* Preserve this so that we know how many kref refs to put */
42971 - temp_open_count = hvcsd->port.count;
42972 + temp_open_count = atomic_read(&hvcsd->port.count);
42973
42974 /*
42975 * Don't kref put inside the spinlock because the destruction
42976 @@ -1281,7 +1282,7 @@ static void hvcs_hangup(struct tty_struct * tty)
42977 tty->driver_data = NULL;
42978 hvcsd->port.tty = NULL;
42979
42980 - hvcsd->port.count = 0;
42981 + atomic_set(&hvcsd->port.count, 0);
42982
42983 /* This will drop any buffered data on the floor which is OK in a hangup
42984 * scenario. */
42985 @@ -1352,7 +1353,7 @@ static int hvcs_write(struct tty_struct *tty,
42986 * the middle of a write operation? This is a crummy place to do this
42987 * but we want to keep it all in the spinlock.
42988 */
42989 - if (hvcsd->port.count <= 0) {
42990 + if (atomic_read(&hvcsd->port.count) <= 0) {
42991 spin_unlock_irqrestore(&hvcsd->lock, flags);
42992 return -ENODEV;
42993 }
42994 @@ -1426,7 +1427,7 @@ static int hvcs_write_room(struct tty_struct *tty)
42995 {
42996 struct hvcs_struct *hvcsd = tty->driver_data;
42997
42998 - if (!hvcsd || hvcsd->port.count <= 0)
42999 + if (!hvcsd || atomic_read(&hvcsd->port.count) <= 0)
43000 return 0;
43001
43002 return HVCS_BUFF_LEN - hvcsd->chars_in_buffer;
43003 diff --git a/drivers/tty/ipwireless/tty.c b/drivers/tty/ipwireless/tty.c
43004 index 8fd72ff..34a0bed 100644
43005 --- a/drivers/tty/ipwireless/tty.c
43006 +++ b/drivers/tty/ipwireless/tty.c
43007 @@ -29,6 +29,7 @@
43008 #include <linux/tty_driver.h>
43009 #include <linux/tty_flip.h>
43010 #include <linux/uaccess.h>
43011 +#include <asm/local.h>
43012
43013 #include "tty.h"
43014 #include "network.h"
43015 @@ -99,10 +100,10 @@ static int ipw_open(struct tty_struct *linux_tty, struct file *filp)
43016 mutex_unlock(&tty->ipw_tty_mutex);
43017 return -ENODEV;
43018 }
43019 - if (tty->port.count == 0)
43020 + if (atomic_read(&tty->port.count) == 0)
43021 tty->tx_bytes_queued = 0;
43022
43023 - tty->port.count++;
43024 + atomic_inc(&tty->port.count);
43025
43026 tty->port.tty = linux_tty;
43027 linux_tty->driver_data = tty;
43028 @@ -118,9 +119,7 @@ static int ipw_open(struct tty_struct *linux_tty, struct file *filp)
43029
43030 static void do_ipw_close(struct ipw_tty *tty)
43031 {
43032 - tty->port.count--;
43033 -
43034 - if (tty->port.count == 0) {
43035 + if (atomic_dec_return(&tty->port.count) == 0) {
43036 struct tty_struct *linux_tty = tty->port.tty;
43037
43038 if (linux_tty != NULL) {
43039 @@ -141,7 +140,7 @@ static void ipw_hangup(struct tty_struct *linux_tty)
43040 return;
43041
43042 mutex_lock(&tty->ipw_tty_mutex);
43043 - if (tty->port.count == 0) {
43044 + if (atomic_read(&tty->port.count) == 0) {
43045 mutex_unlock(&tty->ipw_tty_mutex);
43046 return;
43047 }
43048 @@ -164,7 +163,7 @@ void ipwireless_tty_received(struct ipw_tty *tty, unsigned char *data,
43049
43050 mutex_lock(&tty->ipw_tty_mutex);
43051
43052 - if (!tty->port.count) {
43053 + if (!atomic_read(&tty->port.count)) {
43054 mutex_unlock(&tty->ipw_tty_mutex);
43055 return;
43056 }
43057 @@ -206,7 +205,7 @@ static int ipw_write(struct tty_struct *linux_tty,
43058 return -ENODEV;
43059
43060 mutex_lock(&tty->ipw_tty_mutex);
43061 - if (!tty->port.count) {
43062 + if (!atomic_read(&tty->port.count)) {
43063 mutex_unlock(&tty->ipw_tty_mutex);
43064 return -EINVAL;
43065 }
43066 @@ -246,7 +245,7 @@ static int ipw_write_room(struct tty_struct *linux_tty)
43067 if (!tty)
43068 return -ENODEV;
43069
43070 - if (!tty->port.count)
43071 + if (!atomic_read(&tty->port.count))
43072 return -EINVAL;
43073
43074 room = IPWIRELESS_TX_QUEUE_SIZE - tty->tx_bytes_queued;
43075 @@ -288,7 +287,7 @@ static int ipw_chars_in_buffer(struct tty_struct *linux_tty)
43076 if (!tty)
43077 return 0;
43078
43079 - if (!tty->port.count)
43080 + if (!atomic_read(&tty->port.count))
43081 return 0;
43082
43083 return tty->tx_bytes_queued;
43084 @@ -369,7 +368,7 @@ static int ipw_tiocmget(struct tty_struct *linux_tty)
43085 if (!tty)
43086 return -ENODEV;
43087
43088 - if (!tty->port.count)
43089 + if (!atomic_read(&tty->port.count))
43090 return -EINVAL;
43091
43092 return get_control_lines(tty);
43093 @@ -385,7 +384,7 @@ ipw_tiocmset(struct tty_struct *linux_tty,
43094 if (!tty)
43095 return -ENODEV;
43096
43097 - if (!tty->port.count)
43098 + if (!atomic_read(&tty->port.count))
43099 return -EINVAL;
43100
43101 return set_control_lines(tty, set, clear);
43102 @@ -399,7 +398,7 @@ static int ipw_ioctl(struct tty_struct *linux_tty,
43103 if (!tty)
43104 return -ENODEV;
43105
43106 - if (!tty->port.count)
43107 + if (!atomic_read(&tty->port.count))
43108 return -EINVAL;
43109
43110 /* FIXME: Exactly how is the tty object locked here .. */
43111 @@ -555,7 +554,7 @@ void ipwireless_tty_free(struct ipw_tty *tty)
43112 * are gone */
43113 mutex_lock(&ttyj->ipw_tty_mutex);
43114 }
43115 - while (ttyj->port.count)
43116 + while (atomic_read(&ttyj->port.count))
43117 do_ipw_close(ttyj);
43118 ipwireless_disassociate_network_ttys(network,
43119 ttyj->channel_idx);
43120 diff --git a/drivers/tty/moxa.c b/drivers/tty/moxa.c
43121 index adeac25..787a0a1 100644
43122 --- a/drivers/tty/moxa.c
43123 +++ b/drivers/tty/moxa.c
43124 @@ -1193,7 +1193,7 @@ static int moxa_open(struct tty_struct *tty, struct file *filp)
43125 }
43126
43127 ch = &brd->ports[port % MAX_PORTS_PER_BOARD];
43128 - ch->port.count++;
43129 + atomic_inc(&ch->port.count);
43130 tty->driver_data = ch;
43131 tty_port_tty_set(&ch->port, tty);
43132 mutex_lock(&ch->port.mutex);
43133 diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
43134 index 4a43ef5d7..aa71f27 100644
43135 --- a/drivers/tty/n_gsm.c
43136 +++ b/drivers/tty/n_gsm.c
43137 @@ -1636,7 +1636,7 @@ static struct gsm_dlci *gsm_dlci_alloc(struct gsm_mux *gsm, int addr)
43138 spin_lock_init(&dlci->lock);
43139 mutex_init(&dlci->mutex);
43140 dlci->fifo = &dlci->_fifo;
43141 - if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL) < 0) {
43142 + if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL)) {
43143 kfree(dlci);
43144 return NULL;
43145 }
43146 @@ -2936,7 +2936,7 @@ static int gsmtty_open(struct tty_struct *tty, struct file *filp)
43147 struct gsm_dlci *dlci = tty->driver_data;
43148 struct tty_port *port = &dlci->port;
43149
43150 - port->count++;
43151 + atomic_inc(&port->count);
43152 dlci_get(dlci);
43153 dlci_get(dlci->gsm->dlci[0]);
43154 mux_get(dlci->gsm);
43155 diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
43156 index 05e72be..67f6a0f 100644
43157 --- a/drivers/tty/n_tty.c
43158 +++ b/drivers/tty/n_tty.c
43159 @@ -2197,6 +2197,7 @@ void n_tty_inherit_ops(struct tty_ldisc_ops *ops)
43160 {
43161 *ops = tty_ldisc_N_TTY;
43162 ops->owner = NULL;
43163 - ops->refcount = ops->flags = 0;
43164 + atomic_set(&ops->refcount, 0);
43165 + ops->flags = 0;
43166 }
43167 EXPORT_SYMBOL_GPL(n_tty_inherit_ops);
43168 diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
43169 index 125e0fd..8c50690 100644
43170 --- a/drivers/tty/pty.c
43171 +++ b/drivers/tty/pty.c
43172 @@ -800,8 +800,10 @@ static void __init unix98_pty_init(void)
43173 panic("Couldn't register Unix98 pts driver");
43174
43175 /* Now create the /dev/ptmx special device */
43176 + pax_open_kernel();
43177 tty_default_fops(&ptmx_fops);
43178 - ptmx_fops.open = ptmx_open;
43179 + *(void **)&ptmx_fops.open = ptmx_open;
43180 + pax_close_kernel();
43181
43182 cdev_init(&ptmx_cdev, &ptmx_fops);
43183 if (cdev_add(&ptmx_cdev, MKDEV(TTYAUX_MAJOR, 2), 1) ||
43184 diff --git a/drivers/tty/rocket.c b/drivers/tty/rocket.c
43185 index 1d27003..959f452 100644
43186 --- a/drivers/tty/rocket.c
43187 +++ b/drivers/tty/rocket.c
43188 @@ -923,7 +923,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
43189 tty->driver_data = info;
43190 tty_port_tty_set(port, tty);
43191
43192 - if (port->count++ == 0) {
43193 + if (atomic_inc_return(&port->count) == 1) {
43194 atomic_inc(&rp_num_ports_open);
43195
43196 #ifdef ROCKET_DEBUG_OPEN
43197 @@ -932,7 +932,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
43198 #endif
43199 }
43200 #ifdef ROCKET_DEBUG_OPEN
43201 - printk(KERN_INFO "rp_open ttyR%d, count=%d\n", info->line, info->port.count);
43202 + printk(KERN_INFO "rp_open ttyR%d, count=%d\n", info->line, atomic-read(&info->port.count));
43203 #endif
43204
43205 /*
43206 @@ -1527,7 +1527,7 @@ static void rp_hangup(struct tty_struct *tty)
43207 spin_unlock_irqrestore(&info->port.lock, flags);
43208 return;
43209 }
43210 - if (info->port.count)
43211 + if (atomic_read(&info->port.count))
43212 atomic_dec(&rp_num_ports_open);
43213 clear_bit((info->aiop * 8) + info->chan, (void *) &xmit_flags[info->board]);
43214 spin_unlock_irqrestore(&info->port.lock, flags);
43215 diff --git a/drivers/tty/serial/kgdboc.c b/drivers/tty/serial/kgdboc.c
43216 index 1002054..dd644a8 100644
43217 --- a/drivers/tty/serial/kgdboc.c
43218 +++ b/drivers/tty/serial/kgdboc.c
43219 @@ -24,8 +24,9 @@
43220 #define MAX_CONFIG_LEN 40
43221
43222 static struct kgdb_io kgdboc_io_ops;
43223 +static struct kgdb_io kgdboc_io_ops_console;
43224
43225 -/* -1 = init not run yet, 0 = unconfigured, 1 = configured. */
43226 +/* -1 = init not run yet, 0 = unconfigured, 1/2 = configured. */
43227 static int configured = -1;
43228
43229 static char config[MAX_CONFIG_LEN];
43230 @@ -151,6 +152,8 @@ static void cleanup_kgdboc(void)
43231 kgdboc_unregister_kbd();
43232 if (configured == 1)
43233 kgdb_unregister_io_module(&kgdboc_io_ops);
43234 + else if (configured == 2)
43235 + kgdb_unregister_io_module(&kgdboc_io_ops_console);
43236 }
43237
43238 static int configure_kgdboc(void)
43239 @@ -160,13 +163,13 @@ static int configure_kgdboc(void)
43240 int err;
43241 char *cptr = config;
43242 struct console *cons;
43243 + int is_console = 0;
43244
43245 err = kgdboc_option_setup(config);
43246 if (err || !strlen(config) || isspace(config[0]))
43247 goto noconfig;
43248
43249 err = -ENODEV;
43250 - kgdboc_io_ops.is_console = 0;
43251 kgdb_tty_driver = NULL;
43252
43253 kgdboc_use_kms = 0;
43254 @@ -187,7 +190,7 @@ static int configure_kgdboc(void)
43255 int idx;
43256 if (cons->device && cons->device(cons, &idx) == p &&
43257 idx == tty_line) {
43258 - kgdboc_io_ops.is_console = 1;
43259 + is_console = 1;
43260 break;
43261 }
43262 cons = cons->next;
43263 @@ -197,7 +200,13 @@ static int configure_kgdboc(void)
43264 kgdb_tty_line = tty_line;
43265
43266 do_register:
43267 - err = kgdb_register_io_module(&kgdboc_io_ops);
43268 + if (is_console) {
43269 + err = kgdb_register_io_module(&kgdboc_io_ops_console);
43270 + configured = 2;
43271 + } else {
43272 + err = kgdb_register_io_module(&kgdboc_io_ops);
43273 + configured = 1;
43274 + }
43275 if (err)
43276 goto noconfig;
43277
43278 @@ -205,8 +214,6 @@ do_register:
43279 if (err)
43280 goto nmi_con_failed;
43281
43282 - configured = 1;
43283 -
43284 return 0;
43285
43286 nmi_con_failed:
43287 @@ -223,7 +230,7 @@ noconfig:
43288 static int __init init_kgdboc(void)
43289 {
43290 /* Already configured? */
43291 - if (configured == 1)
43292 + if (configured >= 1)
43293 return 0;
43294
43295 return configure_kgdboc();
43296 @@ -272,7 +279,7 @@ static int param_set_kgdboc_var(const char *kmessage, struct kernel_param *kp)
43297 if (config[len - 1] == '\n')
43298 config[len - 1] = '\0';
43299
43300 - if (configured == 1)
43301 + if (configured >= 1)
43302 cleanup_kgdboc();
43303
43304 /* Go and configure with the new params. */
43305 @@ -312,6 +319,15 @@ static struct kgdb_io kgdboc_io_ops = {
43306 .post_exception = kgdboc_post_exp_handler,
43307 };
43308
43309 +static struct kgdb_io kgdboc_io_ops_console = {
43310 + .name = "kgdboc",
43311 + .read_char = kgdboc_get_char,
43312 + .write_char = kgdboc_put_char,
43313 + .pre_exception = kgdboc_pre_exp_handler,
43314 + .post_exception = kgdboc_post_exp_handler,
43315 + .is_console = 1
43316 +};
43317 +
43318 #ifdef CONFIG_KGDB_SERIAL_CONSOLE
43319 /* This is only available if kgdboc is a built in for early debugging */
43320 static int __init kgdboc_early_init(char *opt)
43321 diff --git a/drivers/tty/serial/samsung.c b/drivers/tty/serial/samsung.c
43322 index 2769a38..f3dbe48 100644
43323 --- a/drivers/tty/serial/samsung.c
43324 +++ b/drivers/tty/serial/samsung.c
43325 @@ -451,11 +451,16 @@ static void s3c24xx_serial_shutdown(struct uart_port *port)
43326 }
43327 }
43328
43329 +static int s3c64xx_serial_startup(struct uart_port *port);
43330 static int s3c24xx_serial_startup(struct uart_port *port)
43331 {
43332 struct s3c24xx_uart_port *ourport = to_ourport(port);
43333 int ret;
43334
43335 + /* Startup sequence is different for s3c64xx and higher SoC's */
43336 + if (s3c24xx_serial_has_interrupt_mask(port))
43337 + return s3c64xx_serial_startup(port);
43338 +
43339 dbg("s3c24xx_serial_startup: port=%p (%08lx,%p)\n",
43340 port->mapbase, port->membase);
43341
43342 @@ -1120,10 +1125,6 @@ static int s3c24xx_serial_init_port(struct s3c24xx_uart_port *ourport,
43343 /* setup info for port */
43344 port->dev = &platdev->dev;
43345
43346 - /* Startup sequence is different for s3c64xx and higher SoC's */
43347 - if (s3c24xx_serial_has_interrupt_mask(port))
43348 - s3c24xx_serial_ops.startup = s3c64xx_serial_startup;
43349 -
43350 port->uartclk = 1;
43351
43352 if (cfg->uart_flags & UPF_CONS_FLOW) {
43353 diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
43354 index 8fbb6d2..822a9e6 100644
43355 --- a/drivers/tty/serial/serial_core.c
43356 +++ b/drivers/tty/serial/serial_core.c
43357 @@ -1454,7 +1454,7 @@ static void uart_hangup(struct tty_struct *tty)
43358 uart_flush_buffer(tty);
43359 uart_shutdown(tty, state);
43360 spin_lock_irqsave(&port->lock, flags);
43361 - port->count = 0;
43362 + atomic_set(&port->count, 0);
43363 clear_bit(ASYNCB_NORMAL_ACTIVE, &port->flags);
43364 spin_unlock_irqrestore(&port->lock, flags);
43365 tty_port_tty_set(port, NULL);
43366 @@ -1550,7 +1550,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
43367 goto end;
43368 }
43369
43370 - port->count++;
43371 + atomic_inc(&port->count);
43372 if (!state->uart_port || state->uart_port->flags & UPF_DEAD) {
43373 retval = -ENXIO;
43374 goto err_dec_count;
43375 @@ -1578,7 +1578,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
43376 /*
43377 * Make sure the device is in D0 state.
43378 */
43379 - if (port->count == 1)
43380 + if (atomic_read(&port->count) == 1)
43381 uart_change_pm(state, UART_PM_STATE_ON);
43382
43383 /*
43384 @@ -1596,7 +1596,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
43385 end:
43386 return retval;
43387 err_dec_count:
43388 - port->count--;
43389 + atomic_inc(&port->count);
43390 mutex_unlock(&port->mutex);
43391 goto end;
43392 }
43393 diff --git a/drivers/tty/synclink.c b/drivers/tty/synclink.c
43394 index 8983276..72a4090 100644
43395 --- a/drivers/tty/synclink.c
43396 +++ b/drivers/tty/synclink.c
43397 @@ -3093,7 +3093,7 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
43398
43399 if (debug_level >= DEBUG_LEVEL_INFO)
43400 printk("%s(%d):mgsl_close(%s) entry, count=%d\n",
43401 - __FILE__,__LINE__, info->device_name, info->port.count);
43402 + __FILE__,__LINE__, info->device_name, atomic_read(&info->port.count));
43403
43404 if (tty_port_close_start(&info->port, tty, filp) == 0)
43405 goto cleanup;
43406 @@ -3111,7 +3111,7 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
43407 cleanup:
43408 if (debug_level >= DEBUG_LEVEL_INFO)
43409 printk("%s(%d):mgsl_close(%s) exit, count=%d\n", __FILE__,__LINE__,
43410 - tty->driver->name, info->port.count);
43411 + tty->driver->name, atomic_read(&info->port.count));
43412
43413 } /* end of mgsl_close() */
43414
43415 @@ -3210,8 +3210,8 @@ static void mgsl_hangup(struct tty_struct *tty)
43416
43417 mgsl_flush_buffer(tty);
43418 shutdown(info);
43419 -
43420 - info->port.count = 0;
43421 +
43422 + atomic_set(&info->port.count, 0);
43423 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
43424 info->port.tty = NULL;
43425
43426 @@ -3300,12 +3300,12 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
43427
43428 if (debug_level >= DEBUG_LEVEL_INFO)
43429 printk("%s(%d):block_til_ready before block on %s count=%d\n",
43430 - __FILE__,__LINE__, tty->driver->name, port->count );
43431 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
43432
43433 spin_lock_irqsave(&info->irq_spinlock, flags);
43434 if (!tty_hung_up_p(filp)) {
43435 extra_count = true;
43436 - port->count--;
43437 + atomic_dec(&port->count);
43438 }
43439 spin_unlock_irqrestore(&info->irq_spinlock, flags);
43440 port->blocked_open++;
43441 @@ -3334,7 +3334,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
43442
43443 if (debug_level >= DEBUG_LEVEL_INFO)
43444 printk("%s(%d):block_til_ready blocking on %s count=%d\n",
43445 - __FILE__,__LINE__, tty->driver->name, port->count );
43446 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
43447
43448 tty_unlock(tty);
43449 schedule();
43450 @@ -3346,12 +3346,12 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
43451
43452 /* FIXME: Racy on hangup during close wait */
43453 if (extra_count)
43454 - port->count++;
43455 + atomic_inc(&port->count);
43456 port->blocked_open--;
43457
43458 if (debug_level >= DEBUG_LEVEL_INFO)
43459 printk("%s(%d):block_til_ready after blocking on %s count=%d\n",
43460 - __FILE__,__LINE__, tty->driver->name, port->count );
43461 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
43462
43463 if (!retval)
43464 port->flags |= ASYNC_NORMAL_ACTIVE;
43465 @@ -3403,7 +3403,7 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
43466
43467 if (debug_level >= DEBUG_LEVEL_INFO)
43468 printk("%s(%d):mgsl_open(%s), old ref count = %d\n",
43469 - __FILE__,__LINE__,tty->driver->name, info->port.count);
43470 + __FILE__,__LINE__,tty->driver->name, atomic_read(&info->port.count));
43471
43472 /* If port is closing, signal caller to try again */
43473 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
43474 @@ -3422,10 +3422,10 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
43475 spin_unlock_irqrestore(&info->netlock, flags);
43476 goto cleanup;
43477 }
43478 - info->port.count++;
43479 + atomic_inc(&info->port.count);
43480 spin_unlock_irqrestore(&info->netlock, flags);
43481
43482 - if (info->port.count == 1) {
43483 + if (atomic_read(&info->port.count) == 1) {
43484 /* 1st open on this device, init hardware */
43485 retval = startup(info);
43486 if (retval < 0)
43487 @@ -3449,8 +3449,8 @@ cleanup:
43488 if (retval) {
43489 if (tty->count == 1)
43490 info->port.tty = NULL; /* tty layer will release tty struct */
43491 - if(info->port.count)
43492 - info->port.count--;
43493 + if (atomic_read(&info->port.count))
43494 + atomic_dec(&info->port.count);
43495 }
43496
43497 return retval;
43498 @@ -7668,7 +7668,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
43499 unsigned short new_crctype;
43500
43501 /* return error if TTY interface open */
43502 - if (info->port.count)
43503 + if (atomic_read(&info->port.count))
43504 return -EBUSY;
43505
43506 switch (encoding)
43507 @@ -7763,7 +7763,7 @@ static int hdlcdev_open(struct net_device *dev)
43508
43509 /* arbitrate between network and tty opens */
43510 spin_lock_irqsave(&info->netlock, flags);
43511 - if (info->port.count != 0 || info->netcount != 0) {
43512 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
43513 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
43514 spin_unlock_irqrestore(&info->netlock, flags);
43515 return -EBUSY;
43516 @@ -7849,7 +7849,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
43517 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
43518
43519 /* return error if TTY interface open */
43520 - if (info->port.count)
43521 + if (atomic_read(&info->port.count))
43522 return -EBUSY;
43523
43524 if (cmd != SIOCWANDEV)
43525 diff --git a/drivers/tty/synclink_gt.c b/drivers/tty/synclink_gt.c
43526 index aa9eece..d8baaec 100644
43527 --- a/drivers/tty/synclink_gt.c
43528 +++ b/drivers/tty/synclink_gt.c
43529 @@ -670,7 +670,7 @@ static int open(struct tty_struct *tty, struct file *filp)
43530 tty->driver_data = info;
43531 info->port.tty = tty;
43532
43533 - DBGINFO(("%s open, old ref count = %d\n", info->device_name, info->port.count));
43534 + DBGINFO(("%s open, old ref count = %d\n", info->device_name, atomic_read(&info->port.count)));
43535
43536 /* If port is closing, signal caller to try again */
43537 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
43538 @@ -691,10 +691,10 @@ static int open(struct tty_struct *tty, struct file *filp)
43539 mutex_unlock(&info->port.mutex);
43540 goto cleanup;
43541 }
43542 - info->port.count++;
43543 + atomic_inc(&info->port.count);
43544 spin_unlock_irqrestore(&info->netlock, flags);
43545
43546 - if (info->port.count == 1) {
43547 + if (atomic_read(&info->port.count) == 1) {
43548 /* 1st open on this device, init hardware */
43549 retval = startup(info);
43550 if (retval < 0) {
43551 @@ -715,8 +715,8 @@ cleanup:
43552 if (retval) {
43553 if (tty->count == 1)
43554 info->port.tty = NULL; /* tty layer will release tty struct */
43555 - if(info->port.count)
43556 - info->port.count--;
43557 + if(atomic_read(&info->port.count))
43558 + atomic_dec(&info->port.count);
43559 }
43560
43561 DBGINFO(("%s open rc=%d\n", info->device_name, retval));
43562 @@ -729,7 +729,7 @@ static void close(struct tty_struct *tty, struct file *filp)
43563
43564 if (sanity_check(info, tty->name, "close"))
43565 return;
43566 - DBGINFO(("%s close entry, count=%d\n", info->device_name, info->port.count));
43567 + DBGINFO(("%s close entry, count=%d\n", info->device_name, atomic_read(&info->port.count)));
43568
43569 if (tty_port_close_start(&info->port, tty, filp) == 0)
43570 goto cleanup;
43571 @@ -746,7 +746,7 @@ static void close(struct tty_struct *tty, struct file *filp)
43572 tty_port_close_end(&info->port, tty);
43573 info->port.tty = NULL;
43574 cleanup:
43575 - DBGINFO(("%s close exit, count=%d\n", tty->driver->name, info->port.count));
43576 + DBGINFO(("%s close exit, count=%d\n", tty->driver->name, atomic_read(&info->port.count)));
43577 }
43578
43579 static void hangup(struct tty_struct *tty)
43580 @@ -764,7 +764,7 @@ static void hangup(struct tty_struct *tty)
43581 shutdown(info);
43582
43583 spin_lock_irqsave(&info->port.lock, flags);
43584 - info->port.count = 0;
43585 + atomic_set(&info->port.count, 0);
43586 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
43587 info->port.tty = NULL;
43588 spin_unlock_irqrestore(&info->port.lock, flags);
43589 @@ -1449,7 +1449,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
43590 unsigned short new_crctype;
43591
43592 /* return error if TTY interface open */
43593 - if (info->port.count)
43594 + if (atomic_read(&info->port.count))
43595 return -EBUSY;
43596
43597 DBGINFO(("%s hdlcdev_attach\n", info->device_name));
43598 @@ -1544,7 +1544,7 @@ static int hdlcdev_open(struct net_device *dev)
43599
43600 /* arbitrate between network and tty opens */
43601 spin_lock_irqsave(&info->netlock, flags);
43602 - if (info->port.count != 0 || info->netcount != 0) {
43603 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
43604 DBGINFO(("%s hdlc_open busy\n", dev->name));
43605 spin_unlock_irqrestore(&info->netlock, flags);
43606 return -EBUSY;
43607 @@ -1629,7 +1629,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
43608 DBGINFO(("%s hdlcdev_ioctl\n", dev->name));
43609
43610 /* return error if TTY interface open */
43611 - if (info->port.count)
43612 + if (atomic_read(&info->port.count))
43613 return -EBUSY;
43614
43615 if (cmd != SIOCWANDEV)
43616 @@ -2413,7 +2413,7 @@ static irqreturn_t slgt_interrupt(int dummy, void *dev_id)
43617 if (port == NULL)
43618 continue;
43619 spin_lock(&port->lock);
43620 - if ((port->port.count || port->netcount) &&
43621 + if ((atomic_read(&port->port.count) || port->netcount) &&
43622 port->pending_bh && !port->bh_running &&
43623 !port->bh_requested) {
43624 DBGISR(("%s bh queued\n", port->device_name));
43625 @@ -3302,7 +3302,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
43626 spin_lock_irqsave(&info->lock, flags);
43627 if (!tty_hung_up_p(filp)) {
43628 extra_count = true;
43629 - port->count--;
43630 + atomic_dec(&port->count);
43631 }
43632 spin_unlock_irqrestore(&info->lock, flags);
43633 port->blocked_open++;
43634 @@ -3339,7 +3339,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
43635 remove_wait_queue(&port->open_wait, &wait);
43636
43637 if (extra_count)
43638 - port->count++;
43639 + atomic_inc(&port->count);
43640 port->blocked_open--;
43641
43642 if (!retval)
43643 diff --git a/drivers/tty/synclinkmp.c b/drivers/tty/synclinkmp.c
43644 index 6d5780c..aa4d8cd 100644
43645 --- a/drivers/tty/synclinkmp.c
43646 +++ b/drivers/tty/synclinkmp.c
43647 @@ -750,7 +750,7 @@ static int open(struct tty_struct *tty, struct file *filp)
43648
43649 if (debug_level >= DEBUG_LEVEL_INFO)
43650 printk("%s(%d):%s open(), old ref count = %d\n",
43651 - __FILE__,__LINE__,tty->driver->name, info->port.count);
43652 + __FILE__,__LINE__,tty->driver->name, atomic_read(&info->port.count));
43653
43654 /* If port is closing, signal caller to try again */
43655 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
43656 @@ -769,10 +769,10 @@ static int open(struct tty_struct *tty, struct file *filp)
43657 spin_unlock_irqrestore(&info->netlock, flags);
43658 goto cleanup;
43659 }
43660 - info->port.count++;
43661 + atomic_inc(&info->port.count);
43662 spin_unlock_irqrestore(&info->netlock, flags);
43663
43664 - if (info->port.count == 1) {
43665 + if (atomic_read(&info->port.count) == 1) {
43666 /* 1st open on this device, init hardware */
43667 retval = startup(info);
43668 if (retval < 0)
43669 @@ -796,8 +796,8 @@ cleanup:
43670 if (retval) {
43671 if (tty->count == 1)
43672 info->port.tty = NULL; /* tty layer will release tty struct */
43673 - if(info->port.count)
43674 - info->port.count--;
43675 + if(atomic_read(&info->port.count))
43676 + atomic_dec(&info->port.count);
43677 }
43678
43679 return retval;
43680 @@ -815,7 +815,7 @@ static void close(struct tty_struct *tty, struct file *filp)
43681
43682 if (debug_level >= DEBUG_LEVEL_INFO)
43683 printk("%s(%d):%s close() entry, count=%d\n",
43684 - __FILE__,__LINE__, info->device_name, info->port.count);
43685 + __FILE__,__LINE__, info->device_name, atomic_read(&info->port.count));
43686
43687 if (tty_port_close_start(&info->port, tty, filp) == 0)
43688 goto cleanup;
43689 @@ -834,7 +834,7 @@ static void close(struct tty_struct *tty, struct file *filp)
43690 cleanup:
43691 if (debug_level >= DEBUG_LEVEL_INFO)
43692 printk("%s(%d):%s close() exit, count=%d\n", __FILE__,__LINE__,
43693 - tty->driver->name, info->port.count);
43694 + tty->driver->name, atomic_read(&info->port.count));
43695 }
43696
43697 /* Called by tty_hangup() when a hangup is signaled.
43698 @@ -857,7 +857,7 @@ static void hangup(struct tty_struct *tty)
43699 shutdown(info);
43700
43701 spin_lock_irqsave(&info->port.lock, flags);
43702 - info->port.count = 0;
43703 + atomic_set(&info->port.count, 0);
43704 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
43705 info->port.tty = NULL;
43706 spin_unlock_irqrestore(&info->port.lock, flags);
43707 @@ -1565,7 +1565,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
43708 unsigned short new_crctype;
43709
43710 /* return error if TTY interface open */
43711 - if (info->port.count)
43712 + if (atomic_read(&info->port.count))
43713 return -EBUSY;
43714
43715 switch (encoding)
43716 @@ -1660,7 +1660,7 @@ static int hdlcdev_open(struct net_device *dev)
43717
43718 /* arbitrate between network and tty opens */
43719 spin_lock_irqsave(&info->netlock, flags);
43720 - if (info->port.count != 0 || info->netcount != 0) {
43721 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
43722 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
43723 spin_unlock_irqrestore(&info->netlock, flags);
43724 return -EBUSY;
43725 @@ -1746,7 +1746,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
43726 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
43727
43728 /* return error if TTY interface open */
43729 - if (info->port.count)
43730 + if (atomic_read(&info->port.count))
43731 return -EBUSY;
43732
43733 if (cmd != SIOCWANDEV)
43734 @@ -2620,7 +2620,7 @@ static irqreturn_t synclinkmp_interrupt(int dummy, void *dev_id)
43735 * do not request bottom half processing if the
43736 * device is not open in a normal mode.
43737 */
43738 - if ( port && (port->port.count || port->netcount) &&
43739 + if ( port && (atomic_read(&port->port.count) || port->netcount) &&
43740 port->pending_bh && !port->bh_running &&
43741 !port->bh_requested ) {
43742 if ( debug_level >= DEBUG_LEVEL_ISR )
43743 @@ -3318,12 +3318,12 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
43744
43745 if (debug_level >= DEBUG_LEVEL_INFO)
43746 printk("%s(%d):%s block_til_ready() before block, count=%d\n",
43747 - __FILE__,__LINE__, tty->driver->name, port->count );
43748 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
43749
43750 spin_lock_irqsave(&info->lock, flags);
43751 if (!tty_hung_up_p(filp)) {
43752 extra_count = true;
43753 - port->count--;
43754 + atomic_dec(&port->count);
43755 }
43756 spin_unlock_irqrestore(&info->lock, flags);
43757 port->blocked_open++;
43758 @@ -3352,7 +3352,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
43759
43760 if (debug_level >= DEBUG_LEVEL_INFO)
43761 printk("%s(%d):%s block_til_ready() count=%d\n",
43762 - __FILE__,__LINE__, tty->driver->name, port->count );
43763 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
43764
43765 tty_unlock(tty);
43766 schedule();
43767 @@ -3363,12 +3363,12 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
43768 remove_wait_queue(&port->open_wait, &wait);
43769
43770 if (extra_count)
43771 - port->count++;
43772 + atomic_inc(&port->count);
43773 port->blocked_open--;
43774
43775 if (debug_level >= DEBUG_LEVEL_INFO)
43776 printk("%s(%d):%s block_til_ready() after, count=%d\n",
43777 - __FILE__,__LINE__, tty->driver->name, port->count );
43778 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
43779
43780 if (!retval)
43781 port->flags |= ASYNC_NORMAL_ACTIVE;
43782 diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c
43783 index 3687f0c..6b9b808 100644
43784 --- a/drivers/tty/sysrq.c
43785 +++ b/drivers/tty/sysrq.c
43786 @@ -995,7 +995,7 @@ EXPORT_SYMBOL(unregister_sysrq_key);
43787 static ssize_t write_sysrq_trigger(struct file *file, const char __user *buf,
43788 size_t count, loff_t *ppos)
43789 {
43790 - if (count) {
43791 + if (count && capable(CAP_SYS_ADMIN)) {
43792 char c;
43793
43794 if (get_user(c, buf))
43795 diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
43796 index a9cd0b9..47b9336 100644
43797 --- a/drivers/tty/tty_io.c
43798 +++ b/drivers/tty/tty_io.c
43799 @@ -3398,7 +3398,7 @@ EXPORT_SYMBOL_GPL(get_current_tty);
43800
43801 void tty_default_fops(struct file_operations *fops)
43802 {
43803 - *fops = tty_fops;
43804 + memcpy((void *)fops, &tty_fops, sizeof(tty_fops));
43805 }
43806
43807 /*
43808 diff --git a/drivers/tty/tty_ldisc.c b/drivers/tty/tty_ldisc.c
43809 index d794087..e4f49e5 100644
43810 --- a/drivers/tty/tty_ldisc.c
43811 +++ b/drivers/tty/tty_ldisc.c
43812 @@ -56,7 +56,7 @@ static void put_ldisc(struct tty_ldisc *ld)
43813 if (atomic_dec_and_test(&ld->users)) {
43814 struct tty_ldisc_ops *ldo = ld->ops;
43815
43816 - ldo->refcount--;
43817 + atomic_dec(&ldo->refcount);
43818 module_put(ldo->owner);
43819 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
43820
43821 @@ -93,7 +93,7 @@ int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc)
43822 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
43823 tty_ldiscs[disc] = new_ldisc;
43824 new_ldisc->num = disc;
43825 - new_ldisc->refcount = 0;
43826 + atomic_set(&new_ldisc->refcount, 0);
43827 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
43828
43829 return ret;
43830 @@ -121,7 +121,7 @@ int tty_unregister_ldisc(int disc)
43831 return -EINVAL;
43832
43833 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
43834 - if (tty_ldiscs[disc]->refcount)
43835 + if (atomic_read(&tty_ldiscs[disc]->refcount))
43836 ret = -EBUSY;
43837 else
43838 tty_ldiscs[disc] = NULL;
43839 @@ -142,7 +142,7 @@ static struct tty_ldisc_ops *get_ldops(int disc)
43840 if (ldops) {
43841 ret = ERR_PTR(-EAGAIN);
43842 if (try_module_get(ldops->owner)) {
43843 - ldops->refcount++;
43844 + atomic_inc(&ldops->refcount);
43845 ret = ldops;
43846 }
43847 }
43848 @@ -155,7 +155,7 @@ static void put_ldops(struct tty_ldisc_ops *ldops)
43849 unsigned long flags;
43850
43851 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
43852 - ldops->refcount--;
43853 + atomic_dec(&ldops->refcount);
43854 module_put(ldops->owner);
43855 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
43856 }
43857 diff --git a/drivers/tty/tty_port.c b/drivers/tty/tty_port.c
43858 index b7ff59d..7c6105e 100644
43859 --- a/drivers/tty/tty_port.c
43860 +++ b/drivers/tty/tty_port.c
43861 @@ -218,7 +218,7 @@ void tty_port_hangup(struct tty_port *port)
43862 unsigned long flags;
43863
43864 spin_lock_irqsave(&port->lock, flags);
43865 - port->count = 0;
43866 + atomic_set(&port->count, 0);
43867 port->flags &= ~ASYNC_NORMAL_ACTIVE;
43868 if (port->tty) {
43869 set_bit(TTY_IO_ERROR, &port->tty->flags);
43870 @@ -344,7 +344,7 @@ int tty_port_block_til_ready(struct tty_port *port,
43871 /* The port lock protects the port counts */
43872 spin_lock_irqsave(&port->lock, flags);
43873 if (!tty_hung_up_p(filp))
43874 - port->count--;
43875 + atomic_dec(&port->count);
43876 port->blocked_open++;
43877 spin_unlock_irqrestore(&port->lock, flags);
43878
43879 @@ -386,7 +386,7 @@ int tty_port_block_til_ready(struct tty_port *port,
43880 we must not mess that up further */
43881 spin_lock_irqsave(&port->lock, flags);
43882 if (!tty_hung_up_p(filp))
43883 - port->count++;
43884 + atomic_inc(&port->count);
43885 port->blocked_open--;
43886 if (retval == 0)
43887 port->flags |= ASYNC_NORMAL_ACTIVE;
43888 @@ -406,19 +406,19 @@ int tty_port_close_start(struct tty_port *port,
43889 return 0;
43890 }
43891
43892 - if (tty->count == 1 && port->count != 1) {
43893 + if (tty->count == 1 && atomic_read(&port->count) != 1) {
43894 printk(KERN_WARNING
43895 "tty_port_close_start: tty->count = 1 port count = %d.\n",
43896 - port->count);
43897 - port->count = 1;
43898 + atomic_read(&port->count));
43899 + atomic_set(&port->count, 1);
43900 }
43901 - if (--port->count < 0) {
43902 + if (atomic_dec_return(&port->count) < 0) {
43903 printk(KERN_WARNING "tty_port_close_start: count = %d\n",
43904 - port->count);
43905 - port->count = 0;
43906 + atomic_read(&port->count));
43907 + atomic_set(&port->count, 0);
43908 }
43909
43910 - if (port->count) {
43911 + if (atomic_read(&port->count)) {
43912 spin_unlock_irqrestore(&port->lock, flags);
43913 if (port->ops->drop)
43914 port->ops->drop(port);
43915 @@ -516,7 +516,7 @@ int tty_port_open(struct tty_port *port, struct tty_struct *tty,
43916 {
43917 spin_lock_irq(&port->lock);
43918 if (!tty_hung_up_p(filp))
43919 - ++port->count;
43920 + atomic_inc(&port->count);
43921 spin_unlock_irq(&port->lock);
43922 tty_port_tty_set(port, tty);
43923
43924 diff --git a/drivers/tty/vt/keyboard.c b/drivers/tty/vt/keyboard.c
43925 index a9af1b9a..1e08e7f 100644
43926 --- a/drivers/tty/vt/keyboard.c
43927 +++ b/drivers/tty/vt/keyboard.c
43928 @@ -647,6 +647,16 @@ static void k_spec(struct vc_data *vc, unsigned char value, char up_flag)
43929 kbd->kbdmode == VC_OFF) &&
43930 value != KVAL(K_SAK))
43931 return; /* SAK is allowed even in raw mode */
43932 +
43933 +#if defined(CONFIG_GRKERNSEC_PROC) || defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
43934 + {
43935 + void *func = fn_handler[value];
43936 + if (func == fn_show_state || func == fn_show_ptregs ||
43937 + func == fn_show_mem)
43938 + return;
43939 + }
43940 +#endif
43941 +
43942 fn_handler[value](vc);
43943 }
43944
43945 @@ -1795,9 +1805,6 @@ int vt_do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm,
43946 if (copy_from_user(&tmp, user_kbe, sizeof(struct kbentry)))
43947 return -EFAULT;
43948
43949 - if (!capable(CAP_SYS_TTY_CONFIG))
43950 - perm = 0;
43951 -
43952 switch (cmd) {
43953 case KDGKBENT:
43954 /* Ensure another thread doesn't free it under us */
43955 @@ -1812,6 +1819,9 @@ int vt_do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm,
43956 spin_unlock_irqrestore(&kbd_event_lock, flags);
43957 return put_user(val, &user_kbe->kb_value);
43958 case KDSKBENT:
43959 + if (!capable(CAP_SYS_TTY_CONFIG))
43960 + perm = 0;
43961 +
43962 if (!perm)
43963 return -EPERM;
43964 if (!i && v == K_NOSUCHMAP) {
43965 @@ -1902,9 +1912,6 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
43966 int i, j, k;
43967 int ret;
43968
43969 - if (!capable(CAP_SYS_TTY_CONFIG))
43970 - perm = 0;
43971 -
43972 kbs = kmalloc(sizeof(*kbs), GFP_KERNEL);
43973 if (!kbs) {
43974 ret = -ENOMEM;
43975 @@ -1938,6 +1945,9 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
43976 kfree(kbs);
43977 return ((p && *p) ? -EOVERFLOW : 0);
43978 case KDSKBSENT:
43979 + if (!capable(CAP_SYS_TTY_CONFIG))
43980 + perm = 0;
43981 +
43982 if (!perm) {
43983 ret = -EPERM;
43984 goto reterr;
43985 diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
43986 index c8b9262..7e824e6 100644
43987 --- a/drivers/uio/uio.c
43988 +++ b/drivers/uio/uio.c
43989 @@ -25,6 +25,7 @@
43990 #include <linux/kobject.h>
43991 #include <linux/cdev.h>
43992 #include <linux/uio_driver.h>
43993 +#include <asm/local.h>
43994
43995 #define UIO_MAX_DEVICES (1U << MINORBITS)
43996
43997 @@ -32,10 +33,10 @@ struct uio_device {
43998 struct module *owner;
43999 struct device *dev;
44000 int minor;
44001 - atomic_t event;
44002 + atomic_unchecked_t event;
44003 struct fasync_struct *async_queue;
44004 wait_queue_head_t wait;
44005 - int vma_count;
44006 + local_t vma_count;
44007 struct uio_info *info;
44008 struct kobject *map_dir;
44009 struct kobject *portio_dir;
44010 @@ -242,7 +243,7 @@ static ssize_t show_event(struct device *dev,
44011 struct device_attribute *attr, char *buf)
44012 {
44013 struct uio_device *idev = dev_get_drvdata(dev);
44014 - return sprintf(buf, "%u\n", (unsigned int)atomic_read(&idev->event));
44015 + return sprintf(buf, "%u\n", (unsigned int)atomic_read_unchecked(&idev->event));
44016 }
44017
44018 static struct device_attribute uio_class_attributes[] = {
44019 @@ -397,7 +398,7 @@ void uio_event_notify(struct uio_info *info)
44020 {
44021 struct uio_device *idev = info->uio_dev;
44022
44023 - atomic_inc(&idev->event);
44024 + atomic_inc_unchecked(&idev->event);
44025 wake_up_interruptible(&idev->wait);
44026 kill_fasync(&idev->async_queue, SIGIO, POLL_IN);
44027 }
44028 @@ -450,7 +451,7 @@ static int uio_open(struct inode *inode, struct file *filep)
44029 }
44030
44031 listener->dev = idev;
44032 - listener->event_count = atomic_read(&idev->event);
44033 + listener->event_count = atomic_read_unchecked(&idev->event);
44034 filep->private_data = listener;
44035
44036 if (idev->info->open) {
44037 @@ -501,7 +502,7 @@ static unsigned int uio_poll(struct file *filep, poll_table *wait)
44038 return -EIO;
44039
44040 poll_wait(filep, &idev->wait, wait);
44041 - if (listener->event_count != atomic_read(&idev->event))
44042 + if (listener->event_count != atomic_read_unchecked(&idev->event))
44043 return POLLIN | POLLRDNORM;
44044 return 0;
44045 }
44046 @@ -526,7 +527,7 @@ static ssize_t uio_read(struct file *filep, char __user *buf,
44047 do {
44048 set_current_state(TASK_INTERRUPTIBLE);
44049
44050 - event_count = atomic_read(&idev->event);
44051 + event_count = atomic_read_unchecked(&idev->event);
44052 if (event_count != listener->event_count) {
44053 if (copy_to_user(buf, &event_count, count))
44054 retval = -EFAULT;
44055 @@ -595,13 +596,13 @@ static int uio_find_mem_index(struct vm_area_struct *vma)
44056 static void uio_vma_open(struct vm_area_struct *vma)
44057 {
44058 struct uio_device *idev = vma->vm_private_data;
44059 - idev->vma_count++;
44060 + local_inc(&idev->vma_count);
44061 }
44062
44063 static void uio_vma_close(struct vm_area_struct *vma)
44064 {
44065 struct uio_device *idev = vma->vm_private_data;
44066 - idev->vma_count--;
44067 + local_dec(&idev->vma_count);
44068 }
44069
44070 static int uio_vma_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
44071 @@ -808,7 +809,7 @@ int __uio_register_device(struct module *owner,
44072 idev->owner = owner;
44073 idev->info = info;
44074 init_waitqueue_head(&idev->wait);
44075 - atomic_set(&idev->event, 0);
44076 + atomic_set_unchecked(&idev->event, 0);
44077
44078 ret = uio_get_minor(idev);
44079 if (ret)
44080 diff --git a/drivers/usb/atm/cxacru.c b/drivers/usb/atm/cxacru.c
44081 index b7eb86a..c00402f 100644
44082 --- a/drivers/usb/atm/cxacru.c
44083 +++ b/drivers/usb/atm/cxacru.c
44084 @@ -473,7 +473,7 @@ static ssize_t cxacru_sysfs_store_adsl_config(struct device *dev,
44085 ret = sscanf(buf + pos, "%x=%x%n", &index, &value, &tmp);
44086 if (ret < 2)
44087 return -EINVAL;
44088 - if (index < 0 || index > 0x7f)
44089 + if (index > 0x7f)
44090 return -EINVAL;
44091 pos += tmp;
44092
44093 @@ -686,7 +686,8 @@ static int cxacru_cm_get_array(struct cxacru_data *instance, enum cxacru_cm_requ
44094 {
44095 int ret, len;
44096 __le32 *buf;
44097 - int offb, offd;
44098 + int offb;
44099 + unsigned int offd;
44100 const int stride = CMD_PACKET_SIZE / (4 * 2) - 1;
44101 int buflen = ((size - 1) / stride + 1 + size * 2) * 4;
44102
44103 diff --git a/drivers/usb/atm/usbatm.c b/drivers/usb/atm/usbatm.c
44104 index 35f10bf..6a38a0b 100644
44105 --- a/drivers/usb/atm/usbatm.c
44106 +++ b/drivers/usb/atm/usbatm.c
44107 @@ -333,7 +333,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
44108 if (printk_ratelimit())
44109 atm_warn(instance, "%s: OAM not supported (vpi %d, vci %d)!\n",
44110 __func__, vpi, vci);
44111 - atomic_inc(&vcc->stats->rx_err);
44112 + atomic_inc_unchecked(&vcc->stats->rx_err);
44113 return;
44114 }
44115
44116 @@ -361,7 +361,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
44117 if (length > ATM_MAX_AAL5_PDU) {
44118 atm_rldbg(instance, "%s: bogus length %u (vcc: 0x%p)!\n",
44119 __func__, length, vcc);
44120 - atomic_inc(&vcc->stats->rx_err);
44121 + atomic_inc_unchecked(&vcc->stats->rx_err);
44122 goto out;
44123 }
44124
44125 @@ -370,14 +370,14 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
44126 if (sarb->len < pdu_length) {
44127 atm_rldbg(instance, "%s: bogus pdu_length %u (sarb->len: %u, vcc: 0x%p)!\n",
44128 __func__, pdu_length, sarb->len, vcc);
44129 - atomic_inc(&vcc->stats->rx_err);
44130 + atomic_inc_unchecked(&vcc->stats->rx_err);
44131 goto out;
44132 }
44133
44134 if (crc32_be(~0, skb_tail_pointer(sarb) - pdu_length, pdu_length) != 0xc704dd7b) {
44135 atm_rldbg(instance, "%s: packet failed crc check (vcc: 0x%p)!\n",
44136 __func__, vcc);
44137 - atomic_inc(&vcc->stats->rx_err);
44138 + atomic_inc_unchecked(&vcc->stats->rx_err);
44139 goto out;
44140 }
44141
44142 @@ -389,7 +389,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
44143 if (printk_ratelimit())
44144 atm_err(instance, "%s: no memory for skb (length: %u)!\n",
44145 __func__, length);
44146 - atomic_inc(&vcc->stats->rx_drop);
44147 + atomic_inc_unchecked(&vcc->stats->rx_drop);
44148 goto out;
44149 }
44150
44151 @@ -417,7 +417,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
44152
44153 vcc->push(vcc, skb);
44154
44155 - atomic_inc(&vcc->stats->rx);
44156 + atomic_inc_unchecked(&vcc->stats->rx);
44157 out:
44158 skb_trim(sarb, 0);
44159 }
44160 @@ -623,7 +623,7 @@ static void usbatm_tx_process(unsigned long data)
44161 struct atm_vcc *vcc = UDSL_SKB(skb)->atm.vcc;
44162
44163 usbatm_pop(vcc, skb);
44164 - atomic_inc(&vcc->stats->tx);
44165 + atomic_inc_unchecked(&vcc->stats->tx);
44166
44167 skb = skb_dequeue(&instance->sndqueue);
44168 }
44169 @@ -779,11 +779,11 @@ static int usbatm_atm_proc_read(struct atm_dev *atm_dev, loff_t * pos, char *pag
44170 if (!left--)
44171 return sprintf(page,
44172 "AAL5: tx %d ( %d err ), rx %d ( %d err, %d drop )\n",
44173 - atomic_read(&atm_dev->stats.aal5.tx),
44174 - atomic_read(&atm_dev->stats.aal5.tx_err),
44175 - atomic_read(&atm_dev->stats.aal5.rx),
44176 - atomic_read(&atm_dev->stats.aal5.rx_err),
44177 - atomic_read(&atm_dev->stats.aal5.rx_drop));
44178 + atomic_read_unchecked(&atm_dev->stats.aal5.tx),
44179 + atomic_read_unchecked(&atm_dev->stats.aal5.tx_err),
44180 + atomic_read_unchecked(&atm_dev->stats.aal5.rx),
44181 + atomic_read_unchecked(&atm_dev->stats.aal5.rx_err),
44182 + atomic_read_unchecked(&atm_dev->stats.aal5.rx_drop));
44183
44184 if (!left--) {
44185 if (instance->disconnected)
44186 diff --git a/drivers/usb/core/devices.c b/drivers/usb/core/devices.c
44187 index 2a3bbdf..91d72cf 100644
44188 --- a/drivers/usb/core/devices.c
44189 +++ b/drivers/usb/core/devices.c
44190 @@ -126,7 +126,7 @@ static const char format_endpt[] =
44191 * time it gets called.
44192 */
44193 static struct device_connect_event {
44194 - atomic_t count;
44195 + atomic_unchecked_t count;
44196 wait_queue_head_t wait;
44197 } device_event = {
44198 .count = ATOMIC_INIT(1),
44199 @@ -164,7 +164,7 @@ static const struct class_info clas_info[] = {
44200
44201 void usbfs_conn_disc_event(void)
44202 {
44203 - atomic_add(2, &device_event.count);
44204 + atomic_add_unchecked(2, &device_event.count);
44205 wake_up(&device_event.wait);
44206 }
44207
44208 @@ -652,7 +652,7 @@ static unsigned int usb_device_poll(struct file *file,
44209
44210 poll_wait(file, &device_event.wait, wait);
44211
44212 - event_count = atomic_read(&device_event.count);
44213 + event_count = atomic_read_unchecked(&device_event.count);
44214 if (file->f_version != event_count) {
44215 file->f_version = event_count;
44216 return POLLIN | POLLRDNORM;
44217 diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
44218 index f9ec44c..eb5779f 100644
44219 --- a/drivers/usb/core/hcd.c
44220 +++ b/drivers/usb/core/hcd.c
44221 @@ -1526,7 +1526,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
44222 */
44223 usb_get_urb(urb);
44224 atomic_inc(&urb->use_count);
44225 - atomic_inc(&urb->dev->urbnum);
44226 + atomic_inc_unchecked(&urb->dev->urbnum);
44227 usbmon_urb_submit(&hcd->self, urb);
44228
44229 /* NOTE requirements on root-hub callers (usbfs and the hub
44230 @@ -1553,7 +1553,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
44231 urb->hcpriv = NULL;
44232 INIT_LIST_HEAD(&urb->urb_list);
44233 atomic_dec(&urb->use_count);
44234 - atomic_dec(&urb->dev->urbnum);
44235 + atomic_dec_unchecked(&urb->dev->urbnum);
44236 if (atomic_read(&urb->reject))
44237 wake_up(&usb_kill_urb_queue);
44238 usb_put_urb(urb);
44239 diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
44240 index 444d30e..f15c850 100644
44241 --- a/drivers/usb/core/message.c
44242 +++ b/drivers/usb/core/message.c
44243 @@ -129,7 +129,7 @@ static int usb_internal_control_msg(struct usb_device *usb_dev,
44244 * method can wait for it to complete. Since you don't have a handle on the
44245 * URB used, you can't cancel the request.
44246 */
44247 -int usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request,
44248 +int __intentional_overflow(-1) usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request,
44249 __u8 requesttype, __u16 value, __u16 index, void *data,
44250 __u16 size, int timeout)
44251 {
44252 diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c
44253 index 3f81a3d..a3aa993 100644
44254 --- a/drivers/usb/core/sysfs.c
44255 +++ b/drivers/usb/core/sysfs.c
44256 @@ -239,7 +239,7 @@ show_urbnum(struct device *dev, struct device_attribute *attr, char *buf)
44257 struct usb_device *udev;
44258
44259 udev = to_usb_device(dev);
44260 - return sprintf(buf, "%d\n", atomic_read(&udev->urbnum));
44261 + return sprintf(buf, "%d\n", atomic_read_unchecked(&udev->urbnum));
44262 }
44263 static DEVICE_ATTR(urbnum, S_IRUGO, show_urbnum, NULL);
44264
44265 diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
44266 index f81b925..78d22ec 100644
44267 --- a/drivers/usb/core/usb.c
44268 +++ b/drivers/usb/core/usb.c
44269 @@ -388,7 +388,7 @@ struct usb_device *usb_alloc_dev(struct usb_device *parent,
44270 set_dev_node(&dev->dev, dev_to_node(bus->controller));
44271 dev->state = USB_STATE_ATTACHED;
44272 dev->lpm_disable_count = 1;
44273 - atomic_set(&dev->urbnum, 0);
44274 + atomic_set_unchecked(&dev->urbnum, 0);
44275
44276 INIT_LIST_HEAD(&dev->ep0.urb_list);
44277 dev->ep0.desc.bLength = USB_DT_ENDPOINT_SIZE;
44278 diff --git a/drivers/usb/early/ehci-dbgp.c b/drivers/usb/early/ehci-dbgp.c
44279 index 5e29dde..eca992f 100644
44280 --- a/drivers/usb/early/ehci-dbgp.c
44281 +++ b/drivers/usb/early/ehci-dbgp.c
44282 @@ -98,7 +98,8 @@ static inline u32 dbgp_len_update(u32 x, u32 len)
44283
44284 #ifdef CONFIG_KGDB
44285 static struct kgdb_io kgdbdbgp_io_ops;
44286 -#define dbgp_kgdb_mode (dbg_io_ops == &kgdbdbgp_io_ops)
44287 +static struct kgdb_io kgdbdbgp_io_ops_console;
44288 +#define dbgp_kgdb_mode (dbg_io_ops == &kgdbdbgp_io_ops || dbg_io_ops == &kgdbdbgp_io_ops_console)
44289 #else
44290 #define dbgp_kgdb_mode (0)
44291 #endif
44292 @@ -1047,6 +1048,13 @@ static struct kgdb_io kgdbdbgp_io_ops = {
44293 .write_char = kgdbdbgp_write_char,
44294 };
44295
44296 +static struct kgdb_io kgdbdbgp_io_ops_console = {
44297 + .name = "kgdbdbgp",
44298 + .read_char = kgdbdbgp_read_char,
44299 + .write_char = kgdbdbgp_write_char,
44300 + .is_console = 1
44301 +};
44302 +
44303 static int kgdbdbgp_wait_time;
44304
44305 static int __init kgdbdbgp_parse_config(char *str)
44306 @@ -1062,8 +1070,10 @@ static int __init kgdbdbgp_parse_config(char *str)
44307 ptr++;
44308 kgdbdbgp_wait_time = simple_strtoul(ptr, &ptr, 10);
44309 }
44310 - kgdb_register_io_module(&kgdbdbgp_io_ops);
44311 - kgdbdbgp_io_ops.is_console = early_dbgp_console.index != -1;
44312 + if (early_dbgp_console.index != -1)
44313 + kgdb_register_io_module(&kgdbdbgp_io_ops_console);
44314 + else
44315 + kgdb_register_io_module(&kgdbdbgp_io_ops);
44316
44317 return 0;
44318 }
44319 diff --git a/drivers/usb/gadget/u_serial.c b/drivers/usb/gadget/u_serial.c
44320 index b369292..9f3ba40 100644
44321 --- a/drivers/usb/gadget/u_serial.c
44322 +++ b/drivers/usb/gadget/u_serial.c
44323 @@ -733,9 +733,9 @@ static int gs_open(struct tty_struct *tty, struct file *file)
44324 spin_lock_irq(&port->port_lock);
44325
44326 /* already open? Great. */
44327 - if (port->port.count) {
44328 + if (atomic_read(&port->port.count)) {
44329 status = 0;
44330 - port->port.count++;
44331 + atomic_inc(&port->port.count);
44332
44333 /* currently opening/closing? wait ... */
44334 } else if (port->openclose) {
44335 @@ -794,7 +794,7 @@ static int gs_open(struct tty_struct *tty, struct file *file)
44336 tty->driver_data = port;
44337 port->port.tty = tty;
44338
44339 - port->port.count = 1;
44340 + atomic_set(&port->port.count, 1);
44341 port->openclose = false;
44342
44343 /* if connected, start the I/O stream */
44344 @@ -836,11 +836,11 @@ static void gs_close(struct tty_struct *tty, struct file *file)
44345
44346 spin_lock_irq(&port->port_lock);
44347
44348 - if (port->port.count != 1) {
44349 - if (port->port.count == 0)
44350 + if (atomic_read(&port->port.count) != 1) {
44351 + if (atomic_read(&port->port.count) == 0)
44352 WARN_ON(1);
44353 else
44354 - --port->port.count;
44355 + atomic_dec(&port->port.count);
44356 goto exit;
44357 }
44358
44359 @@ -850,7 +850,7 @@ static void gs_close(struct tty_struct *tty, struct file *file)
44360 * and sleep if necessary
44361 */
44362 port->openclose = true;
44363 - port->port.count = 0;
44364 + atomic_set(&port->port.count, 0);
44365
44366 gser = port->port_usb;
44367 if (gser && gser->disconnect)
44368 @@ -1066,7 +1066,7 @@ static int gs_closed(struct gs_port *port)
44369 int cond;
44370
44371 spin_lock_irq(&port->port_lock);
44372 - cond = (port->port.count == 0) && !port->openclose;
44373 + cond = (atomic_read(&port->port.count) == 0) && !port->openclose;
44374 spin_unlock_irq(&port->port_lock);
44375 return cond;
44376 }
44377 @@ -1209,7 +1209,7 @@ int gserial_connect(struct gserial *gser, u8 port_num)
44378 /* if it's already open, start I/O ... and notify the serial
44379 * protocol about open/close status (connect/disconnect).
44380 */
44381 - if (port->port.count) {
44382 + if (atomic_read(&port->port.count)) {
44383 pr_debug("gserial_connect: start ttyGS%d\n", port->port_num);
44384 gs_start_io(port);
44385 if (gser->connect)
44386 @@ -1256,7 +1256,7 @@ void gserial_disconnect(struct gserial *gser)
44387
44388 port->port_usb = NULL;
44389 gser->ioport = NULL;
44390 - if (port->port.count > 0 || port->openclose) {
44391 + if (atomic_read(&port->port.count) > 0 || port->openclose) {
44392 wake_up_interruptible(&port->drain_wait);
44393 if (port->port.tty)
44394 tty_hangup(port->port.tty);
44395 @@ -1272,7 +1272,7 @@ void gserial_disconnect(struct gserial *gser)
44396
44397 /* finally, free any unused/unusable I/O buffers */
44398 spin_lock_irqsave(&port->port_lock, flags);
44399 - if (port->port.count == 0 && !port->openclose)
44400 + if (atomic_read(&port->port.count) == 0 && !port->openclose)
44401 gs_buf_free(&port->port_write_buf);
44402 gs_free_requests(gser->out, &port->read_pool, NULL);
44403 gs_free_requests(gser->out, &port->read_queue, NULL);
44404 diff --git a/drivers/usb/serial/console.c b/drivers/usb/serial/console.c
44405 index 5f3bcd3..bfca43f 100644
44406 --- a/drivers/usb/serial/console.c
44407 +++ b/drivers/usb/serial/console.c
44408 @@ -124,7 +124,7 @@ static int usb_console_setup(struct console *co, char *options)
44409
44410 info->port = port;
44411
44412 - ++port->port.count;
44413 + atomic_inc(&port->port.count);
44414 if (!test_bit(ASYNCB_INITIALIZED, &port->port.flags)) {
44415 if (serial->type->set_termios) {
44416 /*
44417 @@ -174,7 +174,7 @@ static int usb_console_setup(struct console *co, char *options)
44418 }
44419 /* Now that any required fake tty operations are completed restore
44420 * the tty port count */
44421 - --port->port.count;
44422 + atomic_dec(&port->port.count);
44423 /* The console is special in terms of closing the device so
44424 * indicate this port is now acting as a system console. */
44425 port->port.console = 1;
44426 @@ -187,7 +187,7 @@ static int usb_console_setup(struct console *co, char *options)
44427 free_tty:
44428 kfree(tty);
44429 reset_open_count:
44430 - port->port.count = 0;
44431 + atomic_set(&port->port.count, 0);
44432 usb_autopm_put_interface(serial->interface);
44433 error_get_interface:
44434 usb_serial_put(serial);
44435 diff --git a/drivers/usb/storage/realtek_cr.c b/drivers/usb/storage/realtek_cr.c
44436 index 6c3586a..a94e621 100644
44437 --- a/drivers/usb/storage/realtek_cr.c
44438 +++ b/drivers/usb/storage/realtek_cr.c
44439 @@ -429,7 +429,7 @@ static int rts51x_read_status(struct us_data *us,
44440
44441 buf = kmalloc(len, GFP_NOIO);
44442 if (buf == NULL)
44443 - return USB_STOR_TRANSPORT_ERROR;
44444 + return -ENOMEM;
44445
44446 US_DEBUGP("%s, lun = %d\n", __func__, lun);
44447
44448 diff --git a/drivers/usb/storage/usb.h b/drivers/usb/storage/usb.h
44449 index 75f70f0..d467e1a 100644
44450 --- a/drivers/usb/storage/usb.h
44451 +++ b/drivers/usb/storage/usb.h
44452 @@ -63,7 +63,7 @@ struct us_unusual_dev {
44453 __u8 useProtocol;
44454 __u8 useTransport;
44455 int (*initFunction)(struct us_data *);
44456 -};
44457 +} __do_const;
44458
44459
44460 /* Dynamic bitflag definitions (us->dflags): used in set_bit() etc. */
44461 diff --git a/drivers/usb/wusbcore/wa-hc.h b/drivers/usb/wusbcore/wa-hc.h
44462 index d6bea3e..60b250e 100644
44463 --- a/drivers/usb/wusbcore/wa-hc.h
44464 +++ b/drivers/usb/wusbcore/wa-hc.h
44465 @@ -192,7 +192,7 @@ struct wahc {
44466 struct list_head xfer_delayed_list;
44467 spinlock_t xfer_list_lock;
44468 struct work_struct xfer_work;
44469 - atomic_t xfer_id_count;
44470 + atomic_unchecked_t xfer_id_count;
44471 };
44472
44473
44474 @@ -246,7 +246,7 @@ static inline void wa_init(struct wahc *wa)
44475 INIT_LIST_HEAD(&wa->xfer_delayed_list);
44476 spin_lock_init(&wa->xfer_list_lock);
44477 INIT_WORK(&wa->xfer_work, wa_urb_enqueue_run);
44478 - atomic_set(&wa->xfer_id_count, 1);
44479 + atomic_set_unchecked(&wa->xfer_id_count, 1);
44480 }
44481
44482 /**
44483 diff --git a/drivers/usb/wusbcore/wa-xfer.c b/drivers/usb/wusbcore/wa-xfer.c
44484 index 6ef94bc..1b41265 100644
44485 --- a/drivers/usb/wusbcore/wa-xfer.c
44486 +++ b/drivers/usb/wusbcore/wa-xfer.c
44487 @@ -296,7 +296,7 @@ out:
44488 */
44489 static void wa_xfer_id_init(struct wa_xfer *xfer)
44490 {
44491 - xfer->id = atomic_add_return(1, &xfer->wa->xfer_id_count);
44492 + xfer->id = atomic_add_return_unchecked(1, &xfer->wa->xfer_id_count);
44493 }
44494
44495 /*
44496 diff --git a/drivers/video/aty/aty128fb.c b/drivers/video/aty/aty128fb.c
44497 index 8c55011..eed4ae1a 100644
44498 --- a/drivers/video/aty/aty128fb.c
44499 +++ b/drivers/video/aty/aty128fb.c
44500 @@ -149,7 +149,7 @@ enum {
44501 };
44502
44503 /* Must match above enum */
44504 -static char * const r128_family[] = {
44505 +static const char * const r128_family[] = {
44506 "AGP",
44507 "PCI",
44508 "PRO AGP",
44509 diff --git a/drivers/video/aty/atyfb_base.c b/drivers/video/aty/atyfb_base.c
44510 index 4f27fdc..d3537e6 100644
44511 --- a/drivers/video/aty/atyfb_base.c
44512 +++ b/drivers/video/aty/atyfb_base.c
44513 @@ -1325,10 +1325,14 @@ static int atyfb_set_par(struct fb_info *info)
44514 par->accel_flags = var->accel_flags; /* hack */
44515
44516 if (var->accel_flags) {
44517 - info->fbops->fb_sync = atyfb_sync;
44518 + pax_open_kernel();
44519 + *(void **)&info->fbops->fb_sync = atyfb_sync;
44520 + pax_close_kernel();
44521 info->flags &= ~FBINFO_HWACCEL_DISABLED;
44522 } else {
44523 - info->fbops->fb_sync = NULL;
44524 + pax_open_kernel();
44525 + *(void **)&info->fbops->fb_sync = NULL;
44526 + pax_close_kernel();
44527 info->flags |= FBINFO_HWACCEL_DISABLED;
44528 }
44529
44530 diff --git a/drivers/video/aty/mach64_cursor.c b/drivers/video/aty/mach64_cursor.c
44531 index 95ec042..e6affdd 100644
44532 --- a/drivers/video/aty/mach64_cursor.c
44533 +++ b/drivers/video/aty/mach64_cursor.c
44534 @@ -7,6 +7,7 @@
44535 #include <linux/string.h>
44536
44537 #include <asm/io.h>
44538 +#include <asm/pgtable.h>
44539
44540 #ifdef __sparc__
44541 #include <asm/fbio.h>
44542 @@ -208,7 +209,9 @@ int aty_init_cursor(struct fb_info *info)
44543 info->sprite.buf_align = 16; /* and 64 lines tall. */
44544 info->sprite.flags = FB_PIXMAP_IO;
44545
44546 - info->fbops->fb_cursor = atyfb_cursor;
44547 + pax_open_kernel();
44548 + *(void **)&info->fbops->fb_cursor = atyfb_cursor;
44549 + pax_close_kernel();
44550
44551 return 0;
44552 }
44553 diff --git a/drivers/video/backlight/kb3886_bl.c b/drivers/video/backlight/kb3886_bl.c
44554 index 6c5ed6b..b727c88 100644
44555 --- a/drivers/video/backlight/kb3886_bl.c
44556 +++ b/drivers/video/backlight/kb3886_bl.c
44557 @@ -78,7 +78,7 @@ static struct kb3886bl_machinfo *bl_machinfo;
44558 static unsigned long kb3886bl_flags;
44559 #define KB3886BL_SUSPENDED 0x01
44560
44561 -static struct dmi_system_id __initdata kb3886bl_device_table[] = {
44562 +static const struct dmi_system_id __initconst kb3886bl_device_table[] = {
44563 {
44564 .ident = "Sahara Touch-iT",
44565 .matches = {
44566 diff --git a/drivers/video/fb_defio.c b/drivers/video/fb_defio.c
44567 index 900aa4e..6d49418 100644
44568 --- a/drivers/video/fb_defio.c
44569 +++ b/drivers/video/fb_defio.c
44570 @@ -206,7 +206,9 @@ void fb_deferred_io_init(struct fb_info *info)
44571
44572 BUG_ON(!fbdefio);
44573 mutex_init(&fbdefio->lock);
44574 - info->fbops->fb_mmap = fb_deferred_io_mmap;
44575 + pax_open_kernel();
44576 + *(void **)&info->fbops->fb_mmap = fb_deferred_io_mmap;
44577 + pax_close_kernel();
44578 INIT_DELAYED_WORK(&info->deferred_work, fb_deferred_io_work);
44579 INIT_LIST_HEAD(&fbdefio->pagelist);
44580 if (fbdefio->delay == 0) /* set a default of 1 s */
44581 @@ -237,7 +239,7 @@ void fb_deferred_io_cleanup(struct fb_info *info)
44582 page->mapping = NULL;
44583 }
44584
44585 - info->fbops->fb_mmap = NULL;
44586 + *(void **)&info->fbops->fb_mmap = NULL;
44587 mutex_destroy(&fbdefio->lock);
44588 }
44589 EXPORT_SYMBOL_GPL(fb_deferred_io_cleanup);
44590 diff --git a/drivers/video/fbcmap.c b/drivers/video/fbcmap.c
44591 index 5c3960d..15cf8fc 100644
44592 --- a/drivers/video/fbcmap.c
44593 +++ b/drivers/video/fbcmap.c
44594 @@ -285,8 +285,7 @@ int fb_set_user_cmap(struct fb_cmap_user *cmap, struct fb_info *info)
44595 rc = -ENODEV;
44596 goto out;
44597 }
44598 - if (cmap->start < 0 || (!info->fbops->fb_setcolreg &&
44599 - !info->fbops->fb_setcmap)) {
44600 + if (!info->fbops->fb_setcolreg && !info->fbops->fb_setcmap) {
44601 rc = -EINVAL;
44602 goto out1;
44603 }
44604 diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
44605 index 86291dc..7cc5962 100644
44606 --- a/drivers/video/fbmem.c
44607 +++ b/drivers/video/fbmem.c
44608 @@ -428,7 +428,7 @@ static void fb_do_show_logo(struct fb_info *info, struct fb_image *image,
44609 image->dx += image->width + 8;
44610 }
44611 } else if (rotate == FB_ROTATE_UD) {
44612 - for (x = 0; x < num && image->dx >= 0; x++) {
44613 + for (x = 0; x < num && (__s32)image->dx >= 0; x++) {
44614 info->fbops->fb_imageblit(info, image);
44615 image->dx -= image->width + 8;
44616 }
44617 @@ -440,7 +440,7 @@ static void fb_do_show_logo(struct fb_info *info, struct fb_image *image,
44618 image->dy += image->height + 8;
44619 }
44620 } else if (rotate == FB_ROTATE_CCW) {
44621 - for (x = 0; x < num && image->dy >= 0; x++) {
44622 + for (x = 0; x < num && (__s32)image->dy >= 0; x++) {
44623 info->fbops->fb_imageblit(info, image);
44624 image->dy -= image->height + 8;
44625 }
44626 @@ -1166,7 +1166,7 @@ static long do_fb_ioctl(struct fb_info *info, unsigned int cmd,
44627 return -EFAULT;
44628 if (con2fb.console < 1 || con2fb.console > MAX_NR_CONSOLES)
44629 return -EINVAL;
44630 - if (con2fb.framebuffer < 0 || con2fb.framebuffer >= FB_MAX)
44631 + if (con2fb.framebuffer >= FB_MAX)
44632 return -EINVAL;
44633 if (!registered_fb[con2fb.framebuffer])
44634 request_module("fb%d", con2fb.framebuffer);
44635 diff --git a/drivers/video/i810/i810_accel.c b/drivers/video/i810/i810_accel.c
44636 index 7672d2e..b56437f 100644
44637 --- a/drivers/video/i810/i810_accel.c
44638 +++ b/drivers/video/i810/i810_accel.c
44639 @@ -73,6 +73,7 @@ static inline int wait_for_space(struct fb_info *info, u32 space)
44640 }
44641 }
44642 printk("ringbuffer lockup!!!\n");
44643 + printk("head:%u tail:%u iring.size:%u space:%u\n", head, tail, par->iring.size, space);
44644 i810_report_error(mmio);
44645 par->dev_flags |= LOCKUP;
44646 info->pixmap.scan_align = 1;
44647 diff --git a/drivers/video/logo/logo_linux_clut224.ppm b/drivers/video/logo/logo_linux_clut224.ppm
44648 index 3c14e43..eafa544 100644
44649 --- a/drivers/video/logo/logo_linux_clut224.ppm
44650 +++ b/drivers/video/logo/logo_linux_clut224.ppm
44651 @@ -1,1604 +1,1123 @@
44652 P3
44653 -# Standard 224-color Linux logo
44654 80 80
44655 255
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 0 0 0 0
44662 - 0 0 0 0 0 0 0 0 0 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 - 6 6 6 6 6 6 10 10 10 10 10 10
44666 - 10 10 10 6 6 6 6 6 6 6 6 6
44667 - 0 0 0 0 0 0 0 0 0 0 0 0
44668 - 0 0 0 0 0 0 0 0 0 0 0 0
44669 - 0 0 0 0 0 0 0 0 0 0 0 0
44670 - 0 0 0 0 0 0 0 0 0 0 0 0
44671 - 0 0 0 0 0 0 0 0 0 0 0 0
44672 - 0 0 0 0 0 0 0 0 0 0 0 0
44673 - 0 0 0 0 0 0 0 0 0 0 0 0
44674 - 0 0 0 0 0 0 0 0 0 0 0 0
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 6 6 6 10 10 10 14 14 14
44685 - 22 22 22 26 26 26 30 30 30 34 34 34
44686 - 30 30 30 30 30 30 26 26 26 18 18 18
44687 - 14 14 14 10 10 10 6 6 6 0 0 0
44688 - 0 0 0 0 0 0 0 0 0 0 0 0
44689 - 0 0 0 0 0 0 0 0 0 0 0 0
44690 - 0 0 0 0 0 0 0 0 0 0 0 0
44691 - 0 0 0 0 0 0 0 0 0 0 0 0
44692 - 0 0 0 0 0 0 0 0 0 0 0 0
44693 - 0 0 0 0 0 0 0 0 0 0 0 0
44694 - 0 0 0 0 0 0 0 0 0 0 0 0
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 1 0 0 1 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 0 0 0 0
44702 - 0 0 0 0 0 0 0 0 0 0 0 0
44703 - 0 0 0 0 0 0 0 0 0 0 0 0
44704 - 6 6 6 14 14 14 26 26 26 42 42 42
44705 - 54 54 54 66 66 66 78 78 78 78 78 78
44706 - 78 78 78 74 74 74 66 66 66 54 54 54
44707 - 42 42 42 26 26 26 18 18 18 10 10 10
44708 - 6 6 6 0 0 0 0 0 0 0 0 0
44709 - 0 0 0 0 0 0 0 0 0 0 0 0
44710 - 0 0 0 0 0 0 0 0 0 0 0 0
44711 - 0 0 0 0 0 0 0 0 0 0 0 0
44712 - 0 0 0 0 0 0 0 0 0 0 0 0
44713 - 0 0 0 0 0 0 0 0 0 0 0 0
44714 - 0 0 0 0 0 0 0 0 0 0 0 0
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 1 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 0 0 0 0
44722 - 0 0 0 0 0 0 0 0 0 0 0 0
44723 - 0 0 0 0 0 0 0 0 0 10 10 10
44724 - 22 22 22 42 42 42 66 66 66 86 86 86
44725 - 66 66 66 38 38 38 38 38 38 22 22 22
44726 - 26 26 26 34 34 34 54 54 54 66 66 66
44727 - 86 86 86 70 70 70 46 46 46 26 26 26
44728 - 14 14 14 6 6 6 0 0 0 0 0 0
44729 - 0 0 0 0 0 0 0 0 0 0 0 0
44730 - 0 0 0 0 0 0 0 0 0 0 0 0
44731 - 0 0 0 0 0 0 0 0 0 0 0 0
44732 - 0 0 0 0 0 0 0 0 0 0 0 0
44733 - 0 0 0 0 0 0 0 0 0 0 0 0
44734 - 0 0 0 0 0 0 0 0 0 0 0 0
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 1 0 0 1 0 0 1 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 0 0 0 0
44742 - 0 0 0 0 0 0 0 0 0 0 0 0
44743 - 0 0 0 0 0 0 10 10 10 26 26 26
44744 - 50 50 50 82 82 82 58 58 58 6 6 6
44745 - 2 2 6 2 2 6 2 2 6 2 2 6
44746 - 2 2 6 2 2 6 2 2 6 2 2 6
44747 - 6 6 6 54 54 54 86 86 86 66 66 66
44748 - 38 38 38 18 18 18 6 6 6 0 0 0
44749 - 0 0 0 0 0 0 0 0 0 0 0 0
44750 - 0 0 0 0 0 0 0 0 0 0 0 0
44751 - 0 0 0 0 0 0 0 0 0 0 0 0
44752 - 0 0 0 0 0 0 0 0 0 0 0 0
44753 - 0 0 0 0 0 0 0 0 0 0 0 0
44754 - 0 0 0 0 0 0 0 0 0 0 0 0
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 6 6 6 22 22 22 50 50 50
44764 - 78 78 78 34 34 34 2 2 6 2 2 6
44765 - 2 2 6 2 2 6 2 2 6 2 2 6
44766 - 2 2 6 2 2 6 2 2 6 2 2 6
44767 - 2 2 6 2 2 6 6 6 6 70 70 70
44768 - 78 78 78 46 46 46 22 22 22 6 6 6
44769 - 0 0 0 0 0 0 0 0 0 0 0 0
44770 - 0 0 0 0 0 0 0 0 0 0 0 0
44771 - 0 0 0 0 0 0 0 0 0 0 0 0
44772 - 0 0 0 0 0 0 0 0 0 0 0 0
44773 - 0 0 0 0 0 0 0 0 0 0 0 0
44774 - 0 0 0 0 0 0 0 0 0 0 0 0
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 1 0 0 1 0 0 1 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 - 6 6 6 18 18 18 42 42 42 82 82 82
44784 - 26 26 26 2 2 6 2 2 6 2 2 6
44785 - 2 2 6 2 2 6 2 2 6 2 2 6
44786 - 2 2 6 2 2 6 2 2 6 14 14 14
44787 - 46 46 46 34 34 34 6 6 6 2 2 6
44788 - 42 42 42 78 78 78 42 42 42 18 18 18
44789 - 6 6 6 0 0 0 0 0 0 0 0 0
44790 - 0 0 0 0 0 0 0 0 0 0 0 0
44791 - 0 0 0 0 0 0 0 0 0 0 0 0
44792 - 0 0 0 0 0 0 0 0 0 0 0 0
44793 - 0 0 0 0 0 0 0 0 0 0 0 0
44794 - 0 0 0 0 0 0 0 0 0 0 0 0
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 1 0 0 0 0 0 1 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 - 10 10 10 30 30 30 66 66 66 58 58 58
44804 - 2 2 6 2 2 6 2 2 6 2 2 6
44805 - 2 2 6 2 2 6 2 2 6 2 2 6
44806 - 2 2 6 2 2 6 2 2 6 26 26 26
44807 - 86 86 86 101 101 101 46 46 46 10 10 10
44808 - 2 2 6 58 58 58 70 70 70 34 34 34
44809 - 10 10 10 0 0 0 0 0 0 0 0 0
44810 - 0 0 0 0 0 0 0 0 0 0 0 0
44811 - 0 0 0 0 0 0 0 0 0 0 0 0
44812 - 0 0 0 0 0 0 0 0 0 0 0 0
44813 - 0 0 0 0 0 0 0 0 0 0 0 0
44814 - 0 0 0 0 0 0 0 0 0 0 0 0
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 1 0 0 1 0 0 1 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 - 14 14 14 42 42 42 86 86 86 10 10 10
44824 - 2 2 6 2 2 6 2 2 6 2 2 6
44825 - 2 2 6 2 2 6 2 2 6 2 2 6
44826 - 2 2 6 2 2 6 2 2 6 30 30 30
44827 - 94 94 94 94 94 94 58 58 58 26 26 26
44828 - 2 2 6 6 6 6 78 78 78 54 54 54
44829 - 22 22 22 6 6 6 0 0 0 0 0 0
44830 - 0 0 0 0 0 0 0 0 0 0 0 0
44831 - 0 0 0 0 0 0 0 0 0 0 0 0
44832 - 0 0 0 0 0 0 0 0 0 0 0 0
44833 - 0 0 0 0 0 0 0 0 0 0 0 0
44834 - 0 0 0 0 0 0 0 0 0 0 0 0
44835 - 0 0 0 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 6 6 6
44843 - 22 22 22 62 62 62 62 62 62 2 2 6
44844 - 2 2 6 2 2 6 2 2 6 2 2 6
44845 - 2 2 6 2 2 6 2 2 6 2 2 6
44846 - 2 2 6 2 2 6 2 2 6 26 26 26
44847 - 54 54 54 38 38 38 18 18 18 10 10 10
44848 - 2 2 6 2 2 6 34 34 34 82 82 82
44849 - 38 38 38 14 14 14 0 0 0 0 0 0
44850 - 0 0 0 0 0 0 0 0 0 0 0 0
44851 - 0 0 0 0 0 0 0 0 0 0 0 0
44852 - 0 0 0 0 0 0 0 0 0 0 0 0
44853 - 0 0 0 0 0 0 0 0 0 0 0 0
44854 - 0 0 0 0 0 0 0 0 0 0 0 0
44855 - 0 0 0 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 1 0 0 1 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 6 6 6
44863 - 30 30 30 78 78 78 30 30 30 2 2 6
44864 - 2 2 6 2 2 6 2 2 6 2 2 6
44865 - 2 2 6 2 2 6 2 2 6 2 2 6
44866 - 2 2 6 2 2 6 2 2 6 10 10 10
44867 - 10 10 10 2 2 6 2 2 6 2 2 6
44868 - 2 2 6 2 2 6 2 2 6 78 78 78
44869 - 50 50 50 18 18 18 6 6 6 0 0 0
44870 - 0 0 0 0 0 0 0 0 0 0 0 0
44871 - 0 0 0 0 0 0 0 0 0 0 0 0
44872 - 0 0 0 0 0 0 0 0 0 0 0 0
44873 - 0 0 0 0 0 0 0 0 0 0 0 0
44874 - 0 0 0 0 0 0 0 0 0 0 0 0
44875 - 0 0 0 0 0 0 0 0 0 0 0 0
44876 - 0 0 0 0 0 0 0 0 0 0 0 0
44877 - 0 0 1 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 10 10 10
44883 - 38 38 38 86 86 86 14 14 14 2 2 6
44884 - 2 2 6 2 2 6 2 2 6 2 2 6
44885 - 2 2 6 2 2 6 2 2 6 2 2 6
44886 - 2 2 6 2 2 6 2 2 6 2 2 6
44887 - 2 2 6 2 2 6 2 2 6 2 2 6
44888 - 2 2 6 2 2 6 2 2 6 54 54 54
44889 - 66 66 66 26 26 26 6 6 6 0 0 0
44890 - 0 0 0 0 0 0 0 0 0 0 0 0
44891 - 0 0 0 0 0 0 0 0 0 0 0 0
44892 - 0 0 0 0 0 0 0 0 0 0 0 0
44893 - 0 0 0 0 0 0 0 0 0 0 0 0
44894 - 0 0 0 0 0 0 0 0 0 0 0 0
44895 - 0 0 0 0 0 0 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 1 0 0 1 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 14 14 14
44903 - 42 42 42 82 82 82 2 2 6 2 2 6
44904 - 2 2 6 6 6 6 10 10 10 2 2 6
44905 - 2 2 6 2 2 6 2 2 6 2 2 6
44906 - 2 2 6 2 2 6 2 2 6 6 6 6
44907 - 14 14 14 10 10 10 2 2 6 2 2 6
44908 - 2 2 6 2 2 6 2 2 6 18 18 18
44909 - 82 82 82 34 34 34 10 10 10 0 0 0
44910 - 0 0 0 0 0 0 0 0 0 0 0 0
44911 - 0 0 0 0 0 0 0 0 0 0 0 0
44912 - 0 0 0 0 0 0 0 0 0 0 0 0
44913 - 0 0 0 0 0 0 0 0 0 0 0 0
44914 - 0 0 0 0 0 0 0 0 0 0 0 0
44915 - 0 0 0 0 0 0 0 0 0 0 0 0
44916 - 0 0 0 0 0 0 0 0 0 0 0 0
44917 - 0 0 1 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 14 14 14
44923 - 46 46 46 86 86 86 2 2 6 2 2 6
44924 - 6 6 6 6 6 6 22 22 22 34 34 34
44925 - 6 6 6 2 2 6 2 2 6 2 2 6
44926 - 2 2 6 2 2 6 18 18 18 34 34 34
44927 - 10 10 10 50 50 50 22 22 22 2 2 6
44928 - 2 2 6 2 2 6 2 2 6 10 10 10
44929 - 86 86 86 42 42 42 14 14 14 0 0 0
44930 - 0 0 0 0 0 0 0 0 0 0 0 0
44931 - 0 0 0 0 0 0 0 0 0 0 0 0
44932 - 0 0 0 0 0 0 0 0 0 0 0 0
44933 - 0 0 0 0 0 0 0 0 0 0 0 0
44934 - 0 0 0 0 0 0 0 0 0 0 0 0
44935 - 0 0 0 0 0 0 0 0 0 0 0 0
44936 - 0 0 0 0 0 0 0 0 0 0 0 0
44937 - 0 0 1 0 0 1 0 0 1 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 14 14 14
44943 - 46 46 46 86 86 86 2 2 6 2 2 6
44944 - 38 38 38 116 116 116 94 94 94 22 22 22
44945 - 22 22 22 2 2 6 2 2 6 2 2 6
44946 - 14 14 14 86 86 86 138 138 138 162 162 162
44947 -154 154 154 38 38 38 26 26 26 6 6 6
44948 - 2 2 6 2 2 6 2 2 6 2 2 6
44949 - 86 86 86 46 46 46 14 14 14 0 0 0
44950 - 0 0 0 0 0 0 0 0 0 0 0 0
44951 - 0 0 0 0 0 0 0 0 0 0 0 0
44952 - 0 0 0 0 0 0 0 0 0 0 0 0
44953 - 0 0 0 0 0 0 0 0 0 0 0 0
44954 - 0 0 0 0 0 0 0 0 0 0 0 0
44955 - 0 0 0 0 0 0 0 0 0 0 0 0
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 14 14 14
44963 - 46 46 46 86 86 86 2 2 6 14 14 14
44964 -134 134 134 198 198 198 195 195 195 116 116 116
44965 - 10 10 10 2 2 6 2 2 6 6 6 6
44966 -101 98 89 187 187 187 210 210 210 218 218 218
44967 -214 214 214 134 134 134 14 14 14 6 6 6
44968 - 2 2 6 2 2 6 2 2 6 2 2 6
44969 - 86 86 86 50 50 50 18 18 18 6 6 6
44970 - 0 0 0 0 0 0 0 0 0 0 0 0
44971 - 0 0 0 0 0 0 0 0 0 0 0 0
44972 - 0 0 0 0 0 0 0 0 0 0 0 0
44973 - 0 0 0 0 0 0 0 0 0 0 0 0
44974 - 0 0 0 0 0 0 0 0 0 0 0 0
44975 - 0 0 0 0 0 0 0 0 0 0 0 0
44976 - 0 0 0 0 0 0 0 0 1 0 0 0
44977 - 0 0 1 0 0 1 0 0 1 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 14 14 14
44983 - 46 46 46 86 86 86 2 2 6 54 54 54
44984 -218 218 218 195 195 195 226 226 226 246 246 246
44985 - 58 58 58 2 2 6 2 2 6 30 30 30
44986 -210 210 210 253 253 253 174 174 174 123 123 123
44987 -221 221 221 234 234 234 74 74 74 2 2 6
44988 - 2 2 6 2 2 6 2 2 6 2 2 6
44989 - 70 70 70 58 58 58 22 22 22 6 6 6
44990 - 0 0 0 0 0 0 0 0 0 0 0 0
44991 - 0 0 0 0 0 0 0 0 0 0 0 0
44992 - 0 0 0 0 0 0 0 0 0 0 0 0
44993 - 0 0 0 0 0 0 0 0 0 0 0 0
44994 - 0 0 0 0 0 0 0 0 0 0 0 0
44995 - 0 0 0 0 0 0 0 0 0 0 0 0
44996 - 0 0 0 0 0 0 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 14 14 14
45003 - 46 46 46 82 82 82 2 2 6 106 106 106
45004 -170 170 170 26 26 26 86 86 86 226 226 226
45005 -123 123 123 10 10 10 14 14 14 46 46 46
45006 -231 231 231 190 190 190 6 6 6 70 70 70
45007 - 90 90 90 238 238 238 158 158 158 2 2 6
45008 - 2 2 6 2 2 6 2 2 6 2 2 6
45009 - 70 70 70 58 58 58 22 22 22 6 6 6
45010 - 0 0 0 0 0 0 0 0 0 0 0 0
45011 - 0 0 0 0 0 0 0 0 0 0 0 0
45012 - 0 0 0 0 0 0 0 0 0 0 0 0
45013 - 0 0 0 0 0 0 0 0 0 0 0 0
45014 - 0 0 0 0 0 0 0 0 0 0 0 0
45015 - 0 0 0 0 0 0 0 0 0 0 0 0
45016 - 0 0 0 0 0 0 0 0 1 0 0 0
45017 - 0 0 1 0 0 1 0 0 1 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 14 14 14
45023 - 42 42 42 86 86 86 6 6 6 116 116 116
45024 -106 106 106 6 6 6 70 70 70 149 149 149
45025 -128 128 128 18 18 18 38 38 38 54 54 54
45026 -221 221 221 106 106 106 2 2 6 14 14 14
45027 - 46 46 46 190 190 190 198 198 198 2 2 6
45028 - 2 2 6 2 2 6 2 2 6 2 2 6
45029 - 74 74 74 62 62 62 22 22 22 6 6 6
45030 - 0 0 0 0 0 0 0 0 0 0 0 0
45031 - 0 0 0 0 0 0 0 0 0 0 0 0
45032 - 0 0 0 0 0 0 0 0 0 0 0 0
45033 - 0 0 0 0 0 0 0 0 0 0 0 0
45034 - 0 0 0 0 0 0 0 0 0 0 0 0
45035 - 0 0 0 0 0 0 0 0 0 0 0 0
45036 - 0 0 0 0 0 0 0 0 1 0 0 0
45037 - 0 0 1 0 0 0 0 0 1 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 14 14 14
45043 - 42 42 42 94 94 94 14 14 14 101 101 101
45044 -128 128 128 2 2 6 18 18 18 116 116 116
45045 -118 98 46 121 92 8 121 92 8 98 78 10
45046 -162 162 162 106 106 106 2 2 6 2 2 6
45047 - 2 2 6 195 195 195 195 195 195 6 6 6
45048 - 2 2 6 2 2 6 2 2 6 2 2 6
45049 - 74 74 74 62 62 62 22 22 22 6 6 6
45050 - 0 0 0 0 0 0 0 0 0 0 0 0
45051 - 0 0 0 0 0 0 0 0 0 0 0 0
45052 - 0 0 0 0 0 0 0 0 0 0 0 0
45053 - 0 0 0 0 0 0 0 0 0 0 0 0
45054 - 0 0 0 0 0 0 0 0 0 0 0 0
45055 - 0 0 0 0 0 0 0 0 0 0 0 0
45056 - 0 0 0 0 0 0 0 0 1 0 0 1
45057 - 0 0 1 0 0 0 0 0 1 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 10 10 10
45063 - 38 38 38 90 90 90 14 14 14 58 58 58
45064 -210 210 210 26 26 26 54 38 6 154 114 10
45065 -226 170 11 236 186 11 225 175 15 184 144 12
45066 -215 174 15 175 146 61 37 26 9 2 2 6
45067 - 70 70 70 246 246 246 138 138 138 2 2 6
45068 - 2 2 6 2 2 6 2 2 6 2 2 6
45069 - 70 70 70 66 66 66 26 26 26 6 6 6
45070 - 0 0 0 0 0 0 0 0 0 0 0 0
45071 - 0 0 0 0 0 0 0 0 0 0 0 0
45072 - 0 0 0 0 0 0 0 0 0 0 0 0
45073 - 0 0 0 0 0 0 0 0 0 0 0 0
45074 - 0 0 0 0 0 0 0 0 0 0 0 0
45075 - 0 0 0 0 0 0 0 0 0 0 0 0
45076 - 0 0 0 0 0 0 0 0 0 0 0 0
45077 - 0 0 0 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 10 10 10
45083 - 38 38 38 86 86 86 14 14 14 10 10 10
45084 -195 195 195 188 164 115 192 133 9 225 175 15
45085 -239 182 13 234 190 10 232 195 16 232 200 30
45086 -245 207 45 241 208 19 232 195 16 184 144 12
45087 -218 194 134 211 206 186 42 42 42 2 2 6
45088 - 2 2 6 2 2 6 2 2 6 2 2 6
45089 - 50 50 50 74 74 74 30 30 30 6 6 6
45090 - 0 0 0 0 0 0 0 0 0 0 0 0
45091 - 0 0 0 0 0 0 0 0 0 0 0 0
45092 - 0 0 0 0 0 0 0 0 0 0 0 0
45093 - 0 0 0 0 0 0 0 0 0 0 0 0
45094 - 0 0 0 0 0 0 0 0 0 0 0 0
45095 - 0 0 0 0 0 0 0 0 0 0 0 0
45096 - 0 0 0 0 0 0 0 0 0 0 0 0
45097 - 0 0 0 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 10 10 10
45103 - 34 34 34 86 86 86 14 14 14 2 2 6
45104 -121 87 25 192 133 9 219 162 10 239 182 13
45105 -236 186 11 232 195 16 241 208 19 244 214 54
45106 -246 218 60 246 218 38 246 215 20 241 208 19
45107 -241 208 19 226 184 13 121 87 25 2 2 6
45108 - 2 2 6 2 2 6 2 2 6 2 2 6
45109 - 50 50 50 82 82 82 34 34 34 10 10 10
45110 - 0 0 0 0 0 0 0 0 0 0 0 0
45111 - 0 0 0 0 0 0 0 0 0 0 0 0
45112 - 0 0 0 0 0 0 0 0 0 0 0 0
45113 - 0 0 0 0 0 0 0 0 0 0 0 0
45114 - 0 0 0 0 0 0 0 0 0 0 0 0
45115 - 0 0 0 0 0 0 0 0 0 0 0 0
45116 - 0 0 0 0 0 0 0 0 0 0 0 0
45117 - 0 0 0 0 0 0 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 10 10 10
45123 - 34 34 34 82 82 82 30 30 30 61 42 6
45124 -180 123 7 206 145 10 230 174 11 239 182 13
45125 -234 190 10 238 202 15 241 208 19 246 218 74
45126 -246 218 38 246 215 20 246 215 20 246 215 20
45127 -226 184 13 215 174 15 184 144 12 6 6 6
45128 - 2 2 6 2 2 6 2 2 6 2 2 6
45129 - 26 26 26 94 94 94 42 42 42 14 14 14
45130 - 0 0 0 0 0 0 0 0 0 0 0 0
45131 - 0 0 0 0 0 0 0 0 0 0 0 0
45132 - 0 0 0 0 0 0 0 0 0 0 0 0
45133 - 0 0 0 0 0 0 0 0 0 0 0 0
45134 - 0 0 0 0 0 0 0 0 0 0 0 0
45135 - 0 0 0 0 0 0 0 0 0 0 0 0
45136 - 0 0 0 0 0 0 0 0 0 0 0 0
45137 - 0 0 0 0 0 0 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 10 10 10
45143 - 30 30 30 78 78 78 50 50 50 104 69 6
45144 -192 133 9 216 158 10 236 178 12 236 186 11
45145 -232 195 16 241 208 19 244 214 54 245 215 43
45146 -246 215 20 246 215 20 241 208 19 198 155 10
45147 -200 144 11 216 158 10 156 118 10 2 2 6
45148 - 2 2 6 2 2 6 2 2 6 2 2 6
45149 - 6 6 6 90 90 90 54 54 54 18 18 18
45150 - 6 6 6 0 0 0 0 0 0 0 0 0
45151 - 0 0 0 0 0 0 0 0 0 0 0 0
45152 - 0 0 0 0 0 0 0 0 0 0 0 0
45153 - 0 0 0 0 0 0 0 0 0 0 0 0
45154 - 0 0 0 0 0 0 0 0 0 0 0 0
45155 - 0 0 0 0 0 0 0 0 0 0 0 0
45156 - 0 0 0 0 0 0 0 0 0 0 0 0
45157 - 0 0 0 0 0 0 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 10 10 10
45163 - 30 30 30 78 78 78 46 46 46 22 22 22
45164 -137 92 6 210 162 10 239 182 13 238 190 10
45165 -238 202 15 241 208 19 246 215 20 246 215 20
45166 -241 208 19 203 166 17 185 133 11 210 150 10
45167 -216 158 10 210 150 10 102 78 10 2 2 6
45168 - 6 6 6 54 54 54 14 14 14 2 2 6
45169 - 2 2 6 62 62 62 74 74 74 30 30 30
45170 - 10 10 10 0 0 0 0 0 0 0 0 0
45171 - 0 0 0 0 0 0 0 0 0 0 0 0
45172 - 0 0 0 0 0 0 0 0 0 0 0 0
45173 - 0 0 0 0 0 0 0 0 0 0 0 0
45174 - 0 0 0 0 0 0 0 0 0 0 0 0
45175 - 0 0 0 0 0 0 0 0 0 0 0 0
45176 - 0 0 0 0 0 0 0 0 0 0 0 0
45177 - 0 0 0 0 0 0 0 0 0 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 10 10 10
45183 - 34 34 34 78 78 78 50 50 50 6 6 6
45184 - 94 70 30 139 102 15 190 146 13 226 184 13
45185 -232 200 30 232 195 16 215 174 15 190 146 13
45186 -168 122 10 192 133 9 210 150 10 213 154 11
45187 -202 150 34 182 157 106 101 98 89 2 2 6
45188 - 2 2 6 78 78 78 116 116 116 58 58 58
45189 - 2 2 6 22 22 22 90 90 90 46 46 46
45190 - 18 18 18 6 6 6 0 0 0 0 0 0
45191 - 0 0 0 0 0 0 0 0 0 0 0 0
45192 - 0 0 0 0 0 0 0 0 0 0 0 0
45193 - 0 0 0 0 0 0 0 0 0 0 0 0
45194 - 0 0 0 0 0 0 0 0 0 0 0 0
45195 - 0 0 0 0 0 0 0 0 0 0 0 0
45196 - 0 0 0 0 0 0 0 0 0 0 0 0
45197 - 0 0 0 0 0 0 0 0 0 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 10 10 10
45203 - 38 38 38 86 86 86 50 50 50 6 6 6
45204 -128 128 128 174 154 114 156 107 11 168 122 10
45205 -198 155 10 184 144 12 197 138 11 200 144 11
45206 -206 145 10 206 145 10 197 138 11 188 164 115
45207 -195 195 195 198 198 198 174 174 174 14 14 14
45208 - 2 2 6 22 22 22 116 116 116 116 116 116
45209 - 22 22 22 2 2 6 74 74 74 70 70 70
45210 - 30 30 30 10 10 10 0 0 0 0 0 0
45211 - 0 0 0 0 0 0 0 0 0 0 0 0
45212 - 0 0 0 0 0 0 0 0 0 0 0 0
45213 - 0 0 0 0 0 0 0 0 0 0 0 0
45214 - 0 0 0 0 0 0 0 0 0 0 0 0
45215 - 0 0 0 0 0 0 0 0 0 0 0 0
45216 - 0 0 0 0 0 0 0 0 0 0 0 0
45217 - 0 0 0 0 0 0 0 0 0 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 6 6 6 18 18 18
45223 - 50 50 50 101 101 101 26 26 26 10 10 10
45224 -138 138 138 190 190 190 174 154 114 156 107 11
45225 -197 138 11 200 144 11 197 138 11 192 133 9
45226 -180 123 7 190 142 34 190 178 144 187 187 187
45227 -202 202 202 221 221 221 214 214 214 66 66 66
45228 - 2 2 6 2 2 6 50 50 50 62 62 62
45229 - 6 6 6 2 2 6 10 10 10 90 90 90
45230 - 50 50 50 18 18 18 6 6 6 0 0 0
45231 - 0 0 0 0 0 0 0 0 0 0 0 0
45232 - 0 0 0 0 0 0 0 0 0 0 0 0
45233 - 0 0 0 0 0 0 0 0 0 0 0 0
45234 - 0 0 0 0 0 0 0 0 0 0 0 0
45235 - 0 0 0 0 0 0 0 0 0 0 0 0
45236 - 0 0 0 0 0 0 0 0 0 0 0 0
45237 - 0 0 0 0 0 0 0 0 0 0 0 0
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 10 10 10 34 34 34
45243 - 74 74 74 74 74 74 2 2 6 6 6 6
45244 -144 144 144 198 198 198 190 190 190 178 166 146
45245 -154 121 60 156 107 11 156 107 11 168 124 44
45246 -174 154 114 187 187 187 190 190 190 210 210 210
45247 -246 246 246 253 253 253 253 253 253 182 182 182
45248 - 6 6 6 2 2 6 2 2 6 2 2 6
45249 - 2 2 6 2 2 6 2 2 6 62 62 62
45250 - 74 74 74 34 34 34 14 14 14 0 0 0
45251 - 0 0 0 0 0 0 0 0 0 0 0 0
45252 - 0 0 0 0 0 0 0 0 0 0 0 0
45253 - 0 0 0 0 0 0 0 0 0 0 0 0
45254 - 0 0 0 0 0 0 0 0 0 0 0 0
45255 - 0 0 0 0 0 0 0 0 0 0 0 0
45256 - 0 0 0 0 0 0 0 0 0 0 0 0
45257 - 0 0 0 0 0 0 0 0 0 0 0 0
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 10 10 10 22 22 22 54 54 54
45263 - 94 94 94 18 18 18 2 2 6 46 46 46
45264 -234 234 234 221 221 221 190 190 190 190 190 190
45265 -190 190 190 187 187 187 187 187 187 190 190 190
45266 -190 190 190 195 195 195 214 214 214 242 242 242
45267 -253 253 253 253 253 253 253 253 253 253 253 253
45268 - 82 82 82 2 2 6 2 2 6 2 2 6
45269 - 2 2 6 2 2 6 2 2 6 14 14 14
45270 - 86 86 86 54 54 54 22 22 22 6 6 6
45271 - 0 0 0 0 0 0 0 0 0 0 0 0
45272 - 0 0 0 0 0 0 0 0 0 0 0 0
45273 - 0 0 0 0 0 0 0 0 0 0 0 0
45274 - 0 0 0 0 0 0 0 0 0 0 0 0
45275 - 0 0 0 0 0 0 0 0 0 0 0 0
45276 - 0 0 0 0 0 0 0 0 0 0 0 0
45277 - 0 0 0 0 0 0 0 0 0 0 0 0
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 - 6 6 6 18 18 18 46 46 46 90 90 90
45283 - 46 46 46 18 18 18 6 6 6 182 182 182
45284 -253 253 253 246 246 246 206 206 206 190 190 190
45285 -190 190 190 190 190 190 190 190 190 190 190 190
45286 -206 206 206 231 231 231 250 250 250 253 253 253
45287 -253 253 253 253 253 253 253 253 253 253 253 253
45288 -202 202 202 14 14 14 2 2 6 2 2 6
45289 - 2 2 6 2 2 6 2 2 6 2 2 6
45290 - 42 42 42 86 86 86 42 42 42 18 18 18
45291 - 6 6 6 0 0 0 0 0 0 0 0 0
45292 - 0 0 0 0 0 0 0 0 0 0 0 0
45293 - 0 0 0 0 0 0 0 0 0 0 0 0
45294 - 0 0 0 0 0 0 0 0 0 0 0 0
45295 - 0 0 0 0 0 0 0 0 0 0 0 0
45296 - 0 0 0 0 0 0 0 0 0 0 0 0
45297 - 0 0 0 0 0 0 0 0 0 0 0 0
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 6 6 6
45302 - 14 14 14 38 38 38 74 74 74 66 66 66
45303 - 2 2 6 6 6 6 90 90 90 250 250 250
45304 -253 253 253 253 253 253 238 238 238 198 198 198
45305 -190 190 190 190 190 190 195 195 195 221 221 221
45306 -246 246 246 253 253 253 253 253 253 253 253 253
45307 -253 253 253 253 253 253 253 253 253 253 253 253
45308 -253 253 253 82 82 82 2 2 6 2 2 6
45309 - 2 2 6 2 2 6 2 2 6 2 2 6
45310 - 2 2 6 78 78 78 70 70 70 34 34 34
45311 - 14 14 14 6 6 6 0 0 0 0 0 0
45312 - 0 0 0 0 0 0 0 0 0 0 0 0
45313 - 0 0 0 0 0 0 0 0 0 0 0 0
45314 - 0 0 0 0 0 0 0 0 0 0 0 0
45315 - 0 0 0 0 0 0 0 0 0 0 0 0
45316 - 0 0 0 0 0 0 0 0 0 0 0 0
45317 - 0 0 0 0 0 0 0 0 0 0 0 0
45318 - 0 0 0 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 14 14 14
45322 - 34 34 34 66 66 66 78 78 78 6 6 6
45323 - 2 2 6 18 18 18 218 218 218 253 253 253
45324 -253 253 253 253 253 253 253 253 253 246 246 246
45325 -226 226 226 231 231 231 246 246 246 253 253 253
45326 -253 253 253 253 253 253 253 253 253 253 253 253
45327 -253 253 253 253 253 253 253 253 253 253 253 253
45328 -253 253 253 178 178 178 2 2 6 2 2 6
45329 - 2 2 6 2 2 6 2 2 6 2 2 6
45330 - 2 2 6 18 18 18 90 90 90 62 62 62
45331 - 30 30 30 10 10 10 0 0 0 0 0 0
45332 - 0 0 0 0 0 0 0 0 0 0 0 0
45333 - 0 0 0 0 0 0 0 0 0 0 0 0
45334 - 0 0 0 0 0 0 0 0 0 0 0 0
45335 - 0 0 0 0 0 0 0 0 0 0 0 0
45336 - 0 0 0 0 0 0 0 0 0 0 0 0
45337 - 0 0 0 0 0 0 0 0 0 0 0 0
45338 - 0 0 0 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 10 10 10 26 26 26
45342 - 58 58 58 90 90 90 18 18 18 2 2 6
45343 - 2 2 6 110 110 110 253 253 253 253 253 253
45344 -253 253 253 253 253 253 253 253 253 253 253 253
45345 -250 250 250 253 253 253 253 253 253 253 253 253
45346 -253 253 253 253 253 253 253 253 253 253 253 253
45347 -253 253 253 253 253 253 253 253 253 253 253 253
45348 -253 253 253 231 231 231 18 18 18 2 2 6
45349 - 2 2 6 2 2 6 2 2 6 2 2 6
45350 - 2 2 6 2 2 6 18 18 18 94 94 94
45351 - 54 54 54 26 26 26 10 10 10 0 0 0
45352 - 0 0 0 0 0 0 0 0 0 0 0 0
45353 - 0 0 0 0 0 0 0 0 0 0 0 0
45354 - 0 0 0 0 0 0 0 0 0 0 0 0
45355 - 0 0 0 0 0 0 0 0 0 0 0 0
45356 - 0 0 0 0 0 0 0 0 0 0 0 0
45357 - 0 0 0 0 0 0 0 0 0 0 0 0
45358 - 0 0 0 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 6 6 6 22 22 22 50 50 50
45362 - 90 90 90 26 26 26 2 2 6 2 2 6
45363 - 14 14 14 195 195 195 250 250 250 253 253 253
45364 -253 253 253 253 253 253 253 253 253 253 253 253
45365 -253 253 253 253 253 253 253 253 253 253 253 253
45366 -253 253 253 253 253 253 253 253 253 253 253 253
45367 -253 253 253 253 253 253 253 253 253 253 253 253
45368 -250 250 250 242 242 242 54 54 54 2 2 6
45369 - 2 2 6 2 2 6 2 2 6 2 2 6
45370 - 2 2 6 2 2 6 2 2 6 38 38 38
45371 - 86 86 86 50 50 50 22 22 22 6 6 6
45372 - 0 0 0 0 0 0 0 0 0 0 0 0
45373 - 0 0 0 0 0 0 0 0 0 0 0 0
45374 - 0 0 0 0 0 0 0 0 0 0 0 0
45375 - 0 0 0 0 0 0 0 0 0 0 0 0
45376 - 0 0 0 0 0 0 0 0 0 0 0 0
45377 - 0 0 0 0 0 0 0 0 0 0 0 0
45378 - 0 0 0 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 - 6 6 6 14 14 14 38 38 38 82 82 82
45382 - 34 34 34 2 2 6 2 2 6 2 2 6
45383 - 42 42 42 195 195 195 246 246 246 253 253 253
45384 -253 253 253 253 253 253 253 253 253 250 250 250
45385 -242 242 242 242 242 242 250 250 250 253 253 253
45386 -253 253 253 253 253 253 253 253 253 253 253 253
45387 -253 253 253 250 250 250 246 246 246 238 238 238
45388 -226 226 226 231 231 231 101 101 101 6 6 6
45389 - 2 2 6 2 2 6 2 2 6 2 2 6
45390 - 2 2 6 2 2 6 2 2 6 2 2 6
45391 - 38 38 38 82 82 82 42 42 42 14 14 14
45392 - 6 6 6 0 0 0 0 0 0 0 0 0
45393 - 0 0 0 0 0 0 0 0 0 0 0 0
45394 - 0 0 0 0 0 0 0 0 0 0 0 0
45395 - 0 0 0 0 0 0 0 0 0 0 0 0
45396 - 0 0 0 0 0 0 0 0 0 0 0 0
45397 - 0 0 0 0 0 0 0 0 0 0 0 0
45398 - 0 0 0 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 - 10 10 10 26 26 26 62 62 62 66 66 66
45402 - 2 2 6 2 2 6 2 2 6 6 6 6
45403 - 70 70 70 170 170 170 206 206 206 234 234 234
45404 -246 246 246 250 250 250 250 250 250 238 238 238
45405 -226 226 226 231 231 231 238 238 238 250 250 250
45406 -250 250 250 250 250 250 246 246 246 231 231 231
45407 -214 214 214 206 206 206 202 202 202 202 202 202
45408 -198 198 198 202 202 202 182 182 182 18 18 18
45409 - 2 2 6 2 2 6 2 2 6 2 2 6
45410 - 2 2 6 2 2 6 2 2 6 2 2 6
45411 - 2 2 6 62 62 62 66 66 66 30 30 30
45412 - 10 10 10 0 0 0 0 0 0 0 0 0
45413 - 0 0 0 0 0 0 0 0 0 0 0 0
45414 - 0 0 0 0 0 0 0 0 0 0 0 0
45415 - 0 0 0 0 0 0 0 0 0 0 0 0
45416 - 0 0 0 0 0 0 0 0 0 0 0 0
45417 - 0 0 0 0 0 0 0 0 0 0 0 0
45418 - 0 0 0 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 - 14 14 14 42 42 42 82 82 82 18 18 18
45422 - 2 2 6 2 2 6 2 2 6 10 10 10
45423 - 94 94 94 182 182 182 218 218 218 242 242 242
45424 -250 250 250 253 253 253 253 253 253 250 250 250
45425 -234 234 234 253 253 253 253 253 253 253 253 253
45426 -253 253 253 253 253 253 253 253 253 246 246 246
45427 -238 238 238 226 226 226 210 210 210 202 202 202
45428 -195 195 195 195 195 195 210 210 210 158 158 158
45429 - 6 6 6 14 14 14 50 50 50 14 14 14
45430 - 2 2 6 2 2 6 2 2 6 2 2 6
45431 - 2 2 6 6 6 6 86 86 86 46 46 46
45432 - 18 18 18 6 6 6 0 0 0 0 0 0
45433 - 0 0 0 0 0 0 0 0 0 0 0 0
45434 - 0 0 0 0 0 0 0 0 0 0 0 0
45435 - 0 0 0 0 0 0 0 0 0 0 0 0
45436 - 0 0 0 0 0 0 0 0 0 0 0 0
45437 - 0 0 0 0 0 0 0 0 0 0 0 0
45438 - 0 0 0 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 6 6 6
45441 - 22 22 22 54 54 54 70 70 70 2 2 6
45442 - 2 2 6 10 10 10 2 2 6 22 22 22
45443 -166 166 166 231 231 231 250 250 250 253 253 253
45444 -253 253 253 253 253 253 253 253 253 250 250 250
45445 -242 242 242 253 253 253 253 253 253 253 253 253
45446 -253 253 253 253 253 253 253 253 253 253 253 253
45447 -253 253 253 253 253 253 253 253 253 246 246 246
45448 -231 231 231 206 206 206 198 198 198 226 226 226
45449 - 94 94 94 2 2 6 6 6 6 38 38 38
45450 - 30 30 30 2 2 6 2 2 6 2 2 6
45451 - 2 2 6 2 2 6 62 62 62 66 66 66
45452 - 26 26 26 10 10 10 0 0 0 0 0 0
45453 - 0 0 0 0 0 0 0 0 0 0 0 0
45454 - 0 0 0 0 0 0 0 0 0 0 0 0
45455 - 0 0 0 0 0 0 0 0 0 0 0 0
45456 - 0 0 0 0 0 0 0 0 0 0 0 0
45457 - 0 0 0 0 0 0 0 0 0 0 0 0
45458 - 0 0 0 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 10 10 10
45461 - 30 30 30 74 74 74 50 50 50 2 2 6
45462 - 26 26 26 26 26 26 2 2 6 106 106 106
45463 -238 238 238 253 253 253 253 253 253 253 253 253
45464 -253 253 253 253 253 253 253 253 253 253 253 253
45465 -253 253 253 253 253 253 253 253 253 253 253 253
45466 -253 253 253 253 253 253 253 253 253 253 253 253
45467 -253 253 253 253 253 253 253 253 253 253 253 253
45468 -253 253 253 246 246 246 218 218 218 202 202 202
45469 -210 210 210 14 14 14 2 2 6 2 2 6
45470 - 30 30 30 22 22 22 2 2 6 2 2 6
45471 - 2 2 6 2 2 6 18 18 18 86 86 86
45472 - 42 42 42 14 14 14 0 0 0 0 0 0
45473 - 0 0 0 0 0 0 0 0 0 0 0 0
45474 - 0 0 0 0 0 0 0 0 0 0 0 0
45475 - 0 0 0 0 0 0 0 0 0 0 0 0
45476 - 0 0 0 0 0 0 0 0 0 0 0 0
45477 - 0 0 0 0 0 0 0 0 0 0 0 0
45478 - 0 0 0 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 14 14 14
45481 - 42 42 42 90 90 90 22 22 22 2 2 6
45482 - 42 42 42 2 2 6 18 18 18 218 218 218
45483 -253 253 253 253 253 253 253 253 253 253 253 253
45484 -253 253 253 253 253 253 253 253 253 253 253 253
45485 -253 253 253 253 253 253 253 253 253 253 253 253
45486 -253 253 253 253 253 253 253 253 253 253 253 253
45487 -253 253 253 253 253 253 253 253 253 253 253 253
45488 -253 253 253 253 253 253 250 250 250 221 221 221
45489 -218 218 218 101 101 101 2 2 6 14 14 14
45490 - 18 18 18 38 38 38 10 10 10 2 2 6
45491 - 2 2 6 2 2 6 2 2 6 78 78 78
45492 - 58 58 58 22 22 22 6 6 6 0 0 0
45493 - 0 0 0 0 0 0 0 0 0 0 0 0
45494 - 0 0 0 0 0 0 0 0 0 0 0 0
45495 - 0 0 0 0 0 0 0 0 0 0 0 0
45496 - 0 0 0 0 0 0 0 0 0 0 0 0
45497 - 0 0 0 0 0 0 0 0 0 0 0 0
45498 - 0 0 0 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 6 6 6 18 18 18
45501 - 54 54 54 82 82 82 2 2 6 26 26 26
45502 - 22 22 22 2 2 6 123 123 123 253 253 253
45503 -253 253 253 253 253 253 253 253 253 253 253 253
45504 -253 253 253 253 253 253 253 253 253 253 253 253
45505 -253 253 253 253 253 253 253 253 253 253 253 253
45506 -253 253 253 253 253 253 253 253 253 253 253 253
45507 -253 253 253 253 253 253 253 253 253 253 253 253
45508 -253 253 253 253 253 253 253 253 253 250 250 250
45509 -238 238 238 198 198 198 6 6 6 38 38 38
45510 - 58 58 58 26 26 26 38 38 38 2 2 6
45511 - 2 2 6 2 2 6 2 2 6 46 46 46
45512 - 78 78 78 30 30 30 10 10 10 0 0 0
45513 - 0 0 0 0 0 0 0 0 0 0 0 0
45514 - 0 0 0 0 0 0 0 0 0 0 0 0
45515 - 0 0 0 0 0 0 0 0 0 0 0 0
45516 - 0 0 0 0 0 0 0 0 0 0 0 0
45517 - 0 0 0 0 0 0 0 0 0 0 0 0
45518 - 0 0 0 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 10 10 10 30 30 30
45521 - 74 74 74 58 58 58 2 2 6 42 42 42
45522 - 2 2 6 22 22 22 231 231 231 253 253 253
45523 -253 253 253 253 253 253 253 253 253 253 253 253
45524 -253 253 253 253 253 253 253 253 253 250 250 250
45525 -253 253 253 253 253 253 253 253 253 253 253 253
45526 -253 253 253 253 253 253 253 253 253 253 253 253
45527 -253 253 253 253 253 253 253 253 253 253 253 253
45528 -253 253 253 253 253 253 253 253 253 253 253 253
45529 -253 253 253 246 246 246 46 46 46 38 38 38
45530 - 42 42 42 14 14 14 38 38 38 14 14 14
45531 - 2 2 6 2 2 6 2 2 6 6 6 6
45532 - 86 86 86 46 46 46 14 14 14 0 0 0
45533 - 0 0 0 0 0 0 0 0 0 0 0 0
45534 - 0 0 0 0 0 0 0 0 0 0 0 0
45535 - 0 0 0 0 0 0 0 0 0 0 0 0
45536 - 0 0 0 0 0 0 0 0 0 0 0 0
45537 - 0 0 0 0 0 0 0 0 0 0 0 0
45538 - 0 0 0 0 0 0 0 0 0 0 0 0
45539 - 0 0 0 0 0 0 0 0 0 0 0 0
45540 - 0 0 0 6 6 6 14 14 14 42 42 42
45541 - 90 90 90 18 18 18 18 18 18 26 26 26
45542 - 2 2 6 116 116 116 253 253 253 253 253 253
45543 -253 253 253 253 253 253 253 253 253 253 253 253
45544 -253 253 253 253 253 253 250 250 250 238 238 238
45545 -253 253 253 253 253 253 253 253 253 253 253 253
45546 -253 253 253 253 253 253 253 253 253 253 253 253
45547 -253 253 253 253 253 253 253 253 253 253 253 253
45548 -253 253 253 253 253 253 253 253 253 253 253 253
45549 -253 253 253 253 253 253 94 94 94 6 6 6
45550 - 2 2 6 2 2 6 10 10 10 34 34 34
45551 - 2 2 6 2 2 6 2 2 6 2 2 6
45552 - 74 74 74 58 58 58 22 22 22 6 6 6
45553 - 0 0 0 0 0 0 0 0 0 0 0 0
45554 - 0 0 0 0 0 0 0 0 0 0 0 0
45555 - 0 0 0 0 0 0 0 0 0 0 0 0
45556 - 0 0 0 0 0 0 0 0 0 0 0 0
45557 - 0 0 0 0 0 0 0 0 0 0 0 0
45558 - 0 0 0 0 0 0 0 0 0 0 0 0
45559 - 0 0 0 0 0 0 0 0 0 0 0 0
45560 - 0 0 0 10 10 10 26 26 26 66 66 66
45561 - 82 82 82 2 2 6 38 38 38 6 6 6
45562 - 14 14 14 210 210 210 253 253 253 253 253 253
45563 -253 253 253 253 253 253 253 253 253 253 253 253
45564 -253 253 253 253 253 253 246 246 246 242 242 242
45565 -253 253 253 253 253 253 253 253 253 253 253 253
45566 -253 253 253 253 253 253 253 253 253 253 253 253
45567 -253 253 253 253 253 253 253 253 253 253 253 253
45568 -253 253 253 253 253 253 253 253 253 253 253 253
45569 -253 253 253 253 253 253 144 144 144 2 2 6
45570 - 2 2 6 2 2 6 2 2 6 46 46 46
45571 - 2 2 6 2 2 6 2 2 6 2 2 6
45572 - 42 42 42 74 74 74 30 30 30 10 10 10
45573 - 0 0 0 0 0 0 0 0 0 0 0 0
45574 - 0 0 0 0 0 0 0 0 0 0 0 0
45575 - 0 0 0 0 0 0 0 0 0 0 0 0
45576 - 0 0 0 0 0 0 0 0 0 0 0 0
45577 - 0 0 0 0 0 0 0 0 0 0 0 0
45578 - 0 0 0 0 0 0 0 0 0 0 0 0
45579 - 0 0 0 0 0 0 0 0 0 0 0 0
45580 - 6 6 6 14 14 14 42 42 42 90 90 90
45581 - 26 26 26 6 6 6 42 42 42 2 2 6
45582 - 74 74 74 250 250 250 253 253 253 253 253 253
45583 -253 253 253 253 253 253 253 253 253 253 253 253
45584 -253 253 253 253 253 253 242 242 242 242 242 242
45585 -253 253 253 253 253 253 253 253 253 253 253 253
45586 -253 253 253 253 253 253 253 253 253 253 253 253
45587 -253 253 253 253 253 253 253 253 253 253 253 253
45588 -253 253 253 253 253 253 253 253 253 253 253 253
45589 -253 253 253 253 253 253 182 182 182 2 2 6
45590 - 2 2 6 2 2 6 2 2 6 46 46 46
45591 - 2 2 6 2 2 6 2 2 6 2 2 6
45592 - 10 10 10 86 86 86 38 38 38 10 10 10
45593 - 0 0 0 0 0 0 0 0 0 0 0 0
45594 - 0 0 0 0 0 0 0 0 0 0 0 0
45595 - 0 0 0 0 0 0 0 0 0 0 0 0
45596 - 0 0 0 0 0 0 0 0 0 0 0 0
45597 - 0 0 0 0 0 0 0 0 0 0 0 0
45598 - 0 0 0 0 0 0 0 0 0 0 0 0
45599 - 0 0 0 0 0 0 0 0 0 0 0 0
45600 - 10 10 10 26 26 26 66 66 66 82 82 82
45601 - 2 2 6 22 22 22 18 18 18 2 2 6
45602 -149 149 149 253 253 253 253 253 253 253 253 253
45603 -253 253 253 253 253 253 253 253 253 253 253 253
45604 -253 253 253 253 253 253 234 234 234 242 242 242
45605 -253 253 253 253 253 253 253 253 253 253 253 253
45606 -253 253 253 253 253 253 253 253 253 253 253 253
45607 -253 253 253 253 253 253 253 253 253 253 253 253
45608 -253 253 253 253 253 253 253 253 253 253 253 253
45609 -253 253 253 253 253 253 206 206 206 2 2 6
45610 - 2 2 6 2 2 6 2 2 6 38 38 38
45611 - 2 2 6 2 2 6 2 2 6 2 2 6
45612 - 6 6 6 86 86 86 46 46 46 14 14 14
45613 - 0 0 0 0 0 0 0 0 0 0 0 0
45614 - 0 0 0 0 0 0 0 0 0 0 0 0
45615 - 0 0 0 0 0 0 0 0 0 0 0 0
45616 - 0 0 0 0 0 0 0 0 0 0 0 0
45617 - 0 0 0 0 0 0 0 0 0 0 0 0
45618 - 0 0 0 0 0 0 0 0 0 0 0 0
45619 - 0 0 0 0 0 0 0 0 0 6 6 6
45620 - 18 18 18 46 46 46 86 86 86 18 18 18
45621 - 2 2 6 34 34 34 10 10 10 6 6 6
45622 -210 210 210 253 253 253 253 253 253 253 253 253
45623 -253 253 253 253 253 253 253 253 253 253 253 253
45624 -253 253 253 253 253 253 234 234 234 242 242 242
45625 -253 253 253 253 253 253 253 253 253 253 253 253
45626 -253 253 253 253 253 253 253 253 253 253 253 253
45627 -253 253 253 253 253 253 253 253 253 253 253 253
45628 -253 253 253 253 253 253 253 253 253 253 253 253
45629 -253 253 253 253 253 253 221 221 221 6 6 6
45630 - 2 2 6 2 2 6 6 6 6 30 30 30
45631 - 2 2 6 2 2 6 2 2 6 2 2 6
45632 - 2 2 6 82 82 82 54 54 54 18 18 18
45633 - 6 6 6 0 0 0 0 0 0 0 0 0
45634 - 0 0 0 0 0 0 0 0 0 0 0 0
45635 - 0 0 0 0 0 0 0 0 0 0 0 0
45636 - 0 0 0 0 0 0 0 0 0 0 0 0
45637 - 0 0 0 0 0 0 0 0 0 0 0 0
45638 - 0 0 0 0 0 0 0 0 0 0 0 0
45639 - 0 0 0 0 0 0 0 0 0 10 10 10
45640 - 26 26 26 66 66 66 62 62 62 2 2 6
45641 - 2 2 6 38 38 38 10 10 10 26 26 26
45642 -238 238 238 253 253 253 253 253 253 253 253 253
45643 -253 253 253 253 253 253 253 253 253 253 253 253
45644 -253 253 253 253 253 253 231 231 231 238 238 238
45645 -253 253 253 253 253 253 253 253 253 253 253 253
45646 -253 253 253 253 253 253 253 253 253 253 253 253
45647 -253 253 253 253 253 253 253 253 253 253 253 253
45648 -253 253 253 253 253 253 253 253 253 253 253 253
45649 -253 253 253 253 253 253 231 231 231 6 6 6
45650 - 2 2 6 2 2 6 10 10 10 30 30 30
45651 - 2 2 6 2 2 6 2 2 6 2 2 6
45652 - 2 2 6 66 66 66 58 58 58 22 22 22
45653 - 6 6 6 0 0 0 0 0 0 0 0 0
45654 - 0 0 0 0 0 0 0 0 0 0 0 0
45655 - 0 0 0 0 0 0 0 0 0 0 0 0
45656 - 0 0 0 0 0 0 0 0 0 0 0 0
45657 - 0 0 0 0 0 0 0 0 0 0 0 0
45658 - 0 0 0 0 0 0 0 0 0 0 0 0
45659 - 0 0 0 0 0 0 0 0 0 10 10 10
45660 - 38 38 38 78 78 78 6 6 6 2 2 6
45661 - 2 2 6 46 46 46 14 14 14 42 42 42
45662 -246 246 246 253 253 253 253 253 253 253 253 253
45663 -253 253 253 253 253 253 253 253 253 253 253 253
45664 -253 253 253 253 253 253 231 231 231 242 242 242
45665 -253 253 253 253 253 253 253 253 253 253 253 253
45666 -253 253 253 253 253 253 253 253 253 253 253 253
45667 -253 253 253 253 253 253 253 253 253 253 253 253
45668 -253 253 253 253 253 253 253 253 253 253 253 253
45669 -253 253 253 253 253 253 234 234 234 10 10 10
45670 - 2 2 6 2 2 6 22 22 22 14 14 14
45671 - 2 2 6 2 2 6 2 2 6 2 2 6
45672 - 2 2 6 66 66 66 62 62 62 22 22 22
45673 - 6 6 6 0 0 0 0 0 0 0 0 0
45674 - 0 0 0 0 0 0 0 0 0 0 0 0
45675 - 0 0 0 0 0 0 0 0 0 0 0 0
45676 - 0 0 0 0 0 0 0 0 0 0 0 0
45677 - 0 0 0 0 0 0 0 0 0 0 0 0
45678 - 0 0 0 0 0 0 0 0 0 0 0 0
45679 - 0 0 0 0 0 0 6 6 6 18 18 18
45680 - 50 50 50 74 74 74 2 2 6 2 2 6
45681 - 14 14 14 70 70 70 34 34 34 62 62 62
45682 -250 250 250 253 253 253 253 253 253 253 253 253
45683 -253 253 253 253 253 253 253 253 253 253 253 253
45684 -253 253 253 253 253 253 231 231 231 246 246 246
45685 -253 253 253 253 253 253 253 253 253 253 253 253
45686 -253 253 253 253 253 253 253 253 253 253 253 253
45687 -253 253 253 253 253 253 253 253 253 253 253 253
45688 -253 253 253 253 253 253 253 253 253 253 253 253
45689 -253 253 253 253 253 253 234 234 234 14 14 14
45690 - 2 2 6 2 2 6 30 30 30 2 2 6
45691 - 2 2 6 2 2 6 2 2 6 2 2 6
45692 - 2 2 6 66 66 66 62 62 62 22 22 22
45693 - 6 6 6 0 0 0 0 0 0 0 0 0
45694 - 0 0 0 0 0 0 0 0 0 0 0 0
45695 - 0 0 0 0 0 0 0 0 0 0 0 0
45696 - 0 0 0 0 0 0 0 0 0 0 0 0
45697 - 0 0 0 0 0 0 0 0 0 0 0 0
45698 - 0 0 0 0 0 0 0 0 0 0 0 0
45699 - 0 0 0 0 0 0 6 6 6 18 18 18
45700 - 54 54 54 62 62 62 2 2 6 2 2 6
45701 - 2 2 6 30 30 30 46 46 46 70 70 70
45702 -250 250 250 253 253 253 253 253 253 253 253 253
45703 -253 253 253 253 253 253 253 253 253 253 253 253
45704 -253 253 253 253 253 253 231 231 231 246 246 246
45705 -253 253 253 253 253 253 253 253 253 253 253 253
45706 -253 253 253 253 253 253 253 253 253 253 253 253
45707 -253 253 253 253 253 253 253 253 253 253 253 253
45708 -253 253 253 253 253 253 253 253 253 253 253 253
45709 -253 253 253 253 253 253 226 226 226 10 10 10
45710 - 2 2 6 6 6 6 30 30 30 2 2 6
45711 - 2 2 6 2 2 6 2 2 6 2 2 6
45712 - 2 2 6 66 66 66 58 58 58 22 22 22
45713 - 6 6 6 0 0 0 0 0 0 0 0 0
45714 - 0 0 0 0 0 0 0 0 0 0 0 0
45715 - 0 0 0 0 0 0 0 0 0 0 0 0
45716 - 0 0 0 0 0 0 0 0 0 0 0 0
45717 - 0 0 0 0 0 0 0 0 0 0 0 0
45718 - 0 0 0 0 0 0 0 0 0 0 0 0
45719 - 0 0 0 0 0 0 6 6 6 22 22 22
45720 - 58 58 58 62 62 62 2 2 6 2 2 6
45721 - 2 2 6 2 2 6 30 30 30 78 78 78
45722 -250 250 250 253 253 253 253 253 253 253 253 253
45723 -253 253 253 253 253 253 253 253 253 253 253 253
45724 -253 253 253 253 253 253 231 231 231 246 246 246
45725 -253 253 253 253 253 253 253 253 253 253 253 253
45726 -253 253 253 253 253 253 253 253 253 253 253 253
45727 -253 253 253 253 253 253 253 253 253 253 253 253
45728 -253 253 253 253 253 253 253 253 253 253 253 253
45729 -253 253 253 253 253 253 206 206 206 2 2 6
45730 - 22 22 22 34 34 34 18 14 6 22 22 22
45731 - 26 26 26 18 18 18 6 6 6 2 2 6
45732 - 2 2 6 82 82 82 54 54 54 18 18 18
45733 - 6 6 6 0 0 0 0 0 0 0 0 0
45734 - 0 0 0 0 0 0 0 0 0 0 0 0
45735 - 0 0 0 0 0 0 0 0 0 0 0 0
45736 - 0 0 0 0 0 0 0 0 0 0 0 0
45737 - 0 0 0 0 0 0 0 0 0 0 0 0
45738 - 0 0 0 0 0 0 0 0 0 0 0 0
45739 - 0 0 0 0 0 0 6 6 6 26 26 26
45740 - 62 62 62 106 106 106 74 54 14 185 133 11
45741 -210 162 10 121 92 8 6 6 6 62 62 62
45742 -238 238 238 253 253 253 253 253 253 253 253 253
45743 -253 253 253 253 253 253 253 253 253 253 253 253
45744 -253 253 253 253 253 253 231 231 231 246 246 246
45745 -253 253 253 253 253 253 253 253 253 253 253 253
45746 -253 253 253 253 253 253 253 253 253 253 253 253
45747 -253 253 253 253 253 253 253 253 253 253 253 253
45748 -253 253 253 253 253 253 253 253 253 253 253 253
45749 -253 253 253 253 253 253 158 158 158 18 18 18
45750 - 14 14 14 2 2 6 2 2 6 2 2 6
45751 - 6 6 6 18 18 18 66 66 66 38 38 38
45752 - 6 6 6 94 94 94 50 50 50 18 18 18
45753 - 6 6 6 0 0 0 0 0 0 0 0 0
45754 - 0 0 0 0 0 0 0 0 0 0 0 0
45755 - 0 0 0 0 0 0 0 0 0 0 0 0
45756 - 0 0 0 0 0 0 0 0 0 0 0 0
45757 - 0 0 0 0 0 0 0 0 0 0 0 0
45758 - 0 0 0 0 0 0 0 0 0 6 6 6
45759 - 10 10 10 10 10 10 18 18 18 38 38 38
45760 - 78 78 78 142 134 106 216 158 10 242 186 14
45761 -246 190 14 246 190 14 156 118 10 10 10 10
45762 - 90 90 90 238 238 238 253 253 253 253 253 253
45763 -253 253 253 253 253 253 253 253 253 253 253 253
45764 -253 253 253 253 253 253 231 231 231 250 250 250
45765 -253 253 253 253 253 253 253 253 253 253 253 253
45766 -253 253 253 253 253 253 253 253 253 253 253 253
45767 -253 253 253 253 253 253 253 253 253 253 253 253
45768 -253 253 253 253 253 253 253 253 253 246 230 190
45769 -238 204 91 238 204 91 181 142 44 37 26 9
45770 - 2 2 6 2 2 6 2 2 6 2 2 6
45771 - 2 2 6 2 2 6 38 38 38 46 46 46
45772 - 26 26 26 106 106 106 54 54 54 18 18 18
45773 - 6 6 6 0 0 0 0 0 0 0 0 0
45774 - 0 0 0 0 0 0 0 0 0 0 0 0
45775 - 0 0 0 0 0 0 0 0 0 0 0 0
45776 - 0 0 0 0 0 0 0 0 0 0 0 0
45777 - 0 0 0 0 0 0 0 0 0 0 0 0
45778 - 0 0 0 6 6 6 14 14 14 22 22 22
45779 - 30 30 30 38 38 38 50 50 50 70 70 70
45780 -106 106 106 190 142 34 226 170 11 242 186 14
45781 -246 190 14 246 190 14 246 190 14 154 114 10
45782 - 6 6 6 74 74 74 226 226 226 253 253 253
45783 -253 253 253 253 253 253 253 253 253 253 253 253
45784 -253 253 253 253 253 253 231 231 231 250 250 250
45785 -253 253 253 253 253 253 253 253 253 253 253 253
45786 -253 253 253 253 253 253 253 253 253 253 253 253
45787 -253 253 253 253 253 253 253 253 253 253 253 253
45788 -253 253 253 253 253 253 253 253 253 228 184 62
45789 -241 196 14 241 208 19 232 195 16 38 30 10
45790 - 2 2 6 2 2 6 2 2 6 2 2 6
45791 - 2 2 6 6 6 6 30 30 30 26 26 26
45792 -203 166 17 154 142 90 66 66 66 26 26 26
45793 - 6 6 6 0 0 0 0 0 0 0 0 0
45794 - 0 0 0 0 0 0 0 0 0 0 0 0
45795 - 0 0 0 0 0 0 0 0 0 0 0 0
45796 - 0 0 0 0 0 0 0 0 0 0 0 0
45797 - 0 0 0 0 0 0 0 0 0 0 0 0
45798 - 6 6 6 18 18 18 38 38 38 58 58 58
45799 - 78 78 78 86 86 86 101 101 101 123 123 123
45800 -175 146 61 210 150 10 234 174 13 246 186 14
45801 -246 190 14 246 190 14 246 190 14 238 190 10
45802 -102 78 10 2 2 6 46 46 46 198 198 198
45803 -253 253 253 253 253 253 253 253 253 253 253 253
45804 -253 253 253 253 253 253 234 234 234 242 242 242
45805 -253 253 253 253 253 253 253 253 253 253 253 253
45806 -253 253 253 253 253 253 253 253 253 253 253 253
45807 -253 253 253 253 253 253 253 253 253 253 253 253
45808 -253 253 253 253 253 253 253 253 253 224 178 62
45809 -242 186 14 241 196 14 210 166 10 22 18 6
45810 - 2 2 6 2 2 6 2 2 6 2 2 6
45811 - 2 2 6 2 2 6 6 6 6 121 92 8
45812 -238 202 15 232 195 16 82 82 82 34 34 34
45813 - 10 10 10 0 0 0 0 0 0 0 0 0
45814 - 0 0 0 0 0 0 0 0 0 0 0 0
45815 - 0 0 0 0 0 0 0 0 0 0 0 0
45816 - 0 0 0 0 0 0 0 0 0 0 0 0
45817 - 0 0 0 0 0 0 0 0 0 0 0 0
45818 - 14 14 14 38 38 38 70 70 70 154 122 46
45819 -190 142 34 200 144 11 197 138 11 197 138 11
45820 -213 154 11 226 170 11 242 186 14 246 190 14
45821 -246 190 14 246 190 14 246 190 14 246 190 14
45822 -225 175 15 46 32 6 2 2 6 22 22 22
45823 -158 158 158 250 250 250 253 253 253 253 253 253
45824 -253 253 253 253 253 253 253 253 253 253 253 253
45825 -253 253 253 253 253 253 253 253 253 253 253 253
45826 -253 253 253 253 253 253 253 253 253 253 253 253
45827 -253 253 253 253 253 253 253 253 253 253 253 253
45828 -253 253 253 250 250 250 242 242 242 224 178 62
45829 -239 182 13 236 186 11 213 154 11 46 32 6
45830 - 2 2 6 2 2 6 2 2 6 2 2 6
45831 - 2 2 6 2 2 6 61 42 6 225 175 15
45832 -238 190 10 236 186 11 112 100 78 42 42 42
45833 - 14 14 14 0 0 0 0 0 0 0 0 0
45834 - 0 0 0 0 0 0 0 0 0 0 0 0
45835 - 0 0 0 0 0 0 0 0 0 0 0 0
45836 - 0 0 0 0 0 0 0 0 0 0 0 0
45837 - 0 0 0 0 0 0 0 0 0 6 6 6
45838 - 22 22 22 54 54 54 154 122 46 213 154 11
45839 -226 170 11 230 174 11 226 170 11 226 170 11
45840 -236 178 12 242 186 14 246 190 14 246 190 14
45841 -246 190 14 246 190 14 246 190 14 246 190 14
45842 -241 196 14 184 144 12 10 10 10 2 2 6
45843 - 6 6 6 116 116 116 242 242 242 253 253 253
45844 -253 253 253 253 253 253 253 253 253 253 253 253
45845 -253 253 253 253 253 253 253 253 253 253 253 253
45846 -253 253 253 253 253 253 253 253 253 253 253 253
45847 -253 253 253 253 253 253 253 253 253 253 253 253
45848 -253 253 253 231 231 231 198 198 198 214 170 54
45849 -236 178 12 236 178 12 210 150 10 137 92 6
45850 - 18 14 6 2 2 6 2 2 6 2 2 6
45851 - 6 6 6 70 47 6 200 144 11 236 178 12
45852 -239 182 13 239 182 13 124 112 88 58 58 58
45853 - 22 22 22 6 6 6 0 0 0 0 0 0
45854 - 0 0 0 0 0 0 0 0 0 0 0 0
45855 - 0 0 0 0 0 0 0 0 0 0 0 0
45856 - 0 0 0 0 0 0 0 0 0 0 0 0
45857 - 0 0 0 0 0 0 0 0 0 10 10 10
45858 - 30 30 30 70 70 70 180 133 36 226 170 11
45859 -239 182 13 242 186 14 242 186 14 246 186 14
45860 -246 190 14 246 190 14 246 190 14 246 190 14
45861 -246 190 14 246 190 14 246 190 14 246 190 14
45862 -246 190 14 232 195 16 98 70 6 2 2 6
45863 - 2 2 6 2 2 6 66 66 66 221 221 221
45864 -253 253 253 253 253 253 253 253 253 253 253 253
45865 -253 253 253 253 253 253 253 253 253 253 253 253
45866 -253 253 253 253 253 253 253 253 253 253 253 253
45867 -253 253 253 253 253 253 253 253 253 253 253 253
45868 -253 253 253 206 206 206 198 198 198 214 166 58
45869 -230 174 11 230 174 11 216 158 10 192 133 9
45870 -163 110 8 116 81 8 102 78 10 116 81 8
45871 -167 114 7 197 138 11 226 170 11 239 182 13
45872 -242 186 14 242 186 14 162 146 94 78 78 78
45873 - 34 34 34 14 14 14 6 6 6 0 0 0
45874 - 0 0 0 0 0 0 0 0 0 0 0 0
45875 - 0 0 0 0 0 0 0 0 0 0 0 0
45876 - 0 0 0 0 0 0 0 0 0 0 0 0
45877 - 0 0 0 0 0 0 0 0 0 6 6 6
45878 - 30 30 30 78 78 78 190 142 34 226 170 11
45879 -239 182 13 246 190 14 246 190 14 246 190 14
45880 -246 190 14 246 190 14 246 190 14 246 190 14
45881 -246 190 14 246 190 14 246 190 14 246 190 14
45882 -246 190 14 241 196 14 203 166 17 22 18 6
45883 - 2 2 6 2 2 6 2 2 6 38 38 38
45884 -218 218 218 253 253 253 253 253 253 253 253 253
45885 -253 253 253 253 253 253 253 253 253 253 253 253
45886 -253 253 253 253 253 253 253 253 253 253 253 253
45887 -253 253 253 253 253 253 253 253 253 253 253 253
45888 -250 250 250 206 206 206 198 198 198 202 162 69
45889 -226 170 11 236 178 12 224 166 10 210 150 10
45890 -200 144 11 197 138 11 192 133 9 197 138 11
45891 -210 150 10 226 170 11 242 186 14 246 190 14
45892 -246 190 14 246 186 14 225 175 15 124 112 88
45893 - 62 62 62 30 30 30 14 14 14 6 6 6
45894 - 0 0 0 0 0 0 0 0 0 0 0 0
45895 - 0 0 0 0 0 0 0 0 0 0 0 0
45896 - 0 0 0 0 0 0 0 0 0 0 0 0
45897 - 0 0 0 0 0 0 0 0 0 10 10 10
45898 - 30 30 30 78 78 78 174 135 50 224 166 10
45899 -239 182 13 246 190 14 246 190 14 246 190 14
45900 -246 190 14 246 190 14 246 190 14 246 190 14
45901 -246 190 14 246 190 14 246 190 14 246 190 14
45902 -246 190 14 246 190 14 241 196 14 139 102 15
45903 - 2 2 6 2 2 6 2 2 6 2 2 6
45904 - 78 78 78 250 250 250 253 253 253 253 253 253
45905 -253 253 253 253 253 253 253 253 253 253 253 253
45906 -253 253 253 253 253 253 253 253 253 253 253 253
45907 -253 253 253 253 253 253 253 253 253 253 253 253
45908 -250 250 250 214 214 214 198 198 198 190 150 46
45909 -219 162 10 236 178 12 234 174 13 224 166 10
45910 -216 158 10 213 154 11 213 154 11 216 158 10
45911 -226 170 11 239 182 13 246 190 14 246 190 14
45912 -246 190 14 246 190 14 242 186 14 206 162 42
45913 -101 101 101 58 58 58 30 30 30 14 14 14
45914 - 6 6 6 0 0 0 0 0 0 0 0 0
45915 - 0 0 0 0 0 0 0 0 0 0 0 0
45916 - 0 0 0 0 0 0 0 0 0 0 0 0
45917 - 0 0 0 0 0 0 0 0 0 10 10 10
45918 - 30 30 30 74 74 74 174 135 50 216 158 10
45919 -236 178 12 246 190 14 246 190 14 246 190 14
45920 -246 190 14 246 190 14 246 190 14 246 190 14
45921 -246 190 14 246 190 14 246 190 14 246 190 14
45922 -246 190 14 246 190 14 241 196 14 226 184 13
45923 - 61 42 6 2 2 6 2 2 6 2 2 6
45924 - 22 22 22 238 238 238 253 253 253 253 253 253
45925 -253 253 253 253 253 253 253 253 253 253 253 253
45926 -253 253 253 253 253 253 253 253 253 253 253 253
45927 -253 253 253 253 253 253 253 253 253 253 253 253
45928 -253 253 253 226 226 226 187 187 187 180 133 36
45929 -216 158 10 236 178 12 239 182 13 236 178 12
45930 -230 174 11 226 170 11 226 170 11 230 174 11
45931 -236 178 12 242 186 14 246 190 14 246 190 14
45932 -246 190 14 246 190 14 246 186 14 239 182 13
45933 -206 162 42 106 106 106 66 66 66 34 34 34
45934 - 14 14 14 6 6 6 0 0 0 0 0 0
45935 - 0 0 0 0 0 0 0 0 0 0 0 0
45936 - 0 0 0 0 0 0 0 0 0 0 0 0
45937 - 0 0 0 0 0 0 0 0 0 6 6 6
45938 - 26 26 26 70 70 70 163 133 67 213 154 11
45939 -236 178 12 246 190 14 246 190 14 246 190 14
45940 -246 190 14 246 190 14 246 190 14 246 190 14
45941 -246 190 14 246 190 14 246 190 14 246 190 14
45942 -246 190 14 246 190 14 246 190 14 241 196 14
45943 -190 146 13 18 14 6 2 2 6 2 2 6
45944 - 46 46 46 246 246 246 253 253 253 253 253 253
45945 -253 253 253 253 253 253 253 253 253 253 253 253
45946 -253 253 253 253 253 253 253 253 253 253 253 253
45947 -253 253 253 253 253 253 253 253 253 253 253 253
45948 -253 253 253 221 221 221 86 86 86 156 107 11
45949 -216 158 10 236 178 12 242 186 14 246 186 14
45950 -242 186 14 239 182 13 239 182 13 242 186 14
45951 -242 186 14 246 186 14 246 190 14 246 190 14
45952 -246 190 14 246 190 14 246 190 14 246 190 14
45953 -242 186 14 225 175 15 142 122 72 66 66 66
45954 - 30 30 30 10 10 10 0 0 0 0 0 0
45955 - 0 0 0 0 0 0 0 0 0 0 0 0
45956 - 0 0 0 0 0 0 0 0 0 0 0 0
45957 - 0 0 0 0 0 0 0 0 0 6 6 6
45958 - 26 26 26 70 70 70 163 133 67 210 150 10
45959 -236 178 12 246 190 14 246 190 14 246 190 14
45960 -246 190 14 246 190 14 246 190 14 246 190 14
45961 -246 190 14 246 190 14 246 190 14 246 190 14
45962 -246 190 14 246 190 14 246 190 14 246 190 14
45963 -232 195 16 121 92 8 34 34 34 106 106 106
45964 -221 221 221 253 253 253 253 253 253 253 253 253
45965 -253 253 253 253 253 253 253 253 253 253 253 253
45966 -253 253 253 253 253 253 253 253 253 253 253 253
45967 -253 253 253 253 253 253 253 253 253 253 253 253
45968 -242 242 242 82 82 82 18 14 6 163 110 8
45969 -216 158 10 236 178 12 242 186 14 246 190 14
45970 -246 190 14 246 190 14 246 190 14 246 190 14
45971 -246 190 14 246 190 14 246 190 14 246 190 14
45972 -246 190 14 246 190 14 246 190 14 246 190 14
45973 -246 190 14 246 190 14 242 186 14 163 133 67
45974 - 46 46 46 18 18 18 6 6 6 0 0 0
45975 - 0 0 0 0 0 0 0 0 0 0 0 0
45976 - 0 0 0 0 0 0 0 0 0 0 0 0
45977 - 0 0 0 0 0 0 0 0 0 10 10 10
45978 - 30 30 30 78 78 78 163 133 67 210 150 10
45979 -236 178 12 246 186 14 246 190 14 246 190 14
45980 -246 190 14 246 190 14 246 190 14 246 190 14
45981 -246 190 14 246 190 14 246 190 14 246 190 14
45982 -246 190 14 246 190 14 246 190 14 246 190 14
45983 -241 196 14 215 174 15 190 178 144 253 253 253
45984 -253 253 253 253 253 253 253 253 253 253 253 253
45985 -253 253 253 253 253 253 253 253 253 253 253 253
45986 -253 253 253 253 253 253 253 253 253 253 253 253
45987 -253 253 253 253 253 253 253 253 253 218 218 218
45988 - 58 58 58 2 2 6 22 18 6 167 114 7
45989 -216 158 10 236 178 12 246 186 14 246 190 14
45990 -246 190 14 246 190 14 246 190 14 246 190 14
45991 -246 190 14 246 190 14 246 190 14 246 190 14
45992 -246 190 14 246 190 14 246 190 14 246 190 14
45993 -246 190 14 246 186 14 242 186 14 190 150 46
45994 - 54 54 54 22 22 22 6 6 6 0 0 0
45995 - 0 0 0 0 0 0 0 0 0 0 0 0
45996 - 0 0 0 0 0 0 0 0 0 0 0 0
45997 - 0 0 0 0 0 0 0 0 0 14 14 14
45998 - 38 38 38 86 86 86 180 133 36 213 154 11
45999 -236 178 12 246 186 14 246 190 14 246 190 14
46000 -246 190 14 246 190 14 246 190 14 246 190 14
46001 -246 190 14 246 190 14 246 190 14 246 190 14
46002 -246 190 14 246 190 14 246 190 14 246 190 14
46003 -246 190 14 232 195 16 190 146 13 214 214 214
46004 -253 253 253 253 253 253 253 253 253 253 253 253
46005 -253 253 253 253 253 253 253 253 253 253 253 253
46006 -253 253 253 253 253 253 253 253 253 253 253 253
46007 -253 253 253 250 250 250 170 170 170 26 26 26
46008 - 2 2 6 2 2 6 37 26 9 163 110 8
46009 -219 162 10 239 182 13 246 186 14 246 190 14
46010 -246 190 14 246 190 14 246 190 14 246 190 14
46011 -246 190 14 246 190 14 246 190 14 246 190 14
46012 -246 190 14 246 190 14 246 190 14 246 190 14
46013 -246 186 14 236 178 12 224 166 10 142 122 72
46014 - 46 46 46 18 18 18 6 6 6 0 0 0
46015 - 0 0 0 0 0 0 0 0 0 0 0 0
46016 - 0 0 0 0 0 0 0 0 0 0 0 0
46017 - 0 0 0 0 0 0 6 6 6 18 18 18
46018 - 50 50 50 109 106 95 192 133 9 224 166 10
46019 -242 186 14 246 190 14 246 190 14 246 190 14
46020 -246 190 14 246 190 14 246 190 14 246 190 14
46021 -246 190 14 246 190 14 246 190 14 246 190 14
46022 -246 190 14 246 190 14 246 190 14 246 190 14
46023 -242 186 14 226 184 13 210 162 10 142 110 46
46024 -226 226 226 253 253 253 253 253 253 253 253 253
46025 -253 253 253 253 253 253 253 253 253 253 253 253
46026 -253 253 253 253 253 253 253 253 253 253 253 253
46027 -198 198 198 66 66 66 2 2 6 2 2 6
46028 - 2 2 6 2 2 6 50 34 6 156 107 11
46029 -219 162 10 239 182 13 246 186 14 246 190 14
46030 -246 190 14 246 190 14 246 190 14 246 190 14
46031 -246 190 14 246 190 14 246 190 14 246 190 14
46032 -246 190 14 246 190 14 246 190 14 242 186 14
46033 -234 174 13 213 154 11 154 122 46 66 66 66
46034 - 30 30 30 10 10 10 0 0 0 0 0 0
46035 - 0 0 0 0 0 0 0 0 0 0 0 0
46036 - 0 0 0 0 0 0 0 0 0 0 0 0
46037 - 0 0 0 0 0 0 6 6 6 22 22 22
46038 - 58 58 58 154 121 60 206 145 10 234 174 13
46039 -242 186 14 246 186 14 246 190 14 246 190 14
46040 -246 190 14 246 190 14 246 190 14 246 190 14
46041 -246 190 14 246 190 14 246 190 14 246 190 14
46042 -246 190 14 246 190 14 246 190 14 246 190 14
46043 -246 186 14 236 178 12 210 162 10 163 110 8
46044 - 61 42 6 138 138 138 218 218 218 250 250 250
46045 -253 253 253 253 253 253 253 253 253 250 250 250
46046 -242 242 242 210 210 210 144 144 144 66 66 66
46047 - 6 6 6 2 2 6 2 2 6 2 2 6
46048 - 2 2 6 2 2 6 61 42 6 163 110 8
46049 -216 158 10 236 178 12 246 190 14 246 190 14
46050 -246 190 14 246 190 14 246 190 14 246 190 14
46051 -246 190 14 246 190 14 246 190 14 246 190 14
46052 -246 190 14 239 182 13 230 174 11 216 158 10
46053 -190 142 34 124 112 88 70 70 70 38 38 38
46054 - 18 18 18 6 6 6 0 0 0 0 0 0
46055 - 0 0 0 0 0 0 0 0 0 0 0 0
46056 - 0 0 0 0 0 0 0 0 0 0 0 0
46057 - 0 0 0 0 0 0 6 6 6 22 22 22
46058 - 62 62 62 168 124 44 206 145 10 224 166 10
46059 -236 178 12 239 182 13 242 186 14 242 186 14
46060 -246 186 14 246 190 14 246 190 14 246 190 14
46061 -246 190 14 246 190 14 246 190 14 246 190 14
46062 -246 190 14 246 190 14 246 190 14 246 190 14
46063 -246 190 14 236 178 12 216 158 10 175 118 6
46064 - 80 54 7 2 2 6 6 6 6 30 30 30
46065 - 54 54 54 62 62 62 50 50 50 38 38 38
46066 - 14 14 14 2 2 6 2 2 6 2 2 6
46067 - 2 2 6 2 2 6 2 2 6 2 2 6
46068 - 2 2 6 6 6 6 80 54 7 167 114 7
46069 -213 154 11 236 178 12 246 190 14 246 190 14
46070 -246 190 14 246 190 14 246 190 14 246 190 14
46071 -246 190 14 242 186 14 239 182 13 239 182 13
46072 -230 174 11 210 150 10 174 135 50 124 112 88
46073 - 82 82 82 54 54 54 34 34 34 18 18 18
46074 - 6 6 6 0 0 0 0 0 0 0 0 0
46075 - 0 0 0 0 0 0 0 0 0 0 0 0
46076 - 0 0 0 0 0 0 0 0 0 0 0 0
46077 - 0 0 0 0 0 0 6 6 6 18 18 18
46078 - 50 50 50 158 118 36 192 133 9 200 144 11
46079 -216 158 10 219 162 10 224 166 10 226 170 11
46080 -230 174 11 236 178 12 239 182 13 239 182 13
46081 -242 186 14 246 186 14 246 190 14 246 190 14
46082 -246 190 14 246 190 14 246 190 14 246 190 14
46083 -246 186 14 230 174 11 210 150 10 163 110 8
46084 -104 69 6 10 10 10 2 2 6 2 2 6
46085 - 2 2 6 2 2 6 2 2 6 2 2 6
46086 - 2 2 6 2 2 6 2 2 6 2 2 6
46087 - 2 2 6 2 2 6 2 2 6 2 2 6
46088 - 2 2 6 6 6 6 91 60 6 167 114 7
46089 -206 145 10 230 174 11 242 186 14 246 190 14
46090 -246 190 14 246 190 14 246 186 14 242 186 14
46091 -239 182 13 230 174 11 224 166 10 213 154 11
46092 -180 133 36 124 112 88 86 86 86 58 58 58
46093 - 38 38 38 22 22 22 10 10 10 6 6 6
46094 - 0 0 0 0 0 0 0 0 0 0 0 0
46095 - 0 0 0 0 0 0 0 0 0 0 0 0
46096 - 0 0 0 0 0 0 0 0 0 0 0 0
46097 - 0 0 0 0 0 0 0 0 0 14 14 14
46098 - 34 34 34 70 70 70 138 110 50 158 118 36
46099 -167 114 7 180 123 7 192 133 9 197 138 11
46100 -200 144 11 206 145 10 213 154 11 219 162 10
46101 -224 166 10 230 174 11 239 182 13 242 186 14
46102 -246 186 14 246 186 14 246 186 14 246 186 14
46103 -239 182 13 216 158 10 185 133 11 152 99 6
46104 -104 69 6 18 14 6 2 2 6 2 2 6
46105 - 2 2 6 2 2 6 2 2 6 2 2 6
46106 - 2 2 6 2 2 6 2 2 6 2 2 6
46107 - 2 2 6 2 2 6 2 2 6 2 2 6
46108 - 2 2 6 6 6 6 80 54 7 152 99 6
46109 -192 133 9 219 162 10 236 178 12 239 182 13
46110 -246 186 14 242 186 14 239 182 13 236 178 12
46111 -224 166 10 206 145 10 192 133 9 154 121 60
46112 - 94 94 94 62 62 62 42 42 42 22 22 22
46113 - 14 14 14 6 6 6 0 0 0 0 0 0
46114 - 0 0 0 0 0 0 0 0 0 0 0 0
46115 - 0 0 0 0 0 0 0 0 0 0 0 0
46116 - 0 0 0 0 0 0 0 0 0 0 0 0
46117 - 0 0 0 0 0 0 0 0 0 6 6 6
46118 - 18 18 18 34 34 34 58 58 58 78 78 78
46119 -101 98 89 124 112 88 142 110 46 156 107 11
46120 -163 110 8 167 114 7 175 118 6 180 123 7
46121 -185 133 11 197 138 11 210 150 10 219 162 10
46122 -226 170 11 236 178 12 236 178 12 234 174 13
46123 -219 162 10 197 138 11 163 110 8 130 83 6
46124 - 91 60 6 10 10 10 2 2 6 2 2 6
46125 - 18 18 18 38 38 38 38 38 38 38 38 38
46126 - 38 38 38 38 38 38 38 38 38 38 38 38
46127 - 38 38 38 38 38 38 26 26 26 2 2 6
46128 - 2 2 6 6 6 6 70 47 6 137 92 6
46129 -175 118 6 200 144 11 219 162 10 230 174 11
46130 -234 174 13 230 174 11 219 162 10 210 150 10
46131 -192 133 9 163 110 8 124 112 88 82 82 82
46132 - 50 50 50 30 30 30 14 14 14 6 6 6
46133 - 0 0 0 0 0 0 0 0 0 0 0 0
46134 - 0 0 0 0 0 0 0 0 0 0 0 0
46135 - 0 0 0 0 0 0 0 0 0 0 0 0
46136 - 0 0 0 0 0 0 0 0 0 0 0 0
46137 - 0 0 0 0 0 0 0 0 0 0 0 0
46138 - 6 6 6 14 14 14 22 22 22 34 34 34
46139 - 42 42 42 58 58 58 74 74 74 86 86 86
46140 -101 98 89 122 102 70 130 98 46 121 87 25
46141 -137 92 6 152 99 6 163 110 8 180 123 7
46142 -185 133 11 197 138 11 206 145 10 200 144 11
46143 -180 123 7 156 107 11 130 83 6 104 69 6
46144 - 50 34 6 54 54 54 110 110 110 101 98 89
46145 - 86 86 86 82 82 82 78 78 78 78 78 78
46146 - 78 78 78 78 78 78 78 78 78 78 78 78
46147 - 78 78 78 82 82 82 86 86 86 94 94 94
46148 -106 106 106 101 101 101 86 66 34 124 80 6
46149 -156 107 11 180 123 7 192 133 9 200 144 11
46150 -206 145 10 200 144 11 192 133 9 175 118 6
46151 -139 102 15 109 106 95 70 70 70 42 42 42
46152 - 22 22 22 10 10 10 0 0 0 0 0 0
46153 - 0 0 0 0 0 0 0 0 0 0 0 0
46154 - 0 0 0 0 0 0 0 0 0 0 0 0
46155 - 0 0 0 0 0 0 0 0 0 0 0 0
46156 - 0 0 0 0 0 0 0 0 0 0 0 0
46157 - 0 0 0 0 0 0 0 0 0 0 0 0
46158 - 0 0 0 0 0 0 6 6 6 10 10 10
46159 - 14 14 14 22 22 22 30 30 30 38 38 38
46160 - 50 50 50 62 62 62 74 74 74 90 90 90
46161 -101 98 89 112 100 78 121 87 25 124 80 6
46162 -137 92 6 152 99 6 152 99 6 152 99 6
46163 -138 86 6 124 80 6 98 70 6 86 66 30
46164 -101 98 89 82 82 82 58 58 58 46 46 46
46165 - 38 38 38 34 34 34 34 34 34 34 34 34
46166 - 34 34 34 34 34 34 34 34 34 34 34 34
46167 - 34 34 34 34 34 34 38 38 38 42 42 42
46168 - 54 54 54 82 82 82 94 86 76 91 60 6
46169 -134 86 6 156 107 11 167 114 7 175 118 6
46170 -175 118 6 167 114 7 152 99 6 121 87 25
46171 -101 98 89 62 62 62 34 34 34 18 18 18
46172 - 6 6 6 0 0 0 0 0 0 0 0 0
46173 - 0 0 0 0 0 0 0 0 0 0 0 0
46174 - 0 0 0 0 0 0 0 0 0 0 0 0
46175 - 0 0 0 0 0 0 0 0 0 0 0 0
46176 - 0 0 0 0 0 0 0 0 0 0 0 0
46177 - 0 0 0 0 0 0 0 0 0 0 0 0
46178 - 0 0 0 0 0 0 0 0 0 0 0 0
46179 - 0 0 0 6 6 6 6 6 6 10 10 10
46180 - 18 18 18 22 22 22 30 30 30 42 42 42
46181 - 50 50 50 66 66 66 86 86 86 101 98 89
46182 -106 86 58 98 70 6 104 69 6 104 69 6
46183 -104 69 6 91 60 6 82 62 34 90 90 90
46184 - 62 62 62 38 38 38 22 22 22 14 14 14
46185 - 10 10 10 10 10 10 10 10 10 10 10 10
46186 - 10 10 10 10 10 10 6 6 6 10 10 10
46187 - 10 10 10 10 10 10 10 10 10 14 14 14
46188 - 22 22 22 42 42 42 70 70 70 89 81 66
46189 - 80 54 7 104 69 6 124 80 6 137 92 6
46190 -134 86 6 116 81 8 100 82 52 86 86 86
46191 - 58 58 58 30 30 30 14 14 14 6 6 6
46192 - 0 0 0 0 0 0 0 0 0 0 0 0
46193 - 0 0 0 0 0 0 0 0 0 0 0 0
46194 - 0 0 0 0 0 0 0 0 0 0 0 0
46195 - 0 0 0 0 0 0 0 0 0 0 0 0
46196 - 0 0 0 0 0 0 0 0 0 0 0 0
46197 - 0 0 0 0 0 0 0 0 0 0 0 0
46198 - 0 0 0 0 0 0 0 0 0 0 0 0
46199 - 0 0 0 0 0 0 0 0 0 0 0 0
46200 - 0 0 0 6 6 6 10 10 10 14 14 14
46201 - 18 18 18 26 26 26 38 38 38 54 54 54
46202 - 70 70 70 86 86 86 94 86 76 89 81 66
46203 - 89 81 66 86 86 86 74 74 74 50 50 50
46204 - 30 30 30 14 14 14 6 6 6 0 0 0
46205 - 0 0 0 0 0 0 0 0 0 0 0 0
46206 - 0 0 0 0 0 0 0 0 0 0 0 0
46207 - 0 0 0 0 0 0 0 0 0 0 0 0
46208 - 6 6 6 18 18 18 34 34 34 58 58 58
46209 - 82 82 82 89 81 66 89 81 66 89 81 66
46210 - 94 86 66 94 86 76 74 74 74 50 50 50
46211 - 26 26 26 14 14 14 6 6 6 0 0 0
46212 - 0 0 0 0 0 0 0 0 0 0 0 0
46213 - 0 0 0 0 0 0 0 0 0 0 0 0
46214 - 0 0 0 0 0 0 0 0 0 0 0 0
46215 - 0 0 0 0 0 0 0 0 0 0 0 0
46216 - 0 0 0 0 0 0 0 0 0 0 0 0
46217 - 0 0 0 0 0 0 0 0 0 0 0 0
46218 - 0 0 0 0 0 0 0 0 0 0 0 0
46219 - 0 0 0 0 0 0 0 0 0 0 0 0
46220 - 0 0 0 0 0 0 0 0 0 0 0 0
46221 - 6 6 6 6 6 6 14 14 14 18 18 18
46222 - 30 30 30 38 38 38 46 46 46 54 54 54
46223 - 50 50 50 42 42 42 30 30 30 18 18 18
46224 - 10 10 10 0 0 0 0 0 0 0 0 0
46225 - 0 0 0 0 0 0 0 0 0 0 0 0
46226 - 0 0 0 0 0 0 0 0 0 0 0 0
46227 - 0 0 0 0 0 0 0 0 0 0 0 0
46228 - 0 0 0 6 6 6 14 14 14 26 26 26
46229 - 38 38 38 50 50 50 58 58 58 58 58 58
46230 - 54 54 54 42 42 42 30 30 30 18 18 18
46231 - 10 10 10 0 0 0 0 0 0 0 0 0
46232 - 0 0 0 0 0 0 0 0 0 0 0 0
46233 - 0 0 0 0 0 0 0 0 0 0 0 0
46234 - 0 0 0 0 0 0 0 0 0 0 0 0
46235 - 0 0 0 0 0 0 0 0 0 0 0 0
46236 - 0 0 0 0 0 0 0 0 0 0 0 0
46237 - 0 0 0 0 0 0 0 0 0 0 0 0
46238 - 0 0 0 0 0 0 0 0 0 0 0 0
46239 - 0 0 0 0 0 0 0 0 0 0 0 0
46240 - 0 0 0 0 0 0 0 0 0 0 0 0
46241 - 0 0 0 0 0 0 0 0 0 6 6 6
46242 - 6 6 6 10 10 10 14 14 14 18 18 18
46243 - 18 18 18 14 14 14 10 10 10 6 6 6
46244 - 0 0 0 0 0 0 0 0 0 0 0 0
46245 - 0 0 0 0 0 0 0 0 0 0 0 0
46246 - 0 0 0 0 0 0 0 0 0 0 0 0
46247 - 0 0 0 0 0 0 0 0 0 0 0 0
46248 - 0 0 0 0 0 0 0 0 0 6 6 6
46249 - 14 14 14 18 18 18 22 22 22 22 22 22
46250 - 18 18 18 14 14 14 10 10 10 6 6 6
46251 - 0 0 0 0 0 0 0 0 0 0 0 0
46252 - 0 0 0 0 0 0 0 0 0 0 0 0
46253 - 0 0 0 0 0 0 0 0 0 0 0 0
46254 - 0 0 0 0 0 0 0 0 0 0 0 0
46255 - 0 0 0 0 0 0 0 0 0 0 0 0
46256 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46257 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46258 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46259 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46260 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46261 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46262 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46263 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46264 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46265 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46266 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46267 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46268 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46269 +4 4 4 4 4 4
46270 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46271 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46272 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46273 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46274 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46275 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46276 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46277 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46278 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46279 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46280 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46281 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46282 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46283 +4 4 4 4 4 4
46284 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46285 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46286 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46287 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46288 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46289 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46290 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46291 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46292 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46293 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46294 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46295 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46296 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46297 +4 4 4 4 4 4
46298 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46299 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46300 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46301 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46302 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46303 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46304 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46305 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46306 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46307 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46308 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46309 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46310 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46311 +4 4 4 4 4 4
46312 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46313 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46314 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46315 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46316 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46317 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46318 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46319 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46320 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46321 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46322 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46323 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46324 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46325 +4 4 4 4 4 4
46326 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46327 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46328 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46329 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46330 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46331 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46332 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46333 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46334 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46335 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46336 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46337 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46338 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46339 +4 4 4 4 4 4
46340 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46341 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46342 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46343 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46344 +4 4 4 4 4 4 4 4 4 3 3 3 0 0 0 0 0 0
46345 +0 0 0 0 0 0 0 0 0 0 0 0 3 3 3 4 4 4
46346 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46347 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46348 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46349 +4 4 4 4 4 4 4 4 4 4 4 4 1 1 1 0 0 0
46350 +0 0 0 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4
46351 +4 4 4 4 4 4 4 4 4 2 1 0 2 1 0 3 2 2
46352 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46353 +4 4 4 4 4 4
46354 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46355 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46356 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46357 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46358 +4 4 4 4 4 4 2 2 2 0 0 0 3 4 3 26 28 28
46359 +37 38 37 37 38 37 14 17 19 2 2 2 0 0 0 2 2 2
46360 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46361 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46362 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46363 +4 4 4 4 4 4 3 3 3 0 0 0 1 1 1 6 6 6
46364 +2 2 2 0 0 0 3 3 3 4 4 4 4 4 4 4 4 4
46365 +4 4 5 3 3 3 1 0 0 0 0 0 1 0 0 0 0 0
46366 +1 1 1 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46367 +4 4 4 4 4 4
46368 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46369 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46370 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46371 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46372 +2 2 2 0 0 0 0 0 0 14 17 19 60 74 84 137 136 137
46373 +153 152 153 137 136 137 125 124 125 60 73 81 6 6 6 3 1 0
46374 +0 0 0 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4
46375 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46376 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46377 +4 4 4 4 4 4 0 0 0 4 4 4 41 54 63 125 124 125
46378 +60 73 81 6 6 6 4 0 0 3 3 3 4 4 4 4 4 4
46379 +4 4 4 0 0 0 6 9 11 41 54 63 41 65 82 22 30 35
46380 +2 2 2 2 1 0 4 4 4 4 4 4 4 4 4 4 4 4
46381 +4 4 4 4 4 4
46382 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46383 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46384 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46385 +4 4 4 4 4 4 5 5 5 5 5 5 2 2 2 0 0 0
46386 +4 0 0 6 6 6 41 54 63 137 136 137 174 174 174 167 166 167
46387 +165 164 165 165 164 165 163 162 163 163 162 163 125 124 125 41 54 63
46388 +1 1 1 0 0 0 0 0 0 3 3 3 5 5 5 4 4 4
46389 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46390 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
46391 +3 3 3 2 0 0 4 0 0 60 73 81 156 155 156 167 166 167
46392 +163 162 163 85 115 134 5 7 8 0 0 0 4 4 4 5 5 5
46393 +0 0 0 2 5 5 55 98 126 90 154 193 90 154 193 72 125 159
46394 +37 51 59 2 0 0 1 1 1 4 5 5 4 4 4 4 4 4
46395 +4 4 4 4 4 4
46396 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46397 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46398 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46399 +4 4 4 5 5 5 4 4 4 1 1 1 0 0 0 3 3 3
46400 +37 38 37 125 124 125 163 162 163 174 174 174 158 157 158 158 157 158
46401 +156 155 156 156 155 156 158 157 158 165 164 165 174 174 174 166 165 166
46402 +125 124 125 16 19 21 1 0 0 0 0 0 0 0 0 4 4 4
46403 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
46404 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 1 1 1
46405 +0 0 0 0 0 0 37 38 37 153 152 153 174 174 174 158 157 158
46406 +174 174 174 163 162 163 37 38 37 4 3 3 4 0 0 1 1 1
46407 +0 0 0 22 40 52 101 161 196 101 161 196 90 154 193 101 161 196
46408 +64 123 161 14 17 19 0 0 0 4 4 4 4 4 4 4 4 4
46409 +4 4 4 4 4 4
46410 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46411 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46412 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
46413 +5 5 5 2 2 2 0 0 0 4 0 0 24 26 27 85 115 134
46414 +156 155 156 174 174 174 167 166 167 156 155 156 154 153 154 157 156 157
46415 +156 155 156 156 155 156 155 154 155 153 152 153 158 157 158 167 166 167
46416 +174 174 174 156 155 156 60 74 84 16 19 21 0 0 0 0 0 0
46417 +1 1 1 5 5 5 5 5 5 4 4 4 4 4 4 4 4 4
46418 +4 4 4 5 5 5 6 6 6 3 3 3 0 0 0 4 0 0
46419 +13 16 17 60 73 81 137 136 137 165 164 165 156 155 156 153 152 153
46420 +174 174 174 177 184 187 60 73 81 3 1 0 0 0 0 1 1 2
46421 +22 30 35 64 123 161 136 185 209 90 154 193 90 154 193 90 154 193
46422 +90 154 193 21 29 34 0 0 0 3 2 2 4 4 5 4 4 4
46423 +4 4 4 4 4 4
46424 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46425 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46426 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 3 3 3
46427 +0 0 0 0 0 0 10 13 16 60 74 84 157 156 157 174 174 174
46428 +174 174 174 158 157 158 153 152 153 154 153 154 156 155 156 155 154 155
46429 +156 155 156 155 154 155 154 153 154 157 156 157 154 153 154 153 152 153
46430 +163 162 163 174 174 174 177 184 187 137 136 137 60 73 81 13 16 17
46431 +4 0 0 0 0 0 3 3 3 5 5 5 4 4 4 4 4 4
46432 +5 5 5 4 4 4 1 1 1 0 0 0 3 3 3 41 54 63
46433 +131 129 131 174 174 174 174 174 174 174 174 174 167 166 167 174 174 174
46434 +190 197 201 137 136 137 24 26 27 4 0 0 16 21 25 50 82 103
46435 +90 154 193 136 185 209 90 154 193 101 161 196 101 161 196 101 161 196
46436 +31 91 132 3 6 7 0 0 0 4 4 4 4 4 4 4 4 4
46437 +4 4 4 4 4 4
46438 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46439 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46440 +4 4 4 4 4 4 4 4 4 2 2 2 0 0 0 4 0 0
46441 +4 0 0 43 57 68 137 136 137 177 184 187 174 174 174 163 162 163
46442 +155 154 155 155 154 155 156 155 156 155 154 155 158 157 158 165 164 165
46443 +167 166 167 166 165 166 163 162 163 157 156 157 155 154 155 155 154 155
46444 +153 152 153 156 155 156 167 166 167 174 174 174 174 174 174 131 129 131
46445 +41 54 63 5 5 5 0 0 0 0 0 0 3 3 3 4 4 4
46446 +1 1 1 0 0 0 1 0 0 26 28 28 125 124 125 174 174 174
46447 +177 184 187 174 174 174 174 174 174 156 155 156 131 129 131 137 136 137
46448 +125 124 125 24 26 27 4 0 0 41 65 82 90 154 193 136 185 209
46449 +136 185 209 101 161 196 53 118 160 37 112 160 90 154 193 34 86 122
46450 +7 12 15 0 0 0 4 4 4 4 4 4 4 4 4 4 4 4
46451 +4 4 4 4 4 4
46452 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46453 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46454 +4 4 4 3 3 3 0 0 0 0 0 0 5 5 5 37 38 37
46455 +125 124 125 167 166 167 174 174 174 167 166 167 158 157 158 155 154 155
46456 +156 155 156 156 155 156 156 155 156 163 162 163 167 166 167 155 154 155
46457 +137 136 137 153 152 153 156 155 156 165 164 165 163 162 163 156 155 156
46458 +156 155 156 156 155 156 155 154 155 158 157 158 166 165 166 174 174 174
46459 +167 166 167 125 124 125 37 38 37 1 0 0 0 0 0 0 0 0
46460 +0 0 0 24 26 27 60 74 84 158 157 158 174 174 174 174 174 174
46461 +166 165 166 158 157 158 125 124 125 41 54 63 13 16 17 6 6 6
46462 +6 6 6 37 38 37 80 127 157 136 185 209 101 161 196 101 161 196
46463 +90 154 193 28 67 93 6 10 14 13 20 25 13 20 25 6 10 14
46464 +1 1 2 4 3 3 4 4 4 4 4 4 4 4 4 4 4 4
46465 +4 4 4 4 4 4
46466 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46467 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46468 +1 1 1 1 0 0 4 3 3 37 38 37 60 74 84 153 152 153
46469 +167 166 167 167 166 167 158 157 158 154 153 154 155 154 155 156 155 156
46470 +157 156 157 158 157 158 167 166 167 167 166 167 131 129 131 43 57 68
46471 +26 28 28 37 38 37 60 73 81 131 129 131 165 164 165 166 165 166
46472 +158 157 158 155 154 155 156 155 156 156 155 156 156 155 156 158 157 158
46473 +165 164 165 174 174 174 163 162 163 60 74 84 16 19 21 13 16 17
46474 +60 73 81 131 129 131 174 174 174 174 174 174 167 166 167 165 164 165
46475 +137 136 137 60 73 81 24 26 27 4 0 0 4 0 0 16 19 21
46476 +52 104 138 101 161 196 136 185 209 136 185 209 90 154 193 27 99 146
46477 +13 20 25 4 5 7 2 5 5 4 5 7 1 1 2 0 0 0
46478 +4 4 4 4 4 4 3 3 3 2 2 2 2 2 2 4 4 4
46479 +4 4 4 4 4 4
46480 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46481 +4 4 4 4 4 4 4 4 4 4 4 4 3 3 3 0 0 0
46482 +0 0 0 13 16 17 60 73 81 137 136 137 174 174 174 166 165 166
46483 +158 157 158 156 155 156 157 156 157 156 155 156 155 154 155 158 157 158
46484 +167 166 167 174 174 174 153 152 153 60 73 81 16 19 21 4 0 0
46485 +4 0 0 4 0 0 6 6 6 26 28 28 60 74 84 158 157 158
46486 +174 174 174 166 165 166 157 156 157 155 154 155 156 155 156 156 155 156
46487 +155 154 155 158 157 158 167 166 167 167 166 167 131 129 131 125 124 125
46488 +137 136 137 167 166 167 167 166 167 174 174 174 158 157 158 125 124 125
46489 +16 19 21 4 0 0 4 0 0 10 13 16 49 76 92 107 159 188
46490 +136 185 209 136 185 209 90 154 193 26 108 161 22 40 52 6 10 14
46491 +2 3 3 1 1 2 1 1 2 4 4 5 4 4 5 4 4 5
46492 +4 4 5 2 2 1 0 0 0 0 0 0 0 0 0 2 2 2
46493 +4 4 4 4 4 4
46494 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46495 +4 4 4 5 5 5 3 3 3 0 0 0 1 0 0 4 0 0
46496 +37 51 59 131 129 131 167 166 167 167 166 167 163 162 163 157 156 157
46497 +157 156 157 155 154 155 153 152 153 157 156 157 167 166 167 174 174 174
46498 +153 152 153 125 124 125 37 38 37 4 0 0 4 0 0 4 0 0
46499 +4 3 3 4 3 3 4 0 0 6 6 6 4 0 0 37 38 37
46500 +125 124 125 174 174 174 174 174 174 165 164 165 156 155 156 154 153 154
46501 +156 155 156 156 155 156 155 154 155 163 162 163 158 157 158 163 162 163
46502 +174 174 174 174 174 174 174 174 174 125 124 125 37 38 37 0 0 0
46503 +4 0 0 6 9 11 41 54 63 90 154 193 136 185 209 146 190 211
46504 +136 185 209 37 112 160 22 40 52 6 10 14 3 6 7 1 1 2
46505 +1 1 2 3 3 3 1 1 2 3 3 3 4 4 4 4 4 4
46506 +2 2 2 2 0 0 16 19 21 37 38 37 24 26 27 0 0 0
46507 +0 0 0 4 4 4
46508 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
46509 +4 4 4 0 0 0 0 0 0 0 0 0 26 28 28 120 125 127
46510 +158 157 158 174 174 174 165 164 165 157 156 157 155 154 155 156 155 156
46511 +153 152 153 153 152 153 167 166 167 174 174 174 174 174 174 125 124 125
46512 +37 38 37 4 0 0 0 0 0 4 0 0 4 3 3 4 4 4
46513 +4 4 4 4 4 4 5 5 5 4 0 0 4 0 0 4 0 0
46514 +4 3 3 43 57 68 137 136 137 174 174 174 174 174 174 165 164 165
46515 +154 153 154 153 152 153 153 152 153 153 152 153 163 162 163 174 174 174
46516 +174 174 174 153 152 153 60 73 81 6 6 6 4 0 0 4 3 3
46517 +32 43 50 80 127 157 136 185 209 146 190 211 146 190 211 90 154 193
46518 +28 67 93 28 67 93 40 71 93 3 6 7 1 1 2 2 5 5
46519 +50 82 103 79 117 143 26 37 45 0 0 0 3 3 3 1 1 1
46520 +0 0 0 41 54 63 137 136 137 174 174 174 153 152 153 60 73 81
46521 +2 0 0 0 0 0
46522 +4 4 4 4 4 4 4 4 4 4 4 4 6 6 6 2 2 2
46523 +0 0 0 2 0 0 24 26 27 60 74 84 153 152 153 174 174 174
46524 +174 174 174 157 156 157 154 153 154 156 155 156 154 153 154 153 152 153
46525 +165 164 165 174 174 174 177 184 187 137 136 137 43 57 68 6 6 6
46526 +4 0 0 2 0 0 3 3 3 5 5 5 5 5 5 4 4 4
46527 +4 4 4 4 4 4 4 4 4 5 5 5 6 6 6 4 3 3
46528 +4 0 0 4 0 0 24 26 27 60 73 81 153 152 153 174 174 174
46529 +174 174 174 158 157 158 158 157 158 174 174 174 174 174 174 158 157 158
46530 +60 74 84 24 26 27 4 0 0 4 0 0 17 23 27 59 113 148
46531 +136 185 209 191 222 234 146 190 211 136 185 209 31 91 132 7 11 13
46532 +22 40 52 101 161 196 90 154 193 6 9 11 3 4 4 43 95 132
46533 +136 185 209 172 205 220 55 98 126 0 0 0 0 0 0 2 0 0
46534 +26 28 28 153 152 153 177 184 187 167 166 167 177 184 187 165 164 165
46535 +37 38 37 0 0 0
46536 +4 4 4 4 4 4 5 5 5 5 5 5 1 1 1 0 0 0
46537 +13 16 17 60 73 81 137 136 137 174 174 174 174 174 174 165 164 165
46538 +153 152 153 153 152 153 155 154 155 154 153 154 158 157 158 174 174 174
46539 +177 184 187 163 162 163 60 73 81 16 19 21 4 0 0 4 0 0
46540 +4 3 3 4 4 4 5 5 5 5 5 5 4 4 4 5 5 5
46541 +5 5 5 5 5 5 5 5 5 4 4 4 4 4 4 5 5 5
46542 +6 6 6 4 0 0 4 0 0 4 0 0 24 26 27 60 74 84
46543 +166 165 166 174 174 174 177 184 187 165 164 165 125 124 125 24 26 27
46544 +4 0 0 4 0 0 5 5 5 50 82 103 136 185 209 172 205 220
46545 +146 190 211 136 185 209 26 108 161 22 40 52 7 12 15 44 81 103
46546 +71 116 144 28 67 93 37 51 59 41 65 82 100 139 164 101 161 196
46547 +90 154 193 90 154 193 28 67 93 0 0 0 0 0 0 26 28 28
46548 +125 124 125 167 166 167 163 162 163 153 152 153 163 162 163 174 174 174
46549 +85 115 134 4 0 0
46550 +4 4 4 5 5 5 4 4 4 1 0 0 4 0 0 34 47 55
46551 +125 124 125 174 174 174 174 174 174 167 166 167 157 156 157 153 152 153
46552 +155 154 155 155 154 155 158 157 158 166 165 166 167 166 167 154 153 154
46553 +125 124 125 26 28 28 4 0 0 4 0 0 4 0 0 5 5 5
46554 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 1 1 1
46555 +0 0 0 0 0 0 1 1 1 4 4 4 4 4 4 4 4 4
46556 +5 5 5 5 5 5 4 3 3 4 0 0 4 0 0 6 6 6
46557 +37 38 37 131 129 131 137 136 137 37 38 37 0 0 0 4 0 0
46558 +4 5 5 43 61 72 90 154 193 172 205 220 146 190 211 136 185 209
46559 +90 154 193 28 67 93 13 20 25 43 61 72 71 116 144 44 81 103
46560 +2 5 5 7 11 13 59 113 148 101 161 196 90 154 193 28 67 93
46561 +13 20 25 6 10 14 0 0 0 13 16 17 60 73 81 137 136 137
46562 +166 165 166 158 157 158 156 155 156 154 153 154 167 166 167 174 174 174
46563 +60 73 81 4 0 0
46564 +4 4 4 4 4 4 0 0 0 3 3 3 60 74 84 174 174 174
46565 +174 174 174 167 166 167 163 162 163 155 154 155 157 156 157 155 154 155
46566 +156 155 156 163 162 163 167 166 167 158 157 158 125 124 125 37 38 37
46567 +4 3 3 4 0 0 4 0 0 6 6 6 6 6 6 5 5 5
46568 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 2 3 3
46569 +10 13 16 7 11 13 1 0 0 0 0 0 2 2 1 4 4 4
46570 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 4 0 0
46571 +4 0 0 7 11 13 13 16 17 4 0 0 3 3 3 34 47 55
46572 +80 127 157 146 190 211 172 205 220 136 185 209 136 185 209 136 185 209
46573 +28 67 93 22 40 52 55 98 126 55 98 126 21 29 34 7 11 13
46574 +50 82 103 101 161 196 101 161 196 35 83 115 13 20 25 2 2 1
46575 +1 1 2 1 1 2 37 51 59 131 129 131 174 174 174 174 174 174
46576 +167 166 167 163 162 163 163 162 163 167 166 167 174 174 174 125 124 125
46577 +16 19 21 4 0 0
46578 +4 4 4 4 0 0 4 0 0 60 74 84 174 174 174 174 174 174
46579 +158 157 158 155 154 155 155 154 155 156 155 156 155 154 155 158 157 158
46580 +167 166 167 165 164 165 131 129 131 60 73 81 13 16 17 4 0 0
46581 +4 0 0 4 3 3 6 6 6 4 3 3 5 5 5 4 4 4
46582 +4 4 4 3 2 2 0 0 0 0 0 0 7 11 13 45 69 86
46583 +80 127 157 71 116 144 43 61 72 7 11 13 0 0 0 1 1 1
46584 +4 3 3 4 4 4 4 4 4 4 4 4 6 6 6 5 5 5
46585 +3 2 2 4 0 0 1 0 0 21 29 34 59 113 148 136 185 209
46586 +146 190 211 136 185 209 136 185 209 136 185 209 136 185 209 136 185 209
46587 +68 124 159 44 81 103 22 40 52 13 16 17 43 61 72 90 154 193
46588 +136 185 209 59 113 148 21 29 34 3 4 3 1 1 1 0 0 0
46589 +24 26 27 125 124 125 163 162 163 174 174 174 166 165 166 165 164 165
46590 +163 162 163 125 124 125 125 124 125 125 124 125 125 124 125 26 28 28
46591 +4 0 0 4 3 3
46592 +3 3 3 0 0 0 24 26 27 153 152 153 177 184 187 158 157 158
46593 +156 155 156 156 155 156 155 154 155 155 154 155 165 164 165 174 174 174
46594 +155 154 155 60 74 84 26 28 28 4 0 0 4 0 0 3 1 0
46595 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 3 3
46596 +2 0 0 0 0 0 0 0 0 32 43 50 72 125 159 101 161 196
46597 +136 185 209 101 161 196 101 161 196 79 117 143 32 43 50 0 0 0
46598 +0 0 0 2 2 2 4 4 4 4 4 4 3 3 3 1 0 0
46599 +0 0 0 4 5 5 49 76 92 101 161 196 146 190 211 146 190 211
46600 +136 185 209 136 185 209 136 185 209 136 185 209 136 185 209 90 154 193
46601 +28 67 93 13 16 17 37 51 59 80 127 157 136 185 209 90 154 193
46602 +22 40 52 6 9 11 3 4 3 2 2 1 16 19 21 60 73 81
46603 +137 136 137 163 162 163 158 157 158 166 165 166 167 166 167 153 152 153
46604 +60 74 84 37 38 37 6 6 6 13 16 17 4 0 0 1 0 0
46605 +3 2 2 4 4 4
46606 +3 2 2 4 0 0 37 38 37 137 136 137 167 166 167 158 157 158
46607 +157 156 157 154 153 154 157 156 157 167 166 167 174 174 174 125 124 125
46608 +37 38 37 4 0 0 4 0 0 4 0 0 4 3 3 4 4 4
46609 +4 4 4 4 4 4 5 5 5 5 5 5 1 1 1 0 0 0
46610 +0 0 0 16 21 25 55 98 126 90 154 193 136 185 209 101 161 196
46611 +101 161 196 101 161 196 136 185 209 136 185 209 101 161 196 55 98 126
46612 +14 17 19 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
46613 +22 40 52 90 154 193 146 190 211 146 190 211 136 185 209 136 185 209
46614 +136 185 209 136 185 209 136 185 209 101 161 196 35 83 115 7 11 13
46615 +17 23 27 59 113 148 136 185 209 101 161 196 34 86 122 7 12 15
46616 +2 5 5 3 4 3 6 6 6 60 73 81 131 129 131 163 162 163
46617 +166 165 166 174 174 174 174 174 174 163 162 163 125 124 125 41 54 63
46618 +13 16 17 4 0 0 4 0 0 4 0 0 1 0 0 2 2 2
46619 +4 4 4 4 4 4
46620 +1 1 1 2 1 0 43 57 68 137 136 137 153 152 153 153 152 153
46621 +163 162 163 156 155 156 165 164 165 167 166 167 60 74 84 6 6 6
46622 +4 0 0 4 0 0 5 5 5 4 4 4 4 4 4 4 4 4
46623 +4 5 5 6 6 6 4 3 3 0 0 0 0 0 0 11 15 18
46624 +40 71 93 100 139 164 101 161 196 101 161 196 101 161 196 101 161 196
46625 +101 161 196 101 161 196 101 161 196 101 161 196 136 185 209 136 185 209
46626 +101 161 196 45 69 86 6 6 6 0 0 0 17 23 27 55 98 126
46627 +136 185 209 146 190 211 136 185 209 136 185 209 136 185 209 136 185 209
46628 +136 185 209 136 185 209 90 154 193 22 40 52 7 11 13 50 82 103
46629 +136 185 209 136 185 209 53 118 160 22 40 52 7 11 13 2 5 5
46630 +3 4 3 37 38 37 125 124 125 157 156 157 166 165 166 167 166 167
46631 +174 174 174 174 174 174 137 136 137 60 73 81 4 0 0 4 0 0
46632 +4 0 0 4 0 0 5 5 5 3 3 3 3 3 3 4 4 4
46633 +4 4 4 4 4 4
46634 +4 0 0 4 0 0 41 54 63 137 136 137 125 124 125 131 129 131
46635 +155 154 155 167 166 167 174 174 174 60 74 84 6 6 6 4 0 0
46636 +4 3 3 6 6 6 4 4 4 4 4 4 4 4 4 5 5 5
46637 +4 4 4 1 1 1 0 0 0 3 6 7 41 65 82 72 125 159
46638 +101 161 196 101 161 196 101 161 196 90 154 193 90 154 193 101 161 196
46639 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 136 185 209
46640 +136 185 209 136 185 209 80 127 157 55 98 126 101 161 196 146 190 211
46641 +136 185 209 136 185 209 136 185 209 101 161 196 136 185 209 101 161 196
46642 +136 185 209 101 161 196 35 83 115 22 30 35 101 161 196 172 205 220
46643 +90 154 193 28 67 93 7 11 13 2 5 5 3 4 3 13 16 17
46644 +85 115 134 167 166 167 174 174 174 174 174 174 174 174 174 174 174 174
46645 +167 166 167 60 74 84 13 16 17 4 0 0 4 0 0 4 3 3
46646 +6 6 6 5 5 5 4 4 4 5 5 5 4 4 4 5 5 5
46647 +5 5 5 5 5 5
46648 +1 1 1 4 0 0 41 54 63 137 136 137 137 136 137 125 124 125
46649 +131 129 131 167 166 167 157 156 157 37 38 37 6 6 6 4 0 0
46650 +6 6 6 5 5 5 4 4 4 4 4 4 4 5 5 2 2 1
46651 +0 0 0 0 0 0 26 37 45 58 111 146 101 161 196 101 161 196
46652 +101 161 196 90 154 193 90 154 193 90 154 193 101 161 196 101 161 196
46653 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
46654 +101 161 196 136 185 209 136 185 209 136 185 209 146 190 211 136 185 209
46655 +136 185 209 101 161 196 136 185 209 136 185 209 101 161 196 136 185 209
46656 +101 161 196 136 185 209 136 185 209 136 185 209 136 185 209 16 89 141
46657 +7 11 13 2 5 5 2 5 5 13 16 17 60 73 81 154 154 154
46658 +174 174 174 174 174 174 174 174 174 174 174 174 163 162 163 125 124 125
46659 +24 26 27 4 0 0 4 0 0 4 0 0 5 5 5 5 5 5
46660 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5
46661 +5 5 5 4 4 4
46662 +4 0 0 6 6 6 37 38 37 137 136 137 137 136 137 131 129 131
46663 +131 129 131 153 152 153 131 129 131 26 28 28 4 0 0 4 3 3
46664 +6 6 6 4 4 4 4 4 4 4 4 4 0 0 0 0 0 0
46665 +13 20 25 51 88 114 90 154 193 101 161 196 101 161 196 90 154 193
46666 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
46667 +101 161 196 101 161 196 101 161 196 101 161 196 136 185 209 101 161 196
46668 +101 161 196 136 185 209 101 161 196 136 185 209 136 185 209 101 161 196
46669 +136 185 209 101 161 196 136 185 209 101 161 196 101 161 196 101 161 196
46670 +136 185 209 136 185 209 136 185 209 37 112 160 21 29 34 5 7 8
46671 +2 5 5 13 16 17 43 57 68 131 129 131 174 174 174 174 174 174
46672 +174 174 174 167 166 167 157 156 157 125 124 125 37 38 37 4 0 0
46673 +4 0 0 4 0 0 5 5 5 5 5 5 4 4 4 4 4 4
46674 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46675 +4 4 4 4 4 4
46676 +1 1 1 4 0 0 41 54 63 153 152 153 137 136 137 137 136 137
46677 +137 136 137 153 152 153 125 124 125 24 26 27 4 0 0 3 2 2
46678 +4 4 4 4 4 4 4 3 3 4 0 0 3 6 7 43 61 72
46679 +64 123 161 101 161 196 90 154 193 90 154 193 90 154 193 90 154 193
46680 +90 154 193 90 154 193 90 154 193 90 154 193 101 161 196 90 154 193
46681 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
46682 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
46683 +136 185 209 101 161 196 101 161 196 136 185 209 136 185 209 101 161 196
46684 +101 161 196 90 154 193 28 67 93 13 16 17 7 11 13 3 6 7
46685 +37 51 59 125 124 125 163 162 163 174 174 174 167 166 167 166 165 166
46686 +167 166 167 131 129 131 60 73 81 4 0 0 4 0 0 4 0 0
46687 +3 3 3 5 5 5 6 6 6 4 4 4 4 4 4 4 4 4
46688 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46689 +4 4 4 4 4 4
46690 +4 0 0 4 0 0 41 54 63 137 136 137 153 152 153 137 136 137
46691 +153 152 153 157 156 157 125 124 125 24 26 27 0 0 0 2 2 2
46692 +4 4 4 4 4 4 2 0 0 0 0 0 28 67 93 90 154 193
46693 +90 154 193 90 154 193 90 154 193 90 154 193 64 123 161 90 154 193
46694 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
46695 +90 154 193 101 161 196 101 161 196 101 161 196 90 154 193 136 185 209
46696 +101 161 196 101 161 196 136 185 209 101 161 196 136 185 209 101 161 196
46697 +101 161 196 101 161 196 136 185 209 101 161 196 101 161 196 90 154 193
46698 +35 83 115 13 16 17 3 6 7 2 5 5 13 16 17 60 74 84
46699 +154 154 154 166 165 166 165 164 165 158 157 158 163 162 163 157 156 157
46700 +60 74 84 13 16 17 4 0 0 4 0 0 3 2 2 4 4 4
46701 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46702 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46703 +4 4 4 4 4 4
46704 +1 1 1 4 0 0 41 54 63 157 156 157 155 154 155 137 136 137
46705 +153 152 153 158 157 158 137 136 137 26 28 28 2 0 0 2 2 2
46706 +4 4 4 4 4 4 1 0 0 6 10 14 34 86 122 90 154 193
46707 +64 123 161 90 154 193 64 123 161 90 154 193 90 154 193 90 154 193
46708 +64 123 161 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
46709 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
46710 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
46711 +136 185 209 101 161 196 136 185 209 90 154 193 26 108 161 22 40 52
46712 +13 16 17 5 7 8 2 5 5 2 5 5 37 38 37 165 164 165
46713 +174 174 174 163 162 163 154 154 154 165 164 165 167 166 167 60 73 81
46714 +6 6 6 4 0 0 4 0 0 4 4 4 4 4 4 4 4 4
46715 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46716 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46717 +4 4 4 4 4 4
46718 +4 0 0 6 6 6 41 54 63 156 155 156 158 157 158 153 152 153
46719 +156 155 156 165 164 165 137 136 137 26 28 28 0 0 0 2 2 2
46720 +4 4 5 4 4 4 2 0 0 7 12 15 31 96 139 64 123 161
46721 +90 154 193 64 123 161 90 154 193 90 154 193 64 123 161 90 154 193
46722 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
46723 +90 154 193 90 154 193 90 154 193 101 161 196 101 161 196 101 161 196
46724 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 136 185 209
46725 +101 161 196 136 185 209 26 108 161 22 40 52 7 11 13 5 7 8
46726 +2 5 5 2 5 5 2 5 5 2 2 1 37 38 37 158 157 158
46727 +174 174 174 154 154 154 156 155 156 167 166 167 165 164 165 37 38 37
46728 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46729 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46730 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46731 +4 4 4 4 4 4
46732 +3 1 0 4 0 0 60 73 81 157 156 157 163 162 163 153 152 153
46733 +158 157 158 167 166 167 137 136 137 26 28 28 2 0 0 2 2 2
46734 +4 5 5 4 4 4 4 0 0 7 12 15 24 86 132 26 108 161
46735 +37 112 160 64 123 161 90 154 193 64 123 161 90 154 193 90 154 193
46736 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
46737 +90 154 193 101 161 196 90 154 193 101 161 196 101 161 196 101 161 196
46738 +101 161 196 101 161 196 101 161 196 136 185 209 101 161 196 136 185 209
46739 +90 154 193 35 83 115 13 16 17 13 16 17 7 11 13 3 6 7
46740 +5 7 8 6 6 6 3 4 3 2 2 1 30 32 34 154 154 154
46741 +167 166 167 154 154 154 154 154 154 174 174 174 165 164 165 37 38 37
46742 +6 6 6 4 0 0 6 6 6 4 4 4 4 4 4 4 4 4
46743 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46744 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46745 +4 4 4 4 4 4
46746 +4 0 0 4 0 0 41 54 63 163 162 163 166 165 166 154 154 154
46747 +163 162 163 174 174 174 137 136 137 26 28 28 0 0 0 2 2 2
46748 +4 5 5 4 4 5 1 1 2 6 10 14 28 67 93 18 97 151
46749 +18 97 151 18 97 151 26 108 161 37 112 160 37 112 160 90 154 193
46750 +64 123 161 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
46751 +90 154 193 101 161 196 101 161 196 90 154 193 101 161 196 101 161 196
46752 +101 161 196 101 161 196 101 161 196 136 185 209 90 154 193 16 89 141
46753 +13 20 25 7 11 13 5 7 8 5 7 8 2 5 5 4 5 5
46754 +3 4 3 4 5 5 3 4 3 0 0 0 37 38 37 158 157 158
46755 +174 174 174 158 157 158 158 157 158 167 166 167 174 174 174 41 54 63
46756 +4 0 0 3 2 2 5 5 5 4 4 4 4 4 4 4 4 4
46757 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46758 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46759 +4 4 4 4 4 4
46760 +1 1 1 4 0 0 60 73 81 165 164 165 174 174 174 158 157 158
46761 +167 166 167 174 174 174 153 152 153 26 28 28 2 0 0 2 2 2
46762 +4 5 5 4 4 4 4 0 0 7 12 15 10 87 144 10 87 144
46763 +18 97 151 18 97 151 18 97 151 26 108 161 26 108 161 26 108 161
46764 +26 108 161 37 112 160 53 118 160 90 154 193 90 154 193 90 154 193
46765 +90 154 193 90 154 193 101 161 196 101 161 196 101 161 196 101 161 196
46766 +101 161 196 136 185 209 90 154 193 26 108 161 22 40 52 13 16 17
46767 +7 11 13 3 6 7 5 7 8 5 7 8 2 5 5 4 5 5
46768 +4 5 5 6 6 6 3 4 3 0 0 0 30 32 34 158 157 158
46769 +174 174 174 156 155 156 155 154 155 165 164 165 154 153 154 37 38 37
46770 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46771 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46772 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46773 +4 4 4 4 4 4
46774 +4 0 0 4 0 0 60 73 81 167 166 167 174 174 174 163 162 163
46775 +174 174 174 174 174 174 153 152 153 26 28 28 0 0 0 3 3 3
46776 +5 5 5 4 4 4 1 1 2 7 12 15 28 67 93 18 97 151
46777 +18 97 151 18 97 151 18 97 151 18 97 151 18 97 151 26 108 161
46778 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
46779 +90 154 193 26 108 161 90 154 193 90 154 193 90 154 193 101 161 196
46780 +101 161 196 26 108 161 22 40 52 13 16 17 7 11 13 2 5 5
46781 +2 5 5 6 6 6 2 5 5 4 5 5 4 5 5 4 5 5
46782 +3 4 3 5 5 5 3 4 3 2 0 0 30 32 34 137 136 137
46783 +153 152 153 137 136 137 131 129 131 137 136 137 131 129 131 37 38 37
46784 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46785 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46786 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46787 +4 4 4 4 4 4
46788 +1 1 1 4 0 0 60 73 81 167 166 167 174 174 174 166 165 166
46789 +174 174 174 177 184 187 153 152 153 30 32 34 1 0 0 3 3 3
46790 +5 5 5 4 3 3 4 0 0 7 12 15 10 87 144 10 87 144
46791 +18 97 151 18 97 151 18 97 151 26 108 161 26 108 161 26 108 161
46792 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
46793 +26 108 161 26 108 161 26 108 161 90 154 193 90 154 193 26 108 161
46794 +35 83 115 13 16 17 7 11 13 5 7 8 3 6 7 5 7 8
46795 +2 5 5 6 6 6 4 5 5 4 5 5 3 4 3 4 5 5
46796 +3 4 3 6 6 6 3 4 3 0 0 0 26 28 28 125 124 125
46797 +131 129 131 125 124 125 125 124 125 131 129 131 131 129 131 37 38 37
46798 +4 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46799 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46800 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46801 +4 4 4 4 4 4
46802 +3 1 0 4 0 0 60 73 81 174 174 174 177 184 187 167 166 167
46803 +174 174 174 177 184 187 153 152 153 30 32 34 0 0 0 3 3 3
46804 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 18 97 151
46805 +18 97 151 18 97 151 18 97 151 18 97 151 18 97 151 26 108 161
46806 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
46807 +26 108 161 90 154 193 26 108 161 26 108 161 24 86 132 13 20 25
46808 +7 11 13 13 20 25 22 40 52 5 7 8 3 4 3 3 4 3
46809 +4 5 5 3 4 3 4 5 5 3 4 3 4 5 5 3 4 3
46810 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 125 124 125
46811 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46812 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46813 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46814 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46815 +4 4 4 4 4 4
46816 +1 1 1 4 0 0 60 73 81 174 174 174 177 184 187 174 174 174
46817 +174 174 174 190 197 201 157 156 157 30 32 34 1 0 0 3 3 3
46818 +5 5 5 4 3 3 4 0 0 7 12 15 10 87 144 10 87 144
46819 +18 97 151 19 95 150 19 95 150 18 97 151 18 97 151 26 108 161
46820 +18 97 151 26 108 161 26 108 161 26 108 161 26 108 161 90 154 193
46821 +26 108 161 26 108 161 26 108 161 22 40 52 2 5 5 3 4 3
46822 +28 67 93 37 112 160 34 86 122 2 5 5 3 4 3 3 4 3
46823 +3 4 3 3 4 3 3 4 3 2 2 1 3 4 3 4 4 4
46824 +4 5 5 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
46825 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46826 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46827 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46828 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46829 +4 4 4 4 4 4
46830 +4 0 0 4 0 0 60 73 81 174 174 174 177 184 187 174 174 174
46831 +174 174 174 190 197 201 158 157 158 30 32 34 0 0 0 2 2 2
46832 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 18 97 151
46833 +10 87 144 19 95 150 19 95 150 18 97 151 18 97 151 18 97 151
46834 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
46835 +18 97 151 22 40 52 2 5 5 2 2 1 22 40 52 26 108 161
46836 +90 154 193 37 112 160 22 40 52 3 4 3 13 20 25 22 30 35
46837 +3 6 7 1 1 1 2 2 2 6 9 11 5 5 5 4 3 3
46838 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
46839 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46840 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46841 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46842 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46843 +4 4 4 4 4 4
46844 +1 1 1 4 0 0 60 73 81 177 184 187 193 200 203 174 174 174
46845 +177 184 187 193 200 203 163 162 163 30 32 34 4 0 0 2 2 2
46846 +5 5 5 4 3 3 4 0 0 6 10 14 24 86 132 10 87 144
46847 +10 87 144 10 87 144 19 95 150 19 95 150 19 95 150 18 97 151
46848 +26 108 161 26 108 161 26 108 161 90 154 193 26 108 161 28 67 93
46849 +6 10 14 2 5 5 13 20 25 24 86 132 37 112 160 90 154 193
46850 +10 87 144 7 12 15 2 5 5 28 67 93 37 112 160 28 67 93
46851 +2 2 1 7 12 15 35 83 115 28 67 93 3 6 7 1 0 0
46852 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
46853 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46854 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46855 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46856 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46857 +4 4 4 4 4 4
46858 +4 0 0 4 0 0 60 73 81 174 174 174 190 197 201 174 174 174
46859 +177 184 187 193 200 203 163 162 163 30 32 34 0 0 0 2 2 2
46860 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
46861 +10 87 144 16 89 141 19 95 150 10 87 144 26 108 161 26 108 161
46862 +26 108 161 26 108 161 26 108 161 28 67 93 6 10 14 1 1 2
46863 +7 12 15 28 67 93 26 108 161 16 89 141 24 86 132 21 29 34
46864 +3 4 3 21 29 34 37 112 160 37 112 160 27 99 146 21 29 34
46865 +21 29 34 26 108 161 90 154 193 35 83 115 1 1 2 2 0 0
46866 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 125 124 125
46867 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46868 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46869 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46870 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46871 +4 4 4 4 4 4
46872 +3 1 0 4 0 0 60 73 81 193 200 203 193 200 203 174 174 174
46873 +190 197 201 193 200 203 165 164 165 37 38 37 4 0 0 2 2 2
46874 +5 5 5 4 3 3 4 0 0 6 10 14 24 86 132 10 87 144
46875 +10 87 144 10 87 144 16 89 141 18 97 151 18 97 151 10 87 144
46876 +24 86 132 24 86 132 13 20 25 4 5 7 4 5 7 22 40 52
46877 +18 97 151 37 112 160 26 108 161 7 12 15 1 1 1 0 0 0
46878 +28 67 93 37 112 160 26 108 161 28 67 93 22 40 52 28 67 93
46879 +26 108 161 90 154 193 26 108 161 10 87 144 0 0 0 2 0 0
46880 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
46881 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46882 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46883 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46884 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46885 +4 4 4 4 4 4
46886 +4 0 0 6 6 6 60 73 81 174 174 174 193 200 203 174 174 174
46887 +190 197 201 193 200 203 165 164 165 30 32 34 0 0 0 2 2 2
46888 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
46889 +10 87 144 10 87 144 10 87 144 18 97 151 28 67 93 6 10 14
46890 +0 0 0 1 1 2 4 5 7 13 20 25 16 89 141 26 108 161
46891 +26 108 161 26 108 161 24 86 132 6 9 11 2 3 3 22 40 52
46892 +37 112 160 16 89 141 22 40 52 28 67 93 26 108 161 26 108 161
46893 +90 154 193 26 108 161 26 108 161 28 67 93 1 1 1 4 0 0
46894 +4 4 4 5 5 5 3 3 3 4 0 0 26 28 28 124 126 130
46895 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46896 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46897 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46898 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46899 +4 4 4 4 4 4
46900 +4 0 0 4 0 0 60 73 81 193 200 203 193 200 203 174 174 174
46901 +193 200 203 193 200 203 167 166 167 37 38 37 4 0 0 2 2 2
46902 +5 5 5 4 4 4 4 0 0 6 10 14 28 67 93 10 87 144
46903 +10 87 144 10 87 144 18 97 151 10 87 144 13 20 25 4 5 7
46904 +1 1 2 1 1 1 22 40 52 26 108 161 26 108 161 26 108 161
46905 +26 108 161 26 108 161 26 108 161 24 86 132 22 40 52 22 40 52
46906 +22 40 52 22 40 52 10 87 144 26 108 161 26 108 161 26 108 161
46907 +26 108 161 26 108 161 90 154 193 10 87 144 0 0 0 4 0 0
46908 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
46909 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46910 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46911 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46912 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46913 +4 4 4 4 4 4
46914 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
46915 +190 197 201 205 212 215 167 166 167 30 32 34 0 0 0 2 2 2
46916 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
46917 +10 87 144 10 87 144 10 87 144 10 87 144 22 40 52 1 1 2
46918 +2 0 0 1 1 2 24 86 132 26 108 161 26 108 161 26 108 161
46919 +26 108 161 19 95 150 16 89 141 10 87 144 22 40 52 22 40 52
46920 +10 87 144 26 108 161 37 112 160 26 108 161 26 108 161 26 108 161
46921 +26 108 161 26 108 161 26 108 161 28 67 93 2 0 0 3 1 0
46922 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
46923 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46924 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46925 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46926 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46927 +4 4 4 4 4 4
46928 +4 0 0 4 0 0 60 73 81 220 221 221 190 197 201 174 174 174
46929 +193 200 203 193 200 203 174 174 174 37 38 37 4 0 0 2 2 2
46930 +5 5 5 4 4 4 3 2 2 1 1 2 13 20 25 10 87 144
46931 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 13 20 25
46932 +13 20 25 22 40 52 10 87 144 18 97 151 18 97 151 26 108 161
46933 +10 87 144 13 20 25 6 10 14 21 29 34 24 86 132 18 97 151
46934 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
46935 +26 108 161 90 154 193 18 97 151 13 20 25 0 0 0 4 3 3
46936 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
46937 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46938 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46939 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46940 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46941 +4 4 4 4 4 4
46942 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
46943 +190 197 201 220 221 221 167 166 167 30 32 34 1 0 0 2 2 2
46944 +5 5 5 4 4 4 4 4 5 2 5 5 4 5 7 13 20 25
46945 +28 67 93 10 87 144 10 87 144 10 87 144 10 87 144 10 87 144
46946 +10 87 144 10 87 144 18 97 151 10 87 144 18 97 151 18 97 151
46947 +28 67 93 2 3 3 0 0 0 28 67 93 26 108 161 26 108 161
46948 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
46949 +26 108 161 10 87 144 13 20 25 1 1 2 3 2 2 4 4 4
46950 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
46951 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46952 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46953 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46954 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46955 +4 4 4 4 4 4
46956 +4 0 0 4 0 0 60 73 81 220 221 221 190 197 201 174 174 174
46957 +193 200 203 193 200 203 174 174 174 26 28 28 4 0 0 4 3 3
46958 +5 5 5 4 4 4 4 4 4 4 4 5 1 1 2 2 5 5
46959 +4 5 7 22 40 52 10 87 144 10 87 144 18 97 151 10 87 144
46960 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 18 97 151
46961 +10 87 144 28 67 93 22 40 52 10 87 144 26 108 161 18 97 151
46962 +18 97 151 18 97 151 26 108 161 26 108 161 26 108 161 26 108 161
46963 +22 40 52 1 1 2 0 0 0 2 3 3 4 4 4 4 4 4
46964 +4 4 4 5 5 5 4 4 4 0 0 0 26 28 28 131 129 131
46965 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46966 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46967 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46968 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46969 +4 4 4 4 4 4
46970 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
46971 +190 197 201 220 221 221 190 197 201 41 54 63 4 0 0 2 2 2
46972 +6 6 6 4 4 4 4 4 4 4 4 5 4 4 5 3 3 3
46973 +1 1 2 1 1 2 6 10 14 22 40 52 10 87 144 18 97 151
46974 +18 97 151 10 87 144 10 87 144 10 87 144 18 97 151 10 87 144
46975 +10 87 144 18 97 151 26 108 161 18 97 151 18 97 151 10 87 144
46976 +26 108 161 26 108 161 26 108 161 10 87 144 28 67 93 6 10 14
46977 +1 1 2 1 1 2 4 3 3 4 4 5 4 4 4 4 4 4
46978 +5 5 5 5 5 5 1 1 1 4 0 0 37 51 59 137 136 137
46979 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46980 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46981 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46982 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46983 +4 4 4 4 4 4
46984 +4 0 0 4 0 0 60 73 81 220 221 221 193 200 203 174 174 174
46985 +193 200 203 193 200 203 220 221 221 137 136 137 13 16 17 4 0 0
46986 +2 2 2 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5
46987 +4 4 5 4 3 3 1 1 2 4 5 7 13 20 25 28 67 93
46988 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 10 87 144
46989 +10 87 144 18 97 151 18 97 151 10 87 144 18 97 151 26 108 161
46990 +26 108 161 18 97 151 28 67 93 6 10 14 0 0 0 0 0 0
46991 +2 3 3 4 5 5 4 4 5 4 4 4 4 4 4 5 5 5
46992 +3 3 3 1 1 1 0 0 0 16 19 21 125 124 125 137 136 137
46993 +131 129 131 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46994 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46995 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46996 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46997 +4 4 4 4 4 4
46998 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
46999 +193 200 203 190 197 201 220 221 221 220 221 221 153 152 153 30 32 34
47000 +0 0 0 0 0 0 2 2 2 4 4 4 4 4 4 4 4 4
47001 +4 4 4 4 5 5 4 5 7 1 1 2 1 1 2 4 5 7
47002 +13 20 25 28 67 93 10 87 144 18 97 151 10 87 144 10 87 144
47003 +10 87 144 10 87 144 10 87 144 18 97 151 26 108 161 18 97 151
47004 +28 67 93 7 12 15 0 0 0 0 0 0 2 2 1 4 4 4
47005 +4 5 5 4 5 5 4 4 4 4 4 4 3 3 3 0 0 0
47006 +0 0 0 0 0 0 37 38 37 125 124 125 158 157 158 131 129 131
47007 +125 124 125 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47008 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47009 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47010 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47011 +4 4 4 4 4 4
47012 +4 3 3 4 0 0 41 54 63 193 200 203 220 221 221 174 174 174
47013 +193 200 203 193 200 203 193 200 203 220 221 221 244 246 246 193 200 203
47014 +120 125 127 5 5 5 1 0 0 0 0 0 1 1 1 4 4 4
47015 +4 4 4 4 4 4 4 5 5 4 5 5 4 4 5 1 1 2
47016 +4 5 7 4 5 7 22 40 52 10 87 144 10 87 144 10 87 144
47017 +10 87 144 10 87 144 18 97 151 10 87 144 10 87 144 13 20 25
47018 +4 5 7 2 3 3 1 1 2 4 4 4 4 5 5 4 4 4
47019 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 1 1 2
47020 +24 26 27 60 74 84 153 152 153 163 162 163 137 136 137 125 124 125
47021 +125 124 125 125 124 125 125 124 125 137 136 137 125 124 125 26 28 28
47022 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47023 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47024 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47025 +4 4 4 4 4 4
47026 +4 0 0 6 6 6 26 28 28 156 155 156 220 221 221 220 221 221
47027 +174 174 174 193 200 203 193 200 203 193 200 203 205 212 215 220 221 221
47028 +220 221 221 167 166 167 60 73 81 7 11 13 0 0 0 0 0 0
47029 +3 3 3 4 4 4 4 4 4 4 4 4 4 4 5 4 4 5
47030 +4 4 5 1 1 2 1 1 2 4 5 7 22 40 52 10 87 144
47031 +10 87 144 10 87 144 10 87 144 22 40 52 4 5 7 1 1 2
47032 +1 1 2 4 4 5 4 4 4 4 4 4 4 4 4 4 4 4
47033 +5 5 5 2 2 2 0 0 0 4 0 0 16 19 21 60 73 81
47034 +137 136 137 167 166 167 158 157 158 137 136 137 131 129 131 131 129 131
47035 +125 124 125 125 124 125 131 129 131 155 154 155 60 74 84 5 7 8
47036 +0 0 0 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 4 4 4 4 4 4 4 4 4
47038 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47039 +4 4 4 4 4 4
47040 +5 5 5 4 0 0 4 0 0 60 73 81 193 200 203 220 221 221
47041 +193 200 203 193 200 203 193 200 203 193 200 203 205 212 215 220 221 221
47042 +220 221 221 220 221 221 220 221 221 137 136 137 43 57 68 6 6 6
47043 +4 0 0 1 1 1 4 4 4 4 4 4 4 4 4 4 4 4
47044 +4 4 5 4 4 5 3 2 2 1 1 2 2 5 5 13 20 25
47045 +22 40 52 22 40 52 13 20 25 2 3 3 1 1 2 3 3 3
47046 +4 5 7 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47047 +1 1 1 0 0 0 2 3 3 41 54 63 131 129 131 166 165 166
47048 +166 165 166 155 154 155 153 152 153 137 136 137 137 136 137 125 124 125
47049 +125 124 125 137 136 137 137 136 137 125 124 125 37 38 37 4 3 3
47050 +4 3 3 5 5 5 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 4 4 4 4 4 4
47052 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47053 +4 4 4 4 4 4
47054 +4 3 3 6 6 6 6 6 6 13 16 17 60 73 81 167 166 167
47055 +220 221 221 220 221 221 220 221 221 193 200 203 193 200 203 193 200 203
47056 +205 212 215 220 221 221 220 221 221 244 246 246 205 212 215 125 124 125
47057 +24 26 27 0 0 0 0 0 0 2 2 2 5 5 5 5 5 5
47058 +4 4 4 4 4 4 4 4 4 4 4 5 1 1 2 4 5 7
47059 +4 5 7 4 5 7 1 1 2 3 2 2 4 4 5 4 4 4
47060 +4 4 4 4 4 4 5 5 5 4 4 4 0 0 0 0 0 0
47061 +2 0 0 26 28 28 125 124 125 174 174 174 174 174 174 166 165 166
47062 +156 155 156 153 152 153 137 136 137 137 136 137 131 129 131 137 136 137
47063 +137 136 137 137 136 137 60 74 84 30 32 34 4 0 0 4 0 0
47064 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47065 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47066 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47067 +4 4 4 4 4 4
47068 +5 5 5 6 6 6 4 0 0 4 0 0 6 6 6 26 28 28
47069 +125 124 125 174 174 174 220 221 221 220 221 221 220 221 221 193 200 203
47070 +205 212 215 220 221 221 205 212 215 220 221 221 220 221 221 244 246 246
47071 +193 200 203 60 74 84 13 16 17 4 0 0 0 0 0 3 3 3
47072 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 5 3 3 3
47073 +1 1 2 3 3 3 4 4 5 4 4 5 4 4 4 4 4 4
47074 +5 5 5 5 5 5 2 2 2 0 0 0 0 0 0 13 16 17
47075 +60 74 84 174 174 174 193 200 203 174 174 174 167 166 167 163 162 163
47076 +153 152 153 153 152 153 137 136 137 137 136 137 153 152 153 137 136 137
47077 +125 124 125 41 54 63 24 26 27 4 0 0 4 0 0 5 5 5
47078 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47079 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47080 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47081 +4 4 4 4 4 4
47082 +4 3 3 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
47083 +6 6 6 37 38 37 131 129 131 220 221 221 220 221 221 220 221 221
47084 +193 200 203 193 200 203 220 221 221 205 212 215 220 221 221 244 246 246
47085 +244 246 246 244 246 246 174 174 174 41 54 63 0 0 0 0 0 0
47086 +0 0 0 4 4 4 5 5 5 5 5 5 4 4 4 4 4 5
47087 +4 4 5 4 4 5 4 4 4 4 4 4 6 6 6 6 6 6
47088 +3 3 3 0 0 0 2 0 0 13 16 17 60 73 81 156 155 156
47089 +220 221 221 193 200 203 174 174 174 165 164 165 163 162 163 154 153 154
47090 +153 152 153 153 152 153 158 157 158 163 162 163 137 136 137 60 73 81
47091 +13 16 17 4 0 0 4 0 0 4 3 3 4 4 4 4 4 4
47092 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47093 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47094 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47095 +4 4 4 4 4 4
47096 +5 5 5 4 3 3 4 3 3 6 6 6 6 6 6 6 6 6
47097 +6 6 6 6 6 6 6 6 6 37 38 37 167 166 167 244 246 246
47098 +244 246 246 220 221 221 205 212 215 205 212 215 220 221 221 193 200 203
47099 +220 221 221 244 246 246 244 246 246 244 246 246 137 136 137 37 38 37
47100 +3 2 2 0 0 0 1 1 1 5 5 5 5 5 5 4 4 4
47101 +4 4 4 4 4 4 4 4 4 5 5 5 4 4 4 1 1 1
47102 +0 0 0 5 5 5 43 57 68 153 152 153 193 200 203 220 221 221
47103 +177 184 187 174 174 174 167 166 167 166 165 166 158 157 158 157 156 157
47104 +158 157 158 166 165 166 156 155 156 85 115 134 13 16 17 4 0 0
47105 +4 0 0 4 0 0 5 5 5 5 5 5 4 4 4 4 4 4
47106 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47107 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47108 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47109 +4 4 4 4 4 4
47110 +5 5 5 4 3 3 6 6 6 6 6 6 4 0 0 6 6 6
47111 +6 6 6 6 6 6 6 6 6 6 6 6 13 16 17 60 73 81
47112 +177 184 187 220 221 221 220 221 221 220 221 221 205 212 215 220 221 221
47113 +220 221 221 205 212 215 220 221 221 244 246 246 244 246 246 205 212 215
47114 +125 124 125 30 32 34 0 0 0 0 0 0 2 2 2 5 5 5
47115 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 1 0 0
47116 +37 38 37 131 129 131 205 212 215 220 221 221 193 200 203 174 174 174
47117 +174 174 174 174 174 174 167 166 167 165 164 165 166 165 166 167 166 167
47118 +158 157 158 125 124 125 37 38 37 4 0 0 4 0 0 4 0 0
47119 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
47120 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47121 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47122 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47123 +4 4 4 4 4 4
47124 +4 4 4 5 5 5 4 3 3 4 3 3 6 6 6 6 6 6
47125 +4 0 0 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
47126 +26 28 28 125 124 125 205 212 215 220 221 221 220 221 221 220 221 221
47127 +205 212 215 220 221 221 205 212 215 220 221 221 220 221 221 244 246 246
47128 +244 246 246 190 197 201 60 74 84 16 19 21 4 0 0 0 0 0
47129 +0 0 0 0 0 0 0 0 0 0 0 0 16 19 21 120 125 127
47130 +177 184 187 220 221 221 205 212 215 177 184 187 174 174 174 177 184 187
47131 +174 174 174 174 174 174 167 166 167 174 174 174 166 165 166 137 136 137
47132 +60 73 81 13 16 17 4 0 0 4 0 0 4 3 3 6 6 6
47133 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47134 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47135 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47136 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47137 +4 4 4 4 4 4
47138 +5 5 5 4 3 3 5 5 5 4 3 3 6 6 6 4 0 0
47139 +6 6 6 6 6 6 4 0 0 6 6 6 4 0 0 6 6 6
47140 +6 6 6 6 6 6 37 38 37 137 136 137 193 200 203 220 221 221
47141 +220 221 221 205 212 215 220 221 221 205 212 215 205 212 215 220 221 221
47142 +220 221 221 220 221 221 244 246 246 166 165 166 43 57 68 2 2 2
47143 +0 0 0 4 0 0 16 19 21 60 73 81 157 156 157 202 210 214
47144 +220 221 221 193 200 203 177 184 187 177 184 187 177 184 187 174 174 174
47145 +174 174 174 174 174 174 174 174 174 157 156 157 60 74 84 24 26 27
47146 +4 0 0 4 0 0 4 0 0 6 6 6 4 4 4 4 4 4
47147 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47148 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47149 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47150 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47151 +4 4 4 4 4 4
47152 +4 4 4 4 4 4 5 5 5 4 3 3 5 5 5 6 6 6
47153 +6 6 6 4 0 0 6 6 6 6 6 6 6 6 6 4 0 0
47154 +4 0 0 4 0 0 6 6 6 24 26 27 60 73 81 167 166 167
47155 +220 221 221 220 221 221 220 221 221 205 212 215 205 212 215 205 212 215
47156 +205 212 215 220 221 221 220 221 221 220 221 221 205 212 215 137 136 137
47157 +60 74 84 125 124 125 137 136 137 190 197 201 220 221 221 193 200 203
47158 +177 184 187 177 184 187 177 184 187 174 174 174 174 174 174 177 184 187
47159 +190 197 201 174 174 174 125 124 125 37 38 37 6 6 6 4 0 0
47160 +4 0 0 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47161 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47162 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47163 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47164 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47165 +4 4 4 4 4 4
47166 +4 4 4 4 4 4 5 5 5 5 5 5 4 3 3 6 6 6
47167 +4 0 0 6 6 6 6 6 6 6 6 6 4 0 0 6 6 6
47168 +6 6 6 6 6 6 4 0 0 4 0 0 6 6 6 6 6 6
47169 +125 124 125 193 200 203 244 246 246 220 221 221 205 212 215 205 212 215
47170 +205 212 215 193 200 203 205 212 215 205 212 215 220 221 221 220 221 221
47171 +193 200 203 193 200 203 205 212 215 193 200 203 193 200 203 177 184 187
47172 +190 197 201 190 197 201 174 174 174 190 197 201 193 200 203 190 197 201
47173 +153 152 153 60 73 81 4 0 0 4 0 0 4 0 0 3 2 2
47174 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47175 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47176 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47177 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47178 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47179 +4 4 4 4 4 4
47180 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 4 3 3
47181 +6 6 6 4 3 3 4 3 3 4 3 3 6 6 6 6 6 6
47182 +4 0 0 6 6 6 6 6 6 6 6 6 4 0 0 4 0 0
47183 +4 0 0 26 28 28 131 129 131 220 221 221 244 246 246 220 221 221
47184 +205 212 215 193 200 203 205 212 215 193 200 203 193 200 203 205 212 215
47185 +220 221 221 193 200 203 193 200 203 193 200 203 190 197 201 174 174 174
47186 +174 174 174 190 197 201 193 200 203 193 200 203 167 166 167 125 124 125
47187 +6 6 6 4 0 0 4 0 0 4 3 3 4 4 4 4 4 4
47188 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47189 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47190 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47191 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47192 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47193 +4 4 4 4 4 4
47194 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
47195 +5 5 5 4 3 3 5 5 5 6 6 6 4 3 3 5 5 5
47196 +6 6 6 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
47197 +4 0 0 4 0 0 6 6 6 41 54 63 158 157 158 220 221 221
47198 +220 221 221 220 221 221 193 200 203 193 200 203 193 200 203 190 197 201
47199 +190 197 201 190 197 201 190 197 201 190 197 201 174 174 174 193 200 203
47200 +193 200 203 220 221 221 174 174 174 125 124 125 37 38 37 4 0 0
47201 +4 0 0 4 3 3 6 6 6 4 4 4 4 4 4 4 4 4
47202 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47203 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47204 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47205 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47206 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47207 +4 4 4 4 4 4
47208 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47209 +4 4 4 5 5 5 4 3 3 4 3 3 4 3 3 5 5 5
47210 +4 3 3 6 6 6 5 5 5 4 3 3 6 6 6 6 6 6
47211 +6 6 6 6 6 6 4 0 0 4 0 0 13 16 17 60 73 81
47212 +174 174 174 220 221 221 220 221 221 205 212 215 190 197 201 174 174 174
47213 +193 200 203 174 174 174 190 197 201 174 174 174 193 200 203 220 221 221
47214 +193 200 203 131 129 131 37 38 37 6 6 6 4 0 0 4 0 0
47215 +6 6 6 6 6 6 4 3 3 5 5 5 4 4 4 4 4 4
47216 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47217 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47218 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47219 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47220 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47221 +4 4 4 4 4 4
47222 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47223 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5
47224 +5 5 5 4 3 3 4 3 3 5 5 5 4 3 3 4 3 3
47225 +5 5 5 6 6 6 6 6 6 4 0 0 6 6 6 6 6 6
47226 +6 6 6 125 124 125 174 174 174 220 221 221 220 221 221 193 200 203
47227 +193 200 203 193 200 203 193 200 203 193 200 203 220 221 221 158 157 158
47228 +60 73 81 6 6 6 4 0 0 4 0 0 5 5 5 6 6 6
47229 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
47230 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47231 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47232 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47233 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47234 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47235 +4 4 4 4 4 4
47236 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47237 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47238 +4 4 4 5 5 5 5 5 5 4 3 3 5 5 5 4 3 3
47239 +5 5 5 5 5 5 6 6 6 6 6 6 4 0 0 4 0 0
47240 +4 0 0 4 0 0 26 28 28 125 124 125 174 174 174 193 200 203
47241 +193 200 203 174 174 174 193 200 203 167 166 167 125 124 125 6 6 6
47242 +6 6 6 6 6 6 4 0 0 6 6 6 6 6 6 5 5 5
47243 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
47244 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47245 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47246 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47247 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47248 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47249 +4 4 4 4 4 4
47250 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47251 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47252 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
47253 +4 3 3 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
47254 +6 6 6 4 0 0 4 0 0 6 6 6 37 38 37 125 124 125
47255 +153 152 153 131 129 131 125 124 125 37 38 37 6 6 6 6 6 6
47256 +6 6 6 4 0 0 6 6 6 6 6 6 4 3 3 5 5 5
47257 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47258 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47259 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47260 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47261 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47262 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47263 +4 4 4 4 4 4
47264 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47265 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47266 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47267 +4 4 4 5 5 5 5 5 5 4 3 3 5 5 5 4 3 3
47268 +6 6 6 6 6 6 4 0 0 4 0 0 6 6 6 6 6 6
47269 +24 26 27 24 26 27 6 6 6 6 6 6 6 6 6 4 0 0
47270 +6 6 6 6 6 6 4 0 0 6 6 6 5 5 5 4 3 3
47271 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47272 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47273 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47274 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47275 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47276 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47277 +4 4 4 4 4 4
47278 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47279 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47280 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47281 +4 4 4 4 4 4 5 5 5 4 3 3 5 5 5 6 6 6
47282 +4 0 0 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
47283 +6 6 6 6 6 6 6 6 6 4 0 0 6 6 6 6 6 6
47284 +4 0 0 6 6 6 6 6 6 4 3 3 5 5 5 4 4 4
47285 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47286 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47287 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47288 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47289 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47290 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47291 +4 4 4 4 4 4
47292 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47293 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47294 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47295 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 5 5 5
47296 +5 5 5 5 5 5 4 0 0 6 6 6 4 0 0 6 6 6
47297 +6 6 6 6 6 6 6 6 6 4 0 0 6 6 6 4 0 0
47298 +6 6 6 4 3 3 5 5 5 4 3 3 5 5 5 4 4 4
47299 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47300 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47301 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47302 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47303 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47304 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47305 +4 4 4 4 4 4
47306 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47307 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47308 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47309 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
47310 +4 3 3 6 6 6 4 3 3 6 6 6 6 6 6 6 6 6
47311 +4 0 0 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
47312 +6 6 6 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47313 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47314 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47315 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47316 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47317 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47318 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47319 +4 4 4 4 4 4
47320 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47321 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47322 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47323 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47324 +4 4 4 5 5 5 4 3 3 5 5 5 4 0 0 6 6 6
47325 +6 6 6 4 0 0 6 6 6 6 6 6 4 0 0 6 6 6
47326 +4 3 3 5 5 5 5 5 5 4 4 4 4 4 4 4 4 4
47327 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47328 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47329 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47330 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47331 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47332 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47333 +4 4 4 4 4 4
47334 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47335 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47336 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47337 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47338 +4 4 4 5 5 5 4 3 3 5 5 5 6 6 6 4 3 3
47339 +4 3 3 6 6 6 6 6 6 4 3 3 6 6 6 4 3 3
47340 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47341 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47342 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47343 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47344 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47345 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47346 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47347 +4 4 4 4 4 4
47348 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47349 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47350 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47351 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47352 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 6 6 6
47353 +5 5 5 4 3 3 4 3 3 4 3 3 5 5 5 5 5 5
47354 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47355 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47356 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47357 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47358 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47359 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47360 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47361 +4 4 4 4 4 4
47362 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47363 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47364 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47365 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47366 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 4 3 3
47367 +5 5 5 4 3 3 5 5 5 5 5 5 4 4 4 4 4 4
47368 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47369 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47370 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47371 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47372 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47373 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47374 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47375 +4 4 4 4 4 4
47376 diff --git a/drivers/video/mb862xx/mb862xxfb_accel.c b/drivers/video/mb862xx/mb862xxfb_accel.c
47377 index fe92eed..106e085 100644
47378 --- a/drivers/video/mb862xx/mb862xxfb_accel.c
47379 +++ b/drivers/video/mb862xx/mb862xxfb_accel.c
47380 @@ -312,14 +312,18 @@ void mb862xxfb_init_accel(struct fb_info *info, int xres)
47381 struct mb862xxfb_par *par = info->par;
47382
47383 if (info->var.bits_per_pixel == 32) {
47384 - info->fbops->fb_fillrect = cfb_fillrect;
47385 - info->fbops->fb_copyarea = cfb_copyarea;
47386 - info->fbops->fb_imageblit = cfb_imageblit;
47387 + pax_open_kernel();
47388 + *(void **)&info->fbops->fb_fillrect = cfb_fillrect;
47389 + *(void **)&info->fbops->fb_copyarea = cfb_copyarea;
47390 + *(void **)&info->fbops->fb_imageblit = cfb_imageblit;
47391 + pax_close_kernel();
47392 } else {
47393 outreg(disp, GC_L0EM, 3);
47394 - info->fbops->fb_fillrect = mb86290fb_fillrect;
47395 - info->fbops->fb_copyarea = mb86290fb_copyarea;
47396 - info->fbops->fb_imageblit = mb86290fb_imageblit;
47397 + pax_open_kernel();
47398 + *(void **)&info->fbops->fb_fillrect = mb86290fb_fillrect;
47399 + *(void **)&info->fbops->fb_copyarea = mb86290fb_copyarea;
47400 + *(void **)&info->fbops->fb_imageblit = mb86290fb_imageblit;
47401 + pax_close_kernel();
47402 }
47403 outreg(draw, GDC_REG_DRAW_BASE, 0);
47404 outreg(draw, GDC_REG_MODE_MISC, 0x8000);
47405 diff --git a/drivers/video/nvidia/nvidia.c b/drivers/video/nvidia/nvidia.c
47406 index ff22871..b129bed 100644
47407 --- a/drivers/video/nvidia/nvidia.c
47408 +++ b/drivers/video/nvidia/nvidia.c
47409 @@ -669,19 +669,23 @@ static int nvidiafb_set_par(struct fb_info *info)
47410 info->fix.line_length = (info->var.xres_virtual *
47411 info->var.bits_per_pixel) >> 3;
47412 if (info->var.accel_flags) {
47413 - info->fbops->fb_imageblit = nvidiafb_imageblit;
47414 - info->fbops->fb_fillrect = nvidiafb_fillrect;
47415 - info->fbops->fb_copyarea = nvidiafb_copyarea;
47416 - info->fbops->fb_sync = nvidiafb_sync;
47417 + pax_open_kernel();
47418 + *(void **)&info->fbops->fb_imageblit = nvidiafb_imageblit;
47419 + *(void **)&info->fbops->fb_fillrect = nvidiafb_fillrect;
47420 + *(void **)&info->fbops->fb_copyarea = nvidiafb_copyarea;
47421 + *(void **)&info->fbops->fb_sync = nvidiafb_sync;
47422 + pax_close_kernel();
47423 info->pixmap.scan_align = 4;
47424 info->flags &= ~FBINFO_HWACCEL_DISABLED;
47425 info->flags |= FBINFO_READS_FAST;
47426 NVResetGraphics(info);
47427 } else {
47428 - info->fbops->fb_imageblit = cfb_imageblit;
47429 - info->fbops->fb_fillrect = cfb_fillrect;
47430 - info->fbops->fb_copyarea = cfb_copyarea;
47431 - info->fbops->fb_sync = NULL;
47432 + pax_open_kernel();
47433 + *(void **)&info->fbops->fb_imageblit = cfb_imageblit;
47434 + *(void **)&info->fbops->fb_fillrect = cfb_fillrect;
47435 + *(void **)&info->fbops->fb_copyarea = cfb_copyarea;
47436 + *(void **)&info->fbops->fb_sync = NULL;
47437 + pax_close_kernel();
47438 info->pixmap.scan_align = 1;
47439 info->flags |= FBINFO_HWACCEL_DISABLED;
47440 info->flags &= ~FBINFO_READS_FAST;
47441 @@ -1173,8 +1177,11 @@ static int nvidia_set_fbinfo(struct fb_info *info)
47442 info->pixmap.size = 8 * 1024;
47443 info->pixmap.flags = FB_PIXMAP_SYSTEM;
47444
47445 - if (!hwcur)
47446 - info->fbops->fb_cursor = NULL;
47447 + if (!hwcur) {
47448 + pax_open_kernel();
47449 + *(void **)&info->fbops->fb_cursor = NULL;
47450 + pax_close_kernel();
47451 + }
47452
47453 info->var.accel_flags = (!noaccel);
47454
47455 diff --git a/drivers/video/s1d13xxxfb.c b/drivers/video/s1d13xxxfb.c
47456 index 76d9053..dec2bfd 100644
47457 --- a/drivers/video/s1d13xxxfb.c
47458 +++ b/drivers/video/s1d13xxxfb.c
47459 @@ -881,8 +881,10 @@ static int s1d13xxxfb_probe(struct platform_device *pdev)
47460
47461 switch(prod_id) {
47462 case S1D13506_PROD_ID: /* activate acceleration */
47463 - s1d13xxxfb_fbops.fb_fillrect = s1d13xxxfb_bitblt_solidfill;
47464 - s1d13xxxfb_fbops.fb_copyarea = s1d13xxxfb_bitblt_copyarea;
47465 + pax_open_kernel();
47466 + *(void **)&s1d13xxxfb_fbops.fb_fillrect = s1d13xxxfb_bitblt_solidfill;
47467 + *(void **)&s1d13xxxfb_fbops.fb_copyarea = s1d13xxxfb_bitblt_copyarea;
47468 + pax_close_kernel();
47469 info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN |
47470 FBINFO_HWACCEL_FILLRECT | FBINFO_HWACCEL_COPYAREA;
47471 break;
47472 diff --git a/drivers/video/smscufx.c b/drivers/video/smscufx.c
47473 index 97bd662..39fab85 100644
47474 --- a/drivers/video/smscufx.c
47475 +++ b/drivers/video/smscufx.c
47476 @@ -1171,7 +1171,9 @@ static int ufx_ops_release(struct fb_info *info, int user)
47477 fb_deferred_io_cleanup(info);
47478 kfree(info->fbdefio);
47479 info->fbdefio = NULL;
47480 - info->fbops->fb_mmap = ufx_ops_mmap;
47481 + pax_open_kernel();
47482 + *(void **)&info->fbops->fb_mmap = ufx_ops_mmap;
47483 + pax_close_kernel();
47484 }
47485
47486 pr_debug("released /dev/fb%d user=%d count=%d",
47487 diff --git a/drivers/video/udlfb.c b/drivers/video/udlfb.c
47488 index 86d449e..8e04dc5 100644
47489 --- a/drivers/video/udlfb.c
47490 +++ b/drivers/video/udlfb.c
47491 @@ -619,11 +619,11 @@ int dlfb_handle_damage(struct dlfb_data *dev, int x, int y,
47492 dlfb_urb_completion(urb);
47493
47494 error:
47495 - atomic_add(bytes_sent, &dev->bytes_sent);
47496 - atomic_add(bytes_identical, &dev->bytes_identical);
47497 - atomic_add(width*height*2, &dev->bytes_rendered);
47498 + atomic_add_unchecked(bytes_sent, &dev->bytes_sent);
47499 + atomic_add_unchecked(bytes_identical, &dev->bytes_identical);
47500 + atomic_add_unchecked(width*height*2, &dev->bytes_rendered);
47501 end_cycles = get_cycles();
47502 - atomic_add(((unsigned int) ((end_cycles - start_cycles)
47503 + atomic_add_unchecked(((unsigned int) ((end_cycles - start_cycles)
47504 >> 10)), /* Kcycles */
47505 &dev->cpu_kcycles_used);
47506
47507 @@ -744,11 +744,11 @@ static void dlfb_dpy_deferred_io(struct fb_info *info,
47508 dlfb_urb_completion(urb);
47509
47510 error:
47511 - atomic_add(bytes_sent, &dev->bytes_sent);
47512 - atomic_add(bytes_identical, &dev->bytes_identical);
47513 - atomic_add(bytes_rendered, &dev->bytes_rendered);
47514 + atomic_add_unchecked(bytes_sent, &dev->bytes_sent);
47515 + atomic_add_unchecked(bytes_identical, &dev->bytes_identical);
47516 + atomic_add_unchecked(bytes_rendered, &dev->bytes_rendered);
47517 end_cycles = get_cycles();
47518 - atomic_add(((unsigned int) ((end_cycles - start_cycles)
47519 + atomic_add_unchecked(((unsigned int) ((end_cycles - start_cycles)
47520 >> 10)), /* Kcycles */
47521 &dev->cpu_kcycles_used);
47522 }
47523 @@ -989,7 +989,9 @@ static int dlfb_ops_release(struct fb_info *info, int user)
47524 fb_deferred_io_cleanup(info);
47525 kfree(info->fbdefio);
47526 info->fbdefio = NULL;
47527 - info->fbops->fb_mmap = dlfb_ops_mmap;
47528 + pax_open_kernel();
47529 + *(void **)&info->fbops->fb_mmap = dlfb_ops_mmap;
47530 + pax_close_kernel();
47531 }
47532
47533 pr_warn("released /dev/fb%d user=%d count=%d\n",
47534 @@ -1372,7 +1374,7 @@ static ssize_t metrics_bytes_rendered_show(struct device *fbdev,
47535 struct fb_info *fb_info = dev_get_drvdata(fbdev);
47536 struct dlfb_data *dev = fb_info->par;
47537 return snprintf(buf, PAGE_SIZE, "%u\n",
47538 - atomic_read(&dev->bytes_rendered));
47539 + atomic_read_unchecked(&dev->bytes_rendered));
47540 }
47541
47542 static ssize_t metrics_bytes_identical_show(struct device *fbdev,
47543 @@ -1380,7 +1382,7 @@ static ssize_t metrics_bytes_identical_show(struct device *fbdev,
47544 struct fb_info *fb_info = dev_get_drvdata(fbdev);
47545 struct dlfb_data *dev = fb_info->par;
47546 return snprintf(buf, PAGE_SIZE, "%u\n",
47547 - atomic_read(&dev->bytes_identical));
47548 + atomic_read_unchecked(&dev->bytes_identical));
47549 }
47550
47551 static ssize_t metrics_bytes_sent_show(struct device *fbdev,
47552 @@ -1388,7 +1390,7 @@ static ssize_t metrics_bytes_sent_show(struct device *fbdev,
47553 struct fb_info *fb_info = dev_get_drvdata(fbdev);
47554 struct dlfb_data *dev = fb_info->par;
47555 return snprintf(buf, PAGE_SIZE, "%u\n",
47556 - atomic_read(&dev->bytes_sent));
47557 + atomic_read_unchecked(&dev->bytes_sent));
47558 }
47559
47560 static ssize_t metrics_cpu_kcycles_used_show(struct device *fbdev,
47561 @@ -1396,7 +1398,7 @@ static ssize_t metrics_cpu_kcycles_used_show(struct device *fbdev,
47562 struct fb_info *fb_info = dev_get_drvdata(fbdev);
47563 struct dlfb_data *dev = fb_info->par;
47564 return snprintf(buf, PAGE_SIZE, "%u\n",
47565 - atomic_read(&dev->cpu_kcycles_used));
47566 + atomic_read_unchecked(&dev->cpu_kcycles_used));
47567 }
47568
47569 static ssize_t edid_show(
47570 @@ -1456,10 +1458,10 @@ static ssize_t metrics_reset_store(struct device *fbdev,
47571 struct fb_info *fb_info = dev_get_drvdata(fbdev);
47572 struct dlfb_data *dev = fb_info->par;
47573
47574 - atomic_set(&dev->bytes_rendered, 0);
47575 - atomic_set(&dev->bytes_identical, 0);
47576 - atomic_set(&dev->bytes_sent, 0);
47577 - atomic_set(&dev->cpu_kcycles_used, 0);
47578 + atomic_set_unchecked(&dev->bytes_rendered, 0);
47579 + atomic_set_unchecked(&dev->bytes_identical, 0);
47580 + atomic_set_unchecked(&dev->bytes_sent, 0);
47581 + atomic_set_unchecked(&dev->cpu_kcycles_used, 0);
47582
47583 return count;
47584 }
47585 diff --git a/drivers/video/uvesafb.c b/drivers/video/uvesafb.c
47586 index d428445..79a78df 100644
47587 --- a/drivers/video/uvesafb.c
47588 +++ b/drivers/video/uvesafb.c
47589 @@ -19,6 +19,7 @@
47590 #include <linux/io.h>
47591 #include <linux/mutex.h>
47592 #include <linux/slab.h>
47593 +#include <linux/moduleloader.h>
47594 #include <video/edid.h>
47595 #include <video/uvesafb.h>
47596 #ifdef CONFIG_X86
47597 @@ -569,10 +570,32 @@ static int uvesafb_vbe_getpmi(struct uvesafb_ktask *task,
47598 if ((task->t.regs.eax & 0xffff) != 0x4f || task->t.regs.es < 0xc000) {
47599 par->pmi_setpal = par->ypan = 0;
47600 } else {
47601 +
47602 +#ifdef CONFIG_PAX_KERNEXEC
47603 +#ifdef CONFIG_MODULES
47604 + par->pmi_code = module_alloc_exec((u16)task->t.regs.ecx);
47605 +#endif
47606 + if (!par->pmi_code) {
47607 + par->pmi_setpal = par->ypan = 0;
47608 + return 0;
47609 + }
47610 +#endif
47611 +
47612 par->pmi_base = (u16 *)phys_to_virt(((u32)task->t.regs.es << 4)
47613 + task->t.regs.edi);
47614 +
47615 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
47616 + pax_open_kernel();
47617 + memcpy(par->pmi_code, par->pmi_base, (u16)task->t.regs.ecx);
47618 + pax_close_kernel();
47619 +
47620 + par->pmi_start = ktva_ktla(par->pmi_code + par->pmi_base[1]);
47621 + par->pmi_pal = ktva_ktla(par->pmi_code + par->pmi_base[2]);
47622 +#else
47623 par->pmi_start = (u8 *)par->pmi_base + par->pmi_base[1];
47624 par->pmi_pal = (u8 *)par->pmi_base + par->pmi_base[2];
47625 +#endif
47626 +
47627 printk(KERN_INFO "uvesafb: protected mode interface info at "
47628 "%04x:%04x\n",
47629 (u16)task->t.regs.es, (u16)task->t.regs.edi);
47630 @@ -817,13 +840,14 @@ static int uvesafb_vbe_init(struct fb_info *info)
47631 par->ypan = ypan;
47632
47633 if (par->pmi_setpal || par->ypan) {
47634 +#if !defined(CONFIG_MODULES) || !defined(CONFIG_PAX_KERNEXEC)
47635 if (__supported_pte_mask & _PAGE_NX) {
47636 par->pmi_setpal = par->ypan = 0;
47637 printk(KERN_WARNING "uvesafb: NX protection is actively."
47638 "We have better not to use the PMI.\n");
47639 - } else {
47640 + } else
47641 +#endif
47642 uvesafb_vbe_getpmi(task, par);
47643 - }
47644 }
47645 #else
47646 /* The protected mode interface is not available on non-x86. */
47647 @@ -1457,8 +1481,11 @@ static void uvesafb_init_info(struct fb_info *info, struct vbe_mode_ib *mode)
47648 info->fix.ywrapstep = (par->ypan > 1) ? 1 : 0;
47649
47650 /* Disable blanking if the user requested so. */
47651 - if (!blank)
47652 - info->fbops->fb_blank = NULL;
47653 + if (!blank) {
47654 + pax_open_kernel();
47655 + *(void **)&info->fbops->fb_blank = NULL;
47656 + pax_close_kernel();
47657 + }
47658
47659 /*
47660 * Find out how much IO memory is required for the mode with
47661 @@ -1534,8 +1561,11 @@ static void uvesafb_init_info(struct fb_info *info, struct vbe_mode_ib *mode)
47662 info->flags = FBINFO_FLAG_DEFAULT |
47663 (par->ypan ? FBINFO_HWACCEL_YPAN : 0);
47664
47665 - if (!par->ypan)
47666 - info->fbops->fb_pan_display = NULL;
47667 + if (!par->ypan) {
47668 + pax_open_kernel();
47669 + *(void **)&info->fbops->fb_pan_display = NULL;
47670 + pax_close_kernel();
47671 + }
47672 }
47673
47674 static void uvesafb_init_mtrr(struct fb_info *info)
47675 @@ -1836,6 +1866,11 @@ out:
47676 if (par->vbe_modes)
47677 kfree(par->vbe_modes);
47678
47679 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
47680 + if (par->pmi_code)
47681 + module_free_exec(NULL, par->pmi_code);
47682 +#endif
47683 +
47684 framebuffer_release(info);
47685 return err;
47686 }
47687 @@ -1862,6 +1897,12 @@ static int uvesafb_remove(struct platform_device *dev)
47688 kfree(par->vbe_state_orig);
47689 if (par->vbe_state_saved)
47690 kfree(par->vbe_state_saved);
47691 +
47692 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
47693 + if (par->pmi_code)
47694 + module_free_exec(NULL, par->pmi_code);
47695 +#endif
47696 +
47697 }
47698
47699 framebuffer_release(info);
47700 diff --git a/drivers/video/vesafb.c b/drivers/video/vesafb.c
47701 index 501b340..d80aa17 100644
47702 --- a/drivers/video/vesafb.c
47703 +++ b/drivers/video/vesafb.c
47704 @@ -9,6 +9,7 @@
47705 */
47706
47707 #include <linux/module.h>
47708 +#include <linux/moduleloader.h>
47709 #include <linux/kernel.h>
47710 #include <linux/errno.h>
47711 #include <linux/string.h>
47712 @@ -52,8 +53,8 @@ static int vram_remap __initdata; /* Set amount of memory to be used */
47713 static int vram_total __initdata; /* Set total amount of memory */
47714 static int pmi_setpal __read_mostly = 1; /* pmi for palette changes ??? */
47715 static int ypan __read_mostly; /* 0..nothing, 1..ypan, 2..ywrap */
47716 -static void (*pmi_start)(void) __read_mostly;
47717 -static void (*pmi_pal) (void) __read_mostly;
47718 +static void (*pmi_start)(void) __read_only;
47719 +static void (*pmi_pal) (void) __read_only;
47720 static int depth __read_mostly;
47721 static int vga_compat __read_mostly;
47722 /* --------------------------------------------------------------------- */
47723 @@ -233,6 +234,7 @@ static int __init vesafb_probe(struct platform_device *dev)
47724 unsigned int size_vmode;
47725 unsigned int size_remap;
47726 unsigned int size_total;
47727 + void *pmi_code = NULL;
47728
47729 if (screen_info.orig_video_isVGA != VIDEO_TYPE_VLFB)
47730 return -ENODEV;
47731 @@ -275,10 +277,6 @@ static int __init vesafb_probe(struct platform_device *dev)
47732 size_remap = size_total;
47733 vesafb_fix.smem_len = size_remap;
47734
47735 -#ifndef __i386__
47736 - screen_info.vesapm_seg = 0;
47737 -#endif
47738 -
47739 if (!request_mem_region(vesafb_fix.smem_start, size_total, "vesafb")) {
47740 printk(KERN_WARNING
47741 "vesafb: cannot reserve video memory at 0x%lx\n",
47742 @@ -307,9 +305,21 @@ static int __init vesafb_probe(struct platform_device *dev)
47743 printk(KERN_INFO "vesafb: mode is %dx%dx%d, linelength=%d, pages=%d\n",
47744 vesafb_defined.xres, vesafb_defined.yres, vesafb_defined.bits_per_pixel, vesafb_fix.line_length, screen_info.pages);
47745
47746 +#ifdef __i386__
47747 +
47748 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
47749 + pmi_code = module_alloc_exec(screen_info.vesapm_size);
47750 + if (!pmi_code)
47751 +#elif !defined(CONFIG_PAX_KERNEXEC)
47752 + if (0)
47753 +#endif
47754 +
47755 +#endif
47756 + screen_info.vesapm_seg = 0;
47757 +
47758 if (screen_info.vesapm_seg) {
47759 - printk(KERN_INFO "vesafb: protected mode interface info at %04x:%04x\n",
47760 - screen_info.vesapm_seg,screen_info.vesapm_off);
47761 + printk(KERN_INFO "vesafb: protected mode interface info at %04x:%04x %04x bytes\n",
47762 + screen_info.vesapm_seg,screen_info.vesapm_off,screen_info.vesapm_size);
47763 }
47764
47765 if (screen_info.vesapm_seg < 0xc000)
47766 @@ -317,9 +327,25 @@ static int __init vesafb_probe(struct platform_device *dev)
47767
47768 if (ypan || pmi_setpal) {
47769 unsigned short *pmi_base;
47770 +
47771 pmi_base = (unsigned short*)phys_to_virt(((unsigned long)screen_info.vesapm_seg << 4) + screen_info.vesapm_off);
47772 - pmi_start = (void*)((char*)pmi_base + pmi_base[1]);
47773 - pmi_pal = (void*)((char*)pmi_base + pmi_base[2]);
47774 +
47775 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
47776 + pax_open_kernel();
47777 + memcpy(pmi_code, pmi_base, screen_info.vesapm_size);
47778 +#else
47779 + pmi_code = pmi_base;
47780 +#endif
47781 +
47782 + pmi_start = (void*)((char*)pmi_code + pmi_base[1]);
47783 + pmi_pal = (void*)((char*)pmi_code + pmi_base[2]);
47784 +
47785 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
47786 + pmi_start = ktva_ktla(pmi_start);
47787 + pmi_pal = ktva_ktla(pmi_pal);
47788 + pax_close_kernel();
47789 +#endif
47790 +
47791 printk(KERN_INFO "vesafb: pmi: set display start = %p, set palette = %p\n",pmi_start,pmi_pal);
47792 if (pmi_base[3]) {
47793 printk(KERN_INFO "vesafb: pmi: ports = ");
47794 @@ -472,8 +498,11 @@ static int __init vesafb_probe(struct platform_device *dev)
47795 info->flags = FBINFO_FLAG_DEFAULT | FBINFO_MISC_FIRMWARE |
47796 (ypan ? FBINFO_HWACCEL_YPAN : 0);
47797
47798 - if (!ypan)
47799 - info->fbops->fb_pan_display = NULL;
47800 + if (!ypan) {
47801 + pax_open_kernel();
47802 + *(void **)&info->fbops->fb_pan_display = NULL;
47803 + pax_close_kernel();
47804 + }
47805
47806 if (fb_alloc_cmap(&info->cmap, 256, 0) < 0) {
47807 err = -ENOMEM;
47808 @@ -488,6 +517,11 @@ static int __init vesafb_probe(struct platform_device *dev)
47809 info->node, info->fix.id);
47810 return 0;
47811 err:
47812 +
47813 +#if defined(__i386__) && defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
47814 + module_free_exec(NULL, pmi_code);
47815 +#endif
47816 +
47817 if (info->screen_base)
47818 iounmap(info->screen_base);
47819 framebuffer_release(info);
47820 diff --git a/drivers/video/via/via_clock.h b/drivers/video/via/via_clock.h
47821 index 88714ae..16c2e11 100644
47822 --- a/drivers/video/via/via_clock.h
47823 +++ b/drivers/video/via/via_clock.h
47824 @@ -56,7 +56,7 @@ struct via_clock {
47825
47826 void (*set_engine_pll_state)(u8 state);
47827 void (*set_engine_pll)(struct via_pll_config config);
47828 -};
47829 +} __no_const;
47830
47831
47832 static inline u32 get_pll_internal_frequency(u32 ref_freq,
47833 diff --git a/drivers/xen/xenfs/xenstored.c b/drivers/xen/xenfs/xenstored.c
47834 index fef20db..d28b1ab 100644
47835 --- a/drivers/xen/xenfs/xenstored.c
47836 +++ b/drivers/xen/xenfs/xenstored.c
47837 @@ -24,7 +24,12 @@ static int xsd_release(struct inode *inode, struct file *file)
47838 static int xsd_kva_open(struct inode *inode, struct file *file)
47839 {
47840 file->private_data = (void *)kasprintf(GFP_KERNEL, "0x%p",
47841 +#ifdef CONFIG_GRKERNSEC_HIDESYM
47842 + NULL);
47843 +#else
47844 xen_store_interface);
47845 +#endif
47846 +
47847 if (!file->private_data)
47848 return -ENOMEM;
47849 return 0;
47850 diff --git a/fs/9p/vfs_addr.c b/fs/9p/vfs_addr.c
47851 index 0ad61c6..f198bd7 100644
47852 --- a/fs/9p/vfs_addr.c
47853 +++ b/fs/9p/vfs_addr.c
47854 @@ -185,7 +185,7 @@ static int v9fs_vfs_writepage_locked(struct page *page)
47855
47856 retval = v9fs_file_write_internal(inode,
47857 v9inode->writeback_fid,
47858 - (__force const char __user *)buffer,
47859 + (const char __force_user *)buffer,
47860 len, &offset, 0);
47861 if (retval > 0)
47862 retval = 0;
47863 diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
47864 index d86edc8..40ff2fb 100644
47865 --- a/fs/9p/vfs_inode.c
47866 +++ b/fs/9p/vfs_inode.c
47867 @@ -1314,7 +1314,7 @@ static void *v9fs_vfs_follow_link(struct dentry *dentry, struct nameidata *nd)
47868 void
47869 v9fs_vfs_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
47870 {
47871 - char *s = nd_get_link(nd);
47872 + const char *s = nd_get_link(nd);
47873
47874 p9_debug(P9_DEBUG_VFS, " %s %s\n",
47875 dentry->d_name.name, IS_ERR(s) ? "<error>" : s);
47876 diff --git a/fs/Kconfig.binfmt b/fs/Kconfig.binfmt
47877 index 0efd152..b5802ad 100644
47878 --- a/fs/Kconfig.binfmt
47879 +++ b/fs/Kconfig.binfmt
47880 @@ -89,7 +89,7 @@ config HAVE_AOUT
47881
47882 config BINFMT_AOUT
47883 tristate "Kernel support for a.out and ECOFF binaries"
47884 - depends on HAVE_AOUT
47885 + depends on HAVE_AOUT && BROKEN
47886 ---help---
47887 A.out (Assembler.OUTput) is a set of formats for libraries and
47888 executables used in the earliest versions of UNIX. Linux used
47889 diff --git a/fs/aio.c b/fs/aio.c
47890 index 1dc8786..d3b29e8 100644
47891 --- a/fs/aio.c
47892 +++ b/fs/aio.c
47893 @@ -111,7 +111,7 @@ static int aio_setup_ring(struct kioctx *ctx)
47894 size += sizeof(struct io_event) * nr_events;
47895 nr_pages = (size + PAGE_SIZE-1) >> PAGE_SHIFT;
47896
47897 - if (nr_pages < 0)
47898 + if (nr_pages <= 0)
47899 return -EINVAL;
47900
47901 nr_events = (PAGE_SIZE * nr_pages - sizeof(struct aio_ring)) / sizeof(struct io_event);
47902 @@ -1375,18 +1375,19 @@ static ssize_t aio_fsync(struct kiocb *iocb)
47903 static ssize_t aio_setup_vectored_rw(int type, struct kiocb *kiocb, bool compat)
47904 {
47905 ssize_t ret;
47906 + struct iovec iovstack;
47907
47908 #ifdef CONFIG_COMPAT
47909 if (compat)
47910 ret = compat_rw_copy_check_uvector(type,
47911 (struct compat_iovec __user *)kiocb->ki_buf,
47912 - kiocb->ki_nbytes, 1, &kiocb->ki_inline_vec,
47913 + kiocb->ki_nbytes, 1, &iovstack,
47914 &kiocb->ki_iovec);
47915 else
47916 #endif
47917 ret = rw_copy_check_uvector(type,
47918 (struct iovec __user *)kiocb->ki_buf,
47919 - kiocb->ki_nbytes, 1, &kiocb->ki_inline_vec,
47920 + kiocb->ki_nbytes, 1, &iovstack,
47921 &kiocb->ki_iovec);
47922 if (ret < 0)
47923 goto out;
47924 @@ -1395,6 +1396,10 @@ static ssize_t aio_setup_vectored_rw(int type, struct kiocb *kiocb, bool compat)
47925 if (ret < 0)
47926 goto out;
47927
47928 + if (kiocb->ki_iovec == &iovstack) {
47929 + kiocb->ki_inline_vec = iovstack;
47930 + kiocb->ki_iovec = &kiocb->ki_inline_vec;
47931 + }
47932 kiocb->ki_nr_segs = kiocb->ki_nbytes;
47933 kiocb->ki_cur_seg = 0;
47934 /* ki_nbytes/left now reflect bytes instead of segs */
47935 diff --git a/fs/attr.c b/fs/attr.c
47936 index 1449adb..a2038c2 100644
47937 --- a/fs/attr.c
47938 +++ b/fs/attr.c
47939 @@ -102,6 +102,7 @@ int inode_newsize_ok(const struct inode *inode, loff_t offset)
47940 unsigned long limit;
47941
47942 limit = rlimit(RLIMIT_FSIZE);
47943 + gr_learn_resource(current, RLIMIT_FSIZE, (unsigned long)offset, 1);
47944 if (limit != RLIM_INFINITY && offset > limit)
47945 goto out_sig;
47946 if (offset > inode->i_sb->s_maxbytes)
47947 diff --git a/fs/autofs4/waitq.c b/fs/autofs4/waitq.c
47948 index 3db70da..7aeec5b 100644
47949 --- a/fs/autofs4/waitq.c
47950 +++ b/fs/autofs4/waitq.c
47951 @@ -59,7 +59,7 @@ static int autofs4_write(struct autofs_sb_info *sbi,
47952 {
47953 unsigned long sigpipe, flags;
47954 mm_segment_t fs;
47955 - const char *data = (const char *)addr;
47956 + const char __user *data = (const char __force_user *)addr;
47957 ssize_t wr = 0;
47958
47959 sigpipe = sigismember(&current->pending.signal, SIGPIPE);
47960 @@ -346,6 +346,10 @@ static int validate_request(struct autofs_wait_queue **wait,
47961 return 1;
47962 }
47963
47964 +#ifdef CONFIG_GRKERNSEC_HIDESYM
47965 +static atomic_unchecked_t autofs_dummy_name_id = ATOMIC_INIT(0);
47966 +#endif
47967 +
47968 int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
47969 enum autofs_notify notify)
47970 {
47971 @@ -379,7 +383,12 @@ int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
47972
47973 /* If this is a direct mount request create a dummy name */
47974 if (IS_ROOT(dentry) && autofs_type_trigger(sbi->type))
47975 +#ifdef CONFIG_GRKERNSEC_HIDESYM
47976 + /* this name does get written to userland via autofs4_write() */
47977 + qstr.len = sprintf(name, "%08x", atomic_inc_return_unchecked(&autofs_dummy_name_id));
47978 +#else
47979 qstr.len = sprintf(name, "%p", dentry);
47980 +#endif
47981 else {
47982 qstr.len = autofs4_getpath(sbi, dentry, &name);
47983 if (!qstr.len) {
47984 diff --git a/fs/befs/endian.h b/fs/befs/endian.h
47985 index 2722387..c8dd2a7 100644
47986 --- a/fs/befs/endian.h
47987 +++ b/fs/befs/endian.h
47988 @@ -11,7 +11,7 @@
47989
47990 #include <asm/byteorder.h>
47991
47992 -static inline u64
47993 +static inline u64 __intentional_overflow(-1)
47994 fs64_to_cpu(const struct super_block *sb, fs64 n)
47995 {
47996 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
47997 @@ -29,7 +29,7 @@ cpu_to_fs64(const struct super_block *sb, u64 n)
47998 return (__force fs64)cpu_to_be64(n);
47999 }
48000
48001 -static inline u32
48002 +static inline u32 __intentional_overflow(-1)
48003 fs32_to_cpu(const struct super_block *sb, fs32 n)
48004 {
48005 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
48006 diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c
48007 index 8615ee8..388ed68 100644
48008 --- a/fs/befs/linuxvfs.c
48009 +++ b/fs/befs/linuxvfs.c
48010 @@ -510,7 +510,7 @@ static void befs_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
48011 {
48012 befs_inode_info *befs_ino = BEFS_I(dentry->d_inode);
48013 if (befs_ino->i_flags & BEFS_LONG_SYMLINK) {
48014 - char *link = nd_get_link(nd);
48015 + const char *link = nd_get_link(nd);
48016 if (!IS_ERR(link))
48017 kfree(link);
48018 }
48019 diff --git a/fs/binfmt_aout.c b/fs/binfmt_aout.c
48020 index bbc8f88..7c7ac97 100644
48021 --- a/fs/binfmt_aout.c
48022 +++ b/fs/binfmt_aout.c
48023 @@ -16,6 +16,7 @@
48024 #include <linux/string.h>
48025 #include <linux/fs.h>
48026 #include <linux/file.h>
48027 +#include <linux/security.h>
48028 #include <linux/stat.h>
48029 #include <linux/fcntl.h>
48030 #include <linux/ptrace.h>
48031 @@ -59,6 +60,8 @@ static int aout_core_dump(struct coredump_params *cprm)
48032 #endif
48033 # define START_STACK(u) ((void __user *)u.start_stack)
48034
48035 + memset(&dump, 0, sizeof(dump));
48036 +
48037 fs = get_fs();
48038 set_fs(KERNEL_DS);
48039 has_dumped = 1;
48040 @@ -70,10 +73,12 @@ static int aout_core_dump(struct coredump_params *cprm)
48041
48042 /* If the size of the dump file exceeds the rlimit, then see what would happen
48043 if we wrote the stack, but not the data area. */
48044 + gr_learn_resource(current, RLIMIT_CORE, (dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE, 1);
48045 if ((dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE > cprm->limit)
48046 dump.u_dsize = 0;
48047
48048 /* Make sure we have enough room to write the stack and data areas. */
48049 + gr_learn_resource(current, RLIMIT_CORE, (dump.u_ssize + 1) * PAGE_SIZE, 1);
48050 if ((dump.u_ssize + 1) * PAGE_SIZE > cprm->limit)
48051 dump.u_ssize = 0;
48052
48053 @@ -234,6 +239,8 @@ static int load_aout_binary(struct linux_binprm * bprm)
48054 rlim = rlimit(RLIMIT_DATA);
48055 if (rlim >= RLIM_INFINITY)
48056 rlim = ~0;
48057 +
48058 + gr_learn_resource(current, RLIMIT_DATA, ex.a_data + ex.a_bss, 1);
48059 if (ex.a_data + ex.a_bss > rlim)
48060 return -ENOMEM;
48061
48062 @@ -268,6 +275,27 @@ static int load_aout_binary(struct linux_binprm * bprm)
48063
48064 install_exec_creds(bprm);
48065
48066 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
48067 + current->mm->pax_flags = 0UL;
48068 +#endif
48069 +
48070 +#ifdef CONFIG_PAX_PAGEEXEC
48071 + if (!(N_FLAGS(ex) & F_PAX_PAGEEXEC)) {
48072 + current->mm->pax_flags |= MF_PAX_PAGEEXEC;
48073 +
48074 +#ifdef CONFIG_PAX_EMUTRAMP
48075 + if (N_FLAGS(ex) & F_PAX_EMUTRAMP)
48076 + current->mm->pax_flags |= MF_PAX_EMUTRAMP;
48077 +#endif
48078 +
48079 +#ifdef CONFIG_PAX_MPROTECT
48080 + if (!(N_FLAGS(ex) & F_PAX_MPROTECT))
48081 + current->mm->pax_flags |= MF_PAX_MPROTECT;
48082 +#endif
48083 +
48084 + }
48085 +#endif
48086 +
48087 if (N_MAGIC(ex) == OMAGIC) {
48088 unsigned long text_addr, map_size;
48089 loff_t pos;
48090 @@ -333,7 +361,7 @@ static int load_aout_binary(struct linux_binprm * bprm)
48091 }
48092
48093 error = vm_mmap(bprm->file, N_DATADDR(ex), ex.a_data,
48094 - PROT_READ | PROT_WRITE | PROT_EXEC,
48095 + PROT_READ | PROT_WRITE,
48096 MAP_FIXED | MAP_PRIVATE | MAP_DENYWRITE | MAP_EXECUTABLE,
48097 fd_offset + ex.a_text);
48098 if (error != N_DATADDR(ex)) {
48099 diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
48100 index 86af964..5d53bf6 100644
48101 --- a/fs/binfmt_elf.c
48102 +++ b/fs/binfmt_elf.c
48103 @@ -34,6 +34,7 @@
48104 #include <linux/utsname.h>
48105 #include <linux/coredump.h>
48106 #include <linux/sched.h>
48107 +#include <linux/xattr.h>
48108 #include <asm/uaccess.h>
48109 #include <asm/param.h>
48110 #include <asm/page.h>
48111 @@ -60,6 +61,10 @@ static int elf_core_dump(struct coredump_params *cprm);
48112 #define elf_core_dump NULL
48113 #endif
48114
48115 +#ifdef CONFIG_PAX_MPROTECT
48116 +static void elf_handle_mprotect(struct vm_area_struct *vma, unsigned long newflags);
48117 +#endif
48118 +
48119 #if ELF_EXEC_PAGESIZE > PAGE_SIZE
48120 #define ELF_MIN_ALIGN ELF_EXEC_PAGESIZE
48121 #else
48122 @@ -79,6 +84,11 @@ static struct linux_binfmt elf_format = {
48123 .load_binary = load_elf_binary,
48124 .load_shlib = load_elf_library,
48125 .core_dump = elf_core_dump,
48126 +
48127 +#ifdef CONFIG_PAX_MPROTECT
48128 + .handle_mprotect= elf_handle_mprotect,
48129 +#endif
48130 +
48131 .min_coredump = ELF_EXEC_PAGESIZE,
48132 };
48133
48134 @@ -86,6 +96,8 @@ static struct linux_binfmt elf_format = {
48135
48136 static int set_brk(unsigned long start, unsigned long end)
48137 {
48138 + unsigned long e = end;
48139 +
48140 start = ELF_PAGEALIGN(start);
48141 end = ELF_PAGEALIGN(end);
48142 if (end > start) {
48143 @@ -94,7 +106,7 @@ static int set_brk(unsigned long start, unsigned long end)
48144 if (BAD_ADDR(addr))
48145 return addr;
48146 }
48147 - current->mm->start_brk = current->mm->brk = end;
48148 + current->mm->start_brk = current->mm->brk = e;
48149 return 0;
48150 }
48151
48152 @@ -155,12 +167,13 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
48153 elf_addr_t __user *u_rand_bytes;
48154 const char *k_platform = ELF_PLATFORM;
48155 const char *k_base_platform = ELF_BASE_PLATFORM;
48156 - unsigned char k_rand_bytes[16];
48157 + u32 k_rand_bytes[4];
48158 int items;
48159 elf_addr_t *elf_info;
48160 int ei_index = 0;
48161 const struct cred *cred = current_cred();
48162 struct vm_area_struct *vma;
48163 + unsigned long saved_auxv[AT_VECTOR_SIZE];
48164
48165 /*
48166 * In some cases (e.g. Hyper-Threading), we want to avoid L1
48167 @@ -202,8 +215,12 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
48168 * Generate 16 random bytes for userspace PRNG seeding.
48169 */
48170 get_random_bytes(k_rand_bytes, sizeof(k_rand_bytes));
48171 - u_rand_bytes = (elf_addr_t __user *)
48172 - STACK_ALLOC(p, sizeof(k_rand_bytes));
48173 + srandom32(k_rand_bytes[0] ^ random32());
48174 + srandom32(k_rand_bytes[1] ^ random32());
48175 + srandom32(k_rand_bytes[2] ^ random32());
48176 + srandom32(k_rand_bytes[3] ^ random32());
48177 + p = STACK_ROUND(p, sizeof(k_rand_bytes));
48178 + u_rand_bytes = (elf_addr_t __user *) p;
48179 if (__copy_to_user(u_rand_bytes, k_rand_bytes, sizeof(k_rand_bytes)))
48180 return -EFAULT;
48181
48182 @@ -315,9 +332,11 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
48183 return -EFAULT;
48184 current->mm->env_end = p;
48185
48186 + memcpy(saved_auxv, elf_info, ei_index * sizeof(elf_addr_t));
48187 +
48188 /* Put the elf_info on the stack in the right place. */
48189 sp = (elf_addr_t __user *)envp + 1;
48190 - if (copy_to_user(sp, elf_info, ei_index * sizeof(elf_addr_t)))
48191 + if (copy_to_user(sp, saved_auxv, ei_index * sizeof(elf_addr_t)))
48192 return -EFAULT;
48193 return 0;
48194 }
48195 @@ -385,15 +404,14 @@ static unsigned long total_mapping_size(struct elf_phdr *cmds, int nr)
48196 an ELF header */
48197
48198 static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
48199 - struct file *interpreter, unsigned long *interp_map_addr,
48200 - unsigned long no_base)
48201 + struct file *interpreter, unsigned long no_base)
48202 {
48203 struct elf_phdr *elf_phdata;
48204 struct elf_phdr *eppnt;
48205 - unsigned long load_addr = 0;
48206 + unsigned long load_addr = 0, pax_task_size = TASK_SIZE;
48207 int load_addr_set = 0;
48208 unsigned long last_bss = 0, elf_bss = 0;
48209 - unsigned long error = ~0UL;
48210 + unsigned long error = -EINVAL;
48211 unsigned long total_size;
48212 int retval, i, size;
48213
48214 @@ -439,6 +457,11 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
48215 goto out_close;
48216 }
48217
48218 +#ifdef CONFIG_PAX_SEGMEXEC
48219 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC)
48220 + pax_task_size = SEGMEXEC_TASK_SIZE;
48221 +#endif
48222 +
48223 eppnt = elf_phdata;
48224 for (i = 0; i < interp_elf_ex->e_phnum; i++, eppnt++) {
48225 if (eppnt->p_type == PT_LOAD) {
48226 @@ -462,8 +485,6 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
48227 map_addr = elf_map(interpreter, load_addr + vaddr,
48228 eppnt, elf_prot, elf_type, total_size);
48229 total_size = 0;
48230 - if (!*interp_map_addr)
48231 - *interp_map_addr = map_addr;
48232 error = map_addr;
48233 if (BAD_ADDR(map_addr))
48234 goto out_close;
48235 @@ -482,8 +503,8 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
48236 k = load_addr + eppnt->p_vaddr;
48237 if (BAD_ADDR(k) ||
48238 eppnt->p_filesz > eppnt->p_memsz ||
48239 - eppnt->p_memsz > TASK_SIZE ||
48240 - TASK_SIZE - eppnt->p_memsz < k) {
48241 + eppnt->p_memsz > pax_task_size ||
48242 + pax_task_size - eppnt->p_memsz < k) {
48243 error = -ENOMEM;
48244 goto out_close;
48245 }
48246 @@ -535,6 +556,315 @@ out:
48247 return error;
48248 }
48249
48250 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
48251 +#ifdef CONFIG_PAX_SOFTMODE
48252 +static unsigned long pax_parse_pt_pax_softmode(const struct elf_phdr * const elf_phdata)
48253 +{
48254 + unsigned long pax_flags = 0UL;
48255 +
48256 +#ifdef CONFIG_PAX_PAGEEXEC
48257 + if (elf_phdata->p_flags & PF_PAGEEXEC)
48258 + pax_flags |= MF_PAX_PAGEEXEC;
48259 +#endif
48260 +
48261 +#ifdef CONFIG_PAX_SEGMEXEC
48262 + if (elf_phdata->p_flags & PF_SEGMEXEC)
48263 + pax_flags |= MF_PAX_SEGMEXEC;
48264 +#endif
48265 +
48266 +#ifdef CONFIG_PAX_EMUTRAMP
48267 + if ((elf_phdata->p_flags & PF_EMUTRAMP) && (pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)))
48268 + pax_flags |= MF_PAX_EMUTRAMP;
48269 +#endif
48270 +
48271 +#ifdef CONFIG_PAX_MPROTECT
48272 + if (elf_phdata->p_flags & PF_MPROTECT)
48273 + pax_flags |= MF_PAX_MPROTECT;
48274 +#endif
48275 +
48276 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
48277 + if (randomize_va_space && (elf_phdata->p_flags & PF_RANDMMAP))
48278 + pax_flags |= MF_PAX_RANDMMAP;
48279 +#endif
48280 +
48281 + return pax_flags;
48282 +}
48283 +#endif
48284 +
48285 +static unsigned long pax_parse_pt_pax_hardmode(const struct elf_phdr * const elf_phdata)
48286 +{
48287 + unsigned long pax_flags = 0UL;
48288 +
48289 +#ifdef CONFIG_PAX_PAGEEXEC
48290 + if (!(elf_phdata->p_flags & PF_NOPAGEEXEC))
48291 + pax_flags |= MF_PAX_PAGEEXEC;
48292 +#endif
48293 +
48294 +#ifdef CONFIG_PAX_SEGMEXEC
48295 + if (!(elf_phdata->p_flags & PF_NOSEGMEXEC))
48296 + pax_flags |= MF_PAX_SEGMEXEC;
48297 +#endif
48298 +
48299 +#ifdef CONFIG_PAX_EMUTRAMP
48300 + if (!(elf_phdata->p_flags & PF_NOEMUTRAMP))
48301 + pax_flags |= MF_PAX_EMUTRAMP;
48302 +#endif
48303 +
48304 +#ifdef CONFIG_PAX_MPROTECT
48305 + if (!(elf_phdata->p_flags & PF_NOMPROTECT))
48306 + pax_flags |= MF_PAX_MPROTECT;
48307 +#endif
48308 +
48309 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
48310 + if (randomize_va_space && !(elf_phdata->p_flags & PF_NORANDMMAP))
48311 + pax_flags |= MF_PAX_RANDMMAP;
48312 +#endif
48313 +
48314 + return pax_flags;
48315 +}
48316 +#endif
48317 +
48318 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
48319 +#ifdef CONFIG_PAX_SOFTMODE
48320 +static unsigned long pax_parse_xattr_pax_softmode(unsigned long pax_flags_softmode)
48321 +{
48322 + unsigned long pax_flags = 0UL;
48323 +
48324 +#ifdef CONFIG_PAX_PAGEEXEC
48325 + if (pax_flags_softmode & MF_PAX_PAGEEXEC)
48326 + pax_flags |= MF_PAX_PAGEEXEC;
48327 +#endif
48328 +
48329 +#ifdef CONFIG_PAX_SEGMEXEC
48330 + if (pax_flags_softmode & MF_PAX_SEGMEXEC)
48331 + pax_flags |= MF_PAX_SEGMEXEC;
48332 +#endif
48333 +
48334 +#ifdef CONFIG_PAX_EMUTRAMP
48335 + if ((pax_flags_softmode & MF_PAX_EMUTRAMP) && (pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)))
48336 + pax_flags |= MF_PAX_EMUTRAMP;
48337 +#endif
48338 +
48339 +#ifdef CONFIG_PAX_MPROTECT
48340 + if (pax_flags_softmode & MF_PAX_MPROTECT)
48341 + pax_flags |= MF_PAX_MPROTECT;
48342 +#endif
48343 +
48344 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
48345 + if (randomize_va_space && (pax_flags_softmode & MF_PAX_RANDMMAP))
48346 + pax_flags |= MF_PAX_RANDMMAP;
48347 +#endif
48348 +
48349 + return pax_flags;
48350 +}
48351 +#endif
48352 +
48353 +static unsigned long pax_parse_xattr_pax_hardmode(unsigned long pax_flags_hardmode)
48354 +{
48355 + unsigned long pax_flags = 0UL;
48356 +
48357 +#ifdef CONFIG_PAX_PAGEEXEC
48358 + if (!(pax_flags_hardmode & MF_PAX_PAGEEXEC))
48359 + pax_flags |= MF_PAX_PAGEEXEC;
48360 +#endif
48361 +
48362 +#ifdef CONFIG_PAX_SEGMEXEC
48363 + if (!(pax_flags_hardmode & MF_PAX_SEGMEXEC))
48364 + pax_flags |= MF_PAX_SEGMEXEC;
48365 +#endif
48366 +
48367 +#ifdef CONFIG_PAX_EMUTRAMP
48368 + if (!(pax_flags_hardmode & MF_PAX_EMUTRAMP))
48369 + pax_flags |= MF_PAX_EMUTRAMP;
48370 +#endif
48371 +
48372 +#ifdef CONFIG_PAX_MPROTECT
48373 + if (!(pax_flags_hardmode & MF_PAX_MPROTECT))
48374 + pax_flags |= MF_PAX_MPROTECT;
48375 +#endif
48376 +
48377 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
48378 + if (randomize_va_space && !(pax_flags_hardmode & MF_PAX_RANDMMAP))
48379 + pax_flags |= MF_PAX_RANDMMAP;
48380 +#endif
48381 +
48382 + return pax_flags;
48383 +}
48384 +#endif
48385 +
48386 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
48387 +static unsigned long pax_parse_ei_pax(const struct elfhdr * const elf_ex)
48388 +{
48389 + unsigned long pax_flags = 0UL;
48390 +
48391 +#ifdef CONFIG_PAX_EI_PAX
48392 +
48393 +#ifdef CONFIG_PAX_PAGEEXEC
48394 + if (!(elf_ex->e_ident[EI_PAX] & EF_PAX_PAGEEXEC))
48395 + pax_flags |= MF_PAX_PAGEEXEC;
48396 +#endif
48397 +
48398 +#ifdef CONFIG_PAX_SEGMEXEC
48399 + if (!(elf_ex->e_ident[EI_PAX] & EF_PAX_SEGMEXEC))
48400 + pax_flags |= MF_PAX_SEGMEXEC;
48401 +#endif
48402 +
48403 +#ifdef CONFIG_PAX_EMUTRAMP
48404 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) && (elf_ex->e_ident[EI_PAX] & EF_PAX_EMUTRAMP))
48405 + pax_flags |= MF_PAX_EMUTRAMP;
48406 +#endif
48407 +
48408 +#ifdef CONFIG_PAX_MPROTECT
48409 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) && !(elf_ex->e_ident[EI_PAX] & EF_PAX_MPROTECT))
48410 + pax_flags |= MF_PAX_MPROTECT;
48411 +#endif
48412 +
48413 +#ifdef CONFIG_PAX_ASLR
48414 + if (randomize_va_space && !(elf_ex->e_ident[EI_PAX] & EF_PAX_RANDMMAP))
48415 + pax_flags |= MF_PAX_RANDMMAP;
48416 +#endif
48417 +
48418 +#else
48419 +
48420 +#ifdef CONFIG_PAX_PAGEEXEC
48421 + pax_flags |= MF_PAX_PAGEEXEC;
48422 +#endif
48423 +
48424 +#ifdef CONFIG_PAX_SEGMEXEC
48425 + pax_flags |= MF_PAX_SEGMEXEC;
48426 +#endif
48427 +
48428 +#ifdef CONFIG_PAX_MPROTECT
48429 + pax_flags |= MF_PAX_MPROTECT;
48430 +#endif
48431 +
48432 +#ifdef CONFIG_PAX_RANDMMAP
48433 + if (randomize_va_space)
48434 + pax_flags |= MF_PAX_RANDMMAP;
48435 +#endif
48436 +
48437 +#endif
48438 +
48439 + return pax_flags;
48440 +}
48441 +
48442 +static unsigned long pax_parse_pt_pax(const struct elfhdr * const elf_ex, const struct elf_phdr * const elf_phdata)
48443 +{
48444 +
48445 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
48446 + unsigned long i;
48447 +
48448 + for (i = 0UL; i < elf_ex->e_phnum; i++)
48449 + if (elf_phdata[i].p_type == PT_PAX_FLAGS) {
48450 + if (((elf_phdata[i].p_flags & PF_PAGEEXEC) && (elf_phdata[i].p_flags & PF_NOPAGEEXEC)) ||
48451 + ((elf_phdata[i].p_flags & PF_SEGMEXEC) && (elf_phdata[i].p_flags & PF_NOSEGMEXEC)) ||
48452 + ((elf_phdata[i].p_flags & PF_EMUTRAMP) && (elf_phdata[i].p_flags & PF_NOEMUTRAMP)) ||
48453 + ((elf_phdata[i].p_flags & PF_MPROTECT) && (elf_phdata[i].p_flags & PF_NOMPROTECT)) ||
48454 + ((elf_phdata[i].p_flags & PF_RANDMMAP) && (elf_phdata[i].p_flags & PF_NORANDMMAP)))
48455 + return ~0UL;
48456 +
48457 +#ifdef CONFIG_PAX_SOFTMODE
48458 + if (pax_softmode)
48459 + return pax_parse_pt_pax_softmode(&elf_phdata[i]);
48460 + else
48461 +#endif
48462 +
48463 + return pax_parse_pt_pax_hardmode(&elf_phdata[i]);
48464 + break;
48465 + }
48466 +#endif
48467 +
48468 + return ~0UL;
48469 +}
48470 +
48471 +static unsigned long pax_parse_xattr_pax(struct file * const file)
48472 +{
48473 +
48474 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
48475 + ssize_t xattr_size, i;
48476 + unsigned char xattr_value[sizeof("pemrs") - 1];
48477 + unsigned long pax_flags_hardmode = 0UL, pax_flags_softmode = 0UL;
48478 +
48479 + xattr_size = pax_getxattr(file->f_path.dentry, xattr_value, sizeof xattr_value);
48480 + if (xattr_size <= 0 || xattr_size > sizeof xattr_value)
48481 + return ~0UL;
48482 +
48483 + for (i = 0; i < xattr_size; i++)
48484 + switch (xattr_value[i]) {
48485 + default:
48486 + return ~0UL;
48487 +
48488 +#define parse_flag(option1, option2, flag) \
48489 + case option1: \
48490 + if (pax_flags_hardmode & MF_PAX_##flag) \
48491 + return ~0UL; \
48492 + pax_flags_hardmode |= MF_PAX_##flag; \
48493 + break; \
48494 + case option2: \
48495 + if (pax_flags_softmode & MF_PAX_##flag) \
48496 + return ~0UL; \
48497 + pax_flags_softmode |= MF_PAX_##flag; \
48498 + break;
48499 +
48500 + parse_flag('p', 'P', PAGEEXEC);
48501 + parse_flag('e', 'E', EMUTRAMP);
48502 + parse_flag('m', 'M', MPROTECT);
48503 + parse_flag('r', 'R', RANDMMAP);
48504 + parse_flag('s', 'S', SEGMEXEC);
48505 +
48506 +#undef parse_flag
48507 + }
48508 +
48509 + if (pax_flags_hardmode & pax_flags_softmode)
48510 + return ~0UL;
48511 +
48512 +#ifdef CONFIG_PAX_SOFTMODE
48513 + if (pax_softmode)
48514 + return pax_parse_xattr_pax_softmode(pax_flags_softmode);
48515 + else
48516 +#endif
48517 +
48518 + return pax_parse_xattr_pax_hardmode(pax_flags_hardmode);
48519 +#else
48520 + return ~0UL;
48521 +#endif
48522 +
48523 +}
48524 +
48525 +static long pax_parse_pax_flags(const struct elfhdr * const elf_ex, const struct elf_phdr * const elf_phdata, struct file * const file)
48526 +{
48527 + unsigned long pax_flags, pt_pax_flags, xattr_pax_flags;
48528 +
48529 + pax_flags = pax_parse_ei_pax(elf_ex);
48530 + pt_pax_flags = pax_parse_pt_pax(elf_ex, elf_phdata);
48531 + xattr_pax_flags = pax_parse_xattr_pax(file);
48532 +
48533 + if (pt_pax_flags == ~0UL)
48534 + pt_pax_flags = xattr_pax_flags;
48535 + else if (xattr_pax_flags == ~0UL)
48536 + xattr_pax_flags = pt_pax_flags;
48537 + if (pt_pax_flags != xattr_pax_flags)
48538 + return -EINVAL;
48539 + if (pt_pax_flags != ~0UL)
48540 + pax_flags = pt_pax_flags;
48541 +
48542 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_PAX_SEGMEXEC)
48543 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) == (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
48544 + if ((__supported_pte_mask & _PAGE_NX))
48545 + pax_flags &= ~MF_PAX_SEGMEXEC;
48546 + else
48547 + pax_flags &= ~MF_PAX_PAGEEXEC;
48548 + }
48549 +#endif
48550 +
48551 + if (0 > pax_check_flags(&pax_flags))
48552 + return -EINVAL;
48553 +
48554 + current->mm->pax_flags = pax_flags;
48555 + return 0;
48556 +}
48557 +#endif
48558 +
48559 /*
48560 * These are the functions used to load ELF style executables and shared
48561 * libraries. There is no binary dependent code anywhere else.
48562 @@ -551,6 +881,11 @@ static unsigned long randomize_stack_top(unsigned long stack_top)
48563 {
48564 unsigned int random_variable = 0;
48565
48566 +#ifdef CONFIG_PAX_RANDUSTACK
48567 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
48568 + return stack_top - current->mm->delta_stack;
48569 +#endif
48570 +
48571 if ((current->flags & PF_RANDOMIZE) &&
48572 !(current->personality & ADDR_NO_RANDOMIZE)) {
48573 random_variable = get_random_int() & STACK_RND_MASK;
48574 @@ -569,7 +904,7 @@ static int load_elf_binary(struct linux_binprm *bprm)
48575 unsigned long load_addr = 0, load_bias = 0;
48576 int load_addr_set = 0;
48577 char * elf_interpreter = NULL;
48578 - unsigned long error;
48579 + unsigned long error = 0;
48580 struct elf_phdr *elf_ppnt, *elf_phdata;
48581 unsigned long elf_bss, elf_brk;
48582 int retval, i;
48583 @@ -579,12 +914,12 @@ static int load_elf_binary(struct linux_binprm *bprm)
48584 unsigned long start_code, end_code, start_data, end_data;
48585 unsigned long reloc_func_desc __maybe_unused = 0;
48586 int executable_stack = EXSTACK_DEFAULT;
48587 - unsigned long def_flags = 0;
48588 struct pt_regs *regs = current_pt_regs();
48589 struct {
48590 struct elfhdr elf_ex;
48591 struct elfhdr interp_elf_ex;
48592 } *loc;
48593 + unsigned long pax_task_size = TASK_SIZE;
48594
48595 loc = kmalloc(sizeof(*loc), GFP_KERNEL);
48596 if (!loc) {
48597 @@ -720,11 +1055,81 @@ static int load_elf_binary(struct linux_binprm *bprm)
48598 goto out_free_dentry;
48599
48600 /* OK, This is the point of no return */
48601 - current->mm->def_flags = def_flags;
48602 +
48603 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
48604 + current->mm->pax_flags = 0UL;
48605 +#endif
48606 +
48607 +#ifdef CONFIG_PAX_DLRESOLVE
48608 + current->mm->call_dl_resolve = 0UL;
48609 +#endif
48610 +
48611 +#if defined(CONFIG_PPC32) && defined(CONFIG_PAX_EMUSIGRT)
48612 + current->mm->call_syscall = 0UL;
48613 +#endif
48614 +
48615 +#ifdef CONFIG_PAX_ASLR
48616 + current->mm->delta_mmap = 0UL;
48617 + current->mm->delta_stack = 0UL;
48618 +#endif
48619 +
48620 + current->mm->def_flags = 0;
48621 +
48622 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
48623 + if (0 > pax_parse_pax_flags(&loc->elf_ex, elf_phdata, bprm->file)) {
48624 + send_sig(SIGKILL, current, 0);
48625 + goto out_free_dentry;
48626 + }
48627 +#endif
48628 +
48629 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
48630 + pax_set_initial_flags(bprm);
48631 +#elif defined(CONFIG_PAX_HOOK_ACL_FLAGS)
48632 + if (pax_set_initial_flags_func)
48633 + (pax_set_initial_flags_func)(bprm);
48634 +#endif
48635 +
48636 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
48637 + if ((current->mm->pax_flags & MF_PAX_PAGEEXEC) && !(__supported_pte_mask & _PAGE_NX)) {
48638 + current->mm->context.user_cs_limit = PAGE_SIZE;
48639 + current->mm->def_flags |= VM_PAGEEXEC | VM_NOHUGEPAGE;
48640 + }
48641 +#endif
48642 +
48643 +#ifdef CONFIG_PAX_SEGMEXEC
48644 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
48645 + current->mm->context.user_cs_base = SEGMEXEC_TASK_SIZE;
48646 + current->mm->context.user_cs_limit = TASK_SIZE-SEGMEXEC_TASK_SIZE;
48647 + pax_task_size = SEGMEXEC_TASK_SIZE;
48648 + current->mm->def_flags |= VM_NOHUGEPAGE;
48649 + }
48650 +#endif
48651 +
48652 +#if defined(CONFIG_ARCH_TRACK_EXEC_LIMIT) || defined(CONFIG_PAX_SEGMEXEC)
48653 + if (current->mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
48654 + set_user_cs(current->mm->context.user_cs_base, current->mm->context.user_cs_limit, get_cpu());
48655 + put_cpu();
48656 + }
48657 +#endif
48658
48659 /* Do this immediately, since STACK_TOP as used in setup_arg_pages
48660 may depend on the personality. */
48661 SET_PERSONALITY(loc->elf_ex);
48662 +
48663 +#ifdef CONFIG_PAX_ASLR
48664 + if (current->mm->pax_flags & MF_PAX_RANDMMAP) {
48665 + current->mm->delta_mmap = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN)-1)) << PAGE_SHIFT;
48666 + current->mm->delta_stack = (pax_get_random_long() & ((1UL << PAX_DELTA_STACK_LEN)-1)) << PAGE_SHIFT;
48667 + }
48668 +#endif
48669 +
48670 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
48671 + if (current->mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
48672 + executable_stack = EXSTACK_DISABLE_X;
48673 + current->personality &= ~READ_IMPLIES_EXEC;
48674 + } else
48675 +#endif
48676 +
48677 if (elf_read_implies_exec(loc->elf_ex, executable_stack))
48678 current->personality |= READ_IMPLIES_EXEC;
48679
48680 @@ -815,6 +1220,20 @@ static int load_elf_binary(struct linux_binprm *bprm)
48681 #else
48682 load_bias = ELF_PAGESTART(ELF_ET_DYN_BASE - vaddr);
48683 #endif
48684 +
48685 +#ifdef CONFIG_PAX_RANDMMAP
48686 + /* PaX: randomize base address at the default exe base if requested */
48687 + if ((current->mm->pax_flags & MF_PAX_RANDMMAP) && elf_interpreter) {
48688 +#ifdef CONFIG_SPARC64
48689 + load_bias = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN) - 1)) << (PAGE_SHIFT+1);
48690 +#else
48691 + load_bias = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN) - 1)) << PAGE_SHIFT;
48692 +#endif
48693 + load_bias = ELF_PAGESTART(PAX_ELF_ET_DYN_BASE - vaddr + load_bias);
48694 + elf_flags |= MAP_FIXED;
48695 + }
48696 +#endif
48697 +
48698 }
48699
48700 error = elf_map(bprm->file, load_bias + vaddr, elf_ppnt,
48701 @@ -847,9 +1266,9 @@ static int load_elf_binary(struct linux_binprm *bprm)
48702 * allowed task size. Note that p_filesz must always be
48703 * <= p_memsz so it is only necessary to check p_memsz.
48704 */
48705 - if (BAD_ADDR(k) || elf_ppnt->p_filesz > elf_ppnt->p_memsz ||
48706 - elf_ppnt->p_memsz > TASK_SIZE ||
48707 - TASK_SIZE - elf_ppnt->p_memsz < k) {
48708 + if (k >= pax_task_size || elf_ppnt->p_filesz > elf_ppnt->p_memsz ||
48709 + elf_ppnt->p_memsz > pax_task_size ||
48710 + pax_task_size - elf_ppnt->p_memsz < k) {
48711 /* set_brk can never work. Avoid overflows. */
48712 send_sig(SIGKILL, current, 0);
48713 retval = -EINVAL;
48714 @@ -888,17 +1307,45 @@ static int load_elf_binary(struct linux_binprm *bprm)
48715 goto out_free_dentry;
48716 }
48717 if (likely(elf_bss != elf_brk) && unlikely(padzero(elf_bss))) {
48718 - send_sig(SIGSEGV, current, 0);
48719 - retval = -EFAULT; /* Nobody gets to see this, but.. */
48720 - goto out_free_dentry;
48721 + /*
48722 + * This bss-zeroing can fail if the ELF
48723 + * file specifies odd protections. So
48724 + * we don't check the return value
48725 + */
48726 }
48727
48728 +#ifdef CONFIG_PAX_RANDMMAP
48729 + if (current->mm->pax_flags & MF_PAX_RANDMMAP) {
48730 + unsigned long start, size, flags;
48731 + vm_flags_t vm_flags;
48732 +
48733 + start = ELF_PAGEALIGN(elf_brk);
48734 + size = PAGE_SIZE + ((pax_get_random_long() & ((1UL << 22) - 1UL)) << 4);
48735 + flags = MAP_FIXED | MAP_PRIVATE;
48736 + vm_flags = VM_DONTEXPAND | VM_DONTDUMP;
48737 +
48738 + down_write(&current->mm->mmap_sem);
48739 + start = get_unmapped_area(NULL, start, PAGE_ALIGN(size), 0, flags);
48740 + retval = -ENOMEM;
48741 + if (!IS_ERR_VALUE(start) && !find_vma_intersection(current->mm, start, start + size + PAGE_SIZE)) {
48742 +// if (current->personality & ADDR_NO_RANDOMIZE)
48743 +// vm_flags |= VM_READ | VM_MAYREAD;
48744 + start = mmap_region(NULL, start, PAGE_ALIGN(size), vm_flags, 0);
48745 + retval = IS_ERR_VALUE(start) ? start : 0;
48746 + }
48747 + up_write(&current->mm->mmap_sem);
48748 + if (retval == 0)
48749 + retval = set_brk(start + size, start + size + PAGE_SIZE);
48750 + if (retval < 0) {
48751 + send_sig(SIGKILL, current, 0);
48752 + goto out_free_dentry;
48753 + }
48754 + }
48755 +#endif
48756 +
48757 if (elf_interpreter) {
48758 - unsigned long interp_map_addr = 0;
48759 -
48760 elf_entry = load_elf_interp(&loc->interp_elf_ex,
48761 interpreter,
48762 - &interp_map_addr,
48763 load_bias);
48764 if (!IS_ERR((void *)elf_entry)) {
48765 /*
48766 @@ -1120,7 +1567,7 @@ static bool always_dump_vma(struct vm_area_struct *vma)
48767 * Decide what to dump of a segment, part, all or none.
48768 */
48769 static unsigned long vma_dump_size(struct vm_area_struct *vma,
48770 - unsigned long mm_flags)
48771 + unsigned long mm_flags, long signr)
48772 {
48773 #define FILTER(type) (mm_flags & (1UL << MMF_DUMP_##type))
48774
48775 @@ -1158,7 +1605,7 @@ static unsigned long vma_dump_size(struct vm_area_struct *vma,
48776 if (vma->vm_file == NULL)
48777 return 0;
48778
48779 - if (FILTER(MAPPED_PRIVATE))
48780 + if (signr == SIGKILL || FILTER(MAPPED_PRIVATE))
48781 goto whole;
48782
48783 /*
48784 @@ -1383,9 +1830,9 @@ static void fill_auxv_note(struct memelfnote *note, struct mm_struct *mm)
48785 {
48786 elf_addr_t *auxv = (elf_addr_t *) mm->saved_auxv;
48787 int i = 0;
48788 - do
48789 + do {
48790 i += 2;
48791 - while (auxv[i - 2] != AT_NULL);
48792 + } while (auxv[i - 2] != AT_NULL);
48793 fill_note(note, "CORE", NT_AUXV, i * sizeof(elf_addr_t), auxv);
48794 }
48795
48796 @@ -1394,7 +1841,7 @@ static void fill_siginfo_note(struct memelfnote *note, user_siginfo_t *csigdata,
48797 {
48798 mm_segment_t old_fs = get_fs();
48799 set_fs(KERNEL_DS);
48800 - copy_siginfo_to_user((user_siginfo_t __user *) csigdata, siginfo);
48801 + copy_siginfo_to_user((user_siginfo_t __force_user *) csigdata, siginfo);
48802 set_fs(old_fs);
48803 fill_note(note, "CORE", NT_SIGINFO, sizeof(*csigdata), csigdata);
48804 }
48805 @@ -2015,14 +2462,14 @@ static void fill_extnum_info(struct elfhdr *elf, struct elf_shdr *shdr4extnum,
48806 }
48807
48808 static size_t elf_core_vma_data_size(struct vm_area_struct *gate_vma,
48809 - unsigned long mm_flags)
48810 + struct coredump_params *cprm)
48811 {
48812 struct vm_area_struct *vma;
48813 size_t size = 0;
48814
48815 for (vma = first_vma(current, gate_vma); vma != NULL;
48816 vma = next_vma(vma, gate_vma))
48817 - size += vma_dump_size(vma, mm_flags);
48818 + size += vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
48819 return size;
48820 }
48821
48822 @@ -2116,7 +2563,7 @@ static int elf_core_dump(struct coredump_params *cprm)
48823
48824 dataoff = offset = roundup(offset, ELF_EXEC_PAGESIZE);
48825
48826 - offset += elf_core_vma_data_size(gate_vma, cprm->mm_flags);
48827 + offset += elf_core_vma_data_size(gate_vma, cprm);
48828 offset += elf_core_extra_data_size();
48829 e_shoff = offset;
48830
48831 @@ -2130,10 +2577,12 @@ static int elf_core_dump(struct coredump_params *cprm)
48832 offset = dataoff;
48833
48834 size += sizeof(*elf);
48835 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
48836 if (size > cprm->limit || !dump_write(cprm->file, elf, sizeof(*elf)))
48837 goto end_coredump;
48838
48839 size += sizeof(*phdr4note);
48840 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
48841 if (size > cprm->limit
48842 || !dump_write(cprm->file, phdr4note, sizeof(*phdr4note)))
48843 goto end_coredump;
48844 @@ -2147,7 +2596,7 @@ static int elf_core_dump(struct coredump_params *cprm)
48845 phdr.p_offset = offset;
48846 phdr.p_vaddr = vma->vm_start;
48847 phdr.p_paddr = 0;
48848 - phdr.p_filesz = vma_dump_size(vma, cprm->mm_flags);
48849 + phdr.p_filesz = vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
48850 phdr.p_memsz = vma->vm_end - vma->vm_start;
48851 offset += phdr.p_filesz;
48852 phdr.p_flags = vma->vm_flags & VM_READ ? PF_R : 0;
48853 @@ -2158,6 +2607,7 @@ static int elf_core_dump(struct coredump_params *cprm)
48854 phdr.p_align = ELF_EXEC_PAGESIZE;
48855
48856 size += sizeof(phdr);
48857 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
48858 if (size > cprm->limit
48859 || !dump_write(cprm->file, &phdr, sizeof(phdr)))
48860 goto end_coredump;
48861 @@ -2182,7 +2632,7 @@ static int elf_core_dump(struct coredump_params *cprm)
48862 unsigned long addr;
48863 unsigned long end;
48864
48865 - end = vma->vm_start + vma_dump_size(vma, cprm->mm_flags);
48866 + end = vma->vm_start + vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
48867
48868 for (addr = vma->vm_start; addr < end; addr += PAGE_SIZE) {
48869 struct page *page;
48870 @@ -2191,6 +2641,7 @@ static int elf_core_dump(struct coredump_params *cprm)
48871 page = get_dump_page(addr);
48872 if (page) {
48873 void *kaddr = kmap(page);
48874 + gr_learn_resource(current, RLIMIT_CORE, size + PAGE_SIZE, 1);
48875 stop = ((size += PAGE_SIZE) > cprm->limit) ||
48876 !dump_write(cprm->file, kaddr,
48877 PAGE_SIZE);
48878 @@ -2208,6 +2659,7 @@ static int elf_core_dump(struct coredump_params *cprm)
48879
48880 if (e_phnum == PN_XNUM) {
48881 size += sizeof(*shdr4extnum);
48882 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
48883 if (size > cprm->limit
48884 || !dump_write(cprm->file, shdr4extnum,
48885 sizeof(*shdr4extnum)))
48886 @@ -2228,6 +2680,97 @@ out:
48887
48888 #endif /* CONFIG_ELF_CORE */
48889
48890 +#ifdef CONFIG_PAX_MPROTECT
48891 +/* PaX: non-PIC ELF libraries need relocations on their executable segments
48892 + * therefore we'll grant them VM_MAYWRITE once during their life. Similarly
48893 + * we'll remove VM_MAYWRITE for good on RELRO segments.
48894 + *
48895 + * The checks favour ld-linux.so behaviour which operates on a per ELF segment
48896 + * basis because we want to allow the common case and not the special ones.
48897 + */
48898 +static void elf_handle_mprotect(struct vm_area_struct *vma, unsigned long newflags)
48899 +{
48900 + struct elfhdr elf_h;
48901 + struct elf_phdr elf_p;
48902 + unsigned long i;
48903 + unsigned long oldflags;
48904 + bool is_textrel_rw, is_textrel_rx, is_relro;
48905 +
48906 + if (!(vma->vm_mm->pax_flags & MF_PAX_MPROTECT))
48907 + return;
48908 +
48909 + oldflags = vma->vm_flags & (VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_EXEC | VM_WRITE | VM_READ);
48910 + newflags &= VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_EXEC | VM_WRITE | VM_READ;
48911 +
48912 +#ifdef CONFIG_PAX_ELFRELOCS
48913 + /* possible TEXTREL */
48914 + is_textrel_rw = vma->vm_file && !vma->anon_vma && oldflags == (VM_MAYEXEC | VM_MAYREAD | VM_EXEC | VM_READ) && newflags == (VM_WRITE | VM_READ);
48915 + 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);
48916 +#else
48917 + is_textrel_rw = false;
48918 + is_textrel_rx = false;
48919 +#endif
48920 +
48921 + /* possible RELRO */
48922 + is_relro = vma->vm_file && vma->anon_vma && oldflags == (VM_MAYWRITE | VM_MAYREAD | VM_READ) && newflags == (VM_MAYWRITE | VM_MAYREAD | VM_READ);
48923 +
48924 + if (!is_textrel_rw && !is_textrel_rx && !is_relro)
48925 + return;
48926 +
48927 + if (sizeof(elf_h) != kernel_read(vma->vm_file, 0UL, (char *)&elf_h, sizeof(elf_h)) ||
48928 + memcmp(elf_h.e_ident, ELFMAG, SELFMAG) ||
48929 +
48930 +#ifdef CONFIG_PAX_ETEXECRELOCS
48931 + ((is_textrel_rw || is_textrel_rx) && (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC)) ||
48932 +#else
48933 + ((is_textrel_rw || is_textrel_rx) && elf_h.e_type != ET_DYN) ||
48934 +#endif
48935 +
48936 + (is_relro && (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC)) ||
48937 + !elf_check_arch(&elf_h) ||
48938 + elf_h.e_phentsize != sizeof(struct elf_phdr) ||
48939 + elf_h.e_phnum > 65536UL / sizeof(struct elf_phdr))
48940 + return;
48941 +
48942 + for (i = 0UL; i < elf_h.e_phnum; i++) {
48943 + if (sizeof(elf_p) != kernel_read(vma->vm_file, elf_h.e_phoff + i*sizeof(elf_p), (char *)&elf_p, sizeof(elf_p)))
48944 + return;
48945 + switch (elf_p.p_type) {
48946 + case PT_DYNAMIC:
48947 + if (!is_textrel_rw && !is_textrel_rx)
48948 + continue;
48949 + i = 0UL;
48950 + while ((i+1) * sizeof(elf_dyn) <= elf_p.p_filesz) {
48951 + elf_dyn dyn;
48952 +
48953 + if (sizeof(dyn) != kernel_read(vma->vm_file, elf_p.p_offset + i*sizeof(dyn), (char *)&dyn, sizeof(dyn)))
48954 + return;
48955 + if (dyn.d_tag == DT_NULL)
48956 + return;
48957 + if (dyn.d_tag == DT_TEXTREL || (dyn.d_tag == DT_FLAGS && (dyn.d_un.d_val & DF_TEXTREL))) {
48958 + gr_log_textrel(vma);
48959 + if (is_textrel_rw)
48960 + vma->vm_flags |= VM_MAYWRITE;
48961 + else
48962 + /* PaX: disallow write access after relocs are done, hopefully noone else needs it... */
48963 + vma->vm_flags &= ~VM_MAYWRITE;
48964 + return;
48965 + }
48966 + i++;
48967 + }
48968 + return;
48969 +
48970 + case PT_GNU_RELRO:
48971 + if (!is_relro)
48972 + continue;
48973 + if ((elf_p.p_offset >> PAGE_SHIFT) == vma->vm_pgoff && ELF_PAGEALIGN(elf_p.p_memsz) == vma->vm_end - vma->vm_start)
48974 + vma->vm_flags &= ~VM_MAYWRITE;
48975 + return;
48976 + }
48977 + }
48978 +}
48979 +#endif
48980 +
48981 static int __init init_elf_binfmt(void)
48982 {
48983 register_binfmt(&elf_format);
48984 diff --git a/fs/binfmt_flat.c b/fs/binfmt_flat.c
48985 index 2036d21..b0430d0 100644
48986 --- a/fs/binfmt_flat.c
48987 +++ b/fs/binfmt_flat.c
48988 @@ -562,7 +562,9 @@ static int load_flat_file(struct linux_binprm * bprm,
48989 realdatastart = (unsigned long) -ENOMEM;
48990 printk("Unable to allocate RAM for process data, errno %d\n",
48991 (int)-realdatastart);
48992 + down_write(&current->mm->mmap_sem);
48993 vm_munmap(textpos, text_len);
48994 + up_write(&current->mm->mmap_sem);
48995 ret = realdatastart;
48996 goto err;
48997 }
48998 @@ -586,8 +588,10 @@ static int load_flat_file(struct linux_binprm * bprm,
48999 }
49000 if (IS_ERR_VALUE(result)) {
49001 printk("Unable to read data+bss, errno %d\n", (int)-result);
49002 + down_write(&current->mm->mmap_sem);
49003 vm_munmap(textpos, text_len);
49004 vm_munmap(realdatastart, len);
49005 + up_write(&current->mm->mmap_sem);
49006 ret = result;
49007 goto err;
49008 }
49009 @@ -654,8 +658,10 @@ static int load_flat_file(struct linux_binprm * bprm,
49010 }
49011 if (IS_ERR_VALUE(result)) {
49012 printk("Unable to read code+data+bss, errno %d\n",(int)-result);
49013 + down_write(&current->mm->mmap_sem);
49014 vm_munmap(textpos, text_len + data_len + extra +
49015 MAX_SHARED_LIBS * sizeof(unsigned long));
49016 + up_write(&current->mm->mmap_sem);
49017 ret = result;
49018 goto err;
49019 }
49020 diff --git a/fs/bio.c b/fs/bio.c
49021 index b96fc6c..431d628 100644
49022 --- a/fs/bio.c
49023 +++ b/fs/bio.c
49024 @@ -818,7 +818,7 @@ struct bio *bio_copy_user_iov(struct request_queue *q,
49025 /*
49026 * Overflow, abort
49027 */
49028 - if (end < start)
49029 + if (end < start || end - start > INT_MAX - nr_pages)
49030 return ERR_PTR(-EINVAL);
49031
49032 nr_pages += end - start;
49033 @@ -952,7 +952,7 @@ static struct bio *__bio_map_user_iov(struct request_queue *q,
49034 /*
49035 * Overflow, abort
49036 */
49037 - if (end < start)
49038 + if (end < start || end - start > INT_MAX - nr_pages)
49039 return ERR_PTR(-EINVAL);
49040
49041 nr_pages += end - start;
49042 @@ -1214,7 +1214,7 @@ static void bio_copy_kern_endio(struct bio *bio, int err)
49043 const int read = bio_data_dir(bio) == READ;
49044 struct bio_map_data *bmd = bio->bi_private;
49045 int i;
49046 - char *p = bmd->sgvecs[0].iov_base;
49047 + char *p = (char __force_kernel *)bmd->sgvecs[0].iov_base;
49048
49049 __bio_for_each_segment(bvec, bio, i, 0) {
49050 char *addr = page_address(bvec->bv_page);
49051 diff --git a/fs/block_dev.c b/fs/block_dev.c
49052 index aae187a..fd790ba 100644
49053 --- a/fs/block_dev.c
49054 +++ b/fs/block_dev.c
49055 @@ -652,7 +652,7 @@ static bool bd_may_claim(struct block_device *bdev, struct block_device *whole,
49056 else if (bdev->bd_contains == bdev)
49057 return true; /* is a whole device which isn't held */
49058
49059 - else if (whole->bd_holder == bd_may_claim)
49060 + else if (whole->bd_holder == (void *)bd_may_claim)
49061 return true; /* is a partition of a device that is being partitioned */
49062 else if (whole->bd_holder != NULL)
49063 return false; /* is a partition of a held device */
49064 diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
49065 index ca9d8f1..8c0142d 100644
49066 --- a/fs/btrfs/ctree.c
49067 +++ b/fs/btrfs/ctree.c
49068 @@ -1036,9 +1036,12 @@ static noinline int __btrfs_cow_block(struct btrfs_trans_handle *trans,
49069 free_extent_buffer(buf);
49070 add_root_to_dirty_list(root);
49071 } else {
49072 - if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID)
49073 - parent_start = parent->start;
49074 - else
49075 + if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID) {
49076 + if (parent)
49077 + parent_start = parent->start;
49078 + else
49079 + parent_start = 0;
49080 + } else
49081 parent_start = 0;
49082
49083 WARN_ON(trans->transid != btrfs_header_generation(parent));
49084 diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
49085 index f49b62f..07834ab 100644
49086 --- a/fs/btrfs/ioctl.c
49087 +++ b/fs/btrfs/ioctl.c
49088 @@ -3077,9 +3077,12 @@ long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg)
49089 for (i = 0; i < num_types; i++) {
49090 struct btrfs_space_info *tmp;
49091
49092 + /* Don't copy in more than we allocated */
49093 if (!slot_count)
49094 break;
49095
49096 + slot_count--;
49097 +
49098 info = NULL;
49099 rcu_read_lock();
49100 list_for_each_entry_rcu(tmp, &root->fs_info->space_info,
49101 @@ -3101,10 +3104,7 @@ long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg)
49102 memcpy(dest, &space, sizeof(space));
49103 dest++;
49104 space_args.total_spaces++;
49105 - slot_count--;
49106 }
49107 - if (!slot_count)
49108 - break;
49109 }
49110 up_read(&info->groups_sem);
49111 }
49112 diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
49113 index f6b8859..54fe8c5 100644
49114 --- a/fs/btrfs/super.c
49115 +++ b/fs/btrfs/super.c
49116 @@ -266,7 +266,7 @@ void __btrfs_abort_transaction(struct btrfs_trans_handle *trans,
49117 function, line, errstr);
49118 return;
49119 }
49120 - ACCESS_ONCE(trans->transaction->aborted) = errno;
49121 + ACCESS_ONCE_RW(trans->transaction->aborted) = errno;
49122 __btrfs_std_error(root->fs_info, function, line, errno, NULL);
49123 }
49124 /*
49125 diff --git a/fs/cachefiles/bind.c b/fs/cachefiles/bind.c
49126 index 622f469..e8d2d55 100644
49127 --- a/fs/cachefiles/bind.c
49128 +++ b/fs/cachefiles/bind.c
49129 @@ -39,13 +39,11 @@ int cachefiles_daemon_bind(struct cachefiles_cache *cache, char *args)
49130 args);
49131
49132 /* start by checking things over */
49133 - ASSERT(cache->fstop_percent >= 0 &&
49134 - cache->fstop_percent < cache->fcull_percent &&
49135 + ASSERT(cache->fstop_percent < cache->fcull_percent &&
49136 cache->fcull_percent < cache->frun_percent &&
49137 cache->frun_percent < 100);
49138
49139 - ASSERT(cache->bstop_percent >= 0 &&
49140 - cache->bstop_percent < cache->bcull_percent &&
49141 + ASSERT(cache->bstop_percent < cache->bcull_percent &&
49142 cache->bcull_percent < cache->brun_percent &&
49143 cache->brun_percent < 100);
49144
49145 diff --git a/fs/cachefiles/daemon.c b/fs/cachefiles/daemon.c
49146 index 0a1467b..6a53245 100644
49147 --- a/fs/cachefiles/daemon.c
49148 +++ b/fs/cachefiles/daemon.c
49149 @@ -196,7 +196,7 @@ static ssize_t cachefiles_daemon_read(struct file *file, char __user *_buffer,
49150 if (n > buflen)
49151 return -EMSGSIZE;
49152
49153 - if (copy_to_user(_buffer, buffer, n) != 0)
49154 + if (n > sizeof(buffer) || copy_to_user(_buffer, buffer, n) != 0)
49155 return -EFAULT;
49156
49157 return n;
49158 @@ -222,7 +222,7 @@ static ssize_t cachefiles_daemon_write(struct file *file,
49159 if (test_bit(CACHEFILES_DEAD, &cache->flags))
49160 return -EIO;
49161
49162 - if (datalen < 0 || datalen > PAGE_SIZE - 1)
49163 + if (datalen > PAGE_SIZE - 1)
49164 return -EOPNOTSUPP;
49165
49166 /* drag the command string into the kernel so we can parse it */
49167 @@ -386,7 +386,7 @@ static int cachefiles_daemon_fstop(struct cachefiles_cache *cache, char *args)
49168 if (args[0] != '%' || args[1] != '\0')
49169 return -EINVAL;
49170
49171 - if (fstop < 0 || fstop >= cache->fcull_percent)
49172 + if (fstop >= cache->fcull_percent)
49173 return cachefiles_daemon_range_error(cache, args);
49174
49175 cache->fstop_percent = fstop;
49176 @@ -458,7 +458,7 @@ static int cachefiles_daemon_bstop(struct cachefiles_cache *cache, char *args)
49177 if (args[0] != '%' || args[1] != '\0')
49178 return -EINVAL;
49179
49180 - if (bstop < 0 || bstop >= cache->bcull_percent)
49181 + if (bstop >= cache->bcull_percent)
49182 return cachefiles_daemon_range_error(cache, args);
49183
49184 cache->bstop_percent = bstop;
49185 diff --git a/fs/cachefiles/internal.h b/fs/cachefiles/internal.h
49186 index 4938251..7e01445 100644
49187 --- a/fs/cachefiles/internal.h
49188 +++ b/fs/cachefiles/internal.h
49189 @@ -59,7 +59,7 @@ struct cachefiles_cache {
49190 wait_queue_head_t daemon_pollwq; /* poll waitqueue for daemon */
49191 struct rb_root active_nodes; /* active nodes (can't be culled) */
49192 rwlock_t active_lock; /* lock for active_nodes */
49193 - atomic_t gravecounter; /* graveyard uniquifier */
49194 + atomic_unchecked_t gravecounter; /* graveyard uniquifier */
49195 unsigned frun_percent; /* when to stop culling (% files) */
49196 unsigned fcull_percent; /* when to start culling (% files) */
49197 unsigned fstop_percent; /* when to stop allocating (% files) */
49198 @@ -171,19 +171,19 @@ extern int cachefiles_check_in_use(struct cachefiles_cache *cache,
49199 * proc.c
49200 */
49201 #ifdef CONFIG_CACHEFILES_HISTOGRAM
49202 -extern atomic_t cachefiles_lookup_histogram[HZ];
49203 -extern atomic_t cachefiles_mkdir_histogram[HZ];
49204 -extern atomic_t cachefiles_create_histogram[HZ];
49205 +extern atomic_unchecked_t cachefiles_lookup_histogram[HZ];
49206 +extern atomic_unchecked_t cachefiles_mkdir_histogram[HZ];
49207 +extern atomic_unchecked_t cachefiles_create_histogram[HZ];
49208
49209 extern int __init cachefiles_proc_init(void);
49210 extern void cachefiles_proc_cleanup(void);
49211 static inline
49212 -void cachefiles_hist(atomic_t histogram[], unsigned long start_jif)
49213 +void cachefiles_hist(atomic_unchecked_t histogram[], unsigned long start_jif)
49214 {
49215 unsigned long jif = jiffies - start_jif;
49216 if (jif >= HZ)
49217 jif = HZ - 1;
49218 - atomic_inc(&histogram[jif]);
49219 + atomic_inc_unchecked(&histogram[jif]);
49220 }
49221
49222 #else
49223 diff --git a/fs/cachefiles/namei.c b/fs/cachefiles/namei.c
49224 index 8c01c5fc..15f982e 100644
49225 --- a/fs/cachefiles/namei.c
49226 +++ b/fs/cachefiles/namei.c
49227 @@ -317,7 +317,7 @@ try_again:
49228 /* first step is to make up a grave dentry in the graveyard */
49229 sprintf(nbuffer, "%08x%08x",
49230 (uint32_t) get_seconds(),
49231 - (uint32_t) atomic_inc_return(&cache->gravecounter));
49232 + (uint32_t) atomic_inc_return_unchecked(&cache->gravecounter));
49233
49234 /* do the multiway lock magic */
49235 trap = lock_rename(cache->graveyard, dir);
49236 diff --git a/fs/cachefiles/proc.c b/fs/cachefiles/proc.c
49237 index eccd339..4c1d995 100644
49238 --- a/fs/cachefiles/proc.c
49239 +++ b/fs/cachefiles/proc.c
49240 @@ -14,9 +14,9 @@
49241 #include <linux/seq_file.h>
49242 #include "internal.h"
49243
49244 -atomic_t cachefiles_lookup_histogram[HZ];
49245 -atomic_t cachefiles_mkdir_histogram[HZ];
49246 -atomic_t cachefiles_create_histogram[HZ];
49247 +atomic_unchecked_t cachefiles_lookup_histogram[HZ];
49248 +atomic_unchecked_t cachefiles_mkdir_histogram[HZ];
49249 +atomic_unchecked_t cachefiles_create_histogram[HZ];
49250
49251 /*
49252 * display the latency histogram
49253 @@ -35,9 +35,9 @@ static int cachefiles_histogram_show(struct seq_file *m, void *v)
49254 return 0;
49255 default:
49256 index = (unsigned long) v - 3;
49257 - x = atomic_read(&cachefiles_lookup_histogram[index]);
49258 - y = atomic_read(&cachefiles_mkdir_histogram[index]);
49259 - z = atomic_read(&cachefiles_create_histogram[index]);
49260 + x = atomic_read_unchecked(&cachefiles_lookup_histogram[index]);
49261 + y = atomic_read_unchecked(&cachefiles_mkdir_histogram[index]);
49262 + z = atomic_read_unchecked(&cachefiles_create_histogram[index]);
49263 if (x == 0 && y == 0 && z == 0)
49264 return 0;
49265
49266 diff --git a/fs/cachefiles/rdwr.c b/fs/cachefiles/rdwr.c
49267 index 4809922..aab2c39 100644
49268 --- a/fs/cachefiles/rdwr.c
49269 +++ b/fs/cachefiles/rdwr.c
49270 @@ -965,7 +965,7 @@ int cachefiles_write_page(struct fscache_storage *op, struct page *page)
49271 old_fs = get_fs();
49272 set_fs(KERNEL_DS);
49273 ret = file->f_op->write(
49274 - file, (const void __user *) data, len, &pos);
49275 + file, (const void __force_user *) data, len, &pos);
49276 set_fs(old_fs);
49277 kunmap(page);
49278 if (ret != len)
49279 diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c
49280 index 6d797f4..0ace2e5 100644
49281 --- a/fs/ceph/dir.c
49282 +++ b/fs/ceph/dir.c
49283 @@ -243,7 +243,7 @@ static int ceph_readdir(struct file *filp, void *dirent, filldir_t filldir)
49284 struct ceph_fs_client *fsc = ceph_inode_to_client(inode);
49285 struct ceph_mds_client *mdsc = fsc->mdsc;
49286 unsigned frag = fpos_frag(filp->f_pos);
49287 - int off = fpos_off(filp->f_pos);
49288 + unsigned int off = fpos_off(filp->f_pos);
49289 int err;
49290 u32 ftype;
49291 struct ceph_mds_reply_info_parsed *rinfo;
49292 diff --git a/fs/cifs/cifs_debug.c b/fs/cifs/cifs_debug.c
49293 index d9ea6ed..1e6c8ac 100644
49294 --- a/fs/cifs/cifs_debug.c
49295 +++ b/fs/cifs/cifs_debug.c
49296 @@ -267,8 +267,8 @@ static ssize_t cifs_stats_proc_write(struct file *file,
49297
49298 if (c == '1' || c == 'y' || c == 'Y' || c == '0') {
49299 #ifdef CONFIG_CIFS_STATS2
49300 - atomic_set(&totBufAllocCount, 0);
49301 - atomic_set(&totSmBufAllocCount, 0);
49302 + atomic_set_unchecked(&totBufAllocCount, 0);
49303 + atomic_set_unchecked(&totSmBufAllocCount, 0);
49304 #endif /* CONFIG_CIFS_STATS2 */
49305 spin_lock(&cifs_tcp_ses_lock);
49306 list_for_each(tmp1, &cifs_tcp_ses_list) {
49307 @@ -281,7 +281,7 @@ static ssize_t cifs_stats_proc_write(struct file *file,
49308 tcon = list_entry(tmp3,
49309 struct cifs_tcon,
49310 tcon_list);
49311 - atomic_set(&tcon->num_smbs_sent, 0);
49312 + atomic_set_unchecked(&tcon->num_smbs_sent, 0);
49313 if (server->ops->clear_stats)
49314 server->ops->clear_stats(tcon);
49315 }
49316 @@ -313,8 +313,8 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
49317 smBufAllocCount.counter, cifs_min_small);
49318 #ifdef CONFIG_CIFS_STATS2
49319 seq_printf(m, "Total Large %d Small %d Allocations\n",
49320 - atomic_read(&totBufAllocCount),
49321 - atomic_read(&totSmBufAllocCount));
49322 + atomic_read_unchecked(&totBufAllocCount),
49323 + atomic_read_unchecked(&totSmBufAllocCount));
49324 #endif /* CONFIG_CIFS_STATS2 */
49325
49326 seq_printf(m, "Operations (MIDs): %d\n", atomic_read(&midCount));
49327 @@ -343,7 +343,7 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
49328 if (tcon->need_reconnect)
49329 seq_puts(m, "\tDISCONNECTED ");
49330 seq_printf(m, "\nSMBs: %d",
49331 - atomic_read(&tcon->num_smbs_sent));
49332 + atomic_read_unchecked(&tcon->num_smbs_sent));
49333 if (server->ops->print_stats)
49334 server->ops->print_stats(m, tcon);
49335 }
49336 diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
49337 index 345fc89..b2acae5 100644
49338 --- a/fs/cifs/cifsfs.c
49339 +++ b/fs/cifs/cifsfs.c
49340 @@ -1033,7 +1033,7 @@ cifs_init_request_bufs(void)
49341 /* cERROR(1, "CIFSMaxBufSize %d 0x%x",CIFSMaxBufSize,CIFSMaxBufSize); */
49342 cifs_req_cachep = kmem_cache_create("cifs_request",
49343 CIFSMaxBufSize + max_hdr_size, 0,
49344 - SLAB_HWCACHE_ALIGN, NULL);
49345 + SLAB_HWCACHE_ALIGN | SLAB_USERCOPY, NULL);
49346 if (cifs_req_cachep == NULL)
49347 return -ENOMEM;
49348
49349 @@ -1060,7 +1060,7 @@ cifs_init_request_bufs(void)
49350 efficient to alloc 1 per page off the slab compared to 17K (5page)
49351 alloc of large cifs buffers even when page debugging is on */
49352 cifs_sm_req_cachep = kmem_cache_create("cifs_small_rq",
49353 - MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN,
49354 + MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN | SLAB_USERCOPY,
49355 NULL);
49356 if (cifs_sm_req_cachep == NULL) {
49357 mempool_destroy(cifs_req_poolp);
49358 @@ -1145,8 +1145,8 @@ init_cifs(void)
49359 atomic_set(&bufAllocCount, 0);
49360 atomic_set(&smBufAllocCount, 0);
49361 #ifdef CONFIG_CIFS_STATS2
49362 - atomic_set(&totBufAllocCount, 0);
49363 - atomic_set(&totSmBufAllocCount, 0);
49364 + atomic_set_unchecked(&totBufAllocCount, 0);
49365 + atomic_set_unchecked(&totSmBufAllocCount, 0);
49366 #endif /* CONFIG_CIFS_STATS2 */
49367
49368 atomic_set(&midCount, 0);
49369 diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
49370 index 4f07f6f..55de8ce 100644
49371 --- a/fs/cifs/cifsglob.h
49372 +++ b/fs/cifs/cifsglob.h
49373 @@ -751,35 +751,35 @@ struct cifs_tcon {
49374 __u16 Flags; /* optional support bits */
49375 enum statusEnum tidStatus;
49376 #ifdef CONFIG_CIFS_STATS
49377 - atomic_t num_smbs_sent;
49378 + atomic_unchecked_t num_smbs_sent;
49379 union {
49380 struct {
49381 - atomic_t num_writes;
49382 - atomic_t num_reads;
49383 - atomic_t num_flushes;
49384 - atomic_t num_oplock_brks;
49385 - atomic_t num_opens;
49386 - atomic_t num_closes;
49387 - atomic_t num_deletes;
49388 - atomic_t num_mkdirs;
49389 - atomic_t num_posixopens;
49390 - atomic_t num_posixmkdirs;
49391 - atomic_t num_rmdirs;
49392 - atomic_t num_renames;
49393 - atomic_t num_t2renames;
49394 - atomic_t num_ffirst;
49395 - atomic_t num_fnext;
49396 - atomic_t num_fclose;
49397 - atomic_t num_hardlinks;
49398 - atomic_t num_symlinks;
49399 - atomic_t num_locks;
49400 - atomic_t num_acl_get;
49401 - atomic_t num_acl_set;
49402 + atomic_unchecked_t num_writes;
49403 + atomic_unchecked_t num_reads;
49404 + atomic_unchecked_t num_flushes;
49405 + atomic_unchecked_t num_oplock_brks;
49406 + atomic_unchecked_t num_opens;
49407 + atomic_unchecked_t num_closes;
49408 + atomic_unchecked_t num_deletes;
49409 + atomic_unchecked_t num_mkdirs;
49410 + atomic_unchecked_t num_posixopens;
49411 + atomic_unchecked_t num_posixmkdirs;
49412 + atomic_unchecked_t num_rmdirs;
49413 + atomic_unchecked_t num_renames;
49414 + atomic_unchecked_t num_t2renames;
49415 + atomic_unchecked_t num_ffirst;
49416 + atomic_unchecked_t num_fnext;
49417 + atomic_unchecked_t num_fclose;
49418 + atomic_unchecked_t num_hardlinks;
49419 + atomic_unchecked_t num_symlinks;
49420 + atomic_unchecked_t num_locks;
49421 + atomic_unchecked_t num_acl_get;
49422 + atomic_unchecked_t num_acl_set;
49423 } cifs_stats;
49424 #ifdef CONFIG_CIFS_SMB2
49425 struct {
49426 - atomic_t smb2_com_sent[NUMBER_OF_SMB2_COMMANDS];
49427 - atomic_t smb2_com_failed[NUMBER_OF_SMB2_COMMANDS];
49428 + atomic_unchecked_t smb2_com_sent[NUMBER_OF_SMB2_COMMANDS];
49429 + atomic_unchecked_t smb2_com_failed[NUMBER_OF_SMB2_COMMANDS];
49430 } smb2_stats;
49431 #endif /* CONFIG_CIFS_SMB2 */
49432 } stats;
49433 @@ -1080,7 +1080,7 @@ convert_delimiter(char *path, char delim)
49434 }
49435
49436 #ifdef CONFIG_CIFS_STATS
49437 -#define cifs_stats_inc atomic_inc
49438 +#define cifs_stats_inc atomic_inc_unchecked
49439
49440 static inline void cifs_stats_bytes_written(struct cifs_tcon *tcon,
49441 unsigned int bytes)
49442 @@ -1445,8 +1445,8 @@ GLOBAL_EXTERN atomic_t tconInfoReconnectCount;
49443 /* Various Debug counters */
49444 GLOBAL_EXTERN atomic_t bufAllocCount; /* current number allocated */
49445 #ifdef CONFIG_CIFS_STATS2
49446 -GLOBAL_EXTERN atomic_t totBufAllocCount; /* total allocated over all time */
49447 -GLOBAL_EXTERN atomic_t totSmBufAllocCount;
49448 +GLOBAL_EXTERN atomic_unchecked_t totBufAllocCount; /* total allocated over all time */
49449 +GLOBAL_EXTERN atomic_unchecked_t totSmBufAllocCount;
49450 #endif
49451 GLOBAL_EXTERN atomic_t smBufAllocCount;
49452 GLOBAL_EXTERN atomic_t midCount;
49453 diff --git a/fs/cifs/link.c b/fs/cifs/link.c
49454 index 9f6c4c4..8de307a 100644
49455 --- a/fs/cifs/link.c
49456 +++ b/fs/cifs/link.c
49457 @@ -616,7 +616,7 @@ symlink_exit:
49458
49459 void cifs_put_link(struct dentry *direntry, struct nameidata *nd, void *cookie)
49460 {
49461 - char *p = nd_get_link(nd);
49462 + const char *p = nd_get_link(nd);
49463 if (!IS_ERR(p))
49464 kfree(p);
49465 }
49466 diff --git a/fs/cifs/misc.c b/fs/cifs/misc.c
49467 index 1b15bf8..1ce489e 100644
49468 --- a/fs/cifs/misc.c
49469 +++ b/fs/cifs/misc.c
49470 @@ -169,7 +169,7 @@ cifs_buf_get(void)
49471 memset(ret_buf, 0, buf_size + 3);
49472 atomic_inc(&bufAllocCount);
49473 #ifdef CONFIG_CIFS_STATS2
49474 - atomic_inc(&totBufAllocCount);
49475 + atomic_inc_unchecked(&totBufAllocCount);
49476 #endif /* CONFIG_CIFS_STATS2 */
49477 }
49478
49479 @@ -204,7 +204,7 @@ cifs_small_buf_get(void)
49480 /* memset(ret_buf, 0, sizeof(struct smb_hdr) + 27);*/
49481 atomic_inc(&smBufAllocCount);
49482 #ifdef CONFIG_CIFS_STATS2
49483 - atomic_inc(&totSmBufAllocCount);
49484 + atomic_inc_unchecked(&totSmBufAllocCount);
49485 #endif /* CONFIG_CIFS_STATS2 */
49486
49487 }
49488 diff --git a/fs/cifs/smb1ops.c b/fs/cifs/smb1ops.c
49489 index 47bc5a8..10decbe 100644
49490 --- a/fs/cifs/smb1ops.c
49491 +++ b/fs/cifs/smb1ops.c
49492 @@ -586,27 +586,27 @@ static void
49493 cifs_clear_stats(struct cifs_tcon *tcon)
49494 {
49495 #ifdef CONFIG_CIFS_STATS
49496 - atomic_set(&tcon->stats.cifs_stats.num_writes, 0);
49497 - atomic_set(&tcon->stats.cifs_stats.num_reads, 0);
49498 - atomic_set(&tcon->stats.cifs_stats.num_flushes, 0);
49499 - atomic_set(&tcon->stats.cifs_stats.num_oplock_brks, 0);
49500 - atomic_set(&tcon->stats.cifs_stats.num_opens, 0);
49501 - atomic_set(&tcon->stats.cifs_stats.num_posixopens, 0);
49502 - atomic_set(&tcon->stats.cifs_stats.num_posixmkdirs, 0);
49503 - atomic_set(&tcon->stats.cifs_stats.num_closes, 0);
49504 - atomic_set(&tcon->stats.cifs_stats.num_deletes, 0);
49505 - atomic_set(&tcon->stats.cifs_stats.num_mkdirs, 0);
49506 - atomic_set(&tcon->stats.cifs_stats.num_rmdirs, 0);
49507 - atomic_set(&tcon->stats.cifs_stats.num_renames, 0);
49508 - atomic_set(&tcon->stats.cifs_stats.num_t2renames, 0);
49509 - atomic_set(&tcon->stats.cifs_stats.num_ffirst, 0);
49510 - atomic_set(&tcon->stats.cifs_stats.num_fnext, 0);
49511 - atomic_set(&tcon->stats.cifs_stats.num_fclose, 0);
49512 - atomic_set(&tcon->stats.cifs_stats.num_hardlinks, 0);
49513 - atomic_set(&tcon->stats.cifs_stats.num_symlinks, 0);
49514 - atomic_set(&tcon->stats.cifs_stats.num_locks, 0);
49515 - atomic_set(&tcon->stats.cifs_stats.num_acl_get, 0);
49516 - atomic_set(&tcon->stats.cifs_stats.num_acl_set, 0);
49517 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_writes, 0);
49518 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_reads, 0);
49519 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_flushes, 0);
49520 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_oplock_brks, 0);
49521 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_opens, 0);
49522 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_posixopens, 0);
49523 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_posixmkdirs, 0);
49524 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_closes, 0);
49525 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_deletes, 0);
49526 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_mkdirs, 0);
49527 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_rmdirs, 0);
49528 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_renames, 0);
49529 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_t2renames, 0);
49530 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_ffirst, 0);
49531 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_fnext, 0);
49532 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_fclose, 0);
49533 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_hardlinks, 0);
49534 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_symlinks, 0);
49535 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_locks, 0);
49536 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_acl_get, 0);
49537 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_acl_set, 0);
49538 #endif
49539 }
49540
49541 @@ -615,36 +615,36 @@ cifs_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
49542 {
49543 #ifdef CONFIG_CIFS_STATS
49544 seq_printf(m, " Oplocks breaks: %d",
49545 - atomic_read(&tcon->stats.cifs_stats.num_oplock_brks));
49546 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_oplock_brks));
49547 seq_printf(m, "\nReads: %d Bytes: %llu",
49548 - atomic_read(&tcon->stats.cifs_stats.num_reads),
49549 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_reads),
49550 (long long)(tcon->bytes_read));
49551 seq_printf(m, "\nWrites: %d Bytes: %llu",
49552 - atomic_read(&tcon->stats.cifs_stats.num_writes),
49553 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_writes),
49554 (long long)(tcon->bytes_written));
49555 seq_printf(m, "\nFlushes: %d",
49556 - atomic_read(&tcon->stats.cifs_stats.num_flushes));
49557 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_flushes));
49558 seq_printf(m, "\nLocks: %d HardLinks: %d Symlinks: %d",
49559 - atomic_read(&tcon->stats.cifs_stats.num_locks),
49560 - atomic_read(&tcon->stats.cifs_stats.num_hardlinks),
49561 - atomic_read(&tcon->stats.cifs_stats.num_symlinks));
49562 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_locks),
49563 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_hardlinks),
49564 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_symlinks));
49565 seq_printf(m, "\nOpens: %d Closes: %d Deletes: %d",
49566 - atomic_read(&tcon->stats.cifs_stats.num_opens),
49567 - atomic_read(&tcon->stats.cifs_stats.num_closes),
49568 - atomic_read(&tcon->stats.cifs_stats.num_deletes));
49569 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_opens),
49570 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_closes),
49571 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_deletes));
49572 seq_printf(m, "\nPosix Opens: %d Posix Mkdirs: %d",
49573 - atomic_read(&tcon->stats.cifs_stats.num_posixopens),
49574 - atomic_read(&tcon->stats.cifs_stats.num_posixmkdirs));
49575 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_posixopens),
49576 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_posixmkdirs));
49577 seq_printf(m, "\nMkdirs: %d Rmdirs: %d",
49578 - atomic_read(&tcon->stats.cifs_stats.num_mkdirs),
49579 - atomic_read(&tcon->stats.cifs_stats.num_rmdirs));
49580 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_mkdirs),
49581 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_rmdirs));
49582 seq_printf(m, "\nRenames: %d T2 Renames %d",
49583 - atomic_read(&tcon->stats.cifs_stats.num_renames),
49584 - atomic_read(&tcon->stats.cifs_stats.num_t2renames));
49585 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_renames),
49586 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_t2renames));
49587 seq_printf(m, "\nFindFirst: %d FNext %d FClose %d",
49588 - atomic_read(&tcon->stats.cifs_stats.num_ffirst),
49589 - atomic_read(&tcon->stats.cifs_stats.num_fnext),
49590 - atomic_read(&tcon->stats.cifs_stats.num_fclose));
49591 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_ffirst),
49592 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_fnext),
49593 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_fclose));
49594 #endif
49595 }
49596
49597 diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
49598 index bceffe7..cd1ae59 100644
49599 --- a/fs/cifs/smb2ops.c
49600 +++ b/fs/cifs/smb2ops.c
49601 @@ -274,8 +274,8 @@ smb2_clear_stats(struct cifs_tcon *tcon)
49602 #ifdef CONFIG_CIFS_STATS
49603 int i;
49604 for (i = 0; i < NUMBER_OF_SMB2_COMMANDS; i++) {
49605 - atomic_set(&tcon->stats.smb2_stats.smb2_com_sent[i], 0);
49606 - atomic_set(&tcon->stats.smb2_stats.smb2_com_failed[i], 0);
49607 + atomic_set_unchecked(&tcon->stats.smb2_stats.smb2_com_sent[i], 0);
49608 + atomic_set_unchecked(&tcon->stats.smb2_stats.smb2_com_failed[i], 0);
49609 }
49610 #endif
49611 }
49612 @@ -284,66 +284,66 @@ static void
49613 smb2_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
49614 {
49615 #ifdef CONFIG_CIFS_STATS
49616 - atomic_t *sent = tcon->stats.smb2_stats.smb2_com_sent;
49617 - atomic_t *failed = tcon->stats.smb2_stats.smb2_com_failed;
49618 + atomic_unchecked_t *sent = tcon->stats.smb2_stats.smb2_com_sent;
49619 + atomic_unchecked_t *failed = tcon->stats.smb2_stats.smb2_com_failed;
49620 seq_printf(m, "\nNegotiates: %d sent %d failed",
49621 - atomic_read(&sent[SMB2_NEGOTIATE_HE]),
49622 - atomic_read(&failed[SMB2_NEGOTIATE_HE]));
49623 + atomic_read_unchecked(&sent[SMB2_NEGOTIATE_HE]),
49624 + atomic_read_unchecked(&failed[SMB2_NEGOTIATE_HE]));
49625 seq_printf(m, "\nSessionSetups: %d sent %d failed",
49626 - atomic_read(&sent[SMB2_SESSION_SETUP_HE]),
49627 - atomic_read(&failed[SMB2_SESSION_SETUP_HE]));
49628 + atomic_read_unchecked(&sent[SMB2_SESSION_SETUP_HE]),
49629 + atomic_read_unchecked(&failed[SMB2_SESSION_SETUP_HE]));
49630 #define SMB2LOGOFF 0x0002 /* trivial request/resp */
49631 seq_printf(m, "\nLogoffs: %d sent %d failed",
49632 - atomic_read(&sent[SMB2_LOGOFF_HE]),
49633 - atomic_read(&failed[SMB2_LOGOFF_HE]));
49634 + atomic_read_unchecked(&sent[SMB2_LOGOFF_HE]),
49635 + atomic_read_unchecked(&failed[SMB2_LOGOFF_HE]));
49636 seq_printf(m, "\nTreeConnects: %d sent %d failed",
49637 - atomic_read(&sent[SMB2_TREE_CONNECT_HE]),
49638 - atomic_read(&failed[SMB2_TREE_CONNECT_HE]));
49639 + atomic_read_unchecked(&sent[SMB2_TREE_CONNECT_HE]),
49640 + atomic_read_unchecked(&failed[SMB2_TREE_CONNECT_HE]));
49641 seq_printf(m, "\nTreeDisconnects: %d sent %d failed",
49642 - atomic_read(&sent[SMB2_TREE_DISCONNECT_HE]),
49643 - atomic_read(&failed[SMB2_TREE_DISCONNECT_HE]));
49644 + atomic_read_unchecked(&sent[SMB2_TREE_DISCONNECT_HE]),
49645 + atomic_read_unchecked(&failed[SMB2_TREE_DISCONNECT_HE]));
49646 seq_printf(m, "\nCreates: %d sent %d failed",
49647 - atomic_read(&sent[SMB2_CREATE_HE]),
49648 - atomic_read(&failed[SMB2_CREATE_HE]));
49649 + atomic_read_unchecked(&sent[SMB2_CREATE_HE]),
49650 + atomic_read_unchecked(&failed[SMB2_CREATE_HE]));
49651 seq_printf(m, "\nCloses: %d sent %d failed",
49652 - atomic_read(&sent[SMB2_CLOSE_HE]),
49653 - atomic_read(&failed[SMB2_CLOSE_HE]));
49654 + atomic_read_unchecked(&sent[SMB2_CLOSE_HE]),
49655 + atomic_read_unchecked(&failed[SMB2_CLOSE_HE]));
49656 seq_printf(m, "\nFlushes: %d sent %d failed",
49657 - atomic_read(&sent[SMB2_FLUSH_HE]),
49658 - atomic_read(&failed[SMB2_FLUSH_HE]));
49659 + atomic_read_unchecked(&sent[SMB2_FLUSH_HE]),
49660 + atomic_read_unchecked(&failed[SMB2_FLUSH_HE]));
49661 seq_printf(m, "\nReads: %d sent %d failed",
49662 - atomic_read(&sent[SMB2_READ_HE]),
49663 - atomic_read(&failed[SMB2_READ_HE]));
49664 + atomic_read_unchecked(&sent[SMB2_READ_HE]),
49665 + atomic_read_unchecked(&failed[SMB2_READ_HE]));
49666 seq_printf(m, "\nWrites: %d sent %d failed",
49667 - atomic_read(&sent[SMB2_WRITE_HE]),
49668 - atomic_read(&failed[SMB2_WRITE_HE]));
49669 + atomic_read_unchecked(&sent[SMB2_WRITE_HE]),
49670 + atomic_read_unchecked(&failed[SMB2_WRITE_HE]));
49671 seq_printf(m, "\nLocks: %d sent %d failed",
49672 - atomic_read(&sent[SMB2_LOCK_HE]),
49673 - atomic_read(&failed[SMB2_LOCK_HE]));
49674 + atomic_read_unchecked(&sent[SMB2_LOCK_HE]),
49675 + atomic_read_unchecked(&failed[SMB2_LOCK_HE]));
49676 seq_printf(m, "\nIOCTLs: %d sent %d failed",
49677 - atomic_read(&sent[SMB2_IOCTL_HE]),
49678 - atomic_read(&failed[SMB2_IOCTL_HE]));
49679 + atomic_read_unchecked(&sent[SMB2_IOCTL_HE]),
49680 + atomic_read_unchecked(&failed[SMB2_IOCTL_HE]));
49681 seq_printf(m, "\nCancels: %d sent %d failed",
49682 - atomic_read(&sent[SMB2_CANCEL_HE]),
49683 - atomic_read(&failed[SMB2_CANCEL_HE]));
49684 + atomic_read_unchecked(&sent[SMB2_CANCEL_HE]),
49685 + atomic_read_unchecked(&failed[SMB2_CANCEL_HE]));
49686 seq_printf(m, "\nEchos: %d sent %d failed",
49687 - atomic_read(&sent[SMB2_ECHO_HE]),
49688 - atomic_read(&failed[SMB2_ECHO_HE]));
49689 + atomic_read_unchecked(&sent[SMB2_ECHO_HE]),
49690 + atomic_read_unchecked(&failed[SMB2_ECHO_HE]));
49691 seq_printf(m, "\nQueryDirectories: %d sent %d failed",
49692 - atomic_read(&sent[SMB2_QUERY_DIRECTORY_HE]),
49693 - atomic_read(&failed[SMB2_QUERY_DIRECTORY_HE]));
49694 + atomic_read_unchecked(&sent[SMB2_QUERY_DIRECTORY_HE]),
49695 + atomic_read_unchecked(&failed[SMB2_QUERY_DIRECTORY_HE]));
49696 seq_printf(m, "\nChangeNotifies: %d sent %d failed",
49697 - atomic_read(&sent[SMB2_CHANGE_NOTIFY_HE]),
49698 - atomic_read(&failed[SMB2_CHANGE_NOTIFY_HE]));
49699 + atomic_read_unchecked(&sent[SMB2_CHANGE_NOTIFY_HE]),
49700 + atomic_read_unchecked(&failed[SMB2_CHANGE_NOTIFY_HE]));
49701 seq_printf(m, "\nQueryInfos: %d sent %d failed",
49702 - atomic_read(&sent[SMB2_QUERY_INFO_HE]),
49703 - atomic_read(&failed[SMB2_QUERY_INFO_HE]));
49704 + atomic_read_unchecked(&sent[SMB2_QUERY_INFO_HE]),
49705 + atomic_read_unchecked(&failed[SMB2_QUERY_INFO_HE]));
49706 seq_printf(m, "\nSetInfos: %d sent %d failed",
49707 - atomic_read(&sent[SMB2_SET_INFO_HE]),
49708 - atomic_read(&failed[SMB2_SET_INFO_HE]));
49709 + atomic_read_unchecked(&sent[SMB2_SET_INFO_HE]),
49710 + atomic_read_unchecked(&failed[SMB2_SET_INFO_HE]));
49711 seq_printf(m, "\nOplockBreaks: %d sent %d failed",
49712 - atomic_read(&sent[SMB2_OPLOCK_BREAK_HE]),
49713 - atomic_read(&failed[SMB2_OPLOCK_BREAK_HE]));
49714 + atomic_read_unchecked(&sent[SMB2_OPLOCK_BREAK_HE]),
49715 + atomic_read_unchecked(&failed[SMB2_OPLOCK_BREAK_HE]));
49716 #endif
49717 }
49718
49719 diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
49720 index 41d9d07..dbb4772 100644
49721 --- a/fs/cifs/smb2pdu.c
49722 +++ b/fs/cifs/smb2pdu.c
49723 @@ -1761,8 +1761,7 @@ SMB2_query_directory(const unsigned int xid, struct cifs_tcon *tcon,
49724 default:
49725 cERROR(1, "info level %u isn't supported",
49726 srch_inf->info_level);
49727 - rc = -EINVAL;
49728 - goto qdir_exit;
49729 + return -EINVAL;
49730 }
49731
49732 req->FileIndex = cpu_to_le32(index);
49733 diff --git a/fs/coda/cache.c b/fs/coda/cache.c
49734 index 1da168c..8bc7ff6 100644
49735 --- a/fs/coda/cache.c
49736 +++ b/fs/coda/cache.c
49737 @@ -24,7 +24,7 @@
49738 #include "coda_linux.h"
49739 #include "coda_cache.h"
49740
49741 -static atomic_t permission_epoch = ATOMIC_INIT(0);
49742 +static atomic_unchecked_t permission_epoch = ATOMIC_INIT(0);
49743
49744 /* replace or extend an acl cache hit */
49745 void coda_cache_enter(struct inode *inode, int mask)
49746 @@ -32,7 +32,7 @@ void coda_cache_enter(struct inode *inode, int mask)
49747 struct coda_inode_info *cii = ITOC(inode);
49748
49749 spin_lock(&cii->c_lock);
49750 - cii->c_cached_epoch = atomic_read(&permission_epoch);
49751 + cii->c_cached_epoch = atomic_read_unchecked(&permission_epoch);
49752 if (!uid_eq(cii->c_uid, current_fsuid())) {
49753 cii->c_uid = current_fsuid();
49754 cii->c_cached_perm = mask;
49755 @@ -46,14 +46,14 @@ void coda_cache_clear_inode(struct inode *inode)
49756 {
49757 struct coda_inode_info *cii = ITOC(inode);
49758 spin_lock(&cii->c_lock);
49759 - cii->c_cached_epoch = atomic_read(&permission_epoch) - 1;
49760 + cii->c_cached_epoch = atomic_read_unchecked(&permission_epoch) - 1;
49761 spin_unlock(&cii->c_lock);
49762 }
49763
49764 /* remove all acl caches */
49765 void coda_cache_clear_all(struct super_block *sb)
49766 {
49767 - atomic_inc(&permission_epoch);
49768 + atomic_inc_unchecked(&permission_epoch);
49769 }
49770
49771
49772 @@ -66,7 +66,7 @@ int coda_cache_check(struct inode *inode, int mask)
49773 spin_lock(&cii->c_lock);
49774 hit = (mask & cii->c_cached_perm) == mask &&
49775 uid_eq(cii->c_uid, current_fsuid()) &&
49776 - cii->c_cached_epoch == atomic_read(&permission_epoch);
49777 + cii->c_cached_epoch == atomic_read_unchecked(&permission_epoch);
49778 spin_unlock(&cii->c_lock);
49779
49780 return hit;
49781 diff --git a/fs/compat.c b/fs/compat.c
49782 index d487985..c9e04b1 100644
49783 --- a/fs/compat.c
49784 +++ b/fs/compat.c
49785 @@ -54,7 +54,7 @@
49786 #include <asm/ioctls.h>
49787 #include "internal.h"
49788
49789 -int compat_log = 1;
49790 +int compat_log = 0;
49791
49792 int compat_printk(const char *fmt, ...)
49793 {
49794 @@ -490,7 +490,7 @@ compat_sys_io_setup(unsigned nr_reqs, u32 __user *ctx32p)
49795
49796 set_fs(KERNEL_DS);
49797 /* The __user pointer cast is valid because of the set_fs() */
49798 - ret = sys_io_setup(nr_reqs, (aio_context_t __user *) &ctx64);
49799 + ret = sys_io_setup(nr_reqs, (aio_context_t __force_user *) &ctx64);
49800 set_fs(oldfs);
49801 /* truncating is ok because it's a user address */
49802 if (!ret)
49803 @@ -548,7 +548,7 @@ ssize_t compat_rw_copy_check_uvector(int type,
49804 goto out;
49805
49806 ret = -EINVAL;
49807 - if (nr_segs > UIO_MAXIOV || nr_segs < 0)
49808 + if (nr_segs > UIO_MAXIOV)
49809 goto out;
49810 if (nr_segs > fast_segs) {
49811 ret = -ENOMEM;
49812 @@ -835,6 +835,7 @@ struct compat_old_linux_dirent {
49813
49814 struct compat_readdir_callback {
49815 struct compat_old_linux_dirent __user *dirent;
49816 + struct file * file;
49817 int result;
49818 };
49819
49820 @@ -852,6 +853,10 @@ static int compat_fillonedir(void *__buf, const char *name, int namlen,
49821 buf->result = -EOVERFLOW;
49822 return -EOVERFLOW;
49823 }
49824 +
49825 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
49826 + return 0;
49827 +
49828 buf->result++;
49829 dirent = buf->dirent;
49830 if (!access_ok(VERIFY_WRITE, dirent,
49831 @@ -882,6 +887,7 @@ asmlinkage long compat_sys_old_readdir(unsigned int fd,
49832
49833 buf.result = 0;
49834 buf.dirent = dirent;
49835 + buf.file = f.file;
49836
49837 error = vfs_readdir(f.file, compat_fillonedir, &buf);
49838 if (buf.result)
49839 @@ -901,6 +907,7 @@ struct compat_linux_dirent {
49840 struct compat_getdents_callback {
49841 struct compat_linux_dirent __user *current_dir;
49842 struct compat_linux_dirent __user *previous;
49843 + struct file * file;
49844 int count;
49845 int error;
49846 };
49847 @@ -922,6 +929,10 @@ static int compat_filldir(void *__buf, const char *name, int namlen,
49848 buf->error = -EOVERFLOW;
49849 return -EOVERFLOW;
49850 }
49851 +
49852 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
49853 + return 0;
49854 +
49855 dirent = buf->previous;
49856 if (dirent) {
49857 if (__put_user(offset, &dirent->d_off))
49858 @@ -967,6 +978,7 @@ asmlinkage long compat_sys_getdents(unsigned int fd,
49859 buf.previous = NULL;
49860 buf.count = count;
49861 buf.error = 0;
49862 + buf.file = f.file;
49863
49864 error = vfs_readdir(f.file, compat_filldir, &buf);
49865 if (error >= 0)
49866 @@ -987,6 +999,7 @@ asmlinkage long compat_sys_getdents(unsigned int fd,
49867 struct compat_getdents_callback64 {
49868 struct linux_dirent64 __user *current_dir;
49869 struct linux_dirent64 __user *previous;
49870 + struct file * file;
49871 int count;
49872 int error;
49873 };
49874 @@ -1003,6 +1016,10 @@ static int compat_filldir64(void * __buf, const char * name, int namlen, loff_t
49875 buf->error = -EINVAL; /* only used if we fail.. */
49876 if (reclen > buf->count)
49877 return -EINVAL;
49878 +
49879 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
49880 + return 0;
49881 +
49882 dirent = buf->previous;
49883
49884 if (dirent) {
49885 @@ -1052,13 +1069,14 @@ asmlinkage long compat_sys_getdents64(unsigned int fd,
49886 buf.previous = NULL;
49887 buf.count = count;
49888 buf.error = 0;
49889 + buf.file = f.file;
49890
49891 error = vfs_readdir(f.file, compat_filldir64, &buf);
49892 if (error >= 0)
49893 error = buf.error;
49894 lastdirent = buf.previous;
49895 if (lastdirent) {
49896 - typeof(lastdirent->d_off) d_off = f.file->f_pos;
49897 + typeof(((struct linux_dirent64 *)0)->d_off) d_off = f.file->f_pos;
49898 if (__put_user_unaligned(d_off, &lastdirent->d_off))
49899 error = -EFAULT;
49900 else
49901 diff --git a/fs/compat_binfmt_elf.c b/fs/compat_binfmt_elf.c
49902 index a81147e..20bf2b5 100644
49903 --- a/fs/compat_binfmt_elf.c
49904 +++ b/fs/compat_binfmt_elf.c
49905 @@ -30,11 +30,13 @@
49906 #undef elf_phdr
49907 #undef elf_shdr
49908 #undef elf_note
49909 +#undef elf_dyn
49910 #undef elf_addr_t
49911 #define elfhdr elf32_hdr
49912 #define elf_phdr elf32_phdr
49913 #define elf_shdr elf32_shdr
49914 #define elf_note elf32_note
49915 +#define elf_dyn Elf32_Dyn
49916 #define elf_addr_t Elf32_Addr
49917
49918 /*
49919 diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
49920 index 3ced75f..b28d192 100644
49921 --- a/fs/compat_ioctl.c
49922 +++ b/fs/compat_ioctl.c
49923 @@ -623,7 +623,7 @@ static int serial_struct_ioctl(unsigned fd, unsigned cmd,
49924 return -EFAULT;
49925 if (__get_user(udata, &ss32->iomem_base))
49926 return -EFAULT;
49927 - ss.iomem_base = compat_ptr(udata);
49928 + ss.iomem_base = (unsigned char __force_kernel *)compat_ptr(udata);
49929 if (__get_user(ss.iomem_reg_shift, &ss32->iomem_reg_shift) ||
49930 __get_user(ss.port_high, &ss32->port_high))
49931 return -EFAULT;
49932 @@ -704,8 +704,8 @@ static int do_i2c_rdwr_ioctl(unsigned int fd, unsigned int cmd,
49933 for (i = 0; i < nmsgs; i++) {
49934 if (copy_in_user(&tmsgs[i].addr, &umsgs[i].addr, 3*sizeof(u16)))
49935 return -EFAULT;
49936 - if (get_user(datap, &umsgs[i].buf) ||
49937 - put_user(compat_ptr(datap), &tmsgs[i].buf))
49938 + if (get_user(datap, (u8 __user * __user *)&umsgs[i].buf) ||
49939 + put_user(compat_ptr(datap), (u8 __user * __user *)&tmsgs[i].buf))
49940 return -EFAULT;
49941 }
49942 return sys_ioctl(fd, cmd, (unsigned long)tdata);
49943 @@ -798,7 +798,7 @@ static int compat_ioctl_preallocate(struct file *file,
49944 copy_in_user(&p->l_len, &p32->l_len, sizeof(s64)) ||
49945 copy_in_user(&p->l_sysid, &p32->l_sysid, sizeof(s32)) ||
49946 copy_in_user(&p->l_pid, &p32->l_pid, sizeof(u32)) ||
49947 - copy_in_user(&p->l_pad, &p32->l_pad, 4*sizeof(u32)))
49948 + copy_in_user(p->l_pad, &p32->l_pad, 4*sizeof(u32)))
49949 return -EFAULT;
49950
49951 return ioctl_preallocate(file, p);
49952 @@ -1620,8 +1620,8 @@ asmlinkage long compat_sys_ioctl(unsigned int fd, unsigned int cmd,
49953 static int __init init_sys32_ioctl_cmp(const void *p, const void *q)
49954 {
49955 unsigned int a, b;
49956 - a = *(unsigned int *)p;
49957 - b = *(unsigned int *)q;
49958 + a = *(const unsigned int *)p;
49959 + b = *(const unsigned int *)q;
49960 if (a > b)
49961 return 1;
49962 if (a < b)
49963 diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c
49964 index 7aabc6a..34c1197 100644
49965 --- a/fs/configfs/dir.c
49966 +++ b/fs/configfs/dir.c
49967 @@ -1565,7 +1565,8 @@ static int configfs_readdir(struct file * filp, void * dirent, filldir_t filldir
49968 }
49969 for (p=q->next; p!= &parent_sd->s_children; p=p->next) {
49970 struct configfs_dirent *next;
49971 - const char * name;
49972 + const unsigned char * name;
49973 + char d_name[sizeof(next->s_dentry->d_iname)];
49974 int len;
49975 struct inode *inode = NULL;
49976
49977 @@ -1575,7 +1576,12 @@ static int configfs_readdir(struct file * filp, void * dirent, filldir_t filldir
49978 continue;
49979
49980 name = configfs_get_name(next);
49981 - len = strlen(name);
49982 + if (next->s_dentry && name == next->s_dentry->d_iname) {
49983 + len = next->s_dentry->d_name.len;
49984 + memcpy(d_name, name, len);
49985 + name = d_name;
49986 + } else
49987 + len = strlen(name);
49988
49989 /*
49990 * We'll have a dentry and an inode for
49991 diff --git a/fs/coredump.c b/fs/coredump.c
49992 index c647965..a77bff3 100644
49993 --- a/fs/coredump.c
49994 +++ b/fs/coredump.c
49995 @@ -52,7 +52,7 @@ struct core_name {
49996 char *corename;
49997 int used, size;
49998 };
49999 -static atomic_t call_count = ATOMIC_INIT(1);
50000 +static atomic_unchecked_t call_count = ATOMIC_INIT(1);
50001
50002 /* The maximal length of core_pattern is also specified in sysctl.c */
50003
50004 @@ -60,7 +60,7 @@ static int expand_corename(struct core_name *cn)
50005 {
50006 char *old_corename = cn->corename;
50007
50008 - cn->size = CORENAME_MAX_SIZE * atomic_inc_return(&call_count);
50009 + cn->size = CORENAME_MAX_SIZE * atomic_inc_return_unchecked(&call_count);
50010 cn->corename = krealloc(old_corename, cn->size, GFP_KERNEL);
50011
50012 if (!cn->corename) {
50013 @@ -157,7 +157,7 @@ static int format_corename(struct core_name *cn, struct coredump_params *cprm)
50014 int pid_in_pattern = 0;
50015 int err = 0;
50016
50017 - cn->size = CORENAME_MAX_SIZE * atomic_read(&call_count);
50018 + cn->size = CORENAME_MAX_SIZE * atomic_read_unchecked(&call_count);
50019 cn->corename = kmalloc(cn->size, GFP_KERNEL);
50020 cn->used = 0;
50021
50022 @@ -414,17 +414,17 @@ static void wait_for_dump_helpers(struct file *file)
50023 pipe = file_inode(file)->i_pipe;
50024
50025 pipe_lock(pipe);
50026 - pipe->readers++;
50027 - pipe->writers--;
50028 + atomic_inc(&pipe->readers);
50029 + atomic_dec(&pipe->writers);
50030
50031 - while ((pipe->readers > 1) && (!signal_pending(current))) {
50032 + while ((atomic_read(&pipe->readers) > 1) && (!signal_pending(current))) {
50033 wake_up_interruptible_sync(&pipe->wait);
50034 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
50035 pipe_wait(pipe);
50036 }
50037
50038 - pipe->readers--;
50039 - pipe->writers++;
50040 + atomic_dec(&pipe->readers);
50041 + atomic_inc(&pipe->writers);
50042 pipe_unlock(pipe);
50043
50044 }
50045 @@ -471,7 +471,8 @@ void do_coredump(siginfo_t *siginfo)
50046 int ispipe;
50047 struct files_struct *displaced;
50048 bool need_nonrelative = false;
50049 - static atomic_t core_dump_count = ATOMIC_INIT(0);
50050 + static atomic_unchecked_t core_dump_count = ATOMIC_INIT(0);
50051 + long signr = siginfo->si_signo;
50052 struct coredump_params cprm = {
50053 .siginfo = siginfo,
50054 .regs = signal_pt_regs(),
50055 @@ -484,7 +485,10 @@ void do_coredump(siginfo_t *siginfo)
50056 .mm_flags = mm->flags,
50057 };
50058
50059 - audit_core_dumps(siginfo->si_signo);
50060 + audit_core_dumps(signr);
50061 +
50062 + if (signr == SIGSEGV || signr == SIGBUS || signr == SIGKILL || signr == SIGILL)
50063 + gr_handle_brute_attach(cprm.mm_flags);
50064
50065 binfmt = mm->binfmt;
50066 if (!binfmt || !binfmt->core_dump)
50067 @@ -508,7 +512,7 @@ void do_coredump(siginfo_t *siginfo)
50068 need_nonrelative = true;
50069 }
50070
50071 - retval = coredump_wait(siginfo->si_signo, &core_state);
50072 + retval = coredump_wait(signr, &core_state);
50073 if (retval < 0)
50074 goto fail_creds;
50075
50076 @@ -556,7 +560,7 @@ void do_coredump(siginfo_t *siginfo)
50077 }
50078 cprm.limit = RLIM_INFINITY;
50079
50080 - dump_count = atomic_inc_return(&core_dump_count);
50081 + dump_count = atomic_inc_return_unchecked(&core_dump_count);
50082 if (core_pipe_limit && (core_pipe_limit < dump_count)) {
50083 printk(KERN_WARNING "Pid %d(%s) over core_pipe_limit\n",
50084 task_tgid_vnr(current), current->comm);
50085 @@ -583,6 +587,8 @@ void do_coredump(siginfo_t *siginfo)
50086 } else {
50087 struct inode *inode;
50088
50089 + gr_learn_resource(current, RLIMIT_CORE, binfmt->min_coredump, 1);
50090 +
50091 if (cprm.limit < binfmt->min_coredump)
50092 goto fail_unlock;
50093
50094 @@ -640,7 +646,7 @@ close_fail:
50095 filp_close(cprm.file, NULL);
50096 fail_dropcount:
50097 if (ispipe)
50098 - atomic_dec(&core_dump_count);
50099 + atomic_dec_unchecked(&core_dump_count);
50100 fail_unlock:
50101 kfree(cn.corename);
50102 fail_corename:
50103 @@ -659,7 +665,7 @@ fail:
50104 */
50105 int dump_write(struct file *file, const void *addr, int nr)
50106 {
50107 - return access_ok(VERIFY_READ, addr, nr) && file->f_op->write(file, addr, nr, &file->f_pos) == nr;
50108 + return access_ok(VERIFY_READ, addr, nr) && file->f_op->write(file, (const char __force_user *)addr, nr, &file->f_pos) == nr;
50109 }
50110 EXPORT_SYMBOL(dump_write);
50111
50112 diff --git a/fs/dcache.c b/fs/dcache.c
50113 index e689268..f36956e 100644
50114 --- a/fs/dcache.c
50115 +++ b/fs/dcache.c
50116 @@ -3100,7 +3100,7 @@ void __init vfs_caches_init(unsigned long mempages)
50117 mempages -= reserve;
50118
50119 names_cachep = kmem_cache_create("names_cache", PATH_MAX, 0,
50120 - SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
50121 + SLAB_HWCACHE_ALIGN|SLAB_PANIC|SLAB_USERCOPY, NULL);
50122
50123 dcache_init();
50124 inode_init();
50125 diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
50126 index 4888cb3..e0f7cf8 100644
50127 --- a/fs/debugfs/inode.c
50128 +++ b/fs/debugfs/inode.c
50129 @@ -415,7 +415,11 @@ EXPORT_SYMBOL_GPL(debugfs_create_file);
50130 */
50131 struct dentry *debugfs_create_dir(const char *name, struct dentry *parent)
50132 {
50133 +#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
50134 + return __create_file(name, S_IFDIR | S_IRWXU,
50135 +#else
50136 return __create_file(name, S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO,
50137 +#endif
50138 parent, NULL, NULL);
50139 }
50140 EXPORT_SYMBOL_GPL(debugfs_create_dir);
50141 diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
50142 index 5eab400..810a3f5 100644
50143 --- a/fs/ecryptfs/inode.c
50144 +++ b/fs/ecryptfs/inode.c
50145 @@ -674,7 +674,7 @@ static int ecryptfs_readlink_lower(struct dentry *dentry, char **buf,
50146 old_fs = get_fs();
50147 set_fs(get_ds());
50148 rc = lower_dentry->d_inode->i_op->readlink(lower_dentry,
50149 - (char __user *)lower_buf,
50150 + (char __force_user *)lower_buf,
50151 PATH_MAX);
50152 set_fs(old_fs);
50153 if (rc < 0)
50154 @@ -706,7 +706,7 @@ out:
50155 static void
50156 ecryptfs_put_link(struct dentry *dentry, struct nameidata *nd, void *ptr)
50157 {
50158 - char *buf = nd_get_link(nd);
50159 + const char *buf = nd_get_link(nd);
50160 if (!IS_ERR(buf)) {
50161 /* Free the char* */
50162 kfree(buf);
50163 diff --git a/fs/ecryptfs/miscdev.c b/fs/ecryptfs/miscdev.c
50164 index e4141f2..d8263e8 100644
50165 --- a/fs/ecryptfs/miscdev.c
50166 +++ b/fs/ecryptfs/miscdev.c
50167 @@ -304,7 +304,7 @@ check_list:
50168 goto out_unlock_msg_ctx;
50169 i = PKT_TYPE_SIZE + PKT_CTR_SIZE;
50170 if (msg_ctx->msg) {
50171 - if (copy_to_user(&buf[i], packet_length, packet_length_size))
50172 + if (packet_length_size > sizeof(packet_length) || copy_to_user(&buf[i], packet_length, packet_length_size))
50173 goto out_unlock_msg_ctx;
50174 i += packet_length_size;
50175 if (copy_to_user(&buf[i], msg_ctx->msg, msg_ctx->msg_size))
50176 diff --git a/fs/ecryptfs/read_write.c b/fs/ecryptfs/read_write.c
50177 index 6a16053..2155147 100644
50178 --- a/fs/ecryptfs/read_write.c
50179 +++ b/fs/ecryptfs/read_write.c
50180 @@ -240,7 +240,7 @@ int ecryptfs_read_lower(char *data, loff_t offset, size_t size,
50181 return -EIO;
50182 fs_save = get_fs();
50183 set_fs(get_ds());
50184 - rc = vfs_read(lower_file, data, size, &offset);
50185 + rc = vfs_read(lower_file, (char __force_user *)data, size, &offset);
50186 set_fs(fs_save);
50187 return rc;
50188 }
50189 diff --git a/fs/exec.c b/fs/exec.c
50190 index 6d56ff2..3bc6638 100644
50191 --- a/fs/exec.c
50192 +++ b/fs/exec.c
50193 @@ -55,8 +55,20 @@
50194 #include <linux/pipe_fs_i.h>
50195 #include <linux/oom.h>
50196 #include <linux/compat.h>
50197 +#include <linux/random.h>
50198 +#include <linux/seq_file.h>
50199 +#include <linux/coredump.h>
50200 +#include <linux/mman.h>
50201 +
50202 +#ifdef CONFIG_PAX_REFCOUNT
50203 +#include <linux/kallsyms.h>
50204 +#include <linux/kdebug.h>
50205 +#endif
50206 +
50207 +#include <trace/events/fs.h>
50208
50209 #include <asm/uaccess.h>
50210 +#include <asm/sections.h>
50211 #include <asm/mmu_context.h>
50212 #include <asm/tlb.h>
50213
50214 @@ -66,6 +78,18 @@
50215
50216 #include <trace/events/sched.h>
50217
50218 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
50219 +void __weak pax_set_initial_flags(struct linux_binprm *bprm)
50220 +{
50221 + 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");
50222 +}
50223 +#endif
50224 +
50225 +#ifdef CONFIG_PAX_HOOK_ACL_FLAGS
50226 +void (*pax_set_initial_flags_func)(struct linux_binprm *bprm);
50227 +EXPORT_SYMBOL(pax_set_initial_flags_func);
50228 +#endif
50229 +
50230 int suid_dumpable = 0;
50231
50232 static LIST_HEAD(formats);
50233 @@ -75,8 +99,8 @@ void __register_binfmt(struct linux_binfmt * fmt, int insert)
50234 {
50235 BUG_ON(!fmt);
50236 write_lock(&binfmt_lock);
50237 - insert ? list_add(&fmt->lh, &formats) :
50238 - list_add_tail(&fmt->lh, &formats);
50239 + insert ? pax_list_add((struct list_head *)&fmt->lh, &formats) :
50240 + pax_list_add_tail((struct list_head *)&fmt->lh, &formats);
50241 write_unlock(&binfmt_lock);
50242 }
50243
50244 @@ -85,7 +109,7 @@ EXPORT_SYMBOL(__register_binfmt);
50245 void unregister_binfmt(struct linux_binfmt * fmt)
50246 {
50247 write_lock(&binfmt_lock);
50248 - list_del(&fmt->lh);
50249 + pax_list_del((struct list_head *)&fmt->lh);
50250 write_unlock(&binfmt_lock);
50251 }
50252
50253 @@ -180,18 +204,10 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
50254 int write)
50255 {
50256 struct page *page;
50257 - int ret;
50258
50259 -#ifdef CONFIG_STACK_GROWSUP
50260 - if (write) {
50261 - ret = expand_downwards(bprm->vma, pos);
50262 - if (ret < 0)
50263 - return NULL;
50264 - }
50265 -#endif
50266 - ret = get_user_pages(current, bprm->mm, pos,
50267 - 1, write, 1, &page, NULL);
50268 - if (ret <= 0)
50269 + if (0 > expand_downwards(bprm->vma, pos))
50270 + return NULL;
50271 + if (0 >= get_user_pages(current, bprm->mm, pos, 1, write, 1, &page, NULL))
50272 return NULL;
50273
50274 if (write) {
50275 @@ -207,6 +223,17 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
50276 if (size <= ARG_MAX)
50277 return page;
50278
50279 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
50280 + // only allow 512KB for argv+env on suid/sgid binaries
50281 + // to prevent easy ASLR exhaustion
50282 + if (((!uid_eq(bprm->cred->euid, current_euid())) ||
50283 + (!gid_eq(bprm->cred->egid, current_egid()))) &&
50284 + (size > (512 * 1024))) {
50285 + put_page(page);
50286 + return NULL;
50287 + }
50288 +#endif
50289 +
50290 /*
50291 * Limit to 1/4-th the stack size for the argv+env strings.
50292 * This ensures that:
50293 @@ -266,6 +293,11 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
50294 vma->vm_end = STACK_TOP_MAX;
50295 vma->vm_start = vma->vm_end - PAGE_SIZE;
50296 vma->vm_flags = VM_STACK_FLAGS | VM_STACK_INCOMPLETE_SETUP;
50297 +
50298 +#ifdef CONFIG_PAX_SEGMEXEC
50299 + vma->vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
50300 +#endif
50301 +
50302 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
50303 INIT_LIST_HEAD(&vma->anon_vma_chain);
50304
50305 @@ -276,6 +308,12 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
50306 mm->stack_vm = mm->total_vm = 1;
50307 up_write(&mm->mmap_sem);
50308 bprm->p = vma->vm_end - sizeof(void *);
50309 +
50310 +#ifdef CONFIG_PAX_RANDUSTACK
50311 + if (randomize_va_space)
50312 + bprm->p ^= random32() & ~PAGE_MASK;
50313 +#endif
50314 +
50315 return 0;
50316 err:
50317 up_write(&mm->mmap_sem);
50318 @@ -396,7 +434,7 @@ struct user_arg_ptr {
50319 } ptr;
50320 };
50321
50322 -static const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
50323 +const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
50324 {
50325 const char __user *native;
50326
50327 @@ -405,14 +443,14 @@ static const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
50328 compat_uptr_t compat;
50329
50330 if (get_user(compat, argv.ptr.compat + nr))
50331 - return ERR_PTR(-EFAULT);
50332 + return (const char __force_user *)ERR_PTR(-EFAULT);
50333
50334 return compat_ptr(compat);
50335 }
50336 #endif
50337
50338 if (get_user(native, argv.ptr.native + nr))
50339 - return ERR_PTR(-EFAULT);
50340 + return (const char __force_user *)ERR_PTR(-EFAULT);
50341
50342 return native;
50343 }
50344 @@ -431,7 +469,7 @@ static int count(struct user_arg_ptr argv, int max)
50345 if (!p)
50346 break;
50347
50348 - if (IS_ERR(p))
50349 + if (IS_ERR((const char __force_kernel *)p))
50350 return -EFAULT;
50351
50352 if (i >= max)
50353 @@ -466,7 +504,7 @@ static int copy_strings(int argc, struct user_arg_ptr argv,
50354
50355 ret = -EFAULT;
50356 str = get_user_arg_ptr(argv, argc);
50357 - if (IS_ERR(str))
50358 + if (IS_ERR((const char __force_kernel *)str))
50359 goto out;
50360
50361 len = strnlen_user(str, MAX_ARG_STRLEN);
50362 @@ -548,7 +586,7 @@ int copy_strings_kernel(int argc, const char *const *__argv,
50363 int r;
50364 mm_segment_t oldfs = get_fs();
50365 struct user_arg_ptr argv = {
50366 - .ptr.native = (const char __user *const __user *)__argv,
50367 + .ptr.native = (const char __force_user * const __force_user *)__argv,
50368 };
50369
50370 set_fs(KERNEL_DS);
50371 @@ -583,7 +621,8 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
50372 unsigned long new_end = old_end - shift;
50373 struct mmu_gather tlb;
50374
50375 - BUG_ON(new_start > new_end);
50376 + if (new_start >= new_end || new_start < mmap_min_addr)
50377 + return -ENOMEM;
50378
50379 /*
50380 * ensure there are no vmas between where we want to go
50381 @@ -592,6 +631,10 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
50382 if (vma != find_vma(mm, new_start))
50383 return -EFAULT;
50384
50385 +#ifdef CONFIG_PAX_SEGMEXEC
50386 + BUG_ON(pax_find_mirror_vma(vma));
50387 +#endif
50388 +
50389 /*
50390 * cover the whole range: [new_start, old_end)
50391 */
50392 @@ -672,10 +715,6 @@ int setup_arg_pages(struct linux_binprm *bprm,
50393 stack_top = arch_align_stack(stack_top);
50394 stack_top = PAGE_ALIGN(stack_top);
50395
50396 - if (unlikely(stack_top < mmap_min_addr) ||
50397 - unlikely(vma->vm_end - vma->vm_start >= stack_top - mmap_min_addr))
50398 - return -ENOMEM;
50399 -
50400 stack_shift = vma->vm_end - stack_top;
50401
50402 bprm->p -= stack_shift;
50403 @@ -687,8 +726,28 @@ int setup_arg_pages(struct linux_binprm *bprm,
50404 bprm->exec -= stack_shift;
50405
50406 down_write(&mm->mmap_sem);
50407 +
50408 + /* Move stack pages down in memory. */
50409 + if (stack_shift) {
50410 + ret = shift_arg_pages(vma, stack_shift);
50411 + if (ret)
50412 + goto out_unlock;
50413 + }
50414 +
50415 vm_flags = VM_STACK_FLAGS;
50416
50417 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
50418 + if (mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
50419 + vm_flags &= ~VM_EXEC;
50420 +
50421 +#ifdef CONFIG_PAX_MPROTECT
50422 + if (mm->pax_flags & MF_PAX_MPROTECT)
50423 + vm_flags &= ~VM_MAYEXEC;
50424 +#endif
50425 +
50426 + }
50427 +#endif
50428 +
50429 /*
50430 * Adjust stack execute permissions; explicitly enable for
50431 * EXSTACK_ENABLE_X, disable for EXSTACK_DISABLE_X and leave alone
50432 @@ -707,13 +766,6 @@ int setup_arg_pages(struct linux_binprm *bprm,
50433 goto out_unlock;
50434 BUG_ON(prev != vma);
50435
50436 - /* Move stack pages down in memory. */
50437 - if (stack_shift) {
50438 - ret = shift_arg_pages(vma, stack_shift);
50439 - if (ret)
50440 - goto out_unlock;
50441 - }
50442 -
50443 /* mprotect_fixup is overkill to remove the temporary stack flags */
50444 vma->vm_flags &= ~VM_STACK_INCOMPLETE_SETUP;
50445
50446 @@ -737,6 +789,27 @@ int setup_arg_pages(struct linux_binprm *bprm,
50447 #endif
50448 current->mm->start_stack = bprm->p;
50449 ret = expand_stack(vma, stack_base);
50450 +
50451 +#if !defined(CONFIG_STACK_GROWSUP) && defined(CONFIG_PAX_RANDMMAP)
50452 + if (!ret && (mm->pax_flags & MF_PAX_RANDMMAP) && STACK_TOP <= 0xFFFFFFFFU && STACK_TOP > vma->vm_end) {
50453 + unsigned long size;
50454 + vm_flags_t vm_flags;
50455 +
50456 + size = STACK_TOP - vma->vm_end;
50457 + vm_flags = VM_NONE | VM_DONTEXPAND | VM_DONTDUMP;
50458 +
50459 + ret = vma->vm_end != mmap_region(NULL, vma->vm_end, size, vm_flags, 0);
50460 +
50461 +#ifdef CONFIG_X86
50462 + if (!ret) {
50463 + size = mmap_min_addr + ((mm->delta_mmap ^ mm->delta_stack) & (0xFFUL << PAGE_SHIFT));
50464 + ret = 0 != mmap_region(NULL, 0, PAGE_ALIGN(size), vm_flags, 0);
50465 + }
50466 +#endif
50467 +
50468 + }
50469 +#endif
50470 +
50471 if (ret)
50472 ret = -EFAULT;
50473
50474 @@ -772,6 +845,8 @@ struct file *open_exec(const char *name)
50475
50476 fsnotify_open(file);
50477
50478 + trace_open_exec(name);
50479 +
50480 err = deny_write_access(file);
50481 if (err)
50482 goto exit;
50483 @@ -795,7 +870,7 @@ int kernel_read(struct file *file, loff_t offset,
50484 old_fs = get_fs();
50485 set_fs(get_ds());
50486 /* The cast to a user pointer is valid due to the set_fs() */
50487 - result = vfs_read(file, (void __user *)addr, count, &pos);
50488 + result = vfs_read(file, (void __force_user *)addr, count, &pos);
50489 set_fs(old_fs);
50490 return result;
50491 }
50492 @@ -1250,7 +1325,7 @@ static int check_unsafe_exec(struct linux_binprm *bprm)
50493 }
50494 rcu_read_unlock();
50495
50496 - if (p->fs->users > n_fs) {
50497 + if (atomic_read(&p->fs->users) > n_fs) {
50498 bprm->unsafe |= LSM_UNSAFE_SHARE;
50499 } else {
50500 res = -EAGAIN;
50501 @@ -1450,6 +1525,31 @@ int search_binary_handler(struct linux_binprm *bprm)
50502
50503 EXPORT_SYMBOL(search_binary_handler);
50504
50505 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
50506 +static DEFINE_PER_CPU(u64, exec_counter);
50507 +static int __init init_exec_counters(void)
50508 +{
50509 + unsigned int cpu;
50510 +
50511 + for_each_possible_cpu(cpu) {
50512 + per_cpu(exec_counter, cpu) = (u64)cpu;
50513 + }
50514 +
50515 + return 0;
50516 +}
50517 +early_initcall(init_exec_counters);
50518 +static inline void increment_exec_counter(void)
50519 +{
50520 + BUILD_BUG_ON(NR_CPUS > (1 << 16));
50521 + current->exec_id = this_cpu_add_return(exec_counter, 1 << 16);
50522 +}
50523 +#else
50524 +static inline void increment_exec_counter(void) {}
50525 +#endif
50526 +
50527 +extern void gr_handle_exec_args(struct linux_binprm *bprm,
50528 + struct user_arg_ptr argv);
50529 +
50530 /*
50531 * sys_execve() executes a new program.
50532 */
50533 @@ -1457,6 +1557,11 @@ static int do_execve_common(const char *filename,
50534 struct user_arg_ptr argv,
50535 struct user_arg_ptr envp)
50536 {
50537 +#ifdef CONFIG_GRKERNSEC
50538 + struct file *old_exec_file;
50539 + struct acl_subject_label *old_acl;
50540 + struct rlimit old_rlim[RLIM_NLIMITS];
50541 +#endif
50542 struct linux_binprm *bprm;
50543 struct file *file;
50544 struct files_struct *displaced;
50545 @@ -1464,6 +1569,8 @@ static int do_execve_common(const char *filename,
50546 int retval;
50547 const struct cred *cred = current_cred();
50548
50549 + gr_learn_resource(current, RLIMIT_NPROC, atomic_read(&cred->user->processes), 1);
50550 +
50551 /*
50552 * We move the actual failure in case of RLIMIT_NPROC excess from
50553 * set*uid() to execve() because too many poorly written programs
50554 @@ -1504,12 +1611,27 @@ static int do_execve_common(const char *filename,
50555 if (IS_ERR(file))
50556 goto out_unmark;
50557
50558 + if (gr_ptrace_readexec(file, bprm->unsafe)) {
50559 + retval = -EPERM;
50560 + goto out_file;
50561 + }
50562 +
50563 sched_exec();
50564
50565 bprm->file = file;
50566 bprm->filename = filename;
50567 bprm->interp = filename;
50568
50569 + if (gr_process_user_ban()) {
50570 + retval = -EPERM;
50571 + goto out_file;
50572 + }
50573 +
50574 + if (!gr_acl_handle_execve(file->f_path.dentry, file->f_path.mnt)) {
50575 + retval = -EACCES;
50576 + goto out_file;
50577 + }
50578 +
50579 retval = bprm_mm_init(bprm);
50580 if (retval)
50581 goto out_file;
50582 @@ -1526,24 +1648,65 @@ static int do_execve_common(const char *filename,
50583 if (retval < 0)
50584 goto out;
50585
50586 +#ifdef CONFIG_GRKERNSEC
50587 + old_acl = current->acl;
50588 + memcpy(old_rlim, current->signal->rlim, sizeof(old_rlim));
50589 + old_exec_file = current->exec_file;
50590 + get_file(file);
50591 + current->exec_file = file;
50592 +#endif
50593 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
50594 + /* limit suid stack to 8MB
50595 + * we saved the old limits above and will restore them if this exec fails
50596 + */
50597 + if (((!uid_eq(bprm->cred->euid, current_euid())) || (!gid_eq(bprm->cred->egid, current_egid()))) &&
50598 + (old_rlim[RLIMIT_STACK].rlim_cur > (8 * 1024 * 1024)))
50599 + current->signal->rlim[RLIMIT_STACK].rlim_cur = 8 * 1024 * 1024;
50600 +#endif
50601 +
50602 + if (!gr_tpe_allow(file)) {
50603 + retval = -EACCES;
50604 + goto out_fail;
50605 + }
50606 +
50607 + if (gr_check_crash_exec(file)) {
50608 + retval = -EACCES;
50609 + goto out_fail;
50610 + }
50611 +
50612 + retval = gr_set_proc_label(file->f_path.dentry, file->f_path.mnt,
50613 + bprm->unsafe);
50614 + if (retval < 0)
50615 + goto out_fail;
50616 +
50617 retval = copy_strings_kernel(1, &bprm->filename, bprm);
50618 if (retval < 0)
50619 - goto out;
50620 + goto out_fail;
50621
50622 bprm->exec = bprm->p;
50623 retval = copy_strings(bprm->envc, envp, bprm);
50624 if (retval < 0)
50625 - goto out;
50626 + goto out_fail;
50627
50628 retval = copy_strings(bprm->argc, argv, bprm);
50629 if (retval < 0)
50630 - goto out;
50631 + goto out_fail;
50632 +
50633 + gr_log_chroot_exec(file->f_path.dentry, file->f_path.mnt);
50634 +
50635 + gr_handle_exec_args(bprm, argv);
50636
50637 retval = search_binary_handler(bprm);
50638 if (retval < 0)
50639 - goto out;
50640 + goto out_fail;
50641 +#ifdef CONFIG_GRKERNSEC
50642 + if (old_exec_file)
50643 + fput(old_exec_file);
50644 +#endif
50645
50646 /* execve succeeded */
50647 +
50648 + increment_exec_counter();
50649 current->fs->in_exec = 0;
50650 current->in_execve = 0;
50651 acct_update_integrals(current);
50652 @@ -1552,6 +1715,14 @@ static int do_execve_common(const char *filename,
50653 put_files_struct(displaced);
50654 return retval;
50655
50656 +out_fail:
50657 +#ifdef CONFIG_GRKERNSEC
50658 + current->acl = old_acl;
50659 + memcpy(current->signal->rlim, old_rlim, sizeof(old_rlim));
50660 + fput(current->exec_file);
50661 + current->exec_file = old_exec_file;
50662 +#endif
50663 +
50664 out:
50665 if (bprm->mm) {
50666 acct_arg_size(bprm, 0);
50667 @@ -1700,3 +1871,283 @@ asmlinkage long compat_sys_execve(const char __user * filename,
50668 return error;
50669 }
50670 #endif
50671 +
50672 +int pax_check_flags(unsigned long *flags)
50673 +{
50674 + int retval = 0;
50675 +
50676 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_SEGMEXEC)
50677 + if (*flags & MF_PAX_SEGMEXEC)
50678 + {
50679 + *flags &= ~MF_PAX_SEGMEXEC;
50680 + retval = -EINVAL;
50681 + }
50682 +#endif
50683 +
50684 + if ((*flags & MF_PAX_PAGEEXEC)
50685 +
50686 +#ifdef CONFIG_PAX_PAGEEXEC
50687 + && (*flags & MF_PAX_SEGMEXEC)
50688 +#endif
50689 +
50690 + )
50691 + {
50692 + *flags &= ~MF_PAX_PAGEEXEC;
50693 + retval = -EINVAL;
50694 + }
50695 +
50696 + if ((*flags & MF_PAX_MPROTECT)
50697 +
50698 +#ifdef CONFIG_PAX_MPROTECT
50699 + && !(*flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC))
50700 +#endif
50701 +
50702 + )
50703 + {
50704 + *flags &= ~MF_PAX_MPROTECT;
50705 + retval = -EINVAL;
50706 + }
50707 +
50708 + if ((*flags & MF_PAX_EMUTRAMP)
50709 +
50710 +#ifdef CONFIG_PAX_EMUTRAMP
50711 + && !(*flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC))
50712 +#endif
50713 +
50714 + )
50715 + {
50716 + *flags &= ~MF_PAX_EMUTRAMP;
50717 + retval = -EINVAL;
50718 + }
50719 +
50720 + return retval;
50721 +}
50722 +
50723 +EXPORT_SYMBOL(pax_check_flags);
50724 +
50725 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
50726 +void pax_report_fault(struct pt_regs *regs, void *pc, void *sp)
50727 +{
50728 + struct task_struct *tsk = current;
50729 + struct mm_struct *mm = current->mm;
50730 + char *buffer_exec = (char *)__get_free_page(GFP_KERNEL);
50731 + char *buffer_fault = (char *)__get_free_page(GFP_KERNEL);
50732 + char *path_exec = NULL;
50733 + char *path_fault = NULL;
50734 + unsigned long start = 0UL, end = 0UL, offset = 0UL;
50735 + siginfo_t info = { };
50736 +
50737 + if (buffer_exec && buffer_fault) {
50738 + struct vm_area_struct *vma, *vma_exec = NULL, *vma_fault = NULL;
50739 +
50740 + down_read(&mm->mmap_sem);
50741 + vma = mm->mmap;
50742 + while (vma && (!vma_exec || !vma_fault)) {
50743 + if (vma->vm_file && mm->exe_file == vma->vm_file && (vma->vm_flags & VM_EXEC))
50744 + vma_exec = vma;
50745 + if (vma->vm_start <= (unsigned long)pc && (unsigned long)pc < vma->vm_end)
50746 + vma_fault = vma;
50747 + vma = vma->vm_next;
50748 + }
50749 + if (vma_exec) {
50750 + path_exec = d_path(&vma_exec->vm_file->f_path, buffer_exec, PAGE_SIZE);
50751 + if (IS_ERR(path_exec))
50752 + path_exec = "<path too long>";
50753 + else {
50754 + path_exec = mangle_path(buffer_exec, path_exec, "\t\n\\");
50755 + if (path_exec) {
50756 + *path_exec = 0;
50757 + path_exec = buffer_exec;
50758 + } else
50759 + path_exec = "<path too long>";
50760 + }
50761 + }
50762 + if (vma_fault) {
50763 + start = vma_fault->vm_start;
50764 + end = vma_fault->vm_end;
50765 + offset = vma_fault->vm_pgoff << PAGE_SHIFT;
50766 + if (vma_fault->vm_file) {
50767 + path_fault = d_path(&vma_fault->vm_file->f_path, buffer_fault, PAGE_SIZE);
50768 + if (IS_ERR(path_fault))
50769 + path_fault = "<path too long>";
50770 + else {
50771 + path_fault = mangle_path(buffer_fault, path_fault, "\t\n\\");
50772 + if (path_fault) {
50773 + *path_fault = 0;
50774 + path_fault = buffer_fault;
50775 + } else
50776 + path_fault = "<path too long>";
50777 + }
50778 + } else
50779 + path_fault = "<anonymous mapping>";
50780 + }
50781 + up_read(&mm->mmap_sem);
50782 + }
50783 + if (tsk->signal->curr_ip)
50784 + printk(KERN_ERR "PAX: From %pI4: execution attempt in: %s, %08lx-%08lx %08lx\n", &tsk->signal->curr_ip, path_fault, start, end, offset);
50785 + else
50786 + printk(KERN_ERR "PAX: execution attempt in: %s, %08lx-%08lx %08lx\n", path_fault, start, end, offset);
50787 + 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),
50788 + from_kuid_munged(&init_user_ns, task_uid(tsk)), from_kuid_munged(&init_user_ns, task_euid(tsk)), pc, sp);
50789 + free_page((unsigned long)buffer_exec);
50790 + free_page((unsigned long)buffer_fault);
50791 + pax_report_insns(regs, pc, sp);
50792 + info.si_signo = SIGKILL;
50793 + info.si_errno = 0;
50794 + info.si_code = SI_KERNEL;
50795 + info.si_pid = 0;
50796 + info.si_uid = 0;
50797 + do_coredump(&info);
50798 +}
50799 +#endif
50800 +
50801 +#ifdef CONFIG_PAX_REFCOUNT
50802 +void pax_report_refcount_overflow(struct pt_regs *regs)
50803 +{
50804 + if (current->signal->curr_ip)
50805 + printk(KERN_ERR "PAX: From %pI4: refcount overflow detected in: %s:%d, uid/euid: %u/%u\n",
50806 + &current->signal->curr_ip, current->comm, task_pid_nr(current),
50807 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
50808 + else
50809 + printk(KERN_ERR "PAX: refcount overflow detected in: %s:%d, uid/euid: %u/%u\n", current->comm, task_pid_nr(current),
50810 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
50811 + print_symbol(KERN_ERR "PAX: refcount overflow occured at: %s\n", instruction_pointer(regs));
50812 + show_regs(regs);
50813 + force_sig_info(SIGKILL, SEND_SIG_FORCED, current);
50814 +}
50815 +#endif
50816 +
50817 +#ifdef CONFIG_PAX_USERCOPY
50818 +/* 0: not at all, 1: fully, 2: fully inside frame, -1: partially (implies an error) */
50819 +static noinline int check_stack_object(const void *obj, unsigned long len)
50820 +{
50821 + const void * const stack = task_stack_page(current);
50822 + const void * const stackend = stack + THREAD_SIZE;
50823 +
50824 +#if defined(CONFIG_FRAME_POINTER) && defined(CONFIG_X86)
50825 + const void *frame = NULL;
50826 + const void *oldframe;
50827 +#endif
50828 +
50829 + if (obj + len < obj)
50830 + return -1;
50831 +
50832 + if (obj + len <= stack || stackend <= obj)
50833 + return 0;
50834 +
50835 + if (obj < stack || stackend < obj + len)
50836 + return -1;
50837 +
50838 +#if defined(CONFIG_FRAME_POINTER) && defined(CONFIG_X86)
50839 + oldframe = __builtin_frame_address(1);
50840 + if (oldframe)
50841 + frame = __builtin_frame_address(2);
50842 + /*
50843 + low ----------------------------------------------> high
50844 + [saved bp][saved ip][args][local vars][saved bp][saved ip]
50845 + ^----------------^
50846 + allow copies only within here
50847 + */
50848 + while (stack <= frame && frame < stackend) {
50849 + /* if obj + len extends past the last frame, this
50850 + check won't pass and the next frame will be 0,
50851 + causing us to bail out and correctly report
50852 + the copy as invalid
50853 + */
50854 + if (obj + len <= frame)
50855 + return obj >= oldframe + 2 * sizeof(void *) ? 2 : -1;
50856 + oldframe = frame;
50857 + frame = *(const void * const *)frame;
50858 + }
50859 + return -1;
50860 +#else
50861 + return 1;
50862 +#endif
50863 +}
50864 +
50865 +static __noreturn void pax_report_usercopy(const void *ptr, unsigned long len, bool to_user, const char *type)
50866 +{
50867 + if (current->signal->curr_ip)
50868 + printk(KERN_ERR "PAX: From %pI4: kernel memory %s attempt detected %s %p (%s) (%lu bytes)\n",
50869 + &current->signal->curr_ip, to_user ? "leak" : "overwrite", to_user ? "from" : "to", ptr, type ? : "unknown", len);
50870 + else
50871 + printk(KERN_ERR "PAX: kernel memory %s attempt detected %s %p (%s) (%lu bytes)\n",
50872 + to_user ? "leak" : "overwrite", to_user ? "from" : "to", ptr, type ? : "unknown", len);
50873 + dump_stack();
50874 + gr_handle_kernel_exploit();
50875 + do_group_exit(SIGKILL);
50876 +}
50877 +#endif
50878 +
50879 +#ifdef CONFIG_PAX_USERCOPY
50880 +static inline bool check_kernel_text_object(unsigned long low, unsigned long high)
50881 +{
50882 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
50883 + unsigned long textlow = ktla_ktva((unsigned long)_stext);
50884 +#ifdef CONFIG_MODULES
50885 + unsigned long texthigh = (unsigned long)MODULES_EXEC_VADDR;
50886 +#else
50887 + unsigned long texthigh = ktla_ktva((unsigned long)_etext);
50888 +#endif
50889 +
50890 +#else
50891 + unsigned long textlow = (unsigned long)_stext;
50892 + unsigned long texthigh = (unsigned long)_etext;
50893 +#endif
50894 +
50895 + if (high <= textlow || low > texthigh)
50896 + return false;
50897 + else
50898 + return true;
50899 +}
50900 +#endif
50901 +
50902 +void __check_object_size(const void *ptr, unsigned long n, bool to_user)
50903 +{
50904 +
50905 +#ifdef CONFIG_PAX_USERCOPY
50906 + const char *type;
50907 +
50908 + if (!n)
50909 + return;
50910 +
50911 + type = check_heap_object(ptr, n);
50912 + if (!type) {
50913 + int ret = check_stack_object(ptr, n);
50914 + if (ret == 1 || ret == 2)
50915 + return;
50916 + if (ret == 0) {
50917 + if (check_kernel_text_object((unsigned long)ptr, (unsigned long)ptr + n))
50918 + type = "<kernel text>";
50919 + else
50920 + return;
50921 + } else
50922 + type = "<process stack>";
50923 + }
50924 +
50925 + pax_report_usercopy(ptr, n, to_user, type);
50926 +#endif
50927 +
50928 +}
50929 +EXPORT_SYMBOL(__check_object_size);
50930 +
50931 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
50932 +void pax_track_stack(void)
50933 +{
50934 + unsigned long sp = (unsigned long)&sp;
50935 + if (sp < current_thread_info()->lowest_stack &&
50936 + sp > (unsigned long)task_stack_page(current))
50937 + current_thread_info()->lowest_stack = sp;
50938 +}
50939 +EXPORT_SYMBOL(pax_track_stack);
50940 +#endif
50941 +
50942 +#ifdef CONFIG_PAX_SIZE_OVERFLOW
50943 +void report_size_overflow(const char *file, unsigned int line, const char *func, const char *ssa_name)
50944 +{
50945 + printk(KERN_ERR "PAX: size overflow detected in function %s %s:%u %s", func, file, line, ssa_name);
50946 + dump_stack();
50947 + do_group_exit(SIGKILL);
50948 +}
50949 +EXPORT_SYMBOL(report_size_overflow);
50950 +#endif
50951 diff --git a/fs/ext2/balloc.c b/fs/ext2/balloc.c
50952 index 9f9992b..8b59411 100644
50953 --- a/fs/ext2/balloc.c
50954 +++ b/fs/ext2/balloc.c
50955 @@ -1184,10 +1184,10 @@ static int ext2_has_free_blocks(struct ext2_sb_info *sbi)
50956
50957 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
50958 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
50959 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
50960 + if (free_blocks < root_blocks + 1 &&
50961 !uid_eq(sbi->s_resuid, current_fsuid()) &&
50962 (gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) ||
50963 - !in_group_p (sbi->s_resgid))) {
50964 + !in_group_p (sbi->s_resgid)) && !capable_nolog(CAP_SYS_RESOURCE)) {
50965 return 0;
50966 }
50967 return 1;
50968 diff --git a/fs/ext3/balloc.c b/fs/ext3/balloc.c
50969 index 22548f5..41521d8 100644
50970 --- a/fs/ext3/balloc.c
50971 +++ b/fs/ext3/balloc.c
50972 @@ -1438,10 +1438,10 @@ static int ext3_has_free_blocks(struct ext3_sb_info *sbi, int use_reservation)
50973
50974 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
50975 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
50976 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
50977 + if (free_blocks < root_blocks + 1 &&
50978 !use_reservation && !uid_eq(sbi->s_resuid, current_fsuid()) &&
50979 (gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) ||
50980 - !in_group_p (sbi->s_resgid))) {
50981 + !in_group_p (sbi->s_resgid)) && !capable_nolog(CAP_SYS_RESOURCE)) {
50982 return 0;
50983 }
50984 return 1;
50985 diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c
50986 index 92e68b3..115d987 100644
50987 --- a/fs/ext4/balloc.c
50988 +++ b/fs/ext4/balloc.c
50989 @@ -505,8 +505,8 @@ static int ext4_has_free_clusters(struct ext4_sb_info *sbi,
50990 /* Hm, nope. Are (enough) root reserved clusters available? */
50991 if (uid_eq(sbi->s_resuid, current_fsuid()) ||
50992 (!gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) && in_group_p(sbi->s_resgid)) ||
50993 - capable(CAP_SYS_RESOURCE) ||
50994 - (flags & EXT4_MB_USE_ROOT_BLOCKS)) {
50995 + (flags & EXT4_MB_USE_ROOT_BLOCKS) ||
50996 + capable_nolog(CAP_SYS_RESOURCE)) {
50997
50998 if (free_clusters >= (nclusters + dirty_clusters))
50999 return 1;
51000 diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
51001 index 3b83cd6..0f34dcd 100644
51002 --- a/fs/ext4/ext4.h
51003 +++ b/fs/ext4/ext4.h
51004 @@ -1254,19 +1254,19 @@ struct ext4_sb_info {
51005 unsigned long s_mb_last_start;
51006
51007 /* stats for buddy allocator */
51008 - atomic_t s_bal_reqs; /* number of reqs with len > 1 */
51009 - atomic_t s_bal_success; /* we found long enough chunks */
51010 - atomic_t s_bal_allocated; /* in blocks */
51011 - atomic_t s_bal_ex_scanned; /* total extents scanned */
51012 - atomic_t s_bal_goals; /* goal hits */
51013 - atomic_t s_bal_breaks; /* too long searches */
51014 - atomic_t s_bal_2orders; /* 2^order hits */
51015 + atomic_unchecked_t s_bal_reqs; /* number of reqs with len > 1 */
51016 + atomic_unchecked_t s_bal_success; /* we found long enough chunks */
51017 + atomic_unchecked_t s_bal_allocated; /* in blocks */
51018 + atomic_unchecked_t s_bal_ex_scanned; /* total extents scanned */
51019 + atomic_unchecked_t s_bal_goals; /* goal hits */
51020 + atomic_unchecked_t s_bal_breaks; /* too long searches */
51021 + atomic_unchecked_t s_bal_2orders; /* 2^order hits */
51022 spinlock_t s_bal_lock;
51023 unsigned long s_mb_buddies_generated;
51024 unsigned long long s_mb_generation_time;
51025 - atomic_t s_mb_lost_chunks;
51026 - atomic_t s_mb_preallocated;
51027 - atomic_t s_mb_discarded;
51028 + atomic_unchecked_t s_mb_lost_chunks;
51029 + atomic_unchecked_t s_mb_preallocated;
51030 + atomic_unchecked_t s_mb_discarded;
51031 atomic_t s_lock_busy;
51032
51033 /* locality groups */
51034 diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
51035 index f3190ab..84ffb21 100644
51036 --- a/fs/ext4/mballoc.c
51037 +++ b/fs/ext4/mballoc.c
51038 @@ -1754,7 +1754,7 @@ void ext4_mb_simple_scan_group(struct ext4_allocation_context *ac,
51039 BUG_ON(ac->ac_b_ex.fe_len != ac->ac_g_ex.fe_len);
51040
51041 if (EXT4_SB(sb)->s_mb_stats)
51042 - atomic_inc(&EXT4_SB(sb)->s_bal_2orders);
51043 + atomic_inc_unchecked(&EXT4_SB(sb)->s_bal_2orders);
51044
51045 break;
51046 }
51047 @@ -2059,7 +2059,7 @@ repeat:
51048 ac->ac_status = AC_STATUS_CONTINUE;
51049 ac->ac_flags |= EXT4_MB_HINT_FIRST;
51050 cr = 3;
51051 - atomic_inc(&sbi->s_mb_lost_chunks);
51052 + atomic_inc_unchecked(&sbi->s_mb_lost_chunks);
51053 goto repeat;
51054 }
51055 }
51056 @@ -2567,25 +2567,25 @@ int ext4_mb_release(struct super_block *sb)
51057 if (sbi->s_mb_stats) {
51058 ext4_msg(sb, KERN_INFO,
51059 "mballoc: %u blocks %u reqs (%u success)",
51060 - atomic_read(&sbi->s_bal_allocated),
51061 - atomic_read(&sbi->s_bal_reqs),
51062 - atomic_read(&sbi->s_bal_success));
51063 + atomic_read_unchecked(&sbi->s_bal_allocated),
51064 + atomic_read_unchecked(&sbi->s_bal_reqs),
51065 + atomic_read_unchecked(&sbi->s_bal_success));
51066 ext4_msg(sb, KERN_INFO,
51067 "mballoc: %u extents scanned, %u goal hits, "
51068 "%u 2^N hits, %u breaks, %u lost",
51069 - atomic_read(&sbi->s_bal_ex_scanned),
51070 - atomic_read(&sbi->s_bal_goals),
51071 - atomic_read(&sbi->s_bal_2orders),
51072 - atomic_read(&sbi->s_bal_breaks),
51073 - atomic_read(&sbi->s_mb_lost_chunks));
51074 + atomic_read_unchecked(&sbi->s_bal_ex_scanned),
51075 + atomic_read_unchecked(&sbi->s_bal_goals),
51076 + atomic_read_unchecked(&sbi->s_bal_2orders),
51077 + atomic_read_unchecked(&sbi->s_bal_breaks),
51078 + atomic_read_unchecked(&sbi->s_mb_lost_chunks));
51079 ext4_msg(sb, KERN_INFO,
51080 "mballoc: %lu generated and it took %Lu",
51081 sbi->s_mb_buddies_generated,
51082 sbi->s_mb_generation_time);
51083 ext4_msg(sb, KERN_INFO,
51084 "mballoc: %u preallocated, %u discarded",
51085 - atomic_read(&sbi->s_mb_preallocated),
51086 - atomic_read(&sbi->s_mb_discarded));
51087 + atomic_read_unchecked(&sbi->s_mb_preallocated),
51088 + atomic_read_unchecked(&sbi->s_mb_discarded));
51089 }
51090
51091 free_percpu(sbi->s_locality_groups);
51092 @@ -3039,16 +3039,16 @@ static void ext4_mb_collect_stats(struct ext4_allocation_context *ac)
51093 struct ext4_sb_info *sbi = EXT4_SB(ac->ac_sb);
51094
51095 if (sbi->s_mb_stats && ac->ac_g_ex.fe_len > 1) {
51096 - atomic_inc(&sbi->s_bal_reqs);
51097 - atomic_add(ac->ac_b_ex.fe_len, &sbi->s_bal_allocated);
51098 + atomic_inc_unchecked(&sbi->s_bal_reqs);
51099 + atomic_add_unchecked(ac->ac_b_ex.fe_len, &sbi->s_bal_allocated);
51100 if (ac->ac_b_ex.fe_len >= ac->ac_o_ex.fe_len)
51101 - atomic_inc(&sbi->s_bal_success);
51102 - atomic_add(ac->ac_found, &sbi->s_bal_ex_scanned);
51103 + atomic_inc_unchecked(&sbi->s_bal_success);
51104 + atomic_add_unchecked(ac->ac_found, &sbi->s_bal_ex_scanned);
51105 if (ac->ac_g_ex.fe_start == ac->ac_b_ex.fe_start &&
51106 ac->ac_g_ex.fe_group == ac->ac_b_ex.fe_group)
51107 - atomic_inc(&sbi->s_bal_goals);
51108 + atomic_inc_unchecked(&sbi->s_bal_goals);
51109 if (ac->ac_found > sbi->s_mb_max_to_scan)
51110 - atomic_inc(&sbi->s_bal_breaks);
51111 + atomic_inc_unchecked(&sbi->s_bal_breaks);
51112 }
51113
51114 if (ac->ac_op == EXT4_MB_HISTORY_ALLOC)
51115 @@ -3448,7 +3448,7 @@ ext4_mb_new_inode_pa(struct ext4_allocation_context *ac)
51116 trace_ext4_mb_new_inode_pa(ac, pa);
51117
51118 ext4_mb_use_inode_pa(ac, pa);
51119 - atomic_add(pa->pa_free, &sbi->s_mb_preallocated);
51120 + atomic_add_unchecked(pa->pa_free, &sbi->s_mb_preallocated);
51121
51122 ei = EXT4_I(ac->ac_inode);
51123 grp = ext4_get_group_info(sb, ac->ac_b_ex.fe_group);
51124 @@ -3508,7 +3508,7 @@ ext4_mb_new_group_pa(struct ext4_allocation_context *ac)
51125 trace_ext4_mb_new_group_pa(ac, pa);
51126
51127 ext4_mb_use_group_pa(ac, pa);
51128 - atomic_add(pa->pa_free, &EXT4_SB(sb)->s_mb_preallocated);
51129 + atomic_add_unchecked(pa->pa_free, &EXT4_SB(sb)->s_mb_preallocated);
51130
51131 grp = ext4_get_group_info(sb, ac->ac_b_ex.fe_group);
51132 lg = ac->ac_lg;
51133 @@ -3597,7 +3597,7 @@ ext4_mb_release_inode_pa(struct ext4_buddy *e4b, struct buffer_head *bitmap_bh,
51134 * from the bitmap and continue.
51135 */
51136 }
51137 - atomic_add(free, &sbi->s_mb_discarded);
51138 + atomic_add_unchecked(free, &sbi->s_mb_discarded);
51139
51140 return err;
51141 }
51142 @@ -3615,7 +3615,7 @@ ext4_mb_release_group_pa(struct ext4_buddy *e4b,
51143 ext4_get_group_no_and_offset(sb, pa->pa_pstart, &group, &bit);
51144 BUG_ON(group != e4b->bd_group && pa->pa_len != 0);
51145 mb_free_blocks(pa->pa_inode, e4b, bit, pa->pa_len);
51146 - atomic_add(pa->pa_len, &EXT4_SB(sb)->s_mb_discarded);
51147 + atomic_add_unchecked(pa->pa_len, &EXT4_SB(sb)->s_mb_discarded);
51148 trace_ext4_mballoc_discard(sb, NULL, group, bit, pa->pa_len);
51149
51150 return 0;
51151 diff --git a/fs/ext4/super.c b/fs/ext4/super.c
51152 index febbe0e..782c4fd 100644
51153 --- a/fs/ext4/super.c
51154 +++ b/fs/ext4/super.c
51155 @@ -2380,7 +2380,7 @@ struct ext4_attr {
51156 ssize_t (*store)(struct ext4_attr *, struct ext4_sb_info *,
51157 const char *, size_t);
51158 int offset;
51159 -};
51160 +} __do_const;
51161
51162 static int parse_strtoul(const char *buf,
51163 unsigned long max, unsigned long *value)
51164 diff --git a/fs/fat/inode.c b/fs/fat/inode.c
51165 index acf6e47..e7a7fde 100644
51166 --- a/fs/fat/inode.c
51167 +++ b/fs/fat/inode.c
51168 @@ -1223,6 +1223,19 @@ static int fat_read_root(struct inode *inode)
51169 return 0;
51170 }
51171
51172 +static unsigned long calc_fat_clusters(struct super_block *sb)
51173 +{
51174 + struct msdos_sb_info *sbi = MSDOS_SB(sb);
51175 +
51176 + /* Divide first to avoid overflow */
51177 + if (sbi->fat_bits != 12) {
51178 + unsigned long ent_per_sec = sb->s_blocksize * 8 / sbi->fat_bits;
51179 + return ent_per_sec * sbi->fat_length;
51180 + }
51181 +
51182 + return sbi->fat_length * sb->s_blocksize * 8 / sbi->fat_bits;
51183 +}
51184 +
51185 /*
51186 * Read the super block of an MS-DOS FS.
51187 */
51188 @@ -1427,7 +1440,7 @@ int fat_fill_super(struct super_block *sb, void *data, int silent, int isvfat,
51189 sbi->dirty = b->fat16.state & FAT_STATE_DIRTY;
51190
51191 /* check that FAT table does not overflow */
51192 - fat_clusters = sbi->fat_length * sb->s_blocksize * 8 / sbi->fat_bits;
51193 + fat_clusters = calc_fat_clusters(sb);
51194 total_clusters = min(total_clusters, fat_clusters - FAT_START_ENT);
51195 if (total_clusters > MAX_FAT(sb)) {
51196 if (!silent)
51197 diff --git a/fs/fcntl.c b/fs/fcntl.c
51198 index 6599222..e7bf0de 100644
51199 --- a/fs/fcntl.c
51200 +++ b/fs/fcntl.c
51201 @@ -107,6 +107,11 @@ int __f_setown(struct file *filp, struct pid *pid, enum pid_type type,
51202 if (err)
51203 return err;
51204
51205 + if (gr_handle_chroot_fowner(pid, type))
51206 + return -ENOENT;
51207 + if (gr_check_protected_task_fowner(pid, type))
51208 + return -EACCES;
51209 +
51210 f_modown(filp, pid, type, force);
51211 return 0;
51212 }
51213 diff --git a/fs/fhandle.c b/fs/fhandle.c
51214 index 999ff5c..41f4109 100644
51215 --- a/fs/fhandle.c
51216 +++ b/fs/fhandle.c
51217 @@ -67,8 +67,7 @@ static long do_sys_name_to_handle(struct path *path,
51218 } else
51219 retval = 0;
51220 /* copy the mount id */
51221 - if (copy_to_user(mnt_id, &real_mount(path->mnt)->mnt_id,
51222 - sizeof(*mnt_id)) ||
51223 + if (put_user(real_mount(path->mnt)->mnt_id, mnt_id) ||
51224 copy_to_user(ufh, handle,
51225 sizeof(struct file_handle) + handle_bytes))
51226 retval = -EFAULT;
51227 diff --git a/fs/fifo.c b/fs/fifo.c
51228 index cf6f434..3d7942c 100644
51229 --- a/fs/fifo.c
51230 +++ b/fs/fifo.c
51231 @@ -59,10 +59,10 @@ static int fifo_open(struct inode *inode, struct file *filp)
51232 */
51233 filp->f_op = &read_pipefifo_fops;
51234 pipe->r_counter++;
51235 - if (pipe->readers++ == 0)
51236 + if (atomic_inc_return(&pipe->readers) == 1)
51237 wake_up_partner(inode);
51238
51239 - if (!pipe->writers) {
51240 + if (!atomic_read(&pipe->writers)) {
51241 if ((filp->f_flags & O_NONBLOCK)) {
51242 /* suppress POLLHUP until we have
51243 * seen a writer */
51244 @@ -81,15 +81,15 @@ static int fifo_open(struct inode *inode, struct file *filp)
51245 * errno=ENXIO when there is no process reading the FIFO.
51246 */
51247 ret = -ENXIO;
51248 - if ((filp->f_flags & O_NONBLOCK) && !pipe->readers)
51249 + if ((filp->f_flags & O_NONBLOCK) && !atomic_read(&pipe->readers))
51250 goto err;
51251
51252 filp->f_op = &write_pipefifo_fops;
51253 pipe->w_counter++;
51254 - if (!pipe->writers++)
51255 + if (atomic_inc_return(&pipe->writers) == 1)
51256 wake_up_partner(inode);
51257
51258 - if (!pipe->readers) {
51259 + if (!atomic_read(&pipe->readers)) {
51260 if (wait_for_partner(inode, &pipe->r_counter))
51261 goto err_wr;
51262 }
51263 @@ -104,11 +104,11 @@ static int fifo_open(struct inode *inode, struct file *filp)
51264 */
51265 filp->f_op = &rdwr_pipefifo_fops;
51266
51267 - pipe->readers++;
51268 - pipe->writers++;
51269 + atomic_inc(&pipe->readers);
51270 + atomic_inc(&pipe->writers);
51271 pipe->r_counter++;
51272 pipe->w_counter++;
51273 - if (pipe->readers == 1 || pipe->writers == 1)
51274 + if (atomic_read(&pipe->readers) == 1 || atomic_read(&pipe->writers) == 1)
51275 wake_up_partner(inode);
51276 break;
51277
51278 @@ -122,19 +122,19 @@ static int fifo_open(struct inode *inode, struct file *filp)
51279 return 0;
51280
51281 err_rd:
51282 - if (!--pipe->readers)
51283 + if (atomic_dec_and_test(&pipe->readers))
51284 wake_up_interruptible(&pipe->wait);
51285 ret = -ERESTARTSYS;
51286 goto err;
51287
51288 err_wr:
51289 - if (!--pipe->writers)
51290 + if (atomic_dec_and_test(&pipe->writers))
51291 wake_up_interruptible(&pipe->wait);
51292 ret = -ERESTARTSYS;
51293 goto err;
51294
51295 err:
51296 - if (!pipe->readers && !pipe->writers)
51297 + if (!atomic_read(&pipe->readers) && !atomic_read(&pipe->writers))
51298 free_pipe_info(inode);
51299
51300 err_nocleanup:
51301 diff --git a/fs/file.c b/fs/file.c
51302 index 3906d95..5fe379b 100644
51303 --- a/fs/file.c
51304 +++ b/fs/file.c
51305 @@ -16,6 +16,7 @@
51306 #include <linux/slab.h>
51307 #include <linux/vmalloc.h>
51308 #include <linux/file.h>
51309 +#include <linux/security.h>
51310 #include <linux/fdtable.h>
51311 #include <linux/bitops.h>
51312 #include <linux/interrupt.h>
51313 @@ -892,6 +893,7 @@ int replace_fd(unsigned fd, struct file *file, unsigned flags)
51314 if (!file)
51315 return __close_fd(files, fd);
51316
51317 + gr_learn_resource(current, RLIMIT_NOFILE, fd, 0);
51318 if (fd >= rlimit(RLIMIT_NOFILE))
51319 return -EBADF;
51320
51321 @@ -918,6 +920,7 @@ SYSCALL_DEFINE3(dup3, unsigned int, oldfd, unsigned int, newfd, int, flags)
51322 if (unlikely(oldfd == newfd))
51323 return -EINVAL;
51324
51325 + gr_learn_resource(current, RLIMIT_NOFILE, newfd, 0);
51326 if (newfd >= rlimit(RLIMIT_NOFILE))
51327 return -EBADF;
51328
51329 @@ -973,6 +976,7 @@ SYSCALL_DEFINE1(dup, unsigned int, fildes)
51330 int f_dupfd(unsigned int from, struct file *file, unsigned flags)
51331 {
51332 int err;
51333 + gr_learn_resource(current, RLIMIT_NOFILE, from, 0);
51334 if (from >= rlimit(RLIMIT_NOFILE))
51335 return -EINVAL;
51336 err = alloc_fd(from, flags);
51337 diff --git a/fs/filesystems.c b/fs/filesystems.c
51338 index 92567d9..fcd8cbf 100644
51339 --- a/fs/filesystems.c
51340 +++ b/fs/filesystems.c
51341 @@ -273,7 +273,11 @@ struct file_system_type *get_fs_type(const char *name)
51342 int len = dot ? dot - name : strlen(name);
51343
51344 fs = __get_fs_type(name, len);
51345 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
51346 + if (!fs && (___request_module(true, "grsec_modharden_fs", "fs-%.*s", len, name) == 0))
51347 +#else
51348 if (!fs && (request_module("fs-%.*s", len, name) == 0))
51349 +#endif
51350 fs = __get_fs_type(name, len);
51351
51352 if (dot && fs && !(fs->fs_flags & FS_HAS_SUBTYPE)) {
51353 diff --git a/fs/fs_struct.c b/fs/fs_struct.c
51354 index d8ac61d..79a36f0 100644
51355 --- a/fs/fs_struct.c
51356 +++ b/fs/fs_struct.c
51357 @@ -4,6 +4,7 @@
51358 #include <linux/path.h>
51359 #include <linux/slab.h>
51360 #include <linux/fs_struct.h>
51361 +#include <linux/grsecurity.h>
51362 #include "internal.h"
51363
51364 /*
51365 @@ -19,6 +20,7 @@ void set_fs_root(struct fs_struct *fs, const struct path *path)
51366 write_seqcount_begin(&fs->seq);
51367 old_root = fs->root;
51368 fs->root = *path;
51369 + gr_set_chroot_entries(current, path);
51370 write_seqcount_end(&fs->seq);
51371 spin_unlock(&fs->lock);
51372 if (old_root.dentry)
51373 @@ -67,6 +69,10 @@ void chroot_fs_refs(const struct path *old_root, const struct path *new_root)
51374 int hits = 0;
51375 spin_lock(&fs->lock);
51376 write_seqcount_begin(&fs->seq);
51377 + /* this root replacement is only done by pivot_root,
51378 + leave grsec's chroot tagging alone for this task
51379 + so that a pivoted root isn't treated as a chroot
51380 + */
51381 hits += replace_path(&fs->root, old_root, new_root);
51382 hits += replace_path(&fs->pwd, old_root, new_root);
51383 write_seqcount_end(&fs->seq);
51384 @@ -99,7 +105,8 @@ void exit_fs(struct task_struct *tsk)
51385 task_lock(tsk);
51386 spin_lock(&fs->lock);
51387 tsk->fs = NULL;
51388 - kill = !--fs->users;
51389 + gr_clear_chroot_entries(tsk);
51390 + kill = !atomic_dec_return(&fs->users);
51391 spin_unlock(&fs->lock);
51392 task_unlock(tsk);
51393 if (kill)
51394 @@ -112,7 +119,7 @@ struct fs_struct *copy_fs_struct(struct fs_struct *old)
51395 struct fs_struct *fs = kmem_cache_alloc(fs_cachep, GFP_KERNEL);
51396 /* We don't need to lock fs - think why ;-) */
51397 if (fs) {
51398 - fs->users = 1;
51399 + atomic_set(&fs->users, 1);
51400 fs->in_exec = 0;
51401 spin_lock_init(&fs->lock);
51402 seqcount_init(&fs->seq);
51403 @@ -121,6 +128,9 @@ struct fs_struct *copy_fs_struct(struct fs_struct *old)
51404 spin_lock(&old->lock);
51405 fs->root = old->root;
51406 path_get(&fs->root);
51407 + /* instead of calling gr_set_chroot_entries here,
51408 + we call it from every caller of this function
51409 + */
51410 fs->pwd = old->pwd;
51411 path_get(&fs->pwd);
51412 spin_unlock(&old->lock);
51413 @@ -139,8 +149,9 @@ int unshare_fs_struct(void)
51414
51415 task_lock(current);
51416 spin_lock(&fs->lock);
51417 - kill = !--fs->users;
51418 + kill = !atomic_dec_return(&fs->users);
51419 current->fs = new_fs;
51420 + gr_set_chroot_entries(current, &new_fs->root);
51421 spin_unlock(&fs->lock);
51422 task_unlock(current);
51423
51424 @@ -153,13 +164,13 @@ EXPORT_SYMBOL_GPL(unshare_fs_struct);
51425
51426 int current_umask(void)
51427 {
51428 - return current->fs->umask;
51429 + return current->fs->umask | gr_acl_umask();
51430 }
51431 EXPORT_SYMBOL(current_umask);
51432
51433 /* to be mentioned only in INIT_TASK */
51434 struct fs_struct init_fs = {
51435 - .users = 1,
51436 + .users = ATOMIC_INIT(1),
51437 .lock = __SPIN_LOCK_UNLOCKED(init_fs.lock),
51438 .seq = SEQCNT_ZERO,
51439 .umask = 0022,
51440 diff --git a/fs/fscache/cookie.c b/fs/fscache/cookie.c
51441 index e2cba1f..17a25bb 100644
51442 --- a/fs/fscache/cookie.c
51443 +++ b/fs/fscache/cookie.c
51444 @@ -68,11 +68,11 @@ struct fscache_cookie *__fscache_acquire_cookie(
51445 parent ? (char *) parent->def->name : "<no-parent>",
51446 def->name, netfs_data);
51447
51448 - fscache_stat(&fscache_n_acquires);
51449 + fscache_stat_unchecked(&fscache_n_acquires);
51450
51451 /* if there's no parent cookie, then we don't create one here either */
51452 if (!parent) {
51453 - fscache_stat(&fscache_n_acquires_null);
51454 + fscache_stat_unchecked(&fscache_n_acquires_null);
51455 _leave(" [no parent]");
51456 return NULL;
51457 }
51458 @@ -87,7 +87,7 @@ struct fscache_cookie *__fscache_acquire_cookie(
51459 /* allocate and initialise a cookie */
51460 cookie = kmem_cache_alloc(fscache_cookie_jar, GFP_KERNEL);
51461 if (!cookie) {
51462 - fscache_stat(&fscache_n_acquires_oom);
51463 + fscache_stat_unchecked(&fscache_n_acquires_oom);
51464 _leave(" [ENOMEM]");
51465 return NULL;
51466 }
51467 @@ -109,13 +109,13 @@ struct fscache_cookie *__fscache_acquire_cookie(
51468
51469 switch (cookie->def->type) {
51470 case FSCACHE_COOKIE_TYPE_INDEX:
51471 - fscache_stat(&fscache_n_cookie_index);
51472 + fscache_stat_unchecked(&fscache_n_cookie_index);
51473 break;
51474 case FSCACHE_COOKIE_TYPE_DATAFILE:
51475 - fscache_stat(&fscache_n_cookie_data);
51476 + fscache_stat_unchecked(&fscache_n_cookie_data);
51477 break;
51478 default:
51479 - fscache_stat(&fscache_n_cookie_special);
51480 + fscache_stat_unchecked(&fscache_n_cookie_special);
51481 break;
51482 }
51483
51484 @@ -126,13 +126,13 @@ struct fscache_cookie *__fscache_acquire_cookie(
51485 if (fscache_acquire_non_index_cookie(cookie) < 0) {
51486 atomic_dec(&parent->n_children);
51487 __fscache_cookie_put(cookie);
51488 - fscache_stat(&fscache_n_acquires_nobufs);
51489 + fscache_stat_unchecked(&fscache_n_acquires_nobufs);
51490 _leave(" = NULL");
51491 return NULL;
51492 }
51493 }
51494
51495 - fscache_stat(&fscache_n_acquires_ok);
51496 + fscache_stat_unchecked(&fscache_n_acquires_ok);
51497 _leave(" = %p", cookie);
51498 return cookie;
51499 }
51500 @@ -168,7 +168,7 @@ static int fscache_acquire_non_index_cookie(struct fscache_cookie *cookie)
51501 cache = fscache_select_cache_for_object(cookie->parent);
51502 if (!cache) {
51503 up_read(&fscache_addremove_sem);
51504 - fscache_stat(&fscache_n_acquires_no_cache);
51505 + fscache_stat_unchecked(&fscache_n_acquires_no_cache);
51506 _leave(" = -ENOMEDIUM [no cache]");
51507 return -ENOMEDIUM;
51508 }
51509 @@ -255,12 +255,12 @@ static int fscache_alloc_object(struct fscache_cache *cache,
51510 object = cache->ops->alloc_object(cache, cookie);
51511 fscache_stat_d(&fscache_n_cop_alloc_object);
51512 if (IS_ERR(object)) {
51513 - fscache_stat(&fscache_n_object_no_alloc);
51514 + fscache_stat_unchecked(&fscache_n_object_no_alloc);
51515 ret = PTR_ERR(object);
51516 goto error;
51517 }
51518
51519 - fscache_stat(&fscache_n_object_alloc);
51520 + fscache_stat_unchecked(&fscache_n_object_alloc);
51521
51522 object->debug_id = atomic_inc_return(&fscache_object_debug_id);
51523
51524 @@ -376,7 +376,7 @@ void __fscache_invalidate(struct fscache_cookie *cookie)
51525
51526 _enter("{%s}", cookie->def->name);
51527
51528 - fscache_stat(&fscache_n_invalidates);
51529 + fscache_stat_unchecked(&fscache_n_invalidates);
51530
51531 /* Only permit invalidation of data files. Invalidating an index will
51532 * require the caller to release all its attachments to the tree rooted
51533 @@ -434,10 +434,10 @@ void __fscache_update_cookie(struct fscache_cookie *cookie)
51534 {
51535 struct fscache_object *object;
51536
51537 - fscache_stat(&fscache_n_updates);
51538 + fscache_stat_unchecked(&fscache_n_updates);
51539
51540 if (!cookie) {
51541 - fscache_stat(&fscache_n_updates_null);
51542 + fscache_stat_unchecked(&fscache_n_updates_null);
51543 _leave(" [no cookie]");
51544 return;
51545 }
51546 @@ -471,12 +471,12 @@ void __fscache_relinquish_cookie(struct fscache_cookie *cookie, int retire)
51547 struct fscache_object *object;
51548 unsigned long event;
51549
51550 - fscache_stat(&fscache_n_relinquishes);
51551 + fscache_stat_unchecked(&fscache_n_relinquishes);
51552 if (retire)
51553 - fscache_stat(&fscache_n_relinquishes_retire);
51554 + fscache_stat_unchecked(&fscache_n_relinquishes_retire);
51555
51556 if (!cookie) {
51557 - fscache_stat(&fscache_n_relinquishes_null);
51558 + fscache_stat_unchecked(&fscache_n_relinquishes_null);
51559 _leave(" [no cookie]");
51560 return;
51561 }
51562 @@ -492,7 +492,7 @@ void __fscache_relinquish_cookie(struct fscache_cookie *cookie, int retire)
51563
51564 /* wait for the cookie to finish being instantiated (or to fail) */
51565 if (test_bit(FSCACHE_COOKIE_CREATING, &cookie->flags)) {
51566 - fscache_stat(&fscache_n_relinquishes_waitcrt);
51567 + fscache_stat_unchecked(&fscache_n_relinquishes_waitcrt);
51568 wait_on_bit(&cookie->flags, FSCACHE_COOKIE_CREATING,
51569 fscache_wait_bit, TASK_UNINTERRUPTIBLE);
51570 }
51571 diff --git a/fs/fscache/internal.h b/fs/fscache/internal.h
51572 index ee38fef..0a326d4 100644
51573 --- a/fs/fscache/internal.h
51574 +++ b/fs/fscache/internal.h
51575 @@ -148,101 +148,101 @@ extern void fscache_proc_cleanup(void);
51576 * stats.c
51577 */
51578 #ifdef CONFIG_FSCACHE_STATS
51579 -extern atomic_t fscache_n_ops_processed[FSCACHE_MAX_THREADS];
51580 -extern atomic_t fscache_n_objs_processed[FSCACHE_MAX_THREADS];
51581 +extern atomic_unchecked_t fscache_n_ops_processed[FSCACHE_MAX_THREADS];
51582 +extern atomic_unchecked_t fscache_n_objs_processed[FSCACHE_MAX_THREADS];
51583
51584 -extern atomic_t fscache_n_op_pend;
51585 -extern atomic_t fscache_n_op_run;
51586 -extern atomic_t fscache_n_op_enqueue;
51587 -extern atomic_t fscache_n_op_deferred_release;
51588 -extern atomic_t fscache_n_op_release;
51589 -extern atomic_t fscache_n_op_gc;
51590 -extern atomic_t fscache_n_op_cancelled;
51591 -extern atomic_t fscache_n_op_rejected;
51592 +extern atomic_unchecked_t fscache_n_op_pend;
51593 +extern atomic_unchecked_t fscache_n_op_run;
51594 +extern atomic_unchecked_t fscache_n_op_enqueue;
51595 +extern atomic_unchecked_t fscache_n_op_deferred_release;
51596 +extern atomic_unchecked_t fscache_n_op_release;
51597 +extern atomic_unchecked_t fscache_n_op_gc;
51598 +extern atomic_unchecked_t fscache_n_op_cancelled;
51599 +extern atomic_unchecked_t fscache_n_op_rejected;
51600
51601 -extern atomic_t fscache_n_attr_changed;
51602 -extern atomic_t fscache_n_attr_changed_ok;
51603 -extern atomic_t fscache_n_attr_changed_nobufs;
51604 -extern atomic_t fscache_n_attr_changed_nomem;
51605 -extern atomic_t fscache_n_attr_changed_calls;
51606 +extern atomic_unchecked_t fscache_n_attr_changed;
51607 +extern atomic_unchecked_t fscache_n_attr_changed_ok;
51608 +extern atomic_unchecked_t fscache_n_attr_changed_nobufs;
51609 +extern atomic_unchecked_t fscache_n_attr_changed_nomem;
51610 +extern atomic_unchecked_t fscache_n_attr_changed_calls;
51611
51612 -extern atomic_t fscache_n_allocs;
51613 -extern atomic_t fscache_n_allocs_ok;
51614 -extern atomic_t fscache_n_allocs_wait;
51615 -extern atomic_t fscache_n_allocs_nobufs;
51616 -extern atomic_t fscache_n_allocs_intr;
51617 -extern atomic_t fscache_n_allocs_object_dead;
51618 -extern atomic_t fscache_n_alloc_ops;
51619 -extern atomic_t fscache_n_alloc_op_waits;
51620 +extern atomic_unchecked_t fscache_n_allocs;
51621 +extern atomic_unchecked_t fscache_n_allocs_ok;
51622 +extern atomic_unchecked_t fscache_n_allocs_wait;
51623 +extern atomic_unchecked_t fscache_n_allocs_nobufs;
51624 +extern atomic_unchecked_t fscache_n_allocs_intr;
51625 +extern atomic_unchecked_t fscache_n_allocs_object_dead;
51626 +extern atomic_unchecked_t fscache_n_alloc_ops;
51627 +extern atomic_unchecked_t fscache_n_alloc_op_waits;
51628
51629 -extern atomic_t fscache_n_retrievals;
51630 -extern atomic_t fscache_n_retrievals_ok;
51631 -extern atomic_t fscache_n_retrievals_wait;
51632 -extern atomic_t fscache_n_retrievals_nodata;
51633 -extern atomic_t fscache_n_retrievals_nobufs;
51634 -extern atomic_t fscache_n_retrievals_intr;
51635 -extern atomic_t fscache_n_retrievals_nomem;
51636 -extern atomic_t fscache_n_retrievals_object_dead;
51637 -extern atomic_t fscache_n_retrieval_ops;
51638 -extern atomic_t fscache_n_retrieval_op_waits;
51639 +extern atomic_unchecked_t fscache_n_retrievals;
51640 +extern atomic_unchecked_t fscache_n_retrievals_ok;
51641 +extern atomic_unchecked_t fscache_n_retrievals_wait;
51642 +extern atomic_unchecked_t fscache_n_retrievals_nodata;
51643 +extern atomic_unchecked_t fscache_n_retrievals_nobufs;
51644 +extern atomic_unchecked_t fscache_n_retrievals_intr;
51645 +extern atomic_unchecked_t fscache_n_retrievals_nomem;
51646 +extern atomic_unchecked_t fscache_n_retrievals_object_dead;
51647 +extern atomic_unchecked_t fscache_n_retrieval_ops;
51648 +extern atomic_unchecked_t fscache_n_retrieval_op_waits;
51649
51650 -extern atomic_t fscache_n_stores;
51651 -extern atomic_t fscache_n_stores_ok;
51652 -extern atomic_t fscache_n_stores_again;
51653 -extern atomic_t fscache_n_stores_nobufs;
51654 -extern atomic_t fscache_n_stores_oom;
51655 -extern atomic_t fscache_n_store_ops;
51656 -extern atomic_t fscache_n_store_calls;
51657 -extern atomic_t fscache_n_store_pages;
51658 -extern atomic_t fscache_n_store_radix_deletes;
51659 -extern atomic_t fscache_n_store_pages_over_limit;
51660 +extern atomic_unchecked_t fscache_n_stores;
51661 +extern atomic_unchecked_t fscache_n_stores_ok;
51662 +extern atomic_unchecked_t fscache_n_stores_again;
51663 +extern atomic_unchecked_t fscache_n_stores_nobufs;
51664 +extern atomic_unchecked_t fscache_n_stores_oom;
51665 +extern atomic_unchecked_t fscache_n_store_ops;
51666 +extern atomic_unchecked_t fscache_n_store_calls;
51667 +extern atomic_unchecked_t fscache_n_store_pages;
51668 +extern atomic_unchecked_t fscache_n_store_radix_deletes;
51669 +extern atomic_unchecked_t fscache_n_store_pages_over_limit;
51670
51671 -extern atomic_t fscache_n_store_vmscan_not_storing;
51672 -extern atomic_t fscache_n_store_vmscan_gone;
51673 -extern atomic_t fscache_n_store_vmscan_busy;
51674 -extern atomic_t fscache_n_store_vmscan_cancelled;
51675 -extern atomic_t fscache_n_store_vmscan_wait;
51676 +extern atomic_unchecked_t fscache_n_store_vmscan_not_storing;
51677 +extern atomic_unchecked_t fscache_n_store_vmscan_gone;
51678 +extern atomic_unchecked_t fscache_n_store_vmscan_busy;
51679 +extern atomic_unchecked_t fscache_n_store_vmscan_cancelled;
51680 +extern atomic_unchecked_t fscache_n_store_vmscan_wait;
51681
51682 -extern atomic_t fscache_n_marks;
51683 -extern atomic_t fscache_n_uncaches;
51684 +extern atomic_unchecked_t fscache_n_marks;
51685 +extern atomic_unchecked_t fscache_n_uncaches;
51686
51687 -extern atomic_t fscache_n_acquires;
51688 -extern atomic_t fscache_n_acquires_null;
51689 -extern atomic_t fscache_n_acquires_no_cache;
51690 -extern atomic_t fscache_n_acquires_ok;
51691 -extern atomic_t fscache_n_acquires_nobufs;
51692 -extern atomic_t fscache_n_acquires_oom;
51693 +extern atomic_unchecked_t fscache_n_acquires;
51694 +extern atomic_unchecked_t fscache_n_acquires_null;
51695 +extern atomic_unchecked_t fscache_n_acquires_no_cache;
51696 +extern atomic_unchecked_t fscache_n_acquires_ok;
51697 +extern atomic_unchecked_t fscache_n_acquires_nobufs;
51698 +extern atomic_unchecked_t fscache_n_acquires_oom;
51699
51700 -extern atomic_t fscache_n_invalidates;
51701 -extern atomic_t fscache_n_invalidates_run;
51702 +extern atomic_unchecked_t fscache_n_invalidates;
51703 +extern atomic_unchecked_t fscache_n_invalidates_run;
51704
51705 -extern atomic_t fscache_n_updates;
51706 -extern atomic_t fscache_n_updates_null;
51707 -extern atomic_t fscache_n_updates_run;
51708 +extern atomic_unchecked_t fscache_n_updates;
51709 +extern atomic_unchecked_t fscache_n_updates_null;
51710 +extern atomic_unchecked_t fscache_n_updates_run;
51711
51712 -extern atomic_t fscache_n_relinquishes;
51713 -extern atomic_t fscache_n_relinquishes_null;
51714 -extern atomic_t fscache_n_relinquishes_waitcrt;
51715 -extern atomic_t fscache_n_relinquishes_retire;
51716 +extern atomic_unchecked_t fscache_n_relinquishes;
51717 +extern atomic_unchecked_t fscache_n_relinquishes_null;
51718 +extern atomic_unchecked_t fscache_n_relinquishes_waitcrt;
51719 +extern atomic_unchecked_t fscache_n_relinquishes_retire;
51720
51721 -extern atomic_t fscache_n_cookie_index;
51722 -extern atomic_t fscache_n_cookie_data;
51723 -extern atomic_t fscache_n_cookie_special;
51724 +extern atomic_unchecked_t fscache_n_cookie_index;
51725 +extern atomic_unchecked_t fscache_n_cookie_data;
51726 +extern atomic_unchecked_t fscache_n_cookie_special;
51727
51728 -extern atomic_t fscache_n_object_alloc;
51729 -extern atomic_t fscache_n_object_no_alloc;
51730 -extern atomic_t fscache_n_object_lookups;
51731 -extern atomic_t fscache_n_object_lookups_negative;
51732 -extern atomic_t fscache_n_object_lookups_positive;
51733 -extern atomic_t fscache_n_object_lookups_timed_out;
51734 -extern atomic_t fscache_n_object_created;
51735 -extern atomic_t fscache_n_object_avail;
51736 -extern atomic_t fscache_n_object_dead;
51737 +extern atomic_unchecked_t fscache_n_object_alloc;
51738 +extern atomic_unchecked_t fscache_n_object_no_alloc;
51739 +extern atomic_unchecked_t fscache_n_object_lookups;
51740 +extern atomic_unchecked_t fscache_n_object_lookups_negative;
51741 +extern atomic_unchecked_t fscache_n_object_lookups_positive;
51742 +extern atomic_unchecked_t fscache_n_object_lookups_timed_out;
51743 +extern atomic_unchecked_t fscache_n_object_created;
51744 +extern atomic_unchecked_t fscache_n_object_avail;
51745 +extern atomic_unchecked_t fscache_n_object_dead;
51746
51747 -extern atomic_t fscache_n_checkaux_none;
51748 -extern atomic_t fscache_n_checkaux_okay;
51749 -extern atomic_t fscache_n_checkaux_update;
51750 -extern atomic_t fscache_n_checkaux_obsolete;
51751 +extern atomic_unchecked_t fscache_n_checkaux_none;
51752 +extern atomic_unchecked_t fscache_n_checkaux_okay;
51753 +extern atomic_unchecked_t fscache_n_checkaux_update;
51754 +extern atomic_unchecked_t fscache_n_checkaux_obsolete;
51755
51756 extern atomic_t fscache_n_cop_alloc_object;
51757 extern atomic_t fscache_n_cop_lookup_object;
51758 @@ -267,6 +267,11 @@ static inline void fscache_stat(atomic_t *stat)
51759 atomic_inc(stat);
51760 }
51761
51762 +static inline void fscache_stat_unchecked(atomic_unchecked_t *stat)
51763 +{
51764 + atomic_inc_unchecked(stat);
51765 +}
51766 +
51767 static inline void fscache_stat_d(atomic_t *stat)
51768 {
51769 atomic_dec(stat);
51770 @@ -279,6 +284,7 @@ extern const struct file_operations fscache_stats_fops;
51771
51772 #define __fscache_stat(stat) (NULL)
51773 #define fscache_stat(stat) do {} while (0)
51774 +#define fscache_stat_unchecked(stat) do {} while (0)
51775 #define fscache_stat_d(stat) do {} while (0)
51776 #endif
51777
51778 diff --git a/fs/fscache/object.c b/fs/fscache/object.c
51779 index 50d41c1..10ee117 100644
51780 --- a/fs/fscache/object.c
51781 +++ b/fs/fscache/object.c
51782 @@ -143,7 +143,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
51783 /* Invalidate an object on disk */
51784 case FSCACHE_OBJECT_INVALIDATING:
51785 clear_bit(FSCACHE_OBJECT_EV_INVALIDATE, &object->events);
51786 - fscache_stat(&fscache_n_invalidates_run);
51787 + fscache_stat_unchecked(&fscache_n_invalidates_run);
51788 fscache_stat(&fscache_n_cop_invalidate_object);
51789 fscache_invalidate_object(object);
51790 fscache_stat_d(&fscache_n_cop_invalidate_object);
51791 @@ -153,7 +153,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
51792 /* update the object metadata on disk */
51793 case FSCACHE_OBJECT_UPDATING:
51794 clear_bit(FSCACHE_OBJECT_EV_UPDATE, &object->events);
51795 - fscache_stat(&fscache_n_updates_run);
51796 + fscache_stat_unchecked(&fscache_n_updates_run);
51797 fscache_stat(&fscache_n_cop_update_object);
51798 object->cache->ops->update_object(object);
51799 fscache_stat_d(&fscache_n_cop_update_object);
51800 @@ -242,7 +242,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
51801 spin_lock(&object->lock);
51802 object->state = FSCACHE_OBJECT_DEAD;
51803 spin_unlock(&object->lock);
51804 - fscache_stat(&fscache_n_object_dead);
51805 + fscache_stat_unchecked(&fscache_n_object_dead);
51806 goto terminal_transit;
51807
51808 /* handle the parent cache of this object being withdrawn from
51809 @@ -257,7 +257,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
51810 spin_lock(&object->lock);
51811 object->state = FSCACHE_OBJECT_DEAD;
51812 spin_unlock(&object->lock);
51813 - fscache_stat(&fscache_n_object_dead);
51814 + fscache_stat_unchecked(&fscache_n_object_dead);
51815 goto terminal_transit;
51816
51817 /* complain about the object being woken up once it is
51818 @@ -495,7 +495,7 @@ static void fscache_lookup_object(struct fscache_object *object)
51819 parent->cookie->def->name, cookie->def->name,
51820 object->cache->tag->name);
51821
51822 - fscache_stat(&fscache_n_object_lookups);
51823 + fscache_stat_unchecked(&fscache_n_object_lookups);
51824 fscache_stat(&fscache_n_cop_lookup_object);
51825 ret = object->cache->ops->lookup_object(object);
51826 fscache_stat_d(&fscache_n_cop_lookup_object);
51827 @@ -506,7 +506,7 @@ static void fscache_lookup_object(struct fscache_object *object)
51828 if (ret == -ETIMEDOUT) {
51829 /* probably stuck behind another object, so move this one to
51830 * the back of the queue */
51831 - fscache_stat(&fscache_n_object_lookups_timed_out);
51832 + fscache_stat_unchecked(&fscache_n_object_lookups_timed_out);
51833 set_bit(FSCACHE_OBJECT_EV_REQUEUE, &object->events);
51834 }
51835
51836 @@ -529,7 +529,7 @@ void fscache_object_lookup_negative(struct fscache_object *object)
51837
51838 spin_lock(&object->lock);
51839 if (object->state == FSCACHE_OBJECT_LOOKING_UP) {
51840 - fscache_stat(&fscache_n_object_lookups_negative);
51841 + fscache_stat_unchecked(&fscache_n_object_lookups_negative);
51842
51843 /* transit here to allow write requests to begin stacking up
51844 * and read requests to begin returning ENODATA */
51845 @@ -575,7 +575,7 @@ void fscache_obtained_object(struct fscache_object *object)
51846 * result, in which case there may be data available */
51847 spin_lock(&object->lock);
51848 if (object->state == FSCACHE_OBJECT_LOOKING_UP) {
51849 - fscache_stat(&fscache_n_object_lookups_positive);
51850 + fscache_stat_unchecked(&fscache_n_object_lookups_positive);
51851
51852 clear_bit(FSCACHE_COOKIE_NO_DATA_YET, &cookie->flags);
51853
51854 @@ -589,7 +589,7 @@ void fscache_obtained_object(struct fscache_object *object)
51855 set_bit(FSCACHE_OBJECT_EV_REQUEUE, &object->events);
51856 } else {
51857 ASSERTCMP(object->state, ==, FSCACHE_OBJECT_CREATING);
51858 - fscache_stat(&fscache_n_object_created);
51859 + fscache_stat_unchecked(&fscache_n_object_created);
51860
51861 object->state = FSCACHE_OBJECT_AVAILABLE;
51862 spin_unlock(&object->lock);
51863 @@ -634,7 +634,7 @@ static void fscache_object_available(struct fscache_object *object)
51864 fscache_enqueue_dependents(object);
51865
51866 fscache_hist(fscache_obj_instantiate_histogram, object->lookup_jif);
51867 - fscache_stat(&fscache_n_object_avail);
51868 + fscache_stat_unchecked(&fscache_n_object_avail);
51869
51870 _leave("");
51871 }
51872 @@ -894,7 +894,7 @@ enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
51873 enum fscache_checkaux result;
51874
51875 if (!object->cookie->def->check_aux) {
51876 - fscache_stat(&fscache_n_checkaux_none);
51877 + fscache_stat_unchecked(&fscache_n_checkaux_none);
51878 return FSCACHE_CHECKAUX_OKAY;
51879 }
51880
51881 @@ -903,17 +903,17 @@ enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
51882 switch (result) {
51883 /* entry okay as is */
51884 case FSCACHE_CHECKAUX_OKAY:
51885 - fscache_stat(&fscache_n_checkaux_okay);
51886 + fscache_stat_unchecked(&fscache_n_checkaux_okay);
51887 break;
51888
51889 /* entry requires update */
51890 case FSCACHE_CHECKAUX_NEEDS_UPDATE:
51891 - fscache_stat(&fscache_n_checkaux_update);
51892 + fscache_stat_unchecked(&fscache_n_checkaux_update);
51893 break;
51894
51895 /* entry requires deletion */
51896 case FSCACHE_CHECKAUX_OBSOLETE:
51897 - fscache_stat(&fscache_n_checkaux_obsolete);
51898 + fscache_stat_unchecked(&fscache_n_checkaux_obsolete);
51899 break;
51900
51901 default:
51902 diff --git a/fs/fscache/operation.c b/fs/fscache/operation.c
51903 index 762a9ec..2023284 100644
51904 --- a/fs/fscache/operation.c
51905 +++ b/fs/fscache/operation.c
51906 @@ -17,7 +17,7 @@
51907 #include <linux/slab.h>
51908 #include "internal.h"
51909
51910 -atomic_t fscache_op_debug_id;
51911 +atomic_unchecked_t fscache_op_debug_id;
51912 EXPORT_SYMBOL(fscache_op_debug_id);
51913
51914 /**
51915 @@ -39,7 +39,7 @@ void fscache_enqueue_operation(struct fscache_operation *op)
51916 ASSERTCMP(atomic_read(&op->usage), >, 0);
51917 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_IN_PROGRESS);
51918
51919 - fscache_stat(&fscache_n_op_enqueue);
51920 + fscache_stat_unchecked(&fscache_n_op_enqueue);
51921 switch (op->flags & FSCACHE_OP_TYPE) {
51922 case FSCACHE_OP_ASYNC:
51923 _debug("queue async");
51924 @@ -73,7 +73,7 @@ static void fscache_run_op(struct fscache_object *object,
51925 wake_up_bit(&op->flags, FSCACHE_OP_WAITING);
51926 if (op->processor)
51927 fscache_enqueue_operation(op);
51928 - fscache_stat(&fscache_n_op_run);
51929 + fscache_stat_unchecked(&fscache_n_op_run);
51930 }
51931
51932 /*
51933 @@ -105,11 +105,11 @@ int fscache_submit_exclusive_op(struct fscache_object *object,
51934 if (object->n_in_progress > 0) {
51935 atomic_inc(&op->usage);
51936 list_add_tail(&op->pend_link, &object->pending_ops);
51937 - fscache_stat(&fscache_n_op_pend);
51938 + fscache_stat_unchecked(&fscache_n_op_pend);
51939 } else if (!list_empty(&object->pending_ops)) {
51940 atomic_inc(&op->usage);
51941 list_add_tail(&op->pend_link, &object->pending_ops);
51942 - fscache_stat(&fscache_n_op_pend);
51943 + fscache_stat_unchecked(&fscache_n_op_pend);
51944 fscache_start_operations(object);
51945 } else {
51946 ASSERTCMP(object->n_in_progress, ==, 0);
51947 @@ -125,7 +125,7 @@ int fscache_submit_exclusive_op(struct fscache_object *object,
51948 object->n_exclusive++; /* reads and writes must wait */
51949 atomic_inc(&op->usage);
51950 list_add_tail(&op->pend_link, &object->pending_ops);
51951 - fscache_stat(&fscache_n_op_pend);
51952 + fscache_stat_unchecked(&fscache_n_op_pend);
51953 ret = 0;
51954 } else {
51955 /* If we're in any other state, there must have been an I/O
51956 @@ -215,11 +215,11 @@ int fscache_submit_op(struct fscache_object *object,
51957 if (object->n_exclusive > 0) {
51958 atomic_inc(&op->usage);
51959 list_add_tail(&op->pend_link, &object->pending_ops);
51960 - fscache_stat(&fscache_n_op_pend);
51961 + fscache_stat_unchecked(&fscache_n_op_pend);
51962 } else if (!list_empty(&object->pending_ops)) {
51963 atomic_inc(&op->usage);
51964 list_add_tail(&op->pend_link, &object->pending_ops);
51965 - fscache_stat(&fscache_n_op_pend);
51966 + fscache_stat_unchecked(&fscache_n_op_pend);
51967 fscache_start_operations(object);
51968 } else {
51969 ASSERTCMP(object->n_exclusive, ==, 0);
51970 @@ -231,12 +231,12 @@ int fscache_submit_op(struct fscache_object *object,
51971 object->n_ops++;
51972 atomic_inc(&op->usage);
51973 list_add_tail(&op->pend_link, &object->pending_ops);
51974 - fscache_stat(&fscache_n_op_pend);
51975 + fscache_stat_unchecked(&fscache_n_op_pend);
51976 ret = 0;
51977 } else if (object->state == FSCACHE_OBJECT_DYING ||
51978 object->state == FSCACHE_OBJECT_LC_DYING ||
51979 object->state == FSCACHE_OBJECT_WITHDRAWING) {
51980 - fscache_stat(&fscache_n_op_rejected);
51981 + fscache_stat_unchecked(&fscache_n_op_rejected);
51982 op->state = FSCACHE_OP_ST_CANCELLED;
51983 ret = -ENOBUFS;
51984 } else if (!test_bit(FSCACHE_IOERROR, &object->cache->flags)) {
51985 @@ -315,7 +315,7 @@ int fscache_cancel_op(struct fscache_operation *op,
51986 ret = -EBUSY;
51987 if (op->state == FSCACHE_OP_ST_PENDING) {
51988 ASSERT(!list_empty(&op->pend_link));
51989 - fscache_stat(&fscache_n_op_cancelled);
51990 + fscache_stat_unchecked(&fscache_n_op_cancelled);
51991 list_del_init(&op->pend_link);
51992 if (do_cancel)
51993 do_cancel(op);
51994 @@ -347,7 +347,7 @@ void fscache_cancel_all_ops(struct fscache_object *object)
51995 while (!list_empty(&object->pending_ops)) {
51996 op = list_entry(object->pending_ops.next,
51997 struct fscache_operation, pend_link);
51998 - fscache_stat(&fscache_n_op_cancelled);
51999 + fscache_stat_unchecked(&fscache_n_op_cancelled);
52000 list_del_init(&op->pend_link);
52001
52002 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_PENDING);
52003 @@ -419,7 +419,7 @@ void fscache_put_operation(struct fscache_operation *op)
52004 op->state, ==, FSCACHE_OP_ST_CANCELLED);
52005 op->state = FSCACHE_OP_ST_DEAD;
52006
52007 - fscache_stat(&fscache_n_op_release);
52008 + fscache_stat_unchecked(&fscache_n_op_release);
52009
52010 if (op->release) {
52011 op->release(op);
52012 @@ -442,7 +442,7 @@ void fscache_put_operation(struct fscache_operation *op)
52013 * lock, and defer it otherwise */
52014 if (!spin_trylock(&object->lock)) {
52015 _debug("defer put");
52016 - fscache_stat(&fscache_n_op_deferred_release);
52017 + fscache_stat_unchecked(&fscache_n_op_deferred_release);
52018
52019 cache = object->cache;
52020 spin_lock(&cache->op_gc_list_lock);
52021 @@ -495,7 +495,7 @@ void fscache_operation_gc(struct work_struct *work)
52022
52023 _debug("GC DEFERRED REL OBJ%x OP%x",
52024 object->debug_id, op->debug_id);
52025 - fscache_stat(&fscache_n_op_gc);
52026 + fscache_stat_unchecked(&fscache_n_op_gc);
52027
52028 ASSERTCMP(atomic_read(&op->usage), ==, 0);
52029 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_DEAD);
52030 diff --git a/fs/fscache/page.c b/fs/fscache/page.c
52031 index ff000e5..c44ec6d 100644
52032 --- a/fs/fscache/page.c
52033 +++ b/fs/fscache/page.c
52034 @@ -61,7 +61,7 @@ try_again:
52035 val = radix_tree_lookup(&cookie->stores, page->index);
52036 if (!val) {
52037 rcu_read_unlock();
52038 - fscache_stat(&fscache_n_store_vmscan_not_storing);
52039 + fscache_stat_unchecked(&fscache_n_store_vmscan_not_storing);
52040 __fscache_uncache_page(cookie, page);
52041 return true;
52042 }
52043 @@ -91,11 +91,11 @@ try_again:
52044 spin_unlock(&cookie->stores_lock);
52045
52046 if (xpage) {
52047 - fscache_stat(&fscache_n_store_vmscan_cancelled);
52048 - fscache_stat(&fscache_n_store_radix_deletes);
52049 + fscache_stat_unchecked(&fscache_n_store_vmscan_cancelled);
52050 + fscache_stat_unchecked(&fscache_n_store_radix_deletes);
52051 ASSERTCMP(xpage, ==, page);
52052 } else {
52053 - fscache_stat(&fscache_n_store_vmscan_gone);
52054 + fscache_stat_unchecked(&fscache_n_store_vmscan_gone);
52055 }
52056
52057 wake_up_bit(&cookie->flags, 0);
52058 @@ -110,11 +110,11 @@ page_busy:
52059 * sleeping on memory allocation, so we may need to impose a timeout
52060 * too. */
52061 if (!(gfp & __GFP_WAIT)) {
52062 - fscache_stat(&fscache_n_store_vmscan_busy);
52063 + fscache_stat_unchecked(&fscache_n_store_vmscan_busy);
52064 return false;
52065 }
52066
52067 - fscache_stat(&fscache_n_store_vmscan_wait);
52068 + fscache_stat_unchecked(&fscache_n_store_vmscan_wait);
52069 __fscache_wait_on_page_write(cookie, page);
52070 gfp &= ~__GFP_WAIT;
52071 goto try_again;
52072 @@ -140,7 +140,7 @@ static void fscache_end_page_write(struct fscache_object *object,
52073 FSCACHE_COOKIE_STORING_TAG);
52074 if (!radix_tree_tag_get(&cookie->stores, page->index,
52075 FSCACHE_COOKIE_PENDING_TAG)) {
52076 - fscache_stat(&fscache_n_store_radix_deletes);
52077 + fscache_stat_unchecked(&fscache_n_store_radix_deletes);
52078 xpage = radix_tree_delete(&cookie->stores, page->index);
52079 }
52080 spin_unlock(&cookie->stores_lock);
52081 @@ -161,7 +161,7 @@ static void fscache_attr_changed_op(struct fscache_operation *op)
52082
52083 _enter("{OBJ%x OP%x}", object->debug_id, op->debug_id);
52084
52085 - fscache_stat(&fscache_n_attr_changed_calls);
52086 + fscache_stat_unchecked(&fscache_n_attr_changed_calls);
52087
52088 if (fscache_object_is_active(object)) {
52089 fscache_stat(&fscache_n_cop_attr_changed);
52090 @@ -187,11 +187,11 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
52091
52092 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
52093
52094 - fscache_stat(&fscache_n_attr_changed);
52095 + fscache_stat_unchecked(&fscache_n_attr_changed);
52096
52097 op = kzalloc(sizeof(*op), GFP_KERNEL);
52098 if (!op) {
52099 - fscache_stat(&fscache_n_attr_changed_nomem);
52100 + fscache_stat_unchecked(&fscache_n_attr_changed_nomem);
52101 _leave(" = -ENOMEM");
52102 return -ENOMEM;
52103 }
52104 @@ -209,7 +209,7 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
52105 if (fscache_submit_exclusive_op(object, op) < 0)
52106 goto nobufs;
52107 spin_unlock(&cookie->lock);
52108 - fscache_stat(&fscache_n_attr_changed_ok);
52109 + fscache_stat_unchecked(&fscache_n_attr_changed_ok);
52110 fscache_put_operation(op);
52111 _leave(" = 0");
52112 return 0;
52113 @@ -217,7 +217,7 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
52114 nobufs:
52115 spin_unlock(&cookie->lock);
52116 kfree(op);
52117 - fscache_stat(&fscache_n_attr_changed_nobufs);
52118 + fscache_stat_unchecked(&fscache_n_attr_changed_nobufs);
52119 _leave(" = %d", -ENOBUFS);
52120 return -ENOBUFS;
52121 }
52122 @@ -255,7 +255,7 @@ static struct fscache_retrieval *fscache_alloc_retrieval(
52123 /* allocate a retrieval operation and attempt to submit it */
52124 op = kzalloc(sizeof(*op), GFP_NOIO);
52125 if (!op) {
52126 - fscache_stat(&fscache_n_retrievals_nomem);
52127 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
52128 return NULL;
52129 }
52130
52131 @@ -283,13 +283,13 @@ static int fscache_wait_for_deferred_lookup(struct fscache_cookie *cookie)
52132 return 0;
52133 }
52134
52135 - fscache_stat(&fscache_n_retrievals_wait);
52136 + fscache_stat_unchecked(&fscache_n_retrievals_wait);
52137
52138 jif = jiffies;
52139 if (wait_on_bit(&cookie->flags, FSCACHE_COOKIE_LOOKING_UP,
52140 fscache_wait_bit_interruptible,
52141 TASK_INTERRUPTIBLE) != 0) {
52142 - fscache_stat(&fscache_n_retrievals_intr);
52143 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
52144 _leave(" = -ERESTARTSYS");
52145 return -ERESTARTSYS;
52146 }
52147 @@ -318,8 +318,8 @@ static void fscache_do_cancel_retrieval(struct fscache_operation *_op)
52148 */
52149 static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
52150 struct fscache_retrieval *op,
52151 - atomic_t *stat_op_waits,
52152 - atomic_t *stat_object_dead)
52153 + atomic_unchecked_t *stat_op_waits,
52154 + atomic_unchecked_t *stat_object_dead)
52155 {
52156 int ret;
52157
52158 @@ -327,7 +327,7 @@ static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
52159 goto check_if_dead;
52160
52161 _debug(">>> WT");
52162 - fscache_stat(stat_op_waits);
52163 + fscache_stat_unchecked(stat_op_waits);
52164 if (wait_on_bit(&op->op.flags, FSCACHE_OP_WAITING,
52165 fscache_wait_bit_interruptible,
52166 TASK_INTERRUPTIBLE) != 0) {
52167 @@ -344,14 +344,14 @@ static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
52168
52169 check_if_dead:
52170 if (op->op.state == FSCACHE_OP_ST_CANCELLED) {
52171 - fscache_stat(stat_object_dead);
52172 + fscache_stat_unchecked(stat_object_dead);
52173 _leave(" = -ENOBUFS [cancelled]");
52174 return -ENOBUFS;
52175 }
52176 if (unlikely(fscache_object_is_dead(object))) {
52177 pr_err("%s() = -ENOBUFS [obj dead %d]\n", __func__, op->op.state);
52178 fscache_cancel_op(&op->op, fscache_do_cancel_retrieval);
52179 - fscache_stat(stat_object_dead);
52180 + fscache_stat_unchecked(stat_object_dead);
52181 return -ENOBUFS;
52182 }
52183 return 0;
52184 @@ -378,7 +378,7 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
52185
52186 _enter("%p,%p,,,", cookie, page);
52187
52188 - fscache_stat(&fscache_n_retrievals);
52189 + fscache_stat_unchecked(&fscache_n_retrievals);
52190
52191 if (hlist_empty(&cookie->backing_objects))
52192 goto nobufs;
52193 @@ -417,7 +417,7 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
52194 goto nobufs_unlock_dec;
52195 spin_unlock(&cookie->lock);
52196
52197 - fscache_stat(&fscache_n_retrieval_ops);
52198 + fscache_stat_unchecked(&fscache_n_retrieval_ops);
52199
52200 /* pin the netfs read context in case we need to do the actual netfs
52201 * read because we've encountered a cache read failure */
52202 @@ -447,15 +447,15 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
52203
52204 error:
52205 if (ret == -ENOMEM)
52206 - fscache_stat(&fscache_n_retrievals_nomem);
52207 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
52208 else if (ret == -ERESTARTSYS)
52209 - fscache_stat(&fscache_n_retrievals_intr);
52210 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
52211 else if (ret == -ENODATA)
52212 - fscache_stat(&fscache_n_retrievals_nodata);
52213 + fscache_stat_unchecked(&fscache_n_retrievals_nodata);
52214 else if (ret < 0)
52215 - fscache_stat(&fscache_n_retrievals_nobufs);
52216 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
52217 else
52218 - fscache_stat(&fscache_n_retrievals_ok);
52219 + fscache_stat_unchecked(&fscache_n_retrievals_ok);
52220
52221 fscache_put_retrieval(op);
52222 _leave(" = %d", ret);
52223 @@ -467,7 +467,7 @@ nobufs_unlock:
52224 spin_unlock(&cookie->lock);
52225 kfree(op);
52226 nobufs:
52227 - fscache_stat(&fscache_n_retrievals_nobufs);
52228 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
52229 _leave(" = -ENOBUFS");
52230 return -ENOBUFS;
52231 }
52232 @@ -505,7 +505,7 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
52233
52234 _enter("%p,,%d,,,", cookie, *nr_pages);
52235
52236 - fscache_stat(&fscache_n_retrievals);
52237 + fscache_stat_unchecked(&fscache_n_retrievals);
52238
52239 if (hlist_empty(&cookie->backing_objects))
52240 goto nobufs;
52241 @@ -541,7 +541,7 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
52242 goto nobufs_unlock_dec;
52243 spin_unlock(&cookie->lock);
52244
52245 - fscache_stat(&fscache_n_retrieval_ops);
52246 + fscache_stat_unchecked(&fscache_n_retrieval_ops);
52247
52248 /* pin the netfs read context in case we need to do the actual netfs
52249 * read because we've encountered a cache read failure */
52250 @@ -571,15 +571,15 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
52251
52252 error:
52253 if (ret == -ENOMEM)
52254 - fscache_stat(&fscache_n_retrievals_nomem);
52255 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
52256 else if (ret == -ERESTARTSYS)
52257 - fscache_stat(&fscache_n_retrievals_intr);
52258 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
52259 else if (ret == -ENODATA)
52260 - fscache_stat(&fscache_n_retrievals_nodata);
52261 + fscache_stat_unchecked(&fscache_n_retrievals_nodata);
52262 else if (ret < 0)
52263 - fscache_stat(&fscache_n_retrievals_nobufs);
52264 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
52265 else
52266 - fscache_stat(&fscache_n_retrievals_ok);
52267 + fscache_stat_unchecked(&fscache_n_retrievals_ok);
52268
52269 fscache_put_retrieval(op);
52270 _leave(" = %d", ret);
52271 @@ -591,7 +591,7 @@ nobufs_unlock:
52272 spin_unlock(&cookie->lock);
52273 kfree(op);
52274 nobufs:
52275 - fscache_stat(&fscache_n_retrievals_nobufs);
52276 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
52277 _leave(" = -ENOBUFS");
52278 return -ENOBUFS;
52279 }
52280 @@ -615,7 +615,7 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
52281
52282 _enter("%p,%p,,,", cookie, page);
52283
52284 - fscache_stat(&fscache_n_allocs);
52285 + fscache_stat_unchecked(&fscache_n_allocs);
52286
52287 if (hlist_empty(&cookie->backing_objects))
52288 goto nobufs;
52289 @@ -647,7 +647,7 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
52290 goto nobufs_unlock;
52291 spin_unlock(&cookie->lock);
52292
52293 - fscache_stat(&fscache_n_alloc_ops);
52294 + fscache_stat_unchecked(&fscache_n_alloc_ops);
52295
52296 ret = fscache_wait_for_retrieval_activation(
52297 object, op,
52298 @@ -663,11 +663,11 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
52299
52300 error:
52301 if (ret == -ERESTARTSYS)
52302 - fscache_stat(&fscache_n_allocs_intr);
52303 + fscache_stat_unchecked(&fscache_n_allocs_intr);
52304 else if (ret < 0)
52305 - fscache_stat(&fscache_n_allocs_nobufs);
52306 + fscache_stat_unchecked(&fscache_n_allocs_nobufs);
52307 else
52308 - fscache_stat(&fscache_n_allocs_ok);
52309 + fscache_stat_unchecked(&fscache_n_allocs_ok);
52310
52311 fscache_put_retrieval(op);
52312 _leave(" = %d", ret);
52313 @@ -677,7 +677,7 @@ nobufs_unlock:
52314 spin_unlock(&cookie->lock);
52315 kfree(op);
52316 nobufs:
52317 - fscache_stat(&fscache_n_allocs_nobufs);
52318 + fscache_stat_unchecked(&fscache_n_allocs_nobufs);
52319 _leave(" = -ENOBUFS");
52320 return -ENOBUFS;
52321 }
52322 @@ -736,7 +736,7 @@ static void fscache_write_op(struct fscache_operation *_op)
52323
52324 spin_lock(&cookie->stores_lock);
52325
52326 - fscache_stat(&fscache_n_store_calls);
52327 + fscache_stat_unchecked(&fscache_n_store_calls);
52328
52329 /* find a page to store */
52330 page = NULL;
52331 @@ -747,7 +747,7 @@ static void fscache_write_op(struct fscache_operation *_op)
52332 page = results[0];
52333 _debug("gang %d [%lx]", n, page->index);
52334 if (page->index > op->store_limit) {
52335 - fscache_stat(&fscache_n_store_pages_over_limit);
52336 + fscache_stat_unchecked(&fscache_n_store_pages_over_limit);
52337 goto superseded;
52338 }
52339
52340 @@ -759,7 +759,7 @@ static void fscache_write_op(struct fscache_operation *_op)
52341 spin_unlock(&cookie->stores_lock);
52342 spin_unlock(&object->lock);
52343
52344 - fscache_stat(&fscache_n_store_pages);
52345 + fscache_stat_unchecked(&fscache_n_store_pages);
52346 fscache_stat(&fscache_n_cop_write_page);
52347 ret = object->cache->ops->write_page(op, page);
52348 fscache_stat_d(&fscache_n_cop_write_page);
52349 @@ -860,7 +860,7 @@ int __fscache_write_page(struct fscache_cookie *cookie,
52350 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
52351 ASSERT(PageFsCache(page));
52352
52353 - fscache_stat(&fscache_n_stores);
52354 + fscache_stat_unchecked(&fscache_n_stores);
52355
52356 if (test_bit(FSCACHE_COOKIE_INVALIDATING, &cookie->flags)) {
52357 _leave(" = -ENOBUFS [invalidating]");
52358 @@ -916,7 +916,7 @@ int __fscache_write_page(struct fscache_cookie *cookie,
52359 spin_unlock(&cookie->stores_lock);
52360 spin_unlock(&object->lock);
52361
52362 - op->op.debug_id = atomic_inc_return(&fscache_op_debug_id);
52363 + op->op.debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
52364 op->store_limit = object->store_limit;
52365
52366 if (fscache_submit_op(object, &op->op) < 0)
52367 @@ -924,8 +924,8 @@ int __fscache_write_page(struct fscache_cookie *cookie,
52368
52369 spin_unlock(&cookie->lock);
52370 radix_tree_preload_end();
52371 - fscache_stat(&fscache_n_store_ops);
52372 - fscache_stat(&fscache_n_stores_ok);
52373 + fscache_stat_unchecked(&fscache_n_store_ops);
52374 + fscache_stat_unchecked(&fscache_n_stores_ok);
52375
52376 /* the work queue now carries its own ref on the object */
52377 fscache_put_operation(&op->op);
52378 @@ -933,14 +933,14 @@ int __fscache_write_page(struct fscache_cookie *cookie,
52379 return 0;
52380
52381 already_queued:
52382 - fscache_stat(&fscache_n_stores_again);
52383 + fscache_stat_unchecked(&fscache_n_stores_again);
52384 already_pending:
52385 spin_unlock(&cookie->stores_lock);
52386 spin_unlock(&object->lock);
52387 spin_unlock(&cookie->lock);
52388 radix_tree_preload_end();
52389 kfree(op);
52390 - fscache_stat(&fscache_n_stores_ok);
52391 + fscache_stat_unchecked(&fscache_n_stores_ok);
52392 _leave(" = 0");
52393 return 0;
52394
52395 @@ -959,14 +959,14 @@ nobufs:
52396 spin_unlock(&cookie->lock);
52397 radix_tree_preload_end();
52398 kfree(op);
52399 - fscache_stat(&fscache_n_stores_nobufs);
52400 + fscache_stat_unchecked(&fscache_n_stores_nobufs);
52401 _leave(" = -ENOBUFS");
52402 return -ENOBUFS;
52403
52404 nomem_free:
52405 kfree(op);
52406 nomem:
52407 - fscache_stat(&fscache_n_stores_oom);
52408 + fscache_stat_unchecked(&fscache_n_stores_oom);
52409 _leave(" = -ENOMEM");
52410 return -ENOMEM;
52411 }
52412 @@ -984,7 +984,7 @@ void __fscache_uncache_page(struct fscache_cookie *cookie, struct page *page)
52413 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
52414 ASSERTCMP(page, !=, NULL);
52415
52416 - fscache_stat(&fscache_n_uncaches);
52417 + fscache_stat_unchecked(&fscache_n_uncaches);
52418
52419 /* cache withdrawal may beat us to it */
52420 if (!PageFsCache(page))
52421 @@ -1035,7 +1035,7 @@ void fscache_mark_page_cached(struct fscache_retrieval *op, struct page *page)
52422 struct fscache_cookie *cookie = op->op.object->cookie;
52423
52424 #ifdef CONFIG_FSCACHE_STATS
52425 - atomic_inc(&fscache_n_marks);
52426 + atomic_inc_unchecked(&fscache_n_marks);
52427 #endif
52428
52429 _debug("- mark %p{%lx}", page, page->index);
52430 diff --git a/fs/fscache/stats.c b/fs/fscache/stats.c
52431 index 40d13c7..ddf52b9 100644
52432 --- a/fs/fscache/stats.c
52433 +++ b/fs/fscache/stats.c
52434 @@ -18,99 +18,99 @@
52435 /*
52436 * operation counters
52437 */
52438 -atomic_t fscache_n_op_pend;
52439 -atomic_t fscache_n_op_run;
52440 -atomic_t fscache_n_op_enqueue;
52441 -atomic_t fscache_n_op_requeue;
52442 -atomic_t fscache_n_op_deferred_release;
52443 -atomic_t fscache_n_op_release;
52444 -atomic_t fscache_n_op_gc;
52445 -atomic_t fscache_n_op_cancelled;
52446 -atomic_t fscache_n_op_rejected;
52447 +atomic_unchecked_t fscache_n_op_pend;
52448 +atomic_unchecked_t fscache_n_op_run;
52449 +atomic_unchecked_t fscache_n_op_enqueue;
52450 +atomic_unchecked_t fscache_n_op_requeue;
52451 +atomic_unchecked_t fscache_n_op_deferred_release;
52452 +atomic_unchecked_t fscache_n_op_release;
52453 +atomic_unchecked_t fscache_n_op_gc;
52454 +atomic_unchecked_t fscache_n_op_cancelled;
52455 +atomic_unchecked_t fscache_n_op_rejected;
52456
52457 -atomic_t fscache_n_attr_changed;
52458 -atomic_t fscache_n_attr_changed_ok;
52459 -atomic_t fscache_n_attr_changed_nobufs;
52460 -atomic_t fscache_n_attr_changed_nomem;
52461 -atomic_t fscache_n_attr_changed_calls;
52462 +atomic_unchecked_t fscache_n_attr_changed;
52463 +atomic_unchecked_t fscache_n_attr_changed_ok;
52464 +atomic_unchecked_t fscache_n_attr_changed_nobufs;
52465 +atomic_unchecked_t fscache_n_attr_changed_nomem;
52466 +atomic_unchecked_t fscache_n_attr_changed_calls;
52467
52468 -atomic_t fscache_n_allocs;
52469 -atomic_t fscache_n_allocs_ok;
52470 -atomic_t fscache_n_allocs_wait;
52471 -atomic_t fscache_n_allocs_nobufs;
52472 -atomic_t fscache_n_allocs_intr;
52473 -atomic_t fscache_n_allocs_object_dead;
52474 -atomic_t fscache_n_alloc_ops;
52475 -atomic_t fscache_n_alloc_op_waits;
52476 +atomic_unchecked_t fscache_n_allocs;
52477 +atomic_unchecked_t fscache_n_allocs_ok;
52478 +atomic_unchecked_t fscache_n_allocs_wait;
52479 +atomic_unchecked_t fscache_n_allocs_nobufs;
52480 +atomic_unchecked_t fscache_n_allocs_intr;
52481 +atomic_unchecked_t fscache_n_allocs_object_dead;
52482 +atomic_unchecked_t fscache_n_alloc_ops;
52483 +atomic_unchecked_t fscache_n_alloc_op_waits;
52484
52485 -atomic_t fscache_n_retrievals;
52486 -atomic_t fscache_n_retrievals_ok;
52487 -atomic_t fscache_n_retrievals_wait;
52488 -atomic_t fscache_n_retrievals_nodata;
52489 -atomic_t fscache_n_retrievals_nobufs;
52490 -atomic_t fscache_n_retrievals_intr;
52491 -atomic_t fscache_n_retrievals_nomem;
52492 -atomic_t fscache_n_retrievals_object_dead;
52493 -atomic_t fscache_n_retrieval_ops;
52494 -atomic_t fscache_n_retrieval_op_waits;
52495 +atomic_unchecked_t fscache_n_retrievals;
52496 +atomic_unchecked_t fscache_n_retrievals_ok;
52497 +atomic_unchecked_t fscache_n_retrievals_wait;
52498 +atomic_unchecked_t fscache_n_retrievals_nodata;
52499 +atomic_unchecked_t fscache_n_retrievals_nobufs;
52500 +atomic_unchecked_t fscache_n_retrievals_intr;
52501 +atomic_unchecked_t fscache_n_retrievals_nomem;
52502 +atomic_unchecked_t fscache_n_retrievals_object_dead;
52503 +atomic_unchecked_t fscache_n_retrieval_ops;
52504 +atomic_unchecked_t fscache_n_retrieval_op_waits;
52505
52506 -atomic_t fscache_n_stores;
52507 -atomic_t fscache_n_stores_ok;
52508 -atomic_t fscache_n_stores_again;
52509 -atomic_t fscache_n_stores_nobufs;
52510 -atomic_t fscache_n_stores_oom;
52511 -atomic_t fscache_n_store_ops;
52512 -atomic_t fscache_n_store_calls;
52513 -atomic_t fscache_n_store_pages;
52514 -atomic_t fscache_n_store_radix_deletes;
52515 -atomic_t fscache_n_store_pages_over_limit;
52516 +atomic_unchecked_t fscache_n_stores;
52517 +atomic_unchecked_t fscache_n_stores_ok;
52518 +atomic_unchecked_t fscache_n_stores_again;
52519 +atomic_unchecked_t fscache_n_stores_nobufs;
52520 +atomic_unchecked_t fscache_n_stores_oom;
52521 +atomic_unchecked_t fscache_n_store_ops;
52522 +atomic_unchecked_t fscache_n_store_calls;
52523 +atomic_unchecked_t fscache_n_store_pages;
52524 +atomic_unchecked_t fscache_n_store_radix_deletes;
52525 +atomic_unchecked_t fscache_n_store_pages_over_limit;
52526
52527 -atomic_t fscache_n_store_vmscan_not_storing;
52528 -atomic_t fscache_n_store_vmscan_gone;
52529 -atomic_t fscache_n_store_vmscan_busy;
52530 -atomic_t fscache_n_store_vmscan_cancelled;
52531 -atomic_t fscache_n_store_vmscan_wait;
52532 +atomic_unchecked_t fscache_n_store_vmscan_not_storing;
52533 +atomic_unchecked_t fscache_n_store_vmscan_gone;
52534 +atomic_unchecked_t fscache_n_store_vmscan_busy;
52535 +atomic_unchecked_t fscache_n_store_vmscan_cancelled;
52536 +atomic_unchecked_t fscache_n_store_vmscan_wait;
52537
52538 -atomic_t fscache_n_marks;
52539 -atomic_t fscache_n_uncaches;
52540 +atomic_unchecked_t fscache_n_marks;
52541 +atomic_unchecked_t fscache_n_uncaches;
52542
52543 -atomic_t fscache_n_acquires;
52544 -atomic_t fscache_n_acquires_null;
52545 -atomic_t fscache_n_acquires_no_cache;
52546 -atomic_t fscache_n_acquires_ok;
52547 -atomic_t fscache_n_acquires_nobufs;
52548 -atomic_t fscache_n_acquires_oom;
52549 +atomic_unchecked_t fscache_n_acquires;
52550 +atomic_unchecked_t fscache_n_acquires_null;
52551 +atomic_unchecked_t fscache_n_acquires_no_cache;
52552 +atomic_unchecked_t fscache_n_acquires_ok;
52553 +atomic_unchecked_t fscache_n_acquires_nobufs;
52554 +atomic_unchecked_t fscache_n_acquires_oom;
52555
52556 -atomic_t fscache_n_invalidates;
52557 -atomic_t fscache_n_invalidates_run;
52558 +atomic_unchecked_t fscache_n_invalidates;
52559 +atomic_unchecked_t fscache_n_invalidates_run;
52560
52561 -atomic_t fscache_n_updates;
52562 -atomic_t fscache_n_updates_null;
52563 -atomic_t fscache_n_updates_run;
52564 +atomic_unchecked_t fscache_n_updates;
52565 +atomic_unchecked_t fscache_n_updates_null;
52566 +atomic_unchecked_t fscache_n_updates_run;
52567
52568 -atomic_t fscache_n_relinquishes;
52569 -atomic_t fscache_n_relinquishes_null;
52570 -atomic_t fscache_n_relinquishes_waitcrt;
52571 -atomic_t fscache_n_relinquishes_retire;
52572 +atomic_unchecked_t fscache_n_relinquishes;
52573 +atomic_unchecked_t fscache_n_relinquishes_null;
52574 +atomic_unchecked_t fscache_n_relinquishes_waitcrt;
52575 +atomic_unchecked_t fscache_n_relinquishes_retire;
52576
52577 -atomic_t fscache_n_cookie_index;
52578 -atomic_t fscache_n_cookie_data;
52579 -atomic_t fscache_n_cookie_special;
52580 +atomic_unchecked_t fscache_n_cookie_index;
52581 +atomic_unchecked_t fscache_n_cookie_data;
52582 +atomic_unchecked_t fscache_n_cookie_special;
52583
52584 -atomic_t fscache_n_object_alloc;
52585 -atomic_t fscache_n_object_no_alloc;
52586 -atomic_t fscache_n_object_lookups;
52587 -atomic_t fscache_n_object_lookups_negative;
52588 -atomic_t fscache_n_object_lookups_positive;
52589 -atomic_t fscache_n_object_lookups_timed_out;
52590 -atomic_t fscache_n_object_created;
52591 -atomic_t fscache_n_object_avail;
52592 -atomic_t fscache_n_object_dead;
52593 +atomic_unchecked_t fscache_n_object_alloc;
52594 +atomic_unchecked_t fscache_n_object_no_alloc;
52595 +atomic_unchecked_t fscache_n_object_lookups;
52596 +atomic_unchecked_t fscache_n_object_lookups_negative;
52597 +atomic_unchecked_t fscache_n_object_lookups_positive;
52598 +atomic_unchecked_t fscache_n_object_lookups_timed_out;
52599 +atomic_unchecked_t fscache_n_object_created;
52600 +atomic_unchecked_t fscache_n_object_avail;
52601 +atomic_unchecked_t fscache_n_object_dead;
52602
52603 -atomic_t fscache_n_checkaux_none;
52604 -atomic_t fscache_n_checkaux_okay;
52605 -atomic_t fscache_n_checkaux_update;
52606 -atomic_t fscache_n_checkaux_obsolete;
52607 +atomic_unchecked_t fscache_n_checkaux_none;
52608 +atomic_unchecked_t fscache_n_checkaux_okay;
52609 +atomic_unchecked_t fscache_n_checkaux_update;
52610 +atomic_unchecked_t fscache_n_checkaux_obsolete;
52611
52612 atomic_t fscache_n_cop_alloc_object;
52613 atomic_t fscache_n_cop_lookup_object;
52614 @@ -138,118 +138,118 @@ static int fscache_stats_show(struct seq_file *m, void *v)
52615 seq_puts(m, "FS-Cache statistics\n");
52616
52617 seq_printf(m, "Cookies: idx=%u dat=%u spc=%u\n",
52618 - atomic_read(&fscache_n_cookie_index),
52619 - atomic_read(&fscache_n_cookie_data),
52620 - atomic_read(&fscache_n_cookie_special));
52621 + atomic_read_unchecked(&fscache_n_cookie_index),
52622 + atomic_read_unchecked(&fscache_n_cookie_data),
52623 + atomic_read_unchecked(&fscache_n_cookie_special));
52624
52625 seq_printf(m, "Objects: alc=%u nal=%u avl=%u ded=%u\n",
52626 - atomic_read(&fscache_n_object_alloc),
52627 - atomic_read(&fscache_n_object_no_alloc),
52628 - atomic_read(&fscache_n_object_avail),
52629 - atomic_read(&fscache_n_object_dead));
52630 + atomic_read_unchecked(&fscache_n_object_alloc),
52631 + atomic_read_unchecked(&fscache_n_object_no_alloc),
52632 + atomic_read_unchecked(&fscache_n_object_avail),
52633 + atomic_read_unchecked(&fscache_n_object_dead));
52634 seq_printf(m, "ChkAux : non=%u ok=%u upd=%u obs=%u\n",
52635 - atomic_read(&fscache_n_checkaux_none),
52636 - atomic_read(&fscache_n_checkaux_okay),
52637 - atomic_read(&fscache_n_checkaux_update),
52638 - atomic_read(&fscache_n_checkaux_obsolete));
52639 + atomic_read_unchecked(&fscache_n_checkaux_none),
52640 + atomic_read_unchecked(&fscache_n_checkaux_okay),
52641 + atomic_read_unchecked(&fscache_n_checkaux_update),
52642 + atomic_read_unchecked(&fscache_n_checkaux_obsolete));
52643
52644 seq_printf(m, "Pages : mrk=%u unc=%u\n",
52645 - atomic_read(&fscache_n_marks),
52646 - atomic_read(&fscache_n_uncaches));
52647 + atomic_read_unchecked(&fscache_n_marks),
52648 + atomic_read_unchecked(&fscache_n_uncaches));
52649
52650 seq_printf(m, "Acquire: n=%u nul=%u noc=%u ok=%u nbf=%u"
52651 " oom=%u\n",
52652 - atomic_read(&fscache_n_acquires),
52653 - atomic_read(&fscache_n_acquires_null),
52654 - atomic_read(&fscache_n_acquires_no_cache),
52655 - atomic_read(&fscache_n_acquires_ok),
52656 - atomic_read(&fscache_n_acquires_nobufs),
52657 - atomic_read(&fscache_n_acquires_oom));
52658 + atomic_read_unchecked(&fscache_n_acquires),
52659 + atomic_read_unchecked(&fscache_n_acquires_null),
52660 + atomic_read_unchecked(&fscache_n_acquires_no_cache),
52661 + atomic_read_unchecked(&fscache_n_acquires_ok),
52662 + atomic_read_unchecked(&fscache_n_acquires_nobufs),
52663 + atomic_read_unchecked(&fscache_n_acquires_oom));
52664
52665 seq_printf(m, "Lookups: n=%u neg=%u pos=%u crt=%u tmo=%u\n",
52666 - atomic_read(&fscache_n_object_lookups),
52667 - atomic_read(&fscache_n_object_lookups_negative),
52668 - atomic_read(&fscache_n_object_lookups_positive),
52669 - atomic_read(&fscache_n_object_created),
52670 - atomic_read(&fscache_n_object_lookups_timed_out));
52671 + atomic_read_unchecked(&fscache_n_object_lookups),
52672 + atomic_read_unchecked(&fscache_n_object_lookups_negative),
52673 + atomic_read_unchecked(&fscache_n_object_lookups_positive),
52674 + atomic_read_unchecked(&fscache_n_object_created),
52675 + atomic_read_unchecked(&fscache_n_object_lookups_timed_out));
52676
52677 seq_printf(m, "Invals : n=%u run=%u\n",
52678 - atomic_read(&fscache_n_invalidates),
52679 - atomic_read(&fscache_n_invalidates_run));
52680 + atomic_read_unchecked(&fscache_n_invalidates),
52681 + atomic_read_unchecked(&fscache_n_invalidates_run));
52682
52683 seq_printf(m, "Updates: n=%u nul=%u run=%u\n",
52684 - atomic_read(&fscache_n_updates),
52685 - atomic_read(&fscache_n_updates_null),
52686 - atomic_read(&fscache_n_updates_run));
52687 + atomic_read_unchecked(&fscache_n_updates),
52688 + atomic_read_unchecked(&fscache_n_updates_null),
52689 + atomic_read_unchecked(&fscache_n_updates_run));
52690
52691 seq_printf(m, "Relinqs: n=%u nul=%u wcr=%u rtr=%u\n",
52692 - atomic_read(&fscache_n_relinquishes),
52693 - atomic_read(&fscache_n_relinquishes_null),
52694 - atomic_read(&fscache_n_relinquishes_waitcrt),
52695 - atomic_read(&fscache_n_relinquishes_retire));
52696 + atomic_read_unchecked(&fscache_n_relinquishes),
52697 + atomic_read_unchecked(&fscache_n_relinquishes_null),
52698 + atomic_read_unchecked(&fscache_n_relinquishes_waitcrt),
52699 + atomic_read_unchecked(&fscache_n_relinquishes_retire));
52700
52701 seq_printf(m, "AttrChg: n=%u ok=%u nbf=%u oom=%u run=%u\n",
52702 - atomic_read(&fscache_n_attr_changed),
52703 - atomic_read(&fscache_n_attr_changed_ok),
52704 - atomic_read(&fscache_n_attr_changed_nobufs),
52705 - atomic_read(&fscache_n_attr_changed_nomem),
52706 - atomic_read(&fscache_n_attr_changed_calls));
52707 + atomic_read_unchecked(&fscache_n_attr_changed),
52708 + atomic_read_unchecked(&fscache_n_attr_changed_ok),
52709 + atomic_read_unchecked(&fscache_n_attr_changed_nobufs),
52710 + atomic_read_unchecked(&fscache_n_attr_changed_nomem),
52711 + atomic_read_unchecked(&fscache_n_attr_changed_calls));
52712
52713 seq_printf(m, "Allocs : n=%u ok=%u wt=%u nbf=%u int=%u\n",
52714 - atomic_read(&fscache_n_allocs),
52715 - atomic_read(&fscache_n_allocs_ok),
52716 - atomic_read(&fscache_n_allocs_wait),
52717 - atomic_read(&fscache_n_allocs_nobufs),
52718 - atomic_read(&fscache_n_allocs_intr));
52719 + atomic_read_unchecked(&fscache_n_allocs),
52720 + atomic_read_unchecked(&fscache_n_allocs_ok),
52721 + atomic_read_unchecked(&fscache_n_allocs_wait),
52722 + atomic_read_unchecked(&fscache_n_allocs_nobufs),
52723 + atomic_read_unchecked(&fscache_n_allocs_intr));
52724 seq_printf(m, "Allocs : ops=%u owt=%u abt=%u\n",
52725 - atomic_read(&fscache_n_alloc_ops),
52726 - atomic_read(&fscache_n_alloc_op_waits),
52727 - atomic_read(&fscache_n_allocs_object_dead));
52728 + atomic_read_unchecked(&fscache_n_alloc_ops),
52729 + atomic_read_unchecked(&fscache_n_alloc_op_waits),
52730 + atomic_read_unchecked(&fscache_n_allocs_object_dead));
52731
52732 seq_printf(m, "Retrvls: n=%u ok=%u wt=%u nod=%u nbf=%u"
52733 " int=%u oom=%u\n",
52734 - atomic_read(&fscache_n_retrievals),
52735 - atomic_read(&fscache_n_retrievals_ok),
52736 - atomic_read(&fscache_n_retrievals_wait),
52737 - atomic_read(&fscache_n_retrievals_nodata),
52738 - atomic_read(&fscache_n_retrievals_nobufs),
52739 - atomic_read(&fscache_n_retrievals_intr),
52740 - atomic_read(&fscache_n_retrievals_nomem));
52741 + atomic_read_unchecked(&fscache_n_retrievals),
52742 + atomic_read_unchecked(&fscache_n_retrievals_ok),
52743 + atomic_read_unchecked(&fscache_n_retrievals_wait),
52744 + atomic_read_unchecked(&fscache_n_retrievals_nodata),
52745 + atomic_read_unchecked(&fscache_n_retrievals_nobufs),
52746 + atomic_read_unchecked(&fscache_n_retrievals_intr),
52747 + atomic_read_unchecked(&fscache_n_retrievals_nomem));
52748 seq_printf(m, "Retrvls: ops=%u owt=%u abt=%u\n",
52749 - atomic_read(&fscache_n_retrieval_ops),
52750 - atomic_read(&fscache_n_retrieval_op_waits),
52751 - atomic_read(&fscache_n_retrievals_object_dead));
52752 + atomic_read_unchecked(&fscache_n_retrieval_ops),
52753 + atomic_read_unchecked(&fscache_n_retrieval_op_waits),
52754 + atomic_read_unchecked(&fscache_n_retrievals_object_dead));
52755
52756 seq_printf(m, "Stores : n=%u ok=%u agn=%u nbf=%u oom=%u\n",
52757 - atomic_read(&fscache_n_stores),
52758 - atomic_read(&fscache_n_stores_ok),
52759 - atomic_read(&fscache_n_stores_again),
52760 - atomic_read(&fscache_n_stores_nobufs),
52761 - atomic_read(&fscache_n_stores_oom));
52762 + atomic_read_unchecked(&fscache_n_stores),
52763 + atomic_read_unchecked(&fscache_n_stores_ok),
52764 + atomic_read_unchecked(&fscache_n_stores_again),
52765 + atomic_read_unchecked(&fscache_n_stores_nobufs),
52766 + atomic_read_unchecked(&fscache_n_stores_oom));
52767 seq_printf(m, "Stores : ops=%u run=%u pgs=%u rxd=%u olm=%u\n",
52768 - atomic_read(&fscache_n_store_ops),
52769 - atomic_read(&fscache_n_store_calls),
52770 - atomic_read(&fscache_n_store_pages),
52771 - atomic_read(&fscache_n_store_radix_deletes),
52772 - atomic_read(&fscache_n_store_pages_over_limit));
52773 + atomic_read_unchecked(&fscache_n_store_ops),
52774 + atomic_read_unchecked(&fscache_n_store_calls),
52775 + atomic_read_unchecked(&fscache_n_store_pages),
52776 + atomic_read_unchecked(&fscache_n_store_radix_deletes),
52777 + atomic_read_unchecked(&fscache_n_store_pages_over_limit));
52778
52779 seq_printf(m, "VmScan : nos=%u gon=%u bsy=%u can=%u wt=%u\n",
52780 - atomic_read(&fscache_n_store_vmscan_not_storing),
52781 - atomic_read(&fscache_n_store_vmscan_gone),
52782 - atomic_read(&fscache_n_store_vmscan_busy),
52783 - atomic_read(&fscache_n_store_vmscan_cancelled),
52784 - atomic_read(&fscache_n_store_vmscan_wait));
52785 + atomic_read_unchecked(&fscache_n_store_vmscan_not_storing),
52786 + atomic_read_unchecked(&fscache_n_store_vmscan_gone),
52787 + atomic_read_unchecked(&fscache_n_store_vmscan_busy),
52788 + atomic_read_unchecked(&fscache_n_store_vmscan_cancelled),
52789 + atomic_read_unchecked(&fscache_n_store_vmscan_wait));
52790
52791 seq_printf(m, "Ops : pend=%u run=%u enq=%u can=%u rej=%u\n",
52792 - atomic_read(&fscache_n_op_pend),
52793 - atomic_read(&fscache_n_op_run),
52794 - atomic_read(&fscache_n_op_enqueue),
52795 - atomic_read(&fscache_n_op_cancelled),
52796 - atomic_read(&fscache_n_op_rejected));
52797 + atomic_read_unchecked(&fscache_n_op_pend),
52798 + atomic_read_unchecked(&fscache_n_op_run),
52799 + atomic_read_unchecked(&fscache_n_op_enqueue),
52800 + atomic_read_unchecked(&fscache_n_op_cancelled),
52801 + atomic_read_unchecked(&fscache_n_op_rejected));
52802 seq_printf(m, "Ops : dfr=%u rel=%u gc=%u\n",
52803 - atomic_read(&fscache_n_op_deferred_release),
52804 - atomic_read(&fscache_n_op_release),
52805 - atomic_read(&fscache_n_op_gc));
52806 + atomic_read_unchecked(&fscache_n_op_deferred_release),
52807 + atomic_read_unchecked(&fscache_n_op_release),
52808 + atomic_read_unchecked(&fscache_n_op_gc));
52809
52810 seq_printf(m, "CacheOp: alo=%d luo=%d luc=%d gro=%d\n",
52811 atomic_read(&fscache_n_cop_alloc_object),
52812 diff --git a/fs/fuse/cuse.c b/fs/fuse/cuse.c
52813 index 6f96a8d..6019bb9 100644
52814 --- a/fs/fuse/cuse.c
52815 +++ b/fs/fuse/cuse.c
52816 @@ -597,10 +597,12 @@ static int __init cuse_init(void)
52817 INIT_LIST_HEAD(&cuse_conntbl[i]);
52818
52819 /* inherit and extend fuse_dev_operations */
52820 - cuse_channel_fops = fuse_dev_operations;
52821 - cuse_channel_fops.owner = THIS_MODULE;
52822 - cuse_channel_fops.open = cuse_channel_open;
52823 - cuse_channel_fops.release = cuse_channel_release;
52824 + pax_open_kernel();
52825 + memcpy((void *)&cuse_channel_fops, &fuse_dev_operations, sizeof(fuse_dev_operations));
52826 + *(void **)&cuse_channel_fops.owner = THIS_MODULE;
52827 + *(void **)&cuse_channel_fops.open = cuse_channel_open;
52828 + *(void **)&cuse_channel_fops.release = cuse_channel_release;
52829 + pax_close_kernel();
52830
52831 cuse_class = class_create(THIS_MODULE, "cuse");
52832 if (IS_ERR(cuse_class))
52833 diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
52834 index 11dfa0c..6f64416 100644
52835 --- a/fs/fuse/dev.c
52836 +++ b/fs/fuse/dev.c
52837 @@ -1294,7 +1294,7 @@ static ssize_t fuse_dev_splice_read(struct file *in, loff_t *ppos,
52838 ret = 0;
52839 pipe_lock(pipe);
52840
52841 - if (!pipe->readers) {
52842 + if (!atomic_read(&pipe->readers)) {
52843 send_sig(SIGPIPE, current, 0);
52844 if (!ret)
52845 ret = -EPIPE;
52846 diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
52847 index ff15522..092a0f6 100644
52848 --- a/fs/fuse/dir.c
52849 +++ b/fs/fuse/dir.c
52850 @@ -1409,7 +1409,7 @@ static char *read_link(struct dentry *dentry)
52851 return link;
52852 }
52853
52854 -static void free_link(char *link)
52855 +static void free_link(const char *link)
52856 {
52857 if (!IS_ERR(link))
52858 free_page((unsigned long) link);
52859 diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
52860 index cc00bd1..3edb692 100644
52861 --- a/fs/gfs2/inode.c
52862 +++ b/fs/gfs2/inode.c
52863 @@ -1500,7 +1500,7 @@ out:
52864
52865 static void gfs2_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
52866 {
52867 - char *s = nd_get_link(nd);
52868 + const char *s = nd_get_link(nd);
52869 if (!IS_ERR(s))
52870 kfree(s);
52871 }
52872 diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
52873 index a3f868a..bb308ae 100644
52874 --- a/fs/hugetlbfs/inode.c
52875 +++ b/fs/hugetlbfs/inode.c
52876 @@ -152,6 +152,7 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
52877 struct mm_struct *mm = current->mm;
52878 struct vm_area_struct *vma;
52879 struct hstate *h = hstate_file(file);
52880 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
52881 struct vm_unmapped_area_info info;
52882
52883 if (len & ~huge_page_mask(h))
52884 @@ -165,17 +166,26 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
52885 return addr;
52886 }
52887
52888 +#ifdef CONFIG_PAX_RANDMMAP
52889 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
52890 +#endif
52891 +
52892 if (addr) {
52893 addr = ALIGN(addr, huge_page_size(h));
52894 vma = find_vma(mm, addr);
52895 - if (TASK_SIZE - len >= addr &&
52896 - (!vma || addr + len <= vma->vm_start))
52897 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
52898 return addr;
52899 }
52900
52901 info.flags = 0;
52902 info.length = len;
52903 info.low_limit = TASK_UNMAPPED_BASE;
52904 +
52905 +#ifdef CONFIG_PAX_RANDMMAP
52906 + if (mm->pax_flags & MF_PAX_RANDMMAP)
52907 + info.low_limit += mm->delta_mmap;
52908 +#endif
52909 +
52910 info.high_limit = TASK_SIZE;
52911 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
52912 info.align_offset = 0;
52913 @@ -898,7 +908,7 @@ static struct file_system_type hugetlbfs_fs_type = {
52914 };
52915 MODULE_ALIAS_FS("hugetlbfs");
52916
52917 -static struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
52918 +struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
52919
52920 static int can_do_hugetlb_shm(void)
52921 {
52922 diff --git a/fs/inode.c b/fs/inode.c
52923 index a898b3d..9b5a214 100644
52924 --- a/fs/inode.c
52925 +++ b/fs/inode.c
52926 @@ -878,8 +878,8 @@ unsigned int get_next_ino(void)
52927
52928 #ifdef CONFIG_SMP
52929 if (unlikely((res & (LAST_INO_BATCH-1)) == 0)) {
52930 - static atomic_t shared_last_ino;
52931 - int next = atomic_add_return(LAST_INO_BATCH, &shared_last_ino);
52932 + static atomic_unchecked_t shared_last_ino;
52933 + int next = atomic_add_return_unchecked(LAST_INO_BATCH, &shared_last_ino);
52934
52935 res = next - LAST_INO_BATCH;
52936 }
52937 diff --git a/fs/jffs2/erase.c b/fs/jffs2/erase.c
52938 index 4a6cf28..d3a29d3 100644
52939 --- a/fs/jffs2/erase.c
52940 +++ b/fs/jffs2/erase.c
52941 @@ -452,7 +452,8 @@ static void jffs2_mark_erased_block(struct jffs2_sb_info *c, struct jffs2_eraseb
52942 struct jffs2_unknown_node marker = {
52943 .magic = cpu_to_je16(JFFS2_MAGIC_BITMASK),
52944 .nodetype = cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER),
52945 - .totlen = cpu_to_je32(c->cleanmarker_size)
52946 + .totlen = cpu_to_je32(c->cleanmarker_size),
52947 + .hdr_crc = cpu_to_je32(0)
52948 };
52949
52950 jffs2_prealloc_raw_node_refs(c, jeb, 1);
52951 diff --git a/fs/jffs2/wbuf.c b/fs/jffs2/wbuf.c
52952 index a6597d6..41b30ec 100644
52953 --- a/fs/jffs2/wbuf.c
52954 +++ b/fs/jffs2/wbuf.c
52955 @@ -1023,7 +1023,8 @@ static const struct jffs2_unknown_node oob_cleanmarker =
52956 {
52957 .magic = constant_cpu_to_je16(JFFS2_MAGIC_BITMASK),
52958 .nodetype = constant_cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER),
52959 - .totlen = constant_cpu_to_je32(8)
52960 + .totlen = constant_cpu_to_je32(8),
52961 + .hdr_crc = constant_cpu_to_je32(0)
52962 };
52963
52964 /*
52965 diff --git a/fs/jfs/super.c b/fs/jfs/super.c
52966 index 2003e83..40db287 100644
52967 --- a/fs/jfs/super.c
52968 +++ b/fs/jfs/super.c
52969 @@ -856,7 +856,7 @@ static int __init init_jfs_fs(void)
52970
52971 jfs_inode_cachep =
52972 kmem_cache_create("jfs_ip", sizeof(struct jfs_inode_info), 0,
52973 - SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD,
52974 + SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD|SLAB_USERCOPY,
52975 init_once);
52976 if (jfs_inode_cachep == NULL)
52977 return -ENOMEM;
52978 diff --git a/fs/libfs.c b/fs/libfs.c
52979 index 916da8c..1588998 100644
52980 --- a/fs/libfs.c
52981 +++ b/fs/libfs.c
52982 @@ -165,6 +165,9 @@ int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir)
52983
52984 for (p=q->next; p != &dentry->d_subdirs; p=p->next) {
52985 struct dentry *next;
52986 + char d_name[sizeof(next->d_iname)];
52987 + const unsigned char *name;
52988 +
52989 next = list_entry(p, struct dentry, d_u.d_child);
52990 spin_lock_nested(&next->d_lock, DENTRY_D_LOCK_NESTED);
52991 if (!simple_positive(next)) {
52992 @@ -174,7 +177,12 @@ int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir)
52993
52994 spin_unlock(&next->d_lock);
52995 spin_unlock(&dentry->d_lock);
52996 - if (filldir(dirent, next->d_name.name,
52997 + name = next->d_name.name;
52998 + if (name == next->d_iname) {
52999 + memcpy(d_name, name, next->d_name.len);
53000 + name = d_name;
53001 + }
53002 + if (filldir(dirent, name,
53003 next->d_name.len, filp->f_pos,
53004 next->d_inode->i_ino,
53005 dt_type(next->d_inode)) < 0)
53006 diff --git a/fs/lockd/clntproc.c b/fs/lockd/clntproc.c
53007 index 9760ecb..9b838ef 100644
53008 --- a/fs/lockd/clntproc.c
53009 +++ b/fs/lockd/clntproc.c
53010 @@ -36,11 +36,11 @@ static const struct rpc_call_ops nlmclnt_cancel_ops;
53011 /*
53012 * Cookie counter for NLM requests
53013 */
53014 -static atomic_t nlm_cookie = ATOMIC_INIT(0x1234);
53015 +static atomic_unchecked_t nlm_cookie = ATOMIC_INIT(0x1234);
53016
53017 void nlmclnt_next_cookie(struct nlm_cookie *c)
53018 {
53019 - u32 cookie = atomic_inc_return(&nlm_cookie);
53020 + u32 cookie = atomic_inc_return_unchecked(&nlm_cookie);
53021
53022 memcpy(c->data, &cookie, 4);
53023 c->len=4;
53024 diff --git a/fs/locks.c b/fs/locks.c
53025 index cb424a4..850e4dd 100644
53026 --- a/fs/locks.c
53027 +++ b/fs/locks.c
53028 @@ -2064,16 +2064,16 @@ void locks_remove_flock(struct file *filp)
53029 return;
53030
53031 if (filp->f_op && filp->f_op->flock) {
53032 - struct file_lock fl = {
53033 + struct file_lock flock = {
53034 .fl_pid = current->tgid,
53035 .fl_file = filp,
53036 .fl_flags = FL_FLOCK,
53037 .fl_type = F_UNLCK,
53038 .fl_end = OFFSET_MAX,
53039 };
53040 - filp->f_op->flock(filp, F_SETLKW, &fl);
53041 - if (fl.fl_ops && fl.fl_ops->fl_release_private)
53042 - fl.fl_ops->fl_release_private(&fl);
53043 + filp->f_op->flock(filp, F_SETLKW, &flock);
53044 + if (flock.fl_ops && flock.fl_ops->fl_release_private)
53045 + flock.fl_ops->fl_release_private(&flock);
53046 }
53047
53048 lock_flocks();
53049 diff --git a/fs/namei.c b/fs/namei.c
53050 index 85e40d1..b66744e 100644
53051 --- a/fs/namei.c
53052 +++ b/fs/namei.c
53053 @@ -319,16 +319,32 @@ int generic_permission(struct inode *inode, int mask)
53054 if (ret != -EACCES)
53055 return ret;
53056
53057 +#ifdef CONFIG_GRKERNSEC
53058 + /* we'll block if we have to log due to a denied capability use */
53059 + if (mask & MAY_NOT_BLOCK)
53060 + return -ECHILD;
53061 +#endif
53062 +
53063 if (S_ISDIR(inode->i_mode)) {
53064 /* DACs are overridable for directories */
53065 - if (inode_capable(inode, CAP_DAC_OVERRIDE))
53066 - return 0;
53067 if (!(mask & MAY_WRITE))
53068 - if (inode_capable(inode, CAP_DAC_READ_SEARCH))
53069 + if (inode_capable_nolog(inode, CAP_DAC_OVERRIDE) ||
53070 + inode_capable(inode, CAP_DAC_READ_SEARCH))
53071 return 0;
53072 + if (inode_capable(inode, CAP_DAC_OVERRIDE))
53073 + return 0;
53074 return -EACCES;
53075 }
53076 /*
53077 + * Searching includes executable on directories, else just read.
53078 + */
53079 + mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
53080 + if (mask == MAY_READ)
53081 + if (inode_capable_nolog(inode, CAP_DAC_OVERRIDE) ||
53082 + inode_capable(inode, CAP_DAC_READ_SEARCH))
53083 + return 0;
53084 +
53085 + /*
53086 * Read/write DACs are always overridable.
53087 * Executable DACs are overridable when there is
53088 * at least one exec bit set.
53089 @@ -337,14 +353,6 @@ int generic_permission(struct inode *inode, int mask)
53090 if (inode_capable(inode, CAP_DAC_OVERRIDE))
53091 return 0;
53092
53093 - /*
53094 - * Searching includes executable on directories, else just read.
53095 - */
53096 - mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
53097 - if (mask == MAY_READ)
53098 - if (inode_capable(inode, CAP_DAC_READ_SEARCH))
53099 - return 0;
53100 -
53101 return -EACCES;
53102 }
53103
53104 @@ -820,7 +828,7 @@ follow_link(struct path *link, struct nameidata *nd, void **p)
53105 {
53106 struct dentry *dentry = link->dentry;
53107 int error;
53108 - char *s;
53109 + const char *s;
53110
53111 BUG_ON(nd->flags & LOOKUP_RCU);
53112
53113 @@ -841,6 +849,12 @@ follow_link(struct path *link, struct nameidata *nd, void **p)
53114 if (error)
53115 goto out_put_nd_path;
53116
53117 + if (gr_handle_follow_link(dentry->d_parent->d_inode,
53118 + dentry->d_inode, dentry, nd->path.mnt)) {
53119 + error = -EACCES;
53120 + goto out_put_nd_path;
53121 + }
53122 +
53123 nd->last_type = LAST_BIND;
53124 *p = dentry->d_inode->i_op->follow_link(dentry, nd);
53125 error = PTR_ERR(*p);
53126 @@ -1588,6 +1602,8 @@ static inline int nested_symlink(struct path *path, struct nameidata *nd)
53127 if (res)
53128 break;
53129 res = walk_component(nd, path, LOOKUP_FOLLOW);
53130 + if (res >= 0 && gr_handle_symlink_owner(&link, nd->inode))
53131 + res = -EACCES;
53132 put_link(nd, &link, cookie);
53133 } while (res > 0);
53134
53135 @@ -1686,7 +1702,7 @@ EXPORT_SYMBOL(full_name_hash);
53136 static inline unsigned long hash_name(const char *name, unsigned int *hashp)
53137 {
53138 unsigned long a, b, adata, bdata, mask, hash, len;
53139 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
53140 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
53141
53142 hash = a = 0;
53143 len = -sizeof(unsigned long);
53144 @@ -1968,6 +1984,8 @@ static int path_lookupat(int dfd, const char *name,
53145 if (err)
53146 break;
53147 err = lookup_last(nd, &path);
53148 + if (!err && gr_handle_symlink_owner(&link, nd->inode))
53149 + err = -EACCES;
53150 put_link(nd, &link, cookie);
53151 }
53152 }
53153 @@ -1975,6 +1993,13 @@ static int path_lookupat(int dfd, const char *name,
53154 if (!err)
53155 err = complete_walk(nd);
53156
53157 + if (!err && !(nd->flags & LOOKUP_PARENT)) {
53158 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
53159 + path_put(&nd->path);
53160 + err = -ENOENT;
53161 + }
53162 + }
53163 +
53164 if (!err && nd->flags & LOOKUP_DIRECTORY) {
53165 if (!nd->inode->i_op->lookup) {
53166 path_put(&nd->path);
53167 @@ -2002,8 +2027,15 @@ static int filename_lookup(int dfd, struct filename *name,
53168 retval = path_lookupat(dfd, name->name,
53169 flags | LOOKUP_REVAL, nd);
53170
53171 - if (likely(!retval))
53172 + if (likely(!retval)) {
53173 audit_inode(name, nd->path.dentry, flags & LOOKUP_PARENT);
53174 + if (name->name[0] != '/' && nd->path.dentry && nd->inode) {
53175 + if (!gr_chroot_fchdir(nd->path.dentry, nd->path.mnt)) {
53176 + path_put(&nd->path);
53177 + return -ENOENT;
53178 + }
53179 + }
53180 + }
53181 return retval;
53182 }
53183
53184 @@ -2381,6 +2413,13 @@ static int may_open(struct path *path, int acc_mode, int flag)
53185 if (flag & O_NOATIME && !inode_owner_or_capable(inode))
53186 return -EPERM;
53187
53188 + if (gr_handle_rofs_blockwrite(dentry, path->mnt, acc_mode))
53189 + return -EPERM;
53190 + if (gr_handle_rawio(inode))
53191 + return -EPERM;
53192 + if (!gr_acl_handle_open(dentry, path->mnt, acc_mode))
53193 + return -EACCES;
53194 +
53195 return 0;
53196 }
53197
53198 @@ -2602,7 +2641,7 @@ looked_up:
53199 * cleared otherwise prior to returning.
53200 */
53201 static int lookup_open(struct nameidata *nd, struct path *path,
53202 - struct file *file,
53203 + struct path *link, struct file *file,
53204 const struct open_flags *op,
53205 bool got_write, int *opened)
53206 {
53207 @@ -2637,6 +2676,17 @@ static int lookup_open(struct nameidata *nd, struct path *path,
53208 /* Negative dentry, just create the file */
53209 if (!dentry->d_inode && (op->open_flag & O_CREAT)) {
53210 umode_t mode = op->mode;
53211 +
53212 + if (link && gr_handle_symlink_owner(link, dir->d_inode)) {
53213 + error = -EACCES;
53214 + goto out_dput;
53215 + }
53216 +
53217 + if (!gr_acl_handle_creat(dentry, dir, nd->path.mnt, op->open_flag, op->acc_mode, mode)) {
53218 + error = -EACCES;
53219 + goto out_dput;
53220 + }
53221 +
53222 if (!IS_POSIXACL(dir->d_inode))
53223 mode &= ~current_umask();
53224 /*
53225 @@ -2658,6 +2708,8 @@ static int lookup_open(struct nameidata *nd, struct path *path,
53226 nd->flags & LOOKUP_EXCL);
53227 if (error)
53228 goto out_dput;
53229 + else
53230 + gr_handle_create(dentry, nd->path.mnt);
53231 }
53232 out_no_open:
53233 path->dentry = dentry;
53234 @@ -2672,7 +2724,7 @@ out_dput:
53235 /*
53236 * Handle the last step of open()
53237 */
53238 -static int do_last(struct nameidata *nd, struct path *path,
53239 +static int do_last(struct nameidata *nd, struct path *path, struct path *link,
53240 struct file *file, const struct open_flags *op,
53241 int *opened, struct filename *name)
53242 {
53243 @@ -2701,16 +2753,32 @@ static int do_last(struct nameidata *nd, struct path *path,
53244 error = complete_walk(nd);
53245 if (error)
53246 return error;
53247 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
53248 + error = -ENOENT;
53249 + goto out;
53250 + }
53251 audit_inode(name, nd->path.dentry, 0);
53252 if (open_flag & O_CREAT) {
53253 error = -EISDIR;
53254 goto out;
53255 }
53256 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
53257 + error = -EACCES;
53258 + goto out;
53259 + }
53260 goto finish_open;
53261 case LAST_BIND:
53262 error = complete_walk(nd);
53263 if (error)
53264 return error;
53265 + if (!gr_acl_handle_hidden_file(dir, nd->path.mnt)) {
53266 + error = -ENOENT;
53267 + goto out;
53268 + }
53269 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
53270 + error = -EACCES;
53271 + goto out;
53272 + }
53273 audit_inode(name, dir, 0);
53274 goto finish_open;
53275 }
53276 @@ -2759,7 +2827,7 @@ retry_lookup:
53277 */
53278 }
53279 mutex_lock(&dir->d_inode->i_mutex);
53280 - error = lookup_open(nd, path, file, op, got_write, opened);
53281 + error = lookup_open(nd, path, link, file, op, got_write, opened);
53282 mutex_unlock(&dir->d_inode->i_mutex);
53283
53284 if (error <= 0) {
53285 @@ -2783,11 +2851,28 @@ retry_lookup:
53286 goto finish_open_created;
53287 }
53288
53289 + if (!gr_acl_handle_hidden_file(path->dentry, nd->path.mnt)) {
53290 + error = -ENOENT;
53291 + goto exit_dput;
53292 + }
53293 + if (link && gr_handle_symlink_owner(link, path->dentry->d_inode)) {
53294 + error = -EACCES;
53295 + goto exit_dput;
53296 + }
53297 +
53298 /*
53299 * create/update audit record if it already exists.
53300 */
53301 - if (path->dentry->d_inode)
53302 + if (path->dentry->d_inode) {
53303 + /* only check if O_CREAT is specified, all other checks need to go
53304 + into may_open */
53305 + if (gr_handle_fifo(path->dentry, path->mnt, dir, open_flag, acc_mode)) {
53306 + error = -EACCES;
53307 + goto exit_dput;
53308 + }
53309 +
53310 audit_inode(name, path->dentry, 0);
53311 + }
53312
53313 /*
53314 * If atomic_open() acquired write access it is dropped now due to
53315 @@ -2828,6 +2913,11 @@ finish_lookup:
53316 }
53317 }
53318 BUG_ON(inode != path->dentry->d_inode);
53319 + /* if we're resolving a symlink to another symlink */
53320 + if (link && gr_handle_symlink_owner(link, inode)) {
53321 + error = -EACCES;
53322 + goto out;
53323 + }
53324 return 1;
53325 }
53326
53327 @@ -2837,7 +2927,6 @@ finish_lookup:
53328 save_parent.dentry = nd->path.dentry;
53329 save_parent.mnt = mntget(path->mnt);
53330 nd->path.dentry = path->dentry;
53331 -
53332 }
53333 nd->inode = inode;
53334 /* Why this, you ask? _Now_ we might have grown LOOKUP_JUMPED... */
53335 @@ -2846,6 +2935,16 @@ finish_lookup:
53336 path_put(&save_parent);
53337 return error;
53338 }
53339 +
53340 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
53341 + error = -ENOENT;
53342 + goto out;
53343 + }
53344 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
53345 + error = -EACCES;
53346 + goto out;
53347 + }
53348 +
53349 error = -EISDIR;
53350 if ((open_flag & O_CREAT) && S_ISDIR(nd->inode->i_mode))
53351 goto out;
53352 @@ -2944,7 +3043,7 @@ static struct file *path_openat(int dfd, struct filename *pathname,
53353 if (unlikely(error))
53354 goto out;
53355
53356 - error = do_last(nd, &path, file, op, &opened, pathname);
53357 + error = do_last(nd, &path, NULL, file, op, &opened, pathname);
53358 while (unlikely(error > 0)) { /* trailing symlink */
53359 struct path link = path;
53360 void *cookie;
53361 @@ -2962,7 +3061,7 @@ static struct file *path_openat(int dfd, struct filename *pathname,
53362 error = follow_link(&link, nd, &cookie);
53363 if (unlikely(error))
53364 break;
53365 - error = do_last(nd, &path, file, op, &opened, pathname);
53366 + error = do_last(nd, &path, &link, file, op, &opened, pathname);
53367 put_link(nd, &link, cookie);
53368 }
53369 out:
53370 @@ -3062,8 +3161,12 @@ struct dentry *kern_path_create(int dfd, const char *pathname,
53371 goto unlock;
53372
53373 error = -EEXIST;
53374 - if (dentry->d_inode)
53375 + if (dentry->d_inode) {
53376 + if (!gr_acl_handle_hidden_file(dentry, nd.path.mnt)) {
53377 + error = -ENOENT;
53378 + }
53379 goto fail;
53380 + }
53381 /*
53382 * Special case - lookup gave negative, but... we had foo/bar/
53383 * From the vfs_mknod() POV we just have a negative dentry -
53384 @@ -3115,6 +3218,20 @@ struct dentry *user_path_create(int dfd, const char __user *pathname,
53385 }
53386 EXPORT_SYMBOL(user_path_create);
53387
53388 +static struct dentry *user_path_create_with_name(int dfd, const char __user *pathname, struct path *path, struct filename **to, unsigned int lookup_flags)
53389 +{
53390 + struct filename *tmp = getname(pathname);
53391 + struct dentry *res;
53392 + if (IS_ERR(tmp))
53393 + return ERR_CAST(tmp);
53394 + res = kern_path_create(dfd, tmp->name, path, lookup_flags);
53395 + if (IS_ERR(res))
53396 + putname(tmp);
53397 + else
53398 + *to = tmp;
53399 + return res;
53400 +}
53401 +
53402 int vfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev)
53403 {
53404 int error = may_create(dir, dentry);
53405 @@ -3177,6 +3294,17 @@ retry:
53406
53407 if (!IS_POSIXACL(path.dentry->d_inode))
53408 mode &= ~current_umask();
53409 +
53410 + if (gr_handle_chroot_mknod(dentry, path.mnt, mode)) {
53411 + error = -EPERM;
53412 + goto out;
53413 + }
53414 +
53415 + if (!gr_acl_handle_mknod(dentry, path.dentry, path.mnt, mode)) {
53416 + error = -EACCES;
53417 + goto out;
53418 + }
53419 +
53420 error = security_path_mknod(&path, dentry, mode, dev);
53421 if (error)
53422 goto out;
53423 @@ -3193,6 +3321,8 @@ retry:
53424 break;
53425 }
53426 out:
53427 + if (!error)
53428 + gr_handle_create(dentry, path.mnt);
53429 done_path_create(&path, dentry);
53430 if (retry_estale(error, lookup_flags)) {
53431 lookup_flags |= LOOKUP_REVAL;
53432 @@ -3245,9 +3375,16 @@ retry:
53433
53434 if (!IS_POSIXACL(path.dentry->d_inode))
53435 mode &= ~current_umask();
53436 + if (!gr_acl_handle_mkdir(dentry, path.dentry, path.mnt)) {
53437 + error = -EACCES;
53438 + goto out;
53439 + }
53440 error = security_path_mkdir(&path, dentry, mode);
53441 if (!error)
53442 error = vfs_mkdir(path.dentry->d_inode, dentry, mode);
53443 + if (!error)
53444 + gr_handle_create(dentry, path.mnt);
53445 +out:
53446 done_path_create(&path, dentry);
53447 if (retry_estale(error, lookup_flags)) {
53448 lookup_flags |= LOOKUP_REVAL;
53449 @@ -3328,6 +3465,8 @@ static long do_rmdir(int dfd, const char __user *pathname)
53450 struct filename *name;
53451 struct dentry *dentry;
53452 struct nameidata nd;
53453 + ino_t saved_ino = 0;
53454 + dev_t saved_dev = 0;
53455 unsigned int lookup_flags = 0;
53456 retry:
53457 name = user_path_parent(dfd, pathname, &nd, lookup_flags);
53458 @@ -3360,10 +3499,21 @@ retry:
53459 error = -ENOENT;
53460 goto exit3;
53461 }
53462 +
53463 + saved_ino = dentry->d_inode->i_ino;
53464 + saved_dev = gr_get_dev_from_dentry(dentry);
53465 +
53466 + if (!gr_acl_handle_rmdir(dentry, nd.path.mnt)) {
53467 + error = -EACCES;
53468 + goto exit3;
53469 + }
53470 +
53471 error = security_path_rmdir(&nd.path, dentry);
53472 if (error)
53473 goto exit3;
53474 error = vfs_rmdir(nd.path.dentry->d_inode, dentry);
53475 + if (!error && (saved_dev || saved_ino))
53476 + gr_handle_delete(saved_ino, saved_dev);
53477 exit3:
53478 dput(dentry);
53479 exit2:
53480 @@ -3429,6 +3579,8 @@ static long do_unlinkat(int dfd, const char __user *pathname)
53481 struct dentry *dentry;
53482 struct nameidata nd;
53483 struct inode *inode = NULL;
53484 + ino_t saved_ino = 0;
53485 + dev_t saved_dev = 0;
53486 unsigned int lookup_flags = 0;
53487 retry:
53488 name = user_path_parent(dfd, pathname, &nd, lookup_flags);
53489 @@ -3455,10 +3607,22 @@ retry:
53490 if (!inode)
53491 goto slashes;
53492 ihold(inode);
53493 +
53494 + if (inode->i_nlink <= 1) {
53495 + saved_ino = inode->i_ino;
53496 + saved_dev = gr_get_dev_from_dentry(dentry);
53497 + }
53498 + if (!gr_acl_handle_unlink(dentry, nd.path.mnt)) {
53499 + error = -EACCES;
53500 + goto exit2;
53501 + }
53502 +
53503 error = security_path_unlink(&nd.path, dentry);
53504 if (error)
53505 goto exit2;
53506 error = vfs_unlink(nd.path.dentry->d_inode, dentry);
53507 + if (!error && (saved_ino || saved_dev))
53508 + gr_handle_delete(saved_ino, saved_dev);
53509 exit2:
53510 dput(dentry);
53511 }
53512 @@ -3536,9 +3700,17 @@ retry:
53513 if (IS_ERR(dentry))
53514 goto out_putname;
53515
53516 + if (!gr_acl_handle_symlink(dentry, path.dentry, path.mnt, from)) {
53517 + error = -EACCES;
53518 + goto out;
53519 + }
53520 +
53521 error = security_path_symlink(&path, dentry, from->name);
53522 if (!error)
53523 error = vfs_symlink(path.dentry->d_inode, dentry, from->name);
53524 + if (!error)
53525 + gr_handle_create(dentry, path.mnt);
53526 +out:
53527 done_path_create(&path, dentry);
53528 if (retry_estale(error, lookup_flags)) {
53529 lookup_flags |= LOOKUP_REVAL;
53530 @@ -3612,6 +3784,7 @@ SYSCALL_DEFINE5(linkat, int, olddfd, const char __user *, oldname,
53531 {
53532 struct dentry *new_dentry;
53533 struct path old_path, new_path;
53534 + struct filename *to = NULL;
53535 int how = 0;
53536 int error;
53537
53538 @@ -3635,7 +3808,7 @@ retry:
53539 if (error)
53540 return error;
53541
53542 - new_dentry = user_path_create(newdfd, newname, &new_path,
53543 + new_dentry = user_path_create_with_name(newdfd, newname, &new_path, &to,
53544 (how & LOOKUP_REVAL));
53545 error = PTR_ERR(new_dentry);
53546 if (IS_ERR(new_dentry))
53547 @@ -3647,11 +3820,28 @@ retry:
53548 error = may_linkat(&old_path);
53549 if (unlikely(error))
53550 goto out_dput;
53551 +
53552 + if (gr_handle_hardlink(old_path.dentry, old_path.mnt,
53553 + old_path.dentry->d_inode,
53554 + old_path.dentry->d_inode->i_mode, to)) {
53555 + error = -EACCES;
53556 + goto out_dput;
53557 + }
53558 +
53559 + if (!gr_acl_handle_link(new_dentry, new_path.dentry, new_path.mnt,
53560 + old_path.dentry, old_path.mnt, to)) {
53561 + error = -EACCES;
53562 + goto out_dput;
53563 + }
53564 +
53565 error = security_path_link(old_path.dentry, &new_path, new_dentry);
53566 if (error)
53567 goto out_dput;
53568 error = vfs_link(old_path.dentry, new_path.dentry->d_inode, new_dentry);
53569 + if (!error)
53570 + gr_handle_create(new_dentry, new_path.mnt);
53571 out_dput:
53572 + putname(to);
53573 done_path_create(&new_path, new_dentry);
53574 if (retry_estale(error, how)) {
53575 how |= LOOKUP_REVAL;
53576 @@ -3897,12 +4087,21 @@ retry:
53577 if (new_dentry == trap)
53578 goto exit5;
53579
53580 + error = gr_acl_handle_rename(new_dentry, new_dir, newnd.path.mnt,
53581 + old_dentry, old_dir->d_inode, oldnd.path.mnt,
53582 + to);
53583 + if (error)
53584 + goto exit5;
53585 +
53586 error = security_path_rename(&oldnd.path, old_dentry,
53587 &newnd.path, new_dentry);
53588 if (error)
53589 goto exit5;
53590 error = vfs_rename(old_dir->d_inode, old_dentry,
53591 new_dir->d_inode, new_dentry);
53592 + if (!error)
53593 + gr_handle_rename(old_dir->d_inode, new_dir->d_inode, old_dentry,
53594 + new_dentry, oldnd.path.mnt, new_dentry->d_inode ? 1 : 0);
53595 exit5:
53596 dput(new_dentry);
53597 exit4:
53598 @@ -3934,6 +4133,8 @@ SYSCALL_DEFINE2(rename, const char __user *, oldname, const char __user *, newna
53599
53600 int vfs_readlink(struct dentry *dentry, char __user *buffer, int buflen, const char *link)
53601 {
53602 + char tmpbuf[64];
53603 + const char *newlink;
53604 int len;
53605
53606 len = PTR_ERR(link);
53607 @@ -3943,7 +4144,14 @@ int vfs_readlink(struct dentry *dentry, char __user *buffer, int buflen, const c
53608 len = strlen(link);
53609 if (len > (unsigned) buflen)
53610 len = buflen;
53611 - if (copy_to_user(buffer, link, len))
53612 +
53613 + if (len < sizeof(tmpbuf)) {
53614 + memcpy(tmpbuf, link, len);
53615 + newlink = tmpbuf;
53616 + } else
53617 + newlink = link;
53618 +
53619 + if (copy_to_user(buffer, newlink, len))
53620 len = -EFAULT;
53621 out:
53622 return len;
53623 diff --git a/fs/namespace.c b/fs/namespace.c
53624 index e945b81..fc018e2 100644
53625 --- a/fs/namespace.c
53626 +++ b/fs/namespace.c
53627 @@ -1219,6 +1219,9 @@ static int do_umount(struct mount *mnt, int flags)
53628 if (!(sb->s_flags & MS_RDONLY))
53629 retval = do_remount_sb(sb, MS_RDONLY, NULL, 0);
53630 up_write(&sb->s_umount);
53631 +
53632 + gr_log_remount(mnt->mnt_devname, retval);
53633 +
53634 return retval;
53635 }
53636
53637 @@ -1238,6 +1241,9 @@ static int do_umount(struct mount *mnt, int flags)
53638 br_write_unlock(&vfsmount_lock);
53639 up_write(&namespace_sem);
53640 release_mounts(&umount_list);
53641 +
53642 + gr_log_unmount(mnt->mnt_devname, retval);
53643 +
53644 return retval;
53645 }
53646
53647 @@ -1257,7 +1263,7 @@ static inline bool may_mount(void)
53648 * unixes. Our API is identical to OSF/1 to avoid making a mess of AMD
53649 */
53650
53651 -SYSCALL_DEFINE2(umount, char __user *, name, int, flags)
53652 +SYSCALL_DEFINE2(umount, const char __user *, name, int, flags)
53653 {
53654 struct path path;
53655 struct mount *mnt;
53656 @@ -1297,7 +1303,7 @@ out:
53657 /*
53658 * The 2.0 compatible umount. No flags.
53659 */
53660 -SYSCALL_DEFINE1(oldumount, char __user *, name)
53661 +SYSCALL_DEFINE1(oldumount, const char __user *, name)
53662 {
53663 return sys_umount(name, 0);
53664 }
53665 @@ -2267,6 +2273,16 @@ long do_mount(const char *dev_name, const char *dir_name,
53666 MS_NOATIME | MS_NODIRATIME | MS_RELATIME| MS_KERNMOUNT |
53667 MS_STRICTATIME);
53668
53669 + if (gr_handle_rofs_mount(path.dentry, path.mnt, mnt_flags)) {
53670 + retval = -EPERM;
53671 + goto dput_out;
53672 + }
53673 +
53674 + if (gr_handle_chroot_mount(path.dentry, path.mnt, dev_name)) {
53675 + retval = -EPERM;
53676 + goto dput_out;
53677 + }
53678 +
53679 if (flags & MS_REMOUNT)
53680 retval = do_remount(&path, flags & ~MS_REMOUNT, mnt_flags,
53681 data_page);
53682 @@ -2281,6 +2297,9 @@ long do_mount(const char *dev_name, const char *dir_name,
53683 dev_name, data_page);
53684 dput_out:
53685 path_put(&path);
53686 +
53687 + gr_log_mount(dev_name, dir_name, retval);
53688 +
53689 return retval;
53690 }
53691
53692 @@ -2454,8 +2473,8 @@ struct dentry *mount_subtree(struct vfsmount *mnt, const char *name)
53693 }
53694 EXPORT_SYMBOL(mount_subtree);
53695
53696 -SYSCALL_DEFINE5(mount, char __user *, dev_name, char __user *, dir_name,
53697 - char __user *, type, unsigned long, flags, void __user *, data)
53698 +SYSCALL_DEFINE5(mount, const char __user *, dev_name, const char __user *, dir_name,
53699 + const char __user *, type, unsigned long, flags, void __user *, data)
53700 {
53701 int ret;
53702 char *kernel_type;
53703 @@ -2567,6 +2586,11 @@ SYSCALL_DEFINE2(pivot_root, const char __user *, new_root,
53704 if (error)
53705 goto out2;
53706
53707 + if (gr_handle_chroot_pivot()) {
53708 + error = -EPERM;
53709 + goto out2;
53710 + }
53711 +
53712 get_fs_root(current->fs, &root);
53713 error = lock_mount(&old);
53714 if (error)
53715 @@ -2815,7 +2839,7 @@ static int mntns_install(struct nsproxy *nsproxy, void *ns)
53716 !nsown_capable(CAP_SYS_ADMIN))
53717 return -EPERM;
53718
53719 - if (fs->users != 1)
53720 + if (atomic_read(&fs->users) != 1)
53721 return -EINVAL;
53722
53723 get_mnt_ns(mnt_ns);
53724 diff --git a/fs/nfs/callback_xdr.c b/fs/nfs/callback_xdr.c
53725 index 59461c9..b17c57e 100644
53726 --- a/fs/nfs/callback_xdr.c
53727 +++ b/fs/nfs/callback_xdr.c
53728 @@ -51,7 +51,7 @@ struct callback_op {
53729 callback_decode_arg_t decode_args;
53730 callback_encode_res_t encode_res;
53731 long res_maxsize;
53732 -};
53733 +} __do_const;
53734
53735 static struct callback_op callback_ops[];
53736
53737 diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
53738 index 1f94167..79c4ce4 100644
53739 --- a/fs/nfs/inode.c
53740 +++ b/fs/nfs/inode.c
53741 @@ -1041,16 +1041,16 @@ static int nfs_size_need_update(const struct inode *inode, const struct nfs_fatt
53742 return nfs_size_to_loff_t(fattr->size) > i_size_read(inode);
53743 }
53744
53745 -static atomic_long_t nfs_attr_generation_counter;
53746 +static atomic_long_unchecked_t nfs_attr_generation_counter;
53747
53748 static unsigned long nfs_read_attr_generation_counter(void)
53749 {
53750 - return atomic_long_read(&nfs_attr_generation_counter);
53751 + return atomic_long_read_unchecked(&nfs_attr_generation_counter);
53752 }
53753
53754 unsigned long nfs_inc_attr_generation_counter(void)
53755 {
53756 - return atomic_long_inc_return(&nfs_attr_generation_counter);
53757 + return atomic_long_inc_return_unchecked(&nfs_attr_generation_counter);
53758 }
53759
53760 void nfs_fattr_init(struct nfs_fattr *fattr)
53761 diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
53762 index d401d01..10b3e62 100644
53763 --- a/fs/nfsd/nfs4proc.c
53764 +++ b/fs/nfsd/nfs4proc.c
53765 @@ -1109,7 +1109,7 @@ struct nfsd4_operation {
53766 nfsd4op_rsize op_rsize_bop;
53767 stateid_getter op_get_currentstateid;
53768 stateid_setter op_set_currentstateid;
53769 -};
53770 +} __do_const;
53771
53772 static struct nfsd4_operation nfsd4_ops[];
53773
53774 diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
53775 index 6eb0dc5..29067a9 100644
53776 --- a/fs/nfsd/nfs4xdr.c
53777 +++ b/fs/nfsd/nfs4xdr.c
53778 @@ -1457,7 +1457,7 @@ nfsd4_decode_notsupp(struct nfsd4_compoundargs *argp, void *p)
53779
53780 typedef __be32(*nfsd4_dec)(struct nfsd4_compoundargs *argp, void *);
53781
53782 -static nfsd4_dec nfsd4_dec_ops[] = {
53783 +static const nfsd4_dec nfsd4_dec_ops[] = {
53784 [OP_ACCESS] = (nfsd4_dec)nfsd4_decode_access,
53785 [OP_CLOSE] = (nfsd4_dec)nfsd4_decode_close,
53786 [OP_COMMIT] = (nfsd4_dec)nfsd4_decode_commit,
53787 @@ -1497,7 +1497,7 @@ static nfsd4_dec nfsd4_dec_ops[] = {
53788 [OP_RELEASE_LOCKOWNER] = (nfsd4_dec)nfsd4_decode_release_lockowner,
53789 };
53790
53791 -static nfsd4_dec nfsd41_dec_ops[] = {
53792 +static const nfsd4_dec nfsd41_dec_ops[] = {
53793 [OP_ACCESS] = (nfsd4_dec)nfsd4_decode_access,
53794 [OP_CLOSE] = (nfsd4_dec)nfsd4_decode_close,
53795 [OP_COMMIT] = (nfsd4_dec)nfsd4_decode_commit,
53796 @@ -1559,7 +1559,7 @@ static nfsd4_dec nfsd41_dec_ops[] = {
53797 };
53798
53799 struct nfsd4_minorversion_ops {
53800 - nfsd4_dec *decoders;
53801 + const nfsd4_dec *decoders;
53802 int nops;
53803 };
53804
53805 diff --git a/fs/nfsd/nfscache.c b/fs/nfsd/nfscache.c
53806 index ca05f6d..411a576 100644
53807 --- a/fs/nfsd/nfscache.c
53808 +++ b/fs/nfsd/nfscache.c
53809 @@ -461,13 +461,15 @@ nfsd_cache_update(struct svc_rqst *rqstp, int cachetype, __be32 *statp)
53810 {
53811 struct svc_cacherep *rp = rqstp->rq_cacherep;
53812 struct kvec *resv = &rqstp->rq_res.head[0], *cachv;
53813 - int len;
53814 + long len;
53815
53816 if (!rp)
53817 return;
53818
53819 - len = resv->iov_len - ((char*)statp - (char*)resv->iov_base);
53820 - len >>= 2;
53821 + if (statp) {
53822 + len = resv->iov_len - ((char*)statp - (char*)resv->iov_base);
53823 + len >>= 2;
53824 + }
53825
53826 /* Don't cache excessive amounts of data and XDR failures */
53827 if (!statp || len > (256 >> 2)) {
53828 diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
53829 index 2b2e239..c915b48 100644
53830 --- a/fs/nfsd/vfs.c
53831 +++ b/fs/nfsd/vfs.c
53832 @@ -939,7 +939,7 @@ nfsd_vfs_read(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
53833 } else {
53834 oldfs = get_fs();
53835 set_fs(KERNEL_DS);
53836 - host_err = vfs_readv(file, (struct iovec __user *)vec, vlen, &offset);
53837 + host_err = vfs_readv(file, (struct iovec __force_user *)vec, vlen, &offset);
53838 set_fs(oldfs);
53839 }
53840
53841 @@ -1026,7 +1026,7 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
53842
53843 /* Write the data. */
53844 oldfs = get_fs(); set_fs(KERNEL_DS);
53845 - host_err = vfs_writev(file, (struct iovec __user *)vec, vlen, &pos);
53846 + host_err = vfs_writev(file, (struct iovec __force_user *)vec, vlen, &pos);
53847 set_fs(oldfs);
53848 if (host_err < 0)
53849 goto out_nfserr;
53850 @@ -1572,7 +1572,7 @@ nfsd_readlink(struct svc_rqst *rqstp, struct svc_fh *fhp, char *buf, int *lenp)
53851 */
53852
53853 oldfs = get_fs(); set_fs(KERNEL_DS);
53854 - host_err = inode->i_op->readlink(path.dentry, (char __user *)buf, *lenp);
53855 + host_err = inode->i_op->readlink(path.dentry, (char __force_user *)buf, *lenp);
53856 set_fs(oldfs);
53857
53858 if (host_err < 0)
53859 diff --git a/fs/nls/nls_base.c b/fs/nls/nls_base.c
53860 index fea6bd5..8ee9d81 100644
53861 --- a/fs/nls/nls_base.c
53862 +++ b/fs/nls/nls_base.c
53863 @@ -234,20 +234,22 @@ EXPORT_SYMBOL(utf16s_to_utf8s);
53864
53865 int register_nls(struct nls_table * nls)
53866 {
53867 - struct nls_table ** tmp = &tables;
53868 + struct nls_table *tmp = tables;
53869
53870 if (nls->next)
53871 return -EBUSY;
53872
53873 spin_lock(&nls_lock);
53874 - while (*tmp) {
53875 - if (nls == *tmp) {
53876 + while (tmp) {
53877 + if (nls == tmp) {
53878 spin_unlock(&nls_lock);
53879 return -EBUSY;
53880 }
53881 - tmp = &(*tmp)->next;
53882 + tmp = tmp->next;
53883 }
53884 - nls->next = tables;
53885 + pax_open_kernel();
53886 + *(struct nls_table **)&nls->next = tables;
53887 + pax_close_kernel();
53888 tables = nls;
53889 spin_unlock(&nls_lock);
53890 return 0;
53891 @@ -255,12 +257,14 @@ int register_nls(struct nls_table * nls)
53892
53893 int unregister_nls(struct nls_table * nls)
53894 {
53895 - struct nls_table ** tmp = &tables;
53896 + struct nls_table * const * tmp = &tables;
53897
53898 spin_lock(&nls_lock);
53899 while (*tmp) {
53900 if (nls == *tmp) {
53901 - *tmp = nls->next;
53902 + pax_open_kernel();
53903 + *(struct nls_table **)tmp = nls->next;
53904 + pax_close_kernel();
53905 spin_unlock(&nls_lock);
53906 return 0;
53907 }
53908 diff --git a/fs/nls/nls_euc-jp.c b/fs/nls/nls_euc-jp.c
53909 index 7424929..35f6be5 100644
53910 --- a/fs/nls/nls_euc-jp.c
53911 +++ b/fs/nls/nls_euc-jp.c
53912 @@ -561,8 +561,10 @@ static int __init init_nls_euc_jp(void)
53913 p_nls = load_nls("cp932");
53914
53915 if (p_nls) {
53916 - table.charset2upper = p_nls->charset2upper;
53917 - table.charset2lower = p_nls->charset2lower;
53918 + pax_open_kernel();
53919 + *(const unsigned char **)&table.charset2upper = p_nls->charset2upper;
53920 + *(const unsigned char **)&table.charset2lower = p_nls->charset2lower;
53921 + pax_close_kernel();
53922 return register_nls(&table);
53923 }
53924
53925 diff --git a/fs/nls/nls_koi8-ru.c b/fs/nls/nls_koi8-ru.c
53926 index e7bc1d7..06bd4bb 100644
53927 --- a/fs/nls/nls_koi8-ru.c
53928 +++ b/fs/nls/nls_koi8-ru.c
53929 @@ -63,8 +63,10 @@ static int __init init_nls_koi8_ru(void)
53930 p_nls = load_nls("koi8-u");
53931
53932 if (p_nls) {
53933 - table.charset2upper = p_nls->charset2upper;
53934 - table.charset2lower = p_nls->charset2lower;
53935 + pax_open_kernel();
53936 + *(const unsigned char **)&table.charset2upper = p_nls->charset2upper;
53937 + *(const unsigned char **)&table.charset2lower = p_nls->charset2lower;
53938 + pax_close_kernel();
53939 return register_nls(&table);
53940 }
53941
53942 diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c
53943 index 5d84442..bf24453 100644
53944 --- a/fs/notify/fanotify/fanotify_user.c
53945 +++ b/fs/notify/fanotify/fanotify_user.c
53946 @@ -251,8 +251,8 @@ static ssize_t copy_event_to_user(struct fsnotify_group *group,
53947
53948 fd = fanotify_event_metadata.fd;
53949 ret = -EFAULT;
53950 - if (copy_to_user(buf, &fanotify_event_metadata,
53951 - fanotify_event_metadata.event_len))
53952 + if (fanotify_event_metadata.event_len > sizeof fanotify_event_metadata ||
53953 + copy_to_user(buf, &fanotify_event_metadata, fanotify_event_metadata.event_len))
53954 goto out_close_fd;
53955
53956 ret = prepare_for_access_response(group, event, fd);
53957 diff --git a/fs/notify/notification.c b/fs/notify/notification.c
53958 index 7b51b05..5ea5ef6 100644
53959 --- a/fs/notify/notification.c
53960 +++ b/fs/notify/notification.c
53961 @@ -57,7 +57,7 @@ static struct kmem_cache *fsnotify_event_holder_cachep;
53962 * get set to 0 so it will never get 'freed'
53963 */
53964 static struct fsnotify_event *q_overflow_event;
53965 -static atomic_t fsnotify_sync_cookie = ATOMIC_INIT(0);
53966 +static atomic_unchecked_t fsnotify_sync_cookie = ATOMIC_INIT(0);
53967
53968 /**
53969 * fsnotify_get_cookie - return a unique cookie for use in synchronizing events.
53970 @@ -65,7 +65,7 @@ static atomic_t fsnotify_sync_cookie = ATOMIC_INIT(0);
53971 */
53972 u32 fsnotify_get_cookie(void)
53973 {
53974 - return atomic_inc_return(&fsnotify_sync_cookie);
53975 + return atomic_inc_return_unchecked(&fsnotify_sync_cookie);
53976 }
53977 EXPORT_SYMBOL_GPL(fsnotify_get_cookie);
53978
53979 diff --git a/fs/ntfs/dir.c b/fs/ntfs/dir.c
53980 index aa411c3..c260a84 100644
53981 --- a/fs/ntfs/dir.c
53982 +++ b/fs/ntfs/dir.c
53983 @@ -1329,7 +1329,7 @@ find_next_index_buffer:
53984 ia = (INDEX_ALLOCATION*)(kaddr + (ia_pos & ~PAGE_CACHE_MASK &
53985 ~(s64)(ndir->itype.index.block_size - 1)));
53986 /* Bounds checks. */
53987 - if (unlikely((u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE)) {
53988 + if (unlikely(!kaddr || (u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE)) {
53989 ntfs_error(sb, "Out of bounds check failed. Corrupt directory "
53990 "inode 0x%lx or driver bug.", vdir->i_ino);
53991 goto err_out;
53992 diff --git a/fs/ntfs/file.c b/fs/ntfs/file.c
53993 index 5b2d4f0..c6de396 100644
53994 --- a/fs/ntfs/file.c
53995 +++ b/fs/ntfs/file.c
53996 @@ -2242,6 +2242,6 @@ const struct inode_operations ntfs_file_inode_ops = {
53997 #endif /* NTFS_RW */
53998 };
53999
54000 -const struct file_operations ntfs_empty_file_ops = {};
54001 +const struct file_operations ntfs_empty_file_ops __read_only;
54002
54003 -const struct inode_operations ntfs_empty_inode_ops = {};
54004 +const struct inode_operations ntfs_empty_inode_ops __read_only;
54005 diff --git a/fs/ocfs2/localalloc.c b/fs/ocfs2/localalloc.c
54006 index aebeacd..0dcdd26 100644
54007 --- a/fs/ocfs2/localalloc.c
54008 +++ b/fs/ocfs2/localalloc.c
54009 @@ -1278,7 +1278,7 @@ static int ocfs2_local_alloc_slide_window(struct ocfs2_super *osb,
54010 goto bail;
54011 }
54012
54013 - atomic_inc(&osb->alloc_stats.moves);
54014 + atomic_inc_unchecked(&osb->alloc_stats.moves);
54015
54016 bail:
54017 if (handle)
54018 diff --git a/fs/ocfs2/ocfs2.h b/fs/ocfs2/ocfs2.h
54019 index d355e6e..578d905 100644
54020 --- a/fs/ocfs2/ocfs2.h
54021 +++ b/fs/ocfs2/ocfs2.h
54022 @@ -235,11 +235,11 @@ enum ocfs2_vol_state
54023
54024 struct ocfs2_alloc_stats
54025 {
54026 - atomic_t moves;
54027 - atomic_t local_data;
54028 - atomic_t bitmap_data;
54029 - atomic_t bg_allocs;
54030 - atomic_t bg_extends;
54031 + atomic_unchecked_t moves;
54032 + atomic_unchecked_t local_data;
54033 + atomic_unchecked_t bitmap_data;
54034 + atomic_unchecked_t bg_allocs;
54035 + atomic_unchecked_t bg_extends;
54036 };
54037
54038 enum ocfs2_local_alloc_state
54039 diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c
54040 index b7e74b5..19c6536 100644
54041 --- a/fs/ocfs2/suballoc.c
54042 +++ b/fs/ocfs2/suballoc.c
54043 @@ -872,7 +872,7 @@ static int ocfs2_reserve_suballoc_bits(struct ocfs2_super *osb,
54044 mlog_errno(status);
54045 goto bail;
54046 }
54047 - atomic_inc(&osb->alloc_stats.bg_extends);
54048 + atomic_inc_unchecked(&osb->alloc_stats.bg_extends);
54049
54050 /* You should never ask for this much metadata */
54051 BUG_ON(bits_wanted >
54052 @@ -2007,7 +2007,7 @@ int ocfs2_claim_metadata(handle_t *handle,
54053 mlog_errno(status);
54054 goto bail;
54055 }
54056 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
54057 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
54058
54059 *suballoc_loc = res.sr_bg_blkno;
54060 *suballoc_bit_start = res.sr_bit_offset;
54061 @@ -2171,7 +2171,7 @@ int ocfs2_claim_new_inode_at_loc(handle_t *handle,
54062 trace_ocfs2_claim_new_inode_at_loc((unsigned long long)di_blkno,
54063 res->sr_bits);
54064
54065 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
54066 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
54067
54068 BUG_ON(res->sr_bits != 1);
54069
54070 @@ -2213,7 +2213,7 @@ int ocfs2_claim_new_inode(handle_t *handle,
54071 mlog_errno(status);
54072 goto bail;
54073 }
54074 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
54075 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
54076
54077 BUG_ON(res.sr_bits != 1);
54078
54079 @@ -2317,7 +2317,7 @@ int __ocfs2_claim_clusters(handle_t *handle,
54080 cluster_start,
54081 num_clusters);
54082 if (!status)
54083 - atomic_inc(&osb->alloc_stats.local_data);
54084 + atomic_inc_unchecked(&osb->alloc_stats.local_data);
54085 } else {
54086 if (min_clusters > (osb->bitmap_cpg - 1)) {
54087 /* The only paths asking for contiguousness
54088 @@ -2343,7 +2343,7 @@ int __ocfs2_claim_clusters(handle_t *handle,
54089 ocfs2_desc_bitmap_to_cluster_off(ac->ac_inode,
54090 res.sr_bg_blkno,
54091 res.sr_bit_offset);
54092 - atomic_inc(&osb->alloc_stats.bitmap_data);
54093 + atomic_inc_unchecked(&osb->alloc_stats.bitmap_data);
54094 *num_clusters = res.sr_bits;
54095 }
54096 }
54097 diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
54098 index 01b8516..579c4df 100644
54099 --- a/fs/ocfs2/super.c
54100 +++ b/fs/ocfs2/super.c
54101 @@ -301,11 +301,11 @@ static int ocfs2_osb_dump(struct ocfs2_super *osb, char *buf, int len)
54102 "%10s => GlobalAllocs: %d LocalAllocs: %d "
54103 "SubAllocs: %d LAWinMoves: %d SAExtends: %d\n",
54104 "Stats",
54105 - atomic_read(&osb->alloc_stats.bitmap_data),
54106 - atomic_read(&osb->alloc_stats.local_data),
54107 - atomic_read(&osb->alloc_stats.bg_allocs),
54108 - atomic_read(&osb->alloc_stats.moves),
54109 - atomic_read(&osb->alloc_stats.bg_extends));
54110 + atomic_read_unchecked(&osb->alloc_stats.bitmap_data),
54111 + atomic_read_unchecked(&osb->alloc_stats.local_data),
54112 + atomic_read_unchecked(&osb->alloc_stats.bg_allocs),
54113 + atomic_read_unchecked(&osb->alloc_stats.moves),
54114 + atomic_read_unchecked(&osb->alloc_stats.bg_extends));
54115
54116 out += snprintf(buf + out, len - out,
54117 "%10s => State: %u Descriptor: %llu Size: %u bits "
54118 @@ -2122,11 +2122,11 @@ static int ocfs2_initialize_super(struct super_block *sb,
54119 spin_lock_init(&osb->osb_xattr_lock);
54120 ocfs2_init_steal_slots(osb);
54121
54122 - atomic_set(&osb->alloc_stats.moves, 0);
54123 - atomic_set(&osb->alloc_stats.local_data, 0);
54124 - atomic_set(&osb->alloc_stats.bitmap_data, 0);
54125 - atomic_set(&osb->alloc_stats.bg_allocs, 0);
54126 - atomic_set(&osb->alloc_stats.bg_extends, 0);
54127 + atomic_set_unchecked(&osb->alloc_stats.moves, 0);
54128 + atomic_set_unchecked(&osb->alloc_stats.local_data, 0);
54129 + atomic_set_unchecked(&osb->alloc_stats.bitmap_data, 0);
54130 + atomic_set_unchecked(&osb->alloc_stats.bg_allocs, 0);
54131 + atomic_set_unchecked(&osb->alloc_stats.bg_extends, 0);
54132
54133 /* Copy the blockcheck stats from the superblock probe */
54134 osb->osb_ecc_stats = *stats;
54135 diff --git a/fs/open.c b/fs/open.c
54136 index 6835446..eadf09f 100644
54137 --- a/fs/open.c
54138 +++ b/fs/open.c
54139 @@ -32,6 +32,8 @@
54140 #include <linux/dnotify.h>
54141 #include <linux/compat.h>
54142
54143 +#define CREATE_TRACE_POINTS
54144 +#include <trace/events/fs.h>
54145 #include "internal.h"
54146
54147 int do_truncate(struct dentry *dentry, loff_t length, unsigned int time_attrs,
54148 @@ -102,6 +104,8 @@ long vfs_truncate(struct path *path, loff_t length)
54149 error = locks_verify_truncate(inode, NULL, length);
54150 if (!error)
54151 error = security_path_truncate(path);
54152 + if (!error && !gr_acl_handle_truncate(path->dentry, path->mnt))
54153 + error = -EACCES;
54154 if (!error)
54155 error = do_truncate(path->dentry, length, 0, NULL);
54156
54157 @@ -186,6 +190,8 @@ static long do_sys_ftruncate(unsigned int fd, loff_t length, int small)
54158 error = locks_verify_truncate(inode, f.file, length);
54159 if (!error)
54160 error = security_path_truncate(&f.file->f_path);
54161 + if (!error && !gr_acl_handle_truncate(f.file->f_path.dentry, f.file->f_path.mnt))
54162 + error = -EACCES;
54163 if (!error)
54164 error = do_truncate(dentry, length, ATTR_MTIME|ATTR_CTIME, f.file);
54165 sb_end_write(inode->i_sb);
54166 @@ -388,6 +394,9 @@ retry:
54167 if (__mnt_is_readonly(path.mnt))
54168 res = -EROFS;
54169
54170 + if (!res && !gr_acl_handle_access(path.dentry, path.mnt, mode))
54171 + res = -EACCES;
54172 +
54173 out_path_release:
54174 path_put(&path);
54175 if (retry_estale(res, lookup_flags)) {
54176 @@ -419,6 +428,8 @@ retry:
54177 if (error)
54178 goto dput_and_out;
54179
54180 + gr_log_chdir(path.dentry, path.mnt);
54181 +
54182 set_fs_pwd(current->fs, &path);
54183
54184 dput_and_out:
54185 @@ -448,6 +459,13 @@ SYSCALL_DEFINE1(fchdir, unsigned int, fd)
54186 goto out_putf;
54187
54188 error = inode_permission(inode, MAY_EXEC | MAY_CHDIR);
54189 +
54190 + if (!error && !gr_chroot_fchdir(f.file->f_path.dentry, f.file->f_path.mnt))
54191 + error = -EPERM;
54192 +
54193 + if (!error)
54194 + gr_log_chdir(f.file->f_path.dentry, f.file->f_path.mnt);
54195 +
54196 if (!error)
54197 set_fs_pwd(current->fs, &f.file->f_path);
54198 out_putf:
54199 @@ -477,7 +495,13 @@ retry:
54200 if (error)
54201 goto dput_and_out;
54202
54203 + if (gr_handle_chroot_chroot(path.dentry, path.mnt))
54204 + goto dput_and_out;
54205 +
54206 set_fs_root(current->fs, &path);
54207 +
54208 + gr_handle_chroot_chdir(&path);
54209 +
54210 error = 0;
54211 dput_and_out:
54212 path_put(&path);
54213 @@ -499,6 +523,16 @@ static int chmod_common(struct path *path, umode_t mode)
54214 if (error)
54215 return error;
54216 mutex_lock(&inode->i_mutex);
54217 +
54218 + if (!gr_acl_handle_chmod(path->dentry, path->mnt, &mode)) {
54219 + error = -EACCES;
54220 + goto out_unlock;
54221 + }
54222 + if (gr_handle_chroot_chmod(path->dentry, path->mnt, mode)) {
54223 + error = -EACCES;
54224 + goto out_unlock;
54225 + }
54226 +
54227 error = security_path_chmod(path, mode);
54228 if (error)
54229 goto out_unlock;
54230 @@ -559,6 +593,9 @@ static int chown_common(struct path *path, uid_t user, gid_t group)
54231 uid = make_kuid(current_user_ns(), user);
54232 gid = make_kgid(current_user_ns(), group);
54233
54234 + if (!gr_acl_handle_chown(path->dentry, path->mnt))
54235 + return -EACCES;
54236 +
54237 newattrs.ia_valid = ATTR_CTIME;
54238 if (user != (uid_t) -1) {
54239 if (!uid_valid(uid))
54240 @@ -974,6 +1011,7 @@ long do_sys_open(int dfd, const char __user *filename, int flags, umode_t mode)
54241 } else {
54242 fsnotify_open(f);
54243 fd_install(fd, f);
54244 + trace_do_sys_open(tmp->name, flags, mode);
54245 }
54246 }
54247 putname(tmp);
54248 diff --git a/fs/pipe.c b/fs/pipe.c
54249 index 2234f3f..f9083a1 100644
54250 --- a/fs/pipe.c
54251 +++ b/fs/pipe.c
54252 @@ -438,9 +438,9 @@ redo:
54253 }
54254 if (bufs) /* More to do? */
54255 continue;
54256 - if (!pipe->writers)
54257 + if (!atomic_read(&pipe->writers))
54258 break;
54259 - if (!pipe->waiting_writers) {
54260 + if (!atomic_read(&pipe->waiting_writers)) {
54261 /* syscall merging: Usually we must not sleep
54262 * if O_NONBLOCK is set, or if we got some data.
54263 * But if a writer sleeps in kernel space, then
54264 @@ -504,7 +504,7 @@ pipe_write(struct kiocb *iocb, const struct iovec *_iov,
54265 mutex_lock(&inode->i_mutex);
54266 pipe = inode->i_pipe;
54267
54268 - if (!pipe->readers) {
54269 + if (!atomic_read(&pipe->readers)) {
54270 send_sig(SIGPIPE, current, 0);
54271 ret = -EPIPE;
54272 goto out;
54273 @@ -553,7 +553,7 @@ redo1:
54274 for (;;) {
54275 int bufs;
54276
54277 - if (!pipe->readers) {
54278 + if (!atomic_read(&pipe->readers)) {
54279 send_sig(SIGPIPE, current, 0);
54280 if (!ret)
54281 ret = -EPIPE;
54282 @@ -644,9 +644,9 @@ redo2:
54283 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
54284 do_wakeup = 0;
54285 }
54286 - pipe->waiting_writers++;
54287 + atomic_inc(&pipe->waiting_writers);
54288 pipe_wait(pipe);
54289 - pipe->waiting_writers--;
54290 + atomic_dec(&pipe->waiting_writers);
54291 }
54292 out:
54293 mutex_unlock(&inode->i_mutex);
54294 @@ -716,7 +716,7 @@ pipe_poll(struct file *filp, poll_table *wait)
54295 mask = 0;
54296 if (filp->f_mode & FMODE_READ) {
54297 mask = (nrbufs > 0) ? POLLIN | POLLRDNORM : 0;
54298 - if (!pipe->writers && filp->f_version != pipe->w_counter)
54299 + if (!atomic_read(&pipe->writers) && filp->f_version != pipe->w_counter)
54300 mask |= POLLHUP;
54301 }
54302
54303 @@ -726,7 +726,7 @@ pipe_poll(struct file *filp, poll_table *wait)
54304 * Most Unices do not set POLLERR for FIFOs but on Linux they
54305 * behave exactly like pipes for poll().
54306 */
54307 - if (!pipe->readers)
54308 + if (!atomic_read(&pipe->readers))
54309 mask |= POLLERR;
54310 }
54311
54312 @@ -740,10 +740,10 @@ pipe_release(struct inode *inode, int decr, int decw)
54313
54314 mutex_lock(&inode->i_mutex);
54315 pipe = inode->i_pipe;
54316 - pipe->readers -= decr;
54317 - pipe->writers -= decw;
54318 + atomic_sub(decr, &pipe->readers);
54319 + atomic_sub(decw, &pipe->writers);
54320
54321 - if (!pipe->readers && !pipe->writers) {
54322 + if (!atomic_read(&pipe->readers) && !atomic_read(&pipe->writers)) {
54323 free_pipe_info(inode);
54324 } else {
54325 wake_up_interruptible_sync_poll(&pipe->wait, POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM | POLLERR | POLLHUP);
54326 @@ -833,7 +833,7 @@ pipe_read_open(struct inode *inode, struct file *filp)
54327
54328 if (inode->i_pipe) {
54329 ret = 0;
54330 - inode->i_pipe->readers++;
54331 + atomic_inc(&inode->i_pipe->readers);
54332 }
54333
54334 mutex_unlock(&inode->i_mutex);
54335 @@ -850,7 +850,7 @@ pipe_write_open(struct inode *inode, struct file *filp)
54336
54337 if (inode->i_pipe) {
54338 ret = 0;
54339 - inode->i_pipe->writers++;
54340 + atomic_inc(&inode->i_pipe->writers);
54341 }
54342
54343 mutex_unlock(&inode->i_mutex);
54344 @@ -871,9 +871,9 @@ pipe_rdwr_open(struct inode *inode, struct file *filp)
54345 if (inode->i_pipe) {
54346 ret = 0;
54347 if (filp->f_mode & FMODE_READ)
54348 - inode->i_pipe->readers++;
54349 + atomic_inc(&inode->i_pipe->readers);
54350 if (filp->f_mode & FMODE_WRITE)
54351 - inode->i_pipe->writers++;
54352 + atomic_inc(&inode->i_pipe->writers);
54353 }
54354
54355 mutex_unlock(&inode->i_mutex);
54356 @@ -965,7 +965,7 @@ void free_pipe_info(struct inode *inode)
54357 inode->i_pipe = NULL;
54358 }
54359
54360 -static struct vfsmount *pipe_mnt __read_mostly;
54361 +struct vfsmount *pipe_mnt __read_mostly;
54362
54363 /*
54364 * pipefs_dname() is called from d_path().
54365 @@ -995,7 +995,8 @@ static struct inode * get_pipe_inode(void)
54366 goto fail_iput;
54367 inode->i_pipe = pipe;
54368
54369 - pipe->readers = pipe->writers = 1;
54370 + atomic_set(&pipe->readers, 1);
54371 + atomic_set(&pipe->writers, 1);
54372 inode->i_fop = &rdwr_pipefifo_fops;
54373
54374 /*
54375 diff --git a/fs/proc/Kconfig b/fs/proc/Kconfig
54376 index 15af622..0e9f4467 100644
54377 --- a/fs/proc/Kconfig
54378 +++ b/fs/proc/Kconfig
54379 @@ -30,12 +30,12 @@ config PROC_FS
54380
54381 config PROC_KCORE
54382 bool "/proc/kcore support" if !ARM
54383 - depends on PROC_FS && MMU
54384 + depends on PROC_FS && MMU && !GRKERNSEC_PROC_ADD
54385
54386 config PROC_VMCORE
54387 bool "/proc/vmcore support"
54388 - depends on PROC_FS && CRASH_DUMP
54389 - default y
54390 + depends on PROC_FS && CRASH_DUMP && !GRKERNSEC
54391 + default n
54392 help
54393 Exports the dump image of crashed kernel in ELF format.
54394
54395 @@ -59,8 +59,8 @@ config PROC_SYSCTL
54396 limited in memory.
54397
54398 config PROC_PAGE_MONITOR
54399 - default y
54400 - depends on PROC_FS && MMU
54401 + default n
54402 + depends on PROC_FS && MMU && !GRKERNSEC
54403 bool "Enable /proc page monitoring" if EXPERT
54404 help
54405 Various /proc files exist to monitor process memory utilization:
54406 diff --git a/fs/proc/array.c b/fs/proc/array.c
54407 index cbd0f1b..adec3f0 100644
54408 --- a/fs/proc/array.c
54409 +++ b/fs/proc/array.c
54410 @@ -60,6 +60,7 @@
54411 #include <linux/tty.h>
54412 #include <linux/string.h>
54413 #include <linux/mman.h>
54414 +#include <linux/grsecurity.h>
54415 #include <linux/proc_fs.h>
54416 #include <linux/ioport.h>
54417 #include <linux/uaccess.h>
54418 @@ -363,6 +364,21 @@ static void task_cpus_allowed(struct seq_file *m, struct task_struct *task)
54419 seq_putc(m, '\n');
54420 }
54421
54422 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
54423 +static inline void task_pax(struct seq_file *m, struct task_struct *p)
54424 +{
54425 + if (p->mm)
54426 + seq_printf(m, "PaX:\t%c%c%c%c%c\n",
54427 + p->mm->pax_flags & MF_PAX_PAGEEXEC ? 'P' : 'p',
54428 + p->mm->pax_flags & MF_PAX_EMUTRAMP ? 'E' : 'e',
54429 + p->mm->pax_flags & MF_PAX_MPROTECT ? 'M' : 'm',
54430 + p->mm->pax_flags & MF_PAX_RANDMMAP ? 'R' : 'r',
54431 + p->mm->pax_flags & MF_PAX_SEGMEXEC ? 'S' : 's');
54432 + else
54433 + seq_printf(m, "PaX:\t-----\n");
54434 +}
54435 +#endif
54436 +
54437 int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
54438 struct pid *pid, struct task_struct *task)
54439 {
54440 @@ -381,9 +397,24 @@ int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
54441 task_cpus_allowed(m, task);
54442 cpuset_task_status_allowed(m, task);
54443 task_context_switch_counts(m, task);
54444 +
54445 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
54446 + task_pax(m, task);
54447 +#endif
54448 +
54449 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
54450 + task_grsec_rbac(m, task);
54451 +#endif
54452 +
54453 return 0;
54454 }
54455
54456 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54457 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
54458 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
54459 + _mm->pax_flags & MF_PAX_SEGMEXEC))
54460 +#endif
54461 +
54462 static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
54463 struct pid *pid, struct task_struct *task, int whole)
54464 {
54465 @@ -405,6 +436,13 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
54466 char tcomm[sizeof(task->comm)];
54467 unsigned long flags;
54468
54469 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54470 + if (current->exec_id != m->exec_id) {
54471 + gr_log_badprocpid("stat");
54472 + return 0;
54473 + }
54474 +#endif
54475 +
54476 state = *get_task_state(task);
54477 vsize = eip = esp = 0;
54478 permitted = ptrace_may_access(task, PTRACE_MODE_READ | PTRACE_MODE_NOAUDIT);
54479 @@ -476,6 +514,19 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
54480 gtime = task_gtime(task);
54481 }
54482
54483 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54484 + if (PAX_RAND_FLAGS(mm)) {
54485 + eip = 0;
54486 + esp = 0;
54487 + wchan = 0;
54488 + }
54489 +#endif
54490 +#ifdef CONFIG_GRKERNSEC_HIDESYM
54491 + wchan = 0;
54492 + eip =0;
54493 + esp =0;
54494 +#endif
54495 +
54496 /* scale priority and nice values from timeslices to -20..20 */
54497 /* to make it look like a "normal" Unix priority/nice value */
54498 priority = task_prio(task);
54499 @@ -512,9 +563,15 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
54500 seq_put_decimal_ull(m, ' ', vsize);
54501 seq_put_decimal_ull(m, ' ', mm ? get_mm_rss(mm) : 0);
54502 seq_put_decimal_ull(m, ' ', rsslim);
54503 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54504 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 1 : (mm ? (permitted ? mm->start_code : 1) : 0));
54505 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 1 : (mm ? (permitted ? mm->end_code : 1) : 0));
54506 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 0 : ((permitted && mm) ? mm->start_stack : 0));
54507 +#else
54508 seq_put_decimal_ull(m, ' ', mm ? (permitted ? mm->start_code : 1) : 0);
54509 seq_put_decimal_ull(m, ' ', mm ? (permitted ? mm->end_code : 1) : 0);
54510 seq_put_decimal_ull(m, ' ', (permitted && mm) ? mm->start_stack : 0);
54511 +#endif
54512 seq_put_decimal_ull(m, ' ', esp);
54513 seq_put_decimal_ull(m, ' ', eip);
54514 /* The signal information here is obsolete.
54515 @@ -536,7 +593,11 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
54516 seq_put_decimal_ull(m, ' ', cputime_to_clock_t(gtime));
54517 seq_put_decimal_ll(m, ' ', cputime_to_clock_t(cgtime));
54518
54519 - if (mm && permitted) {
54520 + if (mm && permitted
54521 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54522 + && !PAX_RAND_FLAGS(mm)
54523 +#endif
54524 + ) {
54525 seq_put_decimal_ull(m, ' ', mm->start_data);
54526 seq_put_decimal_ull(m, ' ', mm->end_data);
54527 seq_put_decimal_ull(m, ' ', mm->start_brk);
54528 @@ -574,8 +635,15 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
54529 struct pid *pid, struct task_struct *task)
54530 {
54531 unsigned long size = 0, resident = 0, shared = 0, text = 0, data = 0;
54532 - struct mm_struct *mm = get_task_mm(task);
54533 + struct mm_struct *mm;
54534
54535 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54536 + if (current->exec_id != m->exec_id) {
54537 + gr_log_badprocpid("statm");
54538 + return 0;
54539 + }
54540 +#endif
54541 + mm = get_task_mm(task);
54542 if (mm) {
54543 size = task_statm(mm, &shared, &text, &data, &resident);
54544 mmput(mm);
54545 @@ -598,6 +666,13 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
54546 return 0;
54547 }
54548
54549 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
54550 +int proc_pid_ipaddr(struct task_struct *task, char *buffer)
54551 +{
54552 + return sprintf(buffer, "%pI4\n", &task->signal->curr_ip);
54553 +}
54554 +#endif
54555 +
54556 #ifdef CONFIG_CHECKPOINT_RESTORE
54557 static struct pid *
54558 get_children_pid(struct inode *inode, struct pid *pid_prev, loff_t pos)
54559 diff --git a/fs/proc/base.c b/fs/proc/base.c
54560 index 69078c7..3e12a75 100644
54561 --- a/fs/proc/base.c
54562 +++ b/fs/proc/base.c
54563 @@ -112,6 +112,14 @@ struct pid_entry {
54564 union proc_op op;
54565 };
54566
54567 +struct getdents_callback {
54568 + struct linux_dirent __user * current_dir;
54569 + struct linux_dirent __user * previous;
54570 + struct file * file;
54571 + int count;
54572 + int error;
54573 +};
54574 +
54575 #define NOD(NAME, MODE, IOP, FOP, OP) { \
54576 .name = (NAME), \
54577 .len = sizeof(NAME) - 1, \
54578 @@ -209,6 +217,9 @@ static int proc_pid_cmdline(struct task_struct *task, char * buffer)
54579 if (!mm->arg_end)
54580 goto out_mm; /* Shh! No looking before we're done */
54581
54582 + if (gr_acl_handle_procpidmem(task))
54583 + goto out_mm;
54584 +
54585 len = mm->arg_end - mm->arg_start;
54586
54587 if (len > PAGE_SIZE)
54588 @@ -236,12 +247,28 @@ out:
54589 return res;
54590 }
54591
54592 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54593 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
54594 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
54595 + _mm->pax_flags & MF_PAX_SEGMEXEC))
54596 +#endif
54597 +
54598 static int proc_pid_auxv(struct task_struct *task, char *buffer)
54599 {
54600 struct mm_struct *mm = mm_access(task, PTRACE_MODE_READ);
54601 int res = PTR_ERR(mm);
54602 if (mm && !IS_ERR(mm)) {
54603 unsigned int nwords = 0;
54604 +
54605 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54606 + /* allow if we're currently ptracing this task */
54607 + if (PAX_RAND_FLAGS(mm) &&
54608 + (!(task->ptrace & PT_PTRACED) || (task->parent != current))) {
54609 + mmput(mm);
54610 + return 0;
54611 + }
54612 +#endif
54613 +
54614 do {
54615 nwords += 2;
54616 } while (mm->saved_auxv[nwords - 2] != 0); /* AT_NULL */
54617 @@ -255,7 +282,7 @@ static int proc_pid_auxv(struct task_struct *task, char *buffer)
54618 }
54619
54620
54621 -#ifdef CONFIG_KALLSYMS
54622 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
54623 /*
54624 * Provides a wchan file via kallsyms in a proper one-value-per-file format.
54625 * Returns the resolved symbol. If that fails, simply return the address.
54626 @@ -294,7 +321,7 @@ static void unlock_trace(struct task_struct *task)
54627 mutex_unlock(&task->signal->cred_guard_mutex);
54628 }
54629
54630 -#ifdef CONFIG_STACKTRACE
54631 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
54632
54633 #define MAX_STACK_TRACE_DEPTH 64
54634
54635 @@ -486,7 +513,7 @@ static int proc_pid_limits(struct task_struct *task, char *buffer)
54636 return count;
54637 }
54638
54639 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
54640 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
54641 static int proc_pid_syscall(struct task_struct *task, char *buffer)
54642 {
54643 long nr;
54644 @@ -515,7 +542,7 @@ static int proc_pid_syscall(struct task_struct *task, char *buffer)
54645 /************************************************************************/
54646
54647 /* permission checks */
54648 -static int proc_fd_access_allowed(struct inode *inode)
54649 +static int proc_fd_access_allowed(struct inode *inode, unsigned int log)
54650 {
54651 struct task_struct *task;
54652 int allowed = 0;
54653 @@ -525,7 +552,10 @@ static int proc_fd_access_allowed(struct inode *inode)
54654 */
54655 task = get_proc_task(inode);
54656 if (task) {
54657 - allowed = ptrace_may_access(task, PTRACE_MODE_READ);
54658 + if (log)
54659 + allowed = ptrace_may_access(task, PTRACE_MODE_READ);
54660 + else
54661 + allowed = ptrace_may_access(task, PTRACE_MODE_READ | PTRACE_MODE_NOAUDIT);
54662 put_task_struct(task);
54663 }
54664 return allowed;
54665 @@ -556,10 +586,35 @@ static bool has_pid_permissions(struct pid_namespace *pid,
54666 struct task_struct *task,
54667 int hide_pid_min)
54668 {
54669 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
54670 + return false;
54671 +
54672 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
54673 + rcu_read_lock();
54674 + {
54675 + const struct cred *tmpcred = current_cred();
54676 + const struct cred *cred = __task_cred(task);
54677 +
54678 + if (uid_eq(tmpcred->uid, GLOBAL_ROOT_UID) || uid_eq(tmpcred->uid, cred->uid)
54679 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
54680 + || in_group_p(grsec_proc_gid)
54681 +#endif
54682 + ) {
54683 + rcu_read_unlock();
54684 + return true;
54685 + }
54686 + }
54687 + rcu_read_unlock();
54688 +
54689 + if (!pid->hide_pid)
54690 + return false;
54691 +#endif
54692 +
54693 if (pid->hide_pid < hide_pid_min)
54694 return true;
54695 if (in_group_p(pid->pid_gid))
54696 return true;
54697 +
54698 return ptrace_may_access(task, PTRACE_MODE_READ);
54699 }
54700
54701 @@ -577,7 +632,11 @@ static int proc_pid_permission(struct inode *inode, int mask)
54702 put_task_struct(task);
54703
54704 if (!has_perms) {
54705 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
54706 + {
54707 +#else
54708 if (pid->hide_pid == 2) {
54709 +#endif
54710 /*
54711 * Let's make getdents(), stat(), and open()
54712 * consistent with each other. If a process
54713 @@ -675,6 +734,11 @@ static int __mem_open(struct inode *inode, struct file *file, unsigned int mode)
54714 if (!task)
54715 return -ESRCH;
54716
54717 + if (gr_acl_handle_procpidmem(task)) {
54718 + put_task_struct(task);
54719 + return -EPERM;
54720 + }
54721 +
54722 mm = mm_access(task, mode);
54723 put_task_struct(task);
54724
54725 @@ -690,6 +754,10 @@ static int __mem_open(struct inode *inode, struct file *file, unsigned int mode)
54726
54727 file->private_data = mm;
54728
54729 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54730 + file->f_version = current->exec_id;
54731 +#endif
54732 +
54733 return 0;
54734 }
54735
54736 @@ -711,6 +779,17 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
54737 ssize_t copied;
54738 char *page;
54739
54740 +#ifdef CONFIG_GRKERNSEC
54741 + if (write)
54742 + return -EPERM;
54743 +#endif
54744 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54745 + if (file->f_version != current->exec_id) {
54746 + gr_log_badprocpid("mem");
54747 + return 0;
54748 + }
54749 +#endif
54750 +
54751 if (!mm)
54752 return 0;
54753
54754 @@ -723,7 +802,7 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
54755 goto free;
54756
54757 while (count > 0) {
54758 - int this_len = min_t(int, count, PAGE_SIZE);
54759 + ssize_t this_len = min_t(ssize_t, count, PAGE_SIZE);
54760
54761 if (write && copy_from_user(page, buf, this_len)) {
54762 copied = -EFAULT;
54763 @@ -815,6 +894,13 @@ static ssize_t environ_read(struct file *file, char __user *buf,
54764 if (!mm)
54765 return 0;
54766
54767 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54768 + if (file->f_version != current->exec_id) {
54769 + gr_log_badprocpid("environ");
54770 + return 0;
54771 + }
54772 +#endif
54773 +
54774 page = (char *)__get_free_page(GFP_TEMPORARY);
54775 if (!page)
54776 return -ENOMEM;
54777 @@ -824,7 +910,7 @@ static ssize_t environ_read(struct file *file, char __user *buf,
54778 goto free;
54779 while (count > 0) {
54780 size_t this_len, max_len;
54781 - int retval;
54782 + ssize_t retval;
54783
54784 if (src >= (mm->env_end - mm->env_start))
54785 break;
54786 @@ -1430,7 +1516,7 @@ static void *proc_pid_follow_link(struct dentry *dentry, struct nameidata *nd)
54787 int error = -EACCES;
54788
54789 /* Are we allowed to snoop on the tasks file descriptors? */
54790 - if (!proc_fd_access_allowed(inode))
54791 + if (!proc_fd_access_allowed(inode, 0))
54792 goto out;
54793
54794 error = PROC_I(inode)->op.proc_get_link(dentry, &path);
54795 @@ -1474,8 +1560,18 @@ static int proc_pid_readlink(struct dentry * dentry, char __user * buffer, int b
54796 struct path path;
54797
54798 /* Are we allowed to snoop on the tasks file descriptors? */
54799 - if (!proc_fd_access_allowed(inode))
54800 - goto out;
54801 + /* logging this is needed for learning on chromium to work properly,
54802 + but we don't want to flood the logs from 'ps' which does a readlink
54803 + on /proc/fd/2 of tasks in the listing, nor do we want 'ps' to learn
54804 + CAP_SYS_PTRACE as it's not necessary for its basic functionality
54805 + */
54806 + if (dentry->d_name.name[0] == '2' && dentry->d_name.name[1] == '\0') {
54807 + if (!proc_fd_access_allowed(inode,0))
54808 + goto out;
54809 + } else {
54810 + if (!proc_fd_access_allowed(inode,1))
54811 + goto out;
54812 + }
54813
54814 error = PROC_I(inode)->op.proc_get_link(dentry, &path);
54815 if (error)
54816 @@ -1525,7 +1621,11 @@ struct inode *proc_pid_make_inode(struct super_block * sb, struct task_struct *t
54817 rcu_read_lock();
54818 cred = __task_cred(task);
54819 inode->i_uid = cred->euid;
54820 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
54821 + inode->i_gid = grsec_proc_gid;
54822 +#else
54823 inode->i_gid = cred->egid;
54824 +#endif
54825 rcu_read_unlock();
54826 }
54827 security_task_to_inode(task, inode);
54828 @@ -1561,10 +1661,19 @@ int pid_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
54829 return -ENOENT;
54830 }
54831 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
54832 +#ifdef CONFIG_GRKERNSEC_PROC_USER
54833 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IXUSR)) ||
54834 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
54835 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP)) ||
54836 +#endif
54837 task_dumpable(task)) {
54838 cred = __task_cred(task);
54839 stat->uid = cred->euid;
54840 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
54841 + stat->gid = grsec_proc_gid;
54842 +#else
54843 stat->gid = cred->egid;
54844 +#endif
54845 }
54846 }
54847 rcu_read_unlock();
54848 @@ -1602,11 +1711,20 @@ int pid_revalidate(struct dentry *dentry, unsigned int flags)
54849
54850 if (task) {
54851 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
54852 +#ifdef CONFIG_GRKERNSEC_PROC_USER
54853 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IXUSR)) ||
54854 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
54855 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP)) ||
54856 +#endif
54857 task_dumpable(task)) {
54858 rcu_read_lock();
54859 cred = __task_cred(task);
54860 inode->i_uid = cred->euid;
54861 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
54862 + inode->i_gid = grsec_proc_gid;
54863 +#else
54864 inode->i_gid = cred->egid;
54865 +#endif
54866 rcu_read_unlock();
54867 } else {
54868 inode->i_uid = GLOBAL_ROOT_UID;
54869 @@ -2059,6 +2177,9 @@ static struct dentry *proc_pident_lookup(struct inode *dir,
54870 if (!task)
54871 goto out_no_task;
54872
54873 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
54874 + goto out;
54875 +
54876 /*
54877 * Yes, it does not scale. And it should not. Don't add
54878 * new entries into /proc/<tgid>/ without very good reasons.
54879 @@ -2103,6 +2224,9 @@ static int proc_pident_readdir(struct file *filp,
54880 if (!task)
54881 goto out_no_task;
54882
54883 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
54884 + goto out;
54885 +
54886 ret = 0;
54887 i = filp->f_pos;
54888 switch (i) {
54889 @@ -2516,7 +2640,7 @@ static const struct pid_entry tgid_base_stuff[] = {
54890 REG("autogroup", S_IRUGO|S_IWUSR, proc_pid_sched_autogroup_operations),
54891 #endif
54892 REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
54893 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
54894 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
54895 INF("syscall", S_IRUGO, proc_pid_syscall),
54896 #endif
54897 INF("cmdline", S_IRUGO, proc_pid_cmdline),
54898 @@ -2541,10 +2665,10 @@ static const struct pid_entry tgid_base_stuff[] = {
54899 #ifdef CONFIG_SECURITY
54900 DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations),
54901 #endif
54902 -#ifdef CONFIG_KALLSYMS
54903 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
54904 INF("wchan", S_IRUGO, proc_pid_wchan),
54905 #endif
54906 -#ifdef CONFIG_STACKTRACE
54907 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
54908 ONE("stack", S_IRUGO, proc_pid_stack),
54909 #endif
54910 #ifdef CONFIG_SCHEDSTATS
54911 @@ -2578,6 +2702,9 @@ static const struct pid_entry tgid_base_stuff[] = {
54912 #ifdef CONFIG_HARDWALL
54913 INF("hardwall", S_IRUGO, proc_pid_hardwall),
54914 #endif
54915 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
54916 + INF("ipaddr", S_IRUSR, proc_pid_ipaddr),
54917 +#endif
54918 #ifdef CONFIG_USER_NS
54919 REG("uid_map", S_IRUGO|S_IWUSR, proc_uid_map_operations),
54920 REG("gid_map", S_IRUGO|S_IWUSR, proc_gid_map_operations),
54921 @@ -2707,7 +2834,14 @@ static struct dentry *proc_pid_instantiate(struct inode *dir,
54922 if (!inode)
54923 goto out;
54924
54925 +#ifdef CONFIG_GRKERNSEC_PROC_USER
54926 + inode->i_mode = S_IFDIR|S_IRUSR|S_IXUSR;
54927 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
54928 + inode->i_gid = grsec_proc_gid;
54929 + inode->i_mode = S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP;
54930 +#else
54931 inode->i_mode = S_IFDIR|S_IRUGO|S_IXUGO;
54932 +#endif
54933 inode->i_op = &proc_tgid_base_inode_operations;
54934 inode->i_fop = &proc_tgid_base_operations;
54935 inode->i_flags|=S_IMMUTABLE;
54936 @@ -2745,7 +2879,11 @@ struct dentry *proc_pid_lookup(struct inode *dir, struct dentry * dentry, unsign
54937 if (!task)
54938 goto out;
54939
54940 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
54941 + goto out_put_task;
54942 +
54943 result = proc_pid_instantiate(dir, dentry, task, NULL);
54944 +out_put_task:
54945 put_task_struct(task);
54946 out:
54947 return result;
54948 @@ -2808,6 +2946,8 @@ static int proc_pid_fill_cache(struct file *filp, void *dirent, filldir_t filldi
54949 static int fake_filldir(void *buf, const char *name, int namelen,
54950 loff_t offset, u64 ino, unsigned d_type)
54951 {
54952 + struct getdents_callback * __buf = (struct getdents_callback *) buf;
54953 + __buf->error = -EINVAL;
54954 return 0;
54955 }
54956
54957 @@ -2859,7 +2999,7 @@ static const struct pid_entry tid_base_stuff[] = {
54958 REG("sched", S_IRUGO|S_IWUSR, proc_pid_sched_operations),
54959 #endif
54960 REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
54961 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
54962 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
54963 INF("syscall", S_IRUGO, proc_pid_syscall),
54964 #endif
54965 INF("cmdline", S_IRUGO, proc_pid_cmdline),
54966 @@ -2886,10 +3026,10 @@ static const struct pid_entry tid_base_stuff[] = {
54967 #ifdef CONFIG_SECURITY
54968 DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations),
54969 #endif
54970 -#ifdef CONFIG_KALLSYMS
54971 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
54972 INF("wchan", S_IRUGO, proc_pid_wchan),
54973 #endif
54974 -#ifdef CONFIG_STACKTRACE
54975 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
54976 ONE("stack", S_IRUGO, proc_pid_stack),
54977 #endif
54978 #ifdef CONFIG_SCHEDSTATS
54979 diff --git a/fs/proc/cmdline.c b/fs/proc/cmdline.c
54980 index 82676e3..5f8518a 100644
54981 --- a/fs/proc/cmdline.c
54982 +++ b/fs/proc/cmdline.c
54983 @@ -23,7 +23,11 @@ static const struct file_operations cmdline_proc_fops = {
54984
54985 static int __init proc_cmdline_init(void)
54986 {
54987 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
54988 + proc_create_grsec("cmdline", 0, NULL, &cmdline_proc_fops);
54989 +#else
54990 proc_create("cmdline", 0, NULL, &cmdline_proc_fops);
54991 +#endif
54992 return 0;
54993 }
54994 module_init(proc_cmdline_init);
54995 diff --git a/fs/proc/devices.c b/fs/proc/devices.c
54996 index b143471..bb105e5 100644
54997 --- a/fs/proc/devices.c
54998 +++ b/fs/proc/devices.c
54999 @@ -64,7 +64,11 @@ static const struct file_operations proc_devinfo_operations = {
55000
55001 static int __init proc_devices_init(void)
55002 {
55003 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
55004 + proc_create_grsec("devices", 0, NULL, &proc_devinfo_operations);
55005 +#else
55006 proc_create("devices", 0, NULL, &proc_devinfo_operations);
55007 +#endif
55008 return 0;
55009 }
55010 module_init(proc_devices_init);
55011 diff --git a/fs/proc/fd.c b/fs/proc/fd.c
55012 index d7a4a28..0201742 100644
55013 --- a/fs/proc/fd.c
55014 +++ b/fs/proc/fd.c
55015 @@ -25,7 +25,8 @@ static int seq_show(struct seq_file *m, void *v)
55016 if (!task)
55017 return -ENOENT;
55018
55019 - files = get_files_struct(task);
55020 + if (!gr_acl_handle_procpidmem(task))
55021 + files = get_files_struct(task);
55022 put_task_struct(task);
55023
55024 if (files) {
55025 @@ -302,11 +303,21 @@ static struct dentry *proc_lookupfd(struct inode *dir, struct dentry *dentry,
55026 */
55027 int proc_fd_permission(struct inode *inode, int mask)
55028 {
55029 + struct task_struct *task;
55030 int rv = generic_permission(inode, mask);
55031 - if (rv == 0)
55032 - return 0;
55033 +
55034 if (task_pid(current) == proc_pid(inode))
55035 rv = 0;
55036 +
55037 + task = get_proc_task(inode);
55038 + if (task == NULL)
55039 + return rv;
55040 +
55041 + if (gr_acl_handle_procpidmem(task))
55042 + rv = -EACCES;
55043 +
55044 + put_task_struct(task);
55045 +
55046 return rv;
55047 }
55048
55049 diff --git a/fs/proc/inode.c b/fs/proc/inode.c
55050 index 869116c..820cb27 100644
55051 --- a/fs/proc/inode.c
55052 +++ b/fs/proc/inode.c
55053 @@ -22,11 +22,17 @@
55054 #include <linux/seq_file.h>
55055 #include <linux/slab.h>
55056 #include <linux/mount.h>
55057 +#include <linux/grsecurity.h>
55058
55059 #include <asm/uaccess.h>
55060
55061 #include "internal.h"
55062
55063 +#ifdef CONFIG_PROC_SYSCTL
55064 +extern const struct inode_operations proc_sys_inode_operations;
55065 +extern const struct inode_operations proc_sys_dir_operations;
55066 +#endif
55067 +
55068 static void proc_evict_inode(struct inode *inode)
55069 {
55070 struct proc_dir_entry *de;
55071 @@ -54,6 +60,13 @@ static void proc_evict_inode(struct inode *inode)
55072 ns = PROC_I(inode)->ns;
55073 if (ns_ops && ns)
55074 ns_ops->put(ns);
55075 +
55076 +#ifdef CONFIG_PROC_SYSCTL
55077 + if (inode->i_op == &proc_sys_inode_operations ||
55078 + inode->i_op == &proc_sys_dir_operations)
55079 + gr_handle_delete(inode->i_ino, inode->i_sb->s_dev);
55080 +#endif
55081 +
55082 }
55083
55084 static struct kmem_cache * proc_inode_cachep;
55085 @@ -456,7 +469,11 @@ struct inode *proc_get_inode(struct super_block *sb, struct proc_dir_entry *de)
55086 if (de->mode) {
55087 inode->i_mode = de->mode;
55088 inode->i_uid = de->uid;
55089 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
55090 + inode->i_gid = grsec_proc_gid;
55091 +#else
55092 inode->i_gid = de->gid;
55093 +#endif
55094 }
55095 if (de->size)
55096 inode->i_size = de->size;
55097 diff --git a/fs/proc/internal.h b/fs/proc/internal.h
55098 index 85ff3a4..a512bd8 100644
55099 --- a/fs/proc/internal.h
55100 +++ b/fs/proc/internal.h
55101 @@ -56,6 +56,9 @@ extern int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
55102 struct pid *pid, struct task_struct *task);
55103 extern int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
55104 struct pid *pid, struct task_struct *task);
55105 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
55106 +extern int proc_pid_ipaddr(struct task_struct *task, char *buffer);
55107 +#endif
55108 extern loff_t mem_lseek(struct file *file, loff_t offset, int orig);
55109
55110 extern const struct file_operations proc_tid_children_operations;
55111 diff --git a/fs/proc/kcore.c b/fs/proc/kcore.c
55112 index eda6f01..006ae24 100644
55113 --- a/fs/proc/kcore.c
55114 +++ b/fs/proc/kcore.c
55115 @@ -481,9 +481,10 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
55116 * the addresses in the elf_phdr on our list.
55117 */
55118 start = kc_offset_to_vaddr(*fpos - elf_buflen);
55119 - if ((tsz = (PAGE_SIZE - (start & ~PAGE_MASK))) > buflen)
55120 + tsz = PAGE_SIZE - (start & ~PAGE_MASK);
55121 + if (tsz > buflen)
55122 tsz = buflen;
55123 -
55124 +
55125 while (buflen) {
55126 struct kcore_list *m;
55127
55128 @@ -512,20 +513,23 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
55129 kfree(elf_buf);
55130 } else {
55131 if (kern_addr_valid(start)) {
55132 - unsigned long n;
55133 + char *elf_buf;
55134 + mm_segment_t oldfs;
55135
55136 - n = copy_to_user(buffer, (char *)start, tsz);
55137 - /*
55138 - * We cannot distinguish between fault on source
55139 - * and fault on destination. When this happens
55140 - * we clear too and hope it will trigger the
55141 - * EFAULT again.
55142 - */
55143 - if (n) {
55144 - if (clear_user(buffer + tsz - n,
55145 - n))
55146 + elf_buf = kmalloc(tsz, GFP_KERNEL);
55147 + if (!elf_buf)
55148 + return -ENOMEM;
55149 + oldfs = get_fs();
55150 + set_fs(KERNEL_DS);
55151 + if (!__copy_from_user(elf_buf, (const void __user *)start, tsz)) {
55152 + set_fs(oldfs);
55153 + if (copy_to_user(buffer, elf_buf, tsz)) {
55154 + kfree(elf_buf);
55155 return -EFAULT;
55156 + }
55157 }
55158 + set_fs(oldfs);
55159 + kfree(elf_buf);
55160 } else {
55161 if (clear_user(buffer, tsz))
55162 return -EFAULT;
55163 @@ -545,6 +549,9 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
55164
55165 static int open_kcore(struct inode *inode, struct file *filp)
55166 {
55167 +#if defined(CONFIG_GRKERNSEC_PROC_ADD) || defined(CONFIG_GRKERNSEC_HIDESYM)
55168 + return -EPERM;
55169 +#endif
55170 if (!capable(CAP_SYS_RAWIO))
55171 return -EPERM;
55172 if (kcore_need_update)
55173 diff --git a/fs/proc/meminfo.c b/fs/proc/meminfo.c
55174 index 1efaaa1..834e49a 100644
55175 --- a/fs/proc/meminfo.c
55176 +++ b/fs/proc/meminfo.c
55177 @@ -158,7 +158,7 @@ static int meminfo_proc_show(struct seq_file *m, void *v)
55178 vmi.used >> 10,
55179 vmi.largest_chunk >> 10
55180 #ifdef CONFIG_MEMORY_FAILURE
55181 - ,atomic_long_read(&num_poisoned_pages) << (PAGE_SHIFT - 10)
55182 + ,atomic_long_read_unchecked(&num_poisoned_pages) << (PAGE_SHIFT - 10)
55183 #endif
55184 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
55185 ,K(global_page_state(NR_ANON_TRANSPARENT_HUGEPAGES) *
55186 diff --git a/fs/proc/nommu.c b/fs/proc/nommu.c
55187 index ccfd99b..1b7e255 100644
55188 --- a/fs/proc/nommu.c
55189 +++ b/fs/proc/nommu.c
55190 @@ -66,7 +66,7 @@ static int nommu_region_show(struct seq_file *m, struct vm_region *region)
55191 if (len < 1)
55192 len = 1;
55193 seq_printf(m, "%*c", len, ' ');
55194 - seq_path(m, &file->f_path, "");
55195 + seq_path(m, &file->f_path, "\n\\");
55196 }
55197
55198 seq_putc(m, '\n');
55199 diff --git a/fs/proc/proc_net.c b/fs/proc/proc_net.c
55200 index b4ac657..0842bd2 100644
55201 --- a/fs/proc/proc_net.c
55202 +++ b/fs/proc/proc_net.c
55203 @@ -23,6 +23,7 @@
55204 #include <linux/nsproxy.h>
55205 #include <net/net_namespace.h>
55206 #include <linux/seq_file.h>
55207 +#include <linux/grsecurity.h>
55208
55209 #include "internal.h"
55210
55211 @@ -105,6 +106,17 @@ static struct net *get_proc_task_net(struct inode *dir)
55212 struct task_struct *task;
55213 struct nsproxy *ns;
55214 struct net *net = NULL;
55215 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55216 + const struct cred *cred = current_cred();
55217 +#endif
55218 +
55219 +#ifdef CONFIG_GRKERNSEC_PROC_USER
55220 + if (!uid_eq(cred->fsuid, GLOBAL_ROOT_UID))
55221 + return net;
55222 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55223 + if (!uid_eq(cred->fsuid, GLOBAL_ROOT_UID) && !in_group_p(grsec_proc_gid))
55224 + return net;
55225 +#endif
55226
55227 rcu_read_lock();
55228 task = pid_task(proc_pid(dir), PIDTYPE_PID);
55229 diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
55230 index ac05f33..1e6dc7e 100644
55231 --- a/fs/proc/proc_sysctl.c
55232 +++ b/fs/proc/proc_sysctl.c
55233 @@ -13,11 +13,15 @@
55234 #include <linux/module.h>
55235 #include "internal.h"
55236
55237 +extern int gr_handle_chroot_sysctl(const int op);
55238 +extern int gr_handle_sysctl_mod(const char *dirname, const char *name,
55239 + const int op);
55240 +
55241 static const struct dentry_operations proc_sys_dentry_operations;
55242 static const struct file_operations proc_sys_file_operations;
55243 -static const struct inode_operations proc_sys_inode_operations;
55244 +const struct inode_operations proc_sys_inode_operations;
55245 static const struct file_operations proc_sys_dir_file_operations;
55246 -static const struct inode_operations proc_sys_dir_operations;
55247 +const struct inode_operations proc_sys_dir_operations;
55248
55249 void proc_sys_poll_notify(struct ctl_table_poll *poll)
55250 {
55251 @@ -467,6 +471,9 @@ static struct dentry *proc_sys_lookup(struct inode *dir, struct dentry *dentry,
55252
55253 err = NULL;
55254 d_set_d_op(dentry, &proc_sys_dentry_operations);
55255 +
55256 + gr_handle_proc_create(dentry, inode);
55257 +
55258 d_add(dentry, inode);
55259
55260 out:
55261 @@ -482,6 +489,7 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
55262 struct inode *inode = file_inode(filp);
55263 struct ctl_table_header *head = grab_header(inode);
55264 struct ctl_table *table = PROC_I(inode)->sysctl_entry;
55265 + int op = write ? MAY_WRITE : MAY_READ;
55266 ssize_t error;
55267 size_t res;
55268
55269 @@ -493,7 +501,7 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
55270 * and won't be until we finish.
55271 */
55272 error = -EPERM;
55273 - if (sysctl_perm(head, table, write ? MAY_WRITE : MAY_READ))
55274 + if (sysctl_perm(head, table, op))
55275 goto out;
55276
55277 /* if that can happen at all, it should be -EINVAL, not -EISDIR */
55278 @@ -501,6 +509,22 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
55279 if (!table->proc_handler)
55280 goto out;
55281
55282 +#ifdef CONFIG_GRKERNSEC
55283 + error = -EPERM;
55284 + if (gr_handle_chroot_sysctl(op))
55285 + goto out;
55286 + dget(filp->f_path.dentry);
55287 + if (gr_handle_sysctl_mod(filp->f_path.dentry->d_parent->d_name.name, table->procname, op)) {
55288 + dput(filp->f_path.dentry);
55289 + goto out;
55290 + }
55291 + dput(filp->f_path.dentry);
55292 + if (!gr_acl_handle_open(filp->f_path.dentry, filp->f_path.mnt, op))
55293 + goto out;
55294 + if (write && !capable(CAP_SYS_ADMIN))
55295 + goto out;
55296 +#endif
55297 +
55298 /* careful: calling conventions are nasty here */
55299 res = count;
55300 error = table->proc_handler(table, write, buf, &res, ppos);
55301 @@ -598,6 +622,9 @@ static int proc_sys_fill_cache(struct file *filp, void *dirent,
55302 return -ENOMEM;
55303 } else {
55304 d_set_d_op(child, &proc_sys_dentry_operations);
55305 +
55306 + gr_handle_proc_create(child, inode);
55307 +
55308 d_add(child, inode);
55309 }
55310 } else {
55311 @@ -641,6 +668,9 @@ static int scan(struct ctl_table_header *head, ctl_table *table,
55312 if ((*pos)++ < file->f_pos)
55313 return 0;
55314
55315 + if (!gr_acl_handle_hidden_file(file->f_path.dentry, file->f_path.mnt))
55316 + return 0;
55317 +
55318 if (unlikely(S_ISLNK(table->mode)))
55319 res = proc_sys_link_fill_cache(file, dirent, filldir, head, table);
55320 else
55321 @@ -751,6 +781,9 @@ static int proc_sys_getattr(struct vfsmount *mnt, struct dentry *dentry, struct
55322 if (IS_ERR(head))
55323 return PTR_ERR(head);
55324
55325 + if (table && !gr_acl_handle_hidden_file(dentry, mnt))
55326 + return -ENOENT;
55327 +
55328 generic_fillattr(inode, stat);
55329 if (table)
55330 stat->mode = (stat->mode & S_IFMT) | table->mode;
55331 @@ -773,13 +806,13 @@ static const struct file_operations proc_sys_dir_file_operations = {
55332 .llseek = generic_file_llseek,
55333 };
55334
55335 -static const struct inode_operations proc_sys_inode_operations = {
55336 +const struct inode_operations proc_sys_inode_operations = {
55337 .permission = proc_sys_permission,
55338 .setattr = proc_sys_setattr,
55339 .getattr = proc_sys_getattr,
55340 };
55341
55342 -static const struct inode_operations proc_sys_dir_operations = {
55343 +const struct inode_operations proc_sys_dir_operations = {
55344 .lookup = proc_sys_lookup,
55345 .permission = proc_sys_permission,
55346 .setattr = proc_sys_setattr,
55347 @@ -855,7 +888,7 @@ static struct ctl_dir *find_subdir(struct ctl_dir *dir,
55348 static struct ctl_dir *new_dir(struct ctl_table_set *set,
55349 const char *name, int namelen)
55350 {
55351 - struct ctl_table *table;
55352 + ctl_table_no_const *table;
55353 struct ctl_dir *new;
55354 struct ctl_node *node;
55355 char *new_name;
55356 @@ -867,7 +900,7 @@ static struct ctl_dir *new_dir(struct ctl_table_set *set,
55357 return NULL;
55358
55359 node = (struct ctl_node *)(new + 1);
55360 - table = (struct ctl_table *)(node + 1);
55361 + table = (ctl_table_no_const *)(node + 1);
55362 new_name = (char *)(table + 2);
55363 memcpy(new_name, name, namelen);
55364 new_name[namelen] = '\0';
55365 @@ -1036,7 +1069,8 @@ static int sysctl_check_table(const char *path, struct ctl_table *table)
55366 static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table *table,
55367 struct ctl_table_root *link_root)
55368 {
55369 - struct ctl_table *link_table, *entry, *link;
55370 + ctl_table_no_const *link_table, *link;
55371 + struct ctl_table *entry;
55372 struct ctl_table_header *links;
55373 struct ctl_node *node;
55374 char *link_name;
55375 @@ -1059,7 +1093,7 @@ static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table
55376 return NULL;
55377
55378 node = (struct ctl_node *)(links + 1);
55379 - link_table = (struct ctl_table *)(node + nr_entries);
55380 + link_table = (ctl_table_no_const *)(node + nr_entries);
55381 link_name = (char *)&link_table[nr_entries + 1];
55382
55383 for (link = link_table, entry = table; entry->procname; link++, entry++) {
55384 @@ -1307,8 +1341,8 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
55385 struct ctl_table_header ***subheader, struct ctl_table_set *set,
55386 struct ctl_table *table)
55387 {
55388 - struct ctl_table *ctl_table_arg = NULL;
55389 - struct ctl_table *entry, *files;
55390 + ctl_table_no_const *ctl_table_arg = NULL, *files = NULL;
55391 + struct ctl_table *entry;
55392 int nr_files = 0;
55393 int nr_dirs = 0;
55394 int err = -ENOMEM;
55395 @@ -1320,10 +1354,9 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
55396 nr_files++;
55397 }
55398
55399 - files = table;
55400 /* If there are mixed files and directories we need a new table */
55401 if (nr_dirs && nr_files) {
55402 - struct ctl_table *new;
55403 + ctl_table_no_const *new;
55404 files = kzalloc(sizeof(struct ctl_table) * (nr_files + 1),
55405 GFP_KERNEL);
55406 if (!files)
55407 @@ -1341,7 +1374,7 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
55408 /* Register everything except a directory full of subdirectories */
55409 if (nr_files || !nr_dirs) {
55410 struct ctl_table_header *header;
55411 - header = __register_sysctl_table(set, path, files);
55412 + header = __register_sysctl_table(set, path, files ? files : table);
55413 if (!header) {
55414 kfree(ctl_table_arg);
55415 goto out;
55416 diff --git a/fs/proc/root.c b/fs/proc/root.c
55417 index 9c7fab1..ed1c8e0 100644
55418 --- a/fs/proc/root.c
55419 +++ b/fs/proc/root.c
55420 @@ -180,7 +180,15 @@ void __init proc_root_init(void)
55421 #ifdef CONFIG_PROC_DEVICETREE
55422 proc_device_tree_init();
55423 #endif
55424 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
55425 +#ifdef CONFIG_GRKERNSEC_PROC_USER
55426 + proc_mkdir_mode("bus", S_IRUSR | S_IXUSR, NULL);
55427 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55428 + proc_mkdir_mode("bus", S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP, NULL);
55429 +#endif
55430 +#else
55431 proc_mkdir("bus", NULL);
55432 +#endif
55433 proc_sys_init();
55434 }
55435
55436 diff --git a/fs/proc/self.c b/fs/proc/self.c
55437 index aa5cc3b..c91a5d0 100644
55438 --- a/fs/proc/self.c
55439 +++ b/fs/proc/self.c
55440 @@ -37,7 +37,7 @@ static void *proc_self_follow_link(struct dentry *dentry, struct nameidata *nd)
55441 static void proc_self_put_link(struct dentry *dentry, struct nameidata *nd,
55442 void *cookie)
55443 {
55444 - char *s = nd_get_link(nd);
55445 + const char *s = nd_get_link(nd);
55446 if (!IS_ERR(s))
55447 kfree(s);
55448 }
55449 diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
55450 index 3e636d8..83e3b71 100644
55451 --- a/fs/proc/task_mmu.c
55452 +++ b/fs/proc/task_mmu.c
55453 @@ -11,12 +11,19 @@
55454 #include <linux/rmap.h>
55455 #include <linux/swap.h>
55456 #include <linux/swapops.h>
55457 +#include <linux/grsecurity.h>
55458
55459 #include <asm/elf.h>
55460 #include <asm/uaccess.h>
55461 #include <asm/tlbflush.h>
55462 #include "internal.h"
55463
55464 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55465 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
55466 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
55467 + _mm->pax_flags & MF_PAX_SEGMEXEC))
55468 +#endif
55469 +
55470 void task_mem(struct seq_file *m, struct mm_struct *mm)
55471 {
55472 unsigned long data, text, lib, swap;
55473 @@ -52,8 +59,13 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
55474 "VmExe:\t%8lu kB\n"
55475 "VmLib:\t%8lu kB\n"
55476 "VmPTE:\t%8lu kB\n"
55477 - "VmSwap:\t%8lu kB\n",
55478 - hiwater_vm << (PAGE_SHIFT-10),
55479 + "VmSwap:\t%8lu kB\n"
55480 +
55481 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
55482 + "CsBase:\t%8lx\nCsLim:\t%8lx\n"
55483 +#endif
55484 +
55485 + ,hiwater_vm << (PAGE_SHIFT-10),
55486 total_vm << (PAGE_SHIFT-10),
55487 mm->locked_vm << (PAGE_SHIFT-10),
55488 mm->pinned_vm << (PAGE_SHIFT-10),
55489 @@ -62,7 +74,19 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
55490 data << (PAGE_SHIFT-10),
55491 mm->stack_vm << (PAGE_SHIFT-10), text, lib,
55492 (PTRS_PER_PTE*sizeof(pte_t)*mm->nr_ptes) >> 10,
55493 - swap << (PAGE_SHIFT-10));
55494 + swap << (PAGE_SHIFT-10)
55495 +
55496 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
55497 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55498 + , PAX_RAND_FLAGS(mm) ? 0 : mm->context.user_cs_base
55499 + , PAX_RAND_FLAGS(mm) ? 0 : mm->context.user_cs_limit
55500 +#else
55501 + , mm->context.user_cs_base
55502 + , mm->context.user_cs_limit
55503 +#endif
55504 +#endif
55505 +
55506 + );
55507 }
55508
55509 unsigned long task_vsize(struct mm_struct *mm)
55510 @@ -277,13 +301,13 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
55511 pgoff = ((loff_t)vma->vm_pgoff) << PAGE_SHIFT;
55512 }
55513
55514 - /* We don't show the stack guard page in /proc/maps */
55515 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55516 + start = PAX_RAND_FLAGS(mm) ? 0UL : vma->vm_start;
55517 + end = PAX_RAND_FLAGS(mm) ? 0UL : vma->vm_end;
55518 +#else
55519 start = vma->vm_start;
55520 - if (stack_guard_page_start(vma, start))
55521 - start += PAGE_SIZE;
55522 end = vma->vm_end;
55523 - if (stack_guard_page_end(vma, end))
55524 - end -= PAGE_SIZE;
55525 +#endif
55526
55527 seq_printf(m, "%08lx-%08lx %c%c%c%c %08llx %02x:%02x %lu %n",
55528 start,
55529 @@ -292,7 +316,11 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
55530 flags & VM_WRITE ? 'w' : '-',
55531 flags & VM_EXEC ? 'x' : '-',
55532 flags & VM_MAYSHARE ? 's' : 'p',
55533 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55534 + PAX_RAND_FLAGS(mm) ? 0UL : pgoff,
55535 +#else
55536 pgoff,
55537 +#endif
55538 MAJOR(dev), MINOR(dev), ino, &len);
55539
55540 /*
55541 @@ -301,7 +329,7 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
55542 */
55543 if (file) {
55544 pad_len_spaces(m, len);
55545 - seq_path(m, &file->f_path, "\n");
55546 + seq_path(m, &file->f_path, "\n\\");
55547 goto done;
55548 }
55549
55550 @@ -327,8 +355,9 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
55551 * Thread stack in /proc/PID/task/TID/maps or
55552 * the main process stack.
55553 */
55554 - if (!is_pid || (vma->vm_start <= mm->start_stack &&
55555 - vma->vm_end >= mm->start_stack)) {
55556 + if (!is_pid || (vma->vm_flags & (VM_GROWSDOWN | VM_GROWSUP)) ||
55557 + (vma->vm_start <= mm->start_stack &&
55558 + vma->vm_end >= mm->start_stack)) {
55559 name = "[stack]";
55560 } else {
55561 /* Thread stack in /proc/PID/maps */
55562 @@ -352,6 +381,13 @@ static int show_map(struct seq_file *m, void *v, int is_pid)
55563 struct proc_maps_private *priv = m->private;
55564 struct task_struct *task = priv->task;
55565
55566 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55567 + if (current->exec_id != m->exec_id) {
55568 + gr_log_badprocpid("maps");
55569 + return 0;
55570 + }
55571 +#endif
55572 +
55573 show_map_vma(m, vma, is_pid);
55574
55575 if (m->count < m->size) /* vma is copied successfully */
55576 @@ -589,12 +625,23 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
55577 .private = &mss,
55578 };
55579
55580 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55581 + if (current->exec_id != m->exec_id) {
55582 + gr_log_badprocpid("smaps");
55583 + return 0;
55584 + }
55585 +#endif
55586 memset(&mss, 0, sizeof mss);
55587 - mss.vma = vma;
55588 - /* mmap_sem is held in m_start */
55589 - if (vma->vm_mm && !is_vm_hugetlb_page(vma))
55590 - walk_page_range(vma->vm_start, vma->vm_end, &smaps_walk);
55591 -
55592 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55593 + if (!PAX_RAND_FLAGS(vma->vm_mm)) {
55594 +#endif
55595 + mss.vma = vma;
55596 + /* mmap_sem is held in m_start */
55597 + if (vma->vm_mm && !is_vm_hugetlb_page(vma))
55598 + walk_page_range(vma->vm_start, vma->vm_end, &smaps_walk);
55599 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55600 + }
55601 +#endif
55602 show_map_vma(m, vma, is_pid);
55603
55604 seq_printf(m,
55605 @@ -612,7 +659,11 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
55606 "KernelPageSize: %8lu kB\n"
55607 "MMUPageSize: %8lu kB\n"
55608 "Locked: %8lu kB\n",
55609 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55610 + PAX_RAND_FLAGS(vma->vm_mm) ? 0UL : (vma->vm_end - vma->vm_start) >> 10,
55611 +#else
55612 (vma->vm_end - vma->vm_start) >> 10,
55613 +#endif
55614 mss.resident >> 10,
55615 (unsigned long)(mss.pss >> (10 + PSS_SHIFT)),
55616 mss.shared_clean >> 10,
55617 @@ -1264,6 +1315,13 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
55618 int n;
55619 char buffer[50];
55620
55621 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55622 + if (current->exec_id != m->exec_id) {
55623 + gr_log_badprocpid("numa_maps");
55624 + return 0;
55625 + }
55626 +#endif
55627 +
55628 if (!mm)
55629 return 0;
55630
55631 @@ -1281,11 +1339,15 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
55632 mpol_to_str(buffer, sizeof(buffer), pol);
55633 mpol_cond_put(pol);
55634
55635 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55636 + seq_printf(m, "%08lx %s", PAX_RAND_FLAGS(vma->vm_mm) ? 0UL : vma->vm_start, buffer);
55637 +#else
55638 seq_printf(m, "%08lx %s", vma->vm_start, buffer);
55639 +#endif
55640
55641 if (file) {
55642 seq_printf(m, " file=");
55643 - seq_path(m, &file->f_path, "\n\t= ");
55644 + seq_path(m, &file->f_path, "\n\t\\= ");
55645 } else if (vma->vm_start <= mm->brk && vma->vm_end >= mm->start_brk) {
55646 seq_printf(m, " heap");
55647 } else {
55648 diff --git a/fs/proc/task_nommu.c b/fs/proc/task_nommu.c
55649 index 56123a6..5a2f6ec 100644
55650 --- a/fs/proc/task_nommu.c
55651 +++ b/fs/proc/task_nommu.c
55652 @@ -51,7 +51,7 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
55653 else
55654 bytes += kobjsize(mm);
55655
55656 - if (current->fs && current->fs->users > 1)
55657 + if (current->fs && atomic_read(&current->fs->users) > 1)
55658 sbytes += kobjsize(current->fs);
55659 else
55660 bytes += kobjsize(current->fs);
55661 @@ -168,7 +168,7 @@ static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma,
55662
55663 if (file) {
55664 pad_len_spaces(m, len);
55665 - seq_path(m, &file->f_path, "");
55666 + seq_path(m, &file->f_path, "\n\\");
55667 } else if (mm) {
55668 pid_t tid = vm_is_stack(priv->task, vma, is_pid);
55669
55670 diff --git a/fs/proc/vmcore.c b/fs/proc/vmcore.c
55671 index b870f74..e9048df 100644
55672 --- a/fs/proc/vmcore.c
55673 +++ b/fs/proc/vmcore.c
55674 @@ -98,9 +98,13 @@ static ssize_t read_from_oldmem(char *buf, size_t count,
55675 nr_bytes = count;
55676
55677 /* If pfn is not ram, return zeros for sparse dump files */
55678 - if (pfn_is_ram(pfn) == 0)
55679 - memset(buf, 0, nr_bytes);
55680 - else {
55681 + if (pfn_is_ram(pfn) == 0) {
55682 + if (userbuf) {
55683 + if (clear_user((char __force_user *)buf, nr_bytes))
55684 + return -EFAULT;
55685 + } else
55686 + memset(buf, 0, nr_bytes);
55687 + } else {
55688 tmp = copy_oldmem_page(pfn, buf, nr_bytes,
55689 offset, userbuf);
55690 if (tmp < 0)
55691 @@ -185,7 +189,7 @@ static ssize_t read_vmcore(struct file *file, char __user *buffer,
55692 if (tsz > nr_bytes)
55693 tsz = nr_bytes;
55694
55695 - tmp = read_from_oldmem(buffer, tsz, &start, 1);
55696 + tmp = read_from_oldmem((char __force_kernel *)buffer, tsz, &start, 1);
55697 if (tmp < 0)
55698 return tmp;
55699 buflen -= tsz;
55700 diff --git a/fs/qnx6/qnx6.h b/fs/qnx6/qnx6.h
55701 index b00fcc9..e0c6381 100644
55702 --- a/fs/qnx6/qnx6.h
55703 +++ b/fs/qnx6/qnx6.h
55704 @@ -74,7 +74,7 @@ enum {
55705 BYTESEX_BE,
55706 };
55707
55708 -static inline __u64 fs64_to_cpu(struct qnx6_sb_info *sbi, __fs64 n)
55709 +static inline __u64 __intentional_overflow(-1) fs64_to_cpu(struct qnx6_sb_info *sbi, __fs64 n)
55710 {
55711 if (sbi->s_bytesex == BYTESEX_LE)
55712 return le64_to_cpu((__force __le64)n);
55713 @@ -90,7 +90,7 @@ static inline __fs64 cpu_to_fs64(struct qnx6_sb_info *sbi, __u64 n)
55714 return (__force __fs64)cpu_to_be64(n);
55715 }
55716
55717 -static inline __u32 fs32_to_cpu(struct qnx6_sb_info *sbi, __fs32 n)
55718 +static inline __u32 __intentional_overflow(-1) fs32_to_cpu(struct qnx6_sb_info *sbi, __fs32 n)
55719 {
55720 if (sbi->s_bytesex == BYTESEX_LE)
55721 return le32_to_cpu((__force __le32)n);
55722 diff --git a/fs/quota/netlink.c b/fs/quota/netlink.c
55723 index 16e8abb..2dcf914 100644
55724 --- a/fs/quota/netlink.c
55725 +++ b/fs/quota/netlink.c
55726 @@ -33,7 +33,7 @@ static struct genl_family quota_genl_family = {
55727 void quota_send_warning(struct kqid qid, dev_t dev,
55728 const char warntype)
55729 {
55730 - static atomic_t seq;
55731 + static atomic_unchecked_t seq;
55732 struct sk_buff *skb;
55733 void *msg_head;
55734 int ret;
55735 @@ -49,7 +49,7 @@ void quota_send_warning(struct kqid qid, dev_t dev,
55736 "VFS: Not enough memory to send quota warning.\n");
55737 return;
55738 }
55739 - msg_head = genlmsg_put(skb, 0, atomic_add_return(1, &seq),
55740 + msg_head = genlmsg_put(skb, 0, atomic_add_return_unchecked(1, &seq),
55741 &quota_genl_family, 0, QUOTA_NL_C_WARNING);
55742 if (!msg_head) {
55743 printk(KERN_ERR
55744 diff --git a/fs/read_write.c b/fs/read_write.c
55745 index e6ddc8d..9155227 100644
55746 --- a/fs/read_write.c
55747 +++ b/fs/read_write.c
55748 @@ -429,7 +429,7 @@ ssize_t __kernel_write(struct file *file, const char *buf, size_t count, loff_t
55749
55750 old_fs = get_fs();
55751 set_fs(get_ds());
55752 - p = (__force const char __user *)buf;
55753 + p = (const char __force_user *)buf;
55754 if (count > MAX_RW_COUNT)
55755 count = MAX_RW_COUNT;
55756 if (file->f_op->write)
55757 diff --git a/fs/readdir.c b/fs/readdir.c
55758 index fee38e0..12fdf47 100644
55759 --- a/fs/readdir.c
55760 +++ b/fs/readdir.c
55761 @@ -17,6 +17,7 @@
55762 #include <linux/security.h>
55763 #include <linux/syscalls.h>
55764 #include <linux/unistd.h>
55765 +#include <linux/namei.h>
55766
55767 #include <asm/uaccess.h>
55768
55769 @@ -67,6 +68,7 @@ struct old_linux_dirent {
55770
55771 struct readdir_callback {
55772 struct old_linux_dirent __user * dirent;
55773 + struct file * file;
55774 int result;
55775 };
55776
55777 @@ -84,6 +86,10 @@ static int fillonedir(void * __buf, const char * name, int namlen, loff_t offset
55778 buf->result = -EOVERFLOW;
55779 return -EOVERFLOW;
55780 }
55781 +
55782 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
55783 + return 0;
55784 +
55785 buf->result++;
55786 dirent = buf->dirent;
55787 if (!access_ok(VERIFY_WRITE, dirent,
55788 @@ -114,6 +120,7 @@ SYSCALL_DEFINE3(old_readdir, unsigned int, fd,
55789
55790 buf.result = 0;
55791 buf.dirent = dirent;
55792 + buf.file = f.file;
55793
55794 error = vfs_readdir(f.file, fillonedir, &buf);
55795 if (buf.result)
55796 @@ -139,6 +146,7 @@ struct linux_dirent {
55797 struct getdents_callback {
55798 struct linux_dirent __user * current_dir;
55799 struct linux_dirent __user * previous;
55800 + struct file * file;
55801 int count;
55802 int error;
55803 };
55804 @@ -160,6 +168,10 @@ static int filldir(void * __buf, const char * name, int namlen, loff_t offset,
55805 buf->error = -EOVERFLOW;
55806 return -EOVERFLOW;
55807 }
55808 +
55809 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
55810 + return 0;
55811 +
55812 dirent = buf->previous;
55813 if (dirent) {
55814 if (__put_user(offset, &dirent->d_off))
55815 @@ -205,6 +217,7 @@ SYSCALL_DEFINE3(getdents, unsigned int, fd,
55816 buf.previous = NULL;
55817 buf.count = count;
55818 buf.error = 0;
55819 + buf.file = f.file;
55820
55821 error = vfs_readdir(f.file, filldir, &buf);
55822 if (error >= 0)
55823 @@ -223,6 +236,7 @@ SYSCALL_DEFINE3(getdents, unsigned int, fd,
55824 struct getdents_callback64 {
55825 struct linux_dirent64 __user * current_dir;
55826 struct linux_dirent64 __user * previous;
55827 + struct file *file;
55828 int count;
55829 int error;
55830 };
55831 @@ -238,6 +252,10 @@ static int filldir64(void * __buf, const char * name, int namlen, loff_t offset,
55832 buf->error = -EINVAL; /* only used if we fail.. */
55833 if (reclen > buf->count)
55834 return -EINVAL;
55835 +
55836 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
55837 + return 0;
55838 +
55839 dirent = buf->previous;
55840 if (dirent) {
55841 if (__put_user(offset, &dirent->d_off))
55842 @@ -283,6 +301,7 @@ SYSCALL_DEFINE3(getdents64, unsigned int, fd,
55843
55844 buf.current_dir = dirent;
55845 buf.previous = NULL;
55846 + buf.file = f.file;
55847 buf.count = count;
55848 buf.error = 0;
55849
55850 @@ -291,7 +310,7 @@ SYSCALL_DEFINE3(getdents64, unsigned int, fd,
55851 error = buf.error;
55852 lastdirent = buf.previous;
55853 if (lastdirent) {
55854 - typeof(lastdirent->d_off) d_off = f.file->f_pos;
55855 + typeof(((struct linux_dirent64 *)0)->d_off) d_off = f.file->f_pos;
55856 if (__put_user(d_off, &lastdirent->d_off))
55857 error = -EFAULT;
55858 else
55859 diff --git a/fs/reiserfs/do_balan.c b/fs/reiserfs/do_balan.c
55860 index 2b7882b..1c5ef48 100644
55861 --- a/fs/reiserfs/do_balan.c
55862 +++ b/fs/reiserfs/do_balan.c
55863 @@ -2051,7 +2051,7 @@ void do_balance(struct tree_balance *tb, /* tree_balance structure */
55864 return;
55865 }
55866
55867 - atomic_inc(&(fs_generation(tb->tb_sb)));
55868 + atomic_inc_unchecked(&(fs_generation(tb->tb_sb)));
55869 do_balance_starts(tb);
55870
55871 /* balance leaf returns 0 except if combining L R and S into
55872 diff --git a/fs/reiserfs/procfs.c b/fs/reiserfs/procfs.c
55873 index 9cc0740a..46bf953 100644
55874 --- a/fs/reiserfs/procfs.c
55875 +++ b/fs/reiserfs/procfs.c
55876 @@ -112,7 +112,7 @@ static int show_super(struct seq_file *m, struct super_block *sb)
55877 "SMALL_TAILS " : "NO_TAILS ",
55878 replay_only(sb) ? "REPLAY_ONLY " : "",
55879 convert_reiserfs(sb) ? "CONV " : "",
55880 - atomic_read(&r->s_generation_counter),
55881 + atomic_read_unchecked(&r->s_generation_counter),
55882 SF(s_disk_reads), SF(s_disk_writes), SF(s_fix_nodes),
55883 SF(s_do_balance), SF(s_unneeded_left_neighbor),
55884 SF(s_good_search_by_key_reada), SF(s_bmaps),
55885 diff --git a/fs/reiserfs/reiserfs.h b/fs/reiserfs/reiserfs.h
55886 index 157e474..65a6114 100644
55887 --- a/fs/reiserfs/reiserfs.h
55888 +++ b/fs/reiserfs/reiserfs.h
55889 @@ -453,7 +453,7 @@ struct reiserfs_sb_info {
55890 /* Comment? -Hans */
55891 wait_queue_head_t s_wait;
55892 /* To be obsoleted soon by per buffer seals.. -Hans */
55893 - atomic_t s_generation_counter; // increased by one every time the
55894 + atomic_unchecked_t s_generation_counter; // increased by one every time the
55895 // tree gets re-balanced
55896 unsigned long s_properties; /* File system properties. Currently holds
55897 on-disk FS format */
55898 @@ -1978,7 +1978,7 @@ static inline loff_t max_reiserfs_offset(struct inode *inode)
55899 #define REISERFS_USER_MEM 1 /* reiserfs user memory mode */
55900
55901 #define fs_generation(s) (REISERFS_SB(s)->s_generation_counter)
55902 -#define get_generation(s) atomic_read (&fs_generation(s))
55903 +#define get_generation(s) atomic_read_unchecked (&fs_generation(s))
55904 #define FILESYSTEM_CHANGED_TB(tb) (get_generation((tb)->tb_sb) != (tb)->fs_gen)
55905 #define __fs_changed(gen,s) (gen != get_generation (s))
55906 #define fs_changed(gen,s) \
55907 diff --git a/fs/select.c b/fs/select.c
55908 index 8c1c96c..a0f9b6d 100644
55909 --- a/fs/select.c
55910 +++ b/fs/select.c
55911 @@ -20,6 +20,7 @@
55912 #include <linux/export.h>
55913 #include <linux/slab.h>
55914 #include <linux/poll.h>
55915 +#include <linux/security.h>
55916 #include <linux/personality.h> /* for STICKY_TIMEOUTS */
55917 #include <linux/file.h>
55918 #include <linux/fdtable.h>
55919 @@ -827,6 +828,7 @@ int do_sys_poll(struct pollfd __user *ufds, unsigned int nfds,
55920 struct poll_list *walk = head;
55921 unsigned long todo = nfds;
55922
55923 + gr_learn_resource(current, RLIMIT_NOFILE, nfds, 1);
55924 if (nfds > rlimit(RLIMIT_NOFILE))
55925 return -EINVAL;
55926
55927 diff --git a/fs/seq_file.c b/fs/seq_file.c
55928 index 38bb59f..a304f9d 100644
55929 --- a/fs/seq_file.c
55930 +++ b/fs/seq_file.c
55931 @@ -10,6 +10,7 @@
55932 #include <linux/seq_file.h>
55933 #include <linux/slab.h>
55934 #include <linux/cred.h>
55935 +#include <linux/sched.h>
55936
55937 #include <asm/uaccess.h>
55938 #include <asm/page.h>
55939 @@ -60,6 +61,9 @@ int seq_open(struct file *file, const struct seq_operations *op)
55940 #ifdef CONFIG_USER_NS
55941 p->user_ns = file->f_cred->user_ns;
55942 #endif
55943 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55944 + p->exec_id = current->exec_id;
55945 +#endif
55946
55947 /*
55948 * Wrappers around seq_open(e.g. swaps_open) need to be
55949 @@ -96,7 +100,7 @@ static int traverse(struct seq_file *m, loff_t offset)
55950 return 0;
55951 }
55952 if (!m->buf) {
55953 - m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL);
55954 + m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL | GFP_USERCOPY);
55955 if (!m->buf)
55956 return -ENOMEM;
55957 }
55958 @@ -136,7 +140,7 @@ static int traverse(struct seq_file *m, loff_t offset)
55959 Eoverflow:
55960 m->op->stop(m, p);
55961 kfree(m->buf);
55962 - m->buf = kmalloc(m->size <<= 1, GFP_KERNEL);
55963 + m->buf = kmalloc(m->size <<= 1, GFP_KERNEL | GFP_USERCOPY);
55964 return !m->buf ? -ENOMEM : -EAGAIN;
55965 }
55966
55967 @@ -191,7 +195,7 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
55968
55969 /* grab buffer if we didn't have one */
55970 if (!m->buf) {
55971 - m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL);
55972 + m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL | GFP_USERCOPY);
55973 if (!m->buf)
55974 goto Enomem;
55975 }
55976 @@ -232,7 +236,7 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
55977 goto Fill;
55978 m->op->stop(m, p);
55979 kfree(m->buf);
55980 - m->buf = kmalloc(m->size <<= 1, GFP_KERNEL);
55981 + m->buf = kmalloc(m->size <<= 1, GFP_KERNEL | GFP_USERCOPY);
55982 if (!m->buf)
55983 goto Enomem;
55984 m->count = 0;
55985 @@ -581,7 +585,7 @@ static void single_stop(struct seq_file *p, void *v)
55986 int single_open(struct file *file, int (*show)(struct seq_file *, void *),
55987 void *data)
55988 {
55989 - struct seq_operations *op = kmalloc(sizeof(*op), GFP_KERNEL);
55990 + seq_operations_no_const *op = kzalloc(sizeof(*op), GFP_KERNEL);
55991 int res = -ENOMEM;
55992
55993 if (op) {
55994 diff --git a/fs/splice.c b/fs/splice.c
55995 index 29e394e..b13c247 100644
55996 --- a/fs/splice.c
55997 +++ b/fs/splice.c
55998 @@ -195,7 +195,7 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
55999 pipe_lock(pipe);
56000
56001 for (;;) {
56002 - if (!pipe->readers) {
56003 + if (!atomic_read(&pipe->readers)) {
56004 send_sig(SIGPIPE, current, 0);
56005 if (!ret)
56006 ret = -EPIPE;
56007 @@ -249,9 +249,9 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
56008 do_wakeup = 0;
56009 }
56010
56011 - pipe->waiting_writers++;
56012 + atomic_inc(&pipe->waiting_writers);
56013 pipe_wait(pipe);
56014 - pipe->waiting_writers--;
56015 + atomic_dec(&pipe->waiting_writers);
56016 }
56017
56018 pipe_unlock(pipe);
56019 @@ -564,7 +564,7 @@ static ssize_t kernel_readv(struct file *file, const struct iovec *vec,
56020 old_fs = get_fs();
56021 set_fs(get_ds());
56022 /* The cast to a user pointer is valid due to the set_fs() */
56023 - res = vfs_readv(file, (const struct iovec __user *)vec, vlen, &pos);
56024 + res = vfs_readv(file, (const struct iovec __force_user *)vec, vlen, &pos);
56025 set_fs(old_fs);
56026
56027 return res;
56028 @@ -579,7 +579,7 @@ ssize_t kernel_write(struct file *file, const char *buf, size_t count,
56029 old_fs = get_fs();
56030 set_fs(get_ds());
56031 /* The cast to a user pointer is valid due to the set_fs() */
56032 - res = vfs_write(file, (__force const char __user *)buf, count, &pos);
56033 + res = vfs_write(file, (const char __force_user *)buf, count, &pos);
56034 set_fs(old_fs);
56035
56036 return res;
56037 @@ -632,7 +632,7 @@ ssize_t default_file_splice_read(struct file *in, loff_t *ppos,
56038 goto err;
56039
56040 this_len = min_t(size_t, len, PAGE_CACHE_SIZE - offset);
56041 - vec[i].iov_base = (void __user *) page_address(page);
56042 + vec[i].iov_base = (void __force_user *) page_address(page);
56043 vec[i].iov_len = this_len;
56044 spd.pages[i] = page;
56045 spd.nr_pages++;
56046 @@ -853,10 +853,10 @@ EXPORT_SYMBOL(splice_from_pipe_feed);
56047 int splice_from_pipe_next(struct pipe_inode_info *pipe, struct splice_desc *sd)
56048 {
56049 while (!pipe->nrbufs) {
56050 - if (!pipe->writers)
56051 + if (!atomic_read(&pipe->writers))
56052 return 0;
56053
56054 - if (!pipe->waiting_writers && sd->num_spliced)
56055 + if (!atomic_read(&pipe->waiting_writers) && sd->num_spliced)
56056 return 0;
56057
56058 if (sd->flags & SPLICE_F_NONBLOCK)
56059 @@ -1192,7 +1192,7 @@ ssize_t splice_direct_to_actor(struct file *in, struct splice_desc *sd,
56060 * out of the pipe right after the splice_to_pipe(). So set
56061 * PIPE_READERS appropriately.
56062 */
56063 - pipe->readers = 1;
56064 + atomic_set(&pipe->readers, 1);
56065
56066 current->splice_pipe = pipe;
56067 }
56068 @@ -1741,9 +1741,9 @@ static int ipipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
56069 ret = -ERESTARTSYS;
56070 break;
56071 }
56072 - if (!pipe->writers)
56073 + if (!atomic_read(&pipe->writers))
56074 break;
56075 - if (!pipe->waiting_writers) {
56076 + if (!atomic_read(&pipe->waiting_writers)) {
56077 if (flags & SPLICE_F_NONBLOCK) {
56078 ret = -EAGAIN;
56079 break;
56080 @@ -1775,7 +1775,7 @@ static int opipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
56081 pipe_lock(pipe);
56082
56083 while (pipe->nrbufs >= pipe->buffers) {
56084 - if (!pipe->readers) {
56085 + if (!atomic_read(&pipe->readers)) {
56086 send_sig(SIGPIPE, current, 0);
56087 ret = -EPIPE;
56088 break;
56089 @@ -1788,9 +1788,9 @@ static int opipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
56090 ret = -ERESTARTSYS;
56091 break;
56092 }
56093 - pipe->waiting_writers++;
56094 + atomic_inc(&pipe->waiting_writers);
56095 pipe_wait(pipe);
56096 - pipe->waiting_writers--;
56097 + atomic_dec(&pipe->waiting_writers);
56098 }
56099
56100 pipe_unlock(pipe);
56101 @@ -1826,14 +1826,14 @@ retry:
56102 pipe_double_lock(ipipe, opipe);
56103
56104 do {
56105 - if (!opipe->readers) {
56106 + if (!atomic_read(&opipe->readers)) {
56107 send_sig(SIGPIPE, current, 0);
56108 if (!ret)
56109 ret = -EPIPE;
56110 break;
56111 }
56112
56113 - if (!ipipe->nrbufs && !ipipe->writers)
56114 + if (!ipipe->nrbufs && !atomic_read(&ipipe->writers))
56115 break;
56116
56117 /*
56118 @@ -1930,7 +1930,7 @@ static int link_pipe(struct pipe_inode_info *ipipe,
56119 pipe_double_lock(ipipe, opipe);
56120
56121 do {
56122 - if (!opipe->readers) {
56123 + if (!atomic_read(&opipe->readers)) {
56124 send_sig(SIGPIPE, current, 0);
56125 if (!ret)
56126 ret = -EPIPE;
56127 @@ -1975,7 +1975,7 @@ static int link_pipe(struct pipe_inode_info *ipipe,
56128 * return EAGAIN if we have the potential of some data in the
56129 * future, otherwise just return 0
56130 */
56131 - if (!ret && ipipe->waiting_writers && (flags & SPLICE_F_NONBLOCK))
56132 + if (!ret && atomic_read(&ipipe->waiting_writers) && (flags & SPLICE_F_NONBLOCK))
56133 ret = -EAGAIN;
56134
56135 pipe_unlock(ipipe);
56136 diff --git a/fs/stat.c b/fs/stat.c
56137 index 04ce1ac..a13dd1e 100644
56138 --- a/fs/stat.c
56139 +++ b/fs/stat.c
56140 @@ -28,8 +28,13 @@ void generic_fillattr(struct inode *inode, struct kstat *stat)
56141 stat->gid = inode->i_gid;
56142 stat->rdev = inode->i_rdev;
56143 stat->size = i_size_read(inode);
56144 - stat->atime = inode->i_atime;
56145 - stat->mtime = inode->i_mtime;
56146 + if (is_sidechannel_device(inode) && !capable_nolog(CAP_MKNOD)) {
56147 + stat->atime = inode->i_ctime;
56148 + stat->mtime = inode->i_ctime;
56149 + } else {
56150 + stat->atime = inode->i_atime;
56151 + stat->mtime = inode->i_mtime;
56152 + }
56153 stat->ctime = inode->i_ctime;
56154 stat->blksize = (1 << inode->i_blkbits);
56155 stat->blocks = inode->i_blocks;
56156 @@ -46,8 +51,14 @@ int vfs_getattr(struct path *path, struct kstat *stat)
56157 if (retval)
56158 return retval;
56159
56160 - if (inode->i_op->getattr)
56161 - return inode->i_op->getattr(path->mnt, path->dentry, stat);
56162 + if (inode->i_op->getattr) {
56163 + retval = inode->i_op->getattr(path->mnt, path->dentry, stat);
56164 + if (!retval && is_sidechannel_device(inode) && !capable_nolog(CAP_MKNOD)) {
56165 + stat->atime = stat->ctime;
56166 + stat->mtime = stat->ctime;
56167 + }
56168 + return retval;
56169 + }
56170
56171 generic_fillattr(inode, stat);
56172 return 0;
56173 diff --git a/fs/sysfs/bin.c b/fs/sysfs/bin.c
56174 index 15c68f9..36a8b3e 100644
56175 --- a/fs/sysfs/bin.c
56176 +++ b/fs/sysfs/bin.c
56177 @@ -235,13 +235,13 @@ static int bin_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
56178 return ret;
56179 }
56180
56181 -static int bin_access(struct vm_area_struct *vma, unsigned long addr,
56182 - void *buf, int len, int write)
56183 +static ssize_t bin_access(struct vm_area_struct *vma, unsigned long addr,
56184 + void *buf, size_t len, int write)
56185 {
56186 struct file *file = vma->vm_file;
56187 struct bin_buffer *bb = file->private_data;
56188 struct sysfs_dirent *attr_sd = file->f_path.dentry->d_fsdata;
56189 - int ret;
56190 + ssize_t ret;
56191
56192 if (!bb->vm_ops)
56193 return -EINVAL;
56194 diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
56195 index 6f31590..3c87c8a 100644
56196 --- a/fs/sysfs/dir.c
56197 +++ b/fs/sysfs/dir.c
56198 @@ -40,7 +40,7 @@ static DEFINE_IDA(sysfs_ino_ida);
56199 *
56200 * Returns 31 bit hash of ns + name (so it fits in an off_t )
56201 */
56202 -static unsigned int sysfs_name_hash(const void *ns, const char *name)
56203 +static unsigned int sysfs_name_hash(const void *ns, const unsigned char *name)
56204 {
56205 unsigned long hash = init_name_hash();
56206 unsigned int len = strlen(name);
56207 @@ -685,6 +685,18 @@ static int create_dir(struct kobject *kobj, struct sysfs_dirent *parent_sd,
56208 struct sysfs_dirent *sd;
56209 int rc;
56210
56211 +#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
56212 + const char *parent_name = parent_sd->s_name;
56213 +
56214 + mode = S_IFDIR | S_IRWXU;
56215 +
56216 + if ((!strcmp(parent_name, "") && (!strcmp(name, "devices") || !strcmp(name, "fs"))) ||
56217 + (!strcmp(parent_name, "devices") && !strcmp(name, "system")) ||
56218 + (!strcmp(parent_name, "fs") && (!strcmp(name, "selinux") || !strcmp(name, "fuse"))) ||
56219 + (!strcmp(parent_name, "system") && !strcmp(name, "cpu")))
56220 + mode = S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO;
56221 +#endif
56222 +
56223 /* allocate */
56224 sd = sysfs_new_dirent(name, mode, SYSFS_DIR);
56225 if (!sd)
56226 diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
56227 index 602f56d..6853db8 100644
56228 --- a/fs/sysfs/file.c
56229 +++ b/fs/sysfs/file.c
56230 @@ -37,7 +37,7 @@ static DEFINE_SPINLOCK(sysfs_open_dirent_lock);
56231
56232 struct sysfs_open_dirent {
56233 atomic_t refcnt;
56234 - atomic_t event;
56235 + atomic_unchecked_t event;
56236 wait_queue_head_t poll;
56237 struct list_head buffers; /* goes through sysfs_buffer.list */
56238 };
56239 @@ -81,7 +81,7 @@ static int fill_read_buffer(struct dentry * dentry, struct sysfs_buffer * buffer
56240 if (!sysfs_get_active(attr_sd))
56241 return -ENODEV;
56242
56243 - buffer->event = atomic_read(&attr_sd->s_attr.open->event);
56244 + buffer->event = atomic_read_unchecked(&attr_sd->s_attr.open->event);
56245 count = ops->show(kobj, attr_sd->s_attr.attr, buffer->page);
56246
56247 sysfs_put_active(attr_sd);
56248 @@ -287,7 +287,7 @@ static int sysfs_get_open_dirent(struct sysfs_dirent *sd,
56249 return -ENOMEM;
56250
56251 atomic_set(&new_od->refcnt, 0);
56252 - atomic_set(&new_od->event, 1);
56253 + atomic_set_unchecked(&new_od->event, 1);
56254 init_waitqueue_head(&new_od->poll);
56255 INIT_LIST_HEAD(&new_od->buffers);
56256 goto retry;
56257 @@ -432,7 +432,7 @@ static unsigned int sysfs_poll(struct file *filp, poll_table *wait)
56258
56259 sysfs_put_active(attr_sd);
56260
56261 - if (buffer->event != atomic_read(&od->event))
56262 + if (buffer->event != atomic_read_unchecked(&od->event))
56263 goto trigger;
56264
56265 return DEFAULT_POLLMASK;
56266 @@ -451,7 +451,7 @@ void sysfs_notify_dirent(struct sysfs_dirent *sd)
56267
56268 od = sd->s_attr.open;
56269 if (od) {
56270 - atomic_inc(&od->event);
56271 + atomic_inc_unchecked(&od->event);
56272 wake_up_interruptible(&od->poll);
56273 }
56274
56275 diff --git a/fs/sysfs/symlink.c b/fs/sysfs/symlink.c
56276 index 8c940df..25b733e 100644
56277 --- a/fs/sysfs/symlink.c
56278 +++ b/fs/sysfs/symlink.c
56279 @@ -305,7 +305,7 @@ static void *sysfs_follow_link(struct dentry *dentry, struct nameidata *nd)
56280
56281 static void sysfs_put_link(struct dentry *dentry, struct nameidata *nd, void *cookie)
56282 {
56283 - char *page = nd_get_link(nd);
56284 + const char *page = nd_get_link(nd);
56285 if (!IS_ERR(page))
56286 free_page((unsigned long)page);
56287 }
56288 diff --git a/fs/sysv/sysv.h b/fs/sysv/sysv.h
56289 index 69d4889..a810bd4 100644
56290 --- a/fs/sysv/sysv.h
56291 +++ b/fs/sysv/sysv.h
56292 @@ -188,7 +188,7 @@ static inline u32 PDP_swab(u32 x)
56293 #endif
56294 }
56295
56296 -static inline __u32 fs32_to_cpu(struct sysv_sb_info *sbi, __fs32 n)
56297 +static inline __u32 __intentional_overflow(-1) fs32_to_cpu(struct sysv_sb_info *sbi, __fs32 n)
56298 {
56299 if (sbi->s_bytesex == BYTESEX_PDP)
56300 return PDP_swab((__force __u32)n);
56301 diff --git a/fs/ubifs/io.c b/fs/ubifs/io.c
56302 index e18b988..f1d4ad0f 100644
56303 --- a/fs/ubifs/io.c
56304 +++ b/fs/ubifs/io.c
56305 @@ -155,7 +155,7 @@ int ubifs_leb_change(struct ubifs_info *c, int lnum, const void *buf, int len)
56306 return err;
56307 }
56308
56309 -int ubifs_leb_unmap(struct ubifs_info *c, int lnum)
56310 +int __intentional_overflow(-1) ubifs_leb_unmap(struct ubifs_info *c, int lnum)
56311 {
56312 int err;
56313
56314 diff --git a/fs/udf/misc.c b/fs/udf/misc.c
56315 index c175b4d..8f36a16 100644
56316 --- a/fs/udf/misc.c
56317 +++ b/fs/udf/misc.c
56318 @@ -289,7 +289,7 @@ void udf_new_tag(char *data, uint16_t ident, uint16_t version, uint16_t snum,
56319
56320 u8 udf_tag_checksum(const struct tag *t)
56321 {
56322 - u8 *data = (u8 *)t;
56323 + const u8 *data = (const u8 *)t;
56324 u8 checksum = 0;
56325 int i;
56326 for (i = 0; i < sizeof(struct tag); ++i)
56327 diff --git a/fs/ufs/swab.h b/fs/ufs/swab.h
56328 index 8d974c4..b82f6ec 100644
56329 --- a/fs/ufs/swab.h
56330 +++ b/fs/ufs/swab.h
56331 @@ -22,7 +22,7 @@ enum {
56332 BYTESEX_BE
56333 };
56334
56335 -static inline u64
56336 +static inline u64 __intentional_overflow(-1)
56337 fs64_to_cpu(struct super_block *sbp, __fs64 n)
56338 {
56339 if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
56340 @@ -40,7 +40,7 @@ cpu_to_fs64(struct super_block *sbp, u64 n)
56341 return (__force __fs64)cpu_to_be64(n);
56342 }
56343
56344 -static inline u32
56345 +static inline u32 __intentional_overflow(-1)
56346 fs32_to_cpu(struct super_block *sbp, __fs32 n)
56347 {
56348 if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
56349 diff --git a/fs/utimes.c b/fs/utimes.c
56350 index f4fb7ec..3fe03c0 100644
56351 --- a/fs/utimes.c
56352 +++ b/fs/utimes.c
56353 @@ -1,6 +1,7 @@
56354 #include <linux/compiler.h>
56355 #include <linux/file.h>
56356 #include <linux/fs.h>
56357 +#include <linux/security.h>
56358 #include <linux/linkage.h>
56359 #include <linux/mount.h>
56360 #include <linux/namei.h>
56361 @@ -101,6 +102,12 @@ static int utimes_common(struct path *path, struct timespec *times)
56362 goto mnt_drop_write_and_out;
56363 }
56364 }
56365 +
56366 + if (!gr_acl_handle_utime(path->dentry, path->mnt)) {
56367 + error = -EACCES;
56368 + goto mnt_drop_write_and_out;
56369 + }
56370 +
56371 mutex_lock(&inode->i_mutex);
56372 error = notify_change(path->dentry, &newattrs);
56373 mutex_unlock(&inode->i_mutex);
56374 diff --git a/fs/xattr.c b/fs/xattr.c
56375 index 3377dff..4d074d9 100644
56376 --- a/fs/xattr.c
56377 +++ b/fs/xattr.c
56378 @@ -227,6 +227,27 @@ int vfs_xattr_cmp(struct dentry *dentry, const char *xattr_name,
56379 return rc;
56380 }
56381
56382 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
56383 +ssize_t
56384 +pax_getxattr(struct dentry *dentry, void *value, size_t size)
56385 +{
56386 + struct inode *inode = dentry->d_inode;
56387 + ssize_t error;
56388 +
56389 + error = inode_permission(inode, MAY_EXEC);
56390 + if (error)
56391 + return error;
56392 +
56393 + if (inode->i_op->getxattr)
56394 + error = inode->i_op->getxattr(dentry, XATTR_NAME_PAX_FLAGS, value, size);
56395 + else
56396 + error = -EOPNOTSUPP;
56397 +
56398 + return error;
56399 +}
56400 +EXPORT_SYMBOL(pax_getxattr);
56401 +#endif
56402 +
56403 ssize_t
56404 vfs_getxattr(struct dentry *dentry, const char *name, void *value, size_t size)
56405 {
56406 @@ -319,7 +340,7 @@ EXPORT_SYMBOL_GPL(vfs_removexattr);
56407 * Extended attribute SET operations
56408 */
56409 static long
56410 -setxattr(struct dentry *d, const char __user *name, const void __user *value,
56411 +setxattr(struct path *path, const char __user *name, const void __user *value,
56412 size_t size, int flags)
56413 {
56414 int error;
56415 @@ -355,7 +376,12 @@ setxattr(struct dentry *d, const char __user *name, const void __user *value,
56416 posix_acl_fix_xattr_from_user(kvalue, size);
56417 }
56418
56419 - error = vfs_setxattr(d, kname, kvalue, size, flags);
56420 + if (!gr_acl_handle_setxattr(path->dentry, path->mnt)) {
56421 + error = -EACCES;
56422 + goto out;
56423 + }
56424 +
56425 + error = vfs_setxattr(path->dentry, kname, kvalue, size, flags);
56426 out:
56427 if (vvalue)
56428 vfree(vvalue);
56429 @@ -377,7 +403,7 @@ retry:
56430 return error;
56431 error = mnt_want_write(path.mnt);
56432 if (!error) {
56433 - error = setxattr(path.dentry, name, value, size, flags);
56434 + error = setxattr(&path, name, value, size, flags);
56435 mnt_drop_write(path.mnt);
56436 }
56437 path_put(&path);
56438 @@ -401,7 +427,7 @@ retry:
56439 return error;
56440 error = mnt_want_write(path.mnt);
56441 if (!error) {
56442 - error = setxattr(path.dentry, name, value, size, flags);
56443 + error = setxattr(&path, name, value, size, flags);
56444 mnt_drop_write(path.mnt);
56445 }
56446 path_put(&path);
56447 @@ -416,16 +442,14 @@ SYSCALL_DEFINE5(fsetxattr, int, fd, const char __user *, name,
56448 const void __user *,value, size_t, size, int, flags)
56449 {
56450 struct fd f = fdget(fd);
56451 - struct dentry *dentry;
56452 int error = -EBADF;
56453
56454 if (!f.file)
56455 return error;
56456 - dentry = f.file->f_path.dentry;
56457 - audit_inode(NULL, dentry, 0);
56458 + audit_inode(NULL, f.file->f_path.dentry, 0);
56459 error = mnt_want_write_file(f.file);
56460 if (!error) {
56461 - error = setxattr(dentry, name, value, size, flags);
56462 + error = setxattr(&f.file->f_path, name, value, size, flags);
56463 mnt_drop_write_file(f.file);
56464 }
56465 fdput(f);
56466 diff --git a/fs/xattr_acl.c b/fs/xattr_acl.c
56467 index 9fbea87..6b19972 100644
56468 --- a/fs/xattr_acl.c
56469 +++ b/fs/xattr_acl.c
56470 @@ -76,8 +76,8 @@ struct posix_acl *
56471 posix_acl_from_xattr(struct user_namespace *user_ns,
56472 const void *value, size_t size)
56473 {
56474 - posix_acl_xattr_header *header = (posix_acl_xattr_header *)value;
56475 - posix_acl_xattr_entry *entry = (posix_acl_xattr_entry *)(header+1), *end;
56476 + const posix_acl_xattr_header *header = (const posix_acl_xattr_header *)value;
56477 + const posix_acl_xattr_entry *entry = (const posix_acl_xattr_entry *)(header+1), *end;
56478 int count;
56479 struct posix_acl *acl;
56480 struct posix_acl_entry *acl_e;
56481 diff --git a/fs/xfs/xfs_bmap.c b/fs/xfs/xfs_bmap.c
56482 index b44af92..06073da 100644
56483 --- a/fs/xfs/xfs_bmap.c
56484 +++ b/fs/xfs/xfs_bmap.c
56485 @@ -192,7 +192,7 @@ xfs_bmap_validate_ret(
56486 int nmap,
56487 int ret_nmap);
56488 #else
56489 -#define xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap)
56490 +#define xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap) do {} while (0)
56491 #endif /* DEBUG */
56492
56493 STATIC int
56494 diff --git a/fs/xfs/xfs_dir2_sf.c b/fs/xfs/xfs_dir2_sf.c
56495 index 1b9fc3e..e1bdde0 100644
56496 --- a/fs/xfs/xfs_dir2_sf.c
56497 +++ b/fs/xfs/xfs_dir2_sf.c
56498 @@ -851,7 +851,15 @@ xfs_dir2_sf_getdents(
56499 }
56500
56501 ino = xfs_dir2_sfe_get_ino(sfp, sfep);
56502 - if (filldir(dirent, (char *)sfep->name, sfep->namelen,
56503 + if (dp->i_df.if_u1.if_data == dp->i_df.if_u2.if_inline_data) {
56504 + char name[sfep->namelen];
56505 + memcpy(name, sfep->name, sfep->namelen);
56506 + if (filldir(dirent, name, sfep->namelen,
56507 + off & 0x7fffffff, ino, DT_UNKNOWN)) {
56508 + *offset = off & 0x7fffffff;
56509 + return 0;
56510 + }
56511 + } else if (filldir(dirent, (char *)sfep->name, sfep->namelen,
56512 off & 0x7fffffff, ino, DT_UNKNOWN)) {
56513 *offset = off & 0x7fffffff;
56514 return 0;
56515 diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
56516 index d681e34..2a3f5ab 100644
56517 --- a/fs/xfs/xfs_ioctl.c
56518 +++ b/fs/xfs/xfs_ioctl.c
56519 @@ -127,7 +127,7 @@ xfs_find_handle(
56520 }
56521
56522 error = -EFAULT;
56523 - if (copy_to_user(hreq->ohandle, &handle, hsize) ||
56524 + if (hsize > sizeof handle || copy_to_user(hreq->ohandle, &handle, hsize) ||
56525 copy_to_user(hreq->ohandlen, &hsize, sizeof(__s32)))
56526 goto out_put;
56527
56528 diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
56529 index d82efaa..0904a8e 100644
56530 --- a/fs/xfs/xfs_iops.c
56531 +++ b/fs/xfs/xfs_iops.c
56532 @@ -395,7 +395,7 @@ xfs_vn_put_link(
56533 struct nameidata *nd,
56534 void *p)
56535 {
56536 - char *s = nd_get_link(nd);
56537 + const char *s = nd_get_link(nd);
56538
56539 if (!IS_ERR(s))
56540 kfree(s);
56541 diff --git a/grsecurity/Kconfig b/grsecurity/Kconfig
56542 new file mode 100644
56543 index 0000000..7174794
56544 --- /dev/null
56545 +++ b/grsecurity/Kconfig
56546 @@ -0,0 +1,1031 @@
56547 +#
56548 +# grecurity configuration
56549 +#
56550 +menu "Memory Protections"
56551 +depends on GRKERNSEC
56552 +
56553 +config GRKERNSEC_KMEM
56554 + bool "Deny reading/writing to /dev/kmem, /dev/mem, and /dev/port"
56555 + default y if GRKERNSEC_CONFIG_AUTO
56556 + select STRICT_DEVMEM if (X86 || ARM || TILE || S390)
56557 + help
56558 + If you say Y here, /dev/kmem and /dev/mem won't be allowed to
56559 + be written to or read from to modify or leak the contents of the running
56560 + kernel. /dev/port will also not be allowed to be opened and support
56561 + for /dev/cpu/*/msr will be removed. If you have module
56562 + support disabled, enabling this will close up five ways that are
56563 + currently used to insert malicious code into the running kernel.
56564 +
56565 + Even with all these features enabled, we still highly recommend that
56566 + you use the RBAC system, as it is still possible for an attacker to
56567 + modify the running kernel through privileged I/O granted by ioperm/iopl.
56568 +
56569 + If you are not using XFree86, you may be able to stop this additional
56570 + case by enabling the 'Disable privileged I/O' option. Though nothing
56571 + legitimately writes to /dev/kmem, XFree86 does need to write to /dev/mem,
56572 + but only to video memory, which is the only writing we allow in this
56573 + case. If /dev/kmem or /dev/mem are mmaped without PROT_WRITE, they will
56574 + not be allowed to mprotect it with PROT_WRITE later.
56575 + Enabling this feature will prevent the "cpupower" and "powertop" tools
56576 + from working.
56577 +
56578 + It is highly recommended that you say Y here if you meet all the
56579 + conditions above.
56580 +
56581 +config GRKERNSEC_VM86
56582 + bool "Restrict VM86 mode"
56583 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
56584 + depends on X86_32
56585 +
56586 + help
56587 + If you say Y here, only processes with CAP_SYS_RAWIO will be able to
56588 + make use of a special execution mode on 32bit x86 processors called
56589 + Virtual 8086 (VM86) mode. XFree86 may need vm86 mode for certain
56590 + video cards and will still work with this option enabled. The purpose
56591 + of the option is to prevent exploitation of emulation errors in
56592 + virtualization of vm86 mode like the one discovered in VMWare in 2009.
56593 + Nearly all users should be able to enable this option.
56594 +
56595 +config GRKERNSEC_IO
56596 + bool "Disable privileged I/O"
56597 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
56598 + depends on X86
56599 + select RTC_CLASS
56600 + select RTC_INTF_DEV
56601 + select RTC_DRV_CMOS
56602 +
56603 + help
56604 + If you say Y here, all ioperm and iopl calls will return an error.
56605 + Ioperm and iopl can be used to modify the running kernel.
56606 + Unfortunately, some programs need this access to operate properly,
56607 + the most notable of which are XFree86 and hwclock. hwclock can be
56608 + remedied by having RTC support in the kernel, so real-time
56609 + clock support is enabled if this option is enabled, to ensure
56610 + that hwclock operates correctly. XFree86 still will not
56611 + operate correctly with this option enabled, so DO NOT CHOOSE Y
56612 + IF YOU USE XFree86. If you use XFree86 and you still want to
56613 + protect your kernel against modification, use the RBAC system.
56614 +
56615 +config GRKERNSEC_JIT_HARDEN
56616 + bool "Harden BPF JIT against spray attacks"
56617 + default y if GRKERNSEC_CONFIG_AUTO
56618 + depends on BPF_JIT
56619 + help
56620 + If you say Y here, the native code generated by the kernel's Berkeley
56621 + Packet Filter (BPF) JIT engine will be hardened against JIT-spraying
56622 + attacks that attempt to fit attacker-beneficial instructions in
56623 + 32bit immediate fields of JIT-generated native instructions. The
56624 + attacker will generally aim to cause an unintended instruction sequence
56625 + of JIT-generated native code to execute by jumping into the middle of
56626 + a generated instruction. This feature effectively randomizes the 32bit
56627 + immediate constants present in the generated code to thwart such attacks.
56628 +
56629 + If you're using KERNEXEC, it's recommended that you enable this option
56630 + to supplement the hardening of the kernel.
56631 +
56632 +config GRKERNSEC_RAND_THREADSTACK
56633 + bool "Insert random gaps between thread stacks"
56634 + default y if GRKERNSEC_CONFIG_AUTO
56635 + depends on PAX_RANDMMAP && !PPC && BROKEN
56636 + help
56637 + If you say Y here, a random-sized gap will be enforced between allocated
56638 + thread stacks. Glibc's NPTL and other threading libraries that
56639 + pass MAP_STACK to the kernel for thread stack allocation are supported.
56640 + The implementation currently provides 8 bits of entropy for the gap.
56641 +
56642 + Many distributions do not compile threaded remote services with the
56643 + -fstack-check argument to GCC, causing the variable-sized stack-based
56644 + allocator, alloca(), to not probe the stack on allocation. This
56645 + permits an unbounded alloca() to skip over any guard page and potentially
56646 + modify another thread's stack reliably. An enforced random gap
56647 + reduces the reliability of such an attack and increases the chance
56648 + that such a read/write to another thread's stack instead lands in
56649 + an unmapped area, causing a crash and triggering grsecurity's
56650 + anti-bruteforcing logic.
56651 +
56652 +config GRKERNSEC_PROC_MEMMAP
56653 + bool "Harden ASLR against information leaks and entropy reduction"
56654 + default y if (GRKERNSEC_CONFIG_AUTO || PAX_NOEXEC || PAX_ASLR)
56655 + depends on PAX_NOEXEC || PAX_ASLR
56656 + help
56657 + If you say Y here, the /proc/<pid>/maps and /proc/<pid>/stat files will
56658 + give no information about the addresses of its mappings if
56659 + PaX features that rely on random addresses are enabled on the task.
56660 + In addition to sanitizing this information and disabling other
56661 + dangerous sources of information, this option causes reads of sensitive
56662 + /proc/<pid> entries where the file descriptor was opened in a different
56663 + task than the one performing the read. Such attempts are logged.
56664 + This option also limits argv/env strings for suid/sgid binaries
56665 + to 512KB to prevent a complete exhaustion of the stack entropy provided
56666 + by ASLR. Finally, it places an 8MB stack resource limit on suid/sgid
56667 + binaries to prevent alternative mmap layouts from being abused.
56668 +
56669 + If you use PaX it is essential that you say Y here as it closes up
56670 + several holes that make full ASLR useless locally.
56671 +
56672 +config GRKERNSEC_BRUTE
56673 + bool "Deter exploit bruteforcing"
56674 + default y if GRKERNSEC_CONFIG_AUTO
56675 + help
56676 + If you say Y here, attempts to bruteforce exploits against forking
56677 + daemons such as apache or sshd, as well as against suid/sgid binaries
56678 + will be deterred. When a child of a forking daemon is killed by PaX
56679 + or crashes due to an illegal instruction or other suspicious signal,
56680 + the parent process will be delayed 30 seconds upon every subsequent
56681 + fork until the administrator is able to assess the situation and
56682 + restart the daemon.
56683 + In the suid/sgid case, the attempt is logged, the user has all their
56684 + processes terminated, and they are prevented from executing any further
56685 + processes for 15 minutes.
56686 + It is recommended that you also enable signal logging in the auditing
56687 + section so that logs are generated when a process triggers a suspicious
56688 + signal.
56689 + If the sysctl option is enabled, a sysctl option with name
56690 + "deter_bruteforce" is created.
56691 +
56692 +
56693 +config GRKERNSEC_MODHARDEN
56694 + bool "Harden module auto-loading"
56695 + default y if GRKERNSEC_CONFIG_AUTO
56696 + depends on MODULES
56697 + help
56698 + If you say Y here, module auto-loading in response to use of some
56699 + feature implemented by an unloaded module will be restricted to
56700 + root users. Enabling this option helps defend against attacks
56701 + by unprivileged users who abuse the auto-loading behavior to
56702 + cause a vulnerable module to load that is then exploited.
56703 +
56704 + If this option prevents a legitimate use of auto-loading for a
56705 + non-root user, the administrator can execute modprobe manually
56706 + with the exact name of the module mentioned in the alert log.
56707 + Alternatively, the administrator can add the module to the list
56708 + of modules loaded at boot by modifying init scripts.
56709 +
56710 + Modification of init scripts will most likely be needed on
56711 + Ubuntu servers with encrypted home directory support enabled,
56712 + as the first non-root user logging in will cause the ecb(aes),
56713 + ecb(aes)-all, cbc(aes), and cbc(aes)-all modules to be loaded.
56714 +
56715 +config GRKERNSEC_HIDESYM
56716 + bool "Hide kernel symbols"
56717 + default y if GRKERNSEC_CONFIG_AUTO
56718 + select PAX_USERCOPY_SLABS
56719 + help
56720 + If you say Y here, getting information on loaded modules, and
56721 + displaying all kernel symbols through a syscall will be restricted
56722 + to users with CAP_SYS_MODULE. For software compatibility reasons,
56723 + /proc/kallsyms will be restricted to the root user. The RBAC
56724 + system can hide that entry even from root.
56725 +
56726 + This option also prevents leaking of kernel addresses through
56727 + several /proc entries.
56728 +
56729 + Note that this option is only effective provided the following
56730 + conditions are met:
56731 + 1) The kernel using grsecurity is not precompiled by some distribution
56732 + 2) You have also enabled GRKERNSEC_DMESG
56733 + 3) You are using the RBAC system and hiding other files such as your
56734 + kernel image and System.map. Alternatively, enabling this option
56735 + causes the permissions on /boot, /lib/modules, and the kernel
56736 + source directory to change at compile time to prevent
56737 + reading by non-root users.
56738 + If the above conditions are met, this option will aid in providing a
56739 + useful protection against local kernel exploitation of overflows
56740 + and arbitrary read/write vulnerabilities.
56741 +
56742 +config GRKERNSEC_KERN_LOCKOUT
56743 + bool "Active kernel exploit response"
56744 + default y if GRKERNSEC_CONFIG_AUTO
56745 + depends on X86 || ARM || PPC || SPARC
56746 + help
56747 + If you say Y here, when a PaX alert is triggered due to suspicious
56748 + activity in the kernel (from KERNEXEC/UDEREF/USERCOPY)
56749 + or an OOPS occurs due to bad memory accesses, instead of just
56750 + terminating the offending process (and potentially allowing
56751 + a subsequent exploit from the same user), we will take one of two
56752 + actions:
56753 + If the user was root, we will panic the system
56754 + If the user was non-root, we will log the attempt, terminate
56755 + all processes owned by the user, then prevent them from creating
56756 + any new processes until the system is restarted
56757 + This deters repeated kernel exploitation/bruteforcing attempts
56758 + and is useful for later forensics.
56759 +
56760 +endmenu
56761 +menu "Role Based Access Control Options"
56762 +depends on GRKERNSEC
56763 +
56764 +config GRKERNSEC_RBAC_DEBUG
56765 + bool
56766 +
56767 +config GRKERNSEC_NO_RBAC
56768 + bool "Disable RBAC system"
56769 + help
56770 + If you say Y here, the /dev/grsec device will be removed from the kernel,
56771 + preventing the RBAC system from being enabled. You should only say Y
56772 + here if you have no intention of using the RBAC system, so as to prevent
56773 + an attacker with root access from misusing the RBAC system to hide files
56774 + and processes when loadable module support and /dev/[k]mem have been
56775 + locked down.
56776 +
56777 +config GRKERNSEC_ACL_HIDEKERN
56778 + bool "Hide kernel processes"
56779 + help
56780 + If you say Y here, all kernel threads will be hidden to all
56781 + processes but those whose subject has the "view hidden processes"
56782 + flag.
56783 +
56784 +config GRKERNSEC_ACL_MAXTRIES
56785 + int "Maximum tries before password lockout"
56786 + default 3
56787 + help
56788 + This option enforces the maximum number of times a user can attempt
56789 + to authorize themselves with the grsecurity RBAC system before being
56790 + denied the ability to attempt authorization again for a specified time.
56791 + The lower the number, the harder it will be to brute-force a password.
56792 +
56793 +config GRKERNSEC_ACL_TIMEOUT
56794 + int "Time to wait after max password tries, in seconds"
56795 + default 30
56796 + help
56797 + This option specifies the time the user must wait after attempting to
56798 + authorize to the RBAC system with the maximum number of invalid
56799 + passwords. The higher the number, the harder it will be to brute-force
56800 + a password.
56801 +
56802 +endmenu
56803 +menu "Filesystem Protections"
56804 +depends on GRKERNSEC
56805 +
56806 +config GRKERNSEC_PROC
56807 + bool "Proc restrictions"
56808 + default y if GRKERNSEC_CONFIG_AUTO
56809 + help
56810 + If you say Y here, the permissions of the /proc filesystem
56811 + will be altered to enhance system security and privacy. You MUST
56812 + choose either a user only restriction or a user and group restriction.
56813 + Depending upon the option you choose, you can either restrict users to
56814 + see only the processes they themselves run, or choose a group that can
56815 + view all processes and files normally restricted to root if you choose
56816 + the "restrict to user only" option. NOTE: If you're running identd or
56817 + ntpd as a non-root user, you will have to run it as the group you
56818 + specify here.
56819 +
56820 +config GRKERNSEC_PROC_USER
56821 + bool "Restrict /proc to user only"
56822 + depends on GRKERNSEC_PROC
56823 + help
56824 + If you say Y here, non-root users will only be able to view their own
56825 + processes, and restricts them from viewing network-related information,
56826 + and viewing kernel symbol and module information.
56827 +
56828 +config GRKERNSEC_PROC_USERGROUP
56829 + bool "Allow special group"
56830 + default y if GRKERNSEC_CONFIG_AUTO
56831 + depends on GRKERNSEC_PROC && !GRKERNSEC_PROC_USER
56832 + help
56833 + If you say Y here, you will be able to select a group that will be
56834 + able to view all processes and network-related information. If you've
56835 + enabled GRKERNSEC_HIDESYM, kernel and symbol information may still
56836 + remain hidden. This option is useful if you want to run identd as
56837 + a non-root user. The group you select may also be chosen at boot time
56838 + via "grsec_proc_gid=" on the kernel commandline.
56839 +
56840 +config GRKERNSEC_PROC_GID
56841 + int "GID for special group"
56842 + depends on GRKERNSEC_PROC_USERGROUP
56843 + default 1001
56844 +
56845 +config GRKERNSEC_PROC_ADD
56846 + bool "Additional restrictions"
56847 + default y if GRKERNSEC_CONFIG_AUTO
56848 + depends on GRKERNSEC_PROC_USER || GRKERNSEC_PROC_USERGROUP
56849 + help
56850 + If you say Y here, additional restrictions will be placed on
56851 + /proc that keep normal users from viewing device information and
56852 + slabinfo information that could be useful for exploits.
56853 +
56854 +config GRKERNSEC_LINK
56855 + bool "Linking restrictions"
56856 + default y if GRKERNSEC_CONFIG_AUTO
56857 + help
56858 + If you say Y here, /tmp race exploits will be prevented, since users
56859 + will no longer be able to follow symlinks owned by other users in
56860 + world-writable +t directories (e.g. /tmp), unless the owner of the
56861 + symlink is the owner of the directory. users will also not be
56862 + able to hardlink to files they do not own. If the sysctl option is
56863 + enabled, a sysctl option with name "linking_restrictions" is created.
56864 +
56865 +config GRKERNSEC_SYMLINKOWN
56866 + bool "Kernel-enforced SymlinksIfOwnerMatch"
56867 + default y if GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER
56868 + help
56869 + Apache's SymlinksIfOwnerMatch option has an inherent race condition
56870 + that prevents it from being used as a security feature. As Apache
56871 + verifies the symlink by performing a stat() against the target of
56872 + the symlink before it is followed, an attacker can setup a symlink
56873 + to point to a same-owned file, then replace the symlink with one
56874 + that targets another user's file just after Apache "validates" the
56875 + symlink -- a classic TOCTOU race. If you say Y here, a complete,
56876 + race-free replacement for Apache's "SymlinksIfOwnerMatch" option
56877 + will be in place for the group you specify. If the sysctl option
56878 + is enabled, a sysctl option with name "enforce_symlinksifowner" is
56879 + created.
56880 +
56881 +config GRKERNSEC_SYMLINKOWN_GID
56882 + int "GID for users with kernel-enforced SymlinksIfOwnerMatch"
56883 + depends on GRKERNSEC_SYMLINKOWN
56884 + default 1006
56885 + help
56886 + Setting this GID determines what group kernel-enforced
56887 + SymlinksIfOwnerMatch will be enabled for. If the sysctl option
56888 + is enabled, a sysctl option with name "symlinkown_gid" is created.
56889 +
56890 +config GRKERNSEC_FIFO
56891 + bool "FIFO restrictions"
56892 + default y if GRKERNSEC_CONFIG_AUTO
56893 + help
56894 + If you say Y here, users will not be able to write to FIFOs they don't
56895 + own in world-writable +t directories (e.g. /tmp), unless the owner of
56896 + the FIFO is the same owner of the directory it's held in. If the sysctl
56897 + option is enabled, a sysctl option with name "fifo_restrictions" is
56898 + created.
56899 +
56900 +config GRKERNSEC_SYSFS_RESTRICT
56901 + bool "Sysfs/debugfs restriction"
56902 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
56903 + depends on SYSFS
56904 + help
56905 + If you say Y here, sysfs (the pseudo-filesystem mounted at /sys) and
56906 + any filesystem normally mounted under it (e.g. debugfs) will be
56907 + mostly accessible only by root. These filesystems generally provide access
56908 + to hardware and debug information that isn't appropriate for unprivileged
56909 + users of the system. Sysfs and debugfs have also become a large source
56910 + of new vulnerabilities, ranging from infoleaks to local compromise.
56911 + There has been very little oversight with an eye toward security involved
56912 + in adding new exporters of information to these filesystems, so their
56913 + use is discouraged.
56914 + For reasons of compatibility, a few directories have been whitelisted
56915 + for access by non-root users:
56916 + /sys/fs/selinux
56917 + /sys/fs/fuse
56918 + /sys/devices/system/cpu
56919 +
56920 +config GRKERNSEC_ROFS
56921 + bool "Runtime read-only mount protection"
56922 + help
56923 + If you say Y here, a sysctl option with name "romount_protect" will
56924 + be created. By setting this option to 1 at runtime, filesystems
56925 + will be protected in the following ways:
56926 + * No new writable mounts will be allowed
56927 + * Existing read-only mounts won't be able to be remounted read/write
56928 + * Write operations will be denied on all block devices
56929 + This option acts independently of grsec_lock: once it is set to 1,
56930 + it cannot be turned off. Therefore, please be mindful of the resulting
56931 + behavior if this option is enabled in an init script on a read-only
56932 + filesystem. This feature is mainly intended for secure embedded systems.
56933 +
56934 +config GRKERNSEC_DEVICE_SIDECHANNEL
56935 + bool "Eliminate stat/notify-based device sidechannels"
56936 + default y if GRKERNSEC_CONFIG_AUTO
56937 + help
56938 + If you say Y here, timing analyses on block or character
56939 + devices like /dev/ptmx using stat or inotify/dnotify/fanotify
56940 + will be thwarted for unprivileged users. If a process without
56941 + CAP_MKNOD stats such a device, the last access and last modify times
56942 + will match the device's create time. No access or modify events
56943 + will be triggered through inotify/dnotify/fanotify for such devices.
56944 + This feature will prevent attacks that may at a minimum
56945 + allow an attacker to determine the administrator's password length.
56946 +
56947 +config GRKERNSEC_CHROOT
56948 + bool "Chroot jail restrictions"
56949 + default y if GRKERNSEC_CONFIG_AUTO
56950 + help
56951 + If you say Y here, you will be able to choose several options that will
56952 + make breaking out of a chrooted jail much more difficult. If you
56953 + encounter no software incompatibilities with the following options, it
56954 + is recommended that you enable each one.
56955 +
56956 +config GRKERNSEC_CHROOT_MOUNT
56957 + bool "Deny mounts"
56958 + default y if GRKERNSEC_CONFIG_AUTO
56959 + depends on GRKERNSEC_CHROOT
56960 + help
56961 + If you say Y here, processes inside a chroot will not be able to
56962 + mount or remount filesystems. If the sysctl option is enabled, a
56963 + sysctl option with name "chroot_deny_mount" is created.
56964 +
56965 +config GRKERNSEC_CHROOT_DOUBLE
56966 + bool "Deny double-chroots"
56967 + default y if GRKERNSEC_CONFIG_AUTO
56968 + depends on GRKERNSEC_CHROOT
56969 + help
56970 + If you say Y here, processes inside a chroot will not be able to chroot
56971 + again outside the chroot. This is a widely used method of breaking
56972 + out of a chroot jail and should not be allowed. If the sysctl
56973 + option is enabled, a sysctl option with name
56974 + "chroot_deny_chroot" is created.
56975 +
56976 +config GRKERNSEC_CHROOT_PIVOT
56977 + bool "Deny pivot_root in chroot"
56978 + default y if GRKERNSEC_CONFIG_AUTO
56979 + depends on GRKERNSEC_CHROOT
56980 + help
56981 + If you say Y here, processes inside a chroot will not be able to use
56982 + a function called pivot_root() that was introduced in Linux 2.3.41. It
56983 + works similar to chroot in that it changes the root filesystem. This
56984 + function could be misused in a chrooted process to attempt to break out
56985 + of the chroot, and therefore should not be allowed. If the sysctl
56986 + option is enabled, a sysctl option with name "chroot_deny_pivot" is
56987 + created.
56988 +
56989 +config GRKERNSEC_CHROOT_CHDIR
56990 + bool "Enforce chdir(\"/\") on all chroots"
56991 + default y if GRKERNSEC_CONFIG_AUTO
56992 + depends on GRKERNSEC_CHROOT
56993 + help
56994 + If you say Y here, the current working directory of all newly-chrooted
56995 + applications will be set to the the root directory of the chroot.
56996 + The man page on chroot(2) states:
56997 + Note that this call does not change the current working
56998 + directory, so that `.' can be outside the tree rooted at
56999 + `/'. In particular, the super-user can escape from a
57000 + `chroot jail' by doing `mkdir foo; chroot foo; cd ..'.
57001 +
57002 + It is recommended that you say Y here, since it's not known to break
57003 + any software. If the sysctl option is enabled, a sysctl option with
57004 + name "chroot_enforce_chdir" is created.
57005 +
57006 +config GRKERNSEC_CHROOT_CHMOD
57007 + bool "Deny (f)chmod +s"
57008 + default y if GRKERNSEC_CONFIG_AUTO
57009 + depends on GRKERNSEC_CHROOT
57010 + help
57011 + If you say Y here, processes inside a chroot will not be able to chmod
57012 + or fchmod files to make them have suid or sgid bits. This protects
57013 + against another published method of breaking a chroot. If the sysctl
57014 + option is enabled, a sysctl option with name "chroot_deny_chmod" is
57015 + created.
57016 +
57017 +config GRKERNSEC_CHROOT_FCHDIR
57018 + bool "Deny fchdir out of chroot"
57019 + default y if GRKERNSEC_CONFIG_AUTO
57020 + depends on GRKERNSEC_CHROOT
57021 + help
57022 + If you say Y here, a well-known method of breaking chroots by fchdir'ing
57023 + to a file descriptor of the chrooting process that points to a directory
57024 + outside the filesystem will be stopped. If the sysctl option
57025 + is enabled, a sysctl option with name "chroot_deny_fchdir" is created.
57026 +
57027 +config GRKERNSEC_CHROOT_MKNOD
57028 + bool "Deny mknod"
57029 + default y if GRKERNSEC_CONFIG_AUTO
57030 + depends on GRKERNSEC_CHROOT
57031 + help
57032 + If you say Y here, processes inside a chroot will not be allowed to
57033 + mknod. The problem with using mknod inside a chroot is that it
57034 + would allow an attacker to create a device entry that is the same
57035 + as one on the physical root of your system, which could range from
57036 + anything from the console device to a device for your harddrive (which
57037 + they could then use to wipe the drive or steal data). It is recommended
57038 + that you say Y here, unless you run into software incompatibilities.
57039 + If the sysctl option is enabled, a sysctl option with name
57040 + "chroot_deny_mknod" is created.
57041 +
57042 +config GRKERNSEC_CHROOT_SHMAT
57043 + bool "Deny shmat() out of chroot"
57044 + default y if GRKERNSEC_CONFIG_AUTO
57045 + depends on GRKERNSEC_CHROOT
57046 + help
57047 + If you say Y here, processes inside a chroot will not be able to attach
57048 + to shared memory segments that were created outside of the chroot jail.
57049 + It is recommended that you say Y here. If the sysctl option is enabled,
57050 + a sysctl option with name "chroot_deny_shmat" is created.
57051 +
57052 +config GRKERNSEC_CHROOT_UNIX
57053 + bool "Deny access to abstract AF_UNIX sockets out of chroot"
57054 + default y if GRKERNSEC_CONFIG_AUTO
57055 + depends on GRKERNSEC_CHROOT
57056 + help
57057 + If you say Y here, processes inside a chroot will not be able to
57058 + connect to abstract (meaning not belonging to a filesystem) Unix
57059 + domain sockets that were bound outside of a chroot. It is recommended
57060 + that you say Y here. If the sysctl option is enabled, a sysctl option
57061 + with name "chroot_deny_unix" is created.
57062 +
57063 +config GRKERNSEC_CHROOT_FINDTASK
57064 + bool "Protect outside processes"
57065 + default y if GRKERNSEC_CONFIG_AUTO
57066 + depends on GRKERNSEC_CHROOT
57067 + help
57068 + If you say Y here, processes inside a chroot will not be able to
57069 + kill, send signals with fcntl, ptrace, capget, getpgid, setpgid,
57070 + getsid, or view any process outside of the chroot. If the sysctl
57071 + option is enabled, a sysctl option with name "chroot_findtask" is
57072 + created.
57073 +
57074 +config GRKERNSEC_CHROOT_NICE
57075 + bool "Restrict priority changes"
57076 + default y if GRKERNSEC_CONFIG_AUTO
57077 + depends on GRKERNSEC_CHROOT
57078 + help
57079 + If you say Y here, processes inside a chroot will not be able to raise
57080 + the priority of processes in the chroot, or alter the priority of
57081 + processes outside the chroot. This provides more security than simply
57082 + removing CAP_SYS_NICE from the process' capability set. If the
57083 + sysctl option is enabled, a sysctl option with name "chroot_restrict_nice"
57084 + is created.
57085 +
57086 +config GRKERNSEC_CHROOT_SYSCTL
57087 + bool "Deny sysctl writes"
57088 + default y if GRKERNSEC_CONFIG_AUTO
57089 + depends on GRKERNSEC_CHROOT
57090 + help
57091 + If you say Y here, an attacker in a chroot will not be able to
57092 + write to sysctl entries, either by sysctl(2) or through a /proc
57093 + interface. It is strongly recommended that you say Y here. If the
57094 + sysctl option is enabled, a sysctl option with name
57095 + "chroot_deny_sysctl" is created.
57096 +
57097 +config GRKERNSEC_CHROOT_CAPS
57098 + bool "Capability restrictions"
57099 + default y if GRKERNSEC_CONFIG_AUTO
57100 + depends on GRKERNSEC_CHROOT
57101 + help
57102 + If you say Y here, the capabilities on all processes within a
57103 + chroot jail will be lowered to stop module insertion, raw i/o,
57104 + system and net admin tasks, rebooting the system, modifying immutable
57105 + files, modifying IPC owned by another, and changing the system time.
57106 + This is left an option because it can break some apps. Disable this
57107 + if your chrooted apps are having problems performing those kinds of
57108 + tasks. If the sysctl option is enabled, a sysctl option with
57109 + name "chroot_caps" is created.
57110 +
57111 +config GRKERNSEC_CHROOT_INITRD
57112 + bool "Exempt initrd tasks from restrictions"
57113 + default y if GRKERNSEC_CONFIG_AUTO
57114 + depends on GRKERNSEC_CHROOT && BLK_DEV_RAM
57115 + help
57116 + If you say Y here, tasks started prior to init will be exempted from
57117 + grsecurity's chroot restrictions. This option is mainly meant to
57118 + resolve Plymouth's performing privileged operations unnecessarily
57119 + in a chroot.
57120 +
57121 +endmenu
57122 +menu "Kernel Auditing"
57123 +depends on GRKERNSEC
57124 +
57125 +config GRKERNSEC_AUDIT_GROUP
57126 + bool "Single group for auditing"
57127 + help
57128 + If you say Y here, the exec and chdir logging features will only operate
57129 + on a group you specify. This option is recommended if you only want to
57130 + watch certain users instead of having a large amount of logs from the
57131 + entire system. If the sysctl option is enabled, a sysctl option with
57132 + name "audit_group" is created.
57133 +
57134 +config GRKERNSEC_AUDIT_GID
57135 + int "GID for auditing"
57136 + depends on GRKERNSEC_AUDIT_GROUP
57137 + default 1007
57138 +
57139 +config GRKERNSEC_EXECLOG
57140 + bool "Exec logging"
57141 + help
57142 + If you say Y here, all execve() calls will be logged (since the
57143 + other exec*() calls are frontends to execve(), all execution
57144 + will be logged). Useful for shell-servers that like to keep track
57145 + of their users. If the sysctl option is enabled, a sysctl option with
57146 + name "exec_logging" is created.
57147 + WARNING: This option when enabled will produce a LOT of logs, especially
57148 + on an active system.
57149 +
57150 +config GRKERNSEC_RESLOG
57151 + bool "Resource logging"
57152 + default y if GRKERNSEC_CONFIG_AUTO
57153 + help
57154 + If you say Y here, all attempts to overstep resource limits will
57155 + be logged with the resource name, the requested size, and the current
57156 + limit. It is highly recommended that you say Y here. If the sysctl
57157 + option is enabled, a sysctl option with name "resource_logging" is
57158 + created. If the RBAC system is enabled, the sysctl value is ignored.
57159 +
57160 +config GRKERNSEC_CHROOT_EXECLOG
57161 + bool "Log execs within chroot"
57162 + help
57163 + If you say Y here, all executions inside a chroot jail will be logged
57164 + to syslog. This can cause a large amount of logs if certain
57165 + applications (eg. djb's daemontools) are installed on the system, and
57166 + is therefore left as an option. If the sysctl option is enabled, a
57167 + sysctl option with name "chroot_execlog" is created.
57168 +
57169 +config GRKERNSEC_AUDIT_PTRACE
57170 + bool "Ptrace logging"
57171 + help
57172 + If you say Y here, all attempts to attach to a process via ptrace
57173 + will be logged. If the sysctl option is enabled, a sysctl option
57174 + with name "audit_ptrace" is created.
57175 +
57176 +config GRKERNSEC_AUDIT_CHDIR
57177 + bool "Chdir logging"
57178 + help
57179 + If you say Y here, all chdir() calls will be logged. If the sysctl
57180 + option is enabled, a sysctl option with name "audit_chdir" is created.
57181 +
57182 +config GRKERNSEC_AUDIT_MOUNT
57183 + bool "(Un)Mount logging"
57184 + help
57185 + If you say Y here, all mounts and unmounts will be logged. If the
57186 + sysctl option is enabled, a sysctl option with name "audit_mount" is
57187 + created.
57188 +
57189 +config GRKERNSEC_SIGNAL
57190 + bool "Signal logging"
57191 + default y if GRKERNSEC_CONFIG_AUTO
57192 + help
57193 + If you say Y here, certain important signals will be logged, such as
57194 + SIGSEGV, which will as a result inform you of when a error in a program
57195 + occurred, which in some cases could mean a possible exploit attempt.
57196 + If the sysctl option is enabled, a sysctl option with name
57197 + "signal_logging" is created.
57198 +
57199 +config GRKERNSEC_FORKFAIL
57200 + bool "Fork failure logging"
57201 + help
57202 + If you say Y here, all failed fork() attempts will be logged.
57203 + This could suggest a fork bomb, or someone attempting to overstep
57204 + their process limit. If the sysctl option is enabled, a sysctl option
57205 + with name "forkfail_logging" is created.
57206 +
57207 +config GRKERNSEC_TIME
57208 + bool "Time change logging"
57209 + default y if GRKERNSEC_CONFIG_AUTO
57210 + help
57211 + If you say Y here, any changes of the system clock will be logged.
57212 + If the sysctl option is enabled, a sysctl option with name
57213 + "timechange_logging" is created.
57214 +
57215 +config GRKERNSEC_PROC_IPADDR
57216 + bool "/proc/<pid>/ipaddr support"
57217 + default y if GRKERNSEC_CONFIG_AUTO
57218 + help
57219 + If you say Y here, a new entry will be added to each /proc/<pid>
57220 + directory that contains the IP address of the person using the task.
57221 + The IP is carried across local TCP and AF_UNIX stream sockets.
57222 + This information can be useful for IDS/IPSes to perform remote response
57223 + to a local attack. The entry is readable by only the owner of the
57224 + process (and root if he has CAP_DAC_OVERRIDE, which can be removed via
57225 + the RBAC system), and thus does not create privacy concerns.
57226 +
57227 +config GRKERNSEC_RWXMAP_LOG
57228 + bool 'Denied RWX mmap/mprotect logging'
57229 + default y if GRKERNSEC_CONFIG_AUTO
57230 + depends on PAX_MPROTECT && !PAX_EMUPLT && !PAX_EMUSIGRT
57231 + help
57232 + If you say Y here, calls to mmap() and mprotect() with explicit
57233 + usage of PROT_WRITE and PROT_EXEC together will be logged when
57234 + denied by the PAX_MPROTECT feature. If the sysctl option is
57235 + enabled, a sysctl option with name "rwxmap_logging" is created.
57236 +
57237 +config GRKERNSEC_AUDIT_TEXTREL
57238 + bool 'ELF text relocations logging (READ HELP)'
57239 + depends on PAX_MPROTECT
57240 + help
57241 + If you say Y here, text relocations will be logged with the filename
57242 + of the offending library or binary. The purpose of the feature is
57243 + to help Linux distribution developers get rid of libraries and
57244 + binaries that need text relocations which hinder the future progress
57245 + of PaX. Only Linux distribution developers should say Y here, and
57246 + never on a production machine, as this option creates an information
57247 + leak that could aid an attacker in defeating the randomization of
57248 + a single memory region. If the sysctl option is enabled, a sysctl
57249 + option with name "audit_textrel" is created.
57250 +
57251 +endmenu
57252 +
57253 +menu "Executable Protections"
57254 +depends on GRKERNSEC
57255 +
57256 +config GRKERNSEC_DMESG
57257 + bool "Dmesg(8) restriction"
57258 + default y if GRKERNSEC_CONFIG_AUTO
57259 + help
57260 + If you say Y here, non-root users will not be able to use dmesg(8)
57261 + to view the contents of the kernel's circular log buffer.
57262 + The kernel's log buffer often contains kernel addresses and other
57263 + identifying information useful to an attacker in fingerprinting a
57264 + system for a targeted exploit.
57265 + If the sysctl option is enabled, a sysctl option with name "dmesg" is
57266 + created.
57267 +
57268 +config GRKERNSEC_HARDEN_PTRACE
57269 + bool "Deter ptrace-based process snooping"
57270 + default y if GRKERNSEC_CONFIG_AUTO
57271 + help
57272 + If you say Y here, TTY sniffers and other malicious monitoring
57273 + programs implemented through ptrace will be defeated. If you
57274 + have been using the RBAC system, this option has already been
57275 + enabled for several years for all users, with the ability to make
57276 + fine-grained exceptions.
57277 +
57278 + This option only affects the ability of non-root users to ptrace
57279 + processes that are not a descendent of the ptracing process.
57280 + This means that strace ./binary and gdb ./binary will still work,
57281 + but attaching to arbitrary processes will not. If the sysctl
57282 + option is enabled, a sysctl option with name "harden_ptrace" is
57283 + created.
57284 +
57285 +config GRKERNSEC_PTRACE_READEXEC
57286 + bool "Require read access to ptrace sensitive binaries"
57287 + default y if GRKERNSEC_CONFIG_AUTO
57288 + help
57289 + If you say Y here, unprivileged users will not be able to ptrace unreadable
57290 + binaries. This option is useful in environments that
57291 + remove the read bits (e.g. file mode 4711) from suid binaries to
57292 + prevent infoleaking of their contents. This option adds
57293 + consistency to the use of that file mode, as the binary could normally
57294 + be read out when run without privileges while ptracing.
57295 +
57296 + If the sysctl option is enabled, a sysctl option with name "ptrace_readexec"
57297 + is created.
57298 +
57299 +config GRKERNSEC_SETXID
57300 + bool "Enforce consistent multithreaded privileges"
57301 + default y if GRKERNSEC_CONFIG_AUTO
57302 + depends on (X86 || SPARC64 || PPC || ARM || MIPS)
57303 + help
57304 + If you say Y here, a change from a root uid to a non-root uid
57305 + in a multithreaded application will cause the resulting uids,
57306 + gids, supplementary groups, and capabilities in that thread
57307 + to be propagated to the other threads of the process. In most
57308 + cases this is unnecessary, as glibc will emulate this behavior
57309 + on behalf of the application. Other libcs do not act in the
57310 + same way, allowing the other threads of the process to continue
57311 + running with root privileges. If the sysctl option is enabled,
57312 + a sysctl option with name "consistent_setxid" is created.
57313 +
57314 +config GRKERNSEC_TPE
57315 + bool "Trusted Path Execution (TPE)"
57316 + default y if GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER
57317 + help
57318 + If you say Y here, you will be able to choose a gid to add to the
57319 + supplementary groups of users you want to mark as "untrusted."
57320 + These users will not be able to execute any files that are not in
57321 + root-owned directories writable only by root. If the sysctl option
57322 + is enabled, a sysctl option with name "tpe" is created.
57323 +
57324 +config GRKERNSEC_TPE_ALL
57325 + bool "Partially restrict all non-root users"
57326 + depends on GRKERNSEC_TPE
57327 + help
57328 + If you say Y here, all non-root users will be covered under
57329 + a weaker TPE restriction. This is separate from, and in addition to,
57330 + the main TPE options that you have selected elsewhere. Thus, if a
57331 + "trusted" GID is chosen, this restriction applies to even that GID.
57332 + Under this restriction, all non-root users will only be allowed to
57333 + execute files in directories they own that are not group or
57334 + world-writable, or in directories owned by root and writable only by
57335 + root. If the sysctl option is enabled, a sysctl option with name
57336 + "tpe_restrict_all" is created.
57337 +
57338 +config GRKERNSEC_TPE_INVERT
57339 + bool "Invert GID option"
57340 + depends on GRKERNSEC_TPE
57341 + help
57342 + If you say Y here, the group you specify in the TPE configuration will
57343 + decide what group TPE restrictions will be *disabled* for. This
57344 + option is useful if you want TPE restrictions to be applied to most
57345 + users on the system. If the sysctl option is enabled, a sysctl option
57346 + with name "tpe_invert" is created. Unlike other sysctl options, this
57347 + entry will default to on for backward-compatibility.
57348 +
57349 +config GRKERNSEC_TPE_GID
57350 + int
57351 + default GRKERNSEC_TPE_UNTRUSTED_GID if (GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT)
57352 + default GRKERNSEC_TPE_TRUSTED_GID if (GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT)
57353 +
57354 +config GRKERNSEC_TPE_UNTRUSTED_GID
57355 + int "GID for TPE-untrusted users"
57356 + depends on GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT
57357 + default 1005
57358 + help
57359 + Setting this GID determines what group TPE restrictions will be
57360 + *enabled* for. If the sysctl option is enabled, a sysctl option
57361 + with name "tpe_gid" is created.
57362 +
57363 +config GRKERNSEC_TPE_TRUSTED_GID
57364 + int "GID for TPE-trusted users"
57365 + depends on GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT
57366 + default 1005
57367 + help
57368 + Setting this GID determines what group TPE restrictions will be
57369 + *disabled* for. If the sysctl option is enabled, a sysctl option
57370 + with name "tpe_gid" is created.
57371 +
57372 +endmenu
57373 +menu "Network Protections"
57374 +depends on GRKERNSEC
57375 +
57376 +config GRKERNSEC_RANDNET
57377 + bool "Larger entropy pools"
57378 + default y if GRKERNSEC_CONFIG_AUTO
57379 + help
57380 + If you say Y here, the entropy pools used for many features of Linux
57381 + and grsecurity will be doubled in size. Since several grsecurity
57382 + features use additional randomness, it is recommended that you say Y
57383 + here. Saying Y here has a similar effect as modifying
57384 + /proc/sys/kernel/random/poolsize.
57385 +
57386 +config GRKERNSEC_BLACKHOLE
57387 + bool "TCP/UDP blackhole and LAST_ACK DoS prevention"
57388 + default y if GRKERNSEC_CONFIG_AUTO
57389 + depends on NET
57390 + help
57391 + If you say Y here, neither TCP resets nor ICMP
57392 + destination-unreachable packets will be sent in response to packets
57393 + sent to ports for which no associated listening process exists.
57394 + This feature supports both IPV4 and IPV6 and exempts the
57395 + loopback interface from blackholing. Enabling this feature
57396 + makes a host more resilient to DoS attacks and reduces network
57397 + visibility against scanners.
57398 +
57399 + The blackhole feature as-implemented is equivalent to the FreeBSD
57400 + blackhole feature, as it prevents RST responses to all packets, not
57401 + just SYNs. Under most application behavior this causes no
57402 + problems, but applications (like haproxy) may not close certain
57403 + connections in a way that cleanly terminates them on the remote
57404 + end, leaving the remote host in LAST_ACK state. Because of this
57405 + side-effect and to prevent intentional LAST_ACK DoSes, this
57406 + feature also adds automatic mitigation against such attacks.
57407 + The mitigation drastically reduces the amount of time a socket
57408 + can spend in LAST_ACK state. If you're using haproxy and not
57409 + all servers it connects to have this option enabled, consider
57410 + disabling this feature on the haproxy host.
57411 +
57412 + If the sysctl option is enabled, two sysctl options with names
57413 + "ip_blackhole" and "lastack_retries" will be created.
57414 + While "ip_blackhole" takes the standard zero/non-zero on/off
57415 + toggle, "lastack_retries" uses the same kinds of values as
57416 + "tcp_retries1" and "tcp_retries2". The default value of 4
57417 + prevents a socket from lasting more than 45 seconds in LAST_ACK
57418 + state.
57419 +
57420 +config GRKERNSEC_NO_SIMULT_CONNECT
57421 + bool "Disable TCP Simultaneous Connect"
57422 + default y if GRKERNSEC_CONFIG_AUTO
57423 + depends on NET
57424 + help
57425 + If you say Y here, a feature by Willy Tarreau will be enabled that
57426 + removes a weakness in Linux's strict implementation of TCP that
57427 + allows two clients to connect to each other without either entering
57428 + a listening state. The weakness allows an attacker to easily prevent
57429 + a client from connecting to a known server provided the source port
57430 + for the connection is guessed correctly.
57431 +
57432 + As the weakness could be used to prevent an antivirus or IPS from
57433 + fetching updates, or prevent an SSL gateway from fetching a CRL,
57434 + it should be eliminated by enabling this option. Though Linux is
57435 + one of few operating systems supporting simultaneous connect, it
57436 + has no legitimate use in practice and is rarely supported by firewalls.
57437 +
57438 +config GRKERNSEC_SOCKET
57439 + bool "Socket restrictions"
57440 + depends on NET
57441 + help
57442 + If you say Y here, you will be able to choose from several options.
57443 + If you assign a GID on your system and add it to the supplementary
57444 + groups of users you want to restrict socket access to, this patch
57445 + will perform up to three things, based on the option(s) you choose.
57446 +
57447 +config GRKERNSEC_SOCKET_ALL
57448 + bool "Deny any sockets to group"
57449 + depends on GRKERNSEC_SOCKET
57450 + help
57451 + If you say Y here, you will be able to choose a GID of whose users will
57452 + be unable to connect to other hosts from your machine or run server
57453 + applications from your machine. If the sysctl option is enabled, a
57454 + sysctl option with name "socket_all" is created.
57455 +
57456 +config GRKERNSEC_SOCKET_ALL_GID
57457 + int "GID to deny all sockets for"
57458 + depends on GRKERNSEC_SOCKET_ALL
57459 + default 1004
57460 + help
57461 + Here you can choose the GID to disable socket access for. Remember to
57462 + add the users you want socket access disabled for to the GID
57463 + specified here. If the sysctl option is enabled, a sysctl option
57464 + with name "socket_all_gid" is created.
57465 +
57466 +config GRKERNSEC_SOCKET_CLIENT
57467 + bool "Deny client sockets to group"
57468 + depends on GRKERNSEC_SOCKET
57469 + help
57470 + If you say Y here, you will be able to choose a GID of whose users will
57471 + be unable to connect to other hosts from your machine, but will be
57472 + able to run servers. If this option is enabled, all users in the group
57473 + you specify will have to use passive mode when initiating ftp transfers
57474 + from the shell on your machine. If the sysctl option is enabled, a
57475 + sysctl option with name "socket_client" is created.
57476 +
57477 +config GRKERNSEC_SOCKET_CLIENT_GID
57478 + int "GID to deny client sockets for"
57479 + depends on GRKERNSEC_SOCKET_CLIENT
57480 + default 1003
57481 + help
57482 + Here you can choose the GID to disable client socket access for.
57483 + Remember to add the users you want client socket access disabled for to
57484 + the GID specified here. If the sysctl option is enabled, a sysctl
57485 + option with name "socket_client_gid" is created.
57486 +
57487 +config GRKERNSEC_SOCKET_SERVER
57488 + bool "Deny server sockets to group"
57489 + depends on GRKERNSEC_SOCKET
57490 + help
57491 + If you say Y here, you will be able to choose a GID of whose users will
57492 + be unable to run server applications from your machine. If the sysctl
57493 + option is enabled, a sysctl option with name "socket_server" is created.
57494 +
57495 +config GRKERNSEC_SOCKET_SERVER_GID
57496 + int "GID to deny server sockets for"
57497 + depends on GRKERNSEC_SOCKET_SERVER
57498 + default 1002
57499 + help
57500 + Here you can choose the GID to disable server socket access for.
57501 + Remember to add the users you want server socket access disabled for to
57502 + the GID specified here. If the sysctl option is enabled, a sysctl
57503 + option with name "socket_server_gid" is created.
57504 +
57505 +endmenu
57506 +menu "Sysctl Support"
57507 +depends on GRKERNSEC && SYSCTL
57508 +
57509 +config GRKERNSEC_SYSCTL
57510 + bool "Sysctl support"
57511 + default y if GRKERNSEC_CONFIG_AUTO
57512 + help
57513 + If you say Y here, you will be able to change the options that
57514 + grsecurity runs with at bootup, without having to recompile your
57515 + kernel. You can echo values to files in /proc/sys/kernel/grsecurity
57516 + to enable (1) or disable (0) various features. All the sysctl entries
57517 + are mutable until the "grsec_lock" entry is set to a non-zero value.
57518 + All features enabled in the kernel configuration are disabled at boot
57519 + if you do not say Y to the "Turn on features by default" option.
57520 + All options should be set at startup, and the grsec_lock entry should
57521 + be set to a non-zero value after all the options are set.
57522 + *THIS IS EXTREMELY IMPORTANT*
57523 +
57524 +config GRKERNSEC_SYSCTL_DISTRO
57525 + bool "Extra sysctl support for distro makers (READ HELP)"
57526 + depends on GRKERNSEC_SYSCTL && GRKERNSEC_IO
57527 + help
57528 + If you say Y here, additional sysctl options will be created
57529 + for features that affect processes running as root. Therefore,
57530 + it is critical when using this option that the grsec_lock entry be
57531 + enabled after boot. Only distros with prebuilt kernel packages
57532 + with this option enabled that can ensure grsec_lock is enabled
57533 + after boot should use this option.
57534 + *Failure to set grsec_lock after boot makes all grsec features
57535 + this option covers useless*
57536 +
57537 + Currently this option creates the following sysctl entries:
57538 + "Disable Privileged I/O": "disable_priv_io"
57539 +
57540 +config GRKERNSEC_SYSCTL_ON
57541 + bool "Turn on features by default"
57542 + default y if GRKERNSEC_CONFIG_AUTO
57543 + depends on GRKERNSEC_SYSCTL
57544 + help
57545 + If you say Y here, instead of having all features enabled in the
57546 + kernel configuration disabled at boot time, the features will be
57547 + enabled at boot time. It is recommended you say Y here unless
57548 + there is some reason you would want all sysctl-tunable features to
57549 + be disabled by default. As mentioned elsewhere, it is important
57550 + to enable the grsec_lock entry once you have finished modifying
57551 + the sysctl entries.
57552 +
57553 +endmenu
57554 +menu "Logging Options"
57555 +depends on GRKERNSEC
57556 +
57557 +config GRKERNSEC_FLOODTIME
57558 + int "Seconds in between log messages (minimum)"
57559 + default 10
57560 + help
57561 + This option allows you to enforce the number of seconds between
57562 + grsecurity log messages. The default should be suitable for most
57563 + people, however, if you choose to change it, choose a value small enough
57564 + to allow informative logs to be produced, but large enough to
57565 + prevent flooding.
57566 +
57567 +config GRKERNSEC_FLOODBURST
57568 + int "Number of messages in a burst (maximum)"
57569 + default 6
57570 + help
57571 + This option allows you to choose the maximum number of messages allowed
57572 + within the flood time interval you chose in a separate option. The
57573 + default should be suitable for most people, however if you find that
57574 + many of your logs are being interpreted as flooding, you may want to
57575 + raise this value.
57576 +
57577 +endmenu
57578 diff --git a/grsecurity/Makefile b/grsecurity/Makefile
57579 new file mode 100644
57580 index 0000000..1b9afa9
57581 --- /dev/null
57582 +++ b/grsecurity/Makefile
57583 @@ -0,0 +1,38 @@
57584 +# grsecurity's ACL system was originally written in 2001 by Michael Dalton
57585 +# during 2001-2009 it has been completely redesigned by Brad Spengler
57586 +# into an RBAC system
57587 +#
57588 +# All code in this directory and various hooks inserted throughout the kernel
57589 +# are copyright Brad Spengler - Open Source Security, Inc., and released
57590 +# under the GPL v2 or higher
57591 +
57592 +KBUILD_CFLAGS += -Werror
57593 +
57594 +obj-y = grsec_chdir.o grsec_chroot.o grsec_exec.o grsec_fifo.o grsec_fork.o \
57595 + grsec_mount.o grsec_sig.o grsec_sysctl.o \
57596 + grsec_time.o grsec_tpe.o grsec_link.o grsec_pax.o grsec_ptrace.o
57597 +
57598 +obj-$(CONFIG_GRKERNSEC) += grsec_init.o grsum.o gracl.o gracl_segv.o \
57599 + gracl_cap.o gracl_alloc.o gracl_shm.o grsec_mem.o gracl_fs.o \
57600 + gracl_learn.o grsec_log.o
57601 +obj-$(CONFIG_GRKERNSEC_RESLOG) += gracl_res.o
57602 +
57603 +ifdef CONFIG_NET
57604 +obj-y += grsec_sock.o
57605 +obj-$(CONFIG_GRKERNSEC) += gracl_ip.o
57606 +endif
57607 +
57608 +ifndef CONFIG_GRKERNSEC
57609 +obj-y += grsec_disabled.o
57610 +endif
57611 +
57612 +ifdef CONFIG_GRKERNSEC_HIDESYM
57613 +extra-y := grsec_hidesym.o
57614 +$(obj)/grsec_hidesym.o:
57615 + @-chmod -f 500 /boot
57616 + @-chmod -f 500 /lib/modules
57617 + @-chmod -f 500 /lib64/modules
57618 + @-chmod -f 500 /lib32/modules
57619 + @-chmod -f 700 .
57620 + @echo ' grsec: protected kernel image paths'
57621 +endif
57622 diff --git a/grsecurity/gracl.c b/grsecurity/gracl.c
57623 new file mode 100644
57624 index 0000000..1248ee0
57625 --- /dev/null
57626 +++ b/grsecurity/gracl.c
57627 @@ -0,0 +1,4073 @@
57628 +#include <linux/kernel.h>
57629 +#include <linux/module.h>
57630 +#include <linux/sched.h>
57631 +#include <linux/mm.h>
57632 +#include <linux/file.h>
57633 +#include <linux/fs.h>
57634 +#include <linux/namei.h>
57635 +#include <linux/mount.h>
57636 +#include <linux/tty.h>
57637 +#include <linux/proc_fs.h>
57638 +#include <linux/lglock.h>
57639 +#include <linux/slab.h>
57640 +#include <linux/vmalloc.h>
57641 +#include <linux/types.h>
57642 +#include <linux/sysctl.h>
57643 +#include <linux/netdevice.h>
57644 +#include <linux/ptrace.h>
57645 +#include <linux/gracl.h>
57646 +#include <linux/gralloc.h>
57647 +#include <linux/security.h>
57648 +#include <linux/grinternal.h>
57649 +#include <linux/pid_namespace.h>
57650 +#include <linux/stop_machine.h>
57651 +#include <linux/fdtable.h>
57652 +#include <linux/percpu.h>
57653 +#include <linux/lglock.h>
57654 +#include <linux/hugetlb.h>
57655 +#include <linux/posix-timers.h>
57656 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
57657 +#include <linux/magic.h>
57658 +#include <linux/pagemap.h>
57659 +#include "../fs/btrfs/async-thread.h"
57660 +#include "../fs/btrfs/ctree.h"
57661 +#include "../fs/btrfs/btrfs_inode.h"
57662 +#endif
57663 +#include "../fs/mount.h"
57664 +
57665 +#include <asm/uaccess.h>
57666 +#include <asm/errno.h>
57667 +#include <asm/mman.h>
57668 +
57669 +extern struct lglock vfsmount_lock;
57670 +
57671 +static struct acl_role_db acl_role_set;
57672 +static struct name_db name_set;
57673 +static struct inodev_db inodev_set;
57674 +
57675 +/* for keeping track of userspace pointers used for subjects, so we
57676 + can share references in the kernel as well
57677 +*/
57678 +
57679 +static struct path real_root;
57680 +
57681 +static struct acl_subj_map_db subj_map_set;
57682 +
57683 +static struct acl_role_label *default_role;
57684 +
57685 +static struct acl_role_label *role_list;
57686 +
57687 +static u16 acl_sp_role_value;
57688 +
57689 +extern char *gr_shared_page[4];
57690 +static DEFINE_MUTEX(gr_dev_mutex);
57691 +DEFINE_RWLOCK(gr_inode_lock);
57692 +
57693 +struct gr_arg *gr_usermode;
57694 +
57695 +static unsigned int gr_status __read_only = GR_STATUS_INIT;
57696 +
57697 +extern int chkpw(struct gr_arg *entry, unsigned char *salt, unsigned char *sum);
57698 +extern void gr_clear_learn_entries(void);
57699 +
57700 +unsigned char *gr_system_salt;
57701 +unsigned char *gr_system_sum;
57702 +
57703 +static struct sprole_pw **acl_special_roles = NULL;
57704 +static __u16 num_sprole_pws = 0;
57705 +
57706 +static struct acl_role_label *kernel_role = NULL;
57707 +
57708 +static unsigned int gr_auth_attempts = 0;
57709 +static unsigned long gr_auth_expires = 0UL;
57710 +
57711 +#ifdef CONFIG_NET
57712 +extern struct vfsmount *sock_mnt;
57713 +#endif
57714 +
57715 +extern struct vfsmount *pipe_mnt;
57716 +extern struct vfsmount *shm_mnt;
57717 +
57718 +#ifdef CONFIG_HUGETLBFS
57719 +extern struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
57720 +#endif
57721 +
57722 +static struct acl_object_label *fakefs_obj_rw;
57723 +static struct acl_object_label *fakefs_obj_rwx;
57724 +
57725 +extern int gr_init_uidset(void);
57726 +extern void gr_free_uidset(void);
57727 +extern void gr_remove_uid(uid_t uid);
57728 +extern int gr_find_uid(uid_t uid);
57729 +
57730 +__inline__ int
57731 +gr_acl_is_enabled(void)
57732 +{
57733 + return (gr_status & GR_READY);
57734 +}
57735 +
57736 +static inline dev_t __get_dev(const struct dentry *dentry)
57737 +{
57738 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
57739 + if (dentry->d_sb->s_magic == BTRFS_SUPER_MAGIC)
57740 + return BTRFS_I(dentry->d_inode)->root->anon_dev;
57741 + else
57742 +#endif
57743 + return dentry->d_sb->s_dev;
57744 +}
57745 +
57746 +dev_t gr_get_dev_from_dentry(struct dentry *dentry)
57747 +{
57748 + return __get_dev(dentry);
57749 +}
57750 +
57751 +static char gr_task_roletype_to_char(struct task_struct *task)
57752 +{
57753 + switch (task->role->roletype &
57754 + (GR_ROLE_DEFAULT | GR_ROLE_USER | GR_ROLE_GROUP |
57755 + GR_ROLE_SPECIAL)) {
57756 + case GR_ROLE_DEFAULT:
57757 + return 'D';
57758 + case GR_ROLE_USER:
57759 + return 'U';
57760 + case GR_ROLE_GROUP:
57761 + return 'G';
57762 + case GR_ROLE_SPECIAL:
57763 + return 'S';
57764 + }
57765 +
57766 + return 'X';
57767 +}
57768 +
57769 +char gr_roletype_to_char(void)
57770 +{
57771 + return gr_task_roletype_to_char(current);
57772 +}
57773 +
57774 +__inline__ int
57775 +gr_acl_tpe_check(void)
57776 +{
57777 + if (unlikely(!(gr_status & GR_READY)))
57778 + return 0;
57779 + if (current->role->roletype & GR_ROLE_TPE)
57780 + return 1;
57781 + else
57782 + return 0;
57783 +}
57784 +
57785 +int
57786 +gr_handle_rawio(const struct inode *inode)
57787 +{
57788 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
57789 + if (inode && S_ISBLK(inode->i_mode) &&
57790 + grsec_enable_chroot_caps && proc_is_chrooted(current) &&
57791 + !capable(CAP_SYS_RAWIO))
57792 + return 1;
57793 +#endif
57794 + return 0;
57795 +}
57796 +
57797 +static int
57798 +gr_streq(const char *a, const char *b, const unsigned int lena, const unsigned int lenb)
57799 +{
57800 + if (likely(lena != lenb))
57801 + return 0;
57802 +
57803 + return !memcmp(a, b, lena);
57804 +}
57805 +
57806 +static int prepend(char **buffer, int *buflen, const char *str, int namelen)
57807 +{
57808 + *buflen -= namelen;
57809 + if (*buflen < 0)
57810 + return -ENAMETOOLONG;
57811 + *buffer -= namelen;
57812 + memcpy(*buffer, str, namelen);
57813 + return 0;
57814 +}
57815 +
57816 +static int prepend_name(char **buffer, int *buflen, struct qstr *name)
57817 +{
57818 + return prepend(buffer, buflen, name->name, name->len);
57819 +}
57820 +
57821 +static int prepend_path(const struct path *path, struct path *root,
57822 + char **buffer, int *buflen)
57823 +{
57824 + struct dentry *dentry = path->dentry;
57825 + struct vfsmount *vfsmnt = path->mnt;
57826 + struct mount *mnt = real_mount(vfsmnt);
57827 + bool slash = false;
57828 + int error = 0;
57829 +
57830 + while (dentry != root->dentry || vfsmnt != root->mnt) {
57831 + struct dentry * parent;
57832 +
57833 + if (dentry == vfsmnt->mnt_root || IS_ROOT(dentry)) {
57834 + /* Global root? */
57835 + if (!mnt_has_parent(mnt)) {
57836 + goto out;
57837 + }
57838 + dentry = mnt->mnt_mountpoint;
57839 + mnt = mnt->mnt_parent;
57840 + vfsmnt = &mnt->mnt;
57841 + continue;
57842 + }
57843 + parent = dentry->d_parent;
57844 + prefetch(parent);
57845 + spin_lock(&dentry->d_lock);
57846 + error = prepend_name(buffer, buflen, &dentry->d_name);
57847 + spin_unlock(&dentry->d_lock);
57848 + if (!error)
57849 + error = prepend(buffer, buflen, "/", 1);
57850 + if (error)
57851 + break;
57852 +
57853 + slash = true;
57854 + dentry = parent;
57855 + }
57856 +
57857 +out:
57858 + if (!error && !slash)
57859 + error = prepend(buffer, buflen, "/", 1);
57860 +
57861 + return error;
57862 +}
57863 +
57864 +/* this must be called with vfsmount_lock and rename_lock held */
57865 +
57866 +static char *__our_d_path(const struct path *path, struct path *root,
57867 + char *buf, int buflen)
57868 +{
57869 + char *res = buf + buflen;
57870 + int error;
57871 +
57872 + prepend(&res, &buflen, "\0", 1);
57873 + error = prepend_path(path, root, &res, &buflen);
57874 + if (error)
57875 + return ERR_PTR(error);
57876 +
57877 + return res;
57878 +}
57879 +
57880 +static char *
57881 +gen_full_path(struct path *path, struct path *root, char *buf, int buflen)
57882 +{
57883 + char *retval;
57884 +
57885 + retval = __our_d_path(path, root, buf, buflen);
57886 + if (unlikely(IS_ERR(retval)))
57887 + retval = strcpy(buf, "<path too long>");
57888 + else if (unlikely(retval[1] == '/' && retval[2] == '\0'))
57889 + retval[1] = '\0';
57890 +
57891 + return retval;
57892 +}
57893 +
57894 +static char *
57895 +__d_real_path(const struct dentry *dentry, const struct vfsmount *vfsmnt,
57896 + char *buf, int buflen)
57897 +{
57898 + struct path path;
57899 + char *res;
57900 +
57901 + path.dentry = (struct dentry *)dentry;
57902 + path.mnt = (struct vfsmount *)vfsmnt;
57903 +
57904 + /* we can use real_root.dentry, real_root.mnt, because this is only called
57905 + by the RBAC system */
57906 + res = gen_full_path(&path, &real_root, buf, buflen);
57907 +
57908 + return res;
57909 +}
57910 +
57911 +static char *
57912 +d_real_path(const struct dentry *dentry, const struct vfsmount *vfsmnt,
57913 + char *buf, int buflen)
57914 +{
57915 + char *res;
57916 + struct path path;
57917 + struct path root;
57918 + struct task_struct *reaper = init_pid_ns.child_reaper;
57919 +
57920 + path.dentry = (struct dentry *)dentry;
57921 + path.mnt = (struct vfsmount *)vfsmnt;
57922 +
57923 + /* we can't use real_root.dentry, real_root.mnt, because they belong only to the RBAC system */
57924 + get_fs_root(reaper->fs, &root);
57925 +
57926 + br_read_lock(&vfsmount_lock);
57927 + write_seqlock(&rename_lock);
57928 + res = gen_full_path(&path, &root, buf, buflen);
57929 + write_sequnlock(&rename_lock);
57930 + br_read_unlock(&vfsmount_lock);
57931 +
57932 + path_put(&root);
57933 + return res;
57934 +}
57935 +
57936 +static char *
57937 +gr_to_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt)
57938 +{
57939 + char *ret;
57940 + br_read_lock(&vfsmount_lock);
57941 + write_seqlock(&rename_lock);
57942 + ret = __d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0],smp_processor_id()),
57943 + PAGE_SIZE);
57944 + write_sequnlock(&rename_lock);
57945 + br_read_unlock(&vfsmount_lock);
57946 + return ret;
57947 +}
57948 +
57949 +static char *
57950 +gr_to_proc_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt)
57951 +{
57952 + char *ret;
57953 + char *buf;
57954 + int buflen;
57955 +
57956 + br_read_lock(&vfsmount_lock);
57957 + write_seqlock(&rename_lock);
57958 + buf = per_cpu_ptr(gr_shared_page[0], smp_processor_id());
57959 + ret = __d_real_path(dentry, mnt, buf, PAGE_SIZE - 6);
57960 + buflen = (int)(ret - buf);
57961 + if (buflen >= 5)
57962 + prepend(&ret, &buflen, "/proc", 5);
57963 + else
57964 + ret = strcpy(buf, "<path too long>");
57965 + write_sequnlock(&rename_lock);
57966 + br_read_unlock(&vfsmount_lock);
57967 + return ret;
57968 +}
57969 +
57970 +char *
57971 +gr_to_filename_nolock(const struct dentry *dentry, const struct vfsmount *mnt)
57972 +{
57973 + return __d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0],smp_processor_id()),
57974 + PAGE_SIZE);
57975 +}
57976 +
57977 +char *
57978 +gr_to_filename(const struct dentry *dentry, const struct vfsmount *mnt)
57979 +{
57980 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0], smp_processor_id()),
57981 + PAGE_SIZE);
57982 +}
57983 +
57984 +char *
57985 +gr_to_filename1(const struct dentry *dentry, const struct vfsmount *mnt)
57986 +{
57987 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[1], smp_processor_id()),
57988 + PAGE_SIZE);
57989 +}
57990 +
57991 +char *
57992 +gr_to_filename2(const struct dentry *dentry, const struct vfsmount *mnt)
57993 +{
57994 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[2], smp_processor_id()),
57995 + PAGE_SIZE);
57996 +}
57997 +
57998 +char *
57999 +gr_to_filename3(const struct dentry *dentry, const struct vfsmount *mnt)
58000 +{
58001 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[3], smp_processor_id()),
58002 + PAGE_SIZE);
58003 +}
58004 +
58005 +__inline__ __u32
58006 +to_gr_audit(const __u32 reqmode)
58007 +{
58008 + /* masks off auditable permission flags, then shifts them to create
58009 + auditing flags, and adds the special case of append auditing if
58010 + we're requesting write */
58011 + return (((reqmode & ~GR_AUDITS) << 10) | ((reqmode & GR_WRITE) ? GR_AUDIT_APPEND : 0));
58012 +}
58013 +
58014 +struct acl_subject_label *
58015 +lookup_subject_map(const struct acl_subject_label *userp)
58016 +{
58017 + unsigned int index = gr_shash(userp, subj_map_set.s_size);
58018 + struct subject_map *match;
58019 +
58020 + match = subj_map_set.s_hash[index];
58021 +
58022 + while (match && match->user != userp)
58023 + match = match->next;
58024 +
58025 + if (match != NULL)
58026 + return match->kernel;
58027 + else
58028 + return NULL;
58029 +}
58030 +
58031 +static void
58032 +insert_subj_map_entry(struct subject_map *subjmap)
58033 +{
58034 + unsigned int index = gr_shash(subjmap->user, subj_map_set.s_size);
58035 + struct subject_map **curr;
58036 +
58037 + subjmap->prev = NULL;
58038 +
58039 + curr = &subj_map_set.s_hash[index];
58040 + if (*curr != NULL)
58041 + (*curr)->prev = subjmap;
58042 +
58043 + subjmap->next = *curr;
58044 + *curr = subjmap;
58045 +
58046 + return;
58047 +}
58048 +
58049 +static struct acl_role_label *
58050 +lookup_acl_role_label(const struct task_struct *task, const uid_t uid,
58051 + const gid_t gid)
58052 +{
58053 + unsigned int index = gr_rhash(uid, GR_ROLE_USER, acl_role_set.r_size);
58054 + struct acl_role_label *match;
58055 + struct role_allowed_ip *ipp;
58056 + unsigned int x;
58057 + u32 curr_ip = task->signal->curr_ip;
58058 +
58059 + task->signal->saved_ip = curr_ip;
58060 +
58061 + match = acl_role_set.r_hash[index];
58062 +
58063 + while (match) {
58064 + if ((match->roletype & (GR_ROLE_DOMAIN | GR_ROLE_USER)) == (GR_ROLE_DOMAIN | GR_ROLE_USER)) {
58065 + for (x = 0; x < match->domain_child_num; x++) {
58066 + if (match->domain_children[x] == uid)
58067 + goto found;
58068 + }
58069 + } else if (match->uidgid == uid && match->roletype & GR_ROLE_USER)
58070 + break;
58071 + match = match->next;
58072 + }
58073 +found:
58074 + if (match == NULL) {
58075 + try_group:
58076 + index = gr_rhash(gid, GR_ROLE_GROUP, acl_role_set.r_size);
58077 + match = acl_role_set.r_hash[index];
58078 +
58079 + while (match) {
58080 + if ((match->roletype & (GR_ROLE_DOMAIN | GR_ROLE_GROUP)) == (GR_ROLE_DOMAIN | GR_ROLE_GROUP)) {
58081 + for (x = 0; x < match->domain_child_num; x++) {
58082 + if (match->domain_children[x] == gid)
58083 + goto found2;
58084 + }
58085 + } else if (match->uidgid == gid && match->roletype & GR_ROLE_GROUP)
58086 + break;
58087 + match = match->next;
58088 + }
58089 +found2:
58090 + if (match == NULL)
58091 + match = default_role;
58092 + if (match->allowed_ips == NULL)
58093 + return match;
58094 + else {
58095 + for (ipp = match->allowed_ips; ipp; ipp = ipp->next) {
58096 + if (likely
58097 + ((ntohl(curr_ip) & ipp->netmask) ==
58098 + (ntohl(ipp->addr) & ipp->netmask)))
58099 + return match;
58100 + }
58101 + match = default_role;
58102 + }
58103 + } else if (match->allowed_ips == NULL) {
58104 + return match;
58105 + } else {
58106 + for (ipp = match->allowed_ips; ipp; ipp = ipp->next) {
58107 + if (likely
58108 + ((ntohl(curr_ip) & ipp->netmask) ==
58109 + (ntohl(ipp->addr) & ipp->netmask)))
58110 + return match;
58111 + }
58112 + goto try_group;
58113 + }
58114 +
58115 + return match;
58116 +}
58117 +
58118 +struct acl_subject_label *
58119 +lookup_acl_subj_label(const ino_t ino, const dev_t dev,
58120 + const struct acl_role_label *role)
58121 +{
58122 + unsigned int index = gr_fhash(ino, dev, role->subj_hash_size);
58123 + struct acl_subject_label *match;
58124 +
58125 + match = role->subj_hash[index];
58126 +
58127 + while (match && (match->inode != ino || match->device != dev ||
58128 + (match->mode & GR_DELETED))) {
58129 + match = match->next;
58130 + }
58131 +
58132 + if (match && !(match->mode & GR_DELETED))
58133 + return match;
58134 + else
58135 + return NULL;
58136 +}
58137 +
58138 +struct acl_subject_label *
58139 +lookup_acl_subj_label_deleted(const ino_t ino, const dev_t dev,
58140 + const struct acl_role_label *role)
58141 +{
58142 + unsigned int index = gr_fhash(ino, dev, role->subj_hash_size);
58143 + struct acl_subject_label *match;
58144 +
58145 + match = role->subj_hash[index];
58146 +
58147 + while (match && (match->inode != ino || match->device != dev ||
58148 + !(match->mode & GR_DELETED))) {
58149 + match = match->next;
58150 + }
58151 +
58152 + if (match && (match->mode & GR_DELETED))
58153 + return match;
58154 + else
58155 + return NULL;
58156 +}
58157 +
58158 +static struct acl_object_label *
58159 +lookup_acl_obj_label(const ino_t ino, const dev_t dev,
58160 + const struct acl_subject_label *subj)
58161 +{
58162 + unsigned int index = gr_fhash(ino, dev, subj->obj_hash_size);
58163 + struct acl_object_label *match;
58164 +
58165 + match = subj->obj_hash[index];
58166 +
58167 + while (match && (match->inode != ino || match->device != dev ||
58168 + (match->mode & GR_DELETED))) {
58169 + match = match->next;
58170 + }
58171 +
58172 + if (match && !(match->mode & GR_DELETED))
58173 + return match;
58174 + else
58175 + return NULL;
58176 +}
58177 +
58178 +static struct acl_object_label *
58179 +lookup_acl_obj_label_create(const ino_t ino, const dev_t dev,
58180 + const struct acl_subject_label *subj)
58181 +{
58182 + unsigned int index = gr_fhash(ino, dev, subj->obj_hash_size);
58183 + struct acl_object_label *match;
58184 +
58185 + match = subj->obj_hash[index];
58186 +
58187 + while (match && (match->inode != ino || match->device != dev ||
58188 + !(match->mode & GR_DELETED))) {
58189 + match = match->next;
58190 + }
58191 +
58192 + if (match && (match->mode & GR_DELETED))
58193 + return match;
58194 +
58195 + match = subj->obj_hash[index];
58196 +
58197 + while (match && (match->inode != ino || match->device != dev ||
58198 + (match->mode & GR_DELETED))) {
58199 + match = match->next;
58200 + }
58201 +
58202 + if (match && !(match->mode & GR_DELETED))
58203 + return match;
58204 + else
58205 + return NULL;
58206 +}
58207 +
58208 +static struct name_entry *
58209 +lookup_name_entry(const char *name)
58210 +{
58211 + unsigned int len = strlen(name);
58212 + unsigned int key = full_name_hash(name, len);
58213 + unsigned int index = key % name_set.n_size;
58214 + struct name_entry *match;
58215 +
58216 + match = name_set.n_hash[index];
58217 +
58218 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len)))
58219 + match = match->next;
58220 +
58221 + return match;
58222 +}
58223 +
58224 +static struct name_entry *
58225 +lookup_name_entry_create(const char *name)
58226 +{
58227 + unsigned int len = strlen(name);
58228 + unsigned int key = full_name_hash(name, len);
58229 + unsigned int index = key % name_set.n_size;
58230 + struct name_entry *match;
58231 +
58232 + match = name_set.n_hash[index];
58233 +
58234 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len) ||
58235 + !match->deleted))
58236 + match = match->next;
58237 +
58238 + if (match && match->deleted)
58239 + return match;
58240 +
58241 + match = name_set.n_hash[index];
58242 +
58243 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len) ||
58244 + match->deleted))
58245 + match = match->next;
58246 +
58247 + if (match && !match->deleted)
58248 + return match;
58249 + else
58250 + return NULL;
58251 +}
58252 +
58253 +static struct inodev_entry *
58254 +lookup_inodev_entry(const ino_t ino, const dev_t dev)
58255 +{
58256 + unsigned int index = gr_fhash(ino, dev, inodev_set.i_size);
58257 + struct inodev_entry *match;
58258 +
58259 + match = inodev_set.i_hash[index];
58260 +
58261 + while (match && (match->nentry->inode != ino || match->nentry->device != dev))
58262 + match = match->next;
58263 +
58264 + return match;
58265 +}
58266 +
58267 +static void
58268 +insert_inodev_entry(struct inodev_entry *entry)
58269 +{
58270 + unsigned int index = gr_fhash(entry->nentry->inode, entry->nentry->device,
58271 + inodev_set.i_size);
58272 + struct inodev_entry **curr;
58273 +
58274 + entry->prev = NULL;
58275 +
58276 + curr = &inodev_set.i_hash[index];
58277 + if (*curr != NULL)
58278 + (*curr)->prev = entry;
58279 +
58280 + entry->next = *curr;
58281 + *curr = entry;
58282 +
58283 + return;
58284 +}
58285 +
58286 +static void
58287 +__insert_acl_role_label(struct acl_role_label *role, uid_t uidgid)
58288 +{
58289 + unsigned int index =
58290 + gr_rhash(uidgid, role->roletype & (GR_ROLE_USER | GR_ROLE_GROUP), acl_role_set.r_size);
58291 + struct acl_role_label **curr;
58292 + struct acl_role_label *tmp, *tmp2;
58293 +
58294 + curr = &acl_role_set.r_hash[index];
58295 +
58296 + /* simple case, slot is empty, just set it to our role */
58297 + if (*curr == NULL) {
58298 + *curr = role;
58299 + } else {
58300 + /* example:
58301 + 1 -> 2 -> 3 (adding 2 -> 3 to here)
58302 + 2 -> 3
58303 + */
58304 + /* first check to see if we can already be reached via this slot */
58305 + tmp = *curr;
58306 + while (tmp && tmp != role)
58307 + tmp = tmp->next;
58308 + if (tmp == role) {
58309 + /* we don't need to add ourselves to this slot's chain */
58310 + return;
58311 + }
58312 + /* we need to add ourselves to this chain, two cases */
58313 + if (role->next == NULL) {
58314 + /* simple case, append the current chain to our role */
58315 + role->next = *curr;
58316 + *curr = role;
58317 + } else {
58318 + /* 1 -> 2 -> 3 -> 4
58319 + 2 -> 3 -> 4
58320 + 3 -> 4 (adding 1 -> 2 -> 3 -> 4 to here)
58321 + */
58322 + /* trickier case: walk our role's chain until we find
58323 + the role for the start of the current slot's chain */
58324 + tmp = role;
58325 + tmp2 = *curr;
58326 + while (tmp->next && tmp->next != tmp2)
58327 + tmp = tmp->next;
58328 + if (tmp->next == tmp2) {
58329 + /* from example above, we found 3, so just
58330 + replace this slot's chain with ours */
58331 + *curr = role;
58332 + } else {
58333 + /* we didn't find a subset of our role's chain
58334 + in the current slot's chain, so append their
58335 + chain to ours, and set us as the first role in
58336 + the slot's chain
58337 +
58338 + we could fold this case with the case above,
58339 + but making it explicit for clarity
58340 + */
58341 + tmp->next = tmp2;
58342 + *curr = role;
58343 + }
58344 + }
58345 + }
58346 +
58347 + return;
58348 +}
58349 +
58350 +static void
58351 +insert_acl_role_label(struct acl_role_label *role)
58352 +{
58353 + int i;
58354 +
58355 + if (role_list == NULL) {
58356 + role_list = role;
58357 + role->prev = NULL;
58358 + } else {
58359 + role->prev = role_list;
58360 + role_list = role;
58361 + }
58362 +
58363 + /* used for hash chains */
58364 + role->next = NULL;
58365 +
58366 + if (role->roletype & GR_ROLE_DOMAIN) {
58367 + for (i = 0; i < role->domain_child_num; i++)
58368 + __insert_acl_role_label(role, role->domain_children[i]);
58369 + } else
58370 + __insert_acl_role_label(role, role->uidgid);
58371 +}
58372 +
58373 +static int
58374 +insert_name_entry(char *name, const ino_t inode, const dev_t device, __u8 deleted)
58375 +{
58376 + struct name_entry **curr, *nentry;
58377 + struct inodev_entry *ientry;
58378 + unsigned int len = strlen(name);
58379 + unsigned int key = full_name_hash(name, len);
58380 + unsigned int index = key % name_set.n_size;
58381 +
58382 + curr = &name_set.n_hash[index];
58383 +
58384 + while (*curr && ((*curr)->key != key || !gr_streq((*curr)->name, name, (*curr)->len, len)))
58385 + curr = &((*curr)->next);
58386 +
58387 + if (*curr != NULL)
58388 + return 1;
58389 +
58390 + nentry = acl_alloc(sizeof (struct name_entry));
58391 + if (nentry == NULL)
58392 + return 0;
58393 + ientry = acl_alloc(sizeof (struct inodev_entry));
58394 + if (ientry == NULL)
58395 + return 0;
58396 + ientry->nentry = nentry;
58397 +
58398 + nentry->key = key;
58399 + nentry->name = name;
58400 + nentry->inode = inode;
58401 + nentry->device = device;
58402 + nentry->len = len;
58403 + nentry->deleted = deleted;
58404 +
58405 + nentry->prev = NULL;
58406 + curr = &name_set.n_hash[index];
58407 + if (*curr != NULL)
58408 + (*curr)->prev = nentry;
58409 + nentry->next = *curr;
58410 + *curr = nentry;
58411 +
58412 + /* insert us into the table searchable by inode/dev */
58413 + insert_inodev_entry(ientry);
58414 +
58415 + return 1;
58416 +}
58417 +
58418 +static void
58419 +insert_acl_obj_label(struct acl_object_label *obj,
58420 + struct acl_subject_label *subj)
58421 +{
58422 + unsigned int index =
58423 + gr_fhash(obj->inode, obj->device, subj->obj_hash_size);
58424 + struct acl_object_label **curr;
58425 +
58426 +
58427 + obj->prev = NULL;
58428 +
58429 + curr = &subj->obj_hash[index];
58430 + if (*curr != NULL)
58431 + (*curr)->prev = obj;
58432 +
58433 + obj->next = *curr;
58434 + *curr = obj;
58435 +
58436 + return;
58437 +}
58438 +
58439 +static void
58440 +insert_acl_subj_label(struct acl_subject_label *obj,
58441 + struct acl_role_label *role)
58442 +{
58443 + unsigned int index = gr_fhash(obj->inode, obj->device, role->subj_hash_size);
58444 + struct acl_subject_label **curr;
58445 +
58446 + obj->prev = NULL;
58447 +
58448 + curr = &role->subj_hash[index];
58449 + if (*curr != NULL)
58450 + (*curr)->prev = obj;
58451 +
58452 + obj->next = *curr;
58453 + *curr = obj;
58454 +
58455 + return;
58456 +}
58457 +
58458 +/* allocating chained hash tables, so optimal size is where lambda ~ 1 */
58459 +
58460 +static void *
58461 +create_table(__u32 * len, int elementsize)
58462 +{
58463 + unsigned int table_sizes[] = {
58464 + 7, 13, 31, 61, 127, 251, 509, 1021, 2039, 4093, 8191, 16381,
58465 + 32749, 65521, 131071, 262139, 524287, 1048573, 2097143,
58466 + 4194301, 8388593, 16777213, 33554393, 67108859
58467 + };
58468 + void *newtable = NULL;
58469 + unsigned int pwr = 0;
58470 +
58471 + while ((pwr < ((sizeof (table_sizes) / sizeof (table_sizes[0])) - 1)) &&
58472 + table_sizes[pwr] <= *len)
58473 + pwr++;
58474 +
58475 + if (table_sizes[pwr] <= *len || (table_sizes[pwr] > ULONG_MAX / elementsize))
58476 + return newtable;
58477 +
58478 + if ((table_sizes[pwr] * elementsize) <= PAGE_SIZE)
58479 + newtable =
58480 + kmalloc(table_sizes[pwr] * elementsize, GFP_KERNEL);
58481 + else
58482 + newtable = vmalloc(table_sizes[pwr] * elementsize);
58483 +
58484 + *len = table_sizes[pwr];
58485 +
58486 + return newtable;
58487 +}
58488 +
58489 +static int
58490 +init_variables(const struct gr_arg *arg)
58491 +{
58492 + struct task_struct *reaper = init_pid_ns.child_reaper;
58493 + unsigned int stacksize;
58494 +
58495 + subj_map_set.s_size = arg->role_db.num_subjects;
58496 + acl_role_set.r_size = arg->role_db.num_roles + arg->role_db.num_domain_children;
58497 + name_set.n_size = arg->role_db.num_objects;
58498 + inodev_set.i_size = arg->role_db.num_objects;
58499 +
58500 + if (!subj_map_set.s_size || !acl_role_set.r_size ||
58501 + !name_set.n_size || !inodev_set.i_size)
58502 + return 1;
58503 +
58504 + if (!gr_init_uidset())
58505 + return 1;
58506 +
58507 + /* set up the stack that holds allocation info */
58508 +
58509 + stacksize = arg->role_db.num_pointers + 5;
58510 +
58511 + if (!acl_alloc_stack_init(stacksize))
58512 + return 1;
58513 +
58514 + /* grab reference for the real root dentry and vfsmount */
58515 + get_fs_root(reaper->fs, &real_root);
58516 +
58517 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
58518 + printk(KERN_ALERT "Obtained real root device=%d, inode=%lu\n", __get_dev(real_root.dentry), real_root.dentry->d_inode->i_ino);
58519 +#endif
58520 +
58521 + fakefs_obj_rw = acl_alloc(sizeof(struct acl_object_label));
58522 + if (fakefs_obj_rw == NULL)
58523 + return 1;
58524 + fakefs_obj_rw->mode = GR_FIND | GR_READ | GR_WRITE;
58525 +
58526 + fakefs_obj_rwx = acl_alloc(sizeof(struct acl_object_label));
58527 + if (fakefs_obj_rwx == NULL)
58528 + return 1;
58529 + fakefs_obj_rwx->mode = GR_FIND | GR_READ | GR_WRITE | GR_EXEC;
58530 +
58531 + subj_map_set.s_hash =
58532 + (struct subject_map **) create_table(&subj_map_set.s_size, sizeof(void *));
58533 + acl_role_set.r_hash =
58534 + (struct acl_role_label **) create_table(&acl_role_set.r_size, sizeof(void *));
58535 + name_set.n_hash = (struct name_entry **) create_table(&name_set.n_size, sizeof(void *));
58536 + inodev_set.i_hash =
58537 + (struct inodev_entry **) create_table(&inodev_set.i_size, sizeof(void *));
58538 +
58539 + if (!subj_map_set.s_hash || !acl_role_set.r_hash ||
58540 + !name_set.n_hash || !inodev_set.i_hash)
58541 + return 1;
58542 +
58543 + memset(subj_map_set.s_hash, 0,
58544 + sizeof(struct subject_map *) * subj_map_set.s_size);
58545 + memset(acl_role_set.r_hash, 0,
58546 + sizeof (struct acl_role_label *) * acl_role_set.r_size);
58547 + memset(name_set.n_hash, 0,
58548 + sizeof (struct name_entry *) * name_set.n_size);
58549 + memset(inodev_set.i_hash, 0,
58550 + sizeof (struct inodev_entry *) * inodev_set.i_size);
58551 +
58552 + return 0;
58553 +}
58554 +
58555 +/* free information not needed after startup
58556 + currently contains user->kernel pointer mappings for subjects
58557 +*/
58558 +
58559 +static void
58560 +free_init_variables(void)
58561 +{
58562 + __u32 i;
58563 +
58564 + if (subj_map_set.s_hash) {
58565 + for (i = 0; i < subj_map_set.s_size; i++) {
58566 + if (subj_map_set.s_hash[i]) {
58567 + kfree(subj_map_set.s_hash[i]);
58568 + subj_map_set.s_hash[i] = NULL;
58569 + }
58570 + }
58571 +
58572 + if ((subj_map_set.s_size * sizeof (struct subject_map *)) <=
58573 + PAGE_SIZE)
58574 + kfree(subj_map_set.s_hash);
58575 + else
58576 + vfree(subj_map_set.s_hash);
58577 + }
58578 +
58579 + return;
58580 +}
58581 +
58582 +static void
58583 +free_variables(void)
58584 +{
58585 + struct acl_subject_label *s;
58586 + struct acl_role_label *r;
58587 + struct task_struct *task, *task2;
58588 + unsigned int x;
58589 +
58590 + gr_clear_learn_entries();
58591 +
58592 + read_lock(&tasklist_lock);
58593 + do_each_thread(task2, task) {
58594 + task->acl_sp_role = 0;
58595 + task->acl_role_id = 0;
58596 + task->acl = NULL;
58597 + task->role = NULL;
58598 + } while_each_thread(task2, task);
58599 + read_unlock(&tasklist_lock);
58600 +
58601 + /* release the reference to the real root dentry and vfsmount */
58602 + path_put(&real_root);
58603 + memset(&real_root, 0, sizeof(real_root));
58604 +
58605 + /* free all object hash tables */
58606 +
58607 + FOR_EACH_ROLE_START(r)
58608 + if (r->subj_hash == NULL)
58609 + goto next_role;
58610 + FOR_EACH_SUBJECT_START(r, s, x)
58611 + if (s->obj_hash == NULL)
58612 + break;
58613 + if ((s->obj_hash_size * sizeof (struct acl_object_label *)) <= PAGE_SIZE)
58614 + kfree(s->obj_hash);
58615 + else
58616 + vfree(s->obj_hash);
58617 + FOR_EACH_SUBJECT_END(s, x)
58618 + FOR_EACH_NESTED_SUBJECT_START(r, s)
58619 + if (s->obj_hash == NULL)
58620 + break;
58621 + if ((s->obj_hash_size * sizeof (struct acl_object_label *)) <= PAGE_SIZE)
58622 + kfree(s->obj_hash);
58623 + else
58624 + vfree(s->obj_hash);
58625 + FOR_EACH_NESTED_SUBJECT_END(s)
58626 + if ((r->subj_hash_size * sizeof (struct acl_subject_label *)) <= PAGE_SIZE)
58627 + kfree(r->subj_hash);
58628 + else
58629 + vfree(r->subj_hash);
58630 + r->subj_hash = NULL;
58631 +next_role:
58632 + FOR_EACH_ROLE_END(r)
58633 +
58634 + acl_free_all();
58635 +
58636 + if (acl_role_set.r_hash) {
58637 + if ((acl_role_set.r_size * sizeof (struct acl_role_label *)) <=
58638 + PAGE_SIZE)
58639 + kfree(acl_role_set.r_hash);
58640 + else
58641 + vfree(acl_role_set.r_hash);
58642 + }
58643 + if (name_set.n_hash) {
58644 + if ((name_set.n_size * sizeof (struct name_entry *)) <=
58645 + PAGE_SIZE)
58646 + kfree(name_set.n_hash);
58647 + else
58648 + vfree(name_set.n_hash);
58649 + }
58650 +
58651 + if (inodev_set.i_hash) {
58652 + if ((inodev_set.i_size * sizeof (struct inodev_entry *)) <=
58653 + PAGE_SIZE)
58654 + kfree(inodev_set.i_hash);
58655 + else
58656 + vfree(inodev_set.i_hash);
58657 + }
58658 +
58659 + gr_free_uidset();
58660 +
58661 + memset(&name_set, 0, sizeof (struct name_db));
58662 + memset(&inodev_set, 0, sizeof (struct inodev_db));
58663 + memset(&acl_role_set, 0, sizeof (struct acl_role_db));
58664 + memset(&subj_map_set, 0, sizeof (struct acl_subj_map_db));
58665 +
58666 + default_role = NULL;
58667 + kernel_role = NULL;
58668 + role_list = NULL;
58669 +
58670 + return;
58671 +}
58672 +
58673 +static __u32
58674 +count_user_objs(struct acl_object_label *userp)
58675 +{
58676 + struct acl_object_label o_tmp;
58677 + __u32 num = 0;
58678 +
58679 + while (userp) {
58680 + if (copy_from_user(&o_tmp, userp,
58681 + sizeof (struct acl_object_label)))
58682 + break;
58683 +
58684 + userp = o_tmp.prev;
58685 + num++;
58686 + }
58687 +
58688 + return num;
58689 +}
58690 +
58691 +static struct acl_subject_label *
58692 +do_copy_user_subj(struct acl_subject_label *userp, struct acl_role_label *role, int *already_copied);
58693 +
58694 +static int
58695 +copy_user_glob(struct acl_object_label *obj)
58696 +{
58697 + struct acl_object_label *g_tmp, **guser;
58698 + unsigned int len;
58699 + char *tmp;
58700 +
58701 + if (obj->globbed == NULL)
58702 + return 0;
58703 +
58704 + guser = &obj->globbed;
58705 + while (*guser) {
58706 + g_tmp = (struct acl_object_label *)
58707 + acl_alloc(sizeof (struct acl_object_label));
58708 + if (g_tmp == NULL)
58709 + return -ENOMEM;
58710 +
58711 + if (copy_from_user(g_tmp, *guser,
58712 + sizeof (struct acl_object_label)))
58713 + return -EFAULT;
58714 +
58715 + len = strnlen_user(g_tmp->filename, PATH_MAX);
58716 +
58717 + if (!len || len >= PATH_MAX)
58718 + return -EINVAL;
58719 +
58720 + if ((tmp = (char *) acl_alloc(len)) == NULL)
58721 + return -ENOMEM;
58722 +
58723 + if (copy_from_user(tmp, g_tmp->filename, len))
58724 + return -EFAULT;
58725 + tmp[len-1] = '\0';
58726 + g_tmp->filename = tmp;
58727 +
58728 + *guser = g_tmp;
58729 + guser = &(g_tmp->next);
58730 + }
58731 +
58732 + return 0;
58733 +}
58734 +
58735 +static int
58736 +copy_user_objs(struct acl_object_label *userp, struct acl_subject_label *subj,
58737 + struct acl_role_label *role)
58738 +{
58739 + struct acl_object_label *o_tmp;
58740 + unsigned int len;
58741 + int ret;
58742 + char *tmp;
58743 +
58744 + while (userp) {
58745 + if ((o_tmp = (struct acl_object_label *)
58746 + acl_alloc(sizeof (struct acl_object_label))) == NULL)
58747 + return -ENOMEM;
58748 +
58749 + if (copy_from_user(o_tmp, userp,
58750 + sizeof (struct acl_object_label)))
58751 + return -EFAULT;
58752 +
58753 + userp = o_tmp->prev;
58754 +
58755 + len = strnlen_user(o_tmp->filename, PATH_MAX);
58756 +
58757 + if (!len || len >= PATH_MAX)
58758 + return -EINVAL;
58759 +
58760 + if ((tmp = (char *) acl_alloc(len)) == NULL)
58761 + return -ENOMEM;
58762 +
58763 + if (copy_from_user(tmp, o_tmp->filename, len))
58764 + return -EFAULT;
58765 + tmp[len-1] = '\0';
58766 + o_tmp->filename = tmp;
58767 +
58768 + insert_acl_obj_label(o_tmp, subj);
58769 + if (!insert_name_entry(o_tmp->filename, o_tmp->inode,
58770 + o_tmp->device, (o_tmp->mode & GR_DELETED) ? 1 : 0))
58771 + return -ENOMEM;
58772 +
58773 + ret = copy_user_glob(o_tmp);
58774 + if (ret)
58775 + return ret;
58776 +
58777 + if (o_tmp->nested) {
58778 + int already_copied;
58779 +
58780 + o_tmp->nested = do_copy_user_subj(o_tmp->nested, role, &already_copied);
58781 + if (IS_ERR(o_tmp->nested))
58782 + return PTR_ERR(o_tmp->nested);
58783 +
58784 + /* insert into nested subject list if we haven't copied this one yet
58785 + to prevent duplicate entries */
58786 + if (!already_copied) {
58787 + o_tmp->nested->next = role->hash->first;
58788 + role->hash->first = o_tmp->nested;
58789 + }
58790 + }
58791 + }
58792 +
58793 + return 0;
58794 +}
58795 +
58796 +static __u32
58797 +count_user_subjs(struct acl_subject_label *userp)
58798 +{
58799 + struct acl_subject_label s_tmp;
58800 + __u32 num = 0;
58801 +
58802 + while (userp) {
58803 + if (copy_from_user(&s_tmp, userp,
58804 + sizeof (struct acl_subject_label)))
58805 + break;
58806 +
58807 + userp = s_tmp.prev;
58808 + }
58809 +
58810 + return num;
58811 +}
58812 +
58813 +static int
58814 +copy_user_allowedips(struct acl_role_label *rolep)
58815 +{
58816 + struct role_allowed_ip *ruserip, *rtmp = NULL, *rlast;
58817 +
58818 + ruserip = rolep->allowed_ips;
58819 +
58820 + while (ruserip) {
58821 + rlast = rtmp;
58822 +
58823 + if ((rtmp = (struct role_allowed_ip *)
58824 + acl_alloc(sizeof (struct role_allowed_ip))) == NULL)
58825 + return -ENOMEM;
58826 +
58827 + if (copy_from_user(rtmp, ruserip,
58828 + sizeof (struct role_allowed_ip)))
58829 + return -EFAULT;
58830 +
58831 + ruserip = rtmp->prev;
58832 +
58833 + if (!rlast) {
58834 + rtmp->prev = NULL;
58835 + rolep->allowed_ips = rtmp;
58836 + } else {
58837 + rlast->next = rtmp;
58838 + rtmp->prev = rlast;
58839 + }
58840 +
58841 + if (!ruserip)
58842 + rtmp->next = NULL;
58843 + }
58844 +
58845 + return 0;
58846 +}
58847 +
58848 +static int
58849 +copy_user_transitions(struct acl_role_label *rolep)
58850 +{
58851 + struct role_transition *rusertp, *rtmp = NULL, *rlast;
58852 +
58853 + unsigned int len;
58854 + char *tmp;
58855 +
58856 + rusertp = rolep->transitions;
58857 +
58858 + while (rusertp) {
58859 + rlast = rtmp;
58860 +
58861 + if ((rtmp = (struct role_transition *)
58862 + acl_alloc(sizeof (struct role_transition))) == NULL)
58863 + return -ENOMEM;
58864 +
58865 + if (copy_from_user(rtmp, rusertp,
58866 + sizeof (struct role_transition)))
58867 + return -EFAULT;
58868 +
58869 + rusertp = rtmp->prev;
58870 +
58871 + len = strnlen_user(rtmp->rolename, GR_SPROLE_LEN);
58872 +
58873 + if (!len || len >= GR_SPROLE_LEN)
58874 + return -EINVAL;
58875 +
58876 + if ((tmp = (char *) acl_alloc(len)) == NULL)
58877 + return -ENOMEM;
58878 +
58879 + if (copy_from_user(tmp, rtmp->rolename, len))
58880 + return -EFAULT;
58881 + tmp[len-1] = '\0';
58882 + rtmp->rolename = tmp;
58883 +
58884 + if (!rlast) {
58885 + rtmp->prev = NULL;
58886 + rolep->transitions = rtmp;
58887 + } else {
58888 + rlast->next = rtmp;
58889 + rtmp->prev = rlast;
58890 + }
58891 +
58892 + if (!rusertp)
58893 + rtmp->next = NULL;
58894 + }
58895 +
58896 + return 0;
58897 +}
58898 +
58899 +static struct acl_subject_label *
58900 +do_copy_user_subj(struct acl_subject_label *userp, struct acl_role_label *role, int *already_copied)
58901 +{
58902 + struct acl_subject_label *s_tmp = NULL, *s_tmp2;
58903 + unsigned int len;
58904 + char *tmp;
58905 + __u32 num_objs;
58906 + struct acl_ip_label **i_tmp, *i_utmp2;
58907 + struct gr_hash_struct ghash;
58908 + struct subject_map *subjmap;
58909 + unsigned int i_num;
58910 + int err;
58911 +
58912 + if (already_copied != NULL)
58913 + *already_copied = 0;
58914 +
58915 + s_tmp = lookup_subject_map(userp);
58916 +
58917 + /* we've already copied this subject into the kernel, just return
58918 + the reference to it, and don't copy it over again
58919 + */
58920 + if (s_tmp) {
58921 + if (already_copied != NULL)
58922 + *already_copied = 1;
58923 + return(s_tmp);
58924 + }
58925 +
58926 + if ((s_tmp = (struct acl_subject_label *)
58927 + acl_alloc(sizeof (struct acl_subject_label))) == NULL)
58928 + return ERR_PTR(-ENOMEM);
58929 +
58930 + subjmap = (struct subject_map *)kmalloc(sizeof (struct subject_map), GFP_KERNEL);
58931 + if (subjmap == NULL)
58932 + return ERR_PTR(-ENOMEM);
58933 +
58934 + subjmap->user = userp;
58935 + subjmap->kernel = s_tmp;
58936 + insert_subj_map_entry(subjmap);
58937 +
58938 + if (copy_from_user(s_tmp, userp,
58939 + sizeof (struct acl_subject_label)))
58940 + return ERR_PTR(-EFAULT);
58941 +
58942 + len = strnlen_user(s_tmp->filename, PATH_MAX);
58943 +
58944 + if (!len || len >= PATH_MAX)
58945 + return ERR_PTR(-EINVAL);
58946 +
58947 + if ((tmp = (char *) acl_alloc(len)) == NULL)
58948 + return ERR_PTR(-ENOMEM);
58949 +
58950 + if (copy_from_user(tmp, s_tmp->filename, len))
58951 + return ERR_PTR(-EFAULT);
58952 + tmp[len-1] = '\0';
58953 + s_tmp->filename = tmp;
58954 +
58955 + if (!strcmp(s_tmp->filename, "/"))
58956 + role->root_label = s_tmp;
58957 +
58958 + if (copy_from_user(&ghash, s_tmp->hash, sizeof(struct gr_hash_struct)))
58959 + return ERR_PTR(-EFAULT);
58960 +
58961 + /* copy user and group transition tables */
58962 +
58963 + if (s_tmp->user_trans_num) {
58964 + uid_t *uidlist;
58965 +
58966 + uidlist = (uid_t *)acl_alloc_num(s_tmp->user_trans_num, sizeof(uid_t));
58967 + if (uidlist == NULL)
58968 + return ERR_PTR(-ENOMEM);
58969 + if (copy_from_user(uidlist, s_tmp->user_transitions, s_tmp->user_trans_num * sizeof(uid_t)))
58970 + return ERR_PTR(-EFAULT);
58971 +
58972 + s_tmp->user_transitions = uidlist;
58973 + }
58974 +
58975 + if (s_tmp->group_trans_num) {
58976 + gid_t *gidlist;
58977 +
58978 + gidlist = (gid_t *)acl_alloc_num(s_tmp->group_trans_num, sizeof(gid_t));
58979 + if (gidlist == NULL)
58980 + return ERR_PTR(-ENOMEM);
58981 + if (copy_from_user(gidlist, s_tmp->group_transitions, s_tmp->group_trans_num * sizeof(gid_t)))
58982 + return ERR_PTR(-EFAULT);
58983 +
58984 + s_tmp->group_transitions = gidlist;
58985 + }
58986 +
58987 + /* set up object hash table */
58988 + num_objs = count_user_objs(ghash.first);
58989 +
58990 + s_tmp->obj_hash_size = num_objs;
58991 + s_tmp->obj_hash =
58992 + (struct acl_object_label **)
58993 + create_table(&(s_tmp->obj_hash_size), sizeof(void *));
58994 +
58995 + if (!s_tmp->obj_hash)
58996 + return ERR_PTR(-ENOMEM);
58997 +
58998 + memset(s_tmp->obj_hash, 0,
58999 + s_tmp->obj_hash_size *
59000 + sizeof (struct acl_object_label *));
59001 +
59002 + /* add in objects */
59003 + err = copy_user_objs(ghash.first, s_tmp, role);
59004 +
59005 + if (err)
59006 + return ERR_PTR(err);
59007 +
59008 + /* set pointer for parent subject */
59009 + if (s_tmp->parent_subject) {
59010 + s_tmp2 = do_copy_user_subj(s_tmp->parent_subject, role, NULL);
59011 +
59012 + if (IS_ERR(s_tmp2))
59013 + return s_tmp2;
59014 +
59015 + s_tmp->parent_subject = s_tmp2;
59016 + }
59017 +
59018 + /* add in ip acls */
59019 +
59020 + if (!s_tmp->ip_num) {
59021 + s_tmp->ips = NULL;
59022 + goto insert;
59023 + }
59024 +
59025 + i_tmp =
59026 + (struct acl_ip_label **) acl_alloc_num(s_tmp->ip_num,
59027 + sizeof (struct acl_ip_label *));
59028 +
59029 + if (!i_tmp)
59030 + return ERR_PTR(-ENOMEM);
59031 +
59032 + for (i_num = 0; i_num < s_tmp->ip_num; i_num++) {
59033 + *(i_tmp + i_num) =
59034 + (struct acl_ip_label *)
59035 + acl_alloc(sizeof (struct acl_ip_label));
59036 + if (!*(i_tmp + i_num))
59037 + return ERR_PTR(-ENOMEM);
59038 +
59039 + if (copy_from_user
59040 + (&i_utmp2, s_tmp->ips + i_num,
59041 + sizeof (struct acl_ip_label *)))
59042 + return ERR_PTR(-EFAULT);
59043 +
59044 + if (copy_from_user
59045 + (*(i_tmp + i_num), i_utmp2,
59046 + sizeof (struct acl_ip_label)))
59047 + return ERR_PTR(-EFAULT);
59048 +
59049 + if ((*(i_tmp + i_num))->iface == NULL)
59050 + continue;
59051 +
59052 + len = strnlen_user((*(i_tmp + i_num))->iface, IFNAMSIZ);
59053 + if (!len || len >= IFNAMSIZ)
59054 + return ERR_PTR(-EINVAL);
59055 + tmp = acl_alloc(len);
59056 + if (tmp == NULL)
59057 + return ERR_PTR(-ENOMEM);
59058 + if (copy_from_user(tmp, (*(i_tmp + i_num))->iface, len))
59059 + return ERR_PTR(-EFAULT);
59060 + (*(i_tmp + i_num))->iface = tmp;
59061 + }
59062 +
59063 + s_tmp->ips = i_tmp;
59064 +
59065 +insert:
59066 + if (!insert_name_entry(s_tmp->filename, s_tmp->inode,
59067 + s_tmp->device, (s_tmp->mode & GR_DELETED) ? 1 : 0))
59068 + return ERR_PTR(-ENOMEM);
59069 +
59070 + return s_tmp;
59071 +}
59072 +
59073 +static int
59074 +copy_user_subjs(struct acl_subject_label *userp, struct acl_role_label *role)
59075 +{
59076 + struct acl_subject_label s_pre;
59077 + struct acl_subject_label * ret;
59078 + int err;
59079 +
59080 + while (userp) {
59081 + if (copy_from_user(&s_pre, userp,
59082 + sizeof (struct acl_subject_label)))
59083 + return -EFAULT;
59084 +
59085 + ret = do_copy_user_subj(userp, role, NULL);
59086 +
59087 + err = PTR_ERR(ret);
59088 + if (IS_ERR(ret))
59089 + return err;
59090 +
59091 + insert_acl_subj_label(ret, role);
59092 +
59093 + userp = s_pre.prev;
59094 + }
59095 +
59096 + return 0;
59097 +}
59098 +
59099 +static int
59100 +copy_user_acl(struct gr_arg *arg)
59101 +{
59102 + struct acl_role_label *r_tmp = NULL, **r_utmp, *r_utmp2;
59103 + struct acl_subject_label *subj_list;
59104 + struct sprole_pw *sptmp;
59105 + struct gr_hash_struct *ghash;
59106 + uid_t *domainlist;
59107 + unsigned int r_num;
59108 + unsigned int len;
59109 + char *tmp;
59110 + int err = 0;
59111 + __u16 i;
59112 + __u32 num_subjs;
59113 +
59114 + /* we need a default and kernel role */
59115 + if (arg->role_db.num_roles < 2)
59116 + return -EINVAL;
59117 +
59118 + /* copy special role authentication info from userspace */
59119 +
59120 + num_sprole_pws = arg->num_sprole_pws;
59121 + acl_special_roles = (struct sprole_pw **) acl_alloc_num(num_sprole_pws, sizeof(struct sprole_pw *));
59122 +
59123 + if (!acl_special_roles && num_sprole_pws)
59124 + return -ENOMEM;
59125 +
59126 + for (i = 0; i < num_sprole_pws; i++) {
59127 + sptmp = (struct sprole_pw *) acl_alloc(sizeof(struct sprole_pw));
59128 + if (!sptmp)
59129 + return -ENOMEM;
59130 + if (copy_from_user(sptmp, arg->sprole_pws + i,
59131 + sizeof (struct sprole_pw)))
59132 + return -EFAULT;
59133 +
59134 + len = strnlen_user(sptmp->rolename, GR_SPROLE_LEN);
59135 +
59136 + if (!len || len >= GR_SPROLE_LEN)
59137 + return -EINVAL;
59138 +
59139 + if ((tmp = (char *) acl_alloc(len)) == NULL)
59140 + return -ENOMEM;
59141 +
59142 + if (copy_from_user(tmp, sptmp->rolename, len))
59143 + return -EFAULT;
59144 +
59145 + tmp[len-1] = '\0';
59146 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
59147 + printk(KERN_ALERT "Copying special role %s\n", tmp);
59148 +#endif
59149 + sptmp->rolename = tmp;
59150 + acl_special_roles[i] = sptmp;
59151 + }
59152 +
59153 + r_utmp = (struct acl_role_label **) arg->role_db.r_table;
59154 +
59155 + for (r_num = 0; r_num < arg->role_db.num_roles; r_num++) {
59156 + r_tmp = acl_alloc(sizeof (struct acl_role_label));
59157 +
59158 + if (!r_tmp)
59159 + return -ENOMEM;
59160 +
59161 + if (copy_from_user(&r_utmp2, r_utmp + r_num,
59162 + sizeof (struct acl_role_label *)))
59163 + return -EFAULT;
59164 +
59165 + if (copy_from_user(r_tmp, r_utmp2,
59166 + sizeof (struct acl_role_label)))
59167 + return -EFAULT;
59168 +
59169 + len = strnlen_user(r_tmp->rolename, GR_SPROLE_LEN);
59170 +
59171 + if (!len || len >= PATH_MAX)
59172 + return -EINVAL;
59173 +
59174 + if ((tmp = (char *) acl_alloc(len)) == NULL)
59175 + return -ENOMEM;
59176 +
59177 + if (copy_from_user(tmp, r_tmp->rolename, len))
59178 + return -EFAULT;
59179 +
59180 + tmp[len-1] = '\0';
59181 + r_tmp->rolename = tmp;
59182 +
59183 + if (!strcmp(r_tmp->rolename, "default")
59184 + && (r_tmp->roletype & GR_ROLE_DEFAULT)) {
59185 + default_role = r_tmp;
59186 + } else if (!strcmp(r_tmp->rolename, ":::kernel:::")) {
59187 + kernel_role = r_tmp;
59188 + }
59189 +
59190 + if ((ghash = (struct gr_hash_struct *) acl_alloc(sizeof(struct gr_hash_struct))) == NULL)
59191 + return -ENOMEM;
59192 +
59193 + if (copy_from_user(ghash, r_tmp->hash, sizeof(struct gr_hash_struct)))
59194 + return -EFAULT;
59195 +
59196 + r_tmp->hash = ghash;
59197 +
59198 + num_subjs = count_user_subjs(r_tmp->hash->first);
59199 +
59200 + r_tmp->subj_hash_size = num_subjs;
59201 + r_tmp->subj_hash =
59202 + (struct acl_subject_label **)
59203 + create_table(&(r_tmp->subj_hash_size), sizeof(void *));
59204 +
59205 + if (!r_tmp->subj_hash)
59206 + return -ENOMEM;
59207 +
59208 + err = copy_user_allowedips(r_tmp);
59209 + if (err)
59210 + return err;
59211 +
59212 + /* copy domain info */
59213 + if (r_tmp->domain_children != NULL) {
59214 + domainlist = acl_alloc_num(r_tmp->domain_child_num, sizeof(uid_t));
59215 + if (domainlist == NULL)
59216 + return -ENOMEM;
59217 +
59218 + if (copy_from_user(domainlist, r_tmp->domain_children, r_tmp->domain_child_num * sizeof(uid_t)))
59219 + return -EFAULT;
59220 +
59221 + r_tmp->domain_children = domainlist;
59222 + }
59223 +
59224 + err = copy_user_transitions(r_tmp);
59225 + if (err)
59226 + return err;
59227 +
59228 + memset(r_tmp->subj_hash, 0,
59229 + r_tmp->subj_hash_size *
59230 + sizeof (struct acl_subject_label *));
59231 +
59232 + /* acquire the list of subjects, then NULL out
59233 + the list prior to parsing the subjects for this role,
59234 + as during this parsing the list is replaced with a list
59235 + of *nested* subjects for the role
59236 + */
59237 + subj_list = r_tmp->hash->first;
59238 +
59239 + /* set nested subject list to null */
59240 + r_tmp->hash->first = NULL;
59241 +
59242 + err = copy_user_subjs(subj_list, r_tmp);
59243 +
59244 + if (err)
59245 + return err;
59246 +
59247 + insert_acl_role_label(r_tmp);
59248 + }
59249 +
59250 + if (default_role == NULL || kernel_role == NULL)
59251 + return -EINVAL;
59252 +
59253 + return err;
59254 +}
59255 +
59256 +static int
59257 +gracl_init(struct gr_arg *args)
59258 +{
59259 + int error = 0;
59260 +
59261 + memcpy(gr_system_salt, args->salt, GR_SALT_LEN);
59262 + memcpy(gr_system_sum, args->sum, GR_SHA_LEN);
59263 +
59264 + if (init_variables(args)) {
59265 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_INITF_ACL_MSG, GR_VERSION);
59266 + error = -ENOMEM;
59267 + free_variables();
59268 + goto out;
59269 + }
59270 +
59271 + error = copy_user_acl(args);
59272 + free_init_variables();
59273 + if (error) {
59274 + free_variables();
59275 + goto out;
59276 + }
59277 +
59278 + if ((error = gr_set_acls(0))) {
59279 + free_variables();
59280 + goto out;
59281 + }
59282 +
59283 + pax_open_kernel();
59284 + gr_status |= GR_READY;
59285 + pax_close_kernel();
59286 +
59287 + out:
59288 + return error;
59289 +}
59290 +
59291 +/* derived from glibc fnmatch() 0: match, 1: no match*/
59292 +
59293 +static int
59294 +glob_match(const char *p, const char *n)
59295 +{
59296 + char c;
59297 +
59298 + while ((c = *p++) != '\0') {
59299 + switch (c) {
59300 + case '?':
59301 + if (*n == '\0')
59302 + return 1;
59303 + else if (*n == '/')
59304 + return 1;
59305 + break;
59306 + case '\\':
59307 + if (*n != c)
59308 + return 1;
59309 + break;
59310 + case '*':
59311 + for (c = *p++; c == '?' || c == '*'; c = *p++) {
59312 + if (*n == '/')
59313 + return 1;
59314 + else if (c == '?') {
59315 + if (*n == '\0')
59316 + return 1;
59317 + else
59318 + ++n;
59319 + }
59320 + }
59321 + if (c == '\0') {
59322 + return 0;
59323 + } else {
59324 + const char *endp;
59325 +
59326 + if ((endp = strchr(n, '/')) == NULL)
59327 + endp = n + strlen(n);
59328 +
59329 + if (c == '[') {
59330 + for (--p; n < endp; ++n)
59331 + if (!glob_match(p, n))
59332 + return 0;
59333 + } else if (c == '/') {
59334 + while (*n != '\0' && *n != '/')
59335 + ++n;
59336 + if (*n == '/' && !glob_match(p, n + 1))
59337 + return 0;
59338 + } else {
59339 + for (--p; n < endp; ++n)
59340 + if (*n == c && !glob_match(p, n))
59341 + return 0;
59342 + }
59343 +
59344 + return 1;
59345 + }
59346 + case '[':
59347 + {
59348 + int not;
59349 + char cold;
59350 +
59351 + if (*n == '\0' || *n == '/')
59352 + return 1;
59353 +
59354 + not = (*p == '!' || *p == '^');
59355 + if (not)
59356 + ++p;
59357 +
59358 + c = *p++;
59359 + for (;;) {
59360 + unsigned char fn = (unsigned char)*n;
59361 +
59362 + if (c == '\0')
59363 + return 1;
59364 + else {
59365 + if (c == fn)
59366 + goto matched;
59367 + cold = c;
59368 + c = *p++;
59369 +
59370 + if (c == '-' && *p != ']') {
59371 + unsigned char cend = *p++;
59372 +
59373 + if (cend == '\0')
59374 + return 1;
59375 +
59376 + if (cold <= fn && fn <= cend)
59377 + goto matched;
59378 +
59379 + c = *p++;
59380 + }
59381 + }
59382 +
59383 + if (c == ']')
59384 + break;
59385 + }
59386 + if (!not)
59387 + return 1;
59388 + break;
59389 + matched:
59390 + while (c != ']') {
59391 + if (c == '\0')
59392 + return 1;
59393 +
59394 + c = *p++;
59395 + }
59396 + if (not)
59397 + return 1;
59398 + }
59399 + break;
59400 + default:
59401 + if (c != *n)
59402 + return 1;
59403 + }
59404 +
59405 + ++n;
59406 + }
59407 +
59408 + if (*n == '\0')
59409 + return 0;
59410 +
59411 + if (*n == '/')
59412 + return 0;
59413 +
59414 + return 1;
59415 +}
59416 +
59417 +static struct acl_object_label *
59418 +chk_glob_label(struct acl_object_label *globbed,
59419 + const struct dentry *dentry, const struct vfsmount *mnt, char **path)
59420 +{
59421 + struct acl_object_label *tmp;
59422 +
59423 + if (*path == NULL)
59424 + *path = gr_to_filename_nolock(dentry, mnt);
59425 +
59426 + tmp = globbed;
59427 +
59428 + while (tmp) {
59429 + if (!glob_match(tmp->filename, *path))
59430 + return tmp;
59431 + tmp = tmp->next;
59432 + }
59433 +
59434 + return NULL;
59435 +}
59436 +
59437 +static struct acl_object_label *
59438 +__full_lookup(const struct dentry *orig_dentry, const struct vfsmount *orig_mnt,
59439 + const ino_t curr_ino, const dev_t curr_dev,
59440 + const struct acl_subject_label *subj, char **path, const int checkglob)
59441 +{
59442 + struct acl_subject_label *tmpsubj;
59443 + struct acl_object_label *retval;
59444 + struct acl_object_label *retval2;
59445 +
59446 + tmpsubj = (struct acl_subject_label *) subj;
59447 + read_lock(&gr_inode_lock);
59448 + do {
59449 + retval = lookup_acl_obj_label(curr_ino, curr_dev, tmpsubj);
59450 + if (retval) {
59451 + if (checkglob && retval->globbed) {
59452 + retval2 = chk_glob_label(retval->globbed, orig_dentry, orig_mnt, path);
59453 + if (retval2)
59454 + retval = retval2;
59455 + }
59456 + break;
59457 + }
59458 + } while ((tmpsubj = tmpsubj->parent_subject));
59459 + read_unlock(&gr_inode_lock);
59460 +
59461 + return retval;
59462 +}
59463 +
59464 +static __inline__ struct acl_object_label *
59465 +full_lookup(const struct dentry *orig_dentry, const struct vfsmount *orig_mnt,
59466 + struct dentry *curr_dentry,
59467 + const struct acl_subject_label *subj, char **path, const int checkglob)
59468 +{
59469 + int newglob = checkglob;
59470 + ino_t inode;
59471 + dev_t device;
59472 +
59473 + /* if we aren't checking a subdirectory of the original path yet, don't do glob checking
59474 + as we don't want a / * rule to match instead of the / object
59475 + don't do this for create lookups that call this function though, since they're looking up
59476 + on the parent and thus need globbing checks on all paths
59477 + */
59478 + if (orig_dentry == curr_dentry && newglob != GR_CREATE_GLOB)
59479 + newglob = GR_NO_GLOB;
59480 +
59481 + spin_lock(&curr_dentry->d_lock);
59482 + inode = curr_dentry->d_inode->i_ino;
59483 + device = __get_dev(curr_dentry);
59484 + spin_unlock(&curr_dentry->d_lock);
59485 +
59486 + return __full_lookup(orig_dentry, orig_mnt, inode, device, subj, path, newglob);
59487 +}
59488 +
59489 +#ifdef CONFIG_HUGETLBFS
59490 +static inline bool
59491 +is_hugetlbfs_mnt(const struct vfsmount *mnt)
59492 +{
59493 + int i;
59494 + for (i = 0; i < HUGE_MAX_HSTATE; i++) {
59495 + if (unlikely(hugetlbfs_vfsmount[i] == mnt))
59496 + return true;
59497 + }
59498 +
59499 + return false;
59500 +}
59501 +#endif
59502 +
59503 +static struct acl_object_label *
59504 +__chk_obj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
59505 + const struct acl_subject_label *subj, char *path, const int checkglob)
59506 +{
59507 + struct dentry *dentry = (struct dentry *) l_dentry;
59508 + struct vfsmount *mnt = (struct vfsmount *) l_mnt;
59509 + struct mount *real_mnt = real_mount(mnt);
59510 + struct acl_object_label *retval;
59511 + struct dentry *parent;
59512 +
59513 + br_read_lock(&vfsmount_lock);
59514 + write_seqlock(&rename_lock);
59515 +
59516 + if (unlikely((mnt == shm_mnt && dentry->d_inode->i_nlink == 0) || mnt == pipe_mnt ||
59517 +#ifdef CONFIG_NET
59518 + mnt == sock_mnt ||
59519 +#endif
59520 +#ifdef CONFIG_HUGETLBFS
59521 + (is_hugetlbfs_mnt(mnt) && dentry->d_inode->i_nlink == 0) ||
59522 +#endif
59523 + /* ignore Eric Biederman */
59524 + IS_PRIVATE(l_dentry->d_inode))) {
59525 + retval = (subj->mode & GR_SHMEXEC) ? fakefs_obj_rwx : fakefs_obj_rw;
59526 + goto out;
59527 + }
59528 +
59529 + for (;;) {
59530 + if (dentry == real_root.dentry && mnt == real_root.mnt)
59531 + break;
59532 +
59533 + if (dentry == mnt->mnt_root || IS_ROOT(dentry)) {
59534 + if (!mnt_has_parent(real_mnt))
59535 + break;
59536 +
59537 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
59538 + if (retval != NULL)
59539 + goto out;
59540 +
59541 + dentry = real_mnt->mnt_mountpoint;
59542 + real_mnt = real_mnt->mnt_parent;
59543 + mnt = &real_mnt->mnt;
59544 + continue;
59545 + }
59546 +
59547 + parent = dentry->d_parent;
59548 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
59549 + if (retval != NULL)
59550 + goto out;
59551 +
59552 + dentry = parent;
59553 + }
59554 +
59555 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
59556 +
59557 + /* real_root is pinned so we don't have to hold a reference */
59558 + if (retval == NULL)
59559 + retval = full_lookup(l_dentry, l_mnt, real_root.dentry, subj, &path, checkglob);
59560 +out:
59561 + write_sequnlock(&rename_lock);
59562 + br_read_unlock(&vfsmount_lock);
59563 +
59564 + BUG_ON(retval == NULL);
59565 +
59566 + return retval;
59567 +}
59568 +
59569 +static __inline__ struct acl_object_label *
59570 +chk_obj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
59571 + const struct acl_subject_label *subj)
59572 +{
59573 + char *path = NULL;
59574 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_REG_GLOB);
59575 +}
59576 +
59577 +static __inline__ struct acl_object_label *
59578 +chk_obj_label_noglob(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
59579 + const struct acl_subject_label *subj)
59580 +{
59581 + char *path = NULL;
59582 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_NO_GLOB);
59583 +}
59584 +
59585 +static __inline__ struct acl_object_label *
59586 +chk_obj_create_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
59587 + const struct acl_subject_label *subj, char *path)
59588 +{
59589 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_CREATE_GLOB);
59590 +}
59591 +
59592 +static struct acl_subject_label *
59593 +chk_subj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
59594 + const struct acl_role_label *role)
59595 +{
59596 + struct dentry *dentry = (struct dentry *) l_dentry;
59597 + struct vfsmount *mnt = (struct vfsmount *) l_mnt;
59598 + struct mount *real_mnt = real_mount(mnt);
59599 + struct acl_subject_label *retval;
59600 + struct dentry *parent;
59601 +
59602 + br_read_lock(&vfsmount_lock);
59603 + write_seqlock(&rename_lock);
59604 +
59605 + for (;;) {
59606 + if (dentry == real_root.dentry && mnt == real_root.mnt)
59607 + break;
59608 + if (dentry == mnt->mnt_root || IS_ROOT(dentry)) {
59609 + if (!mnt_has_parent(real_mnt))
59610 + break;
59611 +
59612 + spin_lock(&dentry->d_lock);
59613 + read_lock(&gr_inode_lock);
59614 + retval =
59615 + lookup_acl_subj_label(dentry->d_inode->i_ino,
59616 + __get_dev(dentry), role);
59617 + read_unlock(&gr_inode_lock);
59618 + spin_unlock(&dentry->d_lock);
59619 + if (retval != NULL)
59620 + goto out;
59621 +
59622 + dentry = real_mnt->mnt_mountpoint;
59623 + real_mnt = real_mnt->mnt_parent;
59624 + mnt = &real_mnt->mnt;
59625 + continue;
59626 + }
59627 +
59628 + spin_lock(&dentry->d_lock);
59629 + read_lock(&gr_inode_lock);
59630 + retval = lookup_acl_subj_label(dentry->d_inode->i_ino,
59631 + __get_dev(dentry), role);
59632 + read_unlock(&gr_inode_lock);
59633 + parent = dentry->d_parent;
59634 + spin_unlock(&dentry->d_lock);
59635 +
59636 + if (retval != NULL)
59637 + goto out;
59638 +
59639 + dentry = parent;
59640 + }
59641 +
59642 + spin_lock(&dentry->d_lock);
59643 + read_lock(&gr_inode_lock);
59644 + retval = lookup_acl_subj_label(dentry->d_inode->i_ino,
59645 + __get_dev(dentry), role);
59646 + read_unlock(&gr_inode_lock);
59647 + spin_unlock(&dentry->d_lock);
59648 +
59649 + if (unlikely(retval == NULL)) {
59650 + /* real_root is pinned, we don't need to hold a reference */
59651 + read_lock(&gr_inode_lock);
59652 + retval = lookup_acl_subj_label(real_root.dentry->d_inode->i_ino,
59653 + __get_dev(real_root.dentry), role);
59654 + read_unlock(&gr_inode_lock);
59655 + }
59656 +out:
59657 + write_sequnlock(&rename_lock);
59658 + br_read_unlock(&vfsmount_lock);
59659 +
59660 + BUG_ON(retval == NULL);
59661 +
59662 + return retval;
59663 +}
59664 +
59665 +static void
59666 +gr_log_learn(const struct dentry *dentry, const struct vfsmount *mnt, const __u32 mode)
59667 +{
59668 + struct task_struct *task = current;
59669 + const struct cred *cred = current_cred();
59670 +
59671 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename, task->role->roletype,
59672 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
59673 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
59674 + 1UL, 1UL, gr_to_filename(dentry, mnt), (unsigned long) mode, &task->signal->saved_ip);
59675 +
59676 + return;
59677 +}
59678 +
59679 +static void
59680 +gr_log_learn_uid_change(const kuid_t real, const kuid_t effective, const kuid_t fs)
59681 +{
59682 + struct task_struct *task = current;
59683 + const struct cred *cred = current_cred();
59684 +
59685 + security_learn(GR_ID_LEARN_MSG, task->role->rolename, task->role->roletype,
59686 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
59687 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
59688 + 'u', GR_GLOBAL_UID(real), GR_GLOBAL_UID(effective), GR_GLOBAL_UID(fs), &task->signal->saved_ip);
59689 +
59690 + return;
59691 +}
59692 +
59693 +static void
59694 +gr_log_learn_gid_change(const kgid_t real, const kgid_t effective, const kgid_t fs)
59695 +{
59696 + struct task_struct *task = current;
59697 + const struct cred *cred = current_cred();
59698 +
59699 + security_learn(GR_ID_LEARN_MSG, task->role->rolename, task->role->roletype,
59700 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
59701 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
59702 + 'g', GR_GLOBAL_GID(real), GR_GLOBAL_GID(effective), GR_GLOBAL_GID(fs), &task->signal->saved_ip);
59703 +
59704 + return;
59705 +}
59706 +
59707 +__u32
59708 +gr_search_file(const struct dentry * dentry, const __u32 mode,
59709 + const struct vfsmount * mnt)
59710 +{
59711 + __u32 retval = mode;
59712 + struct acl_subject_label *curracl;
59713 + struct acl_object_label *currobj;
59714 +
59715 + if (unlikely(!(gr_status & GR_READY)))
59716 + return (mode & ~GR_AUDITS);
59717 +
59718 + curracl = current->acl;
59719 +
59720 + currobj = chk_obj_label(dentry, mnt, curracl);
59721 + retval = currobj->mode & mode;
59722 +
59723 + /* if we're opening a specified transfer file for writing
59724 + (e.g. /dev/initctl), then transfer our role to init
59725 + */
59726 + if (unlikely(currobj->mode & GR_INIT_TRANSFER && retval & GR_WRITE &&
59727 + current->role->roletype & GR_ROLE_PERSIST)) {
59728 + struct task_struct *task = init_pid_ns.child_reaper;
59729 +
59730 + if (task->role != current->role) {
59731 + task->acl_sp_role = 0;
59732 + task->acl_role_id = current->acl_role_id;
59733 + task->role = current->role;
59734 + rcu_read_lock();
59735 + read_lock(&grsec_exec_file_lock);
59736 + gr_apply_subject_to_task(task);
59737 + read_unlock(&grsec_exec_file_lock);
59738 + rcu_read_unlock();
59739 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_INIT_TRANSFER_MSG);
59740 + }
59741 + }
59742 +
59743 + if (unlikely
59744 + ((curracl->mode & (GR_LEARN | GR_INHERITLEARN)) && !(mode & GR_NOPTRACE)
59745 + && (retval != (mode & ~(GR_AUDITS | GR_SUPPRESS))))) {
59746 + __u32 new_mode = mode;
59747 +
59748 + new_mode &= ~(GR_AUDITS | GR_SUPPRESS);
59749 +
59750 + retval = new_mode;
59751 +
59752 + if (new_mode & GR_EXEC && curracl->mode & GR_INHERITLEARN)
59753 + new_mode |= GR_INHERIT;
59754 +
59755 + if (!(mode & GR_NOLEARN))
59756 + gr_log_learn(dentry, mnt, new_mode);
59757 + }
59758 +
59759 + return retval;
59760 +}
59761 +
59762 +struct acl_object_label *gr_get_create_object(const struct dentry *new_dentry,
59763 + const struct dentry *parent,
59764 + const struct vfsmount *mnt)
59765 +{
59766 + struct name_entry *match;
59767 + struct acl_object_label *matchpo;
59768 + struct acl_subject_label *curracl;
59769 + char *path;
59770 +
59771 + if (unlikely(!(gr_status & GR_READY)))
59772 + return NULL;
59773 +
59774 + preempt_disable();
59775 + path = gr_to_filename_rbac(new_dentry, mnt);
59776 + match = lookup_name_entry_create(path);
59777 +
59778 + curracl = current->acl;
59779 +
59780 + if (match) {
59781 + read_lock(&gr_inode_lock);
59782 + matchpo = lookup_acl_obj_label_create(match->inode, match->device, curracl);
59783 + read_unlock(&gr_inode_lock);
59784 +
59785 + if (matchpo) {
59786 + preempt_enable();
59787 + return matchpo;
59788 + }
59789 + }
59790 +
59791 + // lookup parent
59792 +
59793 + matchpo = chk_obj_create_label(parent, mnt, curracl, path);
59794 +
59795 + preempt_enable();
59796 + return matchpo;
59797 +}
59798 +
59799 +__u32
59800 +gr_check_create(const struct dentry * new_dentry, const struct dentry * parent,
59801 + const struct vfsmount * mnt, const __u32 mode)
59802 +{
59803 + struct acl_object_label *matchpo;
59804 + __u32 retval;
59805 +
59806 + if (unlikely(!(gr_status & GR_READY)))
59807 + return (mode & ~GR_AUDITS);
59808 +
59809 + matchpo = gr_get_create_object(new_dentry, parent, mnt);
59810 +
59811 + retval = matchpo->mode & mode;
59812 +
59813 + if ((retval != (mode & ~(GR_AUDITS | GR_SUPPRESS)))
59814 + && (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))) {
59815 + __u32 new_mode = mode;
59816 +
59817 + new_mode &= ~(GR_AUDITS | GR_SUPPRESS);
59818 +
59819 + gr_log_learn(new_dentry, mnt, new_mode);
59820 + return new_mode;
59821 + }
59822 +
59823 + return retval;
59824 +}
59825 +
59826 +__u32
59827 +gr_check_link(const struct dentry * new_dentry,
59828 + const struct dentry * parent_dentry,
59829 + const struct vfsmount * parent_mnt,
59830 + const struct dentry * old_dentry, const struct vfsmount * old_mnt)
59831 +{
59832 + struct acl_object_label *obj;
59833 + __u32 oldmode, newmode;
59834 + __u32 needmode;
59835 + __u32 checkmodes = GR_FIND | GR_APPEND | GR_WRITE | GR_EXEC | GR_SETID | GR_READ |
59836 + GR_DELETE | GR_INHERIT;
59837 +
59838 + if (unlikely(!(gr_status & GR_READY)))
59839 + return (GR_CREATE | GR_LINK);
59840 +
59841 + obj = chk_obj_label(old_dentry, old_mnt, current->acl);
59842 + oldmode = obj->mode;
59843 +
59844 + obj = gr_get_create_object(new_dentry, parent_dentry, parent_mnt);
59845 + newmode = obj->mode;
59846 +
59847 + needmode = newmode & checkmodes;
59848 +
59849 + // old name for hardlink must have at least the permissions of the new name
59850 + if ((oldmode & needmode) != needmode)
59851 + goto bad;
59852 +
59853 + // if old name had restrictions/auditing, make sure the new name does as well
59854 + needmode = oldmode & (GR_NOPTRACE | GR_PTRACERD | GR_INHERIT | GR_AUDITS);
59855 +
59856 + // don't allow hardlinking of suid/sgid/fcapped files without permission
59857 + if (is_privileged_binary(old_dentry))
59858 + needmode |= GR_SETID;
59859 +
59860 + if ((newmode & needmode) != needmode)
59861 + goto bad;
59862 +
59863 + // enforce minimum permissions
59864 + if ((newmode & (GR_CREATE | GR_LINK)) == (GR_CREATE | GR_LINK))
59865 + return newmode;
59866 +bad:
59867 + needmode = oldmode;
59868 + if (is_privileged_binary(old_dentry))
59869 + needmode |= GR_SETID;
59870 +
59871 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN)) {
59872 + gr_log_learn(old_dentry, old_mnt, needmode | GR_CREATE | GR_LINK);
59873 + return (GR_CREATE | GR_LINK);
59874 + } else if (newmode & GR_SUPPRESS)
59875 + return GR_SUPPRESS;
59876 + else
59877 + return 0;
59878 +}
59879 +
59880 +int
59881 +gr_check_hidden_task(const struct task_struct *task)
59882 +{
59883 + if (unlikely(!(gr_status & GR_READY)))
59884 + return 0;
59885 +
59886 + if (!(task->acl->mode & GR_PROCFIND) && !(current->acl->mode & GR_VIEW))
59887 + return 1;
59888 +
59889 + return 0;
59890 +}
59891 +
59892 +int
59893 +gr_check_protected_task(const struct task_struct *task)
59894 +{
59895 + if (unlikely(!(gr_status & GR_READY) || !task))
59896 + return 0;
59897 +
59898 + if ((task->acl->mode & GR_PROTECTED) && !(current->acl->mode & GR_KILL) &&
59899 + task->acl != current->acl)
59900 + return 1;
59901 +
59902 + return 0;
59903 +}
59904 +
59905 +int
59906 +gr_check_protected_task_fowner(struct pid *pid, enum pid_type type)
59907 +{
59908 + struct task_struct *p;
59909 + int ret = 0;
59910 +
59911 + if (unlikely(!(gr_status & GR_READY) || !pid))
59912 + return ret;
59913 +
59914 + read_lock(&tasklist_lock);
59915 + do_each_pid_task(pid, type, p) {
59916 + if ((p->acl->mode & GR_PROTECTED) && !(current->acl->mode & GR_KILL) &&
59917 + p->acl != current->acl) {
59918 + ret = 1;
59919 + goto out;
59920 + }
59921 + } while_each_pid_task(pid, type, p);
59922 +out:
59923 + read_unlock(&tasklist_lock);
59924 +
59925 + return ret;
59926 +}
59927 +
59928 +void
59929 +gr_copy_label(struct task_struct *tsk)
59930 +{
59931 + tsk->signal->used_accept = 0;
59932 + tsk->acl_sp_role = 0;
59933 + tsk->acl_role_id = current->acl_role_id;
59934 + tsk->acl = current->acl;
59935 + tsk->role = current->role;
59936 + tsk->signal->curr_ip = current->signal->curr_ip;
59937 + tsk->signal->saved_ip = current->signal->saved_ip;
59938 + if (current->exec_file)
59939 + get_file(current->exec_file);
59940 + tsk->exec_file = current->exec_file;
59941 + tsk->is_writable = current->is_writable;
59942 + if (unlikely(current->signal->used_accept)) {
59943 + current->signal->curr_ip = 0;
59944 + current->signal->saved_ip = 0;
59945 + }
59946 +
59947 + return;
59948 +}
59949 +
59950 +static void
59951 +gr_set_proc_res(struct task_struct *task)
59952 +{
59953 + struct acl_subject_label *proc;
59954 + unsigned short i;
59955 +
59956 + proc = task->acl;
59957 +
59958 + if (proc->mode & (GR_LEARN | GR_INHERITLEARN))
59959 + return;
59960 +
59961 + for (i = 0; i < RLIM_NLIMITS; i++) {
59962 + if (!(proc->resmask & (1U << i)))
59963 + continue;
59964 +
59965 + task->signal->rlim[i].rlim_cur = proc->res[i].rlim_cur;
59966 + task->signal->rlim[i].rlim_max = proc->res[i].rlim_max;
59967 +
59968 + if (i == RLIMIT_CPU)
59969 + update_rlimit_cpu(task, proc->res[i].rlim_cur);
59970 + }
59971 +
59972 + return;
59973 +}
59974 +
59975 +extern int __gr_process_user_ban(struct user_struct *user);
59976 +
59977 +int
59978 +gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs)
59979 +{
59980 + unsigned int i;
59981 + __u16 num;
59982 + uid_t *uidlist;
59983 + uid_t curuid;
59984 + int realok = 0;
59985 + int effectiveok = 0;
59986 + int fsok = 0;
59987 + uid_t globalreal, globaleffective, globalfs;
59988 +
59989 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT) || defined(CONFIG_GRKERNSEC_BRUTE)
59990 + struct user_struct *user;
59991 +
59992 + if (!uid_valid(real))
59993 + goto skipit;
59994 +
59995 + /* find user based on global namespace */
59996 +
59997 + globalreal = GR_GLOBAL_UID(real);
59998 +
59999 + user = find_user(make_kuid(&init_user_ns, globalreal));
60000 + if (user == NULL)
60001 + goto skipit;
60002 +
60003 + if (__gr_process_user_ban(user)) {
60004 + /* for find_user */
60005 + free_uid(user);
60006 + return 1;
60007 + }
60008 +
60009 + /* for find_user */
60010 + free_uid(user);
60011 +
60012 +skipit:
60013 +#endif
60014 +
60015 + if (unlikely(!(gr_status & GR_READY)))
60016 + return 0;
60017 +
60018 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))
60019 + gr_log_learn_uid_change(real, effective, fs);
60020 +
60021 + num = current->acl->user_trans_num;
60022 + uidlist = current->acl->user_transitions;
60023 +
60024 + if (uidlist == NULL)
60025 + return 0;
60026 +
60027 + if (!uid_valid(real)) {
60028 + realok = 1;
60029 + globalreal = (uid_t)-1;
60030 + } else {
60031 + globalreal = GR_GLOBAL_UID(real);
60032 + }
60033 + if (!uid_valid(effective)) {
60034 + effectiveok = 1;
60035 + globaleffective = (uid_t)-1;
60036 + } else {
60037 + globaleffective = GR_GLOBAL_UID(effective);
60038 + }
60039 + if (!uid_valid(fs)) {
60040 + fsok = 1;
60041 + globalfs = (uid_t)-1;
60042 + } else {
60043 + globalfs = GR_GLOBAL_UID(fs);
60044 + }
60045 +
60046 + if (current->acl->user_trans_type & GR_ID_ALLOW) {
60047 + for (i = 0; i < num; i++) {
60048 + curuid = uidlist[i];
60049 + if (globalreal == curuid)
60050 + realok = 1;
60051 + if (globaleffective == curuid)
60052 + effectiveok = 1;
60053 + if (globalfs == curuid)
60054 + fsok = 1;
60055 + }
60056 + } else if (current->acl->user_trans_type & GR_ID_DENY) {
60057 + for (i = 0; i < num; i++) {
60058 + curuid = uidlist[i];
60059 + if (globalreal == curuid)
60060 + break;
60061 + if (globaleffective == curuid)
60062 + break;
60063 + if (globalfs == curuid)
60064 + break;
60065 + }
60066 + /* not in deny list */
60067 + if (i == num) {
60068 + realok = 1;
60069 + effectiveok = 1;
60070 + fsok = 1;
60071 + }
60072 + }
60073 +
60074 + if (realok && effectiveok && fsok)
60075 + return 0;
60076 + else {
60077 + gr_log_int(GR_DONT_AUDIT, GR_USRCHANGE_ACL_MSG, realok ? (effectiveok ? (fsok ? 0 : globalfs) : globaleffective) : globalreal);
60078 + return 1;
60079 + }
60080 +}
60081 +
60082 +int
60083 +gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs)
60084 +{
60085 + unsigned int i;
60086 + __u16 num;
60087 + gid_t *gidlist;
60088 + gid_t curgid;
60089 + int realok = 0;
60090 + int effectiveok = 0;
60091 + int fsok = 0;
60092 + gid_t globalreal, globaleffective, globalfs;
60093 +
60094 + if (unlikely(!(gr_status & GR_READY)))
60095 + return 0;
60096 +
60097 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))
60098 + gr_log_learn_gid_change(real, effective, fs);
60099 +
60100 + num = current->acl->group_trans_num;
60101 + gidlist = current->acl->group_transitions;
60102 +
60103 + if (gidlist == NULL)
60104 + return 0;
60105 +
60106 + if (!gid_valid(real)) {
60107 + realok = 1;
60108 + globalreal = (gid_t)-1;
60109 + } else {
60110 + globalreal = GR_GLOBAL_GID(real);
60111 + }
60112 + if (!gid_valid(effective)) {
60113 + effectiveok = 1;
60114 + globaleffective = (gid_t)-1;
60115 + } else {
60116 + globaleffective = GR_GLOBAL_GID(effective);
60117 + }
60118 + if (!gid_valid(fs)) {
60119 + fsok = 1;
60120 + globalfs = (gid_t)-1;
60121 + } else {
60122 + globalfs = GR_GLOBAL_GID(fs);
60123 + }
60124 +
60125 + if (current->acl->group_trans_type & GR_ID_ALLOW) {
60126 + for (i = 0; i < num; i++) {
60127 + curgid = gidlist[i];
60128 + if (globalreal == curgid)
60129 + realok = 1;
60130 + if (globaleffective == curgid)
60131 + effectiveok = 1;
60132 + if (globalfs == curgid)
60133 + fsok = 1;
60134 + }
60135 + } else if (current->acl->group_trans_type & GR_ID_DENY) {
60136 + for (i = 0; i < num; i++) {
60137 + curgid = gidlist[i];
60138 + if (globalreal == curgid)
60139 + break;
60140 + if (globaleffective == curgid)
60141 + break;
60142 + if (globalfs == curgid)
60143 + break;
60144 + }
60145 + /* not in deny list */
60146 + if (i == num) {
60147 + realok = 1;
60148 + effectiveok = 1;
60149 + fsok = 1;
60150 + }
60151 + }
60152 +
60153 + if (realok && effectiveok && fsok)
60154 + return 0;
60155 + else {
60156 + gr_log_int(GR_DONT_AUDIT, GR_GRPCHANGE_ACL_MSG, realok ? (effectiveok ? (fsok ? 0 : globalfs) : globaleffective) : globalreal);
60157 + return 1;
60158 + }
60159 +}
60160 +
60161 +extern int gr_acl_is_capable(const int cap);
60162 +
60163 +void
60164 +gr_set_role_label(struct task_struct *task, const kuid_t kuid, const kgid_t kgid)
60165 +{
60166 + struct acl_role_label *role = task->role;
60167 + struct acl_subject_label *subj = NULL;
60168 + struct acl_object_label *obj;
60169 + struct file *filp;
60170 + uid_t uid;
60171 + gid_t gid;
60172 +
60173 + if (unlikely(!(gr_status & GR_READY)))
60174 + return;
60175 +
60176 + uid = GR_GLOBAL_UID(kuid);
60177 + gid = GR_GLOBAL_GID(kgid);
60178 +
60179 + filp = task->exec_file;
60180 +
60181 + /* kernel process, we'll give them the kernel role */
60182 + if (unlikely(!filp)) {
60183 + task->role = kernel_role;
60184 + task->acl = kernel_role->root_label;
60185 + return;
60186 + } else if (!task->role || !(task->role->roletype & GR_ROLE_SPECIAL))
60187 + role = lookup_acl_role_label(task, uid, gid);
60188 +
60189 + /* don't change the role if we're not a privileged process */
60190 + if (role && task->role != role &&
60191 + (((role->roletype & GR_ROLE_USER) && !gr_acl_is_capable(CAP_SETUID)) ||
60192 + ((role->roletype & GR_ROLE_GROUP) && !gr_acl_is_capable(CAP_SETGID))))
60193 + return;
60194 +
60195 + /* perform subject lookup in possibly new role
60196 + we can use this result below in the case where role == task->role
60197 + */
60198 + subj = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, role);
60199 +
60200 + /* if we changed uid/gid, but result in the same role
60201 + and are using inheritance, don't lose the inherited subject
60202 + if current subject is other than what normal lookup
60203 + would result in, we arrived via inheritance, don't
60204 + lose subject
60205 + */
60206 + if (role != task->role || (!(task->acl->mode & GR_INHERITLEARN) &&
60207 + (subj == task->acl)))
60208 + task->acl = subj;
60209 +
60210 + task->role = role;
60211 +
60212 + task->is_writable = 0;
60213 +
60214 + /* ignore additional mmap checks for processes that are writable
60215 + by the default ACL */
60216 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
60217 + if (unlikely(obj->mode & GR_WRITE))
60218 + task->is_writable = 1;
60219 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, task->role->root_label);
60220 + if (unlikely(obj->mode & GR_WRITE))
60221 + task->is_writable = 1;
60222 +
60223 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
60224 + 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);
60225 +#endif
60226 +
60227 + gr_set_proc_res(task);
60228 +
60229 + return;
60230 +}
60231 +
60232 +int
60233 +gr_set_proc_label(const struct dentry *dentry, const struct vfsmount *mnt,
60234 + const int unsafe_flags)
60235 +{
60236 + struct task_struct *task = current;
60237 + struct acl_subject_label *newacl;
60238 + struct acl_object_label *obj;
60239 + __u32 retmode;
60240 +
60241 + if (unlikely(!(gr_status & GR_READY)))
60242 + return 0;
60243 +
60244 + newacl = chk_subj_label(dentry, mnt, task->role);
60245 +
60246 + /* special handling for if we did an strace -f -p <pid> from an admin role, where pid then
60247 + did an exec
60248 + */
60249 + rcu_read_lock();
60250 + read_lock(&tasklist_lock);
60251 + if (task->ptrace && task->parent && ((task->parent->role->roletype & GR_ROLE_GOD) ||
60252 + (task->parent->acl->mode & GR_POVERRIDE))) {
60253 + read_unlock(&tasklist_lock);
60254 + rcu_read_unlock();
60255 + goto skip_check;
60256 + }
60257 + read_unlock(&tasklist_lock);
60258 + rcu_read_unlock();
60259 +
60260 + if (unsafe_flags && !(task->acl->mode & GR_POVERRIDE) && (task->acl != newacl) &&
60261 + !(task->role->roletype & GR_ROLE_GOD) &&
60262 + !gr_search_file(dentry, GR_PTRACERD, mnt) &&
60263 + !(task->acl->mode & (GR_LEARN | GR_INHERITLEARN))) {
60264 + if (unsafe_flags & LSM_UNSAFE_SHARE)
60265 + gr_log_fs_generic(GR_DONT_AUDIT, GR_UNSAFESHARE_EXEC_ACL_MSG, dentry, mnt);
60266 + else
60267 + gr_log_fs_generic(GR_DONT_AUDIT, GR_PTRACE_EXEC_ACL_MSG, dentry, mnt);
60268 + return -EACCES;
60269 + }
60270 +
60271 +skip_check:
60272 +
60273 + obj = chk_obj_label(dentry, mnt, task->acl);
60274 + retmode = obj->mode & (GR_INHERIT | GR_AUDIT_INHERIT);
60275 +
60276 + if (!(task->acl->mode & GR_INHERITLEARN) &&
60277 + ((newacl->mode & GR_LEARN) || !(retmode & GR_INHERIT))) {
60278 + if (obj->nested)
60279 + task->acl = obj->nested;
60280 + else
60281 + task->acl = newacl;
60282 + } else if (retmode & GR_INHERIT && retmode & GR_AUDIT_INHERIT)
60283 + gr_log_str_fs(GR_DO_AUDIT, GR_INHERIT_ACL_MSG, task->acl->filename, dentry, mnt);
60284 +
60285 + task->is_writable = 0;
60286 +
60287 + /* ignore additional mmap checks for processes that are writable
60288 + by the default ACL */
60289 + obj = chk_obj_label(dentry, mnt, default_role->root_label);
60290 + if (unlikely(obj->mode & GR_WRITE))
60291 + task->is_writable = 1;
60292 + obj = chk_obj_label(dentry, mnt, task->role->root_label);
60293 + if (unlikely(obj->mode & GR_WRITE))
60294 + task->is_writable = 1;
60295 +
60296 + gr_set_proc_res(task);
60297 +
60298 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
60299 + 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);
60300 +#endif
60301 + return 0;
60302 +}
60303 +
60304 +/* always called with valid inodev ptr */
60305 +static void
60306 +do_handle_delete(struct inodev_entry *inodev, const ino_t ino, const dev_t dev)
60307 +{
60308 + struct acl_object_label *matchpo;
60309 + struct acl_subject_label *matchps;
60310 + struct acl_subject_label *subj;
60311 + struct acl_role_label *role;
60312 + unsigned int x;
60313 +
60314 + FOR_EACH_ROLE_START(role)
60315 + FOR_EACH_SUBJECT_START(role, subj, x)
60316 + if ((matchpo = lookup_acl_obj_label(ino, dev, subj)) != NULL)
60317 + matchpo->mode |= GR_DELETED;
60318 + FOR_EACH_SUBJECT_END(subj,x)
60319 + FOR_EACH_NESTED_SUBJECT_START(role, subj)
60320 + /* nested subjects aren't in the role's subj_hash table */
60321 + if ((matchpo = lookup_acl_obj_label(ino, dev, subj)) != NULL)
60322 + matchpo->mode |= GR_DELETED;
60323 + FOR_EACH_NESTED_SUBJECT_END(subj)
60324 + if ((matchps = lookup_acl_subj_label(ino, dev, role)) != NULL)
60325 + matchps->mode |= GR_DELETED;
60326 + FOR_EACH_ROLE_END(role)
60327 +
60328 + inodev->nentry->deleted = 1;
60329 +
60330 + return;
60331 +}
60332 +
60333 +void
60334 +gr_handle_delete(const ino_t ino, const dev_t dev)
60335 +{
60336 + struct inodev_entry *inodev;
60337 +
60338 + if (unlikely(!(gr_status & GR_READY)))
60339 + return;
60340 +
60341 + write_lock(&gr_inode_lock);
60342 + inodev = lookup_inodev_entry(ino, dev);
60343 + if (inodev != NULL)
60344 + do_handle_delete(inodev, ino, dev);
60345 + write_unlock(&gr_inode_lock);
60346 +
60347 + return;
60348 +}
60349 +
60350 +static void
60351 +update_acl_obj_label(const ino_t oldinode, const dev_t olddevice,
60352 + const ino_t newinode, const dev_t newdevice,
60353 + struct acl_subject_label *subj)
60354 +{
60355 + unsigned int index = gr_fhash(oldinode, olddevice, subj->obj_hash_size);
60356 + struct acl_object_label *match;
60357 +
60358 + match = subj->obj_hash[index];
60359 +
60360 + while (match && (match->inode != oldinode ||
60361 + match->device != olddevice ||
60362 + !(match->mode & GR_DELETED)))
60363 + match = match->next;
60364 +
60365 + if (match && (match->inode == oldinode)
60366 + && (match->device == olddevice)
60367 + && (match->mode & GR_DELETED)) {
60368 + if (match->prev == NULL) {
60369 + subj->obj_hash[index] = match->next;
60370 + if (match->next != NULL)
60371 + match->next->prev = NULL;
60372 + } else {
60373 + match->prev->next = match->next;
60374 + if (match->next != NULL)
60375 + match->next->prev = match->prev;
60376 + }
60377 + match->prev = NULL;
60378 + match->next = NULL;
60379 + match->inode = newinode;
60380 + match->device = newdevice;
60381 + match->mode &= ~GR_DELETED;
60382 +
60383 + insert_acl_obj_label(match, subj);
60384 + }
60385 +
60386 + return;
60387 +}
60388 +
60389 +static void
60390 +update_acl_subj_label(const ino_t oldinode, const dev_t olddevice,
60391 + const ino_t newinode, const dev_t newdevice,
60392 + struct acl_role_label *role)
60393 +{
60394 + unsigned int index = gr_fhash(oldinode, olddevice, role->subj_hash_size);
60395 + struct acl_subject_label *match;
60396 +
60397 + match = role->subj_hash[index];
60398 +
60399 + while (match && (match->inode != oldinode ||
60400 + match->device != olddevice ||
60401 + !(match->mode & GR_DELETED)))
60402 + match = match->next;
60403 +
60404 + if (match && (match->inode == oldinode)
60405 + && (match->device == olddevice)
60406 + && (match->mode & GR_DELETED)) {
60407 + if (match->prev == NULL) {
60408 + role->subj_hash[index] = match->next;
60409 + if (match->next != NULL)
60410 + match->next->prev = NULL;
60411 + } else {
60412 + match->prev->next = match->next;
60413 + if (match->next != NULL)
60414 + match->next->prev = match->prev;
60415 + }
60416 + match->prev = NULL;
60417 + match->next = NULL;
60418 + match->inode = newinode;
60419 + match->device = newdevice;
60420 + match->mode &= ~GR_DELETED;
60421 +
60422 + insert_acl_subj_label(match, role);
60423 + }
60424 +
60425 + return;
60426 +}
60427 +
60428 +static void
60429 +update_inodev_entry(const ino_t oldinode, const dev_t olddevice,
60430 + const ino_t newinode, const dev_t newdevice)
60431 +{
60432 + unsigned int index = gr_fhash(oldinode, olddevice, inodev_set.i_size);
60433 + struct inodev_entry *match;
60434 +
60435 + match = inodev_set.i_hash[index];
60436 +
60437 + while (match && (match->nentry->inode != oldinode ||
60438 + match->nentry->device != olddevice || !match->nentry->deleted))
60439 + match = match->next;
60440 +
60441 + if (match && (match->nentry->inode == oldinode)
60442 + && (match->nentry->device == olddevice) &&
60443 + match->nentry->deleted) {
60444 + if (match->prev == NULL) {
60445 + inodev_set.i_hash[index] = match->next;
60446 + if (match->next != NULL)
60447 + match->next->prev = NULL;
60448 + } else {
60449 + match->prev->next = match->next;
60450 + if (match->next != NULL)
60451 + match->next->prev = match->prev;
60452 + }
60453 + match->prev = NULL;
60454 + match->next = NULL;
60455 + match->nentry->inode = newinode;
60456 + match->nentry->device = newdevice;
60457 + match->nentry->deleted = 0;
60458 +
60459 + insert_inodev_entry(match);
60460 + }
60461 +
60462 + return;
60463 +}
60464 +
60465 +static void
60466 +__do_handle_create(const struct name_entry *matchn, ino_t ino, dev_t dev)
60467 +{
60468 + struct acl_subject_label *subj;
60469 + struct acl_role_label *role;
60470 + unsigned int x;
60471 +
60472 + FOR_EACH_ROLE_START(role)
60473 + update_acl_subj_label(matchn->inode, matchn->device, ino, dev, role);
60474 +
60475 + FOR_EACH_NESTED_SUBJECT_START(role, subj)
60476 + if ((subj->inode == ino) && (subj->device == dev)) {
60477 + subj->inode = ino;
60478 + subj->device = dev;
60479 + }
60480 + /* nested subjects aren't in the role's subj_hash table */
60481 + update_acl_obj_label(matchn->inode, matchn->device,
60482 + ino, dev, subj);
60483 + FOR_EACH_NESTED_SUBJECT_END(subj)
60484 + FOR_EACH_SUBJECT_START(role, subj, x)
60485 + update_acl_obj_label(matchn->inode, matchn->device,
60486 + ino, dev, subj);
60487 + FOR_EACH_SUBJECT_END(subj,x)
60488 + FOR_EACH_ROLE_END(role)
60489 +
60490 + update_inodev_entry(matchn->inode, matchn->device, ino, dev);
60491 +
60492 + return;
60493 +}
60494 +
60495 +static void
60496 +do_handle_create(const struct name_entry *matchn, const struct dentry *dentry,
60497 + const struct vfsmount *mnt)
60498 +{
60499 + ino_t ino = dentry->d_inode->i_ino;
60500 + dev_t dev = __get_dev(dentry);
60501 +
60502 + __do_handle_create(matchn, ino, dev);
60503 +
60504 + return;
60505 +}
60506 +
60507 +void
60508 +gr_handle_create(const struct dentry *dentry, const struct vfsmount *mnt)
60509 +{
60510 + struct name_entry *matchn;
60511 +
60512 + if (unlikely(!(gr_status & GR_READY)))
60513 + return;
60514 +
60515 + preempt_disable();
60516 + matchn = lookup_name_entry(gr_to_filename_rbac(dentry, mnt));
60517 +
60518 + if (unlikely((unsigned long)matchn)) {
60519 + write_lock(&gr_inode_lock);
60520 + do_handle_create(matchn, dentry, mnt);
60521 + write_unlock(&gr_inode_lock);
60522 + }
60523 + preempt_enable();
60524 +
60525 + return;
60526 +}
60527 +
60528 +void
60529 +gr_handle_proc_create(const struct dentry *dentry, const struct inode *inode)
60530 +{
60531 + struct name_entry *matchn;
60532 +
60533 + if (unlikely(!(gr_status & GR_READY)))
60534 + return;
60535 +
60536 + preempt_disable();
60537 + matchn = lookup_name_entry(gr_to_proc_filename_rbac(dentry, init_pid_ns.proc_mnt));
60538 +
60539 + if (unlikely((unsigned long)matchn)) {
60540 + write_lock(&gr_inode_lock);
60541 + __do_handle_create(matchn, inode->i_ino, inode->i_sb->s_dev);
60542 + write_unlock(&gr_inode_lock);
60543 + }
60544 + preempt_enable();
60545 +
60546 + return;
60547 +}
60548 +
60549 +void
60550 +gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
60551 + struct dentry *old_dentry,
60552 + struct dentry *new_dentry,
60553 + struct vfsmount *mnt, const __u8 replace)
60554 +{
60555 + struct name_entry *matchn;
60556 + struct inodev_entry *inodev;
60557 + struct inode *inode = new_dentry->d_inode;
60558 + ino_t old_ino = old_dentry->d_inode->i_ino;
60559 + dev_t old_dev = __get_dev(old_dentry);
60560 +
60561 + /* vfs_rename swaps the name and parent link for old_dentry and
60562 + new_dentry
60563 + at this point, old_dentry has the new name, parent link, and inode
60564 + for the renamed file
60565 + if a file is being replaced by a rename, new_dentry has the inode
60566 + and name for the replaced file
60567 + */
60568 +
60569 + if (unlikely(!(gr_status & GR_READY)))
60570 + return;
60571 +
60572 + preempt_disable();
60573 + matchn = lookup_name_entry(gr_to_filename_rbac(old_dentry, mnt));
60574 +
60575 + /* we wouldn't have to check d_inode if it weren't for
60576 + NFS silly-renaming
60577 + */
60578 +
60579 + write_lock(&gr_inode_lock);
60580 + if (unlikely(replace && inode)) {
60581 + ino_t new_ino = inode->i_ino;
60582 + dev_t new_dev = __get_dev(new_dentry);
60583 +
60584 + inodev = lookup_inodev_entry(new_ino, new_dev);
60585 + if (inodev != NULL && ((inode->i_nlink <= 1) || S_ISDIR(inode->i_mode)))
60586 + do_handle_delete(inodev, new_ino, new_dev);
60587 + }
60588 +
60589 + inodev = lookup_inodev_entry(old_ino, old_dev);
60590 + if (inodev != NULL && ((old_dentry->d_inode->i_nlink <= 1) || S_ISDIR(old_dentry->d_inode->i_mode)))
60591 + do_handle_delete(inodev, old_ino, old_dev);
60592 +
60593 + if (unlikely((unsigned long)matchn))
60594 + do_handle_create(matchn, old_dentry, mnt);
60595 +
60596 + write_unlock(&gr_inode_lock);
60597 + preempt_enable();
60598 +
60599 + return;
60600 +}
60601 +
60602 +static int
60603 +lookup_special_role_auth(__u16 mode, const char *rolename, unsigned char **salt,
60604 + unsigned char **sum)
60605 +{
60606 + struct acl_role_label *r;
60607 + struct role_allowed_ip *ipp;
60608 + struct role_transition *trans;
60609 + unsigned int i;
60610 + int found = 0;
60611 + u32 curr_ip = current->signal->curr_ip;
60612 +
60613 + current->signal->saved_ip = curr_ip;
60614 +
60615 + /* check transition table */
60616 +
60617 + for (trans = current->role->transitions; trans; trans = trans->next) {
60618 + if (!strcmp(rolename, trans->rolename)) {
60619 + found = 1;
60620 + break;
60621 + }
60622 + }
60623 +
60624 + if (!found)
60625 + return 0;
60626 +
60627 + /* handle special roles that do not require authentication
60628 + and check ip */
60629 +
60630 + FOR_EACH_ROLE_START(r)
60631 + if (!strcmp(rolename, r->rolename) &&
60632 + (r->roletype & GR_ROLE_SPECIAL)) {
60633 + found = 0;
60634 + if (r->allowed_ips != NULL) {
60635 + for (ipp = r->allowed_ips; ipp; ipp = ipp->next) {
60636 + if ((ntohl(curr_ip) & ipp->netmask) ==
60637 + (ntohl(ipp->addr) & ipp->netmask))
60638 + found = 1;
60639 + }
60640 + } else
60641 + found = 2;
60642 + if (!found)
60643 + return 0;
60644 +
60645 + if (((mode == GR_SPROLE) && (r->roletype & GR_ROLE_NOPW)) ||
60646 + ((mode == GR_SPROLEPAM) && (r->roletype & GR_ROLE_PAM))) {
60647 + *salt = NULL;
60648 + *sum = NULL;
60649 + return 1;
60650 + }
60651 + }
60652 + FOR_EACH_ROLE_END(r)
60653 +
60654 + for (i = 0; i < num_sprole_pws; i++) {
60655 + if (!strcmp(rolename, acl_special_roles[i]->rolename)) {
60656 + *salt = acl_special_roles[i]->salt;
60657 + *sum = acl_special_roles[i]->sum;
60658 + return 1;
60659 + }
60660 + }
60661 +
60662 + return 0;
60663 +}
60664 +
60665 +static void
60666 +assign_special_role(char *rolename)
60667 +{
60668 + struct acl_object_label *obj;
60669 + struct acl_role_label *r;
60670 + struct acl_role_label *assigned = NULL;
60671 + struct task_struct *tsk;
60672 + struct file *filp;
60673 +
60674 + FOR_EACH_ROLE_START(r)
60675 + if (!strcmp(rolename, r->rolename) &&
60676 + (r->roletype & GR_ROLE_SPECIAL)) {
60677 + assigned = r;
60678 + break;
60679 + }
60680 + FOR_EACH_ROLE_END(r)
60681 +
60682 + if (!assigned)
60683 + return;
60684 +
60685 + read_lock(&tasklist_lock);
60686 + read_lock(&grsec_exec_file_lock);
60687 +
60688 + tsk = current->real_parent;
60689 + if (tsk == NULL)
60690 + goto out_unlock;
60691 +
60692 + filp = tsk->exec_file;
60693 + if (filp == NULL)
60694 + goto out_unlock;
60695 +
60696 + tsk->is_writable = 0;
60697 +
60698 + tsk->acl_sp_role = 1;
60699 + tsk->acl_role_id = ++acl_sp_role_value;
60700 + tsk->role = assigned;
60701 + tsk->acl = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, tsk->role);
60702 +
60703 + /* ignore additional mmap checks for processes that are writable
60704 + by the default ACL */
60705 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
60706 + if (unlikely(obj->mode & GR_WRITE))
60707 + tsk->is_writable = 1;
60708 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, tsk->role->root_label);
60709 + if (unlikely(obj->mode & GR_WRITE))
60710 + tsk->is_writable = 1;
60711 +
60712 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
60713 + 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));
60714 +#endif
60715 +
60716 +out_unlock:
60717 + read_unlock(&grsec_exec_file_lock);
60718 + read_unlock(&tasklist_lock);
60719 + return;
60720 +}
60721 +
60722 +int gr_check_secure_terminal(struct task_struct *task)
60723 +{
60724 + struct task_struct *p, *p2, *p3;
60725 + struct files_struct *files;
60726 + struct fdtable *fdt;
60727 + struct file *our_file = NULL, *file;
60728 + int i;
60729 +
60730 + if (task->signal->tty == NULL)
60731 + return 1;
60732 +
60733 + files = get_files_struct(task);
60734 + if (files != NULL) {
60735 + rcu_read_lock();
60736 + fdt = files_fdtable(files);
60737 + for (i=0; i < fdt->max_fds; i++) {
60738 + file = fcheck_files(files, i);
60739 + if (file && (our_file == NULL) && (file->private_data == task->signal->tty)) {
60740 + get_file(file);
60741 + our_file = file;
60742 + }
60743 + }
60744 + rcu_read_unlock();
60745 + put_files_struct(files);
60746 + }
60747 +
60748 + if (our_file == NULL)
60749 + return 1;
60750 +
60751 + read_lock(&tasklist_lock);
60752 + do_each_thread(p2, p) {
60753 + files = get_files_struct(p);
60754 + if (files == NULL ||
60755 + (p->signal && p->signal->tty == task->signal->tty)) {
60756 + if (files != NULL)
60757 + put_files_struct(files);
60758 + continue;
60759 + }
60760 + rcu_read_lock();
60761 + fdt = files_fdtable(files);
60762 + for (i=0; i < fdt->max_fds; i++) {
60763 + file = fcheck_files(files, i);
60764 + if (file && S_ISCHR(file->f_path.dentry->d_inode->i_mode) &&
60765 + file->f_path.dentry->d_inode->i_rdev == our_file->f_path.dentry->d_inode->i_rdev) {
60766 + p3 = task;
60767 + while (task_pid_nr(p3) > 0) {
60768 + if (p3 == p)
60769 + break;
60770 + p3 = p3->real_parent;
60771 + }
60772 + if (p3 == p)
60773 + break;
60774 + gr_log_ttysniff(GR_DONT_AUDIT_GOOD, GR_TTYSNIFF_ACL_MSG, p);
60775 + gr_handle_alertkill(p);
60776 + rcu_read_unlock();
60777 + put_files_struct(files);
60778 + read_unlock(&tasklist_lock);
60779 + fput(our_file);
60780 + return 0;
60781 + }
60782 + }
60783 + rcu_read_unlock();
60784 + put_files_struct(files);
60785 + } while_each_thread(p2, p);
60786 + read_unlock(&tasklist_lock);
60787 +
60788 + fput(our_file);
60789 + return 1;
60790 +}
60791 +
60792 +static int gr_rbac_disable(void *unused)
60793 +{
60794 + pax_open_kernel();
60795 + gr_status &= ~GR_READY;
60796 + pax_close_kernel();
60797 +
60798 + return 0;
60799 +}
60800 +
60801 +ssize_t
60802 +write_grsec_handler(struct file *file, const char * buf, size_t count, loff_t *ppos)
60803 +{
60804 + struct gr_arg_wrapper uwrap;
60805 + unsigned char *sprole_salt = NULL;
60806 + unsigned char *sprole_sum = NULL;
60807 + int error = sizeof (struct gr_arg_wrapper);
60808 + int error2 = 0;
60809 +
60810 + mutex_lock(&gr_dev_mutex);
60811 +
60812 + if ((gr_status & GR_READY) && !(current->acl->mode & GR_KERNELAUTH)) {
60813 + error = -EPERM;
60814 + goto out;
60815 + }
60816 +
60817 + if (count != sizeof (struct gr_arg_wrapper)) {
60818 + gr_log_int_int(GR_DONT_AUDIT_GOOD, GR_DEV_ACL_MSG, (int)count, (int)sizeof(struct gr_arg_wrapper));
60819 + error = -EINVAL;
60820 + goto out;
60821 + }
60822 +
60823 +
60824 + if (gr_auth_expires && time_after_eq(get_seconds(), gr_auth_expires)) {
60825 + gr_auth_expires = 0;
60826 + gr_auth_attempts = 0;
60827 + }
60828 +
60829 + if (copy_from_user(&uwrap, buf, sizeof (struct gr_arg_wrapper))) {
60830 + error = -EFAULT;
60831 + goto out;
60832 + }
60833 +
60834 + if ((uwrap.version != GRSECURITY_VERSION) || (uwrap.size != sizeof(struct gr_arg))) {
60835 + error = -EINVAL;
60836 + goto out;
60837 + }
60838 +
60839 + if (copy_from_user(gr_usermode, uwrap.arg, sizeof (struct gr_arg))) {
60840 + error = -EFAULT;
60841 + goto out;
60842 + }
60843 +
60844 + if (gr_usermode->mode != GR_SPROLE && gr_usermode->mode != GR_SPROLEPAM &&
60845 + gr_auth_attempts >= CONFIG_GRKERNSEC_ACL_MAXTRIES &&
60846 + time_after(gr_auth_expires, get_seconds())) {
60847 + error = -EBUSY;
60848 + goto out;
60849 + }
60850 +
60851 + /* if non-root trying to do anything other than use a special role,
60852 + do not attempt authentication, do not count towards authentication
60853 + locking
60854 + */
60855 +
60856 + if (gr_usermode->mode != GR_SPROLE && gr_usermode->mode != GR_STATUS &&
60857 + gr_usermode->mode != GR_UNSPROLE && gr_usermode->mode != GR_SPROLEPAM &&
60858 + gr_is_global_nonroot(current_uid())) {
60859 + error = -EPERM;
60860 + goto out;
60861 + }
60862 +
60863 + /* ensure pw and special role name are null terminated */
60864 +
60865 + gr_usermode->pw[GR_PW_LEN - 1] = '\0';
60866 + gr_usermode->sp_role[GR_SPROLE_LEN - 1] = '\0';
60867 +
60868 + /* Okay.
60869 + * We have our enough of the argument structure..(we have yet
60870 + * to copy_from_user the tables themselves) . Copy the tables
60871 + * only if we need them, i.e. for loading operations. */
60872 +
60873 + switch (gr_usermode->mode) {
60874 + case GR_STATUS:
60875 + if (gr_status & GR_READY) {
60876 + error = 1;
60877 + if (!gr_check_secure_terminal(current))
60878 + error = 3;
60879 + } else
60880 + error = 2;
60881 + goto out;
60882 + case GR_SHUTDOWN:
60883 + if ((gr_status & GR_READY)
60884 + && !(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
60885 + stop_machine(gr_rbac_disable, NULL, NULL);
60886 + free_variables();
60887 + memset(gr_usermode, 0, sizeof (struct gr_arg));
60888 + memset(gr_system_salt, 0, GR_SALT_LEN);
60889 + memset(gr_system_sum, 0, GR_SHA_LEN);
60890 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SHUTS_ACL_MSG);
60891 + } else if (gr_status & GR_READY) {
60892 + gr_log_noargs(GR_DONT_AUDIT, GR_SHUTF_ACL_MSG);
60893 + error = -EPERM;
60894 + } else {
60895 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SHUTI_ACL_MSG);
60896 + error = -EAGAIN;
60897 + }
60898 + break;
60899 + case GR_ENABLE:
60900 + if (!(gr_status & GR_READY) && !(error2 = gracl_init(gr_usermode)))
60901 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_ENABLE_ACL_MSG, GR_VERSION);
60902 + else {
60903 + if (gr_status & GR_READY)
60904 + error = -EAGAIN;
60905 + else
60906 + error = error2;
60907 + gr_log_str(GR_DONT_AUDIT, GR_ENABLEF_ACL_MSG, GR_VERSION);
60908 + }
60909 + break;
60910 + case GR_RELOAD:
60911 + if (!(gr_status & GR_READY)) {
60912 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_RELOADI_ACL_MSG, GR_VERSION);
60913 + error = -EAGAIN;
60914 + } else if (!(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
60915 + stop_machine(gr_rbac_disable, NULL, NULL);
60916 + free_variables();
60917 + error2 = gracl_init(gr_usermode);
60918 + if (!error2)
60919 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_RELOAD_ACL_MSG, GR_VERSION);
60920 + else {
60921 + gr_log_str(GR_DONT_AUDIT, GR_RELOADF_ACL_MSG, GR_VERSION);
60922 + error = error2;
60923 + }
60924 + } else {
60925 + gr_log_str(GR_DONT_AUDIT, GR_RELOADF_ACL_MSG, GR_VERSION);
60926 + error = -EPERM;
60927 + }
60928 + break;
60929 + case GR_SEGVMOD:
60930 + if (unlikely(!(gr_status & GR_READY))) {
60931 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SEGVMODI_ACL_MSG);
60932 + error = -EAGAIN;
60933 + break;
60934 + }
60935 +
60936 + if (!(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
60937 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SEGVMODS_ACL_MSG);
60938 + if (gr_usermode->segv_device && gr_usermode->segv_inode) {
60939 + struct acl_subject_label *segvacl;
60940 + segvacl =
60941 + lookup_acl_subj_label(gr_usermode->segv_inode,
60942 + gr_usermode->segv_device,
60943 + current->role);
60944 + if (segvacl) {
60945 + segvacl->crashes = 0;
60946 + segvacl->expires = 0;
60947 + }
60948 + } else if (gr_find_uid(gr_usermode->segv_uid) >= 0) {
60949 + gr_remove_uid(gr_usermode->segv_uid);
60950 + }
60951 + } else {
60952 + gr_log_noargs(GR_DONT_AUDIT, GR_SEGVMODF_ACL_MSG);
60953 + error = -EPERM;
60954 + }
60955 + break;
60956 + case GR_SPROLE:
60957 + case GR_SPROLEPAM:
60958 + if (unlikely(!(gr_status & GR_READY))) {
60959 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SPROLEI_ACL_MSG);
60960 + error = -EAGAIN;
60961 + break;
60962 + }
60963 +
60964 + if (current->role->expires && time_after_eq(get_seconds(), current->role->expires)) {
60965 + current->role->expires = 0;
60966 + current->role->auth_attempts = 0;
60967 + }
60968 +
60969 + if (current->role->auth_attempts >= CONFIG_GRKERNSEC_ACL_MAXTRIES &&
60970 + time_after(current->role->expires, get_seconds())) {
60971 + error = -EBUSY;
60972 + goto out;
60973 + }
60974 +
60975 + if (lookup_special_role_auth
60976 + (gr_usermode->mode, gr_usermode->sp_role, &sprole_salt, &sprole_sum)
60977 + && ((!sprole_salt && !sprole_sum)
60978 + || !(chkpw(gr_usermode, sprole_salt, sprole_sum)))) {
60979 + char *p = "";
60980 + assign_special_role(gr_usermode->sp_role);
60981 + read_lock(&tasklist_lock);
60982 + if (current->real_parent)
60983 + p = current->real_parent->role->rolename;
60984 + read_unlock(&tasklist_lock);
60985 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_SPROLES_ACL_MSG,
60986 + p, acl_sp_role_value);
60987 + } else {
60988 + gr_log_str(GR_DONT_AUDIT, GR_SPROLEF_ACL_MSG, gr_usermode->sp_role);
60989 + error = -EPERM;
60990 + if(!(current->role->auth_attempts++))
60991 + current->role->expires = get_seconds() + CONFIG_GRKERNSEC_ACL_TIMEOUT;
60992 +
60993 + goto out;
60994 + }
60995 + break;
60996 + case GR_UNSPROLE:
60997 + if (unlikely(!(gr_status & GR_READY))) {
60998 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_UNSPROLEI_ACL_MSG);
60999 + error = -EAGAIN;
61000 + break;
61001 + }
61002 +
61003 + if (current->role->roletype & GR_ROLE_SPECIAL) {
61004 + char *p = "";
61005 + int i = 0;
61006 +
61007 + read_lock(&tasklist_lock);
61008 + if (current->real_parent) {
61009 + p = current->real_parent->role->rolename;
61010 + i = current->real_parent->acl_role_id;
61011 + }
61012 + read_unlock(&tasklist_lock);
61013 +
61014 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_UNSPROLES_ACL_MSG, p, i);
61015 + gr_set_acls(1);
61016 + } else {
61017 + error = -EPERM;
61018 + goto out;
61019 + }
61020 + break;
61021 + default:
61022 + gr_log_int(GR_DONT_AUDIT, GR_INVMODE_ACL_MSG, gr_usermode->mode);
61023 + error = -EINVAL;
61024 + break;
61025 + }
61026 +
61027 + if (error != -EPERM)
61028 + goto out;
61029 +
61030 + if(!(gr_auth_attempts++))
61031 + gr_auth_expires = get_seconds() + CONFIG_GRKERNSEC_ACL_TIMEOUT;
61032 +
61033 + out:
61034 + mutex_unlock(&gr_dev_mutex);
61035 + return error;
61036 +}
61037 +
61038 +/* must be called with
61039 + rcu_read_lock();
61040 + read_lock(&tasklist_lock);
61041 + read_lock(&grsec_exec_file_lock);
61042 +*/
61043 +int gr_apply_subject_to_task(struct task_struct *task)
61044 +{
61045 + struct acl_object_label *obj;
61046 + char *tmpname;
61047 + struct acl_subject_label *tmpsubj;
61048 + struct file *filp;
61049 + struct name_entry *nmatch;
61050 +
61051 + filp = task->exec_file;
61052 + if (filp == NULL)
61053 + return 0;
61054 +
61055 + /* the following is to apply the correct subject
61056 + on binaries running when the RBAC system
61057 + is enabled, when the binaries have been
61058 + replaced or deleted since their execution
61059 + -----
61060 + when the RBAC system starts, the inode/dev
61061 + from exec_file will be one the RBAC system
61062 + is unaware of. It only knows the inode/dev
61063 + of the present file on disk, or the absence
61064 + of it.
61065 + */
61066 + preempt_disable();
61067 + tmpname = gr_to_filename_rbac(filp->f_path.dentry, filp->f_path.mnt);
61068 +
61069 + nmatch = lookup_name_entry(tmpname);
61070 + preempt_enable();
61071 + tmpsubj = NULL;
61072 + if (nmatch) {
61073 + if (nmatch->deleted)
61074 + tmpsubj = lookup_acl_subj_label_deleted(nmatch->inode, nmatch->device, task->role);
61075 + else
61076 + tmpsubj = lookup_acl_subj_label(nmatch->inode, nmatch->device, task->role);
61077 + if (tmpsubj != NULL)
61078 + task->acl = tmpsubj;
61079 + }
61080 + if (tmpsubj == NULL)
61081 + task->acl = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt,
61082 + task->role);
61083 + if (task->acl) {
61084 + task->is_writable = 0;
61085 + /* ignore additional mmap checks for processes that are writable
61086 + by the default ACL */
61087 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
61088 + if (unlikely(obj->mode & GR_WRITE))
61089 + task->is_writable = 1;
61090 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, task->role->root_label);
61091 + if (unlikely(obj->mode & GR_WRITE))
61092 + task->is_writable = 1;
61093 +
61094 + gr_set_proc_res(task);
61095 +
61096 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
61097 + 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);
61098 +#endif
61099 + } else {
61100 + return 1;
61101 + }
61102 +
61103 + return 0;
61104 +}
61105 +
61106 +int
61107 +gr_set_acls(const int type)
61108 +{
61109 + struct task_struct *task, *task2;
61110 + struct acl_role_label *role = current->role;
61111 + __u16 acl_role_id = current->acl_role_id;
61112 + const struct cred *cred;
61113 + int ret;
61114 +
61115 + rcu_read_lock();
61116 + read_lock(&tasklist_lock);
61117 + read_lock(&grsec_exec_file_lock);
61118 + do_each_thread(task2, task) {
61119 + /* check to see if we're called from the exit handler,
61120 + if so, only replace ACLs that have inherited the admin
61121 + ACL */
61122 +
61123 + if (type && (task->role != role ||
61124 + task->acl_role_id != acl_role_id))
61125 + continue;
61126 +
61127 + task->acl_role_id = 0;
61128 + task->acl_sp_role = 0;
61129 +
61130 + if (task->exec_file) {
61131 + cred = __task_cred(task);
61132 + task->role = lookup_acl_role_label(task, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid));
61133 + ret = gr_apply_subject_to_task(task);
61134 + if (ret) {
61135 + read_unlock(&grsec_exec_file_lock);
61136 + read_unlock(&tasklist_lock);
61137 + rcu_read_unlock();
61138 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_DEFACL_MSG, task->comm, task_pid_nr(task));
61139 + return ret;
61140 + }
61141 + } else {
61142 + // it's a kernel process
61143 + task->role = kernel_role;
61144 + task->acl = kernel_role->root_label;
61145 +#ifdef CONFIG_GRKERNSEC_ACL_HIDEKERN
61146 + task->acl->mode &= ~GR_PROCFIND;
61147 +#endif
61148 + }
61149 + } while_each_thread(task2, task);
61150 + read_unlock(&grsec_exec_file_lock);
61151 + read_unlock(&tasklist_lock);
61152 + rcu_read_unlock();
61153 +
61154 + return 0;
61155 +}
61156 +
61157 +#if defined(CONFIG_GRKERNSEC_RESLOG) || !defined(CONFIG_GRKERNSEC_NO_RBAC)
61158 +static const unsigned long res_learn_bumps[GR_NLIMITS] = {
61159 + [RLIMIT_CPU] = GR_RLIM_CPU_BUMP,
61160 + [RLIMIT_FSIZE] = GR_RLIM_FSIZE_BUMP,
61161 + [RLIMIT_DATA] = GR_RLIM_DATA_BUMP,
61162 + [RLIMIT_STACK] = GR_RLIM_STACK_BUMP,
61163 + [RLIMIT_CORE] = GR_RLIM_CORE_BUMP,
61164 + [RLIMIT_RSS] = GR_RLIM_RSS_BUMP,
61165 + [RLIMIT_NPROC] = GR_RLIM_NPROC_BUMP,
61166 + [RLIMIT_NOFILE] = GR_RLIM_NOFILE_BUMP,
61167 + [RLIMIT_MEMLOCK] = GR_RLIM_MEMLOCK_BUMP,
61168 + [RLIMIT_AS] = GR_RLIM_AS_BUMP,
61169 + [RLIMIT_LOCKS] = GR_RLIM_LOCKS_BUMP,
61170 + [RLIMIT_SIGPENDING] = GR_RLIM_SIGPENDING_BUMP,
61171 + [RLIMIT_MSGQUEUE] = GR_RLIM_MSGQUEUE_BUMP,
61172 + [RLIMIT_NICE] = GR_RLIM_NICE_BUMP,
61173 + [RLIMIT_RTPRIO] = GR_RLIM_RTPRIO_BUMP,
61174 + [RLIMIT_RTTIME] = GR_RLIM_RTTIME_BUMP
61175 +};
61176 +
61177 +void
61178 +gr_learn_resource(const struct task_struct *task,
61179 + const int res, const unsigned long wanted, const int gt)
61180 +{
61181 + struct acl_subject_label *acl;
61182 + const struct cred *cred;
61183 +
61184 + if (unlikely((gr_status & GR_READY) &&
61185 + task->acl && (task->acl->mode & (GR_LEARN | GR_INHERITLEARN))))
61186 + goto skip_reslog;
61187 +
61188 + gr_log_resource(task, res, wanted, gt);
61189 +skip_reslog:
61190 +
61191 + if (unlikely(!(gr_status & GR_READY) || !wanted || res >= GR_NLIMITS))
61192 + return;
61193 +
61194 + acl = task->acl;
61195 +
61196 + if (likely(!acl || !(acl->mode & (GR_LEARN | GR_INHERITLEARN)) ||
61197 + !(acl->resmask & (1U << (unsigned short) res))))
61198 + return;
61199 +
61200 + if (wanted >= acl->res[res].rlim_cur) {
61201 + unsigned long res_add;
61202 +
61203 + res_add = wanted + res_learn_bumps[res];
61204 +
61205 + acl->res[res].rlim_cur = res_add;
61206 +
61207 + if (wanted > acl->res[res].rlim_max)
61208 + acl->res[res].rlim_max = res_add;
61209 +
61210 + /* only log the subject filename, since resource logging is supported for
61211 + single-subject learning only */
61212 + rcu_read_lock();
61213 + cred = __task_cred(task);
61214 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename,
61215 + task->role->roletype, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), acl->filename,
61216 + acl->filename, acl->res[res].rlim_cur, acl->res[res].rlim_max,
61217 + "", (unsigned long) res, &task->signal->saved_ip);
61218 + rcu_read_unlock();
61219 + }
61220 +
61221 + return;
61222 +}
61223 +EXPORT_SYMBOL(gr_learn_resource);
61224 +#endif
61225 +
61226 +#if defined(CONFIG_PAX_HAVE_ACL_FLAGS) && (defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR))
61227 +void
61228 +pax_set_initial_flags(struct linux_binprm *bprm)
61229 +{
61230 + struct task_struct *task = current;
61231 + struct acl_subject_label *proc;
61232 + unsigned long flags;
61233 +
61234 + if (unlikely(!(gr_status & GR_READY)))
61235 + return;
61236 +
61237 + flags = pax_get_flags(task);
61238 +
61239 + proc = task->acl;
61240 +
61241 + if (proc->pax_flags & GR_PAX_DISABLE_PAGEEXEC)
61242 + flags &= ~MF_PAX_PAGEEXEC;
61243 + if (proc->pax_flags & GR_PAX_DISABLE_SEGMEXEC)
61244 + flags &= ~MF_PAX_SEGMEXEC;
61245 + if (proc->pax_flags & GR_PAX_DISABLE_RANDMMAP)
61246 + flags &= ~MF_PAX_RANDMMAP;
61247 + if (proc->pax_flags & GR_PAX_DISABLE_EMUTRAMP)
61248 + flags &= ~MF_PAX_EMUTRAMP;
61249 + if (proc->pax_flags & GR_PAX_DISABLE_MPROTECT)
61250 + flags &= ~MF_PAX_MPROTECT;
61251 +
61252 + if (proc->pax_flags & GR_PAX_ENABLE_PAGEEXEC)
61253 + flags |= MF_PAX_PAGEEXEC;
61254 + if (proc->pax_flags & GR_PAX_ENABLE_SEGMEXEC)
61255 + flags |= MF_PAX_SEGMEXEC;
61256 + if (proc->pax_flags & GR_PAX_ENABLE_RANDMMAP)
61257 + flags |= MF_PAX_RANDMMAP;
61258 + if (proc->pax_flags & GR_PAX_ENABLE_EMUTRAMP)
61259 + flags |= MF_PAX_EMUTRAMP;
61260 + if (proc->pax_flags & GR_PAX_ENABLE_MPROTECT)
61261 + flags |= MF_PAX_MPROTECT;
61262 +
61263 + pax_set_flags(task, flags);
61264 +
61265 + return;
61266 +}
61267 +#endif
61268 +
61269 +int
61270 +gr_handle_proc_ptrace(struct task_struct *task)
61271 +{
61272 + struct file *filp;
61273 + struct task_struct *tmp = task;
61274 + struct task_struct *curtemp = current;
61275 + __u32 retmode;
61276 +
61277 +#ifndef CONFIG_GRKERNSEC_HARDEN_PTRACE
61278 + if (unlikely(!(gr_status & GR_READY)))
61279 + return 0;
61280 +#endif
61281 +
61282 + read_lock(&tasklist_lock);
61283 + read_lock(&grsec_exec_file_lock);
61284 + filp = task->exec_file;
61285 +
61286 + while (task_pid_nr(tmp) > 0) {
61287 + if (tmp == curtemp)
61288 + break;
61289 + tmp = tmp->real_parent;
61290 + }
61291 +
61292 + if (!filp || (task_pid_nr(tmp) == 0 && ((grsec_enable_harden_ptrace && gr_is_global_nonroot(current_uid()) && !(gr_status & GR_READY)) ||
61293 + ((gr_status & GR_READY) && !(current->acl->mode & GR_RELAXPTRACE))))) {
61294 + read_unlock(&grsec_exec_file_lock);
61295 + read_unlock(&tasklist_lock);
61296 + return 1;
61297 + }
61298 +
61299 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
61300 + if (!(gr_status & GR_READY)) {
61301 + read_unlock(&grsec_exec_file_lock);
61302 + read_unlock(&tasklist_lock);
61303 + return 0;
61304 + }
61305 +#endif
61306 +
61307 + retmode = gr_search_file(filp->f_path.dentry, GR_NOPTRACE, filp->f_path.mnt);
61308 + read_unlock(&grsec_exec_file_lock);
61309 + read_unlock(&tasklist_lock);
61310 +
61311 + if (retmode & GR_NOPTRACE)
61312 + return 1;
61313 +
61314 + if (!(current->acl->mode & GR_POVERRIDE) && !(current->role->roletype & GR_ROLE_GOD)
61315 + && (current->acl != task->acl || (current->acl != current->role->root_label
61316 + && task_pid_nr(current) != task_pid_nr(task))))
61317 + return 1;
61318 +
61319 + return 0;
61320 +}
61321 +
61322 +void task_grsec_rbac(struct seq_file *m, struct task_struct *p)
61323 +{
61324 + if (unlikely(!(gr_status & GR_READY)))
61325 + return;
61326 +
61327 + if (!(current->role->roletype & GR_ROLE_GOD))
61328 + return;
61329 +
61330 + seq_printf(m, "RBAC:\t%.64s:%c:%.950s\n",
61331 + p->role->rolename, gr_task_roletype_to_char(p),
61332 + p->acl->filename);
61333 +}
61334 +
61335 +int
61336 +gr_handle_ptrace(struct task_struct *task, const long request)
61337 +{
61338 + struct task_struct *tmp = task;
61339 + struct task_struct *curtemp = current;
61340 + __u32 retmode;
61341 +
61342 +#ifndef CONFIG_GRKERNSEC_HARDEN_PTRACE
61343 + if (unlikely(!(gr_status & GR_READY)))
61344 + return 0;
61345 +#endif
61346 + if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
61347 + read_lock(&tasklist_lock);
61348 + while (task_pid_nr(tmp) > 0) {
61349 + if (tmp == curtemp)
61350 + break;
61351 + tmp = tmp->real_parent;
61352 + }
61353 +
61354 + if (task_pid_nr(tmp) == 0 && ((grsec_enable_harden_ptrace && gr_is_global_nonroot(current_uid()) && !(gr_status & GR_READY)) ||
61355 + ((gr_status & GR_READY) && !(current->acl->mode & GR_RELAXPTRACE)))) {
61356 + read_unlock(&tasklist_lock);
61357 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
61358 + return 1;
61359 + }
61360 + read_unlock(&tasklist_lock);
61361 + }
61362 +
61363 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
61364 + if (!(gr_status & GR_READY))
61365 + return 0;
61366 +#endif
61367 +
61368 + read_lock(&grsec_exec_file_lock);
61369 + if (unlikely(!task->exec_file)) {
61370 + read_unlock(&grsec_exec_file_lock);
61371 + return 0;
61372 + }
61373 +
61374 + retmode = gr_search_file(task->exec_file->f_path.dentry, GR_PTRACERD | GR_NOPTRACE, task->exec_file->f_path.mnt);
61375 + read_unlock(&grsec_exec_file_lock);
61376 +
61377 + if (retmode & GR_NOPTRACE) {
61378 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
61379 + return 1;
61380 + }
61381 +
61382 + if (retmode & GR_PTRACERD) {
61383 + switch (request) {
61384 + case PTRACE_SEIZE:
61385 + case PTRACE_POKETEXT:
61386 + case PTRACE_POKEDATA:
61387 + case PTRACE_POKEUSR:
61388 +#if !defined(CONFIG_PPC32) && !defined(CONFIG_PPC64) && !defined(CONFIG_PARISC) && !defined(CONFIG_ALPHA) && !defined(CONFIG_IA64)
61389 + case PTRACE_SETREGS:
61390 + case PTRACE_SETFPREGS:
61391 +#endif
61392 +#ifdef CONFIG_X86
61393 + case PTRACE_SETFPXREGS:
61394 +#endif
61395 +#ifdef CONFIG_ALTIVEC
61396 + case PTRACE_SETVRREGS:
61397 +#endif
61398 + return 1;
61399 + default:
61400 + return 0;
61401 + }
61402 + } else if (!(current->acl->mode & GR_POVERRIDE) &&
61403 + !(current->role->roletype & GR_ROLE_GOD) &&
61404 + (current->acl != task->acl)) {
61405 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
61406 + return 1;
61407 + }
61408 +
61409 + return 0;
61410 +}
61411 +
61412 +static int is_writable_mmap(const struct file *filp)
61413 +{
61414 + struct task_struct *task = current;
61415 + struct acl_object_label *obj, *obj2;
61416 +
61417 + if (gr_status & GR_READY && !(task->acl->mode & GR_OVERRIDE) &&
61418 + !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))) {
61419 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
61420 + obj2 = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt,
61421 + task->role->root_label);
61422 + if (unlikely((obj->mode & GR_WRITE) || (obj2->mode & GR_WRITE))) {
61423 + gr_log_fs_generic(GR_DONT_AUDIT, GR_WRITLIB_ACL_MSG, filp->f_path.dentry, filp->f_path.mnt);
61424 + return 1;
61425 + }
61426 + }
61427 + return 0;
61428 +}
61429 +
61430 +int
61431 +gr_acl_handle_mmap(const struct file *file, const unsigned long prot)
61432 +{
61433 + __u32 mode;
61434 +
61435 + if (unlikely(!file || !(prot & PROT_EXEC)))
61436 + return 1;
61437 +
61438 + if (is_writable_mmap(file))
61439 + return 0;
61440 +
61441 + mode =
61442 + gr_search_file(file->f_path.dentry,
61443 + GR_EXEC | GR_AUDIT_EXEC | GR_SUPPRESS,
61444 + file->f_path.mnt);
61445 +
61446 + if (!gr_tpe_allow(file))
61447 + return 0;
61448 +
61449 + if (unlikely(!(mode & GR_EXEC) && !(mode & GR_SUPPRESS))) {
61450 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_MMAP_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
61451 + return 0;
61452 + } else if (unlikely(!(mode & GR_EXEC))) {
61453 + return 0;
61454 + } else if (unlikely(mode & GR_EXEC && mode & GR_AUDIT_EXEC)) {
61455 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_MMAP_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
61456 + return 1;
61457 + }
61458 +
61459 + return 1;
61460 +}
61461 +
61462 +int
61463 +gr_acl_handle_mprotect(const struct file *file, const unsigned long prot)
61464 +{
61465 + __u32 mode;
61466 +
61467 + if (unlikely(!file || !(prot & PROT_EXEC)))
61468 + return 1;
61469 +
61470 + if (is_writable_mmap(file))
61471 + return 0;
61472 +
61473 + mode =
61474 + gr_search_file(file->f_path.dentry,
61475 + GR_EXEC | GR_AUDIT_EXEC | GR_SUPPRESS,
61476 + file->f_path.mnt);
61477 +
61478 + if (!gr_tpe_allow(file))
61479 + return 0;
61480 +
61481 + if (unlikely(!(mode & GR_EXEC) && !(mode & GR_SUPPRESS))) {
61482 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_MPROTECT_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
61483 + return 0;
61484 + } else if (unlikely(!(mode & GR_EXEC))) {
61485 + return 0;
61486 + } else if (unlikely(mode & GR_EXEC && mode & GR_AUDIT_EXEC)) {
61487 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_MPROTECT_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
61488 + return 1;
61489 + }
61490 +
61491 + return 1;
61492 +}
61493 +
61494 +void
61495 +gr_acl_handle_psacct(struct task_struct *task, const long code)
61496 +{
61497 + unsigned long runtime;
61498 + unsigned long cputime;
61499 + unsigned int wday, cday;
61500 + __u8 whr, chr;
61501 + __u8 wmin, cmin;
61502 + __u8 wsec, csec;
61503 + struct timespec timeval;
61504 +
61505 + if (unlikely(!(gr_status & GR_READY) || !task->acl ||
61506 + !(task->acl->mode & GR_PROCACCT)))
61507 + return;
61508 +
61509 + do_posix_clock_monotonic_gettime(&timeval);
61510 + runtime = timeval.tv_sec - task->start_time.tv_sec;
61511 + wday = runtime / (3600 * 24);
61512 + runtime -= wday * (3600 * 24);
61513 + whr = runtime / 3600;
61514 + runtime -= whr * 3600;
61515 + wmin = runtime / 60;
61516 + runtime -= wmin * 60;
61517 + wsec = runtime;
61518 +
61519 + cputime = (task->utime + task->stime) / HZ;
61520 + cday = cputime / (3600 * 24);
61521 + cputime -= cday * (3600 * 24);
61522 + chr = cputime / 3600;
61523 + cputime -= chr * 3600;
61524 + cmin = cputime / 60;
61525 + cputime -= cmin * 60;
61526 + csec = cputime;
61527 +
61528 + gr_log_procacct(GR_DO_AUDIT, GR_ACL_PROCACCT_MSG, task, wday, whr, wmin, wsec, cday, chr, cmin, csec, code);
61529 +
61530 + return;
61531 +}
61532 +
61533 +void gr_set_kernel_label(struct task_struct *task)
61534 +{
61535 + if (gr_status & GR_READY) {
61536 + task->role = kernel_role;
61537 + task->acl = kernel_role->root_label;
61538 + }
61539 + return;
61540 +}
61541 +
61542 +#ifdef CONFIG_TASKSTATS
61543 +int gr_is_taskstats_denied(int pid)
61544 +{
61545 + struct task_struct *task;
61546 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
61547 + const struct cred *cred;
61548 +#endif
61549 + int ret = 0;
61550 +
61551 + /* restrict taskstats viewing to un-chrooted root users
61552 + who have the 'view' subject flag if the RBAC system is enabled
61553 + */
61554 +
61555 + rcu_read_lock();
61556 + read_lock(&tasklist_lock);
61557 + task = find_task_by_vpid(pid);
61558 + if (task) {
61559 +#ifdef CONFIG_GRKERNSEC_CHROOT
61560 + if (proc_is_chrooted(task))
61561 + ret = -EACCES;
61562 +#endif
61563 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
61564 + cred = __task_cred(task);
61565 +#ifdef CONFIG_GRKERNSEC_PROC_USER
61566 + if (gr_is_global_nonroot(cred->uid))
61567 + ret = -EACCES;
61568 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
61569 + if (gr_is_global_nonroot(cred->uid) && !groups_search(cred->group_info, grsec_proc_gid))
61570 + ret = -EACCES;
61571 +#endif
61572 +#endif
61573 + if (gr_status & GR_READY) {
61574 + if (!(task->acl->mode & GR_VIEW))
61575 + ret = -EACCES;
61576 + }
61577 + } else
61578 + ret = -ENOENT;
61579 +
61580 + read_unlock(&tasklist_lock);
61581 + rcu_read_unlock();
61582 +
61583 + return ret;
61584 +}
61585 +#endif
61586 +
61587 +/* AUXV entries are filled via a descendant of search_binary_handler
61588 + after we've already applied the subject for the target
61589 +*/
61590 +int gr_acl_enable_at_secure(void)
61591 +{
61592 + if (unlikely(!(gr_status & GR_READY)))
61593 + return 0;
61594 +
61595 + if (current->acl->mode & GR_ATSECURE)
61596 + return 1;
61597 +
61598 + return 0;
61599 +}
61600 +
61601 +int gr_acl_handle_filldir(const struct file *file, const char *name, const unsigned int namelen, const ino_t ino)
61602 +{
61603 + struct task_struct *task = current;
61604 + struct dentry *dentry = file->f_path.dentry;
61605 + struct vfsmount *mnt = file->f_path.mnt;
61606 + struct acl_object_label *obj, *tmp;
61607 + struct acl_subject_label *subj;
61608 + unsigned int bufsize;
61609 + int is_not_root;
61610 + char *path;
61611 + dev_t dev = __get_dev(dentry);
61612 +
61613 + if (unlikely(!(gr_status & GR_READY)))
61614 + return 1;
61615 +
61616 + if (task->acl->mode & (GR_LEARN | GR_INHERITLEARN))
61617 + return 1;
61618 +
61619 + /* ignore Eric Biederman */
61620 + if (IS_PRIVATE(dentry->d_inode))
61621 + return 1;
61622 +
61623 + subj = task->acl;
61624 + read_lock(&gr_inode_lock);
61625 + do {
61626 + obj = lookup_acl_obj_label(ino, dev, subj);
61627 + if (obj != NULL) {
61628 + read_unlock(&gr_inode_lock);
61629 + return (obj->mode & GR_FIND) ? 1 : 0;
61630 + }
61631 + } while ((subj = subj->parent_subject));
61632 + read_unlock(&gr_inode_lock);
61633 +
61634 + /* this is purely an optimization since we're looking for an object
61635 + for the directory we're doing a readdir on
61636 + if it's possible for any globbed object to match the entry we're
61637 + filling into the directory, then the object we find here will be
61638 + an anchor point with attached globbed objects
61639 + */
61640 + obj = chk_obj_label_noglob(dentry, mnt, task->acl);
61641 + if (obj->globbed == NULL)
61642 + return (obj->mode & GR_FIND) ? 1 : 0;
61643 +
61644 + is_not_root = ((obj->filename[0] == '/') &&
61645 + (obj->filename[1] == '\0')) ? 0 : 1;
61646 + bufsize = PAGE_SIZE - namelen - is_not_root;
61647 +
61648 + /* check bufsize > PAGE_SIZE || bufsize == 0 */
61649 + if (unlikely((bufsize - 1) > (PAGE_SIZE - 1)))
61650 + return 1;
61651 +
61652 + preempt_disable();
61653 + path = d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0], smp_processor_id()),
61654 + bufsize);
61655 +
61656 + bufsize = strlen(path);
61657 +
61658 + /* if base is "/", don't append an additional slash */
61659 + if (is_not_root)
61660 + *(path + bufsize) = '/';
61661 + memcpy(path + bufsize + is_not_root, name, namelen);
61662 + *(path + bufsize + namelen + is_not_root) = '\0';
61663 +
61664 + tmp = obj->globbed;
61665 + while (tmp) {
61666 + if (!glob_match(tmp->filename, path)) {
61667 + preempt_enable();
61668 + return (tmp->mode & GR_FIND) ? 1 : 0;
61669 + }
61670 + tmp = tmp->next;
61671 + }
61672 + preempt_enable();
61673 + return (obj->mode & GR_FIND) ? 1 : 0;
61674 +}
61675 +
61676 +void gr_put_exec_file(struct task_struct *task)
61677 +{
61678 + struct file *filp;
61679 +
61680 + write_lock(&grsec_exec_file_lock);
61681 + filp = task->exec_file;
61682 + task->exec_file = NULL;
61683 + write_unlock(&grsec_exec_file_lock);
61684 +
61685 + if (filp)
61686 + fput(filp);
61687 +
61688 + return;
61689 +}
61690 +
61691 +
61692 +#ifdef CONFIG_NETFILTER_XT_MATCH_GRADM_MODULE
61693 +EXPORT_SYMBOL(gr_acl_is_enabled);
61694 +#endif
61695 +EXPORT_SYMBOL(gr_set_kernel_label);
61696 +#ifdef CONFIG_SECURITY
61697 +EXPORT_SYMBOL(gr_check_user_change);
61698 +EXPORT_SYMBOL(gr_check_group_change);
61699 +#endif
61700 +
61701 diff --git a/grsecurity/gracl_alloc.c b/grsecurity/gracl_alloc.c
61702 new file mode 100644
61703 index 0000000..34fefda
61704 --- /dev/null
61705 +++ b/grsecurity/gracl_alloc.c
61706 @@ -0,0 +1,105 @@
61707 +#include <linux/kernel.h>
61708 +#include <linux/mm.h>
61709 +#include <linux/slab.h>
61710 +#include <linux/vmalloc.h>
61711 +#include <linux/gracl.h>
61712 +#include <linux/grsecurity.h>
61713 +
61714 +static unsigned long alloc_stack_next = 1;
61715 +static unsigned long alloc_stack_size = 1;
61716 +static void **alloc_stack;
61717 +
61718 +static __inline__ int
61719 +alloc_pop(void)
61720 +{
61721 + if (alloc_stack_next == 1)
61722 + return 0;
61723 +
61724 + kfree(alloc_stack[alloc_stack_next - 2]);
61725 +
61726 + alloc_stack_next--;
61727 +
61728 + return 1;
61729 +}
61730 +
61731 +static __inline__ int
61732 +alloc_push(void *buf)
61733 +{
61734 + if (alloc_stack_next >= alloc_stack_size)
61735 + return 1;
61736 +
61737 + alloc_stack[alloc_stack_next - 1] = buf;
61738 +
61739 + alloc_stack_next++;
61740 +
61741 + return 0;
61742 +}
61743 +
61744 +void *
61745 +acl_alloc(unsigned long len)
61746 +{
61747 + void *ret = NULL;
61748 +
61749 + if (!len || len > PAGE_SIZE)
61750 + goto out;
61751 +
61752 + ret = kmalloc(len, GFP_KERNEL);
61753 +
61754 + if (ret) {
61755 + if (alloc_push(ret)) {
61756 + kfree(ret);
61757 + ret = NULL;
61758 + }
61759 + }
61760 +
61761 +out:
61762 + return ret;
61763 +}
61764 +
61765 +void *
61766 +acl_alloc_num(unsigned long num, unsigned long len)
61767 +{
61768 + if (!len || (num > (PAGE_SIZE / len)))
61769 + return NULL;
61770 +
61771 + return acl_alloc(num * len);
61772 +}
61773 +
61774 +void
61775 +acl_free_all(void)
61776 +{
61777 + if (gr_acl_is_enabled() || !alloc_stack)
61778 + return;
61779 +
61780 + while (alloc_pop()) ;
61781 +
61782 + if (alloc_stack) {
61783 + if ((alloc_stack_size * sizeof (void *)) <= PAGE_SIZE)
61784 + kfree(alloc_stack);
61785 + else
61786 + vfree(alloc_stack);
61787 + }
61788 +
61789 + alloc_stack = NULL;
61790 + alloc_stack_size = 1;
61791 + alloc_stack_next = 1;
61792 +
61793 + return;
61794 +}
61795 +
61796 +int
61797 +acl_alloc_stack_init(unsigned long size)
61798 +{
61799 + if ((size * sizeof (void *)) <= PAGE_SIZE)
61800 + alloc_stack =
61801 + (void **) kmalloc(size * sizeof (void *), GFP_KERNEL);
61802 + else
61803 + alloc_stack = (void **) vmalloc(size * sizeof (void *));
61804 +
61805 + alloc_stack_size = size;
61806 +
61807 + if (!alloc_stack)
61808 + return 0;
61809 + else
61810 + return 1;
61811 +}
61812 diff --git a/grsecurity/gracl_cap.c b/grsecurity/gracl_cap.c
61813 new file mode 100644
61814 index 0000000..bdd51ea
61815 --- /dev/null
61816 +++ b/grsecurity/gracl_cap.c
61817 @@ -0,0 +1,110 @@
61818 +#include <linux/kernel.h>
61819 +#include <linux/module.h>
61820 +#include <linux/sched.h>
61821 +#include <linux/gracl.h>
61822 +#include <linux/grsecurity.h>
61823 +#include <linux/grinternal.h>
61824 +
61825 +extern const char *captab_log[];
61826 +extern int captab_log_entries;
61827 +
61828 +int gr_task_acl_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
61829 +{
61830 + struct acl_subject_label *curracl;
61831 + kernel_cap_t cap_drop = __cap_empty_set, cap_mask = __cap_empty_set;
61832 + kernel_cap_t cap_audit = __cap_empty_set;
61833 +
61834 + if (!gr_acl_is_enabled())
61835 + return 1;
61836 +
61837 + curracl = task->acl;
61838 +
61839 + cap_drop = curracl->cap_lower;
61840 + cap_mask = curracl->cap_mask;
61841 + cap_audit = curracl->cap_invert_audit;
61842 +
61843 + while ((curracl = curracl->parent_subject)) {
61844 + /* if the cap isn't specified in the current computed mask but is specified in the
61845 + current level subject, and is lowered in the current level subject, then add
61846 + it to the set of dropped capabilities
61847 + otherwise, add the current level subject's mask to the current computed mask
61848 + */
61849 + if (!cap_raised(cap_mask, cap) && cap_raised(curracl->cap_mask, cap)) {
61850 + cap_raise(cap_mask, cap);
61851 + if (cap_raised(curracl->cap_lower, cap))
61852 + cap_raise(cap_drop, cap);
61853 + if (cap_raised(curracl->cap_invert_audit, cap))
61854 + cap_raise(cap_audit, cap);
61855 + }
61856 + }
61857 +
61858 + if (!cap_raised(cap_drop, cap)) {
61859 + if (cap_raised(cap_audit, cap))
61860 + gr_log_cap(GR_DO_AUDIT, GR_CAP_ACL_MSG2, task, captab_log[cap]);
61861 + return 1;
61862 + }
61863 +
61864 + curracl = task->acl;
61865 +
61866 + if ((curracl->mode & (GR_LEARN | GR_INHERITLEARN))
61867 + && cap_raised(cred->cap_effective, cap)) {
61868 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename,
61869 + task->role->roletype, GR_GLOBAL_UID(cred->uid),
61870 + GR_GLOBAL_GID(cred->gid), task->exec_file ?
61871 + gr_to_filename(task->exec_file->f_path.dentry,
61872 + task->exec_file->f_path.mnt) : curracl->filename,
61873 + curracl->filename, 0UL,
61874 + 0UL, "", (unsigned long) cap, &task->signal->saved_ip);
61875 + return 1;
61876 + }
61877 +
61878 + if ((cap >= 0) && (cap < captab_log_entries) && cap_raised(cred->cap_effective, cap) && !cap_raised(cap_audit, cap))
61879 + gr_log_cap(GR_DONT_AUDIT, GR_CAP_ACL_MSG, task, captab_log[cap]);
61880 +
61881 + return 0;
61882 +}
61883 +
61884 +int
61885 +gr_acl_is_capable(const int cap)
61886 +{
61887 + return gr_task_acl_is_capable(current, current_cred(), cap);
61888 +}
61889 +
61890 +int gr_task_acl_is_capable_nolog(const struct task_struct *task, const int cap)
61891 +{
61892 + struct acl_subject_label *curracl;
61893 + kernel_cap_t cap_drop = __cap_empty_set, cap_mask = __cap_empty_set;
61894 +
61895 + if (!gr_acl_is_enabled())
61896 + return 1;
61897 +
61898 + curracl = task->acl;
61899 +
61900 + cap_drop = curracl->cap_lower;
61901 + cap_mask = curracl->cap_mask;
61902 +
61903 + while ((curracl = curracl->parent_subject)) {
61904 + /* if the cap isn't specified in the current computed mask but is specified in the
61905 + current level subject, and is lowered in the current level subject, then add
61906 + it to the set of dropped capabilities
61907 + otherwise, add the current level subject's mask to the current computed mask
61908 + */
61909 + if (!cap_raised(cap_mask, cap) && cap_raised(curracl->cap_mask, cap)) {
61910 + cap_raise(cap_mask, cap);
61911 + if (cap_raised(curracl->cap_lower, cap))
61912 + cap_raise(cap_drop, cap);
61913 + }
61914 + }
61915 +
61916 + if (!cap_raised(cap_drop, cap))
61917 + return 1;
61918 +
61919 + return 0;
61920 +}
61921 +
61922 +int
61923 +gr_acl_is_capable_nolog(const int cap)
61924 +{
61925 + return gr_task_acl_is_capable_nolog(current, cap);
61926 +}
61927 +
61928 diff --git a/grsecurity/gracl_fs.c b/grsecurity/gracl_fs.c
61929 new file mode 100644
61930 index 0000000..a340c17
61931 --- /dev/null
61932 +++ b/grsecurity/gracl_fs.c
61933 @@ -0,0 +1,431 @@
61934 +#include <linux/kernel.h>
61935 +#include <linux/sched.h>
61936 +#include <linux/types.h>
61937 +#include <linux/fs.h>
61938 +#include <linux/file.h>
61939 +#include <linux/stat.h>
61940 +#include <linux/grsecurity.h>
61941 +#include <linux/grinternal.h>
61942 +#include <linux/gracl.h>
61943 +
61944 +umode_t
61945 +gr_acl_umask(void)
61946 +{
61947 + if (unlikely(!gr_acl_is_enabled()))
61948 + return 0;
61949 +
61950 + return current->role->umask;
61951 +}
61952 +
61953 +__u32
61954 +gr_acl_handle_hidden_file(const struct dentry * dentry,
61955 + const struct vfsmount * mnt)
61956 +{
61957 + __u32 mode;
61958 +
61959 + if (unlikely(!dentry->d_inode))
61960 + return GR_FIND;
61961 +
61962 + mode =
61963 + gr_search_file(dentry, GR_FIND | GR_AUDIT_FIND | GR_SUPPRESS, mnt);
61964 +
61965 + if (unlikely(mode & GR_FIND && mode & GR_AUDIT_FIND)) {
61966 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_HIDDEN_ACL_MSG, dentry, mnt);
61967 + return mode;
61968 + } else if (unlikely(!(mode & GR_FIND) && !(mode & GR_SUPPRESS))) {
61969 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_HIDDEN_ACL_MSG, dentry, mnt);
61970 + return 0;
61971 + } else if (unlikely(!(mode & GR_FIND)))
61972 + return 0;
61973 +
61974 + return GR_FIND;
61975 +}
61976 +
61977 +__u32
61978 +gr_acl_handle_open(const struct dentry * dentry, const struct vfsmount * mnt,
61979 + int acc_mode)
61980 +{
61981 + __u32 reqmode = GR_FIND;
61982 + __u32 mode;
61983 +
61984 + if (unlikely(!dentry->d_inode))
61985 + return reqmode;
61986 +
61987 + if (acc_mode & MAY_APPEND)
61988 + reqmode |= GR_APPEND;
61989 + else if (acc_mode & MAY_WRITE)
61990 + reqmode |= GR_WRITE;
61991 + if ((acc_mode & MAY_READ) && !S_ISDIR(dentry->d_inode->i_mode))
61992 + reqmode |= GR_READ;
61993 +
61994 + mode =
61995 + gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS,
61996 + mnt);
61997 +
61998 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
61999 + gr_log_fs_rbac_mode2(GR_DO_AUDIT, GR_OPEN_ACL_MSG, dentry, mnt,
62000 + reqmode & GR_READ ? " reading" : "",
62001 + reqmode & GR_WRITE ? " writing" : reqmode &
62002 + GR_APPEND ? " appending" : "");
62003 + return reqmode;
62004 + } else
62005 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
62006 + {
62007 + gr_log_fs_rbac_mode2(GR_DONT_AUDIT, GR_OPEN_ACL_MSG, dentry, mnt,
62008 + reqmode & GR_READ ? " reading" : "",
62009 + reqmode & GR_WRITE ? " writing" : reqmode &
62010 + GR_APPEND ? " appending" : "");
62011 + return 0;
62012 + } else if (unlikely((mode & reqmode) != reqmode))
62013 + return 0;
62014 +
62015 + return reqmode;
62016 +}
62017 +
62018 +__u32
62019 +gr_acl_handle_creat(const struct dentry * dentry,
62020 + const struct dentry * p_dentry,
62021 + const struct vfsmount * p_mnt, int open_flags, int acc_mode,
62022 + const int imode)
62023 +{
62024 + __u32 reqmode = GR_WRITE | GR_CREATE;
62025 + __u32 mode;
62026 +
62027 + if (acc_mode & MAY_APPEND)
62028 + reqmode |= GR_APPEND;
62029 + // if a directory was required or the directory already exists, then
62030 + // don't count this open as a read
62031 + if ((acc_mode & MAY_READ) &&
62032 + !((open_flags & O_DIRECTORY) || (dentry->d_inode && S_ISDIR(dentry->d_inode->i_mode))))
62033 + reqmode |= GR_READ;
62034 + if ((open_flags & O_CREAT) &&
62035 + ((imode & S_ISUID) || ((imode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))
62036 + reqmode |= GR_SETID;
62037 +
62038 + mode =
62039 + gr_check_create(dentry, p_dentry, p_mnt,
62040 + reqmode | to_gr_audit(reqmode) | GR_SUPPRESS);
62041 +
62042 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
62043 + gr_log_fs_rbac_mode2(GR_DO_AUDIT, GR_CREATE_ACL_MSG, dentry, p_mnt,
62044 + reqmode & GR_READ ? " reading" : "",
62045 + reqmode & GR_WRITE ? " writing" : reqmode &
62046 + GR_APPEND ? " appending" : "");
62047 + return reqmode;
62048 + } else
62049 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
62050 + {
62051 + gr_log_fs_rbac_mode2(GR_DONT_AUDIT, GR_CREATE_ACL_MSG, dentry, p_mnt,
62052 + reqmode & GR_READ ? " reading" : "",
62053 + reqmode & GR_WRITE ? " writing" : reqmode &
62054 + GR_APPEND ? " appending" : "");
62055 + return 0;
62056 + } else if (unlikely((mode & reqmode) != reqmode))
62057 + return 0;
62058 +
62059 + return reqmode;
62060 +}
62061 +
62062 +__u32
62063 +gr_acl_handle_access(const struct dentry * dentry, const struct vfsmount * mnt,
62064 + const int fmode)
62065 +{
62066 + __u32 mode, reqmode = GR_FIND;
62067 +
62068 + if ((fmode & S_IXOTH) && !S_ISDIR(dentry->d_inode->i_mode))
62069 + reqmode |= GR_EXEC;
62070 + if (fmode & S_IWOTH)
62071 + reqmode |= GR_WRITE;
62072 + if (fmode & S_IROTH)
62073 + reqmode |= GR_READ;
62074 +
62075 + mode =
62076 + gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS,
62077 + mnt);
62078 +
62079 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
62080 + gr_log_fs_rbac_mode3(GR_DO_AUDIT, GR_ACCESS_ACL_MSG, dentry, mnt,
62081 + reqmode & GR_READ ? " reading" : "",
62082 + reqmode & GR_WRITE ? " writing" : "",
62083 + reqmode & GR_EXEC ? " executing" : "");
62084 + return reqmode;
62085 + } else
62086 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
62087 + {
62088 + gr_log_fs_rbac_mode3(GR_DONT_AUDIT, GR_ACCESS_ACL_MSG, dentry, mnt,
62089 + reqmode & GR_READ ? " reading" : "",
62090 + reqmode & GR_WRITE ? " writing" : "",
62091 + reqmode & GR_EXEC ? " executing" : "");
62092 + return 0;
62093 + } else if (unlikely((mode & reqmode) != reqmode))
62094 + return 0;
62095 +
62096 + return reqmode;
62097 +}
62098 +
62099 +static __u32 generic_fs_handler(const struct dentry *dentry, const struct vfsmount *mnt, __u32 reqmode, const char *fmt)
62100 +{
62101 + __u32 mode;
62102 +
62103 + mode = gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS, mnt);
62104 +
62105 + if (unlikely(((mode & (reqmode)) == (reqmode)) && mode & GR_AUDITS)) {
62106 + gr_log_fs_rbac_generic(GR_DO_AUDIT, fmt, dentry, mnt);
62107 + return mode;
62108 + } else if (unlikely((mode & (reqmode)) != (reqmode) && !(mode & GR_SUPPRESS))) {
62109 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, fmt, dentry, mnt);
62110 + return 0;
62111 + } else if (unlikely((mode & (reqmode)) != (reqmode)))
62112 + return 0;
62113 +
62114 + return (reqmode);
62115 +}
62116 +
62117 +__u32
62118 +gr_acl_handle_rmdir(const struct dentry * dentry, const struct vfsmount * mnt)
62119 +{
62120 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_DELETE , GR_RMDIR_ACL_MSG);
62121 +}
62122 +
62123 +__u32
62124 +gr_acl_handle_unlink(const struct dentry *dentry, const struct vfsmount *mnt)
62125 +{
62126 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_DELETE , GR_UNLINK_ACL_MSG);
62127 +}
62128 +
62129 +__u32
62130 +gr_acl_handle_truncate(const struct dentry *dentry, const struct vfsmount *mnt)
62131 +{
62132 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_TRUNCATE_ACL_MSG);
62133 +}
62134 +
62135 +__u32
62136 +gr_acl_handle_utime(const struct dentry *dentry, const struct vfsmount *mnt)
62137 +{
62138 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_ATIME_ACL_MSG);
62139 +}
62140 +
62141 +__u32
62142 +gr_acl_handle_chmod(const struct dentry *dentry, const struct vfsmount *mnt,
62143 + umode_t *modeptr)
62144 +{
62145 + umode_t mode;
62146 +
62147 + *modeptr &= ~gr_acl_umask();
62148 + mode = *modeptr;
62149 +
62150 + if (unlikely(dentry->d_inode && S_ISSOCK(dentry->d_inode->i_mode)))
62151 + return 1;
62152 +
62153 + if (unlikely(dentry->d_inode && !S_ISDIR(dentry->d_inode->i_mode) &&
62154 + ((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))) {
62155 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_SETID,
62156 + GR_CHMOD_ACL_MSG);
62157 + } else {
62158 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_CHMOD_ACL_MSG);
62159 + }
62160 +}
62161 +
62162 +__u32
62163 +gr_acl_handle_chown(const struct dentry *dentry, const struct vfsmount *mnt)
62164 +{
62165 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_CHOWN_ACL_MSG);
62166 +}
62167 +
62168 +__u32
62169 +gr_acl_handle_setxattr(const struct dentry *dentry, const struct vfsmount *mnt)
62170 +{
62171 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_SETXATTR_ACL_MSG);
62172 +}
62173 +
62174 +__u32
62175 +gr_acl_handle_execve(const struct dentry *dentry, const struct vfsmount *mnt)
62176 +{
62177 + return generic_fs_handler(dentry, mnt, GR_EXEC, GR_EXEC_ACL_MSG);
62178 +}
62179 +
62180 +__u32
62181 +gr_acl_handle_unix(const struct dentry *dentry, const struct vfsmount *mnt)
62182 +{
62183 + return generic_fs_handler(dentry, mnt, GR_READ | GR_WRITE,
62184 + GR_UNIXCONNECT_ACL_MSG);
62185 +}
62186 +
62187 +/* hardlinks require at minimum create and link permission,
62188 + any additional privilege required is based on the
62189 + privilege of the file being linked to
62190 +*/
62191 +__u32
62192 +gr_acl_handle_link(const struct dentry * new_dentry,
62193 + const struct dentry * parent_dentry,
62194 + const struct vfsmount * parent_mnt,
62195 + const struct dentry * old_dentry,
62196 + const struct vfsmount * old_mnt, const struct filename *to)
62197 +{
62198 + __u32 mode;
62199 + __u32 needmode = GR_CREATE | GR_LINK;
62200 + __u32 needaudit = GR_AUDIT_CREATE | GR_AUDIT_LINK;
62201 +
62202 + mode =
62203 + gr_check_link(new_dentry, parent_dentry, parent_mnt, old_dentry,
62204 + old_mnt);
62205 +
62206 + if (unlikely(((mode & needmode) == needmode) && (mode & needaudit))) {
62207 + gr_log_fs_rbac_str(GR_DO_AUDIT, GR_LINK_ACL_MSG, old_dentry, old_mnt, to->name);
62208 + return mode;
62209 + } else if (unlikely(((mode & needmode) != needmode) && !(mode & GR_SUPPRESS))) {
62210 + gr_log_fs_rbac_str(GR_DONT_AUDIT, GR_LINK_ACL_MSG, old_dentry, old_mnt, to->name);
62211 + return 0;
62212 + } else if (unlikely((mode & needmode) != needmode))
62213 + return 0;
62214 +
62215 + return 1;
62216 +}
62217 +
62218 +__u32
62219 +gr_acl_handle_symlink(const struct dentry * new_dentry,
62220 + const struct dentry * parent_dentry,
62221 + const struct vfsmount * parent_mnt, const struct filename *from)
62222 +{
62223 + __u32 needmode = GR_WRITE | GR_CREATE;
62224 + __u32 mode;
62225 +
62226 + mode =
62227 + gr_check_create(new_dentry, parent_dentry, parent_mnt,
62228 + GR_CREATE | GR_AUDIT_CREATE |
62229 + GR_WRITE | GR_AUDIT_WRITE | GR_SUPPRESS);
62230 +
62231 + if (unlikely(mode & GR_WRITE && mode & GR_AUDITS)) {
62232 + gr_log_fs_str_rbac(GR_DO_AUDIT, GR_SYMLINK_ACL_MSG, from->name, new_dentry, parent_mnt);
62233 + return mode;
62234 + } else if (unlikely(((mode & needmode) != needmode) && !(mode & GR_SUPPRESS))) {
62235 + gr_log_fs_str_rbac(GR_DONT_AUDIT, GR_SYMLINK_ACL_MSG, from->name, new_dentry, parent_mnt);
62236 + return 0;
62237 + } else if (unlikely((mode & needmode) != needmode))
62238 + return 0;
62239 +
62240 + return (GR_WRITE | GR_CREATE);
62241 +}
62242 +
62243 +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)
62244 +{
62245 + __u32 mode;
62246 +
62247 + mode = gr_check_create(new_dentry, parent_dentry, parent_mnt, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS);
62248 +
62249 + if (unlikely(((mode & (reqmode)) == (reqmode)) && mode & GR_AUDITS)) {
62250 + gr_log_fs_rbac_generic(GR_DO_AUDIT, fmt, new_dentry, parent_mnt);
62251 + return mode;
62252 + } else if (unlikely((mode & (reqmode)) != (reqmode) && !(mode & GR_SUPPRESS))) {
62253 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, fmt, new_dentry, parent_mnt);
62254 + return 0;
62255 + } else if (unlikely((mode & (reqmode)) != (reqmode)))
62256 + return 0;
62257 +
62258 + return (reqmode);
62259 +}
62260 +
62261 +__u32
62262 +gr_acl_handle_mknod(const struct dentry * new_dentry,
62263 + const struct dentry * parent_dentry,
62264 + const struct vfsmount * parent_mnt,
62265 + const int mode)
62266 +{
62267 + __u32 reqmode = GR_WRITE | GR_CREATE;
62268 + if (unlikely((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))
62269 + reqmode |= GR_SETID;
62270 +
62271 + return generic_fs_create_handler(new_dentry, parent_dentry, parent_mnt,
62272 + reqmode, GR_MKNOD_ACL_MSG);
62273 +}
62274 +
62275 +__u32
62276 +gr_acl_handle_mkdir(const struct dentry *new_dentry,
62277 + const struct dentry *parent_dentry,
62278 + const struct vfsmount *parent_mnt)
62279 +{
62280 + return generic_fs_create_handler(new_dentry, parent_dentry, parent_mnt,
62281 + GR_WRITE | GR_CREATE, GR_MKDIR_ACL_MSG);
62282 +}
62283 +
62284 +#define RENAME_CHECK_SUCCESS(old, new) \
62285 + (((old & (GR_WRITE | GR_READ)) == (GR_WRITE | GR_READ)) && \
62286 + ((new & (GR_WRITE | GR_READ)) == (GR_WRITE | GR_READ)))
62287 +
62288 +int
62289 +gr_acl_handle_rename(struct dentry *new_dentry,
62290 + struct dentry *parent_dentry,
62291 + const struct vfsmount *parent_mnt,
62292 + struct dentry *old_dentry,
62293 + struct inode *old_parent_inode,
62294 + struct vfsmount *old_mnt, const struct filename *newname)
62295 +{
62296 + __u32 comp1, comp2;
62297 + int error = 0;
62298 +
62299 + if (unlikely(!gr_acl_is_enabled()))
62300 + return 0;
62301 +
62302 + if (!new_dentry->d_inode) {
62303 + comp1 = gr_check_create(new_dentry, parent_dentry, parent_mnt,
62304 + GR_READ | GR_WRITE | GR_CREATE | GR_AUDIT_READ |
62305 + GR_AUDIT_WRITE | GR_AUDIT_CREATE | GR_SUPPRESS);
62306 + comp2 = gr_search_file(old_dentry, GR_READ | GR_WRITE |
62307 + GR_DELETE | GR_AUDIT_DELETE |
62308 + GR_AUDIT_READ | GR_AUDIT_WRITE |
62309 + GR_SUPPRESS, old_mnt);
62310 + } else {
62311 + comp1 = gr_search_file(new_dentry, GR_READ | GR_WRITE |
62312 + GR_CREATE | GR_DELETE |
62313 + GR_AUDIT_CREATE | GR_AUDIT_DELETE |
62314 + GR_AUDIT_READ | GR_AUDIT_WRITE |
62315 + GR_SUPPRESS, parent_mnt);
62316 + comp2 =
62317 + gr_search_file(old_dentry,
62318 + GR_READ | GR_WRITE | GR_AUDIT_READ |
62319 + GR_DELETE | GR_AUDIT_DELETE |
62320 + GR_AUDIT_WRITE | GR_SUPPRESS, old_mnt);
62321 + }
62322 +
62323 + if (RENAME_CHECK_SUCCESS(comp1, comp2) &&
62324 + ((comp1 & GR_AUDITS) || (comp2 & GR_AUDITS)))
62325 + gr_log_fs_rbac_str(GR_DO_AUDIT, GR_RENAME_ACL_MSG, old_dentry, old_mnt, newname->name);
62326 + else if (!RENAME_CHECK_SUCCESS(comp1, comp2) && !(comp1 & GR_SUPPRESS)
62327 + && !(comp2 & GR_SUPPRESS)) {
62328 + gr_log_fs_rbac_str(GR_DONT_AUDIT, GR_RENAME_ACL_MSG, old_dentry, old_mnt, newname->name);
62329 + error = -EACCES;
62330 + } else if (unlikely(!RENAME_CHECK_SUCCESS(comp1, comp2)))
62331 + error = -EACCES;
62332 +
62333 + return error;
62334 +}
62335 +
62336 +void
62337 +gr_acl_handle_exit(void)
62338 +{
62339 + u16 id;
62340 + char *rolename;
62341 +
62342 + if (unlikely(current->acl_sp_role && gr_acl_is_enabled() &&
62343 + !(current->role->roletype & GR_ROLE_PERSIST))) {
62344 + id = current->acl_role_id;
62345 + rolename = current->role->rolename;
62346 + gr_set_acls(1);
62347 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_SPROLEL_ACL_MSG, rolename, id);
62348 + }
62349 +
62350 + gr_put_exec_file(current);
62351 + return;
62352 +}
62353 +
62354 +int
62355 +gr_acl_handle_procpidmem(const struct task_struct *task)
62356 +{
62357 + if (unlikely(!gr_acl_is_enabled()))
62358 + return 0;
62359 +
62360 + if (task != current && task->acl->mode & GR_PROTPROCFD)
62361 + return -EACCES;
62362 +
62363 + return 0;
62364 +}
62365 diff --git a/grsecurity/gracl_ip.c b/grsecurity/gracl_ip.c
62366 new file mode 100644
62367 index 0000000..8132048
62368 --- /dev/null
62369 +++ b/grsecurity/gracl_ip.c
62370 @@ -0,0 +1,387 @@
62371 +#include <linux/kernel.h>
62372 +#include <asm/uaccess.h>
62373 +#include <asm/errno.h>
62374 +#include <net/sock.h>
62375 +#include <linux/file.h>
62376 +#include <linux/fs.h>
62377 +#include <linux/net.h>
62378 +#include <linux/in.h>
62379 +#include <linux/skbuff.h>
62380 +#include <linux/ip.h>
62381 +#include <linux/udp.h>
62382 +#include <linux/types.h>
62383 +#include <linux/sched.h>
62384 +#include <linux/netdevice.h>
62385 +#include <linux/inetdevice.h>
62386 +#include <linux/gracl.h>
62387 +#include <linux/grsecurity.h>
62388 +#include <linux/grinternal.h>
62389 +
62390 +#define GR_BIND 0x01
62391 +#define GR_CONNECT 0x02
62392 +#define GR_INVERT 0x04
62393 +#define GR_BINDOVERRIDE 0x08
62394 +#define GR_CONNECTOVERRIDE 0x10
62395 +#define GR_SOCK_FAMILY 0x20
62396 +
62397 +static const char * gr_protocols[IPPROTO_MAX] = {
62398 + "ip", "icmp", "igmp", "ggp", "ipencap", "st", "tcp", "cbt",
62399 + "egp", "igp", "bbn-rcc", "nvp", "pup", "argus", "emcon", "xnet",
62400 + "chaos", "udp", "mux", "dcn", "hmp", "prm", "xns-idp", "trunk-1",
62401 + "trunk-2", "leaf-1", "leaf-2", "rdp", "irtp", "iso-tp4", "netblt", "mfe-nsp",
62402 + "merit-inp", "sep", "3pc", "idpr", "xtp", "ddp", "idpr-cmtp", "tp++",
62403 + "il", "ipv6", "sdrp", "ipv6-route", "ipv6-frag", "idrp", "rsvp", "gre",
62404 + "mhrp", "bna", "ipv6-crypt", "ipv6-auth", "i-nlsp", "swipe", "narp", "mobile",
62405 + "tlsp", "skip", "ipv6-icmp", "ipv6-nonxt", "ipv6-opts", "unknown:61", "cftp", "unknown:63",
62406 + "sat-expak", "kryptolan", "rvd", "ippc", "unknown:68", "sat-mon", "visa", "ipcv",
62407 + "cpnx", "cphb", "wsn", "pvp", "br-sat-mon", "sun-nd", "wb-mon", "wb-expak",
62408 + "iso-ip", "vmtp", "secure-vmtp", "vines", "ttp", "nfsnet-igp", "dgp", "tcf",
62409 + "eigrp", "ospf", "sprite-rpc", "larp", "mtp", "ax.25", "ipip", "micp",
62410 + "scc-sp", "etherip", "encap", "unknown:99", "gmtp", "ifmp", "pnni", "pim",
62411 + "aris", "scps", "qnx", "a/n", "ipcomp", "snp", "compaq-peer", "ipx-in-ip",
62412 + "vrrp", "pgm", "unknown:114", "l2tp", "ddx", "iatp", "stp", "srp",
62413 + "uti", "smp", "sm", "ptp", "isis", "fire", "crtp", "crdup",
62414 + "sscopmce", "iplt", "sps", "pipe", "sctp", "fc", "unkown:134", "unknown:135",
62415 + "unknown:136", "unknown:137", "unknown:138", "unknown:139", "unknown:140", "unknown:141", "unknown:142", "unknown:143",
62416 + "unknown:144", "unknown:145", "unknown:146", "unknown:147", "unknown:148", "unknown:149", "unknown:150", "unknown:151",
62417 + "unknown:152", "unknown:153", "unknown:154", "unknown:155", "unknown:156", "unknown:157", "unknown:158", "unknown:159",
62418 + "unknown:160", "unknown:161", "unknown:162", "unknown:163", "unknown:164", "unknown:165", "unknown:166", "unknown:167",
62419 + "unknown:168", "unknown:169", "unknown:170", "unknown:171", "unknown:172", "unknown:173", "unknown:174", "unknown:175",
62420 + "unknown:176", "unknown:177", "unknown:178", "unknown:179", "unknown:180", "unknown:181", "unknown:182", "unknown:183",
62421 + "unknown:184", "unknown:185", "unknown:186", "unknown:187", "unknown:188", "unknown:189", "unknown:190", "unknown:191",
62422 + "unknown:192", "unknown:193", "unknown:194", "unknown:195", "unknown:196", "unknown:197", "unknown:198", "unknown:199",
62423 + "unknown:200", "unknown:201", "unknown:202", "unknown:203", "unknown:204", "unknown:205", "unknown:206", "unknown:207",
62424 + "unknown:208", "unknown:209", "unknown:210", "unknown:211", "unknown:212", "unknown:213", "unknown:214", "unknown:215",
62425 + "unknown:216", "unknown:217", "unknown:218", "unknown:219", "unknown:220", "unknown:221", "unknown:222", "unknown:223",
62426 + "unknown:224", "unknown:225", "unknown:226", "unknown:227", "unknown:228", "unknown:229", "unknown:230", "unknown:231",
62427 + "unknown:232", "unknown:233", "unknown:234", "unknown:235", "unknown:236", "unknown:237", "unknown:238", "unknown:239",
62428 + "unknown:240", "unknown:241", "unknown:242", "unknown:243", "unknown:244", "unknown:245", "unknown:246", "unknown:247",
62429 + "unknown:248", "unknown:249", "unknown:250", "unknown:251", "unknown:252", "unknown:253", "unknown:254", "unknown:255",
62430 + };
62431 +
62432 +static const char * gr_socktypes[SOCK_MAX] = {
62433 + "unknown:0", "stream", "dgram", "raw", "rdm", "seqpacket", "unknown:6",
62434 + "unknown:7", "unknown:8", "unknown:9", "packet"
62435 + };
62436 +
62437 +static const char * gr_sockfamilies[AF_MAX+1] = {
62438 + "unspec", "unix", "inet", "ax25", "ipx", "appletalk", "netrom", "bridge", "atmpvc", "x25",
62439 + "inet6", "rose", "decnet", "netbeui", "security", "key", "netlink", "packet", "ash",
62440 + "econet", "atmsvc", "rds", "sna", "irda", "ppox", "wanpipe", "llc", "fam_27", "fam_28",
62441 + "tipc", "bluetooth", "iucv", "rxrpc", "isdn", "phonet", "ieee802154", "ciaf"
62442 + };
62443 +
62444 +const char *
62445 +gr_proto_to_name(unsigned char proto)
62446 +{
62447 + return gr_protocols[proto];
62448 +}
62449 +
62450 +const char *
62451 +gr_socktype_to_name(unsigned char type)
62452 +{
62453 + return gr_socktypes[type];
62454 +}
62455 +
62456 +const char *
62457 +gr_sockfamily_to_name(unsigned char family)
62458 +{
62459 + return gr_sockfamilies[family];
62460 +}
62461 +
62462 +int
62463 +gr_search_socket(const int domain, const int type, const int protocol)
62464 +{
62465 + struct acl_subject_label *curr;
62466 + const struct cred *cred = current_cred();
62467 +
62468 + if (unlikely(!gr_acl_is_enabled()))
62469 + goto exit;
62470 +
62471 + if ((domain < 0) || (type < 0) || (protocol < 0) ||
62472 + (domain >= AF_MAX) || (type >= SOCK_MAX) || (protocol >= IPPROTO_MAX))
62473 + goto exit; // let the kernel handle it
62474 +
62475 + curr = current->acl;
62476 +
62477 + if (curr->sock_families[domain / 32] & (1U << (domain % 32))) {
62478 + /* the family is allowed, if this is PF_INET allow it only if
62479 + the extra sock type/protocol checks pass */
62480 + if (domain == PF_INET)
62481 + goto inet_check;
62482 + goto exit;
62483 + } else {
62484 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
62485 + __u32 fakeip = 0;
62486 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
62487 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
62488 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
62489 + gr_to_filename(current->exec_file->f_path.dentry,
62490 + current->exec_file->f_path.mnt) :
62491 + curr->filename, curr->filename,
62492 + &fakeip, domain, 0, 0, GR_SOCK_FAMILY,
62493 + &current->signal->saved_ip);
62494 + goto exit;
62495 + }
62496 + goto exit_fail;
62497 + }
62498 +
62499 +inet_check:
62500 + /* the rest of this checking is for IPv4 only */
62501 + if (!curr->ips)
62502 + goto exit;
62503 +
62504 + if ((curr->ip_type & (1U << type)) &&
62505 + (curr->ip_proto[protocol / 32] & (1U << (protocol % 32))))
62506 + goto exit;
62507 +
62508 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
62509 + /* we don't place acls on raw sockets , and sometimes
62510 + dgram/ip sockets are opened for ioctl and not
62511 + bind/connect, so we'll fake a bind learn log */
62512 + if (type == SOCK_RAW || type == SOCK_PACKET) {
62513 + __u32 fakeip = 0;
62514 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
62515 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
62516 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
62517 + gr_to_filename(current->exec_file->f_path.dentry,
62518 + current->exec_file->f_path.mnt) :
62519 + curr->filename, curr->filename,
62520 + &fakeip, 0, type,
62521 + protocol, GR_CONNECT, &current->signal->saved_ip);
62522 + } else if ((type == SOCK_DGRAM) && (protocol == IPPROTO_IP)) {
62523 + __u32 fakeip = 0;
62524 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
62525 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
62526 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
62527 + gr_to_filename(current->exec_file->f_path.dentry,
62528 + current->exec_file->f_path.mnt) :
62529 + curr->filename, curr->filename,
62530 + &fakeip, 0, type,
62531 + protocol, GR_BIND, &current->signal->saved_ip);
62532 + }
62533 + /* we'll log when they use connect or bind */
62534 + goto exit;
62535 + }
62536 +
62537 +exit_fail:
62538 + if (domain == PF_INET)
62539 + gr_log_str3(GR_DONT_AUDIT, GR_SOCK_MSG, gr_sockfamily_to_name(domain),
62540 + gr_socktype_to_name(type), gr_proto_to_name(protocol));
62541 + else
62542 +#ifndef CONFIG_IPV6
62543 + if (domain != PF_INET6)
62544 +#endif
62545 + gr_log_str2_int(GR_DONT_AUDIT, GR_SOCK_NOINET_MSG, gr_sockfamily_to_name(domain),
62546 + gr_socktype_to_name(type), protocol);
62547 +
62548 + return 0;
62549 +exit:
62550 + return 1;
62551 +}
62552 +
62553 +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)
62554 +{
62555 + if ((ip->mode & mode) &&
62556 + (ip_port >= ip->low) &&
62557 + (ip_port <= ip->high) &&
62558 + ((ntohl(ip_addr) & our_netmask) ==
62559 + (ntohl(our_addr) & our_netmask))
62560 + && (ip->proto[protocol / 32] & (1U << (protocol % 32)))
62561 + && (ip->type & (1U << type))) {
62562 + if (ip->mode & GR_INVERT)
62563 + return 2; // specifically denied
62564 + else
62565 + return 1; // allowed
62566 + }
62567 +
62568 + return 0; // not specifically allowed, may continue parsing
62569 +}
62570 +
62571 +static int
62572 +gr_search_connectbind(const int full_mode, struct sock *sk,
62573 + struct sockaddr_in *addr, const int type)
62574 +{
62575 + char iface[IFNAMSIZ] = {0};
62576 + struct acl_subject_label *curr;
62577 + struct acl_ip_label *ip;
62578 + struct inet_sock *isk;
62579 + struct net_device *dev;
62580 + struct in_device *idev;
62581 + unsigned long i;
62582 + int ret;
62583 + int mode = full_mode & (GR_BIND | GR_CONNECT);
62584 + __u32 ip_addr = 0;
62585 + __u32 our_addr;
62586 + __u32 our_netmask;
62587 + char *p;
62588 + __u16 ip_port = 0;
62589 + const struct cred *cred = current_cred();
62590 +
62591 + if (unlikely(!gr_acl_is_enabled() || sk->sk_family != PF_INET))
62592 + return 0;
62593 +
62594 + curr = current->acl;
62595 + isk = inet_sk(sk);
62596 +
62597 + /* INADDR_ANY overriding for binds, inaddr_any_override is already in network order */
62598 + if ((full_mode & GR_BINDOVERRIDE) && addr->sin_addr.s_addr == htonl(INADDR_ANY) && curr->inaddr_any_override != 0)
62599 + addr->sin_addr.s_addr = curr->inaddr_any_override;
62600 + if ((full_mode & GR_CONNECT) && isk->inet_saddr == htonl(INADDR_ANY) && curr->inaddr_any_override != 0) {
62601 + struct sockaddr_in saddr;
62602 + int err;
62603 +
62604 + saddr.sin_family = AF_INET;
62605 + saddr.sin_addr.s_addr = curr->inaddr_any_override;
62606 + saddr.sin_port = isk->inet_sport;
62607 +
62608 + err = security_socket_bind(sk->sk_socket, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in));
62609 + if (err)
62610 + return err;
62611 +
62612 + err = sk->sk_socket->ops->bind(sk->sk_socket, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in));
62613 + if (err)
62614 + return err;
62615 + }
62616 +
62617 + if (!curr->ips)
62618 + return 0;
62619 +
62620 + ip_addr = addr->sin_addr.s_addr;
62621 + ip_port = ntohs(addr->sin_port);
62622 +
62623 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
62624 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
62625 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
62626 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
62627 + gr_to_filename(current->exec_file->f_path.dentry,
62628 + current->exec_file->f_path.mnt) :
62629 + curr->filename, curr->filename,
62630 + &ip_addr, ip_port, type,
62631 + sk->sk_protocol, mode, &current->signal->saved_ip);
62632 + return 0;
62633 + }
62634 +
62635 + for (i = 0; i < curr->ip_num; i++) {
62636 + ip = *(curr->ips + i);
62637 + if (ip->iface != NULL) {
62638 + strncpy(iface, ip->iface, IFNAMSIZ - 1);
62639 + p = strchr(iface, ':');
62640 + if (p != NULL)
62641 + *p = '\0';
62642 + dev = dev_get_by_name(sock_net(sk), iface);
62643 + if (dev == NULL)
62644 + continue;
62645 + idev = in_dev_get(dev);
62646 + if (idev == NULL) {
62647 + dev_put(dev);
62648 + continue;
62649 + }
62650 + rcu_read_lock();
62651 + for_ifa(idev) {
62652 + if (!strcmp(ip->iface, ifa->ifa_label)) {
62653 + our_addr = ifa->ifa_address;
62654 + our_netmask = 0xffffffff;
62655 + ret = check_ip_policy(ip, ip_addr, ip_port, sk->sk_protocol, mode, type, our_addr, our_netmask);
62656 + if (ret == 1) {
62657 + rcu_read_unlock();
62658 + in_dev_put(idev);
62659 + dev_put(dev);
62660 + return 0;
62661 + } else if (ret == 2) {
62662 + rcu_read_unlock();
62663 + in_dev_put(idev);
62664 + dev_put(dev);
62665 + goto denied;
62666 + }
62667 + }
62668 + } endfor_ifa(idev);
62669 + rcu_read_unlock();
62670 + in_dev_put(idev);
62671 + dev_put(dev);
62672 + } else {
62673 + our_addr = ip->addr;
62674 + our_netmask = ip->netmask;
62675 + ret = check_ip_policy(ip, ip_addr, ip_port, sk->sk_protocol, mode, type, our_addr, our_netmask);
62676 + if (ret == 1)
62677 + return 0;
62678 + else if (ret == 2)
62679 + goto denied;
62680 + }
62681 + }
62682 +
62683 +denied:
62684 + if (mode == GR_BIND)
62685 + 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));
62686 + else if (mode == GR_CONNECT)
62687 + 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));
62688 +
62689 + return -EACCES;
62690 +}
62691 +
62692 +int
62693 +gr_search_connect(struct socket *sock, struct sockaddr_in *addr)
62694 +{
62695 + /* always allow disconnection of dgram sockets with connect */
62696 + if (addr->sin_family == AF_UNSPEC)
62697 + return 0;
62698 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sock->sk, addr, sock->type);
62699 +}
62700 +
62701 +int
62702 +gr_search_bind(struct socket *sock, struct sockaddr_in *addr)
62703 +{
62704 + return gr_search_connectbind(GR_BIND | GR_BINDOVERRIDE, sock->sk, addr, sock->type);
62705 +}
62706 +
62707 +int gr_search_listen(struct socket *sock)
62708 +{
62709 + struct sock *sk = sock->sk;
62710 + struct sockaddr_in addr;
62711 +
62712 + addr.sin_addr.s_addr = inet_sk(sk)->inet_saddr;
62713 + addr.sin_port = inet_sk(sk)->inet_sport;
62714 +
62715 + return gr_search_connectbind(GR_BIND | GR_CONNECTOVERRIDE, sock->sk, &addr, sock->type);
62716 +}
62717 +
62718 +int gr_search_accept(struct socket *sock)
62719 +{
62720 + struct sock *sk = sock->sk;
62721 + struct sockaddr_in addr;
62722 +
62723 + addr.sin_addr.s_addr = inet_sk(sk)->inet_saddr;
62724 + addr.sin_port = inet_sk(sk)->inet_sport;
62725 +
62726 + return gr_search_connectbind(GR_BIND | GR_CONNECTOVERRIDE, sock->sk, &addr, sock->type);
62727 +}
62728 +
62729 +int
62730 +gr_search_udp_sendmsg(struct sock *sk, struct sockaddr_in *addr)
62731 +{
62732 + if (addr)
62733 + return gr_search_connectbind(GR_CONNECT, sk, addr, SOCK_DGRAM);
62734 + else {
62735 + struct sockaddr_in sin;
62736 + const struct inet_sock *inet = inet_sk(sk);
62737 +
62738 + sin.sin_addr.s_addr = inet->inet_daddr;
62739 + sin.sin_port = inet->inet_dport;
62740 +
62741 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sk, &sin, SOCK_DGRAM);
62742 + }
62743 +}
62744 +
62745 +int
62746 +gr_search_udp_recvmsg(struct sock *sk, const struct sk_buff *skb)
62747 +{
62748 + struct sockaddr_in sin;
62749 +
62750 + if (unlikely(skb->len < sizeof (struct udphdr)))
62751 + return 0; // skip this packet
62752 +
62753 + sin.sin_addr.s_addr = ip_hdr(skb)->saddr;
62754 + sin.sin_port = udp_hdr(skb)->source;
62755 +
62756 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sk, &sin, SOCK_DGRAM);
62757 +}
62758 diff --git a/grsecurity/gracl_learn.c b/grsecurity/gracl_learn.c
62759 new file mode 100644
62760 index 0000000..25f54ef
62761 --- /dev/null
62762 +++ b/grsecurity/gracl_learn.c
62763 @@ -0,0 +1,207 @@
62764 +#include <linux/kernel.h>
62765 +#include <linux/mm.h>
62766 +#include <linux/sched.h>
62767 +#include <linux/poll.h>
62768 +#include <linux/string.h>
62769 +#include <linux/file.h>
62770 +#include <linux/types.h>
62771 +#include <linux/vmalloc.h>
62772 +#include <linux/grinternal.h>
62773 +
62774 +extern ssize_t write_grsec_handler(struct file * file, const char __user * buf,
62775 + size_t count, loff_t *ppos);
62776 +extern int gr_acl_is_enabled(void);
62777 +
62778 +static DECLARE_WAIT_QUEUE_HEAD(learn_wait);
62779 +static int gr_learn_attached;
62780 +
62781 +/* use a 512k buffer */
62782 +#define LEARN_BUFFER_SIZE (512 * 1024)
62783 +
62784 +static DEFINE_SPINLOCK(gr_learn_lock);
62785 +static DEFINE_MUTEX(gr_learn_user_mutex);
62786 +
62787 +/* we need to maintain two buffers, so that the kernel context of grlearn
62788 + uses a semaphore around the userspace copying, and the other kernel contexts
62789 + use a spinlock when copying into the buffer, since they cannot sleep
62790 +*/
62791 +static char *learn_buffer;
62792 +static char *learn_buffer_user;
62793 +static int learn_buffer_len;
62794 +static int learn_buffer_user_len;
62795 +
62796 +static ssize_t
62797 +read_learn(struct file *file, char __user * buf, size_t count, loff_t * ppos)
62798 +{
62799 + DECLARE_WAITQUEUE(wait, current);
62800 + ssize_t retval = 0;
62801 +
62802 + add_wait_queue(&learn_wait, &wait);
62803 + set_current_state(TASK_INTERRUPTIBLE);
62804 + do {
62805 + mutex_lock(&gr_learn_user_mutex);
62806 + spin_lock(&gr_learn_lock);
62807 + if (learn_buffer_len)
62808 + break;
62809 + spin_unlock(&gr_learn_lock);
62810 + mutex_unlock(&gr_learn_user_mutex);
62811 + if (file->f_flags & O_NONBLOCK) {
62812 + retval = -EAGAIN;
62813 + goto out;
62814 + }
62815 + if (signal_pending(current)) {
62816 + retval = -ERESTARTSYS;
62817 + goto out;
62818 + }
62819 +
62820 + schedule();
62821 + } while (1);
62822 +
62823 + memcpy(learn_buffer_user, learn_buffer, learn_buffer_len);
62824 + learn_buffer_user_len = learn_buffer_len;
62825 + retval = learn_buffer_len;
62826 + learn_buffer_len = 0;
62827 +
62828 + spin_unlock(&gr_learn_lock);
62829 +
62830 + if (copy_to_user(buf, learn_buffer_user, learn_buffer_user_len))
62831 + retval = -EFAULT;
62832 +
62833 + mutex_unlock(&gr_learn_user_mutex);
62834 +out:
62835 + set_current_state(TASK_RUNNING);
62836 + remove_wait_queue(&learn_wait, &wait);
62837 + return retval;
62838 +}
62839 +
62840 +static unsigned int
62841 +poll_learn(struct file * file, poll_table * wait)
62842 +{
62843 + poll_wait(file, &learn_wait, wait);
62844 +
62845 + if (learn_buffer_len)
62846 + return (POLLIN | POLLRDNORM);
62847 +
62848 + return 0;
62849 +}
62850 +
62851 +void
62852 +gr_clear_learn_entries(void)
62853 +{
62854 + char *tmp;
62855 +
62856 + mutex_lock(&gr_learn_user_mutex);
62857 + spin_lock(&gr_learn_lock);
62858 + tmp = learn_buffer;
62859 + learn_buffer = NULL;
62860 + spin_unlock(&gr_learn_lock);
62861 + if (tmp)
62862 + vfree(tmp);
62863 + if (learn_buffer_user != NULL) {
62864 + vfree(learn_buffer_user);
62865 + learn_buffer_user = NULL;
62866 + }
62867 + learn_buffer_len = 0;
62868 + mutex_unlock(&gr_learn_user_mutex);
62869 +
62870 + return;
62871 +}
62872 +
62873 +void
62874 +gr_add_learn_entry(const char *fmt, ...)
62875 +{
62876 + va_list args;
62877 + unsigned int len;
62878 +
62879 + if (!gr_learn_attached)
62880 + return;
62881 +
62882 + spin_lock(&gr_learn_lock);
62883 +
62884 + /* leave a gap at the end so we know when it's "full" but don't have to
62885 + compute the exact length of the string we're trying to append
62886 + */
62887 + if (learn_buffer_len > LEARN_BUFFER_SIZE - 16384) {
62888 + spin_unlock(&gr_learn_lock);
62889 + wake_up_interruptible(&learn_wait);
62890 + return;
62891 + }
62892 + if (learn_buffer == NULL) {
62893 + spin_unlock(&gr_learn_lock);
62894 + return;
62895 + }
62896 +
62897 + va_start(args, fmt);
62898 + len = vsnprintf(learn_buffer + learn_buffer_len, LEARN_BUFFER_SIZE - learn_buffer_len, fmt, args);
62899 + va_end(args);
62900 +
62901 + learn_buffer_len += len + 1;
62902 +
62903 + spin_unlock(&gr_learn_lock);
62904 + wake_up_interruptible(&learn_wait);
62905 +
62906 + return;
62907 +}
62908 +
62909 +static int
62910 +open_learn(struct inode *inode, struct file *file)
62911 +{
62912 + if (file->f_mode & FMODE_READ && gr_learn_attached)
62913 + return -EBUSY;
62914 + if (file->f_mode & FMODE_READ) {
62915 + int retval = 0;
62916 + mutex_lock(&gr_learn_user_mutex);
62917 + if (learn_buffer == NULL)
62918 + learn_buffer = vmalloc(LEARN_BUFFER_SIZE);
62919 + if (learn_buffer_user == NULL)
62920 + learn_buffer_user = vmalloc(LEARN_BUFFER_SIZE);
62921 + if (learn_buffer == NULL) {
62922 + retval = -ENOMEM;
62923 + goto out_error;
62924 + }
62925 + if (learn_buffer_user == NULL) {
62926 + retval = -ENOMEM;
62927 + goto out_error;
62928 + }
62929 + learn_buffer_len = 0;
62930 + learn_buffer_user_len = 0;
62931 + gr_learn_attached = 1;
62932 +out_error:
62933 + mutex_unlock(&gr_learn_user_mutex);
62934 + return retval;
62935 + }
62936 + return 0;
62937 +}
62938 +
62939 +static int
62940 +close_learn(struct inode *inode, struct file *file)
62941 +{
62942 + if (file->f_mode & FMODE_READ) {
62943 + char *tmp = NULL;
62944 + mutex_lock(&gr_learn_user_mutex);
62945 + spin_lock(&gr_learn_lock);
62946 + tmp = learn_buffer;
62947 + learn_buffer = NULL;
62948 + spin_unlock(&gr_learn_lock);
62949 + if (tmp)
62950 + vfree(tmp);
62951 + if (learn_buffer_user != NULL) {
62952 + vfree(learn_buffer_user);
62953 + learn_buffer_user = NULL;
62954 + }
62955 + learn_buffer_len = 0;
62956 + learn_buffer_user_len = 0;
62957 + gr_learn_attached = 0;
62958 + mutex_unlock(&gr_learn_user_mutex);
62959 + }
62960 +
62961 + return 0;
62962 +}
62963 +
62964 +const struct file_operations grsec_fops = {
62965 + .read = read_learn,
62966 + .write = write_grsec_handler,
62967 + .open = open_learn,
62968 + .release = close_learn,
62969 + .poll = poll_learn,
62970 +};
62971 diff --git a/grsecurity/gracl_res.c b/grsecurity/gracl_res.c
62972 new file mode 100644
62973 index 0000000..39645c9
62974 --- /dev/null
62975 +++ b/grsecurity/gracl_res.c
62976 @@ -0,0 +1,68 @@
62977 +#include <linux/kernel.h>
62978 +#include <linux/sched.h>
62979 +#include <linux/gracl.h>
62980 +#include <linux/grinternal.h>
62981 +
62982 +static const char *restab_log[] = {
62983 + [RLIMIT_CPU] = "RLIMIT_CPU",
62984 + [RLIMIT_FSIZE] = "RLIMIT_FSIZE",
62985 + [RLIMIT_DATA] = "RLIMIT_DATA",
62986 + [RLIMIT_STACK] = "RLIMIT_STACK",
62987 + [RLIMIT_CORE] = "RLIMIT_CORE",
62988 + [RLIMIT_RSS] = "RLIMIT_RSS",
62989 + [RLIMIT_NPROC] = "RLIMIT_NPROC",
62990 + [RLIMIT_NOFILE] = "RLIMIT_NOFILE",
62991 + [RLIMIT_MEMLOCK] = "RLIMIT_MEMLOCK",
62992 + [RLIMIT_AS] = "RLIMIT_AS",
62993 + [RLIMIT_LOCKS] = "RLIMIT_LOCKS",
62994 + [RLIMIT_SIGPENDING] = "RLIMIT_SIGPENDING",
62995 + [RLIMIT_MSGQUEUE] = "RLIMIT_MSGQUEUE",
62996 + [RLIMIT_NICE] = "RLIMIT_NICE",
62997 + [RLIMIT_RTPRIO] = "RLIMIT_RTPRIO",
62998 + [RLIMIT_RTTIME] = "RLIMIT_RTTIME",
62999 + [GR_CRASH_RES] = "RLIMIT_CRASH"
63000 +};
63001 +
63002 +void
63003 +gr_log_resource(const struct task_struct *task,
63004 + const int res, const unsigned long wanted, const int gt)
63005 +{
63006 + const struct cred *cred;
63007 + unsigned long rlim;
63008 +
63009 + if (!gr_acl_is_enabled() && !grsec_resource_logging)
63010 + return;
63011 +
63012 + // not yet supported resource
63013 + if (unlikely(!restab_log[res]))
63014 + return;
63015 +
63016 + if (res == RLIMIT_CPU || res == RLIMIT_RTTIME)
63017 + rlim = task_rlimit_max(task, res);
63018 + else
63019 + rlim = task_rlimit(task, res);
63020 +
63021 + if (likely((rlim == RLIM_INFINITY) || (gt && wanted <= rlim) || (!gt && wanted < rlim)))
63022 + return;
63023 +
63024 + rcu_read_lock();
63025 + cred = __task_cred(task);
63026 +
63027 + if (res == RLIMIT_NPROC &&
63028 + (cap_raised(cred->cap_effective, CAP_SYS_ADMIN) ||
63029 + cap_raised(cred->cap_effective, CAP_SYS_RESOURCE)))
63030 + goto out_rcu_unlock;
63031 + else if (res == RLIMIT_MEMLOCK &&
63032 + cap_raised(cred->cap_effective, CAP_IPC_LOCK))
63033 + goto out_rcu_unlock;
63034 + else if (res == RLIMIT_NICE && cap_raised(cred->cap_effective, CAP_SYS_NICE))
63035 + goto out_rcu_unlock;
63036 + rcu_read_unlock();
63037 +
63038 + gr_log_res_ulong2_str(GR_DONT_AUDIT, GR_RESOURCE_MSG, task, wanted, restab_log[res], rlim);
63039 +
63040 + return;
63041 +out_rcu_unlock:
63042 + rcu_read_unlock();
63043 + return;
63044 +}
63045 diff --git a/grsecurity/gracl_segv.c b/grsecurity/gracl_segv.c
63046 new file mode 100644
63047 index 0000000..4dcc92a
63048 --- /dev/null
63049 +++ b/grsecurity/gracl_segv.c
63050 @@ -0,0 +1,305 @@
63051 +#include <linux/kernel.h>
63052 +#include <linux/mm.h>
63053 +#include <asm/uaccess.h>
63054 +#include <asm/errno.h>
63055 +#include <asm/mman.h>
63056 +#include <net/sock.h>
63057 +#include <linux/file.h>
63058 +#include <linux/fs.h>
63059 +#include <linux/net.h>
63060 +#include <linux/in.h>
63061 +#include <linux/slab.h>
63062 +#include <linux/types.h>
63063 +#include <linux/sched.h>
63064 +#include <linux/timer.h>
63065 +#include <linux/gracl.h>
63066 +#include <linux/grsecurity.h>
63067 +#include <linux/grinternal.h>
63068 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
63069 +#include <linux/magic.h>
63070 +#include <linux/pagemap.h>
63071 +#include "../fs/btrfs/async-thread.h"
63072 +#include "../fs/btrfs/ctree.h"
63073 +#include "../fs/btrfs/btrfs_inode.h"
63074 +#endif
63075 +
63076 +static struct crash_uid *uid_set;
63077 +static unsigned short uid_used;
63078 +static DEFINE_SPINLOCK(gr_uid_lock);
63079 +extern rwlock_t gr_inode_lock;
63080 +extern struct acl_subject_label *
63081 + lookup_acl_subj_label(const ino_t inode, const dev_t dev,
63082 + struct acl_role_label *role);
63083 +
63084 +static inline dev_t __get_dev(const struct dentry *dentry)
63085 +{
63086 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
63087 + if (dentry->d_sb->s_magic == BTRFS_SUPER_MAGIC)
63088 + return BTRFS_I(dentry->d_inode)->root->anon_dev;
63089 + else
63090 +#endif
63091 + return dentry->d_sb->s_dev;
63092 +}
63093 +
63094 +int
63095 +gr_init_uidset(void)
63096 +{
63097 + uid_set =
63098 + kmalloc(GR_UIDTABLE_MAX * sizeof (struct crash_uid), GFP_KERNEL);
63099 + uid_used = 0;
63100 +
63101 + return uid_set ? 1 : 0;
63102 +}
63103 +
63104 +void
63105 +gr_free_uidset(void)
63106 +{
63107 + if (uid_set)
63108 + kfree(uid_set);
63109 +
63110 + return;
63111 +}
63112 +
63113 +int
63114 +gr_find_uid(const uid_t uid)
63115 +{
63116 + struct crash_uid *tmp = uid_set;
63117 + uid_t buid;
63118 + int low = 0, high = uid_used - 1, mid;
63119 +
63120 + while (high >= low) {
63121 + mid = (low + high) >> 1;
63122 + buid = tmp[mid].uid;
63123 + if (buid == uid)
63124 + return mid;
63125 + if (buid > uid)
63126 + high = mid - 1;
63127 + if (buid < uid)
63128 + low = mid + 1;
63129 + }
63130 +
63131 + return -1;
63132 +}
63133 +
63134 +static __inline__ void
63135 +gr_insertsort(void)
63136 +{
63137 + unsigned short i, j;
63138 + struct crash_uid index;
63139 +
63140 + for (i = 1; i < uid_used; i++) {
63141 + index = uid_set[i];
63142 + j = i;
63143 + while ((j > 0) && uid_set[j - 1].uid > index.uid) {
63144 + uid_set[j] = uid_set[j - 1];
63145 + j--;
63146 + }
63147 + uid_set[j] = index;
63148 + }
63149 +
63150 + return;
63151 +}
63152 +
63153 +static __inline__ void
63154 +gr_insert_uid(const kuid_t kuid, const unsigned long expires)
63155 +{
63156 + int loc;
63157 + uid_t uid = GR_GLOBAL_UID(kuid);
63158 +
63159 + if (uid_used == GR_UIDTABLE_MAX)
63160 + return;
63161 +
63162 + loc = gr_find_uid(uid);
63163 +
63164 + if (loc >= 0) {
63165 + uid_set[loc].expires = expires;
63166 + return;
63167 + }
63168 +
63169 + uid_set[uid_used].uid = uid;
63170 + uid_set[uid_used].expires = expires;
63171 + uid_used++;
63172 +
63173 + gr_insertsort();
63174 +
63175 + return;
63176 +}
63177 +
63178 +void
63179 +gr_remove_uid(const unsigned short loc)
63180 +{
63181 + unsigned short i;
63182 +
63183 + for (i = loc + 1; i < uid_used; i++)
63184 + uid_set[i - 1] = uid_set[i];
63185 +
63186 + uid_used--;
63187 +
63188 + return;
63189 +}
63190 +
63191 +int
63192 +gr_check_crash_uid(const kuid_t kuid)
63193 +{
63194 + int loc;
63195 + int ret = 0;
63196 + uid_t uid;
63197 +
63198 + if (unlikely(!gr_acl_is_enabled()))
63199 + return 0;
63200 +
63201 + uid = GR_GLOBAL_UID(kuid);
63202 +
63203 + spin_lock(&gr_uid_lock);
63204 + loc = gr_find_uid(uid);
63205 +
63206 + if (loc < 0)
63207 + goto out_unlock;
63208 +
63209 + if (time_before_eq(uid_set[loc].expires, get_seconds()))
63210 + gr_remove_uid(loc);
63211 + else
63212 + ret = 1;
63213 +
63214 +out_unlock:
63215 + spin_unlock(&gr_uid_lock);
63216 + return ret;
63217 +}
63218 +
63219 +static __inline__ int
63220 +proc_is_setxid(const struct cred *cred)
63221 +{
63222 + if (!uid_eq(cred->uid, cred->euid) || !uid_eq(cred->uid, cred->suid) ||
63223 + !uid_eq(cred->uid, cred->fsuid))
63224 + return 1;
63225 + if (!gid_eq(cred->gid, cred->egid) || !gid_eq(cred->gid, cred->sgid) ||
63226 + !gid_eq(cred->gid, cred->fsgid))
63227 + return 1;
63228 +
63229 + return 0;
63230 +}
63231 +
63232 +extern int gr_fake_force_sig(int sig, struct task_struct *t);
63233 +
63234 +void
63235 +gr_handle_crash(struct task_struct *task, const int sig)
63236 +{
63237 + struct acl_subject_label *curr;
63238 + struct task_struct *tsk, *tsk2;
63239 + const struct cred *cred;
63240 + const struct cred *cred2;
63241 +
63242 + if (sig != SIGSEGV && sig != SIGKILL && sig != SIGBUS && sig != SIGILL)
63243 + return;
63244 +
63245 + if (unlikely(!gr_acl_is_enabled()))
63246 + return;
63247 +
63248 + curr = task->acl;
63249 +
63250 + if (!(curr->resmask & (1U << GR_CRASH_RES)))
63251 + return;
63252 +
63253 + if (time_before_eq(curr->expires, get_seconds())) {
63254 + curr->expires = 0;
63255 + curr->crashes = 0;
63256 + }
63257 +
63258 + curr->crashes++;
63259 +
63260 + if (!curr->expires)
63261 + curr->expires = get_seconds() + curr->res[GR_CRASH_RES].rlim_max;
63262 +
63263 + if ((curr->crashes >= curr->res[GR_CRASH_RES].rlim_cur) &&
63264 + time_after(curr->expires, get_seconds())) {
63265 + rcu_read_lock();
63266 + cred = __task_cred(task);
63267 + if (gr_is_global_nonroot(cred->uid) && proc_is_setxid(cred)) {
63268 + gr_log_crash1(GR_DONT_AUDIT, GR_SEGVSTART_ACL_MSG, task, curr->res[GR_CRASH_RES].rlim_max);
63269 + spin_lock(&gr_uid_lock);
63270 + gr_insert_uid(cred->uid, curr->expires);
63271 + spin_unlock(&gr_uid_lock);
63272 + curr->expires = 0;
63273 + curr->crashes = 0;
63274 + read_lock(&tasklist_lock);
63275 + do_each_thread(tsk2, tsk) {
63276 + cred2 = __task_cred(tsk);
63277 + if (tsk != task && uid_eq(cred2->uid, cred->uid))
63278 + gr_fake_force_sig(SIGKILL, tsk);
63279 + } while_each_thread(tsk2, tsk);
63280 + read_unlock(&tasklist_lock);
63281 + } else {
63282 + gr_log_crash2(GR_DONT_AUDIT, GR_SEGVNOSUID_ACL_MSG, task, curr->res[GR_CRASH_RES].rlim_max);
63283 + read_lock(&tasklist_lock);
63284 + read_lock(&grsec_exec_file_lock);
63285 + do_each_thread(tsk2, tsk) {
63286 + if (likely(tsk != task)) {
63287 + // if this thread has the same subject as the one that triggered
63288 + // RES_CRASH and it's the same binary, kill it
63289 + if (tsk->acl == task->acl && tsk->exec_file == task->exec_file)
63290 + gr_fake_force_sig(SIGKILL, tsk);
63291 + }
63292 + } while_each_thread(tsk2, tsk);
63293 + read_unlock(&grsec_exec_file_lock);
63294 + read_unlock(&tasklist_lock);
63295 + }
63296 + rcu_read_unlock();
63297 + }
63298 +
63299 + return;
63300 +}
63301 +
63302 +int
63303 +gr_check_crash_exec(const struct file *filp)
63304 +{
63305 + struct acl_subject_label *curr;
63306 +
63307 + if (unlikely(!gr_acl_is_enabled()))
63308 + return 0;
63309 +
63310 + read_lock(&gr_inode_lock);
63311 + curr = lookup_acl_subj_label(filp->f_path.dentry->d_inode->i_ino,
63312 + __get_dev(filp->f_path.dentry),
63313 + current->role);
63314 + read_unlock(&gr_inode_lock);
63315 +
63316 + if (!curr || !(curr->resmask & (1U << GR_CRASH_RES)) ||
63317 + (!curr->crashes && !curr->expires))
63318 + return 0;
63319 +
63320 + if ((curr->crashes >= curr->res[GR_CRASH_RES].rlim_cur) &&
63321 + time_after(curr->expires, get_seconds()))
63322 + return 1;
63323 + else if (time_before_eq(curr->expires, get_seconds())) {
63324 + curr->crashes = 0;
63325 + curr->expires = 0;
63326 + }
63327 +
63328 + return 0;
63329 +}
63330 +
63331 +void
63332 +gr_handle_alertkill(struct task_struct *task)
63333 +{
63334 + struct acl_subject_label *curracl;
63335 + __u32 curr_ip;
63336 + struct task_struct *p, *p2;
63337 +
63338 + if (unlikely(!gr_acl_is_enabled()))
63339 + return;
63340 +
63341 + curracl = task->acl;
63342 + curr_ip = task->signal->curr_ip;
63343 +
63344 + if ((curracl->mode & GR_KILLIPPROC) && curr_ip) {
63345 + read_lock(&tasklist_lock);
63346 + do_each_thread(p2, p) {
63347 + if (p->signal->curr_ip == curr_ip)
63348 + gr_fake_force_sig(SIGKILL, p);
63349 + } while_each_thread(p2, p);
63350 + read_unlock(&tasklist_lock);
63351 + } else if (curracl->mode & GR_KILLPROC)
63352 + gr_fake_force_sig(SIGKILL, task);
63353 +
63354 + return;
63355 +}
63356 diff --git a/grsecurity/gracl_shm.c b/grsecurity/gracl_shm.c
63357 new file mode 100644
63358 index 0000000..98011b0
63359 --- /dev/null
63360 +++ b/grsecurity/gracl_shm.c
63361 @@ -0,0 +1,40 @@
63362 +#include <linux/kernel.h>
63363 +#include <linux/mm.h>
63364 +#include <linux/sched.h>
63365 +#include <linux/file.h>
63366 +#include <linux/ipc.h>
63367 +#include <linux/gracl.h>
63368 +#include <linux/grsecurity.h>
63369 +#include <linux/grinternal.h>
63370 +
63371 +int
63372 +gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
63373 + const time_t shm_createtime, const kuid_t cuid, const int shmid)
63374 +{
63375 + struct task_struct *task;
63376 +
63377 + if (!gr_acl_is_enabled())
63378 + return 1;
63379 +
63380 + rcu_read_lock();
63381 + read_lock(&tasklist_lock);
63382 +
63383 + task = find_task_by_vpid(shm_cprid);
63384 +
63385 + if (unlikely(!task))
63386 + task = find_task_by_vpid(shm_lapid);
63387 +
63388 + if (unlikely(task && (time_before_eq((unsigned long)task->start_time.tv_sec, (unsigned long)shm_createtime) ||
63389 + (task_pid_nr(task) == shm_lapid)) &&
63390 + (task->acl->mode & GR_PROTSHM) &&
63391 + (task->acl != current->acl))) {
63392 + read_unlock(&tasklist_lock);
63393 + rcu_read_unlock();
63394 + gr_log_int3(GR_DONT_AUDIT, GR_SHMAT_ACL_MSG, GR_GLOBAL_UID(cuid), shm_cprid, shmid);
63395 + return 0;
63396 + }
63397 + read_unlock(&tasklist_lock);
63398 + rcu_read_unlock();
63399 +
63400 + return 1;
63401 +}
63402 diff --git a/grsecurity/grsec_chdir.c b/grsecurity/grsec_chdir.c
63403 new file mode 100644
63404 index 0000000..bc0be01
63405 --- /dev/null
63406 +++ b/grsecurity/grsec_chdir.c
63407 @@ -0,0 +1,19 @@
63408 +#include <linux/kernel.h>
63409 +#include <linux/sched.h>
63410 +#include <linux/fs.h>
63411 +#include <linux/file.h>
63412 +#include <linux/grsecurity.h>
63413 +#include <linux/grinternal.h>
63414 +
63415 +void
63416 +gr_log_chdir(const struct dentry *dentry, const struct vfsmount *mnt)
63417 +{
63418 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
63419 + if ((grsec_enable_chdir && grsec_enable_group &&
63420 + in_group_p(grsec_audit_gid)) || (grsec_enable_chdir &&
63421 + !grsec_enable_group)) {
63422 + gr_log_fs_generic(GR_DO_AUDIT, GR_CHDIR_AUDIT_MSG, dentry, mnt);
63423 + }
63424 +#endif
63425 + return;
63426 +}
63427 diff --git a/grsecurity/grsec_chroot.c b/grsecurity/grsec_chroot.c
63428 new file mode 100644
63429 index 0000000..bd6e105
63430 --- /dev/null
63431 +++ b/grsecurity/grsec_chroot.c
63432 @@ -0,0 +1,370 @@
63433 +#include <linux/kernel.h>
63434 +#include <linux/module.h>
63435 +#include <linux/sched.h>
63436 +#include <linux/file.h>
63437 +#include <linux/fs.h>
63438 +#include <linux/mount.h>
63439 +#include <linux/types.h>
63440 +#include "../fs/mount.h"
63441 +#include <linux/grsecurity.h>
63442 +#include <linux/grinternal.h>
63443 +
63444 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
63445 +static int gr_init_ran;
63446 +#endif
63447 +
63448 +void gr_set_chroot_entries(struct task_struct *task, const struct path *path)
63449 +{
63450 +#ifdef CONFIG_GRKERNSEC
63451 + if (task_pid_nr(task) > 1 && path->dentry != init_task.fs->root.dentry &&
63452 + path->dentry != task->nsproxy->mnt_ns->root->mnt.mnt_root
63453 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
63454 + && gr_init_ran
63455 +#endif
63456 + )
63457 + task->gr_is_chrooted = 1;
63458 + else {
63459 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
63460 + if (task_pid_nr(task) == 1 && !gr_init_ran)
63461 + gr_init_ran = 1;
63462 +#endif
63463 + task->gr_is_chrooted = 0;
63464 + }
63465 +
63466 + task->gr_chroot_dentry = path->dentry;
63467 +#endif
63468 + return;
63469 +}
63470 +
63471 +void gr_clear_chroot_entries(struct task_struct *task)
63472 +{
63473 +#ifdef CONFIG_GRKERNSEC
63474 + task->gr_is_chrooted = 0;
63475 + task->gr_chroot_dentry = NULL;
63476 +#endif
63477 + return;
63478 +}
63479 +
63480 +int
63481 +gr_handle_chroot_unix(const pid_t pid)
63482 +{
63483 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
63484 + struct task_struct *p;
63485 +
63486 + if (unlikely(!grsec_enable_chroot_unix))
63487 + return 1;
63488 +
63489 + if (likely(!proc_is_chrooted(current)))
63490 + return 1;
63491 +
63492 + rcu_read_lock();
63493 + read_lock(&tasklist_lock);
63494 + p = find_task_by_vpid_unrestricted(pid);
63495 + if (unlikely(p && !have_same_root(current, p))) {
63496 + read_unlock(&tasklist_lock);
63497 + rcu_read_unlock();
63498 + gr_log_noargs(GR_DONT_AUDIT, GR_UNIX_CHROOT_MSG);
63499 + return 0;
63500 + }
63501 + read_unlock(&tasklist_lock);
63502 + rcu_read_unlock();
63503 +#endif
63504 + return 1;
63505 +}
63506 +
63507 +int
63508 +gr_handle_chroot_nice(void)
63509 +{
63510 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
63511 + if (grsec_enable_chroot_nice && proc_is_chrooted(current)) {
63512 + gr_log_noargs(GR_DONT_AUDIT, GR_NICE_CHROOT_MSG);
63513 + return -EPERM;
63514 + }
63515 +#endif
63516 + return 0;
63517 +}
63518 +
63519 +int
63520 +gr_handle_chroot_setpriority(struct task_struct *p, const int niceval)
63521 +{
63522 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
63523 + if (grsec_enable_chroot_nice && (niceval < task_nice(p))
63524 + && proc_is_chrooted(current)) {
63525 + gr_log_str_int(GR_DONT_AUDIT, GR_PRIORITY_CHROOT_MSG, p->comm, task_pid_nr(p));
63526 + return -EACCES;
63527 + }
63528 +#endif
63529 + return 0;
63530 +}
63531 +
63532 +int
63533 +gr_handle_chroot_fowner(struct pid *pid, enum pid_type type)
63534 +{
63535 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
63536 + struct task_struct *p;
63537 + int ret = 0;
63538 + if (!grsec_enable_chroot_findtask || !proc_is_chrooted(current) || !pid)
63539 + return ret;
63540 +
63541 + read_lock(&tasklist_lock);
63542 + do_each_pid_task(pid, type, p) {
63543 + if (!have_same_root(current, p)) {
63544 + ret = 1;
63545 + goto out;
63546 + }
63547 + } while_each_pid_task(pid, type, p);
63548 +out:
63549 + read_unlock(&tasklist_lock);
63550 + return ret;
63551 +#endif
63552 + return 0;
63553 +}
63554 +
63555 +int
63556 +gr_pid_is_chrooted(struct task_struct *p)
63557 +{
63558 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
63559 + if (!grsec_enable_chroot_findtask || !proc_is_chrooted(current) || p == NULL)
63560 + return 0;
63561 +
63562 + if ((p->exit_state & (EXIT_ZOMBIE | EXIT_DEAD)) ||
63563 + !have_same_root(current, p)) {
63564 + return 1;
63565 + }
63566 +#endif
63567 + return 0;
63568 +}
63569 +
63570 +EXPORT_SYMBOL(gr_pid_is_chrooted);
63571 +
63572 +#if defined(CONFIG_GRKERNSEC_CHROOT_DOUBLE) || defined(CONFIG_GRKERNSEC_CHROOT_FCHDIR)
63573 +int gr_is_outside_chroot(const struct dentry *u_dentry, const struct vfsmount *u_mnt)
63574 +{
63575 + struct path path, currentroot;
63576 + int ret = 0;
63577 +
63578 + path.dentry = (struct dentry *)u_dentry;
63579 + path.mnt = (struct vfsmount *)u_mnt;
63580 + get_fs_root(current->fs, &currentroot);
63581 + if (path_is_under(&path, &currentroot))
63582 + ret = 1;
63583 + path_put(&currentroot);
63584 +
63585 + return ret;
63586 +}
63587 +#endif
63588 +
63589 +int
63590 +gr_chroot_fchdir(struct dentry *u_dentry, struct vfsmount *u_mnt)
63591 +{
63592 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
63593 + if (!grsec_enable_chroot_fchdir)
63594 + return 1;
63595 +
63596 + if (!proc_is_chrooted(current))
63597 + return 1;
63598 + else if (!gr_is_outside_chroot(u_dentry, u_mnt)) {
63599 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHROOT_FCHDIR_MSG, u_dentry, u_mnt);
63600 + return 0;
63601 + }
63602 +#endif
63603 + return 1;
63604 +}
63605 +
63606 +int
63607 +gr_chroot_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
63608 + const time_t shm_createtime)
63609 +{
63610 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
63611 + struct task_struct *p;
63612 + time_t starttime;
63613 +
63614 + if (unlikely(!grsec_enable_chroot_shmat))
63615 + return 1;
63616 +
63617 + if (likely(!proc_is_chrooted(current)))
63618 + return 1;
63619 +
63620 + rcu_read_lock();
63621 + read_lock(&tasklist_lock);
63622 +
63623 + if ((p = find_task_by_vpid_unrestricted(shm_cprid))) {
63624 + starttime = p->start_time.tv_sec;
63625 + if (time_before_eq((unsigned long)starttime, (unsigned long)shm_createtime)) {
63626 + if (have_same_root(current, p)) {
63627 + goto allow;
63628 + } else {
63629 + read_unlock(&tasklist_lock);
63630 + rcu_read_unlock();
63631 + gr_log_noargs(GR_DONT_AUDIT, GR_SHMAT_CHROOT_MSG);
63632 + return 0;
63633 + }
63634 + }
63635 + /* creator exited, pid reuse, fall through to next check */
63636 + }
63637 + if ((p = find_task_by_vpid_unrestricted(shm_lapid))) {
63638 + if (unlikely(!have_same_root(current, p))) {
63639 + read_unlock(&tasklist_lock);
63640 + rcu_read_unlock();
63641 + gr_log_noargs(GR_DONT_AUDIT, GR_SHMAT_CHROOT_MSG);
63642 + return 0;
63643 + }
63644 + }
63645 +
63646 +allow:
63647 + read_unlock(&tasklist_lock);
63648 + rcu_read_unlock();
63649 +#endif
63650 + return 1;
63651 +}
63652 +
63653 +void
63654 +gr_log_chroot_exec(const struct dentry *dentry, const struct vfsmount *mnt)
63655 +{
63656 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
63657 + if (grsec_enable_chroot_execlog && proc_is_chrooted(current))
63658 + gr_log_fs_generic(GR_DO_AUDIT, GR_EXEC_CHROOT_MSG, dentry, mnt);
63659 +#endif
63660 + return;
63661 +}
63662 +
63663 +int
63664 +gr_handle_chroot_mknod(const struct dentry *dentry,
63665 + const struct vfsmount *mnt, const int mode)
63666 +{
63667 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
63668 + if (grsec_enable_chroot_mknod && !S_ISFIFO(mode) && !S_ISREG(mode) &&
63669 + proc_is_chrooted(current)) {
63670 + gr_log_fs_generic(GR_DONT_AUDIT, GR_MKNOD_CHROOT_MSG, dentry, mnt);
63671 + return -EPERM;
63672 + }
63673 +#endif
63674 + return 0;
63675 +}
63676 +
63677 +int
63678 +gr_handle_chroot_mount(const struct dentry *dentry,
63679 + const struct vfsmount *mnt, const char *dev_name)
63680 +{
63681 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
63682 + if (grsec_enable_chroot_mount && proc_is_chrooted(current)) {
63683 + gr_log_str_fs(GR_DONT_AUDIT, GR_MOUNT_CHROOT_MSG, dev_name ? dev_name : "none", dentry, mnt);
63684 + return -EPERM;
63685 + }
63686 +#endif
63687 + return 0;
63688 +}
63689 +
63690 +int
63691 +gr_handle_chroot_pivot(void)
63692 +{
63693 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
63694 + if (grsec_enable_chroot_pivot && proc_is_chrooted(current)) {
63695 + gr_log_noargs(GR_DONT_AUDIT, GR_PIVOT_CHROOT_MSG);
63696 + return -EPERM;
63697 + }
63698 +#endif
63699 + return 0;
63700 +}
63701 +
63702 +int
63703 +gr_handle_chroot_chroot(const struct dentry *dentry, const struct vfsmount *mnt)
63704 +{
63705 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
63706 + if (grsec_enable_chroot_double && proc_is_chrooted(current) &&
63707 + !gr_is_outside_chroot(dentry, mnt)) {
63708 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHROOT_CHROOT_MSG, dentry, mnt);
63709 + return -EPERM;
63710 + }
63711 +#endif
63712 + return 0;
63713 +}
63714 +
63715 +extern const char *captab_log[];
63716 +extern int captab_log_entries;
63717 +
63718 +int
63719 +gr_task_chroot_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
63720 +{
63721 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
63722 + if (grsec_enable_chroot_caps && proc_is_chrooted(task)) {
63723 + kernel_cap_t chroot_caps = GR_CHROOT_CAPS;
63724 + if (cap_raised(chroot_caps, cap)) {
63725 + if (cap_raised(cred->cap_effective, cap) && cap < captab_log_entries) {
63726 + gr_log_cap(GR_DONT_AUDIT, GR_CAP_CHROOT_MSG, task, captab_log[cap]);
63727 + }
63728 + return 0;
63729 + }
63730 + }
63731 +#endif
63732 + return 1;
63733 +}
63734 +
63735 +int
63736 +gr_chroot_is_capable(const int cap)
63737 +{
63738 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
63739 + return gr_task_chroot_is_capable(current, current_cred(), cap);
63740 +#endif
63741 + return 1;
63742 +}
63743 +
63744 +int
63745 +gr_task_chroot_is_capable_nolog(const struct task_struct *task, const int cap)
63746 +{
63747 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
63748 + if (grsec_enable_chroot_caps && proc_is_chrooted(task)) {
63749 + kernel_cap_t chroot_caps = GR_CHROOT_CAPS;
63750 + if (cap_raised(chroot_caps, cap)) {
63751 + return 0;
63752 + }
63753 + }
63754 +#endif
63755 + return 1;
63756 +}
63757 +
63758 +int
63759 +gr_chroot_is_capable_nolog(const int cap)
63760 +{
63761 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
63762 + return gr_task_chroot_is_capable_nolog(current, cap);
63763 +#endif
63764 + return 1;
63765 +}
63766 +
63767 +int
63768 +gr_handle_chroot_sysctl(const int op)
63769 +{
63770 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
63771 + if (grsec_enable_chroot_sysctl && (op & MAY_WRITE) &&
63772 + proc_is_chrooted(current))
63773 + return -EACCES;
63774 +#endif
63775 + return 0;
63776 +}
63777 +
63778 +void
63779 +gr_handle_chroot_chdir(const struct path *path)
63780 +{
63781 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
63782 + if (grsec_enable_chroot_chdir)
63783 + set_fs_pwd(current->fs, path);
63784 +#endif
63785 + return;
63786 +}
63787 +
63788 +int
63789 +gr_handle_chroot_chmod(const struct dentry *dentry,
63790 + const struct vfsmount *mnt, const int mode)
63791 +{
63792 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
63793 + /* allow chmod +s on directories, but not files */
63794 + if (grsec_enable_chroot_chmod && !S_ISDIR(dentry->d_inode->i_mode) &&
63795 + ((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))) &&
63796 + proc_is_chrooted(current)) {
63797 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHMOD_CHROOT_MSG, dentry, mnt);
63798 + return -EPERM;
63799 + }
63800 +#endif
63801 + return 0;
63802 +}
63803 diff --git a/grsecurity/grsec_disabled.c b/grsecurity/grsec_disabled.c
63804 new file mode 100644
63805 index 0000000..ce65ceb
63806 --- /dev/null
63807 +++ b/grsecurity/grsec_disabled.c
63808 @@ -0,0 +1,434 @@
63809 +#include <linux/kernel.h>
63810 +#include <linux/module.h>
63811 +#include <linux/sched.h>
63812 +#include <linux/file.h>
63813 +#include <linux/fs.h>
63814 +#include <linux/kdev_t.h>
63815 +#include <linux/net.h>
63816 +#include <linux/in.h>
63817 +#include <linux/ip.h>
63818 +#include <linux/skbuff.h>
63819 +#include <linux/sysctl.h>
63820 +
63821 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
63822 +void
63823 +pax_set_initial_flags(struct linux_binprm *bprm)
63824 +{
63825 + return;
63826 +}
63827 +#endif
63828 +
63829 +#ifdef CONFIG_SYSCTL
63830 +__u32
63831 +gr_handle_sysctl(const struct ctl_table * table, const int op)
63832 +{
63833 + return 0;
63834 +}
63835 +#endif
63836 +
63837 +#ifdef CONFIG_TASKSTATS
63838 +int gr_is_taskstats_denied(int pid)
63839 +{
63840 + return 0;
63841 +}
63842 +#endif
63843 +
63844 +int
63845 +gr_acl_is_enabled(void)
63846 +{
63847 + return 0;
63848 +}
63849 +
63850 +void
63851 +gr_handle_proc_create(const struct dentry *dentry, const struct inode *inode)
63852 +{
63853 + return;
63854 +}
63855 +
63856 +int
63857 +gr_handle_rawio(const struct inode *inode)
63858 +{
63859 + return 0;
63860 +}
63861 +
63862 +void
63863 +gr_acl_handle_psacct(struct task_struct *task, const long code)
63864 +{
63865 + return;
63866 +}
63867 +
63868 +int
63869 +gr_handle_ptrace(struct task_struct *task, const long request)
63870 +{
63871 + return 0;
63872 +}
63873 +
63874 +int
63875 +gr_handle_proc_ptrace(struct task_struct *task)
63876 +{
63877 + return 0;
63878 +}
63879 +
63880 +int
63881 +gr_set_acls(const int type)
63882 +{
63883 + return 0;
63884 +}
63885 +
63886 +int
63887 +gr_check_hidden_task(const struct task_struct *tsk)
63888 +{
63889 + return 0;
63890 +}
63891 +
63892 +int
63893 +gr_check_protected_task(const struct task_struct *task)
63894 +{
63895 + return 0;
63896 +}
63897 +
63898 +int
63899 +gr_check_protected_task_fowner(struct pid *pid, enum pid_type type)
63900 +{
63901 + return 0;
63902 +}
63903 +
63904 +void
63905 +gr_copy_label(struct task_struct *tsk)
63906 +{
63907 + return;
63908 +}
63909 +
63910 +void
63911 +gr_set_pax_flags(struct task_struct *task)
63912 +{
63913 + return;
63914 +}
63915 +
63916 +int
63917 +gr_set_proc_label(const struct dentry *dentry, const struct vfsmount *mnt,
63918 + const int unsafe_share)
63919 +{
63920 + return 0;
63921 +}
63922 +
63923 +void
63924 +gr_handle_delete(const ino_t ino, const dev_t dev)
63925 +{
63926 + return;
63927 +}
63928 +
63929 +void
63930 +gr_handle_create(const struct dentry *dentry, const struct vfsmount *mnt)
63931 +{
63932 + return;
63933 +}
63934 +
63935 +void
63936 +gr_handle_crash(struct task_struct *task, const int sig)
63937 +{
63938 + return;
63939 +}
63940 +
63941 +int
63942 +gr_check_crash_exec(const struct file *filp)
63943 +{
63944 + return 0;
63945 +}
63946 +
63947 +int
63948 +gr_check_crash_uid(const kuid_t uid)
63949 +{
63950 + return 0;
63951 +}
63952 +
63953 +void
63954 +gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
63955 + struct dentry *old_dentry,
63956 + struct dentry *new_dentry,
63957 + struct vfsmount *mnt, const __u8 replace)
63958 +{
63959 + return;
63960 +}
63961 +
63962 +int
63963 +gr_search_socket(const int family, const int type, const int protocol)
63964 +{
63965 + return 1;
63966 +}
63967 +
63968 +int
63969 +gr_search_connectbind(const int mode, const struct socket *sock,
63970 + const struct sockaddr_in *addr)
63971 +{
63972 + return 0;
63973 +}
63974 +
63975 +void
63976 +gr_handle_alertkill(struct task_struct *task)
63977 +{
63978 + return;
63979 +}
63980 +
63981 +__u32
63982 +gr_acl_handle_execve(const struct dentry * dentry, const struct vfsmount * mnt)
63983 +{
63984 + return 1;
63985 +}
63986 +
63987 +__u32
63988 +gr_acl_handle_hidden_file(const struct dentry * dentry,
63989 + const struct vfsmount * mnt)
63990 +{
63991 + return 1;
63992 +}
63993 +
63994 +__u32
63995 +gr_acl_handle_open(const struct dentry * dentry, const struct vfsmount * mnt,
63996 + int acc_mode)
63997 +{
63998 + return 1;
63999 +}
64000 +
64001 +__u32
64002 +gr_acl_handle_rmdir(const struct dentry * dentry, const struct vfsmount * mnt)
64003 +{
64004 + return 1;
64005 +}
64006 +
64007 +__u32
64008 +gr_acl_handle_unlink(const struct dentry * dentry, const struct vfsmount * mnt)
64009 +{
64010 + return 1;
64011 +}
64012 +
64013 +int
64014 +gr_acl_handle_mmap(const struct file *file, const unsigned long prot,
64015 + unsigned int *vm_flags)
64016 +{
64017 + return 1;
64018 +}
64019 +
64020 +__u32
64021 +gr_acl_handle_truncate(const struct dentry * dentry,
64022 + const struct vfsmount * mnt)
64023 +{
64024 + return 1;
64025 +}
64026 +
64027 +__u32
64028 +gr_acl_handle_utime(const struct dentry * dentry, const struct vfsmount * mnt)
64029 +{
64030 + return 1;
64031 +}
64032 +
64033 +__u32
64034 +gr_acl_handle_access(const struct dentry * dentry,
64035 + const struct vfsmount * mnt, const int fmode)
64036 +{
64037 + return 1;
64038 +}
64039 +
64040 +__u32
64041 +gr_acl_handle_chmod(const struct dentry * dentry, const struct vfsmount * mnt,
64042 + umode_t *mode)
64043 +{
64044 + return 1;
64045 +}
64046 +
64047 +__u32
64048 +gr_acl_handle_chown(const struct dentry * dentry, const struct vfsmount * mnt)
64049 +{
64050 + return 1;
64051 +}
64052 +
64053 +__u32
64054 +gr_acl_handle_setxattr(const struct dentry * dentry, const struct vfsmount * mnt)
64055 +{
64056 + return 1;
64057 +}
64058 +
64059 +void
64060 +grsecurity_init(void)
64061 +{
64062 + return;
64063 +}
64064 +
64065 +umode_t gr_acl_umask(void)
64066 +{
64067 + return 0;
64068 +}
64069 +
64070 +__u32
64071 +gr_acl_handle_mknod(const struct dentry * new_dentry,
64072 + const struct dentry * parent_dentry,
64073 + const struct vfsmount * parent_mnt,
64074 + const int mode)
64075 +{
64076 + return 1;
64077 +}
64078 +
64079 +__u32
64080 +gr_acl_handle_mkdir(const struct dentry * new_dentry,
64081 + const struct dentry * parent_dentry,
64082 + const struct vfsmount * parent_mnt)
64083 +{
64084 + return 1;
64085 +}
64086 +
64087 +__u32
64088 +gr_acl_handle_symlink(const struct dentry * new_dentry,
64089 + const struct dentry * parent_dentry,
64090 + const struct vfsmount * parent_mnt, const struct filename *from)
64091 +{
64092 + return 1;
64093 +}
64094 +
64095 +__u32
64096 +gr_acl_handle_link(const struct dentry * new_dentry,
64097 + const struct dentry * parent_dentry,
64098 + const struct vfsmount * parent_mnt,
64099 + const struct dentry * old_dentry,
64100 + const struct vfsmount * old_mnt, const struct filename *to)
64101 +{
64102 + return 1;
64103 +}
64104 +
64105 +int
64106 +gr_acl_handle_rename(const struct dentry *new_dentry,
64107 + const struct dentry *parent_dentry,
64108 + const struct vfsmount *parent_mnt,
64109 + const struct dentry *old_dentry,
64110 + const struct inode *old_parent_inode,
64111 + const struct vfsmount *old_mnt, const struct filename *newname)
64112 +{
64113 + return 0;
64114 +}
64115 +
64116 +int
64117 +gr_acl_handle_filldir(const struct file *file, const char *name,
64118 + const int namelen, const ino_t ino)
64119 +{
64120 + return 1;
64121 +}
64122 +
64123 +int
64124 +gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
64125 + const time_t shm_createtime, const kuid_t cuid, const int shmid)
64126 +{
64127 + return 1;
64128 +}
64129 +
64130 +int
64131 +gr_search_bind(const struct socket *sock, const struct sockaddr_in *addr)
64132 +{
64133 + return 0;
64134 +}
64135 +
64136 +int
64137 +gr_search_accept(const struct socket *sock)
64138 +{
64139 + return 0;
64140 +}
64141 +
64142 +int
64143 +gr_search_listen(const struct socket *sock)
64144 +{
64145 + return 0;
64146 +}
64147 +
64148 +int
64149 +gr_search_connect(const struct socket *sock, const struct sockaddr_in *addr)
64150 +{
64151 + return 0;
64152 +}
64153 +
64154 +__u32
64155 +gr_acl_handle_unix(const struct dentry * dentry, const struct vfsmount * mnt)
64156 +{
64157 + return 1;
64158 +}
64159 +
64160 +__u32
64161 +gr_acl_handle_creat(const struct dentry * dentry,
64162 + const struct dentry * p_dentry,
64163 + const struct vfsmount * p_mnt, int open_flags, int acc_mode,
64164 + const int imode)
64165 +{
64166 + return 1;
64167 +}
64168 +
64169 +void
64170 +gr_acl_handle_exit(void)
64171 +{
64172 + return;
64173 +}
64174 +
64175 +int
64176 +gr_acl_handle_mprotect(const struct file *file, const unsigned long prot)
64177 +{
64178 + return 1;
64179 +}
64180 +
64181 +void
64182 +gr_set_role_label(const kuid_t uid, const kgid_t gid)
64183 +{
64184 + return;
64185 +}
64186 +
64187 +int
64188 +gr_acl_handle_procpidmem(const struct task_struct *task)
64189 +{
64190 + return 0;
64191 +}
64192 +
64193 +int
64194 +gr_search_udp_recvmsg(const struct sock *sk, const struct sk_buff *skb)
64195 +{
64196 + return 0;
64197 +}
64198 +
64199 +int
64200 +gr_search_udp_sendmsg(const struct sock *sk, const struct sockaddr_in *addr)
64201 +{
64202 + return 0;
64203 +}
64204 +
64205 +void
64206 +gr_set_kernel_label(struct task_struct *task)
64207 +{
64208 + return;
64209 +}
64210 +
64211 +int
64212 +gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs)
64213 +{
64214 + return 0;
64215 +}
64216 +
64217 +int
64218 +gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs)
64219 +{
64220 + return 0;
64221 +}
64222 +
64223 +int gr_acl_enable_at_secure(void)
64224 +{
64225 + return 0;
64226 +}
64227 +
64228 +dev_t gr_get_dev_from_dentry(struct dentry *dentry)
64229 +{
64230 + return dentry->d_sb->s_dev;
64231 +}
64232 +
64233 +void gr_put_exec_file(struct task_struct *task)
64234 +{
64235 + return;
64236 +}
64237 +
64238 +EXPORT_SYMBOL(gr_set_kernel_label);
64239 +#ifdef CONFIG_SECURITY
64240 +EXPORT_SYMBOL(gr_check_user_change);
64241 +EXPORT_SYMBOL(gr_check_group_change);
64242 +#endif
64243 diff --git a/grsecurity/grsec_exec.c b/grsecurity/grsec_exec.c
64244 new file mode 100644
64245 index 0000000..387032b
64246 --- /dev/null
64247 +++ b/grsecurity/grsec_exec.c
64248 @@ -0,0 +1,187 @@
64249 +#include <linux/kernel.h>
64250 +#include <linux/sched.h>
64251 +#include <linux/file.h>
64252 +#include <linux/binfmts.h>
64253 +#include <linux/fs.h>
64254 +#include <linux/types.h>
64255 +#include <linux/grdefs.h>
64256 +#include <linux/grsecurity.h>
64257 +#include <linux/grinternal.h>
64258 +#include <linux/capability.h>
64259 +#include <linux/module.h>
64260 +#include <linux/compat.h>
64261 +
64262 +#include <asm/uaccess.h>
64263 +
64264 +#ifdef CONFIG_GRKERNSEC_EXECLOG
64265 +static char gr_exec_arg_buf[132];
64266 +static DEFINE_MUTEX(gr_exec_arg_mutex);
64267 +#endif
64268 +
64269 +struct user_arg_ptr {
64270 +#ifdef CONFIG_COMPAT
64271 + bool is_compat;
64272 +#endif
64273 + union {
64274 + const char __user *const __user *native;
64275 +#ifdef CONFIG_COMPAT
64276 + const compat_uptr_t __user *compat;
64277 +#endif
64278 + } ptr;
64279 +};
64280 +
64281 +extern const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr);
64282 +
64283 +void
64284 +gr_handle_exec_args(struct linux_binprm *bprm, struct user_arg_ptr argv)
64285 +{
64286 +#ifdef CONFIG_GRKERNSEC_EXECLOG
64287 + char *grarg = gr_exec_arg_buf;
64288 + unsigned int i, x, execlen = 0;
64289 + char c;
64290 +
64291 + if (!((grsec_enable_execlog && grsec_enable_group &&
64292 + in_group_p(grsec_audit_gid))
64293 + || (grsec_enable_execlog && !grsec_enable_group)))
64294 + return;
64295 +
64296 + mutex_lock(&gr_exec_arg_mutex);
64297 + memset(grarg, 0, sizeof(gr_exec_arg_buf));
64298 +
64299 + for (i = 0; i < bprm->argc && execlen < 128; i++) {
64300 + const char __user *p;
64301 + unsigned int len;
64302 +
64303 + p = get_user_arg_ptr(argv, i);
64304 + if (IS_ERR(p))
64305 + goto log;
64306 +
64307 + len = strnlen_user(p, 128 - execlen);
64308 + if (len > 128 - execlen)
64309 + len = 128 - execlen;
64310 + else if (len > 0)
64311 + len--;
64312 + if (copy_from_user(grarg + execlen, p, len))
64313 + goto log;
64314 +
64315 + /* rewrite unprintable characters */
64316 + for (x = 0; x < len; x++) {
64317 + c = *(grarg + execlen + x);
64318 + if (c < 32 || c > 126)
64319 + *(grarg + execlen + x) = ' ';
64320 + }
64321 +
64322 + execlen += len;
64323 + *(grarg + execlen) = ' ';
64324 + *(grarg + execlen + 1) = '\0';
64325 + execlen++;
64326 + }
64327 +
64328 + log:
64329 + gr_log_fs_str(GR_DO_AUDIT, GR_EXEC_AUDIT_MSG, bprm->file->f_path.dentry,
64330 + bprm->file->f_path.mnt, grarg);
64331 + mutex_unlock(&gr_exec_arg_mutex);
64332 +#endif
64333 + return;
64334 +}
64335 +
64336 +#ifdef CONFIG_GRKERNSEC
64337 +extern int gr_acl_is_capable(const int cap);
64338 +extern int gr_acl_is_capable_nolog(const int cap);
64339 +extern int gr_task_acl_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
64340 +extern int gr_task_acl_is_capable_nolog(const struct task_struct *task, const int cap);
64341 +extern int gr_chroot_is_capable(const int cap);
64342 +extern int gr_chroot_is_capable_nolog(const int cap);
64343 +extern int gr_task_chroot_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
64344 +extern int gr_task_chroot_is_capable_nolog(const struct task_struct *task, const int cap);
64345 +#endif
64346 +
64347 +const char *captab_log[] = {
64348 + "CAP_CHOWN",
64349 + "CAP_DAC_OVERRIDE",
64350 + "CAP_DAC_READ_SEARCH",
64351 + "CAP_FOWNER",
64352 + "CAP_FSETID",
64353 + "CAP_KILL",
64354 + "CAP_SETGID",
64355 + "CAP_SETUID",
64356 + "CAP_SETPCAP",
64357 + "CAP_LINUX_IMMUTABLE",
64358 + "CAP_NET_BIND_SERVICE",
64359 + "CAP_NET_BROADCAST",
64360 + "CAP_NET_ADMIN",
64361 + "CAP_NET_RAW",
64362 + "CAP_IPC_LOCK",
64363 + "CAP_IPC_OWNER",
64364 + "CAP_SYS_MODULE",
64365 + "CAP_SYS_RAWIO",
64366 + "CAP_SYS_CHROOT",
64367 + "CAP_SYS_PTRACE",
64368 + "CAP_SYS_PACCT",
64369 + "CAP_SYS_ADMIN",
64370 + "CAP_SYS_BOOT",
64371 + "CAP_SYS_NICE",
64372 + "CAP_SYS_RESOURCE",
64373 + "CAP_SYS_TIME",
64374 + "CAP_SYS_TTY_CONFIG",
64375 + "CAP_MKNOD",
64376 + "CAP_LEASE",
64377 + "CAP_AUDIT_WRITE",
64378 + "CAP_AUDIT_CONTROL",
64379 + "CAP_SETFCAP",
64380 + "CAP_MAC_OVERRIDE",
64381 + "CAP_MAC_ADMIN",
64382 + "CAP_SYSLOG",
64383 + "CAP_WAKE_ALARM"
64384 +};
64385 +
64386 +int captab_log_entries = sizeof(captab_log)/sizeof(captab_log[0]);
64387 +
64388 +int gr_is_capable(const int cap)
64389 +{
64390 +#ifdef CONFIG_GRKERNSEC
64391 + if (gr_acl_is_capable(cap) && gr_chroot_is_capable(cap))
64392 + return 1;
64393 + return 0;
64394 +#else
64395 + return 1;
64396 +#endif
64397 +}
64398 +
64399 +int gr_task_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
64400 +{
64401 +#ifdef CONFIG_GRKERNSEC
64402 + if (gr_task_acl_is_capable(task, cred, cap) && gr_task_chroot_is_capable(task, cred, cap))
64403 + return 1;
64404 + return 0;
64405 +#else
64406 + return 1;
64407 +#endif
64408 +}
64409 +
64410 +int gr_is_capable_nolog(const int cap)
64411 +{
64412 +#ifdef CONFIG_GRKERNSEC
64413 + if (gr_acl_is_capable_nolog(cap) && gr_chroot_is_capable_nolog(cap))
64414 + return 1;
64415 + return 0;
64416 +#else
64417 + return 1;
64418 +#endif
64419 +}
64420 +
64421 +int gr_task_is_capable_nolog(const struct task_struct *task, const int cap)
64422 +{
64423 +#ifdef CONFIG_GRKERNSEC
64424 + if (gr_task_acl_is_capable_nolog(task, cap) && gr_task_chroot_is_capable_nolog(task, cap))
64425 + return 1;
64426 + return 0;
64427 +#else
64428 + return 1;
64429 +#endif
64430 +}
64431 +
64432 +EXPORT_SYMBOL(gr_is_capable);
64433 +EXPORT_SYMBOL(gr_is_capable_nolog);
64434 +EXPORT_SYMBOL(gr_task_is_capable);
64435 +EXPORT_SYMBOL(gr_task_is_capable_nolog);
64436 diff --git a/grsecurity/grsec_fifo.c b/grsecurity/grsec_fifo.c
64437 new file mode 100644
64438 index 0000000..06cc6ea
64439 --- /dev/null
64440 +++ b/grsecurity/grsec_fifo.c
64441 @@ -0,0 +1,24 @@
64442 +#include <linux/kernel.h>
64443 +#include <linux/sched.h>
64444 +#include <linux/fs.h>
64445 +#include <linux/file.h>
64446 +#include <linux/grinternal.h>
64447 +
64448 +int
64449 +gr_handle_fifo(const struct dentry *dentry, const struct vfsmount *mnt,
64450 + const struct dentry *dir, const int flag, const int acc_mode)
64451 +{
64452 +#ifdef CONFIG_GRKERNSEC_FIFO
64453 + const struct cred *cred = current_cred();
64454 +
64455 + if (grsec_enable_fifo && S_ISFIFO(dentry->d_inode->i_mode) &&
64456 + !(flag & O_EXCL) && (dir->d_inode->i_mode & S_ISVTX) &&
64457 + !uid_eq(dentry->d_inode->i_uid, dir->d_inode->i_uid) &&
64458 + !uid_eq(cred->fsuid, dentry->d_inode->i_uid)) {
64459 + if (!inode_permission(dentry->d_inode, acc_mode))
64460 + 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));
64461 + return -EACCES;
64462 + }
64463 +#endif
64464 + return 0;
64465 +}
64466 diff --git a/grsecurity/grsec_fork.c b/grsecurity/grsec_fork.c
64467 new file mode 100644
64468 index 0000000..8ca18bf
64469 --- /dev/null
64470 +++ b/grsecurity/grsec_fork.c
64471 @@ -0,0 +1,23 @@
64472 +#include <linux/kernel.h>
64473 +#include <linux/sched.h>
64474 +#include <linux/grsecurity.h>
64475 +#include <linux/grinternal.h>
64476 +#include <linux/errno.h>
64477 +
64478 +void
64479 +gr_log_forkfail(const int retval)
64480 +{
64481 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
64482 + if (grsec_enable_forkfail && (retval == -EAGAIN || retval == -ENOMEM)) {
64483 + switch (retval) {
64484 + case -EAGAIN:
64485 + gr_log_str(GR_DONT_AUDIT, GR_FAILFORK_MSG, "EAGAIN");
64486 + break;
64487 + case -ENOMEM:
64488 + gr_log_str(GR_DONT_AUDIT, GR_FAILFORK_MSG, "ENOMEM");
64489 + break;
64490 + }
64491 + }
64492 +#endif
64493 + return;
64494 +}
64495 diff --git a/grsecurity/grsec_init.c b/grsecurity/grsec_init.c
64496 new file mode 100644
64497 index 0000000..a862e9f
64498 --- /dev/null
64499 +++ b/grsecurity/grsec_init.c
64500 @@ -0,0 +1,283 @@
64501 +#include <linux/kernel.h>
64502 +#include <linux/sched.h>
64503 +#include <linux/mm.h>
64504 +#include <linux/gracl.h>
64505 +#include <linux/slab.h>
64506 +#include <linux/vmalloc.h>
64507 +#include <linux/percpu.h>
64508 +#include <linux/module.h>
64509 +
64510 +int grsec_enable_ptrace_readexec;
64511 +int grsec_enable_setxid;
64512 +int grsec_enable_symlinkown;
64513 +kgid_t grsec_symlinkown_gid;
64514 +int grsec_enable_brute;
64515 +int grsec_enable_link;
64516 +int grsec_enable_dmesg;
64517 +int grsec_enable_harden_ptrace;
64518 +int grsec_enable_fifo;
64519 +int grsec_enable_execlog;
64520 +int grsec_enable_signal;
64521 +int grsec_enable_forkfail;
64522 +int grsec_enable_audit_ptrace;
64523 +int grsec_enable_time;
64524 +int grsec_enable_audit_textrel;
64525 +int grsec_enable_group;
64526 +kgid_t grsec_audit_gid;
64527 +int grsec_enable_chdir;
64528 +int grsec_enable_mount;
64529 +int grsec_enable_rofs;
64530 +int grsec_enable_chroot_findtask;
64531 +int grsec_enable_chroot_mount;
64532 +int grsec_enable_chroot_shmat;
64533 +int grsec_enable_chroot_fchdir;
64534 +int grsec_enable_chroot_double;
64535 +int grsec_enable_chroot_pivot;
64536 +int grsec_enable_chroot_chdir;
64537 +int grsec_enable_chroot_chmod;
64538 +int grsec_enable_chroot_mknod;
64539 +int grsec_enable_chroot_nice;
64540 +int grsec_enable_chroot_execlog;
64541 +int grsec_enable_chroot_caps;
64542 +int grsec_enable_chroot_sysctl;
64543 +int grsec_enable_chroot_unix;
64544 +int grsec_enable_tpe;
64545 +kgid_t grsec_tpe_gid;
64546 +int grsec_enable_blackhole;
64547 +#ifdef CONFIG_IPV6_MODULE
64548 +EXPORT_SYMBOL(grsec_enable_blackhole);
64549 +#endif
64550 +int grsec_lastack_retries;
64551 +int grsec_enable_tpe_all;
64552 +int grsec_enable_tpe_invert;
64553 +int grsec_enable_socket_all;
64554 +kgid_t grsec_socket_all_gid;
64555 +int grsec_enable_socket_client;
64556 +kgid_t grsec_socket_client_gid;
64557 +int grsec_enable_socket_server;
64558 +kgid_t grsec_socket_server_gid;
64559 +int grsec_resource_logging;
64560 +int grsec_disable_privio;
64561 +int grsec_enable_log_rwxmaps;
64562 +int grsec_lock;
64563 +
64564 +DEFINE_SPINLOCK(grsec_alert_lock);
64565 +unsigned long grsec_alert_wtime = 0;
64566 +unsigned long grsec_alert_fyet = 0;
64567 +
64568 +DEFINE_SPINLOCK(grsec_audit_lock);
64569 +
64570 +DEFINE_RWLOCK(grsec_exec_file_lock);
64571 +
64572 +char *gr_shared_page[4];
64573 +
64574 +char *gr_alert_log_fmt;
64575 +char *gr_audit_log_fmt;
64576 +char *gr_alert_log_buf;
64577 +char *gr_audit_log_buf;
64578 +
64579 +extern struct gr_arg *gr_usermode;
64580 +extern unsigned char *gr_system_salt;
64581 +extern unsigned char *gr_system_sum;
64582 +
64583 +void __init
64584 +grsecurity_init(void)
64585 +{
64586 + int j;
64587 + /* create the per-cpu shared pages */
64588 +
64589 +#ifdef CONFIG_X86
64590 + memset((char *)(0x41a + PAGE_OFFSET), 0, 36);
64591 +#endif
64592 +
64593 + for (j = 0; j < 4; j++) {
64594 + gr_shared_page[j] = (char *)__alloc_percpu(PAGE_SIZE, __alignof__(unsigned long long));
64595 + if (gr_shared_page[j] == NULL) {
64596 + panic("Unable to allocate grsecurity shared page");
64597 + return;
64598 + }
64599 + }
64600 +
64601 + /* allocate log buffers */
64602 + gr_alert_log_fmt = kmalloc(512, GFP_KERNEL);
64603 + if (!gr_alert_log_fmt) {
64604 + panic("Unable to allocate grsecurity alert log format buffer");
64605 + return;
64606 + }
64607 + gr_audit_log_fmt = kmalloc(512, GFP_KERNEL);
64608 + if (!gr_audit_log_fmt) {
64609 + panic("Unable to allocate grsecurity audit log format buffer");
64610 + return;
64611 + }
64612 + gr_alert_log_buf = (char *) get_zeroed_page(GFP_KERNEL);
64613 + if (!gr_alert_log_buf) {
64614 + panic("Unable to allocate grsecurity alert log buffer");
64615 + return;
64616 + }
64617 + gr_audit_log_buf = (char *) get_zeroed_page(GFP_KERNEL);
64618 + if (!gr_audit_log_buf) {
64619 + panic("Unable to allocate grsecurity audit log buffer");
64620 + return;
64621 + }
64622 +
64623 + /* allocate memory for authentication structure */
64624 + gr_usermode = kmalloc(sizeof(struct gr_arg), GFP_KERNEL);
64625 + gr_system_salt = kmalloc(GR_SALT_LEN, GFP_KERNEL);
64626 + gr_system_sum = kmalloc(GR_SHA_LEN, GFP_KERNEL);
64627 +
64628 + if (!gr_usermode || !gr_system_salt || !gr_system_sum) {
64629 + panic("Unable to allocate grsecurity authentication structure");
64630 + return;
64631 + }
64632 +
64633 +
64634 +#ifdef CONFIG_GRKERNSEC_IO
64635 +#if !defined(CONFIG_GRKERNSEC_SYSCTL_DISTRO)
64636 + grsec_disable_privio = 1;
64637 +#elif defined(CONFIG_GRKERNSEC_SYSCTL_ON)
64638 + grsec_disable_privio = 1;
64639 +#else
64640 + grsec_disable_privio = 0;
64641 +#endif
64642 +#endif
64643 +
64644 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
64645 + /* for backward compatibility, tpe_invert always defaults to on if
64646 + enabled in the kernel
64647 + */
64648 + grsec_enable_tpe_invert = 1;
64649 +#endif
64650 +
64651 +#if !defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_SYSCTL_ON)
64652 +#ifndef CONFIG_GRKERNSEC_SYSCTL
64653 + grsec_lock = 1;
64654 +#endif
64655 +
64656 +#ifdef CONFIG_GRKERNSEC_AUDIT_TEXTREL
64657 + grsec_enable_audit_textrel = 1;
64658 +#endif
64659 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
64660 + grsec_enable_log_rwxmaps = 1;
64661 +#endif
64662 +#ifdef CONFIG_GRKERNSEC_AUDIT_GROUP
64663 + grsec_enable_group = 1;
64664 + grsec_audit_gid = KGIDT_INIT(CONFIG_GRKERNSEC_AUDIT_GID);
64665 +#endif
64666 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
64667 + grsec_enable_ptrace_readexec = 1;
64668 +#endif
64669 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
64670 + grsec_enable_chdir = 1;
64671 +#endif
64672 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
64673 + grsec_enable_harden_ptrace = 1;
64674 +#endif
64675 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
64676 + grsec_enable_mount = 1;
64677 +#endif
64678 +#ifdef CONFIG_GRKERNSEC_LINK
64679 + grsec_enable_link = 1;
64680 +#endif
64681 +#ifdef CONFIG_GRKERNSEC_BRUTE
64682 + grsec_enable_brute = 1;
64683 +#endif
64684 +#ifdef CONFIG_GRKERNSEC_DMESG
64685 + grsec_enable_dmesg = 1;
64686 +#endif
64687 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
64688 + grsec_enable_blackhole = 1;
64689 + grsec_lastack_retries = 4;
64690 +#endif
64691 +#ifdef CONFIG_GRKERNSEC_FIFO
64692 + grsec_enable_fifo = 1;
64693 +#endif
64694 +#ifdef CONFIG_GRKERNSEC_EXECLOG
64695 + grsec_enable_execlog = 1;
64696 +#endif
64697 +#ifdef CONFIG_GRKERNSEC_SETXID
64698 + grsec_enable_setxid = 1;
64699 +#endif
64700 +#ifdef CONFIG_GRKERNSEC_SIGNAL
64701 + grsec_enable_signal = 1;
64702 +#endif
64703 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
64704 + grsec_enable_forkfail = 1;
64705 +#endif
64706 +#ifdef CONFIG_GRKERNSEC_TIME
64707 + grsec_enable_time = 1;
64708 +#endif
64709 +#ifdef CONFIG_GRKERNSEC_RESLOG
64710 + grsec_resource_logging = 1;
64711 +#endif
64712 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
64713 + grsec_enable_chroot_findtask = 1;
64714 +#endif
64715 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
64716 + grsec_enable_chroot_unix = 1;
64717 +#endif
64718 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
64719 + grsec_enable_chroot_mount = 1;
64720 +#endif
64721 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
64722 + grsec_enable_chroot_fchdir = 1;
64723 +#endif
64724 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
64725 + grsec_enable_chroot_shmat = 1;
64726 +#endif
64727 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
64728 + grsec_enable_audit_ptrace = 1;
64729 +#endif
64730 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
64731 + grsec_enable_chroot_double = 1;
64732 +#endif
64733 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
64734 + grsec_enable_chroot_pivot = 1;
64735 +#endif
64736 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
64737 + grsec_enable_chroot_chdir = 1;
64738 +#endif
64739 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
64740 + grsec_enable_chroot_chmod = 1;
64741 +#endif
64742 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
64743 + grsec_enable_chroot_mknod = 1;
64744 +#endif
64745 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
64746 + grsec_enable_chroot_nice = 1;
64747 +#endif
64748 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
64749 + grsec_enable_chroot_execlog = 1;
64750 +#endif
64751 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
64752 + grsec_enable_chroot_caps = 1;
64753 +#endif
64754 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
64755 + grsec_enable_chroot_sysctl = 1;
64756 +#endif
64757 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
64758 + grsec_enable_symlinkown = 1;
64759 + grsec_symlinkown_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SYMLINKOWN_GID);
64760 +#endif
64761 +#ifdef CONFIG_GRKERNSEC_TPE
64762 + grsec_enable_tpe = 1;
64763 + grsec_tpe_gid = KGIDT_INIT(CONFIG_GRKERNSEC_TPE_GID);
64764 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
64765 + grsec_enable_tpe_all = 1;
64766 +#endif
64767 +#endif
64768 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
64769 + grsec_enable_socket_all = 1;
64770 + grsec_socket_all_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_ALL_GID);
64771 +#endif
64772 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
64773 + grsec_enable_socket_client = 1;
64774 + grsec_socket_client_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_CLIENT_GID);
64775 +#endif
64776 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
64777 + grsec_enable_socket_server = 1;
64778 + grsec_socket_server_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_SERVER_GID);
64779 +#endif
64780 +#endif
64781 +
64782 + return;
64783 +}
64784 diff --git a/grsecurity/grsec_link.c b/grsecurity/grsec_link.c
64785 new file mode 100644
64786 index 0000000..5e05e20
64787 --- /dev/null
64788 +++ b/grsecurity/grsec_link.c
64789 @@ -0,0 +1,58 @@
64790 +#include <linux/kernel.h>
64791 +#include <linux/sched.h>
64792 +#include <linux/fs.h>
64793 +#include <linux/file.h>
64794 +#include <linux/grinternal.h>
64795 +
64796 +int gr_handle_symlink_owner(const struct path *link, const struct inode *target)
64797 +{
64798 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
64799 + const struct inode *link_inode = link->dentry->d_inode;
64800 +
64801 + if (grsec_enable_symlinkown && in_group_p(grsec_symlinkown_gid) &&
64802 + /* ignore root-owned links, e.g. /proc/self */
64803 + gr_is_global_nonroot(link_inode->i_uid) && target &&
64804 + !uid_eq(link_inode->i_uid, target->i_uid)) {
64805 + gr_log_fs_int2(GR_DONT_AUDIT, GR_SYMLINKOWNER_MSG, link->dentry, link->mnt, link_inode->i_uid, target->i_uid);
64806 + return 1;
64807 + }
64808 +#endif
64809 + return 0;
64810 +}
64811 +
64812 +int
64813 +gr_handle_follow_link(const struct inode *parent,
64814 + const struct inode *inode,
64815 + const struct dentry *dentry, const struct vfsmount *mnt)
64816 +{
64817 +#ifdef CONFIG_GRKERNSEC_LINK
64818 + const struct cred *cred = current_cred();
64819 +
64820 + if (grsec_enable_link && S_ISLNK(inode->i_mode) &&
64821 + (parent->i_mode & S_ISVTX) && !uid_eq(parent->i_uid, inode->i_uid) &&
64822 + (parent->i_mode & S_IWOTH) && !uid_eq(cred->fsuid, inode->i_uid)) {
64823 + gr_log_fs_int2(GR_DONT_AUDIT, GR_SYMLINK_MSG, dentry, mnt, inode->i_uid, inode->i_gid);
64824 + return -EACCES;
64825 + }
64826 +#endif
64827 + return 0;
64828 +}
64829 +
64830 +int
64831 +gr_handle_hardlink(const struct dentry *dentry,
64832 + const struct vfsmount *mnt,
64833 + struct inode *inode, const int mode, const struct filename *to)
64834 +{
64835 +#ifdef CONFIG_GRKERNSEC_LINK
64836 + const struct cred *cred = current_cred();
64837 +
64838 + if (grsec_enable_link && !uid_eq(cred->fsuid, inode->i_uid) &&
64839 + (!S_ISREG(mode) || is_privileged_binary(dentry) ||
64840 + (inode_permission(inode, MAY_READ | MAY_WRITE))) &&
64841 + !capable(CAP_FOWNER) && gr_is_global_nonroot(cred->uid)) {
64842 + gr_log_fs_int2_str(GR_DONT_AUDIT, GR_HARDLINK_MSG, dentry, mnt, inode->i_uid, inode->i_gid, to->name);
64843 + return -EPERM;
64844 + }
64845 +#endif
64846 + return 0;
64847 +}
64848 diff --git a/grsecurity/grsec_log.c b/grsecurity/grsec_log.c
64849 new file mode 100644
64850 index 0000000..7c06085
64851 --- /dev/null
64852 +++ b/grsecurity/grsec_log.c
64853 @@ -0,0 +1,326 @@
64854 +#include <linux/kernel.h>
64855 +#include <linux/sched.h>
64856 +#include <linux/file.h>
64857 +#include <linux/tty.h>
64858 +#include <linux/fs.h>
64859 +#include <linux/grinternal.h>
64860 +
64861 +#ifdef CONFIG_TREE_PREEMPT_RCU
64862 +#define DISABLE_PREEMPT() preempt_disable()
64863 +#define ENABLE_PREEMPT() preempt_enable()
64864 +#else
64865 +#define DISABLE_PREEMPT()
64866 +#define ENABLE_PREEMPT()
64867 +#endif
64868 +
64869 +#define BEGIN_LOCKS(x) \
64870 + DISABLE_PREEMPT(); \
64871 + rcu_read_lock(); \
64872 + read_lock(&tasklist_lock); \
64873 + read_lock(&grsec_exec_file_lock); \
64874 + if (x != GR_DO_AUDIT) \
64875 + spin_lock(&grsec_alert_lock); \
64876 + else \
64877 + spin_lock(&grsec_audit_lock)
64878 +
64879 +#define END_LOCKS(x) \
64880 + if (x != GR_DO_AUDIT) \
64881 + spin_unlock(&grsec_alert_lock); \
64882 + else \
64883 + spin_unlock(&grsec_audit_lock); \
64884 + read_unlock(&grsec_exec_file_lock); \
64885 + read_unlock(&tasklist_lock); \
64886 + rcu_read_unlock(); \
64887 + ENABLE_PREEMPT(); \
64888 + if (x == GR_DONT_AUDIT) \
64889 + gr_handle_alertkill(current)
64890 +
64891 +enum {
64892 + FLOODING,
64893 + NO_FLOODING
64894 +};
64895 +
64896 +extern char *gr_alert_log_fmt;
64897 +extern char *gr_audit_log_fmt;
64898 +extern char *gr_alert_log_buf;
64899 +extern char *gr_audit_log_buf;
64900 +
64901 +static int gr_log_start(int audit)
64902 +{
64903 + char *loglevel = (audit == GR_DO_AUDIT) ? KERN_INFO : KERN_ALERT;
64904 + char *fmt = (audit == GR_DO_AUDIT) ? gr_audit_log_fmt : gr_alert_log_fmt;
64905 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
64906 +#if (CONFIG_GRKERNSEC_FLOODTIME > 0 && CONFIG_GRKERNSEC_FLOODBURST > 0)
64907 + unsigned long curr_secs = get_seconds();
64908 +
64909 + if (audit == GR_DO_AUDIT)
64910 + goto set_fmt;
64911 +
64912 + if (!grsec_alert_wtime || time_after(curr_secs, grsec_alert_wtime + CONFIG_GRKERNSEC_FLOODTIME)) {
64913 + grsec_alert_wtime = curr_secs;
64914 + grsec_alert_fyet = 0;
64915 + } else if (time_before_eq(curr_secs, grsec_alert_wtime + CONFIG_GRKERNSEC_FLOODTIME)
64916 + && (grsec_alert_fyet < CONFIG_GRKERNSEC_FLOODBURST)) {
64917 + grsec_alert_fyet++;
64918 + } else if (grsec_alert_fyet == CONFIG_GRKERNSEC_FLOODBURST) {
64919 + grsec_alert_wtime = curr_secs;
64920 + grsec_alert_fyet++;
64921 + printk(KERN_ALERT "grsec: more alerts, logging disabled for %d seconds\n", CONFIG_GRKERNSEC_FLOODTIME);
64922 + return FLOODING;
64923 + }
64924 + else return FLOODING;
64925 +
64926 +set_fmt:
64927 +#endif
64928 + memset(buf, 0, PAGE_SIZE);
64929 + if (current->signal->curr_ip && gr_acl_is_enabled()) {
64930 + sprintf(fmt, "%s%s", loglevel, "grsec: From %pI4: (%.64s:%c:%.950s) ");
64931 + snprintf(buf, PAGE_SIZE - 1, fmt, &current->signal->curr_ip, current->role->rolename, gr_roletype_to_char(), current->acl->filename);
64932 + } else if (current->signal->curr_ip) {
64933 + sprintf(fmt, "%s%s", loglevel, "grsec: From %pI4: ");
64934 + snprintf(buf, PAGE_SIZE - 1, fmt, &current->signal->curr_ip);
64935 + } else if (gr_acl_is_enabled()) {
64936 + sprintf(fmt, "%s%s", loglevel, "grsec: (%.64s:%c:%.950s) ");
64937 + snprintf(buf, PAGE_SIZE - 1, fmt, current->role->rolename, gr_roletype_to_char(), current->acl->filename);
64938 + } else {
64939 + sprintf(fmt, "%s%s", loglevel, "grsec: ");
64940 + strcpy(buf, fmt);
64941 + }
64942 +
64943 + return NO_FLOODING;
64944 +}
64945 +
64946 +static void gr_log_middle(int audit, const char *msg, va_list ap)
64947 + __attribute__ ((format (printf, 2, 0)));
64948 +
64949 +static void gr_log_middle(int audit, const char *msg, va_list ap)
64950 +{
64951 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
64952 + unsigned int len = strlen(buf);
64953 +
64954 + vsnprintf(buf + len, PAGE_SIZE - len - 1, msg, ap);
64955 +
64956 + return;
64957 +}
64958 +
64959 +static void gr_log_middle_varargs(int audit, const char *msg, ...)
64960 + __attribute__ ((format (printf, 2, 3)));
64961 +
64962 +static void gr_log_middle_varargs(int audit, const char *msg, ...)
64963 +{
64964 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
64965 + unsigned int len = strlen(buf);
64966 + va_list ap;
64967 +
64968 + va_start(ap, msg);
64969 + vsnprintf(buf + len, PAGE_SIZE - len - 1, msg, ap);
64970 + va_end(ap);
64971 +
64972 + return;
64973 +}
64974 +
64975 +static void gr_log_end(int audit, int append_default)
64976 +{
64977 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
64978 + if (append_default) {
64979 + struct task_struct *task = current;
64980 + struct task_struct *parent = task->real_parent;
64981 + const struct cred *cred = __task_cred(task);
64982 + const struct cred *pcred = __task_cred(parent);
64983 + unsigned int len = strlen(buf);
64984 +
64985 + 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));
64986 + }
64987 +
64988 + printk("%s\n", buf);
64989 +
64990 + return;
64991 +}
64992 +
64993 +void gr_log_varargs(int audit, const char *msg, int argtypes, ...)
64994 +{
64995 + int logtype;
64996 + char *result = (audit == GR_DO_AUDIT) ? "successful" : "denied";
64997 + char *str1 = NULL, *str2 = NULL, *str3 = NULL;
64998 + void *voidptr = NULL;
64999 + int num1 = 0, num2 = 0;
65000 + unsigned long ulong1 = 0, ulong2 = 0;
65001 + struct dentry *dentry = NULL;
65002 + struct vfsmount *mnt = NULL;
65003 + struct file *file = NULL;
65004 + struct task_struct *task = NULL;
65005 + const struct cred *cred, *pcred;
65006 + va_list ap;
65007 +
65008 + BEGIN_LOCKS(audit);
65009 + logtype = gr_log_start(audit);
65010 + if (logtype == FLOODING) {
65011 + END_LOCKS(audit);
65012 + return;
65013 + }
65014 + va_start(ap, argtypes);
65015 + switch (argtypes) {
65016 + case GR_TTYSNIFF:
65017 + task = va_arg(ap, struct task_struct *);
65018 + 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));
65019 + break;
65020 + case GR_SYSCTL_HIDDEN:
65021 + str1 = va_arg(ap, char *);
65022 + gr_log_middle_varargs(audit, msg, result, str1);
65023 + break;
65024 + case GR_RBAC:
65025 + dentry = va_arg(ap, struct dentry *);
65026 + mnt = va_arg(ap, struct vfsmount *);
65027 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt));
65028 + break;
65029 + case GR_RBAC_STR:
65030 + dentry = va_arg(ap, struct dentry *);
65031 + mnt = va_arg(ap, struct vfsmount *);
65032 + str1 = va_arg(ap, char *);
65033 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1);
65034 + break;
65035 + case GR_STR_RBAC:
65036 + str1 = va_arg(ap, char *);
65037 + dentry = va_arg(ap, struct dentry *);
65038 + mnt = va_arg(ap, struct vfsmount *);
65039 + gr_log_middle_varargs(audit, msg, result, str1, gr_to_filename(dentry, mnt));
65040 + break;
65041 + case GR_RBAC_MODE2:
65042 + dentry = va_arg(ap, struct dentry *);
65043 + mnt = va_arg(ap, struct vfsmount *);
65044 + str1 = va_arg(ap, char *);
65045 + str2 = va_arg(ap, char *);
65046 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1, str2);
65047 + break;
65048 + case GR_RBAC_MODE3:
65049 + dentry = va_arg(ap, struct dentry *);
65050 + mnt = va_arg(ap, struct vfsmount *);
65051 + str1 = va_arg(ap, char *);
65052 + str2 = va_arg(ap, char *);
65053 + str3 = va_arg(ap, char *);
65054 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1, str2, str3);
65055 + break;
65056 + case GR_FILENAME:
65057 + dentry = va_arg(ap, struct dentry *);
65058 + mnt = va_arg(ap, struct vfsmount *);
65059 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt));
65060 + break;
65061 + case GR_STR_FILENAME:
65062 + str1 = va_arg(ap, char *);
65063 + dentry = va_arg(ap, struct dentry *);
65064 + mnt = va_arg(ap, struct vfsmount *);
65065 + gr_log_middle_varargs(audit, msg, str1, gr_to_filename(dentry, mnt));
65066 + break;
65067 + case GR_FILENAME_STR:
65068 + dentry = va_arg(ap, struct dentry *);
65069 + mnt = va_arg(ap, struct vfsmount *);
65070 + str1 = va_arg(ap, char *);
65071 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), str1);
65072 + break;
65073 + case GR_FILENAME_TWO_INT:
65074 + dentry = va_arg(ap, struct dentry *);
65075 + mnt = va_arg(ap, struct vfsmount *);
65076 + num1 = va_arg(ap, int);
65077 + num2 = va_arg(ap, int);
65078 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), num1, num2);
65079 + break;
65080 + case GR_FILENAME_TWO_INT_STR:
65081 + dentry = va_arg(ap, struct dentry *);
65082 + mnt = va_arg(ap, struct vfsmount *);
65083 + num1 = va_arg(ap, int);
65084 + num2 = va_arg(ap, int);
65085 + str1 = va_arg(ap, char *);
65086 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), num1, num2, str1);
65087 + break;
65088 + case GR_TEXTREL:
65089 + file = va_arg(ap, struct file *);
65090 + ulong1 = va_arg(ap, unsigned long);
65091 + ulong2 = va_arg(ap, unsigned long);
65092 + gr_log_middle_varargs(audit, msg, file ? gr_to_filename(file->f_path.dentry, file->f_path.mnt) : "<anonymous mapping>", ulong1, ulong2);
65093 + break;
65094 + case GR_PTRACE:
65095 + task = va_arg(ap, struct task_struct *);
65096 + 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));
65097 + break;
65098 + case GR_RESOURCE:
65099 + task = va_arg(ap, struct task_struct *);
65100 + cred = __task_cred(task);
65101 + pcred = __task_cred(task->real_parent);
65102 + ulong1 = va_arg(ap, unsigned long);
65103 + str1 = va_arg(ap, char *);
65104 + ulong2 = va_arg(ap, unsigned long);
65105 + 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));
65106 + break;
65107 + case GR_CAP:
65108 + task = va_arg(ap, struct task_struct *);
65109 + cred = __task_cred(task);
65110 + pcred = __task_cred(task->real_parent);
65111 + str1 = va_arg(ap, char *);
65112 + 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));
65113 + break;
65114 + case GR_SIG:
65115 + str1 = va_arg(ap, char *);
65116 + voidptr = va_arg(ap, void *);
65117 + gr_log_middle_varargs(audit, msg, str1, voidptr);
65118 + break;
65119 + case GR_SIG2:
65120 + task = va_arg(ap, struct task_struct *);
65121 + cred = __task_cred(task);
65122 + pcred = __task_cred(task->real_parent);
65123 + num1 = va_arg(ap, int);
65124 + 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));
65125 + break;
65126 + case GR_CRASH1:
65127 + task = va_arg(ap, struct task_struct *);
65128 + cred = __task_cred(task);
65129 + pcred = __task_cred(task->real_parent);
65130 + ulong1 = va_arg(ap, unsigned long);
65131 + 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);
65132 + break;
65133 + case GR_CRASH2:
65134 + task = va_arg(ap, struct task_struct *);
65135 + cred = __task_cred(task);
65136 + pcred = __task_cred(task->real_parent);
65137 + ulong1 = va_arg(ap, unsigned long);
65138 + 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);
65139 + break;
65140 + case GR_RWXMAP:
65141 + file = va_arg(ap, struct file *);
65142 + gr_log_middle_varargs(audit, msg, file ? gr_to_filename(file->f_path.dentry, file->f_path.mnt) : "<anonymous mapping>");
65143 + break;
65144 + case GR_PSACCT:
65145 + {
65146 + unsigned int wday, cday;
65147 + __u8 whr, chr;
65148 + __u8 wmin, cmin;
65149 + __u8 wsec, csec;
65150 + char cur_tty[64] = { 0 };
65151 + char parent_tty[64] = { 0 };
65152 +
65153 + task = va_arg(ap, struct task_struct *);
65154 + wday = va_arg(ap, unsigned int);
65155 + cday = va_arg(ap, unsigned int);
65156 + whr = va_arg(ap, int);
65157 + chr = va_arg(ap, int);
65158 + wmin = va_arg(ap, int);
65159 + cmin = va_arg(ap, int);
65160 + wsec = va_arg(ap, int);
65161 + csec = va_arg(ap, int);
65162 + ulong1 = va_arg(ap, unsigned long);
65163 + cred = __task_cred(task);
65164 + pcred = __task_cred(task->real_parent);
65165 +
65166 + 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));
65167 + }
65168 + break;
65169 + default:
65170 + gr_log_middle(audit, msg, ap);
65171 + }
65172 + va_end(ap);
65173 + // these don't need DEFAULTSECARGS printed on the end
65174 + if (argtypes == GR_CRASH1 || argtypes == GR_CRASH2)
65175 + gr_log_end(audit, 0);
65176 + else
65177 + gr_log_end(audit, 1);
65178 + END_LOCKS(audit);
65179 +}
65180 diff --git a/grsecurity/grsec_mem.c b/grsecurity/grsec_mem.c
65181 new file mode 100644
65182 index 0000000..f536303
65183 --- /dev/null
65184 +++ b/grsecurity/grsec_mem.c
65185 @@ -0,0 +1,40 @@
65186 +#include <linux/kernel.h>
65187 +#include <linux/sched.h>
65188 +#include <linux/mm.h>
65189 +#include <linux/mman.h>
65190 +#include <linux/grinternal.h>
65191 +
65192 +void
65193 +gr_handle_ioperm(void)
65194 +{
65195 + gr_log_noargs(GR_DONT_AUDIT, GR_IOPERM_MSG);
65196 + return;
65197 +}
65198 +
65199 +void
65200 +gr_handle_iopl(void)
65201 +{
65202 + gr_log_noargs(GR_DONT_AUDIT, GR_IOPL_MSG);
65203 + return;
65204 +}
65205 +
65206 +void
65207 +gr_handle_mem_readwrite(u64 from, u64 to)
65208 +{
65209 + gr_log_two_u64(GR_DONT_AUDIT, GR_MEM_READWRITE_MSG, from, to);
65210 + return;
65211 +}
65212 +
65213 +void
65214 +gr_handle_vm86(void)
65215 +{
65216 + gr_log_noargs(GR_DONT_AUDIT, GR_VM86_MSG);
65217 + return;
65218 +}
65219 +
65220 +void
65221 +gr_log_badprocpid(const char *entry)
65222 +{
65223 + gr_log_str(GR_DONT_AUDIT, GR_BADPROCPID_MSG, entry);
65224 + return;
65225 +}
65226 diff --git a/grsecurity/grsec_mount.c b/grsecurity/grsec_mount.c
65227 new file mode 100644
65228 index 0000000..2131422
65229 --- /dev/null
65230 +++ b/grsecurity/grsec_mount.c
65231 @@ -0,0 +1,62 @@
65232 +#include <linux/kernel.h>
65233 +#include <linux/sched.h>
65234 +#include <linux/mount.h>
65235 +#include <linux/grsecurity.h>
65236 +#include <linux/grinternal.h>
65237 +
65238 +void
65239 +gr_log_remount(const char *devname, const int retval)
65240 +{
65241 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
65242 + if (grsec_enable_mount && (retval >= 0))
65243 + gr_log_str(GR_DO_AUDIT, GR_REMOUNT_AUDIT_MSG, devname ? devname : "none");
65244 +#endif
65245 + return;
65246 +}
65247 +
65248 +void
65249 +gr_log_unmount(const char *devname, const int retval)
65250 +{
65251 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
65252 + if (grsec_enable_mount && (retval >= 0))
65253 + gr_log_str(GR_DO_AUDIT, GR_UNMOUNT_AUDIT_MSG, devname ? devname : "none");
65254 +#endif
65255 + return;
65256 +}
65257 +
65258 +void
65259 +gr_log_mount(const char *from, const char *to, const int retval)
65260 +{
65261 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
65262 + if (grsec_enable_mount && (retval >= 0))
65263 + gr_log_str_str(GR_DO_AUDIT, GR_MOUNT_AUDIT_MSG, from ? from : "none", to);
65264 +#endif
65265 + return;
65266 +}
65267 +
65268 +int
65269 +gr_handle_rofs_mount(struct dentry *dentry, struct vfsmount *mnt, int mnt_flags)
65270 +{
65271 +#ifdef CONFIG_GRKERNSEC_ROFS
65272 + if (grsec_enable_rofs && !(mnt_flags & MNT_READONLY)) {
65273 + gr_log_fs_generic(GR_DO_AUDIT, GR_ROFS_MOUNT_MSG, dentry, mnt);
65274 + return -EPERM;
65275 + } else
65276 + return 0;
65277 +#endif
65278 + return 0;
65279 +}
65280 +
65281 +int
65282 +gr_handle_rofs_blockwrite(struct dentry *dentry, struct vfsmount *mnt, int acc_mode)
65283 +{
65284 +#ifdef CONFIG_GRKERNSEC_ROFS
65285 + if (grsec_enable_rofs && (acc_mode & MAY_WRITE) &&
65286 + dentry->d_inode && S_ISBLK(dentry->d_inode->i_mode)) {
65287 + gr_log_fs_generic(GR_DO_AUDIT, GR_ROFS_BLOCKWRITE_MSG, dentry, mnt);
65288 + return -EPERM;
65289 + } else
65290 + return 0;
65291 +#endif
65292 + return 0;
65293 +}
65294 diff --git a/grsecurity/grsec_pax.c b/grsecurity/grsec_pax.c
65295 new file mode 100644
65296 index 0000000..a3b12a0
65297 --- /dev/null
65298 +++ b/grsecurity/grsec_pax.c
65299 @@ -0,0 +1,36 @@
65300 +#include <linux/kernel.h>
65301 +#include <linux/sched.h>
65302 +#include <linux/mm.h>
65303 +#include <linux/file.h>
65304 +#include <linux/grinternal.h>
65305 +#include <linux/grsecurity.h>
65306 +
65307 +void
65308 +gr_log_textrel(struct vm_area_struct * vma)
65309 +{
65310 +#ifdef CONFIG_GRKERNSEC_AUDIT_TEXTREL
65311 + if (grsec_enable_audit_textrel)
65312 + gr_log_textrel_ulong_ulong(GR_DO_AUDIT, GR_TEXTREL_AUDIT_MSG, vma->vm_file, vma->vm_start, vma->vm_pgoff);
65313 +#endif
65314 + return;
65315 +}
65316 +
65317 +void
65318 +gr_log_rwxmmap(struct file *file)
65319 +{
65320 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
65321 + if (grsec_enable_log_rwxmaps)
65322 + gr_log_rwxmap(GR_DONT_AUDIT, GR_RWXMMAP_MSG, file);
65323 +#endif
65324 + return;
65325 +}
65326 +
65327 +void
65328 +gr_log_rwxmprotect(struct file *file)
65329 +{
65330 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
65331 + if (grsec_enable_log_rwxmaps)
65332 + gr_log_rwxmap(GR_DONT_AUDIT, GR_RWXMPROTECT_MSG, file);
65333 +#endif
65334 + return;
65335 +}
65336 diff --git a/grsecurity/grsec_ptrace.c b/grsecurity/grsec_ptrace.c
65337 new file mode 100644
65338 index 0000000..f7f29aa
65339 --- /dev/null
65340 +++ b/grsecurity/grsec_ptrace.c
65341 @@ -0,0 +1,30 @@
65342 +#include <linux/kernel.h>
65343 +#include <linux/sched.h>
65344 +#include <linux/grinternal.h>
65345 +#include <linux/security.h>
65346 +
65347 +void
65348 +gr_audit_ptrace(struct task_struct *task)
65349 +{
65350 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
65351 + if (grsec_enable_audit_ptrace)
65352 + gr_log_ptrace(GR_DO_AUDIT, GR_PTRACE_AUDIT_MSG, task);
65353 +#endif
65354 + return;
65355 +}
65356 +
65357 +int
65358 +gr_ptrace_readexec(struct file *file, int unsafe_flags)
65359 +{
65360 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
65361 + const struct dentry *dentry = file->f_path.dentry;
65362 + const struct vfsmount *mnt = file->f_path.mnt;
65363 +
65364 + if (grsec_enable_ptrace_readexec && (unsafe_flags & LSM_UNSAFE_PTRACE) &&
65365 + (inode_permission(dentry->d_inode, MAY_READ) || !gr_acl_handle_open(dentry, mnt, MAY_READ))) {
65366 + gr_log_fs_generic(GR_DONT_AUDIT, GR_PTRACE_READEXEC_MSG, dentry, mnt);
65367 + return -EACCES;
65368 + }
65369 +#endif
65370 + return 0;
65371 +}
65372 diff --git a/grsecurity/grsec_sig.c b/grsecurity/grsec_sig.c
65373 new file mode 100644
65374 index 0000000..e09715a
65375 --- /dev/null
65376 +++ b/grsecurity/grsec_sig.c
65377 @@ -0,0 +1,222 @@
65378 +#include <linux/kernel.h>
65379 +#include <linux/sched.h>
65380 +#include <linux/delay.h>
65381 +#include <linux/grsecurity.h>
65382 +#include <linux/grinternal.h>
65383 +#include <linux/hardirq.h>
65384 +
65385 +char *signames[] = {
65386 + [SIGSEGV] = "Segmentation fault",
65387 + [SIGILL] = "Illegal instruction",
65388 + [SIGABRT] = "Abort",
65389 + [SIGBUS] = "Invalid alignment/Bus error"
65390 +};
65391 +
65392 +void
65393 +gr_log_signal(const int sig, const void *addr, const struct task_struct *t)
65394 +{
65395 +#ifdef CONFIG_GRKERNSEC_SIGNAL
65396 + if (grsec_enable_signal && ((sig == SIGSEGV) || (sig == SIGILL) ||
65397 + (sig == SIGABRT) || (sig == SIGBUS))) {
65398 + if (task_pid_nr(t) == task_pid_nr(current)) {
65399 + gr_log_sig_addr(GR_DONT_AUDIT_GOOD, GR_UNISIGLOG_MSG, signames[sig], addr);
65400 + } else {
65401 + gr_log_sig_task(GR_DONT_AUDIT_GOOD, GR_DUALSIGLOG_MSG, t, sig);
65402 + }
65403 + }
65404 +#endif
65405 + return;
65406 +}
65407 +
65408 +int
65409 +gr_handle_signal(const struct task_struct *p, const int sig)
65410 +{
65411 +#ifdef CONFIG_GRKERNSEC
65412 + /* ignore the 0 signal for protected task checks */
65413 + if (task_pid_nr(current) > 1 && sig && gr_check_protected_task(p)) {
65414 + gr_log_sig_task(GR_DONT_AUDIT, GR_SIG_ACL_MSG, p, sig);
65415 + return -EPERM;
65416 + } else if (gr_pid_is_chrooted((struct task_struct *)p)) {
65417 + return -EPERM;
65418 + }
65419 +#endif
65420 + return 0;
65421 +}
65422 +
65423 +#ifdef CONFIG_GRKERNSEC
65424 +extern int specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t);
65425 +
65426 +int gr_fake_force_sig(int sig, struct task_struct *t)
65427 +{
65428 + unsigned long int flags;
65429 + int ret, blocked, ignored;
65430 + struct k_sigaction *action;
65431 +
65432 + spin_lock_irqsave(&t->sighand->siglock, flags);
65433 + action = &t->sighand->action[sig-1];
65434 + ignored = action->sa.sa_handler == SIG_IGN;
65435 + blocked = sigismember(&t->blocked, sig);
65436 + if (blocked || ignored) {
65437 + action->sa.sa_handler = SIG_DFL;
65438 + if (blocked) {
65439 + sigdelset(&t->blocked, sig);
65440 + recalc_sigpending_and_wake(t);
65441 + }
65442 + }
65443 + if (action->sa.sa_handler == SIG_DFL)
65444 + t->signal->flags &= ~SIGNAL_UNKILLABLE;
65445 + ret = specific_send_sig_info(sig, SEND_SIG_PRIV, t);
65446 +
65447 + spin_unlock_irqrestore(&t->sighand->siglock, flags);
65448 +
65449 + return ret;
65450 +}
65451 +#endif
65452 +
65453 +#ifdef CONFIG_GRKERNSEC_BRUTE
65454 +#define GR_USER_BAN_TIME (15 * 60)
65455 +#define GR_DAEMON_BRUTE_TIME (30 * 60)
65456 +
65457 +static int __get_dumpable(unsigned long mm_flags)
65458 +{
65459 + int ret;
65460 +
65461 + ret = mm_flags & MMF_DUMPABLE_MASK;
65462 + return (ret >= 2) ? 2 : ret;
65463 +}
65464 +#endif
65465 +
65466 +void gr_handle_brute_attach(unsigned long mm_flags)
65467 +{
65468 +#ifdef CONFIG_GRKERNSEC_BRUTE
65469 + struct task_struct *p = current;
65470 + kuid_t uid = GLOBAL_ROOT_UID;
65471 + int daemon = 0;
65472 +
65473 + if (!grsec_enable_brute)
65474 + return;
65475 +
65476 + rcu_read_lock();
65477 + read_lock(&tasklist_lock);
65478 + read_lock(&grsec_exec_file_lock);
65479 + if (p->real_parent && p->real_parent->exec_file == p->exec_file) {
65480 + p->real_parent->brute_expires = get_seconds() + GR_DAEMON_BRUTE_TIME;
65481 + p->real_parent->brute = 1;
65482 + daemon = 1;
65483 + } else {
65484 + const struct cred *cred = __task_cred(p), *cred2;
65485 + struct task_struct *tsk, *tsk2;
65486 +
65487 + if (!__get_dumpable(mm_flags) && gr_is_global_nonroot(cred->uid)) {
65488 + struct user_struct *user;
65489 +
65490 + uid = cred->uid;
65491 +
65492 + /* this is put upon execution past expiration */
65493 + user = find_user(uid);
65494 + if (user == NULL)
65495 + goto unlock;
65496 + user->banned = 1;
65497 + user->ban_expires = get_seconds() + GR_USER_BAN_TIME;
65498 + if (user->ban_expires == ~0UL)
65499 + user->ban_expires--;
65500 +
65501 + do_each_thread(tsk2, tsk) {
65502 + cred2 = __task_cred(tsk);
65503 + if (tsk != p && uid_eq(cred2->uid, uid))
65504 + gr_fake_force_sig(SIGKILL, tsk);
65505 + } while_each_thread(tsk2, tsk);
65506 + }
65507 + }
65508 +unlock:
65509 + read_unlock(&grsec_exec_file_lock);
65510 + read_unlock(&tasklist_lock);
65511 + rcu_read_unlock();
65512 +
65513 + if (gr_is_global_nonroot(uid))
65514 + printk(KERN_ALERT "grsec: bruteforce prevention initiated against uid %u, banning for %d minutes\n",
65515 + GR_GLOBAL_UID(uid), GR_USER_BAN_TIME / 60);
65516 + else if (daemon)
65517 + gr_log_noargs(GR_DONT_AUDIT, GR_BRUTE_DAEMON_MSG);
65518 +
65519 +#endif
65520 + return;
65521 +}
65522 +
65523 +void gr_handle_brute_check(void)
65524 +{
65525 +#ifdef CONFIG_GRKERNSEC_BRUTE
65526 + struct task_struct *p = current;
65527 +
65528 + if (unlikely(p->brute)) {
65529 + if (!grsec_enable_brute)
65530 + p->brute = 0;
65531 + else if (time_before(get_seconds(), p->brute_expires))
65532 + msleep(30 * 1000);
65533 + }
65534 +#endif
65535 + return;
65536 +}
65537 +
65538 +void gr_handle_kernel_exploit(void)
65539 +{
65540 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
65541 + const struct cred *cred;
65542 + struct task_struct *tsk, *tsk2;
65543 + struct user_struct *user;
65544 + kuid_t uid;
65545 +
65546 + if (in_irq() || in_serving_softirq() || in_nmi())
65547 + panic("grsec: halting the system due to suspicious kernel crash caused in interrupt context");
65548 +
65549 + uid = current_uid();
65550 +
65551 + if (gr_is_global_root(uid))
65552 + panic("grsec: halting the system due to suspicious kernel crash caused by root");
65553 + else {
65554 + /* kill all the processes of this user, hold a reference
65555 + to their creds struct, and prevent them from creating
65556 + another process until system reset
65557 + */
65558 + printk(KERN_ALERT "grsec: banning user with uid %u until system restart for suspicious kernel crash\n",
65559 + GR_GLOBAL_UID(uid));
65560 + /* we intentionally leak this ref */
65561 + user = get_uid(current->cred->user);
65562 + if (user) {
65563 + user->banned = 1;
65564 + user->ban_expires = ~0UL;
65565 + }
65566 +
65567 + read_lock(&tasklist_lock);
65568 + do_each_thread(tsk2, tsk) {
65569 + cred = __task_cred(tsk);
65570 + if (uid_eq(cred->uid, uid))
65571 + gr_fake_force_sig(SIGKILL, tsk);
65572 + } while_each_thread(tsk2, tsk);
65573 + read_unlock(&tasklist_lock);
65574 + }
65575 +#endif
65576 +}
65577 +
65578 +int __gr_process_user_ban(struct user_struct *user)
65579 +{
65580 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT) || defined(CONFIG_GRKERNSEC_BRUTE)
65581 + if (unlikely(user->banned)) {
65582 + if (user->ban_expires != ~0UL && time_after_eq(get_seconds(), user->ban_expires)) {
65583 + user->banned = 0;
65584 + user->ban_expires = 0;
65585 + free_uid(user);
65586 + } else
65587 + return -EPERM;
65588 + }
65589 +#endif
65590 + return 0;
65591 +}
65592 +
65593 +int gr_process_user_ban(void)
65594 +{
65595 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT) || defined(CONFIG_GRKERNSEC_BRUTE)
65596 + return __gr_process_user_ban(current->cred->user);
65597 +#endif
65598 + return 0;
65599 +}
65600 diff --git a/grsecurity/grsec_sock.c b/grsecurity/grsec_sock.c
65601 new file mode 100644
65602 index 0000000..4030d57
65603 --- /dev/null
65604 +++ b/grsecurity/grsec_sock.c
65605 @@ -0,0 +1,244 @@
65606 +#include <linux/kernel.h>
65607 +#include <linux/module.h>
65608 +#include <linux/sched.h>
65609 +#include <linux/file.h>
65610 +#include <linux/net.h>
65611 +#include <linux/in.h>
65612 +#include <linux/ip.h>
65613 +#include <net/sock.h>
65614 +#include <net/inet_sock.h>
65615 +#include <linux/grsecurity.h>
65616 +#include <linux/grinternal.h>
65617 +#include <linux/gracl.h>
65618 +
65619 +extern int gr_search_udp_recvmsg(const struct sock *sk, const struct sk_buff *skb);
65620 +extern int gr_search_udp_sendmsg(const struct sock *sk, const struct sockaddr_in *addr);
65621 +
65622 +EXPORT_SYMBOL(gr_search_udp_recvmsg);
65623 +EXPORT_SYMBOL(gr_search_udp_sendmsg);
65624 +
65625 +#ifdef CONFIG_UNIX_MODULE
65626 +EXPORT_SYMBOL(gr_acl_handle_unix);
65627 +EXPORT_SYMBOL(gr_acl_handle_mknod);
65628 +EXPORT_SYMBOL(gr_handle_chroot_unix);
65629 +EXPORT_SYMBOL(gr_handle_create);
65630 +#endif
65631 +
65632 +#ifdef CONFIG_GRKERNSEC
65633 +#define gr_conn_table_size 32749
65634 +struct conn_table_entry {
65635 + struct conn_table_entry *next;
65636 + struct signal_struct *sig;
65637 +};
65638 +
65639 +struct conn_table_entry *gr_conn_table[gr_conn_table_size];
65640 +DEFINE_SPINLOCK(gr_conn_table_lock);
65641 +
65642 +extern const char * gr_socktype_to_name(unsigned char type);
65643 +extern const char * gr_proto_to_name(unsigned char proto);
65644 +extern const char * gr_sockfamily_to_name(unsigned char family);
65645 +
65646 +static __inline__ int
65647 +conn_hash(__u32 saddr, __u32 daddr, __u16 sport, __u16 dport, unsigned int size)
65648 +{
65649 + return ((daddr + saddr + (sport << 8) + (dport << 16)) % size);
65650 +}
65651 +
65652 +static __inline__ int
65653 +conn_match(const struct signal_struct *sig, __u32 saddr, __u32 daddr,
65654 + __u16 sport, __u16 dport)
65655 +{
65656 + if (unlikely(sig->gr_saddr == saddr && sig->gr_daddr == daddr &&
65657 + sig->gr_sport == sport && sig->gr_dport == dport))
65658 + return 1;
65659 + else
65660 + return 0;
65661 +}
65662 +
65663 +static void gr_add_to_task_ip_table_nolock(struct signal_struct *sig, struct conn_table_entry *newent)
65664 +{
65665 + struct conn_table_entry **match;
65666 + unsigned int index;
65667 +
65668 + index = conn_hash(sig->gr_saddr, sig->gr_daddr,
65669 + sig->gr_sport, sig->gr_dport,
65670 + gr_conn_table_size);
65671 +
65672 + newent->sig = sig;
65673 +
65674 + match = &gr_conn_table[index];
65675 + newent->next = *match;
65676 + *match = newent;
65677 +
65678 + return;
65679 +}
65680 +
65681 +static void gr_del_task_from_ip_table_nolock(struct signal_struct *sig)
65682 +{
65683 + struct conn_table_entry *match, *last = NULL;
65684 + unsigned int index;
65685 +
65686 + index = conn_hash(sig->gr_saddr, sig->gr_daddr,
65687 + sig->gr_sport, sig->gr_dport,
65688 + gr_conn_table_size);
65689 +
65690 + match = gr_conn_table[index];
65691 + while (match && !conn_match(match->sig,
65692 + sig->gr_saddr, sig->gr_daddr, sig->gr_sport,
65693 + sig->gr_dport)) {
65694 + last = match;
65695 + match = match->next;
65696 + }
65697 +
65698 + if (match) {
65699 + if (last)
65700 + last->next = match->next;
65701 + else
65702 + gr_conn_table[index] = NULL;
65703 + kfree(match);
65704 + }
65705 +
65706 + return;
65707 +}
65708 +
65709 +static struct signal_struct * gr_lookup_task_ip_table(__u32 saddr, __u32 daddr,
65710 + __u16 sport, __u16 dport)
65711 +{
65712 + struct conn_table_entry *match;
65713 + unsigned int index;
65714 +
65715 + index = conn_hash(saddr, daddr, sport, dport, gr_conn_table_size);
65716 +
65717 + match = gr_conn_table[index];
65718 + while (match && !conn_match(match->sig, saddr, daddr, sport, dport))
65719 + match = match->next;
65720 +
65721 + if (match)
65722 + return match->sig;
65723 + else
65724 + return NULL;
65725 +}
65726 +
65727 +#endif
65728 +
65729 +void gr_update_task_in_ip_table(struct task_struct *task, const struct inet_sock *inet)
65730 +{
65731 +#ifdef CONFIG_GRKERNSEC
65732 + struct signal_struct *sig = task->signal;
65733 + struct conn_table_entry *newent;
65734 +
65735 + newent = kmalloc(sizeof(struct conn_table_entry), GFP_ATOMIC);
65736 + if (newent == NULL)
65737 + return;
65738 + /* no bh lock needed since we are called with bh disabled */
65739 + spin_lock(&gr_conn_table_lock);
65740 + gr_del_task_from_ip_table_nolock(sig);
65741 + sig->gr_saddr = inet->inet_rcv_saddr;
65742 + sig->gr_daddr = inet->inet_daddr;
65743 + sig->gr_sport = inet->inet_sport;
65744 + sig->gr_dport = inet->inet_dport;
65745 + gr_add_to_task_ip_table_nolock(sig, newent);
65746 + spin_unlock(&gr_conn_table_lock);
65747 +#endif
65748 + return;
65749 +}
65750 +
65751 +void gr_del_task_from_ip_table(struct task_struct *task)
65752 +{
65753 +#ifdef CONFIG_GRKERNSEC
65754 + spin_lock_bh(&gr_conn_table_lock);
65755 + gr_del_task_from_ip_table_nolock(task->signal);
65756 + spin_unlock_bh(&gr_conn_table_lock);
65757 +#endif
65758 + return;
65759 +}
65760 +
65761 +void
65762 +gr_attach_curr_ip(const struct sock *sk)
65763 +{
65764 +#ifdef CONFIG_GRKERNSEC
65765 + struct signal_struct *p, *set;
65766 + const struct inet_sock *inet = inet_sk(sk);
65767 +
65768 + if (unlikely(sk->sk_protocol != IPPROTO_TCP))
65769 + return;
65770 +
65771 + set = current->signal;
65772 +
65773 + spin_lock_bh(&gr_conn_table_lock);
65774 + p = gr_lookup_task_ip_table(inet->inet_daddr, inet->inet_rcv_saddr,
65775 + inet->inet_dport, inet->inet_sport);
65776 + if (unlikely(p != NULL)) {
65777 + set->curr_ip = p->curr_ip;
65778 + set->used_accept = 1;
65779 + gr_del_task_from_ip_table_nolock(p);
65780 + spin_unlock_bh(&gr_conn_table_lock);
65781 + return;
65782 + }
65783 + spin_unlock_bh(&gr_conn_table_lock);
65784 +
65785 + set->curr_ip = inet->inet_daddr;
65786 + set->used_accept = 1;
65787 +#endif
65788 + return;
65789 +}
65790 +
65791 +int
65792 +gr_handle_sock_all(const int family, const int type, const int protocol)
65793 +{
65794 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
65795 + if (grsec_enable_socket_all && in_group_p(grsec_socket_all_gid) &&
65796 + (family != AF_UNIX)) {
65797 + if (family == AF_INET)
65798 + gr_log_str3(GR_DONT_AUDIT, GR_SOCK_MSG, gr_sockfamily_to_name(family), gr_socktype_to_name(type), gr_proto_to_name(protocol));
65799 + else
65800 + gr_log_str2_int(GR_DONT_AUDIT, GR_SOCK_NOINET_MSG, gr_sockfamily_to_name(family), gr_socktype_to_name(type), protocol);
65801 + return -EACCES;
65802 + }
65803 +#endif
65804 + return 0;
65805 +}
65806 +
65807 +int
65808 +gr_handle_sock_server(const struct sockaddr *sck)
65809 +{
65810 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
65811 + if (grsec_enable_socket_server &&
65812 + in_group_p(grsec_socket_server_gid) &&
65813 + sck && (sck->sa_family != AF_UNIX) &&
65814 + (sck->sa_family != AF_LOCAL)) {
65815 + gr_log_noargs(GR_DONT_AUDIT, GR_BIND_MSG);
65816 + return -EACCES;
65817 + }
65818 +#endif
65819 + return 0;
65820 +}
65821 +
65822 +int
65823 +gr_handle_sock_server_other(const struct sock *sck)
65824 +{
65825 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
65826 + if (grsec_enable_socket_server &&
65827 + in_group_p(grsec_socket_server_gid) &&
65828 + sck && (sck->sk_family != AF_UNIX) &&
65829 + (sck->sk_family != AF_LOCAL)) {
65830 + gr_log_noargs(GR_DONT_AUDIT, GR_BIND_MSG);
65831 + return -EACCES;
65832 + }
65833 +#endif
65834 + return 0;
65835 +}
65836 +
65837 +int
65838 +gr_handle_sock_client(const struct sockaddr *sck)
65839 +{
65840 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
65841 + if (grsec_enable_socket_client && in_group_p(grsec_socket_client_gid) &&
65842 + sck && (sck->sa_family != AF_UNIX) &&
65843 + (sck->sa_family != AF_LOCAL)) {
65844 + gr_log_noargs(GR_DONT_AUDIT, GR_CONNECT_MSG);
65845 + return -EACCES;
65846 + }
65847 +#endif
65848 + return 0;
65849 +}
65850 diff --git a/grsecurity/grsec_sysctl.c b/grsecurity/grsec_sysctl.c
65851 new file mode 100644
65852 index 0000000..f55ef0f
65853 --- /dev/null
65854 +++ b/grsecurity/grsec_sysctl.c
65855 @@ -0,0 +1,469 @@
65856 +#include <linux/kernel.h>
65857 +#include <linux/sched.h>
65858 +#include <linux/sysctl.h>
65859 +#include <linux/grsecurity.h>
65860 +#include <linux/grinternal.h>
65861 +
65862 +int
65863 +gr_handle_sysctl_mod(const char *dirname, const char *name, const int op)
65864 +{
65865 +#ifdef CONFIG_GRKERNSEC_SYSCTL
65866 + if (dirname == NULL || name == NULL)
65867 + return 0;
65868 + if (!strcmp(dirname, "grsecurity") && grsec_lock && (op & MAY_WRITE)) {
65869 + gr_log_str(GR_DONT_AUDIT, GR_SYSCTL_MSG, name);
65870 + return -EACCES;
65871 + }
65872 +#endif
65873 + return 0;
65874 +}
65875 +
65876 +#ifdef CONFIG_GRKERNSEC_ROFS
65877 +static int __maybe_unused one = 1;
65878 +#endif
65879 +
65880 +#if defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_ROFS)
65881 +struct ctl_table grsecurity_table[] = {
65882 +#ifdef CONFIG_GRKERNSEC_SYSCTL
65883 +#ifdef CONFIG_GRKERNSEC_SYSCTL_DISTRO
65884 +#ifdef CONFIG_GRKERNSEC_IO
65885 + {
65886 + .procname = "disable_priv_io",
65887 + .data = &grsec_disable_privio,
65888 + .maxlen = sizeof(int),
65889 + .mode = 0600,
65890 + .proc_handler = &proc_dointvec,
65891 + },
65892 +#endif
65893 +#endif
65894 +#ifdef CONFIG_GRKERNSEC_LINK
65895 + {
65896 + .procname = "linking_restrictions",
65897 + .data = &grsec_enable_link,
65898 + .maxlen = sizeof(int),
65899 + .mode = 0600,
65900 + .proc_handler = &proc_dointvec,
65901 + },
65902 +#endif
65903 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
65904 + {
65905 + .procname = "enforce_symlinksifowner",
65906 + .data = &grsec_enable_symlinkown,
65907 + .maxlen = sizeof(int),
65908 + .mode = 0600,
65909 + .proc_handler = &proc_dointvec,
65910 + },
65911 + {
65912 + .procname = "symlinkown_gid",
65913 + .data = &grsec_symlinkown_gid,
65914 + .maxlen = sizeof(int),
65915 + .mode = 0600,
65916 + .proc_handler = &proc_dointvec,
65917 + },
65918 +#endif
65919 +#ifdef CONFIG_GRKERNSEC_BRUTE
65920 + {
65921 + .procname = "deter_bruteforce",
65922 + .data = &grsec_enable_brute,
65923 + .maxlen = sizeof(int),
65924 + .mode = 0600,
65925 + .proc_handler = &proc_dointvec,
65926 + },
65927 +#endif
65928 +#ifdef CONFIG_GRKERNSEC_FIFO
65929 + {
65930 + .procname = "fifo_restrictions",
65931 + .data = &grsec_enable_fifo,
65932 + .maxlen = sizeof(int),
65933 + .mode = 0600,
65934 + .proc_handler = &proc_dointvec,
65935 + },
65936 +#endif
65937 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
65938 + {
65939 + .procname = "ptrace_readexec",
65940 + .data = &grsec_enable_ptrace_readexec,
65941 + .maxlen = sizeof(int),
65942 + .mode = 0600,
65943 + .proc_handler = &proc_dointvec,
65944 + },
65945 +#endif
65946 +#ifdef CONFIG_GRKERNSEC_SETXID
65947 + {
65948 + .procname = "consistent_setxid",
65949 + .data = &grsec_enable_setxid,
65950 + .maxlen = sizeof(int),
65951 + .mode = 0600,
65952 + .proc_handler = &proc_dointvec,
65953 + },
65954 +#endif
65955 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
65956 + {
65957 + .procname = "ip_blackhole",
65958 + .data = &grsec_enable_blackhole,
65959 + .maxlen = sizeof(int),
65960 + .mode = 0600,
65961 + .proc_handler = &proc_dointvec,
65962 + },
65963 + {
65964 + .procname = "lastack_retries",
65965 + .data = &grsec_lastack_retries,
65966 + .maxlen = sizeof(int),
65967 + .mode = 0600,
65968 + .proc_handler = &proc_dointvec,
65969 + },
65970 +#endif
65971 +#ifdef CONFIG_GRKERNSEC_EXECLOG
65972 + {
65973 + .procname = "exec_logging",
65974 + .data = &grsec_enable_execlog,
65975 + .maxlen = sizeof(int),
65976 + .mode = 0600,
65977 + .proc_handler = &proc_dointvec,
65978 + },
65979 +#endif
65980 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
65981 + {
65982 + .procname = "rwxmap_logging",
65983 + .data = &grsec_enable_log_rwxmaps,
65984 + .maxlen = sizeof(int),
65985 + .mode = 0600,
65986 + .proc_handler = &proc_dointvec,
65987 + },
65988 +#endif
65989 +#ifdef CONFIG_GRKERNSEC_SIGNAL
65990 + {
65991 + .procname = "signal_logging",
65992 + .data = &grsec_enable_signal,
65993 + .maxlen = sizeof(int),
65994 + .mode = 0600,
65995 + .proc_handler = &proc_dointvec,
65996 + },
65997 +#endif
65998 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
65999 + {
66000 + .procname = "forkfail_logging",
66001 + .data = &grsec_enable_forkfail,
66002 + .maxlen = sizeof(int),
66003 + .mode = 0600,
66004 + .proc_handler = &proc_dointvec,
66005 + },
66006 +#endif
66007 +#ifdef CONFIG_GRKERNSEC_TIME
66008 + {
66009 + .procname = "timechange_logging",
66010 + .data = &grsec_enable_time,
66011 + .maxlen = sizeof(int),
66012 + .mode = 0600,
66013 + .proc_handler = &proc_dointvec,
66014 + },
66015 +#endif
66016 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
66017 + {
66018 + .procname = "chroot_deny_shmat",
66019 + .data = &grsec_enable_chroot_shmat,
66020 + .maxlen = sizeof(int),
66021 + .mode = 0600,
66022 + .proc_handler = &proc_dointvec,
66023 + },
66024 +#endif
66025 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
66026 + {
66027 + .procname = "chroot_deny_unix",
66028 + .data = &grsec_enable_chroot_unix,
66029 + .maxlen = sizeof(int),
66030 + .mode = 0600,
66031 + .proc_handler = &proc_dointvec,
66032 + },
66033 +#endif
66034 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
66035 + {
66036 + .procname = "chroot_deny_mount",
66037 + .data = &grsec_enable_chroot_mount,
66038 + .maxlen = sizeof(int),
66039 + .mode = 0600,
66040 + .proc_handler = &proc_dointvec,
66041 + },
66042 +#endif
66043 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
66044 + {
66045 + .procname = "chroot_deny_fchdir",
66046 + .data = &grsec_enable_chroot_fchdir,
66047 + .maxlen = sizeof(int),
66048 + .mode = 0600,
66049 + .proc_handler = &proc_dointvec,
66050 + },
66051 +#endif
66052 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
66053 + {
66054 + .procname = "chroot_deny_chroot",
66055 + .data = &grsec_enable_chroot_double,
66056 + .maxlen = sizeof(int),
66057 + .mode = 0600,
66058 + .proc_handler = &proc_dointvec,
66059 + },
66060 +#endif
66061 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
66062 + {
66063 + .procname = "chroot_deny_pivot",
66064 + .data = &grsec_enable_chroot_pivot,
66065 + .maxlen = sizeof(int),
66066 + .mode = 0600,
66067 + .proc_handler = &proc_dointvec,
66068 + },
66069 +#endif
66070 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
66071 + {
66072 + .procname = "chroot_enforce_chdir",
66073 + .data = &grsec_enable_chroot_chdir,
66074 + .maxlen = sizeof(int),
66075 + .mode = 0600,
66076 + .proc_handler = &proc_dointvec,
66077 + },
66078 +#endif
66079 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
66080 + {
66081 + .procname = "chroot_deny_chmod",
66082 + .data = &grsec_enable_chroot_chmod,
66083 + .maxlen = sizeof(int),
66084 + .mode = 0600,
66085 + .proc_handler = &proc_dointvec,
66086 + },
66087 +#endif
66088 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
66089 + {
66090 + .procname = "chroot_deny_mknod",
66091 + .data = &grsec_enable_chroot_mknod,
66092 + .maxlen = sizeof(int),
66093 + .mode = 0600,
66094 + .proc_handler = &proc_dointvec,
66095 + },
66096 +#endif
66097 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
66098 + {
66099 + .procname = "chroot_restrict_nice",
66100 + .data = &grsec_enable_chroot_nice,
66101 + .maxlen = sizeof(int),
66102 + .mode = 0600,
66103 + .proc_handler = &proc_dointvec,
66104 + },
66105 +#endif
66106 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
66107 + {
66108 + .procname = "chroot_execlog",
66109 + .data = &grsec_enable_chroot_execlog,
66110 + .maxlen = sizeof(int),
66111 + .mode = 0600,
66112 + .proc_handler = &proc_dointvec,
66113 + },
66114 +#endif
66115 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
66116 + {
66117 + .procname = "chroot_caps",
66118 + .data = &grsec_enable_chroot_caps,
66119 + .maxlen = sizeof(int),
66120 + .mode = 0600,
66121 + .proc_handler = &proc_dointvec,
66122 + },
66123 +#endif
66124 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
66125 + {
66126 + .procname = "chroot_deny_sysctl",
66127 + .data = &grsec_enable_chroot_sysctl,
66128 + .maxlen = sizeof(int),
66129 + .mode = 0600,
66130 + .proc_handler = &proc_dointvec,
66131 + },
66132 +#endif
66133 +#ifdef CONFIG_GRKERNSEC_TPE
66134 + {
66135 + .procname = "tpe",
66136 + .data = &grsec_enable_tpe,
66137 + .maxlen = sizeof(int),
66138 + .mode = 0600,
66139 + .proc_handler = &proc_dointvec,
66140 + },
66141 + {
66142 + .procname = "tpe_gid",
66143 + .data = &grsec_tpe_gid,
66144 + .maxlen = sizeof(int),
66145 + .mode = 0600,
66146 + .proc_handler = &proc_dointvec,
66147 + },
66148 +#endif
66149 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
66150 + {
66151 + .procname = "tpe_invert",
66152 + .data = &grsec_enable_tpe_invert,
66153 + .maxlen = sizeof(int),
66154 + .mode = 0600,
66155 + .proc_handler = &proc_dointvec,
66156 + },
66157 +#endif
66158 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
66159 + {
66160 + .procname = "tpe_restrict_all",
66161 + .data = &grsec_enable_tpe_all,
66162 + .maxlen = sizeof(int),
66163 + .mode = 0600,
66164 + .proc_handler = &proc_dointvec,
66165 + },
66166 +#endif
66167 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
66168 + {
66169 + .procname = "socket_all",
66170 + .data = &grsec_enable_socket_all,
66171 + .maxlen = sizeof(int),
66172 + .mode = 0600,
66173 + .proc_handler = &proc_dointvec,
66174 + },
66175 + {
66176 + .procname = "socket_all_gid",
66177 + .data = &grsec_socket_all_gid,
66178 + .maxlen = sizeof(int),
66179 + .mode = 0600,
66180 + .proc_handler = &proc_dointvec,
66181 + },
66182 +#endif
66183 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
66184 + {
66185 + .procname = "socket_client",
66186 + .data = &grsec_enable_socket_client,
66187 + .maxlen = sizeof(int),
66188 + .mode = 0600,
66189 + .proc_handler = &proc_dointvec,
66190 + },
66191 + {
66192 + .procname = "socket_client_gid",
66193 + .data = &grsec_socket_client_gid,
66194 + .maxlen = sizeof(int),
66195 + .mode = 0600,
66196 + .proc_handler = &proc_dointvec,
66197 + },
66198 +#endif
66199 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
66200 + {
66201 + .procname = "socket_server",
66202 + .data = &grsec_enable_socket_server,
66203 + .maxlen = sizeof(int),
66204 + .mode = 0600,
66205 + .proc_handler = &proc_dointvec,
66206 + },
66207 + {
66208 + .procname = "socket_server_gid",
66209 + .data = &grsec_socket_server_gid,
66210 + .maxlen = sizeof(int),
66211 + .mode = 0600,
66212 + .proc_handler = &proc_dointvec,
66213 + },
66214 +#endif
66215 +#ifdef CONFIG_GRKERNSEC_AUDIT_GROUP
66216 + {
66217 + .procname = "audit_group",
66218 + .data = &grsec_enable_group,
66219 + .maxlen = sizeof(int),
66220 + .mode = 0600,
66221 + .proc_handler = &proc_dointvec,
66222 + },
66223 + {
66224 + .procname = "audit_gid",
66225 + .data = &grsec_audit_gid,
66226 + .maxlen = sizeof(int),
66227 + .mode = 0600,
66228 + .proc_handler = &proc_dointvec,
66229 + },
66230 +#endif
66231 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
66232 + {
66233 + .procname = "audit_chdir",
66234 + .data = &grsec_enable_chdir,
66235 + .maxlen = sizeof(int),
66236 + .mode = 0600,
66237 + .proc_handler = &proc_dointvec,
66238 + },
66239 +#endif
66240 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
66241 + {
66242 + .procname = "audit_mount",
66243 + .data = &grsec_enable_mount,
66244 + .maxlen = sizeof(int),
66245 + .mode = 0600,
66246 + .proc_handler = &proc_dointvec,
66247 + },
66248 +#endif
66249 +#ifdef CONFIG_GRKERNSEC_AUDIT_TEXTREL
66250 + {
66251 + .procname = "audit_textrel",
66252 + .data = &grsec_enable_audit_textrel,
66253 + .maxlen = sizeof(int),
66254 + .mode = 0600,
66255 + .proc_handler = &proc_dointvec,
66256 + },
66257 +#endif
66258 +#ifdef CONFIG_GRKERNSEC_DMESG
66259 + {
66260 + .procname = "dmesg",
66261 + .data = &grsec_enable_dmesg,
66262 + .maxlen = sizeof(int),
66263 + .mode = 0600,
66264 + .proc_handler = &proc_dointvec,
66265 + },
66266 +#endif
66267 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
66268 + {
66269 + .procname = "chroot_findtask",
66270 + .data = &grsec_enable_chroot_findtask,
66271 + .maxlen = sizeof(int),
66272 + .mode = 0600,
66273 + .proc_handler = &proc_dointvec,
66274 + },
66275 +#endif
66276 +#ifdef CONFIG_GRKERNSEC_RESLOG
66277 + {
66278 + .procname = "resource_logging",
66279 + .data = &grsec_resource_logging,
66280 + .maxlen = sizeof(int),
66281 + .mode = 0600,
66282 + .proc_handler = &proc_dointvec,
66283 + },
66284 +#endif
66285 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
66286 + {
66287 + .procname = "audit_ptrace",
66288 + .data = &grsec_enable_audit_ptrace,
66289 + .maxlen = sizeof(int),
66290 + .mode = 0600,
66291 + .proc_handler = &proc_dointvec,
66292 + },
66293 +#endif
66294 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
66295 + {
66296 + .procname = "harden_ptrace",
66297 + .data = &grsec_enable_harden_ptrace,
66298 + .maxlen = sizeof(int),
66299 + .mode = 0600,
66300 + .proc_handler = &proc_dointvec,
66301 + },
66302 +#endif
66303 + {
66304 + .procname = "grsec_lock",
66305 + .data = &grsec_lock,
66306 + .maxlen = sizeof(int),
66307 + .mode = 0600,
66308 + .proc_handler = &proc_dointvec,
66309 + },
66310 +#endif
66311 +#ifdef CONFIG_GRKERNSEC_ROFS
66312 + {
66313 + .procname = "romount_protect",
66314 + .data = &grsec_enable_rofs,
66315 + .maxlen = sizeof(int),
66316 + .mode = 0600,
66317 + .proc_handler = &proc_dointvec_minmax,
66318 + .extra1 = &one,
66319 + .extra2 = &one,
66320 + },
66321 +#endif
66322 + { }
66323 +};
66324 +#endif
66325 diff --git a/grsecurity/grsec_time.c b/grsecurity/grsec_time.c
66326 new file mode 100644
66327 index 0000000..0dc13c3
66328 --- /dev/null
66329 +++ b/grsecurity/grsec_time.c
66330 @@ -0,0 +1,16 @@
66331 +#include <linux/kernel.h>
66332 +#include <linux/sched.h>
66333 +#include <linux/grinternal.h>
66334 +#include <linux/module.h>
66335 +
66336 +void
66337 +gr_log_timechange(void)
66338 +{
66339 +#ifdef CONFIG_GRKERNSEC_TIME
66340 + if (grsec_enable_time)
66341 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_TIME_MSG);
66342 +#endif
66343 + return;
66344 +}
66345 +
66346 +EXPORT_SYMBOL(gr_log_timechange);
66347 diff --git a/grsecurity/grsec_tpe.c b/grsecurity/grsec_tpe.c
66348 new file mode 100644
66349 index 0000000..ee57dcf
66350 --- /dev/null
66351 +++ b/grsecurity/grsec_tpe.c
66352 @@ -0,0 +1,73 @@
66353 +#include <linux/kernel.h>
66354 +#include <linux/sched.h>
66355 +#include <linux/file.h>
66356 +#include <linux/fs.h>
66357 +#include <linux/grinternal.h>
66358 +
66359 +extern int gr_acl_tpe_check(void);
66360 +
66361 +int
66362 +gr_tpe_allow(const struct file *file)
66363 +{
66364 +#ifdef CONFIG_GRKERNSEC
66365 + struct inode *inode = file->f_path.dentry->d_parent->d_inode;
66366 + const struct cred *cred = current_cred();
66367 + char *msg = NULL;
66368 + char *msg2 = NULL;
66369 +
66370 + // never restrict root
66371 + if (gr_is_global_root(cred->uid))
66372 + return 1;
66373 +
66374 + if (grsec_enable_tpe) {
66375 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
66376 + if (grsec_enable_tpe_invert && !in_group_p(grsec_tpe_gid))
66377 + msg = "not being in trusted group";
66378 + else if (!grsec_enable_tpe_invert && in_group_p(grsec_tpe_gid))
66379 + msg = "being in untrusted group";
66380 +#else
66381 + if (in_group_p(grsec_tpe_gid))
66382 + msg = "being in untrusted group";
66383 +#endif
66384 + }
66385 + if (!msg && gr_acl_tpe_check())
66386 + msg = "being in untrusted role";
66387 +
66388 + // not in any affected group/role
66389 + if (!msg)
66390 + goto next_check;
66391 +
66392 + if (gr_is_global_nonroot(inode->i_uid))
66393 + msg2 = "file in non-root-owned directory";
66394 + else if (inode->i_mode & S_IWOTH)
66395 + msg2 = "file in world-writable directory";
66396 + else if (inode->i_mode & S_IWGRP)
66397 + msg2 = "file in group-writable directory";
66398 +
66399 + if (msg && msg2) {
66400 + char fullmsg[70] = {0};
66401 + snprintf(fullmsg, sizeof(fullmsg)-1, "%s and %s", msg, msg2);
66402 + gr_log_str_fs(GR_DONT_AUDIT, GR_EXEC_TPE_MSG, fullmsg, file->f_path.dentry, file->f_path.mnt);
66403 + return 0;
66404 + }
66405 + msg = NULL;
66406 +next_check:
66407 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
66408 + if (!grsec_enable_tpe || !grsec_enable_tpe_all)
66409 + return 1;
66410 +
66411 + if (gr_is_global_nonroot(inode->i_uid) && !uid_eq(inode->i_uid, cred->uid))
66412 + msg = "directory not owned by user";
66413 + else if (inode->i_mode & S_IWOTH)
66414 + msg = "file in world-writable directory";
66415 + else if (inode->i_mode & S_IWGRP)
66416 + msg = "file in group-writable directory";
66417 +
66418 + if (msg) {
66419 + gr_log_str_fs(GR_DONT_AUDIT, GR_EXEC_TPE_MSG, msg, file->f_path.dentry, file->f_path.mnt);
66420 + return 0;
66421 + }
66422 +#endif
66423 +#endif
66424 + return 1;
66425 +}
66426 diff --git a/grsecurity/grsum.c b/grsecurity/grsum.c
66427 new file mode 100644
66428 index 0000000..9f7b1ac
66429 --- /dev/null
66430 +++ b/grsecurity/grsum.c
66431 @@ -0,0 +1,61 @@
66432 +#include <linux/err.h>
66433 +#include <linux/kernel.h>
66434 +#include <linux/sched.h>
66435 +#include <linux/mm.h>
66436 +#include <linux/scatterlist.h>
66437 +#include <linux/crypto.h>
66438 +#include <linux/gracl.h>
66439 +
66440 +
66441 +#if !defined(CONFIG_CRYPTO) || defined(CONFIG_CRYPTO_MODULE) || !defined(CONFIG_CRYPTO_SHA256) || defined(CONFIG_CRYPTO_SHA256_MODULE)
66442 +#error "crypto and sha256 must be built into the kernel"
66443 +#endif
66444 +
66445 +int
66446 +chkpw(struct gr_arg *entry, unsigned char *salt, unsigned char *sum)
66447 +{
66448 + char *p;
66449 + struct crypto_hash *tfm;
66450 + struct hash_desc desc;
66451 + struct scatterlist sg;
66452 + unsigned char temp_sum[GR_SHA_LEN];
66453 + volatile int retval = 0;
66454 + volatile int dummy = 0;
66455 + unsigned int i;
66456 +
66457 + sg_init_table(&sg, 1);
66458 +
66459 + tfm = crypto_alloc_hash("sha256", 0, CRYPTO_ALG_ASYNC);
66460 + if (IS_ERR(tfm)) {
66461 + /* should never happen, since sha256 should be built in */
66462 + return 1;
66463 + }
66464 +
66465 + desc.tfm = tfm;
66466 + desc.flags = 0;
66467 +
66468 + crypto_hash_init(&desc);
66469 +
66470 + p = salt;
66471 + sg_set_buf(&sg, p, GR_SALT_LEN);
66472 + crypto_hash_update(&desc, &sg, sg.length);
66473 +
66474 + p = entry->pw;
66475 + sg_set_buf(&sg, p, strlen(p));
66476 +
66477 + crypto_hash_update(&desc, &sg, sg.length);
66478 +
66479 + crypto_hash_final(&desc, temp_sum);
66480 +
66481 + memset(entry->pw, 0, GR_PW_LEN);
66482 +
66483 + for (i = 0; i < GR_SHA_LEN; i++)
66484 + if (sum[i] != temp_sum[i])
66485 + retval = 1;
66486 + else
66487 + dummy = 1; // waste a cycle
66488 +
66489 + crypto_free_hash(tfm);
66490 +
66491 + return retval;
66492 +}
66493 diff --git a/include/asm-generic/4level-fixup.h b/include/asm-generic/4level-fixup.h
66494 index 77ff547..181834f 100644
66495 --- a/include/asm-generic/4level-fixup.h
66496 +++ b/include/asm-generic/4level-fixup.h
66497 @@ -13,8 +13,10 @@
66498 #define pmd_alloc(mm, pud, address) \
66499 ((unlikely(pgd_none(*(pud))) && __pmd_alloc(mm, pud, address))? \
66500 NULL: pmd_offset(pud, address))
66501 +#define pmd_alloc_kernel(mm, pud, address) pmd_alloc((mm), (pud), (address))
66502
66503 #define pud_alloc(mm, pgd, address) (pgd)
66504 +#define pud_alloc_kernel(mm, pgd, address) pud_alloc((mm), (pgd), (address))
66505 #define pud_offset(pgd, start) (pgd)
66506 #define pud_none(pud) 0
66507 #define pud_bad(pud) 0
66508 diff --git a/include/asm-generic/atomic-long.h b/include/asm-generic/atomic-long.h
66509 index b7babf0..04ad282 100644
66510 --- a/include/asm-generic/atomic-long.h
66511 +++ b/include/asm-generic/atomic-long.h
66512 @@ -22,6 +22,12 @@
66513
66514 typedef atomic64_t atomic_long_t;
66515
66516 +#ifdef CONFIG_PAX_REFCOUNT
66517 +typedef atomic64_unchecked_t atomic_long_unchecked_t;
66518 +#else
66519 +typedef atomic64_t atomic_long_unchecked_t;
66520 +#endif
66521 +
66522 #define ATOMIC_LONG_INIT(i) ATOMIC64_INIT(i)
66523
66524 static inline long atomic_long_read(atomic_long_t *l)
66525 @@ -31,6 +37,15 @@ static inline long atomic_long_read(atomic_long_t *l)
66526 return (long)atomic64_read(v);
66527 }
66528
66529 +#ifdef CONFIG_PAX_REFCOUNT
66530 +static inline long atomic_long_read_unchecked(atomic_long_unchecked_t *l)
66531 +{
66532 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
66533 +
66534 + return (long)atomic64_read_unchecked(v);
66535 +}
66536 +#endif
66537 +
66538 static inline void atomic_long_set(atomic_long_t *l, long i)
66539 {
66540 atomic64_t *v = (atomic64_t *)l;
66541 @@ -38,6 +53,15 @@ static inline void atomic_long_set(atomic_long_t *l, long i)
66542 atomic64_set(v, i);
66543 }
66544
66545 +#ifdef CONFIG_PAX_REFCOUNT
66546 +static inline void atomic_long_set_unchecked(atomic_long_unchecked_t *l, long i)
66547 +{
66548 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
66549 +
66550 + atomic64_set_unchecked(v, i);
66551 +}
66552 +#endif
66553 +
66554 static inline void atomic_long_inc(atomic_long_t *l)
66555 {
66556 atomic64_t *v = (atomic64_t *)l;
66557 @@ -45,6 +69,15 @@ static inline void atomic_long_inc(atomic_long_t *l)
66558 atomic64_inc(v);
66559 }
66560
66561 +#ifdef CONFIG_PAX_REFCOUNT
66562 +static inline void atomic_long_inc_unchecked(atomic_long_unchecked_t *l)
66563 +{
66564 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
66565 +
66566 + atomic64_inc_unchecked(v);
66567 +}
66568 +#endif
66569 +
66570 static inline void atomic_long_dec(atomic_long_t *l)
66571 {
66572 atomic64_t *v = (atomic64_t *)l;
66573 @@ -52,6 +85,15 @@ static inline void atomic_long_dec(atomic_long_t *l)
66574 atomic64_dec(v);
66575 }
66576
66577 +#ifdef CONFIG_PAX_REFCOUNT
66578 +static inline void atomic_long_dec_unchecked(atomic_long_unchecked_t *l)
66579 +{
66580 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
66581 +
66582 + atomic64_dec_unchecked(v);
66583 +}
66584 +#endif
66585 +
66586 static inline void atomic_long_add(long i, atomic_long_t *l)
66587 {
66588 atomic64_t *v = (atomic64_t *)l;
66589 @@ -59,6 +101,15 @@ static inline void atomic_long_add(long i, atomic_long_t *l)
66590 atomic64_add(i, v);
66591 }
66592
66593 +#ifdef CONFIG_PAX_REFCOUNT
66594 +static inline void atomic_long_add_unchecked(long i, atomic_long_unchecked_t *l)
66595 +{
66596 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
66597 +
66598 + atomic64_add_unchecked(i, v);
66599 +}
66600 +#endif
66601 +
66602 static inline void atomic_long_sub(long i, atomic_long_t *l)
66603 {
66604 atomic64_t *v = (atomic64_t *)l;
66605 @@ -66,6 +117,15 @@ static inline void atomic_long_sub(long i, atomic_long_t *l)
66606 atomic64_sub(i, v);
66607 }
66608
66609 +#ifdef CONFIG_PAX_REFCOUNT
66610 +static inline void atomic_long_sub_unchecked(long i, atomic_long_unchecked_t *l)
66611 +{
66612 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
66613 +
66614 + atomic64_sub_unchecked(i, v);
66615 +}
66616 +#endif
66617 +
66618 static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
66619 {
66620 atomic64_t *v = (atomic64_t *)l;
66621 @@ -101,6 +161,15 @@ static inline long atomic_long_add_return(long i, atomic_long_t *l)
66622 return (long)atomic64_add_return(i, v);
66623 }
66624
66625 +#ifdef CONFIG_PAX_REFCOUNT
66626 +static inline long atomic_long_add_return_unchecked(long i, atomic_long_unchecked_t *l)
66627 +{
66628 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
66629 +
66630 + return (long)atomic64_add_return_unchecked(i, v);
66631 +}
66632 +#endif
66633 +
66634 static inline long atomic_long_sub_return(long i, atomic_long_t *l)
66635 {
66636 atomic64_t *v = (atomic64_t *)l;
66637 @@ -115,6 +184,15 @@ static inline long atomic_long_inc_return(atomic_long_t *l)
66638 return (long)atomic64_inc_return(v);
66639 }
66640
66641 +#ifdef CONFIG_PAX_REFCOUNT
66642 +static inline long atomic_long_inc_return_unchecked(atomic_long_unchecked_t *l)
66643 +{
66644 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
66645 +
66646 + return (long)atomic64_inc_return_unchecked(v);
66647 +}
66648 +#endif
66649 +
66650 static inline long atomic_long_dec_return(atomic_long_t *l)
66651 {
66652 atomic64_t *v = (atomic64_t *)l;
66653 @@ -140,6 +218,12 @@ static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
66654
66655 typedef atomic_t atomic_long_t;
66656
66657 +#ifdef CONFIG_PAX_REFCOUNT
66658 +typedef atomic_unchecked_t atomic_long_unchecked_t;
66659 +#else
66660 +typedef atomic_t atomic_long_unchecked_t;
66661 +#endif
66662 +
66663 #define ATOMIC_LONG_INIT(i) ATOMIC_INIT(i)
66664 static inline long atomic_long_read(atomic_long_t *l)
66665 {
66666 @@ -148,6 +232,15 @@ static inline long atomic_long_read(atomic_long_t *l)
66667 return (long)atomic_read(v);
66668 }
66669
66670 +#ifdef CONFIG_PAX_REFCOUNT
66671 +static inline long atomic_long_read_unchecked(atomic_long_unchecked_t *l)
66672 +{
66673 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
66674 +
66675 + return (long)atomic_read_unchecked(v);
66676 +}
66677 +#endif
66678 +
66679 static inline void atomic_long_set(atomic_long_t *l, long i)
66680 {
66681 atomic_t *v = (atomic_t *)l;
66682 @@ -155,6 +248,15 @@ static inline void atomic_long_set(atomic_long_t *l, long i)
66683 atomic_set(v, i);
66684 }
66685
66686 +#ifdef CONFIG_PAX_REFCOUNT
66687 +static inline void atomic_long_set_unchecked(atomic_long_unchecked_t *l, long i)
66688 +{
66689 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
66690 +
66691 + atomic_set_unchecked(v, i);
66692 +}
66693 +#endif
66694 +
66695 static inline void atomic_long_inc(atomic_long_t *l)
66696 {
66697 atomic_t *v = (atomic_t *)l;
66698 @@ -162,6 +264,15 @@ static inline void atomic_long_inc(atomic_long_t *l)
66699 atomic_inc(v);
66700 }
66701
66702 +#ifdef CONFIG_PAX_REFCOUNT
66703 +static inline void atomic_long_inc_unchecked(atomic_long_unchecked_t *l)
66704 +{
66705 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
66706 +
66707 + atomic_inc_unchecked(v);
66708 +}
66709 +#endif
66710 +
66711 static inline void atomic_long_dec(atomic_long_t *l)
66712 {
66713 atomic_t *v = (atomic_t *)l;
66714 @@ -169,6 +280,15 @@ static inline void atomic_long_dec(atomic_long_t *l)
66715 atomic_dec(v);
66716 }
66717
66718 +#ifdef CONFIG_PAX_REFCOUNT
66719 +static inline void atomic_long_dec_unchecked(atomic_long_unchecked_t *l)
66720 +{
66721 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
66722 +
66723 + atomic_dec_unchecked(v);
66724 +}
66725 +#endif
66726 +
66727 static inline void atomic_long_add(long i, atomic_long_t *l)
66728 {
66729 atomic_t *v = (atomic_t *)l;
66730 @@ -176,6 +296,15 @@ static inline void atomic_long_add(long i, atomic_long_t *l)
66731 atomic_add(i, v);
66732 }
66733
66734 +#ifdef CONFIG_PAX_REFCOUNT
66735 +static inline void atomic_long_add_unchecked(long i, atomic_long_unchecked_t *l)
66736 +{
66737 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
66738 +
66739 + atomic_add_unchecked(i, v);
66740 +}
66741 +#endif
66742 +
66743 static inline void atomic_long_sub(long i, atomic_long_t *l)
66744 {
66745 atomic_t *v = (atomic_t *)l;
66746 @@ -183,6 +312,15 @@ static inline void atomic_long_sub(long i, atomic_long_t *l)
66747 atomic_sub(i, v);
66748 }
66749
66750 +#ifdef CONFIG_PAX_REFCOUNT
66751 +static inline void atomic_long_sub_unchecked(long i, atomic_long_unchecked_t *l)
66752 +{
66753 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
66754 +
66755 + atomic_sub_unchecked(i, v);
66756 +}
66757 +#endif
66758 +
66759 static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
66760 {
66761 atomic_t *v = (atomic_t *)l;
66762 @@ -218,6 +356,16 @@ static inline long atomic_long_add_return(long i, atomic_long_t *l)
66763 return (long)atomic_add_return(i, v);
66764 }
66765
66766 +#ifdef CONFIG_PAX_REFCOUNT
66767 +static inline long atomic_long_add_return_unchecked(long i, atomic_long_unchecked_t *l)
66768 +{
66769 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
66770 +
66771 + return (long)atomic_add_return_unchecked(i, v);
66772 +}
66773 +
66774 +#endif
66775 +
66776 static inline long atomic_long_sub_return(long i, atomic_long_t *l)
66777 {
66778 atomic_t *v = (atomic_t *)l;
66779 @@ -232,6 +380,15 @@ static inline long atomic_long_inc_return(atomic_long_t *l)
66780 return (long)atomic_inc_return(v);
66781 }
66782
66783 +#ifdef CONFIG_PAX_REFCOUNT
66784 +static inline long atomic_long_inc_return_unchecked(atomic_long_unchecked_t *l)
66785 +{
66786 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
66787 +
66788 + return (long)atomic_inc_return_unchecked(v);
66789 +}
66790 +#endif
66791 +
66792 static inline long atomic_long_dec_return(atomic_long_t *l)
66793 {
66794 atomic_t *v = (atomic_t *)l;
66795 @@ -255,4 +412,57 @@ static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
66796
66797 #endif /* BITS_PER_LONG == 64 */
66798
66799 +#ifdef CONFIG_PAX_REFCOUNT
66800 +static inline void pax_refcount_needs_these_functions(void)
66801 +{
66802 + atomic_read_unchecked((atomic_unchecked_t *)NULL);
66803 + atomic_set_unchecked((atomic_unchecked_t *)NULL, 0);
66804 + atomic_add_unchecked(0, (atomic_unchecked_t *)NULL);
66805 + atomic_sub_unchecked(0, (atomic_unchecked_t *)NULL);
66806 + atomic_inc_unchecked((atomic_unchecked_t *)NULL);
66807 + (void)atomic_inc_and_test_unchecked((atomic_unchecked_t *)NULL);
66808 + atomic_inc_return_unchecked((atomic_unchecked_t *)NULL);
66809 + atomic_add_return_unchecked(0, (atomic_unchecked_t *)NULL);
66810 + atomic_dec_unchecked((atomic_unchecked_t *)NULL);
66811 + atomic_cmpxchg_unchecked((atomic_unchecked_t *)NULL, 0, 0);
66812 + (void)atomic_xchg_unchecked((atomic_unchecked_t *)NULL, 0);
66813 +#ifdef CONFIG_X86
66814 + atomic_clear_mask_unchecked(0, NULL);
66815 + atomic_set_mask_unchecked(0, NULL);
66816 +#endif
66817 +
66818 + atomic_long_read_unchecked((atomic_long_unchecked_t *)NULL);
66819 + atomic_long_set_unchecked((atomic_long_unchecked_t *)NULL, 0);
66820 + atomic_long_add_unchecked(0, (atomic_long_unchecked_t *)NULL);
66821 + atomic_long_sub_unchecked(0, (atomic_long_unchecked_t *)NULL);
66822 + atomic_long_inc_unchecked((atomic_long_unchecked_t *)NULL);
66823 + atomic_long_add_return_unchecked(0, (atomic_long_unchecked_t *)NULL);
66824 + atomic_long_inc_return_unchecked((atomic_long_unchecked_t *)NULL);
66825 + atomic_long_dec_unchecked((atomic_long_unchecked_t *)NULL);
66826 +}
66827 +#else
66828 +#define atomic_read_unchecked(v) atomic_read(v)
66829 +#define atomic_set_unchecked(v, i) atomic_set((v), (i))
66830 +#define atomic_add_unchecked(i, v) atomic_add((i), (v))
66831 +#define atomic_sub_unchecked(i, v) atomic_sub((i), (v))
66832 +#define atomic_inc_unchecked(v) atomic_inc(v)
66833 +#define atomic_inc_and_test_unchecked(v) atomic_inc_and_test(v)
66834 +#define atomic_inc_return_unchecked(v) atomic_inc_return(v)
66835 +#define atomic_add_return_unchecked(i, v) atomic_add_return((i), (v))
66836 +#define atomic_dec_unchecked(v) atomic_dec(v)
66837 +#define atomic_cmpxchg_unchecked(v, o, n) atomic_cmpxchg((v), (o), (n))
66838 +#define atomic_xchg_unchecked(v, i) atomic_xchg((v), (i))
66839 +#define atomic_clear_mask_unchecked(mask, v) atomic_clear_mask((mask), (v))
66840 +#define atomic_set_mask_unchecked(mask, v) atomic_set_mask((mask), (v))
66841 +
66842 +#define atomic_long_read_unchecked(v) atomic_long_read(v)
66843 +#define atomic_long_set_unchecked(v, i) atomic_long_set((v), (i))
66844 +#define atomic_long_add_unchecked(i, v) atomic_long_add((i), (v))
66845 +#define atomic_long_sub_unchecked(i, v) atomic_long_sub((i), (v))
66846 +#define atomic_long_inc_unchecked(v) atomic_long_inc(v)
66847 +#define atomic_long_add_return_unchecked(i, v) atomic_long_add_return((i), (v))
66848 +#define atomic_long_inc_return_unchecked(v) atomic_long_inc_return(v)
66849 +#define atomic_long_dec_unchecked(v) atomic_long_dec(v)
66850 +#endif
66851 +
66852 #endif /* _ASM_GENERIC_ATOMIC_LONG_H */
66853 diff --git a/include/asm-generic/atomic.h b/include/asm-generic/atomic.h
66854 index 33bd2de..f31bff97 100644
66855 --- a/include/asm-generic/atomic.h
66856 +++ b/include/asm-generic/atomic.h
66857 @@ -153,7 +153,7 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
66858 * Atomically clears the bits set in @mask from @v
66859 */
66860 #ifndef atomic_clear_mask
66861 -static inline void atomic_clear_mask(unsigned long mask, atomic_t *v)
66862 +static inline void atomic_clear_mask(unsigned int mask, atomic_t *v)
66863 {
66864 unsigned long flags;
66865
66866 diff --git a/include/asm-generic/atomic64.h b/include/asm-generic/atomic64.h
66867 index b18ce4f..2ee2843 100644
66868 --- a/include/asm-generic/atomic64.h
66869 +++ b/include/asm-generic/atomic64.h
66870 @@ -16,6 +16,8 @@ typedef struct {
66871 long long counter;
66872 } atomic64_t;
66873
66874 +typedef atomic64_t atomic64_unchecked_t;
66875 +
66876 #define ATOMIC64_INIT(i) { (i) }
66877
66878 extern long long atomic64_read(const atomic64_t *v);
66879 @@ -39,4 +41,14 @@ extern int atomic64_add_unless(atomic64_t *v, long long a, long long u);
66880 #define atomic64_dec_and_test(v) (atomic64_dec_return((v)) == 0)
66881 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1LL, 0LL)
66882
66883 +#define atomic64_read_unchecked(v) atomic64_read(v)
66884 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
66885 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
66886 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
66887 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
66888 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
66889 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
66890 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
66891 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
66892 +
66893 #endif /* _ASM_GENERIC_ATOMIC64_H */
66894 diff --git a/include/asm-generic/cache.h b/include/asm-generic/cache.h
66895 index 1bfcfe5..e04c5c9 100644
66896 --- a/include/asm-generic/cache.h
66897 +++ b/include/asm-generic/cache.h
66898 @@ -6,7 +6,7 @@
66899 * cache lines need to provide their own cache.h.
66900 */
66901
66902 -#define L1_CACHE_SHIFT 5
66903 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
66904 +#define L1_CACHE_SHIFT 5UL
66905 +#define L1_CACHE_BYTES (1UL << L1_CACHE_SHIFT)
66906
66907 #endif /* __ASM_GENERIC_CACHE_H */
66908 diff --git a/include/asm-generic/emergency-restart.h b/include/asm-generic/emergency-restart.h
66909 index 0d68a1e..b74a761 100644
66910 --- a/include/asm-generic/emergency-restart.h
66911 +++ b/include/asm-generic/emergency-restart.h
66912 @@ -1,7 +1,7 @@
66913 #ifndef _ASM_GENERIC_EMERGENCY_RESTART_H
66914 #define _ASM_GENERIC_EMERGENCY_RESTART_H
66915
66916 -static inline void machine_emergency_restart(void)
66917 +static inline __noreturn void machine_emergency_restart(void)
66918 {
66919 machine_restart(NULL);
66920 }
66921 diff --git a/include/asm-generic/kmap_types.h b/include/asm-generic/kmap_types.h
66922 index 90f99c7..00ce236 100644
66923 --- a/include/asm-generic/kmap_types.h
66924 +++ b/include/asm-generic/kmap_types.h
66925 @@ -2,9 +2,9 @@
66926 #define _ASM_GENERIC_KMAP_TYPES_H
66927
66928 #ifdef __WITH_KM_FENCE
66929 -# define KM_TYPE_NR 41
66930 +# define KM_TYPE_NR 42
66931 #else
66932 -# define KM_TYPE_NR 20
66933 +# define KM_TYPE_NR 21
66934 #endif
66935
66936 #endif
66937 diff --git a/include/asm-generic/local.h b/include/asm-generic/local.h
66938 index 9ceb03b..62b0b8f 100644
66939 --- a/include/asm-generic/local.h
66940 +++ b/include/asm-generic/local.h
66941 @@ -23,24 +23,37 @@ typedef struct
66942 atomic_long_t a;
66943 } local_t;
66944
66945 +typedef struct {
66946 + atomic_long_unchecked_t a;
66947 +} local_unchecked_t;
66948 +
66949 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
66950
66951 #define local_read(l) atomic_long_read(&(l)->a)
66952 +#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
66953 #define local_set(l,i) atomic_long_set((&(l)->a),(i))
66954 +#define local_set_unchecked(l,i) atomic_long_set_unchecked((&(l)->a),(i))
66955 #define local_inc(l) atomic_long_inc(&(l)->a)
66956 +#define local_inc_unchecked(l) atomic_long_inc_unchecked(&(l)->a)
66957 #define local_dec(l) atomic_long_dec(&(l)->a)
66958 +#define local_dec_unchecked(l) atomic_long_dec_unchecked(&(l)->a)
66959 #define local_add(i,l) atomic_long_add((i),(&(l)->a))
66960 +#define local_add_unchecked(i,l) atomic_long_add_unchecked((i),(&(l)->a))
66961 #define local_sub(i,l) atomic_long_sub((i),(&(l)->a))
66962 +#define local_sub_unchecked(i,l) atomic_long_sub_unchecked((i),(&(l)->a))
66963
66964 #define local_sub_and_test(i, l) atomic_long_sub_and_test((i), (&(l)->a))
66965 #define local_dec_and_test(l) atomic_long_dec_and_test(&(l)->a)
66966 #define local_inc_and_test(l) atomic_long_inc_and_test(&(l)->a)
66967 #define local_add_negative(i, l) atomic_long_add_negative((i), (&(l)->a))
66968 #define local_add_return(i, l) atomic_long_add_return((i), (&(l)->a))
66969 +#define local_add_return_unchecked(i, l) atomic_long_add_return_unchecked((i), (&(l)->a))
66970 #define local_sub_return(i, l) atomic_long_sub_return((i), (&(l)->a))
66971 #define local_inc_return(l) atomic_long_inc_return(&(l)->a)
66972 +#define local_dec_return(l) atomic_long_dec_return(&(l)->a)
66973
66974 #define local_cmpxchg(l, o, n) atomic_long_cmpxchg((&(l)->a), (o), (n))
66975 +#define local_cmpxchg_unchecked(l, o, n) atomic_long_cmpxchg((&(l)->a), (o), (n))
66976 #define local_xchg(l, n) atomic_long_xchg((&(l)->a), (n))
66977 #define local_add_unless(l, _a, u) atomic_long_add_unless((&(l)->a), (_a), (u))
66978 #define local_inc_not_zero(l) atomic_long_inc_not_zero(&(l)->a)
66979 diff --git a/include/asm-generic/pgtable-nopmd.h b/include/asm-generic/pgtable-nopmd.h
66980 index 725612b..9cc513a 100644
66981 --- a/include/asm-generic/pgtable-nopmd.h
66982 +++ b/include/asm-generic/pgtable-nopmd.h
66983 @@ -1,14 +1,19 @@
66984 #ifndef _PGTABLE_NOPMD_H
66985 #define _PGTABLE_NOPMD_H
66986
66987 -#ifndef __ASSEMBLY__
66988 -
66989 #include <asm-generic/pgtable-nopud.h>
66990
66991 -struct mm_struct;
66992 -
66993 #define __PAGETABLE_PMD_FOLDED
66994
66995 +#define PMD_SHIFT PUD_SHIFT
66996 +#define PTRS_PER_PMD 1
66997 +#define PMD_SIZE (_AC(1,UL) << PMD_SHIFT)
66998 +#define PMD_MASK (~(PMD_SIZE-1))
66999 +
67000 +#ifndef __ASSEMBLY__
67001 +
67002 +struct mm_struct;
67003 +
67004 /*
67005 * Having the pmd type consist of a pud gets the size right, and allows
67006 * us to conceptually access the pud entry that this pmd is folded into
67007 @@ -16,11 +21,6 @@ struct mm_struct;
67008 */
67009 typedef struct { pud_t pud; } pmd_t;
67010
67011 -#define PMD_SHIFT PUD_SHIFT
67012 -#define PTRS_PER_PMD 1
67013 -#define PMD_SIZE (1UL << PMD_SHIFT)
67014 -#define PMD_MASK (~(PMD_SIZE-1))
67015 -
67016 /*
67017 * The "pud_xxx()" functions here are trivial for a folded two-level
67018 * setup: the pmd is never bad, and a pmd always exists (as it's folded
67019 diff --git a/include/asm-generic/pgtable-nopud.h b/include/asm-generic/pgtable-nopud.h
67020 index 810431d..0ec4804f 100644
67021 --- a/include/asm-generic/pgtable-nopud.h
67022 +++ b/include/asm-generic/pgtable-nopud.h
67023 @@ -1,10 +1,15 @@
67024 #ifndef _PGTABLE_NOPUD_H
67025 #define _PGTABLE_NOPUD_H
67026
67027 -#ifndef __ASSEMBLY__
67028 -
67029 #define __PAGETABLE_PUD_FOLDED
67030
67031 +#define PUD_SHIFT PGDIR_SHIFT
67032 +#define PTRS_PER_PUD 1
67033 +#define PUD_SIZE (_AC(1,UL) << PUD_SHIFT)
67034 +#define PUD_MASK (~(PUD_SIZE-1))
67035 +
67036 +#ifndef __ASSEMBLY__
67037 +
67038 /*
67039 * Having the pud type consist of a pgd gets the size right, and allows
67040 * us to conceptually access the pgd entry that this pud is folded into
67041 @@ -12,11 +17,6 @@
67042 */
67043 typedef struct { pgd_t pgd; } pud_t;
67044
67045 -#define PUD_SHIFT PGDIR_SHIFT
67046 -#define PTRS_PER_PUD 1
67047 -#define PUD_SIZE (1UL << PUD_SHIFT)
67048 -#define PUD_MASK (~(PUD_SIZE-1))
67049 -
67050 /*
67051 * The "pgd_xxx()" functions here are trivial for a folded two-level
67052 * setup: the pud is never bad, and a pud always exists (as it's folded
67053 @@ -29,6 +29,7 @@ static inline void pgd_clear(pgd_t *pgd) { }
67054 #define pud_ERROR(pud) (pgd_ERROR((pud).pgd))
67055
67056 #define pgd_populate(mm, pgd, pud) do { } while (0)
67057 +#define pgd_populate_kernel(mm, pgd, pud) do { } while (0)
67058 /*
67059 * (puds are folded into pgds so this doesn't get actually called,
67060 * but the define is needed for a generic inline function.)
67061 diff --git a/include/asm-generic/pgtable.h b/include/asm-generic/pgtable.h
67062 index a59ff51..2594a70 100644
67063 --- a/include/asm-generic/pgtable.h
67064 +++ b/include/asm-generic/pgtable.h
67065 @@ -688,6 +688,14 @@ static inline pmd_t pmd_mknuma(pmd_t pmd)
67066 }
67067 #endif /* CONFIG_NUMA_BALANCING */
67068
67069 +#ifndef __HAVE_ARCH_PAX_OPEN_KERNEL
67070 +static inline unsigned long pax_open_kernel(void) { return 0; }
67071 +#endif
67072 +
67073 +#ifndef __HAVE_ARCH_PAX_CLOSE_KERNEL
67074 +static inline unsigned long pax_close_kernel(void) { return 0; }
67075 +#endif
67076 +
67077 #endif /* CONFIG_MMU */
67078
67079 #endif /* !__ASSEMBLY__ */
67080 diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
67081 index afa12c7..99d4da0 100644
67082 --- a/include/asm-generic/vmlinux.lds.h
67083 +++ b/include/asm-generic/vmlinux.lds.h
67084 @@ -245,6 +245,7 @@
67085 .rodata : AT(ADDR(.rodata) - LOAD_OFFSET) { \
67086 VMLINUX_SYMBOL(__start_rodata) = .; \
67087 *(.rodata) *(.rodata.*) \
67088 + *(.data..read_only) \
67089 *(__vermagic) /* Kernel version magic */ \
67090 . = ALIGN(8); \
67091 VMLINUX_SYMBOL(__start___tracepoints_ptrs) = .; \
67092 @@ -755,17 +756,18 @@
67093 * section in the linker script will go there too. @phdr should have
67094 * a leading colon.
67095 *
67096 - * Note that this macros defines __per_cpu_load as an absolute symbol.
67097 + * Note that this macros defines per_cpu_load as an absolute symbol.
67098 * If there is no need to put the percpu section at a predetermined
67099 * address, use PERCPU_SECTION.
67100 */
67101 #define PERCPU_VADDR(cacheline, vaddr, phdr) \
67102 - VMLINUX_SYMBOL(__per_cpu_load) = .; \
67103 - .data..percpu vaddr : AT(VMLINUX_SYMBOL(__per_cpu_load) \
67104 + per_cpu_load = .; \
67105 + .data..percpu vaddr : AT(VMLINUX_SYMBOL(per_cpu_load) \
67106 - LOAD_OFFSET) { \
67107 + VMLINUX_SYMBOL(__per_cpu_load) = . + per_cpu_load; \
67108 PERCPU_INPUT(cacheline) \
67109 } phdr \
67110 - . = VMLINUX_SYMBOL(__per_cpu_load) + SIZEOF(.data..percpu);
67111 + . = VMLINUX_SYMBOL(per_cpu_load) + SIZEOF(.data..percpu);
67112
67113 /**
67114 * PERCPU_SECTION - define output section for percpu area, simple version
67115 diff --git a/include/crypto/algapi.h b/include/crypto/algapi.h
67116 index 418d270..bfd2794 100644
67117 --- a/include/crypto/algapi.h
67118 +++ b/include/crypto/algapi.h
67119 @@ -34,7 +34,7 @@ struct crypto_type {
67120 unsigned int maskclear;
67121 unsigned int maskset;
67122 unsigned int tfmsize;
67123 -};
67124 +} __do_const;
67125
67126 struct crypto_instance {
67127 struct crypto_alg alg;
67128 diff --git a/include/drm/drmP.h b/include/drm/drmP.h
67129 index f1ce786..086a7a5 100644
67130 --- a/include/drm/drmP.h
67131 +++ b/include/drm/drmP.h
67132 @@ -72,6 +72,7 @@
67133 #include <linux/workqueue.h>
67134 #include <linux/poll.h>
67135 #include <asm/pgalloc.h>
67136 +#include <asm/local.h>
67137 #include <drm/drm.h>
67138 #include <drm/drm_sarea.h>
67139
67140 @@ -296,10 +297,12 @@ do { \
67141 * \param cmd command.
67142 * \param arg argument.
67143 */
67144 -typedef int drm_ioctl_t(struct drm_device *dev, void *data,
67145 +typedef int (* const drm_ioctl_t)(struct drm_device *dev, void *data,
67146 + struct drm_file *file_priv);
67147 +typedef int (* drm_ioctl_no_const_t)(struct drm_device *dev, void *data,
67148 struct drm_file *file_priv);
67149
67150 -typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
67151 +typedef int (* const drm_ioctl_compat_t)(struct file *filp, unsigned int cmd,
67152 unsigned long arg);
67153
67154 #define DRM_IOCTL_NR(n) _IOC_NR(n)
67155 @@ -314,9 +317,9 @@ typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
67156 struct drm_ioctl_desc {
67157 unsigned int cmd;
67158 int flags;
67159 - drm_ioctl_t *func;
67160 + drm_ioctl_t func;
67161 unsigned int cmd_drv;
67162 -};
67163 +} __do_const;
67164
67165 /**
67166 * Creates a driver or general drm_ioctl_desc array entry for the given
67167 @@ -1014,7 +1017,7 @@ struct drm_info_list {
67168 int (*show)(struct seq_file*, void*); /** show callback */
67169 u32 driver_features; /**< Required driver features for this entry */
67170 void *data;
67171 -};
67172 +} __do_const;
67173
67174 /**
67175 * debugfs node structure. This structure represents a debugfs file.
67176 @@ -1087,7 +1090,7 @@ struct drm_device {
67177
67178 /** \name Usage Counters */
67179 /*@{ */
67180 - int open_count; /**< Outstanding files open */
67181 + local_t open_count; /**< Outstanding files open */
67182 atomic_t ioctl_count; /**< Outstanding IOCTLs pending */
67183 atomic_t vma_count; /**< Outstanding vma areas open */
67184 int buf_use; /**< Buffers in use -- cannot alloc */
67185 @@ -1098,7 +1101,7 @@ struct drm_device {
67186 /*@{ */
67187 unsigned long counters;
67188 enum drm_stat_type types[15];
67189 - atomic_t counts[15];
67190 + atomic_unchecked_t counts[15];
67191 /*@} */
67192
67193 struct list_head filelist;
67194 diff --git a/include/drm/drm_crtc_helper.h b/include/drm/drm_crtc_helper.h
67195 index f43d556..94d9343 100644
67196 --- a/include/drm/drm_crtc_helper.h
67197 +++ b/include/drm/drm_crtc_helper.h
67198 @@ -109,7 +109,7 @@ struct drm_encoder_helper_funcs {
67199 struct drm_connector *connector);
67200 /* disable encoder when not in use - more explicit than dpms off */
67201 void (*disable)(struct drm_encoder *encoder);
67202 -};
67203 +} __no_const;
67204
67205 /**
67206 * drm_connector_helper_funcs - helper operations for connectors
67207 diff --git a/include/drm/ttm/ttm_memory.h b/include/drm/ttm/ttm_memory.h
67208 index 72dcbe8..8db58d7 100644
67209 --- a/include/drm/ttm/ttm_memory.h
67210 +++ b/include/drm/ttm/ttm_memory.h
67211 @@ -48,7 +48,7 @@
67212
67213 struct ttm_mem_shrink {
67214 int (*do_shrink) (struct ttm_mem_shrink *);
67215 -};
67216 +} __no_const;
67217
67218 /**
67219 * struct ttm_mem_global - Global memory accounting structure.
67220 diff --git a/include/keys/asymmetric-subtype.h b/include/keys/asymmetric-subtype.h
67221 index 4b840e8..155d235 100644
67222 --- a/include/keys/asymmetric-subtype.h
67223 +++ b/include/keys/asymmetric-subtype.h
67224 @@ -37,7 +37,7 @@ struct asymmetric_key_subtype {
67225 /* Verify the signature on a key of this subtype (optional) */
67226 int (*verify_signature)(const struct key *key,
67227 const struct public_key_signature *sig);
67228 -};
67229 +} __do_const;
67230
67231 /**
67232 * asymmetric_key_subtype - Get the subtype from an asymmetric key
67233 diff --git a/include/linux/atmdev.h b/include/linux/atmdev.h
67234 index c1da539..1dcec55 100644
67235 --- a/include/linux/atmdev.h
67236 +++ b/include/linux/atmdev.h
67237 @@ -28,7 +28,7 @@ struct compat_atm_iobuf {
67238 #endif
67239
67240 struct k_atm_aal_stats {
67241 -#define __HANDLE_ITEM(i) atomic_t i
67242 +#define __HANDLE_ITEM(i) atomic_unchecked_t i
67243 __AAL_STAT_ITEMS
67244 #undef __HANDLE_ITEM
67245 };
67246 @@ -200,7 +200,7 @@ struct atmdev_ops { /* only send is required */
67247 int (*change_qos)(struct atm_vcc *vcc,struct atm_qos *qos,int flags);
67248 int (*proc_read)(struct atm_dev *dev,loff_t *pos,char *page);
67249 struct module *owner;
67250 -};
67251 +} __do_const ;
67252
67253 struct atmphy_ops {
67254 int (*start)(struct atm_dev *dev);
67255 diff --git a/include/linux/binfmts.h b/include/linux/binfmts.h
67256 index c3a0914..ec5d48a 100644
67257 --- a/include/linux/binfmts.h
67258 +++ b/include/linux/binfmts.h
67259 @@ -73,8 +73,9 @@ struct linux_binfmt {
67260 int (*load_binary)(struct linux_binprm *);
67261 int (*load_shlib)(struct file *);
67262 int (*core_dump)(struct coredump_params *cprm);
67263 + void (*handle_mprotect)(struct vm_area_struct *vma, unsigned long newflags);
67264 unsigned long min_coredump; /* minimal dump size */
67265 -};
67266 +} __do_const;
67267
67268 extern void __register_binfmt(struct linux_binfmt *fmt, int insert);
67269
67270 diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
67271 index 33f358f..7f2c27f 100644
67272 --- a/include/linux/blkdev.h
67273 +++ b/include/linux/blkdev.h
67274 @@ -1499,7 +1499,7 @@ struct block_device_operations {
67275 /* this callback is with swap_lock and sometimes page table lock held */
67276 void (*swap_slot_free_notify) (struct block_device *, unsigned long);
67277 struct module *owner;
67278 -};
67279 +} __do_const;
67280
67281 extern int __blkdev_driver_ioctl(struct block_device *, fmode_t, unsigned int,
67282 unsigned long);
67283 diff --git a/include/linux/blktrace_api.h b/include/linux/blktrace_api.h
67284 index 7c2e030..b72475d 100644
67285 --- a/include/linux/blktrace_api.h
67286 +++ b/include/linux/blktrace_api.h
67287 @@ -23,7 +23,7 @@ struct blk_trace {
67288 struct dentry *dir;
67289 struct dentry *dropped_file;
67290 struct dentry *msg_file;
67291 - atomic_t dropped;
67292 + atomic_unchecked_t dropped;
67293 };
67294
67295 extern int blk_trace_ioctl(struct block_device *, unsigned, char __user *);
67296 diff --git a/include/linux/cache.h b/include/linux/cache.h
67297 index 4c57065..4307975 100644
67298 --- a/include/linux/cache.h
67299 +++ b/include/linux/cache.h
67300 @@ -16,6 +16,10 @@
67301 #define __read_mostly
67302 #endif
67303
67304 +#ifndef __read_only
67305 +#define __read_only __read_mostly
67306 +#endif
67307 +
67308 #ifndef ____cacheline_aligned
67309 #define ____cacheline_aligned __attribute__((__aligned__(SMP_CACHE_BYTES)))
67310 #endif
67311 diff --git a/include/linux/capability.h b/include/linux/capability.h
67312 index d9a4f7f4..19f77d6 100644
67313 --- a/include/linux/capability.h
67314 +++ b/include/linux/capability.h
67315 @@ -213,8 +213,13 @@ extern bool ns_capable(struct user_namespace *ns, int cap);
67316 extern bool nsown_capable(int cap);
67317 extern bool inode_capable(const struct inode *inode, int cap);
67318 extern bool file_ns_capable(const struct file *file, struct user_namespace *ns, int cap);
67319 +extern bool capable_nolog(int cap);
67320 +extern bool ns_capable_nolog(struct user_namespace *ns, int cap);
67321 +extern bool inode_capable_nolog(const struct inode *inode, int cap);
67322
67323 /* audit system wants to get cap info from files as well */
67324 extern int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data *cpu_caps);
67325
67326 +extern int is_privileged_binary(const struct dentry *dentry);
67327 +
67328 #endif /* !_LINUX_CAPABILITY_H */
67329 diff --git a/include/linux/cdrom.h b/include/linux/cdrom.h
67330 index 8609d57..86e4d79 100644
67331 --- a/include/linux/cdrom.h
67332 +++ b/include/linux/cdrom.h
67333 @@ -87,7 +87,6 @@ struct cdrom_device_ops {
67334
67335 /* driver specifications */
67336 const int capability; /* capability flags */
67337 - int n_minors; /* number of active minor devices */
67338 /* handle uniform packets for scsi type devices (scsi,atapi) */
67339 int (*generic_packet) (struct cdrom_device_info *,
67340 struct packet_command *);
67341 diff --git a/include/linux/cleancache.h b/include/linux/cleancache.h
67342 index 42e55de..1cd0e66 100644
67343 --- a/include/linux/cleancache.h
67344 +++ b/include/linux/cleancache.h
67345 @@ -31,7 +31,7 @@ struct cleancache_ops {
67346 void (*invalidate_page)(int, struct cleancache_filekey, pgoff_t);
67347 void (*invalidate_inode)(int, struct cleancache_filekey);
67348 void (*invalidate_fs)(int);
67349 -};
67350 +} __no_const;
67351
67352 extern struct cleancache_ops
67353 cleancache_register_ops(struct cleancache_ops *ops);
67354 diff --git a/include/linux/compat.h b/include/linux/compat.h
67355 index 377cd8c..2479845 100644
67356 --- a/include/linux/compat.h
67357 +++ b/include/linux/compat.h
67358 @@ -332,14 +332,14 @@ long compat_sys_msgsnd(int first, int second, int third, void __user *uptr);
67359 long compat_sys_msgrcv(int first, int second, int msgtyp, int third,
67360 int version, void __user *uptr);
67361 long compat_sys_shmat(int first, int second, compat_uptr_t third, int version,
67362 - void __user *uptr);
67363 + void __user *uptr) __intentional_overflow(0);
67364 #else
67365 long compat_sys_semctl(int semid, int semnum, int cmd, int arg);
67366 long compat_sys_msgsnd(int msqid, struct compat_msgbuf __user *msgp,
67367 compat_ssize_t msgsz, int msgflg);
67368 long compat_sys_msgrcv(int msqid, struct compat_msgbuf __user *msgp,
67369 compat_ssize_t msgsz, long msgtyp, int msgflg);
67370 -long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg);
67371 +long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg) __intentional_overflow(0);
67372 #endif
67373 long compat_sys_msgctl(int first, int second, void __user *uptr);
67374 long compat_sys_shmctl(int first, int second, void __user *uptr);
67375 @@ -442,7 +442,7 @@ extern int compat_ptrace_request(struct task_struct *child,
67376 extern long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
67377 compat_ulong_t addr, compat_ulong_t data);
67378 asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
67379 - compat_long_t addr, compat_long_t data);
67380 + compat_ulong_t addr, compat_ulong_t data);
67381
67382 /*
67383 * epoll (fs/eventpoll.c) compat bits follow ...
67384 diff --git a/include/linux/compiler-gcc4.h b/include/linux/compiler-gcc4.h
67385 index 68b162d..660f5f0 100644
67386 --- a/include/linux/compiler-gcc4.h
67387 +++ b/include/linux/compiler-gcc4.h
67388 @@ -39,9 +39,29 @@
67389 # define __compiletime_warning(message) __attribute__((warning(message)))
67390 # define __compiletime_error(message) __attribute__((error(message)))
67391 #endif /* __CHECKER__ */
67392 +
67393 +#define __alloc_size(...) __attribute((alloc_size(__VA_ARGS__)))
67394 +#define __bos(ptr, arg) __builtin_object_size((ptr), (arg))
67395 +#define __bos0(ptr) __bos((ptr), 0)
67396 +#define __bos1(ptr) __bos((ptr), 1)
67397 #endif /* GCC_VERSION >= 40300 */
67398
67399 #if GCC_VERSION >= 40500
67400 +
67401 +#ifdef CONSTIFY_PLUGIN
67402 +#define __no_const __attribute__((no_const))
67403 +#define __do_const __attribute__((do_const))
67404 +#endif
67405 +
67406 +#ifdef SIZE_OVERFLOW_PLUGIN
67407 +#define __size_overflow(...) __attribute__((size_overflow(__VA_ARGS__)))
67408 +#define __intentional_overflow(...) __attribute__((intentional_overflow(__VA_ARGS__)))
67409 +#endif
67410 +
67411 +#ifdef LATENT_ENTROPY_PLUGIN
67412 +#define __latent_entropy __attribute__((latent_entropy))
67413 +#endif
67414 +
67415 /*
67416 * Mark a position in code as unreachable. This can be used to
67417 * suppress control flow warnings after asm blocks that transfer
67418 diff --git a/include/linux/compiler.h b/include/linux/compiler.h
67419 index 10b8f23..5e0b083 100644
67420 --- a/include/linux/compiler.h
67421 +++ b/include/linux/compiler.h
67422 @@ -5,11 +5,14 @@
67423
67424 #ifdef __CHECKER__
67425 # define __user __attribute__((noderef, address_space(1)))
67426 +# define __force_user __force __user
67427 # define __kernel __attribute__((address_space(0)))
67428 +# define __force_kernel __force __kernel
67429 # define __safe __attribute__((safe))
67430 # define __force __attribute__((force))
67431 # define __nocast __attribute__((nocast))
67432 # define __iomem __attribute__((noderef, address_space(2)))
67433 +# define __force_iomem __force __iomem
67434 # define __must_hold(x) __attribute__((context(x,1,1)))
67435 # define __acquires(x) __attribute__((context(x,0,1)))
67436 # define __releases(x) __attribute__((context(x,1,0)))
67437 @@ -17,20 +20,37 @@
67438 # define __release(x) __context__(x,-1)
67439 # define __cond_lock(x,c) ((c) ? ({ __acquire(x); 1; }) : 0)
67440 # define __percpu __attribute__((noderef, address_space(3)))
67441 +# define __force_percpu __force __percpu
67442 #ifdef CONFIG_SPARSE_RCU_POINTER
67443 # define __rcu __attribute__((noderef, address_space(4)))
67444 +# define __force_rcu __force __rcu
67445 #else
67446 # define __rcu
67447 +# define __force_rcu
67448 #endif
67449 extern void __chk_user_ptr(const volatile void __user *);
67450 extern void __chk_io_ptr(const volatile void __iomem *);
67451 #else
67452 -# define __user
67453 -# define __kernel
67454 +# ifdef CHECKER_PLUGIN
67455 +//# define __user
67456 +//# define __force_user
67457 +//# define __kernel
67458 +//# define __force_kernel
67459 +# else
67460 +# ifdef STRUCTLEAK_PLUGIN
67461 +# define __user __attribute__((user))
67462 +# else
67463 +# define __user
67464 +# endif
67465 +# define __force_user
67466 +# define __kernel
67467 +# define __force_kernel
67468 +# endif
67469 # define __safe
67470 # define __force
67471 # define __nocast
67472 # define __iomem
67473 +# define __force_iomem
67474 # define __chk_user_ptr(x) (void)0
67475 # define __chk_io_ptr(x) (void)0
67476 # define __builtin_warning(x, y...) (1)
67477 @@ -41,7 +61,9 @@ extern void __chk_io_ptr(const volatile void __iomem *);
67478 # define __release(x) (void)0
67479 # define __cond_lock(x,c) (c)
67480 # define __percpu
67481 +# define __force_percpu
67482 # define __rcu
67483 +# define __force_rcu
67484 #endif
67485
67486 /* Indirect macros required for expanded argument pasting, eg. __LINE__. */
67487 @@ -275,6 +297,26 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
67488 # define __attribute_const__ /* unimplemented */
67489 #endif
67490
67491 +#ifndef __no_const
67492 +# define __no_const
67493 +#endif
67494 +
67495 +#ifndef __do_const
67496 +# define __do_const
67497 +#endif
67498 +
67499 +#ifndef __size_overflow
67500 +# define __size_overflow(...)
67501 +#endif
67502 +
67503 +#ifndef __intentional_overflow
67504 +# define __intentional_overflow(...)
67505 +#endif
67506 +
67507 +#ifndef __latent_entropy
67508 +# define __latent_entropy
67509 +#endif
67510 +
67511 /*
67512 * Tell gcc if a function is cold. The compiler will assume any path
67513 * directly leading to the call is unlikely.
67514 @@ -284,6 +326,22 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
67515 #define __cold
67516 #endif
67517
67518 +#ifndef __alloc_size
67519 +#define __alloc_size(...)
67520 +#endif
67521 +
67522 +#ifndef __bos
67523 +#define __bos(ptr, arg)
67524 +#endif
67525 +
67526 +#ifndef __bos0
67527 +#define __bos0(ptr)
67528 +#endif
67529 +
67530 +#ifndef __bos1
67531 +#define __bos1(ptr)
67532 +#endif
67533 +
67534 /* Simple shorthand for a section definition */
67535 #ifndef __section
67536 # define __section(S) __attribute__ ((__section__(#S)))
67537 @@ -349,6 +407,7 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
67538 * use is to mediate communication between process-level code and irq/NMI
67539 * handlers, all running on the same CPU.
67540 */
67541 -#define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x))
67542 +#define ACCESS_ONCE(x) (*(volatile const typeof(x) *)&(x))
67543 +#define ACCESS_ONCE_RW(x) (*(volatile typeof(x) *)&(x))
67544
67545 #endif /* __LINUX_COMPILER_H */
67546 diff --git a/include/linux/completion.h b/include/linux/completion.h
67547 index 33f0280..35c6568 100644
67548 --- a/include/linux/completion.h
67549 +++ b/include/linux/completion.h
67550 @@ -79,15 +79,15 @@ static inline void init_completion(struct completion *x)
67551 extern void wait_for_completion(struct completion *);
67552 extern void wait_for_completion_io(struct completion *);
67553 extern int wait_for_completion_interruptible(struct completion *x);
67554 -extern int wait_for_completion_killable(struct completion *x);
67555 +extern int wait_for_completion_killable(struct completion *x) __intentional_overflow(-1);
67556 extern unsigned long wait_for_completion_timeout(struct completion *x,
67557 unsigned long timeout);
67558 extern unsigned long wait_for_completion_io_timeout(struct completion *x,
67559 unsigned long timeout);
67560 extern long wait_for_completion_interruptible_timeout(
67561 - struct completion *x, unsigned long timeout);
67562 + struct completion *x, unsigned long timeout) __intentional_overflow(-1);
67563 extern long wait_for_completion_killable_timeout(
67564 - struct completion *x, unsigned long timeout);
67565 + struct completion *x, unsigned long timeout) __intentional_overflow(-1);
67566 extern bool try_wait_for_completion(struct completion *x);
67567 extern bool completion_done(struct completion *x);
67568
67569 diff --git a/include/linux/configfs.h b/include/linux/configfs.h
67570 index 34025df..d94bbbc 100644
67571 --- a/include/linux/configfs.h
67572 +++ b/include/linux/configfs.h
67573 @@ -125,7 +125,7 @@ struct configfs_attribute {
67574 const char *ca_name;
67575 struct module *ca_owner;
67576 umode_t ca_mode;
67577 -};
67578 +} __do_const;
67579
67580 /*
67581 * Users often need to create attribute structures for their configurable
67582 diff --git a/include/linux/cpu.h b/include/linux/cpu.h
67583 index ce7a074..01ab8ac 100644
67584 --- a/include/linux/cpu.h
67585 +++ b/include/linux/cpu.h
67586 @@ -115,7 +115,7 @@ enum {
67587 /* Need to know about CPUs going up/down? */
67588 #if defined(CONFIG_HOTPLUG_CPU) || !defined(MODULE)
67589 #define cpu_notifier(fn, pri) { \
67590 - static struct notifier_block fn##_nb __cpuinitdata = \
67591 + static struct notifier_block fn##_nb = \
67592 { .notifier_call = fn, .priority = pri }; \
67593 register_cpu_notifier(&fn##_nb); \
67594 }
67595 diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
67596 index a22944c..4e695fe 100644
67597 --- a/include/linux/cpufreq.h
67598 +++ b/include/linux/cpufreq.h
67599 @@ -252,7 +252,7 @@ struct cpufreq_driver {
67600 int (*suspend) (struct cpufreq_policy *policy);
67601 int (*resume) (struct cpufreq_policy *policy);
67602 struct freq_attr **attr;
67603 -};
67604 +} __do_const;
67605
67606 /* flags */
67607
67608 @@ -311,6 +311,7 @@ struct global_attr {
67609 ssize_t (*store)(struct kobject *a, struct attribute *b,
67610 const char *c, size_t count);
67611 };
67612 +typedef struct global_attr __no_const global_attr_no_const;
67613
67614 #define define_one_global_ro(_name) \
67615 static struct global_attr _name = \
67616 diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h
67617 index 480c14d..552896f 100644
67618 --- a/include/linux/cpuidle.h
67619 +++ b/include/linux/cpuidle.h
67620 @@ -52,7 +52,8 @@ struct cpuidle_state {
67621 int index);
67622
67623 int (*enter_dead) (struct cpuidle_device *dev, int index);
67624 -};
67625 +} __do_const;
67626 +typedef struct cpuidle_state __no_const cpuidle_state_no_const;
67627
67628 /* Idle State Flags */
67629 #define CPUIDLE_FLAG_TIME_VALID (0x01) /* is residency time measurable? */
67630 @@ -194,7 +195,7 @@ struct cpuidle_governor {
67631 void (*reflect) (struct cpuidle_device *dev, int index);
67632
67633 struct module *owner;
67634 -};
67635 +} __do_const;
67636
67637 #ifdef CONFIG_CPU_IDLE
67638
67639 diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
67640 index 0325602..5e9feff 100644
67641 --- a/include/linux/cpumask.h
67642 +++ b/include/linux/cpumask.h
67643 @@ -118,17 +118,17 @@ static inline unsigned int cpumask_first(const struct cpumask *srcp)
67644 }
67645
67646 /* Valid inputs for n are -1 and 0. */
67647 -static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
67648 +static inline unsigned int __intentional_overflow(-1) cpumask_next(int n, const struct cpumask *srcp)
67649 {
67650 return n+1;
67651 }
67652
67653 -static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
67654 +static inline unsigned int __intentional_overflow(-1) cpumask_next_zero(int n, const struct cpumask *srcp)
67655 {
67656 return n+1;
67657 }
67658
67659 -static inline unsigned int cpumask_next_and(int n,
67660 +static inline unsigned int __intentional_overflow(-1) cpumask_next_and(int n,
67661 const struct cpumask *srcp,
67662 const struct cpumask *andp)
67663 {
67664 @@ -167,7 +167,7 @@ static inline unsigned int cpumask_first(const struct cpumask *srcp)
67665 *
67666 * Returns >= nr_cpu_ids if no further cpus set.
67667 */
67668 -static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
67669 +static inline unsigned int __intentional_overflow(-1) cpumask_next(int n, const struct cpumask *srcp)
67670 {
67671 /* -1 is a legal arg here. */
67672 if (n != -1)
67673 @@ -182,7 +182,7 @@ static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
67674 *
67675 * Returns >= nr_cpu_ids if no further cpus unset.
67676 */
67677 -static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
67678 +static inline unsigned int __intentional_overflow(-1) cpumask_next_zero(int n, const struct cpumask *srcp)
67679 {
67680 /* -1 is a legal arg here. */
67681 if (n != -1)
67682 @@ -190,7 +190,7 @@ static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
67683 return find_next_zero_bit(cpumask_bits(srcp), nr_cpumask_bits, n+1);
67684 }
67685
67686 -int cpumask_next_and(int n, const struct cpumask *, const struct cpumask *);
67687 +int cpumask_next_and(int n, const struct cpumask *, const struct cpumask *) __intentional_overflow(-1);
67688 int cpumask_any_but(const struct cpumask *mask, unsigned int cpu);
67689
67690 /**
67691 diff --git a/include/linux/cred.h b/include/linux/cred.h
67692 index 04421e8..6bce4ef 100644
67693 --- a/include/linux/cred.h
67694 +++ b/include/linux/cred.h
67695 @@ -194,6 +194,9 @@ static inline void validate_creds_for_do_exit(struct task_struct *tsk)
67696 static inline void validate_process_creds(void)
67697 {
67698 }
67699 +static inline void validate_task_creds(struct task_struct *task)
67700 +{
67701 +}
67702 #endif
67703
67704 /**
67705 diff --git a/include/linux/crypto.h b/include/linux/crypto.h
67706 index b92eadf..b4ecdc1 100644
67707 --- a/include/linux/crypto.h
67708 +++ b/include/linux/crypto.h
67709 @@ -373,7 +373,7 @@ struct cipher_tfm {
67710 const u8 *key, unsigned int keylen);
67711 void (*cit_encrypt_one)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
67712 void (*cit_decrypt_one)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
67713 -};
67714 +} __no_const;
67715
67716 struct hash_tfm {
67717 int (*init)(struct hash_desc *desc);
67718 @@ -394,13 +394,13 @@ struct compress_tfm {
67719 int (*cot_decompress)(struct crypto_tfm *tfm,
67720 const u8 *src, unsigned int slen,
67721 u8 *dst, unsigned int *dlen);
67722 -};
67723 +} __no_const;
67724
67725 struct rng_tfm {
67726 int (*rng_gen_random)(struct crypto_rng *tfm, u8 *rdata,
67727 unsigned int dlen);
67728 int (*rng_reset)(struct crypto_rng *tfm, u8 *seed, unsigned int slen);
67729 -};
67730 +} __no_const;
67731
67732 #define crt_ablkcipher crt_u.ablkcipher
67733 #define crt_aead crt_u.aead
67734 diff --git a/include/linux/ctype.h b/include/linux/ctype.h
67735 index 8acfe31..6ffccd63 100644
67736 --- a/include/linux/ctype.h
67737 +++ b/include/linux/ctype.h
67738 @@ -56,7 +56,7 @@ static inline unsigned char __toupper(unsigned char c)
67739 * Fast implementation of tolower() for internal usage. Do not use in your
67740 * code.
67741 */
67742 -static inline char _tolower(const char c)
67743 +static inline unsigned char _tolower(const unsigned char c)
67744 {
67745 return c | 0x20;
67746 }
67747 diff --git a/include/linux/decompress/mm.h b/include/linux/decompress/mm.h
67748 index 7925bf0..d5143d2 100644
67749 --- a/include/linux/decompress/mm.h
67750 +++ b/include/linux/decompress/mm.h
67751 @@ -77,7 +77,7 @@ static void free(void *where)
67752 * warnings when not needed (indeed large_malloc / large_free are not
67753 * needed by inflate */
67754
67755 -#define malloc(a) kmalloc(a, GFP_KERNEL)
67756 +#define malloc(a) kmalloc((a), GFP_KERNEL)
67757 #define free(a) kfree(a)
67758
67759 #define large_malloc(a) vmalloc(a)
67760 diff --git a/include/linux/devfreq.h b/include/linux/devfreq.h
67761 index fe8c447..bdc1f33 100644
67762 --- a/include/linux/devfreq.h
67763 +++ b/include/linux/devfreq.h
67764 @@ -114,7 +114,7 @@ struct devfreq_governor {
67765 int (*get_target_freq)(struct devfreq *this, unsigned long *freq);
67766 int (*event_handler)(struct devfreq *devfreq,
67767 unsigned int event, void *data);
67768 -};
67769 +} __do_const;
67770
67771 /**
67772 * struct devfreq - Device devfreq structure
67773 diff --git a/include/linux/device.h b/include/linux/device.h
67774 index 9d6464e..8a5cc92 100644
67775 --- a/include/linux/device.h
67776 +++ b/include/linux/device.h
67777 @@ -295,7 +295,7 @@ struct subsys_interface {
67778 struct list_head node;
67779 int (*add_dev)(struct device *dev, struct subsys_interface *sif);
67780 int (*remove_dev)(struct device *dev, struct subsys_interface *sif);
67781 -};
67782 +} __do_const;
67783
67784 int subsys_interface_register(struct subsys_interface *sif);
67785 void subsys_interface_unregister(struct subsys_interface *sif);
67786 @@ -475,7 +475,7 @@ struct device_type {
67787 void (*release)(struct device *dev);
67788
67789 const struct dev_pm_ops *pm;
67790 -};
67791 +} __do_const;
67792
67793 /* interface for exporting device attributes */
67794 struct device_attribute {
67795 @@ -485,11 +485,12 @@ struct device_attribute {
67796 ssize_t (*store)(struct device *dev, struct device_attribute *attr,
67797 const char *buf, size_t count);
67798 };
67799 +typedef struct device_attribute __no_const device_attribute_no_const;
67800
67801 struct dev_ext_attribute {
67802 struct device_attribute attr;
67803 void *var;
67804 -};
67805 +} __do_const;
67806
67807 ssize_t device_show_ulong(struct device *dev, struct device_attribute *attr,
67808 char *buf);
67809 diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
67810 index 94af418..b1ca7a2 100644
67811 --- a/include/linux/dma-mapping.h
67812 +++ b/include/linux/dma-mapping.h
67813 @@ -54,7 +54,7 @@ struct dma_map_ops {
67814 u64 (*get_required_mask)(struct device *dev);
67815 #endif
67816 int is_phys;
67817 -};
67818 +} __do_const;
67819
67820 #define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1))
67821
67822 diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
67823 index 91ac8da..a841318 100644
67824 --- a/include/linux/dmaengine.h
67825 +++ b/include/linux/dmaengine.h
67826 @@ -1034,9 +1034,9 @@ struct dma_pinned_list {
67827 struct dma_pinned_list *dma_pin_iovec_pages(struct iovec *iov, size_t len);
67828 void dma_unpin_iovec_pages(struct dma_pinned_list* pinned_list);
67829
67830 -dma_cookie_t dma_memcpy_to_iovec(struct dma_chan *chan, struct iovec *iov,
67831 +dma_cookie_t __intentional_overflow(0) dma_memcpy_to_iovec(struct dma_chan *chan, struct iovec *iov,
67832 struct dma_pinned_list *pinned_list, unsigned char *kdata, size_t len);
67833 -dma_cookie_t dma_memcpy_pg_to_iovec(struct dma_chan *chan, struct iovec *iov,
67834 +dma_cookie_t __intentional_overflow(0) dma_memcpy_pg_to_iovec(struct dma_chan *chan, struct iovec *iov,
67835 struct dma_pinned_list *pinned_list, struct page *page,
67836 unsigned int offset, size_t len);
67837
67838 diff --git a/include/linux/efi.h b/include/linux/efi.h
67839 index 3d7df3d..301f024 100644
67840 --- a/include/linux/efi.h
67841 +++ b/include/linux/efi.h
67842 @@ -740,6 +740,7 @@ struct efivar_operations {
67843 efi_set_variable_t *set_variable;
67844 efi_query_variable_store_t *query_variable_store;
67845 };
67846 +typedef struct efivar_operations __no_const efivar_operations_no_const;
67847
67848 struct efivars {
67849 /*
67850 diff --git a/include/linux/elf.h b/include/linux/elf.h
67851 index 40a3c0e..4c45a38 100644
67852 --- a/include/linux/elf.h
67853 +++ b/include/linux/elf.h
67854 @@ -24,6 +24,7 @@ extern Elf32_Dyn _DYNAMIC [];
67855 #define elf_note elf32_note
67856 #define elf_addr_t Elf32_Off
67857 #define Elf_Half Elf32_Half
67858 +#define elf_dyn Elf32_Dyn
67859
67860 #else
67861
67862 @@ -34,6 +35,7 @@ extern Elf64_Dyn _DYNAMIC [];
67863 #define elf_note elf64_note
67864 #define elf_addr_t Elf64_Off
67865 #define Elf_Half Elf64_Half
67866 +#define elf_dyn Elf64_Dyn
67867
67868 #endif
67869
67870 diff --git a/include/linux/err.h b/include/linux/err.h
67871 index f2edce2..cc2082c 100644
67872 --- a/include/linux/err.h
67873 +++ b/include/linux/err.h
67874 @@ -19,12 +19,12 @@
67875
67876 #define IS_ERR_VALUE(x) unlikely((x) >= (unsigned long)-MAX_ERRNO)
67877
67878 -static inline void * __must_check ERR_PTR(long error)
67879 +static inline void * __must_check __intentional_overflow(-1) ERR_PTR(long error)
67880 {
67881 return (void *) error;
67882 }
67883
67884 -static inline long __must_check PTR_ERR(const void *ptr)
67885 +static inline long __must_check __intentional_overflow(-1) PTR_ERR(const void *ptr)
67886 {
67887 return (long) ptr;
67888 }
67889 diff --git a/include/linux/extcon.h b/include/linux/extcon.h
67890 index fcb51c8..bdafcf6 100644
67891 --- a/include/linux/extcon.h
67892 +++ b/include/linux/extcon.h
67893 @@ -134,7 +134,7 @@ struct extcon_dev {
67894 /* /sys/class/extcon/.../mutually_exclusive/... */
67895 struct attribute_group attr_g_muex;
67896 struct attribute **attrs_muex;
67897 - struct device_attribute *d_attrs_muex;
67898 + device_attribute_no_const *d_attrs_muex;
67899 };
67900
67901 /**
67902 diff --git a/include/linux/fb.h b/include/linux/fb.h
67903 index 58b9860..58e5516 100644
67904 --- a/include/linux/fb.h
67905 +++ b/include/linux/fb.h
67906 @@ -304,7 +304,7 @@ struct fb_ops {
67907 /* called at KDB enter and leave time to prepare the console */
67908 int (*fb_debug_enter)(struct fb_info *info);
67909 int (*fb_debug_leave)(struct fb_info *info);
67910 -};
67911 +} __do_const;
67912
67913 #ifdef CONFIG_FB_TILEBLITTING
67914 #define FB_TILE_CURSOR_NONE 0
67915 diff --git a/include/linux/filter.h b/include/linux/filter.h
67916 index c45eabc..baa0be5 100644
67917 --- a/include/linux/filter.h
67918 +++ b/include/linux/filter.h
67919 @@ -20,6 +20,7 @@ struct compat_sock_fprog {
67920
67921 struct sk_buff;
67922 struct sock;
67923 +struct bpf_jit_work;
67924
67925 struct sk_filter
67926 {
67927 @@ -27,6 +28,9 @@ struct sk_filter
67928 unsigned int len; /* Number of filter blocks */
67929 unsigned int (*bpf_func)(const struct sk_buff *skb,
67930 const struct sock_filter *filter);
67931 +#ifdef CONFIG_BPF_JIT
67932 + struct bpf_jit_work *work;
67933 +#endif
67934 struct rcu_head rcu;
67935 struct sock_filter insns[0];
67936 };
67937 diff --git a/include/linux/frontswap.h b/include/linux/frontswap.h
67938 index 3044254..9767f41 100644
67939 --- a/include/linux/frontswap.h
67940 +++ b/include/linux/frontswap.h
67941 @@ -11,7 +11,7 @@ struct frontswap_ops {
67942 int (*load)(unsigned, pgoff_t, struct page *);
67943 void (*invalidate_page)(unsigned, pgoff_t);
67944 void (*invalidate_area)(unsigned);
67945 -};
67946 +} __no_const;
67947
67948 extern bool frontswap_enabled;
67949 extern struct frontswap_ops
67950 diff --git a/include/linux/fs.h b/include/linux/fs.h
67951 index 2c28271..8d3d74c 100644
67952 --- a/include/linux/fs.h
67953 +++ b/include/linux/fs.h
67954 @@ -1541,7 +1541,8 @@ struct file_operations {
67955 long (*fallocate)(struct file *file, int mode, loff_t offset,
67956 loff_t len);
67957 int (*show_fdinfo)(struct seq_file *m, struct file *f);
67958 -};
67959 +} __do_const;
67960 +typedef struct file_operations __no_const file_operations_no_const;
67961
67962 struct inode_operations {
67963 struct dentry * (*lookup) (struct inode *,struct dentry *, unsigned int);
67964 @@ -2672,4 +2673,14 @@ static inline void inode_has_no_xattr(struct inode *inode)
67965 inode->i_flags |= S_NOSEC;
67966 }
67967
67968 +static inline bool is_sidechannel_device(const struct inode *inode)
67969 +{
67970 +#ifdef CONFIG_GRKERNSEC_DEVICE_SIDECHANNEL
67971 + umode_t mode = inode->i_mode;
67972 + return ((S_ISCHR(mode) || S_ISBLK(mode)) && (mode & (S_IROTH | S_IWOTH)));
67973 +#else
67974 + return false;
67975 +#endif
67976 +}
67977 +
67978 #endif /* _LINUX_FS_H */
67979 diff --git a/include/linux/fs_struct.h b/include/linux/fs_struct.h
67980 index 2b93a9a..855d94a 100644
67981 --- a/include/linux/fs_struct.h
67982 +++ b/include/linux/fs_struct.h
67983 @@ -6,7 +6,7 @@
67984 #include <linux/seqlock.h>
67985
67986 struct fs_struct {
67987 - int users;
67988 + atomic_t users;
67989 spinlock_t lock;
67990 seqcount_t seq;
67991 int umask;
67992 diff --git a/include/linux/fscache-cache.h b/include/linux/fscache-cache.h
67993 index 5dfa0aa..6acf322 100644
67994 --- a/include/linux/fscache-cache.h
67995 +++ b/include/linux/fscache-cache.h
67996 @@ -112,7 +112,7 @@ struct fscache_operation {
67997 fscache_operation_release_t release;
67998 };
67999
68000 -extern atomic_t fscache_op_debug_id;
68001 +extern atomic_unchecked_t fscache_op_debug_id;
68002 extern void fscache_op_work_func(struct work_struct *work);
68003
68004 extern void fscache_enqueue_operation(struct fscache_operation *);
68005 @@ -134,7 +134,7 @@ static inline void fscache_operation_init(struct fscache_operation *op,
68006 INIT_WORK(&op->work, fscache_op_work_func);
68007 atomic_set(&op->usage, 1);
68008 op->state = FSCACHE_OP_ST_INITIALISED;
68009 - op->debug_id = atomic_inc_return(&fscache_op_debug_id);
68010 + op->debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
68011 op->processor = processor;
68012 op->release = release;
68013 INIT_LIST_HEAD(&op->pend_link);
68014 diff --git a/include/linux/fscache.h b/include/linux/fscache.h
68015 index 7a08623..4c07b0f 100644
68016 --- a/include/linux/fscache.h
68017 +++ b/include/linux/fscache.h
68018 @@ -152,7 +152,7 @@ struct fscache_cookie_def {
68019 * - this is mandatory for any object that may have data
68020 */
68021 void (*now_uncached)(void *cookie_netfs_data);
68022 -};
68023 +} __do_const;
68024
68025 /*
68026 * fscache cached network filesystem type
68027 diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h
68028 index a78680a..87bd73e 100644
68029 --- a/include/linux/fsnotify.h
68030 +++ b/include/linux/fsnotify.h
68031 @@ -195,6 +195,9 @@ static inline void fsnotify_access(struct file *file)
68032 struct inode *inode = path->dentry->d_inode;
68033 __u32 mask = FS_ACCESS;
68034
68035 + if (is_sidechannel_device(inode))
68036 + return;
68037 +
68038 if (S_ISDIR(inode->i_mode))
68039 mask |= FS_ISDIR;
68040
68041 @@ -213,6 +216,9 @@ static inline void fsnotify_modify(struct file *file)
68042 struct inode *inode = path->dentry->d_inode;
68043 __u32 mask = FS_MODIFY;
68044
68045 + if (is_sidechannel_device(inode))
68046 + return;
68047 +
68048 if (S_ISDIR(inode->i_mode))
68049 mask |= FS_ISDIR;
68050
68051 @@ -315,7 +321,7 @@ static inline void fsnotify_change(struct dentry *dentry, unsigned int ia_valid)
68052 */
68053 static inline const unsigned char *fsnotify_oldname_init(const unsigned char *name)
68054 {
68055 - return kstrdup(name, GFP_KERNEL);
68056 + return (const unsigned char *)kstrdup((const char *)name, GFP_KERNEL);
68057 }
68058
68059 /*
68060 diff --git a/include/linux/ftrace_event.h b/include/linux/ftrace_event.h
68061 index 13a54d0..c6ce2a7 100644
68062 --- a/include/linux/ftrace_event.h
68063 +++ b/include/linux/ftrace_event.h
68064 @@ -274,7 +274,7 @@ extern int trace_define_field(struct ftrace_event_call *call, const char *type,
68065 extern int trace_add_event_call(struct ftrace_event_call *call);
68066 extern void trace_remove_event_call(struct ftrace_event_call *call);
68067
68068 -#define is_signed_type(type) (((type)(-1)) < (type)0)
68069 +#define is_signed_type(type) (((type)(-1)) < (type)1)
68070
68071 int trace_set_clr_event(const char *system, const char *event, int set);
68072
68073 diff --git a/include/linux/genhd.h b/include/linux/genhd.h
68074 index 9f3c275..911b591 100644
68075 --- a/include/linux/genhd.h
68076 +++ b/include/linux/genhd.h
68077 @@ -194,7 +194,7 @@ struct gendisk {
68078 struct kobject *slave_dir;
68079
68080 struct timer_rand_state *random;
68081 - atomic_t sync_io; /* RAID */
68082 + atomic_unchecked_t sync_io; /* RAID */
68083 struct disk_events *ev;
68084 #ifdef CONFIG_BLK_DEV_INTEGRITY
68085 struct blk_integrity *integrity;
68086 diff --git a/include/linux/genl_magic_func.h b/include/linux/genl_magic_func.h
68087 index 023bc34..b02b46a 100644
68088 --- a/include/linux/genl_magic_func.h
68089 +++ b/include/linux/genl_magic_func.h
68090 @@ -246,7 +246,7 @@ const char *CONCAT_(GENL_MAGIC_FAMILY, _genl_cmd_to_str)(__u8 cmd)
68091 },
68092
68093 #define ZZZ_genl_ops CONCAT_(GENL_MAGIC_FAMILY, _genl_ops)
68094 -static struct genl_ops ZZZ_genl_ops[] __read_mostly = {
68095 +static struct genl_ops ZZZ_genl_ops[] = {
68096 #include GENL_MAGIC_INCLUDE_FILE
68097 };
68098
68099 diff --git a/include/linux/gfp.h b/include/linux/gfp.h
68100 index 0f615eb..5c3832f 100644
68101 --- a/include/linux/gfp.h
68102 +++ b/include/linux/gfp.h
68103 @@ -35,6 +35,13 @@ struct vm_area_struct;
68104 #define ___GFP_NO_KSWAPD 0x400000u
68105 #define ___GFP_OTHER_NODE 0x800000u
68106 #define ___GFP_WRITE 0x1000000u
68107 +
68108 +#ifdef CONFIG_PAX_USERCOPY_SLABS
68109 +#define ___GFP_USERCOPY 0x2000000u
68110 +#else
68111 +#define ___GFP_USERCOPY 0
68112 +#endif
68113 +
68114 /* If the above are modified, __GFP_BITS_SHIFT may need updating */
68115
68116 /*
68117 @@ -92,6 +99,7 @@ struct vm_area_struct;
68118 #define __GFP_OTHER_NODE ((__force gfp_t)___GFP_OTHER_NODE) /* On behalf of other node */
68119 #define __GFP_KMEMCG ((__force gfp_t)___GFP_KMEMCG) /* Allocation comes from a memcg-accounted resource */
68120 #define __GFP_WRITE ((__force gfp_t)___GFP_WRITE) /* Allocator intends to dirty page */
68121 +#define __GFP_USERCOPY ((__force gfp_t)___GFP_USERCOPY)/* Allocator intends to copy page to/from userland */
68122
68123 /*
68124 * This may seem redundant, but it's a way of annotating false positives vs.
68125 @@ -99,7 +107,7 @@ struct vm_area_struct;
68126 */
68127 #define __GFP_NOTRACK_FALSE_POSITIVE (__GFP_NOTRACK)
68128
68129 -#define __GFP_BITS_SHIFT 25 /* Room for N __GFP_FOO bits */
68130 +#define __GFP_BITS_SHIFT 26 /* Room for N __GFP_FOO bits */
68131 #define __GFP_BITS_MASK ((__force gfp_t)((1 << __GFP_BITS_SHIFT) - 1))
68132
68133 /* This equals 0, but use constants in case they ever change */
68134 @@ -153,6 +161,8 @@ struct vm_area_struct;
68135 /* 4GB DMA on some platforms */
68136 #define GFP_DMA32 __GFP_DMA32
68137
68138 +#define GFP_USERCOPY __GFP_USERCOPY
68139 +
68140 /* Convert GFP flags to their corresponding migrate type */
68141 static inline int allocflags_to_migratetype(gfp_t gfp_flags)
68142 {
68143 diff --git a/include/linux/gracl.h b/include/linux/gracl.h
68144 new file mode 100644
68145 index 0000000..ebe6d72
68146 --- /dev/null
68147 +++ b/include/linux/gracl.h
68148 @@ -0,0 +1,319 @@
68149 +#ifndef GR_ACL_H
68150 +#define GR_ACL_H
68151 +
68152 +#include <linux/grdefs.h>
68153 +#include <linux/resource.h>
68154 +#include <linux/capability.h>
68155 +#include <linux/dcache.h>
68156 +#include <asm/resource.h>
68157 +
68158 +/* Major status information */
68159 +
68160 +#define GR_VERSION "grsecurity 2.9.1"
68161 +#define GRSECURITY_VERSION 0x2901
68162 +
68163 +enum {
68164 + GR_SHUTDOWN = 0,
68165 + GR_ENABLE = 1,
68166 + GR_SPROLE = 2,
68167 + GR_RELOAD = 3,
68168 + GR_SEGVMOD = 4,
68169 + GR_STATUS = 5,
68170 + GR_UNSPROLE = 6,
68171 + GR_PASSSET = 7,
68172 + GR_SPROLEPAM = 8,
68173 +};
68174 +
68175 +/* Password setup definitions
68176 + * kernel/grhash.c */
68177 +enum {
68178 + GR_PW_LEN = 128,
68179 + GR_SALT_LEN = 16,
68180 + GR_SHA_LEN = 32,
68181 +};
68182 +
68183 +enum {
68184 + GR_SPROLE_LEN = 64,
68185 +};
68186 +
68187 +enum {
68188 + GR_NO_GLOB = 0,
68189 + GR_REG_GLOB,
68190 + GR_CREATE_GLOB
68191 +};
68192 +
68193 +#define GR_NLIMITS 32
68194 +
68195 +/* Begin Data Structures */
68196 +
68197 +struct sprole_pw {
68198 + unsigned char *rolename;
68199 + unsigned char salt[GR_SALT_LEN];
68200 + unsigned char sum[GR_SHA_LEN]; /* 256-bit SHA hash of the password */
68201 +};
68202 +
68203 +struct name_entry {
68204 + __u32 key;
68205 + ino_t inode;
68206 + dev_t device;
68207 + char *name;
68208 + __u16 len;
68209 + __u8 deleted;
68210 + struct name_entry *prev;
68211 + struct name_entry *next;
68212 +};
68213 +
68214 +struct inodev_entry {
68215 + struct name_entry *nentry;
68216 + struct inodev_entry *prev;
68217 + struct inodev_entry *next;
68218 +};
68219 +
68220 +struct acl_role_db {
68221 + struct acl_role_label **r_hash;
68222 + __u32 r_size;
68223 +};
68224 +
68225 +struct inodev_db {
68226 + struct inodev_entry **i_hash;
68227 + __u32 i_size;
68228 +};
68229 +
68230 +struct name_db {
68231 + struct name_entry **n_hash;
68232 + __u32 n_size;
68233 +};
68234 +
68235 +struct crash_uid {
68236 + uid_t uid;
68237 + unsigned long expires;
68238 +};
68239 +
68240 +struct gr_hash_struct {
68241 + void **table;
68242 + void **nametable;
68243 + void *first;
68244 + __u32 table_size;
68245 + __u32 used_size;
68246 + int type;
68247 +};
68248 +
68249 +/* Userspace Grsecurity ACL data structures */
68250 +
68251 +struct acl_subject_label {
68252 + char *filename;
68253 + ino_t inode;
68254 + dev_t device;
68255 + __u32 mode;
68256 + kernel_cap_t cap_mask;
68257 + kernel_cap_t cap_lower;
68258 + kernel_cap_t cap_invert_audit;
68259 +
68260 + struct rlimit res[GR_NLIMITS];
68261 + __u32 resmask;
68262 +
68263 + __u8 user_trans_type;
68264 + __u8 group_trans_type;
68265 + uid_t *user_transitions;
68266 + gid_t *group_transitions;
68267 + __u16 user_trans_num;
68268 + __u16 group_trans_num;
68269 +
68270 + __u32 sock_families[2];
68271 + __u32 ip_proto[8];
68272 + __u32 ip_type;
68273 + struct acl_ip_label **ips;
68274 + __u32 ip_num;
68275 + __u32 inaddr_any_override;
68276 +
68277 + __u32 crashes;
68278 + unsigned long expires;
68279 +
68280 + struct acl_subject_label *parent_subject;
68281 + struct gr_hash_struct *hash;
68282 + struct acl_subject_label *prev;
68283 + struct acl_subject_label *next;
68284 +
68285 + struct acl_object_label **obj_hash;
68286 + __u32 obj_hash_size;
68287 + __u16 pax_flags;
68288 +};
68289 +
68290 +struct role_allowed_ip {
68291 + __u32 addr;
68292 + __u32 netmask;
68293 +
68294 + struct role_allowed_ip *prev;
68295 + struct role_allowed_ip *next;
68296 +};
68297 +
68298 +struct role_transition {
68299 + char *rolename;
68300 +
68301 + struct role_transition *prev;
68302 + struct role_transition *next;
68303 +};
68304 +
68305 +struct acl_role_label {
68306 + char *rolename;
68307 + uid_t uidgid;
68308 + __u16 roletype;
68309 +
68310 + __u16 auth_attempts;
68311 + unsigned long expires;
68312 +
68313 + struct acl_subject_label *root_label;
68314 + struct gr_hash_struct *hash;
68315 +
68316 + struct acl_role_label *prev;
68317 + struct acl_role_label *next;
68318 +
68319 + struct role_transition *transitions;
68320 + struct role_allowed_ip *allowed_ips;
68321 + uid_t *domain_children;
68322 + __u16 domain_child_num;
68323 +
68324 + umode_t umask;
68325 +
68326 + struct acl_subject_label **subj_hash;
68327 + __u32 subj_hash_size;
68328 +};
68329 +
68330 +struct user_acl_role_db {
68331 + struct acl_role_label **r_table;
68332 + __u32 num_pointers; /* Number of allocations to track */
68333 + __u32 num_roles; /* Number of roles */
68334 + __u32 num_domain_children; /* Number of domain children */
68335 + __u32 num_subjects; /* Number of subjects */
68336 + __u32 num_objects; /* Number of objects */
68337 +};
68338 +
68339 +struct acl_object_label {
68340 + char *filename;
68341 + ino_t inode;
68342 + dev_t device;
68343 + __u32 mode;
68344 +
68345 + struct acl_subject_label *nested;
68346 + struct acl_object_label *globbed;
68347 +
68348 + /* next two structures not used */
68349 +
68350 + struct acl_object_label *prev;
68351 + struct acl_object_label *next;
68352 +};
68353 +
68354 +struct acl_ip_label {
68355 + char *iface;
68356 + __u32 addr;
68357 + __u32 netmask;
68358 + __u16 low, high;
68359 + __u8 mode;
68360 + __u32 type;
68361 + __u32 proto[8];
68362 +
68363 + /* next two structures not used */
68364 +
68365 + struct acl_ip_label *prev;
68366 + struct acl_ip_label *next;
68367 +};
68368 +
68369 +struct gr_arg {
68370 + struct user_acl_role_db role_db;
68371 + unsigned char pw[GR_PW_LEN];
68372 + unsigned char salt[GR_SALT_LEN];
68373 + unsigned char sum[GR_SHA_LEN];
68374 + unsigned char sp_role[GR_SPROLE_LEN];
68375 + struct sprole_pw *sprole_pws;
68376 + dev_t segv_device;
68377 + ino_t segv_inode;
68378 + uid_t segv_uid;
68379 + __u16 num_sprole_pws;
68380 + __u16 mode;
68381 +};
68382 +
68383 +struct gr_arg_wrapper {
68384 + struct gr_arg *arg;
68385 + __u32 version;
68386 + __u32 size;
68387 +};
68388 +
68389 +struct subject_map {
68390 + struct acl_subject_label *user;
68391 + struct acl_subject_label *kernel;
68392 + struct subject_map *prev;
68393 + struct subject_map *next;
68394 +};
68395 +
68396 +struct acl_subj_map_db {
68397 + struct subject_map **s_hash;
68398 + __u32 s_size;
68399 +};
68400 +
68401 +/* End Data Structures Section */
68402 +
68403 +/* Hash functions generated by empirical testing by Brad Spengler
68404 + Makes good use of the low bits of the inode. Generally 0-1 times
68405 + in loop for successful match. 0-3 for unsuccessful match.
68406 + Shift/add algorithm with modulus of table size and an XOR*/
68407 +
68408 +static __inline__ unsigned int
68409 +gr_rhash(const uid_t uid, const __u16 type, const unsigned int sz)
68410 +{
68411 + return ((((uid + type) << (16 + type)) ^ uid) % sz);
68412 +}
68413 +
68414 + static __inline__ unsigned int
68415 +gr_shash(const struct acl_subject_label *userp, const unsigned int sz)
68416 +{
68417 + return ((const unsigned long)userp % sz);
68418 +}
68419 +
68420 +static __inline__ unsigned int
68421 +gr_fhash(const ino_t ino, const dev_t dev, const unsigned int sz)
68422 +{
68423 + return (((ino + dev) ^ ((ino << 13) + (ino << 23) + (dev << 9))) % sz);
68424 +}
68425 +
68426 +static __inline__ unsigned int
68427 +gr_nhash(const char *name, const __u16 len, const unsigned int sz)
68428 +{
68429 + return full_name_hash((const unsigned char *)name, len) % sz;
68430 +}
68431 +
68432 +#define FOR_EACH_ROLE_START(role) \
68433 + role = role_list; \
68434 + while (role) {
68435 +
68436 +#define FOR_EACH_ROLE_END(role) \
68437 + role = role->prev; \
68438 + }
68439 +
68440 +#define FOR_EACH_SUBJECT_START(role,subj,iter) \
68441 + subj = NULL; \
68442 + iter = 0; \
68443 + while (iter < role->subj_hash_size) { \
68444 + if (subj == NULL) \
68445 + subj = role->subj_hash[iter]; \
68446 + if (subj == NULL) { \
68447 + iter++; \
68448 + continue; \
68449 + }
68450 +
68451 +#define FOR_EACH_SUBJECT_END(subj,iter) \
68452 + subj = subj->next; \
68453 + if (subj == NULL) \
68454 + iter++; \
68455 + }
68456 +
68457 +
68458 +#define FOR_EACH_NESTED_SUBJECT_START(role,subj) \
68459 + subj = role->hash->first; \
68460 + while (subj != NULL) {
68461 +
68462 +#define FOR_EACH_NESTED_SUBJECT_END(subj) \
68463 + subj = subj->next; \
68464 + }
68465 +
68466 +#endif
68467 +
68468 diff --git a/include/linux/gralloc.h b/include/linux/gralloc.h
68469 new file mode 100644
68470 index 0000000..323ecf2
68471 --- /dev/null
68472 +++ b/include/linux/gralloc.h
68473 @@ -0,0 +1,9 @@
68474 +#ifndef __GRALLOC_H
68475 +#define __GRALLOC_H
68476 +
68477 +void acl_free_all(void);
68478 +int acl_alloc_stack_init(unsigned long size);
68479 +void *acl_alloc(unsigned long len);
68480 +void *acl_alloc_num(unsigned long num, unsigned long len);
68481 +
68482 +#endif
68483 diff --git a/include/linux/grdefs.h b/include/linux/grdefs.h
68484 new file mode 100644
68485 index 0000000..be66033
68486 --- /dev/null
68487 +++ b/include/linux/grdefs.h
68488 @@ -0,0 +1,140 @@
68489 +#ifndef GRDEFS_H
68490 +#define GRDEFS_H
68491 +
68492 +/* Begin grsecurity status declarations */
68493 +
68494 +enum {
68495 + GR_READY = 0x01,
68496 + GR_STATUS_INIT = 0x00 // disabled state
68497 +};
68498 +
68499 +/* Begin ACL declarations */
68500 +
68501 +/* Role flags */
68502 +
68503 +enum {
68504 + GR_ROLE_USER = 0x0001,
68505 + GR_ROLE_GROUP = 0x0002,
68506 + GR_ROLE_DEFAULT = 0x0004,
68507 + GR_ROLE_SPECIAL = 0x0008,
68508 + GR_ROLE_AUTH = 0x0010,
68509 + GR_ROLE_NOPW = 0x0020,
68510 + GR_ROLE_GOD = 0x0040,
68511 + GR_ROLE_LEARN = 0x0080,
68512 + GR_ROLE_TPE = 0x0100,
68513 + GR_ROLE_DOMAIN = 0x0200,
68514 + GR_ROLE_PAM = 0x0400,
68515 + GR_ROLE_PERSIST = 0x0800
68516 +};
68517 +
68518 +/* ACL Subject and Object mode flags */
68519 +enum {
68520 + GR_DELETED = 0x80000000
68521 +};
68522 +
68523 +/* ACL Object-only mode flags */
68524 +enum {
68525 + GR_READ = 0x00000001,
68526 + GR_APPEND = 0x00000002,
68527 + GR_WRITE = 0x00000004,
68528 + GR_EXEC = 0x00000008,
68529 + GR_FIND = 0x00000010,
68530 + GR_INHERIT = 0x00000020,
68531 + GR_SETID = 0x00000040,
68532 + GR_CREATE = 0x00000080,
68533 + GR_DELETE = 0x00000100,
68534 + GR_LINK = 0x00000200,
68535 + GR_AUDIT_READ = 0x00000400,
68536 + GR_AUDIT_APPEND = 0x00000800,
68537 + GR_AUDIT_WRITE = 0x00001000,
68538 + GR_AUDIT_EXEC = 0x00002000,
68539 + GR_AUDIT_FIND = 0x00004000,
68540 + GR_AUDIT_INHERIT= 0x00008000,
68541 + GR_AUDIT_SETID = 0x00010000,
68542 + GR_AUDIT_CREATE = 0x00020000,
68543 + GR_AUDIT_DELETE = 0x00040000,
68544 + GR_AUDIT_LINK = 0x00080000,
68545 + GR_PTRACERD = 0x00100000,
68546 + GR_NOPTRACE = 0x00200000,
68547 + GR_SUPPRESS = 0x00400000,
68548 + GR_NOLEARN = 0x00800000,
68549 + GR_INIT_TRANSFER= 0x01000000
68550 +};
68551 +
68552 +#define GR_AUDITS (GR_AUDIT_READ | GR_AUDIT_WRITE | GR_AUDIT_APPEND | GR_AUDIT_EXEC | \
68553 + GR_AUDIT_FIND | GR_AUDIT_INHERIT | GR_AUDIT_SETID | \
68554 + GR_AUDIT_CREATE | GR_AUDIT_DELETE | GR_AUDIT_LINK)
68555 +
68556 +/* ACL subject-only mode flags */
68557 +enum {
68558 + GR_KILL = 0x00000001,
68559 + GR_VIEW = 0x00000002,
68560 + GR_PROTECTED = 0x00000004,
68561 + GR_LEARN = 0x00000008,
68562 + GR_OVERRIDE = 0x00000010,
68563 + /* just a placeholder, this mode is only used in userspace */
68564 + GR_DUMMY = 0x00000020,
68565 + GR_PROTSHM = 0x00000040,
68566 + GR_KILLPROC = 0x00000080,
68567 + GR_KILLIPPROC = 0x00000100,
68568 + /* just a placeholder, this mode is only used in userspace */
68569 + GR_NOTROJAN = 0x00000200,
68570 + GR_PROTPROCFD = 0x00000400,
68571 + GR_PROCACCT = 0x00000800,
68572 + GR_RELAXPTRACE = 0x00001000,
68573 + //GR_NESTED = 0x00002000,
68574 + GR_INHERITLEARN = 0x00004000,
68575 + GR_PROCFIND = 0x00008000,
68576 + GR_POVERRIDE = 0x00010000,
68577 + GR_KERNELAUTH = 0x00020000,
68578 + GR_ATSECURE = 0x00040000,
68579 + GR_SHMEXEC = 0x00080000
68580 +};
68581 +
68582 +enum {
68583 + GR_PAX_ENABLE_SEGMEXEC = 0x0001,
68584 + GR_PAX_ENABLE_PAGEEXEC = 0x0002,
68585 + GR_PAX_ENABLE_MPROTECT = 0x0004,
68586 + GR_PAX_ENABLE_RANDMMAP = 0x0008,
68587 + GR_PAX_ENABLE_EMUTRAMP = 0x0010,
68588 + GR_PAX_DISABLE_SEGMEXEC = 0x0100,
68589 + GR_PAX_DISABLE_PAGEEXEC = 0x0200,
68590 + GR_PAX_DISABLE_MPROTECT = 0x0400,
68591 + GR_PAX_DISABLE_RANDMMAP = 0x0800,
68592 + GR_PAX_DISABLE_EMUTRAMP = 0x1000,
68593 +};
68594 +
68595 +enum {
68596 + GR_ID_USER = 0x01,
68597 + GR_ID_GROUP = 0x02,
68598 +};
68599 +
68600 +enum {
68601 + GR_ID_ALLOW = 0x01,
68602 + GR_ID_DENY = 0x02,
68603 +};
68604 +
68605 +#define GR_CRASH_RES 31
68606 +#define GR_UIDTABLE_MAX 500
68607 +
68608 +/* begin resource learning section */
68609 +enum {
68610 + GR_RLIM_CPU_BUMP = 60,
68611 + GR_RLIM_FSIZE_BUMP = 50000,
68612 + GR_RLIM_DATA_BUMP = 10000,
68613 + GR_RLIM_STACK_BUMP = 1000,
68614 + GR_RLIM_CORE_BUMP = 10000,
68615 + GR_RLIM_RSS_BUMP = 500000,
68616 + GR_RLIM_NPROC_BUMP = 1,
68617 + GR_RLIM_NOFILE_BUMP = 5,
68618 + GR_RLIM_MEMLOCK_BUMP = 50000,
68619 + GR_RLIM_AS_BUMP = 500000,
68620 + GR_RLIM_LOCKS_BUMP = 2,
68621 + GR_RLIM_SIGPENDING_BUMP = 5,
68622 + GR_RLIM_MSGQUEUE_BUMP = 10000,
68623 + GR_RLIM_NICE_BUMP = 1,
68624 + GR_RLIM_RTPRIO_BUMP = 1,
68625 + GR_RLIM_RTTIME_BUMP = 1000000
68626 +};
68627 +
68628 +#endif
68629 diff --git a/include/linux/grinternal.h b/include/linux/grinternal.h
68630 new file mode 100644
68631 index 0000000..5402bce
68632 --- /dev/null
68633 +++ b/include/linux/grinternal.h
68634 @@ -0,0 +1,215 @@
68635 +#ifndef __GRINTERNAL_H
68636 +#define __GRINTERNAL_H
68637 +
68638 +#ifdef CONFIG_GRKERNSEC
68639 +
68640 +#include <linux/fs.h>
68641 +#include <linux/mnt_namespace.h>
68642 +#include <linux/nsproxy.h>
68643 +#include <linux/gracl.h>
68644 +#include <linux/grdefs.h>
68645 +#include <linux/grmsg.h>
68646 +
68647 +void gr_add_learn_entry(const char *fmt, ...)
68648 + __attribute__ ((format (printf, 1, 2)));
68649 +__u32 gr_search_file(const struct dentry *dentry, const __u32 mode,
68650 + const struct vfsmount *mnt);
68651 +__u32 gr_check_create(const struct dentry *new_dentry,
68652 + const struct dentry *parent,
68653 + const struct vfsmount *mnt, const __u32 mode);
68654 +int gr_check_protected_task(const struct task_struct *task);
68655 +__u32 to_gr_audit(const __u32 reqmode);
68656 +int gr_set_acls(const int type);
68657 +int gr_apply_subject_to_task(struct task_struct *task);
68658 +int gr_acl_is_enabled(void);
68659 +char gr_roletype_to_char(void);
68660 +
68661 +void gr_handle_alertkill(struct task_struct *task);
68662 +char *gr_to_filename(const struct dentry *dentry,
68663 + const struct vfsmount *mnt);
68664 +char *gr_to_filename1(const struct dentry *dentry,
68665 + const struct vfsmount *mnt);
68666 +char *gr_to_filename2(const struct dentry *dentry,
68667 + const struct vfsmount *mnt);
68668 +char *gr_to_filename3(const struct dentry *dentry,
68669 + const struct vfsmount *mnt);
68670 +
68671 +extern int grsec_enable_ptrace_readexec;
68672 +extern int grsec_enable_harden_ptrace;
68673 +extern int grsec_enable_link;
68674 +extern int grsec_enable_fifo;
68675 +extern int grsec_enable_execve;
68676 +extern int grsec_enable_shm;
68677 +extern int grsec_enable_execlog;
68678 +extern int grsec_enable_signal;
68679 +extern int grsec_enable_audit_ptrace;
68680 +extern int grsec_enable_forkfail;
68681 +extern int grsec_enable_time;
68682 +extern int grsec_enable_rofs;
68683 +extern int grsec_enable_chroot_shmat;
68684 +extern int grsec_enable_chroot_mount;
68685 +extern int grsec_enable_chroot_double;
68686 +extern int grsec_enable_chroot_pivot;
68687 +extern int grsec_enable_chroot_chdir;
68688 +extern int grsec_enable_chroot_chmod;
68689 +extern int grsec_enable_chroot_mknod;
68690 +extern int grsec_enable_chroot_fchdir;
68691 +extern int grsec_enable_chroot_nice;
68692 +extern int grsec_enable_chroot_execlog;
68693 +extern int grsec_enable_chroot_caps;
68694 +extern int grsec_enable_chroot_sysctl;
68695 +extern int grsec_enable_chroot_unix;
68696 +extern int grsec_enable_symlinkown;
68697 +extern kgid_t grsec_symlinkown_gid;
68698 +extern int grsec_enable_tpe;
68699 +extern kgid_t grsec_tpe_gid;
68700 +extern int grsec_enable_tpe_all;
68701 +extern int grsec_enable_tpe_invert;
68702 +extern int grsec_enable_socket_all;
68703 +extern kgid_t grsec_socket_all_gid;
68704 +extern int grsec_enable_socket_client;
68705 +extern kgid_t grsec_socket_client_gid;
68706 +extern int grsec_enable_socket_server;
68707 +extern kgid_t grsec_socket_server_gid;
68708 +extern kgid_t grsec_audit_gid;
68709 +extern int grsec_enable_group;
68710 +extern int grsec_enable_audit_textrel;
68711 +extern int grsec_enable_log_rwxmaps;
68712 +extern int grsec_enable_mount;
68713 +extern int grsec_enable_chdir;
68714 +extern int grsec_resource_logging;
68715 +extern int grsec_enable_blackhole;
68716 +extern int grsec_lastack_retries;
68717 +extern int grsec_enable_brute;
68718 +extern int grsec_lock;
68719 +
68720 +extern spinlock_t grsec_alert_lock;
68721 +extern unsigned long grsec_alert_wtime;
68722 +extern unsigned long grsec_alert_fyet;
68723 +
68724 +extern spinlock_t grsec_audit_lock;
68725 +
68726 +extern rwlock_t grsec_exec_file_lock;
68727 +
68728 +#define gr_task_fullpath(tsk) ((tsk)->exec_file ? \
68729 + gr_to_filename2((tsk)->exec_file->f_path.dentry, \
68730 + (tsk)->exec_file->f_path.mnt) : "/")
68731 +
68732 +#define gr_parent_task_fullpath(tsk) ((tsk)->real_parent->exec_file ? \
68733 + gr_to_filename3((tsk)->real_parent->exec_file->f_path.dentry, \
68734 + (tsk)->real_parent->exec_file->f_path.mnt) : "/")
68735 +
68736 +#define gr_task_fullpath0(tsk) ((tsk)->exec_file ? \
68737 + gr_to_filename((tsk)->exec_file->f_path.dentry, \
68738 + (tsk)->exec_file->f_path.mnt) : "/")
68739 +
68740 +#define gr_parent_task_fullpath0(tsk) ((tsk)->real_parent->exec_file ? \
68741 + gr_to_filename1((tsk)->real_parent->exec_file->f_path.dentry, \
68742 + (tsk)->real_parent->exec_file->f_path.mnt) : "/")
68743 +
68744 +#define proc_is_chrooted(tsk_a) ((tsk_a)->gr_is_chrooted)
68745 +
68746 +#define have_same_root(tsk_a,tsk_b) ((tsk_a)->gr_chroot_dentry == (tsk_b)->gr_chroot_dentry)
68747 +
68748 +#define GR_CHROOT_CAPS {{ \
68749 + CAP_TO_MASK(CAP_LINUX_IMMUTABLE) | CAP_TO_MASK(CAP_NET_ADMIN) | \
68750 + CAP_TO_MASK(CAP_SYS_MODULE) | CAP_TO_MASK(CAP_SYS_RAWIO) | \
68751 + CAP_TO_MASK(CAP_SYS_PACCT) | CAP_TO_MASK(CAP_SYS_ADMIN) | \
68752 + CAP_TO_MASK(CAP_SYS_BOOT) | CAP_TO_MASK(CAP_SYS_TIME) | \
68753 + CAP_TO_MASK(CAP_NET_RAW) | CAP_TO_MASK(CAP_SYS_TTY_CONFIG) | \
68754 + CAP_TO_MASK(CAP_IPC_OWNER) | CAP_TO_MASK(CAP_SETFCAP), \
68755 + CAP_TO_MASK(CAP_SYSLOG) | CAP_TO_MASK(CAP_MAC_ADMIN) }}
68756 +
68757 +#define security_learn(normal_msg,args...) \
68758 +({ \
68759 + read_lock(&grsec_exec_file_lock); \
68760 + gr_add_learn_entry(normal_msg "\n", ## args); \
68761 + read_unlock(&grsec_exec_file_lock); \
68762 +})
68763 +
68764 +enum {
68765 + GR_DO_AUDIT,
68766 + GR_DONT_AUDIT,
68767 + /* used for non-audit messages that we shouldn't kill the task on */
68768 + GR_DONT_AUDIT_GOOD
68769 +};
68770 +
68771 +enum {
68772 + GR_TTYSNIFF,
68773 + GR_RBAC,
68774 + GR_RBAC_STR,
68775 + GR_STR_RBAC,
68776 + GR_RBAC_MODE2,
68777 + GR_RBAC_MODE3,
68778 + GR_FILENAME,
68779 + GR_SYSCTL_HIDDEN,
68780 + GR_NOARGS,
68781 + GR_ONE_INT,
68782 + GR_ONE_INT_TWO_STR,
68783 + GR_ONE_STR,
68784 + GR_STR_INT,
68785 + GR_TWO_STR_INT,
68786 + GR_TWO_INT,
68787 + GR_TWO_U64,
68788 + GR_THREE_INT,
68789 + GR_FIVE_INT_TWO_STR,
68790 + GR_TWO_STR,
68791 + GR_THREE_STR,
68792 + GR_FOUR_STR,
68793 + GR_STR_FILENAME,
68794 + GR_FILENAME_STR,
68795 + GR_FILENAME_TWO_INT,
68796 + GR_FILENAME_TWO_INT_STR,
68797 + GR_TEXTREL,
68798 + GR_PTRACE,
68799 + GR_RESOURCE,
68800 + GR_CAP,
68801 + GR_SIG,
68802 + GR_SIG2,
68803 + GR_CRASH1,
68804 + GR_CRASH2,
68805 + GR_PSACCT,
68806 + GR_RWXMAP
68807 +};
68808 +
68809 +#define gr_log_hidden_sysctl(audit, msg, str) gr_log_varargs(audit, msg, GR_SYSCTL_HIDDEN, str)
68810 +#define gr_log_ttysniff(audit, msg, task) gr_log_varargs(audit, msg, GR_TTYSNIFF, task)
68811 +#define gr_log_fs_rbac_generic(audit, msg, dentry, mnt) gr_log_varargs(audit, msg, GR_RBAC, dentry, mnt)
68812 +#define gr_log_fs_rbac_str(audit, msg, dentry, mnt, str) gr_log_varargs(audit, msg, GR_RBAC_STR, dentry, mnt, str)
68813 +#define gr_log_fs_str_rbac(audit, msg, str, dentry, mnt) gr_log_varargs(audit, msg, GR_STR_RBAC, str, dentry, mnt)
68814 +#define gr_log_fs_rbac_mode2(audit, msg, dentry, mnt, str1, str2) gr_log_varargs(audit, msg, GR_RBAC_MODE2, dentry, mnt, str1, str2)
68815 +#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)
68816 +#define gr_log_fs_generic(audit, msg, dentry, mnt) gr_log_varargs(audit, msg, GR_FILENAME, dentry, mnt)
68817 +#define gr_log_noargs(audit, msg) gr_log_varargs(audit, msg, GR_NOARGS)
68818 +#define gr_log_int(audit, msg, num) gr_log_varargs(audit, msg, GR_ONE_INT, num)
68819 +#define gr_log_int_str2(audit, msg, num, str1, str2) gr_log_varargs(audit, msg, GR_ONE_INT_TWO_STR, num, str1, str2)
68820 +#define gr_log_str(audit, msg, str) gr_log_varargs(audit, msg, GR_ONE_STR, str)
68821 +#define gr_log_str_int(audit, msg, str, num) gr_log_varargs(audit, msg, GR_STR_INT, str, num)
68822 +#define gr_log_int_int(audit, msg, num1, num2) gr_log_varargs(audit, msg, GR_TWO_INT, num1, num2)
68823 +#define gr_log_two_u64(audit, msg, num1, num2) gr_log_varargs(audit, msg, GR_TWO_U64, num1, num2)
68824 +#define gr_log_int3(audit, msg, num1, num2, num3) gr_log_varargs(audit, msg, GR_THREE_INT, num1, num2, num3)
68825 +#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)
68826 +#define gr_log_str_str(audit, msg, str1, str2) gr_log_varargs(audit, msg, GR_TWO_STR, str1, str2)
68827 +#define gr_log_str2_int(audit, msg, str1, str2, num) gr_log_varargs(audit, msg, GR_TWO_STR_INT, str1, str2, num)
68828 +#define gr_log_str3(audit, msg, str1, str2, str3) gr_log_varargs(audit, msg, GR_THREE_STR, str1, str2, str3)
68829 +#define gr_log_str4(audit, msg, str1, str2, str3, str4) gr_log_varargs(audit, msg, GR_FOUR_STR, str1, str2, str3, str4)
68830 +#define gr_log_str_fs(audit, msg, str, dentry, mnt) gr_log_varargs(audit, msg, GR_STR_FILENAME, str, dentry, mnt)
68831 +#define gr_log_fs_str(audit, msg, dentry, mnt, str) gr_log_varargs(audit, msg, GR_FILENAME_STR, dentry, mnt, str)
68832 +#define gr_log_fs_int2(audit, msg, dentry, mnt, num1, num2) gr_log_varargs(audit, msg, GR_FILENAME_TWO_INT, dentry, mnt, num1, num2)
68833 +#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)
68834 +#define gr_log_textrel_ulong_ulong(audit, msg, file, ulong1, ulong2) gr_log_varargs(audit, msg, GR_TEXTREL, file, ulong1, ulong2)
68835 +#define gr_log_ptrace(audit, msg, task) gr_log_varargs(audit, msg, GR_PTRACE, task)
68836 +#define gr_log_res_ulong2_str(audit, msg, task, ulong1, str, ulong2) gr_log_varargs(audit, msg, GR_RESOURCE, task, ulong1, str, ulong2)
68837 +#define gr_log_cap(audit, msg, task, str) gr_log_varargs(audit, msg, GR_CAP, task, str)
68838 +#define gr_log_sig_addr(audit, msg, str, addr) gr_log_varargs(audit, msg, GR_SIG, str, addr)
68839 +#define gr_log_sig_task(audit, msg, task, num) gr_log_varargs(audit, msg, GR_SIG2, task, num)
68840 +#define gr_log_crash1(audit, msg, task, ulong) gr_log_varargs(audit, msg, GR_CRASH1, task, ulong)
68841 +#define gr_log_crash2(audit, msg, task, ulong1) gr_log_varargs(audit, msg, GR_CRASH2, task, ulong1)
68842 +#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)
68843 +#define gr_log_rwxmap(audit, msg, str) gr_log_varargs(audit, msg, GR_RWXMAP, str)
68844 +
68845 +void gr_log_varargs(int audit, const char *msg, int argtypes, ...);
68846 +
68847 +#endif
68848 +
68849 +#endif
68850 diff --git a/include/linux/grmsg.h b/include/linux/grmsg.h
68851 new file mode 100644
68852 index 0000000..2bd4c8d
68853 --- /dev/null
68854 +++ b/include/linux/grmsg.h
68855 @@ -0,0 +1,111 @@
68856 +#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"
68857 +#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"
68858 +#define GR_PTRACE_ACL_MSG "denied ptrace of %.950s(%.16s:%d) by "
68859 +#define GR_STOPMOD_MSG "denied modification of module state by "
68860 +#define GR_ROFS_BLOCKWRITE_MSG "denied write to block device %.950s by "
68861 +#define GR_ROFS_MOUNT_MSG "denied writable mount of %.950s by "
68862 +#define GR_IOPERM_MSG "denied use of ioperm() by "
68863 +#define GR_IOPL_MSG "denied use of iopl() by "
68864 +#define GR_SHMAT_ACL_MSG "denied attach of shared memory of UID %u, PID %d, ID %u by "
68865 +#define GR_UNIX_CHROOT_MSG "denied connect() to abstract AF_UNIX socket outside of chroot by "
68866 +#define GR_SHMAT_CHROOT_MSG "denied attach of shared memory outside of chroot by "
68867 +#define GR_MEM_READWRITE_MSG "denied access of range %Lx -> %Lx in /dev/mem by "
68868 +#define GR_SYMLINK_MSG "not following symlink %.950s owned by %d.%d by "
68869 +#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"
68870 +#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"
68871 +#define GR_HIDDEN_ACL_MSG "%s access to hidden file %.950s by "
68872 +#define GR_OPEN_ACL_MSG "%s open of %.950s for%s%s by "
68873 +#define GR_CREATE_ACL_MSG "%s create of %.950s for%s%s by "
68874 +#define GR_FIFO_MSG "denied writing FIFO %.950s of %d.%d by "
68875 +#define GR_MKNOD_CHROOT_MSG "denied mknod of %.950s from chroot by "
68876 +#define GR_MKNOD_ACL_MSG "%s mknod of %.950s by "
68877 +#define GR_UNIXCONNECT_ACL_MSG "%s connect() to the unix domain socket %.950s by "
68878 +#define GR_TTYSNIFF_ACL_MSG "terminal being sniffed by IP:%pI4 %.480s[%.16s:%d], parent %.480s[%.16s:%d] against "
68879 +#define GR_MKDIR_ACL_MSG "%s mkdir of %.950s by "
68880 +#define GR_RMDIR_ACL_MSG "%s rmdir of %.950s by "
68881 +#define GR_UNLINK_ACL_MSG "%s unlink of %.950s by "
68882 +#define GR_SYMLINK_ACL_MSG "%s symlink from %.480s to %.480s by "
68883 +#define GR_HARDLINK_MSG "denied hardlink of %.930s (owned by %d.%d) to %.30s for "
68884 +#define GR_LINK_ACL_MSG "%s link of %.480s to %.480s by "
68885 +#define GR_INHERIT_ACL_MSG "successful inherit of %.480s's ACL for %.480s by "
68886 +#define GR_RENAME_ACL_MSG "%s rename of %.480s to %.480s by "
68887 +#define GR_UNSAFESHARE_EXEC_ACL_MSG "denied exec with cloned fs of %.950s by "
68888 +#define GR_PTRACE_EXEC_ACL_MSG "denied ptrace of %.950s by "
68889 +#define GR_EXEC_ACL_MSG "%s execution of %.950s by "
68890 +#define GR_EXEC_TPE_MSG "denied untrusted exec (due to %.70s) of %.950s by "
68891 +#define GR_SEGVSTART_ACL_MSG "possible exploit bruteforcing on " DEFAULTSECMSG " banning uid %u from login for %lu seconds"
68892 +#define GR_SEGVNOSUID_ACL_MSG "possible exploit bruteforcing on " DEFAULTSECMSG " banning execution for %lu seconds"
68893 +#define GR_MOUNT_CHROOT_MSG "denied mount of %.256s as %.930s from chroot by "
68894 +#define GR_PIVOT_CHROOT_MSG "denied pivot_root from chroot by "
68895 +#define GR_TRUNCATE_ACL_MSG "%s truncate of %.950s by "
68896 +#define GR_ATIME_ACL_MSG "%s access time change of %.950s by "
68897 +#define GR_ACCESS_ACL_MSG "%s access of %.950s for%s%s%s by "
68898 +#define GR_CHROOT_CHROOT_MSG "denied double chroot to %.950s by "
68899 +#define GR_CHMOD_CHROOT_MSG "denied chmod +s of %.950s by "
68900 +#define GR_CHMOD_ACL_MSG "%s chmod of %.950s by "
68901 +#define GR_CHROOT_FCHDIR_MSG "denied fchdir outside of chroot to %.950s by "
68902 +#define GR_CHOWN_ACL_MSG "%s chown of %.950s by "
68903 +#define GR_SETXATTR_ACL_MSG "%s setting extended attributes of %.950s by "
68904 +#define GR_WRITLIB_ACL_MSG "denied load of writable library %.950s by "
68905 +#define GR_INITF_ACL_MSG "init_variables() failed %s by "
68906 +#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"
68907 +#define GR_DEV_ACL_MSG "/dev/grsec: %d bytes sent %d required, being fed garbage by "
68908 +#define GR_SHUTS_ACL_MSG "shutdown auth success for "
68909 +#define GR_SHUTF_ACL_MSG "shutdown auth failure for "
68910 +#define GR_SHUTI_ACL_MSG "ignoring shutdown for disabled RBAC system for "
68911 +#define GR_SEGVMODS_ACL_MSG "segvmod auth success for "
68912 +#define GR_SEGVMODF_ACL_MSG "segvmod auth failure for "
68913 +#define GR_SEGVMODI_ACL_MSG "ignoring segvmod for disabled RBAC system for "
68914 +#define GR_ENABLE_ACL_MSG "%s RBAC system loaded by "
68915 +#define GR_ENABLEF_ACL_MSG "unable to load %s for "
68916 +#define GR_RELOADI_ACL_MSG "ignoring reload request for disabled RBAC system"
68917 +#define GR_RELOAD_ACL_MSG "%s RBAC system reloaded by "
68918 +#define GR_RELOADF_ACL_MSG "failed reload of %s for "
68919 +#define GR_SPROLEI_ACL_MSG "ignoring change to special role for disabled RBAC system for "
68920 +#define GR_SPROLES_ACL_MSG "successful change to special role %s (id %d) by "
68921 +#define GR_SPROLEL_ACL_MSG "special role %s (id %d) exited by "
68922 +#define GR_SPROLEF_ACL_MSG "special role %s failure for "
68923 +#define GR_UNSPROLEI_ACL_MSG "ignoring unauth of special role for disabled RBAC system for "
68924 +#define GR_UNSPROLES_ACL_MSG "successful unauth of special role %s (id %d) by "
68925 +#define GR_INVMODE_ACL_MSG "invalid mode %d by "
68926 +#define GR_PRIORITY_CHROOT_MSG "denied priority change of process (%.16s:%d) by "
68927 +#define GR_FAILFORK_MSG "failed fork with errno %s by "
68928 +#define GR_NICE_CHROOT_MSG "denied priority change by "
68929 +#define GR_UNISIGLOG_MSG "%.32s occurred at %p in "
68930 +#define GR_DUALSIGLOG_MSG "signal %d sent to " DEFAULTSECMSG " by "
68931 +#define GR_SIG_ACL_MSG "denied send of signal %d to protected task " DEFAULTSECMSG " by "
68932 +#define GR_SYSCTL_MSG "denied modification of grsecurity sysctl value : %.32s by "
68933 +#define GR_SYSCTL_ACL_MSG "%s sysctl of %.950s for%s%s by "
68934 +#define GR_TIME_MSG "time set by "
68935 +#define GR_DEFACL_MSG "fatal: unable to find subject for (%.16s:%d), loaded by "
68936 +#define GR_MMAP_ACL_MSG "%s executable mmap of %.950s by "
68937 +#define GR_MPROTECT_ACL_MSG "%s executable mprotect of %.950s by "
68938 +#define GR_SOCK_MSG "denied socket(%.16s,%.16s,%.16s) by "
68939 +#define GR_SOCK_NOINET_MSG "denied socket(%.16s,%.16s,%d) by "
68940 +#define GR_BIND_MSG "denied bind() by "
68941 +#define GR_CONNECT_MSG "denied connect() by "
68942 +#define GR_BIND_ACL_MSG "denied bind() to %pI4 port %u sock type %.16s protocol %.16s by "
68943 +#define GR_CONNECT_ACL_MSG "denied connect() to %pI4 port %u sock type %.16s protocol %.16s by "
68944 +#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"
68945 +#define GR_EXEC_CHROOT_MSG "exec of %.980s within chroot by process "
68946 +#define GR_CAP_ACL_MSG "use of %s denied for "
68947 +#define GR_CAP_CHROOT_MSG "use of %s in chroot denied for "
68948 +#define GR_CAP_ACL_MSG2 "use of %s permitted for "
68949 +#define GR_USRCHANGE_ACL_MSG "change to uid %u denied for "
68950 +#define GR_GRPCHANGE_ACL_MSG "change to gid %u denied for "
68951 +#define GR_REMOUNT_AUDIT_MSG "remount of %.256s by "
68952 +#define GR_UNMOUNT_AUDIT_MSG "unmount of %.256s by "
68953 +#define GR_MOUNT_AUDIT_MSG "mount of %.256s to %.256s by "
68954 +#define GR_CHDIR_AUDIT_MSG "chdir to %.980s by "
68955 +#define GR_EXEC_AUDIT_MSG "exec of %.930s (%.128s) by "
68956 +#define GR_RESOURCE_MSG "denied resource overstep by requesting %lu for %.16s against limit %lu for "
68957 +#define GR_RWXMMAP_MSG "denied RWX mmap of %.950s by "
68958 +#define GR_RWXMPROTECT_MSG "denied RWX mprotect of %.950s by "
68959 +#define GR_TEXTREL_AUDIT_MSG "text relocation in %s, VMA:0x%08lx 0x%08lx by "
68960 +#define GR_VM86_MSG "denied use of vm86 by "
68961 +#define GR_PTRACE_AUDIT_MSG "process %.950s(%.16s:%d) attached to via ptrace by "
68962 +#define GR_PTRACE_READEXEC_MSG "denied ptrace of unreadable binary %.950s by "
68963 +#define GR_INIT_TRANSFER_MSG "persistent special role transferred privilege to init by "
68964 +#define GR_BADPROCPID_MSG "denied read of sensitive /proc/pid/%s entry via fd passed across exec by "
68965 +#define GR_SYMLINKOWNER_MSG "denied following symlink %.950s since symlink owner %u does not match target owner %u, by "
68966 +#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 "
68967 diff --git a/include/linux/grsecurity.h b/include/linux/grsecurity.h
68968 new file mode 100644
68969 index 0000000..d7ef0ac
68970 --- /dev/null
68971 +++ b/include/linux/grsecurity.h
68972 @@ -0,0 +1,242 @@
68973 +#ifndef GR_SECURITY_H
68974 +#define GR_SECURITY_H
68975 +#include <linux/fs.h>
68976 +#include <linux/fs_struct.h>
68977 +#include <linux/binfmts.h>
68978 +#include <linux/gracl.h>
68979 +
68980 +/* notify of brain-dead configs */
68981 +#if defined(CONFIG_GRKERNSEC_PROC_USER) && defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
68982 +#error "CONFIG_GRKERNSEC_PROC_USER and CONFIG_GRKERNSEC_PROC_USERGROUP cannot both be enabled."
68983 +#endif
68984 +#if defined(CONFIG_PAX_NOEXEC) && !defined(CONFIG_PAX_PAGEEXEC) && !defined(CONFIG_PAX_SEGMEXEC) && !defined(CONFIG_PAX_KERNEXEC)
68985 +#error "CONFIG_PAX_NOEXEC enabled, but PAGEEXEC, SEGMEXEC, and KERNEXEC are disabled."
68986 +#endif
68987 +#if defined(CONFIG_PAX_ASLR) && !defined(CONFIG_PAX_RANDKSTACK) && !defined(CONFIG_PAX_RANDUSTACK) && !defined(CONFIG_PAX_RANDMMAP)
68988 +#error "CONFIG_PAX_ASLR enabled, but RANDKSTACK, RANDUSTACK, and RANDMMAP are disabled."
68989 +#endif
68990 +#if defined(CONFIG_PAX) && !defined(CONFIG_PAX_NOEXEC) && !defined(CONFIG_PAX_ASLR)
68991 +#error "CONFIG_PAX enabled, but no PaX options are enabled."
68992 +#endif
68993 +
68994 +void gr_handle_brute_attach(unsigned long mm_flags);
68995 +void gr_handle_brute_check(void);
68996 +void gr_handle_kernel_exploit(void);
68997 +int gr_process_user_ban(void);
68998 +
68999 +char gr_roletype_to_char(void);
69000 +
69001 +int gr_acl_enable_at_secure(void);
69002 +
69003 +int gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs);
69004 +int gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs);
69005 +
69006 +void gr_del_task_from_ip_table(struct task_struct *p);
69007 +
69008 +int gr_pid_is_chrooted(struct task_struct *p);
69009 +int gr_handle_chroot_fowner(struct pid *pid, enum pid_type type);
69010 +int gr_handle_chroot_nice(void);
69011 +int gr_handle_chroot_sysctl(const int op);
69012 +int gr_handle_chroot_setpriority(struct task_struct *p,
69013 + const int niceval);
69014 +int gr_chroot_fchdir(struct dentry *u_dentry, struct vfsmount *u_mnt);
69015 +int gr_handle_chroot_chroot(const struct dentry *dentry,
69016 + const struct vfsmount *mnt);
69017 +void gr_handle_chroot_chdir(const struct path *path);
69018 +int gr_handle_chroot_chmod(const struct dentry *dentry,
69019 + const struct vfsmount *mnt, const int mode);
69020 +int gr_handle_chroot_mknod(const struct dentry *dentry,
69021 + const struct vfsmount *mnt, const int mode);
69022 +int gr_handle_chroot_mount(const struct dentry *dentry,
69023 + const struct vfsmount *mnt,
69024 + const char *dev_name);
69025 +int gr_handle_chroot_pivot(void);
69026 +int gr_handle_chroot_unix(const pid_t pid);
69027 +
69028 +int gr_handle_rawio(const struct inode *inode);
69029 +
69030 +void gr_handle_ioperm(void);
69031 +void gr_handle_iopl(void);
69032 +
69033 +umode_t gr_acl_umask(void);
69034 +
69035 +int gr_tpe_allow(const struct file *file);
69036 +
69037 +void gr_set_chroot_entries(struct task_struct *task, const struct path *path);
69038 +void gr_clear_chroot_entries(struct task_struct *task);
69039 +
69040 +void gr_log_forkfail(const int retval);
69041 +void gr_log_timechange(void);
69042 +void gr_log_signal(const int sig, const void *addr, const struct task_struct *t);
69043 +void gr_log_chdir(const struct dentry *dentry,
69044 + const struct vfsmount *mnt);
69045 +void gr_log_chroot_exec(const struct dentry *dentry,
69046 + const struct vfsmount *mnt);
69047 +void gr_log_remount(const char *devname, const int retval);
69048 +void gr_log_unmount(const char *devname, const int retval);
69049 +void gr_log_mount(const char *from, const char *to, const int retval);
69050 +void gr_log_textrel(struct vm_area_struct *vma);
69051 +void gr_log_rwxmmap(struct file *file);
69052 +void gr_log_rwxmprotect(struct file *file);
69053 +
69054 +int gr_handle_follow_link(const struct inode *parent,
69055 + const struct inode *inode,
69056 + const struct dentry *dentry,
69057 + const struct vfsmount *mnt);
69058 +int gr_handle_fifo(const struct dentry *dentry,
69059 + const struct vfsmount *mnt,
69060 + const struct dentry *dir, const int flag,
69061 + const int acc_mode);
69062 +int gr_handle_hardlink(const struct dentry *dentry,
69063 + const struct vfsmount *mnt,
69064 + struct inode *inode,
69065 + const int mode, const struct filename *to);
69066 +
69067 +int gr_is_capable(const int cap);
69068 +int gr_is_capable_nolog(const int cap);
69069 +int gr_task_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
69070 +int gr_task_is_capable_nolog(const struct task_struct *task, const int cap);
69071 +
69072 +void gr_copy_label(struct task_struct *tsk);
69073 +void gr_handle_crash(struct task_struct *task, const int sig);
69074 +int gr_handle_signal(const struct task_struct *p, const int sig);
69075 +int gr_check_crash_uid(const kuid_t uid);
69076 +int gr_check_protected_task(const struct task_struct *task);
69077 +int gr_check_protected_task_fowner(struct pid *pid, enum pid_type type);
69078 +int gr_acl_handle_mmap(const struct file *file,
69079 + const unsigned long prot);
69080 +int gr_acl_handle_mprotect(const struct file *file,
69081 + const unsigned long prot);
69082 +int gr_check_hidden_task(const struct task_struct *tsk);
69083 +__u32 gr_acl_handle_truncate(const struct dentry *dentry,
69084 + const struct vfsmount *mnt);
69085 +__u32 gr_acl_handle_utime(const struct dentry *dentry,
69086 + const struct vfsmount *mnt);
69087 +__u32 gr_acl_handle_access(const struct dentry *dentry,
69088 + const struct vfsmount *mnt, const int fmode);
69089 +__u32 gr_acl_handle_chmod(const struct dentry *dentry,
69090 + const struct vfsmount *mnt, umode_t *mode);
69091 +__u32 gr_acl_handle_chown(const struct dentry *dentry,
69092 + const struct vfsmount *mnt);
69093 +__u32 gr_acl_handle_setxattr(const struct dentry *dentry,
69094 + const struct vfsmount *mnt);
69095 +int gr_handle_ptrace(struct task_struct *task, const long request);
69096 +int gr_handle_proc_ptrace(struct task_struct *task);
69097 +__u32 gr_acl_handle_execve(const struct dentry *dentry,
69098 + const struct vfsmount *mnt);
69099 +int gr_check_crash_exec(const struct file *filp);
69100 +int gr_acl_is_enabled(void);
69101 +void gr_set_kernel_label(struct task_struct *task);
69102 +void gr_set_role_label(struct task_struct *task, const kuid_t uid,
69103 + const kgid_t gid);
69104 +int gr_set_proc_label(const struct dentry *dentry,
69105 + const struct vfsmount *mnt,
69106 + const int unsafe_flags);
69107 +__u32 gr_acl_handle_hidden_file(const struct dentry *dentry,
69108 + const struct vfsmount *mnt);
69109 +__u32 gr_acl_handle_open(const struct dentry *dentry,
69110 + const struct vfsmount *mnt, int acc_mode);
69111 +__u32 gr_acl_handle_creat(const struct dentry *dentry,
69112 + const struct dentry *p_dentry,
69113 + const struct vfsmount *p_mnt,
69114 + int open_flags, int acc_mode, const int imode);
69115 +void gr_handle_create(const struct dentry *dentry,
69116 + const struct vfsmount *mnt);
69117 +void gr_handle_proc_create(const struct dentry *dentry,
69118 + const struct inode *inode);
69119 +__u32 gr_acl_handle_mknod(const struct dentry *new_dentry,
69120 + const struct dentry *parent_dentry,
69121 + const struct vfsmount *parent_mnt,
69122 + const int mode);
69123 +__u32 gr_acl_handle_mkdir(const struct dentry *new_dentry,
69124 + const struct dentry *parent_dentry,
69125 + const struct vfsmount *parent_mnt);
69126 +__u32 gr_acl_handle_rmdir(const struct dentry *dentry,
69127 + const struct vfsmount *mnt);
69128 +void gr_handle_delete(const ino_t ino, const dev_t dev);
69129 +__u32 gr_acl_handle_unlink(const struct dentry *dentry,
69130 + const struct vfsmount *mnt);
69131 +__u32 gr_acl_handle_symlink(const struct dentry *new_dentry,
69132 + const struct dentry *parent_dentry,
69133 + const struct vfsmount *parent_mnt,
69134 + const struct filename *from);
69135 +__u32 gr_acl_handle_link(const struct dentry *new_dentry,
69136 + const struct dentry *parent_dentry,
69137 + const struct vfsmount *parent_mnt,
69138 + const struct dentry *old_dentry,
69139 + const struct vfsmount *old_mnt, const struct filename *to);
69140 +int gr_handle_symlink_owner(const struct path *link, const struct inode *target);
69141 +int gr_acl_handle_rename(struct dentry *new_dentry,
69142 + struct dentry *parent_dentry,
69143 + const struct vfsmount *parent_mnt,
69144 + struct dentry *old_dentry,
69145 + struct inode *old_parent_inode,
69146 + struct vfsmount *old_mnt, const struct filename *newname);
69147 +void gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
69148 + struct dentry *old_dentry,
69149 + struct dentry *new_dentry,
69150 + struct vfsmount *mnt, const __u8 replace);
69151 +__u32 gr_check_link(const struct dentry *new_dentry,
69152 + const struct dentry *parent_dentry,
69153 + const struct vfsmount *parent_mnt,
69154 + const struct dentry *old_dentry,
69155 + const struct vfsmount *old_mnt);
69156 +int gr_acl_handle_filldir(const struct file *file, const char *name,
69157 + const unsigned int namelen, const ino_t ino);
69158 +
69159 +__u32 gr_acl_handle_unix(const struct dentry *dentry,
69160 + const struct vfsmount *mnt);
69161 +void gr_acl_handle_exit(void);
69162 +void gr_acl_handle_psacct(struct task_struct *task, const long code);
69163 +int gr_acl_handle_procpidmem(const struct task_struct *task);
69164 +int gr_handle_rofs_mount(struct dentry *dentry, struct vfsmount *mnt, int mnt_flags);
69165 +int gr_handle_rofs_blockwrite(struct dentry *dentry, struct vfsmount *mnt, int acc_mode);
69166 +void gr_audit_ptrace(struct task_struct *task);
69167 +dev_t gr_get_dev_from_dentry(struct dentry *dentry);
69168 +void gr_put_exec_file(struct task_struct *task);
69169 +
69170 +int gr_ptrace_readexec(struct file *file, int unsafe_flags);
69171 +
69172 +#if defined(CONFIG_GRKERNSEC) && (defined(CONFIG_GRKERNSEC_RESLOG) || !defined(CONFIG_GRKERNSEC_NO_RBAC))
69173 +extern void gr_learn_resource(const struct task_struct *task, const int res,
69174 + const unsigned long wanted, const int gt);
69175 +#else
69176 +static inline void gr_learn_resource(const struct task_struct *task, const int res,
69177 + const unsigned long wanted, const int gt)
69178 +{
69179 +}
69180 +#endif
69181 +
69182 +#ifdef CONFIG_GRKERNSEC_RESLOG
69183 +extern void gr_log_resource(const struct task_struct *task, const int res,
69184 + const unsigned long wanted, const int gt);
69185 +#else
69186 +static inline void gr_log_resource(const struct task_struct *task, const int res,
69187 + const unsigned long wanted, const int gt)
69188 +{
69189 +}
69190 +#endif
69191 +
69192 +#ifdef CONFIG_GRKERNSEC
69193 +void task_grsec_rbac(struct seq_file *m, struct task_struct *p);
69194 +void gr_handle_vm86(void);
69195 +void gr_handle_mem_readwrite(u64 from, u64 to);
69196 +
69197 +void gr_log_badprocpid(const char *entry);
69198 +
69199 +extern int grsec_enable_dmesg;
69200 +extern int grsec_disable_privio;
69201 +
69202 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
69203 +extern kgid_t grsec_proc_gid;
69204 +#endif
69205 +
69206 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
69207 +extern int grsec_enable_chroot_findtask;
69208 +#endif
69209 +#ifdef CONFIG_GRKERNSEC_SETXID
69210 +extern int grsec_enable_setxid;
69211 +#endif
69212 +#endif
69213 +
69214 +#endif
69215 diff --git a/include/linux/grsock.h b/include/linux/grsock.h
69216 new file mode 100644
69217 index 0000000..e7ffaaf
69218 --- /dev/null
69219 +++ b/include/linux/grsock.h
69220 @@ -0,0 +1,19 @@
69221 +#ifndef __GRSOCK_H
69222 +#define __GRSOCK_H
69223 +
69224 +extern void gr_attach_curr_ip(const struct sock *sk);
69225 +extern int gr_handle_sock_all(const int family, const int type,
69226 + const int protocol);
69227 +extern int gr_handle_sock_server(const struct sockaddr *sck);
69228 +extern int gr_handle_sock_server_other(const struct sock *sck);
69229 +extern int gr_handle_sock_client(const struct sockaddr *sck);
69230 +extern int gr_search_connect(struct socket * sock,
69231 + struct sockaddr_in * addr);
69232 +extern int gr_search_bind(struct socket * sock,
69233 + struct sockaddr_in * addr);
69234 +extern int gr_search_listen(struct socket * sock);
69235 +extern int gr_search_accept(struct socket * sock);
69236 +extern int gr_search_socket(const int domain, const int type,
69237 + const int protocol);
69238 +
69239 +#endif
69240 diff --git a/include/linux/highmem.h b/include/linux/highmem.h
69241 index 7fb31da..08b5114 100644
69242 --- a/include/linux/highmem.h
69243 +++ b/include/linux/highmem.h
69244 @@ -189,6 +189,18 @@ static inline void clear_highpage(struct page *page)
69245 kunmap_atomic(kaddr);
69246 }
69247
69248 +static inline void sanitize_highpage(struct page *page)
69249 +{
69250 + void *kaddr;
69251 + unsigned long flags;
69252 +
69253 + local_irq_save(flags);
69254 + kaddr = kmap_atomic(page);
69255 + clear_page(kaddr);
69256 + kunmap_atomic(kaddr);
69257 + local_irq_restore(flags);
69258 +}
69259 +
69260 static inline void zero_user_segments(struct page *page,
69261 unsigned start1, unsigned end1,
69262 unsigned start2, unsigned end2)
69263 diff --git a/include/linux/hwmon-sysfs.h b/include/linux/hwmon-sysfs.h
69264 index 1c7b89a..7f52502 100644
69265 --- a/include/linux/hwmon-sysfs.h
69266 +++ b/include/linux/hwmon-sysfs.h
69267 @@ -25,7 +25,8 @@
69268 struct sensor_device_attribute{
69269 struct device_attribute dev_attr;
69270 int index;
69271 -};
69272 +} __do_const;
69273 +typedef struct sensor_device_attribute __no_const sensor_device_attribute_no_const;
69274 #define to_sensor_dev_attr(_dev_attr) \
69275 container_of(_dev_attr, struct sensor_device_attribute, dev_attr)
69276
69277 @@ -41,7 +42,7 @@ struct sensor_device_attribute_2 {
69278 struct device_attribute dev_attr;
69279 u8 index;
69280 u8 nr;
69281 -};
69282 +} __do_const;
69283 #define to_sensor_dev_attr_2(_dev_attr) \
69284 container_of(_dev_attr, struct sensor_device_attribute_2, dev_attr)
69285
69286 diff --git a/include/linux/i2c.h b/include/linux/i2c.h
69287 index d0c4db7..61b3577 100644
69288 --- a/include/linux/i2c.h
69289 +++ b/include/linux/i2c.h
69290 @@ -369,6 +369,7 @@ struct i2c_algorithm {
69291 /* To determine what the adapter supports */
69292 u32 (*functionality) (struct i2c_adapter *);
69293 };
69294 +typedef struct i2c_algorithm __no_const i2c_algorithm_no_const;
69295
69296 /*
69297 * i2c_adapter is the structure used to identify a physical i2c bus along
69298 diff --git a/include/linux/i2o.h b/include/linux/i2o.h
69299 index d23c3c2..eb63c81 100644
69300 --- a/include/linux/i2o.h
69301 +++ b/include/linux/i2o.h
69302 @@ -565,7 +565,7 @@ struct i2o_controller {
69303 struct i2o_device *exec; /* Executive */
69304 #if BITS_PER_LONG == 64
69305 spinlock_t context_list_lock; /* lock for context_list */
69306 - atomic_t context_list_counter; /* needed for unique contexts */
69307 + atomic_unchecked_t context_list_counter; /* needed for unique contexts */
69308 struct list_head context_list; /* list of context id's
69309 and pointers */
69310 #endif
69311 diff --git a/include/linux/if_pppox.h b/include/linux/if_pppox.h
69312 index aff7ad8..3942bbd 100644
69313 --- a/include/linux/if_pppox.h
69314 +++ b/include/linux/if_pppox.h
69315 @@ -76,7 +76,7 @@ struct pppox_proto {
69316 int (*ioctl)(struct socket *sock, unsigned int cmd,
69317 unsigned long arg);
69318 struct module *owner;
69319 -};
69320 +} __do_const;
69321
69322 extern int register_pppox_proto(int proto_num, const struct pppox_proto *pp);
69323 extern void unregister_pppox_proto(int proto_num);
69324 diff --git a/include/linux/init.h b/include/linux/init.h
69325 index 8618147..0821126 100644
69326 --- a/include/linux/init.h
69327 +++ b/include/linux/init.h
69328 @@ -39,9 +39,36 @@
69329 * Also note, that this data cannot be "const".
69330 */
69331
69332 +#ifdef MODULE
69333 +#define add_init_latent_entropy
69334 +#define add_devinit_latent_entropy
69335 +#define add_cpuinit_latent_entropy
69336 +#define add_meminit_latent_entropy
69337 +#else
69338 +#define add_init_latent_entropy __latent_entropy
69339 +
69340 +#ifdef CONFIG_HOTPLUG
69341 +#define add_devinit_latent_entropy
69342 +#else
69343 +#define add_devinit_latent_entropy __latent_entropy
69344 +#endif
69345 +
69346 +#ifdef CONFIG_HOTPLUG_CPU
69347 +#define add_cpuinit_latent_entropy
69348 +#else
69349 +#define add_cpuinit_latent_entropy __latent_entropy
69350 +#endif
69351 +
69352 +#ifdef CONFIG_MEMORY_HOTPLUG
69353 +#define add_meminit_latent_entropy
69354 +#else
69355 +#define add_meminit_latent_entropy __latent_entropy
69356 +#endif
69357 +#endif
69358 +
69359 /* These are for everybody (although not all archs will actually
69360 discard it in modules) */
69361 -#define __init __section(.init.text) __cold notrace
69362 +#define __init __section(.init.text) __cold notrace add_init_latent_entropy
69363 #define __initdata __section(.init.data)
69364 #define __initconst __constsection(.init.rodata)
69365 #define __exitdata __section(.exit.data)
69366 @@ -94,7 +121,7 @@
69367 #define __exit __section(.exit.text) __exitused __cold notrace
69368
69369 /* Used for HOTPLUG_CPU */
69370 -#define __cpuinit __section(.cpuinit.text) __cold notrace
69371 +#define __cpuinit __section(.cpuinit.text) __cold notrace add_cpuinit_latent_entropy
69372 #define __cpuinitdata __section(.cpuinit.data)
69373 #define __cpuinitconst __constsection(.cpuinit.rodata)
69374 #define __cpuexit __section(.cpuexit.text) __exitused __cold notrace
69375 @@ -102,7 +129,7 @@
69376 #define __cpuexitconst __constsection(.cpuexit.rodata)
69377
69378 /* Used for MEMORY_HOTPLUG */
69379 -#define __meminit __section(.meminit.text) __cold notrace
69380 +#define __meminit __section(.meminit.text) __cold notrace add_meminit_latent_entropy
69381 #define __meminitdata __section(.meminit.data)
69382 #define __meminitconst __constsection(.meminit.rodata)
69383 #define __memexit __section(.memexit.text) __exitused __cold notrace
69384 diff --git a/include/linux/init_task.h b/include/linux/init_task.h
69385 index 5cd0f09..c9f67cc 100644
69386 --- a/include/linux/init_task.h
69387 +++ b/include/linux/init_task.h
69388 @@ -154,6 +154,12 @@ extern struct task_group root_task_group;
69389
69390 #define INIT_TASK_COMM "swapper"
69391
69392 +#ifdef CONFIG_X86
69393 +#define INIT_TASK_THREAD_INFO .tinfo = INIT_THREAD_INFO,
69394 +#else
69395 +#define INIT_TASK_THREAD_INFO
69396 +#endif
69397 +
69398 /*
69399 * INIT_TASK is used to set up the first task table, touch at
69400 * your own risk!. Base=0, limit=0x1fffff (=2MB)
69401 @@ -193,6 +199,7 @@ extern struct task_group root_task_group;
69402 RCU_POINTER_INITIALIZER(cred, &init_cred), \
69403 .comm = INIT_TASK_COMM, \
69404 .thread = INIT_THREAD, \
69405 + INIT_TASK_THREAD_INFO \
69406 .fs = &init_fs, \
69407 .files = &init_files, \
69408 .signal = &init_signals, \
69409 diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
69410 index 5fa5afe..ac55b25 100644
69411 --- a/include/linux/interrupt.h
69412 +++ b/include/linux/interrupt.h
69413 @@ -430,7 +430,7 @@ enum
69414 /* map softirq index to softirq name. update 'softirq_to_name' in
69415 * kernel/softirq.c when adding a new softirq.
69416 */
69417 -extern char *softirq_to_name[NR_SOFTIRQS];
69418 +extern const char * const softirq_to_name[NR_SOFTIRQS];
69419
69420 /* softirq mask and active fields moved to irq_cpustat_t in
69421 * asm/hardirq.h to get better cache usage. KAO
69422 @@ -438,12 +438,12 @@ extern char *softirq_to_name[NR_SOFTIRQS];
69423
69424 struct softirq_action
69425 {
69426 - void (*action)(struct softirq_action *);
69427 -};
69428 + void (*action)(void);
69429 +} __no_const;
69430
69431 asmlinkage void do_softirq(void);
69432 asmlinkage void __do_softirq(void);
69433 -extern void open_softirq(int nr, void (*action)(struct softirq_action *));
69434 +extern void open_softirq(int nr, void (*action)(void));
69435 extern void softirq_init(void);
69436 extern void __raise_softirq_irqoff(unsigned int nr);
69437
69438 diff --git a/include/linux/iommu.h b/include/linux/iommu.h
69439 index ba3b8a9..7e14ed8 100644
69440 --- a/include/linux/iommu.h
69441 +++ b/include/linux/iommu.h
69442 @@ -113,7 +113,7 @@ struct iommu_ops {
69443 u32 (*domain_get_windows)(struct iommu_domain *domain);
69444
69445 unsigned long pgsize_bitmap;
69446 -};
69447 +} __do_const;
69448
69449 #define IOMMU_GROUP_NOTIFY_ADD_DEVICE 1 /* Device added */
69450 #define IOMMU_GROUP_NOTIFY_DEL_DEVICE 2 /* Pre Device removed */
69451 diff --git a/include/linux/ioport.h b/include/linux/ioport.h
69452 index 85ac9b9b..e5759ab 100644
69453 --- a/include/linux/ioport.h
69454 +++ b/include/linux/ioport.h
69455 @@ -161,7 +161,7 @@ struct resource *lookup_resource(struct resource *root, resource_size_t start);
69456 int adjust_resource(struct resource *res, resource_size_t start,
69457 resource_size_t size);
69458 resource_size_t resource_alignment(struct resource *res);
69459 -static inline resource_size_t resource_size(const struct resource *res)
69460 +static inline resource_size_t __intentional_overflow(-1) resource_size(const struct resource *res)
69461 {
69462 return res->end - res->start + 1;
69463 }
69464 diff --git a/include/linux/irq.h b/include/linux/irq.h
69465 index bc4e066..50468a9 100644
69466 --- a/include/linux/irq.h
69467 +++ b/include/linux/irq.h
69468 @@ -328,7 +328,8 @@ struct irq_chip {
69469 void (*irq_print_chip)(struct irq_data *data, struct seq_file *p);
69470
69471 unsigned long flags;
69472 -};
69473 +} __do_const;
69474 +typedef struct irq_chip __no_const irq_chip_no_const;
69475
69476 /*
69477 * irq_chip specific flags
69478 diff --git a/include/linux/irqchip/arm-gic.h b/include/linux/irqchip/arm-gic.h
69479 index 3fd8e42..a73e966 100644
69480 --- a/include/linux/irqchip/arm-gic.h
69481 +++ b/include/linux/irqchip/arm-gic.h
69482 @@ -59,9 +59,11 @@
69483
69484 #ifndef __ASSEMBLY__
69485
69486 +#include <linux/irq.h>
69487 +
69488 struct device_node;
69489
69490 -extern struct irq_chip gic_arch_extn;
69491 +extern irq_chip_no_const gic_arch_extn;
69492
69493 void gic_init_bases(unsigned int, int, void __iomem *, void __iomem *,
69494 u32 offset, struct device_node *);
69495 diff --git a/include/linux/kallsyms.h b/include/linux/kallsyms.h
69496 index 6883e19..06992b1 100644
69497 --- a/include/linux/kallsyms.h
69498 +++ b/include/linux/kallsyms.h
69499 @@ -15,7 +15,8 @@
69500
69501 struct module;
69502
69503 -#ifdef CONFIG_KALLSYMS
69504 +#if !defined(__INCLUDED_BY_HIDESYM) || !defined(CONFIG_KALLSYMS)
69505 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
69506 /* Lookup the address for a symbol. Returns 0 if not found. */
69507 unsigned long kallsyms_lookup_name(const char *name);
69508
69509 @@ -106,6 +107,17 @@ static inline int lookup_symbol_attrs(unsigned long addr, unsigned long *size, u
69510 /* Stupid that this does nothing, but I didn't create this mess. */
69511 #define __print_symbol(fmt, addr)
69512 #endif /*CONFIG_KALLSYMS*/
69513 +#else /* when included by kallsyms.c, vsnprintf.c, or
69514 + arch/x86/kernel/dumpstack.c, with HIDESYM enabled */
69515 +extern void __print_symbol(const char *fmt, unsigned long address);
69516 +extern int sprint_backtrace(char *buffer, unsigned long address);
69517 +extern int sprint_symbol(char *buffer, unsigned long address);
69518 +extern int sprint_symbol_no_offset(char *buffer, unsigned long address);
69519 +const char *kallsyms_lookup(unsigned long addr,
69520 + unsigned long *symbolsize,
69521 + unsigned long *offset,
69522 + char **modname, char *namebuf);
69523 +#endif
69524
69525 /* This macro allows us to keep printk typechecking */
69526 static __printf(1, 2)
69527 diff --git a/include/linux/key-type.h b/include/linux/key-type.h
69528 index 518a53a..5e28358 100644
69529 --- a/include/linux/key-type.h
69530 +++ b/include/linux/key-type.h
69531 @@ -125,7 +125,7 @@ struct key_type {
69532 /* internal fields */
69533 struct list_head link; /* link in types list */
69534 struct lock_class_key lock_class; /* key->sem lock class */
69535 -};
69536 +} __do_const;
69537
69538 extern struct key_type key_type_keyring;
69539
69540 diff --git a/include/linux/kgdb.h b/include/linux/kgdb.h
69541 index c6e091b..a940adf 100644
69542 --- a/include/linux/kgdb.h
69543 +++ b/include/linux/kgdb.h
69544 @@ -52,7 +52,7 @@ extern int kgdb_connected;
69545 extern int kgdb_io_module_registered;
69546
69547 extern atomic_t kgdb_setting_breakpoint;
69548 -extern atomic_t kgdb_cpu_doing_single_step;
69549 +extern atomic_unchecked_t kgdb_cpu_doing_single_step;
69550
69551 extern struct task_struct *kgdb_usethread;
69552 extern struct task_struct *kgdb_contthread;
69553 @@ -254,7 +254,7 @@ struct kgdb_arch {
69554 void (*correct_hw_break)(void);
69555
69556 void (*enable_nmi)(bool on);
69557 -};
69558 +} __do_const;
69559
69560 /**
69561 * struct kgdb_io - Describe the interface for an I/O driver to talk with KGDB.
69562 @@ -279,7 +279,7 @@ struct kgdb_io {
69563 void (*pre_exception) (void);
69564 void (*post_exception) (void);
69565 int is_console;
69566 -};
69567 +} __do_const;
69568
69569 extern struct kgdb_arch arch_kgdb_ops;
69570
69571 diff --git a/include/linux/kmod.h b/include/linux/kmod.h
69572 index 5398d58..5883a34 100644
69573 --- a/include/linux/kmod.h
69574 +++ b/include/linux/kmod.h
69575 @@ -34,6 +34,8 @@ extern char modprobe_path[]; /* for sysctl */
69576 * usually useless though. */
69577 extern __printf(2, 3)
69578 int __request_module(bool wait, const char *name, ...);
69579 +extern __printf(3, 4)
69580 +int ___request_module(bool wait, char *param_name, const char *name, ...);
69581 #define request_module(mod...) __request_module(true, mod)
69582 #define request_module_nowait(mod...) __request_module(false, mod)
69583 #define try_then_request_module(x, mod...) \
69584 diff --git a/include/linux/kobject.h b/include/linux/kobject.h
69585 index 939b112..ed6ed51 100644
69586 --- a/include/linux/kobject.h
69587 +++ b/include/linux/kobject.h
69588 @@ -111,7 +111,7 @@ struct kobj_type {
69589 struct attribute **default_attrs;
69590 const struct kobj_ns_type_operations *(*child_ns_type)(struct kobject *kobj);
69591 const void *(*namespace)(struct kobject *kobj);
69592 -};
69593 +} __do_const;
69594
69595 struct kobj_uevent_env {
69596 char *envp[UEVENT_NUM_ENVP];
69597 @@ -134,6 +134,7 @@ struct kobj_attribute {
69598 ssize_t (*store)(struct kobject *kobj, struct kobj_attribute *attr,
69599 const char *buf, size_t count);
69600 };
69601 +typedef struct kobj_attribute __no_const kobj_attribute_no_const;
69602
69603 extern const struct sysfs_ops kobj_sysfs_ops;
69604
69605 diff --git a/include/linux/kobject_ns.h b/include/linux/kobject_ns.h
69606 index f66b065..c2c29b4 100644
69607 --- a/include/linux/kobject_ns.h
69608 +++ b/include/linux/kobject_ns.h
69609 @@ -43,7 +43,7 @@ struct kobj_ns_type_operations {
69610 const void *(*netlink_ns)(struct sock *sk);
69611 const void *(*initial_ns)(void);
69612 void (*drop_ns)(void *);
69613 -};
69614 +} __do_const;
69615
69616 int kobj_ns_type_register(const struct kobj_ns_type_operations *ops);
69617 int kobj_ns_type_registered(enum kobj_ns_type type);
69618 diff --git a/include/linux/kref.h b/include/linux/kref.h
69619 index 7419c02..aa2f02d 100644
69620 --- a/include/linux/kref.h
69621 +++ b/include/linux/kref.h
69622 @@ -65,7 +65,7 @@ static inline void kref_get(struct kref *kref)
69623 static inline int kref_sub(struct kref *kref, unsigned int count,
69624 void (*release)(struct kref *kref))
69625 {
69626 - WARN_ON(release == NULL);
69627 + BUG_ON(release == NULL);
69628
69629 if (atomic_sub_and_test((int) count, &kref->refcount)) {
69630 release(kref);
69631 diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
69632 index c139582..0b5b102 100644
69633 --- a/include/linux/kvm_host.h
69634 +++ b/include/linux/kvm_host.h
69635 @@ -424,7 +424,7 @@ void kvm_vcpu_uninit(struct kvm_vcpu *vcpu);
69636 int __must_check vcpu_load(struct kvm_vcpu *vcpu);
69637 void vcpu_put(struct kvm_vcpu *vcpu);
69638
69639 -int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
69640 +int kvm_init(const void *opaque, unsigned vcpu_size, unsigned vcpu_align,
69641 struct module *module);
69642 void kvm_exit(void);
69643
69644 @@ -582,7 +582,7 @@ int kvm_arch_vcpu_ioctl_set_guest_debug(struct kvm_vcpu *vcpu,
69645 struct kvm_guest_debug *dbg);
69646 int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run);
69647
69648 -int kvm_arch_init(void *opaque);
69649 +int kvm_arch_init(const void *opaque);
69650 void kvm_arch_exit(void);
69651
69652 int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu);
69653 diff --git a/include/linux/libata.h b/include/linux/libata.h
69654 index eae7a05..2cdd875 100644
69655 --- a/include/linux/libata.h
69656 +++ b/include/linux/libata.h
69657 @@ -919,7 +919,7 @@ struct ata_port_operations {
69658 * fields must be pointers.
69659 */
69660 const struct ata_port_operations *inherits;
69661 -};
69662 +} __do_const;
69663
69664 struct ata_port_info {
69665 unsigned long flags;
69666 diff --git a/include/linux/list.h b/include/linux/list.h
69667 index 6a1f8df..eaec1ff 100644
69668 --- a/include/linux/list.h
69669 +++ b/include/linux/list.h
69670 @@ -112,6 +112,19 @@ extern void __list_del_entry(struct list_head *entry);
69671 extern void list_del(struct list_head *entry);
69672 #endif
69673
69674 +extern void __pax_list_add(struct list_head *new,
69675 + struct list_head *prev,
69676 + struct list_head *next);
69677 +static inline void pax_list_add(struct list_head *new, struct list_head *head)
69678 +{
69679 + __pax_list_add(new, head, head->next);
69680 +}
69681 +static inline void pax_list_add_tail(struct list_head *new, struct list_head *head)
69682 +{
69683 + __pax_list_add(new, head->prev, head);
69684 +}
69685 +extern void pax_list_del(struct list_head *entry);
69686 +
69687 /**
69688 * list_replace - replace old entry by new one
69689 * @old : the element to be replaced
69690 @@ -145,6 +158,8 @@ static inline void list_del_init(struct list_head *entry)
69691 INIT_LIST_HEAD(entry);
69692 }
69693
69694 +extern void pax_list_del_init(struct list_head *entry);
69695 +
69696 /**
69697 * list_move - delete from one list and add as another's head
69698 * @list: the entry to move
69699 diff --git a/include/linux/math64.h b/include/linux/math64.h
69700 index b8ba855..0148090 100644
69701 --- a/include/linux/math64.h
69702 +++ b/include/linux/math64.h
69703 @@ -14,7 +14,7 @@
69704 * This is commonly provided by 32bit archs to provide an optimized 64bit
69705 * divide.
69706 */
69707 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
69708 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
69709 {
69710 *remainder = dividend % divisor;
69711 return dividend / divisor;
69712 @@ -50,7 +50,7 @@ static inline s64 div64_s64(s64 dividend, s64 divisor)
69713 #define div64_long(x,y) div_s64((x),(y))
69714
69715 #ifndef div_u64_rem
69716 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
69717 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
69718 {
69719 *remainder = do_div(dividend, divisor);
69720 return dividend;
69721 @@ -79,7 +79,7 @@ extern s64 div64_s64(s64 dividend, s64 divisor);
69722 * divide.
69723 */
69724 #ifndef div_u64
69725 -static inline u64 div_u64(u64 dividend, u32 divisor)
69726 +static inline u64 __intentional_overflow(-1) div_u64(u64 dividend, u32 divisor)
69727 {
69728 u32 remainder;
69729 return div_u64_rem(dividend, divisor, &remainder);
69730 diff --git a/include/linux/mm.h b/include/linux/mm.h
69731 index e2091b8..821db54 100644
69732 --- a/include/linux/mm.h
69733 +++ b/include/linux/mm.h
69734 @@ -101,6 +101,11 @@ extern unsigned int kobjsize(const void *objp);
69735 #define VM_HUGETLB 0x00400000 /* Huge TLB Page VM */
69736 #define VM_NONLINEAR 0x00800000 /* Is non-linear (remap_file_pages) */
69737 #define VM_ARCH_1 0x01000000 /* Architecture-specific flag */
69738 +
69739 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
69740 +#define VM_PAGEEXEC 0x02000000 /* vma->vm_page_prot needs special handling */
69741 +#endif
69742 +
69743 #define VM_DONTDUMP 0x04000000 /* Do not include in the core dump */
69744
69745 #define VM_MIXEDMAP 0x10000000 /* Can contain "struct page" and pure PFN pages */
69746 @@ -202,8 +207,8 @@ struct vm_operations_struct {
69747 /* called by access_process_vm when get_user_pages() fails, typically
69748 * for use by special VMAs that can switch between memory and hardware
69749 */
69750 - int (*access)(struct vm_area_struct *vma, unsigned long addr,
69751 - void *buf, int len, int write);
69752 + ssize_t (*access)(struct vm_area_struct *vma, unsigned long addr,
69753 + void *buf, size_t len, int write);
69754 #ifdef CONFIG_NUMA
69755 /*
69756 * set_policy() op must add a reference to any non-NULL @new mempolicy
69757 @@ -233,6 +238,7 @@ struct vm_operations_struct {
69758 int (*remap_pages)(struct vm_area_struct *vma, unsigned long addr,
69759 unsigned long size, pgoff_t pgoff);
69760 };
69761 +typedef struct vm_operations_struct __no_const vm_operations_struct_no_const;
69762
69763 struct mmu_gather;
69764 struct inode;
69765 @@ -970,8 +976,8 @@ int follow_pfn(struct vm_area_struct *vma, unsigned long address,
69766 unsigned long *pfn);
69767 int follow_phys(struct vm_area_struct *vma, unsigned long address,
69768 unsigned int flags, unsigned long *prot, resource_size_t *phys);
69769 -int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
69770 - void *buf, int len, int write);
69771 +ssize_t generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
69772 + void *buf, size_t len, int write);
69773
69774 static inline void unmap_shared_mapping_range(struct address_space *mapping,
69775 loff_t const holebegin, loff_t const holelen)
69776 @@ -1010,9 +1016,9 @@ static inline int fixup_user_fault(struct task_struct *tsk,
69777 }
69778 #endif
69779
69780 -extern int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write);
69781 -extern int access_remote_vm(struct mm_struct *mm, unsigned long addr,
69782 - void *buf, int len, int write);
69783 +extern ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, size_t len, int write);
69784 +extern ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
69785 + void *buf, size_t len, int write);
69786
69787 long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
69788 unsigned long start, unsigned long nr_pages,
69789 @@ -1043,34 +1049,6 @@ int set_page_dirty(struct page *page);
69790 int set_page_dirty_lock(struct page *page);
69791 int clear_page_dirty_for_io(struct page *page);
69792
69793 -/* Is the vma a continuation of the stack vma above it? */
69794 -static inline int vma_growsdown(struct vm_area_struct *vma, unsigned long addr)
69795 -{
69796 - return vma && (vma->vm_end == addr) && (vma->vm_flags & VM_GROWSDOWN);
69797 -}
69798 -
69799 -static inline int stack_guard_page_start(struct vm_area_struct *vma,
69800 - unsigned long addr)
69801 -{
69802 - return (vma->vm_flags & VM_GROWSDOWN) &&
69803 - (vma->vm_start == addr) &&
69804 - !vma_growsdown(vma->vm_prev, addr);
69805 -}
69806 -
69807 -/* Is the vma a continuation of the stack vma below it? */
69808 -static inline int vma_growsup(struct vm_area_struct *vma, unsigned long addr)
69809 -{
69810 - return vma && (vma->vm_start == addr) && (vma->vm_flags & VM_GROWSUP);
69811 -}
69812 -
69813 -static inline int stack_guard_page_end(struct vm_area_struct *vma,
69814 - unsigned long addr)
69815 -{
69816 - return (vma->vm_flags & VM_GROWSUP) &&
69817 - (vma->vm_end == addr) &&
69818 - !vma_growsup(vma->vm_next, addr);
69819 -}
69820 -
69821 extern pid_t
69822 vm_is_stack(struct task_struct *task, struct vm_area_struct *vma, int in_group);
69823
69824 @@ -1173,6 +1151,15 @@ static inline void sync_mm_rss(struct mm_struct *mm)
69825 }
69826 #endif
69827
69828 +#ifdef CONFIG_MMU
69829 +pgprot_t vm_get_page_prot(vm_flags_t vm_flags);
69830 +#else
69831 +static inline pgprot_t vm_get_page_prot(vm_flags_t vm_flags)
69832 +{
69833 + return __pgprot(0);
69834 +}
69835 +#endif
69836 +
69837 int vma_wants_writenotify(struct vm_area_struct *vma);
69838
69839 extern pte_t *__get_locked_pte(struct mm_struct *mm, unsigned long addr,
69840 @@ -1191,8 +1178,15 @@ static inline int __pud_alloc(struct mm_struct *mm, pgd_t *pgd,
69841 {
69842 return 0;
69843 }
69844 +
69845 +static inline int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd,
69846 + unsigned long address)
69847 +{
69848 + return 0;
69849 +}
69850 #else
69851 int __pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address);
69852 +int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address);
69853 #endif
69854
69855 #ifdef __PAGETABLE_PMD_FOLDED
69856 @@ -1201,8 +1195,15 @@ static inline int __pmd_alloc(struct mm_struct *mm, pud_t *pud,
69857 {
69858 return 0;
69859 }
69860 +
69861 +static inline int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud,
69862 + unsigned long address)
69863 +{
69864 + return 0;
69865 +}
69866 #else
69867 int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address);
69868 +int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address);
69869 #endif
69870
69871 int __pte_alloc(struct mm_struct *mm, struct vm_area_struct *vma,
69872 @@ -1220,11 +1221,23 @@ static inline pud_t *pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long a
69873 NULL: pud_offset(pgd, address);
69874 }
69875
69876 +static inline pud_t *pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
69877 +{
69878 + return (unlikely(pgd_none(*pgd)) && __pud_alloc_kernel(mm, pgd, address))?
69879 + NULL: pud_offset(pgd, address);
69880 +}
69881 +
69882 static inline pmd_t *pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
69883 {
69884 return (unlikely(pud_none(*pud)) && __pmd_alloc(mm, pud, address))?
69885 NULL: pmd_offset(pud, address);
69886 }
69887 +
69888 +static inline pmd_t *pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address)
69889 +{
69890 + return (unlikely(pud_none(*pud)) && __pmd_alloc_kernel(mm, pud, address))?
69891 + NULL: pmd_offset(pud, address);
69892 +}
69893 #endif /* CONFIG_MMU && !__ARCH_HAS_4LEVEL_HACK */
69894
69895 #if USE_SPLIT_PTLOCKS
69896 @@ -1455,6 +1468,7 @@ extern unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
69897 unsigned long len, unsigned long prot, unsigned long flags,
69898 unsigned long pgoff, unsigned long *populate);
69899 extern int do_munmap(struct mm_struct *, unsigned long, size_t);
69900 +extern int __do_munmap(struct mm_struct *, unsigned long, size_t);
69901
69902 #ifdef CONFIG_MMU
69903 extern int __mm_populate(unsigned long addr, unsigned long len,
69904 @@ -1483,6 +1497,7 @@ struct vm_unmapped_area_info {
69905 unsigned long high_limit;
69906 unsigned long align_mask;
69907 unsigned long align_offset;
69908 + unsigned long threadstack_offset;
69909 };
69910
69911 extern unsigned long unmapped_area(struct vm_unmapped_area_info *info);
69912 @@ -1561,6 +1576,10 @@ extern struct vm_area_struct * find_vma(struct mm_struct * mm, unsigned long add
69913 extern struct vm_area_struct * find_vma_prev(struct mm_struct * mm, unsigned long addr,
69914 struct vm_area_struct **pprev);
69915
69916 +extern struct vm_area_struct *pax_find_mirror_vma(struct vm_area_struct *vma);
69917 +extern __must_check long pax_mirror_vma(struct vm_area_struct *vma_m, struct vm_area_struct *vma);
69918 +extern void pax_mirror_file_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl);
69919 +
69920 /* Look up the first VMA which intersects the interval start_addr..end_addr-1,
69921 NULL if none. Assume start_addr < end_addr. */
69922 static inline struct vm_area_struct * find_vma_intersection(struct mm_struct * mm, unsigned long start_addr, unsigned long end_addr)
69923 @@ -1589,15 +1608,6 @@ static inline struct vm_area_struct *find_exact_vma(struct mm_struct *mm,
69924 return vma;
69925 }
69926
69927 -#ifdef CONFIG_MMU
69928 -pgprot_t vm_get_page_prot(unsigned long vm_flags);
69929 -#else
69930 -static inline pgprot_t vm_get_page_prot(unsigned long vm_flags)
69931 -{
69932 - return __pgprot(0);
69933 -}
69934 -#endif
69935 -
69936 #ifdef CONFIG_ARCH_USES_NUMA_PROT_NONE
69937 unsigned long change_prot_numa(struct vm_area_struct *vma,
69938 unsigned long start, unsigned long end);
69939 @@ -1649,6 +1659,11 @@ void vm_stat_account(struct mm_struct *, unsigned long, struct file *, long);
69940 static inline void vm_stat_account(struct mm_struct *mm,
69941 unsigned long flags, struct file *file, long pages)
69942 {
69943 +
69944 +#ifdef CONFIG_PAX_RANDMMAP
69945 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
69946 +#endif
69947 +
69948 mm->total_vm += pages;
69949 }
69950 #endif /* CONFIG_PROC_FS */
69951 @@ -1725,7 +1740,7 @@ extern int unpoison_memory(unsigned long pfn);
69952 extern int sysctl_memory_failure_early_kill;
69953 extern int sysctl_memory_failure_recovery;
69954 extern void shake_page(struct page *p, int access);
69955 -extern atomic_long_t num_poisoned_pages;
69956 +extern atomic_long_unchecked_t num_poisoned_pages;
69957 extern int soft_offline_page(struct page *page, int flags);
69958
69959 extern void dump_page(struct page *page);
69960 @@ -1756,5 +1771,11 @@ static inline unsigned int debug_guardpage_minorder(void) { return 0; }
69961 static inline bool page_is_guard(struct page *page) { return false; }
69962 #endif /* CONFIG_DEBUG_PAGEALLOC */
69963
69964 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
69965 +extern void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot);
69966 +#else
69967 +static inline void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot) {}
69968 +#endif
69969 +
69970 #endif /* __KERNEL__ */
69971 #endif /* _LINUX_MM_H */
69972 diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
69973 index ace9a5f..81bdb59 100644
69974 --- a/include/linux/mm_types.h
69975 +++ b/include/linux/mm_types.h
69976 @@ -289,6 +289,8 @@ struct vm_area_struct {
69977 #ifdef CONFIG_NUMA
69978 struct mempolicy *vm_policy; /* NUMA policy for the VMA */
69979 #endif
69980 +
69981 + struct vm_area_struct *vm_mirror;/* PaX: mirror vma or NULL */
69982 };
69983
69984 struct core_thread {
69985 @@ -437,6 +439,24 @@ struct mm_struct {
69986 int first_nid;
69987 #endif
69988 struct uprobes_state uprobes_state;
69989 +
69990 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
69991 + unsigned long pax_flags;
69992 +#endif
69993 +
69994 +#ifdef CONFIG_PAX_DLRESOLVE
69995 + unsigned long call_dl_resolve;
69996 +#endif
69997 +
69998 +#if defined(CONFIG_PPC32) && defined(CONFIG_PAX_EMUSIGRT)
69999 + unsigned long call_syscall;
70000 +#endif
70001 +
70002 +#ifdef CONFIG_PAX_ASLR
70003 + unsigned long delta_mmap; /* randomized offset */
70004 + unsigned long delta_stack; /* randomized offset */
70005 +#endif
70006 +
70007 };
70008
70009 /* first nid will either be a valid NID or one of these values */
70010 diff --git a/include/linux/mmiotrace.h b/include/linux/mmiotrace.h
70011 index c5d5278..f0b68c8 100644
70012 --- a/include/linux/mmiotrace.h
70013 +++ b/include/linux/mmiotrace.h
70014 @@ -46,7 +46,7 @@ extern int kmmio_handler(struct pt_regs *regs, unsigned long addr);
70015 /* Called from ioremap.c */
70016 extern void mmiotrace_ioremap(resource_size_t offset, unsigned long size,
70017 void __iomem *addr);
70018 -extern void mmiotrace_iounmap(volatile void __iomem *addr);
70019 +extern void mmiotrace_iounmap(const volatile void __iomem *addr);
70020
70021 /* For anyone to insert markers. Remember trailing newline. */
70022 extern __printf(1, 2) int mmiotrace_printk(const char *fmt, ...);
70023 @@ -66,7 +66,7 @@ static inline void mmiotrace_ioremap(resource_size_t offset,
70024 {
70025 }
70026
70027 -static inline void mmiotrace_iounmap(volatile void __iomem *addr)
70028 +static inline void mmiotrace_iounmap(const volatile void __iomem *addr)
70029 {
70030 }
70031
70032 diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
70033 index c74092e..b663967 100644
70034 --- a/include/linux/mmzone.h
70035 +++ b/include/linux/mmzone.h
70036 @@ -396,7 +396,7 @@ struct zone {
70037 unsigned long flags; /* zone flags, see below */
70038
70039 /* Zone statistics */
70040 - atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
70041 + atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
70042
70043 /*
70044 * The target ratio of ACTIVE_ANON to INACTIVE_ANON pages on
70045 diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
70046 index 779cf7c..e6768240 100644
70047 --- a/include/linux/mod_devicetable.h
70048 +++ b/include/linux/mod_devicetable.h
70049 @@ -12,7 +12,7 @@
70050 typedef unsigned long kernel_ulong_t;
70051 #endif
70052
70053 -#define PCI_ANY_ID (~0)
70054 +#define PCI_ANY_ID ((__u16)~0)
70055
70056 struct pci_device_id {
70057 __u32 vendor, device; /* Vendor and device ID or PCI_ANY_ID*/
70058 @@ -138,7 +138,7 @@ struct usb_device_id {
70059 #define USB_DEVICE_ID_MATCH_INT_PROTOCOL 0x0200
70060 #define USB_DEVICE_ID_MATCH_INT_NUMBER 0x0400
70061
70062 -#define HID_ANY_ID (~0)
70063 +#define HID_ANY_ID (~0U)
70064 #define HID_BUS_ANY 0xffff
70065 #define HID_GROUP_ANY 0x0000
70066
70067 @@ -464,7 +464,7 @@ struct dmi_system_id {
70068 const char *ident;
70069 struct dmi_strmatch matches[4];
70070 void *driver_data;
70071 -};
70072 +} __do_const;
70073 /*
70074 * struct dmi_device_id appears during expansion of
70075 * "MODULE_DEVICE_TABLE(dmi, x)". Compiler doesn't look inside it
70076 diff --git a/include/linux/module.h b/include/linux/module.h
70077 index ead1b57..81a3b6c 100644
70078 --- a/include/linux/module.h
70079 +++ b/include/linux/module.h
70080 @@ -17,9 +17,11 @@
70081 #include <linux/moduleparam.h>
70082 #include <linux/tracepoint.h>
70083 #include <linux/export.h>
70084 +#include <linux/fs.h>
70085
70086 #include <linux/percpu.h>
70087 #include <asm/module.h>
70088 +#include <asm/pgtable.h>
70089
70090 /* In stripped ARM and x86-64 modules, ~ is surprisingly rare. */
70091 #define MODULE_SIG_STRING "~Module signature appended~\n"
70092 @@ -54,12 +56,13 @@ struct module_attribute {
70093 int (*test)(struct module *);
70094 void (*free)(struct module *);
70095 };
70096 +typedef struct module_attribute __no_const module_attribute_no_const;
70097
70098 struct module_version_attribute {
70099 struct module_attribute mattr;
70100 const char *module_name;
70101 const char *version;
70102 -} __attribute__ ((__aligned__(sizeof(void *))));
70103 +} __do_const __attribute__ ((__aligned__(sizeof(void *))));
70104
70105 extern ssize_t __modver_version_show(struct module_attribute *,
70106 struct module_kobject *, char *);
70107 @@ -232,7 +235,7 @@ struct module
70108
70109 /* Sysfs stuff. */
70110 struct module_kobject mkobj;
70111 - struct module_attribute *modinfo_attrs;
70112 + module_attribute_no_const *modinfo_attrs;
70113 const char *version;
70114 const char *srcversion;
70115 struct kobject *holders_dir;
70116 @@ -281,19 +284,16 @@ struct module
70117 int (*init)(void);
70118
70119 /* If this is non-NULL, vfree after init() returns */
70120 - void *module_init;
70121 + void *module_init_rx, *module_init_rw;
70122
70123 /* Here is the actual code + data, vfree'd on unload. */
70124 - void *module_core;
70125 + void *module_core_rx, *module_core_rw;
70126
70127 /* Here are the sizes of the init and core sections */
70128 - unsigned int init_size, core_size;
70129 + unsigned int init_size_rw, core_size_rw;
70130
70131 /* The size of the executable code in each section. */
70132 - unsigned int init_text_size, core_text_size;
70133 -
70134 - /* Size of RO sections of the module (text+rodata) */
70135 - unsigned int init_ro_size, core_ro_size;
70136 + unsigned int init_size_rx, core_size_rx;
70137
70138 /* Arch-specific module values */
70139 struct mod_arch_specific arch;
70140 @@ -349,6 +349,10 @@ struct module
70141 #ifdef CONFIG_EVENT_TRACING
70142 struct ftrace_event_call **trace_events;
70143 unsigned int num_trace_events;
70144 + struct file_operations trace_id;
70145 + struct file_operations trace_enable;
70146 + struct file_operations trace_format;
70147 + struct file_operations trace_filter;
70148 #endif
70149 #ifdef CONFIG_FTRACE_MCOUNT_RECORD
70150 unsigned int num_ftrace_callsites;
70151 @@ -396,16 +400,46 @@ bool is_module_address(unsigned long addr);
70152 bool is_module_percpu_address(unsigned long addr);
70153 bool is_module_text_address(unsigned long addr);
70154
70155 +static inline int within_module_range(unsigned long addr, void *start, unsigned long size)
70156 +{
70157 +
70158 +#ifdef CONFIG_PAX_KERNEXEC
70159 + if (ktla_ktva(addr) >= (unsigned long)start &&
70160 + ktla_ktva(addr) < (unsigned long)start + size)
70161 + return 1;
70162 +#endif
70163 +
70164 + return ((void *)addr >= start && (void *)addr < start + size);
70165 +}
70166 +
70167 +static inline int within_module_core_rx(unsigned long addr, const struct module *mod)
70168 +{
70169 + return within_module_range(addr, mod->module_core_rx, mod->core_size_rx);
70170 +}
70171 +
70172 +static inline int within_module_core_rw(unsigned long addr, const struct module *mod)
70173 +{
70174 + return within_module_range(addr, mod->module_core_rw, mod->core_size_rw);
70175 +}
70176 +
70177 +static inline int within_module_init_rx(unsigned long addr, const struct module *mod)
70178 +{
70179 + return within_module_range(addr, mod->module_init_rx, mod->init_size_rx);
70180 +}
70181 +
70182 +static inline int within_module_init_rw(unsigned long addr, const struct module *mod)
70183 +{
70184 + return within_module_range(addr, mod->module_init_rw, mod->init_size_rw);
70185 +}
70186 +
70187 static inline int within_module_core(unsigned long addr, const struct module *mod)
70188 {
70189 - return (unsigned long)mod->module_core <= addr &&
70190 - addr < (unsigned long)mod->module_core + mod->core_size;
70191 + return within_module_core_rx(addr, mod) || within_module_core_rw(addr, mod);
70192 }
70193
70194 static inline int within_module_init(unsigned long addr, const struct module *mod)
70195 {
70196 - return (unsigned long)mod->module_init <= addr &&
70197 - addr < (unsigned long)mod->module_init + mod->init_size;
70198 + return within_module_init_rx(addr, mod) || within_module_init_rw(addr, mod);
70199 }
70200
70201 /* Search for module by name: must hold module_mutex. */
70202 diff --git a/include/linux/moduleloader.h b/include/linux/moduleloader.h
70203 index 560ca53..ef621ef 100644
70204 --- a/include/linux/moduleloader.h
70205 +++ b/include/linux/moduleloader.h
70206 @@ -25,9 +25,21 @@ unsigned int arch_mod_section_prepend(struct module *mod, unsigned int section);
70207 sections. Returns NULL on failure. */
70208 void *module_alloc(unsigned long size);
70209
70210 +#ifdef CONFIG_PAX_KERNEXEC
70211 +void *module_alloc_exec(unsigned long size);
70212 +#else
70213 +#define module_alloc_exec(x) module_alloc(x)
70214 +#endif
70215 +
70216 /* Free memory returned from module_alloc. */
70217 void module_free(struct module *mod, void *module_region);
70218
70219 +#ifdef CONFIG_PAX_KERNEXEC
70220 +void module_free_exec(struct module *mod, void *module_region);
70221 +#else
70222 +#define module_free_exec(x, y) module_free((x), (y))
70223 +#endif
70224 +
70225 /*
70226 * Apply the given relocation to the (simplified) ELF. Return -error
70227 * or 0.
70228 @@ -45,7 +57,9 @@ static inline int apply_relocate(Elf_Shdr *sechdrs,
70229 unsigned int relsec,
70230 struct module *me)
70231 {
70232 +#ifdef CONFIG_MODULES
70233 printk(KERN_ERR "module %s: REL relocation unsupported\n", me->name);
70234 +#endif
70235 return -ENOEXEC;
70236 }
70237 #endif
70238 @@ -67,7 +81,9 @@ static inline int apply_relocate_add(Elf_Shdr *sechdrs,
70239 unsigned int relsec,
70240 struct module *me)
70241 {
70242 +#ifdef CONFIG_MODULES
70243 printk(KERN_ERR "module %s: REL relocation unsupported\n", me->name);
70244 +#endif
70245 return -ENOEXEC;
70246 }
70247 #endif
70248 diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h
70249 index 137b419..fe663ec 100644
70250 --- a/include/linux/moduleparam.h
70251 +++ b/include/linux/moduleparam.h
70252 @@ -284,7 +284,7 @@ static inline void __kernel_param_unlock(void)
70253 * @len is usually just sizeof(string).
70254 */
70255 #define module_param_string(name, string, len, perm) \
70256 - static const struct kparam_string __param_string_##name \
70257 + static const struct kparam_string __param_string_##name __used \
70258 = { len, string }; \
70259 __module_param_call(MODULE_PARAM_PREFIX, name, \
70260 &param_ops_string, \
70261 @@ -423,7 +423,7 @@ extern int param_set_bint(const char *val, const struct kernel_param *kp);
70262 */
70263 #define module_param_array_named(name, array, type, nump, perm) \
70264 param_check_##type(name, &(array)[0]); \
70265 - static const struct kparam_array __param_arr_##name \
70266 + static const struct kparam_array __param_arr_##name __used \
70267 = { .max = ARRAY_SIZE(array), .num = nump, \
70268 .ops = &param_ops_##type, \
70269 .elemsize = sizeof(array[0]), .elem = array }; \
70270 diff --git a/include/linux/namei.h b/include/linux/namei.h
70271 index 5a5ff57..5ae5070 100644
70272 --- a/include/linux/namei.h
70273 +++ b/include/linux/namei.h
70274 @@ -19,7 +19,7 @@ struct nameidata {
70275 unsigned seq;
70276 int last_type;
70277 unsigned depth;
70278 - char *saved_names[MAX_NESTED_LINKS + 1];
70279 + const char *saved_names[MAX_NESTED_LINKS + 1];
70280 };
70281
70282 /*
70283 @@ -84,12 +84,12 @@ extern void unlock_rename(struct dentry *, struct dentry *);
70284
70285 extern void nd_jump_link(struct nameidata *nd, struct path *path);
70286
70287 -static inline void nd_set_link(struct nameidata *nd, char *path)
70288 +static inline void nd_set_link(struct nameidata *nd, const char *path)
70289 {
70290 nd->saved_names[nd->depth] = path;
70291 }
70292
70293 -static inline char *nd_get_link(struct nameidata *nd)
70294 +static inline const char *nd_get_link(const struct nameidata *nd)
70295 {
70296 return nd->saved_names[nd->depth];
70297 }
70298 diff --git a/include/linux/net.h b/include/linux/net.h
70299 index aa16731..514b875 100644
70300 --- a/include/linux/net.h
70301 +++ b/include/linux/net.h
70302 @@ -183,7 +183,7 @@ struct net_proto_family {
70303 int (*create)(struct net *net, struct socket *sock,
70304 int protocol, int kern);
70305 struct module *owner;
70306 -};
70307 +} __do_const;
70308
70309 struct iovec;
70310 struct kvec;
70311 diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
70312 index 6151e90..2e0afb0 100644
70313 --- a/include/linux/netdevice.h
70314 +++ b/include/linux/netdevice.h
70315 @@ -1028,6 +1028,7 @@ struct net_device_ops {
70316 int (*ndo_change_carrier)(struct net_device *dev,
70317 bool new_carrier);
70318 };
70319 +typedef struct net_device_ops __no_const net_device_ops_no_const;
70320
70321 /*
70322 * The DEVICE structure.
70323 @@ -1094,7 +1095,7 @@ struct net_device {
70324 int iflink;
70325
70326 struct net_device_stats stats;
70327 - atomic_long_t rx_dropped; /* dropped packets by core network
70328 + atomic_long_unchecked_t rx_dropped; /* dropped packets by core network
70329 * Do not use this in drivers.
70330 */
70331
70332 diff --git a/include/linux/netfilter.h b/include/linux/netfilter.h
70333 index ee14284..bc65d63 100644
70334 --- a/include/linux/netfilter.h
70335 +++ b/include/linux/netfilter.h
70336 @@ -82,7 +82,7 @@ struct nf_sockopt_ops {
70337 #endif
70338 /* Use the module struct to lock set/get code in place */
70339 struct module *owner;
70340 -};
70341 +} __do_const;
70342
70343 /* Function to register/unregister hook points. */
70344 int nf_register_hook(struct nf_hook_ops *reg);
70345 diff --git a/include/linux/netfilter/ipset/ip_set.h b/include/linux/netfilter/ipset/ip_set.h
70346 index 7958e84..ed74d7a 100644
70347 --- a/include/linux/netfilter/ipset/ip_set.h
70348 +++ b/include/linux/netfilter/ipset/ip_set.h
70349 @@ -98,7 +98,7 @@ struct ip_set_type_variant {
70350 /* Return true if "b" set is the same as "a"
70351 * according to the create set parameters */
70352 bool (*same_set)(const struct ip_set *a, const struct ip_set *b);
70353 -};
70354 +} __do_const;
70355
70356 /* The core set type structure */
70357 struct ip_set_type {
70358 diff --git a/include/linux/netfilter/nfnetlink.h b/include/linux/netfilter/nfnetlink.h
70359 index ecbb8e4..8a1c4e1 100644
70360 --- a/include/linux/netfilter/nfnetlink.h
70361 +++ b/include/linux/netfilter/nfnetlink.h
70362 @@ -16,7 +16,7 @@ struct nfnl_callback {
70363 const struct nlattr * const cda[]);
70364 const struct nla_policy *policy; /* netlink attribute policy */
70365 const u_int16_t attr_count; /* number of nlattr's */
70366 -};
70367 +} __do_const;
70368
70369 struct nfnetlink_subsystem {
70370 const char *name;
70371 diff --git a/include/linux/netfilter/xt_gradm.h b/include/linux/netfilter/xt_gradm.h
70372 new file mode 100644
70373 index 0000000..33f4af8
70374 --- /dev/null
70375 +++ b/include/linux/netfilter/xt_gradm.h
70376 @@ -0,0 +1,9 @@
70377 +#ifndef _LINUX_NETFILTER_XT_GRADM_H
70378 +#define _LINUX_NETFILTER_XT_GRADM_H 1
70379 +
70380 +struct xt_gradm_mtinfo {
70381 + __u16 flags;
70382 + __u16 invflags;
70383 +};
70384 +
70385 +#endif
70386 diff --git a/include/linux/nls.h b/include/linux/nls.h
70387 index 5dc635f..35f5e11 100644
70388 --- a/include/linux/nls.h
70389 +++ b/include/linux/nls.h
70390 @@ -31,7 +31,7 @@ struct nls_table {
70391 const unsigned char *charset2upper;
70392 struct module *owner;
70393 struct nls_table *next;
70394 -};
70395 +} __do_const;
70396
70397 /* this value hold the maximum octet of charset */
70398 #define NLS_MAX_CHARSET_SIZE 6 /* for UTF-8 */
70399 diff --git a/include/linux/notifier.h b/include/linux/notifier.h
70400 index d65746e..62e72c2 100644
70401 --- a/include/linux/notifier.h
70402 +++ b/include/linux/notifier.h
70403 @@ -51,7 +51,8 @@ struct notifier_block {
70404 int (*notifier_call)(struct notifier_block *, unsigned long, void *);
70405 struct notifier_block __rcu *next;
70406 int priority;
70407 -};
70408 +} __do_const;
70409 +typedef struct notifier_block __no_const notifier_block_no_const;
70410
70411 struct atomic_notifier_head {
70412 spinlock_t lock;
70413 diff --git a/include/linux/oprofile.h b/include/linux/oprofile.h
70414 index a4c5624..79d6d88 100644
70415 --- a/include/linux/oprofile.h
70416 +++ b/include/linux/oprofile.h
70417 @@ -139,9 +139,9 @@ int oprofilefs_create_ulong(struct super_block * sb, struct dentry * root,
70418 int oprofilefs_create_ro_ulong(struct super_block * sb, struct dentry * root,
70419 char const * name, ulong * val);
70420
70421 -/** Create a file for read-only access to an atomic_t. */
70422 +/** Create a file for read-only access to an atomic_unchecked_t. */
70423 int oprofilefs_create_ro_atomic(struct super_block * sb, struct dentry * root,
70424 - char const * name, atomic_t * val);
70425 + char const * name, atomic_unchecked_t * val);
70426
70427 /** create a directory */
70428 struct dentry * oprofilefs_mkdir(struct super_block * sb, struct dentry * root,
70429 diff --git a/include/linux/pci_hotplug.h b/include/linux/pci_hotplug.h
70430 index 45fc162..01a4068 100644
70431 --- a/include/linux/pci_hotplug.h
70432 +++ b/include/linux/pci_hotplug.h
70433 @@ -80,7 +80,8 @@ struct hotplug_slot_ops {
70434 int (*get_attention_status) (struct hotplug_slot *slot, u8 *value);
70435 int (*get_latch_status) (struct hotplug_slot *slot, u8 *value);
70436 int (*get_adapter_status) (struct hotplug_slot *slot, u8 *value);
70437 -};
70438 +} __do_const;
70439 +typedef struct hotplug_slot_ops __no_const hotplug_slot_ops_no_const;
70440
70441 /**
70442 * struct hotplug_slot_info - used to notify the hotplug pci core of the state of the slot
70443 diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
70444 index 1d795df..727aa7b 100644
70445 --- a/include/linux/perf_event.h
70446 +++ b/include/linux/perf_event.h
70447 @@ -333,8 +333,8 @@ struct perf_event {
70448
70449 enum perf_event_active_state state;
70450 unsigned int attach_state;
70451 - local64_t count;
70452 - atomic64_t child_count;
70453 + local64_t count; /* PaX: fix it one day */
70454 + atomic64_unchecked_t child_count;
70455
70456 /*
70457 * These are the total time in nanoseconds that the event
70458 @@ -385,8 +385,8 @@ struct perf_event {
70459 * These accumulate total time (in nanoseconds) that children
70460 * events have been enabled and running, respectively.
70461 */
70462 - atomic64_t child_total_time_enabled;
70463 - atomic64_t child_total_time_running;
70464 + atomic64_unchecked_t child_total_time_enabled;
70465 + atomic64_unchecked_t child_total_time_running;
70466
70467 /*
70468 * Protect attach/detach and child_list:
70469 @@ -704,7 +704,7 @@ static inline void perf_callchain_store(struct perf_callchain_entry *entry, u64
70470 entry->ip[entry->nr++] = ip;
70471 }
70472
70473 -extern int sysctl_perf_event_paranoid;
70474 +extern int sysctl_perf_event_legitimately_concerned;
70475 extern int sysctl_perf_event_mlock;
70476 extern int sysctl_perf_event_sample_rate;
70477
70478 @@ -714,17 +714,17 @@ extern int perf_proc_update_handler(struct ctl_table *table, int write,
70479
70480 static inline bool perf_paranoid_tracepoint_raw(void)
70481 {
70482 - return sysctl_perf_event_paranoid > -1;
70483 + return sysctl_perf_event_legitimately_concerned > -1;
70484 }
70485
70486 static inline bool perf_paranoid_cpu(void)
70487 {
70488 - return sysctl_perf_event_paranoid > 0;
70489 + return sysctl_perf_event_legitimately_concerned > 0;
70490 }
70491
70492 static inline bool perf_paranoid_kernel(void)
70493 {
70494 - return sysctl_perf_event_paranoid > 1;
70495 + return sysctl_perf_event_legitimately_concerned > 1;
70496 }
70497
70498 extern void perf_event_init(void);
70499 @@ -812,7 +812,7 @@ static inline void perf_restore_debug_store(void) { }
70500 */
70501 #define perf_cpu_notifier(fn) \
70502 do { \
70503 - static struct notifier_block fn##_nb __cpuinitdata = \
70504 + static struct notifier_block fn##_nb = \
70505 { .notifier_call = fn, .priority = CPU_PRI_PERF }; \
70506 unsigned long cpu = smp_processor_id(); \
70507 unsigned long flags; \
70508 @@ -831,7 +831,7 @@ do { \
70509 struct perf_pmu_events_attr {
70510 struct device_attribute attr;
70511 u64 id;
70512 -};
70513 +} __do_const;
70514
70515 #define PMU_EVENT_ATTR(_name, _var, _id, _show) \
70516 static struct perf_pmu_events_attr _var = { \
70517 diff --git a/include/linux/pipe_fs_i.h b/include/linux/pipe_fs_i.h
70518 index ad1a427..6419649 100644
70519 --- a/include/linux/pipe_fs_i.h
70520 +++ b/include/linux/pipe_fs_i.h
70521 @@ -45,9 +45,9 @@ struct pipe_buffer {
70522 struct pipe_inode_info {
70523 wait_queue_head_t wait;
70524 unsigned int nrbufs, curbuf, buffers;
70525 - unsigned int readers;
70526 - unsigned int writers;
70527 - unsigned int waiting_writers;
70528 + atomic_t readers;
70529 + atomic_t writers;
70530 + atomic_t waiting_writers;
70531 unsigned int r_counter;
70532 unsigned int w_counter;
70533 struct page *tmp_page;
70534 diff --git a/include/linux/platform_data/usb-ehci-s5p.h b/include/linux/platform_data/usb-ehci-s5p.h
70535 index 5f28cae..3d23723 100644
70536 --- a/include/linux/platform_data/usb-ehci-s5p.h
70537 +++ b/include/linux/platform_data/usb-ehci-s5p.h
70538 @@ -14,7 +14,7 @@
70539 struct s5p_ehci_platdata {
70540 int (*phy_init)(struct platform_device *pdev, int type);
70541 int (*phy_exit)(struct platform_device *pdev, int type);
70542 -};
70543 +} __no_const;
70544
70545 extern void s5p_ehci_set_platdata(struct s5p_ehci_platdata *pd);
70546
70547 diff --git a/include/linux/platform_data/usb-exynos.h b/include/linux/platform_data/usb-exynos.h
70548 index c256c59..8ea94c7 100644
70549 --- a/include/linux/platform_data/usb-exynos.h
70550 +++ b/include/linux/platform_data/usb-exynos.h
70551 @@ -14,7 +14,7 @@
70552 struct exynos4_ohci_platdata {
70553 int (*phy_init)(struct platform_device *pdev, int type);
70554 int (*phy_exit)(struct platform_device *pdev, int type);
70555 -};
70556 +} __no_const;
70557
70558 extern void exynos4_ohci_set_platdata(struct exynos4_ohci_platdata *pd);
70559
70560 diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h
70561 index 7c1d252..c5c773e 100644
70562 --- a/include/linux/pm_domain.h
70563 +++ b/include/linux/pm_domain.h
70564 @@ -48,7 +48,7 @@ struct gpd_dev_ops {
70565
70566 struct gpd_cpu_data {
70567 unsigned int saved_exit_latency;
70568 - struct cpuidle_state *idle_state;
70569 + cpuidle_state_no_const *idle_state;
70570 };
70571
70572 struct generic_pm_domain {
70573 diff --git a/include/linux/pm_runtime.h b/include/linux/pm_runtime.h
70574 index 7d7e09e..8671ef8 100644
70575 --- a/include/linux/pm_runtime.h
70576 +++ b/include/linux/pm_runtime.h
70577 @@ -104,7 +104,7 @@ static inline bool pm_runtime_callbacks_present(struct device *dev)
70578
70579 static inline void pm_runtime_mark_last_busy(struct device *dev)
70580 {
70581 - ACCESS_ONCE(dev->power.last_busy) = jiffies;
70582 + ACCESS_ONCE_RW(dev->power.last_busy) = jiffies;
70583 }
70584
70585 #else /* !CONFIG_PM_RUNTIME */
70586 diff --git a/include/linux/pnp.h b/include/linux/pnp.h
70587 index 195aafc..49a7bc2 100644
70588 --- a/include/linux/pnp.h
70589 +++ b/include/linux/pnp.h
70590 @@ -297,7 +297,7 @@ static inline void pnp_set_drvdata(struct pnp_dev *pdev, void *data)
70591 struct pnp_fixup {
70592 char id[7];
70593 void (*quirk_function) (struct pnp_dev * dev); /* fixup function */
70594 -};
70595 +} __do_const;
70596
70597 /* config parameters */
70598 #define PNP_CONFIG_NORMAL 0x0001
70599 diff --git a/include/linux/poison.h b/include/linux/poison.h
70600 index 2110a81..13a11bb 100644
70601 --- a/include/linux/poison.h
70602 +++ b/include/linux/poison.h
70603 @@ -19,8 +19,8 @@
70604 * under normal circumstances, used to verify that nobody uses
70605 * non-initialized list entries.
70606 */
70607 -#define LIST_POISON1 ((void *) 0x00100100 + POISON_POINTER_DELTA)
70608 -#define LIST_POISON2 ((void *) 0x00200200 + POISON_POINTER_DELTA)
70609 +#define LIST_POISON1 ((void *) (long)0xFFFFFF01)
70610 +#define LIST_POISON2 ((void *) (long)0xFFFFFF02)
70611
70612 /********** include/linux/timer.h **********/
70613 /*
70614 diff --git a/include/linux/power/smartreflex.h b/include/linux/power/smartreflex.h
70615 index c0f44c2..1572583 100644
70616 --- a/include/linux/power/smartreflex.h
70617 +++ b/include/linux/power/smartreflex.h
70618 @@ -238,7 +238,7 @@ struct omap_sr_class_data {
70619 int (*notify)(struct omap_sr *sr, u32 status);
70620 u8 notify_flags;
70621 u8 class_type;
70622 -};
70623 +} __do_const;
70624
70625 /**
70626 * struct omap_sr_nvalue_table - Smartreflex n-target value info
70627 diff --git a/include/linux/ppp-comp.h b/include/linux/ppp-comp.h
70628 index 4ea1d37..80f4b33 100644
70629 --- a/include/linux/ppp-comp.h
70630 +++ b/include/linux/ppp-comp.h
70631 @@ -84,7 +84,7 @@ struct compressor {
70632 struct module *owner;
70633 /* Extra skb space needed by the compressor algorithm */
70634 unsigned int comp_extra;
70635 -};
70636 +} __do_const;
70637
70638 /*
70639 * The return value from decompress routine is the length of the
70640 diff --git a/include/linux/printk.h b/include/linux/printk.h
70641 index 822171f..12b30e8 100644
70642 --- a/include/linux/printk.h
70643 +++ b/include/linux/printk.h
70644 @@ -98,6 +98,8 @@ int no_printk(const char *fmt, ...)
70645 extern asmlinkage __printf(1, 2)
70646 void early_printk(const char *fmt, ...);
70647
70648 +extern int kptr_restrict;
70649 +
70650 #ifdef CONFIG_PRINTK
70651 asmlinkage __printf(5, 0)
70652 int vprintk_emit(int facility, int level,
70653 @@ -132,7 +134,6 @@ extern bool printk_timed_ratelimit(unsigned long *caller_jiffies,
70654
70655 extern int printk_delay_msec;
70656 extern int dmesg_restrict;
70657 -extern int kptr_restrict;
70658
70659 extern void wake_up_klogd(void);
70660
70661 diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h
70662 index 94dfb2a..88b9d3b 100644
70663 --- a/include/linux/proc_fs.h
70664 +++ b/include/linux/proc_fs.h
70665 @@ -165,6 +165,18 @@ static inline struct proc_dir_entry *proc_create(const char *name, umode_t mode,
70666 return proc_create_data(name, mode, parent, proc_fops, NULL);
70667 }
70668
70669 +static inline struct proc_dir_entry *proc_create_grsec(const char *name, umode_t mode,
70670 + struct proc_dir_entry *parent, const struct file_operations *proc_fops)
70671 +{
70672 +#ifdef CONFIG_GRKERNSEC_PROC_USER
70673 + return proc_create_data(name, S_IRUSR, parent, proc_fops, NULL);
70674 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
70675 + return proc_create_data(name, S_IRUSR | S_IRGRP, parent, proc_fops, NULL);
70676 +#else
70677 + return proc_create_data(name, mode, parent, proc_fops, NULL);
70678 +#endif
70679 +}
70680 +
70681 static inline struct proc_dir_entry *create_proc_read_entry(const char *name,
70682 umode_t mode, struct proc_dir_entry *base,
70683 read_proc_t *read_proc, void * data)
70684 @@ -266,7 +278,7 @@ struct proc_ns_operations {
70685 void (*put)(void *ns);
70686 int (*install)(struct nsproxy *nsproxy, void *ns);
70687 unsigned int (*inum)(void *ns);
70688 -};
70689 +} __do_const;
70690 extern const struct proc_ns_operations netns_operations;
70691 extern const struct proc_ns_operations utsns_operations;
70692 extern const struct proc_ns_operations ipcns_operations;
70693 diff --git a/include/linux/random.h b/include/linux/random.h
70694 index 347ce55..880f97c 100644
70695 --- a/include/linux/random.h
70696 +++ b/include/linux/random.h
70697 @@ -39,6 +39,11 @@ void prandom_seed(u32 seed);
70698 u32 prandom_u32_state(struct rnd_state *);
70699 void prandom_bytes_state(struct rnd_state *state, void *buf, int nbytes);
70700
70701 +static inline unsigned long pax_get_random_long(void)
70702 +{
70703 + return prandom_u32() + (sizeof(long) > 4 ? (unsigned long)prandom_u32() << 32 : 0);
70704 +}
70705 +
70706 /*
70707 * Handle minimum values for seeds
70708 */
70709 diff --git a/include/linux/rculist.h b/include/linux/rculist.h
70710 index 8089e35..3a0d59a 100644
70711 --- a/include/linux/rculist.h
70712 +++ b/include/linux/rculist.h
70713 @@ -44,6 +44,9 @@ extern void __list_add_rcu(struct list_head *new,
70714 struct list_head *prev, struct list_head *next);
70715 #endif
70716
70717 +extern void __pax_list_add_rcu(struct list_head *new,
70718 + struct list_head *prev, struct list_head *next);
70719 +
70720 /**
70721 * list_add_rcu - add a new entry to rcu-protected list
70722 * @new: new entry to be added
70723 @@ -65,6 +68,11 @@ static inline void list_add_rcu(struct list_head *new, struct list_head *head)
70724 __list_add_rcu(new, head, head->next);
70725 }
70726
70727 +static inline void pax_list_add_rcu(struct list_head *new, struct list_head *head)
70728 +{
70729 + __pax_list_add_rcu(new, head, head->next);
70730 +}
70731 +
70732 /**
70733 * list_add_tail_rcu - add a new entry to rcu-protected list
70734 * @new: new entry to be added
70735 @@ -87,6 +95,12 @@ static inline void list_add_tail_rcu(struct list_head *new,
70736 __list_add_rcu(new, head->prev, head);
70737 }
70738
70739 +static inline void pax_list_add_tail_rcu(struct list_head *new,
70740 + struct list_head *head)
70741 +{
70742 + __pax_list_add_rcu(new, head->prev, head);
70743 +}
70744 +
70745 /**
70746 * list_del_rcu - deletes entry from list without re-initialization
70747 * @entry: the element to delete from the list.
70748 @@ -117,6 +131,8 @@ static inline void list_del_rcu(struct list_head *entry)
70749 entry->prev = LIST_POISON2;
70750 }
70751
70752 +extern void pax_list_del_rcu(struct list_head *entry);
70753 +
70754 /**
70755 * hlist_del_init_rcu - deletes entry from hash list with re-initialization
70756 * @n: the element to delete from the hash list.
70757 diff --git a/include/linux/reboot.h b/include/linux/reboot.h
70758 index 23b3630..e1bc12b 100644
70759 --- a/include/linux/reboot.h
70760 +++ b/include/linux/reboot.h
70761 @@ -18,9 +18,9 @@ extern int unregister_reboot_notifier(struct notifier_block *);
70762 * Architecture-specific implementations of sys_reboot commands.
70763 */
70764
70765 -extern void machine_restart(char *cmd);
70766 -extern void machine_halt(void);
70767 -extern void machine_power_off(void);
70768 +extern void machine_restart(char *cmd) __noreturn;
70769 +extern void machine_halt(void) __noreturn;
70770 +extern void machine_power_off(void) __noreturn;
70771
70772 extern void machine_shutdown(void);
70773 struct pt_regs;
70774 @@ -31,9 +31,9 @@ extern void machine_crash_shutdown(struct pt_regs *);
70775 */
70776
70777 extern void kernel_restart_prepare(char *cmd);
70778 -extern void kernel_restart(char *cmd);
70779 -extern void kernel_halt(void);
70780 -extern void kernel_power_off(void);
70781 +extern void kernel_restart(char *cmd) __noreturn;
70782 +extern void kernel_halt(void) __noreturn;
70783 +extern void kernel_power_off(void) __noreturn;
70784
70785 extern int C_A_D; /* for sysctl */
70786 void ctrl_alt_del(void);
70787 @@ -47,7 +47,7 @@ extern int orderly_poweroff(bool force);
70788 * Emergency restart, callable from an interrupt handler.
70789 */
70790
70791 -extern void emergency_restart(void);
70792 +extern void emergency_restart(void) __noreturn;
70793 #include <asm/emergency-restart.h>
70794
70795 #endif /* _LINUX_REBOOT_H */
70796 diff --git a/include/linux/regset.h b/include/linux/regset.h
70797 index 8e0c9fe..ac4d221 100644
70798 --- a/include/linux/regset.h
70799 +++ b/include/linux/regset.h
70800 @@ -161,7 +161,8 @@ struct user_regset {
70801 unsigned int align;
70802 unsigned int bias;
70803 unsigned int core_note_type;
70804 -};
70805 +} __do_const;
70806 +typedef struct user_regset __no_const user_regset_no_const;
70807
70808 /**
70809 * struct user_regset_view - available regsets
70810 diff --git a/include/linux/relay.h b/include/linux/relay.h
70811 index 91cacc3..b55ff74 100644
70812 --- a/include/linux/relay.h
70813 +++ b/include/linux/relay.h
70814 @@ -160,7 +160,7 @@ struct rchan_callbacks
70815 * The callback should return 0 if successful, negative if not.
70816 */
70817 int (*remove_buf_file)(struct dentry *dentry);
70818 -};
70819 +} __no_const;
70820
70821 /*
70822 * CONFIG_RELAY kernel API, kernel/relay.c
70823 diff --git a/include/linux/rio.h b/include/linux/rio.h
70824 index a3e7842..d973ca6 100644
70825 --- a/include/linux/rio.h
70826 +++ b/include/linux/rio.h
70827 @@ -339,7 +339,7 @@ struct rio_ops {
70828 int (*map_inb)(struct rio_mport *mport, dma_addr_t lstart,
70829 u64 rstart, u32 size, u32 flags);
70830 void (*unmap_inb)(struct rio_mport *mport, dma_addr_t lstart);
70831 -};
70832 +} __no_const;
70833
70834 #define RIO_RESOURCE_MEM 0x00000100
70835 #define RIO_RESOURCE_DOORBELL 0x00000200
70836 diff --git a/include/linux/rmap.h b/include/linux/rmap.h
70837 index 6dacb93..6174423 100644
70838 --- a/include/linux/rmap.h
70839 +++ b/include/linux/rmap.h
70840 @@ -145,8 +145,8 @@ static inline void anon_vma_unlock_read(struct anon_vma *anon_vma)
70841 void anon_vma_init(void); /* create anon_vma_cachep */
70842 int anon_vma_prepare(struct vm_area_struct *);
70843 void unlink_anon_vmas(struct vm_area_struct *);
70844 -int anon_vma_clone(struct vm_area_struct *, struct vm_area_struct *);
70845 -int anon_vma_fork(struct vm_area_struct *, struct vm_area_struct *);
70846 +int anon_vma_clone(struct vm_area_struct *, const struct vm_area_struct *);
70847 +int anon_vma_fork(struct vm_area_struct *, const struct vm_area_struct *);
70848
70849 static inline void anon_vma_merge(struct vm_area_struct *vma,
70850 struct vm_area_struct *next)
70851 diff --git a/include/linux/sched.h b/include/linux/sched.h
70852 index be4e742..7f9d593 100644
70853 --- a/include/linux/sched.h
70854 +++ b/include/linux/sched.h
70855 @@ -62,6 +62,7 @@ struct bio_list;
70856 struct fs_struct;
70857 struct perf_event_context;
70858 struct blk_plug;
70859 +struct linux_binprm;
70860
70861 /*
70862 * List of flags we want to share for kernel threads,
70863 @@ -315,7 +316,7 @@ extern char __sched_text_start[], __sched_text_end[];
70864 extern int in_sched_functions(unsigned long addr);
70865
70866 #define MAX_SCHEDULE_TIMEOUT LONG_MAX
70867 -extern signed long schedule_timeout(signed long timeout);
70868 +extern signed long schedule_timeout(signed long timeout) __intentional_overflow(-1);
70869 extern signed long schedule_timeout_interruptible(signed long timeout);
70870 extern signed long schedule_timeout_killable(signed long timeout);
70871 extern signed long schedule_timeout_uninterruptible(signed long timeout);
70872 @@ -329,6 +330,18 @@ struct user_namespace;
70873 #include <linux/aio.h>
70874
70875 #ifdef CONFIG_MMU
70876 +
70877 +#ifdef CONFIG_GRKERNSEC_RAND_THREADSTACK
70878 +extern unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags);
70879 +#else
70880 +static inline unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags)
70881 +{
70882 + return 0;
70883 +}
70884 +#endif
70885 +
70886 +extern bool check_heap_stack_gap(const struct vm_area_struct *vma, unsigned long addr, unsigned long len, unsigned long offset);
70887 +extern unsigned long skip_heap_stack_gap(const struct vm_area_struct *vma, unsigned long len, unsigned long offset);
70888 extern void arch_pick_mmap_layout(struct mm_struct *mm);
70889 extern unsigned long
70890 arch_get_unmapped_area(struct file *, unsigned long, unsigned long,
70891 @@ -605,6 +618,17 @@ struct signal_struct {
70892 #ifdef CONFIG_TASKSTATS
70893 struct taskstats *stats;
70894 #endif
70895 +
70896 +#ifdef CONFIG_GRKERNSEC
70897 + u32 curr_ip;
70898 + u32 saved_ip;
70899 + u32 gr_saddr;
70900 + u32 gr_daddr;
70901 + u16 gr_sport;
70902 + u16 gr_dport;
70903 + u8 used_accept:1;
70904 +#endif
70905 +
70906 #ifdef CONFIG_AUDIT
70907 unsigned audit_tty;
70908 struct tty_audit_buf *tty_audit_buf;
70909 @@ -683,6 +707,11 @@ struct user_struct {
70910 struct key *session_keyring; /* UID's default session keyring */
70911 #endif
70912
70913 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT) || defined(CONFIG_GRKERNSEC_BRUTE)
70914 + unsigned int banned;
70915 + unsigned long ban_expires;
70916 +#endif
70917 +
70918 /* Hash table maintenance information */
70919 struct hlist_node uidhash_node;
70920 kuid_t uid;
70921 @@ -1082,7 +1111,7 @@ struct sched_class {
70922 #ifdef CONFIG_FAIR_GROUP_SCHED
70923 void (*task_move_group) (struct task_struct *p, int on_rq);
70924 #endif
70925 -};
70926 +} __do_const;
70927
70928 struct load_weight {
70929 unsigned long weight, inv_weight;
70930 @@ -1323,8 +1352,8 @@ struct task_struct {
70931 struct list_head thread_group;
70932
70933 struct completion *vfork_done; /* for vfork() */
70934 - int __user *set_child_tid; /* CLONE_CHILD_SETTID */
70935 - int __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */
70936 + pid_t __user *set_child_tid; /* CLONE_CHILD_SETTID */
70937 + pid_t __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */
70938
70939 cputime_t utime, stime, utimescaled, stimescaled;
70940 cputime_t gtime;
70941 @@ -1349,11 +1378,6 @@ struct task_struct {
70942 struct task_cputime cputime_expires;
70943 struct list_head cpu_timers[3];
70944
70945 -/* process credentials */
70946 - const struct cred __rcu *real_cred; /* objective and real subjective task
70947 - * credentials (COW) */
70948 - const struct cred __rcu *cred; /* effective (overridable) subjective task
70949 - * credentials (COW) */
70950 char comm[TASK_COMM_LEN]; /* executable name excluding path
70951 - access with [gs]et_task_comm (which lock
70952 it with task_lock())
70953 @@ -1370,6 +1394,10 @@ struct task_struct {
70954 #endif
70955 /* CPU-specific state of this task */
70956 struct thread_struct thread;
70957 +/* thread_info moved to task_struct */
70958 +#ifdef CONFIG_X86
70959 + struct thread_info tinfo;
70960 +#endif
70961 /* filesystem information */
70962 struct fs_struct *fs;
70963 /* open file information */
70964 @@ -1443,6 +1471,10 @@ struct task_struct {
70965 gfp_t lockdep_reclaim_gfp;
70966 #endif
70967
70968 +/* process credentials */
70969 + const struct cred __rcu *real_cred; /* objective and real subjective task
70970 + * credentials (COW) */
70971 +
70972 /* journalling filesystem info */
70973 void *journal_info;
70974
70975 @@ -1481,6 +1513,10 @@ struct task_struct {
70976 /* cg_list protected by css_set_lock and tsk->alloc_lock */
70977 struct list_head cg_list;
70978 #endif
70979 +
70980 + const struct cred __rcu *cred; /* effective (overridable) subjective task
70981 + * credentials (COW) */
70982 +
70983 #ifdef CONFIG_FUTEX
70984 struct robust_list_head __user *robust_list;
70985 #ifdef CONFIG_COMPAT
70986 @@ -1577,8 +1613,74 @@ struct task_struct {
70987 #ifdef CONFIG_UPROBES
70988 struct uprobe_task *utask;
70989 #endif
70990 +
70991 +#ifdef CONFIG_GRKERNSEC
70992 + /* grsecurity */
70993 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
70994 + u64 exec_id;
70995 +#endif
70996 +#ifdef CONFIG_GRKERNSEC_SETXID
70997 + const struct cred *delayed_cred;
70998 +#endif
70999 + struct dentry *gr_chroot_dentry;
71000 + struct acl_subject_label *acl;
71001 + struct acl_role_label *role;
71002 + struct file *exec_file;
71003 + unsigned long brute_expires;
71004 + u16 acl_role_id;
71005 + /* is this the task that authenticated to the special role */
71006 + u8 acl_sp_role;
71007 + u8 is_writable;
71008 + u8 brute;
71009 + u8 gr_is_chrooted;
71010 +#endif
71011 +
71012 };
71013
71014 +#define MF_PAX_PAGEEXEC 0x01000000 /* Paging based non-executable pages */
71015 +#define MF_PAX_EMUTRAMP 0x02000000 /* Emulate trampolines */
71016 +#define MF_PAX_MPROTECT 0x04000000 /* Restrict mprotect() */
71017 +#define MF_PAX_RANDMMAP 0x08000000 /* Randomize mmap() base */
71018 +/*#define MF_PAX_RANDEXEC 0x10000000*/ /* Randomize ET_EXEC base */
71019 +#define MF_PAX_SEGMEXEC 0x20000000 /* Segmentation based non-executable pages */
71020 +
71021 +#ifdef CONFIG_PAX_SOFTMODE
71022 +extern int pax_softmode;
71023 +#endif
71024 +
71025 +extern int pax_check_flags(unsigned long *);
71026 +
71027 +/* if tsk != current then task_lock must be held on it */
71028 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
71029 +static inline unsigned long pax_get_flags(struct task_struct *tsk)
71030 +{
71031 + if (likely(tsk->mm))
71032 + return tsk->mm->pax_flags;
71033 + else
71034 + return 0UL;
71035 +}
71036 +
71037 +/* if tsk != current then task_lock must be held on it */
71038 +static inline long pax_set_flags(struct task_struct *tsk, unsigned long flags)
71039 +{
71040 + if (likely(tsk->mm)) {
71041 + tsk->mm->pax_flags = flags;
71042 + return 0;
71043 + }
71044 + return -EINVAL;
71045 +}
71046 +#endif
71047 +
71048 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
71049 +extern void pax_set_initial_flags(struct linux_binprm *bprm);
71050 +#elif defined(CONFIG_PAX_HOOK_ACL_FLAGS)
71051 +extern void (*pax_set_initial_flags_func)(struct linux_binprm *bprm);
71052 +#endif
71053 +
71054 +extern void pax_report_fault(struct pt_regs *regs, void *pc, void *sp);
71055 +extern void pax_report_insns(struct pt_regs *regs, void *pc, void *sp);
71056 +extern void pax_report_refcount_overflow(struct pt_regs *regs);
71057 +
71058 /* Future-safe accessor for struct task_struct's cpus_allowed. */
71059 #define tsk_cpus_allowed(tsk) (&(tsk)->cpus_allowed)
71060
71061 @@ -1637,7 +1739,7 @@ struct pid_namespace;
71062 pid_t __task_pid_nr_ns(struct task_struct *task, enum pid_type type,
71063 struct pid_namespace *ns);
71064
71065 -static inline pid_t task_pid_nr(struct task_struct *tsk)
71066 +static inline pid_t task_pid_nr(const struct task_struct *tsk)
71067 {
71068 return tsk->pid;
71069 }
71070 @@ -2073,7 +2175,9 @@ void yield(void);
71071 extern struct exec_domain default_exec_domain;
71072
71073 union thread_union {
71074 +#ifndef CONFIG_X86
71075 struct thread_info thread_info;
71076 +#endif
71077 unsigned long stack[THREAD_SIZE/sizeof(long)];
71078 };
71079
71080 @@ -2106,6 +2210,7 @@ extern struct pid_namespace init_pid_ns;
71081 */
71082
71083 extern struct task_struct *find_task_by_vpid(pid_t nr);
71084 +extern struct task_struct *find_task_by_vpid_unrestricted(pid_t nr);
71085 extern struct task_struct *find_task_by_pid_ns(pid_t nr,
71086 struct pid_namespace *ns);
71087
71088 @@ -2272,7 +2377,7 @@ extern void __cleanup_sighand(struct sighand_struct *);
71089 extern void exit_itimers(struct signal_struct *);
71090 extern void flush_itimer_signals(void);
71091
71092 -extern void do_group_exit(int);
71093 +extern __noreturn void do_group_exit(int);
71094
71095 extern int allow_signal(int);
71096 extern int disallow_signal(int);
71097 @@ -2463,9 +2568,9 @@ static inline unsigned long *end_of_stack(struct task_struct *p)
71098
71099 #endif
71100
71101 -static inline int object_is_on_stack(void *obj)
71102 +static inline int object_starts_on_stack(void *obj)
71103 {
71104 - void *stack = task_stack_page(current);
71105 + const void *stack = task_stack_page(current);
71106
71107 return (obj >= stack) && (obj < (stack + THREAD_SIZE));
71108 }
71109 diff --git a/include/linux/sched/sysctl.h b/include/linux/sched/sysctl.h
71110 index bf8086b..962b035 100644
71111 --- a/include/linux/sched/sysctl.h
71112 +++ b/include/linux/sched/sysctl.h
71113 @@ -30,6 +30,7 @@ enum { sysctl_hung_task_timeout_secs = 0 };
71114 #define DEFAULT_MAX_MAP_COUNT (USHRT_MAX - MAPCOUNT_ELF_CORE_MARGIN)
71115
71116 extern int sysctl_max_map_count;
71117 +extern unsigned long sysctl_heap_stack_gap;
71118
71119 extern unsigned int sysctl_sched_latency;
71120 extern unsigned int sysctl_sched_min_granularity;
71121 diff --git a/include/linux/security.h b/include/linux/security.h
71122 index 032c366..2c1c2dc2 100644
71123 --- a/include/linux/security.h
71124 +++ b/include/linux/security.h
71125 @@ -26,6 +26,7 @@
71126 #include <linux/capability.h>
71127 #include <linux/slab.h>
71128 #include <linux/err.h>
71129 +#include <linux/grsecurity.h>
71130
71131 struct linux_binprm;
71132 struct cred;
71133 diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h
71134 index 68a04a3..866e6a1 100644
71135 --- a/include/linux/seq_file.h
71136 +++ b/include/linux/seq_file.h
71137 @@ -26,6 +26,9 @@ struct seq_file {
71138 struct mutex lock;
71139 const struct seq_operations *op;
71140 int poll_event;
71141 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
71142 + u64 exec_id;
71143 +#endif
71144 #ifdef CONFIG_USER_NS
71145 struct user_namespace *user_ns;
71146 #endif
71147 @@ -38,6 +41,7 @@ struct seq_operations {
71148 void * (*next) (struct seq_file *m, void *v, loff_t *pos);
71149 int (*show) (struct seq_file *m, void *v);
71150 };
71151 +typedef struct seq_operations __no_const seq_operations_no_const;
71152
71153 #define SEQ_SKIP 1
71154
71155 diff --git a/include/linux/shm.h b/include/linux/shm.h
71156 index 429c199..4d42e38 100644
71157 --- a/include/linux/shm.h
71158 +++ b/include/linux/shm.h
71159 @@ -21,6 +21,10 @@ struct shmid_kernel /* private to the kernel */
71160
71161 /* The task created the shm object. NULL if the task is dead. */
71162 struct task_struct *shm_creator;
71163 +#ifdef CONFIG_GRKERNSEC
71164 + time_t shm_createtime;
71165 + pid_t shm_lapid;
71166 +#endif
71167 };
71168
71169 /* shm_mode upper byte flags */
71170 diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
71171 index b8292d8..96db310 100644
71172 --- a/include/linux/skbuff.h
71173 +++ b/include/linux/skbuff.h
71174 @@ -599,7 +599,7 @@ extern bool skb_try_coalesce(struct sk_buff *to, struct sk_buff *from,
71175 extern struct sk_buff *__alloc_skb(unsigned int size,
71176 gfp_t priority, int flags, int node);
71177 extern struct sk_buff *build_skb(void *data, unsigned int frag_size);
71178 -static inline struct sk_buff *alloc_skb(unsigned int size,
71179 +static inline struct sk_buff * __intentional_overflow(0) alloc_skb(unsigned int size,
71180 gfp_t priority)
71181 {
71182 return __alloc_skb(size, priority, 0, NUMA_NO_NODE);
71183 @@ -709,7 +709,7 @@ static inline struct skb_shared_hwtstamps *skb_hwtstamps(struct sk_buff *skb)
71184 */
71185 static inline int skb_queue_empty(const struct sk_buff_head *list)
71186 {
71187 - return list->next == (struct sk_buff *)list;
71188 + return list->next == (const struct sk_buff *)list;
71189 }
71190
71191 /**
71192 @@ -722,7 +722,7 @@ static inline int skb_queue_empty(const struct sk_buff_head *list)
71193 static inline bool skb_queue_is_last(const struct sk_buff_head *list,
71194 const struct sk_buff *skb)
71195 {
71196 - return skb->next == (struct sk_buff *)list;
71197 + return skb->next == (const struct sk_buff *)list;
71198 }
71199
71200 /**
71201 @@ -735,7 +735,7 @@ static inline bool skb_queue_is_last(const struct sk_buff_head *list,
71202 static inline bool skb_queue_is_first(const struct sk_buff_head *list,
71203 const struct sk_buff *skb)
71204 {
71205 - return skb->prev == (struct sk_buff *)list;
71206 + return skb->prev == (const struct sk_buff *)list;
71207 }
71208
71209 /**
71210 @@ -1756,7 +1756,7 @@ static inline int pskb_network_may_pull(struct sk_buff *skb, unsigned int len)
71211 * NET_IP_ALIGN(2) + ethernet_header(14) + IP_header(20/40) + ports(8)
71212 */
71213 #ifndef NET_SKB_PAD
71214 -#define NET_SKB_PAD max(32, L1_CACHE_BYTES)
71215 +#define NET_SKB_PAD max(_AC(32,UL), L1_CACHE_BYTES)
71216 #endif
71217
71218 extern int ___pskb_trim(struct sk_buff *skb, unsigned int len);
71219 @@ -2351,7 +2351,7 @@ extern struct sk_buff *skb_recv_datagram(struct sock *sk, unsigned flags,
71220 int noblock, int *err);
71221 extern unsigned int datagram_poll(struct file *file, struct socket *sock,
71222 struct poll_table_struct *wait);
71223 -extern int skb_copy_datagram_iovec(const struct sk_buff *from,
71224 +extern int __intentional_overflow(0) skb_copy_datagram_iovec(const struct sk_buff *from,
71225 int offset, struct iovec *to,
71226 int size);
71227 extern int skb_copy_and_csum_datagram_iovec(struct sk_buff *skb,
71228 @@ -2641,6 +2641,9 @@ static inline void nf_reset(struct sk_buff *skb)
71229 nf_bridge_put(skb->nf_bridge);
71230 skb->nf_bridge = NULL;
71231 #endif
71232 +#if IS_ENABLED(CONFIG_NETFILTER_XT_TARGET_TRACE)
71233 + skb->nf_trace = 0;
71234 +#endif
71235 }
71236
71237 static inline void nf_reset_trace(struct sk_buff *skb)
71238 diff --git a/include/linux/slab.h b/include/linux/slab.h
71239 index 5d168d7..720bff3 100644
71240 --- a/include/linux/slab.h
71241 +++ b/include/linux/slab.h
71242 @@ -12,13 +12,20 @@
71243 #include <linux/gfp.h>
71244 #include <linux/types.h>
71245 #include <linux/workqueue.h>
71246 -
71247 +#include <linux/err.h>
71248
71249 /*
71250 * Flags to pass to kmem_cache_create().
71251 * The ones marked DEBUG are only valid if CONFIG_SLAB_DEBUG is set.
71252 */
71253 #define SLAB_DEBUG_FREE 0x00000100UL /* DEBUG: Perform (expensive) checks on free */
71254 +
71255 +#ifdef CONFIG_PAX_USERCOPY_SLABS
71256 +#define SLAB_USERCOPY 0x00000200UL /* PaX: Allow copying objs to/from userland */
71257 +#else
71258 +#define SLAB_USERCOPY 0x00000000UL
71259 +#endif
71260 +
71261 #define SLAB_RED_ZONE 0x00000400UL /* DEBUG: Red zone objs in a cache */
71262 #define SLAB_POISON 0x00000800UL /* DEBUG: Poison objects */
71263 #define SLAB_HWCACHE_ALIGN 0x00002000UL /* Align objs on cache lines */
71264 @@ -89,10 +96,13 @@
71265 * ZERO_SIZE_PTR can be passed to kfree though in the same way that NULL can.
71266 * Both make kfree a no-op.
71267 */
71268 -#define ZERO_SIZE_PTR ((void *)16)
71269 +#define ZERO_SIZE_PTR \
71270 +({ \
71271 + BUILD_BUG_ON(!(MAX_ERRNO & ~PAGE_MASK));\
71272 + (void *)(-MAX_ERRNO-1L); \
71273 +})
71274
71275 -#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) <= \
71276 - (unsigned long)ZERO_SIZE_PTR)
71277 +#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) - 1 >= (unsigned long)ZERO_SIZE_PTR - 1)
71278
71279 /*
71280 * Common fields provided in kmem_cache by all slab allocators
71281 @@ -112,7 +122,7 @@ struct kmem_cache {
71282 unsigned int align; /* Alignment as calculated */
71283 unsigned long flags; /* Active flags on the slab */
71284 const char *name; /* Slab name for sysfs */
71285 - int refcount; /* Use counter */
71286 + atomic_t refcount; /* Use counter */
71287 void (*ctor)(void *); /* Called on object slot creation */
71288 struct list_head list; /* List of all slab caches on the system */
71289 };
71290 @@ -232,6 +242,8 @@ void * __must_check krealloc(const void *, size_t, gfp_t);
71291 void kfree(const void *);
71292 void kzfree(const void *);
71293 size_t ksize(const void *);
71294 +const char *check_heap_object(const void *ptr, unsigned long n);
71295 +bool is_usercopy_object(const void *ptr);
71296
71297 /*
71298 * Allocator specific definitions. These are mainly used to establish optimized
71299 @@ -311,6 +323,7 @@ size_t ksize(const void *);
71300 * for general use, and so are not documented here. For a full list of
71301 * potential flags, always refer to linux/gfp.h.
71302 */
71303 +
71304 static inline void *kmalloc_array(size_t n, size_t size, gfp_t flags)
71305 {
71306 if (size != 0 && n > SIZE_MAX / size)
71307 @@ -370,7 +383,7 @@ static inline void *kmem_cache_alloc_node(struct kmem_cache *cachep,
71308 #if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB) || \
71309 (defined(CONFIG_SLAB) && defined(CONFIG_TRACING)) || \
71310 (defined(CONFIG_SLOB) && defined(CONFIG_TRACING))
71311 -extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long);
71312 +extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long) __size_overflow(1);
71313 #define kmalloc_track_caller(size, flags) \
71314 __kmalloc_track_caller(size, flags, _RET_IP_)
71315 #else
71316 @@ -390,7 +403,7 @@ extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long);
71317 #if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB) || \
71318 (defined(CONFIG_SLAB) && defined(CONFIG_TRACING)) || \
71319 (defined(CONFIG_SLOB) && defined(CONFIG_TRACING))
71320 -extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, unsigned long);
71321 +extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, unsigned long) __size_overflow(1);
71322 #define kmalloc_node_track_caller(size, flags, node) \
71323 __kmalloc_node_track_caller(size, flags, node, \
71324 _RET_IP_)
71325 diff --git a/include/linux/slab_def.h b/include/linux/slab_def.h
71326 index 8bb6e0e..8eb0dbe 100644
71327 --- a/include/linux/slab_def.h
71328 +++ b/include/linux/slab_def.h
71329 @@ -52,7 +52,7 @@ struct kmem_cache {
71330 /* 4) cache creation/removal */
71331 const char *name;
71332 struct list_head list;
71333 - int refcount;
71334 + atomic_t refcount;
71335 int object_size;
71336 int align;
71337
71338 @@ -68,10 +68,10 @@ struct kmem_cache {
71339 unsigned long node_allocs;
71340 unsigned long node_frees;
71341 unsigned long node_overflow;
71342 - atomic_t allochit;
71343 - atomic_t allocmiss;
71344 - atomic_t freehit;
71345 - atomic_t freemiss;
71346 + atomic_unchecked_t allochit;
71347 + atomic_unchecked_t allocmiss;
71348 + atomic_unchecked_t freehit;
71349 + atomic_unchecked_t freemiss;
71350
71351 /*
71352 * If debugging is enabled, then the allocator can add additional
71353 @@ -111,11 +111,16 @@ struct cache_sizes {
71354 #ifdef CONFIG_ZONE_DMA
71355 struct kmem_cache *cs_dmacachep;
71356 #endif
71357 +
71358 +#ifdef CONFIG_PAX_USERCOPY_SLABS
71359 + struct kmem_cache *cs_usercopycachep;
71360 +#endif
71361 +
71362 };
71363 extern struct cache_sizes malloc_sizes[];
71364
71365 void *kmem_cache_alloc(struct kmem_cache *, gfp_t);
71366 -void *__kmalloc(size_t size, gfp_t flags);
71367 +void *__kmalloc(size_t size, gfp_t flags) __size_overflow(1);
71368
71369 #ifdef CONFIG_TRACING
71370 extern void *kmem_cache_alloc_trace(struct kmem_cache *, gfp_t, size_t);
71371 @@ -152,6 +157,13 @@ found:
71372 cachep = malloc_sizes[i].cs_dmacachep;
71373 else
71374 #endif
71375 +
71376 +#ifdef CONFIG_PAX_USERCOPY_SLABS
71377 + if (flags & GFP_USERCOPY)
71378 + cachep = malloc_sizes[i].cs_usercopycachep;
71379 + else
71380 +#endif
71381 +
71382 cachep = malloc_sizes[i].cs_cachep;
71383
71384 ret = kmem_cache_alloc_trace(cachep, flags, size);
71385 @@ -162,7 +174,7 @@ found:
71386 }
71387
71388 #ifdef CONFIG_NUMA
71389 -extern void *__kmalloc_node(size_t size, gfp_t flags, int node);
71390 +extern void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
71391 extern void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
71392
71393 #ifdef CONFIG_TRACING
71394 @@ -205,6 +217,13 @@ found:
71395 cachep = malloc_sizes[i].cs_dmacachep;
71396 else
71397 #endif
71398 +
71399 +#ifdef CONFIG_PAX_USERCOPY_SLABS
71400 + if (flags & GFP_USERCOPY)
71401 + cachep = malloc_sizes[i].cs_usercopycachep;
71402 + else
71403 +#endif
71404 +
71405 cachep = malloc_sizes[i].cs_cachep;
71406
71407 return kmem_cache_alloc_node_trace(cachep, flags, node, size);
71408 diff --git a/include/linux/slob_def.h b/include/linux/slob_def.h
71409 index f28e14a..7831211 100644
71410 --- a/include/linux/slob_def.h
71411 +++ b/include/linux/slob_def.h
71412 @@ -11,7 +11,7 @@ static __always_inline void *kmem_cache_alloc(struct kmem_cache *cachep,
71413 return kmem_cache_alloc_node(cachep, flags, NUMA_NO_NODE);
71414 }
71415
71416 -void *__kmalloc_node(size_t size, gfp_t flags, int node);
71417 +void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
71418
71419 static __always_inline void *kmalloc_node(size_t size, gfp_t flags, int node)
71420 {
71421 @@ -31,7 +31,7 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
71422 return __kmalloc_node(size, flags, NUMA_NO_NODE);
71423 }
71424
71425 -static __always_inline void *__kmalloc(size_t size, gfp_t flags)
71426 +static __always_inline __size_overflow(1) void *__kmalloc(size_t size, gfp_t flags)
71427 {
71428 return kmalloc(size, flags);
71429 }
71430 diff --git a/include/linux/slub_def.h b/include/linux/slub_def.h
71431 index 9db4825..ed42fb5 100644
71432 --- a/include/linux/slub_def.h
71433 +++ b/include/linux/slub_def.h
71434 @@ -91,7 +91,7 @@ struct kmem_cache {
71435 struct kmem_cache_order_objects max;
71436 struct kmem_cache_order_objects min;
71437 gfp_t allocflags; /* gfp flags to use on each alloc */
71438 - int refcount; /* Refcount for slab cache destroy */
71439 + atomic_t refcount; /* Refcount for slab cache destroy */
71440 void (*ctor)(void *);
71441 int inuse; /* Offset to metadata */
71442 int align; /* Alignment */
71443 @@ -156,7 +156,7 @@ extern struct kmem_cache *kmalloc_caches[SLUB_PAGE_SHIFT];
71444 * Sorry that the following has to be that ugly but some versions of GCC
71445 * have trouble with constant propagation and loops.
71446 */
71447 -static __always_inline int kmalloc_index(size_t size)
71448 +static __always_inline __size_overflow(1) int kmalloc_index(size_t size)
71449 {
71450 if (!size)
71451 return 0;
71452 @@ -221,7 +221,7 @@ static __always_inline struct kmem_cache *kmalloc_slab(size_t size)
71453 }
71454
71455 void *kmem_cache_alloc(struct kmem_cache *, gfp_t);
71456 -void *__kmalloc(size_t size, gfp_t flags);
71457 +void *__kmalloc(size_t size, gfp_t flags) __alloc_size(1) __size_overflow(1);
71458
71459 static __always_inline void *
71460 kmalloc_order(size_t size, gfp_t flags, unsigned int order)
71461 @@ -265,7 +265,7 @@ kmalloc_order_trace(size_t size, gfp_t flags, unsigned int order)
71462 }
71463 #endif
71464
71465 -static __always_inline void *kmalloc_large(size_t size, gfp_t flags)
71466 +static __always_inline __size_overflow(1) void *kmalloc_large(size_t size, gfp_t flags)
71467 {
71468 unsigned int order = get_order(size);
71469 return kmalloc_order_trace(size, flags, order);
71470 @@ -290,7 +290,7 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
71471 }
71472
71473 #ifdef CONFIG_NUMA
71474 -void *__kmalloc_node(size_t size, gfp_t flags, int node);
71475 +void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
71476 void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
71477
71478 #ifdef CONFIG_TRACING
71479 diff --git a/include/linux/sock_diag.h b/include/linux/sock_diag.h
71480 index e8d702e..0a56eb4 100644
71481 --- a/include/linux/sock_diag.h
71482 +++ b/include/linux/sock_diag.h
71483 @@ -10,7 +10,7 @@ struct sock;
71484 struct sock_diag_handler {
71485 __u8 family;
71486 int (*dump)(struct sk_buff *skb, struct nlmsghdr *nlh);
71487 -};
71488 +} __do_const;
71489
71490 int sock_diag_register(const struct sock_diag_handler *h);
71491 void sock_diag_unregister(const struct sock_diag_handler *h);
71492 diff --git a/include/linux/sonet.h b/include/linux/sonet.h
71493 index 680f9a3..f13aeb0 100644
71494 --- a/include/linux/sonet.h
71495 +++ b/include/linux/sonet.h
71496 @@ -7,7 +7,7 @@
71497 #include <uapi/linux/sonet.h>
71498
71499 struct k_sonet_stats {
71500 -#define __HANDLE_ITEM(i) atomic_t i
71501 +#define __HANDLE_ITEM(i) atomic_unchecked_t i
71502 __SONET_ITEMS
71503 #undef __HANDLE_ITEM
71504 };
71505 diff --git a/include/linux/sunrpc/addr.h b/include/linux/sunrpc/addr.h
71506 index 07d8e53..dc934c9 100644
71507 --- a/include/linux/sunrpc/addr.h
71508 +++ b/include/linux/sunrpc/addr.h
71509 @@ -23,9 +23,9 @@ static inline unsigned short rpc_get_port(const struct sockaddr *sap)
71510 {
71511 switch (sap->sa_family) {
71512 case AF_INET:
71513 - return ntohs(((struct sockaddr_in *)sap)->sin_port);
71514 + return ntohs(((const struct sockaddr_in *)sap)->sin_port);
71515 case AF_INET6:
71516 - return ntohs(((struct sockaddr_in6 *)sap)->sin6_port);
71517 + return ntohs(((const struct sockaddr_in6 *)sap)->sin6_port);
71518 }
71519 return 0;
71520 }
71521 @@ -58,7 +58,7 @@ static inline bool __rpc_cmp_addr4(const struct sockaddr *sap1,
71522 static inline bool __rpc_copy_addr4(struct sockaddr *dst,
71523 const struct sockaddr *src)
71524 {
71525 - const struct sockaddr_in *ssin = (struct sockaddr_in *) src;
71526 + const struct sockaddr_in *ssin = (const struct sockaddr_in *) src;
71527 struct sockaddr_in *dsin = (struct sockaddr_in *) dst;
71528
71529 dsin->sin_family = ssin->sin_family;
71530 @@ -164,7 +164,7 @@ static inline u32 rpc_get_scope_id(const struct sockaddr *sa)
71531 if (sa->sa_family != AF_INET6)
71532 return 0;
71533
71534 - return ((struct sockaddr_in6 *) sa)->sin6_scope_id;
71535 + return ((const struct sockaddr_in6 *) sa)->sin6_scope_id;
71536 }
71537
71538 #endif /* _LINUX_SUNRPC_ADDR_H */
71539 diff --git a/include/linux/sunrpc/clnt.h b/include/linux/sunrpc/clnt.h
71540 index 2cf4ffa..470d140 100644
71541 --- a/include/linux/sunrpc/clnt.h
71542 +++ b/include/linux/sunrpc/clnt.h
71543 @@ -96,7 +96,7 @@ struct rpc_procinfo {
71544 unsigned int p_timer; /* Which RTT timer to use */
71545 u32 p_statidx; /* Which procedure to account */
71546 const char * p_name; /* name of procedure */
71547 -};
71548 +} __do_const;
71549
71550 #ifdef __KERNEL__
71551
71552 diff --git a/include/linux/sunrpc/svc.h b/include/linux/sunrpc/svc.h
71553 index 1f0216b..6a4fa50 100644
71554 --- a/include/linux/sunrpc/svc.h
71555 +++ b/include/linux/sunrpc/svc.h
71556 @@ -411,7 +411,7 @@ struct svc_procedure {
71557 unsigned int pc_count; /* call count */
71558 unsigned int pc_cachetype; /* cache info (NFS) */
71559 unsigned int pc_xdrressize; /* maximum size of XDR reply */
71560 -};
71561 +} __do_const;
71562
71563 /*
71564 * Function prototypes.
71565 diff --git a/include/linux/sunrpc/svc_rdma.h b/include/linux/sunrpc/svc_rdma.h
71566 index 0b8e3e6..33e0a01 100644
71567 --- a/include/linux/sunrpc/svc_rdma.h
71568 +++ b/include/linux/sunrpc/svc_rdma.h
71569 @@ -53,15 +53,15 @@ extern unsigned int svcrdma_ord;
71570 extern unsigned int svcrdma_max_requests;
71571 extern unsigned int svcrdma_max_req_size;
71572
71573 -extern atomic_t rdma_stat_recv;
71574 -extern atomic_t rdma_stat_read;
71575 -extern atomic_t rdma_stat_write;
71576 -extern atomic_t rdma_stat_sq_starve;
71577 -extern atomic_t rdma_stat_rq_starve;
71578 -extern atomic_t rdma_stat_rq_poll;
71579 -extern atomic_t rdma_stat_rq_prod;
71580 -extern atomic_t rdma_stat_sq_poll;
71581 -extern atomic_t rdma_stat_sq_prod;
71582 +extern atomic_unchecked_t rdma_stat_recv;
71583 +extern atomic_unchecked_t rdma_stat_read;
71584 +extern atomic_unchecked_t rdma_stat_write;
71585 +extern atomic_unchecked_t rdma_stat_sq_starve;
71586 +extern atomic_unchecked_t rdma_stat_rq_starve;
71587 +extern atomic_unchecked_t rdma_stat_rq_poll;
71588 +extern atomic_unchecked_t rdma_stat_rq_prod;
71589 +extern atomic_unchecked_t rdma_stat_sq_poll;
71590 +extern atomic_unchecked_t rdma_stat_sq_prod;
71591
71592 #define RPCRDMA_VERSION 1
71593
71594 diff --git a/include/linux/sunrpc/svcauth.h b/include/linux/sunrpc/svcauth.h
71595 index ff374ab..7fd2ecb 100644
71596 --- a/include/linux/sunrpc/svcauth.h
71597 +++ b/include/linux/sunrpc/svcauth.h
71598 @@ -109,7 +109,7 @@ struct auth_ops {
71599 int (*release)(struct svc_rqst *rq);
71600 void (*domain_release)(struct auth_domain *);
71601 int (*set_client)(struct svc_rqst *rq);
71602 -};
71603 +} __do_const;
71604
71605 #define SVC_GARBAGE 1
71606 #define SVC_SYSERR 2
71607 diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h
71608 index a5ffd32..0935dea 100644
71609 --- a/include/linux/swiotlb.h
71610 +++ b/include/linux/swiotlb.h
71611 @@ -60,7 +60,8 @@ extern void
71612
71613 extern void
71614 swiotlb_free_coherent(struct device *hwdev, size_t size,
71615 - void *vaddr, dma_addr_t dma_handle);
71616 + void *vaddr, dma_addr_t dma_handle,
71617 + struct dma_attrs *attrs);
71618
71619 extern dma_addr_t swiotlb_map_page(struct device *dev, struct page *page,
71620 unsigned long offset, size_t size,
71621 diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
71622 index 313a8e0..6b273a9 100644
71623 --- a/include/linux/syscalls.h
71624 +++ b/include/linux/syscalls.h
71625 @@ -418,11 +418,11 @@ asmlinkage long sys_sync(void);
71626 asmlinkage long sys_fsync(unsigned int fd);
71627 asmlinkage long sys_fdatasync(unsigned int fd);
71628 asmlinkage long sys_bdflush(int func, long data);
71629 -asmlinkage long sys_mount(char __user *dev_name, char __user *dir_name,
71630 - char __user *type, unsigned long flags,
71631 +asmlinkage long sys_mount(const char __user *dev_name, const char __user *dir_name,
71632 + const char __user *type, unsigned long flags,
71633 void __user *data);
71634 -asmlinkage long sys_umount(char __user *name, int flags);
71635 -asmlinkage long sys_oldumount(char __user *name);
71636 +asmlinkage long sys_umount(const char __user *name, int flags);
71637 +asmlinkage long sys_oldumount(const char __user *name);
71638 asmlinkage long sys_truncate(const char __user *path, long length);
71639 asmlinkage long sys_ftruncate(unsigned int fd, unsigned long length);
71640 asmlinkage long sys_stat(const char __user *filename,
71641 @@ -634,7 +634,7 @@ asmlinkage long sys_getsockname(int, struct sockaddr __user *, int __user *);
71642 asmlinkage long sys_getpeername(int, struct sockaddr __user *, int __user *);
71643 asmlinkage long sys_send(int, void __user *, size_t, unsigned);
71644 asmlinkage long sys_sendto(int, void __user *, size_t, unsigned,
71645 - struct sockaddr __user *, int);
71646 + struct sockaddr __user *, int) __intentional_overflow(0);
71647 asmlinkage long sys_sendmsg(int fd, struct msghdr __user *msg, unsigned flags);
71648 asmlinkage long sys_sendmmsg(int fd, struct mmsghdr __user *msg,
71649 unsigned int vlen, unsigned flags);
71650 diff --git a/include/linux/syscore_ops.h b/include/linux/syscore_ops.h
71651 index 27b3b0b..e093dd9 100644
71652 --- a/include/linux/syscore_ops.h
71653 +++ b/include/linux/syscore_ops.h
71654 @@ -16,7 +16,7 @@ struct syscore_ops {
71655 int (*suspend)(void);
71656 void (*resume)(void);
71657 void (*shutdown)(void);
71658 -};
71659 +} __do_const;
71660
71661 extern void register_syscore_ops(struct syscore_ops *ops);
71662 extern void unregister_syscore_ops(struct syscore_ops *ops);
71663 diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
71664 index 14a8ff2..af52bad 100644
71665 --- a/include/linux/sysctl.h
71666 +++ b/include/linux/sysctl.h
71667 @@ -34,13 +34,13 @@ struct ctl_table_root;
71668 struct ctl_table_header;
71669 struct ctl_dir;
71670
71671 -typedef struct ctl_table ctl_table;
71672 -
71673 typedef int proc_handler (struct ctl_table *ctl, int write,
71674 void __user *buffer, size_t *lenp, loff_t *ppos);
71675
71676 extern int proc_dostring(struct ctl_table *, int,
71677 void __user *, size_t *, loff_t *);
71678 +extern int proc_dostring_modpriv(struct ctl_table *, int,
71679 + void __user *, size_t *, loff_t *);
71680 extern int proc_dointvec(struct ctl_table *, int,
71681 void __user *, size_t *, loff_t *);
71682 extern int proc_dointvec_minmax(struct ctl_table *, int,
71683 @@ -115,7 +115,9 @@ struct ctl_table
71684 struct ctl_table_poll *poll;
71685 void *extra1;
71686 void *extra2;
71687 -};
71688 +} __do_const;
71689 +typedef struct ctl_table __no_const ctl_table_no_const;
71690 +typedef struct ctl_table ctl_table;
71691
71692 struct ctl_node {
71693 struct rb_node node;
71694 diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
71695 index e2cee22..3ddb921 100644
71696 --- a/include/linux/sysfs.h
71697 +++ b/include/linux/sysfs.h
71698 @@ -31,7 +31,8 @@ struct attribute {
71699 struct lock_class_key *key;
71700 struct lock_class_key skey;
71701 #endif
71702 -};
71703 +} __do_const;
71704 +typedef struct attribute __no_const attribute_no_const;
71705
71706 /**
71707 * sysfs_attr_init - initialize a dynamically allocated sysfs attribute
71708 @@ -59,8 +60,8 @@ struct attribute_group {
71709 umode_t (*is_visible)(struct kobject *,
71710 struct attribute *, int);
71711 struct attribute **attrs;
71712 -};
71713 -
71714 +} __do_const;
71715 +typedef struct attribute_group __no_const attribute_group_no_const;
71716
71717
71718 /**
71719 @@ -107,7 +108,8 @@ struct bin_attribute {
71720 char *, loff_t, size_t);
71721 int (*mmap)(struct file *, struct kobject *, struct bin_attribute *attr,
71722 struct vm_area_struct *vma);
71723 -};
71724 +} __do_const;
71725 +typedef struct bin_attribute __no_const bin_attribute_no_const;
71726
71727 /**
71728 * sysfs_bin_attr_init - initialize a dynamically allocated bin_attribute
71729 diff --git a/include/linux/sysrq.h b/include/linux/sysrq.h
71730 index 7faf933..9b85a0c 100644
71731 --- a/include/linux/sysrq.h
71732 +++ b/include/linux/sysrq.h
71733 @@ -16,6 +16,7 @@
71734
71735 #include <linux/errno.h>
71736 #include <linux/types.h>
71737 +#include <linux/compiler.h>
71738
71739 /* Enable/disable SYSRQ support by default (0==no, 1==yes). */
71740 #define SYSRQ_DEFAULT_ENABLE 1
71741 @@ -36,7 +37,7 @@ struct sysrq_key_op {
71742 char *help_msg;
71743 char *action_msg;
71744 int enable_mask;
71745 -};
71746 +} __do_const;
71747
71748 #ifdef CONFIG_MAGIC_SYSRQ
71749
71750 diff --git a/include/linux/thread_info.h b/include/linux/thread_info.h
71751 index e7e0473..7989295 100644
71752 --- a/include/linux/thread_info.h
71753 +++ b/include/linux/thread_info.h
71754 @@ -148,6 +148,15 @@ static inline bool test_and_clear_restore_sigmask(void)
71755 #error "no set_restore_sigmask() provided and default one won't work"
71756 #endif
71757
71758 +extern void __check_object_size(const void *ptr, unsigned long n, bool to_user);
71759 +static inline void check_object_size(const void *ptr, unsigned long n, bool to_user)
71760 +{
71761 +#ifndef CONFIG_PAX_USERCOPY_DEBUG
71762 + if (!__builtin_constant_p(n))
71763 +#endif
71764 + __check_object_size(ptr, n, to_user);
71765 +}
71766 +
71767 #endif /* __KERNEL__ */
71768
71769 #endif /* _LINUX_THREAD_INFO_H */
71770 diff --git a/include/linux/tty.h b/include/linux/tty.h
71771 index c75d886..04cb148 100644
71772 --- a/include/linux/tty.h
71773 +++ b/include/linux/tty.h
71774 @@ -194,7 +194,7 @@ struct tty_port {
71775 const struct tty_port_operations *ops; /* Port operations */
71776 spinlock_t lock; /* Lock protecting tty field */
71777 int blocked_open; /* Waiting to open */
71778 - int count; /* Usage count */
71779 + atomic_t count; /* Usage count */
71780 wait_queue_head_t open_wait; /* Open waiters */
71781 wait_queue_head_t close_wait; /* Close waiters */
71782 wait_queue_head_t delta_msr_wait; /* Modem status change */
71783 @@ -515,7 +515,7 @@ extern int tty_port_open(struct tty_port *port,
71784 struct tty_struct *tty, struct file *filp);
71785 static inline int tty_port_users(struct tty_port *port)
71786 {
71787 - return port->count + port->blocked_open;
71788 + return atomic_read(&port->count) + port->blocked_open;
71789 }
71790
71791 extern int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc);
71792 diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h
71793 index 756a609..b302dd6 100644
71794 --- a/include/linux/tty_driver.h
71795 +++ b/include/linux/tty_driver.h
71796 @@ -285,7 +285,7 @@ struct tty_operations {
71797 void (*poll_put_char)(struct tty_driver *driver, int line, char ch);
71798 #endif
71799 const struct file_operations *proc_fops;
71800 -};
71801 +} __do_const;
71802
71803 struct tty_driver {
71804 int magic; /* magic number for this structure */
71805 diff --git a/include/linux/tty_ldisc.h b/include/linux/tty_ldisc.h
71806 index 455a0d7..bf97ff5 100644
71807 --- a/include/linux/tty_ldisc.h
71808 +++ b/include/linux/tty_ldisc.h
71809 @@ -146,7 +146,7 @@ struct tty_ldisc_ops {
71810
71811 struct module *owner;
71812
71813 - int refcount;
71814 + atomic_t refcount;
71815 };
71816
71817 struct tty_ldisc {
71818 diff --git a/include/linux/types.h b/include/linux/types.h
71819 index 4d118ba..c3ee9bf 100644
71820 --- a/include/linux/types.h
71821 +++ b/include/linux/types.h
71822 @@ -176,10 +176,26 @@ typedef struct {
71823 int counter;
71824 } atomic_t;
71825
71826 +#ifdef CONFIG_PAX_REFCOUNT
71827 +typedef struct {
71828 + int counter;
71829 +} atomic_unchecked_t;
71830 +#else
71831 +typedef atomic_t atomic_unchecked_t;
71832 +#endif
71833 +
71834 #ifdef CONFIG_64BIT
71835 typedef struct {
71836 long counter;
71837 } atomic64_t;
71838 +
71839 +#ifdef CONFIG_PAX_REFCOUNT
71840 +typedef struct {
71841 + long counter;
71842 +} atomic64_unchecked_t;
71843 +#else
71844 +typedef atomic64_t atomic64_unchecked_t;
71845 +#endif
71846 #endif
71847
71848 struct list_head {
71849 diff --git a/include/linux/uaccess.h b/include/linux/uaccess.h
71850 index 5ca0951..ab496a5 100644
71851 --- a/include/linux/uaccess.h
71852 +++ b/include/linux/uaccess.h
71853 @@ -76,11 +76,11 @@ static inline unsigned long __copy_from_user_nocache(void *to,
71854 long ret; \
71855 mm_segment_t old_fs = get_fs(); \
71856 \
71857 - set_fs(KERNEL_DS); \
71858 pagefault_disable(); \
71859 - ret = __copy_from_user_inatomic(&(retval), (__force typeof(retval) __user *)(addr), sizeof(retval)); \
71860 - pagefault_enable(); \
71861 + set_fs(KERNEL_DS); \
71862 + ret = __copy_from_user_inatomic(&(retval), (typeof(retval) __force_user *)(addr), sizeof(retval)); \
71863 set_fs(old_fs); \
71864 + pagefault_enable(); \
71865 ret; \
71866 })
71867
71868 diff --git a/include/linux/uidgid.h b/include/linux/uidgid.h
71869 index 8e522cbc..aa8572d 100644
71870 --- a/include/linux/uidgid.h
71871 +++ b/include/linux/uidgid.h
71872 @@ -197,4 +197,9 @@ static inline bool kgid_has_mapping(struct user_namespace *ns, kgid_t gid)
71873
71874 #endif /* CONFIG_USER_NS */
71875
71876 +#define GR_GLOBAL_UID(x) from_kuid_munged(&init_user_ns, (x))
71877 +#define GR_GLOBAL_GID(x) from_kgid_munged(&init_user_ns, (x))
71878 +#define gr_is_global_root(x) uid_eq((x), GLOBAL_ROOT_UID)
71879 +#define gr_is_global_nonroot(x) (!uid_eq((x), GLOBAL_ROOT_UID))
71880 +
71881 #endif /* _LINUX_UIDGID_H */
71882 diff --git a/include/linux/unaligned/access_ok.h b/include/linux/unaligned/access_ok.h
71883 index 99c1b4d..562e6f3 100644
71884 --- a/include/linux/unaligned/access_ok.h
71885 +++ b/include/linux/unaligned/access_ok.h
71886 @@ -4,34 +4,34 @@
71887 #include <linux/kernel.h>
71888 #include <asm/byteorder.h>
71889
71890 -static inline u16 get_unaligned_le16(const void *p)
71891 +static inline u16 __intentional_overflow(-1) get_unaligned_le16(const void *p)
71892 {
71893 - return le16_to_cpup((__le16 *)p);
71894 + return le16_to_cpup((const __le16 *)p);
71895 }
71896
71897 -static inline u32 get_unaligned_le32(const void *p)
71898 +static inline u32 __intentional_overflow(-1) get_unaligned_le32(const void *p)
71899 {
71900 - return le32_to_cpup((__le32 *)p);
71901 + return le32_to_cpup((const __le32 *)p);
71902 }
71903
71904 -static inline u64 get_unaligned_le64(const void *p)
71905 +static inline u64 __intentional_overflow(-1) get_unaligned_le64(const void *p)
71906 {
71907 - return le64_to_cpup((__le64 *)p);
71908 + return le64_to_cpup((const __le64 *)p);
71909 }
71910
71911 -static inline u16 get_unaligned_be16(const void *p)
71912 +static inline u16 __intentional_overflow(-1) get_unaligned_be16(const void *p)
71913 {
71914 - return be16_to_cpup((__be16 *)p);
71915 + return be16_to_cpup((const __be16 *)p);
71916 }
71917
71918 -static inline u32 get_unaligned_be32(const void *p)
71919 +static inline u32 __intentional_overflow(-1) get_unaligned_be32(const void *p)
71920 {
71921 - return be32_to_cpup((__be32 *)p);
71922 + return be32_to_cpup((const __be32 *)p);
71923 }
71924
71925 -static inline u64 get_unaligned_be64(const void *p)
71926 +static inline u64 __intentional_overflow(-1) get_unaligned_be64(const void *p)
71927 {
71928 - return be64_to_cpup((__be64 *)p);
71929 + return be64_to_cpup((const __be64 *)p);
71930 }
71931
71932 static inline void put_unaligned_le16(u16 val, void *p)
71933 diff --git a/include/linux/usb.h b/include/linux/usb.h
71934 index 4d22d0f..8d0e8f8 100644
71935 --- a/include/linux/usb.h
71936 +++ b/include/linux/usb.h
71937 @@ -554,7 +554,7 @@ struct usb_device {
71938 int maxchild;
71939
71940 u32 quirks;
71941 - atomic_t urbnum;
71942 + atomic_unchecked_t urbnum;
71943
71944 unsigned long active_duration;
71945
71946 @@ -1604,7 +1604,7 @@ void usb_buffer_unmap_sg(const struct usb_device *dev, int is_in,
71947
71948 extern int usb_control_msg(struct usb_device *dev, unsigned int pipe,
71949 __u8 request, __u8 requesttype, __u16 value, __u16 index,
71950 - void *data, __u16 size, int timeout);
71951 + void *data, __u16 size, int timeout) __intentional_overflow(-1);
71952 extern int usb_interrupt_msg(struct usb_device *usb_dev, unsigned int pipe,
71953 void *data, int len, int *actual_length, int timeout);
71954 extern int usb_bulk_msg(struct usb_device *usb_dev, unsigned int pipe,
71955 diff --git a/include/linux/usb/renesas_usbhs.h b/include/linux/usb/renesas_usbhs.h
71956 index c5d36c6..108f4f9 100644
71957 --- a/include/linux/usb/renesas_usbhs.h
71958 +++ b/include/linux/usb/renesas_usbhs.h
71959 @@ -39,7 +39,7 @@ enum {
71960 */
71961 struct renesas_usbhs_driver_callback {
71962 int (*notify_hotplug)(struct platform_device *pdev);
71963 -};
71964 +} __no_const;
71965
71966 /*
71967 * callback functions for platform
71968 diff --git a/include/linux/vermagic.h b/include/linux/vermagic.h
71969 index 6f8fbcf..8259001 100644
71970 --- a/include/linux/vermagic.h
71971 +++ b/include/linux/vermagic.h
71972 @@ -25,9 +25,35 @@
71973 #define MODULE_ARCH_VERMAGIC ""
71974 #endif
71975
71976 +#ifdef CONFIG_PAX_REFCOUNT
71977 +#define MODULE_PAX_REFCOUNT "REFCOUNT "
71978 +#else
71979 +#define MODULE_PAX_REFCOUNT ""
71980 +#endif
71981 +
71982 +#ifdef CONSTIFY_PLUGIN
71983 +#define MODULE_CONSTIFY_PLUGIN "CONSTIFY_PLUGIN "
71984 +#else
71985 +#define MODULE_CONSTIFY_PLUGIN ""
71986 +#endif
71987 +
71988 +#ifdef STACKLEAK_PLUGIN
71989 +#define MODULE_STACKLEAK_PLUGIN "STACKLEAK_PLUGIN "
71990 +#else
71991 +#define MODULE_STACKLEAK_PLUGIN ""
71992 +#endif
71993 +
71994 +#ifdef CONFIG_GRKERNSEC
71995 +#define MODULE_GRSEC "GRSEC "
71996 +#else
71997 +#define MODULE_GRSEC ""
71998 +#endif
71999 +
72000 #define VERMAGIC_STRING \
72001 UTS_RELEASE " " \
72002 MODULE_VERMAGIC_SMP MODULE_VERMAGIC_PREEMPT \
72003 MODULE_VERMAGIC_MODULE_UNLOAD MODULE_VERMAGIC_MODVERSIONS \
72004 - MODULE_ARCH_VERMAGIC
72005 + MODULE_ARCH_VERMAGIC \
72006 + MODULE_PAX_REFCOUNT MODULE_CONSTIFY_PLUGIN MODULE_STACKLEAK_PLUGIN \
72007 + MODULE_GRSEC
72008
72009 diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h
72010 index 6071e91..ca6a489 100644
72011 --- a/include/linux/vmalloc.h
72012 +++ b/include/linux/vmalloc.h
72013 @@ -14,6 +14,11 @@ struct vm_area_struct; /* vma defining user mapping in mm_types.h */
72014 #define VM_USERMAP 0x00000008 /* suitable for remap_vmalloc_range */
72015 #define VM_VPAGES 0x00000010 /* buffer for pages was vmalloc'ed */
72016 #define VM_UNLIST 0x00000020 /* vm_struct is not listed in vmlist */
72017 +
72018 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
72019 +#define VM_KERNEXEC 0x00000040 /* allocate from executable kernel memory range */
72020 +#endif
72021 +
72022 /* bits [20..32] reserved for arch specific ioremap internals */
72023
72024 /*
72025 @@ -62,7 +67,7 @@ extern void *vmalloc_32_user(unsigned long size);
72026 extern void *__vmalloc(unsigned long size, gfp_t gfp_mask, pgprot_t prot);
72027 extern void *__vmalloc_node_range(unsigned long size, unsigned long align,
72028 unsigned long start, unsigned long end, gfp_t gfp_mask,
72029 - pgprot_t prot, int node, const void *caller);
72030 + pgprot_t prot, int node, const void *caller) __size_overflow(1);
72031 extern void vfree(const void *addr);
72032
72033 extern void *vmap(struct page **pages, unsigned int count,
72034 @@ -124,8 +129,8 @@ extern struct vm_struct *alloc_vm_area(size_t size, pte_t **ptes);
72035 extern void free_vm_area(struct vm_struct *area);
72036
72037 /* for /dev/kmem */
72038 -extern long vread(char *buf, char *addr, unsigned long count);
72039 -extern long vwrite(char *buf, char *addr, unsigned long count);
72040 +extern long vread(char *buf, char *addr, unsigned long count) __size_overflow(3);
72041 +extern long vwrite(char *buf, char *addr, unsigned long count) __size_overflow(3);
72042
72043 /*
72044 * Internals. Dont't use..
72045 diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h
72046 index 5fd71a7..e5ef9a9 100644
72047 --- a/include/linux/vmstat.h
72048 +++ b/include/linux/vmstat.h
72049 @@ -95,18 +95,18 @@ static inline void vm_events_fold_cpu(int cpu)
72050 /*
72051 * Zone based page accounting with per cpu differentials.
72052 */
72053 -extern atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
72054 +extern atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
72055
72056 static inline void zone_page_state_add(long x, struct zone *zone,
72057 enum zone_stat_item item)
72058 {
72059 - atomic_long_add(x, &zone->vm_stat[item]);
72060 - atomic_long_add(x, &vm_stat[item]);
72061 + atomic_long_add_unchecked(x, &zone->vm_stat[item]);
72062 + atomic_long_add_unchecked(x, &vm_stat[item]);
72063 }
72064
72065 static inline unsigned long global_page_state(enum zone_stat_item item)
72066 {
72067 - long x = atomic_long_read(&vm_stat[item]);
72068 + long x = atomic_long_read_unchecked(&vm_stat[item]);
72069 #ifdef CONFIG_SMP
72070 if (x < 0)
72071 x = 0;
72072 @@ -117,7 +117,7 @@ static inline unsigned long global_page_state(enum zone_stat_item item)
72073 static inline unsigned long zone_page_state(struct zone *zone,
72074 enum zone_stat_item item)
72075 {
72076 - long x = atomic_long_read(&zone->vm_stat[item]);
72077 + long x = atomic_long_read_unchecked(&zone->vm_stat[item]);
72078 #ifdef CONFIG_SMP
72079 if (x < 0)
72080 x = 0;
72081 @@ -134,7 +134,7 @@ static inline unsigned long zone_page_state(struct zone *zone,
72082 static inline unsigned long zone_page_state_snapshot(struct zone *zone,
72083 enum zone_stat_item item)
72084 {
72085 - long x = atomic_long_read(&zone->vm_stat[item]);
72086 + long x = atomic_long_read_unchecked(&zone->vm_stat[item]);
72087
72088 #ifdef CONFIG_SMP
72089 int cpu;
72090 @@ -226,8 +226,8 @@ static inline void __mod_zone_page_state(struct zone *zone,
72091
72092 static inline void __inc_zone_state(struct zone *zone, enum zone_stat_item item)
72093 {
72094 - atomic_long_inc(&zone->vm_stat[item]);
72095 - atomic_long_inc(&vm_stat[item]);
72096 + atomic_long_inc_unchecked(&zone->vm_stat[item]);
72097 + atomic_long_inc_unchecked(&vm_stat[item]);
72098 }
72099
72100 static inline void __inc_zone_page_state(struct page *page,
72101 @@ -238,8 +238,8 @@ static inline void __inc_zone_page_state(struct page *page,
72102
72103 static inline void __dec_zone_state(struct zone *zone, enum zone_stat_item item)
72104 {
72105 - atomic_long_dec(&zone->vm_stat[item]);
72106 - atomic_long_dec(&vm_stat[item]);
72107 + atomic_long_dec_unchecked(&zone->vm_stat[item]);
72108 + atomic_long_dec_unchecked(&vm_stat[item]);
72109 }
72110
72111 static inline void __dec_zone_page_state(struct page *page,
72112 diff --git a/include/linux/xattr.h b/include/linux/xattr.h
72113 index fdbafc6..49dfe4f 100644
72114 --- a/include/linux/xattr.h
72115 +++ b/include/linux/xattr.h
72116 @@ -28,7 +28,7 @@ struct xattr_handler {
72117 size_t size, int handler_flags);
72118 int (*set)(struct dentry *dentry, const char *name, const void *buffer,
72119 size_t size, int flags, int handler_flags);
72120 -};
72121 +} __do_const;
72122
72123 struct xattr {
72124 char *name;
72125 @@ -37,6 +37,9 @@ struct xattr {
72126 };
72127
72128 ssize_t xattr_getsecurity(struct inode *, const char *, void *, size_t);
72129 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
72130 +ssize_t pax_getxattr(struct dentry *, void *, size_t);
72131 +#endif
72132 ssize_t vfs_getxattr(struct dentry *, const char *, void *, size_t);
72133 ssize_t vfs_listxattr(struct dentry *d, char *list, size_t size);
72134 int __vfs_setxattr_noperm(struct dentry *, const char *, const void *, size_t, int);
72135 diff --git a/include/linux/zlib.h b/include/linux/zlib.h
72136 index 9c5a6b4..09c9438 100644
72137 --- a/include/linux/zlib.h
72138 +++ b/include/linux/zlib.h
72139 @@ -31,6 +31,7 @@
72140 #define _ZLIB_H
72141
72142 #include <linux/zconf.h>
72143 +#include <linux/compiler.h>
72144
72145 /* zlib deflate based on ZLIB_VERSION "1.1.3" */
72146 /* zlib inflate based on ZLIB_VERSION "1.2.3" */
72147 @@ -179,7 +180,7 @@ typedef z_stream *z_streamp;
72148
72149 /* basic functions */
72150
72151 -extern int zlib_deflate_workspacesize (int windowBits, int memLevel);
72152 +extern int zlib_deflate_workspacesize (int windowBits, int memLevel) __intentional_overflow(0);
72153 /*
72154 Returns the number of bytes that needs to be allocated for a per-
72155 stream workspace with the specified parameters. A pointer to this
72156 diff --git a/include/media/v4l2-dev.h b/include/media/v4l2-dev.h
72157 index 95d1c91..6798cca 100644
72158 --- a/include/media/v4l2-dev.h
72159 +++ b/include/media/v4l2-dev.h
72160 @@ -76,7 +76,7 @@ struct v4l2_file_operations {
72161 int (*mmap) (struct file *, struct vm_area_struct *);
72162 int (*open) (struct file *);
72163 int (*release) (struct file *);
72164 -};
72165 +} __do_const;
72166
72167 /*
72168 * Newer version of video_device, handled by videodev2.c
72169 diff --git a/include/media/v4l2-ioctl.h b/include/media/v4l2-ioctl.h
72170 index 4118ad1..cb7e25f 100644
72171 --- a/include/media/v4l2-ioctl.h
72172 +++ b/include/media/v4l2-ioctl.h
72173 @@ -284,7 +284,6 @@ struct v4l2_ioctl_ops {
72174 bool valid_prio, int cmd, void *arg);
72175 };
72176
72177 -
72178 /* v4l debugging and diagnostics */
72179
72180 /* Debug bitmask flags to be used on V4L2 */
72181 diff --git a/include/net/9p/transport.h b/include/net/9p/transport.h
72182 index adcbb20..62c2559 100644
72183 --- a/include/net/9p/transport.h
72184 +++ b/include/net/9p/transport.h
72185 @@ -57,7 +57,7 @@ struct p9_trans_module {
72186 int (*cancel) (struct p9_client *, struct p9_req_t *req);
72187 int (*zc_request)(struct p9_client *, struct p9_req_t *,
72188 char *, char *, int , int, int, int);
72189 -};
72190 +} __do_const;
72191
72192 void v9fs_register_trans(struct p9_trans_module *m);
72193 void v9fs_unregister_trans(struct p9_trans_module *m);
72194 diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
72195 index cdd3302..76f8ede 100644
72196 --- a/include/net/bluetooth/l2cap.h
72197 +++ b/include/net/bluetooth/l2cap.h
72198 @@ -551,7 +551,7 @@ struct l2cap_ops {
72199 void (*defer) (struct l2cap_chan *chan);
72200 struct sk_buff *(*alloc_skb) (struct l2cap_chan *chan,
72201 unsigned long len, int nb);
72202 -};
72203 +} __do_const;
72204
72205 struct l2cap_conn {
72206 struct hci_conn *hcon;
72207 diff --git a/include/net/caif/cfctrl.h b/include/net/caif/cfctrl.h
72208 index 9e5425b..8136ffc 100644
72209 --- a/include/net/caif/cfctrl.h
72210 +++ b/include/net/caif/cfctrl.h
72211 @@ -52,7 +52,7 @@ struct cfctrl_rsp {
72212 void (*radioset_rsp)(void);
72213 void (*reject_rsp)(struct cflayer *layer, u8 linkid,
72214 struct cflayer *client_layer);
72215 -};
72216 +} __no_const;
72217
72218 /* Link Setup Parameters for CAIF-Links. */
72219 struct cfctrl_link_param {
72220 @@ -101,8 +101,8 @@ struct cfctrl_request_info {
72221 struct cfctrl {
72222 struct cfsrvl serv;
72223 struct cfctrl_rsp res;
72224 - atomic_t req_seq_no;
72225 - atomic_t rsp_seq_no;
72226 + atomic_unchecked_t req_seq_no;
72227 + atomic_unchecked_t rsp_seq_no;
72228 struct list_head list;
72229 /* Protects from simultaneous access to first_req list */
72230 spinlock_t info_list_lock;
72231 diff --git a/include/net/flow.h b/include/net/flow.h
72232 index 628e11b..4c475df 100644
72233 --- a/include/net/flow.h
72234 +++ b/include/net/flow.h
72235 @@ -221,6 +221,6 @@ extern struct flow_cache_object *flow_cache_lookup(
72236
72237 extern void flow_cache_flush(void);
72238 extern void flow_cache_flush_deferred(void);
72239 -extern atomic_t flow_cache_genid;
72240 +extern atomic_unchecked_t flow_cache_genid;
72241
72242 #endif
72243 diff --git a/include/net/genetlink.h b/include/net/genetlink.h
72244 index bdfbe68..4402ebe 100644
72245 --- a/include/net/genetlink.h
72246 +++ b/include/net/genetlink.h
72247 @@ -118,7 +118,7 @@ struct genl_ops {
72248 struct netlink_callback *cb);
72249 int (*done)(struct netlink_callback *cb);
72250 struct list_head ops_list;
72251 -};
72252 +} __do_const;
72253
72254 extern int genl_register_family(struct genl_family *family);
72255 extern int genl_register_family_with_ops(struct genl_family *family,
72256 diff --git a/include/net/gro_cells.h b/include/net/gro_cells.h
72257 index 734d9b5..48a9a4b 100644
72258 --- a/include/net/gro_cells.h
72259 +++ b/include/net/gro_cells.h
72260 @@ -29,7 +29,7 @@ static inline void gro_cells_receive(struct gro_cells *gcells, struct sk_buff *s
72261 cell += skb_get_rx_queue(skb) & gcells->gro_cells_mask;
72262
72263 if (skb_queue_len(&cell->napi_skbs) > netdev_max_backlog) {
72264 - atomic_long_inc(&dev->rx_dropped);
72265 + atomic_long_inc_unchecked(&dev->rx_dropped);
72266 kfree_skb(skb);
72267 return;
72268 }
72269 diff --git a/include/net/inet_connection_sock.h b/include/net/inet_connection_sock.h
72270 index 1832927..ce39aea 100644
72271 --- a/include/net/inet_connection_sock.h
72272 +++ b/include/net/inet_connection_sock.h
72273 @@ -62,7 +62,7 @@ struct inet_connection_sock_af_ops {
72274 void (*addr2sockaddr)(struct sock *sk, struct sockaddr *);
72275 int (*bind_conflict)(const struct sock *sk,
72276 const struct inet_bind_bucket *tb, bool relax);
72277 -};
72278 +} __do_const;
72279
72280 /** inet_connection_sock - INET connection oriented sock
72281 *
72282 diff --git a/include/net/inetpeer.h b/include/net/inetpeer.h
72283 index 53f464d..ba76aaa 100644
72284 --- a/include/net/inetpeer.h
72285 +++ b/include/net/inetpeer.h
72286 @@ -47,8 +47,8 @@ struct inet_peer {
72287 */
72288 union {
72289 struct {
72290 - atomic_t rid; /* Frag reception counter */
72291 - atomic_t ip_id_count; /* IP ID for the next packet */
72292 + atomic_unchecked_t rid; /* Frag reception counter */
72293 + atomic_unchecked_t ip_id_count; /* IP ID for the next packet */
72294 };
72295 struct rcu_head rcu;
72296 struct inet_peer *gc_next;
72297 @@ -182,11 +182,11 @@ static inline int inet_getid(struct inet_peer *p, int more)
72298 more++;
72299 inet_peer_refcheck(p);
72300 do {
72301 - old = atomic_read(&p->ip_id_count);
72302 + old = atomic_read_unchecked(&p->ip_id_count);
72303 new = old + more;
72304 if (!new)
72305 new = 1;
72306 - } while (atomic_cmpxchg(&p->ip_id_count, old, new) != old);
72307 + } while (atomic_cmpxchg_unchecked(&p->ip_id_count, old, new) != old);
72308 return new;
72309 }
72310
72311 diff --git a/include/net/ip.h b/include/net/ip.h
72312 index a68f838..74518ab 100644
72313 --- a/include/net/ip.h
72314 +++ b/include/net/ip.h
72315 @@ -202,7 +202,7 @@ extern struct local_ports {
72316 } sysctl_local_ports;
72317 extern void inet_get_local_port_range(int *low, int *high);
72318
72319 -extern unsigned long *sysctl_local_reserved_ports;
72320 +extern unsigned long sysctl_local_reserved_ports[65536 / 8 / sizeof(unsigned long)];
72321 static inline int inet_is_reserved_local_port(int port)
72322 {
72323 return test_bit(port, sysctl_local_reserved_ports);
72324 diff --git a/include/net/ip_fib.h b/include/net/ip_fib.h
72325 index e49db91..76a81de 100644
72326 --- a/include/net/ip_fib.h
72327 +++ b/include/net/ip_fib.h
72328 @@ -167,7 +167,7 @@ extern __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh);
72329
72330 #define FIB_RES_SADDR(net, res) \
72331 ((FIB_RES_NH(res).nh_saddr_genid == \
72332 - atomic_read(&(net)->ipv4.dev_addr_genid)) ? \
72333 + atomic_read_unchecked(&(net)->ipv4.dev_addr_genid)) ? \
72334 FIB_RES_NH(res).nh_saddr : \
72335 fib_info_update_nh_saddr((net), &FIB_RES_NH(res)))
72336 #define FIB_RES_GW(res) (FIB_RES_NH(res).nh_gw)
72337 diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h
72338 index fce8e6b..3ca4916 100644
72339 --- a/include/net/ip_vs.h
72340 +++ b/include/net/ip_vs.h
72341 @@ -599,7 +599,7 @@ struct ip_vs_conn {
72342 struct ip_vs_conn *control; /* Master control connection */
72343 atomic_t n_control; /* Number of controlled ones */
72344 struct ip_vs_dest *dest; /* real server */
72345 - atomic_t in_pkts; /* incoming packet counter */
72346 + atomic_unchecked_t in_pkts; /* incoming packet counter */
72347
72348 /* packet transmitter for different forwarding methods. If it
72349 mangles the packet, it must return NF_DROP or better NF_STOLEN,
72350 @@ -737,7 +737,7 @@ struct ip_vs_dest {
72351 __be16 port; /* port number of the server */
72352 union nf_inet_addr addr; /* IP address of the server */
72353 volatile unsigned int flags; /* dest status flags */
72354 - atomic_t conn_flags; /* flags to copy to conn */
72355 + atomic_unchecked_t conn_flags; /* flags to copy to conn */
72356 atomic_t weight; /* server weight */
72357
72358 atomic_t refcnt; /* reference counter */
72359 @@ -981,11 +981,11 @@ struct netns_ipvs {
72360 /* ip_vs_lblc */
72361 int sysctl_lblc_expiration;
72362 struct ctl_table_header *lblc_ctl_header;
72363 - struct ctl_table *lblc_ctl_table;
72364 + ctl_table_no_const *lblc_ctl_table;
72365 /* ip_vs_lblcr */
72366 int sysctl_lblcr_expiration;
72367 struct ctl_table_header *lblcr_ctl_header;
72368 - struct ctl_table *lblcr_ctl_table;
72369 + ctl_table_no_const *lblcr_ctl_table;
72370 /* ip_vs_est */
72371 struct list_head est_list; /* estimator list */
72372 spinlock_t est_lock;
72373 diff --git a/include/net/irda/ircomm_tty.h b/include/net/irda/ircomm_tty.h
72374 index 80ffde3..968b0f4 100644
72375 --- a/include/net/irda/ircomm_tty.h
72376 +++ b/include/net/irda/ircomm_tty.h
72377 @@ -35,6 +35,7 @@
72378 #include <linux/termios.h>
72379 #include <linux/timer.h>
72380 #include <linux/tty.h> /* struct tty_struct */
72381 +#include <asm/local.h>
72382
72383 #include <net/irda/irias_object.h>
72384 #include <net/irda/ircomm_core.h>
72385 diff --git a/include/net/iucv/af_iucv.h b/include/net/iucv/af_iucv.h
72386 index 714cc9a..ea05f3e 100644
72387 --- a/include/net/iucv/af_iucv.h
72388 +++ b/include/net/iucv/af_iucv.h
72389 @@ -149,7 +149,7 @@ struct iucv_skb_cb {
72390 struct iucv_sock_list {
72391 struct hlist_head head;
72392 rwlock_t lock;
72393 - atomic_t autobind_name;
72394 + atomic_unchecked_t autobind_name;
72395 };
72396
72397 unsigned int iucv_sock_poll(struct file *file, struct socket *sock,
72398 diff --git a/include/net/llc_c_ac.h b/include/net/llc_c_ac.h
72399 index df83f69..9b640b8 100644
72400 --- a/include/net/llc_c_ac.h
72401 +++ b/include/net/llc_c_ac.h
72402 @@ -87,7 +87,7 @@
72403 #define LLC_CONN_AC_STOP_SENDACK_TMR 70
72404 #define LLC_CONN_AC_START_SENDACK_TMR_IF_NOT_RUNNING 71
72405
72406 -typedef int (*llc_conn_action_t)(struct sock *sk, struct sk_buff *skb);
72407 +typedef int (* const llc_conn_action_t)(struct sock *sk, struct sk_buff *skb);
72408
72409 extern int llc_conn_ac_clear_remote_busy(struct sock *sk, struct sk_buff *skb);
72410 extern int llc_conn_ac_conn_ind(struct sock *sk, struct sk_buff *skb);
72411 diff --git a/include/net/llc_c_ev.h b/include/net/llc_c_ev.h
72412 index 6ca3113..f8026dd 100644
72413 --- a/include/net/llc_c_ev.h
72414 +++ b/include/net/llc_c_ev.h
72415 @@ -125,8 +125,8 @@ static __inline__ struct llc_conn_state_ev *llc_conn_ev(struct sk_buff *skb)
72416 return (struct llc_conn_state_ev *)skb->cb;
72417 }
72418
72419 -typedef int (*llc_conn_ev_t)(struct sock *sk, struct sk_buff *skb);
72420 -typedef int (*llc_conn_ev_qfyr_t)(struct sock *sk, struct sk_buff *skb);
72421 +typedef int (* const llc_conn_ev_t)(struct sock *sk, struct sk_buff *skb);
72422 +typedef int (* const llc_conn_ev_qfyr_t)(struct sock *sk, struct sk_buff *skb);
72423
72424 extern int llc_conn_ev_conn_req(struct sock *sk, struct sk_buff *skb);
72425 extern int llc_conn_ev_data_req(struct sock *sk, struct sk_buff *skb);
72426 diff --git a/include/net/llc_c_st.h b/include/net/llc_c_st.h
72427 index 0e79cfb..f46db31 100644
72428 --- a/include/net/llc_c_st.h
72429 +++ b/include/net/llc_c_st.h
72430 @@ -37,7 +37,7 @@ struct llc_conn_state_trans {
72431 u8 next_state;
72432 llc_conn_ev_qfyr_t *ev_qualifiers;
72433 llc_conn_action_t *ev_actions;
72434 -};
72435 +} __do_const;
72436
72437 struct llc_conn_state {
72438 u8 current_state;
72439 diff --git a/include/net/llc_s_ac.h b/include/net/llc_s_ac.h
72440 index 37a3bbd..55a4241 100644
72441 --- a/include/net/llc_s_ac.h
72442 +++ b/include/net/llc_s_ac.h
72443 @@ -23,7 +23,7 @@
72444 #define SAP_ACT_TEST_IND 9
72445
72446 /* All action functions must look like this */
72447 -typedef int (*llc_sap_action_t)(struct llc_sap *sap, struct sk_buff *skb);
72448 +typedef int (* const llc_sap_action_t)(struct llc_sap *sap, struct sk_buff *skb);
72449
72450 extern int llc_sap_action_unitdata_ind(struct llc_sap *sap,
72451 struct sk_buff *skb);
72452 diff --git a/include/net/llc_s_st.h b/include/net/llc_s_st.h
72453 index 567c681..cd73ac0 100644
72454 --- a/include/net/llc_s_st.h
72455 +++ b/include/net/llc_s_st.h
72456 @@ -20,7 +20,7 @@ struct llc_sap_state_trans {
72457 llc_sap_ev_t ev;
72458 u8 next_state;
72459 llc_sap_action_t *ev_actions;
72460 -};
72461 +} __do_const;
72462
72463 struct llc_sap_state {
72464 u8 curr_state;
72465 diff --git a/include/net/mac80211.h b/include/net/mac80211.h
72466 index f7eba13..91ed983 100644
72467 --- a/include/net/mac80211.h
72468 +++ b/include/net/mac80211.h
72469 @@ -4119,7 +4119,7 @@ struct rate_control_ops {
72470 void (*add_sta_debugfs)(void *priv, void *priv_sta,
72471 struct dentry *dir);
72472 void (*remove_sta_debugfs)(void *priv, void *priv_sta);
72473 -};
72474 +} __do_const;
72475
72476 static inline int rate_supported(struct ieee80211_sta *sta,
72477 enum ieee80211_band band,
72478 diff --git a/include/net/neighbour.h b/include/net/neighbour.h
72479 index 7e748ad..5c6229b 100644
72480 --- a/include/net/neighbour.h
72481 +++ b/include/net/neighbour.h
72482 @@ -123,7 +123,7 @@ struct neigh_ops {
72483 void (*error_report)(struct neighbour *, struct sk_buff *);
72484 int (*output)(struct neighbour *, struct sk_buff *);
72485 int (*connected_output)(struct neighbour *, struct sk_buff *);
72486 -};
72487 +} __do_const;
72488
72489 struct pneigh_entry {
72490 struct pneigh_entry *next;
72491 diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h
72492 index de644bc..dfbcc4c 100644
72493 --- a/include/net/net_namespace.h
72494 +++ b/include/net/net_namespace.h
72495 @@ -115,7 +115,7 @@ struct net {
72496 #endif
72497 struct netns_ipvs *ipvs;
72498 struct sock *diag_nlsk;
72499 - atomic_t rt_genid;
72500 + atomic_unchecked_t rt_genid;
72501 };
72502
72503 /*
72504 @@ -272,7 +272,11 @@ static inline struct net *read_pnet(struct net * const *pnet)
72505 #define __net_init __init
72506 #define __net_exit __exit_refok
72507 #define __net_initdata __initdata
72508 +#ifdef CONSTIFY_PLUGIN
72509 #define __net_initconst __initconst
72510 +#else
72511 +#define __net_initconst __initdata
72512 +#endif
72513 #endif
72514
72515 struct pernet_operations {
72516 @@ -282,7 +286,7 @@ struct pernet_operations {
72517 void (*exit_batch)(struct list_head *net_exit_list);
72518 int *id;
72519 size_t size;
72520 -};
72521 +} __do_const;
72522
72523 /*
72524 * Use these carefully. If you implement a network device and it
72525 @@ -330,12 +334,12 @@ static inline void unregister_net_sysctl_table(struct ctl_table_header *header)
72526
72527 static inline int rt_genid(struct net *net)
72528 {
72529 - return atomic_read(&net->rt_genid);
72530 + return atomic_read_unchecked(&net->rt_genid);
72531 }
72532
72533 static inline void rt_genid_bump(struct net *net)
72534 {
72535 - atomic_inc(&net->rt_genid);
72536 + atomic_inc_unchecked(&net->rt_genid);
72537 }
72538
72539 #endif /* __NET_NET_NAMESPACE_H */
72540 diff --git a/include/net/netdma.h b/include/net/netdma.h
72541 index 8ba8ce2..99b7fff 100644
72542 --- a/include/net/netdma.h
72543 +++ b/include/net/netdma.h
72544 @@ -24,7 +24,7 @@
72545 #include <linux/dmaengine.h>
72546 #include <linux/skbuff.h>
72547
72548 -int dma_skb_copy_datagram_iovec(struct dma_chan* chan,
72549 +int __intentional_overflow(3,5) dma_skb_copy_datagram_iovec(struct dma_chan* chan,
72550 struct sk_buff *skb, int offset, struct iovec *to,
72551 size_t len, struct dma_pinned_list *pinned_list);
72552
72553 diff --git a/include/net/netlink.h b/include/net/netlink.h
72554 index 9690b0f..87aded7 100644
72555 --- a/include/net/netlink.h
72556 +++ b/include/net/netlink.h
72557 @@ -534,7 +534,7 @@ static inline void *nlmsg_get_pos(struct sk_buff *skb)
72558 static inline void nlmsg_trim(struct sk_buff *skb, const void *mark)
72559 {
72560 if (mark)
72561 - skb_trim(skb, (unsigned char *) mark - skb->data);
72562 + skb_trim(skb, (const unsigned char *) mark - skb->data);
72563 }
72564
72565 /**
72566 diff --git a/include/net/netns/conntrack.h b/include/net/netns/conntrack.h
72567 index c9c0c53..53f24c3 100644
72568 --- a/include/net/netns/conntrack.h
72569 +++ b/include/net/netns/conntrack.h
72570 @@ -12,10 +12,10 @@ struct nf_conntrack_ecache;
72571 struct nf_proto_net {
72572 #ifdef CONFIG_SYSCTL
72573 struct ctl_table_header *ctl_table_header;
72574 - struct ctl_table *ctl_table;
72575 + ctl_table_no_const *ctl_table;
72576 #ifdef CONFIG_NF_CONNTRACK_PROC_COMPAT
72577 struct ctl_table_header *ctl_compat_header;
72578 - struct ctl_table *ctl_compat_table;
72579 + ctl_table_no_const *ctl_compat_table;
72580 #endif
72581 #endif
72582 unsigned int users;
72583 @@ -58,7 +58,7 @@ struct nf_ip_net {
72584 struct nf_icmp_net icmpv6;
72585 #if defined(CONFIG_SYSCTL) && defined(CONFIG_NF_CONNTRACK_PROC_COMPAT)
72586 struct ctl_table_header *ctl_table_header;
72587 - struct ctl_table *ctl_table;
72588 + ctl_table_no_const *ctl_table;
72589 #endif
72590 };
72591
72592 diff --git a/include/net/netns/ipv4.h b/include/net/netns/ipv4.h
72593 index 2ba9de8..47bd6c7 100644
72594 --- a/include/net/netns/ipv4.h
72595 +++ b/include/net/netns/ipv4.h
72596 @@ -67,7 +67,7 @@ struct netns_ipv4 {
72597 kgid_t sysctl_ping_group_range[2];
72598 long sysctl_tcp_mem[3];
72599
72600 - atomic_t dev_addr_genid;
72601 + atomic_unchecked_t dev_addr_genid;
72602
72603 #ifdef CONFIG_IP_MROUTE
72604 #ifndef CONFIG_IP_MROUTE_MULTIPLE_TABLES
72605 diff --git a/include/net/protocol.h b/include/net/protocol.h
72606 index 047c047..b9dad15 100644
72607 --- a/include/net/protocol.h
72608 +++ b/include/net/protocol.h
72609 @@ -44,7 +44,7 @@ struct net_protocol {
72610 void (*err_handler)(struct sk_buff *skb, u32 info);
72611 unsigned int no_policy:1,
72612 netns_ok:1;
72613 -};
72614 +} __do_const;
72615
72616 #if IS_ENABLED(CONFIG_IPV6)
72617 struct inet6_protocol {
72618 @@ -57,7 +57,7 @@ struct inet6_protocol {
72619 u8 type, u8 code, int offset,
72620 __be32 info);
72621 unsigned int flags; /* INET6_PROTO_xxx */
72622 -};
72623 +} __do_const;
72624
72625 #define INET6_PROTO_NOPOLICY 0x1
72626 #define INET6_PROTO_FINAL 0x2
72627 diff --git a/include/net/rtnetlink.h b/include/net/rtnetlink.h
72628 index 5a15fab..d799ea7 100644
72629 --- a/include/net/rtnetlink.h
72630 +++ b/include/net/rtnetlink.h
72631 @@ -81,7 +81,7 @@ struct rtnl_link_ops {
72632 const struct net_device *dev);
72633 unsigned int (*get_num_tx_queues)(void);
72634 unsigned int (*get_num_rx_queues)(void);
72635 -};
72636 +} __do_const;
72637
72638 extern int __rtnl_link_register(struct rtnl_link_ops *ops);
72639 extern void __rtnl_link_unregister(struct rtnl_link_ops *ops);
72640 diff --git a/include/net/sctp/sctp.h b/include/net/sctp/sctp.h
72641 index df85a0c..19ac300 100644
72642 --- a/include/net/sctp/sctp.h
72643 +++ b/include/net/sctp/sctp.h
72644 @@ -330,9 +330,9 @@ do { \
72645
72646 #else /* SCTP_DEBUG */
72647
72648 -#define SCTP_DEBUG_PRINTK(whatever...)
72649 -#define SCTP_DEBUG_PRINTK_CONT(fmt, args...)
72650 -#define SCTP_DEBUG_PRINTK_IPADDR(whatever...)
72651 +#define SCTP_DEBUG_PRINTK(whatever...) do {} while (0)
72652 +#define SCTP_DEBUG_PRINTK_CONT(fmt, args...) do {} while (0)
72653 +#define SCTP_DEBUG_PRINTK_IPADDR(whatever...) do {} while (0)
72654 #define SCTP_ENABLE_DEBUG
72655 #define SCTP_DISABLE_DEBUG
72656 #define SCTP_ASSERT(expr, str, func)
72657 diff --git a/include/net/sctp/sm.h b/include/net/sctp/sm.h
72658 index 2a82d13..62a31c2 100644
72659 --- a/include/net/sctp/sm.h
72660 +++ b/include/net/sctp/sm.h
72661 @@ -87,7 +87,7 @@ typedef void (sctp_timer_event_t) (unsigned long);
72662 typedef struct {
72663 sctp_state_fn_t *fn;
72664 const char *name;
72665 -} sctp_sm_table_entry_t;
72666 +} __do_const sctp_sm_table_entry_t;
72667
72668 /* A naming convention of "sctp_sf_xxx" applies to all the state functions
72669 * currently in use.
72670 @@ -299,7 +299,7 @@ __u32 sctp_generate_tag(const struct sctp_endpoint *);
72671 __u32 sctp_generate_tsn(const struct sctp_endpoint *);
72672
72673 /* Extern declarations for major data structures. */
72674 -extern sctp_timer_event_t *sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES];
72675 +extern sctp_timer_event_t * const sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES];
72676
72677
72678 /* Get the size of a DATA chunk payload. */
72679 diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h
72680 index 0e0f9d2..cd05ebb 100644
72681 --- a/include/net/sctp/structs.h
72682 +++ b/include/net/sctp/structs.h
72683 @@ -517,7 +517,7 @@ struct sctp_pf {
72684 struct sctp_association *asoc);
72685 void (*addr_v4map) (struct sctp_sock *, union sctp_addr *);
72686 struct sctp_af *af;
72687 -};
72688 +} __do_const;
72689
72690
72691 /* Structure to track chunk fragments that have been acked, but peer
72692 diff --git a/include/net/secure_seq.h b/include/net/secure_seq.h
72693 index c2e542b..6ca975b 100644
72694 --- a/include/net/secure_seq.h
72695 +++ b/include/net/secure_seq.h
72696 @@ -3,6 +3,7 @@
72697
72698 #include <linux/types.h>
72699
72700 +extern void net_secret_init(void);
72701 extern __u32 secure_ip_id(__be32 daddr);
72702 extern __u32 secure_ipv6_id(const __be32 daddr[4]);
72703 extern u32 secure_ipv4_port_ephemeral(__be32 saddr, __be32 daddr, __be16 dport);
72704 diff --git a/include/net/sock.h b/include/net/sock.h
72705 index 0be480a..586232f 100644
72706 --- a/include/net/sock.h
72707 +++ b/include/net/sock.h
72708 @@ -325,7 +325,7 @@ struct sock {
72709 #ifdef CONFIG_RPS
72710 __u32 sk_rxhash;
72711 #endif
72712 - atomic_t sk_drops;
72713 + atomic_unchecked_t sk_drops;
72714 int sk_rcvbuf;
72715
72716 struct sk_filter __rcu *sk_filter;
72717 @@ -1796,7 +1796,7 @@ static inline void sk_nocaps_add(struct sock *sk, netdev_features_t flags)
72718 }
72719
72720 static inline int skb_do_copy_data_nocache(struct sock *sk, struct sk_buff *skb,
72721 - char __user *from, char *to,
72722 + char __user *from, unsigned char *to,
72723 int copy, int offset)
72724 {
72725 if (skb->ip_summed == CHECKSUM_NONE) {
72726 @@ -2055,7 +2055,7 @@ static inline void sk_stream_moderate_sndbuf(struct sock *sk)
72727 }
72728 }
72729
72730 -struct sk_buff *sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp);
72731 +struct sk_buff * __intentional_overflow(0) sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp);
72732
72733 /**
72734 * sk_page_frag - return an appropriate page_frag
72735 diff --git a/include/net/tcp.h b/include/net/tcp.h
72736 index a345480..3c65cf4 100644
72737 --- a/include/net/tcp.h
72738 +++ b/include/net/tcp.h
72739 @@ -529,7 +529,7 @@ extern void tcp_retransmit_timer(struct sock *sk);
72740 extern void tcp_xmit_retransmit_queue(struct sock *);
72741 extern void tcp_simple_retransmit(struct sock *);
72742 extern int tcp_trim_head(struct sock *, struct sk_buff *, u32);
72743 -extern int tcp_fragment(struct sock *, struct sk_buff *, u32, unsigned int);
72744 +extern int __intentional_overflow(3) tcp_fragment(struct sock *, struct sk_buff *, u32, unsigned int);
72745
72746 extern void tcp_send_probe0(struct sock *);
72747 extern void tcp_send_partial(struct sock *);
72748 @@ -700,8 +700,8 @@ struct tcp_skb_cb {
72749 struct inet6_skb_parm h6;
72750 #endif
72751 } header; /* For incoming frames */
72752 - __u32 seq; /* Starting sequence number */
72753 - __u32 end_seq; /* SEQ + FIN + SYN + datalen */
72754 + __u32 seq __intentional_overflow(0); /* Starting sequence number */
72755 + __u32 end_seq __intentional_overflow(0); /* SEQ + FIN + SYN + datalen */
72756 __u32 when; /* used to compute rtt's */
72757 __u8 tcp_flags; /* TCP header flags. (tcp[13]) */
72758
72759 @@ -715,7 +715,7 @@ struct tcp_skb_cb {
72760
72761 __u8 ip_dsfield; /* IPv4 tos or IPv6 dsfield */
72762 /* 1 byte hole */
72763 - __u32 ack_seq; /* Sequence number ACK'd */
72764 + __u32 ack_seq __intentional_overflow(0); /* Sequence number ACK'd */
72765 };
72766
72767 #define TCP_SKB_CB(__skb) ((struct tcp_skb_cb *)&((__skb)->cb[0]))
72768 diff --git a/include/net/xfrm.h b/include/net/xfrm.h
72769 index 24c8886..e6fb816 100644
72770 --- a/include/net/xfrm.h
72771 +++ b/include/net/xfrm.h
72772 @@ -304,7 +304,7 @@ struct xfrm_policy_afinfo {
72773 struct net_device *dev,
72774 const struct flowi *fl);
72775 struct dst_entry *(*blackhole_route)(struct net *net, struct dst_entry *orig);
72776 -};
72777 +} __do_const;
72778
72779 extern int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo);
72780 extern int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo);
72781 @@ -340,7 +340,7 @@ struct xfrm_state_afinfo {
72782 struct sk_buff *skb);
72783 int (*transport_finish)(struct sk_buff *skb,
72784 int async);
72785 -};
72786 +} __do_const;
72787
72788 extern int xfrm_state_register_afinfo(struct xfrm_state_afinfo *afinfo);
72789 extern int xfrm_state_unregister_afinfo(struct xfrm_state_afinfo *afinfo);
72790 @@ -423,7 +423,7 @@ struct xfrm_mode {
72791 struct module *owner;
72792 unsigned int encap;
72793 int flags;
72794 -};
72795 +} __do_const;
72796
72797 /* Flags for xfrm_mode. */
72798 enum {
72799 @@ -520,7 +520,7 @@ struct xfrm_policy {
72800 struct timer_list timer;
72801
72802 struct flow_cache_object flo;
72803 - atomic_t genid;
72804 + atomic_unchecked_t genid;
72805 u32 priority;
72806 u32 index;
72807 struct xfrm_mark mark;
72808 diff --git a/include/rdma/iw_cm.h b/include/rdma/iw_cm.h
72809 index 1a046b1..ee0bef0 100644
72810 --- a/include/rdma/iw_cm.h
72811 +++ b/include/rdma/iw_cm.h
72812 @@ -122,7 +122,7 @@ struct iw_cm_verbs {
72813 int backlog);
72814
72815 int (*destroy_listen)(struct iw_cm_id *cm_id);
72816 -};
72817 +} __no_const;
72818
72819 /**
72820 * iw_create_cm_id - Create an IW CM identifier.
72821 diff --git a/include/scsi/libfc.h b/include/scsi/libfc.h
72822 index e1379b4..67eafbe 100644
72823 --- a/include/scsi/libfc.h
72824 +++ b/include/scsi/libfc.h
72825 @@ -762,6 +762,7 @@ struct libfc_function_template {
72826 */
72827 void (*disc_stop_final) (struct fc_lport *);
72828 };
72829 +typedef struct libfc_function_template __no_const libfc_function_template_no_const;
72830
72831 /**
72832 * struct fc_disc - Discovery context
72833 @@ -866,7 +867,7 @@ struct fc_lport {
72834 struct fc_vport *vport;
72835
72836 /* Operational Information */
72837 - struct libfc_function_template tt;
72838 + libfc_function_template_no_const tt;
72839 u8 link_up;
72840 u8 qfull;
72841 enum fc_lport_state state;
72842 diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
72843 index a7f9cba..b1f44d0 100644
72844 --- a/include/scsi/scsi_device.h
72845 +++ b/include/scsi/scsi_device.h
72846 @@ -171,9 +171,9 @@ struct scsi_device {
72847 unsigned int max_device_blocked; /* what device_blocked counts down from */
72848 #define SCSI_DEFAULT_DEVICE_BLOCKED 3
72849
72850 - atomic_t iorequest_cnt;
72851 - atomic_t iodone_cnt;
72852 - atomic_t ioerr_cnt;
72853 + atomic_unchecked_t iorequest_cnt;
72854 + atomic_unchecked_t iodone_cnt;
72855 + atomic_unchecked_t ioerr_cnt;
72856
72857 struct device sdev_gendev,
72858 sdev_dev;
72859 diff --git a/include/scsi/scsi_transport_fc.h b/include/scsi/scsi_transport_fc.h
72860 index b797e8f..8e2c3aa 100644
72861 --- a/include/scsi/scsi_transport_fc.h
72862 +++ b/include/scsi/scsi_transport_fc.h
72863 @@ -751,7 +751,8 @@ struct fc_function_template {
72864 unsigned long show_host_system_hostname:1;
72865
72866 unsigned long disable_target_scan:1;
72867 -};
72868 +} __do_const;
72869 +typedef struct fc_function_template __no_const fc_function_template_no_const;
72870
72871
72872 /**
72873 diff --git a/include/sound/compress_driver.h b/include/sound/compress_driver.h
72874 index ff6c741..393815f 100644
72875 --- a/include/sound/compress_driver.h
72876 +++ b/include/sound/compress_driver.h
72877 @@ -130,7 +130,7 @@ struct snd_compr_ops {
72878 struct snd_compr_caps *caps);
72879 int (*get_codec_caps) (struct snd_compr_stream *stream,
72880 struct snd_compr_codec_caps *codec);
72881 -};
72882 +} __no_const;
72883
72884 /**
72885 * struct snd_compr: Compressed device
72886 diff --git a/include/sound/soc.h b/include/sound/soc.h
72887 index a6a059c..2243336 100644
72888 --- a/include/sound/soc.h
72889 +++ b/include/sound/soc.h
72890 @@ -771,7 +771,7 @@ struct snd_soc_codec_driver {
72891 /* probe ordering - for components with runtime dependencies */
72892 int probe_order;
72893 int remove_order;
72894 -};
72895 +} __do_const;
72896
72897 /* SoC platform interface */
72898 struct snd_soc_platform_driver {
72899 @@ -817,7 +817,7 @@ struct snd_soc_platform_driver {
72900 unsigned int (*read)(struct snd_soc_platform *, unsigned int);
72901 int (*write)(struct snd_soc_platform *, unsigned int, unsigned int);
72902 int (*bespoke_trigger)(struct snd_pcm_substream *, int);
72903 -};
72904 +} __do_const;
72905
72906 struct snd_soc_platform {
72907 const char *name;
72908 diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h
72909 index c4af592..20c52d2 100644
72910 --- a/include/target/target_core_base.h
72911 +++ b/include/target/target_core_base.h
72912 @@ -657,7 +657,7 @@ struct se_device {
72913 spinlock_t stats_lock;
72914 /* Active commands on this virtual SE device */
72915 atomic_t simple_cmds;
72916 - atomic_t dev_ordered_id;
72917 + atomic_unchecked_t dev_ordered_id;
72918 atomic_t dev_ordered_sync;
72919 atomic_t dev_qf_count;
72920 int export_count;
72921 diff --git a/include/trace/events/fs.h b/include/trace/events/fs.h
72922 new file mode 100644
72923 index 0000000..fb634b7
72924 --- /dev/null
72925 +++ b/include/trace/events/fs.h
72926 @@ -0,0 +1,53 @@
72927 +#undef TRACE_SYSTEM
72928 +#define TRACE_SYSTEM fs
72929 +
72930 +#if !defined(_TRACE_FS_H) || defined(TRACE_HEADER_MULTI_READ)
72931 +#define _TRACE_FS_H
72932 +
72933 +#include <linux/fs.h>
72934 +#include <linux/tracepoint.h>
72935 +
72936 +TRACE_EVENT(do_sys_open,
72937 +
72938 + TP_PROTO(const char *filename, int flags, int mode),
72939 +
72940 + TP_ARGS(filename, flags, mode),
72941 +
72942 + TP_STRUCT__entry(
72943 + __string( filename, filename )
72944 + __field( int, flags )
72945 + __field( int, mode )
72946 + ),
72947 +
72948 + TP_fast_assign(
72949 + __assign_str(filename, filename);
72950 + __entry->flags = flags;
72951 + __entry->mode = mode;
72952 + ),
72953 +
72954 + TP_printk("\"%s\" %x %o",
72955 + __get_str(filename), __entry->flags, __entry->mode)
72956 +);
72957 +
72958 +TRACE_EVENT(open_exec,
72959 +
72960 + TP_PROTO(const char *filename),
72961 +
72962 + TP_ARGS(filename),
72963 +
72964 + TP_STRUCT__entry(
72965 + __string( filename, filename )
72966 + ),
72967 +
72968 + TP_fast_assign(
72969 + __assign_str(filename, filename);
72970 + ),
72971 +
72972 + TP_printk("\"%s\"",
72973 + __get_str(filename))
72974 +);
72975 +
72976 +#endif /* _TRACE_FS_H */
72977 +
72978 +/* This part must be outside protection */
72979 +#include <trace/define_trace.h>
72980 diff --git a/include/trace/events/irq.h b/include/trace/events/irq.h
72981 index 1c09820..7f5ec79 100644
72982 --- a/include/trace/events/irq.h
72983 +++ b/include/trace/events/irq.h
72984 @@ -36,7 +36,7 @@ struct softirq_action;
72985 */
72986 TRACE_EVENT(irq_handler_entry,
72987
72988 - TP_PROTO(int irq, struct irqaction *action),
72989 + TP_PROTO(int irq, const struct irqaction *action),
72990
72991 TP_ARGS(irq, action),
72992
72993 @@ -66,7 +66,7 @@ TRACE_EVENT(irq_handler_entry,
72994 */
72995 TRACE_EVENT(irq_handler_exit,
72996
72997 - TP_PROTO(int irq, struct irqaction *action, int ret),
72998 + TP_PROTO(int irq, const struct irqaction *action, int ret),
72999
73000 TP_ARGS(irq, action, ret),
73001
73002 diff --git a/include/uapi/linux/a.out.h b/include/uapi/linux/a.out.h
73003 index 7caf44c..23c6f27 100644
73004 --- a/include/uapi/linux/a.out.h
73005 +++ b/include/uapi/linux/a.out.h
73006 @@ -39,6 +39,14 @@ enum machine_type {
73007 M_MIPS2 = 152 /* MIPS R6000/R4000 binary */
73008 };
73009
73010 +/* Constants for the N_FLAGS field */
73011 +#define F_PAX_PAGEEXEC 1 /* Paging based non-executable pages */
73012 +#define F_PAX_EMUTRAMP 2 /* Emulate trampolines */
73013 +#define F_PAX_MPROTECT 4 /* Restrict mprotect() */
73014 +#define F_PAX_RANDMMAP 8 /* Randomize mmap() base */
73015 +/*#define F_PAX_RANDEXEC 16*/ /* Randomize ET_EXEC base */
73016 +#define F_PAX_SEGMEXEC 32 /* Segmentation based non-executable pages */
73017 +
73018 #if !defined (N_MAGIC)
73019 #define N_MAGIC(exec) ((exec).a_info & 0xffff)
73020 #endif
73021 diff --git a/include/uapi/linux/byteorder/little_endian.h b/include/uapi/linux/byteorder/little_endian.h
73022 index d876736..ccce5c0 100644
73023 --- a/include/uapi/linux/byteorder/little_endian.h
73024 +++ b/include/uapi/linux/byteorder/little_endian.h
73025 @@ -42,51 +42,51 @@
73026
73027 static inline __le64 __cpu_to_le64p(const __u64 *p)
73028 {
73029 - return (__force __le64)*p;
73030 + return (__force const __le64)*p;
73031 }
73032 -static inline __u64 __le64_to_cpup(const __le64 *p)
73033 +static inline __u64 __intentional_overflow(-1) __le64_to_cpup(const __le64 *p)
73034 {
73035 - return (__force __u64)*p;
73036 + return (__force const __u64)*p;
73037 }
73038 static inline __le32 __cpu_to_le32p(const __u32 *p)
73039 {
73040 - return (__force __le32)*p;
73041 + return (__force const __le32)*p;
73042 }
73043 static inline __u32 __le32_to_cpup(const __le32 *p)
73044 {
73045 - return (__force __u32)*p;
73046 + return (__force const __u32)*p;
73047 }
73048 static inline __le16 __cpu_to_le16p(const __u16 *p)
73049 {
73050 - return (__force __le16)*p;
73051 + return (__force const __le16)*p;
73052 }
73053 static inline __u16 __le16_to_cpup(const __le16 *p)
73054 {
73055 - return (__force __u16)*p;
73056 + return (__force const __u16)*p;
73057 }
73058 static inline __be64 __cpu_to_be64p(const __u64 *p)
73059 {
73060 - return (__force __be64)__swab64p(p);
73061 + return (__force const __be64)__swab64p(p);
73062 }
73063 static inline __u64 __be64_to_cpup(const __be64 *p)
73064 {
73065 - return __swab64p((__u64 *)p);
73066 + return __swab64p((const __u64 *)p);
73067 }
73068 static inline __be32 __cpu_to_be32p(const __u32 *p)
73069 {
73070 - return (__force __be32)__swab32p(p);
73071 + return (__force const __be32)__swab32p(p);
73072 }
73073 -static inline __u32 __be32_to_cpup(const __be32 *p)
73074 +static inline __u32 __intentional_overflow(-1) __be32_to_cpup(const __be32 *p)
73075 {
73076 - return __swab32p((__u32 *)p);
73077 + return __swab32p((const __u32 *)p);
73078 }
73079 static inline __be16 __cpu_to_be16p(const __u16 *p)
73080 {
73081 - return (__force __be16)__swab16p(p);
73082 + return (__force const __be16)__swab16p(p);
73083 }
73084 static inline __u16 __be16_to_cpup(const __be16 *p)
73085 {
73086 - return __swab16p((__u16 *)p);
73087 + return __swab16p((const __u16 *)p);
73088 }
73089 #define __cpu_to_le64s(x) do { (void)(x); } while (0)
73090 #define __le64_to_cpus(x) do { (void)(x); } while (0)
73091 diff --git a/include/uapi/linux/elf.h b/include/uapi/linux/elf.h
73092 index 8072d35..e77aeb8 100644
73093 --- a/include/uapi/linux/elf.h
73094 +++ b/include/uapi/linux/elf.h
73095 @@ -37,6 +37,17 @@ typedef __s64 Elf64_Sxword;
73096 #define PT_GNU_EH_FRAME 0x6474e550
73097
73098 #define PT_GNU_STACK (PT_LOOS + 0x474e551)
73099 +#define PT_GNU_RELRO (PT_LOOS + 0x474e552)
73100 +
73101 +#define PT_PAX_FLAGS (PT_LOOS + 0x5041580)
73102 +
73103 +/* Constants for the e_flags field */
73104 +#define EF_PAX_PAGEEXEC 1 /* Paging based non-executable pages */
73105 +#define EF_PAX_EMUTRAMP 2 /* Emulate trampolines */
73106 +#define EF_PAX_MPROTECT 4 /* Restrict mprotect() */
73107 +#define EF_PAX_RANDMMAP 8 /* Randomize mmap() base */
73108 +/*#define EF_PAX_RANDEXEC 16*/ /* Randomize ET_EXEC base */
73109 +#define EF_PAX_SEGMEXEC 32 /* Segmentation based non-executable pages */
73110
73111 /*
73112 * Extended Numbering
73113 @@ -94,6 +105,8 @@ typedef __s64 Elf64_Sxword;
73114 #define DT_DEBUG 21
73115 #define DT_TEXTREL 22
73116 #define DT_JMPREL 23
73117 +#define DT_FLAGS 30
73118 + #define DF_TEXTREL 0x00000004
73119 #define DT_ENCODING 32
73120 #define OLD_DT_LOOS 0x60000000
73121 #define DT_LOOS 0x6000000d
73122 @@ -240,6 +253,19 @@ typedef struct elf64_hdr {
73123 #define PF_W 0x2
73124 #define PF_X 0x1
73125
73126 +#define PF_PAGEEXEC (1U << 4) /* Enable PAGEEXEC */
73127 +#define PF_NOPAGEEXEC (1U << 5) /* Disable PAGEEXEC */
73128 +#define PF_SEGMEXEC (1U << 6) /* Enable SEGMEXEC */
73129 +#define PF_NOSEGMEXEC (1U << 7) /* Disable SEGMEXEC */
73130 +#define PF_MPROTECT (1U << 8) /* Enable MPROTECT */
73131 +#define PF_NOMPROTECT (1U << 9) /* Disable MPROTECT */
73132 +/*#define PF_RANDEXEC (1U << 10)*/ /* Enable RANDEXEC */
73133 +/*#define PF_NORANDEXEC (1U << 11)*/ /* Disable RANDEXEC */
73134 +#define PF_EMUTRAMP (1U << 12) /* Enable EMUTRAMP */
73135 +#define PF_NOEMUTRAMP (1U << 13) /* Disable EMUTRAMP */
73136 +#define PF_RANDMMAP (1U << 14) /* Enable RANDMMAP */
73137 +#define PF_NORANDMMAP (1U << 15) /* Disable RANDMMAP */
73138 +
73139 typedef struct elf32_phdr{
73140 Elf32_Word p_type;
73141 Elf32_Off p_offset;
73142 @@ -332,6 +358,8 @@ typedef struct elf64_shdr {
73143 #define EI_OSABI 7
73144 #define EI_PAD 8
73145
73146 +#define EI_PAX 14
73147 +
73148 #define ELFMAG0 0x7f /* EI_MAG */
73149 #define ELFMAG1 'E'
73150 #define ELFMAG2 'L'
73151 diff --git a/include/uapi/linux/personality.h b/include/uapi/linux/personality.h
73152 index aa169c4..6a2771d 100644
73153 --- a/include/uapi/linux/personality.h
73154 +++ b/include/uapi/linux/personality.h
73155 @@ -30,6 +30,7 @@ enum {
73156 #define PER_CLEAR_ON_SETID (READ_IMPLIES_EXEC | \
73157 ADDR_NO_RANDOMIZE | \
73158 ADDR_COMPAT_LAYOUT | \
73159 + ADDR_LIMIT_3GB | \
73160 MMAP_PAGE_ZERO)
73161
73162 /*
73163 diff --git a/include/uapi/linux/screen_info.h b/include/uapi/linux/screen_info.h
73164 index 7530e74..e714828 100644
73165 --- a/include/uapi/linux/screen_info.h
73166 +++ b/include/uapi/linux/screen_info.h
73167 @@ -43,7 +43,8 @@ struct screen_info {
73168 __u16 pages; /* 0x32 */
73169 __u16 vesa_attributes; /* 0x34 */
73170 __u32 capabilities; /* 0x36 */
73171 - __u8 _reserved[6]; /* 0x3a */
73172 + __u16 vesapm_size; /* 0x3a */
73173 + __u8 _reserved[4]; /* 0x3c */
73174 } __attribute__((packed));
73175
73176 #define VIDEO_TYPE_MDA 0x10 /* Monochrome Text Display */
73177 diff --git a/include/uapi/linux/swab.h b/include/uapi/linux/swab.h
73178 index 0e011eb..82681b1 100644
73179 --- a/include/uapi/linux/swab.h
73180 +++ b/include/uapi/linux/swab.h
73181 @@ -43,7 +43,7 @@
73182 * ___swab16, ___swab32, ___swab64, ___swahw32, ___swahb32
73183 */
73184
73185 -static inline __attribute_const__ __u16 __fswab16(__u16 val)
73186 +static inline __intentional_overflow(-1) __attribute_const__ __u16 __fswab16(__u16 val)
73187 {
73188 #ifdef __HAVE_BUILTIN_BSWAP16__
73189 return __builtin_bswap16(val);
73190 @@ -54,7 +54,7 @@ static inline __attribute_const__ __u16 __fswab16(__u16 val)
73191 #endif
73192 }
73193
73194 -static inline __attribute_const__ __u32 __fswab32(__u32 val)
73195 +static inline __intentional_overflow(-1) __attribute_const__ __u32 __fswab32(__u32 val)
73196 {
73197 #ifdef __HAVE_BUILTIN_BSWAP32__
73198 return __builtin_bswap32(val);
73199 @@ -65,7 +65,7 @@ static inline __attribute_const__ __u32 __fswab32(__u32 val)
73200 #endif
73201 }
73202
73203 -static inline __attribute_const__ __u64 __fswab64(__u64 val)
73204 +static inline __intentional_overflow(-1) __attribute_const__ __u64 __fswab64(__u64 val)
73205 {
73206 #ifdef __HAVE_BUILTIN_BSWAP64__
73207 return __builtin_bswap64(val);
73208 diff --git a/include/uapi/linux/sysctl.h b/include/uapi/linux/sysctl.h
73209 index 6d67213..8dab561 100644
73210 --- a/include/uapi/linux/sysctl.h
73211 +++ b/include/uapi/linux/sysctl.h
73212 @@ -155,7 +155,11 @@ enum
73213 KERN_PANIC_ON_NMI=76, /* int: whether we will panic on an unrecovered */
73214 };
73215
73216 -
73217 +#ifdef CONFIG_PAX_SOFTMODE
73218 +enum {
73219 + PAX_SOFTMODE=1 /* PaX: disable/enable soft mode */
73220 +};
73221 +#endif
73222
73223 /* CTL_VM names: */
73224 enum
73225 diff --git a/include/uapi/linux/xattr.h b/include/uapi/linux/xattr.h
73226 index e4629b9..6958086 100644
73227 --- a/include/uapi/linux/xattr.h
73228 +++ b/include/uapi/linux/xattr.h
73229 @@ -63,5 +63,9 @@
73230 #define XATTR_POSIX_ACL_DEFAULT "posix_acl_default"
73231 #define XATTR_NAME_POSIX_ACL_DEFAULT XATTR_SYSTEM_PREFIX XATTR_POSIX_ACL_DEFAULT
73232
73233 +/* User namespace */
73234 +#define XATTR_PAX_PREFIX XATTR_USER_PREFIX "pax."
73235 +#define XATTR_PAX_FLAGS_SUFFIX "flags"
73236 +#define XATTR_NAME_PAX_FLAGS XATTR_PAX_PREFIX XATTR_PAX_FLAGS_SUFFIX
73237
73238 #endif /* _UAPI_LINUX_XATTR_H */
73239 diff --git a/include/video/udlfb.h b/include/video/udlfb.h
73240 index f9466fa..f4e2b81 100644
73241 --- a/include/video/udlfb.h
73242 +++ b/include/video/udlfb.h
73243 @@ -53,10 +53,10 @@ struct dlfb_data {
73244 u32 pseudo_palette[256];
73245 int blank_mode; /*one of FB_BLANK_ */
73246 /* blit-only rendering path metrics, exposed through sysfs */
73247 - atomic_t bytes_rendered; /* raw pixel-bytes driver asked to render */
73248 - atomic_t bytes_identical; /* saved effort with backbuffer comparison */
73249 - atomic_t bytes_sent; /* to usb, after compression including overhead */
73250 - atomic_t cpu_kcycles_used; /* transpired during pixel processing */
73251 + atomic_unchecked_t bytes_rendered; /* raw pixel-bytes driver asked to render */
73252 + atomic_unchecked_t bytes_identical; /* saved effort with backbuffer comparison */
73253 + atomic_unchecked_t bytes_sent; /* to usb, after compression including overhead */
73254 + atomic_unchecked_t cpu_kcycles_used; /* transpired during pixel processing */
73255 };
73256
73257 #define NR_USB_REQUEST_I2C_SUB_IO 0x02
73258 diff --git a/include/video/uvesafb.h b/include/video/uvesafb.h
73259 index 1a91850..28573f8 100644
73260 --- a/include/video/uvesafb.h
73261 +++ b/include/video/uvesafb.h
73262 @@ -122,6 +122,7 @@ struct uvesafb_par {
73263 u8 ypan; /* 0 - nothing, 1 - ypan, 2 - ywrap */
73264 u8 pmi_setpal; /* PMI for palette changes */
73265 u16 *pmi_base; /* protected mode interface location */
73266 + u8 *pmi_code; /* protected mode code location */
73267 void *pmi_start;
73268 void *pmi_pal;
73269 u8 *vbe_state_orig; /*
73270 diff --git a/init/Kconfig b/init/Kconfig
73271 index 5341d72..153f24f 100644
73272 --- a/init/Kconfig
73273 +++ b/init/Kconfig
73274 @@ -984,6 +984,7 @@ endif # CGROUPS
73275
73276 config CHECKPOINT_RESTORE
73277 bool "Checkpoint/restore support" if EXPERT
73278 + depends on !GRKERNSEC
73279 default n
73280 help
73281 Enables additional kernel features in a sake of checkpoint/restore.
73282 @@ -1471,7 +1472,7 @@ config SLUB_DEBUG
73283
73284 config COMPAT_BRK
73285 bool "Disable heap randomization"
73286 - default y
73287 + default n
73288 help
73289 Randomizing heap placement makes heap exploits harder, but it
73290 also breaks ancient binaries (including anything libc5 based).
73291 @@ -1734,7 +1735,7 @@ config INIT_ALL_POSSIBLE
73292 config STOP_MACHINE
73293 bool
73294 default y
73295 - depends on (SMP && MODULE_UNLOAD) || HOTPLUG_CPU
73296 + depends on (SMP && MODULE_UNLOAD) || HOTPLUG_CPU || GRKERNSEC
73297 help
73298 Need stop_machine() primitive.
73299
73300 diff --git a/init/Makefile b/init/Makefile
73301 index 7bc47ee..6da2dc7 100644
73302 --- a/init/Makefile
73303 +++ b/init/Makefile
73304 @@ -2,6 +2,9 @@
73305 # Makefile for the linux kernel.
73306 #
73307
73308 +ccflags-y := $(GCC_PLUGINS_CFLAGS)
73309 +asflags-y := $(GCC_PLUGINS_AFLAGS)
73310 +
73311 obj-y := main.o version.o mounts.o
73312 ifneq ($(CONFIG_BLK_DEV_INITRD),y)
73313 obj-y += noinitramfs.o
73314 diff --git a/init/do_mounts.c b/init/do_mounts.c
73315 index a2b49f2..03a0e17c 100644
73316 --- a/init/do_mounts.c
73317 +++ b/init/do_mounts.c
73318 @@ -355,11 +355,11 @@ static void __init get_fs_names(char *page)
73319 static int __init do_mount_root(char *name, char *fs, int flags, void *data)
73320 {
73321 struct super_block *s;
73322 - int err = sys_mount(name, "/root", fs, flags, data);
73323 + int err = sys_mount((char __force_user *)name, (char __force_user *)"/root", (char __force_user *)fs, flags, (void __force_user *)data);
73324 if (err)
73325 return err;
73326
73327 - sys_chdir("/root");
73328 + sys_chdir((const char __force_user *)"/root");
73329 s = current->fs->pwd.dentry->d_sb;
73330 ROOT_DEV = s->s_dev;
73331 printk(KERN_INFO
73332 @@ -480,18 +480,18 @@ void __init change_floppy(char *fmt, ...)
73333 va_start(args, fmt);
73334 vsprintf(buf, fmt, args);
73335 va_end(args);
73336 - fd = sys_open("/dev/root", O_RDWR | O_NDELAY, 0);
73337 + fd = sys_open((char __user *)"/dev/root", O_RDWR | O_NDELAY, 0);
73338 if (fd >= 0) {
73339 sys_ioctl(fd, FDEJECT, 0);
73340 sys_close(fd);
73341 }
73342 printk(KERN_NOTICE "VFS: Insert %s and press ENTER\n", buf);
73343 - fd = sys_open("/dev/console", O_RDWR, 0);
73344 + fd = sys_open((__force const char __user *)"/dev/console", O_RDWR, 0);
73345 if (fd >= 0) {
73346 sys_ioctl(fd, TCGETS, (long)&termios);
73347 termios.c_lflag &= ~ICANON;
73348 sys_ioctl(fd, TCSETSF, (long)&termios);
73349 - sys_read(fd, &c, 1);
73350 + sys_read(fd, (char __user *)&c, 1);
73351 termios.c_lflag |= ICANON;
73352 sys_ioctl(fd, TCSETSF, (long)&termios);
73353 sys_close(fd);
73354 @@ -585,6 +585,6 @@ void __init prepare_namespace(void)
73355 mount_root();
73356 out:
73357 devtmpfs_mount("dev");
73358 - sys_mount(".", "/", NULL, MS_MOVE, NULL);
73359 - sys_chroot(".");
73360 + sys_mount((char __force_user *)".", (char __force_user *)"/", NULL, MS_MOVE, NULL);
73361 + sys_chroot((const char __force_user *)".");
73362 }
73363 diff --git a/init/do_mounts.h b/init/do_mounts.h
73364 index f5b978a..69dbfe8 100644
73365 --- a/init/do_mounts.h
73366 +++ b/init/do_mounts.h
73367 @@ -15,15 +15,15 @@ extern int root_mountflags;
73368
73369 static inline int create_dev(char *name, dev_t dev)
73370 {
73371 - sys_unlink(name);
73372 - return sys_mknod(name, S_IFBLK|0600, new_encode_dev(dev));
73373 + sys_unlink((char __force_user *)name);
73374 + return sys_mknod((char __force_user *)name, S_IFBLK|0600, new_encode_dev(dev));
73375 }
73376
73377 #if BITS_PER_LONG == 32
73378 static inline u32 bstat(char *name)
73379 {
73380 struct stat64 stat;
73381 - if (sys_stat64(name, &stat) != 0)
73382 + if (sys_stat64((char __force_user *)name, (struct stat64 __force_user *)&stat) != 0)
73383 return 0;
73384 if (!S_ISBLK(stat.st_mode))
73385 return 0;
73386 @@ -35,7 +35,7 @@ static inline u32 bstat(char *name)
73387 static inline u32 bstat(char *name)
73388 {
73389 struct stat stat;
73390 - if (sys_newstat(name, &stat) != 0)
73391 + if (sys_newstat((const char __force_user *)name, (struct stat __force_user *)&stat) != 0)
73392 return 0;
73393 if (!S_ISBLK(stat.st_mode))
73394 return 0;
73395 diff --git a/init/do_mounts_initrd.c b/init/do_mounts_initrd.c
73396 index a32ec1c..60a6659 100644
73397 --- a/init/do_mounts_initrd.c
73398 +++ b/init/do_mounts_initrd.c
73399 @@ -37,13 +37,13 @@ static int init_linuxrc(struct subprocess_info *info, struct cred *new)
73400 {
73401 sys_unshare(CLONE_FS | CLONE_FILES);
73402 /* stdin/stdout/stderr for /linuxrc */
73403 - sys_open("/dev/console", O_RDWR, 0);
73404 + sys_open((const char __force_user *)"/dev/console", O_RDWR, 0);
73405 sys_dup(0);
73406 sys_dup(0);
73407 /* move initrd over / and chdir/chroot in initrd root */
73408 - sys_chdir("/root");
73409 - sys_mount(".", "/", NULL, MS_MOVE, NULL);
73410 - sys_chroot(".");
73411 + sys_chdir((const char __force_user *)"/root");
73412 + sys_mount((char __force_user *)".", (char __force_user *)"/", NULL, MS_MOVE, NULL);
73413 + sys_chroot((const char __force_user *)".");
73414 sys_setsid();
73415 return 0;
73416 }
73417 @@ -58,8 +58,8 @@ static void __init handle_initrd(void)
73418 create_dev("/dev/root.old", Root_RAM0);
73419 /* mount initrd on rootfs' /root */
73420 mount_block_root("/dev/root.old", root_mountflags & ~MS_RDONLY);
73421 - sys_mkdir("/old", 0700);
73422 - sys_chdir("/old");
73423 + sys_mkdir((const char __force_user *)"/old", 0700);
73424 + sys_chdir((const char __force_user *)"/old");
73425
73426 /* try loading default modules from initrd */
73427 load_default_modules();
73428 @@ -76,31 +76,31 @@ static void __init handle_initrd(void)
73429 current->flags &= ~PF_FREEZER_SKIP;
73430
73431 /* move initrd to rootfs' /old */
73432 - sys_mount("..", ".", NULL, MS_MOVE, NULL);
73433 + sys_mount((char __force_user *)"..", (char __force_user *)".", NULL, MS_MOVE, NULL);
73434 /* switch root and cwd back to / of rootfs */
73435 - sys_chroot("..");
73436 + sys_chroot((const char __force_user *)"..");
73437
73438 if (new_decode_dev(real_root_dev) == Root_RAM0) {
73439 - sys_chdir("/old");
73440 + sys_chdir((const char __force_user *)"/old");
73441 return;
73442 }
73443
73444 - sys_chdir("/");
73445 + sys_chdir((const char __force_user *)"/");
73446 ROOT_DEV = new_decode_dev(real_root_dev);
73447 mount_root();
73448
73449 printk(KERN_NOTICE "Trying to move old root to /initrd ... ");
73450 - error = sys_mount("/old", "/root/initrd", NULL, MS_MOVE, NULL);
73451 + error = sys_mount((char __force_user *)"/old", (char __force_user *)"/root/initrd", NULL, MS_MOVE, NULL);
73452 if (!error)
73453 printk("okay\n");
73454 else {
73455 - int fd = sys_open("/dev/root.old", O_RDWR, 0);
73456 + int fd = sys_open((const char __force_user *)"/dev/root.old", O_RDWR, 0);
73457 if (error == -ENOENT)
73458 printk("/initrd does not exist. Ignored.\n");
73459 else
73460 printk("failed\n");
73461 printk(KERN_NOTICE "Unmounting old root\n");
73462 - sys_umount("/old", MNT_DETACH);
73463 + sys_umount((char __force_user *)"/old", MNT_DETACH);
73464 printk(KERN_NOTICE "Trying to free ramdisk memory ... ");
73465 if (fd < 0) {
73466 error = fd;
73467 @@ -123,11 +123,11 @@ int __init initrd_load(void)
73468 * mounted in the normal path.
73469 */
73470 if (rd_load_image("/initrd.image") && ROOT_DEV != Root_RAM0) {
73471 - sys_unlink("/initrd.image");
73472 + sys_unlink((const char __force_user *)"/initrd.image");
73473 handle_initrd();
73474 return 1;
73475 }
73476 }
73477 - sys_unlink("/initrd.image");
73478 + sys_unlink((const char __force_user *)"/initrd.image");
73479 return 0;
73480 }
73481 diff --git a/init/do_mounts_md.c b/init/do_mounts_md.c
73482 index 8cb6db5..d729f50 100644
73483 --- a/init/do_mounts_md.c
73484 +++ b/init/do_mounts_md.c
73485 @@ -180,7 +180,7 @@ static void __init md_setup_drive(void)
73486 partitioned ? "_d" : "", minor,
73487 md_setup_args[ent].device_names);
73488
73489 - fd = sys_open(name, 0, 0);
73490 + fd = sys_open((char __force_user *)name, 0, 0);
73491 if (fd < 0) {
73492 printk(KERN_ERR "md: open failed - cannot start "
73493 "array %s\n", name);
73494 @@ -243,7 +243,7 @@ static void __init md_setup_drive(void)
73495 * array without it
73496 */
73497 sys_close(fd);
73498 - fd = sys_open(name, 0, 0);
73499 + fd = sys_open((char __force_user *)name, 0, 0);
73500 sys_ioctl(fd, BLKRRPART, 0);
73501 }
73502 sys_close(fd);
73503 @@ -293,7 +293,7 @@ static void __init autodetect_raid(void)
73504
73505 wait_for_device_probe();
73506
73507 - fd = sys_open("/dev/md0", 0, 0);
73508 + fd = sys_open((const char __force_user *) "/dev/md0", 0, 0);
73509 if (fd >= 0) {
73510 sys_ioctl(fd, RAID_AUTORUN, raid_autopart);
73511 sys_close(fd);
73512 diff --git a/init/init_task.c b/init/init_task.c
73513 index ba0a7f36..2bcf1d5 100644
73514 --- a/init/init_task.c
73515 +++ b/init/init_task.c
73516 @@ -22,5 +22,9 @@ EXPORT_SYMBOL(init_task);
73517 * Initial thread structure. Alignment of this is handled by a special
73518 * linker map entry.
73519 */
73520 +#ifdef CONFIG_X86
73521 +union thread_union init_thread_union __init_task_data;
73522 +#else
73523 union thread_union init_thread_union __init_task_data =
73524 { INIT_THREAD_INFO(init_task) };
73525 +#endif
73526 diff --git a/init/initramfs.c b/init/initramfs.c
73527 index a67ef9d..3d88592 100644
73528 --- a/init/initramfs.c
73529 +++ b/init/initramfs.c
73530 @@ -84,7 +84,7 @@ static void __init free_hash(void)
73531 }
73532 }
73533
73534 -static long __init do_utime(char *filename, time_t mtime)
73535 +static long __init do_utime(char __force_user *filename, time_t mtime)
73536 {
73537 struct timespec t[2];
73538
73539 @@ -119,7 +119,7 @@ static void __init dir_utime(void)
73540 struct dir_entry *de, *tmp;
73541 list_for_each_entry_safe(de, tmp, &dir_list, list) {
73542 list_del(&de->list);
73543 - do_utime(de->name, de->mtime);
73544 + do_utime((char __force_user *)de->name, de->mtime);
73545 kfree(de->name);
73546 kfree(de);
73547 }
73548 @@ -281,7 +281,7 @@ static int __init maybe_link(void)
73549 if (nlink >= 2) {
73550 char *old = find_link(major, minor, ino, mode, collected);
73551 if (old)
73552 - return (sys_link(old, collected) < 0) ? -1 : 1;
73553 + return (sys_link((char __force_user *)old, (char __force_user *)collected) < 0) ? -1 : 1;
73554 }
73555 return 0;
73556 }
73557 @@ -290,11 +290,11 @@ static void __init clean_path(char *path, umode_t mode)
73558 {
73559 struct stat st;
73560
73561 - if (!sys_newlstat(path, &st) && (st.st_mode^mode) & S_IFMT) {
73562 + if (!sys_newlstat((char __force_user *)path, (struct stat __force_user *)&st) && (st.st_mode^mode) & S_IFMT) {
73563 if (S_ISDIR(st.st_mode))
73564 - sys_rmdir(path);
73565 + sys_rmdir((char __force_user *)path);
73566 else
73567 - sys_unlink(path);
73568 + sys_unlink((char __force_user *)path);
73569 }
73570 }
73571
73572 @@ -315,7 +315,7 @@ static int __init do_name(void)
73573 int openflags = O_WRONLY|O_CREAT;
73574 if (ml != 1)
73575 openflags |= O_TRUNC;
73576 - wfd = sys_open(collected, openflags, mode);
73577 + wfd = sys_open((char __force_user *)collected, openflags, mode);
73578
73579 if (wfd >= 0) {
73580 sys_fchown(wfd, uid, gid);
73581 @@ -327,17 +327,17 @@ static int __init do_name(void)
73582 }
73583 }
73584 } else if (S_ISDIR(mode)) {
73585 - sys_mkdir(collected, mode);
73586 - sys_chown(collected, uid, gid);
73587 - sys_chmod(collected, mode);
73588 + sys_mkdir((char __force_user *)collected, mode);
73589 + sys_chown((char __force_user *)collected, uid, gid);
73590 + sys_chmod((char __force_user *)collected, mode);
73591 dir_add(collected, mtime);
73592 } else if (S_ISBLK(mode) || S_ISCHR(mode) ||
73593 S_ISFIFO(mode) || S_ISSOCK(mode)) {
73594 if (maybe_link() == 0) {
73595 - sys_mknod(collected, mode, rdev);
73596 - sys_chown(collected, uid, gid);
73597 - sys_chmod(collected, mode);
73598 - do_utime(collected, mtime);
73599 + sys_mknod((char __force_user *)collected, mode, rdev);
73600 + sys_chown((char __force_user *)collected, uid, gid);
73601 + sys_chmod((char __force_user *)collected, mode);
73602 + do_utime((char __force_user *)collected, mtime);
73603 }
73604 }
73605 return 0;
73606 @@ -346,15 +346,15 @@ static int __init do_name(void)
73607 static int __init do_copy(void)
73608 {
73609 if (count >= body_len) {
73610 - sys_write(wfd, victim, body_len);
73611 + sys_write(wfd, (char __force_user *)victim, body_len);
73612 sys_close(wfd);
73613 - do_utime(vcollected, mtime);
73614 + do_utime((char __force_user *)vcollected, mtime);
73615 kfree(vcollected);
73616 eat(body_len);
73617 state = SkipIt;
73618 return 0;
73619 } else {
73620 - sys_write(wfd, victim, count);
73621 + sys_write(wfd, (char __force_user *)victim, count);
73622 body_len -= count;
73623 eat(count);
73624 return 1;
73625 @@ -365,9 +365,9 @@ static int __init do_symlink(void)
73626 {
73627 collected[N_ALIGN(name_len) + body_len] = '\0';
73628 clean_path(collected, 0);
73629 - sys_symlink(collected + N_ALIGN(name_len), collected);
73630 - sys_lchown(collected, uid, gid);
73631 - do_utime(collected, mtime);
73632 + sys_symlink((char __force_user *)collected + N_ALIGN(name_len), (char __force_user *)collected);
73633 + sys_lchown((char __force_user *)collected, uid, gid);
73634 + do_utime((char __force_user *)collected, mtime);
73635 state = SkipIt;
73636 next_state = Reset;
73637 return 0;
73638 diff --git a/init/main.c b/init/main.c
73639 index 63534a1..85feae2 100644
73640 --- a/init/main.c
73641 +++ b/init/main.c
73642 @@ -98,6 +98,8 @@ static inline void mark_rodata_ro(void) { }
73643 extern void tc_init(void);
73644 #endif
73645
73646 +extern void grsecurity_init(void);
73647 +
73648 /*
73649 * Debug helper: via this flag we know that we are in 'early bootup code'
73650 * where only the boot processor is running with IRQ disabled. This means
73651 @@ -151,6 +153,64 @@ static int __init set_reset_devices(char *str)
73652
73653 __setup("reset_devices", set_reset_devices);
73654
73655 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
73656 +kgid_t grsec_proc_gid = KGIDT_INIT(CONFIG_GRKERNSEC_PROC_GID);
73657 +static int __init setup_grsec_proc_gid(char *str)
73658 +{
73659 + grsec_proc_gid = KGIDT_INIT(simple_strtol(str, NULL, 0));
73660 + return 1;
73661 +}
73662 +__setup("grsec_proc_gid=", setup_grsec_proc_gid);
73663 +#endif
73664 +
73665 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
73666 +unsigned long pax_user_shadow_base __read_only = 1UL << TASK_SIZE_MAX_SHIFT;
73667 +EXPORT_SYMBOL(pax_user_shadow_base);
73668 +extern char pax_enter_kernel_user[];
73669 +extern char pax_exit_kernel_user[];
73670 +extern pgdval_t clone_pgd_mask;
73671 +#endif
73672 +
73673 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_MEMORY_UDEREF)
73674 +static int __init setup_pax_nouderef(char *str)
73675 +{
73676 +#ifdef CONFIG_X86_32
73677 + unsigned int cpu;
73678 + struct desc_struct *gdt;
73679 +
73680 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
73681 + gdt = get_cpu_gdt_table(cpu);
73682 + gdt[GDT_ENTRY_KERNEL_DS].type = 3;
73683 + gdt[GDT_ENTRY_KERNEL_DS].limit = 0xf;
73684 + gdt[GDT_ENTRY_DEFAULT_USER_CS].limit = 0xf;
73685 + gdt[GDT_ENTRY_DEFAULT_USER_DS].limit = 0xf;
73686 + }
73687 + loadsegment(ds, __KERNEL_DS);
73688 + loadsegment(es, __KERNEL_DS);
73689 + loadsegment(ss, __KERNEL_DS);
73690 +#else
73691 + memcpy(pax_enter_kernel_user, (unsigned char []){0xc3}, 1);
73692 + memcpy(pax_exit_kernel_user, (unsigned char []){0xc3}, 1);
73693 + clone_pgd_mask = ~(pgdval_t)0UL;
73694 + pax_user_shadow_base = 0UL;
73695 +#endif
73696 +
73697 + return 0;
73698 +}
73699 +early_param("pax_nouderef", setup_pax_nouderef);
73700 +#endif
73701 +
73702 +#ifdef CONFIG_PAX_SOFTMODE
73703 +int pax_softmode;
73704 +
73705 +static int __init setup_pax_softmode(char *str)
73706 +{
73707 + get_option(&str, &pax_softmode);
73708 + return 1;
73709 +}
73710 +__setup("pax_softmode=", setup_pax_softmode);
73711 +#endif
73712 +
73713 static const char * argv_init[MAX_INIT_ARGS+2] = { "init", NULL, };
73714 const char * envp_init[MAX_INIT_ENVS+2] = { "HOME=/", "TERM=linux", NULL, };
73715 static const char *panic_later, *panic_param;
73716 @@ -683,6 +743,7 @@ int __init_or_module do_one_initcall(initcall_t fn)
73717 {
73718 int count = preempt_count();
73719 int ret;
73720 + const char *msg1 = "", *msg2 = "";
73721
73722 if (initcall_debug)
73723 ret = do_one_initcall_debug(fn);
73724 @@ -695,15 +756,15 @@ int __init_or_module do_one_initcall(initcall_t fn)
73725 sprintf(msgbuf, "error code %d ", ret);
73726
73727 if (preempt_count() != count) {
73728 - strlcat(msgbuf, "preemption imbalance ", sizeof(msgbuf));
73729 + msg1 = " preemption imbalance";
73730 preempt_count() = count;
73731 }
73732 if (irqs_disabled()) {
73733 - strlcat(msgbuf, "disabled interrupts ", sizeof(msgbuf));
73734 + msg2 = " disabled interrupts";
73735 local_irq_enable();
73736 }
73737 - if (msgbuf[0]) {
73738 - printk("initcall %pF returned with %s\n", fn, msgbuf);
73739 + if (msgbuf[0] || *msg1 || *msg2) {
73740 + printk("initcall %pF returned with %s%s%s\n", fn, msgbuf, msg1, msg2);
73741 }
73742
73743 return ret;
73744 @@ -757,8 +818,14 @@ static void __init do_initcall_level(int level)
73745 level, level,
73746 &repair_env_string);
73747
73748 - for (fn = initcall_levels[level]; fn < initcall_levels[level+1]; fn++)
73749 + for (fn = initcall_levels[level]; fn < initcall_levels[level+1]; fn++) {
73750 do_one_initcall(*fn);
73751 +
73752 +#ifdef LATENT_ENTROPY_PLUGIN
73753 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
73754 +#endif
73755 +
73756 + }
73757 }
73758
73759 static void __init do_initcalls(void)
73760 @@ -792,8 +859,14 @@ static void __init do_pre_smp_initcalls(void)
73761 {
73762 initcall_t *fn;
73763
73764 - for (fn = __initcall_start; fn < __initcall0_start; fn++)
73765 + for (fn = __initcall_start; fn < __initcall0_start; fn++) {
73766 do_one_initcall(*fn);
73767 +
73768 +#ifdef LATENT_ENTROPY_PLUGIN
73769 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
73770 +#endif
73771 +
73772 + }
73773 }
73774
73775 /*
73776 @@ -811,8 +884,8 @@ static int run_init_process(const char *init_filename)
73777 {
73778 argv_init[0] = init_filename;
73779 return do_execve(init_filename,
73780 - (const char __user *const __user *)argv_init,
73781 - (const char __user *const __user *)envp_init);
73782 + (const char __user *const __force_user *)argv_init,
73783 + (const char __user *const __force_user *)envp_init);
73784 }
73785
73786 static noinline void __init kernel_init_freeable(void);
73787 @@ -890,7 +963,7 @@ static noinline void __init kernel_init_freeable(void)
73788 do_basic_setup();
73789
73790 /* Open the /dev/console on the rootfs, this should never fail */
73791 - if (sys_open((const char __user *) "/dev/console", O_RDWR, 0) < 0)
73792 + if (sys_open((const char __force_user *) "/dev/console", O_RDWR, 0) < 0)
73793 printk(KERN_WARNING "Warning: unable to open an initial console.\n");
73794
73795 (void) sys_dup(0);
73796 @@ -903,11 +976,13 @@ static noinline void __init kernel_init_freeable(void)
73797 if (!ramdisk_execute_command)
73798 ramdisk_execute_command = "/init";
73799
73800 - if (sys_access((const char __user *) ramdisk_execute_command, 0) != 0) {
73801 + if (sys_access((const char __force_user *) ramdisk_execute_command, 0) != 0) {
73802 ramdisk_execute_command = NULL;
73803 prepare_namespace();
73804 }
73805
73806 + grsecurity_init();
73807 +
73808 /*
73809 * Ok, we have completed the initial bootup, and
73810 * we're essentially up and running. Get rid of the
73811 diff --git a/ipc/ipc_sysctl.c b/ipc/ipc_sysctl.c
73812 index 130dfec..cc88451 100644
73813 --- a/ipc/ipc_sysctl.c
73814 +++ b/ipc/ipc_sysctl.c
73815 @@ -30,7 +30,7 @@ static void *get_ipc(ctl_table *table)
73816 static int proc_ipc_dointvec(ctl_table *table, int write,
73817 void __user *buffer, size_t *lenp, loff_t *ppos)
73818 {
73819 - struct ctl_table ipc_table;
73820 + ctl_table_no_const ipc_table;
73821
73822 memcpy(&ipc_table, table, sizeof(ipc_table));
73823 ipc_table.data = get_ipc(table);
73824 @@ -41,7 +41,7 @@ static int proc_ipc_dointvec(ctl_table *table, int write,
73825 static int proc_ipc_dointvec_minmax(ctl_table *table, int write,
73826 void __user *buffer, size_t *lenp, loff_t *ppos)
73827 {
73828 - struct ctl_table ipc_table;
73829 + ctl_table_no_const ipc_table;
73830
73831 memcpy(&ipc_table, table, sizeof(ipc_table));
73832 ipc_table.data = get_ipc(table);
73833 @@ -65,7 +65,7 @@ static int proc_ipc_dointvec_minmax_orphans(ctl_table *table, int write,
73834 static int proc_ipc_callback_dointvec(ctl_table *table, int write,
73835 void __user *buffer, size_t *lenp, loff_t *ppos)
73836 {
73837 - struct ctl_table ipc_table;
73838 + ctl_table_no_const ipc_table;
73839 size_t lenp_bef = *lenp;
73840 int rc;
73841
73842 @@ -88,7 +88,7 @@ static int proc_ipc_callback_dointvec(ctl_table *table, int write,
73843 static int proc_ipc_doulongvec_minmax(ctl_table *table, int write,
73844 void __user *buffer, size_t *lenp, loff_t *ppos)
73845 {
73846 - struct ctl_table ipc_table;
73847 + ctl_table_no_const ipc_table;
73848 memcpy(&ipc_table, table, sizeof(ipc_table));
73849 ipc_table.data = get_ipc(table);
73850
73851 @@ -122,7 +122,7 @@ static void ipc_auto_callback(int val)
73852 static int proc_ipcauto_dointvec_minmax(ctl_table *table, int write,
73853 void __user *buffer, size_t *lenp, loff_t *ppos)
73854 {
73855 - struct ctl_table ipc_table;
73856 + ctl_table_no_const ipc_table;
73857 size_t lenp_bef = *lenp;
73858 int oldval;
73859 int rc;
73860 diff --git a/ipc/mq_sysctl.c b/ipc/mq_sysctl.c
73861 index 383d638..943fdbb 100644
73862 --- a/ipc/mq_sysctl.c
73863 +++ b/ipc/mq_sysctl.c
73864 @@ -25,7 +25,7 @@ static void *get_mq(ctl_table *table)
73865 static int proc_mq_dointvec_minmax(ctl_table *table, int write,
73866 void __user *buffer, size_t *lenp, loff_t *ppos)
73867 {
73868 - struct ctl_table mq_table;
73869 + ctl_table_no_const mq_table;
73870 memcpy(&mq_table, table, sizeof(mq_table));
73871 mq_table.data = get_mq(table);
73872
73873 diff --git a/ipc/mqueue.c b/ipc/mqueue.c
73874 index e4e47f6..a85e0ad 100644
73875 --- a/ipc/mqueue.c
73876 +++ b/ipc/mqueue.c
73877 @@ -278,6 +278,7 @@ static struct inode *mqueue_get_inode(struct super_block *sb,
73878 mq_bytes = mq_treesize + (info->attr.mq_maxmsg *
73879 info->attr.mq_msgsize);
73880
73881 + gr_learn_resource(current, RLIMIT_MSGQUEUE, u->mq_bytes + mq_bytes, 1);
73882 spin_lock(&mq_lock);
73883 if (u->mq_bytes + mq_bytes < u->mq_bytes ||
73884 u->mq_bytes + mq_bytes > rlimit(RLIMIT_MSGQUEUE)) {
73885 diff --git a/ipc/msg.c b/ipc/msg.c
73886 index fede1d0..9778e0f8 100644
73887 --- a/ipc/msg.c
73888 +++ b/ipc/msg.c
73889 @@ -309,18 +309,19 @@ static inline int msg_security(struct kern_ipc_perm *ipcp, int msgflg)
73890 return security_msg_queue_associate(msq, msgflg);
73891 }
73892
73893 +static struct ipc_ops msg_ops = {
73894 + .getnew = newque,
73895 + .associate = msg_security,
73896 + .more_checks = NULL
73897 +};
73898 +
73899 SYSCALL_DEFINE2(msgget, key_t, key, int, msgflg)
73900 {
73901 struct ipc_namespace *ns;
73902 - struct ipc_ops msg_ops;
73903 struct ipc_params msg_params;
73904
73905 ns = current->nsproxy->ipc_ns;
73906
73907 - msg_ops.getnew = newque;
73908 - msg_ops.associate = msg_security;
73909 - msg_ops.more_checks = NULL;
73910 -
73911 msg_params.key = key;
73912 msg_params.flg = msgflg;
73913
73914 diff --git a/ipc/sem.c b/ipc/sem.c
73915 index 58d31f1..cce7a55 100644
73916 --- a/ipc/sem.c
73917 +++ b/ipc/sem.c
73918 @@ -364,10 +364,15 @@ static inline int sem_more_checks(struct kern_ipc_perm *ipcp,
73919 return 0;
73920 }
73921
73922 +static struct ipc_ops sem_ops = {
73923 + .getnew = newary,
73924 + .associate = sem_security,
73925 + .more_checks = sem_more_checks
73926 +};
73927 +
73928 SYSCALL_DEFINE3(semget, key_t, key, int, nsems, int, semflg)
73929 {
73930 struct ipc_namespace *ns;
73931 - struct ipc_ops sem_ops;
73932 struct ipc_params sem_params;
73933
73934 ns = current->nsproxy->ipc_ns;
73935 @@ -375,10 +380,6 @@ SYSCALL_DEFINE3(semget, key_t, key, int, nsems, int, semflg)
73936 if (nsems < 0 || nsems > ns->sc_semmsl)
73937 return -EINVAL;
73938
73939 - sem_ops.getnew = newary;
73940 - sem_ops.associate = sem_security;
73941 - sem_ops.more_checks = sem_more_checks;
73942 -
73943 sem_params.key = key;
73944 sem_params.flg = semflg;
73945 sem_params.u.nsems = nsems;
73946 diff --git a/ipc/shm.c b/ipc/shm.c
73947 index 7e199fa..180a1ca 100644
73948 --- a/ipc/shm.c
73949 +++ b/ipc/shm.c
73950 @@ -69,6 +69,14 @@ static void shm_destroy (struct ipc_namespace *ns, struct shmid_kernel *shp);
73951 static int sysvipc_shm_proc_show(struct seq_file *s, void *it);
73952 #endif
73953
73954 +#ifdef CONFIG_GRKERNSEC
73955 +extern int gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
73956 + const time_t shm_createtime, const kuid_t cuid,
73957 + const int shmid);
73958 +extern int gr_chroot_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
73959 + const time_t shm_createtime);
73960 +#endif
73961 +
73962 void shm_init_ns(struct ipc_namespace *ns)
73963 {
73964 ns->shm_ctlmax = SHMMAX;
73965 @@ -531,6 +539,14 @@ static int newseg(struct ipc_namespace *ns, struct ipc_params *params)
73966 shp->shm_lprid = 0;
73967 shp->shm_atim = shp->shm_dtim = 0;
73968 shp->shm_ctim = get_seconds();
73969 +#ifdef CONFIG_GRKERNSEC
73970 + {
73971 + struct timespec timeval;
73972 + do_posix_clock_monotonic_gettime(&timeval);
73973 +
73974 + shp->shm_createtime = timeval.tv_sec;
73975 + }
73976 +#endif
73977 shp->shm_segsz = size;
73978 shp->shm_nattch = 0;
73979 shp->shm_file = file;
73980 @@ -582,18 +598,19 @@ static inline int shm_more_checks(struct kern_ipc_perm *ipcp,
73981 return 0;
73982 }
73983
73984 +static struct ipc_ops shm_ops = {
73985 + .getnew = newseg,
73986 + .associate = shm_security,
73987 + .more_checks = shm_more_checks
73988 +};
73989 +
73990 SYSCALL_DEFINE3(shmget, key_t, key, size_t, size, int, shmflg)
73991 {
73992 struct ipc_namespace *ns;
73993 - struct ipc_ops shm_ops;
73994 struct ipc_params shm_params;
73995
73996 ns = current->nsproxy->ipc_ns;
73997
73998 - shm_ops.getnew = newseg;
73999 - shm_ops.associate = shm_security;
74000 - shm_ops.more_checks = shm_more_checks;
74001 -
74002 shm_params.key = key;
74003 shm_params.flg = shmflg;
74004 shm_params.u.size = size;
74005 @@ -1014,6 +1031,12 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
74006 f_mode = FMODE_READ | FMODE_WRITE;
74007 }
74008 if (shmflg & SHM_EXEC) {
74009 +
74010 +#ifdef CONFIG_PAX_MPROTECT
74011 + if (current->mm->pax_flags & MF_PAX_MPROTECT)
74012 + goto out;
74013 +#endif
74014 +
74015 prot |= PROT_EXEC;
74016 acc_mode |= S_IXUGO;
74017 }
74018 @@ -1037,9 +1060,21 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
74019 if (err)
74020 goto out_unlock;
74021
74022 +#ifdef CONFIG_GRKERNSEC
74023 + if (!gr_handle_shmat(shp->shm_cprid, shp->shm_lapid, shp->shm_createtime,
74024 + shp->shm_perm.cuid, shmid) ||
74025 + !gr_chroot_shmat(shp->shm_cprid, shp->shm_lapid, shp->shm_createtime)) {
74026 + err = -EACCES;
74027 + goto out_unlock;
74028 + }
74029 +#endif
74030 +
74031 path = shp->shm_file->f_path;
74032 path_get(&path);
74033 shp->shm_nattch++;
74034 +#ifdef CONFIG_GRKERNSEC
74035 + shp->shm_lapid = current->pid;
74036 +#endif
74037 size = i_size_read(path.dentry->d_inode);
74038 shm_unlock(shp);
74039
74040 diff --git a/kernel/acct.c b/kernel/acct.c
74041 index b9bd7f0..1762b4a 100644
74042 --- a/kernel/acct.c
74043 +++ b/kernel/acct.c
74044 @@ -550,7 +550,7 @@ static void do_acct_process(struct bsd_acct_struct *acct,
74045 */
74046 flim = current->signal->rlim[RLIMIT_FSIZE].rlim_cur;
74047 current->signal->rlim[RLIMIT_FSIZE].rlim_cur = RLIM_INFINITY;
74048 - file->f_op->write(file, (char *)&ac,
74049 + file->f_op->write(file, (char __force_user *)&ac,
74050 sizeof(acct_t), &file->f_pos);
74051 current->signal->rlim[RLIMIT_FSIZE].rlim_cur = flim;
74052 set_fs(fs);
74053 diff --git a/kernel/audit.c b/kernel/audit.c
74054 index d596e53..dbef3c3 100644
74055 --- a/kernel/audit.c
74056 +++ b/kernel/audit.c
74057 @@ -116,7 +116,7 @@ u32 audit_sig_sid = 0;
74058 3) suppressed due to audit_rate_limit
74059 4) suppressed due to audit_backlog_limit
74060 */
74061 -static atomic_t audit_lost = ATOMIC_INIT(0);
74062 +static atomic_unchecked_t audit_lost = ATOMIC_INIT(0);
74063
74064 /* The netlink socket. */
74065 static struct sock *audit_sock;
74066 @@ -238,7 +238,7 @@ void audit_log_lost(const char *message)
74067 unsigned long now;
74068 int print;
74069
74070 - atomic_inc(&audit_lost);
74071 + atomic_inc_unchecked(&audit_lost);
74072
74073 print = (audit_failure == AUDIT_FAIL_PANIC || !audit_rate_limit);
74074
74075 @@ -257,7 +257,7 @@ void audit_log_lost(const char *message)
74076 printk(KERN_WARNING
74077 "audit: audit_lost=%d audit_rate_limit=%d "
74078 "audit_backlog_limit=%d\n",
74079 - atomic_read(&audit_lost),
74080 + atomic_read_unchecked(&audit_lost),
74081 audit_rate_limit,
74082 audit_backlog_limit);
74083 audit_panic(message);
74084 @@ -681,7 +681,7 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
74085 status_set.pid = audit_pid;
74086 status_set.rate_limit = audit_rate_limit;
74087 status_set.backlog_limit = audit_backlog_limit;
74088 - status_set.lost = atomic_read(&audit_lost);
74089 + status_set.lost = atomic_read_unchecked(&audit_lost);
74090 status_set.backlog = skb_queue_len(&audit_skb_queue);
74091 audit_send_reply(NETLINK_CB(skb).portid, seq, AUDIT_GET, 0, 0,
74092 &status_set, sizeof(status_set));
74093 diff --git a/kernel/auditsc.c b/kernel/auditsc.c
74094 index c4b72b0..8654c4e 100644
74095 --- a/kernel/auditsc.c
74096 +++ b/kernel/auditsc.c
74097 @@ -2295,7 +2295,7 @@ int auditsc_get_stamp(struct audit_context *ctx,
74098 }
74099
74100 /* global counter which is incremented every time something logs in */
74101 -static atomic_t session_id = ATOMIC_INIT(0);
74102 +static atomic_unchecked_t session_id = ATOMIC_INIT(0);
74103
74104 /**
74105 * audit_set_loginuid - set current task's audit_context loginuid
74106 @@ -2319,7 +2319,7 @@ int audit_set_loginuid(kuid_t loginuid)
74107 return -EPERM;
74108 #endif /* CONFIG_AUDIT_LOGINUID_IMMUTABLE */
74109
74110 - sessionid = atomic_inc_return(&session_id);
74111 + sessionid = atomic_inc_return_unchecked(&session_id);
74112 if (context && context->in_syscall) {
74113 struct audit_buffer *ab;
74114
74115 diff --git a/kernel/capability.c b/kernel/capability.c
74116 index f6c2ce5..982c0f9 100644
74117 --- a/kernel/capability.c
74118 +++ b/kernel/capability.c
74119 @@ -202,6 +202,9 @@ SYSCALL_DEFINE2(capget, cap_user_header_t, header, cap_user_data_t, dataptr)
74120 * before modification is attempted and the application
74121 * fails.
74122 */
74123 + if (tocopy > ARRAY_SIZE(kdata))
74124 + return -EFAULT;
74125 +
74126 if (copy_to_user(dataptr, kdata, tocopy
74127 * sizeof(struct __user_cap_data_struct))) {
74128 return -EFAULT;
74129 @@ -303,10 +306,11 @@ bool has_ns_capability(struct task_struct *t,
74130 int ret;
74131
74132 rcu_read_lock();
74133 - ret = security_capable(__task_cred(t), ns, cap);
74134 + ret = security_capable(__task_cred(t), ns, cap) == 0 &&
74135 + gr_task_is_capable(t, __task_cred(t), cap);
74136 rcu_read_unlock();
74137
74138 - return (ret == 0);
74139 + return ret;
74140 }
74141
74142 /**
74143 @@ -343,10 +347,10 @@ bool has_ns_capability_noaudit(struct task_struct *t,
74144 int ret;
74145
74146 rcu_read_lock();
74147 - ret = security_capable_noaudit(__task_cred(t), ns, cap);
74148 + ret = security_capable_noaudit(__task_cred(t), ns, cap) == 0 && gr_task_is_capable_nolog(t, cap);
74149 rcu_read_unlock();
74150
74151 - return (ret == 0);
74152 + return ret;
74153 }
74154
74155 /**
74156 @@ -384,7 +388,7 @@ bool ns_capable(struct user_namespace *ns, int cap)
74157 BUG();
74158 }
74159
74160 - if (security_capable(current_cred(), ns, cap) == 0) {
74161 + if (security_capable(current_cred(), ns, cap) == 0 && gr_is_capable(cap)) {
74162 current->flags |= PF_SUPERPRIV;
74163 return true;
74164 }
74165 @@ -392,6 +396,21 @@ bool ns_capable(struct user_namespace *ns, int cap)
74166 }
74167 EXPORT_SYMBOL(ns_capable);
74168
74169 +bool ns_capable_nolog(struct user_namespace *ns, int cap)
74170 +{
74171 + if (unlikely(!cap_valid(cap))) {
74172 + printk(KERN_CRIT "capable_nolog() called with invalid cap=%u\n", cap);
74173 + BUG();
74174 + }
74175 +
74176 + if (security_capable_noaudit(current_cred(), ns, cap) == 0 && gr_is_capable_nolog(cap)) {
74177 + current->flags |= PF_SUPERPRIV;
74178 + return true;
74179 + }
74180 + return false;
74181 +}
74182 +EXPORT_SYMBOL(ns_capable_nolog);
74183 +
74184 /**
74185 * file_ns_capable - Determine if the file's opener had a capability in effect
74186 * @file: The file we want to check
74187 @@ -432,6 +451,12 @@ bool capable(int cap)
74188 }
74189 EXPORT_SYMBOL(capable);
74190
74191 +bool capable_nolog(int cap)
74192 +{
74193 + return ns_capable_nolog(&init_user_ns, cap);
74194 +}
74195 +EXPORT_SYMBOL(capable_nolog);
74196 +
74197 /**
74198 * nsown_capable - Check superior capability to one's own user_ns
74199 * @cap: The capability in question
74200 @@ -464,3 +489,10 @@ bool inode_capable(const struct inode *inode, int cap)
74201
74202 return ns_capable(ns, cap) && kuid_has_mapping(ns, inode->i_uid);
74203 }
74204 +
74205 +bool inode_capable_nolog(const struct inode *inode, int cap)
74206 +{
74207 + struct user_namespace *ns = current_user_ns();
74208 +
74209 + return ns_capable_nolog(ns, cap) && kuid_has_mapping(ns, inode->i_uid);
74210 +}
74211 diff --git a/kernel/cgroup.c b/kernel/cgroup.c
74212 index ba1f977..f840d9c 100644
74213 --- a/kernel/cgroup.c
74214 +++ b/kernel/cgroup.c
74215 @@ -5569,7 +5569,7 @@ static int cgroup_css_links_read(struct cgroup *cont,
74216 struct css_set *cg = link->cg;
74217 struct task_struct *task;
74218 int count = 0;
74219 - seq_printf(seq, "css_set %p\n", cg);
74220 + seq_printf(seq, "css_set %pK\n", cg);
74221 list_for_each_entry(task, &cg->tasks, cg_list) {
74222 if (count++ > MAX_TASKS_SHOWN_PER_CSS) {
74223 seq_puts(seq, " ...\n");
74224 diff --git a/kernel/compat.c b/kernel/compat.c
74225 index 19971d8..02fe2df 100644
74226 --- a/kernel/compat.c
74227 +++ b/kernel/compat.c
74228 @@ -13,6 +13,7 @@
74229
74230 #include <linux/linkage.h>
74231 #include <linux/compat.h>
74232 +#include <linux/module.h>
74233 #include <linux/errno.h>
74234 #include <linux/time.h>
74235 #include <linux/signal.h>
74236 @@ -220,7 +221,7 @@ static long compat_nanosleep_restart(struct restart_block *restart)
74237 mm_segment_t oldfs;
74238 long ret;
74239
74240 - restart->nanosleep.rmtp = (struct timespec __user *) &rmt;
74241 + restart->nanosleep.rmtp = (struct timespec __force_user *) &rmt;
74242 oldfs = get_fs();
74243 set_fs(KERNEL_DS);
74244 ret = hrtimer_nanosleep_restart(restart);
74245 @@ -252,7 +253,7 @@ asmlinkage long compat_sys_nanosleep(struct compat_timespec __user *rqtp,
74246 oldfs = get_fs();
74247 set_fs(KERNEL_DS);
74248 ret = hrtimer_nanosleep(&tu,
74249 - rmtp ? (struct timespec __user *)&rmt : NULL,
74250 + rmtp ? (struct timespec __force_user *)&rmt : NULL,
74251 HRTIMER_MODE_REL, CLOCK_MONOTONIC);
74252 set_fs(oldfs);
74253
74254 @@ -361,7 +362,7 @@ asmlinkage long compat_sys_sigpending(compat_old_sigset_t __user *set)
74255 mm_segment_t old_fs = get_fs();
74256
74257 set_fs(KERNEL_DS);
74258 - ret = sys_sigpending((old_sigset_t __user *) &s);
74259 + ret = sys_sigpending((old_sigset_t __force_user *) &s);
74260 set_fs(old_fs);
74261 if (ret == 0)
74262 ret = put_user(s, set);
74263 @@ -451,7 +452,7 @@ asmlinkage long compat_sys_old_getrlimit(unsigned int resource,
74264 mm_segment_t old_fs = get_fs();
74265
74266 set_fs(KERNEL_DS);
74267 - ret = sys_old_getrlimit(resource, &r);
74268 + ret = sys_old_getrlimit(resource, (struct rlimit __force_user *)&r);
74269 set_fs(old_fs);
74270
74271 if (!ret) {
74272 @@ -523,7 +524,7 @@ asmlinkage long compat_sys_getrusage(int who, struct compat_rusage __user *ru)
74273 mm_segment_t old_fs = get_fs();
74274
74275 set_fs(KERNEL_DS);
74276 - ret = sys_getrusage(who, (struct rusage __user *) &r);
74277 + ret = sys_getrusage(who, (struct rusage __force_user *) &r);
74278 set_fs(old_fs);
74279
74280 if (ret)
74281 @@ -552,8 +553,8 @@ COMPAT_SYSCALL_DEFINE4(wait4,
74282 set_fs (KERNEL_DS);
74283 ret = sys_wait4(pid,
74284 (stat_addr ?
74285 - (unsigned int __user *) &status : NULL),
74286 - options, (struct rusage __user *) &r);
74287 + (unsigned int __force_user *) &status : NULL),
74288 + options, (struct rusage __force_user *) &r);
74289 set_fs (old_fs);
74290
74291 if (ret > 0) {
74292 @@ -579,8 +580,8 @@ COMPAT_SYSCALL_DEFINE5(waitid,
74293 memset(&info, 0, sizeof(info));
74294
74295 set_fs(KERNEL_DS);
74296 - ret = sys_waitid(which, pid, (siginfo_t __user *)&info, options,
74297 - uru ? (struct rusage __user *)&ru : NULL);
74298 + ret = sys_waitid(which, pid, (siginfo_t __force_user *)&info, options,
74299 + uru ? (struct rusage __force_user *)&ru : NULL);
74300 set_fs(old_fs);
74301
74302 if ((ret < 0) || (info.si_signo == 0))
74303 @@ -714,8 +715,8 @@ long compat_sys_timer_settime(timer_t timer_id, int flags,
74304 oldfs = get_fs();
74305 set_fs(KERNEL_DS);
74306 err = sys_timer_settime(timer_id, flags,
74307 - (struct itimerspec __user *) &newts,
74308 - (struct itimerspec __user *) &oldts);
74309 + (struct itimerspec __force_user *) &newts,
74310 + (struct itimerspec __force_user *) &oldts);
74311 set_fs(oldfs);
74312 if (!err && old && put_compat_itimerspec(old, &oldts))
74313 return -EFAULT;
74314 @@ -732,7 +733,7 @@ long compat_sys_timer_gettime(timer_t timer_id,
74315 oldfs = get_fs();
74316 set_fs(KERNEL_DS);
74317 err = sys_timer_gettime(timer_id,
74318 - (struct itimerspec __user *) &ts);
74319 + (struct itimerspec __force_user *) &ts);
74320 set_fs(oldfs);
74321 if (!err && put_compat_itimerspec(setting, &ts))
74322 return -EFAULT;
74323 @@ -751,7 +752,7 @@ long compat_sys_clock_settime(clockid_t which_clock,
74324 oldfs = get_fs();
74325 set_fs(KERNEL_DS);
74326 err = sys_clock_settime(which_clock,
74327 - (struct timespec __user *) &ts);
74328 + (struct timespec __force_user *) &ts);
74329 set_fs(oldfs);
74330 return err;
74331 }
74332 @@ -766,7 +767,7 @@ long compat_sys_clock_gettime(clockid_t which_clock,
74333 oldfs = get_fs();
74334 set_fs(KERNEL_DS);
74335 err = sys_clock_gettime(which_clock,
74336 - (struct timespec __user *) &ts);
74337 + (struct timespec __force_user *) &ts);
74338 set_fs(oldfs);
74339 if (!err && put_compat_timespec(&ts, tp))
74340 return -EFAULT;
74341 @@ -786,7 +787,7 @@ long compat_sys_clock_adjtime(clockid_t which_clock,
74342
74343 oldfs = get_fs();
74344 set_fs(KERNEL_DS);
74345 - ret = sys_clock_adjtime(which_clock, (struct timex __user *) &txc);
74346 + ret = sys_clock_adjtime(which_clock, (struct timex __force_user *) &txc);
74347 set_fs(oldfs);
74348
74349 err = compat_put_timex(utp, &txc);
74350 @@ -806,7 +807,7 @@ long compat_sys_clock_getres(clockid_t which_clock,
74351 oldfs = get_fs();
74352 set_fs(KERNEL_DS);
74353 err = sys_clock_getres(which_clock,
74354 - (struct timespec __user *) &ts);
74355 + (struct timespec __force_user *) &ts);
74356 set_fs(oldfs);
74357 if (!err && tp && put_compat_timespec(&ts, tp))
74358 return -EFAULT;
74359 @@ -818,9 +819,9 @@ static long compat_clock_nanosleep_restart(struct restart_block *restart)
74360 long err;
74361 mm_segment_t oldfs;
74362 struct timespec tu;
74363 - struct compat_timespec *rmtp = restart->nanosleep.compat_rmtp;
74364 + struct compat_timespec __user *rmtp = restart->nanosleep.compat_rmtp;
74365
74366 - restart->nanosleep.rmtp = (struct timespec __user *) &tu;
74367 + restart->nanosleep.rmtp = (struct timespec __force_user *) &tu;
74368 oldfs = get_fs();
74369 set_fs(KERNEL_DS);
74370 err = clock_nanosleep_restart(restart);
74371 @@ -852,8 +853,8 @@ long compat_sys_clock_nanosleep(clockid_t which_clock, int flags,
74372 oldfs = get_fs();
74373 set_fs(KERNEL_DS);
74374 err = sys_clock_nanosleep(which_clock, flags,
74375 - (struct timespec __user *) &in,
74376 - (struct timespec __user *) &out);
74377 + (struct timespec __force_user *) &in,
74378 + (struct timespec __force_user *) &out);
74379 set_fs(oldfs);
74380
74381 if ((err == -ERESTART_RESTARTBLOCK) && rmtp &&
74382 diff --git a/kernel/configs.c b/kernel/configs.c
74383 index 42e8fa0..9e7406b 100644
74384 --- a/kernel/configs.c
74385 +++ b/kernel/configs.c
74386 @@ -74,8 +74,19 @@ static int __init ikconfig_init(void)
74387 struct proc_dir_entry *entry;
74388
74389 /* create the current config file */
74390 +#if defined(CONFIG_GRKERNSEC_PROC_ADD) || defined(CONFIG_GRKERNSEC_HIDESYM)
74391 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_HIDESYM)
74392 + entry = proc_create("config.gz", S_IFREG | S_IRUSR, NULL,
74393 + &ikconfig_file_ops);
74394 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
74395 + entry = proc_create("config.gz", S_IFREG | S_IRUSR | S_IRGRP, NULL,
74396 + &ikconfig_file_ops);
74397 +#endif
74398 +#else
74399 entry = proc_create("config.gz", S_IFREG | S_IRUGO, NULL,
74400 &ikconfig_file_ops);
74401 +#endif
74402 +
74403 if (!entry)
74404 return -ENOMEM;
74405
74406 diff --git a/kernel/cred.c b/kernel/cred.c
74407 index e0573a4..3874e41 100644
74408 --- a/kernel/cred.c
74409 +++ b/kernel/cred.c
74410 @@ -164,6 +164,16 @@ void exit_creds(struct task_struct *tsk)
74411 validate_creds(cred);
74412 alter_cred_subscribers(cred, -1);
74413 put_cred(cred);
74414 +
74415 +#ifdef CONFIG_GRKERNSEC_SETXID
74416 + cred = (struct cred *) tsk->delayed_cred;
74417 + if (cred != NULL) {
74418 + tsk->delayed_cred = NULL;
74419 + validate_creds(cred);
74420 + alter_cred_subscribers(cred, -1);
74421 + put_cred(cred);
74422 + }
74423 +#endif
74424 }
74425
74426 /**
74427 @@ -411,7 +421,7 @@ static bool cred_cap_issubset(const struct cred *set, const struct cred *subset)
74428 * Always returns 0 thus allowing this function to be tail-called at the end
74429 * of, say, sys_setgid().
74430 */
74431 -int commit_creds(struct cred *new)
74432 +static int __commit_creds(struct cred *new)
74433 {
74434 struct task_struct *task = current;
74435 const struct cred *old = task->real_cred;
74436 @@ -430,6 +440,8 @@ int commit_creds(struct cred *new)
74437
74438 get_cred(new); /* we will require a ref for the subj creds too */
74439
74440 + gr_set_role_label(task, new->uid, new->gid);
74441 +
74442 /* dumpability changes */
74443 if (!uid_eq(old->euid, new->euid) ||
74444 !gid_eq(old->egid, new->egid) ||
74445 @@ -479,6 +491,102 @@ int commit_creds(struct cred *new)
74446 put_cred(old);
74447 return 0;
74448 }
74449 +#ifdef CONFIG_GRKERNSEC_SETXID
74450 +extern int set_user(struct cred *new);
74451 +
74452 +void gr_delayed_cred_worker(void)
74453 +{
74454 + const struct cred *new = current->delayed_cred;
74455 + struct cred *ncred;
74456 +
74457 + current->delayed_cred = NULL;
74458 +
74459 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID) && new != NULL) {
74460 + // from doing get_cred on it when queueing this
74461 + put_cred(new);
74462 + return;
74463 + } else if (new == NULL)
74464 + return;
74465 +
74466 + ncred = prepare_creds();
74467 + if (!ncred)
74468 + goto die;
74469 + // uids
74470 + ncred->uid = new->uid;
74471 + ncred->euid = new->euid;
74472 + ncred->suid = new->suid;
74473 + ncred->fsuid = new->fsuid;
74474 + // gids
74475 + ncred->gid = new->gid;
74476 + ncred->egid = new->egid;
74477 + ncred->sgid = new->sgid;
74478 + ncred->fsgid = new->fsgid;
74479 + // groups
74480 + if (set_groups(ncred, new->group_info) < 0) {
74481 + abort_creds(ncred);
74482 + goto die;
74483 + }
74484 + // caps
74485 + ncred->securebits = new->securebits;
74486 + ncred->cap_inheritable = new->cap_inheritable;
74487 + ncred->cap_permitted = new->cap_permitted;
74488 + ncred->cap_effective = new->cap_effective;
74489 + ncred->cap_bset = new->cap_bset;
74490 +
74491 + if (set_user(ncred)) {
74492 + abort_creds(ncred);
74493 + goto die;
74494 + }
74495 +
74496 + // from doing get_cred on it when queueing this
74497 + put_cred(new);
74498 +
74499 + __commit_creds(ncred);
74500 + return;
74501 +die:
74502 + // from doing get_cred on it when queueing this
74503 + put_cred(new);
74504 + do_group_exit(SIGKILL);
74505 +}
74506 +#endif
74507 +
74508 +int commit_creds(struct cred *new)
74509 +{
74510 +#ifdef CONFIG_GRKERNSEC_SETXID
74511 + int ret;
74512 + int schedule_it = 0;
74513 + struct task_struct *t;
74514 +
74515 + /* we won't get called with tasklist_lock held for writing
74516 + and interrupts disabled as the cred struct in that case is
74517 + init_cred
74518 + */
74519 + if (grsec_enable_setxid && !current_is_single_threaded() &&
74520 + uid_eq(current_uid(), GLOBAL_ROOT_UID) &&
74521 + !uid_eq(new->uid, GLOBAL_ROOT_UID)) {
74522 + schedule_it = 1;
74523 + }
74524 + ret = __commit_creds(new);
74525 + if (schedule_it) {
74526 + rcu_read_lock();
74527 + read_lock(&tasklist_lock);
74528 + for (t = next_thread(current); t != current;
74529 + t = next_thread(t)) {
74530 + if (t->delayed_cred == NULL) {
74531 + t->delayed_cred = get_cred(new);
74532 + set_tsk_thread_flag(t, TIF_GRSEC_SETXID);
74533 + set_tsk_need_resched(t);
74534 + }
74535 + }
74536 + read_unlock(&tasklist_lock);
74537 + rcu_read_unlock();
74538 + }
74539 + return ret;
74540 +#else
74541 + return __commit_creds(new);
74542 +#endif
74543 +}
74544 +
74545 EXPORT_SYMBOL(commit_creds);
74546
74547 /**
74548 diff --git a/kernel/debug/debug_core.c b/kernel/debug/debug_core.c
74549 index c26278f..e323fb8 100644
74550 --- a/kernel/debug/debug_core.c
74551 +++ b/kernel/debug/debug_core.c
74552 @@ -123,7 +123,7 @@ static DEFINE_RAW_SPINLOCK(dbg_slave_lock);
74553 */
74554 static atomic_t masters_in_kgdb;
74555 static atomic_t slaves_in_kgdb;
74556 -static atomic_t kgdb_break_tasklet_var;
74557 +static atomic_unchecked_t kgdb_break_tasklet_var;
74558 atomic_t kgdb_setting_breakpoint;
74559
74560 struct task_struct *kgdb_usethread;
74561 @@ -133,7 +133,7 @@ int kgdb_single_step;
74562 static pid_t kgdb_sstep_pid;
74563
74564 /* to keep track of the CPU which is doing the single stepping*/
74565 -atomic_t kgdb_cpu_doing_single_step = ATOMIC_INIT(-1);
74566 +atomic_unchecked_t kgdb_cpu_doing_single_step = ATOMIC_INIT(-1);
74567
74568 /*
74569 * If you are debugging a problem where roundup (the collection of
74570 @@ -541,7 +541,7 @@ return_normal:
74571 * kernel will only try for the value of sstep_tries before
74572 * giving up and continuing on.
74573 */
74574 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1 &&
74575 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1 &&
74576 (kgdb_info[cpu].task &&
74577 kgdb_info[cpu].task->pid != kgdb_sstep_pid) && --sstep_tries) {
74578 atomic_set(&kgdb_active, -1);
74579 @@ -635,8 +635,8 @@ cpu_master_loop:
74580 }
74581
74582 kgdb_restore:
74583 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1) {
74584 - int sstep_cpu = atomic_read(&kgdb_cpu_doing_single_step);
74585 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1) {
74586 + int sstep_cpu = atomic_read_unchecked(&kgdb_cpu_doing_single_step);
74587 if (kgdb_info[sstep_cpu].task)
74588 kgdb_sstep_pid = kgdb_info[sstep_cpu].task->pid;
74589 else
74590 @@ -888,18 +888,18 @@ static void kgdb_unregister_callbacks(void)
74591 static void kgdb_tasklet_bpt(unsigned long ing)
74592 {
74593 kgdb_breakpoint();
74594 - atomic_set(&kgdb_break_tasklet_var, 0);
74595 + atomic_set_unchecked(&kgdb_break_tasklet_var, 0);
74596 }
74597
74598 static DECLARE_TASKLET(kgdb_tasklet_breakpoint, kgdb_tasklet_bpt, 0);
74599
74600 void kgdb_schedule_breakpoint(void)
74601 {
74602 - if (atomic_read(&kgdb_break_tasklet_var) ||
74603 + if (atomic_read_unchecked(&kgdb_break_tasklet_var) ||
74604 atomic_read(&kgdb_active) != -1 ||
74605 atomic_read(&kgdb_setting_breakpoint))
74606 return;
74607 - atomic_inc(&kgdb_break_tasklet_var);
74608 + atomic_inc_unchecked(&kgdb_break_tasklet_var);
74609 tasklet_schedule(&kgdb_tasklet_breakpoint);
74610 }
74611 EXPORT_SYMBOL_GPL(kgdb_schedule_breakpoint);
74612 diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c
74613 index 00eb8f7..d7e3244 100644
74614 --- a/kernel/debug/kdb/kdb_main.c
74615 +++ b/kernel/debug/kdb/kdb_main.c
74616 @@ -1974,7 +1974,7 @@ static int kdb_lsmod(int argc, const char **argv)
74617 continue;
74618
74619 kdb_printf("%-20s%8u 0x%p ", mod->name,
74620 - mod->core_size, (void *)mod);
74621 + mod->core_size_rx + mod->core_size_rw, (void *)mod);
74622 #ifdef CONFIG_MODULE_UNLOAD
74623 kdb_printf("%4ld ", module_refcount(mod));
74624 #endif
74625 @@ -1984,7 +1984,7 @@ static int kdb_lsmod(int argc, const char **argv)
74626 kdb_printf(" (Loading)");
74627 else
74628 kdb_printf(" (Live)");
74629 - kdb_printf(" 0x%p", mod->module_core);
74630 + kdb_printf(" 0x%p 0x%p", mod->module_core_rx, mod->module_core_rw);
74631
74632 #ifdef CONFIG_MODULE_UNLOAD
74633 {
74634 diff --git a/kernel/events/core.c b/kernel/events/core.c
74635 index 9fcb094..fd68c54 100644
74636 --- a/kernel/events/core.c
74637 +++ b/kernel/events/core.c
74638 @@ -155,7 +155,11 @@ static struct srcu_struct pmus_srcu;
74639 * 1 - disallow cpu events for unpriv
74640 * 2 - disallow kernel profiling for unpriv
74641 */
74642 -int sysctl_perf_event_paranoid __read_mostly = 1;
74643 +#ifdef CONFIG_GRKERNSEC_HIDESYM
74644 +int sysctl_perf_event_legitimately_concerned __read_mostly = 2;
74645 +#else
74646 +int sysctl_perf_event_legitimately_concerned __read_mostly = 1;
74647 +#endif
74648
74649 /* Minimum for 512 kiB + 1 user control page */
74650 int sysctl_perf_event_mlock __read_mostly = 512 + (PAGE_SIZE / 1024); /* 'free' kiB per user */
74651 @@ -182,7 +186,7 @@ int perf_proc_update_handler(struct ctl_table *table, int write,
74652 return 0;
74653 }
74654
74655 -static atomic64_t perf_event_id;
74656 +static atomic64_unchecked_t perf_event_id;
74657
74658 static void cpu_ctx_sched_out(struct perf_cpu_context *cpuctx,
74659 enum event_type_t event_type);
74660 @@ -2677,7 +2681,7 @@ static void __perf_event_read(void *info)
74661
74662 static inline u64 perf_event_count(struct perf_event *event)
74663 {
74664 - return local64_read(&event->count) + atomic64_read(&event->child_count);
74665 + return local64_read(&event->count) + atomic64_read_unchecked(&event->child_count);
74666 }
74667
74668 static u64 perf_event_read(struct perf_event *event)
74669 @@ -3007,9 +3011,9 @@ u64 perf_event_read_value(struct perf_event *event, u64 *enabled, u64 *running)
74670 mutex_lock(&event->child_mutex);
74671 total += perf_event_read(event);
74672 *enabled += event->total_time_enabled +
74673 - atomic64_read(&event->child_total_time_enabled);
74674 + atomic64_read_unchecked(&event->child_total_time_enabled);
74675 *running += event->total_time_running +
74676 - atomic64_read(&event->child_total_time_running);
74677 + atomic64_read_unchecked(&event->child_total_time_running);
74678
74679 list_for_each_entry(child, &event->child_list, child_list) {
74680 total += perf_event_read(child);
74681 @@ -3412,10 +3416,10 @@ void perf_event_update_userpage(struct perf_event *event)
74682 userpg->offset -= local64_read(&event->hw.prev_count);
74683
74684 userpg->time_enabled = enabled +
74685 - atomic64_read(&event->child_total_time_enabled);
74686 + atomic64_read_unchecked(&event->child_total_time_enabled);
74687
74688 userpg->time_running = running +
74689 - atomic64_read(&event->child_total_time_running);
74690 + atomic64_read_unchecked(&event->child_total_time_running);
74691
74692 arch_perf_update_userpage(userpg, now);
74693
74694 @@ -3886,7 +3890,7 @@ perf_output_sample_ustack(struct perf_output_handle *handle, u64 dump_size,
74695
74696 /* Data. */
74697 sp = perf_user_stack_pointer(regs);
74698 - rem = __output_copy_user(handle, (void *) sp, dump_size);
74699 + rem = __output_copy_user(handle, (void __user *) sp, dump_size);
74700 dyn_size = dump_size - rem;
74701
74702 perf_output_skip(handle, rem);
74703 @@ -3974,11 +3978,11 @@ static void perf_output_read_one(struct perf_output_handle *handle,
74704 values[n++] = perf_event_count(event);
74705 if (read_format & PERF_FORMAT_TOTAL_TIME_ENABLED) {
74706 values[n++] = enabled +
74707 - atomic64_read(&event->child_total_time_enabled);
74708 + atomic64_read_unchecked(&event->child_total_time_enabled);
74709 }
74710 if (read_format & PERF_FORMAT_TOTAL_TIME_RUNNING) {
74711 values[n++] = running +
74712 - atomic64_read(&event->child_total_time_running);
74713 + atomic64_read_unchecked(&event->child_total_time_running);
74714 }
74715 if (read_format & PERF_FORMAT_ID)
74716 values[n++] = primary_event_id(event);
74717 @@ -4726,12 +4730,12 @@ static void perf_event_mmap_event(struct perf_mmap_event *mmap_event)
74718 * need to add enough zero bytes after the string to handle
74719 * the 64bit alignment we do later.
74720 */
74721 - buf = kzalloc(PATH_MAX + sizeof(u64), GFP_KERNEL);
74722 + buf = kzalloc(PATH_MAX, GFP_KERNEL);
74723 if (!buf) {
74724 name = strncpy(tmp, "//enomem", sizeof(tmp));
74725 goto got_name;
74726 }
74727 - name = d_path(&file->f_path, buf, PATH_MAX);
74728 + name = d_path(&file->f_path, buf, PATH_MAX - sizeof(u64));
74729 if (IS_ERR(name)) {
74730 name = strncpy(tmp, "//toolong", sizeof(tmp));
74731 goto got_name;
74732 @@ -6167,7 +6171,7 @@ perf_event_alloc(struct perf_event_attr *attr, int cpu,
74733 event->parent = parent_event;
74734
74735 event->ns = get_pid_ns(task_active_pid_ns(current));
74736 - event->id = atomic64_inc_return(&perf_event_id);
74737 + event->id = atomic64_inc_return_unchecked(&perf_event_id);
74738
74739 event->state = PERF_EVENT_STATE_INACTIVE;
74740
74741 @@ -6795,10 +6799,10 @@ static void sync_child_event(struct perf_event *child_event,
74742 /*
74743 * Add back the child's count to the parent's count:
74744 */
74745 - atomic64_add(child_val, &parent_event->child_count);
74746 - atomic64_add(child_event->total_time_enabled,
74747 + atomic64_add_unchecked(child_val, &parent_event->child_count);
74748 + atomic64_add_unchecked(child_event->total_time_enabled,
74749 &parent_event->child_total_time_enabled);
74750 - atomic64_add(child_event->total_time_running,
74751 + atomic64_add_unchecked(child_event->total_time_running,
74752 &parent_event->child_total_time_running);
74753
74754 /*
74755 diff --git a/kernel/events/internal.h b/kernel/events/internal.h
74756 index eb675c4..54912ff 100644
74757 --- a/kernel/events/internal.h
74758 +++ b/kernel/events/internal.h
74759 @@ -77,10 +77,10 @@ static inline unsigned long perf_data_size(struct ring_buffer *rb)
74760 return rb->nr_pages << (PAGE_SHIFT + page_order(rb));
74761 }
74762
74763 -#define DEFINE_OUTPUT_COPY(func_name, memcpy_func) \
74764 +#define DEFINE_OUTPUT_COPY(func_name, memcpy_func, user) \
74765 static inline unsigned int \
74766 func_name(struct perf_output_handle *handle, \
74767 - const void *buf, unsigned int len) \
74768 + const void user *buf, unsigned int len) \
74769 { \
74770 unsigned long size, written; \
74771 \
74772 @@ -112,17 +112,17 @@ static inline int memcpy_common(void *dst, const void *src, size_t n)
74773 return n;
74774 }
74775
74776 -DEFINE_OUTPUT_COPY(__output_copy, memcpy_common)
74777 +DEFINE_OUTPUT_COPY(__output_copy, memcpy_common, )
74778
74779 #define MEMCPY_SKIP(dst, src, n) (n)
74780
74781 -DEFINE_OUTPUT_COPY(__output_skip, MEMCPY_SKIP)
74782 +DEFINE_OUTPUT_COPY(__output_skip, MEMCPY_SKIP, )
74783
74784 #ifndef arch_perf_out_copy_user
74785 #define arch_perf_out_copy_user __copy_from_user_inatomic
74786 #endif
74787
74788 -DEFINE_OUTPUT_COPY(__output_copy_user, arch_perf_out_copy_user)
74789 +DEFINE_OUTPUT_COPY(__output_copy_user, arch_perf_out_copy_user, __user)
74790
74791 /* Callchain handling */
74792 extern struct perf_callchain_entry *
74793 diff --git a/kernel/exit.c b/kernel/exit.c
74794 index 60bc027..ca6d727 100644
74795 --- a/kernel/exit.c
74796 +++ b/kernel/exit.c
74797 @@ -172,6 +172,10 @@ void release_task(struct task_struct * p)
74798 struct task_struct *leader;
74799 int zap_leader;
74800 repeat:
74801 +#ifdef CONFIG_NET
74802 + gr_del_task_from_ip_table(p);
74803 +#endif
74804 +
74805 /* don't need to get the RCU readlock here - the process is dead and
74806 * can't be modifying its own credentials. But shut RCU-lockdep up */
74807 rcu_read_lock();
74808 @@ -340,7 +344,7 @@ int allow_signal(int sig)
74809 * know it'll be handled, so that they don't get converted to
74810 * SIGKILL or just silently dropped.
74811 */
74812 - current->sighand->action[(sig)-1].sa.sa_handler = (void __user *)2;
74813 + current->sighand->action[(sig)-1].sa.sa_handler = (__force void __user *)2;
74814 recalc_sigpending();
74815 spin_unlock_irq(&current->sighand->siglock);
74816 return 0;
74817 @@ -710,6 +714,8 @@ void do_exit(long code)
74818 struct task_struct *tsk = current;
74819 int group_dead;
74820
74821 + set_fs(USER_DS);
74822 +
74823 profile_task_exit(tsk);
74824
74825 WARN_ON(blk_needs_flush_plug(tsk));
74826 @@ -726,7 +732,6 @@ void do_exit(long code)
74827 * mm_release()->clear_child_tid() from writing to a user-controlled
74828 * kernel address.
74829 */
74830 - set_fs(USER_DS);
74831
74832 ptrace_event(PTRACE_EVENT_EXIT, code);
74833
74834 @@ -785,6 +790,9 @@ void do_exit(long code)
74835 tsk->exit_code = code;
74836 taskstats_exit(tsk, group_dead);
74837
74838 + gr_acl_handle_psacct(tsk, code);
74839 + gr_acl_handle_exit();
74840 +
74841 exit_mm(tsk);
74842
74843 if (group_dead)
74844 @@ -905,7 +913,7 @@ SYSCALL_DEFINE1(exit, int, error_code)
74845 * Take down every thread in the group. This is called by fatal signals
74846 * as well as by sys_exit_group (below).
74847 */
74848 -void
74849 +__noreturn void
74850 do_group_exit(int exit_code)
74851 {
74852 struct signal_struct *sig = current->signal;
74853 diff --git a/kernel/fork.c b/kernel/fork.c
74854 index 1766d32..c0e44e2 100644
74855 --- a/kernel/fork.c
74856 +++ b/kernel/fork.c
74857 @@ -318,7 +318,7 @@ static struct task_struct *dup_task_struct(struct task_struct *orig)
74858 *stackend = STACK_END_MAGIC; /* for overflow detection */
74859
74860 #ifdef CONFIG_CC_STACKPROTECTOR
74861 - tsk->stack_canary = get_random_int();
74862 + tsk->stack_canary = pax_get_random_long();
74863 #endif
74864
74865 /*
74866 @@ -344,13 +344,81 @@ free_tsk:
74867 }
74868
74869 #ifdef CONFIG_MMU
74870 +static struct vm_area_struct *dup_vma(struct mm_struct *mm, struct mm_struct *oldmm, struct vm_area_struct *mpnt)
74871 +{
74872 + struct vm_area_struct *tmp;
74873 + unsigned long charge;
74874 + struct mempolicy *pol;
74875 + struct file *file;
74876 +
74877 + charge = 0;
74878 + if (mpnt->vm_flags & VM_ACCOUNT) {
74879 + unsigned long len = vma_pages(mpnt);
74880 +
74881 + if (security_vm_enough_memory_mm(oldmm, len)) /* sic */
74882 + goto fail_nomem;
74883 + charge = len;
74884 + }
74885 + tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
74886 + if (!tmp)
74887 + goto fail_nomem;
74888 + *tmp = *mpnt;
74889 + tmp->vm_mm = mm;
74890 + INIT_LIST_HEAD(&tmp->anon_vma_chain);
74891 + pol = mpol_dup(vma_policy(mpnt));
74892 + if (IS_ERR(pol))
74893 + goto fail_nomem_policy;
74894 + vma_set_policy(tmp, pol);
74895 + if (anon_vma_fork(tmp, mpnt))
74896 + goto fail_nomem_anon_vma_fork;
74897 + tmp->vm_flags &= ~VM_LOCKED;
74898 + tmp->vm_next = tmp->vm_prev = NULL;
74899 + tmp->vm_mirror = NULL;
74900 + file = tmp->vm_file;
74901 + if (file) {
74902 + struct inode *inode = file_inode(file);
74903 + struct address_space *mapping = file->f_mapping;
74904 +
74905 + get_file(file);
74906 + if (tmp->vm_flags & VM_DENYWRITE)
74907 + atomic_dec(&inode->i_writecount);
74908 + mutex_lock(&mapping->i_mmap_mutex);
74909 + if (tmp->vm_flags & VM_SHARED)
74910 + mapping->i_mmap_writable++;
74911 + flush_dcache_mmap_lock(mapping);
74912 + /* insert tmp into the share list, just after mpnt */
74913 + if (unlikely(tmp->vm_flags & VM_NONLINEAR))
74914 + vma_nonlinear_insert(tmp, &mapping->i_mmap_nonlinear);
74915 + else
74916 + vma_interval_tree_insert_after(tmp, mpnt, &mapping->i_mmap);
74917 + flush_dcache_mmap_unlock(mapping);
74918 + mutex_unlock(&mapping->i_mmap_mutex);
74919 + }
74920 +
74921 + /*
74922 + * Clear hugetlb-related page reserves for children. This only
74923 + * affects MAP_PRIVATE mappings. Faults generated by the child
74924 + * are not guaranteed to succeed, even if read-only
74925 + */
74926 + if (is_vm_hugetlb_page(tmp))
74927 + reset_vma_resv_huge_pages(tmp);
74928 +
74929 + return tmp;
74930 +
74931 +fail_nomem_anon_vma_fork:
74932 + mpol_put(pol);
74933 +fail_nomem_policy:
74934 + kmem_cache_free(vm_area_cachep, tmp);
74935 +fail_nomem:
74936 + vm_unacct_memory(charge);
74937 + return NULL;
74938 +}
74939 +
74940 static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
74941 {
74942 struct vm_area_struct *mpnt, *tmp, *prev, **pprev;
74943 struct rb_node **rb_link, *rb_parent;
74944 int retval;
74945 - unsigned long charge;
74946 - struct mempolicy *pol;
74947
74948 uprobe_start_dup_mmap();
74949 down_write(&oldmm->mmap_sem);
74950 @@ -364,8 +432,8 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
74951 mm->locked_vm = 0;
74952 mm->mmap = NULL;
74953 mm->mmap_cache = NULL;
74954 - mm->free_area_cache = oldmm->mmap_base;
74955 - mm->cached_hole_size = ~0UL;
74956 + mm->free_area_cache = oldmm->free_area_cache;
74957 + mm->cached_hole_size = oldmm->cached_hole_size;
74958 mm->map_count = 0;
74959 cpumask_clear(mm_cpumask(mm));
74960 mm->mm_rb = RB_ROOT;
74961 @@ -381,57 +449,15 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
74962
74963 prev = NULL;
74964 for (mpnt = oldmm->mmap; mpnt; mpnt = mpnt->vm_next) {
74965 - struct file *file;
74966 -
74967 if (mpnt->vm_flags & VM_DONTCOPY) {
74968 vm_stat_account(mm, mpnt->vm_flags, mpnt->vm_file,
74969 -vma_pages(mpnt));
74970 continue;
74971 }
74972 - charge = 0;
74973 - if (mpnt->vm_flags & VM_ACCOUNT) {
74974 - unsigned long len = vma_pages(mpnt);
74975 -
74976 - if (security_vm_enough_memory_mm(oldmm, len)) /* sic */
74977 - goto fail_nomem;
74978 - charge = len;
74979 - }
74980 - tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
74981 - if (!tmp)
74982 - goto fail_nomem;
74983 - *tmp = *mpnt;
74984 - INIT_LIST_HEAD(&tmp->anon_vma_chain);
74985 - pol = mpol_dup(vma_policy(mpnt));
74986 - retval = PTR_ERR(pol);
74987 - if (IS_ERR(pol))
74988 - goto fail_nomem_policy;
74989 - vma_set_policy(tmp, pol);
74990 - tmp->vm_mm = mm;
74991 - if (anon_vma_fork(tmp, mpnt))
74992 - goto fail_nomem_anon_vma_fork;
74993 - tmp->vm_flags &= ~VM_LOCKED;
74994 - tmp->vm_next = tmp->vm_prev = NULL;
74995 - file = tmp->vm_file;
74996 - if (file) {
74997 - struct inode *inode = file_inode(file);
74998 - struct address_space *mapping = file->f_mapping;
74999 -
75000 - get_file(file);
75001 - if (tmp->vm_flags & VM_DENYWRITE)
75002 - atomic_dec(&inode->i_writecount);
75003 - mutex_lock(&mapping->i_mmap_mutex);
75004 - if (tmp->vm_flags & VM_SHARED)
75005 - mapping->i_mmap_writable++;
75006 - flush_dcache_mmap_lock(mapping);
75007 - /* insert tmp into the share list, just after mpnt */
75008 - if (unlikely(tmp->vm_flags & VM_NONLINEAR))
75009 - vma_nonlinear_insert(tmp,
75010 - &mapping->i_mmap_nonlinear);
75011 - else
75012 - vma_interval_tree_insert_after(tmp, mpnt,
75013 - &mapping->i_mmap);
75014 - flush_dcache_mmap_unlock(mapping);
75015 - mutex_unlock(&mapping->i_mmap_mutex);
75016 + tmp = dup_vma(mm, oldmm, mpnt);
75017 + if (!tmp) {
75018 + retval = -ENOMEM;
75019 + goto out;
75020 }
75021
75022 /*
75023 @@ -463,6 +489,31 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
75024 if (retval)
75025 goto out;
75026 }
75027 +
75028 +#ifdef CONFIG_PAX_SEGMEXEC
75029 + if (oldmm->pax_flags & MF_PAX_SEGMEXEC) {
75030 + struct vm_area_struct *mpnt_m;
75031 +
75032 + for (mpnt = oldmm->mmap, mpnt_m = mm->mmap; mpnt; mpnt = mpnt->vm_next, mpnt_m = mpnt_m->vm_next) {
75033 + BUG_ON(!mpnt_m || mpnt_m->vm_mirror || mpnt->vm_mm != oldmm || mpnt_m->vm_mm != mm);
75034 +
75035 + if (!mpnt->vm_mirror)
75036 + continue;
75037 +
75038 + if (mpnt->vm_end <= SEGMEXEC_TASK_SIZE) {
75039 + BUG_ON(mpnt->vm_mirror->vm_mirror != mpnt);
75040 + mpnt->vm_mirror = mpnt_m;
75041 + } else {
75042 + BUG_ON(mpnt->vm_mirror->vm_mirror == mpnt || mpnt->vm_mirror->vm_mirror->vm_mm != mm);
75043 + mpnt_m->vm_mirror = mpnt->vm_mirror->vm_mirror;
75044 + mpnt_m->vm_mirror->vm_mirror = mpnt_m;
75045 + mpnt->vm_mirror->vm_mirror = mpnt;
75046 + }
75047 + }
75048 + BUG_ON(mpnt_m);
75049 + }
75050 +#endif
75051 +
75052 /* a new mm has just been created */
75053 arch_dup_mmap(oldmm, mm);
75054 retval = 0;
75055 @@ -472,14 +523,6 @@ out:
75056 up_write(&oldmm->mmap_sem);
75057 uprobe_end_dup_mmap();
75058 return retval;
75059 -fail_nomem_anon_vma_fork:
75060 - mpol_put(pol);
75061 -fail_nomem_policy:
75062 - kmem_cache_free(vm_area_cachep, tmp);
75063 -fail_nomem:
75064 - retval = -ENOMEM;
75065 - vm_unacct_memory(charge);
75066 - goto out;
75067 }
75068
75069 static inline int mm_alloc_pgd(struct mm_struct *mm)
75070 @@ -694,8 +737,8 @@ struct mm_struct *mm_access(struct task_struct *task, unsigned int mode)
75071 return ERR_PTR(err);
75072
75073 mm = get_task_mm(task);
75074 - if (mm && mm != current->mm &&
75075 - !ptrace_may_access(task, mode)) {
75076 + if (mm && ((mm != current->mm && !ptrace_may_access(task, mode)) ||
75077 + (mode == PTRACE_MODE_ATTACH && (gr_handle_proc_ptrace(task) || gr_acl_handle_procpidmem(task))))) {
75078 mmput(mm);
75079 mm = ERR_PTR(-EACCES);
75080 }
75081 @@ -917,13 +960,20 @@ static int copy_fs(unsigned long clone_flags, struct task_struct *tsk)
75082 spin_unlock(&fs->lock);
75083 return -EAGAIN;
75084 }
75085 - fs->users++;
75086 + atomic_inc(&fs->users);
75087 spin_unlock(&fs->lock);
75088 return 0;
75089 }
75090 tsk->fs = copy_fs_struct(fs);
75091 if (!tsk->fs)
75092 return -ENOMEM;
75093 + /* Carry through gr_chroot_dentry and is_chrooted instead
75094 + of recomputing it here. Already copied when the task struct
75095 + is duplicated. This allows pivot_root to not be treated as
75096 + a chroot
75097 + */
75098 + //gr_set_chroot_entries(tsk, &tsk->fs->root);
75099 +
75100 return 0;
75101 }
75102
75103 @@ -1196,6 +1246,9 @@ static struct task_struct *copy_process(unsigned long clone_flags,
75104 DEBUG_LOCKS_WARN_ON(!p->softirqs_enabled);
75105 #endif
75106 retval = -EAGAIN;
75107 +
75108 + gr_learn_resource(p, RLIMIT_NPROC, atomic_read(&p->real_cred->user->processes), 0);
75109 +
75110 if (atomic_read(&p->real_cred->user->processes) >=
75111 task_rlimit(p, RLIMIT_NPROC)) {
75112 if (!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_RESOURCE) &&
75113 @@ -1441,6 +1494,11 @@ static struct task_struct *copy_process(unsigned long clone_flags,
75114 goto bad_fork_free_pid;
75115 }
75116
75117 + /* synchronizes with gr_set_acls()
75118 + we need to call this past the point of no return for fork()
75119 + */
75120 + gr_copy_label(p);
75121 +
75122 if (clone_flags & CLONE_THREAD) {
75123 current->signal->nr_threads++;
75124 atomic_inc(&current->signal->live);
75125 @@ -1524,6 +1582,8 @@ bad_fork_cleanup_count:
75126 bad_fork_free:
75127 free_task(p);
75128 fork_out:
75129 + gr_log_forkfail(retval);
75130 +
75131 return ERR_PTR(retval);
75132 }
75133
75134 @@ -1574,6 +1634,23 @@ long do_fork(unsigned long clone_flags,
75135 return -EINVAL;
75136 }
75137
75138 +#ifdef CONFIG_GRKERNSEC
75139 + if (clone_flags & CLONE_NEWUSER) {
75140 + /*
75141 + * This doesn't really inspire confidence:
75142 + * http://marc.info/?l=linux-kernel&m=135543612731939&w=2
75143 + * http://marc.info/?l=linux-kernel&m=135545831607095&w=2
75144 + * Increases kernel attack surface in areas developers
75145 + * previously cared little about ("low importance due
75146 + * to requiring "root" capability")
75147 + * To be removed when this code receives *proper* review
75148 + */
75149 + if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SETUID) ||
75150 + !capable(CAP_SETGID))
75151 + return -EPERM;
75152 + }
75153 +#endif
75154 +
75155 /*
75156 * Determine whether and which event to report to ptracer. When
75157 * called from kernel_thread or CLONE_UNTRACED is explicitly
75158 @@ -1608,6 +1685,8 @@ long do_fork(unsigned long clone_flags,
75159 if (clone_flags & CLONE_PARENT_SETTID)
75160 put_user(nr, parent_tidptr);
75161
75162 + gr_handle_brute_check();
75163 +
75164 if (clone_flags & CLONE_VFORK) {
75165 p->vfork_done = &vfork;
75166 init_completion(&vfork);
75167 @@ -1761,7 +1840,7 @@ static int unshare_fs(unsigned long unshare_flags, struct fs_struct **new_fsp)
75168 return 0;
75169
75170 /* don't need lock here; in the worst case we'll do useless copy */
75171 - if (fs->users == 1)
75172 + if (atomic_read(&fs->users) == 1)
75173 return 0;
75174
75175 *new_fsp = copy_fs_struct(fs);
75176 @@ -1873,7 +1952,8 @@ SYSCALL_DEFINE1(unshare, unsigned long, unshare_flags)
75177 fs = current->fs;
75178 spin_lock(&fs->lock);
75179 current->fs = new_fs;
75180 - if (--fs->users)
75181 + gr_set_chroot_entries(current, &current->fs->root);
75182 + if (atomic_dec_return(&fs->users))
75183 new_fs = NULL;
75184 else
75185 new_fs = fs;
75186 diff --git a/kernel/futex.c b/kernel/futex.c
75187 index b26dcfc..39e266a 100644
75188 --- a/kernel/futex.c
75189 +++ b/kernel/futex.c
75190 @@ -54,6 +54,7 @@
75191 #include <linux/mount.h>
75192 #include <linux/pagemap.h>
75193 #include <linux/syscalls.h>
75194 +#include <linux/ptrace.h>
75195 #include <linux/signal.h>
75196 #include <linux/export.h>
75197 #include <linux/magic.h>
75198 @@ -241,6 +242,11 @@ get_futex_key(u32 __user *uaddr, int fshared, union futex_key *key, int rw)
75199 struct page *page, *page_head;
75200 int err, ro = 0;
75201
75202 +#ifdef CONFIG_PAX_SEGMEXEC
75203 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && address >= SEGMEXEC_TASK_SIZE)
75204 + return -EFAULT;
75205 +#endif
75206 +
75207 /*
75208 * The futex address must be "naturally" aligned.
75209 */
75210 @@ -2732,6 +2738,7 @@ static int __init futex_init(void)
75211 {
75212 u32 curval;
75213 int i;
75214 + mm_segment_t oldfs;
75215
75216 /*
75217 * This will fail and we want it. Some arch implementations do
75218 @@ -2743,8 +2750,11 @@ static int __init futex_init(void)
75219 * implementation, the non-functional ones will return
75220 * -ENOSYS.
75221 */
75222 + oldfs = get_fs();
75223 + set_fs(USER_DS);
75224 if (cmpxchg_futex_value_locked(&curval, NULL, 0, 0) == -EFAULT)
75225 futex_cmpxchg_enabled = 1;
75226 + set_fs(oldfs);
75227
75228 for (i = 0; i < ARRAY_SIZE(futex_queues); i++) {
75229 plist_head_init(&futex_queues[i].chain);
75230 diff --git a/kernel/futex_compat.c b/kernel/futex_compat.c
75231 index f9f44fd..29885e4 100644
75232 --- a/kernel/futex_compat.c
75233 +++ b/kernel/futex_compat.c
75234 @@ -32,7 +32,7 @@ fetch_robust_entry(compat_uptr_t *uentry, struct robust_list __user **entry,
75235 return 0;
75236 }
75237
75238 -static void __user *futex_uaddr(struct robust_list __user *entry,
75239 +static void __user __intentional_overflow(-1) *futex_uaddr(struct robust_list __user *entry,
75240 compat_long_t futex_offset)
75241 {
75242 compat_uptr_t base = ptr_to_compat(entry);
75243 diff --git a/kernel/gcov/base.c b/kernel/gcov/base.c
75244 index 9b22d03..6295b62 100644
75245 --- a/kernel/gcov/base.c
75246 +++ b/kernel/gcov/base.c
75247 @@ -102,11 +102,6 @@ void gcov_enable_events(void)
75248 }
75249
75250 #ifdef CONFIG_MODULES
75251 -static inline int within(void *addr, void *start, unsigned long size)
75252 -{
75253 - return ((addr >= start) && (addr < start + size));
75254 -}
75255 -
75256 /* Update list and generate events when modules are unloaded. */
75257 static int gcov_module_notifier(struct notifier_block *nb, unsigned long event,
75258 void *data)
75259 @@ -121,7 +116,7 @@ static int gcov_module_notifier(struct notifier_block *nb, unsigned long event,
75260 prev = NULL;
75261 /* Remove entries located in module from linked list. */
75262 for (info = gcov_info_head; info; info = info->next) {
75263 - if (within(info, mod->module_core, mod->core_size)) {
75264 + if (within_module_core_rw((unsigned long)info, mod)) {
75265 if (prev)
75266 prev->next = info->next;
75267 else
75268 diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c
75269 index 7ef5556..8247f11 100644
75270 --- a/kernel/hrtimer.c
75271 +++ b/kernel/hrtimer.c
75272 @@ -1416,7 +1416,7 @@ void hrtimer_peek_ahead_timers(void)
75273 local_irq_restore(flags);
75274 }
75275
75276 -static void run_hrtimer_softirq(struct softirq_action *h)
75277 +static void run_hrtimer_softirq(void)
75278 {
75279 struct hrtimer_cpu_base *cpu_base = &__get_cpu_var(hrtimer_bases);
75280
75281 @@ -1758,7 +1758,7 @@ static int __cpuinit hrtimer_cpu_notify(struct notifier_block *self,
75282 return NOTIFY_OK;
75283 }
75284
75285 -static struct notifier_block __cpuinitdata hrtimers_nb = {
75286 +static struct notifier_block hrtimers_nb = {
75287 .notifier_call = hrtimer_cpu_notify,
75288 };
75289
75290 diff --git a/kernel/irq_work.c b/kernel/irq_work.c
75291 index 55fcce6..0e4cf34 100644
75292 --- a/kernel/irq_work.c
75293 +++ b/kernel/irq_work.c
75294 @@ -189,12 +189,13 @@ static int irq_work_cpu_notify(struct notifier_block *self,
75295 return NOTIFY_OK;
75296 }
75297
75298 -static struct notifier_block cpu_notify;
75299 +static struct notifier_block cpu_notify = {
75300 + .notifier_call = irq_work_cpu_notify,
75301 + .priority = 0,
75302 +};
75303
75304 static __init int irq_work_init_cpu_notifier(void)
75305 {
75306 - cpu_notify.notifier_call = irq_work_cpu_notify;
75307 - cpu_notify.priority = 0;
75308 register_cpu_notifier(&cpu_notify);
75309 return 0;
75310 }
75311 diff --git a/kernel/jump_label.c b/kernel/jump_label.c
75312 index 60f48fa..7f3a770 100644
75313 --- a/kernel/jump_label.c
75314 +++ b/kernel/jump_label.c
75315 @@ -13,6 +13,7 @@
75316 #include <linux/sort.h>
75317 #include <linux/err.h>
75318 #include <linux/static_key.h>
75319 +#include <linux/mm.h>
75320
75321 #ifdef HAVE_JUMP_LABEL
75322
75323 @@ -50,7 +51,9 @@ jump_label_sort_entries(struct jump_entry *start, struct jump_entry *stop)
75324
75325 size = (((unsigned long)stop - (unsigned long)start)
75326 / sizeof(struct jump_entry));
75327 + pax_open_kernel();
75328 sort(start, size, sizeof(struct jump_entry), jump_label_cmp, NULL);
75329 + pax_close_kernel();
75330 }
75331
75332 static void jump_label_update(struct static_key *key, int enable);
75333 @@ -357,10 +360,12 @@ static void jump_label_invalidate_module_init(struct module *mod)
75334 struct jump_entry *iter_stop = iter_start + mod->num_jump_entries;
75335 struct jump_entry *iter;
75336
75337 + pax_open_kernel();
75338 for (iter = iter_start; iter < iter_stop; iter++) {
75339 if (within_module_init(iter->code, mod))
75340 iter->code = 0;
75341 }
75342 + pax_close_kernel();
75343 }
75344
75345 static int
75346 diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c
75347 index 2169fee..706ccca 100644
75348 --- a/kernel/kallsyms.c
75349 +++ b/kernel/kallsyms.c
75350 @@ -11,6 +11,9 @@
75351 * Changed the compression method from stem compression to "table lookup"
75352 * compression (see scripts/kallsyms.c for a more complete description)
75353 */
75354 +#ifdef CONFIG_GRKERNSEC_HIDESYM
75355 +#define __INCLUDED_BY_HIDESYM 1
75356 +#endif
75357 #include <linux/kallsyms.h>
75358 #include <linux/module.h>
75359 #include <linux/init.h>
75360 @@ -53,12 +56,33 @@ extern const unsigned long kallsyms_markers[] __attribute__((weak));
75361
75362 static inline int is_kernel_inittext(unsigned long addr)
75363 {
75364 + if (system_state != SYSTEM_BOOTING)
75365 + return 0;
75366 +
75367 if (addr >= (unsigned long)_sinittext
75368 && addr <= (unsigned long)_einittext)
75369 return 1;
75370 return 0;
75371 }
75372
75373 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
75374 +#ifdef CONFIG_MODULES
75375 +static inline int is_module_text(unsigned long addr)
75376 +{
75377 + if ((unsigned long)MODULES_EXEC_VADDR <= addr && addr <= (unsigned long)MODULES_EXEC_END)
75378 + return 1;
75379 +
75380 + addr = ktla_ktva(addr);
75381 + return (unsigned long)MODULES_EXEC_VADDR <= addr && addr <= (unsigned long)MODULES_EXEC_END;
75382 +}
75383 +#else
75384 +static inline int is_module_text(unsigned long addr)
75385 +{
75386 + return 0;
75387 +}
75388 +#endif
75389 +#endif
75390 +
75391 static inline int is_kernel_text(unsigned long addr)
75392 {
75393 if ((addr >= (unsigned long)_stext && addr <= (unsigned long)_etext) ||
75394 @@ -69,13 +93,28 @@ static inline int is_kernel_text(unsigned long addr)
75395
75396 static inline int is_kernel(unsigned long addr)
75397 {
75398 +
75399 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
75400 + if (is_kernel_text(addr) || is_kernel_inittext(addr))
75401 + return 1;
75402 +
75403 + if (ktla_ktva((unsigned long)_text) <= addr && addr < (unsigned long)_end)
75404 +#else
75405 if (addr >= (unsigned long)_stext && addr <= (unsigned long)_end)
75406 +#endif
75407 +
75408 return 1;
75409 return in_gate_area_no_mm(addr);
75410 }
75411
75412 static int is_ksym_addr(unsigned long addr)
75413 {
75414 +
75415 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
75416 + if (is_module_text(addr))
75417 + return 0;
75418 +#endif
75419 +
75420 if (all_var)
75421 return is_kernel(addr);
75422
75423 @@ -470,7 +509,6 @@ static unsigned long get_ksymbol_core(struct kallsym_iter *iter)
75424
75425 static void reset_iter(struct kallsym_iter *iter, loff_t new_pos)
75426 {
75427 - iter->name[0] = '\0';
75428 iter->nameoff = get_symbol_offset(new_pos);
75429 iter->pos = new_pos;
75430 }
75431 @@ -518,6 +556,11 @@ static int s_show(struct seq_file *m, void *p)
75432 {
75433 struct kallsym_iter *iter = m->private;
75434
75435 +#ifdef CONFIG_GRKERNSEC_HIDESYM
75436 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID))
75437 + return 0;
75438 +#endif
75439 +
75440 /* Some debugging symbols have no name. Ignore them. */
75441 if (!iter->name[0])
75442 return 0;
75443 @@ -531,6 +574,7 @@ static int s_show(struct seq_file *m, void *p)
75444 */
75445 type = iter->exported ? toupper(iter->type) :
75446 tolower(iter->type);
75447 +
75448 seq_printf(m, "%pK %c %s\t[%s]\n", (void *)iter->value,
75449 type, iter->name, iter->module_name);
75450 } else
75451 @@ -556,7 +600,7 @@ static int kallsyms_open(struct inode *inode, struct file *file)
75452 struct kallsym_iter *iter;
75453 int ret;
75454
75455 - iter = kmalloc(sizeof(*iter), GFP_KERNEL);
75456 + iter = kzalloc(sizeof(*iter), GFP_KERNEL);
75457 if (!iter)
75458 return -ENOMEM;
75459 reset_iter(iter, 0);
75460 diff --git a/kernel/kcmp.c b/kernel/kcmp.c
75461 index e30ac0f..3528cac 100644
75462 --- a/kernel/kcmp.c
75463 +++ b/kernel/kcmp.c
75464 @@ -99,6 +99,10 @@ SYSCALL_DEFINE5(kcmp, pid_t, pid1, pid_t, pid2, int, type,
75465 struct task_struct *task1, *task2;
75466 int ret;
75467
75468 +#ifdef CONFIG_GRKERNSEC
75469 + return -ENOSYS;
75470 +#endif
75471 +
75472 rcu_read_lock();
75473
75474 /*
75475 diff --git a/kernel/kexec.c b/kernel/kexec.c
75476 index ffd4e11..c3ff6bf 100644
75477 --- a/kernel/kexec.c
75478 +++ b/kernel/kexec.c
75479 @@ -1048,7 +1048,8 @@ asmlinkage long compat_sys_kexec_load(unsigned long entry,
75480 unsigned long flags)
75481 {
75482 struct compat_kexec_segment in;
75483 - struct kexec_segment out, __user *ksegments;
75484 + struct kexec_segment out;
75485 + struct kexec_segment __user *ksegments;
75486 unsigned long i, result;
75487
75488 /* Don't allow clients that don't understand the native
75489 diff --git a/kernel/kmod.c b/kernel/kmod.c
75490 index 8985c87..f539dbe 100644
75491 --- a/kernel/kmod.c
75492 +++ b/kernel/kmod.c
75493 @@ -75,7 +75,7 @@ static void free_modprobe_argv(struct subprocess_info *info)
75494 kfree(info->argv);
75495 }
75496
75497 -static int call_modprobe(char *module_name, int wait)
75498 +static int call_modprobe(char *module_name, char *module_param, int wait)
75499 {
75500 static char *envp[] = {
75501 "HOME=/",
75502 @@ -84,7 +84,7 @@ static int call_modprobe(char *module_name, int wait)
75503 NULL
75504 };
75505
75506 - char **argv = kmalloc(sizeof(char *[5]), GFP_KERNEL);
75507 + char **argv = kmalloc(sizeof(char *[6]), GFP_KERNEL);
75508 if (!argv)
75509 goto out;
75510
75511 @@ -96,7 +96,8 @@ static int call_modprobe(char *module_name, int wait)
75512 argv[1] = "-q";
75513 argv[2] = "--";
75514 argv[3] = module_name; /* check free_modprobe_argv() */
75515 - argv[4] = NULL;
75516 + argv[4] = module_param;
75517 + argv[5] = NULL;
75518
75519 return call_usermodehelper_fns(modprobe_path, argv, envp,
75520 wait | UMH_KILLABLE, NULL, free_modprobe_argv, NULL);
75521 @@ -121,9 +122,8 @@ out:
75522 * If module auto-loading support is disabled then this function
75523 * becomes a no-operation.
75524 */
75525 -int __request_module(bool wait, const char *fmt, ...)
75526 +static int ____request_module(bool wait, char *module_param, const char *fmt, va_list ap)
75527 {
75528 - va_list args;
75529 char module_name[MODULE_NAME_LEN];
75530 unsigned int max_modprobes;
75531 int ret;
75532 @@ -139,9 +139,7 @@ int __request_module(bool wait, const char *fmt, ...)
75533 */
75534 WARN_ON_ONCE(wait && current_is_async());
75535
75536 - va_start(args, fmt);
75537 - ret = vsnprintf(module_name, MODULE_NAME_LEN, fmt, args);
75538 - va_end(args);
75539 + ret = vsnprintf(module_name, MODULE_NAME_LEN, fmt, ap);
75540 if (ret >= MODULE_NAME_LEN)
75541 return -ENAMETOOLONG;
75542
75543 @@ -149,6 +147,20 @@ int __request_module(bool wait, const char *fmt, ...)
75544 if (ret)
75545 return ret;
75546
75547 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
75548 + if (uid_eq(current_uid(), GLOBAL_ROOT_UID)) {
75549 + /* hack to workaround consolekit/udisks stupidity */
75550 + read_lock(&tasklist_lock);
75551 + if (!strcmp(current->comm, "mount") &&
75552 + current->real_parent && !strncmp(current->real_parent->comm, "udisk", 5)) {
75553 + read_unlock(&tasklist_lock);
75554 + printk(KERN_ALERT "grsec: denied attempt to auto-load fs module %.64s by udisks\n", module_name);
75555 + return -EPERM;
75556 + }
75557 + read_unlock(&tasklist_lock);
75558 + }
75559 +#endif
75560 +
75561 /* If modprobe needs a service that is in a module, we get a recursive
75562 * loop. Limit the number of running kmod threads to max_threads/2 or
75563 * MAX_KMOD_CONCURRENT, whichever is the smaller. A cleaner method
75564 @@ -177,11 +189,52 @@ int __request_module(bool wait, const char *fmt, ...)
75565
75566 trace_module_request(module_name, wait, _RET_IP_);
75567
75568 - ret = call_modprobe(module_name, wait ? UMH_WAIT_PROC : UMH_WAIT_EXEC);
75569 + ret = call_modprobe(module_name, module_param, wait ? UMH_WAIT_PROC : UMH_WAIT_EXEC);
75570
75571 atomic_dec(&kmod_concurrent);
75572 return ret;
75573 }
75574 +
75575 +int ___request_module(bool wait, char *module_param, const char *fmt, ...)
75576 +{
75577 + va_list args;
75578 + int ret;
75579 +
75580 + va_start(args, fmt);
75581 + ret = ____request_module(wait, module_param, fmt, args);
75582 + va_end(args);
75583 +
75584 + return ret;
75585 +}
75586 +
75587 +int __request_module(bool wait, const char *fmt, ...)
75588 +{
75589 + va_list args;
75590 + int ret;
75591 +
75592 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
75593 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID)) {
75594 + char module_param[MODULE_NAME_LEN];
75595 +
75596 + memset(module_param, 0, sizeof(module_param));
75597 +
75598 + snprintf(module_param, sizeof(module_param) - 1, "grsec_modharden_normal%u_", GR_GLOBAL_UID(current_uid()));
75599 +
75600 + va_start(args, fmt);
75601 + ret = ____request_module(wait, module_param, fmt, args);
75602 + va_end(args);
75603 +
75604 + return ret;
75605 + }
75606 +#endif
75607 +
75608 + va_start(args, fmt);
75609 + ret = ____request_module(wait, NULL, fmt, args);
75610 + va_end(args);
75611 +
75612 + return ret;
75613 +}
75614 +
75615 EXPORT_SYMBOL(__request_module);
75616 #endif /* CONFIG_MODULES */
75617
75618 @@ -292,7 +345,7 @@ static int wait_for_helper(void *data)
75619 *
75620 * Thus the __user pointer cast is valid here.
75621 */
75622 - sys_wait4(pid, (int __user *)&ret, 0, NULL);
75623 + sys_wait4(pid, (int __force_user *)&ret, 0, NULL);
75624
75625 /*
75626 * If ret is 0, either ____call_usermodehelper failed and the
75627 @@ -649,7 +702,7 @@ EXPORT_SYMBOL(call_usermodehelper_fns);
75628 static int proc_cap_handler(struct ctl_table *table, int write,
75629 void __user *buffer, size_t *lenp, loff_t *ppos)
75630 {
75631 - struct ctl_table t;
75632 + ctl_table_no_const t;
75633 unsigned long cap_array[_KERNEL_CAPABILITY_U32S];
75634 kernel_cap_t new_cap;
75635 int err, i;
75636 diff --git a/kernel/kprobes.c b/kernel/kprobes.c
75637 index 3fed7f0..a3f95ed 100644
75638 --- a/kernel/kprobes.c
75639 +++ b/kernel/kprobes.c
75640 @@ -185,7 +185,7 @@ static kprobe_opcode_t __kprobes *__get_insn_slot(struct kprobe_insn_cache *c)
75641 * kernel image and loaded module images reside. This is required
75642 * so x86_64 can correctly handle the %rip-relative fixups.
75643 */
75644 - kip->insns = module_alloc(PAGE_SIZE);
75645 + kip->insns = module_alloc_exec(PAGE_SIZE);
75646 if (!kip->insns) {
75647 kfree(kip);
75648 return NULL;
75649 @@ -225,7 +225,7 @@ static int __kprobes collect_one_slot(struct kprobe_insn_page *kip, int idx)
75650 */
75651 if (!list_is_singular(&kip->list)) {
75652 list_del(&kip->list);
75653 - module_free(NULL, kip->insns);
75654 + module_free_exec(NULL, kip->insns);
75655 kfree(kip);
75656 }
75657 return 1;
75658 @@ -2073,7 +2073,7 @@ static int __init init_kprobes(void)
75659 {
75660 int i, err = 0;
75661 unsigned long offset = 0, size = 0;
75662 - char *modname, namebuf[128];
75663 + char *modname, namebuf[KSYM_NAME_LEN];
75664 const char *symbol_name;
75665 void *addr;
75666 struct kprobe_blackpoint *kb;
75667 @@ -2158,11 +2158,11 @@ static void __kprobes report_probe(struct seq_file *pi, struct kprobe *p,
75668 kprobe_type = "k";
75669
75670 if (sym)
75671 - seq_printf(pi, "%p %s %s+0x%x %s ",
75672 + seq_printf(pi, "%pK %s %s+0x%x %s ",
75673 p->addr, kprobe_type, sym, offset,
75674 (modname ? modname : " "));
75675 else
75676 - seq_printf(pi, "%p %s %p ",
75677 + seq_printf(pi, "%pK %s %pK ",
75678 p->addr, kprobe_type, p->addr);
75679
75680 if (!pp)
75681 @@ -2199,7 +2199,7 @@ static int __kprobes show_kprobe_addr(struct seq_file *pi, void *v)
75682 const char *sym = NULL;
75683 unsigned int i = *(loff_t *) v;
75684 unsigned long offset = 0;
75685 - char *modname, namebuf[128];
75686 + char *modname, namebuf[KSYM_NAME_LEN];
75687
75688 head = &kprobe_table[i];
75689 preempt_disable();
75690 diff --git a/kernel/ksysfs.c b/kernel/ksysfs.c
75691 index 6ada93c..dce7d5d 100644
75692 --- a/kernel/ksysfs.c
75693 +++ b/kernel/ksysfs.c
75694 @@ -46,6 +46,8 @@ static ssize_t uevent_helper_store(struct kobject *kobj,
75695 {
75696 if (count+1 > UEVENT_HELPER_PATH_LEN)
75697 return -ENOENT;
75698 + if (!capable(CAP_SYS_ADMIN))
75699 + return -EPERM;
75700 memcpy(uevent_helper, buf, count);
75701 uevent_helper[count] = '\0';
75702 if (count && uevent_helper[count-1] == '\n')
75703 @@ -172,7 +174,7 @@ static ssize_t notes_read(struct file *filp, struct kobject *kobj,
75704 return count;
75705 }
75706
75707 -static struct bin_attribute notes_attr = {
75708 +static bin_attribute_no_const notes_attr __read_only = {
75709 .attr = {
75710 .name = "notes",
75711 .mode = S_IRUGO,
75712 diff --git a/kernel/lockdep.c b/kernel/lockdep.c
75713 index 8a0efac..56f1e2d 100644
75714 --- a/kernel/lockdep.c
75715 +++ b/kernel/lockdep.c
75716 @@ -590,6 +590,10 @@ static int static_obj(void *obj)
75717 end = (unsigned long) &_end,
75718 addr = (unsigned long) obj;
75719
75720 +#ifdef CONFIG_PAX_KERNEXEC
75721 + start = ktla_ktva(start);
75722 +#endif
75723 +
75724 /*
75725 * static variable?
75726 */
75727 @@ -730,6 +734,7 @@ register_lock_class(struct lockdep_map *lock, unsigned int subclass, int force)
75728 if (!static_obj(lock->key)) {
75729 debug_locks_off();
75730 printk("INFO: trying to register non-static key.\n");
75731 + printk("lock:%pS key:%pS.\n", lock, lock->key);
75732 printk("the code is fine but needs lockdep annotation.\n");
75733 printk("turning off the locking correctness validator.\n");
75734 dump_stack();
75735 @@ -3078,7 +3083,7 @@ static int __lock_acquire(struct lockdep_map *lock, unsigned int subclass,
75736 if (!class)
75737 return 0;
75738 }
75739 - atomic_inc((atomic_t *)&class->ops);
75740 + atomic_inc_unchecked((atomic_unchecked_t *)&class->ops);
75741 if (very_verbose(class)) {
75742 printk("\nacquire class [%p] %s", class->key, class->name);
75743 if (class->name_version > 1)
75744 diff --git a/kernel/lockdep_proc.c b/kernel/lockdep_proc.c
75745 index b2c71c5..7b88d63 100644
75746 --- a/kernel/lockdep_proc.c
75747 +++ b/kernel/lockdep_proc.c
75748 @@ -65,7 +65,7 @@ static int l_show(struct seq_file *m, void *v)
75749 return 0;
75750 }
75751
75752 - seq_printf(m, "%p", class->key);
75753 + seq_printf(m, "%pK", class->key);
75754 #ifdef CONFIG_DEBUG_LOCKDEP
75755 seq_printf(m, " OPS:%8ld", class->ops);
75756 #endif
75757 @@ -83,7 +83,7 @@ static int l_show(struct seq_file *m, void *v)
75758
75759 list_for_each_entry(entry, &class->locks_after, entry) {
75760 if (entry->distance == 1) {
75761 - seq_printf(m, " -> [%p] ", entry->class->key);
75762 + seq_printf(m, " -> [%pK] ", entry->class->key);
75763 print_name(m, entry->class);
75764 seq_puts(m, "\n");
75765 }
75766 @@ -152,7 +152,7 @@ static int lc_show(struct seq_file *m, void *v)
75767 if (!class->key)
75768 continue;
75769
75770 - seq_printf(m, "[%p] ", class->key);
75771 + seq_printf(m, "[%pK] ", class->key);
75772 print_name(m, class);
75773 seq_puts(m, "\n");
75774 }
75775 @@ -495,7 +495,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
75776 if (!i)
75777 seq_line(m, '-', 40-namelen, namelen);
75778
75779 - snprintf(ip, sizeof(ip), "[<%p>]",
75780 + snprintf(ip, sizeof(ip), "[<%pK>]",
75781 (void *)class->contention_point[i]);
75782 seq_printf(m, "%40s %14lu %29s %pS\n",
75783 name, stats->contention_point[i],
75784 @@ -510,7 +510,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
75785 if (!i)
75786 seq_line(m, '-', 40-namelen, namelen);
75787
75788 - snprintf(ip, sizeof(ip), "[<%p>]",
75789 + snprintf(ip, sizeof(ip), "[<%pK>]",
75790 (void *)class->contending_point[i]);
75791 seq_printf(m, "%40s %14lu %29s %pS\n",
75792 name, stats->contending_point[i],
75793 diff --git a/kernel/module.c b/kernel/module.c
75794 index 0925c9a..6b044ac 100644
75795 --- a/kernel/module.c
75796 +++ b/kernel/module.c
75797 @@ -61,6 +61,7 @@
75798 #include <linux/pfn.h>
75799 #include <linux/bsearch.h>
75800 #include <linux/fips.h>
75801 +#include <linux/grsecurity.h>
75802 #include <uapi/linux/module.h>
75803 #include "module-internal.h"
75804
75805 @@ -156,7 +157,8 @@ static BLOCKING_NOTIFIER_HEAD(module_notify_list);
75806
75807 /* Bounds of module allocation, for speeding __module_address.
75808 * Protected by module_mutex. */
75809 -static unsigned long module_addr_min = -1UL, module_addr_max = 0;
75810 +static unsigned long module_addr_min_rw = -1UL, module_addr_max_rw = 0;
75811 +static unsigned long module_addr_min_rx = -1UL, module_addr_max_rx = 0;
75812
75813 int register_module_notifier(struct notifier_block * nb)
75814 {
75815 @@ -323,7 +325,7 @@ bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
75816 return true;
75817
75818 list_for_each_entry_rcu(mod, &modules, list) {
75819 - struct symsearch arr[] = {
75820 + struct symsearch modarr[] = {
75821 { mod->syms, mod->syms + mod->num_syms, mod->crcs,
75822 NOT_GPL_ONLY, false },
75823 { mod->gpl_syms, mod->gpl_syms + mod->num_gpl_syms,
75824 @@ -348,7 +350,7 @@ bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
75825 if (mod->state == MODULE_STATE_UNFORMED)
75826 continue;
75827
75828 - if (each_symbol_in_section(arr, ARRAY_SIZE(arr), mod, fn, data))
75829 + if (each_symbol_in_section(modarr, ARRAY_SIZE(modarr), mod, fn, data))
75830 return true;
75831 }
75832 return false;
75833 @@ -485,7 +487,7 @@ static inline void __percpu *mod_percpu(struct module *mod)
75834 static int percpu_modalloc(struct module *mod,
75835 unsigned long size, unsigned long align)
75836 {
75837 - if (align > PAGE_SIZE) {
75838 + if (align-1 >= PAGE_SIZE) {
75839 printk(KERN_WARNING "%s: per-cpu alignment %li > %li\n",
75840 mod->name, align, PAGE_SIZE);
75841 align = PAGE_SIZE;
75842 @@ -1089,7 +1091,7 @@ struct module_attribute module_uevent =
75843 static ssize_t show_coresize(struct module_attribute *mattr,
75844 struct module_kobject *mk, char *buffer)
75845 {
75846 - return sprintf(buffer, "%u\n", mk->mod->core_size);
75847 + return sprintf(buffer, "%u\n", mk->mod->core_size_rx + mk->mod->core_size_rw);
75848 }
75849
75850 static struct module_attribute modinfo_coresize =
75851 @@ -1098,7 +1100,7 @@ static struct module_attribute modinfo_coresize =
75852 static ssize_t show_initsize(struct module_attribute *mattr,
75853 struct module_kobject *mk, char *buffer)
75854 {
75855 - return sprintf(buffer, "%u\n", mk->mod->init_size);
75856 + return sprintf(buffer, "%u\n", mk->mod->init_size_rx + mk->mod->init_size_rw);
75857 }
75858
75859 static struct module_attribute modinfo_initsize =
75860 @@ -1312,7 +1314,7 @@ resolve_symbol_wait(struct module *mod,
75861 */
75862 #ifdef CONFIG_SYSFS
75863
75864 -#ifdef CONFIG_KALLSYMS
75865 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
75866 static inline bool sect_empty(const Elf_Shdr *sect)
75867 {
75868 return !(sect->sh_flags & SHF_ALLOC) || sect->sh_size == 0;
75869 @@ -1452,7 +1454,7 @@ static void add_notes_attrs(struct module *mod, const struct load_info *info)
75870 {
75871 unsigned int notes, loaded, i;
75872 struct module_notes_attrs *notes_attrs;
75873 - struct bin_attribute *nattr;
75874 + bin_attribute_no_const *nattr;
75875
75876 /* failed to create section attributes, so can't create notes */
75877 if (!mod->sect_attrs)
75878 @@ -1564,7 +1566,7 @@ static void del_usage_links(struct module *mod)
75879 static int module_add_modinfo_attrs(struct module *mod)
75880 {
75881 struct module_attribute *attr;
75882 - struct module_attribute *temp_attr;
75883 + module_attribute_no_const *temp_attr;
75884 int error = 0;
75885 int i;
75886
75887 @@ -1778,21 +1780,21 @@ static void set_section_ro_nx(void *base,
75888
75889 static void unset_module_core_ro_nx(struct module *mod)
75890 {
75891 - set_page_attributes(mod->module_core + mod->core_text_size,
75892 - mod->module_core + mod->core_size,
75893 + set_page_attributes(mod->module_core_rw,
75894 + mod->module_core_rw + mod->core_size_rw,
75895 set_memory_x);
75896 - set_page_attributes(mod->module_core,
75897 - mod->module_core + mod->core_ro_size,
75898 + set_page_attributes(mod->module_core_rx,
75899 + mod->module_core_rx + mod->core_size_rx,
75900 set_memory_rw);
75901 }
75902
75903 static void unset_module_init_ro_nx(struct module *mod)
75904 {
75905 - set_page_attributes(mod->module_init + mod->init_text_size,
75906 - mod->module_init + mod->init_size,
75907 + set_page_attributes(mod->module_init_rw,
75908 + mod->module_init_rw + mod->init_size_rw,
75909 set_memory_x);
75910 - set_page_attributes(mod->module_init,
75911 - mod->module_init + mod->init_ro_size,
75912 + set_page_attributes(mod->module_init_rx,
75913 + mod->module_init_rx + mod->init_size_rx,
75914 set_memory_rw);
75915 }
75916
75917 @@ -1805,14 +1807,14 @@ void set_all_modules_text_rw(void)
75918 list_for_each_entry_rcu(mod, &modules, list) {
75919 if (mod->state == MODULE_STATE_UNFORMED)
75920 continue;
75921 - if ((mod->module_core) && (mod->core_text_size)) {
75922 - set_page_attributes(mod->module_core,
75923 - mod->module_core + mod->core_text_size,
75924 + if ((mod->module_core_rx) && (mod->core_size_rx)) {
75925 + set_page_attributes(mod->module_core_rx,
75926 + mod->module_core_rx + mod->core_size_rx,
75927 set_memory_rw);
75928 }
75929 - if ((mod->module_init) && (mod->init_text_size)) {
75930 - set_page_attributes(mod->module_init,
75931 - mod->module_init + mod->init_text_size,
75932 + if ((mod->module_init_rx) && (mod->init_size_rx)) {
75933 + set_page_attributes(mod->module_init_rx,
75934 + mod->module_init_rx + mod->init_size_rx,
75935 set_memory_rw);
75936 }
75937 }
75938 @@ -1828,14 +1830,14 @@ void set_all_modules_text_ro(void)
75939 list_for_each_entry_rcu(mod, &modules, list) {
75940 if (mod->state == MODULE_STATE_UNFORMED)
75941 continue;
75942 - if ((mod->module_core) && (mod->core_text_size)) {
75943 - set_page_attributes(mod->module_core,
75944 - mod->module_core + mod->core_text_size,
75945 + if ((mod->module_core_rx) && (mod->core_size_rx)) {
75946 + set_page_attributes(mod->module_core_rx,
75947 + mod->module_core_rx + mod->core_size_rx,
75948 set_memory_ro);
75949 }
75950 - if ((mod->module_init) && (mod->init_text_size)) {
75951 - set_page_attributes(mod->module_init,
75952 - mod->module_init + mod->init_text_size,
75953 + if ((mod->module_init_rx) && (mod->init_size_rx)) {
75954 + set_page_attributes(mod->module_init_rx,
75955 + mod->module_init_rx + mod->init_size_rx,
75956 set_memory_ro);
75957 }
75958 }
75959 @@ -1881,16 +1883,19 @@ static void free_module(struct module *mod)
75960
75961 /* This may be NULL, but that's OK */
75962 unset_module_init_ro_nx(mod);
75963 - module_free(mod, mod->module_init);
75964 + module_free(mod, mod->module_init_rw);
75965 + module_free_exec(mod, mod->module_init_rx);
75966 kfree(mod->args);
75967 percpu_modfree(mod);
75968
75969 /* Free lock-classes: */
75970 - lockdep_free_key_range(mod->module_core, mod->core_size);
75971 + lockdep_free_key_range(mod->module_core_rx, mod->core_size_rx);
75972 + lockdep_free_key_range(mod->module_core_rw, mod->core_size_rw);
75973
75974 /* Finally, free the core (containing the module structure) */
75975 unset_module_core_ro_nx(mod);
75976 - module_free(mod, mod->module_core);
75977 + module_free_exec(mod, mod->module_core_rx);
75978 + module_free(mod, mod->module_core_rw);
75979
75980 #ifdef CONFIG_MPU
75981 update_protections(current->mm);
75982 @@ -1960,9 +1965,31 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
75983 int ret = 0;
75984 const struct kernel_symbol *ksym;
75985
75986 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
75987 + int is_fs_load = 0;
75988 + int register_filesystem_found = 0;
75989 + char *p;
75990 +
75991 + p = strstr(mod->args, "grsec_modharden_fs");
75992 + if (p) {
75993 + char *endptr = p + sizeof("grsec_modharden_fs") - 1;
75994 + /* copy \0 as well */
75995 + memmove(p, endptr, strlen(mod->args) - (unsigned int)(endptr - mod->args) + 1);
75996 + is_fs_load = 1;
75997 + }
75998 +#endif
75999 +
76000 for (i = 1; i < symsec->sh_size / sizeof(Elf_Sym); i++) {
76001 const char *name = info->strtab + sym[i].st_name;
76002
76003 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
76004 + /* it's a real shame this will never get ripped and copied
76005 + upstream! ;(
76006 + */
76007 + if (is_fs_load && !strcmp(name, "register_filesystem"))
76008 + register_filesystem_found = 1;
76009 +#endif
76010 +
76011 switch (sym[i].st_shndx) {
76012 case SHN_COMMON:
76013 /* We compiled with -fno-common. These are not
76014 @@ -1983,7 +2010,9 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
76015 ksym = resolve_symbol_wait(mod, info, name);
76016 /* Ok if resolved. */
76017 if (ksym && !IS_ERR(ksym)) {
76018 + pax_open_kernel();
76019 sym[i].st_value = ksym->value;
76020 + pax_close_kernel();
76021 break;
76022 }
76023
76024 @@ -2002,11 +2031,20 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
76025 secbase = (unsigned long)mod_percpu(mod);
76026 else
76027 secbase = info->sechdrs[sym[i].st_shndx].sh_addr;
76028 + pax_open_kernel();
76029 sym[i].st_value += secbase;
76030 + pax_close_kernel();
76031 break;
76032 }
76033 }
76034
76035 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
76036 + if (is_fs_load && !register_filesystem_found) {
76037 + printk(KERN_ALERT "grsec: Denied attempt to load non-fs module %.64s through mount\n", mod->name);
76038 + ret = -EPERM;
76039 + }
76040 +#endif
76041 +
76042 return ret;
76043 }
76044
76045 @@ -2090,22 +2128,12 @@ static void layout_sections(struct module *mod, struct load_info *info)
76046 || s->sh_entsize != ~0UL
76047 || strstarts(sname, ".init"))
76048 continue;
76049 - s->sh_entsize = get_offset(mod, &mod->core_size, s, i);
76050 + if ((s->sh_flags & SHF_WRITE) || !(s->sh_flags & SHF_ALLOC))
76051 + s->sh_entsize = get_offset(mod, &mod->core_size_rw, s, i);
76052 + else
76053 + s->sh_entsize = get_offset(mod, &mod->core_size_rx, s, i);
76054 pr_debug("\t%s\n", sname);
76055 }
76056 - switch (m) {
76057 - case 0: /* executable */
76058 - mod->core_size = debug_align(mod->core_size);
76059 - mod->core_text_size = mod->core_size;
76060 - break;
76061 - case 1: /* RO: text and ro-data */
76062 - mod->core_size = debug_align(mod->core_size);
76063 - mod->core_ro_size = mod->core_size;
76064 - break;
76065 - case 3: /* whole core */
76066 - mod->core_size = debug_align(mod->core_size);
76067 - break;
76068 - }
76069 }
76070
76071 pr_debug("Init section allocation order:\n");
76072 @@ -2119,23 +2147,13 @@ static void layout_sections(struct module *mod, struct load_info *info)
76073 || s->sh_entsize != ~0UL
76074 || !strstarts(sname, ".init"))
76075 continue;
76076 - s->sh_entsize = (get_offset(mod, &mod->init_size, s, i)
76077 - | INIT_OFFSET_MASK);
76078 + if ((s->sh_flags & SHF_WRITE) || !(s->sh_flags & SHF_ALLOC))
76079 + s->sh_entsize = get_offset(mod, &mod->init_size_rw, s, i);
76080 + else
76081 + s->sh_entsize = get_offset(mod, &mod->init_size_rx, s, i);
76082 + s->sh_entsize |= INIT_OFFSET_MASK;
76083 pr_debug("\t%s\n", sname);
76084 }
76085 - switch (m) {
76086 - case 0: /* executable */
76087 - mod->init_size = debug_align(mod->init_size);
76088 - mod->init_text_size = mod->init_size;
76089 - break;
76090 - case 1: /* RO: text and ro-data */
76091 - mod->init_size = debug_align(mod->init_size);
76092 - mod->init_ro_size = mod->init_size;
76093 - break;
76094 - case 3: /* whole init */
76095 - mod->init_size = debug_align(mod->init_size);
76096 - break;
76097 - }
76098 }
76099 }
76100
76101 @@ -2308,7 +2326,7 @@ static void layout_symtab(struct module *mod, struct load_info *info)
76102
76103 /* Put symbol section at end of init part of module. */
76104 symsect->sh_flags |= SHF_ALLOC;
76105 - symsect->sh_entsize = get_offset(mod, &mod->init_size, symsect,
76106 + symsect->sh_entsize = get_offset(mod, &mod->init_size_rx, symsect,
76107 info->index.sym) | INIT_OFFSET_MASK;
76108 pr_debug("\t%s\n", info->secstrings + symsect->sh_name);
76109
76110 @@ -2325,13 +2343,13 @@ static void layout_symtab(struct module *mod, struct load_info *info)
76111 }
76112
76113 /* Append room for core symbols at end of core part. */
76114 - info->symoffs = ALIGN(mod->core_size, symsect->sh_addralign ?: 1);
76115 - info->stroffs = mod->core_size = info->symoffs + ndst * sizeof(Elf_Sym);
76116 - mod->core_size += strtab_size;
76117 + info->symoffs = ALIGN(mod->core_size_rx, symsect->sh_addralign ?: 1);
76118 + info->stroffs = mod->core_size_rx = info->symoffs + ndst * sizeof(Elf_Sym);
76119 + mod->core_size_rx += strtab_size;
76120
76121 /* Put string table section at end of init part of module. */
76122 strsect->sh_flags |= SHF_ALLOC;
76123 - strsect->sh_entsize = get_offset(mod, &mod->init_size, strsect,
76124 + strsect->sh_entsize = get_offset(mod, &mod->init_size_rx, strsect,
76125 info->index.str) | INIT_OFFSET_MASK;
76126 pr_debug("\t%s\n", info->secstrings + strsect->sh_name);
76127 }
76128 @@ -2349,12 +2367,14 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
76129 /* Make sure we get permanent strtab: don't use info->strtab. */
76130 mod->strtab = (void *)info->sechdrs[info->index.str].sh_addr;
76131
76132 + pax_open_kernel();
76133 +
76134 /* Set types up while we still have access to sections. */
76135 for (i = 0; i < mod->num_symtab; i++)
76136 mod->symtab[i].st_info = elf_type(&mod->symtab[i], info);
76137
76138 - mod->core_symtab = dst = mod->module_core + info->symoffs;
76139 - mod->core_strtab = s = mod->module_core + info->stroffs;
76140 + mod->core_symtab = dst = mod->module_core_rx + info->symoffs;
76141 + mod->core_strtab = s = mod->module_core_rx + info->stroffs;
76142 src = mod->symtab;
76143 for (ndst = i = 0; i < mod->num_symtab; i++) {
76144 if (i == 0 ||
76145 @@ -2366,6 +2386,8 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
76146 }
76147 }
76148 mod->core_num_syms = ndst;
76149 +
76150 + pax_close_kernel();
76151 }
76152 #else
76153 static inline void layout_symtab(struct module *mod, struct load_info *info)
76154 @@ -2399,17 +2421,33 @@ void * __weak module_alloc(unsigned long size)
76155 return vmalloc_exec(size);
76156 }
76157
76158 -static void *module_alloc_update_bounds(unsigned long size)
76159 +static void *module_alloc_update_bounds_rw(unsigned long size)
76160 {
76161 void *ret = module_alloc(size);
76162
76163 if (ret) {
76164 mutex_lock(&module_mutex);
76165 /* Update module bounds. */
76166 - if ((unsigned long)ret < module_addr_min)
76167 - module_addr_min = (unsigned long)ret;
76168 - if ((unsigned long)ret + size > module_addr_max)
76169 - module_addr_max = (unsigned long)ret + size;
76170 + if ((unsigned long)ret < module_addr_min_rw)
76171 + module_addr_min_rw = (unsigned long)ret;
76172 + if ((unsigned long)ret + size > module_addr_max_rw)
76173 + module_addr_max_rw = (unsigned long)ret + size;
76174 + mutex_unlock(&module_mutex);
76175 + }
76176 + return ret;
76177 +}
76178 +
76179 +static void *module_alloc_update_bounds_rx(unsigned long size)
76180 +{
76181 + void *ret = module_alloc_exec(size);
76182 +
76183 + if (ret) {
76184 + mutex_lock(&module_mutex);
76185 + /* Update module bounds. */
76186 + if ((unsigned long)ret < module_addr_min_rx)
76187 + module_addr_min_rx = (unsigned long)ret;
76188 + if ((unsigned long)ret + size > module_addr_max_rx)
76189 + module_addr_max_rx = (unsigned long)ret + size;
76190 mutex_unlock(&module_mutex);
76191 }
76192 return ret;
76193 @@ -2685,8 +2723,14 @@ static struct module *setup_load_info(struct load_info *info, int flags)
76194 static int check_modinfo(struct module *mod, struct load_info *info, int flags)
76195 {
76196 const char *modmagic = get_modinfo(info, "vermagic");
76197 + const char *license = get_modinfo(info, "license");
76198 int err;
76199
76200 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
76201 + if (!license || !license_is_gpl_compatible(license))
76202 + return -ENOEXEC;
76203 +#endif
76204 +
76205 if (flags & MODULE_INIT_IGNORE_VERMAGIC)
76206 modmagic = NULL;
76207
76208 @@ -2712,7 +2756,7 @@ static int check_modinfo(struct module *mod, struct load_info *info, int flags)
76209 }
76210
76211 /* Set up license info based on the info section */
76212 - set_license(mod, get_modinfo(info, "license"));
76213 + set_license(mod, license);
76214
76215 return 0;
76216 }
76217 @@ -2806,7 +2850,7 @@ static int move_module(struct module *mod, struct load_info *info)
76218 void *ptr;
76219
76220 /* Do the allocs. */
76221 - ptr = module_alloc_update_bounds(mod->core_size);
76222 + ptr = module_alloc_update_bounds_rw(mod->core_size_rw);
76223 /*
76224 * The pointer to this block is stored in the module structure
76225 * which is inside the block. Just mark it as not being a
76226 @@ -2816,11 +2860,11 @@ static int move_module(struct module *mod, struct load_info *info)
76227 if (!ptr)
76228 return -ENOMEM;
76229
76230 - memset(ptr, 0, mod->core_size);
76231 - mod->module_core = ptr;
76232 + memset(ptr, 0, mod->core_size_rw);
76233 + mod->module_core_rw = ptr;
76234
76235 - if (mod->init_size) {
76236 - ptr = module_alloc_update_bounds(mod->init_size);
76237 + if (mod->init_size_rw) {
76238 + ptr = module_alloc_update_bounds_rw(mod->init_size_rw);
76239 /*
76240 * The pointer to this block is stored in the module structure
76241 * which is inside the block. This block doesn't need to be
76242 @@ -2829,13 +2873,45 @@ static int move_module(struct module *mod, struct load_info *info)
76243 */
76244 kmemleak_ignore(ptr);
76245 if (!ptr) {
76246 - module_free(mod, mod->module_core);
76247 + module_free(mod, mod->module_core_rw);
76248 return -ENOMEM;
76249 }
76250 - memset(ptr, 0, mod->init_size);
76251 - mod->module_init = ptr;
76252 + memset(ptr, 0, mod->init_size_rw);
76253 + mod->module_init_rw = ptr;
76254 } else
76255 - mod->module_init = NULL;
76256 + mod->module_init_rw = NULL;
76257 +
76258 + ptr = module_alloc_update_bounds_rx(mod->core_size_rx);
76259 + kmemleak_not_leak(ptr);
76260 + if (!ptr) {
76261 + if (mod->module_init_rw)
76262 + module_free(mod, mod->module_init_rw);
76263 + module_free(mod, mod->module_core_rw);
76264 + return -ENOMEM;
76265 + }
76266 +
76267 + pax_open_kernel();
76268 + memset(ptr, 0, mod->core_size_rx);
76269 + pax_close_kernel();
76270 + mod->module_core_rx = ptr;
76271 +
76272 + if (mod->init_size_rx) {
76273 + ptr = module_alloc_update_bounds_rx(mod->init_size_rx);
76274 + kmemleak_ignore(ptr);
76275 + if (!ptr && mod->init_size_rx) {
76276 + module_free_exec(mod, mod->module_core_rx);
76277 + if (mod->module_init_rw)
76278 + module_free(mod, mod->module_init_rw);
76279 + module_free(mod, mod->module_core_rw);
76280 + return -ENOMEM;
76281 + }
76282 +
76283 + pax_open_kernel();
76284 + memset(ptr, 0, mod->init_size_rx);
76285 + pax_close_kernel();
76286 + mod->module_init_rx = ptr;
76287 + } else
76288 + mod->module_init_rx = NULL;
76289
76290 /* Transfer each section which specifies SHF_ALLOC */
76291 pr_debug("final section addresses:\n");
76292 @@ -2846,16 +2922,45 @@ static int move_module(struct module *mod, struct load_info *info)
76293 if (!(shdr->sh_flags & SHF_ALLOC))
76294 continue;
76295
76296 - if (shdr->sh_entsize & INIT_OFFSET_MASK)
76297 - dest = mod->module_init
76298 - + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
76299 - else
76300 - dest = mod->module_core + shdr->sh_entsize;
76301 + if (shdr->sh_entsize & INIT_OFFSET_MASK) {
76302 + if ((shdr->sh_flags & SHF_WRITE) || !(shdr->sh_flags & SHF_ALLOC))
76303 + dest = mod->module_init_rw
76304 + + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
76305 + else
76306 + dest = mod->module_init_rx
76307 + + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
76308 + } else {
76309 + if ((shdr->sh_flags & SHF_WRITE) || !(shdr->sh_flags & SHF_ALLOC))
76310 + dest = mod->module_core_rw + shdr->sh_entsize;
76311 + else
76312 + dest = mod->module_core_rx + shdr->sh_entsize;
76313 + }
76314 +
76315 + if (shdr->sh_type != SHT_NOBITS) {
76316 +
76317 +#ifdef CONFIG_PAX_KERNEXEC
76318 +#ifdef CONFIG_X86_64
76319 + if ((shdr->sh_flags & SHF_WRITE) && (shdr->sh_flags & SHF_EXECINSTR))
76320 + set_memory_x((unsigned long)dest, (shdr->sh_size + PAGE_SIZE) >> PAGE_SHIFT);
76321 +#endif
76322 + if (!(shdr->sh_flags & SHF_WRITE) && (shdr->sh_flags & SHF_ALLOC)) {
76323 + pax_open_kernel();
76324 + memcpy(dest, (void *)shdr->sh_addr, shdr->sh_size);
76325 + pax_close_kernel();
76326 + } else
76327 +#endif
76328
76329 - if (shdr->sh_type != SHT_NOBITS)
76330 memcpy(dest, (void *)shdr->sh_addr, shdr->sh_size);
76331 + }
76332 /* Update sh_addr to point to copy in image. */
76333 - shdr->sh_addr = (unsigned long)dest;
76334 +
76335 +#ifdef CONFIG_PAX_KERNEXEC
76336 + if (shdr->sh_flags & SHF_EXECINSTR)
76337 + shdr->sh_addr = ktva_ktla((unsigned long)dest);
76338 + else
76339 +#endif
76340 +
76341 + shdr->sh_addr = (unsigned long)dest;
76342 pr_debug("\t0x%lx %s\n",
76343 (long)shdr->sh_addr, info->secstrings + shdr->sh_name);
76344 }
76345 @@ -2912,12 +3017,12 @@ static void flush_module_icache(const struct module *mod)
76346 * Do it before processing of module parameters, so the module
76347 * can provide parameter accessor functions of its own.
76348 */
76349 - if (mod->module_init)
76350 - flush_icache_range((unsigned long)mod->module_init,
76351 - (unsigned long)mod->module_init
76352 - + mod->init_size);
76353 - flush_icache_range((unsigned long)mod->module_core,
76354 - (unsigned long)mod->module_core + mod->core_size);
76355 + if (mod->module_init_rx)
76356 + flush_icache_range((unsigned long)mod->module_init_rx,
76357 + (unsigned long)mod->module_init_rx
76358 + + mod->init_size_rx);
76359 + flush_icache_range((unsigned long)mod->module_core_rx,
76360 + (unsigned long)mod->module_core_rx + mod->core_size_rx);
76361
76362 set_fs(old_fs);
76363 }
76364 @@ -2987,8 +3092,10 @@ out:
76365 static void module_deallocate(struct module *mod, struct load_info *info)
76366 {
76367 percpu_modfree(mod);
76368 - module_free(mod, mod->module_init);
76369 - module_free(mod, mod->module_core);
76370 + module_free_exec(mod, mod->module_init_rx);
76371 + module_free_exec(mod, mod->module_core_rx);
76372 + module_free(mod, mod->module_init_rw);
76373 + module_free(mod, mod->module_core_rw);
76374 }
76375
76376 int __weak module_finalize(const Elf_Ehdr *hdr,
76377 @@ -3001,7 +3108,9 @@ int __weak module_finalize(const Elf_Ehdr *hdr,
76378 static int post_relocation(struct module *mod, const struct load_info *info)
76379 {
76380 /* Sort exception table now relocations are done. */
76381 + pax_open_kernel();
76382 sort_extable(mod->extable, mod->extable + mod->num_exentries);
76383 + pax_close_kernel();
76384
76385 /* Copy relocated percpu area over. */
76386 percpu_modcopy(mod, (void *)info->sechdrs[info->index.pcpu].sh_addr,
76387 @@ -3055,16 +3164,16 @@ static int do_init_module(struct module *mod)
76388 MODULE_STATE_COMING, mod);
76389
76390 /* Set RO and NX regions for core */
76391 - set_section_ro_nx(mod->module_core,
76392 - mod->core_text_size,
76393 - mod->core_ro_size,
76394 - mod->core_size);
76395 + set_section_ro_nx(mod->module_core_rx,
76396 + mod->core_size_rx,
76397 + mod->core_size_rx,
76398 + mod->core_size_rx);
76399
76400 /* Set RO and NX regions for init */
76401 - set_section_ro_nx(mod->module_init,
76402 - mod->init_text_size,
76403 - mod->init_ro_size,
76404 - mod->init_size);
76405 + set_section_ro_nx(mod->module_init_rx,
76406 + mod->init_size_rx,
76407 + mod->init_size_rx,
76408 + mod->init_size_rx);
76409
76410 do_mod_ctors(mod);
76411 /* Start the module */
76412 @@ -3126,11 +3235,12 @@ static int do_init_module(struct module *mod)
76413 mod->strtab = mod->core_strtab;
76414 #endif
76415 unset_module_init_ro_nx(mod);
76416 - module_free(mod, mod->module_init);
76417 - mod->module_init = NULL;
76418 - mod->init_size = 0;
76419 - mod->init_ro_size = 0;
76420 - mod->init_text_size = 0;
76421 + module_free(mod, mod->module_init_rw);
76422 + module_free_exec(mod, mod->module_init_rx);
76423 + mod->module_init_rw = NULL;
76424 + mod->module_init_rx = NULL;
76425 + mod->init_size_rw = 0;
76426 + mod->init_size_rx = 0;
76427 mutex_unlock(&module_mutex);
76428 wake_up_all(&module_wq);
76429
76430 @@ -3257,9 +3367,38 @@ static int load_module(struct load_info *info, const char __user *uargs,
76431 if (err)
76432 goto free_unload;
76433
76434 + /* Now copy in args */
76435 + mod->args = strndup_user(uargs, ~0UL >> 1);
76436 + if (IS_ERR(mod->args)) {
76437 + err = PTR_ERR(mod->args);
76438 + goto free_unload;
76439 + }
76440 +
76441 /* Set up MODINFO_ATTR fields */
76442 setup_modinfo(mod, info);
76443
76444 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
76445 + {
76446 + char *p, *p2;
76447 +
76448 + if (strstr(mod->args, "grsec_modharden_netdev")) {
76449 + 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);
76450 + err = -EPERM;
76451 + goto free_modinfo;
76452 + } else if ((p = strstr(mod->args, "grsec_modharden_normal"))) {
76453 + p += sizeof("grsec_modharden_normal") - 1;
76454 + p2 = strstr(p, "_");
76455 + if (p2) {
76456 + *p2 = '\0';
76457 + printk(KERN_ALERT "grsec: denied kernel module auto-load of %.64s by uid %.9s\n", mod->name, p);
76458 + *p2 = '_';
76459 + }
76460 + err = -EPERM;
76461 + goto free_modinfo;
76462 + }
76463 + }
76464 +#endif
76465 +
76466 /* Fix up syms, so that st_value is a pointer to location. */
76467 err = simplify_symbols(mod, info);
76468 if (err < 0)
76469 @@ -3275,13 +3414,6 @@ static int load_module(struct load_info *info, const char __user *uargs,
76470
76471 flush_module_icache(mod);
76472
76473 - /* Now copy in args */
76474 - mod->args = strndup_user(uargs, ~0UL >> 1);
76475 - if (IS_ERR(mod->args)) {
76476 - err = PTR_ERR(mod->args);
76477 - goto free_arch_cleanup;
76478 - }
76479 -
76480 dynamic_debug_setup(info->debug, info->num_debug);
76481
76482 /* Finally it's fully formed, ready to start executing. */
76483 @@ -3316,11 +3448,10 @@ static int load_module(struct load_info *info, const char __user *uargs,
76484 ddebug_cleanup:
76485 dynamic_debug_remove(info->debug);
76486 synchronize_sched();
76487 - kfree(mod->args);
76488 - free_arch_cleanup:
76489 module_arch_cleanup(mod);
76490 free_modinfo:
76491 free_modinfo(mod);
76492 + kfree(mod->args);
76493 free_unload:
76494 module_unload_free(mod);
76495 unlink_mod:
76496 @@ -3403,10 +3534,16 @@ static const char *get_ksymbol(struct module *mod,
76497 unsigned long nextval;
76498
76499 /* At worse, next value is at end of module */
76500 - if (within_module_init(addr, mod))
76501 - nextval = (unsigned long)mod->module_init+mod->init_text_size;
76502 + if (within_module_init_rx(addr, mod))
76503 + nextval = (unsigned long)mod->module_init_rx+mod->init_size_rx;
76504 + else if (within_module_init_rw(addr, mod))
76505 + nextval = (unsigned long)mod->module_init_rw+mod->init_size_rw;
76506 + else if (within_module_core_rx(addr, mod))
76507 + nextval = (unsigned long)mod->module_core_rx+mod->core_size_rx;
76508 + else if (within_module_core_rw(addr, mod))
76509 + nextval = (unsigned long)mod->module_core_rw+mod->core_size_rw;
76510 else
76511 - nextval = (unsigned long)mod->module_core+mod->core_text_size;
76512 + return NULL;
76513
76514 /* Scan for closest preceding symbol, and next symbol. (ELF
76515 starts real symbols at 1). */
76516 @@ -3659,7 +3796,7 @@ static int m_show(struct seq_file *m, void *p)
76517 return 0;
76518
76519 seq_printf(m, "%s %u",
76520 - mod->name, mod->init_size + mod->core_size);
76521 + mod->name, mod->init_size_rx + mod->init_size_rw + mod->core_size_rx + mod->core_size_rw);
76522 print_unload_info(m, mod);
76523
76524 /* Informative for users. */
76525 @@ -3668,7 +3805,7 @@ static int m_show(struct seq_file *m, void *p)
76526 mod->state == MODULE_STATE_COMING ? "Loading":
76527 "Live");
76528 /* Used by oprofile and other similar tools. */
76529 - seq_printf(m, " 0x%pK", mod->module_core);
76530 + seq_printf(m, " 0x%pK 0x%pK", mod->module_core_rx, mod->module_core_rw);
76531
76532 /* Taints info */
76533 if (mod->taints)
76534 @@ -3704,7 +3841,17 @@ static const struct file_operations proc_modules_operations = {
76535
76536 static int __init proc_modules_init(void)
76537 {
76538 +#ifndef CONFIG_GRKERNSEC_HIDESYM
76539 +#ifdef CONFIG_GRKERNSEC_PROC_USER
76540 + proc_create("modules", S_IRUSR, NULL, &proc_modules_operations);
76541 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
76542 + proc_create("modules", S_IRUSR | S_IRGRP, NULL, &proc_modules_operations);
76543 +#else
76544 proc_create("modules", 0, NULL, &proc_modules_operations);
76545 +#endif
76546 +#else
76547 + proc_create("modules", S_IRUSR, NULL, &proc_modules_operations);
76548 +#endif
76549 return 0;
76550 }
76551 module_init(proc_modules_init);
76552 @@ -3765,14 +3912,14 @@ struct module *__module_address(unsigned long addr)
76553 {
76554 struct module *mod;
76555
76556 - if (addr < module_addr_min || addr > module_addr_max)
76557 + if ((addr < module_addr_min_rx || addr > module_addr_max_rx) &&
76558 + (addr < module_addr_min_rw || addr > module_addr_max_rw))
76559 return NULL;
76560
76561 list_for_each_entry_rcu(mod, &modules, list) {
76562 if (mod->state == MODULE_STATE_UNFORMED)
76563 continue;
76564 - if (within_module_core(addr, mod)
76565 - || within_module_init(addr, mod))
76566 + if (within_module_init(addr, mod) || within_module_core(addr, mod))
76567 return mod;
76568 }
76569 return NULL;
76570 @@ -3807,11 +3954,20 @@ bool is_module_text_address(unsigned long addr)
76571 */
76572 struct module *__module_text_address(unsigned long addr)
76573 {
76574 - struct module *mod = __module_address(addr);
76575 + struct module *mod;
76576 +
76577 +#ifdef CONFIG_X86_32
76578 + addr = ktla_ktva(addr);
76579 +#endif
76580 +
76581 + if (addr < module_addr_min_rx || addr > module_addr_max_rx)
76582 + return NULL;
76583 +
76584 + mod = __module_address(addr);
76585 +
76586 if (mod) {
76587 /* Make sure it's within the text section. */
76588 - if (!within(addr, mod->module_init, mod->init_text_size)
76589 - && !within(addr, mod->module_core, mod->core_text_size))
76590 + if (!within_module_init_rx(addr, mod) && !within_module_core_rx(addr, mod))
76591 mod = NULL;
76592 }
76593 return mod;
76594 diff --git a/kernel/mutex-debug.c b/kernel/mutex-debug.c
76595 index 7e3443f..b2a1e6b 100644
76596 --- a/kernel/mutex-debug.c
76597 +++ b/kernel/mutex-debug.c
76598 @@ -49,21 +49,21 @@ void debug_mutex_free_waiter(struct mutex_waiter *waiter)
76599 }
76600
76601 void debug_mutex_add_waiter(struct mutex *lock, struct mutex_waiter *waiter,
76602 - struct thread_info *ti)
76603 + struct task_struct *task)
76604 {
76605 SMP_DEBUG_LOCKS_WARN_ON(!spin_is_locked(&lock->wait_lock));
76606
76607 /* Mark the current thread as blocked on the lock: */
76608 - ti->task->blocked_on = waiter;
76609 + task->blocked_on = waiter;
76610 }
76611
76612 void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
76613 - struct thread_info *ti)
76614 + struct task_struct *task)
76615 {
76616 DEBUG_LOCKS_WARN_ON(list_empty(&waiter->list));
76617 - DEBUG_LOCKS_WARN_ON(waiter->task != ti->task);
76618 - DEBUG_LOCKS_WARN_ON(ti->task->blocked_on != waiter);
76619 - ti->task->blocked_on = NULL;
76620 + DEBUG_LOCKS_WARN_ON(waiter->task != task);
76621 + DEBUG_LOCKS_WARN_ON(task->blocked_on != waiter);
76622 + task->blocked_on = NULL;
76623
76624 list_del_init(&waiter->list);
76625 waiter->task = NULL;
76626 diff --git a/kernel/mutex-debug.h b/kernel/mutex-debug.h
76627 index 0799fd3..d06ae3b 100644
76628 --- a/kernel/mutex-debug.h
76629 +++ b/kernel/mutex-debug.h
76630 @@ -20,9 +20,9 @@ extern void debug_mutex_wake_waiter(struct mutex *lock,
76631 extern void debug_mutex_free_waiter(struct mutex_waiter *waiter);
76632 extern void debug_mutex_add_waiter(struct mutex *lock,
76633 struct mutex_waiter *waiter,
76634 - struct thread_info *ti);
76635 + struct task_struct *task);
76636 extern void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
76637 - struct thread_info *ti);
76638 + struct task_struct *task);
76639 extern void debug_mutex_unlock(struct mutex *lock);
76640 extern void debug_mutex_init(struct mutex *lock, const char *name,
76641 struct lock_class_key *key);
76642 diff --git a/kernel/mutex.c b/kernel/mutex.c
76643 index 52f2301..73f7528 100644
76644 --- a/kernel/mutex.c
76645 +++ b/kernel/mutex.c
76646 @@ -199,7 +199,7 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
76647 spin_lock_mutex(&lock->wait_lock, flags);
76648
76649 debug_mutex_lock_common(lock, &waiter);
76650 - debug_mutex_add_waiter(lock, &waiter, task_thread_info(task));
76651 + debug_mutex_add_waiter(lock, &waiter, task);
76652
76653 /* add waiting tasks to the end of the waitqueue (FIFO): */
76654 list_add_tail(&waiter.list, &lock->wait_list);
76655 @@ -228,8 +228,7 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
76656 * TASK_UNINTERRUPTIBLE case.)
76657 */
76658 if (unlikely(signal_pending_state(state, task))) {
76659 - mutex_remove_waiter(lock, &waiter,
76660 - task_thread_info(task));
76661 + mutex_remove_waiter(lock, &waiter, task);
76662 mutex_release(&lock->dep_map, 1, ip);
76663 spin_unlock_mutex(&lock->wait_lock, flags);
76664
76665 @@ -248,7 +247,7 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
76666 done:
76667 lock_acquired(&lock->dep_map, ip);
76668 /* got the lock - rejoice! */
76669 - mutex_remove_waiter(lock, &waiter, current_thread_info());
76670 + mutex_remove_waiter(lock, &waiter, task);
76671 mutex_set_owner(lock);
76672
76673 /* set it to 0 if there are no waiters left: */
76674 diff --git a/kernel/notifier.c b/kernel/notifier.c
76675 index 2d5cc4c..d9ea600 100644
76676 --- a/kernel/notifier.c
76677 +++ b/kernel/notifier.c
76678 @@ -5,6 +5,7 @@
76679 #include <linux/rcupdate.h>
76680 #include <linux/vmalloc.h>
76681 #include <linux/reboot.h>
76682 +#include <linux/mm.h>
76683
76684 /*
76685 * Notifier list for kernel code which wants to be called
76686 @@ -24,10 +25,12 @@ static int notifier_chain_register(struct notifier_block **nl,
76687 while ((*nl) != NULL) {
76688 if (n->priority > (*nl)->priority)
76689 break;
76690 - nl = &((*nl)->next);
76691 + nl = (struct notifier_block **)&((*nl)->next);
76692 }
76693 - n->next = *nl;
76694 + pax_open_kernel();
76695 + *(const void **)&n->next = *nl;
76696 rcu_assign_pointer(*nl, n);
76697 + pax_close_kernel();
76698 return 0;
76699 }
76700
76701 @@ -39,10 +42,12 @@ static int notifier_chain_cond_register(struct notifier_block **nl,
76702 return 0;
76703 if (n->priority > (*nl)->priority)
76704 break;
76705 - nl = &((*nl)->next);
76706 + nl = (struct notifier_block **)&((*nl)->next);
76707 }
76708 - n->next = *nl;
76709 + pax_open_kernel();
76710 + *(const void **)&n->next = *nl;
76711 rcu_assign_pointer(*nl, n);
76712 + pax_close_kernel();
76713 return 0;
76714 }
76715
76716 @@ -51,10 +56,12 @@ static int notifier_chain_unregister(struct notifier_block **nl,
76717 {
76718 while ((*nl) != NULL) {
76719 if ((*nl) == n) {
76720 + pax_open_kernel();
76721 rcu_assign_pointer(*nl, n->next);
76722 + pax_close_kernel();
76723 return 0;
76724 }
76725 - nl = &((*nl)->next);
76726 + nl = (struct notifier_block **)&((*nl)->next);
76727 }
76728 return -ENOENT;
76729 }
76730 diff --git a/kernel/panic.c b/kernel/panic.c
76731 index 7c57cc9..28f1b3f 100644
76732 --- a/kernel/panic.c
76733 +++ b/kernel/panic.c
76734 @@ -403,7 +403,7 @@ static void warn_slowpath_common(const char *file, int line, void *caller,
76735 const char *board;
76736
76737 printk(KERN_WARNING "------------[ cut here ]------------\n");
76738 - printk(KERN_WARNING "WARNING: at %s:%d %pS()\n", file, line, caller);
76739 + printk(KERN_WARNING "WARNING: at %s:%d %pA()\n", file, line, caller);
76740 board = dmi_get_system_info(DMI_PRODUCT_NAME);
76741 if (board)
76742 printk(KERN_WARNING "Hardware name: %s\n", board);
76743 @@ -459,7 +459,8 @@ EXPORT_SYMBOL(warn_slowpath_null);
76744 */
76745 void __stack_chk_fail(void)
76746 {
76747 - panic("stack-protector: Kernel stack is corrupted in: %p\n",
76748 + dump_stack();
76749 + panic("stack-protector: Kernel stack is corrupted in: %pA\n",
76750 __builtin_return_address(0));
76751 }
76752 EXPORT_SYMBOL(__stack_chk_fail);
76753 diff --git a/kernel/pid.c b/kernel/pid.c
76754 index 047dc62..418d74b 100644
76755 --- a/kernel/pid.c
76756 +++ b/kernel/pid.c
76757 @@ -33,6 +33,7 @@
76758 #include <linux/rculist.h>
76759 #include <linux/bootmem.h>
76760 #include <linux/hash.h>
76761 +#include <linux/security.h>
76762 #include <linux/pid_namespace.h>
76763 #include <linux/init_task.h>
76764 #include <linux/syscalls.h>
76765 @@ -46,7 +47,7 @@ struct pid init_struct_pid = INIT_STRUCT_PID;
76766
76767 int pid_max = PID_MAX_DEFAULT;
76768
76769 -#define RESERVED_PIDS 300
76770 +#define RESERVED_PIDS 500
76771
76772 int pid_max_min = RESERVED_PIDS + 1;
76773 int pid_max_max = PID_MAX_LIMIT;
76774 @@ -440,10 +441,18 @@ EXPORT_SYMBOL(pid_task);
76775 */
76776 struct task_struct *find_task_by_pid_ns(pid_t nr, struct pid_namespace *ns)
76777 {
76778 + struct task_struct *task;
76779 +
76780 rcu_lockdep_assert(rcu_read_lock_held(),
76781 "find_task_by_pid_ns() needs rcu_read_lock()"
76782 " protection");
76783 - return pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
76784 +
76785 + task = pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
76786 +
76787 + if (gr_pid_is_chrooted(task))
76788 + return NULL;
76789 +
76790 + return task;
76791 }
76792
76793 struct task_struct *find_task_by_vpid(pid_t vnr)
76794 @@ -451,6 +460,14 @@ struct task_struct *find_task_by_vpid(pid_t vnr)
76795 return find_task_by_pid_ns(vnr, task_active_pid_ns(current));
76796 }
76797
76798 +struct task_struct *find_task_by_vpid_unrestricted(pid_t vnr)
76799 +{
76800 + rcu_lockdep_assert(rcu_read_lock_held(),
76801 + "find_task_by_pid_ns() needs rcu_read_lock()"
76802 + " protection");
76803 + return pid_task(find_pid_ns(vnr, task_active_pid_ns(current)), PIDTYPE_PID);
76804 +}
76805 +
76806 struct pid *get_task_pid(struct task_struct *task, enum pid_type type)
76807 {
76808 struct pid *pid;
76809 diff --git a/kernel/pid_namespace.c b/kernel/pid_namespace.c
76810 index bea15bd..789f3d0 100644
76811 --- a/kernel/pid_namespace.c
76812 +++ b/kernel/pid_namespace.c
76813 @@ -249,7 +249,7 @@ static int pid_ns_ctl_handler(struct ctl_table *table, int write,
76814 void __user *buffer, size_t *lenp, loff_t *ppos)
76815 {
76816 struct pid_namespace *pid_ns = task_active_pid_ns(current);
76817 - struct ctl_table tmp = *table;
76818 + ctl_table_no_const tmp = *table;
76819
76820 if (write && !ns_capable(pid_ns->user_ns, CAP_SYS_ADMIN))
76821 return -EPERM;
76822 diff --git a/kernel/posix-cpu-timers.c b/kernel/posix-cpu-timers.c
76823 index 8fd709c..542bf4b 100644
76824 --- a/kernel/posix-cpu-timers.c
76825 +++ b/kernel/posix-cpu-timers.c
76826 @@ -1592,14 +1592,14 @@ struct k_clock clock_posix_cpu = {
76827
76828 static __init int init_posix_cpu_timers(void)
76829 {
76830 - struct k_clock process = {
76831 + static struct k_clock process = {
76832 .clock_getres = process_cpu_clock_getres,
76833 .clock_get = process_cpu_clock_get,
76834 .timer_create = process_cpu_timer_create,
76835 .nsleep = process_cpu_nsleep,
76836 .nsleep_restart = process_cpu_nsleep_restart,
76837 };
76838 - struct k_clock thread = {
76839 + static struct k_clock thread = {
76840 .clock_getres = thread_cpu_clock_getres,
76841 .clock_get = thread_cpu_clock_get,
76842 .timer_create = thread_cpu_timer_create,
76843 diff --git a/kernel/posix-timers.c b/kernel/posix-timers.c
76844 index 6edbb2c..334f085 100644
76845 --- a/kernel/posix-timers.c
76846 +++ b/kernel/posix-timers.c
76847 @@ -43,6 +43,7 @@
76848 #include <linux/idr.h>
76849 #include <linux/posix-clock.h>
76850 #include <linux/posix-timers.h>
76851 +#include <linux/grsecurity.h>
76852 #include <linux/syscalls.h>
76853 #include <linux/wait.h>
76854 #include <linux/workqueue.h>
76855 @@ -129,7 +130,7 @@ static DEFINE_SPINLOCK(idr_lock);
76856 * which we beg off on and pass to do_sys_settimeofday().
76857 */
76858
76859 -static struct k_clock posix_clocks[MAX_CLOCKS];
76860 +static struct k_clock *posix_clocks[MAX_CLOCKS];
76861
76862 /*
76863 * These ones are defined below.
76864 @@ -227,7 +228,7 @@ static int posix_get_boottime(const clockid_t which_clock, struct timespec *tp)
76865 */
76866 static __init int init_posix_timers(void)
76867 {
76868 - struct k_clock clock_realtime = {
76869 + static struct k_clock clock_realtime = {
76870 .clock_getres = hrtimer_get_res,
76871 .clock_get = posix_clock_realtime_get,
76872 .clock_set = posix_clock_realtime_set,
76873 @@ -239,7 +240,7 @@ static __init int init_posix_timers(void)
76874 .timer_get = common_timer_get,
76875 .timer_del = common_timer_del,
76876 };
76877 - struct k_clock clock_monotonic = {
76878 + static struct k_clock clock_monotonic = {
76879 .clock_getres = hrtimer_get_res,
76880 .clock_get = posix_ktime_get_ts,
76881 .nsleep = common_nsleep,
76882 @@ -249,19 +250,19 @@ static __init int init_posix_timers(void)
76883 .timer_get = common_timer_get,
76884 .timer_del = common_timer_del,
76885 };
76886 - struct k_clock clock_monotonic_raw = {
76887 + static struct k_clock clock_monotonic_raw = {
76888 .clock_getres = hrtimer_get_res,
76889 .clock_get = posix_get_monotonic_raw,
76890 };
76891 - struct k_clock clock_realtime_coarse = {
76892 + static struct k_clock clock_realtime_coarse = {
76893 .clock_getres = posix_get_coarse_res,
76894 .clock_get = posix_get_realtime_coarse,
76895 };
76896 - struct k_clock clock_monotonic_coarse = {
76897 + static struct k_clock clock_monotonic_coarse = {
76898 .clock_getres = posix_get_coarse_res,
76899 .clock_get = posix_get_monotonic_coarse,
76900 };
76901 - struct k_clock clock_boottime = {
76902 + static struct k_clock clock_boottime = {
76903 .clock_getres = hrtimer_get_res,
76904 .clock_get = posix_get_boottime,
76905 .nsleep = common_nsleep,
76906 @@ -473,7 +474,7 @@ void posix_timers_register_clock(const clockid_t clock_id,
76907 return;
76908 }
76909
76910 - posix_clocks[clock_id] = *new_clock;
76911 + posix_clocks[clock_id] = new_clock;
76912 }
76913 EXPORT_SYMBOL_GPL(posix_timers_register_clock);
76914
76915 @@ -519,9 +520,9 @@ static struct k_clock *clockid_to_kclock(const clockid_t id)
76916 return (id & CLOCKFD_MASK) == CLOCKFD ?
76917 &clock_posix_dynamic : &clock_posix_cpu;
76918
76919 - if (id >= MAX_CLOCKS || !posix_clocks[id].clock_getres)
76920 + if (id >= MAX_CLOCKS || !posix_clocks[id] || !posix_clocks[id]->clock_getres)
76921 return NULL;
76922 - return &posix_clocks[id];
76923 + return posix_clocks[id];
76924 }
76925
76926 static int common_timer_create(struct k_itimer *new_timer)
76927 @@ -964,6 +965,13 @@ SYSCALL_DEFINE2(clock_settime, const clockid_t, which_clock,
76928 if (copy_from_user(&new_tp, tp, sizeof (*tp)))
76929 return -EFAULT;
76930
76931 + /* only the CLOCK_REALTIME clock can be set, all other clocks
76932 + have their clock_set fptr set to a nosettime dummy function
76933 + CLOCK_REALTIME has a NULL clock_set fptr which causes it to
76934 + call common_clock_set, which calls do_sys_settimeofday, which
76935 + we hook
76936 + */
76937 +
76938 return kc->clock_set(which_clock, &new_tp);
76939 }
76940
76941 diff --git a/kernel/power/process.c b/kernel/power/process.c
76942 index 98088e0..aaf95c0 100644
76943 --- a/kernel/power/process.c
76944 +++ b/kernel/power/process.c
76945 @@ -33,6 +33,7 @@ static int try_to_freeze_tasks(bool user_only)
76946 u64 elapsed_csecs64;
76947 unsigned int elapsed_csecs;
76948 bool wakeup = false;
76949 + bool timedout = false;
76950
76951 do_gettimeofday(&start);
76952
76953 @@ -43,13 +44,20 @@ static int try_to_freeze_tasks(bool user_only)
76954
76955 while (true) {
76956 todo = 0;
76957 + if (time_after(jiffies, end_time))
76958 + timedout = true;
76959 read_lock(&tasklist_lock);
76960 do_each_thread(g, p) {
76961 if (p == current || !freeze_task(p))
76962 continue;
76963
76964 - if (!freezer_should_skip(p))
76965 + if (!freezer_should_skip(p)) {
76966 todo++;
76967 + if (timedout) {
76968 + printk(KERN_ERR "Task refusing to freeze:\n");
76969 + sched_show_task(p);
76970 + }
76971 + }
76972 } while_each_thread(g, p);
76973 read_unlock(&tasklist_lock);
76974
76975 @@ -58,7 +66,7 @@ static int try_to_freeze_tasks(bool user_only)
76976 todo += wq_busy;
76977 }
76978
76979 - if (!todo || time_after(jiffies, end_time))
76980 + if (!todo || timedout)
76981 break;
76982
76983 if (pm_wakeup_pending()) {
76984 diff --git a/kernel/printk.c b/kernel/printk.c
76985 index abbdd9e..f294251 100644
76986 --- a/kernel/printk.c
76987 +++ b/kernel/printk.c
76988 @@ -615,11 +615,17 @@ static unsigned int devkmsg_poll(struct file *file, poll_table *wait)
76989 return ret;
76990 }
76991
76992 +static int check_syslog_permissions(int type, bool from_file);
76993 +
76994 static int devkmsg_open(struct inode *inode, struct file *file)
76995 {
76996 struct devkmsg_user *user;
76997 int err;
76998
76999 + err = check_syslog_permissions(SYSLOG_ACTION_OPEN, SYSLOG_FROM_FILE);
77000 + if (err)
77001 + return err;
77002 +
77003 /* write-only does not need any file context */
77004 if ((file->f_flags & O_ACCMODE) == O_WRONLY)
77005 return 0;
77006 @@ -828,7 +834,7 @@ static int syslog_action_restricted(int type)
77007 if (dmesg_restrict)
77008 return 1;
77009 /* Unless restricted, we allow "read all" and "get buffer size" for everybody */
77010 - return type != SYSLOG_ACTION_READ_ALL && type != SYSLOG_ACTION_SIZE_BUFFER;
77011 + return type != SYSLOG_ACTION_OPEN && type != SYSLOG_ACTION_READ_ALL && type != SYSLOG_ACTION_SIZE_BUFFER;
77012 }
77013
77014 static int check_syslog_permissions(int type, bool from_file)
77015 @@ -840,6 +846,11 @@ static int check_syslog_permissions(int type, bool from_file)
77016 if (from_file && type != SYSLOG_ACTION_OPEN)
77017 return 0;
77018
77019 +#ifdef CONFIG_GRKERNSEC_DMESG
77020 + if (grsec_enable_dmesg && !capable(CAP_SYSLOG) && !capable_nolog(CAP_SYS_ADMIN))
77021 + return -EPERM;
77022 +#endif
77023 +
77024 if (syslog_action_restricted(type)) {
77025 if (capable(CAP_SYSLOG))
77026 return 0;
77027 diff --git a/kernel/profile.c b/kernel/profile.c
77028 index dc3384e..0de5b49 100644
77029 --- a/kernel/profile.c
77030 +++ b/kernel/profile.c
77031 @@ -37,7 +37,7 @@ struct profile_hit {
77032 #define NR_PROFILE_HIT (PAGE_SIZE/sizeof(struct profile_hit))
77033 #define NR_PROFILE_GRP (NR_PROFILE_HIT/PROFILE_GRPSZ)
77034
77035 -static atomic_t *prof_buffer;
77036 +static atomic_unchecked_t *prof_buffer;
77037 static unsigned long prof_len, prof_shift;
77038
77039 int prof_on __read_mostly;
77040 @@ -260,7 +260,7 @@ static void profile_flip_buffers(void)
77041 hits[i].pc = 0;
77042 continue;
77043 }
77044 - atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
77045 + atomic_add_unchecked(hits[i].hits, &prof_buffer[hits[i].pc]);
77046 hits[i].hits = hits[i].pc = 0;
77047 }
77048 }
77049 @@ -321,9 +321,9 @@ static void do_profile_hits(int type, void *__pc, unsigned int nr_hits)
77050 * Add the current hit(s) and flush the write-queue out
77051 * to the global buffer:
77052 */
77053 - atomic_add(nr_hits, &prof_buffer[pc]);
77054 + atomic_add_unchecked(nr_hits, &prof_buffer[pc]);
77055 for (i = 0; i < NR_PROFILE_HIT; ++i) {
77056 - atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
77057 + atomic_add_unchecked(hits[i].hits, &prof_buffer[hits[i].pc]);
77058 hits[i].pc = hits[i].hits = 0;
77059 }
77060 out:
77061 @@ -398,7 +398,7 @@ static void do_profile_hits(int type, void *__pc, unsigned int nr_hits)
77062 {
77063 unsigned long pc;
77064 pc = ((unsigned long)__pc - (unsigned long)_stext) >> prof_shift;
77065 - atomic_add(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
77066 + atomic_add_unchecked(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
77067 }
77068 #endif /* !CONFIG_SMP */
77069
77070 @@ -494,7 +494,7 @@ read_profile(struct file *file, char __user *buf, size_t count, loff_t *ppos)
77071 return -EFAULT;
77072 buf++; p++; count--; read++;
77073 }
77074 - pnt = (char *)prof_buffer + p - sizeof(atomic_t);
77075 + pnt = (char *)prof_buffer + p - sizeof(atomic_unchecked_t);
77076 if (copy_to_user(buf, (void *)pnt, count))
77077 return -EFAULT;
77078 read += count;
77079 @@ -525,7 +525,7 @@ static ssize_t write_profile(struct file *file, const char __user *buf,
77080 }
77081 #endif
77082 profile_discard_flip_buffers();
77083 - memset(prof_buffer, 0, prof_len * sizeof(atomic_t));
77084 + memset(prof_buffer, 0, prof_len * sizeof(atomic_unchecked_t));
77085 return count;
77086 }
77087
77088 diff --git a/kernel/ptrace.c b/kernel/ptrace.c
77089 index acbd284..00bb0c9 100644
77090 --- a/kernel/ptrace.c
77091 +++ b/kernel/ptrace.c
77092 @@ -324,7 +324,7 @@ static int ptrace_attach(struct task_struct *task, long request,
77093 if (seize)
77094 flags |= PT_SEIZED;
77095 rcu_read_lock();
77096 - if (ns_capable(__task_cred(task)->user_ns, CAP_SYS_PTRACE))
77097 + if (ns_capable_nolog(__task_cred(task)->user_ns, CAP_SYS_PTRACE))
77098 flags |= PT_PTRACE_CAP;
77099 rcu_read_unlock();
77100 task->ptrace = flags;
77101 @@ -535,7 +535,7 @@ int ptrace_readdata(struct task_struct *tsk, unsigned long src, char __user *dst
77102 break;
77103 return -EIO;
77104 }
77105 - if (copy_to_user(dst, buf, retval))
77106 + if (retval > sizeof(buf) || copy_to_user(dst, buf, retval))
77107 return -EFAULT;
77108 copied += retval;
77109 src += retval;
77110 @@ -726,7 +726,7 @@ int ptrace_request(struct task_struct *child, long request,
77111 bool seized = child->ptrace & PT_SEIZED;
77112 int ret = -EIO;
77113 siginfo_t siginfo, *si;
77114 - void __user *datavp = (void __user *) data;
77115 + void __user *datavp = (__force void __user *) data;
77116 unsigned long __user *datalp = datavp;
77117 unsigned long flags;
77118
77119 @@ -928,14 +928,21 @@ SYSCALL_DEFINE4(ptrace, long, request, long, pid, unsigned long, addr,
77120 goto out;
77121 }
77122
77123 + if (gr_handle_ptrace(child, request)) {
77124 + ret = -EPERM;
77125 + goto out_put_task_struct;
77126 + }
77127 +
77128 if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
77129 ret = ptrace_attach(child, request, addr, data);
77130 /*
77131 * Some architectures need to do book-keeping after
77132 * a ptrace attach.
77133 */
77134 - if (!ret)
77135 + if (!ret) {
77136 arch_ptrace_attach(child);
77137 + gr_audit_ptrace(child);
77138 + }
77139 goto out_put_task_struct;
77140 }
77141
77142 @@ -963,7 +970,7 @@ int generic_ptrace_peekdata(struct task_struct *tsk, unsigned long addr,
77143 copied = access_process_vm(tsk, addr, &tmp, sizeof(tmp), 0);
77144 if (copied != sizeof(tmp))
77145 return -EIO;
77146 - return put_user(tmp, (unsigned long __user *)data);
77147 + return put_user(tmp, (__force unsigned long __user *)data);
77148 }
77149
77150 int generic_ptrace_pokedata(struct task_struct *tsk, unsigned long addr,
77151 @@ -1057,7 +1064,7 @@ int compat_ptrace_request(struct task_struct *child, compat_long_t request,
77152 }
77153
77154 asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
77155 - compat_long_t addr, compat_long_t data)
77156 + compat_ulong_t addr, compat_ulong_t data)
77157 {
77158 struct task_struct *child;
77159 long ret;
77160 @@ -1073,14 +1080,21 @@ asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
77161 goto out;
77162 }
77163
77164 + if (gr_handle_ptrace(child, request)) {
77165 + ret = -EPERM;
77166 + goto out_put_task_struct;
77167 + }
77168 +
77169 if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
77170 ret = ptrace_attach(child, request, addr, data);
77171 /*
77172 * Some architectures need to do book-keeping after
77173 * a ptrace attach.
77174 */
77175 - if (!ret)
77176 + if (!ret) {
77177 arch_ptrace_attach(child);
77178 + gr_audit_ptrace(child);
77179 + }
77180 goto out_put_task_struct;
77181 }
77182
77183 diff --git a/kernel/rcupdate.c b/kernel/rcupdate.c
77184 index 48ab703..07561d4 100644
77185 --- a/kernel/rcupdate.c
77186 +++ b/kernel/rcupdate.c
77187 @@ -439,10 +439,10 @@ int rcu_jiffies_till_stall_check(void)
77188 * for CONFIG_RCU_CPU_STALL_TIMEOUT.
77189 */
77190 if (till_stall_check < 3) {
77191 - ACCESS_ONCE(rcu_cpu_stall_timeout) = 3;
77192 + ACCESS_ONCE_RW(rcu_cpu_stall_timeout) = 3;
77193 till_stall_check = 3;
77194 } else if (till_stall_check > 300) {
77195 - ACCESS_ONCE(rcu_cpu_stall_timeout) = 300;
77196 + ACCESS_ONCE_RW(rcu_cpu_stall_timeout) = 300;
77197 till_stall_check = 300;
77198 }
77199 return till_stall_check * HZ + RCU_STALL_DELAY_DELTA;
77200 diff --git a/kernel/rcutiny.c b/kernel/rcutiny.c
77201 index a0714a5..2ab5e34 100644
77202 --- a/kernel/rcutiny.c
77203 +++ b/kernel/rcutiny.c
77204 @@ -46,7 +46,7 @@
77205 struct rcu_ctrlblk;
77206 static void invoke_rcu_callbacks(void);
77207 static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp);
77208 -static void rcu_process_callbacks(struct softirq_action *unused);
77209 +static void rcu_process_callbacks(void);
77210 static void __call_rcu(struct rcu_head *head,
77211 void (*func)(struct rcu_head *rcu),
77212 struct rcu_ctrlblk *rcp);
77213 @@ -312,7 +312,7 @@ static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp)
77214 rcu_is_callbacks_kthread()));
77215 }
77216
77217 -static void rcu_process_callbacks(struct softirq_action *unused)
77218 +static void rcu_process_callbacks(void)
77219 {
77220 __rcu_process_callbacks(&rcu_sched_ctrlblk);
77221 __rcu_process_callbacks(&rcu_bh_ctrlblk);
77222 diff --git a/kernel/rcutiny_plugin.h b/kernel/rcutiny_plugin.h
77223 index 8a23300..4255818 100644
77224 --- a/kernel/rcutiny_plugin.h
77225 +++ b/kernel/rcutiny_plugin.h
77226 @@ -945,7 +945,7 @@ static int rcu_kthread(void *arg)
77227 have_rcu_kthread_work = morework;
77228 local_irq_restore(flags);
77229 if (work)
77230 - rcu_process_callbacks(NULL);
77231 + rcu_process_callbacks();
77232 schedule_timeout_interruptible(1); /* Leave CPU for others. */
77233 }
77234
77235 diff --git a/kernel/rcutorture.c b/kernel/rcutorture.c
77236 index e1f3a8c..42c94a2 100644
77237 --- a/kernel/rcutorture.c
77238 +++ b/kernel/rcutorture.c
77239 @@ -164,12 +164,12 @@ static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1], rcu_torture_count) =
77240 { 0 };
77241 static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1], rcu_torture_batch) =
77242 { 0 };
77243 -static atomic_t rcu_torture_wcount[RCU_TORTURE_PIPE_LEN + 1];
77244 -static atomic_t n_rcu_torture_alloc;
77245 -static atomic_t n_rcu_torture_alloc_fail;
77246 -static atomic_t n_rcu_torture_free;
77247 -static atomic_t n_rcu_torture_mberror;
77248 -static atomic_t n_rcu_torture_error;
77249 +static atomic_unchecked_t rcu_torture_wcount[RCU_TORTURE_PIPE_LEN + 1];
77250 +static atomic_unchecked_t n_rcu_torture_alloc;
77251 +static atomic_unchecked_t n_rcu_torture_alloc_fail;
77252 +static atomic_unchecked_t n_rcu_torture_free;
77253 +static atomic_unchecked_t n_rcu_torture_mberror;
77254 +static atomic_unchecked_t n_rcu_torture_error;
77255 static long n_rcu_torture_barrier_error;
77256 static long n_rcu_torture_boost_ktrerror;
77257 static long n_rcu_torture_boost_rterror;
77258 @@ -287,11 +287,11 @@ rcu_torture_alloc(void)
77259
77260 spin_lock_bh(&rcu_torture_lock);
77261 if (list_empty(&rcu_torture_freelist)) {
77262 - atomic_inc(&n_rcu_torture_alloc_fail);
77263 + atomic_inc_unchecked(&n_rcu_torture_alloc_fail);
77264 spin_unlock_bh(&rcu_torture_lock);
77265 return NULL;
77266 }
77267 - atomic_inc(&n_rcu_torture_alloc);
77268 + atomic_inc_unchecked(&n_rcu_torture_alloc);
77269 p = rcu_torture_freelist.next;
77270 list_del_init(p);
77271 spin_unlock_bh(&rcu_torture_lock);
77272 @@ -304,7 +304,7 @@ rcu_torture_alloc(void)
77273 static void
77274 rcu_torture_free(struct rcu_torture *p)
77275 {
77276 - atomic_inc(&n_rcu_torture_free);
77277 + atomic_inc_unchecked(&n_rcu_torture_free);
77278 spin_lock_bh(&rcu_torture_lock);
77279 list_add_tail(&p->rtort_free, &rcu_torture_freelist);
77280 spin_unlock_bh(&rcu_torture_lock);
77281 @@ -424,7 +424,7 @@ rcu_torture_cb(struct rcu_head *p)
77282 i = rp->rtort_pipe_count;
77283 if (i > RCU_TORTURE_PIPE_LEN)
77284 i = RCU_TORTURE_PIPE_LEN;
77285 - atomic_inc(&rcu_torture_wcount[i]);
77286 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
77287 if (++rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) {
77288 rp->rtort_mbtest = 0;
77289 rcu_torture_free(rp);
77290 @@ -472,7 +472,7 @@ static void rcu_sync_torture_deferred_free(struct rcu_torture *p)
77291 i = rp->rtort_pipe_count;
77292 if (i > RCU_TORTURE_PIPE_LEN)
77293 i = RCU_TORTURE_PIPE_LEN;
77294 - atomic_inc(&rcu_torture_wcount[i]);
77295 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
77296 if (++rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) {
77297 rp->rtort_mbtest = 0;
77298 list_del(&rp->rtort_free);
77299 @@ -990,7 +990,7 @@ rcu_torture_writer(void *arg)
77300 i = old_rp->rtort_pipe_count;
77301 if (i > RCU_TORTURE_PIPE_LEN)
77302 i = RCU_TORTURE_PIPE_LEN;
77303 - atomic_inc(&rcu_torture_wcount[i]);
77304 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
77305 old_rp->rtort_pipe_count++;
77306 cur_ops->deferred_free(old_rp);
77307 }
77308 @@ -1076,7 +1076,7 @@ static void rcu_torture_timer(unsigned long unused)
77309 return;
77310 }
77311 if (p->rtort_mbtest == 0)
77312 - atomic_inc(&n_rcu_torture_mberror);
77313 + atomic_inc_unchecked(&n_rcu_torture_mberror);
77314 spin_lock(&rand_lock);
77315 cur_ops->read_delay(&rand);
77316 n_rcu_torture_timers++;
77317 @@ -1146,7 +1146,7 @@ rcu_torture_reader(void *arg)
77318 continue;
77319 }
77320 if (p->rtort_mbtest == 0)
77321 - atomic_inc(&n_rcu_torture_mberror);
77322 + atomic_inc_unchecked(&n_rcu_torture_mberror);
77323 cur_ops->read_delay(&rand);
77324 preempt_disable();
77325 pipe_count = p->rtort_pipe_count;
77326 @@ -1209,11 +1209,11 @@ rcu_torture_printk(char *page)
77327 rcu_torture_current,
77328 rcu_torture_current_version,
77329 list_empty(&rcu_torture_freelist),
77330 - atomic_read(&n_rcu_torture_alloc),
77331 - atomic_read(&n_rcu_torture_alloc_fail),
77332 - atomic_read(&n_rcu_torture_free));
77333 + atomic_read_unchecked(&n_rcu_torture_alloc),
77334 + atomic_read_unchecked(&n_rcu_torture_alloc_fail),
77335 + atomic_read_unchecked(&n_rcu_torture_free));
77336 cnt += sprintf(&page[cnt], "rtmbe: %d rtbke: %ld rtbre: %ld ",
77337 - atomic_read(&n_rcu_torture_mberror),
77338 + atomic_read_unchecked(&n_rcu_torture_mberror),
77339 n_rcu_torture_boost_ktrerror,
77340 n_rcu_torture_boost_rterror);
77341 cnt += sprintf(&page[cnt], "rtbf: %ld rtb: %ld nt: %ld ",
77342 @@ -1232,14 +1232,14 @@ rcu_torture_printk(char *page)
77343 n_barrier_attempts,
77344 n_rcu_torture_barrier_error);
77345 cnt += sprintf(&page[cnt], "\n%s%s ", torture_type, TORTURE_FLAG);
77346 - if (atomic_read(&n_rcu_torture_mberror) != 0 ||
77347 + if (atomic_read_unchecked(&n_rcu_torture_mberror) != 0 ||
77348 n_rcu_torture_barrier_error != 0 ||
77349 n_rcu_torture_boost_ktrerror != 0 ||
77350 n_rcu_torture_boost_rterror != 0 ||
77351 n_rcu_torture_boost_failure != 0 ||
77352 i > 1) {
77353 cnt += sprintf(&page[cnt], "!!! ");
77354 - atomic_inc(&n_rcu_torture_error);
77355 + atomic_inc_unchecked(&n_rcu_torture_error);
77356 WARN_ON_ONCE(1);
77357 }
77358 cnt += sprintf(&page[cnt], "Reader Pipe: ");
77359 @@ -1253,7 +1253,7 @@ rcu_torture_printk(char *page)
77360 cnt += sprintf(&page[cnt], "Free-Block Circulation: ");
77361 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
77362 cnt += sprintf(&page[cnt], " %d",
77363 - atomic_read(&rcu_torture_wcount[i]));
77364 + atomic_read_unchecked(&rcu_torture_wcount[i]));
77365 }
77366 cnt += sprintf(&page[cnt], "\n");
77367 if (cur_ops->stats)
77368 @@ -1962,7 +1962,7 @@ rcu_torture_cleanup(void)
77369
77370 rcu_torture_stats_print(); /* -After- the stats thread is stopped! */
77371
77372 - if (atomic_read(&n_rcu_torture_error) || n_rcu_torture_barrier_error)
77373 + if (atomic_read_unchecked(&n_rcu_torture_error) || n_rcu_torture_barrier_error)
77374 rcu_torture_print_module_parms(cur_ops, "End of test: FAILURE");
77375 else if (n_online_successes != n_online_attempts ||
77376 n_offline_successes != n_offline_attempts)
77377 @@ -2031,18 +2031,18 @@ rcu_torture_init(void)
77378
77379 rcu_torture_current = NULL;
77380 rcu_torture_current_version = 0;
77381 - atomic_set(&n_rcu_torture_alloc, 0);
77382 - atomic_set(&n_rcu_torture_alloc_fail, 0);
77383 - atomic_set(&n_rcu_torture_free, 0);
77384 - atomic_set(&n_rcu_torture_mberror, 0);
77385 - atomic_set(&n_rcu_torture_error, 0);
77386 + atomic_set_unchecked(&n_rcu_torture_alloc, 0);
77387 + atomic_set_unchecked(&n_rcu_torture_alloc_fail, 0);
77388 + atomic_set_unchecked(&n_rcu_torture_free, 0);
77389 + atomic_set_unchecked(&n_rcu_torture_mberror, 0);
77390 + atomic_set_unchecked(&n_rcu_torture_error, 0);
77391 n_rcu_torture_barrier_error = 0;
77392 n_rcu_torture_boost_ktrerror = 0;
77393 n_rcu_torture_boost_rterror = 0;
77394 n_rcu_torture_boost_failure = 0;
77395 n_rcu_torture_boosts = 0;
77396 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++)
77397 - atomic_set(&rcu_torture_wcount[i], 0);
77398 + atomic_set_unchecked(&rcu_torture_wcount[i], 0);
77399 for_each_possible_cpu(cpu) {
77400 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
77401 per_cpu(rcu_torture_count, cpu)[i] = 0;
77402 diff --git a/kernel/rcutree.c b/kernel/rcutree.c
77403 index 5b8ad82..17274d1 100644
77404 --- a/kernel/rcutree.c
77405 +++ b/kernel/rcutree.c
77406 @@ -353,9 +353,9 @@ static void rcu_eqs_enter_common(struct rcu_dynticks *rdtp, long long oldval,
77407 rcu_prepare_for_idle(smp_processor_id());
77408 /* CPUs seeing atomic_inc() must see prior RCU read-side crit sects */
77409 smp_mb__before_atomic_inc(); /* See above. */
77410 - atomic_inc(&rdtp->dynticks);
77411 + atomic_inc_unchecked(&rdtp->dynticks);
77412 smp_mb__after_atomic_inc(); /* Force ordering with next sojourn. */
77413 - WARN_ON_ONCE(atomic_read(&rdtp->dynticks) & 0x1);
77414 + WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks) & 0x1);
77415
77416 /*
77417 * It is illegal to enter an extended quiescent state while
77418 @@ -491,10 +491,10 @@ static void rcu_eqs_exit_common(struct rcu_dynticks *rdtp, long long oldval,
77419 int user)
77420 {
77421 smp_mb__before_atomic_inc(); /* Force ordering w/previous sojourn. */
77422 - atomic_inc(&rdtp->dynticks);
77423 + atomic_inc_unchecked(&rdtp->dynticks);
77424 /* CPUs seeing atomic_inc() must see later RCU read-side crit sects */
77425 smp_mb__after_atomic_inc(); /* See above. */
77426 - WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks) & 0x1));
77427 + WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks) & 0x1));
77428 rcu_cleanup_after_idle(smp_processor_id());
77429 trace_rcu_dyntick("End", oldval, rdtp->dynticks_nesting);
77430 if (!user && !is_idle_task(current)) {
77431 @@ -633,14 +633,14 @@ void rcu_nmi_enter(void)
77432 struct rcu_dynticks *rdtp = &__get_cpu_var(rcu_dynticks);
77433
77434 if (rdtp->dynticks_nmi_nesting == 0 &&
77435 - (atomic_read(&rdtp->dynticks) & 0x1))
77436 + (atomic_read_unchecked(&rdtp->dynticks) & 0x1))
77437 return;
77438 rdtp->dynticks_nmi_nesting++;
77439 smp_mb__before_atomic_inc(); /* Force delay from prior write. */
77440 - atomic_inc(&rdtp->dynticks);
77441 + atomic_inc_unchecked(&rdtp->dynticks);
77442 /* CPUs seeing atomic_inc() must see later RCU read-side crit sects */
77443 smp_mb__after_atomic_inc(); /* See above. */
77444 - WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks) & 0x1));
77445 + WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks) & 0x1));
77446 }
77447
77448 /**
77449 @@ -659,9 +659,9 @@ void rcu_nmi_exit(void)
77450 return;
77451 /* CPUs seeing atomic_inc() must see prior RCU read-side crit sects */
77452 smp_mb__before_atomic_inc(); /* See above. */
77453 - atomic_inc(&rdtp->dynticks);
77454 + atomic_inc_unchecked(&rdtp->dynticks);
77455 smp_mb__after_atomic_inc(); /* Force delay to next write. */
77456 - WARN_ON_ONCE(atomic_read(&rdtp->dynticks) & 0x1);
77457 + WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks) & 0x1);
77458 }
77459
77460 /**
77461 @@ -675,7 +675,7 @@ int rcu_is_cpu_idle(void)
77462 int ret;
77463
77464 preempt_disable();
77465 - ret = (atomic_read(&__get_cpu_var(rcu_dynticks).dynticks) & 0x1) == 0;
77466 + ret = (atomic_read_unchecked(&__get_cpu_var(rcu_dynticks).dynticks) & 0x1) == 0;
77467 preempt_enable();
77468 return ret;
77469 }
77470 @@ -743,7 +743,7 @@ static int rcu_is_cpu_rrupt_from_idle(void)
77471 */
77472 static int dyntick_save_progress_counter(struct rcu_data *rdp)
77473 {
77474 - rdp->dynticks_snap = atomic_add_return(0, &rdp->dynticks->dynticks);
77475 + rdp->dynticks_snap = atomic_add_return_unchecked(0, &rdp->dynticks->dynticks);
77476 return (rdp->dynticks_snap & 0x1) == 0;
77477 }
77478
77479 @@ -758,7 +758,7 @@ static int rcu_implicit_dynticks_qs(struct rcu_data *rdp)
77480 unsigned int curr;
77481 unsigned int snap;
77482
77483 - curr = (unsigned int)atomic_add_return(0, &rdp->dynticks->dynticks);
77484 + curr = (unsigned int)atomic_add_return_unchecked(0, &rdp->dynticks->dynticks);
77485 snap = (unsigned int)rdp->dynticks_snap;
77486
77487 /*
77488 @@ -1698,7 +1698,7 @@ rcu_send_cbs_to_orphanage(int cpu, struct rcu_state *rsp,
77489 rsp->qlen += rdp->qlen;
77490 rdp->n_cbs_orphaned += rdp->qlen;
77491 rdp->qlen_lazy = 0;
77492 - ACCESS_ONCE(rdp->qlen) = 0;
77493 + ACCESS_ONCE_RW(rdp->qlen) = 0;
77494 }
77495
77496 /*
77497 @@ -1944,7 +1944,7 @@ static void rcu_do_batch(struct rcu_state *rsp, struct rcu_data *rdp)
77498 }
77499 smp_mb(); /* List handling before counting for rcu_barrier(). */
77500 rdp->qlen_lazy -= count_lazy;
77501 - ACCESS_ONCE(rdp->qlen) -= count;
77502 + ACCESS_ONCE_RW(rdp->qlen) -= count;
77503 rdp->n_cbs_invoked += count;
77504
77505 /* Reinstate batch limit if we have worked down the excess. */
77506 @@ -2137,7 +2137,7 @@ __rcu_process_callbacks(struct rcu_state *rsp)
77507 /*
77508 * Do RCU core processing for the current CPU.
77509 */
77510 -static void rcu_process_callbacks(struct softirq_action *unused)
77511 +static void rcu_process_callbacks(void)
77512 {
77513 struct rcu_state *rsp;
77514
77515 @@ -2260,7 +2260,7 @@ __call_rcu(struct rcu_head *head, void (*func)(struct rcu_head *rcu),
77516 local_irq_restore(flags);
77517 return;
77518 }
77519 - ACCESS_ONCE(rdp->qlen)++;
77520 + ACCESS_ONCE_RW(rdp->qlen)++;
77521 if (lazy)
77522 rdp->qlen_lazy++;
77523 else
77524 @@ -2469,11 +2469,11 @@ void synchronize_sched_expedited(void)
77525 * counter wrap on a 32-bit system. Quite a few more CPUs would of
77526 * course be required on a 64-bit system.
77527 */
77528 - if (ULONG_CMP_GE((ulong)atomic_long_read(&rsp->expedited_start),
77529 + if (ULONG_CMP_GE((ulong)atomic_long_read_unchecked(&rsp->expedited_start),
77530 (ulong)atomic_long_read(&rsp->expedited_done) +
77531 ULONG_MAX / 8)) {
77532 synchronize_sched();
77533 - atomic_long_inc(&rsp->expedited_wrap);
77534 + atomic_long_inc_unchecked(&rsp->expedited_wrap);
77535 return;
77536 }
77537
77538 @@ -2481,7 +2481,7 @@ void synchronize_sched_expedited(void)
77539 * Take a ticket. Note that atomic_inc_return() implies a
77540 * full memory barrier.
77541 */
77542 - snap = atomic_long_inc_return(&rsp->expedited_start);
77543 + snap = atomic_long_inc_return_unchecked(&rsp->expedited_start);
77544 firstsnap = snap;
77545 get_online_cpus();
77546 WARN_ON_ONCE(cpu_is_offline(raw_smp_processor_id()));
77547 @@ -2494,14 +2494,14 @@ void synchronize_sched_expedited(void)
77548 synchronize_sched_expedited_cpu_stop,
77549 NULL) == -EAGAIN) {
77550 put_online_cpus();
77551 - atomic_long_inc(&rsp->expedited_tryfail);
77552 + atomic_long_inc_unchecked(&rsp->expedited_tryfail);
77553
77554 /* Check to see if someone else did our work for us. */
77555 s = atomic_long_read(&rsp->expedited_done);
77556 if (ULONG_CMP_GE((ulong)s, (ulong)firstsnap)) {
77557 /* ensure test happens before caller kfree */
77558 smp_mb__before_atomic_inc(); /* ^^^ */
77559 - atomic_long_inc(&rsp->expedited_workdone1);
77560 + atomic_long_inc_unchecked(&rsp->expedited_workdone1);
77561 return;
77562 }
77563
77564 @@ -2510,7 +2510,7 @@ void synchronize_sched_expedited(void)
77565 udelay(trycount * num_online_cpus());
77566 } else {
77567 wait_rcu_gp(call_rcu_sched);
77568 - atomic_long_inc(&rsp->expedited_normal);
77569 + atomic_long_inc_unchecked(&rsp->expedited_normal);
77570 return;
77571 }
77572
77573 @@ -2519,7 +2519,7 @@ void synchronize_sched_expedited(void)
77574 if (ULONG_CMP_GE((ulong)s, (ulong)firstsnap)) {
77575 /* ensure test happens before caller kfree */
77576 smp_mb__before_atomic_inc(); /* ^^^ */
77577 - atomic_long_inc(&rsp->expedited_workdone2);
77578 + atomic_long_inc_unchecked(&rsp->expedited_workdone2);
77579 return;
77580 }
77581
77582 @@ -2531,10 +2531,10 @@ void synchronize_sched_expedited(void)
77583 * period works for us.
77584 */
77585 get_online_cpus();
77586 - snap = atomic_long_read(&rsp->expedited_start);
77587 + snap = atomic_long_read_unchecked(&rsp->expedited_start);
77588 smp_mb(); /* ensure read is before try_stop_cpus(). */
77589 }
77590 - atomic_long_inc(&rsp->expedited_stoppedcpus);
77591 + atomic_long_inc_unchecked(&rsp->expedited_stoppedcpus);
77592
77593 /*
77594 * Everyone up to our most recent fetch is covered by our grace
77595 @@ -2543,16 +2543,16 @@ void synchronize_sched_expedited(void)
77596 * than we did already did their update.
77597 */
77598 do {
77599 - atomic_long_inc(&rsp->expedited_done_tries);
77600 + atomic_long_inc_unchecked(&rsp->expedited_done_tries);
77601 s = atomic_long_read(&rsp->expedited_done);
77602 if (ULONG_CMP_GE((ulong)s, (ulong)snap)) {
77603 /* ensure test happens before caller kfree */
77604 smp_mb__before_atomic_inc(); /* ^^^ */
77605 - atomic_long_inc(&rsp->expedited_done_lost);
77606 + atomic_long_inc_unchecked(&rsp->expedited_done_lost);
77607 break;
77608 }
77609 } while (atomic_long_cmpxchg(&rsp->expedited_done, s, snap) != s);
77610 - atomic_long_inc(&rsp->expedited_done_exit);
77611 + atomic_long_inc_unchecked(&rsp->expedited_done_exit);
77612
77613 put_online_cpus();
77614 }
77615 @@ -2726,7 +2726,7 @@ static void _rcu_barrier(struct rcu_state *rsp)
77616 * ACCESS_ONCE() to prevent the compiler from speculating
77617 * the increment to precede the early-exit check.
77618 */
77619 - ACCESS_ONCE(rsp->n_barrier_done)++;
77620 + ACCESS_ONCE_RW(rsp->n_barrier_done)++;
77621 WARN_ON_ONCE((rsp->n_barrier_done & 0x1) != 1);
77622 _rcu_barrier_trace(rsp, "Inc1", -1, rsp->n_barrier_done);
77623 smp_mb(); /* Order ->n_barrier_done increment with below mechanism. */
77624 @@ -2776,7 +2776,7 @@ static void _rcu_barrier(struct rcu_state *rsp)
77625
77626 /* Increment ->n_barrier_done to prevent duplicate work. */
77627 smp_mb(); /* Keep increment after above mechanism. */
77628 - ACCESS_ONCE(rsp->n_barrier_done)++;
77629 + ACCESS_ONCE_RW(rsp->n_barrier_done)++;
77630 WARN_ON_ONCE((rsp->n_barrier_done & 0x1) != 0);
77631 _rcu_barrier_trace(rsp, "Inc2", -1, rsp->n_barrier_done);
77632 smp_mb(); /* Keep increment before caller's subsequent code. */
77633 @@ -2821,10 +2821,10 @@ rcu_boot_init_percpu_data(int cpu, struct rcu_state *rsp)
77634 rdp->grpmask = 1UL << (cpu - rdp->mynode->grplo);
77635 init_callback_list(rdp);
77636 rdp->qlen_lazy = 0;
77637 - ACCESS_ONCE(rdp->qlen) = 0;
77638 + ACCESS_ONCE_RW(rdp->qlen) = 0;
77639 rdp->dynticks = &per_cpu(rcu_dynticks, cpu);
77640 WARN_ON_ONCE(rdp->dynticks->dynticks_nesting != DYNTICK_TASK_EXIT_IDLE);
77641 - WARN_ON_ONCE(atomic_read(&rdp->dynticks->dynticks) != 1);
77642 + WARN_ON_ONCE(atomic_read_unchecked(&rdp->dynticks->dynticks) != 1);
77643 rdp->cpu = cpu;
77644 rdp->rsp = rsp;
77645 rcu_boot_init_nocb_percpu_data(rdp);
77646 @@ -2857,8 +2857,8 @@ rcu_init_percpu_data(int cpu, struct rcu_state *rsp, int preemptible)
77647 rdp->blimit = blimit;
77648 init_callback_list(rdp); /* Re-enable callbacks on this CPU. */
77649 rdp->dynticks->dynticks_nesting = DYNTICK_TASK_EXIT_IDLE;
77650 - atomic_set(&rdp->dynticks->dynticks,
77651 - (atomic_read(&rdp->dynticks->dynticks) & ~0x1) + 1);
77652 + atomic_set_unchecked(&rdp->dynticks->dynticks,
77653 + (atomic_read_unchecked(&rdp->dynticks->dynticks) & ~0x1) + 1);
77654 rcu_prepare_for_idle_init(cpu);
77655 raw_spin_unlock(&rnp->lock); /* irqs remain disabled. */
77656
77657 diff --git a/kernel/rcutree.h b/kernel/rcutree.h
77658 index c896b50..c357252 100644
77659 --- a/kernel/rcutree.h
77660 +++ b/kernel/rcutree.h
77661 @@ -86,7 +86,7 @@ struct rcu_dynticks {
77662 long long dynticks_nesting; /* Track irq/process nesting level. */
77663 /* Process level is worth LLONG_MAX/2. */
77664 int dynticks_nmi_nesting; /* Track NMI nesting level. */
77665 - atomic_t dynticks; /* Even value for idle, else odd. */
77666 + atomic_unchecked_t dynticks;/* Even value for idle, else odd. */
77667 #ifdef CONFIG_RCU_FAST_NO_HZ
77668 int dyntick_drain; /* Prepare-for-idle state variable. */
77669 unsigned long dyntick_holdoff;
77670 @@ -416,17 +416,17 @@ struct rcu_state {
77671 /* _rcu_barrier(). */
77672 /* End of fields guarded by barrier_mutex. */
77673
77674 - atomic_long_t expedited_start; /* Starting ticket. */
77675 - atomic_long_t expedited_done; /* Done ticket. */
77676 - atomic_long_t expedited_wrap; /* # near-wrap incidents. */
77677 - atomic_long_t expedited_tryfail; /* # acquisition failures. */
77678 - atomic_long_t expedited_workdone1; /* # done by others #1. */
77679 - atomic_long_t expedited_workdone2; /* # done by others #2. */
77680 - atomic_long_t expedited_normal; /* # fallbacks to normal. */
77681 - atomic_long_t expedited_stoppedcpus; /* # successful stop_cpus. */
77682 - atomic_long_t expedited_done_tries; /* # tries to update _done. */
77683 - atomic_long_t expedited_done_lost; /* # times beaten to _done. */
77684 - atomic_long_t expedited_done_exit; /* # times exited _done loop. */
77685 + atomic_long_unchecked_t expedited_start; /* Starting ticket. */
77686 + atomic_long_t expedited_done; /* Done ticket. */
77687 + atomic_long_unchecked_t expedited_wrap; /* # near-wrap incidents. */
77688 + atomic_long_unchecked_t expedited_tryfail; /* # acquisition failures. */
77689 + atomic_long_unchecked_t expedited_workdone1; /* # done by others #1. */
77690 + atomic_long_unchecked_t expedited_workdone2; /* # done by others #2. */
77691 + atomic_long_unchecked_t expedited_normal; /* # fallbacks to normal. */
77692 + atomic_long_unchecked_t expedited_stoppedcpus; /* # successful stop_cpus. */
77693 + atomic_long_unchecked_t expedited_done_tries; /* # tries to update _done. */
77694 + atomic_long_unchecked_t expedited_done_lost; /* # times beaten to _done. */
77695 + atomic_long_unchecked_t expedited_done_exit; /* # times exited _done loop. */
77696
77697 unsigned long jiffies_force_qs; /* Time at which to invoke */
77698 /* force_quiescent_state(). */
77699 diff --git a/kernel/rcutree_plugin.h b/kernel/rcutree_plugin.h
77700 index c1cc7e1..f62e436 100644
77701 --- a/kernel/rcutree_plugin.h
77702 +++ b/kernel/rcutree_plugin.h
77703 @@ -892,7 +892,7 @@ void synchronize_rcu_expedited(void)
77704
77705 /* Clean up and exit. */
77706 smp_mb(); /* ensure expedited GP seen before counter increment. */
77707 - ACCESS_ONCE(sync_rcu_preempt_exp_count)++;
77708 + ACCESS_ONCE_RW(sync_rcu_preempt_exp_count)++;
77709 unlock_mb_ret:
77710 mutex_unlock(&sync_rcu_preempt_exp_mutex);
77711 mb_ret:
77712 @@ -1440,7 +1440,7 @@ static void rcu_boost_kthread_setaffinity(struct rcu_node *rnp, int outgoingcpu)
77713 free_cpumask_var(cm);
77714 }
77715
77716 -static struct smp_hotplug_thread rcu_cpu_thread_spec = {
77717 +static struct smp_hotplug_thread rcu_cpu_thread_spec __read_only = {
77718 .store = &rcu_cpu_kthread_task,
77719 .thread_should_run = rcu_cpu_kthread_should_run,
77720 .thread_fn = rcu_cpu_kthread,
77721 @@ -2072,7 +2072,7 @@ static void print_cpu_stall_info(struct rcu_state *rsp, int cpu)
77722 print_cpu_stall_fast_no_hz(fast_no_hz, cpu);
77723 printk(KERN_ERR "\t%d: (%lu %s) idle=%03x/%llx/%d %s\n",
77724 cpu, ticks_value, ticks_title,
77725 - atomic_read(&rdtp->dynticks) & 0xfff,
77726 + atomic_read_unchecked(&rdtp->dynticks) & 0xfff,
77727 rdtp->dynticks_nesting, rdtp->dynticks_nmi_nesting,
77728 fast_no_hz);
77729 }
77730 @@ -2192,7 +2192,7 @@ static void __call_rcu_nocb_enqueue(struct rcu_data *rdp,
77731
77732 /* Enqueue the callback on the nocb list and update counts. */
77733 old_rhpp = xchg(&rdp->nocb_tail, rhtp);
77734 - ACCESS_ONCE(*old_rhpp) = rhp;
77735 + ACCESS_ONCE_RW(*old_rhpp) = rhp;
77736 atomic_long_add(rhcount, &rdp->nocb_q_count);
77737 atomic_long_add(rhcount_lazy, &rdp->nocb_q_count_lazy);
77738
77739 @@ -2384,12 +2384,12 @@ static int rcu_nocb_kthread(void *arg)
77740 * Extract queued callbacks, update counts, and wait
77741 * for a grace period to elapse.
77742 */
77743 - ACCESS_ONCE(rdp->nocb_head) = NULL;
77744 + ACCESS_ONCE_RW(rdp->nocb_head) = NULL;
77745 tail = xchg(&rdp->nocb_tail, &rdp->nocb_head);
77746 c = atomic_long_xchg(&rdp->nocb_q_count, 0);
77747 cl = atomic_long_xchg(&rdp->nocb_q_count_lazy, 0);
77748 - ACCESS_ONCE(rdp->nocb_p_count) += c;
77749 - ACCESS_ONCE(rdp->nocb_p_count_lazy) += cl;
77750 + ACCESS_ONCE_RW(rdp->nocb_p_count) += c;
77751 + ACCESS_ONCE_RW(rdp->nocb_p_count_lazy) += cl;
77752 wait_rcu_gp(rdp->rsp->call_remote);
77753
77754 /* Each pass through the following loop invokes a callback. */
77755 @@ -2411,8 +2411,8 @@ static int rcu_nocb_kthread(void *arg)
77756 list = next;
77757 }
77758 trace_rcu_batch_end(rdp->rsp->name, c, !!list, 0, 0, 1);
77759 - ACCESS_ONCE(rdp->nocb_p_count) -= c;
77760 - ACCESS_ONCE(rdp->nocb_p_count_lazy) -= cl;
77761 + ACCESS_ONCE_RW(rdp->nocb_p_count) -= c;
77762 + ACCESS_ONCE_RW(rdp->nocb_p_count_lazy) -= cl;
77763 rdp->n_nocbs_invoked += c;
77764 }
77765 return 0;
77766 @@ -2438,7 +2438,7 @@ static void __init rcu_spawn_nocb_kthreads(struct rcu_state *rsp)
77767 rdp = per_cpu_ptr(rsp->rda, cpu);
77768 t = kthread_run(rcu_nocb_kthread, rdp, "rcuo%d", cpu);
77769 BUG_ON(IS_ERR(t));
77770 - ACCESS_ONCE(rdp->nocb_kthread) = t;
77771 + ACCESS_ONCE_RW(rdp->nocb_kthread) = t;
77772 }
77773 }
77774
77775 diff --git a/kernel/rcutree_trace.c b/kernel/rcutree_trace.c
77776 index 93f8e8f..cf812ae 100644
77777 --- a/kernel/rcutree_trace.c
77778 +++ b/kernel/rcutree_trace.c
77779 @@ -123,7 +123,7 @@ static void print_one_rcu_data(struct seq_file *m, struct rcu_data *rdp)
77780 ulong2long(rdp->completed), ulong2long(rdp->gpnum),
77781 rdp->passed_quiesce, rdp->qs_pending);
77782 seq_printf(m, " dt=%d/%llx/%d df=%lu",
77783 - atomic_read(&rdp->dynticks->dynticks),
77784 + atomic_read_unchecked(&rdp->dynticks->dynticks),
77785 rdp->dynticks->dynticks_nesting,
77786 rdp->dynticks->dynticks_nmi_nesting,
77787 rdp->dynticks_fqs);
77788 @@ -184,17 +184,17 @@ static int show_rcuexp(struct seq_file *m, void *v)
77789 struct rcu_state *rsp = (struct rcu_state *)m->private;
77790
77791 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",
77792 - atomic_long_read(&rsp->expedited_start),
77793 + atomic_long_read_unchecked(&rsp->expedited_start),
77794 atomic_long_read(&rsp->expedited_done),
77795 - atomic_long_read(&rsp->expedited_wrap),
77796 - atomic_long_read(&rsp->expedited_tryfail),
77797 - atomic_long_read(&rsp->expedited_workdone1),
77798 - atomic_long_read(&rsp->expedited_workdone2),
77799 - atomic_long_read(&rsp->expedited_normal),
77800 - atomic_long_read(&rsp->expedited_stoppedcpus),
77801 - atomic_long_read(&rsp->expedited_done_tries),
77802 - atomic_long_read(&rsp->expedited_done_lost),
77803 - atomic_long_read(&rsp->expedited_done_exit));
77804 + atomic_long_read_unchecked(&rsp->expedited_wrap),
77805 + atomic_long_read_unchecked(&rsp->expedited_tryfail),
77806 + atomic_long_read_unchecked(&rsp->expedited_workdone1),
77807 + atomic_long_read_unchecked(&rsp->expedited_workdone2),
77808 + atomic_long_read_unchecked(&rsp->expedited_normal),
77809 + atomic_long_read_unchecked(&rsp->expedited_stoppedcpus),
77810 + atomic_long_read_unchecked(&rsp->expedited_done_tries),
77811 + atomic_long_read_unchecked(&rsp->expedited_done_lost),
77812 + atomic_long_read_unchecked(&rsp->expedited_done_exit));
77813 return 0;
77814 }
77815
77816 diff --git a/kernel/resource.c b/kernel/resource.c
77817 index 73f35d4..4684fc4 100644
77818 --- a/kernel/resource.c
77819 +++ b/kernel/resource.c
77820 @@ -143,8 +143,18 @@ static const struct file_operations proc_iomem_operations = {
77821
77822 static int __init ioresources_init(void)
77823 {
77824 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
77825 +#ifdef CONFIG_GRKERNSEC_PROC_USER
77826 + proc_create("ioports", S_IRUSR, NULL, &proc_ioports_operations);
77827 + proc_create("iomem", S_IRUSR, NULL, &proc_iomem_operations);
77828 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
77829 + proc_create("ioports", S_IRUSR | S_IRGRP, NULL, &proc_ioports_operations);
77830 + proc_create("iomem", S_IRUSR | S_IRGRP, NULL, &proc_iomem_operations);
77831 +#endif
77832 +#else
77833 proc_create("ioports", 0, NULL, &proc_ioports_operations);
77834 proc_create("iomem", 0, NULL, &proc_iomem_operations);
77835 +#endif
77836 return 0;
77837 }
77838 __initcall(ioresources_init);
77839 diff --git a/kernel/rtmutex-tester.c b/kernel/rtmutex-tester.c
77840 index 7890b10..8b68605f 100644
77841 --- a/kernel/rtmutex-tester.c
77842 +++ b/kernel/rtmutex-tester.c
77843 @@ -21,7 +21,7 @@
77844 #define MAX_RT_TEST_MUTEXES 8
77845
77846 static spinlock_t rttest_lock;
77847 -static atomic_t rttest_event;
77848 +static atomic_unchecked_t rttest_event;
77849
77850 struct test_thread_data {
77851 int opcode;
77852 @@ -62,7 +62,7 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
77853
77854 case RTTEST_LOCKCONT:
77855 td->mutexes[td->opdata] = 1;
77856 - td->event = atomic_add_return(1, &rttest_event);
77857 + td->event = atomic_add_return_unchecked(1, &rttest_event);
77858 return 0;
77859
77860 case RTTEST_RESET:
77861 @@ -75,7 +75,7 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
77862 return 0;
77863
77864 case RTTEST_RESETEVENT:
77865 - atomic_set(&rttest_event, 0);
77866 + atomic_set_unchecked(&rttest_event, 0);
77867 return 0;
77868
77869 default:
77870 @@ -92,9 +92,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
77871 return ret;
77872
77873 td->mutexes[id] = 1;
77874 - td->event = atomic_add_return(1, &rttest_event);
77875 + td->event = atomic_add_return_unchecked(1, &rttest_event);
77876 rt_mutex_lock(&mutexes[id]);
77877 - td->event = atomic_add_return(1, &rttest_event);
77878 + td->event = atomic_add_return_unchecked(1, &rttest_event);
77879 td->mutexes[id] = 4;
77880 return 0;
77881
77882 @@ -105,9 +105,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
77883 return ret;
77884
77885 td->mutexes[id] = 1;
77886 - td->event = atomic_add_return(1, &rttest_event);
77887 + td->event = atomic_add_return_unchecked(1, &rttest_event);
77888 ret = rt_mutex_lock_interruptible(&mutexes[id], 0);
77889 - td->event = atomic_add_return(1, &rttest_event);
77890 + td->event = atomic_add_return_unchecked(1, &rttest_event);
77891 td->mutexes[id] = ret ? 0 : 4;
77892 return ret ? -EINTR : 0;
77893
77894 @@ -116,9 +116,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
77895 if (id < 0 || id >= MAX_RT_TEST_MUTEXES || td->mutexes[id] != 4)
77896 return ret;
77897
77898 - td->event = atomic_add_return(1, &rttest_event);
77899 + td->event = atomic_add_return_unchecked(1, &rttest_event);
77900 rt_mutex_unlock(&mutexes[id]);
77901 - td->event = atomic_add_return(1, &rttest_event);
77902 + td->event = atomic_add_return_unchecked(1, &rttest_event);
77903 td->mutexes[id] = 0;
77904 return 0;
77905
77906 @@ -165,7 +165,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
77907 break;
77908
77909 td->mutexes[dat] = 2;
77910 - td->event = atomic_add_return(1, &rttest_event);
77911 + td->event = atomic_add_return_unchecked(1, &rttest_event);
77912 break;
77913
77914 default:
77915 @@ -185,7 +185,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
77916 return;
77917
77918 td->mutexes[dat] = 3;
77919 - td->event = atomic_add_return(1, &rttest_event);
77920 + td->event = atomic_add_return_unchecked(1, &rttest_event);
77921 break;
77922
77923 case RTTEST_LOCKNOWAIT:
77924 @@ -197,7 +197,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
77925 return;
77926
77927 td->mutexes[dat] = 1;
77928 - td->event = atomic_add_return(1, &rttest_event);
77929 + td->event = atomic_add_return_unchecked(1, &rttest_event);
77930 return;
77931
77932 default:
77933 diff --git a/kernel/sched/auto_group.c b/kernel/sched/auto_group.c
77934 index 64de5f8..7735e12 100644
77935 --- a/kernel/sched/auto_group.c
77936 +++ b/kernel/sched/auto_group.c
77937 @@ -11,7 +11,7 @@
77938
77939 unsigned int __read_mostly sysctl_sched_autogroup_enabled = 1;
77940 static struct autogroup autogroup_default;
77941 -static atomic_t autogroup_seq_nr;
77942 +static atomic_unchecked_t autogroup_seq_nr;
77943
77944 void __init autogroup_init(struct task_struct *init_task)
77945 {
77946 @@ -81,7 +81,7 @@ static inline struct autogroup *autogroup_create(void)
77947
77948 kref_init(&ag->kref);
77949 init_rwsem(&ag->lock);
77950 - ag->id = atomic_inc_return(&autogroup_seq_nr);
77951 + ag->id = atomic_inc_return_unchecked(&autogroup_seq_nr);
77952 ag->tg = tg;
77953 #ifdef CONFIG_RT_GROUP_SCHED
77954 /*
77955 diff --git a/kernel/sched/core.c b/kernel/sched/core.c
77956 index 67d0465..4cf9361 100644
77957 --- a/kernel/sched/core.c
77958 +++ b/kernel/sched/core.c
77959 @@ -3406,7 +3406,7 @@ EXPORT_SYMBOL(wait_for_completion_interruptible);
77960 * The return value is -ERESTARTSYS if interrupted, 0 if timed out,
77961 * positive (at least 1, or number of jiffies left till timeout) if completed.
77962 */
77963 -long __sched
77964 +long __sched __intentional_overflow(-1)
77965 wait_for_completion_interruptible_timeout(struct completion *x,
77966 unsigned long timeout)
77967 {
77968 @@ -3423,7 +3423,7 @@ EXPORT_SYMBOL(wait_for_completion_interruptible_timeout);
77969 *
77970 * The return value is -ERESTARTSYS if interrupted, 0 if completed.
77971 */
77972 -int __sched wait_for_completion_killable(struct completion *x)
77973 +int __sched __intentional_overflow(-1) wait_for_completion_killable(struct completion *x)
77974 {
77975 long t = wait_for_common(x, MAX_SCHEDULE_TIMEOUT, TASK_KILLABLE);
77976 if (t == -ERESTARTSYS)
77977 @@ -3444,7 +3444,7 @@ EXPORT_SYMBOL(wait_for_completion_killable);
77978 * The return value is -ERESTARTSYS if interrupted, 0 if timed out,
77979 * positive (at least 1, or number of jiffies left till timeout) if completed.
77980 */
77981 -long __sched
77982 +long __sched __intentional_overflow(-1)
77983 wait_for_completion_killable_timeout(struct completion *x,
77984 unsigned long timeout)
77985 {
77986 @@ -3670,6 +3670,8 @@ int can_nice(const struct task_struct *p, const int nice)
77987 /* convert nice value [19,-20] to rlimit style value [1,40] */
77988 int nice_rlim = 20 - nice;
77989
77990 + gr_learn_resource(p, RLIMIT_NICE, nice_rlim, 1);
77991 +
77992 return (nice_rlim <= task_rlimit(p, RLIMIT_NICE) ||
77993 capable(CAP_SYS_NICE));
77994 }
77995 @@ -3703,7 +3705,8 @@ SYSCALL_DEFINE1(nice, int, increment)
77996 if (nice > 19)
77997 nice = 19;
77998
77999 - if (increment < 0 && !can_nice(current, nice))
78000 + if (increment < 0 && (!can_nice(current, nice) ||
78001 + gr_handle_chroot_nice()))
78002 return -EPERM;
78003
78004 retval = security_task_setnice(current, nice);
78005 @@ -3857,6 +3860,7 @@ recheck:
78006 unsigned long rlim_rtprio =
78007 task_rlimit(p, RLIMIT_RTPRIO);
78008
78009 + gr_learn_resource(p, RLIMIT_RTPRIO, param->sched_priority, 1);
78010 /* can't set/change the rt policy */
78011 if (policy != p->policy && !rlim_rtprio)
78012 return -EPERM;
78013 @@ -4954,7 +4958,7 @@ static void migrate_tasks(unsigned int dead_cpu)
78014
78015 #if defined(CONFIG_SCHED_DEBUG) && defined(CONFIG_SYSCTL)
78016
78017 -static struct ctl_table sd_ctl_dir[] = {
78018 +static ctl_table_no_const sd_ctl_dir[] __read_only = {
78019 {
78020 .procname = "sched_domain",
78021 .mode = 0555,
78022 @@ -4971,17 +4975,17 @@ static struct ctl_table sd_ctl_root[] = {
78023 {}
78024 };
78025
78026 -static struct ctl_table *sd_alloc_ctl_entry(int n)
78027 +static ctl_table_no_const *sd_alloc_ctl_entry(int n)
78028 {
78029 - struct ctl_table *entry =
78030 + ctl_table_no_const *entry =
78031 kcalloc(n, sizeof(struct ctl_table), GFP_KERNEL);
78032
78033 return entry;
78034 }
78035
78036 -static void sd_free_ctl_entry(struct ctl_table **tablep)
78037 +static void sd_free_ctl_entry(ctl_table_no_const *tablep)
78038 {
78039 - struct ctl_table *entry;
78040 + ctl_table_no_const *entry;
78041
78042 /*
78043 * In the intermediate directories, both the child directory and
78044 @@ -4989,22 +4993,25 @@ static void sd_free_ctl_entry(struct ctl_table **tablep)
78045 * will always be set. In the lowest directory the names are
78046 * static strings and all have proc handlers.
78047 */
78048 - for (entry = *tablep; entry->mode; entry++) {
78049 - if (entry->child)
78050 - sd_free_ctl_entry(&entry->child);
78051 + for (entry = tablep; entry->mode; entry++) {
78052 + if (entry->child) {
78053 + sd_free_ctl_entry(entry->child);
78054 + pax_open_kernel();
78055 + entry->child = NULL;
78056 + pax_close_kernel();
78057 + }
78058 if (entry->proc_handler == NULL)
78059 kfree(entry->procname);
78060 }
78061
78062 - kfree(*tablep);
78063 - *tablep = NULL;
78064 + kfree(tablep);
78065 }
78066
78067 static int min_load_idx = 0;
78068 static int max_load_idx = CPU_LOAD_IDX_MAX-1;
78069
78070 static void
78071 -set_table_entry(struct ctl_table *entry,
78072 +set_table_entry(ctl_table_no_const *entry,
78073 const char *procname, void *data, int maxlen,
78074 umode_t mode, proc_handler *proc_handler,
78075 bool load_idx)
78076 @@ -5024,7 +5031,7 @@ set_table_entry(struct ctl_table *entry,
78077 static struct ctl_table *
78078 sd_alloc_ctl_domain_table(struct sched_domain *sd)
78079 {
78080 - struct ctl_table *table = sd_alloc_ctl_entry(13);
78081 + ctl_table_no_const *table = sd_alloc_ctl_entry(13);
78082
78083 if (table == NULL)
78084 return NULL;
78085 @@ -5059,9 +5066,9 @@ sd_alloc_ctl_domain_table(struct sched_domain *sd)
78086 return table;
78087 }
78088
78089 -static ctl_table *sd_alloc_ctl_cpu_table(int cpu)
78090 +static ctl_table_no_const *sd_alloc_ctl_cpu_table(int cpu)
78091 {
78092 - struct ctl_table *entry, *table;
78093 + ctl_table_no_const *entry, *table;
78094 struct sched_domain *sd;
78095 int domain_num = 0, i;
78096 char buf[32];
78097 @@ -5088,11 +5095,13 @@ static struct ctl_table_header *sd_sysctl_header;
78098 static void register_sched_domain_sysctl(void)
78099 {
78100 int i, cpu_num = num_possible_cpus();
78101 - struct ctl_table *entry = sd_alloc_ctl_entry(cpu_num + 1);
78102 + ctl_table_no_const *entry = sd_alloc_ctl_entry(cpu_num + 1);
78103 char buf[32];
78104
78105 WARN_ON(sd_ctl_dir[0].child);
78106 + pax_open_kernel();
78107 sd_ctl_dir[0].child = entry;
78108 + pax_close_kernel();
78109
78110 if (entry == NULL)
78111 return;
78112 @@ -5115,8 +5124,12 @@ static void unregister_sched_domain_sysctl(void)
78113 if (sd_sysctl_header)
78114 unregister_sysctl_table(sd_sysctl_header);
78115 sd_sysctl_header = NULL;
78116 - if (sd_ctl_dir[0].child)
78117 - sd_free_ctl_entry(&sd_ctl_dir[0].child);
78118 + if (sd_ctl_dir[0].child) {
78119 + sd_free_ctl_entry(sd_ctl_dir[0].child);
78120 + pax_open_kernel();
78121 + sd_ctl_dir[0].child = NULL;
78122 + pax_close_kernel();
78123 + }
78124 }
78125 #else
78126 static void register_sched_domain_sysctl(void)
78127 @@ -5215,7 +5228,7 @@ migration_call(struct notifier_block *nfb, unsigned long action, void *hcpu)
78128 * happens before everything else. This has to be lower priority than
78129 * the notifier in the perf_event subsystem, though.
78130 */
78131 -static struct notifier_block __cpuinitdata migration_notifier = {
78132 +static struct notifier_block migration_notifier = {
78133 .notifier_call = migration_call,
78134 .priority = CPU_PRI_MIGRATION,
78135 };
78136 diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
78137 index 7a33e59..2f7730c 100644
78138 --- a/kernel/sched/fair.c
78139 +++ b/kernel/sched/fair.c
78140 @@ -830,7 +830,7 @@ void task_numa_fault(int node, int pages, bool migrated)
78141
78142 static void reset_ptenuma_scan(struct task_struct *p)
78143 {
78144 - ACCESS_ONCE(p->mm->numa_scan_seq)++;
78145 + ACCESS_ONCE_RW(p->mm->numa_scan_seq)++;
78146 p->mm->numa_scan_offset = 0;
78147 }
78148
78149 @@ -5654,7 +5654,7 @@ static void nohz_idle_balance(int this_cpu, enum cpu_idle_type idle) { }
78150 * run_rebalance_domains is triggered when needed from the scheduler tick.
78151 * Also triggered for nohz idle balancing (with nohz_balancing_kick set).
78152 */
78153 -static void run_rebalance_domains(struct softirq_action *h)
78154 +static void run_rebalance_domains(void)
78155 {
78156 int this_cpu = smp_processor_id();
78157 struct rq *this_rq = cpu_rq(this_cpu);
78158 diff --git a/kernel/signal.c b/kernel/signal.c
78159 index 598dc06..471310a 100644
78160 --- a/kernel/signal.c
78161 +++ b/kernel/signal.c
78162 @@ -50,12 +50,12 @@ static struct kmem_cache *sigqueue_cachep;
78163
78164 int print_fatal_signals __read_mostly;
78165
78166 -static void __user *sig_handler(struct task_struct *t, int sig)
78167 +static __sighandler_t sig_handler(struct task_struct *t, int sig)
78168 {
78169 return t->sighand->action[sig - 1].sa.sa_handler;
78170 }
78171
78172 -static int sig_handler_ignored(void __user *handler, int sig)
78173 +static int sig_handler_ignored(__sighandler_t handler, int sig)
78174 {
78175 /* Is it explicitly or implicitly ignored? */
78176 return handler == SIG_IGN ||
78177 @@ -64,7 +64,7 @@ static int sig_handler_ignored(void __user *handler, int sig)
78178
78179 static int sig_task_ignored(struct task_struct *t, int sig, bool force)
78180 {
78181 - void __user *handler;
78182 + __sighandler_t handler;
78183
78184 handler = sig_handler(t, sig);
78185
78186 @@ -368,6 +368,9 @@ __sigqueue_alloc(int sig, struct task_struct *t, gfp_t flags, int override_rlimi
78187 atomic_inc(&user->sigpending);
78188 rcu_read_unlock();
78189
78190 + if (!override_rlimit)
78191 + gr_learn_resource(t, RLIMIT_SIGPENDING, atomic_read(&user->sigpending), 1);
78192 +
78193 if (override_rlimit ||
78194 atomic_read(&user->sigpending) <=
78195 task_rlimit(t, RLIMIT_SIGPENDING)) {
78196 @@ -495,7 +498,7 @@ flush_signal_handlers(struct task_struct *t, int force_default)
78197
78198 int unhandled_signal(struct task_struct *tsk, int sig)
78199 {
78200 - void __user *handler = tsk->sighand->action[sig-1].sa.sa_handler;
78201 + __sighandler_t handler = tsk->sighand->action[sig-1].sa.sa_handler;
78202 if (is_global_init(tsk))
78203 return 1;
78204 if (handler != SIG_IGN && handler != SIG_DFL)
78205 @@ -815,6 +818,13 @@ static int check_kill_permission(int sig, struct siginfo *info,
78206 }
78207 }
78208
78209 + /* allow glibc communication via tgkill to other threads in our
78210 + thread group */
78211 + if ((info == SEND_SIG_NOINFO || info->si_code != SI_TKILL ||
78212 + sig != (SIGRTMIN+1) || task_tgid_vnr(t) != info->si_pid)
78213 + && gr_handle_signal(t, sig))
78214 + return -EPERM;
78215 +
78216 return security_task_kill(t, info, sig, 0);
78217 }
78218
78219 @@ -1197,7 +1207,7 @@ __group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
78220 return send_signal(sig, info, p, 1);
78221 }
78222
78223 -static int
78224 +int
78225 specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t)
78226 {
78227 return send_signal(sig, info, t, 0);
78228 @@ -1234,6 +1244,7 @@ force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
78229 unsigned long int flags;
78230 int ret, blocked, ignored;
78231 struct k_sigaction *action;
78232 + int is_unhandled = 0;
78233
78234 spin_lock_irqsave(&t->sighand->siglock, flags);
78235 action = &t->sighand->action[sig-1];
78236 @@ -1248,9 +1259,18 @@ force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
78237 }
78238 if (action->sa.sa_handler == SIG_DFL)
78239 t->signal->flags &= ~SIGNAL_UNKILLABLE;
78240 + if (action->sa.sa_handler == SIG_IGN || action->sa.sa_handler == SIG_DFL)
78241 + is_unhandled = 1;
78242 ret = specific_send_sig_info(sig, info, t);
78243 spin_unlock_irqrestore(&t->sighand->siglock, flags);
78244
78245 + /* only deal with unhandled signals, java etc trigger SIGSEGV during
78246 + normal operation */
78247 + if (is_unhandled) {
78248 + gr_log_signal(sig, !is_si_special(info) ? info->si_addr : NULL, t);
78249 + gr_handle_crash(t, sig);
78250 + }
78251 +
78252 return ret;
78253 }
78254
78255 @@ -1317,8 +1337,11 @@ int group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
78256 ret = check_kill_permission(sig, info, p);
78257 rcu_read_unlock();
78258
78259 - if (!ret && sig)
78260 + if (!ret && sig) {
78261 ret = do_send_sig_info(sig, info, p, true);
78262 + if (!ret)
78263 + gr_log_signal(sig, !is_si_special(info) ? info->si_addr : NULL, p);
78264 + }
78265
78266 return ret;
78267 }
78268 @@ -2923,7 +2946,15 @@ do_send_specific(pid_t tgid, pid_t pid, int sig, struct siginfo *info)
78269 int error = -ESRCH;
78270
78271 rcu_read_lock();
78272 - p = find_task_by_vpid(pid);
78273 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
78274 + /* allow glibc communication via tgkill to other threads in our
78275 + thread group */
78276 + if (grsec_enable_chroot_findtask && info->si_code == SI_TKILL &&
78277 + sig == (SIGRTMIN+1) && tgid == info->si_pid)
78278 + p = find_task_by_vpid_unrestricted(pid);
78279 + else
78280 +#endif
78281 + p = find_task_by_vpid(pid);
78282 if (p && (tgid <= 0 || task_tgid_vnr(p) == tgid)) {
78283 error = check_kill_permission(sig, info, p);
78284 /*
78285 @@ -3237,8 +3268,8 @@ COMPAT_SYSCALL_DEFINE2(sigaltstack,
78286 }
78287 seg = get_fs();
78288 set_fs(KERNEL_DS);
78289 - ret = do_sigaltstack((stack_t __force __user *) (uss_ptr ? &uss : NULL),
78290 - (stack_t __force __user *) &uoss,
78291 + ret = do_sigaltstack((stack_t __force_user *) (uss_ptr ? &uss : NULL),
78292 + (stack_t __force_user *) &uoss,
78293 compat_user_stack_pointer());
78294 set_fs(seg);
78295 if (ret >= 0 && uoss_ptr) {
78296 diff --git a/kernel/smp.c b/kernel/smp.c
78297 index 8e451f3..8322029 100644
78298 --- a/kernel/smp.c
78299 +++ b/kernel/smp.c
78300 @@ -73,7 +73,7 @@ hotplug_cfd(struct notifier_block *nfb, unsigned long action, void *hcpu)
78301 return NOTIFY_OK;
78302 }
78303
78304 -static struct notifier_block __cpuinitdata hotplug_cfd_notifier = {
78305 +static struct notifier_block hotplug_cfd_notifier = {
78306 .notifier_call = hotplug_cfd,
78307 };
78308
78309 diff --git a/kernel/smpboot.c b/kernel/smpboot.c
78310 index 02fc5c9..e54c335 100644
78311 --- a/kernel/smpboot.c
78312 +++ b/kernel/smpboot.c
78313 @@ -288,7 +288,7 @@ int smpboot_register_percpu_thread(struct smp_hotplug_thread *plug_thread)
78314 }
78315 smpboot_unpark_thread(plug_thread, cpu);
78316 }
78317 - list_add(&plug_thread->list, &hotplug_threads);
78318 + pax_list_add(&plug_thread->list, &hotplug_threads);
78319 out:
78320 mutex_unlock(&smpboot_threads_lock);
78321 return ret;
78322 @@ -305,7 +305,7 @@ void smpboot_unregister_percpu_thread(struct smp_hotplug_thread *plug_thread)
78323 {
78324 get_online_cpus();
78325 mutex_lock(&smpboot_threads_lock);
78326 - list_del(&plug_thread->list);
78327 + pax_list_del(&plug_thread->list);
78328 smpboot_destroy_threads(plug_thread);
78329 mutex_unlock(&smpboot_threads_lock);
78330 put_online_cpus();
78331 diff --git a/kernel/softirq.c b/kernel/softirq.c
78332 index 14d7758..012121f 100644
78333 --- a/kernel/softirq.c
78334 +++ b/kernel/softirq.c
78335 @@ -53,11 +53,11 @@ irq_cpustat_t irq_stat[NR_CPUS] ____cacheline_aligned;
78336 EXPORT_SYMBOL(irq_stat);
78337 #endif
78338
78339 -static struct softirq_action softirq_vec[NR_SOFTIRQS] __cacheline_aligned_in_smp;
78340 +static struct softirq_action softirq_vec[NR_SOFTIRQS] __read_only __aligned(PAGE_SIZE);
78341
78342 DEFINE_PER_CPU(struct task_struct *, ksoftirqd);
78343
78344 -char *softirq_to_name[NR_SOFTIRQS] = {
78345 +const char * const softirq_to_name[NR_SOFTIRQS] = {
78346 "HI", "TIMER", "NET_TX", "NET_RX", "BLOCK", "BLOCK_IOPOLL",
78347 "TASKLET", "SCHED", "HRTIMER", "RCU"
78348 };
78349 @@ -244,7 +244,7 @@ restart:
78350 kstat_incr_softirqs_this_cpu(vec_nr);
78351
78352 trace_softirq_entry(vec_nr);
78353 - h->action(h);
78354 + h->action();
78355 trace_softirq_exit(vec_nr);
78356 if (unlikely(prev_count != preempt_count())) {
78357 printk(KERN_ERR "huh, entered softirq %u %s %p"
78358 @@ -389,7 +389,7 @@ void __raise_softirq_irqoff(unsigned int nr)
78359 or_softirq_pending(1UL << nr);
78360 }
78361
78362 -void open_softirq(int nr, void (*action)(struct softirq_action *))
78363 +void __init open_softirq(int nr, void (*action)(void))
78364 {
78365 softirq_vec[nr].action = action;
78366 }
78367 @@ -445,7 +445,7 @@ void __tasklet_hi_schedule_first(struct tasklet_struct *t)
78368
78369 EXPORT_SYMBOL(__tasklet_hi_schedule_first);
78370
78371 -static void tasklet_action(struct softirq_action *a)
78372 +static void tasklet_action(void)
78373 {
78374 struct tasklet_struct *list;
78375
78376 @@ -480,7 +480,7 @@ static void tasklet_action(struct softirq_action *a)
78377 }
78378 }
78379
78380 -static void tasklet_hi_action(struct softirq_action *a)
78381 +static void tasklet_hi_action(void)
78382 {
78383 struct tasklet_struct *list;
78384
78385 @@ -716,7 +716,7 @@ static int __cpuinit remote_softirq_cpu_notify(struct notifier_block *self,
78386 return NOTIFY_OK;
78387 }
78388
78389 -static struct notifier_block __cpuinitdata remote_softirq_cpu_notifier = {
78390 +static struct notifier_block remote_softirq_cpu_notifier = {
78391 .notifier_call = remote_softirq_cpu_notify,
78392 };
78393
78394 @@ -833,11 +833,11 @@ static int __cpuinit cpu_callback(struct notifier_block *nfb,
78395 return NOTIFY_OK;
78396 }
78397
78398 -static struct notifier_block __cpuinitdata cpu_nfb = {
78399 +static struct notifier_block cpu_nfb = {
78400 .notifier_call = cpu_callback
78401 };
78402
78403 -static struct smp_hotplug_thread softirq_threads = {
78404 +static struct smp_hotplug_thread softirq_threads __read_only = {
78405 .store = &ksoftirqd,
78406 .thread_should_run = ksoftirqd_should_run,
78407 .thread_fn = run_ksoftirqd,
78408 diff --git a/kernel/srcu.c b/kernel/srcu.c
78409 index 01d5ccb..cdcbee6 100644
78410 --- a/kernel/srcu.c
78411 +++ b/kernel/srcu.c
78412 @@ -300,9 +300,9 @@ int __srcu_read_lock(struct srcu_struct *sp)
78413
78414 idx = ACCESS_ONCE(sp->completed) & 0x1;
78415 preempt_disable();
78416 - ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) += 1;
78417 + ACCESS_ONCE_RW(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) += 1;
78418 smp_mb(); /* B */ /* Avoid leaking the critical section. */
78419 - ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->seq[idx]) += 1;
78420 + ACCESS_ONCE_RW(this_cpu_ptr(sp->per_cpu_ref)->seq[idx]) += 1;
78421 preempt_enable();
78422 return idx;
78423 }
78424 diff --git a/kernel/sys.c b/kernel/sys.c
78425 index 0da73cf..5c2af3c 100644
78426 --- a/kernel/sys.c
78427 +++ b/kernel/sys.c
78428 @@ -158,6 +158,12 @@ static int set_one_prio(struct task_struct *p, int niceval, int error)
78429 error = -EACCES;
78430 goto out;
78431 }
78432 +
78433 + if (gr_handle_chroot_setpriority(p, niceval)) {
78434 + error = -EACCES;
78435 + goto out;
78436 + }
78437 +
78438 no_nice = security_task_setnice(p, niceval);
78439 if (no_nice) {
78440 error = no_nice;
78441 @@ -598,6 +604,9 @@ SYSCALL_DEFINE2(setregid, gid_t, rgid, gid_t, egid)
78442 goto error;
78443 }
78444
78445 + if (gr_check_group_change(new->gid, new->egid, INVALID_GID))
78446 + goto error;
78447 +
78448 if (rgid != (gid_t) -1 ||
78449 (egid != (gid_t) -1 && !gid_eq(kegid, old->gid)))
78450 new->sgid = new->egid;
78451 @@ -633,6 +642,10 @@ SYSCALL_DEFINE1(setgid, gid_t, gid)
78452 old = current_cred();
78453
78454 retval = -EPERM;
78455 +
78456 + if (gr_check_group_change(kgid, kgid, kgid))
78457 + goto error;
78458 +
78459 if (nsown_capable(CAP_SETGID))
78460 new->gid = new->egid = new->sgid = new->fsgid = kgid;
78461 else if (gid_eq(kgid, old->gid) || gid_eq(kgid, old->sgid))
78462 @@ -650,7 +663,7 @@ error:
78463 /*
78464 * change the user struct in a credentials set to match the new UID
78465 */
78466 -static int set_user(struct cred *new)
78467 +int set_user(struct cred *new)
78468 {
78469 struct user_struct *new_user;
78470
78471 @@ -730,6 +743,9 @@ SYSCALL_DEFINE2(setreuid, uid_t, ruid, uid_t, euid)
78472 goto error;
78473 }
78474
78475 + if (gr_check_user_change(new->uid, new->euid, INVALID_UID))
78476 + goto error;
78477 +
78478 if (!uid_eq(new->uid, old->uid)) {
78479 retval = set_user(new);
78480 if (retval < 0)
78481 @@ -780,6 +796,12 @@ SYSCALL_DEFINE1(setuid, uid_t, uid)
78482 old = current_cred();
78483
78484 retval = -EPERM;
78485 +
78486 + if (gr_check_crash_uid(kuid))
78487 + goto error;
78488 + if (gr_check_user_change(kuid, kuid, kuid))
78489 + goto error;
78490 +
78491 if (nsown_capable(CAP_SETUID)) {
78492 new->suid = new->uid = kuid;
78493 if (!uid_eq(kuid, old->uid)) {
78494 @@ -849,6 +871,9 @@ SYSCALL_DEFINE3(setresuid, uid_t, ruid, uid_t, euid, uid_t, suid)
78495 goto error;
78496 }
78497
78498 + if (gr_check_user_change(kruid, keuid, INVALID_UID))
78499 + goto error;
78500 +
78501 if (ruid != (uid_t) -1) {
78502 new->uid = kruid;
78503 if (!uid_eq(kruid, old->uid)) {
78504 @@ -931,6 +956,9 @@ SYSCALL_DEFINE3(setresgid, gid_t, rgid, gid_t, egid, gid_t, sgid)
78505 goto error;
78506 }
78507
78508 + if (gr_check_group_change(krgid, kegid, INVALID_GID))
78509 + goto error;
78510 +
78511 if (rgid != (gid_t) -1)
78512 new->gid = krgid;
78513 if (egid != (gid_t) -1)
78514 @@ -992,12 +1020,16 @@ SYSCALL_DEFINE1(setfsuid, uid_t, uid)
78515 uid_eq(kuid, old->suid) || uid_eq(kuid, old->fsuid) ||
78516 nsown_capable(CAP_SETUID)) {
78517 if (!uid_eq(kuid, old->fsuid)) {
78518 + if (gr_check_user_change(INVALID_UID, INVALID_UID, kuid))
78519 + goto error;
78520 +
78521 new->fsuid = kuid;
78522 if (security_task_fix_setuid(new, old, LSM_SETID_FS) == 0)
78523 goto change_okay;
78524 }
78525 }
78526
78527 +error:
78528 abort_creds(new);
78529 return old_fsuid;
78530
78531 @@ -1030,12 +1062,16 @@ SYSCALL_DEFINE1(setfsgid, gid_t, gid)
78532 if (gid_eq(kgid, old->gid) || gid_eq(kgid, old->egid) ||
78533 gid_eq(kgid, old->sgid) || gid_eq(kgid, old->fsgid) ||
78534 nsown_capable(CAP_SETGID)) {
78535 + if (gr_check_group_change(INVALID_GID, INVALID_GID, kgid))
78536 + goto error;
78537 +
78538 if (!gid_eq(kgid, old->fsgid)) {
78539 new->fsgid = kgid;
78540 goto change_okay;
78541 }
78542 }
78543
78544 +error:
78545 abort_creds(new);
78546 return old_fsgid;
78547
78548 @@ -1343,19 +1379,19 @@ SYSCALL_DEFINE1(olduname, struct oldold_utsname __user *, name)
78549 return -EFAULT;
78550
78551 down_read(&uts_sem);
78552 - error = __copy_to_user(&name->sysname, &utsname()->sysname,
78553 + error = __copy_to_user(name->sysname, &utsname()->sysname,
78554 __OLD_UTS_LEN);
78555 error |= __put_user(0, name->sysname + __OLD_UTS_LEN);
78556 - error |= __copy_to_user(&name->nodename, &utsname()->nodename,
78557 + error |= __copy_to_user(name->nodename, &utsname()->nodename,
78558 __OLD_UTS_LEN);
78559 error |= __put_user(0, name->nodename + __OLD_UTS_LEN);
78560 - error |= __copy_to_user(&name->release, &utsname()->release,
78561 + error |= __copy_to_user(name->release, &utsname()->release,
78562 __OLD_UTS_LEN);
78563 error |= __put_user(0, name->release + __OLD_UTS_LEN);
78564 - error |= __copy_to_user(&name->version, &utsname()->version,
78565 + error |= __copy_to_user(name->version, &utsname()->version,
78566 __OLD_UTS_LEN);
78567 error |= __put_user(0, name->version + __OLD_UTS_LEN);
78568 - error |= __copy_to_user(&name->machine, &utsname()->machine,
78569 + error |= __copy_to_user(name->machine, &utsname()->machine,
78570 __OLD_UTS_LEN);
78571 error |= __put_user(0, name->machine + __OLD_UTS_LEN);
78572 up_read(&uts_sem);
78573 @@ -1557,6 +1593,13 @@ int do_prlimit(struct task_struct *tsk, unsigned int resource,
78574 */
78575 new_rlim->rlim_cur = 1;
78576 }
78577 + /* Handle the case where a fork and setuid occur and then RLIMIT_NPROC
78578 + is changed to a lower value. Since tasks can be created by the same
78579 + user in between this limit change and an execve by this task, force
78580 + a recheck only for this task by setting PF_NPROC_EXCEEDED
78581 + */
78582 + if (resource == RLIMIT_NPROC && tsk->real_cred->user != INIT_USER)
78583 + tsk->flags |= PF_NPROC_EXCEEDED;
78584 }
78585 if (!retval) {
78586 if (old_rlim)
78587 diff --git a/kernel/sysctl.c b/kernel/sysctl.c
78588 index afc1dc6..5e28bbf 100644
78589 --- a/kernel/sysctl.c
78590 +++ b/kernel/sysctl.c
78591 @@ -93,7 +93,6 @@
78592
78593
78594 #if defined(CONFIG_SYSCTL)
78595 -
78596 /* External variables not in a header file. */
78597 extern int sysctl_overcommit_memory;
78598 extern int sysctl_overcommit_ratio;
78599 @@ -178,10 +177,8 @@ static int proc_taint(struct ctl_table *table, int write,
78600 void __user *buffer, size_t *lenp, loff_t *ppos);
78601 #endif
78602
78603 -#ifdef CONFIG_PRINTK
78604 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
78605 void __user *buffer, size_t *lenp, loff_t *ppos);
78606 -#endif
78607
78608 static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
78609 void __user *buffer, size_t *lenp, loff_t *ppos);
78610 @@ -212,6 +209,8 @@ static int sysrq_sysctl_handler(ctl_table *table, int write,
78611
78612 #endif
78613
78614 +extern struct ctl_table grsecurity_table[];
78615 +
78616 static struct ctl_table kern_table[];
78617 static struct ctl_table vm_table[];
78618 static struct ctl_table fs_table[];
78619 @@ -226,6 +225,20 @@ extern struct ctl_table epoll_table[];
78620 int sysctl_legacy_va_layout;
78621 #endif
78622
78623 +#ifdef CONFIG_PAX_SOFTMODE
78624 +static ctl_table pax_table[] = {
78625 + {
78626 + .procname = "softmode",
78627 + .data = &pax_softmode,
78628 + .maxlen = sizeof(unsigned int),
78629 + .mode = 0600,
78630 + .proc_handler = &proc_dointvec,
78631 + },
78632 +
78633 + { }
78634 +};
78635 +#endif
78636 +
78637 /* The default sysctl tables: */
78638
78639 static struct ctl_table sysctl_base_table[] = {
78640 @@ -274,6 +287,22 @@ static int max_extfrag_threshold = 1000;
78641 #endif
78642
78643 static struct ctl_table kern_table[] = {
78644 +#if defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_ROFS)
78645 + {
78646 + .procname = "grsecurity",
78647 + .mode = 0500,
78648 + .child = grsecurity_table,
78649 + },
78650 +#endif
78651 +
78652 +#ifdef CONFIG_PAX_SOFTMODE
78653 + {
78654 + .procname = "pax",
78655 + .mode = 0500,
78656 + .child = pax_table,
78657 + },
78658 +#endif
78659 +
78660 {
78661 .procname = "sched_child_runs_first",
78662 .data = &sysctl_sched_child_runs_first,
78663 @@ -608,7 +637,7 @@ static struct ctl_table kern_table[] = {
78664 .data = &modprobe_path,
78665 .maxlen = KMOD_PATH_LEN,
78666 .mode = 0644,
78667 - .proc_handler = proc_dostring,
78668 + .proc_handler = proc_dostring_modpriv,
78669 },
78670 {
78671 .procname = "modules_disabled",
78672 @@ -775,16 +804,20 @@ static struct ctl_table kern_table[] = {
78673 .extra1 = &zero,
78674 .extra2 = &one,
78675 },
78676 +#endif
78677 {
78678 .procname = "kptr_restrict",
78679 .data = &kptr_restrict,
78680 .maxlen = sizeof(int),
78681 .mode = 0644,
78682 .proc_handler = proc_dointvec_minmax_sysadmin,
78683 +#ifdef CONFIG_GRKERNSEC_HIDESYM
78684 + .extra1 = &two,
78685 +#else
78686 .extra1 = &zero,
78687 +#endif
78688 .extra2 = &two,
78689 },
78690 -#endif
78691 {
78692 .procname = "ngroups_max",
78693 .data = &ngroups_max,
78694 @@ -1026,8 +1059,8 @@ static struct ctl_table kern_table[] = {
78695 */
78696 {
78697 .procname = "perf_event_paranoid",
78698 - .data = &sysctl_perf_event_paranoid,
78699 - .maxlen = sizeof(sysctl_perf_event_paranoid),
78700 + .data = &sysctl_perf_event_legitimately_concerned,
78701 + .maxlen = sizeof(sysctl_perf_event_legitimately_concerned),
78702 .mode = 0644,
78703 .proc_handler = proc_dointvec,
78704 },
78705 @@ -1283,6 +1316,13 @@ static struct ctl_table vm_table[] = {
78706 .proc_handler = proc_dointvec_minmax,
78707 .extra1 = &zero,
78708 },
78709 + {
78710 + .procname = "heap_stack_gap",
78711 + .data = &sysctl_heap_stack_gap,
78712 + .maxlen = sizeof(sysctl_heap_stack_gap),
78713 + .mode = 0644,
78714 + .proc_handler = proc_doulongvec_minmax,
78715 + },
78716 #else
78717 {
78718 .procname = "nr_trim_pages",
78719 @@ -1733,6 +1773,16 @@ int proc_dostring(struct ctl_table *table, int write,
78720 buffer, lenp, ppos);
78721 }
78722
78723 +int proc_dostring_modpriv(struct ctl_table *table, int write,
78724 + void __user *buffer, size_t *lenp, loff_t *ppos)
78725 +{
78726 + if (write && !capable(CAP_SYS_MODULE))
78727 + return -EPERM;
78728 +
78729 + return _proc_do_string(table->data, table->maxlen, write,
78730 + buffer, lenp, ppos);
78731 +}
78732 +
78733 static size_t proc_skip_spaces(char **buf)
78734 {
78735 size_t ret;
78736 @@ -1838,6 +1888,8 @@ static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
78737 len = strlen(tmp);
78738 if (len > *size)
78739 len = *size;
78740 + if (len > sizeof(tmp))
78741 + len = sizeof(tmp);
78742 if (copy_to_user(*buf, tmp, len))
78743 return -EFAULT;
78744 *size -= len;
78745 @@ -2002,7 +2054,7 @@ int proc_dointvec(struct ctl_table *table, int write,
78746 static int proc_taint(struct ctl_table *table, int write,
78747 void __user *buffer, size_t *lenp, loff_t *ppos)
78748 {
78749 - struct ctl_table t;
78750 + ctl_table_no_const t;
78751 unsigned long tmptaint = get_taint();
78752 int err;
78753
78754 @@ -2030,7 +2082,6 @@ static int proc_taint(struct ctl_table *table, int write,
78755 return err;
78756 }
78757
78758 -#ifdef CONFIG_PRINTK
78759 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
78760 void __user *buffer, size_t *lenp, loff_t *ppos)
78761 {
78762 @@ -2039,7 +2090,6 @@ static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
78763
78764 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
78765 }
78766 -#endif
78767
78768 struct do_proc_dointvec_minmax_conv_param {
78769 int *min;
78770 @@ -2186,8 +2236,11 @@ static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int
78771 *i = val;
78772 } else {
78773 val = convdiv * (*i) / convmul;
78774 - if (!first)
78775 + if (!first) {
78776 err = proc_put_char(&buffer, &left, '\t');
78777 + if (err)
78778 + break;
78779 + }
78780 err = proc_put_long(&buffer, &left, val, false);
78781 if (err)
78782 break;
78783 @@ -2579,6 +2632,12 @@ int proc_dostring(struct ctl_table *table, int write,
78784 return -ENOSYS;
78785 }
78786
78787 +int proc_dostring_modpriv(struct ctl_table *table, int write,
78788 + void __user *buffer, size_t *lenp, loff_t *ppos)
78789 +{
78790 + return -ENOSYS;
78791 +}
78792 +
78793 int proc_dointvec(struct ctl_table *table, int write,
78794 void __user *buffer, size_t *lenp, loff_t *ppos)
78795 {
78796 @@ -2635,5 +2694,6 @@ EXPORT_SYMBOL(proc_dointvec_minmax);
78797 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
78798 EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
78799 EXPORT_SYMBOL(proc_dostring);
78800 +EXPORT_SYMBOL(proc_dostring_modpriv);
78801 EXPORT_SYMBOL(proc_doulongvec_minmax);
78802 EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
78803 diff --git a/kernel/taskstats.c b/kernel/taskstats.c
78804 index 145bb4d..b2aa969 100644
78805 --- a/kernel/taskstats.c
78806 +++ b/kernel/taskstats.c
78807 @@ -28,9 +28,12 @@
78808 #include <linux/fs.h>
78809 #include <linux/file.h>
78810 #include <linux/pid_namespace.h>
78811 +#include <linux/grsecurity.h>
78812 #include <net/genetlink.h>
78813 #include <linux/atomic.h>
78814
78815 +extern int gr_is_taskstats_denied(int pid);
78816 +
78817 /*
78818 * Maximum length of a cpumask that can be specified in
78819 * the TASKSTATS_CMD_ATTR_REGISTER/DEREGISTER_CPUMASK attribute
78820 @@ -570,6 +573,9 @@ err:
78821
78822 static int taskstats_user_cmd(struct sk_buff *skb, struct genl_info *info)
78823 {
78824 + if (gr_is_taskstats_denied(current->pid))
78825 + return -EACCES;
78826 +
78827 if (info->attrs[TASKSTATS_CMD_ATTR_REGISTER_CPUMASK])
78828 return cmd_attr_register_cpumask(info);
78829 else if (info->attrs[TASKSTATS_CMD_ATTR_DEREGISTER_CPUMASK])
78830 diff --git a/kernel/time.c b/kernel/time.c
78831 index f8342a4..288f13b 100644
78832 --- a/kernel/time.c
78833 +++ b/kernel/time.c
78834 @@ -171,6 +171,11 @@ int do_sys_settimeofday(const struct timespec *tv, const struct timezone *tz)
78835 return error;
78836
78837 if (tz) {
78838 + /* we log in do_settimeofday called below, so don't log twice
78839 + */
78840 + if (!tv)
78841 + gr_log_timechange();
78842 +
78843 sys_tz = *tz;
78844 update_vsyscall_tz();
78845 if (firsttime) {
78846 @@ -501,7 +506,7 @@ EXPORT_SYMBOL(usecs_to_jiffies);
78847 * The >> (NSEC_JIFFIE_SC - SEC_JIFFIE_SC) converts the scaled nsec
78848 * value to a scaled second value.
78849 */
78850 -unsigned long
78851 +unsigned long __intentional_overflow(-1)
78852 timespec_to_jiffies(const struct timespec *value)
78853 {
78854 unsigned long sec = value->tv_sec;
78855 diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
78856 index f11d83b..d016d91 100644
78857 --- a/kernel/time/alarmtimer.c
78858 +++ b/kernel/time/alarmtimer.c
78859 @@ -750,7 +750,7 @@ static int __init alarmtimer_init(void)
78860 struct platform_device *pdev;
78861 int error = 0;
78862 int i;
78863 - struct k_clock alarm_clock = {
78864 + static struct k_clock alarm_clock = {
78865 .clock_getres = alarm_clock_getres,
78866 .clock_get = alarm_clock_get,
78867 .timer_create = alarm_timer_create,
78868 diff --git a/kernel/time/tick-broadcast.c b/kernel/time/tick-broadcast.c
78869 index 90ad470..1814e9a 100644
78870 --- a/kernel/time/tick-broadcast.c
78871 +++ b/kernel/time/tick-broadcast.c
78872 @@ -138,7 +138,7 @@ int tick_device_uses_broadcast(struct clock_event_device *dev, int cpu)
78873 * then clear the broadcast bit.
78874 */
78875 if (!(dev->features & CLOCK_EVT_FEAT_C3STOP)) {
78876 - int cpu = smp_processor_id();
78877 + cpu = smp_processor_id();
78878 cpumask_clear_cpu(cpu, tick_get_broadcast_mask());
78879 tick_broadcast_clear_oneshot(cpu);
78880 } else {
78881 diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
78882 index 9a0bc98..fceb7d0 100644
78883 --- a/kernel/time/timekeeping.c
78884 +++ b/kernel/time/timekeeping.c
78885 @@ -15,6 +15,7 @@
78886 #include <linux/init.h>
78887 #include <linux/mm.h>
78888 #include <linux/sched.h>
78889 +#include <linux/grsecurity.h>
78890 #include <linux/syscore_ops.h>
78891 #include <linux/clocksource.h>
78892 #include <linux/jiffies.h>
78893 @@ -448,6 +449,8 @@ int do_settimeofday(const struct timespec *tv)
78894 if (!timespec_valid_strict(tv))
78895 return -EINVAL;
78896
78897 + gr_log_timechange();
78898 +
78899 write_seqlock_irqsave(&tk->lock, flags);
78900
78901 timekeeping_forward_now(tk);
78902 diff --git a/kernel/time/timer_list.c b/kernel/time/timer_list.c
78903 index af5a7e9..715611a 100644
78904 --- a/kernel/time/timer_list.c
78905 +++ b/kernel/time/timer_list.c
78906 @@ -38,12 +38,16 @@ DECLARE_PER_CPU(struct hrtimer_cpu_base, hrtimer_bases);
78907
78908 static void print_name_offset(struct seq_file *m, void *sym)
78909 {
78910 +#ifdef CONFIG_GRKERNSEC_HIDESYM
78911 + SEQ_printf(m, "<%p>", NULL);
78912 +#else
78913 char symname[KSYM_NAME_LEN];
78914
78915 if (lookup_symbol_name((unsigned long)sym, symname) < 0)
78916 SEQ_printf(m, "<%pK>", sym);
78917 else
78918 SEQ_printf(m, "%s", symname);
78919 +#endif
78920 }
78921
78922 static void
78923 @@ -112,7 +116,11 @@ next_one:
78924 static void
78925 print_base(struct seq_file *m, struct hrtimer_clock_base *base, u64 now)
78926 {
78927 +#ifdef CONFIG_GRKERNSEC_HIDESYM
78928 + SEQ_printf(m, " .base: %p\n", NULL);
78929 +#else
78930 SEQ_printf(m, " .base: %pK\n", base);
78931 +#endif
78932 SEQ_printf(m, " .index: %d\n",
78933 base->index);
78934 SEQ_printf(m, " .resolution: %Lu nsecs\n",
78935 @@ -293,7 +301,11 @@ static int __init init_timer_list_procfs(void)
78936 {
78937 struct proc_dir_entry *pe;
78938
78939 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
78940 + pe = proc_create("timer_list", 0400, NULL, &timer_list_fops);
78941 +#else
78942 pe = proc_create("timer_list", 0444, NULL, &timer_list_fops);
78943 +#endif
78944 if (!pe)
78945 return -ENOMEM;
78946 return 0;
78947 diff --git a/kernel/time/timer_stats.c b/kernel/time/timer_stats.c
78948 index 0b537f2..40d6c20 100644
78949 --- a/kernel/time/timer_stats.c
78950 +++ b/kernel/time/timer_stats.c
78951 @@ -116,7 +116,7 @@ static ktime_t time_start, time_stop;
78952 static unsigned long nr_entries;
78953 static struct entry entries[MAX_ENTRIES];
78954
78955 -static atomic_t overflow_count;
78956 +static atomic_unchecked_t overflow_count;
78957
78958 /*
78959 * The entries are in a hash-table, for fast lookup:
78960 @@ -140,7 +140,7 @@ static void reset_entries(void)
78961 nr_entries = 0;
78962 memset(entries, 0, sizeof(entries));
78963 memset(tstat_hash_table, 0, sizeof(tstat_hash_table));
78964 - atomic_set(&overflow_count, 0);
78965 + atomic_set_unchecked(&overflow_count, 0);
78966 }
78967
78968 static struct entry *alloc_entry(void)
78969 @@ -261,7 +261,7 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
78970 if (likely(entry))
78971 entry->count++;
78972 else
78973 - atomic_inc(&overflow_count);
78974 + atomic_inc_unchecked(&overflow_count);
78975
78976 out_unlock:
78977 raw_spin_unlock_irqrestore(lock, flags);
78978 @@ -269,12 +269,16 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
78979
78980 static void print_name_offset(struct seq_file *m, unsigned long addr)
78981 {
78982 +#ifdef CONFIG_GRKERNSEC_HIDESYM
78983 + seq_printf(m, "<%p>", NULL);
78984 +#else
78985 char symname[KSYM_NAME_LEN];
78986
78987 if (lookup_symbol_name(addr, symname) < 0)
78988 - seq_printf(m, "<%p>", (void *)addr);
78989 + seq_printf(m, "<%pK>", (void *)addr);
78990 else
78991 seq_printf(m, "%s", symname);
78992 +#endif
78993 }
78994
78995 static int tstats_show(struct seq_file *m, void *v)
78996 @@ -300,9 +304,9 @@ static int tstats_show(struct seq_file *m, void *v)
78997
78998 seq_puts(m, "Timer Stats Version: v0.2\n");
78999 seq_printf(m, "Sample period: %ld.%03ld s\n", period.tv_sec, ms);
79000 - if (atomic_read(&overflow_count))
79001 + if (atomic_read_unchecked(&overflow_count))
79002 seq_printf(m, "Overflow: %d entries\n",
79003 - atomic_read(&overflow_count));
79004 + atomic_read_unchecked(&overflow_count));
79005
79006 for (i = 0; i < nr_entries; i++) {
79007 entry = entries + i;
79008 @@ -417,7 +421,11 @@ static int __init init_tstats_procfs(void)
79009 {
79010 struct proc_dir_entry *pe;
79011
79012 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
79013 + pe = proc_create("timer_stats", 0600, NULL, &tstats_fops);
79014 +#else
79015 pe = proc_create("timer_stats", 0644, NULL, &tstats_fops);
79016 +#endif
79017 if (!pe)
79018 return -ENOMEM;
79019 return 0;
79020 diff --git a/kernel/timer.c b/kernel/timer.c
79021 index 1b399c8..90e1849 100644
79022 --- a/kernel/timer.c
79023 +++ b/kernel/timer.c
79024 @@ -1363,7 +1363,7 @@ void update_process_times(int user_tick)
79025 /*
79026 * This function runs timers and the timer-tq in bottom half context.
79027 */
79028 -static void run_timer_softirq(struct softirq_action *h)
79029 +static void run_timer_softirq(void)
79030 {
79031 struct tvec_base *base = __this_cpu_read(tvec_bases);
79032
79033 @@ -1481,7 +1481,7 @@ static void process_timeout(unsigned long __data)
79034 *
79035 * In all cases the return value is guaranteed to be non-negative.
79036 */
79037 -signed long __sched schedule_timeout(signed long timeout)
79038 +signed long __sched __intentional_overflow(-1) schedule_timeout(signed long timeout)
79039 {
79040 struct timer_list timer;
79041 unsigned long expire;
79042 @@ -1772,7 +1772,7 @@ static int __cpuinit timer_cpu_notify(struct notifier_block *self,
79043 return NOTIFY_OK;
79044 }
79045
79046 -static struct notifier_block __cpuinitdata timers_nb = {
79047 +static struct notifier_block timers_nb = {
79048 .notifier_call = timer_cpu_notify,
79049 };
79050
79051 diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
79052 index 5a0f781..1497f95 100644
79053 --- a/kernel/trace/blktrace.c
79054 +++ b/kernel/trace/blktrace.c
79055 @@ -317,7 +317,7 @@ static ssize_t blk_dropped_read(struct file *filp, char __user *buffer,
79056 struct blk_trace *bt = filp->private_data;
79057 char buf[16];
79058
79059 - snprintf(buf, sizeof(buf), "%u\n", atomic_read(&bt->dropped));
79060 + snprintf(buf, sizeof(buf), "%u\n", atomic_read_unchecked(&bt->dropped));
79061
79062 return simple_read_from_buffer(buffer, count, ppos, buf, strlen(buf));
79063 }
79064 @@ -375,7 +375,7 @@ static int blk_subbuf_start_callback(struct rchan_buf *buf, void *subbuf,
79065 return 1;
79066
79067 bt = buf->chan->private_data;
79068 - atomic_inc(&bt->dropped);
79069 + atomic_inc_unchecked(&bt->dropped);
79070 return 0;
79071 }
79072
79073 @@ -476,7 +476,7 @@ int do_blk_trace_setup(struct request_queue *q, char *name, dev_t dev,
79074
79075 bt->dir = dir;
79076 bt->dev = dev;
79077 - atomic_set(&bt->dropped, 0);
79078 + atomic_set_unchecked(&bt->dropped, 0);
79079
79080 ret = -EIO;
79081 bt->dropped_file = debugfs_create_file("dropped", 0444, dir, bt,
79082 diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
79083 index 0a0e2a6..943495e 100644
79084 --- a/kernel/trace/ftrace.c
79085 +++ b/kernel/trace/ftrace.c
79086 @@ -1909,12 +1909,17 @@ ftrace_code_disable(struct module *mod, struct dyn_ftrace *rec)
79087 if (unlikely(ftrace_disabled))
79088 return 0;
79089
79090 + ret = ftrace_arch_code_modify_prepare();
79091 + FTRACE_WARN_ON(ret);
79092 + if (ret)
79093 + return 0;
79094 +
79095 ret = ftrace_make_nop(mod, rec, MCOUNT_ADDR);
79096 + FTRACE_WARN_ON(ftrace_arch_code_modify_post_process());
79097 if (ret) {
79098 ftrace_bug(ret, ip);
79099 - return 0;
79100 }
79101 - return 1;
79102 + return ret ? 0 : 1;
79103 }
79104
79105 /*
79106 @@ -2986,7 +2991,7 @@ static void ftrace_free_entry_rcu(struct rcu_head *rhp)
79107
79108 int
79109 register_ftrace_function_probe(char *glob, struct ftrace_probe_ops *ops,
79110 - void *data)
79111 + void *data)
79112 {
79113 struct ftrace_func_probe *entry;
79114 struct ftrace_page *pg;
79115 @@ -3854,8 +3859,10 @@ static int ftrace_process_locs(struct module *mod,
79116 if (!count)
79117 return 0;
79118
79119 + pax_open_kernel();
79120 sort(start, count, sizeof(*start),
79121 ftrace_cmp_ips, ftrace_swap_ips);
79122 + pax_close_kernel();
79123
79124 start_pg = ftrace_allocate_pages(count);
79125 if (!start_pg)
79126 @@ -4574,8 +4581,6 @@ ftrace_enable_sysctl(struct ctl_table *table, int write,
79127 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
79128
79129 static int ftrace_graph_active;
79130 -static struct notifier_block ftrace_suspend_notifier;
79131 -
79132 int ftrace_graph_entry_stub(struct ftrace_graph_ent *trace)
79133 {
79134 return 0;
79135 @@ -4719,6 +4724,10 @@ ftrace_suspend_notifier_call(struct notifier_block *bl, unsigned long state,
79136 return NOTIFY_DONE;
79137 }
79138
79139 +static struct notifier_block ftrace_suspend_notifier = {
79140 + .notifier_call = ftrace_suspend_notifier_call
79141 +};
79142 +
79143 int register_ftrace_graph(trace_func_graph_ret_t retfunc,
79144 trace_func_graph_ent_t entryfunc)
79145 {
79146 @@ -4732,7 +4741,6 @@ int register_ftrace_graph(trace_func_graph_ret_t retfunc,
79147 goto out;
79148 }
79149
79150 - ftrace_suspend_notifier.notifier_call = ftrace_suspend_notifier_call;
79151 register_pm_notifier(&ftrace_suspend_notifier);
79152
79153 ftrace_graph_active++;
79154 diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
79155 index 6989df2..c2265cf 100644
79156 --- a/kernel/trace/ring_buffer.c
79157 +++ b/kernel/trace/ring_buffer.c
79158 @@ -349,9 +349,9 @@ struct buffer_data_page {
79159 */
79160 struct buffer_page {
79161 struct list_head list; /* list of buffer pages */
79162 - local_t write; /* index for next write */
79163 + local_unchecked_t write; /* index for next write */
79164 unsigned read; /* index for next read */
79165 - local_t entries; /* entries on this page */
79166 + local_unchecked_t entries; /* entries on this page */
79167 unsigned long real_end; /* real end of data */
79168 struct buffer_data_page *page; /* Actual data page */
79169 };
79170 @@ -464,8 +464,8 @@ struct ring_buffer_per_cpu {
79171 unsigned long last_overrun;
79172 local_t entries_bytes;
79173 local_t entries;
79174 - local_t overrun;
79175 - local_t commit_overrun;
79176 + local_unchecked_t overrun;
79177 + local_unchecked_t commit_overrun;
79178 local_t dropped_events;
79179 local_t committing;
79180 local_t commits;
79181 @@ -864,8 +864,8 @@ static int rb_tail_page_update(struct ring_buffer_per_cpu *cpu_buffer,
79182 *
79183 * We add a counter to the write field to denote this.
79184 */
79185 - old_write = local_add_return(RB_WRITE_INTCNT, &next_page->write);
79186 - old_entries = local_add_return(RB_WRITE_INTCNT, &next_page->entries);
79187 + old_write = local_add_return_unchecked(RB_WRITE_INTCNT, &next_page->write);
79188 + old_entries = local_add_return_unchecked(RB_WRITE_INTCNT, &next_page->entries);
79189
79190 /*
79191 * Just make sure we have seen our old_write and synchronize
79192 @@ -893,8 +893,8 @@ static int rb_tail_page_update(struct ring_buffer_per_cpu *cpu_buffer,
79193 * cmpxchg to only update if an interrupt did not already
79194 * do it for us. If the cmpxchg fails, we don't care.
79195 */
79196 - (void)local_cmpxchg(&next_page->write, old_write, val);
79197 - (void)local_cmpxchg(&next_page->entries, old_entries, eval);
79198 + (void)local_cmpxchg_unchecked(&next_page->write, old_write, val);
79199 + (void)local_cmpxchg_unchecked(&next_page->entries, old_entries, eval);
79200
79201 /*
79202 * No need to worry about races with clearing out the commit.
79203 @@ -1253,12 +1253,12 @@ static void rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer);
79204
79205 static inline unsigned long rb_page_entries(struct buffer_page *bpage)
79206 {
79207 - return local_read(&bpage->entries) & RB_WRITE_MASK;
79208 + return local_read_unchecked(&bpage->entries) & RB_WRITE_MASK;
79209 }
79210
79211 static inline unsigned long rb_page_write(struct buffer_page *bpage)
79212 {
79213 - return local_read(&bpage->write) & RB_WRITE_MASK;
79214 + return local_read_unchecked(&bpage->write) & RB_WRITE_MASK;
79215 }
79216
79217 static int
79218 @@ -1353,7 +1353,7 @@ rb_remove_pages(struct ring_buffer_per_cpu *cpu_buffer, unsigned int nr_pages)
79219 * bytes consumed in ring buffer from here.
79220 * Increment overrun to account for the lost events.
79221 */
79222 - local_add(page_entries, &cpu_buffer->overrun);
79223 + local_add_unchecked(page_entries, &cpu_buffer->overrun);
79224 local_sub(BUF_PAGE_SIZE, &cpu_buffer->entries_bytes);
79225 }
79226
79227 @@ -1909,7 +1909,7 @@ rb_handle_head_page(struct ring_buffer_per_cpu *cpu_buffer,
79228 * it is our responsibility to update
79229 * the counters.
79230 */
79231 - local_add(entries, &cpu_buffer->overrun);
79232 + local_add_unchecked(entries, &cpu_buffer->overrun);
79233 local_sub(BUF_PAGE_SIZE, &cpu_buffer->entries_bytes);
79234
79235 /*
79236 @@ -2059,7 +2059,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
79237 if (tail == BUF_PAGE_SIZE)
79238 tail_page->real_end = 0;
79239
79240 - local_sub(length, &tail_page->write);
79241 + local_sub_unchecked(length, &tail_page->write);
79242 return;
79243 }
79244
79245 @@ -2094,7 +2094,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
79246 rb_event_set_padding(event);
79247
79248 /* Set the write back to the previous setting */
79249 - local_sub(length, &tail_page->write);
79250 + local_sub_unchecked(length, &tail_page->write);
79251 return;
79252 }
79253
79254 @@ -2106,7 +2106,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
79255
79256 /* Set write to end of buffer */
79257 length = (tail + length) - BUF_PAGE_SIZE;
79258 - local_sub(length, &tail_page->write);
79259 + local_sub_unchecked(length, &tail_page->write);
79260 }
79261
79262 /*
79263 @@ -2132,7 +2132,7 @@ rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer,
79264 * about it.
79265 */
79266 if (unlikely(next_page == commit_page)) {
79267 - local_inc(&cpu_buffer->commit_overrun);
79268 + local_inc_unchecked(&cpu_buffer->commit_overrun);
79269 goto out_reset;
79270 }
79271
79272 @@ -2188,7 +2188,7 @@ rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer,
79273 cpu_buffer->tail_page) &&
79274 (cpu_buffer->commit_page ==
79275 cpu_buffer->reader_page))) {
79276 - local_inc(&cpu_buffer->commit_overrun);
79277 + local_inc_unchecked(&cpu_buffer->commit_overrun);
79278 goto out_reset;
79279 }
79280 }
79281 @@ -2236,7 +2236,7 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
79282 length += RB_LEN_TIME_EXTEND;
79283
79284 tail_page = cpu_buffer->tail_page;
79285 - write = local_add_return(length, &tail_page->write);
79286 + write = local_add_return_unchecked(length, &tail_page->write);
79287
79288 /* set write to only the index of the write */
79289 write &= RB_WRITE_MASK;
79290 @@ -2253,7 +2253,7 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
79291 kmemcheck_annotate_bitfield(event, bitfield);
79292 rb_update_event(cpu_buffer, event, length, add_timestamp, delta);
79293
79294 - local_inc(&tail_page->entries);
79295 + local_inc_unchecked(&tail_page->entries);
79296
79297 /*
79298 * If this is the first commit on the page, then update
79299 @@ -2286,7 +2286,7 @@ rb_try_to_discard(struct ring_buffer_per_cpu *cpu_buffer,
79300
79301 if (bpage->page == (void *)addr && rb_page_write(bpage) == old_index) {
79302 unsigned long write_mask =
79303 - local_read(&bpage->write) & ~RB_WRITE_MASK;
79304 + local_read_unchecked(&bpage->write) & ~RB_WRITE_MASK;
79305 unsigned long event_length = rb_event_length(event);
79306 /*
79307 * This is on the tail page. It is possible that
79308 @@ -2296,7 +2296,7 @@ rb_try_to_discard(struct ring_buffer_per_cpu *cpu_buffer,
79309 */
79310 old_index += write_mask;
79311 new_index += write_mask;
79312 - index = local_cmpxchg(&bpage->write, old_index, new_index);
79313 + index = local_cmpxchg_unchecked(&bpage->write, old_index, new_index);
79314 if (index == old_index) {
79315 /* update counters */
79316 local_sub(event_length, &cpu_buffer->entries_bytes);
79317 @@ -2670,7 +2670,7 @@ rb_decrement_entry(struct ring_buffer_per_cpu *cpu_buffer,
79318
79319 /* Do the likely case first */
79320 if (likely(bpage->page == (void *)addr)) {
79321 - local_dec(&bpage->entries);
79322 + local_dec_unchecked(&bpage->entries);
79323 return;
79324 }
79325
79326 @@ -2682,7 +2682,7 @@ rb_decrement_entry(struct ring_buffer_per_cpu *cpu_buffer,
79327 start = bpage;
79328 do {
79329 if (bpage->page == (void *)addr) {
79330 - local_dec(&bpage->entries);
79331 + local_dec_unchecked(&bpage->entries);
79332 return;
79333 }
79334 rb_inc_page(cpu_buffer, &bpage);
79335 @@ -2964,7 +2964,7 @@ static inline unsigned long
79336 rb_num_of_entries(struct ring_buffer_per_cpu *cpu_buffer)
79337 {
79338 return local_read(&cpu_buffer->entries) -
79339 - (local_read(&cpu_buffer->overrun) + cpu_buffer->read);
79340 + (local_read_unchecked(&cpu_buffer->overrun) + cpu_buffer->read);
79341 }
79342
79343 /**
79344 @@ -3053,7 +3053,7 @@ unsigned long ring_buffer_overrun_cpu(struct ring_buffer *buffer, int cpu)
79345 return 0;
79346
79347 cpu_buffer = buffer->buffers[cpu];
79348 - ret = local_read(&cpu_buffer->overrun);
79349 + ret = local_read_unchecked(&cpu_buffer->overrun);
79350
79351 return ret;
79352 }
79353 @@ -3076,7 +3076,7 @@ ring_buffer_commit_overrun_cpu(struct ring_buffer *buffer, int cpu)
79354 return 0;
79355
79356 cpu_buffer = buffer->buffers[cpu];
79357 - ret = local_read(&cpu_buffer->commit_overrun);
79358 + ret = local_read_unchecked(&cpu_buffer->commit_overrun);
79359
79360 return ret;
79361 }
79362 @@ -3161,7 +3161,7 @@ unsigned long ring_buffer_overruns(struct ring_buffer *buffer)
79363 /* if you care about this being correct, lock the buffer */
79364 for_each_buffer_cpu(buffer, cpu) {
79365 cpu_buffer = buffer->buffers[cpu];
79366 - overruns += local_read(&cpu_buffer->overrun);
79367 + overruns += local_read_unchecked(&cpu_buffer->overrun);
79368 }
79369
79370 return overruns;
79371 @@ -3337,8 +3337,8 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
79372 /*
79373 * Reset the reader page to size zero.
79374 */
79375 - local_set(&cpu_buffer->reader_page->write, 0);
79376 - local_set(&cpu_buffer->reader_page->entries, 0);
79377 + local_set_unchecked(&cpu_buffer->reader_page->write, 0);
79378 + local_set_unchecked(&cpu_buffer->reader_page->entries, 0);
79379 local_set(&cpu_buffer->reader_page->page->commit, 0);
79380 cpu_buffer->reader_page->real_end = 0;
79381
79382 @@ -3372,7 +3372,7 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
79383 * want to compare with the last_overrun.
79384 */
79385 smp_mb();
79386 - overwrite = local_read(&(cpu_buffer->overrun));
79387 + overwrite = local_read_unchecked(&(cpu_buffer->overrun));
79388
79389 /*
79390 * Here's the tricky part.
79391 @@ -3942,8 +3942,8 @@ rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer)
79392
79393 cpu_buffer->head_page
79394 = list_entry(cpu_buffer->pages, struct buffer_page, list);
79395 - local_set(&cpu_buffer->head_page->write, 0);
79396 - local_set(&cpu_buffer->head_page->entries, 0);
79397 + local_set_unchecked(&cpu_buffer->head_page->write, 0);
79398 + local_set_unchecked(&cpu_buffer->head_page->entries, 0);
79399 local_set(&cpu_buffer->head_page->page->commit, 0);
79400
79401 cpu_buffer->head_page->read = 0;
79402 @@ -3953,14 +3953,14 @@ rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer)
79403
79404 INIT_LIST_HEAD(&cpu_buffer->reader_page->list);
79405 INIT_LIST_HEAD(&cpu_buffer->new_pages);
79406 - local_set(&cpu_buffer->reader_page->write, 0);
79407 - local_set(&cpu_buffer->reader_page->entries, 0);
79408 + local_set_unchecked(&cpu_buffer->reader_page->write, 0);
79409 + local_set_unchecked(&cpu_buffer->reader_page->entries, 0);
79410 local_set(&cpu_buffer->reader_page->page->commit, 0);
79411 cpu_buffer->reader_page->read = 0;
79412
79413 local_set(&cpu_buffer->entries_bytes, 0);
79414 - local_set(&cpu_buffer->overrun, 0);
79415 - local_set(&cpu_buffer->commit_overrun, 0);
79416 + local_set_unchecked(&cpu_buffer->overrun, 0);
79417 + local_set_unchecked(&cpu_buffer->commit_overrun, 0);
79418 local_set(&cpu_buffer->dropped_events, 0);
79419 local_set(&cpu_buffer->entries, 0);
79420 local_set(&cpu_buffer->committing, 0);
79421 @@ -4364,8 +4364,8 @@ int ring_buffer_read_page(struct ring_buffer *buffer,
79422 rb_init_page(bpage);
79423 bpage = reader->page;
79424 reader->page = *data_page;
79425 - local_set(&reader->write, 0);
79426 - local_set(&reader->entries, 0);
79427 + local_set_unchecked(&reader->write, 0);
79428 + local_set_unchecked(&reader->entries, 0);
79429 reader->read = 0;
79430 *data_page = bpage;
79431
79432 diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
79433 index 3f28192..a29e8b0 100644
79434 --- a/kernel/trace/trace.c
79435 +++ b/kernel/trace/trace.c
79436 @@ -2893,7 +2893,7 @@ int trace_keep_overwrite(struct tracer *tracer, u32 mask, int set)
79437 return 0;
79438 }
79439
79440 -int set_tracer_flag(unsigned int mask, int enabled)
79441 +int set_tracer_flag(unsigned long mask, int enabled)
79442 {
79443 /* do nothing if flag is already set */
79444 if (!!(trace_flags & mask) == !!enabled)
79445 @@ -4637,10 +4637,9 @@ static const struct file_operations tracing_dyn_info_fops = {
79446 };
79447 #endif
79448
79449 -static struct dentry *d_tracer;
79450 -
79451 struct dentry *tracing_init_dentry(void)
79452 {
79453 + static struct dentry *d_tracer;
79454 static int once;
79455
79456 if (d_tracer)
79457 @@ -4660,10 +4659,9 @@ struct dentry *tracing_init_dentry(void)
79458 return d_tracer;
79459 }
79460
79461 -static struct dentry *d_percpu;
79462 -
79463 static struct dentry *tracing_dentry_percpu(void)
79464 {
79465 + static struct dentry *d_percpu;
79466 static int once;
79467 struct dentry *d_tracer;
79468
79469 diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
79470 index 2081971..09f861e 100644
79471 --- a/kernel/trace/trace.h
79472 +++ b/kernel/trace/trace.h
79473 @@ -948,7 +948,7 @@ extern const char *__stop___trace_bprintk_fmt[];
79474 void trace_printk_init_buffers(void);
79475 void trace_printk_start_comm(void);
79476 int trace_keep_overwrite(struct tracer *tracer, u32 mask, int set);
79477 -int set_tracer_flag(unsigned int mask, int enabled);
79478 +int set_tracer_flag(unsigned long mask, int enabled);
79479
79480 #undef FTRACE_ENTRY
79481 #define FTRACE_ENTRY(call, struct_name, id, tstruct, print, filter) \
79482 diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
79483 index 57e9b28..eebe41c 100644
79484 --- a/kernel/trace/trace_events.c
79485 +++ b/kernel/trace/trace_events.c
79486 @@ -1329,10 +1329,6 @@ static LIST_HEAD(ftrace_module_file_list);
79487 struct ftrace_module_file_ops {
79488 struct list_head list;
79489 struct module *mod;
79490 - struct file_operations id;
79491 - struct file_operations enable;
79492 - struct file_operations format;
79493 - struct file_operations filter;
79494 };
79495
79496 static struct ftrace_module_file_ops *
79497 @@ -1353,17 +1349,12 @@ trace_create_file_ops(struct module *mod)
79498
79499 file_ops->mod = mod;
79500
79501 - file_ops->id = ftrace_event_id_fops;
79502 - file_ops->id.owner = mod;
79503 -
79504 - file_ops->enable = ftrace_enable_fops;
79505 - file_ops->enable.owner = mod;
79506 -
79507 - file_ops->filter = ftrace_event_filter_fops;
79508 - file_ops->filter.owner = mod;
79509 -
79510 - file_ops->format = ftrace_event_format_fops;
79511 - file_ops->format.owner = mod;
79512 + pax_open_kernel();
79513 + mod->trace_id.owner = mod;
79514 + mod->trace_enable.owner = mod;
79515 + mod->trace_filter.owner = mod;
79516 + mod->trace_format.owner = mod;
79517 + pax_close_kernel();
79518
79519 list_add(&file_ops->list, &ftrace_module_file_list);
79520
79521 @@ -1387,8 +1378,8 @@ static void trace_module_add_events(struct module *mod)
79522
79523 for_each_event(call, start, end) {
79524 __trace_add_event_call(*call, mod,
79525 - &file_ops->id, &file_ops->enable,
79526 - &file_ops->filter, &file_ops->format);
79527 + &mod->trace_id, &mod->trace_enable,
79528 + &mod->trace_filter, &mod->trace_format);
79529 }
79530 }
79531
79532 diff --git a/kernel/trace/trace_mmiotrace.c b/kernel/trace/trace_mmiotrace.c
79533 index fd3c8aa..5f324a6 100644
79534 --- a/kernel/trace/trace_mmiotrace.c
79535 +++ b/kernel/trace/trace_mmiotrace.c
79536 @@ -24,7 +24,7 @@ struct header_iter {
79537 static struct trace_array *mmio_trace_array;
79538 static bool overrun_detected;
79539 static unsigned long prev_overruns;
79540 -static atomic_t dropped_count;
79541 +static atomic_unchecked_t dropped_count;
79542
79543 static void mmio_reset_data(struct trace_array *tr)
79544 {
79545 @@ -127,7 +127,7 @@ static void mmio_close(struct trace_iterator *iter)
79546
79547 static unsigned long count_overruns(struct trace_iterator *iter)
79548 {
79549 - unsigned long cnt = atomic_xchg(&dropped_count, 0);
79550 + unsigned long cnt = atomic_xchg_unchecked(&dropped_count, 0);
79551 unsigned long over = ring_buffer_overruns(iter->tr->buffer);
79552
79553 if (over > prev_overruns)
79554 @@ -317,7 +317,7 @@ static void __trace_mmiotrace_rw(struct trace_array *tr,
79555 event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_RW,
79556 sizeof(*entry), 0, pc);
79557 if (!event) {
79558 - atomic_inc(&dropped_count);
79559 + atomic_inc_unchecked(&dropped_count);
79560 return;
79561 }
79562 entry = ring_buffer_event_data(event);
79563 @@ -347,7 +347,7 @@ static void __trace_mmiotrace_map(struct trace_array *tr,
79564 event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_MAP,
79565 sizeof(*entry), 0, pc);
79566 if (!event) {
79567 - atomic_inc(&dropped_count);
79568 + atomic_inc_unchecked(&dropped_count);
79569 return;
79570 }
79571 entry = ring_buffer_event_data(event);
79572 diff --git a/kernel/trace/trace_output.c b/kernel/trace/trace_output.c
79573 index 697e88d..1a79993 100644
79574 --- a/kernel/trace/trace_output.c
79575 +++ b/kernel/trace/trace_output.c
79576 @@ -278,7 +278,7 @@ int trace_seq_path(struct trace_seq *s, const struct path *path)
79577
79578 p = d_path(path, s->buffer + s->len, PAGE_SIZE - s->len);
79579 if (!IS_ERR(p)) {
79580 - p = mangle_path(s->buffer + s->len, p, "\n");
79581 + p = mangle_path(s->buffer + s->len, p, "\n\\");
79582 if (p) {
79583 s->len = p - s->buffer;
79584 return 1;
79585 @@ -851,14 +851,16 @@ int register_ftrace_event(struct trace_event *event)
79586 goto out;
79587 }
79588
79589 + pax_open_kernel();
79590 if (event->funcs->trace == NULL)
79591 - event->funcs->trace = trace_nop_print;
79592 + *(void **)&event->funcs->trace = trace_nop_print;
79593 if (event->funcs->raw == NULL)
79594 - event->funcs->raw = trace_nop_print;
79595 + *(void **)&event->funcs->raw = trace_nop_print;
79596 if (event->funcs->hex == NULL)
79597 - event->funcs->hex = trace_nop_print;
79598 + *(void **)&event->funcs->hex = trace_nop_print;
79599 if (event->funcs->binary == NULL)
79600 - event->funcs->binary = trace_nop_print;
79601 + *(void **)&event->funcs->binary = trace_nop_print;
79602 + pax_close_kernel();
79603
79604 key = event->type & (EVENT_HASHSIZE - 1);
79605
79606 diff --git a/kernel/trace/trace_stack.c b/kernel/trace/trace_stack.c
79607 index b20428c..4845a10 100644
79608 --- a/kernel/trace/trace_stack.c
79609 +++ b/kernel/trace/trace_stack.c
79610 @@ -68,7 +68,7 @@ check_stack(unsigned long ip, unsigned long *stack)
79611 return;
79612
79613 /* we do not handle interrupt stacks yet */
79614 - if (!object_is_on_stack(stack))
79615 + if (!object_starts_on_stack(stack))
79616 return;
79617
79618 local_irq_save(flags);
79619 diff --git a/kernel/user_namespace.c b/kernel/user_namespace.c
79620 index e134d8f..a018cdd 100644
79621 --- a/kernel/user_namespace.c
79622 +++ b/kernel/user_namespace.c
79623 @@ -853,7 +853,7 @@ static int userns_install(struct nsproxy *nsproxy, void *ns)
79624 if (atomic_read(&current->mm->mm_users) > 1)
79625 return -EINVAL;
79626
79627 - if (current->fs->users != 1)
79628 + if (atomic_read(&current->fs->users) != 1)
79629 return -EINVAL;
79630
79631 if (!ns_capable(user_ns, CAP_SYS_ADMIN))
79632 diff --git a/kernel/utsname_sysctl.c b/kernel/utsname_sysctl.c
79633 index 4f69f9a..7c6f8f8 100644
79634 --- a/kernel/utsname_sysctl.c
79635 +++ b/kernel/utsname_sysctl.c
79636 @@ -47,7 +47,7 @@ static void put_uts(ctl_table *table, int write, void *which)
79637 static int proc_do_uts_string(ctl_table *table, int write,
79638 void __user *buffer, size_t *lenp, loff_t *ppos)
79639 {
79640 - struct ctl_table uts_table;
79641 + ctl_table_no_const uts_table;
79642 int r;
79643 memcpy(&uts_table, table, sizeof(uts_table));
79644 uts_table.data = get_uts(table, write);
79645 diff --git a/kernel/watchdog.c b/kernel/watchdog.c
79646 index 4a94467..80a6f9c 100644
79647 --- a/kernel/watchdog.c
79648 +++ b/kernel/watchdog.c
79649 @@ -526,7 +526,7 @@ int proc_dowatchdog(struct ctl_table *table, int write,
79650 }
79651 #endif /* CONFIG_SYSCTL */
79652
79653 -static struct smp_hotplug_thread watchdog_threads = {
79654 +static struct smp_hotplug_thread watchdog_threads __read_only = {
79655 .store = &softlockup_watchdog,
79656 .thread_should_run = watchdog_should_run,
79657 .thread_fn = watchdog,
79658 diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
79659 index 28be08c..47bab92 100644
79660 --- a/lib/Kconfig.debug
79661 +++ b/lib/Kconfig.debug
79662 @@ -549,7 +549,7 @@ config DEBUG_MUTEXES
79663
79664 config DEBUG_LOCK_ALLOC
79665 bool "Lock debugging: detect incorrect freeing of live locks"
79666 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
79667 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
79668 select DEBUG_SPINLOCK
79669 select DEBUG_MUTEXES
79670 select LOCKDEP
79671 @@ -563,7 +563,7 @@ config DEBUG_LOCK_ALLOC
79672
79673 config PROVE_LOCKING
79674 bool "Lock debugging: prove locking correctness"
79675 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
79676 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
79677 select LOCKDEP
79678 select DEBUG_SPINLOCK
79679 select DEBUG_MUTEXES
79680 @@ -614,7 +614,7 @@ config LOCKDEP
79681
79682 config LOCK_STAT
79683 bool "Lock usage statistics"
79684 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
79685 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
79686 select LOCKDEP
79687 select DEBUG_SPINLOCK
79688 select DEBUG_MUTEXES
79689 @@ -1282,6 +1282,7 @@ config LATENCYTOP
79690 depends on DEBUG_KERNEL
79691 depends on STACKTRACE_SUPPORT
79692 depends on PROC_FS
79693 + depends on !GRKERNSEC_HIDESYM
79694 select FRAME_POINTER if !MIPS && !PPC && !S390 && !MICROBLAZE && !ARM_UNWIND
79695 select KALLSYMS
79696 select KALLSYMS_ALL
79697 @@ -1310,7 +1311,7 @@ config INTERVAL_TREE_TEST
79698
79699 config PROVIDE_OHCI1394_DMA_INIT
79700 bool "Remote debugging over FireWire early on boot"
79701 - depends on PCI && X86
79702 + depends on PCI && X86 && !GRKERNSEC
79703 help
79704 If you want to debug problems which hang or crash the kernel early
79705 on boot and the crashing machine has a FireWire port, you can use
79706 @@ -1339,7 +1340,7 @@ config PROVIDE_OHCI1394_DMA_INIT
79707
79708 config FIREWIRE_OHCI_REMOTE_DMA
79709 bool "Remote debugging over FireWire with firewire-ohci"
79710 - depends on FIREWIRE_OHCI
79711 + depends on FIREWIRE_OHCI && !GRKERNSEC
79712 help
79713 This option lets you use the FireWire bus for remote debugging
79714 with help of the firewire-ohci driver. It enables unfiltered
79715 diff --git a/lib/Makefile b/lib/Makefile
79716 index 6e2cc56..9b13738 100644
79717 --- a/lib/Makefile
79718 +++ b/lib/Makefile
79719 @@ -47,7 +47,7 @@ obj-$(CONFIG_GENERIC_HWEIGHT) += hweight.o
79720
79721 obj-$(CONFIG_BTREE) += btree.o
79722 obj-$(CONFIG_DEBUG_PREEMPT) += smp_processor_id.o
79723 -obj-$(CONFIG_DEBUG_LIST) += list_debug.o
79724 +obj-y += list_debug.o
79725 obj-$(CONFIG_DEBUG_OBJECTS) += debugobjects.o
79726
79727 ifneq ($(CONFIG_HAVE_DEC_LOCK),y)
79728 diff --git a/lib/bitmap.c b/lib/bitmap.c
79729 index 06f7e4f..f3cf2b0 100644
79730 --- a/lib/bitmap.c
79731 +++ b/lib/bitmap.c
79732 @@ -422,7 +422,7 @@ int __bitmap_parse(const char *buf, unsigned int buflen,
79733 {
79734 int c, old_c, totaldigits, ndigits, nchunks, nbits;
79735 u32 chunk;
79736 - const char __user __force *ubuf = (const char __user __force *)buf;
79737 + const char __user *ubuf = (const char __force_user *)buf;
79738
79739 bitmap_zero(maskp, nmaskbits);
79740
79741 @@ -507,7 +507,7 @@ int bitmap_parse_user(const char __user *ubuf,
79742 {
79743 if (!access_ok(VERIFY_READ, ubuf, ulen))
79744 return -EFAULT;
79745 - return __bitmap_parse((const char __force *)ubuf,
79746 + return __bitmap_parse((const char __force_kernel *)ubuf,
79747 ulen, 1, maskp, nmaskbits);
79748
79749 }
79750 @@ -598,7 +598,7 @@ static int __bitmap_parselist(const char *buf, unsigned int buflen,
79751 {
79752 unsigned a, b;
79753 int c, old_c, totaldigits;
79754 - const char __user __force *ubuf = (const char __user __force *)buf;
79755 + const char __user *ubuf = (const char __force_user *)buf;
79756 int exp_digit, in_range;
79757
79758 totaldigits = c = 0;
79759 @@ -698,7 +698,7 @@ int bitmap_parselist_user(const char __user *ubuf,
79760 {
79761 if (!access_ok(VERIFY_READ, ubuf, ulen))
79762 return -EFAULT;
79763 - return __bitmap_parselist((const char __force *)ubuf,
79764 + return __bitmap_parselist((const char __force_kernel *)ubuf,
79765 ulen, 1, maskp, nmaskbits);
79766 }
79767 EXPORT_SYMBOL(bitmap_parselist_user);
79768 diff --git a/lib/bug.c b/lib/bug.c
79769 index 1686034..a9c00c8 100644
79770 --- a/lib/bug.c
79771 +++ b/lib/bug.c
79772 @@ -134,6 +134,8 @@ enum bug_trap_type report_bug(unsigned long bugaddr, struct pt_regs *regs)
79773 return BUG_TRAP_TYPE_NONE;
79774
79775 bug = find_bug(bugaddr);
79776 + if (!bug)
79777 + return BUG_TRAP_TYPE_NONE;
79778
79779 file = NULL;
79780 line = 0;
79781 diff --git a/lib/debugobjects.c b/lib/debugobjects.c
79782 index 37061ed..da83f48 100644
79783 --- a/lib/debugobjects.c
79784 +++ b/lib/debugobjects.c
79785 @@ -286,7 +286,7 @@ static void debug_object_is_on_stack(void *addr, int onstack)
79786 if (limit > 4)
79787 return;
79788
79789 - is_on_stack = object_is_on_stack(addr);
79790 + is_on_stack = object_starts_on_stack(addr);
79791 if (is_on_stack == onstack)
79792 return;
79793
79794 diff --git a/lib/devres.c b/lib/devres.c
79795 index 8235331..5881053 100644
79796 --- a/lib/devres.c
79797 +++ b/lib/devres.c
79798 @@ -81,7 +81,7 @@ EXPORT_SYMBOL(devm_ioremap_nocache);
79799 void devm_iounmap(struct device *dev, void __iomem *addr)
79800 {
79801 WARN_ON(devres_destroy(dev, devm_ioremap_release, devm_ioremap_match,
79802 - (void *)addr));
79803 + (void __force *)addr));
79804 iounmap(addr);
79805 }
79806 EXPORT_SYMBOL(devm_iounmap);
79807 @@ -224,7 +224,7 @@ void devm_ioport_unmap(struct device *dev, void __iomem *addr)
79808 {
79809 ioport_unmap(addr);
79810 WARN_ON(devres_destroy(dev, devm_ioport_map_release,
79811 - devm_ioport_map_match, (void *)addr));
79812 + devm_ioport_map_match, (void __force *)addr));
79813 }
79814 EXPORT_SYMBOL(devm_ioport_unmap);
79815 #endif /* CONFIG_HAS_IOPORT */
79816 diff --git a/lib/div64.c b/lib/div64.c
79817 index a163b6c..9618fa5 100644
79818 --- a/lib/div64.c
79819 +++ b/lib/div64.c
79820 @@ -59,7 +59,7 @@ uint32_t __attribute__((weak)) __div64_32(uint64_t *n, uint32_t base)
79821 EXPORT_SYMBOL(__div64_32);
79822
79823 #ifndef div_s64_rem
79824 -s64 div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
79825 +s64 __intentional_overflow(-1) div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
79826 {
79827 u64 quotient;
79828
79829 @@ -90,7 +90,7 @@ EXPORT_SYMBOL(div_s64_rem);
79830 * 'http://www.hackersdelight.org/HDcode/newCode/divDouble.c.txt'
79831 */
79832 #ifndef div64_u64
79833 -u64 div64_u64(u64 dividend, u64 divisor)
79834 +u64 __intentional_overflow(-1) div64_u64(u64 dividend, u64 divisor)
79835 {
79836 u32 high = divisor >> 32;
79837 u64 quot;
79838 diff --git a/lib/dma-debug.c b/lib/dma-debug.c
79839 index d87a17a..ac0d79a 100644
79840 --- a/lib/dma-debug.c
79841 +++ b/lib/dma-debug.c
79842 @@ -768,7 +768,7 @@ static int dma_debug_device_change(struct notifier_block *nb, unsigned long acti
79843
79844 void dma_debug_add_bus(struct bus_type *bus)
79845 {
79846 - struct notifier_block *nb;
79847 + notifier_block_no_const *nb;
79848
79849 if (global_disable)
79850 return;
79851 @@ -945,7 +945,7 @@ static void check_unmap(struct dma_debug_entry *ref)
79852
79853 static void check_for_stack(struct device *dev, void *addr)
79854 {
79855 - if (object_is_on_stack(addr))
79856 + if (object_starts_on_stack(addr))
79857 err_printk(dev, NULL, "DMA-API: device driver maps memory from"
79858 "stack [addr=%p]\n", addr);
79859 }
79860 diff --git a/lib/inflate.c b/lib/inflate.c
79861 index 013a761..c28f3fc 100644
79862 --- a/lib/inflate.c
79863 +++ b/lib/inflate.c
79864 @@ -269,7 +269,7 @@ static void free(void *where)
79865 malloc_ptr = free_mem_ptr;
79866 }
79867 #else
79868 -#define malloc(a) kmalloc(a, GFP_KERNEL)
79869 +#define malloc(a) kmalloc((a), GFP_KERNEL)
79870 #define free(a) kfree(a)
79871 #endif
79872
79873 diff --git a/lib/ioremap.c b/lib/ioremap.c
79874 index 0c9216c..863bd89 100644
79875 --- a/lib/ioremap.c
79876 +++ b/lib/ioremap.c
79877 @@ -38,7 +38,7 @@ static inline int ioremap_pmd_range(pud_t *pud, unsigned long addr,
79878 unsigned long next;
79879
79880 phys_addr -= addr;
79881 - pmd = pmd_alloc(&init_mm, pud, addr);
79882 + pmd = pmd_alloc_kernel(&init_mm, pud, addr);
79883 if (!pmd)
79884 return -ENOMEM;
79885 do {
79886 @@ -56,7 +56,7 @@ static inline int ioremap_pud_range(pgd_t *pgd, unsigned long addr,
79887 unsigned long next;
79888
79889 phys_addr -= addr;
79890 - pud = pud_alloc(&init_mm, pgd, addr);
79891 + pud = pud_alloc_kernel(&init_mm, pgd, addr);
79892 if (!pud)
79893 return -ENOMEM;
79894 do {
79895 diff --git a/lib/is_single_threaded.c b/lib/is_single_threaded.c
79896 index bd2bea9..6b3c95e 100644
79897 --- a/lib/is_single_threaded.c
79898 +++ b/lib/is_single_threaded.c
79899 @@ -22,6 +22,9 @@ bool current_is_single_threaded(void)
79900 struct task_struct *p, *t;
79901 bool ret;
79902
79903 + if (!mm)
79904 + return true;
79905 +
79906 if (atomic_read(&task->signal->live) != 1)
79907 return false;
79908
79909 diff --git a/lib/kobject.c b/lib/kobject.c
79910 index a654866..a4fd13d 100644
79911 --- a/lib/kobject.c
79912 +++ b/lib/kobject.c
79913 @@ -859,9 +859,9 @@ EXPORT_SYMBOL_GPL(kset_create_and_add);
79914
79915
79916 static DEFINE_SPINLOCK(kobj_ns_type_lock);
79917 -static const struct kobj_ns_type_operations *kobj_ns_ops_tbl[KOBJ_NS_TYPES];
79918 +static const struct kobj_ns_type_operations *kobj_ns_ops_tbl[KOBJ_NS_TYPES] __read_only;
79919
79920 -int kobj_ns_type_register(const struct kobj_ns_type_operations *ops)
79921 +int __init kobj_ns_type_register(const struct kobj_ns_type_operations *ops)
79922 {
79923 enum kobj_ns_type type = ops->type;
79924 int error;
79925 diff --git a/lib/list_debug.c b/lib/list_debug.c
79926 index c24c2f7..06e070b 100644
79927 --- a/lib/list_debug.c
79928 +++ b/lib/list_debug.c
79929 @@ -11,7 +11,9 @@
79930 #include <linux/bug.h>
79931 #include <linux/kernel.h>
79932 #include <linux/rculist.h>
79933 +#include <linux/mm.h>
79934
79935 +#ifdef CONFIG_DEBUG_LIST
79936 /*
79937 * Insert a new entry between two known consecutive entries.
79938 *
79939 @@ -19,21 +21,32 @@
79940 * the prev/next entries already!
79941 */
79942
79943 -void __list_add(struct list_head *new,
79944 - struct list_head *prev,
79945 - struct list_head *next)
79946 +static bool __list_add_debug(struct list_head *new,
79947 + struct list_head *prev,
79948 + struct list_head *next)
79949 {
79950 - WARN(next->prev != prev,
79951 + if (WARN(next->prev != prev,
79952 "list_add corruption. next->prev should be "
79953 "prev (%p), but was %p. (next=%p).\n",
79954 - prev, next->prev, next);
79955 - WARN(prev->next != next,
79956 + prev, next->prev, next) ||
79957 + WARN(prev->next != next,
79958 "list_add corruption. prev->next should be "
79959 "next (%p), but was %p. (prev=%p).\n",
79960 - next, prev->next, prev);
79961 - WARN(new == prev || new == next,
79962 - "list_add double add: new=%p, prev=%p, next=%p.\n",
79963 - new, prev, next);
79964 + next, prev->next, prev) ||
79965 + WARN(new == prev || new == next,
79966 + "list_add double add: new=%p, prev=%p, next=%p.\n",
79967 + new, prev, next))
79968 + return false;
79969 + return true;
79970 +}
79971 +
79972 +void __list_add(struct list_head *new,
79973 + struct list_head *prev,
79974 + struct list_head *next)
79975 +{
79976 + if (!__list_add_debug(new, prev, next))
79977 + return;
79978 +
79979 next->prev = new;
79980 new->next = next;
79981 new->prev = prev;
79982 @@ -41,7 +54,7 @@ void __list_add(struct list_head *new,
79983 }
79984 EXPORT_SYMBOL(__list_add);
79985
79986 -void __list_del_entry(struct list_head *entry)
79987 +static bool __list_del_entry_debug(struct list_head *entry)
79988 {
79989 struct list_head *prev, *next;
79990
79991 @@ -60,9 +73,16 @@ void __list_del_entry(struct list_head *entry)
79992 WARN(next->prev != entry,
79993 "list_del corruption. next->prev should be %p, "
79994 "but was %p\n", entry, next->prev))
79995 + return false;
79996 + return true;
79997 +}
79998 +
79999 +void __list_del_entry(struct list_head *entry)
80000 +{
80001 + if (!__list_del_entry_debug(entry))
80002 return;
80003
80004 - __list_del(prev, next);
80005 + __list_del(entry->prev, entry->next);
80006 }
80007 EXPORT_SYMBOL(__list_del_entry);
80008
80009 @@ -86,15 +106,85 @@ EXPORT_SYMBOL(list_del);
80010 void __list_add_rcu(struct list_head *new,
80011 struct list_head *prev, struct list_head *next)
80012 {
80013 - WARN(next->prev != prev,
80014 - "list_add_rcu corruption. next->prev should be prev (%p), but was %p. (next=%p).\n",
80015 - prev, next->prev, next);
80016 - WARN(prev->next != next,
80017 - "list_add_rcu corruption. prev->next should be next (%p), but was %p. (prev=%p).\n",
80018 - next, prev->next, prev);
80019 + if (!__list_add_debug(new, prev, next))
80020 + return;
80021 +
80022 new->next = next;
80023 new->prev = prev;
80024 rcu_assign_pointer(list_next_rcu(prev), new);
80025 next->prev = new;
80026 }
80027 EXPORT_SYMBOL(__list_add_rcu);
80028 +#endif
80029 +
80030 +void __pax_list_add(struct list_head *new, struct list_head *prev, struct list_head *next)
80031 +{
80032 +#ifdef CONFIG_DEBUG_LIST
80033 + if (!__list_add_debug(new, prev, next))
80034 + return;
80035 +#endif
80036 +
80037 + pax_open_kernel();
80038 + next->prev = new;
80039 + new->next = next;
80040 + new->prev = prev;
80041 + prev->next = new;
80042 + pax_close_kernel();
80043 +}
80044 +EXPORT_SYMBOL(__pax_list_add);
80045 +
80046 +void pax_list_del(struct list_head *entry)
80047 +{
80048 +#ifdef CONFIG_DEBUG_LIST
80049 + if (!__list_del_entry_debug(entry))
80050 + return;
80051 +#endif
80052 +
80053 + pax_open_kernel();
80054 + __list_del(entry->prev, entry->next);
80055 + entry->next = LIST_POISON1;
80056 + entry->prev = LIST_POISON2;
80057 + pax_close_kernel();
80058 +}
80059 +EXPORT_SYMBOL(pax_list_del);
80060 +
80061 +void pax_list_del_init(struct list_head *entry)
80062 +{
80063 + pax_open_kernel();
80064 + __list_del(entry->prev, entry->next);
80065 + INIT_LIST_HEAD(entry);
80066 + pax_close_kernel();
80067 +}
80068 +EXPORT_SYMBOL(pax_list_del_init);
80069 +
80070 +void __pax_list_add_rcu(struct list_head *new,
80071 + struct list_head *prev, struct list_head *next)
80072 +{
80073 +#ifdef CONFIG_DEBUG_LIST
80074 + if (!__list_add_debug(new, prev, next))
80075 + return;
80076 +#endif
80077 +
80078 + pax_open_kernel();
80079 + new->next = next;
80080 + new->prev = prev;
80081 + rcu_assign_pointer(list_next_rcu(prev), new);
80082 + next->prev = new;
80083 + pax_close_kernel();
80084 +}
80085 +EXPORT_SYMBOL(__pax_list_add_rcu);
80086 +
80087 +void pax_list_del_rcu(struct list_head *entry)
80088 +{
80089 +#ifdef CONFIG_DEBUG_LIST
80090 + if (!__list_del_entry_debug(entry))
80091 + return;
80092 +#endif
80093 +
80094 + pax_open_kernel();
80095 + __list_del(entry->prev, entry->next);
80096 + entry->next = LIST_POISON1;
80097 + entry->prev = LIST_POISON2;
80098 + pax_close_kernel();
80099 +}
80100 +EXPORT_SYMBOL(pax_list_del_rcu);
80101 diff --git a/lib/radix-tree.c b/lib/radix-tree.c
80102 index e796429..6e38f9f 100644
80103 --- a/lib/radix-tree.c
80104 +++ b/lib/radix-tree.c
80105 @@ -92,7 +92,7 @@ struct radix_tree_preload {
80106 int nr;
80107 struct radix_tree_node *nodes[RADIX_TREE_PRELOAD_SIZE];
80108 };
80109 -static DEFINE_PER_CPU(struct radix_tree_preload, radix_tree_preloads) = { 0, };
80110 +static DEFINE_PER_CPU(struct radix_tree_preload, radix_tree_preloads);
80111
80112 static inline void *ptr_to_indirect(void *ptr)
80113 {
80114 diff --git a/lib/strncpy_from_user.c b/lib/strncpy_from_user.c
80115 index bb2b201..46abaf9 100644
80116 --- a/lib/strncpy_from_user.c
80117 +++ b/lib/strncpy_from_user.c
80118 @@ -21,7 +21,7 @@
80119 */
80120 static inline long do_strncpy_from_user(char *dst, const char __user *src, long count, unsigned long max)
80121 {
80122 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
80123 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
80124 long res = 0;
80125
80126 /*
80127 diff --git a/lib/strnlen_user.c b/lib/strnlen_user.c
80128 index a28df52..3d55877 100644
80129 --- a/lib/strnlen_user.c
80130 +++ b/lib/strnlen_user.c
80131 @@ -26,7 +26,7 @@
80132 */
80133 static inline long do_strnlen_user(const char __user *src, unsigned long count, unsigned long max)
80134 {
80135 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
80136 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
80137 long align, res = 0;
80138 unsigned long c;
80139
80140 diff --git a/lib/swiotlb.c b/lib/swiotlb.c
80141 index d23762e..e21eab2 100644
80142 --- a/lib/swiotlb.c
80143 +++ b/lib/swiotlb.c
80144 @@ -664,7 +664,7 @@ EXPORT_SYMBOL(swiotlb_alloc_coherent);
80145
80146 void
80147 swiotlb_free_coherent(struct device *hwdev, size_t size, void *vaddr,
80148 - dma_addr_t dev_addr)
80149 + dma_addr_t dev_addr, struct dma_attrs *attrs)
80150 {
80151 phys_addr_t paddr = dma_to_phys(hwdev, dev_addr);
80152
80153 diff --git a/lib/vsprintf.c b/lib/vsprintf.c
80154 index 0d62fd7..b7bc911 100644
80155 --- a/lib/vsprintf.c
80156 +++ b/lib/vsprintf.c
80157 @@ -16,6 +16,9 @@
80158 * - scnprintf and vscnprintf
80159 */
80160
80161 +#ifdef CONFIG_GRKERNSEC_HIDESYM
80162 +#define __INCLUDED_BY_HIDESYM 1
80163 +#endif
80164 #include <stdarg.h>
80165 #include <linux/module.h> /* for KSYM_SYMBOL_LEN */
80166 #include <linux/types.h>
80167 @@ -974,7 +977,11 @@ char *netdev_feature_string(char *buf, char *end, const u8 *addr,
80168 return number(buf, end, *(const netdev_features_t *)addr, spec);
80169 }
80170
80171 +#ifdef CONFIG_GRKERNSEC_HIDESYM
80172 +int kptr_restrict __read_mostly = 2;
80173 +#else
80174 int kptr_restrict __read_mostly;
80175 +#endif
80176
80177 /*
80178 * Show a '%p' thing. A kernel extension is that the '%p' is followed
80179 @@ -988,6 +995,8 @@ int kptr_restrict __read_mostly;
80180 * - 'S' For symbolic direct pointers with offset
80181 * - 's' For symbolic direct pointers without offset
80182 * - 'B' For backtraced symbolic direct pointers with offset
80183 + * - 'A' For symbolic direct pointers with offset approved for use with GRKERNSEC_HIDESYM
80184 + * - 'a' For symbolic direct pointers without offset approved for use with GRKERNSEC_HIDESYM
80185 * - 'R' For decoded struct resource, e.g., [mem 0x0-0x1f 64bit pref]
80186 * - 'r' For raw struct resource, e.g., [mem 0x0-0x1f flags 0x201]
80187 * - 'M' For a 6-byte MAC address, it prints the address in the
80188 @@ -1044,12 +1053,12 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
80189
80190 if (!ptr && *fmt != 'K') {
80191 /*
80192 - * Print (null) with the same width as a pointer so it makes
80193 + * Print (nil) with the same width as a pointer so it makes
80194 * tabular output look nice.
80195 */
80196 if (spec.field_width == -1)
80197 spec.field_width = default_width;
80198 - return string(buf, end, "(null)", spec);
80199 + return string(buf, end, "(nil)", spec);
80200 }
80201
80202 switch (*fmt) {
80203 @@ -1059,6 +1068,12 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
80204 /* Fallthrough */
80205 case 'S':
80206 case 's':
80207 +#ifdef CONFIG_GRKERNSEC_HIDESYM
80208 + break;
80209 +#else
80210 + return symbol_string(buf, end, ptr, spec, *fmt);
80211 +#endif
80212 + case 'A':
80213 case 'B':
80214 return symbol_string(buf, end, ptr, spec, *fmt);
80215 case 'R':
80216 @@ -1099,6 +1114,8 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
80217 va_end(va);
80218 return buf;
80219 }
80220 + case 'P':
80221 + break;
80222 case 'K':
80223 /*
80224 * %pK cannot be used in IRQ context because its test
80225 @@ -1128,6 +1145,21 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
80226 return number(buf, end,
80227 (unsigned long long) *((phys_addr_t *)ptr), spec);
80228 }
80229 +
80230 +#ifdef CONFIG_GRKERNSEC_HIDESYM
80231 + /* 'P' = approved pointers to copy to userland,
80232 + as in the /proc/kallsyms case, as we make it display nothing
80233 + for non-root users, and the real contents for root users
80234 + Also ignore 'K' pointers, since we force their NULLing for non-root users
80235 + above
80236 + */
80237 + if ((unsigned long)ptr > TASK_SIZE && *fmt != 'P' && *fmt != 'K' && is_usercopy_object(buf)) {
80238 + printk(KERN_ALERT "grsec: kernel infoleak detected! Please report this log to spender@grsecurity.net.\n");
80239 + dump_stack();
80240 + ptr = NULL;
80241 + }
80242 +#endif
80243 +
80244 spec.flags |= SMALL;
80245 if (spec.field_width == -1) {
80246 spec.field_width = default_width;
80247 @@ -1849,11 +1881,11 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
80248 typeof(type) value; \
80249 if (sizeof(type) == 8) { \
80250 args = PTR_ALIGN(args, sizeof(u32)); \
80251 - *(u32 *)&value = *(u32 *)args; \
80252 - *((u32 *)&value + 1) = *(u32 *)(args + 4); \
80253 + *(u32 *)&value = *(const u32 *)args; \
80254 + *((u32 *)&value + 1) = *(const u32 *)(args + 4); \
80255 } else { \
80256 args = PTR_ALIGN(args, sizeof(type)); \
80257 - value = *(typeof(type) *)args; \
80258 + value = *(const typeof(type) *)args; \
80259 } \
80260 args += sizeof(type); \
80261 value; \
80262 @@ -1916,7 +1948,7 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
80263 case FORMAT_TYPE_STR: {
80264 const char *str_arg = args;
80265 args += strlen(str_arg) + 1;
80266 - str = string(str, end, (char *)str_arg, spec);
80267 + str = string(str, end, str_arg, spec);
80268 break;
80269 }
80270
80271 diff --git a/localversion-grsec b/localversion-grsec
80272 new file mode 100644
80273 index 0000000..7cd6065
80274 --- /dev/null
80275 +++ b/localversion-grsec
80276 @@ -0,0 +1 @@
80277 +-grsec
80278 diff --git a/mm/Kconfig b/mm/Kconfig
80279 index 3bea74f..e821c99 100644
80280 --- a/mm/Kconfig
80281 +++ b/mm/Kconfig
80282 @@ -311,10 +311,10 @@ config KSM
80283 root has set /sys/kernel/mm/ksm/run to 1 (if CONFIG_SYSFS is set).
80284
80285 config DEFAULT_MMAP_MIN_ADDR
80286 - int "Low address space to protect from user allocation"
80287 + int "Low address space to protect from user allocation"
80288 depends on MMU
80289 - default 4096
80290 - help
80291 + default 65536
80292 + help
80293 This is the portion of low virtual memory which should be protected
80294 from userspace allocation. Keeping a user from writing to low pages
80295 can help reduce the impact of kernel NULL pointer bugs.
80296 @@ -345,7 +345,7 @@ config MEMORY_FAILURE
80297
80298 config HWPOISON_INJECT
80299 tristate "HWPoison pages injector"
80300 - depends on MEMORY_FAILURE && DEBUG_KERNEL && PROC_FS
80301 + depends on MEMORY_FAILURE && DEBUG_KERNEL && PROC_FS && !GRKERNSEC
80302 select PROC_PAGE_MONITOR
80303
80304 config NOMMU_INITIAL_TRIM_EXCESS
80305 diff --git a/mm/filemap.c b/mm/filemap.c
80306 index e1979fd..dda5120 100644
80307 --- a/mm/filemap.c
80308 +++ b/mm/filemap.c
80309 @@ -1748,7 +1748,7 @@ int generic_file_mmap(struct file * file, struct vm_area_struct * vma)
80310 struct address_space *mapping = file->f_mapping;
80311
80312 if (!mapping->a_ops->readpage)
80313 - return -ENOEXEC;
80314 + return -ENODEV;
80315 file_accessed(file);
80316 vma->vm_ops = &generic_file_vm_ops;
80317 return 0;
80318 @@ -2088,6 +2088,7 @@ inline int generic_write_checks(struct file *file, loff_t *pos, size_t *count, i
80319 *pos = i_size_read(inode);
80320
80321 if (limit != RLIM_INFINITY) {
80322 + gr_learn_resource(current, RLIMIT_FSIZE,*pos, 0);
80323 if (*pos >= limit) {
80324 send_sig(SIGXFSZ, current, 0);
80325 return -EFBIG;
80326 diff --git a/mm/fremap.c b/mm/fremap.c
80327 index 87da359..3f41cb1 100644
80328 --- a/mm/fremap.c
80329 +++ b/mm/fremap.c
80330 @@ -158,6 +158,11 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size,
80331 retry:
80332 vma = find_vma(mm, start);
80333
80334 +#ifdef CONFIG_PAX_SEGMEXEC
80335 + if (vma && (mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_flags & VM_MAYEXEC))
80336 + goto out;
80337 +#endif
80338 +
80339 /*
80340 * Make sure the vma is shared, that it supports prefaulting,
80341 * and that the remapped range is valid and fully within
80342 diff --git a/mm/highmem.c b/mm/highmem.c
80343 index b32b70c..e512eb0 100644
80344 --- a/mm/highmem.c
80345 +++ b/mm/highmem.c
80346 @@ -138,8 +138,9 @@ static void flush_all_zero_pkmaps(void)
80347 * So no dangers, even with speculative execution.
80348 */
80349 page = pte_page(pkmap_page_table[i]);
80350 + pax_open_kernel();
80351 pte_clear(&init_mm, PKMAP_ADDR(i), &pkmap_page_table[i]);
80352 -
80353 + pax_close_kernel();
80354 set_page_address(page, NULL);
80355 need_flush = 1;
80356 }
80357 @@ -198,9 +199,11 @@ start:
80358 }
80359 }
80360 vaddr = PKMAP_ADDR(last_pkmap_nr);
80361 +
80362 + pax_open_kernel();
80363 set_pte_at(&init_mm, vaddr,
80364 &(pkmap_page_table[last_pkmap_nr]), mk_pte(page, kmap_prot));
80365 -
80366 + pax_close_kernel();
80367 pkmap_count[last_pkmap_nr] = 1;
80368 set_page_address(page, (void *)vaddr);
80369
80370 diff --git a/mm/huge_memory.c b/mm/huge_memory.c
80371 index e2f7f5aa..a4510d4 100644
80372 --- a/mm/huge_memory.c
80373 +++ b/mm/huge_memory.c
80374 @@ -2318,7 +2318,12 @@ static void collapse_huge_page(struct mm_struct *mm,
80375 pte_unmap(pte);
80376 spin_lock(&mm->page_table_lock);
80377 BUG_ON(!pmd_none(*pmd));
80378 - set_pmd_at(mm, address, pmd, _pmd);
80379 + /*
80380 + * We can only use set_pmd_at when establishing
80381 + * hugepmds and never for establishing regular pmds that
80382 + * points to regular pagetables. Use pmd_populate for that
80383 + */
80384 + pmd_populate(mm, pmd, pmd_pgtable(_pmd));
80385 spin_unlock(&mm->page_table_lock);
80386 anon_vma_unlock_write(vma->anon_vma);
80387 goto out;
80388 diff --git a/mm/hugetlb.c b/mm/hugetlb.c
80389 index 1a12f5b..a85b8fc 100644
80390 --- a/mm/hugetlb.c
80391 +++ b/mm/hugetlb.c
80392 @@ -2005,15 +2005,17 @@ static int hugetlb_sysctl_handler_common(bool obey_mempolicy,
80393 struct hstate *h = &default_hstate;
80394 unsigned long tmp;
80395 int ret;
80396 + ctl_table_no_const hugetlb_table;
80397
80398 tmp = h->max_huge_pages;
80399
80400 if (write && h->order >= MAX_ORDER)
80401 return -EINVAL;
80402
80403 - table->data = &tmp;
80404 - table->maxlen = sizeof(unsigned long);
80405 - ret = proc_doulongvec_minmax(table, write, buffer, length, ppos);
80406 + hugetlb_table = *table;
80407 + hugetlb_table.data = &tmp;
80408 + hugetlb_table.maxlen = sizeof(unsigned long);
80409 + ret = proc_doulongvec_minmax(&hugetlb_table, write, buffer, length, ppos);
80410 if (ret)
80411 goto out;
80412
80413 @@ -2070,15 +2072,17 @@ int hugetlb_overcommit_handler(struct ctl_table *table, int write,
80414 struct hstate *h = &default_hstate;
80415 unsigned long tmp;
80416 int ret;
80417 + ctl_table_no_const hugetlb_table;
80418
80419 tmp = h->nr_overcommit_huge_pages;
80420
80421 if (write && h->order >= MAX_ORDER)
80422 return -EINVAL;
80423
80424 - table->data = &tmp;
80425 - table->maxlen = sizeof(unsigned long);
80426 - ret = proc_doulongvec_minmax(table, write, buffer, length, ppos);
80427 + hugetlb_table = *table;
80428 + hugetlb_table.data = &tmp;
80429 + hugetlb_table.maxlen = sizeof(unsigned long);
80430 + ret = proc_doulongvec_minmax(&hugetlb_table, write, buffer, length, ppos);
80431 if (ret)
80432 goto out;
80433
80434 @@ -2512,6 +2516,27 @@ static int unmap_ref_private(struct mm_struct *mm, struct vm_area_struct *vma,
80435 return 1;
80436 }
80437
80438 +#ifdef CONFIG_PAX_SEGMEXEC
80439 +static void pax_mirror_huge_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m)
80440 +{
80441 + struct mm_struct *mm = vma->vm_mm;
80442 + struct vm_area_struct *vma_m;
80443 + unsigned long address_m;
80444 + pte_t *ptep_m;
80445 +
80446 + vma_m = pax_find_mirror_vma(vma);
80447 + if (!vma_m)
80448 + return;
80449 +
80450 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
80451 + address_m = address + SEGMEXEC_TASK_SIZE;
80452 + ptep_m = huge_pte_offset(mm, address_m & HPAGE_MASK);
80453 + get_page(page_m);
80454 + hugepage_add_anon_rmap(page_m, vma_m, address_m);
80455 + set_huge_pte_at(mm, address_m, ptep_m, make_huge_pte(vma_m, page_m, 0));
80456 +}
80457 +#endif
80458 +
80459 /*
80460 * Hugetlb_cow() should be called with page lock of the original hugepage held.
80461 * Called with hugetlb_instantiation_mutex held and pte_page locked so we
80462 @@ -2630,6 +2655,11 @@ retry_avoidcopy:
80463 make_huge_pte(vma, new_page, 1));
80464 page_remove_rmap(old_page);
80465 hugepage_add_new_anon_rmap(new_page, vma, address);
80466 +
80467 +#ifdef CONFIG_PAX_SEGMEXEC
80468 + pax_mirror_huge_pte(vma, address, new_page);
80469 +#endif
80470 +
80471 /* Make the old page be freed below */
80472 new_page = old_page;
80473 }
80474 @@ -2788,6 +2818,10 @@ retry:
80475 && (vma->vm_flags & VM_SHARED)));
80476 set_huge_pte_at(mm, address, ptep, new_pte);
80477
80478 +#ifdef CONFIG_PAX_SEGMEXEC
80479 + pax_mirror_huge_pte(vma, address, page);
80480 +#endif
80481 +
80482 if ((flags & FAULT_FLAG_WRITE) && !(vma->vm_flags & VM_SHARED)) {
80483 /* Optimization, do the COW without a second fault */
80484 ret = hugetlb_cow(mm, vma, address, ptep, new_pte, page);
80485 @@ -2817,6 +2851,10 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
80486 static DEFINE_MUTEX(hugetlb_instantiation_mutex);
80487 struct hstate *h = hstate_vma(vma);
80488
80489 +#ifdef CONFIG_PAX_SEGMEXEC
80490 + struct vm_area_struct *vma_m;
80491 +#endif
80492 +
80493 address &= huge_page_mask(h);
80494
80495 ptep = huge_pte_offset(mm, address);
80496 @@ -2830,6 +2868,26 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
80497 VM_FAULT_SET_HINDEX(hstate_index(h));
80498 }
80499
80500 +#ifdef CONFIG_PAX_SEGMEXEC
80501 + vma_m = pax_find_mirror_vma(vma);
80502 + if (vma_m) {
80503 + unsigned long address_m;
80504 +
80505 + if (vma->vm_start > vma_m->vm_start) {
80506 + address_m = address;
80507 + address -= SEGMEXEC_TASK_SIZE;
80508 + vma = vma_m;
80509 + h = hstate_vma(vma);
80510 + } else
80511 + address_m = address + SEGMEXEC_TASK_SIZE;
80512 +
80513 + if (!huge_pte_alloc(mm, address_m, huge_page_size(h)))
80514 + return VM_FAULT_OOM;
80515 + address_m &= HPAGE_MASK;
80516 + unmap_hugepage_range(vma, address_m, address_m + HPAGE_SIZE, NULL);
80517 + }
80518 +#endif
80519 +
80520 ptep = huge_pte_alloc(mm, address, huge_page_size(h));
80521 if (!ptep)
80522 return VM_FAULT_OOM;
80523 diff --git a/mm/internal.h b/mm/internal.h
80524 index 8562de0..7fdfe92 100644
80525 --- a/mm/internal.h
80526 +++ b/mm/internal.h
80527 @@ -100,6 +100,7 @@ extern pmd_t *mm_find_pmd(struct mm_struct *mm, unsigned long address);
80528 * in mm/page_alloc.c
80529 */
80530 extern void __free_pages_bootmem(struct page *page, unsigned int order);
80531 +extern void free_compound_page(struct page *page);
80532 extern void prep_compound_page(struct page *page, unsigned long order);
80533 #ifdef CONFIG_MEMORY_FAILURE
80534 extern bool is_free_buddy_page(struct page *page);
80535 diff --git a/mm/kmemleak.c b/mm/kmemleak.c
80536 index c8d7f31..2dbeffd 100644
80537 --- a/mm/kmemleak.c
80538 +++ b/mm/kmemleak.c
80539 @@ -363,7 +363,7 @@ static void print_unreferenced(struct seq_file *seq,
80540
80541 for (i = 0; i < object->trace_len; i++) {
80542 void *ptr = (void *)object->trace[i];
80543 - seq_printf(seq, " [<%p>] %pS\n", ptr, ptr);
80544 + seq_printf(seq, " [<%pP>] %pA\n", ptr, ptr);
80545 }
80546 }
80547
80548 @@ -1851,7 +1851,7 @@ static int __init kmemleak_late_init(void)
80549 return -ENOMEM;
80550 }
80551
80552 - dentry = debugfs_create_file("kmemleak", S_IRUGO, NULL, NULL,
80553 + dentry = debugfs_create_file("kmemleak", S_IRUSR, NULL, NULL,
80554 &kmemleak_fops);
80555 if (!dentry)
80556 pr_warning("Failed to create the debugfs kmemleak file\n");
80557 diff --git a/mm/maccess.c b/mm/maccess.c
80558 index d53adf9..03a24bf 100644
80559 --- a/mm/maccess.c
80560 +++ b/mm/maccess.c
80561 @@ -26,7 +26,7 @@ long __probe_kernel_read(void *dst, const void *src, size_t size)
80562 set_fs(KERNEL_DS);
80563 pagefault_disable();
80564 ret = __copy_from_user_inatomic(dst,
80565 - (__force const void __user *)src, size);
80566 + (const void __force_user *)src, size);
80567 pagefault_enable();
80568 set_fs(old_fs);
80569
80570 @@ -53,7 +53,7 @@ long __probe_kernel_write(void *dst, const void *src, size_t size)
80571
80572 set_fs(KERNEL_DS);
80573 pagefault_disable();
80574 - ret = __copy_to_user_inatomic((__force void __user *)dst, src, size);
80575 + ret = __copy_to_user_inatomic((void __force_user *)dst, src, size);
80576 pagefault_enable();
80577 set_fs(old_fs);
80578
80579 diff --git a/mm/madvise.c b/mm/madvise.c
80580 index c58c94b..86ec14e 100644
80581 --- a/mm/madvise.c
80582 +++ b/mm/madvise.c
80583 @@ -51,6 +51,10 @@ static long madvise_behavior(struct vm_area_struct * vma,
80584 pgoff_t pgoff;
80585 unsigned long new_flags = vma->vm_flags;
80586
80587 +#ifdef CONFIG_PAX_SEGMEXEC
80588 + struct vm_area_struct *vma_m;
80589 +#endif
80590 +
80591 switch (behavior) {
80592 case MADV_NORMAL:
80593 new_flags = new_flags & ~VM_RAND_READ & ~VM_SEQ_READ;
80594 @@ -126,6 +130,13 @@ success:
80595 /*
80596 * vm_flags is protected by the mmap_sem held in write mode.
80597 */
80598 +
80599 +#ifdef CONFIG_PAX_SEGMEXEC
80600 + vma_m = pax_find_mirror_vma(vma);
80601 + if (vma_m)
80602 + vma_m->vm_flags = new_flags & ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT);
80603 +#endif
80604 +
80605 vma->vm_flags = new_flags;
80606
80607 out:
80608 @@ -274,6 +285,11 @@ static long madvise_dontneed(struct vm_area_struct * vma,
80609 struct vm_area_struct ** prev,
80610 unsigned long start, unsigned long end)
80611 {
80612 +
80613 +#ifdef CONFIG_PAX_SEGMEXEC
80614 + struct vm_area_struct *vma_m;
80615 +#endif
80616 +
80617 *prev = vma;
80618 if (vma->vm_flags & (VM_LOCKED|VM_HUGETLB|VM_PFNMAP))
80619 return -EINVAL;
80620 @@ -286,6 +302,21 @@ static long madvise_dontneed(struct vm_area_struct * vma,
80621 zap_page_range(vma, start, end - start, &details);
80622 } else
80623 zap_page_range(vma, start, end - start, NULL);
80624 +
80625 +#ifdef CONFIG_PAX_SEGMEXEC
80626 + vma_m = pax_find_mirror_vma(vma);
80627 + if (vma_m) {
80628 + if (unlikely(vma->vm_flags & VM_NONLINEAR)) {
80629 + struct zap_details details = {
80630 + .nonlinear_vma = vma_m,
80631 + .last_index = ULONG_MAX,
80632 + };
80633 + zap_page_range(vma, start + SEGMEXEC_TASK_SIZE, end - start, &details);
80634 + } else
80635 + zap_page_range(vma, start + SEGMEXEC_TASK_SIZE, end - start, NULL);
80636 + }
80637 +#endif
80638 +
80639 return 0;
80640 }
80641
80642 @@ -491,6 +522,16 @@ SYSCALL_DEFINE3(madvise, unsigned long, start, size_t, len_in, int, behavior)
80643 if (end < start)
80644 goto out;
80645
80646 +#ifdef CONFIG_PAX_SEGMEXEC
80647 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
80648 + if (end > SEGMEXEC_TASK_SIZE)
80649 + goto out;
80650 + } else
80651 +#endif
80652 +
80653 + if (end > TASK_SIZE)
80654 + goto out;
80655 +
80656 error = 0;
80657 if (end == start)
80658 goto out;
80659 diff --git a/mm/memory-failure.c b/mm/memory-failure.c
80660 index df0694c..bc95539 100644
80661 --- a/mm/memory-failure.c
80662 +++ b/mm/memory-failure.c
80663 @@ -61,7 +61,7 @@ int sysctl_memory_failure_early_kill __read_mostly = 0;
80664
80665 int sysctl_memory_failure_recovery __read_mostly = 1;
80666
80667 -atomic_long_t num_poisoned_pages __read_mostly = ATOMIC_LONG_INIT(0);
80668 +atomic_long_unchecked_t num_poisoned_pages __read_mostly = ATOMIC_LONG_INIT(0);
80669
80670 #if defined(CONFIG_HWPOISON_INJECT) || defined(CONFIG_HWPOISON_INJECT_MODULE)
80671
80672 @@ -202,7 +202,7 @@ static int kill_proc(struct task_struct *t, unsigned long addr, int trapno,
80673 pfn, t->comm, t->pid);
80674 si.si_signo = SIGBUS;
80675 si.si_errno = 0;
80676 - si.si_addr = (void *)addr;
80677 + si.si_addr = (void __user *)addr;
80678 #ifdef __ARCH_SI_TRAPNO
80679 si.si_trapno = trapno;
80680 #endif
80681 @@ -760,7 +760,7 @@ static struct page_state {
80682 unsigned long res;
80683 char *msg;
80684 int (*action)(struct page *p, unsigned long pfn);
80685 -} error_states[] = {
80686 +} __do_const error_states[] = {
80687 { reserved, reserved, "reserved kernel", me_kernel },
80688 /*
80689 * free pages are specially detected outside this table:
80690 @@ -1051,7 +1051,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
80691 nr_pages = 1 << compound_order(hpage);
80692 else /* normal page or thp */
80693 nr_pages = 1;
80694 - atomic_long_add(nr_pages, &num_poisoned_pages);
80695 + atomic_long_add_unchecked(nr_pages, &num_poisoned_pages);
80696
80697 /*
80698 * We need/can do nothing about count=0 pages.
80699 @@ -1081,7 +1081,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
80700 if (!PageHWPoison(hpage)
80701 || (hwpoison_filter(p) && TestClearPageHWPoison(p))
80702 || (p != hpage && TestSetPageHWPoison(hpage))) {
80703 - atomic_long_sub(nr_pages, &num_poisoned_pages);
80704 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
80705 return 0;
80706 }
80707 set_page_hwpoison_huge_page(hpage);
80708 @@ -1148,7 +1148,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
80709 }
80710 if (hwpoison_filter(p)) {
80711 if (TestClearPageHWPoison(p))
80712 - atomic_long_sub(nr_pages, &num_poisoned_pages);
80713 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
80714 unlock_page(hpage);
80715 put_page(hpage);
80716 return 0;
80717 @@ -1350,7 +1350,7 @@ int unpoison_memory(unsigned long pfn)
80718 return 0;
80719 }
80720 if (TestClearPageHWPoison(p))
80721 - atomic_long_sub(nr_pages, &num_poisoned_pages);
80722 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
80723 pr_info("MCE: Software-unpoisoned free page %#lx\n", pfn);
80724 return 0;
80725 }
80726 @@ -1364,7 +1364,7 @@ int unpoison_memory(unsigned long pfn)
80727 */
80728 if (TestClearPageHWPoison(page)) {
80729 pr_info("MCE: Software-unpoisoned page %#lx\n", pfn);
80730 - atomic_long_sub(nr_pages, &num_poisoned_pages);
80731 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
80732 freeit = 1;
80733 if (PageHuge(page))
80734 clear_page_hwpoison_huge_page(page);
80735 @@ -1491,7 +1491,7 @@ static int soft_offline_huge_page(struct page *page, int flags)
80736 } else {
80737 set_page_hwpoison_huge_page(hpage);
80738 dequeue_hwpoisoned_huge_page(hpage);
80739 - atomic_long_add(1 << compound_trans_order(hpage),
80740 + atomic_long_add_unchecked(1 << compound_trans_order(hpage),
80741 &num_poisoned_pages);
80742 }
80743 /* keep elevated page count for bad page */
80744 @@ -1552,11 +1552,11 @@ int soft_offline_page(struct page *page, int flags)
80745 if (PageHuge(page)) {
80746 set_page_hwpoison_huge_page(hpage);
80747 dequeue_hwpoisoned_huge_page(hpage);
80748 - atomic_long_add(1 << compound_trans_order(hpage),
80749 + atomic_long_add_unchecked(1 << compound_trans_order(hpage),
80750 &num_poisoned_pages);
80751 } else {
80752 SetPageHWPoison(page);
80753 - atomic_long_inc(&num_poisoned_pages);
80754 + atomic_long_inc_unchecked(&num_poisoned_pages);
80755 }
80756 }
80757 /* keep elevated page count for bad page */
80758 @@ -1596,7 +1596,7 @@ static int __soft_offline_page(struct page *page, int flags)
80759 put_page(page);
80760 pr_info("soft_offline: %#lx: invalidated\n", pfn);
80761 SetPageHWPoison(page);
80762 - atomic_long_inc(&num_poisoned_pages);
80763 + atomic_long_inc_unchecked(&num_poisoned_pages);
80764 return 0;
80765 }
80766
80767 @@ -1626,7 +1626,7 @@ static int __soft_offline_page(struct page *page, int flags)
80768 ret = -EIO;
80769 } else {
80770 SetPageHWPoison(page);
80771 - atomic_long_inc(&num_poisoned_pages);
80772 + atomic_long_inc_unchecked(&num_poisoned_pages);
80773 }
80774 } else {
80775 pr_info("soft offline: %#lx: isolation failed: %d, page count %d, type %lx\n",
80776 diff --git a/mm/memory.c b/mm/memory.c
80777 index ba94dec..08ffe0d 100644
80778 --- a/mm/memory.c
80779 +++ b/mm/memory.c
80780 @@ -438,6 +438,7 @@ static inline void free_pmd_range(struct mmu_gather *tlb, pud_t *pud,
80781 free_pte_range(tlb, pmd, addr);
80782 } while (pmd++, addr = next, addr != end);
80783
80784 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_PER_CPU_PGD)
80785 start &= PUD_MASK;
80786 if (start < floor)
80787 return;
80788 @@ -452,6 +453,8 @@ static inline void free_pmd_range(struct mmu_gather *tlb, pud_t *pud,
80789 pmd = pmd_offset(pud, start);
80790 pud_clear(pud);
80791 pmd_free_tlb(tlb, pmd, start);
80792 +#endif
80793 +
80794 }
80795
80796 static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
80797 @@ -471,6 +474,7 @@ static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
80798 free_pmd_range(tlb, pud, addr, next, floor, ceiling);
80799 } while (pud++, addr = next, addr != end);
80800
80801 +#if !defined(CONFIG_X86_64) || !defined(CONFIG_PAX_PER_CPU_PGD)
80802 start &= PGDIR_MASK;
80803 if (start < floor)
80804 return;
80805 @@ -485,6 +489,8 @@ static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
80806 pud = pud_offset(pgd, start);
80807 pgd_clear(pgd);
80808 pud_free_tlb(tlb, pud, start);
80809 +#endif
80810 +
80811 }
80812
80813 /*
80814 @@ -1644,12 +1650,6 @@ no_page_table:
80815 return page;
80816 }
80817
80818 -static inline int stack_guard_page(struct vm_area_struct *vma, unsigned long addr)
80819 -{
80820 - return stack_guard_page_start(vma, addr) ||
80821 - stack_guard_page_end(vma, addr+PAGE_SIZE);
80822 -}
80823 -
80824 /**
80825 * __get_user_pages() - pin user pages in memory
80826 * @tsk: task_struct of target task
80827 @@ -1736,10 +1736,10 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
80828
80829 i = 0;
80830
80831 - do {
80832 + while (nr_pages) {
80833 struct vm_area_struct *vma;
80834
80835 - vma = find_extend_vma(mm, start);
80836 + vma = find_vma(mm, start);
80837 if (!vma && in_gate_area(mm, start)) {
80838 unsigned long pg = start & PAGE_MASK;
80839 pgd_t *pgd;
80840 @@ -1788,7 +1788,7 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
80841 goto next_page;
80842 }
80843
80844 - if (!vma ||
80845 + if (!vma || start < vma->vm_start ||
80846 (vma->vm_flags & (VM_IO | VM_PFNMAP)) ||
80847 !(vm_flags & vma->vm_flags))
80848 return i ? : -EFAULT;
80849 @@ -1817,11 +1817,6 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
80850 int ret;
80851 unsigned int fault_flags = 0;
80852
80853 - /* For mlock, just skip the stack guard page. */
80854 - if (foll_flags & FOLL_MLOCK) {
80855 - if (stack_guard_page(vma, start))
80856 - goto next_page;
80857 - }
80858 if (foll_flags & FOLL_WRITE)
80859 fault_flags |= FAULT_FLAG_WRITE;
80860 if (nonblocking)
80861 @@ -1901,7 +1896,7 @@ next_page:
80862 start += page_increm * PAGE_SIZE;
80863 nr_pages -= page_increm;
80864 } while (nr_pages && start < vma->vm_end);
80865 - } while (nr_pages);
80866 + }
80867 return i;
80868 }
80869 EXPORT_SYMBOL(__get_user_pages);
80870 @@ -2108,6 +2103,10 @@ static int insert_page(struct vm_area_struct *vma, unsigned long addr,
80871 page_add_file_rmap(page);
80872 set_pte_at(mm, addr, pte, mk_pte(page, prot));
80873
80874 +#ifdef CONFIG_PAX_SEGMEXEC
80875 + pax_mirror_file_pte(vma, addr, page, ptl);
80876 +#endif
80877 +
80878 retval = 0;
80879 pte_unmap_unlock(pte, ptl);
80880 return retval;
80881 @@ -2152,9 +2151,21 @@ int vm_insert_page(struct vm_area_struct *vma, unsigned long addr,
80882 if (!page_count(page))
80883 return -EINVAL;
80884 if (!(vma->vm_flags & VM_MIXEDMAP)) {
80885 +
80886 +#ifdef CONFIG_PAX_SEGMEXEC
80887 + struct vm_area_struct *vma_m;
80888 +#endif
80889 +
80890 BUG_ON(down_read_trylock(&vma->vm_mm->mmap_sem));
80891 BUG_ON(vma->vm_flags & VM_PFNMAP);
80892 vma->vm_flags |= VM_MIXEDMAP;
80893 +
80894 +#ifdef CONFIG_PAX_SEGMEXEC
80895 + vma_m = pax_find_mirror_vma(vma);
80896 + if (vma_m)
80897 + vma_m->vm_flags |= VM_MIXEDMAP;
80898 +#endif
80899 +
80900 }
80901 return insert_page(vma, addr, page, vma->vm_page_prot);
80902 }
80903 @@ -2237,6 +2248,7 @@ int vm_insert_mixed(struct vm_area_struct *vma, unsigned long addr,
80904 unsigned long pfn)
80905 {
80906 BUG_ON(!(vma->vm_flags & VM_MIXEDMAP));
80907 + BUG_ON(vma->vm_mirror);
80908
80909 if (addr < vma->vm_start || addr >= vma->vm_end)
80910 return -EFAULT;
80911 @@ -2484,7 +2496,9 @@ static int apply_to_pmd_range(struct mm_struct *mm, pud_t *pud,
80912
80913 BUG_ON(pud_huge(*pud));
80914
80915 - pmd = pmd_alloc(mm, pud, addr);
80916 + pmd = (mm == &init_mm) ?
80917 + pmd_alloc_kernel(mm, pud, addr) :
80918 + pmd_alloc(mm, pud, addr);
80919 if (!pmd)
80920 return -ENOMEM;
80921 do {
80922 @@ -2504,7 +2518,9 @@ static int apply_to_pud_range(struct mm_struct *mm, pgd_t *pgd,
80923 unsigned long next;
80924 int err;
80925
80926 - pud = pud_alloc(mm, pgd, addr);
80927 + pud = (mm == &init_mm) ?
80928 + pud_alloc_kernel(mm, pgd, addr) :
80929 + pud_alloc(mm, pgd, addr);
80930 if (!pud)
80931 return -ENOMEM;
80932 do {
80933 @@ -2592,6 +2608,186 @@ static inline void cow_user_page(struct page *dst, struct page *src, unsigned lo
80934 copy_user_highpage(dst, src, va, vma);
80935 }
80936
80937 +#ifdef CONFIG_PAX_SEGMEXEC
80938 +static void pax_unmap_mirror_pte(struct vm_area_struct *vma, unsigned long address, pmd_t *pmd)
80939 +{
80940 + struct mm_struct *mm = vma->vm_mm;
80941 + spinlock_t *ptl;
80942 + pte_t *pte, entry;
80943 +
80944 + pte = pte_offset_map_lock(mm, pmd, address, &ptl);
80945 + entry = *pte;
80946 + if (!pte_present(entry)) {
80947 + if (!pte_none(entry)) {
80948 + BUG_ON(pte_file(entry));
80949 + free_swap_and_cache(pte_to_swp_entry(entry));
80950 + pte_clear_not_present_full(mm, address, pte, 0);
80951 + }
80952 + } else {
80953 + struct page *page;
80954 +
80955 + flush_cache_page(vma, address, pte_pfn(entry));
80956 + entry = ptep_clear_flush(vma, address, pte);
80957 + BUG_ON(pte_dirty(entry));
80958 + page = vm_normal_page(vma, address, entry);
80959 + if (page) {
80960 + update_hiwater_rss(mm);
80961 + if (PageAnon(page))
80962 + dec_mm_counter_fast(mm, MM_ANONPAGES);
80963 + else
80964 + dec_mm_counter_fast(mm, MM_FILEPAGES);
80965 + page_remove_rmap(page);
80966 + page_cache_release(page);
80967 + }
80968 + }
80969 + pte_unmap_unlock(pte, ptl);
80970 +}
80971 +
80972 +/* PaX: if vma is mirrored, synchronize the mirror's PTE
80973 + *
80974 + * the ptl of the lower mapped page is held on entry and is not released on exit
80975 + * or inside to ensure atomic changes to the PTE states (swapout, mremap, munmap, etc)
80976 + */
80977 +static void pax_mirror_anon_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl)
80978 +{
80979 + struct mm_struct *mm = vma->vm_mm;
80980 + unsigned long address_m;
80981 + spinlock_t *ptl_m;
80982 + struct vm_area_struct *vma_m;
80983 + pmd_t *pmd_m;
80984 + pte_t *pte_m, entry_m;
80985 +
80986 + BUG_ON(!page_m || !PageAnon(page_m));
80987 +
80988 + vma_m = pax_find_mirror_vma(vma);
80989 + if (!vma_m)
80990 + return;
80991 +
80992 + BUG_ON(!PageLocked(page_m));
80993 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
80994 + address_m = address + SEGMEXEC_TASK_SIZE;
80995 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
80996 + pte_m = pte_offset_map(pmd_m, address_m);
80997 + ptl_m = pte_lockptr(mm, pmd_m);
80998 + if (ptl != ptl_m) {
80999 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
81000 + if (!pte_none(*pte_m))
81001 + goto out;
81002 + }
81003 +
81004 + entry_m = pfn_pte(page_to_pfn(page_m), vma_m->vm_page_prot);
81005 + page_cache_get(page_m);
81006 + page_add_anon_rmap(page_m, vma_m, address_m);
81007 + inc_mm_counter_fast(mm, MM_ANONPAGES);
81008 + set_pte_at(mm, address_m, pte_m, entry_m);
81009 + update_mmu_cache(vma_m, address_m, pte_m);
81010 +out:
81011 + if (ptl != ptl_m)
81012 + spin_unlock(ptl_m);
81013 + pte_unmap(pte_m);
81014 + unlock_page(page_m);
81015 +}
81016 +
81017 +void pax_mirror_file_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl)
81018 +{
81019 + struct mm_struct *mm = vma->vm_mm;
81020 + unsigned long address_m;
81021 + spinlock_t *ptl_m;
81022 + struct vm_area_struct *vma_m;
81023 + pmd_t *pmd_m;
81024 + pte_t *pte_m, entry_m;
81025 +
81026 + BUG_ON(!page_m || PageAnon(page_m));
81027 +
81028 + vma_m = pax_find_mirror_vma(vma);
81029 + if (!vma_m)
81030 + return;
81031 +
81032 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
81033 + address_m = address + SEGMEXEC_TASK_SIZE;
81034 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
81035 + pte_m = pte_offset_map(pmd_m, address_m);
81036 + ptl_m = pte_lockptr(mm, pmd_m);
81037 + if (ptl != ptl_m) {
81038 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
81039 + if (!pte_none(*pte_m))
81040 + goto out;
81041 + }
81042 +
81043 + entry_m = pfn_pte(page_to_pfn(page_m), vma_m->vm_page_prot);
81044 + page_cache_get(page_m);
81045 + page_add_file_rmap(page_m);
81046 + inc_mm_counter_fast(mm, MM_FILEPAGES);
81047 + set_pte_at(mm, address_m, pte_m, entry_m);
81048 + update_mmu_cache(vma_m, address_m, pte_m);
81049 +out:
81050 + if (ptl != ptl_m)
81051 + spin_unlock(ptl_m);
81052 + pte_unmap(pte_m);
81053 +}
81054 +
81055 +static void pax_mirror_pfn_pte(struct vm_area_struct *vma, unsigned long address, unsigned long pfn_m, spinlock_t *ptl)
81056 +{
81057 + struct mm_struct *mm = vma->vm_mm;
81058 + unsigned long address_m;
81059 + spinlock_t *ptl_m;
81060 + struct vm_area_struct *vma_m;
81061 + pmd_t *pmd_m;
81062 + pte_t *pte_m, entry_m;
81063 +
81064 + vma_m = pax_find_mirror_vma(vma);
81065 + if (!vma_m)
81066 + return;
81067 +
81068 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
81069 + address_m = address + SEGMEXEC_TASK_SIZE;
81070 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
81071 + pte_m = pte_offset_map(pmd_m, address_m);
81072 + ptl_m = pte_lockptr(mm, pmd_m);
81073 + if (ptl != ptl_m) {
81074 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
81075 + if (!pte_none(*pte_m))
81076 + goto out;
81077 + }
81078 +
81079 + entry_m = pfn_pte(pfn_m, vma_m->vm_page_prot);
81080 + set_pte_at(mm, address_m, pte_m, entry_m);
81081 +out:
81082 + if (ptl != ptl_m)
81083 + spin_unlock(ptl_m);
81084 + pte_unmap(pte_m);
81085 +}
81086 +
81087 +static void pax_mirror_pte(struct vm_area_struct *vma, unsigned long address, pte_t *pte, pmd_t *pmd, spinlock_t *ptl)
81088 +{
81089 + struct page *page_m;
81090 + pte_t entry;
81091 +
81092 + if (!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC))
81093 + goto out;
81094 +
81095 + entry = *pte;
81096 + page_m = vm_normal_page(vma, address, entry);
81097 + if (!page_m)
81098 + pax_mirror_pfn_pte(vma, address, pte_pfn(entry), ptl);
81099 + else if (PageAnon(page_m)) {
81100 + if (pax_find_mirror_vma(vma)) {
81101 + pte_unmap_unlock(pte, ptl);
81102 + lock_page(page_m);
81103 + pte = pte_offset_map_lock(vma->vm_mm, pmd, address, &ptl);
81104 + if (pte_same(entry, *pte))
81105 + pax_mirror_anon_pte(vma, address, page_m, ptl);
81106 + else
81107 + unlock_page(page_m);
81108 + }
81109 + } else
81110 + pax_mirror_file_pte(vma, address, page_m, ptl);
81111 +
81112 +out:
81113 + pte_unmap_unlock(pte, ptl);
81114 +}
81115 +#endif
81116 +
81117 /*
81118 * This routine handles present pages, when users try to write
81119 * to a shared page. It is done by copying the page to a new address
81120 @@ -2808,6 +3004,12 @@ gotten:
81121 */
81122 page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
81123 if (likely(pte_same(*page_table, orig_pte))) {
81124 +
81125 +#ifdef CONFIG_PAX_SEGMEXEC
81126 + if (pax_find_mirror_vma(vma))
81127 + BUG_ON(!trylock_page(new_page));
81128 +#endif
81129 +
81130 if (old_page) {
81131 if (!PageAnon(old_page)) {
81132 dec_mm_counter_fast(mm, MM_FILEPAGES);
81133 @@ -2859,6 +3061,10 @@ gotten:
81134 page_remove_rmap(old_page);
81135 }
81136
81137 +#ifdef CONFIG_PAX_SEGMEXEC
81138 + pax_mirror_anon_pte(vma, address, new_page, ptl);
81139 +#endif
81140 +
81141 /* Free the old page.. */
81142 new_page = old_page;
81143 ret |= VM_FAULT_WRITE;
81144 @@ -3134,6 +3340,11 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
81145 swap_free(entry);
81146 if (vm_swap_full() || (vma->vm_flags & VM_LOCKED) || PageMlocked(page))
81147 try_to_free_swap(page);
81148 +
81149 +#ifdef CONFIG_PAX_SEGMEXEC
81150 + if ((flags & FAULT_FLAG_WRITE) || !pax_find_mirror_vma(vma))
81151 +#endif
81152 +
81153 unlock_page(page);
81154 if (page != swapcache) {
81155 /*
81156 @@ -3157,6 +3368,11 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
81157
81158 /* No need to invalidate - it was non-present before */
81159 update_mmu_cache(vma, address, page_table);
81160 +
81161 +#ifdef CONFIG_PAX_SEGMEXEC
81162 + pax_mirror_anon_pte(vma, address, page, ptl);
81163 +#endif
81164 +
81165 unlock:
81166 pte_unmap_unlock(page_table, ptl);
81167 out:
81168 @@ -3176,40 +3392,6 @@ out_release:
81169 }
81170
81171 /*
81172 - * This is like a special single-page "expand_{down|up}wards()",
81173 - * except we must first make sure that 'address{-|+}PAGE_SIZE'
81174 - * doesn't hit another vma.
81175 - */
81176 -static inline int check_stack_guard_page(struct vm_area_struct *vma, unsigned long address)
81177 -{
81178 - address &= PAGE_MASK;
81179 - if ((vma->vm_flags & VM_GROWSDOWN) && address == vma->vm_start) {
81180 - struct vm_area_struct *prev = vma->vm_prev;
81181 -
81182 - /*
81183 - * Is there a mapping abutting this one below?
81184 - *
81185 - * That's only ok if it's the same stack mapping
81186 - * that has gotten split..
81187 - */
81188 - if (prev && prev->vm_end == address)
81189 - return prev->vm_flags & VM_GROWSDOWN ? 0 : -ENOMEM;
81190 -
81191 - expand_downwards(vma, address - PAGE_SIZE);
81192 - }
81193 - if ((vma->vm_flags & VM_GROWSUP) && address + PAGE_SIZE == vma->vm_end) {
81194 - struct vm_area_struct *next = vma->vm_next;
81195 -
81196 - /* As VM_GROWSDOWN but s/below/above/ */
81197 - if (next && next->vm_start == address + PAGE_SIZE)
81198 - return next->vm_flags & VM_GROWSUP ? 0 : -ENOMEM;
81199 -
81200 - expand_upwards(vma, address + PAGE_SIZE);
81201 - }
81202 - return 0;
81203 -}
81204 -
81205 -/*
81206 * We enter with non-exclusive mmap_sem (to exclude vma changes,
81207 * but allow concurrent faults), and pte mapped but not yet locked.
81208 * We return with mmap_sem still held, but pte unmapped and unlocked.
81209 @@ -3218,27 +3400,23 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
81210 unsigned long address, pte_t *page_table, pmd_t *pmd,
81211 unsigned int flags)
81212 {
81213 - struct page *page;
81214 + struct page *page = NULL;
81215 spinlock_t *ptl;
81216 pte_t entry;
81217
81218 - pte_unmap(page_table);
81219 -
81220 - /* Check if we need to add a guard page to the stack */
81221 - if (check_stack_guard_page(vma, address) < 0)
81222 - return VM_FAULT_SIGBUS;
81223 -
81224 - /* Use the zero-page for reads */
81225 if (!(flags & FAULT_FLAG_WRITE)) {
81226 entry = pte_mkspecial(pfn_pte(my_zero_pfn(address),
81227 vma->vm_page_prot));
81228 - page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
81229 + ptl = pte_lockptr(mm, pmd);
81230 + spin_lock(ptl);
81231 if (!pte_none(*page_table))
81232 goto unlock;
81233 goto setpte;
81234 }
81235
81236 /* Allocate our own private page. */
81237 + pte_unmap(page_table);
81238 +
81239 if (unlikely(anon_vma_prepare(vma)))
81240 goto oom;
81241 page = alloc_zeroed_user_highpage_movable(vma, address);
81242 @@ -3257,6 +3435,11 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
81243 if (!pte_none(*page_table))
81244 goto release;
81245
81246 +#ifdef CONFIG_PAX_SEGMEXEC
81247 + if (pax_find_mirror_vma(vma))
81248 + BUG_ON(!trylock_page(page));
81249 +#endif
81250 +
81251 inc_mm_counter_fast(mm, MM_ANONPAGES);
81252 page_add_new_anon_rmap(page, vma, address);
81253 setpte:
81254 @@ -3264,6 +3447,12 @@ setpte:
81255
81256 /* No need to invalidate - it was non-present before */
81257 update_mmu_cache(vma, address, page_table);
81258 +
81259 +#ifdef CONFIG_PAX_SEGMEXEC
81260 + if (page)
81261 + pax_mirror_anon_pte(vma, address, page, ptl);
81262 +#endif
81263 +
81264 unlock:
81265 pte_unmap_unlock(page_table, ptl);
81266 return 0;
81267 @@ -3407,6 +3596,12 @@ static int __do_fault(struct mm_struct *mm, struct vm_area_struct *vma,
81268 */
81269 /* Only go through if we didn't race with anybody else... */
81270 if (likely(pte_same(*page_table, orig_pte))) {
81271 +
81272 +#ifdef CONFIG_PAX_SEGMEXEC
81273 + if (anon && pax_find_mirror_vma(vma))
81274 + BUG_ON(!trylock_page(page));
81275 +#endif
81276 +
81277 flush_icache_page(vma, page);
81278 entry = mk_pte(page, vma->vm_page_prot);
81279 if (flags & FAULT_FLAG_WRITE)
81280 @@ -3426,6 +3621,14 @@ static int __do_fault(struct mm_struct *mm, struct vm_area_struct *vma,
81281
81282 /* no need to invalidate: a not-present page won't be cached */
81283 update_mmu_cache(vma, address, page_table);
81284 +
81285 +#ifdef CONFIG_PAX_SEGMEXEC
81286 + if (anon)
81287 + pax_mirror_anon_pte(vma, address, page, ptl);
81288 + else
81289 + pax_mirror_file_pte(vma, address, page, ptl);
81290 +#endif
81291 +
81292 } else {
81293 if (cow_page)
81294 mem_cgroup_uncharge_page(cow_page);
81295 @@ -3747,6 +3950,12 @@ int handle_pte_fault(struct mm_struct *mm,
81296 if (flags & FAULT_FLAG_WRITE)
81297 flush_tlb_fix_spurious_fault(vma, address);
81298 }
81299 +
81300 +#ifdef CONFIG_PAX_SEGMEXEC
81301 + pax_mirror_pte(vma, address, pte, pmd, ptl);
81302 + return 0;
81303 +#endif
81304 +
81305 unlock:
81306 pte_unmap_unlock(pte, ptl);
81307 return 0;
81308 @@ -3763,6 +3972,10 @@ int handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,
81309 pmd_t *pmd;
81310 pte_t *pte;
81311
81312 +#ifdef CONFIG_PAX_SEGMEXEC
81313 + struct vm_area_struct *vma_m;
81314 +#endif
81315 +
81316 __set_current_state(TASK_RUNNING);
81317
81318 count_vm_event(PGFAULT);
81319 @@ -3774,6 +3987,34 @@ int handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,
81320 if (unlikely(is_vm_hugetlb_page(vma)))
81321 return hugetlb_fault(mm, vma, address, flags);
81322
81323 +#ifdef CONFIG_PAX_SEGMEXEC
81324 + vma_m = pax_find_mirror_vma(vma);
81325 + if (vma_m) {
81326 + unsigned long address_m;
81327 + pgd_t *pgd_m;
81328 + pud_t *pud_m;
81329 + pmd_t *pmd_m;
81330 +
81331 + if (vma->vm_start > vma_m->vm_start) {
81332 + address_m = address;
81333 + address -= SEGMEXEC_TASK_SIZE;
81334 + vma = vma_m;
81335 + } else
81336 + address_m = address + SEGMEXEC_TASK_SIZE;
81337 +
81338 + pgd_m = pgd_offset(mm, address_m);
81339 + pud_m = pud_alloc(mm, pgd_m, address_m);
81340 + if (!pud_m)
81341 + return VM_FAULT_OOM;
81342 + pmd_m = pmd_alloc(mm, pud_m, address_m);
81343 + if (!pmd_m)
81344 + return VM_FAULT_OOM;
81345 + if (!pmd_present(*pmd_m) && __pte_alloc(mm, vma_m, pmd_m, address_m))
81346 + return VM_FAULT_OOM;
81347 + pax_unmap_mirror_pte(vma_m, address_m, pmd_m);
81348 + }
81349 +#endif
81350 +
81351 retry:
81352 pgd = pgd_offset(mm, address);
81353 pud = pud_alloc(mm, pgd, address);
81354 @@ -3872,6 +4113,23 @@ int __pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
81355 spin_unlock(&mm->page_table_lock);
81356 return 0;
81357 }
81358 +
81359 +int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
81360 +{
81361 + pud_t *new = pud_alloc_one(mm, address);
81362 + if (!new)
81363 + return -ENOMEM;
81364 +
81365 + smp_wmb(); /* See comment in __pte_alloc */
81366 +
81367 + spin_lock(&mm->page_table_lock);
81368 + if (pgd_present(*pgd)) /* Another has populated it */
81369 + pud_free(mm, new);
81370 + else
81371 + pgd_populate_kernel(mm, pgd, new);
81372 + spin_unlock(&mm->page_table_lock);
81373 + return 0;
81374 +}
81375 #endif /* __PAGETABLE_PUD_FOLDED */
81376
81377 #ifndef __PAGETABLE_PMD_FOLDED
81378 @@ -3902,6 +4160,30 @@ int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
81379 spin_unlock(&mm->page_table_lock);
81380 return 0;
81381 }
81382 +
81383 +int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address)
81384 +{
81385 + pmd_t *new = pmd_alloc_one(mm, address);
81386 + if (!new)
81387 + return -ENOMEM;
81388 +
81389 + smp_wmb(); /* See comment in __pte_alloc */
81390 +
81391 + spin_lock(&mm->page_table_lock);
81392 +#ifndef __ARCH_HAS_4LEVEL_HACK
81393 + if (pud_present(*pud)) /* Another has populated it */
81394 + pmd_free(mm, new);
81395 + else
81396 + pud_populate_kernel(mm, pud, new);
81397 +#else
81398 + if (pgd_present(*pud)) /* Another has populated it */
81399 + pmd_free(mm, new);
81400 + else
81401 + pgd_populate_kernel(mm, pud, new);
81402 +#endif /* __ARCH_HAS_4LEVEL_HACK */
81403 + spin_unlock(&mm->page_table_lock);
81404 + return 0;
81405 +}
81406 #endif /* __PAGETABLE_PMD_FOLDED */
81407
81408 #if !defined(__HAVE_ARCH_GATE_AREA)
81409 @@ -3915,7 +4197,7 @@ static int __init gate_vma_init(void)
81410 gate_vma.vm_start = FIXADDR_USER_START;
81411 gate_vma.vm_end = FIXADDR_USER_END;
81412 gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;
81413 - gate_vma.vm_page_prot = __P101;
81414 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
81415
81416 return 0;
81417 }
81418 @@ -4049,8 +4331,8 @@ out:
81419 return ret;
81420 }
81421
81422 -int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
81423 - void *buf, int len, int write)
81424 +ssize_t generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
81425 + void *buf, size_t len, int write)
81426 {
81427 resource_size_t phys_addr;
81428 unsigned long prot = 0;
81429 @@ -4075,8 +4357,8 @@ int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
81430 * Access another process' address space as given in mm. If non-NULL, use the
81431 * given task for page fault accounting.
81432 */
81433 -static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
81434 - unsigned long addr, void *buf, int len, int write)
81435 +static ssize_t __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
81436 + unsigned long addr, void *buf, size_t len, int write)
81437 {
81438 struct vm_area_struct *vma;
81439 void *old_buf = buf;
81440 @@ -4084,7 +4366,7 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
81441 down_read(&mm->mmap_sem);
81442 /* ignore errors, just check how much was successfully transferred */
81443 while (len) {
81444 - int bytes, ret, offset;
81445 + ssize_t bytes, ret, offset;
81446 void *maddr;
81447 struct page *page = NULL;
81448
81449 @@ -4143,8 +4425,8 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
81450 *
81451 * The caller must hold a reference on @mm.
81452 */
81453 -int access_remote_vm(struct mm_struct *mm, unsigned long addr,
81454 - void *buf, int len, int write)
81455 +ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
81456 + void *buf, size_t len, int write)
81457 {
81458 return __access_remote_vm(NULL, mm, addr, buf, len, write);
81459 }
81460 @@ -4154,11 +4436,11 @@ int access_remote_vm(struct mm_struct *mm, unsigned long addr,
81461 * Source/target buffer must be kernel space,
81462 * Do not walk the page table directly, use get_user_pages
81463 */
81464 -int access_process_vm(struct task_struct *tsk, unsigned long addr,
81465 - void *buf, int len, int write)
81466 +ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr,
81467 + void *buf, size_t len, int write)
81468 {
81469 struct mm_struct *mm;
81470 - int ret;
81471 + ssize_t ret;
81472
81473 mm = get_task_mm(tsk);
81474 if (!mm)
81475 diff --git a/mm/mempolicy.c b/mm/mempolicy.c
81476 index 7431001..0f8344e 100644
81477 --- a/mm/mempolicy.c
81478 +++ b/mm/mempolicy.c
81479 @@ -708,6 +708,10 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
81480 unsigned long vmstart;
81481 unsigned long vmend;
81482
81483 +#ifdef CONFIG_PAX_SEGMEXEC
81484 + struct vm_area_struct *vma_m;
81485 +#endif
81486 +
81487 vma = find_vma(mm, start);
81488 if (!vma || vma->vm_start > start)
81489 return -EFAULT;
81490 @@ -744,9 +748,20 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
81491 if (err)
81492 goto out;
81493 }
81494 +
81495 err = vma_replace_policy(vma, new_pol);
81496 if (err)
81497 goto out;
81498 +
81499 +#ifdef CONFIG_PAX_SEGMEXEC
81500 + vma_m = pax_find_mirror_vma(vma);
81501 + if (vma_m) {
81502 + err = vma_replace_policy(vma_m, new_pol);
81503 + if (err)
81504 + goto out;
81505 + }
81506 +#endif
81507 +
81508 }
81509
81510 out:
81511 @@ -1202,6 +1217,17 @@ static long do_mbind(unsigned long start, unsigned long len,
81512
81513 if (end < start)
81514 return -EINVAL;
81515 +
81516 +#ifdef CONFIG_PAX_SEGMEXEC
81517 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
81518 + if (end > SEGMEXEC_TASK_SIZE)
81519 + return -EINVAL;
81520 + } else
81521 +#endif
81522 +
81523 + if (end > TASK_SIZE)
81524 + return -EINVAL;
81525 +
81526 if (end == start)
81527 return 0;
81528
81529 @@ -1430,8 +1456,7 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
81530 */
81531 tcred = __task_cred(task);
81532 if (!uid_eq(cred->euid, tcred->suid) && !uid_eq(cred->euid, tcred->uid) &&
81533 - !uid_eq(cred->uid, tcred->suid) && !uid_eq(cred->uid, tcred->uid) &&
81534 - !capable(CAP_SYS_NICE)) {
81535 + !uid_eq(cred->uid, tcred->suid) && !capable(CAP_SYS_NICE)) {
81536 rcu_read_unlock();
81537 err = -EPERM;
81538 goto out_put;
81539 @@ -1462,6 +1487,15 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
81540 goto out;
81541 }
81542
81543 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
81544 + if (mm != current->mm &&
81545 + (mm->pax_flags & MF_PAX_RANDMMAP || mm->pax_flags & MF_PAX_SEGMEXEC)) {
81546 + mmput(mm);
81547 + err = -EPERM;
81548 + goto out;
81549 + }
81550 +#endif
81551 +
81552 err = do_migrate_pages(mm, old, new,
81553 capable(CAP_SYS_NICE) ? MPOL_MF_MOVE_ALL : MPOL_MF_MOVE);
81554
81555 diff --git a/mm/migrate.c b/mm/migrate.c
81556 index 3bbaf5d..299b0e9 100644
81557 --- a/mm/migrate.c
81558 +++ b/mm/migrate.c
81559 @@ -1382,8 +1382,7 @@ SYSCALL_DEFINE6(move_pages, pid_t, pid, unsigned long, nr_pages,
81560 */
81561 tcred = __task_cred(task);
81562 if (!uid_eq(cred->euid, tcred->suid) && !uid_eq(cred->euid, tcred->uid) &&
81563 - !uid_eq(cred->uid, tcred->suid) && !uid_eq(cred->uid, tcred->uid) &&
81564 - !capable(CAP_SYS_NICE)) {
81565 + !uid_eq(cred->uid, tcred->suid) && !capable(CAP_SYS_NICE)) {
81566 rcu_read_unlock();
81567 err = -EPERM;
81568 goto out;
81569 diff --git a/mm/mlock.c b/mm/mlock.c
81570 index 79b7cf7..9944291 100644
81571 --- a/mm/mlock.c
81572 +++ b/mm/mlock.c
81573 @@ -13,6 +13,7 @@
81574 #include <linux/pagemap.h>
81575 #include <linux/mempolicy.h>
81576 #include <linux/syscalls.h>
81577 +#include <linux/security.h>
81578 #include <linux/sched.h>
81579 #include <linux/export.h>
81580 #include <linux/rmap.h>
81581 @@ -334,7 +335,7 @@ static int do_mlock(unsigned long start, size_t len, int on)
81582 {
81583 unsigned long nstart, end, tmp;
81584 struct vm_area_struct * vma, * prev;
81585 - int error;
81586 + int error = 0;
81587
81588 VM_BUG_ON(start & ~PAGE_MASK);
81589 VM_BUG_ON(len != PAGE_ALIGN(len));
81590 @@ -343,6 +344,9 @@ static int do_mlock(unsigned long start, size_t len, int on)
81591 return -EINVAL;
81592 if (end == start)
81593 return 0;
81594 + if (end > TASK_SIZE)
81595 + return -EINVAL;
81596 +
81597 vma = find_vma(current->mm, start);
81598 if (!vma || vma->vm_start > start)
81599 return -ENOMEM;
81600 @@ -354,6 +358,11 @@ static int do_mlock(unsigned long start, size_t len, int on)
81601 for (nstart = start ; ; ) {
81602 vm_flags_t newflags;
81603
81604 +#ifdef CONFIG_PAX_SEGMEXEC
81605 + if ((current->mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE))
81606 + break;
81607 +#endif
81608 +
81609 /* Here we know that vma->vm_start <= nstart < vma->vm_end. */
81610
81611 newflags = vma->vm_flags & ~VM_LOCKED;
81612 @@ -466,6 +475,7 @@ SYSCALL_DEFINE2(mlock, unsigned long, start, size_t, len)
81613 lock_limit >>= PAGE_SHIFT;
81614
81615 /* check against resource limits */
81616 + gr_learn_resource(current, RLIMIT_MEMLOCK, (current->mm->locked_vm << PAGE_SHIFT) + len, 1);
81617 if ((locked <= lock_limit) || capable(CAP_IPC_LOCK))
81618 error = do_mlock(start, len, 1);
81619 up_write(&current->mm->mmap_sem);
81620 @@ -500,6 +510,11 @@ static int do_mlockall(int flags)
81621 for (vma = current->mm->mmap; vma ; vma = prev->vm_next) {
81622 vm_flags_t newflags;
81623
81624 +#ifdef CONFIG_PAX_SEGMEXEC
81625 + if ((current->mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE))
81626 + break;
81627 +#endif
81628 +
81629 newflags = vma->vm_flags & ~VM_LOCKED;
81630 if (flags & MCL_CURRENT)
81631 newflags |= VM_LOCKED;
81632 @@ -532,6 +547,7 @@ SYSCALL_DEFINE1(mlockall, int, flags)
81633 lock_limit >>= PAGE_SHIFT;
81634
81635 ret = -ENOMEM;
81636 + gr_learn_resource(current, RLIMIT_MEMLOCK, current->mm->total_vm << PAGE_SHIFT, 1);
81637 if (!(flags & MCL_CURRENT) || (current->mm->total_vm <= lock_limit) ||
81638 capable(CAP_IPC_LOCK))
81639 ret = do_mlockall(flags);
81640 diff --git a/mm/mmap.c b/mm/mmap.c
81641 index 0dceed8..671951c 100644
81642 --- a/mm/mmap.c
81643 +++ b/mm/mmap.c
81644 @@ -33,6 +33,7 @@
81645 #include <linux/uprobes.h>
81646 #include <linux/rbtree_augmented.h>
81647 #include <linux/sched/sysctl.h>
81648 +#include <linux/random.h>
81649
81650 #include <asm/uaccess.h>
81651 #include <asm/cacheflush.h>
81652 @@ -49,6 +50,16 @@
81653 #define arch_rebalance_pgtables(addr, len) (addr)
81654 #endif
81655
81656 +static inline void verify_mm_writelocked(struct mm_struct *mm)
81657 +{
81658 +#if defined(CONFIG_DEBUG_VM) || defined(CONFIG_PAX)
81659 + if (unlikely(down_read_trylock(&mm->mmap_sem))) {
81660 + up_read(&mm->mmap_sem);
81661 + BUG();
81662 + }
81663 +#endif
81664 +}
81665 +
81666 static void unmap_region(struct mm_struct *mm,
81667 struct vm_area_struct *vma, struct vm_area_struct *prev,
81668 unsigned long start, unsigned long end);
81669 @@ -68,22 +79,32 @@ static void unmap_region(struct mm_struct *mm,
81670 * x: (no) no x: (no) yes x: (no) yes x: (yes) yes
81671 *
81672 */
81673 -pgprot_t protection_map[16] = {
81674 +pgprot_t protection_map[16] __read_only = {
81675 __P000, __P001, __P010, __P011, __P100, __P101, __P110, __P111,
81676 __S000, __S001, __S010, __S011, __S100, __S101, __S110, __S111
81677 };
81678
81679 -pgprot_t vm_get_page_prot(unsigned long vm_flags)
81680 +pgprot_t vm_get_page_prot(vm_flags_t vm_flags)
81681 {
81682 - return __pgprot(pgprot_val(protection_map[vm_flags &
81683 + pgprot_t prot = __pgprot(pgprot_val(protection_map[vm_flags &
81684 (VM_READ|VM_WRITE|VM_EXEC|VM_SHARED)]) |
81685 pgprot_val(arch_vm_get_page_prot(vm_flags)));
81686 +
81687 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
81688 + if (!(__supported_pte_mask & _PAGE_NX) &&
81689 + (vm_flags & (VM_PAGEEXEC | VM_EXEC)) == VM_PAGEEXEC &&
81690 + (vm_flags & (VM_READ | VM_WRITE)))
81691 + prot = __pgprot(pte_val(pte_exprotect(__pte(pgprot_val(prot)))));
81692 +#endif
81693 +
81694 + return prot;
81695 }
81696 EXPORT_SYMBOL(vm_get_page_prot);
81697
81698 int sysctl_overcommit_memory __read_mostly = OVERCOMMIT_GUESS; /* heuristic overcommit */
81699 int sysctl_overcommit_ratio __read_mostly = 50; /* default is 50% */
81700 int sysctl_max_map_count __read_mostly = DEFAULT_MAX_MAP_COUNT;
81701 +unsigned long sysctl_heap_stack_gap __read_mostly = 64*1024;
81702 /*
81703 * Make sure vm_committed_as in one cacheline and not cacheline shared with
81704 * other variables. It can be updated by several CPUs frequently.
81705 @@ -239,6 +260,7 @@ static struct vm_area_struct *remove_vma(struct vm_area_struct *vma)
81706 struct vm_area_struct *next = vma->vm_next;
81707
81708 might_sleep();
81709 + BUG_ON(vma->vm_mirror);
81710 if (vma->vm_ops && vma->vm_ops->close)
81711 vma->vm_ops->close(vma);
81712 if (vma->vm_file)
81713 @@ -283,6 +305,7 @@ SYSCALL_DEFINE1(brk, unsigned long, brk)
81714 * not page aligned -Ram Gupta
81715 */
81716 rlim = rlimit(RLIMIT_DATA);
81717 + gr_learn_resource(current, RLIMIT_DATA, (brk - mm->start_brk) + (mm->end_data - mm->start_data), 1);
81718 if (rlim < RLIM_INFINITY && (brk - mm->start_brk) +
81719 (mm->end_data - mm->start_data) > rlim)
81720 goto out;
81721 @@ -897,6 +920,12 @@ static int
81722 can_vma_merge_before(struct vm_area_struct *vma, unsigned long vm_flags,
81723 struct anon_vma *anon_vma, struct file *file, pgoff_t vm_pgoff)
81724 {
81725 +
81726 +#ifdef CONFIG_PAX_SEGMEXEC
81727 + if ((vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_start == SEGMEXEC_TASK_SIZE)
81728 + return 0;
81729 +#endif
81730 +
81731 if (is_mergeable_vma(vma, file, vm_flags) &&
81732 is_mergeable_anon_vma(anon_vma, vma->anon_vma, vma)) {
81733 if (vma->vm_pgoff == vm_pgoff)
81734 @@ -916,6 +945,12 @@ static int
81735 can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags,
81736 struct anon_vma *anon_vma, struct file *file, pgoff_t vm_pgoff)
81737 {
81738 +
81739 +#ifdef CONFIG_PAX_SEGMEXEC
81740 + if ((vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_end == SEGMEXEC_TASK_SIZE)
81741 + return 0;
81742 +#endif
81743 +
81744 if (is_mergeable_vma(vma, file, vm_flags) &&
81745 is_mergeable_anon_vma(anon_vma, vma->anon_vma, vma)) {
81746 pgoff_t vm_pglen;
81747 @@ -958,13 +993,20 @@ can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags,
81748 struct vm_area_struct *vma_merge(struct mm_struct *mm,
81749 struct vm_area_struct *prev, unsigned long addr,
81750 unsigned long end, unsigned long vm_flags,
81751 - struct anon_vma *anon_vma, struct file *file,
81752 + struct anon_vma *anon_vma, struct file *file,
81753 pgoff_t pgoff, struct mempolicy *policy)
81754 {
81755 pgoff_t pglen = (end - addr) >> PAGE_SHIFT;
81756 struct vm_area_struct *area, *next;
81757 int err;
81758
81759 +#ifdef CONFIG_PAX_SEGMEXEC
81760 + unsigned long addr_m = addr + SEGMEXEC_TASK_SIZE, end_m = end + SEGMEXEC_TASK_SIZE;
81761 + struct vm_area_struct *area_m = NULL, *next_m = NULL, *prev_m = NULL;
81762 +
81763 + BUG_ON((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE < end);
81764 +#endif
81765 +
81766 /*
81767 * We later require that vma->vm_flags == vm_flags,
81768 * so this tests vma->vm_flags & VM_SPECIAL, too.
81769 @@ -980,6 +1022,15 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
81770 if (next && next->vm_end == end) /* cases 6, 7, 8 */
81771 next = next->vm_next;
81772
81773 +#ifdef CONFIG_PAX_SEGMEXEC
81774 + if (prev)
81775 + prev_m = pax_find_mirror_vma(prev);
81776 + if (area)
81777 + area_m = pax_find_mirror_vma(area);
81778 + if (next)
81779 + next_m = pax_find_mirror_vma(next);
81780 +#endif
81781 +
81782 /*
81783 * Can it merge with the predecessor?
81784 */
81785 @@ -999,9 +1050,24 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
81786 /* cases 1, 6 */
81787 err = vma_adjust(prev, prev->vm_start,
81788 next->vm_end, prev->vm_pgoff, NULL);
81789 - } else /* cases 2, 5, 7 */
81790 +
81791 +#ifdef CONFIG_PAX_SEGMEXEC
81792 + if (!err && prev_m)
81793 + err = vma_adjust(prev_m, prev_m->vm_start,
81794 + next_m->vm_end, prev_m->vm_pgoff, NULL);
81795 +#endif
81796 +
81797 + } else { /* cases 2, 5, 7 */
81798 err = vma_adjust(prev, prev->vm_start,
81799 end, prev->vm_pgoff, NULL);
81800 +
81801 +#ifdef CONFIG_PAX_SEGMEXEC
81802 + if (!err && prev_m)
81803 + err = vma_adjust(prev_m, prev_m->vm_start,
81804 + end_m, prev_m->vm_pgoff, NULL);
81805 +#endif
81806 +
81807 + }
81808 if (err)
81809 return NULL;
81810 khugepaged_enter_vma_merge(prev);
81811 @@ -1015,12 +1081,27 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
81812 mpol_equal(policy, vma_policy(next)) &&
81813 can_vma_merge_before(next, vm_flags,
81814 anon_vma, file, pgoff+pglen)) {
81815 - if (prev && addr < prev->vm_end) /* case 4 */
81816 + if (prev && addr < prev->vm_end) { /* case 4 */
81817 err = vma_adjust(prev, prev->vm_start,
81818 addr, prev->vm_pgoff, NULL);
81819 - else /* cases 3, 8 */
81820 +
81821 +#ifdef CONFIG_PAX_SEGMEXEC
81822 + if (!err && prev_m)
81823 + err = vma_adjust(prev_m, prev_m->vm_start,
81824 + addr_m, prev_m->vm_pgoff, NULL);
81825 +#endif
81826 +
81827 + } else { /* cases 3, 8 */
81828 err = vma_adjust(area, addr, next->vm_end,
81829 next->vm_pgoff - pglen, NULL);
81830 +
81831 +#ifdef CONFIG_PAX_SEGMEXEC
81832 + if (!err && area_m)
81833 + err = vma_adjust(area_m, addr_m, next_m->vm_end,
81834 + next_m->vm_pgoff - pglen, NULL);
81835 +#endif
81836 +
81837 + }
81838 if (err)
81839 return NULL;
81840 khugepaged_enter_vma_merge(area);
81841 @@ -1129,8 +1210,10 @@ none:
81842 void vm_stat_account(struct mm_struct *mm, unsigned long flags,
81843 struct file *file, long pages)
81844 {
81845 - const unsigned long stack_flags
81846 - = VM_STACK_FLAGS & (VM_GROWSUP|VM_GROWSDOWN);
81847 +
81848 +#ifdef CONFIG_PAX_RANDMMAP
81849 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
81850 +#endif
81851
81852 mm->total_vm += pages;
81853
81854 @@ -1138,7 +1221,7 @@ void vm_stat_account(struct mm_struct *mm, unsigned long flags,
81855 mm->shared_vm += pages;
81856 if ((flags & (VM_EXEC|VM_WRITE)) == VM_EXEC)
81857 mm->exec_vm += pages;
81858 - } else if (flags & stack_flags)
81859 + } else if (flags & (VM_GROWSUP|VM_GROWSDOWN))
81860 mm->stack_vm += pages;
81861 }
81862 #endif /* CONFIG_PROC_FS */
81863 @@ -1177,7 +1260,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
81864 * (the exception is when the underlying filesystem is noexec
81865 * mounted, in which case we dont add PROT_EXEC.)
81866 */
81867 - if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
81868 + if ((prot & (PROT_READ | PROT_WRITE)) && (current->personality & READ_IMPLIES_EXEC))
81869 if (!(file && (file->f_path.mnt->mnt_flags & MNT_NOEXEC)))
81870 prot |= PROT_EXEC;
81871
81872 @@ -1203,7 +1286,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
81873 /* Obtain the address to map to. we verify (or select) it and ensure
81874 * that it represents a valid section of the address space.
81875 */
81876 - addr = get_unmapped_area(file, addr, len, pgoff, flags);
81877 + addr = get_unmapped_area(file, addr, len, pgoff, flags | ((prot & PROT_EXEC) ? MAP_EXECUTABLE : 0));
81878 if (addr & ~PAGE_MASK)
81879 return addr;
81880
81881 @@ -1214,6 +1297,36 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
81882 vm_flags = calc_vm_prot_bits(prot) | calc_vm_flag_bits(flags) |
81883 mm->def_flags | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC;
81884
81885 +#ifdef CONFIG_PAX_MPROTECT
81886 + if (mm->pax_flags & MF_PAX_MPROTECT) {
81887 +#ifndef CONFIG_PAX_MPROTECT_COMPAT
81888 + if ((vm_flags & (VM_WRITE | VM_EXEC)) == (VM_WRITE | VM_EXEC)) {
81889 + gr_log_rwxmmap(file);
81890 +
81891 +#ifdef CONFIG_PAX_EMUPLT
81892 + vm_flags &= ~VM_EXEC;
81893 +#else
81894 + return -EPERM;
81895 +#endif
81896 +
81897 + }
81898 +
81899 + if (!(vm_flags & VM_EXEC))
81900 + vm_flags &= ~VM_MAYEXEC;
81901 +#else
81902 + if ((vm_flags & (VM_WRITE | VM_EXEC)) != VM_EXEC)
81903 + vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
81904 +#endif
81905 + else
81906 + vm_flags &= ~VM_MAYWRITE;
81907 + }
81908 +#endif
81909 +
81910 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
81911 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && file)
81912 + vm_flags &= ~VM_PAGEEXEC;
81913 +#endif
81914 +
81915 if (flags & MAP_LOCKED)
81916 if (!can_do_mlock())
81917 return -EPERM;
81918 @@ -1225,6 +1338,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
81919 locked += mm->locked_vm;
81920 lock_limit = rlimit(RLIMIT_MEMLOCK);
81921 lock_limit >>= PAGE_SHIFT;
81922 + gr_learn_resource(current, RLIMIT_MEMLOCK, locked << PAGE_SHIFT, 1);
81923 if (locked > lock_limit && !capable(CAP_IPC_LOCK))
81924 return -EAGAIN;
81925 }
81926 @@ -1305,6 +1419,9 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
81927 vm_flags |= VM_NORESERVE;
81928 }
81929
81930 + if (!gr_acl_handle_mmap(file, prot))
81931 + return -EACCES;
81932 +
81933 addr = mmap_region(file, addr, len, vm_flags, pgoff);
81934 if (!IS_ERR_VALUE(addr) &&
81935 ((vm_flags & VM_LOCKED) ||
81936 @@ -1396,7 +1513,7 @@ int vma_wants_writenotify(struct vm_area_struct *vma)
81937 vm_flags_t vm_flags = vma->vm_flags;
81938
81939 /* If it was private or non-writable, the write bit is already clear */
81940 - if ((vm_flags & (VM_WRITE|VM_SHARED)) != ((VM_WRITE|VM_SHARED)))
81941 + if ((vm_flags & (VM_WRITE|VM_SHARED)) != (VM_WRITE|VM_SHARED))
81942 return 0;
81943
81944 /* The backer wishes to know when pages are first written to? */
81945 @@ -1444,16 +1561,30 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
81946 unsigned long charged = 0;
81947 struct inode *inode = file ? file_inode(file) : NULL;
81948
81949 +#ifdef CONFIG_PAX_SEGMEXEC
81950 + struct vm_area_struct *vma_m = NULL;
81951 +#endif
81952 +
81953 + /*
81954 + * mm->mmap_sem is required to protect against another thread
81955 + * changing the mappings in case we sleep.
81956 + */
81957 + verify_mm_writelocked(mm);
81958 +
81959 /* Clear old maps */
81960 error = -ENOMEM;
81961 -munmap_back:
81962 if (find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent)) {
81963 if (do_munmap(mm, addr, len))
81964 return -ENOMEM;
81965 - goto munmap_back;
81966 + BUG_ON(find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent));
81967 }
81968
81969 /* Check against address space limit. */
81970 +
81971 +#ifdef CONFIG_PAX_RANDMMAP
81972 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (vm_flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
81973 +#endif
81974 +
81975 if (!may_expand_vm(mm, len >> PAGE_SHIFT))
81976 return -ENOMEM;
81977
81978 @@ -1485,6 +1616,16 @@ munmap_back:
81979 goto unacct_error;
81980 }
81981
81982 +#ifdef CONFIG_PAX_SEGMEXEC
81983 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vm_flags & VM_EXEC)) {
81984 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
81985 + if (!vma_m) {
81986 + error = -ENOMEM;
81987 + goto free_vma;
81988 + }
81989 + }
81990 +#endif
81991 +
81992 vma->vm_mm = mm;
81993 vma->vm_start = addr;
81994 vma->vm_end = addr + len;
81995 @@ -1509,6 +1650,13 @@ munmap_back:
81996 if (error)
81997 goto unmap_and_free_vma;
81998
81999 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
82000 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && !(vma->vm_flags & VM_SPECIAL)) {
82001 + vma->vm_flags |= VM_PAGEEXEC;
82002 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
82003 + }
82004 +#endif
82005 +
82006 /* Can addr have changed??
82007 *
82008 * Answer: Yes, several device drivers can do it in their
82009 @@ -1547,6 +1695,11 @@ munmap_back:
82010 vma_link(mm, vma, prev, rb_link, rb_parent);
82011 file = vma->vm_file;
82012
82013 +#ifdef CONFIG_PAX_SEGMEXEC
82014 + if (vma_m)
82015 + BUG_ON(pax_mirror_vma(vma_m, vma));
82016 +#endif
82017 +
82018 /* Once vma denies write, undo our temporary denial count */
82019 if (correct_wcount)
82020 atomic_inc(&inode->i_writecount);
82021 @@ -1554,6 +1707,7 @@ out:
82022 perf_event_mmap(vma);
82023
82024 vm_stat_account(mm, vm_flags, file, len >> PAGE_SHIFT);
82025 + track_exec_limit(mm, addr, addr + len, vm_flags);
82026 if (vm_flags & VM_LOCKED) {
82027 if (!((vm_flags & VM_SPECIAL) || is_vm_hugetlb_page(vma) ||
82028 vma == get_gate_vma(current->mm)))
82029 @@ -1577,6 +1731,12 @@ unmap_and_free_vma:
82030 unmap_region(mm, vma, prev, vma->vm_start, vma->vm_end);
82031 charged = 0;
82032 free_vma:
82033 +
82034 +#ifdef CONFIG_PAX_SEGMEXEC
82035 + if (vma_m)
82036 + kmem_cache_free(vm_area_cachep, vma_m);
82037 +#endif
82038 +
82039 kmem_cache_free(vm_area_cachep, vma);
82040 unacct_error:
82041 if (charged)
82042 @@ -1584,6 +1744,62 @@ unacct_error:
82043 return error;
82044 }
82045
82046 +#ifdef CONFIG_GRKERNSEC_RAND_THREADSTACK
82047 +unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags)
82048 +{
82049 + if ((mm->pax_flags & MF_PAX_RANDMMAP) && !filp && (flags & MAP_STACK))
82050 + return (random32() & 0xFF) << PAGE_SHIFT;
82051 +
82052 + return 0;
82053 +}
82054 +#endif
82055 +
82056 +bool check_heap_stack_gap(const struct vm_area_struct *vma, unsigned long addr, unsigned long len, unsigned long offset)
82057 +{
82058 + if (!vma) {
82059 +#ifdef CONFIG_STACK_GROWSUP
82060 + if (addr > sysctl_heap_stack_gap)
82061 + vma = find_vma(current->mm, addr - sysctl_heap_stack_gap);
82062 + else
82063 + vma = find_vma(current->mm, 0);
82064 + if (vma && (vma->vm_flags & VM_GROWSUP))
82065 + return false;
82066 +#endif
82067 + return true;
82068 + }
82069 +
82070 + if (addr + len > vma->vm_start)
82071 + return false;
82072 +
82073 + if (vma->vm_flags & VM_GROWSDOWN)
82074 + return sysctl_heap_stack_gap <= vma->vm_start - addr - len;
82075 +#ifdef CONFIG_STACK_GROWSUP
82076 + else if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP))
82077 + return addr - vma->vm_prev->vm_end <= sysctl_heap_stack_gap;
82078 +#endif
82079 + else if (offset)
82080 + return offset <= vma->vm_start - addr - len;
82081 +
82082 + return true;
82083 +}
82084 +
82085 +unsigned long skip_heap_stack_gap(const struct vm_area_struct *vma, unsigned long len, unsigned long offset)
82086 +{
82087 + if (vma->vm_start < len)
82088 + return -ENOMEM;
82089 +
82090 + if (!(vma->vm_flags & VM_GROWSDOWN)) {
82091 + if (offset <= vma->vm_start - len)
82092 + return vma->vm_start - len - offset;
82093 + else
82094 + return -ENOMEM;
82095 + }
82096 +
82097 + if (sysctl_heap_stack_gap <= vma->vm_start - len)
82098 + return vma->vm_start - len - sysctl_heap_stack_gap;
82099 + return -ENOMEM;
82100 +}
82101 +
82102 unsigned long unmapped_area(struct vm_unmapped_area_info *info)
82103 {
82104 /*
82105 @@ -1803,6 +2019,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
82106 struct mm_struct *mm = current->mm;
82107 struct vm_area_struct *vma;
82108 struct vm_unmapped_area_info info;
82109 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
82110
82111 if (len > TASK_SIZE)
82112 return -ENOMEM;
82113 @@ -1810,29 +2027,45 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
82114 if (flags & MAP_FIXED)
82115 return addr;
82116
82117 +#ifdef CONFIG_PAX_RANDMMAP
82118 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
82119 +#endif
82120 +
82121 if (addr) {
82122 addr = PAGE_ALIGN(addr);
82123 vma = find_vma(mm, addr);
82124 - if (TASK_SIZE - len >= addr &&
82125 - (!vma || addr + len <= vma->vm_start))
82126 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
82127 return addr;
82128 }
82129
82130 info.flags = 0;
82131 info.length = len;
82132 info.low_limit = TASK_UNMAPPED_BASE;
82133 +
82134 +#ifdef CONFIG_PAX_RANDMMAP
82135 + if (mm->pax_flags & MF_PAX_RANDMMAP)
82136 + info.low_limit += mm->delta_mmap;
82137 +#endif
82138 +
82139 info.high_limit = TASK_SIZE;
82140 info.align_mask = 0;
82141 + info.threadstack_offset = offset;
82142 return vm_unmapped_area(&info);
82143 }
82144 #endif
82145
82146 void arch_unmap_area(struct mm_struct *mm, unsigned long addr)
82147 {
82148 +
82149 +#ifdef CONFIG_PAX_SEGMEXEC
82150 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE <= addr)
82151 + return;
82152 +#endif
82153 +
82154 /*
82155 * Is this a new hole at the lowest possible address?
82156 */
82157 - if (addr >= TASK_UNMAPPED_BASE && addr < mm->free_area_cache)
82158 + if (addr >= mm->mmap_base && addr < mm->free_area_cache)
82159 mm->free_area_cache = addr;
82160 }
82161
82162 @@ -1850,6 +2083,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
82163 struct mm_struct *mm = current->mm;
82164 unsigned long addr = addr0;
82165 struct vm_unmapped_area_info info;
82166 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
82167
82168 /* requested length too big for entire address space */
82169 if (len > TASK_SIZE)
82170 @@ -1858,12 +2092,15 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
82171 if (flags & MAP_FIXED)
82172 return addr;
82173
82174 +#ifdef CONFIG_PAX_RANDMMAP
82175 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
82176 +#endif
82177 +
82178 /* requesting a specific address */
82179 if (addr) {
82180 addr = PAGE_ALIGN(addr);
82181 vma = find_vma(mm, addr);
82182 - if (TASK_SIZE - len >= addr &&
82183 - (!vma || addr + len <= vma->vm_start))
82184 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
82185 return addr;
82186 }
82187
82188 @@ -1872,6 +2109,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
82189 info.low_limit = PAGE_SIZE;
82190 info.high_limit = mm->mmap_base;
82191 info.align_mask = 0;
82192 + info.threadstack_offset = offset;
82193 addr = vm_unmapped_area(&info);
82194
82195 /*
82196 @@ -1884,6 +2122,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
82197 VM_BUG_ON(addr != -ENOMEM);
82198 info.flags = 0;
82199 info.low_limit = TASK_UNMAPPED_BASE;
82200 +
82201 +#ifdef CONFIG_PAX_RANDMMAP
82202 + if (mm->pax_flags & MF_PAX_RANDMMAP)
82203 + info.low_limit += mm->delta_mmap;
82204 +#endif
82205 +
82206 info.high_limit = TASK_SIZE;
82207 addr = vm_unmapped_area(&info);
82208 }
82209 @@ -1894,6 +2138,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
82210
82211 void arch_unmap_area_topdown(struct mm_struct *mm, unsigned long addr)
82212 {
82213 +
82214 +#ifdef CONFIG_PAX_SEGMEXEC
82215 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE <= addr)
82216 + return;
82217 +#endif
82218 +
82219 /*
82220 * Is this a new hole at the highest possible address?
82221 */
82222 @@ -1901,8 +2151,10 @@ void arch_unmap_area_topdown(struct mm_struct *mm, unsigned long addr)
82223 mm->free_area_cache = addr;
82224
82225 /* dont allow allocations above current base */
82226 - if (mm->free_area_cache > mm->mmap_base)
82227 + if (mm->free_area_cache > mm->mmap_base) {
82228 mm->free_area_cache = mm->mmap_base;
82229 + mm->cached_hole_size = ~0UL;
82230 + }
82231 }
82232
82233 unsigned long
82234 @@ -2001,6 +2253,28 @@ find_vma_prev(struct mm_struct *mm, unsigned long addr,
82235 return vma;
82236 }
82237
82238 +#ifdef CONFIG_PAX_SEGMEXEC
82239 +struct vm_area_struct *pax_find_mirror_vma(struct vm_area_struct *vma)
82240 +{
82241 + struct vm_area_struct *vma_m;
82242 +
82243 + BUG_ON(!vma || vma->vm_start >= vma->vm_end);
82244 + if (!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) || !(vma->vm_flags & VM_EXEC)) {
82245 + BUG_ON(vma->vm_mirror);
82246 + return NULL;
82247 + }
82248 + BUG_ON(vma->vm_start < SEGMEXEC_TASK_SIZE && SEGMEXEC_TASK_SIZE < vma->vm_end);
82249 + vma_m = vma->vm_mirror;
82250 + BUG_ON(!vma_m || vma_m->vm_mirror != vma);
82251 + BUG_ON(vma->vm_file != vma_m->vm_file);
82252 + BUG_ON(vma->vm_end - vma->vm_start != vma_m->vm_end - vma_m->vm_start);
82253 + BUG_ON(vma->vm_pgoff != vma_m->vm_pgoff);
82254 + BUG_ON(vma->anon_vma != vma_m->anon_vma && vma->anon_vma->root != vma_m->anon_vma->root);
82255 + BUG_ON((vma->vm_flags ^ vma_m->vm_flags) & ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT | VM_LOCKED));
82256 + return vma_m;
82257 +}
82258 +#endif
82259 +
82260 /*
82261 * Verify that the stack growth is acceptable and
82262 * update accounting. This is shared with both the
82263 @@ -2017,6 +2291,7 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
82264 return -ENOMEM;
82265
82266 /* Stack limit test */
82267 + gr_learn_resource(current, RLIMIT_STACK, size, 1);
82268 if (size > ACCESS_ONCE(rlim[RLIMIT_STACK].rlim_cur))
82269 return -ENOMEM;
82270
82271 @@ -2027,6 +2302,7 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
82272 locked = mm->locked_vm + grow;
82273 limit = ACCESS_ONCE(rlim[RLIMIT_MEMLOCK].rlim_cur);
82274 limit >>= PAGE_SHIFT;
82275 + gr_learn_resource(current, RLIMIT_MEMLOCK, locked << PAGE_SHIFT, 1);
82276 if (locked > limit && !capable(CAP_IPC_LOCK))
82277 return -ENOMEM;
82278 }
82279 @@ -2056,37 +2332,48 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
82280 * PA-RISC uses this for its stack; IA64 for its Register Backing Store.
82281 * vma is the last one with address > vma->vm_end. Have to extend vma.
82282 */
82283 +#ifndef CONFIG_IA64
82284 +static
82285 +#endif
82286 int expand_upwards(struct vm_area_struct *vma, unsigned long address)
82287 {
82288 int error;
82289 + bool locknext;
82290
82291 if (!(vma->vm_flags & VM_GROWSUP))
82292 return -EFAULT;
82293
82294 + /* Also guard against wrapping around to address 0. */
82295 + if (address < PAGE_ALIGN(address+1))
82296 + address = PAGE_ALIGN(address+1);
82297 + else
82298 + return -ENOMEM;
82299 +
82300 /*
82301 * We must make sure the anon_vma is allocated
82302 * so that the anon_vma locking is not a noop.
82303 */
82304 if (unlikely(anon_vma_prepare(vma)))
82305 return -ENOMEM;
82306 + locknext = vma->vm_next && (vma->vm_next->vm_flags & VM_GROWSDOWN);
82307 + if (locknext && anon_vma_prepare(vma->vm_next))
82308 + return -ENOMEM;
82309 vma_lock_anon_vma(vma);
82310 + if (locknext)
82311 + vma_lock_anon_vma(vma->vm_next);
82312
82313 /*
82314 * vma->vm_start/vm_end cannot change under us because the caller
82315 * is required to hold the mmap_sem in read mode. We need the
82316 - * anon_vma lock to serialize against concurrent expand_stacks.
82317 - * Also guard against wrapping around to address 0.
82318 + * anon_vma locks to serialize against concurrent expand_stacks
82319 + * and expand_upwards.
82320 */
82321 - if (address < PAGE_ALIGN(address+4))
82322 - address = PAGE_ALIGN(address+4);
82323 - else {
82324 - vma_unlock_anon_vma(vma);
82325 - return -ENOMEM;
82326 - }
82327 error = 0;
82328
82329 /* Somebody else might have raced and expanded it already */
82330 - if (address > vma->vm_end) {
82331 + 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)
82332 + error = -ENOMEM;
82333 + else if (address > vma->vm_end && (!locknext || vma->vm_next->vm_start >= address)) {
82334 unsigned long size, grow;
82335
82336 size = address - vma->vm_start;
82337 @@ -2121,6 +2408,8 @@ int expand_upwards(struct vm_area_struct *vma, unsigned long address)
82338 }
82339 }
82340 }
82341 + if (locknext)
82342 + vma_unlock_anon_vma(vma->vm_next);
82343 vma_unlock_anon_vma(vma);
82344 khugepaged_enter_vma_merge(vma);
82345 validate_mm(vma->vm_mm);
82346 @@ -2135,6 +2424,8 @@ int expand_downwards(struct vm_area_struct *vma,
82347 unsigned long address)
82348 {
82349 int error;
82350 + bool lockprev = false;
82351 + struct vm_area_struct *prev;
82352
82353 /*
82354 * We must make sure the anon_vma is allocated
82355 @@ -2148,6 +2439,15 @@ int expand_downwards(struct vm_area_struct *vma,
82356 if (error)
82357 return error;
82358
82359 + prev = vma->vm_prev;
82360 +#if defined(CONFIG_STACK_GROWSUP) || defined(CONFIG_IA64)
82361 + lockprev = prev && (prev->vm_flags & VM_GROWSUP);
82362 +#endif
82363 + if (lockprev && anon_vma_prepare(prev))
82364 + return -ENOMEM;
82365 + if (lockprev)
82366 + vma_lock_anon_vma(prev);
82367 +
82368 vma_lock_anon_vma(vma);
82369
82370 /*
82371 @@ -2157,9 +2457,17 @@ int expand_downwards(struct vm_area_struct *vma,
82372 */
82373
82374 /* Somebody else might have raced and expanded it already */
82375 - if (address < vma->vm_start) {
82376 + if (prev && (prev->vm_flags & (VM_READ | VM_WRITE | VM_EXEC)) && address - prev->vm_end < sysctl_heap_stack_gap)
82377 + error = -ENOMEM;
82378 + else if (address < vma->vm_start && (!lockprev || prev->vm_end <= address)) {
82379 unsigned long size, grow;
82380
82381 +#ifdef CONFIG_PAX_SEGMEXEC
82382 + struct vm_area_struct *vma_m;
82383 +
82384 + vma_m = pax_find_mirror_vma(vma);
82385 +#endif
82386 +
82387 size = vma->vm_end - address;
82388 grow = (vma->vm_start - address) >> PAGE_SHIFT;
82389
82390 @@ -2184,6 +2492,18 @@ int expand_downwards(struct vm_area_struct *vma,
82391 vma->vm_pgoff -= grow;
82392 anon_vma_interval_tree_post_update_vma(vma);
82393 vma_gap_update(vma);
82394 + track_exec_limit(vma->vm_mm, vma->vm_start, vma->vm_end, vma->vm_flags);
82395 +
82396 +#ifdef CONFIG_PAX_SEGMEXEC
82397 + if (vma_m) {
82398 + anon_vma_interval_tree_pre_update_vma(vma_m);
82399 + vma_m->vm_start -= grow << PAGE_SHIFT;
82400 + vma_m->vm_pgoff -= grow;
82401 + anon_vma_interval_tree_post_update_vma(vma_m);
82402 + vma_gap_update(vma_m);
82403 + }
82404 +#endif
82405 +
82406 spin_unlock(&vma->vm_mm->page_table_lock);
82407
82408 perf_event_mmap(vma);
82409 @@ -2288,6 +2608,13 @@ static void remove_vma_list(struct mm_struct *mm, struct vm_area_struct *vma)
82410 do {
82411 long nrpages = vma_pages(vma);
82412
82413 +#ifdef CONFIG_PAX_SEGMEXEC
82414 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE)) {
82415 + vma = remove_vma(vma);
82416 + continue;
82417 + }
82418 +#endif
82419 +
82420 if (vma->vm_flags & VM_ACCOUNT)
82421 nr_accounted += nrpages;
82422 vm_stat_account(mm, vma->vm_flags, vma->vm_file, -nrpages);
82423 @@ -2333,6 +2660,16 @@ detach_vmas_to_be_unmapped(struct mm_struct *mm, struct vm_area_struct *vma,
82424 insertion_point = (prev ? &prev->vm_next : &mm->mmap);
82425 vma->vm_prev = NULL;
82426 do {
82427 +
82428 +#ifdef CONFIG_PAX_SEGMEXEC
82429 + if (vma->vm_mirror) {
82430 + BUG_ON(!vma->vm_mirror->vm_mirror || vma->vm_mirror->vm_mirror != vma);
82431 + vma->vm_mirror->vm_mirror = NULL;
82432 + vma->vm_mirror->vm_flags &= ~VM_EXEC;
82433 + vma->vm_mirror = NULL;
82434 + }
82435 +#endif
82436 +
82437 vma_rb_erase(vma, &mm->mm_rb);
82438 mm->map_count--;
82439 tail_vma = vma;
82440 @@ -2364,14 +2701,33 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
82441 struct vm_area_struct *new;
82442 int err = -ENOMEM;
82443
82444 +#ifdef CONFIG_PAX_SEGMEXEC
82445 + struct vm_area_struct *vma_m, *new_m = NULL;
82446 + unsigned long addr_m = addr + SEGMEXEC_TASK_SIZE;
82447 +#endif
82448 +
82449 if (is_vm_hugetlb_page(vma) && (addr &
82450 ~(huge_page_mask(hstate_vma(vma)))))
82451 return -EINVAL;
82452
82453 +#ifdef CONFIG_PAX_SEGMEXEC
82454 + vma_m = pax_find_mirror_vma(vma);
82455 +#endif
82456 +
82457 new = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
82458 if (!new)
82459 goto out_err;
82460
82461 +#ifdef CONFIG_PAX_SEGMEXEC
82462 + if (vma_m) {
82463 + new_m = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
82464 + if (!new_m) {
82465 + kmem_cache_free(vm_area_cachep, new);
82466 + goto out_err;
82467 + }
82468 + }
82469 +#endif
82470 +
82471 /* most fields are the same, copy all, and then fixup */
82472 *new = *vma;
82473
82474 @@ -2384,6 +2740,22 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
82475 new->vm_pgoff += ((addr - vma->vm_start) >> PAGE_SHIFT);
82476 }
82477
82478 +#ifdef CONFIG_PAX_SEGMEXEC
82479 + if (vma_m) {
82480 + *new_m = *vma_m;
82481 + INIT_LIST_HEAD(&new_m->anon_vma_chain);
82482 + new_m->vm_mirror = new;
82483 + new->vm_mirror = new_m;
82484 +
82485 + if (new_below)
82486 + new_m->vm_end = addr_m;
82487 + else {
82488 + new_m->vm_start = addr_m;
82489 + new_m->vm_pgoff += ((addr_m - vma_m->vm_start) >> PAGE_SHIFT);
82490 + }
82491 + }
82492 +#endif
82493 +
82494 pol = mpol_dup(vma_policy(vma));
82495 if (IS_ERR(pol)) {
82496 err = PTR_ERR(pol);
82497 @@ -2406,6 +2778,36 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
82498 else
82499 err = vma_adjust(vma, vma->vm_start, addr, vma->vm_pgoff, new);
82500
82501 +#ifdef CONFIG_PAX_SEGMEXEC
82502 + if (!err && vma_m) {
82503 + if (anon_vma_clone(new_m, vma_m))
82504 + goto out_free_mpol;
82505 +
82506 + mpol_get(pol);
82507 + vma_set_policy(new_m, pol);
82508 +
82509 + if (new_m->vm_file)
82510 + get_file(new_m->vm_file);
82511 +
82512 + if (new_m->vm_ops && new_m->vm_ops->open)
82513 + new_m->vm_ops->open(new_m);
82514 +
82515 + if (new_below)
82516 + err = vma_adjust(vma_m, addr_m, vma_m->vm_end, vma_m->vm_pgoff +
82517 + ((addr_m - new_m->vm_start) >> PAGE_SHIFT), new_m);
82518 + else
82519 + err = vma_adjust(vma_m, vma_m->vm_start, addr_m, vma_m->vm_pgoff, new_m);
82520 +
82521 + if (err) {
82522 + if (new_m->vm_ops && new_m->vm_ops->close)
82523 + new_m->vm_ops->close(new_m);
82524 + if (new_m->vm_file)
82525 + fput(new_m->vm_file);
82526 + mpol_put(pol);
82527 + }
82528 + }
82529 +#endif
82530 +
82531 /* Success. */
82532 if (!err)
82533 return 0;
82534 @@ -2415,10 +2817,18 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
82535 new->vm_ops->close(new);
82536 if (new->vm_file)
82537 fput(new->vm_file);
82538 - unlink_anon_vmas(new);
82539 out_free_mpol:
82540 mpol_put(pol);
82541 out_free_vma:
82542 +
82543 +#ifdef CONFIG_PAX_SEGMEXEC
82544 + if (new_m) {
82545 + unlink_anon_vmas(new_m);
82546 + kmem_cache_free(vm_area_cachep, new_m);
82547 + }
82548 +#endif
82549 +
82550 + unlink_anon_vmas(new);
82551 kmem_cache_free(vm_area_cachep, new);
82552 out_err:
82553 return err;
82554 @@ -2431,6 +2841,15 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
82555 int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
82556 unsigned long addr, int new_below)
82557 {
82558 +
82559 +#ifdef CONFIG_PAX_SEGMEXEC
82560 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
82561 + BUG_ON(vma->vm_end > SEGMEXEC_TASK_SIZE);
82562 + if (mm->map_count >= sysctl_max_map_count-1)
82563 + return -ENOMEM;
82564 + } else
82565 +#endif
82566 +
82567 if (mm->map_count >= sysctl_max_map_count)
82568 return -ENOMEM;
82569
82570 @@ -2442,11 +2861,30 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
82571 * work. This now handles partial unmappings.
82572 * Jeremy Fitzhardinge <jeremy@goop.org>
82573 */
82574 +#ifdef CONFIG_PAX_SEGMEXEC
82575 int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
82576 {
82577 + int ret = __do_munmap(mm, start, len);
82578 + if (ret || !(mm->pax_flags & MF_PAX_SEGMEXEC))
82579 + return ret;
82580 +
82581 + return __do_munmap(mm, start + SEGMEXEC_TASK_SIZE, len);
82582 +}
82583 +
82584 +int __do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
82585 +#else
82586 +int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
82587 +#endif
82588 +{
82589 unsigned long end;
82590 struct vm_area_struct *vma, *prev, *last;
82591
82592 + /*
82593 + * mm->mmap_sem is required to protect against another thread
82594 + * changing the mappings in case we sleep.
82595 + */
82596 + verify_mm_writelocked(mm);
82597 +
82598 if ((start & ~PAGE_MASK) || start > TASK_SIZE || len > TASK_SIZE-start)
82599 return -EINVAL;
82600
82601 @@ -2521,6 +2959,8 @@ int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
82602 /* Fix up all other VM information */
82603 remove_vma_list(mm, vma);
82604
82605 + track_exec_limit(mm, start, end, 0UL);
82606 +
82607 return 0;
82608 }
82609
82610 @@ -2529,6 +2969,13 @@ int vm_munmap(unsigned long start, size_t len)
82611 int ret;
82612 struct mm_struct *mm = current->mm;
82613
82614 +
82615 +#ifdef CONFIG_PAX_SEGMEXEC
82616 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) &&
82617 + (len > SEGMEXEC_TASK_SIZE || start > SEGMEXEC_TASK_SIZE-len))
82618 + return -EINVAL;
82619 +#endif
82620 +
82621 down_write(&mm->mmap_sem);
82622 ret = do_munmap(mm, start, len);
82623 up_write(&mm->mmap_sem);
82624 @@ -2542,16 +2989,6 @@ SYSCALL_DEFINE2(munmap, unsigned long, addr, size_t, len)
82625 return vm_munmap(addr, len);
82626 }
82627
82628 -static inline void verify_mm_writelocked(struct mm_struct *mm)
82629 -{
82630 -#ifdef CONFIG_DEBUG_VM
82631 - if (unlikely(down_read_trylock(&mm->mmap_sem))) {
82632 - WARN_ON(1);
82633 - up_read(&mm->mmap_sem);
82634 - }
82635 -#endif
82636 -}
82637 -
82638 /*
82639 * this is really a simplified "do_mmap". it only handles
82640 * anonymous maps. eventually we may be able to do some
82641 @@ -2565,6 +3002,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
82642 struct rb_node ** rb_link, * rb_parent;
82643 pgoff_t pgoff = addr >> PAGE_SHIFT;
82644 int error;
82645 + unsigned long charged;
82646
82647 len = PAGE_ALIGN(len);
82648 if (!len)
82649 @@ -2572,16 +3010,30 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
82650
82651 flags = VM_DATA_DEFAULT_FLAGS | VM_ACCOUNT | mm->def_flags;
82652
82653 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
82654 + if (mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
82655 + flags &= ~VM_EXEC;
82656 +
82657 +#ifdef CONFIG_PAX_MPROTECT
82658 + if (mm->pax_flags & MF_PAX_MPROTECT)
82659 + flags &= ~VM_MAYEXEC;
82660 +#endif
82661 +
82662 + }
82663 +#endif
82664 +
82665 error = get_unmapped_area(NULL, addr, len, 0, MAP_FIXED);
82666 if (error & ~PAGE_MASK)
82667 return error;
82668
82669 + charged = len >> PAGE_SHIFT;
82670 +
82671 /*
82672 * mlock MCL_FUTURE?
82673 */
82674 if (mm->def_flags & VM_LOCKED) {
82675 unsigned long locked, lock_limit;
82676 - locked = len >> PAGE_SHIFT;
82677 + locked = charged;
82678 locked += mm->locked_vm;
82679 lock_limit = rlimit(RLIMIT_MEMLOCK);
82680 lock_limit >>= PAGE_SHIFT;
82681 @@ -2598,21 +3050,20 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
82682 /*
82683 * Clear old maps. this also does some error checking for us
82684 */
82685 - munmap_back:
82686 if (find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent)) {
82687 if (do_munmap(mm, addr, len))
82688 return -ENOMEM;
82689 - goto munmap_back;
82690 + BUG_ON(find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent));
82691 }
82692
82693 /* Check against address space limits *after* clearing old maps... */
82694 - if (!may_expand_vm(mm, len >> PAGE_SHIFT))
82695 + if (!may_expand_vm(mm, charged))
82696 return -ENOMEM;
82697
82698 if (mm->map_count > sysctl_max_map_count)
82699 return -ENOMEM;
82700
82701 - if (security_vm_enough_memory_mm(mm, len >> PAGE_SHIFT))
82702 + if (security_vm_enough_memory_mm(mm, charged))
82703 return -ENOMEM;
82704
82705 /* Can we just expand an old private anonymous mapping? */
82706 @@ -2626,7 +3077,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
82707 */
82708 vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
82709 if (!vma) {
82710 - vm_unacct_memory(len >> PAGE_SHIFT);
82711 + vm_unacct_memory(charged);
82712 return -ENOMEM;
82713 }
82714
82715 @@ -2640,9 +3091,10 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
82716 vma_link(mm, vma, prev, rb_link, rb_parent);
82717 out:
82718 perf_event_mmap(vma);
82719 - mm->total_vm += len >> PAGE_SHIFT;
82720 + mm->total_vm += charged;
82721 if (flags & VM_LOCKED)
82722 - mm->locked_vm += (len >> PAGE_SHIFT);
82723 + mm->locked_vm += charged;
82724 + track_exec_limit(mm, addr, addr + len, flags);
82725 return addr;
82726 }
82727
82728 @@ -2704,6 +3156,7 @@ void exit_mmap(struct mm_struct *mm)
82729 while (vma) {
82730 if (vma->vm_flags & VM_ACCOUNT)
82731 nr_accounted += vma_pages(vma);
82732 + vma->vm_mirror = NULL;
82733 vma = remove_vma(vma);
82734 }
82735 vm_unacct_memory(nr_accounted);
82736 @@ -2720,6 +3173,13 @@ int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
82737 struct vm_area_struct *prev;
82738 struct rb_node **rb_link, *rb_parent;
82739
82740 +#ifdef CONFIG_PAX_SEGMEXEC
82741 + struct vm_area_struct *vma_m = NULL;
82742 +#endif
82743 +
82744 + if (security_mmap_addr(vma->vm_start))
82745 + return -EPERM;
82746 +
82747 /*
82748 * The vm_pgoff of a purely anonymous vma should be irrelevant
82749 * until its first write fault, when page's anon_vma and index
82750 @@ -2743,7 +3203,21 @@ int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
82751 security_vm_enough_memory_mm(mm, vma_pages(vma)))
82752 return -ENOMEM;
82753
82754 +#ifdef CONFIG_PAX_SEGMEXEC
82755 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_flags & VM_EXEC)) {
82756 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
82757 + if (!vma_m)
82758 + return -ENOMEM;
82759 + }
82760 +#endif
82761 +
82762 vma_link(mm, vma, prev, rb_link, rb_parent);
82763 +
82764 +#ifdef CONFIG_PAX_SEGMEXEC
82765 + if (vma_m)
82766 + BUG_ON(pax_mirror_vma(vma_m, vma));
82767 +#endif
82768 +
82769 return 0;
82770 }
82771
82772 @@ -2763,6 +3237,8 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
82773 struct mempolicy *pol;
82774 bool faulted_in_anon_vma = true;
82775
82776 + BUG_ON(vma->vm_mirror);
82777 +
82778 /*
82779 * If anonymous vma has not yet been faulted, update new pgoff
82780 * to match new location, to increase its chance of merging.
82781 @@ -2829,6 +3305,39 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
82782 return NULL;
82783 }
82784
82785 +#ifdef CONFIG_PAX_SEGMEXEC
82786 +long pax_mirror_vma(struct vm_area_struct *vma_m, struct vm_area_struct *vma)
82787 +{
82788 + struct vm_area_struct *prev_m;
82789 + struct rb_node **rb_link_m, *rb_parent_m;
82790 + struct mempolicy *pol_m;
82791 +
82792 + BUG_ON(!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) || !(vma->vm_flags & VM_EXEC));
82793 + BUG_ON(vma->vm_mirror || vma_m->vm_mirror);
82794 + BUG_ON(!mpol_equal(vma_policy(vma), vma_policy(vma_m)));
82795 + *vma_m = *vma;
82796 + INIT_LIST_HEAD(&vma_m->anon_vma_chain);
82797 + if (anon_vma_clone(vma_m, vma))
82798 + return -ENOMEM;
82799 + pol_m = vma_policy(vma_m);
82800 + mpol_get(pol_m);
82801 + vma_set_policy(vma_m, pol_m);
82802 + vma_m->vm_start += SEGMEXEC_TASK_SIZE;
82803 + vma_m->vm_end += SEGMEXEC_TASK_SIZE;
82804 + vma_m->vm_flags &= ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT | VM_LOCKED);
82805 + vma_m->vm_page_prot = vm_get_page_prot(vma_m->vm_flags);
82806 + if (vma_m->vm_file)
82807 + get_file(vma_m->vm_file);
82808 + if (vma_m->vm_ops && vma_m->vm_ops->open)
82809 + vma_m->vm_ops->open(vma_m);
82810 + BUG_ON(find_vma_links(vma->vm_mm, vma_m->vm_start, vma_m->vm_end, &prev_m, &rb_link_m, &rb_parent_m));
82811 + vma_link(vma->vm_mm, vma_m, prev_m, rb_link_m, rb_parent_m);
82812 + vma_m->vm_mirror = vma;
82813 + vma->vm_mirror = vma_m;
82814 + return 0;
82815 +}
82816 +#endif
82817 +
82818 /*
82819 * Return true if the calling process may expand its vm space by the passed
82820 * number of pages
82821 @@ -2840,6 +3349,7 @@ int may_expand_vm(struct mm_struct *mm, unsigned long npages)
82822
82823 lim = rlimit(RLIMIT_AS) >> PAGE_SHIFT;
82824
82825 + gr_learn_resource(current, RLIMIT_AS, (cur + npages) << PAGE_SHIFT, 1);
82826 if (cur + npages > lim)
82827 return 0;
82828 return 1;
82829 @@ -2910,6 +3420,22 @@ int install_special_mapping(struct mm_struct *mm,
82830 vma->vm_start = addr;
82831 vma->vm_end = addr + len;
82832
82833 +#ifdef CONFIG_PAX_MPROTECT
82834 + if (mm->pax_flags & MF_PAX_MPROTECT) {
82835 +#ifndef CONFIG_PAX_MPROTECT_COMPAT
82836 + if ((vm_flags & (VM_WRITE | VM_EXEC)) == (VM_WRITE | VM_EXEC))
82837 + return -EPERM;
82838 + if (!(vm_flags & VM_EXEC))
82839 + vm_flags &= ~VM_MAYEXEC;
82840 +#else
82841 + if ((vm_flags & (VM_WRITE | VM_EXEC)) != VM_EXEC)
82842 + vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
82843 +#endif
82844 + else
82845 + vm_flags &= ~VM_MAYWRITE;
82846 + }
82847 +#endif
82848 +
82849 vma->vm_flags = vm_flags | mm->def_flags | VM_DONTEXPAND;
82850 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
82851
82852 diff --git a/mm/mmu_notifier.c b/mm/mmu_notifier.c
82853 index be04122..6725ff1 100644
82854 --- a/mm/mmu_notifier.c
82855 +++ b/mm/mmu_notifier.c
82856 @@ -40,48 +40,44 @@ void __mmu_notifier_release(struct mm_struct *mm)
82857 int id;
82858
82859 /*
82860 - * srcu_read_lock() here will block synchronize_srcu() in
82861 - * mmu_notifier_unregister() until all registered
82862 - * ->release() callouts this function makes have
82863 - * returned.
82864 + * SRCU here will block mmu_notifier_unregister until
82865 + * ->release returns.
82866 */
82867 id = srcu_read_lock(&srcu);
82868 + hlist_for_each_entry_rcu(mn, &mm->mmu_notifier_mm->list, hlist)
82869 + /*
82870 + * If ->release runs before mmu_notifier_unregister it must be
82871 + * handled, as it's the only way for the driver to flush all
82872 + * existing sptes and stop the driver from establishing any more
82873 + * sptes before all the pages in the mm are freed.
82874 + */
82875 + if (mn->ops->release)
82876 + mn->ops->release(mn, mm);
82877 + srcu_read_unlock(&srcu, id);
82878 +
82879 spin_lock(&mm->mmu_notifier_mm->lock);
82880 while (unlikely(!hlist_empty(&mm->mmu_notifier_mm->list))) {
82881 mn = hlist_entry(mm->mmu_notifier_mm->list.first,
82882 struct mmu_notifier,
82883 hlist);
82884 -
82885 /*
82886 - * Unlink. This will prevent mmu_notifier_unregister()
82887 - * from also making the ->release() callout.
82888 + * We arrived before mmu_notifier_unregister so
82889 + * mmu_notifier_unregister will do nothing other than to wait
82890 + * for ->release to finish and for mmu_notifier_unregister to
82891 + * return.
82892 */
82893 hlist_del_init_rcu(&mn->hlist);
82894 - spin_unlock(&mm->mmu_notifier_mm->lock);
82895 -
82896 - /*
82897 - * Clear sptes. (see 'release' description in mmu_notifier.h)
82898 - */
82899 - if (mn->ops->release)
82900 - mn->ops->release(mn, mm);
82901 -
82902 - spin_lock(&mm->mmu_notifier_mm->lock);
82903 }
82904 spin_unlock(&mm->mmu_notifier_mm->lock);
82905
82906 /*
82907 - * All callouts to ->release() which we have done are complete.
82908 - * Allow synchronize_srcu() in mmu_notifier_unregister() to complete
82909 - */
82910 - srcu_read_unlock(&srcu, id);
82911 -
82912 - /*
82913 - * mmu_notifier_unregister() may have unlinked a notifier and may
82914 - * still be calling out to it. Additionally, other notifiers
82915 - * may have been active via vmtruncate() et. al. Block here
82916 - * to ensure that all notifier callouts for this mm have been
82917 - * completed and the sptes are really cleaned up before returning
82918 - * to exit_mmap().
82919 + * synchronize_srcu here prevents mmu_notifier_release from returning to
82920 + * exit_mmap (which would proceed with freeing all pages in the mm)
82921 + * until the ->release method returns, if it was invoked by
82922 + * mmu_notifier_unregister.
82923 + *
82924 + * The mmu_notifier_mm can't go away from under us because one mm_count
82925 + * is held by exit_mmap.
82926 */
82927 synchronize_srcu(&srcu);
82928 }
82929 @@ -292,31 +288,34 @@ void mmu_notifier_unregister(struct mmu_notifier *mn, struct mm_struct *mm)
82930 {
82931 BUG_ON(atomic_read(&mm->mm_count) <= 0);
82932
82933 - spin_lock(&mm->mmu_notifier_mm->lock);
82934 if (!hlist_unhashed(&mn->hlist)) {
82935 + /*
82936 + * SRCU here will force exit_mmap to wait for ->release to
82937 + * finish before freeing the pages.
82938 + */
82939 int id;
82940
82941 - /*
82942 - * Ensure we synchronize up with __mmu_notifier_release().
82943 - */
82944 id = srcu_read_lock(&srcu);
82945 -
82946 - hlist_del_rcu(&mn->hlist);
82947 - spin_unlock(&mm->mmu_notifier_mm->lock);
82948 -
82949 - if (mn->ops->release)
82950 - mn->ops->release(mn, mm);
82951 -
82952 /*
82953 - * Allow __mmu_notifier_release() to complete.
82954 + * exit_mmap will block in mmu_notifier_release to guarantee
82955 + * that ->release is called before freeing the pages.
82956 */
82957 + if (mn->ops->release)
82958 + mn->ops->release(mn, mm);
82959 srcu_read_unlock(&srcu, id);
82960 - } else
82961 +
82962 + spin_lock(&mm->mmu_notifier_mm->lock);
82963 + /*
82964 + * Can not use list_del_rcu() since __mmu_notifier_release
82965 + * can delete it before we hold the lock.
82966 + */
82967 + hlist_del_init_rcu(&mn->hlist);
82968 spin_unlock(&mm->mmu_notifier_mm->lock);
82969 + }
82970
82971 /*
82972 - * Wait for any running method to finish, including ->release() if it
82973 - * was run by __mmu_notifier_release() instead of us.
82974 + * Wait for any running method to finish, of course including
82975 + * ->release if it was run by mmu_notifier_relase instead of us.
82976 */
82977 synchronize_srcu(&srcu);
82978
82979 diff --git a/mm/mprotect.c b/mm/mprotect.c
82980 index 94722a4..07d9926 100644
82981 --- a/mm/mprotect.c
82982 +++ b/mm/mprotect.c
82983 @@ -23,10 +23,18 @@
82984 #include <linux/mmu_notifier.h>
82985 #include <linux/migrate.h>
82986 #include <linux/perf_event.h>
82987 +#include <linux/sched/sysctl.h>
82988 +
82989 +#ifdef CONFIG_PAX_MPROTECT
82990 +#include <linux/elf.h>
82991 +#include <linux/binfmts.h>
82992 +#endif
82993 +
82994 #include <asm/uaccess.h>
82995 #include <asm/pgtable.h>
82996 #include <asm/cacheflush.h>
82997 #include <asm/tlbflush.h>
82998 +#include <asm/mmu_context.h>
82999
83000 #ifndef pgprot_modify
83001 static inline pgprot_t pgprot_modify(pgprot_t oldprot, pgprot_t newprot)
83002 @@ -233,6 +241,48 @@ unsigned long change_protection(struct vm_area_struct *vma, unsigned long start,
83003 return pages;
83004 }
83005
83006 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
83007 +/* called while holding the mmap semaphor for writing except stack expansion */
83008 +void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot)
83009 +{
83010 + unsigned long oldlimit, newlimit = 0UL;
83011 +
83012 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || (__supported_pte_mask & _PAGE_NX))
83013 + return;
83014 +
83015 + spin_lock(&mm->page_table_lock);
83016 + oldlimit = mm->context.user_cs_limit;
83017 + if ((prot & VM_EXEC) && oldlimit < end)
83018 + /* USER_CS limit moved up */
83019 + newlimit = end;
83020 + else if (!(prot & VM_EXEC) && start < oldlimit && oldlimit <= end)
83021 + /* USER_CS limit moved down */
83022 + newlimit = start;
83023 +
83024 + if (newlimit) {
83025 + mm->context.user_cs_limit = newlimit;
83026 +
83027 +#ifdef CONFIG_SMP
83028 + wmb();
83029 + cpus_clear(mm->context.cpu_user_cs_mask);
83030 + cpu_set(smp_processor_id(), mm->context.cpu_user_cs_mask);
83031 +#endif
83032 +
83033 + set_user_cs(mm->context.user_cs_base, mm->context.user_cs_limit, smp_processor_id());
83034 + }
83035 + spin_unlock(&mm->page_table_lock);
83036 + if (newlimit == end) {
83037 + struct vm_area_struct *vma = find_vma(mm, oldlimit);
83038 +
83039 + for (; vma && vma->vm_start < end; vma = vma->vm_next)
83040 + if (is_vm_hugetlb_page(vma))
83041 + hugetlb_change_protection(vma, vma->vm_start, vma->vm_end, vma->vm_page_prot);
83042 + else
83043 + change_protection(vma, vma->vm_start, vma->vm_end, vma->vm_page_prot, vma_wants_writenotify(vma), 0);
83044 + }
83045 +}
83046 +#endif
83047 +
83048 int
83049 mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
83050 unsigned long start, unsigned long end, unsigned long newflags)
83051 @@ -245,11 +295,29 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
83052 int error;
83053 int dirty_accountable = 0;
83054
83055 +#ifdef CONFIG_PAX_SEGMEXEC
83056 + struct vm_area_struct *vma_m = NULL;
83057 + unsigned long start_m, end_m;
83058 +
83059 + start_m = start + SEGMEXEC_TASK_SIZE;
83060 + end_m = end + SEGMEXEC_TASK_SIZE;
83061 +#endif
83062 +
83063 if (newflags == oldflags) {
83064 *pprev = vma;
83065 return 0;
83066 }
83067
83068 + if (newflags & (VM_READ | VM_WRITE | VM_EXEC)) {
83069 + struct vm_area_struct *prev = vma->vm_prev, *next = vma->vm_next;
83070 +
83071 + if (next && (next->vm_flags & VM_GROWSDOWN) && sysctl_heap_stack_gap > next->vm_start - end)
83072 + return -ENOMEM;
83073 +
83074 + if (prev && (prev->vm_flags & VM_GROWSUP) && sysctl_heap_stack_gap > start - prev->vm_end)
83075 + return -ENOMEM;
83076 + }
83077 +
83078 /*
83079 * If we make a private mapping writable we increase our commit;
83080 * but (without finer accounting) cannot reduce our commit if we
83081 @@ -266,6 +334,42 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
83082 }
83083 }
83084
83085 +#ifdef CONFIG_PAX_SEGMEXEC
83086 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && ((oldflags ^ newflags) & VM_EXEC)) {
83087 + if (start != vma->vm_start) {
83088 + error = split_vma(mm, vma, start, 1);
83089 + if (error)
83090 + goto fail;
83091 + BUG_ON(!*pprev || (*pprev)->vm_next == vma);
83092 + *pprev = (*pprev)->vm_next;
83093 + }
83094 +
83095 + if (end != vma->vm_end) {
83096 + error = split_vma(mm, vma, end, 0);
83097 + if (error)
83098 + goto fail;
83099 + }
83100 +
83101 + if (pax_find_mirror_vma(vma)) {
83102 + error = __do_munmap(mm, start_m, end_m - start_m);
83103 + if (error)
83104 + goto fail;
83105 + } else {
83106 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
83107 + if (!vma_m) {
83108 + error = -ENOMEM;
83109 + goto fail;
83110 + }
83111 + vma->vm_flags = newflags;
83112 + error = pax_mirror_vma(vma_m, vma);
83113 + if (error) {
83114 + vma->vm_flags = oldflags;
83115 + goto fail;
83116 + }
83117 + }
83118 + }
83119 +#endif
83120 +
83121 /*
83122 * First try to merge with previous and/or next vma.
83123 */
83124 @@ -296,9 +400,21 @@ success:
83125 * vm_flags and vm_page_prot are protected by the mmap_sem
83126 * held in write mode.
83127 */
83128 +
83129 +#ifdef CONFIG_PAX_SEGMEXEC
83130 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (newflags & VM_EXEC) && ((vma->vm_flags ^ newflags) & VM_READ))
83131 + pax_find_mirror_vma(vma)->vm_flags ^= VM_READ;
83132 +#endif
83133 +
83134 vma->vm_flags = newflags;
83135 +
83136 +#ifdef CONFIG_PAX_MPROTECT
83137 + if (mm->binfmt && mm->binfmt->handle_mprotect)
83138 + mm->binfmt->handle_mprotect(vma, newflags);
83139 +#endif
83140 +
83141 vma->vm_page_prot = pgprot_modify(vma->vm_page_prot,
83142 - vm_get_page_prot(newflags));
83143 + vm_get_page_prot(vma->vm_flags));
83144
83145 if (vma_wants_writenotify(vma)) {
83146 vma->vm_page_prot = vm_get_page_prot(newflags & ~VM_SHARED);
83147 @@ -337,6 +453,17 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
83148 end = start + len;
83149 if (end <= start)
83150 return -ENOMEM;
83151 +
83152 +#ifdef CONFIG_PAX_SEGMEXEC
83153 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
83154 + if (end > SEGMEXEC_TASK_SIZE)
83155 + return -EINVAL;
83156 + } else
83157 +#endif
83158 +
83159 + if (end > TASK_SIZE)
83160 + return -EINVAL;
83161 +
83162 if (!arch_validate_prot(prot))
83163 return -EINVAL;
83164
83165 @@ -344,7 +471,7 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
83166 /*
83167 * Does the application expect PROT_READ to imply PROT_EXEC:
83168 */
83169 - if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
83170 + if ((prot & (PROT_READ | PROT_WRITE)) && (current->personality & READ_IMPLIES_EXEC))
83171 prot |= PROT_EXEC;
83172
83173 vm_flags = calc_vm_prot_bits(prot);
83174 @@ -376,6 +503,11 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
83175 if (start > vma->vm_start)
83176 prev = vma;
83177
83178 +#ifdef CONFIG_PAX_MPROTECT
83179 + if (current->mm->binfmt && current->mm->binfmt->handle_mprotect)
83180 + current->mm->binfmt->handle_mprotect(vma, vm_flags);
83181 +#endif
83182 +
83183 for (nstart = start ; ; ) {
83184 unsigned long newflags;
83185
83186 @@ -386,6 +518,14 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
83187
83188 /* newflags >> 4 shift VM_MAY% in place of VM_% */
83189 if ((newflags & ~(newflags >> 4)) & (VM_READ | VM_WRITE | VM_EXEC)) {
83190 + if (prot & (PROT_WRITE | PROT_EXEC))
83191 + gr_log_rwxmprotect(vma->vm_file);
83192 +
83193 + error = -EACCES;
83194 + goto out;
83195 + }
83196 +
83197 + if (!gr_acl_handle_mprotect(vma->vm_file, prot)) {
83198 error = -EACCES;
83199 goto out;
83200 }
83201 @@ -400,6 +540,9 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
83202 error = mprotect_fixup(vma, &prev, nstart, tmp, newflags);
83203 if (error)
83204 goto out;
83205 +
83206 + track_exec_limit(current->mm, nstart, tmp, vm_flags);
83207 +
83208 nstart = tmp;
83209
83210 if (nstart < prev->vm_end)
83211 diff --git a/mm/mremap.c b/mm/mremap.c
83212 index 463a257..c0c7a92 100644
83213 --- a/mm/mremap.c
83214 +++ b/mm/mremap.c
83215 @@ -126,6 +126,12 @@ static void move_ptes(struct vm_area_struct *vma, pmd_t *old_pmd,
83216 continue;
83217 pte = ptep_get_and_clear(mm, old_addr, old_pte);
83218 pte = move_pte(pte, new_vma->vm_page_prot, old_addr, new_addr);
83219 +
83220 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
83221 + if (!(__supported_pte_mask & _PAGE_NX) && (new_vma->vm_flags & (VM_PAGEEXEC | VM_EXEC)) == VM_PAGEEXEC)
83222 + pte = pte_exprotect(pte);
83223 +#endif
83224 +
83225 set_pte_at(mm, new_addr, new_pte, pte);
83226 }
83227
83228 @@ -318,6 +324,11 @@ static struct vm_area_struct *vma_to_resize(unsigned long addr,
83229 if (is_vm_hugetlb_page(vma))
83230 goto Einval;
83231
83232 +#ifdef CONFIG_PAX_SEGMEXEC
83233 + if (pax_find_mirror_vma(vma))
83234 + goto Einval;
83235 +#endif
83236 +
83237 /* We can't remap across vm area boundaries */
83238 if (old_len > vma->vm_end - addr)
83239 goto Efault;
83240 @@ -373,20 +384,25 @@ static unsigned long mremap_to(unsigned long addr, unsigned long old_len,
83241 unsigned long ret = -EINVAL;
83242 unsigned long charged = 0;
83243 unsigned long map_flags;
83244 + unsigned long pax_task_size = TASK_SIZE;
83245
83246 if (new_addr & ~PAGE_MASK)
83247 goto out;
83248
83249 - if (new_len > TASK_SIZE || new_addr > TASK_SIZE - new_len)
83250 +#ifdef CONFIG_PAX_SEGMEXEC
83251 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
83252 + pax_task_size = SEGMEXEC_TASK_SIZE;
83253 +#endif
83254 +
83255 + pax_task_size -= PAGE_SIZE;
83256 +
83257 + if (new_len > TASK_SIZE || new_addr > pax_task_size - new_len)
83258 goto out;
83259
83260 /* Check if the location we're moving into overlaps the
83261 * old location at all, and fail if it does.
83262 */
83263 - if ((new_addr <= addr) && (new_addr+new_len) > addr)
83264 - goto out;
83265 -
83266 - if ((addr <= new_addr) && (addr+old_len) > new_addr)
83267 + if (addr + old_len > new_addr && new_addr + new_len > addr)
83268 goto out;
83269
83270 ret = do_munmap(mm, new_addr, new_len);
83271 @@ -455,6 +471,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
83272 unsigned long ret = -EINVAL;
83273 unsigned long charged = 0;
83274 bool locked = false;
83275 + unsigned long pax_task_size = TASK_SIZE;
83276
83277 down_write(&current->mm->mmap_sem);
83278
83279 @@ -475,6 +492,17 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
83280 if (!new_len)
83281 goto out;
83282
83283 +#ifdef CONFIG_PAX_SEGMEXEC
83284 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
83285 + pax_task_size = SEGMEXEC_TASK_SIZE;
83286 +#endif
83287 +
83288 + pax_task_size -= PAGE_SIZE;
83289 +
83290 + if (new_len > pax_task_size || addr > pax_task_size-new_len ||
83291 + old_len > pax_task_size || addr > pax_task_size-old_len)
83292 + goto out;
83293 +
83294 if (flags & MREMAP_FIXED) {
83295 if (flags & MREMAP_MAYMOVE)
83296 ret = mremap_to(addr, old_len, new_addr, new_len,
83297 @@ -524,6 +552,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
83298 new_addr = addr;
83299 }
83300 ret = addr;
83301 + track_exec_limit(vma->vm_mm, vma->vm_start, addr + new_len, vma->vm_flags);
83302 goto out;
83303 }
83304 }
83305 @@ -547,7 +576,12 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
83306 goto out;
83307 }
83308
83309 + map_flags = vma->vm_flags;
83310 ret = move_vma(vma, addr, old_len, new_len, new_addr, &locked);
83311 + if (!(ret & ~PAGE_MASK)) {
83312 + track_exec_limit(current->mm, addr, addr + old_len, 0UL);
83313 + track_exec_limit(current->mm, new_addr, new_addr + new_len, map_flags);
83314 + }
83315 }
83316 out:
83317 if (ret & ~PAGE_MASK)
83318 diff --git a/mm/nommu.c b/mm/nommu.c
83319 index e001768..9b52b30 100644
83320 --- a/mm/nommu.c
83321 +++ b/mm/nommu.c
83322 @@ -63,7 +63,6 @@ int sysctl_overcommit_memory = OVERCOMMIT_GUESS; /* heuristic overcommit */
83323 int sysctl_overcommit_ratio = 50; /* default is 50% */
83324 int sysctl_max_map_count = DEFAULT_MAX_MAP_COUNT;
83325 int sysctl_nr_trim_pages = CONFIG_NOMMU_INITIAL_TRIM_EXCESS;
83326 -int heap_stack_gap = 0;
83327
83328 atomic_long_t mmap_pages_allocated;
83329
83330 @@ -841,15 +840,6 @@ struct vm_area_struct *find_vma(struct mm_struct *mm, unsigned long addr)
83331 EXPORT_SYMBOL(find_vma);
83332
83333 /*
83334 - * find a VMA
83335 - * - we don't extend stack VMAs under NOMMU conditions
83336 - */
83337 -struct vm_area_struct *find_extend_vma(struct mm_struct *mm, unsigned long addr)
83338 -{
83339 - return find_vma(mm, addr);
83340 -}
83341 -
83342 -/*
83343 * expand a stack to a given address
83344 * - not supported under NOMMU conditions
83345 */
83346 @@ -1560,6 +1550,7 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
83347
83348 /* most fields are the same, copy all, and then fixup */
83349 *new = *vma;
83350 + INIT_LIST_HEAD(&new->anon_vma_chain);
83351 *region = *vma->vm_region;
83352 new->vm_region = region;
83353
83354 @@ -1992,8 +1983,8 @@ int generic_file_remap_pages(struct vm_area_struct *vma, unsigned long addr,
83355 }
83356 EXPORT_SYMBOL(generic_file_remap_pages);
83357
83358 -static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
83359 - unsigned long addr, void *buf, int len, int write)
83360 +static ssize_t __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
83361 + unsigned long addr, void *buf, size_t len, int write)
83362 {
83363 struct vm_area_struct *vma;
83364
83365 @@ -2034,8 +2025,8 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
83366 *
83367 * The caller must hold a reference on @mm.
83368 */
83369 -int access_remote_vm(struct mm_struct *mm, unsigned long addr,
83370 - void *buf, int len, int write)
83371 +ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
83372 + void *buf, size_t len, int write)
83373 {
83374 return __access_remote_vm(NULL, mm, addr, buf, len, write);
83375 }
83376 @@ -2044,7 +2035,7 @@ int access_remote_vm(struct mm_struct *mm, unsigned long addr,
83377 * Access another process' address space.
83378 * - source/target buffer must be kernel space
83379 */
83380 -int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write)
83381 +ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, size_t len, int write)
83382 {
83383 struct mm_struct *mm;
83384
83385 diff --git a/mm/page-writeback.c b/mm/page-writeback.c
83386 index efe6814..64b4701 100644
83387 --- a/mm/page-writeback.c
83388 +++ b/mm/page-writeback.c
83389 @@ -659,7 +659,7 @@ unsigned long bdi_dirty_limit(struct backing_dev_info *bdi, unsigned long dirty)
83390 * card's bdi_dirty may rush to many times higher than bdi_setpoint.
83391 * - the bdi dirty thresh drops quickly due to change of JBOD workload
83392 */
83393 -static unsigned long bdi_position_ratio(struct backing_dev_info *bdi,
83394 +static unsigned long __intentional_overflow(-1) bdi_position_ratio(struct backing_dev_info *bdi,
83395 unsigned long thresh,
83396 unsigned long bg_thresh,
83397 unsigned long dirty,
83398 @@ -1634,7 +1634,7 @@ ratelimit_handler(struct notifier_block *self, unsigned long action,
83399 }
83400 }
83401
83402 -static struct notifier_block __cpuinitdata ratelimit_nb = {
83403 +static struct notifier_block ratelimit_nb = {
83404 .notifier_call = ratelimit_handler,
83405 .next = NULL,
83406 };
83407 diff --git a/mm/page_alloc.c b/mm/page_alloc.c
83408 index 8fcced7..ebcd481 100644
83409 --- a/mm/page_alloc.c
83410 +++ b/mm/page_alloc.c
83411 @@ -59,6 +59,7 @@
83412 #include <linux/migrate.h>
83413 #include <linux/page-debug-flags.h>
83414 #include <linux/sched/rt.h>
83415 +#include <linux/random.h>
83416
83417 #include <asm/tlbflush.h>
83418 #include <asm/div64.h>
83419 @@ -344,7 +345,7 @@ out:
83420 * This usage means that zero-order pages may not be compound.
83421 */
83422
83423 -static void free_compound_page(struct page *page)
83424 +void free_compound_page(struct page *page)
83425 {
83426 __free_pages_ok(page, compound_order(page));
83427 }
83428 @@ -701,6 +702,10 @@ static bool free_pages_prepare(struct page *page, unsigned int order)
83429 int i;
83430 int bad = 0;
83431
83432 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
83433 + unsigned long index = 1UL << order;
83434 +#endif
83435 +
83436 trace_mm_page_free(page, order);
83437 kmemcheck_free_shadow(page, order);
83438
83439 @@ -716,6 +721,12 @@ static bool free_pages_prepare(struct page *page, unsigned int order)
83440 debug_check_no_obj_freed(page_address(page),
83441 PAGE_SIZE << order);
83442 }
83443 +
83444 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
83445 + for (; index; --index)
83446 + sanitize_highpage(page + index - 1);
83447 +#endif
83448 +
83449 arch_free_page(page, order);
83450 kernel_map_pages(page, 1 << order, 0);
83451
83452 @@ -738,6 +749,19 @@ static void __free_pages_ok(struct page *page, unsigned int order)
83453 local_irq_restore(flags);
83454 }
83455
83456 +#ifdef CONFIG_PAX_LATENT_ENTROPY
83457 +bool __meminitdata extra_latent_entropy;
83458 +
83459 +static int __init setup_pax_extra_latent_entropy(char *str)
83460 +{
83461 + extra_latent_entropy = true;
83462 + return 0;
83463 +}
83464 +early_param("pax_extra_latent_entropy", setup_pax_extra_latent_entropy);
83465 +
83466 +volatile u64 latent_entropy;
83467 +#endif
83468 +
83469 /*
83470 * Read access to zone->managed_pages is safe because it's unsigned long,
83471 * but we still need to serialize writers. Currently all callers of
83472 @@ -760,6 +784,19 @@ void __meminit __free_pages_bootmem(struct page *page, unsigned int order)
83473 set_page_count(p, 0);
83474 }
83475
83476 +#ifdef CONFIG_PAX_LATENT_ENTROPY
83477 + if (extra_latent_entropy && !PageHighMem(page) && page_to_pfn(page) < 0x100000) {
83478 + u64 hash = 0;
83479 + size_t index, end = PAGE_SIZE * nr_pages / sizeof hash;
83480 + const u64 *data = lowmem_page_address(page);
83481 +
83482 + for (index = 0; index < end; index++)
83483 + hash ^= hash + data[index];
83484 + latent_entropy ^= hash;
83485 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
83486 + }
83487 +#endif
83488 +
83489 page_zone(page)->managed_pages += 1 << order;
83490 set_page_refcounted(page);
83491 __free_pages(page, order);
83492 @@ -869,8 +906,10 @@ static int prep_new_page(struct page *page, int order, gfp_t gfp_flags)
83493 arch_alloc_page(page, order);
83494 kernel_map_pages(page, 1 << order, 1);
83495
83496 +#ifndef CONFIG_PAX_MEMORY_SANITIZE
83497 if (gfp_flags & __GFP_ZERO)
83498 prep_zero_page(page, order, gfp_flags);
83499 +#endif
83500
83501 if (order && (gfp_flags & __GFP_COMP))
83502 prep_compound_page(page, order);
83503 diff --git a/mm/page_io.c b/mm/page_io.c
83504 index 6182870..4bba6a2 100644
83505 --- a/mm/page_io.c
83506 +++ b/mm/page_io.c
83507 @@ -205,7 +205,7 @@ int swap_writepage(struct page *page, struct writeback_control *wbc)
83508 struct file *swap_file = sis->swap_file;
83509 struct address_space *mapping = swap_file->f_mapping;
83510 struct iovec iov = {
83511 - .iov_base = kmap(page),
83512 + .iov_base = (void __force_user *)kmap(page),
83513 .iov_len = PAGE_SIZE,
83514 };
83515
83516 diff --git a/mm/percpu.c b/mm/percpu.c
83517 index 8c8e08f..73a5cda 100644
83518 --- a/mm/percpu.c
83519 +++ b/mm/percpu.c
83520 @@ -122,7 +122,7 @@ static unsigned int pcpu_low_unit_cpu __read_mostly;
83521 static unsigned int pcpu_high_unit_cpu __read_mostly;
83522
83523 /* the address of the first chunk which starts with the kernel static area */
83524 -void *pcpu_base_addr __read_mostly;
83525 +void *pcpu_base_addr __read_only;
83526 EXPORT_SYMBOL_GPL(pcpu_base_addr);
83527
83528 static const int *pcpu_unit_map __read_mostly; /* cpu -> unit */
83529 diff --git a/mm/process_vm_access.c b/mm/process_vm_access.c
83530 index fd26d04..0cea1b0 100644
83531 --- a/mm/process_vm_access.c
83532 +++ b/mm/process_vm_access.c
83533 @@ -13,6 +13,7 @@
83534 #include <linux/uio.h>
83535 #include <linux/sched.h>
83536 #include <linux/highmem.h>
83537 +#include <linux/security.h>
83538 #include <linux/ptrace.h>
83539 #include <linux/slab.h>
83540 #include <linux/syscalls.h>
83541 @@ -258,19 +259,19 @@ static ssize_t process_vm_rw_core(pid_t pid, const struct iovec *lvec,
83542 size_t iov_l_curr_offset = 0;
83543 ssize_t iov_len;
83544
83545 + return -ENOSYS; // PaX: until properly audited
83546 +
83547 /*
83548 * Work out how many pages of struct pages we're going to need
83549 * when eventually calling get_user_pages
83550 */
83551 for (i = 0; i < riovcnt; i++) {
83552 iov_len = rvec[i].iov_len;
83553 - if (iov_len > 0) {
83554 - nr_pages_iov = ((unsigned long)rvec[i].iov_base
83555 - + iov_len)
83556 - / PAGE_SIZE - (unsigned long)rvec[i].iov_base
83557 - / PAGE_SIZE + 1;
83558 - nr_pages = max(nr_pages, nr_pages_iov);
83559 - }
83560 + if (iov_len <= 0)
83561 + continue;
83562 + nr_pages_iov = ((unsigned long)rvec[i].iov_base + iov_len) / PAGE_SIZE -
83563 + (unsigned long)rvec[i].iov_base / PAGE_SIZE + 1;
83564 + nr_pages = max(nr_pages, nr_pages_iov);
83565 }
83566
83567 if (nr_pages == 0)
83568 @@ -298,6 +299,11 @@ static ssize_t process_vm_rw_core(pid_t pid, const struct iovec *lvec,
83569 goto free_proc_pages;
83570 }
83571
83572 + if (gr_handle_ptrace(task, vm_write ? PTRACE_POKETEXT : PTRACE_ATTACH)) {
83573 + rc = -EPERM;
83574 + goto put_task_struct;
83575 + }
83576 +
83577 mm = mm_access(task, PTRACE_MODE_ATTACH);
83578 if (!mm || IS_ERR(mm)) {
83579 rc = IS_ERR(mm) ? PTR_ERR(mm) : -ESRCH;
83580 diff --git a/mm/rmap.c b/mm/rmap.c
83581 index 807c96b..0e05279 100644
83582 --- a/mm/rmap.c
83583 +++ b/mm/rmap.c
83584 @@ -163,6 +163,10 @@ int anon_vma_prepare(struct vm_area_struct *vma)
83585 struct anon_vma *anon_vma = vma->anon_vma;
83586 struct anon_vma_chain *avc;
83587
83588 +#ifdef CONFIG_PAX_SEGMEXEC
83589 + struct anon_vma_chain *avc_m = NULL;
83590 +#endif
83591 +
83592 might_sleep();
83593 if (unlikely(!anon_vma)) {
83594 struct mm_struct *mm = vma->vm_mm;
83595 @@ -172,6 +176,12 @@ int anon_vma_prepare(struct vm_area_struct *vma)
83596 if (!avc)
83597 goto out_enomem;
83598
83599 +#ifdef CONFIG_PAX_SEGMEXEC
83600 + avc_m = anon_vma_chain_alloc(GFP_KERNEL);
83601 + if (!avc_m)
83602 + goto out_enomem_free_avc;
83603 +#endif
83604 +
83605 anon_vma = find_mergeable_anon_vma(vma);
83606 allocated = NULL;
83607 if (!anon_vma) {
83608 @@ -185,6 +195,18 @@ int anon_vma_prepare(struct vm_area_struct *vma)
83609 /* page_table_lock to protect against threads */
83610 spin_lock(&mm->page_table_lock);
83611 if (likely(!vma->anon_vma)) {
83612 +
83613 +#ifdef CONFIG_PAX_SEGMEXEC
83614 + struct vm_area_struct *vma_m = pax_find_mirror_vma(vma);
83615 +
83616 + if (vma_m) {
83617 + BUG_ON(vma_m->anon_vma);
83618 + vma_m->anon_vma = anon_vma;
83619 + anon_vma_chain_link(vma_m, avc_m, anon_vma);
83620 + avc_m = NULL;
83621 + }
83622 +#endif
83623 +
83624 vma->anon_vma = anon_vma;
83625 anon_vma_chain_link(vma, avc, anon_vma);
83626 allocated = NULL;
83627 @@ -195,12 +217,24 @@ int anon_vma_prepare(struct vm_area_struct *vma)
83628
83629 if (unlikely(allocated))
83630 put_anon_vma(allocated);
83631 +
83632 +#ifdef CONFIG_PAX_SEGMEXEC
83633 + if (unlikely(avc_m))
83634 + anon_vma_chain_free(avc_m);
83635 +#endif
83636 +
83637 if (unlikely(avc))
83638 anon_vma_chain_free(avc);
83639 }
83640 return 0;
83641
83642 out_enomem_free_avc:
83643 +
83644 +#ifdef CONFIG_PAX_SEGMEXEC
83645 + if (avc_m)
83646 + anon_vma_chain_free(avc_m);
83647 +#endif
83648 +
83649 anon_vma_chain_free(avc);
83650 out_enomem:
83651 return -ENOMEM;
83652 @@ -236,7 +270,7 @@ static inline void unlock_anon_vma_root(struct anon_vma *root)
83653 * Attach the anon_vmas from src to dst.
83654 * Returns 0 on success, -ENOMEM on failure.
83655 */
83656 -int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
83657 +int anon_vma_clone(struct vm_area_struct *dst, const struct vm_area_struct *src)
83658 {
83659 struct anon_vma_chain *avc, *pavc;
83660 struct anon_vma *root = NULL;
83661 @@ -269,7 +303,7 @@ int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
83662 * the corresponding VMA in the parent process is attached to.
83663 * Returns 0 on success, non-zero on failure.
83664 */
83665 -int anon_vma_fork(struct vm_area_struct *vma, struct vm_area_struct *pvma)
83666 +int anon_vma_fork(struct vm_area_struct *vma, const struct vm_area_struct *pvma)
83667 {
83668 struct anon_vma_chain *avc;
83669 struct anon_vma *anon_vma;
83670 diff --git a/mm/shmem.c b/mm/shmem.c
83671 index 1c44af7..cefe9a6 100644
83672 --- a/mm/shmem.c
83673 +++ b/mm/shmem.c
83674 @@ -31,7 +31,7 @@
83675 #include <linux/export.h>
83676 #include <linux/swap.h>
83677
83678 -static struct vfsmount *shm_mnt;
83679 +struct vfsmount *shm_mnt;
83680
83681 #ifdef CONFIG_SHMEM
83682 /*
83683 @@ -75,7 +75,7 @@ static struct vfsmount *shm_mnt;
83684 #define BOGO_DIRENT_SIZE 20
83685
83686 /* Symlink up to this size is kmalloc'ed instead of using a swappable page */
83687 -#define SHORT_SYMLINK_LEN 128
83688 +#define SHORT_SYMLINK_LEN 64
83689
83690 /*
83691 * shmem_fallocate and shmem_writepage communicate via inode->i_private
83692 @@ -2201,6 +2201,11 @@ static const struct xattr_handler *shmem_xattr_handlers[] = {
83693 static int shmem_xattr_validate(const char *name)
83694 {
83695 struct { const char *prefix; size_t len; } arr[] = {
83696 +
83697 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
83698 + { XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN},
83699 +#endif
83700 +
83701 { XATTR_SECURITY_PREFIX, XATTR_SECURITY_PREFIX_LEN },
83702 { XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN }
83703 };
83704 @@ -2256,6 +2261,15 @@ static int shmem_setxattr(struct dentry *dentry, const char *name,
83705 if (err)
83706 return err;
83707
83708 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
83709 + if (!strncmp(name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN)) {
83710 + if (strcmp(name, XATTR_NAME_PAX_FLAGS))
83711 + return -EOPNOTSUPP;
83712 + if (size > 8)
83713 + return -EINVAL;
83714 + }
83715 +#endif
83716 +
83717 return simple_xattr_set(&info->xattrs, name, value, size, flags);
83718 }
83719
83720 @@ -2568,8 +2582,7 @@ int shmem_fill_super(struct super_block *sb, void *data, int silent)
83721 int err = -ENOMEM;
83722
83723 /* Round up to L1_CACHE_BYTES to resist false sharing */
83724 - sbinfo = kzalloc(max((int)sizeof(struct shmem_sb_info),
83725 - L1_CACHE_BYTES), GFP_KERNEL);
83726 + sbinfo = kzalloc(max(sizeof(struct shmem_sb_info), L1_CACHE_BYTES), GFP_KERNEL);
83727 if (!sbinfo)
83728 return -ENOMEM;
83729
83730 diff --git a/mm/slab.c b/mm/slab.c
83731 index 856e4a1..fafb820 100644
83732 --- a/mm/slab.c
83733 +++ b/mm/slab.c
83734 @@ -306,7 +306,7 @@ struct kmem_list3 {
83735 * Need this for bootstrapping a per node allocator.
83736 */
83737 #define NUM_INIT_LISTS (3 * MAX_NUMNODES)
83738 -static struct kmem_list3 __initdata initkmem_list3[NUM_INIT_LISTS];
83739 +static struct kmem_list3 initkmem_list3[NUM_INIT_LISTS];
83740 #define CACHE_CACHE 0
83741 #define SIZE_AC MAX_NUMNODES
83742 #define SIZE_L3 (2 * MAX_NUMNODES)
83743 @@ -407,10 +407,10 @@ static void kmem_list3_init(struct kmem_list3 *parent)
83744 if ((x)->max_freeable < i) \
83745 (x)->max_freeable = i; \
83746 } while (0)
83747 -#define STATS_INC_ALLOCHIT(x) atomic_inc(&(x)->allochit)
83748 -#define STATS_INC_ALLOCMISS(x) atomic_inc(&(x)->allocmiss)
83749 -#define STATS_INC_FREEHIT(x) atomic_inc(&(x)->freehit)
83750 -#define STATS_INC_FREEMISS(x) atomic_inc(&(x)->freemiss)
83751 +#define STATS_INC_ALLOCHIT(x) atomic_inc_unchecked(&(x)->allochit)
83752 +#define STATS_INC_ALLOCMISS(x) atomic_inc_unchecked(&(x)->allocmiss)
83753 +#define STATS_INC_FREEHIT(x) atomic_inc_unchecked(&(x)->freehit)
83754 +#define STATS_INC_FREEMISS(x) atomic_inc_unchecked(&(x)->freemiss)
83755 #else
83756 #define STATS_INC_ACTIVE(x) do { } while (0)
83757 #define STATS_DEC_ACTIVE(x) do { } while (0)
83758 @@ -518,7 +518,7 @@ static inline void *index_to_obj(struct kmem_cache *cache, struct slab *slab,
83759 * reciprocal_divide(offset, cache->reciprocal_buffer_size)
83760 */
83761 static inline unsigned int obj_to_index(const struct kmem_cache *cache,
83762 - const struct slab *slab, void *obj)
83763 + const struct slab *slab, const void *obj)
83764 {
83765 u32 offset = (obj - slab->s_mem);
83766 return reciprocal_divide(offset, cache->reciprocal_buffer_size);
83767 @@ -539,12 +539,13 @@ EXPORT_SYMBOL(malloc_sizes);
83768 struct cache_names {
83769 char *name;
83770 char *name_dma;
83771 + char *name_usercopy;
83772 };
83773
83774 static struct cache_names __initdata cache_names[] = {
83775 -#define CACHE(x) { .name = "size-" #x, .name_dma = "size-" #x "(DMA)" },
83776 +#define CACHE(x) { .name = "size-" #x, .name_dma = "size-" #x "(DMA)", .name_usercopy = "size-" #x "(USERCOPY)" },
83777 #include <linux/kmalloc_sizes.h>
83778 - {NULL,}
83779 + {NULL}
83780 #undef CACHE
83781 };
83782
83783 @@ -729,6 +730,12 @@ static inline struct kmem_cache *__find_general_cachep(size_t size,
83784 if (unlikely(gfpflags & GFP_DMA))
83785 return csizep->cs_dmacachep;
83786 #endif
83787 +
83788 +#ifdef CONFIG_PAX_USERCOPY_SLABS
83789 + if (unlikely(gfpflags & GFP_USERCOPY))
83790 + return csizep->cs_usercopycachep;
83791 +#endif
83792 +
83793 return csizep->cs_cachep;
83794 }
83795
83796 @@ -1482,7 +1489,7 @@ static int __cpuinit cpuup_callback(struct notifier_block *nfb,
83797 return notifier_from_errno(err);
83798 }
83799
83800 -static struct notifier_block __cpuinitdata cpucache_notifier = {
83801 +static struct notifier_block cpucache_notifier = {
83802 &cpuup_callback, NULL, 0
83803 };
83804
83805 @@ -1667,12 +1674,12 @@ void __init kmem_cache_init(void)
83806 */
83807
83808 sizes[INDEX_AC].cs_cachep = create_kmalloc_cache(names[INDEX_AC].name,
83809 - sizes[INDEX_AC].cs_size, ARCH_KMALLOC_FLAGS);
83810 + sizes[INDEX_AC].cs_size, ARCH_KMALLOC_FLAGS|SLAB_USERCOPY);
83811
83812 if (INDEX_AC != INDEX_L3)
83813 sizes[INDEX_L3].cs_cachep =
83814 create_kmalloc_cache(names[INDEX_L3].name,
83815 - sizes[INDEX_L3].cs_size, ARCH_KMALLOC_FLAGS);
83816 + sizes[INDEX_L3].cs_size, ARCH_KMALLOC_FLAGS|SLAB_USERCOPY);
83817
83818 slab_early_init = 0;
83819
83820 @@ -1686,13 +1693,20 @@ void __init kmem_cache_init(void)
83821 */
83822 if (!sizes->cs_cachep)
83823 sizes->cs_cachep = create_kmalloc_cache(names->name,
83824 - sizes->cs_size, ARCH_KMALLOC_FLAGS);
83825 + sizes->cs_size, ARCH_KMALLOC_FLAGS|SLAB_USERCOPY);
83826
83827 #ifdef CONFIG_ZONE_DMA
83828 sizes->cs_dmacachep = create_kmalloc_cache(
83829 names->name_dma, sizes->cs_size,
83830 SLAB_CACHE_DMA|ARCH_KMALLOC_FLAGS);
83831 #endif
83832 +
83833 +#ifdef CONFIG_PAX_USERCOPY_SLABS
83834 + sizes->cs_usercopycachep = create_kmalloc_cache(
83835 + names->name_usercopy, sizes->cs_size,
83836 + ARCH_KMALLOC_FLAGS|SLAB_USERCOPY);
83837 +#endif
83838 +
83839 sizes++;
83840 names++;
83841 }
83842 @@ -3924,6 +3938,7 @@ void kfree(const void *objp)
83843
83844 if (unlikely(ZERO_OR_NULL_PTR(objp)))
83845 return;
83846 + VM_BUG_ON(!virt_addr_valid(objp));
83847 local_irq_save(flags);
83848 kfree_debugcheck(objp);
83849 c = virt_to_cache(objp);
83850 @@ -4365,10 +4380,10 @@ void slabinfo_show_stats(struct seq_file *m, struct kmem_cache *cachep)
83851 }
83852 /* cpu stats */
83853 {
83854 - unsigned long allochit = atomic_read(&cachep->allochit);
83855 - unsigned long allocmiss = atomic_read(&cachep->allocmiss);
83856 - unsigned long freehit = atomic_read(&cachep->freehit);
83857 - unsigned long freemiss = atomic_read(&cachep->freemiss);
83858 + unsigned long allochit = atomic_read_unchecked(&cachep->allochit);
83859 + unsigned long allocmiss = atomic_read_unchecked(&cachep->allocmiss);
83860 + unsigned long freehit = atomic_read_unchecked(&cachep->freehit);
83861 + unsigned long freemiss = atomic_read_unchecked(&cachep->freemiss);
83862
83863 seq_printf(m, " : cpustat %6lu %6lu %6lu %6lu",
83864 allochit, allocmiss, freehit, freemiss);
83865 @@ -4600,13 +4615,71 @@ static const struct file_operations proc_slabstats_operations = {
83866 static int __init slab_proc_init(void)
83867 {
83868 #ifdef CONFIG_DEBUG_SLAB_LEAK
83869 - proc_create("slab_allocators", 0, NULL, &proc_slabstats_operations);
83870 + proc_create("slab_allocators", S_IRUSR, NULL, &proc_slabstats_operations);
83871 #endif
83872 return 0;
83873 }
83874 module_init(slab_proc_init);
83875 #endif
83876
83877 +bool is_usercopy_object(const void *ptr)
83878 +{
83879 + struct page *page;
83880 + struct kmem_cache *cachep;
83881 +
83882 + if (ZERO_OR_NULL_PTR(ptr))
83883 + return false;
83884 +
83885 + if (!slab_is_available())
83886 + return false;
83887 +
83888 + if (!virt_addr_valid(ptr))
83889 + return false;
83890 +
83891 + page = virt_to_head_page(ptr);
83892 +
83893 + if (!PageSlab(page))
83894 + return false;
83895 +
83896 + cachep = page->slab_cache;
83897 + return cachep->flags & SLAB_USERCOPY;
83898 +}
83899 +
83900 +#ifdef CONFIG_PAX_USERCOPY
83901 +const char *check_heap_object(const void *ptr, unsigned long n)
83902 +{
83903 + struct page *page;
83904 + struct kmem_cache *cachep;
83905 + struct slab *slabp;
83906 + unsigned int objnr;
83907 + unsigned long offset;
83908 +
83909 + if (ZERO_OR_NULL_PTR(ptr))
83910 + return "<null>";
83911 +
83912 + if (!virt_addr_valid(ptr))
83913 + return NULL;
83914 +
83915 + page = virt_to_head_page(ptr);
83916 +
83917 + if (!PageSlab(page))
83918 + return NULL;
83919 +
83920 + cachep = page->slab_cache;
83921 + if (!(cachep->flags & SLAB_USERCOPY))
83922 + return cachep->name;
83923 +
83924 + slabp = page->slab_page;
83925 + objnr = obj_to_index(cachep, slabp, ptr);
83926 + BUG_ON(objnr >= cachep->num);
83927 + offset = ptr - index_to_obj(cachep, slabp, objnr) - obj_offset(cachep);
83928 + if (offset <= cachep->object_size && n <= cachep->object_size - offset)
83929 + return NULL;
83930 +
83931 + return cachep->name;
83932 +}
83933 +#endif
83934 +
83935 /**
83936 * ksize - get the actual amount of memory allocated for a given object
83937 * @objp: Pointer to the object
83938 diff --git a/mm/slab.h b/mm/slab.h
83939 index 34a98d6..73633d1 100644
83940 --- a/mm/slab.h
83941 +++ b/mm/slab.h
83942 @@ -58,7 +58,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
83943
83944 /* Legal flag mask for kmem_cache_create(), for various configurations */
83945 #define SLAB_CORE_FLAGS (SLAB_HWCACHE_ALIGN | SLAB_CACHE_DMA | SLAB_PANIC | \
83946 - SLAB_DESTROY_BY_RCU | SLAB_DEBUG_OBJECTS )
83947 + SLAB_DESTROY_BY_RCU | SLAB_DEBUG_OBJECTS | SLAB_USERCOPY)
83948
83949 #if defined(CONFIG_DEBUG_SLAB)
83950 #define SLAB_DEBUG_FLAGS (SLAB_RED_ZONE | SLAB_POISON | SLAB_STORE_USER)
83951 @@ -220,6 +220,9 @@ static inline struct kmem_cache *cache_from_obj(struct kmem_cache *s, void *x)
83952 return s;
83953
83954 page = virt_to_head_page(x);
83955 +
83956 + BUG_ON(!PageSlab(page));
83957 +
83958 cachep = page->slab_cache;
83959 if (slab_equal_or_root(cachep, s))
83960 return cachep;
83961 diff --git a/mm/slab_common.c b/mm/slab_common.c
83962 index 3f3cd97..93b0236 100644
83963 --- a/mm/slab_common.c
83964 +++ b/mm/slab_common.c
83965 @@ -22,7 +22,7 @@
83966
83967 #include "slab.h"
83968
83969 -enum slab_state slab_state;
83970 +enum slab_state slab_state __read_only;
83971 LIST_HEAD(slab_caches);
83972 DEFINE_MUTEX(slab_mutex);
83973 struct kmem_cache *kmem_cache;
83974 @@ -209,7 +209,7 @@ kmem_cache_create_memcg(struct mem_cgroup *memcg, const char *name, size_t size,
83975
83976 err = __kmem_cache_create(s, flags);
83977 if (!err) {
83978 - s->refcount = 1;
83979 + atomic_set(&s->refcount, 1);
83980 list_add(&s->list, &slab_caches);
83981 memcg_cache_list_add(memcg, s);
83982 } else {
83983 @@ -255,8 +255,7 @@ void kmem_cache_destroy(struct kmem_cache *s)
83984
83985 get_online_cpus();
83986 mutex_lock(&slab_mutex);
83987 - s->refcount--;
83988 - if (!s->refcount) {
83989 + if (atomic_dec_and_test(&s->refcount)) {
83990 list_del(&s->list);
83991
83992 if (!__kmem_cache_shutdown(s)) {
83993 @@ -302,7 +301,7 @@ void __init create_boot_cache(struct kmem_cache *s, const char *name, size_t siz
83994 panic("Creation of kmalloc slab %s size=%zd failed. Reason %d\n",
83995 name, size, err);
83996
83997 - s->refcount = -1; /* Exempt from merging for now */
83998 + atomic_set(&s->refcount, -1); /* Exempt from merging for now */
83999 }
84000
84001 struct kmem_cache *__init create_kmalloc_cache(const char *name, size_t size,
84002 @@ -315,7 +314,7 @@ struct kmem_cache *__init create_kmalloc_cache(const char *name, size_t size,
84003
84004 create_boot_cache(s, name, size, flags);
84005 list_add(&s->list, &slab_caches);
84006 - s->refcount = 1;
84007 + atomic_set(&s->refcount, 1);
84008 return s;
84009 }
84010
84011 diff --git a/mm/slob.c b/mm/slob.c
84012 index eeed4a0..6ee34ec 100644
84013 --- a/mm/slob.c
84014 +++ b/mm/slob.c
84015 @@ -157,7 +157,7 @@ static void set_slob(slob_t *s, slobidx_t size, slob_t *next)
84016 /*
84017 * Return the size of a slob block.
84018 */
84019 -static slobidx_t slob_units(slob_t *s)
84020 +static slobidx_t slob_units(const slob_t *s)
84021 {
84022 if (s->units > 0)
84023 return s->units;
84024 @@ -167,7 +167,7 @@ static slobidx_t slob_units(slob_t *s)
84025 /*
84026 * Return the next free slob block pointer after this one.
84027 */
84028 -static slob_t *slob_next(slob_t *s)
84029 +static slob_t *slob_next(const slob_t *s)
84030 {
84031 slob_t *base = (slob_t *)((unsigned long)s & PAGE_MASK);
84032 slobidx_t next;
84033 @@ -182,14 +182,14 @@ static slob_t *slob_next(slob_t *s)
84034 /*
84035 * Returns true if s is the last free block in its page.
84036 */
84037 -static int slob_last(slob_t *s)
84038 +static int slob_last(const slob_t *s)
84039 {
84040 return !((unsigned long)slob_next(s) & ~PAGE_MASK);
84041 }
84042
84043 -static void *slob_new_pages(gfp_t gfp, int order, int node)
84044 +static struct page *slob_new_pages(gfp_t gfp, unsigned int order, int node)
84045 {
84046 - void *page;
84047 + struct page *page;
84048
84049 #ifdef CONFIG_NUMA
84050 if (node != NUMA_NO_NODE)
84051 @@ -201,14 +201,18 @@ static void *slob_new_pages(gfp_t gfp, int order, int node)
84052 if (!page)
84053 return NULL;
84054
84055 - return page_address(page);
84056 + __SetPageSlab(page);
84057 + return page;
84058 }
84059
84060 -static void slob_free_pages(void *b, int order)
84061 +static void slob_free_pages(struct page *sp, int order)
84062 {
84063 if (current->reclaim_state)
84064 current->reclaim_state->reclaimed_slab += 1 << order;
84065 - free_pages((unsigned long)b, order);
84066 + __ClearPageSlab(sp);
84067 + reset_page_mapcount(sp);
84068 + sp->private = 0;
84069 + __free_pages(sp, order);
84070 }
84071
84072 /*
84073 @@ -313,15 +317,15 @@ static void *slob_alloc(size_t size, gfp_t gfp, int align, int node)
84074
84075 /* Not enough space: must allocate a new page */
84076 if (!b) {
84077 - b = slob_new_pages(gfp & ~__GFP_ZERO, 0, node);
84078 - if (!b)
84079 + sp = slob_new_pages(gfp & ~__GFP_ZERO, 0, node);
84080 + if (!sp)
84081 return NULL;
84082 - sp = virt_to_page(b);
84083 - __SetPageSlab(sp);
84084 + b = page_address(sp);
84085
84086 spin_lock_irqsave(&slob_lock, flags);
84087 sp->units = SLOB_UNITS(PAGE_SIZE);
84088 sp->freelist = b;
84089 + sp->private = 0;
84090 INIT_LIST_HEAD(&sp->list);
84091 set_slob(b, SLOB_UNITS(PAGE_SIZE), b + SLOB_UNITS(PAGE_SIZE));
84092 set_slob_page_free(sp, slob_list);
84093 @@ -359,9 +363,7 @@ static void slob_free(void *block, int size)
84094 if (slob_page_free(sp))
84095 clear_slob_page_free(sp);
84096 spin_unlock_irqrestore(&slob_lock, flags);
84097 - __ClearPageSlab(sp);
84098 - page_mapcount_reset(sp);
84099 - slob_free_pages(b, 0);
84100 + slob_free_pages(sp, 0);
84101 return;
84102 }
84103
84104 @@ -424,11 +426,10 @@ out:
84105 */
84106
84107 static __always_inline void *
84108 -__do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
84109 +__do_kmalloc_node_align(size_t size, gfp_t gfp, int node, unsigned long caller, int align)
84110 {
84111 - unsigned int *m;
84112 - int align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
84113 - void *ret;
84114 + slob_t *m;
84115 + void *ret = NULL;
84116
84117 gfp &= gfp_allowed_mask;
84118
84119 @@ -442,23 +443,41 @@ __do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
84120
84121 if (!m)
84122 return NULL;
84123 - *m = size;
84124 + BUILD_BUG_ON(ARCH_KMALLOC_MINALIGN < 2 * SLOB_UNIT);
84125 + BUILD_BUG_ON(ARCH_SLAB_MINALIGN < 2 * SLOB_UNIT);
84126 + m[0].units = size;
84127 + m[1].units = align;
84128 ret = (void *)m + align;
84129
84130 trace_kmalloc_node(caller, ret,
84131 size, size + align, gfp, node);
84132 } else {
84133 unsigned int order = get_order(size);
84134 + struct page *page;
84135
84136 if (likely(order))
84137 gfp |= __GFP_COMP;
84138 - ret = slob_new_pages(gfp, order, node);
84139 + page = slob_new_pages(gfp, order, node);
84140 + if (page) {
84141 + ret = page_address(page);
84142 + page->private = size;
84143 + }
84144
84145 trace_kmalloc_node(caller, ret,
84146 size, PAGE_SIZE << order, gfp, node);
84147 }
84148
84149 - kmemleak_alloc(ret, size, 1, gfp);
84150 + return ret;
84151 +}
84152 +
84153 +static __always_inline void *
84154 +__do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
84155 +{
84156 + int align = max(ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
84157 + void *ret = __do_kmalloc_node_align(size, gfp, node, caller, align);
84158 +
84159 + if (!ZERO_OR_NULL_PTR(ret))
84160 + kmemleak_alloc(ret, size, 1, gfp);
84161 return ret;
84162 }
84163
84164 @@ -493,34 +512,112 @@ void kfree(const void *block)
84165 return;
84166 kmemleak_free(block);
84167
84168 + VM_BUG_ON(!virt_addr_valid(block));
84169 sp = virt_to_page(block);
84170 - if (PageSlab(sp)) {
84171 + VM_BUG_ON(!PageSlab(sp));
84172 + if (!sp->private) {
84173 int align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
84174 - unsigned int *m = (unsigned int *)(block - align);
84175 - slob_free(m, *m + align);
84176 - } else
84177 + slob_t *m = (slob_t *)(block - align);
84178 + slob_free(m, m[0].units + align);
84179 + } else {
84180 + __ClearPageSlab(sp);
84181 + reset_page_mapcount(sp);
84182 + sp->private = 0;
84183 __free_pages(sp, compound_order(sp));
84184 + }
84185 }
84186 EXPORT_SYMBOL(kfree);
84187
84188 +bool is_usercopy_object(const void *ptr)
84189 +{
84190 + if (!slab_is_available())
84191 + return false;
84192 +
84193 + // PAX: TODO
84194 +
84195 + return false;
84196 +}
84197 +
84198 +#ifdef CONFIG_PAX_USERCOPY
84199 +const char *check_heap_object(const void *ptr, unsigned long n)
84200 +{
84201 + struct page *page;
84202 + const slob_t *free;
84203 + const void *base;
84204 + unsigned long flags;
84205 +
84206 + if (ZERO_OR_NULL_PTR(ptr))
84207 + return "<null>";
84208 +
84209 + if (!virt_addr_valid(ptr))
84210 + return NULL;
84211 +
84212 + page = virt_to_head_page(ptr);
84213 + if (!PageSlab(page))
84214 + return NULL;
84215 +
84216 + if (page->private) {
84217 + base = page;
84218 + if (base <= ptr && n <= page->private - (ptr - base))
84219 + return NULL;
84220 + return "<slob>";
84221 + }
84222 +
84223 + /* some tricky double walking to find the chunk */
84224 + spin_lock_irqsave(&slob_lock, flags);
84225 + base = (void *)((unsigned long)ptr & PAGE_MASK);
84226 + free = page->freelist;
84227 +
84228 + while (!slob_last(free) && (void *)free <= ptr) {
84229 + base = free + slob_units(free);
84230 + free = slob_next(free);
84231 + }
84232 +
84233 + while (base < (void *)free) {
84234 + slobidx_t m = ((slob_t *)base)[0].units, align = ((slob_t *)base)[1].units;
84235 + int size = SLOB_UNIT * SLOB_UNITS(m + align);
84236 + int offset;
84237 +
84238 + if (ptr < base + align)
84239 + break;
84240 +
84241 + offset = ptr - base - align;
84242 + if (offset >= m) {
84243 + base += size;
84244 + continue;
84245 + }
84246 +
84247 + if (n > m - offset)
84248 + break;
84249 +
84250 + spin_unlock_irqrestore(&slob_lock, flags);
84251 + return NULL;
84252 + }
84253 +
84254 + spin_unlock_irqrestore(&slob_lock, flags);
84255 + return "<slob>";
84256 +}
84257 +#endif
84258 +
84259 /* can't use ksize for kmem_cache_alloc memory, only kmalloc */
84260 size_t ksize(const void *block)
84261 {
84262 struct page *sp;
84263 int align;
84264 - unsigned int *m;
84265 + slob_t *m;
84266
84267 BUG_ON(!block);
84268 if (unlikely(block == ZERO_SIZE_PTR))
84269 return 0;
84270
84271 sp = virt_to_page(block);
84272 - if (unlikely(!PageSlab(sp)))
84273 - return PAGE_SIZE << compound_order(sp);
84274 + VM_BUG_ON(!PageSlab(sp));
84275 + if (sp->private)
84276 + return sp->private;
84277
84278 align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
84279 - m = (unsigned int *)(block - align);
84280 - return SLOB_UNITS(*m) * SLOB_UNIT;
84281 + m = (slob_t *)(block - align);
84282 + return SLOB_UNITS(m[0].units) * SLOB_UNIT;
84283 }
84284 EXPORT_SYMBOL(ksize);
84285
84286 @@ -536,23 +633,33 @@ int __kmem_cache_create(struct kmem_cache *c, unsigned long flags)
84287
84288 void *kmem_cache_alloc_node(struct kmem_cache *c, gfp_t flags, int node)
84289 {
84290 - void *b;
84291 + void *b = NULL;
84292
84293 flags &= gfp_allowed_mask;
84294
84295 lockdep_trace_alloc(flags);
84296
84297 +#ifdef CONFIG_PAX_USERCOPY_SLABS
84298 + b = __do_kmalloc_node_align(c->size, flags, node, _RET_IP_, c->align);
84299 +#else
84300 if (c->size < PAGE_SIZE) {
84301 b = slob_alloc(c->size, flags, c->align, node);
84302 trace_kmem_cache_alloc_node(_RET_IP_, b, c->object_size,
84303 SLOB_UNITS(c->size) * SLOB_UNIT,
84304 flags, node);
84305 } else {
84306 - b = slob_new_pages(flags, get_order(c->size), node);
84307 + struct page *sp;
84308 +
84309 + sp = slob_new_pages(flags, get_order(c->size), node);
84310 + if (sp) {
84311 + b = page_address(sp);
84312 + sp->private = c->size;
84313 + }
84314 trace_kmem_cache_alloc_node(_RET_IP_, b, c->object_size,
84315 PAGE_SIZE << get_order(c->size),
84316 flags, node);
84317 }
84318 +#endif
84319
84320 if (c->ctor)
84321 c->ctor(b);
84322 @@ -564,10 +671,14 @@ EXPORT_SYMBOL(kmem_cache_alloc_node);
84323
84324 static void __kmem_cache_free(void *b, int size)
84325 {
84326 - if (size < PAGE_SIZE)
84327 + struct page *sp;
84328 +
84329 + sp = virt_to_page(b);
84330 + BUG_ON(!PageSlab(sp));
84331 + if (!sp->private)
84332 slob_free(b, size);
84333 else
84334 - slob_free_pages(b, get_order(size));
84335 + slob_free_pages(sp, get_order(size));
84336 }
84337
84338 static void kmem_rcu_free(struct rcu_head *head)
84339 @@ -580,17 +691,31 @@ static void kmem_rcu_free(struct rcu_head *head)
84340
84341 void kmem_cache_free(struct kmem_cache *c, void *b)
84342 {
84343 + int size = c->size;
84344 +
84345 +#ifdef CONFIG_PAX_USERCOPY_SLABS
84346 + if (size + c->align < PAGE_SIZE) {
84347 + size += c->align;
84348 + b -= c->align;
84349 + }
84350 +#endif
84351 +
84352 kmemleak_free_recursive(b, c->flags);
84353 if (unlikely(c->flags & SLAB_DESTROY_BY_RCU)) {
84354 struct slob_rcu *slob_rcu;
84355 - slob_rcu = b + (c->size - sizeof(struct slob_rcu));
84356 - slob_rcu->size = c->size;
84357 + slob_rcu = b + (size - sizeof(struct slob_rcu));
84358 + slob_rcu->size = size;
84359 call_rcu(&slob_rcu->head, kmem_rcu_free);
84360 } else {
84361 - __kmem_cache_free(b, c->size);
84362 + __kmem_cache_free(b, size);
84363 }
84364
84365 +#ifdef CONFIG_PAX_USERCOPY_SLABS
84366 + trace_kfree(_RET_IP_, b);
84367 +#else
84368 trace_kmem_cache_free(_RET_IP_, b);
84369 +#endif
84370 +
84371 }
84372 EXPORT_SYMBOL(kmem_cache_free);
84373
84374 diff --git a/mm/slub.c b/mm/slub.c
84375 index 4aec537..a64753d 100644
84376 --- a/mm/slub.c
84377 +++ b/mm/slub.c
84378 @@ -197,7 +197,7 @@ struct track {
84379
84380 enum track_item { TRACK_ALLOC, TRACK_FREE };
84381
84382 -#ifdef CONFIG_SYSFS
84383 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
84384 static int sysfs_slab_add(struct kmem_cache *);
84385 static int sysfs_slab_alias(struct kmem_cache *, const char *);
84386 static void sysfs_slab_remove(struct kmem_cache *);
84387 @@ -518,7 +518,7 @@ static void print_track(const char *s, struct track *t)
84388 if (!t->addr)
84389 return;
84390
84391 - printk(KERN_ERR "INFO: %s in %pS age=%lu cpu=%u pid=%d\n",
84392 + printk(KERN_ERR "INFO: %s in %pA age=%lu cpu=%u pid=%d\n",
84393 s, (void *)t->addr, jiffies - t->when, t->cpu, t->pid);
84394 #ifdef CONFIG_STACKTRACE
84395 {
84396 @@ -2653,7 +2653,7 @@ static int slub_min_objects;
84397 * Merge control. If this is set then no merging of slab caches will occur.
84398 * (Could be removed. This was introduced to pacify the merge skeptics.)
84399 */
84400 -static int slub_nomerge;
84401 +static int slub_nomerge = 1;
84402
84403 /*
84404 * Calculate the order of allocation given an slab object size.
84405 @@ -3181,6 +3181,10 @@ EXPORT_SYMBOL(kmalloc_caches);
84406 static struct kmem_cache *kmalloc_dma_caches[SLUB_PAGE_SHIFT];
84407 #endif
84408
84409 +#ifdef CONFIG_PAX_USERCOPY_SLABS
84410 +static struct kmem_cache *kmalloc_usercopy_caches[SLUB_PAGE_SHIFT];
84411 +#endif
84412 +
84413 static int __init setup_slub_min_order(char *str)
84414 {
84415 get_option(&str, &slub_min_order);
84416 @@ -3272,6 +3276,13 @@ static struct kmem_cache *get_slab(size_t size, gfp_t flags)
84417 return kmalloc_dma_caches[index];
84418
84419 #endif
84420 +
84421 +#ifdef CONFIG_PAX_USERCOPY_SLABS
84422 + if (flags & SLAB_USERCOPY)
84423 + return kmalloc_usercopy_caches[index];
84424 +
84425 +#endif
84426 +
84427 return kmalloc_caches[index];
84428 }
84429
84430 @@ -3340,6 +3351,59 @@ void *__kmalloc_node(size_t size, gfp_t flags, int node)
84431 EXPORT_SYMBOL(__kmalloc_node);
84432 #endif
84433
84434 +bool is_usercopy_object(const void *ptr)
84435 +{
84436 + struct page *page;
84437 + struct kmem_cache *s;
84438 +
84439 + if (ZERO_OR_NULL_PTR(ptr))
84440 + return false;
84441 +
84442 + if (!slab_is_available())
84443 + return false;
84444 +
84445 + if (!virt_addr_valid(ptr))
84446 + return false;
84447 +
84448 + page = virt_to_head_page(ptr);
84449 +
84450 + if (!PageSlab(page))
84451 + return false;
84452 +
84453 + s = page->slab_cache;
84454 + return s->flags & SLAB_USERCOPY;
84455 +}
84456 +
84457 +#ifdef CONFIG_PAX_USERCOPY
84458 +const char *check_heap_object(const void *ptr, unsigned long n)
84459 +{
84460 + struct page *page;
84461 + struct kmem_cache *s;
84462 + unsigned long offset;
84463 +
84464 + if (ZERO_OR_NULL_PTR(ptr))
84465 + return "<null>";
84466 +
84467 + if (!virt_addr_valid(ptr))
84468 + return NULL;
84469 +
84470 + page = virt_to_head_page(ptr);
84471 +
84472 + if (!PageSlab(page))
84473 + return NULL;
84474 +
84475 + s = page->slab_cache;
84476 + if (!(s->flags & SLAB_USERCOPY))
84477 + return s->name;
84478 +
84479 + offset = (ptr - page_address(page)) % s->size;
84480 + if (offset <= s->object_size && n <= s->object_size - offset)
84481 + return NULL;
84482 +
84483 + return s->name;
84484 +}
84485 +#endif
84486 +
84487 size_t ksize(const void *object)
84488 {
84489 struct page *page;
84490 @@ -3404,6 +3468,7 @@ void kfree(const void *x)
84491 if (unlikely(ZERO_OR_NULL_PTR(x)))
84492 return;
84493
84494 + VM_BUG_ON(!virt_addr_valid(x));
84495 page = virt_to_head_page(x);
84496 if (unlikely(!PageSlab(page))) {
84497 BUG_ON(!PageCompound(page));
84498 @@ -3712,17 +3777,17 @@ void __init kmem_cache_init(void)
84499
84500 /* Caches that are not of the two-to-the-power-of size */
84501 if (KMALLOC_MIN_SIZE <= 32) {
84502 - kmalloc_caches[1] = create_kmalloc_cache("kmalloc-96", 96, 0);
84503 + kmalloc_caches[1] = create_kmalloc_cache("kmalloc-96", 96, SLAB_USERCOPY);
84504 caches++;
84505 }
84506
84507 if (KMALLOC_MIN_SIZE <= 64) {
84508 - kmalloc_caches[2] = create_kmalloc_cache("kmalloc-192", 192, 0);
84509 + kmalloc_caches[2] = create_kmalloc_cache("kmalloc-192", 192, SLAB_USERCOPY);
84510 caches++;
84511 }
84512
84513 for (i = KMALLOC_SHIFT_LOW; i < SLUB_PAGE_SHIFT; i++) {
84514 - kmalloc_caches[i] = create_kmalloc_cache("kmalloc", 1 << i, 0);
84515 + kmalloc_caches[i] = create_kmalloc_cache("kmalloc", 1 << i, SLAB_USERCOPY);
84516 caches++;
84517 }
84518
84519 @@ -3764,6 +3829,22 @@ void __init kmem_cache_init(void)
84520 }
84521 }
84522 #endif
84523 +
84524 +#ifdef CONFIG_PAX_USERCOPY_SLABS
84525 + for (i = 0; i < SLUB_PAGE_SHIFT; i++) {
84526 + struct kmem_cache *s = kmalloc_caches[i];
84527 +
84528 + if (s && s->size) {
84529 + char *name = kasprintf(GFP_NOWAIT,
84530 + "usercopy-kmalloc-%d", s->object_size);
84531 +
84532 + BUG_ON(!name);
84533 + kmalloc_usercopy_caches[i] = create_kmalloc_cache(name,
84534 + s->object_size, SLAB_USERCOPY);
84535 + }
84536 + }
84537 +#endif
84538 +
84539 printk(KERN_INFO
84540 "SLUB: Genslabs=%d, HWalign=%d, Order=%d-%d, MinObjects=%d,"
84541 " CPUs=%d, Nodes=%d\n",
84542 @@ -3790,7 +3871,7 @@ static int slab_unmergeable(struct kmem_cache *s)
84543 /*
84544 * We may have set a slab to be unmergeable during bootstrap.
84545 */
84546 - if (s->refcount < 0)
84547 + if (atomic_read(&s->refcount) < 0)
84548 return 1;
84549
84550 return 0;
84551 @@ -3848,7 +3929,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
84552
84553 s = find_mergeable(memcg, size, align, flags, name, ctor);
84554 if (s) {
84555 - s->refcount++;
84556 + atomic_inc(&s->refcount);
84557 /*
84558 * Adjust the object sizes so that we clear
84559 * the complete object on kzalloc.
84560 @@ -3857,7 +3938,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
84561 s->inuse = max_t(int, s->inuse, ALIGN(size, sizeof(void *)));
84562
84563 if (sysfs_slab_alias(s, name)) {
84564 - s->refcount--;
84565 + atomic_dec(&s->refcount);
84566 s = NULL;
84567 }
84568 }
84569 @@ -3919,7 +4000,7 @@ static int __cpuinit slab_cpuup_callback(struct notifier_block *nfb,
84570 return NOTIFY_OK;
84571 }
84572
84573 -static struct notifier_block __cpuinitdata slab_notifier = {
84574 +static struct notifier_block slab_notifier = {
84575 .notifier_call = slab_cpuup_callback
84576 };
84577
84578 @@ -3977,7 +4058,7 @@ void *__kmalloc_node_track_caller(size_t size, gfp_t gfpflags,
84579 }
84580 #endif
84581
84582 -#ifdef CONFIG_SYSFS
84583 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
84584 static int count_inuse(struct page *page)
84585 {
84586 return page->inuse;
84587 @@ -4364,12 +4445,12 @@ static void resiliency_test(void)
84588 validate_slab_cache(kmalloc_caches[9]);
84589 }
84590 #else
84591 -#ifdef CONFIG_SYSFS
84592 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
84593 static void resiliency_test(void) {};
84594 #endif
84595 #endif
84596
84597 -#ifdef CONFIG_SYSFS
84598 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
84599 enum slab_stat_type {
84600 SL_ALL, /* All slabs */
84601 SL_PARTIAL, /* Only partially allocated slabs */
84602 @@ -4613,7 +4694,7 @@ SLAB_ATTR_RO(ctor);
84603
84604 static ssize_t aliases_show(struct kmem_cache *s, char *buf)
84605 {
84606 - return sprintf(buf, "%d\n", s->refcount - 1);
84607 + return sprintf(buf, "%d\n", atomic_read(&s->refcount) - 1);
84608 }
84609 SLAB_ATTR_RO(aliases);
84610
84611 @@ -5266,6 +5347,7 @@ static char *create_unique_id(struct kmem_cache *s)
84612 return name;
84613 }
84614
84615 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
84616 static int sysfs_slab_add(struct kmem_cache *s)
84617 {
84618 int err;
84619 @@ -5323,6 +5405,7 @@ static void sysfs_slab_remove(struct kmem_cache *s)
84620 kobject_del(&s->kobj);
84621 kobject_put(&s->kobj);
84622 }
84623 +#endif
84624
84625 /*
84626 * Need to buffer aliases during bootup until sysfs becomes
84627 @@ -5336,6 +5419,7 @@ struct saved_alias {
84628
84629 static struct saved_alias *alias_list;
84630
84631 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
84632 static int sysfs_slab_alias(struct kmem_cache *s, const char *name)
84633 {
84634 struct saved_alias *al;
84635 @@ -5358,6 +5442,7 @@ static int sysfs_slab_alias(struct kmem_cache *s, const char *name)
84636 alias_list = al;
84637 return 0;
84638 }
84639 +#endif
84640
84641 static int __init slab_sysfs_init(void)
84642 {
84643 diff --git a/mm/sparse-vmemmap.c b/mm/sparse-vmemmap.c
84644 index 1b7e22a..3fcd4f3 100644
84645 --- a/mm/sparse-vmemmap.c
84646 +++ b/mm/sparse-vmemmap.c
84647 @@ -128,7 +128,7 @@ pud_t * __meminit vmemmap_pud_populate(pgd_t *pgd, unsigned long addr, int node)
84648 void *p = vmemmap_alloc_block(PAGE_SIZE, node);
84649 if (!p)
84650 return NULL;
84651 - pud_populate(&init_mm, pud, p);
84652 + pud_populate_kernel(&init_mm, pud, p);
84653 }
84654 return pud;
84655 }
84656 @@ -140,7 +140,7 @@ pgd_t * __meminit vmemmap_pgd_populate(unsigned long addr, int node)
84657 void *p = vmemmap_alloc_block(PAGE_SIZE, node);
84658 if (!p)
84659 return NULL;
84660 - pgd_populate(&init_mm, pgd, p);
84661 + pgd_populate_kernel(&init_mm, pgd, p);
84662 }
84663 return pgd;
84664 }
84665 diff --git a/mm/sparse.c b/mm/sparse.c
84666 index 7ca6dc8..6472aa1 100644
84667 --- a/mm/sparse.c
84668 +++ b/mm/sparse.c
84669 @@ -783,7 +783,7 @@ static void clear_hwpoisoned_pages(struct page *memmap, int nr_pages)
84670
84671 for (i = 0; i < PAGES_PER_SECTION; i++) {
84672 if (PageHWPoison(&memmap[i])) {
84673 - atomic_long_sub(1, &num_poisoned_pages);
84674 + atomic_long_sub_unchecked(1, &num_poisoned_pages);
84675 ClearPageHWPoison(&memmap[i]);
84676 }
84677 }
84678 diff --git a/mm/swap.c b/mm/swap.c
84679 index 8a529a0..154ef26 100644
84680 --- a/mm/swap.c
84681 +++ b/mm/swap.c
84682 @@ -30,6 +30,7 @@
84683 #include <linux/backing-dev.h>
84684 #include <linux/memcontrol.h>
84685 #include <linux/gfp.h>
84686 +#include <linux/hugetlb.h>
84687
84688 #include "internal.h"
84689
84690 @@ -72,6 +73,8 @@ static void __put_compound_page(struct page *page)
84691
84692 __page_cache_release(page);
84693 dtor = get_compound_page_dtor(page);
84694 + if (!PageHuge(page))
84695 + BUG_ON(dtor != free_compound_page);
84696 (*dtor)(page);
84697 }
84698
84699 diff --git a/mm/swapfile.c b/mm/swapfile.c
84700 index a1f7772..9e982ac 100644
84701 --- a/mm/swapfile.c
84702 +++ b/mm/swapfile.c
84703 @@ -66,7 +66,7 @@ static DEFINE_MUTEX(swapon_mutex);
84704
84705 static DECLARE_WAIT_QUEUE_HEAD(proc_poll_wait);
84706 /* Activity counter to indicate that a swapon or swapoff has occurred */
84707 -static atomic_t proc_poll_event = ATOMIC_INIT(0);
84708 +static atomic_unchecked_t proc_poll_event = ATOMIC_INIT(0);
84709
84710 static inline unsigned char swap_count(unsigned char ent)
84711 {
84712 @@ -1683,7 +1683,7 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile)
84713 }
84714 filp_close(swap_file, NULL);
84715 err = 0;
84716 - atomic_inc(&proc_poll_event);
84717 + atomic_inc_unchecked(&proc_poll_event);
84718 wake_up_interruptible(&proc_poll_wait);
84719
84720 out_dput:
84721 @@ -1700,8 +1700,8 @@ static unsigned swaps_poll(struct file *file, poll_table *wait)
84722
84723 poll_wait(file, &proc_poll_wait, wait);
84724
84725 - if (seq->poll_event != atomic_read(&proc_poll_event)) {
84726 - seq->poll_event = atomic_read(&proc_poll_event);
84727 + if (seq->poll_event != atomic_read_unchecked(&proc_poll_event)) {
84728 + seq->poll_event = atomic_read_unchecked(&proc_poll_event);
84729 return POLLIN | POLLRDNORM | POLLERR | POLLPRI;
84730 }
84731
84732 @@ -1799,7 +1799,7 @@ static int swaps_open(struct inode *inode, struct file *file)
84733 return ret;
84734
84735 seq = file->private_data;
84736 - seq->poll_event = atomic_read(&proc_poll_event);
84737 + seq->poll_event = atomic_read_unchecked(&proc_poll_event);
84738 return 0;
84739 }
84740
84741 @@ -2142,7 +2142,7 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
84742 (frontswap_map) ? "FS" : "");
84743
84744 mutex_unlock(&swapon_mutex);
84745 - atomic_inc(&proc_poll_event);
84746 + atomic_inc_unchecked(&proc_poll_event);
84747 wake_up_interruptible(&proc_poll_wait);
84748
84749 if (S_ISREG(inode->i_mode))
84750 diff --git a/mm/util.c b/mm/util.c
84751 index ab1424d..7c5bd5a 100644
84752 --- a/mm/util.c
84753 +++ b/mm/util.c
84754 @@ -294,6 +294,12 @@ done:
84755 void arch_pick_mmap_layout(struct mm_struct *mm)
84756 {
84757 mm->mmap_base = TASK_UNMAPPED_BASE;
84758 +
84759 +#ifdef CONFIG_PAX_RANDMMAP
84760 + if (mm->pax_flags & MF_PAX_RANDMMAP)
84761 + mm->mmap_base += mm->delta_mmap;
84762 +#endif
84763 +
84764 mm->get_unmapped_area = arch_get_unmapped_area;
84765 mm->unmap_area = arch_unmap_area;
84766 }
84767 diff --git a/mm/vmalloc.c b/mm/vmalloc.c
84768 index 0f751f2..ef398a0 100644
84769 --- a/mm/vmalloc.c
84770 +++ b/mm/vmalloc.c
84771 @@ -39,8 +39,19 @@ static void vunmap_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end)
84772
84773 pte = pte_offset_kernel(pmd, addr);
84774 do {
84775 - pte_t ptent = ptep_get_and_clear(&init_mm, addr, pte);
84776 - WARN_ON(!pte_none(ptent) && !pte_present(ptent));
84777 +
84778 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
84779 + if ((unsigned long)MODULES_EXEC_VADDR <= addr && addr < (unsigned long)MODULES_EXEC_END) {
84780 + BUG_ON(!pte_exec(*pte));
84781 + set_pte_at(&init_mm, addr, pte, pfn_pte(__pa(addr) >> PAGE_SHIFT, PAGE_KERNEL_EXEC));
84782 + continue;
84783 + }
84784 +#endif
84785 +
84786 + {
84787 + pte_t ptent = ptep_get_and_clear(&init_mm, addr, pte);
84788 + WARN_ON(!pte_none(ptent) && !pte_present(ptent));
84789 + }
84790 } while (pte++, addr += PAGE_SIZE, addr != end);
84791 }
84792
84793 @@ -100,16 +111,29 @@ static int vmap_pte_range(pmd_t *pmd, unsigned long addr,
84794 pte = pte_alloc_kernel(pmd, addr);
84795 if (!pte)
84796 return -ENOMEM;
84797 +
84798 + pax_open_kernel();
84799 do {
84800 struct page *page = pages[*nr];
84801
84802 - if (WARN_ON(!pte_none(*pte)))
84803 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
84804 + if (pgprot_val(prot) & _PAGE_NX)
84805 +#endif
84806 +
84807 + if (!pte_none(*pte)) {
84808 + pax_close_kernel();
84809 + WARN_ON(1);
84810 return -EBUSY;
84811 - if (WARN_ON(!page))
84812 + }
84813 + if (!page) {
84814 + pax_close_kernel();
84815 + WARN_ON(1);
84816 return -ENOMEM;
84817 + }
84818 set_pte_at(&init_mm, addr, pte, mk_pte(page, prot));
84819 (*nr)++;
84820 } while (pte++, addr += PAGE_SIZE, addr != end);
84821 + pax_close_kernel();
84822 return 0;
84823 }
84824
84825 @@ -119,7 +143,7 @@ static int vmap_pmd_range(pud_t *pud, unsigned long addr,
84826 pmd_t *pmd;
84827 unsigned long next;
84828
84829 - pmd = pmd_alloc(&init_mm, pud, addr);
84830 + pmd = pmd_alloc_kernel(&init_mm, pud, addr);
84831 if (!pmd)
84832 return -ENOMEM;
84833 do {
84834 @@ -136,7 +160,7 @@ static int vmap_pud_range(pgd_t *pgd, unsigned long addr,
84835 pud_t *pud;
84836 unsigned long next;
84837
84838 - pud = pud_alloc(&init_mm, pgd, addr);
84839 + pud = pud_alloc_kernel(&init_mm, pgd, addr);
84840 if (!pud)
84841 return -ENOMEM;
84842 do {
84843 @@ -191,11 +215,20 @@ int is_vmalloc_or_module_addr(const void *x)
84844 * and fall back on vmalloc() if that fails. Others
84845 * just put it in the vmalloc space.
84846 */
84847 -#if defined(CONFIG_MODULES) && defined(MODULES_VADDR)
84848 +#ifdef CONFIG_MODULES
84849 +#ifdef MODULES_VADDR
84850 unsigned long addr = (unsigned long)x;
84851 if (addr >= MODULES_VADDR && addr < MODULES_END)
84852 return 1;
84853 #endif
84854 +
84855 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
84856 + if (x >= (const void *)MODULES_EXEC_VADDR && x < (const void *)MODULES_EXEC_END)
84857 + return 1;
84858 +#endif
84859 +
84860 +#endif
84861 +
84862 return is_vmalloc_addr(x);
84863 }
84864
84865 @@ -216,8 +249,14 @@ struct page *vmalloc_to_page(const void *vmalloc_addr)
84866
84867 if (!pgd_none(*pgd)) {
84868 pud_t *pud = pud_offset(pgd, addr);
84869 +#ifdef CONFIG_X86
84870 + if (!pud_large(*pud))
84871 +#endif
84872 if (!pud_none(*pud)) {
84873 pmd_t *pmd = pmd_offset(pud, addr);
84874 +#ifdef CONFIG_X86
84875 + if (!pmd_large(*pmd))
84876 +#endif
84877 if (!pmd_none(*pmd)) {
84878 pte_t *ptep, pte;
84879
84880 @@ -329,7 +368,7 @@ static void purge_vmap_area_lazy(void);
84881 * Allocate a region of KVA of the specified size and alignment, within the
84882 * vstart and vend.
84883 */
84884 -static struct vmap_area *alloc_vmap_area(unsigned long size,
84885 +static __size_overflow(1) struct vmap_area *alloc_vmap_area(unsigned long size,
84886 unsigned long align,
84887 unsigned long vstart, unsigned long vend,
84888 int node, gfp_t gfp_mask)
84889 @@ -1328,6 +1367,16 @@ static struct vm_struct *__get_vm_area_node(unsigned long size,
84890 struct vm_struct *area;
84891
84892 BUG_ON(in_interrupt());
84893 +
84894 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
84895 + if (flags & VM_KERNEXEC) {
84896 + if (start != VMALLOC_START || end != VMALLOC_END)
84897 + return NULL;
84898 + start = (unsigned long)MODULES_EXEC_VADDR;
84899 + end = (unsigned long)MODULES_EXEC_END;
84900 + }
84901 +#endif
84902 +
84903 if (flags & VM_IOREMAP) {
84904 int bit = fls(size);
84905
84906 @@ -1569,6 +1618,11 @@ void *vmap(struct page **pages, unsigned int count,
84907 if (count > totalram_pages)
84908 return NULL;
84909
84910 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
84911 + if (!(pgprot_val(prot) & _PAGE_NX))
84912 + flags |= VM_KERNEXEC;
84913 +#endif
84914 +
84915 area = get_vm_area_caller((count << PAGE_SHIFT), flags,
84916 __builtin_return_address(0));
84917 if (!area)
84918 @@ -1670,6 +1724,13 @@ void *__vmalloc_node_range(unsigned long size, unsigned long align,
84919 if (!size || (size >> PAGE_SHIFT) > totalram_pages)
84920 goto fail;
84921
84922 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
84923 + if (!(pgprot_val(prot) & _PAGE_NX))
84924 + area = __get_vm_area_node(size, align, VM_ALLOC | VM_UNLIST | VM_KERNEXEC,
84925 + VMALLOC_START, VMALLOC_END, node, gfp_mask, caller);
84926 + else
84927 +#endif
84928 +
84929 area = __get_vm_area_node(size, align, VM_ALLOC | VM_UNLIST,
84930 start, end, node, gfp_mask, caller);
84931 if (!area)
84932 @@ -1845,10 +1906,9 @@ EXPORT_SYMBOL(vzalloc_node);
84933 * For tight control over page level allocator and protection flags
84934 * use __vmalloc() instead.
84935 */
84936 -
84937 void *vmalloc_exec(unsigned long size)
84938 {
84939 - return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL_EXEC,
84940 + return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, PAGE_KERNEL_EXEC,
84941 NUMA_NO_NODE, __builtin_return_address(0));
84942 }
84943
84944 @@ -2139,6 +2199,8 @@ int remap_vmalloc_range(struct vm_area_struct *vma, void *addr,
84945 unsigned long uaddr = vma->vm_start;
84946 unsigned long usize = vma->vm_end - vma->vm_start;
84947
84948 + BUG_ON(vma->vm_mirror);
84949 +
84950 if ((PAGE_SIZE-1) & (unsigned long)addr)
84951 return -EINVAL;
84952
84953 @@ -2578,7 +2640,11 @@ static int s_show(struct seq_file *m, void *p)
84954 v->addr, v->addr + v->size, v->size);
84955
84956 if (v->caller)
84957 +#ifdef CONFIG_GRKERNSEC_HIDESYM
84958 + seq_printf(m, " %pK", v->caller);
84959 +#else
84960 seq_printf(m, " %pS", v->caller);
84961 +#endif
84962
84963 if (v->nr_pages)
84964 seq_printf(m, " pages=%d", v->nr_pages);
84965 diff --git a/mm/vmstat.c b/mm/vmstat.c
84966 index e1d8ed1..253fa3c 100644
84967 --- a/mm/vmstat.c
84968 +++ b/mm/vmstat.c
84969 @@ -78,7 +78,7 @@ void vm_events_fold_cpu(int cpu)
84970 *
84971 * vm_stat contains the global counters
84972 */
84973 -atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS] __cacheline_aligned_in_smp;
84974 +atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS] __cacheline_aligned_in_smp;
84975 EXPORT_SYMBOL(vm_stat);
84976
84977 #ifdef CONFIG_SMP
84978 @@ -454,7 +454,7 @@ void refresh_cpu_vm_stats(int cpu)
84979 v = p->vm_stat_diff[i];
84980 p->vm_stat_diff[i] = 0;
84981 local_irq_restore(flags);
84982 - atomic_long_add(v, &zone->vm_stat[i]);
84983 + atomic_long_add_unchecked(v, &zone->vm_stat[i]);
84984 global_diff[i] += v;
84985 #ifdef CONFIG_NUMA
84986 /* 3 seconds idle till flush */
84987 @@ -492,7 +492,7 @@ void refresh_cpu_vm_stats(int cpu)
84988
84989 for (i = 0; i < NR_VM_ZONE_STAT_ITEMS; i++)
84990 if (global_diff[i])
84991 - atomic_long_add(global_diff[i], &vm_stat[i]);
84992 + atomic_long_add_unchecked(global_diff[i], &vm_stat[i]);
84993 }
84994
84995 void drain_zonestat(struct zone *zone, struct per_cpu_pageset *pset)
84996 @@ -503,8 +503,8 @@ void drain_zonestat(struct zone *zone, struct per_cpu_pageset *pset)
84997 if (pset->vm_stat_diff[i]) {
84998 int v = pset->vm_stat_diff[i];
84999 pset->vm_stat_diff[i] = 0;
85000 - atomic_long_add(v, &zone->vm_stat[i]);
85001 - atomic_long_add(v, &vm_stat[i]);
85002 + atomic_long_add_unchecked(v, &zone->vm_stat[i]);
85003 + atomic_long_add_unchecked(v, &vm_stat[i]);
85004 }
85005 }
85006 #endif
85007 @@ -1224,7 +1224,7 @@ static int __cpuinit vmstat_cpuup_callback(struct notifier_block *nfb,
85008 return NOTIFY_OK;
85009 }
85010
85011 -static struct notifier_block __cpuinitdata vmstat_notifier =
85012 +static struct notifier_block vmstat_notifier =
85013 { &vmstat_cpuup_callback, NULL, 0 };
85014 #endif
85015
85016 @@ -1239,10 +1239,20 @@ static int __init setup_vmstat(void)
85017 start_cpu_timer(cpu);
85018 #endif
85019 #ifdef CONFIG_PROC_FS
85020 - proc_create("buddyinfo", S_IRUGO, NULL, &fragmentation_file_operations);
85021 - proc_create("pagetypeinfo", S_IRUGO, NULL, &pagetypeinfo_file_ops);
85022 - proc_create("vmstat", S_IRUGO, NULL, &proc_vmstat_file_operations);
85023 - proc_create("zoneinfo", S_IRUGO, NULL, &proc_zoneinfo_file_operations);
85024 + {
85025 + mode_t gr_mode = S_IRUGO;
85026 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
85027 + gr_mode = S_IRUSR;
85028 +#endif
85029 + proc_create("buddyinfo", gr_mode, NULL, &fragmentation_file_operations);
85030 + proc_create("pagetypeinfo", gr_mode, NULL, &pagetypeinfo_file_ops);
85031 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
85032 + proc_create("vmstat", gr_mode | S_IRGRP, NULL, &proc_vmstat_file_operations);
85033 +#else
85034 + proc_create("vmstat", gr_mode, NULL, &proc_vmstat_file_operations);
85035 +#endif
85036 + proc_create("zoneinfo", gr_mode, NULL, &proc_zoneinfo_file_operations);
85037 + }
85038 #endif
85039 return 0;
85040 }
85041 diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
85042 index 85addcd..c429a13 100644
85043 --- a/net/8021q/vlan.c
85044 +++ b/net/8021q/vlan.c
85045 @@ -114,6 +114,13 @@ void unregister_vlan_dev(struct net_device *dev, struct list_head *head)
85046 if (vlan_id)
85047 vlan_vid_del(real_dev, vlan_id);
85048
85049 + /* Take it out of our own structures, but be sure to interlock with
85050 + * HW accelerating devices or SW vlan input packet processing if
85051 + * VLAN is not 0 (leave it there for 802.1p).
85052 + */
85053 + if (vlan_id)
85054 + vlan_vid_del(real_dev, vlan_id);
85055 +
85056 /* Get rid of the vlan's reference to real_dev */
85057 dev_put(real_dev);
85058 }
85059 @@ -496,7 +503,7 @@ out:
85060 return NOTIFY_DONE;
85061 }
85062
85063 -static struct notifier_block vlan_notifier_block __read_mostly = {
85064 +static struct notifier_block vlan_notifier_block = {
85065 .notifier_call = vlan_device_event,
85066 };
85067
85068 @@ -571,8 +578,7 @@ static int vlan_ioctl_handler(struct net *net, void __user *arg)
85069 err = -EPERM;
85070 if (!ns_capable(net->user_ns, CAP_NET_ADMIN))
85071 break;
85072 - if ((args.u.name_type >= 0) &&
85073 - (args.u.name_type < VLAN_NAME_TYPE_HIGHEST)) {
85074 + if (args.u.name_type < VLAN_NAME_TYPE_HIGHEST) {
85075 struct vlan_net *vn;
85076
85077 vn = net_generic(net, vlan_net_id);
85078 diff --git a/net/9p/mod.c b/net/9p/mod.c
85079 index 6ab36ae..6f1841b 100644
85080 --- a/net/9p/mod.c
85081 +++ b/net/9p/mod.c
85082 @@ -84,7 +84,7 @@ static LIST_HEAD(v9fs_trans_list);
85083 void v9fs_register_trans(struct p9_trans_module *m)
85084 {
85085 spin_lock(&v9fs_trans_lock);
85086 - list_add_tail(&m->list, &v9fs_trans_list);
85087 + pax_list_add_tail((struct list_head *)&m->list, &v9fs_trans_list);
85088 spin_unlock(&v9fs_trans_lock);
85089 }
85090 EXPORT_SYMBOL(v9fs_register_trans);
85091 @@ -97,7 +97,7 @@ EXPORT_SYMBOL(v9fs_register_trans);
85092 void v9fs_unregister_trans(struct p9_trans_module *m)
85093 {
85094 spin_lock(&v9fs_trans_lock);
85095 - list_del_init(&m->list);
85096 + pax_list_del_init((struct list_head *)&m->list);
85097 spin_unlock(&v9fs_trans_lock);
85098 }
85099 EXPORT_SYMBOL(v9fs_unregister_trans);
85100 diff --git a/net/9p/trans_fd.c b/net/9p/trans_fd.c
85101 index 02efb25..41541a9 100644
85102 --- a/net/9p/trans_fd.c
85103 +++ b/net/9p/trans_fd.c
85104 @@ -425,7 +425,7 @@ static int p9_fd_write(struct p9_client *client, void *v, int len)
85105 oldfs = get_fs();
85106 set_fs(get_ds());
85107 /* The cast to a user pointer is valid due to the set_fs() */
85108 - ret = vfs_write(ts->wr, (__force void __user *)v, len, &ts->wr->f_pos);
85109 + ret = vfs_write(ts->wr, (void __force_user *)v, len, &ts->wr->f_pos);
85110 set_fs(oldfs);
85111
85112 if (ret <= 0 && ret != -ERESTARTSYS && ret != -EAGAIN)
85113 diff --git a/net/atm/atm_misc.c b/net/atm/atm_misc.c
85114 index 876fbe8..8bbea9f 100644
85115 --- a/net/atm/atm_misc.c
85116 +++ b/net/atm/atm_misc.c
85117 @@ -17,7 +17,7 @@ int atm_charge(struct atm_vcc *vcc, int truesize)
85118 if (atomic_read(&sk_atm(vcc)->sk_rmem_alloc) <= sk_atm(vcc)->sk_rcvbuf)
85119 return 1;
85120 atm_return(vcc, truesize);
85121 - atomic_inc(&vcc->stats->rx_drop);
85122 + atomic_inc_unchecked(&vcc->stats->rx_drop);
85123 return 0;
85124 }
85125 EXPORT_SYMBOL(atm_charge);
85126 @@ -39,7 +39,7 @@ struct sk_buff *atm_alloc_charge(struct atm_vcc *vcc, int pdu_size,
85127 }
85128 }
85129 atm_return(vcc, guess);
85130 - atomic_inc(&vcc->stats->rx_drop);
85131 + atomic_inc_unchecked(&vcc->stats->rx_drop);
85132 return NULL;
85133 }
85134 EXPORT_SYMBOL(atm_alloc_charge);
85135 @@ -86,7 +86,7 @@ EXPORT_SYMBOL(atm_pcr_goal);
85136
85137 void sonet_copy_stats(struct k_sonet_stats *from, struct sonet_stats *to)
85138 {
85139 -#define __HANDLE_ITEM(i) to->i = atomic_read(&from->i)
85140 +#define __HANDLE_ITEM(i) to->i = atomic_read_unchecked(&from->i)
85141 __SONET_ITEMS
85142 #undef __HANDLE_ITEM
85143 }
85144 @@ -94,7 +94,7 @@ EXPORT_SYMBOL(sonet_copy_stats);
85145
85146 void sonet_subtract_stats(struct k_sonet_stats *from, struct sonet_stats *to)
85147 {
85148 -#define __HANDLE_ITEM(i) atomic_sub(to->i, &from->i)
85149 +#define __HANDLE_ITEM(i) atomic_sub_unchecked(to->i,&from->i)
85150 __SONET_ITEMS
85151 #undef __HANDLE_ITEM
85152 }
85153 diff --git a/net/atm/lec.h b/net/atm/lec.h
85154 index a86aff9..3a0d6f6 100644
85155 --- a/net/atm/lec.h
85156 +++ b/net/atm/lec.h
85157 @@ -48,7 +48,7 @@ struct lane2_ops {
85158 const u8 *tlvs, u32 sizeoftlvs);
85159 void (*associate_indicator) (struct net_device *dev, const u8 *mac_addr,
85160 const u8 *tlvs, u32 sizeoftlvs);
85161 -};
85162 +} __no_const;
85163
85164 /*
85165 * ATM LAN Emulation supports both LLC & Dix Ethernet EtherType
85166 diff --git a/net/atm/proc.c b/net/atm/proc.c
85167 index 6ac35ff..ac0e136 100644
85168 --- a/net/atm/proc.c
85169 +++ b/net/atm/proc.c
85170 @@ -45,9 +45,9 @@ static void add_stats(struct seq_file *seq, const char *aal,
85171 const struct k_atm_aal_stats *stats)
85172 {
85173 seq_printf(seq, "%s ( %d %d %d %d %d )", aal,
85174 - atomic_read(&stats->tx), atomic_read(&stats->tx_err),
85175 - atomic_read(&stats->rx), atomic_read(&stats->rx_err),
85176 - atomic_read(&stats->rx_drop));
85177 + atomic_read_unchecked(&stats->tx),atomic_read_unchecked(&stats->tx_err),
85178 + atomic_read_unchecked(&stats->rx),atomic_read_unchecked(&stats->rx_err),
85179 + atomic_read_unchecked(&stats->rx_drop));
85180 }
85181
85182 static void atm_dev_info(struct seq_file *seq, const struct atm_dev *dev)
85183 diff --git a/net/atm/resources.c b/net/atm/resources.c
85184 index 0447d5d..3cf4728 100644
85185 --- a/net/atm/resources.c
85186 +++ b/net/atm/resources.c
85187 @@ -160,7 +160,7 @@ EXPORT_SYMBOL(atm_dev_deregister);
85188 static void copy_aal_stats(struct k_atm_aal_stats *from,
85189 struct atm_aal_stats *to)
85190 {
85191 -#define __HANDLE_ITEM(i) to->i = atomic_read(&from->i)
85192 +#define __HANDLE_ITEM(i) to->i = atomic_read_unchecked(&from->i)
85193 __AAL_STAT_ITEMS
85194 #undef __HANDLE_ITEM
85195 }
85196 @@ -168,7 +168,7 @@ static void copy_aal_stats(struct k_atm_aal_stats *from,
85197 static void subtract_aal_stats(struct k_atm_aal_stats *from,
85198 struct atm_aal_stats *to)
85199 {
85200 -#define __HANDLE_ITEM(i) atomic_sub(to->i, &from->i)
85201 +#define __HANDLE_ITEM(i) atomic_sub_unchecked(to->i, &from->i)
85202 __AAL_STAT_ITEMS
85203 #undef __HANDLE_ITEM
85204 }
85205 diff --git a/net/ax25/sysctl_net_ax25.c b/net/ax25/sysctl_net_ax25.c
85206 index d5744b7..506bae3 100644
85207 --- a/net/ax25/sysctl_net_ax25.c
85208 +++ b/net/ax25/sysctl_net_ax25.c
85209 @@ -152,7 +152,7 @@ int ax25_register_dev_sysctl(ax25_dev *ax25_dev)
85210 {
85211 char path[sizeof("net/ax25/") + IFNAMSIZ];
85212 int k;
85213 - struct ctl_table *table;
85214 + ctl_table_no_const *table;
85215
85216 table = kmemdup(ax25_param_table, sizeof(ax25_param_table), GFP_KERNEL);
85217 if (!table)
85218 diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
85219 index a5bb0a7..e1d8b97 100644
85220 --- a/net/batman-adv/bat_iv_ogm.c
85221 +++ b/net/batman-adv/bat_iv_ogm.c
85222 @@ -63,7 +63,7 @@ static int batadv_iv_ogm_iface_enable(struct batadv_hard_iface *hard_iface)
85223
85224 /* randomize initial seqno to avoid collision */
85225 get_random_bytes(&random_seqno, sizeof(random_seqno));
85226 - atomic_set(&hard_iface->bat_iv.ogm_seqno, random_seqno);
85227 + atomic_set_unchecked(&hard_iface->bat_iv.ogm_seqno, random_seqno);
85228
85229 hard_iface->bat_iv.ogm_buff_len = BATADV_OGM_HLEN;
85230 ogm_buff = kmalloc(hard_iface->bat_iv.ogm_buff_len, GFP_ATOMIC);
85231 @@ -611,9 +611,9 @@ static void batadv_iv_ogm_schedule(struct batadv_hard_iface *hard_iface)
85232 batadv_ogm_packet = (struct batadv_ogm_packet *)(*ogm_buff);
85233
85234 /* change sequence number to network order */
85235 - seqno = (uint32_t)atomic_read(&hard_iface->bat_iv.ogm_seqno);
85236 + seqno = (uint32_t)atomic_read_unchecked(&hard_iface->bat_iv.ogm_seqno);
85237 batadv_ogm_packet->seqno = htonl(seqno);
85238 - atomic_inc(&hard_iface->bat_iv.ogm_seqno);
85239 + atomic_inc_unchecked(&hard_iface->bat_iv.ogm_seqno);
85240
85241 batadv_ogm_packet->ttvn = atomic_read(&bat_priv->tt.vn);
85242 batadv_ogm_packet->tt_crc = htons(bat_priv->tt.local_crc);
85243 @@ -1013,7 +1013,7 @@ static void batadv_iv_ogm_process(const struct ethhdr *ethhdr,
85244 return;
85245
85246 /* could be changed by schedule_own_packet() */
85247 - if_incoming_seqno = atomic_read(&if_incoming->bat_iv.ogm_seqno);
85248 + if_incoming_seqno = atomic_read_unchecked(&if_incoming->bat_iv.ogm_seqno);
85249
85250 if (batadv_ogm_packet->flags & BATADV_DIRECTLINK)
85251 has_directlink_flag = 1;
85252 diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c
85253 index 368219e..53f56f9 100644
85254 --- a/net/batman-adv/hard-interface.c
85255 +++ b/net/batman-adv/hard-interface.c
85256 @@ -370,7 +370,7 @@ int batadv_hardif_enable_interface(struct batadv_hard_iface *hard_iface,
85257 hard_iface->batman_adv_ptype.dev = hard_iface->net_dev;
85258 dev_add_pack(&hard_iface->batman_adv_ptype);
85259
85260 - atomic_set(&hard_iface->frag_seqno, 1);
85261 + atomic_set_unchecked(&hard_iface->frag_seqno, 1);
85262 batadv_info(hard_iface->soft_iface, "Adding interface: %s\n",
85263 hard_iface->net_dev->name);
85264
85265 @@ -514,7 +514,7 @@ batadv_hardif_add_interface(struct net_device *net_dev)
85266 /* This can't be called via a bat_priv callback because
85267 * we have no bat_priv yet.
85268 */
85269 - atomic_set(&hard_iface->bat_iv.ogm_seqno, 1);
85270 + atomic_set_unchecked(&hard_iface->bat_iv.ogm_seqno, 1);
85271 hard_iface->bat_iv.ogm_buff = NULL;
85272
85273 return hard_iface;
85274 diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
85275 index 2711e87..4ca48fa 100644
85276 --- a/net/batman-adv/soft-interface.c
85277 +++ b/net/batman-adv/soft-interface.c
85278 @@ -252,7 +252,7 @@ static int batadv_interface_tx(struct sk_buff *skb,
85279 primary_if->net_dev->dev_addr, ETH_ALEN);
85280
85281 /* set broadcast sequence number */
85282 - seqno = atomic_inc_return(&bat_priv->bcast_seqno);
85283 + seqno = atomic_inc_return_unchecked(&bat_priv->bcast_seqno);
85284 bcast_packet->seqno = htonl(seqno);
85285
85286 batadv_add_bcast_packet_to_list(bat_priv, skb, brd_delay);
85287 @@ -527,7 +527,7 @@ struct net_device *batadv_softif_create(const char *name)
85288 atomic_set(&bat_priv->batman_queue_left, BATADV_BATMAN_QUEUE_LEN);
85289
85290 atomic_set(&bat_priv->mesh_state, BATADV_MESH_INACTIVE);
85291 - atomic_set(&bat_priv->bcast_seqno, 1);
85292 + atomic_set_unchecked(&bat_priv->bcast_seqno, 1);
85293 atomic_set(&bat_priv->tt.vn, 0);
85294 atomic_set(&bat_priv->tt.local_changes, 0);
85295 atomic_set(&bat_priv->tt.ogm_append_cnt, 0);
85296 diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h
85297 index 4cd87a0..348e705 100644
85298 --- a/net/batman-adv/types.h
85299 +++ b/net/batman-adv/types.h
85300 @@ -51,7 +51,7 @@
85301 struct batadv_hard_iface_bat_iv {
85302 unsigned char *ogm_buff;
85303 int ogm_buff_len;
85304 - atomic_t ogm_seqno;
85305 + atomic_unchecked_t ogm_seqno;
85306 };
85307
85308 /**
85309 @@ -75,7 +75,7 @@ struct batadv_hard_iface {
85310 int16_t if_num;
85311 char if_status;
85312 struct net_device *net_dev;
85313 - atomic_t frag_seqno;
85314 + atomic_unchecked_t frag_seqno;
85315 struct kobject *hardif_obj;
85316 atomic_t refcount;
85317 struct packet_type batman_adv_ptype;
85318 @@ -495,7 +495,7 @@ struct batadv_priv {
85319 #ifdef CONFIG_BATMAN_ADV_DEBUG
85320 atomic_t log_level;
85321 #endif
85322 - atomic_t bcast_seqno;
85323 + atomic_unchecked_t bcast_seqno;
85324 atomic_t bcast_queue_left;
85325 atomic_t batman_queue_left;
85326 char num_ifaces;
85327 diff --git a/net/batman-adv/unicast.c b/net/batman-adv/unicast.c
85328 index 50e079f..49ce2d2 100644
85329 --- a/net/batman-adv/unicast.c
85330 +++ b/net/batman-adv/unicast.c
85331 @@ -270,7 +270,7 @@ int batadv_frag_send_skb(struct sk_buff *skb, struct batadv_priv *bat_priv,
85332 frag1->flags = BATADV_UNI_FRAG_HEAD | large_tail;
85333 frag2->flags = large_tail;
85334
85335 - seqno = atomic_add_return(2, &hard_iface->frag_seqno);
85336 + seqno = atomic_add_return_unchecked(2, &hard_iface->frag_seqno);
85337 frag1->seqno = htons(seqno - 1);
85338 frag2->seqno = htons(seqno);
85339
85340 diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c
85341 index 6a93614..1415549 100644
85342 --- a/net/bluetooth/hci_sock.c
85343 +++ b/net/bluetooth/hci_sock.c
85344 @@ -929,7 +929,7 @@ static int hci_sock_setsockopt(struct socket *sock, int level, int optname,
85345 uf.event_mask[1] = *((u32 *) f->event_mask + 1);
85346 }
85347
85348 - len = min_t(unsigned int, len, sizeof(uf));
85349 + len = min((size_t)len, sizeof(uf));
85350 if (copy_from_user(&uf, optval, len)) {
85351 err = -EFAULT;
85352 break;
85353 diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
85354 index 7c7e932..7a7815d 100644
85355 --- a/net/bluetooth/l2cap_core.c
85356 +++ b/net/bluetooth/l2cap_core.c
85357 @@ -3395,8 +3395,10 @@ static int l2cap_parse_conf_rsp(struct l2cap_chan *chan, void *rsp, int len,
85358 break;
85359
85360 case L2CAP_CONF_RFC:
85361 - if (olen == sizeof(rfc))
85362 - memcpy(&rfc, (void *)val, olen);
85363 + if (olen != sizeof(rfc))
85364 + break;
85365 +
85366 + memcpy(&rfc, (void *)val, olen);
85367
85368 if (test_bit(CONF_STATE2_DEVICE, &chan->conf_state) &&
85369 rfc.mode != chan->mode)
85370 diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
85371 index 1bcfb84..dad9f98 100644
85372 --- a/net/bluetooth/l2cap_sock.c
85373 +++ b/net/bluetooth/l2cap_sock.c
85374 @@ -479,7 +479,8 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname,
85375 struct sock *sk = sock->sk;
85376 struct l2cap_chan *chan = l2cap_pi(sk)->chan;
85377 struct l2cap_options opts;
85378 - int len, err = 0;
85379 + int err = 0;
85380 + size_t len = optlen;
85381 u32 opt;
85382
85383 BT_DBG("sk %p", sk);
85384 @@ -501,7 +502,7 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname,
85385 opts.max_tx = chan->max_tx;
85386 opts.txwin_size = chan->tx_win;
85387
85388 - len = min_t(unsigned int, sizeof(opts), optlen);
85389 + len = min(sizeof(opts), len);
85390 if (copy_from_user((char *) &opts, optval, len)) {
85391 err = -EFAULT;
85392 break;
85393 @@ -581,7 +582,8 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
85394 struct bt_security sec;
85395 struct bt_power pwr;
85396 struct l2cap_conn *conn;
85397 - int len, err = 0;
85398 + int err = 0;
85399 + size_t len = optlen;
85400 u32 opt;
85401
85402 BT_DBG("sk %p", sk);
85403 @@ -604,7 +606,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
85404
85405 sec.level = BT_SECURITY_LOW;
85406
85407 - len = min_t(unsigned int, sizeof(sec), optlen);
85408 + len = min(sizeof(sec), len);
85409 if (copy_from_user((char *) &sec, optval, len)) {
85410 err = -EFAULT;
85411 break;
85412 @@ -701,7 +703,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
85413
85414 pwr.force_active = BT_POWER_FORCE_ACTIVE_ON;
85415
85416 - len = min_t(unsigned int, sizeof(pwr), optlen);
85417 + len = min(sizeof(pwr), len);
85418 if (copy_from_user((char *) &pwr, optval, len)) {
85419 err = -EFAULT;
85420 break;
85421 diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c
85422 index 7c9224b..381009e 100644
85423 --- a/net/bluetooth/rfcomm/sock.c
85424 +++ b/net/bluetooth/rfcomm/sock.c
85425 @@ -666,7 +666,7 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, c
85426 struct sock *sk = sock->sk;
85427 struct bt_security sec;
85428 int err = 0;
85429 - size_t len;
85430 + size_t len = optlen;
85431 u32 opt;
85432
85433 BT_DBG("sk %p", sk);
85434 @@ -688,7 +688,7 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, c
85435
85436 sec.level = BT_SECURITY_LOW;
85437
85438 - len = min_t(unsigned int, sizeof(sec), optlen);
85439 + len = min(sizeof(sec), len);
85440 if (copy_from_user((char *) &sec, optval, len)) {
85441 err = -EFAULT;
85442 break;
85443 diff --git a/net/bluetooth/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c
85444 index b6e44ad..5b0d514 100644
85445 --- a/net/bluetooth/rfcomm/tty.c
85446 +++ b/net/bluetooth/rfcomm/tty.c
85447 @@ -309,7 +309,7 @@ static void rfcomm_dev_del(struct rfcomm_dev *dev)
85448 BUG_ON(test_and_set_bit(RFCOMM_TTY_RELEASED, &dev->flags));
85449
85450 spin_lock_irqsave(&dev->port.lock, flags);
85451 - if (dev->port.count > 0) {
85452 + if (atomic_read(&dev->port.count) > 0) {
85453 spin_unlock_irqrestore(&dev->port.lock, flags);
85454 return;
85455 }
85456 @@ -659,10 +659,10 @@ static int rfcomm_tty_open(struct tty_struct *tty, struct file *filp)
85457 return -ENODEV;
85458
85459 BT_DBG("dev %p dst %pMR channel %d opened %d", dev, &dev->dst,
85460 - dev->channel, dev->port.count);
85461 + dev->channel, atomic_read(&dev->port.count));
85462
85463 spin_lock_irqsave(&dev->port.lock, flags);
85464 - if (++dev->port.count > 1) {
85465 + if (atomic_inc_return(&dev->port.count) > 1) {
85466 spin_unlock_irqrestore(&dev->port.lock, flags);
85467 return 0;
85468 }
85469 @@ -727,10 +727,10 @@ static void rfcomm_tty_close(struct tty_struct *tty, struct file *filp)
85470 return;
85471
85472 BT_DBG("tty %p dev %p dlc %p opened %d", tty, dev, dev->dlc,
85473 - dev->port.count);
85474 + atomic_read(&dev->port.count));
85475
85476 spin_lock_irqsave(&dev->port.lock, flags);
85477 - if (!--dev->port.count) {
85478 + if (!atomic_dec_return(&dev->port.count)) {
85479 spin_unlock_irqrestore(&dev->port.lock, flags);
85480 if (dev->tty_dev->parent)
85481 device_move(dev->tty_dev, NULL, DPM_ORDER_DEV_LAST);
85482 diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c
85483 index 8d493c9..3849e49 100644
85484 --- a/net/bridge/netfilter/ebtables.c
85485 +++ b/net/bridge/netfilter/ebtables.c
85486 @@ -1525,7 +1525,7 @@ static int do_ebt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
85487 tmp.valid_hooks = t->table->valid_hooks;
85488 }
85489 mutex_unlock(&ebt_mutex);
85490 - if (copy_to_user(user, &tmp, *len) != 0){
85491 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0){
85492 BUGPRINT("c2u Didn't work\n");
85493 ret = -EFAULT;
85494 break;
85495 @@ -2331,7 +2331,7 @@ static int compat_do_ebt_get_ctl(struct sock *sk, int cmd,
85496 goto out;
85497 tmp.valid_hooks = t->valid_hooks;
85498
85499 - if (copy_to_user(user, &tmp, *len) != 0) {
85500 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0) {
85501 ret = -EFAULT;
85502 break;
85503 }
85504 @@ -2342,7 +2342,7 @@ static int compat_do_ebt_get_ctl(struct sock *sk, int cmd,
85505 tmp.entries_size = t->table->entries_size;
85506 tmp.valid_hooks = t->table->valid_hooks;
85507
85508 - if (copy_to_user(user, &tmp, *len) != 0) {
85509 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0) {
85510 ret = -EFAULT;
85511 break;
85512 }
85513 diff --git a/net/caif/cfctrl.c b/net/caif/cfctrl.c
85514 index a376ec1..1fbd6be 100644
85515 --- a/net/caif/cfctrl.c
85516 +++ b/net/caif/cfctrl.c
85517 @@ -10,6 +10,7 @@
85518 #include <linux/spinlock.h>
85519 #include <linux/slab.h>
85520 #include <linux/pkt_sched.h>
85521 +#include <linux/sched.h>
85522 #include <net/caif/caif_layer.h>
85523 #include <net/caif/cfpkt.h>
85524 #include <net/caif/cfctrl.h>
85525 @@ -43,8 +44,8 @@ struct cflayer *cfctrl_create(void)
85526 memset(&dev_info, 0, sizeof(dev_info));
85527 dev_info.id = 0xff;
85528 cfsrvl_init(&this->serv, 0, &dev_info, false);
85529 - atomic_set(&this->req_seq_no, 1);
85530 - atomic_set(&this->rsp_seq_no, 1);
85531 + atomic_set_unchecked(&this->req_seq_no, 1);
85532 + atomic_set_unchecked(&this->rsp_seq_no, 1);
85533 this->serv.layer.receive = cfctrl_recv;
85534 sprintf(this->serv.layer.name, "ctrl");
85535 this->serv.layer.ctrlcmd = cfctrl_ctrlcmd;
85536 @@ -130,8 +131,8 @@ static void cfctrl_insert_req(struct cfctrl *ctrl,
85537 struct cfctrl_request_info *req)
85538 {
85539 spin_lock_bh(&ctrl->info_list_lock);
85540 - atomic_inc(&ctrl->req_seq_no);
85541 - req->sequence_no = atomic_read(&ctrl->req_seq_no);
85542 + atomic_inc_unchecked(&ctrl->req_seq_no);
85543 + req->sequence_no = atomic_read_unchecked(&ctrl->req_seq_no);
85544 list_add_tail(&req->list, &ctrl->list);
85545 spin_unlock_bh(&ctrl->info_list_lock);
85546 }
85547 @@ -149,7 +150,7 @@ static struct cfctrl_request_info *cfctrl_remove_req(struct cfctrl *ctrl,
85548 if (p != first)
85549 pr_warn("Requests are not received in order\n");
85550
85551 - atomic_set(&ctrl->rsp_seq_no,
85552 + atomic_set_unchecked(&ctrl->rsp_seq_no,
85553 p->sequence_no);
85554 list_del(&p->list);
85555 goto out;
85556 diff --git a/net/can/af_can.c b/net/can/af_can.c
85557 index c48e522..1223690 100644
85558 --- a/net/can/af_can.c
85559 +++ b/net/can/af_can.c
85560 @@ -870,7 +870,7 @@ static const struct net_proto_family can_family_ops = {
85561 };
85562
85563 /* notifier block for netdevice event */
85564 -static struct notifier_block can_netdev_notifier __read_mostly = {
85565 +static struct notifier_block can_netdev_notifier = {
85566 .notifier_call = can_notifier,
85567 };
85568
85569 diff --git a/net/can/gw.c b/net/can/gw.c
85570 index 117814a..ad4fb73 100644
85571 --- a/net/can/gw.c
85572 +++ b/net/can/gw.c
85573 @@ -80,7 +80,6 @@ MODULE_PARM_DESC(max_hops,
85574 "default: " __stringify(CGW_DEFAULT_HOPS) ")");
85575
85576 static HLIST_HEAD(cgw_list);
85577 -static struct notifier_block notifier;
85578
85579 static struct kmem_cache *cgw_cache __read_mostly;
85580
85581 @@ -928,6 +927,10 @@ static int cgw_remove_job(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
85582 return err;
85583 }
85584
85585 +static struct notifier_block notifier = {
85586 + .notifier_call = cgw_notifier
85587 +};
85588 +
85589 static __init int cgw_module_init(void)
85590 {
85591 /* sanitize given module parameter */
85592 @@ -943,7 +946,6 @@ static __init int cgw_module_init(void)
85593 return -ENOMEM;
85594
85595 /* set notifier */
85596 - notifier.notifier_call = cgw_notifier;
85597 register_netdevice_notifier(&notifier);
85598
85599 if (__rtnl_register(PF_CAN, RTM_GETROUTE, NULL, cgw_dump_jobs, NULL)) {
85600 diff --git a/net/compat.c b/net/compat.c
85601 index 79ae884..17c5c09 100644
85602 --- a/net/compat.c
85603 +++ b/net/compat.c
85604 @@ -71,9 +71,9 @@ int get_compat_msghdr(struct msghdr *kmsg, struct compat_msghdr __user *umsg)
85605 __get_user(kmsg->msg_controllen, &umsg->msg_controllen) ||
85606 __get_user(kmsg->msg_flags, &umsg->msg_flags))
85607 return -EFAULT;
85608 - kmsg->msg_name = compat_ptr(tmp1);
85609 - kmsg->msg_iov = compat_ptr(tmp2);
85610 - kmsg->msg_control = compat_ptr(tmp3);
85611 + kmsg->msg_name = (void __force_kernel *)compat_ptr(tmp1);
85612 + kmsg->msg_iov = (void __force_kernel *)compat_ptr(tmp2);
85613 + kmsg->msg_control = (void __force_kernel *)compat_ptr(tmp3);
85614 return 0;
85615 }
85616
85617 @@ -85,7 +85,7 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
85618
85619 if (kern_msg->msg_namelen) {
85620 if (mode == VERIFY_READ) {
85621 - int err = move_addr_to_kernel(kern_msg->msg_name,
85622 + int err = move_addr_to_kernel((void __force_user *)kern_msg->msg_name,
85623 kern_msg->msg_namelen,
85624 kern_address);
85625 if (err < 0)
85626 @@ -96,7 +96,7 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
85627 kern_msg->msg_name = NULL;
85628
85629 tot_len = iov_from_user_compat_to_kern(kern_iov,
85630 - (struct compat_iovec __user *)kern_msg->msg_iov,
85631 + (struct compat_iovec __force_user *)kern_msg->msg_iov,
85632 kern_msg->msg_iovlen);
85633 if (tot_len >= 0)
85634 kern_msg->msg_iov = kern_iov;
85635 @@ -116,20 +116,20 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
85636
85637 #define CMSG_COMPAT_FIRSTHDR(msg) \
85638 (((msg)->msg_controllen) >= sizeof(struct compat_cmsghdr) ? \
85639 - (struct compat_cmsghdr __user *)((msg)->msg_control) : \
85640 + (struct compat_cmsghdr __force_user *)((msg)->msg_control) : \
85641 (struct compat_cmsghdr __user *)NULL)
85642
85643 #define CMSG_COMPAT_OK(ucmlen, ucmsg, mhdr) \
85644 ((ucmlen) >= sizeof(struct compat_cmsghdr) && \
85645 (ucmlen) <= (unsigned long) \
85646 ((mhdr)->msg_controllen - \
85647 - ((char *)(ucmsg) - (char *)(mhdr)->msg_control)))
85648 + ((char __force_kernel *)(ucmsg) - (char *)(mhdr)->msg_control)))
85649
85650 static inline struct compat_cmsghdr __user *cmsg_compat_nxthdr(struct msghdr *msg,
85651 struct compat_cmsghdr __user *cmsg, int cmsg_len)
85652 {
85653 char __user *ptr = (char __user *)cmsg + CMSG_COMPAT_ALIGN(cmsg_len);
85654 - if ((unsigned long)(ptr + 1 - (char __user *)msg->msg_control) >
85655 + if ((unsigned long)(ptr + 1 - (char __force_user *)msg->msg_control) >
85656 msg->msg_controllen)
85657 return NULL;
85658 return (struct compat_cmsghdr __user *)ptr;
85659 @@ -219,7 +219,7 @@ Efault:
85660
85661 int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *data)
85662 {
85663 - struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control;
85664 + struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __force_user *) kmsg->msg_control;
85665 struct compat_cmsghdr cmhdr;
85666 struct compat_timeval ctv;
85667 struct compat_timespec cts[3];
85668 @@ -275,7 +275,7 @@ int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *dat
85669
85670 void scm_detach_fds_compat(struct msghdr *kmsg, struct scm_cookie *scm)
85671 {
85672 - struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control;
85673 + struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __force_user *) kmsg->msg_control;
85674 int fdmax = (kmsg->msg_controllen - sizeof(struct compat_cmsghdr)) / sizeof(int);
85675 int fdnum = scm->fp->count;
85676 struct file **fp = scm->fp->fp;
85677 @@ -363,7 +363,7 @@ static int do_set_sock_timeout(struct socket *sock, int level,
85678 return -EFAULT;
85679 old_fs = get_fs();
85680 set_fs(KERNEL_DS);
85681 - err = sock_setsockopt(sock, level, optname, (char *)&ktime, sizeof(ktime));
85682 + err = sock_setsockopt(sock, level, optname, (char __force_user *)&ktime, sizeof(ktime));
85683 set_fs(old_fs);
85684
85685 return err;
85686 @@ -424,7 +424,7 @@ static int do_get_sock_timeout(struct socket *sock, int level, int optname,
85687 len = sizeof(ktime);
85688 old_fs = get_fs();
85689 set_fs(KERNEL_DS);
85690 - err = sock_getsockopt(sock, level, optname, (char *) &ktime, &len);
85691 + err = sock_getsockopt(sock, level, optname, (char __force_user *) &ktime, (int __force_user *)&len);
85692 set_fs(old_fs);
85693
85694 if (!err) {
85695 @@ -567,7 +567,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
85696 case MCAST_JOIN_GROUP:
85697 case MCAST_LEAVE_GROUP:
85698 {
85699 - struct compat_group_req __user *gr32 = (void *)optval;
85700 + struct compat_group_req __user *gr32 = (void __user *)optval;
85701 struct group_req __user *kgr =
85702 compat_alloc_user_space(sizeof(struct group_req));
85703 u32 interface;
85704 @@ -588,7 +588,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
85705 case MCAST_BLOCK_SOURCE:
85706 case MCAST_UNBLOCK_SOURCE:
85707 {
85708 - struct compat_group_source_req __user *gsr32 = (void *)optval;
85709 + struct compat_group_source_req __user *gsr32 = (void __user *)optval;
85710 struct group_source_req __user *kgsr = compat_alloc_user_space(
85711 sizeof(struct group_source_req));
85712 u32 interface;
85713 @@ -609,7 +609,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
85714 }
85715 case MCAST_MSFILTER:
85716 {
85717 - struct compat_group_filter __user *gf32 = (void *)optval;
85718 + struct compat_group_filter __user *gf32 = (void __user *)optval;
85719 struct group_filter __user *kgf;
85720 u32 interface, fmode, numsrc;
85721
85722 @@ -647,7 +647,7 @@ int compat_mc_getsockopt(struct sock *sock, int level, int optname,
85723 char __user *optval, int __user *optlen,
85724 int (*getsockopt)(struct sock *, int, int, char __user *, int __user *))
85725 {
85726 - struct compat_group_filter __user *gf32 = (void *)optval;
85727 + struct compat_group_filter __user *gf32 = (void __user *)optval;
85728 struct group_filter __user *kgf;
85729 int __user *koptlen;
85730 u32 interface, fmode, numsrc;
85731 @@ -796,7 +796,7 @@ asmlinkage long compat_sys_socketcall(int call, u32 __user *args)
85732
85733 if (call < SYS_SOCKET || call > SYS_SENDMMSG)
85734 return -EINVAL;
85735 - if (copy_from_user(a, args, nas[call]))
85736 + if (nas[call] > sizeof a || copy_from_user(a, args, nas[call]))
85737 return -EFAULT;
85738 a0 = a[0];
85739 a1 = a[1];
85740 diff --git a/net/core/datagram.c b/net/core/datagram.c
85741 index 368f9c3..f82d4a3 100644
85742 --- a/net/core/datagram.c
85743 +++ b/net/core/datagram.c
85744 @@ -289,7 +289,7 @@ int skb_kill_datagram(struct sock *sk, struct sk_buff *skb, unsigned int flags)
85745 }
85746
85747 kfree_skb(skb);
85748 - atomic_inc(&sk->sk_drops);
85749 + atomic_inc_unchecked(&sk->sk_drops);
85750 sk_mem_reclaim_partial(sk);
85751
85752 return err;
85753 diff --git a/net/core/dev.c b/net/core/dev.c
85754 index 9a278e9..15f2b9e 100644
85755 --- a/net/core/dev.c
85756 +++ b/net/core/dev.c
85757 @@ -1617,7 +1617,7 @@ int dev_forward_skb(struct net_device *dev, struct sk_buff *skb)
85758 {
85759 if (skb_shinfo(skb)->tx_flags & SKBTX_DEV_ZEROCOPY) {
85760 if (skb_copy_ubufs(skb, GFP_ATOMIC)) {
85761 - atomic_long_inc(&dev->rx_dropped);
85762 + atomic_long_inc_unchecked(&dev->rx_dropped);
85763 kfree_skb(skb);
85764 return NET_RX_DROP;
85765 }
85766 @@ -1626,7 +1626,7 @@ int dev_forward_skb(struct net_device *dev, struct sk_buff *skb)
85767 skb_orphan(skb);
85768
85769 if (unlikely(!is_skb_forwardable(dev, skb))) {
85770 - atomic_long_inc(&dev->rx_dropped);
85771 + atomic_long_inc_unchecked(&dev->rx_dropped);
85772 kfree_skb(skb);
85773 return NET_RX_DROP;
85774 }
85775 @@ -2351,7 +2351,7 @@ static int illegal_highdma(struct net_device *dev, struct sk_buff *skb)
85776
85777 struct dev_gso_cb {
85778 void (*destructor)(struct sk_buff *skb);
85779 -};
85780 +} __no_const;
85781
85782 #define DEV_GSO_CB(skb) ((struct dev_gso_cb *)(skb)->cb)
85783
85784 @@ -3093,7 +3093,7 @@ enqueue:
85785
85786 local_irq_restore(flags);
85787
85788 - atomic_long_inc(&skb->dev->rx_dropped);
85789 + atomic_long_inc_unchecked(&skb->dev->rx_dropped);
85790 kfree_skb(skb);
85791 return NET_RX_DROP;
85792 }
85793 @@ -3165,7 +3165,7 @@ int netif_rx_ni(struct sk_buff *skb)
85794 }
85795 EXPORT_SYMBOL(netif_rx_ni);
85796
85797 -static void net_tx_action(struct softirq_action *h)
85798 +static void net_tx_action(void)
85799 {
85800 struct softnet_data *sd = &__get_cpu_var(softnet_data);
85801
85802 @@ -3490,7 +3490,7 @@ ncls:
85803 ret = pt_prev->func(skb, skb->dev, pt_prev, orig_dev);
85804 } else {
85805 drop:
85806 - atomic_long_inc(&skb->dev->rx_dropped);
85807 + atomic_long_inc_unchecked(&skb->dev->rx_dropped);
85808 kfree_skb(skb);
85809 /* Jamal, now you will not able to escape explaining
85810 * me how you were going to use this. :-)
85811 @@ -4095,7 +4095,7 @@ void netif_napi_del(struct napi_struct *napi)
85812 }
85813 EXPORT_SYMBOL(netif_napi_del);
85814
85815 -static void net_rx_action(struct softirq_action *h)
85816 +static void net_rx_action(void)
85817 {
85818 struct softnet_data *sd = &__get_cpu_var(softnet_data);
85819 unsigned long time_limit = jiffies + 2;
85820 @@ -5522,7 +5522,7 @@ struct rtnl_link_stats64 *dev_get_stats(struct net_device *dev,
85821 } else {
85822 netdev_stats_to_stats64(storage, &dev->stats);
85823 }
85824 - storage->rx_dropped += atomic_long_read(&dev->rx_dropped);
85825 + storage->rx_dropped += atomic_long_read_unchecked(&dev->rx_dropped);
85826 return storage;
85827 }
85828 EXPORT_SYMBOL(dev_get_stats);
85829 diff --git a/net/core/dev_ioctl.c b/net/core/dev_ioctl.c
85830 index 6cc0481..59cfb00 100644
85831 --- a/net/core/dev_ioctl.c
85832 +++ b/net/core/dev_ioctl.c
85833 @@ -376,9 +376,13 @@ void dev_load(struct net *net, const char *name)
85834 if (no_module && capable(CAP_NET_ADMIN))
85835 no_module = request_module("netdev-%s", name);
85836 if (no_module && capable(CAP_SYS_MODULE)) {
85837 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
85838 + ___request_module(true, "grsec_modharden_netdev", "%s", name);
85839 +#else
85840 if (!request_module("%s", name))
85841 pr_warn("Loading kernel module for a network device with CAP_SYS_MODULE (deprecated). Use CAP_NET_ADMIN and alias netdev-%s instead.\n",
85842 name);
85843 +#endif
85844 }
85845 }
85846 EXPORT_SYMBOL(dev_load);
85847 diff --git a/net/core/flow.c b/net/core/flow.c
85848 index 2bfd081..53c6058 100644
85849 --- a/net/core/flow.c
85850 +++ b/net/core/flow.c
85851 @@ -61,7 +61,7 @@ struct flow_cache {
85852 struct timer_list rnd_timer;
85853 };
85854
85855 -atomic_t flow_cache_genid = ATOMIC_INIT(0);
85856 +atomic_unchecked_t flow_cache_genid = ATOMIC_INIT(0);
85857 EXPORT_SYMBOL(flow_cache_genid);
85858 static struct flow_cache flow_cache_global;
85859 static struct kmem_cache *flow_cachep __read_mostly;
85860 @@ -86,7 +86,7 @@ static void flow_cache_new_hashrnd(unsigned long arg)
85861
85862 static int flow_entry_valid(struct flow_cache_entry *fle)
85863 {
85864 - if (atomic_read(&flow_cache_genid) != fle->genid)
85865 + if (atomic_read_unchecked(&flow_cache_genid) != fle->genid)
85866 return 0;
85867 if (fle->object && !fle->object->ops->check(fle->object))
85868 return 0;
85869 @@ -258,7 +258,7 @@ flow_cache_lookup(struct net *net, const struct flowi *key, u16 family, u8 dir,
85870 hlist_add_head(&fle->u.hlist, &fcp->hash_table[hash]);
85871 fcp->hash_count++;
85872 }
85873 - } else if (likely(fle->genid == atomic_read(&flow_cache_genid))) {
85874 + } else if (likely(fle->genid == atomic_read_unchecked(&flow_cache_genid))) {
85875 flo = fle->object;
85876 if (!flo)
85877 goto ret_object;
85878 @@ -279,7 +279,7 @@ nocache:
85879 }
85880 flo = resolver(net, key, family, dir, flo, ctx);
85881 if (fle) {
85882 - fle->genid = atomic_read(&flow_cache_genid);
85883 + fle->genid = atomic_read_unchecked(&flow_cache_genid);
85884 if (!IS_ERR(flo))
85885 fle->object = flo;
85886 else
85887 diff --git a/net/core/iovec.c b/net/core/iovec.c
85888 index 7e7aeb0..2a998cb 100644
85889 --- a/net/core/iovec.c
85890 +++ b/net/core/iovec.c
85891 @@ -42,7 +42,7 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr_storage *a
85892 if (m->msg_namelen) {
85893 if (mode == VERIFY_READ) {
85894 void __user *namep;
85895 - namep = (void __user __force *) m->msg_name;
85896 + namep = (void __force_user *) m->msg_name;
85897 err = move_addr_to_kernel(namep, m->msg_namelen,
85898 address);
85899 if (err < 0)
85900 @@ -54,7 +54,7 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr_storage *a
85901 }
85902
85903 size = m->msg_iovlen * sizeof(struct iovec);
85904 - if (copy_from_user(iov, (void __user __force *) m->msg_iov, size))
85905 + if (copy_from_user(iov, (void __force_user *) m->msg_iov, size))
85906 return -EFAULT;
85907
85908 m->msg_iov = iov;
85909 diff --git a/net/core/neighbour.c b/net/core/neighbour.c
85910 index 3863b8f..85c99a6 100644
85911 --- a/net/core/neighbour.c
85912 +++ b/net/core/neighbour.c
85913 @@ -2778,7 +2778,7 @@ static int proc_unres_qlen(ctl_table *ctl, int write, void __user *buffer,
85914 size_t *lenp, loff_t *ppos)
85915 {
85916 int size, ret;
85917 - ctl_table tmp = *ctl;
85918 + ctl_table_no_const tmp = *ctl;
85919
85920 tmp.extra1 = &zero;
85921 tmp.extra2 = &unres_qlen_max;
85922 diff --git a/net/core/net-procfs.c b/net/core/net-procfs.c
85923 index 3174f19..5810985 100644
85924 --- a/net/core/net-procfs.c
85925 +++ b/net/core/net-procfs.c
85926 @@ -271,8 +271,13 @@ static int ptype_seq_show(struct seq_file *seq, void *v)
85927 else
85928 seq_printf(seq, "%04x", ntohs(pt->type));
85929
85930 +#ifdef CONFIG_GRKERNSEC_HIDESYM
85931 + seq_printf(seq, " %-8s %pF\n",
85932 + pt->dev ? pt->dev->name : "", NULL);
85933 +#else
85934 seq_printf(seq, " %-8s %pF\n",
85935 pt->dev ? pt->dev->name : "", pt->func);
85936 +#endif
85937 }
85938
85939 return 0;
85940 diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
85941 index 7427ab5..389f411 100644
85942 --- a/net/core/net-sysfs.c
85943 +++ b/net/core/net-sysfs.c
85944 @@ -1321,7 +1321,7 @@ void netdev_class_remove_file(struct class_attribute *class_attr)
85945 }
85946 EXPORT_SYMBOL(netdev_class_remove_file);
85947
85948 -int netdev_kobject_init(void)
85949 +int __init netdev_kobject_init(void)
85950 {
85951 kobj_ns_type_register(&net_ns_type_operations);
85952 return class_register(&net_class);
85953 diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
85954 index 80e271d..2980cc2 100644
85955 --- a/net/core/net_namespace.c
85956 +++ b/net/core/net_namespace.c
85957 @@ -442,7 +442,7 @@ static int __register_pernet_operations(struct list_head *list,
85958 int error;
85959 LIST_HEAD(net_exit_list);
85960
85961 - list_add_tail(&ops->list, list);
85962 + pax_list_add_tail((struct list_head *)&ops->list, list);
85963 if (ops->init || (ops->id && ops->size)) {
85964 for_each_net(net) {
85965 error = ops_init(ops, net);
85966 @@ -455,7 +455,7 @@ static int __register_pernet_operations(struct list_head *list,
85967
85968 out_undo:
85969 /* If I have an error cleanup all namespaces I initialized */
85970 - list_del(&ops->list);
85971 + pax_list_del((struct list_head *)&ops->list);
85972 ops_exit_list(ops, &net_exit_list);
85973 ops_free_list(ops, &net_exit_list);
85974 return error;
85975 @@ -466,7 +466,7 @@ static void __unregister_pernet_operations(struct pernet_operations *ops)
85976 struct net *net;
85977 LIST_HEAD(net_exit_list);
85978
85979 - list_del(&ops->list);
85980 + pax_list_del((struct list_head *)&ops->list);
85981 for_each_net(net)
85982 list_add_tail(&net->exit_list, &net_exit_list);
85983 ops_exit_list(ops, &net_exit_list);
85984 @@ -600,7 +600,7 @@ int register_pernet_device(struct pernet_operations *ops)
85985 mutex_lock(&net_mutex);
85986 error = register_pernet_operations(&pernet_list, ops);
85987 if (!error && (first_device == &pernet_list))
85988 - first_device = &ops->list;
85989 + first_device = (struct list_head *)&ops->list;
85990 mutex_unlock(&net_mutex);
85991 return error;
85992 }
85993 diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
85994 index 23854b5..ff4fda4 100644
85995 --- a/net/core/rtnetlink.c
85996 +++ b/net/core/rtnetlink.c
85997 @@ -58,7 +58,7 @@ struct rtnl_link {
85998 rtnl_doit_func doit;
85999 rtnl_dumpit_func dumpit;
86000 rtnl_calcit_func calcit;
86001 -};
86002 +} __no_const;
86003
86004 static DEFINE_MUTEX(rtnl_mutex);
86005
86006 @@ -299,10 +299,13 @@ int __rtnl_link_register(struct rtnl_link_ops *ops)
86007 if (rtnl_link_ops_get(ops->kind))
86008 return -EEXIST;
86009
86010 - if (!ops->dellink)
86011 - ops->dellink = unregister_netdevice_queue;
86012 + if (!ops->dellink) {
86013 + pax_open_kernel();
86014 + *(void **)&ops->dellink = unregister_netdevice_queue;
86015 + pax_close_kernel();
86016 + }
86017
86018 - list_add_tail(&ops->list, &link_ops);
86019 + pax_list_add_tail((struct list_head *)&ops->list, &link_ops);
86020 return 0;
86021 }
86022 EXPORT_SYMBOL_GPL(__rtnl_link_register);
86023 @@ -349,7 +352,7 @@ void __rtnl_link_unregister(struct rtnl_link_ops *ops)
86024 for_each_net(net) {
86025 __rtnl_kill_links(net, ops);
86026 }
86027 - list_del(&ops->list);
86028 + pax_list_del((struct list_head *)&ops->list);
86029 }
86030 EXPORT_SYMBOL_GPL(__rtnl_link_unregister);
86031
86032 diff --git a/net/core/scm.c b/net/core/scm.c
86033 index 2dc6cda..2159524 100644
86034 --- a/net/core/scm.c
86035 +++ b/net/core/scm.c
86036 @@ -226,7 +226,7 @@ EXPORT_SYMBOL(__scm_send);
86037 int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
86038 {
86039 struct cmsghdr __user *cm
86040 - = (__force struct cmsghdr __user *)msg->msg_control;
86041 + = (struct cmsghdr __force_user *)msg->msg_control;
86042 struct cmsghdr cmhdr;
86043 int cmlen = CMSG_LEN(len);
86044 int err;
86045 @@ -249,7 +249,7 @@ int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
86046 err = -EFAULT;
86047 if (copy_to_user(cm, &cmhdr, sizeof cmhdr))
86048 goto out;
86049 - if (copy_to_user(CMSG_DATA(cm), data, cmlen - sizeof(struct cmsghdr)))
86050 + if (copy_to_user((void __force_user *)CMSG_DATA((void __force_kernel *)cm), data, cmlen - sizeof(struct cmsghdr)))
86051 goto out;
86052 cmlen = CMSG_SPACE(len);
86053 if (msg->msg_controllen < cmlen)
86054 @@ -265,7 +265,7 @@ EXPORT_SYMBOL(put_cmsg);
86055 void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
86056 {
86057 struct cmsghdr __user *cm
86058 - = (__force struct cmsghdr __user*)msg->msg_control;
86059 + = (struct cmsghdr __force_user *)msg->msg_control;
86060
86061 int fdmax = 0;
86062 int fdnum = scm->fp->count;
86063 @@ -285,7 +285,7 @@ void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
86064 if (fdnum < fdmax)
86065 fdmax = fdnum;
86066
86067 - for (i=0, cmfptr=(__force int __user *)CMSG_DATA(cm); i<fdmax;
86068 + for (i=0, cmfptr=(int __force_user *)CMSG_DATA((void __force_kernel *)cm); i<fdmax;
86069 i++, cmfptr++)
86070 {
86071 struct socket *sock;
86072 diff --git a/net/core/secure_seq.c b/net/core/secure_seq.c
86073 index e61a8bb..6a2f13c 100644
86074 --- a/net/core/secure_seq.c
86075 +++ b/net/core/secure_seq.c
86076 @@ -12,12 +12,10 @@
86077
86078 static u32 net_secret[MD5_MESSAGE_BYTES / 4] ____cacheline_aligned;
86079
86080 -static int __init net_secret_init(void)
86081 +void net_secret_init(void)
86082 {
86083 get_random_bytes(net_secret, sizeof(net_secret));
86084 - return 0;
86085 }
86086 -late_initcall(net_secret_init);
86087
86088 #ifdef CONFIG_INET
86089 static u32 seq_scale(u32 seq)
86090 diff --git a/net/core/sock.c b/net/core/sock.c
86091 index 1432266..1a0d4a1 100644
86092 --- a/net/core/sock.c
86093 +++ b/net/core/sock.c
86094 @@ -390,7 +390,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
86095 struct sk_buff_head *list = &sk->sk_receive_queue;
86096
86097 if (atomic_read(&sk->sk_rmem_alloc) >= sk->sk_rcvbuf) {
86098 - atomic_inc(&sk->sk_drops);
86099 + atomic_inc_unchecked(&sk->sk_drops);
86100 trace_sock_rcvqueue_full(sk, skb);
86101 return -ENOMEM;
86102 }
86103 @@ -400,7 +400,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
86104 return err;
86105
86106 if (!sk_rmem_schedule(sk, skb, skb->truesize)) {
86107 - atomic_inc(&sk->sk_drops);
86108 + atomic_inc_unchecked(&sk->sk_drops);
86109 return -ENOBUFS;
86110 }
86111
86112 @@ -420,7 +420,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
86113 skb_dst_force(skb);
86114
86115 spin_lock_irqsave(&list->lock, flags);
86116 - skb->dropcount = atomic_read(&sk->sk_drops);
86117 + skb->dropcount = atomic_read_unchecked(&sk->sk_drops);
86118 __skb_queue_tail(list, skb);
86119 spin_unlock_irqrestore(&list->lock, flags);
86120
86121 @@ -440,7 +440,7 @@ int sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested)
86122 skb->dev = NULL;
86123
86124 if (sk_rcvqueues_full(sk, skb, sk->sk_rcvbuf)) {
86125 - atomic_inc(&sk->sk_drops);
86126 + atomic_inc_unchecked(&sk->sk_drops);
86127 goto discard_and_relse;
86128 }
86129 if (nested)
86130 @@ -458,7 +458,7 @@ int sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested)
86131 mutex_release(&sk->sk_lock.dep_map, 1, _RET_IP_);
86132 } else if (sk_add_backlog(sk, skb, sk->sk_rcvbuf)) {
86133 bh_unlock_sock(sk);
86134 - atomic_inc(&sk->sk_drops);
86135 + atomic_inc_unchecked(&sk->sk_drops);
86136 goto discard_and_relse;
86137 }
86138
86139 @@ -942,12 +942,12 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
86140 struct timeval tm;
86141 } v;
86142
86143 - int lv = sizeof(int);
86144 - int len;
86145 + unsigned int lv = sizeof(int);
86146 + unsigned int len;
86147
86148 if (get_user(len, optlen))
86149 return -EFAULT;
86150 - if (len < 0)
86151 + if (len > INT_MAX)
86152 return -EINVAL;
86153
86154 memset(&v, 0, sizeof(v));
86155 @@ -1099,11 +1099,11 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
86156
86157 case SO_PEERNAME:
86158 {
86159 - char address[128];
86160 + char address[_K_SS_MAXSIZE];
86161
86162 if (sock->ops->getname(sock, (struct sockaddr *)address, &lv, 2))
86163 return -ENOTCONN;
86164 - if (lv < len)
86165 + if (lv < len || sizeof address < len)
86166 return -EINVAL;
86167 if (copy_to_user(optval, address, len))
86168 return -EFAULT;
86169 @@ -1166,7 +1166,7 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
86170
86171 if (len > lv)
86172 len = lv;
86173 - if (copy_to_user(optval, &v, len))
86174 + if (len > sizeof(v) || copy_to_user(optval, &v, len))
86175 return -EFAULT;
86176 lenout:
86177 if (put_user(len, optlen))
86178 @@ -2284,7 +2284,7 @@ void sock_init_data(struct socket *sock, struct sock *sk)
86179 */
86180 smp_wmb();
86181 atomic_set(&sk->sk_refcnt, 1);
86182 - atomic_set(&sk->sk_drops, 0);
86183 + atomic_set_unchecked(&sk->sk_drops, 0);
86184 }
86185 EXPORT_SYMBOL(sock_init_data);
86186
86187 diff --git a/net/core/sock_diag.c b/net/core/sock_diag.c
86188 index a29e90c..922399c 100644
86189 --- a/net/core/sock_diag.c
86190 +++ b/net/core/sock_diag.c
86191 @@ -9,26 +9,33 @@
86192 #include <linux/inet_diag.h>
86193 #include <linux/sock_diag.h>
86194
86195 -static const struct sock_diag_handler *sock_diag_handlers[AF_MAX];
86196 +static const struct sock_diag_handler *sock_diag_handlers[AF_MAX] __read_only;
86197 static int (*inet_rcv_compat)(struct sk_buff *skb, struct nlmsghdr *nlh);
86198 static DEFINE_MUTEX(sock_diag_table_mutex);
86199
86200 int sock_diag_check_cookie(void *sk, __u32 *cookie)
86201 {
86202 +#ifndef CONFIG_GRKERNSEC_HIDESYM
86203 if ((cookie[0] != INET_DIAG_NOCOOKIE ||
86204 cookie[1] != INET_DIAG_NOCOOKIE) &&
86205 ((u32)(unsigned long)sk != cookie[0] ||
86206 (u32)((((unsigned long)sk) >> 31) >> 1) != cookie[1]))
86207 return -ESTALE;
86208 else
86209 +#endif
86210 return 0;
86211 }
86212 EXPORT_SYMBOL_GPL(sock_diag_check_cookie);
86213
86214 void sock_diag_save_cookie(void *sk, __u32 *cookie)
86215 {
86216 +#ifdef CONFIG_GRKERNSEC_HIDESYM
86217 + cookie[0] = 0;
86218 + cookie[1] = 0;
86219 +#else
86220 cookie[0] = (u32)(unsigned long)sk;
86221 cookie[1] = (u32)(((unsigned long)sk >> 31) >> 1);
86222 +#endif
86223 }
86224 EXPORT_SYMBOL_GPL(sock_diag_save_cookie);
86225
86226 @@ -75,8 +82,11 @@ int sock_diag_register(const struct sock_diag_handler *hndl)
86227 mutex_lock(&sock_diag_table_mutex);
86228 if (sock_diag_handlers[hndl->family])
86229 err = -EBUSY;
86230 - else
86231 + else {
86232 + pax_open_kernel();
86233 sock_diag_handlers[hndl->family] = hndl;
86234 + pax_close_kernel();
86235 + }
86236 mutex_unlock(&sock_diag_table_mutex);
86237
86238 return err;
86239 @@ -92,7 +102,9 @@ void sock_diag_unregister(const struct sock_diag_handler *hnld)
86240
86241 mutex_lock(&sock_diag_table_mutex);
86242 BUG_ON(sock_diag_handlers[family] != hnld);
86243 + pax_open_kernel();
86244 sock_diag_handlers[family] = NULL;
86245 + pax_close_kernel();
86246 mutex_unlock(&sock_diag_table_mutex);
86247 }
86248 EXPORT_SYMBOL_GPL(sock_diag_unregister);
86249 diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c
86250 index cfdb46a..cef55e1 100644
86251 --- a/net/core/sysctl_net_core.c
86252 +++ b/net/core/sysctl_net_core.c
86253 @@ -28,7 +28,7 @@ static int rps_sock_flow_sysctl(ctl_table *table, int write,
86254 {
86255 unsigned int orig_size, size;
86256 int ret, i;
86257 - ctl_table tmp = {
86258 + ctl_table_no_const tmp = {
86259 .data = &size,
86260 .maxlen = sizeof(size),
86261 .mode = table->mode
86262 @@ -211,13 +211,12 @@ static struct ctl_table netns_core_table[] = {
86263
86264 static __net_init int sysctl_core_net_init(struct net *net)
86265 {
86266 - struct ctl_table *tbl;
86267 + ctl_table_no_const *tbl = NULL;
86268
86269 net->core.sysctl_somaxconn = SOMAXCONN;
86270
86271 - tbl = netns_core_table;
86272 if (!net_eq(net, &init_net)) {
86273 - tbl = kmemdup(tbl, sizeof(netns_core_table), GFP_KERNEL);
86274 + tbl = kmemdup(netns_core_table, sizeof(netns_core_table), GFP_KERNEL);
86275 if (tbl == NULL)
86276 goto err_dup;
86277
86278 @@ -227,17 +226,16 @@ static __net_init int sysctl_core_net_init(struct net *net)
86279 if (net->user_ns != &init_user_ns) {
86280 tbl[0].procname = NULL;
86281 }
86282 - }
86283 -
86284 - net->core.sysctl_hdr = register_net_sysctl(net, "net/core", tbl);
86285 + net->core.sysctl_hdr = register_net_sysctl(net, "net/core", tbl);
86286 + } else
86287 + net->core.sysctl_hdr = register_net_sysctl(net, "net/core", netns_core_table);
86288 if (net->core.sysctl_hdr == NULL)
86289 goto err_reg;
86290
86291 return 0;
86292
86293 err_reg:
86294 - if (tbl != netns_core_table)
86295 - kfree(tbl);
86296 + kfree(tbl);
86297 err_dup:
86298 return -ENOMEM;
86299 }
86300 @@ -252,7 +250,7 @@ static __net_exit void sysctl_core_net_exit(struct net *net)
86301 kfree(tbl);
86302 }
86303
86304 -static __net_initdata struct pernet_operations sysctl_core_ops = {
86305 +static __net_initconst struct pernet_operations sysctl_core_ops = {
86306 .init = sysctl_core_net_init,
86307 .exit = sysctl_core_net_exit,
86308 };
86309 diff --git a/net/decnet/af_decnet.c b/net/decnet/af_decnet.c
86310 index c21f200..bc4565b 100644
86311 --- a/net/decnet/af_decnet.c
86312 +++ b/net/decnet/af_decnet.c
86313 @@ -465,6 +465,7 @@ static struct proto dn_proto = {
86314 .sysctl_rmem = sysctl_decnet_rmem,
86315 .max_header = DN_MAX_NSP_DATA_HEADER + 64,
86316 .obj_size = sizeof(struct dn_sock),
86317 + .slab_flags = SLAB_USERCOPY,
86318 };
86319
86320 static struct sock *dn_alloc_sock(struct net *net, struct socket *sock, gfp_t gfp)
86321 diff --git a/net/decnet/sysctl_net_decnet.c b/net/decnet/sysctl_net_decnet.c
86322 index a55eecc..dd8428c 100644
86323 --- a/net/decnet/sysctl_net_decnet.c
86324 +++ b/net/decnet/sysctl_net_decnet.c
86325 @@ -174,7 +174,7 @@ static int dn_node_address_handler(ctl_table *table, int write,
86326
86327 if (len > *lenp) len = *lenp;
86328
86329 - if (copy_to_user(buffer, addr, len))
86330 + if (len > sizeof addr || copy_to_user(buffer, addr, len))
86331 return -EFAULT;
86332
86333 *lenp = len;
86334 @@ -237,7 +237,7 @@ static int dn_def_dev_handler(ctl_table *table, int write,
86335
86336 if (len > *lenp) len = *lenp;
86337
86338 - if (copy_to_user(buffer, devname, len))
86339 + if (len > sizeof devname || copy_to_user(buffer, devname, len))
86340 return -EFAULT;
86341
86342 *lenp = len;
86343 diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
86344 index c929d9c..df10cde 100644
86345 --- a/net/ipv4/af_inet.c
86346 +++ b/net/ipv4/af_inet.c
86347 @@ -115,6 +115,7 @@
86348 #include <net/inet_common.h>
86349 #include <net/xfrm.h>
86350 #include <net/net_namespace.h>
86351 +#include <net/secure_seq.h>
86352 #ifdef CONFIG_IP_MROUTE
86353 #include <linux/mroute.h>
86354 #endif
86355 @@ -263,8 +264,10 @@ void build_ehash_secret(void)
86356 get_random_bytes(&rnd, sizeof(rnd));
86357 } while (rnd == 0);
86358
86359 - if (cmpxchg(&inet_ehash_secret, 0, rnd) == 0)
86360 + if (cmpxchg(&inet_ehash_secret, 0, rnd) == 0) {
86361 get_random_bytes(&ipv6_hash_secret, sizeof(ipv6_hash_secret));
86362 + net_secret_init();
86363 + }
86364 }
86365 EXPORT_SYMBOL(build_ehash_secret);
86366
86367 @@ -1699,13 +1702,9 @@ static int __init inet_init(void)
86368
86369 BUILD_BUG_ON(sizeof(struct inet_skb_parm) > FIELD_SIZEOF(struct sk_buff, cb));
86370
86371 - sysctl_local_reserved_ports = kzalloc(65536 / 8, GFP_KERNEL);
86372 - if (!sysctl_local_reserved_ports)
86373 - goto out;
86374 -
86375 rc = proto_register(&tcp_prot, 1);
86376 if (rc)
86377 - goto out_free_reserved_ports;
86378 + goto out;
86379
86380 rc = proto_register(&udp_prot, 1);
86381 if (rc)
86382 @@ -1814,8 +1813,6 @@ out_unregister_udp_proto:
86383 proto_unregister(&udp_prot);
86384 out_unregister_tcp_proto:
86385 proto_unregister(&tcp_prot);
86386 -out_free_reserved_ports:
86387 - kfree(sysctl_local_reserved_ports);
86388 goto out;
86389 }
86390
86391 diff --git a/net/ipv4/ah4.c b/net/ipv4/ah4.c
86392 index 2e7f194..0fa4d6d 100644
86393 --- a/net/ipv4/ah4.c
86394 +++ b/net/ipv4/ah4.c
86395 @@ -420,7 +420,7 @@ static void ah4_err(struct sk_buff *skb, u32 info)
86396 return;
86397
86398 if (icmp_hdr(skb)->type == ICMP_DEST_UNREACH) {
86399 - atomic_inc(&flow_cache_genid);
86400 + atomic_inc_unchecked(&flow_cache_genid);
86401 rt_genid_bump(net);
86402
86403 ipv4_update_pmtu(skb, net, info, 0, 0, IPPROTO_AH, 0);
86404 diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
86405 index c6287cd..e9bc96a 100644
86406 --- a/net/ipv4/devinet.c
86407 +++ b/net/ipv4/devinet.c
86408 @@ -1992,7 +1992,7 @@ static int ipv4_doint_and_flush(ctl_table *ctl, int write,
86409 #define DEVINET_SYSCTL_FLUSHING_ENTRY(attr, name) \
86410 DEVINET_SYSCTL_COMPLEX_ENTRY(attr, name, ipv4_doint_and_flush)
86411
86412 -static struct devinet_sysctl_table {
86413 +static const struct devinet_sysctl_table {
86414 struct ctl_table_header *sysctl_header;
86415 struct ctl_table devinet_vars[__IPV4_DEVCONF_MAX];
86416 } devinet_sysctl = {
86417 @@ -2110,7 +2110,7 @@ static __net_init int devinet_init_net(struct net *net)
86418 int err;
86419 struct ipv4_devconf *all, *dflt;
86420 #ifdef CONFIG_SYSCTL
86421 - struct ctl_table *tbl = ctl_forward_entry;
86422 + ctl_table_no_const *tbl = NULL;
86423 struct ctl_table_header *forw_hdr;
86424 #endif
86425
86426 @@ -2128,7 +2128,7 @@ static __net_init int devinet_init_net(struct net *net)
86427 goto err_alloc_dflt;
86428
86429 #ifdef CONFIG_SYSCTL
86430 - tbl = kmemdup(tbl, sizeof(ctl_forward_entry), GFP_KERNEL);
86431 + tbl = kmemdup(ctl_forward_entry, sizeof(ctl_forward_entry), GFP_KERNEL);
86432 if (tbl == NULL)
86433 goto err_alloc_ctl;
86434
86435 @@ -2148,7 +2148,10 @@ static __net_init int devinet_init_net(struct net *net)
86436 goto err_reg_dflt;
86437
86438 err = -ENOMEM;
86439 - forw_hdr = register_net_sysctl(net, "net/ipv4", tbl);
86440 + if (!net_eq(net, &init_net))
86441 + forw_hdr = register_net_sysctl(net, "net/ipv4", tbl);
86442 + else
86443 + forw_hdr = register_net_sysctl(net, "net/ipv4", ctl_forward_entry);
86444 if (forw_hdr == NULL)
86445 goto err_reg_ctl;
86446 net->ipv4.forw_hdr = forw_hdr;
86447 @@ -2164,8 +2167,7 @@ err_reg_ctl:
86448 err_reg_dflt:
86449 __devinet_sysctl_unregister(all);
86450 err_reg_all:
86451 - if (tbl != ctl_forward_entry)
86452 - kfree(tbl);
86453 + kfree(tbl);
86454 err_alloc_ctl:
86455 #endif
86456 if (dflt != &ipv4_devconf_dflt)
86457 diff --git a/net/ipv4/esp4.c b/net/ipv4/esp4.c
86458 index 4cfe34d..a6ba66e 100644
86459 --- a/net/ipv4/esp4.c
86460 +++ b/net/ipv4/esp4.c
86461 @@ -503,7 +503,7 @@ static void esp4_err(struct sk_buff *skb, u32 info)
86462 return;
86463
86464 if (icmp_hdr(skb)->type == ICMP_DEST_UNREACH) {
86465 - atomic_inc(&flow_cache_genid);
86466 + atomic_inc_unchecked(&flow_cache_genid);
86467 rt_genid_bump(net);
86468
86469 ipv4_update_pmtu(skb, net, info, 0, 0, IPPROTO_ESP, 0);
86470 diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
86471 index eb4bb12..ee4ec7d 100644
86472 --- a/net/ipv4/fib_frontend.c
86473 +++ b/net/ipv4/fib_frontend.c
86474 @@ -1017,12 +1017,12 @@ static int fib_inetaddr_event(struct notifier_block *this, unsigned long event,
86475 #ifdef CONFIG_IP_ROUTE_MULTIPATH
86476 fib_sync_up(dev);
86477 #endif
86478 - atomic_inc(&net->ipv4.dev_addr_genid);
86479 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
86480 rt_cache_flush(dev_net(dev));
86481 break;
86482 case NETDEV_DOWN:
86483 fib_del_ifaddr(ifa, NULL);
86484 - atomic_inc(&net->ipv4.dev_addr_genid);
86485 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
86486 if (ifa->ifa_dev->ifa_list == NULL) {
86487 /* Last address was deleted from this interface.
86488 * Disable IP.
86489 @@ -1058,7 +1058,7 @@ static int fib_netdev_event(struct notifier_block *this, unsigned long event, vo
86490 #ifdef CONFIG_IP_ROUTE_MULTIPATH
86491 fib_sync_up(dev);
86492 #endif
86493 - atomic_inc(&net->ipv4.dev_addr_genid);
86494 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
86495 rt_cache_flush(net);
86496 break;
86497 case NETDEV_DOWN:
86498 diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
86499 index 8f6cb7a..34507f9 100644
86500 --- a/net/ipv4/fib_semantics.c
86501 +++ b/net/ipv4/fib_semantics.c
86502 @@ -765,7 +765,7 @@ __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh)
86503 nh->nh_saddr = inet_select_addr(nh->nh_dev,
86504 nh->nh_gw,
86505 nh->nh_parent->fib_scope);
86506 - nh->nh_saddr_genid = atomic_read(&net->ipv4.dev_addr_genid);
86507 + nh->nh_saddr_genid = atomic_read_unchecked(&net->ipv4.dev_addr_genid);
86508
86509 return nh->nh_saddr;
86510 }
86511 diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c
86512 index 786d97a..1889c0d 100644
86513 --- a/net/ipv4/inet_connection_sock.c
86514 +++ b/net/ipv4/inet_connection_sock.c
86515 @@ -37,7 +37,7 @@ struct local_ports sysctl_local_ports __read_mostly = {
86516 .range = { 32768, 61000 },
86517 };
86518
86519 -unsigned long *sysctl_local_reserved_ports;
86520 +unsigned long sysctl_local_reserved_ports[65536 / 8 / sizeof(unsigned long)];
86521 EXPORT_SYMBOL(sysctl_local_reserved_ports);
86522
86523 void inet_get_local_port_range(int *low, int *high)
86524 diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c
86525 index 6af375a..c493c74 100644
86526 --- a/net/ipv4/inet_hashtables.c
86527 +++ b/net/ipv4/inet_hashtables.c
86528 @@ -18,12 +18,15 @@
86529 #include <linux/sched.h>
86530 #include <linux/slab.h>
86531 #include <linux/wait.h>
86532 +#include <linux/security.h>
86533
86534 #include <net/inet_connection_sock.h>
86535 #include <net/inet_hashtables.h>
86536 #include <net/secure_seq.h>
86537 #include <net/ip.h>
86538
86539 +extern void gr_update_task_in_ip_table(struct task_struct *task, const struct inet_sock *inet);
86540 +
86541 /*
86542 * Allocate and initialize a new local port bind bucket.
86543 * The bindhash mutex for snum's hash chain must be held here.
86544 @@ -554,6 +557,8 @@ ok:
86545 twrefcnt += inet_twsk_bind_unhash(tw, hinfo);
86546 spin_unlock(&head->lock);
86547
86548 + gr_update_task_in_ip_table(current, inet_sk(sk));
86549 +
86550 if (tw) {
86551 inet_twsk_deschedule(tw, death_row);
86552 while (twrefcnt) {
86553 diff --git a/net/ipv4/inetpeer.c b/net/ipv4/inetpeer.c
86554 index 000e3d2..5472da3 100644
86555 --- a/net/ipv4/inetpeer.c
86556 +++ b/net/ipv4/inetpeer.c
86557 @@ -503,8 +503,8 @@ relookup:
86558 if (p) {
86559 p->daddr = *daddr;
86560 atomic_set(&p->refcnt, 1);
86561 - atomic_set(&p->rid, 0);
86562 - atomic_set(&p->ip_id_count,
86563 + atomic_set_unchecked(&p->rid, 0);
86564 + atomic_set_unchecked(&p->ip_id_count,
86565 (daddr->family == AF_INET) ?
86566 secure_ip_id(daddr->addr.a4) :
86567 secure_ipv6_id(daddr->addr.a6));
86568 diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c
86569 index 52c273e..579060b 100644
86570 --- a/net/ipv4/ip_fragment.c
86571 +++ b/net/ipv4/ip_fragment.c
86572 @@ -311,7 +311,7 @@ static inline int ip_frag_too_far(struct ipq *qp)
86573 return 0;
86574
86575 start = qp->rid;
86576 - end = atomic_inc_return(&peer->rid);
86577 + end = atomic_inc_return_unchecked(&peer->rid);
86578 qp->rid = end;
86579
86580 rc = qp->q.fragments && (end - start) > max;
86581 @@ -788,12 +788,11 @@ static struct ctl_table ip4_frags_ctl_table[] = {
86582
86583 static int __net_init ip4_frags_ns_ctl_register(struct net *net)
86584 {
86585 - struct ctl_table *table;
86586 + ctl_table_no_const *table = NULL;
86587 struct ctl_table_header *hdr;
86588
86589 - table = ip4_frags_ns_ctl_table;
86590 if (!net_eq(net, &init_net)) {
86591 - table = kmemdup(table, sizeof(ip4_frags_ns_ctl_table), GFP_KERNEL);
86592 + table = kmemdup(ip4_frags_ns_ctl_table, sizeof(ip4_frags_ns_ctl_table), GFP_KERNEL);
86593 if (table == NULL)
86594 goto err_alloc;
86595
86596 @@ -804,9 +803,10 @@ static int __net_init ip4_frags_ns_ctl_register(struct net *net)
86597 /* Don't export sysctls to unprivileged users */
86598 if (net->user_ns != &init_user_ns)
86599 table[0].procname = NULL;
86600 - }
86601 + hdr = register_net_sysctl(net, "net/ipv4", table);
86602 + } else
86603 + hdr = register_net_sysctl(net, "net/ipv4", ip4_frags_ns_ctl_table);
86604
86605 - hdr = register_net_sysctl(net, "net/ipv4", table);
86606 if (hdr == NULL)
86607 goto err_reg;
86608
86609 @@ -814,8 +814,7 @@ static int __net_init ip4_frags_ns_ctl_register(struct net *net)
86610 return 0;
86611
86612 err_reg:
86613 - if (!net_eq(net, &init_net))
86614 - kfree(table);
86615 + kfree(table);
86616 err_alloc:
86617 return -ENOMEM;
86618 }
86619 diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
86620 index 91d66db..4af7d99 100644
86621 --- a/net/ipv4/ip_gre.c
86622 +++ b/net/ipv4/ip_gre.c
86623 @@ -124,7 +124,7 @@ static bool log_ecn_error = true;
86624 module_param(log_ecn_error, bool, 0644);
86625 MODULE_PARM_DESC(log_ecn_error, "Log packets received with corrupted ECN");
86626
86627 -static struct rtnl_link_ops ipgre_link_ops __read_mostly;
86628 +static struct rtnl_link_ops ipgre_link_ops;
86629 static int ipgre_tunnel_init(struct net_device *dev);
86630 static void ipgre_tunnel_setup(struct net_device *dev);
86631 static int ipgre_tunnel_bind_dev(struct net_device *dev);
86632 @@ -1823,7 +1823,7 @@ static const struct nla_policy ipgre_policy[IFLA_GRE_MAX + 1] = {
86633 [IFLA_GRE_PMTUDISC] = { .type = NLA_U8 },
86634 };
86635
86636 -static struct rtnl_link_ops ipgre_link_ops __read_mostly = {
86637 +static struct rtnl_link_ops ipgre_link_ops = {
86638 .kind = "gre",
86639 .maxtype = IFLA_GRE_MAX,
86640 .policy = ipgre_policy,
86641 @@ -1836,7 +1836,7 @@ static struct rtnl_link_ops ipgre_link_ops __read_mostly = {
86642 .fill_info = ipgre_fill_info,
86643 };
86644
86645 -static struct rtnl_link_ops ipgre_tap_ops __read_mostly = {
86646 +static struct rtnl_link_ops ipgre_tap_ops = {
86647 .kind = "gretap",
86648 .maxtype = IFLA_GRE_MAX,
86649 .policy = ipgre_policy,
86650 diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c
86651 index d9c4f11..02b82dbc 100644
86652 --- a/net/ipv4/ip_sockglue.c
86653 +++ b/net/ipv4/ip_sockglue.c
86654 @@ -1152,7 +1152,8 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
86655 len = min_t(unsigned int, len, opt->optlen);
86656 if (put_user(len, optlen))
86657 return -EFAULT;
86658 - if (copy_to_user(optval, opt->__data, len))
86659 + if ((len > (sizeof(optbuf) - sizeof(struct ip_options))) ||
86660 + copy_to_user(optval, opt->__data, len))
86661 return -EFAULT;
86662 return 0;
86663 }
86664 @@ -1283,7 +1284,7 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
86665 if (sk->sk_type != SOCK_STREAM)
86666 return -ENOPROTOOPT;
86667
86668 - msg.msg_control = optval;
86669 + msg.msg_control = (void __force_kernel *)optval;
86670 msg.msg_controllen = len;
86671 msg.msg_flags = flags;
86672
86673 diff --git a/net/ipv4/ip_vti.c b/net/ipv4/ip_vti.c
86674 index c3a4233..1412161 100644
86675 --- a/net/ipv4/ip_vti.c
86676 +++ b/net/ipv4/ip_vti.c
86677 @@ -47,7 +47,7 @@
86678 #define HASH_SIZE 16
86679 #define HASH(addr) (((__force u32)addr^((__force u32)addr>>4))&(HASH_SIZE-1))
86680
86681 -static struct rtnl_link_ops vti_link_ops __read_mostly;
86682 +static struct rtnl_link_ops vti_link_ops;
86683
86684 static int vti_net_id __read_mostly;
86685 struct vti_net {
86686 @@ -886,7 +886,7 @@ static const struct nla_policy vti_policy[IFLA_VTI_MAX + 1] = {
86687 [IFLA_VTI_REMOTE] = { .len = FIELD_SIZEOF(struct iphdr, daddr) },
86688 };
86689
86690 -static struct rtnl_link_ops vti_link_ops __read_mostly = {
86691 +static struct rtnl_link_ops vti_link_ops = {
86692 .kind = "vti",
86693 .maxtype = IFLA_VTI_MAX,
86694 .policy = vti_policy,
86695 diff --git a/net/ipv4/ipcomp.c b/net/ipv4/ipcomp.c
86696 index f01d1b1..8fe03ad 100644
86697 --- a/net/ipv4/ipcomp.c
86698 +++ b/net/ipv4/ipcomp.c
86699 @@ -48,7 +48,7 @@ static void ipcomp4_err(struct sk_buff *skb, u32 info)
86700 return;
86701
86702 if (icmp_hdr(skb)->type == ICMP_DEST_UNREACH) {
86703 - atomic_inc(&flow_cache_genid);
86704 + atomic_inc_unchecked(&flow_cache_genid);
86705 rt_genid_bump(net);
86706
86707 ipv4_update_pmtu(skb, net, info, 0, 0, IPPROTO_COMP, 0);
86708 diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c
86709 index bf6c5cf..ab2e9c6 100644
86710 --- a/net/ipv4/ipconfig.c
86711 +++ b/net/ipv4/ipconfig.c
86712 @@ -323,7 +323,7 @@ static int __init ic_devinet_ioctl(unsigned int cmd, struct ifreq *arg)
86713
86714 mm_segment_t oldfs = get_fs();
86715 set_fs(get_ds());
86716 - res = devinet_ioctl(&init_net, cmd, (struct ifreq __user *) arg);
86717 + res = devinet_ioctl(&init_net, cmd, (struct ifreq __force_user *) arg);
86718 set_fs(oldfs);
86719 return res;
86720 }
86721 @@ -334,7 +334,7 @@ static int __init ic_dev_ioctl(unsigned int cmd, struct ifreq *arg)
86722
86723 mm_segment_t oldfs = get_fs();
86724 set_fs(get_ds());
86725 - res = dev_ioctl(&init_net, cmd, (struct ifreq __user *) arg);
86726 + res = dev_ioctl(&init_net, cmd, (struct ifreq __force_user *) arg);
86727 set_fs(oldfs);
86728 return res;
86729 }
86730 @@ -345,7 +345,7 @@ static int __init ic_route_ioctl(unsigned int cmd, struct rtentry *arg)
86731
86732 mm_segment_t oldfs = get_fs();
86733 set_fs(get_ds());
86734 - res = ip_rt_ioctl(&init_net, cmd, (void __user *) arg);
86735 + res = ip_rt_ioctl(&init_net, cmd, (void __force_user *) arg);
86736 set_fs(oldfs);
86737 return res;
86738 }
86739 diff --git a/net/ipv4/ipip.c b/net/ipv4/ipip.c
86740 index 8f024d4..8b3500c 100644
86741 --- a/net/ipv4/ipip.c
86742 +++ b/net/ipv4/ipip.c
86743 @@ -138,7 +138,7 @@ struct ipip_net {
86744 static int ipip_tunnel_init(struct net_device *dev);
86745 static void ipip_tunnel_setup(struct net_device *dev);
86746 static void ipip_dev_free(struct net_device *dev);
86747 -static struct rtnl_link_ops ipip_link_ops __read_mostly;
86748 +static struct rtnl_link_ops ipip_link_ops;
86749
86750 static struct rtnl_link_stats64 *ipip_get_stats64(struct net_device *dev,
86751 struct rtnl_link_stats64 *tot)
86752 @@ -974,7 +974,7 @@ static const struct nla_policy ipip_policy[IFLA_IPTUN_MAX + 1] = {
86753 [IFLA_IPTUN_PMTUDISC] = { .type = NLA_U8 },
86754 };
86755
86756 -static struct rtnl_link_ops ipip_link_ops __read_mostly = {
86757 +static struct rtnl_link_ops ipip_link_ops = {
86758 .kind = "ipip",
86759 .maxtype = IFLA_IPTUN_MAX,
86760 .policy = ipip_policy,
86761 diff --git a/net/ipv4/netfilter/arp_tables.c b/net/ipv4/netfilter/arp_tables.c
86762 index 7dc6a97..229c61b 100644
86763 --- a/net/ipv4/netfilter/arp_tables.c
86764 +++ b/net/ipv4/netfilter/arp_tables.c
86765 @@ -879,14 +879,14 @@ static int compat_table_info(const struct xt_table_info *info,
86766 #endif
86767
86768 static int get_info(struct net *net, void __user *user,
86769 - const int *len, int compat)
86770 + int len, int compat)
86771 {
86772 char name[XT_TABLE_MAXNAMELEN];
86773 struct xt_table *t;
86774 int ret;
86775
86776 - if (*len != sizeof(struct arpt_getinfo)) {
86777 - duprintf("length %u != %Zu\n", *len,
86778 + if (len != sizeof(struct arpt_getinfo)) {
86779 + duprintf("length %u != %Zu\n", len,
86780 sizeof(struct arpt_getinfo));
86781 return -EINVAL;
86782 }
86783 @@ -923,7 +923,7 @@ static int get_info(struct net *net, void __user *user,
86784 info.size = private->size;
86785 strcpy(info.name, name);
86786
86787 - if (copy_to_user(user, &info, *len) != 0)
86788 + if (copy_to_user(user, &info, len) != 0)
86789 ret = -EFAULT;
86790 else
86791 ret = 0;
86792 @@ -1682,7 +1682,7 @@ static int compat_do_arpt_get_ctl(struct sock *sk, int cmd, void __user *user,
86793
86794 switch (cmd) {
86795 case ARPT_SO_GET_INFO:
86796 - ret = get_info(sock_net(sk), user, len, 1);
86797 + ret = get_info(sock_net(sk), user, *len, 1);
86798 break;
86799 case ARPT_SO_GET_ENTRIES:
86800 ret = compat_get_entries(sock_net(sk), user, len);
86801 @@ -1727,7 +1727,7 @@ static int do_arpt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len
86802
86803 switch (cmd) {
86804 case ARPT_SO_GET_INFO:
86805 - ret = get_info(sock_net(sk), user, len, 0);
86806 + ret = get_info(sock_net(sk), user, *len, 0);
86807 break;
86808
86809 case ARPT_SO_GET_ENTRIES:
86810 diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c
86811 index 3efcf87..5247916 100644
86812 --- a/net/ipv4/netfilter/ip_tables.c
86813 +++ b/net/ipv4/netfilter/ip_tables.c
86814 @@ -1068,14 +1068,14 @@ static int compat_table_info(const struct xt_table_info *info,
86815 #endif
86816
86817 static int get_info(struct net *net, void __user *user,
86818 - const int *len, int compat)
86819 + int len, int compat)
86820 {
86821 char name[XT_TABLE_MAXNAMELEN];
86822 struct xt_table *t;
86823 int ret;
86824
86825 - if (*len != sizeof(struct ipt_getinfo)) {
86826 - duprintf("length %u != %zu\n", *len,
86827 + if (len != sizeof(struct ipt_getinfo)) {
86828 + duprintf("length %u != %zu\n", len,
86829 sizeof(struct ipt_getinfo));
86830 return -EINVAL;
86831 }
86832 @@ -1112,7 +1112,7 @@ static int get_info(struct net *net, void __user *user,
86833 info.size = private->size;
86834 strcpy(info.name, name);
86835
86836 - if (copy_to_user(user, &info, *len) != 0)
86837 + if (copy_to_user(user, &info, len) != 0)
86838 ret = -EFAULT;
86839 else
86840 ret = 0;
86841 @@ -1966,7 +1966,7 @@ compat_do_ipt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
86842
86843 switch (cmd) {
86844 case IPT_SO_GET_INFO:
86845 - ret = get_info(sock_net(sk), user, len, 1);
86846 + ret = get_info(sock_net(sk), user, *len, 1);
86847 break;
86848 case IPT_SO_GET_ENTRIES:
86849 ret = compat_get_entries(sock_net(sk), user, len);
86850 @@ -2013,7 +2013,7 @@ do_ipt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
86851
86852 switch (cmd) {
86853 case IPT_SO_GET_INFO:
86854 - ret = get_info(sock_net(sk), user, len, 0);
86855 + ret = get_info(sock_net(sk), user, *len, 0);
86856 break;
86857
86858 case IPT_SO_GET_ENTRIES:
86859 diff --git a/net/ipv4/ping.c b/net/ipv4/ping.c
86860 index 2e91006..f084394 100644
86861 --- a/net/ipv4/ping.c
86862 +++ b/net/ipv4/ping.c
86863 @@ -844,7 +844,7 @@ static void ping_format_sock(struct sock *sp, struct seq_file *f,
86864 from_kuid_munged(seq_user_ns(f), sock_i_uid(sp)),
86865 0, sock_i_ino(sp),
86866 atomic_read(&sp->sk_refcnt), sp,
86867 - atomic_read(&sp->sk_drops), len);
86868 + atomic_read_unchecked(&sp->sk_drops), len);
86869 }
86870
86871 static int ping_seq_show(struct seq_file *seq, void *v)
86872 diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
86873 index dd44e0a..06dcca4 100644
86874 --- a/net/ipv4/raw.c
86875 +++ b/net/ipv4/raw.c
86876 @@ -309,7 +309,7 @@ static int raw_rcv_skb(struct sock *sk, struct sk_buff *skb)
86877 int raw_rcv(struct sock *sk, struct sk_buff *skb)
86878 {
86879 if (!xfrm4_policy_check(sk, XFRM_POLICY_IN, skb)) {
86880 - atomic_inc(&sk->sk_drops);
86881 + atomic_inc_unchecked(&sk->sk_drops);
86882 kfree_skb(skb);
86883 return NET_RX_DROP;
86884 }
86885 @@ -745,16 +745,20 @@ static int raw_init(struct sock *sk)
86886
86887 static int raw_seticmpfilter(struct sock *sk, char __user *optval, int optlen)
86888 {
86889 + struct icmp_filter filter;
86890 +
86891 if (optlen > sizeof(struct icmp_filter))
86892 optlen = sizeof(struct icmp_filter);
86893 - if (copy_from_user(&raw_sk(sk)->filter, optval, optlen))
86894 + if (copy_from_user(&filter, optval, optlen))
86895 return -EFAULT;
86896 + raw_sk(sk)->filter = filter;
86897 return 0;
86898 }
86899
86900 static int raw_geticmpfilter(struct sock *sk, char __user *optval, int __user *optlen)
86901 {
86902 int len, ret = -EFAULT;
86903 + struct icmp_filter filter;
86904
86905 if (get_user(len, optlen))
86906 goto out;
86907 @@ -764,8 +768,8 @@ static int raw_geticmpfilter(struct sock *sk, char __user *optval, int __user *o
86908 if (len > sizeof(struct icmp_filter))
86909 len = sizeof(struct icmp_filter);
86910 ret = -EFAULT;
86911 - if (put_user(len, optlen) ||
86912 - copy_to_user(optval, &raw_sk(sk)->filter, len))
86913 + filter = raw_sk(sk)->filter;
86914 + if (put_user(len, optlen) || len > sizeof filter || copy_to_user(optval, &filter, len))
86915 goto out;
86916 ret = 0;
86917 out: return ret;
86918 @@ -994,7 +998,7 @@ static void raw_sock_seq_show(struct seq_file *seq, struct sock *sp, int i)
86919 0, 0L, 0,
86920 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sp)),
86921 0, sock_i_ino(sp),
86922 - atomic_read(&sp->sk_refcnt), sp, atomic_read(&sp->sk_drops));
86923 + atomic_read(&sp->sk_refcnt), sp, atomic_read_unchecked(&sp->sk_drops));
86924 }
86925
86926 static int raw_seq_show(struct seq_file *seq, void *v)
86927 diff --git a/net/ipv4/route.c b/net/ipv4/route.c
86928 index 6e28514..5e1b055 100644
86929 --- a/net/ipv4/route.c
86930 +++ b/net/ipv4/route.c
86931 @@ -2553,34 +2553,34 @@ static struct ctl_table ipv4_route_flush_table[] = {
86932 .maxlen = sizeof(int),
86933 .mode = 0200,
86934 .proc_handler = ipv4_sysctl_rtcache_flush,
86935 + .extra1 = &init_net,
86936 },
86937 { },
86938 };
86939
86940 static __net_init int sysctl_route_net_init(struct net *net)
86941 {
86942 - struct ctl_table *tbl;
86943 + ctl_table_no_const *tbl = NULL;
86944
86945 - tbl = ipv4_route_flush_table;
86946 if (!net_eq(net, &init_net)) {
86947 - tbl = kmemdup(tbl, sizeof(ipv4_route_flush_table), GFP_KERNEL);
86948 + tbl = kmemdup(ipv4_route_flush_table, sizeof(ipv4_route_flush_table), GFP_KERNEL);
86949 if (tbl == NULL)
86950 goto err_dup;
86951
86952 /* Don't export sysctls to unprivileged users */
86953 if (net->user_ns != &init_user_ns)
86954 tbl[0].procname = NULL;
86955 - }
86956 - tbl[0].extra1 = net;
86957 + tbl[0].extra1 = net;
86958 + net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", tbl);
86959 + } else
86960 + net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", ipv4_route_flush_table);
86961
86962 - net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", tbl);
86963 if (net->ipv4.route_hdr == NULL)
86964 goto err_reg;
86965 return 0;
86966
86967 err_reg:
86968 - if (tbl != ipv4_route_flush_table)
86969 - kfree(tbl);
86970 + kfree(tbl);
86971 err_dup:
86972 return -ENOMEM;
86973 }
86974 @@ -2603,7 +2603,7 @@ static __net_initdata struct pernet_operations sysctl_route_ops = {
86975
86976 static __net_init int rt_genid_init(struct net *net)
86977 {
86978 - atomic_set(&net->rt_genid, 0);
86979 + atomic_set_unchecked(&net->rt_genid, 0);
86980 get_random_bytes(&net->ipv4.dev_addr_genid,
86981 sizeof(net->ipv4.dev_addr_genid));
86982 return 0;
86983 diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c
86984 index 960fd29..d55bf64 100644
86985 --- a/net/ipv4/sysctl_net_ipv4.c
86986 +++ b/net/ipv4/sysctl_net_ipv4.c
86987 @@ -55,7 +55,7 @@ static int ipv4_local_port_range(ctl_table *table, int write,
86988 {
86989 int ret;
86990 int range[2];
86991 - ctl_table tmp = {
86992 + ctl_table_no_const tmp = {
86993 .data = &range,
86994 .maxlen = sizeof(range),
86995 .mode = table->mode,
86996 @@ -108,7 +108,7 @@ static int ipv4_ping_group_range(ctl_table *table, int write,
86997 int ret;
86998 gid_t urange[2];
86999 kgid_t low, high;
87000 - ctl_table tmp = {
87001 + ctl_table_no_const tmp = {
87002 .data = &urange,
87003 .maxlen = sizeof(urange),
87004 .mode = table->mode,
87005 @@ -139,7 +139,7 @@ static int proc_tcp_congestion_control(ctl_table *ctl, int write,
87006 void __user *buffer, size_t *lenp, loff_t *ppos)
87007 {
87008 char val[TCP_CA_NAME_MAX];
87009 - ctl_table tbl = {
87010 + ctl_table_no_const tbl = {
87011 .data = val,
87012 .maxlen = TCP_CA_NAME_MAX,
87013 };
87014 @@ -158,7 +158,7 @@ static int proc_tcp_available_congestion_control(ctl_table *ctl,
87015 void __user *buffer, size_t *lenp,
87016 loff_t *ppos)
87017 {
87018 - ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX, };
87019 + ctl_table_no_const tbl = { .maxlen = TCP_CA_BUF_MAX, };
87020 int ret;
87021
87022 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
87023 @@ -175,7 +175,7 @@ static int proc_allowed_congestion_control(ctl_table *ctl,
87024 void __user *buffer, size_t *lenp,
87025 loff_t *ppos)
87026 {
87027 - ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX };
87028 + ctl_table_no_const tbl = { .maxlen = TCP_CA_BUF_MAX };
87029 int ret;
87030
87031 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
87032 @@ -201,15 +201,17 @@ static int ipv4_tcp_mem(ctl_table *ctl, int write,
87033 struct mem_cgroup *memcg;
87034 #endif
87035
87036 - ctl_table tmp = {
87037 + ctl_table_no_const tmp = {
87038 .data = &vec,
87039 .maxlen = sizeof(vec),
87040 .mode = ctl->mode,
87041 };
87042
87043 if (!write) {
87044 - ctl->data = &net->ipv4.sysctl_tcp_mem;
87045 - return proc_doulongvec_minmax(ctl, write, buffer, lenp, ppos);
87046 + ctl_table_no_const tcp_mem = *ctl;
87047 +
87048 + tcp_mem.data = &net->ipv4.sysctl_tcp_mem;
87049 + return proc_doulongvec_minmax(&tcp_mem, write, buffer, lenp, ppos);
87050 }
87051
87052 ret = proc_doulongvec_minmax(&tmp, write, buffer, lenp, ppos);
87053 @@ -236,7 +238,7 @@ static int ipv4_tcp_mem(ctl_table *ctl, int write,
87054 static int proc_tcp_fastopen_key(ctl_table *ctl, int write, void __user *buffer,
87055 size_t *lenp, loff_t *ppos)
87056 {
87057 - ctl_table tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) };
87058 + ctl_table_no_const tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) };
87059 struct tcp_fastopen_context *ctxt;
87060 int ret;
87061 u32 user_key[4]; /* 16 bytes, matching TCP_FASTOPEN_KEY_LENGTH */
87062 @@ -477,7 +479,7 @@ static struct ctl_table ipv4_table[] = {
87063 },
87064 {
87065 .procname = "ip_local_reserved_ports",
87066 - .data = NULL, /* initialized in sysctl_ipv4_init */
87067 + .data = sysctl_local_reserved_ports,
87068 .maxlen = 65536,
87069 .mode = 0644,
87070 .proc_handler = proc_do_large_bitmap,
87071 @@ -856,11 +858,10 @@ static struct ctl_table ipv4_net_table[] = {
87072
87073 static __net_init int ipv4_sysctl_init_net(struct net *net)
87074 {
87075 - struct ctl_table *table;
87076 + ctl_table_no_const *table = NULL;
87077
87078 - table = ipv4_net_table;
87079 if (!net_eq(net, &init_net)) {
87080 - table = kmemdup(table, sizeof(ipv4_net_table), GFP_KERNEL);
87081 + table = kmemdup(ipv4_net_table, sizeof(ipv4_net_table), GFP_KERNEL);
87082 if (table == NULL)
87083 goto err_alloc;
87084
87085 @@ -895,15 +896,17 @@ static __net_init int ipv4_sysctl_init_net(struct net *net)
87086
87087 tcp_init_mem(net);
87088
87089 - net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
87090 + if (!net_eq(net, &init_net))
87091 + net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
87092 + else
87093 + net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", ipv4_net_table);
87094 if (net->ipv4.ipv4_hdr == NULL)
87095 goto err_reg;
87096
87097 return 0;
87098
87099 err_reg:
87100 - if (!net_eq(net, &init_net))
87101 - kfree(table);
87102 + kfree(table);
87103 err_alloc:
87104 return -ENOMEM;
87105 }
87106 @@ -925,16 +928,6 @@ static __net_initdata struct pernet_operations ipv4_sysctl_ops = {
87107 static __init int sysctl_ipv4_init(void)
87108 {
87109 struct ctl_table_header *hdr;
87110 - struct ctl_table *i;
87111 -
87112 - for (i = ipv4_table; i->procname; i++) {
87113 - if (strcmp(i->procname, "ip_local_reserved_ports") == 0) {
87114 - i->data = sysctl_local_reserved_ports;
87115 - break;
87116 - }
87117 - }
87118 - if (!i->procname)
87119 - return -EINVAL;
87120
87121 hdr = register_net_sysctl(&init_net, "net/ipv4", ipv4_table);
87122 if (hdr == NULL)
87123 diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
87124 index 13b9c08..d33a8d0 100644
87125 --- a/net/ipv4/tcp_input.c
87126 +++ b/net/ipv4/tcp_input.c
87127 @@ -4724,7 +4724,7 @@ static struct sk_buff *tcp_collapse_one(struct sock *sk, struct sk_buff *skb,
87128 * simplifies code)
87129 */
87130 static void
87131 -tcp_collapse(struct sock *sk, struct sk_buff_head *list,
87132 +__intentional_overflow(5,6) tcp_collapse(struct sock *sk, struct sk_buff_head *list,
87133 struct sk_buff *head, struct sk_buff *tail,
87134 u32 start, u32 end)
87135 {
87136 @@ -5838,6 +5838,7 @@ discard:
87137 tcp_paws_reject(&tp->rx_opt, 0))
87138 goto discard_and_undo;
87139
87140 +#ifndef CONFIG_GRKERNSEC_NO_SIMULT_CONNECT
87141 if (th->syn) {
87142 /* We see SYN without ACK. It is attempt of
87143 * simultaneous connect with crossed SYNs.
87144 @@ -5888,6 +5889,7 @@ discard:
87145 goto discard;
87146 #endif
87147 }
87148 +#endif
87149 /* "fifth, if neither of the SYN or RST bits is set then
87150 * drop the segment and return."
87151 */
87152 @@ -5932,7 +5934,7 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
87153 goto discard;
87154
87155 if (th->syn) {
87156 - if (th->fin)
87157 + if (th->fin || th->urg || th->psh)
87158 goto discard;
87159 if (icsk->icsk_af_ops->conn_request(sk, skb) < 0)
87160 return 1;
87161 diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
87162 index d09203c..fd5cc91 100644
87163 --- a/net/ipv4/tcp_ipv4.c
87164 +++ b/net/ipv4/tcp_ipv4.c
87165 @@ -90,6 +90,10 @@ int sysctl_tcp_low_latency __read_mostly;
87166 EXPORT_SYMBOL(sysctl_tcp_low_latency);
87167
87168
87169 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87170 +extern int grsec_enable_blackhole;
87171 +#endif
87172 +
87173 #ifdef CONFIG_TCP_MD5SIG
87174 static int tcp_v4_md5_hash_hdr(char *md5_hash, const struct tcp_md5sig_key *key,
87175 __be32 daddr, __be32 saddr, const struct tcphdr *th);
87176 @@ -1897,6 +1901,9 @@ int tcp_v4_do_rcv(struct sock *sk, struct sk_buff *skb)
87177 return 0;
87178
87179 reset:
87180 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87181 + if (!grsec_enable_blackhole)
87182 +#endif
87183 tcp_v4_send_reset(rsk, skb);
87184 discard:
87185 kfree_skb(skb);
87186 @@ -1996,12 +2003,19 @@ int tcp_v4_rcv(struct sk_buff *skb)
87187 TCP_SKB_CB(skb)->sacked = 0;
87188
87189 sk = __inet_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest);
87190 - if (!sk)
87191 + if (!sk) {
87192 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87193 + ret = 1;
87194 +#endif
87195 goto no_tcp_socket;
87196 -
87197 + }
87198 process:
87199 - if (sk->sk_state == TCP_TIME_WAIT)
87200 + if (sk->sk_state == TCP_TIME_WAIT) {
87201 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87202 + ret = 2;
87203 +#endif
87204 goto do_time_wait;
87205 + }
87206
87207 if (unlikely(iph->ttl < inet_sk(sk)->min_ttl)) {
87208 NET_INC_STATS_BH(net, LINUX_MIB_TCPMINTTLDROP);
87209 @@ -2052,6 +2066,10 @@ no_tcp_socket:
87210 bad_packet:
87211 TCP_INC_STATS_BH(net, TCP_MIB_INERRS);
87212 } else {
87213 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87214 + if (!grsec_enable_blackhole || (ret == 1 &&
87215 + (skb->dev->flags & IFF_LOOPBACK)))
87216 +#endif
87217 tcp_v4_send_reset(NULL, skb);
87218 }
87219
87220 diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c
87221 index 2f672e7..b8895e9 100644
87222 --- a/net/ipv4/tcp_minisocks.c
87223 +++ b/net/ipv4/tcp_minisocks.c
87224 @@ -27,6 +27,10 @@
87225 #include <net/inet_common.h>
87226 #include <net/xfrm.h>
87227
87228 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87229 +extern int grsec_enable_blackhole;
87230 +#endif
87231 +
87232 int sysctl_tcp_syncookies __read_mostly = 1;
87233 EXPORT_SYMBOL(sysctl_tcp_syncookies);
87234
87235 @@ -749,7 +753,10 @@ embryonic_reset:
87236 * avoid becoming vulnerable to outside attack aiming at
87237 * resetting legit local connections.
87238 */
87239 - req->rsk_ops->send_reset(sk, skb);
87240 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87241 + if (!grsec_enable_blackhole)
87242 +#endif
87243 + req->rsk_ops->send_reset(sk, skb);
87244 } else if (fastopen) { /* received a valid RST pkt */
87245 reqsk_fastopen_remove(sk, req, true);
87246 tcp_reset(sk);
87247 diff --git a/net/ipv4/tcp_probe.c b/net/ipv4/tcp_probe.c
87248 index d4943f6..e7a74a5 100644
87249 --- a/net/ipv4/tcp_probe.c
87250 +++ b/net/ipv4/tcp_probe.c
87251 @@ -204,7 +204,7 @@ static ssize_t tcpprobe_read(struct file *file, char __user *buf,
87252 if (cnt + width >= len)
87253 break;
87254
87255 - if (copy_to_user(buf + cnt, tbuf, width))
87256 + if (width > sizeof tbuf || copy_to_user(buf + cnt, tbuf, width))
87257 return -EFAULT;
87258 cnt += width;
87259 }
87260 diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c
87261 index b78aac3..e18230b 100644
87262 --- a/net/ipv4/tcp_timer.c
87263 +++ b/net/ipv4/tcp_timer.c
87264 @@ -22,6 +22,10 @@
87265 #include <linux/gfp.h>
87266 #include <net/tcp.h>
87267
87268 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87269 +extern int grsec_lastack_retries;
87270 +#endif
87271 +
87272 int sysctl_tcp_syn_retries __read_mostly = TCP_SYN_RETRIES;
87273 int sysctl_tcp_synack_retries __read_mostly = TCP_SYNACK_RETRIES;
87274 int sysctl_tcp_keepalive_time __read_mostly = TCP_KEEPALIVE_TIME;
87275 @@ -185,6 +189,13 @@ static int tcp_write_timeout(struct sock *sk)
87276 }
87277 }
87278
87279 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87280 + if ((sk->sk_state == TCP_LAST_ACK) &&
87281 + (grsec_lastack_retries > 0) &&
87282 + (grsec_lastack_retries < retry_until))
87283 + retry_until = grsec_lastack_retries;
87284 +#endif
87285 +
87286 if (retransmits_timed_out(sk, retry_until,
87287 syn_set ? 0 : icsk->icsk_user_timeout, syn_set)) {
87288 /* Has it gone just too far? */
87289 diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
87290 index 0a073a2..ddf6279 100644
87291 --- a/net/ipv4/udp.c
87292 +++ b/net/ipv4/udp.c
87293 @@ -87,6 +87,7 @@
87294 #include <linux/types.h>
87295 #include <linux/fcntl.h>
87296 #include <linux/module.h>
87297 +#include <linux/security.h>
87298 #include <linux/socket.h>
87299 #include <linux/sockios.h>
87300 #include <linux/igmp.h>
87301 @@ -111,6 +112,10 @@
87302 #include <trace/events/skb.h>
87303 #include "udp_impl.h"
87304
87305 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87306 +extern int grsec_enable_blackhole;
87307 +#endif
87308 +
87309 struct udp_table udp_table __read_mostly;
87310 EXPORT_SYMBOL(udp_table);
87311
87312 @@ -594,6 +599,9 @@ found:
87313 return s;
87314 }
87315
87316 +extern int gr_search_udp_recvmsg(struct sock *sk, const struct sk_buff *skb);
87317 +extern int gr_search_udp_sendmsg(struct sock *sk, struct sockaddr_in *addr);
87318 +
87319 /*
87320 * This routine is called by the ICMP module when it gets some
87321 * sort of error condition. If err < 0 then the socket should
87322 @@ -889,9 +897,18 @@ int udp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
87323 dport = usin->sin_port;
87324 if (dport == 0)
87325 return -EINVAL;
87326 +
87327 + err = gr_search_udp_sendmsg(sk, usin);
87328 + if (err)
87329 + return err;
87330 } else {
87331 if (sk->sk_state != TCP_ESTABLISHED)
87332 return -EDESTADDRREQ;
87333 +
87334 + err = gr_search_udp_sendmsg(sk, NULL);
87335 + if (err)
87336 + return err;
87337 +
87338 daddr = inet->inet_daddr;
87339 dport = inet->inet_dport;
87340 /* Open fast path for connected socket.
87341 @@ -1133,7 +1150,7 @@ static unsigned int first_packet_length(struct sock *sk)
87342 udp_lib_checksum_complete(skb)) {
87343 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
87344 IS_UDPLITE(sk));
87345 - atomic_inc(&sk->sk_drops);
87346 + atomic_inc_unchecked(&sk->sk_drops);
87347 __skb_unlink(skb, rcvq);
87348 __skb_queue_tail(&list_kill, skb);
87349 }
87350 @@ -1219,6 +1236,10 @@ try_again:
87351 if (!skb)
87352 goto out;
87353
87354 + err = gr_search_udp_recvmsg(sk, skb);
87355 + if (err)
87356 + goto out_free;
87357 +
87358 ulen = skb->len - sizeof(struct udphdr);
87359 copied = len;
87360 if (copied > ulen)
87361 @@ -1252,7 +1273,7 @@ try_again:
87362 if (unlikely(err)) {
87363 trace_kfree_skb(skb, udp_recvmsg);
87364 if (!peeked) {
87365 - atomic_inc(&sk->sk_drops);
87366 + atomic_inc_unchecked(&sk->sk_drops);
87367 UDP_INC_STATS_USER(sock_net(sk),
87368 UDP_MIB_INERRORS, is_udplite);
87369 }
87370 @@ -1535,7 +1556,7 @@ int udp_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
87371
87372 drop:
87373 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
87374 - atomic_inc(&sk->sk_drops);
87375 + atomic_inc_unchecked(&sk->sk_drops);
87376 kfree_skb(skb);
87377 return -1;
87378 }
87379 @@ -1554,7 +1575,7 @@ static void flush_stack(struct sock **stack, unsigned int count,
87380 skb1 = (i == final) ? skb : skb_clone(skb, GFP_ATOMIC);
87381
87382 if (!skb1) {
87383 - atomic_inc(&sk->sk_drops);
87384 + atomic_inc_unchecked(&sk->sk_drops);
87385 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_RCVBUFERRORS,
87386 IS_UDPLITE(sk));
87387 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
87388 @@ -1723,6 +1744,9 @@ int __udp4_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
87389 goto csum_error;
87390
87391 UDP_INC_STATS_BH(net, UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE);
87392 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87393 + if (!grsec_enable_blackhole || (skb->dev->flags & IFF_LOOPBACK))
87394 +#endif
87395 icmp_send(skb, ICMP_DEST_UNREACH, ICMP_PORT_UNREACH, 0);
87396
87397 /*
87398 @@ -2152,7 +2176,7 @@ static void udp4_format_sock(struct sock *sp, struct seq_file *f,
87399 from_kuid_munged(seq_user_ns(f), sock_i_uid(sp)),
87400 0, sock_i_ino(sp),
87401 atomic_read(&sp->sk_refcnt), sp,
87402 - atomic_read(&sp->sk_drops), len);
87403 + atomic_read_unchecked(&sp->sk_drops), len);
87404 }
87405
87406 int udp4_seq_show(struct seq_file *seq, void *v)
87407 diff --git a/net/ipv4/xfrm4_policy.c b/net/ipv4/xfrm4_policy.c
87408 index 9a459be..086b866 100644
87409 --- a/net/ipv4/xfrm4_policy.c
87410 +++ b/net/ipv4/xfrm4_policy.c
87411 @@ -264,19 +264,18 @@ static struct ctl_table xfrm4_policy_table[] = {
87412
87413 static int __net_init xfrm4_net_init(struct net *net)
87414 {
87415 - struct ctl_table *table;
87416 + ctl_table_no_const *table = NULL;
87417 struct ctl_table_header *hdr;
87418
87419 - table = xfrm4_policy_table;
87420 if (!net_eq(net, &init_net)) {
87421 - table = kmemdup(table, sizeof(xfrm4_policy_table), GFP_KERNEL);
87422 + table = kmemdup(xfrm4_policy_table, sizeof(xfrm4_policy_table), GFP_KERNEL);
87423 if (!table)
87424 goto err_alloc;
87425
87426 table[0].data = &net->xfrm.xfrm4_dst_ops.gc_thresh;
87427 - }
87428 -
87429 - hdr = register_net_sysctl(net, "net/ipv4", table);
87430 + hdr = register_net_sysctl(net, "net/ipv4", table);
87431 + } else
87432 + hdr = register_net_sysctl(net, "net/ipv4", xfrm4_policy_table);
87433 if (!hdr)
87434 goto err_reg;
87435
87436 @@ -284,8 +283,7 @@ static int __net_init xfrm4_net_init(struct net *net)
87437 return 0;
87438
87439 err_reg:
87440 - if (!net_eq(net, &init_net))
87441 - kfree(table);
87442 + kfree(table);
87443 err_alloc:
87444 return -ENOMEM;
87445 }
87446 diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
87447 index dae802c..bfa4baa 100644
87448 --- a/net/ipv6/addrconf.c
87449 +++ b/net/ipv6/addrconf.c
87450 @@ -2274,7 +2274,7 @@ int addrconf_set_dstaddr(struct net *net, void __user *arg)
87451 p.iph.ihl = 5;
87452 p.iph.protocol = IPPROTO_IPV6;
87453 p.iph.ttl = 64;
87454 - ifr.ifr_ifru.ifru_data = (__force void __user *)&p;
87455 + ifr.ifr_ifru.ifru_data = (void __force_user *)&p;
87456
87457 if (ops->ndo_do_ioctl) {
87458 mm_segment_t oldfs = get_fs();
87459 @@ -4410,7 +4410,7 @@ int addrconf_sysctl_forward(ctl_table *ctl, int write,
87460 int *valp = ctl->data;
87461 int val = *valp;
87462 loff_t pos = *ppos;
87463 - ctl_table lctl;
87464 + ctl_table_no_const lctl;
87465 int ret;
87466
87467 /*
87468 @@ -4492,7 +4492,7 @@ int addrconf_sysctl_disable(ctl_table *ctl, int write,
87469 int *valp = ctl->data;
87470 int val = *valp;
87471 loff_t pos = *ppos;
87472 - ctl_table lctl;
87473 + ctl_table_no_const lctl;
87474 int ret;
87475
87476 /*
87477 diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c
87478 index fff5bdd..15194fb 100644
87479 --- a/net/ipv6/icmp.c
87480 +++ b/net/ipv6/icmp.c
87481 @@ -973,7 +973,7 @@ ctl_table ipv6_icmp_table_template[] = {
87482
87483 struct ctl_table * __net_init ipv6_icmp_sysctl_init(struct net *net)
87484 {
87485 - struct ctl_table *table;
87486 + ctl_table_no_const *table;
87487
87488 table = kmemdup(ipv6_icmp_table_template,
87489 sizeof(ipv6_icmp_table_template),
87490 diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
87491 index 95d13c7..791fe2f 100644
87492 --- a/net/ipv6/ip6_gre.c
87493 +++ b/net/ipv6/ip6_gre.c
87494 @@ -73,7 +73,7 @@ struct ip6gre_net {
87495 struct net_device *fb_tunnel_dev;
87496 };
87497
87498 -static struct rtnl_link_ops ip6gre_link_ops __read_mostly;
87499 +static struct rtnl_link_ops ip6gre_link_ops;
87500 static int ip6gre_tunnel_init(struct net_device *dev);
87501 static void ip6gre_tunnel_setup(struct net_device *dev);
87502 static void ip6gre_tunnel_link(struct ip6gre_net *ign, struct ip6_tnl *t);
87503 @@ -1337,7 +1337,7 @@ static void ip6gre_fb_tunnel_init(struct net_device *dev)
87504 }
87505
87506
87507 -static struct inet6_protocol ip6gre_protocol __read_mostly = {
87508 +static struct inet6_protocol ip6gre_protocol = {
87509 .handler = ip6gre_rcv,
87510 .err_handler = ip6gre_err,
87511 .flags = INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL,
87512 @@ -1671,7 +1671,7 @@ static const struct nla_policy ip6gre_policy[IFLA_GRE_MAX + 1] = {
87513 [IFLA_GRE_FLAGS] = { .type = NLA_U32 },
87514 };
87515
87516 -static struct rtnl_link_ops ip6gre_link_ops __read_mostly = {
87517 +static struct rtnl_link_ops ip6gre_link_ops = {
87518 .kind = "ip6gre",
87519 .maxtype = IFLA_GRE_MAX,
87520 .policy = ip6gre_policy,
87521 @@ -1684,7 +1684,7 @@ static struct rtnl_link_ops ip6gre_link_ops __read_mostly = {
87522 .fill_info = ip6gre_fill_info,
87523 };
87524
87525 -static struct rtnl_link_ops ip6gre_tap_ops __read_mostly = {
87526 +static struct rtnl_link_ops ip6gre_tap_ops = {
87527 .kind = "ip6gretap",
87528 .maxtype = IFLA_GRE_MAX,
87529 .policy = ip6gre_policy,
87530 diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
87531 index fff83cb..82d49dd 100644
87532 --- a/net/ipv6/ip6_tunnel.c
87533 +++ b/net/ipv6/ip6_tunnel.c
87534 @@ -87,7 +87,7 @@ static u32 HASH(const struct in6_addr *addr1, const struct in6_addr *addr2)
87535
87536 static int ip6_tnl_dev_init(struct net_device *dev);
87537 static void ip6_tnl_dev_setup(struct net_device *dev);
87538 -static struct rtnl_link_ops ip6_link_ops __read_mostly;
87539 +static struct rtnl_link_ops ip6_link_ops;
87540
87541 static int ip6_tnl_net_id __read_mostly;
87542 struct ip6_tnl_net {
87543 @@ -1684,7 +1684,7 @@ static const struct nla_policy ip6_tnl_policy[IFLA_IPTUN_MAX + 1] = {
87544 [IFLA_IPTUN_PROTO] = { .type = NLA_U8 },
87545 };
87546
87547 -static struct rtnl_link_ops ip6_link_ops __read_mostly = {
87548 +static struct rtnl_link_ops ip6_link_ops = {
87549 .kind = "ip6tnl",
87550 .maxtype = IFLA_IPTUN_MAX,
87551 .policy = ip6_tnl_policy,
87552 diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
87553 index d1e2e8e..51c19ae 100644
87554 --- a/net/ipv6/ipv6_sockglue.c
87555 +++ b/net/ipv6/ipv6_sockglue.c
87556 @@ -991,7 +991,7 @@ static int do_ipv6_getsockopt(struct sock *sk, int level, int optname,
87557 if (sk->sk_type != SOCK_STREAM)
87558 return -ENOPROTOOPT;
87559
87560 - msg.msg_control = optval;
87561 + msg.msg_control = (void __force_kernel *)optval;
87562 msg.msg_controllen = len;
87563 msg.msg_flags = flags;
87564
87565 diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c
87566 index 341b54a..591e8ed 100644
87567 --- a/net/ipv6/netfilter/ip6_tables.c
87568 +++ b/net/ipv6/netfilter/ip6_tables.c
87569 @@ -1076,14 +1076,14 @@ static int compat_table_info(const struct xt_table_info *info,
87570 #endif
87571
87572 static int get_info(struct net *net, void __user *user,
87573 - const int *len, int compat)
87574 + int len, int compat)
87575 {
87576 char name[XT_TABLE_MAXNAMELEN];
87577 struct xt_table *t;
87578 int ret;
87579
87580 - if (*len != sizeof(struct ip6t_getinfo)) {
87581 - duprintf("length %u != %zu\n", *len,
87582 + if (len != sizeof(struct ip6t_getinfo)) {
87583 + duprintf("length %u != %zu\n", len,
87584 sizeof(struct ip6t_getinfo));
87585 return -EINVAL;
87586 }
87587 @@ -1120,7 +1120,7 @@ static int get_info(struct net *net, void __user *user,
87588 info.size = private->size;
87589 strcpy(info.name, name);
87590
87591 - if (copy_to_user(user, &info, *len) != 0)
87592 + if (copy_to_user(user, &info, len) != 0)
87593 ret = -EFAULT;
87594 else
87595 ret = 0;
87596 @@ -1974,7 +1974,7 @@ compat_do_ip6t_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
87597
87598 switch (cmd) {
87599 case IP6T_SO_GET_INFO:
87600 - ret = get_info(sock_net(sk), user, len, 1);
87601 + ret = get_info(sock_net(sk), user, *len, 1);
87602 break;
87603 case IP6T_SO_GET_ENTRIES:
87604 ret = compat_get_entries(sock_net(sk), user, len);
87605 @@ -2021,7 +2021,7 @@ do_ip6t_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
87606
87607 switch (cmd) {
87608 case IP6T_SO_GET_INFO:
87609 - ret = get_info(sock_net(sk), user, len, 0);
87610 + ret = get_info(sock_net(sk), user, *len, 0);
87611 break;
87612
87613 case IP6T_SO_GET_ENTRIES:
87614 diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c b/net/ipv6/netfilter/nf_conntrack_reasm.c
87615 index 6700069..1e50f42 100644
87616 --- a/net/ipv6/netfilter/nf_conntrack_reasm.c
87617 +++ b/net/ipv6/netfilter/nf_conntrack_reasm.c
87618 @@ -89,12 +89,11 @@ static struct ctl_table nf_ct_frag6_sysctl_table[] = {
87619
87620 static int nf_ct_frag6_sysctl_register(struct net *net)
87621 {
87622 - struct ctl_table *table;
87623 + ctl_table_no_const *table = NULL;
87624 struct ctl_table_header *hdr;
87625
87626 - table = nf_ct_frag6_sysctl_table;
87627 if (!net_eq(net, &init_net)) {
87628 - table = kmemdup(table, sizeof(nf_ct_frag6_sysctl_table),
87629 + table = kmemdup(nf_ct_frag6_sysctl_table, sizeof(nf_ct_frag6_sysctl_table),
87630 GFP_KERNEL);
87631 if (table == NULL)
87632 goto err_alloc;
87633 @@ -102,9 +101,9 @@ static int nf_ct_frag6_sysctl_register(struct net *net)
87634 table[0].data = &net->nf_frag.frags.timeout;
87635 table[1].data = &net->nf_frag.frags.low_thresh;
87636 table[2].data = &net->nf_frag.frags.high_thresh;
87637 - }
87638 -
87639 - hdr = register_net_sysctl(net, "net/netfilter", table);
87640 + hdr = register_net_sysctl(net, "net/netfilter", table);
87641 + } else
87642 + hdr = register_net_sysctl(net, "net/netfilter", nf_ct_frag6_sysctl_table);
87643 if (hdr == NULL)
87644 goto err_reg;
87645
87646 @@ -112,8 +111,7 @@ static int nf_ct_frag6_sysctl_register(struct net *net)
87647 return 0;
87648
87649 err_reg:
87650 - if (!net_eq(net, &init_net))
87651 - kfree(table);
87652 + kfree(table);
87653 err_alloc:
87654 return -ENOMEM;
87655 }
87656 diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c
87657 index 330b5e7..796fbf1 100644
87658 --- a/net/ipv6/raw.c
87659 +++ b/net/ipv6/raw.c
87660 @@ -378,7 +378,7 @@ static inline int rawv6_rcv_skb(struct sock *sk, struct sk_buff *skb)
87661 {
87662 if ((raw6_sk(sk)->checksum || rcu_access_pointer(sk->sk_filter)) &&
87663 skb_checksum_complete(skb)) {
87664 - atomic_inc(&sk->sk_drops);
87665 + atomic_inc_unchecked(&sk->sk_drops);
87666 kfree_skb(skb);
87667 return NET_RX_DROP;
87668 }
87669 @@ -406,7 +406,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
87670 struct raw6_sock *rp = raw6_sk(sk);
87671
87672 if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb)) {
87673 - atomic_inc(&sk->sk_drops);
87674 + atomic_inc_unchecked(&sk->sk_drops);
87675 kfree_skb(skb);
87676 return NET_RX_DROP;
87677 }
87678 @@ -430,7 +430,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
87679
87680 if (inet->hdrincl) {
87681 if (skb_checksum_complete(skb)) {
87682 - atomic_inc(&sk->sk_drops);
87683 + atomic_inc_unchecked(&sk->sk_drops);
87684 kfree_skb(skb);
87685 return NET_RX_DROP;
87686 }
87687 @@ -603,7 +603,7 @@ out:
87688 return err;
87689 }
87690
87691 -static int rawv6_send_hdrinc(struct sock *sk, void *from, int length,
87692 +static int rawv6_send_hdrinc(struct sock *sk, void *from, unsigned int length,
87693 struct flowi6 *fl6, struct dst_entry **dstp,
87694 unsigned int flags)
87695 {
87696 @@ -915,12 +915,15 @@ do_confirm:
87697 static int rawv6_seticmpfilter(struct sock *sk, int level, int optname,
87698 char __user *optval, int optlen)
87699 {
87700 + struct icmp6_filter filter;
87701 +
87702 switch (optname) {
87703 case ICMPV6_FILTER:
87704 if (optlen > sizeof(struct icmp6_filter))
87705 optlen = sizeof(struct icmp6_filter);
87706 - if (copy_from_user(&raw6_sk(sk)->filter, optval, optlen))
87707 + if (copy_from_user(&filter, optval, optlen))
87708 return -EFAULT;
87709 + raw6_sk(sk)->filter = filter;
87710 return 0;
87711 default:
87712 return -ENOPROTOOPT;
87713 @@ -933,6 +936,7 @@ static int rawv6_geticmpfilter(struct sock *sk, int level, int optname,
87714 char __user *optval, int __user *optlen)
87715 {
87716 int len;
87717 + struct icmp6_filter filter;
87718
87719 switch (optname) {
87720 case ICMPV6_FILTER:
87721 @@ -944,7 +948,8 @@ static int rawv6_geticmpfilter(struct sock *sk, int level, int optname,
87722 len = sizeof(struct icmp6_filter);
87723 if (put_user(len, optlen))
87724 return -EFAULT;
87725 - if (copy_to_user(optval, &raw6_sk(sk)->filter, len))
87726 + filter = raw6_sk(sk)->filter;
87727 + if (len > sizeof filter || copy_to_user(optval, &filter, len))
87728 return -EFAULT;
87729 return 0;
87730 default:
87731 @@ -1252,7 +1257,7 @@ static void raw6_sock_seq_show(struct seq_file *seq, struct sock *sp, int i)
87732 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sp)),
87733 0,
87734 sock_i_ino(sp),
87735 - atomic_read(&sp->sk_refcnt), sp, atomic_read(&sp->sk_drops));
87736 + atomic_read(&sp->sk_refcnt), sp, atomic_read_unchecked(&sp->sk_drops));
87737 }
87738
87739 static int raw6_seq_show(struct seq_file *seq, void *v)
87740 diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c
87741 index 0ba10e5..c14a4f6 100644
87742 --- a/net/ipv6/reassembly.c
87743 +++ b/net/ipv6/reassembly.c
87744 @@ -602,12 +602,11 @@ static struct ctl_table ip6_frags_ctl_table[] = {
87745
87746 static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
87747 {
87748 - struct ctl_table *table;
87749 + ctl_table_no_const *table = NULL;
87750 struct ctl_table_header *hdr;
87751
87752 - table = ip6_frags_ns_ctl_table;
87753 if (!net_eq(net, &init_net)) {
87754 - table = kmemdup(table, sizeof(ip6_frags_ns_ctl_table), GFP_KERNEL);
87755 + table = kmemdup(ip6_frags_ns_ctl_table, sizeof(ip6_frags_ns_ctl_table), GFP_KERNEL);
87756 if (table == NULL)
87757 goto err_alloc;
87758
87759 @@ -618,9 +617,10 @@ static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
87760 /* Don't export sysctls to unprivileged users */
87761 if (net->user_ns != &init_user_ns)
87762 table[0].procname = NULL;
87763 - }
87764 + hdr = register_net_sysctl(net, "net/ipv6", table);
87765 + } else
87766 + hdr = register_net_sysctl(net, "net/ipv6", ip6_frags_ns_ctl_table);
87767
87768 - hdr = register_net_sysctl(net, "net/ipv6", table);
87769 if (hdr == NULL)
87770 goto err_reg;
87771
87772 @@ -628,8 +628,7 @@ static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
87773 return 0;
87774
87775 err_reg:
87776 - if (!net_eq(net, &init_net))
87777 - kfree(table);
87778 + kfree(table);
87779 err_alloc:
87780 return -ENOMEM;
87781 }
87782 diff --git a/net/ipv6/route.c b/net/ipv6/route.c
87783 index e5fe004..9fe3e8e 100644
87784 --- a/net/ipv6/route.c
87785 +++ b/net/ipv6/route.c
87786 @@ -2881,7 +2881,7 @@ ctl_table ipv6_route_table_template[] = {
87787
87788 struct ctl_table * __net_init ipv6_route_sysctl_init(struct net *net)
87789 {
87790 - struct ctl_table *table;
87791 + ctl_table_no_const *table;
87792
87793 table = kmemdup(ipv6_route_table_template,
87794 sizeof(ipv6_route_table_template),
87795 diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
87796 index 02f96dc..4a5a6e5 100644
87797 --- a/net/ipv6/sit.c
87798 +++ b/net/ipv6/sit.c
87799 @@ -74,7 +74,7 @@ static void ipip6_tunnel_setup(struct net_device *dev);
87800 static void ipip6_dev_free(struct net_device *dev);
87801 static bool check_6rd(struct ip_tunnel *tunnel, const struct in6_addr *v6dst,
87802 __be32 *v4dst);
87803 -static struct rtnl_link_ops sit_link_ops __read_mostly;
87804 +static struct rtnl_link_ops sit_link_ops;
87805
87806 static int sit_net_id __read_mostly;
87807 struct sit_net {
87808 @@ -1486,7 +1486,7 @@ static const struct nla_policy ipip6_policy[IFLA_IPTUN_MAX + 1] = {
87809 #endif
87810 };
87811
87812 -static struct rtnl_link_ops sit_link_ops __read_mostly = {
87813 +static struct rtnl_link_ops sit_link_ops = {
87814 .kind = "sit",
87815 .maxtype = IFLA_IPTUN_MAX,
87816 .policy = ipip6_policy,
87817 diff --git a/net/ipv6/sysctl_net_ipv6.c b/net/ipv6/sysctl_net_ipv6.c
87818 index e85c48b..b8268d3 100644
87819 --- a/net/ipv6/sysctl_net_ipv6.c
87820 +++ b/net/ipv6/sysctl_net_ipv6.c
87821 @@ -40,7 +40,7 @@ static ctl_table ipv6_rotable[] = {
87822
87823 static int __net_init ipv6_sysctl_net_init(struct net *net)
87824 {
87825 - struct ctl_table *ipv6_table;
87826 + ctl_table_no_const *ipv6_table;
87827 struct ctl_table *ipv6_route_table;
87828 struct ctl_table *ipv6_icmp_table;
87829 int err;
87830 diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
87831 index 0fce928..c52a518 100644
87832 --- a/net/ipv6/tcp_ipv6.c
87833 +++ b/net/ipv6/tcp_ipv6.c
87834 @@ -103,6 +103,10 @@ static void inet6_sk_rx_dst_set(struct sock *sk, const struct sk_buff *skb)
87835 inet6_sk(sk)->rx_dst_cookie = rt->rt6i_node->fn_sernum;
87836 }
87837
87838 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87839 +extern int grsec_enable_blackhole;
87840 +#endif
87841 +
87842 static void tcp_v6_hash(struct sock *sk)
87843 {
87844 if (sk->sk_state != TCP_CLOSE) {
87845 @@ -1446,6 +1450,9 @@ static int tcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb)
87846 return 0;
87847
87848 reset:
87849 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87850 + if (!grsec_enable_blackhole)
87851 +#endif
87852 tcp_v6_send_reset(sk, skb);
87853 discard:
87854 if (opt_skb)
87855 @@ -1527,12 +1534,20 @@ static int tcp_v6_rcv(struct sk_buff *skb)
87856 TCP_SKB_CB(skb)->sacked = 0;
87857
87858 sk = __inet6_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest);
87859 - if (!sk)
87860 + if (!sk) {
87861 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87862 + ret = 1;
87863 +#endif
87864 goto no_tcp_socket;
87865 + }
87866
87867 process:
87868 - if (sk->sk_state == TCP_TIME_WAIT)
87869 + if (sk->sk_state == TCP_TIME_WAIT) {
87870 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87871 + ret = 2;
87872 +#endif
87873 goto do_time_wait;
87874 + }
87875
87876 if (hdr->hop_limit < inet6_sk(sk)->min_hopcount) {
87877 NET_INC_STATS_BH(net, LINUX_MIB_TCPMINTTLDROP);
87878 @@ -1581,6 +1596,10 @@ no_tcp_socket:
87879 bad_packet:
87880 TCP_INC_STATS_BH(net, TCP_MIB_INERRS);
87881 } else {
87882 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87883 + if (!grsec_enable_blackhole || (ret == 1 &&
87884 + (skb->dev->flags & IFF_LOOPBACK)))
87885 +#endif
87886 tcp_v6_send_reset(NULL, skb);
87887 }
87888
87889 diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
87890 index 27f0f8e..949e7ee 100644
87891 --- a/net/ipv6/udp.c
87892 +++ b/net/ipv6/udp.c
87893 @@ -52,6 +52,10 @@
87894 #include <trace/events/skb.h>
87895 #include "udp_impl.h"
87896
87897 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87898 +extern int grsec_enable_blackhole;
87899 +#endif
87900 +
87901 int ipv6_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2)
87902 {
87903 const struct in6_addr *sk_rcv_saddr6 = &inet6_sk(sk)->rcv_saddr;
87904 @@ -419,7 +423,7 @@ try_again:
87905 if (unlikely(err)) {
87906 trace_kfree_skb(skb, udpv6_recvmsg);
87907 if (!peeked) {
87908 - atomic_inc(&sk->sk_drops);
87909 + atomic_inc_unchecked(&sk->sk_drops);
87910 if (is_udp4)
87911 UDP_INC_STATS_USER(sock_net(sk),
87912 UDP_MIB_INERRORS,
87913 @@ -657,7 +661,7 @@ int udpv6_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
87914 return rc;
87915 drop:
87916 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
87917 - atomic_inc(&sk->sk_drops);
87918 + atomic_inc_unchecked(&sk->sk_drops);
87919 kfree_skb(skb);
87920 return -1;
87921 }
87922 @@ -715,7 +719,7 @@ static void flush_stack(struct sock **stack, unsigned int count,
87923 if (likely(skb1 == NULL))
87924 skb1 = (i == final) ? skb : skb_clone(skb, GFP_ATOMIC);
87925 if (!skb1) {
87926 - atomic_inc(&sk->sk_drops);
87927 + atomic_inc_unchecked(&sk->sk_drops);
87928 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_RCVBUFERRORS,
87929 IS_UDPLITE(sk));
87930 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
87931 @@ -852,6 +856,9 @@ int __udp6_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
87932 goto discard;
87933
87934 UDP6_INC_STATS_BH(net, UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE);
87935 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87936 + if (!grsec_enable_blackhole || (skb->dev->flags & IFF_LOOPBACK))
87937 +#endif
87938 icmpv6_send(skb, ICMPV6_DEST_UNREACH, ICMPV6_PORT_UNREACH, 0);
87939
87940 kfree_skb(skb);
87941 @@ -1377,7 +1384,7 @@ static void udp6_sock_seq_show(struct seq_file *seq, struct sock *sp, int bucket
87942 0,
87943 sock_i_ino(sp),
87944 atomic_read(&sp->sk_refcnt), sp,
87945 - atomic_read(&sp->sk_drops));
87946 + atomic_read_unchecked(&sp->sk_drops));
87947 }
87948
87949 int udp6_seq_show(struct seq_file *seq, void *v)
87950 diff --git a/net/ipv6/xfrm6_policy.c b/net/ipv6/xfrm6_policy.c
87951 index 23ed03d..465a71d 100644
87952 --- a/net/ipv6/xfrm6_policy.c
87953 +++ b/net/ipv6/xfrm6_policy.c
87954 @@ -324,19 +324,19 @@ static struct ctl_table xfrm6_policy_table[] = {
87955
87956 static int __net_init xfrm6_net_init(struct net *net)
87957 {
87958 - struct ctl_table *table;
87959 + ctl_table_no_const *table = NULL;
87960 struct ctl_table_header *hdr;
87961
87962 - table = xfrm6_policy_table;
87963 if (!net_eq(net, &init_net)) {
87964 - table = kmemdup(table, sizeof(xfrm6_policy_table), GFP_KERNEL);
87965 + table = kmemdup(xfrm6_policy_table, sizeof(xfrm6_policy_table), GFP_KERNEL);
87966 if (!table)
87967 goto err_alloc;
87968
87969 table[0].data = &net->xfrm.xfrm6_dst_ops.gc_thresh;
87970 - }
87971 + hdr = register_net_sysctl(net, "net/ipv6", table);
87972 + } else
87973 + hdr = register_net_sysctl(net, "net/ipv6", xfrm6_policy_table);
87974
87975 - hdr = register_net_sysctl(net, "net/ipv6", table);
87976 if (!hdr)
87977 goto err_reg;
87978
87979 @@ -344,8 +344,7 @@ static int __net_init xfrm6_net_init(struct net *net)
87980 return 0;
87981
87982 err_reg:
87983 - if (!net_eq(net, &init_net))
87984 - kfree(table);
87985 + kfree(table);
87986 err_alloc:
87987 return -ENOMEM;
87988 }
87989 diff --git a/net/irda/ircomm/ircomm_tty.c b/net/irda/ircomm/ircomm_tty.c
87990 index 362ba47..66196f4 100644
87991 --- a/net/irda/ircomm/ircomm_tty.c
87992 +++ b/net/irda/ircomm/ircomm_tty.c
87993 @@ -319,11 +319,11 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
87994 add_wait_queue(&port->open_wait, &wait);
87995
87996 IRDA_DEBUG(2, "%s(%d):block_til_ready before block on %s open_count=%d\n",
87997 - __FILE__, __LINE__, tty->driver->name, port->count);
87998 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
87999
88000 spin_lock_irqsave(&port->lock, flags);
88001 if (!tty_hung_up_p(filp))
88002 - port->count--;
88003 + atomic_dec(&port->count);
88004 port->blocked_open++;
88005 spin_unlock_irqrestore(&port->lock, flags);
88006
88007 @@ -358,7 +358,7 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
88008 }
88009
88010 IRDA_DEBUG(1, "%s(%d):block_til_ready blocking on %s open_count=%d\n",
88011 - __FILE__, __LINE__, tty->driver->name, port->count);
88012 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
88013
88014 schedule();
88015 }
88016 @@ -368,12 +368,12 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
88017
88018 spin_lock_irqsave(&port->lock, flags);
88019 if (!tty_hung_up_p(filp))
88020 - port->count++;
88021 + atomic_inc(&port->count);
88022 port->blocked_open--;
88023 spin_unlock_irqrestore(&port->lock, flags);
88024
88025 IRDA_DEBUG(1, "%s(%d):block_til_ready after blocking on %s open_count=%d\n",
88026 - __FILE__, __LINE__, tty->driver->name, port->count);
88027 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
88028
88029 if (!retval)
88030 port->flags |= ASYNC_NORMAL_ACTIVE;
88031 @@ -447,12 +447,12 @@ static int ircomm_tty_open(struct tty_struct *tty, struct file *filp)
88032
88033 /* ++ is not atomic, so this should be protected - Jean II */
88034 spin_lock_irqsave(&self->port.lock, flags);
88035 - self->port.count++;
88036 + atomic_inc(&self->port.count);
88037 spin_unlock_irqrestore(&self->port.lock, flags);
88038 tty_port_tty_set(&self->port, tty);
88039
88040 IRDA_DEBUG(1, "%s(), %s%d, count = %d\n", __func__ , tty->driver->name,
88041 - self->line, self->port.count);
88042 + self->line, atomic_read(&self->port.count));
88043
88044 /* Not really used by us, but lets do it anyway */
88045 self->port.low_latency = (self->port.flags & ASYNC_LOW_LATENCY) ? 1 : 0;
88046 @@ -989,7 +989,7 @@ static void ircomm_tty_hangup(struct tty_struct *tty)
88047 tty_kref_put(port->tty);
88048 }
88049 port->tty = NULL;
88050 - port->count = 0;
88051 + atomic_set(&port->count, 0);
88052 spin_unlock_irqrestore(&port->lock, flags);
88053
88054 wake_up_interruptible(&port->open_wait);
88055 @@ -1346,7 +1346,7 @@ static void ircomm_tty_line_info(struct ircomm_tty_cb *self, struct seq_file *m)
88056 seq_putc(m, '\n');
88057
88058 seq_printf(m, "Role: %s\n", self->client ? "client" : "server");
88059 - seq_printf(m, "Open count: %d\n", self->port.count);
88060 + seq_printf(m, "Open count: %d\n", atomic_read(&self->port.count));
88061 seq_printf(m, "Max data size: %d\n", self->max_data_size);
88062 seq_printf(m, "Max header size: %d\n", self->max_header_size);
88063
88064 diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c
88065 index 206ce6d..cfb27cd 100644
88066 --- a/net/iucv/af_iucv.c
88067 +++ b/net/iucv/af_iucv.c
88068 @@ -773,10 +773,10 @@ static int iucv_sock_autobind(struct sock *sk)
88069
88070 write_lock_bh(&iucv_sk_list.lock);
88071
88072 - sprintf(name, "%08x", atomic_inc_return(&iucv_sk_list.autobind_name));
88073 + sprintf(name, "%08x", atomic_inc_return_unchecked(&iucv_sk_list.autobind_name));
88074 while (__iucv_get_sock_by_name(name)) {
88075 sprintf(name, "%08x",
88076 - atomic_inc_return(&iucv_sk_list.autobind_name));
88077 + atomic_inc_return_unchecked(&iucv_sk_list.autobind_name));
88078 }
88079
88080 write_unlock_bh(&iucv_sk_list.lock);
88081 diff --git a/net/iucv/iucv.c b/net/iucv/iucv.c
88082 index 4fe76ff..426a904 100644
88083 --- a/net/iucv/iucv.c
88084 +++ b/net/iucv/iucv.c
88085 @@ -690,7 +690,7 @@ static int __cpuinit iucv_cpu_notify(struct notifier_block *self,
88086 return NOTIFY_OK;
88087 }
88088
88089 -static struct notifier_block __refdata iucv_cpu_notifier = {
88090 +static struct notifier_block iucv_cpu_notifier = {
88091 .notifier_call = iucv_cpu_notify,
88092 };
88093
88094 diff --git a/net/key/af_key.c b/net/key/af_key.c
88095 index 5b1e5af..2358147 100644
88096 --- a/net/key/af_key.c
88097 +++ b/net/key/af_key.c
88098 @@ -3041,10 +3041,10 @@ static int pfkey_send_policy_notify(struct xfrm_policy *xp, int dir, const struc
88099 static u32 get_acqseq(void)
88100 {
88101 u32 res;
88102 - static atomic_t acqseq;
88103 + static atomic_unchecked_t acqseq;
88104
88105 do {
88106 - res = atomic_inc_return(&acqseq);
88107 + res = atomic_inc_return_unchecked(&acqseq);
88108 } while (!res);
88109 return res;
88110 }
88111 diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
88112 index 843d8c4..cb04fa1 100644
88113 --- a/net/mac80211/cfg.c
88114 +++ b/net/mac80211/cfg.c
88115 @@ -799,7 +799,7 @@ static int ieee80211_set_monitor_channel(struct wiphy *wiphy,
88116 ret = ieee80211_vif_use_channel(sdata, chandef,
88117 IEEE80211_CHANCTX_EXCLUSIVE);
88118 }
88119 - } else if (local->open_count == local->monitors) {
88120 + } else if (local_read(&local->open_count) == local->monitors) {
88121 local->_oper_channel = chandef->chan;
88122 local->_oper_channel_type = cfg80211_get_chandef_type(chandef);
88123 ieee80211_hw_config(local, 0);
88124 @@ -2834,7 +2834,7 @@ static void ieee80211_mgmt_frame_register(struct wiphy *wiphy,
88125 else
88126 local->probe_req_reg--;
88127
88128 - if (!local->open_count)
88129 + if (!local_read(&local->open_count))
88130 break;
88131
88132 ieee80211_queue_work(&local->hw, &local->reconfig_filter);
88133 @@ -3297,8 +3297,8 @@ static int ieee80211_cfg_get_channel(struct wiphy *wiphy,
88134 if (chanctx_conf) {
88135 *chandef = chanctx_conf->def;
88136 ret = 0;
88137 - } else if (local->open_count > 0 &&
88138 - local->open_count == local->monitors &&
88139 + } else if (local_read(&local->open_count) > 0 &&
88140 + local_read(&local->open_count) == local->monitors &&
88141 sdata->vif.type == NL80211_IFTYPE_MONITOR) {
88142 if (local->use_chanctx)
88143 *chandef = local->monitor_chandef;
88144 diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
88145 index 5672533..6738c93 100644
88146 --- a/net/mac80211/ieee80211_i.h
88147 +++ b/net/mac80211/ieee80211_i.h
88148 @@ -28,6 +28,7 @@
88149 #include <net/ieee80211_radiotap.h>
88150 #include <net/cfg80211.h>
88151 #include <net/mac80211.h>
88152 +#include <asm/local.h>
88153 #include "key.h"
88154 #include "sta_info.h"
88155 #include "debug.h"
88156 @@ -897,7 +898,7 @@ struct ieee80211_local {
88157 /* also used to protect ampdu_ac_queue and amdpu_ac_stop_refcnt */
88158 spinlock_t queue_stop_reason_lock;
88159
88160 - int open_count;
88161 + local_t open_count;
88162 int monitors, cooked_mntrs;
88163 /* number of interfaces with corresponding FIF_ flags */
88164 int fif_fcsfail, fif_plcpfail, fif_control, fif_other_bss, fif_pspoll,
88165 diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
88166 index d51ca9d..042c35f 100644
88167 --- a/net/mac80211/iface.c
88168 +++ b/net/mac80211/iface.c
88169 @@ -495,7 +495,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
88170 break;
88171 }
88172
88173 - if (local->open_count == 0) {
88174 + if (local_read(&local->open_count) == 0) {
88175 res = drv_start(local);
88176 if (res)
88177 goto err_del_bss;
88178 @@ -540,7 +540,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
88179 break;
88180 }
88181
88182 - if (local->monitors == 0 && local->open_count == 0) {
88183 + if (local->monitors == 0 && local_read(&local->open_count) == 0) {
88184 res = ieee80211_add_virtual_monitor(local);
88185 if (res)
88186 goto err_stop;
88187 @@ -649,7 +649,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
88188 atomic_inc(&local->iff_promiscs);
88189
88190 if (coming_up)
88191 - local->open_count++;
88192 + local_inc(&local->open_count);
88193
88194 if (hw_reconf_flags)
88195 ieee80211_hw_config(local, hw_reconf_flags);
88196 @@ -663,7 +663,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
88197 err_del_interface:
88198 drv_remove_interface(local, sdata);
88199 err_stop:
88200 - if (!local->open_count)
88201 + if (!local_read(&local->open_count))
88202 drv_stop(local);
88203 err_del_bss:
88204 sdata->bss = NULL;
88205 @@ -806,7 +806,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
88206 }
88207
88208 if (going_down)
88209 - local->open_count--;
88210 + local_dec(&local->open_count);
88211
88212 switch (sdata->vif.type) {
88213 case NL80211_IFTYPE_AP_VLAN:
88214 @@ -871,7 +871,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
88215
88216 ieee80211_recalc_ps(local, -1);
88217
88218 - if (local->open_count == 0) {
88219 + if (local_read(&local->open_count) == 0) {
88220 if (local->ops->napi_poll)
88221 napi_disable(&local->napi);
88222 ieee80211_clear_tx_pending(local);
88223 @@ -897,7 +897,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
88224 }
88225 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags);
88226
88227 - if (local->monitors == local->open_count && local->monitors > 0)
88228 + if (local->monitors == local_read(&local->open_count) && local->monitors > 0)
88229 ieee80211_add_virtual_monitor(local);
88230 }
88231
88232 diff --git a/net/mac80211/main.c b/net/mac80211/main.c
88233 index 1a8591b..ef5db54 100644
88234 --- a/net/mac80211/main.c
88235 +++ b/net/mac80211/main.c
88236 @@ -180,7 +180,7 @@ int ieee80211_hw_config(struct ieee80211_local *local, u32 changed)
88237 changed &= ~(IEEE80211_CONF_CHANGE_CHANNEL |
88238 IEEE80211_CONF_CHANGE_POWER);
88239
88240 - if (changed && local->open_count) {
88241 + if (changed && local_read(&local->open_count)) {
88242 ret = drv_config(local, changed);
88243 /*
88244 * Goal:
88245 diff --git a/net/mac80211/pm.c b/net/mac80211/pm.c
88246 index 835584c..be46e67 100644
88247 --- a/net/mac80211/pm.c
88248 +++ b/net/mac80211/pm.c
88249 @@ -33,7 +33,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
88250 struct sta_info *sta;
88251 struct ieee80211_chanctx *ctx;
88252
88253 - if (!local->open_count)
88254 + if (!local_read(&local->open_count))
88255 goto suspend;
88256
88257 ieee80211_scan_cancel(local);
88258 @@ -75,7 +75,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
88259 cancel_work_sync(&local->dynamic_ps_enable_work);
88260 del_timer_sync(&local->dynamic_ps_timer);
88261
88262 - local->wowlan = wowlan && local->open_count;
88263 + local->wowlan = wowlan && local_read(&local->open_count);
88264 if (local->wowlan) {
88265 int err = drv_suspend(local, wowlan);
88266 if (err < 0) {
88267 @@ -214,7 +214,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
88268 mutex_unlock(&local->chanctx_mtx);
88269
88270 /* stop hardware - this must stop RX */
88271 - if (local->open_count)
88272 + if (local_read(&local->open_count))
88273 ieee80211_stop_device(local);
88274
88275 suspend:
88276 diff --git a/net/mac80211/rate.c b/net/mac80211/rate.c
88277 index dd88381..eef4dd6 100644
88278 --- a/net/mac80211/rate.c
88279 +++ b/net/mac80211/rate.c
88280 @@ -493,7 +493,7 @@ int ieee80211_init_rate_ctrl_alg(struct ieee80211_local *local,
88281
88282 ASSERT_RTNL();
88283
88284 - if (local->open_count)
88285 + if (local_read(&local->open_count))
88286 return -EBUSY;
88287
88288 if (local->hw.flags & IEEE80211_HW_HAS_RATE_CONTROL) {
88289 diff --git a/net/mac80211/rc80211_pid_debugfs.c b/net/mac80211/rc80211_pid_debugfs.c
88290 index c97a065..ff61928 100644
88291 --- a/net/mac80211/rc80211_pid_debugfs.c
88292 +++ b/net/mac80211/rc80211_pid_debugfs.c
88293 @@ -193,7 +193,7 @@ static ssize_t rate_control_pid_events_read(struct file *file, char __user *buf,
88294
88295 spin_unlock_irqrestore(&events->lock, status);
88296
88297 - if (copy_to_user(buf, pb, p))
88298 + if (p > sizeof(pb) || copy_to_user(buf, pb, p))
88299 return -EFAULT;
88300
88301 return p;
88302 diff --git a/net/mac80211/util.c b/net/mac80211/util.c
88303 index 0f38f43..e53d4a8 100644
88304 --- a/net/mac80211/util.c
88305 +++ b/net/mac80211/util.c
88306 @@ -1388,7 +1388,7 @@ int ieee80211_reconfig(struct ieee80211_local *local)
88307 }
88308 #endif
88309 /* everything else happens only if HW was up & running */
88310 - if (!local->open_count)
88311 + if (!local_read(&local->open_count))
88312 goto wake_up;
88313
88314 /*
88315 diff --git a/net/netfilter/Kconfig b/net/netfilter/Kconfig
88316 index 56d22ca..87c778f 100644
88317 --- a/net/netfilter/Kconfig
88318 +++ b/net/netfilter/Kconfig
88319 @@ -958,6 +958,16 @@ config NETFILTER_XT_MATCH_ESP
88320
88321 To compile it as a module, choose M here. If unsure, say N.
88322
88323 +config NETFILTER_XT_MATCH_GRADM
88324 + tristate '"gradm" match support'
88325 + depends on NETFILTER_XTABLES && NETFILTER_ADVANCED
88326 + depends on GRKERNSEC && !GRKERNSEC_NO_RBAC
88327 + ---help---
88328 + The gradm match allows to match on grsecurity RBAC being enabled.
88329 + It is useful when iptables rules are applied early on bootup to
88330 + prevent connections to the machine (except from a trusted host)
88331 + while the RBAC system is disabled.
88332 +
88333 config NETFILTER_XT_MATCH_HASHLIMIT
88334 tristate '"hashlimit" match support'
88335 depends on (IP6_NF_IPTABLES || IP6_NF_IPTABLES=n)
88336 diff --git a/net/netfilter/Makefile b/net/netfilter/Makefile
88337 index a1abf87..dbcb7ee 100644
88338 --- a/net/netfilter/Makefile
88339 +++ b/net/netfilter/Makefile
88340 @@ -112,6 +112,7 @@ obj-$(CONFIG_NETFILTER_XT_MATCH_DEVGROUP) += xt_devgroup.o
88341 obj-$(CONFIG_NETFILTER_XT_MATCH_DSCP) += xt_dscp.o
88342 obj-$(CONFIG_NETFILTER_XT_MATCH_ECN) += xt_ecn.o
88343 obj-$(CONFIG_NETFILTER_XT_MATCH_ESP) += xt_esp.o
88344 +obj-$(CONFIG_NETFILTER_XT_MATCH_GRADM) += xt_gradm.o
88345 obj-$(CONFIG_NETFILTER_XT_MATCH_HASHLIMIT) += xt_hashlimit.o
88346 obj-$(CONFIG_NETFILTER_XT_MATCH_HELPER) += xt_helper.o
88347 obj-$(CONFIG_NETFILTER_XT_MATCH_HL) += xt_hl.o
88348 diff --git a/net/netfilter/ipset/ip_set_core.c b/net/netfilter/ipset/ip_set_core.c
88349 index 1ba9dbc..e39f4ca 100644
88350 --- a/net/netfilter/ipset/ip_set_core.c
88351 +++ b/net/netfilter/ipset/ip_set_core.c
88352 @@ -1801,7 +1801,7 @@ done:
88353 return ret;
88354 }
88355
88356 -static struct nf_sockopt_ops so_set __read_mostly = {
88357 +static struct nf_sockopt_ops so_set = {
88358 .pf = PF_INET,
88359 .get_optmin = SO_IP_SET,
88360 .get_optmax = SO_IP_SET + 1,
88361 diff --git a/net/netfilter/ipvs/ip_vs_conn.c b/net/netfilter/ipvs/ip_vs_conn.c
88362 index 704e514..d644cc2 100644
88363 --- a/net/netfilter/ipvs/ip_vs_conn.c
88364 +++ b/net/netfilter/ipvs/ip_vs_conn.c
88365 @@ -551,7 +551,7 @@ ip_vs_bind_dest(struct ip_vs_conn *cp, struct ip_vs_dest *dest)
88366 /* Increase the refcnt counter of the dest */
88367 atomic_inc(&dest->refcnt);
88368
88369 - conn_flags = atomic_read(&dest->conn_flags);
88370 + conn_flags = atomic_read_unchecked(&dest->conn_flags);
88371 if (cp->protocol != IPPROTO_UDP)
88372 conn_flags &= ~IP_VS_CONN_F_ONE_PACKET;
88373 flags = cp->flags;
88374 @@ -895,7 +895,7 @@ ip_vs_conn_new(const struct ip_vs_conn_param *p,
88375 atomic_set(&cp->refcnt, 1);
88376
88377 atomic_set(&cp->n_control, 0);
88378 - atomic_set(&cp->in_pkts, 0);
88379 + atomic_set_unchecked(&cp->in_pkts, 0);
88380
88381 atomic_inc(&ipvs->conn_count);
88382 if (flags & IP_VS_CONN_F_NO_CPORT)
88383 @@ -1174,7 +1174,7 @@ static inline int todrop_entry(struct ip_vs_conn *cp)
88384
88385 /* Don't drop the entry if its number of incoming packets is not
88386 located in [0, 8] */
88387 - i = atomic_read(&cp->in_pkts);
88388 + i = atomic_read_unchecked(&cp->in_pkts);
88389 if (i > 8 || i < 0) return 0;
88390
88391 if (!todrop_rate[i]) return 0;
88392 diff --git a/net/netfilter/ipvs/ip_vs_core.c b/net/netfilter/ipvs/ip_vs_core.c
88393 index 61f49d2..6c8c5bc 100644
88394 --- a/net/netfilter/ipvs/ip_vs_core.c
88395 +++ b/net/netfilter/ipvs/ip_vs_core.c
88396 @@ -559,7 +559,7 @@ int ip_vs_leave(struct ip_vs_service *svc, struct sk_buff *skb,
88397 ret = cp->packet_xmit(skb, cp, pd->pp, iph);
88398 /* do not touch skb anymore */
88399
88400 - atomic_inc(&cp->in_pkts);
88401 + atomic_inc_unchecked(&cp->in_pkts);
88402 ip_vs_conn_put(cp);
88403 return ret;
88404 }
88405 @@ -1689,7 +1689,7 @@ ip_vs_in(unsigned int hooknum, struct sk_buff *skb, int af)
88406 if (cp->flags & IP_VS_CONN_F_ONE_PACKET)
88407 pkts = sysctl_sync_threshold(ipvs);
88408 else
88409 - pkts = atomic_add_return(1, &cp->in_pkts);
88410 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
88411
88412 if (ipvs->sync_state & IP_VS_STATE_MASTER)
88413 ip_vs_sync_conn(net, cp, pkts);
88414 diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c
88415 index 9e2d1cc..7f8f569 100644
88416 --- a/net/netfilter/ipvs/ip_vs_ctl.c
88417 +++ b/net/netfilter/ipvs/ip_vs_ctl.c
88418 @@ -787,7 +787,7 @@ __ip_vs_update_dest(struct ip_vs_service *svc, struct ip_vs_dest *dest,
88419 ip_vs_rs_hash(ipvs, dest);
88420 write_unlock_bh(&ipvs->rs_lock);
88421 }
88422 - atomic_set(&dest->conn_flags, conn_flags);
88423 + atomic_set_unchecked(&dest->conn_flags, conn_flags);
88424
88425 /* bind the service */
88426 if (!dest->svc) {
88427 @@ -1688,7 +1688,7 @@ proc_do_sync_ports(ctl_table *table, int write,
88428 * align with netns init in ip_vs_control_net_init()
88429 */
88430
88431 -static struct ctl_table vs_vars[] = {
88432 +static ctl_table_no_const vs_vars[] __read_only = {
88433 {
88434 .procname = "amemthresh",
88435 .maxlen = sizeof(int),
88436 @@ -2087,7 +2087,7 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)
88437 " %-7s %-6d %-10d %-10d\n",
88438 &dest->addr.in6,
88439 ntohs(dest->port),
88440 - ip_vs_fwd_name(atomic_read(&dest->conn_flags)),
88441 + ip_vs_fwd_name(atomic_read_unchecked(&dest->conn_flags)),
88442 atomic_read(&dest->weight),
88443 atomic_read(&dest->activeconns),
88444 atomic_read(&dest->inactconns));
88445 @@ -2098,7 +2098,7 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)
88446 "%-7s %-6d %-10d %-10d\n",
88447 ntohl(dest->addr.ip),
88448 ntohs(dest->port),
88449 - ip_vs_fwd_name(atomic_read(&dest->conn_flags)),
88450 + ip_vs_fwd_name(atomic_read_unchecked(&dest->conn_flags)),
88451 atomic_read(&dest->weight),
88452 atomic_read(&dest->activeconns),
88453 atomic_read(&dest->inactconns));
88454 @@ -2568,7 +2568,7 @@ __ip_vs_get_dest_entries(struct net *net, const struct ip_vs_get_dests *get,
88455
88456 entry.addr = dest->addr.ip;
88457 entry.port = dest->port;
88458 - entry.conn_flags = atomic_read(&dest->conn_flags);
88459 + entry.conn_flags = atomic_read_unchecked(&dest->conn_flags);
88460 entry.weight = atomic_read(&dest->weight);
88461 entry.u_threshold = dest->u_threshold;
88462 entry.l_threshold = dest->l_threshold;
88463 @@ -3104,7 +3104,7 @@ static int ip_vs_genl_fill_dest(struct sk_buff *skb, struct ip_vs_dest *dest)
88464 if (nla_put(skb, IPVS_DEST_ATTR_ADDR, sizeof(dest->addr), &dest->addr) ||
88465 nla_put_u16(skb, IPVS_DEST_ATTR_PORT, dest->port) ||
88466 nla_put_u32(skb, IPVS_DEST_ATTR_FWD_METHOD,
88467 - (atomic_read(&dest->conn_flags) &
88468 + (atomic_read_unchecked(&dest->conn_flags) &
88469 IP_VS_CONN_F_FWD_MASK)) ||
88470 nla_put_u32(skb, IPVS_DEST_ATTR_WEIGHT,
88471 atomic_read(&dest->weight)) ||
88472 @@ -3694,7 +3694,7 @@ static int __net_init ip_vs_control_net_init_sysctl(struct net *net)
88473 {
88474 int idx;
88475 struct netns_ipvs *ipvs = net_ipvs(net);
88476 - struct ctl_table *tbl;
88477 + ctl_table_no_const *tbl;
88478
88479 atomic_set(&ipvs->dropentry, 0);
88480 spin_lock_init(&ipvs->dropentry_lock);
88481 diff --git a/net/netfilter/ipvs/ip_vs_lblc.c b/net/netfilter/ipvs/ip_vs_lblc.c
88482 index fdd89b9..bd96aa9 100644
88483 --- a/net/netfilter/ipvs/ip_vs_lblc.c
88484 +++ b/net/netfilter/ipvs/ip_vs_lblc.c
88485 @@ -115,7 +115,7 @@ struct ip_vs_lblc_table {
88486 * IPVS LBLC sysctl table
88487 */
88488 #ifdef CONFIG_SYSCTL
88489 -static ctl_table vs_vars_table[] = {
88490 +static ctl_table_no_const vs_vars_table[] __read_only = {
88491 {
88492 .procname = "lblc_expiration",
88493 .data = NULL,
88494 diff --git a/net/netfilter/ipvs/ip_vs_lblcr.c b/net/netfilter/ipvs/ip_vs_lblcr.c
88495 index c03b6a3..8ce3681 100644
88496 --- a/net/netfilter/ipvs/ip_vs_lblcr.c
88497 +++ b/net/netfilter/ipvs/ip_vs_lblcr.c
88498 @@ -288,7 +288,7 @@ struct ip_vs_lblcr_table {
88499 * IPVS LBLCR sysctl table
88500 */
88501
88502 -static ctl_table vs_vars_table[] = {
88503 +static ctl_table_no_const vs_vars_table[] __read_only = {
88504 {
88505 .procname = "lblcr_expiration",
88506 .data = NULL,
88507 diff --git a/net/netfilter/ipvs/ip_vs_sync.c b/net/netfilter/ipvs/ip_vs_sync.c
88508 index 44fd10c..2a163b3 100644
88509 --- a/net/netfilter/ipvs/ip_vs_sync.c
88510 +++ b/net/netfilter/ipvs/ip_vs_sync.c
88511 @@ -596,7 +596,7 @@ static void ip_vs_sync_conn_v0(struct net *net, struct ip_vs_conn *cp,
88512 cp = cp->control;
88513 if (cp) {
88514 if (cp->flags & IP_VS_CONN_F_TEMPLATE)
88515 - pkts = atomic_add_return(1, &cp->in_pkts);
88516 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
88517 else
88518 pkts = sysctl_sync_threshold(ipvs);
88519 ip_vs_sync_conn(net, cp->control, pkts);
88520 @@ -758,7 +758,7 @@ control:
88521 if (!cp)
88522 return;
88523 if (cp->flags & IP_VS_CONN_F_TEMPLATE)
88524 - pkts = atomic_add_return(1, &cp->in_pkts);
88525 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
88526 else
88527 pkts = sysctl_sync_threshold(ipvs);
88528 goto sloop;
88529 @@ -885,7 +885,7 @@ static void ip_vs_proc_conn(struct net *net, struct ip_vs_conn_param *param,
88530
88531 if (opt)
88532 memcpy(&cp->in_seq, opt, sizeof(*opt));
88533 - atomic_set(&cp->in_pkts, sysctl_sync_threshold(ipvs));
88534 + atomic_set_unchecked(&cp->in_pkts, sysctl_sync_threshold(ipvs));
88535 cp->state = state;
88536 cp->old_state = cp->state;
88537 /*
88538 diff --git a/net/netfilter/ipvs/ip_vs_xmit.c b/net/netfilter/ipvs/ip_vs_xmit.c
88539 index ee6b7a9..f9a89f6 100644
88540 --- a/net/netfilter/ipvs/ip_vs_xmit.c
88541 +++ b/net/netfilter/ipvs/ip_vs_xmit.c
88542 @@ -1210,7 +1210,7 @@ ip_vs_icmp_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,
88543 else
88544 rc = NF_ACCEPT;
88545 /* do not touch skb anymore */
88546 - atomic_inc(&cp->in_pkts);
88547 + atomic_inc_unchecked(&cp->in_pkts);
88548 goto out;
88549 }
88550
88551 @@ -1332,7 +1332,7 @@ ip_vs_icmp_xmit_v6(struct sk_buff *skb, struct ip_vs_conn *cp,
88552 else
88553 rc = NF_ACCEPT;
88554 /* do not touch skb anymore */
88555 - atomic_inc(&cp->in_pkts);
88556 + atomic_inc_unchecked(&cp->in_pkts);
88557 goto out;
88558 }
88559
88560 diff --git a/net/netfilter/nf_conntrack_acct.c b/net/netfilter/nf_conntrack_acct.c
88561 index 2d3030a..7ba1c0a 100644
88562 --- a/net/netfilter/nf_conntrack_acct.c
88563 +++ b/net/netfilter/nf_conntrack_acct.c
88564 @@ -60,7 +60,7 @@ static struct nf_ct_ext_type acct_extend __read_mostly = {
88565 #ifdef CONFIG_SYSCTL
88566 static int nf_conntrack_acct_init_sysctl(struct net *net)
88567 {
88568 - struct ctl_table *table;
88569 + ctl_table_no_const *table;
88570
88571 table = kmemdup(acct_sysctl_table, sizeof(acct_sysctl_table),
88572 GFP_KERNEL);
88573 diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
88574 index c8e001a..f842a8b 100644
88575 --- a/net/netfilter/nf_conntrack_core.c
88576 +++ b/net/netfilter/nf_conntrack_core.c
88577 @@ -1594,6 +1594,10 @@ void nf_conntrack_init_end(void)
88578 #define DYING_NULLS_VAL ((1<<30)+1)
88579 #define TEMPLATE_NULLS_VAL ((1<<30)+2)
88580
88581 +#ifdef CONFIG_GRKERNSEC_HIDESYM
88582 +static atomic_unchecked_t conntrack_cache_id = ATOMIC_INIT(0);
88583 +#endif
88584 +
88585 int nf_conntrack_init_net(struct net *net)
88586 {
88587 int ret;
88588 @@ -1608,7 +1612,11 @@ int nf_conntrack_init_net(struct net *net)
88589 goto err_stat;
88590 }
88591
88592 +#ifdef CONFIG_GRKERNSEC_HIDESYM
88593 + net->ct.slabname = kasprintf(GFP_KERNEL, "nf_conntrack_%08lx", atomic_inc_return_unchecked(&conntrack_cache_id));
88594 +#else
88595 net->ct.slabname = kasprintf(GFP_KERNEL, "nf_conntrack_%p", net);
88596 +#endif
88597 if (!net->ct.slabname) {
88598 ret = -ENOMEM;
88599 goto err_slabname;
88600 diff --git a/net/netfilter/nf_conntrack_ecache.c b/net/netfilter/nf_conntrack_ecache.c
88601 index b5d2eb8..61ef19a 100644
88602 --- a/net/netfilter/nf_conntrack_ecache.c
88603 +++ b/net/netfilter/nf_conntrack_ecache.c
88604 @@ -186,7 +186,7 @@ static struct nf_ct_ext_type event_extend __read_mostly = {
88605 #ifdef CONFIG_SYSCTL
88606 static int nf_conntrack_event_init_sysctl(struct net *net)
88607 {
88608 - struct ctl_table *table;
88609 + ctl_table_no_const *table;
88610
88611 table = kmemdup(event_sysctl_table, sizeof(event_sysctl_table),
88612 GFP_KERNEL);
88613 diff --git a/net/netfilter/nf_conntrack_helper.c b/net/netfilter/nf_conntrack_helper.c
88614 index 94b4b98..97cf0ad 100644
88615 --- a/net/netfilter/nf_conntrack_helper.c
88616 +++ b/net/netfilter/nf_conntrack_helper.c
88617 @@ -56,7 +56,7 @@ static struct ctl_table helper_sysctl_table[] = {
88618
88619 static int nf_conntrack_helper_init_sysctl(struct net *net)
88620 {
88621 - struct ctl_table *table;
88622 + ctl_table_no_const *table;
88623
88624 table = kmemdup(helper_sysctl_table, sizeof(helper_sysctl_table),
88625 GFP_KERNEL);
88626 diff --git a/net/netfilter/nf_conntrack_proto.c b/net/netfilter/nf_conntrack_proto.c
88627 index 58ab405..50eb8d3 100644
88628 --- a/net/netfilter/nf_conntrack_proto.c
88629 +++ b/net/netfilter/nf_conntrack_proto.c
88630 @@ -51,7 +51,7 @@ nf_ct_register_sysctl(struct net *net,
88631
88632 static void
88633 nf_ct_unregister_sysctl(struct ctl_table_header **header,
88634 - struct ctl_table **table,
88635 + ctl_table_no_const **table,
88636 unsigned int users)
88637 {
88638 if (users > 0)
88639 diff --git a/net/netfilter/nf_conntrack_standalone.c b/net/netfilter/nf_conntrack_standalone.c
88640 index fedee39..d62a93d 100644
88641 --- a/net/netfilter/nf_conntrack_standalone.c
88642 +++ b/net/netfilter/nf_conntrack_standalone.c
88643 @@ -470,7 +470,7 @@ static ctl_table nf_ct_netfilter_table[] = {
88644
88645 static int nf_conntrack_standalone_init_sysctl(struct net *net)
88646 {
88647 - struct ctl_table *table;
88648 + ctl_table_no_const *table;
88649
88650 table = kmemdup(nf_ct_sysctl_table, sizeof(nf_ct_sysctl_table),
88651 GFP_KERNEL);
88652 diff --git a/net/netfilter/nf_conntrack_timestamp.c b/net/netfilter/nf_conntrack_timestamp.c
88653 index 902fb0a..87f7fdb 100644
88654 --- a/net/netfilter/nf_conntrack_timestamp.c
88655 +++ b/net/netfilter/nf_conntrack_timestamp.c
88656 @@ -42,7 +42,7 @@ static struct nf_ct_ext_type tstamp_extend __read_mostly = {
88657 #ifdef CONFIG_SYSCTL
88658 static int nf_conntrack_tstamp_init_sysctl(struct net *net)
88659 {
88660 - struct ctl_table *table;
88661 + ctl_table_no_const *table;
88662
88663 table = kmemdup(tstamp_sysctl_table, sizeof(tstamp_sysctl_table),
88664 GFP_KERNEL);
88665 diff --git a/net/netfilter/nf_log.c b/net/netfilter/nf_log.c
88666 index 9e31269..bc4c1b7 100644
88667 --- a/net/netfilter/nf_log.c
88668 +++ b/net/netfilter/nf_log.c
88669 @@ -215,7 +215,7 @@ static const struct file_operations nflog_file_ops = {
88670
88671 #ifdef CONFIG_SYSCTL
88672 static char nf_log_sysctl_fnames[NFPROTO_NUMPROTO-NFPROTO_UNSPEC][3];
88673 -static struct ctl_table nf_log_sysctl_table[NFPROTO_NUMPROTO+1];
88674 +static ctl_table_no_const nf_log_sysctl_table[NFPROTO_NUMPROTO+1] __read_only;
88675 static struct ctl_table_header *nf_log_dir_header;
88676
88677 static int nf_log_proc_dostring(ctl_table *table, int write,
88678 @@ -246,14 +246,16 @@ static int nf_log_proc_dostring(ctl_table *table, int write,
88679 rcu_assign_pointer(nf_loggers[tindex], logger);
88680 mutex_unlock(&nf_log_mutex);
88681 } else {
88682 + ctl_table_no_const nf_log_table = *table;
88683 +
88684 mutex_lock(&nf_log_mutex);
88685 logger = rcu_dereference_protected(nf_loggers[tindex],
88686 lockdep_is_held(&nf_log_mutex));
88687 if (!logger)
88688 - table->data = "NONE";
88689 + nf_log_table.data = "NONE";
88690 else
88691 - table->data = logger->name;
88692 - r = proc_dostring(table, write, buffer, lenp, ppos);
88693 + nf_log_table.data = logger->name;
88694 + r = proc_dostring(&nf_log_table, write, buffer, lenp, ppos);
88695 mutex_unlock(&nf_log_mutex);
88696 }
88697
88698 diff --git a/net/netfilter/nf_sockopt.c b/net/netfilter/nf_sockopt.c
88699 index f042ae5..30ea486 100644
88700 --- a/net/netfilter/nf_sockopt.c
88701 +++ b/net/netfilter/nf_sockopt.c
88702 @@ -45,7 +45,7 @@ int nf_register_sockopt(struct nf_sockopt_ops *reg)
88703 }
88704 }
88705
88706 - list_add(&reg->list, &nf_sockopts);
88707 + pax_list_add((struct list_head *)&reg->list, &nf_sockopts);
88708 out:
88709 mutex_unlock(&nf_sockopt_mutex);
88710 return ret;
88711 @@ -55,7 +55,7 @@ EXPORT_SYMBOL(nf_register_sockopt);
88712 void nf_unregister_sockopt(struct nf_sockopt_ops *reg)
88713 {
88714 mutex_lock(&nf_sockopt_mutex);
88715 - list_del(&reg->list);
88716 + pax_list_del((struct list_head *)&reg->list);
88717 mutex_unlock(&nf_sockopt_mutex);
88718 }
88719 EXPORT_SYMBOL(nf_unregister_sockopt);
88720 diff --git a/net/netfilter/nfnetlink_log.c b/net/netfilter/nfnetlink_log.c
88721 index f248db5..3778ad9 100644
88722 --- a/net/netfilter/nfnetlink_log.c
88723 +++ b/net/netfilter/nfnetlink_log.c
88724 @@ -72,7 +72,7 @@ struct nfulnl_instance {
88725 };
88726
88727 static DEFINE_SPINLOCK(instances_lock);
88728 -static atomic_t global_seq;
88729 +static atomic_unchecked_t global_seq;
88730
88731 #define INSTANCE_BUCKETS 16
88732 static struct hlist_head instance_table[INSTANCE_BUCKETS];
88733 @@ -536,7 +536,7 @@ __build_packet_message(struct nfulnl_instance *inst,
88734 /* global sequence number */
88735 if ((inst->flags & NFULNL_CFG_F_SEQ_GLOBAL) &&
88736 nla_put_be32(inst->skb, NFULA_SEQ_GLOBAL,
88737 - htonl(atomic_inc_return(&global_seq))))
88738 + htonl(atomic_inc_return_unchecked(&global_seq))))
88739 goto nla_put_failure;
88740
88741 if (data_len) {
88742 diff --git a/net/netfilter/xt_gradm.c b/net/netfilter/xt_gradm.c
88743 new file mode 100644
88744 index 0000000..c566332
88745 --- /dev/null
88746 +++ b/net/netfilter/xt_gradm.c
88747 @@ -0,0 +1,51 @@
88748 +/*
88749 + * gradm match for netfilter
88750 + * Copyright © Zbigniew Krzystolik, 2010
88751 + *
88752 + * This program is free software; you can redistribute it and/or modify
88753 + * it under the terms of the GNU General Public License; either version
88754 + * 2 or 3 as published by the Free Software Foundation.
88755 + */
88756 +#include <linux/module.h>
88757 +#include <linux/moduleparam.h>
88758 +#include <linux/skbuff.h>
88759 +#include <linux/netfilter/x_tables.h>
88760 +#include <linux/grsecurity.h>
88761 +#include <linux/netfilter/xt_gradm.h>
88762 +
88763 +static bool
88764 +gradm_mt(const struct sk_buff *skb, struct xt_action_param *par)
88765 +{
88766 + const struct xt_gradm_mtinfo *info = par->matchinfo;
88767 + bool retval = false;
88768 + if (gr_acl_is_enabled())
88769 + retval = true;
88770 + return retval ^ info->invflags;
88771 +}
88772 +
88773 +static struct xt_match gradm_mt_reg __read_mostly = {
88774 + .name = "gradm",
88775 + .revision = 0,
88776 + .family = NFPROTO_UNSPEC,
88777 + .match = gradm_mt,
88778 + .matchsize = XT_ALIGN(sizeof(struct xt_gradm_mtinfo)),
88779 + .me = THIS_MODULE,
88780 +};
88781 +
88782 +static int __init gradm_mt_init(void)
88783 +{
88784 + return xt_register_match(&gradm_mt_reg);
88785 +}
88786 +
88787 +static void __exit gradm_mt_exit(void)
88788 +{
88789 + xt_unregister_match(&gradm_mt_reg);
88790 +}
88791 +
88792 +module_init(gradm_mt_init);
88793 +module_exit(gradm_mt_exit);
88794 +MODULE_AUTHOR("Zbigniew Krzystolik <zbyniu@destrukcja.pl>");
88795 +MODULE_DESCRIPTION("Xtables: Grsecurity RBAC match");
88796 +MODULE_LICENSE("GPL");
88797 +MODULE_ALIAS("ipt_gradm");
88798 +MODULE_ALIAS("ip6t_gradm");
88799 diff --git a/net/netfilter/xt_statistic.c b/net/netfilter/xt_statistic.c
88800 index 4fe4fb4..87a89e5 100644
88801 --- a/net/netfilter/xt_statistic.c
88802 +++ b/net/netfilter/xt_statistic.c
88803 @@ -19,7 +19,7 @@
88804 #include <linux/module.h>
88805
88806 struct xt_statistic_priv {
88807 - atomic_t count;
88808 + atomic_unchecked_t count;
88809 } ____cacheline_aligned_in_smp;
88810
88811 MODULE_LICENSE("GPL");
88812 @@ -42,9 +42,9 @@ statistic_mt(const struct sk_buff *skb, struct xt_action_param *par)
88813 break;
88814 case XT_STATISTIC_MODE_NTH:
88815 do {
88816 - oval = atomic_read(&info->master->count);
88817 + oval = atomic_read_unchecked(&info->master->count);
88818 nval = (oval == info->u.nth.every) ? 0 : oval + 1;
88819 - } while (atomic_cmpxchg(&info->master->count, oval, nval) != oval);
88820 + } while (atomic_cmpxchg_unchecked(&info->master->count, oval, nval) != oval);
88821 if (nval == 0)
88822 ret = !ret;
88823 break;
88824 @@ -64,7 +64,7 @@ static int statistic_mt_check(const struct xt_mtchk_param *par)
88825 info->master = kzalloc(sizeof(*info->master), GFP_KERNEL);
88826 if (info->master == NULL)
88827 return -ENOMEM;
88828 - atomic_set(&info->master->count, info->u.nth.count);
88829 + atomic_set_unchecked(&info->master->count, info->u.nth.count);
88830
88831 return 0;
88832 }
88833 diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
88834 index 1e3fd5b..ad397ea 100644
88835 --- a/net/netlink/af_netlink.c
88836 +++ b/net/netlink/af_netlink.c
88837 @@ -781,7 +781,7 @@ static void netlink_overrun(struct sock *sk)
88838 sk->sk_error_report(sk);
88839 }
88840 }
88841 - atomic_inc(&sk->sk_drops);
88842 + atomic_inc_unchecked(&sk->sk_drops);
88843 }
88844
88845 static struct sock *netlink_getsockbyportid(struct sock *ssk, u32 portid)
88846 @@ -2063,7 +2063,7 @@ static int netlink_seq_show(struct seq_file *seq, void *v)
88847 sk_wmem_alloc_get(s),
88848 nlk->cb,
88849 atomic_read(&s->sk_refcnt),
88850 - atomic_read(&s->sk_drops),
88851 + atomic_read_unchecked(&s->sk_drops),
88852 sock_i_ino(s)
88853 );
88854
88855 diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c
88856 index 5a55be3..7630745 100644
88857 --- a/net/netlink/genetlink.c
88858 +++ b/net/netlink/genetlink.c
88859 @@ -296,18 +296,20 @@ int genl_register_ops(struct genl_family *family, struct genl_ops *ops)
88860 goto errout;
88861 }
88862
88863 + pax_open_kernel();
88864 if (ops->dumpit)
88865 - ops->flags |= GENL_CMD_CAP_DUMP;
88866 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_DUMP;
88867 if (ops->doit)
88868 - ops->flags |= GENL_CMD_CAP_DO;
88869 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_DO;
88870 if (ops->policy)
88871 - ops->flags |= GENL_CMD_CAP_HASPOL;
88872 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_HASPOL;
88873 + pax_close_kernel();
88874
88875 genl_lock();
88876 - list_add_tail(&ops->ops_list, &family->ops_list);
88877 + pax_list_add_tail((struct list_head *)&ops->ops_list, &family->ops_list);
88878 genl_unlock();
88879
88880 - genl_ctrl_event(CTRL_CMD_NEWOPS, ops);
88881 + genl_ctrl_event(CTRL_CMD_NEWOPS, (void *)ops);
88882 err = 0;
88883 errout:
88884 return err;
88885 @@ -337,9 +339,9 @@ int genl_unregister_ops(struct genl_family *family, struct genl_ops *ops)
88886 genl_lock();
88887 list_for_each_entry(rc, &family->ops_list, ops_list) {
88888 if (rc == ops) {
88889 - list_del(&ops->ops_list);
88890 + pax_list_del((struct list_head *)&ops->ops_list);
88891 genl_unlock();
88892 - genl_ctrl_event(CTRL_CMD_DELOPS, ops);
88893 + genl_ctrl_event(CTRL_CMD_DELOPS, (void *)ops);
88894 return 0;
88895 }
88896 }
88897 diff --git a/net/netrom/af_netrom.c b/net/netrom/af_netrom.c
88898 index 103bd70..f21aad3 100644
88899 --- a/net/netrom/af_netrom.c
88900 +++ b/net/netrom/af_netrom.c
88901 @@ -834,6 +834,7 @@ static int nr_getname(struct socket *sock, struct sockaddr *uaddr,
88902 struct sock *sk = sock->sk;
88903 struct nr_sock *nr = nr_sk(sk);
88904
88905 + memset(sax, 0, sizeof(*sax));
88906 lock_sock(sk);
88907 if (peer != 0) {
88908 if (sk->sk_state != TCP_ESTABLISHED) {
88909 @@ -848,7 +849,6 @@ static int nr_getname(struct socket *sock, struct sockaddr *uaddr,
88910 *uaddr_len = sizeof(struct full_sockaddr_ax25);
88911 } else {
88912 sax->fsa_ax25.sax25_family = AF_NETROM;
88913 - sax->fsa_ax25.sax25_ndigis = 0;
88914 sax->fsa_ax25.sax25_call = nr->source_addr;
88915 *uaddr_len = sizeof(struct sockaddr_ax25);
88916 }
88917 diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
88918 index f83e172..b57140d 100644
88919 --- a/net/packet/af_packet.c
88920 +++ b/net/packet/af_packet.c
88921 @@ -1571,7 +1571,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
88922
88923 spin_lock(&sk->sk_receive_queue.lock);
88924 po->stats.tp_packets++;
88925 - skb->dropcount = atomic_read(&sk->sk_drops);
88926 + skb->dropcount = atomic_read_unchecked(&sk->sk_drops);
88927 __skb_queue_tail(&sk->sk_receive_queue, skb);
88928 spin_unlock(&sk->sk_receive_queue.lock);
88929 sk->sk_data_ready(sk, skb->len);
88930 @@ -1580,7 +1580,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
88931 drop_n_acct:
88932 spin_lock(&sk->sk_receive_queue.lock);
88933 po->stats.tp_drops++;
88934 - atomic_inc(&sk->sk_drops);
88935 + atomic_inc_unchecked(&sk->sk_drops);
88936 spin_unlock(&sk->sk_receive_queue.lock);
88937
88938 drop_n_restore:
88939 @@ -2558,6 +2558,7 @@ out:
88940
88941 static int packet_recv_error(struct sock *sk, struct msghdr *msg, int len)
88942 {
88943 + struct sock_extended_err ee;
88944 struct sock_exterr_skb *serr;
88945 struct sk_buff *skb, *skb2;
88946 int copied, err;
88947 @@ -2579,8 +2580,9 @@ static int packet_recv_error(struct sock *sk, struct msghdr *msg, int len)
88948 sock_recv_timestamp(msg, sk, skb);
88949
88950 serr = SKB_EXT_ERR(skb);
88951 + ee = serr->ee;
88952 put_cmsg(msg, SOL_PACKET, PACKET_TX_TIMESTAMP,
88953 - sizeof(serr->ee), &serr->ee);
88954 + sizeof ee, &ee);
88955
88956 msg->msg_flags |= MSG_ERRQUEUE;
88957 err = copied;
88958 @@ -3205,7 +3207,7 @@ static int packet_getsockopt(struct socket *sock, int level, int optname,
88959 case PACKET_HDRLEN:
88960 if (len > sizeof(int))
88961 len = sizeof(int);
88962 - if (copy_from_user(&val, optval, len))
88963 + if (len > sizeof(val) || copy_from_user(&val, optval, len))
88964 return -EFAULT;
88965 switch (val) {
88966 case TPACKET_V1:
88967 @@ -3247,7 +3249,7 @@ static int packet_getsockopt(struct socket *sock, int level, int optname,
88968 len = lv;
88969 if (put_user(len, optlen))
88970 return -EFAULT;
88971 - if (copy_to_user(optval, data, len))
88972 + if (len > sizeof(st) || copy_to_user(optval, data, len))
88973 return -EFAULT;
88974 return 0;
88975 }
88976 diff --git a/net/phonet/af_phonet.c b/net/phonet/af_phonet.c
88977 index 5a940db..d6a502d 100644
88978 --- a/net/phonet/af_phonet.c
88979 +++ b/net/phonet/af_phonet.c
88980 @@ -469,7 +469,7 @@ int __init_or_module phonet_proto_register(unsigned int protocol,
88981 {
88982 int err = 0;
88983
88984 - if (protocol >= PHONET_NPROTO)
88985 + if (protocol < 0 || protocol >= PHONET_NPROTO)
88986 return -EINVAL;
88987
88988 err = proto_register(pp->prot, 1);
88989 diff --git a/net/phonet/pep.c b/net/phonet/pep.c
88990 index e774117..900b8b7 100644
88991 --- a/net/phonet/pep.c
88992 +++ b/net/phonet/pep.c
88993 @@ -388,7 +388,7 @@ static int pipe_do_rcv(struct sock *sk, struct sk_buff *skb)
88994
88995 case PNS_PEP_CTRL_REQ:
88996 if (skb_queue_len(&pn->ctrlreq_queue) >= PNPIPE_CTRLREQ_MAX) {
88997 - atomic_inc(&sk->sk_drops);
88998 + atomic_inc_unchecked(&sk->sk_drops);
88999 break;
89000 }
89001 __skb_pull(skb, 4);
89002 @@ -409,7 +409,7 @@ static int pipe_do_rcv(struct sock *sk, struct sk_buff *skb)
89003 }
89004
89005 if (pn->rx_credits == 0) {
89006 - atomic_inc(&sk->sk_drops);
89007 + atomic_inc_unchecked(&sk->sk_drops);
89008 err = -ENOBUFS;
89009 break;
89010 }
89011 @@ -580,7 +580,7 @@ static int pipe_handler_do_rcv(struct sock *sk, struct sk_buff *skb)
89012 }
89013
89014 if (pn->rx_credits == 0) {
89015 - atomic_inc(&sk->sk_drops);
89016 + atomic_inc_unchecked(&sk->sk_drops);
89017 err = NET_RX_DROP;
89018 break;
89019 }
89020 diff --git a/net/phonet/socket.c b/net/phonet/socket.c
89021 index 1afd138..0b42453 100644
89022 --- a/net/phonet/socket.c
89023 +++ b/net/phonet/socket.c
89024 @@ -612,7 +612,7 @@ static int pn_sock_seq_show(struct seq_file *seq, void *v)
89025 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sk)),
89026 sock_i_ino(sk),
89027 atomic_read(&sk->sk_refcnt), sk,
89028 - atomic_read(&sk->sk_drops), &len);
89029 + atomic_read_unchecked(&sk->sk_drops), &len);
89030 }
89031 seq_printf(seq, "%*s\n", 127 - len, "");
89032 return 0;
89033 diff --git a/net/phonet/sysctl.c b/net/phonet/sysctl.c
89034 index d6bbbbd..61561e4 100644
89035 --- a/net/phonet/sysctl.c
89036 +++ b/net/phonet/sysctl.c
89037 @@ -67,7 +67,7 @@ static int proc_local_port_range(ctl_table *table, int write,
89038 {
89039 int ret;
89040 int range[2] = {local_port_range[0], local_port_range[1]};
89041 - ctl_table tmp = {
89042 + ctl_table_no_const tmp = {
89043 .data = &range,
89044 .maxlen = sizeof(range),
89045 .mode = table->mode,
89046 diff --git a/net/rds/cong.c b/net/rds/cong.c
89047 index e5b65ac..f3b6fb7 100644
89048 --- a/net/rds/cong.c
89049 +++ b/net/rds/cong.c
89050 @@ -78,7 +78,7 @@
89051 * finds that the saved generation number is smaller than the global generation
89052 * number, it wakes up the process.
89053 */
89054 -static atomic_t rds_cong_generation = ATOMIC_INIT(0);
89055 +static atomic_unchecked_t rds_cong_generation = ATOMIC_INIT(0);
89056
89057 /*
89058 * Congestion monitoring
89059 @@ -233,7 +233,7 @@ void rds_cong_map_updated(struct rds_cong_map *map, uint64_t portmask)
89060 rdsdebug("waking map %p for %pI4\n",
89061 map, &map->m_addr);
89062 rds_stats_inc(s_cong_update_received);
89063 - atomic_inc(&rds_cong_generation);
89064 + atomic_inc_unchecked(&rds_cong_generation);
89065 if (waitqueue_active(&map->m_waitq))
89066 wake_up(&map->m_waitq);
89067 if (waitqueue_active(&rds_poll_waitq))
89068 @@ -259,7 +259,7 @@ EXPORT_SYMBOL_GPL(rds_cong_map_updated);
89069
89070 int rds_cong_updated_since(unsigned long *recent)
89071 {
89072 - unsigned long gen = atomic_read(&rds_cong_generation);
89073 + unsigned long gen = atomic_read_unchecked(&rds_cong_generation);
89074
89075 if (likely(*recent == gen))
89076 return 0;
89077 diff --git a/net/rds/ib.h b/net/rds/ib.h
89078 index 7280ab8..e04f4ea 100644
89079 --- a/net/rds/ib.h
89080 +++ b/net/rds/ib.h
89081 @@ -128,7 +128,7 @@ struct rds_ib_connection {
89082 /* sending acks */
89083 unsigned long i_ack_flags;
89084 #ifdef KERNEL_HAS_ATOMIC64
89085 - atomic64_t i_ack_next; /* next ACK to send */
89086 + atomic64_unchecked_t i_ack_next; /* next ACK to send */
89087 #else
89088 spinlock_t i_ack_lock; /* protect i_ack_next */
89089 u64 i_ack_next; /* next ACK to send */
89090 diff --git a/net/rds/ib_cm.c b/net/rds/ib_cm.c
89091 index 31b74f5..dc1fbfa 100644
89092 --- a/net/rds/ib_cm.c
89093 +++ b/net/rds/ib_cm.c
89094 @@ -717,7 +717,7 @@ void rds_ib_conn_shutdown(struct rds_connection *conn)
89095 /* Clear the ACK state */
89096 clear_bit(IB_ACK_IN_FLIGHT, &ic->i_ack_flags);
89097 #ifdef KERNEL_HAS_ATOMIC64
89098 - atomic64_set(&ic->i_ack_next, 0);
89099 + atomic64_set_unchecked(&ic->i_ack_next, 0);
89100 #else
89101 ic->i_ack_next = 0;
89102 #endif
89103 diff --git a/net/rds/ib_recv.c b/net/rds/ib_recv.c
89104 index 8eb9501..0c386ff 100644
89105 --- a/net/rds/ib_recv.c
89106 +++ b/net/rds/ib_recv.c
89107 @@ -597,7 +597,7 @@ static u64 rds_ib_get_ack(struct rds_ib_connection *ic)
89108 static void rds_ib_set_ack(struct rds_ib_connection *ic, u64 seq,
89109 int ack_required)
89110 {
89111 - atomic64_set(&ic->i_ack_next, seq);
89112 + atomic64_set_unchecked(&ic->i_ack_next, seq);
89113 if (ack_required) {
89114 smp_mb__before_clear_bit();
89115 set_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
89116 @@ -609,7 +609,7 @@ static u64 rds_ib_get_ack(struct rds_ib_connection *ic)
89117 clear_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
89118 smp_mb__after_clear_bit();
89119
89120 - return atomic64_read(&ic->i_ack_next);
89121 + return atomic64_read_unchecked(&ic->i_ack_next);
89122 }
89123 #endif
89124
89125 diff --git a/net/rds/iw.h b/net/rds/iw.h
89126 index 04ce3b1..48119a6 100644
89127 --- a/net/rds/iw.h
89128 +++ b/net/rds/iw.h
89129 @@ -134,7 +134,7 @@ struct rds_iw_connection {
89130 /* sending acks */
89131 unsigned long i_ack_flags;
89132 #ifdef KERNEL_HAS_ATOMIC64
89133 - atomic64_t i_ack_next; /* next ACK to send */
89134 + atomic64_unchecked_t i_ack_next; /* next ACK to send */
89135 #else
89136 spinlock_t i_ack_lock; /* protect i_ack_next */
89137 u64 i_ack_next; /* next ACK to send */
89138 diff --git a/net/rds/iw_cm.c b/net/rds/iw_cm.c
89139 index a91e1db..cf3053f 100644
89140 --- a/net/rds/iw_cm.c
89141 +++ b/net/rds/iw_cm.c
89142 @@ -663,7 +663,7 @@ void rds_iw_conn_shutdown(struct rds_connection *conn)
89143 /* Clear the ACK state */
89144 clear_bit(IB_ACK_IN_FLIGHT, &ic->i_ack_flags);
89145 #ifdef KERNEL_HAS_ATOMIC64
89146 - atomic64_set(&ic->i_ack_next, 0);
89147 + atomic64_set_unchecked(&ic->i_ack_next, 0);
89148 #else
89149 ic->i_ack_next = 0;
89150 #endif
89151 diff --git a/net/rds/iw_recv.c b/net/rds/iw_recv.c
89152 index 4503335..db566b4 100644
89153 --- a/net/rds/iw_recv.c
89154 +++ b/net/rds/iw_recv.c
89155 @@ -427,7 +427,7 @@ static u64 rds_iw_get_ack(struct rds_iw_connection *ic)
89156 static void rds_iw_set_ack(struct rds_iw_connection *ic, u64 seq,
89157 int ack_required)
89158 {
89159 - atomic64_set(&ic->i_ack_next, seq);
89160 + atomic64_set_unchecked(&ic->i_ack_next, seq);
89161 if (ack_required) {
89162 smp_mb__before_clear_bit();
89163 set_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
89164 @@ -439,7 +439,7 @@ static u64 rds_iw_get_ack(struct rds_iw_connection *ic)
89165 clear_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
89166 smp_mb__after_clear_bit();
89167
89168 - return atomic64_read(&ic->i_ack_next);
89169 + return atomic64_read_unchecked(&ic->i_ack_next);
89170 }
89171 #endif
89172
89173 diff --git a/net/rds/rds.h b/net/rds/rds.h
89174 index ec1d731..90a3a8d 100644
89175 --- a/net/rds/rds.h
89176 +++ b/net/rds/rds.h
89177 @@ -449,7 +449,7 @@ struct rds_transport {
89178 void (*sync_mr)(void *trans_private, int direction);
89179 void (*free_mr)(void *trans_private, int invalidate);
89180 void (*flush_mrs)(void);
89181 -};
89182 +} __do_const;
89183
89184 struct rds_sock {
89185 struct sock rs_sk;
89186 diff --git a/net/rds/tcp.c b/net/rds/tcp.c
89187 index edac9ef..16bcb98 100644
89188 --- a/net/rds/tcp.c
89189 +++ b/net/rds/tcp.c
89190 @@ -59,7 +59,7 @@ void rds_tcp_nonagle(struct socket *sock)
89191 int val = 1;
89192
89193 set_fs(KERNEL_DS);
89194 - sock->ops->setsockopt(sock, SOL_TCP, TCP_NODELAY, (char __user *)&val,
89195 + sock->ops->setsockopt(sock, SOL_TCP, TCP_NODELAY, (char __force_user *)&val,
89196 sizeof(val));
89197 set_fs(oldfs);
89198 }
89199 diff --git a/net/rds/tcp_send.c b/net/rds/tcp_send.c
89200 index 81cf5a4..b5826ff 100644
89201 --- a/net/rds/tcp_send.c
89202 +++ b/net/rds/tcp_send.c
89203 @@ -43,7 +43,7 @@ static void rds_tcp_cork(struct socket *sock, int val)
89204
89205 oldfs = get_fs();
89206 set_fs(KERNEL_DS);
89207 - sock->ops->setsockopt(sock, SOL_TCP, TCP_CORK, (char __user *)&val,
89208 + sock->ops->setsockopt(sock, SOL_TCP, TCP_CORK, (char __force_user *)&val,
89209 sizeof(val));
89210 set_fs(oldfs);
89211 }
89212 diff --git a/net/rxrpc/af_rxrpc.c b/net/rxrpc/af_rxrpc.c
89213 index e61aa60..f07cc89 100644
89214 --- a/net/rxrpc/af_rxrpc.c
89215 +++ b/net/rxrpc/af_rxrpc.c
89216 @@ -40,7 +40,7 @@ static const struct proto_ops rxrpc_rpc_ops;
89217 __be32 rxrpc_epoch;
89218
89219 /* current debugging ID */
89220 -atomic_t rxrpc_debug_id;
89221 +atomic_unchecked_t rxrpc_debug_id;
89222
89223 /* count of skbs currently in use */
89224 atomic_t rxrpc_n_skbs;
89225 diff --git a/net/rxrpc/ar-ack.c b/net/rxrpc/ar-ack.c
89226 index e4d9cbc..b229649 100644
89227 --- a/net/rxrpc/ar-ack.c
89228 +++ b/net/rxrpc/ar-ack.c
89229 @@ -175,7 +175,7 @@ static void rxrpc_resend(struct rxrpc_call *call)
89230
89231 _enter("{%d,%d,%d,%d},",
89232 call->acks_hard, call->acks_unacked,
89233 - atomic_read(&call->sequence),
89234 + atomic_read_unchecked(&call->sequence),
89235 CIRC_CNT(call->acks_head, call->acks_tail, call->acks_winsz));
89236
89237 stop = 0;
89238 @@ -199,7 +199,7 @@ static void rxrpc_resend(struct rxrpc_call *call)
89239
89240 /* each Tx packet has a new serial number */
89241 sp->hdr.serial =
89242 - htonl(atomic_inc_return(&call->conn->serial));
89243 + htonl(atomic_inc_return_unchecked(&call->conn->serial));
89244
89245 hdr = (struct rxrpc_header *) txb->head;
89246 hdr->serial = sp->hdr.serial;
89247 @@ -403,7 +403,7 @@ static void rxrpc_rotate_tx_window(struct rxrpc_call *call, u32 hard)
89248 */
89249 static void rxrpc_clear_tx_window(struct rxrpc_call *call)
89250 {
89251 - rxrpc_rotate_tx_window(call, atomic_read(&call->sequence));
89252 + rxrpc_rotate_tx_window(call, atomic_read_unchecked(&call->sequence));
89253 }
89254
89255 /*
89256 @@ -629,7 +629,7 @@ process_further:
89257
89258 latest = ntohl(sp->hdr.serial);
89259 hard = ntohl(ack.firstPacket);
89260 - tx = atomic_read(&call->sequence);
89261 + tx = atomic_read_unchecked(&call->sequence);
89262
89263 _proto("Rx ACK %%%u { m=%hu f=#%u p=#%u s=%%%u r=%s n=%u }",
89264 latest,
89265 @@ -1161,7 +1161,7 @@ void rxrpc_process_call(struct work_struct *work)
89266 goto maybe_reschedule;
89267
89268 send_ACK_with_skew:
89269 - ack.maxSkew = htons(atomic_read(&call->conn->hi_serial) -
89270 + ack.maxSkew = htons(atomic_read_unchecked(&call->conn->hi_serial) -
89271 ntohl(ack.serial));
89272 send_ACK:
89273 mtu = call->conn->trans->peer->if_mtu;
89274 @@ -1173,7 +1173,7 @@ send_ACK:
89275 ackinfo.rxMTU = htonl(5692);
89276 ackinfo.jumbo_max = htonl(4);
89277
89278 - hdr.serial = htonl(atomic_inc_return(&call->conn->serial));
89279 + hdr.serial = htonl(atomic_inc_return_unchecked(&call->conn->serial));
89280 _proto("Tx ACK %%%u { m=%hu f=#%u p=#%u s=%%%u r=%s n=%u }",
89281 ntohl(hdr.serial),
89282 ntohs(ack.maxSkew),
89283 @@ -1191,7 +1191,7 @@ send_ACK:
89284 send_message:
89285 _debug("send message");
89286
89287 - hdr.serial = htonl(atomic_inc_return(&call->conn->serial));
89288 + hdr.serial = htonl(atomic_inc_return_unchecked(&call->conn->serial));
89289 _proto("Tx %s %%%u", rxrpc_pkts[hdr.type], ntohl(hdr.serial));
89290 send_message_2:
89291
89292 diff --git a/net/rxrpc/ar-call.c b/net/rxrpc/ar-call.c
89293 index a3bbb36..3341fb9 100644
89294 --- a/net/rxrpc/ar-call.c
89295 +++ b/net/rxrpc/ar-call.c
89296 @@ -83,7 +83,7 @@ static struct rxrpc_call *rxrpc_alloc_call(gfp_t gfp)
89297 spin_lock_init(&call->lock);
89298 rwlock_init(&call->state_lock);
89299 atomic_set(&call->usage, 1);
89300 - call->debug_id = atomic_inc_return(&rxrpc_debug_id);
89301 + call->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
89302 call->state = RXRPC_CALL_CLIENT_SEND_REQUEST;
89303
89304 memset(&call->sock_node, 0xed, sizeof(call->sock_node));
89305 diff --git a/net/rxrpc/ar-connection.c b/net/rxrpc/ar-connection.c
89306 index 4106ca9..a338d7a 100644
89307 --- a/net/rxrpc/ar-connection.c
89308 +++ b/net/rxrpc/ar-connection.c
89309 @@ -206,7 +206,7 @@ static struct rxrpc_connection *rxrpc_alloc_connection(gfp_t gfp)
89310 rwlock_init(&conn->lock);
89311 spin_lock_init(&conn->state_lock);
89312 atomic_set(&conn->usage, 1);
89313 - conn->debug_id = atomic_inc_return(&rxrpc_debug_id);
89314 + conn->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
89315 conn->avail_calls = RXRPC_MAXCALLS;
89316 conn->size_align = 4;
89317 conn->header_size = sizeof(struct rxrpc_header);
89318 diff --git a/net/rxrpc/ar-connevent.c b/net/rxrpc/ar-connevent.c
89319 index e7ed43a..6afa140 100644
89320 --- a/net/rxrpc/ar-connevent.c
89321 +++ b/net/rxrpc/ar-connevent.c
89322 @@ -109,7 +109,7 @@ static int rxrpc_abort_connection(struct rxrpc_connection *conn,
89323
89324 len = iov[0].iov_len + iov[1].iov_len;
89325
89326 - hdr.serial = htonl(atomic_inc_return(&conn->serial));
89327 + hdr.serial = htonl(atomic_inc_return_unchecked(&conn->serial));
89328 _proto("Tx CONN ABORT %%%u { %d }", ntohl(hdr.serial), abort_code);
89329
89330 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 2, len);
89331 diff --git a/net/rxrpc/ar-input.c b/net/rxrpc/ar-input.c
89332 index 529572f..c758ca7 100644
89333 --- a/net/rxrpc/ar-input.c
89334 +++ b/net/rxrpc/ar-input.c
89335 @@ -340,9 +340,9 @@ void rxrpc_fast_process_packet(struct rxrpc_call *call, struct sk_buff *skb)
89336 /* track the latest serial number on this connection for ACK packet
89337 * information */
89338 serial = ntohl(sp->hdr.serial);
89339 - hi_serial = atomic_read(&call->conn->hi_serial);
89340 + hi_serial = atomic_read_unchecked(&call->conn->hi_serial);
89341 while (serial > hi_serial)
89342 - hi_serial = atomic_cmpxchg(&call->conn->hi_serial, hi_serial,
89343 + hi_serial = atomic_cmpxchg_unchecked(&call->conn->hi_serial, hi_serial,
89344 serial);
89345
89346 /* request ACK generation for any ACK or DATA packet that requests
89347 diff --git a/net/rxrpc/ar-internal.h b/net/rxrpc/ar-internal.h
89348 index a693aca..81e7293 100644
89349 --- a/net/rxrpc/ar-internal.h
89350 +++ b/net/rxrpc/ar-internal.h
89351 @@ -272,8 +272,8 @@ struct rxrpc_connection {
89352 int error; /* error code for local abort */
89353 int debug_id; /* debug ID for printks */
89354 unsigned int call_counter; /* call ID counter */
89355 - atomic_t serial; /* packet serial number counter */
89356 - atomic_t hi_serial; /* highest serial number received */
89357 + atomic_unchecked_t serial; /* packet serial number counter */
89358 + atomic_unchecked_t hi_serial; /* highest serial number received */
89359 u8 avail_calls; /* number of calls available */
89360 u8 size_align; /* data size alignment (for security) */
89361 u8 header_size; /* rxrpc + security header size */
89362 @@ -346,7 +346,7 @@ struct rxrpc_call {
89363 spinlock_t lock;
89364 rwlock_t state_lock; /* lock for state transition */
89365 atomic_t usage;
89366 - atomic_t sequence; /* Tx data packet sequence counter */
89367 + atomic_unchecked_t sequence; /* Tx data packet sequence counter */
89368 u32 abort_code; /* local/remote abort code */
89369 enum { /* current state of call */
89370 RXRPC_CALL_CLIENT_SEND_REQUEST, /* - client sending request phase */
89371 @@ -420,7 +420,7 @@ static inline void rxrpc_abort_call(struct rxrpc_call *call, u32 abort_code)
89372 */
89373 extern atomic_t rxrpc_n_skbs;
89374 extern __be32 rxrpc_epoch;
89375 -extern atomic_t rxrpc_debug_id;
89376 +extern atomic_unchecked_t rxrpc_debug_id;
89377 extern struct workqueue_struct *rxrpc_workqueue;
89378
89379 /*
89380 diff --git a/net/rxrpc/ar-local.c b/net/rxrpc/ar-local.c
89381 index 87f7135..74d3703 100644
89382 --- a/net/rxrpc/ar-local.c
89383 +++ b/net/rxrpc/ar-local.c
89384 @@ -45,7 +45,7 @@ struct rxrpc_local *rxrpc_alloc_local(struct sockaddr_rxrpc *srx)
89385 spin_lock_init(&local->lock);
89386 rwlock_init(&local->services_lock);
89387 atomic_set(&local->usage, 1);
89388 - local->debug_id = atomic_inc_return(&rxrpc_debug_id);
89389 + local->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
89390 memcpy(&local->srx, srx, sizeof(*srx));
89391 }
89392
89393 diff --git a/net/rxrpc/ar-output.c b/net/rxrpc/ar-output.c
89394 index e1ac183..b43e10e 100644
89395 --- a/net/rxrpc/ar-output.c
89396 +++ b/net/rxrpc/ar-output.c
89397 @@ -682,9 +682,9 @@ static int rxrpc_send_data(struct kiocb *iocb,
89398 sp->hdr.cid = call->cid;
89399 sp->hdr.callNumber = call->call_id;
89400 sp->hdr.seq =
89401 - htonl(atomic_inc_return(&call->sequence));
89402 + htonl(atomic_inc_return_unchecked(&call->sequence));
89403 sp->hdr.serial =
89404 - htonl(atomic_inc_return(&conn->serial));
89405 + htonl(atomic_inc_return_unchecked(&conn->serial));
89406 sp->hdr.type = RXRPC_PACKET_TYPE_DATA;
89407 sp->hdr.userStatus = 0;
89408 sp->hdr.securityIndex = conn->security_ix;
89409 diff --git a/net/rxrpc/ar-peer.c b/net/rxrpc/ar-peer.c
89410 index bebaa43..2644591 100644
89411 --- a/net/rxrpc/ar-peer.c
89412 +++ b/net/rxrpc/ar-peer.c
89413 @@ -72,7 +72,7 @@ static struct rxrpc_peer *rxrpc_alloc_peer(struct sockaddr_rxrpc *srx,
89414 INIT_LIST_HEAD(&peer->error_targets);
89415 spin_lock_init(&peer->lock);
89416 atomic_set(&peer->usage, 1);
89417 - peer->debug_id = atomic_inc_return(&rxrpc_debug_id);
89418 + peer->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
89419 memcpy(&peer->srx, srx, sizeof(*srx));
89420
89421 rxrpc_assess_MTU_size(peer);
89422 diff --git a/net/rxrpc/ar-proc.c b/net/rxrpc/ar-proc.c
89423 index 38047f7..9f48511 100644
89424 --- a/net/rxrpc/ar-proc.c
89425 +++ b/net/rxrpc/ar-proc.c
89426 @@ -164,8 +164,8 @@ static int rxrpc_connection_seq_show(struct seq_file *seq, void *v)
89427 atomic_read(&conn->usage),
89428 rxrpc_conn_states[conn->state],
89429 key_serial(conn->key),
89430 - atomic_read(&conn->serial),
89431 - atomic_read(&conn->hi_serial));
89432 + atomic_read_unchecked(&conn->serial),
89433 + atomic_read_unchecked(&conn->hi_serial));
89434
89435 return 0;
89436 }
89437 diff --git a/net/rxrpc/ar-transport.c b/net/rxrpc/ar-transport.c
89438 index 92df566..87ec1bf 100644
89439 --- a/net/rxrpc/ar-transport.c
89440 +++ b/net/rxrpc/ar-transport.c
89441 @@ -47,7 +47,7 @@ static struct rxrpc_transport *rxrpc_alloc_transport(struct rxrpc_local *local,
89442 spin_lock_init(&trans->client_lock);
89443 rwlock_init(&trans->conn_lock);
89444 atomic_set(&trans->usage, 1);
89445 - trans->debug_id = atomic_inc_return(&rxrpc_debug_id);
89446 + trans->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
89447
89448 if (peer->srx.transport.family == AF_INET) {
89449 switch (peer->srx.transport_type) {
89450 diff --git a/net/rxrpc/rxkad.c b/net/rxrpc/rxkad.c
89451 index f226709..0e735a8 100644
89452 --- a/net/rxrpc/rxkad.c
89453 +++ b/net/rxrpc/rxkad.c
89454 @@ -610,7 +610,7 @@ static int rxkad_issue_challenge(struct rxrpc_connection *conn)
89455
89456 len = iov[0].iov_len + iov[1].iov_len;
89457
89458 - hdr.serial = htonl(atomic_inc_return(&conn->serial));
89459 + hdr.serial = htonl(atomic_inc_return_unchecked(&conn->serial));
89460 _proto("Tx CHALLENGE %%%u", ntohl(hdr.serial));
89461
89462 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 2, len);
89463 @@ -660,7 +660,7 @@ static int rxkad_send_response(struct rxrpc_connection *conn,
89464
89465 len = iov[0].iov_len + iov[1].iov_len + iov[2].iov_len;
89466
89467 - hdr->serial = htonl(atomic_inc_return(&conn->serial));
89468 + hdr->serial = htonl(atomic_inc_return_unchecked(&conn->serial));
89469 _proto("Tx RESPONSE %%%u", ntohl(hdr->serial));
89470
89471 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 3, len);
89472 diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c
89473 index 391a245..296b3d7 100644
89474 --- a/net/sctp/ipv6.c
89475 +++ b/net/sctp/ipv6.c
89476 @@ -981,7 +981,7 @@ static const struct inet6_protocol sctpv6_protocol = {
89477 .flags = INET6_PROTO_NOPOLICY | INET6_PROTO_FINAL,
89478 };
89479
89480 -static struct sctp_af sctp_af_inet6 = {
89481 +static struct sctp_af sctp_af_inet6 __read_only = {
89482 .sa_family = AF_INET6,
89483 .sctp_xmit = sctp_v6_xmit,
89484 .setsockopt = ipv6_setsockopt,
89485 @@ -1013,7 +1013,7 @@ static struct sctp_af sctp_af_inet6 = {
89486 #endif
89487 };
89488
89489 -static struct sctp_pf sctp_pf_inet6 = {
89490 +static struct sctp_pf sctp_pf_inet6 __read_only = {
89491 .event_msgname = sctp_inet6_event_msgname,
89492 .skb_msgname = sctp_inet6_skb_msgname,
89493 .af_supported = sctp_inet6_af_supported,
89494 @@ -1038,7 +1038,7 @@ void sctp_v6_pf_init(void)
89495
89496 void sctp_v6_pf_exit(void)
89497 {
89498 - list_del(&sctp_af_inet6.list);
89499 + pax_list_del(&sctp_af_inet6.list);
89500 }
89501
89502 /* Initialize IPv6 support and register with socket layer. */
89503 diff --git a/net/sctp/probe.c b/net/sctp/probe.c
89504 index ad0dba8..e62c225 100644
89505 --- a/net/sctp/probe.c
89506 +++ b/net/sctp/probe.c
89507 @@ -63,7 +63,7 @@ static struct {
89508 struct timespec tstart;
89509 } sctpw;
89510
89511 -static void printl(const char *fmt, ...)
89512 +static __printf(1, 2) void printl(const char *fmt, ...)
89513 {
89514 va_list args;
89515 int len;
89516 diff --git a/net/sctp/proc.c b/net/sctp/proc.c
89517 index ab3bba8..2fbab4e 100644
89518 --- a/net/sctp/proc.c
89519 +++ b/net/sctp/proc.c
89520 @@ -336,7 +336,8 @@ static int sctp_assocs_seq_show(struct seq_file *seq, void *v)
89521 seq_printf(seq,
89522 "%8pK %8pK %-3d %-3d %-2d %-4d "
89523 "%4d %8d %8d %7d %5lu %-5d %5d ",
89524 - assoc, sk, sctp_sk(sk)->type, sk->sk_state,
89525 + assoc, sk,
89526 + sctp_sk(sk)->type, sk->sk_state,
89527 assoc->state, hash,
89528 assoc->assoc_id,
89529 assoc->sndbuf_used,
89530 diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
89531 index 1c2e46c..f91cf5e 100644
89532 --- a/net/sctp/protocol.c
89533 +++ b/net/sctp/protocol.c
89534 @@ -834,8 +834,10 @@ int sctp_register_af(struct sctp_af *af)
89535 return 0;
89536 }
89537
89538 + pax_open_kernel();
89539 INIT_LIST_HEAD(&af->list);
89540 - list_add_tail(&af->list, &sctp_address_families);
89541 + pax_close_kernel();
89542 + pax_list_add_tail(&af->list, &sctp_address_families);
89543 return 1;
89544 }
89545
89546 @@ -966,7 +968,7 @@ static inline int sctp_v4_xmit(struct sk_buff *skb,
89547
89548 static struct sctp_af sctp_af_inet;
89549
89550 -static struct sctp_pf sctp_pf_inet = {
89551 +static struct sctp_pf sctp_pf_inet __read_only = {
89552 .event_msgname = sctp_inet_event_msgname,
89553 .skb_msgname = sctp_inet_skb_msgname,
89554 .af_supported = sctp_inet_af_supported,
89555 @@ -1037,7 +1039,7 @@ static const struct net_protocol sctp_protocol = {
89556 };
89557
89558 /* IPv4 address related functions. */
89559 -static struct sctp_af sctp_af_inet = {
89560 +static struct sctp_af sctp_af_inet __read_only = {
89561 .sa_family = AF_INET,
89562 .sctp_xmit = sctp_v4_xmit,
89563 .setsockopt = ip_setsockopt,
89564 @@ -1122,7 +1124,7 @@ static void sctp_v4_pf_init(void)
89565
89566 static void sctp_v4_pf_exit(void)
89567 {
89568 - list_del(&sctp_af_inet.list);
89569 + pax_list_del(&sctp_af_inet.list);
89570 }
89571
89572 static int sctp_v4_protosw_init(void)
89573 diff --git a/net/sctp/sm_sideeffect.c b/net/sctp/sm_sideeffect.c
89574 index 8aab894..f6b7e7d 100644
89575 --- a/net/sctp/sm_sideeffect.c
89576 +++ b/net/sctp/sm_sideeffect.c
89577 @@ -447,7 +447,7 @@ static void sctp_generate_sack_event(unsigned long data)
89578 sctp_generate_timeout_event(asoc, SCTP_EVENT_TIMEOUT_SACK);
89579 }
89580
89581 -sctp_timer_event_t *sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES] = {
89582 +sctp_timer_event_t * const sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES] = {
89583 NULL,
89584 sctp_generate_t1_cookie_event,
89585 sctp_generate_t1_init_event,
89586 diff --git a/net/sctp/socket.c b/net/sctp/socket.c
89587 index b907073..57fef6c 100644
89588 --- a/net/sctp/socket.c
89589 +++ b/net/sctp/socket.c
89590 @@ -2166,11 +2166,13 @@ static int sctp_setsockopt_events(struct sock *sk, char __user *optval,
89591 {
89592 struct sctp_association *asoc;
89593 struct sctp_ulpevent *event;
89594 + struct sctp_event_subscribe subscribe;
89595
89596 if (optlen > sizeof(struct sctp_event_subscribe))
89597 return -EINVAL;
89598 - if (copy_from_user(&sctp_sk(sk)->subscribe, optval, optlen))
89599 + if (copy_from_user(&subscribe, optval, optlen))
89600 return -EFAULT;
89601 + sctp_sk(sk)->subscribe = subscribe;
89602
89603 /*
89604 * At the time when a user app subscribes to SCTP_SENDER_DRY_EVENT,
89605 @@ -4215,13 +4217,16 @@ static int sctp_getsockopt_disable_fragments(struct sock *sk, int len,
89606 static int sctp_getsockopt_events(struct sock *sk, int len, char __user *optval,
89607 int __user *optlen)
89608 {
89609 + struct sctp_event_subscribe subscribe;
89610 +
89611 if (len <= 0)
89612 return -EINVAL;
89613 if (len > sizeof(struct sctp_event_subscribe))
89614 len = sizeof(struct sctp_event_subscribe);
89615 if (put_user(len, optlen))
89616 return -EFAULT;
89617 - if (copy_to_user(optval, &sctp_sk(sk)->subscribe, len))
89618 + subscribe = sctp_sk(sk)->subscribe;
89619 + if (copy_to_user(optval, &subscribe, len))
89620 return -EFAULT;
89621 return 0;
89622 }
89623 @@ -4239,6 +4244,8 @@ static int sctp_getsockopt_events(struct sock *sk, int len, char __user *optval,
89624 */
89625 static int sctp_getsockopt_autoclose(struct sock *sk, int len, char __user *optval, int __user *optlen)
89626 {
89627 + __u32 autoclose;
89628 +
89629 /* Applicable to UDP-style socket only */
89630 if (sctp_style(sk, TCP))
89631 return -EOPNOTSUPP;
89632 @@ -4247,7 +4254,8 @@ static int sctp_getsockopt_autoclose(struct sock *sk, int len, char __user *optv
89633 len = sizeof(int);
89634 if (put_user(len, optlen))
89635 return -EFAULT;
89636 - if (copy_to_user(optval, &sctp_sk(sk)->autoclose, sizeof(int)))
89637 + autoclose = sctp_sk(sk)->autoclose;
89638 + if (copy_to_user(optval, &autoclose, sizeof(int)))
89639 return -EFAULT;
89640 return 0;
89641 }
89642 @@ -4619,12 +4627,15 @@ static int sctp_getsockopt_delayed_ack(struct sock *sk, int len,
89643 */
89644 static int sctp_getsockopt_initmsg(struct sock *sk, int len, char __user *optval, int __user *optlen)
89645 {
89646 + struct sctp_initmsg initmsg;
89647 +
89648 if (len < sizeof(struct sctp_initmsg))
89649 return -EINVAL;
89650 len = sizeof(struct sctp_initmsg);
89651 if (put_user(len, optlen))
89652 return -EFAULT;
89653 - if (copy_to_user(optval, &sctp_sk(sk)->initmsg, len))
89654 + initmsg = sctp_sk(sk)->initmsg;
89655 + if (copy_to_user(optval, &initmsg, len))
89656 return -EFAULT;
89657 return 0;
89658 }
89659 @@ -4665,6 +4676,8 @@ static int sctp_getsockopt_peer_addrs(struct sock *sk, int len,
89660 addrlen = sctp_get_af_specific(temp.sa.sa_family)->sockaddr_len;
89661 if (space_left < addrlen)
89662 return -ENOMEM;
89663 + if (addrlen > sizeof(temp) || addrlen < 0)
89664 + return -EFAULT;
89665 if (copy_to_user(to, &temp, addrlen))
89666 return -EFAULT;
89667 to += addrlen;
89668 diff --git a/net/sctp/sysctl.c b/net/sctp/sysctl.c
89669 index bf3c6e8..376d8d0 100644
89670 --- a/net/sctp/sysctl.c
89671 +++ b/net/sctp/sysctl.c
89672 @@ -307,7 +307,7 @@ static int proc_sctp_do_hmac_alg(ctl_table *ctl,
89673 {
89674 struct net *net = current->nsproxy->net_ns;
89675 char tmp[8];
89676 - ctl_table tbl;
89677 + ctl_table_no_const tbl;
89678 int ret;
89679 int changed = 0;
89680 char *none = "none";
89681 @@ -350,7 +350,7 @@ static int proc_sctp_do_hmac_alg(ctl_table *ctl,
89682
89683 int sctp_sysctl_net_register(struct net *net)
89684 {
89685 - struct ctl_table *table;
89686 + ctl_table_no_const *table;
89687 int i;
89688
89689 table = kmemdup(sctp_net_table, sizeof(sctp_net_table), GFP_KERNEL);
89690 diff --git a/net/socket.c b/net/socket.c
89691 index 88f759a..c6933de 100644
89692 --- a/net/socket.c
89693 +++ b/net/socket.c
89694 @@ -88,6 +88,7 @@
89695 #include <linux/magic.h>
89696 #include <linux/slab.h>
89697 #include <linux/xattr.h>
89698 +#include <linux/in.h>
89699
89700 #include <asm/uaccess.h>
89701 #include <asm/unistd.h>
89702 @@ -105,6 +106,8 @@
89703 #include <linux/sockios.h>
89704 #include <linux/atalk.h>
89705
89706 +#include <linux/grsock.h>
89707 +
89708 static int sock_no_open(struct inode *irrelevant, struct file *dontcare);
89709 static ssize_t sock_aio_read(struct kiocb *iocb, const struct iovec *iov,
89710 unsigned long nr_segs, loff_t pos);
89711 @@ -321,7 +324,7 @@ static struct dentry *sockfs_mount(struct file_system_type *fs_type,
89712 &sockfs_dentry_operations, SOCKFS_MAGIC);
89713 }
89714
89715 -static struct vfsmount *sock_mnt __read_mostly;
89716 +struct vfsmount *sock_mnt __read_mostly;
89717
89718 static struct file_system_type sock_fs_type = {
89719 .name = "sockfs",
89720 @@ -1268,6 +1271,8 @@ int __sock_create(struct net *net, int family, int type, int protocol,
89721 return -EAFNOSUPPORT;
89722 if (type < 0 || type >= SOCK_MAX)
89723 return -EINVAL;
89724 + if (protocol < 0)
89725 + return -EINVAL;
89726
89727 /* Compatibility.
89728
89729 @@ -1399,6 +1404,16 @@ SYSCALL_DEFINE3(socket, int, family, int, type, int, protocol)
89730 if (SOCK_NONBLOCK != O_NONBLOCK && (flags & SOCK_NONBLOCK))
89731 flags = (flags & ~SOCK_NONBLOCK) | O_NONBLOCK;
89732
89733 + if(!gr_search_socket(family, type, protocol)) {
89734 + retval = -EACCES;
89735 + goto out;
89736 + }
89737 +
89738 + if (gr_handle_sock_all(family, type, protocol)) {
89739 + retval = -EACCES;
89740 + goto out;
89741 + }
89742 +
89743 retval = sock_create(family, type, protocol, &sock);
89744 if (retval < 0)
89745 goto out;
89746 @@ -1526,6 +1541,14 @@ SYSCALL_DEFINE3(bind, int, fd, struct sockaddr __user *, umyaddr, int, addrlen)
89747 if (sock) {
89748 err = move_addr_to_kernel(umyaddr, addrlen, &address);
89749 if (err >= 0) {
89750 + if (gr_handle_sock_server((struct sockaddr *)&address)) {
89751 + err = -EACCES;
89752 + goto error;
89753 + }
89754 + err = gr_search_bind(sock, (struct sockaddr_in *)&address);
89755 + if (err)
89756 + goto error;
89757 +
89758 err = security_socket_bind(sock,
89759 (struct sockaddr *)&address,
89760 addrlen);
89761 @@ -1534,6 +1557,7 @@ SYSCALL_DEFINE3(bind, int, fd, struct sockaddr __user *, umyaddr, int, addrlen)
89762 (struct sockaddr *)
89763 &address, addrlen);
89764 }
89765 +error:
89766 fput_light(sock->file, fput_needed);
89767 }
89768 return err;
89769 @@ -1557,10 +1581,20 @@ SYSCALL_DEFINE2(listen, int, fd, int, backlog)
89770 if ((unsigned int)backlog > somaxconn)
89771 backlog = somaxconn;
89772
89773 + if (gr_handle_sock_server_other(sock->sk)) {
89774 + err = -EPERM;
89775 + goto error;
89776 + }
89777 +
89778 + err = gr_search_listen(sock);
89779 + if (err)
89780 + goto error;
89781 +
89782 err = security_socket_listen(sock, backlog);
89783 if (!err)
89784 err = sock->ops->listen(sock, backlog);
89785
89786 +error:
89787 fput_light(sock->file, fput_needed);
89788 }
89789 return err;
89790 @@ -1604,6 +1638,18 @@ SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr,
89791 newsock->type = sock->type;
89792 newsock->ops = sock->ops;
89793
89794 + if (gr_handle_sock_server_other(sock->sk)) {
89795 + err = -EPERM;
89796 + sock_release(newsock);
89797 + goto out_put;
89798 + }
89799 +
89800 + err = gr_search_accept(sock);
89801 + if (err) {
89802 + sock_release(newsock);
89803 + goto out_put;
89804 + }
89805 +
89806 /*
89807 * We don't need try_module_get here, as the listening socket (sock)
89808 * has the protocol module (sock->ops->owner) held.
89809 @@ -1649,6 +1695,8 @@ SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr,
89810 fd_install(newfd, newfile);
89811 err = newfd;
89812
89813 + gr_attach_curr_ip(newsock->sk);
89814 +
89815 out_put:
89816 fput_light(sock->file, fput_needed);
89817 out:
89818 @@ -1681,6 +1729,7 @@ SYSCALL_DEFINE3(connect, int, fd, struct sockaddr __user *, uservaddr,
89819 int, addrlen)
89820 {
89821 struct socket *sock;
89822 + struct sockaddr *sck;
89823 struct sockaddr_storage address;
89824 int err, fput_needed;
89825
89826 @@ -1691,6 +1740,17 @@ SYSCALL_DEFINE3(connect, int, fd, struct sockaddr __user *, uservaddr,
89827 if (err < 0)
89828 goto out_put;
89829
89830 + sck = (struct sockaddr *)&address;
89831 +
89832 + if (gr_handle_sock_client(sck)) {
89833 + err = -EACCES;
89834 + goto out_put;
89835 + }
89836 +
89837 + err = gr_search_connect(sock, (struct sockaddr_in *)sck);
89838 + if (err)
89839 + goto out_put;
89840 +
89841 err =
89842 security_socket_connect(sock, (struct sockaddr *)&address, addrlen);
89843 if (err)
89844 @@ -1772,6 +1832,8 @@ SYSCALL_DEFINE3(getpeername, int, fd, struct sockaddr __user *, usockaddr,
89845 * the protocol.
89846 */
89847
89848 +asmlinkage long sys_sendto(int, void *, size_t, unsigned, struct sockaddr *, int);
89849 +
89850 SYSCALL_DEFINE6(sendto, int, fd, void __user *, buff, size_t, len,
89851 unsigned int, flags, struct sockaddr __user *, addr,
89852 int, addr_len)
89853 @@ -1838,7 +1900,7 @@ SYSCALL_DEFINE6(recvfrom, int, fd, void __user *, ubuf, size_t, size,
89854 struct socket *sock;
89855 struct iovec iov;
89856 struct msghdr msg;
89857 - struct sockaddr_storage address;
89858 + struct sockaddr_storage address = { };
89859 int err, err2;
89860 int fput_needed;
89861
89862 @@ -2045,7 +2107,7 @@ static int __sys_sendmsg(struct socket *sock, struct msghdr __user *msg,
89863 * checking falls down on this.
89864 */
89865 if (copy_from_user(ctl_buf,
89866 - (void __user __force *)msg_sys->msg_control,
89867 + (void __force_user *)msg_sys->msg_control,
89868 ctl_len))
89869 goto out_freectl;
89870 msg_sys->msg_control = ctl_buf;
89871 @@ -2185,7 +2247,7 @@ static int __sys_recvmsg(struct socket *sock, struct msghdr __user *msg,
89872 int err, total_len, len;
89873
89874 /* kernel mode address */
89875 - struct sockaddr_storage addr;
89876 + struct sockaddr_storage addr = { };
89877
89878 /* user mode address pointers */
89879 struct sockaddr __user *uaddr;
89880 @@ -2213,7 +2275,7 @@ static int __sys_recvmsg(struct socket *sock, struct msghdr __user *msg,
89881 * kernel msghdr to use the kernel address space)
89882 */
89883
89884 - uaddr = (__force void __user *)msg_sys->msg_name;
89885 + uaddr = (void __force_user *)msg_sys->msg_name;
89886 uaddr_len = COMPAT_NAMELEN(msg);
89887 if (MSG_CMSG_COMPAT & flags) {
89888 err = verify_compat_iovec(msg_sys, iov, &addr, VERIFY_WRITE);
89889 @@ -2952,7 +3014,7 @@ static int bond_ioctl(struct net *net, unsigned int cmd,
89890 old_fs = get_fs();
89891 set_fs(KERNEL_DS);
89892 err = dev_ioctl(net, cmd,
89893 - (struct ifreq __user __force *) &kifr);
89894 + (struct ifreq __force_user *) &kifr);
89895 set_fs(old_fs);
89896
89897 return err;
89898 @@ -3061,7 +3123,7 @@ static int compat_sioc_ifmap(struct net *net, unsigned int cmd,
89899
89900 old_fs = get_fs();
89901 set_fs(KERNEL_DS);
89902 - err = dev_ioctl(net, cmd, (void __user __force *)&ifr);
89903 + err = dev_ioctl(net, cmd, (void __force_user *)&ifr);
89904 set_fs(old_fs);
89905
89906 if (cmd == SIOCGIFMAP && !err) {
89907 @@ -3166,7 +3228,7 @@ static int routing_ioctl(struct net *net, struct socket *sock,
89908 ret |= __get_user(rtdev, &(ur4->rt_dev));
89909 if (rtdev) {
89910 ret |= copy_from_user(devname, compat_ptr(rtdev), 15);
89911 - r4.rt_dev = (char __user __force *)devname;
89912 + r4.rt_dev = (char __force_user *)devname;
89913 devname[15] = 0;
89914 } else
89915 r4.rt_dev = NULL;
89916 @@ -3392,8 +3454,8 @@ int kernel_getsockopt(struct socket *sock, int level, int optname,
89917 int __user *uoptlen;
89918 int err;
89919
89920 - uoptval = (char __user __force *) optval;
89921 - uoptlen = (int __user __force *) optlen;
89922 + uoptval = (char __force_user *) optval;
89923 + uoptlen = (int __force_user *) optlen;
89924
89925 set_fs(KERNEL_DS);
89926 if (level == SOL_SOCKET)
89927 @@ -3413,7 +3475,7 @@ int kernel_setsockopt(struct socket *sock, int level, int optname,
89928 char __user *uoptval;
89929 int err;
89930
89931 - uoptval = (char __user __force *) optval;
89932 + uoptval = (char __force_user *) optval;
89933
89934 set_fs(KERNEL_DS);
89935 if (level == SOL_SOCKET)
89936 diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
89937 index d5f35f1..da2680b5 100644
89938 --- a/net/sunrpc/clnt.c
89939 +++ b/net/sunrpc/clnt.c
89940 @@ -1283,7 +1283,9 @@ call_start(struct rpc_task *task)
89941 (RPC_IS_ASYNC(task) ? "async" : "sync"));
89942
89943 /* Increment call count */
89944 - task->tk_msg.rpc_proc->p_count++;
89945 + pax_open_kernel();
89946 + (*(unsigned int *)&task->tk_msg.rpc_proc->p_count)++;
89947 + pax_close_kernel();
89948 clnt->cl_stats->rpccnt++;
89949 task->tk_action = call_reserve;
89950 }
89951 diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c
89952 index f8529fc..ce8c643 100644
89953 --- a/net/sunrpc/sched.c
89954 +++ b/net/sunrpc/sched.c
89955 @@ -261,9 +261,9 @@ static int rpc_wait_bit_killable(void *word)
89956 #ifdef RPC_DEBUG
89957 static void rpc_task_set_debuginfo(struct rpc_task *task)
89958 {
89959 - static atomic_t rpc_pid;
89960 + static atomic_unchecked_t rpc_pid;
89961
89962 - task->tk_pid = atomic_inc_return(&rpc_pid);
89963 + task->tk_pid = atomic_inc_return_unchecked(&rpc_pid);
89964 }
89965 #else
89966 static inline void rpc_task_set_debuginfo(struct rpc_task *task)
89967 diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c
89968 index 89a588b..ba2cef8 100644
89969 --- a/net/sunrpc/svc.c
89970 +++ b/net/sunrpc/svc.c
89971 @@ -1160,7 +1160,9 @@ svc_process_common(struct svc_rqst *rqstp, struct kvec *argv, struct kvec *resv)
89972 svc_putnl(resv, RPC_SUCCESS);
89973
89974 /* Bump per-procedure stats counter */
89975 - procp->pc_count++;
89976 + pax_open_kernel();
89977 + (*(unsigned int *)&procp->pc_count)++;
89978 + pax_close_kernel();
89979
89980 /* Initialize storage for argp and resp */
89981 memset(rqstp->rq_argp, 0, procp->pc_argsize);
89982 diff --git a/net/sunrpc/xprtrdma/svc_rdma.c b/net/sunrpc/xprtrdma/svc_rdma.c
89983 index 8343737..677025e 100644
89984 --- a/net/sunrpc/xprtrdma/svc_rdma.c
89985 +++ b/net/sunrpc/xprtrdma/svc_rdma.c
89986 @@ -62,15 +62,15 @@ unsigned int svcrdma_max_req_size = RPCRDMA_MAX_REQ_SIZE;
89987 static unsigned int min_max_inline = 4096;
89988 static unsigned int max_max_inline = 65536;
89989
89990 -atomic_t rdma_stat_recv;
89991 -atomic_t rdma_stat_read;
89992 -atomic_t rdma_stat_write;
89993 -atomic_t rdma_stat_sq_starve;
89994 -atomic_t rdma_stat_rq_starve;
89995 -atomic_t rdma_stat_rq_poll;
89996 -atomic_t rdma_stat_rq_prod;
89997 -atomic_t rdma_stat_sq_poll;
89998 -atomic_t rdma_stat_sq_prod;
89999 +atomic_unchecked_t rdma_stat_recv;
90000 +atomic_unchecked_t rdma_stat_read;
90001 +atomic_unchecked_t rdma_stat_write;
90002 +atomic_unchecked_t rdma_stat_sq_starve;
90003 +atomic_unchecked_t rdma_stat_rq_starve;
90004 +atomic_unchecked_t rdma_stat_rq_poll;
90005 +atomic_unchecked_t rdma_stat_rq_prod;
90006 +atomic_unchecked_t rdma_stat_sq_poll;
90007 +atomic_unchecked_t rdma_stat_sq_prod;
90008
90009 /* Temporary NFS request map and context caches */
90010 struct kmem_cache *svc_rdma_map_cachep;
90011 @@ -110,7 +110,7 @@ static int read_reset_stat(ctl_table *table, int write,
90012 len -= *ppos;
90013 if (len > *lenp)
90014 len = *lenp;
90015 - if (len && copy_to_user(buffer, str_buf, len))
90016 + if (len > sizeof str_buf || (len && copy_to_user(buffer, str_buf, len)))
90017 return -EFAULT;
90018 *lenp = len;
90019 *ppos += len;
90020 @@ -151,63 +151,63 @@ static ctl_table svcrdma_parm_table[] = {
90021 {
90022 .procname = "rdma_stat_read",
90023 .data = &rdma_stat_read,
90024 - .maxlen = sizeof(atomic_t),
90025 + .maxlen = sizeof(atomic_unchecked_t),
90026 .mode = 0644,
90027 .proc_handler = read_reset_stat,
90028 },
90029 {
90030 .procname = "rdma_stat_recv",
90031 .data = &rdma_stat_recv,
90032 - .maxlen = sizeof(atomic_t),
90033 + .maxlen = sizeof(atomic_unchecked_t),
90034 .mode = 0644,
90035 .proc_handler = read_reset_stat,
90036 },
90037 {
90038 .procname = "rdma_stat_write",
90039 .data = &rdma_stat_write,
90040 - .maxlen = sizeof(atomic_t),
90041 + .maxlen = sizeof(atomic_unchecked_t),
90042 .mode = 0644,
90043 .proc_handler = read_reset_stat,
90044 },
90045 {
90046 .procname = "rdma_stat_sq_starve",
90047 .data = &rdma_stat_sq_starve,
90048 - .maxlen = sizeof(atomic_t),
90049 + .maxlen = sizeof(atomic_unchecked_t),
90050 .mode = 0644,
90051 .proc_handler = read_reset_stat,
90052 },
90053 {
90054 .procname = "rdma_stat_rq_starve",
90055 .data = &rdma_stat_rq_starve,
90056 - .maxlen = sizeof(atomic_t),
90057 + .maxlen = sizeof(atomic_unchecked_t),
90058 .mode = 0644,
90059 .proc_handler = read_reset_stat,
90060 },
90061 {
90062 .procname = "rdma_stat_rq_poll",
90063 .data = &rdma_stat_rq_poll,
90064 - .maxlen = sizeof(atomic_t),
90065 + .maxlen = sizeof(atomic_unchecked_t),
90066 .mode = 0644,
90067 .proc_handler = read_reset_stat,
90068 },
90069 {
90070 .procname = "rdma_stat_rq_prod",
90071 .data = &rdma_stat_rq_prod,
90072 - .maxlen = sizeof(atomic_t),
90073 + .maxlen = sizeof(atomic_unchecked_t),
90074 .mode = 0644,
90075 .proc_handler = read_reset_stat,
90076 },
90077 {
90078 .procname = "rdma_stat_sq_poll",
90079 .data = &rdma_stat_sq_poll,
90080 - .maxlen = sizeof(atomic_t),
90081 + .maxlen = sizeof(atomic_unchecked_t),
90082 .mode = 0644,
90083 .proc_handler = read_reset_stat,
90084 },
90085 {
90086 .procname = "rdma_stat_sq_prod",
90087 .data = &rdma_stat_sq_prod,
90088 - .maxlen = sizeof(atomic_t),
90089 + .maxlen = sizeof(atomic_unchecked_t),
90090 .mode = 0644,
90091 .proc_handler = read_reset_stat,
90092 },
90093 diff --git a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
90094 index 0ce7552..d074459 100644
90095 --- a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
90096 +++ b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
90097 @@ -501,7 +501,7 @@ next_sge:
90098 svc_rdma_put_context(ctxt, 0);
90099 goto out;
90100 }
90101 - atomic_inc(&rdma_stat_read);
90102 + atomic_inc_unchecked(&rdma_stat_read);
90103
90104 if (read_wr.num_sge < chl_map->ch[ch_no].count) {
90105 chl_map->ch[ch_no].count -= read_wr.num_sge;
90106 @@ -611,7 +611,7 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp)
90107 dto_q);
90108 list_del_init(&ctxt->dto_q);
90109 } else {
90110 - atomic_inc(&rdma_stat_rq_starve);
90111 + atomic_inc_unchecked(&rdma_stat_rq_starve);
90112 clear_bit(XPT_DATA, &xprt->xpt_flags);
90113 ctxt = NULL;
90114 }
90115 @@ -631,7 +631,7 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp)
90116 dprintk("svcrdma: processing ctxt=%p on xprt=%p, rqstp=%p, status=%d\n",
90117 ctxt, rdma_xprt, rqstp, ctxt->wc_status);
90118 BUG_ON(ctxt->wc_status != IB_WC_SUCCESS);
90119 - atomic_inc(&rdma_stat_recv);
90120 + atomic_inc_unchecked(&rdma_stat_recv);
90121
90122 /* Build up the XDR from the receive buffers. */
90123 rdma_build_arg_xdr(rqstp, ctxt, ctxt->byte_len);
90124 diff --git a/net/sunrpc/xprtrdma/svc_rdma_sendto.c b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
90125 index c1d124d..acfc59e 100644
90126 --- a/net/sunrpc/xprtrdma/svc_rdma_sendto.c
90127 +++ b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
90128 @@ -362,7 +362,7 @@ static int send_write(struct svcxprt_rdma *xprt, struct svc_rqst *rqstp,
90129 write_wr.wr.rdma.remote_addr = to;
90130
90131 /* Post It */
90132 - atomic_inc(&rdma_stat_write);
90133 + atomic_inc_unchecked(&rdma_stat_write);
90134 if (svc_rdma_send(xprt, &write_wr))
90135 goto err;
90136 return 0;
90137 diff --git a/net/sunrpc/xprtrdma/svc_rdma_transport.c b/net/sunrpc/xprtrdma/svc_rdma_transport.c
90138 index 62e4f9b..dd3f2d7 100644
90139 --- a/net/sunrpc/xprtrdma/svc_rdma_transport.c
90140 +++ b/net/sunrpc/xprtrdma/svc_rdma_transport.c
90141 @@ -292,7 +292,7 @@ static void rq_cq_reap(struct svcxprt_rdma *xprt)
90142 return;
90143
90144 ib_req_notify_cq(xprt->sc_rq_cq, IB_CQ_NEXT_COMP);
90145 - atomic_inc(&rdma_stat_rq_poll);
90146 + atomic_inc_unchecked(&rdma_stat_rq_poll);
90147
90148 while ((ret = ib_poll_cq(xprt->sc_rq_cq, 1, &wc)) > 0) {
90149 ctxt = (struct svc_rdma_op_ctxt *)(unsigned long)wc.wr_id;
90150 @@ -314,7 +314,7 @@ static void rq_cq_reap(struct svcxprt_rdma *xprt)
90151 }
90152
90153 if (ctxt)
90154 - atomic_inc(&rdma_stat_rq_prod);
90155 + atomic_inc_unchecked(&rdma_stat_rq_prod);
90156
90157 set_bit(XPT_DATA, &xprt->sc_xprt.xpt_flags);
90158 /*
90159 @@ -386,7 +386,7 @@ static void sq_cq_reap(struct svcxprt_rdma *xprt)
90160 return;
90161
90162 ib_req_notify_cq(xprt->sc_sq_cq, IB_CQ_NEXT_COMP);
90163 - atomic_inc(&rdma_stat_sq_poll);
90164 + atomic_inc_unchecked(&rdma_stat_sq_poll);
90165 while ((ret = ib_poll_cq(cq, 1, &wc)) > 0) {
90166 if (wc.status != IB_WC_SUCCESS)
90167 /* Close the transport */
90168 @@ -404,7 +404,7 @@ static void sq_cq_reap(struct svcxprt_rdma *xprt)
90169 }
90170
90171 if (ctxt)
90172 - atomic_inc(&rdma_stat_sq_prod);
90173 + atomic_inc_unchecked(&rdma_stat_sq_prod);
90174 }
90175
90176 static void sq_comp_handler(struct ib_cq *cq, void *cq_context)
90177 @@ -1262,7 +1262,7 @@ int svc_rdma_send(struct svcxprt_rdma *xprt, struct ib_send_wr *wr)
90178 spin_lock_bh(&xprt->sc_lock);
90179 if (xprt->sc_sq_depth < atomic_read(&xprt->sc_sq_count) + wr_count) {
90180 spin_unlock_bh(&xprt->sc_lock);
90181 - atomic_inc(&rdma_stat_sq_starve);
90182 + atomic_inc_unchecked(&rdma_stat_sq_starve);
90183
90184 /* See if we can opportunistically reap SQ WR to make room */
90185 sq_cq_reap(xprt);
90186 diff --git a/net/sysctl_net.c b/net/sysctl_net.c
90187 index 9bc6db0..47ac8c0 100644
90188 --- a/net/sysctl_net.c
90189 +++ b/net/sysctl_net.c
90190 @@ -46,7 +46,7 @@ static int net_ctl_permissions(struct ctl_table_header *head,
90191 kgid_t root_gid = make_kgid(net->user_ns, 0);
90192
90193 /* Allow network administrator to have same access as root. */
90194 - if (ns_capable(net->user_ns, CAP_NET_ADMIN) ||
90195 + if (ns_capable_nolog(net->user_ns, CAP_NET_ADMIN) ||
90196 uid_eq(root_uid, current_uid())) {
90197 int mode = (table->mode >> 6) & 7;
90198 return (mode << 6) | (mode << 3) | mode;
90199 diff --git a/net/tipc/link.c b/net/tipc/link.c
90200 index daa6080..2bbbe70 100644
90201 --- a/net/tipc/link.c
90202 +++ b/net/tipc/link.c
90203 @@ -1201,7 +1201,7 @@ static int link_send_sections_long(struct tipc_port *sender,
90204 struct tipc_msg fragm_hdr;
90205 struct sk_buff *buf, *buf_chain, *prev;
90206 u32 fragm_crs, fragm_rest, hsz, sect_rest;
90207 - const unchar *sect_crs;
90208 + const unchar __user *sect_crs;
90209 int curr_sect;
90210 u32 fragm_no;
90211
90212 @@ -1242,7 +1242,7 @@ again:
90213
90214 if (!sect_rest) {
90215 sect_rest = msg_sect[++curr_sect].iov_len;
90216 - sect_crs = (const unchar *)msg_sect[curr_sect].iov_base;
90217 + sect_crs = (const unchar __user *)msg_sect[curr_sect].iov_base;
90218 }
90219
90220 if (sect_rest < fragm_rest)
90221 @@ -1261,7 +1261,7 @@ error:
90222 }
90223 } else
90224 skb_copy_to_linear_data_offset(buf, fragm_crs,
90225 - sect_crs, sz);
90226 + (const void __force_kernel *)sect_crs, sz);
90227 sect_crs += sz;
90228 sect_rest -= sz;
90229 fragm_crs += sz;
90230 @@ -2306,8 +2306,11 @@ static int link_recv_changeover_msg(struct tipc_link **l_ptr,
90231 struct tipc_msg *tunnel_msg = buf_msg(tunnel_buf);
90232 u32 msg_typ = msg_type(tunnel_msg);
90233 u32 msg_count = msg_msgcnt(tunnel_msg);
90234 + u32 bearer_id = msg_bearer_id(tunnel_msg);
90235
90236 - dest_link = (*l_ptr)->owner->links[msg_bearer_id(tunnel_msg)];
90237 + if (bearer_id >= MAX_BEARERS)
90238 + goto exit;
90239 + dest_link = (*l_ptr)->owner->links[bearer_id];
90240 if (!dest_link)
90241 goto exit;
90242 if (dest_link == *l_ptr) {
90243 @@ -2521,14 +2524,16 @@ int tipc_link_recv_fragment(struct sk_buff **pending, struct sk_buff **fb,
90244 struct tipc_msg *imsg = (struct tipc_msg *)msg_data(fragm);
90245 u32 msg_sz = msg_size(imsg);
90246 u32 fragm_sz = msg_data_sz(fragm);
90247 - u32 exp_fragm_cnt = msg_sz/fragm_sz + !!(msg_sz % fragm_sz);
90248 + u32 exp_fragm_cnt;
90249 u32 max = TIPC_MAX_USER_MSG_SIZE + NAMED_H_SIZE;
90250 +
90251 if (msg_type(imsg) == TIPC_MCAST_MSG)
90252 max = TIPC_MAX_USER_MSG_SIZE + MCAST_H_SIZE;
90253 - if (msg_size(imsg) > max) {
90254 + if (fragm_sz == 0 || msg_size(imsg) > max) {
90255 kfree_skb(fbuf);
90256 return 0;
90257 }
90258 + exp_fragm_cnt = msg_sz / fragm_sz + !!(msg_sz % fragm_sz);
90259 pbuf = tipc_buf_acquire(msg_size(imsg));
90260 if (pbuf != NULL) {
90261 pbuf->next = *pending;
90262 diff --git a/net/tipc/msg.c b/net/tipc/msg.c
90263 index f2db8a8..9245aa4 100644
90264 --- a/net/tipc/msg.c
90265 +++ b/net/tipc/msg.c
90266 @@ -98,7 +98,7 @@ int tipc_msg_build(struct tipc_msg *hdr, struct iovec const *msg_sect,
90267 msg_sect[cnt].iov_len);
90268 else
90269 skb_copy_to_linear_data_offset(*buf, pos,
90270 - msg_sect[cnt].iov_base,
90271 + (const void __force_kernel *)msg_sect[cnt].iov_base,
90272 msg_sect[cnt].iov_len);
90273 pos += msg_sect[cnt].iov_len;
90274 }
90275 diff --git a/net/tipc/subscr.c b/net/tipc/subscr.c
90276 index 6b42d47..2ac24d5 100644
90277 --- a/net/tipc/subscr.c
90278 +++ b/net/tipc/subscr.c
90279 @@ -96,7 +96,7 @@ static void subscr_send_event(struct tipc_subscription *sub,
90280 {
90281 struct iovec msg_sect;
90282
90283 - msg_sect.iov_base = (void *)&sub->evt;
90284 + msg_sect.iov_base = (void __force_user *)&sub->evt;
90285 msg_sect.iov_len = sizeof(struct tipc_event);
90286
90287 sub->evt.event = htohl(event, sub->swap);
90288 diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
90289 index 2db702d..09a77488 100644
90290 --- a/net/unix/af_unix.c
90291 +++ b/net/unix/af_unix.c
90292 @@ -783,6 +783,12 @@ static struct sock *unix_find_other(struct net *net,
90293 err = -ECONNREFUSED;
90294 if (!S_ISSOCK(inode->i_mode))
90295 goto put_fail;
90296 +
90297 + if (!gr_acl_handle_unix(path.dentry, path.mnt)) {
90298 + err = -EACCES;
90299 + goto put_fail;
90300 + }
90301 +
90302 u = unix_find_socket_byinode(inode);
90303 if (!u)
90304 goto put_fail;
90305 @@ -803,6 +809,13 @@ static struct sock *unix_find_other(struct net *net,
90306 if (u) {
90307 struct dentry *dentry;
90308 dentry = unix_sk(u)->path.dentry;
90309 +
90310 + if (!gr_handle_chroot_unix(pid_vnr(u->sk_peer_pid))) {
90311 + err = -EPERM;
90312 + sock_put(u);
90313 + goto fail;
90314 + }
90315 +
90316 if (dentry)
90317 touch_atime(&unix_sk(u)->path);
90318 } else
90319 @@ -836,12 +849,18 @@ static int unix_mknod(const char *sun_path, umode_t mode, struct path *res)
90320 */
90321 err = security_path_mknod(&path, dentry, mode, 0);
90322 if (!err) {
90323 + if (!gr_acl_handle_mknod(dentry, path.dentry, path.mnt, mode)) {
90324 + err = -EACCES;
90325 + goto out;
90326 + }
90327 err = vfs_mknod(path.dentry->d_inode, dentry, mode, 0);
90328 if (!err) {
90329 res->mnt = mntget(path.mnt);
90330 res->dentry = dget(dentry);
90331 + gr_handle_create(dentry, path.mnt);
90332 }
90333 }
90334 +out:
90335 done_path_create(&path, dentry);
90336 return err;
90337 }
90338 @@ -2323,9 +2342,13 @@ static int unix_seq_show(struct seq_file *seq, void *v)
90339 seq_puts(seq, "Num RefCount Protocol Flags Type St "
90340 "Inode Path\n");
90341 else {
90342 - struct sock *s = v;
90343 + struct sock *s = v, *peer;
90344 struct unix_sock *u = unix_sk(s);
90345 unix_state_lock(s);
90346 + peer = unix_peer(s);
90347 + unix_state_unlock(s);
90348 +
90349 + unix_state_double_lock(s, peer);
90350
90351 seq_printf(seq, "%pK: %08X %08X %08X %04X %02X %5lu",
90352 s,
90353 @@ -2352,8 +2375,10 @@ static int unix_seq_show(struct seq_file *seq, void *v)
90354 }
90355 for ( ; i < len; i++)
90356 seq_putc(seq, u->addr->name->sun_path[i]);
90357 - }
90358 - unix_state_unlock(s);
90359 + } else if (peer)
90360 + seq_printf(seq, " P%lu", sock_i_ino(peer));
90361 +
90362 + unix_state_double_unlock(s, peer);
90363 seq_putc(seq, '\n');
90364 }
90365
90366 diff --git a/net/unix/sysctl_net_unix.c b/net/unix/sysctl_net_unix.c
90367 index 8800604..0526440 100644
90368 --- a/net/unix/sysctl_net_unix.c
90369 +++ b/net/unix/sysctl_net_unix.c
90370 @@ -28,7 +28,7 @@ static ctl_table unix_table[] = {
90371
90372 int __net_init unix_sysctl_register(struct net *net)
90373 {
90374 - struct ctl_table *table;
90375 + ctl_table_no_const *table;
90376
90377 table = kmemdup(unix_table, sizeof(unix_table), GFP_KERNEL);
90378 if (table == NULL)
90379 diff --git a/net/wireless/wext-core.c b/net/wireless/wext-core.c
90380 index c8717c1..08539f5 100644
90381 --- a/net/wireless/wext-core.c
90382 +++ b/net/wireless/wext-core.c
90383 @@ -748,8 +748,7 @@ static int ioctl_standard_iw_point(struct iw_point *iwp, unsigned int cmd,
90384 */
90385
90386 /* Support for very large requests */
90387 - if ((descr->flags & IW_DESCR_FLAG_NOMAX) &&
90388 - (user_length > descr->max_tokens)) {
90389 + if (user_length > descr->max_tokens) {
90390 /* Allow userspace to GET more than max so
90391 * we can support any size GET requests.
90392 * There is still a limit : -ENOMEM.
90393 @@ -788,22 +787,6 @@ static int ioctl_standard_iw_point(struct iw_point *iwp, unsigned int cmd,
90394 }
90395 }
90396
90397 - if (IW_IS_GET(cmd) && !(descr->flags & IW_DESCR_FLAG_NOMAX)) {
90398 - /*
90399 - * If this is a GET, but not NOMAX, it means that the extra
90400 - * data is not bounded by userspace, but by max_tokens. Thus
90401 - * set the length to max_tokens. This matches the extra data
90402 - * allocation.
90403 - * The driver should fill it with the number of tokens it
90404 - * provided, and it may check iwp->length rather than having
90405 - * knowledge of max_tokens. If the driver doesn't change the
90406 - * iwp->length, this ioctl just copies back max_token tokens
90407 - * filled with zeroes. Hopefully the driver isn't claiming
90408 - * them to be valid data.
90409 - */
90410 - iwp->length = descr->max_tokens;
90411 - }
90412 -
90413 err = handler(dev, info, (union iwreq_data *) iwp, extra);
90414
90415 iwp->length += essid_compat;
90416 diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
90417 index 167c67d..3f2ae427 100644
90418 --- a/net/xfrm/xfrm_policy.c
90419 +++ b/net/xfrm/xfrm_policy.c
90420 @@ -334,7 +334,7 @@ static void xfrm_policy_kill(struct xfrm_policy *policy)
90421 {
90422 policy->walk.dead = 1;
90423
90424 - atomic_inc(&policy->genid);
90425 + atomic_inc_unchecked(&policy->genid);
90426
90427 del_timer(&policy->polq.hold_timer);
90428 xfrm_queue_purge(&policy->polq.hold_queue);
90429 @@ -659,7 +659,7 @@ int xfrm_policy_insert(int dir, struct xfrm_policy *policy, int excl)
90430 hlist_add_head(&policy->bydst, chain);
90431 xfrm_pol_hold(policy);
90432 net->xfrm.policy_count[dir]++;
90433 - atomic_inc(&flow_cache_genid);
90434 + atomic_inc_unchecked(&flow_cache_genid);
90435 rt_genid_bump(net);
90436 if (delpol) {
90437 xfrm_policy_requeue(delpol, policy);
90438 @@ -1611,7 +1611,7 @@ free_dst:
90439 goto out;
90440 }
90441
90442 -static int inline
90443 +static inline int
90444 xfrm_dst_alloc_copy(void **target, const void *src, int size)
90445 {
90446 if (!*target) {
90447 @@ -1623,7 +1623,7 @@ xfrm_dst_alloc_copy(void **target, const void *src, int size)
90448 return 0;
90449 }
90450
90451 -static int inline
90452 +static inline int
90453 xfrm_dst_update_parent(struct dst_entry *dst, const struct xfrm_selector *sel)
90454 {
90455 #ifdef CONFIG_XFRM_SUB_POLICY
90456 @@ -1635,7 +1635,7 @@ xfrm_dst_update_parent(struct dst_entry *dst, const struct xfrm_selector *sel)
90457 #endif
90458 }
90459
90460 -static int inline
90461 +static inline int
90462 xfrm_dst_update_origin(struct dst_entry *dst, const struct flowi *fl)
90463 {
90464 #ifdef CONFIG_XFRM_SUB_POLICY
90465 @@ -1729,7 +1729,7 @@ xfrm_resolve_and_create_bundle(struct xfrm_policy **pols, int num_pols,
90466
90467 xdst->num_pols = num_pols;
90468 memcpy(xdst->pols, pols, sizeof(struct xfrm_policy*) * num_pols);
90469 - xdst->policy_genid = atomic_read(&pols[0]->genid);
90470 + xdst->policy_genid = atomic_read_unchecked(&pols[0]->genid);
90471
90472 return xdst;
90473 }
90474 @@ -2598,7 +2598,7 @@ static int xfrm_bundle_ok(struct xfrm_dst *first)
90475 if (xdst->xfrm_genid != dst->xfrm->genid)
90476 return 0;
90477 if (xdst->num_pols > 0 &&
90478 - xdst->policy_genid != atomic_read(&xdst->pols[0]->genid))
90479 + xdst->policy_genid != atomic_read_unchecked(&xdst->pols[0]->genid))
90480 return 0;
90481
90482 mtu = dst_mtu(dst->child);
90483 @@ -2686,8 +2686,11 @@ int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo)
90484 dst_ops->link_failure = xfrm_link_failure;
90485 if (likely(dst_ops->neigh_lookup == NULL))
90486 dst_ops->neigh_lookup = xfrm_neigh_lookup;
90487 - if (likely(afinfo->garbage_collect == NULL))
90488 - afinfo->garbage_collect = xfrm_garbage_collect_deferred;
90489 + if (likely(afinfo->garbage_collect == NULL)) {
90490 + pax_open_kernel();
90491 + *(void **)&afinfo->garbage_collect = xfrm_garbage_collect_deferred;
90492 + pax_close_kernel();
90493 + }
90494 rcu_assign_pointer(xfrm_policy_afinfo[afinfo->family], afinfo);
90495 }
90496 spin_unlock(&xfrm_policy_afinfo_lock);
90497 @@ -2741,7 +2744,9 @@ int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo)
90498 dst_ops->check = NULL;
90499 dst_ops->negative_advice = NULL;
90500 dst_ops->link_failure = NULL;
90501 - afinfo->garbage_collect = NULL;
90502 + pax_open_kernel();
90503 + *(void **)&afinfo->garbage_collect = NULL;
90504 + pax_close_kernel();
90505 }
90506 return err;
90507 }
90508 @@ -3124,7 +3129,7 @@ static int xfrm_policy_migrate(struct xfrm_policy *pol,
90509 sizeof(pol->xfrm_vec[i].saddr));
90510 pol->xfrm_vec[i].encap_family = mp->new_family;
90511 /* flush bundles */
90512 - atomic_inc(&pol->genid);
90513 + atomic_inc_unchecked(&pol->genid);
90514 }
90515 }
90516
90517 diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
90518 index 2c341bd..4404211 100644
90519 --- a/net/xfrm/xfrm_state.c
90520 +++ b/net/xfrm/xfrm_state.c
90521 @@ -177,12 +177,14 @@ int xfrm_register_type(const struct xfrm_type *type, unsigned short family)
90522
90523 if (unlikely(afinfo == NULL))
90524 return -EAFNOSUPPORT;
90525 - typemap = afinfo->type_map;
90526 + typemap = (const struct xfrm_type **)afinfo->type_map;
90527 spin_lock_bh(&xfrm_type_lock);
90528
90529 - if (likely(typemap[type->proto] == NULL))
90530 + if (likely(typemap[type->proto] == NULL)) {
90531 + pax_open_kernel();
90532 typemap[type->proto] = type;
90533 - else
90534 + pax_close_kernel();
90535 + } else
90536 err = -EEXIST;
90537 spin_unlock_bh(&xfrm_type_lock);
90538 xfrm_state_put_afinfo(afinfo);
90539 @@ -198,13 +200,16 @@ int xfrm_unregister_type(const struct xfrm_type *type, unsigned short family)
90540
90541 if (unlikely(afinfo == NULL))
90542 return -EAFNOSUPPORT;
90543 - typemap = afinfo->type_map;
90544 + typemap = (const struct xfrm_type **)afinfo->type_map;
90545 spin_lock_bh(&xfrm_type_lock);
90546
90547 if (unlikely(typemap[type->proto] != type))
90548 err = -ENOENT;
90549 - else
90550 + else {
90551 + pax_open_kernel();
90552 typemap[type->proto] = NULL;
90553 + pax_close_kernel();
90554 + }
90555 spin_unlock_bh(&xfrm_type_lock);
90556 xfrm_state_put_afinfo(afinfo);
90557 return err;
90558 @@ -214,7 +219,6 @@ EXPORT_SYMBOL(xfrm_unregister_type);
90559 static const struct xfrm_type *xfrm_get_type(u8 proto, unsigned short family)
90560 {
90561 struct xfrm_state_afinfo *afinfo;
90562 - const struct xfrm_type **typemap;
90563 const struct xfrm_type *type;
90564 int modload_attempted = 0;
90565
90566 @@ -222,9 +226,8 @@ retry:
90567 afinfo = xfrm_state_get_afinfo(family);
90568 if (unlikely(afinfo == NULL))
90569 return NULL;
90570 - typemap = afinfo->type_map;
90571
90572 - type = typemap[proto];
90573 + type = afinfo->type_map[proto];
90574 if (unlikely(type && !try_module_get(type->owner)))
90575 type = NULL;
90576 if (!type && !modload_attempted) {
90577 @@ -258,7 +261,7 @@ int xfrm_register_mode(struct xfrm_mode *mode, int family)
90578 return -EAFNOSUPPORT;
90579
90580 err = -EEXIST;
90581 - modemap = afinfo->mode_map;
90582 + modemap = (struct xfrm_mode **)afinfo->mode_map;
90583 spin_lock_bh(&xfrm_mode_lock);
90584 if (modemap[mode->encap])
90585 goto out;
90586 @@ -267,8 +270,10 @@ int xfrm_register_mode(struct xfrm_mode *mode, int family)
90587 if (!try_module_get(afinfo->owner))
90588 goto out;
90589
90590 - mode->afinfo = afinfo;
90591 + pax_open_kernel();
90592 + *(const void **)&mode->afinfo = afinfo;
90593 modemap[mode->encap] = mode;
90594 + pax_close_kernel();
90595 err = 0;
90596
90597 out:
90598 @@ -292,10 +297,12 @@ int xfrm_unregister_mode(struct xfrm_mode *mode, int family)
90599 return -EAFNOSUPPORT;
90600
90601 err = -ENOENT;
90602 - modemap = afinfo->mode_map;
90603 + modemap = (struct xfrm_mode **)afinfo->mode_map;
90604 spin_lock_bh(&xfrm_mode_lock);
90605 if (likely(modemap[mode->encap] == mode)) {
90606 + pax_open_kernel();
90607 modemap[mode->encap] = NULL;
90608 + pax_close_kernel();
90609 module_put(mode->afinfo->owner);
90610 err = 0;
90611 }
90612 diff --git a/net/xfrm/xfrm_sysctl.c b/net/xfrm/xfrm_sysctl.c
90613 index 05a6e3d..6716ec9 100644
90614 --- a/net/xfrm/xfrm_sysctl.c
90615 +++ b/net/xfrm/xfrm_sysctl.c
90616 @@ -42,7 +42,7 @@ static struct ctl_table xfrm_table[] = {
90617
90618 int __net_init xfrm_sysctl_init(struct net *net)
90619 {
90620 - struct ctl_table *table;
90621 + ctl_table_no_const *table;
90622
90623 __xfrm_sysctl_init(net);
90624
90625 diff --git a/scripts/Makefile.build b/scripts/Makefile.build
90626 index 0e801c3..5c8ad3b 100644
90627 --- a/scripts/Makefile.build
90628 +++ b/scripts/Makefile.build
90629 @@ -111,7 +111,7 @@ endif
90630 endif
90631
90632 # Do not include host rules unless needed
90633 -ifneq ($(hostprogs-y)$(hostprogs-m),)
90634 +ifneq ($(hostprogs-y)$(hostprogs-m)$(hostlibs-y)$(hostlibs-m)$(hostcxxlibs-y)$(hostcxxlibs-m),)
90635 include scripts/Makefile.host
90636 endif
90637
90638 diff --git a/scripts/Makefile.clean b/scripts/Makefile.clean
90639 index 686cb0d..9d653bf 100644
90640 --- a/scripts/Makefile.clean
90641 +++ b/scripts/Makefile.clean
90642 @@ -43,7 +43,8 @@ subdir-ymn := $(addprefix $(obj)/,$(subdir-ymn))
90643 __clean-files := $(extra-y) $(always) \
90644 $(targets) $(clean-files) \
90645 $(host-progs) \
90646 - $(hostprogs-y) $(hostprogs-m) $(hostprogs-)
90647 + $(hostprogs-y) $(hostprogs-m) $(hostprogs-) \
90648 + $(hostlibs-y) $(hostlibs-m) $(hostlibs-)
90649
90650 __clean-files := $(filter-out $(no-clean-files), $(__clean-files))
90651
90652 diff --git a/scripts/Makefile.host b/scripts/Makefile.host
90653 index 1ac414f..38575f7 100644
90654 --- a/scripts/Makefile.host
90655 +++ b/scripts/Makefile.host
90656 @@ -31,6 +31,8 @@
90657 # Note: Shared libraries consisting of C++ files are not supported
90658
90659 __hostprogs := $(sort $(hostprogs-y) $(hostprogs-m))
90660 +__hostlibs := $(sort $(hostlibs-y) $(hostlibs-m))
90661 +__hostcxxlibs := $(sort $(hostcxxlibs-y) $(hostcxxlibs-m))
90662
90663 # C code
90664 # Executables compiled from a single .c file
90665 @@ -54,11 +56,15 @@ host-cxxobjs := $(sort $(foreach m,$(host-cxxmulti),$($(m)-cxxobjs)))
90666 # Shared libaries (only .c supported)
90667 # Shared libraries (.so) - all .so files referenced in "xxx-objs"
90668 host-cshlib := $(sort $(filter %.so, $(host-cobjs)))
90669 +host-cshlib += $(sort $(filter %.so, $(__hostlibs)))
90670 +host-cxxshlib := $(sort $(filter %.so, $(__hostcxxlibs)))
90671 # Remove .so files from "xxx-objs"
90672 host-cobjs := $(filter-out %.so,$(host-cobjs))
90673 +host-cxxobjs := $(filter-out %.so,$(host-cxxobjs))
90674
90675 -#Object (.o) files used by the shared libaries
90676 +# Object (.o) files used by the shared libaries
90677 host-cshobjs := $(sort $(foreach m,$(host-cshlib),$($(m:.so=-objs))))
90678 +host-cxxshobjs := $(sort $(foreach m,$(host-cxxshlib),$($(m:.so=-objs))))
90679
90680 # output directory for programs/.o files
90681 # hostprogs-y := tools/build may have been specified. Retrieve directory
90682 @@ -82,7 +88,9 @@ host-cobjs := $(addprefix $(obj)/,$(host-cobjs))
90683 host-cxxmulti := $(addprefix $(obj)/,$(host-cxxmulti))
90684 host-cxxobjs := $(addprefix $(obj)/,$(host-cxxobjs))
90685 host-cshlib := $(addprefix $(obj)/,$(host-cshlib))
90686 +host-cxxshlib := $(addprefix $(obj)/,$(host-cxxshlib))
90687 host-cshobjs := $(addprefix $(obj)/,$(host-cshobjs))
90688 +host-cxxshobjs := $(addprefix $(obj)/,$(host-cxxshobjs))
90689 host-objdirs := $(addprefix $(obj)/,$(host-objdirs))
90690
90691 obj-dirs += $(host-objdirs)
90692 @@ -156,6 +164,13 @@ quiet_cmd_host-cshobjs = HOSTCC -fPIC $@
90693 $(host-cshobjs): $(obj)/%.o: $(src)/%.c FORCE
90694 $(call if_changed_dep,host-cshobjs)
90695
90696 +# Compile .c file, create position independent .o file
90697 +# host-cxxshobjs -> .o
90698 +quiet_cmd_host-cxxshobjs = HOSTCXX -fPIC $@
90699 + cmd_host-cxxshobjs = $(HOSTCXX) $(hostcxx_flags) -fPIC -c -o $@ $<
90700 +$(host-cxxshobjs): $(obj)/%.o: $(src)/%.c FORCE
90701 + $(call if_changed_dep,host-cxxshobjs)
90702 +
90703 # Link a shared library, based on position independent .o files
90704 # *.o -> .so shared library (host-cshlib)
90705 quiet_cmd_host-cshlib = HOSTLLD -shared $@
90706 @@ -165,6 +180,15 @@ quiet_cmd_host-cshlib = HOSTLLD -shared $@
90707 $(host-cshlib): $(obj)/%: $(host-cshobjs) FORCE
90708 $(call if_changed,host-cshlib)
90709
90710 +# Link a shared library, based on position independent .o files
90711 +# *.o -> .so shared library (host-cxxshlib)
90712 +quiet_cmd_host-cxxshlib = HOSTLLD -shared $@
90713 + cmd_host-cxxshlib = $(HOSTCXX) $(HOSTLDFLAGS) -shared -o $@ \
90714 + $(addprefix $(obj)/,$($(@F:.so=-objs))) \
90715 + $(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F))
90716 +$(host-cxxshlib): $(obj)/%: $(host-cxxshobjs) FORCE
90717 + $(call if_changed,host-cxxshlib)
90718 +
90719 targets += $(host-csingle) $(host-cmulti) $(host-cobjs)\
90720 - $(host-cxxmulti) $(host-cxxobjs) $(host-cshlib) $(host-cshobjs)
90721 + $(host-cxxmulti) $(host-cxxobjs) $(host-cshlib) $(host-cshobjs) $(host-cxxshlib) $(host-cxxshobjs)
90722
90723 diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c
90724 index 7f6425e..9864506 100644
90725 --- a/scripts/basic/fixdep.c
90726 +++ b/scripts/basic/fixdep.c
90727 @@ -161,7 +161,7 @@ static unsigned int strhash(const char *str, unsigned int sz)
90728 /*
90729 * Lookup a value in the configuration string.
90730 */
90731 -static int is_defined_config(const char *name, int len, unsigned int hash)
90732 +static int is_defined_config(const char *name, unsigned int len, unsigned int hash)
90733 {
90734 struct item *aux;
90735
90736 @@ -211,10 +211,10 @@ static void clear_config(void)
90737 /*
90738 * Record the use of a CONFIG_* word.
90739 */
90740 -static void use_config(const char *m, int slen)
90741 +static void use_config(const char *m, unsigned int slen)
90742 {
90743 unsigned int hash = strhash(m, slen);
90744 - int c, i;
90745 + unsigned int c, i;
90746
90747 if (is_defined_config(m, slen, hash))
90748 return;
90749 @@ -235,9 +235,9 @@ static void use_config(const char *m, int slen)
90750
90751 static void parse_config_file(const char *map, size_t len)
90752 {
90753 - const int *end = (const int *) (map + len);
90754 + const unsigned int *end = (const unsigned int *) (map + len);
90755 /* start at +1, so that p can never be < map */
90756 - const int *m = (const int *) map + 1;
90757 + const unsigned int *m = (const unsigned int *) map + 1;
90758 const char *p, *q;
90759
90760 for (; m < end; m++) {
90761 @@ -406,7 +406,7 @@ static void print_deps(void)
90762 static void traps(void)
90763 {
90764 static char test[] __attribute__((aligned(sizeof(int)))) = "CONF";
90765 - int *p = (int *)test;
90766 + unsigned int *p = (unsigned int *)test;
90767
90768 if (*p != INT_CONF) {
90769 fprintf(stderr, "fixdep: sizeof(int) != 4 or wrong endianness? %#x\n",
90770 diff --git a/scripts/gcc-plugin.sh b/scripts/gcc-plugin.sh
90771 new file mode 100644
90772 index 0000000..5e0222d
90773 --- /dev/null
90774 +++ b/scripts/gcc-plugin.sh
90775 @@ -0,0 +1,17 @@
90776 +#!/bin/bash
90777 +plugincc=`$1 -E -shared - -o /dev/null -I\`$3 -print-file-name=plugin\`/include 2>&1 <<EOF
90778 +#include "gcc-plugin.h"
90779 +#include "tree.h"
90780 +#include "tm.h"
90781 +#include "rtl.h"
90782 +#ifdef ENABLE_BUILD_WITH_CXX
90783 +#warning $2
90784 +#else
90785 +#warning $1
90786 +#endif
90787 +EOF`
90788 +if [ $? -eq 0 ]
90789 +then
90790 + [[ "$plugincc" =~ "$1" ]] && echo "$1"
90791 + [[ "$plugincc" =~ "$2" ]] && echo "$2"
90792 +fi
90793 diff --git a/scripts/headers_install.pl b/scripts/headers_install.pl
90794 index 581ca99..a6ff02e 100644
90795 --- a/scripts/headers_install.pl
90796 +++ b/scripts/headers_install.pl
90797 @@ -35,6 +35,7 @@ foreach my $filename (@files) {
90798 $line =~ s/([\s(])__user\s/$1/g;
90799 $line =~ s/([\s(])__force\s/$1/g;
90800 $line =~ s/([\s(])__iomem\s/$1/g;
90801 + $line =~ s/(\s?)__intentional_overflow\([-\d\s,]*\)\s?/$1/g;
90802 $line =~ s/\s__attribute_const__\s/ /g;
90803 $line =~ s/\s__attribute_const__$//g;
90804 $line =~ s/\b__packed\b/__attribute__((packed))/g;
90805 diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
90806 index 3d569d6..0c09522 100644
90807 --- a/scripts/link-vmlinux.sh
90808 +++ b/scripts/link-vmlinux.sh
90809 @@ -159,7 +159,7 @@ else
90810 fi;
90811
90812 # final build of init/
90813 -${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init
90814 +${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init GCC_PLUGINS_CFLAGS="${GCC_PLUGINS_CFLAGS}" GCC_PLUGINS_AFLAGS="${GCC_PLUGINS_AFLAGS}"
90815
90816 kallsymso=""
90817 kallsyms_vmlinux=""
90818 diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
90819 index 771ac17..9f0d3ee 100644
90820 --- a/scripts/mod/file2alias.c
90821 +++ b/scripts/mod/file2alias.c
90822 @@ -140,7 +140,7 @@ static void device_id_check(const char *modname, const char *device_id,
90823 unsigned long size, unsigned long id_size,
90824 void *symval)
90825 {
90826 - int i;
90827 + unsigned int i;
90828
90829 if (size % id_size || size < id_size) {
90830 fatal("%s: sizeof(struct %s_device_id)=%lu is not a modulo "
90831 @@ -168,7 +168,7 @@ static void device_id_check(const char *modname, const char *device_id,
90832 /* USB is special because the bcdDevice can be matched against a numeric range */
90833 /* Looks like "usb:vNpNdNdcNdscNdpNicNiscNipNinN" */
90834 static void do_usb_entry(void *symval,
90835 - unsigned int bcdDevice_initial, int bcdDevice_initial_digits,
90836 + unsigned int bcdDevice_initial, unsigned int bcdDevice_initial_digits,
90837 unsigned char range_lo, unsigned char range_hi,
90838 unsigned char max, struct module *mod)
90839 {
90840 @@ -278,7 +278,7 @@ static void do_usb_entry_multi(void *symval, struct module *mod)
90841 {
90842 unsigned int devlo, devhi;
90843 unsigned char chi, clo, max;
90844 - int ndigits;
90845 + unsigned int ndigits;
90846
90847 DEF_FIELD(symval, usb_device_id, match_flags);
90848 DEF_FIELD(symval, usb_device_id, idVendor);
90849 @@ -531,7 +531,7 @@ static void do_pnp_device_entry(void *symval, unsigned long size,
90850 for (i = 0; i < count; i++) {
90851 DEF_FIELD_ADDR(symval + i*id_size, pnp_device_id, id);
90852 char acpi_id[sizeof(*id)];
90853 - int j;
90854 + unsigned int j;
90855
90856 buf_printf(&mod->dev_table_buf,
90857 "MODULE_ALIAS(\"pnp:d%s*\");\n", *id);
90858 @@ -560,7 +560,7 @@ static void do_pnp_card_entries(void *symval, unsigned long size,
90859
90860 for (j = 0; j < PNP_MAX_DEVICES; j++) {
90861 const char *id = (char *)(*devs)[j].id;
90862 - int i2, j2;
90863 + unsigned int i2, j2;
90864 int dup = 0;
90865
90866 if (!id[0])
90867 @@ -586,7 +586,7 @@ static void do_pnp_card_entries(void *symval, unsigned long size,
90868 /* add an individual alias for every device entry */
90869 if (!dup) {
90870 char acpi_id[PNP_ID_LEN];
90871 - int k;
90872 + unsigned int k;
90873
90874 buf_printf(&mod->dev_table_buf,
90875 "MODULE_ALIAS(\"pnp:d%s*\");\n", id);
90876 @@ -938,7 +938,7 @@ static void dmi_ascii_filter(char *d, const char *s)
90877 static int do_dmi_entry(const char *filename, void *symval,
90878 char *alias)
90879 {
90880 - int i, j;
90881 + unsigned int i, j;
90882 DEF_FIELD_ADDR(symval, dmi_system_id, matches);
90883 sprintf(alias, "dmi*");
90884
90885 diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
90886 index 78b30c1..536850d 100644
90887 --- a/scripts/mod/modpost.c
90888 +++ b/scripts/mod/modpost.c
90889 @@ -931,6 +931,7 @@ enum mismatch {
90890 ANY_INIT_TO_ANY_EXIT,
90891 ANY_EXIT_TO_ANY_INIT,
90892 EXPORT_TO_INIT_EXIT,
90893 + DATA_TO_TEXT
90894 };
90895
90896 struct sectioncheck {
90897 @@ -1045,6 +1046,12 @@ const struct sectioncheck sectioncheck[] = {
90898 .tosec = { INIT_SECTIONS, EXIT_SECTIONS, NULL },
90899 .mismatch = EXPORT_TO_INIT_EXIT,
90900 .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL },
90901 +},
90902 +/* Do not reference code from writable data */
90903 +{
90904 + .fromsec = { DATA_SECTIONS, NULL },
90905 + .tosec = { TEXT_SECTIONS, NULL },
90906 + .mismatch = DATA_TO_TEXT
90907 }
90908 };
90909
90910 @@ -1167,10 +1174,10 @@ static Elf_Sym *find_elf_symbol(struct elf_info *elf, Elf64_Sword addr,
90911 continue;
90912 if (ELF_ST_TYPE(sym->st_info) == STT_SECTION)
90913 continue;
90914 - if (sym->st_value == addr)
90915 - return sym;
90916 /* Find a symbol nearby - addr are maybe negative */
90917 d = sym->st_value - addr;
90918 + if (d == 0)
90919 + return sym;
90920 if (d < 0)
90921 d = addr - sym->st_value;
90922 if (d < distance) {
90923 @@ -1449,6 +1456,14 @@ static void report_sec_mismatch(const char *modname,
90924 tosym, prl_to, prl_to, tosym);
90925 free(prl_to);
90926 break;
90927 + case DATA_TO_TEXT:
90928 +#if 0
90929 + fprintf(stderr,
90930 + "The %s %s:%s references\n"
90931 + "the %s %s:%s%s\n",
90932 + from, fromsec, fromsym, to, tosec, tosym, to_p);
90933 +#endif
90934 + break;
90935 }
90936 fprintf(stderr, "\n");
90937 }
90938 @@ -1683,7 +1698,7 @@ static void section_rel(const char *modname, struct elf_info *elf,
90939 static void check_sec_ref(struct module *mod, const char *modname,
90940 struct elf_info *elf)
90941 {
90942 - int i;
90943 + unsigned int i;
90944 Elf_Shdr *sechdrs = elf->sechdrs;
90945
90946 /* Walk through all sections */
90947 @@ -1781,7 +1796,7 @@ void __attribute__((format(printf, 2, 3))) buf_printf(struct buffer *buf,
90948 va_end(ap);
90949 }
90950
90951 -void buf_write(struct buffer *buf, const char *s, int len)
90952 +void buf_write(struct buffer *buf, const char *s, unsigned int len)
90953 {
90954 if (buf->size - buf->pos < len) {
90955 buf->size += len + SZ;
90956 @@ -1999,7 +2014,7 @@ static void write_if_changed(struct buffer *b, const char *fname)
90957 if (fstat(fileno(file), &st) < 0)
90958 goto close_write;
90959
90960 - if (st.st_size != b->pos)
90961 + if (st.st_size != (off_t)b->pos)
90962 goto close_write;
90963
90964 tmp = NOFAIL(malloc(b->pos));
90965 diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h
90966 index 51207e4..f7d603d 100644
90967 --- a/scripts/mod/modpost.h
90968 +++ b/scripts/mod/modpost.h
90969 @@ -92,15 +92,15 @@ void *do_nofail(void *ptr, const char *expr);
90970
90971 struct buffer {
90972 char *p;
90973 - int pos;
90974 - int size;
90975 + unsigned int pos;
90976 + unsigned int size;
90977 };
90978
90979 void __attribute__((format(printf, 2, 3)))
90980 buf_printf(struct buffer *buf, const char *fmt, ...);
90981
90982 void
90983 -buf_write(struct buffer *buf, const char *s, int len);
90984 +buf_write(struct buffer *buf, const char *s, unsigned int len);
90985
90986 struct module {
90987 struct module *next;
90988 diff --git a/scripts/mod/sumversion.c b/scripts/mod/sumversion.c
90989 index 9dfcd6d..099068e 100644
90990 --- a/scripts/mod/sumversion.c
90991 +++ b/scripts/mod/sumversion.c
90992 @@ -470,7 +470,7 @@ static void write_version(const char *filename, const char *sum,
90993 goto out;
90994 }
90995
90996 - if (write(fd, sum, strlen(sum)+1) != strlen(sum)+1) {
90997 + if (write(fd, sum, strlen(sum)+1) != (ssize_t)strlen(sum)+1) {
90998 warn("writing sum in %s failed: %s\n",
90999 filename, strerror(errno));
91000 goto out;
91001 diff --git a/scripts/package/builddeb b/scripts/package/builddeb
91002 index acb8650..b8c5f02 100644
91003 --- a/scripts/package/builddeb
91004 +++ b/scripts/package/builddeb
91005 @@ -246,6 +246,7 @@ fi
91006 (cd $srctree; find . -name Makefile\* -o -name Kconfig\* -o -name \*.pl > "$objtree/debian/hdrsrcfiles")
91007 (cd $srctree; find arch/$SRCARCH/include include scripts -type f >> "$objtree/debian/hdrsrcfiles")
91008 (cd $objtree; find arch/$SRCARCH/include .config Module.symvers include scripts -type f >> "$objtree/debian/hdrobjfiles")
91009 +(cd $objtree; find tools/gcc -name \*.so >> "$objtree/debian/hdrobjfiles")
91010 destdir=$kernel_headers_dir/usr/src/linux-headers-$version
91011 mkdir -p "$destdir"
91012 (cd $srctree; tar -c -f - -T "$objtree/debian/hdrsrcfiles") | (cd $destdir; tar -xf -)
91013 diff --git a/scripts/pnmtologo.c b/scripts/pnmtologo.c
91014 index 68bb4ef..2f419e1 100644
91015 --- a/scripts/pnmtologo.c
91016 +++ b/scripts/pnmtologo.c
91017 @@ -244,14 +244,14 @@ static void write_header(void)
91018 fprintf(out, " * Linux logo %s\n", logoname);
91019 fputs(" */\n\n", out);
91020 fputs("#include <linux/linux_logo.h>\n\n", out);
91021 - fprintf(out, "static unsigned char %s_data[] __initdata = {\n",
91022 + fprintf(out, "static unsigned char %s_data[] = {\n",
91023 logoname);
91024 }
91025
91026 static void write_footer(void)
91027 {
91028 fputs("\n};\n\n", out);
91029 - fprintf(out, "const struct linux_logo %s __initconst = {\n", logoname);
91030 + fprintf(out, "const struct linux_logo %s = {\n", logoname);
91031 fprintf(out, "\t.type\t\t= %s,\n", logo_types[logo_type]);
91032 fprintf(out, "\t.width\t\t= %d,\n", logo_width);
91033 fprintf(out, "\t.height\t\t= %d,\n", logo_height);
91034 @@ -381,7 +381,7 @@ static void write_logo_clut224(void)
91035 fputs("\n};\n\n", out);
91036
91037 /* write logo clut */
91038 - fprintf(out, "static unsigned char %s_clut[] __initdata = {\n",
91039 + fprintf(out, "static unsigned char %s_clut[] = {\n",
91040 logoname);
91041 write_hex_cnt = 0;
91042 for (i = 0; i < logo_clutsize; i++) {
91043 diff --git a/scripts/sortextable.h b/scripts/sortextable.h
91044 index f5eb43d..1814de8 100644
91045 --- a/scripts/sortextable.h
91046 +++ b/scripts/sortextable.h
91047 @@ -106,9 +106,9 @@ do_func(Elf_Ehdr *ehdr, char const *const fname, table_sort_t custom_sort)
91048 const char *secstrtab;
91049 const char *strtab;
91050 char *extab_image;
91051 - int extab_index = 0;
91052 - int i;
91053 - int idx;
91054 + unsigned int extab_index = 0;
91055 + unsigned int i;
91056 + unsigned int idx;
91057
91058 shdr = (Elf_Shdr *)((char *)ehdr + _r(&ehdr->e_shoff));
91059 shstrtab_sec = shdr + r2(&ehdr->e_shstrndx);
91060 diff --git a/security/Kconfig b/security/Kconfig
91061 index e9c6ac7..e6254cf 100644
91062 --- a/security/Kconfig
91063 +++ b/security/Kconfig
91064 @@ -4,6 +4,944 @@
91065
91066 menu "Security options"
91067
91068 +menu "Grsecurity"
91069 +
91070 + config ARCH_TRACK_EXEC_LIMIT
91071 + bool
91072 +
91073 + config PAX_KERNEXEC_PLUGIN
91074 + bool
91075 +
91076 + config PAX_PER_CPU_PGD
91077 + bool
91078 +
91079 + config TASK_SIZE_MAX_SHIFT
91080 + int
91081 + depends on X86_64
91082 + default 47 if !PAX_PER_CPU_PGD
91083 + default 42 if PAX_PER_CPU_PGD
91084 +
91085 + config PAX_ENABLE_PAE
91086 + bool
91087 + default y if (X86_32 && (MPENTIUM4 || MK8 || MPSC || MCORE2 || MATOM))
91088 +
91089 + config PAX_USERCOPY_SLABS
91090 + bool
91091 +
91092 +config GRKERNSEC
91093 + bool "Grsecurity"
91094 + select CRYPTO
91095 + select CRYPTO_SHA256
91096 + select PROC_FS
91097 + select STOP_MACHINE
91098 + select TTY
91099 + help
91100 + If you say Y here, you will be able to configure many features
91101 + that will enhance the security of your system. It is highly
91102 + recommended that you say Y here and read through the help
91103 + for each option so that you fully understand the features and
91104 + can evaluate their usefulness for your machine.
91105 +
91106 +choice
91107 + prompt "Configuration Method"
91108 + depends on GRKERNSEC
91109 + default GRKERNSEC_CONFIG_CUSTOM
91110 + help
91111 +
91112 +config GRKERNSEC_CONFIG_AUTO
91113 + bool "Automatic"
91114 + help
91115 + If you choose this configuration method, you'll be able to answer a small
91116 + number of simple questions about how you plan to use this kernel.
91117 + The settings of grsecurity and PaX will be automatically configured for
91118 + the highest commonly-used settings within the provided constraints.
91119 +
91120 + If you require additional configuration, custom changes can still be made
91121 + from the "custom configuration" menu.
91122 +
91123 +config GRKERNSEC_CONFIG_CUSTOM
91124 + bool "Custom"
91125 + help
91126 + If you choose this configuration method, you'll be able to configure all
91127 + grsecurity and PaX settings manually. Via this method, no options are
91128 + automatically enabled.
91129 +
91130 +endchoice
91131 +
91132 +choice
91133 + prompt "Usage Type"
91134 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
91135 + default GRKERNSEC_CONFIG_SERVER
91136 + help
91137 +
91138 +config GRKERNSEC_CONFIG_SERVER
91139 + bool "Server"
91140 + help
91141 + Choose this option if you plan to use this kernel on a server.
91142 +
91143 +config GRKERNSEC_CONFIG_DESKTOP
91144 + bool "Desktop"
91145 + help
91146 + Choose this option if you plan to use this kernel on a desktop.
91147 +
91148 +endchoice
91149 +
91150 +choice
91151 + prompt "Virtualization Type"
91152 + depends on (GRKERNSEC && X86 && GRKERNSEC_CONFIG_AUTO)
91153 + default GRKERNSEC_CONFIG_VIRT_NONE
91154 + help
91155 +
91156 +config GRKERNSEC_CONFIG_VIRT_NONE
91157 + bool "None"
91158 + help
91159 + Choose this option if this kernel will be run on bare metal.
91160 +
91161 +config GRKERNSEC_CONFIG_VIRT_GUEST
91162 + bool "Guest"
91163 + help
91164 + Choose this option if this kernel will be run as a VM guest.
91165 +
91166 +config GRKERNSEC_CONFIG_VIRT_HOST
91167 + bool "Host"
91168 + help
91169 + Choose this option if this kernel will be run as a VM host.
91170 +
91171 +endchoice
91172 +
91173 +choice
91174 + prompt "Virtualization Hardware"
91175 + depends on (GRKERNSEC && X86 && GRKERNSEC_CONFIG_AUTO && (GRKERNSEC_CONFIG_VIRT_GUEST || GRKERNSEC_CONFIG_VIRT_HOST))
91176 + help
91177 +
91178 +config GRKERNSEC_CONFIG_VIRT_EPT
91179 + bool "EPT/RVI Processor Support"
91180 + depends on X86
91181 + help
91182 + Choose this option if your CPU supports the EPT or RVI features of 2nd-gen
91183 + hardware virtualization. This allows for additional kernel hardening protections
91184 + to operate without additional performance impact.
91185 +
91186 + To see if your Intel processor supports EPT, see:
91187 + http://ark.intel.com/Products/VirtualizationTechnology
91188 + (Most Core i3/5/7 support EPT)
91189 +
91190 + To see if your AMD processor supports RVI, see:
91191 + http://support.amd.com/us/kbarticles/Pages/GPU120AMDRVICPUsHyperVWin8.aspx
91192 +
91193 +config GRKERNSEC_CONFIG_VIRT_SOFT
91194 + bool "First-gen/No Hardware Virtualization"
91195 + help
91196 + Choose this option if you use an Atom/Pentium/Core 2 processor that either doesn't
91197 + support hardware virtualization or doesn't support the EPT/RVI extensions.
91198 +
91199 +endchoice
91200 +
91201 +choice
91202 + prompt "Virtualization Software"
91203 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO && (GRKERNSEC_CONFIG_VIRT_GUEST || GRKERNSEC_CONFIG_VIRT_HOST))
91204 + help
91205 +
91206 +config GRKERNSEC_CONFIG_VIRT_XEN
91207 + bool "Xen"
91208 + help
91209 + Choose this option if this kernel is running as a Xen guest or host.
91210 +
91211 +config GRKERNSEC_CONFIG_VIRT_VMWARE
91212 + bool "VMWare"
91213 + help
91214 + Choose this option if this kernel is running as a VMWare guest or host.
91215 +
91216 +config GRKERNSEC_CONFIG_VIRT_KVM
91217 + bool "KVM"
91218 + help
91219 + Choose this option if this kernel is running as a KVM guest or host.
91220 +
91221 +config GRKERNSEC_CONFIG_VIRT_VIRTUALBOX
91222 + bool "VirtualBox"
91223 + help
91224 + Choose this option if this kernel is running as a VirtualBox guest or host.
91225 +
91226 +endchoice
91227 +
91228 +choice
91229 + prompt "Required Priorities"
91230 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
91231 + default GRKERNSEC_CONFIG_PRIORITY_PERF
91232 + help
91233 +
91234 +config GRKERNSEC_CONFIG_PRIORITY_PERF
91235 + bool "Performance"
91236 + help
91237 + Choose this option if performance is of highest priority for this deployment
91238 + of grsecurity. Features like UDEREF on a 64bit kernel, kernel stack clearing,
91239 + clearing of structures intended for userland, and freed memory sanitizing will
91240 + be disabled.
91241 +
91242 +config GRKERNSEC_CONFIG_PRIORITY_SECURITY
91243 + bool "Security"
91244 + help
91245 + Choose this option if security is of highest priority for this deployment of
91246 + grsecurity. UDEREF, kernel stack clearing, clearing of structures intended
91247 + for userland, and freed memory sanitizing will be enabled for this kernel.
91248 + In a worst-case scenario, these features can introduce a 20% performance hit
91249 + (UDEREF on x64 contributing half of this hit).
91250 +
91251 +endchoice
91252 +
91253 +menu "Default Special Groups"
91254 +depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
91255 +
91256 +config GRKERNSEC_PROC_GID
91257 + int "GID exempted from /proc restrictions"
91258 + default 1001
91259 + help
91260 + Setting this GID determines which group will be exempted from
91261 + grsecurity's /proc restrictions, allowing users of the specified
91262 + group to view network statistics and the existence of other users'
91263 + processes on the system. This GID may also be chosen at boot time
91264 + via "grsec_proc_gid=" on the kernel commandline.
91265 +
91266 +config GRKERNSEC_TPE_UNTRUSTED_GID
91267 + int "GID for TPE-untrusted users"
91268 + depends on GRKERNSEC_CONFIG_SERVER && GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT
91269 + default 1005
91270 + help
91271 + Setting this GID determines which group untrusted users should
91272 + be added to. These users will be placed under grsecurity's Trusted Path
91273 + Execution mechanism, preventing them from executing their own binaries.
91274 + The users will only be able to execute binaries in directories owned and
91275 + writable only by the root user. If the sysctl option is enabled, a sysctl
91276 + option with name "tpe_gid" is created.
91277 +
91278 +config GRKERNSEC_TPE_TRUSTED_GID
91279 + int "GID for TPE-trusted users"
91280 + depends on GRKERNSEC_CONFIG_SERVER && GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT
91281 + default 1005
91282 + help
91283 + Setting this GID determines what group TPE restrictions will be
91284 + *disabled* for. If the sysctl option is enabled, a sysctl option
91285 + with name "tpe_gid" is created.
91286 +
91287 +config GRKERNSEC_SYMLINKOWN_GID
91288 + int "GID for users with kernel-enforced SymlinksIfOwnerMatch"
91289 + depends on GRKERNSEC_CONFIG_SERVER
91290 + default 1006
91291 + help
91292 + Setting this GID determines what group kernel-enforced
91293 + SymlinksIfOwnerMatch will be enabled for. If the sysctl option
91294 + is enabled, a sysctl option with name "symlinkown_gid" is created.
91295 +
91296 +
91297 +endmenu
91298 +
91299 +menu "Customize Configuration"
91300 +depends on GRKERNSEC
91301 +
91302 +menu "PaX"
91303 +
91304 +config PAX
91305 + bool "Enable various PaX features"
91306 + default y if GRKERNSEC_CONFIG_AUTO
91307 + depends on GRKERNSEC && (ALPHA || ARM || AVR32 || IA64 || MIPS || PARISC || PPC || SPARC || X86)
91308 + help
91309 + This allows you to enable various PaX features. PaX adds
91310 + intrusion prevention mechanisms to the kernel that reduce
91311 + the risks posed by exploitable memory corruption bugs.
91312 +
91313 +menu "PaX Control"
91314 + depends on PAX
91315 +
91316 +config PAX_SOFTMODE
91317 + bool 'Support soft mode'
91318 + help
91319 + Enabling this option will allow you to run PaX in soft mode, that
91320 + is, PaX features will not be enforced by default, only on executables
91321 + marked explicitly. You must also enable PT_PAX_FLAGS or XATTR_PAX_FLAGS
91322 + support as they are the only way to mark executables for soft mode use.
91323 +
91324 + Soft mode can be activated by using the "pax_softmode=1" kernel command
91325 + line option on boot. Furthermore you can control various PaX features
91326 + at runtime via the entries in /proc/sys/kernel/pax.
91327 +
91328 +config PAX_EI_PAX
91329 + bool 'Use legacy ELF header marking'
91330 + default y if GRKERNSEC_CONFIG_AUTO
91331 + help
91332 + Enabling this option will allow you to control PaX features on
91333 + a per executable basis via the 'chpax' utility available at
91334 + http://pax.grsecurity.net/. The control flags will be read from
91335 + an otherwise reserved part of the ELF header. This marking has
91336 + numerous drawbacks (no support for soft-mode, toolchain does not
91337 + know about the non-standard use of the ELF header) therefore it
91338 + has been deprecated in favour of PT_PAX_FLAGS and XATTR_PAX_FLAGS
91339 + support.
91340 +
91341 + Note that if you enable PT_PAX_FLAGS or XATTR_PAX_FLAGS marking
91342 + support as well, they will override the legacy EI_PAX marks.
91343 +
91344 + If you enable none of the marking options then all applications
91345 + will run with PaX enabled on them by default.
91346 +
91347 +config PAX_PT_PAX_FLAGS
91348 + bool 'Use ELF program header marking'
91349 + default y if GRKERNSEC_CONFIG_AUTO
91350 + help
91351 + Enabling this option will allow you to control PaX features on
91352 + a per executable basis via the 'paxctl' utility available at
91353 + http://pax.grsecurity.net/. The control flags will be read from
91354 + a PaX specific ELF program header (PT_PAX_FLAGS). This marking
91355 + has the benefits of supporting both soft mode and being fully
91356 + integrated into the toolchain (the binutils patch is available
91357 + from http://pax.grsecurity.net).
91358 +
91359 + Note that if you enable the legacy EI_PAX marking support as well,
91360 + the EI_PAX marks will be overridden by the PT_PAX_FLAGS marks.
91361 +
91362 + If you enable both PT_PAX_FLAGS and XATTR_PAX_FLAGS support then you
91363 + must make sure that the marks are the same if a binary has both marks.
91364 +
91365 + If you enable none of the marking options then all applications
91366 + will run with PaX enabled on them by default.
91367 +
91368 +config PAX_XATTR_PAX_FLAGS
91369 + bool 'Use filesystem extended attributes marking'
91370 + default y if GRKERNSEC_CONFIG_AUTO
91371 + select CIFS_XATTR if CIFS
91372 + select EXT2_FS_XATTR if EXT2_FS
91373 + select EXT3_FS_XATTR if EXT3_FS
91374 + select EXT4_FS_XATTR if EXT4_FS
91375 + select JFFS2_FS_XATTR if JFFS2_FS
91376 + select REISERFS_FS_XATTR if REISERFS_FS
91377 + select SQUASHFS_XATTR if SQUASHFS
91378 + select TMPFS_XATTR if TMPFS
91379 + select UBIFS_FS_XATTR if UBIFS_FS
91380 + help
91381 + Enabling this option will allow you to control PaX features on
91382 + a per executable basis via the 'setfattr' utility. The control
91383 + flags will be read from the user.pax.flags extended attribute of
91384 + the file. This marking has the benefit of supporting binary-only
91385 + applications that self-check themselves (e.g., skype) and would
91386 + not tolerate chpax/paxctl changes. The main drawback is that
91387 + extended attributes are not supported by some filesystems (e.g.,
91388 + isofs, udf, vfat) so copying files through such filesystems will
91389 + lose the extended attributes and these PaX markings.
91390 +
91391 + Note that if you enable the legacy EI_PAX marking support as well,
91392 + the EI_PAX marks will be overridden by the XATTR_PAX_FLAGS marks.
91393 +
91394 + If you enable both PT_PAX_FLAGS and XATTR_PAX_FLAGS support then you
91395 + must make sure that the marks are the same if a binary has both marks.
91396 +
91397 + If you enable none of the marking options then all applications
91398 + will run with PaX enabled on them by default.
91399 +
91400 +choice
91401 + prompt 'MAC system integration'
91402 + default PAX_HAVE_ACL_FLAGS
91403 + help
91404 + Mandatory Access Control systems have the option of controlling
91405 + PaX flags on a per executable basis, choose the method supported
91406 + by your particular system.
91407 +
91408 + - "none": if your MAC system does not interact with PaX,
91409 + - "direct": if your MAC system defines pax_set_initial_flags() itself,
91410 + - "hook": if your MAC system uses the pax_set_initial_flags_func callback.
91411 +
91412 + NOTE: this option is for developers/integrators only.
91413 +
91414 + config PAX_NO_ACL_FLAGS
91415 + bool 'none'
91416 +
91417 + config PAX_HAVE_ACL_FLAGS
91418 + bool 'direct'
91419 +
91420 + config PAX_HOOK_ACL_FLAGS
91421 + bool 'hook'
91422 +endchoice
91423 +
91424 +endmenu
91425 +
91426 +menu "Non-executable pages"
91427 + depends on PAX
91428 +
91429 +config PAX_NOEXEC
91430 + bool "Enforce non-executable pages"
91431 + default y if GRKERNSEC_CONFIG_AUTO
91432 + depends on ALPHA || (ARM && (CPU_V6 || CPU_V7)) || IA64 || MIPS || PARISC || PPC || S390 || SPARC || X86
91433 + help
91434 + By design some architectures do not allow for protecting memory
91435 + pages against execution or even if they do, Linux does not make
91436 + use of this feature. In practice this means that if a page is
91437 + readable (such as the stack or heap) it is also executable.
91438 +
91439 + There is a well known exploit technique that makes use of this
91440 + fact and a common programming mistake where an attacker can
91441 + introduce code of his choice somewhere in the attacked program's
91442 + memory (typically the stack or the heap) and then execute it.
91443 +
91444 + If the attacked program was running with different (typically
91445 + higher) privileges than that of the attacker, then he can elevate
91446 + his own privilege level (e.g. get a root shell, write to files for
91447 + which he does not have write access to, etc).
91448 +
91449 + Enabling this option will let you choose from various features
91450 + that prevent the injection and execution of 'foreign' code in
91451 + a program.
91452 +
91453 + This will also break programs that rely on the old behaviour and
91454 + expect that dynamically allocated memory via the malloc() family
91455 + of functions is executable (which it is not). Notable examples
91456 + are the XFree86 4.x server, the java runtime and wine.
91457 +
91458 +config PAX_PAGEEXEC
91459 + bool "Paging based non-executable pages"
91460 + default y if GRKERNSEC_CONFIG_AUTO
91461 + 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)
91462 + select S390_SWITCH_AMODE if S390
91463 + select S390_EXEC_PROTECT if S390
91464 + select ARCH_TRACK_EXEC_LIMIT if X86_32
91465 + help
91466 + This implementation is based on the paging feature of the CPU.
91467 + On i386 without hardware non-executable bit support there is a
91468 + variable but usually low performance impact, however on Intel's
91469 + P4 core based CPUs it is very high so you should not enable this
91470 + for kernels meant to be used on such CPUs.
91471 +
91472 + On alpha, avr32, ia64, parisc, sparc, sparc64, x86_64 and i386
91473 + with hardware non-executable bit support there is no performance
91474 + impact, on ppc the impact is negligible.
91475 +
91476 + Note that several architectures require various emulations due to
91477 + badly designed userland ABIs, this will cause a performance impact
91478 + but will disappear as soon as userland is fixed. For example, ppc
91479 + userland MUST have been built with secure-plt by a recent toolchain.
91480 +
91481 +config PAX_SEGMEXEC
91482 + bool "Segmentation based non-executable pages"
91483 + default y if GRKERNSEC_CONFIG_AUTO
91484 + depends on PAX_NOEXEC && X86_32
91485 + help
91486 + This implementation is based on the segmentation feature of the
91487 + CPU and has a very small performance impact, however applications
91488 + will be limited to a 1.5 GB address space instead of the normal
91489 + 3 GB.
91490 +
91491 +config PAX_EMUTRAMP
91492 + bool "Emulate trampolines" if (PAX_PAGEEXEC || PAX_SEGMEXEC) && (PARISC || X86)
91493 + default y if PARISC
91494 + help
91495 + There are some programs and libraries that for one reason or
91496 + another attempt to execute special small code snippets from
91497 + non-executable memory pages. Most notable examples are the
91498 + signal handler return code generated by the kernel itself and
91499 + the GCC trampolines.
91500 +
91501 + If you enabled CONFIG_PAX_PAGEEXEC or CONFIG_PAX_SEGMEXEC then
91502 + such programs will no longer work under your kernel.
91503 +
91504 + As a remedy you can say Y here and use the 'chpax' or 'paxctl'
91505 + utilities to enable trampoline emulation for the affected programs
91506 + yet still have the protection provided by the non-executable pages.
91507 +
91508 + On parisc you MUST enable this option and EMUSIGRT as well, otherwise
91509 + your system will not even boot.
91510 +
91511 + Alternatively you can say N here and use the 'chpax' or 'paxctl'
91512 + utilities to disable CONFIG_PAX_PAGEEXEC and CONFIG_PAX_SEGMEXEC
91513 + for the affected files.
91514 +
91515 + NOTE: enabling this feature *may* open up a loophole in the
91516 + protection provided by non-executable pages that an attacker
91517 + could abuse. Therefore the best solution is to not have any
91518 + files on your system that would require this option. This can
91519 + be achieved by not using libc5 (which relies on the kernel
91520 + signal handler return code) and not using or rewriting programs
91521 + that make use of the nested function implementation of GCC.
91522 + Skilled users can just fix GCC itself so that it implements
91523 + nested function calls in a way that does not interfere with PaX.
91524 +
91525 +config PAX_EMUSIGRT
91526 + bool "Automatically emulate sigreturn trampolines"
91527 + depends on PAX_EMUTRAMP && PARISC
91528 + default y
91529 + help
91530 + Enabling this option will have the kernel automatically detect
91531 + and emulate signal return trampolines executing on the stack
91532 + that would otherwise lead to task termination.
91533 +
91534 + This solution is intended as a temporary one for users with
91535 + legacy versions of libc (libc5, glibc 2.0, uClibc before 0.9.17,
91536 + Modula-3 runtime, etc) or executables linked to such, basically
91537 + everything that does not specify its own SA_RESTORER function in
91538 + normal executable memory like glibc 2.1+ does.
91539 +
91540 + On parisc you MUST enable this option, otherwise your system will
91541 + not even boot.
91542 +
91543 + NOTE: this feature cannot be disabled on a per executable basis
91544 + and since it *does* open up a loophole in the protection provided
91545 + by non-executable pages, the best solution is to not have any
91546 + files on your system that would require this option.
91547 +
91548 +config PAX_MPROTECT
91549 + bool "Restrict mprotect()"
91550 + default y if GRKERNSEC_CONFIG_AUTO
91551 + depends on (PAX_PAGEEXEC || PAX_SEGMEXEC)
91552 + help
91553 + Enabling this option will prevent programs from
91554 + - changing the executable status of memory pages that were
91555 + not originally created as executable,
91556 + - making read-only executable pages writable again,
91557 + - creating executable pages from anonymous memory,
91558 + - making read-only-after-relocations (RELRO) data pages writable again.
91559 +
91560 + You should say Y here to complete the protection provided by
91561 + the enforcement of non-executable pages.
91562 +
91563 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control
91564 + this feature on a per file basis.
91565 +
91566 +config PAX_MPROTECT_COMPAT
91567 + bool "Use legacy/compat protection demoting (read help)"
91568 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_DESKTOP)
91569 + depends on PAX_MPROTECT
91570 + help
91571 + The current implementation of PAX_MPROTECT denies RWX allocations/mprotects
91572 + by sending the proper error code to the application. For some broken
91573 + userland, this can cause problems with Python or other applications. The
91574 + current implementation however allows for applications like clamav to
91575 + detect if JIT compilation/execution is allowed and to fall back gracefully
91576 + to an interpreter-based mode if it does not. While we encourage everyone
91577 + to use the current implementation as-is and push upstream to fix broken
91578 + userland (note that the RWX logging option can assist with this), in some
91579 + environments this may not be possible. Having to disable MPROTECT
91580 + completely on certain binaries reduces the security benefit of PaX,
91581 + so this option is provided for those environments to revert to the old
91582 + behavior.
91583 +
91584 +config PAX_ELFRELOCS
91585 + bool "Allow ELF text relocations (read help)"
91586 + depends on PAX_MPROTECT
91587 + default n
91588 + help
91589 + Non-executable pages and mprotect() restrictions are effective
91590 + in preventing the introduction of new executable code into an
91591 + attacked task's address space. There remain only two venues
91592 + for this kind of attack: if the attacker can execute already
91593 + existing code in the attacked task then he can either have it
91594 + create and mmap() a file containing his code or have it mmap()
91595 + an already existing ELF library that does not have position
91596 + independent code in it and use mprotect() on it to make it
91597 + writable and copy his code there. While protecting against
91598 + the former approach is beyond PaX, the latter can be prevented
91599 + by having only PIC ELF libraries on one's system (which do not
91600 + need to relocate their code). If you are sure this is your case,
91601 + as is the case with all modern Linux distributions, then leave
91602 + this option disabled. You should say 'n' here.
91603 +
91604 +config PAX_ETEXECRELOCS
91605 + bool "Allow ELF ET_EXEC text relocations"
91606 + depends on PAX_MPROTECT && (ALPHA || IA64 || PARISC)
91607 + select PAX_ELFRELOCS
91608 + default y
91609 + help
91610 + On some architectures there are incorrectly created applications
91611 + that require text relocations and would not work without enabling
91612 + this option. If you are an alpha, ia64 or parisc user, you should
91613 + enable this option and disable it once you have made sure that
91614 + none of your applications need it.
91615 +
91616 +config PAX_EMUPLT
91617 + bool "Automatically emulate ELF PLT"
91618 + depends on PAX_MPROTECT && (ALPHA || PARISC || SPARC)
91619 + default y
91620 + help
91621 + Enabling this option will have the kernel automatically detect
91622 + and emulate the Procedure Linkage Table entries in ELF files.
91623 + On some architectures such entries are in writable memory, and
91624 + become non-executable leading to task termination. Therefore
91625 + it is mandatory that you enable this option on alpha, parisc,
91626 + sparc and sparc64, otherwise your system would not even boot.
91627 +
91628 + NOTE: this feature *does* open up a loophole in the protection
91629 + provided by the non-executable pages, therefore the proper
91630 + solution is to modify the toolchain to produce a PLT that does
91631 + not need to be writable.
91632 +
91633 +config PAX_DLRESOLVE
91634 + bool 'Emulate old glibc resolver stub'
91635 + depends on PAX_EMUPLT && SPARC
91636 + default n
91637 + help
91638 + This option is needed if userland has an old glibc (before 2.4)
91639 + that puts a 'save' instruction into the runtime generated resolver
91640 + stub that needs special emulation.
91641 +
91642 +config PAX_KERNEXEC
91643 + bool "Enforce non-executable kernel pages"
91644 + 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))
91645 + depends on (X86 || (ARM && (CPU_V6 || CPU_V7) && !(ARM_LPAE && MODULES))) && !XEN
91646 + select PAX_PER_CPU_PGD if X86_64 || (X86_32 && X86_PAE)
91647 + select PAX_KERNEXEC_PLUGIN if X86_64
91648 + help
91649 + This is the kernel land equivalent of PAGEEXEC and MPROTECT,
91650 + that is, enabling this option will make it harder to inject
91651 + and execute 'foreign' code in kernel memory itself.
91652 +
91653 +choice
91654 + prompt "Return Address Instrumentation Method"
91655 + default PAX_KERNEXEC_PLUGIN_METHOD_BTS
91656 + depends on PAX_KERNEXEC_PLUGIN
91657 + help
91658 + Select the method used to instrument function pointer dereferences.
91659 + Note that binary modules cannot be instrumented by this approach.
91660 +
91661 + Note that the implementation requires a gcc with plugin support,
91662 + i.e., gcc 4.5 or newer. You may need to install the supporting
91663 + headers explicitly in addition to the normal gcc package.
91664 +
91665 + config PAX_KERNEXEC_PLUGIN_METHOD_BTS
91666 + bool "bts"
91667 + help
91668 + This method is compatible with binary only modules but has
91669 + a higher runtime overhead.
91670 +
91671 + config PAX_KERNEXEC_PLUGIN_METHOD_OR
91672 + bool "or"
91673 + depends on !PARAVIRT
91674 + help
91675 + This method is incompatible with binary only modules but has
91676 + a lower runtime overhead.
91677 +endchoice
91678 +
91679 +config PAX_KERNEXEC_PLUGIN_METHOD
91680 + string
91681 + default "bts" if PAX_KERNEXEC_PLUGIN_METHOD_BTS
91682 + default "or" if PAX_KERNEXEC_PLUGIN_METHOD_OR
91683 + default ""
91684 +
91685 +config PAX_KERNEXEC_MODULE_TEXT
91686 + int "Minimum amount of memory reserved for module code"
91687 + default "4" if (!GRKERNSEC_CONFIG_AUTO || GRKERNSEC_CONFIG_SERVER)
91688 + default "12" if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_DESKTOP)
91689 + depends on PAX_KERNEXEC && X86_32 && MODULES
91690 + help
91691 + Due to implementation details the kernel must reserve a fixed
91692 + amount of memory for module code at compile time that cannot be
91693 + changed at runtime. Here you can specify the minimum amount
91694 + in MB that will be reserved. Due to the same implementation
91695 + details this size will always be rounded up to the next 2/4 MB
91696 + boundary (depends on PAE) so the actually available memory for
91697 + module code will usually be more than this minimum.
91698 +
91699 + The default 4 MB should be enough for most users but if you have
91700 + an excessive number of modules (e.g., most distribution configs
91701 + compile many drivers as modules) or use huge modules such as
91702 + nvidia's kernel driver, you will need to adjust this amount.
91703 + A good rule of thumb is to look at your currently loaded kernel
91704 + modules and add up their sizes.
91705 +
91706 +endmenu
91707 +
91708 +menu "Address Space Layout Randomization"
91709 + depends on PAX
91710 +
91711 +config PAX_ASLR
91712 + bool "Address Space Layout Randomization"
91713 + default y if GRKERNSEC_CONFIG_AUTO
91714 + help
91715 + Many if not most exploit techniques rely on the knowledge of
91716 + certain addresses in the attacked program. The following options
91717 + will allow the kernel to apply a certain amount of randomization
91718 + to specific parts of the program thereby forcing an attacker to
91719 + guess them in most cases. Any failed guess will most likely crash
91720 + the attacked program which allows the kernel to detect such attempts
91721 + and react on them. PaX itself provides no reaction mechanisms,
91722 + instead it is strongly encouraged that you make use of Nergal's
91723 + segvguard (ftp://ftp.pl.openwall.com/misc/segvguard/) or grsecurity's
91724 + (http://www.grsecurity.net/) built-in crash detection features or
91725 + develop one yourself.
91726 +
91727 + By saying Y here you can choose to randomize the following areas:
91728 + - top of the task's kernel stack
91729 + - top of the task's userland stack
91730 + - base address for mmap() requests that do not specify one
91731 + (this includes all libraries)
91732 + - base address of the main executable
91733 +
91734 + It is strongly recommended to say Y here as address space layout
91735 + randomization has negligible impact on performance yet it provides
91736 + a very effective protection.
91737 +
91738 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control
91739 + this feature on a per file basis.
91740 +
91741 +config PAX_RANDKSTACK
91742 + bool "Randomize kernel stack base"
91743 + default y if GRKERNSEC_CONFIG_AUTO
91744 + depends on X86_TSC && X86
91745 + help
91746 + By saying Y here the kernel will randomize every task's kernel
91747 + stack on every system call. This will not only force an attacker
91748 + to guess it but also prevent him from making use of possible
91749 + leaked information about it.
91750 +
91751 + Since the kernel stack is a rather scarce resource, randomization
91752 + may cause unexpected stack overflows, therefore you should very
91753 + carefully test your system. Note that once enabled in the kernel
91754 + configuration, this feature cannot be disabled on a per file basis.
91755 +
91756 +config PAX_RANDUSTACK
91757 + bool "Randomize user stack base"
91758 + default y if GRKERNSEC_CONFIG_AUTO
91759 + depends on PAX_ASLR
91760 + help
91761 + By saying Y here the kernel will randomize every task's userland
91762 + stack. The randomization is done in two steps where the second
91763 + one may apply a big amount of shift to the top of the stack and
91764 + cause problems for programs that want to use lots of memory (more
91765 + than 2.5 GB if SEGMEXEC is not active, or 1.25 GB when it is).
91766 + For this reason the second step can be controlled by 'chpax' or
91767 + 'paxctl' on a per file basis.
91768 +
91769 +config PAX_RANDMMAP
91770 + bool "Randomize mmap() base"
91771 + default y if GRKERNSEC_CONFIG_AUTO
91772 + depends on PAX_ASLR
91773 + help
91774 + By saying Y here the kernel will use a randomized base address for
91775 + mmap() requests that do not specify one themselves. As a result
91776 + all dynamically loaded libraries will appear at random addresses
91777 + and therefore be harder to exploit by a technique where an attacker
91778 + attempts to execute library code for his purposes (e.g. spawn a
91779 + shell from an exploited program that is running at an elevated
91780 + privilege level).
91781 +
91782 + Furthermore, if a program is relinked as a dynamic ELF file, its
91783 + base address will be randomized as well, completing the full
91784 + randomization of the address space layout. Attacking such programs
91785 + becomes a guess game. You can find an example of doing this at
91786 + http://pax.grsecurity.net/et_dyn.tar.gz and practical samples at
91787 + http://www.grsecurity.net/grsec-gcc-specs.tar.gz .
91788 +
91789 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control this
91790 + feature on a per file basis.
91791 +
91792 +endmenu
91793 +
91794 +menu "Miscellaneous hardening features"
91795 +
91796 +config PAX_MEMORY_SANITIZE
91797 + bool "Sanitize all freed memory"
91798 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
91799 + depends on !HIBERNATION
91800 + help
91801 + By saying Y here the kernel will erase memory pages as soon as they
91802 + are freed. This in turn reduces the lifetime of data stored in the
91803 + pages, making it less likely that sensitive information such as
91804 + passwords, cryptographic secrets, etc stay in memory for too long.
91805 +
91806 + This is especially useful for programs whose runtime is short, long
91807 + lived processes and the kernel itself benefit from this as long as
91808 + they operate on whole memory pages and ensure timely freeing of pages
91809 + that may hold sensitive information.
91810 +
91811 + The tradeoff is performance impact, on a single CPU system kernel
91812 + compilation sees a 3% slowdown, other systems and workloads may vary
91813 + and you are advised to test this feature on your expected workload
91814 + before deploying it.
91815 +
91816 + Note that this feature does not protect data stored in live pages,
91817 + e.g., process memory swapped to disk may stay there for a long time.
91818 +
91819 +config PAX_MEMORY_STACKLEAK
91820 + bool "Sanitize kernel stack"
91821 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
91822 + depends on X86
91823 + help
91824 + By saying Y here the kernel will erase the kernel stack before it
91825 + returns from a system call. This in turn reduces the information
91826 + that a kernel stack leak bug can reveal.
91827 +
91828 + Note that such a bug can still leak information that was put on
91829 + the stack by the current system call (the one eventually triggering
91830 + the bug) but traces of earlier system calls on the kernel stack
91831 + cannot leak anymore.
91832 +
91833 + The tradeoff is performance impact: on a single CPU system kernel
91834 + compilation sees a 1% slowdown, other systems and workloads may vary
91835 + and you are advised to test this feature on your expected workload
91836 + before deploying it.
91837 +
91838 + Note that the full feature requires a gcc with plugin support,
91839 + i.e., gcc 4.5 or newer. You may need to install the supporting
91840 + headers explicitly in addition to the normal gcc package. Using
91841 + older gcc versions means that functions with large enough stack
91842 + frames may leave uninitialized memory behind that may be exposed
91843 + to a later syscall leaking the stack.
91844 +
91845 +config PAX_MEMORY_STRUCTLEAK
91846 + bool "Forcibly initialize local variables copied to userland"
91847 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
91848 + help
91849 + By saying Y here the kernel will zero initialize some local
91850 + variables that are going to be copied to userland. This in
91851 + turn prevents unintended information leakage from the kernel
91852 + stack should later code forget to explicitly set all parts of
91853 + the copied variable.
91854 +
91855 + The tradeoff is less performance impact than PAX_MEMORY_STACKLEAK
91856 + at a much smaller coverage.
91857 +
91858 + Note that the implementation requires a gcc with plugin support,
91859 + i.e., gcc 4.5 or newer. You may need to install the supporting
91860 + headers explicitly in addition to the normal gcc package.
91861 +
91862 +config PAX_MEMORY_UDEREF
91863 + bool "Prevent invalid userland pointer dereference"
91864 + default y if GRKERNSEC_CONFIG_AUTO && !(X86_64 && GRKERNSEC_CONFIG_PRIORITY_PERF) && (GRKERNSEC_CONFIG_VIRT_NONE || GRKERNSEC_CONFIG_VIRT_EPT)
91865 + depends on (X86 || (ARM && (CPU_V6 || CPU_V7) && !ARM_LPAE)) && !UML_X86 && !XEN
91866 + select PAX_PER_CPU_PGD if X86_64
91867 + help
91868 + By saying Y here the kernel will be prevented from dereferencing
91869 + userland pointers in contexts where the kernel expects only kernel
91870 + pointers. This is both a useful runtime debugging feature and a
91871 + security measure that prevents exploiting a class of kernel bugs.
91872 +
91873 + The tradeoff is that some virtualization solutions may experience
91874 + a huge slowdown and therefore you should not enable this feature
91875 + for kernels meant to run in such environments. Whether a given VM
91876 + solution is affected or not is best determined by simply trying it
91877 + out, the performance impact will be obvious right on boot as this
91878 + mechanism engages from very early on. A good rule of thumb is that
91879 + VMs running on CPUs without hardware virtualization support (i.e.,
91880 + the majority of IA-32 CPUs) will likely experience the slowdown.
91881 +
91882 +config PAX_REFCOUNT
91883 + bool "Prevent various kernel object reference counter overflows"
91884 + default y if GRKERNSEC_CONFIG_AUTO
91885 + depends on GRKERNSEC && ((ARM && (CPU_32v6 || CPU_32v6K || CPU_32v7)) || SPARC64 || X86)
91886 + help
91887 + By saying Y here the kernel will detect and prevent overflowing
91888 + various (but not all) kinds of object reference counters. Such
91889 + overflows can normally occur due to bugs only and are often, if
91890 + not always, exploitable.
91891 +
91892 + The tradeoff is that data structures protected by an overflowed
91893 + refcount will never be freed and therefore will leak memory. Note
91894 + that this leak also happens even without this protection but in
91895 + that case the overflow can eventually trigger the freeing of the
91896 + data structure while it is still being used elsewhere, resulting
91897 + in the exploitable situation that this feature prevents.
91898 +
91899 + Since this has a negligible performance impact, you should enable
91900 + this feature.
91901 +
91902 +config PAX_CONSTIFY_PLUGIN
91903 + bool "Automatically constify eligible structures"
91904 + default y
91905 + depends on !UML && PAX_KERNEXEC
91906 + help
91907 + By saying Y here the compiler will automatically constify a class
91908 + of types that contain only function pointers. This reduces the
91909 + kernel's attack surface and also produces a better memory layout.
91910 +
91911 + Note that the implementation requires a gcc with plugin support,
91912 + i.e., gcc 4.5 or newer. You may need to install the supporting
91913 + headers explicitly in addition to the normal gcc package.
91914 +
91915 + Note that if some code really has to modify constified variables
91916 + then the source code will have to be patched to allow it. Examples
91917 + can be found in PaX itself (the no_const attribute) and for some
91918 + out-of-tree modules at http://www.grsecurity.net/~paxguy1/ .
91919 +
91920 +config PAX_USERCOPY
91921 + bool "Harden heap object copies between kernel and userland"
91922 + default y if GRKERNSEC_CONFIG_AUTO
91923 + depends on ARM || IA64 || PPC || SPARC || X86
91924 + depends on GRKERNSEC && (SLAB || SLUB || SLOB)
91925 + select PAX_USERCOPY_SLABS
91926 + help
91927 + By saying Y here the kernel will enforce the size of heap objects
91928 + when they are copied in either direction between the kernel and
91929 + userland, even if only a part of the heap object is copied.
91930 +
91931 + Specifically, this checking prevents information leaking from the
91932 + kernel heap during kernel to userland copies (if the kernel heap
91933 + object is otherwise fully initialized) and prevents kernel heap
91934 + overflows during userland to kernel copies.
91935 +
91936 + Note that the current implementation provides the strictest bounds
91937 + checks for the SLUB allocator.
91938 +
91939 + Enabling this option also enables per-slab cache protection against
91940 + data in a given cache being copied into/out of via userland
91941 + accessors. Though the whitelist of regions will be reduced over
91942 + time, it notably protects important data structures like task structs.
91943 +
91944 + If frame pointers are enabled on x86, this option will also restrict
91945 + copies into and out of the kernel stack to local variables within a
91946 + single frame.
91947 +
91948 + Since this has a negligible performance impact, you should enable
91949 + this feature.
91950 +
91951 +config PAX_USERCOPY_DEBUG
91952 + bool
91953 + depends on X86 && PAX_USERCOPY
91954 + default n
91955 +
91956 +config PAX_SIZE_OVERFLOW
91957 + bool "Prevent various integer overflows in function size parameters"
91958 + default y if GRKERNSEC_CONFIG_AUTO
91959 + depends on X86
91960 + help
91961 + By saying Y here the kernel recomputes expressions of function
91962 + arguments marked by a size_overflow attribute with double integer
91963 + precision (DImode/TImode for 32/64 bit integer types).
91964 +
91965 + The recomputed argument is checked against TYPE_MAX and an event
91966 + is logged on overflow and the triggering process is killed.
91967 +
91968 + Homepage: http://www.grsecurity.net/~ephox/overflow_plugin/
91969 +
91970 + Note that the implementation requires a gcc with plugin support,
91971 + i.e., gcc 4.5 or newer. You may need to install the supporting
91972 + headers explicitly in addition to the normal gcc package.
91973 +
91974 +config PAX_LATENT_ENTROPY
91975 + bool "Generate some entropy during boot"
91976 + default y if GRKERNSEC_CONFIG_AUTO
91977 + help
91978 + By saying Y here the kernel will instrument early boot code to
91979 + extract some entropy from both original and artificially created
91980 + program state. This will help especially embedded systems where
91981 + there is little 'natural' source of entropy normally. The cost
91982 + is some slowdown of the boot process.
91983 +
91984 + When pax_extra_latent_entropy is passed on the kernel command line,
91985 + entropy will be extracted from up to the first 4GB of RAM while the
91986 + runtime memory allocator is being initialized. This costs even more
91987 + slowdown of the boot process.
91988 +
91989 + Note that the implementation requires a gcc with plugin support,
91990 + i.e., gcc 4.5 or newer. You may need to install the supporting
91991 + headers explicitly in addition to the normal gcc package.
91992 +
91993 + Note that entropy extracted this way is not cryptographically
91994 + secure!
91995 +
91996 +endmenu
91997 +
91998 +endmenu
91999 +
92000 +source grsecurity/Kconfig
92001 +
92002 +endmenu
92003 +
92004 +endmenu
92005 +
92006 source security/keys/Kconfig
92007
92008 config SECURITY_DMESG_RESTRICT
92009 @@ -103,7 +1041,7 @@ config INTEL_TXT
92010 config LSM_MMAP_MIN_ADDR
92011 int "Low address space for LSM to protect from user allocation"
92012 depends on SECURITY && SECURITY_SELINUX
92013 - default 32768 if ARM
92014 + default 32768 if ALPHA || ARM || PARISC || SPARC32
92015 default 65536
92016 help
92017 This is the portion of low virtual memory which should be protected
92018 diff --git a/security/apparmor/lsm.c b/security/apparmor/lsm.c
92019 index b21830e..a7d1a17 100644
92020 --- a/security/apparmor/lsm.c
92021 +++ b/security/apparmor/lsm.c
92022 @@ -614,7 +614,7 @@ static int apparmor_task_setrlimit(struct task_struct *task,
92023 return error;
92024 }
92025
92026 -static struct security_operations apparmor_ops = {
92027 +static struct security_operations apparmor_ops __read_only = {
92028 .name = "apparmor",
92029
92030 .ptrace_access_check = apparmor_ptrace_access_check,
92031 diff --git a/security/commoncap.c b/security/commoncap.c
92032 index c44b6fe..932df30 100644
92033 --- a/security/commoncap.c
92034 +++ b/security/commoncap.c
92035 @@ -424,6 +424,32 @@ int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data
92036 return 0;
92037 }
92038
92039 +/* returns:
92040 + 1 for suid privilege
92041 + 2 for sgid privilege
92042 + 3 for fscap privilege
92043 +*/
92044 +int is_privileged_binary(const struct dentry *dentry)
92045 +{
92046 + struct cpu_vfs_cap_data capdata;
92047 + struct inode *inode = dentry->d_inode;
92048 +
92049 + if (!inode || S_ISDIR(inode->i_mode))
92050 + return 0;
92051 +
92052 + if (inode->i_mode & S_ISUID)
92053 + return 1;
92054 + if ((inode->i_mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))
92055 + return 2;
92056 +
92057 + if (!get_vfs_caps_from_disk(dentry, &capdata)) {
92058 + if (!cap_isclear(capdata.inheritable) || !cap_isclear(capdata.permitted))
92059 + return 3;
92060 + }
92061 +
92062 + return 0;
92063 +}
92064 +
92065 /*
92066 * Attempt to get the on-exec apply capability sets for an executable file from
92067 * its xattrs and, if present, apply them to the proposed credentials being
92068 @@ -592,6 +618,9 @@ int cap_bprm_secureexec(struct linux_binprm *bprm)
92069 const struct cred *cred = current_cred();
92070 kuid_t root_uid = make_kuid(cred->user_ns, 0);
92071
92072 + if (gr_acl_enable_at_secure())
92073 + return 1;
92074 +
92075 if (!uid_eq(cred->uid, root_uid)) {
92076 if (bprm->cap_effective)
92077 return 1;
92078 diff --git a/security/integrity/ima/ima.h b/security/integrity/ima/ima.h
92079 index a41c9c1..83da6dd 100644
92080 --- a/security/integrity/ima/ima.h
92081 +++ b/security/integrity/ima/ima.h
92082 @@ -97,8 +97,8 @@ int ima_init_crypto(void);
92083 extern spinlock_t ima_queue_lock;
92084
92085 struct ima_h_table {
92086 - atomic_long_t len; /* number of stored measurements in the list */
92087 - atomic_long_t violations;
92088 + atomic_long_unchecked_t len; /* number of stored measurements in the list */
92089 + atomic_long_unchecked_t violations;
92090 struct hlist_head queue[IMA_MEASURE_HTABLE_SIZE];
92091 };
92092 extern struct ima_h_table ima_htable;
92093 diff --git a/security/integrity/ima/ima_api.c b/security/integrity/ima/ima_api.c
92094 index 1c03e8f1..398a941 100644
92095 --- a/security/integrity/ima/ima_api.c
92096 +++ b/security/integrity/ima/ima_api.c
92097 @@ -79,7 +79,7 @@ void ima_add_violation(struct inode *inode, const unsigned char *filename,
92098 int result;
92099
92100 /* can overflow, only indicator */
92101 - atomic_long_inc(&ima_htable.violations);
92102 + atomic_long_inc_unchecked(&ima_htable.violations);
92103
92104 entry = kmalloc(sizeof(*entry), GFP_KERNEL);
92105 if (!entry) {
92106 diff --git a/security/integrity/ima/ima_fs.c b/security/integrity/ima/ima_fs.c
92107 index 38477c9..87a60c7 100644
92108 --- a/security/integrity/ima/ima_fs.c
92109 +++ b/security/integrity/ima/ima_fs.c
92110 @@ -28,12 +28,12 @@
92111 static int valid_policy = 1;
92112 #define TMPBUFLEN 12
92113 static ssize_t ima_show_htable_value(char __user *buf, size_t count,
92114 - loff_t *ppos, atomic_long_t *val)
92115 + loff_t *ppos, atomic_long_unchecked_t *val)
92116 {
92117 char tmpbuf[TMPBUFLEN];
92118 ssize_t len;
92119
92120 - len = scnprintf(tmpbuf, TMPBUFLEN, "%li\n", atomic_long_read(val));
92121 + len = scnprintf(tmpbuf, TMPBUFLEN, "%li\n", atomic_long_read_unchecked(val));
92122 return simple_read_from_buffer(buf, count, ppos, tmpbuf, len);
92123 }
92124
92125 diff --git a/security/integrity/ima/ima_queue.c b/security/integrity/ima/ima_queue.c
92126 index ff63fe0..809cd96 100644
92127 --- a/security/integrity/ima/ima_queue.c
92128 +++ b/security/integrity/ima/ima_queue.c
92129 @@ -80,7 +80,7 @@ static int ima_add_digest_entry(struct ima_template_entry *entry)
92130 INIT_LIST_HEAD(&qe->later);
92131 list_add_tail_rcu(&qe->later, &ima_measurements);
92132
92133 - atomic_long_inc(&ima_htable.len);
92134 + atomic_long_inc_unchecked(&ima_htable.len);
92135 key = ima_hash_key(entry->digest);
92136 hlist_add_head_rcu(&qe->hnext, &ima_htable.queue[key]);
92137 return 0;
92138 diff --git a/security/keys/compat.c b/security/keys/compat.c
92139 index d65fa7f..cbfe366 100644
92140 --- a/security/keys/compat.c
92141 +++ b/security/keys/compat.c
92142 @@ -44,7 +44,7 @@ static long compat_keyctl_instantiate_key_iov(
92143 if (ret == 0)
92144 goto no_payload_free;
92145
92146 - ret = keyctl_instantiate_key_common(id, iov, ioc, ret, ringid);
92147 + ret = keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, ioc, ret, ringid);
92148 err:
92149 if (iov != iovstack)
92150 kfree(iov);
92151 diff --git a/security/keys/internal.h b/security/keys/internal.h
92152 index 8bbefc3..299d03f 100644
92153 --- a/security/keys/internal.h
92154 +++ b/security/keys/internal.h
92155 @@ -240,7 +240,7 @@ extern long keyctl_instantiate_key_iov(key_serial_t,
92156 extern long keyctl_invalidate_key(key_serial_t);
92157
92158 extern long keyctl_instantiate_key_common(key_serial_t,
92159 - const struct iovec *,
92160 + const struct iovec __user *,
92161 unsigned, size_t, key_serial_t);
92162
92163 /*
92164 diff --git a/security/keys/key.c b/security/keys/key.c
92165 index 8fb7c7b..ba3610d 100644
92166 --- a/security/keys/key.c
92167 +++ b/security/keys/key.c
92168 @@ -284,7 +284,7 @@ struct key *key_alloc(struct key_type *type, const char *desc,
92169
92170 atomic_set(&key->usage, 1);
92171 init_rwsem(&key->sem);
92172 - lockdep_set_class(&key->sem, &type->lock_class);
92173 + lockdep_set_class(&key->sem, (struct lock_class_key *)&type->lock_class);
92174 key->type = type;
92175 key->user = user;
92176 key->quotalen = quotalen;
92177 @@ -1032,7 +1032,9 @@ int register_key_type(struct key_type *ktype)
92178 struct key_type *p;
92179 int ret;
92180
92181 - memset(&ktype->lock_class, 0, sizeof(ktype->lock_class));
92182 + pax_open_kernel();
92183 + memset((void *)&ktype->lock_class, 0, sizeof(ktype->lock_class));
92184 + pax_close_kernel();
92185
92186 ret = -EEXIST;
92187 down_write(&key_types_sem);
92188 @@ -1044,7 +1046,7 @@ int register_key_type(struct key_type *ktype)
92189 }
92190
92191 /* store the type */
92192 - list_add(&ktype->link, &key_types_list);
92193 + pax_list_add((struct list_head *)&ktype->link, &key_types_list);
92194
92195 pr_notice("Key type %s registered\n", ktype->name);
92196 ret = 0;
92197 @@ -1066,7 +1068,7 @@ EXPORT_SYMBOL(register_key_type);
92198 void unregister_key_type(struct key_type *ktype)
92199 {
92200 down_write(&key_types_sem);
92201 - list_del_init(&ktype->link);
92202 + pax_list_del_init((struct list_head *)&ktype->link);
92203 downgrade_write(&key_types_sem);
92204 key_gc_keytype(ktype);
92205 pr_notice("Key type %s unregistered\n", ktype->name);
92206 @@ -1084,10 +1086,10 @@ void __init key_init(void)
92207 0, SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
92208
92209 /* add the special key types */
92210 - list_add_tail(&key_type_keyring.link, &key_types_list);
92211 - list_add_tail(&key_type_dead.link, &key_types_list);
92212 - list_add_tail(&key_type_user.link, &key_types_list);
92213 - list_add_tail(&key_type_logon.link, &key_types_list);
92214 + pax_list_add_tail((struct list_head *)&key_type_keyring.link, &key_types_list);
92215 + pax_list_add_tail((struct list_head *)&key_type_dead.link, &key_types_list);
92216 + pax_list_add_tail((struct list_head *)&key_type_user.link, &key_types_list);
92217 + pax_list_add_tail((struct list_head *)&key_type_logon.link, &key_types_list);
92218
92219 /* record the root user tracking */
92220 rb_link_node(&root_key_user.node,
92221 diff --git a/security/keys/keyctl.c b/security/keys/keyctl.c
92222 index 4b5c948..2054dc1 100644
92223 --- a/security/keys/keyctl.c
92224 +++ b/security/keys/keyctl.c
92225 @@ -986,7 +986,7 @@ static int keyctl_change_reqkey_auth(struct key *key)
92226 /*
92227 * Copy the iovec data from userspace
92228 */
92229 -static long copy_from_user_iovec(void *buffer, const struct iovec *iov,
92230 +static long copy_from_user_iovec(void *buffer, const struct iovec __user *iov,
92231 unsigned ioc)
92232 {
92233 for (; ioc > 0; ioc--) {
92234 @@ -1008,7 +1008,7 @@ static long copy_from_user_iovec(void *buffer, const struct iovec *iov,
92235 * If successful, 0 will be returned.
92236 */
92237 long keyctl_instantiate_key_common(key_serial_t id,
92238 - const struct iovec *payload_iov,
92239 + const struct iovec __user *payload_iov,
92240 unsigned ioc,
92241 size_t plen,
92242 key_serial_t ringid)
92243 @@ -1103,7 +1103,7 @@ long keyctl_instantiate_key(key_serial_t id,
92244 [0].iov_len = plen
92245 };
92246
92247 - return keyctl_instantiate_key_common(id, iov, 1, plen, ringid);
92248 + return keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, 1, plen, ringid);
92249 }
92250
92251 return keyctl_instantiate_key_common(id, NULL, 0, 0, ringid);
92252 @@ -1136,7 +1136,7 @@ long keyctl_instantiate_key_iov(key_serial_t id,
92253 if (ret == 0)
92254 goto no_payload_free;
92255
92256 - ret = keyctl_instantiate_key_common(id, iov, ioc, ret, ringid);
92257 + ret = keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, ioc, ret, ringid);
92258 err:
92259 if (iov != iovstack)
92260 kfree(iov);
92261 diff --git a/security/keys/keyring.c b/security/keys/keyring.c
92262 index 6ece7f2..ecdb55c 100644
92263 --- a/security/keys/keyring.c
92264 +++ b/security/keys/keyring.c
92265 @@ -227,16 +227,16 @@ static long keyring_read(const struct key *keyring,
92266 ret = -EFAULT;
92267
92268 for (loop = 0; loop < klist->nkeys; loop++) {
92269 + key_serial_t serial;
92270 key = rcu_deref_link_locked(klist, loop,
92271 keyring);
92272 + serial = key->serial;
92273
92274 tmp = sizeof(key_serial_t);
92275 if (tmp > buflen)
92276 tmp = buflen;
92277
92278 - if (copy_to_user(buffer,
92279 - &key->serial,
92280 - tmp) != 0)
92281 + if (copy_to_user(buffer, &serial, tmp))
92282 goto error;
92283
92284 buflen -= tmp;
92285 diff --git a/security/min_addr.c b/security/min_addr.c
92286 index f728728..6457a0c 100644
92287 --- a/security/min_addr.c
92288 +++ b/security/min_addr.c
92289 @@ -14,6 +14,7 @@ unsigned long dac_mmap_min_addr = CONFIG_DEFAULT_MMAP_MIN_ADDR;
92290 */
92291 static void update_mmap_min_addr(void)
92292 {
92293 +#ifndef SPARC
92294 #ifdef CONFIG_LSM_MMAP_MIN_ADDR
92295 if (dac_mmap_min_addr > CONFIG_LSM_MMAP_MIN_ADDR)
92296 mmap_min_addr = dac_mmap_min_addr;
92297 @@ -22,6 +23,7 @@ static void update_mmap_min_addr(void)
92298 #else
92299 mmap_min_addr = dac_mmap_min_addr;
92300 #endif
92301 +#endif
92302 }
92303
92304 /*
92305 diff --git a/security/security.c b/security/security.c
92306 index 03f248b..5710c33 100644
92307 --- a/security/security.c
92308 +++ b/security/security.c
92309 @@ -20,6 +20,7 @@
92310 #include <linux/ima.h>
92311 #include <linux/evm.h>
92312 #include <linux/fsnotify.h>
92313 +#include <linux/mm.h>
92314 #include <linux/mman.h>
92315 #include <linux/mount.h>
92316 #include <linux/personality.h>
92317 @@ -32,8 +33,8 @@
92318 static __initdata char chosen_lsm[SECURITY_NAME_MAX + 1] =
92319 CONFIG_DEFAULT_SECURITY;
92320
92321 -static struct security_operations *security_ops;
92322 -static struct security_operations default_security_ops = {
92323 +static struct security_operations *security_ops __read_only;
92324 +static struct security_operations default_security_ops __read_only = {
92325 .name = "default",
92326 };
92327
92328 @@ -74,7 +75,9 @@ int __init security_init(void)
92329
92330 void reset_security_ops(void)
92331 {
92332 + pax_open_kernel();
92333 security_ops = &default_security_ops;
92334 + pax_close_kernel();
92335 }
92336
92337 /* Save user chosen LSM */
92338 diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
92339 index 7171a95..c35e879 100644
92340 --- a/security/selinux/hooks.c
92341 +++ b/security/selinux/hooks.c
92342 @@ -96,8 +96,6 @@
92343
92344 #define NUM_SEL_MNT_OPTS 5
92345
92346 -extern struct security_operations *security_ops;
92347 -
92348 /* SECMARK reference count */
92349 static atomic_t selinux_secmark_refcount = ATOMIC_INIT(0);
92350
92351 @@ -5498,7 +5496,7 @@ static int selinux_key_getsecurity(struct key *key, char **_buffer)
92352
92353 #endif
92354
92355 -static struct security_operations selinux_ops = {
92356 +static struct security_operations selinux_ops __read_only = {
92357 .name = "selinux",
92358
92359 .ptrace_access_check = selinux_ptrace_access_check,
92360 diff --git a/security/selinux/include/xfrm.h b/security/selinux/include/xfrm.h
92361 index 65f67cb..3f141ef 100644
92362 --- a/security/selinux/include/xfrm.h
92363 +++ b/security/selinux/include/xfrm.h
92364 @@ -50,7 +50,7 @@ int selinux_xfrm_decode_session(struct sk_buff *skb, u32 *sid, int ckall);
92365
92366 static inline void selinux_xfrm_notify_policyload(void)
92367 {
92368 - atomic_inc(&flow_cache_genid);
92369 + atomic_inc_unchecked(&flow_cache_genid);
92370 rt_genid_bump(&init_net);
92371 }
92372 #else
92373 diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
92374 index fa64740..bc95b74 100644
92375 --- a/security/smack/smack_lsm.c
92376 +++ b/security/smack/smack_lsm.c
92377 @@ -3392,7 +3392,7 @@ static int smack_inode_getsecctx(struct inode *inode, void **ctx, u32 *ctxlen)
92378 return 0;
92379 }
92380
92381 -struct security_operations smack_ops = {
92382 +struct security_operations smack_ops __read_only = {
92383 .name = "smack",
92384
92385 .ptrace_access_check = smack_ptrace_access_check,
92386 diff --git a/security/tomoyo/mount.c b/security/tomoyo/mount.c
92387 index 390c646..f2f8db3 100644
92388 --- a/security/tomoyo/mount.c
92389 +++ b/security/tomoyo/mount.c
92390 @@ -118,6 +118,10 @@ static int tomoyo_mount_acl(struct tomoyo_request_info *r,
92391 type == tomoyo_mounts[TOMOYO_MOUNT_MOVE]) {
92392 need_dev = -1; /* dev_name is a directory */
92393 } else {
92394 + if (!capable(CAP_SYS_ADMIN)) {
92395 + error = -EPERM;
92396 + goto out;
92397 + }
92398 fstype = get_fs_type(type);
92399 if (!fstype) {
92400 error = -ENODEV;
92401 diff --git a/security/tomoyo/tomoyo.c b/security/tomoyo/tomoyo.c
92402 index a2ee362..5754f34 100644
92403 --- a/security/tomoyo/tomoyo.c
92404 +++ b/security/tomoyo/tomoyo.c
92405 @@ -503,7 +503,7 @@ static int tomoyo_socket_sendmsg(struct socket *sock, struct msghdr *msg,
92406 * tomoyo_security_ops is a "struct security_operations" which is used for
92407 * registering TOMOYO.
92408 */
92409 -static struct security_operations tomoyo_security_ops = {
92410 +static struct security_operations tomoyo_security_ops __read_only = {
92411 .name = "tomoyo",
92412 .cred_alloc_blank = tomoyo_cred_alloc_blank,
92413 .cred_prepare = tomoyo_cred_prepare,
92414 diff --git a/security/yama/Kconfig b/security/yama/Kconfig
92415 index 20ef514..4182bed 100644
92416 --- a/security/yama/Kconfig
92417 +++ b/security/yama/Kconfig
92418 @@ -1,6 +1,6 @@
92419 config SECURITY_YAMA
92420 bool "Yama support"
92421 - depends on SECURITY
92422 + depends on SECURITY && !GRKERNSEC
92423 select SECURITYFS
92424 select SECURITY_PATH
92425 default n
92426 diff --git a/security/yama/yama_lsm.c b/security/yama/yama_lsm.c
92427 index 13c88fbc..f8c115e 100644
92428 --- a/security/yama/yama_lsm.c
92429 +++ b/security/yama/yama_lsm.c
92430 @@ -365,7 +365,7 @@ int yama_ptrace_traceme(struct task_struct *parent)
92431 }
92432
92433 #ifndef CONFIG_SECURITY_YAMA_STACKED
92434 -static struct security_operations yama_ops = {
92435 +static struct security_operations yama_ops __read_only = {
92436 .name = "yama",
92437
92438 .ptrace_access_check = yama_ptrace_access_check,
92439 @@ -376,28 +376,24 @@ static struct security_operations yama_ops = {
92440 #endif
92441
92442 #ifdef CONFIG_SYSCTL
92443 +static int zero __read_only;
92444 +static int max_scope __read_only = YAMA_SCOPE_NO_ATTACH;
92445 +
92446 static int yama_dointvec_minmax(struct ctl_table *table, int write,
92447 void __user *buffer, size_t *lenp, loff_t *ppos)
92448 {
92449 - int rc;
92450 + ctl_table_no_const yama_table;
92451
92452 if (write && !capable(CAP_SYS_PTRACE))
92453 return -EPERM;
92454
92455 - rc = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
92456 - if (rc)
92457 - return rc;
92458 -
92459 + yama_table = *table;
92460 /* Lock the max value if it ever gets set. */
92461 - if (write && *(int *)table->data == *(int *)table->extra2)
92462 - table->extra1 = table->extra2;
92463 -
92464 - return rc;
92465 + if (ptrace_scope == max_scope)
92466 + yama_table.extra1 = &max_scope;
92467 + return proc_dointvec_minmax(&yama_table, write, buffer, lenp, ppos);
92468 }
92469
92470 -static int zero;
92471 -static int max_scope = YAMA_SCOPE_NO_ATTACH;
92472 -
92473 struct ctl_path yama_sysctl_path[] = {
92474 { .procname = "kernel", },
92475 { .procname = "yama", },
92476 diff --git a/sound/aoa/codecs/onyx.c b/sound/aoa/codecs/onyx.c
92477 index 4cedc69..e59d8a3 100644
92478 --- a/sound/aoa/codecs/onyx.c
92479 +++ b/sound/aoa/codecs/onyx.c
92480 @@ -54,7 +54,7 @@ struct onyx {
92481 spdif_locked:1,
92482 analog_locked:1,
92483 original_mute:2;
92484 - int open_count;
92485 + local_t open_count;
92486 struct codec_info *codec_info;
92487
92488 /* mutex serializes concurrent access to the device
92489 @@ -753,7 +753,7 @@ static int onyx_open(struct codec_info_item *cii,
92490 struct onyx *onyx = cii->codec_data;
92491
92492 mutex_lock(&onyx->mutex);
92493 - onyx->open_count++;
92494 + local_inc(&onyx->open_count);
92495 mutex_unlock(&onyx->mutex);
92496
92497 return 0;
92498 @@ -765,8 +765,7 @@ static int onyx_close(struct codec_info_item *cii,
92499 struct onyx *onyx = cii->codec_data;
92500
92501 mutex_lock(&onyx->mutex);
92502 - onyx->open_count--;
92503 - if (!onyx->open_count)
92504 + if (local_dec_and_test(&onyx->open_count))
92505 onyx->spdif_locked = onyx->analog_locked = 0;
92506 mutex_unlock(&onyx->mutex);
92507
92508 diff --git a/sound/aoa/codecs/onyx.h b/sound/aoa/codecs/onyx.h
92509 index ffd2025..df062c9 100644
92510 --- a/sound/aoa/codecs/onyx.h
92511 +++ b/sound/aoa/codecs/onyx.h
92512 @@ -11,6 +11,7 @@
92513 #include <linux/i2c.h>
92514 #include <asm/pmac_low_i2c.h>
92515 #include <asm/prom.h>
92516 +#include <asm/local.h>
92517
92518 /* PCM3052 register definitions */
92519
92520 diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c
92521 index 4c1cc51..16040040 100644
92522 --- a/sound/core/oss/pcm_oss.c
92523 +++ b/sound/core/oss/pcm_oss.c
92524 @@ -1189,10 +1189,10 @@ snd_pcm_sframes_t snd_pcm_oss_write3(struct snd_pcm_substream *substream, const
92525 if (in_kernel) {
92526 mm_segment_t fs;
92527 fs = snd_enter_user();
92528 - ret = snd_pcm_lib_write(substream, (void __force __user *)ptr, frames);
92529 + ret = snd_pcm_lib_write(substream, (void __force_user *)ptr, frames);
92530 snd_leave_user(fs);
92531 } else {
92532 - ret = snd_pcm_lib_write(substream, (void __force __user *)ptr, frames);
92533 + ret = snd_pcm_lib_write(substream, (void __force_user *)ptr, frames);
92534 }
92535 if (ret != -EPIPE && ret != -ESTRPIPE)
92536 break;
92537 @@ -1234,10 +1234,10 @@ snd_pcm_sframes_t snd_pcm_oss_read3(struct snd_pcm_substream *substream, char *p
92538 if (in_kernel) {
92539 mm_segment_t fs;
92540 fs = snd_enter_user();
92541 - ret = snd_pcm_lib_read(substream, (void __force __user *)ptr, frames);
92542 + ret = snd_pcm_lib_read(substream, (void __force_user *)ptr, frames);
92543 snd_leave_user(fs);
92544 } else {
92545 - ret = snd_pcm_lib_read(substream, (void __force __user *)ptr, frames);
92546 + ret = snd_pcm_lib_read(substream, (void __force_user *)ptr, frames);
92547 }
92548 if (ret == -EPIPE) {
92549 if (runtime->status->state == SNDRV_PCM_STATE_DRAINING) {
92550 @@ -1337,7 +1337,7 @@ static ssize_t snd_pcm_oss_write2(struct snd_pcm_substream *substream, const cha
92551 struct snd_pcm_plugin_channel *channels;
92552 size_t oss_frame_bytes = (runtime->oss.plugin_first->src_width * runtime->oss.plugin_first->src_format.channels) / 8;
92553 if (!in_kernel) {
92554 - if (copy_from_user(runtime->oss.buffer, (const char __force __user *)buf, bytes))
92555 + if (copy_from_user(runtime->oss.buffer, (const char __force_user *)buf, bytes))
92556 return -EFAULT;
92557 buf = runtime->oss.buffer;
92558 }
92559 @@ -1407,7 +1407,7 @@ static ssize_t snd_pcm_oss_write1(struct snd_pcm_substream *substream, const cha
92560 }
92561 } else {
92562 tmp = snd_pcm_oss_write2(substream,
92563 - (const char __force *)buf,
92564 + (const char __force_kernel *)buf,
92565 runtime->oss.period_bytes, 0);
92566 if (tmp <= 0)
92567 goto err;
92568 @@ -1433,7 +1433,7 @@ static ssize_t snd_pcm_oss_read2(struct snd_pcm_substream *substream, char *buf,
92569 struct snd_pcm_runtime *runtime = substream->runtime;
92570 snd_pcm_sframes_t frames, frames1;
92571 #ifdef CONFIG_SND_PCM_OSS_PLUGINS
92572 - char __user *final_dst = (char __force __user *)buf;
92573 + char __user *final_dst = (char __force_user *)buf;
92574 if (runtime->oss.plugin_first) {
92575 struct snd_pcm_plugin_channel *channels;
92576 size_t oss_frame_bytes = (runtime->oss.plugin_last->dst_width * runtime->oss.plugin_last->dst_format.channels) / 8;
92577 @@ -1495,7 +1495,7 @@ static ssize_t snd_pcm_oss_read1(struct snd_pcm_substream *substream, char __use
92578 xfer += tmp;
92579 runtime->oss.buffer_used -= tmp;
92580 } else {
92581 - tmp = snd_pcm_oss_read2(substream, (char __force *)buf,
92582 + tmp = snd_pcm_oss_read2(substream, (char __force_kernel *)buf,
92583 runtime->oss.period_bytes, 0);
92584 if (tmp <= 0)
92585 goto err;
92586 @@ -1663,7 +1663,7 @@ static int snd_pcm_oss_sync(struct snd_pcm_oss_file *pcm_oss_file)
92587 size1);
92588 size1 /= runtime->channels; /* frames */
92589 fs = snd_enter_user();
92590 - snd_pcm_lib_write(substream, (void __force __user *)runtime->oss.buffer, size1);
92591 + snd_pcm_lib_write(substream, (void __force_user *)runtime->oss.buffer, size1);
92592 snd_leave_user(fs);
92593 }
92594 } else if (runtime->access == SNDRV_PCM_ACCESS_RW_NONINTERLEAVED) {
92595 diff --git a/sound/core/pcm_compat.c b/sound/core/pcm_compat.c
92596 index af49721..e85058e 100644
92597 --- a/sound/core/pcm_compat.c
92598 +++ b/sound/core/pcm_compat.c
92599 @@ -31,7 +31,7 @@ static int snd_pcm_ioctl_delay_compat(struct snd_pcm_substream *substream,
92600 int err;
92601
92602 fs = snd_enter_user();
92603 - err = snd_pcm_delay(substream, &delay);
92604 + err = snd_pcm_delay(substream, (snd_pcm_sframes_t __force_user *)&delay);
92605 snd_leave_user(fs);
92606 if (err < 0)
92607 return err;
92608 diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
92609 index eb560fa..69a4995 100644
92610 --- a/sound/core/pcm_native.c
92611 +++ b/sound/core/pcm_native.c
92612 @@ -2806,11 +2806,11 @@ int snd_pcm_kernel_ioctl(struct snd_pcm_substream *substream,
92613 switch (substream->stream) {
92614 case SNDRV_PCM_STREAM_PLAYBACK:
92615 result = snd_pcm_playback_ioctl1(NULL, substream, cmd,
92616 - (void __user *)arg);
92617 + (void __force_user *)arg);
92618 break;
92619 case SNDRV_PCM_STREAM_CAPTURE:
92620 result = snd_pcm_capture_ioctl1(NULL, substream, cmd,
92621 - (void __user *)arg);
92622 + (void __force_user *)arg);
92623 break;
92624 default:
92625 result = -EINVAL;
92626 diff --git a/sound/core/seq/seq_device.c b/sound/core/seq/seq_device.c
92627 index 040c60e..989a19a 100644
92628 --- a/sound/core/seq/seq_device.c
92629 +++ b/sound/core/seq/seq_device.c
92630 @@ -64,7 +64,7 @@ struct ops_list {
92631 int argsize; /* argument size */
92632
92633 /* operators */
92634 - struct snd_seq_dev_ops ops;
92635 + struct snd_seq_dev_ops *ops;
92636
92637 /* registered devices */
92638 struct list_head dev_list; /* list of devices */
92639 @@ -333,7 +333,7 @@ int snd_seq_device_register_driver(char *id, struct snd_seq_dev_ops *entry,
92640
92641 mutex_lock(&ops->reg_mutex);
92642 /* copy driver operators */
92643 - ops->ops = *entry;
92644 + ops->ops = entry;
92645 ops->driver |= DRIVER_LOADED;
92646 ops->argsize = argsize;
92647
92648 @@ -463,7 +463,7 @@ static int init_device(struct snd_seq_device *dev, struct ops_list *ops)
92649 dev->name, ops->id, ops->argsize, dev->argsize);
92650 return -EINVAL;
92651 }
92652 - if (ops->ops.init_device(dev) >= 0) {
92653 + if (ops->ops->init_device(dev) >= 0) {
92654 dev->status = SNDRV_SEQ_DEVICE_REGISTERED;
92655 ops->num_init_devices++;
92656 } else {
92657 @@ -490,7 +490,7 @@ static int free_device(struct snd_seq_device *dev, struct ops_list *ops)
92658 dev->name, ops->id, ops->argsize, dev->argsize);
92659 return -EINVAL;
92660 }
92661 - if ((result = ops->ops.free_device(dev)) >= 0 || result == -ENXIO) {
92662 + if ((result = ops->ops->free_device(dev)) >= 0 || result == -ENXIO) {
92663 dev->status = SNDRV_SEQ_DEVICE_FREE;
92664 dev->driver_data = NULL;
92665 ops->num_init_devices--;
92666 diff --git a/sound/drivers/mts64.c b/sound/drivers/mts64.c
92667 index 4e0dd22..7a1f32c 100644
92668 --- a/sound/drivers/mts64.c
92669 +++ b/sound/drivers/mts64.c
92670 @@ -29,6 +29,7 @@
92671 #include <sound/initval.h>
92672 #include <sound/rawmidi.h>
92673 #include <sound/control.h>
92674 +#include <asm/local.h>
92675
92676 #define CARD_NAME "Miditerminal 4140"
92677 #define DRIVER_NAME "MTS64"
92678 @@ -67,7 +68,7 @@ struct mts64 {
92679 struct pardevice *pardev;
92680 int pardev_claimed;
92681
92682 - int open_count;
92683 + local_t open_count;
92684 int current_midi_output_port;
92685 int current_midi_input_port;
92686 u8 mode[MTS64_NUM_INPUT_PORTS];
92687 @@ -697,7 +698,7 @@ static int snd_mts64_rawmidi_open(struct snd_rawmidi_substream *substream)
92688 {
92689 struct mts64 *mts = substream->rmidi->private_data;
92690
92691 - if (mts->open_count == 0) {
92692 + if (local_read(&mts->open_count) == 0) {
92693 /* We don't need a spinlock here, because this is just called
92694 if the device has not been opened before.
92695 So there aren't any IRQs from the device */
92696 @@ -705,7 +706,7 @@ static int snd_mts64_rawmidi_open(struct snd_rawmidi_substream *substream)
92697
92698 msleep(50);
92699 }
92700 - ++(mts->open_count);
92701 + local_inc(&mts->open_count);
92702
92703 return 0;
92704 }
92705 @@ -715,8 +716,7 @@ static int snd_mts64_rawmidi_close(struct snd_rawmidi_substream *substream)
92706 struct mts64 *mts = substream->rmidi->private_data;
92707 unsigned long flags;
92708
92709 - --(mts->open_count);
92710 - if (mts->open_count == 0) {
92711 + if (local_dec_return(&mts->open_count) == 0) {
92712 /* We need the spinlock_irqsave here because we can still
92713 have IRQs at this point */
92714 spin_lock_irqsave(&mts->lock, flags);
92715 @@ -725,8 +725,8 @@ static int snd_mts64_rawmidi_close(struct snd_rawmidi_substream *substream)
92716
92717 msleep(500);
92718
92719 - } else if (mts->open_count < 0)
92720 - mts->open_count = 0;
92721 + } else if (local_read(&mts->open_count) < 0)
92722 + local_set(&mts->open_count, 0);
92723
92724 return 0;
92725 }
92726 diff --git a/sound/drivers/opl4/opl4_lib.c b/sound/drivers/opl4/opl4_lib.c
92727 index b953fb4..1999c01 100644
92728 --- a/sound/drivers/opl4/opl4_lib.c
92729 +++ b/sound/drivers/opl4/opl4_lib.c
92730 @@ -29,7 +29,7 @@ MODULE_AUTHOR("Clemens Ladisch <clemens@ladisch.de>");
92731 MODULE_DESCRIPTION("OPL4 driver");
92732 MODULE_LICENSE("GPL");
92733
92734 -static void inline snd_opl4_wait(struct snd_opl4 *opl4)
92735 +static inline void snd_opl4_wait(struct snd_opl4 *opl4)
92736 {
92737 int timeout = 10;
92738 while ((inb(opl4->fm_port) & OPL4_STATUS_BUSY) && --timeout > 0)
92739 diff --git a/sound/drivers/portman2x4.c b/sound/drivers/portman2x4.c
92740 index 991018d..8984740 100644
92741 --- a/sound/drivers/portman2x4.c
92742 +++ b/sound/drivers/portman2x4.c
92743 @@ -48,6 +48,7 @@
92744 #include <sound/initval.h>
92745 #include <sound/rawmidi.h>
92746 #include <sound/control.h>
92747 +#include <asm/local.h>
92748
92749 #define CARD_NAME "Portman 2x4"
92750 #define DRIVER_NAME "portman"
92751 @@ -85,7 +86,7 @@ struct portman {
92752 struct pardevice *pardev;
92753 int pardev_claimed;
92754
92755 - int open_count;
92756 + local_t open_count;
92757 int mode[PORTMAN_NUM_INPUT_PORTS];
92758 struct snd_rawmidi_substream *midi_input[PORTMAN_NUM_INPUT_PORTS];
92759 };
92760 diff --git a/sound/firewire/amdtp.c b/sound/firewire/amdtp.c
92761 index ea995af..f1bfa37 100644
92762 --- a/sound/firewire/amdtp.c
92763 +++ b/sound/firewire/amdtp.c
92764 @@ -389,7 +389,7 @@ static void queue_out_packet(struct amdtp_out_stream *s, unsigned int cycle)
92765 ptr = s->pcm_buffer_pointer + data_blocks;
92766 if (ptr >= pcm->runtime->buffer_size)
92767 ptr -= pcm->runtime->buffer_size;
92768 - ACCESS_ONCE(s->pcm_buffer_pointer) = ptr;
92769 + ACCESS_ONCE_RW(s->pcm_buffer_pointer) = ptr;
92770
92771 s->pcm_period_pointer += data_blocks;
92772 if (s->pcm_period_pointer >= pcm->runtime->period_size) {
92773 @@ -557,7 +557,7 @@ EXPORT_SYMBOL(amdtp_out_stream_pcm_pointer);
92774 */
92775 void amdtp_out_stream_update(struct amdtp_out_stream *s)
92776 {
92777 - ACCESS_ONCE(s->source_node_id_field) =
92778 + ACCESS_ONCE_RW(s->source_node_id_field) =
92779 (fw_parent_device(s->unit)->card->node_id & 0x3f) << 24;
92780 }
92781 EXPORT_SYMBOL(amdtp_out_stream_update);
92782 diff --git a/sound/firewire/amdtp.h b/sound/firewire/amdtp.h
92783 index b680c5e..061b7a0 100644
92784 --- a/sound/firewire/amdtp.h
92785 +++ b/sound/firewire/amdtp.h
92786 @@ -139,7 +139,7 @@ static inline bool amdtp_out_streaming_error(struct amdtp_out_stream *s)
92787 static inline void amdtp_out_stream_pcm_trigger(struct amdtp_out_stream *s,
92788 struct snd_pcm_substream *pcm)
92789 {
92790 - ACCESS_ONCE(s->pcm) = pcm;
92791 + ACCESS_ONCE_RW(s->pcm) = pcm;
92792 }
92793
92794 static inline bool cip_sfc_is_base_44100(enum cip_sfc sfc)
92795 diff --git a/sound/firewire/isight.c b/sound/firewire/isight.c
92796 index d428ffe..751ef78 100644
92797 --- a/sound/firewire/isight.c
92798 +++ b/sound/firewire/isight.c
92799 @@ -96,7 +96,7 @@ static void isight_update_pointers(struct isight *isight, unsigned int count)
92800 ptr += count;
92801 if (ptr >= runtime->buffer_size)
92802 ptr -= runtime->buffer_size;
92803 - ACCESS_ONCE(isight->buffer_pointer) = ptr;
92804 + ACCESS_ONCE_RW(isight->buffer_pointer) = ptr;
92805
92806 isight->period_counter += count;
92807 if (isight->period_counter >= runtime->period_size) {
92808 @@ -307,7 +307,7 @@ static int isight_hw_params(struct snd_pcm_substream *substream,
92809 if (err < 0)
92810 return err;
92811
92812 - ACCESS_ONCE(isight->pcm_active) = true;
92813 + ACCESS_ONCE_RW(isight->pcm_active) = true;
92814
92815 return 0;
92816 }
92817 @@ -340,7 +340,7 @@ static int isight_hw_free(struct snd_pcm_substream *substream)
92818 {
92819 struct isight *isight = substream->private_data;
92820
92821 - ACCESS_ONCE(isight->pcm_active) = false;
92822 + ACCESS_ONCE_RW(isight->pcm_active) = false;
92823
92824 mutex_lock(&isight->mutex);
92825 isight_stop_streaming(isight);
92826 @@ -433,10 +433,10 @@ static int isight_trigger(struct snd_pcm_substream *substream, int cmd)
92827
92828 switch (cmd) {
92829 case SNDRV_PCM_TRIGGER_START:
92830 - ACCESS_ONCE(isight->pcm_running) = true;
92831 + ACCESS_ONCE_RW(isight->pcm_running) = true;
92832 break;
92833 case SNDRV_PCM_TRIGGER_STOP:
92834 - ACCESS_ONCE(isight->pcm_running) = false;
92835 + ACCESS_ONCE_RW(isight->pcm_running) = false;
92836 break;
92837 default:
92838 return -EINVAL;
92839 diff --git a/sound/firewire/scs1x.c b/sound/firewire/scs1x.c
92840 index 844a555..985ab83 100644
92841 --- a/sound/firewire/scs1x.c
92842 +++ b/sound/firewire/scs1x.c
92843 @@ -74,7 +74,7 @@ static void scs_output_trigger(struct snd_rawmidi_substream *stream, int up)
92844 {
92845 struct scs *scs = stream->rmidi->private_data;
92846
92847 - ACCESS_ONCE(scs->output) = up ? stream : NULL;
92848 + ACCESS_ONCE_RW(scs->output) = up ? stream : NULL;
92849 if (up) {
92850 scs->output_idle = false;
92851 tasklet_schedule(&scs->tasklet);
92852 @@ -257,7 +257,7 @@ static void scs_input_trigger(struct snd_rawmidi_substream *stream, int up)
92853 {
92854 struct scs *scs = stream->rmidi->private_data;
92855
92856 - ACCESS_ONCE(scs->input) = up ? stream : NULL;
92857 + ACCESS_ONCE_RW(scs->input) = up ? stream : NULL;
92858 }
92859
92860 static void scs_input_escaped_byte(struct snd_rawmidi_substream *stream,
92861 @@ -457,8 +457,8 @@ static int scs_remove(struct device *dev)
92862
92863 snd_card_disconnect(scs->card);
92864
92865 - ACCESS_ONCE(scs->output) = NULL;
92866 - ACCESS_ONCE(scs->input) = NULL;
92867 + ACCESS_ONCE_RW(scs->output) = NULL;
92868 + ACCESS_ONCE_RW(scs->input) = NULL;
92869
92870 wait_event(scs->idle_wait, scs->output_idle);
92871
92872 diff --git a/sound/oss/sb_audio.c b/sound/oss/sb_audio.c
92873 index 048439a..3be9f6f 100644
92874 --- a/sound/oss/sb_audio.c
92875 +++ b/sound/oss/sb_audio.c
92876 @@ -904,7 +904,7 @@ sb16_copy_from_user(int dev,
92877 buf16 = (signed short *)(localbuf + localoffs);
92878 while (c)
92879 {
92880 - locallen = (c >= LBUFCOPYSIZE ? LBUFCOPYSIZE : c);
92881 + locallen = ((unsigned)c >= LBUFCOPYSIZE ? LBUFCOPYSIZE : c);
92882 if (copy_from_user(lbuf8,
92883 userbuf+useroffs + p,
92884 locallen))
92885 diff --git a/sound/oss/swarm_cs4297a.c b/sound/oss/swarm_cs4297a.c
92886 index 7d8803a..559f8d0 100644
92887 --- a/sound/oss/swarm_cs4297a.c
92888 +++ b/sound/oss/swarm_cs4297a.c
92889 @@ -2621,7 +2621,6 @@ static int __init cs4297a_init(void)
92890 {
92891 struct cs4297a_state *s;
92892 u32 pwr, id;
92893 - mm_segment_t fs;
92894 int rval;
92895 #ifndef CONFIG_BCM_CS4297A_CSWARM
92896 u64 cfg;
92897 @@ -2711,22 +2710,23 @@ static int __init cs4297a_init(void)
92898 if (!rval) {
92899 char *sb1250_duart_present;
92900
92901 +#if 0
92902 + mm_segment_t fs;
92903 fs = get_fs();
92904 set_fs(KERNEL_DS);
92905 -#if 0
92906 val = SOUND_MASK_LINE;
92907 mixer_ioctl(s, SOUND_MIXER_WRITE_RECSRC, (unsigned long) &val);
92908 for (i = 0; i < ARRAY_SIZE(initvol); i++) {
92909 val = initvol[i].vol;
92910 mixer_ioctl(s, initvol[i].mixch, (unsigned long) &val);
92911 }
92912 + set_fs(fs);
92913 // cs4297a_write_ac97(s, 0x18, 0x0808);
92914 #else
92915 // cs4297a_write_ac97(s, 0x5e, 0x180);
92916 cs4297a_write_ac97(s, 0x02, 0x0808);
92917 cs4297a_write_ac97(s, 0x18, 0x0808);
92918 #endif
92919 - set_fs(fs);
92920
92921 list_add(&s->list, &cs4297a_devs);
92922
92923 diff --git a/sound/pci/ymfpci/ymfpci.h b/sound/pci/ymfpci/ymfpci.h
92924 index 4631a23..001ae57 100644
92925 --- a/sound/pci/ymfpci/ymfpci.h
92926 +++ b/sound/pci/ymfpci/ymfpci.h
92927 @@ -358,7 +358,7 @@ struct snd_ymfpci {
92928 spinlock_t reg_lock;
92929 spinlock_t voice_lock;
92930 wait_queue_head_t interrupt_sleep;
92931 - atomic_t interrupt_sleep_count;
92932 + atomic_unchecked_t interrupt_sleep_count;
92933 struct snd_info_entry *proc_entry;
92934 const struct firmware *dsp_microcode;
92935 const struct firmware *controller_microcode;
92936 diff --git a/sound/pci/ymfpci/ymfpci_main.c b/sound/pci/ymfpci/ymfpci_main.c
92937 index 22056c5..25d3244 100644
92938 --- a/sound/pci/ymfpci/ymfpci_main.c
92939 +++ b/sound/pci/ymfpci/ymfpci_main.c
92940 @@ -202,8 +202,8 @@ static void snd_ymfpci_hw_stop(struct snd_ymfpci *chip)
92941 if ((snd_ymfpci_readl(chip, YDSXGR_STATUS) & 2) == 0)
92942 break;
92943 }
92944 - if (atomic_read(&chip->interrupt_sleep_count)) {
92945 - atomic_set(&chip->interrupt_sleep_count, 0);
92946 + if (atomic_read_unchecked(&chip->interrupt_sleep_count)) {
92947 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
92948 wake_up(&chip->interrupt_sleep);
92949 }
92950 __end:
92951 @@ -787,7 +787,7 @@ static void snd_ymfpci_irq_wait(struct snd_ymfpci *chip)
92952 continue;
92953 init_waitqueue_entry(&wait, current);
92954 add_wait_queue(&chip->interrupt_sleep, &wait);
92955 - atomic_inc(&chip->interrupt_sleep_count);
92956 + atomic_inc_unchecked(&chip->interrupt_sleep_count);
92957 schedule_timeout_uninterruptible(msecs_to_jiffies(50));
92958 remove_wait_queue(&chip->interrupt_sleep, &wait);
92959 }
92960 @@ -825,8 +825,8 @@ static irqreturn_t snd_ymfpci_interrupt(int irq, void *dev_id)
92961 snd_ymfpci_writel(chip, YDSXGR_MODE, mode);
92962 spin_unlock(&chip->reg_lock);
92963
92964 - if (atomic_read(&chip->interrupt_sleep_count)) {
92965 - atomic_set(&chip->interrupt_sleep_count, 0);
92966 + if (atomic_read_unchecked(&chip->interrupt_sleep_count)) {
92967 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
92968 wake_up(&chip->interrupt_sleep);
92969 }
92970 }
92971 @@ -2421,7 +2421,7 @@ int snd_ymfpci_create(struct snd_card *card,
92972 spin_lock_init(&chip->reg_lock);
92973 spin_lock_init(&chip->voice_lock);
92974 init_waitqueue_head(&chip->interrupt_sleep);
92975 - atomic_set(&chip->interrupt_sleep_count, 0);
92976 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
92977 chip->card = card;
92978 chip->pci = pci;
92979 chip->irq = -1;
92980 diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c
92981 index 7decbd9..d17d9d0 100644
92982 --- a/sound/soc/fsl/fsl_ssi.c
92983 +++ b/sound/soc/fsl/fsl_ssi.c
92984 @@ -643,7 +643,7 @@ static int fsl_ssi_probe(struct platform_device *pdev)
92985 {
92986 struct fsl_ssi_private *ssi_private;
92987 int ret = 0;
92988 - struct device_attribute *dev_attr = NULL;
92989 + device_attribute_no_const *dev_attr = NULL;
92990 struct device_node *np = pdev->dev.of_node;
92991 const char *p, *sprop;
92992 const uint32_t *iprop;
92993 diff --git a/tools/gcc/.gitignore b/tools/gcc/.gitignore
92994 new file mode 100644
92995 index 0000000..50f2f2f
92996 --- /dev/null
92997 +++ b/tools/gcc/.gitignore
92998 @@ -0,0 +1 @@
92999 +size_overflow_hash.h
93000 diff --git a/tools/gcc/Makefile b/tools/gcc/Makefile
93001 new file mode 100644
93002 index 0000000..144dbee
93003 --- /dev/null
93004 +++ b/tools/gcc/Makefile
93005 @@ -0,0 +1,45 @@
93006 +#CC := gcc
93007 +#PLUGIN_SOURCE_FILES := pax_plugin.c
93008 +#PLUGIN_OBJECT_FILES := $(patsubst %.c,%.o,$(PLUGIN_SOURCE_FILES))
93009 +GCCPLUGINS_DIR := $(shell $(CC) -print-file-name=plugin)
93010 +#CFLAGS += -I$(GCCPLUGINS_DIR)/include -fPIC -O2 -Wall -W -std=gnu99
93011 +
93012 +ifeq ($(PLUGINCC),$(HOSTCC))
93013 +HOSTLIBS := hostlibs
93014 +HOST_EXTRACFLAGS += -I$(GCCPLUGINS_DIR)/include -std=gnu99 -ggdb
93015 +else
93016 +HOSTLIBS := hostcxxlibs
93017 +HOST_EXTRACXXFLAGS += -I$(GCCPLUGINS_DIR)/include -std=gnu++98 -ggdb -Wno-unused-parameter
93018 +endif
93019 +
93020 +$(HOSTLIBS)-$(CONFIG_PAX_CONSTIFY_PLUGIN) := constify_plugin.so
93021 +$(HOSTLIBS)-$(CONFIG_PAX_MEMORY_STACKLEAK) += stackleak_plugin.so
93022 +$(HOSTLIBS)-$(CONFIG_KALLOCSTAT_PLUGIN) += kallocstat_plugin.so
93023 +$(HOSTLIBS)-$(CONFIG_PAX_KERNEXEC_PLUGIN) += kernexec_plugin.so
93024 +$(HOSTLIBS)-$(CONFIG_CHECKER_PLUGIN) += checker_plugin.so
93025 +$(HOSTLIBS)-y += colorize_plugin.so
93026 +$(HOSTLIBS)-$(CONFIG_PAX_SIZE_OVERFLOW) += size_overflow_plugin.so
93027 +$(HOSTLIBS)-$(CONFIG_PAX_LATENT_ENTROPY) += latent_entropy_plugin.so
93028 +$(HOSTLIBS)-$(CONFIG_PAX_MEMORY_STRUCTLEAK) += structleak_plugin.so
93029 +
93030 +always := $($(HOSTLIBS)-y)
93031 +
93032 +constify_plugin-objs := constify_plugin.o
93033 +stackleak_plugin-objs := stackleak_plugin.o
93034 +kallocstat_plugin-objs := kallocstat_plugin.o
93035 +kernexec_plugin-objs := kernexec_plugin.o
93036 +checker_plugin-objs := checker_plugin.o
93037 +colorize_plugin-objs := colorize_plugin.o
93038 +size_overflow_plugin-objs := size_overflow_plugin.o
93039 +latent_entropy_plugin-objs := latent_entropy_plugin.o
93040 +structleak_plugin-objs := structleak_plugin.o
93041 +
93042 +$(obj)/size_overflow_plugin.o: $(objtree)/$(obj)/size_overflow_hash.h
93043 +
93044 +quiet_cmd_build_size_overflow_hash = GENHASH $@
93045 + cmd_build_size_overflow_hash = \
93046 + $(CONFIG_SHELL) $(srctree)/$(src)/generate_size_overflow_hash.sh -d $< -o $@
93047 +$(objtree)/$(obj)/size_overflow_hash.h: $(src)/size_overflow_hash.data FORCE
93048 + $(call if_changed,build_size_overflow_hash)
93049 +
93050 +targets += size_overflow_hash.h
93051 diff --git a/tools/gcc/checker_plugin.c b/tools/gcc/checker_plugin.c
93052 new file mode 100644
93053 index 0000000..22f03c0
93054 --- /dev/null
93055 +++ b/tools/gcc/checker_plugin.c
93056 @@ -0,0 +1,172 @@
93057 +/*
93058 + * Copyright 2011 by the PaX Team <pageexec@freemail.hu>
93059 + * Licensed under the GPL v2
93060 + *
93061 + * Note: the choice of the license means that the compilation process is
93062 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
93063 + * but for the kernel it doesn't matter since it doesn't link against
93064 + * any of the gcc libraries
93065 + *
93066 + * gcc plugin to implement various sparse (source code checker) features
93067 + *
93068 + * TODO:
93069 + * - define separate __iomem, __percpu and __rcu address spaces (lots of code to patch)
93070 + *
93071 + * BUGS:
93072 + * - none known
93073 + */
93074 +#include "gcc-plugin.h"
93075 +#include "config.h"
93076 +#include "system.h"
93077 +#include "coretypes.h"
93078 +#include "tree.h"
93079 +#include "tree-pass.h"
93080 +#include "flags.h"
93081 +#include "intl.h"
93082 +#include "toplev.h"
93083 +#include "plugin.h"
93084 +//#include "expr.h" where are you...
93085 +#include "diagnostic.h"
93086 +#include "plugin-version.h"
93087 +#include "tm.h"
93088 +#include "function.h"
93089 +#include "basic-block.h"
93090 +#include "gimple.h"
93091 +#include "rtl.h"
93092 +#include "emit-rtl.h"
93093 +#include "tree-flow.h"
93094 +#include "target.h"
93095 +
93096 +extern void c_register_addr_space (const char *str, addr_space_t as);
93097 +extern enum machine_mode default_addr_space_pointer_mode (addr_space_t);
93098 +extern enum machine_mode default_addr_space_address_mode (addr_space_t);
93099 +extern bool default_addr_space_valid_pointer_mode(enum machine_mode mode, addr_space_t as);
93100 +extern bool default_addr_space_legitimate_address_p(enum machine_mode mode, rtx mem, bool strict, addr_space_t as);
93101 +extern rtx default_addr_space_legitimize_address(rtx x, rtx oldx, enum machine_mode mode, addr_space_t as);
93102 +
93103 +extern void print_gimple_stmt(FILE *, gimple, int, int);
93104 +extern rtx emit_move_insn(rtx x, rtx y);
93105 +
93106 +int plugin_is_GPL_compatible;
93107 +
93108 +static struct plugin_info checker_plugin_info = {
93109 + .version = "201111150100",
93110 + .help = NULL,
93111 +};
93112 +
93113 +#define ADDR_SPACE_KERNEL 0
93114 +#define ADDR_SPACE_FORCE_KERNEL 1
93115 +#define ADDR_SPACE_USER 2
93116 +#define ADDR_SPACE_FORCE_USER 3
93117 +#define ADDR_SPACE_IOMEM 0
93118 +#define ADDR_SPACE_FORCE_IOMEM 0
93119 +#define ADDR_SPACE_PERCPU 0
93120 +#define ADDR_SPACE_FORCE_PERCPU 0
93121 +#define ADDR_SPACE_RCU 0
93122 +#define ADDR_SPACE_FORCE_RCU 0
93123 +
93124 +static enum machine_mode checker_addr_space_pointer_mode(addr_space_t addrspace)
93125 +{
93126 + return default_addr_space_pointer_mode(ADDR_SPACE_GENERIC);
93127 +}
93128 +
93129 +static enum machine_mode checker_addr_space_address_mode(addr_space_t addrspace)
93130 +{
93131 + return default_addr_space_address_mode(ADDR_SPACE_GENERIC);
93132 +}
93133 +
93134 +static bool checker_addr_space_valid_pointer_mode(enum machine_mode mode, addr_space_t as)
93135 +{
93136 + return default_addr_space_valid_pointer_mode(mode, as);
93137 +}
93138 +
93139 +static bool checker_addr_space_legitimate_address_p(enum machine_mode mode, rtx mem, bool strict, addr_space_t as)
93140 +{
93141 + return default_addr_space_legitimate_address_p(mode, mem, strict, ADDR_SPACE_GENERIC);
93142 +}
93143 +
93144 +static rtx checker_addr_space_legitimize_address(rtx x, rtx oldx, enum machine_mode mode, addr_space_t as)
93145 +{
93146 + return default_addr_space_legitimize_address(x, oldx, mode, as);
93147 +}
93148 +
93149 +static bool checker_addr_space_subset_p(addr_space_t subset, addr_space_t superset)
93150 +{
93151 + if (subset == ADDR_SPACE_FORCE_KERNEL && superset == ADDR_SPACE_KERNEL)
93152 + return true;
93153 +
93154 + if (subset == ADDR_SPACE_FORCE_USER && superset == ADDR_SPACE_USER)
93155 + return true;
93156 +
93157 + if (subset == ADDR_SPACE_FORCE_IOMEM && superset == ADDR_SPACE_IOMEM)
93158 + return true;
93159 +
93160 + if (subset == ADDR_SPACE_KERNEL && superset == ADDR_SPACE_FORCE_USER)
93161 + return true;
93162 +
93163 + if (subset == ADDR_SPACE_KERNEL && superset == ADDR_SPACE_FORCE_IOMEM)
93164 + return true;
93165 +
93166 + if (subset == ADDR_SPACE_USER && superset == ADDR_SPACE_FORCE_KERNEL)
93167 + return true;
93168 +
93169 + if (subset == ADDR_SPACE_IOMEM && superset == ADDR_SPACE_FORCE_KERNEL)
93170 + return true;
93171 +
93172 + return subset == superset;
93173 +}
93174 +
93175 +static rtx checker_addr_space_convert(rtx op, tree from_type, tree to_type)
93176 +{
93177 +// addr_space_t from_as = TYPE_ADDR_SPACE(TREE_TYPE(from_type));
93178 +// addr_space_t to_as = TYPE_ADDR_SPACE(TREE_TYPE(to_type));
93179 +
93180 + return op;
93181 +}
93182 +
93183 +static void register_checker_address_spaces(void *event_data, void *data)
93184 +{
93185 + c_register_addr_space("__kernel", ADDR_SPACE_KERNEL);
93186 + c_register_addr_space("__force_kernel", ADDR_SPACE_FORCE_KERNEL);
93187 + c_register_addr_space("__user", ADDR_SPACE_USER);
93188 + c_register_addr_space("__force_user", ADDR_SPACE_FORCE_USER);
93189 +// c_register_addr_space("__iomem", ADDR_SPACE_IOMEM);
93190 +// c_register_addr_space("__force_iomem", ADDR_SPACE_FORCE_IOMEM);
93191 +// c_register_addr_space("__percpu", ADDR_SPACE_PERCPU);
93192 +// c_register_addr_space("__force_percpu", ADDR_SPACE_FORCE_PERCPU);
93193 +// c_register_addr_space("__rcu", ADDR_SPACE_RCU);
93194 +// c_register_addr_space("__force_rcu", ADDR_SPACE_FORCE_RCU);
93195 +
93196 + targetm.addr_space.pointer_mode = checker_addr_space_pointer_mode;
93197 + targetm.addr_space.address_mode = checker_addr_space_address_mode;
93198 + targetm.addr_space.valid_pointer_mode = checker_addr_space_valid_pointer_mode;
93199 + targetm.addr_space.legitimate_address_p = checker_addr_space_legitimate_address_p;
93200 +// targetm.addr_space.legitimize_address = checker_addr_space_legitimize_address;
93201 + targetm.addr_space.subset_p = checker_addr_space_subset_p;
93202 + targetm.addr_space.convert = checker_addr_space_convert;
93203 +}
93204 +
93205 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
93206 +{
93207 + const char * const plugin_name = plugin_info->base_name;
93208 + const int argc = plugin_info->argc;
93209 + const struct plugin_argument * const argv = plugin_info->argv;
93210 + int i;
93211 +
93212 + if (!plugin_default_version_check(version, &gcc_version)) {
93213 + error(G_("incompatible gcc/plugin versions"));
93214 + return 1;
93215 + }
93216 +
93217 + register_callback(plugin_name, PLUGIN_INFO, NULL, &checker_plugin_info);
93218 +
93219 + for (i = 0; i < argc; ++i)
93220 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
93221 +
93222 + if (TARGET_64BIT == 0)
93223 + return 0;
93224 +
93225 + register_callback(plugin_name, PLUGIN_PRAGMAS, register_checker_address_spaces, NULL);
93226 +
93227 + return 0;
93228 +}
93229 diff --git a/tools/gcc/colorize_plugin.c b/tools/gcc/colorize_plugin.c
93230 new file mode 100644
93231 index 0000000..414fe5e
93232 --- /dev/null
93233 +++ b/tools/gcc/colorize_plugin.c
93234 @@ -0,0 +1,151 @@
93235 +/*
93236 + * Copyright 2012-2013 by PaX Team <pageexec@freemail.hu>
93237 + * Licensed under the GPL v2
93238 + *
93239 + * Note: the choice of the license means that the compilation process is
93240 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
93241 + * but for the kernel it doesn't matter since it doesn't link against
93242 + * any of the gcc libraries
93243 + *
93244 + * gcc plugin to colorize diagnostic output
93245 + *
93246 + */
93247 +
93248 +#include "gcc-plugin.h"
93249 +#include "config.h"
93250 +#include "system.h"
93251 +#include "coretypes.h"
93252 +#include "tree.h"
93253 +#include "tree-pass.h"
93254 +#include "flags.h"
93255 +#include "intl.h"
93256 +#include "toplev.h"
93257 +#include "plugin.h"
93258 +#include "diagnostic.h"
93259 +#include "plugin-version.h"
93260 +#include "tm.h"
93261 +
93262 +int plugin_is_GPL_compatible;
93263 +
93264 +static struct plugin_info colorize_plugin_info = {
93265 + .version = "201302112000",
93266 + .help = NULL,
93267 +};
93268 +
93269 +#define GREEN "\033[32m\033[2m"
93270 +#define LIGHTGREEN "\033[32m\033[1m"
93271 +#define YELLOW "\033[33m\033[2m"
93272 +#define LIGHTYELLOW "\033[33m\033[1m"
93273 +#define RED "\033[31m\033[2m"
93274 +#define LIGHTRED "\033[31m\033[1m"
93275 +#define BLUE "\033[34m\033[2m"
93276 +#define LIGHTBLUE "\033[34m\033[1m"
93277 +#define BRIGHT "\033[m\033[1m"
93278 +#define NORMAL "\033[m"
93279 +
93280 +static diagnostic_starter_fn old_starter;
93281 +static diagnostic_finalizer_fn old_finalizer;
93282 +
93283 +static void start_colorize(diagnostic_context *context, diagnostic_info *diagnostic)
93284 +{
93285 + const char *color;
93286 + char *newprefix;
93287 +
93288 + switch (diagnostic->kind) {
93289 + case DK_NOTE:
93290 + color = LIGHTBLUE;
93291 + break;
93292 +
93293 + case DK_PEDWARN:
93294 + case DK_WARNING:
93295 + color = LIGHTYELLOW;
93296 + break;
93297 +
93298 + case DK_ERROR:
93299 + case DK_FATAL:
93300 + case DK_ICE:
93301 + case DK_PERMERROR:
93302 + case DK_SORRY:
93303 + color = LIGHTRED;
93304 + break;
93305 +
93306 + default:
93307 + color = NORMAL;
93308 + }
93309 +
93310 + old_starter(context, diagnostic);
93311 + if (-1 == asprintf(&newprefix, "%s%s" NORMAL, color, context->printer->prefix))
93312 + return;
93313 + pp_destroy_prefix(context->printer);
93314 + pp_set_prefix(context->printer, newprefix);
93315 +}
93316 +
93317 +static void finalize_colorize(diagnostic_context *context, diagnostic_info *diagnostic)
93318 +{
93319 + old_finalizer(context, diagnostic);
93320 +}
93321 +
93322 +static void colorize_arm(void)
93323 +{
93324 + old_starter = diagnostic_starter(global_dc);
93325 + old_finalizer = diagnostic_finalizer(global_dc);
93326 +
93327 + diagnostic_starter(global_dc) = start_colorize;
93328 + diagnostic_finalizer(global_dc) = finalize_colorize;
93329 +}
93330 +
93331 +static unsigned int execute_colorize_rearm(void)
93332 +{
93333 + if (diagnostic_starter(global_dc) == start_colorize)
93334 + return 0;
93335 +
93336 + colorize_arm();
93337 + return 0;
93338 +}
93339 +
93340 +struct simple_ipa_opt_pass pass_ipa_colorize_rearm = {
93341 + .pass = {
93342 + .type = SIMPLE_IPA_PASS,
93343 + .name = "colorize_rearm",
93344 +#if BUILDING_GCC_VERSION >= 4008
93345 + .optinfo_flags = OPTGROUP_NONE,
93346 +#endif
93347 + .gate = NULL,
93348 + .execute = execute_colorize_rearm,
93349 + .sub = NULL,
93350 + .next = NULL,
93351 + .static_pass_number = 0,
93352 + .tv_id = TV_NONE,
93353 + .properties_required = 0,
93354 + .properties_provided = 0,
93355 + .properties_destroyed = 0,
93356 + .todo_flags_start = 0,
93357 + .todo_flags_finish = 0
93358 + }
93359 +};
93360 +
93361 +static void colorize_start_unit(void *gcc_data, void *user_data)
93362 +{
93363 + colorize_arm();
93364 +}
93365 +
93366 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
93367 +{
93368 + const char * const plugin_name = plugin_info->base_name;
93369 + struct register_pass_info colorize_rearm_pass_info = {
93370 + .pass = &pass_ipa_colorize_rearm.pass,
93371 + .reference_pass_name = "*free_lang_data",
93372 + .ref_pass_instance_number = 1,
93373 + .pos_op = PASS_POS_INSERT_AFTER
93374 + };
93375 +
93376 + if (!plugin_default_version_check(version, &gcc_version)) {
93377 + error(G_("incompatible gcc/plugin versions"));
93378 + return 1;
93379 + }
93380 +
93381 + register_callback(plugin_name, PLUGIN_INFO, NULL, &colorize_plugin_info);
93382 + register_callback(plugin_name, PLUGIN_START_UNIT, &colorize_start_unit, NULL);
93383 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &colorize_rearm_pass_info);
93384 + return 0;
93385 +}
93386 diff --git a/tools/gcc/constify_plugin.c b/tools/gcc/constify_plugin.c
93387 new file mode 100644
93388 index 0000000..c17312d
93389 --- /dev/null
93390 +++ b/tools/gcc/constify_plugin.c
93391 @@ -0,0 +1,560 @@
93392 +/*
93393 + * Copyright 2011 by Emese Revfy <re.emese@gmail.com>
93394 + * Copyright 2011-2013 by PaX Team <pageexec@freemail.hu>
93395 + * Licensed under the GPL v2, or (at your option) v3
93396 + *
93397 + * This gcc plugin constifies all structures which contain only function pointers or are explicitly marked for constification.
93398 + *
93399 + * Homepage:
93400 + * http://www.grsecurity.net/~ephox/const_plugin/
93401 + *
93402 + * Usage:
93403 + * $ gcc -I`gcc -print-file-name=plugin`/include -fPIC -shared -O2 -o constify_plugin.so constify_plugin.c
93404 + * $ gcc -fplugin=constify_plugin.so test.c -O2
93405 + */
93406 +
93407 +#include "gcc-plugin.h"
93408 +#include "config.h"
93409 +#include "system.h"
93410 +#include "coretypes.h"
93411 +#include "tree.h"
93412 +#include "tree-pass.h"
93413 +#include "flags.h"
93414 +#include "intl.h"
93415 +#include "toplev.h"
93416 +#include "plugin.h"
93417 +#include "diagnostic.h"
93418 +#include "plugin-version.h"
93419 +#include "tm.h"
93420 +#include "function.h"
93421 +#include "basic-block.h"
93422 +#include "gimple.h"
93423 +#include "rtl.h"
93424 +#include "emit-rtl.h"
93425 +#include "tree-flow.h"
93426 +#include "target.h"
93427 +#include "langhooks.h"
93428 +
93429 +// should come from c-tree.h if only it were installed for gcc 4.5...
93430 +#define C_TYPE_FIELDS_READONLY(TYPE) TREE_LANG_FLAG_1(TYPE)
93431 +
93432 +// unused type flag in all versions 4.5-4.8
93433 +#define TYPE_CONSTIFY_VISITED(TYPE) TYPE_LANG_FLAG_4(TYPE)
93434 +
93435 +int plugin_is_GPL_compatible;
93436 +
93437 +static struct plugin_info const_plugin_info = {
93438 + .version = "201305231310",
93439 + .help = "no-constify\tturn off constification\n",
93440 +};
93441 +
93442 +typedef struct {
93443 + bool has_fptr_field;
93444 + bool has_writable_field;
93445 + bool has_do_const_field;
93446 + bool has_no_const_field;
93447 +} constify_info;
93448 +
93449 +static const_tree get_field_type(const_tree field)
93450 +{
93451 + return strip_array_types(TREE_TYPE(field));
93452 +}
93453 +
93454 +static bool is_fptr(const_tree field)
93455 +{
93456 + const_tree ptr = get_field_type(field);
93457 +
93458 + if (TREE_CODE(ptr) != POINTER_TYPE)
93459 + return false;
93460 +
93461 + return TREE_CODE(TREE_TYPE(ptr)) == FUNCTION_TYPE;
93462 +}
93463 +
93464 +/*
93465 + * determine whether the given structure type meets the requirements for automatic constification,
93466 + * including the constification attributes on nested structure types
93467 + */
93468 +static void constifiable(const_tree node, constify_info *cinfo)
93469 +{
93470 + const_tree field;
93471 +
93472 + gcc_assert(TREE_CODE(node) == RECORD_TYPE || TREE_CODE(node) == UNION_TYPE);
93473 +
93474 + // e.g., pointer to structure fields while still constructing the structure type
93475 + if (TYPE_FIELDS(node) == NULL_TREE)
93476 + return;
93477 +
93478 + for (field = TYPE_FIELDS(node); field; field = TREE_CHAIN(field)) {
93479 + const_tree type = get_field_type(field);
93480 + enum tree_code code = TREE_CODE(type);
93481 +
93482 + if (node == type)
93483 + continue;
93484 +
93485 + if (is_fptr(field))
93486 + cinfo->has_fptr_field = true;
93487 + else if (!TREE_READONLY(field))
93488 + cinfo->has_writable_field = true;
93489 +
93490 + if (code == RECORD_TYPE || code == UNION_TYPE) {
93491 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
93492 + cinfo->has_do_const_field = true;
93493 + else if (lookup_attribute("no_const", TYPE_ATTRIBUTES(type)))
93494 + cinfo->has_no_const_field = true;
93495 + else
93496 + constifiable(type, cinfo);
93497 + }
93498 + }
93499 +}
93500 +
93501 +static bool constified(const_tree node)
93502 +{
93503 + constify_info cinfo = {
93504 + .has_fptr_field = false,
93505 + .has_writable_field = false,
93506 + .has_do_const_field = false,
93507 + .has_no_const_field = false
93508 + };
93509 +
93510 + gcc_assert(TREE_CODE(node) == RECORD_TYPE || TREE_CODE(node) == UNION_TYPE);
93511 +
93512 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(node))) {
93513 + gcc_assert(!TYPE_READONLY(node));
93514 + return false;
93515 + }
93516 +
93517 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(node))) {
93518 + gcc_assert(TYPE_READONLY(node));
93519 + return true;
93520 + }
93521 +
93522 + constifiable(node, &cinfo);
93523 + if ((!cinfo.has_fptr_field || cinfo.has_writable_field) && !cinfo.has_do_const_field)
93524 + return false;
93525 +
93526 + return TYPE_READONLY(node);
93527 +}
93528 +
93529 +static void deconstify_tree(tree node);
93530 +
93531 +static void deconstify_type(tree type)
93532 +{
93533 + tree field;
93534 +
93535 + gcc_assert(TREE_CODE(type) == RECORD_TYPE || TREE_CODE(type) == UNION_TYPE);
93536 +
93537 + for (field = TYPE_FIELDS(type); field; field = TREE_CHAIN(field)) {
93538 + const_tree fieldtype = get_field_type(field);
93539 +
93540 + // special case handling of simple ptr-to-same-array-type members
93541 + if (TREE_CODE(TREE_TYPE(field)) == POINTER_TYPE) {
93542 + const_tree ptrtype = TREE_TYPE(TREE_TYPE(field));
93543 +
93544 + if (TREE_CODE(ptrtype) != RECORD_TYPE && TREE_CODE(ptrtype) != UNION_TYPE)
93545 + continue;
93546 + if (TREE_TYPE(TREE_TYPE(field)) == type)
93547 + continue;
93548 + if (TYPE_MAIN_VARIANT(ptrtype) == TYPE_MAIN_VARIANT(type)) {
93549 + TREE_TYPE(field) = copy_node(TREE_TYPE(field));
93550 + TREE_TYPE(TREE_TYPE(field)) = type;
93551 + }
93552 + continue;
93553 + }
93554 + if (TREE_CODE(fieldtype) != RECORD_TYPE && TREE_CODE(fieldtype) != UNION_TYPE)
93555 + continue;
93556 + if (!constified(fieldtype))
93557 + continue;
93558 +
93559 + deconstify_tree(field);
93560 + TREE_READONLY(field) = 0;
93561 + }
93562 + TYPE_READONLY(type) = 0;
93563 + C_TYPE_FIELDS_READONLY(type) = 0;
93564 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
93565 + TYPE_ATTRIBUTES(type) = remove_attribute("do_const", TYPE_ATTRIBUTES(type));
93566 +}
93567 +
93568 +static void deconstify_tree(tree node)
93569 +{
93570 + tree old_type, new_type, field;
93571 +
93572 + old_type = TREE_TYPE(node);
93573 + while (TREE_CODE(old_type) == ARRAY_TYPE && TREE_CODE(TREE_TYPE(old_type)) != ARRAY_TYPE) {
93574 + node = TREE_TYPE(node) = copy_node(old_type);
93575 + old_type = TREE_TYPE(old_type);
93576 + }
93577 +
93578 + gcc_assert(TREE_CODE(old_type) == RECORD_TYPE || TREE_CODE(old_type) == UNION_TYPE);
93579 + gcc_assert(TYPE_READONLY(old_type) && (TYPE_QUALS(old_type) & TYPE_QUAL_CONST));
93580 +
93581 + new_type = build_qualified_type(old_type, TYPE_QUALS(old_type) & ~TYPE_QUAL_CONST);
93582 + TYPE_FIELDS(new_type) = copy_list(TYPE_FIELDS(new_type));
93583 + for (field = TYPE_FIELDS(new_type); field; field = TREE_CHAIN(field))
93584 + DECL_FIELD_CONTEXT(field) = new_type;
93585 +
93586 + deconstify_type(new_type);
93587 +
93588 + TREE_TYPE(node) = new_type;
93589 +}
93590 +
93591 +static tree handle_no_const_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
93592 +{
93593 + tree type;
93594 + constify_info cinfo = {
93595 + .has_fptr_field = false,
93596 + .has_writable_field = false,
93597 + .has_do_const_field = false,
93598 + .has_no_const_field = false
93599 + };
93600 +
93601 + *no_add_attrs = true;
93602 + if (TREE_CODE(*node) == FUNCTION_DECL) {
93603 + error("%qE attribute does not apply to functions", name);
93604 + return NULL_TREE;
93605 + }
93606 +
93607 + if (TREE_CODE(*node) == PARM_DECL) {
93608 + error("%qE attribute does not apply to function parameters", name);
93609 + return NULL_TREE;
93610 + }
93611 +
93612 + if (TREE_CODE(*node) == VAR_DECL) {
93613 + error("%qE attribute does not apply to variables", name);
93614 + return NULL_TREE;
93615 + }
93616 +
93617 + if (TYPE_P(*node)) {
93618 + *no_add_attrs = false;
93619 + type = *node;
93620 + } else {
93621 + gcc_assert(TREE_CODE(*node) == TYPE_DECL);
93622 + type = TREE_TYPE(*node);
93623 + }
93624 +
93625 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE) {
93626 + error("%qE attribute applies to struct and union types only", name);
93627 + return NULL_TREE;
93628 + }
93629 +
93630 + if (lookup_attribute(IDENTIFIER_POINTER(name), TYPE_ATTRIBUTES(type))) {
93631 + error("%qE attribute is already applied to the type", name);
93632 + return NULL_TREE;
93633 + }
93634 +
93635 + if (TYPE_P(*node)) {
93636 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
93637 + error("%qE attribute is incompatible with 'do_const'", name);
93638 + return NULL_TREE;
93639 + }
93640 +
93641 + constifiable(type, &cinfo);
93642 + if ((cinfo.has_fptr_field && !cinfo.has_writable_field) || lookup_attribute("do_const", TYPE_ATTRIBUTES(type))) {
93643 + deconstify_tree(*node);
93644 + TYPE_CONSTIFY_VISITED(TREE_TYPE(*node)) = 1;
93645 + return NULL_TREE;
93646 + }
93647 +
93648 + error("%qE attribute used on type that is not constified", name);
93649 + return NULL_TREE;
93650 +}
93651 +
93652 +static void constify_type(tree type)
93653 +{
93654 + TYPE_READONLY(type) = 1;
93655 + C_TYPE_FIELDS_READONLY(type) = 1;
93656 + TYPE_CONSTIFY_VISITED(type) = 1;
93657 +// TYPE_ATTRIBUTES(type) = tree_cons(get_identifier("do_const"), NULL_TREE, TYPE_ATTRIBUTES(type));
93658 +}
93659 +
93660 +static tree handle_do_const_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
93661 +{
93662 + *no_add_attrs = true;
93663 + if (!TYPE_P(*node)) {
93664 + error("%qE attribute applies to types only", name);
93665 + return NULL_TREE;
93666 + }
93667 +
93668 + if (TREE_CODE(*node) != RECORD_TYPE && TREE_CODE(*node) != UNION_TYPE) {
93669 + error("%qE attribute applies to struct and union types only", name);
93670 + return NULL_TREE;
93671 + }
93672 +
93673 + if (lookup_attribute(IDENTIFIER_POINTER(name), TYPE_ATTRIBUTES(*node))) {
93674 + error("%qE attribute is already applied to the type", name);
93675 + return NULL_TREE;
93676 + }
93677 +
93678 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(*node))) {
93679 + error("%qE attribute is incompatible with 'no_const'", name);
93680 + return NULL_TREE;
93681 + }
93682 +
93683 + *no_add_attrs = false;
93684 + return NULL_TREE;
93685 +}
93686 +
93687 +static struct attribute_spec no_const_attr = {
93688 + .name = "no_const",
93689 + .min_length = 0,
93690 + .max_length = 0,
93691 + .decl_required = false,
93692 + .type_required = false,
93693 + .function_type_required = false,
93694 + .handler = handle_no_const_attribute,
93695 +#if BUILDING_GCC_VERSION >= 4007
93696 + .affects_type_identity = true
93697 +#endif
93698 +};
93699 +
93700 +static struct attribute_spec do_const_attr = {
93701 + .name = "do_const",
93702 + .min_length = 0,
93703 + .max_length = 0,
93704 + .decl_required = false,
93705 + .type_required = false,
93706 + .function_type_required = false,
93707 + .handler = handle_do_const_attribute,
93708 +#if BUILDING_GCC_VERSION >= 4007
93709 + .affects_type_identity = true
93710 +#endif
93711 +};
93712 +
93713 +static void register_attributes(void *event_data, void *data)
93714 +{
93715 + register_attribute(&no_const_attr);
93716 + register_attribute(&do_const_attr);
93717 +}
93718 +
93719 +static void finish_type(void *event_data, void *data)
93720 +{
93721 + tree type = (tree)event_data;
93722 + constify_info cinfo = {
93723 + .has_fptr_field = false,
93724 + .has_writable_field = false,
93725 + .has_do_const_field = false,
93726 + .has_no_const_field = false
93727 + };
93728 +
93729 + if (type == NULL_TREE || type == error_mark_node)
93730 + return;
93731 +
93732 + if (TYPE_FIELDS(type) == NULL_TREE || TYPE_CONSTIFY_VISITED(type))
93733 + return;
93734 +
93735 + constifiable(type, &cinfo);
93736 +
93737 + if (TYPE_READONLY(type) && C_TYPE_FIELDS_READONLY(type)) {
93738 + if (!lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
93739 + return;
93740 + if (cinfo.has_writable_field)
93741 + return;
93742 + error("'do_const' attribute used on type that is%sconstified", cinfo.has_fptr_field ? " " : " not ");
93743 + return;
93744 + }
93745 +
93746 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(type))) {
93747 + if ((cinfo.has_fptr_field && !cinfo.has_writable_field) || cinfo.has_do_const_field) {
93748 + deconstify_type(type);
93749 + TYPE_CONSTIFY_VISITED(type) = 1;
93750 + } else
93751 + error("'no_const' attribute used on type that is not constified");
93752 + return;
93753 + }
93754 +
93755 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type))) {
93756 + constify_type(type);
93757 + return;
93758 + }
93759 +
93760 + if (cinfo.has_fptr_field && !cinfo.has_writable_field) {
93761 + constify_type(type);
93762 + return;
93763 + }
93764 +
93765 + deconstify_type(type);
93766 + TYPE_CONSTIFY_VISITED(type) = 1;
93767 +}
93768 +
93769 +static void check_global_variables(void)
93770 +{
93771 + struct varpool_node *node;
93772 +
93773 +#if BUILDING_GCC_VERSION <= 4007
93774 + for (node = varpool_nodes; node; node = node->next) {
93775 + tree var = node->decl;
93776 +#else
93777 + FOR_EACH_VARIABLE(node) {
93778 + tree var = node->symbol.decl;
93779 +#endif
93780 + tree type = TREE_TYPE(var);
93781 +
93782 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
93783 + continue;
93784 +
93785 + if (!TYPE_READONLY(type) || !C_TYPE_FIELDS_READONLY(type))
93786 + continue;
93787 +
93788 + if (!TYPE_CONSTIFY_VISITED(type))
93789 + continue;
93790 +
93791 + if (DECL_EXTERNAL(var))
93792 + continue;
93793 +
93794 + if (DECL_INITIAL(var))
93795 + continue;
93796 +
93797 + // this works around a gcc bug/feature where uninitialized globals
93798 + // are moved into the .bss section regardless of any constification
93799 + DECL_INITIAL(var) = build_constructor(type, NULL);
93800 +// inform(DECL_SOURCE_LOCATION(var), "constified variable %qE moved into .rodata", var);
93801 + }
93802 +}
93803 +
93804 +static unsigned int check_local_variables(void)
93805 +{
93806 + unsigned int ret = 0;
93807 + tree var;
93808 +
93809 +#if BUILDING_GCC_VERSION == 4005
93810 + tree vars;
93811 +#else
93812 + unsigned int i;
93813 +#endif
93814 +
93815 +#if BUILDING_GCC_VERSION == 4005
93816 + for (vars = cfun->local_decls; vars; vars = TREE_CHAIN(vars)) {
93817 + var = TREE_VALUE(vars);
93818 +#else
93819 + FOR_EACH_LOCAL_DECL(cfun, i, var) {
93820 +#endif
93821 + tree type = TREE_TYPE(var);
93822 +
93823 + gcc_assert(DECL_P(var));
93824 + if (is_global_var(var))
93825 + continue;
93826 +
93827 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
93828 + continue;
93829 +
93830 + if (!TYPE_READONLY(type) || !C_TYPE_FIELDS_READONLY(type))
93831 + continue;
93832 +
93833 + if (!TYPE_CONSTIFY_VISITED(type))
93834 + continue;
93835 +
93836 + error_at(DECL_SOURCE_LOCATION(var), "constified variable %qE cannot be local", var);
93837 + ret = 1;
93838 + }
93839 + return ret;
93840 +}
93841 +
93842 +static unsigned int check_variables(void)
93843 +{
93844 + check_global_variables();
93845 + return check_local_variables();
93846 +}
93847 +
93848 + unsigned int ret = 0;
93849 +static struct gimple_opt_pass pass_local_variable = {
93850 + {
93851 + .type = GIMPLE_PASS,
93852 + .name = "check_variables",
93853 +#if BUILDING_GCC_VERSION >= 4008
93854 + .optinfo_flags = OPTGROUP_NONE,
93855 +#endif
93856 + .gate = NULL,
93857 + .execute = check_variables,
93858 + .sub = NULL,
93859 + .next = NULL,
93860 + .static_pass_number = 0,
93861 + .tv_id = TV_NONE,
93862 + .properties_required = 0,
93863 + .properties_provided = 0,
93864 + .properties_destroyed = 0,
93865 + .todo_flags_start = 0,
93866 + .todo_flags_finish = 0
93867 + }
93868 +};
93869 +
93870 +static struct {
93871 + const char *name;
93872 + const char *asm_op;
93873 +} sections[] = {
93874 + {".init.rodata", "\t.section\t.init.rodata,\"a\""},
93875 + {".ref.rodata", "\t.section\t.ref.rodata,\"a\""},
93876 + {".devinit.rodata", "\t.section\t.devinit.rodata,\"a\""},
93877 + {".devexit.rodata", "\t.section\t.devexit.rodata,\"a\""},
93878 + {".cpuinit.rodata", "\t.section\t.cpuinit.rodata,\"a\""},
93879 + {".cpuexit.rodata", "\t.section\t.cpuexit.rodata,\"a\""},
93880 + {".meminit.rodata", "\t.section\t.meminit.rodata,\"a\""},
93881 + {".memexit.rodata", "\t.section\t.memexit.rodata,\"a\""},
93882 + {".data..read_only", "\t.section\t.data..read_only,\"a\""},
93883 +};
93884 +
93885 +static unsigned int (*old_section_type_flags)(tree decl, const char *name, int reloc);
93886 +
93887 +static unsigned int constify_section_type_flags(tree decl, const char *name, int reloc)
93888 +{
93889 + size_t i;
93890 +
93891 + for (i = 0; i < ARRAY_SIZE(sections); i++)
93892 + if (!strcmp(sections[i].name, name))
93893 + return 0;
93894 + return old_section_type_flags(decl, name, reloc);
93895 +}
93896 +
93897 +static void constify_start_unit(void *gcc_data, void *user_data)
93898 +{
93899 +// size_t i;
93900 +
93901 +// for (i = 0; i < ARRAY_SIZE(sections); i++)
93902 +// sections[i].section = get_unnamed_section(0, output_section_asm_op, sections[i].asm_op);
93903 +// sections[i].section = get_section(sections[i].name, 0, NULL);
93904 +
93905 + old_section_type_flags = targetm.section_type_flags;
93906 + targetm.section_type_flags = constify_section_type_flags;
93907 +}
93908 +
93909 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
93910 +{
93911 + const char * const plugin_name = plugin_info->base_name;
93912 + const int argc = plugin_info->argc;
93913 + const struct plugin_argument * const argv = plugin_info->argv;
93914 + int i;
93915 + bool constify = true;
93916 +
93917 + struct register_pass_info local_variable_pass_info = {
93918 + .pass = &pass_local_variable.pass,
93919 + .reference_pass_name = "ssa",
93920 + .ref_pass_instance_number = 1,
93921 + .pos_op = PASS_POS_INSERT_BEFORE
93922 + };
93923 +
93924 + if (!plugin_default_version_check(version, &gcc_version)) {
93925 + error(G_("incompatible gcc/plugin versions"));
93926 + return 1;
93927 + }
93928 +
93929 + for (i = 0; i < argc; ++i) {
93930 + if (!(strcmp(argv[i].key, "no-constify"))) {
93931 + constify = false;
93932 + continue;
93933 + }
93934 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
93935 + }
93936 +
93937 + if (strcmp(lang_hooks.name, "GNU C")) {
93938 + inform(UNKNOWN_LOCATION, G_("%s supports C only"), plugin_name);
93939 + constify = false;
93940 + }
93941 +
93942 + register_callback(plugin_name, PLUGIN_INFO, NULL, &const_plugin_info);
93943 + if (constify) {
93944 + register_callback(plugin_name, PLUGIN_FINISH_TYPE, finish_type, NULL);
93945 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &local_variable_pass_info);
93946 + register_callback(plugin_name, PLUGIN_START_UNIT, constify_start_unit, NULL);
93947 + }
93948 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
93949 +
93950 + return 0;
93951 +}
93952 diff --git a/tools/gcc/generate_size_overflow_hash.sh b/tools/gcc/generate_size_overflow_hash.sh
93953 new file mode 100644
93954 index 0000000..e518932
93955 --- /dev/null
93956 +++ b/tools/gcc/generate_size_overflow_hash.sh
93957 @@ -0,0 +1,94 @@
93958 +#!/bin/bash
93959 +
93960 +# This script generates the hash table (size_overflow_hash.h) for the size_overflow gcc plugin (size_overflow_plugin.c).
93961 +
93962 +header1="size_overflow_hash.h"
93963 +database="size_overflow_hash.data"
93964 +n=65536
93965 +
93966 +usage() {
93967 +cat <<EOF
93968 +usage: $0 options
93969 +OPTIONS:
93970 + -h|--help help
93971 + -o header file
93972 + -d database file
93973 + -n hash array size
93974 +EOF
93975 + return 0
93976 +}
93977 +
93978 +while true
93979 +do
93980 + case "$1" in
93981 + -h|--help) usage && exit 0;;
93982 + -n) n=$2; shift 2;;
93983 + -o) header1="$2"; shift 2;;
93984 + -d) database="$2"; shift 2;;
93985 + --) shift 1; break ;;
93986 + *) break ;;
93987 + esac
93988 +done
93989 +
93990 +create_defines() {
93991 + for i in `seq 0 31`
93992 + do
93993 + echo -e "#define PARAM"$i" (1U << "$i")" >> "$header1"
93994 + done
93995 + echo >> "$header1"
93996 +}
93997 +
93998 +create_structs() {
93999 + rm -f "$header1"
94000 +
94001 + create_defines
94002 +
94003 + cat "$database" | while read data
94004 + do
94005 + data_array=($data)
94006 + struct_hash_name="${data_array[0]}"
94007 + funcn="${data_array[1]}"
94008 + params="${data_array[2]}"
94009 + next="${data_array[4]}"
94010 +
94011 + echo "const struct size_overflow_hash $struct_hash_name = {" >> "$header1"
94012 +
94013 + echo -e "\t.next\t= $next,\n\t.name\t= \"$funcn\"," >> "$header1"
94014 + echo -en "\t.param\t= " >> "$header1"
94015 + line=
94016 + for param_num in ${params//-/ };
94017 + do
94018 + line="${line}PARAM"$param_num"|"
94019 + done
94020 +
94021 + echo -e "${line%?},\n};\n" >> "$header1"
94022 + done
94023 +}
94024 +
94025 +create_headers() {
94026 + echo "const struct size_overflow_hash * const size_overflow_hash[$n] = {" >> "$header1"
94027 +}
94028 +
94029 +create_array_elements() {
94030 + index=0
94031 + grep -v "nohasharray" $database | sort -n -k 4 | while read data
94032 + do
94033 + data_array=($data)
94034 + i="${data_array[3]}"
94035 + hash="${data_array[0]}"
94036 + while [[ $index -lt $i ]]
94037 + do
94038 + echo -e "\t["$index"]\t= NULL," >> "$header1"
94039 + index=$(($index + 1))
94040 + done
94041 + index=$(($index + 1))
94042 + echo -e "\t["$i"]\t= &"$hash"," >> "$header1"
94043 + done
94044 + echo '};' >> $header1
94045 +}
94046 +
94047 +create_structs
94048 +create_headers
94049 +create_array_elements
94050 +
94051 +exit 0
94052 diff --git a/tools/gcc/kallocstat_plugin.c b/tools/gcc/kallocstat_plugin.c
94053 new file mode 100644
94054 index 0000000..568b360
94055 --- /dev/null
94056 +++ b/tools/gcc/kallocstat_plugin.c
94057 @@ -0,0 +1,170 @@
94058 +/*
94059 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
94060 + * Licensed under the GPL v2
94061 + *
94062 + * Note: the choice of the license means that the compilation process is
94063 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
94064 + * but for the kernel it doesn't matter since it doesn't link against
94065 + * any of the gcc libraries
94066 + *
94067 + * gcc plugin to find the distribution of k*alloc sizes
94068 + *
94069 + * TODO:
94070 + *
94071 + * BUGS:
94072 + * - none known
94073 + */
94074 +#include "gcc-plugin.h"
94075 +#include "config.h"
94076 +#include "system.h"
94077 +#include "coretypes.h"
94078 +#include "tree.h"
94079 +#include "tree-pass.h"
94080 +#include "flags.h"
94081 +#include "intl.h"
94082 +#include "toplev.h"
94083 +#include "plugin.h"
94084 +//#include "expr.h" where are you...
94085 +#include "diagnostic.h"
94086 +#include "plugin-version.h"
94087 +#include "tm.h"
94088 +#include "function.h"
94089 +#include "basic-block.h"
94090 +#include "gimple.h"
94091 +#include "rtl.h"
94092 +#include "emit-rtl.h"
94093 +
94094 +extern void print_gimple_stmt(FILE *, gimple, int, int);
94095 +
94096 +int plugin_is_GPL_compatible;
94097 +
94098 +static const char * const kalloc_functions[] = {
94099 + "__kmalloc",
94100 + "kmalloc",
94101 + "kmalloc_large",
94102 + "kmalloc_node",
94103 + "kmalloc_order",
94104 + "kmalloc_order_trace",
94105 + "kmalloc_slab",
94106 + "kzalloc",
94107 + "kzalloc_node",
94108 +};
94109 +
94110 +static struct plugin_info kallocstat_plugin_info = {
94111 + .version = "201302112000",
94112 +};
94113 +
94114 +static unsigned int execute_kallocstat(void);
94115 +
94116 +static struct gimple_opt_pass kallocstat_pass = {
94117 + .pass = {
94118 + .type = GIMPLE_PASS,
94119 + .name = "kallocstat",
94120 +#if BUILDING_GCC_VERSION >= 4008
94121 + .optinfo_flags = OPTGROUP_NONE,
94122 +#endif
94123 + .gate = NULL,
94124 + .execute = execute_kallocstat,
94125 + .sub = NULL,
94126 + .next = NULL,
94127 + .static_pass_number = 0,
94128 + .tv_id = TV_NONE,
94129 + .properties_required = 0,
94130 + .properties_provided = 0,
94131 + .properties_destroyed = 0,
94132 + .todo_flags_start = 0,
94133 + .todo_flags_finish = 0
94134 + }
94135 +};
94136 +
94137 +static bool is_kalloc(const char *fnname)
94138 +{
94139 + size_t i;
94140 +
94141 + for (i = 0; i < ARRAY_SIZE(kalloc_functions); i++)
94142 + if (!strcmp(fnname, kalloc_functions[i]))
94143 + return true;
94144 + return false;
94145 +}
94146 +
94147 +static unsigned int execute_kallocstat(void)
94148 +{
94149 + basic_block bb;
94150 +
94151 + // 1. loop through BBs and GIMPLE statements
94152 + FOR_EACH_BB(bb) {
94153 + gimple_stmt_iterator gsi;
94154 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
94155 + // gimple match:
94156 + tree fndecl, size;
94157 + gimple call_stmt;
94158 + const char *fnname;
94159 +
94160 + // is it a call
94161 + call_stmt = gsi_stmt(gsi);
94162 + if (!is_gimple_call(call_stmt))
94163 + continue;
94164 + fndecl = gimple_call_fndecl(call_stmt);
94165 + if (fndecl == NULL_TREE)
94166 + continue;
94167 + if (TREE_CODE(fndecl) != FUNCTION_DECL)
94168 + continue;
94169 +
94170 + // is it a call to k*alloc
94171 + fnname = IDENTIFIER_POINTER(DECL_NAME(fndecl));
94172 + if (!is_kalloc(fnname))
94173 + continue;
94174 +
94175 + // is the size arg the result of a simple const assignment
94176 + size = gimple_call_arg(call_stmt, 0);
94177 + while (true) {
94178 + gimple def_stmt;
94179 + expanded_location xloc;
94180 + size_t size_val;
94181 +
94182 + if (TREE_CODE(size) != SSA_NAME)
94183 + break;
94184 + def_stmt = SSA_NAME_DEF_STMT(size);
94185 + if (!def_stmt || !is_gimple_assign(def_stmt))
94186 + break;
94187 + if (gimple_num_ops(def_stmt) != 2)
94188 + break;
94189 + size = gimple_assign_rhs1(def_stmt);
94190 + if (!TREE_CONSTANT(size))
94191 + continue;
94192 + xloc = expand_location(gimple_location(def_stmt));
94193 + if (!xloc.file)
94194 + xloc = expand_location(DECL_SOURCE_LOCATION(current_function_decl));
94195 + size_val = TREE_INT_CST_LOW(size);
94196 + fprintf(stderr, "kallocsize: %8zu %8zx %s %s:%u\n", size_val, size_val, fnname, xloc.file, xloc.line);
94197 + break;
94198 + }
94199 +//print_gimple_stmt(stderr, call_stmt, 0, TDF_LINENO);
94200 +//debug_tree(gimple_call_fn(call_stmt));
94201 +//print_node(stderr, "pax", fndecl, 4);
94202 + }
94203 + }
94204 +
94205 + return 0;
94206 +}
94207 +
94208 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
94209 +{
94210 + const char * const plugin_name = plugin_info->base_name;
94211 + struct register_pass_info kallocstat_pass_info = {
94212 + .pass = &kallocstat_pass.pass,
94213 + .reference_pass_name = "ssa",
94214 + .ref_pass_instance_number = 1,
94215 + .pos_op = PASS_POS_INSERT_AFTER
94216 + };
94217 +
94218 + if (!plugin_default_version_check(version, &gcc_version)) {
94219 + error(G_("incompatible gcc/plugin versions"));
94220 + return 1;
94221 + }
94222 +
94223 + register_callback(plugin_name, PLUGIN_INFO, NULL, &kallocstat_plugin_info);
94224 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kallocstat_pass_info);
94225 +
94226 + return 0;
94227 +}
94228 diff --git a/tools/gcc/kernexec_plugin.c b/tools/gcc/kernexec_plugin.c
94229 new file mode 100644
94230 index 0000000..0408e06
94231 --- /dev/null
94232 +++ b/tools/gcc/kernexec_plugin.c
94233 @@ -0,0 +1,465 @@
94234 +/*
94235 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
94236 + * Licensed under the GPL v2
94237 + *
94238 + * Note: the choice of the license means that the compilation process is
94239 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
94240 + * but for the kernel it doesn't matter since it doesn't link against
94241 + * any of the gcc libraries
94242 + *
94243 + * gcc plugin to make KERNEXEC/amd64 almost as good as it is on i386
94244 + *
94245 + * TODO:
94246 + *
94247 + * BUGS:
94248 + * - none known
94249 + */
94250 +#include "gcc-plugin.h"
94251 +#include "config.h"
94252 +#include "system.h"
94253 +#include "coretypes.h"
94254 +#include "tree.h"
94255 +#include "tree-pass.h"
94256 +#include "flags.h"
94257 +#include "intl.h"
94258 +#include "toplev.h"
94259 +#include "plugin.h"
94260 +//#include "expr.h" where are you...
94261 +#include "diagnostic.h"
94262 +#include "plugin-version.h"
94263 +#include "tm.h"
94264 +#include "function.h"
94265 +#include "basic-block.h"
94266 +#include "gimple.h"
94267 +#include "rtl.h"
94268 +#include "emit-rtl.h"
94269 +#include "tree-flow.h"
94270 +
94271 +extern void print_gimple_stmt(FILE *, gimple, int, int);
94272 +extern rtx emit_move_insn(rtx x, rtx y);
94273 +
94274 +#if BUILDING_GCC_VERSION <= 4006
94275 +#define ANY_RETURN_P(rtx) (GET_CODE(rtx) == RETURN)
94276 +#endif
94277 +
94278 +#if BUILDING_GCC_VERSION >= 4008
94279 +#define TODO_dump_func 0
94280 +#endif
94281 +
94282 +int plugin_is_GPL_compatible;
94283 +
94284 +static struct plugin_info kernexec_plugin_info = {
94285 + .version = "201302112000",
94286 + .help = "method=[bts|or]\tinstrumentation method\n"
94287 +};
94288 +
94289 +static unsigned int execute_kernexec_reload(void);
94290 +static unsigned int execute_kernexec_fptr(void);
94291 +static unsigned int execute_kernexec_retaddr(void);
94292 +static bool kernexec_cmodel_check(void);
94293 +
94294 +static void (*kernexec_instrument_fptr)(gimple_stmt_iterator *);
94295 +static void (*kernexec_instrument_retaddr)(rtx);
94296 +
94297 +static struct gimple_opt_pass kernexec_reload_pass = {
94298 + .pass = {
94299 + .type = GIMPLE_PASS,
94300 + .name = "kernexec_reload",
94301 +#if BUILDING_GCC_VERSION >= 4008
94302 + .optinfo_flags = OPTGROUP_NONE,
94303 +#endif
94304 + .gate = kernexec_cmodel_check,
94305 + .execute = execute_kernexec_reload,
94306 + .sub = NULL,
94307 + .next = NULL,
94308 + .static_pass_number = 0,
94309 + .tv_id = TV_NONE,
94310 + .properties_required = 0,
94311 + .properties_provided = 0,
94312 + .properties_destroyed = 0,
94313 + .todo_flags_start = 0,
94314 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_remove_unused_locals | TODO_update_ssa_no_phi
94315 + }
94316 +};
94317 +
94318 +static struct gimple_opt_pass kernexec_fptr_pass = {
94319 + .pass = {
94320 + .type = GIMPLE_PASS,
94321 + .name = "kernexec_fptr",
94322 +#if BUILDING_GCC_VERSION >= 4008
94323 + .optinfo_flags = OPTGROUP_NONE,
94324 +#endif
94325 + .gate = kernexec_cmodel_check,
94326 + .execute = execute_kernexec_fptr,
94327 + .sub = NULL,
94328 + .next = NULL,
94329 + .static_pass_number = 0,
94330 + .tv_id = TV_NONE,
94331 + .properties_required = 0,
94332 + .properties_provided = 0,
94333 + .properties_destroyed = 0,
94334 + .todo_flags_start = 0,
94335 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_remove_unused_locals | TODO_update_ssa_no_phi
94336 + }
94337 +};
94338 +
94339 +static struct rtl_opt_pass kernexec_retaddr_pass = {
94340 + .pass = {
94341 + .type = RTL_PASS,
94342 + .name = "kernexec_retaddr",
94343 +#if BUILDING_GCC_VERSION >= 4008
94344 + .optinfo_flags = OPTGROUP_NONE,
94345 +#endif
94346 + .gate = kernexec_cmodel_check,
94347 + .execute = execute_kernexec_retaddr,
94348 + .sub = NULL,
94349 + .next = NULL,
94350 + .static_pass_number = 0,
94351 + .tv_id = TV_NONE,
94352 + .properties_required = 0,
94353 + .properties_provided = 0,
94354 + .properties_destroyed = 0,
94355 + .todo_flags_start = 0,
94356 + .todo_flags_finish = TODO_dump_func | TODO_ggc_collect
94357 + }
94358 +};
94359 +
94360 +static bool kernexec_cmodel_check(void)
94361 +{
94362 + tree section;
94363 +
94364 + if (ix86_cmodel != CM_KERNEL)
94365 + return false;
94366 +
94367 + section = lookup_attribute("section", DECL_ATTRIBUTES(current_function_decl));
94368 + if (!section || !TREE_VALUE(section))
94369 + return true;
94370 +
94371 + section = TREE_VALUE(TREE_VALUE(section));
94372 + if (strncmp(TREE_STRING_POINTER(section), ".vsyscall_", 10))
94373 + return true;
94374 +
94375 + return false;
94376 +}
94377 +
94378 +/*
94379 + * add special KERNEXEC instrumentation: reload %r10 after it has been clobbered
94380 + */
94381 +static void kernexec_reload_fptr_mask(gimple_stmt_iterator *gsi)
94382 +{
94383 + gimple asm_movabs_stmt;
94384 +
94385 + // build asm volatile("movabs $0x8000000000000000, %%r10\n\t" : : : );
94386 + asm_movabs_stmt = gimple_build_asm_vec("movabs $0x8000000000000000, %%r10\n\t", NULL, NULL, NULL, NULL);
94387 + gimple_asm_set_volatile(asm_movabs_stmt, true);
94388 + gsi_insert_after(gsi, asm_movabs_stmt, GSI_CONTINUE_LINKING);
94389 + update_stmt(asm_movabs_stmt);
94390 +}
94391 +
94392 +/*
94393 + * find all asm() stmts that clobber r10 and add a reload of r10
94394 + */
94395 +static unsigned int execute_kernexec_reload(void)
94396 +{
94397 + basic_block bb;
94398 +
94399 + // 1. loop through BBs and GIMPLE statements
94400 + FOR_EACH_BB(bb) {
94401 + gimple_stmt_iterator gsi;
94402 +
94403 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
94404 + // gimple match: __asm__ ("" : : : "r10");
94405 + gimple asm_stmt;
94406 + size_t nclobbers;
94407 +
94408 + // is it an asm ...
94409 + asm_stmt = gsi_stmt(gsi);
94410 + if (gimple_code(asm_stmt) != GIMPLE_ASM)
94411 + continue;
94412 +
94413 + // ... clobbering r10
94414 + nclobbers = gimple_asm_nclobbers(asm_stmt);
94415 + while (nclobbers--) {
94416 + tree op = gimple_asm_clobber_op(asm_stmt, nclobbers);
94417 + if (strcmp(TREE_STRING_POINTER(TREE_VALUE(op)), "r10"))
94418 + continue;
94419 + kernexec_reload_fptr_mask(&gsi);
94420 +//print_gimple_stmt(stderr, asm_stmt, 0, TDF_LINENO);
94421 + break;
94422 + }
94423 + }
94424 + }
94425 +
94426 + return 0;
94427 +}
94428 +
94429 +/*
94430 + * add special KERNEXEC instrumentation: force MSB of fptr to 1, which will produce
94431 + * a non-canonical address from a userland ptr and will just trigger a GPF on dereference
94432 + */
94433 +static void kernexec_instrument_fptr_bts(gimple_stmt_iterator *gsi)
94434 +{
94435 + gimple assign_intptr, assign_new_fptr, call_stmt;
94436 + tree intptr, old_fptr, new_fptr, kernexec_mask;
94437 +
94438 + call_stmt = gsi_stmt(*gsi);
94439 + old_fptr = gimple_call_fn(call_stmt);
94440 +
94441 + // create temporary unsigned long variable used for bitops and cast fptr to it
94442 + intptr = create_tmp_var(long_unsigned_type_node, "kernexec_bts");
94443 +#if BUILDING_GCC_VERSION <= 4007
94444 + add_referenced_var(intptr);
94445 + mark_sym_for_renaming(intptr);
94446 +#endif
94447 + assign_intptr = gimple_build_assign(intptr, fold_convert(long_unsigned_type_node, old_fptr));
94448 + gsi_insert_before(gsi, assign_intptr, GSI_SAME_STMT);
94449 + update_stmt(assign_intptr);
94450 +
94451 + // apply logical or to temporary unsigned long and bitmask
94452 + kernexec_mask = build_int_cstu(long_long_unsigned_type_node, 0x8000000000000000LL);
94453 +// kernexec_mask = build_int_cstu(long_long_unsigned_type_node, 0xffffffff80000000LL);
94454 + assign_intptr = gimple_build_assign(intptr, fold_build2(BIT_IOR_EXPR, long_long_unsigned_type_node, intptr, kernexec_mask));
94455 + gsi_insert_before(gsi, assign_intptr, GSI_SAME_STMT);
94456 + update_stmt(assign_intptr);
94457 +
94458 + // cast temporary unsigned long back to a temporary fptr variable
94459 + new_fptr = create_tmp_var(TREE_TYPE(old_fptr), "kernexec_fptr");
94460 +#if BUILDING_GCC_VERSION <= 4007
94461 + add_referenced_var(new_fptr);
94462 + mark_sym_for_renaming(new_fptr);
94463 +#endif
94464 + assign_new_fptr = gimple_build_assign(new_fptr, fold_convert(TREE_TYPE(old_fptr), intptr));
94465 + gsi_insert_before(gsi, assign_new_fptr, GSI_SAME_STMT);
94466 + update_stmt(assign_new_fptr);
94467 +
94468 + // replace call stmt fn with the new fptr
94469 + gimple_call_set_fn(call_stmt, new_fptr);
94470 + update_stmt(call_stmt);
94471 +}
94472 +
94473 +static void kernexec_instrument_fptr_or(gimple_stmt_iterator *gsi)
94474 +{
94475 + gimple asm_or_stmt, call_stmt;
94476 + tree old_fptr, new_fptr, input, output;
94477 +#if BUILDING_GCC_VERSION <= 4007
94478 + VEC(tree, gc) *inputs = NULL;
94479 + VEC(tree, gc) *outputs = NULL;
94480 +#else
94481 + vec<tree, va_gc> *inputs = NULL;
94482 + vec<tree, va_gc> *outputs = NULL;
94483 +#endif
94484 +
94485 + call_stmt = gsi_stmt(*gsi);
94486 + old_fptr = gimple_call_fn(call_stmt);
94487 +
94488 + // create temporary fptr variable
94489 + new_fptr = create_tmp_var(TREE_TYPE(old_fptr), "kernexec_or");
94490 +#if BUILDING_GCC_VERSION <= 4007
94491 + add_referenced_var(new_fptr);
94492 + mark_sym_for_renaming(new_fptr);
94493 +#endif
94494 +
94495 + // build asm volatile("orq %%r10, %0\n\t" : "=r"(new_fptr) : "0"(old_fptr));
94496 + input = build_tree_list(NULL_TREE, build_string(2, "0"));
94497 + input = chainon(NULL_TREE, build_tree_list(input, old_fptr));
94498 + output = build_tree_list(NULL_TREE, build_string(3, "=r"));
94499 + output = chainon(NULL_TREE, build_tree_list(output, new_fptr));
94500 +#if BUILDING_GCC_VERSION <= 4007
94501 + VEC_safe_push(tree, gc, inputs, input);
94502 + VEC_safe_push(tree, gc, outputs, output);
94503 +#else
94504 + vec_safe_push(inputs, input);
94505 + vec_safe_push(outputs, output);
94506 +#endif
94507 + asm_or_stmt = gimple_build_asm_vec("orq %%r10, %0\n\t", inputs, outputs, NULL, NULL);
94508 + gimple_asm_set_volatile(asm_or_stmt, true);
94509 + gsi_insert_before(gsi, asm_or_stmt, GSI_SAME_STMT);
94510 + update_stmt(asm_or_stmt);
94511 +
94512 + // replace call stmt fn with the new fptr
94513 + gimple_call_set_fn(call_stmt, new_fptr);
94514 + update_stmt(call_stmt);
94515 +}
94516 +
94517 +/*
94518 + * find all C level function pointer dereferences and forcibly set the highest bit of the pointer
94519 + */
94520 +static unsigned int execute_kernexec_fptr(void)
94521 +{
94522 + basic_block bb;
94523 +
94524 + // 1. loop through BBs and GIMPLE statements
94525 + FOR_EACH_BB(bb) {
94526 + gimple_stmt_iterator gsi;
94527 +
94528 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
94529 + // gimple match: h_1 = get_fptr (); D.2709_3 = h_1 (x_2(D));
94530 + tree fn;
94531 + gimple call_stmt;
94532 +
94533 + // is it a call ...
94534 + call_stmt = gsi_stmt(gsi);
94535 + if (!is_gimple_call(call_stmt))
94536 + continue;
94537 + fn = gimple_call_fn(call_stmt);
94538 + if (TREE_CODE(fn) == ADDR_EXPR)
94539 + continue;
94540 + if (TREE_CODE(fn) != SSA_NAME)
94541 + gcc_unreachable();
94542 +
94543 + // ... through a function pointer
94544 + if (SSA_NAME_VAR(fn) != NULL_TREE) {
94545 + fn = SSA_NAME_VAR(fn);
94546 + if (TREE_CODE(fn) != VAR_DECL && TREE_CODE(fn) != PARM_DECL) {
94547 + debug_tree(fn);
94548 + gcc_unreachable();
94549 + }
94550 + }
94551 + fn = TREE_TYPE(fn);
94552 + if (TREE_CODE(fn) != POINTER_TYPE)
94553 + continue;
94554 + fn = TREE_TYPE(fn);
94555 + if (TREE_CODE(fn) != FUNCTION_TYPE)
94556 + continue;
94557 +
94558 + kernexec_instrument_fptr(&gsi);
94559 +
94560 +//debug_tree(gimple_call_fn(call_stmt));
94561 +//print_gimple_stmt(stderr, call_stmt, 0, TDF_LINENO);
94562 + }
94563 + }
94564 +
94565 + return 0;
94566 +}
94567 +
94568 +// add special KERNEXEC instrumentation: btsq $63,(%rsp) just before retn
94569 +static void kernexec_instrument_retaddr_bts(rtx insn)
94570 +{
94571 + rtx btsq;
94572 + rtvec argvec, constraintvec, labelvec;
94573 + int line;
94574 +
94575 + // create asm volatile("btsq $63,(%%rsp)":::)
94576 + argvec = rtvec_alloc(0);
94577 + constraintvec = rtvec_alloc(0);
94578 + labelvec = rtvec_alloc(0);
94579 + line = expand_location(RTL_LOCATION(insn)).line;
94580 + btsq = gen_rtx_ASM_OPERANDS(VOIDmode, "btsq $63,(%%rsp)", empty_string, 0, argvec, constraintvec, labelvec, line);
94581 + MEM_VOLATILE_P(btsq) = 1;
94582 +// RTX_FRAME_RELATED_P(btsq) = 1; // not for ASM_OPERANDS
94583 + emit_insn_before(btsq, insn);
94584 +}
94585 +
94586 +// add special KERNEXEC instrumentation: orq %r10,(%rsp) just before retn
94587 +static void kernexec_instrument_retaddr_or(rtx insn)
94588 +{
94589 + rtx orq;
94590 + rtvec argvec, constraintvec, labelvec;
94591 + int line;
94592 +
94593 + // create asm volatile("orq %%r10,(%%rsp)":::)
94594 + argvec = rtvec_alloc(0);
94595 + constraintvec = rtvec_alloc(0);
94596 + labelvec = rtvec_alloc(0);
94597 + line = expand_location(RTL_LOCATION(insn)).line;
94598 + orq = gen_rtx_ASM_OPERANDS(VOIDmode, "orq %%r10,(%%rsp)", empty_string, 0, argvec, constraintvec, labelvec, line);
94599 + MEM_VOLATILE_P(orq) = 1;
94600 +// RTX_FRAME_RELATED_P(orq) = 1; // not for ASM_OPERANDS
94601 + emit_insn_before(orq, insn);
94602 +}
94603 +
94604 +/*
94605 + * find all asm level function returns and forcibly set the highest bit of the return address
94606 + */
94607 +static unsigned int execute_kernexec_retaddr(void)
94608 +{
94609 + rtx insn;
94610 +
94611 + // 1. find function returns
94612 + for (insn = get_insns(); insn; insn = NEXT_INSN(insn)) {
94613 + // rtl match: (jump_insn 41 40 42 2 (return) fptr.c:42 634 {return_internal} (nil))
94614 + // (jump_insn 12 9 11 2 (parallel [ (return) (unspec [ (0) ] UNSPEC_REP) ]) fptr.c:46 635 {return_internal_long} (nil))
94615 + // (jump_insn 97 96 98 6 (simple_return) fptr.c:50 -1 (nil) -> simple_return)
94616 + rtx body;
94617 +
94618 + // is it a retn
94619 + if (!JUMP_P(insn))
94620 + continue;
94621 + body = PATTERN(insn);
94622 + if (GET_CODE(body) == PARALLEL)
94623 + body = XVECEXP(body, 0, 0);
94624 + if (!ANY_RETURN_P(body))
94625 + continue;
94626 + kernexec_instrument_retaddr(insn);
94627 + }
94628 +
94629 +// print_simple_rtl(stderr, get_insns());
94630 +// print_rtl(stderr, get_insns());
94631 +
94632 + return 0;
94633 +}
94634 +
94635 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
94636 +{
94637 + const char * const plugin_name = plugin_info->base_name;
94638 + const int argc = plugin_info->argc;
94639 + const struct plugin_argument * const argv = plugin_info->argv;
94640 + int i;
94641 + struct register_pass_info kernexec_reload_pass_info = {
94642 + .pass = &kernexec_reload_pass.pass,
94643 + .reference_pass_name = "ssa",
94644 + .ref_pass_instance_number = 1,
94645 + .pos_op = PASS_POS_INSERT_AFTER
94646 + };
94647 + struct register_pass_info kernexec_fptr_pass_info = {
94648 + .pass = &kernexec_fptr_pass.pass,
94649 + .reference_pass_name = "ssa",
94650 + .ref_pass_instance_number = 1,
94651 + .pos_op = PASS_POS_INSERT_AFTER
94652 + };
94653 + struct register_pass_info kernexec_retaddr_pass_info = {
94654 + .pass = &kernexec_retaddr_pass.pass,
94655 + .reference_pass_name = "pro_and_epilogue",
94656 + .ref_pass_instance_number = 1,
94657 + .pos_op = PASS_POS_INSERT_AFTER
94658 + };
94659 +
94660 + if (!plugin_default_version_check(version, &gcc_version)) {
94661 + error(G_("incompatible gcc/plugin versions"));
94662 + return 1;
94663 + }
94664 +
94665 + register_callback(plugin_name, PLUGIN_INFO, NULL, &kernexec_plugin_info);
94666 +
94667 + if (TARGET_64BIT == 0)
94668 + return 0;
94669 +
94670 + for (i = 0; i < argc; ++i) {
94671 + if (!strcmp(argv[i].key, "method")) {
94672 + if (!argv[i].value) {
94673 + error(G_("no value supplied for option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
94674 + continue;
94675 + }
94676 + if (!strcmp(argv[i].value, "bts")) {
94677 + kernexec_instrument_fptr = kernexec_instrument_fptr_bts;
94678 + kernexec_instrument_retaddr = kernexec_instrument_retaddr_bts;
94679 + } else if (!strcmp(argv[i].value, "or")) {
94680 + kernexec_instrument_fptr = kernexec_instrument_fptr_or;
94681 + kernexec_instrument_retaddr = kernexec_instrument_retaddr_or;
94682 + fix_register("r10", 1, 1);
94683 + } else
94684 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
94685 + continue;
94686 + }
94687 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
94688 + }
94689 + if (!kernexec_instrument_fptr || !kernexec_instrument_retaddr)
94690 + error(G_("no instrumentation method was selected via '-fplugin-arg-%s-method'"), plugin_name);
94691 +
94692 + if (kernexec_instrument_fptr == kernexec_instrument_fptr_or)
94693 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_reload_pass_info);
94694 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_fptr_pass_info);
94695 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_retaddr_pass_info);
94696 +
94697 + return 0;
94698 +}
94699 diff --git a/tools/gcc/latent_entropy_plugin.c b/tools/gcc/latent_entropy_plugin.c
94700 new file mode 100644
94701 index 0000000..b5395ba
94702 --- /dev/null
94703 +++ b/tools/gcc/latent_entropy_plugin.c
94704 @@ -0,0 +1,327 @@
94705 +/*
94706 + * Copyright 2012-2013 by the PaX Team <pageexec@freemail.hu>
94707 + * Licensed under the GPL v2
94708 + *
94709 + * Note: the choice of the license means that the compilation process is
94710 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
94711 + * but for the kernel it doesn't matter since it doesn't link against
94712 + * any of the gcc libraries
94713 + *
94714 + * gcc plugin to help generate a little bit of entropy from program state,
94715 + * used during boot in the kernel
94716 + *
94717 + * TODO:
94718 + * - add ipa pass to identify not explicitly marked candidate functions
94719 + * - mix in more program state (function arguments/return values, loop variables, etc)
94720 + * - more instrumentation control via attribute parameters
94721 + *
94722 + * BUGS:
94723 + * - LTO needs -flto-partition=none for now
94724 + */
94725 +#include "gcc-plugin.h"
94726 +#include "config.h"
94727 +#include "system.h"
94728 +#include "coretypes.h"
94729 +#include "tree.h"
94730 +#include "tree-pass.h"
94731 +#include "flags.h"
94732 +#include "intl.h"
94733 +#include "toplev.h"
94734 +#include "plugin.h"
94735 +//#include "expr.h" where are you...
94736 +#include "diagnostic.h"
94737 +#include "plugin-version.h"
94738 +#include "tm.h"
94739 +#include "function.h"
94740 +#include "basic-block.h"
94741 +#include "gimple.h"
94742 +#include "rtl.h"
94743 +#include "emit-rtl.h"
94744 +#include "tree-flow.h"
94745 +#include "langhooks.h"
94746 +
94747 +#if BUILDING_GCC_VERSION >= 4008
94748 +#define TODO_dump_func 0
94749 +#endif
94750 +
94751 +int plugin_is_GPL_compatible;
94752 +
94753 +static tree latent_entropy_decl;
94754 +
94755 +static struct plugin_info latent_entropy_plugin_info = {
94756 + .version = "201303102320",
94757 + .help = NULL
94758 +};
94759 +
94760 +static unsigned int execute_latent_entropy(void);
94761 +static bool gate_latent_entropy(void);
94762 +
94763 +static struct gimple_opt_pass latent_entropy_pass = {
94764 + .pass = {
94765 + .type = GIMPLE_PASS,
94766 + .name = "latent_entropy",
94767 +#if BUILDING_GCC_VERSION >= 4008
94768 + .optinfo_flags = OPTGROUP_NONE,
94769 +#endif
94770 + .gate = gate_latent_entropy,
94771 + .execute = execute_latent_entropy,
94772 + .sub = NULL,
94773 + .next = NULL,
94774 + .static_pass_number = 0,
94775 + .tv_id = TV_NONE,
94776 + .properties_required = PROP_gimple_leh | PROP_cfg,
94777 + .properties_provided = 0,
94778 + .properties_destroyed = 0,
94779 + .todo_flags_start = 0, //TODO_verify_ssa | TODO_verify_flow | TODO_verify_stmts,
94780 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_update_ssa
94781 + }
94782 +};
94783 +
94784 +static tree handle_latent_entropy_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
94785 +{
94786 + if (TREE_CODE(*node) != FUNCTION_DECL) {
94787 + *no_add_attrs = true;
94788 + error("%qE attribute only applies to functions", name);
94789 + }
94790 + return NULL_TREE;
94791 +}
94792 +
94793 +static struct attribute_spec latent_entropy_attr = {
94794 + .name = "latent_entropy",
94795 + .min_length = 0,
94796 + .max_length = 0,
94797 + .decl_required = true,
94798 + .type_required = false,
94799 + .function_type_required = false,
94800 + .handler = handle_latent_entropy_attribute,
94801 +#if BUILDING_GCC_VERSION >= 4007
94802 + .affects_type_identity = false
94803 +#endif
94804 +};
94805 +
94806 +static void register_attributes(void *event_data, void *data)
94807 +{
94808 + register_attribute(&latent_entropy_attr);
94809 +}
94810 +
94811 +static bool gate_latent_entropy(void)
94812 +{
94813 + tree latent_entropy_attr;
94814 +
94815 + latent_entropy_attr = lookup_attribute("latent_entropy", DECL_ATTRIBUTES(current_function_decl));
94816 + return latent_entropy_attr != NULL_TREE;
94817 +}
94818 +
94819 +static unsigned HOST_WIDE_INT seed;
94820 +static unsigned HOST_WIDE_INT get_random_const(void)
94821 +{
94822 + seed = (seed >> 1U) ^ (-(seed & 1ULL) & 0xD800000000000000ULL);
94823 + return seed;
94824 +}
94825 +
94826 +static enum tree_code get_op(tree *rhs)
94827 +{
94828 + static enum tree_code op;
94829 + unsigned HOST_WIDE_INT random_const;
94830 +
94831 + random_const = get_random_const();
94832 +
94833 + switch (op) {
94834 + case BIT_XOR_EXPR:
94835 + op = PLUS_EXPR;
94836 + break;
94837 +
94838 + case PLUS_EXPR:
94839 + if (rhs) {
94840 + op = LROTATE_EXPR;
94841 + random_const &= HOST_BITS_PER_WIDE_INT - 1;
94842 + break;
94843 + }
94844 +
94845 + case LROTATE_EXPR:
94846 + default:
94847 + op = BIT_XOR_EXPR;
94848 + break;
94849 + }
94850 + if (rhs)
94851 + *rhs = build_int_cstu(unsigned_intDI_type_node, random_const);
94852 + return op;
94853 +}
94854 +
94855 +static void perturb_local_entropy(basic_block bb, tree local_entropy)
94856 +{
94857 + gimple_stmt_iterator gsi;
94858 + gimple assign;
94859 + tree addxorrol, rhs;
94860 + enum tree_code op;
94861 +
94862 + op = get_op(&rhs);
94863 + addxorrol = fold_build2_loc(UNKNOWN_LOCATION, op, unsigned_intDI_type_node, local_entropy, rhs);
94864 + assign = gimple_build_assign(local_entropy, addxorrol);
94865 +#if BUILDING_GCC_VERSION <= 4007
94866 + find_referenced_vars_in(assign);
94867 +#endif
94868 +//debug_bb(bb);
94869 + gsi = gsi_after_labels(bb);
94870 + gsi_insert_before(&gsi, assign, GSI_NEW_STMT);
94871 + update_stmt(assign);
94872 +}
94873 +
94874 +static void perturb_latent_entropy(basic_block bb, tree rhs)
94875 +{
94876 + gimple_stmt_iterator gsi;
94877 + gimple assign;
94878 + tree addxorrol, temp;
94879 +
94880 + // 1. create temporary copy of latent_entropy
94881 + temp = create_tmp_var(unsigned_intDI_type_node, "temp_latent_entropy");
94882 +#if BUILDING_GCC_VERSION <= 4007
94883 + add_referenced_var(temp);
94884 + mark_sym_for_renaming(temp);
94885 +#endif
94886 +
94887 + // 2. read...
94888 + assign = gimple_build_assign(temp, latent_entropy_decl);
94889 +#if BUILDING_GCC_VERSION <= 4007
94890 + find_referenced_vars_in(assign);
94891 +#endif
94892 + gsi = gsi_after_labels(bb);
94893 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
94894 + update_stmt(assign);
94895 +
94896 + // 3. ...modify...
94897 + addxorrol = fold_build2_loc(UNKNOWN_LOCATION, get_op(NULL), unsigned_intDI_type_node, temp, rhs);
94898 + assign = gimple_build_assign(temp, addxorrol);
94899 +#if BUILDING_GCC_VERSION <= 4007
94900 + find_referenced_vars_in(assign);
94901 +#endif
94902 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
94903 + update_stmt(assign);
94904 +
94905 + // 4. ...write latent_entropy
94906 + assign = gimple_build_assign(latent_entropy_decl, temp);
94907 +#if BUILDING_GCC_VERSION <= 4007
94908 + find_referenced_vars_in(assign);
94909 +#endif
94910 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
94911 + update_stmt(assign);
94912 +}
94913 +
94914 +static unsigned int execute_latent_entropy(void)
94915 +{
94916 + basic_block bb;
94917 + gimple assign;
94918 + gimple_stmt_iterator gsi;
94919 + tree local_entropy;
94920 +
94921 + if (!latent_entropy_decl) {
94922 + struct varpool_node *node;
94923 +
94924 +#if BUILDING_GCC_VERSION <= 4007
94925 + for (node = varpool_nodes; node; node = node->next) {
94926 + tree var = node->decl;
94927 +#else
94928 + FOR_EACH_VARIABLE(node) {
94929 + tree var = node->symbol.decl;
94930 +#endif
94931 + if (strcmp(IDENTIFIER_POINTER(DECL_NAME(var)), "latent_entropy"))
94932 + continue;
94933 + latent_entropy_decl = var;
94934 +// debug_tree(var);
94935 + break;
94936 + }
94937 + if (!latent_entropy_decl) {
94938 +// debug_tree(current_function_decl);
94939 + return 0;
94940 + }
94941 + }
94942 +
94943 +//fprintf(stderr, "latent_entropy: %s\n", IDENTIFIER_POINTER(DECL_NAME(current_function_decl)));
94944 +
94945 + // 1. create local entropy variable
94946 + local_entropy = create_tmp_var(unsigned_intDI_type_node, "local_entropy");
94947 +#if BUILDING_GCC_VERSION <= 4007
94948 + add_referenced_var(local_entropy);
94949 + mark_sym_for_renaming(local_entropy);
94950 +#endif
94951 +
94952 + // 2. initialize local entropy variable
94953 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
94954 + if (dom_info_available_p(CDI_DOMINATORS))
94955 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
94956 + gsi = gsi_start_bb(bb);
94957 +
94958 + assign = gimple_build_assign(local_entropy, build_int_cstu(unsigned_intDI_type_node, get_random_const()));
94959 +// gimple_set_location(assign, loc);
94960 +#if BUILDING_GCC_VERSION <= 4007
94961 + find_referenced_vars_in(assign);
94962 +#endif
94963 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
94964 + update_stmt(assign);
94965 + bb = bb->next_bb;
94966 +
94967 + // 3. instrument each BB with an operation on the local entropy variable
94968 + while (bb != EXIT_BLOCK_PTR) {
94969 + perturb_local_entropy(bb, local_entropy);
94970 + bb = bb->next_bb;
94971 + };
94972 +
94973 + // 4. mix local entropy into the global entropy variable
94974 + perturb_latent_entropy(EXIT_BLOCK_PTR->prev_bb, local_entropy);
94975 + return 0;
94976 +}
94977 +
94978 +static void start_unit_callback(void *gcc_data, void *user_data)
94979 +{
94980 + tree latent_entropy_type;
94981 +
94982 +#if BUILDING_GCC_VERSION >= 4007
94983 + seed = get_random_seed(false);
94984 +#else
94985 + sscanf(get_random_seed(false), "%" HOST_WIDE_INT_PRINT "x", &seed);
94986 + seed *= seed;
94987 +#endif
94988 +
94989 + if (in_lto_p)
94990 + return;
94991 +
94992 + // extern volatile u64 latent_entropy
94993 + gcc_assert(TYPE_PRECISION(long_long_unsigned_type_node) == 64);
94994 + latent_entropy_type = build_qualified_type(long_long_unsigned_type_node, TYPE_QUALS(long_long_unsigned_type_node) | TYPE_QUAL_VOLATILE);
94995 + latent_entropy_decl = build_decl(UNKNOWN_LOCATION, VAR_DECL, get_identifier("latent_entropy"), latent_entropy_type);
94996 +
94997 + TREE_STATIC(latent_entropy_decl) = 1;
94998 + TREE_PUBLIC(latent_entropy_decl) = 1;
94999 + TREE_USED(latent_entropy_decl) = 1;
95000 + TREE_THIS_VOLATILE(latent_entropy_decl) = 1;
95001 + DECL_EXTERNAL(latent_entropy_decl) = 1;
95002 + DECL_ARTIFICIAL(latent_entropy_decl) = 1;
95003 + DECL_INITIAL(latent_entropy_decl) = NULL;
95004 + lang_hooks.decls.pushdecl(latent_entropy_decl);
95005 +// DECL_ASSEMBLER_NAME(latent_entropy_decl);
95006 +// varpool_finalize_decl(latent_entropy_decl);
95007 +// varpool_mark_needed_node(latent_entropy_decl);
95008 +}
95009 +
95010 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
95011 +{
95012 + const char * const plugin_name = plugin_info->base_name;
95013 + struct register_pass_info latent_entropy_pass_info = {
95014 + .pass = &latent_entropy_pass.pass,
95015 + .reference_pass_name = "optimized",
95016 + .ref_pass_instance_number = 1,
95017 + .pos_op = PASS_POS_INSERT_BEFORE
95018 + };
95019 +
95020 + if (!plugin_default_version_check(version, &gcc_version)) {
95021 + error(G_("incompatible gcc/plugin versions"));
95022 + return 1;
95023 + }
95024 +
95025 + register_callback(plugin_name, PLUGIN_INFO, NULL, &latent_entropy_plugin_info);
95026 + register_callback ("start_unit", PLUGIN_START_UNIT, &start_unit_callback, NULL);
95027 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &latent_entropy_pass_info);
95028 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
95029 +
95030 + return 0;
95031 +}
95032 diff --git a/tools/gcc/size_overflow_hash.data b/tools/gcc/size_overflow_hash.data
95033 new file mode 100644
95034 index 0000000..7982a0c
95035 --- /dev/null
95036 +++ b/tools/gcc/size_overflow_hash.data
95037 @@ -0,0 +1,5893 @@
95038 +intel_fake_agp_alloc_by_type_1 intel_fake_agp_alloc_by_type 1 1 NULL
95039 +batadv_orig_node_del_if_4 batadv_orig_node_del_if 2 4 NULL
95040 +storvsc_connect_to_vsp_22 storvsc_connect_to_vsp 2 22 NULL
95041 +compat_sock_setsockopt_23 compat_sock_setsockopt 5 23 NULL
95042 +carl9170_alloc_27 carl9170_alloc 1 27 NULL
95043 +sel_read_policyvers_55 sel_read_policyvers 3 55 NULL nohasharray
95044 +padzero_55 padzero 1 55 &sel_read_policyvers_55
95045 +cfg80211_disconnected_57 cfg80211_disconnected 4 57 NULL
95046 +__skb_to_sgvec_72 __skb_to_sgvec 0 72 NULL
95047 +crypto_authenc_setkey_80 crypto_authenc_setkey 3 80 NULL
95048 +snd_korg1212_copy_to_92 snd_korg1212_copy_to 6 92 NULL
95049 +load_msg_95 load_msg 2 95 NULL
95050 +device_flush_iotlb_115 device_flush_iotlb 2-3 115 NULL
95051 +init_q_132 init_q 4 132 NULL
95052 +memstick_alloc_host_142 memstick_alloc_host 1 142 NULL
95053 +hva_to_gfn_memslot_149 hva_to_gfn_memslot 0-1 149 NULL
95054 +tracing_trace_options_write_153 tracing_trace_options_write 3 153 NULL
95055 +nvme_create_queue_170 nvme_create_queue 3 170 NULL
95056 +xfs_buf_item_get_format_189 xfs_buf_item_get_format 2 189 NULL
95057 +iscsi_session_setup_196 iscsi_session_setup 4-5 196 NULL
95058 +virtblk_add_req_197 virtblk_add_req 2-3 197 NULL
95059 +proc_scsi_write_proc_267 proc_scsi_write_proc 3 267 NULL
95060 +br_port_info_size_268 br_port_info_size 0 268 NULL
95061 +generic_file_direct_write_291 generic_file_direct_write 0 291 NULL
95062 +read_file_war_stats_292 read_file_war_stats 3 292 NULL
95063 +syslog_print_307 syslog_print 2 307 NULL
95064 +platform_device_add_data_310 platform_device_add_data 3 310 NULL
95065 +dn_setsockopt_314 dn_setsockopt 5 314 NULL
95066 +next_node_allowed_318 next_node_allowed 1 318 NULL
95067 +compat_sys_ioctl_333 compat_sys_ioctl 3 333 NULL
95068 +btmrvl_txdnldready_read_413 btmrvl_txdnldready_read 3 413 NULL
95069 +lbs_rdmac_read_418 lbs_rdmac_read 3 418 NULL
95070 +snd_ca0106_ptr_read_467 snd_ca0106_ptr_read 0 467 NULL
95071 +_alloc_get_attr_desc_470 _alloc_get_attr_desc 2 470 NULL
95072 +dccp_manip_pkt_476 dccp_manip_pkt 4 476 NULL
95073 +pidlist_resize_496 pidlist_resize 2 496 NULL
95074 +read_vbt_r0_503 read_vbt_r0 1 503 NULL
95075 +rx_rx_defrag_end_read_505 rx_rx_defrag_end_read 3 505 NULL
95076 +ocfs2_validate_meta_ecc_bhs_527 ocfs2_validate_meta_ecc_bhs 0 527 NULL
95077 +zlib_deflate_workspacesize_537 zlib_deflate_workspacesize 0 537 NULL
95078 +iwl_dbgfs_wowlan_sram_read_540 iwl_dbgfs_wowlan_sram_read 3 540 NULL
95079 +dle_count_543 dle_count 0 543 NULL
95080 +devres_alloc_551 devres_alloc 2 551 NULL
95081 +snd_aw2_saa7146_get_hw_ptr_playback_558 snd_aw2_saa7146_get_hw_ptr_playback 0 558 NULL
95082 +dev_hard_header_565 dev_hard_header 0 565 NULL nohasharray
95083 +start_isoc_chain_565 start_isoc_chain 2 565 &dev_hard_header_565
95084 +compat_sys_preadv_583 compat_sys_preadv 3 583 NULL
95085 +smk_write_load_self2_591 smk_write_load_self2 3 591 NULL
95086 +ni_gpct_device_construct_610 ni_gpct_device_construct 5 610 NULL
95087 +fuse_request_alloc_nofs_617 fuse_request_alloc_nofs 1 617 NULL
95088 +compat_sys_shmat_620 compat_sys_shmat 3 620 NULL
95089 +isp1760_register_628 isp1760_register 1-2 628 NULL
95090 +clone_split_bio_633 clone_split_bio 6 633 NULL
95091 +remap_to_cache_640 remap_to_cache 3 640 NULL
95092 +drbd_bm_find_next_643 drbd_bm_find_next 2 643 NULL
95093 +unlink_queued_645 unlink_queued 3-4 645 NULL
95094 +dtim_interval_read_654 dtim_interval_read 3 654 NULL
95095 +mem_rx_free_mem_blks_read_675 mem_rx_free_mem_blks_read 3 675 NULL
95096 +rtl8169_try_rx_copy_705 rtl8169_try_rx_copy 3 705 NULL
95097 +persistent_ram_vmap_709 persistent_ram_vmap 1-2 709 NULL
95098 +ipath_resize_cq_712 ipath_resize_cq 2 712 NULL
95099 +disk_max_parts_719 disk_max_parts 0 719 NULL
95100 +sctp_setsockopt_peer_addr_params_734 sctp_setsockopt_peer_addr_params 3 734 NULL
95101 +dvb_video_write_754 dvb_video_write 3 754 NULL
95102 +if_writecmd_815 if_writecmd 2 815 NULL
95103 +aac_change_queue_depth_825 aac_change_queue_depth 2 825 NULL
95104 +read_fifo_826 read_fifo 3 826 NULL
95105 +um_idi_read_850 um_idi_read 3 850 NULL
95106 +ieee80211_if_fmt_rc_rateidx_mcs_mask_5ghz_856 ieee80211_if_fmt_rc_rateidx_mcs_mask_5ghz 3 856 NULL
95107 +o2net_send_message_vec_879 o2net_send_message_vec 4 879 NULL nohasharray
95108 +iwl_dbgfs_fh_reg_read_879 iwl_dbgfs_fh_reg_read 3 879 &o2net_send_message_vec_879
95109 +snd_pcm_action_single_905 snd_pcm_action_single 0 905 NULL
95110 +btmrvl_hsstate_read_920 btmrvl_hsstate_read 3 920 NULL
95111 +carl9170_cmd_buf_950 carl9170_cmd_buf 3 950 NULL
95112 +get_ramdisk_size_954 get_ramdisk_size 0 954 NULL
95113 +__nodes_weight_956 __nodes_weight 2-0 956 NULL
95114 +sys_msgrcv_959 sys_msgrcv 3 959 NULL
95115 +pte_prefetch_gfn_to_pfn_997 pte_prefetch_gfn_to_pfn 2 997 NULL nohasharray
95116 +hdlcdev_rx_997 hdlcdev_rx 3 997 &pte_prefetch_gfn_to_pfn_997
95117 +dm_cache_set_dirty_1016 dm_cache_set_dirty 2 1016 NULL
95118 +smk_write_cipso2_1021 smk_write_cipso2 3 1021 NULL
95119 +gigaset_initdriver_1060 gigaset_initdriver 2 1060 NULL
95120 +Read_hfc16_1070 Read_hfc16 0 1070 NULL
95121 +mce_request_packet_1073 mce_request_packet 3 1073 NULL
95122 +agp_create_memory_1075 agp_create_memory 1 1075 NULL
95123 +_scsih_adjust_queue_depth_1083 _scsih_adjust_queue_depth 2 1083 NULL
95124 +nfs_pgarray_set_1085 nfs_pgarray_set 2 1085 NULL
95125 +llcp_sock_sendmsg_1092 llcp_sock_sendmsg 4 1092 NULL
95126 +nfs4_init_nonuniform_client_string_1097 nfs4_init_nonuniform_client_string 3 1097 NULL
95127 +sys_mremap_1107 sys_mremap 5-1-2 1107 NULL
95128 +cfg80211_report_obss_beacon_1133 cfg80211_report_obss_beacon 3 1133 NULL
95129 +vmalloc_32_1135 vmalloc_32 1 1135 NULL
95130 +i2400m_rx_ctl_1157 i2400m_rx_ctl 4 1157 NULL
95131 +ipc_alloc_1192 ipc_alloc 1 1192 NULL
95132 +ib_create_send_mad_1196 ib_create_send_mad 5 1196 NULL
95133 +i2400m_rx_ctl_ack_1199 i2400m_rx_ctl_ack 3 1199 NULL
95134 +dgrp_dpa_read_1204 dgrp_dpa_read 3 1204 NULL
95135 +i2cdev_read_1206 i2cdev_read 3 1206 NULL
95136 +ipw_packet_received_skb_1230 ipw_packet_received_skb 2 1230 NULL
95137 +acpi_battery_write_alarm_1240 acpi_battery_write_alarm 3 1240 NULL
95138 +nested_get_page_1252 nested_get_page 2 1252 NULL
95139 +ocfs2_extend_file_1266 ocfs2_extend_file 3 1266 NULL
95140 +qla4xxx_change_queue_depth_1268 qla4xxx_change_queue_depth 2 1268 NULL
95141 +ioctl_private_iw_point_1273 ioctl_private_iw_point 7 1273 NULL
95142 +batadv_tt_prepare_packet_buff_1280 batadv_tt_prepare_packet_buff 4 1280 NULL
95143 +tx_frag_in_process_called_read_1290 tx_frag_in_process_called_read 3 1290 NULL
95144 +wm_adsp_buf_alloc_1317 wm_adsp_buf_alloc 2 1317 NULL
95145 +compat_put_u64_1319 compat_put_u64 1 1319 NULL
95146 +ffs_1322 ffs 0 1322 NULL
95147 +carl9170_rx_stream_1334 carl9170_rx_stream 3 1334 NULL
95148 +btrfs_submit_compressed_write_1347 btrfs_submit_compressed_write 5 1347 NULL
95149 +gen_pool_best_fit_1348 gen_pool_best_fit 2-3-4 1348 NULL
95150 +io_mapping_create_wc_1354 io_mapping_create_wc 1-2 1354 NULL
95151 +snd_pcm_lib_write1_1358 snd_pcm_lib_write1 0-3 1358 NULL
95152 +ipx_sendmsg_1362 ipx_sendmsg 4 1362 NULL
95153 +iov_num_pages_1364 iov_num_pages 0 1364 NULL
95154 +fw_stats_raw_read_1369 fw_stats_raw_read 3 1369 NULL
95155 +ocfs2_prepare_inode_for_write_1372 ocfs2_prepare_inode_for_write 3 1372 NULL
95156 +sctp_setsockopt_initmsg_1383 sctp_setsockopt_initmsg 3 1383 NULL
95157 +do_msgsnd_1387 do_msgsnd 4 1387 NULL
95158 +zone_page_state_1393 zone_page_state 0 1393 NULL
95159 +file_read_actor_1401 file_read_actor 4 1401 NULL
95160 +vb2_dc_get_user_pages_1442 vb2_dc_get_user_pages 1-3 1442 NULL
95161 +stack_max_size_read_1445 stack_max_size_read 3 1445 NULL
95162 +tx_queue_len_read_1463 tx_queue_len_read 3 1463 NULL
95163 +xprt_alloc_1475 xprt_alloc 2 1475 NULL
95164 +sta_num_ps_buf_frames_read_1488 sta_num_ps_buf_frames_read 3 1488 NULL
95165 +posix_acl_permission_1495 posix_acl_permission 0 1495 NULL
95166 +tomoyo_round2_1518 tomoyo_round2 0 1518 NULL
95167 +__vfio_dma_map_1523 __vfio_dma_map 3 1523 NULL
95168 +alloc_perm_bits_1532 alloc_perm_bits 2 1532 NULL
95169 +ieee80211_if_read_dot11MeshHWMPnetDiameterTraversalTime_1589 ieee80211_if_read_dot11MeshHWMPnetDiameterTraversalTime 3 1589 NULL
95170 +fc_frame_alloc_1596 fc_frame_alloc 2 1596 NULL
95171 +packet_buffer_init_1607 packet_buffer_init 2 1607 NULL
95172 +btmrvl_hscmd_read_1614 btmrvl_hscmd_read 3 1614 NULL
95173 +v9fs_fid_xattr_get_1618 v9fs_fid_xattr_get 0 1618 NULL
95174 +btmrvl_hsmode_read_1647 btmrvl_hsmode_read 3 1647 NULL
95175 +ikconfig_read_current_1658 ikconfig_read_current 3 1658 NULL
95176 +netdev_feature_string_1667 netdev_feature_string 0 1667 NULL
95177 +compat_x25_ioctl_1674 compat_x25_ioctl 3 1674 NULL
95178 +rmap_add_1677 rmap_add 3 1677 NULL
95179 +configfs_read_file_1683 configfs_read_file 3 1683 NULL
95180 +coda_psdev_write_1711 coda_psdev_write 3 1711 NULL
95181 +btrfs_dir_data_len_1714 btrfs_dir_data_len 0 1714 NULL
95182 +dma_memcpy_pg_to_iovec_1725 dma_memcpy_pg_to_iovec 6 1725 NULL
95183 +tx_frag_called_read_1748 tx_frag_called_read 3 1748 NULL
95184 +compat_cdrom_generic_command_1756 compat_cdrom_generic_command 4 1756 NULL
95185 +ieee80211_new_mesh_header_1761 ieee80211_new_mesh_header 0 1761 NULL
95186 +ebt_size_mwt_1768 ebt_size_mwt 0 1768 NULL
95187 +cosa_write_1774 cosa_write 3 1774 NULL
95188 +update_macheader_1775 update_macheader 7 1775 NULL
95189 +fcoe_ctlr_device_add_1793 fcoe_ctlr_device_add 3 1793 NULL
95190 +__nodelist_scnprintf_1815 __nodelist_scnprintf 0-2-4 1815 NULL
95191 +alloc_pages_exact_1892 alloc_pages_exact 1 1892 NULL
95192 +rx_defrag_called_read_1897 rx_defrag_called_read 3 1897 NULL
95193 +nfs_parse_server_name_1899 nfs_parse_server_name 2 1899 NULL
95194 +tx_tx_retry_data_read_1926 tx_tx_retry_data_read 3 1926 NULL
95195 +memblock_alloc_base_1938 memblock_alloc_base 1-2 1938 NULL
95196 +cyttsp_probe_1940 cyttsp_probe 4 1940 NULL
95197 +ieee80211_if_fmt_dot11MeshConfirmTimeout_1945 ieee80211_if_fmt_dot11MeshConfirmTimeout 3 1945 NULL
95198 +read_swap_header_1957 read_swap_header 0 1957 NULL
95199 +ivtv_v4l2_read_1964 ivtv_v4l2_read 3 1964 NULL
95200 +sel_read_avc_hash_stats_1984 sel_read_avc_hash_stats 3 1984 NULL
95201 +__alloc_bootmem_node_1992 __alloc_bootmem_node 2-3 1992 NULL
95202 +atomic_read_unchecked_1995 atomic_read_unchecked 0 1995 NULL
95203 +batadv_tt_commit_changes_2008 batadv_tt_commit_changes 4 2008 NULL
95204 +sep_prepare_input_dma_table_2009 sep_prepare_input_dma_table 2-3 2009 NULL
95205 +rx_rx_defrag_read_2010 rx_rx_defrag_read 3 2010 NULL
95206 +ocfs2_global_qinit_alloc_2018 ocfs2_global_qinit_alloc 0 2018 NULL
95207 +write_flush_pipefs_2021 write_flush_pipefs 3 2021 NULL
95208 +BcmCopySection_2035 BcmCopySection 5 2035 NULL
95209 +devm_ioremap_nocache_2036 devm_ioremap_nocache 2-3 2036 NULL
95210 +ath6kl_fwlog_mask_read_2050 ath6kl_fwlog_mask_read 3 2050 NULL
95211 +ocfs2_expand_inline_dir_2063 ocfs2_expand_inline_dir 3 2063 NULL
95212 +subbuf_read_actor_2071 subbuf_read_actor 3 2071 NULL
95213 +iwl_dbgfs_current_sleep_command_read_2081 iwl_dbgfs_current_sleep_command_read 3 2081 NULL
95214 +idetape_chrdev_read_2097 idetape_chrdev_read 3 2097 NULL
95215 +audit_expand_2098 audit_expand 2 2098 NULL
95216 +num_pages_spanned_2105 num_pages_spanned 0 2105 NULL
95217 +iwl_dbgfs_log_event_read_2107 iwl_dbgfs_log_event_read 3 2107 NULL
95218 +ecryptfs_encrypt_and_encode_filename_2109 ecryptfs_encrypt_and_encode_filename 6 2109 NULL
95219 +__find_xattr_2117 __find_xattr 6 2117 NULL nohasharray
95220 +enable_read_2117 enable_read 3 2117 &__find_xattr_2117
95221 +pcf50633_write_block_2124 pcf50633_write_block 2-3 2124 NULL
95222 +check_load_and_stores_2143 check_load_and_stores 2 2143 NULL
95223 +lp_gpio_irq_map_2149 lp_gpio_irq_map 2 2149 NULL
95224 +mlx4_init_icm_table_2151 mlx4_init_icm_table 5-4 2151 NULL
95225 +iov_iter_count_2152 iov_iter_count 0 2152 NULL
95226 +_ore_get_io_state_2166 _ore_get_io_state 3-4-5 2166 NULL
95227 +ssb_bus_ssbbus_register_2217 ssb_bus_ssbbus_register 2 2217 NULL
95228 +u32_array_read_2219 u32_array_read 3 2219 NULL
95229 +vhci_write_2224 vhci_write 3 2224 NULL
95230 +efx_tsoh_page_count_2225 efx_tsoh_page_count 0 2225 NULL
95231 +lowpan_get_mac_header_length_2231 lowpan_get_mac_header_length 0 2231 NULL
95232 +ieee80211_if_read_dot11MeshHWMPRannInterval_2249 ieee80211_if_read_dot11MeshHWMPRannInterval 3 2249 NULL
95233 +netlbl_secattr_catmap_walk_2255 netlbl_secattr_catmap_walk 0-2 2255 NULL
95234 +sel_write_avc_cache_threshold_2256 sel_write_avc_cache_threshold 3 2256 NULL
95235 +do_update_counters_2259 do_update_counters 4 2259 NULL
95236 +ath6kl_wmi_bssinfo_event_rx_2275 ath6kl_wmi_bssinfo_event_rx 3 2275 NULL
95237 +debug_debug5_read_2291 debug_debug5_read 3 2291 NULL
95238 +kvm_clear_guest_page_2308 kvm_clear_guest_page 4-2 2308 NULL
95239 +intel_sdvo_set_value_2311 intel_sdvo_set_value 4 2311 NULL
95240 +picolcd_fb_write_2318 picolcd_fb_write 3 2318 NULL
95241 +gart_map_page_2325 gart_map_page 3-4 2325 NULL
95242 +__erst_read_to_erange_2341 __erst_read_to_erange 0 2341 NULL
95243 +zr364xx_read_2354 zr364xx_read 3 2354 NULL
95244 +viafb_iga2_odev_proc_write_2363 viafb_iga2_odev_proc_write 3 2363 NULL
95245 +xfs_buf_map_from_irec_2368 xfs_buf_map_from_irec 5 2368 NULL
95246 +il_dbgfs_sensitivity_read_2370 il_dbgfs_sensitivity_read 3 2370 NULL
95247 +rtl_port_map_2385 rtl_port_map 1-2 2385 NULL
95248 +rxpipe_rx_prep_beacon_drop_read_2403 rxpipe_rx_prep_beacon_drop_read 3 2403 NULL
95249 +isdn_v110_open_2418 isdn_v110_open 3 2418 NULL
95250 +raid1_size_2419 raid1_size 0-2 2419 NULL
95251 +roccat_common2_send_2422 roccat_common2_send 4 2422 NULL
95252 +hfcpci_empty_fifo_2427 hfcpci_empty_fifo 4 2427 NULL
95253 +ioremap_nocache_2439 ioremap_nocache 1-2 2439 NULL
95254 +tty_buffer_find_2443 tty_buffer_find 2 2443 NULL
95255 +ath6kl_usb_bmi_write_2454 ath6kl_usb_bmi_write 3 2454 NULL
95256 +b43legacy_debugfs_read_2473 b43legacy_debugfs_read 3 2473 NULL
95257 +update_pmkid_2481 update_pmkid 4 2481 NULL
95258 +wiphy_new_2482 wiphy_new 2 2482 NULL
95259 +bio_alloc_bioset_2484 bio_alloc_bioset 2 2484 NULL
95260 +lookup_cache_entry_2494 lookup_cache_entry 2 2494 NULL
95261 +squashfs_read_fragment_index_table_2506 squashfs_read_fragment_index_table 4 2506 NULL
95262 +dm_write_2513 dm_write 3 2513 NULL
95263 +v9fs_cached_file_read_2514 v9fs_cached_file_read 3 2514 NULL
95264 +ext4_get_inode_loc_2516 ext4_get_inode_loc 0 2516 NULL
95265 +gspca_dev_probe_2570 gspca_dev_probe 4 2570 NULL
95266 +i915_next_seqno_write_2572 i915_next_seqno_write 3 2572 NULL
95267 +pcm_sanity_check_2574 pcm_sanity_check 0 2574 NULL
95268 +smk_write_logging_2618 smk_write_logging 3 2618 NULL
95269 +kvm_gfn_to_hva_cache_init_2636 kvm_gfn_to_hva_cache_init 3 2636 NULL
95270 +lro_gen_skb_2644 lro_gen_skb 6 2644 NULL
95271 +nfc_llcp_send_ui_frame_2702 nfc_llcp_send_ui_frame 5 2702 NULL
95272 +memcpy_fromiovecend_2707 memcpy_fromiovecend 3-4 2707 NULL
95273 +__xip_file_write_2733 __xip_file_write 4-3 2733 NULL
95274 +hid_report_raw_event_2762 hid_report_raw_event 4 2762 NULL
95275 +mon_bin_ioctl_2771 mon_bin_ioctl 3 2771 NULL
95276 +__next_cpu_2782 __next_cpu 1 2782 NULL
95277 +set_msr_hyperv_pw_2785 set_msr_hyperv_pw 3 2785 NULL
95278 +sel_read_enforce_2828 sel_read_enforce 3 2828 NULL
95279 +vb2_dc_get_userptr_2829 vb2_dc_get_userptr 2-3 2829 NULL
95280 +wait_for_avail_2847 wait_for_avail 0 2847 NULL
95281 +ufs_free_fragments_2857 ufs_free_fragments 2 2857 NULL
95282 +sfq_alloc_2861 sfq_alloc 1 2861 NULL
95283 +move_addr_to_user_2868 move_addr_to_user 2 2868 NULL
95284 +mq_map_2871 mq_map 2 2871 NULL
95285 +nla_padlen_2883 nla_padlen 1 2883 NULL
95286 +cmm_write_2896 cmm_write 3 2896 NULL
95287 +alloc_page_cgroup_2919 alloc_page_cgroup 1 2919 NULL
95288 +xfs_trans_get_buf_map_2927 xfs_trans_get_buf_map 4 2927 NULL
95289 +nes_read_indexed_2946 nes_read_indexed 0 2946 NULL
95290 +tm6000_i2c_recv_regs16_2949 tm6000_i2c_recv_regs16 5 2949 NULL
95291 +ppp_cp_event_2965 ppp_cp_event 6 2965 NULL
95292 +do_strnlen_user_2976 do_strnlen_user 0-2 2976 NULL
95293 +p9_nr_pages_2992 p9_nr_pages 0-2 2992 NULL
95294 +do_dmabuf_dirty_sou_3017 do_dmabuf_dirty_sou 7 3017 NULL
95295 +depth_write_3021 depth_write 3 3021 NULL
95296 +snd_azf3328_codec_inl_3022 snd_azf3328_codec_inl 0 3022 NULL
95297 +xfrm_dst_alloc_copy_3034 xfrm_dst_alloc_copy 3 3034 NULL
95298 +iwl_dbgfs_sleep_level_override_read_3038 iwl_dbgfs_sleep_level_override_read 3 3038 NULL
95299 +nr_free_buffer_pages_3044 nr_free_buffer_pages 0 3044 NULL
95300 +il3945_ucode_rx_stats_read_3048 il3945_ucode_rx_stats_read 3 3048 NULL
95301 +qp_alloc_ppn_set_3068 qp_alloc_ppn_set 2-4 3068 NULL
95302 +__blk_end_bidi_request_3070 __blk_end_bidi_request 3-4 3070 NULL
95303 +dac960_user_command_proc_write_3071 dac960_user_command_proc_write 3 3071 NULL
95304 +free_coherent_3082 free_coherent 4-2 3082 NULL
95305 +clone_bio_3100 clone_bio 6 3100 NULL nohasharray
95306 +ttusb2_msg_3100 ttusb2_msg 4 3100 &clone_bio_3100
95307 +rb_alloc_3102 rb_alloc 1 3102 NULL
95308 +simple_write_to_buffer_3122 simple_write_to_buffer 5-2 3122 NULL
95309 +print_time_3132 print_time 0 3132 NULL
95310 +fill_write_buffer_3142 fill_write_buffer 3 3142 NULL
95311 +CIFSSMBSetPosixACL_3154 CIFSSMBSetPosixACL 5 3154 NULL
95312 +compat_sys_migrate_pages_3157 compat_sys_migrate_pages 2 3157 NULL
95313 +uv_num_possible_blades_3177 uv_num_possible_blades 0 3177 NULL
95314 +uvc_video_stats_dump_3181 uvc_video_stats_dump 3 3181 NULL
95315 +compat_do_ip6t_set_ctl_3184 compat_do_ip6t_set_ctl 4 3184 NULL
95316 +mempool_create_node_3191 mempool_create_node 1 3191 NULL
95317 +alloc_context_3194 alloc_context 1 3194 NULL
95318 +shmem_pread_slow_3198 shmem_pread_slow 3 3198 NULL
95319 +kimage_crash_alloc_3233 kimage_crash_alloc 3 3233 NULL
95320 +do_read_log_to_user_3236 do_read_log_to_user 4 3236 NULL
95321 +ext3_xattr_find_entry_3237 ext3_xattr_find_entry 0 3237 NULL
95322 +key_key_read_3241 key_key_read 3 3241 NULL
95323 +number_3243 number 0 3243 NULL
95324 +check_vendor_extension_3254 check_vendor_extension 1 3254 NULL
95325 +__ilog2_u64_3284 __ilog2_u64 0 3284 NULL
95326 +arvo_sysfs_write_3311 arvo_sysfs_write 6 3311 NULL
95327 +dbDiscardAG_3322 dbDiscardAG 3 3322 NULL
95328 +compat_sys_setsockopt_3326 compat_sys_setsockopt 5 3326 NULL
95329 +aac_rkt_ioremap_3333 aac_rkt_ioremap 2 3333 NULL
95330 +read_from_oldmem_3337 read_from_oldmem 2 3337 NULL
95331 +tty_port_register_device_attr_3341 tty_port_register_device_attr 3 3341 NULL
95332 +il_dbgfs_interrupt_read_3351 il_dbgfs_interrupt_read 3 3351 NULL
95333 +gsm_control_rls_3353 gsm_control_rls 3 3353 NULL
95334 +scnprintf_3360 scnprintf 0-2 3360 NULL
95335 +x86_emulate_instruction_3389 x86_emulate_instruction 2 3389 NULL
95336 +mtdchar_writeoob_3393 mtdchar_writeoob 4 3393 NULL
95337 +send_stream_3397 send_stream 4 3397 NULL
95338 +isdn_readbchan_3401 isdn_readbchan 0-5 3401 NULL
95339 +msix_map_region_3411 msix_map_region 3 3411 NULL
95340 +mei_io_cb_alloc_resp_buf_3414 mei_io_cb_alloc_resp_buf 2 3414 NULL
95341 +pci_add_cap_save_buffer_3426 pci_add_cap_save_buffer 3 3426 NULL
95342 +crystalhd_create_dio_pool_3427 crystalhd_create_dio_pool 2 3427 NULL
95343 +pipe_iov_copy_to_user_3447 pipe_iov_copy_to_user 3 3447 NULL
95344 +percpu_modalloc_3448 percpu_modalloc 2-3 3448 NULL
95345 +map_single_3449 map_single 0-2 3449 NULL
95346 +jffs2_acl_setxattr_3464 jffs2_acl_setxattr 4 3464 NULL nohasharray
95347 +snd_pcm_lib_readv_transfer_3464 snd_pcm_lib_readv_transfer 4-2-5 3464 &jffs2_acl_setxattr_3464
95348 +alloc_skb_fclone_3467 alloc_skb_fclone 1 3467 NULL
95349 +security_context_to_sid_default_3492 security_context_to_sid_default 2 3492 NULL
95350 +xfrm_migrate_msgsize_3496 xfrm_migrate_msgsize 1 3496 NULL
95351 +kvm_handle_bad_page_3503 kvm_handle_bad_page 2 3503 NULL
95352 +mem_tx_free_mem_blks_read_3521 mem_tx_free_mem_blks_read 3 3521 NULL nohasharray
95353 +ieee80211_wx_set_gen_ie_rsl_3521 ieee80211_wx_set_gen_ie_rsl 3 3521 &mem_tx_free_mem_blks_read_3521
95354 +btrfs_dir_name_len_3549 btrfs_dir_name_len 0 3549 NULL
95355 +b43legacy_read16_3561 b43legacy_read16 0 3561 NULL
95356 +alloc_smp_resp_3566 alloc_smp_resp 1 3566 NULL
95357 +evtchn_read_3569 evtchn_read 3 3569 NULL
95358 +vc_resize_3585 vc_resize 2-3 3585 NULL
95359 +compat_sys_semtimedop_3606 compat_sys_semtimedop 3 3606 NULL
95360 +sctp_getsockopt_events_3607 sctp_getsockopt_events 2 3607 NULL
95361 +edac_mc_alloc_3611 edac_mc_alloc 4 3611 NULL
95362 +tx_tx_starts_read_3617 tx_tx_starts_read 3 3617 NULL
95363 +aligned_kmalloc_3628 aligned_kmalloc 1 3628 NULL
95364 +cm_copy_private_data_3649 cm_copy_private_data 2 3649 NULL
95365 +ath6kl_disconnect_timeout_read_3650 ath6kl_disconnect_timeout_read 3 3650 NULL
95366 +i915_compat_ioctl_3656 i915_compat_ioctl 2 3656 NULL
95367 +create_irq_3703 create_irq 0 3703 NULL nohasharray
95368 +btmrvl_psmode_write_3703 btmrvl_psmode_write 3 3703 &create_irq_3703 nohasharray
95369 +snd_m3_assp_read_3703 snd_m3_assp_read 0 3703 &btmrvl_psmode_write_3703
95370 +videobuf_pages_to_sg_3708 videobuf_pages_to_sg 2 3708 NULL
95371 +ci_ll_write_3740 ci_ll_write 4 3740 NULL nohasharray
95372 +ath6kl_mgmt_tx_3740 ath6kl_mgmt_tx 7 3740 &ci_ll_write_3740
95373 +sctp_setsockopt_auth_key_3793 sctp_setsockopt_auth_key 3 3793 NULL
95374 +ncp_file_write_3813 ncp_file_write 3 3813 NULL
95375 +read_file_tx_chainmask_3829 read_file_tx_chainmask 3 3829 NULL
95376 +stringify_nodemap_3842 stringify_nodemap 2 3842 NULL
95377 +ubi_eba_read_leb_3847 ubi_eba_read_leb 0 3847 NULL
95378 +create_one_cdev_3852 create_one_cdev 2 3852 NULL
95379 +smk_read_onlycap_3855 smk_read_onlycap 3 3855 NULL
95380 +get_fd_set_3866 get_fd_set 1 3866 NULL
95381 +garp_attr_create_3883 garp_attr_create 3 3883 NULL
95382 +uea_send_modem_cmd_3888 uea_send_modem_cmd 3 3888 NULL
95383 +efivarfs_file_read_3893 efivarfs_file_read 3 3893 NULL
95384 +nvram_write_3894 nvram_write 3 3894 NULL
95385 +pipeline_pre_proc_swi_read_3898 pipeline_pre_proc_swi_read 3 3898 NULL
95386 +comedi_buf_read_n_available_3899 comedi_buf_read_n_available 0 3899 NULL
95387 +vcs_write_3910 vcs_write 3 3910 NULL
95388 +atalk_compat_ioctl_3991 atalk_compat_ioctl 3 3991 NULL
95389 +do_add_counters_3992 do_add_counters 3 3992 NULL
95390 +userspace_status_4004 userspace_status 4 4004 NULL
95391 +mei_write_4005 mei_write 3 4005 NULL nohasharray
95392 +xfs_check_block_4005 xfs_check_block 4 4005 &mei_write_4005
95393 +snd_hdsp_capture_copy_4011 snd_hdsp_capture_copy 5 4011 NULL
95394 +mm_populate_4016 mm_populate 1 4016 NULL
95395 +blk_end_request_4024 blk_end_request 3 4024 NULL
95396 +ext4_xattr_find_entry_4025 ext4_xattr_find_entry 0 4025 NULL
95397 +usbnet_write_cmd_async_4035 usbnet_write_cmd_async 7 4035 NULL
95398 +read_file_queues_4078 read_file_queues 3 4078 NULL
95399 +fbcon_do_set_font_4079 fbcon_do_set_font 2-3 4079 NULL
95400 +da9052_free_irq_4090 da9052_free_irq 2 4090 NULL
95401 +ntb_netdev_change_mtu_4147 ntb_netdev_change_mtu 2 4147 NULL
95402 +tm6000_read_4151 tm6000_read 3 4151 NULL
95403 +mpt_raid_phys_disk_get_num_paths_4155 mpt_raid_phys_disk_get_num_paths 0 4155 NULL
95404 +msg_bits_4158 msg_bits 0-3-4 4158 NULL
95405 +get_alua_req_4166 get_alua_req 3 4166 NULL
95406 +blk_dropped_read_4168 blk_dropped_read 3 4168 NULL
95407 +read_file_bool_4180 read_file_bool 3 4180 NULL
95408 +f1x_determine_channel_4202 f1x_determine_channel 2 4202 NULL
95409 +_osd_req_list_objects_4204 _osd_req_list_objects 6 4204 NULL
95410 +__snd_gf1_read_addr_4210 __snd_gf1_read_addr 0 4210 NULL
95411 +goldfish_audio_write_4284 goldfish_audio_write 3 4284 NULL
95412 +paging32_page_fault_4288 paging32_page_fault 2 4288 NULL
95413 +xt_compat_add_offset_4289 xt_compat_add_offset 0 4289 NULL
95414 +__usbnet_read_cmd_4299 __usbnet_read_cmd 7 4299 NULL
95415 +dvb_ringbuffer_pkt_read_user_4303 dvb_ringbuffer_pkt_read_user 3-2-5 4303 NULL
95416 +nouveau_fifo_create__4327 nouveau_fifo_create_ 5-6 4327 NULL
95417 +snd_rawmidi_kernel_read_4328 snd_rawmidi_kernel_read 3 4328 NULL
95418 +__copy_from_user_inatomic_4365 __copy_from_user_inatomic 3 4365 NULL
95419 +sys_setdomainname_4373 sys_setdomainname 2 4373 NULL
95420 +irda_sendmsg_4388 irda_sendmsg 4 4388 NULL
95421 +access_process_vm_4412 access_process_vm 0-2-4 4412 NULL nohasharray
95422 +cxacru_cm_get_array_4412 cxacru_cm_get_array 4 4412 &access_process_vm_4412
95423 +libfc_vport_create_4415 libfc_vport_create 2 4415 NULL
95424 +do_pages_stat_4437 do_pages_stat 2 4437 NULL
95425 +memparse_4444 memparse 0 4444 NULL
95426 +at76_set_card_command_4471 at76_set_card_command 4 4471 NULL
95427 +snd_seq_expand_var_event_4481 snd_seq_expand_var_event 0-5 4481 NULL
95428 +sys_semtimedop_4486 sys_semtimedop 3 4486 NULL
95429 +vmbus_establish_gpadl_4495 vmbus_establish_gpadl 3 4495 NULL
95430 +set_link_security_4502 set_link_security 4 4502 NULL
95431 +dm_cache_remove_mapping_4513 dm_cache_remove_mapping 2 4513 NULL
95432 +__gfn_to_pfn_memslot_4530 __gfn_to_pfn_memslot 2 4530 NULL
95433 +sys_llistxattr_4532 sys_llistxattr 3 4532 NULL
95434 +da9052_group_write_4534 da9052_group_write 2-3 4534 NULL
95435 +tty_register_device_4544 tty_register_device 2 4544 NULL
95436 +videobuf_vmalloc_to_sg_4548 videobuf_vmalloc_to_sg 2 4548 NULL
95437 +btrfs_file_extent_inline_item_len_4575 btrfs_file_extent_inline_item_len 0 4575 NULL
95438 +xfs_buf_get_maps_4581 xfs_buf_get_maps 2 4581 NULL
95439 +bch_alloc_4593 bch_alloc 1 4593 NULL
95440 +__wb_force_remove_mapping_4622 __wb_force_remove_mapping 2 4622 NULL
95441 +iwl_dbgfs_tx_queue_read_4635 iwl_dbgfs_tx_queue_read 3 4635 NULL
95442 +skb_add_data_nocache_4682 skb_add_data_nocache 4 4682 NULL
95443 +cx18_read_pos_4683 cx18_read_pos 3 4683 NULL
95444 +short_retry_limit_read_4687 short_retry_limit_read 3 4687 NULL
95445 +kone_receive_4690 kone_receive 4 4690 NULL
95446 +round_pipe_size_4701 round_pipe_size 0 4701 NULL
95447 +cxgbi_alloc_big_mem_4707 cxgbi_alloc_big_mem 1 4707 NULL
95448 +btmrvl_gpiogap_read_4718 btmrvl_gpiogap_read 3 4718 NULL
95449 +ati_create_gatt_pages_4722 ati_create_gatt_pages 1 4722 NULL nohasharray
95450 +show_header_4722 show_header 3 4722 &ati_create_gatt_pages_4722
95451 +__find_free_cblock_4741 __find_free_cblock 2 4741 NULL
95452 +memblock_find_in_range_4759 memblock_find_in_range 3-4 4759 NULL
95453 +pwr_rcvd_bcns_cnt_read_4774 pwr_rcvd_bcns_cnt_read 3 4774 NULL
95454 +create_subvol_4791 create_subvol 4 4791 NULL
95455 +ncp__vol2io_4804 ncp__vol2io 5 4804 NULL
95456 +repair_io_failure_4815 repair_io_failure 4 4815 NULL
95457 +gigaset_if_receive_4861 gigaset_if_receive 3 4861 NULL
95458 +key_tx_spec_read_4862 key_tx_spec_read 3 4862 NULL
95459 +ocfs2_defrag_extent_4873 ocfs2_defrag_extent 3 4873 NULL
95460 +hid_register_field_4874 hid_register_field 2-3 4874 NULL
95461 +vga_arb_read_4886 vga_arb_read 3 4886 NULL
95462 +sys_ipc_4889 sys_ipc 3 4889 NULL
95463 +sys_process_vm_writev_4928 sys_process_vm_writev 3-5 4928 NULL
95464 +ntfs_rl_insert_4931 ntfs_rl_insert 2-4 4931 NULL
95465 +ieee80211_if_fmt_ave_beacon_4941 ieee80211_if_fmt_ave_beacon 3 4941 NULL
95466 +devm_kzalloc_4966 devm_kzalloc 2 4966 NULL
95467 +compat_rawv6_setsockopt_4967 compat_rawv6_setsockopt 5 4967 NULL
95468 +skb_network_header_len_4971 skb_network_header_len 0 4971 NULL
95469 +ieee80211_if_fmt_dot11MeshHWMPconfirmationInterval_4976 ieee80211_if_fmt_dot11MeshHWMPconfirmationInterval 3 4976 NULL
95470 +vmw_surface_define_size_4993 vmw_surface_define_size 0 4993 NULL
95471 +qla82xx_pci_mem_write_direct_5008 qla82xx_pci_mem_write_direct 2 5008 NULL
95472 +do_mincore_5018 do_mincore 0-1 5018 NULL
95473 +mtd_device_parse_register_5024 mtd_device_parse_register 5 5024 NULL
95474 +ocfs2_check_range_for_holes_5066 ocfs2_check_range_for_holes 2-3 5066 NULL
95475 +snd_mixart_BA1_read_5082 snd_mixart_BA1_read 5 5082 NULL
95476 +snd_emu10k1_ptr20_read_5087 snd_emu10k1_ptr20_read 0 5087 NULL
95477 +get_random_bytes_5091 get_random_bytes 2 5091 NULL nohasharray
95478 +kfifo_copy_from_user_5091 kfifo_copy_from_user 3 5091 &get_random_bytes_5091 nohasharray
95479 +blk_rq_sectors_5091 blk_rq_sectors 0 5091 &kfifo_copy_from_user_5091
95480 +mpol_to_str_5093 mpol_to_str 2 5093 NULL
95481 +sound_write_5102 sound_write 3 5102 NULL
95482 +clear_dirty_5105 clear_dirty 3 5105 NULL
95483 +ufs_add_fragments_5144 ufs_add_fragments 2 5144 NULL
95484 +compat_ptr_5159 compat_ptr 0-1 5159 NULL
95485 +__uwb_addr_print_5161 __uwb_addr_print 2 5161 NULL
95486 +iwl_dbgfs_status_read_5171 iwl_dbgfs_status_read 3 5171 NULL
95487 +acpi_pcc_get_sqty_5176 acpi_pcc_get_sqty 0 5176 NULL
95488 +sfi_map_memory_5183 sfi_map_memory 1-2 5183 NULL
95489 +skb_network_header_5203 skb_network_header 0 5203 NULL
95490 +pipe_set_size_5204 pipe_set_size 2 5204 NULL
95491 +ppp_cp_parse_cr_5214 ppp_cp_parse_cr 4 5214 NULL
95492 +ath6kl_debug_roam_tbl_event_5224 ath6kl_debug_roam_tbl_event 3 5224 NULL
95493 +ssb_ioremap_5228 ssb_ioremap 2 5228 NULL
95494 +isdn_ppp_skb_push_5236 isdn_ppp_skb_push 2 5236 NULL
95495 +do_atmif_sioc_5247 do_atmif_sioc 3 5247 NULL
95496 +gfn_to_hva_memslot_5265 gfn_to_hva_memslot 2 5265 NULL
95497 +alloc_cache_blocks_with_hash_5285 alloc_cache_blocks_with_hash 2 5285 NULL
95498 +__gfn_to_hva_memslot_5304 __gfn_to_hva_memslot 0-2 5304 NULL
95499 +sbc_get_write_same_sectors_5317 sbc_get_write_same_sectors 0 5317 NULL
95500 +pwr_elp_enter_read_5324 pwr_elp_enter_read 3 5324 NULL
95501 +allocate_cnodes_5329 allocate_cnodes 1 5329 NULL
95502 +ps_pspoll_utilization_read_5361 ps_pspoll_utilization_read 3 5361 NULL
95503 +cciss_allocate_sg_chain_blocks_5368 cciss_allocate_sg_chain_blocks 3-2 5368 NULL
95504 +kvm_pin_pages_5369 kvm_pin_pages 2 5369 NULL
95505 +bitmap_fold_5396 bitmap_fold 4 5396 NULL
95506 +nilfs_palloc_entries_per_group_5418 nilfs_palloc_entries_per_group 0 5418 NULL
95507 +sfi_map_table_5462 sfi_map_table 1 5462 NULL
95508 +xfs_efd_init_5463 xfs_efd_init 3 5463 NULL
95509 +xfs_efi_init_5476 xfs_efi_init 2 5476 NULL
95510 +ubi_leb_write_5478 ubi_leb_write 4-5 5478 NULL
95511 +cifs_security_flags_proc_write_5484 cifs_security_flags_proc_write 3 5484 NULL
95512 +tty_write_5494 tty_write 3 5494 NULL
95513 +tomoyo_update_domain_5498 tomoyo_update_domain 2 5498 NULL nohasharray
95514 +ieee80211_if_fmt_last_beacon_5498 ieee80211_if_fmt_last_beacon 3 5498 &tomoyo_update_domain_5498
95515 +__max_nr_grant_frames_5505 __max_nr_grant_frames 0 5505 NULL
95516 +spidev_message_5518 spidev_message 3 5518 NULL
95517 +ieee80211_if_fmt_auto_open_plinks_5534 ieee80211_if_fmt_auto_open_plinks 3 5534 NULL
95518 +brcmu_pkt_buf_get_skb_5556 brcmu_pkt_buf_get_skb 1 5556 NULL
95519 +le_readq_5557 le_readq 0 5557 NULL
95520 +inw_5558 inw 0 5558 NULL
95521 +fir16_create_5574 fir16_create 3 5574 NULL
95522 +bioset_create_5580 bioset_create 1 5580 NULL
95523 +oz_ep_alloc_5587 oz_ep_alloc 2 5587 NULL
95524 +usb_dump_device_descriptor_5599 usb_dump_device_descriptor 0 5599 NULL
95525 +ldm_frag_add_5611 ldm_frag_add 2 5611 NULL
95526 +compat_copy_entries_5617 compat_copy_entries 0 5617 NULL
95527 +ext4_xattr_get_5661 ext4_xattr_get 0 5661 NULL
95528 +posix_clock_register_5662 posix_clock_register 2 5662 NULL
95529 +mthca_map_reg_5664 mthca_map_reg 2-3 5664 NULL
95530 +__videobuf_alloc_vb_5665 __videobuf_alloc_vb 1 5665 NULL
95531 +wb_clear_dirty_5684 wb_clear_dirty 2 5684 NULL
95532 +get_arg_5694 get_arg 3 5694 NULL
95533 +vmw_kms_readback_5727 vmw_kms_readback 6 5727 NULL
95534 +reexecute_instruction_5733 reexecute_instruction 2 5733 NULL
95535 +rts51x_transfer_data_partial_5735 rts51x_transfer_data_partial 6 5735 NULL
95536 +ubi_cdev_compat_ioctl_5746 ubi_cdev_compat_ioctl 3 5746 NULL
95537 +sctp_setsockopt_autoclose_5775 sctp_setsockopt_autoclose 3 5775 NULL
95538 +compat_sys_writev_5784 compat_sys_writev 3 5784 NULL
95539 +__vxge_hw_blockpool_malloc_5786 __vxge_hw_blockpool_malloc 2 5786 NULL
95540 +skb_copy_datagram_iovec_5806 skb_copy_datagram_iovec 2-4 5806 NULL
95541 +nv50_disp_pioc_create__5812 nv50_disp_pioc_create_ 5 5812 NULL
95542 +ceph_x_encrypt_buflen_5829 ceph_x_encrypt_buflen 0-1 5829 NULL
95543 +autofs4_root_compat_ioctl_5838 autofs4_root_compat_ioctl 3 5838 NULL
95544 +ceph_msg_new_5846 ceph_msg_new 2 5846 NULL
95545 +ixgb_check_copybreak_5847 ixgb_check_copybreak 3 5847 NULL
95546 +setup_req_5848 setup_req 3 5848 NULL
95547 +rx_filter_max_arp_queue_dep_read_5851 rx_filter_max_arp_queue_dep_read 3 5851 NULL
95548 +compat_sys_move_pages_5861 compat_sys_move_pages 2 5861 NULL nohasharray
95549 +uinput_compat_ioctl_5861 uinput_compat_ioctl 3 5861 &compat_sys_move_pages_5861
95550 +paging64_walk_addr_5887 paging64_walk_addr 3 5887 NULL
95551 +port_show_regs_5904 port_show_regs 3 5904 NULL
95552 +uhci_debug_read_5911 uhci_debug_read 3 5911 NULL
95553 +qla82xx_pci_mem_read_2M_5912 qla82xx_pci_mem_read_2M 2 5912 NULL
95554 +ttm_bo_kmap_ttm_5922 ttm_bo_kmap_ttm 3 5922 NULL
95555 +lbs_highsnr_read_5931 lbs_highsnr_read 3 5931 NULL
95556 +ps_poll_ps_poll_timeouts_read_5934 ps_poll_ps_poll_timeouts_read 3 5934 NULL
95557 +edac_device_alloc_ctl_info_5941 edac_device_alloc_ctl_info 1 5941 NULL
95558 +tipc_subseq_alloc_5957 tipc_subseq_alloc 1 5957 NULL
95559 +__apu_get_register_5967 __apu_get_register 0 5967 NULL
95560 +ieee80211_if_fmt_rc_rateidx_mask_5ghz_5971 ieee80211_if_fmt_rc_rateidx_mask_5ghz 3 5971 NULL
95561 +native_pte_val_5978 native_pte_val 0 5978 NULL
95562 +ntfs_rl_append_6037 ntfs_rl_append 2-4 6037 NULL
95563 +da9052_request_irq_6058 da9052_request_irq 2 6058 NULL
95564 +sctp_setsockopt_connectx_6073 sctp_setsockopt_connectx 3 6073 NULL
95565 +rts51x_ms_rw_multi_sector_6076 rts51x_ms_rw_multi_sector 3-4 6076 NULL
95566 +ipmi_addr_length_6110 ipmi_addr_length 0 6110 NULL
95567 +dfs_global_file_write_6112 dfs_global_file_write 3 6112 NULL
95568 +matrix_keypad_build_keymap_6129 matrix_keypad_build_keymap 3 6129 NULL
95569 +nouveau_parent_create__6131 nouveau_parent_create_ 7 6131 NULL
95570 +ivtv_copy_buf_to_user_6159 ivtv_copy_buf_to_user 4 6159 NULL
95571 +vdma_mem_alloc_6171 vdma_mem_alloc 1 6171 NULL
95572 +wl1251_cmd_template_set_6172 wl1251_cmd_template_set 4 6172 NULL
95573 +paging64_walk_addr_generic_6180 paging64_walk_addr_generic 4 6180 NULL
95574 +qp_host_get_user_memory_6189 qp_host_get_user_memory 1-2 6189 NULL
95575 +mxt_show_instance_6207 mxt_show_instance 2-0 6207 NULL
95576 +v4l2_ctrl_new_std_menu_6221 v4l2_ctrl_new_std_menu 4 6221 NULL
95577 +mqueue_read_file_6228 mqueue_read_file 3 6228 NULL
95578 +f_hidg_read_6238 f_hidg_read 3 6238 NULL
95579 +fbcon_prepare_logo_6246 fbcon_prepare_logo 5 6246 NULL
95580 +pcpu_next_pop_6277 pcpu_next_pop 4 6277 NULL
95581 +tx_tx_start_null_frame_read_6281 tx_tx_start_null_frame_read 3 6281 NULL
95582 +snd_hda_override_conn_list_6282 snd_hda_override_conn_list 3 6282 NULL nohasharray
95583 +xenbus_file_write_6282 xenbus_file_write 3 6282 &snd_hda_override_conn_list_6282
95584 +posix_acl_fix_xattr_to_user_6283 posix_acl_fix_xattr_to_user 2 6283 NULL
95585 +paging64_gva_to_gpa_nested_6287 paging64_gva_to_gpa_nested 2 6287 NULL
95586 +nf_nat_ipv6_manip_pkt_6289 nf_nat_ipv6_manip_pkt 2 6289 NULL
95587 +nf_nat_sack_adjust_6297 nf_nat_sack_adjust 2 6297 NULL
95588 +mid_get_vbt_data_r10_6308 mid_get_vbt_data_r10 2 6308 NULL
95589 +ucs2_strnlen_6342 ucs2_strnlen 0 6342 NULL
95590 +_proc_do_string_6376 _proc_do_string 2 6376 NULL
95591 +osd_req_read_sg_kern_6378 osd_req_read_sg_kern 5 6378 NULL
95592 +posix_acl_fix_xattr_userns_6420 posix_acl_fix_xattr_userns 4 6420 NULL
95593 +ipr_change_queue_depth_6431 ipr_change_queue_depth 2 6431 NULL
95594 +__alloc_bootmem_node_nopanic_6432 __alloc_bootmem_node_nopanic 2-3 6432 NULL
95595 +paging32_gva_to_gpa_nested_6442 paging32_gva_to_gpa_nested 2 6442 NULL
95596 +mlx4_ib_reg_user_mr_6471 mlx4_ib_reg_user_mr 2-3 6471 NULL nohasharray
95597 +ext4_compat_ioctl_6471 ext4_compat_ioctl 3 6471 &mlx4_ib_reg_user_mr_6471
95598 +ieee80211_if_fmt_dot11MeshMaxRetries_6476 ieee80211_if_fmt_dot11MeshMaxRetries 3 6476 NULL
95599 +qp_memcpy_from_queue_6479 qp_memcpy_from_queue 4-5 6479 NULL
95600 +cipso_v4_map_lvl_hton_6490 cipso_v4_map_lvl_hton 0 6490 NULL
95601 +dbg_intr_buf_6501 dbg_intr_buf 2 6501 NULL
95602 +mei_read_6507 mei_read 3 6507 NULL
95603 +read_file_disable_ani_6536 read_file_disable_ani 3 6536 NULL
95604 +rndis_set_oid_6547 rndis_set_oid 4 6547 NULL
95605 +wdm_read_6549 wdm_read 3 6549 NULL
95606 +fb_alloc_cmap_6554 fb_alloc_cmap 2 6554 NULL
95607 +snmp_mib_init_6604 snmp_mib_init 2-3 6604 NULL
95608 +ecryptfs_filldir_6622 ecryptfs_filldir 3 6622 NULL
95609 +virtscsi_alloc_tgt_6643 virtscsi_alloc_tgt 2 6643 NULL
95610 +aac_srcv_ioremap_6659 aac_srcv_ioremap 2 6659 NULL
95611 +process_rcvd_data_6679 process_rcvd_data 3 6679 NULL
95612 +ql_process_mac_rx_skb_6689 ql_process_mac_rx_skb 4 6689 NULL
95613 +btrfs_lookup_csums_range_6696 btrfs_lookup_csums_range 2 6696 NULL
95614 +ps_pspoll_max_apturn_read_6699 ps_pspoll_max_apturn_read 3 6699 NULL
95615 +bnad_debugfs_write_regrd_6706 bnad_debugfs_write_regrd 3 6706 NULL
95616 +mpeg_read_6708 mpeg_read 3 6708 NULL
95617 +set_orig_insn_6712 set_orig_insn 3 6712 NULL
95618 +video_proc_write_6724 video_proc_write 3 6724 NULL
95619 +posix_acl_xattr_count_6725 posix_acl_xattr_count 0-1 6725 NULL
95620 +rds_rdma_pages_6735 rds_rdma_pages 0 6735 NULL
95621 +sfi_check_table_6772 sfi_check_table 1 6772 NULL
95622 +iwl_dbgfs_channels_read_6784 iwl_dbgfs_channels_read 3 6784 NULL
95623 +ieee80211_if_read_6785 ieee80211_if_read 3 6785 NULL
95624 +hdlcdrv_register_6792 hdlcdrv_register 2 6792 NULL
95625 +tx_tx_done_data_read_6799 tx_tx_done_data_read 3 6799 NULL
95626 +make_8259A_irq_6828 make_8259A_irq 1 6828 NULL
95627 +calc_pages_for_6838 calc_pages_for 0-1-2 6838 NULL
95628 +mon_bin_read_6841 mon_bin_read 3 6841 NULL
95629 +snd_cs4281_BA0_read_6847 snd_cs4281_BA0_read 5 6847 NULL
95630 +ieee80211_if_fmt_path_refresh_time_6888 ieee80211_if_fmt_path_refresh_time 3 6888 NULL nohasharray
95631 +raw_seticmpfilter_6888 raw_seticmpfilter 3 6888 &ieee80211_if_fmt_path_refresh_time_6888
95632 +dlmfs_file_write_6892 dlmfs_file_write 3 6892 NULL
95633 +spi_show_regs_6911 spi_show_regs 3 6911 NULL nohasharray
95634 +proc_sessionid_read_6911 proc_sessionid_read 3 6911 &spi_show_regs_6911 nohasharray
95635 +acm_alloc_minor_6911 acm_alloc_minor 0 6911 &proc_sessionid_read_6911
95636 +__kfifo_dma_in_finish_r_6913 __kfifo_dma_in_finish_r 2-3 6913 NULL
95637 +do_msgrcv_6921 do_msgrcv 3 6921 NULL
95638 +cache_do_downcall_6926 cache_do_downcall 3 6926 NULL
95639 +qsfp_cks_6945 qsfp_cks 0-2 6945 NULL
95640 +pch_uart_hal_read_6961 pch_uart_hal_read 0 6961 NULL
95641 +videobuf_dma_init_kernel_6963 videobuf_dma_init_kernel 3 6963 NULL
95642 +rsa_extract_mpi_6973 rsa_extract_mpi 5 6973 NULL
95643 +crypto_authenc_esn_setkey_6985 crypto_authenc_esn_setkey 3 6985 NULL
95644 +request_key_async_6990 request_key_async 4 6990 NULL
95645 +r871x_set_wpa_ie_7000 r871x_set_wpa_ie 3 7000 NULL
95646 +cipso_v4_gentag_enum_7006 cipso_v4_gentag_enum 0 7006 NULL
95647 +tracing_cpumask_read_7010 tracing_cpumask_read 3 7010 NULL
95648 +wimax_msg_7030 wimax_msg 4 7030 NULL
95649 +ipath_get_base_info_7043 ipath_get_base_info 3 7043 NULL
95650 +snd_pcm_oss_bytes_7051 snd_pcm_oss_bytes 2 7051 NULL
95651 +event_enable_read_7074 event_enable_read 3 7074 NULL
95652 +beacon_interval_read_7091 beacon_interval_read 3 7091 NULL
95653 +lp_compat_ioctl_7098 lp_compat_ioctl 3 7098 NULL
95654 +pipeline_enc_rx_stat_fifo_int_read_7107 pipeline_enc_rx_stat_fifo_int_read 3 7107 NULL
95655 +check_header_7108 check_header 0 7108 NULL
95656 +qlcnic_enable_msix_7144 qlcnic_enable_msix 2 7144 NULL
95657 +__alloc_objio_seg_7203 __alloc_objio_seg 1 7203 NULL
95658 +sys32_ipc_7238 sys32_ipc 3-5-6 7238 NULL
95659 +get_param_h_7247 get_param_h 0 7247 NULL
95660 +af_alg_make_sg_7254 af_alg_make_sg 3 7254 NULL
95661 +vm_mmap_pgoff_7259 vm_mmap_pgoff 0 7259 NULL
95662 +dma_ops_alloc_addresses_7272 dma_ops_alloc_addresses 3-4-5 7272 NULL
95663 +rx_rate_rx_frames_per_rates_read_7282 rx_rate_rx_frames_per_rates_read 3 7282 NULL
95664 +wb_remove_mapping_7307 wb_remove_mapping 2 7307 NULL
95665 +mgmt_control_7349 mgmt_control 3 7349 NULL
95666 +ext3_free_blocks_7362 ext3_free_blocks 3-4 7362 NULL
95667 +ieee80211_if_read_dot11MeshHWMPactivePathTimeout_7368 ieee80211_if_read_dot11MeshHWMPactivePathTimeout 3 7368 NULL
95668 +hweight_long_7388 hweight_long 0-1 7388 NULL
95669 +vhost_scsi_compat_ioctl_7393 vhost_scsi_compat_ioctl 3 7393 NULL
95670 +sl_change_mtu_7396 sl_change_mtu 2 7396 NULL
95671 +readb_7401 readb 0 7401 NULL
95672 +drm_property_create_blob_7414 drm_property_create_blob 2 7414 NULL
95673 +ip_options_get_alloc_7448 ip_options_get_alloc 1 7448 NULL
95674 +numa_emulation_7466 numa_emulation 2 7466 NULL
95675 +__mutex_lock_common_7469 __mutex_lock_common 0 7469 NULL
95676 +garp_request_join_7471 garp_request_join 4 7471 NULL
95677 +compat_sys_msgrcv_7482 compat_sys_msgrcv 2 7482 NULL
95678 +snd_pcm_lib_read1_7491 snd_pcm_lib_read1 0-3 7491 NULL
95679 +sdhci_alloc_host_7509 sdhci_alloc_host 2 7509 NULL nohasharray
95680 +ahash_instance_headroom_7509 ahash_instance_headroom 0 7509 &sdhci_alloc_host_7509
95681 +array_zalloc_7519 array_zalloc 1-2 7519 NULL
95682 +goal_in_my_reservation_7553 goal_in_my_reservation 3 7553 NULL
95683 +smk_read_mapped_7562 smk_read_mapped 3 7562 NULL
95684 +ext3_try_to_allocate_7590 ext3_try_to_allocate 5-3 7590 NULL
95685 +groups_alloc_7614 groups_alloc 1 7614 NULL
95686 +sg_virt_7616 sg_virt 0 7616 NULL
95687 +skb_copy_expand_7685 skb_copy_expand 2-3 7685 NULL nohasharray
95688 +acpi_ex_allocate_name_string_7685 acpi_ex_allocate_name_string 2-1 7685 &skb_copy_expand_7685
95689 +acpi_ns_get_pathname_length_7699 acpi_ns_get_pathname_length 0 7699 NULL
95690 +dev_write_7708 dev_write 3 7708 NULL
95691 +brcmf_sdcard_send_buf_7713 brcmf_sdcard_send_buf 6 7713 NULL
95692 +set_bypass_pwup_pfs_7742 set_bypass_pwup_pfs 3 7742 NULL
95693 +vxge_device_register_7752 vxge_device_register 4 7752 NULL
95694 +osdv2_attr_list_elem_size_7763 osdv2_attr_list_elem_size 0-1 7763 NULL
95695 +ubi_io_read_vid_hdr_7766 ubi_io_read_vid_hdr 0 7766 NULL
95696 +ioread32be_7773 ioread32be 0 7773 NULL
95697 +alloc_candev_7776 alloc_candev 1-2 7776 NULL
95698 +dfs_global_file_read_7787 dfs_global_file_read 3 7787 NULL
95699 +bnx2_nvram_write_7790 bnx2_nvram_write 4-2 7790 NULL
95700 +diva_os_copy_from_user_7792 diva_os_copy_from_user 4 7792 NULL
95701 +ubifs_leb_read_7828 ubifs_leb_read 0 7828 NULL
95702 +dvb_dmxdev_read_sec_7892 dvb_dmxdev_read_sec 4 7892 NULL
95703 +xfs_trans_get_efi_7898 xfs_trans_get_efi 2 7898 NULL
95704 +gfs2_tune_get_i_7903 gfs2_tune_get_i 0 7903 NULL
95705 +ext3_group_extend_7911 ext3_group_extend 3 7911 NULL
95706 +libfc_host_alloc_7917 libfc_host_alloc 2 7917 NULL
95707 +f_hidg_write_7932 f_hidg_write 3 7932 NULL
95708 +io_apic_setup_irq_pin_once_7934 io_apic_setup_irq_pin_once 1 7934 NULL
95709 +integrity_digsig_verify_7956 integrity_digsig_verify 3 7956 NULL
95710 +smk_write_load_self_7958 smk_write_load_self 3 7958 NULL
95711 +sys_mbind_7990 sys_mbind 5 7990 NULL
95712 +tt3650_ci_msg_locked_8013 tt3650_ci_msg_locked 4 8013 NULL
95713 +vcs_read_8017 vcs_read 3 8017 NULL
95714 +normalize_up_8037 normalize_up 0-1-2 8037 NULL
95715 +vhost_add_used_and_signal_n_8038 vhost_add_used_and_signal_n 4 8038 NULL
95716 +ms_read_multiple_pages_8052 ms_read_multiple_pages 5-4 8052 NULL
95717 +dgrp_mon_read_8065 dgrp_mon_read 3 8065 NULL
95718 +leb_read_lock_8070 leb_read_lock 0 8070 NULL
95719 +alloc_targets_8074 alloc_targets 2 8074 NULL nohasharray
95720 +qla4xxx_post_ping_evt_work_8074 qla4xxx_post_ping_evt_work 4 8074 &alloc_targets_8074
95721 +venus_lookup_8121 venus_lookup 4 8121 NULL
95722 +ieee80211_if_fmt_num_buffered_multicast_8127 ieee80211_if_fmt_num_buffered_multicast 3 8127 NULL
95723 +dma_map_area_8178 dma_map_area 5-2-3 8178 NULL
95724 +__sk_mem_schedule_8185 __sk_mem_schedule 2 8185 NULL
95725 +ieee80211_if_fmt_dot11MeshHoldingTimeout_8187 ieee80211_if_fmt_dot11MeshHoldingTimeout 3 8187 NULL
95726 +recent_mt_proc_write_8206 recent_mt_proc_write 3 8206 NULL
95727 +rt2x00debug_write_bbp_8212 rt2x00debug_write_bbp 3 8212 NULL
95728 +ad7879_spi_multi_read_8218 ad7879_spi_multi_read 3 8218 NULL
95729 +play_iframe_8219 play_iframe 3 8219 NULL
95730 +create_log_8225 create_log 2 8225 NULL nohasharray
95731 +kvm_mmu_page_set_gfn_8225 kvm_mmu_page_set_gfn 2 8225 &create_log_8225
95732 +sctp_ssnmap_size_8228 sctp_ssnmap_size 0-1-2 8228 NULL
95733 +bnx2x_iov_get_max_queue_count_8235 bnx2x_iov_get_max_queue_count 0 8235 NULL
95734 +check_xattr_ref_inode_8244 check_xattr_ref_inode 0 8244 NULL
95735 +add_rx_skb_8257 add_rx_skb 3 8257 NULL
95736 +t3_init_l2t_8261 t3_init_l2t 1 8261 NULL
95737 +init_cdev_8274 init_cdev 1 8274 NULL
95738 +rproc_recovery_write_8281 rproc_recovery_write 3 8281 NULL
95739 +qib_decode_7220_err_8315 qib_decode_7220_err 3 8315 NULL
95740 +construct_key_and_link_8321 construct_key_and_link 4 8321 NULL
95741 +ipwireless_send_packet_8328 ipwireless_send_packet 4 8328 NULL
95742 +tracing_entries_read_8345 tracing_entries_read 3 8345 NULL
95743 +ieee80211_if_fmt_ht_opmode_8347 ieee80211_if_fmt_ht_opmode 3 8347 NULL
95744 +ping_getfrag_8360 ping_getfrag 4-3 8360 NULL
95745 +uvc_v4l2_compat_ioctl32_8375 uvc_v4l2_compat_ioctl32 3 8375 NULL
95746 +xdi_copy_from_user_8395 xdi_copy_from_user 4 8395 NULL
95747 +zd_rf_scnprint_id_8406 zd_rf_scnprint_id 0-3 8406 NULL
95748 +uvc_v4l2_ioctl_8411 uvc_v4l2_ioctl 2 8411 NULL
95749 +pca953x_gpio_to_irq_8424 pca953x_gpio_to_irq 2 8424 NULL
95750 +snd_usb_ctl_msg_8436 snd_usb_ctl_msg 8 8436 NULL
95751 +irq_create_mapping_8437 irq_create_mapping 2 8437 NULL
95752 +afs_cell_lookup_8482 afs_cell_lookup 2 8482 NULL
95753 +batadv_tt_len_8502 batadv_tt_len 0-1 8502 NULL
95754 +dev_config_8506 dev_config 3 8506 NULL
95755 +ACL_to_cifs_posix_8509 ACL_to_cifs_posix 3 8509 NULL
95756 +opticon_process_data_packet_8524 opticon_process_data_packet 3 8524 NULL
95757 +pnp_resource_len_8532 pnp_resource_len 0 8532 NULL
95758 +alloc_pg_vec_8533 alloc_pg_vec 2 8533 NULL
95759 +ocfs2_read_virt_blocks_8538 ocfs2_read_virt_blocks 2-3 8538 NULL
95760 +profile_remove_8556 profile_remove 3 8556 NULL
95761 +cache_slow_downcall_8570 cache_slow_downcall 2 8570 NULL
95762 +mga_ioremap_8571 mga_ioremap 1-2 8571 NULL
95763 +isr_dma0_done_read_8574 isr_dma0_done_read 3 8574 NULL
95764 +tower_write_8580 tower_write 3 8580 NULL
95765 +rtllib_MFIE_rate_len_8606 rtllib_MFIE_rate_len 0 8606 NULL
95766 +shash_setkey_unaligned_8620 shash_setkey_unaligned 3 8620 NULL
95767 +it821x_firmware_command_8628 it821x_firmware_command 3 8628 NULL
95768 +scsi_dma_map_8632 scsi_dma_map 0 8632 NULL
95769 +fuse_send_write_pages_8636 fuse_send_write_pages 0 8636 NULL
95770 +generic_acl_set_8658 generic_acl_set 4 8658 NULL
95771 +dio_bio_alloc_8677 dio_bio_alloc 5 8677 NULL
95772 +lbs_bcnmiss_read_8678 lbs_bcnmiss_read 3 8678 NULL
95773 +tc3589x_gpio_irq_unmap_8680 tc3589x_gpio_irq_unmap 2 8680 NULL
95774 +rproc_trace_read_8686 rproc_trace_read 3 8686 NULL
95775 +skb_frag_size_8695 skb_frag_size 0 8695 NULL
95776 +arcfb_write_8702 arcfb_write 3 8702 NULL
95777 +i_size_read_8703 i_size_read 0 8703 NULL nohasharray
95778 +init_header_8703 init_header 0 8703 &i_size_read_8703
95779 +ctrl_out_8712 ctrl_out 3-5 8712 NULL
95780 +jffs2_acl_count_8729 jffs2_acl_count 0-1 8729 NULL
95781 +f_dupfd_8730 f_dupfd 1 8730 NULL
95782 +__create_irqs_8733 __create_irqs 2-1 8733 NULL
95783 +pca953x_gpio_irq_map_8737 pca953x_gpio_irq_map 2 8737 NULL
95784 +tx_tx_exch_expiry_read_8749 tx_tx_exch_expiry_read 3 8749 NULL
95785 +joydev_compat_ioctl_8765 joydev_compat_ioctl 2 8765 NULL
95786 +sys_prctl_8766 sys_prctl 4 8766 NULL
95787 +x32_arch_ptrace_8767 x32_arch_ptrace 3-4 8767 NULL
95788 +paging32_prefetch_gpte_8783 paging32_prefetch_gpte 4 8783 NULL
95789 +ext4_try_to_write_inline_data_8785 ext4_try_to_write_inline_data 3-4 8785 NULL
95790 +__bitmap_weight_8796 __bitmap_weight 0-2 8796 NULL
95791 +cpuset_common_file_read_8800 cpuset_common_file_read 5 8800 NULL
95792 +metronomefb_write_8823 metronomefb_write 3 8823 NULL
95793 +icmpv6_manip_pkt_8833 icmpv6_manip_pkt 4 8833 NULL nohasharray
95794 +get_queue_depth_8833 get_queue_depth 0 8833 &icmpv6_manip_pkt_8833
95795 +dvb_ringbuffer_pkt_next_8834 dvb_ringbuffer_pkt_next 0-2 8834 NULL
95796 +usb_ep_queue_8839 usb_ep_queue 0 8839 NULL
95797 +clear_bitset_8840 clear_bitset 2 8840 NULL
95798 +debug_debug1_read_8856 debug_debug1_read 3 8856 NULL
95799 +wa_nep_queue_8858 wa_nep_queue 2 8858 NULL
95800 +compressed_bio_size_8887 compressed_bio_size 0-2 8887 NULL
95801 +tracing_max_lat_read_8890 tracing_max_lat_read 3 8890 NULL
95802 +sdio_max_byte_size_8907 sdio_max_byte_size 0 8907 NULL
95803 +layout_commit_8926 layout_commit 3 8926 NULL
95804 +adjust_priv_size_8935 adjust_priv_size 0-1 8935 NULL
95805 +driver_stats_read_8944 driver_stats_read 3 8944 NULL
95806 +read_file_tgt_stats_8959 read_file_tgt_stats 3 8959 NULL
95807 +seq_bitmap_list_8963 seq_bitmap_list 3 8963 NULL
95808 +usb_allocate_stream_buffers_8964 usb_allocate_stream_buffers 3 8964 NULL
95809 +qib_qsfp_dump_8966 qib_qsfp_dump 0-3 8966 NULL
95810 +venus_mkdir_8967 venus_mkdir 4 8967 NULL
95811 +vol_cdev_read_8968 vol_cdev_read 3 8968 NULL nohasharray
95812 +seq_open_net_8968 seq_open_net 4 8968 &vol_cdev_read_8968
95813 +bio_integrity_get_tag_8974 bio_integrity_get_tag 3 8974 NULL
95814 +snd_emu10k1_ptr_read_9026 snd_emu10k1_ptr_read 0-2 9026 NULL
95815 +__pskb_copy_9038 __pskb_copy 2 9038 NULL
95816 +nla_put_9042 nla_put 3 9042 NULL
95817 +snd_emu10k1_synth_copy_from_user_9061 snd_emu10k1_synth_copy_from_user 3-5 9061 NULL
95818 +snd_gus_dram_peek_9062 snd_gus_dram_peek 4 9062 NULL
95819 +fib_info_hash_alloc_9075 fib_info_hash_alloc 1 9075 NULL
95820 +string_9080 string 0 9080 NULL
95821 +create_queues_9088 create_queues 2-3 9088 NULL
95822 +ftdi_prepare_write_buffer_9093 ftdi_prepare_write_buffer 3 9093 NULL
95823 +caif_stream_sendmsg_9110 caif_stream_sendmsg 4 9110 NULL nohasharray
95824 +gfn_to_rmap_9110 gfn_to_rmap 2-3 9110 &caif_stream_sendmsg_9110
95825 +pmcraid_change_queue_depth_9116 pmcraid_change_queue_depth 2 9116 NULL
95826 +mq_remove_mapping_9124 mq_remove_mapping 2 9124 NULL
95827 +mlx4_alloc_resize_umem_9132 mlx4_alloc_resize_umem 3 9132 NULL
95828 +ext4_list_backups_9138 ext4_list_backups 0 9138 NULL
95829 +dbg_command_buf_9165 dbg_command_buf 2 9165 NULL
95830 +isr_irqs_read_9181 isr_irqs_read 3 9181 NULL
95831 +count_leading_zeros_9183 count_leading_zeros 0 9183 NULL
95832 +alloc_group_attrs_9194 alloc_group_attrs 2 9194 NULL nohasharray
95833 +altera_swap_ir_9194 altera_swap_ir 2 9194 &alloc_group_attrs_9194
95834 +gx1_gx_base_9198 gx1_gx_base 0 9198 NULL
95835 +snd_m3_get_pointer_9206 snd_m3_get_pointer 0 9206 NULL
95836 +get_pfn_9207 get_pfn 1 9207 NULL
95837 +tx_tx_prepared_descs_read_9221 tx_tx_prepared_descs_read 3 9221 NULL
95838 +sctp_getsockopt_delayed_ack_9232 sctp_getsockopt_delayed_ack 2 9232 NULL
95839 +ocfs2_clear_ext_refcount_9256 ocfs2_clear_ext_refcount 4 9256 NULL
95840 +tcf_csum_ipv4_icmp_9258 tcf_csum_ipv4_icmp 3 9258 NULL
95841 +sparse_early_usemaps_alloc_node_9269 sparse_early_usemaps_alloc_node 4 9269 NULL
95842 +hdpvr_read_9273 hdpvr_read 3 9273 NULL
95843 +flakey_status_9274 flakey_status 5 9274 NULL
95844 +qla82xx_pci_set_window_9303 qla82xx_pci_set_window 0-2 9303 NULL
95845 +iwl_dbgfs_stations_read_9309 iwl_dbgfs_stations_read 3 9309 NULL
95846 +ceph_sync_setxattr_9310 ceph_sync_setxattr 4 9310 NULL
95847 +memblock_find_in_range_node_9328 memblock_find_in_range_node 0-3-4 9328 NULL
95848 +ieee80211_if_fmt_txpower_9334 ieee80211_if_fmt_txpower 3 9334 NULL
95849 +ocfs2_orphan_for_truncate_9342 ocfs2_orphan_for_truncate 4 9342 NULL
95850 +read_9397 read 3 9397 NULL
95851 +nf_nat_sip_expect_9418 nf_nat_sip_expect 8 9418 NULL
95852 +bm_realloc_pages_9431 bm_realloc_pages 2 9431 NULL
95853 +ffs_ep0_write_9438 ffs_ep0_write 3 9438 NULL
95854 +kmalloc_array_9444 kmalloc_array 1-2 9444 NULL
95855 +ieee80211_if_fmt_fwded_unicast_9454 ieee80211_if_fmt_fwded_unicast 3 9454 NULL
95856 +mcs_unwrap_mir_9455 mcs_unwrap_mir 3 9455 NULL
95857 +ext3_xattr_set_acl_9467 ext3_xattr_set_acl 4 9467 NULL
95858 +agp_generic_alloc_user_9470 agp_generic_alloc_user 1 9470 NULL
95859 +__alloc_preds_9492 __alloc_preds 2 9492 NULL nohasharray
95860 +crypt_status_9492 crypt_status 5 9492 &__alloc_preds_9492
95861 +lp_write_9511 lp_write 3 9511 NULL
95862 +xen_remap_exchanged_ptes_9513 xen_remap_exchanged_ptes 1 9513 NULL
95863 +scsi_tgt_kspace_exec_9522 scsi_tgt_kspace_exec 8 9522 NULL
95864 +read_file_dma_9530 read_file_dma 3 9530 NULL
95865 +ext3_alloc_branch_9534 ext3_alloc_branch 5 9534 NULL
95866 +audit_log_n_untrustedstring_9548 audit_log_n_untrustedstring 3 9548 NULL
95867 +fw_node_create_9559 fw_node_create 2 9559 NULL
95868 +ipath_get_user_pages_9561 ipath_get_user_pages 1-2 9561 NULL
95869 +kobj_map_9566 kobj_map 2-3 9566 NULL
95870 +f2fs_read_data_pages_9574 f2fs_read_data_pages 4 9574 NULL
95871 +biovec_create_pools_9575 biovec_create_pools 2 9575 NULL
95872 +ieee80211_tdls_mgmt_9581 ieee80211_tdls_mgmt 8 9581 NULL
95873 +do_sync_9604 do_sync 1 9604 NULL
95874 +snd_emu10k1_fx8010_read_9605 snd_emu10k1_fx8010_read 5-6 9605 NULL
95875 +saa7164_buffer_alloc_user_9627 saa7164_buffer_alloc_user 2 9627 NULL
95876 +ceph_copy_user_to_page_vector_9635 ceph_copy_user_to_page_vector 4-3 9635 NULL
95877 +compat_sys_keyctl_9639 compat_sys_keyctl 4-2-3 9639 NULL
95878 +ocfs2_xattr_get_rec_9652 ocfs2_xattr_get_rec 0 9652 NULL
95879 +uvc_alloc_buffers_9656 uvc_alloc_buffers 2-3 9656 NULL
95880 +queue_received_packet_9657 queue_received_packet 5 9657 NULL
95881 +snd_opl4_mem_proc_write_9670 snd_opl4_mem_proc_write 5 9670 NULL
95882 +ks8842_read16_9676 ks8842_read16 0 9676 NULL nohasharray
95883 +dns_query_9676 dns_query 3 9676 &ks8842_read16_9676
95884 +qib_7322_handle_hwerrors_9678 qib_7322_handle_hwerrors 3 9678 NULL
95885 +__erst_read_from_storage_9690 __erst_read_from_storage 0 9690 NULL
95886 +is_hole_9694 is_hole 2 9694 NULL nohasharray
95887 +x25_asy_compat_ioctl_9694 x25_asy_compat_ioctl 4 9694 &is_hole_9694
95888 +fnb_9703 fnb 2-3 9703 NULL
95889 +fuse_iter_npages_9705 fuse_iter_npages 0 9705 NULL nohasharray
95890 +ieee80211_if_read_aid_9705 ieee80211_if_read_aid 3 9705 &fuse_iter_npages_9705
95891 +ieee80211_if_fmt_num_mcast_sta_9738 ieee80211_if_fmt_num_mcast_sta 3 9738 NULL
95892 +ddb_input_read_9743 ddb_input_read 3 9743 NULL
95893 +sta_last_ack_signal_read_9751 sta_last_ack_signal_read 3 9751 NULL
95894 +btrfs_super_root_9763 btrfs_super_root 0 9763 NULL
95895 +__alloc_percpu_9764 __alloc_percpu 1-2 9764 NULL
95896 +__blk_queue_init_tags_9778 __blk_queue_init_tags 2 9778 NULL
95897 +snd_mem_proc_write_9786 snd_mem_proc_write 3 9786 NULL
95898 +ttm_bo_fbdev_io_9805 ttm_bo_fbdev_io 4 9805 NULL
95899 +ieee80211_if_read_state_9813 ieee80211_if_read_state 3 9813 NULL
95900 +pnp_mem_start_9817 pnp_mem_start 0 9817 NULL
95901 +kernel_physical_mapping_init_9818 kernel_physical_mapping_init 0-2-1 9818 NULL
95902 +dvb_dvr_set_buffer_size_9840 dvb_dvr_set_buffer_size 2 9840 NULL
95903 +cfg80211_send_deauth_9862 cfg80211_send_deauth 3 9862 NULL
95904 +pmcraid_alloc_sglist_9864 pmcraid_alloc_sglist 1 9864 NULL
95905 +btrfs_free_reserved_extent_9867 btrfs_free_reserved_extent 2 9867 NULL
95906 +f1x_translate_sysaddr_to_cs_9868 f1x_translate_sysaddr_to_cs 2 9868 NULL
95907 +mlx4_bitmap_alloc_range_9876 mlx4_bitmap_alloc_range 2-3 9876 NULL
95908 +wil_read_file_ioblob_9878 wil_read_file_ioblob 3 9878 NULL
95909 +bm_register_write_9893 bm_register_write 3 9893 NULL nohasharray
95910 +snd_midi_event_new_9893 snd_midi_event_new 1 9893 &bm_register_write_9893
95911 +snd_gf1_pcm_playback_copy_9895 snd_gf1_pcm_playback_copy 3-5 9895 NULL
95912 +nonpaging_page_fault_9908 nonpaging_page_fault 2 9908 NULL
95913 +gen6_get_total_gtt_size_9913 gen6_get_total_gtt_size 0-1 9913 NULL
95914 +pstore_ftrace_knob_read_9947 pstore_ftrace_knob_read 3 9947 NULL
95915 +read_file_misc_9948 read_file_misc 3 9948 NULL
95916 +set_rxd_buffer_pointer_9950 set_rxd_buffer_pointer 8 9950 NULL
95917 +ext2_new_blocks_9954 ext2_new_blocks 2 9954 NULL
95918 +csum_partial_copy_fromiovecend_9957 csum_partial_copy_fromiovecend 3-4 9957 NULL
95919 +get_free_serial_index_9969 get_free_serial_index 0 9969 NULL
95920 +btrfs_add_link_9973 btrfs_add_link 5 9973 NULL
95921 +ath6kl_usb_submit_ctrl_out_9978 ath6kl_usb_submit_ctrl_out 6 9978 NULL
95922 +aat2870_dump_reg_10019 aat2870_dump_reg 0 10019 NULL
95923 +handle_request_10024 handle_request 9 10024 NULL
95924 +batadv_orig_hash_add_if_10033 batadv_orig_hash_add_if 2 10033 NULL
95925 +ieee80211_probereq_get_10040 ieee80211_probereq_get 4-5 10040 NULL
95926 +xen_destroy_contiguous_region_10054 xen_destroy_contiguous_region 1 10054 NULL
95927 +ieee80211_set_probe_resp_10077 ieee80211_set_probe_resp 3 10077 NULL
95928 +ufs_bitmap_search_10105 ufs_bitmap_search 0-3 10105 NULL
95929 +get_elem_size_10110 get_elem_size 0-2 10110 NULL nohasharray
95930 +dynamic_ps_timeout_read_10110 dynamic_ps_timeout_read 3 10110 &get_elem_size_10110
95931 +jbd_alloc_10112 jbd_alloc 0 10112 NULL nohasharray
95932 +gfs2_meta_read_10112 gfs2_meta_read 0 10112 &jbd_alloc_10112
95933 +offset_to_bit_10134 offset_to_bit 0 10134 NULL
95934 +aes_decrypt_packets_read_10155 aes_decrypt_packets_read 3 10155 NULL
95935 +rx_out_of_mem_read_10157 rx_out_of_mem_read 3 10157 NULL
95936 +hidg_alloc_ep_req_10159 hidg_alloc_ep_req 2 10159 NULL nohasharray
95937 +ol_chunk_entries_10159 ol_chunk_entries 0 10159 &hidg_alloc_ep_req_10159
95938 +stmpe_irq_unmap_10164 stmpe_irq_unmap 2 10164 NULL
95939 +asd_store_update_bios_10165 asd_store_update_bios 4 10165 NULL
95940 +proc_pid_attr_read_10173 proc_pid_attr_read 3 10173 NULL
95941 +jffs2_user_setxattr_10182 jffs2_user_setxattr 4 10182 NULL
95942 +do_ioctl_trans_10194 do_ioctl_trans 3 10194 NULL
95943 +cciss_proc_write_10259 cciss_proc_write 3 10259 NULL
95944 +snd_rme9652_capture_copy_10287 snd_rme9652_capture_copy 5 10287 NULL
95945 +ubi_leb_change_10289 ubi_leb_change 4 10289 NULL
95946 +read_emulate_10310 read_emulate 2-4 10310 NULL
95947 +read_file_spectral_count_10320 read_file_spectral_count 3 10320 NULL
95948 +ttm_object_device_init_10321 ttm_object_device_init 2 10321 NULL
95949 +ubi_leb_read_10328 ubi_leb_read 0 10328 NULL
95950 +tun_sendmsg_10337 tun_sendmsg 4 10337 NULL
95951 +get_dump_page_10338 get_dump_page 1 10338 NULL
95952 +ufx_alloc_urb_list_10349 ufx_alloc_urb_list 3 10349 NULL
95953 +dbAllocAny_10354 dbAllocAny 0 10354 NULL
95954 +ath6kl_listen_int_read_10355 ath6kl_listen_int_read 3 10355 NULL
95955 +ms_write_multiple_pages_10362 ms_write_multiple_pages 6-5 10362 NULL
95956 +sta_ht_capa_read_10366 sta_ht_capa_read 3 10366 NULL
95957 +ecryptfs_decode_and_decrypt_filename_10379 ecryptfs_decode_and_decrypt_filename 5 10379 NULL
95958 +do_compat_pselect_10398 do_compat_pselect 1 10398 NULL
95959 +fwtty_rx_10434 fwtty_rx 3 10434 NULL
95960 +event_phy_transmit_error_read_10471 event_phy_transmit_error_read 3 10471 NULL
95961 +ca91cx42_alloc_resource_10502 ca91cx42_alloc_resource 2 10502 NULL
95962 +qib_alloc_fast_reg_page_list_10507 qib_alloc_fast_reg_page_list 2 10507 NULL
95963 +sel_write_disable_10511 sel_write_disable 3 10511 NULL
95964 +osd_req_write_sg_kern_10514 osd_req_write_sg_kern 5 10514 NULL
95965 +rds_message_alloc_10517 rds_message_alloc 1 10517 NULL
95966 +ocfs2_add_refcounted_extent_10526 ocfs2_add_refcounted_extent 6 10526 NULL
95967 +get_vm_area_caller_10527 get_vm_area_caller 1 10527 NULL
95968 +snd_pcm_lib_read_10536 snd_pcm_lib_read 0-3 10536 NULL
95969 +ieee80211_send_probe_req_10539 ieee80211_send_probe_req 4-6 10539 NULL
95970 +ext4_write_begin_10576 ext4_write_begin 3-4 10576 NULL
95971 +scrub_remap_extent_10588 scrub_remap_extent 2 10588 NULL
95972 +otp_read_10594 otp_read 2-4-5 10594 NULL
95973 +supply_map_read_file_10608 supply_map_read_file 3 10608 NULL
95974 +ima_show_htable_violations_10619 ima_show_htable_violations 3 10619 NULL
95975 +alloc_coherent_10632 alloc_coherent 2 10632 NULL
95976 +nfs_idmap_lookup_id_10660 nfs_idmap_lookup_id 2 10660 NULL
95977 +parport_write_10669 parport_write 0 10669 NULL
95978 +inl_10708 inl 0 10708 NULL nohasharray
95979 +selinux_inode_setxattr_10708 selinux_inode_setxattr 4 10708 &inl_10708
95980 +pvr2_ioread_read_10720 pvr2_ioread_read 3 10720 NULL nohasharray
95981 +shash_async_setkey_10720 shash_async_setkey 3 10720 &pvr2_ioread_read_10720
95982 +spi_sync_10731 spi_sync 0 10731 NULL
95983 +sctp_getsockopt_maxseg_10737 sctp_getsockopt_maxseg 2 10737 NULL nohasharray
95984 +apu_get_register_10737 apu_get_register 0 10737 &sctp_getsockopt_maxseg_10737
95985 +compat_sys_msgsnd_10738 compat_sys_msgsnd 2 10738 NULL
95986 +sys_syslog_10746 sys_syslog 3 10746 NULL
95987 +alloc_one_pg_vec_page_10747 alloc_one_pg_vec_page 1 10747 NULL
95988 +vhost_add_used_n_10760 vhost_add_used_n 3 10760 NULL
95989 +kvm_read_guest_atomic_10765 kvm_read_guest_atomic 4-2 10765 NULL
95990 +wb_set_dirty_10778 wb_set_dirty 2 10778 NULL
95991 +__qp_memcpy_to_queue_10779 __qp_memcpy_to_queue 2-4 10779 NULL
95992 +sys_bind_10799 sys_bind 3 10799 NULL
95993 +compat_put_int_10828 compat_put_int 1 10828 NULL
95994 +lbs_sleepparams_read_10840 lbs_sleepparams_read 3 10840 NULL
95995 +ida_get_new_above_10853 ida_get_new_above 2 10853 NULL
95996 +fuse_conn_max_background_read_10855 fuse_conn_max_background_read 3 10855 NULL
95997 +ol_chunk_blocks_10864 ol_chunk_blocks 0 10864 NULL
95998 +snd_pcm_oss_write1_10872 snd_pcm_oss_write1 3 10872 NULL
95999 +mid_get_vbt_data_r0_10876 mid_get_vbt_data_r0 2 10876 NULL
96000 +bl_mark_for_commit_10879 bl_mark_for_commit 2-3 10879 NULL
96001 +get_scq_10897 get_scq 2 10897 NULL
96002 +cgroup_write_string_10900 cgroup_write_string 5 10900 NULL
96003 +tifm_alloc_adapter_10903 tifm_alloc_adapter 1 10903 NULL
96004 +__copy_from_user_10918 __copy_from_user 3 10918 NULL
96005 +da9052_map_irq_10952 da9052_map_irq 2 10952 NULL
96006 +bm_entry_read_10976 bm_entry_read 3 10976 NULL
96007 +i915_min_freq_write_10981 i915_min_freq_write 3 10981 NULL
96008 +sched_autogroup_write_10984 sched_autogroup_write 3 10984 NULL
96009 +__hci_num_ctrl_10985 __hci_num_ctrl 0 10985 NULL
96010 +xfrm_hash_alloc_10997 xfrm_hash_alloc 1 10997 NULL
96011 +rx_filter_accum_arp_pend_requests_read_11003 rx_filter_accum_arp_pend_requests_read 3 11003 NULL
96012 +SetLineNumber_11023 SetLineNumber 0 11023 NULL
96013 +mb_find_next_bit_11037 mb_find_next_bit 2-3-0 11037 NULL
96014 +tda10048_writeregbulk_11050 tda10048_writeregbulk 4 11050 NULL
96015 +tcp_send_mss_11079 tcp_send_mss 0 11079 NULL
96016 +count_argc_11083 count_argc 0 11083 NULL
96017 +kvm_write_guest_cached_11106 kvm_write_guest_cached 4 11106 NULL
96018 +stmpe_gpio_to_irq_11110 stmpe_gpio_to_irq 2 11110 NULL
96019 +tw_change_queue_depth_11116 tw_change_queue_depth 2 11116 NULL
96020 +page_offset_11120 page_offset 0 11120 NULL
96021 +tracing_buffers_read_11124 tracing_buffers_read 3 11124 NULL
96022 +acpi_os_map_memory_11161 acpi_os_map_memory 1-2 11161 NULL
96023 +ioat2_alloc_ring_11172 ioat2_alloc_ring 2 11172 NULL nohasharray
96024 +snd_gf1_pcm_playback_silence_11172 snd_gf1_pcm_playback_silence 3-4 11172 &ioat2_alloc_ring_11172
96025 +__swab16p_11220 __swab16p 0 11220 NULL
96026 +il_dbgfs_rx_queue_read_11221 il_dbgfs_rx_queue_read 3 11221 NULL
96027 +mmap_region_11247 mmap_region 0-2 11247 NULL
96028 +ubifs_write_node_11258 ubifs_write_node 5-3 11258 NULL
96029 +dm_cache_discard_bitset_resize_11262 dm_cache_discard_bitset_resize 3 11262 NULL
96030 +hugetlbfs_read_11268 hugetlbfs_read 3 11268 NULL
96031 +cru_detect_11272 cru_detect 1 11272 NULL
96032 +ext4_xattr_check_names_11314 ext4_xattr_check_names 0 11314 NULL
96033 +tcp_send_rcvq_11316 tcp_send_rcvq 3 11316 NULL
96034 +construct_key_11329 construct_key 3 11329 NULL nohasharray
96035 +__kfifo_out_peek_11329 __kfifo_out_peek 0-3 11329 &construct_key_11329
96036 +next_segment_11330 next_segment 0-2-1 11330 NULL
96037 +persistent_ram_buffer_map_11332 persistent_ram_buffer_map 1-2 11332 NULL
96038 +ext4_get_inline_size_11349 ext4_get_inline_size 0 11349 NULL
96039 +i915_max_freq_write_11350 i915_max_freq_write 3 11350 NULL
96040 +sel_write_create_11353 sel_write_create 3 11353 NULL
96041 +handle_unit_11355 handle_unit 0-1 11355 NULL
96042 +batadv_skb_head_push_11360 batadv_skb_head_push 2 11360 NULL
96043 +drm_vblank_init_11362 drm_vblank_init 2 11362 NULL
96044 +qib_get_base_info_11369 qib_get_base_info 3 11369 NULL
96045 +dev_irnet_write_11398 dev_irnet_write 3 11398 NULL
96046 +___alloc_bootmem_11410 ___alloc_bootmem 1-2 11410 NULL
96047 +str_to_user_11411 str_to_user 2 11411 NULL
96048 +mem_fw_gen_free_mem_blks_read_11413 mem_fw_gen_free_mem_blks_read 3 11413 NULL
96049 +ath6kl_wmi_test_rx_11414 ath6kl_wmi_test_rx 3 11414 NULL
96050 +adis16480_show_firmware_revision_11417 adis16480_show_firmware_revision 3 11417 NULL
96051 +trace_options_read_11419 trace_options_read 3 11419 NULL
96052 +xd_read_multiple_pages_11422 xd_read_multiple_pages 5-4 11422 NULL
96053 +prepare_image_11424 prepare_image 0 11424 NULL
96054 +vring_size_11426 vring_size 0-1-2 11426 NULL
96055 +bttv_read_11432 bttv_read 3 11432 NULL
96056 +create_zero_mask_11453 create_zero_mask 0-1 11453 NULL
96057 +swp_offset_11475 swp_offset 0 11475 NULL
96058 +sca3000_read_first_n_hw_rb_11479 sca3000_read_first_n_hw_rb 2 11479 NULL
96059 +xfs_file_buffered_aio_write_11492 xfs_file_buffered_aio_write 4 11492 NULL
96060 +sd_do_mode_sense_11507 sd_do_mode_sense 5 11507 NULL
96061 +kmem_zalloc_11510 kmem_zalloc 1 11510 NULL
96062 +twl_direction_in_11527 twl_direction_in 2 11527 NULL
96063 +setup_IO_APIC_irq_extra_11537 setup_IO_APIC_irq_extra 1 11537 NULL
96064 +skb_cow_data_11565 skb_cow_data 0-2 11565 NULL
96065 +mlx4_init_cmpt_table_11569 mlx4_init_cmpt_table 3 11569 NULL
96066 +oprofilefs_ulong_to_user_11582 oprofilefs_ulong_to_user 3 11582 NULL
96067 +snd_pcm_action_11589 snd_pcm_action 0 11589 NULL
96068 +fw_device_op_ioctl_11595 fw_device_op_ioctl 2 11595 NULL
96069 +sisusb_send_bridge_packet_11649 sisusb_send_bridge_packet 2 11649 NULL
96070 +nla_total_size_11658 nla_total_size 0-1 11658 NULL
96071 +ide_queue_pc_tail_11673 ide_queue_pc_tail 5 11673 NULL
96072 +btrfs_alloc_delayed_item_11678 btrfs_alloc_delayed_item 1 11678 NULL
96073 +dsp_buffer_alloc_11684 dsp_buffer_alloc 2 11684 NULL
96074 +sctp_setsockopt_hmac_ident_11687 sctp_setsockopt_hmac_ident 3 11687 NULL
96075 +split_11691 split 2 11691 NULL
96076 +snd_ctl_elem_user_tlv_11695 snd_ctl_elem_user_tlv 3 11695 NULL
96077 +blk_rq_cur_bytes_11723 blk_rq_cur_bytes 0 11723 NULL
96078 +tcf_csum_ipv6_icmp_11738 tcf_csum_ipv6_icmp 4 11738 NULL
96079 +nfsd4_get_drc_mem_11748 nfsd4_get_drc_mem 0-1-2 11748 NULL
96080 +dm_bio_prison_create_11749 dm_bio_prison_create 1 11749 NULL
96081 +iwl_dbgfs_qos_read_11753 iwl_dbgfs_qos_read 3 11753 NULL
96082 +ps_pspoll_timeouts_read_11776 ps_pspoll_timeouts_read 3 11776 NULL
96083 +ebt_buf_add_11779 ebt_buf_add 0 11779 NULL
96084 +btrfs_key_blockptr_11786 btrfs_key_blockptr 0 11786 NULL
96085 +pcpu_fc_alloc_11818 pcpu_fc_alloc 2-3 11818 NULL
96086 +zerocopy_sg_from_iovec_11828 zerocopy_sg_from_iovec 3 11828 NULL
96087 +sctp_setsockopt_maxseg_11829 sctp_setsockopt_maxseg 3 11829 NULL
96088 +rts51x_read_status_11830 rts51x_read_status 4 11830 NULL
96089 +unix_stream_connect_11844 unix_stream_connect 3 11844 NULL
96090 +nf_nat_sdp_media_11863 nf_nat_sdp_media 9 11863 NULL
96091 +ecryptfs_copy_filename_11868 ecryptfs_copy_filename 4 11868 NULL
96092 +ieee80211_rx_bss_info_11887 ieee80211_rx_bss_info 3 11887 NULL
96093 +kmalloc_slab_11917 kmalloc_slab 1 11917 NULL
96094 +fs_devrw_entry_11924 fs_devrw_entry 3 11924 NULL
96095 +bitmap_remap_11929 bitmap_remap 5 11929 NULL
96096 +atomic_sub_return_11939 atomic_sub_return 0-1 11939 NULL
96097 +dccp_feat_clone_sp_val_11942 dccp_feat_clone_sp_val 3 11942 NULL
96098 +f1x_swap_interleaved_region_11970 f1x_swap_interleaved_region 0-2 11970 NULL
96099 +atmel_read16_11981 atmel_read16 0 11981 NULL
96100 +read_and_add_raw_conns_11987 read_and_add_raw_conns 0 11987 NULL
96101 +ftdi_elan_total_command_size_12045 ftdi_elan_total_command_size 0 12045 NULL
96102 +ieee80211_if_read_user_power_level_12050 ieee80211_if_read_user_power_level 3 12050 NULL
96103 +il4965_ucode_tx_stats_read_12064 il4965_ucode_tx_stats_read 3 12064 NULL
96104 +ptc_proc_write_12076 ptc_proc_write 3 12076 NULL
96105 +ubifs_recover_log_leb_12079 ubifs_recover_log_leb 3 12079 NULL
96106 +pse36_gfn_delta_12087 pse36_gfn_delta 0-1 12087 NULL
96107 +alloc_bulk_urbs_generic_12127 alloc_bulk_urbs_generic 5 12127 NULL
96108 +set_powered_12129 set_powered 4 12129 NULL
96109 +nfs_writedata_alloc_12133 nfs_writedata_alloc 2 12133 NULL
96110 +ramoops_init_prz_12134 ramoops_init_prz 5 12134 NULL
96111 +xfs_handle_to_dentry_12135 xfs_handle_to_dentry 3 12135 NULL
96112 +batadv_add_packet_12136 batadv_add_packet 3 12136 NULL
96113 +rawv6_seticmpfilter_12137 rawv6_seticmpfilter 5 12137 NULL
96114 +vmw_fifo_reserve_12141 vmw_fifo_reserve 2 12141 NULL
96115 +get_idx_gc_leb_12148 get_idx_gc_leb 0 12148 NULL
96116 +btmrvl_sdio_host_to_card_12152 btmrvl_sdio_host_to_card 3 12152 NULL
96117 +vmbus_open_12154 vmbus_open 2-3 12154 NULL
96118 +wil_rxdesc_phy_length_12165 wil_rxdesc_phy_length 0 12165 NULL
96119 +dma_memcpy_to_iovec_12173 dma_memcpy_to_iovec 5 12173 NULL
96120 +ddp_make_gl_12179 ddp_make_gl 1 12179 NULL
96121 +compat_do_arpt_set_ctl_12184 compat_do_arpt_set_ctl 4 12184 NULL
96122 +ip_generic_getfrag_12187 ip_generic_getfrag 3-4 12187 NULL
96123 +bl_is_sector_init_12199 bl_is_sector_init 2 12199 NULL
96124 +free_initrd_mem_12203 free_initrd_mem 1 12203 NULL
96125 +receive_copy_12216 receive_copy 3 12216 NULL
96126 +snd_pcm_kernel_ioctl_12219 snd_pcm_kernel_ioctl 0 12219 NULL
96127 +fuse_get_req_12221 fuse_get_req 2 12221 NULL nohasharray
96128 +aat2870_reg_read_file_12221 aat2870_reg_read_file 3 12221 &fuse_get_req_12221
96129 +__alloc_bootmem_low_nopanic_12235 __alloc_bootmem_low_nopanic 1-2 12235 NULL
96130 +ib_uverbs_unmarshall_recv_12251 ib_uverbs_unmarshall_recv 5 12251 NULL
96131 +ath_descdma_setup_12257 ath_descdma_setup 5 12257 NULL
96132 +shash_compat_setkey_12267 shash_compat_setkey 3 12267 NULL
96133 +add_sctp_bind_addr_12269 add_sctp_bind_addr 3 12269 NULL
96134 +note_last_dentry_12285 note_last_dentry 3 12285 NULL
96135 +roundup_to_multiple_of_64_12288 roundup_to_multiple_of_64 0-1 12288 NULL nohasharray
96136 +il_dbgfs_nvm_read_12288 il_dbgfs_nvm_read 3 12288 &roundup_to_multiple_of_64_12288
96137 +vxge_get_num_vfs_12302 vxge_get_num_vfs 0 12302 NULL
96138 +tipc_msg_build_12326 tipc_msg_build 4 12326 NULL
96139 +pcbit_writecmd_12332 pcbit_writecmd 2 12332 NULL
96140 +mptctl_ioctl_12355 mptctl_ioctl 2 12355 NULL
96141 +paging32_walk_addr_12359 paging32_walk_addr 3 12359 NULL
96142 +__nf_ct_ext_add_length_12364 __nf_ct_ext_add_length 3 12364 NULL
96143 +xfs_iext_inline_to_direct_12384 xfs_iext_inline_to_direct 2 12384 NULL
96144 +btrfs_file_extent_ram_bytes_12391 btrfs_file_extent_ram_bytes 0 12391 NULL
96145 +ieee80211_if_read_num_mcast_sta_12419 ieee80211_if_read_num_mcast_sta 3 12419 NULL
96146 +skb_do_copy_data_nocache_12465 skb_do_copy_data_nocache 5 12465 NULL
96147 +qla4_82xx_pci_mem_write_direct_12479 qla4_82xx_pci_mem_write_direct 2 12479 NULL
96148 +x25_sendmsg_12487 x25_sendmsg 4 12487 NULL
96149 +rtllib_auth_challenge_12493 rtllib_auth_challenge 3 12493 NULL
96150 +fnic_trace_ctrl_read_12497 fnic_trace_ctrl_read 3 12497 NULL
96151 +nfs_readdir_make_qstr_12509 nfs_readdir_make_qstr 3 12509 NULL
96152 +qib_alloc_fast_reg_mr_12526 qib_alloc_fast_reg_mr 2 12526 NULL
96153 +kvm_setup_async_pf_12555 kvm_setup_async_pf 3 12555 NULL
96154 +ib_umem_get_12557 ib_umem_get 2-3 12557 NULL
96155 +hvc_alloc_12579 hvc_alloc 4 12579 NULL
96156 +snd_pcm_plugin_alloc_12580 snd_pcm_plugin_alloc 2 12580 NULL
96157 +macvtap_compat_ioctl_12587 macvtap_compat_ioctl 3 12587 NULL
96158 +pcpu_extend_area_map_12589 pcpu_extend_area_map 2 12589 NULL
96159 +ipv6_get_l4proto_12600 ipv6_get_l4proto 2 12600 NULL
96160 +vhci_put_user_12604 vhci_put_user 4 12604 NULL
96161 +fc_fcp_frame_alloc_12624 fc_fcp_frame_alloc 2 12624 NULL
96162 +pwr_rcvd_awake_bcns_cnt_read_12632 pwr_rcvd_awake_bcns_cnt_read 3 12632 NULL
96163 +ctrl_cdev_compat_ioctl_12634 ctrl_cdev_compat_ioctl 3 12634 NULL
96164 +pn_sendmsg_12640 pn_sendmsg 4 12640 NULL
96165 +wb_create_12651 wb_create 1 12651 NULL
96166 +ocfs2_read_block_12659 ocfs2_read_block 0 12659 NULL
96167 +sel_read_class_12669 sel_read_class 3 12669 NULL nohasharray
96168 +sparse_mem_maps_populate_node_12669 sparse_mem_maps_populate_node 4 12669 &sel_read_class_12669
96169 +ieee80211_if_read_num_buffered_multicast_12716 ieee80211_if_read_num_buffered_multicast 3 12716 NULL
96170 +ivtv_write_12721 ivtv_write 3 12721 NULL
96171 +key_rx_spec_read_12736 key_rx_spec_read 3 12736 NULL
96172 +__videobuf_alloc_cached_12740 __videobuf_alloc_cached 1 12740 NULL
96173 +ieee80211_if_read_dot11MeshMaxRetries_12756 ieee80211_if_read_dot11MeshMaxRetries 3 12756 NULL
96174 +listxattr_12769 listxattr 3 12769 NULL
96175 +sctp_ssnmap_init_12772 sctp_ssnmap_init 2-3 12772 NULL
96176 +ieee80211_rx_mgmt_beacon_12780 ieee80211_rx_mgmt_beacon 3 12780 NULL
96177 +platform_create_bundle_12785 platform_create_bundle 4-6 12785 NULL
96178 +scsi_adjust_queue_depth_12802 scsi_adjust_queue_depth 3 12802 NULL
96179 +xfs_inumbers_fmt_12817 xfs_inumbers_fmt 3 12817 NULL
96180 +readq_12825 readq 0 12825 NULL
96181 +TSS_authhmac_12839 TSS_authhmac 3 12839 NULL
96182 +spidev_sync_12842 spidev_sync 0 12842 NULL nohasharray
96183 +ath6kl_wmi_add_wow_pattern_cmd_12842 ath6kl_wmi_add_wow_pattern_cmd 4 12842 &spidev_sync_12842
96184 +spidev_ioctl_12846 spidev_ioctl 2 12846 NULL
96185 +get_leb_cnt_12892 get_leb_cnt 0-2 12892 NULL
96186 +ocfs2_hamming_encode_block_12904 ocfs2_hamming_encode_block 2 12904 NULL
96187 +get_virtual_node_size_12908 get_virtual_node_size 0 12908 NULL
96188 +rds_pages_in_vec_12922 rds_pages_in_vec 0 12922 NULL
96189 +ci_ll_init_12930 ci_ll_init 3 12930 NULL
96190 +do_inode_permission_12946 do_inode_permission 0 12946 NULL
96191 +bm_status_write_12964 bm_status_write 3 12964 NULL
96192 +_drbd_md_first_sector_12984 _drbd_md_first_sector 0 12984 NULL
96193 +raid56_parity_recover_12987 raid56_parity_recover 5 12987 NULL
96194 +acpi_tb_install_table_12988 acpi_tb_install_table 1 12988 NULL
96195 +TransmitTcb_12989 TransmitTcb 4 12989 NULL
96196 +sk_peek_offset_12991 sk_peek_offset 0 12991 NULL
96197 +subsystem_filter_write_13022 subsystem_filter_write 3 13022 NULL
96198 +generic_segment_checks_13041 generic_segment_checks 0 13041 NULL
96199 +ocfs2_write_begin_13045 ocfs2_write_begin 3-4 13045 NULL
96200 +__dn_setsockopt_13060 __dn_setsockopt 5 13060 NULL
96201 +irq_set_chip_and_handler_13088 irq_set_chip_and_handler 1 13088 NULL
96202 +xattr_getsecurity_13090 xattr_getsecurity 0 13090 NULL
96203 +blk_rq_map_sg_13092 blk_rq_map_sg 0 13092 NULL
96204 +mb_find_next_zero_bit_13100 mb_find_next_zero_bit 2-3 13100 NULL
96205 +ubifs_compat_ioctl_13108 ubifs_compat_ioctl 3 13108 NULL
96206 +snd_rme96_playback_copy_13111 snd_rme96_playback_copy 5 13111 NULL
96207 +xen_allocate_irq_dynamic_13116 xen_allocate_irq_dynamic 0 13116 NULL
96208 +bfad_debugfs_read_13119 bfad_debugfs_read 3 13119 NULL
96209 +blk_update_request_13146 blk_update_request 3 13146 NULL
96210 +caif_stream_recvmsg_13173 caif_stream_recvmsg 4 13173 NULL
96211 +pwr_disable_ps_read_13176 pwr_disable_ps_read 3 13176 NULL
96212 +ucs2_strlen_13178 ucs2_strlen 0 13178 NULL
96213 +dgrp_net_ioctl_13183 dgrp_net_ioctl 2 13183 NULL
96214 +create_trace_uprobe_13184 create_trace_uprobe 1 13184 NULL
96215 +compat_put_ulong_13186 compat_put_ulong 1 13186 NULL
96216 +__cmpxchg64_13187 __cmpxchg64 0 13187 NULL
96217 +comedi_read_13199 comedi_read 3 13199 NULL
96218 +mmc_ext_csd_read_13205 mmc_ext_csd_read 3 13205 NULL
96219 +__nodes_fold_13215 __nodes_fold 4 13215 NULL
96220 +svm_msrpm_offset_13220 svm_msrpm_offset 0-1 13220 NULL
96221 +fnic_trace_ctrl_write_13229 fnic_trace_ctrl_write 3 13229 NULL
96222 +asix_read_cmd_13245 asix_read_cmd 5 13245 NULL
96223 +fw_download_code_13249 fw_download_code 3 13249 NULL nohasharray
96224 +kvm_lapic_enable_pv_eoi_13249 kvm_lapic_enable_pv_eoi 2 13249 &fw_download_code_13249
96225 +init_tid_tabs_13252 init_tid_tabs 2-3-4 13252 NULL
96226 +hostap_80211_get_hdrlen_13255 hostap_80211_get_hdrlen 0 13255 NULL
96227 +bio_integrity_trim_13259 bio_integrity_trim 3 13259 NULL
96228 +c4iw_reg_user_mr_13269 c4iw_reg_user_mr 2-3 13269 NULL
96229 +carl9170_rx_13272 carl9170_rx 3 13272 NULL
96230 +pmcraid_notify_aen_13274 pmcraid_notify_aen 3 13274 NULL
96231 +il4965_stats_flag_13281 il4965_stats_flag 0-3 13281 NULL
96232 +lpfc_idiag_mbxacc_get_setup_13282 lpfc_idiag_mbxacc_get_setup 0 13282 NULL
96233 +platform_device_add_resources_13289 platform_device_add_resources 3 13289 NULL
96234 +i915_drop_caches_write_13308 i915_drop_caches_write 3 13308 NULL
96235 +us122l_ctl_msg_13330 us122l_ctl_msg 8 13330 NULL
96236 +__clone_and_map_data_bio_13334 __clone_and_map_data_bio 4-8 13334 NULL
96237 +kvm_read_nested_guest_page_13337 kvm_read_nested_guest_page 5-2 13337 NULL
96238 +cache_ctr_13364 cache_ctr 2 13364 NULL
96239 +mthca_alloc_mtt_range_13371 mthca_alloc_mtt_range 2 13371 NULL
96240 +iso_sched_alloc_13377 iso_sched_alloc 1 13377 NULL nohasharray
96241 +wep_key_not_found_read_13377 wep_key_not_found_read 3 13377 &iso_sched_alloc_13377
96242 +carl9170_rx_untie_data_13405 carl9170_rx_untie_data 3 13405 NULL
96243 +sky2_receive_13407 sky2_receive 2 13407 NULL
96244 +netxen_alloc_sds_rings_13417 netxen_alloc_sds_rings 2 13417 NULL
96245 +keyring_read_13438 keyring_read 3 13438 NULL
96246 +sctp_setsockopt_peer_primary_addr_13440 sctp_setsockopt_peer_primary_addr 3 13440 NULL nohasharray
96247 +set_tap_pwup_pfs_13440 set_tap_pwup_pfs 3 13440 &sctp_setsockopt_peer_primary_addr_13440
96248 +ath6kl_cfg80211_connect_event_13443 ath6kl_cfg80211_connect_event 8-9-7 13443 NULL
96249 +mthca_buddy_alloc_13454 mthca_buddy_alloc 2 13454 NULL
96250 +ocfs2_align_bytes_to_blocks_13512 ocfs2_align_bytes_to_blocks 2 13512 NULL
96251 +core_status_13515 core_status 4 13515 NULL
96252 +smk_write_mapped_13519 smk_write_mapped 3 13519 NULL
96253 +bm_init_13529 bm_init 2 13529 NULL
96254 +non_atomic_pte_lookup_13540 non_atomic_pte_lookup 2 13540 NULL
96255 +ieee80211_if_read_ap_power_level_13558 ieee80211_if_read_ap_power_level 3 13558 NULL
96256 +ubifs_get_idx_gc_leb_13566 ubifs_get_idx_gc_leb 0 13566 NULL
96257 +sys_madvise_13569 sys_madvise 1 13569 NULL
96258 +read_file_antenna_13574 read_file_antenna 3 13574 NULL
96259 +cache_write_13589 cache_write 3 13589 NULL
96260 +mpt_lan_receive_post_turbo_13592 mpt_lan_receive_post_turbo 2 13592 NULL
96261 +aac_sa_ioremap_13596 aac_sa_ioremap 2 13596 NULL nohasharray
96262 +irias_new_octseq_value_13596 irias_new_octseq_value 2 13596 &aac_sa_ioremap_13596
96263 +usb_dump_interface_descriptor_13603 usb_dump_interface_descriptor 0 13603 NULL
96264 +swap_cgroup_swapon_13614 swap_cgroup_swapon 2 13614 NULL
96265 +wm8994_bulk_write_13615 wm8994_bulk_write 2-3 13615 NULL
96266 +pmcraid_get_minor_13619 pmcraid_get_minor 0 13619 NULL
96267 +iio_device_add_event_sysfs_13627 iio_device_add_event_sysfs 0 13627 NULL
96268 +packet_snd_13634 packet_snd 3 13634 NULL
96269 +blk_msg_write_13655 blk_msg_write 3 13655 NULL
96270 +cache_downcall_13666 cache_downcall 3 13666 NULL
96271 +fw_iso_buffer_alloc_13704 fw_iso_buffer_alloc 2 13704 NULL
96272 +audit_unpack_string_13748 audit_unpack_string 3 13748 NULL
96273 +ufs_dtog_13750 ufs_dtog 0-2 13750 NULL
96274 +ieee802154_alloc_device_13767 ieee802154_alloc_device 1 13767 NULL
96275 +fb_sys_read_13778 fb_sys_read 3 13778 NULL
96276 +ath6kl_mgmt_powersave_ap_13791 ath6kl_mgmt_powersave_ap 6 13791 NULL
96277 +random_read_13815 random_read 3 13815 NULL
96278 +hsi_register_board_info_13820 hsi_register_board_info 2 13820 NULL
96279 +evdev_ioctl_compat_13851 evdev_ioctl_compat 2-3 13851 NULL
96280 +compat_ip_setsockopt_13870 compat_ip_setsockopt 5 13870 NULL nohasharray
96281 +alloc_trace_uprobe_13870 alloc_trace_uprobe 3 13870 &compat_ip_setsockopt_13870
96282 +qp_memcpy_to_queue_13886 qp_memcpy_to_queue 2-5 13886 NULL
96283 +snd_pcm_aio_read_13900 snd_pcm_aio_read 3 13900 NULL
96284 +ext3_xattr_block_get_13936 ext3_xattr_block_get 0 13936 NULL
96285 +ieee80211_if_read_dot11MeshForwarding_13940 ieee80211_if_read_dot11MeshForwarding 3 13940 NULL nohasharray
96286 +ocfs2_xa_value_truncate_13940 ocfs2_xa_value_truncate 2 13940 &ieee80211_if_read_dot11MeshForwarding_13940
96287 +iwl_dbgfs_protection_mode_read_13943 iwl_dbgfs_protection_mode_read 3 13943 NULL
96288 +compat_chaninfo_13945 compat_chaninfo 2 13945 NULL
96289 +ieee80211_if_read_min_discovery_timeout_13946 ieee80211_if_read_min_discovery_timeout 3 13946 NULL
96290 +lpfc_idiag_queacc_read_13950 lpfc_idiag_queacc_read 3 13950 NULL
96291 +snd_pcm_plug_slave_size_13967 snd_pcm_plug_slave_size 0-2 13967 NULL
96292 +com90xx_found_13974 com90xx_found 3 13974 NULL
96293 +qcam_read_13977 qcam_read 3 13977 NULL
96294 +dsp_read_13980 dsp_read 2 13980 NULL
96295 +bm_block_bits_13981 bm_block_bits 0 13981 NULL nohasharray
96296 +dvb_demux_read_13981 dvb_demux_read 3 13981 &bm_block_bits_13981
96297 +btrfs_get_blocks_direct_14016 btrfs_get_blocks_direct 2 14016 NULL
96298 +_rtl92s_firmware_downloadcode_14021 _rtl92s_firmware_downloadcode 3 14021 NULL
96299 +dvb_usercopy_14036 dvb_usercopy 2 14036 NULL
96300 +read_def_modal_eeprom_14041 read_def_modal_eeprom 3 14041 NULL
96301 +ieee80211_if_fmt_aid_14055 ieee80211_if_fmt_aid 3 14055 NULL
96302 +sta_agg_status_read_14058 sta_agg_status_read 3 14058 NULL
96303 +i915_drop_caches_read_14060 i915_drop_caches_read 3 14060 NULL
96304 +do_proc_readlink_14096 do_proc_readlink 3 14096 NULL
96305 +compat_sys_pselect6_14105 compat_sys_pselect6 1 14105 NULL
96306 +nlmsg_len_14115 nlmsg_len 0 14115 NULL
96307 +vfio_fops_compat_ioctl_14130 vfio_fops_compat_ioctl 3 14130 NULL
96308 +ntfs_rl_replace_14136 ntfs_rl_replace 2-4 14136 NULL
96309 +em_canid_change_14150 em_canid_change 3 14150 NULL
96310 +gsm_dlci_data_14155 gsm_dlci_data 3 14155 NULL
96311 +print_input_mask_14168 print_input_mask 3-0 14168 NULL
96312 +ocfs2_xattr_value_truncate_14183 ocfs2_xattr_value_truncate 3 14183 NULL
96313 +alloc_async_14208 alloc_async 1 14208 NULL
96314 +sys_kexec_load_14222 sys_kexec_load 2 14222 NULL
96315 +ieee80211_if_write_uapsd_max_sp_len_14233 ieee80211_if_write_uapsd_max_sp_len 3 14233 NULL
96316 +dma_declare_coherent_memory_14244 dma_declare_coherent_memory 4-2 14244 NULL
96317 +snd_soc_hw_bulk_write_raw_14245 snd_soc_hw_bulk_write_raw 2-4 14245 NULL
96318 +reiserfs_compat_ioctl_14265 reiserfs_compat_ioctl 3 14265 NULL
96319 +ath6kl_connect_event_14267 ath6kl_connect_event 8-9-7 14267 NULL
96320 +add_numbered_child_14273 add_numbered_child 5 14273 NULL
96321 +OS_mem_token_alloc_14276 OS_mem_token_alloc 1 14276 NULL
96322 +snd_seq_oss_readq_new_14283 snd_seq_oss_readq_new 2 14283 NULL
96323 +rr_status_14293 rr_status 5 14293 NULL
96324 +read_default_ldt_14302 read_default_ldt 2 14302 NULL
96325 +oo_objects_14319 oo_objects 0 14319 NULL
96326 +p9_client_zc_rpc_14345 p9_client_zc_rpc 7 14345 NULL
96327 +scsi2int_14358 scsi2int 0 14358 NULL
96328 +snd_pcm_lib_readv_14363 snd_pcm_lib_readv 0-3 14363 NULL
96329 +acpi_get_override_irq_14381 acpi_get_override_irq 1 14381 NULL
96330 +ath6kl_regdump_read_14393 ath6kl_regdump_read 3 14393 NULL
96331 +smk_write_onlycap_14400 smk_write_onlycap 3 14400 NULL
96332 +mtd_concat_create_14416 mtd_concat_create 2 14416 NULL
96333 +get_kcore_size_14425 get_kcore_size 0 14425 NULL
96334 +check_lpt_crc_14442 check_lpt_crc 0 14442 NULL
96335 +block_size_14443 block_size 0 14443 NULL
96336 +ci13xxx_add_device_14456 ci13xxx_add_device 3 14456 NULL
96337 +snd_emu10k1_proc_spdif_status_14457 snd_emu10k1_proc_spdif_status 4-5 14457 NULL
96338 +udplite_getfrag_14479 udplite_getfrag 3-4 14479 NULL
96339 +ieee80211_if_read_dot11MeshGateAnnouncementProtocol_14486 ieee80211_if_read_dot11MeshGateAnnouncementProtocol 3 14486 NULL
96340 +ocfs2_debug_read_14507 ocfs2_debug_read 3 14507 NULL
96341 +dataflash_read_user_otp_14536 dataflash_read_user_otp 2-3 14536 NULL nohasharray
96342 +ep0_write_14536 ep0_write 3 14536 &dataflash_read_user_otp_14536
96343 +picolcd_debug_eeprom_read_14549 picolcd_debug_eeprom_read 3 14549 NULL
96344 +drm_vmalloc_dma_14550 drm_vmalloc_dma 1 14550 NULL
96345 +usb_dump_desc_14553 usb_dump_desc 0 14553 NULL
96346 +qp_host_alloc_queue_14566 qp_host_alloc_queue 1 14566 NULL
96347 +remap_to_origin_then_cache_14583 remap_to_origin_then_cache 3 14583 NULL
96348 +idmap_pipe_downcall_14591 idmap_pipe_downcall 3 14591 NULL
96349 +ceph_osdc_alloc_request_14597 ceph_osdc_alloc_request 3 14597 NULL
96350 +ocfs2_trim_group_14641 ocfs2_trim_group 4-3 14641 NULL
96351 +dbJoin_14644 dbJoin 0 14644 NULL
96352 +profile_replace_14652 profile_replace 3 14652 NULL
96353 +pipeline_enc_tx_stat_fifo_int_read_14680 pipeline_enc_tx_stat_fifo_int_read 3 14680 NULL
96354 +ieee80211_if_fmt_rc_rateidx_mask_2ghz_14683 ieee80211_if_fmt_rc_rateidx_mask_2ghz 3 14683 NULL
96355 +tsi148_master_set_14685 tsi148_master_set 4 14685 NULL
96356 +u_audio_playback_14709 u_audio_playback 3 14709 NULL
96357 +get_bio_block_14714 get_bio_block 0 14714 NULL
96358 +vfd_write_14717 vfd_write 3 14717 NULL
96359 +__blk_end_request_14729 __blk_end_request 3 14729 NULL
96360 +raid1_resize_14740 raid1_resize 2 14740 NULL
96361 +btrfs_inode_extref_name_len_14752 btrfs_inode_extref_name_len 0 14752 NULL
96362 +rx_rx_cmplt_read_14753 rx_rx_cmplt_read 3 14753 NULL
96363 +qla82xx_pci_mem_write_2M_14765 qla82xx_pci_mem_write_2M 2 14765 NULL
96364 +regmap_range_read_file_14775 regmap_range_read_file 3 14775 NULL
96365 +sta_dev_read_14782 sta_dev_read 3 14782 NULL
96366 +ext4_kvmalloc_14796 ext4_kvmalloc 1 14796 NULL
96367 +hpet_readl_14801 hpet_readl 0 14801 NULL nohasharray
96368 +snd_als300_gcr_read_14801 snd_als300_gcr_read 0 14801 &hpet_readl_14801
96369 +bcma_scan_read32_14802 bcma_scan_read32 0 14802 NULL
96370 +__mutex_fastpath_lock_retval_14844 __mutex_fastpath_lock_retval 0 14844 NULL
96371 +mrp_attr_create_14853 mrp_attr_create 3 14853 NULL
96372 +lcd_write_14857 lcd_write 3 14857 NULL nohasharray
96373 +__krealloc_14857 __krealloc 2 14857 &lcd_write_14857
96374 +get_user_cpu_mask_14861 get_user_cpu_mask 2 14861 NULL
96375 +sriov_enable_migration_14889 sriov_enable_migration 2 14889 NULL
96376 +acpi_os_allocate_14892 acpi_os_allocate 1 14892 NULL
96377 +unifi_read_14899 unifi_read 3 14899 NULL
96378 +krealloc_14908 krealloc 2 14908 NULL
96379 +regmap_irq_get_virq_14910 regmap_irq_get_virq 2 14910 NULL
96380 +__arch_hweight64_14923 __arch_hweight64 0 14923 NULL nohasharray
96381 +qp_memcpy_to_queue_iov_14923 qp_memcpy_to_queue_iov 2-5 14923 &__arch_hweight64_14923
96382 +ocfs2_expand_nonsparse_inode_14936 ocfs2_expand_nonsparse_inode 3-4 14936 NULL
96383 +queue_cnt_14951 queue_cnt 0 14951 NULL
96384 +videobuf_read_stream_14956 videobuf_read_stream 3 14956 NULL
96385 +mce_flush_rx_buffer_14976 mce_flush_rx_buffer 2 14976 NULL
96386 +setkey_14987 setkey 3 14987 NULL nohasharray
96387 +gpio_twl4030_write_14987 gpio_twl4030_write 1 14987 &setkey_14987
96388 +vmap_15025 vmap 2 15025 NULL
96389 +blk_integrity_tuple_size_15027 blk_integrity_tuple_size 0 15027 NULL
96390 +irq_get_next_irq_15053 irq_get_next_irq 1 15053 NULL
96391 +cld_pipe_downcall_15058 cld_pipe_downcall 3 15058 NULL
96392 +ieee80211_if_read_uapsd_max_sp_len_15067 ieee80211_if_read_uapsd_max_sp_len 3 15067 NULL
96393 +nfs4_write_cached_acl_15070 nfs4_write_cached_acl 4 15070 NULL
96394 +ntfs_copy_from_user_15072 ntfs_copy_from_user 3-5 15072 NULL
96395 +hex_dump_to_buffer_15121 hex_dump_to_buffer 6 15121 NULL
96396 +start_port_15124 start_port 0 15124 NULL
96397 +memchr_15126 memchr 0 15126 NULL
96398 +ipwireless_ppp_mru_15153 ipwireless_ppp_mru 0 15153 NULL
96399 +self_check_not_bad_15175 self_check_not_bad 0 15175 NULL
96400 +iscsi_create_endpoint_15193 iscsi_create_endpoint 1 15193 NULL
96401 +reserve_resources_15194 reserve_resources 3 15194 NULL
96402 +bfad_debugfs_write_regrd_15218 bfad_debugfs_write_regrd 3 15218 NULL
96403 +il_dbgfs_rx_stats_read_15243 il_dbgfs_rx_stats_read 3 15243 NULL
96404 +compat_raw_ioctl_15290 compat_raw_ioctl 3 15290 NULL
96405 +sys_connect_15291 sys_connect 3 15291 NULL nohasharray
96406 +xlate_dev_mem_ptr_15291 xlate_dev_mem_ptr 1 15291 &sys_connect_15291
96407 +arch_enable_uv_irq_15294 arch_enable_uv_irq 2 15294 NULL
96408 +acpi_ev_create_gpe_block_15297 acpi_ev_create_gpe_block 5 15297 NULL
96409 +tpm_tis_init_15304 tpm_tis_init 2-3 15304 NULL
96410 +fcoe_ctlr_send_keep_alive_15308 fcoe_ctlr_send_keep_alive 3 15308 NULL
96411 +__ocfs2_remove_xattr_range_15330 __ocfs2_remove_xattr_range 4-5-3 15330 NULL
96412 +kovaplus_sysfs_read_15337 kovaplus_sysfs_read 6 15337 NULL
96413 +ioread16_15342 ioread16 0 15342 NULL
96414 +alloc_ring_15345 alloc_ring 2-4 15345 NULL
96415 +acpi_ut_create_string_object_15360 acpi_ut_create_string_object 1 15360 NULL
96416 +graph_depth_read_15371 graph_depth_read 3 15371 NULL
96417 +compat_sys_process_vm_readv_15374 compat_sys_process_vm_readv 3-5 15374 NULL
96418 +fq_codel_zalloc_15378 fq_codel_zalloc 1 15378 NULL
96419 +domain_flush_pages_15379 domain_flush_pages 2-3 15379 NULL
96420 +alloc_fddidev_15382 alloc_fddidev 1 15382 NULL
96421 +btrfs_level_size_15392 btrfs_level_size 0 15392 NULL
96422 +pipeline_csum_to_rx_xfer_swi_read_15403 pipeline_csum_to_rx_xfer_swi_read 3 15403 NULL
96423 +get_modalias_15406 get_modalias 2 15406 NULL
96424 +dm_cache_resize_15422 dm_cache_resize 2 15422 NULL
96425 +__videobuf_copy_to_user_15423 __videobuf_copy_to_user 4 15423 NULL
96426 +tcp_mtu_to_mss_15438 tcp_mtu_to_mss 2 15438 NULL
96427 +hpsa_change_queue_depth_15449 hpsa_change_queue_depth 2 15449 NULL
96428 +memweight_15450 memweight 2 15450 NULL
96429 +vmalloc_15464 vmalloc 1 15464 NULL
96430 +zd_chip_is_zd1211b_15518 zd_chip_is_zd1211b 0 15518 NULL
96431 +da9052_bat_irq_15533 da9052_bat_irq 1 15533 NULL
96432 +p9_check_zc_errors_15534 p9_check_zc_errors 4 15534 NULL
96433 +ql_process_mac_rx_page_15543 ql_process_mac_rx_page 4 15543 NULL
96434 +ieee80211_amsdu_to_8023s_15561 ieee80211_amsdu_to_8023s 5 15561 NULL
96435 +persistent_status_15574 persistent_status 4 15574 NULL
96436 +bnx2fc_process_unsol_compl_15576 bnx2fc_process_unsol_compl 2 15576 NULL
96437 +vme_user_write_15587 vme_user_write 3 15587 NULL
96438 +ocfs2_truncate_rec_15595 ocfs2_truncate_rec 7 15595 NULL
96439 +sx150x_install_irq_chip_15609 sx150x_install_irq_chip 3 15609 NULL
96440 +iommu_device_max_index_15620 iommu_device_max_index 0-3-2-1 15620 NULL nohasharray
96441 +compat_fillonedir_15620 compat_fillonedir 3 15620 &iommu_device_max_index_15620
96442 +set_dis_tap_pfs_15621 set_dis_tap_pfs 3 15621 NULL
96443 +proc_loginuid_read_15631 proc_loginuid_read 3 15631 NULL
96444 +tomoyo_scan_bprm_15642 tomoyo_scan_bprm 2-4 15642 NULL nohasharray
96445 +sk_memory_allocated_add_15642 sk_memory_allocated_add 2 15642 &tomoyo_scan_bprm_15642 nohasharray
96446 +pipeline_hs_tx_stat_fifo_int_read_15642 pipeline_hs_tx_stat_fifo_int_read 3 15642 &sk_memory_allocated_add_15642
96447 +fs_path_add_15648 fs_path_add 3 15648 NULL
96448 +xsd_read_15653 xsd_read 3 15653 NULL
96449 +compat_sys_fcntl_15654 compat_sys_fcntl 3 15654 NULL
96450 +unix_bind_15668 unix_bind 3 15668 NULL
96451 +dm_read_15674 dm_read 3 15674 NULL
96452 +pstore_mkfile_15675 pstore_mkfile 6 15675 NULL
96453 +uf_sme_queue_message_15697 uf_sme_queue_message 3 15697 NULL
96454 +ocfs2_split_tree_15716 ocfs2_split_tree 5 15716 NULL
96455 +HiSax_readstatus_15752 HiSax_readstatus 2 15752 NULL
96456 +bitmap_search_next_usable_block_15762 bitmap_search_next_usable_block 3-1 15762 NULL
96457 +do_test_15766 do_test 1 15766 NULL
96458 +set_std_nic_pfs_15792 set_std_nic_pfs 3 15792 NULL
96459 +smk_read_direct_15803 smk_read_direct 3 15803 NULL
96460 +snd_pcm_ioctl_compat_15804 snd_pcm_ioctl_compat 3 15804 NULL
96461 +gx1_read_conf_reg_15817 gx1_read_conf_reg 0 15817 NULL nohasharray
96462 +nameseq_list_15817 nameseq_list 3 15817 &gx1_read_conf_reg_15817 nohasharray
96463 +gnttab_expand_15817 gnttab_expand 1 15817 &nameseq_list_15817
96464 +afs_proc_rootcell_write_15822 afs_proc_rootcell_write 3 15822 NULL
96465 +brcmf_sdbrcm_died_dump_15841 brcmf_sdbrcm_died_dump 3 15841 NULL
96466 +table_size_15851 table_size 0-1-2 15851 NULL
96467 +ubi_io_write_15870 ubi_io_write 5-4 15870 NULL nohasharray
96468 +media_entity_init_15870 media_entity_init 2-4 15870 &ubi_io_write_15870
96469 +__mptctl_ioctl_15875 __mptctl_ioctl 2 15875 NULL
96470 +nfs_map_group_to_gid_15892 nfs_map_group_to_gid 3 15892 NULL
96471 +native_read_msr_15905 native_read_msr 0 15905 NULL
96472 +parse_audio_stream_data_15937 parse_audio_stream_data 3 15937 NULL
96473 +power_read_15939 power_read 3 15939 NULL
96474 +lpfc_idiag_drbacc_read_15948 lpfc_idiag_drbacc_read 3 15948 NULL
96475 +snd_pcm_lib_read_transfer_15952 snd_pcm_lib_read_transfer 4-2-5 15952 NULL
96476 +remap_pci_mem_15966 remap_pci_mem 1-2 15966 NULL
96477 +frame_alloc_15981 frame_alloc 4 15981 NULL
96478 +alloc_vm_area_15989 alloc_vm_area 1 15989 NULL
96479 +hdpvr_register_videodev_16010 hdpvr_register_videodev 3 16010 NULL
96480 +viafb_vt1636_proc_write_16018 viafb_vt1636_proc_write 3 16018 NULL
96481 +got_frame_16028 got_frame 2 16028 NULL
96482 +read_file_spectral_period_16057 read_file_spectral_period 3 16057 NULL
96483 +isr_tx_exch_complete_read_16103 isr_tx_exch_complete_read 3 16103 NULL
96484 +dma_tx_requested_read_16110 dma_tx_requested_read 3 16110 NULL nohasharray
96485 +isr_hw_pm_mode_changes_read_16110 isr_hw_pm_mode_changes_read 3 16110 &dma_tx_requested_read_16110
96486 +irq_set_chip_and_handler_name_16111 irq_set_chip_and_handler_name 1 16111 NULL
96487 +snd_dma_pointer_16126 snd_dma_pointer 0-2 16126 NULL
96488 +compat_sys_select_16131 compat_sys_select 1 16131 NULL
96489 +fsm_init_16134 fsm_init 2 16134 NULL
96490 +hysdn_rx_netpkt_16136 hysdn_rx_netpkt 3 16136 NULL
96491 +ext4_xattr_block_get_16148 ext4_xattr_block_get 0 16148 NULL
96492 +bnx2i_get_cid_num_16166 bnx2i_get_cid_num 0 16166 NULL
96493 +mapping_level_16188 mapping_level 2 16188 NULL
96494 +cipso_v4_map_cat_rng_hton_16203 cipso_v4_map_cat_rng_hton 0 16203 NULL
96495 +create_table_16213 create_table 2 16213 NULL
96496 +atomic_read_file_16227 atomic_read_file 3 16227 NULL
96497 +BcmGetSectionValStartOffset_16235 BcmGetSectionValStartOffset 0 16235 NULL
96498 +swiotlb_sync_single_for_device_16247 swiotlb_sync_single_for_device 2 16247 NULL nohasharray
96499 +btrfs_dev_extent_chunk_offset_16247 btrfs_dev_extent_chunk_offset 0 16247 &swiotlb_sync_single_for_device_16247
96500 +mark_written_sectors_16262 mark_written_sectors 2 16262 NULL
96501 +reiserfs_acl_count_16265 reiserfs_acl_count 0-1 16265 NULL
96502 +set_disc_pfs_16270 set_disc_pfs 3 16270 NULL
96503 +mq_force_mapping_16277 mq_force_mapping 2 16277 NULL
96504 +ocfs2_xattr_bucket_value_truncate_16279 ocfs2_xattr_bucket_value_truncate 4 16279 NULL
96505 +drbd_setsockopt_16280 drbd_setsockopt 5 16280 NULL nohasharray
96506 +nand_bch_init_16280 nand_bch_init 3-2 16280 &drbd_setsockopt_16280
96507 +account_16283 account 0-2-4 16283 NULL nohasharray
96508 +mirror_status_16283 mirror_status 5 16283 &account_16283
96509 +retry_instruction_16285 retry_instruction 2 16285 NULL
96510 +stk_allocate_buffers_16291 stk_allocate_buffers 2 16291 NULL
96511 +rsc_mgr_init_16299 rsc_mgr_init 3 16299 NULL
96512 +wb_map_16301 wb_map 2 16301 NULL
96513 +vmw_cursor_update_image_16332 vmw_cursor_update_image 3-4 16332 NULL
96514 +total_ps_buffered_read_16365 total_ps_buffered_read 3 16365 NULL
96515 +iscsi_tcp_conn_setup_16376 iscsi_tcp_conn_setup 2 16376 NULL
96516 +nl80211_send_unprot_deauth_16378 nl80211_send_unprot_deauth 4 16378 NULL
96517 +diva_os_malloc_16406 diva_os_malloc 2 16406 NULL
96518 +ieee80211_if_read_tsf_16420 ieee80211_if_read_tsf 3 16420 NULL
96519 +rxrpc_server_keyring_16431 rxrpc_server_keyring 3 16431 NULL
96520 +netlink_change_ngroups_16457 netlink_change_ngroups 2 16457 NULL
96521 +tracing_readme_read_16493 tracing_readme_read 3 16493 NULL
96522 +snd_interval_max_16529 snd_interval_max 0 16529 NULL
96523 +raid10_resize_16537 raid10_resize 2 16537 NULL
96524 +tcp_manip_pkt_16563 tcp_manip_pkt 4 16563 NULL
96525 +lpfc_debugfs_read_16566 lpfc_debugfs_read 3 16566 NULL
96526 +agp_allocate_memory_wrap_16576 agp_allocate_memory_wrap 1 16576 NULL
96527 +virt_to_scatterlist_16582 virt_to_scatterlist 2 16582 NULL
96528 +palmas_irq_get_virq_16613 palmas_irq_get_virq 2 16613 NULL
96529 +btrfs_get_token_32_16651 btrfs_get_token_32 0 16651 NULL
96530 +mfd_add_devices_16668 mfd_add_devices 4 16668 NULL
96531 +ax88179_write_cmd_async_16671 ax88179_write_cmd_async 5 16671 NULL
96532 +arcmsr_adjust_disk_queue_depth_16756 arcmsr_adjust_disk_queue_depth 2 16756 NULL
96533 +compat_blkdev_driver_ioctl_16769 compat_blkdev_driver_ioctl 4 16769 NULL
96534 +blk_rq_map_user_iov_16772 blk_rq_map_user_iov 5 16772 NULL
96535 +i2o_parm_issue_16790 i2o_parm_issue 0 16790 NULL
96536 +get_server_iovec_16804 get_server_iovec 2 16804 NULL
96537 +tipc_send2name_16809 tipc_send2name 6 16809 NULL
96538 +dm_vcalloc_16814 dm_vcalloc 1-2 16814 NULL
96539 +drm_malloc_ab_16831 drm_malloc_ab 1-2 16831 NULL
96540 +scsi_mode_sense_16835 scsi_mode_sense 5 16835 NULL
96541 +hfsplus_min_io_size_16859 hfsplus_min_io_size 0 16859 NULL
96542 +alloc_idx_lebs_16872 alloc_idx_lebs 2 16872 NULL
96543 +carl9170_debugfs_ampdu_state_read_16873 carl9170_debugfs_ampdu_state_read 3 16873 NULL
96544 +st_write_16874 st_write 3 16874 NULL
96545 +__kfifo_peek_n_16877 __kfifo_peek_n 0 16877 NULL
96546 +idx_to_pfn_16919 idx_to_pfn 0 16919 NULL
96547 +psb_unlocked_ioctl_16926 psb_unlocked_ioctl 2 16926 NULL nohasharray
96548 +snd_gf1_mem_proc_dump_16926 snd_gf1_mem_proc_dump 5 16926 &psb_unlocked_ioctl_16926
96549 +_sp2d_alloc_16944 _sp2d_alloc 1-2-3 16944 NULL
96550 +squashfs_read_table_16945 squashfs_read_table 3 16945 NULL
96551 +cfg80211_send_unprot_disassoc_16951 cfg80211_send_unprot_disassoc 3 16951 NULL
96552 +keyctl_instantiate_key_iov_16969 keyctl_instantiate_key_iov 3 16969 NULL
96553 +ceph_read_dir_17005 ceph_read_dir 3 17005 NULL
96554 +copy_counters_to_user_17027 copy_counters_to_user 5 17027 NULL
96555 +jffs2_trusted_setxattr_17048 jffs2_trusted_setxattr 4 17048 NULL
96556 +__arch_hweight32_17060 __arch_hweight32 0 17060 NULL
96557 +dvb_dvr_read_17073 dvb_dvr_read 3 17073 NULL
96558 +simple_transaction_read_17076 simple_transaction_read 3 17076 NULL
96559 +__kmalloc_reserve_17080 __kmalloc_reserve 1 17080 NULL
96560 +carl9170_debugfs_mem_usage_read_17084 carl9170_debugfs_mem_usage_read 3 17084 NULL
96561 +mac_address_string_17091 mac_address_string 0 17091 NULL
96562 +entry_length_17093 entry_length 0 17093 NULL
96563 +sys_preadv_17100 sys_preadv 3 17100 NULL
96564 +pvr2_hdw_state_report_17121 pvr2_hdw_state_report 3 17121 NULL
96565 +mwifiex_get_common_rates_17131 mwifiex_get_common_rates 3 17131 NULL
96566 +nouveau_instobj_create__17144 nouveau_instobj_create_ 4 17144 NULL
96567 +sep_read_17161 sep_read 3 17161 NULL
96568 +befs_nls2utf_17163 befs_nls2utf 3 17163 NULL
96569 +tx_tx_start_templates_read_17164 tx_tx_start_templates_read 3 17164 NULL
96570 +UniStrnlen_17169 UniStrnlen 0 17169 NULL
96571 +access_remote_vm_17189 access_remote_vm 0-2-4 17189 NULL
96572 +driver_state_read_17194 driver_state_read 3 17194 NULL nohasharray
96573 +iscsit_find_cmd_from_itt_or_dump_17194 iscsit_find_cmd_from_itt_or_dump 3 17194 &driver_state_read_17194
96574 +dn_recvmsg_17213 dn_recvmsg 4 17213 NULL
96575 +to_oblock_17254 to_oblock 0-1 17254 NULL
96576 +unpack_value_17259 unpack_value 1 17259 NULL
96577 +__be16_to_cpup_17261 __be16_to_cpup 0 17261 NULL
96578 +error_error_frame_cts_nul_flid_read_17262 error_error_frame_cts_nul_flid_read 3 17262 NULL
96579 +alloc_ep_17269 alloc_ep 1 17269 NULL
96580 +pg_read_17276 pg_read 3 17276 NULL
96581 +raw_recvmsg_17277 raw_recvmsg 4 17277 NULL
96582 +hmac_sha256_17278 hmac_sha256 2 17278 NULL
96583 +neigh_hash_grow_17283 neigh_hash_grow 2 17283 NULL
96584 +minstrel_stats_read_17290 minstrel_stats_read 3 17290 NULL
96585 +install_breakpoint_17292 install_breakpoint 4 17292 NULL
96586 +ieee80211_if_fmt_dot11MeshForwarding_17301 ieee80211_if_fmt_dot11MeshForwarding 3 17301 NULL
96587 +skb_pad_17302 skb_pad 2 17302 NULL
96588 +mb_cache_create_17307 mb_cache_create 2 17307 NULL
96589 +gnttab_map_frames_v2_17314 gnttab_map_frames_v2 2 17314 NULL
96590 +ata_host_alloc_pinfo_17325 ata_host_alloc_pinfo 3 17325 NULL
96591 +ieee80211_if_read_dot11MeshHWMPperrMinInterval_17346 ieee80211_if_read_dot11MeshHWMPperrMinInterval 3 17346 NULL
96592 +ath6kl_wmi_send_mgmt_cmd_17347 ath6kl_wmi_send_mgmt_cmd 7 17347 NULL
96593 +_fd_dma_mem_free_17406 _fd_dma_mem_free 1 17406 NULL
96594 +lpfc_debugfs_dif_err_write_17424 lpfc_debugfs_dif_err_write 3 17424 NULL
96595 +sta_connected_time_read_17435 sta_connected_time_read 3 17435 NULL
96596 +nla_get_u32_17455 nla_get_u32 0 17455 NULL
96597 +__ref_totlen_17461 __ref_totlen 0 17461 NULL
96598 +compat_cmd_17465 compat_cmd 2 17465 NULL
96599 +probe_bios_17467 probe_bios 1 17467 NULL
96600 +probe_kernel_write_17481 probe_kernel_write 3 17481 NULL
96601 +__alloc_session_17485 __alloc_session 2-1 17485 NULL
96602 +TSS_rawhmac_17486 TSS_rawhmac 3 17486 NULL
96603 +bitmap_pos_to_ord_17503 bitmap_pos_to_ord 3 17503 NULL
96604 +__copy_to_user_17551 __copy_to_user 0-3 17551 NULL
96605 +copy_from_user_17559 copy_from_user 3 17559 NULL
96606 +acpi_ut_create_package_object_17594 acpi_ut_create_package_object 1 17594 NULL
96607 +neigh_hash_alloc_17595 neigh_hash_alloc 1 17595 NULL
96608 +rts51x_write_mem_17598 rts51x_write_mem 4 17598 NULL
96609 +iwl_dump_nic_event_log_17601 iwl_dump_nic_event_log 0 17601 NULL
96610 +wm8994_gpio_to_irq_17604 wm8994_gpio_to_irq 2 17604 NULL
96611 +osst_execute_17607 osst_execute 7-6 17607 NULL
96612 +ocfs2_mark_extent_written_17615 ocfs2_mark_extent_written 6 17615 NULL
96613 +ieee80211_if_read_dot11MeshHWMPactivePathToRootTimeout_17618 ieee80211_if_read_dot11MeshHWMPactivePathToRootTimeout 3 17618 NULL
96614 +twl4030_set_gpio_direction_17645 twl4030_set_gpio_direction 1 17645 NULL
96615 +packet_setsockopt_17662 packet_setsockopt 5 17662 NULL nohasharray
96616 +ubi_io_read_data_17662 ubi_io_read_data 0 17662 &packet_setsockopt_17662
96617 +pwr_enable_ps_read_17686 pwr_enable_ps_read 3 17686 NULL
96618 +gfn_to_pfn_memslot_17693 gfn_to_pfn_memslot 2 17693 NULL
96619 +__einj_error_trigger_17707 __einj_error_trigger 1 17707 NULL nohasharray
96620 +venus_rename_17707 venus_rename 5-4 17707 &__einj_error_trigger_17707
96621 +exofs_read_lookup_dev_table_17733 exofs_read_lookup_dev_table 3 17733 NULL
96622 +sctpprobe_read_17741 sctpprobe_read 3 17741 NULL
96623 +mark_unsafe_pages_17759 mark_unsafe_pages 0 17759 NULL
96624 +brcmf_usb_attach_17766 brcmf_usb_attach 2-3 17766 NULL
96625 +ubifs_leb_change_17789 ubifs_leb_change 4 17789 NULL
96626 +_snd_pcm_lib_alloc_vmalloc_buffer_17820 _snd_pcm_lib_alloc_vmalloc_buffer 2 17820 NULL
96627 +gnet_stats_copy_app_17821 gnet_stats_copy_app 3 17821 NULL
96628 +cipso_v4_gentag_rbm_17836 cipso_v4_gentag_rbm 0 17836 NULL
96629 +count_leafs_17842 count_leafs 0 17842 NULL
96630 +sisusb_send_bulk_msg_17864 sisusb_send_bulk_msg 3 17864 NULL
96631 +alloc_sja1000dev_17868 alloc_sja1000dev 1 17868 NULL
96632 +ray_cs_essid_proc_write_17875 ray_cs_essid_proc_write 3 17875 NULL
96633 +orinoco_set_key_17878 orinoco_set_key 5-7 17878 NULL
96634 +init_per_cpu_17880 init_per_cpu 1 17880 NULL
96635 +ieee80211_if_fmt_dot11MeshMaxPeerLinks_17883 ieee80211_if_fmt_dot11MeshMaxPeerLinks 3 17883 NULL
96636 +compat_sys_pwritev_17886 compat_sys_pwritev 3 17886 NULL
96637 +ieee80211_if_fmt_dot11MeshHWMPRootMode_17890 ieee80211_if_fmt_dot11MeshHWMPRootMode 3 17890 NULL
96638 +ocfs2_clusters_to_blocks_17896 ocfs2_clusters_to_blocks 0-2 17896 NULL
96639 +recover_head_17904 recover_head 3 17904 NULL
96640 +dccp_feat_register_sp_17914 dccp_feat_register_sp 5 17914 NULL
96641 +xfs_buf_associate_memory_17915 xfs_buf_associate_memory 3 17915 NULL
96642 +srp_iu_pool_alloc_17920 srp_iu_pool_alloc 2 17920 NULL
96643 +scsi_bufflen_17933 scsi_bufflen 0 17933 NULL
96644 +ufs_free_blocks_17963 ufs_free_blocks 2-3 17963 NULL
96645 +calc_nr_buckets_17976 calc_nr_buckets 0 17976 NULL
96646 +smk_write_cipso_17989 smk_write_cipso 3 17989 NULL
96647 +gnttab_max_grant_frames_17993 gnttab_max_grant_frames 0 17993 NULL
96648 +ext4_num_overhead_clusters_18001 ext4_num_overhead_clusters 2 18001 NULL
96649 +pvr2_v4l2_read_18006 pvr2_v4l2_read 3 18006 NULL
96650 +alloc_rx_desc_ring_18016 alloc_rx_desc_ring 2 18016 NULL
96651 +fill_read_18019 fill_read 0 18019 NULL
96652 +o2hb_highest_node_18034 o2hb_highest_node 2 18034 NULL
96653 +cryptd_alloc_instance_18048 cryptd_alloc_instance 2-3 18048 NULL
96654 +find_next_inuse_18051 find_next_inuse 2-3 18051 NULL
96655 +ddebug_proc_write_18055 ddebug_proc_write 3 18055 NULL
96656 +lua_sysfs_read_18062 lua_sysfs_read 6 18062 NULL
96657 +hex_byte_pack_18064 hex_byte_pack 0 18064 NULL
96658 +packet_came_18072 packet_came 3 18072 NULL
96659 +kvm_read_guest_page_18074 kvm_read_guest_page 5-2 18074 NULL
96660 +get_vm_area_18080 get_vm_area 1 18080 NULL
96661 +mpi_alloc_18094 mpi_alloc 1 18094 NULL
96662 +dfs_file_read_18116 dfs_file_read 3 18116 NULL
96663 +svc_getnl_18120 svc_getnl 0 18120 NULL
96664 +paging32_gpte_to_gfn_lvl_18131 paging32_gpte_to_gfn_lvl 0-1-2 18131 NULL
96665 +vmw_surface_dma_size_18132 vmw_surface_dma_size 0 18132 NULL
96666 +selinux_inode_setsecurity_18148 selinux_inode_setsecurity 4 18148 NULL
96667 +_has_tag_18169 _has_tag 2 18169 NULL
96668 +pccard_store_cis_18176 pccard_store_cis 6 18176 NULL
96669 +orinoco_add_extscan_result_18207 orinoco_add_extscan_result 3 18207 NULL
96670 +gsm_control_message_18209 gsm_control_message 4 18209 NULL
96671 +do_ipv6_setsockopt_18215 do_ipv6_setsockopt 5 18215 NULL
96672 +gnttab_alloc_grant_references_18240 gnttab_alloc_grant_references 1 18240 NULL
96673 +snd_ctl_ioctl_compat_18250 snd_ctl_ioctl_compat 3 18250 NULL
96674 +qdisc_class_hash_alloc_18262 qdisc_class_hash_alloc 1 18262 NULL
96675 +gfs2_alloc_sort_buffer_18275 gfs2_alloc_sort_buffer 1 18275 NULL
96676 +alloc_ring_18278 alloc_ring 2-4 18278 NULL
96677 +find_dirty_idx_leb_18280 find_dirty_idx_leb 0 18280 NULL
96678 +nouveau_subdev_create__18281 nouveau_subdev_create_ 7 18281 NULL nohasharray
96679 +bio_phys_segments_18281 bio_phys_segments 0 18281 &nouveau_subdev_create__18281
96680 +ext4_readpages_18283 ext4_readpages 4 18283 NULL
96681 +mmc_send_bus_test_18285 mmc_send_bus_test 4 18285 NULL
96682 +um_idi_write_18293 um_idi_write 3 18293 NULL
96683 +nouveau_disp_create__18305 nouveau_disp_create_ 4-7 18305 NULL
96684 +ip6ip6_err_18308 ip6ip6_err 5 18308 NULL
96685 +vga_r_18310 vga_r 0 18310 NULL
96686 +ecryptfs_send_message_18322 ecryptfs_send_message 2 18322 NULL
96687 +bio_integrity_advance_18324 bio_integrity_advance 2 18324 NULL
96688 +pwr_power_save_off_read_18355 pwr_power_save_off_read 3 18355 NULL
96689 +xlbd_reserve_minors_18365 xlbd_reserve_minors 1-2 18365 NULL
96690 +ep_io_18367 ep_io 0 18367 NULL
96691 +qib_user_sdma_num_pages_18371 qib_user_sdma_num_pages 0 18371 NULL
96692 +__video_register_device_18399 __video_register_device 3 18399 NULL
96693 +adis16136_show_serial_18402 adis16136_show_serial 3 18402 NULL
96694 +crystalhd_user_data_18407 crystalhd_user_data 3 18407 NULL
96695 +usbnet_write_cmd_nopm_18426 usbnet_write_cmd_nopm 7 18426 NULL
96696 +batadv_orig_node_add_if_18433 batadv_orig_node_add_if 2 18433 NULL
96697 +snd_hda_get_connections_18437 snd_hda_get_connections 0 18437 NULL
96698 +fuse_perform_write_18457 fuse_perform_write 4 18457 NULL
96699 +regset_tls_set_18459 regset_tls_set 4 18459 NULL
96700 +dma_alloc_from_contiguous_18466 dma_alloc_from_contiguous 3-2 18466 NULL
96701 +pci_vpd_lrdt_size_18479 pci_vpd_lrdt_size 0 18479 NULL
96702 +udpv6_setsockopt_18487 udpv6_setsockopt 5 18487 NULL
96703 +snd_gus_dram_poke_18525 snd_gus_dram_poke 4 18525 NULL
96704 +nouveau_fifo_channel_create__18530 nouveau_fifo_channel_create_ 5-6-9 18530 NULL
96705 +seq_copy_in_user_18543 seq_copy_in_user 3 18543 NULL
96706 +acpi_register_gsi_ioapic_18550 acpi_register_gsi_ioapic 2 18550 NULL
96707 +sas_change_queue_depth_18555 sas_change_queue_depth 2 18555 NULL
96708 +smk_write_rules_list_18565 smk_write_rules_list 3 18565 NULL
96709 +debug_output_18575 debug_output 3 18575 NULL
96710 +check_lpt_type_18577 check_lpt_type 0 18577 NULL
96711 +__netdev_alloc_skb_18595 __netdev_alloc_skb 2 18595 NULL
96712 +filemap_fdatawait_range_18600 filemap_fdatawait_range 0 18600 NULL
96713 +iowarrior_write_18604 iowarrior_write 3 18604 NULL
96714 +batadv_arp_get_type_18609 batadv_arp_get_type 3 18609 NULL
96715 +from_buffer_18625 from_buffer 3 18625 NULL
96716 +snd_pcm_oss_write3_18657 snd_pcm_oss_write3 0-3 18657 NULL
96717 +ieee80211_if_fmt_rssi_threshold_18664 ieee80211_if_fmt_rssi_threshold 3 18664 NULL
96718 +unmap_page_18665 unmap_page 2-3 18665 NULL
96719 +xfs_iext_insert_18667 xfs_iext_insert 3 18667 NULL
96720 +replay_log_leb_18704 replay_log_leb 3 18704 NULL
96721 +iwl_dbgfs_rx_handlers_read_18708 iwl_dbgfs_rx_handlers_read 3 18708 NULL
96722 +ceph_alloc_page_vector_18710 ceph_alloc_page_vector 1 18710 NULL
96723 +ocfs2_trim_extent_18711 ocfs2_trim_extent 4-3 18711 NULL
96724 +blk_rq_bytes_18715 blk_rq_bytes 0 18715 NULL
96725 +snd_als4k_gcr_read_addr_18741 snd_als4k_gcr_read_addr 0 18741 NULL
96726 +o2hb_debug_create_18744 o2hb_debug_create 4 18744 NULL
96727 +__erst_read_to_erange_from_nvram_18748 __erst_read_to_erange_from_nvram 0 18748 NULL
96728 +wep_packets_read_18751 wep_packets_read 3 18751 NULL
96729 +md_compat_ioctl_18764 md_compat_ioctl 4 18764 NULL
96730 +read_file_dump_nfcal_18766 read_file_dump_nfcal 3 18766 NULL
96731 +ffs_epfile_read_18775 ffs_epfile_read 3 18775 NULL
96732 +alloc_fcdev_18780 alloc_fcdev 1 18780 NULL
96733 +fat_compat_dir_ioctl_18800 fat_compat_dir_ioctl 3 18800 NULL
96734 +ieee80211_auth_challenge_18810 ieee80211_auth_challenge 3 18810 NULL
96735 +madvise_hwpoison_18812 madvise_hwpoison 2 18812 NULL
96736 +setup_ioapic_irq_18813 setup_ioapic_irq 1 18813 NULL
96737 +sys_modify_ldt_18824 sys_modify_ldt 3 18824 NULL
96738 +mtf_test_write_18844 mtf_test_write 3 18844 NULL
96739 +drm_ht_create_18853 drm_ht_create 2 18853 NULL
96740 +sctp_setsockopt_events_18862 sctp_setsockopt_events 3 18862 NULL
96741 +ieee80211_if_read_element_ttl_18869 ieee80211_if_read_element_ttl 3 18869 NULL
96742 +xlog_find_verify_log_record_18870 xlog_find_verify_log_record 2 18870 NULL
96743 +___alloc_bootmem_node_18882 ___alloc_bootmem_node 2-3 18882 NULL
96744 +width_to_agaw_18883 width_to_agaw 0-1 18883 NULL
96745 +ceph_setxattr_18913 ceph_setxattr 4 18913 NULL
96746 +mangle_packet_18920 mangle_packet 7-9 18920 NULL
96747 +snapshot_write_next_18937 snapshot_write_next 0 18937 NULL
96748 +__nla_reserve_18974 __nla_reserve 3 18974 NULL
96749 +gfn_to_pfn_atomic_18981 gfn_to_pfn_atomic 2 18981 NULL
96750 +find_dirtiest_idx_leb_19001 find_dirtiest_idx_leb 0 19001 NULL
96751 +layout_in_gaps_19006 layout_in_gaps 2 19006 NULL
96752 +huge_page_size_19008 huge_page_size 0 19008 NULL
96753 +usbdev_compat_ioctl_19026 usbdev_compat_ioctl 3 19026 NULL
96754 +prepare_highmem_image_19028 prepare_highmem_image 0 19028 NULL
96755 +revalidate_19043 revalidate 2 19043 NULL
96756 +drm_fb_helper_init_19044 drm_fb_helper_init 3-4 19044 NULL
96757 +create_gpadl_header_19064 create_gpadl_header 2 19064 NULL
96758 +ieee80211_key_alloc_19065 ieee80211_key_alloc 3 19065 NULL
96759 +sys_process_vm_readv_19090 sys_process_vm_readv 3-5 19090 NULL nohasharray
96760 +brcmf_usbdev_qinit_19090 brcmf_usbdev_qinit 2 19090 &sys_process_vm_readv_19090
96761 +sta_last_seq_ctrl_read_19106 sta_last_seq_ctrl_read 3 19106 NULL
96762 +cifs_readv_from_socket_19109 cifs_readv_from_socket 3 19109 NULL
96763 +skb_gro_offset_19123 skb_gro_offset 0 19123 NULL
96764 +ext4_inode_table_19125 ext4_inode_table 0 19125 NULL
96765 +snd_als4k_iobase_readl_19136 snd_als4k_iobase_readl 0 19136 NULL
96766 +alloc_irdadev_19140 alloc_irdadev 1 19140 NULL
96767 +sleep_auth_read_19159 sleep_auth_read 3 19159 NULL
96768 +smk_write_access2_19170 smk_write_access2 3 19170 NULL
96769 +iwl_dbgfs_reply_tx_error_read_19205 iwl_dbgfs_reply_tx_error_read 3 19205 NULL
96770 +vmw_unlocked_ioctl_19212 vmw_unlocked_ioctl 2 19212 NULL
96771 +__copy_to_user_inatomic_19214 __copy_to_user_inatomic 3 19214 NULL
96772 +dev_counters_read_19216 dev_counters_read 3 19216 NULL
96773 +wbcir_tx_19219 wbcir_tx 3 19219 NULL
96774 +gsi_to_irq_19220 gsi_to_irq 0-1 19220 NULL
96775 +snd_mask_max_19224 snd_mask_max 0 19224 NULL
96776 +bio_alloc_mddev_19238 bio_alloc_mddev 2 19238 NULL
96777 +sys_fcntl_19267 sys_fcntl 3 19267 NULL
96778 +il_dbgfs_rxon_filter_flags_read_19281 il_dbgfs_rxon_filter_flags_read 3 19281 NULL
96779 +io_mapping_map_wc_19284 io_mapping_map_wc 2 19284 NULL
96780 +qc_capture_19298 qc_capture 3 19298 NULL
96781 +ocfs2_prepare_inode_for_refcount_19303 ocfs2_prepare_inode_for_refcount 3-4 19303 NULL
96782 +event_tx_stuck_read_19305 event_tx_stuck_read 3 19305 NULL
96783 +gfn_to_gpa_19320 gfn_to_gpa 0-1 19320 NULL
96784 +debug_read_19322 debug_read 3 19322 NULL
96785 +cfg80211_inform_bss_19332 cfg80211_inform_bss 8 19332 NULL
96786 +read_zero_19366 read_zero 3 19366 NULL
96787 +interpret_user_input_19393 interpret_user_input 2 19393 NULL
96788 +get_n_events_by_type_19401 get_n_events_by_type 0 19401 NULL
96789 +dvbdmx_write_19423 dvbdmx_write 3 19423 NULL
96790 +__phys_addr_19434 __phys_addr 0 19434 NULL
96791 +xfrm_alg_auth_len_19454 xfrm_alg_auth_len 0 19454 NULL
96792 +hpet_compat_ioctl_19455 hpet_compat_ioctl 3 19455 NULL
96793 +gnet_stats_copy_19458 gnet_stats_copy 4 19458 NULL
96794 +sky2_read16_19475 sky2_read16 0 19475 NULL
96795 +efivar_create_sysfs_entry_19485 efivar_create_sysfs_entry 2 19485 NULL
96796 +ext4_add_new_descs_19509 ext4_add_new_descs 3 19509 NULL
96797 +skb_realloc_headroom_19516 skb_realloc_headroom 2 19516 NULL
96798 +dev_alloc_skb_19517 dev_alloc_skb 1 19517 NULL
96799 +nfc_llcp_build_tlv_19536 nfc_llcp_build_tlv 3 19536 NULL
96800 +gfn_to_index_19558 gfn_to_index 0-1-3-2 19558 NULL
96801 +ocfs2_control_message_19564 ocfs2_control_message 3 19564 NULL
96802 +ieee80211_if_read_tkip_mic_test_19565 ieee80211_if_read_tkip_mic_test 3 19565 NULL nohasharray
96803 +wlcore_hw_get_rx_packet_len_19565 wlcore_hw_get_rx_packet_len 0 19565 &ieee80211_if_read_tkip_mic_test_19565
96804 +nfsd_read_19568 nfsd_read 5 19568 NULL
96805 +cgroup_read_s64_19570 cgroup_read_s64 5 19570 NULL
96806 +bm_status_read_19583 bm_status_read 3 19583 NULL
96807 +batadv_tt_update_orig_19586 batadv_tt_update_orig 4 19586 NULL
96808 +load_xattr_datum_19594 load_xattr_datum 0 19594 NULL
96809 +usbvision_rvmalloc_19655 usbvision_rvmalloc 1 19655 NULL
96810 +LoadBitmap_19658 LoadBitmap 2 19658 NULL
96811 +usbnet_write_cmd_19679 usbnet_write_cmd 7 19679 NULL
96812 +bio_detain_19690 bio_detain 2 19690 NULL
96813 +read_reg_19723 read_reg 0 19723 NULL
96814 +wm8350_block_write_19727 wm8350_block_write 3-2 19727 NULL
96815 +memcpy_toiovecend_19736 memcpy_toiovecend 4-3 19736 NULL
96816 +snd_es1968_get_dma_ptr_19747 snd_es1968_get_dma_ptr 0 19747 NULL
96817 +p9_client_read_19750 p9_client_read 5 19750 NULL
96818 +pnpbios_proc_write_19758 pnpbios_proc_write 3 19758 NULL
96819 +ocfs2_readpages_19759 ocfs2_readpages 4 19759 NULL
96820 +jffs2_acl_from_medium_19762 jffs2_acl_from_medium 2 19762 NULL
96821 +__set_print_fmt_19776 __set_print_fmt 0 19776 NULL
96822 +saa7146_vmalloc_build_pgtable_19780 saa7146_vmalloc_build_pgtable 2 19780 NULL
96823 +irda_setsockopt_19824 irda_setsockopt 5 19824 NULL
96824 +pcpu_next_unpop_19831 pcpu_next_unpop 4 19831 NULL
96825 +vfs_getxattr_19832 vfs_getxattr 0 19832 NULL
96826 +security_context_to_sid_19839 security_context_to_sid 2 19839 NULL
96827 +crypt_alloc_buffer_19846 crypt_alloc_buffer 2 19846 NULL
96828 +cfg80211_mlme_register_mgmt_19852 cfg80211_mlme_register_mgmt 5 19852 NULL
96829 +__nla_put_19857 __nla_put 3 19857 NULL
96830 +ip6gre_err_19869 ip6gre_err 5 19869 NULL
96831 +mrp_request_join_19882 mrp_request_join 4 19882 NULL
96832 +aes_decrypt_interrupt_read_19910 aes_decrypt_interrupt_read 3 19910 NULL
96833 +ps_upsd_max_apturn_read_19918 ps_upsd_max_apturn_read 3 19918 NULL
96834 +cgroup_task_count_19930 cgroup_task_count 0 19930 NULL
96835 +iwl_dbgfs_rx_queue_read_19943 iwl_dbgfs_rx_queue_read 3 19943 NULL
96836 +attach_hdlc_protocol_19986 attach_hdlc_protocol 3 19986 NULL
96837 +diva_um_idi_read_20003 diva_um_idi_read 0 20003 NULL
96838 +split_scan_timeout_read_20029 split_scan_timeout_read 3 20029 NULL
96839 +alloc_ieee80211_20063 alloc_ieee80211 1 20063 NULL
96840 +rawv6_sendmsg_20080 rawv6_sendmsg 4 20080 NULL
96841 +fuse_conn_limit_read_20084 fuse_conn_limit_read 3 20084 NULL
96842 +team_options_register_20091 team_options_register 3 20091 NULL
96843 +qla2x00_adjust_sdev_qdepth_up_20097 qla2x00_adjust_sdev_qdepth_up 2 20097 NULL
96844 +hptiop_adjust_disk_queue_depth_20122 hptiop_adjust_disk_queue_depth 2 20122 NULL
96845 +tomoyo_commit_ok_20167 tomoyo_commit_ok 2 20167 NULL
96846 +read_flush_pipefs_20171 read_flush_pipefs 3 20171 NULL
96847 +wep_addr_key_count_read_20174 wep_addr_key_count_read 3 20174 NULL
96848 +create_trace_probe_20175 create_trace_probe 1 20175 NULL
96849 +crystalhd_map_dio_20181 crystalhd_map_dio 3 20181 NULL
96850 +udf_bitmap_new_block_20214 udf_bitmap_new_block 4 20214 NULL
96851 +pvr2_ctrl_value_to_sym_20229 pvr2_ctrl_value_to_sym 5 20229 NULL
96852 +rose_sendmsg_20249 rose_sendmsg 4 20249 NULL
96853 +tm6000_i2c_send_regs_20250 tm6000_i2c_send_regs 5 20250 NULL
96854 +pcpu_alloc_20255 pcpu_alloc 1-2 20255 NULL
96855 +_rtl92s_get_h2c_cmdlen_20312 _rtl92s_get_h2c_cmdlen 0 20312 NULL
96856 +tx_tx_burst_programmed_read_20320 tx_tx_burst_programmed_read 3 20320 NULL
96857 +snd_cs4281_BA1_read_20323 snd_cs4281_BA1_read 5 20323 NULL
96858 +gfs2_glock_nq_m_20347 gfs2_glock_nq_m 1 20347 NULL
96859 +handle_arr_calc_size_20355 handle_arr_calc_size 0-1 20355 NULL
96860 +qla82xx_pci_mem_read_direct_20368 qla82xx_pci_mem_read_direct 2 20368 NULL
96861 +smk_set_cipso_20379 smk_set_cipso 3 20379 NULL
96862 +u64_to_uptr_20384 u64_to_uptr 1 20384 NULL
96863 +snd_nm256_readl_20394 snd_nm256_readl 0 20394 NULL
96864 +__kfifo_from_user_20399 __kfifo_from_user 3 20399 NULL
96865 +xen_create_contiguous_region_20457 xen_create_contiguous_region 1 20457 NULL
96866 +nfs3_setxattr_20458 nfs3_setxattr 4 20458 NULL
96867 +compat_ipv6_setsockopt_20468 compat_ipv6_setsockopt 5 20468 NULL
96868 +read_buf_20469 read_buf 2 20469 NULL
96869 +btrfs_get_32_20476 btrfs_get_32 0 20476 NULL
96870 +fast_user_write_20494 fast_user_write 5 20494 NULL
96871 +ocfs2_db_frozen_trigger_20503 ocfs2_db_frozen_trigger 4 20503 NULL nohasharray
96872 +hidraw_report_event_20503 hidraw_report_event 3 20503 &ocfs2_db_frozen_trigger_20503
96873 +pcpu_alloc_area_20511 pcpu_alloc_area 0-3 20511 NULL
96874 +pcpu_depopulate_chunk_20517 pcpu_depopulate_chunk 2-3 20517 NULL
96875 +xfs_iext_realloc_direct_20521 xfs_iext_realloc_direct 2 20521 NULL
96876 +drbd_bm_resize_20522 drbd_bm_resize 2 20522 NULL
96877 +amd_create_gatt_pages_20537 amd_create_gatt_pages 1 20537 NULL
96878 +scsi_report_opcode_20551 scsi_report_opcode 3 20551 NULL
96879 +venus_create_20555 venus_create 4 20555 NULL
96880 +btrfs_super_log_root_20565 btrfs_super_log_root 0 20565 NULL
96881 +crypto_ahash_reqsize_20569 crypto_ahash_reqsize 0 20569 NULL
96882 +i915_max_freq_read_20581 i915_max_freq_read 3 20581 NULL
96883 +batadv_tt_append_diff_20588 batadv_tt_append_diff 4 20588 NULL
96884 +lirc_write_20604 lirc_write 3 20604 NULL
96885 +qib_qsfp_write_20614 qib_qsfp_write 0-4-2 20614 NULL
96886 +snd_pcm_oss_prepare_20641 snd_pcm_oss_prepare 0 20641 NULL
96887 +kfifo_copy_to_user_20646 kfifo_copy_to_user 3 20646 NULL
96888 +cpulist_scnprintf_20648 cpulist_scnprintf 0-2 20648 NULL
96889 +oz_add_farewell_20652 oz_add_farewell 5 20652 NULL
96890 +oz_cdev_read_20659 oz_cdev_read 3 20659 NULL
96891 +snd_hdsp_playback_copy_20676 snd_hdsp_playback_copy 5 20676 NULL
96892 +get_user_page_nowait_20682 get_user_page_nowait 3 20682 NULL nohasharray
96893 +dvb_dmxdev_buffer_read_20682 dvb_dmxdev_buffer_read 0-4 20682 &get_user_page_nowait_20682
96894 +cpumask_size_20683 cpumask_size 0 20683 NULL
96895 +btrfs_node_blockptr_20685 btrfs_node_blockptr 0 20685 NULL
96896 +gru_vtop_20689 gru_vtop 2 20689 NULL
96897 +read_file_tgt_int_stats_20697 read_file_tgt_int_stats 3 20697 NULL
96898 +__maestro_read_20700 __maestro_read 0 20700 NULL
96899 +cipso_v4_gentag_rng_20703 cipso_v4_gentag_rng 0 20703 NULL
96900 +pcpu_page_first_chunk_20712 pcpu_page_first_chunk 1 20712 NULL
96901 +ocfs2_read_xattr_bucket_20722 ocfs2_read_xattr_bucket 0 20722 NULL
96902 +security_context_to_sid_force_20724 security_context_to_sid_force 2 20724 NULL
96903 +vring_add_indirect_20737 vring_add_indirect 3-4 20737 NULL
96904 +io_apic_set_pci_routing_20740 io_apic_set_pci_routing 2 20740 NULL
96905 +vol_cdev_direct_write_20751 vol_cdev_direct_write 3 20751 NULL
96906 +ocfs2_align_bytes_to_clusters_20754 ocfs2_align_bytes_to_clusters 2 20754 NULL
96907 +brcmf_p2p_escan_20763 brcmf_p2p_escan 2 20763 NULL
96908 +ubi_io_read_20767 ubi_io_read 0 20767 NULL
96909 +fb_alloc_cmap_gfp_20792 fb_alloc_cmap_gfp 2 20792 NULL
96910 +iommu_range_alloc_20794 iommu_range_alloc 3 20794 NULL
96911 +iwl_dbgfs_rxon_flags_read_20795 iwl_dbgfs_rxon_flags_read 3 20795 NULL
96912 +sys_sendto_20809 sys_sendto 6 20809 NULL
96913 +strndup_user_20819 strndup_user 2 20819 NULL
96914 +calc_layout_20829 calc_layout 3 20829 NULL
96915 +wl1271_format_buffer_20834 wl1271_format_buffer 2 20834 NULL
96916 +uvc_alloc_entity_20836 uvc_alloc_entity 3-4 20836 NULL
96917 +snd_pcm_capture_avail_20867 snd_pcm_capture_avail 0 20867 NULL
96918 +ocfs2_bmap_20874 ocfs2_bmap 2 20874 NULL
96919 +skb_tail_pointer_20878 skb_tail_pointer 0 20878 NULL
96920 +sisusb_send_packet_20891 sisusb_send_packet 2 20891 NULL
96921 +key_icverrors_read_20895 key_icverrors_read 3 20895 NULL
96922 +vfio_msi_enable_20906 vfio_msi_enable 2 20906 NULL
96923 +compat_sys_readv_20911 compat_sys_readv 3 20911 NULL
96924 +htable_bits_20933 htable_bits 0 20933 NULL
96925 +altera_set_ir_post_20948 altera_set_ir_post 2 20948 NULL
96926 +rx_rx_phy_hdr_read_20950 rx_rx_phy_hdr_read 3 20950 NULL
96927 +nfs_map_name_to_uid_20962 nfs_map_name_to_uid 3 20962 NULL
96928 +snd_rme9652_playback_copy_20970 snd_rme9652_playback_copy 5 20970 NULL
96929 +brcmf_tx_frame_20978 brcmf_tx_frame 3 20978 NULL
96930 +alg_setsockopt_20985 alg_setsockopt 5 20985 NULL
96931 +ocfs2_free_clusters_21001 ocfs2_free_clusters 4 21001 NULL
96932 +ceph_osdc_new_request_21017 ceph_osdc_new_request 14-4 21017 NULL
96933 +btrfs_inode_ref_name_len_21024 btrfs_inode_ref_name_len 0 21024 NULL
96934 +rx_defrag_tkip_called_read_21031 rx_defrag_tkip_called_read 3 21031 NULL
96935 +lbs_threshold_read_21046 lbs_threshold_read 5 21046 NULL
96936 +proc_fault_inject_write_21058 proc_fault_inject_write 3 21058 NULL
96937 +event_calibration_read_21083 event_calibration_read 3 21083 NULL
96938 +compat_sock_ioctl_trans_21092 compat_sock_ioctl_trans 4 21092 NULL
96939 +multipath_status_21094 multipath_status 5 21094 NULL
96940 +__cfg80211_send_disassoc_21096 __cfg80211_send_disassoc 3 21096 NULL
96941 +ext2_valid_block_bitmap_21101 ext2_valid_block_bitmap 3 21101 NULL
96942 +ath6kl_send_go_probe_resp_21113 ath6kl_send_go_probe_resp 3 21113 NULL
96943 +bitset_size_in_bytes_21124 bitset_size_in_bytes 0-1 21124 NULL
96944 +i2400m_rx_trace_21127 i2400m_rx_trace 3 21127 NULL
96945 +tps6586x_irq_init_21144 tps6586x_irq_init 3 21144 NULL
96946 +ocfs2_block_check_validate_21149 ocfs2_block_check_validate 2 21149 NULL
96947 +cx18_v4l2_read_21196 cx18_v4l2_read 3 21196 NULL
96948 +ipc_rcu_alloc_21208 ipc_rcu_alloc 1 21208 NULL
96949 +_ocfs2_free_clusters_21220 _ocfs2_free_clusters 4 21220 NULL
96950 +get_numpages_21227 get_numpages 0-1-2 21227 NULL
96951 +input_ff_create_21240 input_ff_create 2 21240 NULL
96952 +cfg80211_notify_new_peer_candidate_21242 cfg80211_notify_new_peer_candidate 4 21242 NULL
96953 +ocfs2_blocks_for_bytes_21268 ocfs2_blocks_for_bytes 0-2 21268 NULL
96954 +ip_vs_icmp_xmit_21269 ip_vs_icmp_xmit 4 21269 NULL
96955 +make_alloc_exact_21279 make_alloc_exact 1-3 21279 NULL
96956 +vmw_gmr2_bind_21305 vmw_gmr2_bind 3 21305 NULL
96957 +do_msg_fill_21307 do_msg_fill 3 21307 NULL
96958 +add_res_range_21310 add_res_range 4 21310 NULL
96959 +get_zeroed_page_21322 get_zeroed_page 0 21322 NULL
96960 +ftrace_profile_read_21327 ftrace_profile_read 3 21327 NULL
96961 +gfs2_ea_get_copy_21353 gfs2_ea_get_copy 0 21353 NULL
96962 +max77693_irq_domain_map_21357 max77693_irq_domain_map 2 21357 NULL
96963 +alloc_orinocodev_21371 alloc_orinocodev 1 21371 NULL
96964 +video_ioctl2_21380 video_ioctl2 2 21380 NULL
96965 +diva_get_driver_dbg_mask_21399 diva_get_driver_dbg_mask 0 21399 NULL
96966 +snd_m3_inw_21406 snd_m3_inw 0 21406 NULL
96967 +snapshot_read_next_21426 snapshot_read_next 0 21426 NULL
96968 +tcp_bound_to_half_wnd_21429 tcp_bound_to_half_wnd 0-2 21429 NULL
96969 +tracing_saved_cmdlines_read_21434 tracing_saved_cmdlines_read 3 21434 NULL
96970 +aggr_size_tx_agg_vs_rate_read_21438 aggr_size_tx_agg_vs_rate_read 3 21438 NULL
96971 +__ertm_hdr_size_21450 __ertm_hdr_size 0 21450 NULL
96972 +concat_writev_21451 concat_writev 3 21451 NULL
96973 +read_file_xmit_21487 read_file_xmit 3 21487 NULL
96974 +mmc_alloc_sg_21504 mmc_alloc_sg 1 21504 NULL
96975 +btrfs_file_aio_write_21520 btrfs_file_aio_write 4 21520 NULL
96976 +il_dbgfs_stations_read_21532 il_dbgfs_stations_read 3 21532 NULL
96977 +cipso_v4_map_cat_enum_hton_21540 cipso_v4_map_cat_enum_hton 0 21540 NULL
96978 +rxrpc_send_data_21553 rxrpc_send_data 5 21553 NULL
96979 +rx_rx_beacon_early_term_read_21559 rx_rx_beacon_early_term_read 3 21559 NULL
96980 +xfs_buf_read_uncached_21585 xfs_buf_read_uncached 3 21585 NULL
96981 +ocfs2_acl_from_xattr_21604 ocfs2_acl_from_xattr 2 21604 NULL
96982 +__jfs_getxattr_21631 __jfs_getxattr 0 21631 NULL
96983 +validate_nnode_21638 validate_nnode 0 21638 NULL
96984 +__irq_alloc_descs_21639 __irq_alloc_descs 2-1-3 21639 NULL
96985 +carl9170_rx_copy_data_21656 carl9170_rx_copy_data 2 21656 NULL
96986 +atalk_sendmsg_21677 atalk_sendmsg 4 21677 NULL
96987 +ocfs2_xattr_get_nolock_21678 ocfs2_xattr_get_nolock 0 21678 NULL
96988 +regmap_register_patch_21681 regmap_register_patch 3 21681 NULL
96989 +rtllib_alloc_txb_21687 rtllib_alloc_txb 1-2 21687 NULL
96990 +evdev_ioctl_handler_21705 evdev_ioctl_handler 2 21705 NULL
96991 +reiserfs_allocate_list_bitmaps_21732 reiserfs_allocate_list_bitmaps 3 21732 NULL
96992 +vm_brk_21739 vm_brk 1 21739 NULL
96993 +__nf_nat_mangle_tcp_packet_21744 __nf_nat_mangle_tcp_packet 8-6 21744 NULL
96994 +mthca_alloc_init_21754 mthca_alloc_init 2 21754 NULL
96995 +gen_pool_add_21776 gen_pool_add 3 21776 NULL
96996 +xfs_da_grow_inode_int_21785 xfs_da_grow_inode_int 3 21785 NULL
96997 +__ioremap_caller_21800 __ioremap_caller 1-2 21800 NULL
96998 +min_odd_21802 min_odd 0 21802 NULL
96999 +dvb_generic_ioctl_21810 dvb_generic_ioctl 2 21810 NULL
97000 +wm8994_request_irq_21822 wm8994_request_irq 2 21822 NULL
97001 +oom_adj_read_21847 oom_adj_read 3 21847 NULL
97002 +acpi_tb_check_xsdt_21862 acpi_tb_check_xsdt 1 21862 NULL
97003 +lpfc_idiag_extacc_avail_get_21865 lpfc_idiag_extacc_avail_get 0-3 21865 NULL
97004 +brcms_debugfs_hardware_read_21867 brcms_debugfs_hardware_read 3 21867 NULL
97005 +sisusbcon_bmove_21873 sisusbcon_bmove 6-5-7 21873 NULL nohasharray
97006 +tcp_cookie_size_check_21873 tcp_cookie_size_check 0-1 21873 &sisusbcon_bmove_21873
97007 +xen_swiotlb_map_page_21886 xen_swiotlb_map_page 3 21886 NULL
97008 +__alloc_reserved_percpu_21895 __alloc_reserved_percpu 1-2 21895 NULL
97009 +rio_destid_first_21900 rio_destid_first 0 21900 NULL
97010 +dbAllocCtl_21911 dbAllocCtl 0 21911 NULL
97011 +qsfp_1_read_21915 qsfp_1_read 3 21915 NULL
97012 +security_mmap_addr_21970 security_mmap_addr 0 21970 NULL
97013 +alloc_ldt_21972 alloc_ldt 2 21972 NULL
97014 +rxpipe_descr_host_int_trig_rx_data_read_22001 rxpipe_descr_host_int_trig_rx_data_read 3 22001 NULL nohasharray
97015 +compat_rw_copy_check_uvector_22001 compat_rw_copy_check_uvector 0-3 22001 &rxpipe_descr_host_int_trig_rx_data_read_22001
97016 +btrfs_get_16_22023 btrfs_get_16 0 22023 NULL
97017 +zd_usb_read_fw_22049 zd_usb_read_fw 4 22049 NULL
97018 +ieee80211_if_fmt_dropped_frames_ttl_22054 ieee80211_if_fmt_dropped_frames_ttl 3 22054 NULL
97019 +btrfs_reloc_clone_csums_22077 btrfs_reloc_clone_csums 2 22077 NULL
97020 +write_opcode_22082 write_opcode 2 22082 NULL
97021 +mem_rw_22085 mem_rw 3 22085 NULL
97022 +is_swbp_at_addr_22089 is_swbp_at_addr 2 22089 NULL
97023 +lowpan_fragment_xmit_22095 lowpan_fragment_xmit 3-4 22095 NULL
97024 +sys_remap_file_pages_22124 sys_remap_file_pages 1 22124 NULL
97025 +__bitmap_size_22138 __bitmap_size 0 22138 NULL
97026 +compat_insn_22142 compat_insn 2 22142 NULL
97027 +do_tcp_sendpages_22155 do_tcp_sendpages 4 22155 NULL
97028 +__kfifo_alloc_22173 __kfifo_alloc 3 22173 NULL
97029 +fls_22210 fls 0 22210 NULL
97030 +mem_write_22232 mem_write 3 22232 NULL
97031 +p9_virtio_zc_request_22240 p9_virtio_zc_request 6-5 22240 NULL
97032 +atomic64_xchg_22246 atomic64_xchg 0 22246 NULL
97033 +compat_process_vm_rw_22254 compat_process_vm_rw 3-5 22254 NULL
97034 +__btrfs_direct_write_22273 __btrfs_direct_write 4 22273 NULL
97035 +queue_max_sectors_22280 queue_max_sectors 0 22280 NULL
97036 +pci_vpd_srdt_size_22300 pci_vpd_srdt_size 0 22300 NULL nohasharray
97037 +__tun_chr_ioctl_22300 __tun_chr_ioctl 4 22300 &pci_vpd_srdt_size_22300
97038 +extend_brk_22301 extend_brk 0 22301 NULL
97039 +mesh_table_alloc_22305 mesh_table_alloc 1 22305 NULL
97040 +get_segment_base_22324 get_segment_base 0 22324 NULL
97041 +radix_tree_find_next_bit_22334 radix_tree_find_next_bit 2-3 22334 NULL
97042 +atomic_read_22342 atomic_read 0 22342 NULL
97043 +mlx4_db_alloc_22358 mlx4_db_alloc 3 22358 NULL
97044 +irq_reserve_irq_22360 irq_reserve_irq 1 22360 NULL nohasharray
97045 +memcg_size_22360 memcg_size 0 22360 &irq_reserve_irq_22360
97046 +snd_pcm_alsa_frames_22363 snd_pcm_alsa_frames 2 22363 NULL
97047 +tps6586x_gpio_to_irq_22365 tps6586x_gpio_to_irq 2 22365 NULL
97048 +evdev_ioctl_22371 evdev_ioctl 2 22371 NULL
97049 +alloc_large_system_hash_22391 alloc_large_system_hash 2 22391 NULL
97050 +btmrvl_psmode_read_22395 btmrvl_psmode_read 3 22395 NULL
97051 +crash_shrink_memory_22401 crash_shrink_memory 1 22401 NULL
97052 +zoran_write_22404 zoran_write 3 22404 NULL
97053 +queue_reply_22416 queue_reply 3 22416 NULL
97054 +__set_enter_print_fmt_22431 __set_enter_print_fmt 0 22431 NULL
97055 +queue_max_segments_22441 queue_max_segments 0 22441 NULL
97056 +handle_received_packet_22457 handle_received_packet 3 22457 NULL
97057 +mem_cgroup_read_22461 mem_cgroup_read 5 22461 NULL
97058 +batadv_check_unicast_packet_22468 batadv_check_unicast_packet 3 22468 NULL
97059 +cache_write_procfs_22491 cache_write_procfs 3 22491 NULL
97060 +mp_find_ioapic_pin_22499 mp_find_ioapic_pin 0-2 22499 NULL
97061 +mutex_lock_interruptible_22505 mutex_lock_interruptible 0 22505 NULL
97062 +ip4_addr_string_22511 ip4_addr_string 0 22511 NULL
97063 +swiotlb_tbl_unmap_single_22522 swiotlb_tbl_unmap_single 2 22522 NULL nohasharray
97064 +usb_dump_config_descriptor_22522 usb_dump_config_descriptor 0 22522 &swiotlb_tbl_unmap_single_22522
97065 +pskb_may_pull_22546 pskb_may_pull 2 22546 NULL
97066 +ocfs2_read_extent_block_22550 ocfs2_read_extent_block 0 22550 NULL
97067 +atomic_long_read_unchecked_22551 atomic_long_read_unchecked 0 22551 NULL
97068 +agp_alloc_page_array_22554 agp_alloc_page_array 1 22554 NULL
97069 +dbFindCtl_22587 dbFindCtl 0 22587 NULL
97070 +snapshot_read_22601 snapshot_read 3 22601 NULL
97071 +remove_breakpoint_22628 remove_breakpoint 3 22628 NULL
97072 +sctp_setsockopt_connectx_old_22631 sctp_setsockopt_connectx_old 3 22631 NULL
97073 +ide_core_cp_entry_22636 ide_core_cp_entry 3 22636 NULL
97074 +wl1271_rx_filter_get_fields_size_22638 wl1271_rx_filter_get_fields_size 0 22638 NULL
97075 +pwr_wake_on_timer_exp_read_22640 pwr_wake_on_timer_exp_read 3 22640 NULL
97076 +iwl_dbgfs_calib_disabled_read_22649 iwl_dbgfs_calib_disabled_read 3 22649 NULL
97077 +ubifs_leb_write_22679 ubifs_leb_write 4-5 22679 NULL
97078 +ocfs2_get_block_22687 ocfs2_get_block 2 22687 NULL
97079 +compat_fd_ioctl_22694 compat_fd_ioctl 4 22694 NULL
97080 +map_22700 map 2 22700 NULL
97081 +alloc_libipw_22708 alloc_libipw 1 22708 NULL
97082 +brcmf_sdbrcm_read_control_22721 brcmf_sdbrcm_read_control 3 22721 NULL
97083 +cx18_copy_buf_to_user_22735 cx18_copy_buf_to_user 4 22735 NULL
97084 +ceph_decode_32_22738 ceph_decode_32 0 22738 NULL
97085 +iio_debugfs_write_reg_22742 iio_debugfs_write_reg 3 22742 NULL
97086 +print_frame_22769 print_frame 0 22769 NULL
97087 +ftrace_arch_read_dyn_info_22773 ftrace_arch_read_dyn_info 0 22773 NULL
97088 +compat_blkdev_ioctl_22841 compat_blkdev_ioctl 3 22841 NULL
97089 +clone_bio_integrity_22842 clone_bio_integrity 4 22842 NULL
97090 +read_file_rcstat_22854 read_file_rcstat 3 22854 NULL
97091 +do_atm_iobuf_22857 do_atm_iobuf 3 22857 NULL
97092 +create_attr_set_22861 create_attr_set 1 22861 NULL
97093 +vmw_execbuf_process_22885 vmw_execbuf_process 5 22885 NULL
97094 +usblp_new_writeurb_22894 usblp_new_writeurb 2 22894 NULL
97095 +mdc800_device_read_22896 mdc800_device_read 3 22896 NULL
97096 +policy_emit_config_values_22900 policy_emit_config_values 3 22900 NULL
97097 +pcpu_mem_zalloc_22948 pcpu_mem_zalloc 1 22948 NULL
97098 +alloc_sglist_22960 alloc_sglist 1-2-3 22960 NULL
97099 +caif_seqpkt_sendmsg_22961 caif_seqpkt_sendmsg 4 22961 NULL
97100 +vme_get_size_22964 vme_get_size 0 22964 NULL
97101 +tx_frag_key_not_found_read_22971 tx_frag_key_not_found_read 3 22971 NULL
97102 +page_table_range_init_count_22977 page_table_range_init_count 0 22977 NULL
97103 +usb_get_langid_22983 usb_get_langid 0 22983 NULL
97104 +set_msr_hyperv_22985 set_msr_hyperv 3 22985 NULL
97105 +remote_settings_file_write_22987 remote_settings_file_write 3 22987 NULL
97106 +viafb_dvp0_proc_write_23023 viafb_dvp0_proc_write 3 23023 NULL
97107 +cifs_local_to_utf16_bytes_23025 cifs_local_to_utf16_bytes 0 23025 NULL
97108 +st_status_23032 st_status 5 23032 NULL
97109 +nv50_disp_chan_create__23056 nv50_disp_chan_create_ 5 23056 NULL
97110 +reiserfs_add_entry_23062 reiserfs_add_entry 4 23062 NULL
97111 +kvm_mmu_gva_to_gpa_write_23075 kvm_mmu_gva_to_gpa_write 0 23075 NULL
97112 +vm_map_ram_23078 vm_map_ram 2 23078 NULL nohasharray
97113 +raw_sendmsg_23078 raw_sendmsg 4 23078 &vm_map_ram_23078
97114 +qla4_82xx_pci_mem_read_2M_23081 qla4_82xx_pci_mem_read_2M 2 23081 NULL
97115 +isr_tx_procs_read_23084 isr_tx_procs_read 3 23084 NULL
97116 +lnw_gpio_irq_map_23087 lnw_gpio_irq_map 2 23087 NULL
97117 +rt2x00debug_write_eeprom_23091 rt2x00debug_write_eeprom 3 23091 NULL
97118 +fls_long_23096 fls_long 0 23096 NULL
97119 +ntfs_ucstonls_23097 ntfs_ucstonls 3-5 23097 NULL
97120 +pipe_iov_copy_from_user_23102 pipe_iov_copy_from_user 3 23102 NULL
97121 +mwl8k_cmd_set_beacon_23110 mwl8k_cmd_set_beacon 4 23110 NULL
97122 +nl80211_send_rx_auth_23111 nl80211_send_rx_auth 4 23111 NULL
97123 +__clear_user_23118 __clear_user 0 23118 NULL
97124 +dm_write_async_23120 dm_write_async 3 23120 NULL
97125 +drm_mode_create_tv_properties_23122 drm_mode_create_tv_properties 2 23122 NULL
97126 +ca91cx42_master_set_23146 ca91cx42_master_set 4 23146 NULL
97127 +read_file_ani_23161 read_file_ani 3 23161 NULL
97128 +ioremap_23172 ioremap 1-2 23172 NULL
97129 +usblp_write_23178 usblp_write 3 23178 NULL
97130 +msnd_fifo_alloc_23179 msnd_fifo_alloc 2 23179 NULL
97131 +gss_pipe_downcall_23182 gss_pipe_downcall 3 23182 NULL
97132 +ieee80211_get_mesh_hdrlen_23183 ieee80211_get_mesh_hdrlen 0 23183 NULL
97133 +fix_unclean_leb_23188 fix_unclean_leb 3 23188 NULL
97134 +mpi_alloc_limb_space_23190 mpi_alloc_limb_space 1 23190 NULL
97135 +convert_ip_to_linear_23198 convert_ip_to_linear 0 23198 NULL
97136 +pm80x_free_irq_23210 pm80x_free_irq 2 23210 NULL nohasharray
97137 +compat_rawv6_ioctl_23210 compat_rawv6_ioctl 3 23210 &pm80x_free_irq_23210
97138 +tty_buffer_request_room_23228 tty_buffer_request_room 2 23228 NULL
97139 +xlog_get_bp_23229 xlog_get_bp 2 23229 NULL
97140 +rxrpc_client_sendmsg_23236 rxrpc_client_sendmsg 5 23236 NULL
97141 +__gfn_to_rmap_23240 __gfn_to_rmap 1-2 23240 NULL
97142 +uwb_dev_addr_print_23282 uwb_dev_addr_print 2 23282 NULL
97143 +ipv6_skip_exthdr_23283 ipv6_skip_exthdr 0-2 23283 NULL
97144 +doc_probe_23285 doc_probe 1 23285 NULL
97145 +diva_get_trace_filter_23286 diva_get_trace_filter 0 23286 NULL
97146 +perf_mmap_free_page_23302 perf_mmap_free_page 1 23302 NULL
97147 +i2cdev_write_23310 i2cdev_write 3 23310 NULL
97148 +mc13xxx_get_num_regulators_dt_23344 mc13xxx_get_num_regulators_dt 0 23344 NULL
97149 +page_readlink_23346 page_readlink 3 23346 NULL
97150 +get_dst_timing_23358 get_dst_timing 0 23358 NULL
97151 +fd_setup_write_same_buf_23369 fd_setup_write_same_buf 3 23369 NULL
97152 +iscsi_change_queue_depth_23416 iscsi_change_queue_depth 2 23416 NULL
97153 +vga_mm_r_23419 vga_mm_r 0 23419 NULL
97154 +vzalloc_node_23424 vzalloc_node 1 23424 NULL
97155 +ocfs2_zero_tail_23447 ocfs2_zero_tail 3 23447 NULL
97156 +hidraw_send_report_23449 hidraw_send_report 3 23449 NULL
97157 +linear_conf_23485 linear_conf 2 23485 NULL nohasharray
97158 +divasa_remap_pci_bar_23485 divasa_remap_pci_bar 3-4 23485 &linear_conf_23485
97159 +event_filter_read_23494 event_filter_read 3 23494 NULL
97160 +__gfn_to_hva_many_23508 __gfn_to_hva_many 0-2 23508 NULL
97161 +ima_show_measurements_count_23536 ima_show_measurements_count 3 23536 NULL
97162 +xen_allocate_irq_gsi_23546 xen_allocate_irq_gsi 1-0 23546 NULL
97163 +tcp_current_mss_23552 tcp_current_mss 0 23552 NULL
97164 +dbg_leb_change_23555 dbg_leb_change 4 23555 NULL
97165 +venus_symlink_23570 venus_symlink 4-6 23570 NULL
97166 +iwl_dbgfs_interrupt_read_23574 iwl_dbgfs_interrupt_read 3 23574 NULL
97167 +snd_interval_min_23590 snd_interval_min 0 23590 NULL
97168 +do_mmap_pgoff_23600 do_mmap_pgoff 0 23600 NULL
97169 +_alloc_cdb_cont_23609 _alloc_cdb_cont 2 23609 NULL
97170 +islpci_mgt_transaction_23610 islpci_mgt_transaction 5 23610 NULL
97171 +__i2400mu_send_barker_23652 __i2400mu_send_barker 3 23652 NULL
97172 +ext3_compat_ioctl_23659 ext3_compat_ioctl 3 23659 NULL
97173 +sInW_23663 sInW 0 23663 NULL
97174 +proc_ioctl_compat_23682 proc_ioctl_compat 2 23682 NULL
97175 +nftl_partscan_23688 nftl_partscan 0 23688 NULL
97176 +cx18_read_23699 cx18_read 3 23699 NULL
97177 +mp_config_acpi_gsi_23728 mp_config_acpi_gsi 2 23728 NULL
97178 +pack_sg_list_p_23739 pack_sg_list_p 0-2 23739 NULL
97179 +rx_rx_dropped_frame_read_23748 rx_rx_dropped_frame_read 3 23748 NULL
97180 +__kfifo_max_r_23768 __kfifo_max_r 0-2-1 23768 NULL
97181 +security_inode_getxattr_23781 security_inode_getxattr 0 23781 NULL
97182 +diva_alloc_dma_map_23798 diva_alloc_dma_map 2 23798 NULL
97183 +rx_path_reset_read_23801 rx_path_reset_read 3 23801 NULL
97184 +__earlyonly_bootmem_alloc_23824 __earlyonly_bootmem_alloc 2-3 23824 NULL
97185 +ceph_copy_page_vector_to_user_23829 ceph_copy_page_vector_to_user 3-4 23829 NULL
97186 +xfs_dir2_leaf_getdents_23841 xfs_dir2_leaf_getdents 3 23841 NULL
97187 +pgdat_end_pfn_23842 pgdat_end_pfn 0 23842 NULL
97188 +iwl_dbgfs_nvm_read_23845 iwl_dbgfs_nvm_read 3 23845 NULL
97189 +p54_init_common_23850 p54_init_common 1 23850 NULL
97190 +gart_alloc_coherent_23852 gart_alloc_coherent 2 23852 NULL
97191 +bin_to_hex_dup_23853 bin_to_hex_dup 2 23853 NULL
97192 +ocfs2_xattr_get_clusters_23857 ocfs2_xattr_get_clusters 0 23857 NULL
97193 +ieee80211_if_read_dot11MeshMaxPeerLinks_23878 ieee80211_if_read_dot11MeshMaxPeerLinks 3 23878 NULL
97194 +nes_alloc_resource_23891 nes_alloc_resource 3 23891 NULL
97195 +tipc_snprintf_23893 tipc_snprintf 2 23893 NULL
97196 +add_new_gdb_meta_bg_23911 add_new_gdb_meta_bg 3 23911 NULL nohasharray
97197 +ieee80211_if_read_hw_queues_23911 ieee80211_if_read_hw_queues 3 23911 &add_new_gdb_meta_bg_23911
97198 +f2fs_getxattr_23917 f2fs_getxattr 0 23917 NULL
97199 +ipath_reg_phys_mr_23918 ipath_reg_phys_mr 3 23918 NULL nohasharray
97200 +mpihelp_mul_karatsuba_case_23918 mpihelp_mul_karatsuba_case 5-3 23918 &ipath_reg_phys_mr_23918
97201 +kvm_read_guest_23928 kvm_read_guest 4-2 23928 NULL
97202 +__alloc_skb_23940 __alloc_skb 1 23940 NULL
97203 +uvc_endpoint_max_bpi_23944 uvc_endpoint_max_bpi 0 23944 NULL
97204 +cifs_setxattr_23957 cifs_setxattr 4 23957 NULL
97205 +zd_usb_iowrite16v_async_23984 zd_usb_iowrite16v_async 3 23984 NULL
97206 +cxgb_alloc_mem_24007 cxgb_alloc_mem 1 24007 NULL
97207 +dgrp_send_24028 dgrp_send 0-2 24028 NULL
97208 +ocfs2_mark_extent_refcounted_24035 ocfs2_mark_extent_refcounted 6 24035 NULL
97209 +adis16400_show_serial_number_24037 adis16400_show_serial_number 3 24037 NULL
97210 +afs_cell_alloc_24052 afs_cell_alloc 2 24052 NULL
97211 +blkcipher_copy_iv_24075 blkcipher_copy_iv 3 24075 NULL
97212 +vb2_fop_read_24080 vb2_fop_read 3 24080 NULL
97213 +pipeline_post_proc_swi_read_24108 pipeline_post_proc_swi_read 3 24108 NULL
97214 +request_key_auth_read_24109 request_key_auth_read 3 24109 NULL
97215 +mpu401_read_24126 mpu401_read 3 24126 NULL
97216 +irnet_ctrl_write_24139 irnet_ctrl_write 3 24139 NULL
97217 +trim_bitmaps_24158 trim_bitmaps 3 24158 NULL
97218 +set_discard_24162 set_discard 2 24162 NULL
97219 +adu_read_24177 adu_read 3 24177 NULL
97220 +safe_prepare_write_buffer_24187 safe_prepare_write_buffer 3 24187 NULL
97221 +ieee80211_if_read_dot11MeshHWMPpreqMinInterval_24208 ieee80211_if_read_dot11MeshHWMPpreqMinInterval 3 24208 NULL
97222 +efx_vf_size_24213 efx_vf_size 0 24213 NULL
97223 +tcpprobe_sprint_24222 tcpprobe_sprint 0-2 24222 NULL
97224 +pcpu_embed_first_chunk_24224 pcpu_embed_first_chunk 1-2-3 24224 NULL nohasharray
97225 +mei_amthif_read_24224 mei_amthif_read 4 24224 &pcpu_embed_first_chunk_24224
97226 +pci_num_vf_24235 pci_num_vf 0 24235 NULL
97227 +sel_read_bool_24236 sel_read_bool 3 24236 NULL
97228 +dm_cache_save_hint_24257 dm_cache_save_hint 2 24257 NULL
97229 +em28xx_alloc_urbs_24260 em28xx_alloc_urbs 4-6 24260 NULL
97230 +thin_status_24278 thin_status 5 24278 NULL
97231 +compat_sys_preadv64_24283 compat_sys_preadv64 3 24283 NULL
97232 +msg_size_24288 msg_size 0 24288 NULL
97233 +ext2_free_blocks_24292 ext2_free_blocks 2-3 24292 NULL
97234 +map_page_24298 map_page 3-4 24298 NULL
97235 +btmrvl_pscmd_read_24308 btmrvl_pscmd_read 3 24308 NULL
97236 +ath6kl_add_bss_if_needed_24317 ath6kl_add_bss_if_needed 6 24317 NULL
97237 +ocfs2_direct_IO_get_blocks_24333 ocfs2_direct_IO_get_blocks 2 24333 NULL
97238 +kzalloc_node_24352 kzalloc_node 1 24352 NULL
97239 +qla2x00_handle_queue_full_24365 qla2x00_handle_queue_full 2 24365 NULL
97240 +cfi_read_pri_24366 cfi_read_pri 3 24366 NULL
97241 +btrfs_item_size_nr_24367 btrfs_item_size_nr 0 24367 NULL
97242 +igetword_24373 igetword 0 24373 NULL
97243 +pvr2_v4l2_ioctl_24398 pvr2_v4l2_ioctl 2 24398 NULL nohasharray
97244 +getxattr_24398 getxattr 4 24398 &pvr2_v4l2_ioctl_24398
97245 +blk_update_bidi_request_24415 blk_update_bidi_request 3-4 24415 NULL
97246 +b43_debugfs_read_24425 b43_debugfs_read 3 24425 NULL
97247 +iwl_nvm_read_section_24438 iwl_nvm_read_section 0 24438 NULL
97248 +ixgbe_alloc_q_vector_24439 ixgbe_alloc_q_vector 4-6 24439 NULL
97249 +smk_user_access_24440 smk_user_access 3 24440 NULL
97250 +page_address_24444 page_address 0 24444 NULL
97251 +evdev_do_ioctl_24459 evdev_do_ioctl 2 24459 NULL
97252 +ocfs2_write_cluster_by_desc_24466 ocfs2_write_cluster_by_desc 5-6 24466 NULL
97253 +read_file_spec_scan_ctl_24491 read_file_spec_scan_ctl 3 24491 NULL
97254 +pd_video_read_24510 pd_video_read 3 24510 NULL
97255 +request_key_with_auxdata_24515 request_key_with_auxdata 4 24515 NULL
97256 +xfs_buf_get_map_24522 xfs_buf_get_map 3 24522 NULL
97257 +named_prepare_buf_24532 named_prepare_buf 2 24532 NULL
97258 +do_mpage_readpage_24536 do_mpage_readpage 3 24536 NULL
97259 +write_cache_pages_24562 write_cache_pages 0 24562 NULL
97260 +tsi148_alloc_resource_24563 tsi148_alloc_resource 2 24563 NULL
97261 +udf_compute_nr_groups_24594 udf_compute_nr_groups 0 24594 NULL
97262 +count_preds_24600 count_preds 0 24600 NULL
97263 +sensor_hub_get_physical_device_count_24605 sensor_hub_get_physical_device_count 0 24605 NULL
97264 +kvm_pv_enable_async_pf_24637 kvm_pv_enable_async_pf 2 24637 NULL
97265 +context_alloc_24645 context_alloc 3 24645 NULL
97266 +blk_rq_err_bytes_24650 blk_rq_err_bytes 0 24650 NULL
97267 +unifi_net_data_malloc_24716 unifi_net_data_malloc 3 24716 NULL
97268 +read_fs_24717 read_fs 0 24717 NULL
97269 +simple_attr_read_24738 simple_attr_read 3 24738 NULL
97270 +qla2x00_change_queue_depth_24742 qla2x00_change_queue_depth 2 24742 NULL
97271 +ath_rxbuf_alloc_24745 ath_rxbuf_alloc 2 24745 NULL
97272 +get_dma_residue_24749 get_dma_residue 0 24749 NULL
97273 +kgdb_hex2mem_24755 kgdb_hex2mem 3 24755 NULL
97274 +nfsd4_sanitize_slot_size_24756 nfsd4_sanitize_slot_size 0-1 24756 NULL
97275 +i915_cache_sharing_read_24775 i915_cache_sharing_read 3 24775 NULL
97276 +ocfs2_read_blocks_24777 ocfs2_read_blocks 0 24777 NULL
97277 +skb_make_writable_24783 skb_make_writable 2 24783 NULL
97278 +datablob_hmac_verify_24786 datablob_hmac_verify 4 24786 NULL
97279 +cache_read_24790 cache_read 3 24790 NULL
97280 +unpack_str_24798 unpack_str 0 24798 NULL
97281 +__next_cpu_nr_24805 __next_cpu_nr 1 24805 NULL
97282 +comedi_buf_alloc_24822 comedi_buf_alloc 3 24822 NULL
97283 +snd_als4k_gcr_read_24840 snd_als4k_gcr_read 0 24840 NULL
97284 +snd_pcm_lib_buffer_bytes_24865 snd_pcm_lib_buffer_bytes 0 24865 NULL
97285 +pnp_alloc_24869 pnp_alloc 1 24869 NULL nohasharray
97286 +l2cap_create_basic_pdu_24869 l2cap_create_basic_pdu 3 24869 &pnp_alloc_24869
97287 +setup_buffering_24872 setup_buffering 3 24872 NULL
97288 +bnx2fc_cmd_mgr_alloc_24873 bnx2fc_cmd_mgr_alloc 3-2 24873 NULL
97289 +queues_read_24877 queues_read 3 24877 NULL
97290 +codec_list_read_file_24910 codec_list_read_file 3 24910 NULL
97291 +v4l2_ctrl_new_24927 v4l2_ctrl_new 7 24927 NULL
97292 +next_token_24929 next_token 0 24929 NULL
97293 +uf_create_device_nodes_24948 uf_create_device_nodes 2 24948 NULL
97294 +ocfs2_fiemap_24949 ocfs2_fiemap 3-4 24949 NULL
97295 +packet_sendmsg_24954 packet_sendmsg 4 24954 NULL
97296 +sys_rt_sigpending_24961 sys_rt_sigpending 2 24961 NULL
97297 +ensure_wear_leveling_24971 ensure_wear_leveling 0 24971 NULL
97298 +twl_i2c_write_u8_24976 twl_i2c_write_u8 3 24976 NULL
97299 +nf_nat_sdp_port_24977 nf_nat_sdp_port 7 24977 NULL
97300 +llc_ui_sendmsg_24987 llc_ui_sendmsg 4 24987 NULL
97301 +key_conf_hw_key_idx_read_25003 key_conf_hw_key_idx_read 3 25003 NULL
97302 +il_dbgfs_channels_read_25005 il_dbgfs_channels_read 3 25005 NULL
97303 +ni_660x_num_counters_25031 ni_660x_num_counters 0 25031 NULL
97304 +nfs_dns_resolve_name_25036 nfs_dns_resolve_name 3 25036 NULL
97305 +gs_buf_alloc_25067 gs_buf_alloc 2 25067 NULL
97306 +ceph_osdc_writepages_25085 ceph_osdc_writepages 5 25085 NULL
97307 +snd_rawmidi_kernel_write_25106 snd_rawmidi_kernel_write 3 25106 NULL
97308 +sys_fgetxattr_25166 sys_fgetxattr 4 25166 NULL
97309 +ipath_init_qp_table_25167 ipath_init_qp_table 2 25167 NULL
97310 +sctp_getsockopt_local_addrs_25178 sctp_getsockopt_local_addrs 2 25178 NULL
97311 +ks8851_rdreg32_25187 ks8851_rdreg32 0 25187 NULL
97312 +ocfs2_block_check_compute_25223 ocfs2_block_check_compute 2 25223 NULL
97313 +free_memcg_kmem_pages_25228 free_memcg_kmem_pages 1 25228 NULL
97314 +mon_stat_read_25238 mon_stat_read 3 25238 NULL
97315 +tcf_csum_ipv6_udp_25241 tcf_csum_ipv6_udp 4 25241 NULL
97316 +nilfs_palloc_find_available_slot_25245 nilfs_palloc_find_available_slot 3-5 25245 NULL
97317 +stripe_status_25259 stripe_status 5 25259 NULL
97318 +snd_pcm_start_25273 snd_pcm_start 0 25273 NULL
97319 +crypto_alloc_instance2_25277 crypto_alloc_instance2 3 25277 NULL
97320 +vfs_writev_25278 vfs_writev 3 25278 NULL
97321 +l2tp_session_create_25286 l2tp_session_create 1 25286 NULL
97322 +snd_seq_ioctl_compat_25307 snd_seq_ioctl_compat 3 25307 NULL
97323 +help_25316 help 5 25316 NULL nohasharray
97324 +ath9k_debugfs_read_buf_25316 ath9k_debugfs_read_buf 3 25316 &help_25316
97325 +rng_buffer_size_25348 rng_buffer_size 0 25348 NULL
97326 +rio_destid_next_25368 rio_destid_next 2 25368 NULL nohasharray
97327 +unix_mkname_25368 unix_mkname 0-2 25368 &rio_destid_next_25368
97328 +sel_read_mls_25369 sel_read_mls 3 25369 NULL
97329 +tc3589x_gpio_to_irq_25371 tc3589x_gpio_to_irq 2 25371 NULL
97330 +ebt_buf_add_pad_25413 ebt_buf_add_pad 0 25413 NULL
97331 +dai_list_read_file_25421 dai_list_read_file 3 25421 NULL
97332 +ath6kl_wmi_beginscan_cmd_25462 ath6kl_wmi_beginscan_cmd 8 25462 NULL
97333 +generic_file_buffered_write_25464 generic_file_buffered_write 4 25464 NULL
97334 +crypto_hash_digestsize_25469 crypto_hash_digestsize 0 25469 NULL
97335 +ocfs2_hamming_encode_25501 ocfs2_hamming_encode 3 25501 NULL
97336 +ivtv_buf_copy_from_user_25502 ivtv_buf_copy_from_user 4 25502 NULL
97337 +snd_pcm_plugin_build_25505 snd_pcm_plugin_build 5 25505 NULL
97338 +sb_permission_25523 sb_permission 0 25523 NULL
97339 +ext3_get_inode_loc_25542 ext3_get_inode_loc 0 25542 NULL
97340 +ieee80211_if_read_path_refresh_time_25545 ieee80211_if_read_path_refresh_time 3 25545 NULL
97341 +wimax_addr_scnprint_25548 wimax_addr_scnprint 2 25548 NULL
97342 +ht_print_chan_25556 ht_print_chan 0 25556 NULL
97343 +skb_tailroom_25567 skb_tailroom 0 25567 NULL
97344 +find_extend_vma_25597 find_extend_vma 2 25597 NULL
97345 +__devres_alloc_25598 __devres_alloc 2 25598 NULL
97346 +copy_user_generic_25611 copy_user_generic 0 25611 NULL
97347 +proc_coredump_filter_write_25625 proc_coredump_filter_write 3 25625 NULL
97348 +__get_user_pages_25628 __get_user_pages 0-3-4 25628 NULL nohasharray
97349 +befs_utf2nls_25628 befs_utf2nls 3 25628 &__get_user_pages_25628
97350 +__direct_map_25647 __direct_map 5-6 25647 NULL
97351 +ext2_try_to_allocate_25667 ext2_try_to_allocate 4-2 25667 NULL
97352 +aircable_prepare_write_buffer_25669 aircable_prepare_write_buffer 3 25669 NULL
97353 +sta_inactive_ms_read_25690 sta_inactive_ms_read 3 25690 NULL
97354 +ebitmap_start_positive_25703 ebitmap_start_positive 0 25703 NULL
97355 +rx_filter_mc_filter_read_25712 rx_filter_mc_filter_read 3 25712 NULL
97356 +ibmasm_new_command_25714 ibmasm_new_command 2 25714 NULL
97357 +sel_write_context_25726 sel_write_context 3 25726 NULL nohasharray
97358 +__alloc_bootmem_low_node_25726 __alloc_bootmem_low_node 2-3 25726 &sel_write_context_25726
97359 +mcs_unwrap_fir_25733 mcs_unwrap_fir 3 25733 NULL
97360 +ext2_find_near_25734 ext2_find_near 0 25734 NULL
97361 +__set_clear_dirty_25744 __set_clear_dirty 2 25744 NULL
97362 +cxgbi_device_portmap_create_25747 cxgbi_device_portmap_create 3 25747 NULL
97363 +event_rx_pool_read_25792 event_rx_pool_read 3 25792 NULL
97364 +sg_read_25799 sg_read 3 25799 NULL
97365 +system_enable_read_25815 system_enable_read 3 25815 NULL
97366 +realloc_buffer_25816 realloc_buffer 2 25816 NULL
97367 +mthca_map_user_db_25823 mthca_map_user_db 5 25823 NULL
97368 +pwr_missing_bcns_read_25824 pwr_missing_bcns_read 3 25824 NULL
97369 +parport_read_25855 parport_read 0 25855 NULL
97370 +xfs_dir2_sf_hdr_size_25858 xfs_dir2_sf_hdr_size 0 25858 NULL
97371 +uf_ap_process_data_pdu_25860 uf_ap_process_data_pdu 7 25860 NULL
97372 +ath6kl_regread_read_25884 ath6kl_regread_read 3 25884 NULL
97373 +run_delalloc_nocow_25896 run_delalloc_nocow 3 25896 NULL
97374 +sisusbcon_scroll_area_25899 sisusbcon_scroll_area 4-3 25899 NULL
97375 +lpfc_change_queue_depth_25905 lpfc_change_queue_depth 2 25905 NULL
97376 +do_jffs2_setxattr_25910 do_jffs2_setxattr 5 25910 NULL
97377 +rcname_read_25919 rcname_read 3 25919 NULL
97378 +snd_es1938_capture_copy_25930 snd_es1938_capture_copy 5 25930 NULL
97379 +key_flags_read_25931 key_flags_read 3 25931 NULL
97380 +copy_play_buf_25932 copy_play_buf 3 25932 NULL
97381 +flush_25957 flush 2 25957 NULL
97382 +video_register_device_25971 video_register_device 3 25971 NULL
97383 +udp_setsockopt_25985 udp_setsockopt 5 25985 NULL
97384 +ebt_compat_entry_padsize_26001 ebt_compat_entry_padsize 0 26001 NULL
97385 +lpfc_sli_probe_sriov_nr_virtfn_26004 lpfc_sli_probe_sriov_nr_virtfn 2 26004 NULL
97386 +irq_create_strict_mappings_26025 irq_create_strict_mappings 2-4 26025 NULL
97387 +xfs_xattr_acl_set_26028 xfs_xattr_acl_set 4 26028 NULL
97388 +skb_mac_header_26034 skb_mac_header 0 26034 NULL
97389 +mptscsih_change_queue_depth_26036 mptscsih_change_queue_depth 2 26036 NULL
97390 +selinux_inode_post_setxattr_26037 selinux_inode_post_setxattr 4 26037 NULL
97391 +tun_do_read_26047 tun_do_read 5 26047 NULL
97392 +__alloc_memory_core_early_26053 __alloc_memory_core_early 2-3 26053 NULL
97393 +keyctl_update_key_26061 keyctl_update_key 3 26061 NULL
97394 +rx_rx_wa_density_dropped_frame_read_26095 rx_rx_wa_density_dropped_frame_read 3 26095 NULL
97395 +skb_cow_26138 skb_cow 2 26138 NULL
97396 +usb_dump_device_strings_26146 usb_dump_device_strings 0 26146 NULL
97397 +copy_oldmem_page_26164 copy_oldmem_page 3-1 26164 NULL
97398 +gfs2_xattr_acl_get_26166 gfs2_xattr_acl_get 0 26166 NULL nohasharray
97399 +ath6kl_roam_table_read_26166 ath6kl_roam_table_read 3 26166 &gfs2_xattr_acl_get_26166
97400 +mid_get_vbt_data_r1_26170 mid_get_vbt_data_r1 2 26170 NULL
97401 +disk_devt_26180 disk_devt 0 26180 NULL
97402 +get_registers_26187 get_registers 3 26187 NULL
97403 +cgroup_setxattr_26188 cgroup_setxattr 4 26188 NULL
97404 +ieee80211_if_fmt_dot11MeshTTL_26198 ieee80211_if_fmt_dot11MeshTTL 3 26198 NULL
97405 +xfs_idata_realloc_26199 xfs_idata_realloc 2 26199 NULL
97406 +mce_write_26201 mce_write 3 26201 NULL
97407 +_scsih_change_queue_depth_26230 _scsih_change_queue_depth 2 26230 NULL
97408 +bio_split_26235 bio_split 2 26235 NULL
97409 +crypto_ctxsize_26278 crypto_ctxsize 0 26278 NULL
97410 +wacom_set_device_mode_26280 wacom_set_device_mode 3 26280 NULL
97411 +ext2_find_goal_26306 ext2_find_goal 0 26306 NULL
97412 +snd_pcm_plug_client_channels_buf_26309 snd_pcm_plug_client_channels_buf 0-3 26309 NULL nohasharray
97413 +pax_get_random_long_26309 pax_get_random_long 0 26309 &snd_pcm_plug_client_channels_buf_26309
97414 +pwr_wake_on_host_read_26321 pwr_wake_on_host_read 3 26321 NULL
97415 +ocfs2_duplicate_clusters_by_page_26357 ocfs2_duplicate_clusters_by_page 5 26357 NULL
97416 +cifs_readdata_alloc_26360 cifs_readdata_alloc 1 26360 NULL
97417 +dup_to_netobj_26363 dup_to_netobj 3 26363 NULL
97418 +invalidate_inode_pages2_range_26403 invalidate_inode_pages2_range 0 26403 NULL
97419 +dma_declare_contiguous_26455 dma_declare_contiguous 2 26455 NULL
97420 +ib_alloc_device_26483 ib_alloc_device 1 26483 NULL
97421 +ulong_write_file_26485 ulong_write_file 3 26485 NULL
97422 +dvb_ca_en50221_io_ioctl_26490 dvb_ca_en50221_io_ioctl 2 26490 NULL
97423 +read_vmcore_26501 read_vmcore 3 26501 NULL
97424 +vfio_pci_set_msi_trigger_26507 vfio_pci_set_msi_trigger 3-4 26507 NULL
97425 +iwl_dbgfs_rf_reset_read_26512 iwl_dbgfs_rf_reset_read 3 26512 NULL
97426 +__vhost_add_used_n_26554 __vhost_add_used_n 3 26554 NULL
97427 +ip6_addr_string_26568 ip6_addr_string 0 26568 NULL
97428 +kvm_iommu_put_pages_26571 kvm_iommu_put_pages 2 26571 NULL
97429 +rts51x_read_mem_26577 rts51x_read_mem 4 26577 NULL nohasharray
97430 +batadv_receive_server_sync_packet_26577 batadv_receive_server_sync_packet 3 26577 &rts51x_read_mem_26577
97431 +cirrusfb_get_memsize_26597 cirrusfb_get_memsize 0 26597 NULL
97432 +__unmap_single_26604 __unmap_single 2-3 26604 NULL
97433 +iommu_alloc_26621 iommu_alloc 4 26621 NULL
97434 +pack_value_26625 pack_value 1 26625 NULL
97435 +pwr_fix_tsf_ps_read_26627 pwr_fix_tsf_ps_read 3 26627 NULL
97436 +irq_alloc_generic_chip_26650 irq_alloc_generic_chip 2 26650 NULL nohasharray
97437 +inb_p_26650 inb_p 0 26650 &irq_alloc_generic_chip_26650
97438 +cipso_v4_map_cat_rbm_hton_26680 cipso_v4_map_cat_rbm_hton 0 26680 NULL
97439 +__alloc_pred_stack_26687 __alloc_pred_stack 2 26687 NULL
97440 +rtllib_authentication_req_26713 rtllib_authentication_req 3 26713 NULL
97441 +aty_ld_le32_26720 aty_ld_le32 0 26720 NULL
97442 +nouveau_namedb_create__26732 nouveau_namedb_create_ 7 26732 NULL
97443 +pipeline_tcp_rx_stat_fifo_int_read_26745 pipeline_tcp_rx_stat_fifo_int_read 3 26745 NULL
97444 +srp_ring_alloc_26760 srp_ring_alloc 2 26760 NULL
97445 +snd_hda_get_raw_connections_26762 snd_hda_get_raw_connections 0 26762 NULL
97446 +qlcnic_alloc_sds_rings_26795 qlcnic_alloc_sds_rings 2 26795 NULL
97447 +cipso_v4_genopt_26812 cipso_v4_genopt 0 26812 NULL
97448 +iwl_trans_read_mem32_26825 iwl_trans_read_mem32 0 26825 NULL
97449 +smk_write_load_26829 smk_write_load 3 26829 NULL
97450 +sizeof_pwm_leds_priv_26830 sizeof_pwm_leds_priv 0-1 26830 NULL
97451 +slgt_compat_ioctl_26834 slgt_compat_ioctl 3 26834 NULL
97452 +__nodes_onto_26838 __nodes_onto 4 26838 NULL
97453 +scnprint_id_26842 scnprint_id 3 26842 NULL
97454 +ecryptfs_miscdev_write_26847 ecryptfs_miscdev_write 3 26847 NULL
97455 +netxen_nic_hw_read_wx_128M_26858 netxen_nic_hw_read_wx_128M 2 26858 NULL
97456 +svc_print_xprts_26881 svc_print_xprts 0 26881 NULL
97457 +ext2_compat_ioctl_26883 ext2_compat_ioctl 3 26883 NULL
97458 +slhc_uncompress_26905 slhc_uncompress 0-3 26905 NULL
97459 +x25_asy_change_mtu_26928 x25_asy_change_mtu 2 26928 NULL
97460 +compat_mtw_from_user_26932 compat_mtw_from_user 0 26932 NULL
97461 +scsi_tgt_copy_sense_26933 scsi_tgt_copy_sense 3 26933 NULL
97462 +pwr_ps_enter_read_26935 pwr_ps_enter_read 3 26935 NULL nohasharray
97463 +sctp_setsockopt_adaptation_layer_26935 sctp_setsockopt_adaptation_layer 3 26935 &pwr_ps_enter_read_26935
97464 +carl9170_handle_mpdu_26940 carl9170_handle_mpdu 3 26940 NULL nohasharray
97465 +create_bm_block_list_26940 create_bm_block_list 0 26940 &carl9170_handle_mpdu_26940
97466 +hecubafb_write_26942 hecubafb_write 3 26942 NULL
97467 +extract_entropy_user_26952 extract_entropy_user 3 26952 NULL nohasharray
97468 +do_trimming_26952 do_trimming 3 26952 &extract_entropy_user_26952
97469 +pcf857x_irq_domain_map_26998 pcf857x_irq_domain_map 2 26998 NULL
97470 +swiotlb_bounce_27046 swiotlb_bounce 2-1 27046 NULL
97471 +ufs_alloc_fragments_27059 ufs_alloc_fragments 3-0-2 27059 NULL
97472 +__videobuf_alloc_vb_27062 __videobuf_alloc_vb 1 27062 NULL
97473 +snd_pcm_lib_period_bytes_27071 snd_pcm_lib_period_bytes 0 27071 NULL
97474 +paravirt_read_msr_27077 paravirt_read_msr 0 27077 NULL
97475 +alloc_fdmem_27083 alloc_fdmem 1 27083 NULL
97476 +find_first_bit_27088 find_first_bit 0-2 27088 NULL
97477 +btmrvl_hscmd_write_27089 btmrvl_hscmd_write 3 27089 NULL
97478 +nes_reg_user_mr_27106 nes_reg_user_mr 2-3 27106 NULL
97479 +__devcgroup_inode_permission_27108 __devcgroup_inode_permission 0 27108 NULL
97480 +get_kernel_page_27133 get_kernel_page 0 27133 NULL
97481 +drbd_get_capacity_27141 drbd_get_capacity 0 27141 NULL
97482 +pms_capture_27142 pms_capture 4 27142 NULL
97483 +btmrvl_hscfgcmd_write_27143 btmrvl_hscfgcmd_write 3 27143 NULL
97484 +snd_compr_calc_avail_27165 snd_compr_calc_avail 0 27165 NULL
97485 +i2400m_net_rx_27170 i2400m_net_rx 5 27170 NULL
97486 +ieee80211_if_read_rc_rateidx_mask_5ghz_27183 ieee80211_if_read_rc_rateidx_mask_5ghz 3 27183 NULL
97487 +mmc_blk_compat_ioctl_27194 mmc_blk_compat_ioctl 4 27194 NULL
97488 +dbAllocAG_27228 dbAllocAG 0 27228 NULL
97489 +rxrpc_request_key_27235 rxrpc_request_key 3 27235 NULL
97490 +cfpkt_add_trail_27260 cfpkt_add_trail 3 27260 NULL
97491 +__dma_map_cont_27289 __dma_map_cont 5 27289 NULL
97492 +hpi_read_reg_27302 hpi_read_reg 0 27302 NULL
97493 +copy_from_buf_27308 copy_from_buf 4-2 27308 NULL
97494 +ath6kl_wmi_test_cmd_27312 ath6kl_wmi_test_cmd 3 27312 NULL
97495 +ocfs2_blocks_to_clusters_27327 ocfs2_blocks_to_clusters 0-2 27327 NULL
97496 +snd_pcm_oss_write2_27332 snd_pcm_oss_write2 3-0 27332 NULL
97497 +afs_cell_create_27346 afs_cell_create 2 27346 NULL
97498 +pcbit_stat_27364 pcbit_stat 2 27364 NULL
97499 +init_memory_mapping_27395 init_memory_mapping 0 27395 NULL
97500 +phys_pte_init_27411 phys_pte_init 0-3-2 27411 NULL
97501 +ib_dma_map_sg_27413 ib_dma_map_sg 0 27413 NULL
97502 +acpi_os_get_root_pointer_27416 acpi_os_get_root_pointer 0 27416 NULL nohasharray
97503 +ieee80211_if_read_smps_27416 ieee80211_if_read_smps 3 27416 &acpi_os_get_root_pointer_27416
97504 +pack_sg_list_27425 pack_sg_list 0-2 27425 NULL
97505 +v4l2_ctrl_new_std_menu_items_27487 v4l2_ctrl_new_std_menu_items 4 27487 NULL
97506 +set_tpl_pfs_27490 set_tpl_pfs 3 27490 NULL
97507 +hcd_buffer_alloc_27495 hcd_buffer_alloc 2 27495 NULL
97508 +qib_create_cq_27497 qib_create_cq 2 27497 NULL
97509 +ip_set_get_h32_27498 ip_set_get_h32 0 27498 NULL
97510 +btrfs_get_64_27499 btrfs_get_64 0 27499 NULL
97511 +__usbnet_write_cmd_27500 __usbnet_write_cmd 7 27500 NULL
97512 +garmin_read_process_27509 garmin_read_process 3 27509 NULL
97513 +ib_copy_to_udata_27525 ib_copy_to_udata 3 27525 NULL
97514 +snd_sonicvibes_getdmaa_27552 snd_sonicvibes_getdmaa 0 27552 NULL
97515 +libipw_alloc_txb_27579 libipw_alloc_txb 1-2-3 27579 NULL
97516 +read_flush_procfs_27642 read_flush_procfs 3 27642 NULL nohasharray
97517 +nl80211_send_connect_result_27642 nl80211_send_connect_result 5-7 27642 &read_flush_procfs_27642 nohasharray
97518 +ocfs2_xattr_ibody_get_27642 ocfs2_xattr_ibody_get 0 27642 &nl80211_send_connect_result_27642
97519 +add_new_gdb_27643 add_new_gdb 3 27643 NULL
97520 +qnx6_readpages_27657 qnx6_readpages 4 27657 NULL
97521 +cdrom_read_cdda_old_27664 cdrom_read_cdda_old 4 27664 NULL
97522 +set_bypass_pwoff_pfs_27669 set_bypass_pwoff_pfs 3 27669 NULL
97523 +qword_get_27670 qword_get 0 27670 NULL
97524 +ocfs2_extend_dir_27695 ocfs2_extend_dir 4 27695 NULL
97525 +fs_path_add_from_extent_buffer_27702 fs_path_add_from_extent_buffer 4 27702 NULL
97526 +evm_write_key_27715 evm_write_key 3 27715 NULL
97527 +ieee80211_if_fmt_dot11MeshGateAnnouncementProtocol_27722 ieee80211_if_fmt_dot11MeshGateAnnouncementProtocol 3 27722 NULL
97528 +reg_w_buf_27724 reg_w_buf 3 27724 NULL
97529 +xfs_dir2_block_sfsize_27727 xfs_dir2_block_sfsize 0 27727 NULL
97530 +a4t_cs_init_27734 a4t_cs_init 3 27734 NULL
97531 +kcalloc_27770 kcalloc 1-2 27770 NULL
97532 +twl4030_set_gpio_dataout_27792 twl4030_set_gpio_dataout 1 27792 NULL
97533 +DivaSTraceGetMemotyRequirement_27797 DivaSTraceGetMemotyRequirement 0-1 27797 NULL
97534 +ttm_object_file_init_27804 ttm_object_file_init 2 27804 NULL
97535 +mpihelp_mul_27805 mpihelp_mul 5-3 27805 NULL
97536 +fwtty_buffer_rx_27821 fwtty_buffer_rx 3 27821 NULL
97537 +init_header_complete_27833 init_header_complete 0 27833 NULL nohasharray
97538 +sys_listxattr_27833 sys_listxattr 3 27833 &init_header_complete_27833
97539 +read_profile_27859 read_profile 3 27859 NULL
97540 +sky2_pci_read16_27863 sky2_pci_read16 0 27863 NULL
97541 +ieee80211_if_read_dot11MeshHWMProotInterval_27873 ieee80211_if_read_dot11MeshHWMProotInterval 3 27873 NULL
97542 +unix_seqpacket_sendmsg_27893 unix_seqpacket_sendmsg 4 27893 NULL
97543 +gluebi_write_27905 gluebi_write 3 27905 NULL
97544 +bm_find_next_27929 bm_find_next 2 27929 NULL
97545 +tracing_clock_write_27961 tracing_clock_write 3 27961 NULL
97546 +tipc_media_addr_printf_27971 tipc_media_addr_printf 2 27971 NULL
97547 +mic_rx_pkts_read_27972 mic_rx_pkts_read 3 27972 NULL
97548 +f2fs_bio_alloc_27983 f2fs_bio_alloc 2 27983 NULL
97549 +edt_ft5x06_debugfs_raw_data_read_28002 edt_ft5x06_debugfs_raw_data_read 3 28002 NULL
97550 +snd_rawmidi_write_28008 snd_rawmidi_write 3 28008 NULL
97551 +serial8250_port_size_28019 serial8250_port_size 0 28019 NULL
97552 +sctp_setsockopt_maxburst_28041 sctp_setsockopt_maxburst 3 28041 NULL
97553 +rts51x_xd_rw_28046 rts51x_xd_rw 3-4 28046 NULL
97554 +cx231xx_init_vbi_isoc_28053 cx231xx_init_vbi_isoc 3-2 28053 NULL
97555 +pool_status_28055 pool_status 5 28055 NULL
97556 +lpfc_idiag_mbxacc_read_28061 lpfc_idiag_mbxacc_read 3 28061 NULL
97557 +tx_frag_bad_mblk_num_read_28064 tx_frag_bad_mblk_num_read 3 28064 NULL
97558 +ext4_read_block_bitmap_nowait_28078 ext4_read_block_bitmap_nowait 2 28078 NULL
97559 +GetRecvByte_28082 GetRecvByte 0 28082 NULL
97560 +platform_get_irq_28088 platform_get_irq 0 28088 NULL
97561 +gdth_init_isa_28091 gdth_init_isa 1 28091 NULL
97562 +mmc_test_alloc_mem_28102 mmc_test_alloc_mem 3-2 28102 NULL
97563 +rx_defrag_need_defrag_read_28117 rx_defrag_need_defrag_read 3 28117 NULL
97564 +vgacon_adjust_height_28124 vgacon_adjust_height 2 28124 NULL
97565 +video_read_28148 video_read 3 28148 NULL
97566 +snd_midi_channel_alloc_set_28153 snd_midi_channel_alloc_set 1 28153 NULL
97567 +stats_dot11FCSErrorCount_read_28154 stats_dot11FCSErrorCount_read 3 28154 NULL
97568 +vread_28173 vread 0 28173 NULL
97569 +macvtap_get_user_28185 macvtap_get_user 4 28185 NULL
97570 +d_path_28198 d_path 0 28198 NULL
97571 +nouveau_mxm_create__28200 nouveau_mxm_create_ 4 28200 NULL
97572 +__qp_memcpy_from_queue_28220 __qp_memcpy_from_queue 3-4 28220 NULL
97573 +line6_alloc_sysex_buffer_28225 line6_alloc_sysex_buffer 4 28225 NULL nohasharray
97574 +set_dis_disc_pfs_28225 set_dis_disc_pfs 3 28225 &line6_alloc_sysex_buffer_28225
97575 +amd_nb_num_28228 amd_nb_num 0 28228 NULL
97576 +ext4_validate_block_bitmap_28243 ext4_validate_block_bitmap 3 28243 NULL
97577 +usemap_size_28281 usemap_size 0 28281 NULL
97578 +dma_map_sg_attrs_28289 dma_map_sg_attrs 0 28289 NULL
97579 +acpi_register_gsi_xen_28305 acpi_register_gsi_xen 2 28305 NULL nohasharray
97580 +nouveau_compat_ioctl_28305 nouveau_compat_ioctl 2 28305 &acpi_register_gsi_xen_28305
97581 +__mlock_vma_pages_range_28315 __mlock_vma_pages_range 2-3 28315 NULL
97582 +snd_pcm_oss_read_28317 snd_pcm_oss_read 3 28317 NULL
97583 +bm_entry_write_28338 bm_entry_write 3 28338 NULL
97584 +snapshot_write_28351 snapshot_write 3 28351 NULL
97585 +sys_writev_28384 sys_writev 3 28384 NULL
97586 +dlmfs_file_read_28385 dlmfs_file_read 3 28385 NULL
97587 +tx_frag_cache_miss_read_28394 tx_frag_cache_miss_read 3 28394 NULL
97588 +set_bypass_pfs_28395 set_bypass_pfs 3 28395 NULL
97589 +subdev_ioctl_28417 subdev_ioctl 2 28417 NULL
97590 +__split_large_page_28429 __split_large_page 2 28429 NULL
97591 +mpage_readpages_28436 mpage_readpages 3 28436 NULL
97592 +set_memory_uc_28439 set_memory_uc 1 28439 NULL
97593 +snd_emu10k1_efx_read_28452 snd_emu10k1_efx_read 2 28452 NULL
97594 +key_mic_failures_read_28457 key_mic_failures_read 3 28457 NULL
97595 +alloc_irq_cpu_rmap_28459 alloc_irq_cpu_rmap 1 28459 NULL
97596 +vmw_du_crtc_cursor_set_28479 vmw_du_crtc_cursor_set 4-5 28479 NULL
97597 +ocfs2_backup_super_blkno_28484 ocfs2_backup_super_blkno 0-2 28484 NULL
97598 +max_response_pages_28492 max_response_pages 0 28492 NULL
97599 +clear_discard_28494 clear_discard 2 28494 NULL
97600 +ps_poll_upsd_utilization_read_28519 ps_poll_upsd_utilization_read 3 28519 NULL
97601 +__next_node_28521 __next_node 1 28521 NULL
97602 +i2400m_tx_stats_read_28527 i2400m_tx_stats_read 3 28527 NULL
97603 +sel_read_policycap_28544 sel_read_policycap 3 28544 NULL
97604 +run_delalloc_range_28545 run_delalloc_range 3 28545 NULL nohasharray
97605 +mptctl_getiocinfo_28545 mptctl_getiocinfo 2 28545 &run_delalloc_range_28545
97606 +b43legacy_debugfs_write_28556 b43legacy_debugfs_write 3 28556 NULL
97607 +asymmetric_verify_28567 asymmetric_verify 3 28567 NULL
97608 +phys_pud_init_28574 phys_pud_init 0-3-2 28574 NULL
97609 +cfg80211_send_rx_auth_28580 cfg80211_send_rx_auth 3 28580 NULL
97610 +oxygen_read32_28582 oxygen_read32 0 28582 NULL
97611 +ocfs2_read_dir_block_28587 ocfs2_read_dir_block 2 28587 NULL
97612 +extract_entropy_28604 extract_entropy 3-5 28604 NULL
97613 +kfifo_unused_28612 kfifo_unused 0 28612 NULL
97614 +mp_override_legacy_irq_28618 mp_override_legacy_irq 4 28618 NULL
97615 +snd_nm256_capture_copy_28622 snd_nm256_capture_copy 5-3 28622 NULL
97616 +_set_range_28627 _set_range 3 28627 NULL
97617 +v4l2_compat_ioctl32_28630 v4l2_compat_ioctl32 3 28630 NULL
97618 +setup_usemap_28636 setup_usemap 3-4 28636 NULL
97619 +blk_queue_resize_tags_28670 blk_queue_resize_tags 2 28670 NULL
97620 +__dev_alloc_skb_28681 __dev_alloc_skb 1 28681 NULL
97621 +nl80211_send_new_peer_candidate_28692 nl80211_send_new_peer_candidate 5 28692 NULL nohasharray
97622 +kvm_mmu_get_page_28692 kvm_mmu_get_page 2 28692 &nl80211_send_new_peer_candidate_28692
97623 +drm_plane_init_28731 drm_plane_init 6 28731 NULL
97624 +spi_execute_28736 spi_execute 5 28736 NULL
97625 +snd_pcm_aio_write_28738 snd_pcm_aio_write 3 28738 NULL nohasharray
97626 +phantom_compat_ioctl_28738 phantom_compat_ioctl 3 28738 &snd_pcm_aio_write_28738
97627 +read_file_btcoex_28743 read_file_btcoex 3 28743 NULL
97628 +ath6kl_get_num_reg_28780 ath6kl_get_num_reg 0 28780 NULL
97629 +dvb_net_sec_callback_28786 dvb_net_sec_callback 2 28786 NULL
97630 +sel_write_member_28800 sel_write_member 3 28800 NULL
97631 +cgroup_file_read_28804 cgroup_file_read 3 28804 NULL
97632 +btrfs_ref_to_path_28809 btrfs_ref_to_path 0 28809 NULL
97633 +memory_bm_create_28814 memory_bm_create 0 28814 NULL
97634 +iwl_dbgfs_rxon_filter_flags_read_28832 iwl_dbgfs_rxon_filter_flags_read 3 28832 NULL
97635 +vp_request_msix_vectors_28849 vp_request_msix_vectors 2 28849 NULL
97636 +ipv6_renew_options_28867 ipv6_renew_options 5 28867 NULL
97637 +packet_sendmsg_spkt_28885 packet_sendmsg_spkt 4 28885 NULL
97638 +to_cblock_28899 to_cblock 0-1 28899 NULL
97639 +da9055_group_write_28904 da9055_group_write 2-3 28904 NULL
97640 +ps_upsd_timeouts_read_28924 ps_upsd_timeouts_read 3 28924 NULL
97641 +ocfs2_frozen_trigger_28929 ocfs2_frozen_trigger 4 28929 NULL
97642 +push_rx_28939 push_rx 3 28939 NULL
97643 +btrfs_trim_block_group_28963 btrfs_trim_block_group 3 28963 NULL
97644 +alloc_sched_domains_28972 alloc_sched_domains 1 28972 NULL
97645 +ext4_mb_add_groupinfo_28988 ext4_mb_add_groupinfo 2 28988 NULL
97646 +bin_uuid_28999 bin_uuid 3 28999 NULL
97647 +xz_dec_init_29029 xz_dec_init 2 29029 NULL
97648 +sys_fcntl64_29031 sys_fcntl64 3 29031 NULL
97649 +ieee80211_if_read_ht_opmode_29044 ieee80211_if_read_ht_opmode 3 29044 NULL
97650 +rxrpc_sendmsg_29049 rxrpc_sendmsg 4 29049 NULL
97651 +iso_packets_buffer_init_29061 iso_packets_buffer_init 3-4 29061 NULL
97652 +lpfc_idiag_extacc_drivr_get_29067 lpfc_idiag_extacc_drivr_get 0-3 29067 NULL
97653 +memblock_alloc_base_nid_29072 memblock_alloc_base_nid 1-2 29072 NULL
97654 +sctp_getsockopt_assoc_stats_29074 sctp_getsockopt_assoc_stats 2 29074 NULL
97655 +mark_extents_written_29082 mark_extents_written 2 29082 NULL
97656 +isdn_ppp_write_29109 isdn_ppp_write 4 29109 NULL
97657 +snprintf_29125 snprintf 0 29125 NULL
97658 +iov_shorten_29130 iov_shorten 0 29130 NULL
97659 +proc_scsi_write_29142 proc_scsi_write 3 29142 NULL
97660 +reshape_ring_29147 reshape_ring 2 29147 NULL
97661 +alloc_irqs_from_29152 alloc_irqs_from 1-2 29152 NULL
97662 +drm_property_create_enum_29201 drm_property_create_enum 5 29201 NULL
97663 +wusb_prf_256_29203 wusb_prf_256 7 29203 NULL nohasharray
97664 +alloc_group_attrs_29203 alloc_group_attrs 3 29203 &wusb_prf_256_29203
97665 +__mm_populate_29204 __mm_populate 1 29204 NULL
97666 +comedi_alloc_subdevices_29207 comedi_alloc_subdevices 2 29207 NULL
97667 +do_shrinker_shrink_29208 do_shrinker_shrink 0 29208 NULL
97668 +iwl_dbgfs_temperature_read_29224 iwl_dbgfs_temperature_read 3 29224 NULL
97669 +devm_ioremap_29235 devm_ioremap 2-3 29235 NULL
97670 +irq_domain_add_linear_29236 irq_domain_add_linear 2 29236 NULL
97671 +recover_peb_29238 recover_peb 6-7 29238 NULL
97672 +security_context_to_sid_core_29248 security_context_to_sid_core 2 29248 NULL
97673 +block_div_29268 block_div 0-1-2 29268 NULL
97674 +prism2_set_genericelement_29277 prism2_set_genericelement 3 29277 NULL
97675 +bitmap_ord_to_pos_29279 bitmap_ord_to_pos 3 29279 NULL
97676 +sn9c102_read_29305 sn9c102_read 3 29305 NULL
97677 +lo_compat_ioctl_29336 lo_compat_ioctl 4 29336 NULL
97678 +tun_put_user_29337 tun_put_user 5 29337 NULL
97679 +__alloc_ei_netdev_29338 __alloc_ei_netdev 1 29338 NULL
97680 +alloc_and_copy_ftrace_hash_29368 alloc_and_copy_ftrace_hash 1 29368 NULL
97681 +mwifiex_cfg80211_mgmt_tx_29387 mwifiex_cfg80211_mgmt_tx 7 29387 NULL
97682 +pca953x_irq_setup_29407 pca953x_irq_setup 3 29407 NULL
97683 +mempool_create_29437 mempool_create 1 29437 NULL
97684 +crypto_ahash_alignmask_29445 crypto_ahash_alignmask 0 29445 NULL
97685 +apei_exec_ctx_get_output_29457 apei_exec_ctx_get_output 0 29457 NULL
97686 +validate_scan_freqs_29462 validate_scan_freqs 0 29462 NULL
97687 +do_register_entry_29478 do_register_entry 4 29478 NULL
97688 +simple_strtoul_29480 simple_strtoul 0 29480 NULL
97689 +btmrvl_pscmd_write_29504 btmrvl_pscmd_write 3 29504 NULL
97690 +btrfs_file_extent_disk_bytenr_29505 btrfs_file_extent_disk_bytenr 0 29505 NULL
97691 +atk_debugfs_ggrp_read_29522 atk_debugfs_ggrp_read 3 29522 NULL
97692 +_regmap_raw_write_29541 _regmap_raw_write 4-2 29541 NULL
97693 +set_brk_29551 set_brk 1 29551 NULL nohasharray
97694 +ftrace_write_29551 ftrace_write 3 29551 &set_brk_29551
97695 +idetape_queue_rw_tail_29562 idetape_queue_rw_tail 3 29562 NULL
97696 +leaf_dealloc_29566 leaf_dealloc 3 29566 NULL nohasharray
97697 +alloc_empty_pages_29566 alloc_empty_pages 2 29566 &leaf_dealloc_29566
97698 +lbs_lowsnr_read_29571 lbs_lowsnr_read 3 29571 NULL
97699 +pvr2_hdw_report_unlocked_29589 pvr2_hdw_report_unlocked 4 29589 NULL
97700 +slots_per_page_29601 slots_per_page 0 29601 NULL
97701 +qla4_82xx_pci_set_window_29605 qla4_82xx_pci_set_window 0-2 29605 NULL
97702 +alloc_low_pages_29623 alloc_low_pages 1 29623 NULL
97703 +nla_get_u16_29624 nla_get_u16 0 29624 NULL
97704 +tx_frag_cache_hit_read_29639 tx_frag_cache_hit_read 3 29639 NULL
97705 +lowmem_page_address_29649 lowmem_page_address 0 29649 NULL
97706 +sctp_make_abort_user_29654 sctp_make_abort_user 3 29654 NULL
97707 +br_send_bpdu_29669 br_send_bpdu 3 29669 NULL
97708 +sisusb_write_mem_bulk_29678 sisusb_write_mem_bulk 4 29678 NULL
97709 +sd_alloc_ctl_entry_29708 sd_alloc_ctl_entry 1 29708 NULL nohasharray
97710 +posix_acl_from_xattr_29708 posix_acl_from_xattr 3 29708 &sd_alloc_ctl_entry_29708
97711 +probes_write_29711 probes_write 3 29711 NULL
97712 +emi62_writememory_29731 emi62_writememory 4 29731 NULL
97713 +read_cis_cache_29735 read_cis_cache 4 29735 NULL
97714 +ip_vs_conn_fill_param_sync_29771 ip_vs_conn_fill_param_sync 6 29771 NULL
97715 +dbAlloc_29794 dbAlloc 0 29794 NULL
97716 +ext4_trim_all_free_29806 ext4_trim_all_free 4-3-2 29806 NULL
97717 +tcp_sendpage_29829 tcp_sendpage 4 29829 NULL
97718 +scan_bitmap_block_29840 scan_bitmap_block 4 29840 NULL
97719 +__probe_kernel_write_29842 __probe_kernel_write 3 29842 NULL
97720 +kvm_read_hva_atomic_29848 kvm_read_hva_atomic 3 29848 NULL
97721 +ipv6_setsockopt_29871 ipv6_setsockopt 5 29871 NULL
97722 +scsi_end_request_29876 scsi_end_request 3 29876 NULL
97723 +crypto_aead_alignmask_29885 crypto_aead_alignmask 0 29885 NULL
97724 +nfc_targets_found_29886 nfc_targets_found 3 29886 NULL
97725 +ext4_xattr_set_acl_29930 ext4_xattr_set_acl 4 29930 NULL
97726 +__btrfs_getxattr_29947 __btrfs_getxattr 0 29947 NULL
97727 +irias_add_octseq_attrib_29983 irias_add_octseq_attrib 4 29983 NULL nohasharray
97728 +diva_os_get_context_size_29983 diva_os_get_context_size 0 29983 &irias_add_octseq_attrib_29983
97729 +arch_setup_dmar_msi_29992 arch_setup_dmar_msi 1 29992 NULL
97730 +vmci_host_setup_notify_30002 vmci_host_setup_notify 2 30002 NULL
97731 +utf32_to_utf8_30028 utf32_to_utf8 0 30028 NULL
97732 +alloc_netdev_mqs_30030 alloc_netdev_mqs 1 30030 NULL
97733 +scsi_vpd_inquiry_30040 scsi_vpd_inquiry 4 30040 NULL
97734 +drp_wmove_30043 drp_wmove 4 30043 NULL
97735 +cxgbi_ddp_reserve_30091 cxgbi_ddp_reserve 4 30091 NULL
97736 +snd_midi_channel_init_set_30092 snd_midi_channel_init_set 1 30092 NULL
97737 +tg3_run_loopback_30093 tg3_run_loopback 2 30093 NULL
97738 +rx_filter_data_filter_read_30098 rx_filter_data_filter_read 3 30098 NULL nohasharray
97739 +dma_to_phys_30098 dma_to_phys 0-2 30098 &rx_filter_data_filter_read_30098
97740 +skb_pagelen_30113 skb_pagelen 0 30113 NULL
97741 +spi_async_locked_30117 spi_async_locked 0 30117 NULL
97742 +calgary_unmap_page_30130 calgary_unmap_page 2-3 30130 NULL
97743 +_osd_req_sizeof_alist_header_30134 _osd_req_sizeof_alist_header 0 30134 NULL
97744 +u_memcpya_30139 u_memcpya 2-3 30139 NULL
97745 +cx25821_video_ioctl_30188 cx25821_video_ioctl 2 30188 NULL
97746 +mempool_create_page_pool_30189 mempool_create_page_pool 1 30189 NULL
97747 +drm_property_create_bitmask_30195 drm_property_create_bitmask 5 30195 NULL
97748 +usblp_ioctl_30203 usblp_ioctl 2 30203 NULL
97749 +nfs_idmap_request_key_30208 nfs_idmap_request_key 3 30208 NULL
97750 +read_4k_modal_eeprom_30212 read_4k_modal_eeprom 3 30212 NULL
97751 +snd_ac97_pcm_assign_30218 snd_ac97_pcm_assign 2 30218 NULL
97752 +f2fs_compat_ioctl_30261 f2fs_compat_ioctl 3 30261 NULL
97753 +isr_pci_pm_read_30271 isr_pci_pm_read 3 30271 NULL
97754 +compat_readv_30273 compat_readv 3 30273 NULL
97755 +lapic_register_intr_30279 lapic_register_intr 1 30279 NULL
97756 +skcipher_sendmsg_30290 skcipher_sendmsg 4 30290 NULL
97757 +pipeline_sec_frag_swi_read_30294 pipeline_sec_frag_swi_read 3 30294 NULL
97758 +tcp_sendmsg_30296 tcp_sendmsg 4 30296 NULL
97759 +ext4_acl_from_disk_30320 ext4_acl_from_disk 2 30320 NULL
97760 +generic_ptrace_pokedata_30338 generic_ptrace_pokedata 2 30338 NULL
97761 +resource_from_user_30341 resource_from_user 3 30341 NULL
97762 +__vmalloc_node_flags_30352 __vmalloc_node_flags 1 30352 NULL
97763 +sys_get_mempolicy_30379 sys_get_mempolicy 3-4 30379 NULL
97764 +mangle_sdp_packet_30381 mangle_sdp_packet 10 30381 NULL
97765 +c4iw_init_resource_30393 c4iw_init_resource 2-3 30393 NULL
97766 +get_kernel_pages_30397 get_kernel_pages 0 30397 NULL
97767 +_drbd_bm_find_next_zero_30415 _drbd_bm_find_next_zero 2 30415 NULL
97768 +vb2_fop_write_30420 vb2_fop_write 3 30420 NULL
97769 +tx_tx_template_prepared_read_30424 tx_tx_template_prepared_read 3 30424 NULL
97770 +mq_create_30425 mq_create 1 30425 NULL
97771 +enable_write_30456 enable_write 3 30456 NULL
97772 +tx_tx_template_programmed_read_30461 tx_tx_template_programmed_read 3 30461 NULL
97773 +urandom_read_30462 urandom_read 3 30462 NULL
97774 +zoran_ioctl_30465 zoran_ioctl 2 30465 NULL
97775 +ocrdma_reg_user_mr_30474 ocrdma_reg_user_mr 2-3 30474 NULL
97776 +write_head_30481 write_head 4 30481 NULL
97777 +adu_write_30487 adu_write 3 30487 NULL
97778 +debug_debug2_read_30526 debug_debug2_read 3 30526 NULL
97779 +batadv_dat_snoop_incoming_arp_request_30548 batadv_dat_snoop_incoming_arp_request 3 30548 NULL
97780 +disk_expand_part_tbl_30561 disk_expand_part_tbl 2 30561 NULL
97781 +set_le_30581 set_le 4 30581 NULL
97782 +from_cblock_30582 from_cblock 0-1 30582 NULL
97783 +blk_init_tags_30592 blk_init_tags 1 30592 NULL
97784 +i2c_hid_get_report_length_30598 i2c_hid_get_report_length 0 30598 NULL
97785 +sgl_map_user_pages_30610 sgl_map_user_pages 2-3-4 30610 NULL
97786 +macvtap_sendmsg_30629 macvtap_sendmsg 4 30629 NULL
97787 +ieee80211_if_read_dot11MeshAwakeWindowDuration_30631 ieee80211_if_read_dot11MeshAwakeWindowDuration 3 30631 NULL
97788 +compat_raw_setsockopt_30634 compat_raw_setsockopt 5 30634 NULL
97789 +agp_remap_30665 agp_remap 2 30665 NULL
97790 +jffs2_flash_read_30667 jffs2_flash_read 0 30667 NULL
97791 +il_free_pages_30692 il_free_pages 2 30692 NULL
97792 +dccp_setsockopt_ccid_30701 dccp_setsockopt_ccid 4 30701 NULL
97793 +lbs_debugfs_read_30721 lbs_debugfs_read 3 30721 NULL
97794 +snd_nm256_playback_silence_30727 snd_nm256_playback_silence 4-3 30727 NULL
97795 +snapshot_status_30744 snapshot_status 5 30744 NULL
97796 +tcf_csum_ipv4_udp_30777 tcf_csum_ipv4_udp 4 30777 NULL
97797 +smk_read_doi_30813 smk_read_doi 3 30813 NULL
97798 +get_kobj_path_length_30831 get_kobj_path_length 0 30831 NULL
97799 +sctp_setsockopt_auth_chunk_30843 sctp_setsockopt_auth_chunk 3 30843 NULL
97800 +cfg80211_rx_mgmt_30844 cfg80211_rx_mgmt 5 30844 NULL
97801 +hda_hwdep_ioctl_compat_30847 hda_hwdep_ioctl_compat 4 30847 NULL
97802 +ieee80211_if_fmt_dropped_frames_no_route_30884 ieee80211_if_fmt_dropped_frames_no_route 3 30884 NULL
97803 +iommu_map_mmio_space_30919 iommu_map_mmio_space 1 30919 NULL
97804 +sctp_setsockopt_rtoinfo_30941 sctp_setsockopt_rtoinfo 3 30941 NULL
97805 +tty_insert_flip_string_flags_30969 tty_insert_flip_string_flags 4 30969 NULL
97806 +huge_page_mask_30981 huge_page_mask 0 30981 NULL
97807 +i2400mu_rx_size_grow_30989 i2400mu_rx_size_grow 0 30989 NULL
97808 +lbs_host_sleep_read_31013 lbs_host_sleep_read 3 31013 NULL
97809 +phys_pmd_init_31024 phys_pmd_init 0-3-2 31024 NULL
97810 +compat_sys_mq_timedsend_31060 compat_sys_mq_timedsend 3 31060 NULL
97811 +lbs_failcount_read_31063 lbs_failcount_read 3 31063 NULL
97812 +find_next_bit_le_31064 find_next_bit_le 0-2-3 31064 NULL
97813 +sys_mincore_31079 sys_mincore 1 31079 NULL
97814 +ttm_bo_ioremap_31082 ttm_bo_ioremap 2-3 31082 NULL
97815 +sctp_setsockopt_context_31091 sctp_setsockopt_context 3 31091 NULL
97816 +compat_sys_get_mempolicy_31109 compat_sys_get_mempolicy 3-4 31109 NULL
97817 +depth_read_31112 depth_read 3 31112 NULL
97818 +ssb_read16_31139 ssb_read16 0 31139 NULL
97819 +kimage_normal_alloc_31140 kimage_normal_alloc 3 31140 NULL
97820 +size_inside_page_31141 size_inside_page 0 31141 NULL
97821 +w9966_v4l_read_31148 w9966_v4l_read 3 31148 NULL
97822 +ch_do_scsi_31171 ch_do_scsi 4 31171 NULL
97823 +acpi_ex_system_memory_space_handler_31192 acpi_ex_system_memory_space_handler 2 31192 NULL
97824 +r592_read_fifo_pio_31198 r592_read_fifo_pio 3 31198 NULL
97825 +mtdchar_readoob_31200 mtdchar_readoob 4 31200 NULL
97826 +__btrfs_free_reserved_extent_31207 __btrfs_free_reserved_extent 2 31207 NULL
97827 +kvm_mmu_page_fault_31213 kvm_mmu_page_fault 2 31213 NULL
97828 +cpumask_weight_31215 cpumask_weight 0 31215 NULL
97829 +__read_reg_31216 __read_reg 0 31216 NULL
97830 +atm_get_addr_31221 atm_get_addr 3 31221 NULL
97831 +cyy_readb_31240 cyy_readb 0 31240 NULL
97832 +_create_sg_bios_31244 _create_sg_bios 4 31244 NULL
97833 +ieee80211_if_read_last_beacon_31257 ieee80211_if_read_last_beacon 3 31257 NULL
97834 +sctp_tsnmap_find_gap_ack_31272 sctp_tsnmap_find_gap_ack 3-2 31272 NULL
97835 +uvc_simplify_fraction_31303 uvc_simplify_fraction 3 31303 NULL
97836 +sisusbcon_scroll_31315 sisusbcon_scroll 5-2-3 31315 NULL
97837 +command_file_write_31318 command_file_write 3 31318 NULL
97838 +em28xx_init_usb_xfer_31337 em28xx_init_usb_xfer 4-6 31337 NULL
97839 +xprt_rdma_allocate_31372 xprt_rdma_allocate 2 31372 NULL
97840 +vb2_vmalloc_get_userptr_31374 vb2_vmalloc_get_userptr 3-2 31374 NULL
97841 +trace_parser_get_init_31379 trace_parser_get_init 2 31379 NULL
97842 +inb_31388 inb 0 31388 NULL
97843 +key_ifindex_read_31411 key_ifindex_read 3 31411 NULL
97844 +mcs7830_set_reg_31413 mcs7830_set_reg 3 31413 NULL
97845 +TSS_checkhmac1_31429 TSS_checkhmac1 5 31429 NULL
97846 +snd_aw2_saa7146_get_hw_ptr_capture_31431 snd_aw2_saa7146_get_hw_ptr_capture 0 31431 NULL
97847 +acpi_sci_ioapic_setup_31445 acpi_sci_ioapic_setup 4 31445 NULL
97848 +opera1_xilinx_rw_31453 opera1_xilinx_rw 5 31453 NULL
97849 +input_get_new_minor_31464 input_get_new_minor 1 31464 NULL
97850 +do_fcntl_31468 do_fcntl 3 31468 NULL
97851 +xfs_btree_get_numrecs_31477 xfs_btree_get_numrecs 0 31477 NULL
97852 +alg_setkey_31485 alg_setkey 3 31485 NULL
97853 +rds_message_map_pages_31487 rds_message_map_pages 2 31487 NULL
97854 +qsfp_2_read_31491 qsfp_2_read 3 31491 NULL
97855 +__alloc_bootmem_31498 __alloc_bootmem 1-2 31498 NULL
97856 +rmode_tss_base_31510 rmode_tss_base 0 31510 NULL
97857 +hidraw_write_31536 hidraw_write 3 31536 NULL
97858 +mtd_div_by_eb_31543 mtd_div_by_eb 0-1 31543 NULL
97859 +usbvision_read_31555 usbvision_read 3 31555 NULL
97860 +normalize_31566 normalize 0-1-2 31566 NULL
97861 +tx_frag_tkip_called_read_31575 tx_frag_tkip_called_read 3 31575 NULL
97862 +get_max_inline_xattr_value_size_31578 get_max_inline_xattr_value_size 0 31578 NULL
97863 +osst_write_31581 osst_write 3 31581 NULL
97864 +snd_compr_get_avail_31584 snd_compr_get_avail 0 31584 NULL
97865 +iwl_dbgfs_ucode_tx_stats_read_31611 iwl_dbgfs_ucode_tx_stats_read 3 31611 NULL
97866 +mtd_get_user_prot_info_31616 mtd_get_user_prot_info 0 31616 NULL
97867 +arvo_sysfs_read_31617 arvo_sysfs_read 6 31617 NULL
97868 +videobuf_read_one_31637 videobuf_read_one 3 31637 NULL
97869 +pod_alloc_sysex_buffer_31651 pod_alloc_sysex_buffer 3 31651 NULL
97870 +xfer_secondary_pool_31661 xfer_secondary_pool 2 31661 NULL
97871 +emulator_set_cr_31665 emulator_set_cr 3 31665 NULL
97872 +__lgread_31668 __lgread 4 31668 NULL
97873 +symbol_string_31670 symbol_string 0 31670 NULL
97874 +_usb_writeN_sync_31682 _usb_writeN_sync 4 31682 NULL
97875 +forced_ps_read_31685 forced_ps_read 3 31685 NULL
97876 +reiserfs_in_journal_31689 reiserfs_in_journal 3 31689 NULL
97877 +audit_log_n_string_31705 audit_log_n_string 3 31705 NULL
97878 +ath6kl_wmi_send_probe_response_cmd_31728 ath6kl_wmi_send_probe_response_cmd 6 31728 NULL nohasharray
97879 +gfn_to_hva_read_31728 gfn_to_hva_read 2 31728 &ath6kl_wmi_send_probe_response_cmd_31728
97880 +utf16s_to_utf8s_31735 utf16s_to_utf8s 0 31735 NULL
97881 +shmem_pwrite_slow_31741 shmem_pwrite_slow 3 31741 NULL
97882 +NCR_700_change_queue_depth_31742 NCR_700_change_queue_depth 2 31742 NULL nohasharray
97883 +input_abs_get_max_31742 input_abs_get_max 0 31742 &NCR_700_change_queue_depth_31742
97884 +bcm_char_read_31750 bcm_char_read 3 31750 NULL
97885 +snd_seq_device_new_31753 snd_seq_device_new 4 31753 NULL
97886 +set_memory_wb_31761 set_memory_wb 1 31761 NULL
97887 +usblp_cache_device_id_string_31790 usblp_cache_device_id_string 0 31790 NULL
97888 +get_count_order_31800 get_count_order 0 31800 NULL
97889 +ecryptfs_send_message_locked_31801 ecryptfs_send_message_locked 2 31801 NULL
97890 +isr_rx_procs_read_31804 isr_rx_procs_read 3 31804 NULL
97891 +strnlen_user_31815 strnlen_user 0-2 31815 NULL
97892 +sta_last_signal_read_31818 sta_last_signal_read 3 31818 NULL
97893 +drm_mode_crtc_set_gamma_size_31881 drm_mode_crtc_set_gamma_size 2 31881 NULL
97894 +ddb_output_write_31902 ddb_output_write 3 31902 NULL
97895 +xattr_permission_31907 xattr_permission 0 31907 NULL
97896 +new_dir_31919 new_dir 3 31919 NULL
97897 +kmem_alloc_31920 kmem_alloc 1 31920 NULL
97898 +guestwidth_to_adjustwidth_31937 guestwidth_to_adjustwidth 0-1 31937 NULL
97899 +iov_iter_copy_from_user_31942 iov_iter_copy_from_user 4 31942 NULL
97900 +vb2_write_31948 vb2_write 3 31948 NULL
97901 +pvr2_ctrl_get_valname_31951 pvr2_ctrl_get_valname 4 31951 NULL
97902 +copy_from_user_toio_31966 copy_from_user_toio 3 31966 NULL
97903 +mtd_add_partition_31971 mtd_add_partition 3 31971 NULL
97904 +find_next_zero_bit_31990 find_next_zero_bit 0-2-3 31990 NULL
97905 +default_setup_hpet_msi_31991 default_setup_hpet_msi 1 31991 NULL
97906 +tps6586x_irq_map_32002 tps6586x_irq_map 2 32002 NULL
97907 +calc_hmac_32010 calc_hmac 3 32010 NULL
97908 +vmcs_read64_32012 vmcs_read64 0 32012 NULL
97909 +aead_len_32021 aead_len 0 32021 NULL
97910 +ocfs2_remove_extent_32032 ocfs2_remove_extent 4-3 32032 NULL
97911 +posix_acl_set_32037 posix_acl_set 4 32037 NULL
97912 +vmw_cursor_update_dmabuf_32045 vmw_cursor_update_dmabuf 3-4 32045 NULL
97913 +sys_sched_setaffinity_32046 sys_sched_setaffinity 2 32046 NULL
97914 +proc_scsi_devinfo_write_32064 proc_scsi_devinfo_write 3 32064 NULL
97915 +cfg80211_send_unprot_deauth_32080 cfg80211_send_unprot_deauth 3 32080 NULL
97916 +bio_alloc_32095 bio_alloc 2 32095 NULL
97917 +alloc_pwms_32100 alloc_pwms 1-2 32100 NULL
97918 +ath6kl_fwlog_read_32101 ath6kl_fwlog_read 3 32101 NULL
97919 +disk_status_32120 disk_status 4 32120 NULL
97920 +venus_link_32165 venus_link 5 32165 NULL
97921 +do_writepages_32173 do_writepages 0 32173 NULL nohasharray
97922 +ntfs_rl_realloc_nofail_32173 ntfs_rl_realloc_nofail 3 32173 &do_writepages_32173
97923 +load_header_32183 load_header 0 32183 NULL
97924 +ubi_wl_scrub_peb_32196 ubi_wl_scrub_peb 0 32196 NULL
97925 +wusb_ccm_mac_32199 wusb_ccm_mac 7 32199 NULL
97926 +riva_get_cmap_len_32218 riva_get_cmap_len 0 32218 NULL
97927 +lbs_lowrssi_read_32242 lbs_lowrssi_read 3 32242 NULL
97928 +ocfs2_xattr_find_entry_32260 ocfs2_xattr_find_entry 0 32260 NULL
97929 +fb_compat_ioctl_32265 fb_compat_ioctl 3 32265 NULL
97930 +vmalloc_user_32308 vmalloc_user 1 32308 NULL
97931 +hex_string_32310 hex_string 0 32310 NULL
97932 +nouveau_bar_create__32332 nouveau_bar_create_ 4 32332 NULL
97933 +nl80211_send_mlme_event_32337 nl80211_send_mlme_event 4 32337 NULL
97934 +t4_alloc_mem_32342 t4_alloc_mem 1 32342 NULL
97935 +dispatch_ioctl_32357 dispatch_ioctl 2 32357 NULL
97936 +sel_read_initcon_32362 sel_read_initcon 3 32362 NULL
97937 +_drbd_bm_find_next_32372 _drbd_bm_find_next 2 32372 NULL
97938 +usbtmc_read_32377 usbtmc_read 3 32377 NULL
97939 +qla4_82xx_pci_mem_write_2M_32398 qla4_82xx_pci_mem_write_2M 2 32398 NULL
97940 +xfs_iext_add_indirect_multi_32400 xfs_iext_add_indirect_multi 3 32400 NULL
97941 +vmci_qp_alloc_32405 vmci_qp_alloc 3-5 32405 NULL
97942 +log_text_32428 log_text 0 32428 NULL
97943 +regmap_irq_map_32429 regmap_irq_map 2 32429 NULL
97944 +hid_input_report_32458 hid_input_report 4 32458 NULL
97945 +cache_status_32462 cache_status 5 32462 NULL
97946 +ieee80211_fill_mesh_addresses_32465 ieee80211_fill_mesh_addresses 0 32465 NULL
97947 +ide_driver_proc_write_32493 ide_driver_proc_write 3 32493 NULL
97948 +ctrl_std_val_to_sym_32516 ctrl_std_val_to_sym 5 32516 NULL
97949 +disconnect_32521 disconnect 4 32521 NULL
97950 +qsfp_read_32522 qsfp_read 0-4-2 32522 NULL
97951 +ilo_read_32531 ilo_read 3 32531 NULL
97952 +ieee80211_if_read_estab_plinks_32533 ieee80211_if_read_estab_plinks 3 32533 NULL
97953 +gnttab_set_unmap_op_32534 gnttab_set_unmap_op 2 32534 NULL
97954 +ieee80211_send_auth_32543 ieee80211_send_auth 6 32543 NULL
97955 +format_devstat_counter_32550 format_devstat_counter 3 32550 NULL
97956 +__first_node_32558 __first_node 0 32558 NULL
97957 +aes_encrypt_fail_read_32562 aes_encrypt_fail_read 3 32562 NULL
97958 +pnp_mem_len_32584 pnp_mem_len 0 32584 NULL
97959 +mem_swapout_entry_32586 mem_swapout_entry 3 32586 NULL
97960 +pipeline_tcp_tx_stat_fifo_int_read_32589 pipeline_tcp_tx_stat_fifo_int_read 3 32589 NULL
97961 +read_file_beacon_32595 read_file_beacon 3 32595 NULL
97962 +ieee80211_if_read_dropped_frames_congestion_32603 ieee80211_if_read_dropped_frames_congestion 3 32603 NULL
97963 +sys_set_mempolicy_32608 sys_set_mempolicy 3 32608 NULL
97964 +cfg80211_roamed_32632 cfg80211_roamed 5-7 32632 NULL
97965 +ieee80211_hdrlen_32637 ieee80211_hdrlen 0 32637 NULL
97966 +ite_decode_bytes_32642 ite_decode_bytes 3 32642 NULL
97967 +kvmalloc_32646 kvmalloc 1 32646 NULL
97968 +ib_sg_dma_len_32649 ib_sg_dma_len 0 32649 NULL
97969 +generic_readlink_32654 generic_readlink 3 32654 NULL
97970 +move_addr_to_kernel_32673 move_addr_to_kernel 2 32673 NULL
97971 +jfs_readpages_32702 jfs_readpages 4 32702 NULL
97972 +snd_hwdep_ioctl_compat_32736 snd_hwdep_ioctl_compat 3 32736 NULL
97973 +get_arg_page_32746 get_arg_page 2 32746 NULL
97974 +megasas_change_queue_depth_32747 megasas_change_queue_depth 2 32747 NULL
97975 +stats_read_ul_32751 stats_read_ul 3 32751 NULL
97976 +tty_compat_ioctl_32761 tty_compat_ioctl 3 32761 NULL
97977 +sctp_tsnmap_grow_32784 sctp_tsnmap_grow 2 32784 NULL
97978 +firmwareUpload_32794 firmwareUpload 3 32794 NULL
97979 +rproc_name_read_32805 rproc_name_read 3 32805 NULL
97980 +vga_rseq_32848 vga_rseq 0 32848 NULL
97981 +new_tape_buffer_32866 new_tape_buffer 2 32866 NULL
97982 +io_apic_setup_irq_pin_32868 io_apic_setup_irq_pin 1 32868 NULL
97983 +ath6kl_usb_submit_ctrl_in_32880 ath6kl_usb_submit_ctrl_in 6 32880 NULL nohasharray
97984 +cifs_writedata_alloc_32880 cifs_writedata_alloc 1 32880 &ath6kl_usb_submit_ctrl_in_32880
97985 +ath6kl_usb_post_recv_transfers_32892 ath6kl_usb_post_recv_transfers 2 32892 NULL
97986 +il_dbgfs_tx_stats_read_32913 il_dbgfs_tx_stats_read 3 32913 NULL
97987 +zlib_inflate_workspacesize_32927 zlib_inflate_workspacesize 0 32927 NULL
97988 +rmap_recycle_32938 rmap_recycle 3 32938 NULL
97989 +irq_reserve_irqs_32946 irq_reserve_irqs 1-2 32946 NULL
97990 +ext4_valid_block_bitmap_32958 ext4_valid_block_bitmap 3 32958 NULL
97991 +arch_ptrace_32981 arch_ptrace 3 32981 NULL
97992 +compat_filldir_32999 compat_filldir 3 32999 NULL
97993 +ext3_alloc_blocks_33007 ext3_alloc_blocks 3 33007 NULL
97994 +pipeline_dec_packet_in_fifo_full_read_33052 pipeline_dec_packet_in_fifo_full_read 3 33052 NULL
97995 +ebt_compat_match_offset_33053 ebt_compat_match_offset 0-2 33053 NULL
97996 +bitmap_resize_33054 bitmap_resize 2 33054 NULL
97997 +stats_dot11RTSSuccessCount_read_33065 stats_dot11RTSSuccessCount_read 3 33065 NULL
97998 +sel_read_checkreqprot_33068 sel_read_checkreqprot 3 33068 NULL
97999 +alloc_tio_33077 alloc_tio 3 33077 NULL
98000 +acl_permission_check_33083 acl_permission_check 0 33083 NULL
98001 +ieee80211_fragment_33112 ieee80211_fragment 4 33112 NULL
98002 +write_node_33121 write_node 4 33121 NULL
98003 +calc_patch_size_33124 calc_patch_size 0 33124 NULL
98004 +fb_sys_write_33130 fb_sys_write 3 33130 NULL
98005 +__len_within_target_33132 __len_within_target 0 33132 NULL
98006 +debug_debug6_read_33168 debug_debug6_read 3 33168 NULL
98007 +dataflash_read_fact_otp_33204 dataflash_read_fact_otp 2-3 33204 NULL
98008 +pp_read_33210 pp_read 3 33210 NULL
98009 +xfs_file_aio_write_33234 xfs_file_aio_write 4 33234 NULL
98010 +build_completion_wait_33242 build_completion_wait 2 33242 NULL
98011 +snd_pcm_plug_client_size_33267 snd_pcm_plug_client_size 0-2 33267 NULL
98012 +sched_find_first_bit_33270 sched_find_first_bit 0 33270 NULL
98013 +cachefiles_cook_key_33274 cachefiles_cook_key 2 33274 NULL
98014 +mei_compat_ioctl_33275 mei_compat_ioctl 3 33275 NULL
98015 +mcs7830_get_reg_33308 mcs7830_get_reg 3 33308 NULL
98016 +ath6kl_usb_ctrl_msg_exchange_33327 ath6kl_usb_ctrl_msg_exchange 4 33327 NULL
98017 +gsm_mux_rx_netchar_33336 gsm_mux_rx_netchar 3 33336 NULL
98018 +joydev_ioctl_33343 joydev_ioctl 2 33343 NULL
98019 +create_xattr_datum_33356 create_xattr_datum 5 33356 NULL nohasharray
98020 +irq_pkt_threshold_read_33356 irq_pkt_threshold_read 3 33356 &create_xattr_datum_33356
98021 +read_file_regidx_33370 read_file_regidx 3 33370 NULL
98022 +ocfs2_quota_read_33382 ocfs2_quota_read 5 33382 NULL
98023 +ieee80211_if_read_dropped_frames_no_route_33383 ieee80211_if_read_dropped_frames_no_route 3 33383 NULL
98024 +scsi_varlen_cdb_length_33385 scsi_varlen_cdb_length 0 33385 NULL
98025 +ocfs2_allocate_unwritten_extents_33394 ocfs2_allocate_unwritten_extents 2-3 33394 NULL
98026 +ext4_meta_bg_first_block_no_33408 ext4_meta_bg_first_block_no 2 33408 NULL nohasharray
98027 +snd_pcm_capture_ioctl1_33408 snd_pcm_capture_ioctl1 0 33408 &ext4_meta_bg_first_block_no_33408
98028 +ufs_getfrag_block_33409 ufs_getfrag_block 2 33409 NULL
98029 +ubh_scanc_33436 ubh_scanc 0-4-3 33436 NULL
98030 +ovs_vport_alloc_33475 ovs_vport_alloc 1 33475 NULL
98031 +create_entry_33479 create_entry 2 33479 NULL
98032 +ip_setsockopt_33487 ip_setsockopt 5 33487 NULL nohasharray
98033 +elf_map_33487 elf_map 0-2 33487 &ip_setsockopt_33487
98034 +netxen_nic_hw_write_wx_128M_33488 netxen_nic_hw_write_wx_128M 2 33488 NULL
98035 +ol_dqblk_chunk_off_33489 ol_dqblk_chunk_off 2 33489 NULL
98036 +res_counter_read_33499 res_counter_read 4 33499 NULL
98037 +fb_read_33506 fb_read 3 33506 NULL
98038 +musb_test_mode_write_33518 musb_test_mode_write 3 33518 NULL
98039 +ahash_setkey_unaligned_33521 ahash_setkey_unaligned 3 33521 NULL
98040 +nes_alloc_fast_reg_page_list_33523 nes_alloc_fast_reg_page_list 2 33523 NULL
98041 +aggr_size_rx_size_read_33526 aggr_size_rx_size_read 3 33526 NULL
98042 +acpi_gsi_to_irq_33533 acpi_gsi_to_irq 1 33533 NULL
98043 +tomoyo_read_self_33539 tomoyo_read_self 3 33539 NULL
98044 +dup_array_33551 dup_array 3 33551 NULL
98045 +solo_enc_read_33553 solo_enc_read 3 33553 NULL
98046 +count_subheaders_33591 count_subheaders 0 33591 NULL
98047 +scsi_execute_33596 scsi_execute 5 33596 NULL
98048 +comedi_buf_write_n_allocated_33604 comedi_buf_write_n_allocated 0 33604 NULL
98049 +xt_compat_target_offset_33608 xt_compat_target_offset 0 33608 NULL nohasharray
98050 +ip6_find_1stfragopt_33608 ip6_find_1stfragopt 0 33608 &xt_compat_target_offset_33608
98051 +usb_gstrings_attach_33615 usb_gstrings_attach 3 33615 NULL nohasharray
98052 +il_dbgfs_qos_read_33615 il_dbgfs_qos_read 3 33615 &usb_gstrings_attach_33615
98053 +irq_blk_threshold_read_33666 irq_blk_threshold_read 3 33666 NULL
98054 +inw_p_33668 inw_p 0 33668 NULL
98055 +arp_hdr_len_33671 arp_hdr_len 0 33671 NULL
98056 +i2c_hid_alloc_buffers_33673 i2c_hid_alloc_buffers 2 33673 NULL
98057 +ath6kl_wmi_startscan_cmd_33674 ath6kl_wmi_startscan_cmd 8 33674 NULL
98058 +nv50_disp_dmac_create__33696 nv50_disp_dmac_create_ 6 33696 NULL
98059 +compat_insnlist_33706 compat_insnlist 2 33706 NULL
98060 +sys_keyctl_33708 sys_keyctl 4 33708 NULL nohasharray
98061 +netlink_sendmsg_33708 netlink_sendmsg 4 33708 &sys_keyctl_33708
98062 +tipc_link_stats_33716 tipc_link_stats 3 33716 NULL
98063 +pvr2_stream_buffer_count_33719 pvr2_stream_buffer_count 2 33719 NULL
98064 +ocfs2_extent_map_get_blocks_33720 ocfs2_extent_map_get_blocks 2 33720 NULL
98065 +__mutex_lock_interruptible_slowpath_33735 __mutex_lock_interruptible_slowpath 0 33735 NULL
98066 +Read_hfc_33755 Read_hfc 0 33755 NULL
98067 +vifs_state_read_33762 vifs_state_read 3 33762 NULL
98068 +hashtab_create_33769 hashtab_create 3 33769 NULL
98069 +midibuf_message_length_33770 midibuf_message_length 0 33770 NULL
98070 +if_sdio_read_rx_len_33800 if_sdio_read_rx_len 0 33800 NULL
98071 +find_next_offset_33804 find_next_offset 3 33804 NULL
98072 +sky2_rx_pad_33819 sky2_rx_pad 0 33819 NULL
98073 +sep_create_msgarea_context_33829 sep_create_msgarea_context 4 33829 NULL
98074 +scrub_setup_recheck_block_33831 scrub_setup_recheck_block 5-4 33831 NULL
98075 +udplite_manip_pkt_33832 udplite_manip_pkt 4 33832 NULL
98076 +usb_dump_endpoint_descriptor_33849 usb_dump_endpoint_descriptor 0 33849 NULL
98077 +calgary_alloc_coherent_33851 calgary_alloc_coherent 2 33851 NULL
98078 +oz_cdev_write_33852 oz_cdev_write 3 33852 NULL
98079 +cap_mmap_addr_33853 cap_mmap_addr 0 33853 NULL
98080 +get_user_pages_33908 get_user_pages 0-3-4 33908 NULL
98081 +queue_logical_block_size_33918 queue_logical_block_size 0 33918 NULL
98082 +sel_read_avc_cache_threshold_33942 sel_read_avc_cache_threshold 3 33942 NULL
98083 +lpfc_idiag_ctlacc_read_33943 lpfc_idiag_ctlacc_read 3 33943 NULL
98084 +read_file_tgt_rx_stats_33944 read_file_tgt_rx_stats 3 33944 NULL
98085 +vga_switcheroo_debugfs_write_33984 vga_switcheroo_debugfs_write 3 33984 NULL
98086 +__ntfs_malloc_34022 __ntfs_malloc 1 34022 NULL
98087 +ppp_write_34034 ppp_write 3 34034 NULL
98088 +tty_insert_flip_string_34042 tty_insert_flip_string 3 34042 NULL
98089 +__domain_flush_pages_34045 __domain_flush_pages 2-3 34045 NULL
98090 +acpi_dev_get_irqresource_34064 acpi_dev_get_irqresource 2 34064 NULL
98091 +memcg_update_all_caches_34068 memcg_update_all_caches 1 34068 NULL
98092 +read_file_ant_diversity_34071 read_file_ant_diversity 3 34071 NULL
98093 +compat_hdio_ioctl_34088 compat_hdio_ioctl 4 34088 NULL
98094 +pipeline_pipeline_fifo_full_read_34095 pipeline_pipeline_fifo_full_read 3 34095 NULL
98095 +is_discarded_oblock_34120 is_discarded_oblock 2 34120 NULL
98096 +islpci_mgt_transmit_34133 islpci_mgt_transmit 5 34133 NULL
98097 +ttm_dma_page_pool_free_34135 ttm_dma_page_pool_free 2 34135 NULL
98098 +cdc_mbim_process_dgram_34136 cdc_mbim_process_dgram 3 34136 NULL
98099 +ixgbe_dbg_netdev_ops_write_34141 ixgbe_dbg_netdev_ops_write 3 34141 NULL
98100 +shmem_pread_fast_34147 shmem_pread_fast 3 34147 NULL
98101 +skb_to_sgvec_34171 skb_to_sgvec 0 34171 NULL
98102 +ext4_da_write_begin_34215 ext4_da_write_begin 3-4 34215 NULL
98103 +bl_pipe_downcall_34264 bl_pipe_downcall 3 34264 NULL
98104 +pcf857x_to_irq_34273 pcf857x_to_irq 2 34273 NULL
98105 +zone_spanned_pages_in_node_34299 zone_spanned_pages_in_node 0 34299 NULL
98106 +iov_iter_single_seg_count_34326 iov_iter_single_seg_count 0 34326 NULL nohasharray
98107 +pcpu_need_to_extend_34326 pcpu_need_to_extend 0 34326 &iov_iter_single_seg_count_34326
98108 +__insert_34349 __insert 2-3 34349 NULL
98109 +crypto_ablkcipher_ivsize_34363 crypto_ablkcipher_ivsize 0 34363 NULL
98110 +rngapi_reset_34366 rngapi_reset 3 34366 NULL nohasharray
98111 +p54_alloc_skb_34366 p54_alloc_skb 3 34366 &rngapi_reset_34366
98112 +reiserfs_resize_34377 reiserfs_resize 2 34377 NULL
98113 +ea_read_34378 ea_read 0 34378 NULL
98114 +av7110_vbi_write_34384 av7110_vbi_write 3 34384 NULL
98115 +usbvision_v4l2_read_34386 usbvision_v4l2_read 3 34386 NULL
98116 +read_rbu_image_type_34387 read_rbu_image_type 6 34387 NULL
98117 +iwl_calib_set_34400 iwl_calib_set 3 34400 NULL nohasharray
98118 +ivtv_read_pos_34400 ivtv_read_pos 3 34400 &iwl_calib_set_34400
98119 +nl80211_send_disassoc_34424 nl80211_send_disassoc 4 34424 NULL
98120 +usbtest_alloc_urb_34446 usbtest_alloc_urb 3-5 34446 NULL
98121 +mwifiex_regrdwr_read_34472 mwifiex_regrdwr_read 3 34472 NULL
98122 +skcipher_sndbuf_34476 skcipher_sndbuf 0 34476 NULL
98123 +i2o_parm_field_get_34477 i2o_parm_field_get 5 34477 NULL
98124 +security_inode_permission_34488 security_inode_permission 0 34488 NULL
98125 +tracing_stats_read_34537 tracing_stats_read 3 34537 NULL
98126 +hugetlbfs_read_actor_34547 hugetlbfs_read_actor 0-2-5-4 34547 NULL
98127 +dbBackSplit_34561 dbBackSplit 0 34561 NULL
98128 +alloc_ieee80211_rsl_34564 alloc_ieee80211_rsl 1 34564 NULL
98129 +velocity_rx_copy_34583 velocity_rx_copy 2 34583 NULL
98130 +init_send_hfcd_34586 init_send_hfcd 1 34586 NULL
98131 +inet6_ifla6_size_34591 inet6_ifla6_size 0 34591 NULL
98132 +ceph_msgpool_init_34599 ceph_msgpool_init 4 34599 NULL
98133 +brcmf_cfg80211_mgmt_tx_34608 brcmf_cfg80211_mgmt_tx 7 34608 NULL
98134 +__jffs2_ref_totlen_34609 __jffs2_ref_totlen 0 34609 NULL
98135 +__cfg80211_disconnected_34622 __cfg80211_disconnected 3 34622 NULL
98136 +cnic_alloc_dma_34641 cnic_alloc_dma 3 34641 NULL
98137 +tomoyo_dump_page_34649 tomoyo_dump_page 2 34649 NULL
98138 +nf_nat_mangle_udp_packet_34661 nf_nat_mangle_udp_packet 8-6 34661 NULL
98139 +isr_fiqs_read_34687 isr_fiqs_read 3 34687 NULL
98140 +port_print_34704 port_print 3 34704 NULL
98141 +alloc_irq_and_cfg_at_34706 alloc_irq_and_cfg_at 1 34706 NULL
98142 +ieee80211_if_read_num_sta_ps_34722 ieee80211_if_read_num_sta_ps 3 34722 NULL
98143 +platform_list_read_file_34734 platform_list_read_file 3 34734 NULL
98144 +reg_w_ixbuf_34736 reg_w_ixbuf 4 34736 NULL
98145 +qib_cdev_init_34778 qib_cdev_init 1 34778 NULL
98146 +__copy_in_user_34790 __copy_in_user 3 34790 NULL
98147 +drbd_get_max_capacity_34804 drbd_get_max_capacity 0 34804 NULL
98148 +b43_debugfs_write_34838 b43_debugfs_write 3 34838 NULL
98149 +nl_portid_hash_zalloc_34843 nl_portid_hash_zalloc 1 34843 NULL
98150 +acpi_system_write_wakeup_device_34853 acpi_system_write_wakeup_device 3 34853 NULL
98151 +usb_serial_generic_prepare_write_buffer_34857 usb_serial_generic_prepare_write_buffer 3 34857 NULL
98152 +ieee80211_if_read_txpower_34871 ieee80211_if_read_txpower 3 34871 NULL
98153 +msg_print_text_34889 msg_print_text 0 34889 NULL
98154 +ieee80211_if_write_34894 ieee80211_if_write 3 34894 NULL
98155 +compat_put_uint_34905 compat_put_uint 1 34905 NULL
98156 +__inode_permission_34925 __inode_permission 0 34925 NULL nohasharray
98157 +btrfs_super_chunk_root_34925 btrfs_super_chunk_root 0 34925 &__inode_permission_34925
98158 +skb_gro_header_slow_34958 skb_gro_header_slow 2 34958 NULL
98159 +Realloc_34961 Realloc 2 34961 NULL
98160 +mq_lookup_34990 mq_lookup 2 34990 NULL
98161 +rx_rx_hdr_overflow_read_35002 rx_rx_hdr_overflow_read 3 35002 NULL
98162 +l2cap_skbuff_fromiovec_35003 l2cap_skbuff_fromiovec 4-3 35003 NULL
98163 +dm_cache_insert_mapping_35005 dm_cache_insert_mapping 2-3 35005 NULL
98164 +sisusb_copy_memory_35016 sisusb_copy_memory 4 35016 NULL
98165 +alloc_p2m_page_35025 alloc_p2m_page 0 35025 NULL
98166 +coda_psdev_read_35029 coda_psdev_read 3 35029 NULL
98167 +btmrvl_gpiogap_write_35053 btmrvl_gpiogap_write 3 35053 NULL
98168 +pwr_connection_out_of_sync_read_35061 pwr_connection_out_of_sync_read 3 35061 NULL
98169 +store_ifalias_35088 store_ifalias 4 35088 NULL
98170 +__kfifo_uint_must_check_helper_35097 __kfifo_uint_must_check_helper 0-1 35097 NULL
98171 +capi_write_35104 capi_write 3 35104 NULL nohasharray
98172 +tx_tx_done_template_read_35104 tx_tx_done_template_read 3 35104 &capi_write_35104
98173 +ide_settings_proc_write_35110 ide_settings_proc_write 3 35110 NULL
98174 +pointer_35138 pointer 0 35138 NULL
98175 +gntdev_alloc_map_35145 gntdev_alloc_map 2 35145 NULL
98176 +iscsi_conn_setup_35159 iscsi_conn_setup 2 35159 NULL
98177 +ieee80211_if_read_bssid_35161 ieee80211_if_read_bssid 3 35161 NULL
98178 +mlx4_ib_get_cq_umem_35184 mlx4_ib_get_cq_umem 5-6 35184 NULL
98179 +iwl_nvm_read_chunk_35198 iwl_nvm_read_chunk 0 35198 NULL
98180 +uprobe_get_swbp_addr_35201 uprobe_get_swbp_addr 0 35201 NULL
98181 +unix_stream_recvmsg_35210 unix_stream_recvmsg 4 35210 NULL
98182 +_osd_req_alist_elem_size_35216 _osd_req_alist_elem_size 0-2 35216 NULL
98183 +striped_read_35218 striped_read 0-2-8-3 35218 NULL nohasharray
98184 +security_key_getsecurity_35218 security_key_getsecurity 0 35218 &striped_read_35218
98185 +rx_rx_cmplt_task_read_35226 rx_rx_cmplt_task_read 3 35226 NULL nohasharray
98186 +video_register_device_no_warn_35226 video_register_device_no_warn 3 35226 &rx_rx_cmplt_task_read_35226
98187 +gfn_to_page_many_atomic_35234 gfn_to_page_many_atomic 2 35234 NULL
98188 +set_fd_set_35249 set_fd_set 1 35249 NULL
98189 +ioapic_setup_resources_35255 ioapic_setup_resources 1 35255 NULL
98190 +dma_show_regs_35266 dma_show_regs 3 35266 NULL
98191 +irda_recvmsg_stream_35280 irda_recvmsg_stream 4 35280 NULL
98192 +i2o_block_end_request_35282 i2o_block_end_request 3 35282 NULL
98193 +isr_rx_rdys_read_35283 isr_rx_rdys_read 3 35283 NULL
98194 +brcmf_sdio_forensic_read_35311 brcmf_sdio_forensic_read 3 35311 NULL nohasharray
98195 +__btrfs_buffered_write_35311 __btrfs_buffered_write 3 35311 &brcmf_sdio_forensic_read_35311
98196 +tracing_read_pipe_35312 tracing_read_pipe 3 35312 NULL
98197 +sys_setsockopt_35320 sys_setsockopt 5 35320 NULL
98198 +irq_domain_disassociate_many_35325 irq_domain_disassociate_many 2-3 35325 NULL
98199 +fallback_on_nodma_alloc_35332 fallback_on_nodma_alloc 2 35332 NULL
98200 +pskb_network_may_pull_35336 pskb_network_may_pull 2 35336 NULL
98201 +ieee80211_if_fmt_ap_power_level_35347 ieee80211_if_fmt_ap_power_level 3 35347 NULL
98202 +nouveau_devinit_create__35348 nouveau_devinit_create_ 4 35348 NULL
98203 +hpi_alloc_control_cache_35351 hpi_alloc_control_cache 1 35351 NULL
98204 +compat_filldir64_35354 compat_filldir64 3 35354 NULL
98205 +rawv6_send_hdrinc_35425 rawv6_send_hdrinc 3 35425 NULL
98206 +__set_test_and_free_35436 __set_test_and_free 2 35436 NULL
98207 +buffer_to_user_35439 buffer_to_user 3 35439 NULL
98208 +i915_wedged_read_35474 i915_wedged_read 3 35474 NULL
98209 +ecryptfs_get_zeroed_pages_35483 ecryptfs_get_zeroed_pages 0 35483 NULL
98210 +do_atm_ioctl_35519 do_atm_ioctl 3 35519 NULL
98211 +async_setkey_35521 async_setkey 3 35521 NULL
98212 +__filemap_fdatawrite_range_35528 __filemap_fdatawrite_range 0 35528 NULL
98213 +iwl_dbgfs_bt_traffic_read_35534 iwl_dbgfs_bt_traffic_read 3 35534 NULL
98214 +rxpipe_tx_xfr_host_int_trig_rx_data_read_35538 rxpipe_tx_xfr_host_int_trig_rx_data_read 3 35538 NULL
98215 +ibnl_put_attr_35541 ibnl_put_attr 3 35541 NULL
98216 +ieee80211_if_write_smps_35550 ieee80211_if_write_smps 3 35550 NULL
98217 +ext2_acl_from_disk_35580 ext2_acl_from_disk 2 35580 NULL
98218 +spk_msg_set_35586 spk_msg_set 3 35586 NULL
98219 +ReadZReg_35604 ReadZReg 0 35604 NULL
98220 +kernel_readv_35617 kernel_readv 3 35617 NULL
98221 +ixgbe_pci_sriov_configure_35624 ixgbe_pci_sriov_configure 2 35624 NULL
98222 +reiserfs_readpages_35629 reiserfs_readpages 4 35629 NULL
98223 +spi_register_board_info_35651 spi_register_board_info 2 35651 NULL
98224 +store_debug_level_35652 store_debug_level 3 35652 NULL
98225 +rdmaltWithLock_35669 rdmaltWithLock 0 35669 NULL
98226 +compat_sys_kexec_load_35674 compat_sys_kexec_load 2 35674 NULL
98227 +dm_table_create_35687 dm_table_create 3 35687 NULL
98228 +rds_page_copy_user_35691 rds_page_copy_user 4 35691 NULL
98229 +pci_enable_sriov_35745 pci_enable_sriov 2 35745 NULL
98230 +iwl_dbgfs_disable_ht40_read_35761 iwl_dbgfs_disable_ht40_read 3 35761 NULL
98231 +udf_alloc_i_data_35786 udf_alloc_i_data 2 35786 NULL
98232 +pvr2_hdw_cpufw_get_35824 pvr2_hdw_cpufw_get 0-4-2 35824 NULL
98233 +tx_tx_cmplt_read_35854 tx_tx_cmplt_read 3 35854 NULL
98234 +mthca_buf_alloc_35861 mthca_buf_alloc 2 35861 NULL
98235 +fls64_35862 fls64 0 35862 NULL
98236 +kvm_dirty_bitmap_bytes_35886 kvm_dirty_bitmap_bytes 0 35886 NULL
98237 +ieee80211_if_fmt_dot11MeshRetryTimeout_35890 ieee80211_if_fmt_dot11MeshRetryTimeout 3 35890 NULL
98238 +uwb_rc_cmd_done_35892 uwb_rc_cmd_done 4 35892 NULL
98239 +kernel_setsockopt_35913 kernel_setsockopt 5 35913 NULL
98240 +rbio_nr_pages_35916 rbio_nr_pages 0-1-2 35916 NULL
98241 +vol_cdev_compat_ioctl_35923 vol_cdev_compat_ioctl 3 35923 NULL
98242 +sctp_tsnmap_mark_35929 sctp_tsnmap_mark 2 35929 NULL
98243 +rx_defrag_init_called_read_35935 rx_defrag_init_called_read 3 35935 NULL
98244 +put_cmsg_compat_35937 put_cmsg_compat 4 35937 NULL
98245 +ext_rts51x_sd_execute_write_data_35971 ext_rts51x_sd_execute_write_data 9 35971 NULL
98246 +ceph_buffer_new_35974 ceph_buffer_new 1 35974 NULL
98247 +acl_alloc_35979 acl_alloc 1 35979 NULL
98248 +generic_file_aio_read_35987 generic_file_aio_read 0 35987 NULL
98249 +koneplus_sysfs_write_35993 koneplus_sysfs_write 6 35993 NULL
98250 +il3945_ucode_tx_stats_read_36016 il3945_ucode_tx_stats_read 3 36016 NULL
98251 +ubi_eba_write_leb_36029 ubi_eba_write_leb 5-6 36029 NULL
98252 +account_shadowed_36048 account_shadowed 2 36048 NULL
98253 +gpio_power_read_36059 gpio_power_read 3 36059 NULL
98254 +write_emulate_36065 write_emulate 2-4 36065 NULL
98255 +radeon_vm_num_pdes_36070 radeon_vm_num_pdes 0 36070 NULL
98256 +ieee80211_if_fmt_peer_36071 ieee80211_if_fmt_peer 3 36071 NULL
98257 +ext3_new_blocks_36073 ext3_new_blocks 3 36073 NULL
98258 +ieee80211_if_write_tsf_36077 ieee80211_if_write_tsf 3 36077 NULL
98259 +snd_pcm_plug_read_transfer_36080 snd_pcm_plug_read_transfer 0-3 36080 NULL
98260 +vga_arb_write_36112 vga_arb_write 3 36112 NULL
98261 +simple_xattr_alloc_36118 simple_xattr_alloc 2 36118 NULL
98262 +compat_ptrace_request_36131 compat_ptrace_request 3-4 36131 NULL
98263 +vmalloc_exec_36132 vmalloc_exec 1 36132 NULL
98264 +max8925_irq_domain_map_36133 max8925_irq_domain_map 2 36133 NULL
98265 +ext3_readpages_36144 ext3_readpages 4 36144 NULL
98266 +alloc_vm_area_36149 alloc_vm_area 1 36149 NULL
98267 +twl_set_36154 twl_set 2 36154 NULL
98268 +b1_alloc_card_36155 b1_alloc_card 1 36155 NULL
98269 +btrfs_file_extent_inline_len_36158 btrfs_file_extent_inline_len 0 36158 NULL
98270 +snd_korg1212_copy_from_36169 snd_korg1212_copy_from 6 36169 NULL
98271 +ubifs_read_nnode_36221 ubifs_read_nnode 0 36221 NULL
98272 +is_dirty_36223 is_dirty 2 36223 NULL
98273 +dma_alloc_attrs_36225 dma_alloc_attrs 0 36225 NULL
98274 +nfqnl_mangle_36226 nfqnl_mangle 4-2 36226 NULL
98275 +atomic_stats_read_36228 atomic_stats_read 3 36228 NULL
98276 +viafb_iga1_odev_proc_write_36241 viafb_iga1_odev_proc_write 3 36241 NULL
98277 +rproc_recovery_read_36245 rproc_recovery_read 3 36245 NULL
98278 +scrub_stripe_36248 scrub_stripe 5-4 36248 NULL
98279 +compat_sys_mbind_36256 compat_sys_mbind 5 36256 NULL
98280 +usb_buffer_alloc_36276 usb_buffer_alloc 2 36276 NULL
98281 +codec_reg_read_file_36280 codec_reg_read_file 3 36280 NULL
98282 +crypto_shash_digestsize_36284 crypto_shash_digestsize 0 36284 NULL
98283 +nouveau_cli_create_36293 nouveau_cli_create 3 36293 NULL
98284 +lpfc_debugfs_dif_err_read_36303 lpfc_debugfs_dif_err_read 3 36303 NULL
98285 +ad7879_spi_xfer_36311 ad7879_spi_xfer 3 36311 NULL
98286 +fuse_get_user_addr_36312 fuse_get_user_addr 0 36312 NULL
98287 +fat_compat_ioctl_filldir_36328 fat_compat_ioctl_filldir 3 36328 NULL
98288 +lc_create_36332 lc_create 4 36332 NULL
98289 +jbd2_journal_init_revoke_table_36336 jbd2_journal_init_revoke_table 1 36336 NULL
98290 +v9fs_file_readn_36353 v9fs_file_readn 4 36353 NULL nohasharray
98291 +xz_dec_lzma2_create_36353 xz_dec_lzma2_create 2 36353 &v9fs_file_readn_36353
98292 +to_sector_36361 to_sector 0-1 36361 NULL
98293 +tunables_read_36385 tunables_read 3 36385 NULL
98294 +afs_alloc_flat_call_36399 afs_alloc_flat_call 2-3 36399 NULL
98295 +sctp_tsnmap_init_36446 sctp_tsnmap_init 2 36446 NULL
98296 +alloc_etherdev_mqs_36450 alloc_etherdev_mqs 1 36450 NULL
98297 +b43_nphy_load_samples_36481 b43_nphy_load_samples 3 36481 NULL
98298 +tx_tx_checksum_result_read_36490 tx_tx_checksum_result_read 3 36490 NULL
98299 +__hwahc_op_set_ptk_36510 __hwahc_op_set_ptk 5 36510 NULL
98300 +mcam_v4l_read_36513 mcam_v4l_read 3 36513 NULL
98301 +get_param_l_36518 get_param_l 0 36518 NULL
98302 +ieee80211_if_read_fwded_frames_36520 ieee80211_if_read_fwded_frames 3 36520 NULL
98303 +lguest_setup_irq_36531 lguest_setup_irq 1 36531 NULL
98304 +crypto_aead_authsize_36537 crypto_aead_authsize 0 36537 NULL
98305 +cpu_type_read_36540 cpu_type_read 3 36540 NULL
98306 +get_entry_len_36549 get_entry_len 0 36549 NULL
98307 +__kfifo_to_user_36555 __kfifo_to_user 3 36555 NULL nohasharray
98308 +macvtap_do_read_36555 macvtap_do_read 4 36555 &__kfifo_to_user_36555
98309 +btrfs_get_token_64_36572 btrfs_get_token_64 0 36572 NULL
98310 +ssb_bus_scan_36578 ssb_bus_scan 2 36578 NULL
98311 +__erst_read_36579 __erst_read 0 36579 NULL
98312 +put_cmsg_36589 put_cmsg 4 36589 NULL
98313 +pcnet32_realloc_rx_ring_36598 pcnet32_realloc_rx_ring 3 36598 NULL
98314 +fat_ioctl_filldir_36621 fat_ioctl_filldir 3 36621 NULL
98315 +vxge_config_vpaths_36636 vxge_config_vpaths 0 36636 NULL
98316 +format_decode_36638 format_decode 0 36638 NULL
98317 +ced_ioctl_36647 ced_ioctl 2 36647 NULL
98318 +lpfc_idiag_extacc_alloc_get_36648 lpfc_idiag_extacc_alloc_get 0-3 36648 NULL
98319 +osd_req_list_collection_objects_36664 osd_req_list_collection_objects 5 36664 NULL
98320 +iscsi_host_alloc_36671 iscsi_host_alloc 2 36671 NULL
98321 +ptr_to_compat_36680 ptr_to_compat 0 36680 NULL
98322 +ext4_mb_discard_group_preallocations_36685 ext4_mb_discard_group_preallocations 2 36685 NULL
98323 +extract_icmp6_fields_36732 extract_icmp6_fields 2 36732 NULL
98324 +snd_rawmidi_kernel_read1_36740 snd_rawmidi_kernel_read1 4 36740 NULL
98325 +cxgbi_device_register_36746 cxgbi_device_register 1-2 36746 NULL
98326 +ps_poll_upsd_timeouts_read_36755 ps_poll_upsd_timeouts_read 3 36755 NULL
98327 +ip4ip6_err_36772 ip4ip6_err 5 36772 NULL
98328 +ptp_filter_init_36780 ptp_filter_init 2 36780 NULL
98329 +proc_fault_inject_read_36802 proc_fault_inject_read 3 36802 NULL
98330 +hiddev_ioctl_36816 hiddev_ioctl 2 36816 NULL
98331 +int_hardware_entry_36833 int_hardware_entry 3 36833 NULL
98332 +fc_change_queue_depth_36841 fc_change_queue_depth 2 36841 NULL
98333 +keyctl_describe_key_36853 keyctl_describe_key 3 36853 NULL
98334 +cm_write_36858 cm_write 3 36858 NULL
98335 +tx_tx_data_programmed_read_36871 tx_tx_data_programmed_read 3 36871 NULL
98336 +svc_setsockopt_36876 svc_setsockopt 5 36876 NULL
98337 +raid56_parity_write_36877 raid56_parity_write 5 36877 NULL
98338 +__btrfs_map_block_36883 __btrfs_map_block 3 36883 NULL
98339 +ib_ucm_alloc_data_36885 ib_ucm_alloc_data 3 36885 NULL
98340 +selinux_inode_notifysecctx_36896 selinux_inode_notifysecctx 3 36896 NULL
98341 +OS_kmalloc_36909 OS_kmalloc 1 36909 NULL
98342 +build_key_36931 build_key 1 36931 NULL
98343 +crypto_blkcipher_ivsize_36944 crypto_blkcipher_ivsize 0 36944 NULL
98344 +write_leb_36957 write_leb 5 36957 NULL
98345 +ntfs_external_attr_find_36963 ntfs_external_attr_find 0 36963 NULL
98346 +sparse_early_mem_maps_alloc_node_36971 sparse_early_mem_maps_alloc_node 4 36971 NULL
98347 +drbd_new_dev_size_36998 drbd_new_dev_size 0-3 36998 NULL
98348 +auok190xfb_write_37001 auok190xfb_write 3 37001 NULL
98349 +setxattr_37006 setxattr 4 37006 NULL
98350 +qp_broker_create_37053 qp_broker_create 6-5 37053 NULL nohasharray
98351 +ieee80211_if_read_drop_unencrypted_37053 ieee80211_if_read_drop_unencrypted 3 37053 &qp_broker_create_37053
98352 +parse_command_37079 parse_command 2 37079 NULL
98353 +pipeline_cs_rx_packet_in_read_37089 pipeline_cs_rx_packet_in_read 3 37089 NULL
98354 +tun_get_user_37094 tun_get_user 5 37094 NULL
98355 +has_wrprotected_page_37123 has_wrprotected_page 2-3 37123 NULL
98356 +snd_hda_get_conn_list_37132 snd_hda_get_conn_list 0 37132 NULL
98357 +msg_word_37164 msg_word 0 37164 NULL
98358 +can_set_xattr_37182 can_set_xattr 4 37182 NULL
98359 +crypto_shash_descsize_37212 crypto_shash_descsize 0 37212 NULL
98360 +regmap_access_read_file_37223 regmap_access_read_file 3 37223 NULL
98361 +__do_replace_37227 __do_replace 5 37227 NULL
98362 +rx_filter_dup_filter_read_37238 rx_filter_dup_filter_read 3 37238 NULL
98363 +prot_queue_del_37258 prot_queue_del 0 37258 NULL
98364 +ath6kl_wmi_set_ie_cmd_37260 ath6kl_wmi_set_ie_cmd 6 37260 NULL
98365 +exofs_max_io_pages_37263 exofs_max_io_pages 0-2 37263 NULL
98366 +nested_svm_map_37268 nested_svm_map 2 37268 NULL
98367 +c101_run_37279 c101_run 2 37279 NULL
98368 +srp_target_alloc_37288 srp_target_alloc 3 37288 NULL
98369 +ieee80211_if_read_power_mode_37305 ieee80211_if_read_power_mode 3 37305 NULL
98370 +jffs2_write_dirent_37311 jffs2_write_dirent 5 37311 NULL
98371 +send_msg_37323 send_msg 4 37323 NULL
98372 +brcmf_sdbrcm_membytes_37324 brcmf_sdbrcm_membytes 3-5 37324 NULL
98373 +l2cap_create_connless_pdu_37327 l2cap_create_connless_pdu 3 37327 NULL
98374 +scsi_mode_select_37330 scsi_mode_select 6 37330 NULL
98375 +rxrpc_server_sendmsg_37331 rxrpc_server_sendmsg 4 37331 NULL
98376 +security_inode_getsecurity_37354 security_inode_getsecurity 0 37354 NULL
98377 +iommu_num_pages_37391 iommu_num_pages 0-1-3-2 37391 NULL
98378 +sys_getxattr_37418 sys_getxattr 4 37418 NULL
98379 +hci_sock_sendmsg_37420 hci_sock_sendmsg 4 37420 NULL
98380 +acpi_os_allocate_zeroed_37422 acpi_os_allocate_zeroed 1 37422 NULL nohasharray
98381 +find_next_bit_37422 find_next_bit 0-2-3 37422 &acpi_os_allocate_zeroed_37422
98382 +tty_insert_flip_string_fixed_flag_37428 tty_insert_flip_string_fixed_flag 4 37428 NULL
98383 +iwl_print_last_event_logs_37433 iwl_print_last_event_logs 0-7-9 37433 NULL
98384 +tcp_established_options_37450 tcp_established_options 0 37450 NULL
98385 +brcmf_sdio_dump_console_37455 brcmf_sdio_dump_console 4 37455 NULL
98386 +__remove_37457 __remove 2 37457 NULL
98387 +ufs_data_ptr_to_cpu_37475 ufs_data_ptr_to_cpu 0 37475 NULL
98388 +get_est_timing_37484 get_est_timing 0 37484 NULL
98389 +kmem_realloc_37489 kmem_realloc 2 37489 NULL
98390 +kvm_vcpu_compat_ioctl_37500 kvm_vcpu_compat_ioctl 3 37500 NULL
98391 +vmalloc_32_user_37519 vmalloc_32_user 1 37519 NULL
98392 +fault_inject_read_37534 fault_inject_read 3 37534 NULL
98393 +hdr_size_37536 hdr_size 0 37536 NULL
98394 +a2p_37544 a2p 0-1 37544 NULL
98395 +sep_create_dcb_dmatables_context_37551 sep_create_dcb_dmatables_context 6 37551 NULL nohasharray
98396 +nf_nat_mangle_tcp_packet_37551 nf_nat_mangle_tcp_packet 6-8 37551 &sep_create_dcb_dmatables_context_37551
98397 +xhci_alloc_streams_37586 xhci_alloc_streams 5 37586 NULL
98398 +mlx4_get_mgm_entry_size_37607 mlx4_get_mgm_entry_size 0 37607 NULL
98399 +kvm_read_guest_page_mmu_37611 kvm_read_guest_page_mmu 6-3 37611 NULL
98400 +policy_residency_37629 policy_residency 0 37629 NULL
98401 +check_pt_base_37635 check_pt_base 3 37635 NULL
98402 +alloc_fd_37637 alloc_fd 1 37637 NULL
98403 +bio_copy_user_iov_37660 bio_copy_user_iov 4 37660 NULL
98404 +rfcomm_sock_sendmsg_37661 rfcomm_sock_sendmsg 4 37661 NULL nohasharray
98405 +vmw_framebuffer_dmabuf_dirty_37661 vmw_framebuffer_dmabuf_dirty 6 37661 &rfcomm_sock_sendmsg_37661
98406 +lnw_gpio_to_irq_37665 lnw_gpio_to_irq 2 37665 NULL
98407 +ieee80211_if_read_rc_rateidx_mcs_mask_2ghz_37675 ieee80211_if_read_rc_rateidx_mcs_mask_2ghz 3 37675 NULL
98408 +regmap_map_read_file_37685 regmap_map_read_file 3 37685 NULL
98409 +nametbl_header_37698 nametbl_header 2 37698 NULL
98410 +__le32_to_cpup_37702 __le32_to_cpup 0 37702 NULL
98411 +dm_thin_remove_block_37724 dm_thin_remove_block 2 37724 NULL
98412 +find_active_uprobe_37733 find_active_uprobe 1 37733 NULL
98413 +read_enabled_file_bool_37744 read_enabled_file_bool 3 37744 NULL
98414 +ocfs2_duplicate_clusters_by_jbd_37749 ocfs2_duplicate_clusters_by_jbd 6-4-5 37749 NULL
98415 +ocfs2_control_cfu_37750 ocfs2_control_cfu 2 37750 NULL
98416 +ipath_cdev_init_37752 ipath_cdev_init 1 37752 NULL
98417 +dccp_setsockopt_cscov_37766 dccp_setsockopt_cscov 2 37766 NULL
98418 +dma_pte_addr_37784 dma_pte_addr 0 37784 NULL
98419 +il4965_rs_sta_dbgfs_rate_scale_data_read_37792 il4965_rs_sta_dbgfs_rate_scale_data_read 3 37792 NULL
98420 +smk_read_logging_37804 smk_read_logging 3 37804 NULL
98421 +deny_write_access_37813 deny_write_access 0 37813 NULL
98422 +rx_decrypt_key_not_found_read_37820 rx_decrypt_key_not_found_read 3 37820 NULL
98423 +bitmap_find_next_zero_area_37827 bitmap_find_next_zero_area 2-3-5-4 37827 NULL
98424 +o2hb_debug_read_37851 o2hb_debug_read 3 37851 NULL
98425 +xfs_dir2_block_to_sf_37868 xfs_dir2_block_to_sf 3 37868 NULL
98426 +sys_setxattr_37880 sys_setxattr 4 37880 NULL
98427 +dvb_net_sec_37884 dvb_net_sec 3 37884 NULL
98428 +max77686_irq_domain_map_37897 max77686_irq_domain_map 2 37897 NULL
98429 +compat_sys_rt_sigpending_37899 compat_sys_rt_sigpending 2 37899 NULL
98430 +tipc_link_send_sections_fast_37920 tipc_link_send_sections_fast 4 37920 NULL
98431 +pkt_alloc_packet_data_37928 pkt_alloc_packet_data 1 37928 NULL
98432 +read_rbu_packet_size_37939 read_rbu_packet_size 6 37939 NULL
98433 +fifo_alloc_37961 fifo_alloc 1 37961 NULL
98434 +ext3_free_blocks_sb_37967 ext3_free_blocks_sb 3-4 37967 NULL
98435 +rds_rdma_extra_size_37990 rds_rdma_extra_size 0 37990 NULL
98436 +persistent_ram_old_size_37997 persistent_ram_old_size 0 37997 NULL
98437 +vfs_readv_38011 vfs_readv 3 38011 NULL
98438 +aggr_recv_addba_req_evt_38037 aggr_recv_addba_req_evt 4 38037 NULL
98439 +klsi_105_prepare_write_buffer_38044 klsi_105_prepare_write_buffer 3 38044 NULL nohasharray
98440 +il_dbgfs_chain_noise_read_38044 il_dbgfs_chain_noise_read 3 38044 &klsi_105_prepare_write_buffer_38044
98441 +_xfs_buf_alloc_38058 _xfs_buf_alloc 3 38058 NULL nohasharray
98442 +is_discarded_38058 is_discarded 2 38058 &_xfs_buf_alloc_38058
98443 +nsm_create_handle_38060 nsm_create_handle 4 38060 NULL
98444 +alloc_ltalkdev_38071 alloc_ltalkdev 1 38071 NULL
98445 +xfs_buf_readahead_map_38081 xfs_buf_readahead_map 3 38081 NULL
98446 +uwb_mac_addr_print_38085 uwb_mac_addr_print 2 38085 NULL
98447 +request_key_auth_new_38092 request_key_auth_new 3 38092 NULL
98448 +proc_self_readlink_38094 proc_self_readlink 3 38094 NULL
98449 +ep0_read_38095 ep0_read 3 38095 NULL
98450 +sk_wmem_schedule_38096 sk_wmem_schedule 2 38096 NULL
98451 +rbd_obj_read_sync_38098 rbd_obj_read_sync 3-4 38098 NULL
98452 +snd_pcm_oss_write_38108 snd_pcm_oss_write 3 38108 NULL
98453 +vmw_kms_present_38130 vmw_kms_present 9 38130 NULL
98454 +__ntfs_copy_from_user_iovec_inatomic_38153 __ntfs_copy_from_user_iovec_inatomic 3-4 38153 NULL
98455 +kvm_clear_guest_38164 kvm_clear_guest 3-2 38164 NULL
98456 +cdev_add_38176 cdev_add 2-3 38176 NULL
98457 +brcmf_sdcard_recv_buf_38179 brcmf_sdcard_recv_buf 6 38179 NULL
98458 +rt2x00debug_write_rf_38195 rt2x00debug_write_rf 3 38195 NULL
98459 +get_ucode_user_38202 get_ucode_user 3 38202 NULL
98460 +ext3_new_block_38208 ext3_new_block 3 38208 NULL
98461 +stmpe_gpio_irq_map_38222 stmpe_gpio_irq_map 3 38222 NULL
98462 +osd_req_list_partition_collections_38223 osd_req_list_partition_collections 5 38223 NULL
98463 +palmas_gpio_to_irq_38235 palmas_gpio_to_irq 2 38235 NULL
98464 +vhost_net_compat_ioctl_38237 vhost_net_compat_ioctl 3 38237 NULL
98465 +_ipw_read_reg32_38245 _ipw_read_reg32 0 38245 NULL
98466 +from_dblock_38256 from_dblock 0-1 38256 NULL
98467 +vmci_qp_broker_set_page_store_38260 vmci_qp_broker_set_page_store 2-3 38260 NULL
98468 +ieee80211_if_read_auto_open_plinks_38268 ieee80211_if_read_auto_open_plinks 3 38268 NULL nohasharray
98469 +mthca_alloc_icm_table_38268 mthca_alloc_icm_table 4-3 38268 &ieee80211_if_read_auto_open_plinks_38268
98470 +xfs_bmbt_to_bmdr_38275 xfs_bmbt_to_bmdr 3 38275 NULL nohasharray
98471 +xfs_bmdr_to_bmbt_38275 xfs_bmdr_to_bmbt 5 38275 &xfs_bmbt_to_bmdr_38275
98472 +ftdi_process_packet_38281 ftdi_process_packet 4 38281 NULL nohasharray
98473 +swiotlb_sync_single_for_cpu_38281 swiotlb_sync_single_for_cpu 2 38281 &ftdi_process_packet_38281
98474 +gpa_to_gfn_38291 gpa_to_gfn 0-1 38291 NULL
98475 +zd_mac_rx_38296 zd_mac_rx 3 38296 NULL
98476 +isr_rx_headers_read_38325 isr_rx_headers_read 3 38325 NULL
98477 +ida_simple_get_38326 ida_simple_get 2 38326 NULL
98478 +__snd_gf1_look8_38333 __snd_gf1_look8 0 38333 NULL
98479 +pyra_sysfs_write_38370 pyra_sysfs_write 6 38370 NULL
98480 +dn_sendmsg_38390 dn_sendmsg 4 38390 NULL
98481 +get_valid_node_allowed_38412 get_valid_node_allowed 1-0 38412 NULL
98482 +ocfs2_which_cluster_group_38413 ocfs2_which_cluster_group 2 38413 NULL
98483 +ht_destroy_irq_38418 ht_destroy_irq 1 38418 NULL
98484 +ieee80211_if_read_dtim_count_38419 ieee80211_if_read_dtim_count 3 38419 NULL
98485 +asix_write_cmd_async_38420 asix_write_cmd_async 5 38420 NULL
98486 +pcnet32_realloc_tx_ring_38428 pcnet32_realloc_tx_ring 3 38428 NULL
98487 +pmcraid_copy_sglist_38431 pmcraid_copy_sglist 3 38431 NULL
98488 +kvm_write_guest_38454 kvm_write_guest 4-2 38454 NULL
98489 +i915_min_freq_read_38470 i915_min_freq_read 3 38470 NULL
98490 +kvm_arch_setup_async_pf_38481 kvm_arch_setup_async_pf 3 38481 NULL
98491 +blk_end_bidi_request_38482 blk_end_bidi_request 3-4 38482 NULL
98492 +dev_names_read_38509 dev_names_read 3 38509 NULL
98493 +iscsi_create_iface_38510 iscsi_create_iface 5 38510 NULL
98494 +event_rx_mismatch_read_38518 event_rx_mismatch_read 3 38518 NULL
98495 +set_queue_count_38519 set_queue_count 0 38519 NULL
98496 +mlx4_ib_db_map_user_38529 mlx4_ib_db_map_user 2 38529 NULL
98497 +ubifs_idx_node_sz_38546 ubifs_idx_node_sz 0-2 38546 NULL
98498 +btrfs_discard_extent_38547 btrfs_discard_extent 2 38547 NULL
98499 +irda_sendmsg_dgram_38563 irda_sendmsg_dgram 4 38563 NULL
98500 +il4965_rs_sta_dbgfs_scale_table_read_38564 il4965_rs_sta_dbgfs_scale_table_read 3 38564 NULL
98501 +_ipw_read32_38565 _ipw_read32 0 38565 NULL
98502 +snd_nm256_playback_copy_38567 snd_nm256_playback_copy 5-3 38567 NULL
98503 +copy_ctl_value_to_user_38587 copy_ctl_value_to_user 4 38587 NULL
98504 +cosa_net_setup_rx_38594 cosa_net_setup_rx 2 38594 NULL
98505 +compat_sys_ptrace_38595 compat_sys_ptrace 3-4 38595 NULL
98506 +icn_writecmd_38629 icn_writecmd 2 38629 NULL
98507 +ext2_readpages_38640 ext2_readpages 4 38640 NULL
98508 +cma_create_area_38642 cma_create_area 2 38642 NULL
98509 +audit_init_entry_38644 audit_init_entry 1 38644 NULL
98510 +qp_broker_alloc_38646 qp_broker_alloc 5-6 38646 NULL
98511 +mmc_send_cxd_data_38655 mmc_send_cxd_data 5 38655 NULL
98512 +nouveau_instmem_create__38664 nouveau_instmem_create_ 4 38664 NULL
98513 +cfg80211_send_disassoc_38678 cfg80211_send_disassoc 3 38678 NULL
98514 +iscsit_dump_data_payload_38683 iscsit_dump_data_payload 2 38683 NULL
98515 +ext4_wait_block_bitmap_38695 ext4_wait_block_bitmap 2 38695 NULL
98516 +rbio_add_io_page_38700 rbio_add_io_page 6 38700 NULL
98517 +find_next_usable_block_38716 find_next_usable_block 1-3 38716 NULL
98518 +alloc_trace_probe_38720 alloc_trace_probe 6 38720 NULL
98519 +phys_to_virt_38757 phys_to_virt 0-1 38757 NULL
98520 +udf_readpages_38761 udf_readpages 4 38761 NULL
98521 +iwl_dbgfs_thermal_throttling_read_38779 iwl_dbgfs_thermal_throttling_read 3 38779 NULL
98522 +snd_gus_dram_write_38784 snd_gus_dram_write 4 38784 NULL
98523 +err_decode_38804 err_decode 2 38804 NULL
98524 +ipv6_renew_option_38813 ipv6_renew_option 3 38813 NULL
98525 +sys_select_38827 sys_select 1 38827 NULL
98526 +b43_txhdr_size_38832 b43_txhdr_size 0 38832 NULL
98527 +direct_entry_38836 direct_entry 3 38836 NULL
98528 +compat_udp_setsockopt_38840 compat_udp_setsockopt 5 38840 NULL
98529 +interfaces_38859 interfaces 2 38859 NULL
98530 +pci_msix_table_size_38867 pci_msix_table_size 0 38867 NULL
98531 +sizeof_gpio_leds_priv_38882 sizeof_gpio_leds_priv 0-1 38882 NULL
98532 +dbgfs_state_38894 dbgfs_state 3 38894 NULL
98533 +f2fs_xattr_set_acl_38895 f2fs_xattr_set_acl 4 38895 NULL
98534 +process_bulk_data_command_38906 process_bulk_data_command 4 38906 NULL
98535 +ext3_trim_all_free_38929 ext3_trim_all_free 3-4-2 38929 NULL
98536 +sbp_count_se_tpg_luns_38943 sbp_count_se_tpg_luns 0 38943 NULL
98537 +__ath6kl_wmi_send_mgmt_cmd_38971 __ath6kl_wmi_send_mgmt_cmd 7 38971 NULL
98538 +usb_maxpacket_38977 usb_maxpacket 0 38977 NULL
98539 +OSDSetBlock_38986 OSDSetBlock 4-2 38986 NULL
98540 +udf_new_block_38999 udf_new_block 4 38999 NULL
98541 +get_nodes_39012 get_nodes 3 39012 NULL
98542 +twl6030_interrupt_unmask_39013 twl6030_interrupt_unmask 2 39013 NULL
98543 +acpi_install_gpe_block_39031 acpi_install_gpe_block 4 39031 NULL
98544 +_zd_iowrite32v_async_locked_39034 _zd_iowrite32v_async_locked 3 39034 NULL
98545 +line6_midibuf_read_39067 line6_midibuf_read 0-3 39067 NULL
98546 +ext4_init_block_bitmap_39071 ext4_init_block_bitmap 3 39071 NULL
98547 +tomoyo_truncate_39105 tomoyo_truncate 0 39105 NULL
98548 +__kfifo_to_user_r_39123 __kfifo_to_user_r 3 39123 NULL
98549 +ea_foreach_39133 ea_foreach 0 39133 NULL
98550 +generic_permission_39150 generic_permission 0 39150 NULL
98551 +alloc_ring_39151 alloc_ring 2-4 39151 NULL
98552 +proc_coredump_filter_read_39153 proc_coredump_filter_read 3 39153 NULL
98553 +create_bounce_buffer_39155 create_bounce_buffer 3 39155 NULL
98554 +ext3_xattr_check_names_39174 ext3_xattr_check_names 0 39174 NULL
98555 +init_list_set_39188 init_list_set 2-3 39188 NULL
98556 +ubi_more_update_data_39189 ubi_more_update_data 4 39189 NULL
98557 +qcam_read_bytes_39205 qcam_read_bytes 0 39205 NULL
98558 +qla4_82xx_pci_mem_read_direct_39208 qla4_82xx_pci_mem_read_direct 2 39208 NULL
98559 +vfio_group_fops_compat_ioctl_39219 vfio_group_fops_compat_ioctl 3 39219 NULL
98560 +ivtv_v4l2_write_39226 ivtv_v4l2_write 3 39226 NULL
98561 +batadv_tt_response_fill_table_39236 batadv_tt_response_fill_table 1 39236 NULL
98562 +posix_acl_to_xattr_39237 posix_acl_to_xattr 0 39237 NULL
98563 +drm_order_39244 drm_order 0 39244 NULL
98564 +r128_compat_ioctl_39250 r128_compat_ioctl 2 39250 NULL nohasharray
98565 +pwr_cont_miss_bcns_spread_read_39250 pwr_cont_miss_bcns_spread_read 3 39250 &r128_compat_ioctl_39250
98566 +__skb_cow_39254 __skb_cow 2 39254 NULL
98567 +ath6kl_wmi_set_appie_cmd_39266 ath6kl_wmi_set_appie_cmd 5 39266 NULL
98568 +rx_filter_protection_filter_read_39282 rx_filter_protection_filter_read 3 39282 NULL
98569 +__vmalloc_node_39308 __vmalloc_node 1 39308 NULL
98570 +__cfg80211_connect_result_39326 __cfg80211_connect_result 4-6 39326 NULL
98571 +wimax_msg_alloc_39343 wimax_msg_alloc 4 39343 NULL
98572 +__cfg80211_send_deauth_39344 __cfg80211_send_deauth 3 39344 NULL
98573 +__copy_from_user_nocache_39351 __copy_from_user_nocache 3 39351 NULL
98574 +ide_complete_rq_39354 ide_complete_rq 3 39354 NULL
98575 +do_write_log_from_user_39362 do_write_log_from_user 3 39362 NULL
98576 +vortex_wtdma_getlinearpos_39371 vortex_wtdma_getlinearpos 0 39371 NULL
98577 +regmap_name_read_file_39379 regmap_name_read_file 3 39379 NULL
98578 +fnic_trace_debugfs_read_39380 fnic_trace_debugfs_read 3 39380 NULL
98579 +ps_poll_ps_poll_utilization_read_39383 ps_poll_ps_poll_utilization_read 3 39383 NULL
98580 +__send_to_port_39386 __send_to_port 3 39386 NULL
98581 +user_power_read_39414 user_power_read 3 39414 NULL
98582 +alloc_agpphysmem_i8xx_39427 alloc_agpphysmem_i8xx 1 39427 NULL
98583 +sys_semop_39457 sys_semop 3 39457 NULL
98584 +setkey_unaligned_39474 setkey_unaligned 3 39474 NULL
98585 +do_get_mempolicy_39485 do_get_mempolicy 3 39485 NULL
98586 +ieee80211_if_fmt_dot11MeshHWMPmaxPREQretries_39499 ieee80211_if_fmt_dot11MeshHWMPmaxPREQretries 3 39499 NULL
98587 +atomic64_read_unchecked_39505 atomic64_read_unchecked 0 39505 NULL
98588 +int_proc_write_39542 int_proc_write 3 39542 NULL
98589 +pp_write_39554 pp_write 3 39554 NULL
98590 +ol_dqblk_block_39558 ol_dqblk_block 0-3-2 39558 NULL
98591 +datablob_format_39571 datablob_format 2 39571 NULL nohasharray
98592 +ieee80211_if_read_fwded_mcast_39571 ieee80211_if_read_fwded_mcast 3 39571 &datablob_format_39571
98593 +handle_response_icmp_39574 handle_response_icmp 7 39574 NULL
98594 +mtdchar_compat_ioctl_39602 mtdchar_compat_ioctl 3 39602 NULL
98595 +n_tty_compat_ioctl_helper_39605 n_tty_compat_ioctl_helper 4 39605 NULL
98596 +ext_depth_39607 ext_depth 0 39607 NULL
98597 +nfs_idmap_get_key_39616 nfs_idmap_get_key 2 39616 NULL
98598 +sdio_readb_39618 sdio_readb 0 39618 NULL
98599 +set_dev_class_39645 set_dev_class 4 39645 NULL nohasharray
98600 +dm_exception_table_init_39645 dm_exception_table_init 2 39645 &set_dev_class_39645
98601 +snd_rme32_capture_copy_39653 snd_rme32_capture_copy 5 39653 NULL
98602 +tcp_try_rmem_schedule_39657 tcp_try_rmem_schedule 3 39657 NULL nohasharray
98603 +prism2_info_hostscanresults_39657 prism2_info_hostscanresults 3 39657 &tcp_try_rmem_schedule_39657
98604 +kvm_read_guest_cached_39666 kvm_read_guest_cached 4 39666 NULL
98605 +v4l_stk_read_39672 v4l_stk_read 3 39672 NULL
98606 +hsc_msg_len_get_39673 hsc_msg_len_get 0 39673 NULL
98607 +do_surface_dirty_sou_39678 do_surface_dirty_sou 7 39678 NULL
98608 +ftrace_pid_write_39710 ftrace_pid_write 3 39710 NULL
98609 +tcf_csum_ipv4_tcp_39713 tcf_csum_ipv4_tcp 4 39713 NULL
98610 +remap_to_origin_clear_discard_39767 remap_to_origin_clear_discard 3 39767 NULL
98611 +ocfs2_pages_per_cluster_39790 ocfs2_pages_per_cluster 0 39790 NULL
98612 +crypto_ablkcipher_blocksize_39811 crypto_ablkcipher_blocksize 0 39811 NULL
98613 +security_inode_listsecurity_39812 security_inode_listsecurity 0 39812 NULL
98614 +snd_pcm_oss_writev3_39818 snd_pcm_oss_writev3 3 39818 NULL
98615 +sys_migrate_pages_39825 sys_migrate_pages 2 39825 NULL
98616 +get_priv_size_39828 get_priv_size 0-1 39828 NULL
98617 +pkt_add_39897 pkt_add 3 39897 NULL
98618 +read_file_modal_eeprom_39909 read_file_modal_eeprom 3 39909 NULL
98619 +gen_pool_add_virt_39913 gen_pool_add_virt 4 39913 NULL
98620 +dw210x_op_rw_39915 dw210x_op_rw 6 39915 NULL
98621 +aes_encrypt_interrupt_read_39919 aes_encrypt_interrupt_read 3 39919 NULL
98622 +exofs_read_kern_39921 exofs_read_kern 6 39921 NULL nohasharray
98623 +oom_score_adj_read_39921 oom_score_adj_read 3 39921 &exofs_read_kern_39921
98624 +__spi_async_39932 __spi_async 0 39932 NULL
98625 +__get_order_39935 __get_order 0 39935 NULL
98626 +error_error_frame_read_39947 error_error_frame_read 3 39947 NULL nohasharray
98627 +fwnet_pd_new_39947 fwnet_pd_new 4 39947 &error_error_frame_read_39947
98628 +tty_prepare_flip_string_39955 tty_prepare_flip_string 3 39955 NULL
98629 +dma_push_rx_39973 dma_push_rx 2 39973 NULL
98630 +broadsheetfb_write_39976 broadsheetfb_write 3 39976 NULL
98631 +mthca_array_init_39987 mthca_array_init 2 39987 NULL
98632 +xen_hvm_config_40018 xen_hvm_config 2 40018 NULL
98633 +nf_nat_icmpv6_reply_translation_40023 nf_nat_icmpv6_reply_translation 5 40023 NULL nohasharray
98634 +ivtvfb_write_40023 ivtvfb_write 3 40023 &nf_nat_icmpv6_reply_translation_40023
98635 +ea_foreach_i_40028 ea_foreach_i 0 40028 NULL
98636 +datablob_hmac_append_40038 datablob_hmac_append 3 40038 NULL
98637 +regmap_add_irq_chip_40042 regmap_add_irq_chip 4 40042 NULL
98638 +add_tty_40055 add_tty 1 40055 NULL nohasharray
98639 +l2cap_create_iframe_pdu_40055 l2cap_create_iframe_pdu 3 40055 &add_tty_40055
98640 +atomic_xchg_40070 atomic_xchg 0 40070 NULL
98641 +gen_pool_first_fit_40110 gen_pool_first_fit 2-3-4 40110 NULL
98642 +sctp_setsockopt_delayed_ack_40129 sctp_setsockopt_delayed_ack 3 40129 NULL
98643 +rx_rx_frame_checksum_read_40140 rx_rx_frame_checksum_read 3 40140 NULL
98644 +iwch_alloc_fastreg_pbl_40153 iwch_alloc_fastreg_pbl 2 40153 NULL
98645 +pt_write_40159 pt_write 3 40159 NULL
98646 +scsi_sg_count_40182 scsi_sg_count 0 40182 NULL
98647 +ipr_alloc_ucode_buffer_40199 ipr_alloc_ucode_buffer 1 40199 NULL nohasharray
98648 +devnode_find_40199 devnode_find 3-2 40199 &ipr_alloc_ucode_buffer_40199
98649 +allocate_probes_40204 allocate_probes 1 40204 NULL
98650 +compat_put_long_40214 compat_put_long 1 40214 NULL
98651 +au0828_v4l2_read_40220 au0828_v4l2_read 3 40220 NULL
98652 +osst_read_40237 osst_read 3 40237 NULL
98653 +lpage_info_slot_40243 lpage_info_slot 1-3 40243 NULL
98654 +ocfs2_zero_extend_get_range_40248 ocfs2_zero_extend_get_range 4 40248 NULL
98655 +of_get_child_count_40254 of_get_child_count 0 40254 NULL
98656 +rs_sta_dbgfs_scale_table_read_40262 rs_sta_dbgfs_scale_table_read 3 40262 NULL
98657 +usbnet_read_cmd_40275 usbnet_read_cmd 7 40275 NULL
98658 +rx_xfr_hint_trig_read_40283 rx_xfr_hint_trig_read 3 40283 NULL
98659 +crash_free_reserved_phys_range_40292 crash_free_reserved_phys_range 1 40292 NULL
98660 +ubi_io_write_data_40305 ubi_io_write_data 4-5 40305 NULL
98661 +batadv_tt_changes_fill_buff_40323 batadv_tt_changes_fill_buff 4 40323 NULL
98662 +ib_get_mad_data_offset_40336 ib_get_mad_data_offset 0 40336 NULL
98663 +mmio_read_40348 mmio_read 4 40348 NULL
98664 +usb_dump_interface_40353 usb_dump_interface 0 40353 NULL
98665 +ocfs2_release_clusters_40355 ocfs2_release_clusters 4 40355 NULL
98666 +event_rx_mem_empty_read_40363 event_rx_mem_empty_read 3 40363 NULL
98667 +ocfs2_check_range_for_refcount_40365 ocfs2_check_range_for_refcount 2-3 40365 NULL
98668 +fwnet_incoming_packet_40380 fwnet_incoming_packet 3 40380 NULL
98669 +brcmf_sdbrcm_get_image_40397 brcmf_sdbrcm_get_image 0-2 40397 NULL
98670 +atmel_rmem16_40450 atmel_rmem16 0 40450 NULL
98671 +tomoyo_update_policy_40458 tomoyo_update_policy 2 40458 NULL
98672 +zd_usb_scnprint_id_40459 zd_usb_scnprint_id 0-3 40459 NULL
98673 +batadv_hash_new_40491 batadv_hash_new 1 40491 NULL
98674 +devcgroup_inode_permission_40492 devcgroup_inode_permission 0 40492 NULL
98675 +tty_write_room_40495 tty_write_room 0 40495 NULL
98676 +persistent_ram_new_40501 persistent_ram_new 1-2 40501 NULL
98677 +sg_phys_40507 sg_phys 0 40507 NULL
98678 +TSS_checkhmac2_40520 TSS_checkhmac2 5-7 40520 NULL
98679 +ixgbe_dbg_reg_ops_read_40540 ixgbe_dbg_reg_ops_read 3 40540 NULL
98680 +ima_write_policy_40548 ima_write_policy 3 40548 NULL
98681 +esp_alloc_tmp_40558 esp_alloc_tmp 3-2 40558 NULL
98682 +ufs_inode_getfrag_40560 ufs_inode_getfrag 2-4 40560 NULL
98683 +skge_rx_get_40598 skge_rx_get 3 40598 NULL
98684 +get_priv_descr_and_size_40612 get_priv_descr_and_size 0 40612 NULL
98685 +bl_mark_sectors_init_40613 bl_mark_sectors_init 2-3 40613 NULL
98686 +cpuset_sprintf_cpulist_40627 cpuset_sprintf_cpulist 0 40627 NULL
98687 +twl4030_kpwrite_u8_40665 twl4030_kpwrite_u8 3 40665 NULL
98688 +__cfg80211_roamed_40668 __cfg80211_roamed 4-6 40668 NULL
98689 +pipeline_rx_complete_stat_fifo_int_read_40671 pipeline_rx_complete_stat_fifo_int_read 3 40671 NULL
98690 +fops_read_40672 fops_read 3 40672 NULL
98691 +alloc_rbio_40676 alloc_rbio 4 40676 NULL
98692 +videobuf_dma_init_user_locked_40678 videobuf_dma_init_user_locked 3 40678 NULL
98693 +nfc_hci_set_param_40697 nfc_hci_set_param 5 40697 NULL
98694 +__seq_open_private_40715 __seq_open_private 3 40715 NULL
98695 +fuse_readpages_40737 fuse_readpages 4 40737 NULL
98696 +xfs_iext_remove_direct_40744 xfs_iext_remove_direct 3 40744 NULL nohasharray
98697 +find_next_zero_bit_le_40744 find_next_zero_bit_le 0-2-3 40744 &xfs_iext_remove_direct_40744
98698 +security_inode_listxattr_40752 security_inode_listxattr 0 40752 NULL
98699 +fat_generic_compat_ioctl_40755 fat_generic_compat_ioctl 3 40755 NULL
98700 +card_send_command_40757 card_send_command 3 40757 NULL
98701 +ad1889_readl_40765 ad1889_readl 0 40765 NULL
98702 +pg_write_40766 pg_write 3 40766 NULL
98703 +show_list_40775 show_list 3 40775 NULL
98704 +kfifo_out_copy_r_40784 kfifo_out_copy_r 0-3 40784 NULL
98705 +bitmap_weight_40791 bitmap_weight 0-2 40791 NULL
98706 +pyra_sysfs_read_40795 pyra_sysfs_read 6 40795 NULL
98707 +netdev_alloc_skb_ip_align_40811 netdev_alloc_skb_ip_align 2 40811 NULL
98708 +nl80211_send_roamed_40825 nl80211_send_roamed 5-7 40825 NULL
98709 +__mlx4_qp_reserve_range_40847 __mlx4_qp_reserve_range 2-3 40847 NULL
98710 +ocfs2_zero_partial_clusters_40856 ocfs2_zero_partial_clusters 2-3 40856 NULL
98711 +v9fs_file_read_40858 v9fs_file_read 3 40858 NULL
98712 +read_file_queue_40895 read_file_queue 3 40895 NULL
98713 +waiters_read_40902 waiters_read 3 40902 NULL
98714 +isdn_add_channels_40905 isdn_add_channels 3 40905 NULL
98715 +gfs2_ea_find_40913 gfs2_ea_find 0 40913 NULL
98716 +vol_cdev_write_40915 vol_cdev_write 3 40915 NULL
98717 +snd_vx_create_40948 snd_vx_create 4 40948 NULL
98718 +skb_end_offset_40949 skb_end_offset 0 40949 NULL
98719 +wm8994_free_irq_40951 wm8994_free_irq 2 40951 NULL
98720 +rds_sendmsg_40976 rds_sendmsg 4 40976 NULL
98721 +il_dbgfs_fh_reg_read_40993 il_dbgfs_fh_reg_read 3 40993 NULL
98722 +mac80211_format_buffer_41010 mac80211_format_buffer 2 41010 NULL
98723 +mtd_block_isbad_41015 mtd_block_isbad 0 41015 NULL
98724 +_req_append_segment_41031 _req_append_segment 2 41031 NULL
98725 +mISDN_sock_sendmsg_41035 mISDN_sock_sendmsg 4 41035 NULL
98726 +ocfs2_xattr_index_block_find_41040 ocfs2_xattr_index_block_find 0 41040 NULL
98727 +vfs_listxattr_41062 vfs_listxattr 0 41062 NULL
98728 +cfg80211_inform_bss_frame_41078 cfg80211_inform_bss_frame 4 41078 NULL
98729 +roccat_read_41093 roccat_read 3 41093 NULL nohasharray
98730 +nvme_map_user_pages_41093 nvme_map_user_pages 3-4 41093 &roccat_read_41093
98731 +dma_attach_41094 dma_attach 5-6 41094 NULL
98732 +provide_user_output_41105 provide_user_output 3 41105 NULL
98733 +f_audio_buffer_alloc_41110 f_audio_buffer_alloc 1 41110 NULL
98734 +v4l2_ctrl_new_int_menu_41151 v4l2_ctrl_new_int_menu 4 41151 NULL
98735 +tx_frag_mpdu_alloc_failed_read_41167 tx_frag_mpdu_alloc_failed_read 3 41167 NULL
98736 +dvb_ca_write_41171 dvb_ca_write 3 41171 NULL
98737 +ol_quota_chunk_block_41177 ol_quota_chunk_block 0-2 41177 NULL
98738 +netif_get_num_default_rss_queues_41187 netif_get_num_default_rss_queues 0 41187 NULL
98739 +compat_sys_process_vm_writev_41194 compat_sys_process_vm_writev 3-5 41194 NULL
98740 +dfs_file_write_41196 dfs_file_write 3 41196 NULL
98741 +xfs_readdir_41200 xfs_readdir 3 41200 NULL
98742 +ocfs2_read_quota_block_41207 ocfs2_read_quota_block 2 41207 NULL
98743 +nfs_page_array_len_41219 nfs_page_array_len 0-2-1 41219 NULL
98744 +hiddev_compat_ioctl_41255 hiddev_compat_ioctl 2-3 41255 NULL
98745 +erst_read_41260 erst_read 0 41260 NULL
98746 +__fprog_create_41263 __fprog_create 2 41263 NULL
98747 +alloc_context_41283 alloc_context 1 41283 NULL
98748 +arch_gnttab_map_shared_41306 arch_gnttab_map_shared 3 41306 NULL
98749 +twl_change_queue_depth_41342 twl_change_queue_depth 2 41342 NULL
98750 +cnic_init_id_tbl_41354 cnic_init_id_tbl 2 41354 NULL
98751 +jbd2_alloc_41359 jbd2_alloc 1 41359 NULL
98752 +kmp_init_41373 kmp_init 2 41373 NULL
98753 +isr_commands_read_41398 isr_commands_read 3 41398 NULL
98754 +is_writethrough_io_41406 is_writethrough_io 3 41406 NULL
98755 +sys_flistxattr_41407 sys_flistxattr 3 41407 NULL
98756 +rx_defrag_decrypt_failed_read_41411 rx_defrag_decrypt_failed_read 3 41411 NULL
98757 +xfs_iext_add_41422 xfs_iext_add 3 41422 NULL
98758 +vsock_dev_compat_ioctl_41427 vsock_dev_compat_ioctl 3 41427 NULL
98759 +isdn_ppp_fill_rq_41428 isdn_ppp_fill_rq 2 41428 NULL
98760 +lbs_rdrf_read_41431 lbs_rdrf_read 3 41431 NULL
98761 +iio_device_alloc_41440 iio_device_alloc 1 41440 NULL
98762 +ntfs_file_buffered_write_41442 ntfs_file_buffered_write 4-6 41442 NULL
98763 +pcpu_build_alloc_info_41443 pcpu_build_alloc_info 1-2-3 41443 NULL
98764 +layout_leb_in_gaps_41470 layout_leb_in_gaps 0 41470 NULL
98765 +rt2x00debug_write_rfcsr_41473 rt2x00debug_write_rfcsr 3 41473 NULL
98766 +wep_interrupt_read_41492 wep_interrupt_read 3 41492 NULL
98767 +hpfs_translate_name_41497 hpfs_translate_name 3 41497 NULL
98768 +xfrm_hash_new_size_41505 xfrm_hash_new_size 0-1 41505 NULL
98769 +ldisc_receive_41516 ldisc_receive 4 41516 NULL
98770 +tx_tx_frame_checksum_read_41553 tx_tx_frame_checksum_read 3 41553 NULL
98771 +ath6kl_endpoint_stats_read_41554 ath6kl_endpoint_stats_read 3 41554 NULL
98772 +nr_status_frames_41559 nr_status_frames 0-1 41559 NULL
98773 +batadv_receive_client_update_packet_41578 batadv_receive_client_update_packet 3 41578 NULL
98774 +rng_dev_read_41581 rng_dev_read 3 41581 NULL
98775 +read_file_rx_chainmask_41605 read_file_rx_chainmask 3 41605 NULL
98776 +vga_io_r_41609 vga_io_r 0 41609 NULL
98777 +tcp_hdrlen_41610 tcp_hdrlen 0 41610 NULL
98778 +usb_endpoint_maxp_41613 usb_endpoint_maxp 0 41613 NULL
98779 +a2mp_send_41615 a2mp_send 4 41615 NULL
98780 +mempool_create_kmalloc_pool_41650 mempool_create_kmalloc_pool 1 41650 NULL
98781 +rx_rx_pre_complt_read_41653 rx_rx_pre_complt_read 3 41653 NULL
98782 +get_std_timing_41654 get_std_timing 0 41654 NULL
98783 +squashfs_cache_init_41656 squashfs_cache_init 2 41656 NULL
98784 +ieee80211_if_fmt_bssid_41677 ieee80211_if_fmt_bssid 3 41677 NULL
98785 +params_period_bytes_41683 params_period_bytes 0 41683 NULL
98786 +aac_src_ioremap_41688 aac_src_ioremap 2 41688 NULL
98787 +bdx_tx_db_init_41719 bdx_tx_db_init 2 41719 NULL
98788 +sys_pwritev_41722 sys_pwritev 3 41722 NULL
98789 +get_bios_ebda_41730 get_bios_ebda 0 41730 NULL
98790 +fillonedir_41746 fillonedir 3 41746 NULL
98791 +ocfs2_dx_dir_rebalance_41793 ocfs2_dx_dir_rebalance 7 41793 NULL
98792 +hsi_alloc_controller_41802 hsi_alloc_controller 1 41802 NULL
98793 +da9052_enable_irq_41814 da9052_enable_irq 2 41814 NULL
98794 +sco_send_frame_41815 sco_send_frame 3 41815 NULL
98795 +lp_gpio_to_irq_41822 lp_gpio_to_irq 2 41822 NULL
98796 +ixgbe_dbg_netdev_ops_read_41839 ixgbe_dbg_netdev_ops_read 3 41839 NULL
98797 +do_ip_setsockopt_41852 do_ip_setsockopt 5 41852 NULL
98798 +keyctl_instantiate_key_41855 keyctl_instantiate_key 3 41855 NULL
98799 +ieee80211_rx_radiotap_space_41870 ieee80211_rx_radiotap_space 0 41870 NULL
98800 +get_fdb_entries_41916 get_fdb_entries 3 41916 NULL
98801 +find_ge_pid_41918 find_ge_pid 1 41918 NULL
98802 +build_inv_iotlb_pages_41922 build_inv_iotlb_pages 4-5 41922 NULL
98803 +nfsd_getxattr_41934 nfsd_getxattr 0 41934 NULL
98804 +ext4_da_write_inline_data_begin_41935 ext4_da_write_inline_data_begin 3-4 41935 NULL
98805 +ocfs2_xattr_bucket_get_name_value_41949 ocfs2_xattr_bucket_get_name_value 0 41949 NULL
98806 +portnames_read_41958 portnames_read 3 41958 NULL
98807 +ubi_self_check_all_ff_41959 ubi_self_check_all_ff 4 41959 NULL
98808 +dst_mtu_41969 dst_mtu 0 41969 NULL
98809 +cx24116_writeregN_41975 cx24116_writeregN 4 41975 NULL
98810 +ubi_io_is_bad_41983 ubi_io_is_bad 0 41983 NULL
98811 +lguest_map_42008 lguest_map 1-2 42008 NULL
98812 +pool_allocate_42012 pool_allocate 3 42012 NULL
98813 +spidev_sync_read_42014 spidev_sync_read 0 42014 NULL
98814 +acpi_ut_create_buffer_object_42030 acpi_ut_create_buffer_object 1 42030 NULL
98815 +__hwahc_op_set_gtk_42038 __hwahc_op_set_gtk 4 42038 NULL
98816 +irda_sendmsg_ultra_42047 irda_sendmsg_ultra 4 42047 NULL
98817 +dma_generic_alloc_coherent_42048 dma_generic_alloc_coherent 2 42048 NULL nohasharray
98818 +jffs2_do_link_42048 jffs2_do_link 6 42048 &dma_generic_alloc_coherent_42048
98819 +ps_poll_upsd_max_ap_turn_read_42050 ps_poll_upsd_max_ap_turn_read 3 42050 NULL
98820 +InterfaceTransmitPacket_42058 InterfaceTransmitPacket 3 42058 NULL
98821 +alloc_bitset_42085 alloc_bitset 1 42085 NULL
98822 +scsi_execute_req_42088 scsi_execute_req 5 42088 NULL
98823 +sk_chk_filter_42095 sk_chk_filter 2 42095 NULL
98824 +submit_inquiry_42108 submit_inquiry 3 42108 NULL
98825 +sysfs_read_file_42113 sysfs_read_file 3 42113 NULL nohasharray
98826 +dw_dma_cyclic_prep_42113 dw_dma_cyclic_prep 3-4 42113 &sysfs_read_file_42113
98827 +Read_hfc16_stable_42131 Read_hfc16_stable 0 42131 NULL
98828 +mmc_align_data_size_42161 mmc_align_data_size 0-2 42161 NULL
98829 +read_file_base_eeprom_42168 read_file_base_eeprom 3 42168 NULL
98830 +iwl_mvm_send_cmd_42173 iwl_mvm_send_cmd 0 42173 NULL
98831 +oprofilefs_str_to_user_42182 oprofilefs_str_to_user 3 42182 NULL
98832 +get_znodes_to_commit_42201 get_znodes_to_commit 0 42201 NULL
98833 +btmrvl_hsmode_write_42252 btmrvl_hsmode_write 3 42252 NULL
98834 +rx_defrag_need_decrypt_read_42253 rx_defrag_need_decrypt_read 3 42253 NULL
98835 +netxen_nic_map_indirect_address_128M_42257 netxen_nic_map_indirect_address_128M 2 42257 NULL
98836 +savu_sysfs_write_42273 savu_sysfs_write 6 42273 NULL
98837 +snd_pcm_hw_param_value_max_42280 snd_pcm_hw_param_value_max 0 42280 NULL
98838 +sel_read_perm_42302 sel_read_perm 3 42302 NULL
98839 +sctp_setsockopt_del_key_42304 sctp_setsockopt_del_key 3 42304 NULL nohasharray
98840 +ulong_read_file_42304 ulong_read_file 3 42304 &sctp_setsockopt_del_key_42304
98841 +gfn_to_hva_42305 gfn_to_hva 0-2 42305 NULL
98842 +xfs_vm_readpages_42308 xfs_vm_readpages 4 42308 NULL
98843 +free_cblock_42318 free_cblock 2 42318 NULL
98844 +hysdn_conf_read_42324 hysdn_conf_read 3 42324 NULL
98845 +tcp_sync_mss_42330 tcp_sync_mss 0-2 42330 NULL
98846 +snd_pcm_plug_alloc_42339 snd_pcm_plug_alloc 2 42339 NULL
98847 +ide_raw_taskfile_42355 ide_raw_taskfile 4 42355 NULL
98848 +il_dbgfs_disable_ht40_read_42386 il_dbgfs_disable_ht40_read 3 42386 NULL
98849 +msnd_fifo_read_42406 msnd_fifo_read 0-3 42406 NULL
98850 +krng_get_random_42420 krng_get_random 3 42420 NULL
98851 +gsm_data_alloc_42437 gsm_data_alloc 3 42437 NULL
98852 +key_conf_keyidx_read_42443 key_conf_keyidx_read 3 42443 NULL
98853 +snd_pcm_action_group_42452 snd_pcm_action_group 0 42452 NULL
98854 +tcm_loop_change_queue_depth_42454 tcm_loop_change_queue_depth 2 42454 NULL
98855 +tc3589x_gpio_irq_get_virq_42457 tc3589x_gpio_irq_get_virq 2 42457 NULL
98856 +ext3_valid_block_bitmap_42459 ext3_valid_block_bitmap 3 42459 NULL
98857 +__simple_xattr_set_42474 __simple_xattr_set 4 42474 NULL
98858 +follow_hugetlb_page_42486 follow_hugetlb_page 0-7 42486 NULL
98859 +omfs_readpages_42490 omfs_readpages 4 42490 NULL
98860 +brcmf_sdbrcm_bus_txctl_42492 brcmf_sdbrcm_bus_txctl 3 42492 NULL
98861 +kvm_write_wall_clock_42520 kvm_write_wall_clock 2 42520 NULL
98862 +smk_write_netlbladdr_42525 smk_write_netlbladdr 3 42525 NULL
98863 +snd_emux_create_port_42533 snd_emux_create_port 3 42533 NULL
98864 +dbAllocNear_42546 dbAllocNear 0 42546 NULL
98865 +i915_ring_stop_read_42549 i915_ring_stop_read 3 42549 NULL nohasharray
98866 +ath6kl_wmi_proc_events_vif_42549 ath6kl_wmi_proc_events_vif 5 42549 &i915_ring_stop_read_42549
98867 +iwl_print_event_log_42566 iwl_print_event_log 0-5-7 42566 NULL
98868 +xfrm_new_hash_mask_42579 xfrm_new_hash_mask 0-1 42579 NULL
98869 +oom_score_adj_write_42594 oom_score_adj_write 3 42594 NULL
98870 +map_state_42602 map_state 1 42602 NULL nohasharray
98871 +__pskb_pull_42602 __pskb_pull 2 42602 &map_state_42602
98872 +nd_get_link_42603 nd_get_link 0 42603 NULL
98873 +sys_move_pages_42626 sys_move_pages 2 42626 NULL
98874 +ieee80211_if_fmt_dot11MeshHWMPactivePathTimeout_42635 ieee80211_if_fmt_dot11MeshHWMPactivePathTimeout 3 42635 NULL
98875 +scsi_activate_tcq_42640 scsi_activate_tcq 2 42640 NULL
98876 +br_mdb_rehash_42643 br_mdb_rehash 2 42643 NULL
98877 +l2tp_xmit_skb_42672 l2tp_xmit_skb 3 42672 NULL
98878 +request_key_and_link_42693 request_key_and_link 4 42693 NULL
98879 +vb2_read_42703 vb2_read 3 42703 NULL
98880 +sierra_net_send_cmd_42708 sierra_net_send_cmd 3 42708 NULL
98881 +__ocfs2_decrease_refcount_42717 __ocfs2_decrease_refcount 4 42717 NULL
98882 +dvb_demux_ioctl_42733 dvb_demux_ioctl 2 42733 NULL
98883 +set_aoe_iflist_42737 set_aoe_iflist 2 42737 NULL
98884 +ax25_setsockopt_42740 ax25_setsockopt 5 42740 NULL
98885 +xen_bind_pirq_gsi_to_irq_42750 xen_bind_pirq_gsi_to_irq 1 42750 NULL
98886 +snd_midi_event_decode_42780 snd_midi_event_decode 0 42780 NULL
98887 +cryptd_hash_setkey_42781 cryptd_hash_setkey 3 42781 NULL
98888 +koneplus_sysfs_read_42792 koneplus_sysfs_read 6 42792 NULL
98889 +ntfs_attr_extend_allocation_42796 ntfs_attr_extend_allocation 0-2 42796 NULL
98890 +fw_device_op_compat_ioctl_42804 fw_device_op_compat_ioctl 2-3 42804 NULL
98891 +drm_ioctl_42813 drm_ioctl 2 42813 NULL
98892 +iwl_dbgfs_ucode_bt_stats_read_42820 iwl_dbgfs_ucode_bt_stats_read 3 42820 NULL
98893 +set_arg_42824 set_arg 3 42824 NULL
98894 +ocfs2_desc_bitmap_to_cluster_off_42831 ocfs2_desc_bitmap_to_cluster_off 2 42831 NULL
98895 +prandom_u32_42853 prandom_u32 0 42853 NULL
98896 +of_property_count_strings_42863 of_property_count_strings 0 42863 NULL
98897 +ocfs2_clusters_for_bytes_42872 ocfs2_clusters_for_bytes 0-2 42872 NULL
98898 +pskb_expand_head_42881 pskb_expand_head 2-3 42881 NULL
98899 +vt_compat_ioctl_42887 vt_compat_ioctl 3 42887 NULL
98900 +tipc_port_recv_sections_42890 tipc_port_recv_sections 4 42890 NULL
98901 +xpc_kmalloc_cacheline_aligned_42895 xpc_kmalloc_cacheline_aligned 1 42895 NULL
98902 +SendTxCommandPacket_42901 SendTxCommandPacket 3 42901 NULL
98903 +hd_end_request_42904 hd_end_request 2 42904 NULL
98904 +sta_last_rx_rate_read_42909 sta_last_rx_rate_read 3 42909 NULL
98905 +sctp_getsockopt_maxburst_42941 sctp_getsockopt_maxburst 2 42941 NULL
98906 +get_unmapped_area_42944 get_unmapped_area 0 42944 NULL
98907 +sys_sethostname_42962 sys_sethostname 2 42962 NULL
98908 +read_file_node_stat_42964 read_file_node_stat 3 42964 NULL
98909 +compat_udpv6_setsockopt_42981 compat_udpv6_setsockopt 5 42981 NULL
98910 +snd_timer_user_ioctl_compat_42985 snd_timer_user_ioctl_compat 3 42985 NULL
98911 +nfs_idmap_get_desc_42990 nfs_idmap_get_desc 4-2 42990 NULL
98912 +mlx4_qp_reserve_range_43000 mlx4_qp_reserve_range 2-3 43000 NULL
98913 +isr_rx_mem_overflow_read_43025 isr_rx_mem_overflow_read 3 43025 NULL
98914 +wep_default_key_count_read_43035 wep_default_key_count_read 3 43035 NULL
98915 +nouveau_gpuobj_create__43072 nouveau_gpuobj_create_ 9 43072 NULL
98916 +nfs_map_group_to_gid_43082 nfs_map_group_to_gid 3 43082 NULL
98917 +cpuset_sprintf_memlist_43088 cpuset_sprintf_memlist 0 43088 NULL
98918 +ieee80211_if_fmt_drop_unencrypted_43107 ieee80211_if_fmt_drop_unencrypted 3 43107 NULL
98919 +read_file_dfs_43145 read_file_dfs 3 43145 NULL
98920 +uuid_string_43154 uuid_string 0 43154 NULL
98921 +usb_string_sub_43164 usb_string_sub 0 43164 NULL
98922 +il_dbgfs_power_save_status_read_43165 il_dbgfs_power_save_status_read 3 43165 NULL
98923 +ath6kl_set_assoc_req_ies_43185 ath6kl_set_assoc_req_ies 3 43185 NULL
98924 +process_measurement_43190 process_measurement 0 43190 NULL
98925 +ext4_xattr_ibody_get_43200 ext4_xattr_ibody_get 0 43200 NULL
98926 +uio_write_43202 uio_write 3 43202 NULL
98927 +iso_callback_43208 iso_callback 3 43208 NULL
98928 +f2fs_acl_from_disk_43210 f2fs_acl_from_disk 2 43210 NULL
98929 +atomic_long_add_return_43217 atomic_long_add_return 1 43217 NULL
98930 +comedi_compat_ioctl_43218 comedi_compat_ioctl 3 43218 NULL
98931 +vmemmap_alloc_block_43245 vmemmap_alloc_block 1 43245 NULL
98932 +fixup_leb_43256 fixup_leb 3 43256 NULL
98933 +ide_end_rq_43269 ide_end_rq 4 43269 NULL
98934 +evtchn_write_43278 evtchn_write 3 43278 NULL
98935 +filemap_write_and_wait_range_43279 filemap_write_and_wait_range 0 43279 NULL
98936 +mpage_alloc_43299 mpage_alloc 3 43299 NULL
98937 +get_nr_irqs_gsi_43315 get_nr_irqs_gsi 0 43315 NULL
98938 +mmu_set_spte_43327 mmu_set_spte 6-7 43327 NULL
98939 +__ext4_get_inode_loc_43332 __ext4_get_inode_loc 0 43332 NULL
98940 +kvm_host_page_size_43348 kvm_host_page_size 2 43348 NULL
98941 +gart_free_coherent_43362 gart_free_coherent 4-2 43362 NULL
98942 +__alloc_bootmem_low_43423 __alloc_bootmem_low 1-2 43423 NULL nohasharray
98943 +gdm_wimax_netif_rx_43423 gdm_wimax_netif_rx 3 43423 &__alloc_bootmem_low_43423
98944 +usb_alloc_urb_43436 usb_alloc_urb 1 43436 NULL
98945 +ucs2_strsize_43438 ucs2_strsize 0 43438 NULL
98946 +ath6kl_wmi_roam_tbl_event_rx_43440 ath6kl_wmi_roam_tbl_event_rx 3 43440 NULL
98947 +usemap_size_43443 usemap_size 0-2-1 43443 NULL nohasharray
98948 +usb_string_43443 usb_string 0 43443 &usemap_size_43443
98949 +alloc_new_reservation_43480 alloc_new_reservation 4 43480 NULL
98950 +tx_tx_data_prepared_read_43497 tx_tx_data_prepared_read 3 43497 NULL
98951 +ieee80211_if_fmt_dot11MeshHWMPnetDiameterTraversalTime_43505 ieee80211_if_fmt_dot11MeshHWMPnetDiameterTraversalTime 3 43505 NULL
98952 +do_readlink_43518 do_readlink 2 43518 NULL
98953 +dvb_ca_en50221_io_write_43533 dvb_ca_en50221_io_write 3 43533 NULL
98954 +cachefiles_daemon_write_43535 cachefiles_daemon_write 3 43535 NULL
98955 +tx_frag_failed_read_43540 tx_frag_failed_read 3 43540 NULL nohasharray
98956 +ufs_alloccg_block_43540 ufs_alloccg_block 3-0 43540 &tx_frag_failed_read_43540
98957 +ath_rx_init_43564 ath_rx_init 2 43564 NULL
98958 +_fc_frame_alloc_43568 _fc_frame_alloc 1 43568 NULL
98959 +rpc_malloc_43573 rpc_malloc 2 43573 NULL
98960 +lpfc_idiag_drbacc_read_reg_43606 lpfc_idiag_drbacc_read_reg 0-3 43606 NULL
98961 +proc_read_43614 proc_read 3 43614 NULL
98962 +bio_integrity_tag_43658 bio_integrity_tag 3 43658 NULL
98963 +ext4_acl_count_43659 ext4_acl_count 0-1 43659 NULL
98964 +dmam_declare_coherent_memory_43679 dmam_declare_coherent_memory 4-2 43679 NULL
98965 +calgary_map_page_43686 calgary_map_page 3-4 43686 NULL
98966 +max77693_bulk_write_43698 max77693_bulk_write 2-3 43698 NULL
98967 +snd_rme32_playback_copy_43732 snd_rme32_playback_copy 5 43732 NULL
98968 +ocfs2_replace_clusters_43733 ocfs2_replace_clusters 5 43733 NULL
98969 +osdv1_attr_list_elem_size_43747 osdv1_attr_list_elem_size 0-1 43747 NULL
98970 +__bm_find_next_43748 __bm_find_next 2 43748 NULL
98971 +gigaset_initcs_43753 gigaset_initcs 2 43753 NULL
98972 +sctp_setsockopt_active_key_43755 sctp_setsockopt_active_key 3 43755 NULL
98973 +ocfs2_xattr_get_value_outside_43787 ocfs2_xattr_get_value_outside 0 43787 NULL nohasharray
98974 +byte_pos_43787 byte_pos 0-2 43787 &ocfs2_xattr_get_value_outside_43787
98975 +btrfs_copy_from_user_43806 btrfs_copy_from_user 3-1 43806 NULL
98976 +ext4_read_block_bitmap_43814 ext4_read_block_bitmap 2 43814 NULL
98977 +ieee80211_if_fmt_element_ttl_43825 ieee80211_if_fmt_element_ttl 3 43825 NULL
98978 +ieee80211_alloc_hw_43829 ieee80211_alloc_hw 1 43829 NULL
98979 +p54_download_eeprom_43842 p54_download_eeprom 4 43842 NULL
98980 +read_flush_43851 read_flush 3 43851 NULL
98981 +ocfs2_block_group_find_clear_bits_43874 ocfs2_block_group_find_clear_bits 4 43874 NULL
98982 +pm860x_bulk_write_43875 pm860x_bulk_write 2-3 43875 NULL
98983 +prism2_sta_send_mgmt_43916 prism2_sta_send_mgmt 5 43916 NULL
98984 +SendString_43928 SendString 3 43928 NULL
98985 +xen_register_gsi_43946 xen_register_gsi 1-2 43946 NULL
98986 +stats_dot11RTSFailureCount_read_43948 stats_dot11RTSFailureCount_read 3 43948 NULL
98987 +__get_required_blob_size_43980 __get_required_blob_size 0-2-3 43980 NULL
98988 +nla_reserve_43984 nla_reserve 3 43984 NULL
98989 +__clkdev_alloc_43990 __clkdev_alloc 1 43990 NULL
98990 +scsi_command_size_43992 scsi_command_size 0 43992 NULL nohasharray
98991 +bcm_recvmsg_43992 bcm_recvmsg 4 43992 &scsi_command_size_43992
98992 +emit_flags_44006 emit_flags 4-3 44006 NULL
98993 +write_flush_procfs_44011 write_flush_procfs 3 44011 NULL
98994 +swiotlb_unmap_page_44063 swiotlb_unmap_page 2 44063 NULL
98995 +load_discard_44083 load_discard 3 44083 NULL
98996 +xlog_recover_add_to_cont_trans_44102 xlog_recover_add_to_cont_trans 4 44102 NULL
98997 +tracing_set_trace_read_44122 tracing_set_trace_read 3 44122 NULL
98998 +vmw_gmr_bind_44130 vmw_gmr_bind 3 44130 NULL
98999 +scsi_get_resid_44147 scsi_get_resid 0 44147 NULL
99000 +ubifs_find_dirty_idx_leb_44169 ubifs_find_dirty_idx_leb 0 44169 NULL
99001 +ocfs2_xattr_bucket_find_44174 ocfs2_xattr_bucket_find 0 44174 NULL
99002 +handle_eviocgbit_44193 handle_eviocgbit 3 44193 NULL
99003 +IO_APIC_get_PCI_irq_vector_44198 IO_APIC_get_PCI_irq_vector 0 44198 NULL
99004 +__set_free_44211 __set_free 2 44211 NULL
99005 +claim_ptd_buffers_44213 claim_ptd_buffers 3 44213 NULL
99006 +srp_alloc_iu_44227 srp_alloc_iu 2 44227 NULL
99007 +ioapic_register_intr_44238 ioapic_register_intr 1 44238 NULL
99008 +scsi_track_queue_full_44239 scsi_track_queue_full 2 44239 NULL
99009 +tc3589x_gpio_irq_map_44245 tc3589x_gpio_irq_map 2 44245 NULL
99010 +enlarge_skb_44248 enlarge_skb 2 44248 NULL
99011 +ufs_clusteracct_44293 ufs_clusteracct 3 44293 NULL
99012 +ocfs2_zero_range_for_truncate_44294 ocfs2_zero_range_for_truncate 3 44294 NULL
99013 +ath6kl_keepalive_read_44303 ath6kl_keepalive_read 3 44303 NULL
99014 +bitmap_scnprintf_44318 bitmap_scnprintf 2 44318 NULL
99015 +dispatch_proc_write_44320 dispatch_proc_write 3 44320 NULL
99016 +ubi_eba_write_leb_st_44343 ubi_eba_write_leb_st 5 44343 NULL
99017 +nfs_fscache_get_super_cookie_44355 nfs_fscache_get_super_cookie 3 44355 NULL nohasharray
99018 +blk_queue_init_tags_44355 blk_queue_init_tags 2 44355 &nfs_fscache_get_super_cookie_44355
99019 +__is_discarded_44359 __is_discarded 2 44359 NULL
99020 +rts_threshold_read_44384 rts_threshold_read 3 44384 NULL
99021 +aoedev_flush_44398 aoedev_flush 2 44398 NULL
99022 +drm_buffer_alloc_44405 drm_buffer_alloc 2 44405 NULL
99023 +osst_do_scsi_44410 osst_do_scsi 4 44410 NULL
99024 +check_user_page_hwpoison_44412 check_user_page_hwpoison 1 44412 NULL
99025 +ieee80211_if_read_rc_rateidx_mcs_mask_5ghz_44423 ieee80211_if_read_rc_rateidx_mcs_mask_5ghz 3 44423 NULL
99026 +prandom_u32_state_44445 prandom_u32_state 0 44445 NULL
99027 +___alloc_bootmem_node_nopanic_44461 ___alloc_bootmem_node_nopanic 2-3 44461 NULL
99028 +btrfs_chunk_item_size_44478 btrfs_chunk_item_size 0-1 44478 NULL
99029 +sdio_align_size_44489 sdio_align_size 0-2 44489 NULL
99030 +ieee80211_if_read_dropped_frames_ttl_44500 ieee80211_if_read_dropped_frames_ttl 3 44500 NULL
99031 +security_getprocattr_44505 security_getprocattr 0 44505 NULL nohasharray
99032 +iwl_dbgfs_sram_read_44505 iwl_dbgfs_sram_read 3 44505 &security_getprocattr_44505
99033 +spidev_write_44510 spidev_write 3 44510 NULL
99034 +sys_msgsnd_44537 sys_msgsnd 3 44537 NULL nohasharray
99035 +comm_write_44537 comm_write 3 44537 &sys_msgsnd_44537
99036 +dgrp_config_proc_write_44571 dgrp_config_proc_write 3 44571 NULL
99037 +snd_pcm_alloc_vmalloc_buffer_44595 snd_pcm_alloc_vmalloc_buffer 2 44595 NULL
99038 +slip_compat_ioctl_44599 slip_compat_ioctl 4 44599 NULL
99039 +brcmf_sdbrcm_glom_len_44618 brcmf_sdbrcm_glom_len 0 44618 NULL
99040 +cfpkt_add_body_44630 cfpkt_add_body 3 44630 NULL
99041 +ext2_new_block_44645 ext2_new_block 2 44645 NULL
99042 +alloc_ctrl_packet_44667 alloc_ctrl_packet 1 44667 NULL
99043 +mpi_resize_44674 mpi_resize 2 44674 NULL
99044 +ts_read_44687 ts_read 3 44687 NULL
99045 +qib_get_user_pages_44689 qib_get_user_pages 1-2 44689 NULL
99046 +_zd_iowrite32v_locked_44725 _zd_iowrite32v_locked 3 44725 NULL
99047 +clusterip_proc_write_44729 clusterip_proc_write 3 44729 NULL
99048 +fib_count_nexthops_44730 fib_count_nexthops 0 44730 NULL
99049 +key_tx_rx_count_read_44742 key_tx_rx_count_read 3 44742 NULL
99050 +WIL_GET_BITS_44747 WIL_GET_BITS 0-1-2-3 44747 NULL
99051 +set_brk_44749 set_brk 1 44749 NULL
99052 +tnode_new_44757 tnode_new 3 44757 NULL nohasharray
99053 +pty_write_44757 pty_write 3 44757 &tnode_new_44757
99054 +__videobuf_copy_stream_44769 __videobuf_copy_stream 4 44769 NULL
99055 +handsfree_ramp_44777 handsfree_ramp 2 44777 NULL
99056 +sctp_setsockopt_44788 sctp_setsockopt 5 44788 NULL
99057 +rx_dropped_read_44799 rx_dropped_read 3 44799 NULL
99058 +qla4xxx_alloc_work_44813 qla4xxx_alloc_work 2 44813 NULL
99059 +rmap_write_protect_44833 rmap_write_protect 2 44833 NULL
99060 +sisusb_write_44834 sisusb_write 3 44834 NULL
99061 +nl80211_send_unprot_disassoc_44846 nl80211_send_unprot_disassoc 4 44846 NULL
99062 +kvm_read_hva_44847 kvm_read_hva 3 44847 NULL
99063 +skb_availroom_44883 skb_availroom 0 44883 NULL
99064 +nf_bridge_encap_header_len_44890 nf_bridge_encap_header_len 0 44890 NULL
99065 +do_tty_write_44896 do_tty_write 5 44896 NULL
99066 +tx_queue_status_read_44978 tx_queue_status_read 3 44978 NULL
99067 +nf_nat_seq_adjust_44989 nf_nat_seq_adjust 4 44989 NULL
99068 +bytepos_delta_45017 bytepos_delta 0 45017 NULL
99069 +read_block_bitmap_45021 read_block_bitmap 2 45021 NULL nohasharray
99070 +ptrace_writedata_45021 ptrace_writedata 4-3 45021 &read_block_bitmap_45021
99071 +vhci_get_user_45039 vhci_get_user 3 45039 NULL
99072 +sel_write_user_45060 sel_write_user 3 45060 NULL
99073 +snd_mixart_BA0_read_45069 snd_mixart_BA0_read 5 45069 NULL nohasharray
99074 +do_video_ioctl_45069 do_video_ioctl 3 45069 &snd_mixart_BA0_read_45069
99075 +kvm_mmu_page_get_gfn_45110 kvm_mmu_page_get_gfn 0-2 45110 NULL
99076 +pwr_missing_bcns_cnt_read_45113 pwr_missing_bcns_cnt_read 3 45113 NULL
99077 +usbdev_read_45114 usbdev_read 3 45114 NULL
99078 +send_to_tty_45141 send_to_tty 3 45141 NULL
99079 +stmpe_irq_map_45146 stmpe_irq_map 2 45146 NULL
99080 +crypto_aead_blocksize_45148 crypto_aead_blocksize 0 45148 NULL
99081 +gen_bitmask_string_45149 gen_bitmask_string 6 45149 NULL
99082 +ocfs2_remove_inode_range_45156 ocfs2_remove_inode_range 3-4 45156 NULL nohasharray
99083 +device_write_45156 device_write 3 45156 &ocfs2_remove_inode_range_45156
99084 +ocfs2_dq_frozen_trigger_45159 ocfs2_dq_frozen_trigger 4 45159 NULL
99085 +tomoyo_write_self_45161 tomoyo_write_self 3 45161 NULL
99086 +sta_agg_status_write_45164 sta_agg_status_write 3 45164 NULL
99087 +snd_sb_csp_load_user_45190 snd_sb_csp_load_user 3 45190 NULL
99088 +num_clusters_in_group_45194 num_clusters_in_group 2 45194 NULL
99089 +add_child_45201 add_child 4 45201 NULL
99090 +iso_alloc_urb_45206 iso_alloc_urb 4-5 45206 NULL
99091 +spi_alloc_master_45223 spi_alloc_master 2 45223 NULL
99092 +__dirty_45228 __dirty 2 45228 NULL
99093 +ieee80211_if_read_peer_45233 ieee80211_if_read_peer 3 45233 NULL
99094 +input_mt_init_slots_45279 input_mt_init_slots 2 45279 NULL
99095 +vcc_compat_ioctl_45291 vcc_compat_ioctl 3 45291 NULL
99096 +snd_pcm_oss_sync1_45298 snd_pcm_oss_sync1 2 45298 NULL
99097 +pte_val_45313 pte_val 0 45313 NULL
99098 +copy_vm86_regs_from_user_45340 copy_vm86_regs_from_user 3 45340 NULL
99099 +lane2_associate_req_45398 lane2_associate_req 4 45398 NULL
99100 +keymap_store_45406 keymap_store 4 45406 NULL
99101 +paging64_gva_to_gpa_45421 paging64_gva_to_gpa 2 45421 NULL nohasharray
99102 +ieee80211_if_fmt_dot11MeshHWMProotInterval_45421 ieee80211_if_fmt_dot11MeshHWMProotInterval 3 45421 &paging64_gva_to_gpa_45421
99103 +tty_buffer_alloc_45437 tty_buffer_alloc 2 45437 NULL
99104 +intel_render_ring_init_dri_45446 intel_render_ring_init_dri 2-3 45446 NULL
99105 +__node_remap_45458 __node_remap 4 45458 NULL
99106 +rds_ib_set_wr_signal_state_45463 rds_ib_set_wr_signal_state 0 45463 NULL
99107 +udp_manip_pkt_45467 udp_manip_pkt 4 45467 NULL
99108 +tracing_read_dyn_info_45468 tracing_read_dyn_info 3 45468 NULL
99109 +arizona_init_fll_45503 arizona_init_fll 5 45503 NULL
99110 +rds_message_copy_from_user_45510 rds_message_copy_from_user 3 45510 NULL
99111 +sys_lgetxattr_45531 sys_lgetxattr 4 45531 NULL
99112 +cgroup_read_u64_45532 cgroup_read_u64 5 45532 NULL
99113 +copy_macs_45534 copy_macs 4 45534 NULL
99114 +nla_attr_size_45545 nla_attr_size 0-1 45545 NULL
99115 +v9fs_direct_read_45546 v9fs_direct_read 3 45546 NULL
99116 +cx18_copy_mdl_to_user_45549 cx18_copy_mdl_to_user 4 45549 NULL
99117 +atomic_long_sub_return_45551 atomic_long_sub_return 1 45551 NULL
99118 +ext3_group_first_block_no_45555 ext3_group_first_block_no 0-2 45555 NULL
99119 +stats_dot11ACKFailureCount_read_45558 stats_dot11ACKFailureCount_read 3 45558 NULL
99120 +_regmap_bus_raw_write_45559 _regmap_bus_raw_write 2 45559 NULL
99121 +posix_acl_xattr_size_45561 posix_acl_xattr_size 0-1 45561 NULL
99122 +venus_rmdir_45564 venus_rmdir 4 45564 NULL
99123 +ipath_create_cq_45586 ipath_create_cq 2 45586 NULL
99124 +rdma_set_ib_paths_45592 rdma_set_ib_paths 3 45592 NULL
99125 +hidraw_get_report_45609 hidraw_get_report 3 45609 NULL
99126 +audit_log_n_hex_45617 audit_log_n_hex 3 45617 NULL
99127 +ebitmap_next_positive_45651 ebitmap_next_positive 3 45651 NULL
99128 +dma_map_cont_45668 dma_map_cont 5 45668 NULL
99129 +compat_mpctl_ioctl_45671 compat_mpctl_ioctl 2 45671 NULL
99130 +dgram_sendmsg_45679 dgram_sendmsg 4 45679 NULL
99131 +smk_write_ambient_45691 smk_write_ambient 3 45691 NULL
99132 +dm_compat_ctl_ioctl_45692 dm_compat_ctl_ioctl 3 45692 NULL
99133 +unix_dgram_sendmsg_45699 unix_dgram_sendmsg 4 45699 NULL nohasharray
99134 +bscnl_emit_45699 bscnl_emit 2-5-0 45699 &unix_dgram_sendmsg_45699
99135 +dvb_ca_en50221_init_45718 dvb_ca_en50221_init 4 45718 NULL
99136 +snd_cs46xx_io_read_45734 snd_cs46xx_io_read 5 45734 NULL
99137 +rw_copy_check_uvector_45748 rw_copy_check_uvector 3 45748 NULL nohasharray
99138 +v4l2_ctrl_new_std_45748 v4l2_ctrl_new_std 5 45748 &rw_copy_check_uvector_45748
99139 +lkdtm_debugfs_read_45752 lkdtm_debugfs_read 3 45752 NULL
99140 +nilfs_compat_ioctl_45769 nilfs_compat_ioctl 3 45769 NULL
99141 +alloc_ts_config_45775 alloc_ts_config 1 45775 NULL
99142 +raw_setsockopt_45800 raw_setsockopt 5 45800 NULL
99143 +lbs_rdbbp_read_45805 lbs_rdbbp_read 3 45805 NULL
99144 +pcpu_alloc_alloc_info_45813 pcpu_alloc_alloc_info 1-2 45813 NULL
99145 +fm_v4l2_init_video_device_45821 fm_v4l2_init_video_device 2 45821 NULL
99146 +memcg_update_cache_size_45828 memcg_update_cache_size 2 45828 NULL
99147 +x509_process_extension_45854 x509_process_extension 5 45854 NULL
99148 +isdn_write_45863 isdn_write 3 45863 NULL
99149 +unpack_orig_pfns_45867 unpack_orig_pfns 0 45867 NULL
99150 +get_rdac_req_45882 get_rdac_req 3 45882 NULL
99151 +ocfs2_xattr_block_find_45891 ocfs2_xattr_block_find 0 45891 NULL
99152 +wm_adsp_region_to_reg_45915 wm_adsp_region_to_reg 0-2 45915 NULL
99153 +dbgfs_frame_45917 dbgfs_frame 3 45917 NULL
99154 +nf_nat_ftp_fmt_cmd_45926 nf_nat_ftp_fmt_cmd 0 45926 NULL
99155 +smp_scan_config_45934 smp_scan_config 1 45934 NULL
99156 +alloc_mr_45935 alloc_mr 1 45935 NULL
99157 +split_large_page_45941 split_large_page 2 45941 NULL
99158 +rb_simple_read_45972 rb_simple_read 3 45972 NULL
99159 +ezusb_writememory_45976 ezusb_writememory 4 45976 NULL
99160 +ioat2_dca_count_dca_slots_45984 ioat2_dca_count_dca_slots 0 45984 NULL
99161 +sierra_setup_urb_46029 sierra_setup_urb 5 46029 NULL
99162 +get_free_entries_46030 get_free_entries 1 46030 NULL
99163 +__access_remote_vm_46031 __access_remote_vm 0-5-3 46031 NULL
99164 +snd_emu10k1x_ptr_read_46049 snd_emu10k1x_ptr_read 0 46049 NULL
99165 +acpi_register_gsi_xen_hvm_46052 acpi_register_gsi_xen_hvm 2 46052 NULL
99166 +line6_midibuf_bytes_used_46059 line6_midibuf_bytes_used 0 46059 NULL
99167 +__ocfs2_move_extent_46060 __ocfs2_move_extent 5-6 46060 NULL nohasharray
99168 +dma_tx_errors_read_46060 dma_tx_errors_read 3 46060 &__ocfs2_move_extent_46060
99169 +slhc_toss_46066 slhc_toss 0 46066 NULL
99170 +sel_commit_bools_write_46077 sel_commit_bools_write 3 46077 NULL
99171 +vfio_config_do_rw_46091 vfio_config_do_rw 3 46091 NULL
99172 +ata_host_alloc_46094 ata_host_alloc 2 46094 NULL
99173 +arizona_set_irq_wake_46101 arizona_set_irq_wake 2 46101 NULL
99174 +pkt_ctl_compat_ioctl_46110 pkt_ctl_compat_ioctl 3 46110 NULL
99175 +memcg_update_array_size_46111 memcg_update_array_size 1 46111 NULL nohasharray
99176 +il3945_ucode_general_stats_read_46111 il3945_ucode_general_stats_read 3 46111 &memcg_update_array_size_46111
99177 +mlx4_ib_alloc_fast_reg_page_list_46119 mlx4_ib_alloc_fast_reg_page_list 2 46119 NULL
99178 +paging32_walk_addr_nested_46121 paging32_walk_addr_nested 3 46121 NULL
99179 +__netlink_change_ngroups_46156 __netlink_change_ngroups 2 46156 NULL
99180 +twl_direction_out_46182 twl_direction_out 2 46182 NULL
99181 +vxge_os_dma_malloc_46184 vxge_os_dma_malloc 2 46184 NULL
99182 +add_conn_list_46197 add_conn_list 3 46197 NULL
99183 +i2400m_op_msg_from_user_46213 i2400m_op_msg_from_user 4 46213 NULL
99184 +tm6000_i2c_recv_regs_46215 tm6000_i2c_recv_regs 5 46215 NULL
99185 +dsp_write_46218 dsp_write 2 46218 NULL
99186 +mpi_read_raw_data_46248 mpi_read_raw_data 2 46248 NULL
99187 +nf_nat_ftp_46265 nf_nat_ftp 6 46265 NULL
99188 +ReadReg_46277 ReadReg 0 46277 NULL
99189 +batadv_iv_ogm_queue_add_46319 batadv_iv_ogm_queue_add 3 46319 NULL
99190 +__hwahc_dev_set_key_46328 __hwahc_dev_set_key 5 46328 NULL
99191 +iwl_dbgfs_chain_noise_read_46355 iwl_dbgfs_chain_noise_read 3 46355 NULL
99192 +smk_write_direct_46363 smk_write_direct 3 46363 NULL
99193 +__iommu_calculate_agaw_46366 __iommu_calculate_agaw 2 46366 NULL
99194 +ubi_dump_flash_46381 ubi_dump_flash 4 46381 NULL
99195 +fuse_file_aio_write_46399 fuse_file_aio_write 4 46399 NULL
99196 +crypto_ablkcipher_reqsize_46411 crypto_ablkcipher_reqsize 0 46411 NULL
99197 +cp210x_set_config_46447 cp210x_set_config 4 46447 NULL
99198 +filldir64_46469 filldir64 3 46469 NULL
99199 +fill_in_write_vector_46498 fill_in_write_vector 0 46498 NULL
99200 +pin_code_reply_46510 pin_code_reply 4 46510 NULL
99201 +mthca_alloc_cq_buf_46512 mthca_alloc_cq_buf 3 46512 NULL
99202 +kmsg_read_46514 kmsg_read 3 46514 NULL
99203 +bdx_rxdb_create_46525 bdx_rxdb_create 1 46525 NULL
99204 +nl80211_send_rx_assoc_46538 nl80211_send_rx_assoc 4 46538 NULL
99205 +pm860x_irq_domain_map_46553 pm860x_irq_domain_map 2 46553 NULL
99206 +mv_get_hc_count_46554 mv_get_hc_count 0 46554 NULL
99207 +link_send_sections_long_46556 link_send_sections_long 4 46556 NULL
99208 +irq_domain_associate_46564 irq_domain_associate 2 46564 NULL
99209 +dn_current_mss_46574 dn_current_mss 0 46574 NULL
99210 +serverworks_create_gatt_pages_46582 serverworks_create_gatt_pages 1 46582 NULL
99211 +snd_compr_write_data_46592 snd_compr_write_data 3 46592 NULL
99212 +il3945_stats_flag_46606 il3945_stats_flag 0-3 46606 NULL
99213 +vscnprintf_46617 vscnprintf 0-2 46617 NULL
99214 +__kfifo_out_r_46623 __kfifo_out_r 0-3 46623 NULL
99215 +request_key_async_with_auxdata_46624 request_key_async_with_auxdata 4 46624 NULL
99216 +vfs_getxattr_alloc_46649 vfs_getxattr_alloc 0 46649 NULL
99217 +av7110_ipack_init_46655 av7110_ipack_init 2 46655 NULL
99218 +alloc_data_packet_46698 alloc_data_packet 1 46698 NULL
99219 +__ilog2_u32_46706 __ilog2_u32 0 46706 NULL
99220 +erst_dbg_write_46715 erst_dbg_write 3 46715 NULL
99221 +wl1271_rx_filter_alloc_field_46721 wl1271_rx_filter_alloc_field 5 46721 NULL
99222 +prepare_copy_46725 prepare_copy 2 46725 NULL
99223 +irq_domain_add_simple_46734 irq_domain_add_simple 2-3 46734 NULL
99224 +set_memory_wc_46747 set_memory_wc 1 46747 NULL
99225 +ext4_count_free_46754 ext4_count_free 2 46754 NULL nohasharray
99226 +pte_pfn_46754 pte_pfn 0 46754 &ext4_count_free_46754
99227 +hest_ghes_dev_register_46766 hest_ghes_dev_register 1 46766 NULL
99228 +int_hw_irq_en_46776 int_hw_irq_en 3 46776 NULL
99229 +regcache_lzo_sync_46777 regcache_lzo_sync 2 46777 NULL
99230 +_sys_packet_req_46793 _sys_packet_req 4 46793 NULL
99231 +_xfs_buf_get_pages_46811 _xfs_buf_get_pages 2 46811 NULL
99232 +xfs_iroot_realloc_46826 xfs_iroot_realloc 2 46826 NULL
99233 +shmem_pwrite_fast_46842 shmem_pwrite_fast 3 46842 NULL
99234 +spi_async_46857 spi_async 0 46857 NULL
99235 +vsnprintf_46863 vsnprintf 0 46863 NULL
99236 +nvme_alloc_queue_46865 nvme_alloc_queue 3 46865 NULL
99237 +sip_sprintf_addr_46872 sip_sprintf_addr 0 46872 NULL
99238 +rvmalloc_46873 rvmalloc 1 46873 NULL
99239 +qp_memcpy_from_queue_iov_46874 qp_memcpy_from_queue_iov 4-5 46874 NULL
99240 +hpi_read_word_nolock_46881 hpi_read_word_nolock 0 46881 NULL
99241 +stmpe_gpio_irq_unmap_46884 stmpe_gpio_irq_unmap 2 46884 NULL
99242 +ixgbe_dbg_reg_ops_write_46895 ixgbe_dbg_reg_ops_write 3 46895 NULL
99243 +sk_mem_pages_46896 sk_mem_pages 0-1 46896 NULL
99244 +ol_dqblk_off_46904 ol_dqblk_off 3-2 46904 NULL
99245 +ieee80211_if_fmt_power_mode_46906 ieee80211_if_fmt_power_mode 3 46906 NULL
99246 +wlcore_alloc_hw_46917 wlcore_alloc_hw 1 46917 NULL
99247 +fb_write_46924 fb_write 3 46924 NULL
99248 +btmrvl_curpsmode_read_46939 btmrvl_curpsmode_read 3 46939 NULL
99249 +kvm_register_read_46948 kvm_register_read 0 46948 NULL
99250 +__sctp_setsockopt_connectx_46949 __sctp_setsockopt_connectx 3 46949 NULL
99251 +qla4xxx_post_aen_work_46953 qla4xxx_post_aen_work 3 46953 NULL
99252 +crypto_tfm_alg_alignmask_46971 crypto_tfm_alg_alignmask 0 46971 NULL
99253 +mgmt_pending_add_46976 mgmt_pending_add 5 46976 NULL
99254 +gfs2_xattr_system_set_46996 gfs2_xattr_system_set 4 46996 NULL nohasharray
99255 +sel_write_bool_46996 sel_write_bool 3 46996 &gfs2_xattr_system_set_46996
99256 +ttm_bo_io_47000 ttm_bo_io 5 47000 NULL
99257 +blk_rq_map_kern_47004 blk_rq_map_kern 4 47004 NULL
99258 +__map_single_47020 __map_single 3-4-7 47020 NULL
99259 +cx231xx_init_bulk_47024 cx231xx_init_bulk 3-2 47024 NULL
99260 +swiotlb_sync_single_47031 swiotlb_sync_single 2 47031 NULL
99261 +set_dis_bypass_pfs_47038 set_dis_bypass_pfs 3 47038 NULL
99262 +fs_path_len_47060 fs_path_len 0 47060 NULL
99263 +ufs_new_fragments_47070 ufs_new_fragments 3-5-4 47070 NULL
99264 +pipeline_dec_packet_in_read_47076 pipeline_dec_packet_in_read 3 47076 NULL
99265 +scsi_deactivate_tcq_47086 scsi_deactivate_tcq 2 47086 NULL
99266 +mousedev_read_47123 mousedev_read 3 47123 NULL
99267 +ses_recv_diag_47143 ses_recv_diag 4 47143 NULL nohasharray
99268 +acpi_ut_initialize_buffer_47143 acpi_ut_initialize_buffer 2 47143 &ses_recv_diag_47143
99269 +persistent_ram_iomap_47156 persistent_ram_iomap 1-2 47156 NULL
99270 +mxms_headerlen_47161 mxms_headerlen 0 47161 NULL
99271 +rs_sta_dbgfs_rate_scale_data_read_47165 rs_sta_dbgfs_rate_scale_data_read 3 47165 NULL
99272 +rts51x_ms_rw_47171 rts51x_ms_rw 3-4 47171 NULL
99273 +svc_pool_map_alloc_arrays_47181 svc_pool_map_alloc_arrays 2 47181 NULL
99274 +can_set_system_xattr_47182 can_set_system_xattr 4 47182 NULL
99275 +ioremap_cache_47189 ioremap_cache 1-2 47189 NULL
99276 +gnttab_set_map_op_47206 gnttab_set_map_op 2 47206 NULL
99277 +l2headersize_47238 l2headersize 0 47238 NULL
99278 +options_write_47243 options_write 3 47243 NULL
99279 +portcntrs_1_read_47253 portcntrs_1_read 3 47253 NULL
99280 +da9052_disable_irq_nosync_47260 da9052_disable_irq_nosync 2 47260 NULL
99281 +ablkcipher_next_slow_47274 ablkcipher_next_slow 4-3 47274 NULL
99282 +tty_audit_log_47280 tty_audit_log 8 47280 NULL
99283 +gfs2_readpages_47285 gfs2_readpages 4 47285 NULL
99284 +vsnprintf_47291 vsnprintf 0 47291 NULL
99285 +tx_internal_desc_overflow_read_47300 tx_internal_desc_overflow_read 3 47300 NULL
99286 +ieee80211_if_read_dot11MeshHoldingTimeout_47356 ieee80211_if_read_dot11MeshHoldingTimeout 3 47356 NULL
99287 +avc_get_hash_stats_47359 avc_get_hash_stats 0 47359 NULL
99288 +find_first_zero_bit_le_47369 find_first_zero_bit_le 2 47369 NULL
99289 +__bio_map_kern_47379 __bio_map_kern 3 47379 NULL
99290 +nv_rd32_47390 nv_rd32 0 47390 NULL nohasharray
99291 +trace_options_core_read_47390 trace_options_core_read 3 47390 &nv_rd32_47390
99292 +nametbl_list_47391 nametbl_list 2 47391 NULL
99293 +dgrp_net_write_47392 dgrp_net_write 3 47392 NULL
99294 +pfkey_sendmsg_47394 pfkey_sendmsg 4 47394 NULL
99295 +gfn_to_pfn_prot_47398 gfn_to_pfn_prot 2 47398 NULL
99296 +ocfs2_resv_end_47408 ocfs2_resv_end 0 47408 NULL
99297 +crypto_ablkcipher_alignmask_47410 crypto_ablkcipher_alignmask 0 47410 NULL
99298 +vzalloc_47421 vzalloc 1 47421 NULL
99299 +posix_acl_from_disk_47445 posix_acl_from_disk 2 47445 NULL
99300 +__load_mapping_47460 __load_mapping 2 47460 NULL
99301 +wb_force_mapping_47485 wb_force_mapping 2 47485 NULL nohasharray
99302 +newpart_47485 newpart 6 47485 &wb_force_mapping_47485
99303 +core_sys_select_47494 core_sys_select 1 47494 NULL
99304 +unlink_simple_47506 unlink_simple 3 47506 NULL
99305 +ufs_inode_getblock_47512 ufs_inode_getblock 4 47512 NULL
99306 +vscnprintf_47533 vscnprintf 0-2 47533 NULL nohasharray
99307 +process_vm_rw_47533 process_vm_rw 3-5 47533 &vscnprintf_47533
99308 +oz_events_read_47535 oz_events_read 3 47535 NULL
99309 +ieee80211_if_fmt_min_discovery_timeout_47539 ieee80211_if_fmt_min_discovery_timeout 3 47539 NULL
99310 +read_ldt_47570 read_ldt 2 47570 NULL
99311 +pci_iomap_47575 pci_iomap 3 47575 NULL
99312 +rpipe_get_idx_47579 rpipe_get_idx 2 47579 NULL
99313 +ext4_kvzalloc_47605 ext4_kvzalloc 1 47605 NULL
99314 +sctp_ssnmap_new_47608 sctp_ssnmap_new 1-2 47608 NULL
99315 +uea_request_47613 uea_request 4 47613 NULL
99316 +cache_read_pipefs_47615 cache_read_pipefs 3 47615 NULL
99317 +twl4030_clear_set_47624 twl4030_clear_set 4 47624 NULL
99318 +irq_set_chip_47638 irq_set_chip 1 47638 NULL
99319 +__build_packet_message_47643 __build_packet_message 3-9 47643 NULL
99320 +save_microcode_47717 save_microcode 3 47717 NULL
99321 +bits_to_user_47733 bits_to_user 2-3 47733 NULL
99322 +carl9170_debugfs_read_47738 carl9170_debugfs_read 3 47738 NULL
99323 +ir_prepare_write_buffer_47747 ir_prepare_write_buffer 3 47747 NULL
99324 +mvumi_alloc_mem_resource_47750 mvumi_alloc_mem_resource 3 47750 NULL
99325 +ext3_find_near_47752 ext3_find_near 0 47752 NULL
99326 +alloc_sched_domains_47756 alloc_sched_domains 1 47756 NULL
99327 +i915_wedged_write_47771 i915_wedged_write 3 47771 NULL
99328 +uwb_ie_dump_hex_47774 uwb_ie_dump_hex 4 47774 NULL
99329 +error_error_numll_frame_cts_start_read_47781 error_error_numll_frame_cts_start_read 3 47781 NULL
99330 +posix_acl_fix_xattr_from_user_47793 posix_acl_fix_xattr_from_user 2 47793 NULL
99331 +stmmac_set_bfsize_47834 stmmac_set_bfsize 0 47834 NULL
99332 +ubifs_unpack_nnode_47866 ubifs_unpack_nnode 0 47866 NULL
99333 +vhci_read_47878 vhci_read 3 47878 NULL
99334 +keyctl_instantiate_key_common_47889 keyctl_instantiate_key_common 4 47889 NULL
99335 +load_mapping_47904 load_mapping 3 47904 NULL
99336 +osd_req_read_sg_47905 osd_req_read_sg 5 47905 NULL
99337 +comedi_write_47926 comedi_write 3 47926 NULL
99338 +lp8788_irq_map_47964 lp8788_irq_map 2 47964 NULL
99339 +iwl_dbgfs_ucode_tracing_read_47983 iwl_dbgfs_ucode_tracing_read 3 47983 NULL nohasharray
99340 +mempool_resize_47983 mempool_resize 2 47983 &iwl_dbgfs_ucode_tracing_read_47983
99341 +dbg_port_buf_47990 dbg_port_buf 2 47990 NULL
99342 +ib_umad_write_47993 ib_umad_write 3 47993 NULL
99343 +ffs_epfile_write_48014 ffs_epfile_write 3 48014 NULL
99344 +bio_integrity_set_tag_48035 bio_integrity_set_tag 3 48035 NULL
99345 +pppoe_sendmsg_48039 pppoe_sendmsg 4 48039 NULL
99346 +wpan_phy_alloc_48056 wpan_phy_alloc 1 48056 NULL
99347 +posix_acl_alloc_48063 posix_acl_alloc 1 48063 NULL
99348 +palmas_bulk_write_48068 palmas_bulk_write 2-3-5 48068 NULL
99349 +mmc_alloc_host_48097 mmc_alloc_host 1 48097 NULL
99350 +skb_copy_datagram_const_iovec_48102 skb_copy_datagram_const_iovec 4-2-5 48102 NULL
99351 +radio_isa_common_probe_48107 radio_isa_common_probe 3 48107 NULL
99352 +vmw_framebuffer_surface_dirty_48132 vmw_framebuffer_surface_dirty 6 48132 NULL
99353 +set_discoverable_48141 set_discoverable 4 48141 NULL
99354 +dn_fib_count_nhs_48145 dn_fib_count_nhs 0 48145 NULL
99355 +bitmap_onto_48152 bitmap_onto 4 48152 NULL
99356 +isr_dma1_done_read_48159 isr_dma1_done_read 3 48159 NULL
99357 +c4iw_id_table_alloc_48163 c4iw_id_table_alloc 3 48163 NULL
99358 +ocfs2_find_next_zero_bit_unaligned_48170 ocfs2_find_next_zero_bit_unaligned 2-3 48170 NULL
99359 +alloc_cc770dev_48186 alloc_cc770dev 1 48186 NULL
99360 +init_ipath_48187 init_ipath 1 48187 NULL
99361 +snd_seq_dump_var_event_48209 snd_seq_dump_var_event 0 48209 NULL
99362 +is_block_in_journal_48223 is_block_in_journal 3 48223 NULL
99363 +uv_blade_nr_possible_cpus_48226 uv_blade_nr_possible_cpus 0 48226 NULL
99364 +nilfs_readpages_48229 nilfs_readpages 4 48229 NULL
99365 +read_file_recv_48232 read_file_recv 3 48232 NULL
99366 +unaccount_shadowed_48233 unaccount_shadowed 2 48233 NULL
99367 +nfsctl_transaction_read_48250 nfsctl_transaction_read 3 48250 NULL
99368 +cache_write_pipefs_48270 cache_write_pipefs 3 48270 NULL
99369 +send_set_info_48288 send_set_info 7 48288 NULL
99370 +set_disc_pwup_pfs_48300 set_disc_pwup_pfs 3 48300 NULL
99371 +lpfc_idiag_extacc_read_48301 lpfc_idiag_extacc_read 3 48301 NULL
99372 +timblogiw_read_48305 timblogiw_read 3 48305 NULL
99373 +hash_setkey_48310 hash_setkey 3 48310 NULL
99374 +__alloc_fd_48356 __alloc_fd 2 48356 NULL
99375 +skb_add_data_48363 skb_add_data 3 48363 NULL
99376 +tx_frag_init_called_read_48377 tx_frag_init_called_read 3 48377 NULL
99377 +ixgbe_pci_sriov_enable_48410 ixgbe_pci_sriov_enable 2 48410 NULL
99378 +lbs_debugfs_write_48413 lbs_debugfs_write 3 48413 NULL
99379 +pwr_tx_without_ps_read_48423 pwr_tx_without_ps_read 3 48423 NULL
99380 +nfs4_alloc_pages_48426 nfs4_alloc_pages 1 48426 NULL
99381 +tun_recvmsg_48463 tun_recvmsg 4 48463 NULL
99382 +r8712_usbctrl_vendorreq_48489 r8712_usbctrl_vendorreq 6 48489 NULL
99383 +send_control_msg_48498 send_control_msg 6 48498 NULL
99384 +mlx4_en_create_tx_ring_48501 mlx4_en_create_tx_ring 4 48501 NULL
99385 +count_masked_bytes_48507 count_masked_bytes 0-1 48507 NULL
99386 +diva_os_copy_to_user_48508 diva_os_copy_to_user 4 48508 NULL
99387 +brcmf_sdio_trap_info_48510 brcmf_sdio_trap_info 4 48510 NULL
99388 +phantom_get_free_48514 phantom_get_free 0 48514 NULL
99389 +wiimote_hid_send_48528 wiimote_hid_send 3 48528 NULL
99390 +ext3_splice_branch_48531 ext3_splice_branch 6 48531 NULL
99391 +named_distribute_48544 named_distribute 4 48544 NULL
99392 +raid10_size_48571 raid10_size 0-2-3 48571 NULL
99393 +ufs_dtogd_48616 ufs_dtogd 0-2 48616 NULL
99394 +do_ip_vs_set_ctl_48641 do_ip_vs_set_ctl 4 48641 NULL
99395 +mtd_read_48655 mtd_read 0 48655 NULL
99396 +aes_encrypt_packets_read_48666 aes_encrypt_packets_read 3 48666 NULL
99397 +sm501_create_subdev_48668 sm501_create_subdev 3-4 48668 NULL nohasharray
99398 +sys_setgroups_48668 sys_setgroups 1 48668 &sm501_create_subdev_48668
99399 +altera_drscan_48698 altera_drscan 2 48698 NULL
99400 +kvm_set_irq_routing_48704 kvm_set_irq_routing 3 48704 NULL
99401 +ath6kl_usb_bmi_read_48745 ath6kl_usb_bmi_read 3 48745 NULL
99402 +ath6kl_regwrite_read_48747 ath6kl_regwrite_read 3 48747 NULL
99403 +l2cap_segment_sdu_48772 l2cap_segment_sdu 4 48772 NULL
99404 +lua_sysfs_write_48797 lua_sysfs_write 6 48797 NULL
99405 +il3945_sta_dbgfs_stats_table_read_48802 il3945_sta_dbgfs_stats_table_read 3 48802 NULL
99406 +twa_change_queue_depth_48808 twa_change_queue_depth 2 48808 NULL
99407 +atomic_counters_read_48827 atomic_counters_read 3 48827 NULL
99408 +efi_memory_uc_48828 efi_memory_uc 1 48828 NULL
99409 +azx_get_position_48841 azx_get_position 0 48841 NULL
99410 +vc_do_resize_48842 vc_do_resize 3-4 48842 NULL
99411 +viafb_dvp1_proc_write_48864 viafb_dvp1_proc_write 3 48864 NULL
99412 +__ffs_ep0_read_events_48868 __ffs_ep0_read_events 3 48868 NULL
99413 +sys_setgroups16_48882 sys_setgroups16 1 48882 NULL
99414 +ext2_alloc_branch_48889 ext2_alloc_branch 4 48889 NULL
99415 +crypto_cipher_ctxsize_48890 crypto_cipher_ctxsize 0 48890 NULL
99416 +xdi_copy_to_user_48900 xdi_copy_to_user 4 48900 NULL
99417 +msg_hdr_sz_48908 msg_hdr_sz 0 48908 NULL
99418 +gdth_isa_probe_one_48925 gdth_isa_probe_one 1 48925 NULL
99419 +sep_crypto_dma_48937 sep_crypto_dma 0 48937 NULL
99420 +event_heart_beat_read_48961 event_heart_beat_read 3 48961 NULL
99421 +nand_ecc_test_run_48966 nand_ecc_test_run 1 48966 NULL
99422 +vmci_handle_arr_create_48971 vmci_handle_arr_create 1 48971 NULL
99423 +batadv_orig_hash_del_if_48972 batadv_orig_hash_del_if 2 48972 NULL
99424 +_alloc_set_attr_list_48991 _alloc_set_attr_list 4 48991 NULL
99425 +rds_rm_size_48996 rds_rm_size 0-2 48996 NULL
99426 +sel_write_enforce_48998 sel_write_enforce 3 48998 NULL
99427 +transient_status_49027 transient_status 4 49027 NULL
99428 +ipath_reg_user_mr_49038 ipath_reg_user_mr 2-3 49038 NULL
99429 +setup_msi_irq_49052 setup_msi_irq 3-4 49052 NULL
99430 +ubi_read_49061 ubi_read 0 49061 NULL
99431 +scsi_register_49094 scsi_register 2 49094 NULL
99432 +paging64_walk_addr_nested_49100 paging64_walk_addr_nested 3 49100 NULL
99433 +compat_do_readv_writev_49102 compat_do_readv_writev 4 49102 NULL
99434 +xfrm_replay_state_esn_len_49119 xfrm_replay_state_esn_len 0 49119 NULL
99435 +pt_read_49136 pt_read 3 49136 NULL
99436 +tipc_multicast_49144 tipc_multicast 5 49144 NULL
99437 +atyfb_setup_generic_49151 atyfb_setup_generic 3 49151 NULL
99438 +ipwireless_tty_received_49154 ipwireless_tty_received 3 49154 NULL
99439 +f2fs_acl_count_49155 f2fs_acl_count 0-1 49155 NULL
99440 +ipw_queue_tx_init_49161 ipw_queue_tx_init 3 49161 NULL
99441 +ext4_free_clusters_after_init_49174 ext4_free_clusters_after_init 2 49174 NULL
99442 +dvb_dvr_ioctl_49182 dvb_dvr_ioctl 2 49182 NULL
99443 +iwl_dbgfs_ucode_general_stats_read_49199 iwl_dbgfs_ucode_general_stats_read 3 49199 NULL
99444 +il4965_rs_sta_dbgfs_stats_table_read_49206 il4965_rs_sta_dbgfs_stats_table_read 3 49206 NULL
99445 +do_jffs2_getxattr_49210 do_jffs2_getxattr 0 49210 NULL
99446 +nouveau_therm_create__49228 nouveau_therm_create_ 4 49228 NULL
99447 +nouveau_i2c_port_create__49237 nouveau_i2c_port_create_ 6 49237 NULL
99448 +hugetlb_cgroup_read_49259 hugetlb_cgroup_read 5 49259 NULL
99449 +ieee80211_if_read_rssi_threshold_49260 ieee80211_if_read_rssi_threshold 3 49260 NULL
99450 +osd_req_add_get_attr_list_49278 osd_req_add_get_attr_list 3 49278 NULL
99451 +rx_filter_beacon_filter_read_49279 rx_filter_beacon_filter_read 3 49279 NULL
99452 +uio_read_49300 uio_read 3 49300 NULL
99453 +ocfs2_resmap_find_free_bits_49301 ocfs2_resmap_find_free_bits 3 49301 NULL
99454 +fwtty_port_handler_49327 fwtty_port_handler 9 49327 NULL
99455 +srpt_alloc_ioctx_ring_49330 srpt_alloc_ioctx_ring 2-3-4 49330 NULL
99456 +cfpkt_setlen_49343 cfpkt_setlen 2 49343 NULL
99457 +joydev_ioctl_common_49359 joydev_ioctl_common 2 49359 NULL
99458 +ocfs2_remove_btree_range_49370 ocfs2_remove_btree_range 4-5-3 49370 NULL
99459 +px_raw_event_49371 px_raw_event 4 49371 NULL
99460 +iscsi_alloc_session_49390 iscsi_alloc_session 3 49390 NULL
99461 +applesmc_create_nodes_49392 applesmc_create_nodes 2 49392 NULL
99462 +rx_streaming_always_read_49401 rx_streaming_always_read 3 49401 NULL
99463 +tnode_alloc_49407 tnode_alloc 1 49407 NULL
99464 +samples_to_bytes_49426 samples_to_bytes 0-2 49426 NULL
99465 +md_domain_init_49432 md_domain_init 2 49432 NULL
99466 +compat_do_msg_fill_49440 compat_do_msg_fill 3 49440 NULL
99467 +agp_3_5_isochronous_node_enable_49465 agp_3_5_isochronous_node_enable 3 49465 NULL
99468 +xfs_iformat_local_49472 xfs_iformat_local 4 49472 NULL
99469 +savu_sysfs_read_49473 savu_sysfs_read 6 49473 NULL
99470 +isr_decrypt_done_read_49490 isr_decrypt_done_read 3 49490 NULL
99471 +emulator_write_phys_49520 emulator_write_phys 2-4 49520 NULL
99472 +acpi_os_ioremap_49523 acpi_os_ioremap 1-2 49523 NULL
99473 +smk_write_access_49561 smk_write_access 3 49561 NULL
99474 +ntfs_malloc_nofs_49572 ntfs_malloc_nofs 1 49572 NULL
99475 +alloc_chunk_49575 alloc_chunk 1 49575 NULL
99476 +sctp_setsockopt_default_send_param_49578 sctp_setsockopt_default_send_param 3 49578 NULL
99477 +isr_wakeups_read_49607 isr_wakeups_read 3 49607 NULL
99478 +btrfs_mksubvol_49616 btrfs_mksubvol 3 49616 NULL
99479 +heap_init_49617 heap_init 2 49617 NULL
99480 +smk_write_doi_49621 smk_write_doi 3 49621 NULL
99481 +btrfsic_cmp_log_and_dev_bytenr_49628 btrfsic_cmp_log_and_dev_bytenr 2 49628 NULL
99482 +aa_simple_write_to_buffer_49683 aa_simple_write_to_buffer 3-4 49683 NULL
99483 +sys_gethostname_49698 sys_gethostname 2 49698 NULL
99484 +cx2341x_ctrl_new_menu_49700 cx2341x_ctrl_new_menu 3 49700 NULL
99485 +dm_thin_insert_block_49720 dm_thin_insert_block 2-3 49720 NULL
99486 +sep_create_dcb_dmatables_context_kernel_49728 sep_create_dcb_dmatables_context_kernel 6 49728 NULL
99487 +sys_fsetxattr_49736 sys_fsetxattr 4 49736 NULL
99488 +check_frame_49741 check_frame 0 49741 NULL
99489 +zd_usb_iowrite16v_49744 zd_usb_iowrite16v 3 49744 NULL
99490 +btrfs_chunk_num_stripes_49751 btrfs_chunk_num_stripes 0 49751 NULL
99491 +fuse_wr_pages_49753 fuse_wr_pages 0-1-2 49753 NULL
99492 +key_conf_keylen_read_49758 key_conf_keylen_read 3 49758 NULL
99493 +fuse_conn_waiting_read_49762 fuse_conn_waiting_read 3 49762 NULL
99494 +isku_sysfs_write_49767 isku_sysfs_write 6 49767 NULL
99495 +ceph_osdc_readpages_49789 ceph_osdc_readpages 10-4 49789 NULL
99496 +nfs4_acl_new_49806 nfs4_acl_new 1 49806 NULL
99497 +arch_gnttab_map_status_49812 arch_gnttab_map_status 3 49812 NULL
99498 +ntfs_copy_from_user_iovec_49829 ntfs_copy_from_user_iovec 3-6-0 49829 NULL
99499 +add_uuid_49831 add_uuid 4 49831 NULL
99500 +ath6kl_fwlog_block_read_49836 ath6kl_fwlog_block_read 3 49836 NULL
99501 +twl4030_write_49846 twl4030_write 2 49846 NULL
99502 +scsi_dispatch_cmd_entry_49848 scsi_dispatch_cmd_entry 3 49848 NULL
99503 +timeradd_entry_49850 timeradd_entry 3 49850 NULL
99504 +sctp_setsockopt_bindx_49870 sctp_setsockopt_bindx 3 49870 NULL
99505 +ceph_get_caps_49890 ceph_get_caps 0 49890 NULL
99506 +__cow_file_range_49901 __cow_file_range 5 49901 NULL
99507 +__copy_from_user_inatomic_nocache_49921 __copy_from_user_inatomic_nocache 3 49921 NULL
99508 +batadv_tt_realloc_packet_buff_49960 batadv_tt_realloc_packet_buff 4 49960 NULL
99509 +b43legacy_pio_read_49978 b43legacy_pio_read 0 49978 NULL
99510 +ieee80211_if_fmt_dtim_count_49987 ieee80211_if_fmt_dtim_count 3 49987 NULL
99511 +l2cap_chan_send_49995 l2cap_chan_send 3 49995 NULL
99512 +__module_alloc_50004 __module_alloc 1 50004 NULL
99513 +dn_mss_from_pmtu_50011 dn_mss_from_pmtu 0-2 50011 NULL
99514 +ptrace_readdata_50020 ptrace_readdata 2-4 50020 NULL
99515 +isdn_read_50021 isdn_read 3 50021 NULL
99516 +qp_alloc_queue_50028 qp_alloc_queue 1 50028 NULL
99517 +alloc_ebda_hpc_50046 alloc_ebda_hpc 1-2 50046 NULL
99518 +vmw_surface_destroy_size_50072 vmw_surface_destroy_size 0 50072 NULL
99519 +arch_setup_ht_irq_50073 arch_setup_ht_irq 1 50073 NULL
99520 +dev_set_alias_50084 dev_set_alias 3 50084 NULL
99521 +pcpu_get_vm_areas_50085 pcpu_get_vm_areas 3 50085 NULL
99522 +sock_setsockopt_50088 sock_setsockopt 5 50088 NULL
99523 +altera_swap_dr_50090 altera_swap_dr 2 50090 NULL
99524 +read_file_slot_50111 read_file_slot 3 50111 NULL
99525 +copy_items_50140 copy_items 6 50140 NULL
99526 +tx_frag_need_fragmentation_read_50153 tx_frag_need_fragmentation_read 3 50153 NULL
99527 +set_cmd_header_50155 set_cmd_header 0 50155 NULL
99528 +reiserfs_bmap_count_50160 reiserfs_bmap_count 0 50160 NULL
99529 +aac_nark_ioremap_50163 aac_nark_ioremap 2 50163 NULL nohasharray
99530 +kmalloc_node_50163 kmalloc_node 1 50163 &aac_nark_ioremap_50163
99531 +rx_filter_ibss_filter_read_50167 rx_filter_ibss_filter_read 3 50167 NULL
99532 +odev_update_50169 odev_update 2 50169 NULL
99533 +ieee80211_if_fmt_dot11MeshHWMPRannInterval_50172 ieee80211_if_fmt_dot11MeshHWMPRannInterval 3 50172 NULL nohasharray
99534 +ubi_resize_volume_50172 ubi_resize_volume 2 50172 &ieee80211_if_fmt_dot11MeshHWMPRannInterval_50172
99535 +ib_send_cm_drep_50186 ib_send_cm_drep 3 50186 NULL
99536 +cfg80211_roamed_bss_50198 cfg80211_roamed_bss 4-6 50198 NULL
99537 +rx_rx_timeout_wa_read_50204 rx_rx_timeout_wa_read 3 50204 NULL
99538 +ieee80211_skb_resize_50211 ieee80211_skb_resize 3 50211 NULL
99539 +mon_bin_compat_ioctl_50234 mon_bin_compat_ioctl 3 50234 NULL
99540 +sg_kmalloc_50240 sg_kmalloc 1 50240 NULL
99541 +afs_extract_data_50261 afs_extract_data 5 50261 NULL
99542 +rxrpc_setsockopt_50286 rxrpc_setsockopt 5 50286 NULL
99543 +soc_codec_reg_show_50302 soc_codec_reg_show 0 50302 NULL
99544 +soc_camera_read_50319 soc_camera_read 3 50319 NULL
99545 +do_launder_page_50329 do_launder_page 0 50329 NULL
99546 +nouveau_engine_create__50331 nouveau_engine_create_ 7 50331 NULL
99547 +lpfc_idiag_pcicfg_read_50334 lpfc_idiag_pcicfg_read 3 50334 NULL
99548 +ocfs2_block_to_cluster_group_50337 ocfs2_block_to_cluster_group 2 50337 NULL nohasharray
99549 +snd_pcm_lib_writev_50337 snd_pcm_lib_writev 0-3 50337 &ocfs2_block_to_cluster_group_50337
99550 +roccat_common2_send_with_status_50343 roccat_common2_send_with_status 4 50343 NULL
99551 +tpm_read_50344 tpm_read 3 50344 NULL
99552 +kvm_arch_create_memslot_50354 kvm_arch_create_memslot 2 50354 NULL
99553 +isdn_ppp_read_50356 isdn_ppp_read 4 50356 NULL
99554 +unpack_u16_chunk_50357 unpack_u16_chunk 0 50357 NULL
99555 +xfrm_send_migrate_50365 xfrm_send_migrate 5 50365 NULL
99556 +roccat_common2_receive_50369 roccat_common2_receive 4 50369 NULL
99557 +sl_alloc_bufs_50380 sl_alloc_bufs 2 50380 NULL
99558 +l2tp_ip_sendmsg_50411 l2tp_ip_sendmsg 4 50411 NULL
99559 +iscsi_create_conn_50425 iscsi_create_conn 2 50425 NULL
99560 +validate_acl_mac_addrs_50429 validate_acl_mac_addrs 0 50429 NULL
99561 +btrfs_error_discard_extent_50444 btrfs_error_discard_extent 2 50444 NULL
99562 +pgctrl_write_50453 pgctrl_write 3 50453 NULL
99563 +force_mapping_50464 force_mapping 2 50464 NULL
99564 +cdrom_read_cdda_50478 cdrom_read_cdda 4 50478 NULL
99565 +mei_io_cb_alloc_req_buf_50493 mei_io_cb_alloc_req_buf 2 50493 NULL
99566 +pwr_rcvd_awake_beacons_read_50505 pwr_rcvd_awake_beacons_read 3 50505 NULL
99567 +fwnet_receive_packet_50537 fwnet_receive_packet 9 50537 NULL
99568 +ath6kl_set_ap_probe_resp_ies_50539 ath6kl_set_ap_probe_resp_ies 3 50539 NULL
99569 +hme_read_desc32_50574 hme_read_desc32 0 50574 NULL
99570 +fat_readpages_50582 fat_readpages 4 50582 NULL
99571 +iwl_dbgfs_missed_beacon_read_50584 iwl_dbgfs_missed_beacon_read 3 50584 NULL
99572 +build_inv_iommu_pages_50589 build_inv_iommu_pages 2-3 50589 NULL
99573 +rx_rx_checksum_result_read_50617 rx_rx_checksum_result_read 3 50617 NULL
99574 +__ffs_50625 __ffs 0 50625 NULL
99575 +simple_transaction_get_50633 simple_transaction_get 3 50633 NULL
99576 +ath6kl_tm_rx_event_50664 ath6kl_tm_rx_event 3 50664 NULL nohasharray
99577 +sys_readv_50664 sys_readv 3 50664 &ath6kl_tm_rx_event_50664
99578 +bnad_debugfs_read_50665 bnad_debugfs_read 3 50665 NULL
99579 +ext2_try_to_allocate_with_rsv_50669 ext2_try_to_allocate_with_rsv 4-2 50669 NULL
99580 +btmrvl_psstate_read_50683 btmrvl_psstate_read 3 50683 NULL
99581 +swiotlb_free_coherent_50690 swiotlb_free_coherent 4 50690 NULL
99582 +paging32_gva_to_gpa_50696 paging32_gva_to_gpa 2 50696 NULL
99583 +xfs_growfs_get_hdr_buf_50697 xfs_growfs_get_hdr_buf 3 50697 NULL
99584 +blk_check_plugged_50736 blk_check_plugged 3 50736 NULL
99585 +__ext3_get_inode_loc_50744 __ext3_get_inode_loc 0 50744 NULL
99586 +skb_padto_50759 skb_padto 2 50759 NULL
99587 +ocfs2_xattr_block_get_50773 ocfs2_xattr_block_get 0 50773 NULL
99588 +tm6000_read_write_usb_50774 tm6000_read_write_usb 7 50774 NULL
99589 +bio_alloc_map_data_50782 bio_alloc_map_data 1-2 50782 NULL
99590 +tpm_write_50798 tpm_write 3 50798 NULL
99591 +write_flush_50803 write_flush 3 50803 NULL
99592 +dvb_play_50814 dvb_play 3 50814 NULL
99593 +dpcm_show_state_50827 dpcm_show_state 0 50827 NULL
99594 +acpi_ev_install_gpe_block_50829 acpi_ev_install_gpe_block 2 50829 NULL
99595 +SetArea_50835 SetArea 4 50835 NULL nohasharray
99596 +create_mem_extents_50835 create_mem_extents 0 50835 &SetArea_50835
99597 +videobuf_dma_init_user_50839 videobuf_dma_init_user 3 50839 NULL
99598 +self_check_write_50856 self_check_write 5 50856 NULL
99599 +carl9170_debugfs_write_50857 carl9170_debugfs_write 3 50857 NULL
99600 +netlbl_secattr_catmap_walk_rng_50894 netlbl_secattr_catmap_walk_rng 0-2 50894 NULL
99601 +osd_req_write_sg_50908 osd_req_write_sg 5 50908 NULL
99602 +xfs_iext_remove_50909 xfs_iext_remove 3 50909 NULL
99603 +blk_rq_cur_sectors_50910 blk_rq_cur_sectors 0 50910 NULL
99604 +hash_recvmsg_50924 hash_recvmsg 4 50924 NULL
99605 +chd_dec_fetch_cdata_50926 chd_dec_fetch_cdata 3 50926 NULL
99606 +ocfs2_add_refcount_flag_50952 ocfs2_add_refcount_flag 6 50952 NULL
99607 +iwl_statistics_flag_50981 iwl_statistics_flag 0-3 50981 NULL
99608 +timeout_write_50991 timeout_write 3 50991 NULL
99609 +wm831x_irq_map_50995 wm831x_irq_map 2 50995 NULL
99610 +proc_write_51003 proc_write 3 51003 NULL
99611 +snd_pcm_default_page_ops_51021 snd_pcm_default_page_ops 2 51021 NULL
99612 +lbs_dev_info_51023 lbs_dev_info 3 51023 NULL
99613 +ntfs_attr_find_51028 ntfs_attr_find 0 51028 NULL nohasharray
99614 +fuse_conn_congestion_threshold_read_51028 fuse_conn_congestion_threshold_read 3 51028 &ntfs_attr_find_51028
99615 +BcmGetSectionValEndOffset_51039 BcmGetSectionValEndOffset 0 51039 NULL
99616 +dump_midi_51040 dump_midi 3 51040 NULL
99617 +srpt_alloc_ioctx_51042 srpt_alloc_ioctx 2-3 51042 NULL
99618 +do_arpt_set_ctl_51053 do_arpt_set_ctl 4 51053 NULL
99619 +wusb_prf_64_51065 wusb_prf_64 7 51065 NULL
99620 +jbd2_journal_init_revoke_51088 jbd2_journal_init_revoke 2 51088 NULL
99621 +__ocfs2_find_path_51096 __ocfs2_find_path 0 51096 NULL
99622 +ti_recv_51110 ti_recv 3 51110 NULL
99623 +dgrp_net_read_51113 dgrp_net_read 3 51113 NULL
99624 +nfs_map_name_to_uid_51132 nfs_map_name_to_uid 3 51132 NULL
99625 +alloc_rtllib_51136 alloc_rtllib 1 51136 NULL
99626 +simple_xattr_set_51140 simple_xattr_set 4 51140 NULL
99627 +set_dirty_51144 set_dirty 3 51144 NULL
99628 +xfs_trans_get_efd_51148 xfs_trans_get_efd 3 51148 NULL
99629 +compat_sys_pwritev64_51151 compat_sys_pwritev64 3 51151 NULL
99630 +blk_bio_map_sg_51213 blk_bio_map_sg 0 51213 NULL
99631 +nf_ct_ext_create_51232 nf_ct_ext_create 3 51232 NULL
99632 +snd_pcm_write_51235 snd_pcm_write 3 51235 NULL
99633 +tipc_send_51238 tipc_send 4 51238 NULL
99634 +drm_property_create_51239 drm_property_create 4 51239 NULL
99635 +st_read_51251 st_read 3 51251 NULL
99636 +compat_dccp_setsockopt_51263 compat_dccp_setsockopt 5 51263 NULL
99637 +dvb_audio_write_51275 dvb_audio_write 3 51275 NULL
99638 +ipwireless_network_packet_received_51277 ipwireless_network_packet_received 4 51277 NULL
99639 +zone_reclaimable_pages_51283 zone_reclaimable_pages 0 51283 NULL
99640 +pvr2_std_id_to_str_51288 pvr2_std_id_to_str 2 51288 NULL
99641 +bnad_debugfs_read_regrd_51308 bnad_debugfs_read_regrd 3 51308 NULL
99642 +get_cell_51316 get_cell 2 51316 NULL
99643 +alloc_hippi_dev_51320 alloc_hippi_dev 1 51320 NULL
99644 +ext2_xattr_get_51327 ext2_xattr_get 0 51327 NULL
99645 +alloc_smp_req_51337 alloc_smp_req 1 51337 NULL nohasharray
99646 +compat_arch_ptrace_51337 compat_arch_ptrace 3-4 51337 &alloc_smp_req_51337
99647 +ipw_get_event_log_len_51341 ipw_get_event_log_len 0 51341 NULL
99648 +ieee80211_if_fmt_estab_plinks_51370 ieee80211_if_fmt_estab_plinks 3 51370 NULL
99649 +radeon_kms_compat_ioctl_51371 radeon_kms_compat_ioctl 2 51371 NULL
99650 +ieee80211_wx_set_gen_ie_51399 ieee80211_wx_set_gen_ie 3 51399 NULL
99651 +ceph_sync_read_51410 ceph_sync_read 3 51410 NULL
99652 +x86_swiotlb_free_coherent_51421 x86_swiotlb_free_coherent 4 51421 NULL
99653 +blk_register_region_51424 blk_register_region 1-2 51424 NULL
99654 +mwifiex_rdeeprom_read_51429 mwifiex_rdeeprom_read 3 51429 NULL
99655 +ieee80211_if_read_dot11MeshHWMPRootMode_51441 ieee80211_if_read_dot11MeshHWMPRootMode 3 51441 NULL
99656 +print_devstats_dot11ACKFailureCount_51443 print_devstats_dot11ACKFailureCount 3 51443 NULL
99657 +____alloc_ei_netdev_51475 ____alloc_ei_netdev 1 51475 NULL
99658 +xfs_buf_get_uncached_51477 xfs_buf_get_uncached 2 51477 NULL
99659 +vaddr_51480 vaddr 0 51480 NULL
99660 +__cpa_process_fault_51502 __cpa_process_fault 2 51502 NULL
99661 +ieee80211_if_write_uapsd_queues_51526 ieee80211_if_write_uapsd_queues 3 51526 NULL
99662 +load_pdptrs_51541 load_pdptrs 3 51541 NULL
99663 +__alloc_eip_netdev_51549 __alloc_eip_netdev 1 51549 NULL
99664 +icmp_manip_pkt_51560 icmp_manip_pkt 4 51560 NULL
99665 +ixgb_get_eeprom_len_51586 ixgb_get_eeprom_len 0 51586 NULL
99666 +aac_convert_sgraw2_51598 aac_convert_sgraw2 4 51598 NULL
99667 +raw_ioctl_51607 raw_ioctl 3 51607 NULL
99668 +table_size_to_number_of_entries_51613 table_size_to_number_of_entries 0-1 51613 NULL
99669 +gnttab_end_foreign_access_51617 gnttab_end_foreign_access 3 51617 NULL
99670 +dns_resolve_server_name_to_ip_51632 dns_resolve_server_name_to_ip 0 51632 NULL
99671 +sctp_auth_create_key_51641 sctp_auth_create_key 1 51641 NULL
99672 +iscsi_create_session_51647 iscsi_create_session 3 51647 NULL
99673 +get_new_cssid_51665 get_new_cssid 2 51665 NULL
99674 +ps_upsd_utilization_read_51669 ps_upsd_utilization_read 3 51669 NULL
99675 +sctp_setsockopt_associnfo_51684 sctp_setsockopt_associnfo 3 51684 NULL
99676 +sfi_sysfs_install_table_51688 sfi_sysfs_install_table 1 51688 NULL
99677 +host_mapping_level_51696 host_mapping_level 2 51696 NULL
99678 +sel_write_access_51704 sel_write_access 3 51704 NULL
99679 +tty_cdev_add_51714 tty_cdev_add 2-4 51714 NULL
99680 +v9fs_alloc_rdir_buf_51716 v9fs_alloc_rdir_buf 2 51716 NULL
99681 +drm_compat_ioctl_51717 drm_compat_ioctl 2 51717 NULL
99682 +sg_read_oxfer_51724 sg_read_oxfer 3 51724 NULL
99683 +hid_parse_report_51737 hid_parse_report 3 51737 NULL
99684 +get_user_pages_fast_51751 get_user_pages_fast 0-1-2 51751 NULL
99685 +ifx_spi_insert_flip_string_51752 ifx_spi_insert_flip_string 3 51752 NULL
99686 +if_write_51756 if_write 3 51756 NULL
99687 +ioremap_prot_51764 ioremap_prot 1-2 51764 NULL
99688 +iio_buffer_add_channel_sysfs_51766 iio_buffer_add_channel_sysfs 0 51766 NULL
99689 +qib_alloc_devdata_51819 qib_alloc_devdata 2 51819 NULL
99690 +buffer_from_user_51826 buffer_from_user 3 51826 NULL
99691 +ioread32_51847 ioread32 0 51847 NULL nohasharray
99692 +read_file_tgt_tx_stats_51847 read_file_tgt_tx_stats 3 51847 &ioread32_51847
99693 +do_readv_writev_51849 do_readv_writev 4 51849 NULL
99694 +pointer_size_read_51863 pointer_size_read 3 51863 NULL
99695 +mlx4_alloc_db_from_pgdir_51865 mlx4_alloc_db_from_pgdir 3 51865 NULL
99696 +get_indirect_ea_51869 get_indirect_ea 4 51869 NULL
99697 +user_read_51881 user_read 3 51881 NULL
99698 +memblock_alloc_51884 memblock_alloc 1-2 51884 NULL
99699 +dbAdjCtl_51888 dbAdjCtl 0 51888 NULL
99700 +virt_to_phys_51896 virt_to_phys 0 51896 NULL
99701 +wmi_set_ie_51919 wmi_set_ie 3 51919 NULL
99702 +dbg_status_buf_51930 dbg_status_buf 2 51930 NULL
99703 +__tcp_mtu_to_mss_51938 __tcp_mtu_to_mss 0-2 51938 NULL
99704 +xfrm_alg_len_51940 xfrm_alg_len 0 51940 NULL
99705 +irq_dispose_mapping_51941 irq_dispose_mapping 1 51941 NULL
99706 +scsi_get_vpd_page_51951 scsi_get_vpd_page 4 51951 NULL
99707 +arizona_free_irq_51969 arizona_free_irq 2 51969 NULL nohasharray
99708 +snd_mask_min_51969 snd_mask_min 0 51969 &arizona_free_irq_51969
99709 +ath6kl_sdio_alloc_prep_scat_req_51986 ath6kl_sdio_alloc_prep_scat_req 2 51986 NULL
99710 +skb_copy_datagram_from_iovec_52014 skb_copy_datagram_from_iovec 4-2-5 52014 NULL
99711 +rdmalt_52022 rdmalt 0 52022 NULL
99712 +vxge_rx_alloc_52024 vxge_rx_alloc 3 52024 NULL
99713 +override_release_52032 override_release 2 52032 NULL
99714 +end_port_52042 end_port 0 52042 NULL
99715 +dma_rx_errors_read_52045 dma_rx_errors_read 3 52045 NULL
99716 +msnd_fifo_write_52052 msnd_fifo_write 0-3 52052 NULL
99717 +dvb_ringbuffer_avail_52057 dvb_ringbuffer_avail 0 52057 NULL
99718 +__fuse_request_alloc_52060 __fuse_request_alloc 1 52060 NULL
99719 +isofs_readpages_52067 isofs_readpages 4 52067 NULL
99720 +nsm_get_handle_52089 nsm_get_handle 4 52089 NULL
99721 +o2net_debug_read_52105 o2net_debug_read 3 52105 NULL
99722 +retry_count_read_52129 retry_count_read 3 52129 NULL
99723 +zram_meta_alloc_52140 zram_meta_alloc 1 52140 NULL
99724 +hysdn_conf_write_52145 hysdn_conf_write 3 52145 NULL nohasharray
99725 +ext2_alloc_blocks_52145 ext2_alloc_blocks 2 52145 &hysdn_conf_write_52145
99726 +htable_size_52148 htable_size 0-1 52148 NULL
99727 +__le16_to_cpup_52155 __le16_to_cpup 0 52155 NULL nohasharray
99728 +smk_write_load2_52155 smk_write_load2 3 52155 &__le16_to_cpup_52155
99729 +alix_present_52165 alix_present 1 52165 NULL
99730 +ieee80211_if_read_dot11MeshRetryTimeout_52168 ieee80211_if_read_dot11MeshRetryTimeout 3 52168 NULL
99731 +mga_compat_ioctl_52170 mga_compat_ioctl 2 52170 NULL
99732 +print_prefix_52176 print_prefix 0 52176 NULL
99733 +proc_pid_readlink_52186 proc_pid_readlink 3 52186 NULL
99734 +vmci_qp_broker_alloc_52216 vmci_qp_broker_alloc 5-6 52216 NULL
99735 +do_dmabuf_dirty_ldu_52241 do_dmabuf_dirty_ldu 6 52241 NULL
99736 +fuse_request_alloc_52243 fuse_request_alloc 1 52243 NULL
99737 +pm80x_request_irq_52250 pm80x_request_irq 2 52250 NULL
99738 +mdiobus_alloc_size_52259 mdiobus_alloc_size 1 52259 NULL
99739 +shrink_slab_52261 shrink_slab 2-3 52261 NULL
99740 +hva_to_pfn_slow_52262 hva_to_pfn_slow 1 52262 NULL
99741 +sisusbcon_do_font_op_52271 sisusbcon_do_font_op 9 52271 NULL
99742 +ath6kl_wmi_get_new_buf_52304 ath6kl_wmi_get_new_buf 1 52304 NULL
99743 +read_file_reset_52310 read_file_reset 3 52310 NULL
99744 +request_asymmetric_key_52317 request_asymmetric_key 2-4 52317 NULL
99745 +hwflags_read_52318 hwflags_read 3 52318 NULL
99746 +ntfs_rl_split_52328 ntfs_rl_split 2-4 52328 NULL
99747 +test_unaligned_bulk_52333 test_unaligned_bulk 3 52333 NULL
99748 +bytes_to_frames_52362 bytes_to_frames 0-2 52362 NULL
99749 +copy_entries_to_user_52367 copy_entries_to_user 1 52367 NULL
99750 +mq_emit_config_values_52378 mq_emit_config_values 3 52378 NULL
99751 +isdn_writebuf_stub_52383 isdn_writebuf_stub 4 52383 NULL
99752 +jfs_setxattr_52389 jfs_setxattr 4 52389 NULL
99753 +aer_inject_write_52399 aer_inject_write 3 52399 NULL
99754 +aac_rx_ioremap_52410 aac_rx_ioremap 2 52410 NULL
99755 +cgroup_file_write_52417 cgroup_file_write 3 52417 NULL
99756 +line6_midibuf_init_52425 line6_midibuf_init 2 52425 NULL
99757 +delay_status_52431 delay_status 5 52431 NULL
99758 +ieee80211_if_fmt_num_sta_ps_52438 ieee80211_if_fmt_num_sta_ps 3 52438 NULL
99759 +nl80211_send_mgmt_tx_status_52445 nl80211_send_mgmt_tx_status 5 52445 NULL
99760 +ieee80211_alloc_txb_52477 ieee80211_alloc_txb 1-2 52477 NULL
99761 +ocfs2_extend_no_holes_52483 ocfs2_extend_no_holes 3-4 52483 NULL
99762 +fd_do_rw_52495 fd_do_rw 3 52495 NULL nohasharray
99763 +skb_cow_head_52495 skb_cow_head 2 52495 &fd_do_rw_52495
99764 +qib_user_sdma_pin_pages_52498 qib_user_sdma_pin_pages 3-5 52498 NULL
99765 +int_tasklet_entry_52500 int_tasklet_entry 3 52500 NULL
99766 +pm_qos_power_write_52513 pm_qos_power_write 3 52513 NULL
99767 +dup_variable_bug_52525 dup_variable_bug 3 52525 NULL
99768 +from_oblock_52546 from_oblock 0-1 52546 NULL
99769 +dccpprobe_read_52549 dccpprobe_read 3 52549 NULL
99770 +ocfs2_make_right_split_rec_52562 ocfs2_make_right_split_rec 3 52562 NULL
99771 +emit_code_52583 emit_code 0-3 52583 NULL
99772 +tps80031_writes_52638 tps80031_writes 3-4 52638 NULL
99773 +brcmf_sdio_assert_info_52653 brcmf_sdio_assert_info 4 52653 NULL
99774 +nvd0_disp_pioc_create__52693 nvd0_disp_pioc_create_ 5 52693 NULL
99775 +nouveau_client_create__52715 nouveau_client_create_ 5 52715 NULL
99776 +cx25840_ir_rx_read_52724 cx25840_ir_rx_read 3 52724 NULL
99777 +blkcipher_next_slow_52733 blkcipher_next_slow 3-4 52733 NULL
99778 +relay_alloc_page_array_52735 relay_alloc_page_array 1 52735 NULL
99779 +carl9170_debugfs_vif_dump_read_52755 carl9170_debugfs_vif_dump_read 3 52755 NULL
99780 +copy_ctr_args_52761 copy_ctr_args 2 52761 NULL
99781 +pwr_rcvd_beacons_read_52836 pwr_rcvd_beacons_read 3 52836 NULL
99782 +ext2_xattr_set_acl_52857 ext2_xattr_set_acl 4 52857 NULL
99783 +mon_bin_get_event_52863 mon_bin_get_event 4 52863 NULL
99784 +twlreg_write_52880 twlreg_write 3 52880 NULL
99785 +pvr2_ctrl_value_to_sym_internal_52881 pvr2_ctrl_value_to_sym_internal 5 52881 NULL
99786 +cache_read_procfs_52882 cache_read_procfs 3 52882 NULL
99787 +kvm_kvzalloc_52894 kvm_kvzalloc 1 52894 NULL
99788 +arizona_request_irq_52908 arizona_request_irq 2 52908 NULL
99789 +__kfifo_out_peek_r_52919 __kfifo_out_peek_r 3 52919 NULL
99790 +iblock_get_bio_52936 iblock_get_bio 3 52936 NULL nohasharray
99791 +__iio_device_attr_init_52936 __iio_device_attr_init 0 52936 &iblock_get_bio_52936
99792 +__nodes_remap_52951 __nodes_remap 5 52951 NULL
99793 +send_packet_52960 send_packet 4 52960 NULL
99794 +ieee80211_if_fmt_fwded_mcast_52961 ieee80211_if_fmt_fwded_mcast 3 52961 NULL
99795 +hx8357_spi_write_then_read_52964 hx8357_spi_write_then_read 3 52964 NULL nohasharray
99796 +compat_sock_ioctl_52964 compat_sock_ioctl 3 52964 &hx8357_spi_write_then_read_52964
99797 +tx_tx_exch_read_52986 tx_tx_exch_read 3 52986 NULL
99798 +num_node_state_52989 num_node_state 0 52989 NULL
99799 +batadv_check_management_packet_52993 batadv_check_management_packet 3 52993 NULL
99800 +efivarfs_file_write_53000 efivarfs_file_write 3 53000 NULL
99801 +btrfs_free_and_pin_reserved_extent_53016 btrfs_free_and_pin_reserved_extent 2 53016 NULL
99802 +tx_tx_exch_pending_read_53018 tx_tx_exch_pending_read 3 53018 NULL
99803 +ext4_meta_bg_first_group_53031 ext4_meta_bg_first_group 0-2 53031 NULL
99804 +bio_cur_bytes_53037 bio_cur_bytes 0 53037 NULL
99805 +regcache_lzo_block_count_53056 regcache_lzo_block_count 0 53056 NULL
99806 +cfi_read_query_53066 cfi_read_query 0 53066 NULL
99807 +mwifiex_debug_read_53074 mwifiex_debug_read 3 53074 NULL
99808 +qib_resize_cq_53090 qib_resize_cq 2 53090 NULL
99809 +verity_status_53120 verity_status 5 53120 NULL
99810 +brcmf_usb_dl_cmd_53130 brcmf_usb_dl_cmd 4 53130 NULL
99811 +ps_poll_ps_poll_max_ap_turn_read_53140 ps_poll_ps_poll_max_ap_turn_read 3 53140 NULL
99812 +ieee80211_bss_info_update_53170 ieee80211_bss_info_update 4 53170 NULL
99813 +clear_capture_buf_53192 clear_capture_buf 2 53192 NULL
99814 +mtdoops_erase_block_53206 mtdoops_erase_block 2 53206 NULL
99815 +fixup_user_fault_53210 fixup_user_fault 3 53210 NULL
99816 +tx_tx_start_data_read_53219 tx_tx_start_data_read 3 53219 NULL
99817 +rbd_obj_method_sync_53252 rbd_obj_method_sync 8 53252 NULL
99818 +xfs_trans_read_buf_map_53258 xfs_trans_read_buf_map 5 53258 NULL
99819 +wil_write_file_ssid_53266 wil_write_file_ssid 3 53266 NULL
99820 +btrfs_file_extent_num_bytes_53269 btrfs_file_extent_num_bytes 0 53269 NULL
99821 +batadv_interface_rx_53325 batadv_interface_rx 4 53325 NULL
99822 +gsm_control_reply_53333 gsm_control_reply 4 53333 NULL
99823 +vm_mmap_53339 vm_mmap 0 53339 NULL
99824 +sock_setbindtodevice_53369 sock_setbindtodevice 3 53369 NULL
99825 +get_random_bytes_arch_53370 get_random_bytes_arch 2 53370 NULL
99826 +iwl_pcie_txq_alloc_53413 iwl_pcie_txq_alloc 3 53413 NULL
99827 +isr_cmd_cmplt_read_53439 isr_cmd_cmplt_read 3 53439 NULL
99828 +mwifiex_info_read_53447 mwifiex_info_read 3 53447 NULL
99829 +apei_exec_run_optional_53452 apei_exec_run_optional 0 53452 NULL
99830 +acpi_tb_parse_root_table_53455 acpi_tb_parse_root_table 1 53455 NULL
99831 +n2_run_53459 n2_run 3 53459 NULL
99832 +paging64_prefetch_gpte_53468 paging64_prefetch_gpte 4 53468 NULL
99833 +rds_tcp_data_recv_53476 rds_tcp_data_recv 3 53476 NULL
99834 +iowarrior_read_53483 iowarrior_read 3 53483 NULL
99835 +osd_req_write_kern_53486 osd_req_write_kern 5 53486 NULL
99836 +do_verify_xattr_datum_53499 do_verify_xattr_datum 0 53499 NULL
99837 +snd_pcm_format_physical_width_53505 snd_pcm_format_physical_width 0 53505 NULL
99838 +dbAllocNext_53506 dbAllocNext 0 53506 NULL
99839 +ocfs2_xattr_set_acl_53508 ocfs2_xattr_set_acl 4 53508 NULL
99840 +check_acl_53512 check_acl 0 53512 NULL
99841 +alloc_pages_exact_nid_53515 alloc_pages_exact_nid 2 53515 NULL
99842 +set_registers_53582 set_registers 3 53582 NULL
99843 +cifs_utf16_bytes_53593 cifs_utf16_bytes 0 53593 NULL
99844 +gfn_to_pfn_async_53597 gfn_to_pfn_async 2 53597 NULL
99845 +___alloc_bootmem_nopanic_53626 ___alloc_bootmem_nopanic 1-2 53626 NULL
99846 +xd_write_multiple_pages_53633 xd_write_multiple_pages 6-5 53633 NULL
99847 +ccid_getsockopt_builtin_ccids_53634 ccid_getsockopt_builtin_ccids 2 53634 NULL
99848 +nr_sendmsg_53656 nr_sendmsg 4 53656 NULL
99849 +_preload_range_53676 _preload_range 2-3 53676 NULL
99850 +fuse_fill_write_pages_53682 fuse_fill_write_pages 4 53682 NULL
99851 +v4l2_event_subscribe_53687 v4l2_event_subscribe 3 53687 NULL
99852 +bdev_logical_block_size_53690 bdev_logical_block_size 0 53690 NULL nohasharray
99853 +igb_alloc_q_vector_53690 igb_alloc_q_vector 4-6 53690 &bdev_logical_block_size_53690
99854 +find_overflow_devnum_53711 find_overflow_devnum 0 53711 NULL
99855 +bio_integrity_split_53714 bio_integrity_split 3 53714 NULL
99856 +__ocfs2_resv_find_window_53721 __ocfs2_resv_find_window 3 53721 NULL
99857 +wdm_write_53735 wdm_write 3 53735 NULL
99858 +ext3_try_to_allocate_with_rsv_53737 ext3_try_to_allocate_with_rsv 5-3 53737 NULL
99859 +da9052_disable_irq_53745 da9052_disable_irq 2 53745 NULL
99860 +lpfc_idiag_queacc_read_qe_53755 lpfc_idiag_queacc_read_qe 0-2 53755 NULL nohasharray
99861 +amdtp_out_stream_get_max_payload_53755 amdtp_out_stream_get_max_payload 0 53755 &lpfc_idiag_queacc_read_qe_53755
99862 +ext2_acl_count_53773 ext2_acl_count 0-1 53773 NULL
99863 +__kfifo_dma_in_prepare_r_53792 __kfifo_dma_in_prepare_r 4-5 53792 NULL
99864 +qp_alloc_host_work_53798 qp_alloc_host_work 3-5 53798 NULL
99865 +__tty_alloc_driver_53799 __tty_alloc_driver 1 53799 NULL
99866 +regmap_raw_write_53803 regmap_raw_write 2-4 53803 NULL
99867 +lpfc_idiag_ctlacc_read_reg_53809 lpfc_idiag_ctlacc_read_reg 0-3 53809 NULL
99868 +nls_nullsize_53815 nls_nullsize 0 53815 NULL
99869 +pms_read_53873 pms_read 3 53873 NULL
99870 +ieee80211_if_fmt_dropped_frames_congestion_53883 ieee80211_if_fmt_dropped_frames_congestion 3 53883 NULL
99871 +ocfs2_rm_xattr_cluster_53900 ocfs2_rm_xattr_cluster 5-4-3 53900 NULL
99872 +proc_file_read_53905 proc_file_read 3 53905 NULL
99873 +early_reserve_e820_53915 early_reserve_e820 1-2 53915 NULL
99874 +ocfs2_make_clusters_writable_53938 ocfs2_make_clusters_writable 4 53938 NULL
99875 +mthca_setup_cmd_doorbells_53954 mthca_setup_cmd_doorbells 2 53954 NULL
99876 +mlx4_num_eq_uar_53965 mlx4_num_eq_uar 0 53965 NULL
99877 +idetape_chrdev_write_53976 idetape_chrdev_write 3 53976 NULL
99878 +mthca_reg_user_mr_53980 mthca_reg_user_mr 2-3 53980 NULL
99879 +__ocfs2_xattr_set_value_outside_53981 __ocfs2_xattr_set_value_outside 5 53981 NULL
99880 +ieee80211_if_fmt_dot11MeshHWMPperrMinInterval_53998 ieee80211_if_fmt_dot11MeshHWMPperrMinInterval 3 53998 NULL
99881 +snd_pcm_lib_write_transfer_54018 snd_pcm_lib_write_transfer 4-2-5 54018 NULL
99882 +cmpk_message_handle_tx_54024 cmpk_message_handle_tx 4 54024 NULL
99883 +ipxrtr_route_packet_54036 ipxrtr_route_packet 4 54036 NULL
99884 +pipeline_dec_packet_out_read_54052 pipeline_dec_packet_out_read 3 54052 NULL
99885 +nl80211_send_disconnected_54056 nl80211_send_disconnected 5 54056 NULL
99886 +rproc_state_read_54057 rproc_state_read 3 54057 NULL
99887 +_malloc_54077 _malloc 1 54077 NULL
99888 +bitmap_bitremap_54096 bitmap_bitremap 4 54096 NULL
99889 +altera_set_ir_pre_54103 altera_set_ir_pre 2 54103 NULL
99890 +create_xattr_54106 create_xattr 5 54106 NULL
99891 +strn_len_54122 strn_len 0 54122 NULL
99892 +isku_receive_54130 isku_receive 4 54130 NULL
99893 +isr_host_acknowledges_read_54136 isr_host_acknowledges_read 3 54136 NULL
99894 +i2400m_zrealloc_2x_54166 i2400m_zrealloc_2x 3 54166 NULL nohasharray
99895 +memcpy_toiovec_54166 memcpy_toiovec 3 54166 &i2400m_zrealloc_2x_54166
99896 +nouveau_falcon_create__54169 nouveau_falcon_create_ 8 54169 NULL
99897 +acpi_os_read_memory_54186 acpi_os_read_memory 1-3 54186 NULL
99898 +__register_chrdev_54223 __register_chrdev 2-3 54223 NULL
99899 +_format_mac_addr_54229 _format_mac_addr 2-0 54229 NULL
99900 +pi_read_regr_54231 pi_read_regr 0 54231 NULL
99901 +reada_add_block_54247 reada_add_block 2 54247 NULL
99902 +xfs_dir2_sf_addname_hard_54254 xfs_dir2_sf_addname_hard 3 54254 NULL
99903 +ceph_msgpool_get_54258 ceph_msgpool_get 2 54258 NULL
99904 +wusb_prf_54261 wusb_prf 7 54261 NULL nohasharray
99905 +audio_write_54261 audio_write 4 54261 &wusb_prf_54261
99906 +mwifiex_getlog_read_54269 mwifiex_getlog_read 3 54269 NULL
99907 +ubi_calc_data_len_54279 ubi_calc_data_len 0-3 54279 NULL
99908 +altera_set_dr_post_54291 altera_set_dr_post 2 54291 NULL
99909 +dlm_alloc_pagevec_54296 dlm_alloc_pagevec 1 54296 NULL
99910 +get_iovec_page_array_54298 get_iovec_page_array 6 54298 NULL
99911 +sprintf_54306 sprintf 0 54306 NULL
99912 +irq_domain_associate_many_54307 irq_domain_associate_many 2 54307 NULL
99913 +br_fdb_fillbuf_54339 br_fdb_fillbuf 0 54339 NULL
99914 +__alloc_dev_table_54343 __alloc_dev_table 2 54343 NULL
99915 +__get_free_pages_54352 __get_free_pages 0 54352 NULL nohasharray
99916 +_osd_realloc_seg_54352 _osd_realloc_seg 3 54352 &__get_free_pages_54352
99917 +tcf_hash_create_54360 tcf_hash_create 4 54360 NULL
99918 +read_file_credit_dist_stats_54367 read_file_credit_dist_stats 3 54367 NULL
99919 +vfs_readlink_54368 vfs_readlink 3 54368 NULL
99920 +do_dccp_setsockopt_54377 do_dccp_setsockopt 5 54377 NULL nohasharray
99921 +intel_sdvo_write_cmd_54377 intel_sdvo_write_cmd 4 54377 &do_dccp_setsockopt_54377
99922 +ah_alloc_tmp_54378 ah_alloc_tmp 3-2 54378 NULL
99923 +gart_unmap_page_54379 gart_unmap_page 2-3 54379 NULL
99924 +snd_pcm_oss_read2_54387 snd_pcm_oss_read2 0-3 54387 NULL
99925 +i386_mmap_check_54388 i386_mmap_check 0 54388 NULL
99926 +__do_krealloc_54389 __do_krealloc 2 54389 NULL
99927 +iwl_dbgfs_power_save_status_read_54392 iwl_dbgfs_power_save_status_read 3 54392 NULL
99928 +copy_gadget_strings_54417 copy_gadget_strings 2-3 54417 NULL
99929 +swiotlb_tbl_sync_single_54486 swiotlb_tbl_sync_single 2 54486 NULL
99930 +simple_strtoull_54493 simple_strtoull 0 54493 NULL
99931 +swiotlb_tbl_map_single_54495 swiotlb_tbl_map_single 3-0 54495 NULL
99932 +btrfs_ordered_sum_size_54509 btrfs_ordered_sum_size 0-2 54509 NULL
99933 +cgroup_write_X64_54514 cgroup_write_X64 5 54514 NULL nohasharray
99934 +xen_bus_to_phys_54514 xen_bus_to_phys 0 54514 &cgroup_write_X64_54514
99935 +rfc4106_set_key_54519 rfc4106_set_key 3 54519 NULL
99936 +vmci_transport_dgram_enqueue_54525 vmci_transport_dgram_enqueue 4 54525 NULL
99937 +viacam_read_54526 viacam_read 3 54526 NULL
99938 +unix_dgram_connect_54535 unix_dgram_connect 3 54535 NULL
99939 +setsockopt_54539 setsockopt 5 54539 NULL
99940 +mwifiex_usb_submit_rx_urb_54558 mwifiex_usb_submit_rx_urb 2 54558 NULL
99941 +nfsd_vfs_write_54577 nfsd_vfs_write 6 54577 NULL
99942 +fw_iso_buffer_init_54582 fw_iso_buffer_init 3 54582 NULL
99943 +nvme_npages_54601 nvme_npages 0-1 54601 NULL
99944 +fwSendNullPacket_54618 fwSendNullPacket 2 54618 NULL
99945 +irq_timeout_read_54653 irq_timeout_read 3 54653 NULL
99946 +dns_resolver_read_54658 dns_resolver_read 3 54658 NULL
99947 +twl6030_interrupt_mask_54659 twl6030_interrupt_mask 2 54659 NULL
99948 +kvm_read_cr3_54662 kvm_read_cr3 0 54662 NULL
99949 +bio_kmalloc_54672 bio_kmalloc 2 54672 NULL
99950 +vring_new_virtqueue_54673 vring_new_virtqueue 2 54673 NULL
99951 +evm_read_key_54674 evm_read_key 3 54674 NULL
99952 +resource_string_54699 resource_string 0 54699 NULL
99953 +platform_get_irq_byname_54700 platform_get_irq_byname 0 54700 NULL
99954 +rfkill_fop_read_54711 rfkill_fop_read 3 54711 NULL
99955 +_add_sg_continuation_descriptor_54721 _add_sg_continuation_descriptor 3 54721 NULL
99956 +ocfs2_control_write_54737 ocfs2_control_write 3 54737 NULL
99957 +kzalloc_54740 kzalloc 1 54740 NULL
99958 +wep_iv_read_54744 wep_iv_read 3 54744 NULL
99959 +iio_event_chrdev_read_54757 iio_event_chrdev_read 3 54757 NULL
99960 +batadv_iv_ogm_aggregate_new_54761 batadv_iv_ogm_aggregate_new 2 54761 NULL
99961 +adis16480_show_firmware_date_54762 adis16480_show_firmware_date 3 54762 NULL
99962 +flexcop_device_kmalloc_54793 flexcop_device_kmalloc 1 54793 NULL
99963 +domain_init_54797 domain_init 2 54797 NULL
99964 +ext3_find_goal_54801 ext3_find_goal 0 54801 NULL
99965 +get_dev_size_54807 get_dev_size 0 54807 NULL
99966 +nfsd_write_54809 nfsd_write 6 54809 NULL
99967 +aes_decrypt_fail_read_54815 aes_decrypt_fail_read 3 54815 NULL nohasharray
99968 +crypto_tfm_ctx_alignment_54815 crypto_tfm_ctx_alignment 0 54815 &aes_decrypt_fail_read_54815
99969 +generic_perform_write_54832 generic_perform_write 3 54832 NULL
99970 +write_rio_54837 write_rio 3 54837 NULL
99971 +nouveau_engctx_create__54839 nouveau_engctx_create_ 8 54839 NULL nohasharray
99972 +ext3_acl_from_disk_54839 ext3_acl_from_disk 2 54839 &nouveau_engctx_create__54839
99973 +ufx_ops_write_54848 ufx_ops_write 3 54848 NULL
99974 +printer_read_54851 printer_read 3 54851 NULL
99975 +qib_reg_user_mr_54858 qib_reg_user_mr 2-3 54858 NULL
99976 +alloc_ep_req_54860 alloc_ep_req 2 54860 NULL
99977 +broadsheet_spiflash_rewrite_sector_54864 broadsheet_spiflash_rewrite_sector 2 54864 NULL
99978 +prism_build_supp_rates_54865 prism_build_supp_rates 0 54865 NULL
99979 +tcf_csum_ipv6_tcp_54877 tcf_csum_ipv6_tcp 4 54877 NULL
99980 +iscsi_pool_init_54913 iscsi_pool_init 2-4 54913 NULL
99981 +btrfs_stack_chunk_num_stripes_54923 btrfs_stack_chunk_num_stripes 0 54923 NULL
99982 +mxms_structlen_54939 mxms_structlen 0 54939 NULL
99983 +add_port_54941 add_port 2 54941 NULL
99984 +virtblk_add_buf_wait_54943 virtblk_add_buf_wait 3-4 54943 NULL
99985 +wl12xx_cmd_build_probe_req_54946 wl12xx_cmd_build_probe_req 6-8 54946 NULL
99986 +ath9k_dump_btcoex_54949 ath9k_dump_btcoex 0 54949 NULL
99987 +c4_add_card_54968 c4_add_card 3 54968 NULL
99988 +iwl_pcie_dump_fh_54975 iwl_pcie_dump_fh 0 54975 NULL
99989 +__proc_file_read_54978 __proc_file_read 3 54978 NULL
99990 +ext3_xattr_get_54989 ext3_xattr_get 0 54989 NULL
99991 +Bus_to_Virtual_54991 Bus_to_Virtual 1 54991 NULL
99992 +cx231xx_v4l2_read_55014 cx231xx_v4l2_read 3 55014 NULL
99993 +paging32_get_level1_sp_gpa_55022 paging32_get_level1_sp_gpa 0 55022 NULL
99994 +error_error_null_Frame_tx_start_read_55024 error_error_null_Frame_tx_start_read 3 55024 NULL
99995 +__netdev_alloc_skb_ip_align_55067 __netdev_alloc_skb_ip_align 2 55067 NULL
99996 +apei_exec_run_55075 apei_exec_run 0 55075 NULL
99997 +bitmap_storage_alloc_55077 bitmap_storage_alloc 2 55077 NULL
99998 +hx8357_spi_write_array_55095 hx8357_spi_write_array 3 55095 NULL
99999 +rxpipe_beacon_buffer_thres_host_int_trig_rx_data_read_55106 rxpipe_beacon_buffer_thres_host_int_trig_rx_data_read 3 55106 NULL
100000 +corrupt_data_55120 corrupt_data 0 55120 NULL
100001 +crypto_ahash_setkey_55134 crypto_ahash_setkey 3 55134 NULL
100002 +ocfs2_prepare_refcount_change_for_del_55137 ocfs2_prepare_refcount_change_for_del 3 55137 NULL nohasharray
100003 +filldir_55137 filldir 3 55137 &ocfs2_prepare_refcount_change_for_del_55137
100004 +ocfs2_truncate_file_55148 ocfs2_truncate_file 3 55148 NULL
100005 +ieee80211_if_read_uapsd_queues_55150 ieee80211_if_read_uapsd_queues 3 55150 NULL
100006 +mtd_get_fact_prot_info_55186 mtd_get_fact_prot_info 0 55186 NULL
100007 +sel_write_relabel_55195 sel_write_relabel 3 55195 NULL
100008 +sched_feat_write_55202 sched_feat_write 3 55202 NULL
100009 +ht40allow_map_read_55209 ht40allow_map_read 3 55209 NULL
100010 +__kfifo_dma_out_prepare_r_55211 __kfifo_dma_out_prepare_r 4-5 55211 NULL
100011 +do_raw_setsockopt_55215 do_raw_setsockopt 5 55215 NULL
100012 +dump_command_55220 dump_command 1 55220 NULL
100013 +dbAllocDmap_55227 dbAllocDmap 0 55227 NULL
100014 +tipc_port_reject_sections_55229 tipc_port_reject_sections 5 55229 NULL
100015 +register_unifi_sdio_55239 register_unifi_sdio 2 55239 NULL
100016 +memcpy_fromiovec_55247 memcpy_fromiovec 3 55247 NULL
100017 +ptrace_request_55288 ptrace_request 3 55288 NULL
100018 +rx_streaming_interval_read_55291 rx_streaming_interval_read 3 55291 NULL
100019 +gsm_control_modem_55303 gsm_control_modem 3 55303 NULL
100020 +qp_alloc_guest_work_55305 qp_alloc_guest_work 3-5 55305 NULL nohasharray
100021 +__get_vm_area_node_55305 __get_vm_area_node 1 55305 &qp_alloc_guest_work_55305
100022 +do_shmat_55336 do_shmat 5 55336 NULL
100023 +vme_user_read_55338 vme_user_read 3 55338 NULL
100024 +sctp_datamsg_from_user_55342 sctp_datamsg_from_user 4 55342 NULL nohasharray
100025 +__wa_xfer_setup_sizes_55342 __wa_xfer_setup_sizes 0 55342 &sctp_datamsg_from_user_55342
100026 +__memblock_alloc_base_55359 __memblock_alloc_base 1-2 55359 NULL
100027 +acpi_system_read_event_55362 acpi_system_read_event 3 55362 NULL
100028 +nf_nat_ipv4_manip_pkt_55387 nf_nat_ipv4_manip_pkt 2 55387 NULL
100029 +iwl_dbgfs_plcp_delta_read_55407 iwl_dbgfs_plcp_delta_read 3 55407 NULL
100030 +alloc_skb_55439 alloc_skb 1 55439 NULL
100031 +__vxge_hw_channel_allocate_55462 __vxge_hw_channel_allocate 3 55462 NULL
100032 +isdnhdlc_decode_55466 isdnhdlc_decode 0 55466 NULL
100033 +cx23888_ir_rx_read_55473 cx23888_ir_rx_read 3 55473 NULL
100034 +batadv_unicast_push_and_fill_skb_55474 batadv_unicast_push_and_fill_skb 2 55474 NULL
100035 +snd_pcm_lib_write_55483 snd_pcm_lib_write 0-3 55483 NULL
100036 +i2o_pool_alloc_55485 i2o_pool_alloc 4 55485 NULL
100037 +ocfs2_rec_clusters_55501 ocfs2_rec_clusters 0 55501 NULL
100038 +ext4_flex_bg_size_55502 ext4_flex_bg_size 0 55502 NULL
100039 +cfpkt_pad_trail_55511 cfpkt_pad_trail 2 55511 NULL nohasharray
100040 +tx_tx_done_int_template_read_55511 tx_tx_done_int_template_read 3 55511 &cfpkt_pad_trail_55511
100041 +ea_get_55522 ea_get 0 55522 NULL
100042 +buffer_size_55534 buffer_size 0 55534 NULL
100043 +set_msr_interception_55538 set_msr_interception 2 55538 NULL
100044 +tty_port_register_device_55543 tty_port_register_device 3 55543 NULL
100045 +add_partition_55588 add_partition 2 55588 NULL
100046 +free_pages_55603 free_pages 1 55603 NULL
100047 +macvtap_put_user_55609 macvtap_put_user 4 55609 NULL
100048 +selinux_setprocattr_55611 selinux_setprocattr 4 55611 NULL
100049 +edge_tty_recv_55622 edge_tty_recv 3 55622 NULL
100050 +reiserfs_xattr_get_55628 reiserfs_xattr_get 0 55628 NULL nohasharray
100051 +pktgen_if_write_55628 pktgen_if_write 3 55628 &reiserfs_xattr_get_55628
100052 +dvb_dmxdev_set_buffer_size_55643 dvb_dmxdev_set_buffer_size 2 55643 NULL
100053 +mlx4_buddy_alloc_55647 mlx4_buddy_alloc 2 55647 NULL
100054 +xfs_bmbt_maxrecs_55649 xfs_bmbt_maxrecs 0-2 55649 NULL
100055 +ib_umad_compat_ioctl_55650 ib_umad_compat_ioctl 3 55650 NULL
100056 +cfg80211_send_rx_assoc_55651 cfg80211_send_rx_assoc 4 55651 NULL
100057 +read_oldmem_55658 read_oldmem 3 55658 NULL
100058 +lpfc_idiag_queinfo_read_55662 lpfc_idiag_queinfo_read 3 55662 NULL
100059 +il_dbgfs_tx_queue_read_55668 il_dbgfs_tx_queue_read 3 55668 NULL
100060 +get_info_55681 get_info 3 55681 NULL
100061 +wil_vring_alloc_skb_55703 wil_vring_alloc_skb 4 55703 NULL
100062 +__videobuf_alloc_uncached_55711 __videobuf_alloc_uncached 1 55711 NULL
100063 +pm8001_store_update_fw_55716 pm8001_store_update_fw 4 55716 NULL
100064 +mtdswap_init_55719 mtdswap_init 2 55719 NULL
100065 +__iio_allocate_kfifo_55738 __iio_allocate_kfifo 2 55738 NULL
100066 +set_local_name_55757 set_local_name 4 55757 NULL
100067 +strlen_55778 strlen 0 55778 NULL
100068 +set_spte_55783 set_spte 5-4 55783 NULL
100069 +req_bio_endio_55786 req_bio_endio 3 55786 NULL nohasharray
100070 +conf_read_55786 conf_read 3 55786 &req_bio_endio_55786
100071 +uwb_rc_neh_grok_event_55799 uwb_rc_neh_grok_event 3 55799 NULL
100072 +sb16_copy_from_user_55836 sb16_copy_from_user 10-6-7 55836 NULL
100073 +ip_hdrlen_55849 ip_hdrlen 0 55849 NULL
100074 +hcd_alloc_coherent_55862 hcd_alloc_coherent 5 55862 NULL
100075 +shmem_setxattr_55867 shmem_setxattr 4 55867 NULL
100076 +hsc_write_55875 hsc_write 3 55875 NULL
100077 +pm_qos_power_read_55891 pm_qos_power_read 3 55891 NULL
100078 +snd_pcm_hw_param_value_min_55917 snd_pcm_hw_param_value_min 0 55917 NULL
100079 +paging64_page_fault_55942 paging64_page_fault 2 55942 NULL
100080 +sel_read_policy_55947 sel_read_policy 3 55947 NULL
100081 +ceph_get_direct_page_vector_55956 ceph_get_direct_page_vector 2 55956 NULL
100082 +simple_read_from_buffer_55957 simple_read_from_buffer 2-5 55957 NULL
100083 +tx_tx_imm_resp_read_55964 tx_tx_imm_resp_read 3 55964 NULL
100084 +ssb_bus_pcmciabus_register_56020 ssb_bus_pcmciabus_register 3 56020 NULL
100085 +nvme_alloc_iod_56027 nvme_alloc_iod 1-2 56027 NULL
100086 +dccp_sendmsg_56058 dccp_sendmsg 4 56058 NULL
100087 +__set_discard_56081 __set_discard 2 56081 NULL
100088 +pscsi_get_bio_56103 pscsi_get_bio 1 56103 NULL
100089 +usb_alloc_stream_buffers_56123 usb_alloc_stream_buffers 3 56123 NULL
100090 +kmem_zalloc_large_56128 kmem_zalloc_large 1 56128 NULL
100091 +sel_read_handle_status_56139 sel_read_handle_status 3 56139 NULL
100092 +map_addr_56144 map_addr 7 56144 NULL
100093 +rawv6_setsockopt_56165 rawv6_setsockopt 5 56165 NULL
100094 +create_irq_nr_56180 create_irq_nr 1 56180 NULL
100095 +ath9k_dump_legacy_btcoex_56194 ath9k_dump_legacy_btcoex 0 56194 NULL
100096 +skb_headroom_56200 skb_headroom 0 56200 NULL
100097 +usb_dump_iad_descriptor_56204 usb_dump_iad_descriptor 0 56204 NULL
100098 +ncp_read_bounce_size_56221 ncp_read_bounce_size 0-1 56221 NULL
100099 +ocfs2_find_xe_in_bucket_56224 ocfs2_find_xe_in_bucket 0 56224 NULL
100100 +cp210x_get_config_56229 cp210x_get_config 4 56229 NULL
100101 +do_ipt_set_ctl_56238 do_ipt_set_ctl 4 56238 NULL
100102 +fd_copyin_56247 fd_copyin 3 56247 NULL
100103 +sk_rmem_schedule_56255 sk_rmem_schedule 3 56255 NULL
100104 +il4965_ucode_general_stats_read_56277 il4965_ucode_general_stats_read 3 56277 NULL
100105 +ieee80211_if_fmt_user_power_level_56283 ieee80211_if_fmt_user_power_level 3 56283 NULL
100106 +RESIZE_IF_NEEDED_56286 RESIZE_IF_NEEDED 2 56286 NULL
100107 +dvb_aplay_56296 dvb_aplay 3 56296 NULL
100108 +btmrvl_hscfgcmd_read_56303 btmrvl_hscfgcmd_read 3 56303 NULL
100109 +compat_cdrom_read_audio_56304 compat_cdrom_read_audio 4 56304 NULL
100110 +pipeline_pre_to_defrag_swi_read_56321 pipeline_pre_to_defrag_swi_read 3 56321 NULL
100111 +journal_init_revoke_table_56331 journal_init_revoke_table 1 56331 NULL
100112 +snd_rawmidi_read_56337 snd_rawmidi_read 3 56337 NULL
100113 +sixpack_compat_ioctl_56346 sixpack_compat_ioctl 4 56346 NULL
100114 +vxge_os_dma_malloc_async_56348 vxge_os_dma_malloc_async 3 56348 NULL
100115 +iov_iter_copy_from_user_atomic_56368 iov_iter_copy_from_user_atomic 4 56368 NULL
100116 +dev_read_56369 dev_read 3 56369 NULL
100117 +ocfs2_control_read_56405 ocfs2_control_read 3 56405 NULL
100118 +__get_vm_area_caller_56416 __get_vm_area_caller 1 56416 NULL nohasharray
100119 +acpi_os_write_memory_56416 acpi_os_write_memory 1-3 56416 &__get_vm_area_caller_56416
100120 +store_msg_56417 store_msg 3 56417 NULL
100121 +pppol2tp_sendmsg_56420 pppol2tp_sendmsg 4 56420 NULL
100122 +fl_create_56435 fl_create 5 56435 NULL
100123 +gnttab_map_56439 gnttab_map 2 56439 NULL
100124 +cx231xx_init_isoc_56453 cx231xx_init_isoc 3-2 56453 NULL
100125 +set_connectable_56458 set_connectable 4 56458 NULL
100126 +osd_req_list_partition_objects_56464 osd_req_list_partition_objects 5 56464 NULL
100127 +calc_linear_pos_56472 calc_linear_pos 0-3 56472 NULL
100128 +crypto_shash_alignmask_56486 crypto_shash_alignmask 0 56486 NULL
100129 +ieee80211_rx_mgmt_probe_beacon_56491 ieee80211_rx_mgmt_probe_beacon 3 56491 NULL
100130 +cfg80211_connect_result_56515 cfg80211_connect_result 4-6 56515 NULL
100131 +ip_options_get_56538 ip_options_get 4 56538 NULL
100132 +ocfs2_change_extent_flag_56549 ocfs2_change_extent_flag 5 56549 NULL
100133 +alloc_apertures_56561 alloc_apertures 1 56561 NULL
100134 +rs_sta_dbgfs_stats_table_read_56573 rs_sta_dbgfs_stats_table_read 3 56573 NULL
100135 +portcntrs_2_read_56586 portcntrs_2_read 3 56586 NULL
100136 +event_filter_write_56609 event_filter_write 3 56609 NULL
100137 +gather_array_56641 gather_array 3 56641 NULL
100138 +uvc_debugfs_stats_read_56651 uvc_debugfs_stats_read 3 56651 NULL
100139 +snd_gus_dram_read_56686 snd_gus_dram_read 4 56686 NULL nohasharray
100140 +da9055_gpio_to_irq_56686 da9055_gpio_to_irq 2 56686 &snd_gus_dram_read_56686
100141 +build_map_info_56696 build_map_info 2 56696 NULL
100142 +dvb_ringbuffer_read_user_56702 dvb_ringbuffer_read_user 3 56702 NULL
100143 +sta_flags_read_56710 sta_flags_read 3 56710 NULL
100144 +ipv6_getsockopt_sticky_56711 ipv6_getsockopt_sticky 5 56711 NULL
100145 +__wa_xfer_setup_segs_56725 __wa_xfer_setup_segs 2 56725 NULL
100146 +pcpu_populate_chunk_56741 pcpu_populate_chunk 2-3 56741 NULL
100147 +drm_agp_bind_pages_56748 drm_agp_bind_pages 3 56748 NULL
100148 +btrfsic_map_block_56751 btrfsic_map_block 2 56751 NULL
100149 +alloc_iommu_56778 alloc_iommu 2-3 56778 NULL
100150 +__carl9170_rx_56784 __carl9170_rx 3 56784 NULL
100151 +hash_lookup_56792 hash_lookup 2 56792 NULL
100152 +do_syslog_56807 do_syslog 3 56807 NULL
100153 +mtdchar_write_56831 mtdchar_write 3 56831 NULL nohasharray
100154 +ntfs_rl_realloc_56831 ntfs_rl_realloc 3 56831 &mtdchar_write_56831
100155 +snd_rawmidi_kernel_write1_56847 snd_rawmidi_kernel_write1 4 56847 NULL
100156 +wb_lookup_56858 wb_lookup 2 56858 NULL
100157 +ext3_xattr_ibody_get_56880 ext3_xattr_ibody_get 0 56880 NULL
100158 +pvr2_debugifc_print_status_56890 pvr2_debugifc_print_status 3 56890 NULL
100159 +debug_debug3_read_56894 debug_debug3_read 3 56894 NULL
100160 +batadv_tt_update_changes_56895 batadv_tt_update_changes 3 56895 NULL
100161 +strcspn_56913 strcspn 0 56913 NULL
100162 +__kfifo_out_56927 __kfifo_out 0-3 56927 NULL
100163 +check_header_56930 check_header 2 56930 NULL
100164 +journal_init_revoke_56933 journal_init_revoke 2 56933 NULL
100165 +diva_get_driver_info_56967 diva_get_driver_info 0 56967 NULL
100166 +nouveau_device_create__56984 nouveau_device_create_ 6 56984 NULL
100167 +vlsi_alloc_ring_57003 vlsi_alloc_ring 3-4 57003 NULL
100168 +btrfs_super_csum_size_57004 btrfs_super_csum_size 0 57004 NULL
100169 +aircable_process_packet_57027 aircable_process_packet 4 57027 NULL
100170 +skb_network_offset_57043 skb_network_offset 0 57043 NULL nohasharray
100171 +ieee80211_if_fmt_state_57043 ieee80211_if_fmt_state 3 57043 &skb_network_offset_57043
100172 +bytes_to_samples_57049 bytes_to_samples 0-2 57049 NULL
100173 +xfs_buf_read_map_57053 xfs_buf_read_map 3 57053 NULL
100174 +autofs_dev_ioctl_compat_57059 autofs_dev_ioctl_compat 3 57059 NULL
100175 +cx2341x_ctrl_new_std_57061 cx2341x_ctrl_new_std 4 57061 NULL
100176 +sca3000_read_data_57064 sca3000_read_data 4 57064 NULL
100177 +pcmcia_replace_cis_57066 pcmcia_replace_cis 3 57066 NULL
100178 +sis190_try_rx_copy_57069 sis190_try_rx_copy 3 57069 NULL
100179 +tracing_set_trace_write_57096 tracing_set_trace_write 3 57096 NULL
100180 +crypto_compress_ctxsize_57109 crypto_compress_ctxsize 0 57109 NULL
100181 +sysfs_write_file_57116 sysfs_write_file 3 57116 NULL
100182 +cipso_v4_gentag_loc_57119 cipso_v4_gentag_loc 0 57119 NULL
100183 +nl80211_send_deauth_57136 nl80211_send_deauth 4 57136 NULL nohasharray
100184 +rds_ib_sub_signaled_57136 rds_ib_sub_signaled 2 57136 &nl80211_send_deauth_57136 nohasharray
100185 +ima_show_htable_value_57136 ima_show_htable_value 2 57136 &rds_ib_sub_signaled_57136
100186 +snd_sonicvibes_getdmac_57140 snd_sonicvibes_getdmac 0 57140 NULL
100187 +udl_prime_create_57159 udl_prime_create 2 57159 NULL
100188 +__ipath_get_user_pages_57166 __ipath_get_user_pages 1-2 57166 NULL
100189 +stk_prepare_sio_buffers_57168 stk_prepare_sio_buffers 2 57168 NULL
100190 +rx_hw_stuck_read_57179 rx_hw_stuck_read 3 57179 NULL
100191 +tt3650_ci_msg_57219 tt3650_ci_msg 4 57219 NULL
100192 +dma_fifo_alloc_57236 dma_fifo_alloc 5-3-2 57236 NULL
100193 +ieee80211_if_fmt_tsf_57249 ieee80211_if_fmt_tsf 3 57249 NULL
100194 +oprofilefs_ulong_from_user_57251 oprofilefs_ulong_from_user 3 57251 NULL
100195 +alloc_flex_gd_57259 alloc_flex_gd 1 57259 NULL
100196 +security_mmap_file_57268 security_mmap_file 0 57268 NULL
100197 +pstore_file_read_57288 pstore_file_read 3 57288 NULL
100198 +snd_pcm_read_57289 snd_pcm_read 3 57289 NULL
100199 +ath6kl_buf_alloc_57304 ath6kl_buf_alloc 1 57304 NULL
100200 +fw_file_size_57307 fw_file_size 0 57307 NULL
100201 +ftdi_elan_write_57309 ftdi_elan_write 3 57309 NULL
100202 +__mxt_write_reg_57326 __mxt_write_reg 3 57326 NULL
100203 +ocfs2_xattr_shrink_size_57328 ocfs2_xattr_shrink_size 3 57328 NULL
100204 +check_mirror_57342 check_mirror 1-2 57342 NULL nohasharray
100205 +usblp_read_57342 usblp_read 3 57342 &check_mirror_57342
100206 +print_devstats_dot11RTSFailureCount_57347 print_devstats_dot11RTSFailureCount 3 57347 NULL
100207 +tipc_bclink_stats_57372 tipc_bclink_stats 2 57372 NULL
100208 +max8997_irq_domain_map_57375 max8997_irq_domain_map 2 57375 NULL
100209 +tty_register_device_attr_57381 tty_register_device_attr 2 57381 NULL
100210 +read_file_blob_57406 read_file_blob 3 57406 NULL
100211 +enclosure_register_57412 enclosure_register 3 57412 NULL
100212 +gre_manip_pkt_57416 gre_manip_pkt 4 57416 NULL
100213 +compat_keyctl_instantiate_key_iov_57431 compat_keyctl_instantiate_key_iov 3 57431 NULL nohasharray
100214 +alloc_ftrace_hash_57431 alloc_ftrace_hash 1 57431 &compat_keyctl_instantiate_key_iov_57431
100215 +copy_to_user_fromio_57432 copy_to_user_fromio 3 57432 NULL
100216 +sys_pselect6_57449 sys_pselect6 1 57449 NULL
100217 +ReadReg_57453 ReadReg 0 57453 NULL
100218 +__roundup_pow_of_two_57461 __roundup_pow_of_two 0 57461 NULL
100219 +crypto_tfm_alg_blocksize_57463 crypto_tfm_alg_blocksize 0 57463 NULL nohasharray
100220 +send_midi_async_57463 send_midi_async 3 57463 &crypto_tfm_alg_blocksize_57463
100221 +sisusb_clear_vram_57466 sisusb_clear_vram 3-2 57466 NULL
100222 +ieee80211_if_read_flags_57470 ieee80211_if_read_flags 3 57470 NULL nohasharray
100223 +sep_lock_user_pages_57470 sep_lock_user_pages 2-3 57470 &ieee80211_if_read_flags_57470
100224 +ocfs2_write_cluster_57483 ocfs2_write_cluster 8-2-9 57483 NULL
100225 +bnad_debugfs_write_regwr_57500 bnad_debugfs_write_regwr 3 57500 NULL
100226 +skb_headlen_57501 skb_headlen 0 57501 NULL
100227 +copy_in_user_57502 copy_in_user 3 57502 NULL
100228 +ks8842_read32_57505 ks8842_read32 0 57505 NULL nohasharray
100229 +ckhdid_printf_57505 ckhdid_printf 2 57505 &ks8842_read32_57505
100230 +init_tag_map_57515 init_tag_map 3 57515 NULL
100231 +wil_read_file_ssid_57517 wil_read_file_ssid 3 57517 NULL nohasharray
100232 +il_dbgfs_force_reset_read_57517 il_dbgfs_force_reset_read 3 57517 &wil_read_file_ssid_57517
100233 +inode_permission_57531 inode_permission 0 57531 NULL
100234 +acpi_dev_get_resources_57534 acpi_dev_get_resources 0 57534 NULL nohasharray
100235 +DoC_Probe_57534 DoC_Probe 1 57534 &acpi_dev_get_resources_57534
100236 +ext4_group_first_block_no_57559 ext4_group_first_block_no 0-2 57559 NULL
100237 +snd_pcm_playback_ioctl1_57569 snd_pcm_playback_ioctl1 0 57569 NULL
100238 +uio_find_mem_index_57584 uio_find_mem_index 0 57584 NULL
100239 +read_file_spectral_fft_period_57593 read_file_spectral_fft_period 3 57593 NULL
100240 +wm831x_gpio_to_irq_57614 wm831x_gpio_to_irq 2 57614 NULL
100241 +sk_stream_alloc_skb_57622 sk_stream_alloc_skb 2 57622 NULL
100242 +tx_tx_retry_template_read_57623 tx_tx_retry_template_read 3 57623 NULL
100243 +osdmap_set_max_osd_57630 osdmap_set_max_osd 2 57630 NULL nohasharray
100244 +sisusbcon_putcs_57630 sisusbcon_putcs 3 57630 &osdmap_set_max_osd_57630
100245 +mem_read_57631 mem_read 3 57631 NULL
100246 +tc3589x_irq_map_57639 tc3589x_irq_map 2 57639 NULL
100247 +sys_mq_timedsend_57661 sys_mq_timedsend 3 57661 NULL
100248 +r3964_write_57662 r3964_write 4 57662 NULL
100249 +proc_ns_readlink_57664 proc_ns_readlink 3 57664 NULL
100250 +__lgwrite_57669 __lgwrite 4 57669 NULL
100251 +ieee80211_MFIE_rate_len_57692 ieee80211_MFIE_rate_len 0 57692 NULL
100252 +f1x_match_to_this_node_57695 f1x_match_to_this_node 3 57695 NULL
100253 +check_prefree_segments_57702 check_prefree_segments 2 57702 NULL
100254 +i2400m_rx_stats_read_57706 i2400m_rx_stats_read 3 57706 NULL
100255 +ieee80211_if_read_dot11MeshHWMPconfirmationInterval_57722 ieee80211_if_read_dot11MeshHWMPconfirmationInterval 3 57722 NULL
100256 +nouveau_gpio_create__57735 nouveau_gpio_create_ 4-5 57735 NULL
100257 +compat_sys_set_mempolicy_57742 compat_sys_set_mempolicy 3 57742 NULL
100258 +ieee80211_if_fmt_dot11MeshHWMPpreqMinInterval_57762 ieee80211_if_fmt_dot11MeshHWMPpreqMinInterval 3 57762 NULL
100259 +ld2_57794 ld2 0 57794 NULL
100260 +ivtv_read_57796 ivtv_read 3 57796 NULL
100261 +generic_ptrace_peekdata_57806 generic_ptrace_peekdata 2 57806 NULL
100262 +ipath_user_sdma_num_pages_57813 ipath_user_sdma_num_pages 0 57813 NULL
100263 +usb_dump_config_57817 usb_dump_config 0 57817 NULL
100264 +bfad_debugfs_read_regrd_57830 bfad_debugfs_read_regrd 3 57830 NULL
100265 +copy_to_user_57835 copy_to_user 3 57835 NULL
100266 +flash_read_57843 flash_read 3 57843 NULL
100267 +xt_alloc_table_info_57903 xt_alloc_table_info 1 57903 NULL
100268 +emi26_writememory_57908 emi26_writememory 4 57908 NULL
100269 +iio_read_first_n_kfifo_57910 iio_read_first_n_kfifo 2 57910 NULL
100270 +memcg_caches_array_size_57918 memcg_caches_array_size 0-1 57918 NULL
100271 +twl_i2c_write_57923 twl_i2c_write 4-3 57923 NULL
100272 +__snd_gf1_look16_57925 __snd_gf1_look16 0 57925 NULL
100273 +sel_read_handle_unknown_57933 sel_read_handle_unknown 3 57933 NULL
100274 +key_algorithm_read_57946 key_algorithm_read 3 57946 NULL
100275 +ip_set_alloc_57953 ip_set_alloc 1 57953 NULL nohasharray
100276 +ioat3_dca_count_dca_slots_57953 ioat3_dca_count_dca_slots 0 57953 &ip_set_alloc_57953
100277 +i915_cache_sharing_write_57961 i915_cache_sharing_write 3 57961 NULL
100278 +hfc_empty_fifo_57972 hfc_empty_fifo 2 57972 NULL
100279 +c2_reg_user_mr_57982 c2_reg_user_mr 2-3 57982 NULL
100280 +rx_reset_counter_read_58001 rx_reset_counter_read 3 58001 NULL
100281 +regcache_rbtree_insert_to_block_58009 regcache_rbtree_insert_to_block 5 58009 NULL
100282 +iwl_dbgfs_ucode_rx_stats_read_58023 iwl_dbgfs_ucode_rx_stats_read 3 58023 NULL
100283 +io_playback_transfer_58030 io_playback_transfer 4 58030 NULL
100284 +mce_async_out_58056 mce_async_out 3 58056 NULL
100285 +ocfs2_find_leaf_58065 ocfs2_find_leaf 0 58065 NULL
100286 +dt3155_alloc_coherent_58073 dt3155_alloc_coherent 2 58073 NULL
100287 +cm4040_write_58079 cm4040_write 3 58079 NULL
100288 +udi_log_event_58105 udi_log_event 3 58105 NULL
100289 +savemem_58129 savemem 3 58129 NULL
100290 +ipv6_flowlabel_opt_58135 ipv6_flowlabel_opt 3 58135 NULL nohasharray
100291 +slhc_init_58135 slhc_init 1-2 58135 &ipv6_flowlabel_opt_58135
100292 +garmin_write_bulk_58191 garmin_write_bulk 3 58191 NULL
100293 +asix_write_cmd_58192 asix_write_cmd 5 58192 NULL
100294 +ieee80211_if_fmt_flags_58205 ieee80211_if_fmt_flags 3 58205 NULL
100295 +hva_to_pfn_58241 hva_to_pfn 1 58241 NULL
100296 +btrfsic_create_link_to_next_block_58246 btrfsic_create_link_to_next_block 4 58246 NULL
100297 +read_file_debug_58256 read_file_debug 3 58256 NULL
100298 +cfg80211_mgmt_tx_status_58266 cfg80211_mgmt_tx_status 4 58266 NULL
100299 +profile_load_58267 profile_load 3 58267 NULL
100300 +acpi_ds_build_internal_package_obj_58271 acpi_ds_build_internal_package_obj 3 58271 NULL
100301 +r100_mm_rreg_58276 r100_mm_rreg 0 58276 NULL
100302 +iscsi_decode_text_input_58292 iscsi_decode_text_input 4 58292 NULL
100303 +ieee80211_if_read_dot11MeshTTL_58307 ieee80211_if_read_dot11MeshTTL 3 58307 NULL
100304 +tx_tx_start_int_templates_read_58324 tx_tx_start_int_templates_read 3 58324 NULL
100305 +pcim_iomap_58334 pcim_iomap 3 58334 NULL
100306 +diva_init_dma_map_58336 diva_init_dma_map 3 58336 NULL
100307 +next_pidmap_58347 next_pidmap 2 58347 NULL
100308 +vmalloc_to_sg_58354 vmalloc_to_sg 2 58354 NULL
100309 +save_hint_58359 save_hint 2 58359 NULL
100310 +brcmf_debugfs_sdio_counter_read_58369 brcmf_debugfs_sdio_counter_read 3 58369 NULL
100311 +il_dbgfs_status_read_58388 il_dbgfs_status_read 3 58388 NULL
100312 +kvm_mmu_write_protect_pt_masked_58406 kvm_mmu_write_protect_pt_masked 3 58406 NULL
100313 +i2400m_pld_size_58415 i2400m_pld_size 0 58415 NULL
100314 +__mlx4_alloc_mtt_range_58418 __mlx4_alloc_mtt_range 2 58418 NULL
100315 +__iio_add_chan_devattr_58451 __iio_add_chan_devattr 0 58451 NULL
100316 +capabilities_read_58457 capabilities_read 3 58457 NULL
100317 +batadv_iv_ogm_aggr_packet_58462 batadv_iv_ogm_aggr_packet 3 58462 NULL
100318 +lpfc_idiag_baracc_read_58466 lpfc_idiag_baracc_read 3 58466 NULL nohasharray
100319 +compat_do_ipt_set_ctl_58466 compat_do_ipt_set_ctl 4 58466 &lpfc_idiag_baracc_read_58466
100320 +snd_gf1_read_addr_58483 snd_gf1_read_addr 0 58483 NULL
100321 +snd_rme96_capture_copy_58484 snd_rme96_capture_copy 5 58484 NULL
100322 +batadv_bla_is_backbone_gw_58488 batadv_bla_is_backbone_gw 3 58488 NULL
100323 +memblock_alloc_try_nid_58493 memblock_alloc_try_nid 1-2 58493 NULL
100324 +rndis_add_response_58544 rndis_add_response 2 58544 NULL
100325 +__clear_discard_58546 __clear_discard 2 58546 NULL
100326 +wep_decrypt_fail_read_58567 wep_decrypt_fail_read 3 58567 NULL
100327 +sip_sprintf_addr_port_58574 sip_sprintf_addr_port 0 58574 NULL
100328 +scnprint_mac_oui_58578 scnprint_mac_oui 3-0 58578 NULL
100329 +ea_read_inline_58589 ea_read_inline 0 58589 NULL
100330 +xip_file_read_58592 xip_file_read 3 58592 NULL
100331 +gdth_search_isa_58595 gdth_search_isa 1 58595 NULL
100332 +ebt_buf_count_58607 ebt_buf_count 0 58607 NULL
100333 +skb_copy_to_page_nocache_58624 skb_copy_to_page_nocache 6 58624 NULL
100334 +module_alloc_update_bounds_rx_58634 module_alloc_update_bounds_rx 1 58634 NULL nohasharray
100335 +efi_ioremap_58634 efi_ioremap 1-2 58634 &module_alloc_update_bounds_rx_58634
100336 +tx_tx_start_fw_gen_read_58648 tx_tx_start_fw_gen_read 3 58648 NULL
100337 +ocfs2_block_to_cluster_start_58653 ocfs2_block_to_cluster_start 2 58653 NULL
100338 +__gfn_to_pfn_58671 __gfn_to_pfn 2 58671 NULL
100339 +iwl_trans_send_cmd_58681 iwl_trans_send_cmd 0 58681 NULL
100340 +find_zero_58685 find_zero 0-1 58685 NULL nohasharray
100341 +mcs7830_set_reg_async_58685 mcs7830_set_reg_async 3 58685 &find_zero_58685
100342 +uwb_bce_print_IEs_58686 uwb_bce_print_IEs 4 58686 NULL
100343 +pci_alloc_consistent_58688 pci_alloc_consistent 0 58688 NULL
100344 +tps6586x_writes_58689 tps6586x_writes 3-2 58689 NULL
100345 +vmalloc_node_58700 vmalloc_node 1 58700 NULL
100346 +acpi_map_58725 acpi_map 1-2 58725 NULL
100347 +da9052_gpio_to_irq_58729 da9052_gpio_to_irq 2 58729 NULL
100348 +csum_exist_in_range_58730 csum_exist_in_range 2 58730 NULL
100349 +frames_to_bytes_58741 frames_to_bytes 0-2 58741 NULL
100350 +ieee80211_if_write_tkip_mic_test_58748 ieee80211_if_write_tkip_mic_test 3 58748 NULL
100351 +agp_allocate_memory_58761 agp_allocate_memory 2 58761 NULL
100352 +oblock_to_dblock_58762 oblock_to_dblock 0-2 58762 NULL
100353 +__do_config_autodelink_58763 __do_config_autodelink 3 58763 NULL
100354 +regmap_calc_reg_len_58795 regmap_calc_reg_len 0 58795 NULL
100355 +raw_send_hdrinc_58803 raw_send_hdrinc 4 58803 NULL
100356 +isku_sysfs_read_58806 isku_sysfs_read 6 58806 NULL
100357 +ep_read_58813 ep_read 3 58813 NULL
100358 +command_write_58841 command_write 3 58841 NULL
100359 +ocfs2_truncate_log_append_58850 ocfs2_truncate_log_append 3 58850 NULL
100360 +ath6kl_wmi_send_action_cmd_58860 ath6kl_wmi_send_action_cmd 7 58860 NULL
100361 +gs_alloc_req_58883 gs_alloc_req 2 58883 NULL
100362 +cs553x_init_one_58886 cs553x_init_one 3 58886 NULL
100363 +raw_ctl_compat_ioctl_58905 raw_ctl_compat_ioctl 3 58905 NULL
100364 +print_devstats_dot11FCSErrorCount_58919 print_devstats_dot11FCSErrorCount 3 58919 NULL
100365 +tun_chr_compat_ioctl_58921 tun_chr_compat_ioctl 3 58921 NULL
100366 +pipeline_cs_rx_packet_out_read_58926 pipeline_cs_rx_packet_out_read 3 58926 NULL
100367 +st5481_isoc_flatten_58952 st5481_isoc_flatten 0 58952 NULL
100368 +ieee80211_if_fmt_dot11MeshHWMPactivePathToRootTimeout_58965 ieee80211_if_fmt_dot11MeshHWMPactivePathToRootTimeout 3 58965 NULL
100369 +idx_to_kaddr_58968 idx_to_kaddr 0 58968 NULL
100370 +crypto_aead_ivsize_58970 crypto_aead_ivsize 0 58970 NULL
100371 +remap_to_cache_dirty_58991 remap_to_cache_dirty 4-3 58991 NULL
100372 +handle_rx_packet_58993 handle_rx_packet 3 58993 NULL
100373 +edac_align_ptr_59003 edac_align_ptr 0 59003 NULL
100374 +ep_write_59008 ep_write 3 59008 NULL
100375 +i915_ring_stop_write_59010 i915_ring_stop_write 3 59010 NULL
100376 +init_pci_cap_msi_perm_59033 init_pci_cap_msi_perm 2 59033 NULL
100377 +selinux_transaction_write_59038 selinux_transaction_write 3 59038 NULL
100378 +crypto_aead_reqsize_59039 crypto_aead_reqsize 0 59039 NULL
100379 +regmap_bulk_write_59049 regmap_bulk_write 4-2 59049 NULL
100380 +vfio_device_fops_compat_ioctl_59111 vfio_device_fops_compat_ioctl 3 59111 NULL
100381 +mmc_sd_num_wr_blocks_59112 mmc_sd_num_wr_blocks 0 59112 NULL
100382 +scsi_io_completion_59122 scsi_io_completion 2 59122 NULL
100383 +nfc_llcp_send_i_frame_59130 nfc_llcp_send_i_frame 3 59130 NULL
100384 +__iio_add_event_config_attrs_59136 __iio_add_event_config_attrs 0 59136 NULL
100385 +print_devstats_dot11RTSSuccessCount_59145 print_devstats_dot11RTSSuccessCount 3 59145 NULL nohasharray
100386 +framebuffer_alloc_59145 framebuffer_alloc 1 59145 &print_devstats_dot11RTSSuccessCount_59145
100387 +radeon_compat_ioctl_59150 radeon_compat_ioctl 2 59150 NULL
100388 +pvr2_hdw_report_clients_59152 pvr2_hdw_report_clients 3 59152 NULL
100389 +setup_window_59178 setup_window 4-2-5-7 59178 NULL
100390 +ocfs2_move_extent_59187 ocfs2_move_extent 3 59187 NULL
100391 +xfs_iext_realloc_indirect_59211 xfs_iext_realloc_indirect 2 59211 NULL
100392 +fast_rx_path_59214 fast_rx_path 3 59214 NULL
100393 +inftl_partscan_59216 inftl_partscan 0 59216 NULL
100394 +skb_transport_header_59223 skb_transport_header 0 59223 NULL
100395 +dt3155_read_59226 dt3155_read 3 59226 NULL
100396 +paging64_gpte_to_gfn_lvl_59229 paging64_gpte_to_gfn_lvl 0-1-2 59229 NULL
100397 +tty_prepare_flip_string_flags_59240 tty_prepare_flip_string_flags 4 59240 NULL
100398 +solo_v4l2_read_59247 solo_v4l2_read 3 59247 NULL
100399 +nla_len_59258 nla_len 0 59258 NULL
100400 +btrfs_insert_dir_item_59304 btrfs_insert_dir_item 4 59304 NULL
100401 +fd_copyout_59323 fd_copyout 3 59323 NULL
100402 +read_9287_modal_eeprom_59327 read_9287_modal_eeprom 3 59327 NULL
100403 +rx_defrag_in_process_called_read_59338 rx_defrag_in_process_called_read 3 59338 NULL
100404 +paging64_get_level1_sp_gpa_59346 paging64_get_level1_sp_gpa 0 59346 NULL nohasharray
100405 +xfs_attrmulti_attr_set_59346 xfs_attrmulti_attr_set 4 59346 &paging64_get_level1_sp_gpa_59346
100406 +xfs_dir2_sf_entsize_59366 xfs_dir2_sf_entsize 0-2 59366 NULL
100407 +pvr2_debugifc_print_info_59380 pvr2_debugifc_print_info 3 59380 NULL
100408 +fc_frame_alloc_fill_59394 fc_frame_alloc_fill 2 59394 NULL
100409 +vxge_hw_ring_rxds_per_block_get_59425 vxge_hw_ring_rxds_per_block_get 0 59425 NULL
100410 +squashfs_read_data_59440 squashfs_read_data 6 59440 NULL
100411 +fs_path_ensure_buf_59445 fs_path_ensure_buf 2 59445 NULL
100412 +descriptor_loc_59446 descriptor_loc 3 59446 NULL
100413 +do_compat_semctl_59449 do_compat_semctl 4 59449 NULL
100414 +virtqueue_add_buf_59470 virtqueue_add_buf 3-4 59470 NULL
100415 +ib_copy_from_udata_59502 ib_copy_from_udata 3 59502 NULL
100416 +nfsd_nrpools_59503 nfsd_nrpools 0 59503 NULL
100417 +rds_pin_pages_59507 rds_pin_pages 0-1-2 59507 NULL
100418 +mpi_get_nbits_59551 mpi_get_nbits 0 59551 NULL
100419 +tunables_write_59563 tunables_write 3 59563 NULL
100420 +memdup_user_59590 memdup_user 2 59590 NULL
100421 +tps6586x_irq_get_virq_59601 tps6586x_irq_get_virq 2 59601 NULL
100422 +mem_fwlog_free_mem_blks_read_59616 mem_fwlog_free_mem_blks_read 3 59616 NULL
100423 +mtrr_write_59622 mtrr_write 3 59622 NULL
100424 +find_first_zero_bit_59636 find_first_zero_bit 0-2 59636 NULL
100425 +ubifs_setxattr_59650 ubifs_setxattr 4 59650 NULL nohasharray
100426 +hidraw_read_59650 hidraw_read 3 59650 &ubifs_setxattr_59650
100427 +v9fs_xattr_set_acl_59651 v9fs_xattr_set_acl 4 59651 NULL
100428 +__devcgroup_check_permission_59665 __devcgroup_check_permission 0 59665 NULL
100429 +alloc_dca_provider_59670 alloc_dca_provider 2 59670 NULL
100430 +can_nocow_odirect_59681 can_nocow_odirect 3 59681 NULL
100431 +sriov_enable_59689 sriov_enable 2 59689 NULL
100432 +mic_calc_failure_read_59700 mic_calc_failure_read 3 59700 NULL
100433 +prism2_info_scanresults_59729 prism2_info_scanresults 3 59729 NULL
100434 +ieee80211_if_read_fwded_unicast_59740 ieee80211_if_read_fwded_unicast 3 59740 NULL
100435 +qib_decode_7220_sdma_errs_59745 qib_decode_7220_sdma_errs 4 59745 NULL
100436 +strnlen_59746 strnlen 0 59746 NULL
100437 +sctp_manip_pkt_59749 sctp_manip_pkt 4 59749 NULL
100438 +ext3_acl_count_59754 ext3_acl_count 0-1 59754 NULL
100439 +long_retry_limit_read_59766 long_retry_limit_read 3 59766 NULL
100440 +venus_remove_59781 venus_remove 4 59781 NULL
100441 +ipw_write_59807 ipw_write 3 59807 NULL
100442 +rtllib_wx_set_gen_ie_59808 rtllib_wx_set_gen_ie 3 59808 NULL
100443 +scsi_init_shared_tag_map_59812 scsi_init_shared_tag_map 2 59812 NULL
100444 +ieee80211_if_read_dot11MeshHWMPmaxPREQretries_59829 ieee80211_if_read_dot11MeshHWMPmaxPREQretries 3 59829 NULL
100445 +gspca_dev_probe2_59833 gspca_dev_probe2 4 59833 NULL
100446 +regmap_raw_write_async_59849 regmap_raw_write_async 2-4 59849 NULL
100447 +pvr2_ioread_set_sync_key_59882 pvr2_ioread_set_sync_key 3 59882 NULL
100448 +shmem_zero_setup_59885 shmem_zero_setup 0 59885 NULL
100449 +ffs_prepare_buffer_59892 ffs_prepare_buffer 2 59892 NULL
100450 +swiotlb_map_page_59909 swiotlb_map_page 3 59909 NULL
100451 +il_dbgfs_rxon_flags_read_59950 il_dbgfs_rxon_flags_read 3 59950 NULL nohasharray
100452 +dapm_widget_power_read_file_59950 dapm_widget_power_read_file 3 59950 &il_dbgfs_rxon_flags_read_59950
100453 +lookup_node_59953 lookup_node 2 59953 NULL
100454 +il_dbgfs_missed_beacon_read_59956 il_dbgfs_missed_beacon_read 3 59956 NULL nohasharray
100455 +compat_ipmi_ioctl_59956 compat_ipmi_ioctl 3 59956 &il_dbgfs_missed_beacon_read_59956
100456 +kvm_set_cr3_59965 kvm_set_cr3 2 59965 NULL
100457 +fb_getput_cmap_59971 fb_getput_cmap 3 59971 NULL
100458 +__arch_hweight16_59975 __arch_hweight16 0 59975 NULL
100459 +osd_req_read_kern_59990 osd_req_read_kern 5 59990 NULL
100460 +ghash_async_setkey_60001 ghash_async_setkey 3 60001 NULL
100461 +ieee80211_if_fmt_dot11MeshAwakeWindowDuration_60006 ieee80211_if_fmt_dot11MeshAwakeWindowDuration 3 60006 NULL
100462 +rawsock_sendmsg_60010 rawsock_sendmsg 4 60010 NULL
100463 +mthca_init_cq_60011 mthca_init_cq 2 60011 NULL
100464 +register_device_60015 register_device 2-3 60015 NULL
100465 +osd_req_list_dev_partitions_60027 osd_req_list_dev_partitions 4 60027 NULL
100466 +xlog_bread_offset_60030 xlog_bread_offset 3 60030 NULL
100467 +sys_sched_getaffinity_60033 sys_sched_getaffinity 2 60033 NULL
100468 +bio_integrity_hw_sectors_60039 bio_integrity_hw_sectors 0-2 60039 NULL
100469 +do_ip6t_set_ctl_60040 do_ip6t_set_ctl 4 60040 NULL
100470 +pin_2_irq_60050 pin_2_irq 0-3 60050 NULL nohasharray
100471 +vcs_size_60050 vcs_size 0 60050 &pin_2_irq_60050
100472 +gru_alloc_gts_60056 gru_alloc_gts 3-2 60056 NULL
100473 +compat_writev_60063 compat_writev 3 60063 NULL
100474 +ieee80211_build_probe_req_60064 ieee80211_build_probe_req 6-8 60064 NULL
100475 +c4iw_num_stags_60073 c4iw_num_stags 0 60073 NULL
100476 +mp_register_gsi_60079 mp_register_gsi 2 60079 NULL
100477 +rxrpc_kernel_send_data_60083 rxrpc_kernel_send_data 3 60083 NULL
100478 +ieee80211_if_fmt_fwded_frames_60103 ieee80211_if_fmt_fwded_frames 3 60103 NULL
100479 +ttm_bo_kmap_60118 ttm_bo_kmap 3-2 60118 NULL
100480 +jmb38x_ms_count_slots_60164 jmb38x_ms_count_slots 0 60164 NULL
100481 +init_state_60165 init_state 2 60165 NULL
100482 +sg_build_sgat_60179 sg_build_sgat 3 60179 NULL nohasharray
100483 +jffs2_alloc_full_dirent_60179 jffs2_alloc_full_dirent 1 60179 &sg_build_sgat_60179
100484 +rx_rx_tkip_replays_read_60193 rx_rx_tkip_replays_read 3 60193 NULL
100485 +svc_compat_ioctl_60194 svc_compat_ioctl 3 60194 NULL
100486 +ib_send_cm_mra_60202 ib_send_cm_mra 4 60202 NULL nohasharray
100487 +qib_reg_phys_mr_60202 qib_reg_phys_mr 3 60202 &ib_send_cm_mra_60202
100488 +set_tap_pfs_60203 set_tap_pfs 3 60203 NULL
100489 +ieee80211_mgmt_tx_60209 ieee80211_mgmt_tx 7 60209 NULL
100490 +btrfs_get_token_16_60220 btrfs_get_token_16 0 60220 NULL
100491 +arizona_map_irq_60230 arizona_map_irq 2 60230 NULL nohasharray
100492 +__phys_addr_nodebug_60230 __phys_addr_nodebug 0-1 60230 &arizona_map_irq_60230
100493 +wm831x_irq_60254 wm831x_irq 2 60254 NULL
100494 +compat_sys_fcntl64_60256 compat_sys_fcntl64 3 60256 NULL
100495 +printer_write_60276 printer_write 3 60276 NULL
100496 +__pskb_pull_tail_60287 __pskb_pull_tail 2 60287 NULL
100497 +do_xip_mapping_read_60297 do_xip_mapping_read 5 60297 NULL
100498 +getDataLength_60301 getDataLength 0 60301 NULL
100499 +ceph_parse_server_name_60318 ceph_parse_server_name 2 60318 NULL
100500 +__kfifo_from_user_r_60345 __kfifo_from_user_r 3-5 60345 NULL
100501 +dccp_setsockopt_60367 dccp_setsockopt 5 60367 NULL
100502 +ubi_eba_atomic_leb_change_60379 ubi_eba_atomic_leb_change 5 60379 NULL
100503 +instruction_pointer_60384 instruction_pointer 0 60384 NULL
100504 +mthca_alloc_resize_buf_60394 mthca_alloc_resize_buf 3 60394 NULL
100505 +ocfs2_zero_extend_60396 ocfs2_zero_extend 3 60396 NULL
100506 +driver_names_read_60399 driver_names_read 3 60399 NULL
100507 +paging32_walk_addr_generic_60415 paging32_walk_addr_generic 4 60415 NULL
100508 +simple_alloc_urb_60420 simple_alloc_urb 3 60420 NULL
100509 +excessive_retries_read_60425 excessive_retries_read 3 60425 NULL
100510 +tstats_write_60432 tstats_write 3 60432 NULL nohasharray
100511 +kmalloc_60432 kmalloc 1 60432 &tstats_write_60432
100512 +tipc_buf_acquire_60437 tipc_buf_acquire 1 60437 NULL
100513 +rx_data_60442 rx_data 4 60442 NULL
100514 +tcf_csum_ipv4_igmp_60446 tcf_csum_ipv4_igmp 3 60446 NULL
100515 +snd_hda_get_num_raw_conns_60462 snd_hda_get_num_raw_conns 0 60462 NULL
100516 +crypto_shash_setkey_60483 crypto_shash_setkey 3 60483 NULL
100517 +ath_tx_init_60515 ath_tx_init 2 60515 NULL
100518 +hysdn_sched_rx_60533 hysdn_sched_rx 3 60533 NULL
100519 +v9fs_fid_readn_60544 v9fs_fid_readn 4 60544 NULL
100520 +nonpaging_map_60551 nonpaging_map 4 60551 NULL
100521 +skb_transport_offset_60619 skb_transport_offset 0 60619 NULL
100522 +wl1273_fm_fops_write_60621 wl1273_fm_fops_write 3 60621 NULL
100523 +acl_alloc_stack_init_60630 acl_alloc_stack_init 1 60630 NULL
100524 +ubifs_recover_leb_60639 ubifs_recover_leb 3 60639 NULL
100525 +fb_get_fscreeninfo_60640 fb_get_fscreeninfo 3 60640 NULL
100526 +if_sdio_host_to_card_60666 if_sdio_host_to_card 4 60666 NULL
100527 +ieee80211_if_read_dot11MeshConfirmTimeout_60670 ieee80211_if_read_dot11MeshConfirmTimeout 3 60670 NULL
100528 +read_vbt_r10_60679 read_vbt_r10 1 60679 NULL
100529 +init_data_container_60709 init_data_container 1 60709 NULL
100530 +snd_ice1712_ds_read_60754 snd_ice1712_ds_read 0 60754 NULL
100531 +raid_status_60755 raid_status 5 60755 NULL
100532 +sel_write_checkreqprot_60774 sel_write_checkreqprot 3 60774 NULL
100533 +opticon_write_60775 opticon_write 4 60775 NULL
100534 +acl_alloc_num_60778 acl_alloc_num 1-2 60778 NULL
100535 +snd_pcm_oss_readv3_60792 snd_pcm_oss_readv3 3 60792 NULL
100536 +pwr_tx_with_ps_read_60851 pwr_tx_with_ps_read 3 60851 NULL
100537 +alloc_buf_60864 alloc_buf 3-2 60864 NULL
100538 +generic_writepages_60871 generic_writepages 0 60871 NULL
100539 +ext4_update_inline_data_60888 ext4_update_inline_data 3 60888 NULL
100540 +iio_debugfs_read_reg_60908 iio_debugfs_read_reg 3 60908 NULL
100541 +mgt_set_varlen_60916 mgt_set_varlen 4 60916 NULL
100542 +scrub_chunk_60926 scrub_chunk 5 60926 NULL
100543 +sys_mlock_60932 sys_mlock 1 60932 NULL
100544 +pti_char_write_60960 pti_char_write 3 60960 NULL
100545 +mwifiex_alloc_sdio_mpa_buffers_60961 mwifiex_alloc_sdio_mpa_buffers 2-3 60961 NULL
100546 +__a2mp_build_60987 __a2mp_build 3 60987 NULL
100547 +hsc_msg_alloc_60990 hsc_msg_alloc 1 60990 NULL
100548 +ath6kl_lrssi_roam_read_61022 ath6kl_lrssi_roam_read 3 61022 NULL
100549 +symtab_init_61050 symtab_init 2 61050 NULL
100550 +fuse_send_write_61053 fuse_send_write 0 61053 NULL
100551 +bitmap_scnlistprintf_61062 bitmap_scnlistprintf 0-4-2 61062 NULL
100552 +ahash_align_buffer_size_61070 ahash_align_buffer_size 0-1-2 61070 NULL
100553 +get_derived_key_61100 get_derived_key 4 61100 NULL
100554 +alloc_chrdev_region_61112 alloc_chrdev_region 0 61112 NULL
100555 +p80211_headerlen_61119 p80211_headerlen 0 61119 NULL nohasharray
100556 +__probe_kernel_read_61119 __probe_kernel_read 3 61119 &p80211_headerlen_61119
100557 +vmemmap_alloc_block_buf_61126 vmemmap_alloc_block_buf 1 61126 NULL
100558 +afs_proc_cells_write_61139 afs_proc_cells_write 3 61139 NULL
100559 +__vmalloc_61168 __vmalloc 1 61168 NULL
100560 +event_oom_late_read_61175 event_oom_late_read 3 61175 NULL nohasharray
100561 +pair_device_61175 pair_device 4 61175 &event_oom_late_read_61175
100562 +sys_lsetxattr_61177 sys_lsetxattr 4 61177 NULL
100563 +arch_hibernation_header_save_61212 arch_hibernation_header_save 0 61212 NULL
100564 +smk_read_ambient_61220 smk_read_ambient 3 61220 NULL
100565 +btrfs_bio_alloc_61270 btrfs_bio_alloc 3 61270 NULL
100566 +vortex_adbdma_getlinearpos_61283 vortex_adbdma_getlinearpos 0 61283 NULL
100567 +sys_add_key_61288 sys_add_key 4 61288 NULL
100568 +ext4_issue_discard_61305 ext4_issue_discard 2 61305 NULL
100569 +xfrm_user_sec_ctx_size_61320 xfrm_user_sec_ctx_size 0 61320 NULL
100570 +st5481_setup_isocpipes_61340 st5481_setup_isocpipes 6-4 61340 NULL
100571 +rx_rx_wa_ba_not_expected_read_61341 rx_rx_wa_ba_not_expected_read 3 61341 NULL
100572 +f1x_map_sysaddr_to_csrow_61344 f1x_map_sysaddr_to_csrow 2 61344 NULL
100573 +debug_debug4_read_61367 debug_debug4_read 3 61367 NULL
100574 +sys_ptrace_61369 sys_ptrace 3 61369 NULL
100575 +change_xattr_61390 change_xattr 5 61390 NULL
100576 +size_entry_mwt_61400 size_entry_mwt 0 61400 NULL
100577 +dma_ops_area_alloc_61440 dma_ops_area_alloc 3-4-5 61440 NULL
100578 +tc3589x_irq_unmap_61447 tc3589x_irq_unmap 2 61447 NULL
100579 +unix_stream_sendmsg_61455 unix_stream_sendmsg 4 61455 NULL
100580 +snd_pcm_lib_writev_transfer_61483 snd_pcm_lib_writev_transfer 4-2-5 61483 NULL
100581 +btrfs_item_size_61485 btrfs_item_size 0 61485 NULL
100582 +erst_errno_61526 erst_errno 0 61526 NULL
100583 +ntfs_attr_lookup_61539 ntfs_attr_lookup 0 61539 NULL
100584 +o2hb_pop_count_61553 o2hb_pop_count 2 61553 NULL
100585 +dvb_net_ioctl_61559 dvb_net_ioctl 2 61559 NULL
100586 +ieee80211_if_read_rc_rateidx_mask_2ghz_61570 ieee80211_if_read_rc_rateidx_mask_2ghz 3 61570 NULL
100587 +seq_open_private_61589 seq_open_private 3 61589 NULL
100588 +__get_vm_area_61599 __get_vm_area 1 61599 NULL
100589 +nfs4_init_uniform_client_string_61601 nfs4_init_uniform_client_string 3 61601 NULL
100590 +ncp_compat_ioctl_61608 ncp_compat_ioctl 3 61608 NULL
100591 +configfs_write_file_61621 configfs_write_file 3 61621 NULL
100592 +ieee80211_if_fmt_hw_queues_61629 ieee80211_if_fmt_hw_queues 3 61629 NULL
100593 +i2o_parm_table_get_61635 i2o_parm_table_get 6 61635 NULL
100594 +snd_pcm_oss_read3_61643 snd_pcm_oss_read3 0-3 61643 NULL
100595 +resize_stripes_61650 resize_stripes 2 61650 NULL
100596 +ttm_page_pool_free_61661 ttm_page_pool_free 2 61661 NULL
100597 +insert_one_name_61668 insert_one_name 7 61668 NULL
100598 +lock_loop_61681 lock_loop 1 61681 NULL
100599 +filter_read_61692 filter_read 3 61692 NULL
100600 +iov_length_61716 iov_length 0 61716 NULL
100601 +fragmentation_threshold_read_61718 fragmentation_threshold_read 3 61718 NULL
100602 +read_file_interrupt_61742 read_file_interrupt 3 61742 NULL nohasharray
100603 +read_file_regval_61742 read_file_regval 3 61742 &read_file_interrupt_61742
100604 +batadv_dat_snoop_incoming_arp_reply_61801 batadv_dat_snoop_incoming_arp_reply 3 61801 NULL
100605 +tps80031_irq_init_61830 tps80031_irq_init 3 61830 NULL
100606 +bfad_debugfs_write_regwr_61841 bfad_debugfs_write_regwr 3 61841 NULL
100607 +fs_path_prepare_for_add_61854 fs_path_prepare_for_add 2 61854 NULL
100608 +evdev_compute_buffer_size_61863 evdev_compute_buffer_size 0 61863 NULL
100609 +get_fw_name_61874 get_fw_name 3 61874 NULL
100610 +free_init_pages_61875 free_init_pages 2 61875 NULL
100611 +twl4030_sih_setup_61878 twl4030_sih_setup 3 61878 NULL
100612 +ieee80211_rtl_auth_challenge_61897 ieee80211_rtl_auth_challenge 3 61897 NULL
100613 +ax25_addr_size_61899 ax25_addr_size 0 61899 NULL nohasharray
100614 +cxgb4_pktgl_to_skb_61899 cxgb4_pktgl_to_skb 2 61899 &ax25_addr_size_61899
100615 +clear_refs_write_61904 clear_refs_write 3 61904 NULL
100616 +rx_filter_arp_filter_read_61914 rx_filter_arp_filter_read 3 61914 NULL
100617 +au0828_init_isoc_61917 au0828_init_isoc 3-2 61917 NULL
100618 +sctp_sendmsg_61919 sctp_sendmsg 4 61919 NULL
100619 +send_bulk_static_data_61932 send_bulk_static_data 3 61932 NULL
100620 +gfn_to_pfn_memslot_atomic_61947 gfn_to_pfn_memslot_atomic 2 61947 NULL
100621 +il4965_ucode_rx_stats_read_61948 il4965_ucode_rx_stats_read 3 61948 NULL
100622 +squashfs_read_id_index_table_61961 squashfs_read_id_index_table 4 61961 NULL
100623 +mlx4_alloc_mtt_range_61966 mlx4_alloc_mtt_range 2 61966 NULL
100624 +ocfs2_quota_write_61972 ocfs2_quota_write 5-4 61972 NULL
100625 +cow_file_range_61979 cow_file_range 3 61979 NULL
100626 +module_alloc_exec_61991 module_alloc_exec 1 61991 NULL
100627 +virtnet_send_command_61993 virtnet_send_command 5-6 61993 NULL
100628 +xt_compat_match_offset_62011 xt_compat_match_offset 0 62011 NULL
100629 +jffs2_do_unlink_62020 jffs2_do_unlink 4 62020 NULL
100630 +pmcraid_build_passthrough_ioadls_62034 pmcraid_build_passthrough_ioadls 2 62034 NULL
100631 +ppp_tx_cp_62044 ppp_tx_cp 5 62044 NULL
100632 +sctp_user_addto_chunk_62047 sctp_user_addto_chunk 2-3 62047 NULL
100633 +do_pselect_62061 do_pselect 1 62061 NULL
100634 +pcpu_alloc_bootmem_62074 pcpu_alloc_bootmem 2-3 62074 NULL
100635 +get_domain_for_dev_62099 get_domain_for_dev 2 62099 NULL
100636 +ipath_user_sdma_pin_pages_62100 ipath_user_sdma_pin_pages 3-5 62100 NULL
100637 +jffs2_security_setxattr_62107 jffs2_security_setxattr 4 62107 NULL
100638 +llc_ui_header_len_62131 llc_ui_header_len 0 62131 NULL
100639 +qib_diag_write_62133 qib_diag_write 3 62133 NULL
100640 +ql_status_62135 ql_status 5 62135 NULL
100641 +video_usercopy_62151 video_usercopy 2 62151 NULL
100642 +prism54_wpa_bss_ie_get_62173 prism54_wpa_bss_ie_get 0 62173 NULL
100643 +alloc_upcall_62186 alloc_upcall 2 62186 NULL
100644 +btrfs_xattr_acl_set_62203 btrfs_xattr_acl_set 4 62203 NULL
100645 +sock_kmalloc_62205 sock_kmalloc 2 62205 NULL
100646 +nfsd_read_file_62241 nfsd_read_file 6 62241 NULL
100647 +allocate_partition_62245 allocate_partition 4 62245 NULL
100648 +__qib_get_user_pages_62287 __qib_get_user_pages 1-2 62287 NULL
100649 +il_dbgfs_sram_read_62296 il_dbgfs_sram_read 3 62296 NULL
100650 +sparse_early_usemaps_alloc_pgdat_section_62304 sparse_early_usemaps_alloc_pgdat_section 2 62304 NULL
100651 +subsystem_filter_read_62310 subsystem_filter_read 3 62310 NULL
100652 +udf_sb_alloc_partition_maps_62313 udf_sb_alloc_partition_maps 2 62313 NULL
100653 +Wb35Reg_BurstWrite_62327 Wb35Reg_BurstWrite 4 62327 NULL
100654 +subseq_list_62332 subseq_list 3-0 62332 NULL
100655 +flash_write_62354 flash_write 3 62354 NULL
100656 +set_wd_exp_mode_pfs_62372 set_wd_exp_mode_pfs 3 62372 NULL
100657 +twl_get_num_slaves_62386 twl_get_num_slaves 0 62386 NULL
100658 +rx_rx_timeout_read_62389 rx_rx_timeout_read 3 62389 NULL
100659 +altera_irscan_62396 altera_irscan 2 62396 NULL
100660 +set_ssp_62411 set_ssp 4 62411 NULL
100661 +unmap_single_62423 unmap_single 2 62423 NULL
100662 +netdev_alloc_skb_62437 netdev_alloc_skb 2 62437 NULL
100663 +e1000_check_copybreak_62448 e1000_check_copybreak 3 62448 NULL
100664 +ip_vs_icmp_xmit_v6_62477 ip_vs_icmp_xmit_v6 4 62477 NULL
100665 +ceph_dns_resolve_name_62488 ceph_dns_resolve_name 2 62488 NULL
100666 +remove_mapping_62491 remove_mapping 2 62491 NULL
100667 +mlx4_en_create_rx_ring_62498 mlx4_en_create_rx_ring 3 62498 NULL
100668 +ext_rts51x_sd_execute_read_data_62501 ext_rts51x_sd_execute_read_data 9 62501 NULL
100669 +pep_sendmsg_62524 pep_sendmsg 4 62524 NULL nohasharray
100670 +i915_next_seqno_read_62524 i915_next_seqno_read 3 62524 &pep_sendmsg_62524
100671 +test_iso_queue_62534 test_iso_queue 5 62534 NULL
100672 +debugfs_read_62535 debugfs_read 3 62535 NULL
100673 +sco_sock_sendmsg_62542 sco_sock_sendmsg 4 62542 NULL
100674 +qib_refresh_qsfp_cache_62547 qib_refresh_qsfp_cache 0 62547 NULL
100675 +xfrm_user_policy_62573 xfrm_user_policy 4 62573 NULL
100676 +get_subdir_62581 get_subdir 3 62581 NULL
100677 +prism2_send_mgmt_62605 prism2_send_mgmt 4 62605 NULL nohasharray
100678 +nfsd_vfs_read_62605 nfsd_vfs_read 6 62605 &prism2_send_mgmt_62605
100679 +iommu_area_alloc_62619 iommu_area_alloc 2-3-4-7 62619 NULL
100680 +ems_pcmcia_add_card_62627 ems_pcmcia_add_card 2 62627 NULL
100681 +compat_rangeinfo_62630 compat_rangeinfo 2 62630 NULL
100682 +lpfc_sli4_queue_alloc_62646 lpfc_sli4_queue_alloc 3 62646 NULL
100683 +memblock_alloc_nid_62652 memblock_alloc_nid 1-2 62652 NULL
100684 +ima_file_mmap_62663 ima_file_mmap 0 62663 NULL
100685 +write_62671 write 3 62671 NULL
100686 +printer_req_alloc_62687 printer_req_alloc 2 62687 NULL
100687 +qla4_83xx_rd_reg_62693 qla4_83xx_rd_reg 0 62693 NULL
100688 +ioremap_wc_62695 ioremap_wc 1-2 62695 NULL
100689 +bioset_integrity_create_62708 bioset_integrity_create 2 62708 NULL
100690 +rdm_62719 rdm 0 62719 NULL
100691 +key_replays_read_62746 key_replays_read 3 62746 NULL
100692 +init_chip_wc_pat_62768 init_chip_wc_pat 2 62768 NULL
100693 +ax25_sendmsg_62770 ax25_sendmsg 4 62770 NULL
100694 +page_key_alloc_62771 page_key_alloc 0 62771 NULL
100695 +tracing_total_entries_read_62817 tracing_total_entries_read 3 62817 NULL
100696 +__rounddown_pow_of_two_62836 __rounddown_pow_of_two 0 62836 NULL
100697 +bio_get_nr_vecs_62838 bio_get_nr_vecs 0 62838 NULL
100698 +xlog_recover_add_to_trans_62839 xlog_recover_add_to_trans 4 62839 NULL
100699 +rx_fcs_err_read_62844 rx_fcs_err_read 3 62844 NULL
100700 +set_swbp_62853 set_swbp 3 62853 NULL
100701 +hpi_read_word_62862 hpi_read_word 0 62862 NULL
100702 +aoechr_write_62883 aoechr_write 3 62883 NULL
100703 +resize_info_buffer_62889 resize_info_buffer 2 62889 NULL
100704 +if_spi_host_to_card_62890 if_spi_host_to_card 4 62890 NULL
100705 +mempool_create_slab_pool_62907 mempool_create_slab_pool 1 62907 NULL
100706 +getdqbuf_62908 getdqbuf 1 62908 NULL
100707 +try_async_pf_62914 try_async_pf 3 62914 NULL
100708 +agp_create_user_memory_62955 agp_create_user_memory 1 62955 NULL
100709 +__vb2_perform_fileio_63033 __vb2_perform_fileio 3 63033 NULL
100710 +pipeline_defrag_to_csum_swi_read_63037 pipeline_defrag_to_csum_swi_read 3 63037 NULL
100711 +scsi_host_alloc_63041 scsi_host_alloc 2 63041 NULL
100712 +unlink1_63059 unlink1 3 63059 NULL
100713 +xen_set_nslabs_63066 xen_set_nslabs 0 63066 NULL
100714 +ocfs2_decrease_refcount_63078 ocfs2_decrease_refcount 3 63078 NULL
100715 +sep_prepare_input_output_dma_table_in_dcb_63087 sep_prepare_input_output_dma_table_in_dcb 4-5-2-3 63087 NULL
100716 +iwl_dbgfs_sensitivity_read_63116 iwl_dbgfs_sensitivity_read 3 63116 NULL
100717 +alloc_cblock_63133 alloc_cblock 2 63133 NULL
100718 +ib_send_cm_rtu_63138 ib_send_cm_rtu 3 63138 NULL
100719 +xen_zap_pfn_range_63149 xen_zap_pfn_range 1 63149 NULL
100720 +smk_write_revoke_subj_63173 smk_write_revoke_subj 3 63173 NULL
100721 +vme_master_read_63221 vme_master_read 0 63221 NULL
100722 +module_alloc_update_bounds_rw_63233 module_alloc_update_bounds_rw 1 63233 NULL
100723 +ptp_read_63251 ptp_read 4 63251 NULL
100724 +raid5_resize_63306 raid5_resize 2 63306 NULL
100725 +proc_info_read_63344 proc_info_read 3 63344 NULL
100726 +ps_upsd_max_sptime_read_63362 ps_upsd_max_sptime_read 3 63362 NULL
100727 +idmouse_read_63374 idmouse_read 3 63374 NULL
100728 +edac_pci_alloc_ctl_info_63388 edac_pci_alloc_ctl_info 1 63388 NULL nohasharray
100729 +usbnet_read_cmd_nopm_63388 usbnet_read_cmd_nopm 7 63388 &edac_pci_alloc_ctl_info_63388
100730 +rxpipe_missed_beacon_host_int_trig_rx_data_read_63405 rxpipe_missed_beacon_host_int_trig_rx_data_read 3 63405 NULL
100731 +nouveau_event_create_63411 nouveau_event_create 1 63411 NULL
100732 +l2cap_sock_sendmsg_63427 l2cap_sock_sendmsg 4 63427 NULL
100733 +sep_prepare_input_output_dma_table_63429 sep_prepare_input_output_dma_table 2-4-3 63429 NULL
100734 +kone_send_63435 kone_send 4 63435 NULL
100735 +gfn_to_hva_many_63437 gfn_to_hva_many 0-2 63437 NULL
100736 +nfsd_symlink_63442 nfsd_symlink 6 63442 NULL
100737 +ipv6_is_mld_63461 ipv6_is_mld 3 63461 NULL
100738 +snd_info_entry_write_63474 snd_info_entry_write 3 63474 NULL
100739 +reada_find_extent_63486 reada_find_extent 2 63486 NULL
100740 +read_kcore_63488 read_kcore 3 63488 NULL
100741 +save_hint_63497 save_hint 2 63497 NULL
100742 +snd_pcm_plug_write_transfer_63503 snd_pcm_plug_write_transfer 0-3 63503 NULL
100743 +ubi_more_leb_change_data_63534 ubi_more_leb_change_data 4 63534 NULL
100744 +if_sdio_read_scratch_63540 if_sdio_read_scratch 0 63540 NULL
100745 +append_to_buffer_63550 append_to_buffer 3 63550 NULL
100746 +dbg_leb_write_63555 dbg_leb_write 4-5 63555 NULL nohasharray
100747 +kvm_write_guest_page_63555 kvm_write_guest_page 5-2 63555 &dbg_leb_write_63555
100748 +ubifs_lpt_scan_nolock_63572 ubifs_lpt_scan_nolock 0 63572 NULL
100749 +iwch_reg_user_mr_63575 iwch_reg_user_mr 2-3 63575 NULL
100750 +ocfs2_calc_trunc_pos_63576 ocfs2_calc_trunc_pos 4 63576 NULL
100751 +rproc_alloc_63577 rproc_alloc 5 63577 NULL
100752 +ext3_clear_blocks_63597 ext3_clear_blocks 4-5 63597 NULL
100753 +module_alloc_63630 module_alloc 1 63630 NULL
100754 +ntfs_malloc_nofs_nofail_63631 ntfs_malloc_nofs_nofail 1 63631 NULL
100755 +symbol_build_supp_rates_63634 symbol_build_supp_rates 0 63634 NULL
100756 +_ubh_find_next_zero_bit__63640 _ubh_find_next_zero_bit_ 4-5-3 63640 NULL
100757 +proc_loginuid_write_63648 proc_loginuid_write 3 63648 NULL
100758 +ValidateDSDParamsChecksum_63654 ValidateDSDParamsChecksum 3 63654 NULL
100759 +hidraw_ioctl_63658 hidraw_ioctl 2 63658 NULL
100760 +vbi_read_63673 vbi_read 3 63673 NULL nohasharray
100761 +xen_register_pirq_63673 xen_register_pirq 1-2 63673 &vbi_read_63673
100762 +alloc_tty_driver_63681 alloc_tty_driver 1 63681 NULL
100763 +mkiss_compat_ioctl_63686 mkiss_compat_ioctl 4 63686 NULL
100764 +arizona_irq_map_63709 arizona_irq_map 2 63709 NULL
100765 +nouveau_object_create__63715 nouveau_object_create_ 5 63715 NULL
100766 +btrfs_insert_delayed_dir_index_63720 btrfs_insert_delayed_dir_index 4 63720 NULL
100767 +selinux_secctx_to_secid_63744 selinux_secctx_to_secid 2 63744 NULL
100768 +snd_pcm_oss_read1_63771 snd_pcm_oss_read1 3 63771 NULL
100769 +snd_opl4_mem_proc_read_63774 snd_opl4_mem_proc_read 5 63774 NULL
100770 +spidev_compat_ioctl_63778 spidev_compat_ioctl 2-3 63778 NULL
100771 +snapshot_compat_ioctl_63792 snapshot_compat_ioctl 3 63792 NULL
100772 +kovaplus_sysfs_write_63795 kovaplus_sysfs_write 6 63795 NULL
100773 +mwifiex_11n_create_rx_reorder_tbl_63806 mwifiex_11n_create_rx_reorder_tbl 4 63806 NULL
100774 +copy_nodes_to_user_63807 copy_nodes_to_user 2 63807 NULL
100775 +sel_write_load_63830 sel_write_load 3 63830 NULL
100776 +proc_pid_attr_write_63845 proc_pid_attr_write 3 63845 NULL
100777 +init_map_ipmac_63896 init_map_ipmac 4-3 63896 NULL
100778 +divas_write_63901 divas_write 3 63901 NULL
100779 +xhci_alloc_stream_info_63902 xhci_alloc_stream_info 3 63902 NULL
100780 +uvc_alloc_urb_buffers_63922 uvc_alloc_urb_buffers 0-3-2 63922 NULL
100781 +snd_compr_write_63923 snd_compr_write 3 63923 NULL
100782 +acpi_ev_get_gpe_xrupt_block_63924 acpi_ev_get_gpe_xrupt_block 1 63924 NULL
100783 +tipc_send2port_63935 tipc_send2port 5 63935 NULL
100784 +afs_send_simple_reply_63940 afs_send_simple_reply 3 63940 NULL
100785 +__team_options_register_63941 __team_options_register 3 63941 NULL
100786 +macvtap_recvmsg_63949 macvtap_recvmsg 4 63949 NULL
100787 +ieee80211_if_fmt_rc_rateidx_mcs_mask_2ghz_63968 ieee80211_if_fmt_rc_rateidx_mcs_mask_2ghz 3 63968 NULL
100788 +ieee80211_authentication_req_63973 ieee80211_authentication_req 3 63973 NULL
100789 +diva_xdi_write_63975 diva_xdi_write 4 63975 NULL
100790 +read_file_frameerrors_64001 read_file_frameerrors 3 64001 NULL
100791 +kmemdup_64015 kmemdup 2 64015 NULL
100792 +offset_to_vaddr_64025 offset_to_vaddr 0-2 64025 NULL nohasharray
100793 +tcf_csum_skb_nextlayer_64025 tcf_csum_skb_nextlayer 3 64025 &offset_to_vaddr_64025
100794 +dbAllocDmapLev_64030 dbAllocDmapLev 0 64030 NULL
100795 +resize_async_buffer_64031 resize_async_buffer 4 64031 NULL
100796 +sep_lli_table_secure_dma_64042 sep_lli_table_secure_dma 2-3 64042 NULL
100797 +get_u8_64076 get_u8 0 64076 NULL
100798 +sl_realloc_bufs_64086 sl_realloc_bufs 2 64086 NULL
100799 +vmci_handle_arr_get_size_64088 vmci_handle_arr_get_size 0 64088 NULL
100800 +lbs_highrssi_read_64089 lbs_highrssi_read 3 64089 NULL
100801 +do_load_xattr_datum_64118 do_load_xattr_datum 0 64118 NULL
100802 +ol_quota_entries_per_block_64122 ol_quota_entries_per_block 0 64122 NULL
100803 +ext4_prepare_inline_data_64124 ext4_prepare_inline_data 3 64124 NULL
100804 +init_bch_64130 init_bch 1-2 64130 NULL
100805 +uea_idma_write_64139 uea_idma_write 3 64139 NULL
100806 +ablkcipher_copy_iv_64140 ablkcipher_copy_iv 3 64140 NULL
100807 +dlfb_ops_write_64150 dlfb_ops_write 3 64150 NULL
100808 +__comedi_buf_alloc_64155 __comedi_buf_alloc 3 64155 NULL
100809 +cpumask_scnprintf_64170 cpumask_scnprintf 2 64170 NULL
100810 +read_pulse_64227 read_pulse 0-3 64227 NULL
100811 +header_len_64232 header_len 0 64232 NULL
100812 +redrat3_transmit_ir_64244 redrat3_transmit_ir 3 64244 NULL
100813 +io_capture_transfer_64276 io_capture_transfer 4 64276 NULL
100814 +btrfs_file_extent_offset_64278 btrfs_file_extent_offset 0 64278 NULL
100815 +sta_current_tx_rate_read_64286 sta_current_tx_rate_read 3 64286 NULL
100816 +event_id_read_64288 event_id_read 3 64288 NULL nohasharray
100817 +xfs_dir_cilookup_result_64288 xfs_dir_cilookup_result 3 64288 &event_id_read_64288
100818 +ocfs2_block_check_validate_bhs_64302 ocfs2_block_check_validate_bhs 0 64302 NULL
100819 +error_error_bar_retry_read_64305 error_error_bar_retry_read 3 64305 NULL
100820 +ffz_64324 ffz 0 64324 NULL
100821 +sisusbcon_clear_64329 sisusbcon_clear 4-3-5 64329 NULL
100822 +ts_write_64336 ts_write 3 64336 NULL
100823 +usbtmc_write_64340 usbtmc_write 3 64340 NULL
100824 +do_write_orph_node_64343 do_write_orph_node 2 64343 NULL
100825 +ft1000_read_reg_64352 ft1000_read_reg 0 64352 NULL
100826 +bnx2x_vfop_mcast_cmd_64354 bnx2x_vfop_mcast_cmd 5 64354 NULL
100827 +wlc_phy_loadsampletable_nphy_64367 wlc_phy_loadsampletable_nphy 3 64367 NULL
100828 +ilo_write_64378 ilo_write 3 64378 NULL
100829 +btrfs_map_block_64379 btrfs_map_block 3 64379 NULL
100830 +vmcs_readl_64381 vmcs_readl 0 64381 NULL
100831 +nilfs_alloc_seg_bio_64383 nilfs_alloc_seg_bio 3 64383 NULL
100832 +ir_lirc_transmit_ir_64403 ir_lirc_transmit_ir 3 64403 NULL
100833 +pidlist_allocate_64404 pidlist_allocate 1 64404 NULL
100834 +rx_hdr_overflow_read_64407 rx_hdr_overflow_read 3 64407 NULL
100835 +snd_card_create_64418 snd_card_create 4 64418 NULL nohasharray
100836 +keyctl_get_security_64418 keyctl_get_security 3 64418 &snd_card_create_64418
100837 +nl80211_send_mgmt_64419 nl80211_send_mgmt 7 64419 NULL
100838 +oom_adj_write_64428 oom_adj_write 3 64428 NULL
100839 +ext4_trim_extent_64431 ext4_trim_extent 4 64431 NULL nohasharray
100840 +read_file_spectral_short_repeat_64431 read_file_spectral_short_repeat 3 64431 &ext4_trim_extent_64431
100841 +cap_capable_64462 cap_capable 0 64462 NULL
100842 +ip_vs_create_timeout_table_64478 ip_vs_create_timeout_table 2 64478 NULL
100843 +p54_parse_rssical_64493 p54_parse_rssical 3 64493 NULL
100844 +msg_data_sz_64503 msg_data_sz 0 64503 NULL
100845 +remove_uuid_64505 remove_uuid 4 64505 NULL nohasharray
100846 +handle_abnormal_pfn_64505 handle_abnormal_pfn 3 64505 &remove_uuid_64505
100847 +crypto_blkcipher_alignmask_64520 crypto_blkcipher_alignmask 0 64520 NULL
100848 +opera1_usb_i2c_msgxfer_64521 opera1_usb_i2c_msgxfer 4 64521 NULL
100849 +ses_send_diag_64527 ses_send_diag 4 64527 NULL
100850 +prctl_set_mm_64538 prctl_set_mm 3 64538 NULL
100851 +__spi_sync_64561 __spi_sync 0 64561 NULL
100852 +__apei_exec_run_64563 __apei_exec_run 0 64563 NULL
100853 +fanotify_write_64623 fanotify_write 3 64623 NULL
100854 +to_dblock_64655 to_dblock 0-1 64655 NULL
100855 +regmap_read_debugfs_64658 regmap_read_debugfs 5 64658 NULL
100856 +ocfs2_read_xattr_block_64661 ocfs2_read_xattr_block 0 64661 NULL nohasharray
100857 +tlbflush_read_file_64661 tlbflush_read_file 3 64661 &ocfs2_read_xattr_block_64661
100858 +efx_tsoh_get_buffer_64664 efx_tsoh_get_buffer 3 64664 NULL
100859 +rx_rx_out_of_mpdu_nodes_read_64668 rx_rx_out_of_mpdu_nodes_read 3 64668 NULL
100860 +nr_free_zone_pages_64680 nr_free_zone_pages 0 64680 NULL
100861 +sec_bulk_write_64691 sec_bulk_write 2-3 64691 NULL
100862 +__feat_register_sp_64712 __feat_register_sp 6 64712 NULL
100863 +snd_pcm_oss_capture_position_fixup_64713 snd_pcm_oss_capture_position_fixup 0 64713 NULL
100864 +dapm_bias_read_file_64715 dapm_bias_read_file 3 64715 NULL
100865 +atomic_add_return_64720 atomic_add_return 0-1 64720 NULL
100866 +i2400m_msg_to_dev_64722 i2400m_msg_to_dev 3 64722 NULL
100867 +squashfs_read_inode_lookup_table_64739 squashfs_read_inode_lookup_table 4 64739 NULL
100868 +bio_map_kern_64751 bio_map_kern 3 64751 NULL
100869 +rt2x00debug_write_csr_64753 rt2x00debug_write_csr 3 64753 NULL
100870 +isr_low_rssi_read_64789 isr_low_rssi_read 3 64789 NULL
100871 +nfsctl_transaction_write_64800 nfsctl_transaction_write 3 64800 NULL
100872 +megaraid_change_queue_depth_64815 megaraid_change_queue_depth 2 64815 NULL
100873 +ecryptfs_send_miscdev_64816 ecryptfs_send_miscdev 2 64816 NULL
100874 +vaddr_get_pfn_64818 vaddr_get_pfn 1 64818 NULL
100875 +gfn_to_page_64826 gfn_to_page 2 64826 NULL
100876 +do_kimage_alloc_64827 do_kimage_alloc 3 64827 NULL
100877 +altera_set_dr_pre_64862 altera_set_dr_pre 2 64862 NULL
100878 +gfn_to_pfn_64870 gfn_to_pfn 2 64870 NULL
100879 +ffs_epfile_io_64886 ffs_epfile_io 3 64886 NULL
100880 +ieee80211_if_read_ave_beacon_64924 ieee80211_if_read_ave_beacon 3 64924 NULL
100881 +ubifs_wbuf_write_nolock_64946 ubifs_wbuf_write_nolock 3 64946 NULL
100882 +snd_rawmidi_ioctl_compat_64954 snd_rawmidi_ioctl_compat 3 64954 NULL
100883 +ip_options_get_from_user_64958 ip_options_get_from_user 4 64958 NULL
100884 +acpi_os_install_interrupt_handler_64968 acpi_os_install_interrupt_handler 1 64968 NULL
100885 +traceprobe_probes_write_64969 traceprobe_probes_write 3 64969 NULL
100886 +suspend_dtim_interval_read_64971 suspend_dtim_interval_read 3 64971 NULL
100887 +ext2_group_first_block_no_64972 ext2_group_first_block_no 0-2 64972 NULL
100888 +pskb_pull_65005 pskb_pull 2 65005 NULL
100889 +unifi_write_65012 unifi_write 3 65012 NULL
100890 +crypto_ahash_digestsize_65014 crypto_ahash_digestsize 0 65014 NULL
100891 +nfs_readdata_alloc_65015 nfs_readdata_alloc 2 65015 NULL
100892 +insert_dent_65034 insert_dent 7 65034 NULL
100893 +compat_put_ushort_65040 compat_put_ushort 1 65040 NULL
100894 +brcmf_sdcard_rwdata_65041 brcmf_sdcard_rwdata 5 65041 NULL
100895 +tty_audit_log_65043 tty_audit_log 8 65043 NULL
100896 +compat_cmdtest_65064 compat_cmdtest 2 65064 NULL
100897 +count_run_65072 count_run 0-2-4 65072 NULL nohasharray
100898 +bnx2fc_process_l2_frame_compl_65072 bnx2fc_process_l2_frame_compl 3 65072 &count_run_65072
100899 +__alloc_bootmem_node_high_65076 __alloc_bootmem_node_high 2-3 65076 NULL
100900 +ocfs2_truncate_cluster_pages_65086 ocfs2_truncate_cluster_pages 2 65086 NULL
100901 +ath9k_dump_mci_btcoex_65090 ath9k_dump_mci_btcoex 0 65090 NULL
100902 +ssb_bus_register_65183 ssb_bus_register 3 65183 NULL
100903 +rx_rx_done_read_65217 rx_rx_done_read 3 65217 NULL
100904 +print_endpoint_stat_65232 print_endpoint_stat 3-4-0 65232 NULL
100905 +whci_n_caps_65247 whci_n_caps 0 65247 NULL
100906 +kmem_zalloc_greedy_65268 kmem_zalloc_greedy 3-2 65268 NULL
100907 +kmalloc_parameter_65279 kmalloc_parameter 1 65279 NULL
100908 +compat_core_sys_select_65285 compat_core_sys_select 1 65285 NULL
100909 +mpi_set_buffer_65294 mpi_set_buffer 3 65294 NULL
100910 +redirected_tty_write_65297 redirected_tty_write 3 65297 NULL
100911 +get_var_len_65304 get_var_len 0 65304 NULL
100912 +unpack_array_65318 unpack_array 0 65318 NULL
100913 +pci_vpd_find_tag_65325 pci_vpd_find_tag 0-2 65325 NULL
100914 +dccp_setsockopt_service_65336 dccp_setsockopt_service 4 65336 NULL
100915 +dma_rx_requested_read_65354 dma_rx_requested_read 3 65354 NULL
100916 +batadv_tt_save_orig_buffer_65361 batadv_tt_save_orig_buffer 4 65361 NULL
100917 +alloc_cpu_rmap_65363 alloc_cpu_rmap 1 65363 NULL
100918 +__ext4_new_inode_65370 __ext4_new_inode 5 65370 NULL
100919 +strchr_65372 strchr 0 65372 NULL
100920 +__alloc_bootmem_nopanic_65397 __alloc_bootmem_nopanic 1-2 65397 NULL
100921 +trace_seq_to_user_65398 trace_seq_to_user 3 65398 NULL
100922 +mtd_get_device_size_65400 mtd_get_device_size 0 65400 NULL
100923 +iio_device_add_channel_sysfs_65406 iio_device_add_channel_sysfs 0 65406 NULL
100924 +ocfs2_write_begin_nolock_65410 ocfs2_write_begin_nolock 3-4 65410 NULL
100925 +drm_calloc_large_65421 drm_calloc_large 1-2 65421 NULL
100926 +xpc_kzalloc_cacheline_aligned_65433 xpc_kzalloc_cacheline_aligned 1 65433 NULL
100927 +usb_alloc_coherent_65444 usb_alloc_coherent 2 65444 NULL
100928 +ath_rx_edma_init_65483 ath_rx_edma_init 2 65483 NULL
100929 +dpcm_state_read_file_65489 dpcm_state_read_file 3 65489 NULL
100930 +alloc_dr_65495 alloc_dr 2 65495 NULL
100931 diff --git a/tools/gcc/size_overflow_plugin.c b/tools/gcc/size_overflow_plugin.c
100932 new file mode 100644
100933 index 0000000..9db0d0e
100934 --- /dev/null
100935 +++ b/tools/gcc/size_overflow_plugin.c
100936 @@ -0,0 +1,2114 @@
100937 +/*
100938 + * Copyright 2011, 2012, 2013 by Emese Revfy <re.emese@gmail.com>
100939 + * Licensed under the GPL v2, or (at your option) v3
100940 + *
100941 + * Homepage:
100942 + * http://www.grsecurity.net/~ephox/overflow_plugin/
100943 + *
100944 + * Documentation:
100945 + * http://forums.grsecurity.net/viewtopic.php?f=7&t=3043
100946 + *
100947 + * This plugin recomputes expressions of function arguments marked by a size_overflow attribute
100948 + * with double integer precision (DImode/TImode for 32/64 bit integer types).
100949 + * The recomputed argument is checked against TYPE_MAX and an event is logged on overflow and the triggering process is killed.
100950 + *
100951 + * Usage:
100952 + * $ 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
100953 + * $ gcc -fplugin=size_overflow_plugin.so test.c -O2
100954 + */
100955 +
100956 +#include "gcc-plugin.h"
100957 +#include "config.h"
100958 +#include "system.h"
100959 +#include "coretypes.h"
100960 +#include "tree.h"
100961 +#include "tree-pass.h"
100962 +#include "intl.h"
100963 +#include "plugin-version.h"
100964 +#include "tm.h"
100965 +#include "toplev.h"
100966 +#include "function.h"
100967 +#include "tree-flow.h"
100968 +#include "plugin.h"
100969 +#include "gimple.h"
100970 +#include "diagnostic.h"
100971 +#include "cfgloop.h"
100972 +
100973 +#if BUILDING_GCC_VERSION >= 4008
100974 +#define TODO_dump_func 0
100975 +#endif
100976 +
100977 +struct size_overflow_hash {
100978 + const struct size_overflow_hash * const next;
100979 + const char * const name;
100980 + const unsigned int param;
100981 +};
100982 +
100983 +#include "size_overflow_hash.h"
100984 +
100985 +enum mark {
100986 + MARK_NO, MARK_YES, MARK_NOT_INTENTIONAL, MARK_TURN_OFF
100987 +};
100988 +
100989 +enum err_code_conditions {
100990 + CAST_ONLY, FROM_CONST
100991 +};
100992 +
100993 +static unsigned int call_count = 0;
100994 +
100995 +#define __unused __attribute__((__unused__))
100996 +#define NAME(node) IDENTIFIER_POINTER(DECL_NAME(node))
100997 +#define NAME_LEN(node) IDENTIFIER_LENGTH(DECL_NAME(node))
100998 +#define BEFORE_STMT true
100999 +#define AFTER_STMT false
101000 +#define CREATE_NEW_VAR NULL_TREE
101001 +#define CODES_LIMIT 32
101002 +#define MAX_PARAM 31
101003 +#define MY_STMT GF_PLF_1
101004 +#define NO_CAST_CHECK GF_PLF_2
101005 +#define FROM_ARG true
101006 +#define FROM_RET false
101007 +
101008 +#if BUILDING_GCC_VERSION == 4005
101009 +#define DECL_CHAIN(NODE) (TREE_CHAIN(DECL_MINIMAL_CHECK(NODE)))
101010 +#endif
101011 +
101012 +int plugin_is_GPL_compatible;
101013 +void debug_gimple_stmt(gimple gs);
101014 +
101015 +static tree expand(struct pointer_set_t *visited, tree lhs);
101016 +static enum mark pre_expand(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs);
101017 +static tree report_size_overflow_decl;
101018 +static const_tree const_char_ptr_type_node;
101019 +static unsigned int handle_function(void);
101020 +static void check_size_overflow(gimple stmt, tree size_overflow_type, tree cast_rhs, tree rhs, bool before);
101021 +static tree get_size_overflow_type(gimple stmt, const_tree node);
101022 +static tree dup_assign(struct pointer_set_t *visited, gimple oldstmt, const_tree node, tree rhs1, tree rhs2, tree __unused rhs3);
101023 +static void print_missing_msg(tree func, unsigned int argnum);
101024 +
101025 +static struct plugin_info size_overflow_plugin_info = {
101026 + .version = "20130410beta",
101027 + .help = "no-size-overflow\tturn off size overflow checking\n",
101028 +};
101029 +
101030 +static tree handle_size_overflow_attribute(tree *node, tree __unused name, tree args, int __unused flags, bool *no_add_attrs)
101031 +{
101032 + unsigned int arg_count;
101033 + enum tree_code code = TREE_CODE(*node);
101034 +
101035 + switch (code) {
101036 + case FUNCTION_DECL:
101037 + arg_count = type_num_arguments(TREE_TYPE(*node));
101038 + break;
101039 + case FUNCTION_TYPE:
101040 + case METHOD_TYPE:
101041 + arg_count = type_num_arguments(*node);
101042 + break;
101043 + default:
101044 + *no_add_attrs = true;
101045 + error("%s: %qE attribute only applies to functions", __func__, name);
101046 + return NULL_TREE;
101047 + }
101048 +
101049 + for (; args; args = TREE_CHAIN(args)) {
101050 + tree position = TREE_VALUE(args);
101051 + if (TREE_CODE(position) != INTEGER_CST || TREE_INT_CST_LOW(position) > arg_count ) {
101052 + error("%s: parameter %u is outside range.", __func__, (unsigned int)TREE_INT_CST_LOW(position));
101053 + *no_add_attrs = true;
101054 + }
101055 + }
101056 + return NULL_TREE;
101057 +}
101058 +
101059 +static const char* get_asm_name(tree node)
101060 +{
101061 + return IDENTIFIER_POINTER(DECL_ASSEMBLER_NAME(node));
101062 +}
101063 +
101064 +static tree handle_intentional_overflow_attribute(tree *node, tree __unused name, tree args, int __unused flags, bool *no_add_attrs)
101065 +{
101066 + unsigned int arg_count, arg_num;
101067 + enum tree_code code = TREE_CODE(*node);
101068 +
101069 + switch (code) {
101070 + case FUNCTION_DECL:
101071 + arg_count = type_num_arguments(TREE_TYPE(*node));
101072 + break;
101073 + case FUNCTION_TYPE:
101074 + case METHOD_TYPE:
101075 + arg_count = type_num_arguments(*node);
101076 + break;
101077 + case FIELD_DECL:
101078 + arg_num = TREE_INT_CST_LOW(TREE_VALUE(args));
101079 + if (arg_num != 0) {
101080 + *no_add_attrs = true;
101081 + error("%s: %qE attribute parameter can only be 0 in structure fields", __func__, name);
101082 + }
101083 + return NULL_TREE;
101084 + default:
101085 + *no_add_attrs = true;
101086 + error("%qE attribute only applies to functions", name);
101087 + return NULL_TREE;
101088 + }
101089 +
101090 + if (TREE_INT_CST_HIGH(TREE_VALUE(args)) != 0)
101091 + return NULL_TREE;
101092 +
101093 + for (; args; args = TREE_CHAIN(args)) {
101094 + tree position = TREE_VALUE(args);
101095 + if (TREE_CODE(position) != INTEGER_CST || TREE_INT_CST_LOW(position) > arg_count ) {
101096 + error("%s: parameter %u is outside range.", __func__, (unsigned int)TREE_INT_CST_LOW(position));
101097 + *no_add_attrs = true;
101098 + }
101099 + }
101100 + return NULL_TREE;
101101 +}
101102 +
101103 +static struct attribute_spec size_overflow_attr = {
101104 + .name = "size_overflow",
101105 + .min_length = 1,
101106 + .max_length = -1,
101107 + .decl_required = true,
101108 + .type_required = false,
101109 + .function_type_required = false,
101110 + .handler = handle_size_overflow_attribute,
101111 +#if BUILDING_GCC_VERSION >= 4007
101112 + .affects_type_identity = false
101113 +#endif
101114 +};
101115 +
101116 +static struct attribute_spec intentional_overflow_attr = {
101117 + .name = "intentional_overflow",
101118 + .min_length = 1,
101119 + .max_length = -1,
101120 + .decl_required = true,
101121 + .type_required = false,
101122 + .function_type_required = false,
101123 + .handler = handle_intentional_overflow_attribute,
101124 +#if BUILDING_GCC_VERSION >= 4007
101125 + .affects_type_identity = false
101126 +#endif
101127 +};
101128 +
101129 +static void register_attributes(void __unused *event_data, void __unused *data)
101130 +{
101131 + register_attribute(&size_overflow_attr);
101132 + register_attribute(&intentional_overflow_attr);
101133 +}
101134 +
101135 +// http://www.team5150.com/~andrew/noncryptohashzoo2~/CrapWow.html
101136 +static unsigned int CrapWow(const char *key, unsigned int len, unsigned int seed)
101137 +{
101138 +#define cwfold( a, b, lo, hi ) { p = (unsigned int)(a) * (unsigned long long)(b); lo ^= (unsigned int)p; hi ^= (unsigned int)(p >> 32); }
101139 +#define cwmixa( in ) { cwfold( in, m, k, h ); }
101140 +#define cwmixb( in ) { cwfold( in, n, h, k ); }
101141 +
101142 + unsigned int m = 0x57559429;
101143 + unsigned int n = 0x5052acdb;
101144 + const unsigned int *key4 = (const unsigned int *)key;
101145 + unsigned int h = len;
101146 + unsigned int k = len + seed + n;
101147 + unsigned long long p;
101148 +
101149 + while (len >= 8) {
101150 + cwmixb(key4[0]) cwmixa(key4[1]) key4 += 2;
101151 + len -= 8;
101152 + }
101153 + if (len >= 4) {
101154 + cwmixb(key4[0]) key4 += 1;
101155 + len -= 4;
101156 + }
101157 + if (len)
101158 + cwmixa(key4[0] & ((1 << (len * 8)) - 1 ));
101159 + cwmixb(h ^ (k + n));
101160 + return k ^ h;
101161 +
101162 +#undef cwfold
101163 +#undef cwmixa
101164 +#undef cwmixb
101165 +}
101166 +
101167 +static inline unsigned int get_hash_num(const char *fndecl, const char *tree_codes, unsigned int len, unsigned int seed)
101168 +{
101169 + unsigned int fn = CrapWow(fndecl, strlen(fndecl), seed) & 0xffff;
101170 + unsigned int codes = CrapWow(tree_codes, len, seed) & 0xffff;
101171 + return fn ^ codes;
101172 +}
101173 +
101174 +static inline tree get_original_function_decl(tree fndecl)
101175 +{
101176 + if (DECL_ABSTRACT_ORIGIN(fndecl))
101177 + return DECL_ABSTRACT_ORIGIN(fndecl);
101178 + return fndecl;
101179 +}
101180 +
101181 +static inline gimple get_def_stmt(const_tree node)
101182 +{
101183 + gcc_assert(node != NULL_TREE);
101184 + if (TREE_CODE(node) != SSA_NAME)
101185 + return NULL;
101186 + return SSA_NAME_DEF_STMT(node);
101187 +}
101188 +
101189 +static unsigned char get_tree_code(const_tree type)
101190 +{
101191 + switch (TREE_CODE(type)) {
101192 + case ARRAY_TYPE:
101193 + return 0;
101194 + case BOOLEAN_TYPE:
101195 + return 1;
101196 + case ENUMERAL_TYPE:
101197 + return 2;
101198 + case FUNCTION_TYPE:
101199 + return 3;
101200 + case INTEGER_TYPE:
101201 + return 4;
101202 + case POINTER_TYPE:
101203 + return 5;
101204 + case RECORD_TYPE:
101205 + return 6;
101206 + case UNION_TYPE:
101207 + return 7;
101208 + case VOID_TYPE:
101209 + return 8;
101210 + case REAL_TYPE:
101211 + return 9;
101212 + case VECTOR_TYPE:
101213 + return 10;
101214 + case REFERENCE_TYPE:
101215 + return 11;
101216 + case OFFSET_TYPE:
101217 + return 12;
101218 + case COMPLEX_TYPE:
101219 + return 13;
101220 + default:
101221 + debug_tree((tree)type);
101222 + gcc_unreachable();
101223 + }
101224 +}
101225 +
101226 +static size_t add_type_codes(const_tree type, unsigned char *tree_codes, size_t len)
101227 +{
101228 + gcc_assert(type != NULL_TREE);
101229 +
101230 + while (type && len < CODES_LIMIT) {
101231 + tree_codes[len] = get_tree_code(type);
101232 + len++;
101233 + type = TREE_TYPE(type);
101234 + }
101235 + return len;
101236 +}
101237 +
101238 +static unsigned int get_function_decl(const_tree fndecl, unsigned char *tree_codes)
101239 +{
101240 + const_tree arg, result, arg_field, type = TREE_TYPE(fndecl);
101241 + enum tree_code code = TREE_CODE(type);
101242 + size_t len = 0;
101243 +
101244 + gcc_assert(code == FUNCTION_TYPE || code == METHOD_TYPE);
101245 +
101246 + arg = TYPE_ARG_TYPES(type);
101247 + // skip builtins __builtin_constant_p
101248 + if (!arg && DECL_BUILT_IN(fndecl))
101249 + return 0;
101250 +
101251 + if (TREE_CODE_CLASS(code) == tcc_type)
101252 + result = type;
101253 + else
101254 + result = DECL_RESULT(fndecl);
101255 +
101256 + gcc_assert(result != NULL_TREE);
101257 + len = add_type_codes(TREE_TYPE(result), tree_codes, len);
101258 +
101259 + if (arg == NULL_TREE) {
101260 + gcc_assert(CODE_CONTAINS_STRUCT(TREE_CODE(fndecl), TS_DECL_NON_COMMON));
101261 + arg_field = DECL_ARGUMENT_FLD(fndecl);
101262 + if (arg_field == NULL_TREE)
101263 + return 0;
101264 + arg = TREE_TYPE(arg_field);
101265 + len = add_type_codes(arg, tree_codes, len);
101266 + gcc_assert(len != 0);
101267 + return len;
101268 + }
101269 +
101270 + gcc_assert(arg != NULL_TREE && TREE_CODE(arg) == TREE_LIST);
101271 + while (arg && len < CODES_LIMIT) {
101272 + len = add_type_codes(TREE_VALUE(arg), tree_codes, len);
101273 + arg = TREE_CHAIN(arg);
101274 + }
101275 +
101276 + gcc_assert(len != 0);
101277 + return len;
101278 +}
101279 +
101280 +static const struct size_overflow_hash *get_function_hash(tree fndecl)
101281 +{
101282 + unsigned int hash;
101283 + const struct size_overflow_hash *entry;
101284 + unsigned char tree_codes[CODES_LIMIT];
101285 + size_t len;
101286 + const char *func_name;
101287 +
101288 + fndecl = get_original_function_decl(fndecl);
101289 + len = get_function_decl(fndecl, tree_codes);
101290 + if (len == 0)
101291 + return NULL;
101292 +
101293 + func_name = get_asm_name(fndecl);
101294 + hash = get_hash_num(func_name, (const char*) tree_codes, len, 0);
101295 +
101296 + entry = size_overflow_hash[hash];
101297 + while (entry) {
101298 + if (!strcmp(entry->name, func_name))
101299 + return entry;
101300 + entry = entry->next;
101301 + }
101302 +
101303 + return NULL;
101304 +}
101305 +
101306 +static bool is_bool(const_tree node)
101307 +{
101308 + const_tree type;
101309 +
101310 + if (node == NULL_TREE)
101311 + return false;
101312 +
101313 + type = TREE_TYPE(node);
101314 + if (!INTEGRAL_TYPE_P(type))
101315 + return false;
101316 + if (TREE_CODE(type) == BOOLEAN_TYPE)
101317 + return true;
101318 + if (TYPE_PRECISION(type) == 1)
101319 + return true;
101320 + return false;
101321 +}
101322 +
101323 +static bool skip_types(const_tree var)
101324 +{
101325 + tree type;
101326 +
101327 + if (is_gimple_constant(var))
101328 + return true;
101329 +
101330 + switch (TREE_CODE(var)) {
101331 + case ADDR_EXPR:
101332 +#if BUILDING_GCC_VERSION >= 4006
101333 + case MEM_REF:
101334 +#endif
101335 + case ARRAY_REF:
101336 + case BIT_FIELD_REF:
101337 + case INDIRECT_REF:
101338 + case TARGET_MEM_REF:
101339 + return true;
101340 + case PARM_DECL:
101341 + case VAR_DECL:
101342 + case COMPONENT_REF:
101343 + return false;
101344 + default:
101345 + break;
101346 + }
101347 +
101348 + gcc_assert(TREE_CODE(var) == SSA_NAME);
101349 +
101350 + type = TREE_TYPE(var);
101351 + switch (TREE_CODE(type)) {
101352 + case INTEGER_TYPE:
101353 + case ENUMERAL_TYPE:
101354 + return false;
101355 + case BOOLEAN_TYPE:
101356 + return is_bool(var);
101357 + default:
101358 + break;
101359 + }
101360 +
101361 + gcc_assert(TREE_CODE(type) == POINTER_TYPE);
101362 +
101363 + type = TREE_TYPE(type);
101364 + gcc_assert(type != NULL_TREE);
101365 + switch (TREE_CODE(type)) {
101366 + case RECORD_TYPE:
101367 + case POINTER_TYPE:
101368 + case ARRAY_TYPE:
101369 + return true;
101370 + case VOID_TYPE:
101371 + case INTEGER_TYPE:
101372 + case UNION_TYPE:
101373 + return false;
101374 + default:
101375 + break;
101376 + }
101377 +
101378 + debug_tree((tree)var);
101379 + gcc_unreachable();
101380 +}
101381 +
101382 +static unsigned int find_arg_number(const_tree arg, tree func)
101383 +{
101384 + tree var;
101385 + unsigned int argnum = 1;
101386 +
101387 + if (TREE_CODE(arg) == SSA_NAME)
101388 + arg = SSA_NAME_VAR(arg);
101389 +
101390 + for (var = DECL_ARGUMENTS(func); var; var = TREE_CHAIN(var), argnum++) {
101391 + if (!operand_equal_p(arg, var, 0) && strcmp(NAME(var), NAME(arg)))
101392 + continue;
101393 + if (!skip_types(var))
101394 + return argnum;
101395 + }
101396 +
101397 + return 0;
101398 +}
101399 +
101400 +static tree create_new_var(tree type)
101401 +{
101402 + tree new_var = create_tmp_var(type, "cicus");
101403 +
101404 +#if BUILDING_GCC_VERSION <= 4007
101405 + add_referenced_var(new_var);
101406 + mark_sym_for_renaming(new_var);
101407 +#endif
101408 + return new_var;
101409 +}
101410 +
101411 +static gimple create_binary_assign(enum tree_code code, gimple stmt, tree rhs1, tree rhs2)
101412 +{
101413 + gimple assign;
101414 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
101415 + tree type = TREE_TYPE(rhs1);
101416 + tree lhs = create_new_var(type);
101417 +
101418 + gcc_assert(types_compatible_p(type, TREE_TYPE(rhs2)));
101419 + assign = gimple_build_assign_with_ops(code, lhs, rhs1, rhs2);
101420 + gimple_set_lhs(assign, make_ssa_name(lhs, assign));
101421 +
101422 + gsi_insert_before(&gsi, assign, GSI_NEW_STMT);
101423 + update_stmt(assign);
101424 + gimple_set_plf(assign, MY_STMT, true);
101425 + return assign;
101426 +}
101427 +
101428 +static tree cast_a_tree(tree type, tree var)
101429 +{
101430 + gcc_assert(type != NULL_TREE);
101431 + gcc_assert(var != NULL_TREE);
101432 + gcc_assert(fold_convertible_p(type, var));
101433 +
101434 + return fold_convert(type, var);
101435 +}
101436 +
101437 +static tree get_lhs(const_gimple stmt)
101438 +{
101439 + switch (gimple_code(stmt)) {
101440 + case GIMPLE_ASSIGN:
101441 + return gimple_get_lhs(stmt);
101442 + case GIMPLE_PHI:
101443 + return gimple_phi_result(stmt);
101444 + case GIMPLE_CALL:
101445 + return gimple_call_lhs(stmt);
101446 + default:
101447 + return NULL_TREE;
101448 + }
101449 +}
101450 +
101451 +static bool skip_cast(tree dst_type, const_tree rhs, bool force)
101452 +{
101453 + const_gimple def_stmt = get_def_stmt(rhs);
101454 +
101455 + if (force)
101456 + return false;
101457 +
101458 + if (is_gimple_constant(rhs))
101459 + return false;
101460 +
101461 + if (!def_stmt || gimple_code(def_stmt) == GIMPLE_NOP)
101462 + return false;
101463 +
101464 + if (!types_compatible_p(dst_type, TREE_TYPE(rhs)))
101465 + return false;
101466 +
101467 + // DI type can be on 32 bit (from create_assign) but overflow type stays DI
101468 + if (LONG_TYPE_SIZE == GET_MODE_BITSIZE(SImode))
101469 + return false;
101470 +
101471 + return true;
101472 +}
101473 +
101474 +static gimple build_cast_stmt(tree dst_type, tree rhs, tree lhs, gimple_stmt_iterator *gsi, bool before, bool force)
101475 +{
101476 + gimple assign, def_stmt;
101477 +
101478 + gcc_assert(dst_type != NULL_TREE && rhs != NULL_TREE);
101479 + if (gsi_end_p(*gsi) && before == AFTER_STMT)
101480 + gcc_unreachable();
101481 +
101482 + def_stmt = get_def_stmt(rhs);
101483 + if (skip_cast(dst_type, rhs, force) && gimple_plf(def_stmt, MY_STMT))
101484 + return def_stmt;
101485 +
101486 + if (lhs == CREATE_NEW_VAR)
101487 + lhs = create_new_var(dst_type);
101488 +
101489 + assign = gimple_build_assign(lhs, cast_a_tree(dst_type, rhs));
101490 +
101491 + if (!gsi_end_p(*gsi)) {
101492 + location_t loc = gimple_location(gsi_stmt(*gsi));
101493 + gimple_set_location(assign, loc);
101494 + }
101495 +
101496 + gimple_set_lhs(assign, make_ssa_name(lhs, assign));
101497 +
101498 + if (before)
101499 + gsi_insert_before(gsi, assign, GSI_NEW_STMT);
101500 + else
101501 + gsi_insert_after(gsi, assign, GSI_NEW_STMT);
101502 + update_stmt(assign);
101503 + gimple_set_plf(assign, MY_STMT, true);
101504 +
101505 + return assign;
101506 +}
101507 +
101508 +static tree cast_to_new_size_overflow_type(gimple stmt, tree rhs, tree size_overflow_type, bool before)
101509 +{
101510 + gimple_stmt_iterator gsi;
101511 + tree lhs;
101512 + const_gimple new_stmt;
101513 +
101514 + if (rhs == NULL_TREE)
101515 + return NULL_TREE;
101516 +
101517 + gsi = gsi_for_stmt(stmt);
101518 + new_stmt = build_cast_stmt(size_overflow_type, rhs, CREATE_NEW_VAR, &gsi, before, false);
101519 +
101520 + lhs = get_lhs(new_stmt);
101521 + gcc_assert(lhs != NULL_TREE);
101522 + return lhs;
101523 +}
101524 +
101525 +static tree cast_to_TI_type(gimple stmt, tree node)
101526 +{
101527 + gimple_stmt_iterator gsi;
101528 + gimple cast_stmt;
101529 + tree type = TREE_TYPE(node);
101530 +
101531 + if (types_compatible_p(type, intTI_type_node))
101532 + return node;
101533 +
101534 + gsi = gsi_for_stmt(stmt);
101535 + cast_stmt = build_cast_stmt(intTI_type_node, node, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
101536 + return gimple_get_lhs(cast_stmt);
101537 +}
101538 +
101539 +static void check_function_hash(const_gimple stmt)
101540 +{
101541 + tree func;
101542 + const struct size_overflow_hash *hash;
101543 +
101544 + if (gimple_code(stmt) != GIMPLE_CALL)
101545 + return;
101546 +
101547 + func = gimple_call_fndecl(stmt);
101548 + //fs/xattr.c D.34222_15 = D.34219_14 (dentry_3(D), name_7(D), 0B, 0);
101549 + if (func == NULL_TREE)
101550 + return;
101551 +
101552 + hash = get_function_hash(func);
101553 + if (!hash)
101554 + print_missing_msg(func, 0);
101555 +}
101556 +
101557 +static tree create_assign(struct pointer_set_t *visited, gimple oldstmt, tree rhs1, bool before)
101558 +{
101559 + tree lhs, new_lhs;
101560 + gimple_stmt_iterator gsi;
101561 +
101562 + if (rhs1 == NULL_TREE) {
101563 + debug_gimple_stmt(oldstmt);
101564 + error("%s: rhs1 is NULL_TREE", __func__);
101565 + gcc_unreachable();
101566 + }
101567 +
101568 + switch (gimple_code(oldstmt)) {
101569 + case GIMPLE_ASM:
101570 + lhs = rhs1;
101571 + break;
101572 + case GIMPLE_CALL:
101573 + lhs = gimple_call_lhs(oldstmt);
101574 + break;
101575 + case GIMPLE_ASSIGN:
101576 + lhs = gimple_get_lhs(oldstmt);
101577 + break;
101578 + default:
101579 + debug_gimple_stmt(oldstmt);
101580 + gcc_unreachable();
101581 + }
101582 +
101583 + gsi = gsi_for_stmt(oldstmt);
101584 + pointer_set_insert(visited, oldstmt);
101585 + if (lookup_stmt_eh_lp(oldstmt) != 0) {
101586 + basic_block next_bb, cur_bb;
101587 + const_edge e;
101588 +
101589 + gcc_assert(before == false);
101590 + gcc_assert(stmt_can_throw_internal(oldstmt));
101591 + gcc_assert(gimple_code(oldstmt) == GIMPLE_CALL);
101592 + gcc_assert(!gsi_end_p(gsi));
101593 +
101594 + cur_bb = gimple_bb(oldstmt);
101595 + next_bb = cur_bb->next_bb;
101596 + e = find_edge(cur_bb, next_bb);
101597 + gcc_assert(e != NULL);
101598 + gcc_assert(e->flags & EDGE_FALLTHRU);
101599 +
101600 + gsi = gsi_after_labels(next_bb);
101601 + gcc_assert(!gsi_end_p(gsi));
101602 +
101603 + before = true;
101604 + oldstmt = gsi_stmt(gsi);
101605 + }
101606 +
101607 + new_lhs = cast_to_new_size_overflow_type(oldstmt, rhs1, get_size_overflow_type(oldstmt, lhs), before);
101608 + return new_lhs;
101609 +}
101610 +
101611 +static tree dup_assign(struct pointer_set_t *visited, gimple oldstmt, const_tree node, tree rhs1, tree rhs2, tree __unused rhs3)
101612 +{
101613 + gimple stmt;
101614 + gimple_stmt_iterator gsi;
101615 + tree size_overflow_type, new_var, lhs = gimple_get_lhs(oldstmt);
101616 +
101617 + if (gimple_plf(oldstmt, MY_STMT))
101618 + return lhs;
101619 +
101620 + if (gimple_num_ops(oldstmt) != 4 && rhs1 == NULL_TREE) {
101621 + rhs1 = gimple_assign_rhs1(oldstmt);
101622 + rhs1 = create_assign(visited, oldstmt, rhs1, BEFORE_STMT);
101623 + }
101624 + if (gimple_num_ops(oldstmt) == 3 && rhs2 == NULL_TREE) {
101625 + rhs2 = gimple_assign_rhs2(oldstmt);
101626 + rhs2 = create_assign(visited, oldstmt, rhs2, BEFORE_STMT);
101627 + }
101628 +
101629 + stmt = gimple_copy(oldstmt);
101630 + gimple_set_location(stmt, gimple_location(oldstmt));
101631 + gimple_set_plf(stmt, MY_STMT, true);
101632 +
101633 + if (gimple_assign_rhs_code(oldstmt) == WIDEN_MULT_EXPR)
101634 + gimple_assign_set_rhs_code(stmt, MULT_EXPR);
101635 +
101636 + size_overflow_type = get_size_overflow_type(oldstmt, node);
101637 +
101638 + new_var = create_new_var(size_overflow_type);
101639 + new_var = make_ssa_name(new_var, stmt);
101640 + gimple_set_lhs(stmt, new_var);
101641 +
101642 + if (rhs1 != NULL_TREE)
101643 + gimple_assign_set_rhs1(stmt, rhs1);
101644 +
101645 + if (rhs2 != NULL_TREE)
101646 + gimple_assign_set_rhs2(stmt, rhs2);
101647 +#if BUILDING_GCC_VERSION >= 4007
101648 + if (rhs3 != NULL_TREE)
101649 + gimple_assign_set_rhs3(stmt, rhs3);
101650 +#endif
101651 + gimple_set_vuse(stmt, gimple_vuse(oldstmt));
101652 + gimple_set_vdef(stmt, gimple_vdef(oldstmt));
101653 +
101654 + gsi = gsi_for_stmt(oldstmt);
101655 + gsi_insert_after(&gsi, stmt, GSI_SAME_STMT);
101656 + update_stmt(stmt);
101657 + pointer_set_insert(visited, oldstmt);
101658 + return gimple_get_lhs(stmt);
101659 +}
101660 +
101661 +static tree cast_parm_decl(tree phi_ssa_name, tree arg, tree size_overflow_type)
101662 +{
101663 + basic_block first_bb;
101664 + gimple assign;
101665 + gimple_stmt_iterator gsi;
101666 +
101667 + first_bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
101668 + gcc_assert(dom_info_available_p(CDI_DOMINATORS));
101669 + set_immediate_dominator(CDI_DOMINATORS, first_bb, ENTRY_BLOCK_PTR);
101670 +
101671 + gsi = gsi_start_bb(first_bb);
101672 + assign = build_cast_stmt(size_overflow_type, arg, phi_ssa_name, &gsi, BEFORE_STMT, false);
101673 + return gimple_get_lhs(assign);
101674 +}
101675 +
101676 +static tree use_phi_ssa_name(tree phi_ssa_name, tree new_arg)
101677 +{
101678 + gimple_stmt_iterator gsi;
101679 + const_gimple assign;
101680 + gimple def_stmt = get_def_stmt(new_arg);
101681 +
101682 + if (gimple_code(def_stmt) == GIMPLE_PHI) {
101683 + gsi = gsi_after_labels(gimple_bb(def_stmt));
101684 + assign = build_cast_stmt(TREE_TYPE(new_arg), new_arg, phi_ssa_name, &gsi, BEFORE_STMT, true);
101685 + } else {
101686 + gsi = gsi_for_stmt(def_stmt);
101687 + assign = build_cast_stmt(TREE_TYPE(new_arg), new_arg, phi_ssa_name, &gsi, AFTER_STMT, true);
101688 + }
101689 +
101690 + return gimple_get_lhs(assign);
101691 +}
101692 +
101693 +static tree cast_visited_phi_arg(tree phi_ssa_name, tree arg, tree size_overflow_type)
101694 +{
101695 + basic_block bb;
101696 + gimple_stmt_iterator gsi;
101697 + const_gimple assign, def_stmt;
101698 +
101699 + def_stmt = get_def_stmt(arg);
101700 + bb = gimple_bb(def_stmt);
101701 + gcc_assert(bb->index != 0);
101702 + gsi = gsi_after_labels(bb);
101703 +
101704 + assign = build_cast_stmt(size_overflow_type, arg, phi_ssa_name, &gsi, BEFORE_STMT, false);
101705 + return gimple_get_lhs(assign);
101706 +}
101707 +
101708 +static tree create_new_phi_arg(tree phi_ssa_name, tree new_arg, tree arg, gimple oldstmt)
101709 +{
101710 + tree size_overflow_type;
101711 + const_gimple def_stmt = get_def_stmt(arg);
101712 +
101713 + if (phi_ssa_name != NULL_TREE)
101714 + phi_ssa_name = SSA_NAME_VAR(phi_ssa_name);
101715 +
101716 + size_overflow_type = get_size_overflow_type(oldstmt, arg);
101717 +
101718 + if (new_arg != NULL_TREE) {
101719 + gcc_assert(types_compatible_p(TREE_TYPE(new_arg), size_overflow_type));
101720 + return use_phi_ssa_name(phi_ssa_name, new_arg);
101721 + }
101722 +
101723 + switch(gimple_code(def_stmt)) {
101724 + case GIMPLE_PHI:
101725 + return cast_visited_phi_arg(phi_ssa_name, arg, size_overflow_type);
101726 + case GIMPLE_NOP:
101727 + return cast_parm_decl(phi_ssa_name, arg, size_overflow_type);
101728 + default:
101729 + debug_gimple_stmt((gimple)def_stmt);
101730 + gcc_unreachable();
101731 + }
101732 +}
101733 +
101734 +static gimple overflow_create_phi_node(gimple oldstmt, tree result)
101735 +{
101736 + basic_block bb;
101737 + gimple phi;
101738 + gimple_seq seq;
101739 + gimple_stmt_iterator gsi = gsi_for_stmt(oldstmt);
101740 +
101741 + bb = gsi_bb(gsi);
101742 +
101743 + phi = create_phi_node(result, bb);
101744 + gimple_phi_set_result(phi, make_ssa_name(result, phi));
101745 + seq = phi_nodes(bb);
101746 + gsi = gsi_last(seq);
101747 + gsi_remove(&gsi, false);
101748 +
101749 + gsi = gsi_for_stmt(oldstmt);
101750 + gsi_insert_after(&gsi, phi, GSI_NEW_STMT);
101751 + gimple_set_bb(phi, bb);
101752 + gimple_set_plf(phi, MY_STMT, true);
101753 + return phi;
101754 +}
101755 +
101756 +static tree handle_phi(struct pointer_set_t *visited, tree orig_result)
101757 +{
101758 + gimple new_phi = NULL;
101759 + gimple oldstmt = get_def_stmt(orig_result);
101760 + tree phi_ssa_name = NULL_TREE;
101761 + unsigned int i;
101762 +
101763 + pointer_set_insert(visited, oldstmt);
101764 + for (i = 0; i < gimple_phi_num_args(oldstmt); i++) {
101765 + tree arg, new_arg;
101766 +
101767 + arg = gimple_phi_arg_def(oldstmt, i);
101768 +
101769 + new_arg = expand(visited, arg);
101770 + new_arg = create_new_phi_arg(phi_ssa_name, new_arg, arg, oldstmt);
101771 + if (i == 0) {
101772 + phi_ssa_name = new_arg;
101773 + new_phi = overflow_create_phi_node(oldstmt, SSA_NAME_VAR(phi_ssa_name));
101774 + }
101775 +
101776 + gcc_assert(new_phi != NULL);
101777 + add_phi_arg(new_phi, new_arg, gimple_phi_arg_edge(oldstmt, i), gimple_location(oldstmt));
101778 + }
101779 +
101780 + gcc_assert(new_phi != NULL);
101781 + update_stmt(new_phi);
101782 + return gimple_phi_result(new_phi);
101783 +}
101784 +
101785 +static tree change_assign_rhs(gimple stmt, const_tree orig_rhs, tree new_rhs)
101786 +{
101787 + const_gimple assign;
101788 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
101789 + tree origtype = TREE_TYPE(orig_rhs);
101790 +
101791 + gcc_assert(gimple_code(stmt) == GIMPLE_ASSIGN);
101792 +
101793 + assign = build_cast_stmt(origtype, new_rhs, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
101794 + return gimple_get_lhs(assign);
101795 +}
101796 +
101797 +static bool is_a_cast_and_const_overflow(const_tree no_const_rhs)
101798 +{
101799 + const_tree rhs1, lhs, rhs1_type, lhs_type;
101800 + enum machine_mode lhs_mode, rhs_mode;
101801 + gimple def_stmt = get_def_stmt(no_const_rhs);
101802 +
101803 + if (!gimple_assign_cast_p(def_stmt))
101804 + return false;
101805 +
101806 + rhs1 = gimple_assign_rhs1(def_stmt);
101807 + lhs = gimple_get_lhs(def_stmt);
101808 + rhs1_type = TREE_TYPE(rhs1);
101809 + lhs_type = TREE_TYPE(lhs);
101810 + rhs_mode = TYPE_MODE(rhs1_type);
101811 + lhs_mode = TYPE_MODE(lhs_type);
101812 + if (TYPE_UNSIGNED(lhs_type) == TYPE_UNSIGNED(rhs1_type) || lhs_mode != rhs_mode)
101813 + return false;
101814 +
101815 + return true;
101816 +}
101817 +
101818 +static tree create_cast_assign(struct pointer_set_t *visited, gimple stmt)
101819 +{
101820 + tree rhs1 = gimple_assign_rhs1(stmt);
101821 + tree lhs = gimple_get_lhs(stmt);
101822 + const_tree rhs1_type = TREE_TYPE(rhs1);
101823 + const_tree lhs_type = TREE_TYPE(lhs);
101824 +
101825 + if (TYPE_UNSIGNED(rhs1_type) == TYPE_UNSIGNED(lhs_type))
101826 + return create_assign(visited, stmt, lhs, AFTER_STMT);
101827 +
101828 + return create_assign(visited, stmt, rhs1, AFTER_STMT);
101829 +}
101830 +
101831 +static bool no_uses(tree node)
101832 +{
101833 + imm_use_iterator imm_iter;
101834 + use_operand_p use_p;
101835 +
101836 + FOR_EACH_IMM_USE_FAST(use_p, imm_iter, node) {
101837 + const_gimple use_stmt = USE_STMT(use_p);
101838 + if (use_stmt == NULL)
101839 + return true;
101840 + if (is_gimple_debug(use_stmt))
101841 + continue;
101842 + if (!(gimple_bb(use_stmt)->flags & BB_REACHABLE))
101843 + continue;
101844 + return false;
101845 + }
101846 + return true;
101847 +}
101848 +
101849 +// 3.8.5 mm/page-writeback.c __ilog2_u64(): ret, uint + uintmax; uint -> int; int max
101850 +static bool is_const_plus_unsigned_signed_truncation(const_tree lhs)
101851 +{
101852 + tree rhs1, lhs_type, rhs_type, rhs2, not_const_rhs;
101853 + gimple def_stmt = get_def_stmt(lhs);
101854 +
101855 + if (!def_stmt || !gimple_assign_cast_p(def_stmt))
101856 + return false;
101857 +
101858 + rhs1 = gimple_assign_rhs1(def_stmt);
101859 + rhs_type = TREE_TYPE(rhs1);
101860 + lhs_type = TREE_TYPE(lhs);
101861 + if (TYPE_UNSIGNED(lhs_type) || !TYPE_UNSIGNED(rhs_type))
101862 + return false;
101863 + if (TYPE_MODE(lhs_type) != TYPE_MODE(rhs_type))
101864 + return false;
101865 +
101866 + def_stmt = get_def_stmt(rhs1);
101867 + if (!def_stmt || gimple_code(def_stmt) != GIMPLE_ASSIGN || gimple_num_ops(def_stmt) != 3)
101868 + return false;
101869 +
101870 + if (gimple_assign_rhs_code(def_stmt) != PLUS_EXPR)
101871 + return false;
101872 +
101873 + rhs1 = gimple_assign_rhs1(def_stmt);
101874 + rhs2 = gimple_assign_rhs2(def_stmt);
101875 + if (!is_gimple_constant(rhs1) && !is_gimple_constant(rhs2))
101876 + return false;
101877 +
101878 + if (is_gimple_constant(rhs2))
101879 + not_const_rhs = rhs1;
101880 + else
101881 + not_const_rhs = rhs2;
101882 +
101883 + return no_uses(not_const_rhs);
101884 +}
101885 +
101886 +static bool skip_lhs_cast_check(const_gimple stmt)
101887 +{
101888 + const_tree rhs = gimple_assign_rhs1(stmt);
101889 + const_gimple def_stmt = get_def_stmt(rhs);
101890 +
101891 + // 3.8.2 kernel/futex_compat.c compat_exit_robust_list(): get_user() 64 ulong -> int (compat_long_t), int max
101892 + if (gimple_code(def_stmt) == GIMPLE_ASM)
101893 + return true;
101894 +
101895 + if (is_const_plus_unsigned_signed_truncation(rhs))
101896 + return true;
101897 +
101898 + return false;
101899 +}
101900 +
101901 +static tree create_cast_overflow_check(struct pointer_set_t *visited, tree new_rhs1, gimple stmt)
101902 +{
101903 + bool cast_lhs, cast_rhs;
101904 + tree lhs = gimple_get_lhs(stmt);
101905 + tree rhs = gimple_assign_rhs1(stmt);
101906 + const_tree lhs_type = TREE_TYPE(lhs);
101907 + const_tree rhs_type = TREE_TYPE(rhs);
101908 + enum machine_mode lhs_mode = TYPE_MODE(lhs_type);
101909 + enum machine_mode rhs_mode = TYPE_MODE(rhs_type);
101910 + unsigned int lhs_size = GET_MODE_BITSIZE(lhs_mode);
101911 + unsigned int rhs_size = GET_MODE_BITSIZE(rhs_mode);
101912 +
101913 + static bool check_lhs[3][4] = {
101914 + // ss su us uu
101915 + { false, true, true, false }, // lhs > rhs
101916 + { false, false, false, false }, // lhs = rhs
101917 + { true, true, true, true }, // lhs < rhs
101918 + };
101919 +
101920 + static bool check_rhs[3][4] = {
101921 + // ss su us uu
101922 + { true, false, true, true }, // lhs > rhs
101923 + { true, false, true, true }, // lhs = rhs
101924 + { true, false, true, true }, // lhs < rhs
101925 + };
101926 +
101927 + // skip lhs check on signed SI -> HI cast or signed SI -> QI cast !!!!
101928 + if (rhs_mode == SImode && !TYPE_UNSIGNED(rhs_type) && (lhs_mode == HImode || lhs_mode == QImode))
101929 + return create_assign(visited, stmt, lhs, AFTER_STMT);
101930 +
101931 + if (lhs_size > rhs_size) {
101932 + cast_lhs = check_lhs[0][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
101933 + cast_rhs = check_rhs[0][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
101934 + } else if (lhs_size == rhs_size) {
101935 + cast_lhs = check_lhs[1][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
101936 + cast_rhs = check_rhs[1][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
101937 + } else {
101938 + cast_lhs = check_lhs[2][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
101939 + cast_rhs = check_rhs[2][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
101940 + }
101941 +
101942 + if (!cast_lhs && !cast_rhs)
101943 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
101944 +
101945 + if (cast_lhs && !skip_lhs_cast_check(stmt))
101946 + check_size_overflow(stmt, TREE_TYPE(new_rhs1), new_rhs1, lhs, BEFORE_STMT);
101947 +
101948 + if (cast_rhs)
101949 + check_size_overflow(stmt, TREE_TYPE(new_rhs1), new_rhs1, rhs, BEFORE_STMT);
101950 +
101951 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
101952 +}
101953 +
101954 +static tree handle_unary_rhs(struct pointer_set_t *visited, gimple stmt)
101955 +{
101956 + tree rhs1, new_rhs1, lhs = gimple_get_lhs(stmt);
101957 +
101958 + if (gimple_plf(stmt, MY_STMT))
101959 + return lhs;
101960 +
101961 + rhs1 = gimple_assign_rhs1(stmt);
101962 + if (TREE_CODE(TREE_TYPE(rhs1)) == POINTER_TYPE)
101963 + return create_assign(visited, stmt, lhs, AFTER_STMT);
101964 +
101965 + new_rhs1 = expand(visited, rhs1);
101966 +
101967 + if (new_rhs1 == NULL_TREE)
101968 + return create_cast_assign(visited, stmt);
101969 +
101970 + if (gimple_plf(stmt, NO_CAST_CHECK))
101971 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
101972 +
101973 + if (gimple_assign_rhs_code(stmt) == BIT_NOT_EXPR) {
101974 + tree size_overflow_type = get_size_overflow_type(stmt, rhs1);
101975 +
101976 + new_rhs1 = cast_to_new_size_overflow_type(stmt, new_rhs1, size_overflow_type, BEFORE_STMT);
101977 + check_size_overflow(stmt, size_overflow_type, new_rhs1, rhs1, BEFORE_STMT);
101978 + return create_assign(visited, stmt, lhs, AFTER_STMT);
101979 + }
101980 +
101981 + if (!gimple_assign_cast_p(stmt))
101982 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
101983 +
101984 + return create_cast_overflow_check(visited, new_rhs1, stmt);
101985 +}
101986 +
101987 +static tree handle_unary_ops(struct pointer_set_t *visited, gimple stmt)
101988 +{
101989 + tree rhs1, lhs = gimple_get_lhs(stmt);
101990 + gimple def_stmt = get_def_stmt(lhs);
101991 +
101992 + gcc_assert(gimple_code(def_stmt) != GIMPLE_NOP);
101993 + rhs1 = gimple_assign_rhs1(def_stmt);
101994 +
101995 + if (is_gimple_constant(rhs1))
101996 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
101997 +
101998 + switch (TREE_CODE(rhs1)) {
101999 + case SSA_NAME:
102000 + return handle_unary_rhs(visited, def_stmt);
102001 + case ARRAY_REF:
102002 + case BIT_FIELD_REF:
102003 + case ADDR_EXPR:
102004 + case COMPONENT_REF:
102005 + case INDIRECT_REF:
102006 +#if BUILDING_GCC_VERSION >= 4006
102007 + case MEM_REF:
102008 +#endif
102009 + case TARGET_MEM_REF:
102010 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
102011 + case PARM_DECL:
102012 + case VAR_DECL:
102013 + return create_assign(visited, stmt, lhs, AFTER_STMT);
102014 +
102015 + default:
102016 + debug_gimple_stmt(def_stmt);
102017 + debug_tree(rhs1);
102018 + gcc_unreachable();
102019 + }
102020 +}
102021 +
102022 +static void insert_cond(basic_block cond_bb, tree arg, enum tree_code cond_code, tree type_value)
102023 +{
102024 + gimple cond_stmt;
102025 + gimple_stmt_iterator gsi = gsi_last_bb(cond_bb);
102026 +
102027 + cond_stmt = gimple_build_cond(cond_code, arg, type_value, NULL_TREE, NULL_TREE);
102028 + gsi_insert_after(&gsi, cond_stmt, GSI_CONTINUE_LINKING);
102029 + update_stmt(cond_stmt);
102030 +}
102031 +
102032 +static tree create_string_param(tree string)
102033 +{
102034 + tree i_type, a_type;
102035 + const int length = TREE_STRING_LENGTH(string);
102036 +
102037 + gcc_assert(length > 0);
102038 +
102039 + i_type = build_index_type(build_int_cst(NULL_TREE, length - 1));
102040 + a_type = build_array_type(char_type_node, i_type);
102041 +
102042 + TREE_TYPE(string) = a_type;
102043 + TREE_CONSTANT(string) = 1;
102044 + TREE_READONLY(string) = 1;
102045 +
102046 + return build1(ADDR_EXPR, ptr_type_node, string);
102047 +}
102048 +
102049 +static void insert_cond_result(basic_block bb_true, const_gimple stmt, const_tree arg, bool min)
102050 +{
102051 + gimple func_stmt;
102052 + const_gimple def_stmt;
102053 + const_tree loc_line;
102054 + tree loc_file, ssa_name, current_func;
102055 + expanded_location xloc;
102056 + char *ssa_name_buf;
102057 + int len;
102058 + gimple_stmt_iterator gsi = gsi_start_bb(bb_true);
102059 +
102060 + def_stmt = get_def_stmt(arg);
102061 + xloc = expand_location(gimple_location(def_stmt));
102062 +
102063 + if (!gimple_has_location(def_stmt)) {
102064 + xloc = expand_location(gimple_location(stmt));
102065 + if (!gimple_has_location(stmt))
102066 + xloc = expand_location(DECL_SOURCE_LOCATION(current_function_decl));
102067 + }
102068 +
102069 + loc_line = build_int_cstu(unsigned_type_node, xloc.line);
102070 +
102071 + loc_file = build_string(strlen(xloc.file) + 1, xloc.file);
102072 + loc_file = create_string_param(loc_file);
102073 +
102074 + current_func = build_string(NAME_LEN(current_function_decl) + 1, NAME(current_function_decl));
102075 + current_func = create_string_param(current_func);
102076 +
102077 + gcc_assert(DECL_NAME(SSA_NAME_VAR(arg)) != NULL);
102078 + call_count++;
102079 + 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);
102080 + gcc_assert(len > 0);
102081 + ssa_name = build_string(len + 1, ssa_name_buf);
102082 + free(ssa_name_buf);
102083 + ssa_name = create_string_param(ssa_name);
102084 +
102085 + // void report_size_overflow(const char *file, unsigned int line, const char *func, const char *ssa_name)
102086 + func_stmt = gimple_build_call(report_size_overflow_decl, 4, loc_file, loc_line, current_func, ssa_name);
102087 +
102088 + gsi_insert_after(&gsi, func_stmt, GSI_CONTINUE_LINKING);
102089 +}
102090 +
102091 +static void __unused print_the_code_insertions(const_gimple stmt)
102092 +{
102093 + location_t loc = gimple_location(stmt);
102094 +
102095 + inform(loc, "Integer size_overflow check applied here.");
102096 +}
102097 +
102098 +static void insert_check_size_overflow(gimple stmt, enum tree_code cond_code, tree arg, tree type_value, bool before, bool min)
102099 +{
102100 + basic_block cond_bb, join_bb, bb_true;
102101 + edge e;
102102 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
102103 +
102104 + cond_bb = gimple_bb(stmt);
102105 + if (before)
102106 + gsi_prev(&gsi);
102107 + if (gsi_end_p(gsi))
102108 + e = split_block_after_labels(cond_bb);
102109 + else
102110 + e = split_block(cond_bb, gsi_stmt(gsi));
102111 + cond_bb = e->src;
102112 + join_bb = e->dest;
102113 + e->flags = EDGE_FALSE_VALUE;
102114 + e->probability = REG_BR_PROB_BASE;
102115 +
102116 + bb_true = create_empty_bb(cond_bb);
102117 + make_edge(cond_bb, bb_true, EDGE_TRUE_VALUE);
102118 + make_edge(cond_bb, join_bb, EDGE_FALSE_VALUE);
102119 + make_edge(bb_true, join_bb, EDGE_FALLTHRU);
102120 +
102121 + gcc_assert(dom_info_available_p(CDI_DOMINATORS));
102122 + set_immediate_dominator(CDI_DOMINATORS, bb_true, cond_bb);
102123 + set_immediate_dominator(CDI_DOMINATORS, join_bb, cond_bb);
102124 +
102125 + if (current_loops != NULL) {
102126 + gcc_assert(cond_bb->loop_father == join_bb->loop_father);
102127 + add_bb_to_loop(bb_true, cond_bb->loop_father);
102128 + }
102129 +
102130 + insert_cond(cond_bb, arg, cond_code, type_value);
102131 + insert_cond_result(bb_true, stmt, arg, min);
102132 +
102133 +// print_the_code_insertions(stmt);
102134 +}
102135 +
102136 +static void check_size_overflow(gimple stmt, tree size_overflow_type, tree cast_rhs, tree rhs, bool before)
102137 +{
102138 + const_tree rhs_type = TREE_TYPE(rhs);
102139 + tree cast_rhs_type, type_max_type, type_min_type, type_max, type_min;
102140 +
102141 + gcc_assert(rhs_type != NULL_TREE);
102142 + if (TREE_CODE(rhs_type) == POINTER_TYPE)
102143 + return;
102144 +
102145 + gcc_assert(TREE_CODE(rhs_type) == INTEGER_TYPE || TREE_CODE(rhs_type) == ENUMERAL_TYPE);
102146 +
102147 + if (is_const_plus_unsigned_signed_truncation(rhs))
102148 + return;
102149 +
102150 + type_max = cast_a_tree(size_overflow_type, TYPE_MAX_VALUE(rhs_type));
102151 + // typemax (-1) < typemin (0)
102152 + if (TREE_OVERFLOW(type_max))
102153 + return;
102154 +
102155 + type_min = cast_a_tree(size_overflow_type, TYPE_MIN_VALUE(rhs_type));
102156 +
102157 + cast_rhs_type = TREE_TYPE(cast_rhs);
102158 + type_max_type = TREE_TYPE(type_max);
102159 + type_min_type = TREE_TYPE(type_min);
102160 + gcc_assert(types_compatible_p(cast_rhs_type, type_max_type));
102161 + gcc_assert(types_compatible_p(type_max_type, type_min_type));
102162 +
102163 + insert_check_size_overflow(stmt, GT_EXPR, cast_rhs, type_max, before, false);
102164 + insert_check_size_overflow(stmt, LT_EXPR, cast_rhs, type_min, before, true);
102165 +}
102166 +
102167 +static bool is_a_constant_overflow(const_gimple stmt, const_tree rhs)
102168 +{
102169 + if (gimple_assign_rhs_code(stmt) == MIN_EXPR)
102170 + return false;
102171 + if (!is_gimple_constant(rhs))
102172 + return false;
102173 + return true;
102174 +}
102175 +
102176 +static tree get_def_stmt_rhs(const_tree var)
102177 +{
102178 + tree rhs1, def_stmt_rhs1;
102179 + gimple rhs1_def_stmt, def_stmt_rhs1_def_stmt, def_stmt;
102180 +
102181 + def_stmt = get_def_stmt(var);
102182 + gcc_assert(gimple_code(def_stmt) != GIMPLE_NOP && gimple_plf(def_stmt, MY_STMT) && gimple_assign_cast_p(def_stmt));
102183 +
102184 + rhs1 = gimple_assign_rhs1(def_stmt);
102185 + rhs1_def_stmt = get_def_stmt(rhs1);
102186 + if (!gimple_assign_cast_p(rhs1_def_stmt))
102187 + return rhs1;
102188 +
102189 + def_stmt_rhs1 = gimple_assign_rhs1(rhs1_def_stmt);
102190 + def_stmt_rhs1_def_stmt = get_def_stmt(def_stmt_rhs1);
102191 +
102192 + switch (gimple_code(def_stmt_rhs1_def_stmt)) {
102193 + case GIMPLE_CALL:
102194 + case GIMPLE_NOP:
102195 + case GIMPLE_ASM:
102196 + case GIMPLE_PHI:
102197 + return def_stmt_rhs1;
102198 + case GIMPLE_ASSIGN:
102199 + return rhs1;
102200 + default:
102201 + debug_gimple_stmt(def_stmt_rhs1_def_stmt);
102202 + gcc_unreachable();
102203 + }
102204 +}
102205 +
102206 +static tree handle_intentional_overflow(struct pointer_set_t *visited, bool check_overflow, gimple stmt, tree change_rhs, tree new_rhs2)
102207 +{
102208 + tree new_rhs, orig_rhs;
102209 + void (*gimple_assign_set_rhs)(gimple, tree);
102210 + tree rhs1 = gimple_assign_rhs1(stmt);
102211 + tree rhs2 = gimple_assign_rhs2(stmt);
102212 + tree lhs = gimple_get_lhs(stmt);
102213 +
102214 + if (!check_overflow)
102215 + return create_assign(visited, stmt, lhs, AFTER_STMT);
102216 +
102217 + if (change_rhs == NULL_TREE)
102218 + return create_assign(visited, stmt, lhs, AFTER_STMT);
102219 +
102220 + if (new_rhs2 == NULL_TREE) {
102221 + orig_rhs = rhs1;
102222 + gimple_assign_set_rhs = &gimple_assign_set_rhs1;
102223 + } else {
102224 + orig_rhs = rhs2;
102225 + gimple_assign_set_rhs = &gimple_assign_set_rhs2;
102226 + }
102227 +
102228 + check_size_overflow(stmt, TREE_TYPE(change_rhs), change_rhs, orig_rhs, BEFORE_STMT);
102229 +
102230 + new_rhs = change_assign_rhs(stmt, orig_rhs, change_rhs);
102231 + gimple_assign_set_rhs(stmt, new_rhs);
102232 + update_stmt(stmt);
102233 +
102234 + return create_assign(visited, stmt, lhs, AFTER_STMT);
102235 +}
102236 +
102237 +static bool is_subtraction_special(const_gimple stmt)
102238 +{
102239 + gimple rhs1_def_stmt, rhs2_def_stmt;
102240 + const_tree rhs1_def_stmt_rhs1, rhs2_def_stmt_rhs1, rhs1_def_stmt_lhs, rhs2_def_stmt_lhs;
102241 + enum machine_mode rhs1_def_stmt_rhs1_mode, rhs2_def_stmt_rhs1_mode, rhs1_def_stmt_lhs_mode, rhs2_def_stmt_lhs_mode;
102242 + const_tree rhs1 = gimple_assign_rhs1(stmt);
102243 + const_tree rhs2 = gimple_assign_rhs2(stmt);
102244 +
102245 + if (is_gimple_constant(rhs1) || is_gimple_constant(rhs2))
102246 + return false;
102247 +
102248 + gcc_assert(TREE_CODE(rhs1) == SSA_NAME && TREE_CODE(rhs2) == SSA_NAME);
102249 +
102250 + if (gimple_assign_rhs_code(stmt) != MINUS_EXPR)
102251 + return false;
102252 +
102253 + rhs1_def_stmt = get_def_stmt(rhs1);
102254 + rhs2_def_stmt = get_def_stmt(rhs2);
102255 + if (!gimple_assign_cast_p(rhs1_def_stmt) || !gimple_assign_cast_p(rhs2_def_stmt))
102256 + return false;
102257 +
102258 + rhs1_def_stmt_rhs1 = gimple_assign_rhs1(rhs1_def_stmt);
102259 + rhs2_def_stmt_rhs1 = gimple_assign_rhs1(rhs2_def_stmt);
102260 + rhs1_def_stmt_lhs = gimple_get_lhs(rhs1_def_stmt);
102261 + rhs2_def_stmt_lhs = gimple_get_lhs(rhs2_def_stmt);
102262 + rhs1_def_stmt_rhs1_mode = TYPE_MODE(TREE_TYPE(rhs1_def_stmt_rhs1));
102263 + rhs2_def_stmt_rhs1_mode = TYPE_MODE(TREE_TYPE(rhs2_def_stmt_rhs1));
102264 + rhs1_def_stmt_lhs_mode = TYPE_MODE(TREE_TYPE(rhs1_def_stmt_lhs));
102265 + rhs2_def_stmt_lhs_mode = TYPE_MODE(TREE_TYPE(rhs2_def_stmt_lhs));
102266 + if (GET_MODE_BITSIZE(rhs1_def_stmt_rhs1_mode) <= GET_MODE_BITSIZE(rhs1_def_stmt_lhs_mode))
102267 + return false;
102268 + if (GET_MODE_BITSIZE(rhs2_def_stmt_rhs1_mode) <= GET_MODE_BITSIZE(rhs2_def_stmt_lhs_mode))
102269 + return false;
102270 +
102271 + gimple_set_plf(rhs1_def_stmt, NO_CAST_CHECK, true);
102272 + gimple_set_plf(rhs2_def_stmt, NO_CAST_CHECK, true);
102273 + return true;
102274 +}
102275 +
102276 +static tree handle_integer_truncation(struct pointer_set_t *visited, const_tree lhs)
102277 +{
102278 + tree new_rhs1, new_rhs2;
102279 + tree new_rhs1_def_stmt_rhs1, new_rhs2_def_stmt_rhs1, new_lhs;
102280 + gimple assign, stmt = get_def_stmt(lhs);
102281 + tree rhs1 = gimple_assign_rhs1(stmt);
102282 + tree rhs2 = gimple_assign_rhs2(stmt);
102283 +
102284 + if (!is_subtraction_special(stmt))
102285 + return NULL_TREE;
102286 +
102287 + new_rhs1 = expand(visited, rhs1);
102288 + new_rhs2 = expand(visited, rhs2);
102289 +
102290 + new_rhs1_def_stmt_rhs1 = get_def_stmt_rhs(new_rhs1);
102291 + new_rhs2_def_stmt_rhs1 = get_def_stmt_rhs(new_rhs2);
102292 +
102293 + if (!types_compatible_p(TREE_TYPE(new_rhs1_def_stmt_rhs1), TREE_TYPE(new_rhs2_def_stmt_rhs1))) {
102294 + new_rhs1_def_stmt_rhs1 = cast_to_TI_type(stmt, new_rhs1_def_stmt_rhs1);
102295 + new_rhs2_def_stmt_rhs1 = cast_to_TI_type(stmt, new_rhs2_def_stmt_rhs1);
102296 + }
102297 +
102298 + assign = create_binary_assign(MINUS_EXPR, stmt, new_rhs1_def_stmt_rhs1, new_rhs2_def_stmt_rhs1);
102299 + new_lhs = gimple_get_lhs(assign);
102300 + check_size_overflow(assign, TREE_TYPE(new_lhs), new_lhs, rhs1, AFTER_STMT);
102301 +
102302 + return dup_assign(visited, stmt, lhs, new_rhs1, new_rhs2, NULL_TREE);
102303 +}
102304 +
102305 +static bool is_a_neg_overflow(const_gimple stmt, const_tree rhs)
102306 +{
102307 + const_gimple def_stmt;
102308 +
102309 + if (TREE_CODE(rhs) != SSA_NAME)
102310 + return false;
102311 +
102312 + if (gimple_assign_rhs_code(stmt) != PLUS_EXPR)
102313 + return false;
102314 +
102315 + def_stmt = get_def_stmt(rhs);
102316 + if (gimple_code(def_stmt) != GIMPLE_ASSIGN || gimple_assign_rhs_code(def_stmt) != BIT_NOT_EXPR)
102317 + return false;
102318 +
102319 + return true;
102320 +}
102321 +
102322 +static tree handle_binary_ops(struct pointer_set_t *visited, tree lhs)
102323 +{
102324 + tree rhs1, rhs2, new_lhs;
102325 + gimple def_stmt = get_def_stmt(lhs);
102326 + tree new_rhs1 = NULL_TREE;
102327 + tree new_rhs2 = NULL_TREE;
102328 +
102329 + rhs1 = gimple_assign_rhs1(def_stmt);
102330 + rhs2 = gimple_assign_rhs2(def_stmt);
102331 +
102332 + /* no DImode/TImode division in the 32/64 bit kernel */
102333 + switch (gimple_assign_rhs_code(def_stmt)) {
102334 + case RDIV_EXPR:
102335 + case TRUNC_DIV_EXPR:
102336 + case CEIL_DIV_EXPR:
102337 + case FLOOR_DIV_EXPR:
102338 + case ROUND_DIV_EXPR:
102339 + case TRUNC_MOD_EXPR:
102340 + case CEIL_MOD_EXPR:
102341 + case FLOOR_MOD_EXPR:
102342 + case ROUND_MOD_EXPR:
102343 + case EXACT_DIV_EXPR:
102344 + case POINTER_PLUS_EXPR:
102345 + case BIT_AND_EXPR:
102346 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
102347 + default:
102348 + break;
102349 + }
102350 +
102351 + new_lhs = handle_integer_truncation(visited, lhs);
102352 + if (new_lhs != NULL_TREE)
102353 + return new_lhs;
102354 +
102355 + if (TREE_CODE(rhs1) == SSA_NAME)
102356 + new_rhs1 = expand(visited, rhs1);
102357 + if (TREE_CODE(rhs2) == SSA_NAME)
102358 + new_rhs2 = expand(visited, rhs2);
102359 +
102360 + if (is_a_neg_overflow(def_stmt, rhs2))
102361 + return handle_intentional_overflow(visited, true, def_stmt, new_rhs1, NULL_TREE);
102362 + if (is_a_neg_overflow(def_stmt, rhs1))
102363 + return handle_intentional_overflow(visited, true, def_stmt, new_rhs2, new_rhs2);
102364 +
102365 +
102366 + if (is_a_constant_overflow(def_stmt, rhs2))
102367 + return handle_intentional_overflow(visited, !is_a_cast_and_const_overflow(rhs1), def_stmt, new_rhs1, NULL_TREE);
102368 + if (is_a_constant_overflow(def_stmt, rhs1))
102369 + return handle_intentional_overflow(visited, !is_a_cast_and_const_overflow(rhs2), def_stmt, new_rhs2, new_rhs2);
102370 +
102371 + return dup_assign(visited, def_stmt, lhs, new_rhs1, new_rhs2, NULL_TREE);
102372 +}
102373 +
102374 +#if BUILDING_GCC_VERSION >= 4007
102375 +static tree get_new_rhs(struct pointer_set_t *visited, tree size_overflow_type, tree rhs)
102376 +{
102377 + if (is_gimple_constant(rhs))
102378 + return cast_a_tree(size_overflow_type, rhs);
102379 + if (TREE_CODE(rhs) != SSA_NAME)
102380 + return NULL_TREE;
102381 + return expand(visited, rhs);
102382 +}
102383 +
102384 +static tree handle_ternary_ops(struct pointer_set_t *visited, tree lhs)
102385 +{
102386 + tree rhs1, rhs2, rhs3, new_rhs1, new_rhs2, new_rhs3, size_overflow_type;
102387 + gimple def_stmt = get_def_stmt(lhs);
102388 +
102389 + size_overflow_type = get_size_overflow_type(def_stmt, lhs);
102390 +
102391 + rhs1 = gimple_assign_rhs1(def_stmt);
102392 + rhs2 = gimple_assign_rhs2(def_stmt);
102393 + rhs3 = gimple_assign_rhs3(def_stmt);
102394 + new_rhs1 = get_new_rhs(visited, size_overflow_type, rhs1);
102395 + new_rhs2 = get_new_rhs(visited, size_overflow_type, rhs2);
102396 + new_rhs3 = get_new_rhs(visited, size_overflow_type, rhs3);
102397 +
102398 + return dup_assign(visited, def_stmt, lhs, new_rhs1, new_rhs2, new_rhs3);
102399 +}
102400 +#endif
102401 +
102402 +static tree get_size_overflow_type(gimple stmt, const_tree node)
102403 +{
102404 + const_tree type;
102405 + tree new_type;
102406 +
102407 + gcc_assert(node != NULL_TREE);
102408 +
102409 + type = TREE_TYPE(node);
102410 +
102411 + if (gimple_plf(stmt, MY_STMT))
102412 + return TREE_TYPE(node);
102413 +
102414 + switch (TYPE_MODE(type)) {
102415 + case QImode:
102416 + new_type = intHI_type_node;
102417 + break;
102418 + case HImode:
102419 + new_type = intSI_type_node;
102420 + break;
102421 + case SImode:
102422 + new_type = intDI_type_node;
102423 + break;
102424 + case DImode:
102425 + if (LONG_TYPE_SIZE == GET_MODE_BITSIZE(SImode))
102426 + new_type = intDI_type_node;
102427 + else
102428 + new_type = intTI_type_node;
102429 + break;
102430 + default:
102431 + debug_tree((tree)node);
102432 + error("%s: unsupported gcc configuration.", __func__);
102433 + gcc_unreachable();
102434 + }
102435 +
102436 + if (TYPE_QUALS(type) != 0)
102437 + return build_qualified_type(new_type, TYPE_QUALS(type));
102438 + return new_type;
102439 +}
102440 +
102441 +static tree expand_visited(gimple def_stmt)
102442 +{
102443 + const_gimple next_stmt;
102444 + gimple_stmt_iterator gsi;
102445 + enum gimple_code code = gimple_code(def_stmt);
102446 +
102447 + if (code == GIMPLE_ASM)
102448 + return NULL_TREE;
102449 +
102450 + gsi = gsi_for_stmt(def_stmt);
102451 + gsi_next(&gsi);
102452 +
102453 + if (gimple_code(def_stmt) == GIMPLE_PHI && gsi_end_p(gsi))
102454 + return NULL_TREE;
102455 + gcc_assert(!gsi_end_p(gsi));
102456 + next_stmt = gsi_stmt(gsi);
102457 +
102458 + if (gimple_code(def_stmt) == GIMPLE_PHI && !gimple_plf((gimple)next_stmt, MY_STMT))
102459 + return NULL_TREE;
102460 + gcc_assert(gimple_plf((gimple)next_stmt, MY_STMT));
102461 +
102462 + return get_lhs(next_stmt);
102463 +}
102464 +
102465 +static tree expand(struct pointer_set_t *visited, tree lhs)
102466 +{
102467 + gimple def_stmt;
102468 +
102469 + if (skip_types(lhs))
102470 + return NULL_TREE;
102471 +
102472 + def_stmt = get_def_stmt(lhs);
102473 +
102474 + if (!def_stmt || gimple_code(def_stmt) == GIMPLE_NOP)
102475 + return NULL_TREE;
102476 +
102477 + if (gimple_plf(def_stmt, MY_STMT))
102478 + return lhs;
102479 +
102480 + if (pointer_set_contains(visited, def_stmt))
102481 + return expand_visited(def_stmt);
102482 +
102483 + switch (gimple_code(def_stmt)) {
102484 + case GIMPLE_PHI:
102485 + return handle_phi(visited, lhs);
102486 + case GIMPLE_CALL:
102487 + case GIMPLE_ASM:
102488 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
102489 + case GIMPLE_ASSIGN:
102490 + switch (gimple_num_ops(def_stmt)) {
102491 + case 2:
102492 + return handle_unary_ops(visited, def_stmt);
102493 + case 3:
102494 + return handle_binary_ops(visited, lhs);
102495 +#if BUILDING_GCC_VERSION >= 4007
102496 + case 4:
102497 + return handle_ternary_ops(visited, lhs);
102498 +#endif
102499 + }
102500 + default:
102501 + debug_gimple_stmt(def_stmt);
102502 + error("%s: unknown gimple code", __func__);
102503 + gcc_unreachable();
102504 + }
102505 +}
102506 +
102507 +static tree get_new_tree(gimple stmt, const_tree orig_node, tree new_node)
102508 +{
102509 + const_gimple assign;
102510 + tree orig_type = TREE_TYPE(orig_node);
102511 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
102512 +
102513 + assign = build_cast_stmt(orig_type, new_node, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
102514 + return gimple_get_lhs(assign);
102515 +}
102516 +
102517 +static void change_function_arg(gimple stmt, const_tree orig_arg, unsigned int argnum, tree new_arg)
102518 +{
102519 + gimple_call_set_arg(stmt, argnum, get_new_tree(stmt, orig_arg, new_arg));
102520 + update_stmt(stmt);
102521 +}
102522 +
102523 +static void change_function_return(gimple stmt, const_tree orig_ret, tree new_ret)
102524 +{
102525 + gimple_return_set_retval(stmt, get_new_tree(stmt, orig_ret, new_ret));
102526 + update_stmt(stmt);
102527 +}
102528 +
102529 +static bool get_function_arg(unsigned int* argnum, const_tree fndecl)
102530 +{
102531 + tree arg;
102532 + const_tree origarg;
102533 +
102534 + if (!DECL_ABSTRACT_ORIGIN(fndecl))
102535 + return true;
102536 +
102537 + origarg = DECL_ARGUMENTS(DECL_ABSTRACT_ORIGIN(fndecl));
102538 + while (origarg && *argnum) {
102539 + (*argnum)--;
102540 + origarg = TREE_CHAIN(origarg);
102541 + }
102542 +
102543 + gcc_assert(*argnum == 0);
102544 +
102545 + gcc_assert(origarg != NULL_TREE);
102546 + *argnum = 0;
102547 + for (arg = DECL_ARGUMENTS(fndecl); arg; arg = TREE_CHAIN(arg), (*argnum)++)
102548 + if (operand_equal_p(origarg, arg, 0) || !strcmp(NAME(origarg), NAME(arg)))
102549 + return true;
102550 + return false;
102551 +}
102552 +
102553 +static enum mark walk_phi(struct pointer_set_t *visited, bool *search_err_code, const_tree result)
102554 +{
102555 + gimple phi = get_def_stmt(result);
102556 + unsigned int i, n = gimple_phi_num_args(phi);
102557 +
102558 + if (!phi)
102559 + return MARK_NO;
102560 +
102561 + pointer_set_insert(visited, phi);
102562 + for (i = 0; i < n; i++) {
102563 + enum mark marked;
102564 + const_tree arg = gimple_phi_arg_def(phi, i);
102565 + marked = pre_expand(visited, search_err_code, arg);
102566 + if (marked != MARK_NO)
102567 + return marked;
102568 + }
102569 + return MARK_NO;
102570 +}
102571 +
102572 +static enum mark walk_unary_ops(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
102573 +{
102574 + gimple def_stmt = get_def_stmt(lhs);
102575 + const_tree rhs;
102576 +
102577 + if (!def_stmt)
102578 + return MARK_NO;
102579 +
102580 + rhs = gimple_assign_rhs1(def_stmt);
102581 +
102582 + def_stmt = get_def_stmt(rhs);
102583 + if (is_gimple_constant(rhs))
102584 + search_err_code[FROM_CONST] = true;
102585 +
102586 + return pre_expand(visited, search_err_code, rhs);
102587 +}
102588 +
102589 +static enum mark walk_binary_ops(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
102590 +{
102591 + gimple def_stmt = get_def_stmt(lhs);
102592 + const_tree rhs1, rhs2;
102593 + enum mark marked;
102594 +
102595 + if (!def_stmt)
102596 + return MARK_NO;
102597 +
102598 + search_err_code[CAST_ONLY] = false;
102599 +
102600 + rhs1 = gimple_assign_rhs1(def_stmt);
102601 + rhs2 = gimple_assign_rhs2(def_stmt);
102602 + marked = pre_expand(visited, search_err_code, rhs1);
102603 + if (marked != MARK_NO)
102604 + return marked;
102605 + return pre_expand(visited, search_err_code, rhs2);
102606 +}
102607 +
102608 +static const_tree search_field_decl(const_tree comp_ref)
102609 +{
102610 + const_tree field = NULL_TREE;
102611 + unsigned int i, len = TREE_OPERAND_LENGTH(comp_ref);
102612 +
102613 + for (i = 0; i < len; i++) {
102614 + field = TREE_OPERAND(comp_ref, i);
102615 + if (TREE_CODE(field) == FIELD_DECL)
102616 + break;
102617 + }
102618 + gcc_assert(TREE_CODE(field) == FIELD_DECL);
102619 + return field;
102620 +}
102621 +
102622 +static enum mark mark_status(const_tree fndecl, unsigned int argnum)
102623 +{
102624 + const_tree attr, p;
102625 +
102626 + // 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);
102627 + if (fndecl == NULL_TREE)
102628 + return MARK_NO;
102629 +
102630 + attr = lookup_attribute("intentional_overflow", DECL_ATTRIBUTES(fndecl));
102631 + if (!attr || !TREE_VALUE(attr))
102632 + return MARK_NO;
102633 +
102634 + p = TREE_VALUE(attr);
102635 + if (TREE_INT_CST_HIGH(TREE_VALUE(p)) == -1)
102636 + return MARK_TURN_OFF;
102637 + if (!TREE_INT_CST_LOW(TREE_VALUE(p)))
102638 + return MARK_NOT_INTENTIONAL;
102639 + if (argnum == 0) {
102640 + gcc_assert(current_function_decl == fndecl);
102641 + return MARK_NO;
102642 + }
102643 +
102644 + do {
102645 + if (argnum == TREE_INT_CST_LOW(TREE_VALUE(p)))
102646 + return MARK_YES;
102647 + p = TREE_CHAIN(p);
102648 + } while (p);
102649 +
102650 + return MARK_NO;
102651 +}
102652 +
102653 +static void print_missing_msg(tree func, unsigned int argnum)
102654 +{
102655 + unsigned int new_hash;
102656 + size_t len;
102657 + unsigned char tree_codes[CODES_LIMIT];
102658 + location_t loc;
102659 + const char *curfunc;
102660 +
102661 + func = get_original_function_decl(func);
102662 + loc = DECL_SOURCE_LOCATION(func);
102663 + curfunc = get_asm_name(func);
102664 +
102665 + len = get_function_decl(func, tree_codes);
102666 + new_hash = get_hash_num(curfunc, (const char *) tree_codes, len, 0);
102667 + inform(loc, "Function %s is missing from the size_overflow hash table +%s+%u+%u+", curfunc, curfunc, argnum, new_hash);
102668 +}
102669 +
102670 +static unsigned int search_missing_attribute(const_tree arg)
102671 +{
102672 + unsigned int argnum;
102673 + const struct size_overflow_hash *hash;
102674 + const_tree type = TREE_TYPE(arg);
102675 + tree func = get_original_function_decl(current_function_decl);
102676 +
102677 + gcc_assert(TREE_CODE(arg) != COMPONENT_REF);
102678 +
102679 + if (TREE_CODE(type) == POINTER_TYPE)
102680 + return 0;
102681 +
102682 + argnum = find_arg_number(arg, func);
102683 + if (argnum == 0)
102684 + return 0;
102685 +
102686 + if (lookup_attribute("size_overflow", DECL_ATTRIBUTES(func)))
102687 + return argnum;
102688 +
102689 + hash = get_function_hash(func);
102690 + if (!hash || !(hash->param & (1U << argnum))) {
102691 + print_missing_msg(func, argnum);
102692 + return 0;
102693 + }
102694 + return argnum;
102695 +}
102696 +
102697 +static enum mark is_already_marked(const_tree lhs)
102698 +{
102699 + unsigned int argnum;
102700 + const_tree fndecl;
102701 +
102702 + argnum = search_missing_attribute(lhs);
102703 + fndecl = get_original_function_decl(current_function_decl);
102704 + if (argnum && mark_status(fndecl, argnum) == MARK_YES)
102705 + return MARK_YES;
102706 + return MARK_NO;
102707 +}
102708 +
102709 +static enum mark pre_expand(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
102710 +{
102711 + const_gimple def_stmt;
102712 +
102713 + if (skip_types(lhs))
102714 + return MARK_NO;
102715 +
102716 + if (TREE_CODE(lhs) == PARM_DECL)
102717 + return is_already_marked(lhs);
102718 +
102719 + if (TREE_CODE(lhs) == COMPONENT_REF) {
102720 + const_tree field, attr;
102721 +
102722 + field = search_field_decl(lhs);
102723 + attr = lookup_attribute("intentional_overflow", DECL_ATTRIBUTES(field));
102724 + if (!attr || !TREE_VALUE(attr))
102725 + return MARK_NO;
102726 + return MARK_YES;
102727 + }
102728 +
102729 + def_stmt = get_def_stmt(lhs);
102730 +
102731 + if (!def_stmt)
102732 + return MARK_NO;
102733 +
102734 + if (pointer_set_contains(visited, def_stmt))
102735 + return MARK_NO;
102736 +
102737 + switch (gimple_code(def_stmt)) {
102738 + case GIMPLE_NOP:
102739 + if (TREE_CODE(SSA_NAME_VAR(lhs)) == PARM_DECL)
102740 + return is_already_marked(lhs);
102741 + return MARK_NO;
102742 + case GIMPLE_PHI:
102743 + return walk_phi(visited, search_err_code, lhs);
102744 + case GIMPLE_CALL:
102745 + if (mark_status((gimple_call_fndecl(def_stmt)), 0) == MARK_TURN_OFF)
102746 + return MARK_TURN_OFF;
102747 + check_function_hash(def_stmt);
102748 + return MARK_NO;
102749 + case GIMPLE_ASM:
102750 + search_err_code[CAST_ONLY] = false;
102751 + return MARK_NO;
102752 + case GIMPLE_ASSIGN:
102753 + switch (gimple_num_ops(def_stmt)) {
102754 + case 2:
102755 + return walk_unary_ops(visited, search_err_code, lhs);
102756 + case 3:
102757 + return walk_binary_ops(visited, search_err_code, lhs);
102758 + }
102759 + default:
102760 + debug_gimple_stmt((gimple)def_stmt);
102761 + error("%s: unknown gimple code", __func__);
102762 + gcc_unreachable();
102763 + }
102764 +}
102765 +
102766 +// e.g., 3.8.2, 64, arch/x86/ia32/ia32_signal.c copy_siginfo_from_user32(): compat_ptr() u32 max
102767 +static bool skip_asm(const_tree arg)
102768 +{
102769 + gimple def_stmt = get_def_stmt(arg);
102770 +
102771 + if (!def_stmt || !gimple_assign_cast_p(def_stmt))
102772 + return false;
102773 +
102774 + def_stmt = get_def_stmt(gimple_assign_rhs1(def_stmt));
102775 + return def_stmt && gimple_code(def_stmt) == GIMPLE_ASM;
102776 +}
102777 +
102778 +/*
102779 +0</MARK_YES: no dup, search attributes (so, int)
102780 +0/MARK_NOT_INTENTIONAL: no dup, search attribute (int)
102781 +-1/MARK_TURN_OFF: no dup, no search, current_function_decl -> no dup
102782 +*/
102783 +
102784 +static bool search_attributes(tree fndecl, const_tree arg, unsigned int argnum, bool where)
102785 +{
102786 + struct pointer_set_t *visited;
102787 + enum mark is_marked, is_found;
102788 + location_t loc;
102789 + bool search_err_code[2] = {true, false};
102790 +
102791 + is_marked = mark_status(current_function_decl, 0);
102792 + if (is_marked == MARK_TURN_OFF)
102793 + return true;
102794 +
102795 + is_marked = mark_status(fndecl, argnum + 1);
102796 + if (is_marked == MARK_TURN_OFF || is_marked == MARK_NOT_INTENTIONAL)
102797 + return true;
102798 +
102799 + visited = pointer_set_create();
102800 + is_found = pre_expand(visited, search_err_code, arg);
102801 + pointer_set_destroy(visited);
102802 +
102803 + if (where == FROM_RET && search_err_code[CAST_ONLY] && search_err_code[FROM_CONST])
102804 + return true;
102805 +
102806 + if (where == FROM_ARG && skip_asm(arg))
102807 + return true;
102808 +
102809 + if (is_found == MARK_TURN_OFF)
102810 + return true;
102811 +
102812 + if ((is_found == MARK_YES && is_marked == MARK_YES))
102813 + return true;
102814 +
102815 + if (is_found == MARK_YES) {
102816 + loc = DECL_SOURCE_LOCATION(fndecl);
102817 + inform(loc, "The intentional_overflow attribute is missing from +%s+%u+", get_asm_name(fndecl), argnum + 1);
102818 + return true;
102819 + }
102820 + return false;
102821 +}
102822 +
102823 +static void handle_function_arg(gimple stmt, tree fndecl, unsigned int argnum)
102824 +{
102825 + struct pointer_set_t *visited;
102826 + tree arg, new_arg;
102827 + bool match;
102828 +
102829 + if (argnum == 0)
102830 + return;
102831 +
102832 + argnum--;
102833 +
102834 + match = get_function_arg(&argnum, fndecl);
102835 + if (!match)
102836 + return;
102837 + gcc_assert(gimple_call_num_args(stmt) > argnum);
102838 + arg = gimple_call_arg(stmt, argnum);
102839 + if (arg == NULL_TREE)
102840 + return;
102841 +
102842 + if (skip_types(arg))
102843 + return;
102844 +
102845 + if (search_attributes(fndecl, arg, argnum, FROM_ARG))
102846 + return;
102847 +
102848 + visited = pointer_set_create();
102849 + new_arg = expand(visited, arg);
102850 + pointer_set_destroy(visited);
102851 +
102852 + if (new_arg == NULL_TREE)
102853 + return;
102854 +
102855 + change_function_arg(stmt, arg, argnum, new_arg);
102856 + check_size_overflow(stmt, TREE_TYPE(new_arg), new_arg, arg, BEFORE_STMT);
102857 +}
102858 +
102859 +static void handle_function_by_attribute(gimple stmt, const_tree attr, tree fndecl)
102860 +{
102861 + tree p = TREE_VALUE(attr);
102862 + do {
102863 + handle_function_arg(stmt, fndecl, TREE_INT_CST_LOW(TREE_VALUE(p)));
102864 + p = TREE_CHAIN(p);
102865 + } while (p);
102866 +}
102867 +
102868 +static void handle_function_by_hash(gimple stmt, tree fndecl)
102869 +{
102870 + unsigned int num;
102871 + const struct size_overflow_hash *hash;
102872 +
102873 + hash = get_function_hash(fndecl);
102874 + if (!hash)
102875 + return;
102876 +
102877 + for (num = 0; num <= MAX_PARAM; num++)
102878 + if (hash->param & (1U << num))
102879 + handle_function_arg(stmt, fndecl, num);
102880 +}
102881 +
102882 +static bool check_return_value(void)
102883 +{
102884 + const struct size_overflow_hash *hash;
102885 +
102886 + hash = get_function_hash(current_function_decl);
102887 + if (!hash || !(hash->param & 1U << 0))
102888 + return false;
102889 +
102890 + return true;
102891 +}
102892 +
102893 +static void handle_return_value(gimple ret_stmt)
102894 +{
102895 + struct pointer_set_t *visited;
102896 + tree ret, new_ret;
102897 +
102898 + if (gimple_code(ret_stmt) != GIMPLE_RETURN)
102899 + return;
102900 +
102901 + ret = gimple_return_retval(ret_stmt);
102902 +
102903 + if (skip_types(ret))
102904 + return;
102905 +
102906 + if (search_attributes(current_function_decl, ret, 0, FROM_RET))
102907 + return;
102908 +
102909 + visited = pointer_set_create();
102910 + new_ret = expand(visited, ret);
102911 + pointer_set_destroy(visited);
102912 +
102913 + change_function_return(ret_stmt, ret, new_ret);
102914 + check_size_overflow(ret_stmt, TREE_TYPE(new_ret), new_ret, ret, BEFORE_STMT);
102915 +}
102916 +
102917 +static void set_plf_false(void)
102918 +{
102919 + basic_block bb;
102920 +
102921 + FOR_ALL_BB(bb) {
102922 + gimple_stmt_iterator si;
102923 +
102924 + for (si = gsi_start_bb(bb); !gsi_end_p(si); gsi_next(&si))
102925 + gimple_set_plf(gsi_stmt(si), MY_STMT, false);
102926 + for (si = gsi_start_phis(bb); !gsi_end_p(si); gsi_next(&si))
102927 + gimple_set_plf(gsi_stmt(si), MY_STMT, false);
102928 + }
102929 +}
102930 +
102931 +static unsigned int handle_function(void)
102932 +{
102933 + basic_block next, bb = ENTRY_BLOCK_PTR->next_bb;
102934 + bool check_ret;
102935 +
102936 + set_plf_false();
102937 +
102938 + check_ret = check_return_value();
102939 +
102940 + do {
102941 + gimple_stmt_iterator gsi;
102942 + next = bb->next_bb;
102943 +
102944 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
102945 + tree fndecl, attr;
102946 + gimple stmt = gsi_stmt(gsi);
102947 +
102948 + if (check_ret)
102949 + handle_return_value(stmt);
102950 +
102951 + if (!(is_gimple_call(stmt)))
102952 + continue;
102953 + fndecl = gimple_call_fndecl(stmt);
102954 + if (fndecl == NULL_TREE)
102955 + continue;
102956 + if (gimple_call_num_args(stmt) == 0)
102957 + continue;
102958 + attr = lookup_attribute("size_overflow", DECL_ATTRIBUTES(fndecl));
102959 + if (!attr || !TREE_VALUE(attr))
102960 + handle_function_by_hash(stmt, fndecl);
102961 + else
102962 + handle_function_by_attribute(stmt, attr, fndecl);
102963 + gsi = gsi_for_stmt(stmt);
102964 + next = gimple_bb(stmt)->next_bb;
102965 + }
102966 + bb = next;
102967 + } while (bb);
102968 + return 0;
102969 +}
102970 +
102971 +static struct gimple_opt_pass size_overflow_pass = {
102972 + .pass = {
102973 + .type = GIMPLE_PASS,
102974 + .name = "size_overflow",
102975 +#if BUILDING_GCC_VERSION >= 4008
102976 + .optinfo_flags = OPTGROUP_NONE,
102977 +#endif
102978 + .gate = NULL,
102979 + .execute = handle_function,
102980 + .sub = NULL,
102981 + .next = NULL,
102982 + .static_pass_number = 0,
102983 + .tv_id = TV_NONE,
102984 + .properties_required = PROP_cfg,
102985 + .properties_provided = 0,
102986 + .properties_destroyed = 0,
102987 + .todo_flags_start = 0,
102988 + .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
102989 + }
102990 +};
102991 +
102992 +static void start_unit_callback(void __unused *gcc_data, void __unused *user_data)
102993 +{
102994 + tree fntype;
102995 +
102996 + const_char_ptr_type_node = build_pointer_type(build_type_variant(char_type_node, 1, 0));
102997 +
102998 + // void report_size_overflow(const char *loc_file, unsigned int loc_line, const char *current_func, const char *ssa_var)
102999 + fntype = build_function_type_list(void_type_node,
103000 + const_char_ptr_type_node,
103001 + unsigned_type_node,
103002 + const_char_ptr_type_node,
103003 + const_char_ptr_type_node,
103004 + NULL_TREE);
103005 + report_size_overflow_decl = build_fn_decl("report_size_overflow", fntype);
103006 +
103007 + DECL_ASSEMBLER_NAME(report_size_overflow_decl);
103008 + TREE_PUBLIC(report_size_overflow_decl) = 1;
103009 + DECL_EXTERNAL(report_size_overflow_decl) = 1;
103010 + DECL_ARTIFICIAL(report_size_overflow_decl) = 1;
103011 + TREE_THIS_VOLATILE(report_size_overflow_decl) = 1;
103012 +}
103013 +
103014 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
103015 +{
103016 + int i;
103017 + const char * const plugin_name = plugin_info->base_name;
103018 + const int argc = plugin_info->argc;
103019 + const struct plugin_argument * const argv = plugin_info->argv;
103020 + bool enable = true;
103021 +
103022 + struct register_pass_info size_overflow_pass_info = {
103023 + .pass = &size_overflow_pass.pass,
103024 + .reference_pass_name = "ssa",
103025 + .ref_pass_instance_number = 1,
103026 + .pos_op = PASS_POS_INSERT_AFTER
103027 + };
103028 +
103029 + if (!plugin_default_version_check(version, &gcc_version)) {
103030 + error(G_("incompatible gcc/plugin versions"));
103031 + return 1;
103032 + }
103033 +
103034 + for (i = 0; i < argc; ++i) {
103035 + if (!strcmp(argv[i].key, "no-size-overflow")) {
103036 + enable = false;
103037 + continue;
103038 + }
103039 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
103040 + }
103041 +
103042 + register_callback(plugin_name, PLUGIN_INFO, NULL, &size_overflow_plugin_info);
103043 + if (enable) {
103044 + register_callback("start_unit", PLUGIN_START_UNIT, &start_unit_callback, NULL);
103045 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &size_overflow_pass_info);
103046 + }
103047 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
103048 +
103049 + return 0;
103050 +}
103051 diff --git a/tools/gcc/stackleak_plugin.c b/tools/gcc/stackleak_plugin.c
103052 new file mode 100644
103053 index 0000000..ac2901e
103054 --- /dev/null
103055 +++ b/tools/gcc/stackleak_plugin.c
103056 @@ -0,0 +1,327 @@
103057 +/*
103058 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
103059 + * Licensed under the GPL v2
103060 + *
103061 + * Note: the choice of the license means that the compilation process is
103062 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
103063 + * but for the kernel it doesn't matter since it doesn't link against
103064 + * any of the gcc libraries
103065 + *
103066 + * gcc plugin to help implement various PaX features
103067 + *
103068 + * - track lowest stack pointer
103069 + *
103070 + * TODO:
103071 + * - initialize all local variables
103072 + *
103073 + * BUGS:
103074 + * - none known
103075 + */
103076 +#include "gcc-plugin.h"
103077 +#include "config.h"
103078 +#include "system.h"
103079 +#include "coretypes.h"
103080 +#include "tree.h"
103081 +#include "tree-pass.h"
103082 +#include "flags.h"
103083 +#include "intl.h"
103084 +#include "toplev.h"
103085 +#include "plugin.h"
103086 +//#include "expr.h" where are you...
103087 +#include "diagnostic.h"
103088 +#include "plugin-version.h"
103089 +#include "tm.h"
103090 +#include "function.h"
103091 +#include "basic-block.h"
103092 +#include "gimple.h"
103093 +#include "rtl.h"
103094 +#include "emit-rtl.h"
103095 +
103096 +#if BUILDING_GCC_VERSION >= 4008
103097 +#define TODO_dump_func 0
103098 +#endif
103099 +
103100 +extern void print_gimple_stmt(FILE *, gimple, int, int);
103101 +
103102 +int plugin_is_GPL_compatible;
103103 +
103104 +static int track_frame_size = -1;
103105 +static const char track_function[] = "pax_track_stack";
103106 +static const char check_function[] = "pax_check_alloca";
103107 +static bool init_locals;
103108 +
103109 +static struct plugin_info stackleak_plugin_info = {
103110 + .version = "201302112000",
103111 + .help = "track-lowest-sp=nn\ttrack sp in functions whose frame size is at least nn bytes\n"
103112 +// "initialize-locals\t\tforcibly initialize all stack frames\n"
103113 +};
103114 +
103115 +static bool gate_stackleak_track_stack(void);
103116 +static unsigned int execute_stackleak_tree_instrument(void);
103117 +static unsigned int execute_stackleak_final(void);
103118 +
103119 +static struct gimple_opt_pass stackleak_tree_instrument_pass = {
103120 + .pass = {
103121 + .type = GIMPLE_PASS,
103122 + .name = "stackleak_tree_instrument",
103123 +#if BUILDING_GCC_VERSION >= 4008
103124 + .optinfo_flags = OPTGROUP_NONE,
103125 +#endif
103126 + .gate = gate_stackleak_track_stack,
103127 + .execute = execute_stackleak_tree_instrument,
103128 + .sub = NULL,
103129 + .next = NULL,
103130 + .static_pass_number = 0,
103131 + .tv_id = TV_NONE,
103132 + .properties_required = PROP_gimple_leh | PROP_cfg,
103133 + .properties_provided = 0,
103134 + .properties_destroyed = 0,
103135 + .todo_flags_start = 0, //TODO_verify_ssa | TODO_verify_flow | TODO_verify_stmts,
103136 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_update_ssa
103137 + }
103138 +};
103139 +
103140 +static struct rtl_opt_pass stackleak_final_rtl_opt_pass = {
103141 + .pass = {
103142 + .type = RTL_PASS,
103143 + .name = "stackleak_final",
103144 +#if BUILDING_GCC_VERSION >= 4008
103145 + .optinfo_flags = OPTGROUP_NONE,
103146 +#endif
103147 + .gate = gate_stackleak_track_stack,
103148 + .execute = execute_stackleak_final,
103149 + .sub = NULL,
103150 + .next = NULL,
103151 + .static_pass_number = 0,
103152 + .tv_id = TV_NONE,
103153 + .properties_required = 0,
103154 + .properties_provided = 0,
103155 + .properties_destroyed = 0,
103156 + .todo_flags_start = 0,
103157 + .todo_flags_finish = TODO_dump_func
103158 + }
103159 +};
103160 +
103161 +static bool gate_stackleak_track_stack(void)
103162 +{
103163 + return track_frame_size >= 0;
103164 +}
103165 +
103166 +static void stackleak_check_alloca(gimple_stmt_iterator *gsi)
103167 +{
103168 + gimple check_alloca;
103169 + tree fntype, fndecl, alloca_size;
103170 +
103171 + fntype = build_function_type_list(void_type_node, long_unsigned_type_node, NULL_TREE);
103172 + fndecl = build_fn_decl(check_function, fntype);
103173 + DECL_ASSEMBLER_NAME(fndecl); // for LTO
103174 +
103175 + // insert call to void pax_check_alloca(unsigned long size)
103176 + alloca_size = gimple_call_arg(gsi_stmt(*gsi), 0);
103177 + check_alloca = gimple_build_call(fndecl, 1, alloca_size);
103178 + gsi_insert_before(gsi, check_alloca, GSI_SAME_STMT);
103179 +}
103180 +
103181 +static void stackleak_add_instrumentation(gimple_stmt_iterator *gsi)
103182 +{
103183 + gimple track_stack;
103184 + tree fntype, fndecl;
103185 +
103186 + fntype = build_function_type_list(void_type_node, NULL_TREE);
103187 + fndecl = build_fn_decl(track_function, fntype);
103188 + DECL_ASSEMBLER_NAME(fndecl); // for LTO
103189 +
103190 + // insert call to void pax_track_stack(void)
103191 + track_stack = gimple_build_call(fndecl, 0);
103192 + gsi_insert_after(gsi, track_stack, GSI_CONTINUE_LINKING);
103193 +}
103194 +
103195 +#if BUILDING_GCC_VERSION == 4005
103196 +static bool gimple_call_builtin_p(gimple stmt, enum built_in_function code)
103197 +{
103198 + tree fndecl;
103199 +
103200 + if (!is_gimple_call(stmt))
103201 + return false;
103202 + fndecl = gimple_call_fndecl(stmt);
103203 + if (!fndecl)
103204 + return false;
103205 + if (DECL_BUILT_IN_CLASS(fndecl) != BUILT_IN_NORMAL)
103206 + return false;
103207 +// print_node(stderr, "pax", fndecl, 4);
103208 + return DECL_FUNCTION_CODE(fndecl) == code;
103209 +}
103210 +#endif
103211 +
103212 +static bool is_alloca(gimple stmt)
103213 +{
103214 + if (gimple_call_builtin_p(stmt, BUILT_IN_ALLOCA))
103215 + return true;
103216 +
103217 +#if BUILDING_GCC_VERSION >= 4007
103218 + if (gimple_call_builtin_p(stmt, BUILT_IN_ALLOCA_WITH_ALIGN))
103219 + return true;
103220 +#endif
103221 +
103222 + return false;
103223 +}
103224 +
103225 +static unsigned int execute_stackleak_tree_instrument(void)
103226 +{
103227 + basic_block bb, entry_bb;
103228 + bool prologue_instrumented = false, is_leaf = true;
103229 +
103230 + entry_bb = ENTRY_BLOCK_PTR_FOR_FUNCTION(cfun)->next_bb;
103231 +
103232 + // 1. loop through BBs and GIMPLE statements
103233 + FOR_EACH_BB(bb) {
103234 + gimple_stmt_iterator gsi;
103235 +
103236 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
103237 + gimple stmt;
103238 +
103239 + stmt = gsi_stmt(gsi);
103240 +
103241 + if (is_gimple_call(stmt))
103242 + is_leaf = false;
103243 +
103244 + // gimple match: align 8 built-in BUILT_IN_NORMAL:BUILT_IN_ALLOCA attributes <tree_list 0xb7576450>
103245 + if (!is_alloca(stmt))
103246 + continue;
103247 +
103248 + // 2. insert stack overflow check before each __builtin_alloca call
103249 + stackleak_check_alloca(&gsi);
103250 +
103251 + // 3. insert track call after each __builtin_alloca call
103252 + stackleak_add_instrumentation(&gsi);
103253 + if (bb == entry_bb)
103254 + prologue_instrumented = true;
103255 + }
103256 + }
103257 +
103258 + // special cases for some bad linux code: taking the address of static inline functions will materialize them
103259 + // but we mustn't instrument some of them as the resulting stack alignment required by the function call ABI
103260 + // will break other assumptions regarding the expected (but not otherwise enforced) register clobbering ABI.
103261 + // case in point: native_save_fl on amd64 when optimized for size clobbers rdx if it were instrumented here.
103262 + if (is_leaf && !TREE_PUBLIC(current_function_decl) && DECL_DECLARED_INLINE_P(current_function_decl))
103263 + return 0;
103264 + if (is_leaf && !strncmp(IDENTIFIER_POINTER(DECL_NAME(current_function_decl)), "_paravirt_", 10))
103265 + return 0;
103266 +
103267 + // 4. insert track call at the beginning
103268 + if (!prologue_instrumented) {
103269 + gimple_stmt_iterator gsi;
103270 +
103271 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
103272 + if (dom_info_available_p(CDI_DOMINATORS))
103273 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
103274 + gsi = gsi_start_bb(bb);
103275 + stackleak_add_instrumentation(&gsi);
103276 + }
103277 +
103278 + return 0;
103279 +}
103280 +
103281 +static unsigned int execute_stackleak_final(void)
103282 +{
103283 + rtx insn, next;
103284 +
103285 + if (cfun->calls_alloca)
103286 + return 0;
103287 +
103288 + // keep calls only if function frame is big enough
103289 + if (get_frame_size() >= track_frame_size)
103290 + return 0;
103291 +
103292 + // 1. find pax_track_stack calls
103293 + for (insn = get_insns(); insn; insn = next) {
103294 + // 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))
103295 + rtx body;
103296 +
103297 + next = NEXT_INSN(insn);
103298 + if (!CALL_P(insn))
103299 + continue;
103300 + body = PATTERN(insn);
103301 + if (GET_CODE(body) != CALL)
103302 + continue;
103303 + body = XEXP(body, 0);
103304 + if (GET_CODE(body) != MEM)
103305 + continue;
103306 + body = XEXP(body, 0);
103307 + if (GET_CODE(body) != SYMBOL_REF)
103308 + continue;
103309 + if (strcmp(XSTR(body, 0), track_function))
103310 + continue;
103311 +// warning(0, "track_frame_size: %d %ld %d", cfun->calls_alloca, get_frame_size(), track_frame_size);
103312 + // 2. delete call
103313 + delete_insn_and_edges(insn);
103314 +#if BUILDING_GCC_VERSION >= 4007
103315 + if (GET_CODE(next) == NOTE && NOTE_KIND(next) == NOTE_INSN_CALL_ARG_LOCATION) {
103316 + insn = next;
103317 + next = NEXT_INSN(insn);
103318 + delete_insn_and_edges(insn);
103319 + }
103320 +#endif
103321 + }
103322 +
103323 +// print_simple_rtl(stderr, get_insns());
103324 +// print_rtl(stderr, get_insns());
103325 +// warning(0, "track_frame_size: %d %ld %d", cfun->calls_alloca, get_frame_size(), track_frame_size);
103326 +
103327 + return 0;
103328 +}
103329 +
103330 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
103331 +{
103332 + const char * const plugin_name = plugin_info->base_name;
103333 + const int argc = plugin_info->argc;
103334 + const struct plugin_argument * const argv = plugin_info->argv;
103335 + int i;
103336 + struct register_pass_info stackleak_tree_instrument_pass_info = {
103337 + .pass = &stackleak_tree_instrument_pass.pass,
103338 +// .reference_pass_name = "tree_profile",
103339 + .reference_pass_name = "optimized",
103340 + .ref_pass_instance_number = 1,
103341 + .pos_op = PASS_POS_INSERT_BEFORE
103342 + };
103343 + struct register_pass_info stackleak_final_pass_info = {
103344 + .pass = &stackleak_final_rtl_opt_pass.pass,
103345 + .reference_pass_name = "final",
103346 + .ref_pass_instance_number = 1,
103347 + .pos_op = PASS_POS_INSERT_BEFORE
103348 + };
103349 +
103350 + if (!plugin_default_version_check(version, &gcc_version)) {
103351 + error(G_("incompatible gcc/plugin versions"));
103352 + return 1;
103353 + }
103354 +
103355 + register_callback(plugin_name, PLUGIN_INFO, NULL, &stackleak_plugin_info);
103356 +
103357 + for (i = 0; i < argc; ++i) {
103358 + if (!strcmp(argv[i].key, "track-lowest-sp")) {
103359 + if (!argv[i].value) {
103360 + error(G_("no value supplied for option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
103361 + continue;
103362 + }
103363 + track_frame_size = atoi(argv[i].value);
103364 + if (argv[i].value[0] < '0' || argv[i].value[0] > '9' || track_frame_size < 0)
103365 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
103366 + continue;
103367 + }
103368 + if (!strcmp(argv[i].key, "initialize-locals")) {
103369 + if (argv[i].value) {
103370 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
103371 + continue;
103372 + }
103373 + init_locals = true;
103374 + continue;
103375 + }
103376 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
103377 + }
103378 +
103379 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &stackleak_tree_instrument_pass_info);
103380 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &stackleak_final_pass_info);
103381 +
103382 + return 0;
103383 +}
103384 diff --git a/tools/gcc/structleak_plugin.c b/tools/gcc/structleak_plugin.c
103385 new file mode 100644
103386 index 0000000..4fae911
103387 --- /dev/null
103388 +++ b/tools/gcc/structleak_plugin.c
103389 @@ -0,0 +1,277 @@
103390 +/*
103391 + * Copyright 2013 by PaX Team <pageexec@freemail.hu>
103392 + * Licensed under the GPL v2
103393 + *
103394 + * Note: the choice of the license means that the compilation process is
103395 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
103396 + * but for the kernel it doesn't matter since it doesn't link against
103397 + * any of the gcc libraries
103398 + *
103399 + * gcc plugin to forcibly initialize certain local variables that could
103400 + * otherwise leak kernel stack to userland if they aren't properly initialized
103401 + * by later code
103402 + *
103403 + * Homepage: http://pax.grsecurity.net/
103404 + *
103405 + * Usage:
103406 + * $ # for 4.5/4.6/C based 4.7
103407 + * $ 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
103408 + * $ # for C++ based 4.7/4.8+
103409 + * $ 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
103410 + * $ gcc -fplugin=./structleak_plugin.so test.c -O2
103411 + *
103412 + * TODO: eliminate redundant initializers
103413 + * increase type coverage
103414 + */
103415 +
103416 +#include "gcc-plugin.h"
103417 +#include "config.h"
103418 +#include "system.h"
103419 +#include "coretypes.h"
103420 +#include "tree.h"
103421 +#include "tree-pass.h"
103422 +#include "intl.h"
103423 +#include "plugin-version.h"
103424 +#include "tm.h"
103425 +#include "toplev.h"
103426 +#include "function.h"
103427 +#include "tree-flow.h"
103428 +#include "plugin.h"
103429 +#include "gimple.h"
103430 +#include "diagnostic.h"
103431 +#include "cfgloop.h"
103432 +#include "langhooks.h"
103433 +
103434 +#if BUILDING_GCC_VERSION >= 4008
103435 +#define TODO_dump_func 0
103436 +#endif
103437 +
103438 +#define NAME(node) IDENTIFIER_POINTER(DECL_NAME(node))
103439 +
103440 +// unused type flag in all versions 4.5-4.8
103441 +#define TYPE_USERSPACE(TYPE) TYPE_LANG_FLAG_3(TYPE)
103442 +
103443 +int plugin_is_GPL_compatible;
103444 +void debug_gimple_stmt(gimple gs);
103445 +
103446 +static struct plugin_info structleak_plugin_info = {
103447 + .version = "201304082245",
103448 + .help = "disable\tdo not activate plugin\n",
103449 +};
103450 +
103451 +static tree handle_user_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
103452 +{
103453 + *no_add_attrs = true;
103454 +
103455 + // check for types? for now accept everything linux has to offer
103456 + if (TREE_CODE(*node) != FIELD_DECL)
103457 + return NULL_TREE;
103458 +
103459 + *no_add_attrs = false;
103460 + return NULL_TREE;
103461 +}
103462 +
103463 +static struct attribute_spec user_attr = {
103464 + .name = "user",
103465 + .min_length = 0,
103466 + .max_length = 0,
103467 + .decl_required = false,
103468 + .type_required = false,
103469 + .function_type_required = false,
103470 + .handler = handle_user_attribute,
103471 +#if BUILDING_GCC_VERSION >= 4007
103472 + .affects_type_identity = true
103473 +#endif
103474 +};
103475 +
103476 +static void register_attributes(void *event_data, void *data)
103477 +{
103478 + register_attribute(&user_attr);
103479 +// register_attribute(&force_attr);
103480 +}
103481 +
103482 +static tree get_field_type(tree field)
103483 +{
103484 + return strip_array_types(TREE_TYPE(field));
103485 +}
103486 +
103487 +static bool is_userspace_type(tree type)
103488 +{
103489 + tree field;
103490 +
103491 + for (field = TYPE_FIELDS(type); field; field = TREE_CHAIN(field)) {
103492 + tree fieldtype = get_field_type(field);
103493 + enum tree_code code = TREE_CODE(fieldtype);
103494 +
103495 + if (code == RECORD_TYPE || code == UNION_TYPE)
103496 + if (is_userspace_type(fieldtype))
103497 + return true;
103498 +
103499 + if (lookup_attribute("user", DECL_ATTRIBUTES(field)))
103500 + return true;
103501 + }
103502 + return false;
103503 +}
103504 +
103505 +static void finish_type(void *event_data, void *data)
103506 +{
103507 + tree type = (tree)event_data;
103508 +
103509 + if (TYPE_USERSPACE(type))
103510 + return;
103511 +
103512 + if (is_userspace_type(type))
103513 + TYPE_USERSPACE(type) = 1;
103514 +}
103515 +
103516 +static void initialize(tree var)
103517 +{
103518 + basic_block bb;
103519 + gimple_stmt_iterator gsi;
103520 + tree initializer;
103521 + gimple init_stmt;
103522 +
103523 + // this is the original entry bb before the forced split
103524 + // TODO: check further BBs in case more splits occured before us
103525 + bb = ENTRY_BLOCK_PTR->next_bb->next_bb;
103526 +
103527 + // first check if the variable is already initialized, warn otherwise
103528 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
103529 + gimple stmt = gsi_stmt(gsi);
103530 + tree rhs1;
103531 +
103532 + // we're looking for an assignment of a single rhs...
103533 + if (!gimple_assign_single_p(stmt))
103534 + continue;
103535 + rhs1 = gimple_assign_rhs1(stmt);
103536 +#if BUILDING_GCC_VERSION >= 4007
103537 + // ... of a non-clobbering expression...
103538 + if (TREE_CLOBBER_P(rhs1))
103539 + continue;
103540 +#endif
103541 + // ... to our variable...
103542 + if (gimple_get_lhs(stmt) != var)
103543 + continue;
103544 + // if it's an initializer then we're good
103545 + if (TREE_CODE(rhs1) == CONSTRUCTOR)
103546 + return;
103547 + }
103548 +
103549 + // these aren't the 0days you're looking for
103550 +// inform(DECL_SOURCE_LOCATION(var), "userspace variable will be forcibly initialized");
103551 +
103552 + // build the initializer expression
103553 + initializer = build_constructor(TREE_TYPE(var), NULL);
103554 +
103555 + // build the initializer stmt
103556 + init_stmt = gimple_build_assign(var, initializer);
103557 + gsi = gsi_start_bb(ENTRY_BLOCK_PTR->next_bb);
103558 + gsi_insert_before(&gsi, init_stmt, GSI_NEW_STMT);
103559 + update_stmt(init_stmt);
103560 +}
103561 +
103562 +static unsigned int handle_function(void)
103563 +{
103564 + basic_block bb;
103565 + unsigned int ret = 0;
103566 + tree var;
103567 +
103568 +#if BUILDING_GCC_VERSION == 4005
103569 + tree vars;
103570 +#else
103571 + unsigned int i;
103572 +#endif
103573 +
103574 + // split the first bb where we can put the forced initializers
103575 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
103576 + if (dom_info_available_p(CDI_DOMINATORS))
103577 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
103578 +
103579 + // enumarate all local variables and forcibly initialize our targets
103580 +#if BUILDING_GCC_VERSION == 4005
103581 + for (vars = cfun->local_decls; vars; vars = TREE_CHAIN(vars)) {
103582 + var = TREE_VALUE(vars);
103583 +#else
103584 + FOR_EACH_LOCAL_DECL(cfun, i, var) {
103585 +#endif
103586 + tree type = TREE_TYPE(var);
103587 +
103588 + gcc_assert(DECL_P(var));
103589 + if (!auto_var_in_fn_p(var, current_function_decl))
103590 + continue;
103591 +
103592 + // only care about structure types
103593 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
103594 + continue;
103595 +
103596 + // if the type is of interest, examine the variable
103597 + if (TYPE_USERSPACE(type))
103598 + initialize(var);
103599 + }
103600 +
103601 + return ret;
103602 +}
103603 +
103604 +static struct gimple_opt_pass structleak_pass = {
103605 + .pass = {
103606 + .type = GIMPLE_PASS,
103607 + .name = "structleak",
103608 +#if BUILDING_GCC_VERSION >= 4008
103609 + .optinfo_flags = OPTGROUP_NONE,
103610 +#endif
103611 + .gate = NULL,
103612 + .execute = handle_function,
103613 + .sub = NULL,
103614 + .next = NULL,
103615 + .static_pass_number = 0,
103616 + .tv_id = TV_NONE,
103617 + .properties_required = PROP_cfg,
103618 + .properties_provided = 0,
103619 + .properties_destroyed = 0,
103620 + .todo_flags_start = 0,
103621 + .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
103622 + }
103623 +};
103624 +
103625 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
103626 +{
103627 + int i;
103628 + const char * const plugin_name = plugin_info->base_name;
103629 + const int argc = plugin_info->argc;
103630 + const struct plugin_argument * const argv = plugin_info->argv;
103631 + bool enable = true;
103632 +
103633 + struct register_pass_info structleak_pass_info = {
103634 + .pass = &structleak_pass.pass,
103635 + .reference_pass_name = "ssa",
103636 + .ref_pass_instance_number = 1,
103637 + .pos_op = PASS_POS_INSERT_AFTER
103638 + };
103639 +
103640 + if (!plugin_default_version_check(version, &gcc_version)) {
103641 + error(G_("incompatible gcc/plugin versions"));
103642 + return 1;
103643 + }
103644 +
103645 + if (strcmp(lang_hooks.name, "GNU C")) {
103646 + inform(UNKNOWN_LOCATION, G_("%s supports C only"), plugin_name);
103647 + enable = false;
103648 + }
103649 +
103650 + for (i = 0; i < argc; ++i) {
103651 + if (!strcmp(argv[i].key, "disable")) {
103652 + enable = false;
103653 + continue;
103654 + }
103655 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
103656 + }
103657 +
103658 + register_callback(plugin_name, PLUGIN_INFO, NULL, &structleak_plugin_info);
103659 + if (enable) {
103660 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &structleak_pass_info);
103661 + register_callback(plugin_name, PLUGIN_FINISH_TYPE, finish_type, NULL);
103662 + }
103663 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
103664 +
103665 + return 0;
103666 +}
103667 diff --git a/tools/perf/util/include/asm/alternative-asm.h b/tools/perf/util/include/asm/alternative-asm.h
103668 index 6789d78..4afd019e 100644
103669 --- a/tools/perf/util/include/asm/alternative-asm.h
103670 +++ b/tools/perf/util/include/asm/alternative-asm.h
103671 @@ -5,4 +5,7 @@
103672
103673 #define altinstruction_entry #
103674
103675 + .macro pax_force_retaddr rip=0, reload=0
103676 + .endm
103677 +
103678 #endif
103679 diff --git a/tools/perf/util/include/linux/compiler.h b/tools/perf/util/include/linux/compiler.h
103680 index 96b919d..c49bb74 100644
103681 --- a/tools/perf/util/include/linux/compiler.h
103682 +++ b/tools/perf/util/include/linux/compiler.h
103683 @@ -18,4 +18,12 @@
103684 #define __force
103685 #endif
103686
103687 +#ifndef __size_overflow
103688 +# define __size_overflow(...)
103689 +#endif
103690 +
103691 +#ifndef __intentional_overflow
103692 +# define __intentional_overflow(...)
103693 +#endif
103694 +
103695 #endif
103696 diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
103697 index f18013f..90421df 100644
103698 --- a/virt/kvm/kvm_main.c
103699 +++ b/virt/kvm/kvm_main.c
103700 @@ -75,12 +75,17 @@ LIST_HEAD(vm_list);
103701
103702 static cpumask_var_t cpus_hardware_enabled;
103703 static int kvm_usage_count = 0;
103704 -static atomic_t hardware_enable_failed;
103705 +static atomic_unchecked_t hardware_enable_failed;
103706
103707 struct kmem_cache *kvm_vcpu_cache;
103708 EXPORT_SYMBOL_GPL(kvm_vcpu_cache);
103709
103710 -static __read_mostly struct preempt_ops kvm_preempt_ops;
103711 +static void kvm_sched_in(struct preempt_notifier *pn, int cpu);
103712 +static void kvm_sched_out(struct preempt_notifier *pn, struct task_struct *next);
103713 +static struct preempt_ops kvm_preempt_ops = {
103714 + .sched_in = kvm_sched_in,
103715 + .sched_out = kvm_sched_out,
103716 +};
103717
103718 struct dentry *kvm_debugfs_dir;
103719
103720 @@ -769,7 +774,7 @@ int __kvm_set_memory_region(struct kvm *kvm,
103721 /* We can read the guest memory with __xxx_user() later on. */
103722 if (user_alloc &&
103723 ((mem->userspace_addr & (PAGE_SIZE - 1)) ||
103724 - !access_ok(VERIFY_WRITE,
103725 + !__access_ok(VERIFY_WRITE,
103726 (void __user *)(unsigned long)mem->userspace_addr,
103727 mem->memory_size)))
103728 goto out;
103729 @@ -1881,7 +1886,7 @@ static int kvm_vcpu_release(struct inode *inode, struct file *filp)
103730 return 0;
103731 }
103732
103733 -static struct file_operations kvm_vcpu_fops = {
103734 +static file_operations_no_const kvm_vcpu_fops __read_only = {
103735 .release = kvm_vcpu_release,
103736 .unlocked_ioctl = kvm_vcpu_ioctl,
103737 #ifdef CONFIG_COMPAT
103738 @@ -2402,7 +2407,7 @@ static int kvm_vm_mmap(struct file *file, struct vm_area_struct *vma)
103739 return 0;
103740 }
103741
103742 -static struct file_operations kvm_vm_fops = {
103743 +static file_operations_no_const kvm_vm_fops __read_only = {
103744 .release = kvm_vm_release,
103745 .unlocked_ioctl = kvm_vm_ioctl,
103746 #ifdef CONFIG_COMPAT
103747 @@ -2500,7 +2505,7 @@ out:
103748 return r;
103749 }
103750
103751 -static struct file_operations kvm_chardev_ops = {
103752 +static file_operations_no_const kvm_chardev_ops __read_only = {
103753 .unlocked_ioctl = kvm_dev_ioctl,
103754 .compat_ioctl = kvm_dev_ioctl,
103755 .llseek = noop_llseek,
103756 @@ -2526,7 +2531,7 @@ static void hardware_enable_nolock(void *junk)
103757
103758 if (r) {
103759 cpumask_clear_cpu(cpu, cpus_hardware_enabled);
103760 - atomic_inc(&hardware_enable_failed);
103761 + atomic_inc_unchecked(&hardware_enable_failed);
103762 printk(KERN_INFO "kvm: enabling virtualization on "
103763 "CPU%d failed\n", cpu);
103764 }
103765 @@ -2580,10 +2585,10 @@ static int hardware_enable_all(void)
103766
103767 kvm_usage_count++;
103768 if (kvm_usage_count == 1) {
103769 - atomic_set(&hardware_enable_failed, 0);
103770 + atomic_set_unchecked(&hardware_enable_failed, 0);
103771 on_each_cpu(hardware_enable_nolock, NULL, 1);
103772
103773 - if (atomic_read(&hardware_enable_failed)) {
103774 + if (atomic_read_unchecked(&hardware_enable_failed)) {
103775 hardware_disable_all_nolock();
103776 r = -EBUSY;
103777 }
103778 @@ -2941,7 +2946,7 @@ static void kvm_sched_out(struct preempt_notifier *pn,
103779 kvm_arch_vcpu_put(vcpu);
103780 }
103781
103782 -int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
103783 +int kvm_init(const void *opaque, unsigned vcpu_size, unsigned vcpu_align,
103784 struct module *module)
103785 {
103786 int r;
103787 @@ -2977,7 +2982,7 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
103788 if (!vcpu_align)
103789 vcpu_align = __alignof__(struct kvm_vcpu);
103790 kvm_vcpu_cache = kmem_cache_create("kvm_vcpu", vcpu_size, vcpu_align,
103791 - 0, NULL);
103792 + SLAB_USERCOPY, NULL);
103793 if (!kvm_vcpu_cache) {
103794 r = -ENOMEM;
103795 goto out_free_3;
103796 @@ -2987,9 +2992,11 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
103797 if (r)
103798 goto out_free;
103799
103800 + pax_open_kernel();
103801 kvm_chardev_ops.owner = module;
103802 kvm_vm_fops.owner = module;
103803 kvm_vcpu_fops.owner = module;
103804 + pax_close_kernel();
103805
103806 r = misc_register(&kvm_dev);
103807 if (r) {
103808 @@ -2999,9 +3006,6 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
103809
103810 register_syscore_ops(&kvm_syscore_ops);
103811
103812 - kvm_preempt_ops.sched_in = kvm_sched_in;
103813 - kvm_preempt_ops.sched_out = kvm_sched_out;
103814 -
103815 r = kvm_init_debug();
103816 if (r) {
103817 printk(KERN_ERR "kvm: create debugfs files failed\n");