]> git.ipfire.org Git - thirdparty/grsecurity-scrape.git/blob - test/grsecurity-2.9.1-3.9.5-201306102218.patch
Auto commit, 1 new patch{es}.
[thirdparty/grsecurity-scrape.git] / test / grsecurity-2.9.1-3.9.5-201306102218.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 8818c95..ced0bb1 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 3a750de..4c9b88f 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/drivers.c b/arch/parisc/kernel/drivers.c
5767 index 5709c5e..14285ca 100644
5768 --- a/arch/parisc/kernel/drivers.c
5769 +++ b/arch/parisc/kernel/drivers.c
5770 @@ -394,7 +394,7 @@ EXPORT_SYMBOL(print_pci_hwpath);
5771 static void setup_bus_id(struct parisc_device *padev)
5772 {
5773 struct hardware_path path;
5774 - char name[20];
5775 + char name[28];
5776 char *output = name;
5777 int i;
5778
5779 diff --git a/arch/parisc/kernel/module.c b/arch/parisc/kernel/module.c
5780 index 2a625fb..9908930 100644
5781 --- a/arch/parisc/kernel/module.c
5782 +++ b/arch/parisc/kernel/module.c
5783 @@ -98,16 +98,38 @@
5784
5785 /* three functions to determine where in the module core
5786 * or init pieces the location is */
5787 +static inline int in_init_rx(struct module *me, void *loc)
5788 +{
5789 + return (loc >= me->module_init_rx &&
5790 + loc < (me->module_init_rx + me->init_size_rx));
5791 +}
5792 +
5793 +static inline int in_init_rw(struct module *me, void *loc)
5794 +{
5795 + return (loc >= me->module_init_rw &&
5796 + loc < (me->module_init_rw + me->init_size_rw));
5797 +}
5798 +
5799 static inline int in_init(struct module *me, void *loc)
5800 {
5801 - return (loc >= me->module_init &&
5802 - loc <= (me->module_init + me->init_size));
5803 + return in_init_rx(me, loc) || in_init_rw(me, loc);
5804 +}
5805 +
5806 +static inline int in_core_rx(struct module *me, void *loc)
5807 +{
5808 + return (loc >= me->module_core_rx &&
5809 + loc < (me->module_core_rx + me->core_size_rx));
5810 +}
5811 +
5812 +static inline int in_core_rw(struct module *me, void *loc)
5813 +{
5814 + return (loc >= me->module_core_rw &&
5815 + loc < (me->module_core_rw + me->core_size_rw));
5816 }
5817
5818 static inline int in_core(struct module *me, void *loc)
5819 {
5820 - return (loc >= me->module_core &&
5821 - loc <= (me->module_core + me->core_size));
5822 + return in_core_rx(me, loc) || in_core_rw(me, loc);
5823 }
5824
5825 static inline int in_local(struct module *me, void *loc)
5826 @@ -371,13 +393,13 @@ int module_frob_arch_sections(CONST Elf_Ehdr *hdr,
5827 }
5828
5829 /* align things a bit */
5830 - me->core_size = ALIGN(me->core_size, 16);
5831 - me->arch.got_offset = me->core_size;
5832 - me->core_size += gots * sizeof(struct got_entry);
5833 + me->core_size_rw = ALIGN(me->core_size_rw, 16);
5834 + me->arch.got_offset = me->core_size_rw;
5835 + me->core_size_rw += gots * sizeof(struct got_entry);
5836
5837 - me->core_size = ALIGN(me->core_size, 16);
5838 - me->arch.fdesc_offset = me->core_size;
5839 - me->core_size += fdescs * sizeof(Elf_Fdesc);
5840 + me->core_size_rw = ALIGN(me->core_size_rw, 16);
5841 + me->arch.fdesc_offset = me->core_size_rw;
5842 + me->core_size_rw += fdescs * sizeof(Elf_Fdesc);
5843
5844 me->arch.got_max = gots;
5845 me->arch.fdesc_max = fdescs;
5846 @@ -395,7 +417,7 @@ static Elf64_Word get_got(struct module *me, unsigned long value, long addend)
5847
5848 BUG_ON(value == 0);
5849
5850 - got = me->module_core + me->arch.got_offset;
5851 + got = me->module_core_rw + me->arch.got_offset;
5852 for (i = 0; got[i].addr; i++)
5853 if (got[i].addr == value)
5854 goto out;
5855 @@ -413,7 +435,7 @@ static Elf64_Word get_got(struct module *me, unsigned long value, long addend)
5856 #ifdef CONFIG_64BIT
5857 static Elf_Addr get_fdesc(struct module *me, unsigned long value)
5858 {
5859 - Elf_Fdesc *fdesc = me->module_core + me->arch.fdesc_offset;
5860 + Elf_Fdesc *fdesc = me->module_core_rw + me->arch.fdesc_offset;
5861
5862 if (!value) {
5863 printk(KERN_ERR "%s: zero OPD requested!\n", me->name);
5864 @@ -431,7 +453,7 @@ static Elf_Addr get_fdesc(struct module *me, unsigned long value)
5865
5866 /* Create new one */
5867 fdesc->addr = value;
5868 - fdesc->gp = (Elf_Addr)me->module_core + me->arch.got_offset;
5869 + fdesc->gp = (Elf_Addr)me->module_core_rw + me->arch.got_offset;
5870 return (Elf_Addr)fdesc;
5871 }
5872 #endif /* CONFIG_64BIT */
5873 @@ -843,7 +865,7 @@ register_unwind_table(struct module *me,
5874
5875 table = (unsigned char *)sechdrs[me->arch.unwind_section].sh_addr;
5876 end = table + sechdrs[me->arch.unwind_section].sh_size;
5877 - gp = (Elf_Addr)me->module_core + me->arch.got_offset;
5878 + gp = (Elf_Addr)me->module_core_rw + me->arch.got_offset;
5879
5880 DEBUGP("register_unwind_table(), sect = %d at 0x%p - 0x%p (gp=0x%lx)\n",
5881 me->arch.unwind_section, table, end, gp);
5882 diff --git a/arch/parisc/kernel/setup.c b/arch/parisc/kernel/setup.c
5883 index a3328c2..3b812eb 100644
5884 --- a/arch/parisc/kernel/setup.c
5885 +++ b/arch/parisc/kernel/setup.c
5886 @@ -69,7 +69,8 @@ void __init setup_cmdline(char **cmdline_p)
5887 /* called from hpux boot loader */
5888 boot_command_line[0] = '\0';
5889 } else {
5890 - strcpy(boot_command_line, (char *)__va(boot_args[1]));
5891 + strlcpy(boot_command_line, (char *)__va(boot_args[1]),
5892 + COMMAND_LINE_SIZE);
5893
5894 #ifdef CONFIG_BLK_DEV_INITRD
5895 if (boot_args[2] != 0) /* did palo pass us a ramdisk? */
5896 diff --git a/arch/parisc/kernel/sys_parisc.c b/arch/parisc/kernel/sys_parisc.c
5897 index 5dfd248..64914ac 100644
5898 --- a/arch/parisc/kernel/sys_parisc.c
5899 +++ b/arch/parisc/kernel/sys_parisc.c
5900 @@ -33,9 +33,11 @@
5901 #include <linux/utsname.h>
5902 #include <linux/personality.h>
5903
5904 -static unsigned long get_unshared_area(unsigned long addr, unsigned long len)
5905 +static unsigned long get_unshared_area(struct file *filp, unsigned long addr, unsigned long len,
5906 + unsigned long flags)
5907 {
5908 struct vm_unmapped_area_info info;
5909 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
5910
5911 info.flags = 0;
5912 info.length = len;
5913 @@ -43,6 +45,7 @@ static unsigned long get_unshared_area(unsigned long addr, unsigned long len)
5914 info.high_limit = TASK_SIZE;
5915 info.align_mask = 0;
5916 info.align_offset = 0;
5917 + info.threadstack_offset = offset;
5918 return vm_unmapped_area(&info);
5919 }
5920
5921 @@ -61,10 +64,11 @@ static int get_offset(struct address_space *mapping)
5922 return (unsigned long) mapping >> 8;
5923 }
5924
5925 -static unsigned long get_shared_area(struct address_space *mapping,
5926 - unsigned long addr, unsigned long len, unsigned long pgoff)
5927 +static unsigned long get_shared_area(struct file *filp, struct address_space *mapping,
5928 + unsigned long addr, unsigned long len, unsigned long pgoff, unsigned long flags)
5929 {
5930 struct vm_unmapped_area_info info;
5931 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
5932
5933 info.flags = 0;
5934 info.length = len;
5935 @@ -72,6 +76,7 @@ static unsigned long get_shared_area(struct address_space *mapping,
5936 info.high_limit = TASK_SIZE;
5937 info.align_mask = PAGE_MASK & (SHMLBA - 1);
5938 info.align_offset = (get_offset(mapping) + pgoff) << PAGE_SHIFT;
5939 + info.threadstack_offset = offset;
5940 return vm_unmapped_area(&info);
5941 }
5942
5943 @@ -86,15 +91,22 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
5944 return -EINVAL;
5945 return addr;
5946 }
5947 - if (!addr)
5948 + if (!addr) {
5949 addr = TASK_UNMAPPED_BASE;
5950
5951 +#ifdef CONFIG_PAX_RANDMMAP
5952 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
5953 + addr += current->mm->delta_mmap;
5954 +#endif
5955 +
5956 + }
5957 +
5958 if (filp) {
5959 - addr = get_shared_area(filp->f_mapping, addr, len, pgoff);
5960 + addr = get_shared_area(filp, filp->f_mapping, addr, len, pgoff, flags);
5961 } else if(flags & MAP_SHARED) {
5962 - addr = get_shared_area(NULL, addr, len, pgoff);
5963 + addr = get_shared_area(filp, NULL, addr, len, pgoff, flags);
5964 } else {
5965 - addr = get_unshared_area(addr, len);
5966 + addr = get_unshared_area(filp, addr, len, flags);
5967 }
5968 return addr;
5969 }
5970 diff --git a/arch/parisc/kernel/traps.c b/arch/parisc/kernel/traps.c
5971 index aeb8f8f..27a6c2f 100644
5972 --- a/arch/parisc/kernel/traps.c
5973 +++ b/arch/parisc/kernel/traps.c
5974 @@ -732,9 +732,7 @@ void notrace handle_interruption(int code, struct pt_regs *regs)
5975
5976 down_read(&current->mm->mmap_sem);
5977 vma = find_vma(current->mm,regs->iaoq[0]);
5978 - if (vma && (regs->iaoq[0] >= vma->vm_start)
5979 - && (vma->vm_flags & VM_EXEC)) {
5980 -
5981 + if (vma && (regs->iaoq[0] >= vma->vm_start)) {
5982 fault_address = regs->iaoq[0];
5983 fault_space = regs->iasq[0];
5984
5985 diff --git a/arch/parisc/mm/fault.c b/arch/parisc/mm/fault.c
5986 index f247a34..dc0f219 100644
5987 --- a/arch/parisc/mm/fault.c
5988 +++ b/arch/parisc/mm/fault.c
5989 @@ -15,6 +15,7 @@
5990 #include <linux/sched.h>
5991 #include <linux/interrupt.h>
5992 #include <linux/module.h>
5993 +#include <linux/unistd.h>
5994
5995 #include <asm/uaccess.h>
5996 #include <asm/traps.h>
5997 @@ -52,7 +53,7 @@ DEFINE_PER_CPU(struct exception_data, exception_data);
5998 static unsigned long
5999 parisc_acctyp(unsigned long code, unsigned int inst)
6000 {
6001 - if (code == 6 || code == 16)
6002 + if (code == 6 || code == 7 || code == 16)
6003 return VM_EXEC;
6004
6005 switch (inst & 0xf0000000) {
6006 @@ -138,6 +139,116 @@ parisc_acctyp(unsigned long code, unsigned int inst)
6007 }
6008 #endif
6009
6010 +#ifdef CONFIG_PAX_PAGEEXEC
6011 +/*
6012 + * PaX: decide what to do with offenders (instruction_pointer(regs) = fault address)
6013 + *
6014 + * returns 1 when task should be killed
6015 + * 2 when rt_sigreturn trampoline was detected
6016 + * 3 when unpatched PLT trampoline was detected
6017 + */
6018 +static int pax_handle_fetch_fault(struct pt_regs *regs)
6019 +{
6020 +
6021 +#ifdef CONFIG_PAX_EMUPLT
6022 + int err;
6023 +
6024 + do { /* PaX: unpatched PLT emulation */
6025 + unsigned int bl, depwi;
6026 +
6027 + err = get_user(bl, (unsigned int *)instruction_pointer(regs));
6028 + err |= get_user(depwi, (unsigned int *)(instruction_pointer(regs)+4));
6029 +
6030 + if (err)
6031 + break;
6032 +
6033 + if (bl == 0xEA9F1FDDU && depwi == 0xD6801C1EU) {
6034 + unsigned int ldw, bv, ldw2, addr = instruction_pointer(regs)-12;
6035 +
6036 + err = get_user(ldw, (unsigned int *)addr);
6037 + err |= get_user(bv, (unsigned int *)(addr+4));
6038 + err |= get_user(ldw2, (unsigned int *)(addr+8));
6039 +
6040 + if (err)
6041 + break;
6042 +
6043 + if (ldw == 0x0E801096U &&
6044 + bv == 0xEAC0C000U &&
6045 + ldw2 == 0x0E881095U)
6046 + {
6047 + unsigned int resolver, map;
6048 +
6049 + err = get_user(resolver, (unsigned int *)(instruction_pointer(regs)+8));
6050 + err |= get_user(map, (unsigned int *)(instruction_pointer(regs)+12));
6051 + if (err)
6052 + break;
6053 +
6054 + regs->gr[20] = instruction_pointer(regs)+8;
6055 + regs->gr[21] = map;
6056 + regs->gr[22] = resolver;
6057 + regs->iaoq[0] = resolver | 3UL;
6058 + regs->iaoq[1] = regs->iaoq[0] + 4;
6059 + return 3;
6060 + }
6061 + }
6062 + } while (0);
6063 +#endif
6064 +
6065 +#ifdef CONFIG_PAX_EMUTRAMP
6066 +
6067 +#ifndef CONFIG_PAX_EMUSIGRT
6068 + if (!(current->mm->pax_flags & MF_PAX_EMUTRAMP))
6069 + return 1;
6070 +#endif
6071 +
6072 + do { /* PaX: rt_sigreturn emulation */
6073 + unsigned int ldi1, ldi2, bel, nop;
6074 +
6075 + err = get_user(ldi1, (unsigned int *)instruction_pointer(regs));
6076 + err |= get_user(ldi2, (unsigned int *)(instruction_pointer(regs)+4));
6077 + err |= get_user(bel, (unsigned int *)(instruction_pointer(regs)+8));
6078 + err |= get_user(nop, (unsigned int *)(instruction_pointer(regs)+12));
6079 +
6080 + if (err)
6081 + break;
6082 +
6083 + if ((ldi1 == 0x34190000U || ldi1 == 0x34190002U) &&
6084 + ldi2 == 0x3414015AU &&
6085 + bel == 0xE4008200U &&
6086 + nop == 0x08000240U)
6087 + {
6088 + regs->gr[25] = (ldi1 & 2) >> 1;
6089 + regs->gr[20] = __NR_rt_sigreturn;
6090 + regs->gr[31] = regs->iaoq[1] + 16;
6091 + regs->sr[0] = regs->iasq[1];
6092 + regs->iaoq[0] = 0x100UL;
6093 + regs->iaoq[1] = regs->iaoq[0] + 4;
6094 + regs->iasq[0] = regs->sr[2];
6095 + regs->iasq[1] = regs->sr[2];
6096 + return 2;
6097 + }
6098 + } while (0);
6099 +#endif
6100 +
6101 + return 1;
6102 +}
6103 +
6104 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
6105 +{
6106 + unsigned long i;
6107 +
6108 + printk(KERN_ERR "PAX: bytes at PC: ");
6109 + for (i = 0; i < 5; i++) {
6110 + unsigned int c;
6111 + if (get_user(c, (unsigned int *)pc+i))
6112 + printk(KERN_CONT "???????? ");
6113 + else
6114 + printk(KERN_CONT "%08x ", c);
6115 + }
6116 + printk("\n");
6117 +}
6118 +#endif
6119 +
6120 int fixup_exception(struct pt_regs *regs)
6121 {
6122 const struct exception_table_entry *fix;
6123 @@ -194,8 +305,33 @@ good_area:
6124
6125 acc_type = parisc_acctyp(code,regs->iir);
6126
6127 - if ((vma->vm_flags & acc_type) != acc_type)
6128 + if ((vma->vm_flags & acc_type) != acc_type) {
6129 +
6130 +#ifdef CONFIG_PAX_PAGEEXEC
6131 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && (acc_type & VM_EXEC) &&
6132 + (address & ~3UL) == instruction_pointer(regs))
6133 + {
6134 + up_read(&mm->mmap_sem);
6135 + switch (pax_handle_fetch_fault(regs)) {
6136 +
6137 +#ifdef CONFIG_PAX_EMUPLT
6138 + case 3:
6139 + return;
6140 +#endif
6141 +
6142 +#ifdef CONFIG_PAX_EMUTRAMP
6143 + case 2:
6144 + return;
6145 +#endif
6146 +
6147 + }
6148 + pax_report_fault(regs, (void *)instruction_pointer(regs), (void *)regs->gr[30]);
6149 + do_group_exit(SIGKILL);
6150 + }
6151 +#endif
6152 +
6153 goto bad_area;
6154 + }
6155
6156 /*
6157 * If for any reason at all we couldn't handle the fault, make
6158 diff --git a/arch/powerpc/include/asm/atomic.h b/arch/powerpc/include/asm/atomic.h
6159 index e3b1d41..8e81edf 100644
6160 --- a/arch/powerpc/include/asm/atomic.h
6161 +++ b/arch/powerpc/include/asm/atomic.h
6162 @@ -523,6 +523,16 @@ static __inline__ long atomic64_inc_not_zero(atomic64_t *v)
6163 return t1;
6164 }
6165
6166 +#define atomic64_read_unchecked(v) atomic64_read(v)
6167 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
6168 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
6169 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
6170 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
6171 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
6172 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
6173 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
6174 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
6175 +
6176 #endif /* __powerpc64__ */
6177
6178 #endif /* __KERNEL__ */
6179 diff --git a/arch/powerpc/include/asm/cache.h b/arch/powerpc/include/asm/cache.h
6180 index 9e495c9..b6878e5 100644
6181 --- a/arch/powerpc/include/asm/cache.h
6182 +++ b/arch/powerpc/include/asm/cache.h
6183 @@ -3,6 +3,7 @@
6184
6185 #ifdef __KERNEL__
6186
6187 +#include <linux/const.h>
6188
6189 /* bytes per L1 cache line */
6190 #if defined(CONFIG_8xx) || defined(CONFIG_403GCX)
6191 @@ -22,7 +23,7 @@
6192 #define L1_CACHE_SHIFT 7
6193 #endif
6194
6195 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
6196 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
6197
6198 #define SMP_CACHE_BYTES L1_CACHE_BYTES
6199
6200 diff --git a/arch/powerpc/include/asm/elf.h b/arch/powerpc/include/asm/elf.h
6201 index ac9790f..6d30741 100644
6202 --- a/arch/powerpc/include/asm/elf.h
6203 +++ b/arch/powerpc/include/asm/elf.h
6204 @@ -28,8 +28,19 @@
6205 the loader. We need to make sure that it is out of the way of the program
6206 that it will "exec", and that there is sufficient room for the brk. */
6207
6208 -extern unsigned long randomize_et_dyn(unsigned long base);
6209 -#define ELF_ET_DYN_BASE (randomize_et_dyn(0x20000000))
6210 +#define ELF_ET_DYN_BASE (0x20000000)
6211 +
6212 +#ifdef CONFIG_PAX_ASLR
6213 +#define PAX_ELF_ET_DYN_BASE (0x10000000UL)
6214 +
6215 +#ifdef __powerpc64__
6216 +#define PAX_DELTA_MMAP_LEN (is_32bit_task() ? 16 : 28)
6217 +#define PAX_DELTA_STACK_LEN (is_32bit_task() ? 16 : 28)
6218 +#else
6219 +#define PAX_DELTA_MMAP_LEN 15
6220 +#define PAX_DELTA_STACK_LEN 15
6221 +#endif
6222 +#endif
6223
6224 /*
6225 * Our registers are always unsigned longs, whether we're a 32 bit
6226 @@ -122,10 +133,6 @@ extern int arch_setup_additional_pages(struct linux_binprm *bprm,
6227 (0x7ff >> (PAGE_SHIFT - 12)) : \
6228 (0x3ffff >> (PAGE_SHIFT - 12)))
6229
6230 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
6231 -#define arch_randomize_brk arch_randomize_brk
6232 -
6233 -
6234 #ifdef CONFIG_SPU_BASE
6235 /* Notes used in ET_CORE. Note name is "SPU/<fd>/<filename>". */
6236 #define NT_SPU 1
6237 diff --git a/arch/powerpc/include/asm/exec.h b/arch/powerpc/include/asm/exec.h
6238 index 8196e9c..d83a9f3 100644
6239 --- a/arch/powerpc/include/asm/exec.h
6240 +++ b/arch/powerpc/include/asm/exec.h
6241 @@ -4,6 +4,6 @@
6242 #ifndef _ASM_POWERPC_EXEC_H
6243 #define _ASM_POWERPC_EXEC_H
6244
6245 -extern unsigned long arch_align_stack(unsigned long sp);
6246 +#define arch_align_stack(x) ((x) & ~0xfUL)
6247
6248 #endif /* _ASM_POWERPC_EXEC_H */
6249 diff --git a/arch/powerpc/include/asm/kmap_types.h b/arch/powerpc/include/asm/kmap_types.h
6250 index 5acabbd..7ea14fa 100644
6251 --- a/arch/powerpc/include/asm/kmap_types.h
6252 +++ b/arch/powerpc/include/asm/kmap_types.h
6253 @@ -10,7 +10,7 @@
6254 * 2 of the License, or (at your option) any later version.
6255 */
6256
6257 -#define KM_TYPE_NR 16
6258 +#define KM_TYPE_NR 17
6259
6260 #endif /* __KERNEL__ */
6261 #endif /* _ASM_POWERPC_KMAP_TYPES_H */
6262 diff --git a/arch/powerpc/include/asm/mman.h b/arch/powerpc/include/asm/mman.h
6263 index 8565c25..2865190 100644
6264 --- a/arch/powerpc/include/asm/mman.h
6265 +++ b/arch/powerpc/include/asm/mman.h
6266 @@ -24,7 +24,7 @@ static inline unsigned long arch_calc_vm_prot_bits(unsigned long prot)
6267 }
6268 #define arch_calc_vm_prot_bits(prot) arch_calc_vm_prot_bits(prot)
6269
6270 -static inline pgprot_t arch_vm_get_page_prot(unsigned long vm_flags)
6271 +static inline pgprot_t arch_vm_get_page_prot(vm_flags_t vm_flags)
6272 {
6273 return (vm_flags & VM_SAO) ? __pgprot(_PAGE_SAO) : __pgprot(0);
6274 }
6275 diff --git a/arch/powerpc/include/asm/page.h b/arch/powerpc/include/asm/page.h
6276 index f072e97..b436dee 100644
6277 --- a/arch/powerpc/include/asm/page.h
6278 +++ b/arch/powerpc/include/asm/page.h
6279 @@ -220,8 +220,9 @@ extern long long virt_phys_offset;
6280 * and needs to be executable. This means the whole heap ends
6281 * up being executable.
6282 */
6283 -#define VM_DATA_DEFAULT_FLAGS32 (VM_READ | VM_WRITE | VM_EXEC | \
6284 - VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6285 +#define VM_DATA_DEFAULT_FLAGS32 \
6286 + (((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0) | \
6287 + VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6288
6289 #define VM_DATA_DEFAULT_FLAGS64 (VM_READ | VM_WRITE | \
6290 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6291 @@ -249,6 +250,9 @@ extern long long virt_phys_offset;
6292 #define is_kernel_addr(x) ((x) >= PAGE_OFFSET)
6293 #endif
6294
6295 +#define ktla_ktva(addr) (addr)
6296 +#define ktva_ktla(addr) (addr)
6297 +
6298 /*
6299 * Use the top bit of the higher-level page table entries to indicate whether
6300 * the entries we point to contain hugepages. This works because we know that
6301 diff --git a/arch/powerpc/include/asm/page_64.h b/arch/powerpc/include/asm/page_64.h
6302 index cd915d6..c10cee8 100644
6303 --- a/arch/powerpc/include/asm/page_64.h
6304 +++ b/arch/powerpc/include/asm/page_64.h
6305 @@ -154,15 +154,18 @@ do { \
6306 * stack by default, so in the absence of a PT_GNU_STACK program header
6307 * we turn execute permission off.
6308 */
6309 -#define VM_STACK_DEFAULT_FLAGS32 (VM_READ | VM_WRITE | VM_EXEC | \
6310 - VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6311 +#define VM_STACK_DEFAULT_FLAGS32 \
6312 + (((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0) | \
6313 + VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6314
6315 #define VM_STACK_DEFAULT_FLAGS64 (VM_READ | VM_WRITE | \
6316 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6317
6318 +#ifndef CONFIG_PAX_PAGEEXEC
6319 #define VM_STACK_DEFAULT_FLAGS \
6320 (is_32bit_task() ? \
6321 VM_STACK_DEFAULT_FLAGS32 : VM_STACK_DEFAULT_FLAGS64)
6322 +#endif
6323
6324 #include <asm-generic/getorder.h>
6325
6326 diff --git a/arch/powerpc/include/asm/pgalloc-64.h b/arch/powerpc/include/asm/pgalloc-64.h
6327 index 292725c..f87ae14 100644
6328 --- a/arch/powerpc/include/asm/pgalloc-64.h
6329 +++ b/arch/powerpc/include/asm/pgalloc-64.h
6330 @@ -50,6 +50,7 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
6331 #ifndef CONFIG_PPC_64K_PAGES
6332
6333 #define pgd_populate(MM, PGD, PUD) pgd_set(PGD, PUD)
6334 +#define pgd_populate_kernel(MM, PGD, PUD) pgd_populate((MM), (PGD), (PUD))
6335
6336 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
6337 {
6338 @@ -67,6 +68,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
6339 pud_set(pud, (unsigned long)pmd);
6340 }
6341
6342 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
6343 +{
6344 + pud_populate(mm, pud, pmd);
6345 +}
6346 +
6347 #define pmd_populate(mm, pmd, pte_page) \
6348 pmd_populate_kernel(mm, pmd, page_address(pte_page))
6349 #define pmd_populate_kernel(mm, pmd, pte) pmd_set(pmd, (unsigned long)(pte))
6350 @@ -76,6 +82,7 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
6351 #else /* CONFIG_PPC_64K_PAGES */
6352
6353 #define pud_populate(mm, pud, pmd) pud_set(pud, (unsigned long)pmd)
6354 +#define pud_populate_kernel(mm, pud, pmd) pud_populate((mm), (pud), (pmd))
6355
6356 static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd,
6357 pte_t *pte)
6358 diff --git a/arch/powerpc/include/asm/pgtable.h b/arch/powerpc/include/asm/pgtable.h
6359 index a9cbd3b..3b67efa 100644
6360 --- a/arch/powerpc/include/asm/pgtable.h
6361 +++ b/arch/powerpc/include/asm/pgtable.h
6362 @@ -2,6 +2,7 @@
6363 #define _ASM_POWERPC_PGTABLE_H
6364 #ifdef __KERNEL__
6365
6366 +#include <linux/const.h>
6367 #ifndef __ASSEMBLY__
6368 #include <asm/processor.h> /* For TASK_SIZE */
6369 #include <asm/mmu.h>
6370 diff --git a/arch/powerpc/include/asm/pte-hash32.h b/arch/powerpc/include/asm/pte-hash32.h
6371 index 4aad413..85d86bf 100644
6372 --- a/arch/powerpc/include/asm/pte-hash32.h
6373 +++ b/arch/powerpc/include/asm/pte-hash32.h
6374 @@ -21,6 +21,7 @@
6375 #define _PAGE_FILE 0x004 /* when !present: nonlinear file mapping */
6376 #define _PAGE_USER 0x004 /* usermode access allowed */
6377 #define _PAGE_GUARDED 0x008 /* G: prohibit speculative access */
6378 +#define _PAGE_EXEC _PAGE_GUARDED
6379 #define _PAGE_COHERENT 0x010 /* M: enforce memory coherence (SMP systems) */
6380 #define _PAGE_NO_CACHE 0x020 /* I: cache inhibit */
6381 #define _PAGE_WRITETHRU 0x040 /* W: cache write-through */
6382 diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h
6383 index 3b097a8..8f8c774 100644
6384 --- a/arch/powerpc/include/asm/reg.h
6385 +++ b/arch/powerpc/include/asm/reg.h
6386 @@ -234,6 +234,7 @@
6387 #define SPRN_DBCR 0x136 /* e300 Data Breakpoint Control Reg */
6388 #define SPRN_DSISR 0x012 /* Data Storage Interrupt Status Register */
6389 #define DSISR_NOHPTE 0x40000000 /* no translation found */
6390 +#define DSISR_GUARDED 0x10000000 /* fetch from guarded storage */
6391 #define DSISR_PROTFAULT 0x08000000 /* protection fault */
6392 #define DSISR_ISSTORE 0x02000000 /* access was a store */
6393 #define DSISR_DABRMATCH 0x00400000 /* hit data breakpoint */
6394 diff --git a/arch/powerpc/include/asm/smp.h b/arch/powerpc/include/asm/smp.h
6395 index 195ce2a..ab5c614 100644
6396 --- a/arch/powerpc/include/asm/smp.h
6397 +++ b/arch/powerpc/include/asm/smp.h
6398 @@ -50,7 +50,7 @@ struct smp_ops_t {
6399 int (*cpu_disable)(void);
6400 void (*cpu_die)(unsigned int nr);
6401 int (*cpu_bootable)(unsigned int nr);
6402 -};
6403 +} __no_const;
6404
6405 extern void smp_send_debugger_break(void);
6406 extern void start_secondary_resume(void);
6407 diff --git a/arch/powerpc/include/asm/thread_info.h b/arch/powerpc/include/asm/thread_info.h
6408 index 406b7b9..af63426 100644
6409 --- a/arch/powerpc/include/asm/thread_info.h
6410 +++ b/arch/powerpc/include/asm/thread_info.h
6411 @@ -97,7 +97,6 @@ static inline struct thread_info *current_thread_info(void)
6412 #define TIF_PERFMON_CTXSW 6 /* perfmon needs ctxsw calls */
6413 #define TIF_SYSCALL_AUDIT 7 /* syscall auditing active */
6414 #define TIF_SINGLESTEP 8 /* singlestepping active */
6415 -#define TIF_MEMDIE 9 /* is terminating due to OOM killer */
6416 #define TIF_SECCOMP 10 /* secure computing */
6417 #define TIF_RESTOREALL 11 /* Restore all regs (implies NOERROR) */
6418 #define TIF_NOERROR 12 /* Force successful syscall return */
6419 @@ -106,6 +105,9 @@ static inline struct thread_info *current_thread_info(void)
6420 #define TIF_SYSCALL_TRACEPOINT 15 /* syscall tracepoint instrumentation */
6421 #define TIF_EMULATE_STACK_STORE 16 /* Is an instruction emulation
6422 for stack store? */
6423 +#define TIF_MEMDIE 17 /* is terminating due to OOM killer */
6424 +/* mask must be expressable within 16 bits to satisfy 'andi' instruction reqs */
6425 +#define TIF_GRSEC_SETXID 9 /* update credentials on syscall entry/exit */
6426
6427 /* as above, but as bit values */
6428 #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
6429 @@ -124,8 +126,10 @@ static inline struct thread_info *current_thread_info(void)
6430 #define _TIF_UPROBE (1<<TIF_UPROBE)
6431 #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
6432 #define _TIF_EMULATE_STACK_STORE (1<<TIF_EMULATE_STACK_STORE)
6433 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
6434 #define _TIF_SYSCALL_T_OR_A (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
6435 - _TIF_SECCOMP | _TIF_SYSCALL_TRACEPOINT)
6436 + _TIF_SECCOMP | _TIF_SYSCALL_TRACEPOINT | \
6437 + _TIF_GRSEC_SETXID)
6438
6439 #define _TIF_USER_WORK_MASK (_TIF_SIGPENDING | _TIF_NEED_RESCHED | \
6440 _TIF_NOTIFY_RESUME | _TIF_UPROBE)
6441 diff --git a/arch/powerpc/include/asm/uaccess.h b/arch/powerpc/include/asm/uaccess.h
6442 index 4db4959..aba5c41 100644
6443 --- a/arch/powerpc/include/asm/uaccess.h
6444 +++ b/arch/powerpc/include/asm/uaccess.h
6445 @@ -318,52 +318,6 @@ do { \
6446 extern unsigned long __copy_tofrom_user(void __user *to,
6447 const void __user *from, unsigned long size);
6448
6449 -#ifndef __powerpc64__
6450 -
6451 -static inline unsigned long copy_from_user(void *to,
6452 - const void __user *from, unsigned long n)
6453 -{
6454 - unsigned long over;
6455 -
6456 - if (access_ok(VERIFY_READ, from, n))
6457 - return __copy_tofrom_user((__force void __user *)to, from, n);
6458 - if ((unsigned long)from < TASK_SIZE) {
6459 - over = (unsigned long)from + n - TASK_SIZE;
6460 - return __copy_tofrom_user((__force void __user *)to, from,
6461 - n - over) + over;
6462 - }
6463 - return n;
6464 -}
6465 -
6466 -static inline unsigned long copy_to_user(void __user *to,
6467 - const void *from, unsigned long n)
6468 -{
6469 - unsigned long over;
6470 -
6471 - if (access_ok(VERIFY_WRITE, to, n))
6472 - return __copy_tofrom_user(to, (__force void __user *)from, n);
6473 - if ((unsigned long)to < TASK_SIZE) {
6474 - over = (unsigned long)to + n - TASK_SIZE;
6475 - return __copy_tofrom_user(to, (__force void __user *)from,
6476 - n - over) + over;
6477 - }
6478 - return n;
6479 -}
6480 -
6481 -#else /* __powerpc64__ */
6482 -
6483 -#define __copy_in_user(to, from, size) \
6484 - __copy_tofrom_user((to), (from), (size))
6485 -
6486 -extern unsigned long copy_from_user(void *to, const void __user *from,
6487 - unsigned long n);
6488 -extern unsigned long copy_to_user(void __user *to, const void *from,
6489 - unsigned long n);
6490 -extern unsigned long copy_in_user(void __user *to, const void __user *from,
6491 - unsigned long n);
6492 -
6493 -#endif /* __powerpc64__ */
6494 -
6495 static inline unsigned long __copy_from_user_inatomic(void *to,
6496 const void __user *from, unsigned long n)
6497 {
6498 @@ -387,6 +341,10 @@ static inline unsigned long __copy_from_user_inatomic(void *to,
6499 if (ret == 0)
6500 return 0;
6501 }
6502 +
6503 + if (!__builtin_constant_p(n))
6504 + check_object_size(to, n, false);
6505 +
6506 return __copy_tofrom_user((__force void __user *)to, from, n);
6507 }
6508
6509 @@ -413,6 +371,10 @@ static inline unsigned long __copy_to_user_inatomic(void __user *to,
6510 if (ret == 0)
6511 return 0;
6512 }
6513 +
6514 + if (!__builtin_constant_p(n))
6515 + check_object_size(from, n, true);
6516 +
6517 return __copy_tofrom_user(to, (__force const void __user *)from, n);
6518 }
6519
6520 @@ -430,6 +392,92 @@ static inline unsigned long __copy_to_user(void __user *to,
6521 return __copy_to_user_inatomic(to, from, size);
6522 }
6523
6524 +#ifndef __powerpc64__
6525 +
6526 +static inline unsigned long __must_check copy_from_user(void *to,
6527 + const void __user *from, unsigned long n)
6528 +{
6529 + unsigned long over;
6530 +
6531 + if ((long)n < 0)
6532 + return n;
6533 +
6534 + if (access_ok(VERIFY_READ, from, n)) {
6535 + if (!__builtin_constant_p(n))
6536 + check_object_size(to, n, false);
6537 + return __copy_tofrom_user((__force void __user *)to, from, n);
6538 + }
6539 + if ((unsigned long)from < TASK_SIZE) {
6540 + over = (unsigned long)from + n - TASK_SIZE;
6541 + if (!__builtin_constant_p(n - over))
6542 + check_object_size(to, n - over, false);
6543 + return __copy_tofrom_user((__force void __user *)to, from,
6544 + n - over) + over;
6545 + }
6546 + return n;
6547 +}
6548 +
6549 +static inline unsigned long __must_check copy_to_user(void __user *to,
6550 + const void *from, unsigned long n)
6551 +{
6552 + unsigned long over;
6553 +
6554 + if ((long)n < 0)
6555 + return n;
6556 +
6557 + if (access_ok(VERIFY_WRITE, to, n)) {
6558 + if (!__builtin_constant_p(n))
6559 + check_object_size(from, n, true);
6560 + return __copy_tofrom_user(to, (__force void __user *)from, n);
6561 + }
6562 + if ((unsigned long)to < TASK_SIZE) {
6563 + over = (unsigned long)to + n - TASK_SIZE;
6564 + if (!__builtin_constant_p(n))
6565 + check_object_size(from, n - over, true);
6566 + return __copy_tofrom_user(to, (__force void __user *)from,
6567 + n - over) + over;
6568 + }
6569 + return n;
6570 +}
6571 +
6572 +#else /* __powerpc64__ */
6573 +
6574 +#define __copy_in_user(to, from, size) \
6575 + __copy_tofrom_user((to), (from), (size))
6576 +
6577 +static inline unsigned long __must_check copy_from_user(void *to, const void __user *from, unsigned long n)
6578 +{
6579 + if ((long)n < 0 || n > INT_MAX)
6580 + return n;
6581 +
6582 + if (!__builtin_constant_p(n))
6583 + check_object_size(to, n, false);
6584 +
6585 + if (likely(access_ok(VERIFY_READ, from, n)))
6586 + n = __copy_from_user(to, from, n);
6587 + else
6588 + memset(to, 0, n);
6589 + return n;
6590 +}
6591 +
6592 +static inline unsigned long __must_check copy_to_user(void __user *to, const void *from, unsigned long n)
6593 +{
6594 + if ((long)n < 0 || n > INT_MAX)
6595 + return n;
6596 +
6597 + if (likely(access_ok(VERIFY_WRITE, to, n))) {
6598 + if (!__builtin_constant_p(n))
6599 + check_object_size(from, n, true);
6600 + n = __copy_to_user(to, from, n);
6601 + }
6602 + return n;
6603 +}
6604 +
6605 +extern unsigned long copy_in_user(void __user *to, const void __user *from,
6606 + unsigned long n);
6607 +
6608 +#endif /* __powerpc64__ */
6609 +
6610 extern unsigned long __clear_user(void __user *addr, unsigned long size);
6611
6612 static inline unsigned long clear_user(void __user *addr, unsigned long size)
6613 diff --git a/arch/powerpc/kernel/exceptions-64e.S b/arch/powerpc/kernel/exceptions-64e.S
6614 index ae54553..cf2184d 100644
6615 --- a/arch/powerpc/kernel/exceptions-64e.S
6616 +++ b/arch/powerpc/kernel/exceptions-64e.S
6617 @@ -716,6 +716,7 @@ storage_fault_common:
6618 std r14,_DAR(r1)
6619 std r15,_DSISR(r1)
6620 addi r3,r1,STACK_FRAME_OVERHEAD
6621 + bl .save_nvgprs
6622 mr r4,r14
6623 mr r5,r15
6624 ld r14,PACA_EXGEN+EX_R14(r13)
6625 @@ -724,8 +725,7 @@ storage_fault_common:
6626 cmpdi r3,0
6627 bne- 1f
6628 b .ret_from_except_lite
6629 -1: bl .save_nvgprs
6630 - mr r5,r3
6631 +1: mr r5,r3
6632 addi r3,r1,STACK_FRAME_OVERHEAD
6633 ld r4,_DAR(r1)
6634 bl .bad_page_fault
6635 diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S
6636 index 3bbe7ed..14ec3eb 100644
6637 --- a/arch/powerpc/kernel/exceptions-64s.S
6638 +++ b/arch/powerpc/kernel/exceptions-64s.S
6639 @@ -1390,10 +1390,10 @@ handle_page_fault:
6640 11: ld r4,_DAR(r1)
6641 ld r5,_DSISR(r1)
6642 addi r3,r1,STACK_FRAME_OVERHEAD
6643 + bl .save_nvgprs
6644 bl .do_page_fault
6645 cmpdi r3,0
6646 beq+ 12f
6647 - bl .save_nvgprs
6648 mr r5,r3
6649 addi r3,r1,STACK_FRAME_OVERHEAD
6650 lwz r4,_DAR(r1)
6651 diff --git a/arch/powerpc/kernel/module_32.c b/arch/powerpc/kernel/module_32.c
6652 index 2e3200c..72095ce 100644
6653 --- a/arch/powerpc/kernel/module_32.c
6654 +++ b/arch/powerpc/kernel/module_32.c
6655 @@ -162,7 +162,7 @@ int module_frob_arch_sections(Elf32_Ehdr *hdr,
6656 me->arch.core_plt_section = i;
6657 }
6658 if (!me->arch.core_plt_section || !me->arch.init_plt_section) {
6659 - printk("Module doesn't contain .plt or .init.plt sections.\n");
6660 + printk("Module %s doesn't contain .plt or .init.plt sections.\n", me->name);
6661 return -ENOEXEC;
6662 }
6663
6664 @@ -192,11 +192,16 @@ static uint32_t do_plt_call(void *location,
6665
6666 DEBUGP("Doing plt for call to 0x%x at 0x%x\n", val, (unsigned int)location);
6667 /* Init, or core PLT? */
6668 - if (location >= mod->module_core
6669 - && location < mod->module_core + mod->core_size)
6670 + if ((location >= mod->module_core_rx && location < mod->module_core_rx + mod->core_size_rx) ||
6671 + (location >= mod->module_core_rw && location < mod->module_core_rw + mod->core_size_rw))
6672 entry = (void *)sechdrs[mod->arch.core_plt_section].sh_addr;
6673 - else
6674 + else if ((location >= mod->module_init_rx && location < mod->module_init_rx + mod->init_size_rx) ||
6675 + (location >= mod->module_init_rw && location < mod->module_init_rw + mod->init_size_rw))
6676 entry = (void *)sechdrs[mod->arch.init_plt_section].sh_addr;
6677 + else {
6678 + printk(KERN_ERR "%s: invalid R_PPC_REL24 entry found\n", mod->name);
6679 + return ~0UL;
6680 + }
6681
6682 /* Find this entry, or if that fails, the next avail. entry */
6683 while (entry->jump[0]) {
6684 diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
6685 index 16e77a8..4501b41 100644
6686 --- a/arch/powerpc/kernel/process.c
6687 +++ b/arch/powerpc/kernel/process.c
6688 @@ -870,8 +870,8 @@ void show_regs(struct pt_regs * regs)
6689 * Lookup NIP late so we have the best change of getting the
6690 * above info out without failing
6691 */
6692 - printk("NIP ["REG"] %pS\n", regs->nip, (void *)regs->nip);
6693 - printk("LR ["REG"] %pS\n", regs->link, (void *)regs->link);
6694 + printk("NIP ["REG"] %pA\n", regs->nip, (void *)regs->nip);
6695 + printk("LR ["REG"] %pA\n", regs->link, (void *)regs->link);
6696 #endif
6697 #ifdef CONFIG_PPC_TRANSACTIONAL_MEM
6698 printk("PACATMSCRATCH [%llx]\n", get_paca()->tm_scratch);
6699 @@ -1330,10 +1330,10 @@ void show_stack(struct task_struct *tsk, unsigned long *stack)
6700 newsp = stack[0];
6701 ip = stack[STACK_FRAME_LR_SAVE];
6702 if (!firstframe || ip != lr) {
6703 - printk("["REG"] ["REG"] %pS", sp, ip, (void *)ip);
6704 + printk("["REG"] ["REG"] %pA", sp, ip, (void *)ip);
6705 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
6706 if ((ip == rth || ip == mrth) && curr_frame >= 0) {
6707 - printk(" (%pS)",
6708 + printk(" (%pA)",
6709 (void *)current->ret_stack[curr_frame].ret);
6710 curr_frame--;
6711 }
6712 @@ -1353,7 +1353,7 @@ void show_stack(struct task_struct *tsk, unsigned long *stack)
6713 struct pt_regs *regs = (struct pt_regs *)
6714 (sp + STACK_FRAME_OVERHEAD);
6715 lr = regs->link;
6716 - printk("--- Exception: %lx at %pS\n LR = %pS\n",
6717 + printk("--- Exception: %lx at %pA\n LR = %pA\n",
6718 regs->trap, (void *)regs->nip, (void *)lr);
6719 firstframe = 1;
6720 }
6721 @@ -1395,58 +1395,3 @@ void __ppc64_runlatch_off(void)
6722 mtspr(SPRN_CTRLT, ctrl);
6723 }
6724 #endif /* CONFIG_PPC64 */
6725 -
6726 -unsigned long arch_align_stack(unsigned long sp)
6727 -{
6728 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
6729 - sp -= get_random_int() & ~PAGE_MASK;
6730 - return sp & ~0xf;
6731 -}
6732 -
6733 -static inline unsigned long brk_rnd(void)
6734 -{
6735 - unsigned long rnd = 0;
6736 -
6737 - /* 8MB for 32bit, 1GB for 64bit */
6738 - if (is_32bit_task())
6739 - rnd = (long)(get_random_int() % (1<<(23-PAGE_SHIFT)));
6740 - else
6741 - rnd = (long)(get_random_int() % (1<<(30-PAGE_SHIFT)));
6742 -
6743 - return rnd << PAGE_SHIFT;
6744 -}
6745 -
6746 -unsigned long arch_randomize_brk(struct mm_struct *mm)
6747 -{
6748 - unsigned long base = mm->brk;
6749 - unsigned long ret;
6750 -
6751 -#ifdef CONFIG_PPC_STD_MMU_64
6752 - /*
6753 - * If we are using 1TB segments and we are allowed to randomise
6754 - * the heap, we can put it above 1TB so it is backed by a 1TB
6755 - * segment. Otherwise the heap will be in the bottom 1TB
6756 - * which always uses 256MB segments and this may result in a
6757 - * performance penalty.
6758 - */
6759 - if (!is_32bit_task() && (mmu_highuser_ssize == MMU_SEGSIZE_1T))
6760 - base = max_t(unsigned long, mm->brk, 1UL << SID_SHIFT_1T);
6761 -#endif
6762 -
6763 - ret = PAGE_ALIGN(base + brk_rnd());
6764 -
6765 - if (ret < mm->brk)
6766 - return mm->brk;
6767 -
6768 - return ret;
6769 -}
6770 -
6771 -unsigned long randomize_et_dyn(unsigned long base)
6772 -{
6773 - unsigned long ret = PAGE_ALIGN(base + brk_rnd());
6774 -
6775 - if (ret < base)
6776 - return base;
6777 -
6778 - return ret;
6779 -}
6780 diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c
6781 index f9b30c6..d72e7a3 100644
6782 --- a/arch/powerpc/kernel/ptrace.c
6783 +++ b/arch/powerpc/kernel/ptrace.c
6784 @@ -1771,6 +1771,10 @@ long arch_ptrace(struct task_struct *child, long request,
6785 return ret;
6786 }
6787
6788 +#ifdef CONFIG_GRKERNSEC_SETXID
6789 +extern void gr_delayed_cred_worker(void);
6790 +#endif
6791 +
6792 /*
6793 * We must return the syscall number to actually look up in the table.
6794 * This can be -1L to skip running any syscall at all.
6795 @@ -1781,6 +1785,11 @@ long do_syscall_trace_enter(struct pt_regs *regs)
6796
6797 secure_computing_strict(regs->gpr[0]);
6798
6799 +#ifdef CONFIG_GRKERNSEC_SETXID
6800 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
6801 + gr_delayed_cred_worker();
6802 +#endif
6803 +
6804 if (test_thread_flag(TIF_SYSCALL_TRACE) &&
6805 tracehook_report_syscall_entry(regs))
6806 /*
6807 @@ -1815,6 +1824,11 @@ void do_syscall_trace_leave(struct pt_regs *regs)
6808 {
6809 int step;
6810
6811 +#ifdef CONFIG_GRKERNSEC_SETXID
6812 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
6813 + gr_delayed_cred_worker();
6814 +#endif
6815 +
6816 audit_syscall_exit(regs);
6817
6818 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
6819 diff --git a/arch/powerpc/kernel/signal_32.c b/arch/powerpc/kernel/signal_32.c
6820 index 201385c..0f01828 100644
6821 --- a/arch/powerpc/kernel/signal_32.c
6822 +++ b/arch/powerpc/kernel/signal_32.c
6823 @@ -976,7 +976,7 @@ int handle_rt_signal32(unsigned long sig, struct k_sigaction *ka,
6824 /* Save user registers on the stack */
6825 frame = &rt_sf->uc.uc_mcontext;
6826 addr = frame;
6827 - if (vdso32_rt_sigtramp && current->mm->context.vdso_base) {
6828 + if (vdso32_rt_sigtramp && current->mm->context.vdso_base != ~0UL) {
6829 sigret = 0;
6830 tramp = current->mm->context.vdso_base + vdso32_rt_sigtramp;
6831 } else {
6832 diff --git a/arch/powerpc/kernel/signal_64.c b/arch/powerpc/kernel/signal_64.c
6833 index 3459473..2d40783 100644
6834 --- a/arch/powerpc/kernel/signal_64.c
6835 +++ b/arch/powerpc/kernel/signal_64.c
6836 @@ -749,7 +749,7 @@ int handle_rt_signal64(int signr, struct k_sigaction *ka, siginfo_t *info,
6837 #endif
6838
6839 /* Set up to return from userspace. */
6840 - if (vdso64_rt_sigtramp && current->mm->context.vdso_base) {
6841 + if (vdso64_rt_sigtramp && current->mm->context.vdso_base != ~0UL) {
6842 regs->link = current->mm->context.vdso_base + vdso64_rt_sigtramp;
6843 } else {
6844 err |= setup_trampoline(__NR_rt_sigreturn, &frame->tramp[0]);
6845 diff --git a/arch/powerpc/kernel/sysfs.c b/arch/powerpc/kernel/sysfs.c
6846 index 3ce1f86..c30e629 100644
6847 --- a/arch/powerpc/kernel/sysfs.c
6848 +++ b/arch/powerpc/kernel/sysfs.c
6849 @@ -522,7 +522,7 @@ static int __cpuinit sysfs_cpu_notify(struct notifier_block *self,
6850 return NOTIFY_OK;
6851 }
6852
6853 -static struct notifier_block __cpuinitdata sysfs_cpu_nb = {
6854 +static struct notifier_block sysfs_cpu_nb = {
6855 .notifier_call = sysfs_cpu_notify,
6856 };
6857
6858 diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
6859 index 1c22b2d..3b56e67 100644
6860 --- a/arch/powerpc/kernel/traps.c
6861 +++ b/arch/powerpc/kernel/traps.c
6862 @@ -142,6 +142,8 @@ static unsigned __kprobes long oops_begin(struct pt_regs *regs)
6863 return flags;
6864 }
6865
6866 +extern void gr_handle_kernel_exploit(void);
6867 +
6868 static void __kprobes oops_end(unsigned long flags, struct pt_regs *regs,
6869 int signr)
6870 {
6871 @@ -191,6 +193,9 @@ static void __kprobes oops_end(unsigned long flags, struct pt_regs *regs,
6872 panic("Fatal exception in interrupt");
6873 if (panic_on_oops)
6874 panic("Fatal exception");
6875 +
6876 + gr_handle_kernel_exploit();
6877 +
6878 do_exit(signr);
6879 }
6880
6881 diff --git a/arch/powerpc/kernel/vdso.c b/arch/powerpc/kernel/vdso.c
6882 index 1b2076f..835e4be 100644
6883 --- a/arch/powerpc/kernel/vdso.c
6884 +++ b/arch/powerpc/kernel/vdso.c
6885 @@ -34,6 +34,7 @@
6886 #include <asm/firmware.h>
6887 #include <asm/vdso.h>
6888 #include <asm/vdso_datapage.h>
6889 +#include <asm/mman.h>
6890
6891 #include "setup.h"
6892
6893 @@ -218,7 +219,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
6894 vdso_base = VDSO32_MBASE;
6895 #endif
6896
6897 - current->mm->context.vdso_base = 0;
6898 + current->mm->context.vdso_base = ~0UL;
6899
6900 /* vDSO has a problem and was disabled, just don't "enable" it for the
6901 * process
6902 @@ -238,7 +239,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
6903 vdso_base = get_unmapped_area(NULL, vdso_base,
6904 (vdso_pages << PAGE_SHIFT) +
6905 ((VDSO_ALIGNMENT - 1) & PAGE_MASK),
6906 - 0, 0);
6907 + 0, MAP_PRIVATE | MAP_EXECUTABLE);
6908 if (IS_ERR_VALUE(vdso_base)) {
6909 rc = vdso_base;
6910 goto fail_mmapsem;
6911 diff --git a/arch/powerpc/lib/usercopy_64.c b/arch/powerpc/lib/usercopy_64.c
6912 index 5eea6f3..5d10396 100644
6913 --- a/arch/powerpc/lib/usercopy_64.c
6914 +++ b/arch/powerpc/lib/usercopy_64.c
6915 @@ -9,22 +9,6 @@
6916 #include <linux/module.h>
6917 #include <asm/uaccess.h>
6918
6919 -unsigned long copy_from_user(void *to, const void __user *from, unsigned long n)
6920 -{
6921 - if (likely(access_ok(VERIFY_READ, from, n)))
6922 - n = __copy_from_user(to, from, n);
6923 - else
6924 - memset(to, 0, n);
6925 - return n;
6926 -}
6927 -
6928 -unsigned long copy_to_user(void __user *to, const void *from, unsigned long n)
6929 -{
6930 - if (likely(access_ok(VERIFY_WRITE, to, n)))
6931 - n = __copy_to_user(to, from, n);
6932 - return n;
6933 -}
6934 -
6935 unsigned long copy_in_user(void __user *to, const void __user *from,
6936 unsigned long n)
6937 {
6938 @@ -35,7 +19,5 @@ unsigned long copy_in_user(void __user *to, const void __user *from,
6939 return n;
6940 }
6941
6942 -EXPORT_SYMBOL(copy_from_user);
6943 -EXPORT_SYMBOL(copy_to_user);
6944 EXPORT_SYMBOL(copy_in_user);
6945
6946 diff --git a/arch/powerpc/mm/fault.c b/arch/powerpc/mm/fault.c
6947 index 229951f..cdeca42 100644
6948 --- a/arch/powerpc/mm/fault.c
6949 +++ b/arch/powerpc/mm/fault.c
6950 @@ -32,6 +32,10 @@
6951 #include <linux/perf_event.h>
6952 #include <linux/magic.h>
6953 #include <linux/ratelimit.h>
6954 +#include <linux/slab.h>
6955 +#include <linux/pagemap.h>
6956 +#include <linux/compiler.h>
6957 +#include <linux/unistd.h>
6958
6959 #include <asm/firmware.h>
6960 #include <asm/page.h>
6961 @@ -68,6 +72,33 @@ static inline int notify_page_fault(struct pt_regs *regs)
6962 }
6963 #endif
6964
6965 +#ifdef CONFIG_PAX_PAGEEXEC
6966 +/*
6967 + * PaX: decide what to do with offenders (regs->nip = fault address)
6968 + *
6969 + * returns 1 when task should be killed
6970 + */
6971 +static int pax_handle_fetch_fault(struct pt_regs *regs)
6972 +{
6973 + return 1;
6974 +}
6975 +
6976 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
6977 +{
6978 + unsigned long i;
6979 +
6980 + printk(KERN_ERR "PAX: bytes at PC: ");
6981 + for (i = 0; i < 5; i++) {
6982 + unsigned int c;
6983 + if (get_user(c, (unsigned int __user *)pc+i))
6984 + printk(KERN_CONT "???????? ");
6985 + else
6986 + printk(KERN_CONT "%08x ", c);
6987 + }
6988 + printk("\n");
6989 +}
6990 +#endif
6991 +
6992 /*
6993 * Check whether the instruction at regs->nip is a store using
6994 * an update addressing form which will update r1.
6995 @@ -213,7 +244,7 @@ int __kprobes do_page_fault(struct pt_regs *regs, unsigned long address,
6996 * indicate errors in DSISR but can validly be set in SRR1.
6997 */
6998 if (trap == 0x400)
6999 - error_code &= 0x48200000;
7000 + error_code &= 0x58200000;
7001 else
7002 is_write = error_code & DSISR_ISSTORE;
7003 #else
7004 @@ -364,7 +395,7 @@ good_area:
7005 * "undefined". Of those that can be set, this is the only
7006 * one which seems bad.
7007 */
7008 - if (error_code & 0x10000000)
7009 + if (error_code & DSISR_GUARDED)
7010 /* Guarded storage error. */
7011 goto bad_area;
7012 #endif /* CONFIG_8xx */
7013 @@ -379,7 +410,7 @@ good_area:
7014 * processors use the same I/D cache coherency mechanism
7015 * as embedded.
7016 */
7017 - if (error_code & DSISR_PROTFAULT)
7018 + if (error_code & (DSISR_PROTFAULT | DSISR_GUARDED))
7019 goto bad_area;
7020 #endif /* CONFIG_PPC_STD_MMU */
7021
7022 @@ -462,6 +493,23 @@ bad_area:
7023 bad_area_nosemaphore:
7024 /* User mode accesses cause a SIGSEGV */
7025 if (user_mode(regs)) {
7026 +
7027 +#ifdef CONFIG_PAX_PAGEEXEC
7028 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
7029 +#ifdef CONFIG_PPC_STD_MMU
7030 + if (is_exec && (error_code & (DSISR_PROTFAULT | DSISR_GUARDED))) {
7031 +#else
7032 + if (is_exec && regs->nip == address) {
7033 +#endif
7034 + switch (pax_handle_fetch_fault(regs)) {
7035 + }
7036 +
7037 + pax_report_fault(regs, (void *)regs->nip, (void *)regs->gpr[PT_R1]);
7038 + do_group_exit(SIGKILL);
7039 + }
7040 + }
7041 +#endif
7042 +
7043 _exception(SIGSEGV, regs, code, address);
7044 return 0;
7045 }
7046 diff --git a/arch/powerpc/mm/mmap_64.c b/arch/powerpc/mm/mmap_64.c
7047 index 67a42ed..cd463e0 100644
7048 --- a/arch/powerpc/mm/mmap_64.c
7049 +++ b/arch/powerpc/mm/mmap_64.c
7050 @@ -57,6 +57,10 @@ static unsigned long mmap_rnd(void)
7051 {
7052 unsigned long rnd = 0;
7053
7054 +#ifdef CONFIG_PAX_RANDMMAP
7055 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
7056 +#endif
7057 +
7058 if (current->flags & PF_RANDOMIZE) {
7059 /* 8MB for 32bit, 1GB for 64bit */
7060 if (is_32bit_task())
7061 @@ -91,10 +95,22 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
7062 */
7063 if (mmap_is_legacy()) {
7064 mm->mmap_base = TASK_UNMAPPED_BASE;
7065 +
7066 +#ifdef CONFIG_PAX_RANDMMAP
7067 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7068 + mm->mmap_base += mm->delta_mmap;
7069 +#endif
7070 +
7071 mm->get_unmapped_area = arch_get_unmapped_area;
7072 mm->unmap_area = arch_unmap_area;
7073 } else {
7074 mm->mmap_base = mmap_base();
7075 +
7076 +#ifdef CONFIG_PAX_RANDMMAP
7077 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7078 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
7079 +#endif
7080 +
7081 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
7082 mm->unmap_area = arch_unmap_area_topdown;
7083 }
7084 diff --git a/arch/powerpc/mm/mmu_context_nohash.c b/arch/powerpc/mm/mmu_context_nohash.c
7085 index e779642..e5bb889 100644
7086 --- a/arch/powerpc/mm/mmu_context_nohash.c
7087 +++ b/arch/powerpc/mm/mmu_context_nohash.c
7088 @@ -363,7 +363,7 @@ static int __cpuinit mmu_context_cpu_notify(struct notifier_block *self,
7089 return NOTIFY_OK;
7090 }
7091
7092 -static struct notifier_block __cpuinitdata mmu_context_cpu_nb = {
7093 +static struct notifier_block mmu_context_cpu_nb = {
7094 .notifier_call = mmu_context_cpu_notify,
7095 };
7096
7097 diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c
7098 index 6a252c4..3024d81 100644
7099 --- a/arch/powerpc/mm/numa.c
7100 +++ b/arch/powerpc/mm/numa.c
7101 @@ -932,7 +932,7 @@ static void __init *careful_zallocation(int nid, unsigned long size,
7102 return ret;
7103 }
7104
7105 -static struct notifier_block __cpuinitdata ppc64_numa_nb = {
7106 +static struct notifier_block ppc64_numa_nb = {
7107 .notifier_call = cpu_numa_callback,
7108 .priority = 1 /* Must run before sched domains notifier. */
7109 };
7110 diff --git a/arch/powerpc/mm/slice.c b/arch/powerpc/mm/slice.c
7111 index cf9dada..241529f 100644
7112 --- a/arch/powerpc/mm/slice.c
7113 +++ b/arch/powerpc/mm/slice.c
7114 @@ -103,7 +103,7 @@ static int slice_area_is_free(struct mm_struct *mm, unsigned long addr,
7115 if ((mm->task_size - len) < addr)
7116 return 0;
7117 vma = find_vma(mm, addr);
7118 - return (!vma || (addr + len) <= vma->vm_start);
7119 + return check_heap_stack_gap(vma, addr, len, 0);
7120 }
7121
7122 static int slice_low_has_vma(struct mm_struct *mm, unsigned long slice)
7123 @@ -272,7 +272,7 @@ full_search:
7124 addr = _ALIGN_UP(addr + 1, 1ul << SLICE_HIGH_SHIFT);
7125 continue;
7126 }
7127 - if (!vma || addr + len <= vma->vm_start) {
7128 + if (check_heap_stack_gap(vma, addr, len, 0)) {
7129 /*
7130 * Remember the place where we stopped the search:
7131 */
7132 @@ -329,10 +329,14 @@ static unsigned long slice_find_area_topdown(struct mm_struct *mm,
7133 }
7134 }
7135
7136 - addr = mm->mmap_base;
7137 - while (addr > len) {
7138 + if (mm->mmap_base < len)
7139 + addr = -ENOMEM;
7140 + else
7141 + addr = mm->mmap_base - len;
7142 +
7143 + while (!IS_ERR_VALUE(addr)) {
7144 /* Go down by chunk size */
7145 - addr = _ALIGN_DOWN(addr - len, 1ul << pshift);
7146 + addr = _ALIGN_DOWN(addr, 1ul << pshift);
7147
7148 /* Check for hit with different page size */
7149 mask = slice_range_to_mask(addr, len);
7150 @@ -352,7 +356,7 @@ static unsigned long slice_find_area_topdown(struct mm_struct *mm,
7151 * return with success:
7152 */
7153 vma = find_vma(mm, addr);
7154 - if (!vma || (addr + len) <= vma->vm_start) {
7155 + if (check_heap_stack_gap(vma, addr, len, 0)) {
7156 /* remember the address as a hint for next time */
7157 if (use_cache)
7158 mm->free_area_cache = addr;
7159 @@ -364,7 +368,7 @@ static unsigned long slice_find_area_topdown(struct mm_struct *mm,
7160 mm->cached_hole_size = vma->vm_start - addr;
7161
7162 /* try just below the current vma->vm_start */
7163 - addr = vma->vm_start;
7164 + addr = skip_heap_stack_gap(vma, len, 0);
7165 }
7166
7167 /*
7168 @@ -442,6 +446,11 @@ unsigned long slice_get_unmapped_area(unsigned long addr, unsigned long len,
7169 if (fixed && addr > (mm->task_size - len))
7170 return -EINVAL;
7171
7172 +#ifdef CONFIG_PAX_RANDMMAP
7173 + if (!fixed && (mm->pax_flags & MF_PAX_RANDMMAP))
7174 + addr = 0;
7175 +#endif
7176 +
7177 /* If hint, make sure it matches our alignment restrictions */
7178 if (!fixed && addr) {
7179 addr = _ALIGN_UP(addr, 1ul << pshift);
7180 diff --git a/arch/powerpc/platforms/cell/spufs/file.c b/arch/powerpc/platforms/cell/spufs/file.c
7181 index 68c57d3..1fdcfb2 100644
7182 --- a/arch/powerpc/platforms/cell/spufs/file.c
7183 +++ b/arch/powerpc/platforms/cell/spufs/file.c
7184 @@ -281,9 +281,9 @@ spufs_mem_mmap_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
7185 return VM_FAULT_NOPAGE;
7186 }
7187
7188 -static int spufs_mem_mmap_access(struct vm_area_struct *vma,
7189 +static ssize_t spufs_mem_mmap_access(struct vm_area_struct *vma,
7190 unsigned long address,
7191 - void *buf, int len, int write)
7192 + void *buf, size_t len, int write)
7193 {
7194 struct spu_context *ctx = vma->vm_file->private_data;
7195 unsigned long offset = address - vma->vm_start;
7196 diff --git a/arch/powerpc/platforms/powermac/smp.c b/arch/powerpc/platforms/powermac/smp.c
7197 index bdb738a..49c9f95 100644
7198 --- a/arch/powerpc/platforms/powermac/smp.c
7199 +++ b/arch/powerpc/platforms/powermac/smp.c
7200 @@ -885,7 +885,7 @@ static int smp_core99_cpu_notify(struct notifier_block *self,
7201 return NOTIFY_OK;
7202 }
7203
7204 -static struct notifier_block __cpuinitdata smp_core99_cpu_nb = {
7205 +static struct notifier_block smp_core99_cpu_nb = {
7206 .notifier_call = smp_core99_cpu_notify,
7207 };
7208 #endif /* CONFIG_HOTPLUG_CPU */
7209 diff --git a/arch/s390/include/asm/atomic.h b/arch/s390/include/asm/atomic.h
7210 index c797832..ce575c8 100644
7211 --- a/arch/s390/include/asm/atomic.h
7212 +++ b/arch/s390/include/asm/atomic.h
7213 @@ -326,6 +326,16 @@ static inline long long atomic64_dec_if_positive(atomic64_t *v)
7214 #define atomic64_dec_and_test(_v) (atomic64_sub_return(1, _v) == 0)
7215 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
7216
7217 +#define atomic64_read_unchecked(v) atomic64_read(v)
7218 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
7219 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
7220 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
7221 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
7222 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
7223 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
7224 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
7225 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
7226 +
7227 #define smp_mb__before_atomic_dec() smp_mb()
7228 #define smp_mb__after_atomic_dec() smp_mb()
7229 #define smp_mb__before_atomic_inc() smp_mb()
7230 diff --git a/arch/s390/include/asm/cache.h b/arch/s390/include/asm/cache.h
7231 index 4d7ccac..d03d0ad 100644
7232 --- a/arch/s390/include/asm/cache.h
7233 +++ b/arch/s390/include/asm/cache.h
7234 @@ -9,8 +9,10 @@
7235 #ifndef __ARCH_S390_CACHE_H
7236 #define __ARCH_S390_CACHE_H
7237
7238 -#define L1_CACHE_BYTES 256
7239 +#include <linux/const.h>
7240 +
7241 #define L1_CACHE_SHIFT 8
7242 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7243 #define NET_SKB_PAD 32
7244
7245 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
7246 diff --git a/arch/s390/include/asm/elf.h b/arch/s390/include/asm/elf.h
7247 index 1bfdf24..9c9ab2e 100644
7248 --- a/arch/s390/include/asm/elf.h
7249 +++ b/arch/s390/include/asm/elf.h
7250 @@ -160,8 +160,14 @@ extern unsigned int vdso_enabled;
7251 the loader. We need to make sure that it is out of the way of the program
7252 that it will "exec", and that there is sufficient room for the brk. */
7253
7254 -extern unsigned long randomize_et_dyn(unsigned long base);
7255 -#define ELF_ET_DYN_BASE (randomize_et_dyn(STACK_TOP / 3 * 2))
7256 +#define ELF_ET_DYN_BASE (STACK_TOP / 3 * 2)
7257 +
7258 +#ifdef CONFIG_PAX_ASLR
7259 +#define PAX_ELF_ET_DYN_BASE (test_thread_flag(TIF_31BIT) ? 0x10000UL : 0x80000000UL)
7260 +
7261 +#define PAX_DELTA_MMAP_LEN (test_thread_flag(TIF_31BIT) ? 15 : 26)
7262 +#define PAX_DELTA_STACK_LEN (test_thread_flag(TIF_31BIT) ? 15 : 26)
7263 +#endif
7264
7265 /* This yields a mask that user programs can use to figure out what
7266 instruction set this CPU supports. */
7267 @@ -207,9 +213,6 @@ struct linux_binprm;
7268 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
7269 int arch_setup_additional_pages(struct linux_binprm *, int);
7270
7271 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
7272 -#define arch_randomize_brk arch_randomize_brk
7273 -
7274 void *fill_cpu_elf_notes(void *ptr, struct save_area *sa);
7275
7276 #endif
7277 diff --git a/arch/s390/include/asm/exec.h b/arch/s390/include/asm/exec.h
7278 index c4a93d6..4d2a9b4 100644
7279 --- a/arch/s390/include/asm/exec.h
7280 +++ b/arch/s390/include/asm/exec.h
7281 @@ -7,6 +7,6 @@
7282 #ifndef __ASM_EXEC_H
7283 #define __ASM_EXEC_H
7284
7285 -extern unsigned long arch_align_stack(unsigned long sp);
7286 +#define arch_align_stack(x) ((x) & ~0xfUL)
7287
7288 #endif /* __ASM_EXEC_H */
7289 diff --git a/arch/s390/include/asm/uaccess.h b/arch/s390/include/asm/uaccess.h
7290 index 9c33ed4..e40cbef 100644
7291 --- a/arch/s390/include/asm/uaccess.h
7292 +++ b/arch/s390/include/asm/uaccess.h
7293 @@ -252,6 +252,10 @@ static inline unsigned long __must_check
7294 copy_to_user(void __user *to, const void *from, unsigned long n)
7295 {
7296 might_fault();
7297 +
7298 + if ((long)n < 0)
7299 + return n;
7300 +
7301 return __copy_to_user(to, from, n);
7302 }
7303
7304 @@ -275,6 +279,9 @@ copy_to_user(void __user *to, const void *from, unsigned long n)
7305 static inline unsigned long __must_check
7306 __copy_from_user(void *to, const void __user *from, unsigned long n)
7307 {
7308 + if ((long)n < 0)
7309 + return n;
7310 +
7311 if (__builtin_constant_p(n) && (n <= 256))
7312 return uaccess.copy_from_user_small(n, from, to);
7313 else
7314 @@ -306,10 +313,14 @@ __compiletime_warning("copy_from_user() buffer size is not provably correct")
7315 static inline unsigned long __must_check
7316 copy_from_user(void *to, const void __user *from, unsigned long n)
7317 {
7318 - unsigned int sz = __compiletime_object_size(to);
7319 + size_t sz = __compiletime_object_size(to);
7320
7321 might_fault();
7322 - if (unlikely(sz != -1 && sz < n)) {
7323 +
7324 + if ((long)n < 0)
7325 + return n;
7326 +
7327 + if (unlikely(sz != (size_t)-1 && sz < n)) {
7328 copy_from_user_overflow();
7329 return n;
7330 }
7331 diff --git a/arch/s390/kernel/module.c b/arch/s390/kernel/module.c
7332 index 7845e15..59c4353 100644
7333 --- a/arch/s390/kernel/module.c
7334 +++ b/arch/s390/kernel/module.c
7335 @@ -169,11 +169,11 @@ int module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs,
7336
7337 /* Increase core size by size of got & plt and set start
7338 offsets for got and plt. */
7339 - me->core_size = ALIGN(me->core_size, 4);
7340 - me->arch.got_offset = me->core_size;
7341 - me->core_size += me->arch.got_size;
7342 - me->arch.plt_offset = me->core_size;
7343 - me->core_size += me->arch.plt_size;
7344 + me->core_size_rw = ALIGN(me->core_size_rw, 4);
7345 + me->arch.got_offset = me->core_size_rw;
7346 + me->core_size_rw += me->arch.got_size;
7347 + me->arch.plt_offset = me->core_size_rx;
7348 + me->core_size_rx += me->arch.plt_size;
7349 return 0;
7350 }
7351
7352 @@ -289,7 +289,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7353 if (info->got_initialized == 0) {
7354 Elf_Addr *gotent;
7355
7356 - gotent = me->module_core + me->arch.got_offset +
7357 + gotent = me->module_core_rw + me->arch.got_offset +
7358 info->got_offset;
7359 *gotent = val;
7360 info->got_initialized = 1;
7361 @@ -312,7 +312,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7362 rc = apply_rela_bits(loc, val, 0, 64, 0);
7363 else if (r_type == R_390_GOTENT ||
7364 r_type == R_390_GOTPLTENT) {
7365 - val += (Elf_Addr) me->module_core - loc;
7366 + val += (Elf_Addr) me->module_core_rw - loc;
7367 rc = apply_rela_bits(loc, val, 1, 32, 1);
7368 }
7369 break;
7370 @@ -325,7 +325,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7371 case R_390_PLTOFF64: /* 16 bit offset from GOT to PLT. */
7372 if (info->plt_initialized == 0) {
7373 unsigned int *ip;
7374 - ip = me->module_core + me->arch.plt_offset +
7375 + ip = me->module_core_rx + me->arch.plt_offset +
7376 info->plt_offset;
7377 #ifndef CONFIG_64BIT
7378 ip[0] = 0x0d105810; /* basr 1,0; l 1,6(1); br 1 */
7379 @@ -350,7 +350,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7380 val - loc + 0xffffUL < 0x1ffffeUL) ||
7381 (r_type == R_390_PLT32DBL &&
7382 val - loc + 0xffffffffULL < 0x1fffffffeULL)))
7383 - val = (Elf_Addr) me->module_core +
7384 + val = (Elf_Addr) me->module_core_rx +
7385 me->arch.plt_offset +
7386 info->plt_offset;
7387 val += rela->r_addend - loc;
7388 @@ -372,7 +372,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7389 case R_390_GOTOFF32: /* 32 bit offset to GOT. */
7390 case R_390_GOTOFF64: /* 64 bit offset to GOT. */
7391 val = val + rela->r_addend -
7392 - ((Elf_Addr) me->module_core + me->arch.got_offset);
7393 + ((Elf_Addr) me->module_core_rw + me->arch.got_offset);
7394 if (r_type == R_390_GOTOFF16)
7395 rc = apply_rela_bits(loc, val, 0, 16, 0);
7396 else if (r_type == R_390_GOTOFF32)
7397 @@ -382,7 +382,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7398 break;
7399 case R_390_GOTPC: /* 32 bit PC relative offset to GOT. */
7400 case R_390_GOTPCDBL: /* 32 bit PC rel. off. to GOT shifted by 1. */
7401 - val = (Elf_Addr) me->module_core + me->arch.got_offset +
7402 + val = (Elf_Addr) me->module_core_rw + me->arch.got_offset +
7403 rela->r_addend - loc;
7404 if (r_type == R_390_GOTPC)
7405 rc = apply_rela_bits(loc, val, 1, 32, 0);
7406 diff --git a/arch/s390/kernel/process.c b/arch/s390/kernel/process.c
7407 index 536d645..4a5bd9e 100644
7408 --- a/arch/s390/kernel/process.c
7409 +++ b/arch/s390/kernel/process.c
7410 @@ -250,39 +250,3 @@ unsigned long get_wchan(struct task_struct *p)
7411 }
7412 return 0;
7413 }
7414 -
7415 -unsigned long arch_align_stack(unsigned long sp)
7416 -{
7417 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
7418 - sp -= get_random_int() & ~PAGE_MASK;
7419 - return sp & ~0xf;
7420 -}
7421 -
7422 -static inline unsigned long brk_rnd(void)
7423 -{
7424 - /* 8MB for 32bit, 1GB for 64bit */
7425 - if (is_32bit_task())
7426 - return (get_random_int() & 0x7ffUL) << PAGE_SHIFT;
7427 - else
7428 - return (get_random_int() & 0x3ffffUL) << PAGE_SHIFT;
7429 -}
7430 -
7431 -unsigned long arch_randomize_brk(struct mm_struct *mm)
7432 -{
7433 - unsigned long ret = PAGE_ALIGN(mm->brk + brk_rnd());
7434 -
7435 - if (ret < mm->brk)
7436 - return mm->brk;
7437 - return ret;
7438 -}
7439 -
7440 -unsigned long randomize_et_dyn(unsigned long base)
7441 -{
7442 - unsigned long ret = PAGE_ALIGN(base + brk_rnd());
7443 -
7444 - if (!(current->flags & PF_RANDOMIZE))
7445 - return base;
7446 - if (ret < base)
7447 - return base;
7448 - return ret;
7449 -}
7450 diff --git a/arch/s390/mm/mmap.c b/arch/s390/mm/mmap.c
7451 index 06bafec..2bca531 100644
7452 --- a/arch/s390/mm/mmap.c
7453 +++ b/arch/s390/mm/mmap.c
7454 @@ -90,10 +90,22 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
7455 */
7456 if (mmap_is_legacy()) {
7457 mm->mmap_base = TASK_UNMAPPED_BASE;
7458 +
7459 +#ifdef CONFIG_PAX_RANDMMAP
7460 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7461 + mm->mmap_base += mm->delta_mmap;
7462 +#endif
7463 +
7464 mm->get_unmapped_area = arch_get_unmapped_area;
7465 mm->unmap_area = arch_unmap_area;
7466 } else {
7467 mm->mmap_base = mmap_base();
7468 +
7469 +#ifdef CONFIG_PAX_RANDMMAP
7470 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7471 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
7472 +#endif
7473 +
7474 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
7475 mm->unmap_area = arch_unmap_area_topdown;
7476 }
7477 @@ -175,10 +187,22 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
7478 */
7479 if (mmap_is_legacy()) {
7480 mm->mmap_base = TASK_UNMAPPED_BASE;
7481 +
7482 +#ifdef CONFIG_PAX_RANDMMAP
7483 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7484 + mm->mmap_base += mm->delta_mmap;
7485 +#endif
7486 +
7487 mm->get_unmapped_area = s390_get_unmapped_area;
7488 mm->unmap_area = arch_unmap_area;
7489 } else {
7490 mm->mmap_base = mmap_base();
7491 +
7492 +#ifdef CONFIG_PAX_RANDMMAP
7493 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7494 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
7495 +#endif
7496 +
7497 mm->get_unmapped_area = s390_get_unmapped_area_topdown;
7498 mm->unmap_area = arch_unmap_area_topdown;
7499 }
7500 diff --git a/arch/score/include/asm/cache.h b/arch/score/include/asm/cache.h
7501 index ae3d59f..f65f075 100644
7502 --- a/arch/score/include/asm/cache.h
7503 +++ b/arch/score/include/asm/cache.h
7504 @@ -1,7 +1,9 @@
7505 #ifndef _ASM_SCORE_CACHE_H
7506 #define _ASM_SCORE_CACHE_H
7507
7508 +#include <linux/const.h>
7509 +
7510 #define L1_CACHE_SHIFT 4
7511 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
7512 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7513
7514 #endif /* _ASM_SCORE_CACHE_H */
7515 diff --git a/arch/score/include/asm/exec.h b/arch/score/include/asm/exec.h
7516 index f9f3cd5..58ff438 100644
7517 --- a/arch/score/include/asm/exec.h
7518 +++ b/arch/score/include/asm/exec.h
7519 @@ -1,6 +1,6 @@
7520 #ifndef _ASM_SCORE_EXEC_H
7521 #define _ASM_SCORE_EXEC_H
7522
7523 -extern unsigned long arch_align_stack(unsigned long sp);
7524 +#define arch_align_stack(x) (x)
7525
7526 #endif /* _ASM_SCORE_EXEC_H */
7527 diff --git a/arch/score/kernel/process.c b/arch/score/kernel/process.c
7528 index 7956846..5f37677 100644
7529 --- a/arch/score/kernel/process.c
7530 +++ b/arch/score/kernel/process.c
7531 @@ -134,8 +134,3 @@ unsigned long get_wchan(struct task_struct *task)
7532
7533 return task_pt_regs(task)->cp0_epc;
7534 }
7535 -
7536 -unsigned long arch_align_stack(unsigned long sp)
7537 -{
7538 - return sp;
7539 -}
7540 diff --git a/arch/sh/include/asm/cache.h b/arch/sh/include/asm/cache.h
7541 index ef9e555..331bd29 100644
7542 --- a/arch/sh/include/asm/cache.h
7543 +++ b/arch/sh/include/asm/cache.h
7544 @@ -9,10 +9,11 @@
7545 #define __ASM_SH_CACHE_H
7546 #ifdef __KERNEL__
7547
7548 +#include <linux/const.h>
7549 #include <linux/init.h>
7550 #include <cpu/cache.h>
7551
7552 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
7553 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7554
7555 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
7556
7557 diff --git a/arch/sh/kernel/cpu/sh4a/smp-shx3.c b/arch/sh/kernel/cpu/sh4a/smp-shx3.c
7558 index 03f2b55..b0270327 100644
7559 --- a/arch/sh/kernel/cpu/sh4a/smp-shx3.c
7560 +++ b/arch/sh/kernel/cpu/sh4a/smp-shx3.c
7561 @@ -143,7 +143,7 @@ shx3_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
7562 return NOTIFY_OK;
7563 }
7564
7565 -static struct notifier_block __cpuinitdata shx3_cpu_notifier = {
7566 +static struct notifier_block shx3_cpu_notifier = {
7567 .notifier_call = shx3_cpu_callback,
7568 };
7569
7570 diff --git a/arch/sh/mm/mmap.c b/arch/sh/mm/mmap.c
7571 index 6777177..cb5e44f 100644
7572 --- a/arch/sh/mm/mmap.c
7573 +++ b/arch/sh/mm/mmap.c
7574 @@ -36,6 +36,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
7575 struct mm_struct *mm = current->mm;
7576 struct vm_area_struct *vma;
7577 int do_colour_align;
7578 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
7579 struct vm_unmapped_area_info info;
7580
7581 if (flags & MAP_FIXED) {
7582 @@ -55,6 +56,10 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
7583 if (filp || (flags & MAP_SHARED))
7584 do_colour_align = 1;
7585
7586 +#ifdef CONFIG_PAX_RANDMMAP
7587 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
7588 +#endif
7589 +
7590 if (addr) {
7591 if (do_colour_align)
7592 addr = COLOUR_ALIGN(addr, pgoff);
7593 @@ -62,14 +67,13 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
7594 addr = PAGE_ALIGN(addr);
7595
7596 vma = find_vma(mm, addr);
7597 - if (TASK_SIZE - len >= addr &&
7598 - (!vma || addr + len <= vma->vm_start))
7599 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
7600 return addr;
7601 }
7602
7603 info.flags = 0;
7604 info.length = len;
7605 - info.low_limit = TASK_UNMAPPED_BASE;
7606 + info.low_limit = mm->mmap_base;
7607 info.high_limit = TASK_SIZE;
7608 info.align_mask = do_colour_align ? (PAGE_MASK & shm_align_mask) : 0;
7609 info.align_offset = pgoff << PAGE_SHIFT;
7610 @@ -85,6 +89,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
7611 struct mm_struct *mm = current->mm;
7612 unsigned long addr = addr0;
7613 int do_colour_align;
7614 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
7615 struct vm_unmapped_area_info info;
7616
7617 if (flags & MAP_FIXED) {
7618 @@ -104,6 +109,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
7619 if (filp || (flags & MAP_SHARED))
7620 do_colour_align = 1;
7621
7622 +#ifdef CONFIG_PAX_RANDMMAP
7623 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
7624 +#endif
7625 +
7626 /* requesting a specific address */
7627 if (addr) {
7628 if (do_colour_align)
7629 @@ -112,8 +121,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
7630 addr = PAGE_ALIGN(addr);
7631
7632 vma = find_vma(mm, addr);
7633 - if (TASK_SIZE - len >= addr &&
7634 - (!vma || addr + len <= vma->vm_start))
7635 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
7636 return addr;
7637 }
7638
7639 @@ -135,6 +143,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
7640 VM_BUG_ON(addr != -ENOMEM);
7641 info.flags = 0;
7642 info.low_limit = TASK_UNMAPPED_BASE;
7643 +
7644 +#ifdef CONFIG_PAX_RANDMMAP
7645 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7646 + info.low_limit += mm->delta_mmap;
7647 +#endif
7648 +
7649 info.high_limit = TASK_SIZE;
7650 addr = vm_unmapped_area(&info);
7651 }
7652 diff --git a/arch/sparc/include/asm/atomic_64.h b/arch/sparc/include/asm/atomic_64.h
7653 index be56a24..443328f 100644
7654 --- a/arch/sparc/include/asm/atomic_64.h
7655 +++ b/arch/sparc/include/asm/atomic_64.h
7656 @@ -14,18 +14,40 @@
7657 #define ATOMIC64_INIT(i) { (i) }
7658
7659 #define atomic_read(v) (*(volatile int *)&(v)->counter)
7660 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
7661 +{
7662 + return v->counter;
7663 +}
7664 #define atomic64_read(v) (*(volatile long *)&(v)->counter)
7665 +static inline long atomic64_read_unchecked(const atomic64_unchecked_t *v)
7666 +{
7667 + return v->counter;
7668 +}
7669
7670 #define atomic_set(v, i) (((v)->counter) = i)
7671 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
7672 +{
7673 + v->counter = i;
7674 +}
7675 #define atomic64_set(v, i) (((v)->counter) = i)
7676 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
7677 +{
7678 + v->counter = i;
7679 +}
7680
7681 extern void atomic_add(int, atomic_t *);
7682 +extern void atomic_add_unchecked(int, atomic_unchecked_t *);
7683 extern void atomic64_add(long, atomic64_t *);
7684 +extern void atomic64_add_unchecked(long, atomic64_unchecked_t *);
7685 extern void atomic_sub(int, atomic_t *);
7686 +extern void atomic_sub_unchecked(int, atomic_unchecked_t *);
7687 extern void atomic64_sub(long, atomic64_t *);
7688 +extern void atomic64_sub_unchecked(long, atomic64_unchecked_t *);
7689
7690 extern int atomic_add_ret(int, atomic_t *);
7691 +extern int atomic_add_ret_unchecked(int, atomic_unchecked_t *);
7692 extern long atomic64_add_ret(long, atomic64_t *);
7693 +extern long atomic64_add_ret_unchecked(long, atomic64_unchecked_t *);
7694 extern int atomic_sub_ret(int, atomic_t *);
7695 extern long atomic64_sub_ret(long, atomic64_t *);
7696
7697 @@ -33,13 +55,29 @@ extern long atomic64_sub_ret(long, atomic64_t *);
7698 #define atomic64_dec_return(v) atomic64_sub_ret(1, v)
7699
7700 #define atomic_inc_return(v) atomic_add_ret(1, v)
7701 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
7702 +{
7703 + return atomic_add_ret_unchecked(1, v);
7704 +}
7705 #define atomic64_inc_return(v) atomic64_add_ret(1, v)
7706 +static inline long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
7707 +{
7708 + return atomic64_add_ret_unchecked(1, v);
7709 +}
7710
7711 #define atomic_sub_return(i, v) atomic_sub_ret(i, v)
7712 #define atomic64_sub_return(i, v) atomic64_sub_ret(i, v)
7713
7714 #define atomic_add_return(i, v) atomic_add_ret(i, v)
7715 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
7716 +{
7717 + return atomic_add_ret_unchecked(i, v);
7718 +}
7719 #define atomic64_add_return(i, v) atomic64_add_ret(i, v)
7720 +static inline long atomic64_add_return_unchecked(long i, atomic64_unchecked_t *v)
7721 +{
7722 + return atomic64_add_ret_unchecked(i, v);
7723 +}
7724
7725 /*
7726 * atomic_inc_and_test - increment and test
7727 @@ -50,6 +88,10 @@ extern long atomic64_sub_ret(long, atomic64_t *);
7728 * other cases.
7729 */
7730 #define atomic_inc_and_test(v) (atomic_inc_return(v) == 0)
7731 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
7732 +{
7733 + return atomic_inc_return_unchecked(v) == 0;
7734 +}
7735 #define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0)
7736
7737 #define atomic_sub_and_test(i, v) (atomic_sub_ret(i, v) == 0)
7738 @@ -59,25 +101,60 @@ extern long atomic64_sub_ret(long, atomic64_t *);
7739 #define atomic64_dec_and_test(v) (atomic64_sub_ret(1, v) == 0)
7740
7741 #define atomic_inc(v) atomic_add(1, v)
7742 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
7743 +{
7744 + atomic_add_unchecked(1, v);
7745 +}
7746 #define atomic64_inc(v) atomic64_add(1, v)
7747 +static inline void atomic64_inc_unchecked(atomic64_unchecked_t *v)
7748 +{
7749 + atomic64_add_unchecked(1, v);
7750 +}
7751
7752 #define atomic_dec(v) atomic_sub(1, v)
7753 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
7754 +{
7755 + atomic_sub_unchecked(1, v);
7756 +}
7757 #define atomic64_dec(v) atomic64_sub(1, v)
7758 +static inline void atomic64_dec_unchecked(atomic64_unchecked_t *v)
7759 +{
7760 + atomic64_sub_unchecked(1, v);
7761 +}
7762
7763 #define atomic_add_negative(i, v) (atomic_add_ret(i, v) < 0)
7764 #define atomic64_add_negative(i, v) (atomic64_add_ret(i, v) < 0)
7765
7766 #define atomic_cmpxchg(v, o, n) (cmpxchg(&((v)->counter), (o), (n)))
7767 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
7768 +{
7769 + return cmpxchg(&v->counter, old, new);
7770 +}
7771 #define atomic_xchg(v, new) (xchg(&((v)->counter), new))
7772 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
7773 +{
7774 + return xchg(&v->counter, new);
7775 +}
7776
7777 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
7778 {
7779 - int c, old;
7780 + int c, old, new;
7781 c = atomic_read(v);
7782 for (;;) {
7783 - if (unlikely(c == (u)))
7784 + if (unlikely(c == u))
7785 break;
7786 - old = atomic_cmpxchg((v), c, c + (a));
7787 +
7788 + asm volatile("addcc %2, %0, %0\n"
7789 +
7790 +#ifdef CONFIG_PAX_REFCOUNT
7791 + "tvs %%icc, 6\n"
7792 +#endif
7793 +
7794 + : "=r" (new)
7795 + : "0" (c), "ir" (a)
7796 + : "cc");
7797 +
7798 + old = atomic_cmpxchg(v, c, new);
7799 if (likely(old == c))
7800 break;
7801 c = old;
7802 @@ -88,20 +165,35 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
7803 #define atomic64_cmpxchg(v, o, n) \
7804 ((__typeof__((v)->counter))cmpxchg(&((v)->counter), (o), (n)))
7805 #define atomic64_xchg(v, new) (xchg(&((v)->counter), new))
7806 +static inline long atomic64_xchg_unchecked(atomic64_unchecked_t *v, long new)
7807 +{
7808 + return xchg(&v->counter, new);
7809 +}
7810
7811 static inline long atomic64_add_unless(atomic64_t *v, long a, long u)
7812 {
7813 - long c, old;
7814 + long c, old, new;
7815 c = atomic64_read(v);
7816 for (;;) {
7817 - if (unlikely(c == (u)))
7818 + if (unlikely(c == u))
7819 break;
7820 - old = atomic64_cmpxchg((v), c, c + (a));
7821 +
7822 + asm volatile("addcc %2, %0, %0\n"
7823 +
7824 +#ifdef CONFIG_PAX_REFCOUNT
7825 + "tvs %%xcc, 6\n"
7826 +#endif
7827 +
7828 + : "=r" (new)
7829 + : "0" (c), "ir" (a)
7830 + : "cc");
7831 +
7832 + old = atomic64_cmpxchg(v, c, new);
7833 if (likely(old == c))
7834 break;
7835 c = old;
7836 }
7837 - return c != (u);
7838 + return c != u;
7839 }
7840
7841 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
7842 diff --git a/arch/sparc/include/asm/cache.h b/arch/sparc/include/asm/cache.h
7843 index 5bb6991..5c2132e 100644
7844 --- a/arch/sparc/include/asm/cache.h
7845 +++ b/arch/sparc/include/asm/cache.h
7846 @@ -7,10 +7,12 @@
7847 #ifndef _SPARC_CACHE_H
7848 #define _SPARC_CACHE_H
7849
7850 +#include <linux/const.h>
7851 +
7852 #define ARCH_SLAB_MINALIGN __alignof__(unsigned long long)
7853
7854 #define L1_CACHE_SHIFT 5
7855 -#define L1_CACHE_BYTES 32
7856 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7857
7858 #ifdef CONFIG_SPARC32
7859 #define SMP_CACHE_BYTES_SHIFT 5
7860 diff --git a/arch/sparc/include/asm/elf_32.h b/arch/sparc/include/asm/elf_32.h
7861 index a24e41f..47677ff 100644
7862 --- a/arch/sparc/include/asm/elf_32.h
7863 +++ b/arch/sparc/include/asm/elf_32.h
7864 @@ -114,6 +114,13 @@ typedef struct {
7865
7866 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE)
7867
7868 +#ifdef CONFIG_PAX_ASLR
7869 +#define PAX_ELF_ET_DYN_BASE 0x10000UL
7870 +
7871 +#define PAX_DELTA_MMAP_LEN 16
7872 +#define PAX_DELTA_STACK_LEN 16
7873 +#endif
7874 +
7875 /* This yields a mask that user programs can use to figure out what
7876 instruction set this cpu supports. This can NOT be done in userspace
7877 on Sparc. */
7878 diff --git a/arch/sparc/include/asm/elf_64.h b/arch/sparc/include/asm/elf_64.h
7879 index 370ca1e..d4f4a98 100644
7880 --- a/arch/sparc/include/asm/elf_64.h
7881 +++ b/arch/sparc/include/asm/elf_64.h
7882 @@ -189,6 +189,13 @@ typedef struct {
7883 #define ELF_ET_DYN_BASE 0x0000010000000000UL
7884 #define COMPAT_ELF_ET_DYN_BASE 0x0000000070000000UL
7885
7886 +#ifdef CONFIG_PAX_ASLR
7887 +#define PAX_ELF_ET_DYN_BASE (test_thread_flag(TIF_32BIT) ? 0x10000UL : 0x100000UL)
7888 +
7889 +#define PAX_DELTA_MMAP_LEN (test_thread_flag(TIF_32BIT) ? 14 : 28)
7890 +#define PAX_DELTA_STACK_LEN (test_thread_flag(TIF_32BIT) ? 15 : 29)
7891 +#endif
7892 +
7893 extern unsigned long sparc64_elf_hwcap;
7894 #define ELF_HWCAP sparc64_elf_hwcap
7895
7896 diff --git a/arch/sparc/include/asm/pgalloc_32.h b/arch/sparc/include/asm/pgalloc_32.h
7897 index 9b1c36d..209298b 100644
7898 --- a/arch/sparc/include/asm/pgalloc_32.h
7899 +++ b/arch/sparc/include/asm/pgalloc_32.h
7900 @@ -33,6 +33,7 @@ static inline void pgd_set(pgd_t * pgdp, pmd_t * pmdp)
7901 }
7902
7903 #define pgd_populate(MM, PGD, PMD) pgd_set(PGD, PMD)
7904 +#define pgd_populate_kernel(MM, PGD, PMD) pgd_populate((MM), (PGD), (PMD))
7905
7906 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm,
7907 unsigned long address)
7908 diff --git a/arch/sparc/include/asm/pgalloc_64.h b/arch/sparc/include/asm/pgalloc_64.h
7909 index bcfe063..b333142 100644
7910 --- a/arch/sparc/include/asm/pgalloc_64.h
7911 +++ b/arch/sparc/include/asm/pgalloc_64.h
7912 @@ -26,6 +26,7 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
7913 }
7914
7915 #define pud_populate(MM, PUD, PMD) pud_set(PUD, PMD)
7916 +#define pud_populate_kernel(MM, PUD, PMD) pud_populate((MM), (PUD), (PMD))
7917
7918 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
7919 {
7920 diff --git a/arch/sparc/include/asm/pgtable_32.h b/arch/sparc/include/asm/pgtable_32.h
7921 index 6fc1348..390c50a 100644
7922 --- a/arch/sparc/include/asm/pgtable_32.h
7923 +++ b/arch/sparc/include/asm/pgtable_32.h
7924 @@ -50,6 +50,9 @@ extern unsigned long calc_highpages(void);
7925 #define PAGE_SHARED SRMMU_PAGE_SHARED
7926 #define PAGE_COPY SRMMU_PAGE_COPY
7927 #define PAGE_READONLY SRMMU_PAGE_RDONLY
7928 +#define PAGE_SHARED_NOEXEC SRMMU_PAGE_SHARED_NOEXEC
7929 +#define PAGE_COPY_NOEXEC SRMMU_PAGE_COPY_NOEXEC
7930 +#define PAGE_READONLY_NOEXEC SRMMU_PAGE_RDONLY_NOEXEC
7931 #define PAGE_KERNEL SRMMU_PAGE_KERNEL
7932
7933 /* Top-level page directory - dummy used by init-mm.
7934 @@ -62,18 +65,18 @@ extern unsigned long ptr_in_current_pgd;
7935
7936 /* xwr */
7937 #define __P000 PAGE_NONE
7938 -#define __P001 PAGE_READONLY
7939 -#define __P010 PAGE_COPY
7940 -#define __P011 PAGE_COPY
7941 +#define __P001 PAGE_READONLY_NOEXEC
7942 +#define __P010 PAGE_COPY_NOEXEC
7943 +#define __P011 PAGE_COPY_NOEXEC
7944 #define __P100 PAGE_READONLY
7945 #define __P101 PAGE_READONLY
7946 #define __P110 PAGE_COPY
7947 #define __P111 PAGE_COPY
7948
7949 #define __S000 PAGE_NONE
7950 -#define __S001 PAGE_READONLY
7951 -#define __S010 PAGE_SHARED
7952 -#define __S011 PAGE_SHARED
7953 +#define __S001 PAGE_READONLY_NOEXEC
7954 +#define __S010 PAGE_SHARED_NOEXEC
7955 +#define __S011 PAGE_SHARED_NOEXEC
7956 #define __S100 PAGE_READONLY
7957 #define __S101 PAGE_READONLY
7958 #define __S110 PAGE_SHARED
7959 diff --git a/arch/sparc/include/asm/pgtsrmmu.h b/arch/sparc/include/asm/pgtsrmmu.h
7960 index 79da178..c2eede8 100644
7961 --- a/arch/sparc/include/asm/pgtsrmmu.h
7962 +++ b/arch/sparc/include/asm/pgtsrmmu.h
7963 @@ -115,6 +115,11 @@
7964 SRMMU_EXEC | SRMMU_REF)
7965 #define SRMMU_PAGE_RDONLY __pgprot(SRMMU_VALID | SRMMU_CACHE | \
7966 SRMMU_EXEC | SRMMU_REF)
7967 +
7968 +#define SRMMU_PAGE_SHARED_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_WRITE | SRMMU_REF)
7969 +#define SRMMU_PAGE_COPY_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_REF)
7970 +#define SRMMU_PAGE_RDONLY_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_REF)
7971 +
7972 #define SRMMU_PAGE_KERNEL __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_PRIV | \
7973 SRMMU_DIRTY | SRMMU_REF)
7974
7975 diff --git a/arch/sparc/include/asm/spinlock_64.h b/arch/sparc/include/asm/spinlock_64.h
7976 index 9689176..63c18ea 100644
7977 --- a/arch/sparc/include/asm/spinlock_64.h
7978 +++ b/arch/sparc/include/asm/spinlock_64.h
7979 @@ -92,14 +92,19 @@ static inline void arch_spin_lock_flags(arch_spinlock_t *lock, unsigned long fla
7980
7981 /* Multi-reader locks, these are much saner than the 32-bit Sparc ones... */
7982
7983 -static void inline arch_read_lock(arch_rwlock_t *lock)
7984 +static inline void arch_read_lock(arch_rwlock_t *lock)
7985 {
7986 unsigned long tmp1, tmp2;
7987
7988 __asm__ __volatile__ (
7989 "1: ldsw [%2], %0\n"
7990 " brlz,pn %0, 2f\n"
7991 -"4: add %0, 1, %1\n"
7992 +"4: 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 @@ -112,10 +117,10 @@ static void inline arch_read_lock(arch_rwlock_t *lock)
8002 " .previous"
8003 : "=&r" (tmp1), "=&r" (tmp2)
8004 : "r" (lock)
8005 - : "memory");
8006 + : "memory", "cc");
8007 }
8008
8009 -static int inline arch_read_trylock(arch_rwlock_t *lock)
8010 +static inline int arch_read_trylock(arch_rwlock_t *lock)
8011 {
8012 int tmp1, tmp2;
8013
8014 @@ -123,7 +128,12 @@ static int inline arch_read_trylock(arch_rwlock_t *lock)
8015 "1: ldsw [%2], %0\n"
8016 " brlz,a,pn %0, 2f\n"
8017 " mov 0, %0\n"
8018 -" add %0, 1, %1\n"
8019 +" addcc %0, 1, %1\n"
8020 +
8021 +#ifdef CONFIG_PAX_REFCOUNT
8022 +" tvs %%icc, 6\n"
8023 +#endif
8024 +
8025 " cas [%2], %0, %1\n"
8026 " cmp %0, %1\n"
8027 " bne,pn %%icc, 1b\n"
8028 @@ -136,13 +146,18 @@ static int inline arch_read_trylock(arch_rwlock_t *lock)
8029 return tmp1;
8030 }
8031
8032 -static void inline arch_read_unlock(arch_rwlock_t *lock)
8033 +static inline void arch_read_unlock(arch_rwlock_t *lock)
8034 {
8035 unsigned long tmp1, tmp2;
8036
8037 __asm__ __volatile__(
8038 "1: lduw [%2], %0\n"
8039 -" sub %0, 1, %1\n"
8040 +" subcc %0, 1, %1\n"
8041 +
8042 +#ifdef CONFIG_PAX_REFCOUNT
8043 +" tvs %%icc, 6\n"
8044 +#endif
8045 +
8046 " cas [%2], %0, %1\n"
8047 " cmp %0, %1\n"
8048 " bne,pn %%xcc, 1b\n"
8049 @@ -152,7 +167,7 @@ static void inline arch_read_unlock(arch_rwlock_t *lock)
8050 : "memory");
8051 }
8052
8053 -static void inline arch_write_lock(arch_rwlock_t *lock)
8054 +static inline void arch_write_lock(arch_rwlock_t *lock)
8055 {
8056 unsigned long mask, tmp1, tmp2;
8057
8058 @@ -177,7 +192,7 @@ static void inline arch_write_lock(arch_rwlock_t *lock)
8059 : "memory");
8060 }
8061
8062 -static void inline arch_write_unlock(arch_rwlock_t *lock)
8063 +static inline void arch_write_unlock(arch_rwlock_t *lock)
8064 {
8065 __asm__ __volatile__(
8066 " stw %%g0, [%0]"
8067 @@ -186,7 +201,7 @@ static void inline arch_write_unlock(arch_rwlock_t *lock)
8068 : "memory");
8069 }
8070
8071 -static int inline arch_write_trylock(arch_rwlock_t *lock)
8072 +static inline int arch_write_trylock(arch_rwlock_t *lock)
8073 {
8074 unsigned long mask, tmp1, tmp2, result;
8075
8076 diff --git a/arch/sparc/include/asm/thread_info_32.h b/arch/sparc/include/asm/thread_info_32.h
8077 index 25849ae..924c54b 100644
8078 --- a/arch/sparc/include/asm/thread_info_32.h
8079 +++ b/arch/sparc/include/asm/thread_info_32.h
8080 @@ -49,6 +49,8 @@ struct thread_info {
8081 unsigned long w_saved;
8082
8083 struct restart_block restart_block;
8084 +
8085 + unsigned long lowest_stack;
8086 };
8087
8088 /*
8089 diff --git a/arch/sparc/include/asm/thread_info_64.h b/arch/sparc/include/asm/thread_info_64.h
8090 index 269bd92..e46a9b8 100644
8091 --- a/arch/sparc/include/asm/thread_info_64.h
8092 +++ b/arch/sparc/include/asm/thread_info_64.h
8093 @@ -63,6 +63,8 @@ struct thread_info {
8094 struct pt_regs *kern_una_regs;
8095 unsigned int kern_una_insn;
8096
8097 + unsigned long lowest_stack;
8098 +
8099 unsigned long fpregs[0] __attribute__ ((aligned(64)));
8100 };
8101
8102 @@ -192,10 +194,11 @@ register struct thread_info *current_thread_info_reg asm("g6");
8103 #define TIF_UNALIGNED 5 /* allowed to do unaligned accesses */
8104 /* flag bit 6 is available */
8105 #define TIF_32BIT 7 /* 32-bit binary */
8106 -/* flag bit 8 is available */
8107 +#define TIF_GRSEC_SETXID 8 /* update credentials on syscall entry/exit */
8108 #define TIF_SECCOMP 9 /* secure computing */
8109 #define TIF_SYSCALL_AUDIT 10 /* syscall auditing active */
8110 #define TIF_SYSCALL_TRACEPOINT 11 /* syscall tracepoint instrumentation */
8111 +
8112 /* NOTE: Thread flags >= 12 should be ones we have no interest
8113 * in using in assembly, else we can't use the mask as
8114 * an immediate value in instructions such as andcc.
8115 @@ -214,12 +217,18 @@ register struct thread_info *current_thread_info_reg asm("g6");
8116 #define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT)
8117 #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
8118 #define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
8119 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
8120
8121 #define _TIF_USER_WORK_MASK ((0xff << TI_FLAG_WSAVED_SHIFT) | \
8122 _TIF_DO_NOTIFY_RESUME_MASK | \
8123 _TIF_NEED_RESCHED)
8124 #define _TIF_DO_NOTIFY_RESUME_MASK (_TIF_NOTIFY_RESUME | _TIF_SIGPENDING)
8125
8126 +#define _TIF_WORK_SYSCALL \
8127 + (_TIF_SYSCALL_TRACE | _TIF_SECCOMP | _TIF_SYSCALL_AUDIT | \
8128 + _TIF_SYSCALL_TRACEPOINT | _TIF_GRSEC_SETXID)
8129 +
8130 +
8131 /*
8132 * Thread-synchronous status.
8133 *
8134 diff --git a/arch/sparc/include/asm/uaccess.h b/arch/sparc/include/asm/uaccess.h
8135 index 0167d26..767bb0c 100644
8136 --- a/arch/sparc/include/asm/uaccess.h
8137 +++ b/arch/sparc/include/asm/uaccess.h
8138 @@ -1,5 +1,6 @@
8139 #ifndef ___ASM_SPARC_UACCESS_H
8140 #define ___ASM_SPARC_UACCESS_H
8141 +
8142 #if defined(__sparc__) && defined(__arch64__)
8143 #include <asm/uaccess_64.h>
8144 #else
8145 diff --git a/arch/sparc/include/asm/uaccess_32.h b/arch/sparc/include/asm/uaccess_32.h
8146 index 53a28dd..50c38c3 100644
8147 --- a/arch/sparc/include/asm/uaccess_32.h
8148 +++ b/arch/sparc/include/asm/uaccess_32.h
8149 @@ -250,27 +250,46 @@ extern unsigned long __copy_user(void __user *to, const void __user *from, unsig
8150
8151 static inline unsigned long copy_to_user(void __user *to, const void *from, unsigned long n)
8152 {
8153 - if (n && __access_ok((unsigned long) to, n))
8154 + if ((long)n < 0)
8155 + return n;
8156 +
8157 + if (n && __access_ok((unsigned long) to, n)) {
8158 + if (!__builtin_constant_p(n))
8159 + check_object_size(from, n, true);
8160 return __copy_user(to, (__force void __user *) from, n);
8161 - else
8162 + } else
8163 return n;
8164 }
8165
8166 static inline unsigned long __copy_to_user(void __user *to, const void *from, unsigned long n)
8167 {
8168 + if ((long)n < 0)
8169 + return n;
8170 +
8171 + if (!__builtin_constant_p(n))
8172 + check_object_size(from, n, true);
8173 +
8174 return __copy_user(to, (__force void __user *) from, n);
8175 }
8176
8177 static inline unsigned long copy_from_user(void *to, const void __user *from, unsigned long n)
8178 {
8179 - if (n && __access_ok((unsigned long) from, n))
8180 + if ((long)n < 0)
8181 + return n;
8182 +
8183 + if (n && __access_ok((unsigned long) from, n)) {
8184 + if (!__builtin_constant_p(n))
8185 + check_object_size(to, n, false);
8186 return __copy_user((__force void __user *) to, from, n);
8187 - else
8188 + } else
8189 return n;
8190 }
8191
8192 static inline unsigned long __copy_from_user(void *to, const void __user *from, unsigned long n)
8193 {
8194 + if ((long)n < 0)
8195 + return n;
8196 +
8197 return __copy_user((__force void __user *) to, from, n);
8198 }
8199
8200 diff --git a/arch/sparc/include/asm/uaccess_64.h b/arch/sparc/include/asm/uaccess_64.h
8201 index e562d3c..191f176 100644
8202 --- a/arch/sparc/include/asm/uaccess_64.h
8203 +++ b/arch/sparc/include/asm/uaccess_64.h
8204 @@ -10,6 +10,7 @@
8205 #include <linux/compiler.h>
8206 #include <linux/string.h>
8207 #include <linux/thread_info.h>
8208 +#include <linux/kernel.h>
8209 #include <asm/asi.h>
8210 #include <asm/spitfire.h>
8211 #include <asm-generic/uaccess-unaligned.h>
8212 @@ -214,8 +215,15 @@ extern unsigned long copy_from_user_fixup(void *to, const void __user *from,
8213 static inline unsigned long __must_check
8214 copy_from_user(void *to, const void __user *from, unsigned long size)
8215 {
8216 - unsigned long ret = ___copy_from_user(to, from, size);
8217 + unsigned long ret;
8218
8219 + if ((long)size < 0 || size > INT_MAX)
8220 + return size;
8221 +
8222 + if (!__builtin_constant_p(size))
8223 + check_object_size(to, size, false);
8224 +
8225 + ret = ___copy_from_user(to, from, size);
8226 if (unlikely(ret))
8227 ret = copy_from_user_fixup(to, from, size);
8228
8229 @@ -231,8 +239,15 @@ extern unsigned long copy_to_user_fixup(void __user *to, const void *from,
8230 static inline unsigned long __must_check
8231 copy_to_user(void __user *to, const void *from, unsigned long size)
8232 {
8233 - unsigned long ret = ___copy_to_user(to, from, size);
8234 + unsigned long ret;
8235
8236 + if ((long)size < 0 || size > INT_MAX)
8237 + return size;
8238 +
8239 + if (!__builtin_constant_p(size))
8240 + check_object_size(from, size, true);
8241 +
8242 + ret = ___copy_to_user(to, from, size);
8243 if (unlikely(ret))
8244 ret = copy_to_user_fixup(to, from, size);
8245 return ret;
8246 diff --git a/arch/sparc/kernel/Makefile b/arch/sparc/kernel/Makefile
8247 index 6cf591b..b49e65a 100644
8248 --- a/arch/sparc/kernel/Makefile
8249 +++ b/arch/sparc/kernel/Makefile
8250 @@ -3,7 +3,7 @@
8251 #
8252
8253 asflags-y := -ansi
8254 -ccflags-y := -Werror
8255 +#ccflags-y := -Werror
8256
8257 extra-y := head_$(BITS).o
8258
8259 diff --git a/arch/sparc/kernel/process_32.c b/arch/sparc/kernel/process_32.c
8260 index 62eede1..9c5b904 100644
8261 --- a/arch/sparc/kernel/process_32.c
8262 +++ b/arch/sparc/kernel/process_32.c
8263 @@ -125,14 +125,14 @@ void show_regs(struct pt_regs *r)
8264
8265 printk("PSR: %08lx PC: %08lx NPC: %08lx Y: %08lx %s\n",
8266 r->psr, r->pc, r->npc, r->y, print_tainted());
8267 - printk("PC: <%pS>\n", (void *) r->pc);
8268 + printk("PC: <%pA>\n", (void *) r->pc);
8269 printk("%%G: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
8270 r->u_regs[0], r->u_regs[1], r->u_regs[2], r->u_regs[3],
8271 r->u_regs[4], r->u_regs[5], r->u_regs[6], r->u_regs[7]);
8272 printk("%%O: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
8273 r->u_regs[8], r->u_regs[9], r->u_regs[10], r->u_regs[11],
8274 r->u_regs[12], r->u_regs[13], r->u_regs[14], r->u_regs[15]);
8275 - printk("RPC: <%pS>\n", (void *) r->u_regs[15]);
8276 + printk("RPC: <%pA>\n", (void *) r->u_regs[15]);
8277
8278 printk("%%L: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
8279 rw->locals[0], rw->locals[1], rw->locals[2], rw->locals[3],
8280 @@ -167,7 +167,7 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp)
8281 rw = (struct reg_window32 *) fp;
8282 pc = rw->ins[7];
8283 printk("[%08lx : ", pc);
8284 - printk("%pS ] ", (void *) pc);
8285 + printk("%pA ] ", (void *) pc);
8286 fp = rw->ins[6];
8287 } while (++count < 16);
8288 printk("\n");
8289 diff --git a/arch/sparc/kernel/process_64.c b/arch/sparc/kernel/process_64.c
8290 index cdb80b2..5ca141d 100644
8291 --- a/arch/sparc/kernel/process_64.c
8292 +++ b/arch/sparc/kernel/process_64.c
8293 @@ -181,14 +181,14 @@ static void show_regwindow(struct pt_regs *regs)
8294 printk("i4: %016lx i5: %016lx i6: %016lx i7: %016lx\n",
8295 rwk->ins[4], rwk->ins[5], rwk->ins[6], rwk->ins[7]);
8296 if (regs->tstate & TSTATE_PRIV)
8297 - printk("I7: <%pS>\n", (void *) rwk->ins[7]);
8298 + printk("I7: <%pA>\n", (void *) rwk->ins[7]);
8299 }
8300
8301 void show_regs(struct pt_regs *regs)
8302 {
8303 printk("TSTATE: %016lx TPC: %016lx TNPC: %016lx Y: %08x %s\n", regs->tstate,
8304 regs->tpc, regs->tnpc, regs->y, print_tainted());
8305 - printk("TPC: <%pS>\n", (void *) regs->tpc);
8306 + printk("TPC: <%pA>\n", (void *) regs->tpc);
8307 printk("g0: %016lx g1: %016lx g2: %016lx g3: %016lx\n",
8308 regs->u_regs[0], regs->u_regs[1], regs->u_regs[2],
8309 regs->u_regs[3]);
8310 @@ -201,7 +201,7 @@ void show_regs(struct pt_regs *regs)
8311 printk("o4: %016lx o5: %016lx sp: %016lx ret_pc: %016lx\n",
8312 regs->u_regs[12], regs->u_regs[13], regs->u_regs[14],
8313 regs->u_regs[15]);
8314 - printk("RPC: <%pS>\n", (void *) regs->u_regs[15]);
8315 + printk("RPC: <%pA>\n", (void *) regs->u_regs[15]);
8316 show_regwindow(regs);
8317 show_stack(current, (unsigned long *) regs->u_regs[UREG_FP]);
8318 }
8319 @@ -290,7 +290,7 @@ void arch_trigger_all_cpu_backtrace(void)
8320 ((tp && tp->task) ? tp->task->pid : -1));
8321
8322 if (gp->tstate & TSTATE_PRIV) {
8323 - printk(" TPC[%pS] O7[%pS] I7[%pS] RPC[%pS]\n",
8324 + printk(" TPC[%pA] O7[%pA] I7[%pA] RPC[%pA]\n",
8325 (void *) gp->tpc,
8326 (void *) gp->o7,
8327 (void *) gp->i7,
8328 diff --git a/arch/sparc/kernel/prom_common.c b/arch/sparc/kernel/prom_common.c
8329 index 9f20566..67eb41b 100644
8330 --- a/arch/sparc/kernel/prom_common.c
8331 +++ b/arch/sparc/kernel/prom_common.c
8332 @@ -143,7 +143,7 @@ static int __init prom_common_nextprop(phandle node, char *prev, char *buf)
8333
8334 unsigned int prom_early_allocated __initdata;
8335
8336 -static struct of_pdt_ops prom_sparc_ops __initdata = {
8337 +static struct of_pdt_ops prom_sparc_ops __initconst = {
8338 .nextprop = prom_common_nextprop,
8339 .getproplen = prom_getproplen,
8340 .getproperty = prom_getproperty,
8341 diff --git a/arch/sparc/kernel/ptrace_64.c b/arch/sparc/kernel/ptrace_64.c
8342 index 7ff45e4..a58f271 100644
8343 --- a/arch/sparc/kernel/ptrace_64.c
8344 +++ b/arch/sparc/kernel/ptrace_64.c
8345 @@ -1057,6 +1057,10 @@ long arch_ptrace(struct task_struct *child, long request,
8346 return ret;
8347 }
8348
8349 +#ifdef CONFIG_GRKERNSEC_SETXID
8350 +extern void gr_delayed_cred_worker(void);
8351 +#endif
8352 +
8353 asmlinkage int syscall_trace_enter(struct pt_regs *regs)
8354 {
8355 int ret = 0;
8356 @@ -1064,6 +1068,11 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs)
8357 /* do the secure computing check first */
8358 secure_computing_strict(regs->u_regs[UREG_G1]);
8359
8360 +#ifdef CONFIG_GRKERNSEC_SETXID
8361 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
8362 + gr_delayed_cred_worker();
8363 +#endif
8364 +
8365 if (test_thread_flag(TIF_SYSCALL_TRACE))
8366 ret = tracehook_report_syscall_entry(regs);
8367
8368 @@ -1084,6 +1093,11 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs)
8369
8370 asmlinkage void syscall_trace_leave(struct pt_regs *regs)
8371 {
8372 +#ifdef CONFIG_GRKERNSEC_SETXID
8373 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
8374 + gr_delayed_cred_worker();
8375 +#endif
8376 +
8377 audit_syscall_exit(regs);
8378
8379 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
8380 diff --git a/arch/sparc/kernel/sys_sparc_32.c b/arch/sparc/kernel/sys_sparc_32.c
8381 index 3a8d184..49498a8 100644
8382 --- a/arch/sparc/kernel/sys_sparc_32.c
8383 +++ b/arch/sparc/kernel/sys_sparc_32.c
8384 @@ -52,7 +52,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
8385 if (len > TASK_SIZE - PAGE_SIZE)
8386 return -ENOMEM;
8387 if (!addr)
8388 - addr = TASK_UNMAPPED_BASE;
8389 + addr = current->mm->mmap_base;
8390
8391 info.flags = 0;
8392 info.length = len;
8393 diff --git a/arch/sparc/kernel/sys_sparc_64.c b/arch/sparc/kernel/sys_sparc_64.c
8394 index 708bc29..6bfdfad 100644
8395 --- a/arch/sparc/kernel/sys_sparc_64.c
8396 +++ b/arch/sparc/kernel/sys_sparc_64.c
8397 @@ -90,13 +90,14 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
8398 struct vm_area_struct * vma;
8399 unsigned long task_size = TASK_SIZE;
8400 int do_color_align;
8401 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
8402 struct vm_unmapped_area_info info;
8403
8404 if (flags & MAP_FIXED) {
8405 /* We do not accept a shared mapping if it would violate
8406 * cache aliasing constraints.
8407 */
8408 - if ((flags & MAP_SHARED) &&
8409 + if ((filp || (flags & MAP_SHARED)) &&
8410 ((addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)))
8411 return -EINVAL;
8412 return addr;
8413 @@ -111,6 +112,10 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
8414 if (filp || (flags & MAP_SHARED))
8415 do_color_align = 1;
8416
8417 +#ifdef CONFIG_PAX_RANDMMAP
8418 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8419 +#endif
8420 +
8421 if (addr) {
8422 if (do_color_align)
8423 addr = COLOR_ALIGN(addr, pgoff);
8424 @@ -118,22 +123,28 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
8425 addr = PAGE_ALIGN(addr);
8426
8427 vma = find_vma(mm, addr);
8428 - if (task_size - len >= addr &&
8429 - (!vma || addr + len <= vma->vm_start))
8430 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
8431 return addr;
8432 }
8433
8434 info.flags = 0;
8435 info.length = len;
8436 - info.low_limit = TASK_UNMAPPED_BASE;
8437 + info.low_limit = mm->mmap_base;
8438 info.high_limit = min(task_size, VA_EXCLUDE_START);
8439 info.align_mask = do_color_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
8440 info.align_offset = pgoff << PAGE_SHIFT;
8441 + info.threadstack_offset = offset;
8442 addr = vm_unmapped_area(&info);
8443
8444 if ((addr & ~PAGE_MASK) && task_size > VA_EXCLUDE_END) {
8445 VM_BUG_ON(addr != -ENOMEM);
8446 info.low_limit = VA_EXCLUDE_END;
8447 +
8448 +#ifdef CONFIG_PAX_RANDMMAP
8449 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8450 + info.low_limit += mm->delta_mmap;
8451 +#endif
8452 +
8453 info.high_limit = task_size;
8454 addr = vm_unmapped_area(&info);
8455 }
8456 @@ -151,6 +162,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8457 unsigned long task_size = STACK_TOP32;
8458 unsigned long addr = addr0;
8459 int do_color_align;
8460 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
8461 struct vm_unmapped_area_info info;
8462
8463 /* This should only ever run for 32-bit processes. */
8464 @@ -160,7 +172,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8465 /* We do not accept a shared mapping if it would violate
8466 * cache aliasing constraints.
8467 */
8468 - if ((flags & MAP_SHARED) &&
8469 + if ((filp || (flags & MAP_SHARED)) &&
8470 ((addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)))
8471 return -EINVAL;
8472 return addr;
8473 @@ -173,6 +185,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8474 if (filp || (flags & MAP_SHARED))
8475 do_color_align = 1;
8476
8477 +#ifdef CONFIG_PAX_RANDMMAP
8478 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8479 +#endif
8480 +
8481 /* requesting a specific address */
8482 if (addr) {
8483 if (do_color_align)
8484 @@ -181,8 +197,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8485 addr = PAGE_ALIGN(addr);
8486
8487 vma = find_vma(mm, addr);
8488 - if (task_size - len >= addr &&
8489 - (!vma || addr + len <= vma->vm_start))
8490 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
8491 return addr;
8492 }
8493
8494 @@ -192,6 +207,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8495 info.high_limit = mm->mmap_base;
8496 info.align_mask = do_color_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
8497 info.align_offset = pgoff << PAGE_SHIFT;
8498 + info.threadstack_offset = offset;
8499 addr = vm_unmapped_area(&info);
8500
8501 /*
8502 @@ -204,6 +220,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8503 VM_BUG_ON(addr != -ENOMEM);
8504 info.flags = 0;
8505 info.low_limit = TASK_UNMAPPED_BASE;
8506 +
8507 +#ifdef CONFIG_PAX_RANDMMAP
8508 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8509 + info.low_limit += mm->delta_mmap;
8510 +#endif
8511 +
8512 info.high_limit = STACK_TOP32;
8513 addr = vm_unmapped_area(&info);
8514 }
8515 @@ -264,6 +286,10 @@ static unsigned long mmap_rnd(void)
8516 {
8517 unsigned long rnd = 0UL;
8518
8519 +#ifdef CONFIG_PAX_RANDMMAP
8520 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8521 +#endif
8522 +
8523 if (current->flags & PF_RANDOMIZE) {
8524 unsigned long val = get_random_int();
8525 if (test_thread_flag(TIF_32BIT))
8526 @@ -289,6 +315,12 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
8527 gap == RLIM_INFINITY ||
8528 sysctl_legacy_va_layout) {
8529 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
8530 +
8531 +#ifdef CONFIG_PAX_RANDMMAP
8532 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8533 + mm->mmap_base += mm->delta_mmap;
8534 +#endif
8535 +
8536 mm->get_unmapped_area = arch_get_unmapped_area;
8537 mm->unmap_area = arch_unmap_area;
8538 } else {
8539 @@ -301,6 +333,12 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
8540 gap = (task_size / 6 * 5);
8541
8542 mm->mmap_base = PAGE_ALIGN(task_size - gap - random_factor);
8543 +
8544 +#ifdef CONFIG_PAX_RANDMMAP
8545 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8546 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
8547 +#endif
8548 +
8549 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
8550 mm->unmap_area = arch_unmap_area_topdown;
8551 }
8552 diff --git a/arch/sparc/kernel/syscalls.S b/arch/sparc/kernel/syscalls.S
8553 index 22a1098..6255eb9 100644
8554 --- a/arch/sparc/kernel/syscalls.S
8555 +++ b/arch/sparc/kernel/syscalls.S
8556 @@ -52,7 +52,7 @@ sys32_rt_sigreturn:
8557 #endif
8558 .align 32
8559 1: ldx [%g6 + TI_FLAGS], %l5
8560 - andcc %l5, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
8561 + andcc %l5, _TIF_WORK_SYSCALL, %g0
8562 be,pt %icc, rtrap
8563 nop
8564 call syscall_trace_leave
8565 @@ -184,7 +184,7 @@ linux_sparc_syscall32:
8566
8567 srl %i5, 0, %o5 ! IEU1
8568 srl %i2, 0, %o2 ! IEU0 Group
8569 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
8570 + andcc %l0, _TIF_WORK_SYSCALL, %g0
8571 bne,pn %icc, linux_syscall_trace32 ! CTI
8572 mov %i0, %l5 ! IEU1
8573 call %l7 ! CTI Group brk forced
8574 @@ -207,7 +207,7 @@ linux_sparc_syscall:
8575
8576 mov %i3, %o3 ! IEU1
8577 mov %i4, %o4 ! IEU0 Group
8578 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
8579 + andcc %l0, _TIF_WORK_SYSCALL, %g0
8580 bne,pn %icc, linux_syscall_trace ! CTI Group
8581 mov %i0, %l5 ! IEU0
8582 2: call %l7 ! CTI Group brk forced
8583 @@ -223,7 +223,7 @@ ret_sys_call:
8584
8585 cmp %o0, -ERESTART_RESTARTBLOCK
8586 bgeu,pn %xcc, 1f
8587 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
8588 + andcc %l0, _TIF_WORK_SYSCALL, %g0
8589 ldx [%sp + PTREGS_OFF + PT_V9_TNPC], %l1 ! pc = npc
8590
8591 2:
8592 diff --git a/arch/sparc/kernel/sysfs.c b/arch/sparc/kernel/sysfs.c
8593 index 654e8aa..45f431b 100644
8594 --- a/arch/sparc/kernel/sysfs.c
8595 +++ b/arch/sparc/kernel/sysfs.c
8596 @@ -266,7 +266,7 @@ static int __cpuinit sysfs_cpu_notify(struct notifier_block *self,
8597 return NOTIFY_OK;
8598 }
8599
8600 -static struct notifier_block __cpuinitdata sysfs_cpu_nb = {
8601 +static struct notifier_block sysfs_cpu_nb = {
8602 .notifier_call = sysfs_cpu_notify,
8603 };
8604
8605 diff --git a/arch/sparc/kernel/traps_32.c b/arch/sparc/kernel/traps_32.c
8606 index 6629829..036032d 100644
8607 --- a/arch/sparc/kernel/traps_32.c
8608 +++ b/arch/sparc/kernel/traps_32.c
8609 @@ -44,6 +44,8 @@ static void instruction_dump(unsigned long *pc)
8610 #define __SAVE __asm__ __volatile__("save %sp, -0x40, %sp\n\t")
8611 #define __RESTORE __asm__ __volatile__("restore %g0, %g0, %g0\n\t")
8612
8613 +extern void gr_handle_kernel_exploit(void);
8614 +
8615 void die_if_kernel(char *str, struct pt_regs *regs)
8616 {
8617 static int die_counter;
8618 @@ -76,15 +78,17 @@ void die_if_kernel(char *str, struct pt_regs *regs)
8619 count++ < 30 &&
8620 (((unsigned long) rw) >= PAGE_OFFSET) &&
8621 !(((unsigned long) rw) & 0x7)) {
8622 - printk("Caller[%08lx]: %pS\n", rw->ins[7],
8623 + printk("Caller[%08lx]: %pA\n", rw->ins[7],
8624 (void *) rw->ins[7]);
8625 rw = (struct reg_window32 *)rw->ins[6];
8626 }
8627 }
8628 printk("Instruction DUMP:");
8629 instruction_dump ((unsigned long *) regs->pc);
8630 - if(regs->psr & PSR_PS)
8631 + if(regs->psr & PSR_PS) {
8632 + gr_handle_kernel_exploit();
8633 do_exit(SIGKILL);
8634 + }
8635 do_exit(SIGSEGV);
8636 }
8637
8638 diff --git a/arch/sparc/kernel/traps_64.c b/arch/sparc/kernel/traps_64.c
8639 index 8d38ca9..845b1d6 100644
8640 --- a/arch/sparc/kernel/traps_64.c
8641 +++ b/arch/sparc/kernel/traps_64.c
8642 @@ -76,7 +76,7 @@ static void dump_tl1_traplog(struct tl1_traplog *p)
8643 i + 1,
8644 p->trapstack[i].tstate, p->trapstack[i].tpc,
8645 p->trapstack[i].tnpc, p->trapstack[i].tt);
8646 - printk("TRAPLOG: TPC<%pS>\n", (void *) p->trapstack[i].tpc);
8647 + printk("TRAPLOG: TPC<%pA>\n", (void *) p->trapstack[i].tpc);
8648 }
8649 }
8650
8651 @@ -96,6 +96,12 @@ void bad_trap(struct pt_regs *regs, long lvl)
8652
8653 lvl -= 0x100;
8654 if (regs->tstate & TSTATE_PRIV) {
8655 +
8656 +#ifdef CONFIG_PAX_REFCOUNT
8657 + if (lvl == 6)
8658 + pax_report_refcount_overflow(regs);
8659 +#endif
8660 +
8661 sprintf(buffer, "Kernel bad sw trap %lx", lvl);
8662 die_if_kernel(buffer, regs);
8663 }
8664 @@ -114,11 +120,16 @@ void bad_trap(struct pt_regs *regs, long lvl)
8665 void bad_trap_tl1(struct pt_regs *regs, long lvl)
8666 {
8667 char buffer[32];
8668 -
8669 +
8670 if (notify_die(DIE_TRAP_TL1, "bad trap tl1", regs,
8671 0, lvl, SIGTRAP) == NOTIFY_STOP)
8672 return;
8673
8674 +#ifdef CONFIG_PAX_REFCOUNT
8675 + if (lvl == 6)
8676 + pax_report_refcount_overflow(regs);
8677 +#endif
8678 +
8679 dump_tl1_traplog((struct tl1_traplog *)(regs + 1));
8680
8681 sprintf (buffer, "Bad trap %lx at tl>0", lvl);
8682 @@ -1142,7 +1153,7 @@ static void cheetah_log_errors(struct pt_regs *regs, struct cheetah_err_info *in
8683 regs->tpc, regs->tnpc, regs->u_regs[UREG_I7], regs->tstate);
8684 printk("%s" "ERROR(%d): ",
8685 (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id());
8686 - printk("TPC<%pS>\n", (void *) regs->tpc);
8687 + printk("TPC<%pA>\n", (void *) regs->tpc);
8688 printk("%s" "ERROR(%d): M_SYND(%lx), E_SYND(%lx)%s%s\n",
8689 (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id(),
8690 (afsr & CHAFSR_M_SYNDROME) >> CHAFSR_M_SYNDROME_SHIFT,
8691 @@ -1749,7 +1760,7 @@ void cheetah_plus_parity_error(int type, struct pt_regs *regs)
8692 smp_processor_id(),
8693 (type & 0x1) ? 'I' : 'D',
8694 regs->tpc);
8695 - printk(KERN_EMERG "TPC<%pS>\n", (void *) regs->tpc);
8696 + printk(KERN_EMERG "TPC<%pA>\n", (void *) regs->tpc);
8697 panic("Irrecoverable Cheetah+ parity error.");
8698 }
8699
8700 @@ -1757,7 +1768,7 @@ void cheetah_plus_parity_error(int type, struct pt_regs *regs)
8701 smp_processor_id(),
8702 (type & 0x1) ? 'I' : 'D',
8703 regs->tpc);
8704 - printk(KERN_WARNING "TPC<%pS>\n", (void *) regs->tpc);
8705 + printk(KERN_WARNING "TPC<%pA>\n", (void *) regs->tpc);
8706 }
8707
8708 struct sun4v_error_entry {
8709 @@ -2104,9 +2115,9 @@ void sun4v_itlb_error_report(struct pt_regs *regs, int tl)
8710
8711 printk(KERN_EMERG "SUN4V-ITLB: Error at TPC[%lx], tl %d\n",
8712 regs->tpc, tl);
8713 - printk(KERN_EMERG "SUN4V-ITLB: TPC<%pS>\n", (void *) regs->tpc);
8714 + printk(KERN_EMERG "SUN4V-ITLB: TPC<%pA>\n", (void *) regs->tpc);
8715 printk(KERN_EMERG "SUN4V-ITLB: O7[%lx]\n", regs->u_regs[UREG_I7]);
8716 - printk(KERN_EMERG "SUN4V-ITLB: O7<%pS>\n",
8717 + printk(KERN_EMERG "SUN4V-ITLB: O7<%pA>\n",
8718 (void *) regs->u_regs[UREG_I7]);
8719 printk(KERN_EMERG "SUN4V-ITLB: vaddr[%lx] ctx[%lx] "
8720 "pte[%lx] error[%lx]\n",
8721 @@ -2128,9 +2139,9 @@ void sun4v_dtlb_error_report(struct pt_regs *regs, int tl)
8722
8723 printk(KERN_EMERG "SUN4V-DTLB: Error at TPC[%lx], tl %d\n",
8724 regs->tpc, tl);
8725 - printk(KERN_EMERG "SUN4V-DTLB: TPC<%pS>\n", (void *) regs->tpc);
8726 + printk(KERN_EMERG "SUN4V-DTLB: TPC<%pA>\n", (void *) regs->tpc);
8727 printk(KERN_EMERG "SUN4V-DTLB: O7[%lx]\n", regs->u_regs[UREG_I7]);
8728 - printk(KERN_EMERG "SUN4V-DTLB: O7<%pS>\n",
8729 + printk(KERN_EMERG "SUN4V-DTLB: O7<%pA>\n",
8730 (void *) regs->u_regs[UREG_I7]);
8731 printk(KERN_EMERG "SUN4V-DTLB: vaddr[%lx] ctx[%lx] "
8732 "pte[%lx] error[%lx]\n",
8733 @@ -2336,13 +2347,13 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp)
8734 fp = (unsigned long)sf->fp + STACK_BIAS;
8735 }
8736
8737 - printk(" [%016lx] %pS\n", pc, (void *) pc);
8738 + printk(" [%016lx] %pA\n", pc, (void *) pc);
8739 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
8740 if ((pc + 8UL) == (unsigned long) &return_to_handler) {
8741 int index = tsk->curr_ret_stack;
8742 if (tsk->ret_stack && index >= graph) {
8743 pc = tsk->ret_stack[index - graph].ret;
8744 - printk(" [%016lx] %pS\n", pc, (void *) pc);
8745 + printk(" [%016lx] %pA\n", pc, (void *) pc);
8746 graph++;
8747 }
8748 }
8749 @@ -2367,6 +2378,8 @@ static inline struct reg_window *kernel_stack_up(struct reg_window *rw)
8750 return (struct reg_window *) (fp + STACK_BIAS);
8751 }
8752
8753 +extern void gr_handle_kernel_exploit(void);
8754 +
8755 void die_if_kernel(char *str, struct pt_regs *regs)
8756 {
8757 static int die_counter;
8758 @@ -2395,7 +2408,7 @@ void die_if_kernel(char *str, struct pt_regs *regs)
8759 while (rw &&
8760 count++ < 30 &&
8761 kstack_valid(tp, (unsigned long) rw)) {
8762 - printk("Caller[%016lx]: %pS\n", rw->ins[7],
8763 + printk("Caller[%016lx]: %pA\n", rw->ins[7],
8764 (void *) rw->ins[7]);
8765
8766 rw = kernel_stack_up(rw);
8767 @@ -2408,8 +2421,10 @@ void die_if_kernel(char *str, struct pt_regs *regs)
8768 }
8769 user_instruction_dump ((unsigned int __user *) regs->tpc);
8770 }
8771 - if (regs->tstate & TSTATE_PRIV)
8772 + if (regs->tstate & TSTATE_PRIV) {
8773 + gr_handle_kernel_exploit();
8774 do_exit(SIGKILL);
8775 + }
8776 do_exit(SIGSEGV);
8777 }
8778 EXPORT_SYMBOL(die_if_kernel);
8779 diff --git a/arch/sparc/kernel/unaligned_64.c b/arch/sparc/kernel/unaligned_64.c
8780 index 8201c25e..072a2a7 100644
8781 --- a/arch/sparc/kernel/unaligned_64.c
8782 +++ b/arch/sparc/kernel/unaligned_64.c
8783 @@ -286,7 +286,7 @@ static void log_unaligned(struct pt_regs *regs)
8784 static DEFINE_RATELIMIT_STATE(ratelimit, 5 * HZ, 5);
8785
8786 if (__ratelimit(&ratelimit)) {
8787 - printk("Kernel unaligned access at TPC[%lx] %pS\n",
8788 + printk("Kernel unaligned access at TPC[%lx] %pA\n",
8789 regs->tpc, (void *) regs->tpc);
8790 }
8791 }
8792 diff --git a/arch/sparc/kernel/us3_cpufreq.c b/arch/sparc/kernel/us3_cpufreq.c
8793 index eb1624b..55100de 100644
8794 --- a/arch/sparc/kernel/us3_cpufreq.c
8795 +++ b/arch/sparc/kernel/us3_cpufreq.c
8796 @@ -18,14 +18,12 @@
8797 #include <asm/head.h>
8798 #include <asm/timer.h>
8799
8800 -static struct cpufreq_driver *cpufreq_us3_driver;
8801 -
8802 struct us3_freq_percpu_info {
8803 struct cpufreq_frequency_table table[4];
8804 };
8805
8806 /* Indexed by cpu number. */
8807 -static struct us3_freq_percpu_info *us3_freq_table;
8808 +static struct us3_freq_percpu_info us3_freq_table[NR_CPUS];
8809
8810 /* UltraSPARC-III has three dividers: 1, 2, and 32. These are controlled
8811 * in the Safari config register.
8812 @@ -191,12 +189,25 @@ static int __init us3_freq_cpu_init(struct cpufreq_policy *policy)
8813
8814 static int us3_freq_cpu_exit(struct cpufreq_policy *policy)
8815 {
8816 - if (cpufreq_us3_driver)
8817 - us3_set_cpu_divider_index(policy->cpu, 0);
8818 + us3_set_cpu_divider_index(policy->cpu, 0);
8819
8820 return 0;
8821 }
8822
8823 +static int __init us3_freq_init(void);
8824 +static void __exit us3_freq_exit(void);
8825 +
8826 +static struct cpufreq_driver cpufreq_us3_driver = {
8827 + .init = us3_freq_cpu_init,
8828 + .verify = us3_freq_verify,
8829 + .target = us3_freq_target,
8830 + .get = us3_freq_get,
8831 + .exit = us3_freq_cpu_exit,
8832 + .owner = THIS_MODULE,
8833 + .name = "UltraSPARC-III",
8834 +
8835 +};
8836 +
8837 static int __init us3_freq_init(void)
8838 {
8839 unsigned long manuf, impl, ver;
8840 @@ -213,57 +224,15 @@ static int __init us3_freq_init(void)
8841 (impl == CHEETAH_IMPL ||
8842 impl == CHEETAH_PLUS_IMPL ||
8843 impl == JAGUAR_IMPL ||
8844 - impl == PANTHER_IMPL)) {
8845 - struct cpufreq_driver *driver;
8846 -
8847 - ret = -ENOMEM;
8848 - driver = kzalloc(sizeof(struct cpufreq_driver), GFP_KERNEL);
8849 - if (!driver)
8850 - goto err_out;
8851 -
8852 - us3_freq_table = kzalloc(
8853 - (NR_CPUS * sizeof(struct us3_freq_percpu_info)),
8854 - GFP_KERNEL);
8855 - if (!us3_freq_table)
8856 - goto err_out;
8857 -
8858 - driver->init = us3_freq_cpu_init;
8859 - driver->verify = us3_freq_verify;
8860 - driver->target = us3_freq_target;
8861 - driver->get = us3_freq_get;
8862 - driver->exit = us3_freq_cpu_exit;
8863 - driver->owner = THIS_MODULE,
8864 - strcpy(driver->name, "UltraSPARC-III");
8865 -
8866 - cpufreq_us3_driver = driver;
8867 - ret = cpufreq_register_driver(driver);
8868 - if (ret)
8869 - goto err_out;
8870 -
8871 - return 0;
8872 -
8873 -err_out:
8874 - if (driver) {
8875 - kfree(driver);
8876 - cpufreq_us3_driver = NULL;
8877 - }
8878 - kfree(us3_freq_table);
8879 - us3_freq_table = NULL;
8880 - return ret;
8881 - }
8882 + impl == PANTHER_IMPL))
8883 + return cpufreq_register_driver(&cpufreq_us3_driver);
8884
8885 return -ENODEV;
8886 }
8887
8888 static void __exit us3_freq_exit(void)
8889 {
8890 - if (cpufreq_us3_driver) {
8891 - cpufreq_unregister_driver(cpufreq_us3_driver);
8892 - kfree(cpufreq_us3_driver);
8893 - cpufreq_us3_driver = NULL;
8894 - kfree(us3_freq_table);
8895 - us3_freq_table = NULL;
8896 - }
8897 + cpufreq_unregister_driver(&cpufreq_us3_driver);
8898 }
8899
8900 MODULE_AUTHOR("David S. Miller <davem@redhat.com>");
8901 diff --git a/arch/sparc/lib/Makefile b/arch/sparc/lib/Makefile
8902 index 8410065f2..4fd4ca22 100644
8903 --- a/arch/sparc/lib/Makefile
8904 +++ b/arch/sparc/lib/Makefile
8905 @@ -2,7 +2,7 @@
8906 #
8907
8908 asflags-y := -ansi -DST_DIV0=0x02
8909 -ccflags-y := -Werror
8910 +#ccflags-y := -Werror
8911
8912 lib-$(CONFIG_SPARC32) += ashrdi3.o
8913 lib-$(CONFIG_SPARC32) += memcpy.o memset.o
8914 diff --git a/arch/sparc/lib/atomic_64.S b/arch/sparc/lib/atomic_64.S
8915 index 85c233d..68500e0 100644
8916 --- a/arch/sparc/lib/atomic_64.S
8917 +++ b/arch/sparc/lib/atomic_64.S
8918 @@ -17,7 +17,12 @@
8919 ENTRY(atomic_add) /* %o0 = increment, %o1 = atomic_ptr */
8920 BACKOFF_SETUP(%o2)
8921 1: lduw [%o1], %g1
8922 - add %g1, %o0, %g7
8923 + addcc %g1, %o0, %g7
8924 +
8925 +#ifdef CONFIG_PAX_REFCOUNT
8926 + tvs %icc, 6
8927 +#endif
8928 +
8929 cas [%o1], %g1, %g7
8930 cmp %g1, %g7
8931 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
8932 @@ -27,10 +32,28 @@ ENTRY(atomic_add) /* %o0 = increment, %o1 = atomic_ptr */
8933 2: BACKOFF_SPIN(%o2, %o3, 1b)
8934 ENDPROC(atomic_add)
8935
8936 +ENTRY(atomic_add_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
8937 + BACKOFF_SETUP(%o2)
8938 +1: lduw [%o1], %g1
8939 + add %g1, %o0, %g7
8940 + cas [%o1], %g1, %g7
8941 + cmp %g1, %g7
8942 + bne,pn %icc, 2f
8943 + nop
8944 + retl
8945 + nop
8946 +2: BACKOFF_SPIN(%o2, %o3, 1b)
8947 +ENDPROC(atomic_add_unchecked)
8948 +
8949 ENTRY(atomic_sub) /* %o0 = decrement, %o1 = atomic_ptr */
8950 BACKOFF_SETUP(%o2)
8951 1: lduw [%o1], %g1
8952 - sub %g1, %o0, %g7
8953 + subcc %g1, %o0, %g7
8954 +
8955 +#ifdef CONFIG_PAX_REFCOUNT
8956 + tvs %icc, 6
8957 +#endif
8958 +
8959 cas [%o1], %g1, %g7
8960 cmp %g1, %g7
8961 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
8962 @@ -40,10 +63,28 @@ ENTRY(atomic_sub) /* %o0 = decrement, %o1 = atomic_ptr */
8963 2: BACKOFF_SPIN(%o2, %o3, 1b)
8964 ENDPROC(atomic_sub)
8965
8966 +ENTRY(atomic_sub_unchecked) /* %o0 = decrement, %o1 = atomic_ptr */
8967 + BACKOFF_SETUP(%o2)
8968 +1: lduw [%o1], %g1
8969 + sub %g1, %o0, %g7
8970 + cas [%o1], %g1, %g7
8971 + cmp %g1, %g7
8972 + bne,pn %icc, 2f
8973 + nop
8974 + retl
8975 + nop
8976 +2: BACKOFF_SPIN(%o2, %o3, 1b)
8977 +ENDPROC(atomic_sub_unchecked)
8978 +
8979 ENTRY(atomic_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
8980 BACKOFF_SETUP(%o2)
8981 1: lduw [%o1], %g1
8982 - add %g1, %o0, %g7
8983 + addcc %g1, %o0, %g7
8984 +
8985 +#ifdef CONFIG_PAX_REFCOUNT
8986 + tvs %icc, 6
8987 +#endif
8988 +
8989 cas [%o1], %g1, %g7
8990 cmp %g1, %g7
8991 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
8992 @@ -53,10 +94,29 @@ ENTRY(atomic_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
8993 2: BACKOFF_SPIN(%o2, %o3, 1b)
8994 ENDPROC(atomic_add_ret)
8995
8996 +ENTRY(atomic_add_ret_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
8997 + BACKOFF_SETUP(%o2)
8998 +1: lduw [%o1], %g1
8999 + addcc %g1, %o0, %g7
9000 + cas [%o1], %g1, %g7
9001 + cmp %g1, %g7
9002 + bne,pn %icc, 2f
9003 + add %g7, %o0, %g7
9004 + sra %g7, 0, %o0
9005 + retl
9006 + nop
9007 +2: BACKOFF_SPIN(%o2, %o3, 1b)
9008 +ENDPROC(atomic_add_ret_unchecked)
9009 +
9010 ENTRY(atomic_sub_ret) /* %o0 = decrement, %o1 = atomic_ptr */
9011 BACKOFF_SETUP(%o2)
9012 1: lduw [%o1], %g1
9013 - sub %g1, %o0, %g7
9014 + subcc %g1, %o0, %g7
9015 +
9016 +#ifdef CONFIG_PAX_REFCOUNT
9017 + tvs %icc, 6
9018 +#endif
9019 +
9020 cas [%o1], %g1, %g7
9021 cmp %g1, %g7
9022 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
9023 @@ -69,7 +129,12 @@ ENDPROC(atomic_sub_ret)
9024 ENTRY(atomic64_add) /* %o0 = increment, %o1 = atomic_ptr */
9025 BACKOFF_SETUP(%o2)
9026 1: ldx [%o1], %g1
9027 - add %g1, %o0, %g7
9028 + addcc %g1, %o0, %g7
9029 +
9030 +#ifdef CONFIG_PAX_REFCOUNT
9031 + tvs %xcc, 6
9032 +#endif
9033 +
9034 casx [%o1], %g1, %g7
9035 cmp %g1, %g7
9036 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
9037 @@ -79,10 +144,28 @@ ENTRY(atomic64_add) /* %o0 = increment, %o1 = atomic_ptr */
9038 2: BACKOFF_SPIN(%o2, %o3, 1b)
9039 ENDPROC(atomic64_add)
9040
9041 +ENTRY(atomic64_add_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
9042 + BACKOFF_SETUP(%o2)
9043 +1: ldx [%o1], %g1
9044 + addcc %g1, %o0, %g7
9045 + casx [%o1], %g1, %g7
9046 + cmp %g1, %g7
9047 + bne,pn %xcc, 2f
9048 + nop
9049 + retl
9050 + nop
9051 +2: BACKOFF_SPIN(%o2, %o3, 1b)
9052 +ENDPROC(atomic64_add_unchecked)
9053 +
9054 ENTRY(atomic64_sub) /* %o0 = decrement, %o1 = atomic_ptr */
9055 BACKOFF_SETUP(%o2)
9056 1: ldx [%o1], %g1
9057 - sub %g1, %o0, %g7
9058 + subcc %g1, %o0, %g7
9059 +
9060 +#ifdef CONFIG_PAX_REFCOUNT
9061 + tvs %xcc, 6
9062 +#endif
9063 +
9064 casx [%o1], %g1, %g7
9065 cmp %g1, %g7
9066 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
9067 @@ -92,10 +175,28 @@ ENTRY(atomic64_sub) /* %o0 = decrement, %o1 = atomic_ptr */
9068 2: BACKOFF_SPIN(%o2, %o3, 1b)
9069 ENDPROC(atomic64_sub)
9070
9071 +ENTRY(atomic64_sub_unchecked) /* %o0 = decrement, %o1 = atomic_ptr */
9072 + BACKOFF_SETUP(%o2)
9073 +1: ldx [%o1], %g1
9074 + subcc %g1, %o0, %g7
9075 + casx [%o1], %g1, %g7
9076 + cmp %g1, %g7
9077 + bne,pn %xcc, 2f
9078 + nop
9079 + retl
9080 + nop
9081 +2: BACKOFF_SPIN(%o2, %o3, 1b)
9082 +ENDPROC(atomic64_sub_unchecked)
9083 +
9084 ENTRY(atomic64_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
9085 BACKOFF_SETUP(%o2)
9086 1: ldx [%o1], %g1
9087 - add %g1, %o0, %g7
9088 + addcc %g1, %o0, %g7
9089 +
9090 +#ifdef CONFIG_PAX_REFCOUNT
9091 + tvs %xcc, 6
9092 +#endif
9093 +
9094 casx [%o1], %g1, %g7
9095 cmp %g1, %g7
9096 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
9097 @@ -105,10 +206,29 @@ ENTRY(atomic64_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
9098 2: BACKOFF_SPIN(%o2, %o3, 1b)
9099 ENDPROC(atomic64_add_ret)
9100
9101 +ENTRY(atomic64_add_ret_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
9102 + BACKOFF_SETUP(%o2)
9103 +1: ldx [%o1], %g1
9104 + addcc %g1, %o0, %g7
9105 + casx [%o1], %g1, %g7
9106 + cmp %g1, %g7
9107 + bne,pn %xcc, 2f
9108 + add %g7, %o0, %g7
9109 + mov %g7, %o0
9110 + retl
9111 + nop
9112 +2: BACKOFF_SPIN(%o2, %o3, 1b)
9113 +ENDPROC(atomic64_add_ret_unchecked)
9114 +
9115 ENTRY(atomic64_sub_ret) /* %o0 = decrement, %o1 = atomic_ptr */
9116 BACKOFF_SETUP(%o2)
9117 1: ldx [%o1], %g1
9118 - sub %g1, %o0, %g7
9119 + subcc %g1, %o0, %g7
9120 +
9121 +#ifdef CONFIG_PAX_REFCOUNT
9122 + tvs %xcc, 6
9123 +#endif
9124 +
9125 casx [%o1], %g1, %g7
9126 cmp %g1, %g7
9127 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
9128 diff --git a/arch/sparc/lib/ksyms.c b/arch/sparc/lib/ksyms.c
9129 index 0c4e35e..745d3e4 100644
9130 --- a/arch/sparc/lib/ksyms.c
9131 +++ b/arch/sparc/lib/ksyms.c
9132 @@ -109,12 +109,18 @@ EXPORT_SYMBOL(__downgrade_write);
9133
9134 /* Atomic counter implementation. */
9135 EXPORT_SYMBOL(atomic_add);
9136 +EXPORT_SYMBOL(atomic_add_unchecked);
9137 EXPORT_SYMBOL(atomic_add_ret);
9138 +EXPORT_SYMBOL(atomic_add_ret_unchecked);
9139 EXPORT_SYMBOL(atomic_sub);
9140 +EXPORT_SYMBOL(atomic_sub_unchecked);
9141 EXPORT_SYMBOL(atomic_sub_ret);
9142 EXPORT_SYMBOL(atomic64_add);
9143 +EXPORT_SYMBOL(atomic64_add_unchecked);
9144 EXPORT_SYMBOL(atomic64_add_ret);
9145 +EXPORT_SYMBOL(atomic64_add_ret_unchecked);
9146 EXPORT_SYMBOL(atomic64_sub);
9147 +EXPORT_SYMBOL(atomic64_sub_unchecked);
9148 EXPORT_SYMBOL(atomic64_sub_ret);
9149 EXPORT_SYMBOL(atomic64_dec_if_positive);
9150
9151 diff --git a/arch/sparc/mm/Makefile b/arch/sparc/mm/Makefile
9152 index 30c3ecc..736f015 100644
9153 --- a/arch/sparc/mm/Makefile
9154 +++ b/arch/sparc/mm/Makefile
9155 @@ -2,7 +2,7 @@
9156 #
9157
9158 asflags-y := -ansi
9159 -ccflags-y := -Werror
9160 +#ccflags-y := -Werror
9161
9162 obj-$(CONFIG_SPARC64) += ultra.o tlb.o tsb.o gup.o
9163 obj-y += fault_$(BITS).o
9164 diff --git a/arch/sparc/mm/fault_32.c b/arch/sparc/mm/fault_32.c
9165 index e98bfda..ea8d221 100644
9166 --- a/arch/sparc/mm/fault_32.c
9167 +++ b/arch/sparc/mm/fault_32.c
9168 @@ -21,6 +21,9 @@
9169 #include <linux/perf_event.h>
9170 #include <linux/interrupt.h>
9171 #include <linux/kdebug.h>
9172 +#include <linux/slab.h>
9173 +#include <linux/pagemap.h>
9174 +#include <linux/compiler.h>
9175
9176 #include <asm/page.h>
9177 #include <asm/pgtable.h>
9178 @@ -159,6 +162,277 @@ static unsigned long compute_si_addr(struct pt_regs *regs, int text_fault)
9179 return safe_compute_effective_address(regs, insn);
9180 }
9181
9182 +#ifdef CONFIG_PAX_PAGEEXEC
9183 +#ifdef CONFIG_PAX_DLRESOLVE
9184 +static void pax_emuplt_close(struct vm_area_struct *vma)
9185 +{
9186 + vma->vm_mm->call_dl_resolve = 0UL;
9187 +}
9188 +
9189 +static int pax_emuplt_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
9190 +{
9191 + unsigned int *kaddr;
9192 +
9193 + vmf->page = alloc_page(GFP_HIGHUSER);
9194 + if (!vmf->page)
9195 + return VM_FAULT_OOM;
9196 +
9197 + kaddr = kmap(vmf->page);
9198 + memset(kaddr, 0, PAGE_SIZE);
9199 + kaddr[0] = 0x9DE3BFA8U; /* save */
9200 + flush_dcache_page(vmf->page);
9201 + kunmap(vmf->page);
9202 + return VM_FAULT_MAJOR;
9203 +}
9204 +
9205 +static const struct vm_operations_struct pax_vm_ops = {
9206 + .close = pax_emuplt_close,
9207 + .fault = pax_emuplt_fault
9208 +};
9209 +
9210 +static int pax_insert_vma(struct vm_area_struct *vma, unsigned long addr)
9211 +{
9212 + int ret;
9213 +
9214 + INIT_LIST_HEAD(&vma->anon_vma_chain);
9215 + vma->vm_mm = current->mm;
9216 + vma->vm_start = addr;
9217 + vma->vm_end = addr + PAGE_SIZE;
9218 + vma->vm_flags = VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYEXEC;
9219 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
9220 + vma->vm_ops = &pax_vm_ops;
9221 +
9222 + ret = insert_vm_struct(current->mm, vma);
9223 + if (ret)
9224 + return ret;
9225 +
9226 + ++current->mm->total_vm;
9227 + return 0;
9228 +}
9229 +#endif
9230 +
9231 +/*
9232 + * PaX: decide what to do with offenders (regs->pc = fault address)
9233 + *
9234 + * returns 1 when task should be killed
9235 + * 2 when patched PLT trampoline was detected
9236 + * 3 when unpatched PLT trampoline was detected
9237 + */
9238 +static int pax_handle_fetch_fault(struct pt_regs *regs)
9239 +{
9240 +
9241 +#ifdef CONFIG_PAX_EMUPLT
9242 + int err;
9243 +
9244 + do { /* PaX: patched PLT emulation #1 */
9245 + unsigned int sethi1, sethi2, jmpl;
9246 +
9247 + err = get_user(sethi1, (unsigned int *)regs->pc);
9248 + err |= get_user(sethi2, (unsigned int *)(regs->pc+4));
9249 + err |= get_user(jmpl, (unsigned int *)(regs->pc+8));
9250 +
9251 + if (err)
9252 + break;
9253 +
9254 + if ((sethi1 & 0xFFC00000U) == 0x03000000U &&
9255 + (sethi2 & 0xFFC00000U) == 0x03000000U &&
9256 + (jmpl & 0xFFFFE000U) == 0x81C06000U)
9257 + {
9258 + unsigned int addr;
9259 +
9260 + regs->u_regs[UREG_G1] = (sethi2 & 0x003FFFFFU) << 10;
9261 + addr = regs->u_regs[UREG_G1];
9262 + addr += (((jmpl | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
9263 + regs->pc = addr;
9264 + regs->npc = addr+4;
9265 + return 2;
9266 + }
9267 + } while (0);
9268 +
9269 + do { /* PaX: patched PLT emulation #2 */
9270 + unsigned int ba;
9271 +
9272 + err = get_user(ba, (unsigned int *)regs->pc);
9273 +
9274 + if (err)
9275 + break;
9276 +
9277 + if ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30480000U) {
9278 + unsigned int addr;
9279 +
9280 + if ((ba & 0xFFC00000U) == 0x30800000U)
9281 + addr = regs->pc + ((((ba | 0xFFC00000U) ^ 0x00200000U) + 0x00200000U) << 2);
9282 + else
9283 + addr = regs->pc + ((((ba | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
9284 + regs->pc = addr;
9285 + regs->npc = addr+4;
9286 + return 2;
9287 + }
9288 + } while (0);
9289 +
9290 + do { /* PaX: patched PLT emulation #3 */
9291 + unsigned int sethi, bajmpl, nop;
9292 +
9293 + err = get_user(sethi, (unsigned int *)regs->pc);
9294 + err |= get_user(bajmpl, (unsigned int *)(regs->pc+4));
9295 + err |= get_user(nop, (unsigned int *)(regs->pc+8));
9296 +
9297 + if (err)
9298 + break;
9299 +
9300 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9301 + ((bajmpl & 0xFFFFE000U) == 0x81C06000U || (bajmpl & 0xFFF80000U) == 0x30480000U) &&
9302 + nop == 0x01000000U)
9303 + {
9304 + unsigned int addr;
9305 +
9306 + addr = (sethi & 0x003FFFFFU) << 10;
9307 + regs->u_regs[UREG_G1] = addr;
9308 + if ((bajmpl & 0xFFFFE000U) == 0x81C06000U)
9309 + addr += (((bajmpl | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
9310 + else
9311 + addr = regs->pc + ((((bajmpl | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
9312 + regs->pc = addr;
9313 + regs->npc = addr+4;
9314 + return 2;
9315 + }
9316 + } while (0);
9317 +
9318 + do { /* PaX: unpatched PLT emulation step 1 */
9319 + unsigned int sethi, ba, nop;
9320 +
9321 + err = get_user(sethi, (unsigned int *)regs->pc);
9322 + err |= get_user(ba, (unsigned int *)(regs->pc+4));
9323 + err |= get_user(nop, (unsigned int *)(regs->pc+8));
9324 +
9325 + if (err)
9326 + break;
9327 +
9328 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9329 + ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30680000U) &&
9330 + nop == 0x01000000U)
9331 + {
9332 + unsigned int addr, save, call;
9333 +
9334 + if ((ba & 0xFFC00000U) == 0x30800000U)
9335 + addr = regs->pc + 4 + ((((ba | 0xFFC00000U) ^ 0x00200000U) + 0x00200000U) << 2);
9336 + else
9337 + addr = regs->pc + 4 + ((((ba | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
9338 +
9339 + err = get_user(save, (unsigned int *)addr);
9340 + err |= get_user(call, (unsigned int *)(addr+4));
9341 + err |= get_user(nop, (unsigned int *)(addr+8));
9342 + if (err)
9343 + break;
9344 +
9345 +#ifdef CONFIG_PAX_DLRESOLVE
9346 + if (save == 0x9DE3BFA8U &&
9347 + (call & 0xC0000000U) == 0x40000000U &&
9348 + nop == 0x01000000U)
9349 + {
9350 + struct vm_area_struct *vma;
9351 + unsigned long call_dl_resolve;
9352 +
9353 + down_read(&current->mm->mmap_sem);
9354 + call_dl_resolve = current->mm->call_dl_resolve;
9355 + up_read(&current->mm->mmap_sem);
9356 + if (likely(call_dl_resolve))
9357 + goto emulate;
9358 +
9359 + vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
9360 +
9361 + down_write(&current->mm->mmap_sem);
9362 + if (current->mm->call_dl_resolve) {
9363 + call_dl_resolve = current->mm->call_dl_resolve;
9364 + up_write(&current->mm->mmap_sem);
9365 + if (vma)
9366 + kmem_cache_free(vm_area_cachep, vma);
9367 + goto emulate;
9368 + }
9369 +
9370 + call_dl_resolve = get_unmapped_area(NULL, 0UL, PAGE_SIZE, 0UL, MAP_PRIVATE);
9371 + if (!vma || (call_dl_resolve & ~PAGE_MASK)) {
9372 + up_write(&current->mm->mmap_sem);
9373 + if (vma)
9374 + kmem_cache_free(vm_area_cachep, vma);
9375 + return 1;
9376 + }
9377 +
9378 + if (pax_insert_vma(vma, call_dl_resolve)) {
9379 + up_write(&current->mm->mmap_sem);
9380 + kmem_cache_free(vm_area_cachep, vma);
9381 + return 1;
9382 + }
9383 +
9384 + current->mm->call_dl_resolve = call_dl_resolve;
9385 + up_write(&current->mm->mmap_sem);
9386 +
9387 +emulate:
9388 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
9389 + regs->pc = call_dl_resolve;
9390 + regs->npc = addr+4;
9391 + return 3;
9392 + }
9393 +#endif
9394 +
9395 + /* PaX: glibc 2.4+ generates sethi/jmpl instead of save/call */
9396 + if ((save & 0xFFC00000U) == 0x05000000U &&
9397 + (call & 0xFFFFE000U) == 0x85C0A000U &&
9398 + nop == 0x01000000U)
9399 + {
9400 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
9401 + regs->u_regs[UREG_G2] = addr + 4;
9402 + addr = (save & 0x003FFFFFU) << 10;
9403 + addr += (((call | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
9404 + regs->pc = addr;
9405 + regs->npc = addr+4;
9406 + return 3;
9407 + }
9408 + }
9409 + } while (0);
9410 +
9411 + do { /* PaX: unpatched PLT emulation step 2 */
9412 + unsigned int save, call, nop;
9413 +
9414 + err = get_user(save, (unsigned int *)(regs->pc-4));
9415 + err |= get_user(call, (unsigned int *)regs->pc);
9416 + err |= get_user(nop, (unsigned int *)(regs->pc+4));
9417 + if (err)
9418 + break;
9419 +
9420 + if (save == 0x9DE3BFA8U &&
9421 + (call & 0xC0000000U) == 0x40000000U &&
9422 + nop == 0x01000000U)
9423 + {
9424 + unsigned int dl_resolve = regs->pc + ((((call | 0xC0000000U) ^ 0x20000000U) + 0x20000000U) << 2);
9425 +
9426 + regs->u_regs[UREG_RETPC] = regs->pc;
9427 + regs->pc = dl_resolve;
9428 + regs->npc = dl_resolve+4;
9429 + return 3;
9430 + }
9431 + } while (0);
9432 +#endif
9433 +
9434 + return 1;
9435 +}
9436 +
9437 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
9438 +{
9439 + unsigned long i;
9440 +
9441 + printk(KERN_ERR "PAX: bytes at PC: ");
9442 + for (i = 0; i < 8; i++) {
9443 + unsigned int c;
9444 + if (get_user(c, (unsigned int *)pc+i))
9445 + printk(KERN_CONT "???????? ");
9446 + else
9447 + printk(KERN_CONT "%08x ", c);
9448 + }
9449 + printk("\n");
9450 +}
9451 +#endif
9452 +
9453 static noinline void do_fault_siginfo(int code, int sig, struct pt_regs *regs,
9454 int text_fault)
9455 {
9456 @@ -230,6 +504,24 @@ good_area:
9457 if (!(vma->vm_flags & VM_WRITE))
9458 goto bad_area;
9459 } else {
9460 +
9461 +#ifdef CONFIG_PAX_PAGEEXEC
9462 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && text_fault && !(vma->vm_flags & VM_EXEC)) {
9463 + up_read(&mm->mmap_sem);
9464 + switch (pax_handle_fetch_fault(regs)) {
9465 +
9466 +#ifdef CONFIG_PAX_EMUPLT
9467 + case 2:
9468 + case 3:
9469 + return;
9470 +#endif
9471 +
9472 + }
9473 + pax_report_fault(regs, (void *)regs->pc, (void *)regs->u_regs[UREG_FP]);
9474 + do_group_exit(SIGKILL);
9475 + }
9476 +#endif
9477 +
9478 /* Allow reads even for write-only mappings */
9479 if (!(vma->vm_flags & (VM_READ | VM_EXEC)))
9480 goto bad_area;
9481 diff --git a/arch/sparc/mm/fault_64.c b/arch/sparc/mm/fault_64.c
9482 index 5062ff3..e0b75f3 100644
9483 --- a/arch/sparc/mm/fault_64.c
9484 +++ b/arch/sparc/mm/fault_64.c
9485 @@ -21,6 +21,9 @@
9486 #include <linux/kprobes.h>
9487 #include <linux/kdebug.h>
9488 #include <linux/percpu.h>
9489 +#include <linux/slab.h>
9490 +#include <linux/pagemap.h>
9491 +#include <linux/compiler.h>
9492
9493 #include <asm/page.h>
9494 #include <asm/pgtable.h>
9495 @@ -74,7 +77,7 @@ static void __kprobes bad_kernel_pc(struct pt_regs *regs, unsigned long vaddr)
9496 printk(KERN_CRIT "OOPS: Bogus kernel PC [%016lx] in fault handler\n",
9497 regs->tpc);
9498 printk(KERN_CRIT "OOPS: RPC [%016lx]\n", regs->u_regs[15]);
9499 - printk("OOPS: RPC <%pS>\n", (void *) regs->u_regs[15]);
9500 + printk("OOPS: RPC <%pA>\n", (void *) regs->u_regs[15]);
9501 printk(KERN_CRIT "OOPS: Fault was to vaddr[%lx]\n", vaddr);
9502 dump_stack();
9503 unhandled_fault(regs->tpc, current, regs);
9504 @@ -270,6 +273,466 @@ static void noinline __kprobes bogus_32bit_fault_address(struct pt_regs *regs,
9505 show_regs(regs);
9506 }
9507
9508 +#ifdef CONFIG_PAX_PAGEEXEC
9509 +#ifdef CONFIG_PAX_DLRESOLVE
9510 +static void pax_emuplt_close(struct vm_area_struct *vma)
9511 +{
9512 + vma->vm_mm->call_dl_resolve = 0UL;
9513 +}
9514 +
9515 +static int pax_emuplt_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
9516 +{
9517 + unsigned int *kaddr;
9518 +
9519 + vmf->page = alloc_page(GFP_HIGHUSER);
9520 + if (!vmf->page)
9521 + return VM_FAULT_OOM;
9522 +
9523 + kaddr = kmap(vmf->page);
9524 + memset(kaddr, 0, PAGE_SIZE);
9525 + kaddr[0] = 0x9DE3BFA8U; /* save */
9526 + flush_dcache_page(vmf->page);
9527 + kunmap(vmf->page);
9528 + return VM_FAULT_MAJOR;
9529 +}
9530 +
9531 +static const struct vm_operations_struct pax_vm_ops = {
9532 + .close = pax_emuplt_close,
9533 + .fault = pax_emuplt_fault
9534 +};
9535 +
9536 +static int pax_insert_vma(struct vm_area_struct *vma, unsigned long addr)
9537 +{
9538 + int ret;
9539 +
9540 + INIT_LIST_HEAD(&vma->anon_vma_chain);
9541 + vma->vm_mm = current->mm;
9542 + vma->vm_start = addr;
9543 + vma->vm_end = addr + PAGE_SIZE;
9544 + vma->vm_flags = VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYEXEC;
9545 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
9546 + vma->vm_ops = &pax_vm_ops;
9547 +
9548 + ret = insert_vm_struct(current->mm, vma);
9549 + if (ret)
9550 + return ret;
9551 +
9552 + ++current->mm->total_vm;
9553 + return 0;
9554 +}
9555 +#endif
9556 +
9557 +/*
9558 + * PaX: decide what to do with offenders (regs->tpc = fault address)
9559 + *
9560 + * returns 1 when task should be killed
9561 + * 2 when patched PLT trampoline was detected
9562 + * 3 when unpatched PLT trampoline was detected
9563 + */
9564 +static int pax_handle_fetch_fault(struct pt_regs *regs)
9565 +{
9566 +
9567 +#ifdef CONFIG_PAX_EMUPLT
9568 + int err;
9569 +
9570 + do { /* PaX: patched PLT emulation #1 */
9571 + unsigned int sethi1, sethi2, jmpl;
9572 +
9573 + err = get_user(sethi1, (unsigned int *)regs->tpc);
9574 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+4));
9575 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+8));
9576 +
9577 + if (err)
9578 + break;
9579 +
9580 + if ((sethi1 & 0xFFC00000U) == 0x03000000U &&
9581 + (sethi2 & 0xFFC00000U) == 0x03000000U &&
9582 + (jmpl & 0xFFFFE000U) == 0x81C06000U)
9583 + {
9584 + unsigned long addr;
9585 +
9586 + regs->u_regs[UREG_G1] = (sethi2 & 0x003FFFFFU) << 10;
9587 + addr = regs->u_regs[UREG_G1];
9588 + addr += (((jmpl | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
9589 +
9590 + if (test_thread_flag(TIF_32BIT))
9591 + addr &= 0xFFFFFFFFUL;
9592 +
9593 + regs->tpc = addr;
9594 + regs->tnpc = addr+4;
9595 + return 2;
9596 + }
9597 + } while (0);
9598 +
9599 + do { /* PaX: patched PLT emulation #2 */
9600 + unsigned int ba;
9601 +
9602 + err = get_user(ba, (unsigned int *)regs->tpc);
9603 +
9604 + if (err)
9605 + break;
9606 +
9607 + if ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30480000U) {
9608 + unsigned long addr;
9609 +
9610 + if ((ba & 0xFFC00000U) == 0x30800000U)
9611 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFC00000UL) ^ 0x00200000UL) + 0x00200000UL) << 2);
9612 + else
9613 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
9614 +
9615 + if (test_thread_flag(TIF_32BIT))
9616 + addr &= 0xFFFFFFFFUL;
9617 +
9618 + regs->tpc = addr;
9619 + regs->tnpc = addr+4;
9620 + return 2;
9621 + }
9622 + } while (0);
9623 +
9624 + do { /* PaX: patched PLT emulation #3 */
9625 + unsigned int sethi, bajmpl, nop;
9626 +
9627 + err = get_user(sethi, (unsigned int *)regs->tpc);
9628 + err |= get_user(bajmpl, (unsigned int *)(regs->tpc+4));
9629 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
9630 +
9631 + if (err)
9632 + break;
9633 +
9634 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9635 + ((bajmpl & 0xFFFFE000U) == 0x81C06000U || (bajmpl & 0xFFF80000U) == 0x30480000U) &&
9636 + nop == 0x01000000U)
9637 + {
9638 + unsigned long addr;
9639 +
9640 + addr = (sethi & 0x003FFFFFU) << 10;
9641 + regs->u_regs[UREG_G1] = addr;
9642 + if ((bajmpl & 0xFFFFE000U) == 0x81C06000U)
9643 + addr += (((bajmpl | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
9644 + else
9645 + addr = regs->tpc + ((((bajmpl | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
9646 +
9647 + if (test_thread_flag(TIF_32BIT))
9648 + addr &= 0xFFFFFFFFUL;
9649 +
9650 + regs->tpc = addr;
9651 + regs->tnpc = addr+4;
9652 + return 2;
9653 + }
9654 + } while (0);
9655 +
9656 + do { /* PaX: patched PLT emulation #4 */
9657 + unsigned int sethi, mov1, call, mov2;
9658 +
9659 + err = get_user(sethi, (unsigned int *)regs->tpc);
9660 + err |= get_user(mov1, (unsigned int *)(regs->tpc+4));
9661 + err |= get_user(call, (unsigned int *)(regs->tpc+8));
9662 + err |= get_user(mov2, (unsigned int *)(regs->tpc+12));
9663 +
9664 + if (err)
9665 + break;
9666 +
9667 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9668 + mov1 == 0x8210000FU &&
9669 + (call & 0xC0000000U) == 0x40000000U &&
9670 + mov2 == 0x9E100001U)
9671 + {
9672 + unsigned long addr;
9673 +
9674 + regs->u_regs[UREG_G1] = regs->u_regs[UREG_RETPC];
9675 + addr = regs->tpc + 4 + ((((call | 0xFFFFFFFFC0000000UL) ^ 0x20000000UL) + 0x20000000UL) << 2);
9676 +
9677 + if (test_thread_flag(TIF_32BIT))
9678 + addr &= 0xFFFFFFFFUL;
9679 +
9680 + regs->tpc = addr;
9681 + regs->tnpc = addr+4;
9682 + return 2;
9683 + }
9684 + } while (0);
9685 +
9686 + do { /* PaX: patched PLT emulation #5 */
9687 + unsigned int sethi, sethi1, sethi2, or1, or2, sllx, jmpl, nop;
9688 +
9689 + err = get_user(sethi, (unsigned int *)regs->tpc);
9690 + err |= get_user(sethi1, (unsigned int *)(regs->tpc+4));
9691 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+8));
9692 + err |= get_user(or1, (unsigned int *)(regs->tpc+12));
9693 + err |= get_user(or2, (unsigned int *)(regs->tpc+16));
9694 + err |= get_user(sllx, (unsigned int *)(regs->tpc+20));
9695 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+24));
9696 + err |= get_user(nop, (unsigned int *)(regs->tpc+28));
9697 +
9698 + if (err)
9699 + break;
9700 +
9701 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9702 + (sethi1 & 0xFFC00000U) == 0x03000000U &&
9703 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
9704 + (or1 & 0xFFFFE000U) == 0x82106000U &&
9705 + (or2 & 0xFFFFE000U) == 0x8A116000U &&
9706 + sllx == 0x83287020U &&
9707 + jmpl == 0x81C04005U &&
9708 + nop == 0x01000000U)
9709 + {
9710 + unsigned long addr;
9711 +
9712 + regs->u_regs[UREG_G1] = ((sethi1 & 0x003FFFFFU) << 10) | (or1 & 0x000003FFU);
9713 + regs->u_regs[UREG_G1] <<= 32;
9714 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or2 & 0x000003FFU);
9715 + addr = regs->u_regs[UREG_G1] + regs->u_regs[UREG_G5];
9716 + regs->tpc = addr;
9717 + regs->tnpc = addr+4;
9718 + return 2;
9719 + }
9720 + } while (0);
9721 +
9722 + do { /* PaX: patched PLT emulation #6 */
9723 + unsigned int sethi, sethi1, sethi2, sllx, or, jmpl, nop;
9724 +
9725 + err = get_user(sethi, (unsigned int *)regs->tpc);
9726 + err |= get_user(sethi1, (unsigned int *)(regs->tpc+4));
9727 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+8));
9728 + err |= get_user(sllx, (unsigned int *)(regs->tpc+12));
9729 + err |= get_user(or, (unsigned int *)(regs->tpc+16));
9730 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+20));
9731 + err |= get_user(nop, (unsigned int *)(regs->tpc+24));
9732 +
9733 + if (err)
9734 + break;
9735 +
9736 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9737 + (sethi1 & 0xFFC00000U) == 0x03000000U &&
9738 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
9739 + sllx == 0x83287020U &&
9740 + (or & 0xFFFFE000U) == 0x8A116000U &&
9741 + jmpl == 0x81C04005U &&
9742 + nop == 0x01000000U)
9743 + {
9744 + unsigned long addr;
9745 +
9746 + regs->u_regs[UREG_G1] = (sethi1 & 0x003FFFFFU) << 10;
9747 + regs->u_regs[UREG_G1] <<= 32;
9748 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or & 0x3FFU);
9749 + addr = regs->u_regs[UREG_G1] + regs->u_regs[UREG_G5];
9750 + regs->tpc = addr;
9751 + regs->tnpc = addr+4;
9752 + return 2;
9753 + }
9754 + } while (0);
9755 +
9756 + do { /* PaX: unpatched PLT emulation step 1 */
9757 + unsigned int sethi, ba, nop;
9758 +
9759 + err = get_user(sethi, (unsigned int *)regs->tpc);
9760 + err |= get_user(ba, (unsigned int *)(regs->tpc+4));
9761 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
9762 +
9763 + if (err)
9764 + break;
9765 +
9766 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9767 + ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30680000U) &&
9768 + nop == 0x01000000U)
9769 + {
9770 + unsigned long addr;
9771 + unsigned int save, call;
9772 + unsigned int sethi1, sethi2, or1, or2, sllx, add, jmpl;
9773 +
9774 + if ((ba & 0xFFC00000U) == 0x30800000U)
9775 + addr = regs->tpc + 4 + ((((ba | 0xFFFFFFFFFFC00000UL) ^ 0x00200000UL) + 0x00200000UL) << 2);
9776 + else
9777 + addr = regs->tpc + 4 + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
9778 +
9779 + if (test_thread_flag(TIF_32BIT))
9780 + addr &= 0xFFFFFFFFUL;
9781 +
9782 + err = get_user(save, (unsigned int *)addr);
9783 + err |= get_user(call, (unsigned int *)(addr+4));
9784 + err |= get_user(nop, (unsigned int *)(addr+8));
9785 + if (err)
9786 + break;
9787 +
9788 +#ifdef CONFIG_PAX_DLRESOLVE
9789 + if (save == 0x9DE3BFA8U &&
9790 + (call & 0xC0000000U) == 0x40000000U &&
9791 + nop == 0x01000000U)
9792 + {
9793 + struct vm_area_struct *vma;
9794 + unsigned long call_dl_resolve;
9795 +
9796 + down_read(&current->mm->mmap_sem);
9797 + call_dl_resolve = current->mm->call_dl_resolve;
9798 + up_read(&current->mm->mmap_sem);
9799 + if (likely(call_dl_resolve))
9800 + goto emulate;
9801 +
9802 + vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
9803 +
9804 + down_write(&current->mm->mmap_sem);
9805 + if (current->mm->call_dl_resolve) {
9806 + call_dl_resolve = current->mm->call_dl_resolve;
9807 + up_write(&current->mm->mmap_sem);
9808 + if (vma)
9809 + kmem_cache_free(vm_area_cachep, vma);
9810 + goto emulate;
9811 + }
9812 +
9813 + call_dl_resolve = get_unmapped_area(NULL, 0UL, PAGE_SIZE, 0UL, MAP_PRIVATE);
9814 + if (!vma || (call_dl_resolve & ~PAGE_MASK)) {
9815 + up_write(&current->mm->mmap_sem);
9816 + if (vma)
9817 + kmem_cache_free(vm_area_cachep, vma);
9818 + return 1;
9819 + }
9820 +
9821 + if (pax_insert_vma(vma, call_dl_resolve)) {
9822 + up_write(&current->mm->mmap_sem);
9823 + kmem_cache_free(vm_area_cachep, vma);
9824 + return 1;
9825 + }
9826 +
9827 + current->mm->call_dl_resolve = call_dl_resolve;
9828 + up_write(&current->mm->mmap_sem);
9829 +
9830 +emulate:
9831 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
9832 + regs->tpc = call_dl_resolve;
9833 + regs->tnpc = addr+4;
9834 + return 3;
9835 + }
9836 +#endif
9837 +
9838 + /* PaX: glibc 2.4+ generates sethi/jmpl instead of save/call */
9839 + if ((save & 0xFFC00000U) == 0x05000000U &&
9840 + (call & 0xFFFFE000U) == 0x85C0A000U &&
9841 + nop == 0x01000000U)
9842 + {
9843 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
9844 + regs->u_regs[UREG_G2] = addr + 4;
9845 + addr = (save & 0x003FFFFFU) << 10;
9846 + addr += (((call | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
9847 +
9848 + if (test_thread_flag(TIF_32BIT))
9849 + addr &= 0xFFFFFFFFUL;
9850 +
9851 + regs->tpc = addr;
9852 + regs->tnpc = addr+4;
9853 + return 3;
9854 + }
9855 +
9856 + /* PaX: 64-bit PLT stub */
9857 + err = get_user(sethi1, (unsigned int *)addr);
9858 + err |= get_user(sethi2, (unsigned int *)(addr+4));
9859 + err |= get_user(or1, (unsigned int *)(addr+8));
9860 + err |= get_user(or2, (unsigned int *)(addr+12));
9861 + err |= get_user(sllx, (unsigned int *)(addr+16));
9862 + err |= get_user(add, (unsigned int *)(addr+20));
9863 + err |= get_user(jmpl, (unsigned int *)(addr+24));
9864 + err |= get_user(nop, (unsigned int *)(addr+28));
9865 + if (err)
9866 + break;
9867 +
9868 + if ((sethi1 & 0xFFC00000U) == 0x09000000U &&
9869 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
9870 + (or1 & 0xFFFFE000U) == 0x88112000U &&
9871 + (or2 & 0xFFFFE000U) == 0x8A116000U &&
9872 + sllx == 0x89293020U &&
9873 + add == 0x8A010005U &&
9874 + jmpl == 0x89C14000U &&
9875 + nop == 0x01000000U)
9876 + {
9877 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
9878 + regs->u_regs[UREG_G4] = ((sethi1 & 0x003FFFFFU) << 10) | (or1 & 0x000003FFU);
9879 + regs->u_regs[UREG_G4] <<= 32;
9880 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or2 & 0x000003FFU);
9881 + regs->u_regs[UREG_G5] += regs->u_regs[UREG_G4];
9882 + regs->u_regs[UREG_G4] = addr + 24;
9883 + addr = regs->u_regs[UREG_G5];
9884 + regs->tpc = addr;
9885 + regs->tnpc = addr+4;
9886 + return 3;
9887 + }
9888 + }
9889 + } while (0);
9890 +
9891 +#ifdef CONFIG_PAX_DLRESOLVE
9892 + do { /* PaX: unpatched PLT emulation step 2 */
9893 + unsigned int save, call, nop;
9894 +
9895 + err = get_user(save, (unsigned int *)(regs->tpc-4));
9896 + err |= get_user(call, (unsigned int *)regs->tpc);
9897 + err |= get_user(nop, (unsigned int *)(regs->tpc+4));
9898 + if (err)
9899 + break;
9900 +
9901 + if (save == 0x9DE3BFA8U &&
9902 + (call & 0xC0000000U) == 0x40000000U &&
9903 + nop == 0x01000000U)
9904 + {
9905 + unsigned long dl_resolve = regs->tpc + ((((call | 0xFFFFFFFFC0000000UL) ^ 0x20000000UL) + 0x20000000UL) << 2);
9906 +
9907 + if (test_thread_flag(TIF_32BIT))
9908 + dl_resolve &= 0xFFFFFFFFUL;
9909 +
9910 + regs->u_regs[UREG_RETPC] = regs->tpc;
9911 + regs->tpc = dl_resolve;
9912 + regs->tnpc = dl_resolve+4;
9913 + return 3;
9914 + }
9915 + } while (0);
9916 +#endif
9917 +
9918 + do { /* PaX: patched PLT emulation #7, must be AFTER the unpatched PLT emulation */
9919 + unsigned int sethi, ba, nop;
9920 +
9921 + err = get_user(sethi, (unsigned int *)regs->tpc);
9922 + err |= get_user(ba, (unsigned int *)(regs->tpc+4));
9923 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
9924 +
9925 + if (err)
9926 + break;
9927 +
9928 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9929 + (ba & 0xFFF00000U) == 0x30600000U &&
9930 + nop == 0x01000000U)
9931 + {
9932 + unsigned long addr;
9933 +
9934 + addr = (sethi & 0x003FFFFFU) << 10;
9935 + regs->u_regs[UREG_G1] = addr;
9936 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
9937 +
9938 + if (test_thread_flag(TIF_32BIT))
9939 + addr &= 0xFFFFFFFFUL;
9940 +
9941 + regs->tpc = addr;
9942 + regs->tnpc = addr+4;
9943 + return 2;
9944 + }
9945 + } while (0);
9946 +
9947 +#endif
9948 +
9949 + return 1;
9950 +}
9951 +
9952 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
9953 +{
9954 + unsigned long i;
9955 +
9956 + printk(KERN_ERR "PAX: bytes at PC: ");
9957 + for (i = 0; i < 8; i++) {
9958 + unsigned int c;
9959 + if (get_user(c, (unsigned int *)pc+i))
9960 + printk(KERN_CONT "???????? ");
9961 + else
9962 + printk(KERN_CONT "%08x ", c);
9963 + }
9964 + printk("\n");
9965 +}
9966 +#endif
9967 +
9968 asmlinkage void __kprobes do_sparc64_fault(struct pt_regs *regs)
9969 {
9970 struct mm_struct *mm = current->mm;
9971 @@ -341,6 +804,29 @@ retry:
9972 if (!vma)
9973 goto bad_area;
9974
9975 +#ifdef CONFIG_PAX_PAGEEXEC
9976 + /* PaX: detect ITLB misses on non-exec pages */
9977 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && vma->vm_start <= address &&
9978 + !(vma->vm_flags & VM_EXEC) && (fault_code & FAULT_CODE_ITLB))
9979 + {
9980 + if (address != regs->tpc)
9981 + goto good_area;
9982 +
9983 + up_read(&mm->mmap_sem);
9984 + switch (pax_handle_fetch_fault(regs)) {
9985 +
9986 +#ifdef CONFIG_PAX_EMUPLT
9987 + case 2:
9988 + case 3:
9989 + return;
9990 +#endif
9991 +
9992 + }
9993 + pax_report_fault(regs, (void *)regs->tpc, (void *)(regs->u_regs[UREG_FP] + STACK_BIAS));
9994 + do_group_exit(SIGKILL);
9995 + }
9996 +#endif
9997 +
9998 /* Pure DTLB misses do not tell us whether the fault causing
9999 * load/store/atomic was a write or not, it only says that there
10000 * was no match. So in such a case we (carefully) read the
10001 diff --git a/arch/sparc/mm/hugetlbpage.c b/arch/sparc/mm/hugetlbpage.c
10002 index d2b5944..bd813f2 100644
10003 --- a/arch/sparc/mm/hugetlbpage.c
10004 +++ b/arch/sparc/mm/hugetlbpage.c
10005 @@ -38,7 +38,7 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *filp,
10006
10007 info.flags = 0;
10008 info.length = len;
10009 - info.low_limit = TASK_UNMAPPED_BASE;
10010 + info.low_limit = mm->mmap_base;
10011 info.high_limit = min(task_size, VA_EXCLUDE_START);
10012 info.align_mask = PAGE_MASK & ~HPAGE_MASK;
10013 info.align_offset = 0;
10014 @@ -47,6 +47,12 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *filp,
10015 if ((addr & ~PAGE_MASK) && task_size > VA_EXCLUDE_END) {
10016 VM_BUG_ON(addr != -ENOMEM);
10017 info.low_limit = VA_EXCLUDE_END;
10018 +
10019 +#ifdef CONFIG_PAX_RANDMMAP
10020 + if (mm->pax_flags & MF_PAX_RANDMMAP)
10021 + info.low_limit += mm->delta_mmap;
10022 +#endif
10023 +
10024 info.high_limit = task_size;
10025 addr = vm_unmapped_area(&info);
10026 }
10027 @@ -85,6 +91,12 @@ hugetlb_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
10028 VM_BUG_ON(addr != -ENOMEM);
10029 info.flags = 0;
10030 info.low_limit = TASK_UNMAPPED_BASE;
10031 +
10032 +#ifdef CONFIG_PAX_RANDMMAP
10033 + if (mm->pax_flags & MF_PAX_RANDMMAP)
10034 + info.low_limit += mm->delta_mmap;
10035 +#endif
10036 +
10037 info.high_limit = STACK_TOP32;
10038 addr = vm_unmapped_area(&info);
10039 }
10040 @@ -99,6 +111,7 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
10041 struct mm_struct *mm = current->mm;
10042 struct vm_area_struct *vma;
10043 unsigned long task_size = TASK_SIZE;
10044 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
10045
10046 if (test_thread_flag(TIF_32BIT))
10047 task_size = STACK_TOP32;
10048 @@ -114,11 +127,14 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
10049 return addr;
10050 }
10051
10052 +#ifdef CONFIG_PAX_RANDMMAP
10053 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
10054 +#endif
10055 +
10056 if (addr) {
10057 addr = ALIGN(addr, HPAGE_SIZE);
10058 vma = find_vma(mm, addr);
10059 - if (task_size - len >= addr &&
10060 - (!vma || addr + len <= vma->vm_start))
10061 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
10062 return addr;
10063 }
10064 if (mm->get_unmapped_area == arch_get_unmapped_area)
10065 diff --git a/arch/tile/include/asm/atomic_64.h b/arch/tile/include/asm/atomic_64.h
10066 index f4500c6..889656c 100644
10067 --- a/arch/tile/include/asm/atomic_64.h
10068 +++ b/arch/tile/include/asm/atomic_64.h
10069 @@ -143,6 +143,16 @@ static inline long atomic64_add_unless(atomic64_t *v, long a, long u)
10070
10071 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
10072
10073 +#define atomic64_read_unchecked(v) atomic64_read(v)
10074 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
10075 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
10076 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
10077 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
10078 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
10079 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
10080 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
10081 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
10082 +
10083 /* Atomic dec and inc don't implement barrier, so provide them if needed. */
10084 #define smp_mb__before_atomic_dec() smp_mb()
10085 #define smp_mb__after_atomic_dec() smp_mb()
10086 diff --git a/arch/tile/include/asm/cache.h b/arch/tile/include/asm/cache.h
10087 index a9a5299..0fce79e 100644
10088 --- a/arch/tile/include/asm/cache.h
10089 +++ b/arch/tile/include/asm/cache.h
10090 @@ -15,11 +15,12 @@
10091 #ifndef _ASM_TILE_CACHE_H
10092 #define _ASM_TILE_CACHE_H
10093
10094 +#include <linux/const.h>
10095 #include <arch/chip.h>
10096
10097 /* bytes per L1 data cache line */
10098 #define L1_CACHE_SHIFT CHIP_L1D_LOG_LINE_SIZE()
10099 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
10100 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
10101
10102 /* bytes per L2 cache line */
10103 #define L2_CACHE_SHIFT CHIP_L2_LOG_LINE_SIZE()
10104 diff --git a/arch/tile/include/asm/uaccess.h b/arch/tile/include/asm/uaccess.h
10105 index 9ab078a..d6635c2 100644
10106 --- a/arch/tile/include/asm/uaccess.h
10107 +++ b/arch/tile/include/asm/uaccess.h
10108 @@ -403,9 +403,9 @@ static inline unsigned long __must_check copy_from_user(void *to,
10109 const void __user *from,
10110 unsigned long n)
10111 {
10112 - int sz = __compiletime_object_size(to);
10113 + size_t sz = __compiletime_object_size(to);
10114
10115 - if (likely(sz == -1 || sz >= n))
10116 + if (likely(sz == (size_t)-1 || sz >= n))
10117 n = _copy_from_user(to, from, n);
10118 else
10119 copy_from_user_overflow();
10120 diff --git a/arch/tile/mm/hugetlbpage.c b/arch/tile/mm/hugetlbpage.c
10121 index 650ccff..45fe2d6 100644
10122 --- a/arch/tile/mm/hugetlbpage.c
10123 +++ b/arch/tile/mm/hugetlbpage.c
10124 @@ -239,6 +239,7 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *file,
10125 info.high_limit = TASK_SIZE;
10126 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
10127 info.align_offset = 0;
10128 + info.threadstack_offset = 0;
10129 return vm_unmapped_area(&info);
10130 }
10131
10132 @@ -256,6 +257,7 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
10133 info.high_limit = current->mm->mmap_base;
10134 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
10135 info.align_offset = 0;
10136 + info.threadstack_offset = 0;
10137 addr = vm_unmapped_area(&info);
10138
10139 /*
10140 diff --git a/arch/um/Makefile b/arch/um/Makefile
10141 index 133f7de..1d6f2f1 100644
10142 --- a/arch/um/Makefile
10143 +++ b/arch/um/Makefile
10144 @@ -62,6 +62,10 @@ USER_CFLAGS = $(patsubst $(KERNEL_DEFINES),,$(patsubst -D__KERNEL__,,\
10145 $(patsubst -I%,,$(KBUILD_CFLAGS)))) $(ARCH_INCLUDE) $(MODE_INCLUDE) \
10146 $(filter -I%,$(CFLAGS)) -D_FILE_OFFSET_BITS=64 -idirafter include
10147
10148 +ifdef CONSTIFY_PLUGIN
10149 +USER_CFLAGS += -fplugin-arg-constify_plugin-no-constify
10150 +endif
10151 +
10152 #This will adjust *FLAGS accordingly to the platform.
10153 include $(srctree)/$(ARCH_DIR)/Makefile-os-$(OS)
10154
10155 diff --git a/arch/um/defconfig b/arch/um/defconfig
10156 index 08107a7..ab22afe 100644
10157 --- a/arch/um/defconfig
10158 +++ b/arch/um/defconfig
10159 @@ -51,7 +51,6 @@ CONFIG_X86_CMPXCHG=y
10160 CONFIG_X86_L1_CACHE_SHIFT=5
10161 CONFIG_X86_XADD=y
10162 CONFIG_X86_PPRO_FENCE=y
10163 -CONFIG_X86_WP_WORKS_OK=y
10164 CONFIG_X86_INVLPG=y
10165 CONFIG_X86_BSWAP=y
10166 CONFIG_X86_POPAD_OK=y
10167 diff --git a/arch/um/include/asm/cache.h b/arch/um/include/asm/cache.h
10168 index 19e1bdd..3665b77 100644
10169 --- a/arch/um/include/asm/cache.h
10170 +++ b/arch/um/include/asm/cache.h
10171 @@ -1,6 +1,7 @@
10172 #ifndef __UM_CACHE_H
10173 #define __UM_CACHE_H
10174
10175 +#include <linux/const.h>
10176
10177 #if defined(CONFIG_UML_X86) && !defined(CONFIG_64BIT)
10178 # define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT)
10179 @@ -12,6 +13,6 @@
10180 # define L1_CACHE_SHIFT 5
10181 #endif
10182
10183 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
10184 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
10185
10186 #endif
10187 diff --git a/arch/um/include/asm/kmap_types.h b/arch/um/include/asm/kmap_types.h
10188 index 2e0a6b1..a64d0f5 100644
10189 --- a/arch/um/include/asm/kmap_types.h
10190 +++ b/arch/um/include/asm/kmap_types.h
10191 @@ -8,6 +8,6 @@
10192
10193 /* No more #include "asm/arch/kmap_types.h" ! */
10194
10195 -#define KM_TYPE_NR 14
10196 +#define KM_TYPE_NR 15
10197
10198 #endif
10199 diff --git a/arch/um/include/asm/page.h b/arch/um/include/asm/page.h
10200 index 5ff53d9..5850cdf 100644
10201 --- a/arch/um/include/asm/page.h
10202 +++ b/arch/um/include/asm/page.h
10203 @@ -14,6 +14,9 @@
10204 #define PAGE_SIZE (_AC(1, UL) << PAGE_SHIFT)
10205 #define PAGE_MASK (~(PAGE_SIZE-1))
10206
10207 +#define ktla_ktva(addr) (addr)
10208 +#define ktva_ktla(addr) (addr)
10209 +
10210 #ifndef __ASSEMBLY__
10211
10212 struct page;
10213 diff --git a/arch/um/include/asm/pgtable-3level.h b/arch/um/include/asm/pgtable-3level.h
10214 index 0032f92..cd151e0 100644
10215 --- a/arch/um/include/asm/pgtable-3level.h
10216 +++ b/arch/um/include/asm/pgtable-3level.h
10217 @@ -58,6 +58,7 @@
10218 #define pud_present(x) (pud_val(x) & _PAGE_PRESENT)
10219 #define pud_populate(mm, pud, pmd) \
10220 set_pud(pud, __pud(_PAGE_TABLE + __pa(pmd)))
10221 +#define pud_populate_kernel(mm, pud, pmd) pud_populate((mm), (pud), (pmd))
10222
10223 #ifdef CONFIG_64BIT
10224 #define set_pud(pudptr, pudval) set_64bit((u64 *) (pudptr), pud_val(pudval))
10225 diff --git a/arch/um/kernel/process.c b/arch/um/kernel/process.c
10226 index b462b13..e7a19aa 100644
10227 --- a/arch/um/kernel/process.c
10228 +++ b/arch/um/kernel/process.c
10229 @@ -386,22 +386,6 @@ int singlestepping(void * t)
10230 return 2;
10231 }
10232
10233 -/*
10234 - * Only x86 and x86_64 have an arch_align_stack().
10235 - * All other arches have "#define arch_align_stack(x) (x)"
10236 - * in their asm/system.h
10237 - * As this is included in UML from asm-um/system-generic.h,
10238 - * we can use it to behave as the subarch does.
10239 - */
10240 -#ifndef arch_align_stack
10241 -unsigned long arch_align_stack(unsigned long sp)
10242 -{
10243 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
10244 - sp -= get_random_int() % 8192;
10245 - return sp & ~0xf;
10246 -}
10247 -#endif
10248 -
10249 unsigned long get_wchan(struct task_struct *p)
10250 {
10251 unsigned long stack_page, sp, ip;
10252 diff --git a/arch/unicore32/include/asm/cache.h b/arch/unicore32/include/asm/cache.h
10253 index ad8f795..2c7eec6 100644
10254 --- a/arch/unicore32/include/asm/cache.h
10255 +++ b/arch/unicore32/include/asm/cache.h
10256 @@ -12,8 +12,10 @@
10257 #ifndef __UNICORE_CACHE_H__
10258 #define __UNICORE_CACHE_H__
10259
10260 -#define L1_CACHE_SHIFT (5)
10261 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
10262 +#include <linux/const.h>
10263 +
10264 +#define L1_CACHE_SHIFT 5
10265 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
10266
10267 /*
10268 * Memory returned by kmalloc() may be used for DMA, so we must make
10269 diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
10270 index 6ef2a37..74ad6ad 100644
10271 --- a/arch/x86/Kconfig
10272 +++ b/arch/x86/Kconfig
10273 @@ -243,7 +243,7 @@ config X86_HT
10274
10275 config X86_32_LAZY_GS
10276 def_bool y
10277 - depends on X86_32 && !CC_STACKPROTECTOR
10278 + depends on X86_32 && !CC_STACKPROTECTOR && !PAX_MEMORY_UDEREF
10279
10280 config ARCH_HWEIGHT_CFLAGS
10281 string
10282 @@ -1076,6 +1076,7 @@ config MICROCODE_EARLY
10283
10284 config X86_MSR
10285 tristate "/dev/cpu/*/msr - Model-specific register support"
10286 + depends on !GRKERNSEC_KMEM
10287 ---help---
10288 This device gives privileged processes access to the x86
10289 Model-Specific Registers (MSRs). It is a character device with
10290 @@ -1099,7 +1100,7 @@ choice
10291
10292 config NOHIGHMEM
10293 bool "off"
10294 - depends on !X86_NUMAQ
10295 + depends on !X86_NUMAQ && !(PAX_PAGEEXEC && PAX_ENABLE_PAE)
10296 ---help---
10297 Linux can use up to 64 Gigabytes of physical memory on x86 systems.
10298 However, the address space of 32-bit x86 processors is only 4
10299 @@ -1136,7 +1137,7 @@ config NOHIGHMEM
10300
10301 config HIGHMEM4G
10302 bool "4GB"
10303 - depends on !X86_NUMAQ
10304 + depends on !X86_NUMAQ && !(PAX_PAGEEXEC && PAX_ENABLE_PAE)
10305 ---help---
10306 Select this if you have a 32-bit processor and between 1 and 4
10307 gigabytes of physical RAM.
10308 @@ -1189,7 +1190,7 @@ config PAGE_OFFSET
10309 hex
10310 default 0xB0000000 if VMSPLIT_3G_OPT
10311 default 0x80000000 if VMSPLIT_2G
10312 - default 0x78000000 if VMSPLIT_2G_OPT
10313 + default 0x70000000 if VMSPLIT_2G_OPT
10314 default 0x40000000 if VMSPLIT_1G
10315 default 0xC0000000
10316 depends on X86_32
10317 @@ -1587,6 +1588,7 @@ config SECCOMP
10318
10319 config CC_STACKPROTECTOR
10320 bool "Enable -fstack-protector buffer overflow detection"
10321 + depends on X86_64 || !PAX_MEMORY_UDEREF
10322 ---help---
10323 This option turns on the -fstack-protector GCC feature. This
10324 feature puts, at the beginning of functions, a canary value on
10325 @@ -1706,6 +1708,8 @@ config X86_NEED_RELOCS
10326 config PHYSICAL_ALIGN
10327 hex "Alignment value to which kernel should be aligned" if X86_32
10328 default "0x1000000"
10329 + range 0x200000 0x1000000 if PAX_KERNEXEC && X86_PAE
10330 + range 0x400000 0x1000000 if PAX_KERNEXEC && !X86_PAE
10331 range 0x2000 0x1000000
10332 ---help---
10333 This value puts the alignment restrictions on physical address
10334 @@ -1781,9 +1785,10 @@ config DEBUG_HOTPLUG_CPU0
10335 If unsure, say N.
10336
10337 config COMPAT_VDSO
10338 - def_bool y
10339 + def_bool n
10340 prompt "Compat VDSO support"
10341 depends on X86_32 || IA32_EMULATION
10342 + depends on !PAX_PAGEEXEC && !PAX_SEGMEXEC && !PAX_KERNEXEC && !PAX_MEMORY_UDEREF
10343 ---help---
10344 Map the 32-bit VDSO to the predictable old-style address too.
10345
10346 diff --git a/arch/x86/Kconfig.cpu b/arch/x86/Kconfig.cpu
10347 index c026cca..14657ae 100644
10348 --- a/arch/x86/Kconfig.cpu
10349 +++ b/arch/x86/Kconfig.cpu
10350 @@ -319,7 +319,7 @@ config X86_PPRO_FENCE
10351
10352 config X86_F00F_BUG
10353 def_bool y
10354 - depends on M586MMX || M586TSC || M586 || M486
10355 + depends on (M586MMX || M586TSC || M586 || M486) && !PAX_KERNEXEC
10356
10357 config X86_INVD_BUG
10358 def_bool y
10359 @@ -327,7 +327,7 @@ config X86_INVD_BUG
10360
10361 config X86_ALIGNMENT_16
10362 def_bool y
10363 - depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || MELAN || MK6 || M586MMX || M586TSC || M586 || M486 || MVIAC3_2 || MGEODEGX1
10364 + depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || X86_ELAN || MK8 || MK7 || MK6 || MCORE2 || MPENTIUM4 || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || M586 || M486 || MVIAC3_2 || MGEODEGX1
10365
10366 config X86_INTEL_USERCOPY
10367 def_bool y
10368 @@ -373,7 +373,7 @@ config X86_CMPXCHG64
10369 # generates cmov.
10370 config X86_CMOV
10371 def_bool y
10372 - depends on (MK8 || MK7 || MCORE2 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MATOM || MGEODE_LX)
10373 + depends on (MK8 || MK7 || MCORE2 || MPSC || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MATOM || MGEODE_LX)
10374
10375 config X86_MINIMUM_CPU_FAMILY
10376 int
10377 diff --git a/arch/x86/Kconfig.debug b/arch/x86/Kconfig.debug
10378 index b322f12..652d0d9 100644
10379 --- a/arch/x86/Kconfig.debug
10380 +++ b/arch/x86/Kconfig.debug
10381 @@ -84,7 +84,7 @@ config X86_PTDUMP
10382 config DEBUG_RODATA
10383 bool "Write protect kernel read-only data structures"
10384 default y
10385 - depends on DEBUG_KERNEL
10386 + depends on DEBUG_KERNEL && BROKEN
10387 ---help---
10388 Mark the kernel read-only data as write-protected in the pagetables,
10389 in order to catch accidental (and incorrect) writes to such const
10390 @@ -102,7 +102,7 @@ config DEBUG_RODATA_TEST
10391
10392 config DEBUG_SET_MODULE_RONX
10393 bool "Set loadable kernel module data as NX and text as RO"
10394 - depends on MODULES
10395 + depends on MODULES && BROKEN
10396 ---help---
10397 This option helps catch unintended modifications to loadable
10398 kernel module's text and read-only data. It also prevents execution
10399 @@ -294,7 +294,7 @@ config OPTIMIZE_INLINING
10400
10401 config DEBUG_STRICT_USER_COPY_CHECKS
10402 bool "Strict copy size checks"
10403 - depends on DEBUG_KERNEL && !TRACE_BRANCH_PROFILING
10404 + depends on DEBUG_KERNEL && !TRACE_BRANCH_PROFILING && !PAX_SIZE_OVERFLOW
10405 ---help---
10406 Enabling this option turns a certain set of sanity checks for user
10407 copy operations into compile time failures.
10408 diff --git a/arch/x86/Makefile b/arch/x86/Makefile
10409 index 5c47726..8c4fa67 100644
10410 --- a/arch/x86/Makefile
10411 +++ b/arch/x86/Makefile
10412 @@ -54,6 +54,7 @@ else
10413 UTS_MACHINE := x86_64
10414 CHECKFLAGS += -D__x86_64__ -m64
10415
10416 + biarch := $(call cc-option,-m64)
10417 KBUILD_AFLAGS += -m64
10418 KBUILD_CFLAGS += -m64
10419
10420 @@ -234,3 +235,12 @@ define archhelp
10421 echo ' FDARGS="..." arguments for the booted kernel'
10422 echo ' FDINITRD=file initrd for the booted kernel'
10423 endef
10424 +
10425 +define OLD_LD
10426 +
10427 +*** ${VERSION}.${PATCHLEVEL} PaX kernels no longer build correctly with old versions of binutils.
10428 +*** Please upgrade your binutils to 2.18 or newer
10429 +endef
10430 +
10431 +archprepare:
10432 + $(if $(LDFLAGS_BUILD_ID),,$(error $(OLD_LD)))
10433 diff --git a/arch/x86/boot/Makefile b/arch/x86/boot/Makefile
10434 index 379814b..add62ce 100644
10435 --- a/arch/x86/boot/Makefile
10436 +++ b/arch/x86/boot/Makefile
10437 @@ -65,6 +65,9 @@ KBUILD_CFLAGS := $(USERINCLUDE) -g -Os -D_SETUP -D__KERNEL__ \
10438 $(call cc-option, -fno-stack-protector) \
10439 $(call cc-option, -mpreferred-stack-boundary=2)
10440 KBUILD_CFLAGS += $(call cc-option, -m32)
10441 +ifdef CONSTIFY_PLUGIN
10442 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
10443 +endif
10444 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
10445 GCOV_PROFILE := n
10446
10447 diff --git a/arch/x86/boot/bitops.h b/arch/x86/boot/bitops.h
10448 index 878e4b9..20537ab 100644
10449 --- a/arch/x86/boot/bitops.h
10450 +++ b/arch/x86/boot/bitops.h
10451 @@ -26,7 +26,7 @@ static inline int variable_test_bit(int nr, const void *addr)
10452 u8 v;
10453 const u32 *p = (const u32 *)addr;
10454
10455 - asm("btl %2,%1; setc %0" : "=qm" (v) : "m" (*p), "Ir" (nr));
10456 + asm volatile("btl %2,%1; setc %0" : "=qm" (v) : "m" (*p), "Ir" (nr));
10457 return v;
10458 }
10459
10460 @@ -37,7 +37,7 @@ static inline int variable_test_bit(int nr, const void *addr)
10461
10462 static inline void set_bit(int nr, void *addr)
10463 {
10464 - asm("btsl %1,%0" : "+m" (*(u32 *)addr) : "Ir" (nr));
10465 + asm volatile("btsl %1,%0" : "+m" (*(u32 *)addr) : "Ir" (nr));
10466 }
10467
10468 #endif /* BOOT_BITOPS_H */
10469 diff --git a/arch/x86/boot/boot.h b/arch/x86/boot/boot.h
10470 index 5b75319..331a4ca 100644
10471 --- a/arch/x86/boot/boot.h
10472 +++ b/arch/x86/boot/boot.h
10473 @@ -85,7 +85,7 @@ static inline void io_delay(void)
10474 static inline u16 ds(void)
10475 {
10476 u16 seg;
10477 - asm("movw %%ds,%0" : "=rm" (seg));
10478 + asm volatile("movw %%ds,%0" : "=rm" (seg));
10479 return seg;
10480 }
10481
10482 @@ -181,7 +181,7 @@ static inline void wrgs32(u32 v, addr_t addr)
10483 static inline int memcmp(const void *s1, const void *s2, size_t len)
10484 {
10485 u8 diff;
10486 - asm("repe; cmpsb; setnz %0"
10487 + asm volatile("repe; cmpsb; setnz %0"
10488 : "=qm" (diff), "+D" (s1), "+S" (s2), "+c" (len));
10489 return diff;
10490 }
10491 diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile
10492 index 5ef205c..342191d 100644
10493 --- a/arch/x86/boot/compressed/Makefile
10494 +++ b/arch/x86/boot/compressed/Makefile
10495 @@ -14,6 +14,9 @@ cflags-$(CONFIG_X86_64) := -mcmodel=small
10496 KBUILD_CFLAGS += $(cflags-y)
10497 KBUILD_CFLAGS += $(call cc-option,-ffreestanding)
10498 KBUILD_CFLAGS += $(call cc-option,-fno-stack-protector)
10499 +ifdef CONSTIFY_PLUGIN
10500 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
10501 +endif
10502
10503 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
10504 GCOV_PROFILE := n
10505 diff --git a/arch/x86/boot/compressed/eboot.c b/arch/x86/boot/compressed/eboot.c
10506 index 35ee62f..b6609b6 100644
10507 --- a/arch/x86/boot/compressed/eboot.c
10508 +++ b/arch/x86/boot/compressed/eboot.c
10509 @@ -150,7 +150,6 @@ again:
10510 *addr = max_addr;
10511 }
10512
10513 -free_pool:
10514 efi_call_phys1(sys_table->boottime->free_pool, map);
10515
10516 fail:
10517 @@ -214,7 +213,6 @@ static efi_status_t low_alloc(unsigned long size, unsigned long align,
10518 if (i == map_size / desc_size)
10519 status = EFI_NOT_FOUND;
10520
10521 -free_pool:
10522 efi_call_phys1(sys_table->boottime->free_pool, map);
10523 fail:
10524 return status;
10525 diff --git a/arch/x86/boot/compressed/head_32.S b/arch/x86/boot/compressed/head_32.S
10526 index 1e3184f..0d11e2e 100644
10527 --- a/arch/x86/boot/compressed/head_32.S
10528 +++ b/arch/x86/boot/compressed/head_32.S
10529 @@ -118,7 +118,7 @@ preferred_addr:
10530 notl %eax
10531 andl %eax, %ebx
10532 #else
10533 - movl $LOAD_PHYSICAL_ADDR, %ebx
10534 + movl $____LOAD_PHYSICAL_ADDR, %ebx
10535 #endif
10536
10537 /* Target address to relocate to for decompression */
10538 @@ -204,7 +204,7 @@ relocated:
10539 * and where it was actually loaded.
10540 */
10541 movl %ebp, %ebx
10542 - subl $LOAD_PHYSICAL_ADDR, %ebx
10543 + subl $____LOAD_PHYSICAL_ADDR, %ebx
10544 jz 2f /* Nothing to be done if loaded at compiled addr. */
10545 /*
10546 * Process relocations.
10547 @@ -212,8 +212,7 @@ relocated:
10548
10549 1: subl $4, %edi
10550 movl (%edi), %ecx
10551 - testl %ecx, %ecx
10552 - jz 2f
10553 + jecxz 2f
10554 addl %ebx, -__PAGE_OFFSET(%ebx, %ecx)
10555 jmp 1b
10556 2:
10557 diff --git a/arch/x86/boot/compressed/head_64.S b/arch/x86/boot/compressed/head_64.S
10558 index c1d383d..57ab51c 100644
10559 --- a/arch/x86/boot/compressed/head_64.S
10560 +++ b/arch/x86/boot/compressed/head_64.S
10561 @@ -97,7 +97,7 @@ ENTRY(startup_32)
10562 notl %eax
10563 andl %eax, %ebx
10564 #else
10565 - movl $LOAD_PHYSICAL_ADDR, %ebx
10566 + movl $____LOAD_PHYSICAL_ADDR, %ebx
10567 #endif
10568
10569 /* Target address to relocate to for decompression */
10570 @@ -272,7 +272,7 @@ preferred_addr:
10571 notq %rax
10572 andq %rax, %rbp
10573 #else
10574 - movq $LOAD_PHYSICAL_ADDR, %rbp
10575 + movq $____LOAD_PHYSICAL_ADDR, %rbp
10576 #endif
10577
10578 /* Target address to relocate to for decompression */
10579 @@ -363,8 +363,8 @@ gdt:
10580 .long gdt
10581 .word 0
10582 .quad 0x0000000000000000 /* NULL descriptor */
10583 - .quad 0x00af9a000000ffff /* __KERNEL_CS */
10584 - .quad 0x00cf92000000ffff /* __KERNEL_DS */
10585 + .quad 0x00af9b000000ffff /* __KERNEL_CS */
10586 + .quad 0x00cf93000000ffff /* __KERNEL_DS */
10587 .quad 0x0080890000000000 /* TS descriptor */
10588 .quad 0x0000000000000000 /* TS continued */
10589 gdt_end:
10590 diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c
10591 index 7cb56c6..d382d84 100644
10592 --- a/arch/x86/boot/compressed/misc.c
10593 +++ b/arch/x86/boot/compressed/misc.c
10594 @@ -303,7 +303,7 @@ static void parse_elf(void *output)
10595 case PT_LOAD:
10596 #ifdef CONFIG_RELOCATABLE
10597 dest = output;
10598 - dest += (phdr->p_paddr - LOAD_PHYSICAL_ADDR);
10599 + dest += (phdr->p_paddr - ____LOAD_PHYSICAL_ADDR);
10600 #else
10601 dest = (void *)(phdr->p_paddr);
10602 #endif
10603 @@ -354,7 +354,7 @@ asmlinkage void decompress_kernel(void *rmode, memptr heap,
10604 error("Destination address too large");
10605 #endif
10606 #ifndef CONFIG_RELOCATABLE
10607 - if ((unsigned long)output != LOAD_PHYSICAL_ADDR)
10608 + if ((unsigned long)output != ____LOAD_PHYSICAL_ADDR)
10609 error("Wrong destination address");
10610 #endif
10611
10612 diff --git a/arch/x86/boot/cpucheck.c b/arch/x86/boot/cpucheck.c
10613 index 4d3ff03..e4972ff 100644
10614 --- a/arch/x86/boot/cpucheck.c
10615 +++ b/arch/x86/boot/cpucheck.c
10616 @@ -74,7 +74,7 @@ static int has_fpu(void)
10617 u16 fcw = -1, fsw = -1;
10618 u32 cr0;
10619
10620 - asm("movl %%cr0,%0" : "=r" (cr0));
10621 + asm volatile("movl %%cr0,%0" : "=r" (cr0));
10622 if (cr0 & (X86_CR0_EM|X86_CR0_TS)) {
10623 cr0 &= ~(X86_CR0_EM|X86_CR0_TS);
10624 asm volatile("movl %0,%%cr0" : : "r" (cr0));
10625 @@ -90,7 +90,7 @@ static int has_eflag(u32 mask)
10626 {
10627 u32 f0, f1;
10628
10629 - asm("pushfl ; "
10630 + asm volatile("pushfl ; "
10631 "pushfl ; "
10632 "popl %0 ; "
10633 "movl %0,%1 ; "
10634 @@ -115,7 +115,7 @@ static void get_flags(void)
10635 set_bit(X86_FEATURE_FPU, cpu.flags);
10636
10637 if (has_eflag(X86_EFLAGS_ID)) {
10638 - asm("cpuid"
10639 + asm volatile("cpuid"
10640 : "=a" (max_intel_level),
10641 "=b" (cpu_vendor[0]),
10642 "=d" (cpu_vendor[1]),
10643 @@ -124,7 +124,7 @@ static void get_flags(void)
10644
10645 if (max_intel_level >= 0x00000001 &&
10646 max_intel_level <= 0x0000ffff) {
10647 - asm("cpuid"
10648 + asm volatile("cpuid"
10649 : "=a" (tfms),
10650 "=c" (cpu.flags[4]),
10651 "=d" (cpu.flags[0])
10652 @@ -136,7 +136,7 @@ static void get_flags(void)
10653 cpu.model += ((tfms >> 16) & 0xf) << 4;
10654 }
10655
10656 - asm("cpuid"
10657 + asm volatile("cpuid"
10658 : "=a" (max_amd_level)
10659 : "a" (0x80000000)
10660 : "ebx", "ecx", "edx");
10661 @@ -144,7 +144,7 @@ static void get_flags(void)
10662 if (max_amd_level >= 0x80000001 &&
10663 max_amd_level <= 0x8000ffff) {
10664 u32 eax = 0x80000001;
10665 - asm("cpuid"
10666 + asm volatile("cpuid"
10667 : "+a" (eax),
10668 "=c" (cpu.flags[6]),
10669 "=d" (cpu.flags[1])
10670 @@ -203,9 +203,9 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
10671 u32 ecx = MSR_K7_HWCR;
10672 u32 eax, edx;
10673
10674 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10675 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10676 eax &= ~(1 << 15);
10677 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10678 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10679
10680 get_flags(); /* Make sure it really did something */
10681 err = check_flags();
10682 @@ -218,9 +218,9 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
10683 u32 ecx = MSR_VIA_FCR;
10684 u32 eax, edx;
10685
10686 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10687 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10688 eax |= (1<<1)|(1<<7);
10689 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10690 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10691
10692 set_bit(X86_FEATURE_CX8, cpu.flags);
10693 err = check_flags();
10694 @@ -231,12 +231,12 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
10695 u32 eax, edx;
10696 u32 level = 1;
10697
10698 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10699 - asm("wrmsr" : : "a" (~0), "d" (edx), "c" (ecx));
10700 - asm("cpuid"
10701 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10702 + asm volatile("wrmsr" : : "a" (~0), "d" (edx), "c" (ecx));
10703 + asm volatile("cpuid"
10704 : "+a" (level), "=d" (cpu.flags[0])
10705 : : "ecx", "ebx");
10706 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10707 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10708
10709 err = check_flags();
10710 }
10711 diff --git a/arch/x86/boot/header.S b/arch/x86/boot/header.S
10712 index 9ec06a1..2c25e79 100644
10713 --- a/arch/x86/boot/header.S
10714 +++ b/arch/x86/boot/header.S
10715 @@ -409,10 +409,14 @@ setup_data: .quad 0 # 64-bit physical pointer to
10716 # single linked list of
10717 # struct setup_data
10718
10719 -pref_address: .quad LOAD_PHYSICAL_ADDR # preferred load addr
10720 +pref_address: .quad ____LOAD_PHYSICAL_ADDR # preferred load addr
10721
10722 #define ZO_INIT_SIZE (ZO__end - ZO_startup_32 + ZO_z_extract_offset)
10723 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
10724 +#define VO_INIT_SIZE (VO__end - VO__text - __PAGE_OFFSET - ____LOAD_PHYSICAL_ADDR)
10725 +#else
10726 #define VO_INIT_SIZE (VO__end - VO__text)
10727 +#endif
10728 #if ZO_INIT_SIZE > VO_INIT_SIZE
10729 #define INIT_SIZE ZO_INIT_SIZE
10730 #else
10731 diff --git a/arch/x86/boot/memory.c b/arch/x86/boot/memory.c
10732 index db75d07..8e6d0af 100644
10733 --- a/arch/x86/boot/memory.c
10734 +++ b/arch/x86/boot/memory.c
10735 @@ -19,7 +19,7 @@
10736
10737 static int detect_memory_e820(void)
10738 {
10739 - int count = 0;
10740 + unsigned int count = 0;
10741 struct biosregs ireg, oreg;
10742 struct e820entry *desc = boot_params.e820_map;
10743 static struct e820entry buf; /* static so it is zeroed */
10744 diff --git a/arch/x86/boot/video-vesa.c b/arch/x86/boot/video-vesa.c
10745 index 11e8c6e..fdbb1ed 100644
10746 --- a/arch/x86/boot/video-vesa.c
10747 +++ b/arch/x86/boot/video-vesa.c
10748 @@ -200,6 +200,7 @@ static void vesa_store_pm_info(void)
10749
10750 boot_params.screen_info.vesapm_seg = oreg.es;
10751 boot_params.screen_info.vesapm_off = oreg.di;
10752 + boot_params.screen_info.vesapm_size = oreg.cx;
10753 }
10754
10755 /*
10756 diff --git a/arch/x86/boot/video.c b/arch/x86/boot/video.c
10757 index 43eda28..5ab5fdb 100644
10758 --- a/arch/x86/boot/video.c
10759 +++ b/arch/x86/boot/video.c
10760 @@ -96,7 +96,7 @@ static void store_mode_params(void)
10761 static unsigned int get_entry(void)
10762 {
10763 char entry_buf[4];
10764 - int i, len = 0;
10765 + unsigned int i, len = 0;
10766 int key;
10767 unsigned int v;
10768
10769 diff --git a/arch/x86/crypto/aes-x86_64-asm_64.S b/arch/x86/crypto/aes-x86_64-asm_64.S
10770 index 9105655..5e37f27 100644
10771 --- a/arch/x86/crypto/aes-x86_64-asm_64.S
10772 +++ b/arch/x86/crypto/aes-x86_64-asm_64.S
10773 @@ -8,6 +8,8 @@
10774 * including this sentence is retained in full.
10775 */
10776
10777 +#include <asm/alternative-asm.h>
10778 +
10779 .extern crypto_ft_tab
10780 .extern crypto_it_tab
10781 .extern crypto_fl_tab
10782 @@ -70,6 +72,8 @@
10783 je B192; \
10784 leaq 32(r9),r9;
10785
10786 +#define ret pax_force_retaddr 0, 1; ret
10787 +
10788 #define epilogue(FUNC,r1,r2,r3,r4,r5,r6,r7,r8,r9) \
10789 movq r1,r2; \
10790 movq r3,r4; \
10791 diff --git a/arch/x86/crypto/aesni-intel_asm.S b/arch/x86/crypto/aesni-intel_asm.S
10792 index 04b7977..402f223 100644
10793 --- a/arch/x86/crypto/aesni-intel_asm.S
10794 +++ b/arch/x86/crypto/aesni-intel_asm.S
10795 @@ -31,6 +31,7 @@
10796
10797 #include <linux/linkage.h>
10798 #include <asm/inst.h>
10799 +#include <asm/alternative-asm.h>
10800
10801 #ifdef __x86_64__
10802 .data
10803 @@ -1435,6 +1436,7 @@ _return_T_done_decrypt:
10804 pop %r14
10805 pop %r13
10806 pop %r12
10807 + pax_force_retaddr 0, 1
10808 ret
10809 ENDPROC(aesni_gcm_dec)
10810
10811 @@ -1699,6 +1701,7 @@ _return_T_done_encrypt:
10812 pop %r14
10813 pop %r13
10814 pop %r12
10815 + pax_force_retaddr 0, 1
10816 ret
10817 ENDPROC(aesni_gcm_enc)
10818
10819 @@ -1716,6 +1719,7 @@ _key_expansion_256a:
10820 pxor %xmm1, %xmm0
10821 movaps %xmm0, (TKEYP)
10822 add $0x10, TKEYP
10823 + pax_force_retaddr_bts
10824 ret
10825 ENDPROC(_key_expansion_128)
10826 ENDPROC(_key_expansion_256a)
10827 @@ -1742,6 +1746,7 @@ _key_expansion_192a:
10828 shufps $0b01001110, %xmm2, %xmm1
10829 movaps %xmm1, 0x10(TKEYP)
10830 add $0x20, TKEYP
10831 + pax_force_retaddr_bts
10832 ret
10833 ENDPROC(_key_expansion_192a)
10834
10835 @@ -1762,6 +1767,7 @@ _key_expansion_192b:
10836
10837 movaps %xmm0, (TKEYP)
10838 add $0x10, TKEYP
10839 + pax_force_retaddr_bts
10840 ret
10841 ENDPROC(_key_expansion_192b)
10842
10843 @@ -1775,6 +1781,7 @@ _key_expansion_256b:
10844 pxor %xmm1, %xmm2
10845 movaps %xmm2, (TKEYP)
10846 add $0x10, TKEYP
10847 + pax_force_retaddr_bts
10848 ret
10849 ENDPROC(_key_expansion_256b)
10850
10851 @@ -1888,6 +1895,7 @@ ENTRY(aesni_set_key)
10852 #ifndef __x86_64__
10853 popl KEYP
10854 #endif
10855 + pax_force_retaddr 0, 1
10856 ret
10857 ENDPROC(aesni_set_key)
10858
10859 @@ -1910,6 +1918,7 @@ ENTRY(aesni_enc)
10860 popl KLEN
10861 popl KEYP
10862 #endif
10863 + pax_force_retaddr 0, 1
10864 ret
10865 ENDPROC(aesni_enc)
10866
10867 @@ -1968,6 +1977,7 @@ _aesni_enc1:
10868 AESENC KEY STATE
10869 movaps 0x70(TKEYP), KEY
10870 AESENCLAST KEY STATE
10871 + pax_force_retaddr_bts
10872 ret
10873 ENDPROC(_aesni_enc1)
10874
10875 @@ -2077,6 +2087,7 @@ _aesni_enc4:
10876 AESENCLAST KEY STATE2
10877 AESENCLAST KEY STATE3
10878 AESENCLAST KEY STATE4
10879 + pax_force_retaddr_bts
10880 ret
10881 ENDPROC(_aesni_enc4)
10882
10883 @@ -2100,6 +2111,7 @@ ENTRY(aesni_dec)
10884 popl KLEN
10885 popl KEYP
10886 #endif
10887 + pax_force_retaddr 0, 1
10888 ret
10889 ENDPROC(aesni_dec)
10890
10891 @@ -2158,6 +2170,7 @@ _aesni_dec1:
10892 AESDEC KEY STATE
10893 movaps 0x70(TKEYP), KEY
10894 AESDECLAST KEY STATE
10895 + pax_force_retaddr_bts
10896 ret
10897 ENDPROC(_aesni_dec1)
10898
10899 @@ -2267,6 +2280,7 @@ _aesni_dec4:
10900 AESDECLAST KEY STATE2
10901 AESDECLAST KEY STATE3
10902 AESDECLAST KEY STATE4
10903 + pax_force_retaddr_bts
10904 ret
10905 ENDPROC(_aesni_dec4)
10906
10907 @@ -2325,6 +2339,7 @@ ENTRY(aesni_ecb_enc)
10908 popl KEYP
10909 popl LEN
10910 #endif
10911 + pax_force_retaddr 0, 1
10912 ret
10913 ENDPROC(aesni_ecb_enc)
10914
10915 @@ -2384,6 +2399,7 @@ ENTRY(aesni_ecb_dec)
10916 popl KEYP
10917 popl LEN
10918 #endif
10919 + pax_force_retaddr 0, 1
10920 ret
10921 ENDPROC(aesni_ecb_dec)
10922
10923 @@ -2426,6 +2442,7 @@ ENTRY(aesni_cbc_enc)
10924 popl LEN
10925 popl IVP
10926 #endif
10927 + pax_force_retaddr 0, 1
10928 ret
10929 ENDPROC(aesni_cbc_enc)
10930
10931 @@ -2517,6 +2534,7 @@ ENTRY(aesni_cbc_dec)
10932 popl LEN
10933 popl IVP
10934 #endif
10935 + pax_force_retaddr 0, 1
10936 ret
10937 ENDPROC(aesni_cbc_dec)
10938
10939 @@ -2544,6 +2562,7 @@ _aesni_inc_init:
10940 mov $1, TCTR_LOW
10941 MOVQ_R64_XMM TCTR_LOW INC
10942 MOVQ_R64_XMM CTR TCTR_LOW
10943 + pax_force_retaddr_bts
10944 ret
10945 ENDPROC(_aesni_inc_init)
10946
10947 @@ -2573,6 +2592,7 @@ _aesni_inc:
10948 .Linc_low:
10949 movaps CTR, IV
10950 PSHUFB_XMM BSWAP_MASK IV
10951 + pax_force_retaddr_bts
10952 ret
10953 ENDPROC(_aesni_inc)
10954
10955 @@ -2634,6 +2654,7 @@ ENTRY(aesni_ctr_enc)
10956 .Lctr_enc_ret:
10957 movups IV, (IVP)
10958 .Lctr_enc_just_ret:
10959 + pax_force_retaddr 0, 1
10960 ret
10961 ENDPROC(aesni_ctr_enc)
10962 #endif
10963 diff --git a/arch/x86/crypto/blowfish-x86_64-asm_64.S b/arch/x86/crypto/blowfish-x86_64-asm_64.S
10964 index 246c670..4d1ed00 100644
10965 --- a/arch/x86/crypto/blowfish-x86_64-asm_64.S
10966 +++ b/arch/x86/crypto/blowfish-x86_64-asm_64.S
10967 @@ -21,6 +21,7 @@
10968 */
10969
10970 #include <linux/linkage.h>
10971 +#include <asm/alternative-asm.h>
10972
10973 .file "blowfish-x86_64-asm.S"
10974 .text
10975 @@ -149,9 +150,11 @@ ENTRY(__blowfish_enc_blk)
10976 jnz .L__enc_xor;
10977
10978 write_block();
10979 + pax_force_retaddr 0, 1
10980 ret;
10981 .L__enc_xor:
10982 xor_block();
10983 + pax_force_retaddr 0, 1
10984 ret;
10985 ENDPROC(__blowfish_enc_blk)
10986
10987 @@ -183,6 +186,7 @@ ENTRY(blowfish_dec_blk)
10988
10989 movq %r11, %rbp;
10990
10991 + pax_force_retaddr 0, 1
10992 ret;
10993 ENDPROC(blowfish_dec_blk)
10994
10995 @@ -334,6 +338,7 @@ ENTRY(__blowfish_enc_blk_4way)
10996
10997 popq %rbx;
10998 popq %rbp;
10999 + pax_force_retaddr 0, 1
11000 ret;
11001
11002 .L__enc_xor4:
11003 @@ -341,6 +346,7 @@ ENTRY(__blowfish_enc_blk_4way)
11004
11005 popq %rbx;
11006 popq %rbp;
11007 + pax_force_retaddr 0, 1
11008 ret;
11009 ENDPROC(__blowfish_enc_blk_4way)
11010
11011 @@ -375,5 +381,6 @@ ENTRY(blowfish_dec_blk_4way)
11012 popq %rbx;
11013 popq %rbp;
11014
11015 + pax_force_retaddr 0, 1
11016 ret;
11017 ENDPROC(blowfish_dec_blk_4way)
11018 diff --git a/arch/x86/crypto/camellia-x86_64-asm_64.S b/arch/x86/crypto/camellia-x86_64-asm_64.S
11019 index 310319c..ce174a4 100644
11020 --- a/arch/x86/crypto/camellia-x86_64-asm_64.S
11021 +++ b/arch/x86/crypto/camellia-x86_64-asm_64.S
11022 @@ -21,6 +21,7 @@
11023 */
11024
11025 #include <linux/linkage.h>
11026 +#include <asm/alternative-asm.h>
11027
11028 .file "camellia-x86_64-asm_64.S"
11029 .text
11030 @@ -228,12 +229,14 @@ ENTRY(__camellia_enc_blk)
11031 enc_outunpack(mov, RT1);
11032
11033 movq RRBP, %rbp;
11034 + pax_force_retaddr 0, 1
11035 ret;
11036
11037 .L__enc_xor:
11038 enc_outunpack(xor, RT1);
11039
11040 movq RRBP, %rbp;
11041 + pax_force_retaddr 0, 1
11042 ret;
11043 ENDPROC(__camellia_enc_blk)
11044
11045 @@ -272,6 +275,7 @@ ENTRY(camellia_dec_blk)
11046 dec_outunpack();
11047
11048 movq RRBP, %rbp;
11049 + pax_force_retaddr 0, 1
11050 ret;
11051 ENDPROC(camellia_dec_blk)
11052
11053 @@ -463,6 +467,7 @@ ENTRY(__camellia_enc_blk_2way)
11054
11055 movq RRBP, %rbp;
11056 popq %rbx;
11057 + pax_force_retaddr 0, 1
11058 ret;
11059
11060 .L__enc2_xor:
11061 @@ -470,6 +475,7 @@ ENTRY(__camellia_enc_blk_2way)
11062
11063 movq RRBP, %rbp;
11064 popq %rbx;
11065 + pax_force_retaddr 0, 1
11066 ret;
11067 ENDPROC(__camellia_enc_blk_2way)
11068
11069 @@ -510,5 +516,6 @@ ENTRY(camellia_dec_blk_2way)
11070
11071 movq RRBP, %rbp;
11072 movq RXOR, %rbx;
11073 + pax_force_retaddr 0, 1
11074 ret;
11075 ENDPROC(camellia_dec_blk_2way)
11076 diff --git a/arch/x86/crypto/cast5-avx-x86_64-asm_64.S b/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
11077 index c35fd5d..c1ee236 100644
11078 --- a/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
11079 +++ b/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
11080 @@ -24,6 +24,7 @@
11081 */
11082
11083 #include <linux/linkage.h>
11084 +#include <asm/alternative-asm.h>
11085
11086 .file "cast5-avx-x86_64-asm_64.S"
11087
11088 @@ -281,6 +282,7 @@ __cast5_enc_blk16:
11089 outunpack_blocks(RR3, RL3, RTMP, RX, RKM);
11090 outunpack_blocks(RR4, RL4, RTMP, RX, RKM);
11091
11092 + pax_force_retaddr 0, 1
11093 ret;
11094 ENDPROC(__cast5_enc_blk16)
11095
11096 @@ -352,6 +354,7 @@ __cast5_dec_blk16:
11097 outunpack_blocks(RR3, RL3, RTMP, RX, RKM);
11098 outunpack_blocks(RR4, RL4, RTMP, RX, RKM);
11099
11100 + pax_force_retaddr 0, 1
11101 ret;
11102
11103 .L__skip_dec:
11104 @@ -388,6 +391,7 @@ ENTRY(cast5_ecb_enc_16way)
11105 vmovdqu RR4, (6*4*4)(%r11);
11106 vmovdqu RL4, (7*4*4)(%r11);
11107
11108 + pax_force_retaddr
11109 ret;
11110 ENDPROC(cast5_ecb_enc_16way)
11111
11112 @@ -420,6 +424,7 @@ ENTRY(cast5_ecb_dec_16way)
11113 vmovdqu RR4, (6*4*4)(%r11);
11114 vmovdqu RL4, (7*4*4)(%r11);
11115
11116 + pax_force_retaddr
11117 ret;
11118 ENDPROC(cast5_ecb_dec_16way)
11119
11120 @@ -469,6 +474,7 @@ ENTRY(cast5_cbc_dec_16way)
11121
11122 popq %r12;
11123
11124 + pax_force_retaddr
11125 ret;
11126 ENDPROC(cast5_cbc_dec_16way)
11127
11128 @@ -542,5 +548,6 @@ ENTRY(cast5_ctr_16way)
11129
11130 popq %r12;
11131
11132 + pax_force_retaddr
11133 ret;
11134 ENDPROC(cast5_ctr_16way)
11135 diff --git a/arch/x86/crypto/cast6-avx-x86_64-asm_64.S b/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
11136 index f93b610..c09bf40 100644
11137 --- a/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
11138 +++ b/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
11139 @@ -24,6 +24,7 @@
11140 */
11141
11142 #include <linux/linkage.h>
11143 +#include <asm/alternative-asm.h>
11144 #include "glue_helper-asm-avx.S"
11145
11146 .file "cast6-avx-x86_64-asm_64.S"
11147 @@ -293,6 +294,7 @@ __cast6_enc_blk8:
11148 outunpack_blocks(RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM);
11149 outunpack_blocks(RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM);
11150
11151 + pax_force_retaddr 0, 1
11152 ret;
11153 ENDPROC(__cast6_enc_blk8)
11154
11155 @@ -338,6 +340,7 @@ __cast6_dec_blk8:
11156 outunpack_blocks(RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM);
11157 outunpack_blocks(RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM);
11158
11159 + pax_force_retaddr 0, 1
11160 ret;
11161 ENDPROC(__cast6_dec_blk8)
11162
11163 @@ -356,6 +359,7 @@ ENTRY(cast6_ecb_enc_8way)
11164
11165 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11166
11167 + pax_force_retaddr
11168 ret;
11169 ENDPROC(cast6_ecb_enc_8way)
11170
11171 @@ -374,6 +378,7 @@ ENTRY(cast6_ecb_dec_8way)
11172
11173 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11174
11175 + pax_force_retaddr
11176 ret;
11177 ENDPROC(cast6_ecb_dec_8way)
11178
11179 @@ -397,6 +402,7 @@ ENTRY(cast6_cbc_dec_8way)
11180
11181 popq %r12;
11182
11183 + pax_force_retaddr
11184 ret;
11185 ENDPROC(cast6_cbc_dec_8way)
11186
11187 @@ -422,5 +428,6 @@ ENTRY(cast6_ctr_8way)
11188
11189 popq %r12;
11190
11191 + pax_force_retaddr
11192 ret;
11193 ENDPROC(cast6_ctr_8way)
11194 diff --git a/arch/x86/crypto/salsa20-x86_64-asm_64.S b/arch/x86/crypto/salsa20-x86_64-asm_64.S
11195 index 9279e0b..9270820 100644
11196 --- a/arch/x86/crypto/salsa20-x86_64-asm_64.S
11197 +++ b/arch/x86/crypto/salsa20-x86_64-asm_64.S
11198 @@ -1,4 +1,5 @@
11199 #include <linux/linkage.h>
11200 +#include <asm/alternative-asm.h>
11201
11202 # enter salsa20_encrypt_bytes
11203 ENTRY(salsa20_encrypt_bytes)
11204 @@ -789,6 +790,7 @@ ENTRY(salsa20_encrypt_bytes)
11205 add %r11,%rsp
11206 mov %rdi,%rax
11207 mov %rsi,%rdx
11208 + pax_force_retaddr 0, 1
11209 ret
11210 # bytesatleast65:
11211 ._bytesatleast65:
11212 @@ -889,6 +891,7 @@ ENTRY(salsa20_keysetup)
11213 add %r11,%rsp
11214 mov %rdi,%rax
11215 mov %rsi,%rdx
11216 + pax_force_retaddr
11217 ret
11218 ENDPROC(salsa20_keysetup)
11219
11220 @@ -914,5 +917,6 @@ ENTRY(salsa20_ivsetup)
11221 add %r11,%rsp
11222 mov %rdi,%rax
11223 mov %rsi,%rdx
11224 + pax_force_retaddr
11225 ret
11226 ENDPROC(salsa20_ivsetup)
11227 diff --git a/arch/x86/crypto/serpent-avx-x86_64-asm_64.S b/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
11228 index 43c9386..a0e2d60 100644
11229 --- a/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
11230 +++ b/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
11231 @@ -25,6 +25,7 @@
11232 */
11233
11234 #include <linux/linkage.h>
11235 +#include <asm/alternative-asm.h>
11236 #include "glue_helper-asm-avx.S"
11237
11238 .file "serpent-avx-x86_64-asm_64.S"
11239 @@ -617,6 +618,7 @@ __serpent_enc_blk8_avx:
11240 write_blocks(RA1, RB1, RC1, RD1, RK0, RK1, RK2);
11241 write_blocks(RA2, RB2, RC2, RD2, RK0, RK1, RK2);
11242
11243 + pax_force_retaddr
11244 ret;
11245 ENDPROC(__serpent_enc_blk8_avx)
11246
11247 @@ -671,6 +673,7 @@ __serpent_dec_blk8_avx:
11248 write_blocks(RC1, RD1, RB1, RE1, RK0, RK1, RK2);
11249 write_blocks(RC2, RD2, RB2, RE2, RK0, RK1, RK2);
11250
11251 + pax_force_retaddr
11252 ret;
11253 ENDPROC(__serpent_dec_blk8_avx)
11254
11255 @@ -687,6 +690,7 @@ ENTRY(serpent_ecb_enc_8way_avx)
11256
11257 store_8way(%rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11258
11259 + pax_force_retaddr
11260 ret;
11261 ENDPROC(serpent_ecb_enc_8way_avx)
11262
11263 @@ -703,6 +707,7 @@ ENTRY(serpent_ecb_dec_8way_avx)
11264
11265 store_8way(%rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
11266
11267 + pax_force_retaddr
11268 ret;
11269 ENDPROC(serpent_ecb_dec_8way_avx)
11270
11271 @@ -719,6 +724,7 @@ ENTRY(serpent_cbc_dec_8way_avx)
11272
11273 store_cbc_8way(%rdx, %rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
11274
11275 + pax_force_retaddr
11276 ret;
11277 ENDPROC(serpent_cbc_dec_8way_avx)
11278
11279 @@ -737,5 +743,6 @@ ENTRY(serpent_ctr_8way_avx)
11280
11281 store_ctr_8way(%rdx, %rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11282
11283 + pax_force_retaddr
11284 ret;
11285 ENDPROC(serpent_ctr_8way_avx)
11286 diff --git a/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S b/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
11287 index acc066c..1559cc4 100644
11288 --- a/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
11289 +++ b/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
11290 @@ -25,6 +25,7 @@
11291 */
11292
11293 #include <linux/linkage.h>
11294 +#include <asm/alternative-asm.h>
11295
11296 .file "serpent-sse2-x86_64-asm_64.S"
11297 .text
11298 @@ -690,12 +691,14 @@ ENTRY(__serpent_enc_blk_8way)
11299 write_blocks(%rsi, RA1, RB1, RC1, RD1, RK0, RK1, RK2);
11300 write_blocks(%rax, RA2, RB2, RC2, RD2, RK0, RK1, RK2);
11301
11302 + pax_force_retaddr
11303 ret;
11304
11305 .L__enc_xor8:
11306 xor_blocks(%rsi, RA1, RB1, RC1, RD1, RK0, RK1, RK2);
11307 xor_blocks(%rax, RA2, RB2, RC2, RD2, RK0, RK1, RK2);
11308
11309 + pax_force_retaddr
11310 ret;
11311 ENDPROC(__serpent_enc_blk_8way)
11312
11313 @@ -750,5 +753,6 @@ ENTRY(serpent_dec_blk_8way)
11314 write_blocks(%rsi, RC1, RD1, RB1, RE1, RK0, RK1, RK2);
11315 write_blocks(%rax, RC2, RD2, RB2, RE2, RK0, RK1, RK2);
11316
11317 + pax_force_retaddr
11318 ret;
11319 ENDPROC(serpent_dec_blk_8way)
11320 diff --git a/arch/x86/crypto/sha1_ssse3_asm.S b/arch/x86/crypto/sha1_ssse3_asm.S
11321 index a410950..3356d42 100644
11322 --- a/arch/x86/crypto/sha1_ssse3_asm.S
11323 +++ b/arch/x86/crypto/sha1_ssse3_asm.S
11324 @@ -29,6 +29,7 @@
11325 */
11326
11327 #include <linux/linkage.h>
11328 +#include <asm/alternative-asm.h>
11329
11330 #define CTX %rdi // arg1
11331 #define BUF %rsi // arg2
11332 @@ -104,6 +105,7 @@
11333 pop %r12
11334 pop %rbp
11335 pop %rbx
11336 + pax_force_retaddr 0, 1
11337 ret
11338
11339 ENDPROC(\name)
11340 diff --git a/arch/x86/crypto/twofish-avx-x86_64-asm_64.S b/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
11341 index 8d3e113..898b161 100644
11342 --- a/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
11343 +++ b/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
11344 @@ -24,6 +24,7 @@
11345 */
11346
11347 #include <linux/linkage.h>
11348 +#include <asm/alternative-asm.h>
11349 #include "glue_helper-asm-avx.S"
11350
11351 .file "twofish-avx-x86_64-asm_64.S"
11352 @@ -282,6 +283,7 @@ __twofish_enc_blk8:
11353 outunpack_blocks(RC1, RD1, RA1, RB1, RK1, RX0, RY0, RK2);
11354 outunpack_blocks(RC2, RD2, RA2, RB2, RK1, RX0, RY0, RK2);
11355
11356 + pax_force_retaddr 0, 1
11357 ret;
11358 ENDPROC(__twofish_enc_blk8)
11359
11360 @@ -322,6 +324,7 @@ __twofish_dec_blk8:
11361 outunpack_blocks(RA1, RB1, RC1, RD1, RK1, RX0, RY0, RK2);
11362 outunpack_blocks(RA2, RB2, RC2, RD2, RK1, RX0, RY0, RK2);
11363
11364 + pax_force_retaddr 0, 1
11365 ret;
11366 ENDPROC(__twofish_dec_blk8)
11367
11368 @@ -340,6 +343,7 @@ ENTRY(twofish_ecb_enc_8way)
11369
11370 store_8way(%r11, RC1, RD1, RA1, RB1, RC2, RD2, RA2, RB2);
11371
11372 + pax_force_retaddr 0, 1
11373 ret;
11374 ENDPROC(twofish_ecb_enc_8way)
11375
11376 @@ -358,6 +362,7 @@ ENTRY(twofish_ecb_dec_8way)
11377
11378 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11379
11380 + pax_force_retaddr 0, 1
11381 ret;
11382 ENDPROC(twofish_ecb_dec_8way)
11383
11384 @@ -381,6 +386,7 @@ ENTRY(twofish_cbc_dec_8way)
11385
11386 popq %r12;
11387
11388 + pax_force_retaddr 0, 1
11389 ret;
11390 ENDPROC(twofish_cbc_dec_8way)
11391
11392 @@ -406,5 +412,6 @@ ENTRY(twofish_ctr_8way)
11393
11394 popq %r12;
11395
11396 + pax_force_retaddr 0, 1
11397 ret;
11398 ENDPROC(twofish_ctr_8way)
11399 diff --git a/arch/x86/crypto/twofish-x86_64-asm_64-3way.S b/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
11400 index 1c3b7ce..b365c5e 100644
11401 --- a/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
11402 +++ b/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
11403 @@ -21,6 +21,7 @@
11404 */
11405
11406 #include <linux/linkage.h>
11407 +#include <asm/alternative-asm.h>
11408
11409 .file "twofish-x86_64-asm-3way.S"
11410 .text
11411 @@ -258,6 +259,7 @@ ENTRY(__twofish_enc_blk_3way)
11412 popq %r13;
11413 popq %r14;
11414 popq %r15;
11415 + pax_force_retaddr 0, 1
11416 ret;
11417
11418 .L__enc_xor3:
11419 @@ -269,6 +271,7 @@ ENTRY(__twofish_enc_blk_3way)
11420 popq %r13;
11421 popq %r14;
11422 popq %r15;
11423 + pax_force_retaddr 0, 1
11424 ret;
11425 ENDPROC(__twofish_enc_blk_3way)
11426
11427 @@ -308,5 +311,6 @@ ENTRY(twofish_dec_blk_3way)
11428 popq %r13;
11429 popq %r14;
11430 popq %r15;
11431 + pax_force_retaddr 0, 1
11432 ret;
11433 ENDPROC(twofish_dec_blk_3way)
11434 diff --git a/arch/x86/crypto/twofish-x86_64-asm_64.S b/arch/x86/crypto/twofish-x86_64-asm_64.S
11435 index a039d21..29e7615 100644
11436 --- a/arch/x86/crypto/twofish-x86_64-asm_64.S
11437 +++ b/arch/x86/crypto/twofish-x86_64-asm_64.S
11438 @@ -22,6 +22,7 @@
11439
11440 #include <linux/linkage.h>
11441 #include <asm/asm-offsets.h>
11442 +#include <asm/alternative-asm.h>
11443
11444 #define a_offset 0
11445 #define b_offset 4
11446 @@ -265,6 +266,7 @@ ENTRY(twofish_enc_blk)
11447
11448 popq R1
11449 movq $1,%rax
11450 + pax_force_retaddr 0, 1
11451 ret
11452 ENDPROC(twofish_enc_blk)
11453
11454 @@ -317,5 +319,6 @@ ENTRY(twofish_dec_blk)
11455
11456 popq R1
11457 movq $1,%rax
11458 + pax_force_retaddr 0, 1
11459 ret
11460 ENDPROC(twofish_dec_blk)
11461 diff --git a/arch/x86/ia32/ia32_aout.c b/arch/x86/ia32/ia32_aout.c
11462 index 03abf9b..a42ba29 100644
11463 --- a/arch/x86/ia32/ia32_aout.c
11464 +++ b/arch/x86/ia32/ia32_aout.c
11465 @@ -159,6 +159,8 @@ static int aout_core_dump(long signr, struct pt_regs *regs, struct file *file,
11466 unsigned long dump_start, dump_size;
11467 struct user32 dump;
11468
11469 + memset(&dump, 0, sizeof(dump));
11470 +
11471 fs = get_fs();
11472 set_fs(KERNEL_DS);
11473 has_dumped = 1;
11474 diff --git a/arch/x86/ia32/ia32_signal.c b/arch/x86/ia32/ia32_signal.c
11475 index cf1a471..3bc4cf8 100644
11476 --- a/arch/x86/ia32/ia32_signal.c
11477 +++ b/arch/x86/ia32/ia32_signal.c
11478 @@ -340,7 +340,7 @@ static void __user *get_sigframe(struct ksignal *ksig, struct pt_regs *regs,
11479 sp -= frame_size;
11480 /* Align the stack pointer according to the i386 ABI,
11481 * i.e. so that on function entry ((sp + 4) & 15) == 0. */
11482 - sp = ((sp + 4) & -16ul) - 4;
11483 + sp = ((sp - 12) & -16ul) - 4;
11484 return (void __user *) sp;
11485 }
11486
11487 @@ -398,7 +398,7 @@ int ia32_setup_frame(int sig, struct ksignal *ksig,
11488 * These are actually not used anymore, but left because some
11489 * gdb versions depend on them as a marker.
11490 */
11491 - put_user_ex(*((u64 *)&code), (u64 __user *)frame->retcode);
11492 + put_user_ex(*((const u64 *)&code), (u64 __user *)frame->retcode);
11493 } put_user_catch(err);
11494
11495 if (err)
11496 @@ -440,7 +440,7 @@ int ia32_setup_rt_frame(int sig, struct ksignal *ksig,
11497 0xb8,
11498 __NR_ia32_rt_sigreturn,
11499 0x80cd,
11500 - 0,
11501 + 0
11502 };
11503
11504 frame = get_sigframe(ksig, regs, sizeof(*frame), &fpstate);
11505 @@ -463,16 +463,18 @@ int ia32_setup_rt_frame(int sig, struct ksignal *ksig,
11506
11507 if (ksig->ka.sa.sa_flags & SA_RESTORER)
11508 restorer = ksig->ka.sa.sa_restorer;
11509 + else if (current->mm->context.vdso)
11510 + /* Return stub is in 32bit vsyscall page */
11511 + restorer = VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
11512 else
11513 - restorer = VDSO32_SYMBOL(current->mm->context.vdso,
11514 - rt_sigreturn);
11515 + restorer = &frame->retcode;
11516 put_user_ex(ptr_to_compat(restorer), &frame->pretcode);
11517
11518 /*
11519 * Not actually used anymore, but left because some gdb
11520 * versions need it.
11521 */
11522 - put_user_ex(*((u64 *)&code), (u64 __user *)frame->retcode);
11523 + put_user_ex(*((const u64 *)&code), (u64 __user *)frame->retcode);
11524 } put_user_catch(err);
11525
11526 err |= copy_siginfo_to_user32(&frame->info, &ksig->info);
11527 diff --git a/arch/x86/ia32/ia32entry.S b/arch/x86/ia32/ia32entry.S
11528 index 474dc1b..be7bff5 100644
11529 --- a/arch/x86/ia32/ia32entry.S
11530 +++ b/arch/x86/ia32/ia32entry.S
11531 @@ -15,8 +15,10 @@
11532 #include <asm/irqflags.h>
11533 #include <asm/asm.h>
11534 #include <asm/smap.h>
11535 +#include <asm/pgtable.h>
11536 #include <linux/linkage.h>
11537 #include <linux/err.h>
11538 +#include <asm/alternative-asm.h>
11539
11540 /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */
11541 #include <linux/elf-em.h>
11542 @@ -96,6 +98,32 @@ ENTRY(native_irq_enable_sysexit)
11543 ENDPROC(native_irq_enable_sysexit)
11544 #endif
11545
11546 + .macro pax_enter_kernel_user
11547 + pax_set_fptr_mask
11548 +#ifdef CONFIG_PAX_MEMORY_UDEREF
11549 + call pax_enter_kernel_user
11550 +#endif
11551 + .endm
11552 +
11553 + .macro pax_exit_kernel_user
11554 +#ifdef CONFIG_PAX_MEMORY_UDEREF
11555 + call pax_exit_kernel_user
11556 +#endif
11557 +#ifdef CONFIG_PAX_RANDKSTACK
11558 + pushq %rax
11559 + pushq %r11
11560 + call pax_randomize_kstack
11561 + popq %r11
11562 + popq %rax
11563 +#endif
11564 + .endm
11565 +
11566 +.macro pax_erase_kstack
11567 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
11568 + call pax_erase_kstack
11569 +#endif
11570 +.endm
11571 +
11572 /*
11573 * 32bit SYSENTER instruction entry.
11574 *
11575 @@ -122,12 +150,6 @@ ENTRY(ia32_sysenter_target)
11576 CFI_REGISTER rsp,rbp
11577 SWAPGS_UNSAFE_STACK
11578 movq PER_CPU_VAR(kernel_stack), %rsp
11579 - addq $(KERNEL_STACK_OFFSET),%rsp
11580 - /*
11581 - * No need to follow this irqs on/off section: the syscall
11582 - * disabled irqs, here we enable it straight after entry:
11583 - */
11584 - ENABLE_INTERRUPTS(CLBR_NONE)
11585 movl %ebp,%ebp /* zero extension */
11586 pushq_cfi $__USER32_DS
11587 /*CFI_REL_OFFSET ss,0*/
11588 @@ -135,24 +157,44 @@ ENTRY(ia32_sysenter_target)
11589 CFI_REL_OFFSET rsp,0
11590 pushfq_cfi
11591 /*CFI_REL_OFFSET rflags,0*/
11592 - movl TI_sysenter_return+THREAD_INFO(%rsp,3*8-KERNEL_STACK_OFFSET),%r10d
11593 - CFI_REGISTER rip,r10
11594 + orl $X86_EFLAGS_IF,(%rsp)
11595 + GET_THREAD_INFO(%r11)
11596 + movl TI_sysenter_return(%r11), %r11d
11597 + CFI_REGISTER rip,r11
11598 pushq_cfi $__USER32_CS
11599 /*CFI_REL_OFFSET cs,0*/
11600 movl %eax, %eax
11601 - pushq_cfi %r10
11602 + pushq_cfi %r11
11603 CFI_REL_OFFSET rip,0
11604 pushq_cfi %rax
11605 cld
11606 SAVE_ARGS 0,1,0
11607 + pax_enter_kernel_user
11608 +
11609 +#ifdef CONFIG_PAX_RANDKSTACK
11610 + pax_erase_kstack
11611 +#endif
11612 +
11613 + /*
11614 + * No need to follow this irqs on/off section: the syscall
11615 + * disabled irqs, here we enable it straight after entry:
11616 + */
11617 + ENABLE_INTERRUPTS(CLBR_NONE)
11618 /* no need to do an access_ok check here because rbp has been
11619 32bit zero extended */
11620 +
11621 +#ifdef CONFIG_PAX_MEMORY_UDEREF
11622 + mov pax_user_shadow_base,%r11
11623 + add %r11,%rbp
11624 +#endif
11625 +
11626 ASM_STAC
11627 1: movl (%rbp),%ebp
11628 _ASM_EXTABLE(1b,ia32_badarg)
11629 ASM_CLAC
11630 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11631 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11632 + GET_THREAD_INFO(%r11)
11633 + orl $TS_COMPAT,TI_status(%r11)
11634 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
11635 CFI_REMEMBER_STATE
11636 jnz sysenter_tracesys
11637 cmpq $(IA32_NR_syscalls-1),%rax
11638 @@ -162,12 +204,15 @@ sysenter_do_call:
11639 sysenter_dispatch:
11640 call *ia32_sys_call_table(,%rax,8)
11641 movq %rax,RAX-ARGOFFSET(%rsp)
11642 + GET_THREAD_INFO(%r11)
11643 DISABLE_INTERRUPTS(CLBR_NONE)
11644 TRACE_IRQS_OFF
11645 - testl $_TIF_ALLWORK_MASK,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11646 + testl $_TIF_ALLWORK_MASK,TI_flags(%r11)
11647 jnz sysexit_audit
11648 sysexit_from_sys_call:
11649 - andl $~TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11650 + pax_exit_kernel_user
11651 + pax_erase_kstack
11652 + andl $~TS_COMPAT,TI_status(%r11)
11653 /* clear IF, that popfq doesn't enable interrupts early */
11654 andl $~0x200,EFLAGS-R11(%rsp)
11655 movl RIP-R11(%rsp),%edx /* User %eip */
11656 @@ -193,6 +238,9 @@ sysexit_from_sys_call:
11657 movl %eax,%esi /* 2nd arg: syscall number */
11658 movl $AUDIT_ARCH_I386,%edi /* 1st arg: audit arch */
11659 call __audit_syscall_entry
11660 +
11661 + pax_erase_kstack
11662 +
11663 movl RAX-ARGOFFSET(%rsp),%eax /* reload syscall number */
11664 cmpq $(IA32_NR_syscalls-1),%rax
11665 ja ia32_badsys
11666 @@ -204,7 +252,7 @@ sysexit_from_sys_call:
11667 .endm
11668
11669 .macro auditsys_exit exit
11670 - testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11671 + testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
11672 jnz ia32_ret_from_sys_call
11673 TRACE_IRQS_ON
11674 ENABLE_INTERRUPTS(CLBR_NONE)
11675 @@ -215,11 +263,12 @@ sysexit_from_sys_call:
11676 1: setbe %al /* 1 if error, 0 if not */
11677 movzbl %al,%edi /* zero-extend that into %edi */
11678 call __audit_syscall_exit
11679 + GET_THREAD_INFO(%r11)
11680 movq RAX-ARGOFFSET(%rsp),%rax /* reload syscall return value */
11681 movl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),%edi
11682 DISABLE_INTERRUPTS(CLBR_NONE)
11683 TRACE_IRQS_OFF
11684 - testl %edi,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11685 + testl %edi,TI_flags(%r11)
11686 jz \exit
11687 CLEAR_RREGS -ARGOFFSET
11688 jmp int_with_check
11689 @@ -237,7 +286,7 @@ sysexit_audit:
11690
11691 sysenter_tracesys:
11692 #ifdef CONFIG_AUDITSYSCALL
11693 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11694 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
11695 jz sysenter_auditsys
11696 #endif
11697 SAVE_REST
11698 @@ -249,6 +298,9 @@ sysenter_tracesys:
11699 RESTORE_REST
11700 cmpq $(IA32_NR_syscalls-1),%rax
11701 ja int_ret_from_sys_call /* sysenter_tracesys has set RAX(%rsp) */
11702 +
11703 + pax_erase_kstack
11704 +
11705 jmp sysenter_do_call
11706 CFI_ENDPROC
11707 ENDPROC(ia32_sysenter_target)
11708 @@ -276,19 +328,25 @@ ENDPROC(ia32_sysenter_target)
11709 ENTRY(ia32_cstar_target)
11710 CFI_STARTPROC32 simple
11711 CFI_SIGNAL_FRAME
11712 - CFI_DEF_CFA rsp,KERNEL_STACK_OFFSET
11713 + CFI_DEF_CFA rsp,0
11714 CFI_REGISTER rip,rcx
11715 /*CFI_REGISTER rflags,r11*/
11716 SWAPGS_UNSAFE_STACK
11717 movl %esp,%r8d
11718 CFI_REGISTER rsp,r8
11719 movq PER_CPU_VAR(kernel_stack),%rsp
11720 + SAVE_ARGS 8*6,0,0
11721 + pax_enter_kernel_user
11722 +
11723 +#ifdef CONFIG_PAX_RANDKSTACK
11724 + pax_erase_kstack
11725 +#endif
11726 +
11727 /*
11728 * No need to follow this irqs on/off section: the syscall
11729 * disabled irqs and here we enable it straight after entry:
11730 */
11731 ENABLE_INTERRUPTS(CLBR_NONE)
11732 - SAVE_ARGS 8,0,0
11733 movl %eax,%eax /* zero extension */
11734 movq %rax,ORIG_RAX-ARGOFFSET(%rsp)
11735 movq %rcx,RIP-ARGOFFSET(%rsp)
11736 @@ -304,12 +362,19 @@ ENTRY(ia32_cstar_target)
11737 /* no need to do an access_ok check here because r8 has been
11738 32bit zero extended */
11739 /* hardware stack frame is complete now */
11740 +
11741 +#ifdef CONFIG_PAX_MEMORY_UDEREF
11742 + mov pax_user_shadow_base,%r11
11743 + add %r11,%r8
11744 +#endif
11745 +
11746 ASM_STAC
11747 1: movl (%r8),%r9d
11748 _ASM_EXTABLE(1b,ia32_badarg)
11749 ASM_CLAC
11750 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11751 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11752 + GET_THREAD_INFO(%r11)
11753 + orl $TS_COMPAT,TI_status(%r11)
11754 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
11755 CFI_REMEMBER_STATE
11756 jnz cstar_tracesys
11757 cmpq $IA32_NR_syscalls-1,%rax
11758 @@ -319,12 +384,15 @@ cstar_do_call:
11759 cstar_dispatch:
11760 call *ia32_sys_call_table(,%rax,8)
11761 movq %rax,RAX-ARGOFFSET(%rsp)
11762 + GET_THREAD_INFO(%r11)
11763 DISABLE_INTERRUPTS(CLBR_NONE)
11764 TRACE_IRQS_OFF
11765 - testl $_TIF_ALLWORK_MASK,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11766 + testl $_TIF_ALLWORK_MASK,TI_flags(%r11)
11767 jnz sysretl_audit
11768 sysretl_from_sys_call:
11769 - andl $~TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11770 + pax_exit_kernel_user
11771 + pax_erase_kstack
11772 + andl $~TS_COMPAT,TI_status(%r11)
11773 RESTORE_ARGS 0,-ARG_SKIP,0,0,0
11774 movl RIP-ARGOFFSET(%rsp),%ecx
11775 CFI_REGISTER rip,rcx
11776 @@ -352,7 +420,7 @@ sysretl_audit:
11777
11778 cstar_tracesys:
11779 #ifdef CONFIG_AUDITSYSCALL
11780 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11781 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
11782 jz cstar_auditsys
11783 #endif
11784 xchgl %r9d,%ebp
11785 @@ -366,6 +434,9 @@ cstar_tracesys:
11786 xchgl %ebp,%r9d
11787 cmpq $(IA32_NR_syscalls-1),%rax
11788 ja int_ret_from_sys_call /* cstar_tracesys has set RAX(%rsp) */
11789 +
11790 + pax_erase_kstack
11791 +
11792 jmp cstar_do_call
11793 END(ia32_cstar_target)
11794
11795 @@ -407,19 +478,26 @@ ENTRY(ia32_syscall)
11796 CFI_REL_OFFSET rip,RIP-RIP
11797 PARAVIRT_ADJUST_EXCEPTION_FRAME
11798 SWAPGS
11799 - /*
11800 - * No need to follow this irqs on/off section: the syscall
11801 - * disabled irqs and here we enable it straight after entry:
11802 - */
11803 - ENABLE_INTERRUPTS(CLBR_NONE)
11804 movl %eax,%eax
11805 pushq_cfi %rax
11806 cld
11807 /* note the registers are not zero extended to the sf.
11808 this could be a problem. */
11809 SAVE_ARGS 0,1,0
11810 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11811 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11812 + pax_enter_kernel_user
11813 +
11814 +#ifdef CONFIG_PAX_RANDKSTACK
11815 + pax_erase_kstack
11816 +#endif
11817 +
11818 + /*
11819 + * No need to follow this irqs on/off section: the syscall
11820 + * disabled irqs and here we enable it straight after entry:
11821 + */
11822 + ENABLE_INTERRUPTS(CLBR_NONE)
11823 + GET_THREAD_INFO(%r11)
11824 + orl $TS_COMPAT,TI_status(%r11)
11825 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
11826 jnz ia32_tracesys
11827 cmpq $(IA32_NR_syscalls-1),%rax
11828 ja ia32_badsys
11829 @@ -442,6 +520,9 @@ ia32_tracesys:
11830 RESTORE_REST
11831 cmpq $(IA32_NR_syscalls-1),%rax
11832 ja int_ret_from_sys_call /* ia32_tracesys has set RAX(%rsp) */
11833 +
11834 + pax_erase_kstack
11835 +
11836 jmp ia32_do_call
11837 END(ia32_syscall)
11838
11839 diff --git a/arch/x86/ia32/sys_ia32.c b/arch/x86/ia32/sys_ia32.c
11840 index ad7a20c..1ffa3c1 100644
11841 --- a/arch/x86/ia32/sys_ia32.c
11842 +++ b/arch/x86/ia32/sys_ia32.c
11843 @@ -69,8 +69,8 @@ asmlinkage long sys32_ftruncate64(unsigned int fd, unsigned long offset_low,
11844 */
11845 static int cp_stat64(struct stat64 __user *ubuf, struct kstat *stat)
11846 {
11847 - typeof(ubuf->st_uid) uid = 0;
11848 - typeof(ubuf->st_gid) gid = 0;
11849 + typeof(((struct stat64 *)0)->st_uid) uid = 0;
11850 + typeof(((struct stat64 *)0)->st_gid) gid = 0;
11851 SET_UID(uid, from_kuid_munged(current_user_ns(), stat->uid));
11852 SET_GID(gid, from_kgid_munged(current_user_ns(), stat->gid));
11853 if (!access_ok(VERIFY_WRITE, ubuf, sizeof(struct stat64)) ||
11854 @@ -205,7 +205,7 @@ asmlinkage long sys32_sendfile(int out_fd, int in_fd,
11855 return -EFAULT;
11856
11857 set_fs(KERNEL_DS);
11858 - ret = sys_sendfile(out_fd, in_fd, offset ? (off_t __user *)&of : NULL,
11859 + ret = sys_sendfile(out_fd, in_fd, offset ? (off_t __force_user *)&of : NULL,
11860 count);
11861 set_fs(old_fs);
11862
11863 diff --git a/arch/x86/include/asm/alternative-asm.h b/arch/x86/include/asm/alternative-asm.h
11864 index 372231c..a5aa1a1 100644
11865 --- a/arch/x86/include/asm/alternative-asm.h
11866 +++ b/arch/x86/include/asm/alternative-asm.h
11867 @@ -18,6 +18,45 @@
11868 .endm
11869 #endif
11870
11871 +#ifdef KERNEXEC_PLUGIN
11872 + .macro pax_force_retaddr_bts rip=0
11873 + btsq $63,\rip(%rsp)
11874 + .endm
11875 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_BTS
11876 + .macro pax_force_retaddr rip=0, reload=0
11877 + btsq $63,\rip(%rsp)
11878 + .endm
11879 + .macro pax_force_fptr ptr
11880 + btsq $63,\ptr
11881 + .endm
11882 + .macro pax_set_fptr_mask
11883 + .endm
11884 +#endif
11885 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
11886 + .macro pax_force_retaddr rip=0, reload=0
11887 + .if \reload
11888 + pax_set_fptr_mask
11889 + .endif
11890 + orq %r10,\rip(%rsp)
11891 + .endm
11892 + .macro pax_force_fptr ptr
11893 + orq %r10,\ptr
11894 + .endm
11895 + .macro pax_set_fptr_mask
11896 + movabs $0x8000000000000000,%r10
11897 + .endm
11898 +#endif
11899 +#else
11900 + .macro pax_force_retaddr rip=0, reload=0
11901 + .endm
11902 + .macro pax_force_fptr ptr
11903 + .endm
11904 + .macro pax_force_retaddr_bts rip=0
11905 + .endm
11906 + .macro pax_set_fptr_mask
11907 + .endm
11908 +#endif
11909 +
11910 .macro altinstruction_entry orig alt feature orig_len alt_len
11911 .long \orig - .
11912 .long \alt - .
11913 diff --git a/arch/x86/include/asm/alternative.h b/arch/x86/include/asm/alternative.h
11914 index 58ed6d9..f1cbe58 100644
11915 --- a/arch/x86/include/asm/alternative.h
11916 +++ b/arch/x86/include/asm/alternative.h
11917 @@ -105,7 +105,7 @@ static inline int alternatives_text_reserved(void *start, void *end)
11918 ".pushsection .discard,\"aw\",@progbits\n" \
11919 DISCARD_ENTRY(1) \
11920 ".popsection\n" \
11921 - ".pushsection .altinstr_replacement, \"ax\"\n" \
11922 + ".pushsection .altinstr_replacement, \"a\"\n" \
11923 ALTINSTR_REPLACEMENT(newinstr, feature, 1) \
11924 ".popsection"
11925
11926 @@ -119,7 +119,7 @@ static inline int alternatives_text_reserved(void *start, void *end)
11927 DISCARD_ENTRY(1) \
11928 DISCARD_ENTRY(2) \
11929 ".popsection\n" \
11930 - ".pushsection .altinstr_replacement, \"ax\"\n" \
11931 + ".pushsection .altinstr_replacement, \"a\"\n" \
11932 ALTINSTR_REPLACEMENT(newinstr1, feature1, 1) \
11933 ALTINSTR_REPLACEMENT(newinstr2, feature2, 2) \
11934 ".popsection"
11935 diff --git a/arch/x86/include/asm/apic.h b/arch/x86/include/asm/apic.h
11936 index 3388034..050f0b9 100644
11937 --- a/arch/x86/include/asm/apic.h
11938 +++ b/arch/x86/include/asm/apic.h
11939 @@ -44,7 +44,7 @@ static inline void generic_apic_probe(void)
11940
11941 #ifdef CONFIG_X86_LOCAL_APIC
11942
11943 -extern unsigned int apic_verbosity;
11944 +extern int apic_verbosity;
11945 extern int local_apic_timer_c2_ok;
11946
11947 extern int disable_apic;
11948 diff --git a/arch/x86/include/asm/apm.h b/arch/x86/include/asm/apm.h
11949 index 20370c6..a2eb9b0 100644
11950 --- a/arch/x86/include/asm/apm.h
11951 +++ b/arch/x86/include/asm/apm.h
11952 @@ -34,7 +34,7 @@ static inline void apm_bios_call_asm(u32 func, u32 ebx_in, u32 ecx_in,
11953 __asm__ __volatile__(APM_DO_ZERO_SEGS
11954 "pushl %%edi\n\t"
11955 "pushl %%ebp\n\t"
11956 - "lcall *%%cs:apm_bios_entry\n\t"
11957 + "lcall *%%ss:apm_bios_entry\n\t"
11958 "setc %%al\n\t"
11959 "popl %%ebp\n\t"
11960 "popl %%edi\n\t"
11961 @@ -58,7 +58,7 @@ static inline u8 apm_bios_call_simple_asm(u32 func, u32 ebx_in,
11962 __asm__ __volatile__(APM_DO_ZERO_SEGS
11963 "pushl %%edi\n\t"
11964 "pushl %%ebp\n\t"
11965 - "lcall *%%cs:apm_bios_entry\n\t"
11966 + "lcall *%%ss:apm_bios_entry\n\t"
11967 "setc %%bl\n\t"
11968 "popl %%ebp\n\t"
11969 "popl %%edi\n\t"
11970 diff --git a/arch/x86/include/asm/atomic.h b/arch/x86/include/asm/atomic.h
11971 index 722aa3b..3a0bb27 100644
11972 --- a/arch/x86/include/asm/atomic.h
11973 +++ b/arch/x86/include/asm/atomic.h
11974 @@ -22,7 +22,18 @@
11975 */
11976 static inline int atomic_read(const atomic_t *v)
11977 {
11978 - return (*(volatile int *)&(v)->counter);
11979 + return (*(volatile const int *)&(v)->counter);
11980 +}
11981 +
11982 +/**
11983 + * atomic_read_unchecked - read atomic variable
11984 + * @v: pointer of type atomic_unchecked_t
11985 + *
11986 + * Atomically reads the value of @v.
11987 + */
11988 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
11989 +{
11990 + return (*(volatile const int *)&(v)->counter);
11991 }
11992
11993 /**
11994 @@ -38,6 +49,18 @@ static inline void atomic_set(atomic_t *v, int i)
11995 }
11996
11997 /**
11998 + * atomic_set_unchecked - set atomic variable
11999 + * @v: pointer of type atomic_unchecked_t
12000 + * @i: required value
12001 + *
12002 + * Atomically sets the value of @v to @i.
12003 + */
12004 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
12005 +{
12006 + v->counter = i;
12007 +}
12008 +
12009 +/**
12010 * atomic_add - add integer to atomic variable
12011 * @i: integer value to add
12012 * @v: pointer of type atomic_t
12013 @@ -46,7 +69,29 @@ static inline void atomic_set(atomic_t *v, int i)
12014 */
12015 static inline void atomic_add(int i, atomic_t *v)
12016 {
12017 - asm volatile(LOCK_PREFIX "addl %1,%0"
12018 + asm volatile(LOCK_PREFIX "addl %1,%0\n"
12019 +
12020 +#ifdef CONFIG_PAX_REFCOUNT
12021 + "jno 0f\n"
12022 + LOCK_PREFIX "subl %1,%0\n"
12023 + "int $4\n0:\n"
12024 + _ASM_EXTABLE(0b, 0b)
12025 +#endif
12026 +
12027 + : "+m" (v->counter)
12028 + : "ir" (i));
12029 +}
12030 +
12031 +/**
12032 + * atomic_add_unchecked - add integer to atomic variable
12033 + * @i: integer value to add
12034 + * @v: pointer of type atomic_unchecked_t
12035 + *
12036 + * Atomically adds @i to @v.
12037 + */
12038 +static inline void atomic_add_unchecked(int i, atomic_unchecked_t *v)
12039 +{
12040 + asm volatile(LOCK_PREFIX "addl %1,%0\n"
12041 : "+m" (v->counter)
12042 : "ir" (i));
12043 }
12044 @@ -60,7 +105,29 @@ static inline void atomic_add(int i, atomic_t *v)
12045 */
12046 static inline void atomic_sub(int i, atomic_t *v)
12047 {
12048 - asm volatile(LOCK_PREFIX "subl %1,%0"
12049 + asm volatile(LOCK_PREFIX "subl %1,%0\n"
12050 +
12051 +#ifdef CONFIG_PAX_REFCOUNT
12052 + "jno 0f\n"
12053 + LOCK_PREFIX "addl %1,%0\n"
12054 + "int $4\n0:\n"
12055 + _ASM_EXTABLE(0b, 0b)
12056 +#endif
12057 +
12058 + : "+m" (v->counter)
12059 + : "ir" (i));
12060 +}
12061 +
12062 +/**
12063 + * atomic_sub_unchecked - subtract integer from atomic variable
12064 + * @i: integer value to subtract
12065 + * @v: pointer of type atomic_unchecked_t
12066 + *
12067 + * Atomically subtracts @i from @v.
12068 + */
12069 +static inline void atomic_sub_unchecked(int i, atomic_unchecked_t *v)
12070 +{
12071 + asm volatile(LOCK_PREFIX "subl %1,%0\n"
12072 : "+m" (v->counter)
12073 : "ir" (i));
12074 }
12075 @@ -78,7 +145,16 @@ static inline int atomic_sub_and_test(int i, atomic_t *v)
12076 {
12077 unsigned char c;
12078
12079 - asm volatile(LOCK_PREFIX "subl %2,%0; sete %1"
12080 + asm volatile(LOCK_PREFIX "subl %2,%0\n"
12081 +
12082 +#ifdef CONFIG_PAX_REFCOUNT
12083 + "jno 0f\n"
12084 + LOCK_PREFIX "addl %2,%0\n"
12085 + "int $4\n0:\n"
12086 + _ASM_EXTABLE(0b, 0b)
12087 +#endif
12088 +
12089 + "sete %1\n"
12090 : "+m" (v->counter), "=qm" (c)
12091 : "ir" (i) : "memory");
12092 return c;
12093 @@ -92,7 +168,27 @@ static inline int atomic_sub_and_test(int i, atomic_t *v)
12094 */
12095 static inline void atomic_inc(atomic_t *v)
12096 {
12097 - asm volatile(LOCK_PREFIX "incl %0"
12098 + asm volatile(LOCK_PREFIX "incl %0\n"
12099 +
12100 +#ifdef CONFIG_PAX_REFCOUNT
12101 + "jno 0f\n"
12102 + LOCK_PREFIX "decl %0\n"
12103 + "int $4\n0:\n"
12104 + _ASM_EXTABLE(0b, 0b)
12105 +#endif
12106 +
12107 + : "+m" (v->counter));
12108 +}
12109 +
12110 +/**
12111 + * atomic_inc_unchecked - increment atomic variable
12112 + * @v: pointer of type atomic_unchecked_t
12113 + *
12114 + * Atomically increments @v by 1.
12115 + */
12116 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
12117 +{
12118 + asm volatile(LOCK_PREFIX "incl %0\n"
12119 : "+m" (v->counter));
12120 }
12121
12122 @@ -104,7 +200,27 @@ static inline void atomic_inc(atomic_t *v)
12123 */
12124 static inline void atomic_dec(atomic_t *v)
12125 {
12126 - asm volatile(LOCK_PREFIX "decl %0"
12127 + asm volatile(LOCK_PREFIX "decl %0\n"
12128 +
12129 +#ifdef CONFIG_PAX_REFCOUNT
12130 + "jno 0f\n"
12131 + LOCK_PREFIX "incl %0\n"
12132 + "int $4\n0:\n"
12133 + _ASM_EXTABLE(0b, 0b)
12134 +#endif
12135 +
12136 + : "+m" (v->counter));
12137 +}
12138 +
12139 +/**
12140 + * atomic_dec_unchecked - decrement atomic variable
12141 + * @v: pointer of type atomic_unchecked_t
12142 + *
12143 + * Atomically decrements @v by 1.
12144 + */
12145 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
12146 +{
12147 + asm volatile(LOCK_PREFIX "decl %0\n"
12148 : "+m" (v->counter));
12149 }
12150
12151 @@ -120,7 +236,16 @@ static inline int atomic_dec_and_test(atomic_t *v)
12152 {
12153 unsigned char c;
12154
12155 - asm volatile(LOCK_PREFIX "decl %0; sete %1"
12156 + asm volatile(LOCK_PREFIX "decl %0\n"
12157 +
12158 +#ifdef CONFIG_PAX_REFCOUNT
12159 + "jno 0f\n"
12160 + LOCK_PREFIX "incl %0\n"
12161 + "int $4\n0:\n"
12162 + _ASM_EXTABLE(0b, 0b)
12163 +#endif
12164 +
12165 + "sete %1\n"
12166 : "+m" (v->counter), "=qm" (c)
12167 : : "memory");
12168 return c != 0;
12169 @@ -138,7 +263,35 @@ static inline int atomic_inc_and_test(atomic_t *v)
12170 {
12171 unsigned char c;
12172
12173 - asm volatile(LOCK_PREFIX "incl %0; sete %1"
12174 + asm volatile(LOCK_PREFIX "incl %0\n"
12175 +
12176 +#ifdef CONFIG_PAX_REFCOUNT
12177 + "jno 0f\n"
12178 + LOCK_PREFIX "decl %0\n"
12179 + "int $4\n0:\n"
12180 + _ASM_EXTABLE(0b, 0b)
12181 +#endif
12182 +
12183 + "sete %1\n"
12184 + : "+m" (v->counter), "=qm" (c)
12185 + : : "memory");
12186 + return c != 0;
12187 +}
12188 +
12189 +/**
12190 + * atomic_inc_and_test_unchecked - increment and test
12191 + * @v: pointer of type atomic_unchecked_t
12192 + *
12193 + * Atomically increments @v by 1
12194 + * and returns true if the result is zero, or false for all
12195 + * other cases.
12196 + */
12197 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
12198 +{
12199 + unsigned char c;
12200 +
12201 + asm volatile(LOCK_PREFIX "incl %0\n"
12202 + "sete %1\n"
12203 : "+m" (v->counter), "=qm" (c)
12204 : : "memory");
12205 return c != 0;
12206 @@ -157,7 +310,16 @@ static inline int atomic_add_negative(int i, atomic_t *v)
12207 {
12208 unsigned char c;
12209
12210 - asm volatile(LOCK_PREFIX "addl %2,%0; sets %1"
12211 + asm volatile(LOCK_PREFIX "addl %2,%0\n"
12212 +
12213 +#ifdef CONFIG_PAX_REFCOUNT
12214 + "jno 0f\n"
12215 + LOCK_PREFIX "subl %2,%0\n"
12216 + "int $4\n0:\n"
12217 + _ASM_EXTABLE(0b, 0b)
12218 +#endif
12219 +
12220 + "sets %1\n"
12221 : "+m" (v->counter), "=qm" (c)
12222 : "ir" (i) : "memory");
12223 return c;
12224 @@ -172,6 +334,18 @@ static inline int atomic_add_negative(int i, atomic_t *v)
12225 */
12226 static inline int atomic_add_return(int i, atomic_t *v)
12227 {
12228 + return i + xadd_check_overflow(&v->counter, i);
12229 +}
12230 +
12231 +/**
12232 + * atomic_add_return_unchecked - add integer and return
12233 + * @i: integer value to add
12234 + * @v: pointer of type atomic_unchecked_t
12235 + *
12236 + * Atomically adds @i to @v and returns @i + @v
12237 + */
12238 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
12239 +{
12240 return i + xadd(&v->counter, i);
12241 }
12242
12243 @@ -188,6 +362,10 @@ static inline int atomic_sub_return(int i, atomic_t *v)
12244 }
12245
12246 #define atomic_inc_return(v) (atomic_add_return(1, v))
12247 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
12248 +{
12249 + return atomic_add_return_unchecked(1, v);
12250 +}
12251 #define atomic_dec_return(v) (atomic_sub_return(1, v))
12252
12253 static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
12254 @@ -195,11 +373,21 @@ static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
12255 return cmpxchg(&v->counter, old, new);
12256 }
12257
12258 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
12259 +{
12260 + return cmpxchg(&v->counter, old, new);
12261 +}
12262 +
12263 static inline int atomic_xchg(atomic_t *v, int new)
12264 {
12265 return xchg(&v->counter, new);
12266 }
12267
12268 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
12269 +{
12270 + return xchg(&v->counter, new);
12271 +}
12272 +
12273 /**
12274 * __atomic_add_unless - add unless the number is already a given value
12275 * @v: pointer of type atomic_t
12276 @@ -211,12 +399,25 @@ static inline int atomic_xchg(atomic_t *v, int new)
12277 */
12278 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
12279 {
12280 - int c, old;
12281 + int c, old, new;
12282 c = atomic_read(v);
12283 for (;;) {
12284 - if (unlikely(c == (u)))
12285 + if (unlikely(c == u))
12286 break;
12287 - old = atomic_cmpxchg((v), c, c + (a));
12288 +
12289 + asm volatile("addl %2,%0\n"
12290 +
12291 +#ifdef CONFIG_PAX_REFCOUNT
12292 + "jno 0f\n"
12293 + "subl %2,%0\n"
12294 + "int $4\n0:\n"
12295 + _ASM_EXTABLE(0b, 0b)
12296 +#endif
12297 +
12298 + : "=r" (new)
12299 + : "0" (c), "ir" (a));
12300 +
12301 + old = atomic_cmpxchg(v, c, new);
12302 if (likely(old == c))
12303 break;
12304 c = old;
12305 @@ -225,6 +426,49 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
12306 }
12307
12308 /**
12309 + * atomic_inc_not_zero_hint - increment if not null
12310 + * @v: pointer of type atomic_t
12311 + * @hint: probable value of the atomic before the increment
12312 + *
12313 + * This version of atomic_inc_not_zero() gives a hint of probable
12314 + * value of the atomic. This helps processor to not read the memory
12315 + * before doing the atomic read/modify/write cycle, lowering
12316 + * number of bus transactions on some arches.
12317 + *
12318 + * Returns: 0 if increment was not done, 1 otherwise.
12319 + */
12320 +#define atomic_inc_not_zero_hint atomic_inc_not_zero_hint
12321 +static inline int atomic_inc_not_zero_hint(atomic_t *v, int hint)
12322 +{
12323 + int val, c = hint, new;
12324 +
12325 + /* sanity test, should be removed by compiler if hint is a constant */
12326 + if (!hint)
12327 + return __atomic_add_unless(v, 1, 0);
12328 +
12329 + do {
12330 + asm volatile("incl %0\n"
12331 +
12332 +#ifdef CONFIG_PAX_REFCOUNT
12333 + "jno 0f\n"
12334 + "decl %0\n"
12335 + "int $4\n0:\n"
12336 + _ASM_EXTABLE(0b, 0b)
12337 +#endif
12338 +
12339 + : "=r" (new)
12340 + : "0" (c));
12341 +
12342 + val = atomic_cmpxchg(v, c, new);
12343 + if (val == c)
12344 + return 1;
12345 + c = val;
12346 + } while (c);
12347 +
12348 + return 0;
12349 +}
12350 +
12351 +/**
12352 * atomic_inc_short - increment of a short integer
12353 * @v: pointer to type int
12354 *
12355 @@ -253,14 +497,37 @@ static inline void atomic_or_long(unsigned long *v1, unsigned long v2)
12356 #endif
12357
12358 /* These are x86-specific, used by some header files */
12359 -#define atomic_clear_mask(mask, addr) \
12360 - asm volatile(LOCK_PREFIX "andl %0,%1" \
12361 - : : "r" (~(mask)), "m" (*(addr)) : "memory")
12362 +static inline void atomic_clear_mask(unsigned int mask, atomic_t *v)
12363 +{
12364 + asm volatile(LOCK_PREFIX "andl %1,%0"
12365 + : "+m" (v->counter)
12366 + : "r" (~(mask))
12367 + : "memory");
12368 +}
12369
12370 -#define atomic_set_mask(mask, addr) \
12371 - asm volatile(LOCK_PREFIX "orl %0,%1" \
12372 - : : "r" ((unsigned)(mask)), "m" (*(addr)) \
12373 - : "memory")
12374 +static inline void atomic_clear_mask_unchecked(unsigned int mask, atomic_unchecked_t *v)
12375 +{
12376 + asm volatile(LOCK_PREFIX "andl %1,%0"
12377 + : "+m" (v->counter)
12378 + : "r" (~(mask))
12379 + : "memory");
12380 +}
12381 +
12382 +static inline void atomic_set_mask(unsigned int mask, atomic_t *v)
12383 +{
12384 + asm volatile(LOCK_PREFIX "orl %1,%0"
12385 + : "+m" (v->counter)
12386 + : "r" (mask)
12387 + : "memory");
12388 +}
12389 +
12390 +static inline void atomic_set_mask_unchecked(unsigned int mask, atomic_unchecked_t *v)
12391 +{
12392 + asm volatile(LOCK_PREFIX "orl %1,%0"
12393 + : "+m" (v->counter)
12394 + : "r" (mask)
12395 + : "memory");
12396 +}
12397
12398 /* Atomic operations are already serializing on x86 */
12399 #define smp_mb__before_atomic_dec() barrier()
12400 diff --git a/arch/x86/include/asm/atomic64_32.h b/arch/x86/include/asm/atomic64_32.h
12401 index b154de7..aadebd8 100644
12402 --- a/arch/x86/include/asm/atomic64_32.h
12403 +++ b/arch/x86/include/asm/atomic64_32.h
12404 @@ -12,6 +12,14 @@ typedef struct {
12405 u64 __aligned(8) counter;
12406 } atomic64_t;
12407
12408 +#ifdef CONFIG_PAX_REFCOUNT
12409 +typedef struct {
12410 + u64 __aligned(8) counter;
12411 +} atomic64_unchecked_t;
12412 +#else
12413 +typedef atomic64_t atomic64_unchecked_t;
12414 +#endif
12415 +
12416 #define ATOMIC64_INIT(val) { (val) }
12417
12418 #define __ATOMIC64_DECL(sym) void atomic64_##sym(atomic64_t *, ...)
12419 @@ -37,21 +45,31 @@ typedef struct {
12420 ATOMIC64_DECL_ONE(sym##_386)
12421
12422 ATOMIC64_DECL_ONE(add_386);
12423 +ATOMIC64_DECL_ONE(add_unchecked_386);
12424 ATOMIC64_DECL_ONE(sub_386);
12425 +ATOMIC64_DECL_ONE(sub_unchecked_386);
12426 ATOMIC64_DECL_ONE(inc_386);
12427 +ATOMIC64_DECL_ONE(inc_unchecked_386);
12428 ATOMIC64_DECL_ONE(dec_386);
12429 +ATOMIC64_DECL_ONE(dec_unchecked_386);
12430 #endif
12431
12432 #define alternative_atomic64(f, out, in...) \
12433 __alternative_atomic64(f, f, ASM_OUTPUT2(out), ## in)
12434
12435 ATOMIC64_DECL(read);
12436 +ATOMIC64_DECL(read_unchecked);
12437 ATOMIC64_DECL(set);
12438 +ATOMIC64_DECL(set_unchecked);
12439 ATOMIC64_DECL(xchg);
12440 ATOMIC64_DECL(add_return);
12441 +ATOMIC64_DECL(add_return_unchecked);
12442 ATOMIC64_DECL(sub_return);
12443 +ATOMIC64_DECL(sub_return_unchecked);
12444 ATOMIC64_DECL(inc_return);
12445 +ATOMIC64_DECL(inc_return_unchecked);
12446 ATOMIC64_DECL(dec_return);
12447 +ATOMIC64_DECL(dec_return_unchecked);
12448 ATOMIC64_DECL(dec_if_positive);
12449 ATOMIC64_DECL(inc_not_zero);
12450 ATOMIC64_DECL(add_unless);
12451 @@ -77,6 +95,21 @@ static inline long long atomic64_cmpxchg(atomic64_t *v, long long o, long long n
12452 }
12453
12454 /**
12455 + * atomic64_cmpxchg_unchecked - cmpxchg atomic64 variable
12456 + * @p: pointer to type atomic64_unchecked_t
12457 + * @o: expected value
12458 + * @n: new value
12459 + *
12460 + * Atomically sets @v to @n if it was equal to @o and returns
12461 + * the old value.
12462 + */
12463 +
12464 +static inline long long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long long o, long long n)
12465 +{
12466 + return cmpxchg64(&v->counter, o, n);
12467 +}
12468 +
12469 +/**
12470 * atomic64_xchg - xchg atomic64 variable
12471 * @v: pointer to type atomic64_t
12472 * @n: value to assign
12473 @@ -112,6 +145,22 @@ static inline void atomic64_set(atomic64_t *v, long long i)
12474 }
12475
12476 /**
12477 + * atomic64_set_unchecked - set atomic64 variable
12478 + * @v: pointer to type atomic64_unchecked_t
12479 + * @n: value to assign
12480 + *
12481 + * Atomically sets the value of @v to @n.
12482 + */
12483 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long long i)
12484 +{
12485 + unsigned high = (unsigned)(i >> 32);
12486 + unsigned low = (unsigned)i;
12487 + alternative_atomic64(set, /* no output */,
12488 + "S" (v), "b" (low), "c" (high)
12489 + : "eax", "edx", "memory");
12490 +}
12491 +
12492 +/**
12493 * atomic64_read - read atomic64 variable
12494 * @v: pointer to type atomic64_t
12495 *
12496 @@ -125,6 +174,19 @@ static inline long long atomic64_read(const atomic64_t *v)
12497 }
12498
12499 /**
12500 + * atomic64_read_unchecked - read atomic64 variable
12501 + * @v: pointer to type atomic64_unchecked_t
12502 + *
12503 + * Atomically reads the value of @v and returns it.
12504 + */
12505 +static inline long long atomic64_read_unchecked(atomic64_unchecked_t *v)
12506 +{
12507 + long long r;
12508 + alternative_atomic64(read, "=&A" (r), "c" (v) : "memory");
12509 + return r;
12510 + }
12511 +
12512 +/**
12513 * atomic64_add_return - add and return
12514 * @i: integer value to add
12515 * @v: pointer to type atomic64_t
12516 @@ -139,6 +201,21 @@ static inline long long atomic64_add_return(long long i, atomic64_t *v)
12517 return i;
12518 }
12519
12520 +/**
12521 + * atomic64_add_return_unchecked - add and return
12522 + * @i: integer value to add
12523 + * @v: pointer to type atomic64_unchecked_t
12524 + *
12525 + * Atomically adds @i to @v and returns @i + *@v
12526 + */
12527 +static inline long long atomic64_add_return_unchecked(long long i, atomic64_unchecked_t *v)
12528 +{
12529 + alternative_atomic64(add_return_unchecked,
12530 + ASM_OUTPUT2("+A" (i), "+c" (v)),
12531 + ASM_NO_INPUT_CLOBBER("memory"));
12532 + return i;
12533 +}
12534 +
12535 /*
12536 * Other variants with different arithmetic operators:
12537 */
12538 @@ -158,6 +235,14 @@ static inline long long atomic64_inc_return(atomic64_t *v)
12539 return a;
12540 }
12541
12542 +static inline long long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
12543 +{
12544 + long long a;
12545 + alternative_atomic64(inc_return_unchecked, "=&A" (a),
12546 + "S" (v) : "memory", "ecx");
12547 + return a;
12548 +}
12549 +
12550 static inline long long atomic64_dec_return(atomic64_t *v)
12551 {
12552 long long a;
12553 @@ -182,6 +267,21 @@ static inline long long atomic64_add(long long i, atomic64_t *v)
12554 }
12555
12556 /**
12557 + * atomic64_add_unchecked - add integer to atomic64 variable
12558 + * @i: integer value to add
12559 + * @v: pointer to type atomic64_unchecked_t
12560 + *
12561 + * Atomically adds @i to @v.
12562 + */
12563 +static inline long long atomic64_add_unchecked(long long i, atomic64_unchecked_t *v)
12564 +{
12565 + __alternative_atomic64(add_unchecked, add_return_unchecked,
12566 + ASM_OUTPUT2("+A" (i), "+c" (v)),
12567 + ASM_NO_INPUT_CLOBBER("memory"));
12568 + return i;
12569 +}
12570 +
12571 +/**
12572 * atomic64_sub - subtract the atomic64 variable
12573 * @i: integer value to subtract
12574 * @v: pointer to type atomic64_t
12575 diff --git a/arch/x86/include/asm/atomic64_64.h b/arch/x86/include/asm/atomic64_64.h
12576 index 0e1cbfc..5623683 100644
12577 --- a/arch/x86/include/asm/atomic64_64.h
12578 +++ b/arch/x86/include/asm/atomic64_64.h
12579 @@ -18,7 +18,19 @@
12580 */
12581 static inline long atomic64_read(const atomic64_t *v)
12582 {
12583 - return (*(volatile long *)&(v)->counter);
12584 + return (*(volatile const long *)&(v)->counter);
12585 +}
12586 +
12587 +/**
12588 + * atomic64_read_unchecked - read atomic64 variable
12589 + * @v: pointer of type atomic64_unchecked_t
12590 + *
12591 + * Atomically reads the value of @v.
12592 + * Doesn't imply a read memory barrier.
12593 + */
12594 +static inline long atomic64_read_unchecked(const atomic64_unchecked_t *v)
12595 +{
12596 + return (*(volatile const long *)&(v)->counter);
12597 }
12598
12599 /**
12600 @@ -34,6 +46,18 @@ static inline void atomic64_set(atomic64_t *v, long i)
12601 }
12602
12603 /**
12604 + * atomic64_set_unchecked - set atomic64 variable
12605 + * @v: pointer to type atomic64_unchecked_t
12606 + * @i: required value
12607 + *
12608 + * Atomically sets the value of @v to @i.
12609 + */
12610 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
12611 +{
12612 + v->counter = i;
12613 +}
12614 +
12615 +/**
12616 * atomic64_add - add integer to atomic64 variable
12617 * @i: integer value to add
12618 * @v: pointer to type atomic64_t
12619 @@ -42,6 +66,28 @@ static inline void atomic64_set(atomic64_t *v, long i)
12620 */
12621 static inline void atomic64_add(long i, atomic64_t *v)
12622 {
12623 + asm volatile(LOCK_PREFIX "addq %1,%0\n"
12624 +
12625 +#ifdef CONFIG_PAX_REFCOUNT
12626 + "jno 0f\n"
12627 + LOCK_PREFIX "subq %1,%0\n"
12628 + "int $4\n0:\n"
12629 + _ASM_EXTABLE(0b, 0b)
12630 +#endif
12631 +
12632 + : "=m" (v->counter)
12633 + : "er" (i), "m" (v->counter));
12634 +}
12635 +
12636 +/**
12637 + * atomic64_add_unchecked - add integer to atomic64 variable
12638 + * @i: integer value to add
12639 + * @v: pointer to type atomic64_unchecked_t
12640 + *
12641 + * Atomically adds @i to @v.
12642 + */
12643 +static inline void atomic64_add_unchecked(long i, atomic64_unchecked_t *v)
12644 +{
12645 asm volatile(LOCK_PREFIX "addq %1,%0"
12646 : "=m" (v->counter)
12647 : "er" (i), "m" (v->counter));
12648 @@ -56,7 +102,29 @@ static inline void atomic64_add(long i, atomic64_t *v)
12649 */
12650 static inline void atomic64_sub(long i, atomic64_t *v)
12651 {
12652 - asm volatile(LOCK_PREFIX "subq %1,%0"
12653 + asm volatile(LOCK_PREFIX "subq %1,%0\n"
12654 +
12655 +#ifdef CONFIG_PAX_REFCOUNT
12656 + "jno 0f\n"
12657 + LOCK_PREFIX "addq %1,%0\n"
12658 + "int $4\n0:\n"
12659 + _ASM_EXTABLE(0b, 0b)
12660 +#endif
12661 +
12662 + : "=m" (v->counter)
12663 + : "er" (i), "m" (v->counter));
12664 +}
12665 +
12666 +/**
12667 + * atomic64_sub_unchecked - subtract the atomic64 variable
12668 + * @i: integer value to subtract
12669 + * @v: pointer to type atomic64_unchecked_t
12670 + *
12671 + * Atomically subtracts @i from @v.
12672 + */
12673 +static inline void atomic64_sub_unchecked(long i, atomic64_unchecked_t *v)
12674 +{
12675 + asm volatile(LOCK_PREFIX "subq %1,%0\n"
12676 : "=m" (v->counter)
12677 : "er" (i), "m" (v->counter));
12678 }
12679 @@ -74,7 +142,16 @@ static inline int atomic64_sub_and_test(long i, atomic64_t *v)
12680 {
12681 unsigned char c;
12682
12683 - asm volatile(LOCK_PREFIX "subq %2,%0; sete %1"
12684 + asm volatile(LOCK_PREFIX "subq %2,%0\n"
12685 +
12686 +#ifdef CONFIG_PAX_REFCOUNT
12687 + "jno 0f\n"
12688 + LOCK_PREFIX "addq %2,%0\n"
12689 + "int $4\n0:\n"
12690 + _ASM_EXTABLE(0b, 0b)
12691 +#endif
12692 +
12693 + "sete %1\n"
12694 : "=m" (v->counter), "=qm" (c)
12695 : "er" (i), "m" (v->counter) : "memory");
12696 return c;
12697 @@ -88,6 +165,27 @@ static inline int atomic64_sub_and_test(long i, atomic64_t *v)
12698 */
12699 static inline void atomic64_inc(atomic64_t *v)
12700 {
12701 + asm volatile(LOCK_PREFIX "incq %0\n"
12702 +
12703 +#ifdef CONFIG_PAX_REFCOUNT
12704 + "jno 0f\n"
12705 + LOCK_PREFIX "decq %0\n"
12706 + "int $4\n0:\n"
12707 + _ASM_EXTABLE(0b, 0b)
12708 +#endif
12709 +
12710 + : "=m" (v->counter)
12711 + : "m" (v->counter));
12712 +}
12713 +
12714 +/**
12715 + * atomic64_inc_unchecked - increment atomic64 variable
12716 + * @v: pointer to type atomic64_unchecked_t
12717 + *
12718 + * Atomically increments @v by 1.
12719 + */
12720 +static inline void atomic64_inc_unchecked(atomic64_unchecked_t *v)
12721 +{
12722 asm volatile(LOCK_PREFIX "incq %0"
12723 : "=m" (v->counter)
12724 : "m" (v->counter));
12725 @@ -101,7 +199,28 @@ static inline void atomic64_inc(atomic64_t *v)
12726 */
12727 static inline void atomic64_dec(atomic64_t *v)
12728 {
12729 - asm volatile(LOCK_PREFIX "decq %0"
12730 + asm volatile(LOCK_PREFIX "decq %0\n"
12731 +
12732 +#ifdef CONFIG_PAX_REFCOUNT
12733 + "jno 0f\n"
12734 + LOCK_PREFIX "incq %0\n"
12735 + "int $4\n0:\n"
12736 + _ASM_EXTABLE(0b, 0b)
12737 +#endif
12738 +
12739 + : "=m" (v->counter)
12740 + : "m" (v->counter));
12741 +}
12742 +
12743 +/**
12744 + * atomic64_dec_unchecked - decrement atomic64 variable
12745 + * @v: pointer to type atomic64_t
12746 + *
12747 + * Atomically decrements @v by 1.
12748 + */
12749 +static inline void atomic64_dec_unchecked(atomic64_unchecked_t *v)
12750 +{
12751 + asm volatile(LOCK_PREFIX "decq %0\n"
12752 : "=m" (v->counter)
12753 : "m" (v->counter));
12754 }
12755 @@ -118,7 +237,16 @@ static inline int atomic64_dec_and_test(atomic64_t *v)
12756 {
12757 unsigned char c;
12758
12759 - asm volatile(LOCK_PREFIX "decq %0; sete %1"
12760 + asm volatile(LOCK_PREFIX "decq %0\n"
12761 +
12762 +#ifdef CONFIG_PAX_REFCOUNT
12763 + "jno 0f\n"
12764 + LOCK_PREFIX "incq %0\n"
12765 + "int $4\n0:\n"
12766 + _ASM_EXTABLE(0b, 0b)
12767 +#endif
12768 +
12769 + "sete %1\n"
12770 : "=m" (v->counter), "=qm" (c)
12771 : "m" (v->counter) : "memory");
12772 return c != 0;
12773 @@ -136,7 +264,16 @@ static inline int atomic64_inc_and_test(atomic64_t *v)
12774 {
12775 unsigned char c;
12776
12777 - asm volatile(LOCK_PREFIX "incq %0; sete %1"
12778 + asm volatile(LOCK_PREFIX "incq %0\n"
12779 +
12780 +#ifdef CONFIG_PAX_REFCOUNT
12781 + "jno 0f\n"
12782 + LOCK_PREFIX "decq %0\n"
12783 + "int $4\n0:\n"
12784 + _ASM_EXTABLE(0b, 0b)
12785 +#endif
12786 +
12787 + "sete %1\n"
12788 : "=m" (v->counter), "=qm" (c)
12789 : "m" (v->counter) : "memory");
12790 return c != 0;
12791 @@ -155,7 +292,16 @@ static inline int atomic64_add_negative(long i, atomic64_t *v)
12792 {
12793 unsigned char c;
12794
12795 - asm volatile(LOCK_PREFIX "addq %2,%0; sets %1"
12796 + asm volatile(LOCK_PREFIX "addq %2,%0\n"
12797 +
12798 +#ifdef CONFIG_PAX_REFCOUNT
12799 + "jno 0f\n"
12800 + LOCK_PREFIX "subq %2,%0\n"
12801 + "int $4\n0:\n"
12802 + _ASM_EXTABLE(0b, 0b)
12803 +#endif
12804 +
12805 + "sets %1\n"
12806 : "=m" (v->counter), "=qm" (c)
12807 : "er" (i), "m" (v->counter) : "memory");
12808 return c;
12809 @@ -170,6 +316,18 @@ static inline int atomic64_add_negative(long i, atomic64_t *v)
12810 */
12811 static inline long atomic64_add_return(long i, atomic64_t *v)
12812 {
12813 + return i + xadd_check_overflow(&v->counter, i);
12814 +}
12815 +
12816 +/**
12817 + * atomic64_add_return_unchecked - add and return
12818 + * @i: integer value to add
12819 + * @v: pointer to type atomic64_unchecked_t
12820 + *
12821 + * Atomically adds @i to @v and returns @i + @v
12822 + */
12823 +static inline long atomic64_add_return_unchecked(long i, atomic64_unchecked_t *v)
12824 +{
12825 return i + xadd(&v->counter, i);
12826 }
12827
12828 @@ -179,6 +337,10 @@ static inline long atomic64_sub_return(long i, atomic64_t *v)
12829 }
12830
12831 #define atomic64_inc_return(v) (atomic64_add_return(1, (v)))
12832 +static inline long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
12833 +{
12834 + return atomic64_add_return_unchecked(1, v);
12835 +}
12836 #define atomic64_dec_return(v) (atomic64_sub_return(1, (v)))
12837
12838 static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
12839 @@ -186,6 +348,11 @@ static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
12840 return cmpxchg(&v->counter, old, new);
12841 }
12842
12843 +static inline long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long old, long new)
12844 +{
12845 + return cmpxchg(&v->counter, old, new);
12846 +}
12847 +
12848 static inline long atomic64_xchg(atomic64_t *v, long new)
12849 {
12850 return xchg(&v->counter, new);
12851 @@ -202,17 +369,30 @@ static inline long atomic64_xchg(atomic64_t *v, long new)
12852 */
12853 static inline int atomic64_add_unless(atomic64_t *v, long a, long u)
12854 {
12855 - long c, old;
12856 + long c, old, new;
12857 c = atomic64_read(v);
12858 for (;;) {
12859 - if (unlikely(c == (u)))
12860 + if (unlikely(c == u))
12861 break;
12862 - old = atomic64_cmpxchg((v), c, c + (a));
12863 +
12864 + asm volatile("add %2,%0\n"
12865 +
12866 +#ifdef CONFIG_PAX_REFCOUNT
12867 + "jno 0f\n"
12868 + "sub %2,%0\n"
12869 + "int $4\n0:\n"
12870 + _ASM_EXTABLE(0b, 0b)
12871 +#endif
12872 +
12873 + : "=r" (new)
12874 + : "0" (c), "ir" (a));
12875 +
12876 + old = atomic64_cmpxchg(v, c, new);
12877 if (likely(old == c))
12878 break;
12879 c = old;
12880 }
12881 - return c != (u);
12882 + return c != u;
12883 }
12884
12885 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
12886 diff --git a/arch/x86/include/asm/bitops.h b/arch/x86/include/asm/bitops.h
12887 index 6dfd019..28e188d 100644
12888 --- a/arch/x86/include/asm/bitops.h
12889 +++ b/arch/x86/include/asm/bitops.h
12890 @@ -40,7 +40,7 @@
12891 * a mask operation on a byte.
12892 */
12893 #define IS_IMMEDIATE(nr) (__builtin_constant_p(nr))
12894 -#define CONST_MASK_ADDR(nr, addr) BITOP_ADDR((void *)(addr) + ((nr)>>3))
12895 +#define CONST_MASK_ADDR(nr, addr) BITOP_ADDR((volatile void *)(addr) + ((nr)>>3))
12896 #define CONST_MASK(nr) (1 << ((nr) & 7))
12897
12898 /**
12899 @@ -486,7 +486,7 @@ static inline int fls(int x)
12900 * at position 64.
12901 */
12902 #ifdef CONFIG_X86_64
12903 -static __always_inline int fls64(__u64 x)
12904 +static __always_inline long fls64(__u64 x)
12905 {
12906 int bitpos = -1;
12907 /*
12908 diff --git a/arch/x86/include/asm/boot.h b/arch/x86/include/asm/boot.h
12909 index 4fa687a..60f2d39 100644
12910 --- a/arch/x86/include/asm/boot.h
12911 +++ b/arch/x86/include/asm/boot.h
12912 @@ -6,10 +6,15 @@
12913 #include <uapi/asm/boot.h>
12914
12915 /* Physical address where kernel should be loaded. */
12916 -#define LOAD_PHYSICAL_ADDR ((CONFIG_PHYSICAL_START \
12917 +#define ____LOAD_PHYSICAL_ADDR ((CONFIG_PHYSICAL_START \
12918 + (CONFIG_PHYSICAL_ALIGN - 1)) \
12919 & ~(CONFIG_PHYSICAL_ALIGN - 1))
12920
12921 +#ifndef __ASSEMBLY__
12922 +extern unsigned char __LOAD_PHYSICAL_ADDR[];
12923 +#define LOAD_PHYSICAL_ADDR ((unsigned long)__LOAD_PHYSICAL_ADDR)
12924 +#endif
12925 +
12926 /* Minimum kernel alignment, as a power of two */
12927 #ifdef CONFIG_X86_64
12928 #define MIN_KERNEL_ALIGN_LG2 PMD_SHIFT
12929 diff --git a/arch/x86/include/asm/cache.h b/arch/x86/include/asm/cache.h
12930 index 48f99f1..d78ebf9 100644
12931 --- a/arch/x86/include/asm/cache.h
12932 +++ b/arch/x86/include/asm/cache.h
12933 @@ -5,12 +5,13 @@
12934
12935 /* L1 cache line size */
12936 #define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT)
12937 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
12938 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
12939
12940 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
12941 +#define __read_only __attribute__((__section__(".data..read_only")))
12942
12943 #define INTERNODE_CACHE_SHIFT CONFIG_X86_INTERNODE_CACHE_SHIFT
12944 -#define INTERNODE_CACHE_BYTES (1 << INTERNODE_CACHE_SHIFT)
12945 +#define INTERNODE_CACHE_BYTES (_AC(1,UL) << INTERNODE_CACHE_SHIFT)
12946
12947 #ifdef CONFIG_X86_VSMP
12948 #ifdef CONFIG_SMP
12949 diff --git a/arch/x86/include/asm/cacheflush.h b/arch/x86/include/asm/cacheflush.h
12950 index 9863ee3..4a1f8e1 100644
12951 --- a/arch/x86/include/asm/cacheflush.h
12952 +++ b/arch/x86/include/asm/cacheflush.h
12953 @@ -27,7 +27,7 @@ static inline unsigned long get_page_memtype(struct page *pg)
12954 unsigned long pg_flags = pg->flags & _PGMT_MASK;
12955
12956 if (pg_flags == _PGMT_DEFAULT)
12957 - return -1;
12958 + return ~0UL;
12959 else if (pg_flags == _PGMT_WC)
12960 return _PAGE_CACHE_WC;
12961 else if (pg_flags == _PGMT_UC_MINUS)
12962 diff --git a/arch/x86/include/asm/checksum_32.h b/arch/x86/include/asm/checksum_32.h
12963 index 46fc474..b02b0f9 100644
12964 --- a/arch/x86/include/asm/checksum_32.h
12965 +++ b/arch/x86/include/asm/checksum_32.h
12966 @@ -31,6 +31,14 @@ asmlinkage __wsum csum_partial_copy_generic(const void *src, void *dst,
12967 int len, __wsum sum,
12968 int *src_err_ptr, int *dst_err_ptr);
12969
12970 +asmlinkage __wsum csum_partial_copy_generic_to_user(const void *src, void *dst,
12971 + int len, __wsum sum,
12972 + int *src_err_ptr, int *dst_err_ptr);
12973 +
12974 +asmlinkage __wsum csum_partial_copy_generic_from_user(const void *src, void *dst,
12975 + int len, __wsum sum,
12976 + int *src_err_ptr, int *dst_err_ptr);
12977 +
12978 /*
12979 * Note: when you get a NULL pointer exception here this means someone
12980 * passed in an incorrect kernel address to one of these functions.
12981 @@ -50,7 +58,7 @@ static inline __wsum csum_partial_copy_from_user(const void __user *src,
12982 int *err_ptr)
12983 {
12984 might_sleep();
12985 - return csum_partial_copy_generic((__force void *)src, dst,
12986 + return csum_partial_copy_generic_from_user((__force void *)src, dst,
12987 len, sum, err_ptr, NULL);
12988 }
12989
12990 @@ -178,7 +186,7 @@ static inline __wsum csum_and_copy_to_user(const void *src,
12991 {
12992 might_sleep();
12993 if (access_ok(VERIFY_WRITE, dst, len))
12994 - return csum_partial_copy_generic(src, (__force void *)dst,
12995 + return csum_partial_copy_generic_to_user(src, (__force void *)dst,
12996 len, sum, NULL, err_ptr);
12997
12998 if (len)
12999 diff --git a/arch/x86/include/asm/cmpxchg.h b/arch/x86/include/asm/cmpxchg.h
13000 index 8d871ea..c1a0dc9 100644
13001 --- a/arch/x86/include/asm/cmpxchg.h
13002 +++ b/arch/x86/include/asm/cmpxchg.h
13003 @@ -14,8 +14,12 @@ extern void __cmpxchg_wrong_size(void)
13004 __compiletime_error("Bad argument size for cmpxchg");
13005 extern void __xadd_wrong_size(void)
13006 __compiletime_error("Bad argument size for xadd");
13007 +extern void __xadd_check_overflow_wrong_size(void)
13008 + __compiletime_error("Bad argument size for xadd_check_overflow");
13009 extern void __add_wrong_size(void)
13010 __compiletime_error("Bad argument size for add");
13011 +extern void __add_check_overflow_wrong_size(void)
13012 + __compiletime_error("Bad argument size for add_check_overflow");
13013
13014 /*
13015 * Constants for operation sizes. On 32-bit, the 64-bit size it set to
13016 @@ -67,6 +71,34 @@ extern void __add_wrong_size(void)
13017 __ret; \
13018 })
13019
13020 +#define __xchg_op_check_overflow(ptr, arg, op, lock) \
13021 + ({ \
13022 + __typeof__ (*(ptr)) __ret = (arg); \
13023 + switch (sizeof(*(ptr))) { \
13024 + case __X86_CASE_L: \
13025 + asm volatile (lock #op "l %0, %1\n" \
13026 + "jno 0f\n" \
13027 + "mov %0,%1\n" \
13028 + "int $4\n0:\n" \
13029 + _ASM_EXTABLE(0b, 0b) \
13030 + : "+r" (__ret), "+m" (*(ptr)) \
13031 + : : "memory", "cc"); \
13032 + break; \
13033 + case __X86_CASE_Q: \
13034 + asm volatile (lock #op "q %q0, %1\n" \
13035 + "jno 0f\n" \
13036 + "mov %0,%1\n" \
13037 + "int $4\n0:\n" \
13038 + _ASM_EXTABLE(0b, 0b) \
13039 + : "+r" (__ret), "+m" (*(ptr)) \
13040 + : : "memory", "cc"); \
13041 + break; \
13042 + default: \
13043 + __ ## op ## _check_overflow_wrong_size(); \
13044 + } \
13045 + __ret; \
13046 + })
13047 +
13048 /*
13049 * Note: no "lock" prefix even on SMP: xchg always implies lock anyway.
13050 * Since this is generally used to protect other memory information, we
13051 @@ -167,6 +199,9 @@ extern void __add_wrong_size(void)
13052 #define xadd_sync(ptr, inc) __xadd((ptr), (inc), "lock; ")
13053 #define xadd_local(ptr, inc) __xadd((ptr), (inc), "")
13054
13055 +#define __xadd_check_overflow(ptr, inc, lock) __xchg_op_check_overflow((ptr), (inc), xadd, lock)
13056 +#define xadd_check_overflow(ptr, inc) __xadd_check_overflow((ptr), (inc), LOCK_PREFIX)
13057 +
13058 #define __add(ptr, inc, lock) \
13059 ({ \
13060 __typeof__ (*(ptr)) __ret = (inc); \
13061 diff --git a/arch/x86/include/asm/compat.h b/arch/x86/include/asm/compat.h
13062 index 59c6c40..5e0b22c 100644
13063 --- a/arch/x86/include/asm/compat.h
13064 +++ b/arch/x86/include/asm/compat.h
13065 @@ -41,7 +41,7 @@ typedef s64 __attribute__((aligned(4))) compat_s64;
13066 typedef u32 compat_uint_t;
13067 typedef u32 compat_ulong_t;
13068 typedef u64 __attribute__((aligned(4))) compat_u64;
13069 -typedef u32 compat_uptr_t;
13070 +typedef u32 __user compat_uptr_t;
13071
13072 struct compat_timespec {
13073 compat_time_t tv_sec;
13074 diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h
13075 index 93fe929..90858b7 100644
13076 --- a/arch/x86/include/asm/cpufeature.h
13077 +++ b/arch/x86/include/asm/cpufeature.h
13078 @@ -207,7 +207,7 @@
13079 #define X86_FEATURE_BMI1 (9*32+ 3) /* 1st group bit manipulation extensions */
13080 #define X86_FEATURE_HLE (9*32+ 4) /* Hardware Lock Elision */
13081 #define X86_FEATURE_AVX2 (9*32+ 5) /* AVX2 instructions */
13082 -#define X86_FEATURE_SMEP (9*32+ 7) /* Supervisor Mode Execution Protection */
13083 +#define X86_FEATURE_SMEP (9*32+ 7) /* Supervisor Mode Execution Prevention */
13084 #define X86_FEATURE_BMI2 (9*32+ 8) /* 2nd group bit manipulation extensions */
13085 #define X86_FEATURE_ERMS (9*32+ 9) /* Enhanced REP MOVSB/STOSB */
13086 #define X86_FEATURE_INVPCID (9*32+10) /* Invalidate Processor Context ID */
13087 @@ -377,7 +377,7 @@ static __always_inline __pure bool __static_cpu_has(u16 bit)
13088 ".section .discard,\"aw\",@progbits\n"
13089 " .byte 0xff + (4f-3f) - (2b-1b)\n" /* size check */
13090 ".previous\n"
13091 - ".section .altinstr_replacement,\"ax\"\n"
13092 + ".section .altinstr_replacement,\"a\"\n"
13093 "3: movb $1,%0\n"
13094 "4:\n"
13095 ".previous\n"
13096 diff --git a/arch/x86/include/asm/desc.h b/arch/x86/include/asm/desc.h
13097 index 8bf1c06..b6ae785 100644
13098 --- a/arch/x86/include/asm/desc.h
13099 +++ b/arch/x86/include/asm/desc.h
13100 @@ -4,6 +4,7 @@
13101 #include <asm/desc_defs.h>
13102 #include <asm/ldt.h>
13103 #include <asm/mmu.h>
13104 +#include <asm/pgtable.h>
13105
13106 #include <linux/smp.h>
13107 #include <linux/percpu.h>
13108 @@ -17,6 +18,7 @@ static inline void fill_ldt(struct desc_struct *desc, const struct user_desc *in
13109
13110 desc->type = (info->read_exec_only ^ 1) << 1;
13111 desc->type |= info->contents << 2;
13112 + desc->type |= info->seg_not_present ^ 1;
13113
13114 desc->s = 1;
13115 desc->dpl = 0x3;
13116 @@ -35,19 +37,14 @@ static inline void fill_ldt(struct desc_struct *desc, const struct user_desc *in
13117 }
13118
13119 extern struct desc_ptr idt_descr;
13120 -extern gate_desc idt_table[];
13121 extern struct desc_ptr nmi_idt_descr;
13122 -extern gate_desc nmi_idt_table[];
13123 -
13124 -struct gdt_page {
13125 - struct desc_struct gdt[GDT_ENTRIES];
13126 -} __attribute__((aligned(PAGE_SIZE)));
13127 -
13128 -DECLARE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page);
13129 +extern gate_desc idt_table[256];
13130 +extern gate_desc nmi_idt_table[256];
13131
13132 +extern struct desc_struct cpu_gdt_table[NR_CPUS][PAGE_SIZE / sizeof(struct desc_struct)];
13133 static inline struct desc_struct *get_cpu_gdt_table(unsigned int cpu)
13134 {
13135 - return per_cpu(gdt_page, cpu).gdt;
13136 + return cpu_gdt_table[cpu];
13137 }
13138
13139 #ifdef CONFIG_X86_64
13140 @@ -72,8 +69,14 @@ static inline void pack_gate(gate_desc *gate, unsigned char type,
13141 unsigned long base, unsigned dpl, unsigned flags,
13142 unsigned short seg)
13143 {
13144 - gate->a = (seg << 16) | (base & 0xffff);
13145 - gate->b = (base & 0xffff0000) | (((0x80 | type | (dpl << 5)) & 0xff) << 8);
13146 + gate->gate.offset_low = base;
13147 + gate->gate.seg = seg;
13148 + gate->gate.reserved = 0;
13149 + gate->gate.type = type;
13150 + gate->gate.s = 0;
13151 + gate->gate.dpl = dpl;
13152 + gate->gate.p = 1;
13153 + gate->gate.offset_high = base >> 16;
13154 }
13155
13156 #endif
13157 @@ -118,12 +121,16 @@ static inline void paravirt_free_ldt(struct desc_struct *ldt, unsigned entries)
13158
13159 static inline void native_write_idt_entry(gate_desc *idt, int entry, const gate_desc *gate)
13160 {
13161 + pax_open_kernel();
13162 memcpy(&idt[entry], gate, sizeof(*gate));
13163 + pax_close_kernel();
13164 }
13165
13166 static inline void native_write_ldt_entry(struct desc_struct *ldt, int entry, const void *desc)
13167 {
13168 + pax_open_kernel();
13169 memcpy(&ldt[entry], desc, 8);
13170 + pax_close_kernel();
13171 }
13172
13173 static inline void
13174 @@ -137,7 +144,9 @@ native_write_gdt_entry(struct desc_struct *gdt, int entry, const void *desc, int
13175 default: size = sizeof(*gdt); break;
13176 }
13177
13178 + pax_open_kernel();
13179 memcpy(&gdt[entry], desc, size);
13180 + pax_close_kernel();
13181 }
13182
13183 static inline void pack_descriptor(struct desc_struct *desc, unsigned long base,
13184 @@ -210,7 +219,9 @@ static inline void native_set_ldt(const void *addr, unsigned int entries)
13185
13186 static inline void native_load_tr_desc(void)
13187 {
13188 + pax_open_kernel();
13189 asm volatile("ltr %w0"::"q" (GDT_ENTRY_TSS*8));
13190 + pax_close_kernel();
13191 }
13192
13193 static inline void native_load_gdt(const struct desc_ptr *dtr)
13194 @@ -247,8 +258,10 @@ static inline void native_load_tls(struct thread_struct *t, unsigned int cpu)
13195 struct desc_struct *gdt = get_cpu_gdt_table(cpu);
13196 unsigned int i;
13197
13198 + pax_open_kernel();
13199 for (i = 0; i < GDT_ENTRY_TLS_ENTRIES; i++)
13200 gdt[GDT_ENTRY_TLS_MIN + i] = t->tls_array[i];
13201 + pax_close_kernel();
13202 }
13203
13204 #define _LDT_empty(info) \
13205 @@ -287,7 +300,7 @@ static inline void load_LDT(mm_context_t *pc)
13206 preempt_enable();
13207 }
13208
13209 -static inline unsigned long get_desc_base(const struct desc_struct *desc)
13210 +static inline unsigned long __intentional_overflow(-1) get_desc_base(const struct desc_struct *desc)
13211 {
13212 return (unsigned)(desc->base0 | ((desc->base1) << 16) | ((desc->base2) << 24));
13213 }
13214 @@ -311,7 +324,7 @@ static inline void set_desc_limit(struct desc_struct *desc, unsigned long limit)
13215 }
13216
13217 #ifdef CONFIG_X86_64
13218 -static inline void set_nmi_gate(int gate, void *addr)
13219 +static inline void set_nmi_gate(int gate, const void *addr)
13220 {
13221 gate_desc s;
13222
13223 @@ -320,7 +333,7 @@ static inline void set_nmi_gate(int gate, void *addr)
13224 }
13225 #endif
13226
13227 -static inline void _set_gate(int gate, unsigned type, void *addr,
13228 +static inline void _set_gate(int gate, unsigned type, const void *addr,
13229 unsigned dpl, unsigned ist, unsigned seg)
13230 {
13231 gate_desc s;
13232 @@ -339,7 +352,7 @@ static inline void _set_gate(int gate, unsigned type, void *addr,
13233 * Pentium F0 0F bugfix can have resulted in the mapped
13234 * IDT being write-protected.
13235 */
13236 -static inline void set_intr_gate(unsigned int n, void *addr)
13237 +static inline void set_intr_gate(unsigned int n, const void *addr)
13238 {
13239 BUG_ON((unsigned)n > 0xFF);
13240 _set_gate(n, GATE_INTERRUPT, addr, 0, 0, __KERNEL_CS);
13241 @@ -369,19 +382,19 @@ static inline void alloc_intr_gate(unsigned int n, void *addr)
13242 /*
13243 * This routine sets up an interrupt gate at directory privilege level 3.
13244 */
13245 -static inline void set_system_intr_gate(unsigned int n, void *addr)
13246 +static inline void set_system_intr_gate(unsigned int n, const void *addr)
13247 {
13248 BUG_ON((unsigned)n > 0xFF);
13249 _set_gate(n, GATE_INTERRUPT, addr, 0x3, 0, __KERNEL_CS);
13250 }
13251
13252 -static inline void set_system_trap_gate(unsigned int n, void *addr)
13253 +static inline void set_system_trap_gate(unsigned int n, const void *addr)
13254 {
13255 BUG_ON((unsigned)n > 0xFF);
13256 _set_gate(n, GATE_TRAP, addr, 0x3, 0, __KERNEL_CS);
13257 }
13258
13259 -static inline void set_trap_gate(unsigned int n, void *addr)
13260 +static inline void set_trap_gate(unsigned int n, const void *addr)
13261 {
13262 BUG_ON((unsigned)n > 0xFF);
13263 _set_gate(n, GATE_TRAP, addr, 0, 0, __KERNEL_CS);
13264 @@ -390,19 +403,31 @@ static inline void set_trap_gate(unsigned int n, void *addr)
13265 static inline void set_task_gate(unsigned int n, unsigned int gdt_entry)
13266 {
13267 BUG_ON((unsigned)n > 0xFF);
13268 - _set_gate(n, GATE_TASK, (void *)0, 0, 0, (gdt_entry<<3));
13269 + _set_gate(n, GATE_TASK, (const void *)0, 0, 0, (gdt_entry<<3));
13270 }
13271
13272 -static inline void set_intr_gate_ist(int n, void *addr, unsigned ist)
13273 +static inline void set_intr_gate_ist(int n, const void *addr, unsigned ist)
13274 {
13275 BUG_ON((unsigned)n > 0xFF);
13276 _set_gate(n, GATE_INTERRUPT, addr, 0, ist, __KERNEL_CS);
13277 }
13278
13279 -static inline void set_system_intr_gate_ist(int n, void *addr, unsigned ist)
13280 +static inline void set_system_intr_gate_ist(int n, const void *addr, unsigned ist)
13281 {
13282 BUG_ON((unsigned)n > 0xFF);
13283 _set_gate(n, GATE_INTERRUPT, addr, 0x3, ist, __KERNEL_CS);
13284 }
13285
13286 +#ifdef CONFIG_X86_32
13287 +static inline void set_user_cs(unsigned long base, unsigned long limit, int cpu)
13288 +{
13289 + struct desc_struct d;
13290 +
13291 + if (likely(limit))
13292 + limit = (limit - 1UL) >> PAGE_SHIFT;
13293 + pack_descriptor(&d, base, limit, 0xFB, 0xC);
13294 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_DEFAULT_USER_CS, &d, DESCTYPE_S);
13295 +}
13296 +#endif
13297 +
13298 #endif /* _ASM_X86_DESC_H */
13299 diff --git a/arch/x86/include/asm/desc_defs.h b/arch/x86/include/asm/desc_defs.h
13300 index 278441f..b95a174 100644
13301 --- a/arch/x86/include/asm/desc_defs.h
13302 +++ b/arch/x86/include/asm/desc_defs.h
13303 @@ -31,6 +31,12 @@ struct desc_struct {
13304 unsigned base1: 8, type: 4, s: 1, dpl: 2, p: 1;
13305 unsigned limit: 4, avl: 1, l: 1, d: 1, g: 1, base2: 8;
13306 };
13307 + struct {
13308 + u16 offset_low;
13309 + u16 seg;
13310 + unsigned reserved: 8, type: 4, s: 1, dpl: 2, p: 1;
13311 + unsigned offset_high: 16;
13312 + } gate;
13313 };
13314 } __attribute__((packed));
13315
13316 diff --git a/arch/x86/include/asm/div64.h b/arch/x86/include/asm/div64.h
13317 index ced283a..ffe04cc 100644
13318 --- a/arch/x86/include/asm/div64.h
13319 +++ b/arch/x86/include/asm/div64.h
13320 @@ -39,7 +39,7 @@
13321 __mod; \
13322 })
13323
13324 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
13325 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
13326 {
13327 union {
13328 u64 v64;
13329 diff --git a/arch/x86/include/asm/elf.h b/arch/x86/include/asm/elf.h
13330 index 9c999c1..3860cb8 100644
13331 --- a/arch/x86/include/asm/elf.h
13332 +++ b/arch/x86/include/asm/elf.h
13333 @@ -243,7 +243,25 @@ extern int force_personality32;
13334 the loader. We need to make sure that it is out of the way of the program
13335 that it will "exec", and that there is sufficient room for the brk. */
13336
13337 +#ifdef CONFIG_PAX_SEGMEXEC
13338 +#define ELF_ET_DYN_BASE ((current->mm->pax_flags & MF_PAX_SEGMEXEC) ? SEGMEXEC_TASK_SIZE/3*2 : TASK_SIZE/3*2)
13339 +#else
13340 #define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
13341 +#endif
13342 +
13343 +#ifdef CONFIG_PAX_ASLR
13344 +#ifdef CONFIG_X86_32
13345 +#define PAX_ELF_ET_DYN_BASE 0x10000000UL
13346 +
13347 +#define PAX_DELTA_MMAP_LEN (current->mm->pax_flags & MF_PAX_SEGMEXEC ? 15 : 16)
13348 +#define PAX_DELTA_STACK_LEN (current->mm->pax_flags & MF_PAX_SEGMEXEC ? 15 : 16)
13349 +#else
13350 +#define PAX_ELF_ET_DYN_BASE 0x400000UL
13351 +
13352 +#define PAX_DELTA_MMAP_LEN ((test_thread_flag(TIF_ADDR32)) ? 16 : TASK_SIZE_MAX_SHIFT - PAGE_SHIFT - 3)
13353 +#define PAX_DELTA_STACK_LEN ((test_thread_flag(TIF_ADDR32)) ? 16 : TASK_SIZE_MAX_SHIFT - PAGE_SHIFT - 3)
13354 +#endif
13355 +#endif
13356
13357 /* This yields a mask that user programs can use to figure out what
13358 instruction set this CPU supports. This could be done in user space,
13359 @@ -296,16 +314,12 @@ do { \
13360
13361 #define ARCH_DLINFO \
13362 do { \
13363 - if (vdso_enabled) \
13364 - NEW_AUX_ENT(AT_SYSINFO_EHDR, \
13365 - (unsigned long)current->mm->context.vdso); \
13366 + NEW_AUX_ENT(AT_SYSINFO_EHDR, current->mm->context.vdso); \
13367 } while (0)
13368
13369 #define ARCH_DLINFO_X32 \
13370 do { \
13371 - if (vdso_enabled) \
13372 - NEW_AUX_ENT(AT_SYSINFO_EHDR, \
13373 - (unsigned long)current->mm->context.vdso); \
13374 + NEW_AUX_ENT(AT_SYSINFO_EHDR, current->mm->context.vdso); \
13375 } while (0)
13376
13377 #define AT_SYSINFO 32
13378 @@ -320,7 +334,7 @@ else \
13379
13380 #endif /* !CONFIG_X86_32 */
13381
13382 -#define VDSO_CURRENT_BASE ((unsigned long)current->mm->context.vdso)
13383 +#define VDSO_CURRENT_BASE (current->mm->context.vdso)
13384
13385 #define VDSO_ENTRY \
13386 ((unsigned long)VDSO32_SYMBOL(VDSO_CURRENT_BASE, vsyscall))
13387 @@ -336,9 +350,6 @@ extern int x32_setup_additional_pages(struct linux_binprm *bprm,
13388 extern int syscall32_setup_pages(struct linux_binprm *, int exstack);
13389 #define compat_arch_setup_additional_pages syscall32_setup_pages
13390
13391 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
13392 -#define arch_randomize_brk arch_randomize_brk
13393 -
13394 /*
13395 * True on X86_32 or when emulating IA32 on X86_64
13396 */
13397 diff --git a/arch/x86/include/asm/emergency-restart.h b/arch/x86/include/asm/emergency-restart.h
13398 index 75ce3f4..882e801 100644
13399 --- a/arch/x86/include/asm/emergency-restart.h
13400 +++ b/arch/x86/include/asm/emergency-restart.h
13401 @@ -13,6 +13,6 @@ enum reboot_type {
13402
13403 extern enum reboot_type reboot_type;
13404
13405 -extern void machine_emergency_restart(void);
13406 +extern void machine_emergency_restart(void) __noreturn;
13407
13408 #endif /* _ASM_X86_EMERGENCY_RESTART_H */
13409 diff --git a/arch/x86/include/asm/fpu-internal.h b/arch/x86/include/asm/fpu-internal.h
13410 index e25cc33..425d099 100644
13411 --- a/arch/x86/include/asm/fpu-internal.h
13412 +++ b/arch/x86/include/asm/fpu-internal.h
13413 @@ -127,7 +127,9 @@ static inline void sanitize_i387_state(struct task_struct *tsk)
13414 ({ \
13415 int err; \
13416 asm volatile(ASM_STAC "\n" \
13417 - "1:" #insn "\n\t" \
13418 + "1:" \
13419 + __copyuser_seg \
13420 + #insn "\n\t" \
13421 "2: " ASM_CLAC "\n" \
13422 ".section .fixup,\"ax\"\n" \
13423 "3: movl $-1,%[err]\n" \
13424 @@ -300,7 +302,7 @@ static inline int restore_fpu_checking(struct task_struct *tsk)
13425 "emms\n\t" /* clear stack tags */
13426 "fildl %P[addr]", /* set F?P to defined value */
13427 X86_FEATURE_FXSAVE_LEAK,
13428 - [addr] "m" (tsk->thread.fpu.has_fpu));
13429 + [addr] "m" (init_tss[raw_smp_processor_id()].x86_tss.sp0));
13430
13431 return fpu_restore_checking(&tsk->thread.fpu);
13432 }
13433 diff --git a/arch/x86/include/asm/futex.h b/arch/x86/include/asm/futex.h
13434 index be27ba1..8f13ff9 100644
13435 --- a/arch/x86/include/asm/futex.h
13436 +++ b/arch/x86/include/asm/futex.h
13437 @@ -12,6 +12,7 @@
13438 #include <asm/smap.h>
13439
13440 #define __futex_atomic_op1(insn, ret, oldval, uaddr, oparg) \
13441 + typecheck(u32 __user *, uaddr); \
13442 asm volatile("\t" ASM_STAC "\n" \
13443 "1:\t" insn "\n" \
13444 "2:\t" ASM_CLAC "\n" \
13445 @@ -20,15 +21,16 @@
13446 "\tjmp\t2b\n" \
13447 "\t.previous\n" \
13448 _ASM_EXTABLE(1b, 3b) \
13449 - : "=r" (oldval), "=r" (ret), "+m" (*uaddr) \
13450 + : "=r" (oldval), "=r" (ret), "+m" (*(u32 __user *)____m(uaddr)) \
13451 : "i" (-EFAULT), "0" (oparg), "1" (0))
13452
13453 #define __futex_atomic_op2(insn, ret, oldval, uaddr, oparg) \
13454 + typecheck(u32 __user *, uaddr); \
13455 asm volatile("\t" ASM_STAC "\n" \
13456 "1:\tmovl %2, %0\n" \
13457 "\tmovl\t%0, %3\n" \
13458 "\t" insn "\n" \
13459 - "2:\t" LOCK_PREFIX "cmpxchgl %3, %2\n" \
13460 + "2:\t" LOCK_PREFIX __copyuser_seg"cmpxchgl %3, %2\n" \
13461 "\tjnz\t1b\n" \
13462 "3:\t" ASM_CLAC "\n" \
13463 "\t.section .fixup,\"ax\"\n" \
13464 @@ -38,7 +40,7 @@
13465 _ASM_EXTABLE(1b, 4b) \
13466 _ASM_EXTABLE(2b, 4b) \
13467 : "=&a" (oldval), "=&r" (ret), \
13468 - "+m" (*uaddr), "=&r" (tem) \
13469 + "+m" (*(u32 __user *)____m(uaddr)), "=&r" (tem) \
13470 : "r" (oparg), "i" (-EFAULT), "1" (0))
13471
13472 static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
13473 @@ -59,10 +61,10 @@ static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
13474
13475 switch (op) {
13476 case FUTEX_OP_SET:
13477 - __futex_atomic_op1("xchgl %0, %2", ret, oldval, uaddr, oparg);
13478 + __futex_atomic_op1(__copyuser_seg"xchgl %0, %2", ret, oldval, uaddr, oparg);
13479 break;
13480 case FUTEX_OP_ADD:
13481 - __futex_atomic_op1(LOCK_PREFIX "xaddl %0, %2", ret, oldval,
13482 + __futex_atomic_op1(LOCK_PREFIX __copyuser_seg"xaddl %0, %2", ret, oldval,
13483 uaddr, oparg);
13484 break;
13485 case FUTEX_OP_OR:
13486 @@ -116,14 +118,14 @@ static inline int futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
13487 return -EFAULT;
13488
13489 asm volatile("\t" ASM_STAC "\n"
13490 - "1:\t" LOCK_PREFIX "cmpxchgl %4, %2\n"
13491 + "1:\t" LOCK_PREFIX __copyuser_seg"cmpxchgl %4, %2\n"
13492 "2:\t" ASM_CLAC "\n"
13493 "\t.section .fixup, \"ax\"\n"
13494 "3:\tmov %3, %0\n"
13495 "\tjmp 2b\n"
13496 "\t.previous\n"
13497 _ASM_EXTABLE(1b, 3b)
13498 - : "+r" (ret), "=a" (oldval), "+m" (*uaddr)
13499 + : "+r" (ret), "=a" (oldval), "+m" (*(u32 __user *)____m(uaddr))
13500 : "i" (-EFAULT), "r" (newval), "1" (oldval)
13501 : "memory"
13502 );
13503 diff --git a/arch/x86/include/asm/hw_irq.h b/arch/x86/include/asm/hw_irq.h
13504 index 10a78c3..cc77143 100644
13505 --- a/arch/x86/include/asm/hw_irq.h
13506 +++ b/arch/x86/include/asm/hw_irq.h
13507 @@ -147,8 +147,8 @@ extern void setup_ioapic_dest(void);
13508 extern void enable_IO_APIC(void);
13509
13510 /* Statistics */
13511 -extern atomic_t irq_err_count;
13512 -extern atomic_t irq_mis_count;
13513 +extern atomic_unchecked_t irq_err_count;
13514 +extern atomic_unchecked_t irq_mis_count;
13515
13516 /* EISA */
13517 extern void eisa_set_level_irq(unsigned int irq);
13518 diff --git a/arch/x86/include/asm/i8259.h b/arch/x86/include/asm/i8259.h
13519 index a203659..9889f1c 100644
13520 --- a/arch/x86/include/asm/i8259.h
13521 +++ b/arch/x86/include/asm/i8259.h
13522 @@ -62,7 +62,7 @@ struct legacy_pic {
13523 void (*init)(int auto_eoi);
13524 int (*irq_pending)(unsigned int irq);
13525 void (*make_irq)(unsigned int irq);
13526 -};
13527 +} __do_const;
13528
13529 extern struct legacy_pic *legacy_pic;
13530 extern struct legacy_pic null_legacy_pic;
13531 diff --git a/arch/x86/include/asm/io.h b/arch/x86/include/asm/io.h
13532 index d8e8eef..1765f78 100644
13533 --- a/arch/x86/include/asm/io.h
13534 +++ b/arch/x86/include/asm/io.h
13535 @@ -51,12 +51,12 @@ static inline void name(type val, volatile void __iomem *addr) \
13536 "m" (*(volatile type __force *)addr) barrier); }
13537
13538 build_mmio_read(readb, "b", unsigned char, "=q", :"memory")
13539 -build_mmio_read(readw, "w", unsigned short, "=r", :"memory")
13540 -build_mmio_read(readl, "l", unsigned int, "=r", :"memory")
13541 +build_mmio_read(__intentional_overflow(-1) readw, "w", unsigned short, "=r", :"memory")
13542 +build_mmio_read(__intentional_overflow(-1) readl, "l", unsigned int, "=r", :"memory")
13543
13544 build_mmio_read(__readb, "b", unsigned char, "=q", )
13545 -build_mmio_read(__readw, "w", unsigned short, "=r", )
13546 -build_mmio_read(__readl, "l", unsigned int, "=r", )
13547 +build_mmio_read(__intentional_overflow(-1) __readw, "w", unsigned short, "=r", )
13548 +build_mmio_read(__intentional_overflow(-1) __readl, "l", unsigned int, "=r", )
13549
13550 build_mmio_write(writeb, "b", unsigned char, "q", :"memory")
13551 build_mmio_write(writew, "w", unsigned short, "r", :"memory")
13552 @@ -184,7 +184,7 @@ static inline void __iomem *ioremap(resource_size_t offset, unsigned long size)
13553 return ioremap_nocache(offset, size);
13554 }
13555
13556 -extern void iounmap(volatile void __iomem *addr);
13557 +extern void iounmap(const volatile void __iomem *addr);
13558
13559 extern void set_iounmap_nonlazy(void);
13560
13561 @@ -194,6 +194,17 @@ extern void set_iounmap_nonlazy(void);
13562
13563 #include <linux/vmalloc.h>
13564
13565 +#define ARCH_HAS_VALID_PHYS_ADDR_RANGE
13566 +static inline int valid_phys_addr_range(unsigned long addr, size_t count)
13567 +{
13568 + return ((addr + count + PAGE_SIZE - 1) >> PAGE_SHIFT) < (1ULL << (boot_cpu_data.x86_phys_bits - PAGE_SHIFT)) ? 1 : 0;
13569 +}
13570 +
13571 +static inline int valid_mmap_phys_addr_range(unsigned long pfn, size_t count)
13572 +{
13573 + return (pfn + (count >> PAGE_SHIFT)) < (1ULL << (boot_cpu_data.x86_phys_bits - PAGE_SHIFT)) ? 1 : 0;
13574 +}
13575 +
13576 /*
13577 * Convert a virtual cached pointer to an uncached pointer
13578 */
13579 diff --git a/arch/x86/include/asm/irqflags.h b/arch/x86/include/asm/irqflags.h
13580 index bba3cf8..06bc8da 100644
13581 --- a/arch/x86/include/asm/irqflags.h
13582 +++ b/arch/x86/include/asm/irqflags.h
13583 @@ -141,6 +141,11 @@ static inline notrace unsigned long arch_local_irq_save(void)
13584 sti; \
13585 sysexit
13586
13587 +#define GET_CR0_INTO_RDI mov %cr0, %rdi
13588 +#define SET_RDI_INTO_CR0 mov %rdi, %cr0
13589 +#define GET_CR3_INTO_RDI mov %cr3, %rdi
13590 +#define SET_RDI_INTO_CR3 mov %rdi, %cr3
13591 +
13592 #else
13593 #define INTERRUPT_RETURN iret
13594 #define ENABLE_INTERRUPTS_SYSEXIT sti; sysexit
13595 diff --git a/arch/x86/include/asm/kprobes.h b/arch/x86/include/asm/kprobes.h
13596 index 5a6d287..f815789 100644
13597 --- a/arch/x86/include/asm/kprobes.h
13598 +++ b/arch/x86/include/asm/kprobes.h
13599 @@ -38,13 +38,8 @@ typedef u8 kprobe_opcode_t;
13600 #define RELATIVEJUMP_SIZE 5
13601 #define RELATIVECALL_OPCODE 0xe8
13602 #define RELATIVE_ADDR_SIZE 4
13603 -#define MAX_STACK_SIZE 64
13604 -#define MIN_STACK_SIZE(ADDR) \
13605 - (((MAX_STACK_SIZE) < (((unsigned long)current_thread_info()) + \
13606 - THREAD_SIZE - (unsigned long)(ADDR))) \
13607 - ? (MAX_STACK_SIZE) \
13608 - : (((unsigned long)current_thread_info()) + \
13609 - THREAD_SIZE - (unsigned long)(ADDR)))
13610 +#define MAX_STACK_SIZE 64UL
13611 +#define MIN_STACK_SIZE(ADDR) min(MAX_STACK_SIZE, current->thread.sp0 - (unsigned long)(ADDR))
13612
13613 #define flush_insn_slot(p) do { } while (0)
13614
13615 diff --git a/arch/x86/include/asm/local.h b/arch/x86/include/asm/local.h
13616 index 2d89e39..baee879 100644
13617 --- a/arch/x86/include/asm/local.h
13618 +++ b/arch/x86/include/asm/local.h
13619 @@ -10,33 +10,97 @@ typedef struct {
13620 atomic_long_t a;
13621 } local_t;
13622
13623 +typedef struct {
13624 + atomic_long_unchecked_t a;
13625 +} local_unchecked_t;
13626 +
13627 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
13628
13629 #define local_read(l) atomic_long_read(&(l)->a)
13630 +#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
13631 #define local_set(l, i) atomic_long_set(&(l)->a, (i))
13632 +#define local_set_unchecked(l, i) atomic_long_set_unchecked(&(l)->a, (i))
13633
13634 static inline void local_inc(local_t *l)
13635 {
13636 - asm volatile(_ASM_INC "%0"
13637 + asm volatile(_ASM_INC "%0\n"
13638 +
13639 +#ifdef CONFIG_PAX_REFCOUNT
13640 + "jno 0f\n"
13641 + _ASM_DEC "%0\n"
13642 + "int $4\n0:\n"
13643 + _ASM_EXTABLE(0b, 0b)
13644 +#endif
13645 +
13646 + : "+m" (l->a.counter));
13647 +}
13648 +
13649 +static inline void local_inc_unchecked(local_unchecked_t *l)
13650 +{
13651 + asm volatile(_ASM_INC "%0\n"
13652 : "+m" (l->a.counter));
13653 }
13654
13655 static inline void local_dec(local_t *l)
13656 {
13657 - asm volatile(_ASM_DEC "%0"
13658 + asm volatile(_ASM_DEC "%0\n"
13659 +
13660 +#ifdef CONFIG_PAX_REFCOUNT
13661 + "jno 0f\n"
13662 + _ASM_INC "%0\n"
13663 + "int $4\n0:\n"
13664 + _ASM_EXTABLE(0b, 0b)
13665 +#endif
13666 +
13667 + : "+m" (l->a.counter));
13668 +}
13669 +
13670 +static inline void local_dec_unchecked(local_unchecked_t *l)
13671 +{
13672 + asm volatile(_ASM_DEC "%0\n"
13673 : "+m" (l->a.counter));
13674 }
13675
13676 static inline void local_add(long i, local_t *l)
13677 {
13678 - asm volatile(_ASM_ADD "%1,%0"
13679 + asm volatile(_ASM_ADD "%1,%0\n"
13680 +
13681 +#ifdef CONFIG_PAX_REFCOUNT
13682 + "jno 0f\n"
13683 + _ASM_SUB "%1,%0\n"
13684 + "int $4\n0:\n"
13685 + _ASM_EXTABLE(0b, 0b)
13686 +#endif
13687 +
13688 + : "+m" (l->a.counter)
13689 + : "ir" (i));
13690 +}
13691 +
13692 +static inline void local_add_unchecked(long i, local_unchecked_t *l)
13693 +{
13694 + asm volatile(_ASM_ADD "%1,%0\n"
13695 : "+m" (l->a.counter)
13696 : "ir" (i));
13697 }
13698
13699 static inline void local_sub(long i, local_t *l)
13700 {
13701 - asm volatile(_ASM_SUB "%1,%0"
13702 + asm volatile(_ASM_SUB "%1,%0\n"
13703 +
13704 +#ifdef CONFIG_PAX_REFCOUNT
13705 + "jno 0f\n"
13706 + _ASM_ADD "%1,%0\n"
13707 + "int $4\n0:\n"
13708 + _ASM_EXTABLE(0b, 0b)
13709 +#endif
13710 +
13711 + : "+m" (l->a.counter)
13712 + : "ir" (i));
13713 +}
13714 +
13715 +static inline void local_sub_unchecked(long i, local_unchecked_t *l)
13716 +{
13717 + asm volatile(_ASM_SUB "%1,%0\n"
13718 : "+m" (l->a.counter)
13719 : "ir" (i));
13720 }
13721 @@ -54,7 +118,16 @@ static inline int local_sub_and_test(long i, local_t *l)
13722 {
13723 unsigned char c;
13724
13725 - asm volatile(_ASM_SUB "%2,%0; sete %1"
13726 + asm volatile(_ASM_SUB "%2,%0\n"
13727 +
13728 +#ifdef CONFIG_PAX_REFCOUNT
13729 + "jno 0f\n"
13730 + _ASM_ADD "%2,%0\n"
13731 + "int $4\n0:\n"
13732 + _ASM_EXTABLE(0b, 0b)
13733 +#endif
13734 +
13735 + "sete %1\n"
13736 : "+m" (l->a.counter), "=qm" (c)
13737 : "ir" (i) : "memory");
13738 return c;
13739 @@ -72,7 +145,16 @@ static inline int local_dec_and_test(local_t *l)
13740 {
13741 unsigned char c;
13742
13743 - asm volatile(_ASM_DEC "%0; sete %1"
13744 + asm volatile(_ASM_DEC "%0\n"
13745 +
13746 +#ifdef CONFIG_PAX_REFCOUNT
13747 + "jno 0f\n"
13748 + _ASM_INC "%0\n"
13749 + "int $4\n0:\n"
13750 + _ASM_EXTABLE(0b, 0b)
13751 +#endif
13752 +
13753 + "sete %1\n"
13754 : "+m" (l->a.counter), "=qm" (c)
13755 : : "memory");
13756 return c != 0;
13757 @@ -90,7 +172,16 @@ static inline int local_inc_and_test(local_t *l)
13758 {
13759 unsigned char c;
13760
13761 - asm volatile(_ASM_INC "%0; sete %1"
13762 + asm volatile(_ASM_INC "%0\n"
13763 +
13764 +#ifdef CONFIG_PAX_REFCOUNT
13765 + "jno 0f\n"
13766 + _ASM_DEC "%0\n"
13767 + "int $4\n0:\n"
13768 + _ASM_EXTABLE(0b, 0b)
13769 +#endif
13770 +
13771 + "sete %1\n"
13772 : "+m" (l->a.counter), "=qm" (c)
13773 : : "memory");
13774 return c != 0;
13775 @@ -109,7 +200,16 @@ static inline int local_add_negative(long i, local_t *l)
13776 {
13777 unsigned char c;
13778
13779 - asm volatile(_ASM_ADD "%2,%0; sets %1"
13780 + asm volatile(_ASM_ADD "%2,%0\n"
13781 +
13782 +#ifdef CONFIG_PAX_REFCOUNT
13783 + "jno 0f\n"
13784 + _ASM_SUB "%2,%0\n"
13785 + "int $4\n0:\n"
13786 + _ASM_EXTABLE(0b, 0b)
13787 +#endif
13788 +
13789 + "sets %1\n"
13790 : "+m" (l->a.counter), "=qm" (c)
13791 : "ir" (i) : "memory");
13792 return c;
13793 @@ -125,6 +225,30 @@ static inline int local_add_negative(long i, local_t *l)
13794 static inline long local_add_return(long i, local_t *l)
13795 {
13796 long __i = i;
13797 + asm volatile(_ASM_XADD "%0, %1\n"
13798 +
13799 +#ifdef CONFIG_PAX_REFCOUNT
13800 + "jno 0f\n"
13801 + _ASM_MOV "%0,%1\n"
13802 + "int $4\n0:\n"
13803 + _ASM_EXTABLE(0b, 0b)
13804 +#endif
13805 +
13806 + : "+r" (i), "+m" (l->a.counter)
13807 + : : "memory");
13808 + return i + __i;
13809 +}
13810 +
13811 +/**
13812 + * local_add_return_unchecked - add and return
13813 + * @i: integer value to add
13814 + * @l: pointer to type local_unchecked_t
13815 + *
13816 + * Atomically adds @i to @l and returns @i + @l
13817 + */
13818 +static inline long local_add_return_unchecked(long i, local_unchecked_t *l)
13819 +{
13820 + long __i = i;
13821 asm volatile(_ASM_XADD "%0, %1;"
13822 : "+r" (i), "+m" (l->a.counter)
13823 : : "memory");
13824 @@ -141,6 +265,8 @@ static inline long local_sub_return(long i, local_t *l)
13825
13826 #define local_cmpxchg(l, o, n) \
13827 (cmpxchg_local(&((l)->a.counter), (o), (n)))
13828 +#define local_cmpxchg_unchecked(l, o, n) \
13829 + (cmpxchg_local(&((l)->a.counter), (o), (n)))
13830 /* Always has a lock prefix */
13831 #define local_xchg(l, n) (xchg(&((l)->a.counter), (n)))
13832
13833 diff --git a/arch/x86/include/asm/mman.h b/arch/x86/include/asm/mman.h
13834 new file mode 100644
13835 index 0000000..2bfd3ba
13836 --- /dev/null
13837 +++ b/arch/x86/include/asm/mman.h
13838 @@ -0,0 +1,15 @@
13839 +#ifndef _X86_MMAN_H
13840 +#define _X86_MMAN_H
13841 +
13842 +#include <uapi/asm/mman.h>
13843 +
13844 +#ifdef __KERNEL__
13845 +#ifndef __ASSEMBLY__
13846 +#ifdef CONFIG_X86_32
13847 +#define arch_mmap_check i386_mmap_check
13848 +int i386_mmap_check(unsigned long addr, unsigned long len, unsigned long flags);
13849 +#endif
13850 +#endif
13851 +#endif
13852 +
13853 +#endif /* X86_MMAN_H */
13854 diff --git a/arch/x86/include/asm/mmu.h b/arch/x86/include/asm/mmu.h
13855 index 5f55e69..e20bfb1 100644
13856 --- a/arch/x86/include/asm/mmu.h
13857 +++ b/arch/x86/include/asm/mmu.h
13858 @@ -9,7 +9,7 @@
13859 * we put the segment information here.
13860 */
13861 typedef struct {
13862 - void *ldt;
13863 + struct desc_struct *ldt;
13864 int size;
13865
13866 #ifdef CONFIG_X86_64
13867 @@ -18,7 +18,19 @@ typedef struct {
13868 #endif
13869
13870 struct mutex lock;
13871 - void *vdso;
13872 + unsigned long vdso;
13873 +
13874 +#ifdef CONFIG_X86_32
13875 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
13876 + unsigned long user_cs_base;
13877 + unsigned long user_cs_limit;
13878 +
13879 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
13880 + cpumask_t cpu_user_cs_mask;
13881 +#endif
13882 +
13883 +#endif
13884 +#endif
13885 } mm_context_t;
13886
13887 #ifdef CONFIG_SMP
13888 diff --git a/arch/x86/include/asm/mmu_context.h b/arch/x86/include/asm/mmu_context.h
13889 index cdbf367..adb37ac 100644
13890 --- a/arch/x86/include/asm/mmu_context.h
13891 +++ b/arch/x86/include/asm/mmu_context.h
13892 @@ -24,6 +24,18 @@ void destroy_context(struct mm_struct *mm);
13893
13894 static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
13895 {
13896 +
13897 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
13898 + unsigned int i;
13899 + pgd_t *pgd;
13900 +
13901 + pax_open_kernel();
13902 + pgd = get_cpu_pgd(smp_processor_id());
13903 + for (i = USER_PGD_PTRS; i < 2 * USER_PGD_PTRS; ++i)
13904 + set_pgd_batched(pgd+i, native_make_pgd(0));
13905 + pax_close_kernel();
13906 +#endif
13907 +
13908 #ifdef CONFIG_SMP
13909 if (this_cpu_read(cpu_tlbstate.state) == TLBSTATE_OK)
13910 this_cpu_write(cpu_tlbstate.state, TLBSTATE_LAZY);
13911 @@ -34,16 +46,30 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
13912 struct task_struct *tsk)
13913 {
13914 unsigned cpu = smp_processor_id();
13915 +#if defined(CONFIG_X86_32) && defined(CONFIG_SMP) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
13916 + int tlbstate = TLBSTATE_OK;
13917 +#endif
13918
13919 if (likely(prev != next)) {
13920 #ifdef CONFIG_SMP
13921 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
13922 + tlbstate = this_cpu_read(cpu_tlbstate.state);
13923 +#endif
13924 this_cpu_write(cpu_tlbstate.state, TLBSTATE_OK);
13925 this_cpu_write(cpu_tlbstate.active_mm, next);
13926 #endif
13927 cpumask_set_cpu(cpu, mm_cpumask(next));
13928
13929 /* Re-load page tables */
13930 +#ifdef CONFIG_PAX_PER_CPU_PGD
13931 + pax_open_kernel();
13932 + __clone_user_pgds(get_cpu_pgd(cpu), next->pgd);
13933 + __shadow_user_pgds(get_cpu_pgd(cpu) + USER_PGD_PTRS, next->pgd);
13934 + pax_close_kernel();
13935 + load_cr3(get_cpu_pgd(cpu));
13936 +#else
13937 load_cr3(next->pgd);
13938 +#endif
13939
13940 /* stop flush ipis for the previous mm */
13941 cpumask_clear_cpu(cpu, mm_cpumask(prev));
13942 @@ -53,9 +79,38 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
13943 */
13944 if (unlikely(prev->context.ldt != next->context.ldt))
13945 load_LDT_nolock(&next->context);
13946 - }
13947 +
13948 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
13949 + if (!(__supported_pte_mask & _PAGE_NX)) {
13950 + smp_mb__before_clear_bit();
13951 + cpu_clear(cpu, prev->context.cpu_user_cs_mask);
13952 + smp_mb__after_clear_bit();
13953 + cpu_set(cpu, next->context.cpu_user_cs_mask);
13954 + }
13955 +#endif
13956 +
13957 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
13958 + if (unlikely(prev->context.user_cs_base != next->context.user_cs_base ||
13959 + prev->context.user_cs_limit != next->context.user_cs_limit))
13960 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
13961 #ifdef CONFIG_SMP
13962 + else if (unlikely(tlbstate != TLBSTATE_OK))
13963 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
13964 +#endif
13965 +#endif
13966 +
13967 + }
13968 else {
13969 +
13970 +#ifdef CONFIG_PAX_PER_CPU_PGD
13971 + pax_open_kernel();
13972 + __clone_user_pgds(get_cpu_pgd(cpu), next->pgd);
13973 + __shadow_user_pgds(get_cpu_pgd(cpu) + USER_PGD_PTRS, next->pgd);
13974 + pax_close_kernel();
13975 + load_cr3(get_cpu_pgd(cpu));
13976 +#endif
13977 +
13978 +#ifdef CONFIG_SMP
13979 this_cpu_write(cpu_tlbstate.state, TLBSTATE_OK);
13980 BUG_ON(this_cpu_read(cpu_tlbstate.active_mm) != next);
13981
13982 @@ -64,11 +119,28 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
13983 * tlb flush IPI delivery. We must reload CR3
13984 * to make sure to use no freed page tables.
13985 */
13986 +
13987 +#ifndef CONFIG_PAX_PER_CPU_PGD
13988 load_cr3(next->pgd);
13989 +#endif
13990 +
13991 load_LDT_nolock(&next->context);
13992 +
13993 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
13994 + if (!(__supported_pte_mask & _PAGE_NX))
13995 + cpu_set(cpu, next->context.cpu_user_cs_mask);
13996 +#endif
13997 +
13998 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
13999 +#ifdef CONFIG_PAX_PAGEEXEC
14000 + if (!((next->pax_flags & MF_PAX_PAGEEXEC) && (__supported_pte_mask & _PAGE_NX)))
14001 +#endif
14002 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
14003 +#endif
14004 +
14005 }
14006 +#endif
14007 }
14008 -#endif
14009 }
14010
14011 #define activate_mm(prev, next) \
14012 diff --git a/arch/x86/include/asm/module.h b/arch/x86/include/asm/module.h
14013 index e3b7819..b257c64 100644
14014 --- a/arch/x86/include/asm/module.h
14015 +++ b/arch/x86/include/asm/module.h
14016 @@ -5,6 +5,7 @@
14017
14018 #ifdef CONFIG_X86_64
14019 /* X86_64 does not define MODULE_PROC_FAMILY */
14020 +#define MODULE_PROC_FAMILY ""
14021 #elif defined CONFIG_M486
14022 #define MODULE_PROC_FAMILY "486 "
14023 #elif defined CONFIG_M586
14024 @@ -57,8 +58,20 @@
14025 #error unknown processor family
14026 #endif
14027
14028 -#ifdef CONFIG_X86_32
14029 -# define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY
14030 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_BTS
14031 +#define MODULE_PAX_KERNEXEC "KERNEXEC_BTS "
14032 +#elif defined(CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR)
14033 +#define MODULE_PAX_KERNEXEC "KERNEXEC_OR "
14034 +#else
14035 +#define MODULE_PAX_KERNEXEC ""
14036 #endif
14037
14038 +#ifdef CONFIG_PAX_MEMORY_UDEREF
14039 +#define MODULE_PAX_UDEREF "UDEREF "
14040 +#else
14041 +#define MODULE_PAX_UDEREF ""
14042 +#endif
14043 +
14044 +#define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY MODULE_PAX_KERNEXEC MODULE_PAX_UDEREF
14045 +
14046 #endif /* _ASM_X86_MODULE_H */
14047 diff --git a/arch/x86/include/asm/nmi.h b/arch/x86/include/asm/nmi.h
14048 index c0fa356..07a498a 100644
14049 --- a/arch/x86/include/asm/nmi.h
14050 +++ b/arch/x86/include/asm/nmi.h
14051 @@ -42,11 +42,11 @@ struct nmiaction {
14052 nmi_handler_t handler;
14053 unsigned long flags;
14054 const char *name;
14055 -};
14056 +} __do_const;
14057
14058 #define register_nmi_handler(t, fn, fg, n, init...) \
14059 ({ \
14060 - static struct nmiaction init fn##_na = { \
14061 + static const struct nmiaction init fn##_na = { \
14062 .handler = (fn), \
14063 .name = (n), \
14064 .flags = (fg), \
14065 @@ -54,7 +54,7 @@ struct nmiaction {
14066 __register_nmi_handler((t), &fn##_na); \
14067 })
14068
14069 -int __register_nmi_handler(unsigned int, struct nmiaction *);
14070 +int __register_nmi_handler(unsigned int, const struct nmiaction *);
14071
14072 void unregister_nmi_handler(unsigned int, const char *);
14073
14074 diff --git a/arch/x86/include/asm/page_64.h b/arch/x86/include/asm/page_64.h
14075 index 0f1ddee..e2fc3d1 100644
14076 --- a/arch/x86/include/asm/page_64.h
14077 +++ b/arch/x86/include/asm/page_64.h
14078 @@ -7,9 +7,9 @@
14079
14080 /* duplicated to the one in bootmem.h */
14081 extern unsigned long max_pfn;
14082 -extern unsigned long phys_base;
14083 +extern const unsigned long phys_base;
14084
14085 -static inline unsigned long __phys_addr_nodebug(unsigned long x)
14086 +static inline unsigned long __intentional_overflow(-1) __phys_addr_nodebug(unsigned long x)
14087 {
14088 unsigned long y = x - __START_KERNEL_map;
14089
14090 diff --git a/arch/x86/include/asm/paravirt.h b/arch/x86/include/asm/paravirt.h
14091 index 7361e47..16dc226 100644
14092 --- a/arch/x86/include/asm/paravirt.h
14093 +++ b/arch/x86/include/asm/paravirt.h
14094 @@ -564,7 +564,7 @@ static inline pmd_t __pmd(pmdval_t val)
14095 return (pmd_t) { ret };
14096 }
14097
14098 -static inline pmdval_t pmd_val(pmd_t pmd)
14099 +static inline __intentional_overflow(-1) pmdval_t pmd_val(pmd_t pmd)
14100 {
14101 pmdval_t ret;
14102
14103 @@ -630,6 +630,18 @@ static inline void set_pgd(pgd_t *pgdp, pgd_t pgd)
14104 val);
14105 }
14106
14107 +static inline void set_pgd_batched(pgd_t *pgdp, pgd_t pgd)
14108 +{
14109 + pgdval_t val = native_pgd_val(pgd);
14110 +
14111 + if (sizeof(pgdval_t) > sizeof(long))
14112 + PVOP_VCALL3(pv_mmu_ops.set_pgd_batched, pgdp,
14113 + val, (u64)val >> 32);
14114 + else
14115 + PVOP_VCALL2(pv_mmu_ops.set_pgd_batched, pgdp,
14116 + val);
14117 +}
14118 +
14119 static inline void pgd_clear(pgd_t *pgdp)
14120 {
14121 set_pgd(pgdp, __pgd(0));
14122 @@ -714,6 +726,21 @@ static inline void __set_fixmap(unsigned /* enum fixed_addresses */ idx,
14123 pv_mmu_ops.set_fixmap(idx, phys, flags);
14124 }
14125
14126 +#ifdef CONFIG_PAX_KERNEXEC
14127 +static inline unsigned long pax_open_kernel(void)
14128 +{
14129 + return PVOP_CALL0(unsigned long, pv_mmu_ops.pax_open_kernel);
14130 +}
14131 +
14132 +static inline unsigned long pax_close_kernel(void)
14133 +{
14134 + return PVOP_CALL0(unsigned long, pv_mmu_ops.pax_close_kernel);
14135 +}
14136 +#else
14137 +static inline unsigned long pax_open_kernel(void) { return 0; }
14138 +static inline unsigned long pax_close_kernel(void) { return 0; }
14139 +#endif
14140 +
14141 #if defined(CONFIG_SMP) && defined(CONFIG_PARAVIRT_SPINLOCKS)
14142
14143 static inline int arch_spin_is_locked(struct arch_spinlock *lock)
14144 @@ -930,7 +957,7 @@ extern void default_banner(void);
14145
14146 #define PARA_PATCH(struct, off) ((PARAVIRT_PATCH_##struct + (off)) / 4)
14147 #define PARA_SITE(ptype, clobbers, ops) _PVSITE(ptype, clobbers, ops, .long, 4)
14148 -#define PARA_INDIRECT(addr) *%cs:addr
14149 +#define PARA_INDIRECT(addr) *%ss:addr
14150 #endif
14151
14152 #define INTERRUPT_RETURN \
14153 @@ -1005,6 +1032,21 @@ extern void default_banner(void);
14154 PARA_SITE(PARA_PATCH(pv_cpu_ops, PV_CPU_irq_enable_sysexit), \
14155 CLBR_NONE, \
14156 jmp PARA_INDIRECT(pv_cpu_ops+PV_CPU_irq_enable_sysexit))
14157 +
14158 +#define GET_CR0_INTO_RDI \
14159 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0); \
14160 + mov %rax,%rdi
14161 +
14162 +#define SET_RDI_INTO_CR0 \
14163 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0)
14164 +
14165 +#define GET_CR3_INTO_RDI \
14166 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_read_cr3); \
14167 + mov %rax,%rdi
14168 +
14169 +#define SET_RDI_INTO_CR3 \
14170 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_write_cr3)
14171 +
14172 #endif /* CONFIG_X86_32 */
14173
14174 #endif /* __ASSEMBLY__ */
14175 diff --git a/arch/x86/include/asm/paravirt_types.h b/arch/x86/include/asm/paravirt_types.h
14176 index b3b0ec1..b1cd3eb 100644
14177 --- a/arch/x86/include/asm/paravirt_types.h
14178 +++ b/arch/x86/include/asm/paravirt_types.h
14179 @@ -84,7 +84,7 @@ struct pv_init_ops {
14180 */
14181 unsigned (*patch)(u8 type, u16 clobber, void *insnbuf,
14182 unsigned long addr, unsigned len);
14183 -};
14184 +} __no_const;
14185
14186
14187 struct pv_lazy_ops {
14188 @@ -98,7 +98,7 @@ struct pv_time_ops {
14189 unsigned long long (*sched_clock)(void);
14190 unsigned long long (*steal_clock)(int cpu);
14191 unsigned long (*get_tsc_khz)(void);
14192 -};
14193 +} __no_const;
14194
14195 struct pv_cpu_ops {
14196 /* hooks for various privileged instructions */
14197 @@ -192,7 +192,7 @@ struct pv_cpu_ops {
14198
14199 void (*start_context_switch)(struct task_struct *prev);
14200 void (*end_context_switch)(struct task_struct *next);
14201 -};
14202 +} __no_const;
14203
14204 struct pv_irq_ops {
14205 /*
14206 @@ -223,7 +223,7 @@ struct pv_apic_ops {
14207 unsigned long start_eip,
14208 unsigned long start_esp);
14209 #endif
14210 -};
14211 +} __no_const;
14212
14213 struct pv_mmu_ops {
14214 unsigned long (*read_cr2)(void);
14215 @@ -313,6 +313,7 @@ struct pv_mmu_ops {
14216 struct paravirt_callee_save make_pud;
14217
14218 void (*set_pgd)(pgd_t *pudp, pgd_t pgdval);
14219 + void (*set_pgd_batched)(pgd_t *pudp, pgd_t pgdval);
14220 #endif /* PAGETABLE_LEVELS == 4 */
14221 #endif /* PAGETABLE_LEVELS >= 3 */
14222
14223 @@ -324,6 +325,12 @@ struct pv_mmu_ops {
14224 an mfn. We can tell which is which from the index. */
14225 void (*set_fixmap)(unsigned /* enum fixed_addresses */ idx,
14226 phys_addr_t phys, pgprot_t flags);
14227 +
14228 +#ifdef CONFIG_PAX_KERNEXEC
14229 + unsigned long (*pax_open_kernel)(void);
14230 + unsigned long (*pax_close_kernel)(void);
14231 +#endif
14232 +
14233 };
14234
14235 struct arch_spinlock;
14236 @@ -334,7 +341,7 @@ struct pv_lock_ops {
14237 void (*spin_lock_flags)(struct arch_spinlock *lock, unsigned long flags);
14238 int (*spin_trylock)(struct arch_spinlock *lock);
14239 void (*spin_unlock)(struct arch_spinlock *lock);
14240 -};
14241 +} __no_const;
14242
14243 /* This contains all the paravirt structures: we get a convenient
14244 * number for each function using the offset which we use to indicate
14245 diff --git a/arch/x86/include/asm/pgalloc.h b/arch/x86/include/asm/pgalloc.h
14246 index b4389a4..7024269 100644
14247 --- a/arch/x86/include/asm/pgalloc.h
14248 +++ b/arch/x86/include/asm/pgalloc.h
14249 @@ -63,6 +63,13 @@ static inline void pmd_populate_kernel(struct mm_struct *mm,
14250 pmd_t *pmd, pte_t *pte)
14251 {
14252 paravirt_alloc_pte(mm, __pa(pte) >> PAGE_SHIFT);
14253 + set_pmd(pmd, __pmd(__pa(pte) | _KERNPG_TABLE));
14254 +}
14255 +
14256 +static inline void pmd_populate_user(struct mm_struct *mm,
14257 + pmd_t *pmd, pte_t *pte)
14258 +{
14259 + paravirt_alloc_pte(mm, __pa(pte) >> PAGE_SHIFT);
14260 set_pmd(pmd, __pmd(__pa(pte) | _PAGE_TABLE));
14261 }
14262
14263 @@ -99,12 +106,22 @@ static inline void __pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmd,
14264
14265 #ifdef CONFIG_X86_PAE
14266 extern void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd);
14267 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
14268 +{
14269 + pud_populate(mm, pudp, pmd);
14270 +}
14271 #else /* !CONFIG_X86_PAE */
14272 static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
14273 {
14274 paravirt_alloc_pmd(mm, __pa(pmd) >> PAGE_SHIFT);
14275 set_pud(pud, __pud(_PAGE_TABLE | __pa(pmd)));
14276 }
14277 +
14278 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
14279 +{
14280 + paravirt_alloc_pmd(mm, __pa(pmd) >> PAGE_SHIFT);
14281 + set_pud(pud, __pud(_KERNPG_TABLE | __pa(pmd)));
14282 +}
14283 #endif /* CONFIG_X86_PAE */
14284
14285 #if PAGETABLE_LEVELS > 3
14286 @@ -114,6 +131,12 @@ static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pud_t *pud)
14287 set_pgd(pgd, __pgd(_PAGE_TABLE | __pa(pud)));
14288 }
14289
14290 +static inline void pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pud_t *pud)
14291 +{
14292 + paravirt_alloc_pud(mm, __pa(pud) >> PAGE_SHIFT);
14293 + set_pgd(pgd, __pgd(_KERNPG_TABLE | __pa(pud)));
14294 +}
14295 +
14296 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
14297 {
14298 return (pud_t *)get_zeroed_page(GFP_KERNEL|__GFP_REPEAT);
14299 diff --git a/arch/x86/include/asm/pgtable-2level.h b/arch/x86/include/asm/pgtable-2level.h
14300 index f2b489c..4f7e2e5 100644
14301 --- a/arch/x86/include/asm/pgtable-2level.h
14302 +++ b/arch/x86/include/asm/pgtable-2level.h
14303 @@ -18,7 +18,9 @@ static inline void native_set_pte(pte_t *ptep , pte_t pte)
14304
14305 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
14306 {
14307 + pax_open_kernel();
14308 *pmdp = pmd;
14309 + pax_close_kernel();
14310 }
14311
14312 static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
14313 diff --git a/arch/x86/include/asm/pgtable-3level.h b/arch/x86/include/asm/pgtable-3level.h
14314 index 4cc9f2b..5fd9226 100644
14315 --- a/arch/x86/include/asm/pgtable-3level.h
14316 +++ b/arch/x86/include/asm/pgtable-3level.h
14317 @@ -92,12 +92,16 @@ static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
14318
14319 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
14320 {
14321 + pax_open_kernel();
14322 set_64bit((unsigned long long *)(pmdp), native_pmd_val(pmd));
14323 + pax_close_kernel();
14324 }
14325
14326 static inline void native_set_pud(pud_t *pudp, pud_t pud)
14327 {
14328 + pax_open_kernel();
14329 set_64bit((unsigned long long *)(pudp), native_pud_val(pud));
14330 + pax_close_kernel();
14331 }
14332
14333 /*
14334 diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h
14335 index 1e67223..dd6e7ea 100644
14336 --- a/arch/x86/include/asm/pgtable.h
14337 +++ b/arch/x86/include/asm/pgtable.h
14338 @@ -44,6 +44,7 @@ extern struct mm_struct *pgd_page_get_mm(struct page *page);
14339
14340 #ifndef __PAGETABLE_PUD_FOLDED
14341 #define set_pgd(pgdp, pgd) native_set_pgd(pgdp, pgd)
14342 +#define set_pgd_batched(pgdp, pgd) native_set_pgd_batched(pgdp, pgd)
14343 #define pgd_clear(pgd) native_pgd_clear(pgd)
14344 #endif
14345
14346 @@ -81,12 +82,51 @@ extern struct mm_struct *pgd_page_get_mm(struct page *page);
14347
14348 #define arch_end_context_switch(prev) do {} while(0)
14349
14350 +#define pax_open_kernel() native_pax_open_kernel()
14351 +#define pax_close_kernel() native_pax_close_kernel()
14352 #endif /* CONFIG_PARAVIRT */
14353
14354 +#define __HAVE_ARCH_PAX_OPEN_KERNEL
14355 +#define __HAVE_ARCH_PAX_CLOSE_KERNEL
14356 +
14357 +#ifdef CONFIG_PAX_KERNEXEC
14358 +static inline unsigned long native_pax_open_kernel(void)
14359 +{
14360 + unsigned long cr0;
14361 +
14362 + preempt_disable();
14363 + barrier();
14364 + cr0 = read_cr0() ^ X86_CR0_WP;
14365 + BUG_ON(cr0 & X86_CR0_WP);
14366 + write_cr0(cr0);
14367 + return cr0 ^ X86_CR0_WP;
14368 +}
14369 +
14370 +static inline unsigned long native_pax_close_kernel(void)
14371 +{
14372 + unsigned long cr0;
14373 +
14374 + cr0 = read_cr0() ^ X86_CR0_WP;
14375 + BUG_ON(!(cr0 & X86_CR0_WP));
14376 + write_cr0(cr0);
14377 + barrier();
14378 + preempt_enable_no_resched();
14379 + return cr0 ^ X86_CR0_WP;
14380 +}
14381 +#else
14382 +static inline unsigned long native_pax_open_kernel(void) { return 0; }
14383 +static inline unsigned long native_pax_close_kernel(void) { return 0; }
14384 +#endif
14385 +
14386 /*
14387 * The following only work if pte_present() is true.
14388 * Undefined behaviour if not..
14389 */
14390 +static inline int pte_user(pte_t pte)
14391 +{
14392 + return pte_val(pte) & _PAGE_USER;
14393 +}
14394 +
14395 static inline int pte_dirty(pte_t pte)
14396 {
14397 return pte_flags(pte) & _PAGE_DIRTY;
14398 @@ -147,6 +187,11 @@ static inline unsigned long pud_pfn(pud_t pud)
14399 return (pud_val(pud) & PTE_PFN_MASK) >> PAGE_SHIFT;
14400 }
14401
14402 +static inline unsigned long pgd_pfn(pgd_t pgd)
14403 +{
14404 + return (pgd_val(pgd) & PTE_PFN_MASK) >> PAGE_SHIFT;
14405 +}
14406 +
14407 #define pte_page(pte) pfn_to_page(pte_pfn(pte))
14408
14409 static inline int pmd_large(pmd_t pte)
14410 @@ -200,9 +245,29 @@ static inline pte_t pte_wrprotect(pte_t pte)
14411 return pte_clear_flags(pte, _PAGE_RW);
14412 }
14413
14414 +static inline pte_t pte_mkread(pte_t pte)
14415 +{
14416 + return __pte(pte_val(pte) | _PAGE_USER);
14417 +}
14418 +
14419 static inline pte_t pte_mkexec(pte_t pte)
14420 {
14421 - return pte_clear_flags(pte, _PAGE_NX);
14422 +#ifdef CONFIG_X86_PAE
14423 + if (__supported_pte_mask & _PAGE_NX)
14424 + return pte_clear_flags(pte, _PAGE_NX);
14425 + else
14426 +#endif
14427 + return pte_set_flags(pte, _PAGE_USER);
14428 +}
14429 +
14430 +static inline pte_t pte_exprotect(pte_t pte)
14431 +{
14432 +#ifdef CONFIG_X86_PAE
14433 + if (__supported_pte_mask & _PAGE_NX)
14434 + return pte_set_flags(pte, _PAGE_NX);
14435 + else
14436 +#endif
14437 + return pte_clear_flags(pte, _PAGE_USER);
14438 }
14439
14440 static inline pte_t pte_mkdirty(pte_t pte)
14441 @@ -394,6 +459,15 @@ pte_t *populate_extra_pte(unsigned long vaddr);
14442 #endif
14443
14444 #ifndef __ASSEMBLY__
14445 +
14446 +#ifdef CONFIG_PAX_PER_CPU_PGD
14447 +extern pgd_t cpu_pgd[NR_CPUS][PTRS_PER_PGD];
14448 +static inline pgd_t *get_cpu_pgd(unsigned int cpu)
14449 +{
14450 + return cpu_pgd[cpu];
14451 +}
14452 +#endif
14453 +
14454 #include <linux/mm_types.h>
14455 #include <linux/log2.h>
14456
14457 @@ -529,7 +603,7 @@ static inline unsigned long pud_page_vaddr(pud_t pud)
14458 * Currently stuck as a macro due to indirect forward reference to
14459 * linux/mmzone.h's __section_mem_map_addr() definition:
14460 */
14461 -#define pud_page(pud) pfn_to_page(pud_val(pud) >> PAGE_SHIFT)
14462 +#define pud_page(pud) pfn_to_page((pud_val(pud) & PTE_PFN_MASK) >> PAGE_SHIFT)
14463
14464 /* Find an entry in the second-level page table.. */
14465 static inline pmd_t *pmd_offset(pud_t *pud, unsigned long address)
14466 @@ -569,7 +643,7 @@ static inline unsigned long pgd_page_vaddr(pgd_t pgd)
14467 * Currently stuck as a macro due to indirect forward reference to
14468 * linux/mmzone.h's __section_mem_map_addr() definition:
14469 */
14470 -#define pgd_page(pgd) pfn_to_page(pgd_val(pgd) >> PAGE_SHIFT)
14471 +#define pgd_page(pgd) pfn_to_page((pgd_val(pgd) & PTE_PFN_MASK) >> PAGE_SHIFT)
14472
14473 /* to find an entry in a page-table-directory. */
14474 static inline unsigned long pud_index(unsigned long address)
14475 @@ -584,7 +658,7 @@ static inline pud_t *pud_offset(pgd_t *pgd, unsigned long address)
14476
14477 static inline int pgd_bad(pgd_t pgd)
14478 {
14479 - return (pgd_flags(pgd) & ~_PAGE_USER) != _KERNPG_TABLE;
14480 + return (pgd_flags(pgd) & ~(_PAGE_USER | _PAGE_NX)) != _KERNPG_TABLE;
14481 }
14482
14483 static inline int pgd_none(pgd_t pgd)
14484 @@ -607,7 +681,12 @@ static inline int pgd_none(pgd_t pgd)
14485 * pgd_offset() returns a (pgd_t *)
14486 * pgd_index() is used get the offset into the pgd page's array of pgd_t's;
14487 */
14488 -#define pgd_offset(mm, address) ((mm)->pgd + pgd_index((address)))
14489 +#define pgd_offset(mm, address) ((mm)->pgd + pgd_index(address))
14490 +
14491 +#ifdef CONFIG_PAX_PER_CPU_PGD
14492 +#define pgd_offset_cpu(cpu, address) (get_cpu_pgd(cpu) + pgd_index(address))
14493 +#endif
14494 +
14495 /*
14496 * a shortcut which implies the use of the kernel's pgd, instead
14497 * of a process's
14498 @@ -618,6 +697,22 @@ static inline int pgd_none(pgd_t pgd)
14499 #define KERNEL_PGD_BOUNDARY pgd_index(PAGE_OFFSET)
14500 #define KERNEL_PGD_PTRS (PTRS_PER_PGD - KERNEL_PGD_BOUNDARY)
14501
14502 +#ifdef CONFIG_X86_32
14503 +#define USER_PGD_PTRS KERNEL_PGD_BOUNDARY
14504 +#else
14505 +#define TASK_SIZE_MAX_SHIFT CONFIG_TASK_SIZE_MAX_SHIFT
14506 +#define USER_PGD_PTRS (_AC(1,UL) << (TASK_SIZE_MAX_SHIFT - PGDIR_SHIFT))
14507 +
14508 +#ifdef CONFIG_PAX_MEMORY_UDEREF
14509 +#ifdef __ASSEMBLY__
14510 +#define pax_user_shadow_base pax_user_shadow_base(%rip)
14511 +#else
14512 +extern unsigned long pax_user_shadow_base;
14513 +#endif
14514 +#endif
14515 +
14516 +#endif
14517 +
14518 #ifndef __ASSEMBLY__
14519
14520 extern int direct_gbpages;
14521 @@ -784,11 +879,24 @@ static inline void pmdp_set_wrprotect(struct mm_struct *mm,
14522 * dst and src can be on the same page, but the range must not overlap,
14523 * and must not cross a page boundary.
14524 */
14525 -static inline void clone_pgd_range(pgd_t *dst, pgd_t *src, int count)
14526 +static inline void clone_pgd_range(pgd_t *dst, const pgd_t *src, int count)
14527 {
14528 - memcpy(dst, src, count * sizeof(pgd_t));
14529 + pax_open_kernel();
14530 + while (count--)
14531 + *dst++ = *src++;
14532 + pax_close_kernel();
14533 }
14534
14535 +#ifdef CONFIG_PAX_PER_CPU_PGD
14536 +extern void __clone_user_pgds(pgd_t *dst, const pgd_t *src);
14537 +#endif
14538 +
14539 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
14540 +extern void __shadow_user_pgds(pgd_t *dst, const pgd_t *src);
14541 +#else
14542 +static inline void __shadow_user_pgds(pgd_t *dst, const pgd_t *src) {}
14543 +#endif
14544 +
14545 #define PTE_SHIFT ilog2(PTRS_PER_PTE)
14546 static inline int page_level_shift(enum pg_level level)
14547 {
14548 diff --git a/arch/x86/include/asm/pgtable_32.h b/arch/x86/include/asm/pgtable_32.h
14549 index 9ee3221..b979c6b 100644
14550 --- a/arch/x86/include/asm/pgtable_32.h
14551 +++ b/arch/x86/include/asm/pgtable_32.h
14552 @@ -25,9 +25,6 @@
14553 struct mm_struct;
14554 struct vm_area_struct;
14555
14556 -extern pgd_t swapper_pg_dir[1024];
14557 -extern pgd_t initial_page_table[1024];
14558 -
14559 static inline void pgtable_cache_init(void) { }
14560 static inline void check_pgt_cache(void) { }
14561 void paging_init(void);
14562 @@ -48,6 +45,12 @@ extern void set_pmd_pfn(unsigned long, unsigned long, pgprot_t);
14563 # include <asm/pgtable-2level.h>
14564 #endif
14565
14566 +extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
14567 +extern pgd_t initial_page_table[PTRS_PER_PGD];
14568 +#ifdef CONFIG_X86_PAE
14569 +extern pmd_t swapper_pm_dir[PTRS_PER_PGD][PTRS_PER_PMD];
14570 +#endif
14571 +
14572 #if defined(CONFIG_HIGHPTE)
14573 #define pte_offset_map(dir, address) \
14574 ((pte_t *)kmap_atomic(pmd_page(*(dir))) + \
14575 @@ -62,12 +65,17 @@ extern void set_pmd_pfn(unsigned long, unsigned long, pgprot_t);
14576 /* Clear a kernel PTE and flush it from the TLB */
14577 #define kpte_clear_flush(ptep, vaddr) \
14578 do { \
14579 + pax_open_kernel(); \
14580 pte_clear(&init_mm, (vaddr), (ptep)); \
14581 + pax_close_kernel(); \
14582 __flush_tlb_one((vaddr)); \
14583 } while (0)
14584
14585 #endif /* !__ASSEMBLY__ */
14586
14587 +#define HAVE_ARCH_UNMAPPED_AREA
14588 +#define HAVE_ARCH_UNMAPPED_AREA_TOPDOWN
14589 +
14590 /*
14591 * kern_addr_valid() is (1) for FLATMEM and (0) for
14592 * SPARSEMEM and DISCONTIGMEM
14593 diff --git a/arch/x86/include/asm/pgtable_32_types.h b/arch/x86/include/asm/pgtable_32_types.h
14594 index ed5903b..c7fe163 100644
14595 --- a/arch/x86/include/asm/pgtable_32_types.h
14596 +++ b/arch/x86/include/asm/pgtable_32_types.h
14597 @@ -8,7 +8,7 @@
14598 */
14599 #ifdef CONFIG_X86_PAE
14600 # include <asm/pgtable-3level_types.h>
14601 -# define PMD_SIZE (1UL << PMD_SHIFT)
14602 +# define PMD_SIZE (_AC(1, UL) << PMD_SHIFT)
14603 # define PMD_MASK (~(PMD_SIZE - 1))
14604 #else
14605 # include <asm/pgtable-2level_types.h>
14606 @@ -46,6 +46,19 @@ extern bool __vmalloc_start_set; /* set once high_memory is set */
14607 # define VMALLOC_END (FIXADDR_START - 2 * PAGE_SIZE)
14608 #endif
14609
14610 +#ifdef CONFIG_PAX_KERNEXEC
14611 +#ifndef __ASSEMBLY__
14612 +extern unsigned char MODULES_EXEC_VADDR[];
14613 +extern unsigned char MODULES_EXEC_END[];
14614 +#endif
14615 +#include <asm/boot.h>
14616 +#define ktla_ktva(addr) (addr + LOAD_PHYSICAL_ADDR + PAGE_OFFSET)
14617 +#define ktva_ktla(addr) (addr - LOAD_PHYSICAL_ADDR - PAGE_OFFSET)
14618 +#else
14619 +#define ktla_ktva(addr) (addr)
14620 +#define ktva_ktla(addr) (addr)
14621 +#endif
14622 +
14623 #define MODULES_VADDR VMALLOC_START
14624 #define MODULES_END VMALLOC_END
14625 #define MODULES_LEN (MODULES_VADDR - MODULES_END)
14626 diff --git a/arch/x86/include/asm/pgtable_64.h b/arch/x86/include/asm/pgtable_64.h
14627 index e22c1db..23a625a 100644
14628 --- a/arch/x86/include/asm/pgtable_64.h
14629 +++ b/arch/x86/include/asm/pgtable_64.h
14630 @@ -16,10 +16,14 @@
14631
14632 extern pud_t level3_kernel_pgt[512];
14633 extern pud_t level3_ident_pgt[512];
14634 +extern pud_t level3_vmalloc_start_pgt[512];
14635 +extern pud_t level3_vmalloc_end_pgt[512];
14636 +extern pud_t level3_vmemmap_pgt[512];
14637 +extern pud_t level2_vmemmap_pgt[512];
14638 extern pmd_t level2_kernel_pgt[512];
14639 extern pmd_t level2_fixmap_pgt[512];
14640 -extern pmd_t level2_ident_pgt[512];
14641 -extern pgd_t init_level4_pgt[];
14642 +extern pmd_t level2_ident_pgt[512*2];
14643 +extern pgd_t init_level4_pgt[512];
14644
14645 #define swapper_pg_dir init_level4_pgt
14646
14647 @@ -61,7 +65,9 @@ static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
14648
14649 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
14650 {
14651 + pax_open_kernel();
14652 *pmdp = pmd;
14653 + pax_close_kernel();
14654 }
14655
14656 static inline void native_pmd_clear(pmd_t *pmd)
14657 @@ -97,7 +103,9 @@ static inline pmd_t native_pmdp_get_and_clear(pmd_t *xp)
14658
14659 static inline void native_set_pud(pud_t *pudp, pud_t pud)
14660 {
14661 + pax_open_kernel();
14662 *pudp = pud;
14663 + pax_close_kernel();
14664 }
14665
14666 static inline void native_pud_clear(pud_t *pud)
14667 @@ -107,6 +115,13 @@ static inline void native_pud_clear(pud_t *pud)
14668
14669 static inline void native_set_pgd(pgd_t *pgdp, pgd_t pgd)
14670 {
14671 + pax_open_kernel();
14672 + *pgdp = pgd;
14673 + pax_close_kernel();
14674 +}
14675 +
14676 +static inline void native_set_pgd_batched(pgd_t *pgdp, pgd_t pgd)
14677 +{
14678 *pgdp = pgd;
14679 }
14680
14681 diff --git a/arch/x86/include/asm/pgtable_64_types.h b/arch/x86/include/asm/pgtable_64_types.h
14682 index 2d88344..4679fc3 100644
14683 --- a/arch/x86/include/asm/pgtable_64_types.h
14684 +++ b/arch/x86/include/asm/pgtable_64_types.h
14685 @@ -61,6 +61,11 @@ typedef struct { pteval_t pte; } pte_t;
14686 #define MODULES_VADDR _AC(0xffffffffa0000000, UL)
14687 #define MODULES_END _AC(0xffffffffff000000, UL)
14688 #define MODULES_LEN (MODULES_END - MODULES_VADDR)
14689 +#define MODULES_EXEC_VADDR MODULES_VADDR
14690 +#define MODULES_EXEC_END MODULES_END
14691 +
14692 +#define ktla_ktva(addr) (addr)
14693 +#define ktva_ktla(addr) (addr)
14694
14695 #define EARLY_DYNAMIC_PAGE_TABLES 64
14696
14697 diff --git a/arch/x86/include/asm/pgtable_types.h b/arch/x86/include/asm/pgtable_types.h
14698 index 567b5d0..bd91d64 100644
14699 --- a/arch/x86/include/asm/pgtable_types.h
14700 +++ b/arch/x86/include/asm/pgtable_types.h
14701 @@ -16,13 +16,12 @@
14702 #define _PAGE_BIT_PSE 7 /* 4 MB (or 2MB) page */
14703 #define _PAGE_BIT_PAT 7 /* on 4KB pages */
14704 #define _PAGE_BIT_GLOBAL 8 /* Global TLB entry PPro+ */
14705 -#define _PAGE_BIT_UNUSED1 9 /* available for programmer */
14706 +#define _PAGE_BIT_SPECIAL 9 /* special mappings, no associated struct page */
14707 #define _PAGE_BIT_IOMAP 10 /* flag used to indicate IO mapping */
14708 #define _PAGE_BIT_HIDDEN 11 /* hidden by kmemcheck */
14709 #define _PAGE_BIT_PAT_LARGE 12 /* On 2MB or 1GB pages */
14710 -#define _PAGE_BIT_SPECIAL _PAGE_BIT_UNUSED1
14711 -#define _PAGE_BIT_CPA_TEST _PAGE_BIT_UNUSED1
14712 -#define _PAGE_BIT_SPLITTING _PAGE_BIT_UNUSED1 /* only valid on a PSE pmd */
14713 +#define _PAGE_BIT_CPA_TEST _PAGE_BIT_SPECIAL
14714 +#define _PAGE_BIT_SPLITTING _PAGE_BIT_SPECIAL /* only valid on a PSE pmd */
14715 #define _PAGE_BIT_NX 63 /* No execute: only valid after cpuid check */
14716
14717 /* If _PAGE_BIT_PRESENT is clear, we use these: */
14718 @@ -40,7 +39,6 @@
14719 #define _PAGE_DIRTY (_AT(pteval_t, 1) << _PAGE_BIT_DIRTY)
14720 #define _PAGE_PSE (_AT(pteval_t, 1) << _PAGE_BIT_PSE)
14721 #define _PAGE_GLOBAL (_AT(pteval_t, 1) << _PAGE_BIT_GLOBAL)
14722 -#define _PAGE_UNUSED1 (_AT(pteval_t, 1) << _PAGE_BIT_UNUSED1)
14723 #define _PAGE_IOMAP (_AT(pteval_t, 1) << _PAGE_BIT_IOMAP)
14724 #define _PAGE_PAT (_AT(pteval_t, 1) << _PAGE_BIT_PAT)
14725 #define _PAGE_PAT_LARGE (_AT(pteval_t, 1) << _PAGE_BIT_PAT_LARGE)
14726 @@ -57,8 +55,10 @@
14727
14728 #if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
14729 #define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_NX)
14730 -#else
14731 +#elif defined(CONFIG_KMEMCHECK)
14732 #define _PAGE_NX (_AT(pteval_t, 0))
14733 +#else
14734 +#define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_HIDDEN)
14735 #endif
14736
14737 #define _PAGE_FILE (_AT(pteval_t, 1) << _PAGE_BIT_FILE)
14738 @@ -116,6 +116,9 @@
14739 #define PAGE_READONLY_EXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | \
14740 _PAGE_ACCESSED)
14741
14742 +#define PAGE_READONLY_NOEXEC PAGE_READONLY
14743 +#define PAGE_SHARED_NOEXEC PAGE_SHARED
14744 +
14745 #define __PAGE_KERNEL_EXEC \
14746 (_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_GLOBAL)
14747 #define __PAGE_KERNEL (__PAGE_KERNEL_EXEC | _PAGE_NX)
14748 @@ -126,7 +129,7 @@
14749 #define __PAGE_KERNEL_WC (__PAGE_KERNEL | _PAGE_CACHE_WC)
14750 #define __PAGE_KERNEL_NOCACHE (__PAGE_KERNEL | _PAGE_PCD | _PAGE_PWT)
14751 #define __PAGE_KERNEL_UC_MINUS (__PAGE_KERNEL | _PAGE_PCD)
14752 -#define __PAGE_KERNEL_VSYSCALL (__PAGE_KERNEL_RX | _PAGE_USER)
14753 +#define __PAGE_KERNEL_VSYSCALL (__PAGE_KERNEL_RO | _PAGE_USER)
14754 #define __PAGE_KERNEL_VVAR (__PAGE_KERNEL_RO | _PAGE_USER)
14755 #define __PAGE_KERNEL_VVAR_NOCACHE (__PAGE_KERNEL_VVAR | _PAGE_PCD | _PAGE_PWT)
14756 #define __PAGE_KERNEL_LARGE (__PAGE_KERNEL | _PAGE_PSE)
14757 @@ -188,8 +191,8 @@
14758 * bits are combined, this will alow user to access the high address mapped
14759 * VDSO in the presence of CONFIG_COMPAT_VDSO
14760 */
14761 -#define PTE_IDENT_ATTR 0x003 /* PRESENT+RW */
14762 -#define PDE_IDENT_ATTR 0x067 /* PRESENT+RW+USER+DIRTY+ACCESSED */
14763 +#define PTE_IDENT_ATTR 0x063 /* PRESENT+RW+DIRTY+ACCESSED */
14764 +#define PDE_IDENT_ATTR 0x063 /* PRESENT+RW+DIRTY+ACCESSED */
14765 #define PGD_IDENT_ATTR 0x001 /* PRESENT (no other attributes) */
14766 #endif
14767
14768 @@ -227,7 +230,17 @@ static inline pgdval_t pgd_flags(pgd_t pgd)
14769 {
14770 return native_pgd_val(pgd) & PTE_FLAGS_MASK;
14771 }
14772 +#endif
14773
14774 +#if PAGETABLE_LEVELS == 3
14775 +#include <asm-generic/pgtable-nopud.h>
14776 +#endif
14777 +
14778 +#if PAGETABLE_LEVELS == 2
14779 +#include <asm-generic/pgtable-nopmd.h>
14780 +#endif
14781 +
14782 +#ifndef __ASSEMBLY__
14783 #if PAGETABLE_LEVELS > 3
14784 typedef struct { pudval_t pud; } pud_t;
14785
14786 @@ -241,8 +254,6 @@ static inline pudval_t native_pud_val(pud_t pud)
14787 return pud.pud;
14788 }
14789 #else
14790 -#include <asm-generic/pgtable-nopud.h>
14791 -
14792 static inline pudval_t native_pud_val(pud_t pud)
14793 {
14794 return native_pgd_val(pud.pgd);
14795 @@ -262,8 +273,6 @@ static inline pmdval_t native_pmd_val(pmd_t pmd)
14796 return pmd.pmd;
14797 }
14798 #else
14799 -#include <asm-generic/pgtable-nopmd.h>
14800 -
14801 static inline pmdval_t native_pmd_val(pmd_t pmd)
14802 {
14803 return native_pgd_val(pmd.pud.pgd);
14804 @@ -303,7 +312,6 @@ typedef struct page *pgtable_t;
14805
14806 extern pteval_t __supported_pte_mask;
14807 extern void set_nx(void);
14808 -extern int nx_enabled;
14809
14810 #define pgprot_writecombine pgprot_writecombine
14811 extern pgprot_t pgprot_writecombine(pgprot_t prot);
14812 diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
14813 index 3270116..8d99d82 100644
14814 --- a/arch/x86/include/asm/processor.h
14815 +++ b/arch/x86/include/asm/processor.h
14816 @@ -285,7 +285,7 @@ struct tss_struct {
14817
14818 } ____cacheline_aligned;
14819
14820 -DECLARE_PER_CPU_SHARED_ALIGNED(struct tss_struct, init_tss);
14821 +extern struct tss_struct init_tss[NR_CPUS];
14822
14823 /*
14824 * Save the original ist values for checking stack pointers during debugging
14825 @@ -826,11 +826,18 @@ static inline void spin_lock_prefetch(const void *x)
14826 */
14827 #define TASK_SIZE PAGE_OFFSET
14828 #define TASK_SIZE_MAX TASK_SIZE
14829 +
14830 +#ifdef CONFIG_PAX_SEGMEXEC
14831 +#define SEGMEXEC_TASK_SIZE (TASK_SIZE / 2)
14832 +#define STACK_TOP ((current->mm->pax_flags & MF_PAX_SEGMEXEC)?SEGMEXEC_TASK_SIZE:TASK_SIZE)
14833 +#else
14834 #define STACK_TOP TASK_SIZE
14835 -#define STACK_TOP_MAX STACK_TOP
14836 +#endif
14837 +
14838 +#define STACK_TOP_MAX TASK_SIZE
14839
14840 #define INIT_THREAD { \
14841 - .sp0 = sizeof(init_stack) + (long)&init_stack, \
14842 + .sp0 = sizeof(init_stack) + (long)&init_stack - 8, \
14843 .vm86_info = NULL, \
14844 .sysenter_cs = __KERNEL_CS, \
14845 .io_bitmap_ptr = NULL, \
14846 @@ -844,7 +851,7 @@ static inline void spin_lock_prefetch(const void *x)
14847 */
14848 #define INIT_TSS { \
14849 .x86_tss = { \
14850 - .sp0 = sizeof(init_stack) + (long)&init_stack, \
14851 + .sp0 = sizeof(init_stack) + (long)&init_stack - 8, \
14852 .ss0 = __KERNEL_DS, \
14853 .ss1 = __KERNEL_CS, \
14854 .io_bitmap_base = INVALID_IO_BITMAP_OFFSET, \
14855 @@ -855,11 +862,7 @@ static inline void spin_lock_prefetch(const void *x)
14856 extern unsigned long thread_saved_pc(struct task_struct *tsk);
14857
14858 #define THREAD_SIZE_LONGS (THREAD_SIZE/sizeof(unsigned long))
14859 -#define KSTK_TOP(info) \
14860 -({ \
14861 - unsigned long *__ptr = (unsigned long *)(info); \
14862 - (unsigned long)(&__ptr[THREAD_SIZE_LONGS]); \
14863 -})
14864 +#define KSTK_TOP(info) ((container_of(info, struct task_struct, tinfo))->thread.sp0)
14865
14866 /*
14867 * The below -8 is to reserve 8 bytes on top of the ring0 stack.
14868 @@ -874,7 +877,7 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
14869 #define task_pt_regs(task) \
14870 ({ \
14871 struct pt_regs *__regs__; \
14872 - __regs__ = (struct pt_regs *)(KSTK_TOP(task_stack_page(task))-8); \
14873 + __regs__ = (struct pt_regs *)((task)->thread.sp0); \
14874 __regs__ - 1; \
14875 })
14876
14877 @@ -884,13 +887,13 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
14878 /*
14879 * User space process size. 47bits minus one guard page.
14880 */
14881 -#define TASK_SIZE_MAX ((1UL << 47) - PAGE_SIZE)
14882 +#define TASK_SIZE_MAX ((1UL << TASK_SIZE_MAX_SHIFT) - PAGE_SIZE)
14883
14884 /* This decides where the kernel will search for a free chunk of vm
14885 * space during mmap's.
14886 */
14887 #define IA32_PAGE_OFFSET ((current->personality & ADDR_LIMIT_3GB) ? \
14888 - 0xc0000000 : 0xFFFFe000)
14889 + 0xc0000000 : 0xFFFFf000)
14890
14891 #define TASK_SIZE (test_thread_flag(TIF_ADDR32) ? \
14892 IA32_PAGE_OFFSET : TASK_SIZE_MAX)
14893 @@ -901,11 +904,11 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
14894 #define STACK_TOP_MAX TASK_SIZE_MAX
14895
14896 #define INIT_THREAD { \
14897 - .sp0 = (unsigned long)&init_stack + sizeof(init_stack) \
14898 + .sp0 = (unsigned long)&init_stack + sizeof(init_stack) - 16 \
14899 }
14900
14901 #define INIT_TSS { \
14902 - .x86_tss.sp0 = (unsigned long)&init_stack + sizeof(init_stack) \
14903 + .x86_tss.sp0 = (unsigned long)&init_stack + sizeof(init_stack) - 16 \
14904 }
14905
14906 /*
14907 @@ -933,6 +936,10 @@ extern void start_thread(struct pt_regs *regs, unsigned long new_ip,
14908 */
14909 #define TASK_UNMAPPED_BASE (PAGE_ALIGN(TASK_SIZE / 3))
14910
14911 +#ifdef CONFIG_PAX_SEGMEXEC
14912 +#define SEGMEXEC_TASK_UNMAPPED_BASE (PAGE_ALIGN(SEGMEXEC_TASK_SIZE / 3))
14913 +#endif
14914 +
14915 #define KSTK_EIP(task) (task_pt_regs(task)->ip)
14916
14917 /* Get/set a process' ability to use the timestamp counter instruction */
14918 @@ -993,7 +1000,7 @@ extern bool cpu_has_amd_erratum(const int *);
14919 #define cpu_has_amd_erratum(x) (false)
14920 #endif /* CONFIG_CPU_SUP_AMD */
14921
14922 -extern unsigned long arch_align_stack(unsigned long sp);
14923 +#define arch_align_stack(x) ((x) & ~0xfUL)
14924 extern void free_init_pages(char *what, unsigned long begin, unsigned long end);
14925
14926 void default_idle(void);
14927 @@ -1003,6 +1010,6 @@ bool xen_set_default_idle(void);
14928 #define xen_set_default_idle 0
14929 #endif
14930
14931 -void stop_this_cpu(void *dummy);
14932 +void stop_this_cpu(void *dummy) __noreturn;
14933
14934 #endif /* _ASM_X86_PROCESSOR_H */
14935 diff --git a/arch/x86/include/asm/ptrace.h b/arch/x86/include/asm/ptrace.h
14936 index 942a086..6c26446 100644
14937 --- a/arch/x86/include/asm/ptrace.h
14938 +++ b/arch/x86/include/asm/ptrace.h
14939 @@ -85,28 +85,29 @@ static inline unsigned long regs_return_value(struct pt_regs *regs)
14940 }
14941
14942 /*
14943 - * user_mode_vm(regs) determines whether a register set came from user mode.
14944 + * user_mode(regs) determines whether a register set came from user mode.
14945 * This is true if V8086 mode was enabled OR if the register set was from
14946 * protected mode with RPL-3 CS value. This tricky test checks that with
14947 * one comparison. Many places in the kernel can bypass this full check
14948 - * if they have already ruled out V8086 mode, so user_mode(regs) can be used.
14949 + * if they have already ruled out V8086 mode, so user_mode_novm(regs) can
14950 + * be used.
14951 */
14952 -static inline int user_mode(struct pt_regs *regs)
14953 +static inline int user_mode_novm(struct pt_regs *regs)
14954 {
14955 #ifdef CONFIG_X86_32
14956 return (regs->cs & SEGMENT_RPL_MASK) == USER_RPL;
14957 #else
14958 - return !!(regs->cs & 3);
14959 + return !!(regs->cs & SEGMENT_RPL_MASK);
14960 #endif
14961 }
14962
14963 -static inline int user_mode_vm(struct pt_regs *regs)
14964 +static inline int user_mode(struct pt_regs *regs)
14965 {
14966 #ifdef CONFIG_X86_32
14967 return ((regs->cs & SEGMENT_RPL_MASK) | (regs->flags & X86_VM_MASK)) >=
14968 USER_RPL;
14969 #else
14970 - return user_mode(regs);
14971 + return user_mode_novm(regs);
14972 #endif
14973 }
14974
14975 @@ -122,15 +123,16 @@ static inline int v8086_mode(struct pt_regs *regs)
14976 #ifdef CONFIG_X86_64
14977 static inline bool user_64bit_mode(struct pt_regs *regs)
14978 {
14979 + unsigned long cs = regs->cs & 0xffff;
14980 #ifndef CONFIG_PARAVIRT
14981 /*
14982 * On non-paravirt systems, this is the only long mode CPL 3
14983 * selector. We do not allow long mode selectors in the LDT.
14984 */
14985 - return regs->cs == __USER_CS;
14986 + return cs == __USER_CS;
14987 #else
14988 /* Headers are too twisted for this to go in paravirt.h. */
14989 - return regs->cs == __USER_CS || regs->cs == pv_info.extra_user_64bit_cs;
14990 + return cs == __USER_CS || cs == pv_info.extra_user_64bit_cs;
14991 #endif
14992 }
14993
14994 @@ -181,9 +183,11 @@ static inline unsigned long regs_get_register(struct pt_regs *regs,
14995 * Traps from the kernel do not save sp and ss.
14996 * Use the helper function to retrieve sp.
14997 */
14998 - if (offset == offsetof(struct pt_regs, sp) &&
14999 - regs->cs == __KERNEL_CS)
15000 - return kernel_stack_pointer(regs);
15001 + if (offset == offsetof(struct pt_regs, sp)) {
15002 + unsigned long cs = regs->cs & 0xffff;
15003 + if (cs == __KERNEL_CS || cs == __KERNEXEC_KERNEL_CS)
15004 + return kernel_stack_pointer(regs);
15005 + }
15006 #endif
15007 return *(unsigned long *)((unsigned long)regs + offset);
15008 }
15009 diff --git a/arch/x86/include/asm/realmode.h b/arch/x86/include/asm/realmode.h
15010 index 9c6b890..5305f53 100644
15011 --- a/arch/x86/include/asm/realmode.h
15012 +++ b/arch/x86/include/asm/realmode.h
15013 @@ -22,16 +22,14 @@ struct real_mode_header {
15014 #endif
15015 /* APM/BIOS reboot */
15016 u32 machine_real_restart_asm;
15017 -#ifdef CONFIG_X86_64
15018 u32 machine_real_restart_seg;
15019 -#endif
15020 };
15021
15022 /* This must match data at trampoline_32/64.S */
15023 struct trampoline_header {
15024 #ifdef CONFIG_X86_32
15025 u32 start;
15026 - u16 gdt_pad;
15027 + u16 boot_cs;
15028 u16 gdt_limit;
15029 u32 gdt_base;
15030 #else
15031 diff --git a/arch/x86/include/asm/reboot.h b/arch/x86/include/asm/reboot.h
15032 index a82c4f1..ac45053 100644
15033 --- a/arch/x86/include/asm/reboot.h
15034 +++ b/arch/x86/include/asm/reboot.h
15035 @@ -6,13 +6,13 @@
15036 struct pt_regs;
15037
15038 struct machine_ops {
15039 - void (*restart)(char *cmd);
15040 - void (*halt)(void);
15041 - void (*power_off)(void);
15042 + void (* __noreturn restart)(char *cmd);
15043 + void (* __noreturn halt)(void);
15044 + void (* __noreturn power_off)(void);
15045 void (*shutdown)(void);
15046 void (*crash_shutdown)(struct pt_regs *);
15047 - void (*emergency_restart)(void);
15048 -};
15049 + void (* __noreturn emergency_restart)(void);
15050 +} __no_const;
15051
15052 extern struct machine_ops machine_ops;
15053
15054 diff --git a/arch/x86/include/asm/rwsem.h b/arch/x86/include/asm/rwsem.h
15055 index 2dbe4a7..ce1db00 100644
15056 --- a/arch/x86/include/asm/rwsem.h
15057 +++ b/arch/x86/include/asm/rwsem.h
15058 @@ -64,6 +64,14 @@ static inline void __down_read(struct rw_semaphore *sem)
15059 {
15060 asm volatile("# beginning down_read\n\t"
15061 LOCK_PREFIX _ASM_INC "(%1)\n\t"
15062 +
15063 +#ifdef CONFIG_PAX_REFCOUNT
15064 + "jno 0f\n"
15065 + LOCK_PREFIX _ASM_DEC "(%1)\n"
15066 + "int $4\n0:\n"
15067 + _ASM_EXTABLE(0b, 0b)
15068 +#endif
15069 +
15070 /* adds 0x00000001 */
15071 " jns 1f\n"
15072 " call call_rwsem_down_read_failed\n"
15073 @@ -85,6 +93,14 @@ static inline int __down_read_trylock(struct rw_semaphore *sem)
15074 "1:\n\t"
15075 " mov %1,%2\n\t"
15076 " add %3,%2\n\t"
15077 +
15078 +#ifdef CONFIG_PAX_REFCOUNT
15079 + "jno 0f\n"
15080 + "sub %3,%2\n"
15081 + "int $4\n0:\n"
15082 + _ASM_EXTABLE(0b, 0b)
15083 +#endif
15084 +
15085 " jle 2f\n\t"
15086 LOCK_PREFIX " cmpxchg %2,%0\n\t"
15087 " jnz 1b\n\t"
15088 @@ -104,6 +120,14 @@ static inline void __down_write_nested(struct rw_semaphore *sem, int subclass)
15089 long tmp;
15090 asm volatile("# beginning down_write\n\t"
15091 LOCK_PREFIX " xadd %1,(%2)\n\t"
15092 +
15093 +#ifdef CONFIG_PAX_REFCOUNT
15094 + "jno 0f\n"
15095 + "mov %1,(%2)\n"
15096 + "int $4\n0:\n"
15097 + _ASM_EXTABLE(0b, 0b)
15098 +#endif
15099 +
15100 /* adds 0xffff0001, returns the old value */
15101 " test %1,%1\n\t"
15102 /* was the count 0 before? */
15103 @@ -141,6 +165,14 @@ static inline void __up_read(struct rw_semaphore *sem)
15104 long tmp;
15105 asm volatile("# beginning __up_read\n\t"
15106 LOCK_PREFIX " xadd %1,(%2)\n\t"
15107 +
15108 +#ifdef CONFIG_PAX_REFCOUNT
15109 + "jno 0f\n"
15110 + "mov %1,(%2)\n"
15111 + "int $4\n0:\n"
15112 + _ASM_EXTABLE(0b, 0b)
15113 +#endif
15114 +
15115 /* subtracts 1, returns the old value */
15116 " jns 1f\n\t"
15117 " call call_rwsem_wake\n" /* expects old value in %edx */
15118 @@ -159,6 +191,14 @@ static inline void __up_write(struct rw_semaphore *sem)
15119 long tmp;
15120 asm volatile("# beginning __up_write\n\t"
15121 LOCK_PREFIX " xadd %1,(%2)\n\t"
15122 +
15123 +#ifdef CONFIG_PAX_REFCOUNT
15124 + "jno 0f\n"
15125 + "mov %1,(%2)\n"
15126 + "int $4\n0:\n"
15127 + _ASM_EXTABLE(0b, 0b)
15128 +#endif
15129 +
15130 /* subtracts 0xffff0001, returns the old value */
15131 " jns 1f\n\t"
15132 " call call_rwsem_wake\n" /* expects old value in %edx */
15133 @@ -176,6 +216,14 @@ static inline void __downgrade_write(struct rw_semaphore *sem)
15134 {
15135 asm volatile("# beginning __downgrade_write\n\t"
15136 LOCK_PREFIX _ASM_ADD "%2,(%1)\n\t"
15137 +
15138 +#ifdef CONFIG_PAX_REFCOUNT
15139 + "jno 0f\n"
15140 + LOCK_PREFIX _ASM_SUB "%2,(%1)\n"
15141 + "int $4\n0:\n"
15142 + _ASM_EXTABLE(0b, 0b)
15143 +#endif
15144 +
15145 /*
15146 * transitions 0xZZZZ0001 -> 0xYYYY0001 (i386)
15147 * 0xZZZZZZZZ00000001 -> 0xYYYYYYYY00000001 (x86_64)
15148 @@ -194,7 +242,15 @@ static inline void __downgrade_write(struct rw_semaphore *sem)
15149 */
15150 static inline void rwsem_atomic_add(long delta, struct rw_semaphore *sem)
15151 {
15152 - asm volatile(LOCK_PREFIX _ASM_ADD "%1,%0"
15153 + asm volatile(LOCK_PREFIX _ASM_ADD "%1,%0\n"
15154 +
15155 +#ifdef CONFIG_PAX_REFCOUNT
15156 + "jno 0f\n"
15157 + LOCK_PREFIX _ASM_SUB "%1,%0\n"
15158 + "int $4\n0:\n"
15159 + _ASM_EXTABLE(0b, 0b)
15160 +#endif
15161 +
15162 : "+m" (sem->count)
15163 : "er" (delta));
15164 }
15165 @@ -204,7 +260,7 @@ static inline void rwsem_atomic_add(long delta, struct rw_semaphore *sem)
15166 */
15167 static inline long rwsem_atomic_update(long delta, struct rw_semaphore *sem)
15168 {
15169 - return delta + xadd(&sem->count, delta);
15170 + return delta + xadd_check_overflow(&sem->count, delta);
15171 }
15172
15173 #endif /* __KERNEL__ */
15174 diff --git a/arch/x86/include/asm/segment.h b/arch/x86/include/asm/segment.h
15175 index c48a950..c6d7468 100644
15176 --- a/arch/x86/include/asm/segment.h
15177 +++ b/arch/x86/include/asm/segment.h
15178 @@ -64,10 +64,15 @@
15179 * 26 - ESPFIX small SS
15180 * 27 - per-cpu [ offset to per-cpu data area ]
15181 * 28 - stack_canary-20 [ for stack protector ]
15182 - * 29 - unused
15183 - * 30 - unused
15184 + * 29 - PCI BIOS CS
15185 + * 30 - PCI BIOS DS
15186 * 31 - TSS for double fault handler
15187 */
15188 +#define GDT_ENTRY_KERNEXEC_EFI_CS (1)
15189 +#define GDT_ENTRY_KERNEXEC_EFI_DS (2)
15190 +#define __KERNEXEC_EFI_CS (GDT_ENTRY_KERNEXEC_EFI_CS*8)
15191 +#define __KERNEXEC_EFI_DS (GDT_ENTRY_KERNEXEC_EFI_DS*8)
15192 +
15193 #define GDT_ENTRY_TLS_MIN 6
15194 #define GDT_ENTRY_TLS_MAX (GDT_ENTRY_TLS_MIN + GDT_ENTRY_TLS_ENTRIES - 1)
15195
15196 @@ -79,6 +84,8 @@
15197
15198 #define GDT_ENTRY_KERNEL_CS (GDT_ENTRY_KERNEL_BASE+0)
15199
15200 +#define GDT_ENTRY_KERNEXEC_KERNEL_CS (4)
15201 +
15202 #define GDT_ENTRY_KERNEL_DS (GDT_ENTRY_KERNEL_BASE+1)
15203
15204 #define GDT_ENTRY_TSS (GDT_ENTRY_KERNEL_BASE+4)
15205 @@ -104,6 +111,12 @@
15206 #define __KERNEL_STACK_CANARY 0
15207 #endif
15208
15209 +#define GDT_ENTRY_PCIBIOS_CS (GDT_ENTRY_KERNEL_BASE+17)
15210 +#define __PCIBIOS_CS (GDT_ENTRY_PCIBIOS_CS * 8)
15211 +
15212 +#define GDT_ENTRY_PCIBIOS_DS (GDT_ENTRY_KERNEL_BASE+18)
15213 +#define __PCIBIOS_DS (GDT_ENTRY_PCIBIOS_DS * 8)
15214 +
15215 #define GDT_ENTRY_DOUBLEFAULT_TSS 31
15216
15217 /*
15218 @@ -141,7 +154,7 @@
15219 */
15220
15221 /* Matches PNP_CS32 and PNP_CS16 (they must be consecutive) */
15222 -#define SEGMENT_IS_PNP_CODE(x) (((x) & 0xf4) == GDT_ENTRY_PNPBIOS_BASE * 8)
15223 +#define SEGMENT_IS_PNP_CODE(x) (((x) & 0xFFFCU) == PNP_CS32 || ((x) & 0xFFFCU) == PNP_CS16)
15224
15225
15226 #else
15227 @@ -165,6 +178,8 @@
15228 #define __USER32_CS (GDT_ENTRY_DEFAULT_USER32_CS*8+3)
15229 #define __USER32_DS __USER_DS
15230
15231 +#define GDT_ENTRY_KERNEXEC_KERNEL_CS 7
15232 +
15233 #define GDT_ENTRY_TSS 8 /* needs two entries */
15234 #define GDT_ENTRY_LDT 10 /* needs two entries */
15235 #define GDT_ENTRY_TLS_MIN 12
15236 @@ -185,6 +200,7 @@
15237 #endif
15238
15239 #define __KERNEL_CS (GDT_ENTRY_KERNEL_CS*8)
15240 +#define __KERNEXEC_KERNEL_CS (GDT_ENTRY_KERNEXEC_KERNEL_CS*8)
15241 #define __KERNEL_DS (GDT_ENTRY_KERNEL_DS*8)
15242 #define __USER_DS (GDT_ENTRY_DEFAULT_USER_DS*8+3)
15243 #define __USER_CS (GDT_ENTRY_DEFAULT_USER_CS*8+3)
15244 @@ -265,7 +281,7 @@ static inline unsigned long get_limit(unsigned long segment)
15245 {
15246 unsigned long __limit;
15247 asm("lsll %1,%0" : "=r" (__limit) : "r" (segment));
15248 - return __limit + 1;
15249 + return __limit;
15250 }
15251
15252 #endif /* !__ASSEMBLY__ */
15253 diff --git a/arch/x86/include/asm/smp.h b/arch/x86/include/asm/smp.h
15254 index b073aae..39f9bdd 100644
15255 --- a/arch/x86/include/asm/smp.h
15256 +++ b/arch/x86/include/asm/smp.h
15257 @@ -36,7 +36,7 @@ DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_core_map);
15258 /* cpus sharing the last level cache: */
15259 DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_llc_shared_map);
15260 DECLARE_PER_CPU_READ_MOSTLY(u16, cpu_llc_id);
15261 -DECLARE_PER_CPU_READ_MOSTLY(int, cpu_number);
15262 +DECLARE_PER_CPU_READ_MOSTLY(unsigned int, cpu_number);
15263
15264 static inline struct cpumask *cpu_sibling_mask(int cpu)
15265 {
15266 @@ -79,7 +79,7 @@ struct smp_ops {
15267
15268 void (*send_call_func_ipi)(const struct cpumask *mask);
15269 void (*send_call_func_single_ipi)(int cpu);
15270 -};
15271 +} __no_const;
15272
15273 /* Globals due to paravirt */
15274 extern void set_cpu_sibling_map(int cpu);
15275 @@ -191,14 +191,8 @@ extern unsigned disabled_cpus __cpuinitdata;
15276 extern int safe_smp_processor_id(void);
15277
15278 #elif defined(CONFIG_X86_64_SMP)
15279 -#define raw_smp_processor_id() (this_cpu_read(cpu_number))
15280 -
15281 -#define stack_smp_processor_id() \
15282 -({ \
15283 - struct thread_info *ti; \
15284 - __asm__("andq %%rsp,%0; ":"=r" (ti) : "0" (CURRENT_MASK)); \
15285 - ti->cpu; \
15286 -})
15287 +#define raw_smp_processor_id() (this_cpu_read(cpu_number))
15288 +#define stack_smp_processor_id() raw_smp_processor_id()
15289 #define safe_smp_processor_id() smp_processor_id()
15290
15291 #endif
15292 diff --git a/arch/x86/include/asm/spinlock.h b/arch/x86/include/asm/spinlock.h
15293 index 33692ea..350a534 100644
15294 --- a/arch/x86/include/asm/spinlock.h
15295 +++ b/arch/x86/include/asm/spinlock.h
15296 @@ -172,6 +172,14 @@ static inline int arch_write_can_lock(arch_rwlock_t *lock)
15297 static inline void arch_read_lock(arch_rwlock_t *rw)
15298 {
15299 asm volatile(LOCK_PREFIX READ_LOCK_SIZE(dec) " (%0)\n\t"
15300 +
15301 +#ifdef CONFIG_PAX_REFCOUNT
15302 + "jno 0f\n"
15303 + LOCK_PREFIX READ_LOCK_SIZE(inc) " (%0)\n"
15304 + "int $4\n0:\n"
15305 + _ASM_EXTABLE(0b, 0b)
15306 +#endif
15307 +
15308 "jns 1f\n"
15309 "call __read_lock_failed\n\t"
15310 "1:\n"
15311 @@ -181,6 +189,14 @@ static inline void arch_read_lock(arch_rwlock_t *rw)
15312 static inline void arch_write_lock(arch_rwlock_t *rw)
15313 {
15314 asm volatile(LOCK_PREFIX WRITE_LOCK_SUB(%1) "(%0)\n\t"
15315 +
15316 +#ifdef CONFIG_PAX_REFCOUNT
15317 + "jno 0f\n"
15318 + LOCK_PREFIX WRITE_LOCK_ADD(%1) "(%0)\n"
15319 + "int $4\n0:\n"
15320 + _ASM_EXTABLE(0b, 0b)
15321 +#endif
15322 +
15323 "jz 1f\n"
15324 "call __write_lock_failed\n\t"
15325 "1:\n"
15326 @@ -210,13 +226,29 @@ static inline int arch_write_trylock(arch_rwlock_t *lock)
15327
15328 static inline void arch_read_unlock(arch_rwlock_t *rw)
15329 {
15330 - asm volatile(LOCK_PREFIX READ_LOCK_SIZE(inc) " %0"
15331 + asm volatile(LOCK_PREFIX READ_LOCK_SIZE(inc) " %0\n"
15332 +
15333 +#ifdef CONFIG_PAX_REFCOUNT
15334 + "jno 0f\n"
15335 + LOCK_PREFIX READ_LOCK_SIZE(dec) " %0\n"
15336 + "int $4\n0:\n"
15337 + _ASM_EXTABLE(0b, 0b)
15338 +#endif
15339 +
15340 :"+m" (rw->lock) : : "memory");
15341 }
15342
15343 static inline void arch_write_unlock(arch_rwlock_t *rw)
15344 {
15345 - asm volatile(LOCK_PREFIX WRITE_LOCK_ADD(%1) "%0"
15346 + asm volatile(LOCK_PREFIX WRITE_LOCK_ADD(%1) "%0\n"
15347 +
15348 +#ifdef CONFIG_PAX_REFCOUNT
15349 + "jno 0f\n"
15350 + LOCK_PREFIX WRITE_LOCK_SUB(%1) "%0\n"
15351 + "int $4\n0:\n"
15352 + _ASM_EXTABLE(0b, 0b)
15353 +#endif
15354 +
15355 : "+m" (rw->write) : "i" (RW_LOCK_BIAS) : "memory");
15356 }
15357
15358 diff --git a/arch/x86/include/asm/stackprotector.h b/arch/x86/include/asm/stackprotector.h
15359 index 6a99859..03cb807 100644
15360 --- a/arch/x86/include/asm/stackprotector.h
15361 +++ b/arch/x86/include/asm/stackprotector.h
15362 @@ -47,7 +47,7 @@
15363 * head_32 for boot CPU and setup_per_cpu_areas() for others.
15364 */
15365 #define GDT_STACK_CANARY_INIT \
15366 - [GDT_ENTRY_STACK_CANARY] = GDT_ENTRY_INIT(0x4090, 0, 0x18),
15367 + [GDT_ENTRY_STACK_CANARY] = GDT_ENTRY_INIT(0x4090, 0, 0x17),
15368
15369 /*
15370 * Initialize the stackprotector canary value.
15371 @@ -112,7 +112,7 @@ static inline void setup_stack_canary_segment(int cpu)
15372
15373 static inline void load_stack_canary_segment(void)
15374 {
15375 -#ifdef CONFIG_X86_32
15376 +#if defined(CONFIG_X86_32) && !defined(CONFIG_PAX_MEMORY_UDEREF)
15377 asm volatile ("mov %0, %%gs" : : "r" (0));
15378 #endif
15379 }
15380 diff --git a/arch/x86/include/asm/stacktrace.h b/arch/x86/include/asm/stacktrace.h
15381 index 70bbe39..4ae2bd4 100644
15382 --- a/arch/x86/include/asm/stacktrace.h
15383 +++ b/arch/x86/include/asm/stacktrace.h
15384 @@ -11,28 +11,20 @@
15385
15386 extern int kstack_depth_to_print;
15387
15388 -struct thread_info;
15389 +struct task_struct;
15390 struct stacktrace_ops;
15391
15392 -typedef unsigned long (*walk_stack_t)(struct thread_info *tinfo,
15393 - unsigned long *stack,
15394 - unsigned long bp,
15395 - const struct stacktrace_ops *ops,
15396 - void *data,
15397 - unsigned long *end,
15398 - int *graph);
15399 +typedef unsigned long walk_stack_t(struct task_struct *task,
15400 + void *stack_start,
15401 + unsigned long *stack,
15402 + unsigned long bp,
15403 + const struct stacktrace_ops *ops,
15404 + void *data,
15405 + unsigned long *end,
15406 + int *graph);
15407
15408 -extern unsigned long
15409 -print_context_stack(struct thread_info *tinfo,
15410 - unsigned long *stack, unsigned long bp,
15411 - const struct stacktrace_ops *ops, void *data,
15412 - unsigned long *end, int *graph);
15413 -
15414 -extern unsigned long
15415 -print_context_stack_bp(struct thread_info *tinfo,
15416 - unsigned long *stack, unsigned long bp,
15417 - const struct stacktrace_ops *ops, void *data,
15418 - unsigned long *end, int *graph);
15419 +extern walk_stack_t print_context_stack;
15420 +extern walk_stack_t print_context_stack_bp;
15421
15422 /* Generic stack tracer with callbacks */
15423
15424 @@ -40,7 +32,7 @@ struct stacktrace_ops {
15425 void (*address)(void *data, unsigned long address, int reliable);
15426 /* On negative return stop dumping */
15427 int (*stack)(void *data, char *name);
15428 - walk_stack_t walk_stack;
15429 + walk_stack_t *walk_stack;
15430 };
15431
15432 void dump_trace(struct task_struct *tsk, struct pt_regs *regs,
15433 diff --git a/arch/x86/include/asm/switch_to.h b/arch/x86/include/asm/switch_to.h
15434 index 4ec45b3..a4f0a8a 100644
15435 --- a/arch/x86/include/asm/switch_to.h
15436 +++ b/arch/x86/include/asm/switch_to.h
15437 @@ -108,7 +108,7 @@ do { \
15438 "call __switch_to\n\t" \
15439 "movq "__percpu_arg([current_task])",%%rsi\n\t" \
15440 __switch_canary \
15441 - "movq %P[thread_info](%%rsi),%%r8\n\t" \
15442 + "movq "__percpu_arg([thread_info])",%%r8\n\t" \
15443 "movq %%rax,%%rdi\n\t" \
15444 "testl %[_tif_fork],%P[ti_flags](%%r8)\n\t" \
15445 "jnz ret_from_fork\n\t" \
15446 @@ -119,7 +119,7 @@ do { \
15447 [threadrsp] "i" (offsetof(struct task_struct, thread.sp)), \
15448 [ti_flags] "i" (offsetof(struct thread_info, flags)), \
15449 [_tif_fork] "i" (_TIF_FORK), \
15450 - [thread_info] "i" (offsetof(struct task_struct, stack)), \
15451 + [thread_info] "m" (current_tinfo), \
15452 [current_task] "m" (current_task) \
15453 __switch_canary_iparam \
15454 : "memory", "cc" __EXTRA_CLOBBER)
15455 diff --git a/arch/x86/include/asm/thread_info.h b/arch/x86/include/asm/thread_info.h
15456 index 2cd056e..0224df8 100644
15457 --- a/arch/x86/include/asm/thread_info.h
15458 +++ b/arch/x86/include/asm/thread_info.h
15459 @@ -10,6 +10,7 @@
15460 #include <linux/compiler.h>
15461 #include <asm/page.h>
15462 #include <asm/types.h>
15463 +#include <asm/percpu.h>
15464
15465 /*
15466 * low level task data that entry.S needs immediate access to
15467 @@ -23,7 +24,6 @@ struct exec_domain;
15468 #include <linux/atomic.h>
15469
15470 struct thread_info {
15471 - struct task_struct *task; /* main task structure */
15472 struct exec_domain *exec_domain; /* execution domain */
15473 __u32 flags; /* low level flags */
15474 __u32 status; /* thread synchronous flags */
15475 @@ -33,19 +33,13 @@ struct thread_info {
15476 mm_segment_t addr_limit;
15477 struct restart_block restart_block;
15478 void __user *sysenter_return;
15479 -#ifdef CONFIG_X86_32
15480 - unsigned long previous_esp; /* ESP of the previous stack in
15481 - case of nested (IRQ) stacks
15482 - */
15483 - __u8 supervisor_stack[0];
15484 -#endif
15485 + unsigned long lowest_stack;
15486 unsigned int sig_on_uaccess_error:1;
15487 unsigned int uaccess_err:1; /* uaccess failed */
15488 };
15489
15490 -#define INIT_THREAD_INFO(tsk) \
15491 +#define INIT_THREAD_INFO \
15492 { \
15493 - .task = &tsk, \
15494 .exec_domain = &default_exec_domain, \
15495 .flags = 0, \
15496 .cpu = 0, \
15497 @@ -56,7 +50,7 @@ struct thread_info {
15498 }, \
15499 }
15500
15501 -#define init_thread_info (init_thread_union.thread_info)
15502 +#define init_thread_info (init_thread_union.stack)
15503 #define init_stack (init_thread_union.stack)
15504
15505 #else /* !__ASSEMBLY__ */
15506 @@ -97,6 +91,7 @@ struct thread_info {
15507 #define TIF_SYSCALL_TRACEPOINT 28 /* syscall tracepoint instrumentation */
15508 #define TIF_ADDR32 29 /* 32-bit address space on 64 bits */
15509 #define TIF_X32 30 /* 32-bit native x86-64 binary */
15510 +#define TIF_GRSEC_SETXID 31 /* update credentials on syscall entry/exit */
15511
15512 #define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
15513 #define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)
15514 @@ -121,17 +116,18 @@ struct thread_info {
15515 #define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT)
15516 #define _TIF_ADDR32 (1 << TIF_ADDR32)
15517 #define _TIF_X32 (1 << TIF_X32)
15518 +#define _TIF_GRSEC_SETXID (1 << TIF_GRSEC_SETXID)
15519
15520 /* work to do in syscall_trace_enter() */
15521 #define _TIF_WORK_SYSCALL_ENTRY \
15522 (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_EMU | _TIF_SYSCALL_AUDIT | \
15523 _TIF_SECCOMP | _TIF_SINGLESTEP | _TIF_SYSCALL_TRACEPOINT | \
15524 - _TIF_NOHZ)
15525 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
15526
15527 /* work to do in syscall_trace_leave() */
15528 #define _TIF_WORK_SYSCALL_EXIT \
15529 (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_SINGLESTEP | \
15530 - _TIF_SYSCALL_TRACEPOINT | _TIF_NOHZ)
15531 + _TIF_SYSCALL_TRACEPOINT | _TIF_NOHZ | _TIF_GRSEC_SETXID)
15532
15533 /* work to do on interrupt/exception return */
15534 #define _TIF_WORK_MASK \
15535 @@ -142,7 +138,7 @@ struct thread_info {
15536 /* work to do on any return to user space */
15537 #define _TIF_ALLWORK_MASK \
15538 ((0x0000FFFF & ~_TIF_SECCOMP) | _TIF_SYSCALL_TRACEPOINT | \
15539 - _TIF_NOHZ)
15540 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
15541
15542 /* Only used for 64 bit */
15543 #define _TIF_DO_NOTIFY_MASK \
15544 @@ -158,45 +154,40 @@ struct thread_info {
15545
15546 #define PREEMPT_ACTIVE 0x10000000
15547
15548 -#ifdef CONFIG_X86_32
15549 -
15550 -#define STACK_WARN (THREAD_SIZE/8)
15551 -/*
15552 - * macros/functions for gaining access to the thread information structure
15553 - *
15554 - * preempt_count needs to be 1 initially, until the scheduler is functional.
15555 - */
15556 -#ifndef __ASSEMBLY__
15557 -
15558 -
15559 -/* how to get the current stack pointer from C */
15560 -register unsigned long current_stack_pointer asm("esp") __used;
15561 -
15562 -/* how to get the thread information struct from C */
15563 -static inline struct thread_info *current_thread_info(void)
15564 -{
15565 - return (struct thread_info *)
15566 - (current_stack_pointer & ~(THREAD_SIZE - 1));
15567 -}
15568 -
15569 -#else /* !__ASSEMBLY__ */
15570 -
15571 +#ifdef __ASSEMBLY__
15572 /* how to get the thread information struct from ASM */
15573 #define GET_THREAD_INFO(reg) \
15574 - movl $-THREAD_SIZE, reg; \
15575 - andl %esp, reg
15576 + mov PER_CPU_VAR(current_tinfo), reg
15577
15578 /* use this one if reg already contains %esp */
15579 -#define GET_THREAD_INFO_WITH_ESP(reg) \
15580 - andl $-THREAD_SIZE, reg
15581 +#define GET_THREAD_INFO_WITH_ESP(reg) GET_THREAD_INFO(reg)
15582 +#else
15583 +/* how to get the thread information struct from C */
15584 +DECLARE_PER_CPU(struct thread_info *, current_tinfo);
15585 +
15586 +static __always_inline struct thread_info *current_thread_info(void)
15587 +{
15588 + return this_cpu_read_stable(current_tinfo);
15589 +}
15590 +#endif
15591 +
15592 +#ifdef CONFIG_X86_32
15593 +
15594 +#define STACK_WARN (THREAD_SIZE/8)
15595 +/*
15596 + * macros/functions for gaining access to the thread information structure
15597 + *
15598 + * preempt_count needs to be 1 initially, until the scheduler is functional.
15599 + */
15600 +#ifndef __ASSEMBLY__
15601 +
15602 +/* how to get the current stack pointer from C */
15603 +register unsigned long current_stack_pointer asm("esp") __used;
15604
15605 #endif
15606
15607 #else /* X86_32 */
15608
15609 -#include <asm/percpu.h>
15610 -#define KERNEL_STACK_OFFSET (5*8)
15611 -
15612 /*
15613 * macros/functions for gaining access to the thread information structure
15614 * preempt_count needs to be 1 initially, until the scheduler is functional.
15615 @@ -204,27 +195,8 @@ static inline struct thread_info *current_thread_info(void)
15616 #ifndef __ASSEMBLY__
15617 DECLARE_PER_CPU(unsigned long, kernel_stack);
15618
15619 -static inline struct thread_info *current_thread_info(void)
15620 -{
15621 - struct thread_info *ti;
15622 - ti = (void *)(this_cpu_read_stable(kernel_stack) +
15623 - KERNEL_STACK_OFFSET - THREAD_SIZE);
15624 - return ti;
15625 -}
15626 -
15627 -#else /* !__ASSEMBLY__ */
15628 -
15629 -/* how to get the thread information struct from ASM */
15630 -#define GET_THREAD_INFO(reg) \
15631 - movq PER_CPU_VAR(kernel_stack),reg ; \
15632 - subq $(THREAD_SIZE-KERNEL_STACK_OFFSET),reg
15633 -
15634 -/*
15635 - * Same if PER_CPU_VAR(kernel_stack) is, perhaps with some offset, already in
15636 - * a certain register (to be used in assembler memory operands).
15637 - */
15638 -#define THREAD_INFO(reg, off) KERNEL_STACK_OFFSET+(off)-THREAD_SIZE(reg)
15639 -
15640 +/* how to get the current stack pointer from C */
15641 +register unsigned long current_stack_pointer asm("rsp") __used;
15642 #endif
15643
15644 #endif /* !X86_32 */
15645 @@ -285,5 +257,12 @@ static inline bool is_ia32_task(void)
15646 extern void arch_task_cache_init(void);
15647 extern int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src);
15648 extern void arch_release_task_struct(struct task_struct *tsk);
15649 +
15650 +#define __HAVE_THREAD_FUNCTIONS
15651 +#define task_thread_info(task) (&(task)->tinfo)
15652 +#define task_stack_page(task) ((task)->stack)
15653 +#define setup_thread_stack(p, org) do {} while (0)
15654 +#define end_of_stack(p) ((unsigned long *)task_stack_page(p) + 1)
15655 +
15656 #endif
15657 #endif /* _ASM_X86_THREAD_INFO_H */
15658 diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h
15659 index 5ee2687..70d5895 100644
15660 --- a/arch/x86/include/asm/uaccess.h
15661 +++ b/arch/x86/include/asm/uaccess.h
15662 @@ -7,6 +7,7 @@
15663 #include <linux/compiler.h>
15664 #include <linux/thread_info.h>
15665 #include <linux/string.h>
15666 +#include <linux/sched.h>
15667 #include <asm/asm.h>
15668 #include <asm/page.h>
15669 #include <asm/smap.h>
15670 @@ -29,7 +30,12 @@
15671
15672 #define get_ds() (KERNEL_DS)
15673 #define get_fs() (current_thread_info()->addr_limit)
15674 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
15675 +void __set_fs(mm_segment_t x);
15676 +void set_fs(mm_segment_t x);
15677 +#else
15678 #define set_fs(x) (current_thread_info()->addr_limit = (x))
15679 +#endif
15680
15681 #define segment_eq(a, b) ((a).seg == (b).seg)
15682
15683 @@ -77,8 +83,33 @@
15684 * checks that the pointer is in the user space range - after calling
15685 * this function, memory access functions may still return -EFAULT.
15686 */
15687 -#define access_ok(type, addr, size) \
15688 - (likely(__range_not_ok(addr, size, user_addr_max()) == 0))
15689 +#define __access_ok(type, addr, size) (likely(__range_not_ok(addr, size, user_addr_max()) == 0))
15690 +#define access_ok(type, addr, size) \
15691 +({ \
15692 + long __size = size; \
15693 + unsigned long __addr = (unsigned long)addr; \
15694 + unsigned long __addr_ao = __addr & PAGE_MASK; \
15695 + unsigned long __end_ao = __addr + __size - 1; \
15696 + bool __ret_ao = __range_not_ok(__addr, __size, user_addr_max()) == 0;\
15697 + if (__ret_ao && unlikely((__end_ao ^ __addr_ao) & PAGE_MASK)) { \
15698 + while(__addr_ao <= __end_ao) { \
15699 + char __c_ao; \
15700 + __addr_ao += PAGE_SIZE; \
15701 + if (__size > PAGE_SIZE) \
15702 + cond_resched(); \
15703 + if (__get_user(__c_ao, (char __user *)__addr)) \
15704 + break; \
15705 + if (type != VERIFY_WRITE) { \
15706 + __addr = __addr_ao; \
15707 + continue; \
15708 + } \
15709 + if (__put_user(__c_ao, (char __user *)__addr)) \
15710 + break; \
15711 + __addr = __addr_ao; \
15712 + } \
15713 + } \
15714 + __ret_ao; \
15715 +})
15716
15717 /*
15718 * The exception table consists of pairs of addresses relative to the
15719 @@ -176,13 +207,21 @@ __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
15720 asm volatile("call __put_user_" #size : "=a" (__ret_pu) \
15721 : "0" ((typeof(*(ptr)))(x)), "c" (ptr) : "ebx")
15722
15723 -
15724 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
15725 +#define __copyuser_seg "gs;"
15726 +#define __COPYUSER_SET_ES "pushl %%gs; popl %%es\n"
15727 +#define __COPYUSER_RESTORE_ES "pushl %%ss; popl %%es\n"
15728 +#else
15729 +#define __copyuser_seg
15730 +#define __COPYUSER_SET_ES
15731 +#define __COPYUSER_RESTORE_ES
15732 +#endif
15733
15734 #ifdef CONFIG_X86_32
15735 #define __put_user_asm_u64(x, addr, err, errret) \
15736 asm volatile(ASM_STAC "\n" \
15737 - "1: movl %%eax,0(%2)\n" \
15738 - "2: movl %%edx,4(%2)\n" \
15739 + "1: "__copyuser_seg"movl %%eax,0(%2)\n" \
15740 + "2: "__copyuser_seg"movl %%edx,4(%2)\n" \
15741 "3: " ASM_CLAC "\n" \
15742 ".section .fixup,\"ax\"\n" \
15743 "4: movl %3,%0\n" \
15744 @@ -195,8 +234,8 @@ __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
15745
15746 #define __put_user_asm_ex_u64(x, addr) \
15747 asm volatile(ASM_STAC "\n" \
15748 - "1: movl %%eax,0(%1)\n" \
15749 - "2: movl %%edx,4(%1)\n" \
15750 + "1: "__copyuser_seg"movl %%eax,0(%1)\n" \
15751 + "2: "__copyuser_seg"movl %%edx,4(%1)\n" \
15752 "3: " ASM_CLAC "\n" \
15753 _ASM_EXTABLE_EX(1b, 2b) \
15754 _ASM_EXTABLE_EX(2b, 3b) \
15755 @@ -246,7 +285,7 @@ extern void __put_user_8(void);
15756 __typeof__(*(ptr)) __pu_val; \
15757 __chk_user_ptr(ptr); \
15758 might_fault(); \
15759 - __pu_val = x; \
15760 + __pu_val = (x); \
15761 switch (sizeof(*(ptr))) { \
15762 case 1: \
15763 __put_user_x(1, __pu_val, ptr, __ret_pu); \
15764 @@ -345,7 +384,7 @@ do { \
15765
15766 #define __get_user_asm(x, addr, err, itype, rtype, ltype, errret) \
15767 asm volatile(ASM_STAC "\n" \
15768 - "1: mov"itype" %2,%"rtype"1\n" \
15769 + "1: "__copyuser_seg"mov"itype" %2,%"rtype"1\n"\
15770 "2: " ASM_CLAC "\n" \
15771 ".section .fixup,\"ax\"\n" \
15772 "3: mov %3,%0\n" \
15773 @@ -353,7 +392,7 @@ do { \
15774 " jmp 2b\n" \
15775 ".previous\n" \
15776 _ASM_EXTABLE(1b, 3b) \
15777 - : "=r" (err), ltype(x) \
15778 + : "=r" (err), ltype (x) \
15779 : "m" (__m(addr)), "i" (errret), "0" (err))
15780
15781 #define __get_user_size_ex(x, ptr, size) \
15782 @@ -378,7 +417,7 @@ do { \
15783 } while (0)
15784
15785 #define __get_user_asm_ex(x, addr, itype, rtype, ltype) \
15786 - asm volatile("1: mov"itype" %1,%"rtype"0\n" \
15787 + asm volatile("1: "__copyuser_seg"mov"itype" %1,%"rtype"0\n"\
15788 "2:\n" \
15789 _ASM_EXTABLE_EX(1b, 2b) \
15790 : ltype(x) : "m" (__m(addr)))
15791 @@ -395,13 +434,24 @@ do { \
15792 int __gu_err; \
15793 unsigned long __gu_val; \
15794 __get_user_size(__gu_val, (ptr), (size), __gu_err, -EFAULT); \
15795 - (x) = (__force __typeof__(*(ptr)))__gu_val; \
15796 + (x) = (__typeof__(*(ptr)))__gu_val; \
15797 __gu_err; \
15798 })
15799
15800 /* FIXME: this hack is definitely wrong -AK */
15801 struct __large_struct { unsigned long buf[100]; };
15802 -#define __m(x) (*(struct __large_struct __user *)(x))
15803 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15804 +#define ____m(x) \
15805 +({ \
15806 + unsigned long ____x = (unsigned long)(x); \
15807 + if (____x < pax_user_shadow_base) \
15808 + ____x += pax_user_shadow_base; \
15809 + (typeof(x))____x; \
15810 +})
15811 +#else
15812 +#define ____m(x) (x)
15813 +#endif
15814 +#define __m(x) (*(struct __large_struct __user *)____m(x))
15815
15816 /*
15817 * Tell gcc we read from memory instead of writing: this is because
15818 @@ -410,7 +460,7 @@ struct __large_struct { unsigned long buf[100]; };
15819 */
15820 #define __put_user_asm(x, addr, err, itype, rtype, ltype, errret) \
15821 asm volatile(ASM_STAC "\n" \
15822 - "1: mov"itype" %"rtype"1,%2\n" \
15823 + "1: "__copyuser_seg"mov"itype" %"rtype"1,%2\n"\
15824 "2: " ASM_CLAC "\n" \
15825 ".section .fixup,\"ax\"\n" \
15826 "3: mov %3,%0\n" \
15827 @@ -418,10 +468,10 @@ struct __large_struct { unsigned long buf[100]; };
15828 ".previous\n" \
15829 _ASM_EXTABLE(1b, 3b) \
15830 : "=r"(err) \
15831 - : ltype(x), "m" (__m(addr)), "i" (errret), "0" (err))
15832 + : ltype (x), "m" (__m(addr)), "i" (errret), "0" (err))
15833
15834 #define __put_user_asm_ex(x, addr, itype, rtype, ltype) \
15835 - asm volatile("1: mov"itype" %"rtype"0,%1\n" \
15836 + asm volatile("1: "__copyuser_seg"mov"itype" %"rtype"0,%1\n"\
15837 "2:\n" \
15838 _ASM_EXTABLE_EX(1b, 2b) \
15839 : : ltype(x), "m" (__m(addr)))
15840 @@ -460,8 +510,12 @@ struct __large_struct { unsigned long buf[100]; };
15841 * On error, the variable @x is set to zero.
15842 */
15843
15844 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15845 +#define __get_user(x, ptr) get_user((x), (ptr))
15846 +#else
15847 #define __get_user(x, ptr) \
15848 __get_user_nocheck((x), (ptr), sizeof(*(ptr)))
15849 +#endif
15850
15851 /**
15852 * __put_user: - Write a simple value into user space, with less checking.
15853 @@ -483,8 +537,12 @@ struct __large_struct { unsigned long buf[100]; };
15854 * Returns zero on success, or -EFAULT on error.
15855 */
15856
15857 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15858 +#define __put_user(x, ptr) put_user((x), (ptr))
15859 +#else
15860 #define __put_user(x, ptr) \
15861 __put_user_nocheck((__typeof__(*(ptr)))(x), (ptr), sizeof(*(ptr)))
15862 +#endif
15863
15864 #define __get_user_unaligned __get_user
15865 #define __put_user_unaligned __put_user
15866 @@ -502,7 +560,7 @@ struct __large_struct { unsigned long buf[100]; };
15867 #define get_user_ex(x, ptr) do { \
15868 unsigned long __gue_val; \
15869 __get_user_size_ex((__gue_val), (ptr), (sizeof(*(ptr)))); \
15870 - (x) = (__force __typeof__(*(ptr)))__gue_val; \
15871 + (x) = (__typeof__(*(ptr)))__gue_val; \
15872 } while (0)
15873
15874 #define put_user_try uaccess_try
15875 @@ -519,8 +577,8 @@ strncpy_from_user(char *dst, const char __user *src, long count);
15876 extern __must_check long strlen_user(const char __user *str);
15877 extern __must_check long strnlen_user(const char __user *str, long n);
15878
15879 -unsigned long __must_check clear_user(void __user *mem, unsigned long len);
15880 -unsigned long __must_check __clear_user(void __user *mem, unsigned long len);
15881 +unsigned long __must_check clear_user(void __user *mem, unsigned long len) __size_overflow(2);
15882 +unsigned long __must_check __clear_user(void __user *mem, unsigned long len) __size_overflow(2);
15883
15884 /*
15885 * movsl can be slow when source and dest are not both 8-byte aligned
15886 diff --git a/arch/x86/include/asm/uaccess_32.h b/arch/x86/include/asm/uaccess_32.h
15887 index 7f760a9..04b1c65 100644
15888 --- a/arch/x86/include/asm/uaccess_32.h
15889 +++ b/arch/x86/include/asm/uaccess_32.h
15890 @@ -11,15 +11,15 @@
15891 #include <asm/page.h>
15892
15893 unsigned long __must_check __copy_to_user_ll
15894 - (void __user *to, const void *from, unsigned long n);
15895 + (void __user *to, const void *from, unsigned long n) __size_overflow(3);
15896 unsigned long __must_check __copy_from_user_ll
15897 - (void *to, const void __user *from, unsigned long n);
15898 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
15899 unsigned long __must_check __copy_from_user_ll_nozero
15900 - (void *to, const void __user *from, unsigned long n);
15901 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
15902 unsigned long __must_check __copy_from_user_ll_nocache
15903 - (void *to, const void __user *from, unsigned long n);
15904 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
15905 unsigned long __must_check __copy_from_user_ll_nocache_nozero
15906 - (void *to, const void __user *from, unsigned long n);
15907 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
15908
15909 /**
15910 * __copy_to_user_inatomic: - Copy a block of data into user space, with less checking.
15911 @@ -43,6 +43,11 @@ unsigned long __must_check __copy_from_user_ll_nocache_nozero
15912 static __always_inline unsigned long __must_check
15913 __copy_to_user_inatomic(void __user *to, const void *from, unsigned long n)
15914 {
15915 + if ((long)n < 0)
15916 + return n;
15917 +
15918 + check_object_size(from, n, true);
15919 +
15920 if (__builtin_constant_p(n)) {
15921 unsigned long ret;
15922
15923 @@ -82,12 +87,16 @@ static __always_inline unsigned long __must_check
15924 __copy_to_user(void __user *to, const void *from, unsigned long n)
15925 {
15926 might_fault();
15927 +
15928 return __copy_to_user_inatomic(to, from, n);
15929 }
15930
15931 static __always_inline unsigned long
15932 __copy_from_user_inatomic(void *to, const void __user *from, unsigned long n)
15933 {
15934 + if ((long)n < 0)
15935 + return n;
15936 +
15937 /* Avoid zeroing the tail if the copy fails..
15938 * If 'n' is constant and 1, 2, or 4, we do still zero on a failure,
15939 * but as the zeroing behaviour is only significant when n is not
15940 @@ -137,6 +146,12 @@ static __always_inline unsigned long
15941 __copy_from_user(void *to, const void __user *from, unsigned long n)
15942 {
15943 might_fault();
15944 +
15945 + if ((long)n < 0)
15946 + return n;
15947 +
15948 + check_object_size(to, n, false);
15949 +
15950 if (__builtin_constant_p(n)) {
15951 unsigned long ret;
15952
15953 @@ -159,6 +174,10 @@ static __always_inline unsigned long __copy_from_user_nocache(void *to,
15954 const void __user *from, unsigned long n)
15955 {
15956 might_fault();
15957 +
15958 + if ((long)n < 0)
15959 + return n;
15960 +
15961 if (__builtin_constant_p(n)) {
15962 unsigned long ret;
15963
15964 @@ -181,15 +200,19 @@ static __always_inline unsigned long
15965 __copy_from_user_inatomic_nocache(void *to, const void __user *from,
15966 unsigned long n)
15967 {
15968 - return __copy_from_user_ll_nocache_nozero(to, from, n);
15969 + if ((long)n < 0)
15970 + return n;
15971 +
15972 + return __copy_from_user_ll_nocache_nozero(to, from, n);
15973 }
15974
15975 -unsigned long __must_check copy_to_user(void __user *to,
15976 - const void *from, unsigned long n);
15977 -unsigned long __must_check _copy_from_user(void *to,
15978 - const void __user *from,
15979 - unsigned long n);
15980 -
15981 +extern void copy_to_user_overflow(void)
15982 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
15983 + __compiletime_error("copy_to_user() buffer size is not provably correct")
15984 +#else
15985 + __compiletime_warning("copy_to_user() buffer size is not provably correct")
15986 +#endif
15987 +;
15988
15989 extern void copy_from_user_overflow(void)
15990 #ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
15991 @@ -199,17 +222,60 @@ extern void copy_from_user_overflow(void)
15992 #endif
15993 ;
15994
15995 -static inline unsigned long __must_check copy_from_user(void *to,
15996 - const void __user *from,
15997 - unsigned long n)
15998 +/**
15999 + * copy_to_user: - Copy a block of data into user space.
16000 + * @to: Destination address, in user space.
16001 + * @from: Source address, in kernel space.
16002 + * @n: Number of bytes to copy.
16003 + *
16004 + * Context: User context only. This function may sleep.
16005 + *
16006 + * Copy data from kernel space to user space.
16007 + *
16008 + * Returns number of bytes that could not be copied.
16009 + * On success, this will be zero.
16010 + */
16011 +static inline unsigned long __must_check
16012 +copy_to_user(void __user *to, const void *from, unsigned long n)
16013 {
16014 - int sz = __compiletime_object_size(to);
16015 + size_t sz = __compiletime_object_size(from);
16016
16017 - if (likely(sz == -1 || sz >= n))
16018 - n = _copy_from_user(to, from, n);
16019 - else
16020 + if (unlikely(sz != (size_t)-1 && sz < n))
16021 + copy_to_user_overflow();
16022 + else if (access_ok(VERIFY_WRITE, to, n))
16023 + n = __copy_to_user(to, from, n);
16024 + return n;
16025 +}
16026 +
16027 +/**
16028 + * copy_from_user: - Copy a block of data from user space.
16029 + * @to: Destination address, in kernel space.
16030 + * @from: Source address, in user space.
16031 + * @n: Number of bytes to copy.
16032 + *
16033 + * Context: User context only. This function may sleep.
16034 + *
16035 + * Copy data from user space to kernel space.
16036 + *
16037 + * Returns number of bytes that could not be copied.
16038 + * On success, this will be zero.
16039 + *
16040 + * If some data could not be copied, this function will pad the copied
16041 + * data to the requested size using zero bytes.
16042 + */
16043 +static inline unsigned long __must_check
16044 +copy_from_user(void *to, const void __user *from, unsigned long n)
16045 +{
16046 + size_t sz = __compiletime_object_size(to);
16047 +
16048 + check_object_size(to, n, false);
16049 +
16050 + if (unlikely(sz != (size_t)-1 && sz < n))
16051 copy_from_user_overflow();
16052 -
16053 + else if (access_ok(VERIFY_READ, from, n))
16054 + n = __copy_from_user(to, from, n);
16055 + else if ((long)n > 0)
16056 + memset(to, 0, n);
16057 return n;
16058 }
16059
16060 diff --git a/arch/x86/include/asm/uaccess_64.h b/arch/x86/include/asm/uaccess_64.h
16061 index 142810c..1f2a0a7 100644
16062 --- a/arch/x86/include/asm/uaccess_64.h
16063 +++ b/arch/x86/include/asm/uaccess_64.h
16064 @@ -10,6 +10,9 @@
16065 #include <asm/alternative.h>
16066 #include <asm/cpufeature.h>
16067 #include <asm/page.h>
16068 +#include <asm/pgtable.h>
16069 +
16070 +#define set_fs(x) (current_thread_info()->addr_limit = (x))
16071
16072 /*
16073 * Copy To/From Userspace
16074 @@ -17,13 +20,13 @@
16075
16076 /* Handles exceptions in both to and from, but doesn't do access_ok */
16077 __must_check unsigned long
16078 -copy_user_enhanced_fast_string(void *to, const void *from, unsigned len);
16079 +copy_user_enhanced_fast_string(void *to, const void *from, unsigned len) __size_overflow(3);
16080 __must_check unsigned long
16081 -copy_user_generic_string(void *to, const void *from, unsigned len);
16082 +copy_user_generic_string(void *to, const void *from, unsigned len) __size_overflow(3);
16083 __must_check unsigned long
16084 -copy_user_generic_unrolled(void *to, const void *from, unsigned len);
16085 +copy_user_generic_unrolled(void *to, const void *from, unsigned len) __size_overflow(3);
16086
16087 -static __always_inline __must_check unsigned long
16088 +static __always_inline __must_check __size_overflow(3) unsigned long
16089 copy_user_generic(void *to, const void *from, unsigned len)
16090 {
16091 unsigned ret;
16092 @@ -41,142 +44,204 @@ copy_user_generic(void *to, const void *from, unsigned len)
16093 ASM_OUTPUT2("=a" (ret), "=D" (to), "=S" (from),
16094 "=d" (len)),
16095 "1" (to), "2" (from), "3" (len)
16096 - : "memory", "rcx", "r8", "r9", "r10", "r11");
16097 + : "memory", "rcx", "r8", "r9", "r11");
16098 return ret;
16099 }
16100
16101 +static __always_inline __must_check unsigned long
16102 +__copy_to_user(void __user *to, const void *from, unsigned long len);
16103 +static __always_inline __must_check unsigned long
16104 +__copy_from_user(void *to, const void __user *from, unsigned long len);
16105 __must_check unsigned long
16106 -_copy_to_user(void __user *to, const void *from, unsigned len);
16107 -__must_check unsigned long
16108 -_copy_from_user(void *to, const void __user *from, unsigned len);
16109 -__must_check unsigned long
16110 -copy_in_user(void __user *to, const void __user *from, unsigned len);
16111 +copy_in_user(void __user *to, const void __user *from, unsigned long len);
16112 +
16113 +extern void copy_to_user_overflow(void)
16114 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
16115 + __compiletime_error("copy_to_user() buffer size is not provably correct")
16116 +#else
16117 + __compiletime_warning("copy_to_user() buffer size is not provably correct")
16118 +#endif
16119 +;
16120 +
16121 +extern void copy_from_user_overflow(void)
16122 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
16123 + __compiletime_error("copy_from_user() buffer size is not provably correct")
16124 +#else
16125 + __compiletime_warning("copy_from_user() buffer size is not provably correct")
16126 +#endif
16127 +;
16128
16129 static inline unsigned long __must_check copy_from_user(void *to,
16130 const void __user *from,
16131 unsigned long n)
16132 {
16133 - int sz = __compiletime_object_size(to);
16134 -
16135 might_fault();
16136 - if (likely(sz == -1 || sz >= n))
16137 - n = _copy_from_user(to, from, n);
16138 -#ifdef CONFIG_DEBUG_VM
16139 - else
16140 - WARN(1, "Buffer overflow detected!\n");
16141 -#endif
16142 +
16143 + check_object_size(to, n, false);
16144 +
16145 + if (access_ok(VERIFY_READ, from, n))
16146 + n = __copy_from_user(to, from, n);
16147 + else if (n < INT_MAX)
16148 + memset(to, 0, n);
16149 return n;
16150 }
16151
16152 static __always_inline __must_check
16153 -int copy_to_user(void __user *dst, const void *src, unsigned size)
16154 +int copy_to_user(void __user *dst, const void *src, unsigned long size)
16155 {
16156 might_fault();
16157
16158 - return _copy_to_user(dst, src, size);
16159 + if (access_ok(VERIFY_WRITE, dst, size))
16160 + size = __copy_to_user(dst, src, size);
16161 + return size;
16162 }
16163
16164 static __always_inline __must_check
16165 -int __copy_from_user(void *dst, const void __user *src, unsigned size)
16166 +unsigned long __copy_from_user(void *dst, const void __user *src, unsigned long size)
16167 {
16168 - int ret = 0;
16169 + size_t sz = __compiletime_object_size(dst);
16170 + unsigned ret = 0;
16171
16172 might_fault();
16173 +
16174 + if (size > INT_MAX)
16175 + return size;
16176 +
16177 + check_object_size(dst, size, false);
16178 +
16179 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16180 + if (!__access_ok(VERIFY_READ, src, size))
16181 + return size;
16182 +#endif
16183 +
16184 + if (unlikely(sz != (size_t)-1 && sz < size)) {
16185 + copy_from_user_overflow();
16186 + return size;
16187 + }
16188 +
16189 if (!__builtin_constant_p(size))
16190 - return copy_user_generic(dst, (__force void *)src, size);
16191 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
16192 switch (size) {
16193 - case 1:__get_user_asm(*(u8 *)dst, (u8 __user *)src,
16194 + case 1:__get_user_asm(*(u8 *)dst, (const u8 __user *)src,
16195 ret, "b", "b", "=q", 1);
16196 return ret;
16197 - case 2:__get_user_asm(*(u16 *)dst, (u16 __user *)src,
16198 + case 2:__get_user_asm(*(u16 *)dst, (const u16 __user *)src,
16199 ret, "w", "w", "=r", 2);
16200 return ret;
16201 - case 4:__get_user_asm(*(u32 *)dst, (u32 __user *)src,
16202 + case 4:__get_user_asm(*(u32 *)dst, (const u32 __user *)src,
16203 ret, "l", "k", "=r", 4);
16204 return ret;
16205 - case 8:__get_user_asm(*(u64 *)dst, (u64 __user *)src,
16206 + case 8:__get_user_asm(*(u64 *)dst, (const u64 __user *)src,
16207 ret, "q", "", "=r", 8);
16208 return ret;
16209 case 10:
16210 - __get_user_asm(*(u64 *)dst, (u64 __user *)src,
16211 + __get_user_asm(*(u64 *)dst, (const u64 __user *)src,
16212 ret, "q", "", "=r", 10);
16213 if (unlikely(ret))
16214 return ret;
16215 __get_user_asm(*(u16 *)(8 + (char *)dst),
16216 - (u16 __user *)(8 + (char __user *)src),
16217 + (const u16 __user *)(8 + (const char __user *)src),
16218 ret, "w", "w", "=r", 2);
16219 return ret;
16220 case 16:
16221 - __get_user_asm(*(u64 *)dst, (u64 __user *)src,
16222 + __get_user_asm(*(u64 *)dst, (const u64 __user *)src,
16223 ret, "q", "", "=r", 16);
16224 if (unlikely(ret))
16225 return ret;
16226 __get_user_asm(*(u64 *)(8 + (char *)dst),
16227 - (u64 __user *)(8 + (char __user *)src),
16228 + (const u64 __user *)(8 + (const char __user *)src),
16229 ret, "q", "", "=r", 8);
16230 return ret;
16231 default:
16232 - return copy_user_generic(dst, (__force void *)src, size);
16233 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
16234 }
16235 }
16236
16237 static __always_inline __must_check
16238 -int __copy_to_user(void __user *dst, const void *src, unsigned size)
16239 +unsigned long __copy_to_user(void __user *dst, const void *src, unsigned long size)
16240 {
16241 - int ret = 0;
16242 + size_t sz = __compiletime_object_size(src);
16243 + unsigned ret = 0;
16244
16245 might_fault();
16246 +
16247 + if (size > INT_MAX)
16248 + return size;
16249 +
16250 + check_object_size(src, size, true);
16251 +
16252 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16253 + if (!__access_ok(VERIFY_WRITE, dst, size))
16254 + return size;
16255 +#endif
16256 +
16257 + if (unlikely(sz != (size_t)-1 && sz < size)) {
16258 + copy_to_user_overflow();
16259 + return size;
16260 + }
16261 +
16262 if (!__builtin_constant_p(size))
16263 - return copy_user_generic((__force void *)dst, src, size);
16264 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
16265 switch (size) {
16266 - case 1:__put_user_asm(*(u8 *)src, (u8 __user *)dst,
16267 + case 1:__put_user_asm(*(const u8 *)src, (u8 __user *)dst,
16268 ret, "b", "b", "iq", 1);
16269 return ret;
16270 - case 2:__put_user_asm(*(u16 *)src, (u16 __user *)dst,
16271 + case 2:__put_user_asm(*(const u16 *)src, (u16 __user *)dst,
16272 ret, "w", "w", "ir", 2);
16273 return ret;
16274 - case 4:__put_user_asm(*(u32 *)src, (u32 __user *)dst,
16275 + case 4:__put_user_asm(*(const u32 *)src, (u32 __user *)dst,
16276 ret, "l", "k", "ir", 4);
16277 return ret;
16278 - case 8:__put_user_asm(*(u64 *)src, (u64 __user *)dst,
16279 + case 8:__put_user_asm(*(const u64 *)src, (u64 __user *)dst,
16280 ret, "q", "", "er", 8);
16281 return ret;
16282 case 10:
16283 - __put_user_asm(*(u64 *)src, (u64 __user *)dst,
16284 + __put_user_asm(*(const u64 *)src, (u64 __user *)dst,
16285 ret, "q", "", "er", 10);
16286 if (unlikely(ret))
16287 return ret;
16288 asm("":::"memory");
16289 - __put_user_asm(4[(u16 *)src], 4 + (u16 __user *)dst,
16290 + __put_user_asm(4[(const u16 *)src], 4 + (u16 __user *)dst,
16291 ret, "w", "w", "ir", 2);
16292 return ret;
16293 case 16:
16294 - __put_user_asm(*(u64 *)src, (u64 __user *)dst,
16295 + __put_user_asm(*(const u64 *)src, (u64 __user *)dst,
16296 ret, "q", "", "er", 16);
16297 if (unlikely(ret))
16298 return ret;
16299 asm("":::"memory");
16300 - __put_user_asm(1[(u64 *)src], 1 + (u64 __user *)dst,
16301 + __put_user_asm(1[(const u64 *)src], 1 + (u64 __user *)dst,
16302 ret, "q", "", "er", 8);
16303 return ret;
16304 default:
16305 - return copy_user_generic((__force void *)dst, src, size);
16306 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
16307 }
16308 }
16309
16310 static __always_inline __must_check
16311 -int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
16312 +unsigned long __copy_in_user(void __user *dst, const void __user *src, unsigned long size)
16313 {
16314 - int ret = 0;
16315 + unsigned ret = 0;
16316
16317 might_fault();
16318 +
16319 + if (size > INT_MAX)
16320 + return size;
16321 +
16322 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16323 + if (!__access_ok(VERIFY_READ, src, size))
16324 + return size;
16325 + if (!__access_ok(VERIFY_WRITE, dst, size))
16326 + return size;
16327 +#endif
16328 +
16329 if (!__builtin_constant_p(size))
16330 - return copy_user_generic((__force void *)dst,
16331 - (__force void *)src, size);
16332 + return copy_user_generic((__force_kernel void *)____m(dst),
16333 + (__force_kernel const void *)____m(src), size);
16334 switch (size) {
16335 case 1: {
16336 u8 tmp;
16337 - __get_user_asm(tmp, (u8 __user *)src,
16338 + __get_user_asm(tmp, (const u8 __user *)src,
16339 ret, "b", "b", "=q", 1);
16340 if (likely(!ret))
16341 __put_user_asm(tmp, (u8 __user *)dst,
16342 @@ -185,7 +250,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
16343 }
16344 case 2: {
16345 u16 tmp;
16346 - __get_user_asm(tmp, (u16 __user *)src,
16347 + __get_user_asm(tmp, (const u16 __user *)src,
16348 ret, "w", "w", "=r", 2);
16349 if (likely(!ret))
16350 __put_user_asm(tmp, (u16 __user *)dst,
16351 @@ -195,7 +260,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
16352
16353 case 4: {
16354 u32 tmp;
16355 - __get_user_asm(tmp, (u32 __user *)src,
16356 + __get_user_asm(tmp, (const u32 __user *)src,
16357 ret, "l", "k", "=r", 4);
16358 if (likely(!ret))
16359 __put_user_asm(tmp, (u32 __user *)dst,
16360 @@ -204,7 +269,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
16361 }
16362 case 8: {
16363 u64 tmp;
16364 - __get_user_asm(tmp, (u64 __user *)src,
16365 + __get_user_asm(tmp, (const u64 __user *)src,
16366 ret, "q", "", "=r", 8);
16367 if (likely(!ret))
16368 __put_user_asm(tmp, (u64 __user *)dst,
16369 @@ -212,41 +277,72 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
16370 return ret;
16371 }
16372 default:
16373 - return copy_user_generic((__force void *)dst,
16374 - (__force void *)src, size);
16375 + return copy_user_generic((__force_kernel void *)____m(dst),
16376 + (__force_kernel const void *)____m(src), size);
16377 }
16378 }
16379
16380 static __must_check __always_inline int
16381 -__copy_from_user_inatomic(void *dst, const void __user *src, unsigned size)
16382 +__copy_from_user_inatomic(void *dst, const void __user *src, unsigned long size)
16383 {
16384 - return copy_user_generic(dst, (__force const void *)src, size);
16385 + if (size > INT_MAX)
16386 + return size;
16387 +
16388 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16389 + if (!__access_ok(VERIFY_READ, src, size))
16390 + return size;
16391 +#endif
16392 +
16393 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
16394 }
16395
16396 -static __must_check __always_inline int
16397 -__copy_to_user_inatomic(void __user *dst, const void *src, unsigned size)
16398 +static __must_check __always_inline unsigned long
16399 +__copy_to_user_inatomic(void __user *dst, const void *src, unsigned long size)
16400 {
16401 - return copy_user_generic((__force void *)dst, src, size);
16402 + if (size > INT_MAX)
16403 + return size;
16404 +
16405 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16406 + if (!__access_ok(VERIFY_WRITE, dst, size))
16407 + return size;
16408 +#endif
16409 +
16410 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
16411 }
16412
16413 -extern long __copy_user_nocache(void *dst, const void __user *src,
16414 - unsigned size, int zerorest);
16415 +extern unsigned long __copy_user_nocache(void *dst, const void __user *src,
16416 + unsigned long size, int zerorest) __size_overflow(3);
16417
16418 -static inline int
16419 -__copy_from_user_nocache(void *dst, const void __user *src, unsigned size)
16420 +static inline unsigned long __copy_from_user_nocache(void *dst, const void __user *src, unsigned long size)
16421 {
16422 might_sleep();
16423 +
16424 + if (size > INT_MAX)
16425 + return size;
16426 +
16427 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16428 + if (!__access_ok(VERIFY_READ, src, size))
16429 + return size;
16430 +#endif
16431 +
16432 return __copy_user_nocache(dst, src, size, 1);
16433 }
16434
16435 -static inline int
16436 -__copy_from_user_inatomic_nocache(void *dst, const void __user *src,
16437 - unsigned size)
16438 +static inline unsigned long __copy_from_user_inatomic_nocache(void *dst, const void __user *src,
16439 + unsigned long size)
16440 {
16441 + if (size > INT_MAX)
16442 + return size;
16443 +
16444 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16445 + if (!__access_ok(VERIFY_READ, src, size))
16446 + return size;
16447 +#endif
16448 +
16449 return __copy_user_nocache(dst, src, size, 0);
16450 }
16451
16452 -unsigned long
16453 -copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest);
16454 +extern unsigned long
16455 +copy_user_handle_tail(char __user *to, char __user *from, unsigned long len, unsigned zerorest) __size_overflow(3);
16456
16457 #endif /* _ASM_X86_UACCESS_64_H */
16458 diff --git a/arch/x86/include/asm/word-at-a-time.h b/arch/x86/include/asm/word-at-a-time.h
16459 index 5b238981..77fdd78 100644
16460 --- a/arch/x86/include/asm/word-at-a-time.h
16461 +++ b/arch/x86/include/asm/word-at-a-time.h
16462 @@ -11,7 +11,7 @@
16463 * and shift, for example.
16464 */
16465 struct word_at_a_time {
16466 - const unsigned long one_bits, high_bits;
16467 + unsigned long one_bits, high_bits;
16468 };
16469
16470 #define WORD_AT_A_TIME_CONSTANTS { REPEAT_BYTE(0x01), REPEAT_BYTE(0x80) }
16471 diff --git a/arch/x86/include/asm/x86_init.h b/arch/x86/include/asm/x86_init.h
16472 index d8d9922..bf6cecb 100644
16473 --- a/arch/x86/include/asm/x86_init.h
16474 +++ b/arch/x86/include/asm/x86_init.h
16475 @@ -129,7 +129,7 @@ struct x86_init_ops {
16476 struct x86_init_timers timers;
16477 struct x86_init_iommu iommu;
16478 struct x86_init_pci pci;
16479 -};
16480 +} __no_const;
16481
16482 /**
16483 * struct x86_cpuinit_ops - platform specific cpu hotplug setups
16484 @@ -140,7 +140,7 @@ struct x86_cpuinit_ops {
16485 void (*setup_percpu_clockev)(void);
16486 void (*early_percpu_clock_init)(void);
16487 void (*fixup_cpu_id)(struct cpuinfo_x86 *c, int node);
16488 -};
16489 +} __no_const;
16490
16491 /**
16492 * struct x86_platform_ops - platform specific runtime functions
16493 @@ -166,7 +166,7 @@ struct x86_platform_ops {
16494 void (*save_sched_clock_state)(void);
16495 void (*restore_sched_clock_state)(void);
16496 void (*apic_post_init)(void);
16497 -};
16498 +} __no_const;
16499
16500 struct pci_dev;
16501 struct msi_msg;
16502 @@ -180,7 +180,7 @@ struct x86_msi_ops {
16503 void (*teardown_msi_irqs)(struct pci_dev *dev);
16504 void (*restore_msi_irqs)(struct pci_dev *dev, int irq);
16505 int (*setup_hpet_msi)(unsigned int irq, unsigned int id);
16506 -};
16507 +} __no_const;
16508
16509 struct IO_APIC_route_entry;
16510 struct io_apic_irq_attr;
16511 @@ -201,7 +201,7 @@ struct x86_io_apic_ops {
16512 unsigned int destination, int vector,
16513 struct io_apic_irq_attr *attr);
16514 void (*eoi_ioapic_pin)(int apic, int pin, int vector);
16515 -};
16516 +} __no_const;
16517
16518 extern struct x86_init_ops x86_init;
16519 extern struct x86_cpuinit_ops x86_cpuinit;
16520 diff --git a/arch/x86/include/asm/xsave.h b/arch/x86/include/asm/xsave.h
16521 index 0415cda..b43d877 100644
16522 --- a/arch/x86/include/asm/xsave.h
16523 +++ b/arch/x86/include/asm/xsave.h
16524 @@ -71,7 +71,9 @@ static inline int xsave_user(struct xsave_struct __user *buf)
16525 return -EFAULT;
16526
16527 __asm__ __volatile__(ASM_STAC "\n"
16528 - "1: .byte " REX_PREFIX "0x0f,0xae,0x27\n"
16529 + "1:"
16530 + __copyuser_seg
16531 + ".byte " REX_PREFIX "0x0f,0xae,0x27\n"
16532 "2: " ASM_CLAC "\n"
16533 ".section .fixup,\"ax\"\n"
16534 "3: movl $-1,%[err]\n"
16535 @@ -87,12 +89,14 @@ static inline int xsave_user(struct xsave_struct __user *buf)
16536 static inline int xrestore_user(struct xsave_struct __user *buf, u64 mask)
16537 {
16538 int err;
16539 - struct xsave_struct *xstate = ((__force struct xsave_struct *)buf);
16540 + struct xsave_struct *xstate = ((__force_kernel struct xsave_struct *)buf);
16541 u32 lmask = mask;
16542 u32 hmask = mask >> 32;
16543
16544 __asm__ __volatile__(ASM_STAC "\n"
16545 - "1: .byte " REX_PREFIX "0x0f,0xae,0x2f\n"
16546 + "1:"
16547 + __copyuser_seg
16548 + ".byte " REX_PREFIX "0x0f,0xae,0x2f\n"
16549 "2: " ASM_CLAC "\n"
16550 ".section .fixup,\"ax\"\n"
16551 "3: movl $-1,%[err]\n"
16552 diff --git a/arch/x86/include/uapi/asm/e820.h b/arch/x86/include/uapi/asm/e820.h
16553 index bbae024..e1528f9 100644
16554 --- a/arch/x86/include/uapi/asm/e820.h
16555 +++ b/arch/x86/include/uapi/asm/e820.h
16556 @@ -63,7 +63,7 @@ struct e820map {
16557 #define ISA_START_ADDRESS 0xa0000
16558 #define ISA_END_ADDRESS 0x100000
16559
16560 -#define BIOS_BEGIN 0x000a0000
16561 +#define BIOS_BEGIN 0x000c0000
16562 #define BIOS_END 0x00100000
16563
16564 #define BIOS_ROM_BASE 0xffe00000
16565 diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile
16566 index 7bd3bd3..5dac791 100644
16567 --- a/arch/x86/kernel/Makefile
16568 +++ b/arch/x86/kernel/Makefile
16569 @@ -22,7 +22,7 @@ obj-y += time.o ioport.o ldt.o dumpstack.o nmi.o
16570 obj-y += setup.o x86_init.o i8259.o irqinit.o jump_label.o
16571 obj-$(CONFIG_IRQ_WORK) += irq_work.o
16572 obj-y += probe_roms.o
16573 -obj-$(CONFIG_X86_32) += i386_ksyms_32.o
16574 +obj-$(CONFIG_X86_32) += sys_i386_32.o i386_ksyms_32.o
16575 obj-$(CONFIG_X86_64) += sys_x86_64.o x8664_ksyms_64.o
16576 obj-y += syscall_$(BITS).o
16577 obj-$(CONFIG_X86_64) += vsyscall_64.o
16578 diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
16579 index 230c8ea..f915130 100644
16580 --- a/arch/x86/kernel/acpi/boot.c
16581 +++ b/arch/x86/kernel/acpi/boot.c
16582 @@ -1361,7 +1361,7 @@ static int __init dmi_ignore_irq0_timer_override(const struct dmi_system_id *d)
16583 * If your system is blacklisted here, but you find that acpi=force
16584 * works for you, please contact linux-acpi@vger.kernel.org
16585 */
16586 -static struct dmi_system_id __initdata acpi_dmi_table[] = {
16587 +static const struct dmi_system_id __initconst acpi_dmi_table[] = {
16588 /*
16589 * Boxes that need ACPI disabled
16590 */
16591 @@ -1436,7 +1436,7 @@ static struct dmi_system_id __initdata acpi_dmi_table[] = {
16592 };
16593
16594 /* second table for DMI checks that should run after early-quirks */
16595 -static struct dmi_system_id __initdata acpi_dmi_table_late[] = {
16596 +static const struct dmi_system_id __initconst acpi_dmi_table_late[] = {
16597 /*
16598 * HP laptops which use a DSDT reporting as HP/SB400/10000,
16599 * which includes some code which overrides all temperature
16600 diff --git a/arch/x86/kernel/acpi/sleep.c b/arch/x86/kernel/acpi/sleep.c
16601 index 0532f5d..36afc0a 100644
16602 --- a/arch/x86/kernel/acpi/sleep.c
16603 +++ b/arch/x86/kernel/acpi/sleep.c
16604 @@ -74,8 +74,12 @@ int acpi_suspend_lowlevel(void)
16605 #else /* CONFIG_64BIT */
16606 #ifdef CONFIG_SMP
16607 stack_start = (unsigned long)temp_stack + sizeof(temp_stack);
16608 +
16609 + pax_open_kernel();
16610 early_gdt_descr.address =
16611 (unsigned long)get_cpu_gdt_table(smp_processor_id());
16612 + pax_close_kernel();
16613 +
16614 initial_gs = per_cpu_offset(smp_processor_id());
16615 #endif
16616 initial_code = (unsigned long)wakeup_long64;
16617 diff --git a/arch/x86/kernel/acpi/wakeup_32.S b/arch/x86/kernel/acpi/wakeup_32.S
16618 index 13ab720..95d5442 100644
16619 --- a/arch/x86/kernel/acpi/wakeup_32.S
16620 +++ b/arch/x86/kernel/acpi/wakeup_32.S
16621 @@ -30,13 +30,11 @@ wakeup_pmode_return:
16622 # and restore the stack ... but you need gdt for this to work
16623 movl saved_context_esp, %esp
16624
16625 - movl %cs:saved_magic, %eax
16626 - cmpl $0x12345678, %eax
16627 + cmpl $0x12345678, saved_magic
16628 jne bogus_magic
16629
16630 # jump to place where we left off
16631 - movl saved_eip, %eax
16632 - jmp *%eax
16633 + jmp *(saved_eip)
16634
16635 bogus_magic:
16636 jmp bogus_magic
16637 diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c
16638 index ef5ccca..bd83949 100644
16639 --- a/arch/x86/kernel/alternative.c
16640 +++ b/arch/x86/kernel/alternative.c
16641 @@ -268,6 +268,13 @@ void __init_or_module apply_alternatives(struct alt_instr *start,
16642 */
16643 for (a = start; a < end; a++) {
16644 instr = (u8 *)&a->instr_offset + a->instr_offset;
16645 +
16646 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
16647 + instr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16648 + if (instr < (u8 *)_text || (u8 *)_einittext <= instr)
16649 + instr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16650 +#endif
16651 +
16652 replacement = (u8 *)&a->repl_offset + a->repl_offset;
16653 BUG_ON(a->replacementlen > a->instrlen);
16654 BUG_ON(a->instrlen > sizeof(insnbuf));
16655 @@ -299,10 +306,16 @@ static void alternatives_smp_lock(const s32 *start, const s32 *end,
16656 for (poff = start; poff < end; poff++) {
16657 u8 *ptr = (u8 *)poff + *poff;
16658
16659 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
16660 + ptr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16661 + if (ptr < (u8 *)_text || (u8 *)_einittext <= ptr)
16662 + ptr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16663 +#endif
16664 +
16665 if (!*poff || ptr < text || ptr >= text_end)
16666 continue;
16667 /* turn DS segment override prefix into lock prefix */
16668 - if (*ptr == 0x3e)
16669 + if (*ktla_ktva(ptr) == 0x3e)
16670 text_poke(ptr, ((unsigned char []){0xf0}), 1);
16671 }
16672 mutex_unlock(&text_mutex);
16673 @@ -317,10 +330,16 @@ static void alternatives_smp_unlock(const s32 *start, const s32 *end,
16674 for (poff = start; poff < end; poff++) {
16675 u8 *ptr = (u8 *)poff + *poff;
16676
16677 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
16678 + ptr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16679 + if (ptr < (u8 *)_text || (u8 *)_einittext <= ptr)
16680 + ptr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16681 +#endif
16682 +
16683 if (!*poff || ptr < text || ptr >= text_end)
16684 continue;
16685 /* turn lock prefix into DS segment override prefix */
16686 - if (*ptr == 0xf0)
16687 + if (*ktla_ktva(ptr) == 0xf0)
16688 text_poke(ptr, ((unsigned char []){0x3E}), 1);
16689 }
16690 mutex_unlock(&text_mutex);
16691 @@ -468,7 +487,7 @@ void __init_or_module apply_paravirt(struct paravirt_patch_site *start,
16692
16693 BUG_ON(p->len > MAX_PATCH_LEN);
16694 /* prep the buffer with the original instructions */
16695 - memcpy(insnbuf, p->instr, p->len);
16696 + memcpy(insnbuf, ktla_ktva(p->instr), p->len);
16697 used = pv_init_ops.patch(p->instrtype, p->clobbers, insnbuf,
16698 (unsigned long)p->instr, p->len);
16699
16700 @@ -515,7 +534,7 @@ void __init alternative_instructions(void)
16701 if (!uniproc_patched || num_possible_cpus() == 1)
16702 free_init_pages("SMP alternatives",
16703 (unsigned long)__smp_locks,
16704 - (unsigned long)__smp_locks_end);
16705 + PAGE_ALIGN((unsigned long)__smp_locks_end));
16706 #endif
16707
16708 apply_paravirt(__parainstructions, __parainstructions_end);
16709 @@ -535,13 +554,17 @@ void __init alternative_instructions(void)
16710 * instructions. And on the local CPU you need to be protected again NMI or MCE
16711 * handlers seeing an inconsistent instruction while you patch.
16712 */
16713 -void *__init_or_module text_poke_early(void *addr, const void *opcode,
16714 +void *__kprobes text_poke_early(void *addr, const void *opcode,
16715 size_t len)
16716 {
16717 unsigned long flags;
16718 local_irq_save(flags);
16719 - memcpy(addr, opcode, len);
16720 +
16721 + pax_open_kernel();
16722 + memcpy(ktla_ktva(addr), opcode, len);
16723 sync_core();
16724 + pax_close_kernel();
16725 +
16726 local_irq_restore(flags);
16727 /* Could also do a CLFLUSH here to speed up CPU recovery; but
16728 that causes hangs on some VIA CPUs. */
16729 @@ -563,36 +586,22 @@ void *__init_or_module text_poke_early(void *addr, const void *opcode,
16730 */
16731 void *__kprobes text_poke(void *addr, const void *opcode, size_t len)
16732 {
16733 - unsigned long flags;
16734 - char *vaddr;
16735 + unsigned char *vaddr = ktla_ktva(addr);
16736 struct page *pages[2];
16737 - int i;
16738 + size_t i;
16739
16740 if (!core_kernel_text((unsigned long)addr)) {
16741 - pages[0] = vmalloc_to_page(addr);
16742 - pages[1] = vmalloc_to_page(addr + PAGE_SIZE);
16743 + pages[0] = vmalloc_to_page(vaddr);
16744 + pages[1] = vmalloc_to_page(vaddr + PAGE_SIZE);
16745 } else {
16746 - pages[0] = virt_to_page(addr);
16747 + pages[0] = virt_to_page(vaddr);
16748 WARN_ON(!PageReserved(pages[0]));
16749 - pages[1] = virt_to_page(addr + PAGE_SIZE);
16750 + pages[1] = virt_to_page(vaddr + PAGE_SIZE);
16751 }
16752 BUG_ON(!pages[0]);
16753 - local_irq_save(flags);
16754 - set_fixmap(FIX_TEXT_POKE0, page_to_phys(pages[0]));
16755 - if (pages[1])
16756 - set_fixmap(FIX_TEXT_POKE1, page_to_phys(pages[1]));
16757 - vaddr = (char *)fix_to_virt(FIX_TEXT_POKE0);
16758 - memcpy(&vaddr[(unsigned long)addr & ~PAGE_MASK], opcode, len);
16759 - clear_fixmap(FIX_TEXT_POKE0);
16760 - if (pages[1])
16761 - clear_fixmap(FIX_TEXT_POKE1);
16762 - local_flush_tlb();
16763 - sync_core();
16764 - /* Could also do a CLFLUSH here to speed up CPU recovery; but
16765 - that causes hangs on some VIA CPUs. */
16766 + text_poke_early(addr, opcode, len);
16767 for (i = 0; i < len; i++)
16768 - BUG_ON(((char *)addr)[i] != ((char *)opcode)[i]);
16769 - local_irq_restore(flags);
16770 + BUG_ON((vaddr)[i] != ((const unsigned char *)opcode)[i]);
16771 return addr;
16772 }
16773
16774 diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
16775 index 904611b..004dde6 100644
16776 --- a/arch/x86/kernel/apic/apic.c
16777 +++ b/arch/x86/kernel/apic/apic.c
16778 @@ -189,7 +189,7 @@ int first_system_vector = 0xfe;
16779 /*
16780 * Debug level, exported for io_apic.c
16781 */
16782 -unsigned int apic_verbosity;
16783 +int apic_verbosity;
16784
16785 int pic_mode;
16786
16787 @@ -1955,7 +1955,7 @@ void smp_error_interrupt(struct pt_regs *regs)
16788 apic_write(APIC_ESR, 0);
16789 v1 = apic_read(APIC_ESR);
16790 ack_APIC_irq();
16791 - atomic_inc(&irq_err_count);
16792 + atomic_inc_unchecked(&irq_err_count);
16793
16794 apic_printk(APIC_DEBUG, KERN_DEBUG "APIC error on CPU%d: %02x(%02x)",
16795 smp_processor_id(), v0 , v1);
16796 diff --git a/arch/x86/kernel/apic/apic_flat_64.c b/arch/x86/kernel/apic/apic_flat_64.c
16797 index 00c77cf..2dc6a2d 100644
16798 --- a/arch/x86/kernel/apic/apic_flat_64.c
16799 +++ b/arch/x86/kernel/apic/apic_flat_64.c
16800 @@ -157,7 +157,7 @@ static int flat_probe(void)
16801 return 1;
16802 }
16803
16804 -static struct apic apic_flat = {
16805 +static struct apic apic_flat __read_only = {
16806 .name = "flat",
16807 .probe = flat_probe,
16808 .acpi_madt_oem_check = flat_acpi_madt_oem_check,
16809 @@ -271,7 +271,7 @@ static int physflat_probe(void)
16810 return 0;
16811 }
16812
16813 -static struct apic apic_physflat = {
16814 +static struct apic apic_physflat __read_only = {
16815
16816 .name = "physical flat",
16817 .probe = physflat_probe,
16818 diff --git a/arch/x86/kernel/apic/apic_noop.c b/arch/x86/kernel/apic/apic_noop.c
16819 index e145f28..2752888 100644
16820 --- a/arch/x86/kernel/apic/apic_noop.c
16821 +++ b/arch/x86/kernel/apic/apic_noop.c
16822 @@ -119,7 +119,7 @@ static void noop_apic_write(u32 reg, u32 v)
16823 WARN_ON_ONCE(cpu_has_apic && !disable_apic);
16824 }
16825
16826 -struct apic apic_noop = {
16827 +struct apic apic_noop __read_only = {
16828 .name = "noop",
16829 .probe = noop_probe,
16830 .acpi_madt_oem_check = NULL,
16831 diff --git a/arch/x86/kernel/apic/bigsmp_32.c b/arch/x86/kernel/apic/bigsmp_32.c
16832 index d50e364..543bee3 100644
16833 --- a/arch/x86/kernel/apic/bigsmp_32.c
16834 +++ b/arch/x86/kernel/apic/bigsmp_32.c
16835 @@ -152,7 +152,7 @@ static int probe_bigsmp(void)
16836 return dmi_bigsmp;
16837 }
16838
16839 -static struct apic apic_bigsmp = {
16840 +static struct apic apic_bigsmp __read_only = {
16841
16842 .name = "bigsmp",
16843 .probe = probe_bigsmp,
16844 diff --git a/arch/x86/kernel/apic/es7000_32.c b/arch/x86/kernel/apic/es7000_32.c
16845 index 0874799..a7a7892 100644
16846 --- a/arch/x86/kernel/apic/es7000_32.c
16847 +++ b/arch/x86/kernel/apic/es7000_32.c
16848 @@ -608,8 +608,7 @@ static int es7000_mps_oem_check_cluster(struct mpc_table *mpc, char *oem,
16849 return ret && es7000_apic_is_cluster();
16850 }
16851
16852 -/* We've been warned by a false positive warning.Use __refdata to keep calm. */
16853 -static struct apic __refdata apic_es7000_cluster = {
16854 +static struct apic apic_es7000_cluster __read_only = {
16855
16856 .name = "es7000",
16857 .probe = probe_es7000,
16858 @@ -675,7 +674,7 @@ static struct apic __refdata apic_es7000_cluster = {
16859 .x86_32_early_logical_apicid = es7000_early_logical_apicid,
16860 };
16861
16862 -static struct apic __refdata apic_es7000 = {
16863 +static struct apic apic_es7000 __read_only = {
16864
16865 .name = "es7000",
16866 .probe = probe_es7000,
16867 diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
16868 index 9ed796c..e930fe4 100644
16869 --- a/arch/x86/kernel/apic/io_apic.c
16870 +++ b/arch/x86/kernel/apic/io_apic.c
16871 @@ -1060,7 +1060,7 @@ int IO_APIC_get_PCI_irq_vector(int bus, int slot, int pin,
16872 }
16873 EXPORT_SYMBOL(IO_APIC_get_PCI_irq_vector);
16874
16875 -void lock_vector_lock(void)
16876 +void lock_vector_lock(void) __acquires(vector_lock)
16877 {
16878 /* Used to the online set of cpus does not change
16879 * during assign_irq_vector.
16880 @@ -1068,7 +1068,7 @@ void lock_vector_lock(void)
16881 raw_spin_lock(&vector_lock);
16882 }
16883
16884 -void unlock_vector_lock(void)
16885 +void unlock_vector_lock(void) __releases(vector_lock)
16886 {
16887 raw_spin_unlock(&vector_lock);
16888 }
16889 @@ -2362,7 +2362,7 @@ static void ack_apic_edge(struct irq_data *data)
16890 ack_APIC_irq();
16891 }
16892
16893 -atomic_t irq_mis_count;
16894 +atomic_unchecked_t irq_mis_count;
16895
16896 #ifdef CONFIG_GENERIC_PENDING_IRQ
16897 static bool io_apic_level_ack_pending(struct irq_cfg *cfg)
16898 @@ -2503,7 +2503,7 @@ static void ack_apic_level(struct irq_data *data)
16899 * at the cpu.
16900 */
16901 if (!(v & (1 << (i & 0x1f)))) {
16902 - atomic_inc(&irq_mis_count);
16903 + atomic_inc_unchecked(&irq_mis_count);
16904
16905 eoi_ioapic_irq(irq, cfg);
16906 }
16907 diff --git a/arch/x86/kernel/apic/numaq_32.c b/arch/x86/kernel/apic/numaq_32.c
16908 index d661ee9..791fd33 100644
16909 --- a/arch/x86/kernel/apic/numaq_32.c
16910 +++ b/arch/x86/kernel/apic/numaq_32.c
16911 @@ -455,8 +455,7 @@ static void numaq_setup_portio_remap(void)
16912 (u_long) xquad_portio, (u_long) num_quads*XQUAD_PORTIO_QUAD);
16913 }
16914
16915 -/* Use __refdata to keep false positive warning calm. */
16916 -static struct apic __refdata apic_numaq = {
16917 +static struct apic apic_numaq __read_only = {
16918
16919 .name = "NUMAQ",
16920 .probe = probe_numaq,
16921 diff --git a/arch/x86/kernel/apic/probe_32.c b/arch/x86/kernel/apic/probe_32.c
16922 index eb35ef9..f184a21 100644
16923 --- a/arch/x86/kernel/apic/probe_32.c
16924 +++ b/arch/x86/kernel/apic/probe_32.c
16925 @@ -72,7 +72,7 @@ static int probe_default(void)
16926 return 1;
16927 }
16928
16929 -static struct apic apic_default = {
16930 +static struct apic apic_default __read_only = {
16931
16932 .name = "default",
16933 .probe = probe_default,
16934 diff --git a/arch/x86/kernel/apic/summit_32.c b/arch/x86/kernel/apic/summit_32.c
16935 index 77c95c0..434f8a4 100644
16936 --- a/arch/x86/kernel/apic/summit_32.c
16937 +++ b/arch/x86/kernel/apic/summit_32.c
16938 @@ -486,7 +486,7 @@ void setup_summit(void)
16939 }
16940 #endif
16941
16942 -static struct apic apic_summit = {
16943 +static struct apic apic_summit __read_only = {
16944
16945 .name = "summit",
16946 .probe = probe_summit,
16947 diff --git a/arch/x86/kernel/apic/x2apic_cluster.c b/arch/x86/kernel/apic/x2apic_cluster.c
16948 index c88baa4..757aee1 100644
16949 --- a/arch/x86/kernel/apic/x2apic_cluster.c
16950 +++ b/arch/x86/kernel/apic/x2apic_cluster.c
16951 @@ -183,7 +183,7 @@ update_clusterinfo(struct notifier_block *nfb, unsigned long action, void *hcpu)
16952 return notifier_from_errno(err);
16953 }
16954
16955 -static struct notifier_block __refdata x2apic_cpu_notifier = {
16956 +static struct notifier_block x2apic_cpu_notifier = {
16957 .notifier_call = update_clusterinfo,
16958 };
16959
16960 @@ -235,7 +235,7 @@ static void cluster_vector_allocation_domain(int cpu, struct cpumask *retmask,
16961 cpumask_and(retmask, mask, per_cpu(cpus_in_cluster, cpu));
16962 }
16963
16964 -static struct apic apic_x2apic_cluster = {
16965 +static struct apic apic_x2apic_cluster __read_only = {
16966
16967 .name = "cluster x2apic",
16968 .probe = x2apic_cluster_probe,
16969 diff --git a/arch/x86/kernel/apic/x2apic_phys.c b/arch/x86/kernel/apic/x2apic_phys.c
16970 index 562a76d..a003c0f 100644
16971 --- a/arch/x86/kernel/apic/x2apic_phys.c
16972 +++ b/arch/x86/kernel/apic/x2apic_phys.c
16973 @@ -89,7 +89,7 @@ static int x2apic_phys_probe(void)
16974 return apic == &apic_x2apic_phys;
16975 }
16976
16977 -static struct apic apic_x2apic_phys = {
16978 +static struct apic apic_x2apic_phys __read_only = {
16979
16980 .name = "physical x2apic",
16981 .probe = x2apic_phys_probe,
16982 diff --git a/arch/x86/kernel/apic/x2apic_uv_x.c b/arch/x86/kernel/apic/x2apic_uv_x.c
16983 index 794f6eb..67e1db2 100644
16984 --- a/arch/x86/kernel/apic/x2apic_uv_x.c
16985 +++ b/arch/x86/kernel/apic/x2apic_uv_x.c
16986 @@ -342,7 +342,7 @@ static int uv_probe(void)
16987 return apic == &apic_x2apic_uv_x;
16988 }
16989
16990 -static struct apic __refdata apic_x2apic_uv_x = {
16991 +static struct apic apic_x2apic_uv_x __read_only = {
16992
16993 .name = "UV large system",
16994 .probe = uv_probe,
16995 diff --git a/arch/x86/kernel/apm_32.c b/arch/x86/kernel/apm_32.c
16996 index 66b5faf..3442423 100644
16997 --- a/arch/x86/kernel/apm_32.c
16998 +++ b/arch/x86/kernel/apm_32.c
16999 @@ -434,7 +434,7 @@ static DEFINE_MUTEX(apm_mutex);
17000 * This is for buggy BIOS's that refer to (real mode) segment 0x40
17001 * even though they are called in protected mode.
17002 */
17003 -static struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4092,
17004 +static const struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4093,
17005 (unsigned long)__va(0x400UL), PAGE_SIZE - 0x400 - 1);
17006
17007 static const char driver_version[] = "1.16ac"; /* no spaces */
17008 @@ -612,7 +612,10 @@ static long __apm_bios_call(void *_call)
17009 BUG_ON(cpu != 0);
17010 gdt = get_cpu_gdt_table(cpu);
17011 save_desc_40 = gdt[0x40 / 8];
17012 +
17013 + pax_open_kernel();
17014 gdt[0x40 / 8] = bad_bios_desc;
17015 + pax_close_kernel();
17016
17017 apm_irq_save(flags);
17018 APM_DO_SAVE_SEGS;
17019 @@ -621,7 +624,11 @@ static long __apm_bios_call(void *_call)
17020 &call->esi);
17021 APM_DO_RESTORE_SEGS;
17022 apm_irq_restore(flags);
17023 +
17024 + pax_open_kernel();
17025 gdt[0x40 / 8] = save_desc_40;
17026 + pax_close_kernel();
17027 +
17028 put_cpu();
17029
17030 return call->eax & 0xff;
17031 @@ -688,7 +695,10 @@ static long __apm_bios_call_simple(void *_call)
17032 BUG_ON(cpu != 0);
17033 gdt = get_cpu_gdt_table(cpu);
17034 save_desc_40 = gdt[0x40 / 8];
17035 +
17036 + pax_open_kernel();
17037 gdt[0x40 / 8] = bad_bios_desc;
17038 + pax_close_kernel();
17039
17040 apm_irq_save(flags);
17041 APM_DO_SAVE_SEGS;
17042 @@ -696,7 +706,11 @@ static long __apm_bios_call_simple(void *_call)
17043 &call->eax);
17044 APM_DO_RESTORE_SEGS;
17045 apm_irq_restore(flags);
17046 +
17047 + pax_open_kernel();
17048 gdt[0x40 / 8] = save_desc_40;
17049 + pax_close_kernel();
17050 +
17051 put_cpu();
17052 return error;
17053 }
17054 @@ -2363,12 +2377,15 @@ static int __init apm_init(void)
17055 * code to that CPU.
17056 */
17057 gdt = get_cpu_gdt_table(0);
17058 +
17059 + pax_open_kernel();
17060 set_desc_base(&gdt[APM_CS >> 3],
17061 (unsigned long)__va((unsigned long)apm_info.bios.cseg << 4));
17062 set_desc_base(&gdt[APM_CS_16 >> 3],
17063 (unsigned long)__va((unsigned long)apm_info.bios.cseg_16 << 4));
17064 set_desc_base(&gdt[APM_DS >> 3],
17065 (unsigned long)__va((unsigned long)apm_info.bios.dseg << 4));
17066 + pax_close_kernel();
17067
17068 proc_create("apm", 0, NULL, &apm_file_ops);
17069
17070 diff --git a/arch/x86/kernel/asm-offsets.c b/arch/x86/kernel/asm-offsets.c
17071 index 2861082..6d4718e 100644
17072 --- a/arch/x86/kernel/asm-offsets.c
17073 +++ b/arch/x86/kernel/asm-offsets.c
17074 @@ -33,6 +33,8 @@ void common(void) {
17075 OFFSET(TI_status, thread_info, status);
17076 OFFSET(TI_addr_limit, thread_info, addr_limit);
17077 OFFSET(TI_preempt_count, thread_info, preempt_count);
17078 + OFFSET(TI_lowest_stack, thread_info, lowest_stack);
17079 + DEFINE(TI_task_thread_sp0, offsetof(struct task_struct, thread.sp0) - offsetof(struct task_struct, tinfo));
17080
17081 BLANK();
17082 OFFSET(crypto_tfm_ctx_offset, crypto_tfm, __crt_ctx);
17083 @@ -53,8 +55,26 @@ void common(void) {
17084 OFFSET(PV_CPU_irq_enable_sysexit, pv_cpu_ops, irq_enable_sysexit);
17085 OFFSET(PV_CPU_read_cr0, pv_cpu_ops, read_cr0);
17086 OFFSET(PV_MMU_read_cr2, pv_mmu_ops, read_cr2);
17087 +
17088 +#ifdef CONFIG_PAX_KERNEXEC
17089 + OFFSET(PV_CPU_write_cr0, pv_cpu_ops, write_cr0);
17090 #endif
17091
17092 +#ifdef CONFIG_PAX_MEMORY_UDEREF
17093 + OFFSET(PV_MMU_read_cr3, pv_mmu_ops, read_cr3);
17094 + OFFSET(PV_MMU_write_cr3, pv_mmu_ops, write_cr3);
17095 +#ifdef CONFIG_X86_64
17096 + OFFSET(PV_MMU_set_pgd_batched, pv_mmu_ops, set_pgd_batched);
17097 +#endif
17098 +#endif
17099 +
17100 +#endif
17101 +
17102 + BLANK();
17103 + DEFINE(PAGE_SIZE_asm, PAGE_SIZE);
17104 + DEFINE(PAGE_SHIFT_asm, PAGE_SHIFT);
17105 + DEFINE(THREAD_SIZE_asm, THREAD_SIZE);
17106 +
17107 #ifdef CONFIG_XEN
17108 BLANK();
17109 OFFSET(XEN_vcpu_info_mask, vcpu_info, evtchn_upcall_mask);
17110 diff --git a/arch/x86/kernel/asm-offsets_64.c b/arch/x86/kernel/asm-offsets_64.c
17111 index 1b4754f..fbb4227 100644
17112 --- a/arch/x86/kernel/asm-offsets_64.c
17113 +++ b/arch/x86/kernel/asm-offsets_64.c
17114 @@ -76,6 +76,7 @@ int main(void)
17115 BLANK();
17116 #undef ENTRY
17117
17118 + DEFINE(TSS_size, sizeof(struct tss_struct));
17119 OFFSET(TSS_ist, tss_struct, x86_tss.ist);
17120 BLANK();
17121
17122 diff --git a/arch/x86/kernel/cpu/Makefile b/arch/x86/kernel/cpu/Makefile
17123 index a0e067d..9c7db16 100644
17124 --- a/arch/x86/kernel/cpu/Makefile
17125 +++ b/arch/x86/kernel/cpu/Makefile
17126 @@ -8,10 +8,6 @@ CFLAGS_REMOVE_common.o = -pg
17127 CFLAGS_REMOVE_perf_event.o = -pg
17128 endif
17129
17130 -# Make sure load_percpu_segment has no stackprotector
17131 -nostackp := $(call cc-option, -fno-stack-protector)
17132 -CFLAGS_common.o := $(nostackp)
17133 -
17134 obj-y := intel_cacheinfo.o scattered.o topology.o
17135 obj-y += proc.o capflags.o powerflags.o common.o
17136 obj-y += vmware.o hypervisor.o mshyperv.o
17137 diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
17138 index fa96eb0..03efe73 100644
17139 --- a/arch/x86/kernel/cpu/amd.c
17140 +++ b/arch/x86/kernel/cpu/amd.c
17141 @@ -737,7 +737,7 @@ static unsigned int __cpuinit amd_size_cache(struct cpuinfo_x86 *c,
17142 unsigned int size)
17143 {
17144 /* AMD errata T13 (order #21922) */
17145 - if ((c->x86 == 6)) {
17146 + if (c->x86 == 6) {
17147 /* Duron Rev A0 */
17148 if (c->x86_model == 3 && c->x86_mask == 0)
17149 size = 64;
17150 diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
17151 index d814772..c615653 100644
17152 --- a/arch/x86/kernel/cpu/common.c
17153 +++ b/arch/x86/kernel/cpu/common.c
17154 @@ -88,60 +88,6 @@ static const struct cpu_dev __cpuinitconst default_cpu = {
17155
17156 static const struct cpu_dev *this_cpu __cpuinitdata = &default_cpu;
17157
17158 -DEFINE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page) = { .gdt = {
17159 -#ifdef CONFIG_X86_64
17160 - /*
17161 - * We need valid kernel segments for data and code in long mode too
17162 - * IRET will check the segment types kkeil 2000/10/28
17163 - * Also sysret mandates a special GDT layout
17164 - *
17165 - * TLS descriptors are currently at a different place compared to i386.
17166 - * Hopefully nobody expects them at a fixed place (Wine?)
17167 - */
17168 - [GDT_ENTRY_KERNEL32_CS] = GDT_ENTRY_INIT(0xc09b, 0, 0xfffff),
17169 - [GDT_ENTRY_KERNEL_CS] = GDT_ENTRY_INIT(0xa09b, 0, 0xfffff),
17170 - [GDT_ENTRY_KERNEL_DS] = GDT_ENTRY_INIT(0xc093, 0, 0xfffff),
17171 - [GDT_ENTRY_DEFAULT_USER32_CS] = GDT_ENTRY_INIT(0xc0fb, 0, 0xfffff),
17172 - [GDT_ENTRY_DEFAULT_USER_DS] = GDT_ENTRY_INIT(0xc0f3, 0, 0xfffff),
17173 - [GDT_ENTRY_DEFAULT_USER_CS] = GDT_ENTRY_INIT(0xa0fb, 0, 0xfffff),
17174 -#else
17175 - [GDT_ENTRY_KERNEL_CS] = GDT_ENTRY_INIT(0xc09a, 0, 0xfffff),
17176 - [GDT_ENTRY_KERNEL_DS] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
17177 - [GDT_ENTRY_DEFAULT_USER_CS] = GDT_ENTRY_INIT(0xc0fa, 0, 0xfffff),
17178 - [GDT_ENTRY_DEFAULT_USER_DS] = GDT_ENTRY_INIT(0xc0f2, 0, 0xfffff),
17179 - /*
17180 - * Segments used for calling PnP BIOS have byte granularity.
17181 - * They code segments and data segments have fixed 64k limits,
17182 - * the transfer segment sizes are set at run time.
17183 - */
17184 - /* 32-bit code */
17185 - [GDT_ENTRY_PNPBIOS_CS32] = GDT_ENTRY_INIT(0x409a, 0, 0xffff),
17186 - /* 16-bit code */
17187 - [GDT_ENTRY_PNPBIOS_CS16] = GDT_ENTRY_INIT(0x009a, 0, 0xffff),
17188 - /* 16-bit data */
17189 - [GDT_ENTRY_PNPBIOS_DS] = GDT_ENTRY_INIT(0x0092, 0, 0xffff),
17190 - /* 16-bit data */
17191 - [GDT_ENTRY_PNPBIOS_TS1] = GDT_ENTRY_INIT(0x0092, 0, 0),
17192 - /* 16-bit data */
17193 - [GDT_ENTRY_PNPBIOS_TS2] = GDT_ENTRY_INIT(0x0092, 0, 0),
17194 - /*
17195 - * The APM segments have byte granularity and their bases
17196 - * are set at run time. All have 64k limits.
17197 - */
17198 - /* 32-bit code */
17199 - [GDT_ENTRY_APMBIOS_BASE] = GDT_ENTRY_INIT(0x409a, 0, 0xffff),
17200 - /* 16-bit code */
17201 - [GDT_ENTRY_APMBIOS_BASE+1] = GDT_ENTRY_INIT(0x009a, 0, 0xffff),
17202 - /* data */
17203 - [GDT_ENTRY_APMBIOS_BASE+2] = GDT_ENTRY_INIT(0x4092, 0, 0xffff),
17204 -
17205 - [GDT_ENTRY_ESPFIX_SS] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
17206 - [GDT_ENTRY_PERCPU] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
17207 - GDT_STACK_CANARY_INIT
17208 -#endif
17209 -} };
17210 -EXPORT_PER_CPU_SYMBOL_GPL(gdt_page);
17211 -
17212 static int __init x86_xsave_setup(char *s)
17213 {
17214 setup_clear_cpu_cap(X86_FEATURE_XSAVE);
17215 @@ -386,7 +332,7 @@ void switch_to_new_gdt(int cpu)
17216 {
17217 struct desc_ptr gdt_descr;
17218
17219 - gdt_descr.address = (long)get_cpu_gdt_table(cpu);
17220 + gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu);
17221 gdt_descr.size = GDT_SIZE - 1;
17222 load_gdt(&gdt_descr);
17223 /* Reload the per-cpu base */
17224 @@ -882,6 +828,10 @@ static void __cpuinit identify_cpu(struct cpuinfo_x86 *c)
17225 /* Filter out anything that depends on CPUID levels we don't have */
17226 filter_cpuid_features(c, true);
17227
17228 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_SEGMEXEC) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF))
17229 + setup_clear_cpu_cap(X86_FEATURE_SEP);
17230 +#endif
17231 +
17232 /* If the model name is still unset, do table lookup. */
17233 if (!c->x86_model_id[0]) {
17234 const char *p;
17235 @@ -1065,10 +1015,12 @@ static __init int setup_disablecpuid(char *arg)
17236 }
17237 __setup("clearcpuid=", setup_disablecpuid);
17238
17239 +DEFINE_PER_CPU(struct thread_info *, current_tinfo) = &init_task.tinfo;
17240 +EXPORT_PER_CPU_SYMBOL(current_tinfo);
17241 +
17242 #ifdef CONFIG_X86_64
17243 struct desc_ptr idt_descr = { NR_VECTORS * 16 - 1, (unsigned long) idt_table };
17244 -struct desc_ptr nmi_idt_descr = { NR_VECTORS * 16 - 1,
17245 - (unsigned long) nmi_idt_table };
17246 +struct desc_ptr nmi_idt_descr = { NR_VECTORS * 16 - 1, (unsigned long) nmi_idt_table };
17247
17248 DEFINE_PER_CPU_FIRST(union irq_stack_union,
17249 irq_stack_union) __aligned(PAGE_SIZE);
17250 @@ -1082,7 +1034,7 @@ DEFINE_PER_CPU(struct task_struct *, current_task) ____cacheline_aligned =
17251 EXPORT_PER_CPU_SYMBOL(current_task);
17252
17253 DEFINE_PER_CPU(unsigned long, kernel_stack) =
17254 - (unsigned long)&init_thread_union - KERNEL_STACK_OFFSET + THREAD_SIZE;
17255 + (unsigned long)&init_thread_union - 16 + THREAD_SIZE;
17256 EXPORT_PER_CPU_SYMBOL(kernel_stack);
17257
17258 DEFINE_PER_CPU(char *, irq_stack_ptr) =
17259 @@ -1227,7 +1179,7 @@ void __cpuinit cpu_init(void)
17260 load_ucode_ap();
17261
17262 cpu = stack_smp_processor_id();
17263 - t = &per_cpu(init_tss, cpu);
17264 + t = init_tss + cpu;
17265 oist = &per_cpu(orig_ist, cpu);
17266
17267 #ifdef CONFIG_NUMA
17268 @@ -1253,7 +1205,7 @@ void __cpuinit cpu_init(void)
17269 switch_to_new_gdt(cpu);
17270 loadsegment(fs, 0);
17271
17272 - load_idt((const struct desc_ptr *)&idt_descr);
17273 + load_idt(&idt_descr);
17274
17275 memset(me->thread.tls_array, 0, GDT_ENTRY_TLS_ENTRIES * 8);
17276 syscall_init();
17277 @@ -1262,7 +1214,6 @@ void __cpuinit cpu_init(void)
17278 wrmsrl(MSR_KERNEL_GS_BASE, 0);
17279 barrier();
17280
17281 - x86_configure_nx();
17282 enable_x2apic();
17283
17284 /*
17285 @@ -1314,7 +1265,7 @@ void __cpuinit cpu_init(void)
17286 {
17287 int cpu = smp_processor_id();
17288 struct task_struct *curr = current;
17289 - struct tss_struct *t = &per_cpu(init_tss, cpu);
17290 + struct tss_struct *t = init_tss + cpu;
17291 struct thread_struct *thread = &curr->thread;
17292
17293 show_ucode_info_early();
17294 diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c
17295 index 1905ce9..a7ac587 100644
17296 --- a/arch/x86/kernel/cpu/intel.c
17297 +++ b/arch/x86/kernel/cpu/intel.c
17298 @@ -173,7 +173,7 @@ static void __cpuinit trap_init_f00f_bug(void)
17299 * Update the IDT descriptor and reload the IDT so that
17300 * it uses the read-only mapped virtual address.
17301 */
17302 - idt_descr.address = fix_to_virt(FIX_F00F_IDT);
17303 + idt_descr.address = (struct desc_struct *)fix_to_virt(FIX_F00F_IDT);
17304 load_idt(&idt_descr);
17305 }
17306 #endif
17307 diff --git a/arch/x86/kernel/cpu/intel_cacheinfo.c b/arch/x86/kernel/cpu/intel_cacheinfo.c
17308 index 7c6f7d5..8cac382 100644
17309 --- a/arch/x86/kernel/cpu/intel_cacheinfo.c
17310 +++ b/arch/x86/kernel/cpu/intel_cacheinfo.c
17311 @@ -1017,6 +1017,22 @@ static struct attribute *default_attrs[] = {
17312 };
17313
17314 #ifdef CONFIG_AMD_NB
17315 +static struct attribute *default_attrs_amd_nb[] = {
17316 + &type.attr,
17317 + &level.attr,
17318 + &coherency_line_size.attr,
17319 + &physical_line_partition.attr,
17320 + &ways_of_associativity.attr,
17321 + &number_of_sets.attr,
17322 + &size.attr,
17323 + &shared_cpu_map.attr,
17324 + &shared_cpu_list.attr,
17325 + NULL,
17326 + NULL,
17327 + NULL,
17328 + NULL
17329 +};
17330 +
17331 static struct attribute ** __cpuinit amd_l3_attrs(void)
17332 {
17333 static struct attribute **attrs;
17334 @@ -1027,18 +1043,7 @@ static struct attribute ** __cpuinit amd_l3_attrs(void)
17335
17336 n = ARRAY_SIZE(default_attrs);
17337
17338 - if (amd_nb_has_feature(AMD_NB_L3_INDEX_DISABLE))
17339 - n += 2;
17340 -
17341 - if (amd_nb_has_feature(AMD_NB_L3_PARTITIONING))
17342 - n += 1;
17343 -
17344 - attrs = kzalloc(n * sizeof (struct attribute *), GFP_KERNEL);
17345 - if (attrs == NULL)
17346 - return attrs = default_attrs;
17347 -
17348 - for (n = 0; default_attrs[n]; n++)
17349 - attrs[n] = default_attrs[n];
17350 + attrs = default_attrs_amd_nb;
17351
17352 if (amd_nb_has_feature(AMD_NB_L3_INDEX_DISABLE)) {
17353 attrs[n++] = &cache_disable_0.attr;
17354 @@ -1089,6 +1094,13 @@ static struct kobj_type ktype_cache = {
17355 .default_attrs = default_attrs,
17356 };
17357
17358 +#ifdef CONFIG_AMD_NB
17359 +static struct kobj_type ktype_cache_amd_nb = {
17360 + .sysfs_ops = &sysfs_ops,
17361 + .default_attrs = default_attrs_amd_nb,
17362 +};
17363 +#endif
17364 +
17365 static struct kobj_type ktype_percpu_entry = {
17366 .sysfs_ops = &sysfs_ops,
17367 };
17368 @@ -1154,20 +1166,26 @@ static int __cpuinit cache_add_dev(struct device *dev)
17369 return retval;
17370 }
17371
17372 +#ifdef CONFIG_AMD_NB
17373 + amd_l3_attrs();
17374 +#endif
17375 +
17376 for (i = 0; i < num_cache_leaves; i++) {
17377 + struct kobj_type *ktype;
17378 +
17379 this_object = INDEX_KOBJECT_PTR(cpu, i);
17380 this_object->cpu = cpu;
17381 this_object->index = i;
17382
17383 this_leaf = CPUID4_INFO_IDX(cpu, i);
17384
17385 - ktype_cache.default_attrs = default_attrs;
17386 + ktype = &ktype_cache;
17387 #ifdef CONFIG_AMD_NB
17388 if (this_leaf->base.nb)
17389 - ktype_cache.default_attrs = amd_l3_attrs();
17390 + ktype = &ktype_cache_amd_nb;
17391 #endif
17392 retval = kobject_init_and_add(&(this_object->kobj),
17393 - &ktype_cache,
17394 + ktype,
17395 per_cpu(ici_cache_kobject, cpu),
17396 "index%1lu", i);
17397 if (unlikely(retval)) {
17398 @@ -1222,7 +1240,7 @@ static int __cpuinit cacheinfo_cpu_callback(struct notifier_block *nfb,
17399 return NOTIFY_OK;
17400 }
17401
17402 -static struct notifier_block __cpuinitdata cacheinfo_cpu_notifier = {
17403 +static struct notifier_block cacheinfo_cpu_notifier = {
17404 .notifier_call = cacheinfo_cpu_callback,
17405 };
17406
17407 diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
17408 index 7bc1263..ce2cbfb 100644
17409 --- a/arch/x86/kernel/cpu/mcheck/mce.c
17410 +++ b/arch/x86/kernel/cpu/mcheck/mce.c
17411 @@ -45,6 +45,7 @@
17412 #include <asm/processor.h>
17413 #include <asm/mce.h>
17414 #include <asm/msr.h>
17415 +#include <asm/local.h>
17416
17417 #include "mce-internal.h"
17418
17419 @@ -246,7 +247,7 @@ static void print_mce(struct mce *m)
17420 !(m->mcgstatus & MCG_STATUS_EIPV) ? " !INEXACT!" : "",
17421 m->cs, m->ip);
17422
17423 - if (m->cs == __KERNEL_CS)
17424 + if (m->cs == __KERNEL_CS || m->cs == __KERNEXEC_KERNEL_CS)
17425 print_symbol("{%s}", m->ip);
17426 pr_cont("\n");
17427 }
17428 @@ -279,10 +280,10 @@ static void print_mce(struct mce *m)
17429
17430 #define PANIC_TIMEOUT 5 /* 5 seconds */
17431
17432 -static atomic_t mce_paniced;
17433 +static atomic_unchecked_t mce_paniced;
17434
17435 static int fake_panic;
17436 -static atomic_t mce_fake_paniced;
17437 +static atomic_unchecked_t mce_fake_paniced;
17438
17439 /* Panic in progress. Enable interrupts and wait for final IPI */
17440 static void wait_for_panic(void)
17441 @@ -306,7 +307,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
17442 /*
17443 * Make sure only one CPU runs in machine check panic
17444 */
17445 - if (atomic_inc_return(&mce_paniced) > 1)
17446 + if (atomic_inc_return_unchecked(&mce_paniced) > 1)
17447 wait_for_panic();
17448 barrier();
17449
17450 @@ -314,7 +315,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
17451 console_verbose();
17452 } else {
17453 /* Don't log too much for fake panic */
17454 - if (atomic_inc_return(&mce_fake_paniced) > 1)
17455 + if (atomic_inc_return_unchecked(&mce_fake_paniced) > 1)
17456 return;
17457 }
17458 /* First print corrected ones that are still unlogged */
17459 @@ -683,7 +684,7 @@ static int mce_timed_out(u64 *t)
17460 * might have been modified by someone else.
17461 */
17462 rmb();
17463 - if (atomic_read(&mce_paniced))
17464 + if (atomic_read_unchecked(&mce_paniced))
17465 wait_for_panic();
17466 if (!mca_cfg.monarch_timeout)
17467 goto out;
17468 @@ -1654,7 +1655,7 @@ static void unexpected_machine_check(struct pt_regs *regs, long error_code)
17469 }
17470
17471 /* Call the installed machine check handler for this CPU setup. */
17472 -void (*machine_check_vector)(struct pt_regs *, long error_code) =
17473 +void (*machine_check_vector)(struct pt_regs *, long error_code) __read_only =
17474 unexpected_machine_check;
17475
17476 /*
17477 @@ -1677,7 +1678,9 @@ void __cpuinit mcheck_cpu_init(struct cpuinfo_x86 *c)
17478 return;
17479 }
17480
17481 + pax_open_kernel();
17482 machine_check_vector = do_machine_check;
17483 + pax_close_kernel();
17484
17485 __mcheck_cpu_init_generic();
17486 __mcheck_cpu_init_vendor(c);
17487 @@ -1691,7 +1694,7 @@ void __cpuinit mcheck_cpu_init(struct cpuinfo_x86 *c)
17488 */
17489
17490 static DEFINE_SPINLOCK(mce_chrdev_state_lock);
17491 -static int mce_chrdev_open_count; /* #times opened */
17492 +static local_t mce_chrdev_open_count; /* #times opened */
17493 static int mce_chrdev_open_exclu; /* already open exclusive? */
17494
17495 static int mce_chrdev_open(struct inode *inode, struct file *file)
17496 @@ -1699,7 +1702,7 @@ static int mce_chrdev_open(struct inode *inode, struct file *file)
17497 spin_lock(&mce_chrdev_state_lock);
17498
17499 if (mce_chrdev_open_exclu ||
17500 - (mce_chrdev_open_count && (file->f_flags & O_EXCL))) {
17501 + (local_read(&mce_chrdev_open_count) && (file->f_flags & O_EXCL))) {
17502 spin_unlock(&mce_chrdev_state_lock);
17503
17504 return -EBUSY;
17505 @@ -1707,7 +1710,7 @@ static int mce_chrdev_open(struct inode *inode, struct file *file)
17506
17507 if (file->f_flags & O_EXCL)
17508 mce_chrdev_open_exclu = 1;
17509 - mce_chrdev_open_count++;
17510 + local_inc(&mce_chrdev_open_count);
17511
17512 spin_unlock(&mce_chrdev_state_lock);
17513
17514 @@ -1718,7 +1721,7 @@ static int mce_chrdev_release(struct inode *inode, struct file *file)
17515 {
17516 spin_lock(&mce_chrdev_state_lock);
17517
17518 - mce_chrdev_open_count--;
17519 + local_dec(&mce_chrdev_open_count);
17520 mce_chrdev_open_exclu = 0;
17521
17522 spin_unlock(&mce_chrdev_state_lock);
17523 @@ -2364,7 +2367,7 @@ mce_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
17524 return NOTIFY_OK;
17525 }
17526
17527 -static struct notifier_block mce_cpu_notifier __cpuinitdata = {
17528 +static struct notifier_block mce_cpu_notifier = {
17529 .notifier_call = mce_cpu_callback,
17530 };
17531
17532 @@ -2374,7 +2377,7 @@ static __init void mce_init_banks(void)
17533
17534 for (i = 0; i < mca_cfg.banks; i++) {
17535 struct mce_bank *b = &mce_banks[i];
17536 - struct device_attribute *a = &b->attr;
17537 + device_attribute_no_const *a = &b->attr;
17538
17539 sysfs_attr_init(&a->attr);
17540 a->attr.name = b->attrname;
17541 @@ -2442,7 +2445,7 @@ struct dentry *mce_get_debugfs_dir(void)
17542 static void mce_reset(void)
17543 {
17544 cpu_missing = 0;
17545 - atomic_set(&mce_fake_paniced, 0);
17546 + atomic_set_unchecked(&mce_fake_paniced, 0);
17547 atomic_set(&mce_executing, 0);
17548 atomic_set(&mce_callin, 0);
17549 atomic_set(&global_nwo, 0);
17550 diff --git a/arch/x86/kernel/cpu/mcheck/p5.c b/arch/x86/kernel/cpu/mcheck/p5.c
17551 index 1c044b1..37a2a43 100644
17552 --- a/arch/x86/kernel/cpu/mcheck/p5.c
17553 +++ b/arch/x86/kernel/cpu/mcheck/p5.c
17554 @@ -11,6 +11,7 @@
17555 #include <asm/processor.h>
17556 #include <asm/mce.h>
17557 #include <asm/msr.h>
17558 +#include <asm/pgtable.h>
17559
17560 /* By default disabled */
17561 int mce_p5_enabled __read_mostly;
17562 @@ -49,7 +50,9 @@ void intel_p5_mcheck_init(struct cpuinfo_x86 *c)
17563 if (!cpu_has(c, X86_FEATURE_MCE))
17564 return;
17565
17566 + pax_open_kernel();
17567 machine_check_vector = pentium_machine_check;
17568 + pax_close_kernel();
17569 /* Make sure the vector pointer is visible before we enable MCEs: */
17570 wmb();
17571
17572 diff --git a/arch/x86/kernel/cpu/mcheck/therm_throt.c b/arch/x86/kernel/cpu/mcheck/therm_throt.c
17573 index 47a1870..8c019a7 100644
17574 --- a/arch/x86/kernel/cpu/mcheck/therm_throt.c
17575 +++ b/arch/x86/kernel/cpu/mcheck/therm_throt.c
17576 @@ -288,7 +288,7 @@ thermal_throttle_cpu_callback(struct notifier_block *nfb,
17577 return notifier_from_errno(err);
17578 }
17579
17580 -static struct notifier_block thermal_throttle_cpu_notifier __cpuinitdata =
17581 +static struct notifier_block thermal_throttle_cpu_notifier =
17582 {
17583 .notifier_call = thermal_throttle_cpu_callback,
17584 };
17585 diff --git a/arch/x86/kernel/cpu/mcheck/winchip.c b/arch/x86/kernel/cpu/mcheck/winchip.c
17586 index e9a701a..35317d6 100644
17587 --- a/arch/x86/kernel/cpu/mcheck/winchip.c
17588 +++ b/arch/x86/kernel/cpu/mcheck/winchip.c
17589 @@ -10,6 +10,7 @@
17590 #include <asm/processor.h>
17591 #include <asm/mce.h>
17592 #include <asm/msr.h>
17593 +#include <asm/pgtable.h>
17594
17595 /* Machine check handler for WinChip C6: */
17596 static void winchip_machine_check(struct pt_regs *regs, long error_code)
17597 @@ -23,7 +24,9 @@ void winchip_mcheck_init(struct cpuinfo_x86 *c)
17598 {
17599 u32 lo, hi;
17600
17601 + pax_open_kernel();
17602 machine_check_vector = winchip_machine_check;
17603 + pax_close_kernel();
17604 /* Make sure the vector pointer is visible before we enable MCEs: */
17605 wmb();
17606
17607 diff --git a/arch/x86/kernel/cpu/mtrr/main.c b/arch/x86/kernel/cpu/mtrr/main.c
17608 index 726bf96..81f0526 100644
17609 --- a/arch/x86/kernel/cpu/mtrr/main.c
17610 +++ b/arch/x86/kernel/cpu/mtrr/main.c
17611 @@ -62,7 +62,7 @@ static DEFINE_MUTEX(mtrr_mutex);
17612 u64 size_or_mask, size_and_mask;
17613 static bool mtrr_aps_delayed_init;
17614
17615 -static const struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM];
17616 +static const struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM] __read_only;
17617
17618 const struct mtrr_ops *mtrr_if;
17619
17620 diff --git a/arch/x86/kernel/cpu/mtrr/mtrr.h b/arch/x86/kernel/cpu/mtrr/mtrr.h
17621 index df5e41f..816c719 100644
17622 --- a/arch/x86/kernel/cpu/mtrr/mtrr.h
17623 +++ b/arch/x86/kernel/cpu/mtrr/mtrr.h
17624 @@ -25,7 +25,7 @@ struct mtrr_ops {
17625 int (*validate_add_page)(unsigned long base, unsigned long size,
17626 unsigned int type);
17627 int (*have_wrcomb)(void);
17628 -};
17629 +} __do_const;
17630
17631 extern int generic_get_free_region(unsigned long base, unsigned long size,
17632 int replace_reg);
17633 diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c
17634 index bf0f01a..9adfee1 100644
17635 --- a/arch/x86/kernel/cpu/perf_event.c
17636 +++ b/arch/x86/kernel/cpu/perf_event.c
17637 @@ -1305,7 +1305,7 @@ static void __init pmu_check_apic(void)
17638 pr_info("no hardware sampling interrupt available.\n");
17639 }
17640
17641 -static struct attribute_group x86_pmu_format_group = {
17642 +static attribute_group_no_const x86_pmu_format_group = {
17643 .name = "format",
17644 .attrs = NULL,
17645 };
17646 @@ -1374,7 +1374,7 @@ static struct attribute *events_attr[] = {
17647 NULL,
17648 };
17649
17650 -static struct attribute_group x86_pmu_events_group = {
17651 +static attribute_group_no_const x86_pmu_events_group = {
17652 .name = "events",
17653 .attrs = events_attr,
17654 };
17655 @@ -1873,7 +1873,7 @@ static unsigned long get_segment_base(unsigned int segment)
17656 if (idx > GDT_ENTRIES)
17657 return 0;
17658
17659 - desc = __this_cpu_ptr(&gdt_page.gdt[0]);
17660 + desc = get_cpu_gdt_table(smp_processor_id());
17661 }
17662
17663 return get_desc_base(desc + idx);
17664 @@ -1963,7 +1963,7 @@ perf_callchain_user(struct perf_callchain_entry *entry, struct pt_regs *regs)
17665 break;
17666
17667 perf_callchain_store(entry, frame.return_address);
17668 - fp = frame.next_frame;
17669 + fp = (const void __force_user *)frame.next_frame;
17670 }
17671 }
17672
17673 diff --git a/arch/x86/kernel/cpu/perf_event_intel.c b/arch/x86/kernel/cpu/perf_event_intel.c
17674 index 4a0a462..be3b204 100644
17675 --- a/arch/x86/kernel/cpu/perf_event_intel.c
17676 +++ b/arch/x86/kernel/cpu/perf_event_intel.c
17677 @@ -1994,10 +1994,10 @@ __init int intel_pmu_init(void)
17678 * v2 and above have a perf capabilities MSR
17679 */
17680 if (version > 1) {
17681 - u64 capabilities;
17682 + u64 capabilities = x86_pmu.intel_cap.capabilities;
17683
17684 - rdmsrl(MSR_IA32_PERF_CAPABILITIES, capabilities);
17685 - x86_pmu.intel_cap.capabilities = capabilities;
17686 + if (rdmsrl_safe(MSR_IA32_PERF_CAPABILITIES, &x86_pmu.intel_cap.capabilities))
17687 + x86_pmu.intel_cap.capabilities = capabilities;
17688 }
17689
17690 intel_ds_init();
17691 diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.c b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
17692 index 3e091f0..d2dc8d6 100644
17693 --- a/arch/x86/kernel/cpu/perf_event_intel_uncore.c
17694 +++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
17695 @@ -2428,7 +2428,7 @@ static void __init uncore_types_exit(struct intel_uncore_type **types)
17696 static int __init uncore_type_init(struct intel_uncore_type *type)
17697 {
17698 struct intel_uncore_pmu *pmus;
17699 - struct attribute_group *attr_group;
17700 + attribute_group_no_const *attr_group;
17701 struct attribute **attrs;
17702 int i, j;
17703
17704 @@ -2826,7 +2826,7 @@ static int
17705 return NOTIFY_OK;
17706 }
17707
17708 -static struct notifier_block uncore_cpu_nb __cpuinitdata = {
17709 +static struct notifier_block uncore_cpu_nb = {
17710 .notifier_call = uncore_cpu_notifier,
17711 /*
17712 * to migrate uncore events, our notifier should be executed
17713 diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.h b/arch/x86/kernel/cpu/perf_event_intel_uncore.h
17714 index e68a455..975a932 100644
17715 --- a/arch/x86/kernel/cpu/perf_event_intel_uncore.h
17716 +++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.h
17717 @@ -428,7 +428,7 @@ struct intel_uncore_box {
17718 struct uncore_event_desc {
17719 struct kobj_attribute attr;
17720 const char *config;
17721 -};
17722 +} __do_const;
17723
17724 #define INTEL_UNCORE_EVENT_DESC(_name, _config) \
17725 { \
17726 diff --git a/arch/x86/kernel/cpuid.c b/arch/x86/kernel/cpuid.c
17727 index 1e4dbcf..b9a34c2 100644
17728 --- a/arch/x86/kernel/cpuid.c
17729 +++ b/arch/x86/kernel/cpuid.c
17730 @@ -171,7 +171,7 @@ static int __cpuinit cpuid_class_cpu_callback(struct notifier_block *nfb,
17731 return notifier_from_errno(err);
17732 }
17733
17734 -static struct notifier_block __refdata cpuid_class_cpu_notifier =
17735 +static struct notifier_block cpuid_class_cpu_notifier =
17736 {
17737 .notifier_call = cpuid_class_cpu_callback,
17738 };
17739 diff --git a/arch/x86/kernel/crash.c b/arch/x86/kernel/crash.c
17740 index 74467fe..18793d5 100644
17741 --- a/arch/x86/kernel/crash.c
17742 +++ b/arch/x86/kernel/crash.c
17743 @@ -58,10 +58,8 @@ static void kdump_nmi_callback(int cpu, struct pt_regs *regs)
17744 {
17745 #ifdef CONFIG_X86_32
17746 struct pt_regs fixed_regs;
17747 -#endif
17748
17749 -#ifdef CONFIG_X86_32
17750 - if (!user_mode_vm(regs)) {
17751 + if (!user_mode(regs)) {
17752 crash_fixup_ss_esp(&fixed_regs, regs);
17753 regs = &fixed_regs;
17754 }
17755 diff --git a/arch/x86/kernel/crash_dump_64.c b/arch/x86/kernel/crash_dump_64.c
17756 index afa64ad..dce67dd 100644
17757 --- a/arch/x86/kernel/crash_dump_64.c
17758 +++ b/arch/x86/kernel/crash_dump_64.c
17759 @@ -36,7 +36,7 @@ ssize_t copy_oldmem_page(unsigned long pfn, char *buf,
17760 return -ENOMEM;
17761
17762 if (userbuf) {
17763 - if (copy_to_user(buf, vaddr + offset, csize)) {
17764 + if (copy_to_user((char __force_user *)buf, vaddr + offset, csize)) {
17765 iounmap(vaddr);
17766 return -EFAULT;
17767 }
17768 diff --git a/arch/x86/kernel/doublefault_32.c b/arch/x86/kernel/doublefault_32.c
17769 index 37250fe..bf2ec74 100644
17770 --- a/arch/x86/kernel/doublefault_32.c
17771 +++ b/arch/x86/kernel/doublefault_32.c
17772 @@ -11,7 +11,7 @@
17773
17774 #define DOUBLEFAULT_STACKSIZE (1024)
17775 static unsigned long doublefault_stack[DOUBLEFAULT_STACKSIZE];
17776 -#define STACK_START (unsigned long)(doublefault_stack+DOUBLEFAULT_STACKSIZE)
17777 +#define STACK_START (unsigned long)(doublefault_stack+DOUBLEFAULT_STACKSIZE-2)
17778
17779 #define ptr_ok(x) ((x) > PAGE_OFFSET && (x) < PAGE_OFFSET + MAXMEM)
17780
17781 @@ -21,7 +21,7 @@ static void doublefault_fn(void)
17782 unsigned long gdt, tss;
17783
17784 store_gdt(&gdt_desc);
17785 - gdt = gdt_desc.address;
17786 + gdt = (unsigned long)gdt_desc.address;
17787
17788 printk(KERN_EMERG "PANIC: double fault, gdt at %08lx [%d bytes]\n", gdt, gdt_desc.size);
17789
17790 @@ -58,10 +58,10 @@ struct tss_struct doublefault_tss __cacheline_aligned = {
17791 /* 0x2 bit is always set */
17792 .flags = X86_EFLAGS_SF | 0x2,
17793 .sp = STACK_START,
17794 - .es = __USER_DS,
17795 + .es = __KERNEL_DS,
17796 .cs = __KERNEL_CS,
17797 .ss = __KERNEL_DS,
17798 - .ds = __USER_DS,
17799 + .ds = __KERNEL_DS,
17800 .fs = __KERNEL_PERCPU,
17801
17802 .__cr3 = __pa_nodebug(swapper_pg_dir),
17803 diff --git a/arch/x86/kernel/dumpstack.c b/arch/x86/kernel/dumpstack.c
17804 index c8797d5..c605e53 100644
17805 --- a/arch/x86/kernel/dumpstack.c
17806 +++ b/arch/x86/kernel/dumpstack.c
17807 @@ -2,6 +2,9 @@
17808 * Copyright (C) 1991, 1992 Linus Torvalds
17809 * Copyright (C) 2000, 2001, 2002 Andi Kleen, SuSE Labs
17810 */
17811 +#ifdef CONFIG_GRKERNSEC_HIDESYM
17812 +#define __INCLUDED_BY_HIDESYM 1
17813 +#endif
17814 #include <linux/kallsyms.h>
17815 #include <linux/kprobes.h>
17816 #include <linux/uaccess.h>
17817 @@ -35,16 +38,14 @@ void printk_address(unsigned long address, int reliable)
17818 static void
17819 print_ftrace_graph_addr(unsigned long addr, void *data,
17820 const struct stacktrace_ops *ops,
17821 - struct thread_info *tinfo, int *graph)
17822 + struct task_struct *task, int *graph)
17823 {
17824 - struct task_struct *task;
17825 unsigned long ret_addr;
17826 int index;
17827
17828 if (addr != (unsigned long)return_to_handler)
17829 return;
17830
17831 - task = tinfo->task;
17832 index = task->curr_ret_stack;
17833
17834 if (!task->ret_stack || index < *graph)
17835 @@ -61,7 +62,7 @@ print_ftrace_graph_addr(unsigned long addr, void *data,
17836 static inline void
17837 print_ftrace_graph_addr(unsigned long addr, void *data,
17838 const struct stacktrace_ops *ops,
17839 - struct thread_info *tinfo, int *graph)
17840 + struct task_struct *task, int *graph)
17841 { }
17842 #endif
17843
17844 @@ -72,10 +73,8 @@ print_ftrace_graph_addr(unsigned long addr, void *data,
17845 * severe exception (double fault, nmi, stack fault, debug, mce) hardware stack
17846 */
17847
17848 -static inline int valid_stack_ptr(struct thread_info *tinfo,
17849 - void *p, unsigned int size, void *end)
17850 +static inline int valid_stack_ptr(void *t, void *p, unsigned int size, void *end)
17851 {
17852 - void *t = tinfo;
17853 if (end) {
17854 if (p < end && p >= (end-THREAD_SIZE))
17855 return 1;
17856 @@ -86,14 +85,14 @@ static inline int valid_stack_ptr(struct thread_info *tinfo,
17857 }
17858
17859 unsigned long
17860 -print_context_stack(struct thread_info *tinfo,
17861 +print_context_stack(struct task_struct *task, void *stack_start,
17862 unsigned long *stack, unsigned long bp,
17863 const struct stacktrace_ops *ops, void *data,
17864 unsigned long *end, int *graph)
17865 {
17866 struct stack_frame *frame = (struct stack_frame *)bp;
17867
17868 - while (valid_stack_ptr(tinfo, stack, sizeof(*stack), end)) {
17869 + while (valid_stack_ptr(stack_start, stack, sizeof(*stack), end)) {
17870 unsigned long addr;
17871
17872 addr = *stack;
17873 @@ -105,7 +104,7 @@ print_context_stack(struct thread_info *tinfo,
17874 } else {
17875 ops->address(data, addr, 0);
17876 }
17877 - print_ftrace_graph_addr(addr, data, ops, tinfo, graph);
17878 + print_ftrace_graph_addr(addr, data, ops, task, graph);
17879 }
17880 stack++;
17881 }
17882 @@ -114,7 +113,7 @@ print_context_stack(struct thread_info *tinfo,
17883 EXPORT_SYMBOL_GPL(print_context_stack);
17884
17885 unsigned long
17886 -print_context_stack_bp(struct thread_info *tinfo,
17887 +print_context_stack_bp(struct task_struct *task, void *stack_start,
17888 unsigned long *stack, unsigned long bp,
17889 const struct stacktrace_ops *ops, void *data,
17890 unsigned long *end, int *graph)
17891 @@ -122,7 +121,7 @@ print_context_stack_bp(struct thread_info *tinfo,
17892 struct stack_frame *frame = (struct stack_frame *)bp;
17893 unsigned long *ret_addr = &frame->return_address;
17894
17895 - while (valid_stack_ptr(tinfo, ret_addr, sizeof(*ret_addr), end)) {
17896 + while (valid_stack_ptr(stack_start, ret_addr, sizeof(*ret_addr), end)) {
17897 unsigned long addr = *ret_addr;
17898
17899 if (!__kernel_text_address(addr))
17900 @@ -131,7 +130,7 @@ print_context_stack_bp(struct thread_info *tinfo,
17901 ops->address(data, addr, 1);
17902 frame = frame->next_frame;
17903 ret_addr = &frame->return_address;
17904 - print_ftrace_graph_addr(addr, data, ops, tinfo, graph);
17905 + print_ftrace_graph_addr(addr, data, ops, task, graph);
17906 }
17907
17908 return (unsigned long)frame;
17909 @@ -189,7 +188,7 @@ void dump_stack(void)
17910
17911 bp = stack_frame(current, NULL);
17912 printk("Pid: %d, comm: %.20s %s %s %.*s\n",
17913 - current->pid, current->comm, print_tainted(),
17914 + task_pid_nr(current), current->comm, print_tainted(),
17915 init_utsname()->release,
17916 (int)strcspn(init_utsname()->version, " "),
17917 init_utsname()->version);
17918 @@ -225,6 +224,8 @@ unsigned __kprobes long oops_begin(void)
17919 }
17920 EXPORT_SYMBOL_GPL(oops_begin);
17921
17922 +extern void gr_handle_kernel_exploit(void);
17923 +
17924 void __kprobes oops_end(unsigned long flags, struct pt_regs *regs, int signr)
17925 {
17926 if (regs && kexec_should_crash(current))
17927 @@ -246,7 +247,10 @@ void __kprobes oops_end(unsigned long flags, struct pt_regs *regs, int signr)
17928 panic("Fatal exception in interrupt");
17929 if (panic_on_oops)
17930 panic("Fatal exception");
17931 - do_exit(signr);
17932 +
17933 + gr_handle_kernel_exploit();
17934 +
17935 + do_group_exit(signr);
17936 }
17937
17938 int __kprobes __die(const char *str, struct pt_regs *regs, long err)
17939 @@ -274,7 +278,7 @@ int __kprobes __die(const char *str, struct pt_regs *regs, long err)
17940 print_modules();
17941 show_regs(regs);
17942 #ifdef CONFIG_X86_32
17943 - if (user_mode_vm(regs)) {
17944 + if (user_mode(regs)) {
17945 sp = regs->sp;
17946 ss = regs->ss & 0xffff;
17947 } else {
17948 @@ -302,7 +306,7 @@ void die(const char *str, struct pt_regs *regs, long err)
17949 unsigned long flags = oops_begin();
17950 int sig = SIGSEGV;
17951
17952 - if (!user_mode_vm(regs))
17953 + if (!user_mode(regs))
17954 report_bug(regs->ip, regs);
17955
17956 if (__die(str, regs, err))
17957 diff --git a/arch/x86/kernel/dumpstack_32.c b/arch/x86/kernel/dumpstack_32.c
17958 index 1038a41..db2c12b 100644
17959 --- a/arch/x86/kernel/dumpstack_32.c
17960 +++ b/arch/x86/kernel/dumpstack_32.c
17961 @@ -38,15 +38,13 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
17962 bp = stack_frame(task, regs);
17963
17964 for (;;) {
17965 - struct thread_info *context;
17966 + void *stack_start = (void *)((unsigned long)stack & ~(THREAD_SIZE-1));
17967
17968 - context = (struct thread_info *)
17969 - ((unsigned long)stack & (~(THREAD_SIZE - 1)));
17970 - bp = ops->walk_stack(context, stack, bp, ops, data, NULL, &graph);
17971 + bp = ops->walk_stack(task, stack_start, stack, bp, ops, data, NULL, &graph);
17972
17973 - stack = (unsigned long *)context->previous_esp;
17974 - if (!stack)
17975 + if (stack_start == task_stack_page(task))
17976 break;
17977 + stack = *(unsigned long **)stack_start;
17978 if (ops->stack(data, "IRQ") < 0)
17979 break;
17980 touch_nmi_watchdog();
17981 @@ -86,7 +84,7 @@ void show_regs(struct pt_regs *regs)
17982 {
17983 int i;
17984
17985 - __show_regs(regs, !user_mode_vm(regs));
17986 + __show_regs(regs, !user_mode(regs));
17987
17988 pr_emerg("Process %.*s (pid: %d, ti=%p task=%p task.ti=%p)\n",
17989 TASK_COMM_LEN, current->comm, task_pid_nr(current),
17990 @@ -95,21 +93,22 @@ void show_regs(struct pt_regs *regs)
17991 * When in-kernel, we also print out the stack and code at the
17992 * time of the fault..
17993 */
17994 - if (!user_mode_vm(regs)) {
17995 + if (!user_mode(regs)) {
17996 unsigned int code_prologue = code_bytes * 43 / 64;
17997 unsigned int code_len = code_bytes;
17998 unsigned char c;
17999 u8 *ip;
18000 + unsigned long cs_base = get_desc_base(&get_cpu_gdt_table(0)[(0xffff & regs->cs) >> 3]);
18001
18002 pr_emerg("Stack:\n");
18003 show_stack_log_lvl(NULL, regs, &regs->sp, 0, KERN_EMERG);
18004
18005 pr_emerg("Code:");
18006
18007 - ip = (u8 *)regs->ip - code_prologue;
18008 + ip = (u8 *)regs->ip - code_prologue + cs_base;
18009 if (ip < (u8 *)PAGE_OFFSET || probe_kernel_address(ip, c)) {
18010 /* try starting at IP */
18011 - ip = (u8 *)regs->ip;
18012 + ip = (u8 *)regs->ip + cs_base;
18013 code_len = code_len - code_prologue + 1;
18014 }
18015 for (i = 0; i < code_len; i++, ip++) {
18016 @@ -118,7 +117,7 @@ void show_regs(struct pt_regs *regs)
18017 pr_cont(" Bad EIP value.");
18018 break;
18019 }
18020 - if (ip == (u8 *)regs->ip)
18021 + if (ip == (u8 *)regs->ip + cs_base)
18022 pr_cont(" <%02x>", c);
18023 else
18024 pr_cont(" %02x", c);
18025 @@ -131,6 +130,7 @@ int is_valid_bugaddr(unsigned long ip)
18026 {
18027 unsigned short ud2;
18028
18029 + ip = ktla_ktva(ip);
18030 if (ip < PAGE_OFFSET)
18031 return 0;
18032 if (probe_kernel_address((unsigned short *)ip, ud2))
18033 @@ -138,3 +138,15 @@ int is_valid_bugaddr(unsigned long ip)
18034
18035 return ud2 == 0x0b0f;
18036 }
18037 +
18038 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
18039 +void pax_check_alloca(unsigned long size)
18040 +{
18041 + unsigned long sp = (unsigned long)&sp, stack_left;
18042 +
18043 + /* all kernel stacks are of the same size */
18044 + stack_left = sp & (THREAD_SIZE - 1);
18045 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
18046 +}
18047 +EXPORT_SYMBOL(pax_check_alloca);
18048 +#endif
18049 diff --git a/arch/x86/kernel/dumpstack_64.c b/arch/x86/kernel/dumpstack_64.c
18050 index b653675..51cc8c0 100644
18051 --- a/arch/x86/kernel/dumpstack_64.c
18052 +++ b/arch/x86/kernel/dumpstack_64.c
18053 @@ -119,9 +119,9 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18054 unsigned long *irq_stack_end =
18055 (unsigned long *)per_cpu(irq_stack_ptr, cpu);
18056 unsigned used = 0;
18057 - struct thread_info *tinfo;
18058 int graph = 0;
18059 unsigned long dummy;
18060 + void *stack_start;
18061
18062 if (!task)
18063 task = current;
18064 @@ -142,10 +142,10 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18065 * current stack address. If the stacks consist of nested
18066 * exceptions
18067 */
18068 - tinfo = task_thread_info(task);
18069 for (;;) {
18070 char *id;
18071 unsigned long *estack_end;
18072 +
18073 estack_end = in_exception_stack(cpu, (unsigned long)stack,
18074 &used, &id);
18075
18076 @@ -153,7 +153,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18077 if (ops->stack(data, id) < 0)
18078 break;
18079
18080 - bp = ops->walk_stack(tinfo, stack, bp, ops,
18081 + bp = ops->walk_stack(task, estack_end - EXCEPTION_STKSZ, stack, bp, ops,
18082 data, estack_end, &graph);
18083 ops->stack(data, "<EOE>");
18084 /*
18085 @@ -161,6 +161,8 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18086 * second-to-last pointer (index -2 to end) in the
18087 * exception stack:
18088 */
18089 + if ((u16)estack_end[-1] != __KERNEL_DS)
18090 + goto out;
18091 stack = (unsigned long *) estack_end[-2];
18092 continue;
18093 }
18094 @@ -172,7 +174,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18095 if (in_irq_stack(stack, irq_stack, irq_stack_end)) {
18096 if (ops->stack(data, "IRQ") < 0)
18097 break;
18098 - bp = ops->walk_stack(tinfo, stack, bp,
18099 + bp = ops->walk_stack(task, irq_stack, stack, bp,
18100 ops, data, irq_stack_end, &graph);
18101 /*
18102 * We link to the next stack (which would be
18103 @@ -191,7 +193,9 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18104 /*
18105 * This handles the process stack:
18106 */
18107 - bp = ops->walk_stack(tinfo, stack, bp, ops, data, NULL, &graph);
18108 + stack_start = (void *)((unsigned long)stack & ~(THREAD_SIZE-1));
18109 + bp = ops->walk_stack(task, stack_start, stack, bp, ops, data, NULL, &graph);
18110 +out:
18111 put_cpu();
18112 }
18113 EXPORT_SYMBOL(dump_trace);
18114 @@ -249,7 +253,7 @@ void show_regs(struct pt_regs *regs)
18115 {
18116 int i;
18117 unsigned long sp;
18118 - const int cpu = smp_processor_id();
18119 + const int cpu = raw_smp_processor_id();
18120 struct task_struct *cur = current;
18121
18122 sp = regs->sp;
18123 @@ -304,3 +308,50 @@ int is_valid_bugaddr(unsigned long ip)
18124
18125 return ud2 == 0x0b0f;
18126 }
18127 +
18128 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
18129 +void pax_check_alloca(unsigned long size)
18130 +{
18131 + unsigned long sp = (unsigned long)&sp, stack_start, stack_end;
18132 + unsigned cpu, used;
18133 + char *id;
18134 +
18135 + /* check the process stack first */
18136 + stack_start = (unsigned long)task_stack_page(current);
18137 + stack_end = stack_start + THREAD_SIZE;
18138 + if (likely(stack_start <= sp && sp < stack_end)) {
18139 + unsigned long stack_left = sp & (THREAD_SIZE - 1);
18140 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
18141 + return;
18142 + }
18143 +
18144 + cpu = get_cpu();
18145 +
18146 + /* check the irq stacks */
18147 + stack_end = (unsigned long)per_cpu(irq_stack_ptr, cpu);
18148 + stack_start = stack_end - IRQ_STACK_SIZE;
18149 + if (stack_start <= sp && sp < stack_end) {
18150 + unsigned long stack_left = sp & (IRQ_STACK_SIZE - 1);
18151 + put_cpu();
18152 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
18153 + return;
18154 + }
18155 +
18156 + /* check the exception stacks */
18157 + used = 0;
18158 + stack_end = (unsigned long)in_exception_stack(cpu, sp, &used, &id);
18159 + stack_start = stack_end - EXCEPTION_STKSZ;
18160 + if (stack_end && stack_start <= sp && sp < stack_end) {
18161 + unsigned long stack_left = sp & (EXCEPTION_STKSZ - 1);
18162 + put_cpu();
18163 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
18164 + return;
18165 + }
18166 +
18167 + put_cpu();
18168 +
18169 + /* unknown stack */
18170 + BUG();
18171 +}
18172 +EXPORT_SYMBOL(pax_check_alloca);
18173 +#endif
18174 diff --git a/arch/x86/kernel/early_printk.c b/arch/x86/kernel/early_printk.c
18175 index 9b9f18b..9fcaa04 100644
18176 --- a/arch/x86/kernel/early_printk.c
18177 +++ b/arch/x86/kernel/early_printk.c
18178 @@ -7,6 +7,7 @@
18179 #include <linux/pci_regs.h>
18180 #include <linux/pci_ids.h>
18181 #include <linux/errno.h>
18182 +#include <linux/sched.h>
18183 #include <asm/io.h>
18184 #include <asm/processor.h>
18185 #include <asm/fcntl.h>
18186 diff --git a/arch/x86/kernel/entry_32.S b/arch/x86/kernel/entry_32.S
18187 index 8f3e2de..934870f 100644
18188 --- a/arch/x86/kernel/entry_32.S
18189 +++ b/arch/x86/kernel/entry_32.S
18190 @@ -177,13 +177,153 @@
18191 /*CFI_REL_OFFSET gs, PT_GS*/
18192 .endm
18193 .macro SET_KERNEL_GS reg
18194 +
18195 +#ifdef CONFIG_CC_STACKPROTECTOR
18196 movl $(__KERNEL_STACK_CANARY), \reg
18197 +#elif defined(CONFIG_PAX_MEMORY_UDEREF)
18198 + movl $(__USER_DS), \reg
18199 +#else
18200 + xorl \reg, \reg
18201 +#endif
18202 +
18203 movl \reg, %gs
18204 .endm
18205
18206 #endif /* CONFIG_X86_32_LAZY_GS */
18207
18208 -.macro SAVE_ALL
18209 +.macro pax_enter_kernel
18210 +#ifdef CONFIG_PAX_KERNEXEC
18211 + call pax_enter_kernel
18212 +#endif
18213 +.endm
18214 +
18215 +.macro pax_exit_kernel
18216 +#ifdef CONFIG_PAX_KERNEXEC
18217 + call pax_exit_kernel
18218 +#endif
18219 +.endm
18220 +
18221 +#ifdef CONFIG_PAX_KERNEXEC
18222 +ENTRY(pax_enter_kernel)
18223 +#ifdef CONFIG_PARAVIRT
18224 + pushl %eax
18225 + pushl %ecx
18226 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0)
18227 + mov %eax, %esi
18228 +#else
18229 + mov %cr0, %esi
18230 +#endif
18231 + bts $16, %esi
18232 + jnc 1f
18233 + mov %cs, %esi
18234 + cmp $__KERNEL_CS, %esi
18235 + jz 3f
18236 + ljmp $__KERNEL_CS, $3f
18237 +1: ljmp $__KERNEXEC_KERNEL_CS, $2f
18238 +2:
18239 +#ifdef CONFIG_PARAVIRT
18240 + mov %esi, %eax
18241 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0)
18242 +#else
18243 + mov %esi, %cr0
18244 +#endif
18245 +3:
18246 +#ifdef CONFIG_PARAVIRT
18247 + popl %ecx
18248 + popl %eax
18249 +#endif
18250 + ret
18251 +ENDPROC(pax_enter_kernel)
18252 +
18253 +ENTRY(pax_exit_kernel)
18254 +#ifdef CONFIG_PARAVIRT
18255 + pushl %eax
18256 + pushl %ecx
18257 +#endif
18258 + mov %cs, %esi
18259 + cmp $__KERNEXEC_KERNEL_CS, %esi
18260 + jnz 2f
18261 +#ifdef CONFIG_PARAVIRT
18262 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0);
18263 + mov %eax, %esi
18264 +#else
18265 + mov %cr0, %esi
18266 +#endif
18267 + btr $16, %esi
18268 + ljmp $__KERNEL_CS, $1f
18269 +1:
18270 +#ifdef CONFIG_PARAVIRT
18271 + mov %esi, %eax
18272 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0);
18273 +#else
18274 + mov %esi, %cr0
18275 +#endif
18276 +2:
18277 +#ifdef CONFIG_PARAVIRT
18278 + popl %ecx
18279 + popl %eax
18280 +#endif
18281 + ret
18282 +ENDPROC(pax_exit_kernel)
18283 +#endif
18284 +
18285 +.macro pax_erase_kstack
18286 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
18287 + call pax_erase_kstack
18288 +#endif
18289 +.endm
18290 +
18291 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
18292 +/*
18293 + * ebp: thread_info
18294 + */
18295 +ENTRY(pax_erase_kstack)
18296 + pushl %edi
18297 + pushl %ecx
18298 + pushl %eax
18299 +
18300 + mov TI_lowest_stack(%ebp), %edi
18301 + mov $-0xBEEF, %eax
18302 + std
18303 +
18304 +1: mov %edi, %ecx
18305 + and $THREAD_SIZE_asm - 1, %ecx
18306 + shr $2, %ecx
18307 + repne scasl
18308 + jecxz 2f
18309 +
18310 + cmp $2*16, %ecx
18311 + jc 2f
18312 +
18313 + mov $2*16, %ecx
18314 + repe scasl
18315 + jecxz 2f
18316 + jne 1b
18317 +
18318 +2: cld
18319 + mov %esp, %ecx
18320 + sub %edi, %ecx
18321 +
18322 + cmp $THREAD_SIZE_asm, %ecx
18323 + jb 3f
18324 + ud2
18325 +3:
18326 +
18327 + shr $2, %ecx
18328 + rep stosl
18329 +
18330 + mov TI_task_thread_sp0(%ebp), %edi
18331 + sub $128, %edi
18332 + mov %edi, TI_lowest_stack(%ebp)
18333 +
18334 + popl %eax
18335 + popl %ecx
18336 + popl %edi
18337 + ret
18338 +ENDPROC(pax_erase_kstack)
18339 +#endif
18340 +
18341 +.macro __SAVE_ALL _DS
18342 cld
18343 PUSH_GS
18344 pushl_cfi %fs
18345 @@ -206,7 +346,7 @@
18346 CFI_REL_OFFSET ecx, 0
18347 pushl_cfi %ebx
18348 CFI_REL_OFFSET ebx, 0
18349 - movl $(__USER_DS), %edx
18350 + movl $\_DS, %edx
18351 movl %edx, %ds
18352 movl %edx, %es
18353 movl $(__KERNEL_PERCPU), %edx
18354 @@ -214,6 +354,15 @@
18355 SET_KERNEL_GS %edx
18356 .endm
18357
18358 +.macro SAVE_ALL
18359 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
18360 + __SAVE_ALL __KERNEL_DS
18361 + pax_enter_kernel
18362 +#else
18363 + __SAVE_ALL __USER_DS
18364 +#endif
18365 +.endm
18366 +
18367 .macro RESTORE_INT_REGS
18368 popl_cfi %ebx
18369 CFI_RESTORE ebx
18370 @@ -297,7 +446,7 @@ ENTRY(ret_from_fork)
18371 popfl_cfi
18372 jmp syscall_exit
18373 CFI_ENDPROC
18374 -END(ret_from_fork)
18375 +ENDPROC(ret_from_fork)
18376
18377 ENTRY(ret_from_kernel_thread)
18378 CFI_STARTPROC
18379 @@ -344,7 +493,15 @@ ret_from_intr:
18380 andl $SEGMENT_RPL_MASK, %eax
18381 #endif
18382 cmpl $USER_RPL, %eax
18383 +
18384 +#ifdef CONFIG_PAX_KERNEXEC
18385 + jae resume_userspace
18386 +
18387 + pax_exit_kernel
18388 + jmp resume_kernel
18389 +#else
18390 jb resume_kernel # not returning to v8086 or userspace
18391 +#endif
18392
18393 ENTRY(resume_userspace)
18394 LOCKDEP_SYS_EXIT
18395 @@ -356,8 +513,8 @@ ENTRY(resume_userspace)
18396 andl $_TIF_WORK_MASK, %ecx # is there any work to be done on
18397 # int/exception return?
18398 jne work_pending
18399 - jmp restore_all
18400 -END(ret_from_exception)
18401 + jmp restore_all_pax
18402 +ENDPROC(ret_from_exception)
18403
18404 #ifdef CONFIG_PREEMPT
18405 ENTRY(resume_kernel)
18406 @@ -372,7 +529,7 @@ need_resched:
18407 jz restore_all
18408 call preempt_schedule_irq
18409 jmp need_resched
18410 -END(resume_kernel)
18411 +ENDPROC(resume_kernel)
18412 #endif
18413 CFI_ENDPROC
18414 /*
18415 @@ -406,30 +563,45 @@ sysenter_past_esp:
18416 /*CFI_REL_OFFSET cs, 0*/
18417 /*
18418 * Push current_thread_info()->sysenter_return to the stack.
18419 - * A tiny bit of offset fixup is necessary - 4*4 means the 4 words
18420 - * pushed above; +8 corresponds to copy_thread's esp0 setting.
18421 */
18422 - pushl_cfi ((TI_sysenter_return)-THREAD_SIZE+8+4*4)(%esp)
18423 + pushl_cfi $0
18424 CFI_REL_OFFSET eip, 0
18425
18426 pushl_cfi %eax
18427 SAVE_ALL
18428 + GET_THREAD_INFO(%ebp)
18429 + movl TI_sysenter_return(%ebp),%ebp
18430 + movl %ebp,PT_EIP(%esp)
18431 ENABLE_INTERRUPTS(CLBR_NONE)
18432
18433 /*
18434 * Load the potential sixth argument from user stack.
18435 * Careful about security.
18436 */
18437 + movl PT_OLDESP(%esp),%ebp
18438 +
18439 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18440 + mov PT_OLDSS(%esp),%ds
18441 +1: movl %ds:(%ebp),%ebp
18442 + push %ss
18443 + pop %ds
18444 +#else
18445 cmpl $__PAGE_OFFSET-3,%ebp
18446 jae syscall_fault
18447 ASM_STAC
18448 1: movl (%ebp),%ebp
18449 ASM_CLAC
18450 +#endif
18451 +
18452 movl %ebp,PT_EBP(%esp)
18453 _ASM_EXTABLE(1b,syscall_fault)
18454
18455 GET_THREAD_INFO(%ebp)
18456
18457 +#ifdef CONFIG_PAX_RANDKSTACK
18458 + pax_erase_kstack
18459 +#endif
18460 +
18461 testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%ebp)
18462 jnz sysenter_audit
18463 sysenter_do_call:
18464 @@ -444,12 +616,24 @@ sysenter_do_call:
18465 testl $_TIF_ALLWORK_MASK, %ecx
18466 jne sysexit_audit
18467 sysenter_exit:
18468 +
18469 +#ifdef CONFIG_PAX_RANDKSTACK
18470 + pushl_cfi %eax
18471 + movl %esp, %eax
18472 + call pax_randomize_kstack
18473 + popl_cfi %eax
18474 +#endif
18475 +
18476 + pax_erase_kstack
18477 +
18478 /* if something modifies registers it must also disable sysexit */
18479 movl PT_EIP(%esp), %edx
18480 movl PT_OLDESP(%esp), %ecx
18481 xorl %ebp,%ebp
18482 TRACE_IRQS_ON
18483 1: mov PT_FS(%esp), %fs
18484 +2: mov PT_DS(%esp), %ds
18485 +3: mov PT_ES(%esp), %es
18486 PTGS_TO_GS
18487 ENABLE_INTERRUPTS_SYSEXIT
18488
18489 @@ -466,6 +650,9 @@ sysenter_audit:
18490 movl %eax,%edx /* 2nd arg: syscall number */
18491 movl $AUDIT_ARCH_I386,%eax /* 1st arg: audit arch */
18492 call __audit_syscall_entry
18493 +
18494 + pax_erase_kstack
18495 +
18496 pushl_cfi %ebx
18497 movl PT_EAX(%esp),%eax /* reload syscall number */
18498 jmp sysenter_do_call
18499 @@ -491,10 +678,16 @@ sysexit_audit:
18500
18501 CFI_ENDPROC
18502 .pushsection .fixup,"ax"
18503 -2: movl $0,PT_FS(%esp)
18504 +4: movl $0,PT_FS(%esp)
18505 + jmp 1b
18506 +5: movl $0,PT_DS(%esp)
18507 + jmp 1b
18508 +6: movl $0,PT_ES(%esp)
18509 jmp 1b
18510 .popsection
18511 - _ASM_EXTABLE(1b,2b)
18512 + _ASM_EXTABLE(1b,4b)
18513 + _ASM_EXTABLE(2b,5b)
18514 + _ASM_EXTABLE(3b,6b)
18515 PTGS_TO_GS_EX
18516 ENDPROC(ia32_sysenter_target)
18517
18518 @@ -509,6 +702,11 @@ ENTRY(system_call)
18519 pushl_cfi %eax # save orig_eax
18520 SAVE_ALL
18521 GET_THREAD_INFO(%ebp)
18522 +
18523 +#ifdef CONFIG_PAX_RANDKSTACK
18524 + pax_erase_kstack
18525 +#endif
18526 +
18527 # system call tracing in operation / emulation
18528 testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%ebp)
18529 jnz syscall_trace_entry
18530 @@ -527,6 +725,15 @@ syscall_exit:
18531 testl $_TIF_ALLWORK_MASK, %ecx # current->work
18532 jne syscall_exit_work
18533
18534 +restore_all_pax:
18535 +
18536 +#ifdef CONFIG_PAX_RANDKSTACK
18537 + movl %esp, %eax
18538 + call pax_randomize_kstack
18539 +#endif
18540 +
18541 + pax_erase_kstack
18542 +
18543 restore_all:
18544 TRACE_IRQS_IRET
18545 restore_all_notrace:
18546 @@ -583,14 +790,34 @@ ldt_ss:
18547 * compensating for the offset by changing to the ESPFIX segment with
18548 * a base address that matches for the difference.
18549 */
18550 -#define GDT_ESPFIX_SS PER_CPU_VAR(gdt_page) + (GDT_ENTRY_ESPFIX_SS * 8)
18551 +#define GDT_ESPFIX_SS (GDT_ENTRY_ESPFIX_SS * 8)(%ebx)
18552 mov %esp, %edx /* load kernel esp */
18553 mov PT_OLDESP(%esp), %eax /* load userspace esp */
18554 mov %dx, %ax /* eax: new kernel esp */
18555 sub %eax, %edx /* offset (low word is 0) */
18556 +#ifdef CONFIG_SMP
18557 + movl PER_CPU_VAR(cpu_number), %ebx
18558 + shll $PAGE_SHIFT_asm, %ebx
18559 + addl $cpu_gdt_table, %ebx
18560 +#else
18561 + movl $cpu_gdt_table, %ebx
18562 +#endif
18563 shr $16, %edx
18564 - mov %dl, GDT_ESPFIX_SS + 4 /* bits 16..23 */
18565 - mov %dh, GDT_ESPFIX_SS + 7 /* bits 24..31 */
18566 +
18567 +#ifdef CONFIG_PAX_KERNEXEC
18568 + mov %cr0, %esi
18569 + btr $16, %esi
18570 + mov %esi, %cr0
18571 +#endif
18572 +
18573 + mov %dl, 4 + GDT_ESPFIX_SS /* bits 16..23 */
18574 + mov %dh, 7 + GDT_ESPFIX_SS /* bits 24..31 */
18575 +
18576 +#ifdef CONFIG_PAX_KERNEXEC
18577 + bts $16, %esi
18578 + mov %esi, %cr0
18579 +#endif
18580 +
18581 pushl_cfi $__ESPFIX_SS
18582 pushl_cfi %eax /* new kernel esp */
18583 /* Disable interrupts, but do not irqtrace this section: we
18584 @@ -619,20 +846,18 @@ work_resched:
18585 movl TI_flags(%ebp), %ecx
18586 andl $_TIF_WORK_MASK, %ecx # is there any work to be done other
18587 # than syscall tracing?
18588 - jz restore_all
18589 + jz restore_all_pax
18590 testb $_TIF_NEED_RESCHED, %cl
18591 jnz work_resched
18592
18593 work_notifysig: # deal with pending signals and
18594 # notify-resume requests
18595 + movl %esp, %eax
18596 #ifdef CONFIG_VM86
18597 testl $X86_EFLAGS_VM, PT_EFLAGS(%esp)
18598 - movl %esp, %eax
18599 jne work_notifysig_v86 # returning to kernel-space or
18600 # vm86-space
18601 1:
18602 -#else
18603 - movl %esp, %eax
18604 #endif
18605 TRACE_IRQS_ON
18606 ENABLE_INTERRUPTS(CLBR_NONE)
18607 @@ -653,7 +878,7 @@ work_notifysig_v86:
18608 movl %eax, %esp
18609 jmp 1b
18610 #endif
18611 -END(work_pending)
18612 +ENDPROC(work_pending)
18613
18614 # perform syscall exit tracing
18615 ALIGN
18616 @@ -661,11 +886,14 @@ syscall_trace_entry:
18617 movl $-ENOSYS,PT_EAX(%esp)
18618 movl %esp, %eax
18619 call syscall_trace_enter
18620 +
18621 + pax_erase_kstack
18622 +
18623 /* What it returned is what we'll actually use. */
18624 cmpl $(NR_syscalls), %eax
18625 jnae syscall_call
18626 jmp syscall_exit
18627 -END(syscall_trace_entry)
18628 +ENDPROC(syscall_trace_entry)
18629
18630 # perform syscall exit tracing
18631 ALIGN
18632 @@ -678,21 +906,25 @@ syscall_exit_work:
18633 movl %esp, %eax
18634 call syscall_trace_leave
18635 jmp resume_userspace
18636 -END(syscall_exit_work)
18637 +ENDPROC(syscall_exit_work)
18638 CFI_ENDPROC
18639
18640 RING0_INT_FRAME # can't unwind into user space anyway
18641 syscall_fault:
18642 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18643 + push %ss
18644 + pop %ds
18645 +#endif
18646 ASM_CLAC
18647 GET_THREAD_INFO(%ebp)
18648 movl $-EFAULT,PT_EAX(%esp)
18649 jmp resume_userspace
18650 -END(syscall_fault)
18651 +ENDPROC(syscall_fault)
18652
18653 syscall_badsys:
18654 movl $-ENOSYS,PT_EAX(%esp)
18655 jmp resume_userspace
18656 -END(syscall_badsys)
18657 +ENDPROC(syscall_badsys)
18658 CFI_ENDPROC
18659 /*
18660 * End of kprobes section
18661 @@ -708,8 +940,15 @@ END(syscall_badsys)
18662 * normal stack and adjusts ESP with the matching offset.
18663 */
18664 /* fixup the stack */
18665 - mov GDT_ESPFIX_SS + 4, %al /* bits 16..23 */
18666 - mov GDT_ESPFIX_SS + 7, %ah /* bits 24..31 */
18667 +#ifdef CONFIG_SMP
18668 + movl PER_CPU_VAR(cpu_number), %ebx
18669 + shll $PAGE_SHIFT_asm, %ebx
18670 + addl $cpu_gdt_table, %ebx
18671 +#else
18672 + movl $cpu_gdt_table, %ebx
18673 +#endif
18674 + mov 4 + GDT_ESPFIX_SS, %al /* bits 16..23 */
18675 + mov 7 + GDT_ESPFIX_SS, %ah /* bits 24..31 */
18676 shl $16, %eax
18677 addl %esp, %eax /* the adjusted stack pointer */
18678 pushl_cfi $__KERNEL_DS
18679 @@ -762,7 +1001,7 @@ vector=vector+1
18680 .endr
18681 2: jmp common_interrupt
18682 .endr
18683 -END(irq_entries_start)
18684 +ENDPROC(irq_entries_start)
18685
18686 .previous
18687 END(interrupt)
18688 @@ -813,7 +1052,7 @@ ENTRY(coprocessor_error)
18689 pushl_cfi $do_coprocessor_error
18690 jmp error_code
18691 CFI_ENDPROC
18692 -END(coprocessor_error)
18693 +ENDPROC(coprocessor_error)
18694
18695 ENTRY(simd_coprocessor_error)
18696 RING0_INT_FRAME
18697 @@ -835,7 +1074,7 @@ ENTRY(simd_coprocessor_error)
18698 #endif
18699 jmp error_code
18700 CFI_ENDPROC
18701 -END(simd_coprocessor_error)
18702 +ENDPROC(simd_coprocessor_error)
18703
18704 ENTRY(device_not_available)
18705 RING0_INT_FRAME
18706 @@ -844,18 +1083,18 @@ ENTRY(device_not_available)
18707 pushl_cfi $do_device_not_available
18708 jmp error_code
18709 CFI_ENDPROC
18710 -END(device_not_available)
18711 +ENDPROC(device_not_available)
18712
18713 #ifdef CONFIG_PARAVIRT
18714 ENTRY(native_iret)
18715 iret
18716 _ASM_EXTABLE(native_iret, iret_exc)
18717 -END(native_iret)
18718 +ENDPROC(native_iret)
18719
18720 ENTRY(native_irq_enable_sysexit)
18721 sti
18722 sysexit
18723 -END(native_irq_enable_sysexit)
18724 +ENDPROC(native_irq_enable_sysexit)
18725 #endif
18726
18727 ENTRY(overflow)
18728 @@ -865,7 +1104,7 @@ ENTRY(overflow)
18729 pushl_cfi $do_overflow
18730 jmp error_code
18731 CFI_ENDPROC
18732 -END(overflow)
18733 +ENDPROC(overflow)
18734
18735 ENTRY(bounds)
18736 RING0_INT_FRAME
18737 @@ -874,7 +1113,7 @@ ENTRY(bounds)
18738 pushl_cfi $do_bounds
18739 jmp error_code
18740 CFI_ENDPROC
18741 -END(bounds)
18742 +ENDPROC(bounds)
18743
18744 ENTRY(invalid_op)
18745 RING0_INT_FRAME
18746 @@ -883,7 +1122,7 @@ ENTRY(invalid_op)
18747 pushl_cfi $do_invalid_op
18748 jmp error_code
18749 CFI_ENDPROC
18750 -END(invalid_op)
18751 +ENDPROC(invalid_op)
18752
18753 ENTRY(coprocessor_segment_overrun)
18754 RING0_INT_FRAME
18755 @@ -892,7 +1131,7 @@ ENTRY(coprocessor_segment_overrun)
18756 pushl_cfi $do_coprocessor_segment_overrun
18757 jmp error_code
18758 CFI_ENDPROC
18759 -END(coprocessor_segment_overrun)
18760 +ENDPROC(coprocessor_segment_overrun)
18761
18762 ENTRY(invalid_TSS)
18763 RING0_EC_FRAME
18764 @@ -900,7 +1139,7 @@ ENTRY(invalid_TSS)
18765 pushl_cfi $do_invalid_TSS
18766 jmp error_code
18767 CFI_ENDPROC
18768 -END(invalid_TSS)
18769 +ENDPROC(invalid_TSS)
18770
18771 ENTRY(segment_not_present)
18772 RING0_EC_FRAME
18773 @@ -908,7 +1147,7 @@ ENTRY(segment_not_present)
18774 pushl_cfi $do_segment_not_present
18775 jmp error_code
18776 CFI_ENDPROC
18777 -END(segment_not_present)
18778 +ENDPROC(segment_not_present)
18779
18780 ENTRY(stack_segment)
18781 RING0_EC_FRAME
18782 @@ -916,7 +1155,7 @@ ENTRY(stack_segment)
18783 pushl_cfi $do_stack_segment
18784 jmp error_code
18785 CFI_ENDPROC
18786 -END(stack_segment)
18787 +ENDPROC(stack_segment)
18788
18789 ENTRY(alignment_check)
18790 RING0_EC_FRAME
18791 @@ -924,7 +1163,7 @@ ENTRY(alignment_check)
18792 pushl_cfi $do_alignment_check
18793 jmp error_code
18794 CFI_ENDPROC
18795 -END(alignment_check)
18796 +ENDPROC(alignment_check)
18797
18798 ENTRY(divide_error)
18799 RING0_INT_FRAME
18800 @@ -933,7 +1172,7 @@ ENTRY(divide_error)
18801 pushl_cfi $do_divide_error
18802 jmp error_code
18803 CFI_ENDPROC
18804 -END(divide_error)
18805 +ENDPROC(divide_error)
18806
18807 #ifdef CONFIG_X86_MCE
18808 ENTRY(machine_check)
18809 @@ -943,7 +1182,7 @@ ENTRY(machine_check)
18810 pushl_cfi machine_check_vector
18811 jmp error_code
18812 CFI_ENDPROC
18813 -END(machine_check)
18814 +ENDPROC(machine_check)
18815 #endif
18816
18817 ENTRY(spurious_interrupt_bug)
18818 @@ -953,7 +1192,7 @@ ENTRY(spurious_interrupt_bug)
18819 pushl_cfi $do_spurious_interrupt_bug
18820 jmp error_code
18821 CFI_ENDPROC
18822 -END(spurious_interrupt_bug)
18823 +ENDPROC(spurious_interrupt_bug)
18824 /*
18825 * End of kprobes section
18826 */
18827 @@ -1063,7 +1302,7 @@ BUILD_INTERRUPT3(hyperv_callback_vector, HYPERVISOR_CALLBACK_VECTOR,
18828
18829 ENTRY(mcount)
18830 ret
18831 -END(mcount)
18832 +ENDPROC(mcount)
18833
18834 ENTRY(ftrace_caller)
18835 cmpl $0, function_trace_stop
18836 @@ -1096,7 +1335,7 @@ ftrace_graph_call:
18837 .globl ftrace_stub
18838 ftrace_stub:
18839 ret
18840 -END(ftrace_caller)
18841 +ENDPROC(ftrace_caller)
18842
18843 ENTRY(ftrace_regs_caller)
18844 pushf /* push flags before compare (in cs location) */
18845 @@ -1197,7 +1436,7 @@ trace:
18846 popl %ecx
18847 popl %eax
18848 jmp ftrace_stub
18849 -END(mcount)
18850 +ENDPROC(mcount)
18851 #endif /* CONFIG_DYNAMIC_FTRACE */
18852 #endif /* CONFIG_FUNCTION_TRACER */
18853
18854 @@ -1215,7 +1454,7 @@ ENTRY(ftrace_graph_caller)
18855 popl %ecx
18856 popl %eax
18857 ret
18858 -END(ftrace_graph_caller)
18859 +ENDPROC(ftrace_graph_caller)
18860
18861 .globl return_to_handler
18862 return_to_handler:
18863 @@ -1271,15 +1510,18 @@ error_code:
18864 movl $-1, PT_ORIG_EAX(%esp) # no syscall to restart
18865 REG_TO_PTGS %ecx
18866 SET_KERNEL_GS %ecx
18867 - movl $(__USER_DS), %ecx
18868 + movl $(__KERNEL_DS), %ecx
18869 movl %ecx, %ds
18870 movl %ecx, %es
18871 +
18872 + pax_enter_kernel
18873 +
18874 TRACE_IRQS_OFF
18875 movl %esp,%eax # pt_regs pointer
18876 call *%edi
18877 jmp ret_from_exception
18878 CFI_ENDPROC
18879 -END(page_fault)
18880 +ENDPROC(page_fault)
18881
18882 /*
18883 * Debug traps and NMI can happen at the one SYSENTER instruction
18884 @@ -1322,7 +1564,7 @@ debug_stack_correct:
18885 call do_debug
18886 jmp ret_from_exception
18887 CFI_ENDPROC
18888 -END(debug)
18889 +ENDPROC(debug)
18890
18891 /*
18892 * NMI is doubly nasty. It can happen _while_ we're handling
18893 @@ -1360,6 +1602,9 @@ nmi_stack_correct:
18894 xorl %edx,%edx # zero error code
18895 movl %esp,%eax # pt_regs pointer
18896 call do_nmi
18897 +
18898 + pax_exit_kernel
18899 +
18900 jmp restore_all_notrace
18901 CFI_ENDPROC
18902
18903 @@ -1396,12 +1641,15 @@ nmi_espfix_stack:
18904 FIXUP_ESPFIX_STACK # %eax == %esp
18905 xorl %edx,%edx # zero error code
18906 call do_nmi
18907 +
18908 + pax_exit_kernel
18909 +
18910 RESTORE_REGS
18911 lss 12+4(%esp), %esp # back to espfix stack
18912 CFI_ADJUST_CFA_OFFSET -24
18913 jmp irq_return
18914 CFI_ENDPROC
18915 -END(nmi)
18916 +ENDPROC(nmi)
18917
18918 ENTRY(int3)
18919 RING0_INT_FRAME
18920 @@ -1414,14 +1662,14 @@ ENTRY(int3)
18921 call do_int3
18922 jmp ret_from_exception
18923 CFI_ENDPROC
18924 -END(int3)
18925 +ENDPROC(int3)
18926
18927 ENTRY(general_protection)
18928 RING0_EC_FRAME
18929 pushl_cfi $do_general_protection
18930 jmp error_code
18931 CFI_ENDPROC
18932 -END(general_protection)
18933 +ENDPROC(general_protection)
18934
18935 #ifdef CONFIG_KVM_GUEST
18936 ENTRY(async_page_fault)
18937 @@ -1430,7 +1678,7 @@ ENTRY(async_page_fault)
18938 pushl_cfi $do_async_page_fault
18939 jmp error_code
18940 CFI_ENDPROC
18941 -END(async_page_fault)
18942 +ENDPROC(async_page_fault)
18943 #endif
18944
18945 /*
18946 diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
18947 index c1d01e6..5625dce 100644
18948 --- a/arch/x86/kernel/entry_64.S
18949 +++ b/arch/x86/kernel/entry_64.S
18950 @@ -59,6 +59,8 @@
18951 #include <asm/context_tracking.h>
18952 #include <asm/smap.h>
18953 #include <linux/err.h>
18954 +#include <asm/pgtable.h>
18955 +#include <asm/alternative-asm.h>
18956
18957 /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */
18958 #include <linux/elf-em.h>
18959 @@ -80,8 +82,9 @@
18960 #ifdef CONFIG_DYNAMIC_FTRACE
18961
18962 ENTRY(function_hook)
18963 + pax_force_retaddr
18964 retq
18965 -END(function_hook)
18966 +ENDPROC(function_hook)
18967
18968 /* skip is set if stack has been adjusted */
18969 .macro ftrace_caller_setup skip=0
18970 @@ -122,8 +125,9 @@ GLOBAL(ftrace_graph_call)
18971 #endif
18972
18973 GLOBAL(ftrace_stub)
18974 + pax_force_retaddr
18975 retq
18976 -END(ftrace_caller)
18977 +ENDPROC(ftrace_caller)
18978
18979 ENTRY(ftrace_regs_caller)
18980 /* Save the current flags before compare (in SS location)*/
18981 @@ -191,7 +195,7 @@ ftrace_restore_flags:
18982 popfq
18983 jmp ftrace_stub
18984
18985 -END(ftrace_regs_caller)
18986 +ENDPROC(ftrace_regs_caller)
18987
18988
18989 #else /* ! CONFIG_DYNAMIC_FTRACE */
18990 @@ -212,6 +216,7 @@ ENTRY(function_hook)
18991 #endif
18992
18993 GLOBAL(ftrace_stub)
18994 + pax_force_retaddr
18995 retq
18996
18997 trace:
18998 @@ -225,12 +230,13 @@ trace:
18999 #endif
19000 subq $MCOUNT_INSN_SIZE, %rdi
19001
19002 + pax_force_fptr ftrace_trace_function
19003 call *ftrace_trace_function
19004
19005 MCOUNT_RESTORE_FRAME
19006
19007 jmp ftrace_stub
19008 -END(function_hook)
19009 +ENDPROC(function_hook)
19010 #endif /* CONFIG_DYNAMIC_FTRACE */
19011 #endif /* CONFIG_FUNCTION_TRACER */
19012
19013 @@ -252,8 +258,9 @@ ENTRY(ftrace_graph_caller)
19014
19015 MCOUNT_RESTORE_FRAME
19016
19017 + pax_force_retaddr
19018 retq
19019 -END(ftrace_graph_caller)
19020 +ENDPROC(ftrace_graph_caller)
19021
19022 GLOBAL(return_to_handler)
19023 subq $24, %rsp
19024 @@ -269,7 +276,9 @@ GLOBAL(return_to_handler)
19025 movq 8(%rsp), %rdx
19026 movq (%rsp), %rax
19027 addq $24, %rsp
19028 + pax_force_fptr %rdi
19029 jmp *%rdi
19030 +ENDPROC(return_to_handler)
19031 #endif
19032
19033
19034 @@ -284,6 +293,282 @@ ENTRY(native_usergs_sysret64)
19035 ENDPROC(native_usergs_sysret64)
19036 #endif /* CONFIG_PARAVIRT */
19037
19038 + .macro ljmpq sel, off
19039 +#if defined(CONFIG_MPSC) || defined(CONFIG_MCORE2) || defined (CONFIG_MATOM)
19040 + .byte 0x48; ljmp *1234f(%rip)
19041 + .pushsection .rodata
19042 + .align 16
19043 + 1234: .quad \off; .word \sel
19044 + .popsection
19045 +#else
19046 + pushq $\sel
19047 + pushq $\off
19048 + lretq
19049 +#endif
19050 + .endm
19051 +
19052 + .macro pax_enter_kernel
19053 + pax_set_fptr_mask
19054 +#ifdef CONFIG_PAX_KERNEXEC
19055 + call pax_enter_kernel
19056 +#endif
19057 + .endm
19058 +
19059 + .macro pax_exit_kernel
19060 +#ifdef CONFIG_PAX_KERNEXEC
19061 + call pax_exit_kernel
19062 +#endif
19063 + .endm
19064 +
19065 +#ifdef CONFIG_PAX_KERNEXEC
19066 +ENTRY(pax_enter_kernel)
19067 + pushq %rdi
19068 +
19069 +#ifdef CONFIG_PARAVIRT
19070 + PV_SAVE_REGS(CLBR_RDI)
19071 +#endif
19072 +
19073 + GET_CR0_INTO_RDI
19074 + bts $16,%rdi
19075 + jnc 3f
19076 + mov %cs,%edi
19077 + cmp $__KERNEL_CS,%edi
19078 + jnz 2f
19079 +1:
19080 +
19081 +#ifdef CONFIG_PARAVIRT
19082 + PV_RESTORE_REGS(CLBR_RDI)
19083 +#endif
19084 +
19085 + popq %rdi
19086 + pax_force_retaddr
19087 + retq
19088 +
19089 +2: ljmpq __KERNEL_CS,1b
19090 +3: ljmpq __KERNEXEC_KERNEL_CS,4f
19091 +4: SET_RDI_INTO_CR0
19092 + jmp 1b
19093 +ENDPROC(pax_enter_kernel)
19094 +
19095 +ENTRY(pax_exit_kernel)
19096 + pushq %rdi
19097 +
19098 +#ifdef CONFIG_PARAVIRT
19099 + PV_SAVE_REGS(CLBR_RDI)
19100 +#endif
19101 +
19102 + mov %cs,%rdi
19103 + cmp $__KERNEXEC_KERNEL_CS,%edi
19104 + jz 2f
19105 + GET_CR0_INTO_RDI
19106 + bts $16,%rdi
19107 + jnc 4f
19108 +1:
19109 +
19110 +#ifdef CONFIG_PARAVIRT
19111 + PV_RESTORE_REGS(CLBR_RDI);
19112 +#endif
19113 +
19114 + popq %rdi
19115 + pax_force_retaddr
19116 + retq
19117 +
19118 +2: GET_CR0_INTO_RDI
19119 + btr $16,%rdi
19120 + jnc 4f
19121 + ljmpq __KERNEL_CS,3f
19122 +3: SET_RDI_INTO_CR0
19123 + jmp 1b
19124 +4: ud2
19125 + jmp 4b
19126 +ENDPROC(pax_exit_kernel)
19127 +#endif
19128 +
19129 + .macro pax_enter_kernel_user
19130 + pax_set_fptr_mask
19131 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19132 + call pax_enter_kernel_user
19133 +#endif
19134 + .endm
19135 +
19136 + .macro pax_exit_kernel_user
19137 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19138 + call pax_exit_kernel_user
19139 +#endif
19140 +#ifdef CONFIG_PAX_RANDKSTACK
19141 + pushq %rax
19142 + call pax_randomize_kstack
19143 + popq %rax
19144 +#endif
19145 + .endm
19146 +
19147 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19148 +ENTRY(pax_enter_kernel_user)
19149 + pushq %rdi
19150 + pushq %rbx
19151 +
19152 +#ifdef CONFIG_PARAVIRT
19153 + PV_SAVE_REGS(CLBR_RDI)
19154 +#endif
19155 +
19156 + GET_CR3_INTO_RDI
19157 + mov %rdi,%rbx
19158 + add $__START_KERNEL_map,%rbx
19159 + sub phys_base(%rip),%rbx
19160 +
19161 +#ifdef CONFIG_PARAVIRT
19162 + pushq %rdi
19163 + cmpl $0, pv_info+PARAVIRT_enabled
19164 + jz 1f
19165 + i = 0
19166 + .rept USER_PGD_PTRS
19167 + mov i*8(%rbx),%rsi
19168 + mov $0,%sil
19169 + lea i*8(%rbx),%rdi
19170 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_set_pgd_batched)
19171 + i = i + 1
19172 + .endr
19173 + jmp 2f
19174 +1:
19175 +#endif
19176 +
19177 + i = 0
19178 + .rept USER_PGD_PTRS
19179 + movb $0,i*8(%rbx)
19180 + i = i + 1
19181 + .endr
19182 +
19183 +#ifdef CONFIG_PARAVIRT
19184 +2: popq %rdi
19185 +#endif
19186 + SET_RDI_INTO_CR3
19187 +
19188 +#ifdef CONFIG_PAX_KERNEXEC
19189 + GET_CR0_INTO_RDI
19190 + bts $16,%rdi
19191 + SET_RDI_INTO_CR0
19192 +#endif
19193 +
19194 +#ifdef CONFIG_PARAVIRT
19195 + PV_RESTORE_REGS(CLBR_RDI)
19196 +#endif
19197 +
19198 + popq %rbx
19199 + popq %rdi
19200 + pax_force_retaddr
19201 + retq
19202 +ENDPROC(pax_enter_kernel_user)
19203 +
19204 +ENTRY(pax_exit_kernel_user)
19205 + push %rdi
19206 +
19207 +#ifdef CONFIG_PARAVIRT
19208 + pushq %rbx
19209 + PV_SAVE_REGS(CLBR_RDI)
19210 +#endif
19211 +
19212 +#ifdef CONFIG_PAX_KERNEXEC
19213 + GET_CR0_INTO_RDI
19214 + btr $16,%rdi
19215 + jnc 3f
19216 + SET_RDI_INTO_CR0
19217 +#endif
19218 +
19219 + GET_CR3_INTO_RDI
19220 + add $__START_KERNEL_map,%rdi
19221 + sub phys_base(%rip),%rdi
19222 +
19223 +#ifdef CONFIG_PARAVIRT
19224 + cmpl $0, pv_info+PARAVIRT_enabled
19225 + jz 1f
19226 + mov %rdi,%rbx
19227 + i = 0
19228 + .rept USER_PGD_PTRS
19229 + mov i*8(%rbx),%rsi
19230 + mov $0x67,%sil
19231 + lea i*8(%rbx),%rdi
19232 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_set_pgd_batched)
19233 + i = i + 1
19234 + .endr
19235 + jmp 2f
19236 +1:
19237 +#endif
19238 +
19239 + i = 0
19240 + .rept USER_PGD_PTRS
19241 + movb $0x67,i*8(%rdi)
19242 + i = i + 1
19243 + .endr
19244 +
19245 +#ifdef CONFIG_PARAVIRT
19246 +2: PV_RESTORE_REGS(CLBR_RDI)
19247 + popq %rbx
19248 +#endif
19249 +
19250 + popq %rdi
19251 + pax_force_retaddr
19252 + retq
19253 +3: ud2
19254 + jmp 3b
19255 +ENDPROC(pax_exit_kernel_user)
19256 +#endif
19257 +
19258 +.macro pax_erase_kstack
19259 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
19260 + call pax_erase_kstack
19261 +#endif
19262 +.endm
19263 +
19264 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
19265 +ENTRY(pax_erase_kstack)
19266 + pushq %rdi
19267 + pushq %rcx
19268 + pushq %rax
19269 + pushq %r11
19270 +
19271 + GET_THREAD_INFO(%r11)
19272 + mov TI_lowest_stack(%r11), %rdi
19273 + mov $-0xBEEF, %rax
19274 + std
19275 +
19276 +1: mov %edi, %ecx
19277 + and $THREAD_SIZE_asm - 1, %ecx
19278 + shr $3, %ecx
19279 + repne scasq
19280 + jecxz 2f
19281 +
19282 + cmp $2*8, %ecx
19283 + jc 2f
19284 +
19285 + mov $2*8, %ecx
19286 + repe scasq
19287 + jecxz 2f
19288 + jne 1b
19289 +
19290 +2: cld
19291 + mov %esp, %ecx
19292 + sub %edi, %ecx
19293 +
19294 + cmp $THREAD_SIZE_asm, %rcx
19295 + jb 3f
19296 + ud2
19297 +3:
19298 +
19299 + shr $3, %ecx
19300 + rep stosq
19301 +
19302 + mov TI_task_thread_sp0(%r11), %rdi
19303 + sub $256, %rdi
19304 + mov %rdi, TI_lowest_stack(%r11)
19305 +
19306 + popq %r11
19307 + popq %rax
19308 + popq %rcx
19309 + popq %rdi
19310 + pax_force_retaddr
19311 + ret
19312 +ENDPROC(pax_erase_kstack)
19313 +#endif
19314
19315 .macro TRACE_IRQS_IRETQ offset=ARGOFFSET
19316 #ifdef CONFIG_TRACE_IRQFLAGS
19317 @@ -375,8 +660,8 @@ ENDPROC(native_usergs_sysret64)
19318 .endm
19319
19320 .macro UNFAKE_STACK_FRAME
19321 - addq $8*6, %rsp
19322 - CFI_ADJUST_CFA_OFFSET -(6*8)
19323 + addq $8*6 + ARG_SKIP, %rsp
19324 + CFI_ADJUST_CFA_OFFSET -(6*8 + ARG_SKIP)
19325 .endm
19326
19327 /*
19328 @@ -463,7 +748,7 @@ ENDPROC(native_usergs_sysret64)
19329 movq %rsp, %rsi
19330
19331 leaq -RBP(%rsp),%rdi /* arg1 for handler */
19332 - testl $3, CS-RBP(%rsi)
19333 + testb $3, CS-RBP(%rsi)
19334 je 1f
19335 SWAPGS
19336 /*
19337 @@ -498,9 +783,10 @@ ENTRY(save_rest)
19338 movq_cfi r15, R15+16
19339 movq %r11, 8(%rsp) /* return address */
19340 FIXUP_TOP_OF_STACK %r11, 16
19341 + pax_force_retaddr
19342 ret
19343 CFI_ENDPROC
19344 -END(save_rest)
19345 +ENDPROC(save_rest)
19346
19347 /* save complete stack frame */
19348 .pushsection .kprobes.text, "ax"
19349 @@ -529,9 +815,10 @@ ENTRY(save_paranoid)
19350 js 1f /* negative -> in kernel */
19351 SWAPGS
19352 xorl %ebx,%ebx
19353 -1: ret
19354 +1: pax_force_retaddr_bts
19355 + ret
19356 CFI_ENDPROC
19357 -END(save_paranoid)
19358 +ENDPROC(save_paranoid)
19359 .popsection
19360
19361 /*
19362 @@ -553,7 +840,7 @@ ENTRY(ret_from_fork)
19363
19364 RESTORE_REST
19365
19366 - testl $3, CS-ARGOFFSET(%rsp) # from kernel_thread?
19367 + testb $3, CS-ARGOFFSET(%rsp) # from kernel_thread?
19368 jz 1f
19369
19370 testl $_TIF_IA32, TI_flags(%rcx) # 32-bit compat task needs IRET
19371 @@ -571,7 +858,7 @@ ENTRY(ret_from_fork)
19372 RESTORE_REST
19373 jmp int_ret_from_sys_call
19374 CFI_ENDPROC
19375 -END(ret_from_fork)
19376 +ENDPROC(ret_from_fork)
19377
19378 /*
19379 * System call entry. Up to 6 arguments in registers are supported.
19380 @@ -608,7 +895,7 @@ END(ret_from_fork)
19381 ENTRY(system_call)
19382 CFI_STARTPROC simple
19383 CFI_SIGNAL_FRAME
19384 - CFI_DEF_CFA rsp,KERNEL_STACK_OFFSET
19385 + CFI_DEF_CFA rsp,0
19386 CFI_REGISTER rip,rcx
19387 /*CFI_REGISTER rflags,r11*/
19388 SWAPGS_UNSAFE_STACK
19389 @@ -621,16 +908,23 @@ GLOBAL(system_call_after_swapgs)
19390
19391 movq %rsp,PER_CPU_VAR(old_rsp)
19392 movq PER_CPU_VAR(kernel_stack),%rsp
19393 + SAVE_ARGS 8*6,0
19394 + pax_enter_kernel_user
19395 +
19396 +#ifdef CONFIG_PAX_RANDKSTACK
19397 + pax_erase_kstack
19398 +#endif
19399 +
19400 /*
19401 * No need to follow this irqs off/on section - it's straight
19402 * and short:
19403 */
19404 ENABLE_INTERRUPTS(CLBR_NONE)
19405 - SAVE_ARGS 8,0
19406 movq %rax,ORIG_RAX-ARGOFFSET(%rsp)
19407 movq %rcx,RIP-ARGOFFSET(%rsp)
19408 CFI_REL_OFFSET rip,RIP-ARGOFFSET
19409 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
19410 + GET_THREAD_INFO(%rcx)
19411 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%rcx)
19412 jnz tracesys
19413 system_call_fastpath:
19414 #if __SYSCALL_MASK == ~0
19415 @@ -640,7 +934,7 @@ system_call_fastpath:
19416 cmpl $__NR_syscall_max,%eax
19417 #endif
19418 ja badsys
19419 - movq %r10,%rcx
19420 + movq R10-ARGOFFSET(%rsp),%rcx
19421 call *sys_call_table(,%rax,8) # XXX: rip relative
19422 movq %rax,RAX-ARGOFFSET(%rsp)
19423 /*
19424 @@ -654,10 +948,13 @@ sysret_check:
19425 LOCKDEP_SYS_EXIT
19426 DISABLE_INTERRUPTS(CLBR_NONE)
19427 TRACE_IRQS_OFF
19428 - movl TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET),%edx
19429 + GET_THREAD_INFO(%rcx)
19430 + movl TI_flags(%rcx),%edx
19431 andl %edi,%edx
19432 jnz sysret_careful
19433 CFI_REMEMBER_STATE
19434 + pax_exit_kernel_user
19435 + pax_erase_kstack
19436 /*
19437 * sysretq will re-enable interrupts:
19438 */
19439 @@ -709,14 +1006,18 @@ badsys:
19440 * jump back to the normal fast path.
19441 */
19442 auditsys:
19443 - movq %r10,%r9 /* 6th arg: 4th syscall arg */
19444 + movq R10-ARGOFFSET(%rsp),%r9 /* 6th arg: 4th syscall arg */
19445 movq %rdx,%r8 /* 5th arg: 3rd syscall arg */
19446 movq %rsi,%rcx /* 4th arg: 2nd syscall arg */
19447 movq %rdi,%rdx /* 3rd arg: 1st syscall arg */
19448 movq %rax,%rsi /* 2nd arg: syscall number */
19449 movl $AUDIT_ARCH_X86_64,%edi /* 1st arg: audit arch */
19450 call __audit_syscall_entry
19451 +
19452 + pax_erase_kstack
19453 +
19454 LOAD_ARGS 0 /* reload call-clobbered registers */
19455 + pax_set_fptr_mask
19456 jmp system_call_fastpath
19457
19458 /*
19459 @@ -737,7 +1038,7 @@ sysret_audit:
19460 /* Do syscall tracing */
19461 tracesys:
19462 #ifdef CONFIG_AUDITSYSCALL
19463 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
19464 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%rcx)
19465 jz auditsys
19466 #endif
19467 SAVE_REST
19468 @@ -745,12 +1046,16 @@ tracesys:
19469 FIXUP_TOP_OF_STACK %rdi
19470 movq %rsp,%rdi
19471 call syscall_trace_enter
19472 +
19473 + pax_erase_kstack
19474 +
19475 /*
19476 * Reload arg registers from stack in case ptrace changed them.
19477 * We don't reload %rax because syscall_trace_enter() returned
19478 * the value it wants us to use in the table lookup.
19479 */
19480 LOAD_ARGS ARGOFFSET, 1
19481 + pax_set_fptr_mask
19482 RESTORE_REST
19483 #if __SYSCALL_MASK == ~0
19484 cmpq $__NR_syscall_max,%rax
19485 @@ -759,7 +1064,7 @@ tracesys:
19486 cmpl $__NR_syscall_max,%eax
19487 #endif
19488 ja int_ret_from_sys_call /* RAX(%rsp) set to -ENOSYS above */
19489 - movq %r10,%rcx /* fixup for C */
19490 + movq R10-ARGOFFSET(%rsp),%rcx /* fixup for C */
19491 call *sys_call_table(,%rax,8)
19492 movq %rax,RAX-ARGOFFSET(%rsp)
19493 /* Use IRET because user could have changed frame */
19494 @@ -780,7 +1085,9 @@ GLOBAL(int_with_check)
19495 andl %edi,%edx
19496 jnz int_careful
19497 andl $~TS_COMPAT,TI_status(%rcx)
19498 - jmp retint_swapgs
19499 + pax_exit_kernel_user
19500 + pax_erase_kstack
19501 + jmp retint_swapgs_pax
19502
19503 /* Either reschedule or signal or syscall exit tracking needed. */
19504 /* First do a reschedule test. */
19505 @@ -826,7 +1133,7 @@ int_restore_rest:
19506 TRACE_IRQS_OFF
19507 jmp int_with_check
19508 CFI_ENDPROC
19509 -END(system_call)
19510 +ENDPROC(system_call)
19511
19512 .macro FORK_LIKE func
19513 ENTRY(stub_\func)
19514 @@ -839,9 +1146,10 @@ ENTRY(stub_\func)
19515 DEFAULT_FRAME 0 8 /* offset 8: return address */
19516 call sys_\func
19517 RESTORE_TOP_OF_STACK %r11, 8
19518 + pax_force_retaddr
19519 ret $REST_SKIP /* pop extended registers */
19520 CFI_ENDPROC
19521 -END(stub_\func)
19522 +ENDPROC(stub_\func)
19523 .endm
19524
19525 .macro FIXED_FRAME label,func
19526 @@ -851,9 +1159,10 @@ ENTRY(\label)
19527 FIXUP_TOP_OF_STACK %r11, 8-ARGOFFSET
19528 call \func
19529 RESTORE_TOP_OF_STACK %r11, 8-ARGOFFSET
19530 + pax_force_retaddr
19531 ret
19532 CFI_ENDPROC
19533 -END(\label)
19534 +ENDPROC(\label)
19535 .endm
19536
19537 FORK_LIKE clone
19538 @@ -870,9 +1179,10 @@ ENTRY(ptregscall_common)
19539 movq_cfi_restore R12+8, r12
19540 movq_cfi_restore RBP+8, rbp
19541 movq_cfi_restore RBX+8, rbx
19542 + pax_force_retaddr
19543 ret $REST_SKIP /* pop extended registers */
19544 CFI_ENDPROC
19545 -END(ptregscall_common)
19546 +ENDPROC(ptregscall_common)
19547
19548 ENTRY(stub_execve)
19549 CFI_STARTPROC
19550 @@ -885,7 +1195,7 @@ ENTRY(stub_execve)
19551 RESTORE_REST
19552 jmp int_ret_from_sys_call
19553 CFI_ENDPROC
19554 -END(stub_execve)
19555 +ENDPROC(stub_execve)
19556
19557 /*
19558 * sigreturn is special because it needs to restore all registers on return.
19559 @@ -902,7 +1212,7 @@ ENTRY(stub_rt_sigreturn)
19560 RESTORE_REST
19561 jmp int_ret_from_sys_call
19562 CFI_ENDPROC
19563 -END(stub_rt_sigreturn)
19564 +ENDPROC(stub_rt_sigreturn)
19565
19566 #ifdef CONFIG_X86_X32_ABI
19567 ENTRY(stub_x32_rt_sigreturn)
19568 @@ -916,7 +1226,7 @@ ENTRY(stub_x32_rt_sigreturn)
19569 RESTORE_REST
19570 jmp int_ret_from_sys_call
19571 CFI_ENDPROC
19572 -END(stub_x32_rt_sigreturn)
19573 +ENDPROC(stub_x32_rt_sigreturn)
19574
19575 ENTRY(stub_x32_execve)
19576 CFI_STARTPROC
19577 @@ -930,7 +1240,7 @@ ENTRY(stub_x32_execve)
19578 RESTORE_REST
19579 jmp int_ret_from_sys_call
19580 CFI_ENDPROC
19581 -END(stub_x32_execve)
19582 +ENDPROC(stub_x32_execve)
19583
19584 #endif
19585
19586 @@ -967,7 +1277,7 @@ vector=vector+1
19587 2: jmp common_interrupt
19588 .endr
19589 CFI_ENDPROC
19590 -END(irq_entries_start)
19591 +ENDPROC(irq_entries_start)
19592
19593 .previous
19594 END(interrupt)
19595 @@ -987,6 +1297,16 @@ END(interrupt)
19596 subq $ORIG_RAX-RBP, %rsp
19597 CFI_ADJUST_CFA_OFFSET ORIG_RAX-RBP
19598 SAVE_ARGS_IRQ
19599 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19600 + testb $3, CS(%rdi)
19601 + jnz 1f
19602 + pax_enter_kernel
19603 + jmp 2f
19604 +1: pax_enter_kernel_user
19605 +2:
19606 +#else
19607 + pax_enter_kernel
19608 +#endif
19609 call \func
19610 .endm
19611
19612 @@ -1019,7 +1339,7 @@ ret_from_intr:
19613
19614 exit_intr:
19615 GET_THREAD_INFO(%rcx)
19616 - testl $3,CS-ARGOFFSET(%rsp)
19617 + testb $3,CS-ARGOFFSET(%rsp)
19618 je retint_kernel
19619
19620 /* Interrupt came from user space */
19621 @@ -1041,12 +1361,16 @@ retint_swapgs: /* return to user-space */
19622 * The iretq could re-enable interrupts:
19623 */
19624 DISABLE_INTERRUPTS(CLBR_ANY)
19625 + pax_exit_kernel_user
19626 +retint_swapgs_pax:
19627 TRACE_IRQS_IRETQ
19628 SWAPGS
19629 jmp restore_args
19630
19631 retint_restore_args: /* return to kernel space */
19632 DISABLE_INTERRUPTS(CLBR_ANY)
19633 + pax_exit_kernel
19634 + pax_force_retaddr (RIP-ARGOFFSET)
19635 /*
19636 * The iretq could re-enable interrupts:
19637 */
19638 @@ -1129,7 +1453,7 @@ ENTRY(retint_kernel)
19639 #endif
19640
19641 CFI_ENDPROC
19642 -END(common_interrupt)
19643 +ENDPROC(common_interrupt)
19644 /*
19645 * End of kprobes section
19646 */
19647 @@ -1147,7 +1471,7 @@ ENTRY(\sym)
19648 interrupt \do_sym
19649 jmp ret_from_intr
19650 CFI_ENDPROC
19651 -END(\sym)
19652 +ENDPROC(\sym)
19653 .endm
19654
19655 #ifdef CONFIG_SMP
19656 @@ -1203,12 +1527,22 @@ ENTRY(\sym)
19657 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
19658 call error_entry
19659 DEFAULT_FRAME 0
19660 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19661 + testb $3, CS(%rsp)
19662 + jnz 1f
19663 + pax_enter_kernel
19664 + jmp 2f
19665 +1: pax_enter_kernel_user
19666 +2:
19667 +#else
19668 + pax_enter_kernel
19669 +#endif
19670 movq %rsp,%rdi /* pt_regs pointer */
19671 xorl %esi,%esi /* no error code */
19672 call \do_sym
19673 jmp error_exit /* %ebx: no swapgs flag */
19674 CFI_ENDPROC
19675 -END(\sym)
19676 +ENDPROC(\sym)
19677 .endm
19678
19679 .macro paranoidzeroentry sym do_sym
19680 @@ -1221,15 +1555,25 @@ ENTRY(\sym)
19681 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
19682 call save_paranoid
19683 TRACE_IRQS_OFF
19684 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19685 + testb $3, CS(%rsp)
19686 + jnz 1f
19687 + pax_enter_kernel
19688 + jmp 2f
19689 +1: pax_enter_kernel_user
19690 +2:
19691 +#else
19692 + pax_enter_kernel
19693 +#endif
19694 movq %rsp,%rdi /* pt_regs pointer */
19695 xorl %esi,%esi /* no error code */
19696 call \do_sym
19697 jmp paranoid_exit /* %ebx: no swapgs flag */
19698 CFI_ENDPROC
19699 -END(\sym)
19700 +ENDPROC(\sym)
19701 .endm
19702
19703 -#define INIT_TSS_IST(x) PER_CPU_VAR(init_tss) + (TSS_ist + ((x) - 1) * 8)
19704 +#define INIT_TSS_IST(x) (TSS_ist + ((x) - 1) * 8)(%r12)
19705 .macro paranoidzeroentry_ist sym do_sym ist
19706 ENTRY(\sym)
19707 INTR_FRAME
19708 @@ -1240,14 +1584,30 @@ ENTRY(\sym)
19709 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
19710 call save_paranoid
19711 TRACE_IRQS_OFF_DEBUG
19712 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19713 + testb $3, CS(%rsp)
19714 + jnz 1f
19715 + pax_enter_kernel
19716 + jmp 2f
19717 +1: pax_enter_kernel_user
19718 +2:
19719 +#else
19720 + pax_enter_kernel
19721 +#endif
19722 movq %rsp,%rdi /* pt_regs pointer */
19723 xorl %esi,%esi /* no error code */
19724 +#ifdef CONFIG_SMP
19725 + imul $TSS_size, PER_CPU_VAR(cpu_number), %r12d
19726 + lea init_tss(%r12), %r12
19727 +#else
19728 + lea init_tss(%rip), %r12
19729 +#endif
19730 subq $EXCEPTION_STKSZ, INIT_TSS_IST(\ist)
19731 call \do_sym
19732 addq $EXCEPTION_STKSZ, INIT_TSS_IST(\ist)
19733 jmp paranoid_exit /* %ebx: no swapgs flag */
19734 CFI_ENDPROC
19735 -END(\sym)
19736 +ENDPROC(\sym)
19737 .endm
19738
19739 .macro errorentry sym do_sym
19740 @@ -1259,13 +1619,23 @@ ENTRY(\sym)
19741 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
19742 call error_entry
19743 DEFAULT_FRAME 0
19744 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19745 + testb $3, CS(%rsp)
19746 + jnz 1f
19747 + pax_enter_kernel
19748 + jmp 2f
19749 +1: pax_enter_kernel_user
19750 +2:
19751 +#else
19752 + pax_enter_kernel
19753 +#endif
19754 movq %rsp,%rdi /* pt_regs pointer */
19755 movq ORIG_RAX(%rsp),%rsi /* get error code */
19756 movq $-1,ORIG_RAX(%rsp) /* no syscall to restart */
19757 call \do_sym
19758 jmp error_exit /* %ebx: no swapgs flag */
19759 CFI_ENDPROC
19760 -END(\sym)
19761 +ENDPROC(\sym)
19762 .endm
19763
19764 /* error code is on the stack already */
19765 @@ -1279,13 +1649,23 @@ ENTRY(\sym)
19766 call save_paranoid
19767 DEFAULT_FRAME 0
19768 TRACE_IRQS_OFF
19769 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19770 + testb $3, CS(%rsp)
19771 + jnz 1f
19772 + pax_enter_kernel
19773 + jmp 2f
19774 +1: pax_enter_kernel_user
19775 +2:
19776 +#else
19777 + pax_enter_kernel
19778 +#endif
19779 movq %rsp,%rdi /* pt_regs pointer */
19780 movq ORIG_RAX(%rsp),%rsi /* get error code */
19781 movq $-1,ORIG_RAX(%rsp) /* no syscall to restart */
19782 call \do_sym
19783 jmp paranoid_exit /* %ebx: no swapgs flag */
19784 CFI_ENDPROC
19785 -END(\sym)
19786 +ENDPROC(\sym)
19787 .endm
19788
19789 zeroentry divide_error do_divide_error
19790 @@ -1315,9 +1695,10 @@ gs_change:
19791 2: mfence /* workaround */
19792 SWAPGS
19793 popfq_cfi
19794 + pax_force_retaddr
19795 ret
19796 CFI_ENDPROC
19797 -END(native_load_gs_index)
19798 +ENDPROC(native_load_gs_index)
19799
19800 _ASM_EXTABLE(gs_change,bad_gs)
19801 .section .fixup,"ax"
19802 @@ -1345,9 +1726,10 @@ ENTRY(call_softirq)
19803 CFI_DEF_CFA_REGISTER rsp
19804 CFI_ADJUST_CFA_OFFSET -8
19805 decl PER_CPU_VAR(irq_count)
19806 + pax_force_retaddr
19807 ret
19808 CFI_ENDPROC
19809 -END(call_softirq)
19810 +ENDPROC(call_softirq)
19811
19812 #ifdef CONFIG_XEN
19813 zeroentry xen_hypervisor_callback xen_do_hypervisor_callback
19814 @@ -1385,7 +1767,7 @@ ENTRY(xen_do_hypervisor_callback) # do_hypervisor_callback(struct *pt_regs)
19815 decl PER_CPU_VAR(irq_count)
19816 jmp error_exit
19817 CFI_ENDPROC
19818 -END(xen_do_hypervisor_callback)
19819 +ENDPROC(xen_do_hypervisor_callback)
19820
19821 /*
19822 * Hypervisor uses this for application faults while it executes.
19823 @@ -1444,7 +1826,7 @@ ENTRY(xen_failsafe_callback)
19824 SAVE_ALL
19825 jmp error_exit
19826 CFI_ENDPROC
19827 -END(xen_failsafe_callback)
19828 +ENDPROC(xen_failsafe_callback)
19829
19830 apicinterrupt HYPERVISOR_CALLBACK_VECTOR \
19831 xen_hvm_callback_vector xen_evtchn_do_upcall
19832 @@ -1498,16 +1880,31 @@ ENTRY(paranoid_exit)
19833 TRACE_IRQS_OFF_DEBUG
19834 testl %ebx,%ebx /* swapgs needed? */
19835 jnz paranoid_restore
19836 - testl $3,CS(%rsp)
19837 + testb $3,CS(%rsp)
19838 jnz paranoid_userspace
19839 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19840 + pax_exit_kernel
19841 + TRACE_IRQS_IRETQ 0
19842 + SWAPGS_UNSAFE_STACK
19843 + RESTORE_ALL 8
19844 + pax_force_retaddr_bts
19845 + jmp irq_return
19846 +#endif
19847 paranoid_swapgs:
19848 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19849 + pax_exit_kernel_user
19850 +#else
19851 + pax_exit_kernel
19852 +#endif
19853 TRACE_IRQS_IRETQ 0
19854 SWAPGS_UNSAFE_STACK
19855 RESTORE_ALL 8
19856 jmp irq_return
19857 paranoid_restore:
19858 + pax_exit_kernel
19859 TRACE_IRQS_IRETQ_DEBUG 0
19860 RESTORE_ALL 8
19861 + pax_force_retaddr_bts
19862 jmp irq_return
19863 paranoid_userspace:
19864 GET_THREAD_INFO(%rcx)
19865 @@ -1536,7 +1933,7 @@ paranoid_schedule:
19866 TRACE_IRQS_OFF
19867 jmp paranoid_userspace
19868 CFI_ENDPROC
19869 -END(paranoid_exit)
19870 +ENDPROC(paranoid_exit)
19871
19872 /*
19873 * Exception entry point. This expects an error code/orig_rax on the stack.
19874 @@ -1563,12 +1960,13 @@ ENTRY(error_entry)
19875 movq_cfi r14, R14+8
19876 movq_cfi r15, R15+8
19877 xorl %ebx,%ebx
19878 - testl $3,CS+8(%rsp)
19879 + testb $3,CS+8(%rsp)
19880 je error_kernelspace
19881 error_swapgs:
19882 SWAPGS
19883 error_sti:
19884 TRACE_IRQS_OFF
19885 + pax_force_retaddr_bts
19886 ret
19887
19888 /*
19889 @@ -1595,7 +1993,7 @@ bstep_iret:
19890 movq %rcx,RIP+8(%rsp)
19891 jmp error_swapgs
19892 CFI_ENDPROC
19893 -END(error_entry)
19894 +ENDPROC(error_entry)
19895
19896
19897 /* ebx: no swapgs flag (1: don't need swapgs, 0: need it) */
19898 @@ -1615,7 +2013,7 @@ ENTRY(error_exit)
19899 jnz retint_careful
19900 jmp retint_swapgs
19901 CFI_ENDPROC
19902 -END(error_exit)
19903 +ENDPROC(error_exit)
19904
19905 /*
19906 * Test if a given stack is an NMI stack or not.
19907 @@ -1673,9 +2071,11 @@ ENTRY(nmi)
19908 * If %cs was not the kernel segment, then the NMI triggered in user
19909 * space, which means it is definitely not nested.
19910 */
19911 + cmpl $__KERNEXEC_KERNEL_CS, 16(%rsp)
19912 + je 1f
19913 cmpl $__KERNEL_CS, 16(%rsp)
19914 jne first_nmi
19915 -
19916 +1:
19917 /*
19918 * Check the special variable on the stack to see if NMIs are
19919 * executing.
19920 @@ -1709,8 +2109,7 @@ nested_nmi:
19921
19922 1:
19923 /* Set up the interrupted NMIs stack to jump to repeat_nmi */
19924 - leaq -1*8(%rsp), %rdx
19925 - movq %rdx, %rsp
19926 + subq $8, %rsp
19927 CFI_ADJUST_CFA_OFFSET 1*8
19928 leaq -10*8(%rsp), %rdx
19929 pushq_cfi $__KERNEL_DS
19930 @@ -1728,6 +2127,7 @@ nested_nmi_out:
19931 CFI_RESTORE rdx
19932
19933 /* No need to check faults here */
19934 + pax_force_retaddr_bts
19935 INTERRUPT_RETURN
19936
19937 CFI_RESTORE_STATE
19938 @@ -1844,6 +2244,17 @@ end_repeat_nmi:
19939 */
19940 movq %cr2, %r12
19941
19942 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19943 + testb $3, CS(%rsp)
19944 + jnz 1f
19945 + pax_enter_kernel
19946 + jmp 2f
19947 +1: pax_enter_kernel_user
19948 +2:
19949 +#else
19950 + pax_enter_kernel
19951 +#endif
19952 +
19953 /* paranoidentry do_nmi, 0; without TRACE_IRQS_OFF */
19954 movq %rsp,%rdi
19955 movq $-1,%rsi
19956 @@ -1859,23 +2270,34 @@ end_repeat_nmi:
19957 testl %ebx,%ebx /* swapgs needed? */
19958 jnz nmi_restore
19959 nmi_swapgs:
19960 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19961 + pax_exit_kernel_user
19962 +#else
19963 + pax_exit_kernel
19964 +#endif
19965 SWAPGS_UNSAFE_STACK
19966 + RESTORE_ALL 6*8
19967 + /* Clear the NMI executing stack variable */
19968 + movq $0, 5*8(%rsp)
19969 + jmp irq_return
19970 nmi_restore:
19971 + pax_exit_kernel
19972 /* Pop the extra iret frame at once */
19973 RESTORE_ALL 6*8
19974 + pax_force_retaddr_bts
19975
19976 /* Clear the NMI executing stack variable */
19977 movq $0, 5*8(%rsp)
19978 jmp irq_return
19979 CFI_ENDPROC
19980 -END(nmi)
19981 +ENDPROC(nmi)
19982
19983 ENTRY(ignore_sysret)
19984 CFI_STARTPROC
19985 mov $-ENOSYS,%eax
19986 sysret
19987 CFI_ENDPROC
19988 -END(ignore_sysret)
19989 +ENDPROC(ignore_sysret)
19990
19991 /*
19992 * End of kprobes section
19993 diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c
19994 index 42a392a..fbbd930 100644
19995 --- a/arch/x86/kernel/ftrace.c
19996 +++ b/arch/x86/kernel/ftrace.c
19997 @@ -105,6 +105,8 @@ ftrace_modify_code_direct(unsigned long ip, unsigned const char *old_code,
19998 {
19999 unsigned char replaced[MCOUNT_INSN_SIZE];
20000
20001 + ip = ktla_ktva(ip);
20002 +
20003 /*
20004 * Note: Due to modules and __init, code can
20005 * disappear and change, we need to protect against faulting
20006 @@ -227,7 +229,7 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
20007 unsigned char old[MCOUNT_INSN_SIZE], *new;
20008 int ret;
20009
20010 - memcpy(old, &ftrace_call, MCOUNT_INSN_SIZE);
20011 + memcpy(old, (void *)ktla_ktva((unsigned long)ftrace_call), MCOUNT_INSN_SIZE);
20012 new = ftrace_call_replace(ip, (unsigned long)func);
20013
20014 /* See comment above by declaration of modifying_ftrace_code */
20015 @@ -238,7 +240,7 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
20016 /* Also update the regs callback function */
20017 if (!ret) {
20018 ip = (unsigned long)(&ftrace_regs_call);
20019 - memcpy(old, &ftrace_regs_call, MCOUNT_INSN_SIZE);
20020 + memcpy(old, ktla_ktva((void *)&ftrace_regs_call), MCOUNT_INSN_SIZE);
20021 new = ftrace_call_replace(ip, (unsigned long)func);
20022 ret = ftrace_modify_code(ip, old, new);
20023 }
20024 @@ -279,7 +281,7 @@ static int ftrace_write(unsigned long ip, const char *val, int size)
20025 * kernel identity mapping to modify code.
20026 */
20027 if (within(ip, (unsigned long)_text, (unsigned long)_etext))
20028 - ip = (unsigned long)__va(__pa_symbol(ip));
20029 + ip = (unsigned long)__va(__pa_symbol(ktla_ktva(ip)));
20030
20031 return probe_kernel_write((void *)ip, val, size);
20032 }
20033 @@ -289,7 +291,7 @@ static int add_break(unsigned long ip, const char *old)
20034 unsigned char replaced[MCOUNT_INSN_SIZE];
20035 unsigned char brk = BREAKPOINT_INSTRUCTION;
20036
20037 - if (probe_kernel_read(replaced, (void *)ip, MCOUNT_INSN_SIZE))
20038 + if (probe_kernel_read(replaced, (void *)ktla_ktva(ip), MCOUNT_INSN_SIZE))
20039 return -EFAULT;
20040
20041 /* Make sure it is what we expect it to be */
20042 @@ -637,7 +639,7 @@ ftrace_modify_code(unsigned long ip, unsigned const char *old_code,
20043 return ret;
20044
20045 fail_update:
20046 - probe_kernel_write((void *)ip, &old_code[0], 1);
20047 + probe_kernel_write((void *)ktla_ktva(ip), &old_code[0], 1);
20048 goto out;
20049 }
20050
20051 @@ -670,6 +672,8 @@ static int ftrace_mod_jmp(unsigned long ip,
20052 {
20053 unsigned char code[MCOUNT_INSN_SIZE];
20054
20055 + ip = ktla_ktva(ip);
20056 +
20057 if (probe_kernel_read(code, (void *)ip, MCOUNT_INSN_SIZE))
20058 return -EFAULT;
20059
20060 diff --git a/arch/x86/kernel/head64.c b/arch/x86/kernel/head64.c
20061 index 8f3201d..aa860bf 100644
20062 --- a/arch/x86/kernel/head64.c
20063 +++ b/arch/x86/kernel/head64.c
20064 @@ -175,7 +175,6 @@ void __init x86_64_start_kernel(char * real_mode_data)
20065 if (console_loglevel == 10)
20066 early_printk("Kernel alive\n");
20067
20068 - clear_page(init_level4_pgt);
20069 /* set init_level4_pgt kernel high mapping*/
20070 init_level4_pgt[511] = early_level4_pgt[511];
20071
20072 diff --git a/arch/x86/kernel/head_32.S b/arch/x86/kernel/head_32.S
20073 index 73afd11..d1670f5 100644
20074 --- a/arch/x86/kernel/head_32.S
20075 +++ b/arch/x86/kernel/head_32.S
20076 @@ -26,6 +26,12 @@
20077 /* Physical address */
20078 #define pa(X) ((X) - __PAGE_OFFSET)
20079
20080 +#ifdef CONFIG_PAX_KERNEXEC
20081 +#define ta(X) (X)
20082 +#else
20083 +#define ta(X) ((X) - __PAGE_OFFSET)
20084 +#endif
20085 +
20086 /*
20087 * References to members of the new_cpu_data structure.
20088 */
20089 @@ -55,11 +61,7 @@
20090 * and small than max_low_pfn, otherwise will waste some page table entries
20091 */
20092
20093 -#if PTRS_PER_PMD > 1
20094 -#define PAGE_TABLE_SIZE(pages) (((pages) / PTRS_PER_PMD) + PTRS_PER_PGD)
20095 -#else
20096 -#define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PGD)
20097 -#endif
20098 +#define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PTE)
20099
20100 /* Number of possible pages in the lowmem region */
20101 LOWMEM_PAGES = (((1<<32) - __PAGE_OFFSET) >> PAGE_SHIFT)
20102 @@ -78,6 +80,12 @@ INIT_MAP_SIZE = PAGE_TABLE_SIZE(KERNEL_PAGES) * PAGE_SIZE
20103 RESERVE_BRK(pagetables, INIT_MAP_SIZE)
20104
20105 /*
20106 + * Real beginning of normal "text" segment
20107 + */
20108 +ENTRY(stext)
20109 +ENTRY(_stext)
20110 +
20111 +/*
20112 * 32-bit kernel entrypoint; only used by the boot CPU. On entry,
20113 * %esi points to the real-mode code as a 32-bit pointer.
20114 * CS and DS must be 4 GB flat segments, but we don't depend on
20115 @@ -85,6 +93,13 @@ RESERVE_BRK(pagetables, INIT_MAP_SIZE)
20116 * can.
20117 */
20118 __HEAD
20119 +
20120 +#ifdef CONFIG_PAX_KERNEXEC
20121 + jmp startup_32
20122 +/* PaX: fill first page in .text with int3 to catch NULL derefs in kernel mode */
20123 +.fill PAGE_SIZE-5,1,0xcc
20124 +#endif
20125 +
20126 ENTRY(startup_32)
20127 movl pa(stack_start),%ecx
20128
20129 @@ -106,6 +121,59 @@ ENTRY(startup_32)
20130 2:
20131 leal -__PAGE_OFFSET(%ecx),%esp
20132
20133 +#ifdef CONFIG_SMP
20134 + movl $pa(cpu_gdt_table),%edi
20135 + movl $__per_cpu_load,%eax
20136 + movw %ax,GDT_ENTRY_PERCPU * 8 + 2(%edi)
20137 + rorl $16,%eax
20138 + movb %al,GDT_ENTRY_PERCPU * 8 + 4(%edi)
20139 + movb %ah,GDT_ENTRY_PERCPU * 8 + 7(%edi)
20140 + movl $__per_cpu_end - 1,%eax
20141 + subl $__per_cpu_start,%eax
20142 + movw %ax,GDT_ENTRY_PERCPU * 8 + 0(%edi)
20143 +#endif
20144 +
20145 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20146 + movl $NR_CPUS,%ecx
20147 + movl $pa(cpu_gdt_table),%edi
20148 +1:
20149 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c09700),GDT_ENTRY_KERNEL_DS * 8 + 4(%edi)
20150 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c0fb00),GDT_ENTRY_DEFAULT_USER_CS * 8 + 4(%edi)
20151 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c0f300),GDT_ENTRY_DEFAULT_USER_DS * 8 + 4(%edi)
20152 + addl $PAGE_SIZE_asm,%edi
20153 + loop 1b
20154 +#endif
20155 +
20156 +#ifdef CONFIG_PAX_KERNEXEC
20157 + movl $pa(boot_gdt),%edi
20158 + movl $__LOAD_PHYSICAL_ADDR,%eax
20159 + movw %ax,GDT_ENTRY_BOOT_CS * 8 + 2(%edi)
20160 + rorl $16,%eax
20161 + movb %al,GDT_ENTRY_BOOT_CS * 8 + 4(%edi)
20162 + movb %ah,GDT_ENTRY_BOOT_CS * 8 + 7(%edi)
20163 + rorl $16,%eax
20164 +
20165 + ljmp $(__BOOT_CS),$1f
20166 +1:
20167 +
20168 + movl $NR_CPUS,%ecx
20169 + movl $pa(cpu_gdt_table),%edi
20170 + addl $__PAGE_OFFSET,%eax
20171 +1:
20172 + movb $0xc0,GDT_ENTRY_KERNEL_CS * 8 + 6(%edi)
20173 + movb $0xc0,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 6(%edi)
20174 + movw %ax,GDT_ENTRY_KERNEL_CS * 8 + 2(%edi)
20175 + movw %ax,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 2(%edi)
20176 + rorl $16,%eax
20177 + movb %al,GDT_ENTRY_KERNEL_CS * 8 + 4(%edi)
20178 + movb %al,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 4(%edi)
20179 + movb %ah,GDT_ENTRY_KERNEL_CS * 8 + 7(%edi)
20180 + movb %ah,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 7(%edi)
20181 + rorl $16,%eax
20182 + addl $PAGE_SIZE_asm,%edi
20183 + loop 1b
20184 +#endif
20185 +
20186 /*
20187 * Clear BSS first so that there are no surprises...
20188 */
20189 @@ -201,8 +269,11 @@ ENTRY(startup_32)
20190 movl %eax, pa(max_pfn_mapped)
20191
20192 /* Do early initialization of the fixmap area */
20193 - movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,%eax
20194 - movl %eax,pa(initial_pg_pmd+0x1000*KPMDS-8)
20195 +#ifdef CONFIG_COMPAT_VDSO
20196 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR+_PAGE_USER,pa(initial_pg_pmd+0x1000*KPMDS-8)
20197 +#else
20198 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,pa(initial_pg_pmd+0x1000*KPMDS-8)
20199 +#endif
20200 #else /* Not PAE */
20201
20202 page_pde_offset = (__PAGE_OFFSET >> 20);
20203 @@ -232,8 +303,11 @@ page_pde_offset = (__PAGE_OFFSET >> 20);
20204 movl %eax, pa(max_pfn_mapped)
20205
20206 /* Do early initialization of the fixmap area */
20207 - movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,%eax
20208 - movl %eax,pa(initial_page_table+0xffc)
20209 +#ifdef CONFIG_COMPAT_VDSO
20210 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR+_PAGE_USER,pa(initial_page_table+0xffc)
20211 +#else
20212 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,pa(initial_page_table+0xffc)
20213 +#endif
20214 #endif
20215
20216 #ifdef CONFIG_PARAVIRT
20217 @@ -247,9 +321,7 @@ page_pde_offset = (__PAGE_OFFSET >> 20);
20218 cmpl $num_subarch_entries, %eax
20219 jae bad_subarch
20220
20221 - movl pa(subarch_entries)(,%eax,4), %eax
20222 - subl $__PAGE_OFFSET, %eax
20223 - jmp *%eax
20224 + jmp *pa(subarch_entries)(,%eax,4)
20225
20226 bad_subarch:
20227 WEAK(lguest_entry)
20228 @@ -261,10 +333,10 @@ WEAK(xen_entry)
20229 __INITDATA
20230
20231 subarch_entries:
20232 - .long default_entry /* normal x86/PC */
20233 - .long lguest_entry /* lguest hypervisor */
20234 - .long xen_entry /* Xen hypervisor */
20235 - .long default_entry /* Moorestown MID */
20236 + .long ta(default_entry) /* normal x86/PC */
20237 + .long ta(lguest_entry) /* lguest hypervisor */
20238 + .long ta(xen_entry) /* Xen hypervisor */
20239 + .long ta(default_entry) /* Moorestown MID */
20240 num_subarch_entries = (. - subarch_entries) / 4
20241 .previous
20242 #else
20243 @@ -355,6 +427,7 @@ default_entry:
20244 movl pa(mmu_cr4_features),%eax
20245 movl %eax,%cr4
20246
20247 +#ifdef CONFIG_X86_PAE
20248 testb $X86_CR4_PAE, %al # check if PAE is enabled
20249 jz enable_paging
20250
20251 @@ -383,6 +456,9 @@ default_entry:
20252 /* Make changes effective */
20253 wrmsr
20254
20255 + btsl $_PAGE_BIT_NX-32,pa(__supported_pte_mask+4)
20256 +#endif
20257 +
20258 enable_paging:
20259
20260 /*
20261 @@ -451,14 +527,20 @@ is486:
20262 1: movl $(__KERNEL_DS),%eax # reload all the segment registers
20263 movl %eax,%ss # after changing gdt.
20264
20265 - movl $(__USER_DS),%eax # DS/ES contains default USER segment
20266 +# movl $(__KERNEL_DS),%eax # DS/ES contains default KERNEL segment
20267 movl %eax,%ds
20268 movl %eax,%es
20269
20270 movl $(__KERNEL_PERCPU), %eax
20271 movl %eax,%fs # set this cpu's percpu
20272
20273 +#ifdef CONFIG_CC_STACKPROTECTOR
20274 movl $(__KERNEL_STACK_CANARY),%eax
20275 +#elif defined(CONFIG_PAX_MEMORY_UDEREF)
20276 + movl $(__USER_DS),%eax
20277 +#else
20278 + xorl %eax,%eax
20279 +#endif
20280 movl %eax,%gs
20281
20282 xorl %eax,%eax # Clear LDT
20283 @@ -534,8 +616,11 @@ setup_once:
20284 * relocation. Manually set base address in stack canary
20285 * segment descriptor.
20286 */
20287 - movl $gdt_page,%eax
20288 + movl $cpu_gdt_table,%eax
20289 movl $stack_canary,%ecx
20290 +#ifdef CONFIG_SMP
20291 + addl $__per_cpu_load,%ecx
20292 +#endif
20293 movw %cx, 8 * GDT_ENTRY_STACK_CANARY + 2(%eax)
20294 shrl $16, %ecx
20295 movb %cl, 8 * GDT_ENTRY_STACK_CANARY + 4(%eax)
20296 @@ -566,7 +651,7 @@ ENDPROC(early_idt_handlers)
20297 /* This is global to keep gas from relaxing the jumps */
20298 ENTRY(early_idt_handler)
20299 cld
20300 - cmpl $2,%ss:early_recursion_flag
20301 + cmpl $1,%ss:early_recursion_flag
20302 je hlt_loop
20303 incl %ss:early_recursion_flag
20304
20305 @@ -604,8 +689,8 @@ ENTRY(early_idt_handler)
20306 pushl (20+6*4)(%esp) /* trapno */
20307 pushl $fault_msg
20308 call printk
20309 -#endif
20310 call dump_stack
20311 +#endif
20312 hlt_loop:
20313 hlt
20314 jmp hlt_loop
20315 @@ -624,8 +709,11 @@ ENDPROC(early_idt_handler)
20316 /* This is the default interrupt "handler" :-) */
20317 ALIGN
20318 ignore_int:
20319 - cld
20320 #ifdef CONFIG_PRINTK
20321 + cmpl $2,%ss:early_recursion_flag
20322 + je hlt_loop
20323 + incl %ss:early_recursion_flag
20324 + cld
20325 pushl %eax
20326 pushl %ecx
20327 pushl %edx
20328 @@ -634,9 +722,6 @@ ignore_int:
20329 movl $(__KERNEL_DS),%eax
20330 movl %eax,%ds
20331 movl %eax,%es
20332 - cmpl $2,early_recursion_flag
20333 - je hlt_loop
20334 - incl early_recursion_flag
20335 pushl 16(%esp)
20336 pushl 24(%esp)
20337 pushl 32(%esp)
20338 @@ -670,29 +755,43 @@ ENTRY(setup_once_ref)
20339 /*
20340 * BSS section
20341 */
20342 -__PAGE_ALIGNED_BSS
20343 - .align PAGE_SIZE
20344 #ifdef CONFIG_X86_PAE
20345 +.section .initial_pg_pmd,"a",@progbits
20346 initial_pg_pmd:
20347 .fill 1024*KPMDS,4,0
20348 #else
20349 +.section .initial_page_table,"a",@progbits
20350 ENTRY(initial_page_table)
20351 .fill 1024,4,0
20352 #endif
20353 +.section .initial_pg_fixmap,"a",@progbits
20354 initial_pg_fixmap:
20355 .fill 1024,4,0
20356 +.section .empty_zero_page,"a",@progbits
20357 ENTRY(empty_zero_page)
20358 .fill 4096,1,0
20359 +.section .swapper_pg_dir,"a",@progbits
20360 ENTRY(swapper_pg_dir)
20361 +#ifdef CONFIG_X86_PAE
20362 + .fill 4,8,0
20363 +#else
20364 .fill 1024,4,0
20365 +#endif
20366 +
20367 +/*
20368 + * The IDT has to be page-aligned to simplify the Pentium
20369 + * F0 0F bug workaround.. We have a special link segment
20370 + * for this.
20371 + */
20372 +.section .idt,"a",@progbits
20373 +ENTRY(idt_table)
20374 + .fill 256,8,0
20375
20376 /*
20377 * This starts the data section.
20378 */
20379 #ifdef CONFIG_X86_PAE
20380 -__PAGE_ALIGNED_DATA
20381 - /* Page-aligned for the benefit of paravirt? */
20382 - .align PAGE_SIZE
20383 +.section .initial_page_table,"a",@progbits
20384 ENTRY(initial_page_table)
20385 .long pa(initial_pg_pmd+PGD_IDENT_ATTR),0 /* low identity map */
20386 # if KPMDS == 3
20387 @@ -711,12 +810,20 @@ ENTRY(initial_page_table)
20388 # error "Kernel PMDs should be 1, 2 or 3"
20389 # endif
20390 .align PAGE_SIZE /* needs to be page-sized too */
20391 +
20392 +#ifdef CONFIG_PAX_PER_CPU_PGD
20393 +ENTRY(cpu_pgd)
20394 + .rept NR_CPUS
20395 + .fill 4,8,0
20396 + .endr
20397 +#endif
20398 +
20399 #endif
20400
20401 .data
20402 .balign 4
20403 ENTRY(stack_start)
20404 - .long init_thread_union+THREAD_SIZE
20405 + .long init_thread_union+THREAD_SIZE-8
20406
20407 __INITRODATA
20408 int_msg:
20409 @@ -744,7 +851,7 @@ fault_msg:
20410 * segment size, and 32-bit linear address value:
20411 */
20412
20413 - .data
20414 +.section .rodata,"a",@progbits
20415 .globl boot_gdt_descr
20416 .globl idt_descr
20417
20418 @@ -753,7 +860,7 @@ fault_msg:
20419 .word 0 # 32 bit align gdt_desc.address
20420 boot_gdt_descr:
20421 .word __BOOT_DS+7
20422 - .long boot_gdt - __PAGE_OFFSET
20423 + .long pa(boot_gdt)
20424
20425 .word 0 # 32-bit align idt_desc.address
20426 idt_descr:
20427 @@ -764,7 +871,7 @@ idt_descr:
20428 .word 0 # 32 bit align gdt_desc.address
20429 ENTRY(early_gdt_descr)
20430 .word GDT_ENTRIES*8-1
20431 - .long gdt_page /* Overwritten for secondary CPUs */
20432 + .long cpu_gdt_table /* Overwritten for secondary CPUs */
20433
20434 /*
20435 * The boot_gdt must mirror the equivalent in setup.S and is
20436 @@ -773,5 +880,65 @@ ENTRY(early_gdt_descr)
20437 .align L1_CACHE_BYTES
20438 ENTRY(boot_gdt)
20439 .fill GDT_ENTRY_BOOT_CS,8,0
20440 - .quad 0x00cf9a000000ffff /* kernel 4GB code at 0x00000000 */
20441 - .quad 0x00cf92000000ffff /* kernel 4GB data at 0x00000000 */
20442 + .quad 0x00cf9b000000ffff /* kernel 4GB code at 0x00000000 */
20443 + .quad 0x00cf93000000ffff /* kernel 4GB data at 0x00000000 */
20444 +
20445 + .align PAGE_SIZE_asm
20446 +ENTRY(cpu_gdt_table)
20447 + .rept NR_CPUS
20448 + .quad 0x0000000000000000 /* NULL descriptor */
20449 + .quad 0x0000000000000000 /* 0x0b reserved */
20450 + .quad 0x0000000000000000 /* 0x13 reserved */
20451 + .quad 0x0000000000000000 /* 0x1b reserved */
20452 +
20453 +#ifdef CONFIG_PAX_KERNEXEC
20454 + .quad 0x00cf9b000000ffff /* 0x20 alternate kernel 4GB code at 0x00000000 */
20455 +#else
20456 + .quad 0x0000000000000000 /* 0x20 unused */
20457 +#endif
20458 +
20459 + .quad 0x0000000000000000 /* 0x28 unused */
20460 + .quad 0x0000000000000000 /* 0x33 TLS entry 1 */
20461 + .quad 0x0000000000000000 /* 0x3b TLS entry 2 */
20462 + .quad 0x0000000000000000 /* 0x43 TLS entry 3 */
20463 + .quad 0x0000000000000000 /* 0x4b reserved */
20464 + .quad 0x0000000000000000 /* 0x53 reserved */
20465 + .quad 0x0000000000000000 /* 0x5b reserved */
20466 +
20467 + .quad 0x00cf9b000000ffff /* 0x60 kernel 4GB code at 0x00000000 */
20468 + .quad 0x00cf93000000ffff /* 0x68 kernel 4GB data at 0x00000000 */
20469 + .quad 0x00cffb000000ffff /* 0x73 user 4GB code at 0x00000000 */
20470 + .quad 0x00cff3000000ffff /* 0x7b user 4GB data at 0x00000000 */
20471 +
20472 + .quad 0x0000000000000000 /* 0x80 TSS descriptor */
20473 + .quad 0x0000000000000000 /* 0x88 LDT descriptor */
20474 +
20475 + /*
20476 + * Segments used for calling PnP BIOS have byte granularity.
20477 + * The code segments and data segments have fixed 64k limits,
20478 + * the transfer segment sizes are set at run time.
20479 + */
20480 + .quad 0x00409b000000ffff /* 0x90 32-bit code */
20481 + .quad 0x00009b000000ffff /* 0x98 16-bit code */
20482 + .quad 0x000093000000ffff /* 0xa0 16-bit data */
20483 + .quad 0x0000930000000000 /* 0xa8 16-bit data */
20484 + .quad 0x0000930000000000 /* 0xb0 16-bit data */
20485 +
20486 + /*
20487 + * The APM segments have byte granularity and their bases
20488 + * are set at run time. All have 64k limits.
20489 + */
20490 + .quad 0x00409b000000ffff /* 0xb8 APM CS code */
20491 + .quad 0x00009b000000ffff /* 0xc0 APM CS 16 code (16 bit) */
20492 + .quad 0x004093000000ffff /* 0xc8 APM DS data */
20493 +
20494 + .quad 0x00c0930000000000 /* 0xd0 - ESPFIX SS */
20495 + .quad 0x0040930000000000 /* 0xd8 - PERCPU */
20496 + .quad 0x0040910000000017 /* 0xe0 - STACK_CANARY */
20497 + .quad 0x0000000000000000 /* 0xe8 - PCIBIOS_CS */
20498 + .quad 0x0000000000000000 /* 0xf0 - PCIBIOS_DS */
20499 + .quad 0x0000000000000000 /* 0xf8 - GDT entry 31: double-fault TSS */
20500 +
20501 + /* Be sure this is zeroed to avoid false validations in Xen */
20502 + .fill PAGE_SIZE_asm - GDT_SIZE,1,0
20503 + .endr
20504 diff --git a/arch/x86/kernel/head_64.S b/arch/x86/kernel/head_64.S
20505 index 321d65e..e9437f7 100644
20506 --- a/arch/x86/kernel/head_64.S
20507 +++ b/arch/x86/kernel/head_64.S
20508 @@ -20,6 +20,8 @@
20509 #include <asm/processor-flags.h>
20510 #include <asm/percpu.h>
20511 #include <asm/nops.h>
20512 +#include <asm/cpufeature.h>
20513 +#include <asm/alternative-asm.h>
20514
20515 #ifdef CONFIG_PARAVIRT
20516 #include <asm/asm-offsets.h>
20517 @@ -41,6 +43,12 @@ L4_PAGE_OFFSET = pgd_index(__PAGE_OFFSET)
20518 L3_PAGE_OFFSET = pud_index(__PAGE_OFFSET)
20519 L4_START_KERNEL = pgd_index(__START_KERNEL_map)
20520 L3_START_KERNEL = pud_index(__START_KERNEL_map)
20521 +L4_VMALLOC_START = pgd_index(VMALLOC_START)
20522 +L3_VMALLOC_START = pud_index(VMALLOC_START)
20523 +L4_VMALLOC_END = pgd_index(VMALLOC_END)
20524 +L3_VMALLOC_END = pud_index(VMALLOC_END)
20525 +L4_VMEMMAP_START = pgd_index(VMEMMAP_START)
20526 +L3_VMEMMAP_START = pud_index(VMEMMAP_START)
20527
20528 .text
20529 __HEAD
20530 @@ -89,11 +97,15 @@ startup_64:
20531 * Fixup the physical addresses in the page table
20532 */
20533 addq %rbp, early_level4_pgt + (L4_START_KERNEL*8)(%rip)
20534 + addq %rbp, init_level4_pgt + (L4_VMALLOC_START*8)(%rip)
20535 + addq %rbp, init_level4_pgt + (L4_VMALLOC_END*8)(%rip)
20536 + addq %rbp, init_level4_pgt + (L4_VMEMMAP_START*8)(%rip)
20537
20538 addq %rbp, level3_kernel_pgt + (510*8)(%rip)
20539 addq %rbp, level3_kernel_pgt + (511*8)(%rip)
20540
20541 addq %rbp, level2_fixmap_pgt + (506*8)(%rip)
20542 + addq %rbp, level2_fixmap_pgt + (507*8)(%rip)
20543
20544 /*
20545 * Set up the identity mapping for the switchover. These
20546 @@ -177,8 +189,8 @@ ENTRY(secondary_startup_64)
20547 movq $(init_level4_pgt - __START_KERNEL_map), %rax
20548 1:
20549
20550 - /* Enable PAE mode and PGE */
20551 - movl $(X86_CR4_PAE | X86_CR4_PGE), %ecx
20552 + /* Enable PAE mode and PSE/PGE */
20553 + movl $(X86_CR4_PSE | X86_CR4_PAE | X86_CR4_PGE), %ecx
20554 movq %rcx, %cr4
20555
20556 /* Setup early boot stage 4 level pagetables. */
20557 @@ -199,10 +211,18 @@ ENTRY(secondary_startup_64)
20558 movl $MSR_EFER, %ecx
20559 rdmsr
20560 btsl $_EFER_SCE, %eax /* Enable System Call */
20561 - btl $20,%edi /* No Execute supported? */
20562 + btl $(X86_FEATURE_NX & 31),%edi /* No Execute supported? */
20563 jnc 1f
20564 btsl $_EFER_NX, %eax
20565 btsq $_PAGE_BIT_NX,early_pmd_flags(%rip)
20566 + leaq init_level4_pgt(%rip), %rdi
20567 +#ifndef CONFIG_EFI
20568 + btsq $_PAGE_BIT_NX, 8*L4_PAGE_OFFSET(%rdi)
20569 +#endif
20570 + btsq $_PAGE_BIT_NX, 8*L4_VMALLOC_START(%rdi)
20571 + btsq $_PAGE_BIT_NX, 8*L4_VMALLOC_END(%rdi)
20572 + btsq $_PAGE_BIT_NX, 8*L4_VMEMMAP_START(%rdi)
20573 + btsq $_PAGE_BIT_NX, __supported_pte_mask(%rip)
20574 1: wrmsr /* Make changes effective */
20575
20576 /* Setup cr0 */
20577 @@ -282,6 +302,7 @@ ENTRY(secondary_startup_64)
20578 * REX.W + FF /5 JMP m16:64 Jump far, absolute indirect,
20579 * address given in m16:64.
20580 */
20581 + pax_set_fptr_mask
20582 movq initial_code(%rip),%rax
20583 pushq $0 # fake return address to stop unwinder
20584 pushq $__KERNEL_CS # set correct cs
20585 @@ -388,7 +409,7 @@ ENTRY(early_idt_handler)
20586 call dump_stack
20587 #ifdef CONFIG_KALLSYMS
20588 leaq early_idt_ripmsg(%rip),%rdi
20589 - movq 40(%rsp),%rsi # %rip again
20590 + movq 88(%rsp),%rsi # %rip again
20591 call __print_symbol
20592 #endif
20593 #endif /* EARLY_PRINTK */
20594 @@ -416,6 +437,7 @@ ENDPROC(early_idt_handler)
20595 early_recursion_flag:
20596 .long 0
20597
20598 + .section .rodata,"a",@progbits
20599 #ifdef CONFIG_EARLY_PRINTK
20600 early_idt_msg:
20601 .asciz "PANIC: early exception %02lx rip %lx:%lx error %lx cr2 %lx\n"
20602 @@ -445,27 +467,50 @@ NEXT_PAGE(early_dynamic_pgts)
20603
20604 .data
20605
20606 -#ifndef CONFIG_XEN
20607 NEXT_PAGE(init_level4_pgt)
20608 - .fill 512,8,0
20609 -#else
20610 -NEXT_PAGE(init_level4_pgt)
20611 - .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
20612 .org init_level4_pgt + L4_PAGE_OFFSET*8, 0
20613 .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
20614 + .org init_level4_pgt + L4_VMALLOC_START*8, 0
20615 + .quad level3_vmalloc_start_pgt - __START_KERNEL_map + _KERNPG_TABLE
20616 + .org init_level4_pgt + L4_VMALLOC_END*8, 0
20617 + .quad level3_vmalloc_end_pgt - __START_KERNEL_map + _KERNPG_TABLE
20618 + .org init_level4_pgt + L4_VMEMMAP_START*8, 0
20619 + .quad level3_vmemmap_pgt - __START_KERNEL_map + _KERNPG_TABLE
20620 .org init_level4_pgt + L4_START_KERNEL*8, 0
20621 /* (2^48-(2*1024*1024*1024))/(2^39) = 511 */
20622 .quad level3_kernel_pgt - __START_KERNEL_map + _PAGE_TABLE
20623
20624 +#ifdef CONFIG_PAX_PER_CPU_PGD
20625 +NEXT_PAGE(cpu_pgd)
20626 + .rept NR_CPUS
20627 + .fill 512,8,0
20628 + .endr
20629 +#endif
20630 +
20631 NEXT_PAGE(level3_ident_pgt)
20632 .quad level2_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
20633 +#ifdef CONFIG_XEN
20634 .fill 511, 8, 0
20635 +#else
20636 + .quad level2_ident_pgt + PAGE_SIZE - __START_KERNEL_map + _KERNPG_TABLE
20637 + .fill 510,8,0
20638 +#endif
20639 +
20640 +NEXT_PAGE(level3_vmalloc_start_pgt)
20641 + .fill 512,8,0
20642 +
20643 +NEXT_PAGE(level3_vmalloc_end_pgt)
20644 + .fill 512,8,0
20645 +
20646 +NEXT_PAGE(level3_vmemmap_pgt)
20647 + .fill L3_VMEMMAP_START,8,0
20648 + .quad level2_vmemmap_pgt - __START_KERNEL_map + _KERNPG_TABLE
20649 +
20650 NEXT_PAGE(level2_ident_pgt)
20651 - /* Since I easily can, map the first 1G.
20652 + /* Since I easily can, map the first 2G.
20653 * Don't set NX because code runs from these pages.
20654 */
20655 - PMDS(0, __PAGE_KERNEL_IDENT_LARGE_EXEC, PTRS_PER_PMD)
20656 -#endif
20657 + PMDS(0, __PAGE_KERNEL_IDENT_LARGE_EXEC, 2*PTRS_PER_PMD)
20658
20659 NEXT_PAGE(level3_kernel_pgt)
20660 .fill L3_START_KERNEL,8,0
20661 @@ -473,6 +518,9 @@ NEXT_PAGE(level3_kernel_pgt)
20662 .quad level2_kernel_pgt - __START_KERNEL_map + _KERNPG_TABLE
20663 .quad level2_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE
20664
20665 +NEXT_PAGE(level2_vmemmap_pgt)
20666 + .fill 512,8,0
20667 +
20668 NEXT_PAGE(level2_kernel_pgt)
20669 /*
20670 * 512 MB kernel mapping. We spend a full page on this pagetable
20671 @@ -488,38 +536,64 @@ NEXT_PAGE(level2_kernel_pgt)
20672 KERNEL_IMAGE_SIZE/PMD_SIZE)
20673
20674 NEXT_PAGE(level2_fixmap_pgt)
20675 - .fill 506,8,0
20676 - .quad level1_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE
20677 - /* 8MB reserved for vsyscalls + a 2MB hole = 4 + 1 entries */
20678 - .fill 5,8,0
20679 + .fill 507,8,0
20680 + .quad level1_vsyscall_pgt - __START_KERNEL_map + _PAGE_TABLE
20681 + /* 6MB reserved for vsyscalls + a 2MB hole = 3 + 1 entries */
20682 + .fill 4,8,0
20683
20684 -NEXT_PAGE(level1_fixmap_pgt)
20685 +NEXT_PAGE(level1_vsyscall_pgt)
20686 .fill 512,8,0
20687
20688 #undef PMDS
20689
20690 - .data
20691 + .align PAGE_SIZE
20692 +ENTRY(cpu_gdt_table)
20693 + .rept NR_CPUS
20694 + .quad 0x0000000000000000 /* NULL descriptor */
20695 + .quad 0x00cf9b000000ffff /* __KERNEL32_CS */
20696 + .quad 0x00af9b000000ffff /* __KERNEL_CS */
20697 + .quad 0x00cf93000000ffff /* __KERNEL_DS */
20698 + .quad 0x00cffb000000ffff /* __USER32_CS */
20699 + .quad 0x00cff3000000ffff /* __USER_DS, __USER32_DS */
20700 + .quad 0x00affb000000ffff /* __USER_CS */
20701 +
20702 +#ifdef CONFIG_PAX_KERNEXEC
20703 + .quad 0x00af9b000000ffff /* __KERNEXEC_KERNEL_CS */
20704 +#else
20705 + .quad 0x0 /* unused */
20706 +#endif
20707 +
20708 + .quad 0,0 /* TSS */
20709 + .quad 0,0 /* LDT */
20710 + .quad 0,0,0 /* three TLS descriptors */
20711 + .quad 0x0000f40000000000 /* node/CPU stored in limit */
20712 + /* asm/segment.h:GDT_ENTRIES must match this */
20713 +
20714 + /* zero the remaining page */
20715 + .fill PAGE_SIZE / 8 - GDT_ENTRIES,8,0
20716 + .endr
20717 +
20718 .align 16
20719 .globl early_gdt_descr
20720 early_gdt_descr:
20721 .word GDT_ENTRIES*8-1
20722 early_gdt_descr_base:
20723 - .quad INIT_PER_CPU_VAR(gdt_page)
20724 + .quad cpu_gdt_table
20725
20726 ENTRY(phys_base)
20727 /* This must match the first entry in level2_kernel_pgt */
20728 .quad 0x0000000000000000
20729
20730 #include "../../x86/xen/xen-head.S"
20731 -
20732 - .section .bss, "aw", @nobits
20733 +
20734 + .section .rodata,"a",@progbits
20735 .align L1_CACHE_BYTES
20736 ENTRY(idt_table)
20737 - .skip IDT_ENTRIES * 16
20738 + .fill 512,8,0
20739
20740 .align L1_CACHE_BYTES
20741 ENTRY(nmi_idt_table)
20742 - .skip IDT_ENTRIES * 16
20743 + .fill 512,8,0
20744
20745 __PAGE_ALIGNED_BSS
20746 NEXT_PAGE(empty_zero_page)
20747 diff --git a/arch/x86/kernel/i386_ksyms_32.c b/arch/x86/kernel/i386_ksyms_32.c
20748 index 0fa6912..37fce70 100644
20749 --- a/arch/x86/kernel/i386_ksyms_32.c
20750 +++ b/arch/x86/kernel/i386_ksyms_32.c
20751 @@ -20,8 +20,12 @@ extern void cmpxchg8b_emu(void);
20752 EXPORT_SYMBOL(cmpxchg8b_emu);
20753 #endif
20754
20755 +EXPORT_SYMBOL_GPL(cpu_gdt_table);
20756 +
20757 /* Networking helper routines. */
20758 EXPORT_SYMBOL(csum_partial_copy_generic);
20759 +EXPORT_SYMBOL(csum_partial_copy_generic_to_user);
20760 +EXPORT_SYMBOL(csum_partial_copy_generic_from_user);
20761
20762 EXPORT_SYMBOL(__get_user_1);
20763 EXPORT_SYMBOL(__get_user_2);
20764 @@ -37,3 +41,7 @@ EXPORT_SYMBOL(strstr);
20765
20766 EXPORT_SYMBOL(csum_partial);
20767 EXPORT_SYMBOL(empty_zero_page);
20768 +
20769 +#ifdef CONFIG_PAX_KERNEXEC
20770 +EXPORT_SYMBOL(__LOAD_PHYSICAL_ADDR);
20771 +#endif
20772 diff --git a/arch/x86/kernel/i387.c b/arch/x86/kernel/i387.c
20773 index cb33909..1163b40 100644
20774 --- a/arch/x86/kernel/i387.c
20775 +++ b/arch/x86/kernel/i387.c
20776 @@ -51,7 +51,7 @@ static inline bool interrupted_kernel_fpu_idle(void)
20777 static inline bool interrupted_user_mode(void)
20778 {
20779 struct pt_regs *regs = get_irq_regs();
20780 - return regs && user_mode_vm(regs);
20781 + return regs && user_mode(regs);
20782 }
20783
20784 /*
20785 diff --git a/arch/x86/kernel/i8259.c b/arch/x86/kernel/i8259.c
20786 index 9a5c460..84868423 100644
20787 --- a/arch/x86/kernel/i8259.c
20788 +++ b/arch/x86/kernel/i8259.c
20789 @@ -110,7 +110,7 @@ static int i8259A_irq_pending(unsigned int irq)
20790 static void make_8259A_irq(unsigned int irq)
20791 {
20792 disable_irq_nosync(irq);
20793 - io_apic_irqs &= ~(1<<irq);
20794 + io_apic_irqs &= ~(1UL<<irq);
20795 irq_set_chip_and_handler_name(irq, &i8259A_chip, handle_level_irq,
20796 i8259A_chip.name);
20797 enable_irq(irq);
20798 @@ -209,7 +209,7 @@ spurious_8259A_irq:
20799 "spurious 8259A interrupt: IRQ%d.\n", irq);
20800 spurious_irq_mask |= irqmask;
20801 }
20802 - atomic_inc(&irq_err_count);
20803 + atomic_inc_unchecked(&irq_err_count);
20804 /*
20805 * Theoretically we do not have to handle this IRQ,
20806 * but in Linux this does not cause problems and is
20807 @@ -333,14 +333,16 @@ static void init_8259A(int auto_eoi)
20808 /* (slave's support for AEOI in flat mode is to be investigated) */
20809 outb_pic(SLAVE_ICW4_DEFAULT, PIC_SLAVE_IMR);
20810
20811 + pax_open_kernel();
20812 if (auto_eoi)
20813 /*
20814 * In AEOI mode we just have to mask the interrupt
20815 * when acking.
20816 */
20817 - i8259A_chip.irq_mask_ack = disable_8259A_irq;
20818 + *(void **)&i8259A_chip.irq_mask_ack = disable_8259A_irq;
20819 else
20820 - i8259A_chip.irq_mask_ack = mask_and_ack_8259A;
20821 + *(void **)&i8259A_chip.irq_mask_ack = mask_and_ack_8259A;
20822 + pax_close_kernel();
20823
20824 udelay(100); /* wait for 8259A to initialize */
20825
20826 diff --git a/arch/x86/kernel/io_delay.c b/arch/x86/kernel/io_delay.c
20827 index a979b5b..1d6db75 100644
20828 --- a/arch/x86/kernel/io_delay.c
20829 +++ b/arch/x86/kernel/io_delay.c
20830 @@ -58,7 +58,7 @@ static int __init dmi_io_delay_0xed_port(const struct dmi_system_id *id)
20831 * Quirk table for systems that misbehave (lock up, etc.) if port
20832 * 0x80 is used:
20833 */
20834 -static struct dmi_system_id __initdata io_delay_0xed_port_dmi_table[] = {
20835 +static const struct dmi_system_id __initconst io_delay_0xed_port_dmi_table[] = {
20836 {
20837 .callback = dmi_io_delay_0xed_port,
20838 .ident = "Compaq Presario V6000",
20839 diff --git a/arch/x86/kernel/ioport.c b/arch/x86/kernel/ioport.c
20840 index 4ddaf66..6292f4e 100644
20841 --- a/arch/x86/kernel/ioport.c
20842 +++ b/arch/x86/kernel/ioport.c
20843 @@ -6,6 +6,7 @@
20844 #include <linux/sched.h>
20845 #include <linux/kernel.h>
20846 #include <linux/capability.h>
20847 +#include <linux/security.h>
20848 #include <linux/errno.h>
20849 #include <linux/types.h>
20850 #include <linux/ioport.h>
20851 @@ -28,6 +29,12 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
20852
20853 if ((from + num <= from) || (from + num > IO_BITMAP_BITS))
20854 return -EINVAL;
20855 +#ifdef CONFIG_GRKERNSEC_IO
20856 + if (turn_on && grsec_disable_privio) {
20857 + gr_handle_ioperm();
20858 + return -EPERM;
20859 + }
20860 +#endif
20861 if (turn_on && !capable(CAP_SYS_RAWIO))
20862 return -EPERM;
20863
20864 @@ -54,7 +61,7 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
20865 * because the ->io_bitmap_max value must match the bitmap
20866 * contents:
20867 */
20868 - tss = &per_cpu(init_tss, get_cpu());
20869 + tss = init_tss + get_cpu();
20870
20871 if (turn_on)
20872 bitmap_clear(t->io_bitmap_ptr, from, num);
20873 @@ -103,6 +110,12 @@ SYSCALL_DEFINE1(iopl, unsigned int, level)
20874 return -EINVAL;
20875 /* Trying to gain more privileges? */
20876 if (level > old) {
20877 +#ifdef CONFIG_GRKERNSEC_IO
20878 + if (grsec_disable_privio) {
20879 + gr_handle_iopl();
20880 + return -EPERM;
20881 + }
20882 +#endif
20883 if (!capable(CAP_SYS_RAWIO))
20884 return -EPERM;
20885 }
20886 diff --git a/arch/x86/kernel/irq.c b/arch/x86/kernel/irq.c
20887 index 84b7789..e65e8be 100644
20888 --- a/arch/x86/kernel/irq.c
20889 +++ b/arch/x86/kernel/irq.c
20890 @@ -18,7 +18,7 @@
20891 #include <asm/mce.h>
20892 #include <asm/hw_irq.h>
20893
20894 -atomic_t irq_err_count;
20895 +atomic_unchecked_t irq_err_count;
20896
20897 /* Function pointer for generic interrupt vector handling */
20898 void (*x86_platform_ipi_callback)(void) = NULL;
20899 @@ -122,9 +122,9 @@ int arch_show_interrupts(struct seq_file *p, int prec)
20900 seq_printf(p, "%10u ", per_cpu(mce_poll_count, j));
20901 seq_printf(p, " Machine check polls\n");
20902 #endif
20903 - seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read(&irq_err_count));
20904 + seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read_unchecked(&irq_err_count));
20905 #if defined(CONFIG_X86_IO_APIC)
20906 - seq_printf(p, "%*s: %10u\n", prec, "MIS", atomic_read(&irq_mis_count));
20907 + seq_printf(p, "%*s: %10u\n", prec, "MIS", atomic_read_unchecked(&irq_mis_count));
20908 #endif
20909 return 0;
20910 }
20911 @@ -164,7 +164,7 @@ u64 arch_irq_stat_cpu(unsigned int cpu)
20912
20913 u64 arch_irq_stat(void)
20914 {
20915 - u64 sum = atomic_read(&irq_err_count);
20916 + u64 sum = atomic_read_unchecked(&irq_err_count);
20917 return sum;
20918 }
20919
20920 diff --git a/arch/x86/kernel/irq_32.c b/arch/x86/kernel/irq_32.c
20921 index 344faf8..355f60d 100644
20922 --- a/arch/x86/kernel/irq_32.c
20923 +++ b/arch/x86/kernel/irq_32.c
20924 @@ -39,7 +39,7 @@ static int check_stack_overflow(void)
20925 __asm__ __volatile__("andl %%esp,%0" :
20926 "=r" (sp) : "0" (THREAD_SIZE - 1));
20927
20928 - return sp < (sizeof(struct thread_info) + STACK_WARN);
20929 + return sp < STACK_WARN;
20930 }
20931
20932 static void print_stack_overflow(void)
20933 @@ -59,8 +59,8 @@ static inline void print_stack_overflow(void) { }
20934 * per-CPU IRQ handling contexts (thread information and stack)
20935 */
20936 union irq_ctx {
20937 - struct thread_info tinfo;
20938 - u32 stack[THREAD_SIZE/sizeof(u32)];
20939 + unsigned long previous_esp;
20940 + u32 stack[THREAD_SIZE/sizeof(u32)];
20941 } __attribute__((aligned(THREAD_SIZE)));
20942
20943 static DEFINE_PER_CPU(union irq_ctx *, hardirq_ctx);
20944 @@ -80,10 +80,9 @@ static void call_on_stack(void *func, void *stack)
20945 static inline int
20946 execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
20947 {
20948 - union irq_ctx *curctx, *irqctx;
20949 + union irq_ctx *irqctx;
20950 u32 *isp, arg1, arg2;
20951
20952 - curctx = (union irq_ctx *) current_thread_info();
20953 irqctx = __this_cpu_read(hardirq_ctx);
20954
20955 /*
20956 @@ -92,16 +91,16 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
20957 * handler) we can't do that and just have to keep using the
20958 * current stack (which is the irq stack already after all)
20959 */
20960 - if (unlikely(curctx == irqctx))
20961 + if (unlikely((void *)current_stack_pointer - (void *)irqctx < THREAD_SIZE))
20962 return 0;
20963
20964 /* build the stack frame on the IRQ stack */
20965 - isp = (u32 *) ((char *)irqctx + sizeof(*irqctx));
20966 - irqctx->tinfo.task = curctx->tinfo.task;
20967 - irqctx->tinfo.previous_esp = current_stack_pointer;
20968 + isp = (u32 *) ((char *)irqctx + sizeof(*irqctx) - 8);
20969 + irqctx->previous_esp = current_stack_pointer;
20970
20971 - /* Copy the preempt_count so that the [soft]irq checks work. */
20972 - irqctx->tinfo.preempt_count = curctx->tinfo.preempt_count;
20973 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20974 + __set_fs(MAKE_MM_SEG(0));
20975 +#endif
20976
20977 if (unlikely(overflow))
20978 call_on_stack(print_stack_overflow, isp);
20979 @@ -113,6 +112,11 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
20980 : "0" (irq), "1" (desc), "2" (isp),
20981 "D" (desc->handle_irq)
20982 : "memory", "cc", "ecx");
20983 +
20984 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20985 + __set_fs(current_thread_info()->addr_limit);
20986 +#endif
20987 +
20988 return 1;
20989 }
20990
20991 @@ -121,29 +125,14 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
20992 */
20993 void __cpuinit irq_ctx_init(int cpu)
20994 {
20995 - union irq_ctx *irqctx;
20996 -
20997 if (per_cpu(hardirq_ctx, cpu))
20998 return;
20999
21000 - irqctx = page_address(alloc_pages_node(cpu_to_node(cpu),
21001 - THREADINFO_GFP,
21002 - THREAD_SIZE_ORDER));
21003 - memset(&irqctx->tinfo, 0, sizeof(struct thread_info));
21004 - irqctx->tinfo.cpu = cpu;
21005 - irqctx->tinfo.preempt_count = HARDIRQ_OFFSET;
21006 - irqctx->tinfo.addr_limit = MAKE_MM_SEG(0);
21007 -
21008 - per_cpu(hardirq_ctx, cpu) = irqctx;
21009 -
21010 - irqctx = page_address(alloc_pages_node(cpu_to_node(cpu),
21011 - THREADINFO_GFP,
21012 - THREAD_SIZE_ORDER));
21013 - memset(&irqctx->tinfo, 0, sizeof(struct thread_info));
21014 - irqctx->tinfo.cpu = cpu;
21015 - irqctx->tinfo.addr_limit = MAKE_MM_SEG(0);
21016 -
21017 - per_cpu(softirq_ctx, cpu) = irqctx;
21018 + per_cpu(hardirq_ctx, cpu) = page_address(alloc_pages_node(cpu_to_node(cpu), THREADINFO_GFP, THREAD_SIZE_ORDER));
21019 + per_cpu(softirq_ctx, cpu) = page_address(alloc_pages_node(cpu_to_node(cpu), THREADINFO_GFP, THREAD_SIZE_ORDER));
21020 +
21021 + printk(KERN_DEBUG "CPU %u irqstacks, hard=%p soft=%p\n",
21022 + cpu, per_cpu(hardirq_ctx, cpu), per_cpu(softirq_ctx, cpu));
21023
21024 printk(KERN_DEBUG "CPU %u irqstacks, hard=%p soft=%p\n",
21025 cpu, per_cpu(hardirq_ctx, cpu), per_cpu(softirq_ctx, cpu));
21026 @@ -152,7 +141,6 @@ void __cpuinit irq_ctx_init(int cpu)
21027 asmlinkage void do_softirq(void)
21028 {
21029 unsigned long flags;
21030 - struct thread_info *curctx;
21031 union irq_ctx *irqctx;
21032 u32 *isp;
21033
21034 @@ -162,15 +150,22 @@ asmlinkage void do_softirq(void)
21035 local_irq_save(flags);
21036
21037 if (local_softirq_pending()) {
21038 - curctx = current_thread_info();
21039 irqctx = __this_cpu_read(softirq_ctx);
21040 - irqctx->tinfo.task = curctx->task;
21041 - irqctx->tinfo.previous_esp = current_stack_pointer;
21042 + irqctx->previous_esp = current_stack_pointer;
21043
21044 /* build the stack frame on the softirq stack */
21045 - isp = (u32 *) ((char *)irqctx + sizeof(*irqctx));
21046 + isp = (u32 *) ((char *)irqctx + sizeof(*irqctx) - 8);
21047 +
21048 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21049 + __set_fs(MAKE_MM_SEG(0));
21050 +#endif
21051
21052 call_on_stack(__do_softirq, isp);
21053 +
21054 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21055 + __set_fs(current_thread_info()->addr_limit);
21056 +#endif
21057 +
21058 /*
21059 * Shouldn't happen, we returned above if in_interrupt():
21060 */
21061 @@ -191,7 +186,7 @@ bool handle_irq(unsigned irq, struct pt_regs *regs)
21062 if (unlikely(!desc))
21063 return false;
21064
21065 - if (user_mode_vm(regs) || !execute_on_irq_stack(overflow, desc, irq)) {
21066 + if (user_mode(regs) || !execute_on_irq_stack(overflow, desc, irq)) {
21067 if (unlikely(overflow))
21068 print_stack_overflow();
21069 desc->handle_irq(irq, desc);
21070 diff --git a/arch/x86/kernel/irq_64.c b/arch/x86/kernel/irq_64.c
21071 index d04d3ec..ea4b374 100644
21072 --- a/arch/x86/kernel/irq_64.c
21073 +++ b/arch/x86/kernel/irq_64.c
21074 @@ -44,7 +44,7 @@ static inline void stack_overflow_check(struct pt_regs *regs)
21075 u64 estack_top, estack_bottom;
21076 u64 curbase = (u64)task_stack_page(current);
21077
21078 - if (user_mode_vm(regs))
21079 + if (user_mode(regs))
21080 return;
21081
21082 if (regs->sp >= curbase + sizeof(struct thread_info) +
21083 diff --git a/arch/x86/kernel/kdebugfs.c b/arch/x86/kernel/kdebugfs.c
21084 index dc1404b..bbc43e7 100644
21085 --- a/arch/x86/kernel/kdebugfs.c
21086 +++ b/arch/x86/kernel/kdebugfs.c
21087 @@ -27,7 +27,7 @@ struct setup_data_node {
21088 u32 len;
21089 };
21090
21091 -static ssize_t setup_data_read(struct file *file, char __user *user_buf,
21092 +static ssize_t __size_overflow(3) setup_data_read(struct file *file, char __user *user_buf,
21093 size_t count, loff_t *ppos)
21094 {
21095 struct setup_data_node *node = file->private_data;
21096 diff --git a/arch/x86/kernel/kgdb.c b/arch/x86/kernel/kgdb.c
21097 index 836f832..a8bda67 100644
21098 --- a/arch/x86/kernel/kgdb.c
21099 +++ b/arch/x86/kernel/kgdb.c
21100 @@ -127,11 +127,11 @@ char *dbg_get_reg(int regno, void *mem, struct pt_regs *regs)
21101 #ifdef CONFIG_X86_32
21102 switch (regno) {
21103 case GDB_SS:
21104 - if (!user_mode_vm(regs))
21105 + if (!user_mode(regs))
21106 *(unsigned long *)mem = __KERNEL_DS;
21107 break;
21108 case GDB_SP:
21109 - if (!user_mode_vm(regs))
21110 + if (!user_mode(regs))
21111 *(unsigned long *)mem = kernel_stack_pointer(regs);
21112 break;
21113 case GDB_GS:
21114 @@ -229,7 +229,10 @@ static void kgdb_correct_hw_break(void)
21115 bp->attr.bp_addr = breakinfo[breakno].addr;
21116 bp->attr.bp_len = breakinfo[breakno].len;
21117 bp->attr.bp_type = breakinfo[breakno].type;
21118 - info->address = breakinfo[breakno].addr;
21119 + if (breakinfo[breakno].type == X86_BREAKPOINT_EXECUTE)
21120 + info->address = ktla_ktva(breakinfo[breakno].addr);
21121 + else
21122 + info->address = breakinfo[breakno].addr;
21123 info->len = breakinfo[breakno].len;
21124 info->type = breakinfo[breakno].type;
21125 val = arch_install_hw_breakpoint(bp);
21126 @@ -476,12 +479,12 @@ int kgdb_arch_handle_exception(int e_vector, int signo, int err_code,
21127 case 'k':
21128 /* clear the trace bit */
21129 linux_regs->flags &= ~X86_EFLAGS_TF;
21130 - atomic_set(&kgdb_cpu_doing_single_step, -1);
21131 + atomic_set_unchecked(&kgdb_cpu_doing_single_step, -1);
21132
21133 /* set the trace bit if we're stepping */
21134 if (remcomInBuffer[0] == 's') {
21135 linux_regs->flags |= X86_EFLAGS_TF;
21136 - atomic_set(&kgdb_cpu_doing_single_step,
21137 + atomic_set_unchecked(&kgdb_cpu_doing_single_step,
21138 raw_smp_processor_id());
21139 }
21140
21141 @@ -546,7 +549,7 @@ static int __kgdb_notify(struct die_args *args, unsigned long cmd)
21142
21143 switch (cmd) {
21144 case DIE_DEBUG:
21145 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1) {
21146 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1) {
21147 if (user_mode(regs))
21148 return single_step_cont(regs, args);
21149 break;
21150 @@ -751,11 +754,11 @@ int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
21151 #endif /* CONFIG_DEBUG_RODATA */
21152
21153 bpt->type = BP_BREAKPOINT;
21154 - err = probe_kernel_read(bpt->saved_instr, (char *)bpt->bpt_addr,
21155 + err = probe_kernel_read(bpt->saved_instr, ktla_ktva((char *)bpt->bpt_addr),
21156 BREAK_INSTR_SIZE);
21157 if (err)
21158 return err;
21159 - err = probe_kernel_write((char *)bpt->bpt_addr,
21160 + err = probe_kernel_write(ktla_ktva((char *)bpt->bpt_addr),
21161 arch_kgdb_ops.gdb_bpt_instr, BREAK_INSTR_SIZE);
21162 #ifdef CONFIG_DEBUG_RODATA
21163 if (!err)
21164 @@ -768,7 +771,7 @@ int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
21165 return -EBUSY;
21166 text_poke((void *)bpt->bpt_addr, arch_kgdb_ops.gdb_bpt_instr,
21167 BREAK_INSTR_SIZE);
21168 - err = probe_kernel_read(opc, (char *)bpt->bpt_addr, BREAK_INSTR_SIZE);
21169 + err = probe_kernel_read(opc, ktla_ktva((char *)bpt->bpt_addr), BREAK_INSTR_SIZE);
21170 if (err)
21171 return err;
21172 if (memcmp(opc, arch_kgdb_ops.gdb_bpt_instr, BREAK_INSTR_SIZE))
21173 @@ -793,13 +796,13 @@ int kgdb_arch_remove_breakpoint(struct kgdb_bkpt *bpt)
21174 if (mutex_is_locked(&text_mutex))
21175 goto knl_write;
21176 text_poke((void *)bpt->bpt_addr, bpt->saved_instr, BREAK_INSTR_SIZE);
21177 - err = probe_kernel_read(opc, (char *)bpt->bpt_addr, BREAK_INSTR_SIZE);
21178 + err = probe_kernel_read(opc, ktla_ktva((char *)bpt->bpt_addr), BREAK_INSTR_SIZE);
21179 if (err || memcmp(opc, bpt->saved_instr, BREAK_INSTR_SIZE))
21180 goto knl_write;
21181 return err;
21182 knl_write:
21183 #endif /* CONFIG_DEBUG_RODATA */
21184 - return probe_kernel_write((char *)bpt->bpt_addr,
21185 + return probe_kernel_write(ktla_ktva((char *)bpt->bpt_addr),
21186 (char *)bpt->saved_instr, BREAK_INSTR_SIZE);
21187 }
21188
21189 diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c
21190 index 7bfe318..383d238 100644
21191 --- a/arch/x86/kernel/kprobes/core.c
21192 +++ b/arch/x86/kernel/kprobes/core.c
21193 @@ -119,9 +119,12 @@ static void __kprobes __synthesize_relative_insn(void *from, void *to, u8 op)
21194 s32 raddr;
21195 } __packed *insn;
21196
21197 - insn = (struct __arch_relative_insn *)from;
21198 + insn = (struct __arch_relative_insn *)ktla_ktva(from);
21199 +
21200 + pax_open_kernel();
21201 insn->raddr = (s32)((long)(to) - ((long)(from) + 5));
21202 insn->op = op;
21203 + pax_close_kernel();
21204 }
21205
21206 /* Insert a jump instruction at address 'from', which jumps to address 'to'.*/
21207 @@ -164,7 +167,7 @@ int __kprobes can_boost(kprobe_opcode_t *opcodes)
21208 kprobe_opcode_t opcode;
21209 kprobe_opcode_t *orig_opcodes = opcodes;
21210
21211 - if (search_exception_tables((unsigned long)opcodes))
21212 + if (search_exception_tables(ktva_ktla((unsigned long)opcodes)))
21213 return 0; /* Page fault may occur on this address. */
21214
21215 retry:
21216 @@ -238,9 +241,9 @@ __recover_probed_insn(kprobe_opcode_t *buf, unsigned long addr)
21217 * for the first byte, we can recover the original instruction
21218 * from it and kp->opcode.
21219 */
21220 - memcpy(buf, kp->addr, MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
21221 + memcpy(buf, ktla_ktva(kp->addr), MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
21222 buf[0] = kp->opcode;
21223 - return (unsigned long)buf;
21224 + return ktva_ktla((unsigned long)buf);
21225 }
21226
21227 /*
21228 @@ -332,7 +335,9 @@ int __kprobes __copy_instruction(u8 *dest, u8 *src)
21229 /* Another subsystem puts a breakpoint, failed to recover */
21230 if (insn.opcode.bytes[0] == BREAKPOINT_INSTRUCTION)
21231 return 0;
21232 + pax_open_kernel();
21233 memcpy(dest, insn.kaddr, insn.length);
21234 + pax_close_kernel();
21235
21236 #ifdef CONFIG_X86_64
21237 if (insn_rip_relative(&insn)) {
21238 @@ -355,7 +360,9 @@ int __kprobes __copy_instruction(u8 *dest, u8 *src)
21239 newdisp = (u8 *) src + (s64) insn.displacement.value - (u8 *) dest;
21240 BUG_ON((s64) (s32) newdisp != newdisp); /* Sanity check. */
21241 disp = (u8 *) dest + insn_offset_displacement(&insn);
21242 + pax_open_kernel();
21243 *(s32 *) disp = (s32) newdisp;
21244 + pax_close_kernel();
21245 }
21246 #endif
21247 return insn.length;
21248 @@ -488,7 +495,7 @@ setup_singlestep(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *k
21249 * nor set current_kprobe, because it doesn't use single
21250 * stepping.
21251 */
21252 - regs->ip = (unsigned long)p->ainsn.insn;
21253 + regs->ip = ktva_ktla((unsigned long)p->ainsn.insn);
21254 preempt_enable_no_resched();
21255 return;
21256 }
21257 @@ -505,9 +512,9 @@ setup_singlestep(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *k
21258 regs->flags &= ~X86_EFLAGS_IF;
21259 /* single step inline if the instruction is an int3 */
21260 if (p->opcode == BREAKPOINT_INSTRUCTION)
21261 - regs->ip = (unsigned long)p->addr;
21262 + regs->ip = ktla_ktva((unsigned long)p->addr);
21263 else
21264 - regs->ip = (unsigned long)p->ainsn.insn;
21265 + regs->ip = ktva_ktla((unsigned long)p->ainsn.insn);
21266 }
21267
21268 /*
21269 @@ -586,7 +593,7 @@ static int __kprobes kprobe_handler(struct pt_regs *regs)
21270 setup_singlestep(p, regs, kcb, 0);
21271 return 1;
21272 }
21273 - } else if (*addr != BREAKPOINT_INSTRUCTION) {
21274 + } else if (*(kprobe_opcode_t *)ktla_ktva((unsigned long)addr) != BREAKPOINT_INSTRUCTION) {
21275 /*
21276 * The breakpoint instruction was removed right
21277 * after we hit it. Another cpu has removed
21278 @@ -632,6 +639,9 @@ static void __used __kprobes kretprobe_trampoline_holder(void)
21279 " movq %rax, 152(%rsp)\n"
21280 RESTORE_REGS_STRING
21281 " popfq\n"
21282 +#ifdef KERNEXEC_PLUGIN
21283 + " btsq $63,(%rsp)\n"
21284 +#endif
21285 #else
21286 " pushf\n"
21287 SAVE_REGS_STRING
21288 @@ -769,7 +779,7 @@ static void __kprobes
21289 resume_execution(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *kcb)
21290 {
21291 unsigned long *tos = stack_addr(regs);
21292 - unsigned long copy_ip = (unsigned long)p->ainsn.insn;
21293 + unsigned long copy_ip = ktva_ktla((unsigned long)p->ainsn.insn);
21294 unsigned long orig_ip = (unsigned long)p->addr;
21295 kprobe_opcode_t *insn = p->ainsn.insn;
21296
21297 @@ -951,7 +961,7 @@ kprobe_exceptions_notify(struct notifier_block *self, unsigned long val, void *d
21298 struct die_args *args = data;
21299 int ret = NOTIFY_DONE;
21300
21301 - if (args->regs && user_mode_vm(args->regs))
21302 + if (args->regs && user_mode(args->regs))
21303 return ret;
21304
21305 switch (val) {
21306 diff --git a/arch/x86/kernel/kprobes/opt.c b/arch/x86/kernel/kprobes/opt.c
21307 index 76dc6f0..66bdfc3 100644
21308 --- a/arch/x86/kernel/kprobes/opt.c
21309 +++ b/arch/x86/kernel/kprobes/opt.c
21310 @@ -79,6 +79,7 @@ found:
21311 /* Insert a move instruction which sets a pointer to eax/rdi (1st arg). */
21312 static void __kprobes synthesize_set_arg1(kprobe_opcode_t *addr, unsigned long val)
21313 {
21314 + pax_open_kernel();
21315 #ifdef CONFIG_X86_64
21316 *addr++ = 0x48;
21317 *addr++ = 0xbf;
21318 @@ -86,6 +87,7 @@ static void __kprobes synthesize_set_arg1(kprobe_opcode_t *addr, unsigned long v
21319 *addr++ = 0xb8;
21320 #endif
21321 *(unsigned long *)addr = val;
21322 + pax_close_kernel();
21323 }
21324
21325 static void __used __kprobes kprobes_optinsn_template_holder(void)
21326 @@ -338,7 +340,7 @@ int __kprobes arch_prepare_optimized_kprobe(struct optimized_kprobe *op)
21327 * Verify if the address gap is in 2GB range, because this uses
21328 * a relative jump.
21329 */
21330 - rel = (long)op->optinsn.insn - (long)op->kp.addr + RELATIVEJUMP_SIZE;
21331 + rel = (long)op->optinsn.insn - ktla_ktva((long)op->kp.addr) + RELATIVEJUMP_SIZE;
21332 if (abs(rel) > 0x7fffffff)
21333 return -ERANGE;
21334
21335 @@ -353,16 +355,18 @@ int __kprobes arch_prepare_optimized_kprobe(struct optimized_kprobe *op)
21336 op->optinsn.size = ret;
21337
21338 /* Copy arch-dep-instance from template */
21339 - memcpy(buf, &optprobe_template_entry, TMPL_END_IDX);
21340 + pax_open_kernel();
21341 + memcpy(buf, ktla_ktva(&optprobe_template_entry), TMPL_END_IDX);
21342 + pax_close_kernel();
21343
21344 /* Set probe information */
21345 synthesize_set_arg1(buf + TMPL_MOVE_IDX, (unsigned long)op);
21346
21347 /* Set probe function call */
21348 - synthesize_relcall(buf + TMPL_CALL_IDX, optimized_callback);
21349 + synthesize_relcall(ktva_ktla(buf) + TMPL_CALL_IDX, optimized_callback);
21350
21351 /* Set returning jmp instruction at the tail of out-of-line buffer */
21352 - synthesize_reljump(buf + TMPL_END_IDX + op->optinsn.size,
21353 + synthesize_reljump(ktva_ktla(buf) + TMPL_END_IDX + op->optinsn.size,
21354 (u8 *)op->kp.addr + op->optinsn.size);
21355
21356 flush_icache_range((unsigned long) buf,
21357 @@ -385,7 +389,7 @@ static void __kprobes setup_optimize_kprobe(struct text_poke_param *tprm,
21358 ((long)op->kp.addr + RELATIVEJUMP_SIZE));
21359
21360 /* Backup instructions which will be replaced by jump address */
21361 - memcpy(op->optinsn.copied_insn, op->kp.addr + INT3_SIZE,
21362 + memcpy(op->optinsn.copied_insn, ktla_ktva(op->kp.addr) + INT3_SIZE,
21363 RELATIVE_ADDR_SIZE);
21364
21365 insn_buf[0] = RELATIVEJUMP_OPCODE;
21366 @@ -483,7 +487,7 @@ setup_detour_execution(struct kprobe *p, struct pt_regs *regs, int reenter)
21367 /* This kprobe is really able to run optimized path. */
21368 op = container_of(p, struct optimized_kprobe, kp);
21369 /* Detour through copied instructions */
21370 - regs->ip = (unsigned long)op->optinsn.insn + TMPL_END_IDX;
21371 + regs->ip = ktva_ktla((unsigned long)op->optinsn.insn) + TMPL_END_IDX;
21372 if (!reenter)
21373 reset_current_kprobe();
21374 preempt_enable_no_resched();
21375 diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c
21376 index b686a90..60d36fb 100644
21377 --- a/arch/x86/kernel/kvm.c
21378 +++ b/arch/x86/kernel/kvm.c
21379 @@ -453,7 +453,7 @@ static int __cpuinit kvm_cpu_notify(struct notifier_block *self,
21380 return NOTIFY_OK;
21381 }
21382
21383 -static struct notifier_block __cpuinitdata kvm_cpu_notifier = {
21384 +static struct notifier_block kvm_cpu_notifier = {
21385 .notifier_call = kvm_cpu_notify,
21386 };
21387 #endif
21388 diff --git a/arch/x86/kernel/ldt.c b/arch/x86/kernel/ldt.c
21389 index ebc9873..1b9724b 100644
21390 --- a/arch/x86/kernel/ldt.c
21391 +++ b/arch/x86/kernel/ldt.c
21392 @@ -66,13 +66,13 @@ static int alloc_ldt(mm_context_t *pc, int mincount, int reload)
21393 if (reload) {
21394 #ifdef CONFIG_SMP
21395 preempt_disable();
21396 - load_LDT(pc);
21397 + load_LDT_nolock(pc);
21398 if (!cpumask_equal(mm_cpumask(current->mm),
21399 cpumask_of(smp_processor_id())))
21400 smp_call_function(flush_ldt, current->mm, 1);
21401 preempt_enable();
21402 #else
21403 - load_LDT(pc);
21404 + load_LDT_nolock(pc);
21405 #endif
21406 }
21407 if (oldsize) {
21408 @@ -94,7 +94,7 @@ static inline int copy_ldt(mm_context_t *new, mm_context_t *old)
21409 return err;
21410
21411 for (i = 0; i < old->size; i++)
21412 - write_ldt_entry(new->ldt, i, old->ldt + i * LDT_ENTRY_SIZE);
21413 + write_ldt_entry(new->ldt, i, old->ldt + i);
21414 return 0;
21415 }
21416
21417 @@ -115,6 +115,24 @@ int init_new_context(struct task_struct *tsk, struct mm_struct *mm)
21418 retval = copy_ldt(&mm->context, &old_mm->context);
21419 mutex_unlock(&old_mm->context.lock);
21420 }
21421 +
21422 + if (tsk == current) {
21423 + mm->context.vdso = 0;
21424 +
21425 +#ifdef CONFIG_X86_32
21426 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
21427 + mm->context.user_cs_base = 0UL;
21428 + mm->context.user_cs_limit = ~0UL;
21429 +
21430 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
21431 + cpus_clear(mm->context.cpu_user_cs_mask);
21432 +#endif
21433 +
21434 +#endif
21435 +#endif
21436 +
21437 + }
21438 +
21439 return retval;
21440 }
21441
21442 @@ -229,6 +247,13 @@ static int write_ldt(void __user *ptr, unsigned long bytecount, int oldmode)
21443 }
21444 }
21445
21446 +#ifdef CONFIG_PAX_SEGMEXEC
21447 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (ldt_info.contents & MODIFY_LDT_CONTENTS_CODE)) {
21448 + error = -EINVAL;
21449 + goto out_unlock;
21450 + }
21451 +#endif
21452 +
21453 fill_ldt(&ldt, &ldt_info);
21454 if (oldmode)
21455 ldt.avl = 0;
21456 diff --git a/arch/x86/kernel/machine_kexec_32.c b/arch/x86/kernel/machine_kexec_32.c
21457 index 5b19e4d..6476a76 100644
21458 --- a/arch/x86/kernel/machine_kexec_32.c
21459 +++ b/arch/x86/kernel/machine_kexec_32.c
21460 @@ -26,7 +26,7 @@
21461 #include <asm/cacheflush.h>
21462 #include <asm/debugreg.h>
21463
21464 -static void set_idt(void *newidt, __u16 limit)
21465 +static void set_idt(struct desc_struct *newidt, __u16 limit)
21466 {
21467 struct desc_ptr curidt;
21468
21469 @@ -38,7 +38,7 @@ static void set_idt(void *newidt, __u16 limit)
21470 }
21471
21472
21473 -static void set_gdt(void *newgdt, __u16 limit)
21474 +static void set_gdt(struct desc_struct *newgdt, __u16 limit)
21475 {
21476 struct desc_ptr curgdt;
21477
21478 @@ -216,7 +216,7 @@ void machine_kexec(struct kimage *image)
21479 }
21480
21481 control_page = page_address(image->control_code_page);
21482 - memcpy(control_page, relocate_kernel, KEXEC_CONTROL_CODE_MAX_SIZE);
21483 + memcpy(control_page, (void *)ktla_ktva((unsigned long)relocate_kernel), KEXEC_CONTROL_CODE_MAX_SIZE);
21484
21485 relocate_kernel_ptr = control_page;
21486 page_list[PA_CONTROL_PAGE] = __pa(control_page);
21487 diff --git a/arch/x86/kernel/microcode_core.c b/arch/x86/kernel/microcode_core.c
21488 index 22db92b..d546bec 100644
21489 --- a/arch/x86/kernel/microcode_core.c
21490 +++ b/arch/x86/kernel/microcode_core.c
21491 @@ -513,7 +513,7 @@ mc_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu)
21492 return NOTIFY_OK;
21493 }
21494
21495 -static struct notifier_block __refdata mc_cpu_notifier = {
21496 +static struct notifier_block mc_cpu_notifier = {
21497 .notifier_call = mc_cpu_callback,
21498 };
21499
21500 diff --git a/arch/x86/kernel/microcode_intel.c b/arch/x86/kernel/microcode_intel.c
21501 index 5fb2ceb..3ae90bb 100644
21502 --- a/arch/x86/kernel/microcode_intel.c
21503 +++ b/arch/x86/kernel/microcode_intel.c
21504 @@ -293,13 +293,13 @@ static enum ucode_state request_microcode_fw(int cpu, struct device *device,
21505
21506 static int get_ucode_user(void *to, const void *from, size_t n)
21507 {
21508 - return copy_from_user(to, from, n);
21509 + return copy_from_user(to, (const void __force_user *)from, n);
21510 }
21511
21512 static enum ucode_state
21513 request_microcode_user(int cpu, const void __user *buf, size_t size)
21514 {
21515 - return generic_load_microcode(cpu, (void *)buf, size, &get_ucode_user);
21516 + return generic_load_microcode(cpu, (__force_kernel void *)buf, size, &get_ucode_user);
21517 }
21518
21519 static void microcode_fini_cpu(int cpu)
21520 diff --git a/arch/x86/kernel/module.c b/arch/x86/kernel/module.c
21521 index 216a4d7..228255a 100644
21522 --- a/arch/x86/kernel/module.c
21523 +++ b/arch/x86/kernel/module.c
21524 @@ -43,15 +43,60 @@ do { \
21525 } while (0)
21526 #endif
21527
21528 -void *module_alloc(unsigned long size)
21529 +static inline void *__module_alloc(unsigned long size, pgprot_t prot)
21530 {
21531 - if (PAGE_ALIGN(size) > MODULES_LEN)
21532 + if (!size || PAGE_ALIGN(size) > MODULES_LEN)
21533 return NULL;
21534 return __vmalloc_node_range(size, 1, MODULES_VADDR, MODULES_END,
21535 - GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL_EXEC,
21536 + GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, prot,
21537 -1, __builtin_return_address(0));
21538 }
21539
21540 +void *module_alloc(unsigned long size)
21541 +{
21542 +
21543 +#ifdef CONFIG_PAX_KERNEXEC
21544 + return __module_alloc(size, PAGE_KERNEL);
21545 +#else
21546 + return __module_alloc(size, PAGE_KERNEL_EXEC);
21547 +#endif
21548 +
21549 +}
21550 +
21551 +#ifdef CONFIG_PAX_KERNEXEC
21552 +#ifdef CONFIG_X86_32
21553 +void *module_alloc_exec(unsigned long size)
21554 +{
21555 + struct vm_struct *area;
21556 +
21557 + if (size == 0)
21558 + return NULL;
21559 +
21560 + area = __get_vm_area(size, VM_ALLOC, (unsigned long)&MODULES_EXEC_VADDR, (unsigned long)&MODULES_EXEC_END);
21561 + return area ? area->addr : NULL;
21562 +}
21563 +EXPORT_SYMBOL(module_alloc_exec);
21564 +
21565 +void module_free_exec(struct module *mod, void *module_region)
21566 +{
21567 + vunmap(module_region);
21568 +}
21569 +EXPORT_SYMBOL(module_free_exec);
21570 +#else
21571 +void module_free_exec(struct module *mod, void *module_region)
21572 +{
21573 + module_free(mod, module_region);
21574 +}
21575 +EXPORT_SYMBOL(module_free_exec);
21576 +
21577 +void *module_alloc_exec(unsigned long size)
21578 +{
21579 + return __module_alloc(size, PAGE_KERNEL_RX);
21580 +}
21581 +EXPORT_SYMBOL(module_alloc_exec);
21582 +#endif
21583 +#endif
21584 +
21585 #ifdef CONFIG_X86_32
21586 int apply_relocate(Elf32_Shdr *sechdrs,
21587 const char *strtab,
21588 @@ -62,14 +107,16 @@ int apply_relocate(Elf32_Shdr *sechdrs,
21589 unsigned int i;
21590 Elf32_Rel *rel = (void *)sechdrs[relsec].sh_addr;
21591 Elf32_Sym *sym;
21592 - uint32_t *location;
21593 + uint32_t *plocation, location;
21594
21595 DEBUGP("Applying relocate section %u to %u\n",
21596 relsec, sechdrs[relsec].sh_info);
21597 for (i = 0; i < sechdrs[relsec].sh_size / sizeof(*rel); i++) {
21598 /* This is where to make the change */
21599 - location = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr
21600 - + rel[i].r_offset;
21601 + plocation = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr + rel[i].r_offset;
21602 + location = (uint32_t)plocation;
21603 + if (sechdrs[sechdrs[relsec].sh_info].sh_flags & SHF_EXECINSTR)
21604 + plocation = ktla_ktva((void *)plocation);
21605 /* This is the symbol it is referring to. Note that all
21606 undefined symbols have been resolved. */
21607 sym = (Elf32_Sym *)sechdrs[symindex].sh_addr
21608 @@ -78,11 +125,15 @@ int apply_relocate(Elf32_Shdr *sechdrs,
21609 switch (ELF32_R_TYPE(rel[i].r_info)) {
21610 case R_386_32:
21611 /* We add the value into the location given */
21612 - *location += sym->st_value;
21613 + pax_open_kernel();
21614 + *plocation += sym->st_value;
21615 + pax_close_kernel();
21616 break;
21617 case R_386_PC32:
21618 /* Add the value, subtract its position */
21619 - *location += sym->st_value - (uint32_t)location;
21620 + pax_open_kernel();
21621 + *plocation += sym->st_value - location;
21622 + pax_close_kernel();
21623 break;
21624 default:
21625 pr_err("%s: Unknown relocation: %u\n",
21626 @@ -127,21 +178,30 @@ int apply_relocate_add(Elf64_Shdr *sechdrs,
21627 case R_X86_64_NONE:
21628 break;
21629 case R_X86_64_64:
21630 + pax_open_kernel();
21631 *(u64 *)loc = val;
21632 + pax_close_kernel();
21633 break;
21634 case R_X86_64_32:
21635 + pax_open_kernel();
21636 *(u32 *)loc = val;
21637 + pax_close_kernel();
21638 if (val != *(u32 *)loc)
21639 goto overflow;
21640 break;
21641 case R_X86_64_32S:
21642 + pax_open_kernel();
21643 *(s32 *)loc = val;
21644 + pax_close_kernel();
21645 if ((s64)val != *(s32 *)loc)
21646 goto overflow;
21647 break;
21648 case R_X86_64_PC32:
21649 val -= (u64)loc;
21650 + pax_open_kernel();
21651 *(u32 *)loc = val;
21652 + pax_close_kernel();
21653 +
21654 #if 0
21655 if ((s64)val != *(s32 *)loc)
21656 goto overflow;
21657 diff --git a/arch/x86/kernel/msr.c b/arch/x86/kernel/msr.c
21658 index ce13049..e2e9c3c 100644
21659 --- a/arch/x86/kernel/msr.c
21660 +++ b/arch/x86/kernel/msr.c
21661 @@ -233,7 +233,7 @@ static int __cpuinit msr_class_cpu_callback(struct notifier_block *nfb,
21662 return notifier_from_errno(err);
21663 }
21664
21665 -static struct notifier_block __refdata msr_class_cpu_notifier = {
21666 +static struct notifier_block msr_class_cpu_notifier = {
21667 .notifier_call = msr_class_cpu_callback,
21668 };
21669
21670 diff --git a/arch/x86/kernel/nmi.c b/arch/x86/kernel/nmi.c
21671 index 6030805..2d33f21 100644
21672 --- a/arch/x86/kernel/nmi.c
21673 +++ b/arch/x86/kernel/nmi.c
21674 @@ -105,7 +105,7 @@ static int __kprobes nmi_handle(unsigned int type, struct pt_regs *regs, bool b2
21675 return handled;
21676 }
21677
21678 -int __register_nmi_handler(unsigned int type, struct nmiaction *action)
21679 +int __register_nmi_handler(unsigned int type, const struct nmiaction *action)
21680 {
21681 struct nmi_desc *desc = nmi_to_desc(type);
21682 unsigned long flags;
21683 @@ -129,9 +129,9 @@ int __register_nmi_handler(unsigned int type, struct nmiaction *action)
21684 * event confuses some handlers (kdump uses this flag)
21685 */
21686 if (action->flags & NMI_FLAG_FIRST)
21687 - list_add_rcu(&action->list, &desc->head);
21688 + pax_list_add_rcu((struct list_head *)&action->list, &desc->head);
21689 else
21690 - list_add_tail_rcu(&action->list, &desc->head);
21691 + pax_list_add_tail_rcu((struct list_head *)&action->list, &desc->head);
21692
21693 spin_unlock_irqrestore(&desc->lock, flags);
21694 return 0;
21695 @@ -154,7 +154,7 @@ void unregister_nmi_handler(unsigned int type, const char *name)
21696 if (!strcmp(n->name, name)) {
21697 WARN(in_nmi(),
21698 "Trying to free NMI (%s) from NMI context!\n", n->name);
21699 - list_del_rcu(&n->list);
21700 + pax_list_del_rcu((struct list_head *)&n->list);
21701 break;
21702 }
21703 }
21704 @@ -479,6 +479,17 @@ static inline void nmi_nesting_postprocess(void)
21705 dotraplinkage notrace __kprobes void
21706 do_nmi(struct pt_regs *regs, long error_code)
21707 {
21708 +
21709 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
21710 + if (!user_mode(regs)) {
21711 + unsigned long cs = regs->cs & 0xFFFF;
21712 + unsigned long ip = ktva_ktla(regs->ip);
21713 +
21714 + if ((cs == __KERNEL_CS || cs == __KERNEXEC_KERNEL_CS) && ip <= (unsigned long)_etext)
21715 + regs->ip = ip;
21716 + }
21717 +#endif
21718 +
21719 nmi_nesting_preprocess(regs);
21720
21721 nmi_enter();
21722 diff --git a/arch/x86/kernel/nmi_selftest.c b/arch/x86/kernel/nmi_selftest.c
21723 index 6d9582e..f746287 100644
21724 --- a/arch/x86/kernel/nmi_selftest.c
21725 +++ b/arch/x86/kernel/nmi_selftest.c
21726 @@ -43,7 +43,7 @@ static void __init init_nmi_testsuite(void)
21727 {
21728 /* trap all the unknown NMIs we may generate */
21729 register_nmi_handler(NMI_UNKNOWN, nmi_unk_cb, 0, "nmi_selftest_unk",
21730 - __initdata);
21731 + __initconst);
21732 }
21733
21734 static void __init cleanup_nmi_testsuite(void)
21735 @@ -66,7 +66,7 @@ static void __init test_nmi_ipi(struct cpumask *mask)
21736 unsigned long timeout;
21737
21738 if (register_nmi_handler(NMI_LOCAL, test_nmi_ipi_callback,
21739 - NMI_FLAG_FIRST, "nmi_selftest", __initdata)) {
21740 + NMI_FLAG_FIRST, "nmi_selftest", __initconst)) {
21741 nmi_fail = FAILURE;
21742 return;
21743 }
21744 diff --git a/arch/x86/kernel/paravirt-spinlocks.c b/arch/x86/kernel/paravirt-spinlocks.c
21745 index 676b8c7..870ba04 100644
21746 --- a/arch/x86/kernel/paravirt-spinlocks.c
21747 +++ b/arch/x86/kernel/paravirt-spinlocks.c
21748 @@ -13,7 +13,7 @@ default_spin_lock_flags(arch_spinlock_t *lock, unsigned long flags)
21749 arch_spin_lock(lock);
21750 }
21751
21752 -struct pv_lock_ops pv_lock_ops = {
21753 +struct pv_lock_ops pv_lock_ops __read_only = {
21754 #ifdef CONFIG_SMP
21755 .spin_is_locked = __ticket_spin_is_locked,
21756 .spin_is_contended = __ticket_spin_is_contended,
21757 diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c
21758 index 8bfb335..c1463c6 100644
21759 --- a/arch/x86/kernel/paravirt.c
21760 +++ b/arch/x86/kernel/paravirt.c
21761 @@ -55,6 +55,9 @@ u64 _paravirt_ident_64(u64 x)
21762 {
21763 return x;
21764 }
21765 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
21766 +PV_CALLEE_SAVE_REGS_THUNK(_paravirt_ident_64);
21767 +#endif
21768
21769 void __init default_banner(void)
21770 {
21771 @@ -147,15 +150,19 @@ unsigned paravirt_patch_default(u8 type, u16 clobbers, void *insnbuf,
21772 if (opfunc == NULL)
21773 /* If there's no function, patch it with a ud2a (BUG) */
21774 ret = paravirt_patch_insns(insnbuf, len, ud2a, ud2a+sizeof(ud2a));
21775 - else if (opfunc == _paravirt_nop)
21776 + else if (opfunc == (void *)_paravirt_nop)
21777 /* If the operation is a nop, then nop the callsite */
21778 ret = paravirt_patch_nop();
21779
21780 /* identity functions just return their single argument */
21781 - else if (opfunc == _paravirt_ident_32)
21782 + else if (opfunc == (void *)_paravirt_ident_32)
21783 ret = paravirt_patch_ident_32(insnbuf, len);
21784 - else if (opfunc == _paravirt_ident_64)
21785 + else if (opfunc == (void *)_paravirt_ident_64)
21786 ret = paravirt_patch_ident_64(insnbuf, len);
21787 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
21788 + else if (opfunc == (void *)__raw_callee_save__paravirt_ident_64)
21789 + ret = paravirt_patch_ident_64(insnbuf, len);
21790 +#endif
21791
21792 else if (type == PARAVIRT_PATCH(pv_cpu_ops.iret) ||
21793 type == PARAVIRT_PATCH(pv_cpu_ops.irq_enable_sysexit) ||
21794 @@ -180,7 +187,7 @@ unsigned paravirt_patch_insns(void *insnbuf, unsigned len,
21795 if (insn_len > len || start == NULL)
21796 insn_len = len;
21797 else
21798 - memcpy(insnbuf, start, insn_len);
21799 + memcpy(insnbuf, ktla_ktva(start), insn_len);
21800
21801 return insn_len;
21802 }
21803 @@ -304,7 +311,7 @@ enum paravirt_lazy_mode paravirt_get_lazy_mode(void)
21804 return this_cpu_read(paravirt_lazy_mode);
21805 }
21806
21807 -struct pv_info pv_info = {
21808 +struct pv_info pv_info __read_only = {
21809 .name = "bare hardware",
21810 .paravirt_enabled = 0,
21811 .kernel_rpl = 0,
21812 @@ -315,16 +322,16 @@ struct pv_info pv_info = {
21813 #endif
21814 };
21815
21816 -struct pv_init_ops pv_init_ops = {
21817 +struct pv_init_ops pv_init_ops __read_only = {
21818 .patch = native_patch,
21819 };
21820
21821 -struct pv_time_ops pv_time_ops = {
21822 +struct pv_time_ops pv_time_ops __read_only = {
21823 .sched_clock = native_sched_clock,
21824 .steal_clock = native_steal_clock,
21825 };
21826
21827 -struct pv_irq_ops pv_irq_ops = {
21828 +struct pv_irq_ops pv_irq_ops __read_only = {
21829 .save_fl = __PV_IS_CALLEE_SAVE(native_save_fl),
21830 .restore_fl = __PV_IS_CALLEE_SAVE(native_restore_fl),
21831 .irq_disable = __PV_IS_CALLEE_SAVE(native_irq_disable),
21832 @@ -336,7 +343,7 @@ struct pv_irq_ops pv_irq_ops = {
21833 #endif
21834 };
21835
21836 -struct pv_cpu_ops pv_cpu_ops = {
21837 +struct pv_cpu_ops pv_cpu_ops __read_only = {
21838 .cpuid = native_cpuid,
21839 .get_debugreg = native_get_debugreg,
21840 .set_debugreg = native_set_debugreg,
21841 @@ -395,21 +402,26 @@ struct pv_cpu_ops pv_cpu_ops = {
21842 .end_context_switch = paravirt_nop,
21843 };
21844
21845 -struct pv_apic_ops pv_apic_ops = {
21846 +struct pv_apic_ops pv_apic_ops __read_only= {
21847 #ifdef CONFIG_X86_LOCAL_APIC
21848 .startup_ipi_hook = paravirt_nop,
21849 #endif
21850 };
21851
21852 -#if defined(CONFIG_X86_32) && !defined(CONFIG_X86_PAE)
21853 +#ifdef CONFIG_X86_32
21854 +#ifdef CONFIG_X86_PAE
21855 +/* 64-bit pagetable entries */
21856 +#define PTE_IDENT PV_CALLEE_SAVE(_paravirt_ident_64)
21857 +#else
21858 /* 32-bit pagetable entries */
21859 #define PTE_IDENT __PV_IS_CALLEE_SAVE(_paravirt_ident_32)
21860 +#endif
21861 #else
21862 /* 64-bit pagetable entries */
21863 #define PTE_IDENT __PV_IS_CALLEE_SAVE(_paravirt_ident_64)
21864 #endif
21865
21866 -struct pv_mmu_ops pv_mmu_ops = {
21867 +struct pv_mmu_ops pv_mmu_ops __read_only = {
21868
21869 .read_cr2 = native_read_cr2,
21870 .write_cr2 = native_write_cr2,
21871 @@ -459,6 +471,7 @@ struct pv_mmu_ops pv_mmu_ops = {
21872 .make_pud = PTE_IDENT,
21873
21874 .set_pgd = native_set_pgd,
21875 + .set_pgd_batched = native_set_pgd_batched,
21876 #endif
21877 #endif /* PAGETABLE_LEVELS >= 3 */
21878
21879 @@ -479,6 +492,12 @@ struct pv_mmu_ops pv_mmu_ops = {
21880 },
21881
21882 .set_fixmap = native_set_fixmap,
21883 +
21884 +#ifdef CONFIG_PAX_KERNEXEC
21885 + .pax_open_kernel = native_pax_open_kernel,
21886 + .pax_close_kernel = native_pax_close_kernel,
21887 +#endif
21888 +
21889 };
21890
21891 EXPORT_SYMBOL_GPL(pv_time_ops);
21892 diff --git a/arch/x86/kernel/pci-calgary_64.c b/arch/x86/kernel/pci-calgary_64.c
21893 index 299d493..2ccb0ee 100644
21894 --- a/arch/x86/kernel/pci-calgary_64.c
21895 +++ b/arch/x86/kernel/pci-calgary_64.c
21896 @@ -1339,7 +1339,7 @@ static void __init get_tce_space_from_tar(void)
21897 tce_space = be64_to_cpu(readq(target));
21898 tce_space = tce_space & TAR_SW_BITS;
21899
21900 - tce_space = tce_space & (~specified_table_size);
21901 + tce_space = tce_space & (~(unsigned long)specified_table_size);
21902 info->tce_space = (u64 *)__va(tce_space);
21903 }
21904 }
21905 diff --git a/arch/x86/kernel/pci-iommu_table.c b/arch/x86/kernel/pci-iommu_table.c
21906 index 35ccf75..7a15747 100644
21907 --- a/arch/x86/kernel/pci-iommu_table.c
21908 +++ b/arch/x86/kernel/pci-iommu_table.c
21909 @@ -2,7 +2,7 @@
21910 #include <asm/iommu_table.h>
21911 #include <linux/string.h>
21912 #include <linux/kallsyms.h>
21913 -
21914 +#include <linux/sched.h>
21915
21916 #define DEBUG 1
21917
21918 diff --git a/arch/x86/kernel/pci-swiotlb.c b/arch/x86/kernel/pci-swiotlb.c
21919 index 6c483ba..d10ce2f 100644
21920 --- a/arch/x86/kernel/pci-swiotlb.c
21921 +++ b/arch/x86/kernel/pci-swiotlb.c
21922 @@ -32,7 +32,7 @@ static void x86_swiotlb_free_coherent(struct device *dev, size_t size,
21923 void *vaddr, dma_addr_t dma_addr,
21924 struct dma_attrs *attrs)
21925 {
21926 - swiotlb_free_coherent(dev, size, vaddr, dma_addr);
21927 + swiotlb_free_coherent(dev, size, vaddr, dma_addr, attrs);
21928 }
21929
21930 static struct dma_map_ops swiotlb_dma_ops = {
21931 diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
21932 index 14ae100..752a4f6 100644
21933 --- a/arch/x86/kernel/process.c
21934 +++ b/arch/x86/kernel/process.c
21935 @@ -36,7 +36,8 @@
21936 * section. Since TSS's are completely CPU-local, we want them
21937 * on exact cacheline boundaries, to eliminate cacheline ping-pong.
21938 */
21939 -DEFINE_PER_CPU_SHARED_ALIGNED(struct tss_struct, init_tss) = INIT_TSS;
21940 +struct tss_struct init_tss[NR_CPUS] ____cacheline_internodealigned_in_smp = { [0 ... NR_CPUS-1] = INIT_TSS };
21941 +EXPORT_SYMBOL(init_tss);
21942
21943 #ifdef CONFIG_X86_64
21944 static DEFINE_PER_CPU(unsigned char, is_idle);
21945 @@ -92,7 +93,7 @@ void arch_task_cache_init(void)
21946 task_xstate_cachep =
21947 kmem_cache_create("task_xstate", xstate_size,
21948 __alignof__(union thread_xstate),
21949 - SLAB_PANIC | SLAB_NOTRACK, NULL);
21950 + SLAB_PANIC | SLAB_NOTRACK | SLAB_USERCOPY, NULL);
21951 }
21952
21953 /*
21954 @@ -105,7 +106,7 @@ void exit_thread(void)
21955 unsigned long *bp = t->io_bitmap_ptr;
21956
21957 if (bp) {
21958 - struct tss_struct *tss = &per_cpu(init_tss, get_cpu());
21959 + struct tss_struct *tss = init_tss + get_cpu();
21960
21961 t->io_bitmap_ptr = NULL;
21962 clear_thread_flag(TIF_IO_BITMAP);
21963 @@ -136,7 +137,7 @@ void show_regs_common(void)
21964 board = dmi_get_system_info(DMI_BOARD_NAME);
21965
21966 printk(KERN_DEFAULT "Pid: %d, comm: %.20s %s %s %.*s %s %s%s%s\n",
21967 - current->pid, current->comm, print_tainted(),
21968 + task_pid_nr(current), current->comm, print_tainted(),
21969 init_utsname()->release,
21970 (int)strcspn(init_utsname()->version, " "),
21971 init_utsname()->version,
21972 @@ -149,6 +150,9 @@ void flush_thread(void)
21973 {
21974 struct task_struct *tsk = current;
21975
21976 +#if defined(CONFIG_X86_32) && !defined(CONFIG_CC_STACKPROTECTOR) && !defined(CONFIG_PAX_MEMORY_UDEREF)
21977 + loadsegment(gs, 0);
21978 +#endif
21979 flush_ptrace_hw_breakpoint(tsk);
21980 memset(tsk->thread.tls_array, 0, sizeof(tsk->thread.tls_array));
21981 drop_init_fpu(tsk);
21982 @@ -295,7 +299,7 @@ static void __exit_idle(void)
21983 void exit_idle(void)
21984 {
21985 /* idle loop has pid 0 */
21986 - if (current->pid)
21987 + if (task_pid_nr(current))
21988 return;
21989 __exit_idle();
21990 }
21991 @@ -398,7 +402,7 @@ bool xen_set_default_idle(void)
21992 return ret;
21993 }
21994 #endif
21995 -void stop_this_cpu(void *dummy)
21996 +__noreturn void stop_this_cpu(void *dummy)
21997 {
21998 local_irq_disable();
21999 /*
22000 @@ -544,16 +548,37 @@ static int __init idle_setup(char *str)
22001 }
22002 early_param("idle", idle_setup);
22003
22004 -unsigned long arch_align_stack(unsigned long sp)
22005 +#ifdef CONFIG_PAX_RANDKSTACK
22006 +void pax_randomize_kstack(struct pt_regs *regs)
22007 {
22008 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
22009 - sp -= get_random_int() % 8192;
22010 - return sp & ~0xf;
22011 -}
22012 + struct thread_struct *thread = &current->thread;
22013 + unsigned long time;
22014
22015 -unsigned long arch_randomize_brk(struct mm_struct *mm)
22016 -{
22017 - unsigned long range_end = mm->brk + 0x02000000;
22018 - return randomize_range(mm->brk, range_end, 0) ? : mm->brk;
22019 -}
22020 + if (!randomize_va_space)
22021 + return;
22022 +
22023 + if (v8086_mode(regs))
22024 + return;
22025
22026 + rdtscl(time);
22027 +
22028 + /* P4 seems to return a 0 LSB, ignore it */
22029 +#ifdef CONFIG_MPENTIUM4
22030 + time &= 0x3EUL;
22031 + time <<= 2;
22032 +#elif defined(CONFIG_X86_64)
22033 + time &= 0xFUL;
22034 + time <<= 4;
22035 +#else
22036 + time &= 0x1FUL;
22037 + time <<= 3;
22038 +#endif
22039 +
22040 + thread->sp0 ^= time;
22041 + load_sp0(init_tss + smp_processor_id(), thread);
22042 +
22043 +#ifdef CONFIG_X86_64
22044 + this_cpu_write(kernel_stack, thread->sp0);
22045 +#endif
22046 +}
22047 +#endif
22048 diff --git a/arch/x86/kernel/process_32.c b/arch/x86/kernel/process_32.c
22049 index b5a8905..d9cacac 100644
22050 --- a/arch/x86/kernel/process_32.c
22051 +++ b/arch/x86/kernel/process_32.c
22052 @@ -65,6 +65,7 @@ asmlinkage void ret_from_kernel_thread(void) __asm__("ret_from_kernel_thread");
22053 unsigned long thread_saved_pc(struct task_struct *tsk)
22054 {
22055 return ((unsigned long *)tsk->thread.sp)[3];
22056 +//XXX return tsk->thread.eip;
22057 }
22058
22059 void __show_regs(struct pt_regs *regs, int all)
22060 @@ -74,21 +75,20 @@ void __show_regs(struct pt_regs *regs, int all)
22061 unsigned long sp;
22062 unsigned short ss, gs;
22063
22064 - if (user_mode_vm(regs)) {
22065 + if (user_mode(regs)) {
22066 sp = regs->sp;
22067 ss = regs->ss & 0xffff;
22068 - gs = get_user_gs(regs);
22069 } else {
22070 sp = kernel_stack_pointer(regs);
22071 savesegment(ss, ss);
22072 - savesegment(gs, gs);
22073 }
22074 + gs = get_user_gs(regs);
22075
22076 show_regs_common();
22077
22078 printk(KERN_DEFAULT "EIP: %04x:[<%08lx>] EFLAGS: %08lx CPU: %d\n",
22079 (u16)regs->cs, regs->ip, regs->flags,
22080 - smp_processor_id());
22081 + raw_smp_processor_id());
22082 print_symbol("EIP is at %s\n", regs->ip);
22083
22084 printk(KERN_DEFAULT "EAX: %08lx EBX: %08lx ECX: %08lx EDX: %08lx\n",
22085 @@ -130,20 +130,21 @@ void release_thread(struct task_struct *dead_task)
22086 int copy_thread(unsigned long clone_flags, unsigned long sp,
22087 unsigned long arg, struct task_struct *p)
22088 {
22089 - struct pt_regs *childregs = task_pt_regs(p);
22090 + struct pt_regs *childregs = task_stack_page(p) + THREAD_SIZE - sizeof(struct pt_regs) - 8;
22091 struct task_struct *tsk;
22092 int err;
22093
22094 p->thread.sp = (unsigned long) childregs;
22095 p->thread.sp0 = (unsigned long) (childregs+1);
22096 + p->tinfo.lowest_stack = (unsigned long)task_stack_page(p);
22097
22098 if (unlikely(p->flags & PF_KTHREAD)) {
22099 /* kernel thread */
22100 memset(childregs, 0, sizeof(struct pt_regs));
22101 p->thread.ip = (unsigned long) ret_from_kernel_thread;
22102 - task_user_gs(p) = __KERNEL_STACK_CANARY;
22103 - childregs->ds = __USER_DS;
22104 - childregs->es = __USER_DS;
22105 + savesegment(gs, childregs->gs);
22106 + childregs->ds = __KERNEL_DS;
22107 + childregs->es = __KERNEL_DS;
22108 childregs->fs = __KERNEL_PERCPU;
22109 childregs->bx = sp; /* function */
22110 childregs->bp = arg;
22111 @@ -250,7 +251,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22112 struct thread_struct *prev = &prev_p->thread,
22113 *next = &next_p->thread;
22114 int cpu = smp_processor_id();
22115 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
22116 + struct tss_struct *tss = init_tss + cpu;
22117 fpu_switch_t fpu;
22118
22119 /* never put a printk in __switch_to... printk() calls wake_up*() indirectly */
22120 @@ -274,6 +275,10 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22121 */
22122 lazy_save_gs(prev->gs);
22123
22124 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22125 + __set_fs(task_thread_info(next_p)->addr_limit);
22126 +#endif
22127 +
22128 /*
22129 * Load the per-thread Thread-Local Storage descriptor.
22130 */
22131 @@ -304,6 +309,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22132 */
22133 arch_end_context_switch(next_p);
22134
22135 + this_cpu_write(current_task, next_p);
22136 + this_cpu_write(current_tinfo, &next_p->tinfo);
22137 +
22138 /*
22139 * Restore %gs if needed (which is common)
22140 */
22141 @@ -312,8 +320,6 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22142
22143 switch_fpu_finish(next_p, fpu);
22144
22145 - this_cpu_write(current_task, next_p);
22146 -
22147 return prev_p;
22148 }
22149
22150 @@ -343,4 +349,3 @@ unsigned long get_wchan(struct task_struct *p)
22151 } while (count++ < 16);
22152 return 0;
22153 }
22154 -
22155 diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
22156 index 0f49677..fcbf88c 100644
22157 --- a/arch/x86/kernel/process_64.c
22158 +++ b/arch/x86/kernel/process_64.c
22159 @@ -152,10 +152,11 @@ int copy_thread(unsigned long clone_flags, unsigned long sp,
22160 struct pt_regs *childregs;
22161 struct task_struct *me = current;
22162
22163 - p->thread.sp0 = (unsigned long)task_stack_page(p) + THREAD_SIZE;
22164 + p->thread.sp0 = (unsigned long)task_stack_page(p) + THREAD_SIZE - 16;
22165 childregs = task_pt_regs(p);
22166 p->thread.sp = (unsigned long) childregs;
22167 p->thread.usersp = me->thread.usersp;
22168 + p->tinfo.lowest_stack = (unsigned long)task_stack_page(p);
22169 set_tsk_thread_flag(p, TIF_FORK);
22170 p->fpu_counter = 0;
22171 p->thread.io_bitmap_ptr = NULL;
22172 @@ -274,7 +275,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22173 struct thread_struct *prev = &prev_p->thread;
22174 struct thread_struct *next = &next_p->thread;
22175 int cpu = smp_processor_id();
22176 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
22177 + struct tss_struct *tss = init_tss + cpu;
22178 unsigned fsindex, gsindex;
22179 fpu_switch_t fpu;
22180
22181 @@ -356,10 +357,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22182 prev->usersp = this_cpu_read(old_rsp);
22183 this_cpu_write(old_rsp, next->usersp);
22184 this_cpu_write(current_task, next_p);
22185 + this_cpu_write(current_tinfo, &next_p->tinfo);
22186
22187 - this_cpu_write(kernel_stack,
22188 - (unsigned long)task_stack_page(next_p) +
22189 - THREAD_SIZE - KERNEL_STACK_OFFSET);
22190 + this_cpu_write(kernel_stack, next->sp0);
22191
22192 /*
22193 * Now maybe reload the debug registers and handle I/O bitmaps
22194 @@ -428,12 +428,11 @@ unsigned long get_wchan(struct task_struct *p)
22195 if (!p || p == current || p->state == TASK_RUNNING)
22196 return 0;
22197 stack = (unsigned long)task_stack_page(p);
22198 - if (p->thread.sp < stack || p->thread.sp >= stack+THREAD_SIZE)
22199 + if (p->thread.sp < stack || p->thread.sp > stack+THREAD_SIZE-16-sizeof(u64))
22200 return 0;
22201 fp = *(u64 *)(p->thread.sp);
22202 do {
22203 - if (fp < (unsigned long)stack ||
22204 - fp >= (unsigned long)stack+THREAD_SIZE)
22205 + if (fp < stack || fp > stack+THREAD_SIZE-16-sizeof(u64))
22206 return 0;
22207 ip = *(u64 *)(fp+8);
22208 if (!in_sched_functions(ip))
22209 diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c
22210 index 29a8120..a50b5ee 100644
22211 --- a/arch/x86/kernel/ptrace.c
22212 +++ b/arch/x86/kernel/ptrace.c
22213 @@ -184,14 +184,13 @@ unsigned long kernel_stack_pointer(struct pt_regs *regs)
22214 {
22215 unsigned long context = (unsigned long)regs & ~(THREAD_SIZE - 1);
22216 unsigned long sp = (unsigned long)&regs->sp;
22217 - struct thread_info *tinfo;
22218
22219 - if (context == (sp & ~(THREAD_SIZE - 1)))
22220 + if (context == ((sp + 8) & ~(THREAD_SIZE - 1)))
22221 return sp;
22222
22223 - tinfo = (struct thread_info *)context;
22224 - if (tinfo->previous_esp)
22225 - return tinfo->previous_esp;
22226 + sp = *(unsigned long *)context;
22227 + if (sp)
22228 + return sp;
22229
22230 return (unsigned long)regs;
22231 }
22232 @@ -588,7 +587,7 @@ static void ptrace_triggered(struct perf_event *bp,
22233 static unsigned long ptrace_get_dr7(struct perf_event *bp[])
22234 {
22235 int i;
22236 - int dr7 = 0;
22237 + unsigned long dr7 = 0;
22238 struct arch_hw_breakpoint *info;
22239
22240 for (i = 0; i < HBP_NUM; i++) {
22241 @@ -856,7 +855,7 @@ long arch_ptrace(struct task_struct *child, long request,
22242 unsigned long addr, unsigned long data)
22243 {
22244 int ret;
22245 - unsigned long __user *datap = (unsigned long __user *)data;
22246 + unsigned long __user *datap = (__force unsigned long __user *)data;
22247
22248 switch (request) {
22249 /* read the word at location addr in the USER area. */
22250 @@ -941,14 +940,14 @@ long arch_ptrace(struct task_struct *child, long request,
22251 if ((int) addr < 0)
22252 return -EIO;
22253 ret = do_get_thread_area(child, addr,
22254 - (struct user_desc __user *)data);
22255 + (__force struct user_desc __user *) data);
22256 break;
22257
22258 case PTRACE_SET_THREAD_AREA:
22259 if ((int) addr < 0)
22260 return -EIO;
22261 ret = do_set_thread_area(child, addr,
22262 - (struct user_desc __user *)data, 0);
22263 + (__force struct user_desc __user *) data, 0);
22264 break;
22265 #endif
22266
22267 @@ -1326,7 +1325,7 @@ long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
22268
22269 #ifdef CONFIG_X86_64
22270
22271 -static struct user_regset x86_64_regsets[] __read_mostly = {
22272 +static user_regset_no_const x86_64_regsets[] __read_only = {
22273 [REGSET_GENERAL] = {
22274 .core_note_type = NT_PRSTATUS,
22275 .n = sizeof(struct user_regs_struct) / sizeof(long),
22276 @@ -1367,7 +1366,7 @@ static const struct user_regset_view user_x86_64_view = {
22277 #endif /* CONFIG_X86_64 */
22278
22279 #if defined CONFIG_X86_32 || defined CONFIG_IA32_EMULATION
22280 -static struct user_regset x86_32_regsets[] __read_mostly = {
22281 +static user_regset_no_const x86_32_regsets[] __read_only = {
22282 [REGSET_GENERAL] = {
22283 .core_note_type = NT_PRSTATUS,
22284 .n = sizeof(struct user_regs_struct32) / sizeof(u32),
22285 @@ -1420,7 +1419,7 @@ static const struct user_regset_view user_x86_32_view = {
22286 */
22287 u64 xstate_fx_sw_bytes[USER_XSTATE_FX_SW_WORDS];
22288
22289 -void update_regset_xstate_info(unsigned int size, u64 xstate_mask)
22290 +void __init update_regset_xstate_info(unsigned int size, u64 xstate_mask)
22291 {
22292 #ifdef CONFIG_X86_64
22293 x86_64_regsets[REGSET_XSTATE].n = size / sizeof(u64);
22294 @@ -1455,7 +1454,7 @@ static void fill_sigtrap_info(struct task_struct *tsk,
22295 memset(info, 0, sizeof(*info));
22296 info->si_signo = SIGTRAP;
22297 info->si_code = si_code;
22298 - info->si_addr = user_mode_vm(regs) ? (void __user *)regs->ip : NULL;
22299 + info->si_addr = user_mode(regs) ? (__force void __user *)regs->ip : NULL;
22300 }
22301
22302 void user_single_step_siginfo(struct task_struct *tsk,
22303 @@ -1484,6 +1483,10 @@ void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs,
22304 # define IS_IA32 0
22305 #endif
22306
22307 +#ifdef CONFIG_GRKERNSEC_SETXID
22308 +extern void gr_delayed_cred_worker(void);
22309 +#endif
22310 +
22311 /*
22312 * We must return the syscall number to actually look up in the table.
22313 * This can be -1L to skip running any syscall at all.
22314 @@ -1494,6 +1497,11 @@ long syscall_trace_enter(struct pt_regs *regs)
22315
22316 user_exit();
22317
22318 +#ifdef CONFIG_GRKERNSEC_SETXID
22319 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
22320 + gr_delayed_cred_worker();
22321 +#endif
22322 +
22323 /*
22324 * If we stepped into a sysenter/syscall insn, it trapped in
22325 * kernel mode; do_debug() cleared TF and set TIF_SINGLESTEP.
22326 @@ -1549,6 +1557,11 @@ void syscall_trace_leave(struct pt_regs *regs)
22327 */
22328 user_exit();
22329
22330 +#ifdef CONFIG_GRKERNSEC_SETXID
22331 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
22332 + gr_delayed_cred_worker();
22333 +#endif
22334 +
22335 audit_syscall_exit(regs);
22336
22337 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
22338 diff --git a/arch/x86/kernel/pvclock.c b/arch/x86/kernel/pvclock.c
22339 index 2cb9470..ff1fd80 100644
22340 --- a/arch/x86/kernel/pvclock.c
22341 +++ b/arch/x86/kernel/pvclock.c
22342 @@ -43,11 +43,11 @@ unsigned long pvclock_tsc_khz(struct pvclock_vcpu_time_info *src)
22343 return pv_tsc_khz;
22344 }
22345
22346 -static atomic64_t last_value = ATOMIC64_INIT(0);
22347 +static atomic64_unchecked_t last_value = ATOMIC64_INIT(0);
22348
22349 void pvclock_resume(void)
22350 {
22351 - atomic64_set(&last_value, 0);
22352 + atomic64_set_unchecked(&last_value, 0);
22353 }
22354
22355 u8 pvclock_read_flags(struct pvclock_vcpu_time_info *src)
22356 @@ -92,11 +92,11 @@ cycle_t pvclock_clocksource_read(struct pvclock_vcpu_time_info *src)
22357 * updating at the same time, and one of them could be slightly behind,
22358 * making the assumption that last_value always go forward fail to hold.
22359 */
22360 - last = atomic64_read(&last_value);
22361 + last = atomic64_read_unchecked(&last_value);
22362 do {
22363 if (ret < last)
22364 return last;
22365 - last = atomic64_cmpxchg(&last_value, last, ret);
22366 + last = atomic64_cmpxchg_unchecked(&last_value, last, ret);
22367 } while (unlikely(last != ret));
22368
22369 return ret;
22370 diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c
22371 index 76fa1e9..abf09ea 100644
22372 --- a/arch/x86/kernel/reboot.c
22373 +++ b/arch/x86/kernel/reboot.c
22374 @@ -36,7 +36,7 @@ void (*pm_power_off)(void);
22375 EXPORT_SYMBOL(pm_power_off);
22376
22377 static const struct desc_ptr no_idt = {};
22378 -static int reboot_mode;
22379 +static unsigned short reboot_mode;
22380 enum reboot_type reboot_type = BOOT_ACPI;
22381 int reboot_force;
22382
22383 @@ -157,6 +157,11 @@ static int __init set_bios_reboot(const struct dmi_system_id *d)
22384
22385 void __noreturn machine_real_restart(unsigned int type)
22386 {
22387 +
22388 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF))
22389 + struct desc_struct *gdt;
22390 +#endif
22391 +
22392 local_irq_disable();
22393
22394 /*
22395 @@ -184,7 +189,29 @@ void __noreturn machine_real_restart(unsigned int type)
22396
22397 /* Jump to the identity-mapped low memory code */
22398 #ifdef CONFIG_X86_32
22399 - asm volatile("jmpl *%0" : :
22400 +
22401 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
22402 + gdt = get_cpu_gdt_table(smp_processor_id());
22403 + pax_open_kernel();
22404 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22405 + gdt[GDT_ENTRY_KERNEL_DS].type = 3;
22406 + gdt[GDT_ENTRY_KERNEL_DS].limit = 0xf;
22407 + loadsegment(ds, __KERNEL_DS);
22408 + loadsegment(es, __KERNEL_DS);
22409 + loadsegment(ss, __KERNEL_DS);
22410 +#endif
22411 +#ifdef CONFIG_PAX_KERNEXEC
22412 + gdt[GDT_ENTRY_KERNEL_CS].base0 = 0;
22413 + gdt[GDT_ENTRY_KERNEL_CS].base1 = 0;
22414 + gdt[GDT_ENTRY_KERNEL_CS].base2 = 0;
22415 + gdt[GDT_ENTRY_KERNEL_CS].limit0 = 0xffff;
22416 + gdt[GDT_ENTRY_KERNEL_CS].limit = 0xf;
22417 + gdt[GDT_ENTRY_KERNEL_CS].g = 1;
22418 +#endif
22419 + pax_close_kernel();
22420 +#endif
22421 +
22422 + asm volatile("ljmpl *%0" : :
22423 "rm" (real_mode_header->machine_real_restart_asm),
22424 "a" (type));
22425 #else
22426 @@ -531,7 +558,7 @@ void __attribute__((weak)) mach_reboot_fixups(void)
22427 * try to force a triple fault and then cycle between hitting the keyboard
22428 * controller and doing that
22429 */
22430 -static void native_machine_emergency_restart(void)
22431 +static void __noreturn native_machine_emergency_restart(void)
22432 {
22433 int i;
22434 int attempt = 0;
22435 @@ -654,13 +681,13 @@ void native_machine_shutdown(void)
22436 #endif
22437 }
22438
22439 -static void __machine_emergency_restart(int emergency)
22440 +static void __noreturn __machine_emergency_restart(int emergency)
22441 {
22442 reboot_emergency = emergency;
22443 machine_ops.emergency_restart();
22444 }
22445
22446 -static void native_machine_restart(char *__unused)
22447 +static void __noreturn native_machine_restart(char *__unused)
22448 {
22449 pr_notice("machine restart\n");
22450
22451 @@ -669,7 +696,7 @@ static void native_machine_restart(char *__unused)
22452 __machine_emergency_restart(0);
22453 }
22454
22455 -static void native_machine_halt(void)
22456 +static void __noreturn native_machine_halt(void)
22457 {
22458 /* Stop other cpus and apics */
22459 machine_shutdown();
22460 @@ -679,7 +706,7 @@ static void native_machine_halt(void)
22461 stop_this_cpu(NULL);
22462 }
22463
22464 -static void native_machine_power_off(void)
22465 +static void __noreturn native_machine_power_off(void)
22466 {
22467 if (pm_power_off) {
22468 if (!reboot_force)
22469 @@ -688,9 +715,10 @@ static void native_machine_power_off(void)
22470 }
22471 /* A fallback in case there is no PM info available */
22472 tboot_shutdown(TB_SHUTDOWN_HALT);
22473 + unreachable();
22474 }
22475
22476 -struct machine_ops machine_ops = {
22477 +struct machine_ops machine_ops __read_only = {
22478 .power_off = native_machine_power_off,
22479 .shutdown = native_machine_shutdown,
22480 .emergency_restart = native_machine_emergency_restart,
22481 diff --git a/arch/x86/kernel/relocate_kernel_64.S b/arch/x86/kernel/relocate_kernel_64.S
22482 index 7a6f3b3..bed145d7 100644
22483 --- a/arch/x86/kernel/relocate_kernel_64.S
22484 +++ b/arch/x86/kernel/relocate_kernel_64.S
22485 @@ -11,6 +11,7 @@
22486 #include <asm/kexec.h>
22487 #include <asm/processor-flags.h>
22488 #include <asm/pgtable_types.h>
22489 +#include <asm/alternative-asm.h>
22490
22491 /*
22492 * Must be relocatable PIC code callable as a C function
22493 @@ -160,13 +161,14 @@ identity_mapped:
22494 xorq %rbp, %rbp
22495 xorq %r8, %r8
22496 xorq %r9, %r9
22497 - xorq %r10, %r9
22498 + xorq %r10, %r10
22499 xorq %r11, %r11
22500 xorq %r12, %r12
22501 xorq %r13, %r13
22502 xorq %r14, %r14
22503 xorq %r15, %r15
22504
22505 + pax_force_retaddr 0, 1
22506 ret
22507
22508 1:
22509 diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
22510 index fae9134..b7d4a57 100644
22511 --- a/arch/x86/kernel/setup.c
22512 +++ b/arch/x86/kernel/setup.c
22513 @@ -111,6 +111,7 @@
22514 #include <asm/mce.h>
22515 #include <asm/alternative.h>
22516 #include <asm/prom.h>
22517 +#include <asm/boot.h>
22518
22519 /*
22520 * max_low_pfn_mapped: highest direct mapped pfn under 4GB
22521 @@ -447,7 +448,7 @@ static void __init parse_setup_data(void)
22522
22523 switch (data->type) {
22524 case SETUP_E820_EXT:
22525 - parse_e820_ext(data);
22526 + parse_e820_ext((struct setup_data __force_kernel *)data);
22527 break;
22528 case SETUP_DTB:
22529 add_dtb(pa_data);
22530 @@ -774,7 +775,7 @@ static void __init trim_bios_range(void)
22531 * area (640->1Mb) as ram even though it is not.
22532 * take them out.
22533 */
22534 - e820_remove_range(BIOS_BEGIN, BIOS_END - BIOS_BEGIN, E820_RAM, 1);
22535 + e820_remove_range(ISA_START_ADDRESS, ISA_END_ADDRESS - ISA_START_ADDRESS, E820_RAM, 1);
22536
22537 sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map);
22538 }
22539 @@ -844,8 +845,12 @@ static void __init trim_low_memory_range(void)
22540
22541 void __init setup_arch(char **cmdline_p)
22542 {
22543 +#ifdef CONFIG_X86_32
22544 + memblock_reserve(LOAD_PHYSICAL_ADDR, __pa_symbol(__bss_stop) - ____LOAD_PHYSICAL_ADDR);
22545 +#else
22546 memblock_reserve(__pa_symbol(_text),
22547 (unsigned long)__bss_stop - (unsigned long)_text);
22548 +#endif
22549
22550 early_reserve_initrd();
22551
22552 @@ -937,14 +942,14 @@ void __init setup_arch(char **cmdline_p)
22553
22554 if (!boot_params.hdr.root_flags)
22555 root_mountflags &= ~MS_RDONLY;
22556 - init_mm.start_code = (unsigned long) _text;
22557 - init_mm.end_code = (unsigned long) _etext;
22558 + init_mm.start_code = ktla_ktva((unsigned long) _text);
22559 + init_mm.end_code = ktla_ktva((unsigned long) _etext);
22560 init_mm.end_data = (unsigned long) _edata;
22561 init_mm.brk = _brk_end;
22562
22563 - code_resource.start = __pa_symbol(_text);
22564 - code_resource.end = __pa_symbol(_etext)-1;
22565 - data_resource.start = __pa_symbol(_etext);
22566 + code_resource.start = __pa_symbol(ktla_ktva(_text));
22567 + code_resource.end = __pa_symbol(ktla_ktva(_etext))-1;
22568 + data_resource.start = __pa_symbol(_sdata);
22569 data_resource.end = __pa_symbol(_edata)-1;
22570 bss_resource.start = __pa_symbol(__bss_start);
22571 bss_resource.end = __pa_symbol(__bss_stop)-1;
22572 diff --git a/arch/x86/kernel/setup_percpu.c b/arch/x86/kernel/setup_percpu.c
22573 index 5cdff03..80fa283 100644
22574 --- a/arch/x86/kernel/setup_percpu.c
22575 +++ b/arch/x86/kernel/setup_percpu.c
22576 @@ -21,19 +21,17 @@
22577 #include <asm/cpu.h>
22578 #include <asm/stackprotector.h>
22579
22580 -DEFINE_PER_CPU_READ_MOSTLY(int, cpu_number);
22581 +#ifdef CONFIG_SMP
22582 +DEFINE_PER_CPU_READ_MOSTLY(unsigned int, cpu_number);
22583 EXPORT_PER_CPU_SYMBOL(cpu_number);
22584 +#endif
22585
22586 -#ifdef CONFIG_X86_64
22587 #define BOOT_PERCPU_OFFSET ((unsigned long)__per_cpu_load)
22588 -#else
22589 -#define BOOT_PERCPU_OFFSET 0
22590 -#endif
22591
22592 DEFINE_PER_CPU(unsigned long, this_cpu_off) = BOOT_PERCPU_OFFSET;
22593 EXPORT_PER_CPU_SYMBOL(this_cpu_off);
22594
22595 -unsigned long __per_cpu_offset[NR_CPUS] __read_mostly = {
22596 +unsigned long __per_cpu_offset[NR_CPUS] __read_only = {
22597 [0 ... NR_CPUS-1] = BOOT_PERCPU_OFFSET,
22598 };
22599 EXPORT_SYMBOL(__per_cpu_offset);
22600 @@ -66,7 +64,7 @@ static bool __init pcpu_need_numa(void)
22601 {
22602 #ifdef CONFIG_NEED_MULTIPLE_NODES
22603 pg_data_t *last = NULL;
22604 - unsigned int cpu;
22605 + int cpu;
22606
22607 for_each_possible_cpu(cpu) {
22608 int node = early_cpu_to_node(cpu);
22609 @@ -155,10 +153,10 @@ static inline void setup_percpu_segment(int cpu)
22610 {
22611 #ifdef CONFIG_X86_32
22612 struct desc_struct gdt;
22613 + unsigned long base = per_cpu_offset(cpu);
22614
22615 - pack_descriptor(&gdt, per_cpu_offset(cpu), 0xFFFFF,
22616 - 0x2 | DESCTYPE_S, 0x8);
22617 - gdt.s = 1;
22618 + pack_descriptor(&gdt, base, (VMALLOC_END - base - 1) >> PAGE_SHIFT,
22619 + 0x83 | DESCTYPE_S, 0xC);
22620 write_gdt_entry(get_cpu_gdt_table(cpu),
22621 GDT_ENTRY_PERCPU, &gdt, DESCTYPE_S);
22622 #endif
22623 @@ -219,6 +217,11 @@ void __init setup_per_cpu_areas(void)
22624 /* alrighty, percpu areas up and running */
22625 delta = (unsigned long)pcpu_base_addr - (unsigned long)__per_cpu_start;
22626 for_each_possible_cpu(cpu) {
22627 +#ifdef CONFIG_CC_STACKPROTECTOR
22628 +#ifdef CONFIG_X86_32
22629 + unsigned long canary = per_cpu(stack_canary.canary, cpu);
22630 +#endif
22631 +#endif
22632 per_cpu_offset(cpu) = delta + pcpu_unit_offsets[cpu];
22633 per_cpu(this_cpu_off, cpu) = per_cpu_offset(cpu);
22634 per_cpu(cpu_number, cpu) = cpu;
22635 @@ -259,6 +262,12 @@ void __init setup_per_cpu_areas(void)
22636 */
22637 set_cpu_numa_node(cpu, early_cpu_to_node(cpu));
22638 #endif
22639 +#ifdef CONFIG_CC_STACKPROTECTOR
22640 +#ifdef CONFIG_X86_32
22641 + if (!cpu)
22642 + per_cpu(stack_canary.canary, cpu) = canary;
22643 +#endif
22644 +#endif
22645 /*
22646 * Up to this point, the boot CPU has been using .init.data
22647 * area. Reload any changed state for the boot CPU.
22648 diff --git a/arch/x86/kernel/signal.c b/arch/x86/kernel/signal.c
22649 index 6956299..f20beae 100644
22650 --- a/arch/x86/kernel/signal.c
22651 +++ b/arch/x86/kernel/signal.c
22652 @@ -196,7 +196,7 @@ static unsigned long align_sigframe(unsigned long sp)
22653 * Align the stack pointer according to the i386 ABI,
22654 * i.e. so that on function entry ((sp + 4) & 15) == 0.
22655 */
22656 - sp = ((sp + 4) & -16ul) - 4;
22657 + sp = ((sp - 12) & -16ul) - 4;
22658 #else /* !CONFIG_X86_32 */
22659 sp = round_down(sp, 16) - 8;
22660 #endif
22661 @@ -304,9 +304,9 @@ __setup_frame(int sig, struct ksignal *ksig, sigset_t *set,
22662 }
22663
22664 if (current->mm->context.vdso)
22665 - restorer = VDSO32_SYMBOL(current->mm->context.vdso, sigreturn);
22666 + restorer = (__force void __user *)VDSO32_SYMBOL(current->mm->context.vdso, sigreturn);
22667 else
22668 - restorer = &frame->retcode;
22669 + restorer = (void __user *)&frame->retcode;
22670 if (ksig->ka.sa.sa_flags & SA_RESTORER)
22671 restorer = ksig->ka.sa.sa_restorer;
22672
22673 @@ -320,7 +320,7 @@ __setup_frame(int sig, struct ksignal *ksig, sigset_t *set,
22674 * reasons and because gdb uses it as a signature to notice
22675 * signal handler stack frames.
22676 */
22677 - err |= __put_user(*((u64 *)&retcode), (u64 *)frame->retcode);
22678 + err |= __put_user(*((u64 *)&retcode), (u64 __user *)frame->retcode);
22679
22680 if (err)
22681 return -EFAULT;
22682 @@ -367,7 +367,10 @@ static int __setup_rt_frame(int sig, struct ksignal *ksig,
22683 err |= __save_altstack(&frame->uc.uc_stack, regs->sp);
22684
22685 /* Set up to return from userspace. */
22686 - restorer = VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
22687 + if (current->mm->context.vdso)
22688 + restorer = (__force void __user *)VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
22689 + else
22690 + restorer = (void __user *)&frame->retcode;
22691 if (ksig->ka.sa.sa_flags & SA_RESTORER)
22692 restorer = ksig->ka.sa.sa_restorer;
22693 put_user_ex(restorer, &frame->pretcode);
22694 @@ -379,7 +382,7 @@ static int __setup_rt_frame(int sig, struct ksignal *ksig,
22695 * reasons and because gdb uses it as a signature to notice
22696 * signal handler stack frames.
22697 */
22698 - put_user_ex(*((u64 *)&rt_retcode), (u64 *)frame->retcode);
22699 + put_user_ex(*((u64 *)&rt_retcode), (u64 __user *)frame->retcode);
22700 } put_user_catch(err);
22701
22702 err |= copy_siginfo_to_user(&frame->info, &ksig->info);
22703 @@ -615,7 +618,12 @@ setup_rt_frame(struct ksignal *ksig, struct pt_regs *regs)
22704 {
22705 int usig = signr_convert(ksig->sig);
22706 sigset_t *set = sigmask_to_save();
22707 - compat_sigset_t *cset = (compat_sigset_t *) set;
22708 + sigset_t sigcopy;
22709 + compat_sigset_t *cset;
22710 +
22711 + sigcopy = *set;
22712 +
22713 + cset = (compat_sigset_t *) &sigcopy;
22714
22715 /* Set up the stack frame */
22716 if (is_ia32_frame()) {
22717 @@ -626,7 +634,7 @@ setup_rt_frame(struct ksignal *ksig, struct pt_regs *regs)
22718 } else if (is_x32_frame()) {
22719 return x32_setup_rt_frame(ksig, cset, regs);
22720 } else {
22721 - return __setup_rt_frame(ksig->sig, ksig, set, regs);
22722 + return __setup_rt_frame(ksig->sig, ksig, &sigcopy, regs);
22723 }
22724 }
22725
22726 diff --git a/arch/x86/kernel/smp.c b/arch/x86/kernel/smp.c
22727 index 48d2b7d..90d328a 100644
22728 --- a/arch/x86/kernel/smp.c
22729 +++ b/arch/x86/kernel/smp.c
22730 @@ -285,7 +285,7 @@ static int __init nonmi_ipi_setup(char *str)
22731
22732 __setup("nonmi_ipi", nonmi_ipi_setup);
22733
22734 -struct smp_ops smp_ops = {
22735 +struct smp_ops smp_ops __read_only = {
22736 .smp_prepare_boot_cpu = native_smp_prepare_boot_cpu,
22737 .smp_prepare_cpus = native_smp_prepare_cpus,
22738 .smp_cpus_done = native_smp_cpus_done,
22739 diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
22740 index 9f190a2..90a0688 100644
22741 --- a/arch/x86/kernel/smpboot.c
22742 +++ b/arch/x86/kernel/smpboot.c
22743 @@ -748,6 +748,7 @@ static int __cpuinit do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
22744 idle->thread.sp = (unsigned long) (((struct pt_regs *)
22745 (THREAD_SIZE + task_stack_page(idle))) - 1);
22746 per_cpu(current_task, cpu) = idle;
22747 + per_cpu(current_tinfo, cpu) = &idle->tinfo;
22748
22749 #ifdef CONFIG_X86_32
22750 /* Stack for startup_32 can be just as for start_secondary onwards */
22751 @@ -755,11 +756,13 @@ static int __cpuinit do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
22752 #else
22753 clear_tsk_thread_flag(idle, TIF_FORK);
22754 initial_gs = per_cpu_offset(cpu);
22755 - per_cpu(kernel_stack, cpu) =
22756 - (unsigned long)task_stack_page(idle) -
22757 - KERNEL_STACK_OFFSET + THREAD_SIZE;
22758 + per_cpu(kernel_stack, cpu) = (unsigned long)task_stack_page(idle) - 16 + THREAD_SIZE;
22759 #endif
22760 +
22761 + pax_open_kernel();
22762 early_gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu);
22763 + pax_close_kernel();
22764 +
22765 initial_code = (unsigned long)start_secondary;
22766 stack_start = idle->thread.sp;
22767
22768 @@ -908,6 +911,15 @@ int __cpuinit native_cpu_up(unsigned int cpu, struct task_struct *tidle)
22769 /* the FPU context is blank, nobody can own it */
22770 __cpu_disable_lazy_restore(cpu);
22771
22772 +#ifdef CONFIG_PAX_PER_CPU_PGD
22773 + clone_pgd_range(get_cpu_pgd(cpu) + KERNEL_PGD_BOUNDARY,
22774 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
22775 + KERNEL_PGD_PTRS);
22776 +#endif
22777 +
22778 + /* the FPU context is blank, nobody can own it */
22779 + __cpu_disable_lazy_restore(cpu);
22780 +
22781 err = do_boot_cpu(apicid, cpu, tidle);
22782 if (err) {
22783 pr_debug("do_boot_cpu failed %d\n", err);
22784 diff --git a/arch/x86/kernel/step.c b/arch/x86/kernel/step.c
22785 index 9b4d51d..5d28b58 100644
22786 --- a/arch/x86/kernel/step.c
22787 +++ b/arch/x86/kernel/step.c
22788 @@ -27,10 +27,10 @@ unsigned long convert_ip_to_linear(struct task_struct *child, struct pt_regs *re
22789 struct desc_struct *desc;
22790 unsigned long base;
22791
22792 - seg &= ~7UL;
22793 + seg >>= 3;
22794
22795 mutex_lock(&child->mm->context.lock);
22796 - if (unlikely((seg >> 3) >= child->mm->context.size))
22797 + if (unlikely(seg >= child->mm->context.size))
22798 addr = -1L; /* bogus selector, access would fault */
22799 else {
22800 desc = child->mm->context.ldt + seg;
22801 @@ -42,7 +42,8 @@ unsigned long convert_ip_to_linear(struct task_struct *child, struct pt_regs *re
22802 addr += base;
22803 }
22804 mutex_unlock(&child->mm->context.lock);
22805 - }
22806 + } else if (seg == __KERNEL_CS || seg == __KERNEXEC_KERNEL_CS)
22807 + addr = ktla_ktva(addr);
22808
22809 return addr;
22810 }
22811 @@ -53,6 +54,9 @@ static int is_setting_trap_flag(struct task_struct *child, struct pt_regs *regs)
22812 unsigned char opcode[15];
22813 unsigned long addr = convert_ip_to_linear(child, regs);
22814
22815 + if (addr == -EINVAL)
22816 + return 0;
22817 +
22818 copied = access_process_vm(child, addr, opcode, sizeof(opcode), 0);
22819 for (i = 0; i < copied; i++) {
22820 switch (opcode[i]) {
22821 diff --git a/arch/x86/kernel/sys_i386_32.c b/arch/x86/kernel/sys_i386_32.c
22822 new file mode 100644
22823 index 0000000..207bec6
22824 --- /dev/null
22825 +++ b/arch/x86/kernel/sys_i386_32.c
22826 @@ -0,0 +1,250 @@
22827 +/*
22828 + * This file contains various random system calls that
22829 + * have a non-standard calling sequence on the Linux/i386
22830 + * platform.
22831 + */
22832 +
22833 +#include <linux/errno.h>
22834 +#include <linux/sched.h>
22835 +#include <linux/mm.h>
22836 +#include <linux/fs.h>
22837 +#include <linux/smp.h>
22838 +#include <linux/sem.h>
22839 +#include <linux/msg.h>
22840 +#include <linux/shm.h>
22841 +#include <linux/stat.h>
22842 +#include <linux/syscalls.h>
22843 +#include <linux/mman.h>
22844 +#include <linux/file.h>
22845 +#include <linux/utsname.h>
22846 +#include <linux/ipc.h>
22847 +
22848 +#include <linux/uaccess.h>
22849 +#include <linux/unistd.h>
22850 +
22851 +#include <asm/syscalls.h>
22852 +
22853 +int i386_mmap_check(unsigned long addr, unsigned long len, unsigned long flags)
22854 +{
22855 + unsigned long pax_task_size = TASK_SIZE;
22856 +
22857 +#ifdef CONFIG_PAX_SEGMEXEC
22858 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC)
22859 + pax_task_size = SEGMEXEC_TASK_SIZE;
22860 +#endif
22861 +
22862 + if (flags & MAP_FIXED)
22863 + if (len > pax_task_size || addr > pax_task_size - len)
22864 + return -EINVAL;
22865 +
22866 + return 0;
22867 +}
22868 +
22869 +unsigned long
22870 +arch_get_unmapped_area(struct file *filp, unsigned long addr,
22871 + unsigned long len, unsigned long pgoff, unsigned long flags)
22872 +{
22873 + struct mm_struct *mm = current->mm;
22874 + struct vm_area_struct *vma;
22875 + unsigned long start_addr, pax_task_size = TASK_SIZE;
22876 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
22877 +
22878 +#ifdef CONFIG_PAX_SEGMEXEC
22879 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
22880 + pax_task_size = SEGMEXEC_TASK_SIZE;
22881 +#endif
22882 +
22883 + pax_task_size -= PAGE_SIZE;
22884 +
22885 + if (len > pax_task_size)
22886 + return -ENOMEM;
22887 +
22888 + if (flags & MAP_FIXED)
22889 + return addr;
22890 +
22891 +#ifdef CONFIG_PAX_RANDMMAP
22892 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
22893 +#endif
22894 +
22895 + if (addr) {
22896 + addr = PAGE_ALIGN(addr);
22897 + if (pax_task_size - len >= addr) {
22898 + vma = find_vma(mm, addr);
22899 + if (check_heap_stack_gap(vma, addr, len, offset))
22900 + return addr;
22901 + }
22902 + }
22903 + if (len > mm->cached_hole_size) {
22904 + start_addr = addr = mm->free_area_cache;
22905 + } else {
22906 + start_addr = addr = mm->mmap_base;
22907 + mm->cached_hole_size = 0;
22908 + }
22909 +
22910 +#ifdef CONFIG_PAX_PAGEEXEC
22911 + if (!(__supported_pte_mask & _PAGE_NX) && (mm->pax_flags & MF_PAX_PAGEEXEC) && (flags & MAP_EXECUTABLE) && start_addr >= mm->mmap_base) {
22912 + start_addr = 0x00110000UL;
22913 +
22914 +#ifdef CONFIG_PAX_RANDMMAP
22915 + if (mm->pax_flags & MF_PAX_RANDMMAP)
22916 + start_addr += mm->delta_mmap & 0x03FFF000UL;
22917 +#endif
22918 +
22919 + if (mm->start_brk <= start_addr && start_addr < mm->mmap_base)
22920 + start_addr = addr = mm->mmap_base;
22921 + else
22922 + addr = start_addr;
22923 + }
22924 +#endif
22925 +
22926 +full_search:
22927 + for (vma = find_vma(mm, addr); ; vma = vma->vm_next) {
22928 + /* At this point: (!vma || addr < vma->vm_end). */
22929 + if (pax_task_size - len < addr) {
22930 + /*
22931 + * Start a new search - just in case we missed
22932 + * some holes.
22933 + */
22934 + if (start_addr != mm->mmap_base) {
22935 + start_addr = addr = mm->mmap_base;
22936 + mm->cached_hole_size = 0;
22937 + goto full_search;
22938 + }
22939 + return -ENOMEM;
22940 + }
22941 + if (check_heap_stack_gap(vma, addr, len, offset))
22942 + break;
22943 + if (addr + mm->cached_hole_size < vma->vm_start)
22944 + mm->cached_hole_size = vma->vm_start - addr;
22945 + addr = vma->vm_end;
22946 + if (mm->start_brk <= addr && addr < mm->mmap_base) {
22947 + start_addr = addr = mm->mmap_base;
22948 + mm->cached_hole_size = 0;
22949 + goto full_search;
22950 + }
22951 + }
22952 +
22953 + /*
22954 + * Remember the place where we stopped the search:
22955 + */
22956 + mm->free_area_cache = addr + len;
22957 + return addr;
22958 +}
22959 +
22960 +unsigned long
22961 +arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
22962 + const unsigned long len, const unsigned long pgoff,
22963 + const unsigned long flags)
22964 +{
22965 + struct vm_area_struct *vma;
22966 + struct mm_struct *mm = current->mm;
22967 + unsigned long base = mm->mmap_base, addr = addr0, pax_task_size = TASK_SIZE;
22968 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
22969 +
22970 +#ifdef CONFIG_PAX_SEGMEXEC
22971 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
22972 + pax_task_size = SEGMEXEC_TASK_SIZE;
22973 +#endif
22974 +
22975 + pax_task_size -= PAGE_SIZE;
22976 +
22977 + /* requested length too big for entire address space */
22978 + if (len > pax_task_size)
22979 + return -ENOMEM;
22980 +
22981 + if (flags & MAP_FIXED)
22982 + return addr;
22983 +
22984 +#ifdef CONFIG_PAX_PAGEEXEC
22985 + if (!(__supported_pte_mask & _PAGE_NX) && (mm->pax_flags & MF_PAX_PAGEEXEC) && (flags & MAP_EXECUTABLE))
22986 + goto bottomup;
22987 +#endif
22988 +
22989 +#ifdef CONFIG_PAX_RANDMMAP
22990 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
22991 +#endif
22992 +
22993 + /* requesting a specific address */
22994 + if (addr) {
22995 + addr = PAGE_ALIGN(addr);
22996 + if (pax_task_size - len >= addr) {
22997 + vma = find_vma(mm, addr);
22998 + if (check_heap_stack_gap(vma, addr, len, offset))
22999 + return addr;
23000 + }
23001 + }
23002 +
23003 + /* check if free_area_cache is useful for us */
23004 + if (len <= mm->cached_hole_size) {
23005 + mm->cached_hole_size = 0;
23006 + mm->free_area_cache = mm->mmap_base;
23007 + }
23008 +
23009 + /* either no address requested or can't fit in requested address hole */
23010 + addr = mm->free_area_cache;
23011 +
23012 + /* make sure it can fit in the remaining address space */
23013 + if (addr > len) {
23014 + vma = find_vma(mm, addr-len);
23015 + if (check_heap_stack_gap(vma, addr - len, len, offset))
23016 + /* remember the address as a hint for next time */
23017 + return (mm->free_area_cache = addr-len);
23018 + }
23019 +
23020 + if (mm->mmap_base < len)
23021 + goto bottomup;
23022 +
23023 + addr = mm->mmap_base-len;
23024 +
23025 + do {
23026 + /*
23027 + * Lookup failure means no vma is above this address,
23028 + * else if new region fits below vma->vm_start,
23029 + * return with success:
23030 + */
23031 + vma = find_vma(mm, addr);
23032 + if (check_heap_stack_gap(vma, addr, len, offset))
23033 + /* remember the address as a hint for next time */
23034 + return (mm->free_area_cache = addr);
23035 +
23036 + /* remember the largest hole we saw so far */
23037 + if (addr + mm->cached_hole_size < vma->vm_start)
23038 + mm->cached_hole_size = vma->vm_start - addr;
23039 +
23040 + /* try just below the current vma->vm_start */
23041 + addr = skip_heap_stack_gap(vma, len, offset);
23042 + } while (!IS_ERR_VALUE(addr));
23043 +
23044 +bottomup:
23045 + /*
23046 + * A failed mmap() very likely causes application failure,
23047 + * so fall back to the bottom-up function here. This scenario
23048 + * can happen with large stack limits and large mmap()
23049 + * allocations.
23050 + */
23051 +
23052 +#ifdef CONFIG_PAX_SEGMEXEC
23053 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
23054 + mm->mmap_base = SEGMEXEC_TASK_UNMAPPED_BASE;
23055 + else
23056 +#endif
23057 +
23058 + mm->mmap_base = TASK_UNMAPPED_BASE;
23059 +
23060 +#ifdef CONFIG_PAX_RANDMMAP
23061 + if (mm->pax_flags & MF_PAX_RANDMMAP)
23062 + mm->mmap_base += mm->delta_mmap;
23063 +#endif
23064 +
23065 + mm->free_area_cache = mm->mmap_base;
23066 + mm->cached_hole_size = ~0UL;
23067 + addr = arch_get_unmapped_area(filp, addr0, len, pgoff, flags);
23068 + /*
23069 + * Restore the topdown base:
23070 + */
23071 + mm->mmap_base = base;
23072 + mm->free_area_cache = base;
23073 + mm->cached_hole_size = ~0UL;
23074 +
23075 + return addr;
23076 +}
23077 diff --git a/arch/x86/kernel/sys_x86_64.c b/arch/x86/kernel/sys_x86_64.c
23078 index dbded5a..ace2781 100644
23079 --- a/arch/x86/kernel/sys_x86_64.c
23080 +++ b/arch/x86/kernel/sys_x86_64.c
23081 @@ -81,8 +81,8 @@ out:
23082 return error;
23083 }
23084
23085 -static void find_start_end(unsigned long flags, unsigned long *begin,
23086 - unsigned long *end)
23087 +static void find_start_end(struct mm_struct *mm, unsigned long flags,
23088 + unsigned long *begin, unsigned long *end)
23089 {
23090 if (!test_thread_flag(TIF_ADDR32) && (flags & MAP_32BIT)) {
23091 unsigned long new_begin;
23092 @@ -101,7 +101,7 @@ static void find_start_end(unsigned long flags, unsigned long *begin,
23093 *begin = new_begin;
23094 }
23095 } else {
23096 - *begin = TASK_UNMAPPED_BASE;
23097 + *begin = mm->mmap_base;
23098 *end = TASK_SIZE;
23099 }
23100 }
23101 @@ -114,20 +114,24 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
23102 struct vm_area_struct *vma;
23103 struct vm_unmapped_area_info info;
23104 unsigned long begin, end;
23105 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
23106
23107 if (flags & MAP_FIXED)
23108 return addr;
23109
23110 - find_start_end(flags, &begin, &end);
23111 + find_start_end(mm, flags, &begin, &end);
23112
23113 if (len > end)
23114 return -ENOMEM;
23115
23116 +#ifdef CONFIG_PAX_RANDMMAP
23117 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
23118 +#endif
23119 +
23120 if (addr) {
23121 addr = PAGE_ALIGN(addr);
23122 vma = find_vma(mm, addr);
23123 - if (end - len >= addr &&
23124 - (!vma || addr + len <= vma->vm_start))
23125 + if (end - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
23126 return addr;
23127 }
23128
23129 @@ -137,6 +141,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
23130 info.high_limit = end;
23131 info.align_mask = filp ? get_align_mask() : 0;
23132 info.align_offset = pgoff << PAGE_SHIFT;
23133 + info.threadstack_offset = offset;
23134 return vm_unmapped_area(&info);
23135 }
23136
23137 @@ -149,6 +154,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
23138 struct mm_struct *mm = current->mm;
23139 unsigned long addr = addr0;
23140 struct vm_unmapped_area_info info;
23141 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
23142
23143 /* requested length too big for entire address space */
23144 if (len > TASK_SIZE)
23145 @@ -161,12 +167,15 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
23146 if (!test_thread_flag(TIF_ADDR32) && (flags & MAP_32BIT))
23147 goto bottomup;
23148
23149 +#ifdef CONFIG_PAX_RANDMMAP
23150 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
23151 +#endif
23152 +
23153 /* requesting a specific address */
23154 if (addr) {
23155 addr = PAGE_ALIGN(addr);
23156 vma = find_vma(mm, addr);
23157 - if (TASK_SIZE - len >= addr &&
23158 - (!vma || addr + len <= vma->vm_start))
23159 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
23160 return addr;
23161 }
23162
23163 @@ -176,6 +185,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
23164 info.high_limit = mm->mmap_base;
23165 info.align_mask = filp ? get_align_mask() : 0;
23166 info.align_offset = pgoff << PAGE_SHIFT;
23167 + info.threadstack_offset = offset;
23168 addr = vm_unmapped_area(&info);
23169 if (!(addr & ~PAGE_MASK))
23170 return addr;
23171 diff --git a/arch/x86/kernel/tboot.c b/arch/x86/kernel/tboot.c
23172 index f84fe00..f41d9f1 100644
23173 --- a/arch/x86/kernel/tboot.c
23174 +++ b/arch/x86/kernel/tboot.c
23175 @@ -220,7 +220,7 @@ static int tboot_setup_sleep(void)
23176
23177 void tboot_shutdown(u32 shutdown_type)
23178 {
23179 - void (*shutdown)(void);
23180 + void (* __noreturn shutdown)(void);
23181
23182 if (!tboot_enabled())
23183 return;
23184 @@ -242,7 +242,7 @@ void tboot_shutdown(u32 shutdown_type)
23185
23186 switch_to_tboot_pt();
23187
23188 - shutdown = (void(*)(void))(unsigned long)tboot->shutdown_entry;
23189 + shutdown = (void *)tboot->shutdown_entry;
23190 shutdown();
23191
23192 /* should not reach here */
23193 @@ -300,7 +300,7 @@ static int tboot_sleep(u8 sleep_state, u32 pm1a_control, u32 pm1b_control)
23194 return 0;
23195 }
23196
23197 -static atomic_t ap_wfs_count;
23198 +static atomic_unchecked_t ap_wfs_count;
23199
23200 static int tboot_wait_for_aps(int num_aps)
23201 {
23202 @@ -324,16 +324,16 @@ static int __cpuinit tboot_cpu_callback(struct notifier_block *nfb,
23203 {
23204 switch (action) {
23205 case CPU_DYING:
23206 - atomic_inc(&ap_wfs_count);
23207 + atomic_inc_unchecked(&ap_wfs_count);
23208 if (num_online_cpus() == 1)
23209 - if (tboot_wait_for_aps(atomic_read(&ap_wfs_count)))
23210 + if (tboot_wait_for_aps(atomic_read_unchecked(&ap_wfs_count)))
23211 return NOTIFY_BAD;
23212 break;
23213 }
23214 return NOTIFY_OK;
23215 }
23216
23217 -static struct notifier_block tboot_cpu_notifier __cpuinitdata =
23218 +static struct notifier_block tboot_cpu_notifier =
23219 {
23220 .notifier_call = tboot_cpu_callback,
23221 };
23222 @@ -345,7 +345,7 @@ static __init int tboot_late_init(void)
23223
23224 tboot_create_trampoline();
23225
23226 - atomic_set(&ap_wfs_count, 0);
23227 + atomic_set_unchecked(&ap_wfs_count, 0);
23228 register_hotcpu_notifier(&tboot_cpu_notifier);
23229
23230 acpi_os_set_prepare_sleep(&tboot_sleep);
23231 diff --git a/arch/x86/kernel/time.c b/arch/x86/kernel/time.c
23232 index 24d3c91..d06b473 100644
23233 --- a/arch/x86/kernel/time.c
23234 +++ b/arch/x86/kernel/time.c
23235 @@ -30,9 +30,9 @@ unsigned long profile_pc(struct pt_regs *regs)
23236 {
23237 unsigned long pc = instruction_pointer(regs);
23238
23239 - if (!user_mode_vm(regs) && in_lock_functions(pc)) {
23240 + if (!user_mode(regs) && in_lock_functions(pc)) {
23241 #ifdef CONFIG_FRAME_POINTER
23242 - return *(unsigned long *)(regs->bp + sizeof(long));
23243 + return ktla_ktva(*(unsigned long *)(regs->bp + sizeof(long)));
23244 #else
23245 unsigned long *sp =
23246 (unsigned long *)kernel_stack_pointer(regs);
23247 @@ -41,11 +41,17 @@ unsigned long profile_pc(struct pt_regs *regs)
23248 * or above a saved flags. Eflags has bits 22-31 zero,
23249 * kernel addresses don't.
23250 */
23251 +
23252 +#ifdef CONFIG_PAX_KERNEXEC
23253 + return ktla_ktva(sp[0]);
23254 +#else
23255 if (sp[0] >> 22)
23256 return sp[0];
23257 if (sp[1] >> 22)
23258 return sp[1];
23259 #endif
23260 +
23261 +#endif
23262 }
23263 return pc;
23264 }
23265 diff --git a/arch/x86/kernel/tls.c b/arch/x86/kernel/tls.c
23266 index 9d9d2f9..cad418a 100644
23267 --- a/arch/x86/kernel/tls.c
23268 +++ b/arch/x86/kernel/tls.c
23269 @@ -84,6 +84,11 @@ int do_set_thread_area(struct task_struct *p, int idx,
23270 if (idx < GDT_ENTRY_TLS_MIN || idx > GDT_ENTRY_TLS_MAX)
23271 return -EINVAL;
23272
23273 +#ifdef CONFIG_PAX_SEGMEXEC
23274 + if ((p->mm->pax_flags & MF_PAX_SEGMEXEC) && (info.contents & MODIFY_LDT_CONTENTS_CODE))
23275 + return -EINVAL;
23276 +#endif
23277 +
23278 set_tls_desc(p, idx, &info, 1);
23279
23280 return 0;
23281 @@ -204,7 +209,7 @@ int regset_tls_set(struct task_struct *target, const struct user_regset *regset,
23282
23283 if (kbuf)
23284 info = kbuf;
23285 - else if (__copy_from_user(infobuf, ubuf, count))
23286 + else if (count > sizeof infobuf || __copy_from_user(infobuf, ubuf, count))
23287 return -EFAULT;
23288 else
23289 info = infobuf;
23290 diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
23291 index 68bda7a..3ec7bb7 100644
23292 --- a/arch/x86/kernel/traps.c
23293 +++ b/arch/x86/kernel/traps.c
23294 @@ -68,12 +68,6 @@
23295 #include <asm/setup.h>
23296
23297 asmlinkage int system_call(void);
23298 -
23299 -/*
23300 - * The IDT has to be page-aligned to simplify the Pentium
23301 - * F0 0F bug workaround.
23302 - */
23303 -gate_desc idt_table[NR_VECTORS] __page_aligned_data = { { { { 0, 0 } } }, };
23304 #endif
23305
23306 DECLARE_BITMAP(used_vectors, NR_VECTORS);
23307 @@ -106,11 +100,11 @@ static inline void preempt_conditional_cli(struct pt_regs *regs)
23308 }
23309
23310 static int __kprobes
23311 -do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
23312 +do_trap_no_signal(struct task_struct *tsk, int trapnr, const char *str,
23313 struct pt_regs *regs, long error_code)
23314 {
23315 #ifdef CONFIG_X86_32
23316 - if (regs->flags & X86_VM_MASK) {
23317 + if (v8086_mode(regs)) {
23318 /*
23319 * Traps 0, 1, 3, 4, and 5 should be forwarded to vm86.
23320 * On nmi (interrupt 2), do_trap should not be called.
23321 @@ -123,12 +117,24 @@ do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
23322 return -1;
23323 }
23324 #endif
23325 - if (!user_mode(regs)) {
23326 + if (!user_mode_novm(regs)) {
23327 if (!fixup_exception(regs)) {
23328 tsk->thread.error_code = error_code;
23329 tsk->thread.trap_nr = trapnr;
23330 +
23331 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
23332 + if (trapnr == 12 && ((regs->cs & 0xFFFF) == __KERNEL_CS || (regs->cs & 0xFFFF) == __KERNEXEC_KERNEL_CS))
23333 + str = "PAX: suspicious stack segment fault";
23334 +#endif
23335 +
23336 die(str, regs, error_code);
23337 }
23338 +
23339 +#ifdef CONFIG_PAX_REFCOUNT
23340 + if (trapnr == 4)
23341 + pax_report_refcount_overflow(regs);
23342 +#endif
23343 +
23344 return 0;
23345 }
23346
23347 @@ -136,7 +142,7 @@ do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
23348 }
23349
23350 static void __kprobes
23351 -do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
23352 +do_trap(int trapnr, int signr, const char *str, struct pt_regs *regs,
23353 long error_code, siginfo_t *info)
23354 {
23355 struct task_struct *tsk = current;
23356 @@ -160,7 +166,7 @@ do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
23357 if (show_unhandled_signals && unhandled_signal(tsk, signr) &&
23358 printk_ratelimit()) {
23359 pr_info("%s[%d] trap %s ip:%lx sp:%lx error:%lx",
23360 - tsk->comm, tsk->pid, str,
23361 + tsk->comm, task_pid_nr(tsk), str,
23362 regs->ip, regs->sp, error_code);
23363 print_vma_addr(" in ", regs->ip);
23364 pr_cont("\n");
23365 @@ -266,7 +272,7 @@ do_general_protection(struct pt_regs *regs, long error_code)
23366 conditional_sti(regs);
23367
23368 #ifdef CONFIG_X86_32
23369 - if (regs->flags & X86_VM_MASK) {
23370 + if (v8086_mode(regs)) {
23371 local_irq_enable();
23372 handle_vm86_fault((struct kernel_vm86_regs *) regs, error_code);
23373 goto exit;
23374 @@ -274,18 +280,42 @@ do_general_protection(struct pt_regs *regs, long error_code)
23375 #endif
23376
23377 tsk = current;
23378 - if (!user_mode(regs)) {
23379 + if (!user_mode_novm(regs)) {
23380 if (fixup_exception(regs))
23381 goto exit;
23382
23383 tsk->thread.error_code = error_code;
23384 tsk->thread.trap_nr = X86_TRAP_GP;
23385 if (notify_die(DIE_GPF, "general protection fault", regs, error_code,
23386 - X86_TRAP_GP, SIGSEGV) != NOTIFY_STOP)
23387 + X86_TRAP_GP, SIGSEGV) != NOTIFY_STOP) {
23388 +
23389 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
23390 + if ((regs->cs & 0xFFFF) == __KERNEL_CS || (regs->cs & 0xFFFF) == __KERNEXEC_KERNEL_CS)
23391 + die("PAX: suspicious general protection fault", regs, error_code);
23392 + else
23393 +#endif
23394 +
23395 die("general protection fault", regs, error_code);
23396 + }
23397 goto exit;
23398 }
23399
23400 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
23401 + if (!(__supported_pte_mask & _PAGE_NX) && tsk->mm && (tsk->mm->pax_flags & MF_PAX_PAGEEXEC)) {
23402 + struct mm_struct *mm = tsk->mm;
23403 + unsigned long limit;
23404 +
23405 + down_write(&mm->mmap_sem);
23406 + limit = mm->context.user_cs_limit;
23407 + if (limit < TASK_SIZE) {
23408 + track_exec_limit(mm, limit, TASK_SIZE, VM_EXEC);
23409 + up_write(&mm->mmap_sem);
23410 + return;
23411 + }
23412 + up_write(&mm->mmap_sem);
23413 + }
23414 +#endif
23415 +
23416 tsk->thread.error_code = error_code;
23417 tsk->thread.trap_nr = X86_TRAP_GP;
23418
23419 @@ -440,7 +470,7 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
23420 /* It's safe to allow irq's after DR6 has been saved */
23421 preempt_conditional_sti(regs);
23422
23423 - if (regs->flags & X86_VM_MASK) {
23424 + if (v8086_mode(regs)) {
23425 handle_vm86_trap((struct kernel_vm86_regs *) regs, error_code,
23426 X86_TRAP_DB);
23427 preempt_conditional_cli(regs);
23428 @@ -455,7 +485,7 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
23429 * We already checked v86 mode above, so we can check for kernel mode
23430 * by just checking the CPL of CS.
23431 */
23432 - if ((dr6 & DR_STEP) && !user_mode(regs)) {
23433 + if ((dr6 & DR_STEP) && !user_mode_novm(regs)) {
23434 tsk->thread.debugreg6 &= ~DR_STEP;
23435 set_tsk_thread_flag(tsk, TIF_SINGLESTEP);
23436 regs->flags &= ~X86_EFLAGS_TF;
23437 @@ -487,7 +517,7 @@ void math_error(struct pt_regs *regs, int error_code, int trapnr)
23438 return;
23439 conditional_sti(regs);
23440
23441 - if (!user_mode_vm(regs))
23442 + if (!user_mode(regs))
23443 {
23444 if (!fixup_exception(regs)) {
23445 task->thread.error_code = error_code;
23446 diff --git a/arch/x86/kernel/uprobes.c b/arch/x86/kernel/uprobes.c
23447 index 0ba4cfb..4596bec 100644
23448 --- a/arch/x86/kernel/uprobes.c
23449 +++ b/arch/x86/kernel/uprobes.c
23450 @@ -629,7 +629,7 @@ int arch_uprobe_exception_notify(struct notifier_block *self, unsigned long val,
23451 int ret = NOTIFY_DONE;
23452
23453 /* We are only interested in userspace traps */
23454 - if (regs && !user_mode_vm(regs))
23455 + if (regs && !user_mode(regs))
23456 return NOTIFY_DONE;
23457
23458 switch (val) {
23459 diff --git a/arch/x86/kernel/verify_cpu.S b/arch/x86/kernel/verify_cpu.S
23460 index b9242ba..50c5edd 100644
23461 --- a/arch/x86/kernel/verify_cpu.S
23462 +++ b/arch/x86/kernel/verify_cpu.S
23463 @@ -20,6 +20,7 @@
23464 * arch/x86/boot/compressed/head_64.S: Boot cpu verification
23465 * arch/x86/kernel/trampoline_64.S: secondary processor verification
23466 * arch/x86/kernel/head_32.S: processor startup
23467 + * arch/x86/kernel/acpi/realmode/wakeup.S: 32bit processor resume
23468 *
23469 * verify_cpu, returns the status of longmode and SSE in register %eax.
23470 * 0: Success 1: Failure
23471 diff --git a/arch/x86/kernel/vm86_32.c b/arch/x86/kernel/vm86_32.c
23472 index 3dbdd9c..888b14e 100644
23473 --- a/arch/x86/kernel/vm86_32.c
23474 +++ b/arch/x86/kernel/vm86_32.c
23475 @@ -44,6 +44,7 @@
23476 #include <linux/ptrace.h>
23477 #include <linux/audit.h>
23478 #include <linux/stddef.h>
23479 +#include <linux/grsecurity.h>
23480
23481 #include <asm/uaccess.h>
23482 #include <asm/io.h>
23483 @@ -150,7 +151,7 @@ struct pt_regs *save_v86_state(struct kernel_vm86_regs *regs)
23484 do_exit(SIGSEGV);
23485 }
23486
23487 - tss = &per_cpu(init_tss, get_cpu());
23488 + tss = init_tss + get_cpu();
23489 current->thread.sp0 = current->thread.saved_sp0;
23490 current->thread.sysenter_cs = __KERNEL_CS;
23491 load_sp0(tss, &current->thread);
23492 @@ -214,6 +215,14 @@ SYSCALL_DEFINE1(vm86old, struct vm86_struct __user *, v86)
23493
23494 if (tsk->thread.saved_sp0)
23495 goto out;
23496 +
23497 +#ifdef CONFIG_GRKERNSEC_VM86
23498 + if (!capable(CAP_SYS_RAWIO)) {
23499 + gr_handle_vm86();
23500 + goto out;
23501 + }
23502 +#endif
23503 +
23504 tmp = copy_vm86_regs_from_user(&info.regs, &v86->regs,
23505 offsetof(struct kernel_vm86_struct, vm86plus) -
23506 sizeof(info.regs));
23507 @@ -242,6 +251,14 @@ SYSCALL_DEFINE2(vm86, unsigned long, cmd, unsigned long, arg)
23508 int tmp, ret;
23509 struct vm86plus_struct __user *v86;
23510
23511 +#ifdef CONFIG_GRKERNSEC_VM86
23512 + if (!capable(CAP_SYS_RAWIO)) {
23513 + gr_handle_vm86();
23514 + ret = -EPERM;
23515 + goto out;
23516 + }
23517 +#endif
23518 +
23519 tsk = current;
23520 switch (cmd) {
23521 case VM86_REQUEST_IRQ:
23522 @@ -329,7 +346,7 @@ static void do_sys_vm86(struct kernel_vm86_struct *info, struct task_struct *tsk
23523 tsk->thread.saved_fs = info->regs32->fs;
23524 tsk->thread.saved_gs = get_user_gs(info->regs32);
23525
23526 - tss = &per_cpu(init_tss, get_cpu());
23527 + tss = init_tss + get_cpu();
23528 tsk->thread.sp0 = (unsigned long) &info->VM86_TSS_ESP0;
23529 if (cpu_has_sep)
23530 tsk->thread.sysenter_cs = 0;
23531 @@ -536,7 +553,7 @@ static void do_int(struct kernel_vm86_regs *regs, int i,
23532 goto cannot_handle;
23533 if (i == 0x21 && is_revectored(AH(regs), &KVM86->int21_revectored))
23534 goto cannot_handle;
23535 - intr_ptr = (unsigned long __user *) (i << 2);
23536 + intr_ptr = (__force unsigned long __user *) (i << 2);
23537 if (get_user(segoffs, intr_ptr))
23538 goto cannot_handle;
23539 if ((segoffs >> 16) == BIOSSEG)
23540 diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S
23541 index 22a1530..8fbaaad 100644
23542 --- a/arch/x86/kernel/vmlinux.lds.S
23543 +++ b/arch/x86/kernel/vmlinux.lds.S
23544 @@ -26,6 +26,13 @@
23545 #include <asm/page_types.h>
23546 #include <asm/cache.h>
23547 #include <asm/boot.h>
23548 +#include <asm/segment.h>
23549 +
23550 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
23551 +#define __KERNEL_TEXT_OFFSET (LOAD_OFFSET + ____LOAD_PHYSICAL_ADDR)
23552 +#else
23553 +#define __KERNEL_TEXT_OFFSET 0
23554 +#endif
23555
23556 #undef i386 /* in case the preprocessor is a 32bit one */
23557
23558 @@ -69,30 +76,43 @@ jiffies_64 = jiffies;
23559
23560 PHDRS {
23561 text PT_LOAD FLAGS(5); /* R_E */
23562 +#ifdef CONFIG_X86_32
23563 + module PT_LOAD FLAGS(5); /* R_E */
23564 +#endif
23565 +#ifdef CONFIG_XEN
23566 + rodata PT_LOAD FLAGS(5); /* R_E */
23567 +#else
23568 + rodata PT_LOAD FLAGS(4); /* R__ */
23569 +#endif
23570 data PT_LOAD FLAGS(6); /* RW_ */
23571 -#ifdef CONFIG_X86_64
23572 + init.begin PT_LOAD FLAGS(6); /* RW_ */
23573 #ifdef CONFIG_SMP
23574 percpu PT_LOAD FLAGS(6); /* RW_ */
23575 #endif
23576 + text.init PT_LOAD FLAGS(5); /* R_E */
23577 + text.exit PT_LOAD FLAGS(5); /* R_E */
23578 init PT_LOAD FLAGS(7); /* RWE */
23579 -#endif
23580 note PT_NOTE FLAGS(0); /* ___ */
23581 }
23582
23583 SECTIONS
23584 {
23585 #ifdef CONFIG_X86_32
23586 - . = LOAD_OFFSET + LOAD_PHYSICAL_ADDR;
23587 - phys_startup_32 = startup_32 - LOAD_OFFSET;
23588 + . = LOAD_OFFSET + ____LOAD_PHYSICAL_ADDR;
23589 #else
23590 - . = __START_KERNEL;
23591 - phys_startup_64 = startup_64 - LOAD_OFFSET;
23592 + . = __START_KERNEL;
23593 #endif
23594
23595 /* Text and read-only data */
23596 - .text : AT(ADDR(.text) - LOAD_OFFSET) {
23597 - _text = .;
23598 + .text (. - __KERNEL_TEXT_OFFSET): AT(ADDR(.text) - LOAD_OFFSET + __KERNEL_TEXT_OFFSET) {
23599 /* bootstrapping code */
23600 +#ifdef CONFIG_X86_32
23601 + phys_startup_32 = startup_32 - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
23602 +#else
23603 + phys_startup_64 = startup_64 - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
23604 +#endif
23605 + __LOAD_PHYSICAL_ADDR = . - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
23606 + _text = .;
23607 HEAD_TEXT
23608 #ifdef CONFIG_X86_32
23609 . = ALIGN(PAGE_SIZE);
23610 @@ -108,13 +128,48 @@ SECTIONS
23611 IRQENTRY_TEXT
23612 *(.fixup)
23613 *(.gnu.warning)
23614 - /* End of text section */
23615 - _etext = .;
23616 } :text = 0x9090
23617
23618 - NOTES :text :note
23619 + . += __KERNEL_TEXT_OFFSET;
23620
23621 - EXCEPTION_TABLE(16) :text = 0x9090
23622 +#ifdef CONFIG_X86_32
23623 + . = ALIGN(PAGE_SIZE);
23624 + .module.text : AT(ADDR(.module.text) - LOAD_OFFSET) {
23625 +
23626 +#if defined(CONFIG_PAX_KERNEXEC) && defined(CONFIG_MODULES)
23627 + MODULES_EXEC_VADDR = .;
23628 + BYTE(0)
23629 + . += (CONFIG_PAX_KERNEXEC_MODULE_TEXT * 1024 * 1024);
23630 + . = ALIGN(HPAGE_SIZE) - 1;
23631 + MODULES_EXEC_END = .;
23632 +#endif
23633 +
23634 + } :module
23635 +#endif
23636 +
23637 + .text.end : AT(ADDR(.text.end) - LOAD_OFFSET) {
23638 + /* End of text section */
23639 + BYTE(0)
23640 + _etext = . - __KERNEL_TEXT_OFFSET;
23641 + }
23642 +
23643 +#ifdef CONFIG_X86_32
23644 + . = ALIGN(PAGE_SIZE);
23645 + .rodata.page_aligned : AT(ADDR(.rodata.page_aligned) - LOAD_OFFSET) {
23646 + *(.idt)
23647 + . = ALIGN(PAGE_SIZE);
23648 + *(.empty_zero_page)
23649 + *(.initial_pg_fixmap)
23650 + *(.initial_pg_pmd)
23651 + *(.initial_page_table)
23652 + *(.swapper_pg_dir)
23653 + } :rodata
23654 +#endif
23655 +
23656 + . = ALIGN(PAGE_SIZE);
23657 + NOTES :rodata :note
23658 +
23659 + EXCEPTION_TABLE(16) :rodata
23660
23661 #if defined(CONFIG_DEBUG_RODATA)
23662 /* .text should occupy whole number of pages */
23663 @@ -126,16 +181,20 @@ SECTIONS
23664
23665 /* Data */
23666 .data : AT(ADDR(.data) - LOAD_OFFSET) {
23667 +
23668 +#ifdef CONFIG_PAX_KERNEXEC
23669 + . = ALIGN(HPAGE_SIZE);
23670 +#else
23671 + . = ALIGN(PAGE_SIZE);
23672 +#endif
23673 +
23674 /* Start of data section */
23675 _sdata = .;
23676
23677 /* init_task */
23678 INIT_TASK_DATA(THREAD_SIZE)
23679
23680 -#ifdef CONFIG_X86_32
23681 - /* 32 bit has nosave before _edata */
23682 NOSAVE_DATA
23683 -#endif
23684
23685 PAGE_ALIGNED_DATA(PAGE_SIZE)
23686
23687 @@ -176,12 +235,19 @@ SECTIONS
23688 #endif /* CONFIG_X86_64 */
23689
23690 /* Init code and data - will be freed after init */
23691 - . = ALIGN(PAGE_SIZE);
23692 .init.begin : AT(ADDR(.init.begin) - LOAD_OFFSET) {
23693 + BYTE(0)
23694 +
23695 +#ifdef CONFIG_PAX_KERNEXEC
23696 + . = ALIGN(HPAGE_SIZE);
23697 +#else
23698 + . = ALIGN(PAGE_SIZE);
23699 +#endif
23700 +
23701 __init_begin = .; /* paired with __init_end */
23702 - }
23703 + } :init.begin
23704
23705 -#if defined(CONFIG_X86_64) && defined(CONFIG_SMP)
23706 +#ifdef CONFIG_SMP
23707 /*
23708 * percpu offsets are zero-based on SMP. PERCPU_VADDR() changes the
23709 * output PHDR, so the next output section - .init.text - should
23710 @@ -190,12 +256,27 @@ SECTIONS
23711 PERCPU_VADDR(INTERNODE_CACHE_BYTES, 0, :percpu)
23712 #endif
23713
23714 - INIT_TEXT_SECTION(PAGE_SIZE)
23715 -#ifdef CONFIG_X86_64
23716 - :init
23717 -#endif
23718 + . = ALIGN(PAGE_SIZE);
23719 + init_begin = .;
23720 + .init.text (. - __KERNEL_TEXT_OFFSET): AT(init_begin - LOAD_OFFSET) {
23721 + VMLINUX_SYMBOL(_sinittext) = .;
23722 + INIT_TEXT
23723 + VMLINUX_SYMBOL(_einittext) = .;
23724 + . = ALIGN(PAGE_SIZE);
23725 + } :text.init
23726
23727 - INIT_DATA_SECTION(16)
23728 + /*
23729 + * .exit.text is discard at runtime, not link time, to deal with
23730 + * references from .altinstructions and .eh_frame
23731 + */
23732 + .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET + __KERNEL_TEXT_OFFSET) {
23733 + EXIT_TEXT
23734 + . = ALIGN(16);
23735 + } :text.exit
23736 + . = init_begin + SIZEOF(.init.text) + SIZEOF(.exit.text);
23737 +
23738 + . = ALIGN(PAGE_SIZE);
23739 + INIT_DATA_SECTION(16) :init
23740
23741 .x86_cpu_dev.init : AT(ADDR(.x86_cpu_dev.init) - LOAD_OFFSET) {
23742 __x86_cpu_dev_start = .;
23743 @@ -257,19 +338,12 @@ SECTIONS
23744 }
23745
23746 . = ALIGN(8);
23747 - /*
23748 - * .exit.text is discard at runtime, not link time, to deal with
23749 - * references from .altinstructions and .eh_frame
23750 - */
23751 - .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) {
23752 - EXIT_TEXT
23753 - }
23754
23755 .exit.data : AT(ADDR(.exit.data) - LOAD_OFFSET) {
23756 EXIT_DATA
23757 }
23758
23759 -#if !defined(CONFIG_X86_64) || !defined(CONFIG_SMP)
23760 +#ifndef CONFIG_SMP
23761 PERCPU_SECTION(INTERNODE_CACHE_BYTES)
23762 #endif
23763
23764 @@ -288,16 +362,10 @@ SECTIONS
23765 .smp_locks : AT(ADDR(.smp_locks) - LOAD_OFFSET) {
23766 __smp_locks = .;
23767 *(.smp_locks)
23768 - . = ALIGN(PAGE_SIZE);
23769 __smp_locks_end = .;
23770 + . = ALIGN(PAGE_SIZE);
23771 }
23772
23773 -#ifdef CONFIG_X86_64
23774 - .data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) {
23775 - NOSAVE_DATA
23776 - }
23777 -#endif
23778 -
23779 /* BSS */
23780 . = ALIGN(PAGE_SIZE);
23781 .bss : AT(ADDR(.bss) - LOAD_OFFSET) {
23782 @@ -313,6 +381,7 @@ SECTIONS
23783 __brk_base = .;
23784 . += 64 * 1024; /* 64k alignment slop space */
23785 *(.brk_reservation) /* areas brk users have reserved */
23786 + . = ALIGN(HPAGE_SIZE);
23787 __brk_limit = .;
23788 }
23789
23790 @@ -339,13 +408,12 @@ SECTIONS
23791 * for the boot processor.
23792 */
23793 #define INIT_PER_CPU(x) init_per_cpu__##x = x + __per_cpu_load
23794 -INIT_PER_CPU(gdt_page);
23795 INIT_PER_CPU(irq_stack_union);
23796
23797 /*
23798 * Build-time check on the image size:
23799 */
23800 -. = ASSERT((_end - _text <= KERNEL_IMAGE_SIZE),
23801 +. = ASSERT((_end - _text - __KERNEL_TEXT_OFFSET <= KERNEL_IMAGE_SIZE),
23802 "kernel image bigger than KERNEL_IMAGE_SIZE");
23803
23804 #ifdef CONFIG_SMP
23805 diff --git a/arch/x86/kernel/vsyscall_64.c b/arch/x86/kernel/vsyscall_64.c
23806 index 9a907a6..f83f921 100644
23807 --- a/arch/x86/kernel/vsyscall_64.c
23808 +++ b/arch/x86/kernel/vsyscall_64.c
23809 @@ -56,15 +56,13 @@
23810 DEFINE_VVAR(int, vgetcpu_mode);
23811 DEFINE_VVAR(struct vsyscall_gtod_data, vsyscall_gtod_data);
23812
23813 -static enum { EMULATE, NATIVE, NONE } vsyscall_mode = EMULATE;
23814 +static enum { EMULATE, NONE } vsyscall_mode = EMULATE;
23815
23816 static int __init vsyscall_setup(char *str)
23817 {
23818 if (str) {
23819 if (!strcmp("emulate", str))
23820 vsyscall_mode = EMULATE;
23821 - else if (!strcmp("native", str))
23822 - vsyscall_mode = NATIVE;
23823 else if (!strcmp("none", str))
23824 vsyscall_mode = NONE;
23825 else
23826 @@ -323,8 +321,7 @@ do_ret:
23827 return true;
23828
23829 sigsegv:
23830 - force_sig(SIGSEGV, current);
23831 - return true;
23832 + do_group_exit(SIGKILL);
23833 }
23834
23835 /*
23836 @@ -377,10 +374,7 @@ void __init map_vsyscall(void)
23837 extern char __vvar_page;
23838 unsigned long physaddr_vvar_page = __pa_symbol(&__vvar_page);
23839
23840 - __set_fixmap(VSYSCALL_FIRST_PAGE, physaddr_vsyscall,
23841 - vsyscall_mode == NATIVE
23842 - ? PAGE_KERNEL_VSYSCALL
23843 - : PAGE_KERNEL_VVAR);
23844 + __set_fixmap(VSYSCALL_FIRST_PAGE, physaddr_vsyscall, PAGE_KERNEL_VVAR);
23845 BUILD_BUG_ON((unsigned long)__fix_to_virt(VSYSCALL_FIRST_PAGE) !=
23846 (unsigned long)VSYSCALL_START);
23847
23848 diff --git a/arch/x86/kernel/x8664_ksyms_64.c b/arch/x86/kernel/x8664_ksyms_64.c
23849 index b014d94..6d6ca7b 100644
23850 --- a/arch/x86/kernel/x8664_ksyms_64.c
23851 +++ b/arch/x86/kernel/x8664_ksyms_64.c
23852 @@ -34,8 +34,6 @@ EXPORT_SYMBOL(copy_user_generic_string);
23853 EXPORT_SYMBOL(copy_user_generic_unrolled);
23854 EXPORT_SYMBOL(copy_user_enhanced_fast_string);
23855 EXPORT_SYMBOL(__copy_user_nocache);
23856 -EXPORT_SYMBOL(_copy_from_user);
23857 -EXPORT_SYMBOL(_copy_to_user);
23858
23859 EXPORT_SYMBOL(copy_page);
23860 EXPORT_SYMBOL(clear_page);
23861 diff --git a/arch/x86/kernel/x86_init.c b/arch/x86/kernel/x86_init.c
23862 index 45a14db..075bb9b 100644
23863 --- a/arch/x86/kernel/x86_init.c
23864 +++ b/arch/x86/kernel/x86_init.c
23865 @@ -85,7 +85,7 @@ struct x86_init_ops x86_init __initdata = {
23866 },
23867 };
23868
23869 -struct x86_cpuinit_ops x86_cpuinit __cpuinitdata = {
23870 +struct x86_cpuinit_ops x86_cpuinit __cpuinitconst = {
23871 .early_percpu_clock_init = x86_init_noop,
23872 .setup_percpu_clockev = setup_secondary_APIC_clock,
23873 };
23874 @@ -93,7 +93,7 @@ struct x86_cpuinit_ops x86_cpuinit __cpuinitdata = {
23875 static void default_nmi_init(void) { };
23876 static int default_i8042_detect(void) { return 1; };
23877
23878 -struct x86_platform_ops x86_platform = {
23879 +struct x86_platform_ops x86_platform __read_only = {
23880 .calibrate_tsc = native_calibrate_tsc,
23881 .get_wallclock = mach_get_cmos_time,
23882 .set_wallclock = mach_set_rtc_mmss,
23883 @@ -107,7 +107,7 @@ struct x86_platform_ops x86_platform = {
23884 };
23885
23886 EXPORT_SYMBOL_GPL(x86_platform);
23887 -struct x86_msi_ops x86_msi = {
23888 +struct x86_msi_ops x86_msi __read_only = {
23889 .setup_msi_irqs = native_setup_msi_irqs,
23890 .compose_msi_msg = native_compose_msi_msg,
23891 .teardown_msi_irq = native_teardown_msi_irq,
23892 @@ -116,7 +116,7 @@ struct x86_msi_ops x86_msi = {
23893 .setup_hpet_msi = default_setup_hpet_msi,
23894 };
23895
23896 -struct x86_io_apic_ops x86_io_apic_ops = {
23897 +struct x86_io_apic_ops x86_io_apic_ops __read_only = {
23898 .init = native_io_apic_init_mappings,
23899 .read = native_io_apic_read,
23900 .write = native_io_apic_write,
23901 diff --git a/arch/x86/kernel/xsave.c b/arch/x86/kernel/xsave.c
23902 index ada87a3..afea76d 100644
23903 --- a/arch/x86/kernel/xsave.c
23904 +++ b/arch/x86/kernel/xsave.c
23905 @@ -199,6 +199,7 @@ static inline int save_user_xstate(struct xsave_struct __user *buf)
23906 {
23907 int err;
23908
23909 + buf = (struct xsave_struct __user *)____m(buf);
23910 if (use_xsave())
23911 err = xsave_user(buf);
23912 else if (use_fxsr())
23913 @@ -311,6 +312,7 @@ sanitize_restored_xstate(struct task_struct *tsk,
23914 */
23915 static inline int restore_user_xstate(void __user *buf, u64 xbv, int fx_only)
23916 {
23917 + buf = (void __user *)____m(buf);
23918 if (use_xsave()) {
23919 if ((unsigned long)buf % 64 || fx_only) {
23920 u64 init_bv = pcntxt_mask & ~XSTATE_FPSSE;
23921 diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
23922 index a20ecb5..d0e2194 100644
23923 --- a/arch/x86/kvm/cpuid.c
23924 +++ b/arch/x86/kvm/cpuid.c
23925 @@ -124,15 +124,20 @@ int kvm_vcpu_ioctl_set_cpuid2(struct kvm_vcpu *vcpu,
23926 struct kvm_cpuid2 *cpuid,
23927 struct kvm_cpuid_entry2 __user *entries)
23928 {
23929 - int r;
23930 + int r, i;
23931
23932 r = -E2BIG;
23933 if (cpuid->nent > KVM_MAX_CPUID_ENTRIES)
23934 goto out;
23935 r = -EFAULT;
23936 - if (copy_from_user(&vcpu->arch.cpuid_entries, entries,
23937 - cpuid->nent * sizeof(struct kvm_cpuid_entry2)))
23938 + if (!access_ok(VERIFY_READ, entries, cpuid->nent * sizeof(struct kvm_cpuid_entry2)))
23939 goto out;
23940 + for (i = 0; i < cpuid->nent; ++i) {
23941 + struct kvm_cpuid_entry2 cpuid_entry;
23942 + if (__copy_from_user(&cpuid_entry, entries + i, sizeof(cpuid_entry)))
23943 + goto out;
23944 + vcpu->arch.cpuid_entries[i] = cpuid_entry;
23945 + }
23946 vcpu->arch.cpuid_nent = cpuid->nent;
23947 kvm_apic_set_version(vcpu);
23948 kvm_x86_ops->cpuid_update(vcpu);
23949 @@ -147,15 +152,19 @@ int kvm_vcpu_ioctl_get_cpuid2(struct kvm_vcpu *vcpu,
23950 struct kvm_cpuid2 *cpuid,
23951 struct kvm_cpuid_entry2 __user *entries)
23952 {
23953 - int r;
23954 + int r, i;
23955
23956 r = -E2BIG;
23957 if (cpuid->nent < vcpu->arch.cpuid_nent)
23958 goto out;
23959 r = -EFAULT;
23960 - if (copy_to_user(entries, &vcpu->arch.cpuid_entries,
23961 - vcpu->arch.cpuid_nent * sizeof(struct kvm_cpuid_entry2)))
23962 + if (!access_ok(VERIFY_WRITE, entries, vcpu->arch.cpuid_nent * sizeof(struct kvm_cpuid_entry2)))
23963 goto out;
23964 + for (i = 0; i < vcpu->arch.cpuid_nent; ++i) {
23965 + struct kvm_cpuid_entry2 cpuid_entry = vcpu->arch.cpuid_entries[i];
23966 + if (__copy_to_user(entries + i, &cpuid_entry, sizeof(cpuid_entry)))
23967 + goto out;
23968 + }
23969 return 0;
23970
23971 out:
23972 diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
23973 index 698eece..776b682 100644
23974 --- a/arch/x86/kvm/emulate.c
23975 +++ b/arch/x86/kvm/emulate.c
23976 @@ -328,6 +328,7 @@ static void invalidate_registers(struct x86_emulate_ctxt *ctxt)
23977
23978 #define ____emulate_2op(ctxt, _op, _x, _y, _suffix, _dsttype) \
23979 do { \
23980 + unsigned long _tmp; \
23981 __asm__ __volatile__ ( \
23982 _PRE_EFLAGS("0", "4", "2") \
23983 _op _suffix " %"_x"3,%1; " \
23984 @@ -342,8 +343,6 @@ static void invalidate_registers(struct x86_emulate_ctxt *ctxt)
23985 /* Raw emulation: instruction has two explicit operands. */
23986 #define __emulate_2op_nobyte(ctxt,_op,_wx,_wy,_lx,_ly,_qx,_qy) \
23987 do { \
23988 - unsigned long _tmp; \
23989 - \
23990 switch ((ctxt)->dst.bytes) { \
23991 case 2: \
23992 ____emulate_2op(ctxt,_op,_wx,_wy,"w",u16); \
23993 @@ -359,7 +358,6 @@ static void invalidate_registers(struct x86_emulate_ctxt *ctxt)
23994
23995 #define __emulate_2op(ctxt,_op,_bx,_by,_wx,_wy,_lx,_ly,_qx,_qy) \
23996 do { \
23997 - unsigned long _tmp; \
23998 switch ((ctxt)->dst.bytes) { \
23999 case 1: \
24000 ____emulate_2op(ctxt,_op,_bx,_by,"b",u8); \
24001 diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
24002 index f77df1c..6f20690 100644
24003 --- a/arch/x86/kvm/lapic.c
24004 +++ b/arch/x86/kvm/lapic.c
24005 @@ -55,7 +55,7 @@
24006 #define APIC_BUS_CYCLE_NS 1
24007
24008 /* #define apic_debug(fmt,arg...) printk(KERN_WARNING fmt,##arg) */
24009 -#define apic_debug(fmt, arg...)
24010 +#define apic_debug(fmt, arg...) do {} while (0)
24011
24012 #define APIC_LVT_NUM 6
24013 /* 14 is the version for Xeon and Pentium 8.4.8*/
24014 diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h
24015 index 105dd5b..1b0ccc2 100644
24016 --- a/arch/x86/kvm/paging_tmpl.h
24017 +++ b/arch/x86/kvm/paging_tmpl.h
24018 @@ -208,7 +208,7 @@ retry_walk:
24019 if (unlikely(kvm_is_error_hva(host_addr)))
24020 goto error;
24021
24022 - ptep_user = (pt_element_t __user *)((void *)host_addr + offset);
24023 + ptep_user = (pt_element_t __force_user *)((void *)host_addr + offset);
24024 if (unlikely(__copy_from_user(&pte, ptep_user, sizeof(pte))))
24025 goto error;
24026 walker->ptep_user[walker->level - 1] = ptep_user;
24027 diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
24028 index e1b1ce2..f7b4b43 100644
24029 --- a/arch/x86/kvm/svm.c
24030 +++ b/arch/x86/kvm/svm.c
24031 @@ -3507,7 +3507,11 @@ static void reload_tss(struct kvm_vcpu *vcpu)
24032 int cpu = raw_smp_processor_id();
24033
24034 struct svm_cpu_data *sd = per_cpu(svm_data, cpu);
24035 +
24036 + pax_open_kernel();
24037 sd->tss_desc->type = 9; /* available 32/64-bit TSS */
24038 + pax_close_kernel();
24039 +
24040 load_TR_desc();
24041 }
24042
24043 @@ -3901,6 +3905,10 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu)
24044 #endif
24045 #endif
24046
24047 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
24048 + __set_fs(current_thread_info()->addr_limit);
24049 +#endif
24050 +
24051 reload_tss(vcpu);
24052
24053 local_irq_disable();
24054 diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
24055 index 0af1807..06912bb 100644
24056 --- a/arch/x86/kvm/vmx.c
24057 +++ b/arch/x86/kvm/vmx.c
24058 @@ -1184,12 +1184,12 @@ static void vmcs_write64(unsigned long field, u64 value)
24059 #endif
24060 }
24061
24062 -static void vmcs_clear_bits(unsigned long field, u32 mask)
24063 +static void vmcs_clear_bits(unsigned long field, unsigned long mask)
24064 {
24065 vmcs_writel(field, vmcs_readl(field) & ~mask);
24066 }
24067
24068 -static void vmcs_set_bits(unsigned long field, u32 mask)
24069 +static void vmcs_set_bits(unsigned long field, unsigned long mask)
24070 {
24071 vmcs_writel(field, vmcs_readl(field) | mask);
24072 }
24073 @@ -1390,7 +1390,11 @@ static void reload_tss(void)
24074 struct desc_struct *descs;
24075
24076 descs = (void *)gdt->address;
24077 +
24078 + pax_open_kernel();
24079 descs[GDT_ENTRY_TSS].type = 9; /* available TSS */
24080 + pax_close_kernel();
24081 +
24082 load_TR_desc();
24083 }
24084
24085 @@ -1614,6 +1618,10 @@ static void vmx_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
24086 vmcs_writel(HOST_TR_BASE, kvm_read_tr_base()); /* 22.2.4 */
24087 vmcs_writel(HOST_GDTR_BASE, gdt->address); /* 22.2.4 */
24088
24089 +#ifdef CONFIG_PAX_PER_CPU_PGD
24090 + vmcs_writel(HOST_CR3, read_cr3()); /* 22.2.3 FIXME: shadow tables */
24091 +#endif
24092 +
24093 rdmsrl(MSR_IA32_SYSENTER_ESP, sysenter_esp);
24094 vmcs_writel(HOST_IA32_SYSENTER_ESP, sysenter_esp); /* 22.2.3 */
24095 vmx->loaded_vmcs->cpu = cpu;
24096 @@ -2779,8 +2787,11 @@ static __init int hardware_setup(void)
24097 if (!cpu_has_vmx_flexpriority())
24098 flexpriority_enabled = 0;
24099
24100 - if (!cpu_has_vmx_tpr_shadow())
24101 - kvm_x86_ops->update_cr8_intercept = NULL;
24102 + if (!cpu_has_vmx_tpr_shadow()) {
24103 + pax_open_kernel();
24104 + *(void **)&kvm_x86_ops->update_cr8_intercept = NULL;
24105 + pax_close_kernel();
24106 + }
24107
24108 if (enable_ept && !cpu_has_vmx_ept_2m_page())
24109 kvm_disable_largepages();
24110 @@ -2792,10 +2803,12 @@ static __init int hardware_setup(void)
24111 !cpu_has_vmx_virtual_intr_delivery())
24112 enable_apicv_reg_vid = 0;
24113
24114 + pax_open_kernel();
24115 if (enable_apicv_reg_vid)
24116 - kvm_x86_ops->update_cr8_intercept = NULL;
24117 + *(void **)&kvm_x86_ops->update_cr8_intercept = NULL;
24118 else
24119 - kvm_x86_ops->hwapic_irr_update = NULL;
24120 + *(void **)&kvm_x86_ops->hwapic_irr_update = NULL;
24121 + pax_close_kernel();
24122
24123 if (nested)
24124 nested_vmx_setup_ctls_msrs();
24125 @@ -3883,7 +3896,10 @@ static void vmx_set_constant_host_state(void)
24126
24127 vmcs_writel(HOST_CR0, read_cr0() & ~X86_CR0_TS); /* 22.2.3 */
24128 vmcs_writel(HOST_CR4, read_cr4()); /* 22.2.3, 22.2.5 */
24129 +
24130 +#ifndef CONFIG_PAX_PER_CPU_PGD
24131 vmcs_writel(HOST_CR3, read_cr3()); /* 22.2.3 FIXME: shadow tables */
24132 +#endif
24133
24134 vmcs_write16(HOST_CS_SELECTOR, __KERNEL_CS); /* 22.2.4 */
24135 #ifdef CONFIG_X86_64
24136 @@ -3904,7 +3920,7 @@ static void vmx_set_constant_host_state(void)
24137 native_store_idt(&dt);
24138 vmcs_writel(HOST_IDTR_BASE, dt.address); /* 22.2.4 */
24139
24140 - vmcs_writel(HOST_RIP, vmx_return); /* 22.2.5 */
24141 + vmcs_writel(HOST_RIP, ktla_ktva(vmx_return)); /* 22.2.5 */
24142
24143 rdmsr(MSR_IA32_SYSENTER_CS, low32, high32);
24144 vmcs_write32(HOST_IA32_SYSENTER_CS, low32);
24145 @@ -6580,6 +6596,12 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
24146 "jmp 2f \n\t"
24147 "1: " __ex(ASM_VMX_VMRESUME) "\n\t"
24148 "2: "
24149 +
24150 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
24151 + "ljmp %[cs],$3f\n\t"
24152 + "3: "
24153 +#endif
24154 +
24155 /* Save guest registers, load host registers, keep flags */
24156 "mov %0, %c[wordsize](%%" _ASM_SP ") \n\t"
24157 "pop %0 \n\t"
24158 @@ -6632,6 +6654,11 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
24159 #endif
24160 [cr2]"i"(offsetof(struct vcpu_vmx, vcpu.arch.cr2)),
24161 [wordsize]"i"(sizeof(ulong))
24162 +
24163 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
24164 + ,[cs]"i"(__KERNEL_CS)
24165 +#endif
24166 +
24167 : "cc", "memory"
24168 #ifdef CONFIG_X86_64
24169 , "rax", "rbx", "rdi", "rsi"
24170 @@ -6645,7 +6672,7 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
24171 if (debugctlmsr)
24172 update_debugctlmsr(debugctlmsr);
24173
24174 -#ifndef CONFIG_X86_64
24175 +#ifdef CONFIG_X86_32
24176 /*
24177 * The sysexit path does not restore ds/es, so we must set them to
24178 * a reasonable value ourselves.
24179 @@ -6654,8 +6681,18 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
24180 * may be executed in interrupt context, which saves and restore segments
24181 * around it, nullifying its effect.
24182 */
24183 - loadsegment(ds, __USER_DS);
24184 - loadsegment(es, __USER_DS);
24185 + loadsegment(ds, __KERNEL_DS);
24186 + loadsegment(es, __KERNEL_DS);
24187 + loadsegment(ss, __KERNEL_DS);
24188 +
24189 +#ifdef CONFIG_PAX_KERNEXEC
24190 + loadsegment(fs, __KERNEL_PERCPU);
24191 +#endif
24192 +
24193 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24194 + __set_fs(current_thread_info()->addr_limit);
24195 +#endif
24196 +
24197 #endif
24198
24199 vcpu->arch.regs_avail = ~((1 << VCPU_REGS_RIP) | (1 << VCPU_REGS_RSP)
24200 diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
24201 index e172132..c3d3e27 100644
24202 --- a/arch/x86/kvm/x86.c
24203 +++ b/arch/x86/kvm/x86.c
24204 @@ -1686,8 +1686,8 @@ static int xen_hvm_config(struct kvm_vcpu *vcpu, u64 data)
24205 {
24206 struct kvm *kvm = vcpu->kvm;
24207 int lm = is_long_mode(vcpu);
24208 - u8 *blob_addr = lm ? (u8 *)(long)kvm->arch.xen_hvm_config.blob_addr_64
24209 - : (u8 *)(long)kvm->arch.xen_hvm_config.blob_addr_32;
24210 + u8 __user *blob_addr = lm ? (u8 __user *)(long)kvm->arch.xen_hvm_config.blob_addr_64
24211 + : (u8 __user *)(long)kvm->arch.xen_hvm_config.blob_addr_32;
24212 u8 blob_size = lm ? kvm->arch.xen_hvm_config.blob_size_64
24213 : kvm->arch.xen_hvm_config.blob_size_32;
24214 u32 page_num = data & ~PAGE_MASK;
24215 @@ -2567,6 +2567,8 @@ long kvm_arch_dev_ioctl(struct file *filp,
24216 if (n < msr_list.nmsrs)
24217 goto out;
24218 r = -EFAULT;
24219 + if (num_msrs_to_save > ARRAY_SIZE(msrs_to_save))
24220 + goto out;
24221 if (copy_to_user(user_msr_list->indices, &msrs_to_save,
24222 num_msrs_to_save * sizeof(u32)))
24223 goto out;
24224 @@ -2696,7 +2698,7 @@ static int kvm_vcpu_ioctl_set_lapic(struct kvm_vcpu *vcpu,
24225 static int kvm_vcpu_ioctl_interrupt(struct kvm_vcpu *vcpu,
24226 struct kvm_interrupt *irq)
24227 {
24228 - if (irq->irq < 0 || irq->irq >= KVM_NR_INTERRUPTS)
24229 + if (irq->irq >= KVM_NR_INTERRUPTS)
24230 return -EINVAL;
24231 if (irqchip_in_kernel(vcpu->kvm))
24232 return -ENXIO;
24233 @@ -5247,7 +5249,7 @@ static struct notifier_block pvclock_gtod_notifier = {
24234 };
24235 #endif
24236
24237 -int kvm_arch_init(void *opaque)
24238 +int kvm_arch_init(const void *opaque)
24239 {
24240 int r;
24241 struct kvm_x86_ops *ops = (struct kvm_x86_ops *)opaque;
24242 diff --git a/arch/x86/lguest/boot.c b/arch/x86/lguest/boot.c
24243 index 7114c63..a1018fc 100644
24244 --- a/arch/x86/lguest/boot.c
24245 +++ b/arch/x86/lguest/boot.c
24246 @@ -1201,9 +1201,10 @@ static __init int early_put_chars(u32 vtermno, const char *buf, int count)
24247 * Rebooting also tells the Host we're finished, but the RESTART flag tells the
24248 * Launcher to reboot us.
24249 */
24250 -static void lguest_restart(char *reason)
24251 +static __noreturn void lguest_restart(char *reason)
24252 {
24253 hcall(LHCALL_SHUTDOWN, __pa(reason), LGUEST_SHUTDOWN_RESTART, 0, 0);
24254 + BUG();
24255 }
24256
24257 /*G:050
24258 diff --git a/arch/x86/lib/atomic64_386_32.S b/arch/x86/lib/atomic64_386_32.S
24259 index 00933d5..3a64af9 100644
24260 --- a/arch/x86/lib/atomic64_386_32.S
24261 +++ b/arch/x86/lib/atomic64_386_32.S
24262 @@ -48,6 +48,10 @@ BEGIN(read)
24263 movl (v), %eax
24264 movl 4(v), %edx
24265 RET_ENDP
24266 +BEGIN(read_unchecked)
24267 + movl (v), %eax
24268 + movl 4(v), %edx
24269 +RET_ENDP
24270 #undef v
24271
24272 #define v %esi
24273 @@ -55,6 +59,10 @@ BEGIN(set)
24274 movl %ebx, (v)
24275 movl %ecx, 4(v)
24276 RET_ENDP
24277 +BEGIN(set_unchecked)
24278 + movl %ebx, (v)
24279 + movl %ecx, 4(v)
24280 +RET_ENDP
24281 #undef v
24282
24283 #define v %esi
24284 @@ -70,6 +78,20 @@ RET_ENDP
24285 BEGIN(add)
24286 addl %eax, (v)
24287 adcl %edx, 4(v)
24288 +
24289 +#ifdef CONFIG_PAX_REFCOUNT
24290 + jno 0f
24291 + subl %eax, (v)
24292 + sbbl %edx, 4(v)
24293 + int $4
24294 +0:
24295 + _ASM_EXTABLE(0b, 0b)
24296 +#endif
24297 +
24298 +RET_ENDP
24299 +BEGIN(add_unchecked)
24300 + addl %eax, (v)
24301 + adcl %edx, 4(v)
24302 RET_ENDP
24303 #undef v
24304
24305 @@ -77,6 +99,24 @@ RET_ENDP
24306 BEGIN(add_return)
24307 addl (v), %eax
24308 adcl 4(v), %edx
24309 +
24310 +#ifdef CONFIG_PAX_REFCOUNT
24311 + into
24312 +1234:
24313 + _ASM_EXTABLE(1234b, 2f)
24314 +#endif
24315 +
24316 + movl %eax, (v)
24317 + movl %edx, 4(v)
24318 +
24319 +#ifdef CONFIG_PAX_REFCOUNT
24320 +2:
24321 +#endif
24322 +
24323 +RET_ENDP
24324 +BEGIN(add_return_unchecked)
24325 + addl (v), %eax
24326 + adcl 4(v), %edx
24327 movl %eax, (v)
24328 movl %edx, 4(v)
24329 RET_ENDP
24330 @@ -86,6 +126,20 @@ RET_ENDP
24331 BEGIN(sub)
24332 subl %eax, (v)
24333 sbbl %edx, 4(v)
24334 +
24335 +#ifdef CONFIG_PAX_REFCOUNT
24336 + jno 0f
24337 + addl %eax, (v)
24338 + adcl %edx, 4(v)
24339 + int $4
24340 +0:
24341 + _ASM_EXTABLE(0b, 0b)
24342 +#endif
24343 +
24344 +RET_ENDP
24345 +BEGIN(sub_unchecked)
24346 + subl %eax, (v)
24347 + sbbl %edx, 4(v)
24348 RET_ENDP
24349 #undef v
24350
24351 @@ -96,6 +150,27 @@ BEGIN(sub_return)
24352 sbbl $0, %edx
24353 addl (v), %eax
24354 adcl 4(v), %edx
24355 +
24356 +#ifdef CONFIG_PAX_REFCOUNT
24357 + into
24358 +1234:
24359 + _ASM_EXTABLE(1234b, 2f)
24360 +#endif
24361 +
24362 + movl %eax, (v)
24363 + movl %edx, 4(v)
24364 +
24365 +#ifdef CONFIG_PAX_REFCOUNT
24366 +2:
24367 +#endif
24368 +
24369 +RET_ENDP
24370 +BEGIN(sub_return_unchecked)
24371 + negl %edx
24372 + negl %eax
24373 + sbbl $0, %edx
24374 + addl (v), %eax
24375 + adcl 4(v), %edx
24376 movl %eax, (v)
24377 movl %edx, 4(v)
24378 RET_ENDP
24379 @@ -105,6 +180,20 @@ RET_ENDP
24380 BEGIN(inc)
24381 addl $1, (v)
24382 adcl $0, 4(v)
24383 +
24384 +#ifdef CONFIG_PAX_REFCOUNT
24385 + jno 0f
24386 + subl $1, (v)
24387 + sbbl $0, 4(v)
24388 + int $4
24389 +0:
24390 + _ASM_EXTABLE(0b, 0b)
24391 +#endif
24392 +
24393 +RET_ENDP
24394 +BEGIN(inc_unchecked)
24395 + addl $1, (v)
24396 + adcl $0, 4(v)
24397 RET_ENDP
24398 #undef v
24399
24400 @@ -114,6 +203,26 @@ BEGIN(inc_return)
24401 movl 4(v), %edx
24402 addl $1, %eax
24403 adcl $0, %edx
24404 +
24405 +#ifdef CONFIG_PAX_REFCOUNT
24406 + into
24407 +1234:
24408 + _ASM_EXTABLE(1234b, 2f)
24409 +#endif
24410 +
24411 + movl %eax, (v)
24412 + movl %edx, 4(v)
24413 +
24414 +#ifdef CONFIG_PAX_REFCOUNT
24415 +2:
24416 +#endif
24417 +
24418 +RET_ENDP
24419 +BEGIN(inc_return_unchecked)
24420 + movl (v), %eax
24421 + movl 4(v), %edx
24422 + addl $1, %eax
24423 + adcl $0, %edx
24424 movl %eax, (v)
24425 movl %edx, 4(v)
24426 RET_ENDP
24427 @@ -123,6 +232,20 @@ RET_ENDP
24428 BEGIN(dec)
24429 subl $1, (v)
24430 sbbl $0, 4(v)
24431 +
24432 +#ifdef CONFIG_PAX_REFCOUNT
24433 + jno 0f
24434 + addl $1, (v)
24435 + adcl $0, 4(v)
24436 + int $4
24437 +0:
24438 + _ASM_EXTABLE(0b, 0b)
24439 +#endif
24440 +
24441 +RET_ENDP
24442 +BEGIN(dec_unchecked)
24443 + subl $1, (v)
24444 + sbbl $0, 4(v)
24445 RET_ENDP
24446 #undef v
24447
24448 @@ -132,6 +255,26 @@ BEGIN(dec_return)
24449 movl 4(v), %edx
24450 subl $1, %eax
24451 sbbl $0, %edx
24452 +
24453 +#ifdef CONFIG_PAX_REFCOUNT
24454 + into
24455 +1234:
24456 + _ASM_EXTABLE(1234b, 2f)
24457 +#endif
24458 +
24459 + movl %eax, (v)
24460 + movl %edx, 4(v)
24461 +
24462 +#ifdef CONFIG_PAX_REFCOUNT
24463 +2:
24464 +#endif
24465 +
24466 +RET_ENDP
24467 +BEGIN(dec_return_unchecked)
24468 + movl (v), %eax
24469 + movl 4(v), %edx
24470 + subl $1, %eax
24471 + sbbl $0, %edx
24472 movl %eax, (v)
24473 movl %edx, 4(v)
24474 RET_ENDP
24475 @@ -143,6 +286,13 @@ BEGIN(add_unless)
24476 adcl %edx, %edi
24477 addl (v), %eax
24478 adcl 4(v), %edx
24479 +
24480 +#ifdef CONFIG_PAX_REFCOUNT
24481 + into
24482 +1234:
24483 + _ASM_EXTABLE(1234b, 2f)
24484 +#endif
24485 +
24486 cmpl %eax, %ecx
24487 je 3f
24488 1:
24489 @@ -168,6 +318,13 @@ BEGIN(inc_not_zero)
24490 1:
24491 addl $1, %eax
24492 adcl $0, %edx
24493 +
24494 +#ifdef CONFIG_PAX_REFCOUNT
24495 + into
24496 +1234:
24497 + _ASM_EXTABLE(1234b, 2f)
24498 +#endif
24499 +
24500 movl %eax, (v)
24501 movl %edx, 4(v)
24502 movl $1, %eax
24503 @@ -186,6 +343,13 @@ BEGIN(dec_if_positive)
24504 movl 4(v), %edx
24505 subl $1, %eax
24506 sbbl $0, %edx
24507 +
24508 +#ifdef CONFIG_PAX_REFCOUNT
24509 + into
24510 +1234:
24511 + _ASM_EXTABLE(1234b, 1f)
24512 +#endif
24513 +
24514 js 1f
24515 movl %eax, (v)
24516 movl %edx, 4(v)
24517 diff --git a/arch/x86/lib/atomic64_cx8_32.S b/arch/x86/lib/atomic64_cx8_32.S
24518 index f5cc9eb..51fa319 100644
24519 --- a/arch/x86/lib/atomic64_cx8_32.S
24520 +++ b/arch/x86/lib/atomic64_cx8_32.S
24521 @@ -35,10 +35,20 @@ ENTRY(atomic64_read_cx8)
24522 CFI_STARTPROC
24523
24524 read64 %ecx
24525 + pax_force_retaddr
24526 ret
24527 CFI_ENDPROC
24528 ENDPROC(atomic64_read_cx8)
24529
24530 +ENTRY(atomic64_read_unchecked_cx8)
24531 + CFI_STARTPROC
24532 +
24533 + read64 %ecx
24534 + pax_force_retaddr
24535 + ret
24536 + CFI_ENDPROC
24537 +ENDPROC(atomic64_read_unchecked_cx8)
24538 +
24539 ENTRY(atomic64_set_cx8)
24540 CFI_STARTPROC
24541
24542 @@ -48,10 +58,25 @@ ENTRY(atomic64_set_cx8)
24543 cmpxchg8b (%esi)
24544 jne 1b
24545
24546 + pax_force_retaddr
24547 ret
24548 CFI_ENDPROC
24549 ENDPROC(atomic64_set_cx8)
24550
24551 +ENTRY(atomic64_set_unchecked_cx8)
24552 + CFI_STARTPROC
24553 +
24554 +1:
24555 +/* we don't need LOCK_PREFIX since aligned 64-bit writes
24556 + * are atomic on 586 and newer */
24557 + cmpxchg8b (%esi)
24558 + jne 1b
24559 +
24560 + pax_force_retaddr
24561 + ret
24562 + CFI_ENDPROC
24563 +ENDPROC(atomic64_set_unchecked_cx8)
24564 +
24565 ENTRY(atomic64_xchg_cx8)
24566 CFI_STARTPROC
24567
24568 @@ -60,12 +85,13 @@ ENTRY(atomic64_xchg_cx8)
24569 cmpxchg8b (%esi)
24570 jne 1b
24571
24572 + pax_force_retaddr
24573 ret
24574 CFI_ENDPROC
24575 ENDPROC(atomic64_xchg_cx8)
24576
24577 -.macro addsub_return func ins insc
24578 -ENTRY(atomic64_\func\()_return_cx8)
24579 +.macro addsub_return func ins insc unchecked=""
24580 +ENTRY(atomic64_\func\()_return\unchecked\()_cx8)
24581 CFI_STARTPROC
24582 SAVE ebp
24583 SAVE ebx
24584 @@ -82,27 +108,44 @@ ENTRY(atomic64_\func\()_return_cx8)
24585 movl %edx, %ecx
24586 \ins\()l %esi, %ebx
24587 \insc\()l %edi, %ecx
24588 +
24589 +.ifb \unchecked
24590 +#ifdef CONFIG_PAX_REFCOUNT
24591 + into
24592 +2:
24593 + _ASM_EXTABLE(2b, 3f)
24594 +#endif
24595 +.endif
24596 +
24597 LOCK_PREFIX
24598 cmpxchg8b (%ebp)
24599 jne 1b
24600 -
24601 -10:
24602 movl %ebx, %eax
24603 movl %ecx, %edx
24604 +
24605 +.ifb \unchecked
24606 +#ifdef CONFIG_PAX_REFCOUNT
24607 +3:
24608 +#endif
24609 +.endif
24610 +
24611 RESTORE edi
24612 RESTORE esi
24613 RESTORE ebx
24614 RESTORE ebp
24615 + pax_force_retaddr
24616 ret
24617 CFI_ENDPROC
24618 -ENDPROC(atomic64_\func\()_return_cx8)
24619 +ENDPROC(atomic64_\func\()_return\unchecked\()_cx8)
24620 .endm
24621
24622 addsub_return add add adc
24623 addsub_return sub sub sbb
24624 +addsub_return add add adc _unchecked
24625 +addsub_return sub sub sbb _unchecked
24626
24627 -.macro incdec_return func ins insc
24628 -ENTRY(atomic64_\func\()_return_cx8)
24629 +.macro incdec_return func ins insc unchecked=""
24630 +ENTRY(atomic64_\func\()_return\unchecked\()_cx8)
24631 CFI_STARTPROC
24632 SAVE ebx
24633
24634 @@ -112,21 +155,39 @@ ENTRY(atomic64_\func\()_return_cx8)
24635 movl %edx, %ecx
24636 \ins\()l $1, %ebx
24637 \insc\()l $0, %ecx
24638 +
24639 +.ifb \unchecked
24640 +#ifdef CONFIG_PAX_REFCOUNT
24641 + into
24642 +2:
24643 + _ASM_EXTABLE(2b, 3f)
24644 +#endif
24645 +.endif
24646 +
24647 LOCK_PREFIX
24648 cmpxchg8b (%esi)
24649 jne 1b
24650
24651 -10:
24652 movl %ebx, %eax
24653 movl %ecx, %edx
24654 +
24655 +.ifb \unchecked
24656 +#ifdef CONFIG_PAX_REFCOUNT
24657 +3:
24658 +#endif
24659 +.endif
24660 +
24661 RESTORE ebx
24662 + pax_force_retaddr
24663 ret
24664 CFI_ENDPROC
24665 -ENDPROC(atomic64_\func\()_return_cx8)
24666 +ENDPROC(atomic64_\func\()_return\unchecked\()_cx8)
24667 .endm
24668
24669 incdec_return inc add adc
24670 incdec_return dec sub sbb
24671 +incdec_return inc add adc _unchecked
24672 +incdec_return dec sub sbb _unchecked
24673
24674 ENTRY(atomic64_dec_if_positive_cx8)
24675 CFI_STARTPROC
24676 @@ -138,6 +199,13 @@ ENTRY(atomic64_dec_if_positive_cx8)
24677 movl %edx, %ecx
24678 subl $1, %ebx
24679 sbb $0, %ecx
24680 +
24681 +#ifdef CONFIG_PAX_REFCOUNT
24682 + into
24683 +1234:
24684 + _ASM_EXTABLE(1234b, 2f)
24685 +#endif
24686 +
24687 js 2f
24688 LOCK_PREFIX
24689 cmpxchg8b (%esi)
24690 @@ -147,6 +215,7 @@ ENTRY(atomic64_dec_if_positive_cx8)
24691 movl %ebx, %eax
24692 movl %ecx, %edx
24693 RESTORE ebx
24694 + pax_force_retaddr
24695 ret
24696 CFI_ENDPROC
24697 ENDPROC(atomic64_dec_if_positive_cx8)
24698 @@ -171,6 +240,13 @@ ENTRY(atomic64_add_unless_cx8)
24699 movl %edx, %ecx
24700 addl %ebp, %ebx
24701 adcl %edi, %ecx
24702 +
24703 +#ifdef CONFIG_PAX_REFCOUNT
24704 + into
24705 +1234:
24706 + _ASM_EXTABLE(1234b, 3f)
24707 +#endif
24708 +
24709 LOCK_PREFIX
24710 cmpxchg8b (%esi)
24711 jne 1b
24712 @@ -181,6 +257,7 @@ ENTRY(atomic64_add_unless_cx8)
24713 CFI_ADJUST_CFA_OFFSET -8
24714 RESTORE ebx
24715 RESTORE ebp
24716 + pax_force_retaddr
24717 ret
24718 4:
24719 cmpl %edx, 4(%esp)
24720 @@ -203,6 +280,13 @@ ENTRY(atomic64_inc_not_zero_cx8)
24721 xorl %ecx, %ecx
24722 addl $1, %ebx
24723 adcl %edx, %ecx
24724 +
24725 +#ifdef CONFIG_PAX_REFCOUNT
24726 + into
24727 +1234:
24728 + _ASM_EXTABLE(1234b, 3f)
24729 +#endif
24730 +
24731 LOCK_PREFIX
24732 cmpxchg8b (%esi)
24733 jne 1b
24734 @@ -210,6 +294,7 @@ ENTRY(atomic64_inc_not_zero_cx8)
24735 movl $1, %eax
24736 3:
24737 RESTORE ebx
24738 + pax_force_retaddr
24739 ret
24740 CFI_ENDPROC
24741 ENDPROC(atomic64_inc_not_zero_cx8)
24742 diff --git a/arch/x86/lib/checksum_32.S b/arch/x86/lib/checksum_32.S
24743 index 2af5df3..62b1a5a 100644
24744 --- a/arch/x86/lib/checksum_32.S
24745 +++ b/arch/x86/lib/checksum_32.S
24746 @@ -29,7 +29,8 @@
24747 #include <asm/dwarf2.h>
24748 #include <asm/errno.h>
24749 #include <asm/asm.h>
24750 -
24751 +#include <asm/segment.h>
24752 +
24753 /*
24754 * computes a partial checksum, e.g. for TCP/UDP fragments
24755 */
24756 @@ -293,9 +294,24 @@ unsigned int csum_partial_copy_generic (const char *src, char *dst,
24757
24758 #define ARGBASE 16
24759 #define FP 12
24760 -
24761 -ENTRY(csum_partial_copy_generic)
24762 +
24763 +ENTRY(csum_partial_copy_generic_to_user)
24764 CFI_STARTPROC
24765 +
24766 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24767 + pushl_cfi %gs
24768 + popl_cfi %es
24769 + jmp csum_partial_copy_generic
24770 +#endif
24771 +
24772 +ENTRY(csum_partial_copy_generic_from_user)
24773 +
24774 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24775 + pushl_cfi %gs
24776 + popl_cfi %ds
24777 +#endif
24778 +
24779 +ENTRY(csum_partial_copy_generic)
24780 subl $4,%esp
24781 CFI_ADJUST_CFA_OFFSET 4
24782 pushl_cfi %edi
24783 @@ -317,7 +333,7 @@ ENTRY(csum_partial_copy_generic)
24784 jmp 4f
24785 SRC(1: movw (%esi), %bx )
24786 addl $2, %esi
24787 -DST( movw %bx, (%edi) )
24788 +DST( movw %bx, %es:(%edi) )
24789 addl $2, %edi
24790 addw %bx, %ax
24791 adcl $0, %eax
24792 @@ -329,30 +345,30 @@ DST( movw %bx, (%edi) )
24793 SRC(1: movl (%esi), %ebx )
24794 SRC( movl 4(%esi), %edx )
24795 adcl %ebx, %eax
24796 -DST( movl %ebx, (%edi) )
24797 +DST( movl %ebx, %es:(%edi) )
24798 adcl %edx, %eax
24799 -DST( movl %edx, 4(%edi) )
24800 +DST( movl %edx, %es:4(%edi) )
24801
24802 SRC( movl 8(%esi), %ebx )
24803 SRC( movl 12(%esi), %edx )
24804 adcl %ebx, %eax
24805 -DST( movl %ebx, 8(%edi) )
24806 +DST( movl %ebx, %es:8(%edi) )
24807 adcl %edx, %eax
24808 -DST( movl %edx, 12(%edi) )
24809 +DST( movl %edx, %es:12(%edi) )
24810
24811 SRC( movl 16(%esi), %ebx )
24812 SRC( movl 20(%esi), %edx )
24813 adcl %ebx, %eax
24814 -DST( movl %ebx, 16(%edi) )
24815 +DST( movl %ebx, %es:16(%edi) )
24816 adcl %edx, %eax
24817 -DST( movl %edx, 20(%edi) )
24818 +DST( movl %edx, %es:20(%edi) )
24819
24820 SRC( movl 24(%esi), %ebx )
24821 SRC( movl 28(%esi), %edx )
24822 adcl %ebx, %eax
24823 -DST( movl %ebx, 24(%edi) )
24824 +DST( movl %ebx, %es:24(%edi) )
24825 adcl %edx, %eax
24826 -DST( movl %edx, 28(%edi) )
24827 +DST( movl %edx, %es:28(%edi) )
24828
24829 lea 32(%esi), %esi
24830 lea 32(%edi), %edi
24831 @@ -366,7 +382,7 @@ DST( movl %edx, 28(%edi) )
24832 shrl $2, %edx # This clears CF
24833 SRC(3: movl (%esi), %ebx )
24834 adcl %ebx, %eax
24835 -DST( movl %ebx, (%edi) )
24836 +DST( movl %ebx, %es:(%edi) )
24837 lea 4(%esi), %esi
24838 lea 4(%edi), %edi
24839 dec %edx
24840 @@ -378,12 +394,12 @@ DST( movl %ebx, (%edi) )
24841 jb 5f
24842 SRC( movw (%esi), %cx )
24843 leal 2(%esi), %esi
24844 -DST( movw %cx, (%edi) )
24845 +DST( movw %cx, %es:(%edi) )
24846 leal 2(%edi), %edi
24847 je 6f
24848 shll $16,%ecx
24849 SRC(5: movb (%esi), %cl )
24850 -DST( movb %cl, (%edi) )
24851 +DST( movb %cl, %es:(%edi) )
24852 6: addl %ecx, %eax
24853 adcl $0, %eax
24854 7:
24855 @@ -394,7 +410,7 @@ DST( movb %cl, (%edi) )
24856
24857 6001:
24858 movl ARGBASE+20(%esp), %ebx # src_err_ptr
24859 - movl $-EFAULT, (%ebx)
24860 + movl $-EFAULT, %ss:(%ebx)
24861
24862 # zero the complete destination - computing the rest
24863 # is too much work
24864 @@ -407,11 +423,15 @@ DST( movb %cl, (%edi) )
24865
24866 6002:
24867 movl ARGBASE+24(%esp), %ebx # dst_err_ptr
24868 - movl $-EFAULT,(%ebx)
24869 + movl $-EFAULT,%ss:(%ebx)
24870 jmp 5000b
24871
24872 .previous
24873
24874 + pushl_cfi %ss
24875 + popl_cfi %ds
24876 + pushl_cfi %ss
24877 + popl_cfi %es
24878 popl_cfi %ebx
24879 CFI_RESTORE ebx
24880 popl_cfi %esi
24881 @@ -421,26 +441,43 @@ DST( movb %cl, (%edi) )
24882 popl_cfi %ecx # equivalent to addl $4,%esp
24883 ret
24884 CFI_ENDPROC
24885 -ENDPROC(csum_partial_copy_generic)
24886 +ENDPROC(csum_partial_copy_generic_to_user)
24887
24888 #else
24889
24890 /* Version for PentiumII/PPro */
24891
24892 #define ROUND1(x) \
24893 + nop; nop; nop; \
24894 SRC(movl x(%esi), %ebx ) ; \
24895 addl %ebx, %eax ; \
24896 - DST(movl %ebx, x(%edi) ) ;
24897 + DST(movl %ebx, %es:x(%edi)) ;
24898
24899 #define ROUND(x) \
24900 + nop; nop; nop; \
24901 SRC(movl x(%esi), %ebx ) ; \
24902 adcl %ebx, %eax ; \
24903 - DST(movl %ebx, x(%edi) ) ;
24904 + DST(movl %ebx, %es:x(%edi)) ;
24905
24906 #define ARGBASE 12
24907 -
24908 -ENTRY(csum_partial_copy_generic)
24909 +
24910 +ENTRY(csum_partial_copy_generic_to_user)
24911 CFI_STARTPROC
24912 +
24913 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24914 + pushl_cfi %gs
24915 + popl_cfi %es
24916 + jmp csum_partial_copy_generic
24917 +#endif
24918 +
24919 +ENTRY(csum_partial_copy_generic_from_user)
24920 +
24921 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24922 + pushl_cfi %gs
24923 + popl_cfi %ds
24924 +#endif
24925 +
24926 +ENTRY(csum_partial_copy_generic)
24927 pushl_cfi %ebx
24928 CFI_REL_OFFSET ebx, 0
24929 pushl_cfi %edi
24930 @@ -461,7 +498,7 @@ ENTRY(csum_partial_copy_generic)
24931 subl %ebx, %edi
24932 lea -1(%esi),%edx
24933 andl $-32,%edx
24934 - lea 3f(%ebx,%ebx), %ebx
24935 + lea 3f(%ebx,%ebx,2), %ebx
24936 testl %esi, %esi
24937 jmp *%ebx
24938 1: addl $64,%esi
24939 @@ -482,19 +519,19 @@ ENTRY(csum_partial_copy_generic)
24940 jb 5f
24941 SRC( movw (%esi), %dx )
24942 leal 2(%esi), %esi
24943 -DST( movw %dx, (%edi) )
24944 +DST( movw %dx, %es:(%edi) )
24945 leal 2(%edi), %edi
24946 je 6f
24947 shll $16,%edx
24948 5:
24949 SRC( movb (%esi), %dl )
24950 -DST( movb %dl, (%edi) )
24951 +DST( movb %dl, %es:(%edi) )
24952 6: addl %edx, %eax
24953 adcl $0, %eax
24954 7:
24955 .section .fixup, "ax"
24956 6001: movl ARGBASE+20(%esp), %ebx # src_err_ptr
24957 - movl $-EFAULT, (%ebx)
24958 + movl $-EFAULT, %ss:(%ebx)
24959 # zero the complete destination (computing the rest is too much work)
24960 movl ARGBASE+8(%esp),%edi # dst
24961 movl ARGBASE+12(%esp),%ecx # len
24962 @@ -502,10 +539,17 @@ DST( movb %dl, (%edi) )
24963 rep; stosb
24964 jmp 7b
24965 6002: movl ARGBASE+24(%esp), %ebx # dst_err_ptr
24966 - movl $-EFAULT, (%ebx)
24967 + movl $-EFAULT, %ss:(%ebx)
24968 jmp 7b
24969 .previous
24970
24971 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24972 + pushl_cfi %ss
24973 + popl_cfi %ds
24974 + pushl_cfi %ss
24975 + popl_cfi %es
24976 +#endif
24977 +
24978 popl_cfi %esi
24979 CFI_RESTORE esi
24980 popl_cfi %edi
24981 @@ -514,7 +558,7 @@ DST( movb %dl, (%edi) )
24982 CFI_RESTORE ebx
24983 ret
24984 CFI_ENDPROC
24985 -ENDPROC(csum_partial_copy_generic)
24986 +ENDPROC(csum_partial_copy_generic_to_user)
24987
24988 #undef ROUND
24989 #undef ROUND1
24990 diff --git a/arch/x86/lib/clear_page_64.S b/arch/x86/lib/clear_page_64.S
24991 index f2145cf..cea889d 100644
24992 --- a/arch/x86/lib/clear_page_64.S
24993 +++ b/arch/x86/lib/clear_page_64.S
24994 @@ -11,6 +11,7 @@ ENTRY(clear_page_c)
24995 movl $4096/8,%ecx
24996 xorl %eax,%eax
24997 rep stosq
24998 + pax_force_retaddr
24999 ret
25000 CFI_ENDPROC
25001 ENDPROC(clear_page_c)
25002 @@ -20,6 +21,7 @@ ENTRY(clear_page_c_e)
25003 movl $4096,%ecx
25004 xorl %eax,%eax
25005 rep stosb
25006 + pax_force_retaddr
25007 ret
25008 CFI_ENDPROC
25009 ENDPROC(clear_page_c_e)
25010 @@ -43,6 +45,7 @@ ENTRY(clear_page)
25011 leaq 64(%rdi),%rdi
25012 jnz .Lloop
25013 nop
25014 + pax_force_retaddr
25015 ret
25016 CFI_ENDPROC
25017 .Lclear_page_end:
25018 @@ -58,7 +61,7 @@ ENDPROC(clear_page)
25019
25020 #include <asm/cpufeature.h>
25021
25022 - .section .altinstr_replacement,"ax"
25023 + .section .altinstr_replacement,"a"
25024 1: .byte 0xeb /* jmp <disp8> */
25025 .byte (clear_page_c - clear_page) - (2f - 1b) /* offset */
25026 2: .byte 0xeb /* jmp <disp8> */
25027 diff --git a/arch/x86/lib/cmpxchg16b_emu.S b/arch/x86/lib/cmpxchg16b_emu.S
25028 index 1e572c5..2a162cd 100644
25029 --- a/arch/x86/lib/cmpxchg16b_emu.S
25030 +++ b/arch/x86/lib/cmpxchg16b_emu.S
25031 @@ -53,11 +53,13 @@ this_cpu_cmpxchg16b_emu:
25032
25033 popf
25034 mov $1, %al
25035 + pax_force_retaddr
25036 ret
25037
25038 not_same:
25039 popf
25040 xor %al,%al
25041 + pax_force_retaddr
25042 ret
25043
25044 CFI_ENDPROC
25045 diff --git a/arch/x86/lib/copy_page_64.S b/arch/x86/lib/copy_page_64.S
25046 index 176cca6..1166c50 100644
25047 --- a/arch/x86/lib/copy_page_64.S
25048 +++ b/arch/x86/lib/copy_page_64.S
25049 @@ -9,6 +9,7 @@ copy_page_rep:
25050 CFI_STARTPROC
25051 movl $4096/8, %ecx
25052 rep movsq
25053 + pax_force_retaddr
25054 ret
25055 CFI_ENDPROC
25056 ENDPROC(copy_page_rep)
25057 @@ -20,12 +21,14 @@ ENDPROC(copy_page_rep)
25058
25059 ENTRY(copy_page)
25060 CFI_STARTPROC
25061 - subq $2*8, %rsp
25062 - CFI_ADJUST_CFA_OFFSET 2*8
25063 + subq $3*8, %rsp
25064 + CFI_ADJUST_CFA_OFFSET 3*8
25065 movq %rbx, (%rsp)
25066 CFI_REL_OFFSET rbx, 0
25067 movq %r12, 1*8(%rsp)
25068 CFI_REL_OFFSET r12, 1*8
25069 + movq %r13, 2*8(%rsp)
25070 + CFI_REL_OFFSET r13, 2*8
25071
25072 movl $(4096/64)-5, %ecx
25073 .p2align 4
25074 @@ -36,7 +39,7 @@ ENTRY(copy_page)
25075 movq 0x8*2(%rsi), %rdx
25076 movq 0x8*3(%rsi), %r8
25077 movq 0x8*4(%rsi), %r9
25078 - movq 0x8*5(%rsi), %r10
25079 + movq 0x8*5(%rsi), %r13
25080 movq 0x8*6(%rsi), %r11
25081 movq 0x8*7(%rsi), %r12
25082
25083 @@ -47,7 +50,7 @@ ENTRY(copy_page)
25084 movq %rdx, 0x8*2(%rdi)
25085 movq %r8, 0x8*3(%rdi)
25086 movq %r9, 0x8*4(%rdi)
25087 - movq %r10, 0x8*5(%rdi)
25088 + movq %r13, 0x8*5(%rdi)
25089 movq %r11, 0x8*6(%rdi)
25090 movq %r12, 0x8*7(%rdi)
25091
25092 @@ -66,7 +69,7 @@ ENTRY(copy_page)
25093 movq 0x8*2(%rsi), %rdx
25094 movq 0x8*3(%rsi), %r8
25095 movq 0x8*4(%rsi), %r9
25096 - movq 0x8*5(%rsi), %r10
25097 + movq 0x8*5(%rsi), %r13
25098 movq 0x8*6(%rsi), %r11
25099 movq 0x8*7(%rsi), %r12
25100
25101 @@ -75,7 +78,7 @@ ENTRY(copy_page)
25102 movq %rdx, 0x8*2(%rdi)
25103 movq %r8, 0x8*3(%rdi)
25104 movq %r9, 0x8*4(%rdi)
25105 - movq %r10, 0x8*5(%rdi)
25106 + movq %r13, 0x8*5(%rdi)
25107 movq %r11, 0x8*6(%rdi)
25108 movq %r12, 0x8*7(%rdi)
25109
25110 @@ -87,8 +90,11 @@ ENTRY(copy_page)
25111 CFI_RESTORE rbx
25112 movq 1*8(%rsp), %r12
25113 CFI_RESTORE r12
25114 - addq $2*8, %rsp
25115 - CFI_ADJUST_CFA_OFFSET -2*8
25116 + movq 2*8(%rsp), %r13
25117 + CFI_RESTORE r13
25118 + addq $3*8, %rsp
25119 + CFI_ADJUST_CFA_OFFSET -3*8
25120 + pax_force_retaddr
25121 ret
25122 .Lcopy_page_end:
25123 CFI_ENDPROC
25124 @@ -99,7 +105,7 @@ ENDPROC(copy_page)
25125
25126 #include <asm/cpufeature.h>
25127
25128 - .section .altinstr_replacement,"ax"
25129 + .section .altinstr_replacement,"a"
25130 1: .byte 0xeb /* jmp <disp8> */
25131 .byte (copy_page_rep - copy_page) - (2f - 1b) /* offset */
25132 2:
25133 diff --git a/arch/x86/lib/copy_user_64.S b/arch/x86/lib/copy_user_64.S
25134 index a30ca15..d25fab6 100644
25135 --- a/arch/x86/lib/copy_user_64.S
25136 +++ b/arch/x86/lib/copy_user_64.S
25137 @@ -18,6 +18,7 @@
25138 #include <asm/alternative-asm.h>
25139 #include <asm/asm.h>
25140 #include <asm/smap.h>
25141 +#include <asm/pgtable.h>
25142
25143 /*
25144 * By placing feature2 after feature1 in altinstructions section, we logically
25145 @@ -31,7 +32,7 @@
25146 .byte 0xe9 /* 32bit jump */
25147 .long \orig-1f /* by default jump to orig */
25148 1:
25149 - .section .altinstr_replacement,"ax"
25150 + .section .altinstr_replacement,"a"
25151 2: .byte 0xe9 /* near jump with 32bit immediate */
25152 .long \alt1-1b /* offset */ /* or alternatively to alt1 */
25153 3: .byte 0xe9 /* near jump with 32bit immediate */
25154 @@ -70,47 +71,20 @@
25155 #endif
25156 .endm
25157
25158 -/* Standard copy_to_user with segment limit checking */
25159 -ENTRY(_copy_to_user)
25160 - CFI_STARTPROC
25161 - GET_THREAD_INFO(%rax)
25162 - movq %rdi,%rcx
25163 - addq %rdx,%rcx
25164 - jc bad_to_user
25165 - cmpq TI_addr_limit(%rax),%rcx
25166 - ja bad_to_user
25167 - ALTERNATIVE_JUMP X86_FEATURE_REP_GOOD,X86_FEATURE_ERMS, \
25168 - copy_user_generic_unrolled,copy_user_generic_string, \
25169 - copy_user_enhanced_fast_string
25170 - CFI_ENDPROC
25171 -ENDPROC(_copy_to_user)
25172 -
25173 -/* Standard copy_from_user with segment limit checking */
25174 -ENTRY(_copy_from_user)
25175 - CFI_STARTPROC
25176 - GET_THREAD_INFO(%rax)
25177 - movq %rsi,%rcx
25178 - addq %rdx,%rcx
25179 - jc bad_from_user
25180 - cmpq TI_addr_limit(%rax),%rcx
25181 - ja bad_from_user
25182 - ALTERNATIVE_JUMP X86_FEATURE_REP_GOOD,X86_FEATURE_ERMS, \
25183 - copy_user_generic_unrolled,copy_user_generic_string, \
25184 - copy_user_enhanced_fast_string
25185 - CFI_ENDPROC
25186 -ENDPROC(_copy_from_user)
25187 -
25188 .section .fixup,"ax"
25189 /* must zero dest */
25190 ENTRY(bad_from_user)
25191 bad_from_user:
25192 CFI_STARTPROC
25193 + testl %edx,%edx
25194 + js bad_to_user
25195 movl %edx,%ecx
25196 xorl %eax,%eax
25197 rep
25198 stosb
25199 bad_to_user:
25200 movl %edx,%eax
25201 + pax_force_retaddr
25202 ret
25203 CFI_ENDPROC
25204 ENDPROC(bad_from_user)
25205 @@ -141,19 +115,19 @@ ENTRY(copy_user_generic_unrolled)
25206 jz 17f
25207 1: movq (%rsi),%r8
25208 2: movq 1*8(%rsi),%r9
25209 -3: movq 2*8(%rsi),%r10
25210 +3: movq 2*8(%rsi),%rax
25211 4: movq 3*8(%rsi),%r11
25212 5: movq %r8,(%rdi)
25213 6: movq %r9,1*8(%rdi)
25214 -7: movq %r10,2*8(%rdi)
25215 +7: movq %rax,2*8(%rdi)
25216 8: movq %r11,3*8(%rdi)
25217 9: movq 4*8(%rsi),%r8
25218 10: movq 5*8(%rsi),%r9
25219 -11: movq 6*8(%rsi),%r10
25220 +11: movq 6*8(%rsi),%rax
25221 12: movq 7*8(%rsi),%r11
25222 13: movq %r8,4*8(%rdi)
25223 14: movq %r9,5*8(%rdi)
25224 -15: movq %r10,6*8(%rdi)
25225 +15: movq %rax,6*8(%rdi)
25226 16: movq %r11,7*8(%rdi)
25227 leaq 64(%rsi),%rsi
25228 leaq 64(%rdi),%rdi
25229 @@ -180,6 +154,7 @@ ENTRY(copy_user_generic_unrolled)
25230 jnz 21b
25231 23: xor %eax,%eax
25232 ASM_CLAC
25233 + pax_force_retaddr
25234 ret
25235
25236 .section .fixup,"ax"
25237 @@ -251,6 +226,7 @@ ENTRY(copy_user_generic_string)
25238 movsb
25239 4: xorl %eax,%eax
25240 ASM_CLAC
25241 + pax_force_retaddr
25242 ret
25243
25244 .section .fixup,"ax"
25245 @@ -286,6 +262,7 @@ ENTRY(copy_user_enhanced_fast_string)
25246 movsb
25247 2: xorl %eax,%eax
25248 ASM_CLAC
25249 + pax_force_retaddr
25250 ret
25251
25252 .section .fixup,"ax"
25253 diff --git a/arch/x86/lib/copy_user_nocache_64.S b/arch/x86/lib/copy_user_nocache_64.S
25254 index 6a4f43c..f08b4a2 100644
25255 --- a/arch/x86/lib/copy_user_nocache_64.S
25256 +++ b/arch/x86/lib/copy_user_nocache_64.S
25257 @@ -8,6 +8,7 @@
25258
25259 #include <linux/linkage.h>
25260 #include <asm/dwarf2.h>
25261 +#include <asm/alternative-asm.h>
25262
25263 #define FIX_ALIGNMENT 1
25264
25265 @@ -16,6 +17,7 @@
25266 #include <asm/thread_info.h>
25267 #include <asm/asm.h>
25268 #include <asm/smap.h>
25269 +#include <asm/pgtable.h>
25270
25271 .macro ALIGN_DESTINATION
25272 #ifdef FIX_ALIGNMENT
25273 @@ -49,6 +51,15 @@
25274 */
25275 ENTRY(__copy_user_nocache)
25276 CFI_STARTPROC
25277 +
25278 +#ifdef CONFIG_PAX_MEMORY_UDEREF
25279 + mov pax_user_shadow_base,%rcx
25280 + cmp %rcx,%rsi
25281 + jae 1f
25282 + add %rcx,%rsi
25283 +1:
25284 +#endif
25285 +
25286 ASM_STAC
25287 cmpl $8,%edx
25288 jb 20f /* less then 8 bytes, go to byte copy loop */
25289 @@ -59,19 +70,19 @@ ENTRY(__copy_user_nocache)
25290 jz 17f
25291 1: movq (%rsi),%r8
25292 2: movq 1*8(%rsi),%r9
25293 -3: movq 2*8(%rsi),%r10
25294 +3: movq 2*8(%rsi),%rax
25295 4: movq 3*8(%rsi),%r11
25296 5: movnti %r8,(%rdi)
25297 6: movnti %r9,1*8(%rdi)
25298 -7: movnti %r10,2*8(%rdi)
25299 +7: movnti %rax,2*8(%rdi)
25300 8: movnti %r11,3*8(%rdi)
25301 9: movq 4*8(%rsi),%r8
25302 10: movq 5*8(%rsi),%r9
25303 -11: movq 6*8(%rsi),%r10
25304 +11: movq 6*8(%rsi),%rax
25305 12: movq 7*8(%rsi),%r11
25306 13: movnti %r8,4*8(%rdi)
25307 14: movnti %r9,5*8(%rdi)
25308 -15: movnti %r10,6*8(%rdi)
25309 +15: movnti %rax,6*8(%rdi)
25310 16: movnti %r11,7*8(%rdi)
25311 leaq 64(%rsi),%rsi
25312 leaq 64(%rdi),%rdi
25313 @@ -99,6 +110,7 @@ ENTRY(__copy_user_nocache)
25314 23: xorl %eax,%eax
25315 ASM_CLAC
25316 sfence
25317 + pax_force_retaddr
25318 ret
25319
25320 .section .fixup,"ax"
25321 diff --git a/arch/x86/lib/csum-copy_64.S b/arch/x86/lib/csum-copy_64.S
25322 index 2419d5f..953ee51 100644
25323 --- a/arch/x86/lib/csum-copy_64.S
25324 +++ b/arch/x86/lib/csum-copy_64.S
25325 @@ -9,6 +9,7 @@
25326 #include <asm/dwarf2.h>
25327 #include <asm/errno.h>
25328 #include <asm/asm.h>
25329 +#include <asm/alternative-asm.h>
25330
25331 /*
25332 * Checksum copy with exception handling.
25333 @@ -220,6 +221,7 @@ ENTRY(csum_partial_copy_generic)
25334 CFI_RESTORE rbp
25335 addq $7*8, %rsp
25336 CFI_ADJUST_CFA_OFFSET -7*8
25337 + pax_force_retaddr 0, 1
25338 ret
25339 CFI_RESTORE_STATE
25340
25341 diff --git a/arch/x86/lib/csum-wrappers_64.c b/arch/x86/lib/csum-wrappers_64.c
25342 index 25b7ae8..169fafc 100644
25343 --- a/arch/x86/lib/csum-wrappers_64.c
25344 +++ b/arch/x86/lib/csum-wrappers_64.c
25345 @@ -52,7 +52,7 @@ csum_partial_copy_from_user(const void __user *src, void *dst,
25346 len -= 2;
25347 }
25348 }
25349 - isum = csum_partial_copy_generic((__force const void *)src,
25350 + isum = csum_partial_copy_generic((const void __force_kernel *)____m(src),
25351 dst, len, isum, errp, NULL);
25352 if (unlikely(*errp))
25353 goto out_err;
25354 @@ -105,7 +105,7 @@ csum_partial_copy_to_user(const void *src, void __user *dst,
25355 }
25356
25357 *errp = 0;
25358 - return csum_partial_copy_generic(src, (void __force *)dst,
25359 + return csum_partial_copy_generic(src, (void __force_kernel *)____m(dst),
25360 len, isum, NULL, errp);
25361 }
25362 EXPORT_SYMBOL(csum_partial_copy_to_user);
25363 diff --git a/arch/x86/lib/getuser.S b/arch/x86/lib/getuser.S
25364 index a451235..79fb5cf 100644
25365 --- a/arch/x86/lib/getuser.S
25366 +++ b/arch/x86/lib/getuser.S
25367 @@ -33,17 +33,40 @@
25368 #include <asm/thread_info.h>
25369 #include <asm/asm.h>
25370 #include <asm/smap.h>
25371 +#include <asm/segment.h>
25372 +#include <asm/pgtable.h>
25373 +#include <asm/alternative-asm.h>
25374 +
25375 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
25376 +#define __copyuser_seg gs;
25377 +#else
25378 +#define __copyuser_seg
25379 +#endif
25380
25381 .text
25382 ENTRY(__get_user_1)
25383 CFI_STARTPROC
25384 +
25385 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
25386 GET_THREAD_INFO(%_ASM_DX)
25387 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
25388 jae bad_get_user
25389 ASM_STAC
25390 -1: movzbl (%_ASM_AX),%edx
25391 +
25392 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
25393 + mov pax_user_shadow_base,%_ASM_DX
25394 + cmp %_ASM_DX,%_ASM_AX
25395 + jae 1234f
25396 + add %_ASM_DX,%_ASM_AX
25397 +1234:
25398 +#endif
25399 +
25400 +#endif
25401 +
25402 +1: __copyuser_seg movzbl (%_ASM_AX),%edx
25403 xor %eax,%eax
25404 ASM_CLAC
25405 + pax_force_retaddr
25406 ret
25407 CFI_ENDPROC
25408 ENDPROC(__get_user_1)
25409 @@ -51,14 +74,28 @@ ENDPROC(__get_user_1)
25410 ENTRY(__get_user_2)
25411 CFI_STARTPROC
25412 add $1,%_ASM_AX
25413 +
25414 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
25415 jc bad_get_user
25416 GET_THREAD_INFO(%_ASM_DX)
25417 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
25418 jae bad_get_user
25419 ASM_STAC
25420 -2: movzwl -1(%_ASM_AX),%edx
25421 +
25422 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
25423 + mov pax_user_shadow_base,%_ASM_DX
25424 + cmp %_ASM_DX,%_ASM_AX
25425 + jae 1234f
25426 + add %_ASM_DX,%_ASM_AX
25427 +1234:
25428 +#endif
25429 +
25430 +#endif
25431 +
25432 +2: __copyuser_seg movzwl -1(%_ASM_AX),%edx
25433 xor %eax,%eax
25434 ASM_CLAC
25435 + pax_force_retaddr
25436 ret
25437 CFI_ENDPROC
25438 ENDPROC(__get_user_2)
25439 @@ -66,14 +103,28 @@ ENDPROC(__get_user_2)
25440 ENTRY(__get_user_4)
25441 CFI_STARTPROC
25442 add $3,%_ASM_AX
25443 +
25444 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
25445 jc bad_get_user
25446 GET_THREAD_INFO(%_ASM_DX)
25447 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
25448 jae bad_get_user
25449 ASM_STAC
25450 -3: movl -3(%_ASM_AX),%edx
25451 +
25452 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
25453 + mov pax_user_shadow_base,%_ASM_DX
25454 + cmp %_ASM_DX,%_ASM_AX
25455 + jae 1234f
25456 + add %_ASM_DX,%_ASM_AX
25457 +1234:
25458 +#endif
25459 +
25460 +#endif
25461 +
25462 +3: __copyuser_seg movl -3(%_ASM_AX),%edx
25463 xor %eax,%eax
25464 ASM_CLAC
25465 + pax_force_retaddr
25466 ret
25467 CFI_ENDPROC
25468 ENDPROC(__get_user_4)
25469 @@ -86,10 +137,20 @@ ENTRY(__get_user_8)
25470 GET_THREAD_INFO(%_ASM_DX)
25471 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
25472 jae bad_get_user
25473 +
25474 +#ifdef CONFIG_PAX_MEMORY_UDEREF
25475 + mov pax_user_shadow_base,%_ASM_DX
25476 + cmp %_ASM_DX,%_ASM_AX
25477 + jae 1234f
25478 + add %_ASM_DX,%_ASM_AX
25479 +1234:
25480 +#endif
25481 +
25482 ASM_STAC
25483 4: movq -7(%_ASM_AX),%rdx
25484 xor %eax,%eax
25485 ASM_CLAC
25486 + pax_force_retaddr
25487 ret
25488 #else
25489 add $7,%_ASM_AX
25490 @@ -102,6 +163,7 @@ ENTRY(__get_user_8)
25491 5: movl -3(%_ASM_AX),%ecx
25492 xor %eax,%eax
25493 ASM_CLAC
25494 + pax_force_retaddr
25495 ret
25496 #endif
25497 CFI_ENDPROC
25498 @@ -113,6 +175,7 @@ bad_get_user:
25499 xor %edx,%edx
25500 mov $(-EFAULT),%_ASM_AX
25501 ASM_CLAC
25502 + pax_force_retaddr
25503 ret
25504 CFI_ENDPROC
25505 END(bad_get_user)
25506 @@ -124,6 +187,7 @@ bad_get_user_8:
25507 xor %ecx,%ecx
25508 mov $(-EFAULT),%_ASM_AX
25509 ASM_CLAC
25510 + pax_force_retaddr
25511 ret
25512 CFI_ENDPROC
25513 END(bad_get_user_8)
25514 diff --git a/arch/x86/lib/insn.c b/arch/x86/lib/insn.c
25515 index 54fcffe..7be149e 100644
25516 --- a/arch/x86/lib/insn.c
25517 +++ b/arch/x86/lib/insn.c
25518 @@ -20,8 +20,10 @@
25519
25520 #ifdef __KERNEL__
25521 #include <linux/string.h>
25522 +#include <asm/pgtable_types.h>
25523 #else
25524 #include <string.h>
25525 +#define ktla_ktva(addr) addr
25526 #endif
25527 #include <asm/inat.h>
25528 #include <asm/insn.h>
25529 @@ -53,8 +55,8 @@
25530 void insn_init(struct insn *insn, const void *kaddr, int x86_64)
25531 {
25532 memset(insn, 0, sizeof(*insn));
25533 - insn->kaddr = kaddr;
25534 - insn->next_byte = kaddr;
25535 + insn->kaddr = ktla_ktva(kaddr);
25536 + insn->next_byte = ktla_ktva(kaddr);
25537 insn->x86_64 = x86_64 ? 1 : 0;
25538 insn->opnd_bytes = 4;
25539 if (x86_64)
25540 diff --git a/arch/x86/lib/iomap_copy_64.S b/arch/x86/lib/iomap_copy_64.S
25541 index 05a95e7..326f2fa 100644
25542 --- a/arch/x86/lib/iomap_copy_64.S
25543 +++ b/arch/x86/lib/iomap_copy_64.S
25544 @@ -17,6 +17,7 @@
25545
25546 #include <linux/linkage.h>
25547 #include <asm/dwarf2.h>
25548 +#include <asm/alternative-asm.h>
25549
25550 /*
25551 * override generic version in lib/iomap_copy.c
25552 @@ -25,6 +26,7 @@ ENTRY(__iowrite32_copy)
25553 CFI_STARTPROC
25554 movl %edx,%ecx
25555 rep movsd
25556 + pax_force_retaddr
25557 ret
25558 CFI_ENDPROC
25559 ENDPROC(__iowrite32_copy)
25560 diff --git a/arch/x86/lib/memcpy_64.S b/arch/x86/lib/memcpy_64.S
25561 index 1c273be..da9cc0e 100644
25562 --- a/arch/x86/lib/memcpy_64.S
25563 +++ b/arch/x86/lib/memcpy_64.S
25564 @@ -33,6 +33,7 @@
25565 rep movsq
25566 movl %edx, %ecx
25567 rep movsb
25568 + pax_force_retaddr
25569 ret
25570 .Lmemcpy_e:
25571 .previous
25572 @@ -49,6 +50,7 @@
25573 movq %rdi, %rax
25574 movq %rdx, %rcx
25575 rep movsb
25576 + pax_force_retaddr
25577 ret
25578 .Lmemcpy_e_e:
25579 .previous
25580 @@ -76,13 +78,13 @@ ENTRY(memcpy)
25581 */
25582 movq 0*8(%rsi), %r8
25583 movq 1*8(%rsi), %r9
25584 - movq 2*8(%rsi), %r10
25585 + movq 2*8(%rsi), %rcx
25586 movq 3*8(%rsi), %r11
25587 leaq 4*8(%rsi), %rsi
25588
25589 movq %r8, 0*8(%rdi)
25590 movq %r9, 1*8(%rdi)
25591 - movq %r10, 2*8(%rdi)
25592 + movq %rcx, 2*8(%rdi)
25593 movq %r11, 3*8(%rdi)
25594 leaq 4*8(%rdi), %rdi
25595 jae .Lcopy_forward_loop
25596 @@ -105,12 +107,12 @@ ENTRY(memcpy)
25597 subq $0x20, %rdx
25598 movq -1*8(%rsi), %r8
25599 movq -2*8(%rsi), %r9
25600 - movq -3*8(%rsi), %r10
25601 + movq -3*8(%rsi), %rcx
25602 movq -4*8(%rsi), %r11
25603 leaq -4*8(%rsi), %rsi
25604 movq %r8, -1*8(%rdi)
25605 movq %r9, -2*8(%rdi)
25606 - movq %r10, -3*8(%rdi)
25607 + movq %rcx, -3*8(%rdi)
25608 movq %r11, -4*8(%rdi)
25609 leaq -4*8(%rdi), %rdi
25610 jae .Lcopy_backward_loop
25611 @@ -130,12 +132,13 @@ ENTRY(memcpy)
25612 */
25613 movq 0*8(%rsi), %r8
25614 movq 1*8(%rsi), %r9
25615 - movq -2*8(%rsi, %rdx), %r10
25616 + movq -2*8(%rsi, %rdx), %rcx
25617 movq -1*8(%rsi, %rdx), %r11
25618 movq %r8, 0*8(%rdi)
25619 movq %r9, 1*8(%rdi)
25620 - movq %r10, -2*8(%rdi, %rdx)
25621 + movq %rcx, -2*8(%rdi, %rdx)
25622 movq %r11, -1*8(%rdi, %rdx)
25623 + pax_force_retaddr
25624 retq
25625 .p2align 4
25626 .Lless_16bytes:
25627 @@ -148,6 +151,7 @@ ENTRY(memcpy)
25628 movq -1*8(%rsi, %rdx), %r9
25629 movq %r8, 0*8(%rdi)
25630 movq %r9, -1*8(%rdi, %rdx)
25631 + pax_force_retaddr
25632 retq
25633 .p2align 4
25634 .Lless_8bytes:
25635 @@ -161,6 +165,7 @@ ENTRY(memcpy)
25636 movl -4(%rsi, %rdx), %r8d
25637 movl %ecx, (%rdi)
25638 movl %r8d, -4(%rdi, %rdx)
25639 + pax_force_retaddr
25640 retq
25641 .p2align 4
25642 .Lless_3bytes:
25643 @@ -179,6 +184,7 @@ ENTRY(memcpy)
25644 movb %cl, (%rdi)
25645
25646 .Lend:
25647 + pax_force_retaddr
25648 retq
25649 CFI_ENDPROC
25650 ENDPROC(memcpy)
25651 diff --git a/arch/x86/lib/memmove_64.S b/arch/x86/lib/memmove_64.S
25652 index ee16461..c39c199 100644
25653 --- a/arch/x86/lib/memmove_64.S
25654 +++ b/arch/x86/lib/memmove_64.S
25655 @@ -61,13 +61,13 @@ ENTRY(memmove)
25656 5:
25657 sub $0x20, %rdx
25658 movq 0*8(%rsi), %r11
25659 - movq 1*8(%rsi), %r10
25660 + movq 1*8(%rsi), %rcx
25661 movq 2*8(%rsi), %r9
25662 movq 3*8(%rsi), %r8
25663 leaq 4*8(%rsi), %rsi
25664
25665 movq %r11, 0*8(%rdi)
25666 - movq %r10, 1*8(%rdi)
25667 + movq %rcx, 1*8(%rdi)
25668 movq %r9, 2*8(%rdi)
25669 movq %r8, 3*8(%rdi)
25670 leaq 4*8(%rdi), %rdi
25671 @@ -81,10 +81,10 @@ ENTRY(memmove)
25672 4:
25673 movq %rdx, %rcx
25674 movq -8(%rsi, %rdx), %r11
25675 - lea -8(%rdi, %rdx), %r10
25676 + lea -8(%rdi, %rdx), %r9
25677 shrq $3, %rcx
25678 rep movsq
25679 - movq %r11, (%r10)
25680 + movq %r11, (%r9)
25681 jmp 13f
25682 .Lmemmove_end_forward:
25683
25684 @@ -95,14 +95,14 @@ ENTRY(memmove)
25685 7:
25686 movq %rdx, %rcx
25687 movq (%rsi), %r11
25688 - movq %rdi, %r10
25689 + movq %rdi, %r9
25690 leaq -8(%rsi, %rdx), %rsi
25691 leaq -8(%rdi, %rdx), %rdi
25692 shrq $3, %rcx
25693 std
25694 rep movsq
25695 cld
25696 - movq %r11, (%r10)
25697 + movq %r11, (%r9)
25698 jmp 13f
25699
25700 /*
25701 @@ -127,13 +127,13 @@ ENTRY(memmove)
25702 8:
25703 subq $0x20, %rdx
25704 movq -1*8(%rsi), %r11
25705 - movq -2*8(%rsi), %r10
25706 + movq -2*8(%rsi), %rcx
25707 movq -3*8(%rsi), %r9
25708 movq -4*8(%rsi), %r8
25709 leaq -4*8(%rsi), %rsi
25710
25711 movq %r11, -1*8(%rdi)
25712 - movq %r10, -2*8(%rdi)
25713 + movq %rcx, -2*8(%rdi)
25714 movq %r9, -3*8(%rdi)
25715 movq %r8, -4*8(%rdi)
25716 leaq -4*8(%rdi), %rdi
25717 @@ -151,11 +151,11 @@ ENTRY(memmove)
25718 * Move data from 16 bytes to 31 bytes.
25719 */
25720 movq 0*8(%rsi), %r11
25721 - movq 1*8(%rsi), %r10
25722 + movq 1*8(%rsi), %rcx
25723 movq -2*8(%rsi, %rdx), %r9
25724 movq -1*8(%rsi, %rdx), %r8
25725 movq %r11, 0*8(%rdi)
25726 - movq %r10, 1*8(%rdi)
25727 + movq %rcx, 1*8(%rdi)
25728 movq %r9, -2*8(%rdi, %rdx)
25729 movq %r8, -1*8(%rdi, %rdx)
25730 jmp 13f
25731 @@ -167,9 +167,9 @@ ENTRY(memmove)
25732 * Move data from 8 bytes to 15 bytes.
25733 */
25734 movq 0*8(%rsi), %r11
25735 - movq -1*8(%rsi, %rdx), %r10
25736 + movq -1*8(%rsi, %rdx), %r9
25737 movq %r11, 0*8(%rdi)
25738 - movq %r10, -1*8(%rdi, %rdx)
25739 + movq %r9, -1*8(%rdi, %rdx)
25740 jmp 13f
25741 10:
25742 cmpq $4, %rdx
25743 @@ -178,9 +178,9 @@ ENTRY(memmove)
25744 * Move data from 4 bytes to 7 bytes.
25745 */
25746 movl (%rsi), %r11d
25747 - movl -4(%rsi, %rdx), %r10d
25748 + movl -4(%rsi, %rdx), %r9d
25749 movl %r11d, (%rdi)
25750 - movl %r10d, -4(%rdi, %rdx)
25751 + movl %r9d, -4(%rdi, %rdx)
25752 jmp 13f
25753 11:
25754 cmp $2, %rdx
25755 @@ -189,9 +189,9 @@ ENTRY(memmove)
25756 * Move data from 2 bytes to 3 bytes.
25757 */
25758 movw (%rsi), %r11w
25759 - movw -2(%rsi, %rdx), %r10w
25760 + movw -2(%rsi, %rdx), %r9w
25761 movw %r11w, (%rdi)
25762 - movw %r10w, -2(%rdi, %rdx)
25763 + movw %r9w, -2(%rdi, %rdx)
25764 jmp 13f
25765 12:
25766 cmp $1, %rdx
25767 @@ -202,6 +202,7 @@ ENTRY(memmove)
25768 movb (%rsi), %r11b
25769 movb %r11b, (%rdi)
25770 13:
25771 + pax_force_retaddr
25772 retq
25773 CFI_ENDPROC
25774
25775 @@ -210,6 +211,7 @@ ENTRY(memmove)
25776 /* Forward moving data. */
25777 movq %rdx, %rcx
25778 rep movsb
25779 + pax_force_retaddr
25780 retq
25781 .Lmemmove_end_forward_efs:
25782 .previous
25783 diff --git a/arch/x86/lib/memset_64.S b/arch/x86/lib/memset_64.S
25784 index 2dcb380..963660a 100644
25785 --- a/arch/x86/lib/memset_64.S
25786 +++ b/arch/x86/lib/memset_64.S
25787 @@ -30,6 +30,7 @@
25788 movl %edx,%ecx
25789 rep stosb
25790 movq %r9,%rax
25791 + pax_force_retaddr
25792 ret
25793 .Lmemset_e:
25794 .previous
25795 @@ -52,6 +53,7 @@
25796 movq %rdx,%rcx
25797 rep stosb
25798 movq %r9,%rax
25799 + pax_force_retaddr
25800 ret
25801 .Lmemset_e_e:
25802 .previous
25803 @@ -59,7 +61,7 @@
25804 ENTRY(memset)
25805 ENTRY(__memset)
25806 CFI_STARTPROC
25807 - movq %rdi,%r10
25808 + movq %rdi,%r11
25809
25810 /* expand byte value */
25811 movzbl %sil,%ecx
25812 @@ -117,7 +119,8 @@ ENTRY(__memset)
25813 jnz .Lloop_1
25814
25815 .Lende:
25816 - movq %r10,%rax
25817 + movq %r11,%rax
25818 + pax_force_retaddr
25819 ret
25820
25821 CFI_RESTORE_STATE
25822 diff --git a/arch/x86/lib/mmx_32.c b/arch/x86/lib/mmx_32.c
25823 index c9f2d9b..e7fd2c0 100644
25824 --- a/arch/x86/lib/mmx_32.c
25825 +++ b/arch/x86/lib/mmx_32.c
25826 @@ -29,6 +29,7 @@ void *_mmx_memcpy(void *to, const void *from, size_t len)
25827 {
25828 void *p;
25829 int i;
25830 + unsigned long cr0;
25831
25832 if (unlikely(in_interrupt()))
25833 return __memcpy(to, from, len);
25834 @@ -39,44 +40,72 @@ void *_mmx_memcpy(void *to, const void *from, size_t len)
25835 kernel_fpu_begin();
25836
25837 __asm__ __volatile__ (
25838 - "1: prefetch (%0)\n" /* This set is 28 bytes */
25839 - " prefetch 64(%0)\n"
25840 - " prefetch 128(%0)\n"
25841 - " prefetch 192(%0)\n"
25842 - " prefetch 256(%0)\n"
25843 + "1: prefetch (%1)\n" /* This set is 28 bytes */
25844 + " prefetch 64(%1)\n"
25845 + " prefetch 128(%1)\n"
25846 + " prefetch 192(%1)\n"
25847 + " prefetch 256(%1)\n"
25848 "2: \n"
25849 ".section .fixup, \"ax\"\n"
25850 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
25851 + "3: \n"
25852 +
25853 +#ifdef CONFIG_PAX_KERNEXEC
25854 + " movl %%cr0, %0\n"
25855 + " movl %0, %%eax\n"
25856 + " andl $0xFFFEFFFF, %%eax\n"
25857 + " movl %%eax, %%cr0\n"
25858 +#endif
25859 +
25860 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
25861 +
25862 +#ifdef CONFIG_PAX_KERNEXEC
25863 + " movl %0, %%cr0\n"
25864 +#endif
25865 +
25866 " jmp 2b\n"
25867 ".previous\n"
25868 _ASM_EXTABLE(1b, 3b)
25869 - : : "r" (from));
25870 + : "=&r" (cr0) : "r" (from) : "ax");
25871
25872 for ( ; i > 5; i--) {
25873 __asm__ __volatile__ (
25874 - "1: prefetch 320(%0)\n"
25875 - "2: movq (%0), %%mm0\n"
25876 - " movq 8(%0), %%mm1\n"
25877 - " movq 16(%0), %%mm2\n"
25878 - " movq 24(%0), %%mm3\n"
25879 - " movq %%mm0, (%1)\n"
25880 - " movq %%mm1, 8(%1)\n"
25881 - " movq %%mm2, 16(%1)\n"
25882 - " movq %%mm3, 24(%1)\n"
25883 - " movq 32(%0), %%mm0\n"
25884 - " movq 40(%0), %%mm1\n"
25885 - " movq 48(%0), %%mm2\n"
25886 - " movq 56(%0), %%mm3\n"
25887 - " movq %%mm0, 32(%1)\n"
25888 - " movq %%mm1, 40(%1)\n"
25889 - " movq %%mm2, 48(%1)\n"
25890 - " movq %%mm3, 56(%1)\n"
25891 + "1: prefetch 320(%1)\n"
25892 + "2: movq (%1), %%mm0\n"
25893 + " movq 8(%1), %%mm1\n"
25894 + " movq 16(%1), %%mm2\n"
25895 + " movq 24(%1), %%mm3\n"
25896 + " movq %%mm0, (%2)\n"
25897 + " movq %%mm1, 8(%2)\n"
25898 + " movq %%mm2, 16(%2)\n"
25899 + " movq %%mm3, 24(%2)\n"
25900 + " movq 32(%1), %%mm0\n"
25901 + " movq 40(%1), %%mm1\n"
25902 + " movq 48(%1), %%mm2\n"
25903 + " movq 56(%1), %%mm3\n"
25904 + " movq %%mm0, 32(%2)\n"
25905 + " movq %%mm1, 40(%2)\n"
25906 + " movq %%mm2, 48(%2)\n"
25907 + " movq %%mm3, 56(%2)\n"
25908 ".section .fixup, \"ax\"\n"
25909 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
25910 + "3:\n"
25911 +
25912 +#ifdef CONFIG_PAX_KERNEXEC
25913 + " movl %%cr0, %0\n"
25914 + " movl %0, %%eax\n"
25915 + " andl $0xFFFEFFFF, %%eax\n"
25916 + " movl %%eax, %%cr0\n"
25917 +#endif
25918 +
25919 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
25920 +
25921 +#ifdef CONFIG_PAX_KERNEXEC
25922 + " movl %0, %%cr0\n"
25923 +#endif
25924 +
25925 " jmp 2b\n"
25926 ".previous\n"
25927 _ASM_EXTABLE(1b, 3b)
25928 - : : "r" (from), "r" (to) : "memory");
25929 + : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
25930
25931 from += 64;
25932 to += 64;
25933 @@ -158,6 +187,7 @@ static void fast_clear_page(void *page)
25934 static void fast_copy_page(void *to, void *from)
25935 {
25936 int i;
25937 + unsigned long cr0;
25938
25939 kernel_fpu_begin();
25940
25941 @@ -166,42 +196,70 @@ static void fast_copy_page(void *to, void *from)
25942 * but that is for later. -AV
25943 */
25944 __asm__ __volatile__(
25945 - "1: prefetch (%0)\n"
25946 - " prefetch 64(%0)\n"
25947 - " prefetch 128(%0)\n"
25948 - " prefetch 192(%0)\n"
25949 - " prefetch 256(%0)\n"
25950 + "1: prefetch (%1)\n"
25951 + " prefetch 64(%1)\n"
25952 + " prefetch 128(%1)\n"
25953 + " prefetch 192(%1)\n"
25954 + " prefetch 256(%1)\n"
25955 "2: \n"
25956 ".section .fixup, \"ax\"\n"
25957 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
25958 + "3: \n"
25959 +
25960 +#ifdef CONFIG_PAX_KERNEXEC
25961 + " movl %%cr0, %0\n"
25962 + " movl %0, %%eax\n"
25963 + " andl $0xFFFEFFFF, %%eax\n"
25964 + " movl %%eax, %%cr0\n"
25965 +#endif
25966 +
25967 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
25968 +
25969 +#ifdef CONFIG_PAX_KERNEXEC
25970 + " movl %0, %%cr0\n"
25971 +#endif
25972 +
25973 " jmp 2b\n"
25974 ".previous\n"
25975 - _ASM_EXTABLE(1b, 3b) : : "r" (from));
25976 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from) : "ax");
25977
25978 for (i = 0; i < (4096-320)/64; i++) {
25979 __asm__ __volatile__ (
25980 - "1: prefetch 320(%0)\n"
25981 - "2: movq (%0), %%mm0\n"
25982 - " movntq %%mm0, (%1)\n"
25983 - " movq 8(%0), %%mm1\n"
25984 - " movntq %%mm1, 8(%1)\n"
25985 - " movq 16(%0), %%mm2\n"
25986 - " movntq %%mm2, 16(%1)\n"
25987 - " movq 24(%0), %%mm3\n"
25988 - " movntq %%mm3, 24(%1)\n"
25989 - " movq 32(%0), %%mm4\n"
25990 - " movntq %%mm4, 32(%1)\n"
25991 - " movq 40(%0), %%mm5\n"
25992 - " movntq %%mm5, 40(%1)\n"
25993 - " movq 48(%0), %%mm6\n"
25994 - " movntq %%mm6, 48(%1)\n"
25995 - " movq 56(%0), %%mm7\n"
25996 - " movntq %%mm7, 56(%1)\n"
25997 + "1: prefetch 320(%1)\n"
25998 + "2: movq (%1), %%mm0\n"
25999 + " movntq %%mm0, (%2)\n"
26000 + " movq 8(%1), %%mm1\n"
26001 + " movntq %%mm1, 8(%2)\n"
26002 + " movq 16(%1), %%mm2\n"
26003 + " movntq %%mm2, 16(%2)\n"
26004 + " movq 24(%1), %%mm3\n"
26005 + " movntq %%mm3, 24(%2)\n"
26006 + " movq 32(%1), %%mm4\n"
26007 + " movntq %%mm4, 32(%2)\n"
26008 + " movq 40(%1), %%mm5\n"
26009 + " movntq %%mm5, 40(%2)\n"
26010 + " movq 48(%1), %%mm6\n"
26011 + " movntq %%mm6, 48(%2)\n"
26012 + " movq 56(%1), %%mm7\n"
26013 + " movntq %%mm7, 56(%2)\n"
26014 ".section .fixup, \"ax\"\n"
26015 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
26016 + "3:\n"
26017 +
26018 +#ifdef CONFIG_PAX_KERNEXEC
26019 + " movl %%cr0, %0\n"
26020 + " movl %0, %%eax\n"
26021 + " andl $0xFFFEFFFF, %%eax\n"
26022 + " movl %%eax, %%cr0\n"
26023 +#endif
26024 +
26025 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
26026 +
26027 +#ifdef CONFIG_PAX_KERNEXEC
26028 + " movl %0, %%cr0\n"
26029 +#endif
26030 +
26031 " jmp 2b\n"
26032 ".previous\n"
26033 - _ASM_EXTABLE(1b, 3b) : : "r" (from), "r" (to) : "memory");
26034 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
26035
26036 from += 64;
26037 to += 64;
26038 @@ -280,47 +338,76 @@ static void fast_clear_page(void *page)
26039 static void fast_copy_page(void *to, void *from)
26040 {
26041 int i;
26042 + unsigned long cr0;
26043
26044 kernel_fpu_begin();
26045
26046 __asm__ __volatile__ (
26047 - "1: prefetch (%0)\n"
26048 - " prefetch 64(%0)\n"
26049 - " prefetch 128(%0)\n"
26050 - " prefetch 192(%0)\n"
26051 - " prefetch 256(%0)\n"
26052 + "1: prefetch (%1)\n"
26053 + " prefetch 64(%1)\n"
26054 + " prefetch 128(%1)\n"
26055 + " prefetch 192(%1)\n"
26056 + " prefetch 256(%1)\n"
26057 "2: \n"
26058 ".section .fixup, \"ax\"\n"
26059 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
26060 + "3: \n"
26061 +
26062 +#ifdef CONFIG_PAX_KERNEXEC
26063 + " movl %%cr0, %0\n"
26064 + " movl %0, %%eax\n"
26065 + " andl $0xFFFEFFFF, %%eax\n"
26066 + " movl %%eax, %%cr0\n"
26067 +#endif
26068 +
26069 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
26070 +
26071 +#ifdef CONFIG_PAX_KERNEXEC
26072 + " movl %0, %%cr0\n"
26073 +#endif
26074 +
26075 " jmp 2b\n"
26076 ".previous\n"
26077 - _ASM_EXTABLE(1b, 3b) : : "r" (from));
26078 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from) : "ax");
26079
26080 for (i = 0; i < 4096/64; i++) {
26081 __asm__ __volatile__ (
26082 - "1: prefetch 320(%0)\n"
26083 - "2: movq (%0), %%mm0\n"
26084 - " movq 8(%0), %%mm1\n"
26085 - " movq 16(%0), %%mm2\n"
26086 - " movq 24(%0), %%mm3\n"
26087 - " movq %%mm0, (%1)\n"
26088 - " movq %%mm1, 8(%1)\n"
26089 - " movq %%mm2, 16(%1)\n"
26090 - " movq %%mm3, 24(%1)\n"
26091 - " movq 32(%0), %%mm0\n"
26092 - " movq 40(%0), %%mm1\n"
26093 - " movq 48(%0), %%mm2\n"
26094 - " movq 56(%0), %%mm3\n"
26095 - " movq %%mm0, 32(%1)\n"
26096 - " movq %%mm1, 40(%1)\n"
26097 - " movq %%mm2, 48(%1)\n"
26098 - " movq %%mm3, 56(%1)\n"
26099 + "1: prefetch 320(%1)\n"
26100 + "2: movq (%1), %%mm0\n"
26101 + " movq 8(%1), %%mm1\n"
26102 + " movq 16(%1), %%mm2\n"
26103 + " movq 24(%1), %%mm3\n"
26104 + " movq %%mm0, (%2)\n"
26105 + " movq %%mm1, 8(%2)\n"
26106 + " movq %%mm2, 16(%2)\n"
26107 + " movq %%mm3, 24(%2)\n"
26108 + " movq 32(%1), %%mm0\n"
26109 + " movq 40(%1), %%mm1\n"
26110 + " movq 48(%1), %%mm2\n"
26111 + " movq 56(%1), %%mm3\n"
26112 + " movq %%mm0, 32(%2)\n"
26113 + " movq %%mm1, 40(%2)\n"
26114 + " movq %%mm2, 48(%2)\n"
26115 + " movq %%mm3, 56(%2)\n"
26116 ".section .fixup, \"ax\"\n"
26117 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
26118 + "3:\n"
26119 +
26120 +#ifdef CONFIG_PAX_KERNEXEC
26121 + " movl %%cr0, %0\n"
26122 + " movl %0, %%eax\n"
26123 + " andl $0xFFFEFFFF, %%eax\n"
26124 + " movl %%eax, %%cr0\n"
26125 +#endif
26126 +
26127 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
26128 +
26129 +#ifdef CONFIG_PAX_KERNEXEC
26130 + " movl %0, %%cr0\n"
26131 +#endif
26132 +
26133 " jmp 2b\n"
26134 ".previous\n"
26135 _ASM_EXTABLE(1b, 3b)
26136 - : : "r" (from), "r" (to) : "memory");
26137 + : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
26138
26139 from += 64;
26140 to += 64;
26141 diff --git a/arch/x86/lib/msr-reg.S b/arch/x86/lib/msr-reg.S
26142 index f6d13ee..aca5f0b 100644
26143 --- a/arch/x86/lib/msr-reg.S
26144 +++ b/arch/x86/lib/msr-reg.S
26145 @@ -3,6 +3,7 @@
26146 #include <asm/dwarf2.h>
26147 #include <asm/asm.h>
26148 #include <asm/msr.h>
26149 +#include <asm/alternative-asm.h>
26150
26151 #ifdef CONFIG_X86_64
26152 /*
26153 @@ -16,7 +17,7 @@ ENTRY(\op\()_safe_regs)
26154 CFI_STARTPROC
26155 pushq_cfi %rbx
26156 pushq_cfi %rbp
26157 - movq %rdi, %r10 /* Save pointer */
26158 + movq %rdi, %r9 /* Save pointer */
26159 xorl %r11d, %r11d /* Return value */
26160 movl (%rdi), %eax
26161 movl 4(%rdi), %ecx
26162 @@ -27,16 +28,17 @@ ENTRY(\op\()_safe_regs)
26163 movl 28(%rdi), %edi
26164 CFI_REMEMBER_STATE
26165 1: \op
26166 -2: movl %eax, (%r10)
26167 +2: movl %eax, (%r9)
26168 movl %r11d, %eax /* Return value */
26169 - movl %ecx, 4(%r10)
26170 - movl %edx, 8(%r10)
26171 - movl %ebx, 12(%r10)
26172 - movl %ebp, 20(%r10)
26173 - movl %esi, 24(%r10)
26174 - movl %edi, 28(%r10)
26175 + movl %ecx, 4(%r9)
26176 + movl %edx, 8(%r9)
26177 + movl %ebx, 12(%r9)
26178 + movl %ebp, 20(%r9)
26179 + movl %esi, 24(%r9)
26180 + movl %edi, 28(%r9)
26181 popq_cfi %rbp
26182 popq_cfi %rbx
26183 + pax_force_retaddr
26184 ret
26185 3:
26186 CFI_RESTORE_STATE
26187 diff --git a/arch/x86/lib/putuser.S b/arch/x86/lib/putuser.S
26188 index fc6ba17..d4d989d 100644
26189 --- a/arch/x86/lib/putuser.S
26190 +++ b/arch/x86/lib/putuser.S
26191 @@ -16,7 +16,9 @@
26192 #include <asm/errno.h>
26193 #include <asm/asm.h>
26194 #include <asm/smap.h>
26195 -
26196 +#include <asm/segment.h>
26197 +#include <asm/pgtable.h>
26198 +#include <asm/alternative-asm.h>
26199
26200 /*
26201 * __put_user_X
26202 @@ -30,57 +32,125 @@
26203 * as they get called from within inline assembly.
26204 */
26205
26206 -#define ENTER CFI_STARTPROC ; \
26207 - GET_THREAD_INFO(%_ASM_BX)
26208 -#define EXIT ASM_CLAC ; \
26209 - ret ; \
26210 +#define ENTER CFI_STARTPROC
26211 +#define EXIT ASM_CLAC ; \
26212 + pax_force_retaddr ; \
26213 + ret ; \
26214 CFI_ENDPROC
26215
26216 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26217 +#define _DEST %_ASM_CX,%_ASM_BX
26218 +#else
26219 +#define _DEST %_ASM_CX
26220 +#endif
26221 +
26222 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
26223 +#define __copyuser_seg gs;
26224 +#else
26225 +#define __copyuser_seg
26226 +#endif
26227 +
26228 .text
26229 ENTRY(__put_user_1)
26230 ENTER
26231 +
26232 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
26233 + GET_THREAD_INFO(%_ASM_BX)
26234 cmp TI_addr_limit(%_ASM_BX),%_ASM_CX
26235 jae bad_put_user
26236 ASM_STAC
26237 -1: movb %al,(%_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 +1: __copyuser_seg movb %al,(_DEST)
26250 xor %eax,%eax
26251 EXIT
26252 ENDPROC(__put_user_1)
26253
26254 ENTRY(__put_user_2)
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 $1,%_ASM_BX
26261 cmp %_ASM_BX,%_ASM_CX
26262 jae bad_put_user
26263 ASM_STAC
26264 -2: movw %ax,(%_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 +2: __copyuser_seg movw %ax,(_DEST)
26277 xor %eax,%eax
26278 EXIT
26279 ENDPROC(__put_user_2)
26280
26281 ENTRY(__put_user_4)
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 $3,%_ASM_BX
26288 cmp %_ASM_BX,%_ASM_CX
26289 jae bad_put_user
26290 ASM_STAC
26291 -3: movl %eax,(%_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 +3: __copyuser_seg movl %eax,(_DEST)
26304 xor %eax,%eax
26305 EXIT
26306 ENDPROC(__put_user_4)
26307
26308 ENTRY(__put_user_8)
26309 ENTER
26310 +
26311 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
26312 + GET_THREAD_INFO(%_ASM_BX)
26313 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
26314 sub $7,%_ASM_BX
26315 cmp %_ASM_BX,%_ASM_CX
26316 jae bad_put_user
26317 ASM_STAC
26318 -4: mov %_ASM_AX,(%_ASM_CX)
26319 +
26320 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26321 + mov pax_user_shadow_base,%_ASM_BX
26322 + cmp %_ASM_BX,%_ASM_CX
26323 + jb 1234f
26324 + xor %ebx,%ebx
26325 +1234:
26326 +#endif
26327 +
26328 +#endif
26329 +
26330 +4: __copyuser_seg mov %_ASM_AX,(_DEST)
26331 #ifdef CONFIG_X86_32
26332 -5: movl %edx,4(%_ASM_CX)
26333 +5: __copyuser_seg movl %edx,4(_DEST)
26334 #endif
26335 xor %eax,%eax
26336 EXIT
26337 diff --git a/arch/x86/lib/rwlock.S b/arch/x86/lib/rwlock.S
26338 index 1cad221..de671ee 100644
26339 --- a/arch/x86/lib/rwlock.S
26340 +++ b/arch/x86/lib/rwlock.S
26341 @@ -16,13 +16,34 @@ ENTRY(__write_lock_failed)
26342 FRAME
26343 0: LOCK_PREFIX
26344 WRITE_LOCK_ADD($RW_LOCK_BIAS) (%__lock_ptr)
26345 +
26346 +#ifdef CONFIG_PAX_REFCOUNT
26347 + jno 1234f
26348 + LOCK_PREFIX
26349 + WRITE_LOCK_SUB($RW_LOCK_BIAS) (%__lock_ptr)
26350 + int $4
26351 +1234:
26352 + _ASM_EXTABLE(1234b, 1234b)
26353 +#endif
26354 +
26355 1: rep; nop
26356 cmpl $WRITE_LOCK_CMP, (%__lock_ptr)
26357 jne 1b
26358 LOCK_PREFIX
26359 WRITE_LOCK_SUB($RW_LOCK_BIAS) (%__lock_ptr)
26360 +
26361 +#ifdef CONFIG_PAX_REFCOUNT
26362 + jno 1234f
26363 + LOCK_PREFIX
26364 + WRITE_LOCK_ADD($RW_LOCK_BIAS) (%__lock_ptr)
26365 + int $4
26366 +1234:
26367 + _ASM_EXTABLE(1234b, 1234b)
26368 +#endif
26369 +
26370 jnz 0b
26371 ENDFRAME
26372 + pax_force_retaddr
26373 ret
26374 CFI_ENDPROC
26375 END(__write_lock_failed)
26376 @@ -32,13 +53,34 @@ ENTRY(__read_lock_failed)
26377 FRAME
26378 0: LOCK_PREFIX
26379 READ_LOCK_SIZE(inc) (%__lock_ptr)
26380 +
26381 +#ifdef CONFIG_PAX_REFCOUNT
26382 + jno 1234f
26383 + LOCK_PREFIX
26384 + READ_LOCK_SIZE(dec) (%__lock_ptr)
26385 + int $4
26386 +1234:
26387 + _ASM_EXTABLE(1234b, 1234b)
26388 +#endif
26389 +
26390 1: rep; nop
26391 READ_LOCK_SIZE(cmp) $1, (%__lock_ptr)
26392 js 1b
26393 LOCK_PREFIX
26394 READ_LOCK_SIZE(dec) (%__lock_ptr)
26395 +
26396 +#ifdef CONFIG_PAX_REFCOUNT
26397 + jno 1234f
26398 + LOCK_PREFIX
26399 + READ_LOCK_SIZE(inc) (%__lock_ptr)
26400 + int $4
26401 +1234:
26402 + _ASM_EXTABLE(1234b, 1234b)
26403 +#endif
26404 +
26405 js 0b
26406 ENDFRAME
26407 + pax_force_retaddr
26408 ret
26409 CFI_ENDPROC
26410 END(__read_lock_failed)
26411 diff --git a/arch/x86/lib/rwsem.S b/arch/x86/lib/rwsem.S
26412 index 5dff5f0..cadebf4 100644
26413 --- a/arch/x86/lib/rwsem.S
26414 +++ b/arch/x86/lib/rwsem.S
26415 @@ -94,6 +94,7 @@ ENTRY(call_rwsem_down_read_failed)
26416 __ASM_SIZE(pop,_cfi) %__ASM_REG(dx)
26417 CFI_RESTORE __ASM_REG(dx)
26418 restore_common_regs
26419 + pax_force_retaddr
26420 ret
26421 CFI_ENDPROC
26422 ENDPROC(call_rwsem_down_read_failed)
26423 @@ -104,6 +105,7 @@ ENTRY(call_rwsem_down_write_failed)
26424 movq %rax,%rdi
26425 call rwsem_down_write_failed
26426 restore_common_regs
26427 + pax_force_retaddr
26428 ret
26429 CFI_ENDPROC
26430 ENDPROC(call_rwsem_down_write_failed)
26431 @@ -117,7 +119,8 @@ ENTRY(call_rwsem_wake)
26432 movq %rax,%rdi
26433 call rwsem_wake
26434 restore_common_regs
26435 -1: ret
26436 +1: pax_force_retaddr
26437 + ret
26438 CFI_ENDPROC
26439 ENDPROC(call_rwsem_wake)
26440
26441 @@ -131,6 +134,7 @@ ENTRY(call_rwsem_downgrade_wake)
26442 __ASM_SIZE(pop,_cfi) %__ASM_REG(dx)
26443 CFI_RESTORE __ASM_REG(dx)
26444 restore_common_regs
26445 + pax_force_retaddr
26446 ret
26447 CFI_ENDPROC
26448 ENDPROC(call_rwsem_downgrade_wake)
26449 diff --git a/arch/x86/lib/thunk_64.S b/arch/x86/lib/thunk_64.S
26450 index a63efd6..ccecad8 100644
26451 --- a/arch/x86/lib/thunk_64.S
26452 +++ b/arch/x86/lib/thunk_64.S
26453 @@ -8,6 +8,7 @@
26454 #include <linux/linkage.h>
26455 #include <asm/dwarf2.h>
26456 #include <asm/calling.h>
26457 +#include <asm/alternative-asm.h>
26458
26459 /* rdi: arg1 ... normal C conventions. rax is saved/restored. */
26460 .macro THUNK name, func, put_ret_addr_in_rdi=0
26461 @@ -41,5 +42,6 @@
26462 SAVE_ARGS
26463 restore:
26464 RESTORE_ARGS
26465 + pax_force_retaddr
26466 ret
26467 CFI_ENDPROC
26468 diff --git a/arch/x86/lib/usercopy_32.c b/arch/x86/lib/usercopy_32.c
26469 index f0312d7..9c39d63 100644
26470 --- a/arch/x86/lib/usercopy_32.c
26471 +++ b/arch/x86/lib/usercopy_32.c
26472 @@ -42,11 +42,13 @@ do { \
26473 int __d0; \
26474 might_fault(); \
26475 __asm__ __volatile__( \
26476 + __COPYUSER_SET_ES \
26477 ASM_STAC "\n" \
26478 "0: rep; stosl\n" \
26479 " movl %2,%0\n" \
26480 "1: rep; stosb\n" \
26481 "2: " ASM_CLAC "\n" \
26482 + __COPYUSER_RESTORE_ES \
26483 ".section .fixup,\"ax\"\n" \
26484 "3: lea 0(%2,%0,4),%0\n" \
26485 " jmp 2b\n" \
26486 @@ -98,7 +100,7 @@ EXPORT_SYMBOL(__clear_user);
26487
26488 #ifdef CONFIG_X86_INTEL_USERCOPY
26489 static unsigned long
26490 -__copy_user_intel(void __user *to, const void *from, unsigned long size)
26491 +__generic_copy_to_user_intel(void __user *to, const void *from, unsigned long size)
26492 {
26493 int d0, d1;
26494 __asm__ __volatile__(
26495 @@ -110,36 +112,36 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
26496 " .align 2,0x90\n"
26497 "3: movl 0(%4), %%eax\n"
26498 "4: movl 4(%4), %%edx\n"
26499 - "5: movl %%eax, 0(%3)\n"
26500 - "6: movl %%edx, 4(%3)\n"
26501 + "5: "__copyuser_seg" movl %%eax, 0(%3)\n"
26502 + "6: "__copyuser_seg" movl %%edx, 4(%3)\n"
26503 "7: movl 8(%4), %%eax\n"
26504 "8: movl 12(%4),%%edx\n"
26505 - "9: movl %%eax, 8(%3)\n"
26506 - "10: movl %%edx, 12(%3)\n"
26507 + "9: "__copyuser_seg" movl %%eax, 8(%3)\n"
26508 + "10: "__copyuser_seg" movl %%edx, 12(%3)\n"
26509 "11: movl 16(%4), %%eax\n"
26510 "12: movl 20(%4), %%edx\n"
26511 - "13: movl %%eax, 16(%3)\n"
26512 - "14: movl %%edx, 20(%3)\n"
26513 + "13: "__copyuser_seg" movl %%eax, 16(%3)\n"
26514 + "14: "__copyuser_seg" movl %%edx, 20(%3)\n"
26515 "15: movl 24(%4), %%eax\n"
26516 "16: movl 28(%4), %%edx\n"
26517 - "17: movl %%eax, 24(%3)\n"
26518 - "18: movl %%edx, 28(%3)\n"
26519 + "17: "__copyuser_seg" movl %%eax, 24(%3)\n"
26520 + "18: "__copyuser_seg" movl %%edx, 28(%3)\n"
26521 "19: movl 32(%4), %%eax\n"
26522 "20: movl 36(%4), %%edx\n"
26523 - "21: movl %%eax, 32(%3)\n"
26524 - "22: movl %%edx, 36(%3)\n"
26525 + "21: "__copyuser_seg" movl %%eax, 32(%3)\n"
26526 + "22: "__copyuser_seg" movl %%edx, 36(%3)\n"
26527 "23: movl 40(%4), %%eax\n"
26528 "24: movl 44(%4), %%edx\n"
26529 - "25: movl %%eax, 40(%3)\n"
26530 - "26: movl %%edx, 44(%3)\n"
26531 + "25: "__copyuser_seg" movl %%eax, 40(%3)\n"
26532 + "26: "__copyuser_seg" movl %%edx, 44(%3)\n"
26533 "27: movl 48(%4), %%eax\n"
26534 "28: movl 52(%4), %%edx\n"
26535 - "29: movl %%eax, 48(%3)\n"
26536 - "30: movl %%edx, 52(%3)\n"
26537 + "29: "__copyuser_seg" movl %%eax, 48(%3)\n"
26538 + "30: "__copyuser_seg" movl %%edx, 52(%3)\n"
26539 "31: movl 56(%4), %%eax\n"
26540 "32: movl 60(%4), %%edx\n"
26541 - "33: movl %%eax, 56(%3)\n"
26542 - "34: movl %%edx, 60(%3)\n"
26543 + "33: "__copyuser_seg" movl %%eax, 56(%3)\n"
26544 + "34: "__copyuser_seg" movl %%edx, 60(%3)\n"
26545 " addl $-64, %0\n"
26546 " addl $64, %4\n"
26547 " addl $64, %3\n"
26548 @@ -149,10 +151,12 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
26549 " shrl $2, %0\n"
26550 " andl $3, %%eax\n"
26551 " cld\n"
26552 + __COPYUSER_SET_ES
26553 "99: rep; movsl\n"
26554 "36: movl %%eax, %0\n"
26555 "37: rep; movsb\n"
26556 "100:\n"
26557 + __COPYUSER_RESTORE_ES
26558 ".section .fixup,\"ax\"\n"
26559 "101: lea 0(%%eax,%0,4),%0\n"
26560 " jmp 100b\n"
26561 @@ -202,46 +206,150 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
26562 }
26563
26564 static unsigned long
26565 +__generic_copy_from_user_intel(void *to, const void __user *from, unsigned long size)
26566 +{
26567 + int d0, d1;
26568 + __asm__ __volatile__(
26569 + " .align 2,0x90\n"
26570 + "1: "__copyuser_seg" movl 32(%4), %%eax\n"
26571 + " cmpl $67, %0\n"
26572 + " jbe 3f\n"
26573 + "2: "__copyuser_seg" movl 64(%4), %%eax\n"
26574 + " .align 2,0x90\n"
26575 + "3: "__copyuser_seg" movl 0(%4), %%eax\n"
26576 + "4: "__copyuser_seg" movl 4(%4), %%edx\n"
26577 + "5: movl %%eax, 0(%3)\n"
26578 + "6: movl %%edx, 4(%3)\n"
26579 + "7: "__copyuser_seg" movl 8(%4), %%eax\n"
26580 + "8: "__copyuser_seg" movl 12(%4),%%edx\n"
26581 + "9: movl %%eax, 8(%3)\n"
26582 + "10: movl %%edx, 12(%3)\n"
26583 + "11: "__copyuser_seg" movl 16(%4), %%eax\n"
26584 + "12: "__copyuser_seg" movl 20(%4), %%edx\n"
26585 + "13: movl %%eax, 16(%3)\n"
26586 + "14: movl %%edx, 20(%3)\n"
26587 + "15: "__copyuser_seg" movl 24(%4), %%eax\n"
26588 + "16: "__copyuser_seg" movl 28(%4), %%edx\n"
26589 + "17: movl %%eax, 24(%3)\n"
26590 + "18: movl %%edx, 28(%3)\n"
26591 + "19: "__copyuser_seg" movl 32(%4), %%eax\n"
26592 + "20: "__copyuser_seg" movl 36(%4), %%edx\n"
26593 + "21: movl %%eax, 32(%3)\n"
26594 + "22: movl %%edx, 36(%3)\n"
26595 + "23: "__copyuser_seg" movl 40(%4), %%eax\n"
26596 + "24: "__copyuser_seg" movl 44(%4), %%edx\n"
26597 + "25: movl %%eax, 40(%3)\n"
26598 + "26: movl %%edx, 44(%3)\n"
26599 + "27: "__copyuser_seg" movl 48(%4), %%eax\n"
26600 + "28: "__copyuser_seg" movl 52(%4), %%edx\n"
26601 + "29: movl %%eax, 48(%3)\n"
26602 + "30: movl %%edx, 52(%3)\n"
26603 + "31: "__copyuser_seg" movl 56(%4), %%eax\n"
26604 + "32: "__copyuser_seg" movl 60(%4), %%edx\n"
26605 + "33: movl %%eax, 56(%3)\n"
26606 + "34: movl %%edx, 60(%3)\n"
26607 + " addl $-64, %0\n"
26608 + " addl $64, %4\n"
26609 + " addl $64, %3\n"
26610 + " cmpl $63, %0\n"
26611 + " ja 1b\n"
26612 + "35: movl %0, %%eax\n"
26613 + " shrl $2, %0\n"
26614 + " andl $3, %%eax\n"
26615 + " cld\n"
26616 + "99: rep; "__copyuser_seg" movsl\n"
26617 + "36: movl %%eax, %0\n"
26618 + "37: rep; "__copyuser_seg" movsb\n"
26619 + "100:\n"
26620 + ".section .fixup,\"ax\"\n"
26621 + "101: lea 0(%%eax,%0,4),%0\n"
26622 + " jmp 100b\n"
26623 + ".previous\n"
26624 + _ASM_EXTABLE(1b,100b)
26625 + _ASM_EXTABLE(2b,100b)
26626 + _ASM_EXTABLE(3b,100b)
26627 + _ASM_EXTABLE(4b,100b)
26628 + _ASM_EXTABLE(5b,100b)
26629 + _ASM_EXTABLE(6b,100b)
26630 + _ASM_EXTABLE(7b,100b)
26631 + _ASM_EXTABLE(8b,100b)
26632 + _ASM_EXTABLE(9b,100b)
26633 + _ASM_EXTABLE(10b,100b)
26634 + _ASM_EXTABLE(11b,100b)
26635 + _ASM_EXTABLE(12b,100b)
26636 + _ASM_EXTABLE(13b,100b)
26637 + _ASM_EXTABLE(14b,100b)
26638 + _ASM_EXTABLE(15b,100b)
26639 + _ASM_EXTABLE(16b,100b)
26640 + _ASM_EXTABLE(17b,100b)
26641 + _ASM_EXTABLE(18b,100b)
26642 + _ASM_EXTABLE(19b,100b)
26643 + _ASM_EXTABLE(20b,100b)
26644 + _ASM_EXTABLE(21b,100b)
26645 + _ASM_EXTABLE(22b,100b)
26646 + _ASM_EXTABLE(23b,100b)
26647 + _ASM_EXTABLE(24b,100b)
26648 + _ASM_EXTABLE(25b,100b)
26649 + _ASM_EXTABLE(26b,100b)
26650 + _ASM_EXTABLE(27b,100b)
26651 + _ASM_EXTABLE(28b,100b)
26652 + _ASM_EXTABLE(29b,100b)
26653 + _ASM_EXTABLE(30b,100b)
26654 + _ASM_EXTABLE(31b,100b)
26655 + _ASM_EXTABLE(32b,100b)
26656 + _ASM_EXTABLE(33b,100b)
26657 + _ASM_EXTABLE(34b,100b)
26658 + _ASM_EXTABLE(35b,100b)
26659 + _ASM_EXTABLE(36b,100b)
26660 + _ASM_EXTABLE(37b,100b)
26661 + _ASM_EXTABLE(99b,101b)
26662 + : "=&c"(size), "=&D" (d0), "=&S" (d1)
26663 + : "1"(to), "2"(from), "0"(size)
26664 + : "eax", "edx", "memory");
26665 + return size;
26666 +}
26667 +
26668 +static unsigned long __size_overflow(3)
26669 __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
26670 {
26671 int d0, d1;
26672 __asm__ __volatile__(
26673 " .align 2,0x90\n"
26674 - "0: movl 32(%4), %%eax\n"
26675 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
26676 " cmpl $67, %0\n"
26677 " jbe 2f\n"
26678 - "1: movl 64(%4), %%eax\n"
26679 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
26680 " .align 2,0x90\n"
26681 - "2: movl 0(%4), %%eax\n"
26682 - "21: movl 4(%4), %%edx\n"
26683 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
26684 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
26685 " movl %%eax, 0(%3)\n"
26686 " movl %%edx, 4(%3)\n"
26687 - "3: movl 8(%4), %%eax\n"
26688 - "31: movl 12(%4),%%edx\n"
26689 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
26690 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
26691 " movl %%eax, 8(%3)\n"
26692 " movl %%edx, 12(%3)\n"
26693 - "4: movl 16(%4), %%eax\n"
26694 - "41: movl 20(%4), %%edx\n"
26695 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
26696 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
26697 " movl %%eax, 16(%3)\n"
26698 " movl %%edx, 20(%3)\n"
26699 - "10: movl 24(%4), %%eax\n"
26700 - "51: movl 28(%4), %%edx\n"
26701 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
26702 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
26703 " movl %%eax, 24(%3)\n"
26704 " movl %%edx, 28(%3)\n"
26705 - "11: movl 32(%4), %%eax\n"
26706 - "61: movl 36(%4), %%edx\n"
26707 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
26708 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
26709 " movl %%eax, 32(%3)\n"
26710 " movl %%edx, 36(%3)\n"
26711 - "12: movl 40(%4), %%eax\n"
26712 - "71: movl 44(%4), %%edx\n"
26713 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
26714 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
26715 " movl %%eax, 40(%3)\n"
26716 " movl %%edx, 44(%3)\n"
26717 - "13: movl 48(%4), %%eax\n"
26718 - "81: movl 52(%4), %%edx\n"
26719 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
26720 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
26721 " movl %%eax, 48(%3)\n"
26722 " movl %%edx, 52(%3)\n"
26723 - "14: movl 56(%4), %%eax\n"
26724 - "91: movl 60(%4), %%edx\n"
26725 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
26726 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
26727 " movl %%eax, 56(%3)\n"
26728 " movl %%edx, 60(%3)\n"
26729 " addl $-64, %0\n"
26730 @@ -253,9 +361,9 @@ __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
26731 " shrl $2, %0\n"
26732 " andl $3, %%eax\n"
26733 " cld\n"
26734 - "6: rep; movsl\n"
26735 + "6: rep; "__copyuser_seg" movsl\n"
26736 " movl %%eax,%0\n"
26737 - "7: rep; movsb\n"
26738 + "7: rep; "__copyuser_seg" movsb\n"
26739 "8:\n"
26740 ".section .fixup,\"ax\"\n"
26741 "9: lea 0(%%eax,%0,4),%0\n"
26742 @@ -298,48 +406,48 @@ __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
26743 * hyoshiok@miraclelinux.com
26744 */
26745
26746 -static unsigned long __copy_user_zeroing_intel_nocache(void *to,
26747 +static unsigned long __size_overflow(3) __copy_user_zeroing_intel_nocache(void *to,
26748 const void __user *from, unsigned long size)
26749 {
26750 int d0, d1;
26751
26752 __asm__ __volatile__(
26753 " .align 2,0x90\n"
26754 - "0: movl 32(%4), %%eax\n"
26755 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
26756 " cmpl $67, %0\n"
26757 " jbe 2f\n"
26758 - "1: movl 64(%4), %%eax\n"
26759 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
26760 " .align 2,0x90\n"
26761 - "2: movl 0(%4), %%eax\n"
26762 - "21: movl 4(%4), %%edx\n"
26763 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
26764 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
26765 " movnti %%eax, 0(%3)\n"
26766 " movnti %%edx, 4(%3)\n"
26767 - "3: movl 8(%4), %%eax\n"
26768 - "31: movl 12(%4),%%edx\n"
26769 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
26770 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
26771 " movnti %%eax, 8(%3)\n"
26772 " movnti %%edx, 12(%3)\n"
26773 - "4: movl 16(%4), %%eax\n"
26774 - "41: movl 20(%4), %%edx\n"
26775 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
26776 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
26777 " movnti %%eax, 16(%3)\n"
26778 " movnti %%edx, 20(%3)\n"
26779 - "10: movl 24(%4), %%eax\n"
26780 - "51: movl 28(%4), %%edx\n"
26781 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
26782 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
26783 " movnti %%eax, 24(%3)\n"
26784 " movnti %%edx, 28(%3)\n"
26785 - "11: movl 32(%4), %%eax\n"
26786 - "61: movl 36(%4), %%edx\n"
26787 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
26788 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
26789 " movnti %%eax, 32(%3)\n"
26790 " movnti %%edx, 36(%3)\n"
26791 - "12: movl 40(%4), %%eax\n"
26792 - "71: movl 44(%4), %%edx\n"
26793 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
26794 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
26795 " movnti %%eax, 40(%3)\n"
26796 " movnti %%edx, 44(%3)\n"
26797 - "13: movl 48(%4), %%eax\n"
26798 - "81: movl 52(%4), %%edx\n"
26799 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
26800 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
26801 " movnti %%eax, 48(%3)\n"
26802 " movnti %%edx, 52(%3)\n"
26803 - "14: movl 56(%4), %%eax\n"
26804 - "91: movl 60(%4), %%edx\n"
26805 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
26806 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
26807 " movnti %%eax, 56(%3)\n"
26808 " movnti %%edx, 60(%3)\n"
26809 " addl $-64, %0\n"
26810 @@ -352,9 +460,9 @@ static unsigned long __copy_user_zeroing_intel_nocache(void *to,
26811 " shrl $2, %0\n"
26812 " andl $3, %%eax\n"
26813 " cld\n"
26814 - "6: rep; movsl\n"
26815 + "6: rep; "__copyuser_seg" movsl\n"
26816 " movl %%eax,%0\n"
26817 - "7: rep; movsb\n"
26818 + "7: rep; "__copyuser_seg" movsb\n"
26819 "8:\n"
26820 ".section .fixup,\"ax\"\n"
26821 "9: lea 0(%%eax,%0,4),%0\n"
26822 @@ -392,48 +500,48 @@ static unsigned long __copy_user_zeroing_intel_nocache(void *to,
26823 return size;
26824 }
26825
26826 -static unsigned long __copy_user_intel_nocache(void *to,
26827 +static unsigned long __size_overflow(3) __copy_user_intel_nocache(void *to,
26828 const void __user *from, unsigned long size)
26829 {
26830 int d0, d1;
26831
26832 __asm__ __volatile__(
26833 " .align 2,0x90\n"
26834 - "0: movl 32(%4), %%eax\n"
26835 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
26836 " cmpl $67, %0\n"
26837 " jbe 2f\n"
26838 - "1: movl 64(%4), %%eax\n"
26839 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
26840 " .align 2,0x90\n"
26841 - "2: movl 0(%4), %%eax\n"
26842 - "21: movl 4(%4), %%edx\n"
26843 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
26844 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
26845 " movnti %%eax, 0(%3)\n"
26846 " movnti %%edx, 4(%3)\n"
26847 - "3: movl 8(%4), %%eax\n"
26848 - "31: movl 12(%4),%%edx\n"
26849 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
26850 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
26851 " movnti %%eax, 8(%3)\n"
26852 " movnti %%edx, 12(%3)\n"
26853 - "4: movl 16(%4), %%eax\n"
26854 - "41: movl 20(%4), %%edx\n"
26855 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
26856 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
26857 " movnti %%eax, 16(%3)\n"
26858 " movnti %%edx, 20(%3)\n"
26859 - "10: movl 24(%4), %%eax\n"
26860 - "51: movl 28(%4), %%edx\n"
26861 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
26862 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
26863 " movnti %%eax, 24(%3)\n"
26864 " movnti %%edx, 28(%3)\n"
26865 - "11: movl 32(%4), %%eax\n"
26866 - "61: movl 36(%4), %%edx\n"
26867 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
26868 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
26869 " movnti %%eax, 32(%3)\n"
26870 " movnti %%edx, 36(%3)\n"
26871 - "12: movl 40(%4), %%eax\n"
26872 - "71: movl 44(%4), %%edx\n"
26873 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
26874 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
26875 " movnti %%eax, 40(%3)\n"
26876 " movnti %%edx, 44(%3)\n"
26877 - "13: movl 48(%4), %%eax\n"
26878 - "81: movl 52(%4), %%edx\n"
26879 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
26880 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
26881 " movnti %%eax, 48(%3)\n"
26882 " movnti %%edx, 52(%3)\n"
26883 - "14: movl 56(%4), %%eax\n"
26884 - "91: movl 60(%4), %%edx\n"
26885 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
26886 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
26887 " movnti %%eax, 56(%3)\n"
26888 " movnti %%edx, 60(%3)\n"
26889 " addl $-64, %0\n"
26890 @@ -446,9 +554,9 @@ static unsigned long __copy_user_intel_nocache(void *to,
26891 " shrl $2, %0\n"
26892 " andl $3, %%eax\n"
26893 " cld\n"
26894 - "6: rep; movsl\n"
26895 + "6: rep; "__copyuser_seg" movsl\n"
26896 " movl %%eax,%0\n"
26897 - "7: rep; movsb\n"
26898 + "7: rep; "__copyuser_seg" movsb\n"
26899 "8:\n"
26900 ".section .fixup,\"ax\"\n"
26901 "9: lea 0(%%eax,%0,4),%0\n"
26902 @@ -488,32 +596,36 @@ static unsigned long __copy_user_intel_nocache(void *to,
26903 */
26904 unsigned long __copy_user_zeroing_intel(void *to, const void __user *from,
26905 unsigned long size);
26906 -unsigned long __copy_user_intel(void __user *to, const void *from,
26907 +unsigned long __generic_copy_to_user_intel(void __user *to, const void *from,
26908 + unsigned long size);
26909 +unsigned long __generic_copy_from_user_intel(void *to, const void __user *from,
26910 unsigned long size);
26911 unsigned long __copy_user_zeroing_intel_nocache(void *to,
26912 const void __user *from, unsigned long size);
26913 #endif /* CONFIG_X86_INTEL_USERCOPY */
26914
26915 /* Generic arbitrary sized copy. */
26916 -#define __copy_user(to, from, size) \
26917 +#define __copy_user(to, from, size, prefix, set, restore) \
26918 do { \
26919 int __d0, __d1, __d2; \
26920 __asm__ __volatile__( \
26921 + set \
26922 " cmp $7,%0\n" \
26923 " jbe 1f\n" \
26924 " movl %1,%0\n" \
26925 " negl %0\n" \
26926 " andl $7,%0\n" \
26927 " subl %0,%3\n" \
26928 - "4: rep; movsb\n" \
26929 + "4: rep; "prefix"movsb\n" \
26930 " movl %3,%0\n" \
26931 " shrl $2,%0\n" \
26932 " andl $3,%3\n" \
26933 " .align 2,0x90\n" \
26934 - "0: rep; movsl\n" \
26935 + "0: rep; "prefix"movsl\n" \
26936 " movl %3,%0\n" \
26937 - "1: rep; movsb\n" \
26938 + "1: rep; "prefix"movsb\n" \
26939 "2:\n" \
26940 + restore \
26941 ".section .fixup,\"ax\"\n" \
26942 "5: addl %3,%0\n" \
26943 " jmp 2b\n" \
26944 @@ -538,14 +650,14 @@ do { \
26945 " negl %0\n" \
26946 " andl $7,%0\n" \
26947 " subl %0,%3\n" \
26948 - "4: rep; movsb\n" \
26949 + "4: rep; "__copyuser_seg"movsb\n" \
26950 " movl %3,%0\n" \
26951 " shrl $2,%0\n" \
26952 " andl $3,%3\n" \
26953 " .align 2,0x90\n" \
26954 - "0: rep; movsl\n" \
26955 + "0: rep; "__copyuser_seg"movsl\n" \
26956 " movl %3,%0\n" \
26957 - "1: rep; movsb\n" \
26958 + "1: rep; "__copyuser_seg"movsb\n" \
26959 "2:\n" \
26960 ".section .fixup,\"ax\"\n" \
26961 "5: addl %3,%0\n" \
26962 @@ -572,9 +684,9 @@ unsigned long __copy_to_user_ll(void __user *to, const void *from,
26963 {
26964 stac();
26965 if (movsl_is_ok(to, from, n))
26966 - __copy_user(to, from, n);
26967 + __copy_user(to, from, n, "", __COPYUSER_SET_ES, __COPYUSER_RESTORE_ES);
26968 else
26969 - n = __copy_user_intel(to, from, n);
26970 + n = __generic_copy_to_user_intel(to, from, n);
26971 clac();
26972 return n;
26973 }
26974 @@ -598,10 +710,9 @@ unsigned long __copy_from_user_ll_nozero(void *to, const void __user *from,
26975 {
26976 stac();
26977 if (movsl_is_ok(to, from, n))
26978 - __copy_user(to, from, n);
26979 + __copy_user(to, from, n, __copyuser_seg, "", "");
26980 else
26981 - n = __copy_user_intel((void __user *)to,
26982 - (const void *)from, n);
26983 + n = __generic_copy_from_user_intel(to, from, n);
26984 clac();
26985 return n;
26986 }
26987 @@ -632,66 +743,51 @@ unsigned long __copy_from_user_ll_nocache_nozero(void *to, const void __user *fr
26988 if (n > 64 && cpu_has_xmm2)
26989 n = __copy_user_intel_nocache(to, from, n);
26990 else
26991 - __copy_user(to, from, n);
26992 + __copy_user(to, from, n, __copyuser_seg, "", "");
26993 #else
26994 - __copy_user(to, from, n);
26995 + __copy_user(to, from, n, __copyuser_seg, "", "");
26996 #endif
26997 clac();
26998 return n;
26999 }
27000 EXPORT_SYMBOL(__copy_from_user_ll_nocache_nozero);
27001
27002 -/**
27003 - * copy_to_user: - Copy a block of data into user space.
27004 - * @to: Destination address, in user space.
27005 - * @from: Source address, in kernel space.
27006 - * @n: Number of bytes to copy.
27007 - *
27008 - * Context: User context only. This function may sleep.
27009 - *
27010 - * Copy data from kernel space to user space.
27011 - *
27012 - * Returns number of bytes that could not be copied.
27013 - * On success, this will be zero.
27014 - */
27015 -unsigned long
27016 -copy_to_user(void __user *to, const void *from, unsigned long n)
27017 -{
27018 - if (access_ok(VERIFY_WRITE, to, n))
27019 - n = __copy_to_user(to, from, n);
27020 - return n;
27021 -}
27022 -EXPORT_SYMBOL(copy_to_user);
27023 -
27024 -/**
27025 - * copy_from_user: - Copy a block of data from user space.
27026 - * @to: Destination address, in kernel space.
27027 - * @from: Source address, in user space.
27028 - * @n: Number of bytes to copy.
27029 - *
27030 - * Context: User context only. This function may sleep.
27031 - *
27032 - * Copy data from user space to kernel space.
27033 - *
27034 - * Returns number of bytes that could not be copied.
27035 - * On success, this will be zero.
27036 - *
27037 - * If some data could not be copied, this function will pad the copied
27038 - * data to the requested size using zero bytes.
27039 - */
27040 -unsigned long
27041 -_copy_from_user(void *to, const void __user *from, unsigned long n)
27042 -{
27043 - if (access_ok(VERIFY_READ, from, n))
27044 - n = __copy_from_user(to, from, n);
27045 - else
27046 - memset(to, 0, n);
27047 - return n;
27048 -}
27049 -EXPORT_SYMBOL(_copy_from_user);
27050 -
27051 void copy_from_user_overflow(void)
27052 {
27053 WARN(1, "Buffer overflow detected!\n");
27054 }
27055 EXPORT_SYMBOL(copy_from_user_overflow);
27056 +
27057 +void copy_to_user_overflow(void)
27058 +{
27059 + WARN(1, "Buffer overflow detected!\n");
27060 +}
27061 +EXPORT_SYMBOL(copy_to_user_overflow);
27062 +
27063 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27064 +void __set_fs(mm_segment_t x)
27065 +{
27066 + switch (x.seg) {
27067 + case 0:
27068 + loadsegment(gs, 0);
27069 + break;
27070 + case TASK_SIZE_MAX:
27071 + loadsegment(gs, __USER_DS);
27072 + break;
27073 + case -1UL:
27074 + loadsegment(gs, __KERNEL_DS);
27075 + break;
27076 + default:
27077 + BUG();
27078 + }
27079 + return;
27080 +}
27081 +EXPORT_SYMBOL(__set_fs);
27082 +
27083 +void set_fs(mm_segment_t x)
27084 +{
27085 + current_thread_info()->addr_limit = x;
27086 + __set_fs(x);
27087 +}
27088 +EXPORT_SYMBOL(set_fs);
27089 +#endif
27090 diff --git a/arch/x86/lib/usercopy_64.c b/arch/x86/lib/usercopy_64.c
27091 index 906fea3..ee8a097 100644
27092 --- a/arch/x86/lib/usercopy_64.c
27093 +++ b/arch/x86/lib/usercopy_64.c
27094 @@ -39,7 +39,7 @@ unsigned long __clear_user(void __user *addr, unsigned long size)
27095 _ASM_EXTABLE(0b,3b)
27096 _ASM_EXTABLE(1b,2b)
27097 : [size8] "=&c"(size), [dst] "=&D" (__d0)
27098 - : [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(addr),
27099 + : [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(____m(addr)),
27100 [zero] "r" (0UL), [eight] "r" (8UL));
27101 clac();
27102 return size;
27103 @@ -54,12 +54,11 @@ unsigned long clear_user(void __user *to, unsigned long n)
27104 }
27105 EXPORT_SYMBOL(clear_user);
27106
27107 -unsigned long copy_in_user(void __user *to, const void __user *from, unsigned len)
27108 +unsigned long copy_in_user(void __user *to, const void __user *from, unsigned long len)
27109 {
27110 - if (access_ok(VERIFY_WRITE, to, len) && access_ok(VERIFY_READ, from, len)) {
27111 - return copy_user_generic((__force void *)to, (__force void *)from, len);
27112 - }
27113 - return len;
27114 + if (access_ok(VERIFY_WRITE, to, len) && access_ok(VERIFY_READ, from, len))
27115 + return copy_user_generic((void __force_kernel *)____m(to), (void __force_kernel *)____m(from), len);
27116 + return len;
27117 }
27118 EXPORT_SYMBOL(copy_in_user);
27119
27120 @@ -69,7 +68,7 @@ EXPORT_SYMBOL(copy_in_user);
27121 * it is not necessary to optimize tail handling.
27122 */
27123 unsigned long
27124 -copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest)
27125 +copy_user_handle_tail(char __user *to, char __user *from, unsigned long len, unsigned zerorest)
27126 {
27127 char c;
27128 unsigned zero_len;
27129 @@ -87,3 +86,15 @@ copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest)
27130 clac();
27131 return len;
27132 }
27133 +
27134 +void copy_from_user_overflow(void)
27135 +{
27136 + WARN(1, "Buffer overflow detected!\n");
27137 +}
27138 +EXPORT_SYMBOL(copy_from_user_overflow);
27139 +
27140 +void copy_to_user_overflow(void)
27141 +{
27142 + WARN(1, "Buffer overflow detected!\n");
27143 +}
27144 +EXPORT_SYMBOL(copy_to_user_overflow);
27145 diff --git a/arch/x86/mm/extable.c b/arch/x86/mm/extable.c
27146 index 903ec1e..c4166b2 100644
27147 --- a/arch/x86/mm/extable.c
27148 +++ b/arch/x86/mm/extable.c
27149 @@ -6,12 +6,24 @@
27150 static inline unsigned long
27151 ex_insn_addr(const struct exception_table_entry *x)
27152 {
27153 - return (unsigned long)&x->insn + x->insn;
27154 + unsigned long reloc = 0;
27155 +
27156 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
27157 + reloc = ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
27158 +#endif
27159 +
27160 + return (unsigned long)&x->insn + x->insn + reloc;
27161 }
27162 static inline unsigned long
27163 ex_fixup_addr(const struct exception_table_entry *x)
27164 {
27165 - return (unsigned long)&x->fixup + x->fixup;
27166 + unsigned long reloc = 0;
27167 +
27168 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
27169 + reloc = ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
27170 +#endif
27171 +
27172 + return (unsigned long)&x->fixup + x->fixup + reloc;
27173 }
27174
27175 int fixup_exception(struct pt_regs *regs)
27176 @@ -20,7 +32,7 @@ int fixup_exception(struct pt_regs *regs)
27177 unsigned long new_ip;
27178
27179 #ifdef CONFIG_PNPBIOS
27180 - if (unlikely(SEGMENT_IS_PNP_CODE(regs->cs))) {
27181 + if (unlikely(!v8086_mode(regs) && SEGMENT_IS_PNP_CODE(regs->cs))) {
27182 extern u32 pnp_bios_fault_eip, pnp_bios_fault_esp;
27183 extern u32 pnp_bios_is_utter_crap;
27184 pnp_bios_is_utter_crap = 1;
27185 @@ -145,6 +157,13 @@ void sort_extable(struct exception_table_entry *start,
27186 i += 4;
27187 p->fixup -= i;
27188 i += 4;
27189 +
27190 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
27191 + BUILD_BUG_ON(!IS_ENABLED(CONFIG_BUILDTIME_EXTABLE_SORT));
27192 + p->insn -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
27193 + p->fixup -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
27194 +#endif
27195 +
27196 }
27197 }
27198
27199 diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
27200 index 0e88336..2bb9777 100644
27201 --- a/arch/x86/mm/fault.c
27202 +++ b/arch/x86/mm/fault.c
27203 @@ -13,12 +13,19 @@
27204 #include <linux/perf_event.h> /* perf_sw_event */
27205 #include <linux/hugetlb.h> /* hstate_index_to_shift */
27206 #include <linux/prefetch.h> /* prefetchw */
27207 +#include <linux/unistd.h>
27208 +#include <linux/compiler.h>
27209
27210 #include <asm/traps.h> /* dotraplinkage, ... */
27211 #include <asm/pgalloc.h> /* pgd_*(), ... */
27212 #include <asm/kmemcheck.h> /* kmemcheck_*(), ... */
27213 #include <asm/fixmap.h> /* VSYSCALL_START */
27214 #include <asm/context_tracking.h> /* exception_enter(), ... */
27215 +#include <asm/tlbflush.h>
27216 +
27217 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
27218 +#include <asm/stacktrace.h>
27219 +#endif
27220
27221 /*
27222 * Page fault error code bits:
27223 @@ -56,7 +63,7 @@ static inline int __kprobes notify_page_fault(struct pt_regs *regs)
27224 int ret = 0;
27225
27226 /* kprobe_running() needs smp_processor_id() */
27227 - if (kprobes_built_in() && !user_mode_vm(regs)) {
27228 + if (kprobes_built_in() && !user_mode(regs)) {
27229 preempt_disable();
27230 if (kprobe_running() && kprobe_fault_handler(regs, 14))
27231 ret = 1;
27232 @@ -117,7 +124,10 @@ check_prefetch_opcode(struct pt_regs *regs, unsigned char *instr,
27233 return !instr_lo || (instr_lo>>1) == 1;
27234 case 0x00:
27235 /* Prefetch instruction is 0x0F0D or 0x0F18 */
27236 - if (probe_kernel_address(instr, opcode))
27237 + if (user_mode(regs)) {
27238 + if (__copy_from_user_inatomic(&opcode, (unsigned char __force_user *)(instr), 1))
27239 + return 0;
27240 + } else if (probe_kernel_address(instr, opcode))
27241 return 0;
27242
27243 *prefetch = (instr_lo == 0xF) &&
27244 @@ -151,7 +161,10 @@ is_prefetch(struct pt_regs *regs, unsigned long error_code, unsigned long addr)
27245 while (instr < max_instr) {
27246 unsigned char opcode;
27247
27248 - if (probe_kernel_address(instr, opcode))
27249 + if (user_mode(regs)) {
27250 + if (__copy_from_user_inatomic(&opcode, (unsigned char __force_user *)(instr), 1))
27251 + break;
27252 + } else if (probe_kernel_address(instr, opcode))
27253 break;
27254
27255 instr++;
27256 @@ -182,6 +195,34 @@ force_sig_info_fault(int si_signo, int si_code, unsigned long address,
27257 force_sig_info(si_signo, &info, tsk);
27258 }
27259
27260 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
27261 +static bool pax_is_fetch_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address);
27262 +#endif
27263 +
27264 +#ifdef CONFIG_PAX_EMUTRAMP
27265 +static int pax_handle_fetch_fault(struct pt_regs *regs);
27266 +#endif
27267 +
27268 +#ifdef CONFIG_PAX_PAGEEXEC
27269 +static inline pmd_t * pax_get_pmd(struct mm_struct *mm, unsigned long address)
27270 +{
27271 + pgd_t *pgd;
27272 + pud_t *pud;
27273 + pmd_t *pmd;
27274 +
27275 + pgd = pgd_offset(mm, address);
27276 + if (!pgd_present(*pgd))
27277 + return NULL;
27278 + pud = pud_offset(pgd, address);
27279 + if (!pud_present(*pud))
27280 + return NULL;
27281 + pmd = pmd_offset(pud, address);
27282 + if (!pmd_present(*pmd))
27283 + return NULL;
27284 + return pmd;
27285 +}
27286 +#endif
27287 +
27288 DEFINE_SPINLOCK(pgd_lock);
27289 LIST_HEAD(pgd_list);
27290
27291 @@ -232,10 +273,22 @@ void vmalloc_sync_all(void)
27292 for (address = VMALLOC_START & PMD_MASK;
27293 address >= TASK_SIZE && address < FIXADDR_TOP;
27294 address += PMD_SIZE) {
27295 +
27296 +#ifdef CONFIG_PAX_PER_CPU_PGD
27297 + unsigned long cpu;
27298 +#else
27299 struct page *page;
27300 +#endif
27301
27302 spin_lock(&pgd_lock);
27303 +
27304 +#ifdef CONFIG_PAX_PER_CPU_PGD
27305 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
27306 + pgd_t *pgd = get_cpu_pgd(cpu);
27307 + pmd_t *ret;
27308 +#else
27309 list_for_each_entry(page, &pgd_list, lru) {
27310 + pgd_t *pgd;
27311 spinlock_t *pgt_lock;
27312 pmd_t *ret;
27313
27314 @@ -243,8 +296,14 @@ void vmalloc_sync_all(void)
27315 pgt_lock = &pgd_page_get_mm(page)->page_table_lock;
27316
27317 spin_lock(pgt_lock);
27318 - ret = vmalloc_sync_one(page_address(page), address);
27319 + pgd = page_address(page);
27320 +#endif
27321 +
27322 + ret = vmalloc_sync_one(pgd, address);
27323 +
27324 +#ifndef CONFIG_PAX_PER_CPU_PGD
27325 spin_unlock(pgt_lock);
27326 +#endif
27327
27328 if (!ret)
27329 break;
27330 @@ -278,6 +337,11 @@ static noinline __kprobes int vmalloc_fault(unsigned long address)
27331 * an interrupt in the middle of a task switch..
27332 */
27333 pgd_paddr = read_cr3();
27334 +
27335 +#ifdef CONFIG_PAX_PER_CPU_PGD
27336 + BUG_ON(__pa(get_cpu_pgd(smp_processor_id())) != (pgd_paddr & PHYSICAL_PAGE_MASK));
27337 +#endif
27338 +
27339 pmd_k = vmalloc_sync_one(__va(pgd_paddr), address);
27340 if (!pmd_k)
27341 return -1;
27342 @@ -373,7 +437,14 @@ static noinline __kprobes int vmalloc_fault(unsigned long address)
27343 * happen within a race in page table update. In the later
27344 * case just flush:
27345 */
27346 +
27347 +#ifdef CONFIG_PAX_PER_CPU_PGD
27348 + BUG_ON(__pa(get_cpu_pgd(smp_processor_id())) != (read_cr3() & PHYSICAL_PAGE_MASK));
27349 + pgd = pgd_offset_cpu(smp_processor_id(), address);
27350 +#else
27351 pgd = pgd_offset(current->active_mm, address);
27352 +#endif
27353 +
27354 pgd_ref = pgd_offset_k(address);
27355 if (pgd_none(*pgd_ref))
27356 return -1;
27357 @@ -543,7 +614,7 @@ static int is_errata93(struct pt_regs *regs, unsigned long address)
27358 static int is_errata100(struct pt_regs *regs, unsigned long address)
27359 {
27360 #ifdef CONFIG_X86_64
27361 - if ((regs->cs == __USER32_CS || (regs->cs & (1<<2))) && (address >> 32))
27362 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT)) && (address >> 32))
27363 return 1;
27364 #endif
27365 return 0;
27366 @@ -570,7 +641,7 @@ static int is_f00f_bug(struct pt_regs *regs, unsigned long address)
27367 }
27368
27369 static const char nx_warning[] = KERN_CRIT
27370 -"kernel tried to execute NX-protected page - exploit attempt? (uid: %d)\n";
27371 +"kernel tried to execute NX-protected page - exploit attempt? (uid: %d, task: %s, pid: %d)\n";
27372
27373 static void
27374 show_fault_oops(struct pt_regs *regs, unsigned long error_code,
27375 @@ -579,15 +650,27 @@ show_fault_oops(struct pt_regs *regs, unsigned long error_code,
27376 if (!oops_may_print())
27377 return;
27378
27379 - if (error_code & PF_INSTR) {
27380 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR)) {
27381 unsigned int level;
27382
27383 pte_t *pte = lookup_address(address, &level);
27384
27385 if (pte && pte_present(*pte) && !pte_exec(*pte))
27386 - printk(nx_warning, from_kuid(&init_user_ns, current_uid()));
27387 + printk(nx_warning, from_kuid_munged(&init_user_ns, current_uid()), current->comm, task_pid_nr(current));
27388 }
27389
27390 +#ifdef CONFIG_PAX_KERNEXEC
27391 + if (init_mm.start_code <= address && address < init_mm.end_code) {
27392 + if (current->signal->curr_ip)
27393 + printk(KERN_ERR "PAX: From %pI4: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n",
27394 + &current->signal->curr_ip, current->comm, task_pid_nr(current),
27395 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
27396 + else
27397 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n", current->comm, task_pid_nr(current),
27398 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
27399 + }
27400 +#endif
27401 +
27402 printk(KERN_ALERT "BUG: unable to handle kernel ");
27403 if (address < PAGE_SIZE)
27404 printk(KERN_CONT "NULL pointer dereference");
27405 @@ -750,6 +833,22 @@ __bad_area_nosemaphore(struct pt_regs *regs, unsigned long error_code,
27406 return;
27407 }
27408 #endif
27409 +
27410 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
27411 + if (pax_is_fetch_fault(regs, error_code, address)) {
27412 +
27413 +#ifdef CONFIG_PAX_EMUTRAMP
27414 + switch (pax_handle_fetch_fault(regs)) {
27415 + case 2:
27416 + return;
27417 + }
27418 +#endif
27419 +
27420 + pax_report_fault(regs, (void *)regs->ip, (void *)regs->sp);
27421 + do_group_exit(SIGKILL);
27422 + }
27423 +#endif
27424 +
27425 /* Kernel addresses are always protection faults: */
27426 if (address >= TASK_SIZE)
27427 error_code |= PF_PROT;
27428 @@ -835,7 +934,7 @@ do_sigbus(struct pt_regs *regs, unsigned long error_code, unsigned long address,
27429 if (fault & (VM_FAULT_HWPOISON|VM_FAULT_HWPOISON_LARGE)) {
27430 printk(KERN_ERR
27431 "MCE: Killing %s:%d due to hardware memory corruption fault at %lx\n",
27432 - tsk->comm, tsk->pid, address);
27433 + tsk->comm, task_pid_nr(tsk), address);
27434 code = BUS_MCEERR_AR;
27435 }
27436 #endif
27437 @@ -898,6 +997,99 @@ static int spurious_fault_check(unsigned long error_code, pte_t *pte)
27438 return 1;
27439 }
27440
27441 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
27442 +static int pax_handle_pageexec_fault(struct pt_regs *regs, struct mm_struct *mm, unsigned long address, unsigned long error_code)
27443 +{
27444 + pte_t *pte;
27445 + pmd_t *pmd;
27446 + spinlock_t *ptl;
27447 + unsigned char pte_mask;
27448 +
27449 + if ((__supported_pte_mask & _PAGE_NX) || (error_code & (PF_PROT|PF_USER)) != (PF_PROT|PF_USER) || v8086_mode(regs) ||
27450 + !(mm->pax_flags & MF_PAX_PAGEEXEC))
27451 + return 0;
27452 +
27453 + /* PaX: it's our fault, let's handle it if we can */
27454 +
27455 + /* PaX: take a look at read faults before acquiring any locks */
27456 + if (unlikely(!(error_code & PF_WRITE) && (regs->ip == address))) {
27457 + /* instruction fetch attempt from a protected page in user mode */
27458 + up_read(&mm->mmap_sem);
27459 +
27460 +#ifdef CONFIG_PAX_EMUTRAMP
27461 + switch (pax_handle_fetch_fault(regs)) {
27462 + case 2:
27463 + return 1;
27464 + }
27465 +#endif
27466 +
27467 + pax_report_fault(regs, (void *)regs->ip, (void *)regs->sp);
27468 + do_group_exit(SIGKILL);
27469 + }
27470 +
27471 + pmd = pax_get_pmd(mm, address);
27472 + if (unlikely(!pmd))
27473 + return 0;
27474 +
27475 + pte = pte_offset_map_lock(mm, pmd, address, &ptl);
27476 + if (unlikely(!(pte_val(*pte) & _PAGE_PRESENT) || pte_user(*pte))) {
27477 + pte_unmap_unlock(pte, ptl);
27478 + return 0;
27479 + }
27480 +
27481 + if (unlikely((error_code & PF_WRITE) && !pte_write(*pte))) {
27482 + /* write attempt to a protected page in user mode */
27483 + pte_unmap_unlock(pte, ptl);
27484 + return 0;
27485 + }
27486 +
27487 +#ifdef CONFIG_SMP
27488 + if (likely(address > get_limit(regs->cs) && cpu_isset(smp_processor_id(), mm->context.cpu_user_cs_mask)))
27489 +#else
27490 + if (likely(address > get_limit(regs->cs)))
27491 +#endif
27492 + {
27493 + set_pte(pte, pte_mkread(*pte));
27494 + __flush_tlb_one(address);
27495 + pte_unmap_unlock(pte, ptl);
27496 + up_read(&mm->mmap_sem);
27497 + return 1;
27498 + }
27499 +
27500 + pte_mask = _PAGE_ACCESSED | _PAGE_USER | ((error_code & PF_WRITE) << (_PAGE_BIT_DIRTY-1));
27501 +
27502 + /*
27503 + * PaX: fill DTLB with user rights and retry
27504 + */
27505 + __asm__ __volatile__ (
27506 + "orb %2,(%1)\n"
27507 +#if defined(CONFIG_M586) || defined(CONFIG_M586TSC)
27508 +/*
27509 + * PaX: let this uncommented 'invlpg' remind us on the behaviour of Intel's
27510 + * (and AMD's) TLBs. namely, they do not cache PTEs that would raise *any*
27511 + * page fault when examined during a TLB load attempt. this is true not only
27512 + * for PTEs holding a non-present entry but also present entries that will
27513 + * raise a page fault (such as those set up by PaX, or the copy-on-write
27514 + * mechanism). in effect it means that we do *not* need to flush the TLBs
27515 + * for our target pages since their PTEs are simply not in the TLBs at all.
27516 +
27517 + * the best thing in omitting it is that we gain around 15-20% speed in the
27518 + * fast path of the page fault handler and can get rid of tracing since we
27519 + * can no longer flush unintended entries.
27520 + */
27521 + "invlpg (%0)\n"
27522 +#endif
27523 + __copyuser_seg"testb $0,(%0)\n"
27524 + "xorb %3,(%1)\n"
27525 + :
27526 + : "r" (address), "r" (pte), "q" (pte_mask), "i" (_PAGE_USER)
27527 + : "memory", "cc");
27528 + pte_unmap_unlock(pte, ptl);
27529 + up_read(&mm->mmap_sem);
27530 + return 1;
27531 +}
27532 +#endif
27533 +
27534 /*
27535 * Handle a spurious fault caused by a stale TLB entry.
27536 *
27537 @@ -964,6 +1156,9 @@ int show_unhandled_signals = 1;
27538 static inline int
27539 access_error(unsigned long error_code, struct vm_area_struct *vma)
27540 {
27541 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR) && !(vma->vm_flags & VM_EXEC))
27542 + return 1;
27543 +
27544 if (error_code & PF_WRITE) {
27545 /* write, present and write, not present: */
27546 if (unlikely(!(vma->vm_flags & VM_WRITE)))
27547 @@ -992,7 +1187,7 @@ static inline bool smap_violation(int error_code, struct pt_regs *regs)
27548 if (error_code & PF_USER)
27549 return false;
27550
27551 - if (!user_mode_vm(regs) && (regs->flags & X86_EFLAGS_AC))
27552 + if (!user_mode(regs) && (regs->flags & X86_EFLAGS_AC))
27553 return false;
27554
27555 return true;
27556 @@ -1008,18 +1203,33 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code)
27557 {
27558 struct vm_area_struct *vma;
27559 struct task_struct *tsk;
27560 - unsigned long address;
27561 struct mm_struct *mm;
27562 int fault;
27563 int write = error_code & PF_WRITE;
27564 unsigned int flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE |
27565 (write ? FAULT_FLAG_WRITE : 0);
27566
27567 - tsk = current;
27568 - mm = tsk->mm;
27569 -
27570 /* Get the faulting address: */
27571 - address = read_cr2();
27572 + unsigned long address = read_cr2();
27573 +
27574 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
27575 + if (!user_mode(regs) && address < 2 * pax_user_shadow_base) {
27576 + if (!search_exception_tables(regs->ip)) {
27577 + printk(KERN_ERR "PAX: please report this to pageexec@freemail.hu\n");
27578 + bad_area_nosemaphore(regs, error_code, address);
27579 + return;
27580 + }
27581 + if (address < pax_user_shadow_base) {
27582 + printk(KERN_ERR "PAX: please report this to pageexec@freemail.hu\n");
27583 + printk(KERN_ERR "PAX: faulting IP: %pS\n", (void *)regs->ip);
27584 + show_trace_log_lvl(NULL, NULL, (void *)regs->sp, regs->bp, KERN_ERR);
27585 + } else
27586 + address -= pax_user_shadow_base;
27587 + }
27588 +#endif
27589 +
27590 + tsk = current;
27591 + mm = tsk->mm;
27592
27593 /*
27594 * Detect and handle instructions that would cause a page fault for
27595 @@ -1080,7 +1290,7 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code)
27596 * User-mode registers count as a user access even for any
27597 * potential system fault or CPU buglet:
27598 */
27599 - if (user_mode_vm(regs)) {
27600 + if (user_mode(regs)) {
27601 local_irq_enable();
27602 error_code |= PF_USER;
27603 } else {
27604 @@ -1142,6 +1352,11 @@ retry:
27605 might_sleep();
27606 }
27607
27608 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
27609 + if (pax_handle_pageexec_fault(regs, mm, address, error_code))
27610 + return;
27611 +#endif
27612 +
27613 vma = find_vma(mm, address);
27614 if (unlikely(!vma)) {
27615 bad_area(regs, error_code, address);
27616 @@ -1153,18 +1368,24 @@ retry:
27617 bad_area(regs, error_code, address);
27618 return;
27619 }
27620 - if (error_code & PF_USER) {
27621 - /*
27622 - * Accessing the stack below %sp is always a bug.
27623 - * The large cushion allows instructions like enter
27624 - * and pusha to work. ("enter $65535, $31" pushes
27625 - * 32 pointers and then decrements %sp by 65535.)
27626 - */
27627 - if (unlikely(address + 65536 + 32 * sizeof(unsigned long) < regs->sp)) {
27628 - bad_area(regs, error_code, address);
27629 - return;
27630 - }
27631 + /*
27632 + * Accessing the stack below %sp is always a bug.
27633 + * The large cushion allows instructions like enter
27634 + * and pusha to work. ("enter $65535, $31" pushes
27635 + * 32 pointers and then decrements %sp by 65535.)
27636 + */
27637 + if (unlikely(address + 65536 + 32 * sizeof(unsigned long) < task_pt_regs(tsk)->sp)) {
27638 + bad_area(regs, error_code, address);
27639 + return;
27640 }
27641 +
27642 +#ifdef CONFIG_PAX_SEGMEXEC
27643 + if (unlikely((mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_end - SEGMEXEC_TASK_SIZE - 1 < address - SEGMEXEC_TASK_SIZE - 1)) {
27644 + bad_area(regs, error_code, address);
27645 + return;
27646 + }
27647 +#endif
27648 +
27649 if (unlikely(expand_stack(vma, address))) {
27650 bad_area(regs, error_code, address);
27651 return;
27652 @@ -1228,3 +1449,292 @@ do_page_fault(struct pt_regs *regs, unsigned long error_code)
27653 __do_page_fault(regs, error_code);
27654 exception_exit(regs);
27655 }
27656 +
27657 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
27658 +static bool pax_is_fetch_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address)
27659 +{
27660 + struct mm_struct *mm = current->mm;
27661 + unsigned long ip = regs->ip;
27662 +
27663 + if (v8086_mode(regs))
27664 + ip = ((regs->cs & 0xffff) << 4) + (ip & 0xffff);
27665 +
27666 +#ifdef CONFIG_PAX_PAGEEXEC
27667 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
27668 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR))
27669 + return true;
27670 + if (!(error_code & (PF_PROT | PF_WRITE)) && ip == address)
27671 + return true;
27672 + return false;
27673 + }
27674 +#endif
27675 +
27676 +#ifdef CONFIG_PAX_SEGMEXEC
27677 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
27678 + if (!(error_code & (PF_PROT | PF_WRITE)) && (ip + SEGMEXEC_TASK_SIZE == address))
27679 + return true;
27680 + return false;
27681 + }
27682 +#endif
27683 +
27684 + return false;
27685 +}
27686 +#endif
27687 +
27688 +#ifdef CONFIG_PAX_EMUTRAMP
27689 +static int pax_handle_fetch_fault_32(struct pt_regs *regs)
27690 +{
27691 + int err;
27692 +
27693 + do { /* PaX: libffi trampoline emulation */
27694 + unsigned char mov, jmp;
27695 + unsigned int addr1, addr2;
27696 +
27697 +#ifdef CONFIG_X86_64
27698 + if ((regs->ip + 9) >> 32)
27699 + break;
27700 +#endif
27701 +
27702 + err = get_user(mov, (unsigned char __user *)regs->ip);
27703 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
27704 + err |= get_user(jmp, (unsigned char __user *)(regs->ip + 5));
27705 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
27706 +
27707 + if (err)
27708 + break;
27709 +
27710 + if (mov == 0xB8 && jmp == 0xE9) {
27711 + regs->ax = addr1;
27712 + regs->ip = (unsigned int)(regs->ip + addr2 + 10);
27713 + return 2;
27714 + }
27715 + } while (0);
27716 +
27717 + do { /* PaX: gcc trampoline emulation #1 */
27718 + unsigned char mov1, mov2;
27719 + unsigned short jmp;
27720 + unsigned int addr1, addr2;
27721 +
27722 +#ifdef CONFIG_X86_64
27723 + if ((regs->ip + 11) >> 32)
27724 + break;
27725 +#endif
27726 +
27727 + err = get_user(mov1, (unsigned char __user *)regs->ip);
27728 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
27729 + err |= get_user(mov2, (unsigned char __user *)(regs->ip + 5));
27730 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
27731 + err |= get_user(jmp, (unsigned short __user *)(regs->ip + 10));
27732 +
27733 + if (err)
27734 + break;
27735 +
27736 + if (mov1 == 0xB9 && mov2 == 0xB8 && jmp == 0xE0FF) {
27737 + regs->cx = addr1;
27738 + regs->ax = addr2;
27739 + regs->ip = addr2;
27740 + return 2;
27741 + }
27742 + } while (0);
27743 +
27744 + do { /* PaX: gcc trampoline emulation #2 */
27745 + unsigned char mov, jmp;
27746 + unsigned int addr1, addr2;
27747 +
27748 +#ifdef CONFIG_X86_64
27749 + if ((regs->ip + 9) >> 32)
27750 + break;
27751 +#endif
27752 +
27753 + err = get_user(mov, (unsigned char __user *)regs->ip);
27754 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
27755 + err |= get_user(jmp, (unsigned char __user *)(regs->ip + 5));
27756 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
27757 +
27758 + if (err)
27759 + break;
27760 +
27761 + if (mov == 0xB9 && jmp == 0xE9) {
27762 + regs->cx = addr1;
27763 + regs->ip = (unsigned int)(regs->ip + addr2 + 10);
27764 + return 2;
27765 + }
27766 + } while (0);
27767 +
27768 + return 1; /* PaX in action */
27769 +}
27770 +
27771 +#ifdef CONFIG_X86_64
27772 +static int pax_handle_fetch_fault_64(struct pt_regs *regs)
27773 +{
27774 + int err;
27775 +
27776 + do { /* PaX: libffi trampoline emulation */
27777 + unsigned short mov1, mov2, jmp1;
27778 + unsigned char stcclc, jmp2;
27779 + unsigned long addr1, addr2;
27780 +
27781 + err = get_user(mov1, (unsigned short __user *)regs->ip);
27782 + err |= get_user(addr1, (unsigned long __user *)(regs->ip + 2));
27783 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 10));
27784 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 12));
27785 + err |= get_user(stcclc, (unsigned char __user *)(regs->ip + 20));
27786 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 21));
27787 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 23));
27788 +
27789 + if (err)
27790 + break;
27791 +
27792 + if (mov1 == 0xBB49 && mov2 == 0xBA49 && (stcclc == 0xF8 || stcclc == 0xF9) && jmp1 == 0xFF49 && jmp2 == 0xE3) {
27793 + regs->r11 = addr1;
27794 + regs->r10 = addr2;
27795 + if (stcclc == 0xF8)
27796 + regs->flags &= ~X86_EFLAGS_CF;
27797 + else
27798 + regs->flags |= X86_EFLAGS_CF;
27799 + regs->ip = addr1;
27800 + return 2;
27801 + }
27802 + } while (0);
27803 +
27804 + do { /* PaX: gcc trampoline emulation #1 */
27805 + unsigned short mov1, mov2, jmp1;
27806 + unsigned char jmp2;
27807 + unsigned int addr1;
27808 + unsigned long addr2;
27809 +
27810 + err = get_user(mov1, (unsigned short __user *)regs->ip);
27811 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 2));
27812 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 6));
27813 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 8));
27814 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 16));
27815 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 18));
27816 +
27817 + if (err)
27818 + break;
27819 +
27820 + if (mov1 == 0xBB41 && mov2 == 0xBA49 && jmp1 == 0xFF49 && jmp2 == 0xE3) {
27821 + regs->r11 = addr1;
27822 + regs->r10 = addr2;
27823 + regs->ip = addr1;
27824 + return 2;
27825 + }
27826 + } while (0);
27827 +
27828 + do { /* PaX: gcc trampoline emulation #2 */
27829 + unsigned short mov1, mov2, jmp1;
27830 + unsigned char jmp2;
27831 + unsigned long addr1, addr2;
27832 +
27833 + err = get_user(mov1, (unsigned short __user *)regs->ip);
27834 + err |= get_user(addr1, (unsigned long __user *)(regs->ip + 2));
27835 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 10));
27836 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 12));
27837 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 20));
27838 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 22));
27839 +
27840 + if (err)
27841 + break;
27842 +
27843 + if (mov1 == 0xBB49 && mov2 == 0xBA49 && jmp1 == 0xFF49 && jmp2 == 0xE3) {
27844 + regs->r11 = addr1;
27845 + regs->r10 = addr2;
27846 + regs->ip = addr1;
27847 + return 2;
27848 + }
27849 + } while (0);
27850 +
27851 + return 1; /* PaX in action */
27852 +}
27853 +#endif
27854 +
27855 +/*
27856 + * PaX: decide what to do with offenders (regs->ip = fault address)
27857 + *
27858 + * returns 1 when task should be killed
27859 + * 2 when gcc trampoline was detected
27860 + */
27861 +static int pax_handle_fetch_fault(struct pt_regs *regs)
27862 +{
27863 + if (v8086_mode(regs))
27864 + return 1;
27865 +
27866 + if (!(current->mm->pax_flags & MF_PAX_EMUTRAMP))
27867 + return 1;
27868 +
27869 +#ifdef CONFIG_X86_32
27870 + return pax_handle_fetch_fault_32(regs);
27871 +#else
27872 + if (regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT))
27873 + return pax_handle_fetch_fault_32(regs);
27874 + else
27875 + return pax_handle_fetch_fault_64(regs);
27876 +#endif
27877 +}
27878 +#endif
27879 +
27880 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
27881 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
27882 +{
27883 + long i;
27884 +
27885 + printk(KERN_ERR "PAX: bytes at PC: ");
27886 + for (i = 0; i < 20; i++) {
27887 + unsigned char c;
27888 + if (get_user(c, (unsigned char __force_user *)pc+i))
27889 + printk(KERN_CONT "?? ");
27890 + else
27891 + printk(KERN_CONT "%02x ", c);
27892 + }
27893 + printk("\n");
27894 +
27895 + printk(KERN_ERR "PAX: bytes at SP-%lu: ", (unsigned long)sizeof(long));
27896 + for (i = -1; i < 80 / (long)sizeof(long); i++) {
27897 + unsigned long c;
27898 + if (get_user(c, (unsigned long __force_user *)sp+i)) {
27899 +#ifdef CONFIG_X86_32
27900 + printk(KERN_CONT "???????? ");
27901 +#else
27902 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT)))
27903 + printk(KERN_CONT "???????? ???????? ");
27904 + else
27905 + printk(KERN_CONT "???????????????? ");
27906 +#endif
27907 + } else {
27908 +#ifdef CONFIG_X86_64
27909 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT))) {
27910 + printk(KERN_CONT "%08x ", (unsigned int)c);
27911 + printk(KERN_CONT "%08x ", (unsigned int)(c >> 32));
27912 + } else
27913 +#endif
27914 + printk(KERN_CONT "%0*lx ", 2 * (int)sizeof(long), c);
27915 + }
27916 + }
27917 + printk("\n");
27918 +}
27919 +#endif
27920 +
27921 +/**
27922 + * probe_kernel_write(): safely attempt to write to a location
27923 + * @dst: address to write to
27924 + * @src: pointer to the data that shall be written
27925 + * @size: size of the data chunk
27926 + *
27927 + * Safely write to address @dst from the buffer at @src. If a kernel fault
27928 + * happens, handle that and return -EFAULT.
27929 + */
27930 +long notrace probe_kernel_write(void *dst, const void *src, size_t size)
27931 +{
27932 + long ret;
27933 + mm_segment_t old_fs = get_fs();
27934 +
27935 + set_fs(KERNEL_DS);
27936 + pagefault_disable();
27937 + pax_open_kernel();
27938 + ret = __copy_to_user_inatomic((void __force_user *)dst, src, size);
27939 + pax_close_kernel();
27940 + pagefault_enable();
27941 + set_fs(old_fs);
27942 +
27943 + return ret ? -EFAULT : 0;
27944 +}
27945 diff --git a/arch/x86/mm/gup.c b/arch/x86/mm/gup.c
27946 index dd74e46..7d26398 100644
27947 --- a/arch/x86/mm/gup.c
27948 +++ b/arch/x86/mm/gup.c
27949 @@ -255,7 +255,7 @@ int __get_user_pages_fast(unsigned long start, int nr_pages, int write,
27950 addr = start;
27951 len = (unsigned long) nr_pages << PAGE_SHIFT;
27952 end = start + len;
27953 - if (unlikely(!access_ok(write ? VERIFY_WRITE : VERIFY_READ,
27954 + if (unlikely(!__access_ok(write ? VERIFY_WRITE : VERIFY_READ,
27955 (void __user *)start, len)))
27956 return 0;
27957
27958 diff --git a/arch/x86/mm/highmem_32.c b/arch/x86/mm/highmem_32.c
27959 index 6f31ee5..8ee4164 100644
27960 --- a/arch/x86/mm/highmem_32.c
27961 +++ b/arch/x86/mm/highmem_32.c
27962 @@ -44,7 +44,11 @@ void *kmap_atomic_prot(struct page *page, pgprot_t prot)
27963 idx = type + KM_TYPE_NR*smp_processor_id();
27964 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
27965 BUG_ON(!pte_none(*(kmap_pte-idx)));
27966 +
27967 + pax_open_kernel();
27968 set_pte(kmap_pte-idx, mk_pte(page, prot));
27969 + pax_close_kernel();
27970 +
27971 arch_flush_lazy_mmu_mode();
27972
27973 return (void *)vaddr;
27974 diff --git a/arch/x86/mm/hugetlbpage.c b/arch/x86/mm/hugetlbpage.c
27975 index ae1aa71..d9bea75 100644
27976 --- a/arch/x86/mm/hugetlbpage.c
27977 +++ b/arch/x86/mm/hugetlbpage.c
27978 @@ -271,23 +271,30 @@ follow_huge_pud(struct mm_struct *mm, unsigned long address,
27979 #ifdef HAVE_ARCH_HUGETLB_UNMAPPED_AREA
27980 static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *file,
27981 unsigned long addr, unsigned long len,
27982 - unsigned long pgoff, unsigned long flags)
27983 + unsigned long pgoff, unsigned long flags, unsigned long offset)
27984 {
27985 struct hstate *h = hstate_file(file);
27986 struct vm_unmapped_area_info info;
27987 -
27988 +
27989 info.flags = 0;
27990 info.length = len;
27991 info.low_limit = TASK_UNMAPPED_BASE;
27992 +
27993 +#ifdef CONFIG_PAX_RANDMMAP
27994 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
27995 + info.low_limit += current->mm->delta_mmap;
27996 +#endif
27997 +
27998 info.high_limit = TASK_SIZE;
27999 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
28000 info.align_offset = 0;
28001 + info.threadstack_offset = offset;
28002 return vm_unmapped_area(&info);
28003 }
28004
28005 static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
28006 unsigned long addr0, unsigned long len,
28007 - unsigned long pgoff, unsigned long flags)
28008 + unsigned long pgoff, unsigned long flags, unsigned long offset)
28009 {
28010 struct hstate *h = hstate_file(file);
28011 struct vm_unmapped_area_info info;
28012 @@ -299,6 +306,7 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
28013 info.high_limit = current->mm->mmap_base;
28014 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
28015 info.align_offset = 0;
28016 + info.threadstack_offset = offset;
28017 addr = vm_unmapped_area(&info);
28018
28019 /*
28020 @@ -311,6 +319,12 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
28021 VM_BUG_ON(addr != -ENOMEM);
28022 info.flags = 0;
28023 info.low_limit = TASK_UNMAPPED_BASE;
28024 +
28025 +#ifdef CONFIG_PAX_RANDMMAP
28026 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
28027 + info.low_limit += current->mm->delta_mmap;
28028 +#endif
28029 +
28030 info.high_limit = TASK_SIZE;
28031 addr = vm_unmapped_area(&info);
28032 }
28033 @@ -325,10 +339,20 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
28034 struct hstate *h = hstate_file(file);
28035 struct mm_struct *mm = current->mm;
28036 struct vm_area_struct *vma;
28037 + unsigned long pax_task_size = TASK_SIZE;
28038 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
28039
28040 if (len & ~huge_page_mask(h))
28041 return -EINVAL;
28042 - if (len > TASK_SIZE)
28043 +
28044 +#ifdef CONFIG_PAX_SEGMEXEC
28045 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
28046 + pax_task_size = SEGMEXEC_TASK_SIZE;
28047 +#endif
28048 +
28049 + pax_task_size -= PAGE_SIZE;
28050 +
28051 + if (len > pax_task_size)
28052 return -ENOMEM;
28053
28054 if (flags & MAP_FIXED) {
28055 @@ -337,19 +361,22 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
28056 return addr;
28057 }
28058
28059 +#ifdef CONFIG_PAX_RANDMMAP
28060 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
28061 +#endif
28062 +
28063 if (addr) {
28064 addr = ALIGN(addr, huge_page_size(h));
28065 vma = find_vma(mm, addr);
28066 - if (TASK_SIZE - len >= addr &&
28067 - (!vma || addr + len <= vma->vm_start))
28068 + if (pax_task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
28069 return addr;
28070 }
28071 if (mm->get_unmapped_area == arch_get_unmapped_area)
28072 return hugetlb_get_unmapped_area_bottomup(file, addr, len,
28073 - pgoff, flags);
28074 + pgoff, flags, offset);
28075 else
28076 return hugetlb_get_unmapped_area_topdown(file, addr, len,
28077 - pgoff, flags);
28078 + pgoff, flags, offset);
28079 }
28080
28081 #endif /*HAVE_ARCH_HUGETLB_UNMAPPED_AREA*/
28082 diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
28083 index 59b7fc4..b1dd75f 100644
28084 --- a/arch/x86/mm/init.c
28085 +++ b/arch/x86/mm/init.c
28086 @@ -4,6 +4,7 @@
28087 #include <linux/swap.h>
28088 #include <linux/memblock.h>
28089 #include <linux/bootmem.h> /* for max_low_pfn */
28090 +#include <linux/tboot.h>
28091
28092 #include <asm/cacheflush.h>
28093 #include <asm/e820.h>
28094 @@ -17,6 +18,8 @@
28095 #include <asm/proto.h>
28096 #include <asm/dma.h> /* for MAX_DMA_PFN */
28097 #include <asm/microcode.h>
28098 +#include <asm/desc.h>
28099 +#include <asm/bios_ebda.h>
28100
28101 #include "mm_internal.h"
28102
28103 @@ -464,10 +467,40 @@ void __init init_mem_mapping(void)
28104 * Access has to be given to non-kernel-ram areas as well, these contain the PCI
28105 * mmio resources as well as potential bios/acpi data regions.
28106 */
28107 +
28108 +#ifdef CONFIG_GRKERNSEC_KMEM
28109 +static unsigned int ebda_start __read_only;
28110 +static unsigned int ebda_end __read_only;
28111 +#endif
28112 +
28113 int devmem_is_allowed(unsigned long pagenr)
28114 {
28115 - if (pagenr < 256)
28116 +#ifdef CONFIG_GRKERNSEC_KMEM
28117 + /* allow BDA */
28118 + if (!pagenr)
28119 return 1;
28120 + /* allow EBDA */
28121 + if (pagenr >= ebda_start && pagenr < ebda_end)
28122 + return 1;
28123 + /* if tboot is in use, allow access to its hardcoded serial log range */
28124 + if (tboot_enabled() && ((0x60000 >> PAGE_SHIFT) <= pagenr) && (pagenr < (0x68000 >> PAGE_SHIFT)))
28125 + return 1;
28126 +#else
28127 + if (!pagenr)
28128 + return 1;
28129 +#ifdef CONFIG_VM86
28130 + if (pagenr < (ISA_START_ADDRESS >> PAGE_SHIFT))
28131 + return 1;
28132 +#endif
28133 +#endif
28134 +
28135 + if ((ISA_START_ADDRESS >> PAGE_SHIFT) <= pagenr && pagenr < (ISA_END_ADDRESS >> PAGE_SHIFT))
28136 + return 1;
28137 +#ifdef CONFIG_GRKERNSEC_KMEM
28138 + /* throw out everything else below 1MB */
28139 + if (pagenr <= 256)
28140 + return 0;
28141 +#endif
28142 if (iomem_is_exclusive(pagenr << PAGE_SHIFT))
28143 return 0;
28144 if (!page_is_ram(pagenr))
28145 @@ -524,8 +557,117 @@ void free_init_pages(char *what, unsigned long begin, unsigned long end)
28146 #endif
28147 }
28148
28149 +#ifdef CONFIG_GRKERNSEC_KMEM
28150 +static inline void gr_init_ebda(void)
28151 +{
28152 + unsigned int ebda_addr;
28153 + unsigned int ebda_size = 0;
28154 +
28155 + ebda_addr = get_bios_ebda();
28156 + if (ebda_addr) {
28157 + ebda_size = *(unsigned char *)phys_to_virt(ebda_addr);
28158 + ebda_size <<= 10;
28159 + }
28160 + if (ebda_addr && ebda_size) {
28161 + ebda_start = ebda_addr >> PAGE_SHIFT;
28162 + ebda_end = min((unsigned int)PAGE_ALIGN(ebda_addr + ebda_size), (unsigned int)0xa0000) >> PAGE_SHIFT;
28163 + } else {
28164 + ebda_start = 0x9f000 >> PAGE_SHIFT;
28165 + ebda_end = 0xa0000 >> PAGE_SHIFT;
28166 + }
28167 +}
28168 +#else
28169 +static inline void gr_init_ebda(void) { }
28170 +#endif
28171 +
28172 void free_initmem(void)
28173 {
28174 +#ifdef CONFIG_PAX_KERNEXEC
28175 +#ifdef CONFIG_X86_32
28176 + /* PaX: limit KERNEL_CS to actual size */
28177 + unsigned long addr, limit;
28178 + struct desc_struct d;
28179 + int cpu;
28180 +#else
28181 + pgd_t *pgd;
28182 + pud_t *pud;
28183 + pmd_t *pmd;
28184 + unsigned long addr, end;
28185 +#endif
28186 +#endif
28187 +
28188 + gr_init_ebda();
28189 +
28190 +#ifdef CONFIG_PAX_KERNEXEC
28191 +#ifdef CONFIG_X86_32
28192 + limit = paravirt_enabled() ? ktva_ktla(0xffffffff) : (unsigned long)&_etext;
28193 + limit = (limit - 1UL) >> PAGE_SHIFT;
28194 +
28195 + memset(__LOAD_PHYSICAL_ADDR + PAGE_OFFSET, POISON_FREE_INITMEM, PAGE_SIZE);
28196 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
28197 + pack_descriptor(&d, get_desc_base(&get_cpu_gdt_table(cpu)[GDT_ENTRY_KERNEL_CS]), limit, 0x9B, 0xC);
28198 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_KERNEL_CS, &d, DESCTYPE_S);
28199 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_KERNEXEC_KERNEL_CS, &d, DESCTYPE_S);
28200 + }
28201 +
28202 + /* PaX: make KERNEL_CS read-only */
28203 + addr = PFN_ALIGN(ktla_ktva((unsigned long)&_text));
28204 + if (!paravirt_enabled())
28205 + set_memory_ro(addr, (PFN_ALIGN(_sdata) - addr) >> PAGE_SHIFT);
28206 +/*
28207 + for (addr = ktla_ktva((unsigned long)&_text); addr < (unsigned long)&_sdata; addr += PMD_SIZE) {
28208 + pgd = pgd_offset_k(addr);
28209 + pud = pud_offset(pgd, addr);
28210 + pmd = pmd_offset(pud, addr);
28211 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
28212 + }
28213 +*/
28214 +#ifdef CONFIG_X86_PAE
28215 + set_memory_nx(PFN_ALIGN(__init_begin), (PFN_ALIGN(__init_end) - PFN_ALIGN(__init_begin)) >> PAGE_SHIFT);
28216 +/*
28217 + for (addr = (unsigned long)&__init_begin; addr < (unsigned long)&__init_end; addr += PMD_SIZE) {
28218 + pgd = pgd_offset_k(addr);
28219 + pud = pud_offset(pgd, addr);
28220 + pmd = pmd_offset(pud, addr);
28221 + set_pmd(pmd, __pmd(pmd_val(*pmd) | (_PAGE_NX & __supported_pte_mask)));
28222 + }
28223 +*/
28224 +#endif
28225 +
28226 +#ifdef CONFIG_MODULES
28227 + set_memory_4k((unsigned long)MODULES_EXEC_VADDR, (MODULES_EXEC_END - MODULES_EXEC_VADDR) >> PAGE_SHIFT);
28228 +#endif
28229 +
28230 +#else
28231 + /* PaX: make kernel code/rodata read-only, rest non-executable */
28232 + for (addr = __START_KERNEL_map; addr < __START_KERNEL_map + KERNEL_IMAGE_SIZE; addr += PMD_SIZE) {
28233 + pgd = pgd_offset_k(addr);
28234 + pud = pud_offset(pgd, addr);
28235 + pmd = pmd_offset(pud, addr);
28236 + if (!pmd_present(*pmd))
28237 + continue;
28238 + if ((unsigned long)_text <= addr && addr < (unsigned long)_sdata)
28239 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
28240 + else
28241 + set_pmd(pmd, __pmd(pmd_val(*pmd) | (_PAGE_NX & __supported_pte_mask)));
28242 + }
28243 +
28244 + addr = (unsigned long)__va(__pa(__START_KERNEL_map));
28245 + end = addr + KERNEL_IMAGE_SIZE;
28246 + for (; addr < end; addr += PMD_SIZE) {
28247 + pgd = pgd_offset_k(addr);
28248 + pud = pud_offset(pgd, addr);
28249 + pmd = pmd_offset(pud, addr);
28250 + if (!pmd_present(*pmd))
28251 + continue;
28252 + if ((unsigned long)__va(__pa(_text)) <= addr && addr < (unsigned long)__va(__pa(_sdata)))
28253 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
28254 + }
28255 +#endif
28256 +
28257 + flush_tlb_all();
28258 +#endif
28259 +
28260 free_init_pages("unused kernel memory",
28261 (unsigned long)(&__init_begin),
28262 (unsigned long)(&__init_end));
28263 diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c
28264 index 2d19001..6a1046c 100644
28265 --- a/arch/x86/mm/init_32.c
28266 +++ b/arch/x86/mm/init_32.c
28267 @@ -62,33 +62,6 @@ static noinline int do_test_wp_bit(void);
28268 bool __read_mostly __vmalloc_start_set = false;
28269
28270 /*
28271 - * Creates a middle page table and puts a pointer to it in the
28272 - * given global directory entry. This only returns the gd entry
28273 - * in non-PAE compilation mode, since the middle layer is folded.
28274 - */
28275 -static pmd_t * __init one_md_table_init(pgd_t *pgd)
28276 -{
28277 - pud_t *pud;
28278 - pmd_t *pmd_table;
28279 -
28280 -#ifdef CONFIG_X86_PAE
28281 - if (!(pgd_val(*pgd) & _PAGE_PRESENT)) {
28282 - pmd_table = (pmd_t *)alloc_low_page();
28283 - paravirt_alloc_pmd(&init_mm, __pa(pmd_table) >> PAGE_SHIFT);
28284 - set_pgd(pgd, __pgd(__pa(pmd_table) | _PAGE_PRESENT));
28285 - pud = pud_offset(pgd, 0);
28286 - BUG_ON(pmd_table != pmd_offset(pud, 0));
28287 -
28288 - return pmd_table;
28289 - }
28290 -#endif
28291 - pud = pud_offset(pgd, 0);
28292 - pmd_table = pmd_offset(pud, 0);
28293 -
28294 - return pmd_table;
28295 -}
28296 -
28297 -/*
28298 * Create a page table and place a pointer to it in a middle page
28299 * directory entry:
28300 */
28301 @@ -98,13 +71,28 @@ static pte_t * __init one_page_table_init(pmd_t *pmd)
28302 pte_t *page_table = (pte_t *)alloc_low_page();
28303
28304 paravirt_alloc_pte(&init_mm, __pa(page_table) >> PAGE_SHIFT);
28305 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
28306 + set_pmd(pmd, __pmd(__pa(page_table) | _KERNPG_TABLE));
28307 +#else
28308 set_pmd(pmd, __pmd(__pa(page_table) | _PAGE_TABLE));
28309 +#endif
28310 BUG_ON(page_table != pte_offset_kernel(pmd, 0));
28311 }
28312
28313 return pte_offset_kernel(pmd, 0);
28314 }
28315
28316 +static pmd_t * __init one_md_table_init(pgd_t *pgd)
28317 +{
28318 + pud_t *pud;
28319 + pmd_t *pmd_table;
28320 +
28321 + pud = pud_offset(pgd, 0);
28322 + pmd_table = pmd_offset(pud, 0);
28323 +
28324 + return pmd_table;
28325 +}
28326 +
28327 pmd_t * __init populate_extra_pmd(unsigned long vaddr)
28328 {
28329 int pgd_idx = pgd_index(vaddr);
28330 @@ -208,6 +196,7 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
28331 int pgd_idx, pmd_idx;
28332 unsigned long vaddr;
28333 pgd_t *pgd;
28334 + pud_t *pud;
28335 pmd_t *pmd;
28336 pte_t *pte = NULL;
28337 unsigned long count = page_table_range_init_count(start, end);
28338 @@ -222,8 +211,13 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
28339 pgd = pgd_base + pgd_idx;
28340
28341 for ( ; (pgd_idx < PTRS_PER_PGD) && (vaddr != end); pgd++, pgd_idx++) {
28342 - pmd = one_md_table_init(pgd);
28343 - pmd = pmd + pmd_index(vaddr);
28344 + pud = pud_offset(pgd, vaddr);
28345 + pmd = pmd_offset(pud, vaddr);
28346 +
28347 +#ifdef CONFIG_X86_PAE
28348 + paravirt_alloc_pmd(&init_mm, __pa(pmd) >> PAGE_SHIFT);
28349 +#endif
28350 +
28351 for (; (pmd_idx < PTRS_PER_PMD) && (vaddr != end);
28352 pmd++, pmd_idx++) {
28353 pte = page_table_kmap_check(one_page_table_init(pmd),
28354 @@ -235,11 +229,20 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
28355 }
28356 }
28357
28358 -static inline int is_kernel_text(unsigned long addr)
28359 +static inline int is_kernel_text(unsigned long start, unsigned long end)
28360 {
28361 - if (addr >= (unsigned long)_text && addr <= (unsigned long)__init_end)
28362 - return 1;
28363 - return 0;
28364 + if ((start > ktla_ktva((unsigned long)_etext) ||
28365 + end <= ktla_ktva((unsigned long)_stext)) &&
28366 + (start > ktla_ktva((unsigned long)_einittext) ||
28367 + end <= ktla_ktva((unsigned long)_sinittext)) &&
28368 +
28369 +#ifdef CONFIG_ACPI_SLEEP
28370 + (start > (unsigned long)__va(acpi_wakeup_address) + 0x4000 || end <= (unsigned long)__va(acpi_wakeup_address)) &&
28371 +#endif
28372 +
28373 + (start > (unsigned long)__va(0xfffff) || end <= (unsigned long)__va(0xc0000)))
28374 + return 0;
28375 + return 1;
28376 }
28377
28378 /*
28379 @@ -256,9 +259,10 @@ kernel_physical_mapping_init(unsigned long start,
28380 unsigned long last_map_addr = end;
28381 unsigned long start_pfn, end_pfn;
28382 pgd_t *pgd_base = swapper_pg_dir;
28383 - int pgd_idx, pmd_idx, pte_ofs;
28384 + unsigned int pgd_idx, pmd_idx, pte_ofs;
28385 unsigned long pfn;
28386 pgd_t *pgd;
28387 + pud_t *pud;
28388 pmd_t *pmd;
28389 pte_t *pte;
28390 unsigned pages_2m, pages_4k;
28391 @@ -291,8 +295,13 @@ repeat:
28392 pfn = start_pfn;
28393 pgd_idx = pgd_index((pfn<<PAGE_SHIFT) + PAGE_OFFSET);
28394 pgd = pgd_base + pgd_idx;
28395 - for (; pgd_idx < PTRS_PER_PGD; pgd++, pgd_idx++) {
28396 - pmd = one_md_table_init(pgd);
28397 + for (; pgd_idx < PTRS_PER_PGD && pfn < max_low_pfn; pgd++, pgd_idx++) {
28398 + pud = pud_offset(pgd, 0);
28399 + pmd = pmd_offset(pud, 0);
28400 +
28401 +#ifdef CONFIG_X86_PAE
28402 + paravirt_alloc_pmd(&init_mm, __pa(pmd) >> PAGE_SHIFT);
28403 +#endif
28404
28405 if (pfn >= end_pfn)
28406 continue;
28407 @@ -304,14 +313,13 @@ repeat:
28408 #endif
28409 for (; pmd_idx < PTRS_PER_PMD && pfn < end_pfn;
28410 pmd++, pmd_idx++) {
28411 - unsigned int addr = pfn * PAGE_SIZE + PAGE_OFFSET;
28412 + unsigned long address = pfn * PAGE_SIZE + PAGE_OFFSET;
28413
28414 /*
28415 * Map with big pages if possible, otherwise
28416 * create normal page tables:
28417 */
28418 if (use_pse) {
28419 - unsigned int addr2;
28420 pgprot_t prot = PAGE_KERNEL_LARGE;
28421 /*
28422 * first pass will use the same initial
28423 @@ -322,11 +330,7 @@ repeat:
28424 _PAGE_PSE);
28425
28426 pfn &= PMD_MASK >> PAGE_SHIFT;
28427 - addr2 = (pfn + PTRS_PER_PTE-1) * PAGE_SIZE +
28428 - PAGE_OFFSET + PAGE_SIZE-1;
28429 -
28430 - if (is_kernel_text(addr) ||
28431 - is_kernel_text(addr2))
28432 + if (is_kernel_text(address, address + PMD_SIZE))
28433 prot = PAGE_KERNEL_LARGE_EXEC;
28434
28435 pages_2m++;
28436 @@ -343,7 +347,7 @@ repeat:
28437 pte_ofs = pte_index((pfn<<PAGE_SHIFT) + PAGE_OFFSET);
28438 pte += pte_ofs;
28439 for (; pte_ofs < PTRS_PER_PTE && pfn < end_pfn;
28440 - pte++, pfn++, pte_ofs++, addr += PAGE_SIZE) {
28441 + pte++, pfn++, pte_ofs++, address += PAGE_SIZE) {
28442 pgprot_t prot = PAGE_KERNEL;
28443 /*
28444 * first pass will use the same initial
28445 @@ -351,7 +355,7 @@ repeat:
28446 */
28447 pgprot_t init_prot = __pgprot(PTE_IDENT_ATTR);
28448
28449 - if (is_kernel_text(addr))
28450 + if (is_kernel_text(address, address + PAGE_SIZE))
28451 prot = PAGE_KERNEL_EXEC;
28452
28453 pages_4k++;
28454 @@ -482,7 +486,7 @@ void __init native_pagetable_init(void)
28455
28456 pud = pud_offset(pgd, va);
28457 pmd = pmd_offset(pud, va);
28458 - if (!pmd_present(*pmd))
28459 + if (!pmd_present(*pmd)) // PAX TODO || pmd_large(*pmd))
28460 break;
28461
28462 /* should not be large page here */
28463 @@ -540,12 +544,10 @@ void __init early_ioremap_page_table_range_init(void)
28464
28465 static void __init pagetable_init(void)
28466 {
28467 - pgd_t *pgd_base = swapper_pg_dir;
28468 -
28469 - permanent_kmaps_init(pgd_base);
28470 + permanent_kmaps_init(swapper_pg_dir);
28471 }
28472
28473 -pteval_t __supported_pte_mask __read_mostly = ~(_PAGE_NX | _PAGE_GLOBAL | _PAGE_IOMAP);
28474 +pteval_t __supported_pte_mask __read_only = ~(_PAGE_NX | _PAGE_GLOBAL | _PAGE_IOMAP);
28475 EXPORT_SYMBOL_GPL(__supported_pte_mask);
28476
28477 /* user-defined highmem size */
28478 @@ -752,6 +754,12 @@ void __init mem_init(void)
28479
28480 pci_iommu_alloc();
28481
28482 +#ifdef CONFIG_PAX_PER_CPU_PGD
28483 + clone_pgd_range(get_cpu_pgd(0) + KERNEL_PGD_BOUNDARY,
28484 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
28485 + KERNEL_PGD_PTRS);
28486 +#endif
28487 +
28488 #ifdef CONFIG_FLATMEM
28489 BUG_ON(!mem_map);
28490 #endif
28491 @@ -780,7 +788,7 @@ void __init mem_init(void)
28492 after_bootmem = 1;
28493
28494 codesize = (unsigned long) &_etext - (unsigned long) &_text;
28495 - datasize = (unsigned long) &_edata - (unsigned long) &_etext;
28496 + datasize = (unsigned long) &_edata - (unsigned long) &_sdata;
28497 initsize = (unsigned long) &__init_end - (unsigned long) &__init_begin;
28498
28499 printk(KERN_INFO "Memory: %luk/%luk available (%dk kernel code, "
28500 @@ -821,10 +829,10 @@ void __init mem_init(void)
28501 ((unsigned long)&__init_end -
28502 (unsigned long)&__init_begin) >> 10,
28503
28504 - (unsigned long)&_etext, (unsigned long)&_edata,
28505 - ((unsigned long)&_edata - (unsigned long)&_etext) >> 10,
28506 + (unsigned long)&_sdata, (unsigned long)&_edata,
28507 + ((unsigned long)&_edata - (unsigned long)&_sdata) >> 10,
28508
28509 - (unsigned long)&_text, (unsigned long)&_etext,
28510 + ktla_ktva((unsigned long)&_text), ktla_ktva((unsigned long)&_etext),
28511 ((unsigned long)&_etext - (unsigned long)&_text) >> 10);
28512
28513 /*
28514 @@ -914,6 +922,7 @@ void set_kernel_text_rw(void)
28515 if (!kernel_set_to_readonly)
28516 return;
28517
28518 + start = ktla_ktva(start);
28519 pr_debug("Set kernel text: %lx - %lx for read write\n",
28520 start, start+size);
28521
28522 @@ -928,6 +937,7 @@ void set_kernel_text_ro(void)
28523 if (!kernel_set_to_readonly)
28524 return;
28525
28526 + start = ktla_ktva(start);
28527 pr_debug("Set kernel text: %lx - %lx for read only\n",
28528 start, start+size);
28529
28530 @@ -956,6 +966,7 @@ void mark_rodata_ro(void)
28531 unsigned long start = PFN_ALIGN(_text);
28532 unsigned long size = PFN_ALIGN(_etext) - start;
28533
28534 + start = ktla_ktva(start);
28535 set_pages_ro(virt_to_page(start), size >> PAGE_SHIFT);
28536 printk(KERN_INFO "Write protecting the kernel text: %luk\n",
28537 size >> 10);
28538 diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
28539 index 474e28f..647dd12 100644
28540 --- a/arch/x86/mm/init_64.c
28541 +++ b/arch/x86/mm/init_64.c
28542 @@ -150,7 +150,7 @@ early_param("gbpages", parse_direct_gbpages_on);
28543 * around without checking the pgd every time.
28544 */
28545
28546 -pteval_t __supported_pte_mask __read_mostly = ~_PAGE_IOMAP;
28547 +pteval_t __supported_pte_mask __read_only = ~(_PAGE_NX | _PAGE_IOMAP);
28548 EXPORT_SYMBOL_GPL(__supported_pte_mask);
28549
28550 int force_personality32;
28551 @@ -183,12 +183,22 @@ void sync_global_pgds(unsigned long start, unsigned long end)
28552
28553 for (address = start; address <= end; address += PGDIR_SIZE) {
28554 const pgd_t *pgd_ref = pgd_offset_k(address);
28555 +
28556 +#ifdef CONFIG_PAX_PER_CPU_PGD
28557 + unsigned long cpu;
28558 +#else
28559 struct page *page;
28560 +#endif
28561
28562 if (pgd_none(*pgd_ref))
28563 continue;
28564
28565 spin_lock(&pgd_lock);
28566 +
28567 +#ifdef CONFIG_PAX_PER_CPU_PGD
28568 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
28569 + pgd_t *pgd = pgd_offset_cpu(cpu, address);
28570 +#else
28571 list_for_each_entry(page, &pgd_list, lru) {
28572 pgd_t *pgd;
28573 spinlock_t *pgt_lock;
28574 @@ -197,6 +207,7 @@ void sync_global_pgds(unsigned long start, unsigned long end)
28575 /* the pgt_lock only for Xen */
28576 pgt_lock = &pgd_page_get_mm(page)->page_table_lock;
28577 spin_lock(pgt_lock);
28578 +#endif
28579
28580 if (pgd_none(*pgd))
28581 set_pgd(pgd, *pgd_ref);
28582 @@ -204,7 +215,10 @@ void sync_global_pgds(unsigned long start, unsigned long end)
28583 BUG_ON(pgd_page_vaddr(*pgd)
28584 != pgd_page_vaddr(*pgd_ref));
28585
28586 +#ifndef CONFIG_PAX_PER_CPU_PGD
28587 spin_unlock(pgt_lock);
28588 +#endif
28589 +
28590 }
28591 spin_unlock(&pgd_lock);
28592 }
28593 @@ -237,7 +251,7 @@ static pud_t *fill_pud(pgd_t *pgd, unsigned long vaddr)
28594 {
28595 if (pgd_none(*pgd)) {
28596 pud_t *pud = (pud_t *)spp_getpage();
28597 - pgd_populate(&init_mm, pgd, pud);
28598 + pgd_populate_kernel(&init_mm, pgd, pud);
28599 if (pud != pud_offset(pgd, 0))
28600 printk(KERN_ERR "PAGETABLE BUG #00! %p <-> %p\n",
28601 pud, pud_offset(pgd, 0));
28602 @@ -249,7 +263,7 @@ static pmd_t *fill_pmd(pud_t *pud, unsigned long vaddr)
28603 {
28604 if (pud_none(*pud)) {
28605 pmd_t *pmd = (pmd_t *) spp_getpage();
28606 - pud_populate(&init_mm, pud, pmd);
28607 + pud_populate_kernel(&init_mm, pud, pmd);
28608 if (pmd != pmd_offset(pud, 0))
28609 printk(KERN_ERR "PAGETABLE BUG #01! %p <-> %p\n",
28610 pmd, pmd_offset(pud, 0));
28611 @@ -278,7 +292,9 @@ void set_pte_vaddr_pud(pud_t *pud_page, unsigned long vaddr, pte_t new_pte)
28612 pmd = fill_pmd(pud, vaddr);
28613 pte = fill_pte(pmd, vaddr);
28614
28615 + pax_open_kernel();
28616 set_pte(pte, new_pte);
28617 + pax_close_kernel();
28618
28619 /*
28620 * It's enough to flush this one mapping.
28621 @@ -337,14 +353,12 @@ static void __init __init_extra_mapping(unsigned long phys, unsigned long size,
28622 pgd = pgd_offset_k((unsigned long)__va(phys));
28623 if (pgd_none(*pgd)) {
28624 pud = (pud_t *) spp_getpage();
28625 - set_pgd(pgd, __pgd(__pa(pud) | _KERNPG_TABLE |
28626 - _PAGE_USER));
28627 + set_pgd(pgd, __pgd(__pa(pud) | _PAGE_TABLE));
28628 }
28629 pud = pud_offset(pgd, (unsigned long)__va(phys));
28630 if (pud_none(*pud)) {
28631 pmd = (pmd_t *) spp_getpage();
28632 - set_pud(pud, __pud(__pa(pmd) | _KERNPG_TABLE |
28633 - _PAGE_USER));
28634 + set_pud(pud, __pud(__pa(pmd) | _PAGE_TABLE));
28635 }
28636 pmd = pmd_offset(pud, phys);
28637 BUG_ON(!pmd_none(*pmd));
28638 @@ -585,7 +599,7 @@ phys_pud_init(pud_t *pud_page, unsigned long addr, unsigned long end,
28639 prot);
28640
28641 spin_lock(&init_mm.page_table_lock);
28642 - pud_populate(&init_mm, pud, pmd);
28643 + pud_populate_kernel(&init_mm, pud, pmd);
28644 spin_unlock(&init_mm.page_table_lock);
28645 }
28646 __flush_tlb_all();
28647 @@ -626,7 +640,7 @@ kernel_physical_mapping_init(unsigned long start,
28648 page_size_mask);
28649
28650 spin_lock(&init_mm.page_table_lock);
28651 - pgd_populate(&init_mm, pgd, pud);
28652 + pgd_populate_kernel(&init_mm, pgd, pud);
28653 spin_unlock(&init_mm.page_table_lock);
28654 pgd_changed = true;
28655 }
28656 @@ -1065,6 +1079,12 @@ void __init mem_init(void)
28657
28658 pci_iommu_alloc();
28659
28660 +#ifdef CONFIG_PAX_PER_CPU_PGD
28661 + clone_pgd_range(get_cpu_pgd(0) + KERNEL_PGD_BOUNDARY,
28662 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
28663 + KERNEL_PGD_PTRS);
28664 +#endif
28665 +
28666 /* clear_bss() already clear the empty_zero_page */
28667
28668 reservedpages = 0;
28669 @@ -1224,8 +1244,8 @@ int kern_addr_valid(unsigned long addr)
28670 static struct vm_area_struct gate_vma = {
28671 .vm_start = VSYSCALL_START,
28672 .vm_end = VSYSCALL_START + (VSYSCALL_MAPPED_PAGES * PAGE_SIZE),
28673 - .vm_page_prot = PAGE_READONLY_EXEC,
28674 - .vm_flags = VM_READ | VM_EXEC
28675 + .vm_page_prot = PAGE_READONLY,
28676 + .vm_flags = VM_READ
28677 };
28678
28679 struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
28680 @@ -1259,7 +1279,7 @@ int in_gate_area_no_mm(unsigned long addr)
28681
28682 const char *arch_vma_name(struct vm_area_struct *vma)
28683 {
28684 - if (vma->vm_mm && vma->vm_start == (long)vma->vm_mm->context.vdso)
28685 + if (vma->vm_mm && vma->vm_start == vma->vm_mm->context.vdso)
28686 return "[vdso]";
28687 if (vma == &gate_vma)
28688 return "[vsyscall]";
28689 diff --git a/arch/x86/mm/iomap_32.c b/arch/x86/mm/iomap_32.c
28690 index 7b179b4..6bd17777 100644
28691 --- a/arch/x86/mm/iomap_32.c
28692 +++ b/arch/x86/mm/iomap_32.c
28693 @@ -64,7 +64,11 @@ void *kmap_atomic_prot_pfn(unsigned long pfn, pgprot_t prot)
28694 type = kmap_atomic_idx_push();
28695 idx = type + KM_TYPE_NR * smp_processor_id();
28696 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
28697 +
28698 + pax_open_kernel();
28699 set_pte(kmap_pte - idx, pfn_pte(pfn, prot));
28700 + pax_close_kernel();
28701 +
28702 arch_flush_lazy_mmu_mode();
28703
28704 return (void *)vaddr;
28705 diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c
28706 index 78fe3f1..73b95e2 100644
28707 --- a/arch/x86/mm/ioremap.c
28708 +++ b/arch/x86/mm/ioremap.c
28709 @@ -97,7 +97,7 @@ static void __iomem *__ioremap_caller(resource_size_t phys_addr,
28710 for (pfn = phys_addr >> PAGE_SHIFT; pfn <= last_pfn; pfn++) {
28711 int is_ram = page_is_ram(pfn);
28712
28713 - if (is_ram && pfn_valid(pfn) && !PageReserved(pfn_to_page(pfn)))
28714 + if (is_ram && pfn_valid(pfn) && (pfn >= 0x100 || !PageReserved(pfn_to_page(pfn))))
28715 return NULL;
28716 WARN_ON_ONCE(is_ram);
28717 }
28718 @@ -256,7 +256,7 @@ EXPORT_SYMBOL(ioremap_prot);
28719 *
28720 * Caller must ensure there is only one unmapping for the same pointer.
28721 */
28722 -void iounmap(volatile void __iomem *addr)
28723 +void iounmap(const volatile void __iomem *addr)
28724 {
28725 struct vm_struct *p, *o;
28726
28727 @@ -315,6 +315,9 @@ void *xlate_dev_mem_ptr(unsigned long phys)
28728
28729 /* If page is RAM, we can use __va. Otherwise ioremap and unmap. */
28730 if (page_is_ram(start >> PAGE_SHIFT))
28731 +#ifdef CONFIG_HIGHMEM
28732 + if ((start >> PAGE_SHIFT) < max_low_pfn)
28733 +#endif
28734 return __va(phys);
28735
28736 addr = (void __force *)ioremap_cache(start, PAGE_SIZE);
28737 @@ -327,6 +330,9 @@ void *xlate_dev_mem_ptr(unsigned long phys)
28738 void unxlate_dev_mem_ptr(unsigned long phys, void *addr)
28739 {
28740 if (page_is_ram(phys >> PAGE_SHIFT))
28741 +#ifdef CONFIG_HIGHMEM
28742 + if ((phys >> PAGE_SHIFT) < max_low_pfn)
28743 +#endif
28744 return;
28745
28746 iounmap((void __iomem *)((unsigned long)addr & PAGE_MASK));
28747 @@ -344,7 +350,7 @@ static int __init early_ioremap_debug_setup(char *str)
28748 early_param("early_ioremap_debug", early_ioremap_debug_setup);
28749
28750 static __initdata int after_paging_init;
28751 -static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __page_aligned_bss;
28752 +static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __read_only __aligned(PAGE_SIZE);
28753
28754 static inline pmd_t * __init early_ioremap_pmd(unsigned long addr)
28755 {
28756 @@ -381,8 +387,7 @@ void __init early_ioremap_init(void)
28757 slot_virt[i] = __fix_to_virt(FIX_BTMAP_BEGIN - NR_FIX_BTMAPS*i);
28758
28759 pmd = early_ioremap_pmd(fix_to_virt(FIX_BTMAP_BEGIN));
28760 - memset(bm_pte, 0, sizeof(bm_pte));
28761 - pmd_populate_kernel(&init_mm, pmd, bm_pte);
28762 + pmd_populate_user(&init_mm, pmd, bm_pte);
28763
28764 /*
28765 * The boot-ioremap range spans multiple pmds, for which
28766 diff --git a/arch/x86/mm/kmemcheck/kmemcheck.c b/arch/x86/mm/kmemcheck/kmemcheck.c
28767 index d87dd6d..bf3fa66 100644
28768 --- a/arch/x86/mm/kmemcheck/kmemcheck.c
28769 +++ b/arch/x86/mm/kmemcheck/kmemcheck.c
28770 @@ -622,9 +622,9 @@ bool kmemcheck_fault(struct pt_regs *regs, unsigned long address,
28771 * memory (e.g. tracked pages)? For now, we need this to avoid
28772 * invoking kmemcheck for PnP BIOS calls.
28773 */
28774 - if (regs->flags & X86_VM_MASK)
28775 + if (v8086_mode(regs))
28776 return false;
28777 - if (regs->cs != __KERNEL_CS)
28778 + if (regs->cs != __KERNEL_CS && regs->cs != __KERNEXEC_KERNEL_CS)
28779 return false;
28780
28781 pte = kmemcheck_pte_lookup(address);
28782 diff --git a/arch/x86/mm/mmap.c b/arch/x86/mm/mmap.c
28783 index 845df68..1d8d29f 100644
28784 --- a/arch/x86/mm/mmap.c
28785 +++ b/arch/x86/mm/mmap.c
28786 @@ -52,7 +52,7 @@ static unsigned int stack_maxrandom_size(void)
28787 * Leave an at least ~128 MB hole with possible stack randomization.
28788 */
28789 #define MIN_GAP (128*1024*1024UL + stack_maxrandom_size())
28790 -#define MAX_GAP (TASK_SIZE/6*5)
28791 +#define MAX_GAP (pax_task_size/6*5)
28792
28793 static int mmap_is_legacy(void)
28794 {
28795 @@ -82,27 +82,40 @@ static unsigned long mmap_rnd(void)
28796 return rnd << PAGE_SHIFT;
28797 }
28798
28799 -static unsigned long mmap_base(void)
28800 +static unsigned long mmap_base(struct mm_struct *mm)
28801 {
28802 unsigned long gap = rlimit(RLIMIT_STACK);
28803 + unsigned long pax_task_size = TASK_SIZE;
28804 +
28805 +#ifdef CONFIG_PAX_SEGMEXEC
28806 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
28807 + pax_task_size = SEGMEXEC_TASK_SIZE;
28808 +#endif
28809
28810 if (gap < MIN_GAP)
28811 gap = MIN_GAP;
28812 else if (gap > MAX_GAP)
28813 gap = MAX_GAP;
28814
28815 - return PAGE_ALIGN(TASK_SIZE - gap - mmap_rnd());
28816 + return PAGE_ALIGN(pax_task_size - gap - mmap_rnd());
28817 }
28818
28819 /*
28820 * Bottom-up (legacy) layout on X86_32 did not support randomization, X86_64
28821 * does, but not when emulating X86_32
28822 */
28823 -static unsigned long mmap_legacy_base(void)
28824 +static unsigned long mmap_legacy_base(struct mm_struct *mm)
28825 {
28826 - if (mmap_is_ia32())
28827 + if (mmap_is_ia32()) {
28828 +
28829 +#ifdef CONFIG_PAX_SEGMEXEC
28830 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
28831 + return SEGMEXEC_TASK_UNMAPPED_BASE;
28832 + else
28833 +#endif
28834 +
28835 return TASK_UNMAPPED_BASE;
28836 - else
28837 + } else
28838 return TASK_UNMAPPED_BASE + mmap_rnd();
28839 }
28840
28841 @@ -113,11 +126,23 @@ static unsigned long mmap_legacy_base(void)
28842 void arch_pick_mmap_layout(struct mm_struct *mm)
28843 {
28844 if (mmap_is_legacy()) {
28845 - mm->mmap_base = mmap_legacy_base();
28846 + mm->mmap_base = mmap_legacy_base(mm);
28847 +
28848 +#ifdef CONFIG_PAX_RANDMMAP
28849 + if (mm->pax_flags & MF_PAX_RANDMMAP)
28850 + mm->mmap_base += mm->delta_mmap;
28851 +#endif
28852 +
28853 mm->get_unmapped_area = arch_get_unmapped_area;
28854 mm->unmap_area = arch_unmap_area;
28855 } else {
28856 - mm->mmap_base = mmap_base();
28857 + mm->mmap_base = mmap_base(mm);
28858 +
28859 +#ifdef CONFIG_PAX_RANDMMAP
28860 + if (mm->pax_flags & MF_PAX_RANDMMAP)
28861 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
28862 +#endif
28863 +
28864 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
28865 mm->unmap_area = arch_unmap_area_topdown;
28866 }
28867 diff --git a/arch/x86/mm/mmio-mod.c b/arch/x86/mm/mmio-mod.c
28868 index dc0b727..f612039 100644
28869 --- a/arch/x86/mm/mmio-mod.c
28870 +++ b/arch/x86/mm/mmio-mod.c
28871 @@ -194,7 +194,7 @@ static void pre(struct kmmio_probe *p, struct pt_regs *regs,
28872 break;
28873 default:
28874 {
28875 - unsigned char *ip = (unsigned char *)instptr;
28876 + unsigned char *ip = (unsigned char *)ktla_ktva(instptr);
28877 my_trace->opcode = MMIO_UNKNOWN_OP;
28878 my_trace->width = 0;
28879 my_trace->value = (*ip) << 16 | *(ip + 1) << 8 |
28880 @@ -234,7 +234,7 @@ static void post(struct kmmio_probe *p, unsigned long condition,
28881 static void ioremap_trace_core(resource_size_t offset, unsigned long size,
28882 void __iomem *addr)
28883 {
28884 - static atomic_t next_id;
28885 + static atomic_unchecked_t next_id;
28886 struct remap_trace *trace = kmalloc(sizeof(*trace), GFP_KERNEL);
28887 /* These are page-unaligned. */
28888 struct mmiotrace_map map = {
28889 @@ -258,7 +258,7 @@ static void ioremap_trace_core(resource_size_t offset, unsigned long size,
28890 .private = trace
28891 },
28892 .phys = offset,
28893 - .id = atomic_inc_return(&next_id)
28894 + .id = atomic_inc_return_unchecked(&next_id)
28895 };
28896 map.map_id = trace->id;
28897
28898 @@ -290,7 +290,7 @@ void mmiotrace_ioremap(resource_size_t offset, unsigned long size,
28899 ioremap_trace_core(offset, size, addr);
28900 }
28901
28902 -static void iounmap_trace_core(volatile void __iomem *addr)
28903 +static void iounmap_trace_core(const volatile void __iomem *addr)
28904 {
28905 struct mmiotrace_map map = {
28906 .phys = 0,
28907 @@ -328,7 +328,7 @@ not_enabled:
28908 }
28909 }
28910
28911 -void mmiotrace_iounmap(volatile void __iomem *addr)
28912 +void mmiotrace_iounmap(const volatile void __iomem *addr)
28913 {
28914 might_sleep();
28915 if (is_enabled()) /* recheck and proper locking in *_core() */
28916 diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c
28917 index 72fe01e..f1a8daa 100644
28918 --- a/arch/x86/mm/numa.c
28919 +++ b/arch/x86/mm/numa.c
28920 @@ -477,7 +477,7 @@ static bool __init numa_meminfo_cover_memory(const struct numa_meminfo *mi)
28921 return true;
28922 }
28923
28924 -static int __init numa_register_memblks(struct numa_meminfo *mi)
28925 +static int __init __intentional_overflow(-1) numa_register_memblks(struct numa_meminfo *mi)
28926 {
28927 unsigned long uninitialized_var(pfn_align);
28928 int i, nid;
28929 diff --git a/arch/x86/mm/pageattr-test.c b/arch/x86/mm/pageattr-test.c
28930 index 0e38951..4ca8458 100644
28931 --- a/arch/x86/mm/pageattr-test.c
28932 +++ b/arch/x86/mm/pageattr-test.c
28933 @@ -36,7 +36,7 @@ enum {
28934
28935 static int pte_testbit(pte_t pte)
28936 {
28937 - return pte_flags(pte) & _PAGE_UNUSED1;
28938 + return pte_flags(pte) & _PAGE_CPA_TEST;
28939 }
28940
28941 struct split_state {
28942 diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c
28943 index fb4e73e..43f7238 100644
28944 --- a/arch/x86/mm/pageattr.c
28945 +++ b/arch/x86/mm/pageattr.c
28946 @@ -261,7 +261,7 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
28947 */
28948 #ifdef CONFIG_PCI_BIOS
28949 if (pcibios_enabled && within(pfn, BIOS_BEGIN >> PAGE_SHIFT, BIOS_END >> PAGE_SHIFT))
28950 - pgprot_val(forbidden) |= _PAGE_NX;
28951 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
28952 #endif
28953
28954 /*
28955 @@ -269,9 +269,10 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
28956 * Does not cover __inittext since that is gone later on. On
28957 * 64bit we do not enforce !NX on the low mapping
28958 */
28959 - if (within(address, (unsigned long)_text, (unsigned long)_etext))
28960 - pgprot_val(forbidden) |= _PAGE_NX;
28961 + if (within(address, ktla_ktva((unsigned long)_text), ktla_ktva((unsigned long)_etext)))
28962 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
28963
28964 +#ifdef CONFIG_DEBUG_RODATA
28965 /*
28966 * The .rodata section needs to be read-only. Using the pfn
28967 * catches all aliases.
28968 @@ -279,6 +280,7 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
28969 if (within(pfn, __pa_symbol(__start_rodata) >> PAGE_SHIFT,
28970 __pa_symbol(__end_rodata) >> PAGE_SHIFT))
28971 pgprot_val(forbidden) |= _PAGE_RW;
28972 +#endif
28973
28974 #if defined(CONFIG_X86_64) && defined(CONFIG_DEBUG_RODATA)
28975 /*
28976 @@ -317,6 +319,13 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
28977 }
28978 #endif
28979
28980 +#ifdef CONFIG_PAX_KERNEXEC
28981 + if (within(pfn, __pa(ktla_ktva((unsigned long)&_text)), __pa((unsigned long)&_sdata))) {
28982 + pgprot_val(forbidden) |= _PAGE_RW;
28983 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
28984 + }
28985 +#endif
28986 +
28987 prot = __pgprot(pgprot_val(prot) & ~pgprot_val(forbidden));
28988
28989 return prot;
28990 @@ -400,23 +409,37 @@ EXPORT_SYMBOL_GPL(slow_virt_to_phys);
28991 static void __set_pmd_pte(pte_t *kpte, unsigned long address, pte_t pte)
28992 {
28993 /* change init_mm */
28994 + pax_open_kernel();
28995 set_pte_atomic(kpte, pte);
28996 +
28997 #ifdef CONFIG_X86_32
28998 if (!SHARED_KERNEL_PMD) {
28999 +
29000 +#ifdef CONFIG_PAX_PER_CPU_PGD
29001 + unsigned long cpu;
29002 +#else
29003 struct page *page;
29004 +#endif
29005
29006 +#ifdef CONFIG_PAX_PER_CPU_PGD
29007 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
29008 + pgd_t *pgd = get_cpu_pgd(cpu);
29009 +#else
29010 list_for_each_entry(page, &pgd_list, lru) {
29011 - pgd_t *pgd;
29012 + pgd_t *pgd = (pgd_t *)page_address(page);
29013 +#endif
29014 +
29015 pud_t *pud;
29016 pmd_t *pmd;
29017
29018 - pgd = (pgd_t *)page_address(page) + pgd_index(address);
29019 + pgd += pgd_index(address);
29020 pud = pud_offset(pgd, address);
29021 pmd = pmd_offset(pud, address);
29022 set_pte_atomic((pte_t *)pmd, pte);
29023 }
29024 }
29025 #endif
29026 + pax_close_kernel();
29027 }
29028
29029 static int
29030 diff --git a/arch/x86/mm/pat.c b/arch/x86/mm/pat.c
29031 index 6574388..87e9bef 100644
29032 --- a/arch/x86/mm/pat.c
29033 +++ b/arch/x86/mm/pat.c
29034 @@ -376,7 +376,7 @@ int free_memtype(u64 start, u64 end)
29035
29036 if (!entry) {
29037 printk(KERN_INFO "%s:%d freeing invalid memtype [mem %#010Lx-%#010Lx]\n",
29038 - current->comm, current->pid, start, end - 1);
29039 + current->comm, task_pid_nr(current), start, end - 1);
29040 return -EINVAL;
29041 }
29042
29043 @@ -506,8 +506,8 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
29044
29045 while (cursor < to) {
29046 if (!devmem_is_allowed(pfn)) {
29047 - printk(KERN_INFO "Program %s tried to access /dev/mem between [mem %#010Lx-%#010Lx]\n",
29048 - current->comm, from, to - 1);
29049 + printk(KERN_INFO "Program %s tried to access /dev/mem between [mem %#010Lx-%#010Lx] (%#010Lx)\n",
29050 + current->comm, from, to - 1, cursor);
29051 return 0;
29052 }
29053 cursor += PAGE_SIZE;
29054 @@ -577,7 +577,7 @@ int kernel_map_sync_memtype(u64 base, unsigned long size, unsigned long flags)
29055 if (ioremap_change_attr((unsigned long)__va(base), id_sz, flags) < 0) {
29056 printk(KERN_INFO "%s:%d ioremap_change_attr failed %s "
29057 "for [mem %#010Lx-%#010Lx]\n",
29058 - current->comm, current->pid,
29059 + current->comm, task_pid_nr(current),
29060 cattr_name(flags),
29061 base, (unsigned long long)(base + size-1));
29062 return -EINVAL;
29063 @@ -612,7 +612,7 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot,
29064 flags = lookup_memtype(paddr);
29065 if (want_flags != flags) {
29066 printk(KERN_WARNING "%s:%d map pfn RAM range req %s for [mem %#010Lx-%#010Lx], got %s\n",
29067 - current->comm, current->pid,
29068 + current->comm, task_pid_nr(current),
29069 cattr_name(want_flags),
29070 (unsigned long long)paddr,
29071 (unsigned long long)(paddr + size - 1),
29072 @@ -634,7 +634,7 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot,
29073 free_memtype(paddr, paddr + size);
29074 printk(KERN_ERR "%s:%d map pfn expected mapping type %s"
29075 " for [mem %#010Lx-%#010Lx], got %s\n",
29076 - current->comm, current->pid,
29077 + current->comm, task_pid_nr(current),
29078 cattr_name(want_flags),
29079 (unsigned long long)paddr,
29080 (unsigned long long)(paddr + size - 1),
29081 diff --git a/arch/x86/mm/pf_in.c b/arch/x86/mm/pf_in.c
29082 index 9f0614d..92ae64a 100644
29083 --- a/arch/x86/mm/pf_in.c
29084 +++ b/arch/x86/mm/pf_in.c
29085 @@ -148,7 +148,7 @@ enum reason_type get_ins_type(unsigned long ins_addr)
29086 int i;
29087 enum reason_type rv = OTHERS;
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
29094 @@ -168,7 +168,7 @@ static unsigned int get_ins_reg_width(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
29103 @@ -191,7 +191,7 @@ unsigned int get_ins_mem_width(unsigned long ins_addr)
29104 struct prefix_bits prf;
29105 int i;
29106
29107 - p = (unsigned char *)ins_addr;
29108 + p = (unsigned char *)ktla_ktva(ins_addr);
29109 p += skip_prefix(p, &prf);
29110 p += get_opcode(p, &opcode);
29111
29112 @@ -415,7 +415,7 @@ unsigned long get_ins_reg_val(unsigned long ins_addr, struct pt_regs *regs)
29113 struct prefix_bits prf;
29114 int i;
29115
29116 - p = (unsigned char *)ins_addr;
29117 + p = (unsigned char *)ktla_ktva(ins_addr);
29118 p += skip_prefix(p, &prf);
29119 p += get_opcode(p, &opcode);
29120 for (i = 0; i < ARRAY_SIZE(reg_rop); i++)
29121 @@ -470,7 +470,7 @@ unsigned long get_ins_imm_val(unsigned long ins_addr)
29122 struct prefix_bits prf;
29123 int i;
29124
29125 - p = (unsigned char *)ins_addr;
29126 + p = (unsigned char *)ktla_ktva(ins_addr);
29127 p += skip_prefix(p, &prf);
29128 p += get_opcode(p, &opcode);
29129 for (i = 0; i < ARRAY_SIZE(imm_wop); i++)
29130 diff --git a/arch/x86/mm/pgtable.c b/arch/x86/mm/pgtable.c
29131 index 17fda6a..489c74a 100644
29132 --- a/arch/x86/mm/pgtable.c
29133 +++ b/arch/x86/mm/pgtable.c
29134 @@ -91,10 +91,64 @@ static inline void pgd_list_del(pgd_t *pgd)
29135 list_del(&page->lru);
29136 }
29137
29138 -#define UNSHARED_PTRS_PER_PGD \
29139 - (SHARED_KERNEL_PMD ? KERNEL_PGD_BOUNDARY : PTRS_PER_PGD)
29140 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
29141 +pgdval_t clone_pgd_mask __read_only = ~_PAGE_PRESENT;
29142
29143 +void __shadow_user_pgds(pgd_t *dst, const pgd_t *src)
29144 +{
29145 + unsigned int count = USER_PGD_PTRS;
29146
29147 + while (count--)
29148 + *dst++ = __pgd((pgd_val(*src++) | (_PAGE_NX & __supported_pte_mask)) & ~_PAGE_USER);
29149 +}
29150 +#endif
29151 +
29152 +#ifdef CONFIG_PAX_PER_CPU_PGD
29153 +void __clone_user_pgds(pgd_t *dst, const pgd_t *src)
29154 +{
29155 + unsigned int count = USER_PGD_PTRS;
29156 +
29157 + while (count--) {
29158 + pgd_t pgd;
29159 +
29160 +#ifdef CONFIG_X86_64
29161 + pgd = __pgd(pgd_val(*src++) | _PAGE_USER);
29162 +#else
29163 + pgd = *src++;
29164 +#endif
29165 +
29166 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
29167 + pgd = __pgd(pgd_val(pgd) & clone_pgd_mask);
29168 +#endif
29169 +
29170 + *dst++ = pgd;
29171 + }
29172 +
29173 +}
29174 +#endif
29175 +
29176 +#ifdef CONFIG_X86_64
29177 +#define pxd_t pud_t
29178 +#define pyd_t pgd_t
29179 +#define paravirt_release_pxd(pfn) paravirt_release_pud(pfn)
29180 +#define pxd_free(mm, pud) pud_free((mm), (pud))
29181 +#define pyd_populate(mm, pgd, pud) pgd_populate((mm), (pgd), (pud))
29182 +#define pyd_offset(mm, address) pgd_offset((mm), (address))
29183 +#define PYD_SIZE PGDIR_SIZE
29184 +#else
29185 +#define pxd_t pmd_t
29186 +#define pyd_t pud_t
29187 +#define paravirt_release_pxd(pfn) paravirt_release_pmd(pfn)
29188 +#define pxd_free(mm, pud) pmd_free((mm), (pud))
29189 +#define pyd_populate(mm, pgd, pud) pud_populate((mm), (pgd), (pud))
29190 +#define pyd_offset(mm, address) pud_offset((mm), (address))
29191 +#define PYD_SIZE PUD_SIZE
29192 +#endif
29193 +
29194 +#ifdef CONFIG_PAX_PER_CPU_PGD
29195 +static inline void pgd_ctor(struct mm_struct *mm, pgd_t *pgd) {}
29196 +static inline void pgd_dtor(pgd_t *pgd) {}
29197 +#else
29198 static void pgd_set_mm(pgd_t *pgd, struct mm_struct *mm)
29199 {
29200 BUILD_BUG_ON(sizeof(virt_to_page(pgd)->index) < sizeof(mm));
29201 @@ -135,6 +189,7 @@ static void pgd_dtor(pgd_t *pgd)
29202 pgd_list_del(pgd);
29203 spin_unlock(&pgd_lock);
29204 }
29205 +#endif
29206
29207 /*
29208 * List of all pgd's needed for non-PAE so it can invalidate entries
29209 @@ -147,7 +202,7 @@ static void pgd_dtor(pgd_t *pgd)
29210 * -- nyc
29211 */
29212
29213 -#ifdef CONFIG_X86_PAE
29214 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
29215 /*
29216 * In PAE mode, we need to do a cr3 reload (=tlb flush) when
29217 * updating the top-level pagetable entries to guarantee the
29218 @@ -159,7 +214,7 @@ static void pgd_dtor(pgd_t *pgd)
29219 * not shared between pagetables (!SHARED_KERNEL_PMDS), we allocate
29220 * and initialize the kernel pmds here.
29221 */
29222 -#define PREALLOCATED_PMDS UNSHARED_PTRS_PER_PGD
29223 +#define PREALLOCATED_PXDS (SHARED_KERNEL_PMD ? KERNEL_PGD_BOUNDARY : PTRS_PER_PGD)
29224
29225 void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
29226 {
29227 @@ -177,36 +232,38 @@ void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
29228 */
29229 flush_tlb_mm(mm);
29230 }
29231 +#elif defined(CONFIG_X86_64) && defined(CONFIG_PAX_PER_CPU_PGD)
29232 +#define PREALLOCATED_PXDS USER_PGD_PTRS
29233 #else /* !CONFIG_X86_PAE */
29234
29235 /* No need to prepopulate any pagetable entries in non-PAE modes. */
29236 -#define PREALLOCATED_PMDS 0
29237 +#define PREALLOCATED_PXDS 0
29238
29239 #endif /* CONFIG_X86_PAE */
29240
29241 -static void free_pmds(pmd_t *pmds[])
29242 +static void free_pxds(pxd_t *pxds[])
29243 {
29244 int i;
29245
29246 - for(i = 0; i < PREALLOCATED_PMDS; i++)
29247 - if (pmds[i])
29248 - free_page((unsigned long)pmds[i]);
29249 + for(i = 0; i < PREALLOCATED_PXDS; i++)
29250 + if (pxds[i])
29251 + free_page((unsigned long)pxds[i]);
29252 }
29253
29254 -static int preallocate_pmds(pmd_t *pmds[])
29255 +static int preallocate_pxds(pxd_t *pxds[])
29256 {
29257 int i;
29258 bool failed = false;
29259
29260 - for(i = 0; i < PREALLOCATED_PMDS; i++) {
29261 - pmd_t *pmd = (pmd_t *)__get_free_page(PGALLOC_GFP);
29262 - if (pmd == NULL)
29263 + for(i = 0; i < PREALLOCATED_PXDS; i++) {
29264 + pxd_t *pxd = (pxd_t *)__get_free_page(PGALLOC_GFP);
29265 + if (pxd == NULL)
29266 failed = true;
29267 - pmds[i] = pmd;
29268 + pxds[i] = pxd;
29269 }
29270
29271 if (failed) {
29272 - free_pmds(pmds);
29273 + free_pxds(pxds);
29274 return -ENOMEM;
29275 }
29276
29277 @@ -219,51 +276,55 @@ static int preallocate_pmds(pmd_t *pmds[])
29278 * preallocate which never got a corresponding vma will need to be
29279 * freed manually.
29280 */
29281 -static void pgd_mop_up_pmds(struct mm_struct *mm, pgd_t *pgdp)
29282 +static void pgd_mop_up_pxds(struct mm_struct *mm, pgd_t *pgdp)
29283 {
29284 int i;
29285
29286 - for(i = 0; i < PREALLOCATED_PMDS; i++) {
29287 + for(i = 0; i < PREALLOCATED_PXDS; i++) {
29288 pgd_t pgd = pgdp[i];
29289
29290 if (pgd_val(pgd) != 0) {
29291 - pmd_t *pmd = (pmd_t *)pgd_page_vaddr(pgd);
29292 + pxd_t *pxd = (pxd_t *)pgd_page_vaddr(pgd);
29293
29294 - pgdp[i] = native_make_pgd(0);
29295 + set_pgd(pgdp + i, native_make_pgd(0));
29296
29297 - paravirt_release_pmd(pgd_val(pgd) >> PAGE_SHIFT);
29298 - pmd_free(mm, pmd);
29299 + paravirt_release_pxd(pgd_val(pgd) >> PAGE_SHIFT);
29300 + pxd_free(mm, pxd);
29301 }
29302 }
29303 }
29304
29305 -static void pgd_prepopulate_pmd(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmds[])
29306 +static void pgd_prepopulate_pxd(struct mm_struct *mm, pgd_t *pgd, pxd_t *pxds[])
29307 {
29308 - pud_t *pud;
29309 + pyd_t *pyd;
29310 unsigned long addr;
29311 int i;
29312
29313 - if (PREALLOCATED_PMDS == 0) /* Work around gcc-3.4.x bug */
29314 + if (PREALLOCATED_PXDS == 0) /* Work around gcc-3.4.x bug */
29315 return;
29316
29317 - pud = pud_offset(pgd, 0);
29318 +#ifdef CONFIG_X86_64
29319 + pyd = pyd_offset(mm, 0L);
29320 +#else
29321 + pyd = pyd_offset(pgd, 0L);
29322 +#endif
29323
29324 - for (addr = i = 0; i < PREALLOCATED_PMDS;
29325 - i++, pud++, addr += PUD_SIZE) {
29326 - pmd_t *pmd = pmds[i];
29327 + for (addr = i = 0; i < PREALLOCATED_PXDS;
29328 + i++, pyd++, addr += PYD_SIZE) {
29329 + pxd_t *pxd = pxds[i];
29330
29331 if (i >= KERNEL_PGD_BOUNDARY)
29332 - memcpy(pmd, (pmd_t *)pgd_page_vaddr(swapper_pg_dir[i]),
29333 - sizeof(pmd_t) * PTRS_PER_PMD);
29334 + memcpy(pxd, (pxd_t *)pgd_page_vaddr(swapper_pg_dir[i]),
29335 + sizeof(pxd_t) * PTRS_PER_PMD);
29336
29337 - pud_populate(mm, pud, pmd);
29338 + pyd_populate(mm, pyd, pxd);
29339 }
29340 }
29341
29342 pgd_t *pgd_alloc(struct mm_struct *mm)
29343 {
29344 pgd_t *pgd;
29345 - pmd_t *pmds[PREALLOCATED_PMDS];
29346 + pxd_t *pxds[PREALLOCATED_PXDS];
29347
29348 pgd = (pgd_t *)__get_free_page(PGALLOC_GFP);
29349
29350 @@ -272,11 +333,11 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
29351
29352 mm->pgd = pgd;
29353
29354 - if (preallocate_pmds(pmds) != 0)
29355 + if (preallocate_pxds(pxds) != 0)
29356 goto out_free_pgd;
29357
29358 if (paravirt_pgd_alloc(mm) != 0)
29359 - goto out_free_pmds;
29360 + goto out_free_pxds;
29361
29362 /*
29363 * Make sure that pre-populating the pmds is atomic with
29364 @@ -286,14 +347,14 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
29365 spin_lock(&pgd_lock);
29366
29367 pgd_ctor(mm, pgd);
29368 - pgd_prepopulate_pmd(mm, pgd, pmds);
29369 + pgd_prepopulate_pxd(mm, pgd, pxds);
29370
29371 spin_unlock(&pgd_lock);
29372
29373 return pgd;
29374
29375 -out_free_pmds:
29376 - free_pmds(pmds);
29377 +out_free_pxds:
29378 + free_pxds(pxds);
29379 out_free_pgd:
29380 free_page((unsigned long)pgd);
29381 out:
29382 @@ -302,7 +363,7 @@ out:
29383
29384 void pgd_free(struct mm_struct *mm, pgd_t *pgd)
29385 {
29386 - pgd_mop_up_pmds(mm, pgd);
29387 + pgd_mop_up_pxds(mm, pgd);
29388 pgd_dtor(pgd);
29389 paravirt_pgd_free(mm, pgd);
29390 free_page((unsigned long)pgd);
29391 diff --git a/arch/x86/mm/pgtable_32.c b/arch/x86/mm/pgtable_32.c
29392 index a69bcb8..19068ab 100644
29393 --- a/arch/x86/mm/pgtable_32.c
29394 +++ b/arch/x86/mm/pgtable_32.c
29395 @@ -47,10 +47,13 @@ void set_pte_vaddr(unsigned long vaddr, pte_t pteval)
29396 return;
29397 }
29398 pte = pte_offset_kernel(pmd, vaddr);
29399 +
29400 + pax_open_kernel();
29401 if (pte_val(pteval))
29402 set_pte_at(&init_mm, vaddr, pte, pteval);
29403 else
29404 pte_clear(&init_mm, vaddr, pte);
29405 + pax_close_kernel();
29406
29407 /*
29408 * It's enough to flush this one mapping.
29409 diff --git a/arch/x86/mm/physaddr.c b/arch/x86/mm/physaddr.c
29410 index e666cbb..61788c45 100644
29411 --- a/arch/x86/mm/physaddr.c
29412 +++ b/arch/x86/mm/physaddr.c
29413 @@ -10,7 +10,7 @@
29414 #ifdef CONFIG_X86_64
29415
29416 #ifdef CONFIG_DEBUG_VIRTUAL
29417 -unsigned long __phys_addr(unsigned long x)
29418 +unsigned long __intentional_overflow(-1) __phys_addr(unsigned long x)
29419 {
29420 unsigned long y = x - __START_KERNEL_map;
29421
29422 @@ -67,7 +67,7 @@ EXPORT_SYMBOL(__virt_addr_valid);
29423 #else
29424
29425 #ifdef CONFIG_DEBUG_VIRTUAL
29426 -unsigned long __phys_addr(unsigned long x)
29427 +unsigned long __intentional_overflow(-1) __phys_addr(unsigned long x)
29428 {
29429 unsigned long phys_addr = x - PAGE_OFFSET;
29430 /* VMALLOC_* aren't constants */
29431 diff --git a/arch/x86/mm/setup_nx.c b/arch/x86/mm/setup_nx.c
29432 index 410531d..0f16030 100644
29433 --- a/arch/x86/mm/setup_nx.c
29434 +++ b/arch/x86/mm/setup_nx.c
29435 @@ -5,8 +5,10 @@
29436 #include <asm/pgtable.h>
29437 #include <asm/proto.h>
29438
29439 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
29440 static int disable_nx __cpuinitdata;
29441
29442 +#ifndef CONFIG_PAX_PAGEEXEC
29443 /*
29444 * noexec = on|off
29445 *
29446 @@ -28,12 +30,17 @@ static int __init noexec_setup(char *str)
29447 return 0;
29448 }
29449 early_param("noexec", noexec_setup);
29450 +#endif
29451 +
29452 +#endif
29453
29454 void __cpuinit x86_configure_nx(void)
29455 {
29456 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
29457 if (cpu_has_nx && !disable_nx)
29458 __supported_pte_mask |= _PAGE_NX;
29459 else
29460 +#endif
29461 __supported_pte_mask &= ~_PAGE_NX;
29462 }
29463
29464 diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c
29465 index 282375f..e03a98f 100644
29466 --- a/arch/x86/mm/tlb.c
29467 +++ b/arch/x86/mm/tlb.c
29468 @@ -48,7 +48,11 @@ void leave_mm(int cpu)
29469 BUG();
29470 if (cpumask_test_cpu(cpu, mm_cpumask(active_mm))) {
29471 cpumask_clear_cpu(cpu, mm_cpumask(active_mm));
29472 +
29473 +#ifndef CONFIG_PAX_PER_CPU_PGD
29474 load_cr3(swapper_pg_dir);
29475 +#endif
29476 +
29477 }
29478 }
29479 EXPORT_SYMBOL_GPL(leave_mm);
29480 diff --git a/arch/x86/net/bpf_jit.S b/arch/x86/net/bpf_jit.S
29481 index 877b9a1..a8ecf42 100644
29482 --- a/arch/x86/net/bpf_jit.S
29483 +++ b/arch/x86/net/bpf_jit.S
29484 @@ -9,6 +9,7 @@
29485 */
29486 #include <linux/linkage.h>
29487 #include <asm/dwarf2.h>
29488 +#include <asm/alternative-asm.h>
29489
29490 /*
29491 * Calling convention :
29492 @@ -35,6 +36,7 @@ sk_load_word_positive_offset:
29493 jle bpf_slow_path_word
29494 mov (SKBDATA,%rsi),%eax
29495 bswap %eax /* ntohl() */
29496 + pax_force_retaddr
29497 ret
29498
29499 sk_load_half:
29500 @@ -52,6 +54,7 @@ sk_load_half_positive_offset:
29501 jle bpf_slow_path_half
29502 movzwl (SKBDATA,%rsi),%eax
29503 rol $8,%ax # ntohs()
29504 + pax_force_retaddr
29505 ret
29506
29507 sk_load_byte:
29508 @@ -66,6 +69,7 @@ sk_load_byte_positive_offset:
29509 cmp %esi,%r9d /* if (offset >= hlen) goto bpf_slow_path_byte */
29510 jle bpf_slow_path_byte
29511 movzbl (SKBDATA,%rsi),%eax
29512 + pax_force_retaddr
29513 ret
29514
29515 /**
29516 @@ -87,6 +91,7 @@ sk_load_byte_msh_positive_offset:
29517 movzbl (SKBDATA,%rsi),%ebx
29518 and $15,%bl
29519 shl $2,%bl
29520 + pax_force_retaddr
29521 ret
29522
29523 /* rsi contains offset and can be scratched */
29524 @@ -109,6 +114,7 @@ bpf_slow_path_word:
29525 js bpf_error
29526 mov -12(%rbp),%eax
29527 bswap %eax
29528 + pax_force_retaddr
29529 ret
29530
29531 bpf_slow_path_half:
29532 @@ -117,12 +123,14 @@ bpf_slow_path_half:
29533 mov -12(%rbp),%ax
29534 rol $8,%ax
29535 movzwl %ax,%eax
29536 + pax_force_retaddr
29537 ret
29538
29539 bpf_slow_path_byte:
29540 bpf_slow_path_common(1)
29541 js bpf_error
29542 movzbl -12(%rbp),%eax
29543 + pax_force_retaddr
29544 ret
29545
29546 bpf_slow_path_byte_msh:
29547 @@ -133,6 +141,7 @@ bpf_slow_path_byte_msh:
29548 and $15,%al
29549 shl $2,%al
29550 xchg %eax,%ebx
29551 + pax_force_retaddr
29552 ret
29553
29554 #define sk_negative_common(SIZE) \
29555 @@ -157,6 +166,7 @@ sk_load_word_negative_offset:
29556 sk_negative_common(4)
29557 mov (%rax), %eax
29558 bswap %eax
29559 + pax_force_retaddr
29560 ret
29561
29562 bpf_slow_path_half_neg:
29563 @@ -168,6 +178,7 @@ sk_load_half_negative_offset:
29564 mov (%rax),%ax
29565 rol $8,%ax
29566 movzwl %ax,%eax
29567 + pax_force_retaddr
29568 ret
29569
29570 bpf_slow_path_byte_neg:
29571 @@ -177,6 +188,7 @@ sk_load_byte_negative_offset:
29572 .globl sk_load_byte_negative_offset
29573 sk_negative_common(1)
29574 movzbl (%rax), %eax
29575 + pax_force_retaddr
29576 ret
29577
29578 bpf_slow_path_byte_msh_neg:
29579 @@ -190,6 +202,7 @@ sk_load_byte_msh_negative_offset:
29580 and $15,%al
29581 shl $2,%al
29582 xchg %eax,%ebx
29583 + pax_force_retaddr
29584 ret
29585
29586 bpf_error:
29587 @@ -197,4 +210,5 @@ bpf_error:
29588 xor %eax,%eax
29589 mov -8(%rbp),%rbx
29590 leaveq
29591 + pax_force_retaddr
29592 ret
29593 diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c
29594 index 3cbe4538..003d011 100644
29595 --- a/arch/x86/net/bpf_jit_comp.c
29596 +++ b/arch/x86/net/bpf_jit_comp.c
29597 @@ -12,6 +12,7 @@
29598 #include <linux/netdevice.h>
29599 #include <linux/filter.h>
29600 #include <linux/if_vlan.h>
29601 +#include <linux/random.h>
29602
29603 /*
29604 * Conventions :
29605 @@ -49,13 +50,90 @@ static inline u8 *emit_code(u8 *ptr, u32 bytes, unsigned int len)
29606 return ptr + len;
29607 }
29608
29609 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29610 +#define MAX_INSTR_CODE_SIZE 96
29611 +#else
29612 +#define MAX_INSTR_CODE_SIZE 64
29613 +#endif
29614 +
29615 #define EMIT(bytes, len) do { prog = emit_code(prog, bytes, len); } while (0)
29616
29617 #define EMIT1(b1) EMIT(b1, 1)
29618 #define EMIT2(b1, b2) EMIT((b1) + ((b2) << 8), 2)
29619 #define EMIT3(b1, b2, b3) EMIT((b1) + ((b2) << 8) + ((b3) << 16), 3)
29620 #define EMIT4(b1, b2, b3, b4) EMIT((b1) + ((b2) << 8) + ((b3) << 16) + ((b4) << 24), 4)
29621 +
29622 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29623 +/* original constant will appear in ecx */
29624 +#define DILUTE_CONST_SEQUENCE(_off, _key) \
29625 +do { \
29626 + /* mov ecx, randkey */ \
29627 + EMIT1(0xb9); \
29628 + EMIT(_key, 4); \
29629 + /* xor ecx, randkey ^ off */ \
29630 + EMIT2(0x81, 0xf1); \
29631 + EMIT((_key) ^ (_off), 4); \
29632 +} while (0)
29633 +
29634 +#define EMIT1_off32(b1, _off) \
29635 +do { \
29636 + switch (b1) { \
29637 + case 0x05: /* add eax, imm32 */ \
29638 + case 0x2d: /* sub eax, imm32 */ \
29639 + case 0x25: /* and eax, imm32 */ \
29640 + case 0x0d: /* or eax, imm32 */ \
29641 + case 0xb8: /* mov eax, imm32 */ \
29642 + case 0x35: /* xor eax, imm32 */ \
29643 + case 0x3d: /* cmp eax, imm32 */ \
29644 + case 0xa9: /* test eax, imm32 */ \
29645 + DILUTE_CONST_SEQUENCE(_off, randkey); \
29646 + EMIT2((b1) - 4, 0xc8); /* convert imm instruction to eax, ecx */\
29647 + break; \
29648 + case 0xbb: /* mov ebx, imm32 */ \
29649 + DILUTE_CONST_SEQUENCE(_off, randkey); \
29650 + /* mov ebx, ecx */ \
29651 + EMIT2(0x89, 0xcb); \
29652 + break; \
29653 + case 0xbe: /* mov esi, imm32 */ \
29654 + DILUTE_CONST_SEQUENCE(_off, randkey); \
29655 + /* mov esi, ecx */ \
29656 + EMIT2(0x89, 0xce); \
29657 + break; \
29658 + case 0xe8: /* call rel imm32, always to known funcs */ \
29659 + EMIT1(b1); \
29660 + EMIT(_off, 4); \
29661 + break; \
29662 + case 0xe9: /* jmp rel imm32 */ \
29663 + EMIT1(b1); \
29664 + EMIT(_off, 4); \
29665 + /* prevent fall-through, we're not called if off = 0 */ \
29666 + EMIT(0xcccccccc, 4); \
29667 + EMIT(0xcccccccc, 4); \
29668 + break; \
29669 + default: \
29670 + BUILD_BUG(); \
29671 + } \
29672 +} while (0)
29673 +
29674 +#define EMIT2_off32(b1, b2, _off) \
29675 +do { \
29676 + if ((b1) == 0x8d && (b2) == 0xb3) { /* lea esi, [rbx+imm32] */ \
29677 + EMIT2(0x8d, 0xb3); /* lea esi, [rbx+randkey] */ \
29678 + EMIT(randkey, 4); \
29679 + EMIT2(0x8d, 0xb6); /* lea esi, [esi+off-randkey] */ \
29680 + EMIT((_off) - randkey, 4); \
29681 + } else if ((b1) == 0x69 && (b2) == 0xc0) { /* imul eax, imm32 */\
29682 + DILUTE_CONST_SEQUENCE(_off, randkey); \
29683 + /* imul eax, ecx */ \
29684 + EMIT3(0x0f, 0xaf, 0xc1); \
29685 + } else { \
29686 + BUILD_BUG(); \
29687 + } \
29688 +} while (0)
29689 +#else
29690 #define EMIT1_off32(b1, off) do { EMIT1(b1); EMIT(off, 4);} while (0)
29691 +#define EMIT2_off32(b1, b2, off) do { EMIT2(b1, b2); EMIT(off, 4);} while (0)
29692 +#endif
29693
29694 #define CLEAR_A() EMIT2(0x31, 0xc0) /* xor %eax,%eax */
29695 #define CLEAR_X() EMIT2(0x31, 0xdb) /* xor %ebx,%ebx */
29696 @@ -90,6 +168,24 @@ do { \
29697 #define X86_JBE 0x76
29698 #define X86_JA 0x77
29699
29700 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29701 +#define APPEND_FLOW_VERIFY() \
29702 +do { \
29703 + /* mov ecx, randkey */ \
29704 + EMIT1(0xb9); \
29705 + EMIT(randkey, 4); \
29706 + /* cmp ecx, randkey */ \
29707 + EMIT2(0x81, 0xf9); \
29708 + EMIT(randkey, 4); \
29709 + /* jz after 8 int 3s */ \
29710 + EMIT2(0x74, 0x08); \
29711 + EMIT(0xcccccccc, 4); \
29712 + EMIT(0xcccccccc, 4); \
29713 +} while (0)
29714 +#else
29715 +#define APPEND_FLOW_VERIFY() do { } while (0)
29716 +#endif
29717 +
29718 #define EMIT_COND_JMP(op, offset) \
29719 do { \
29720 if (is_near(offset)) \
29721 @@ -97,6 +193,7 @@ do { \
29722 else { \
29723 EMIT2(0x0f, op + 0x10); \
29724 EMIT(offset, 4); /* jxx .+off32 */ \
29725 + APPEND_FLOW_VERIFY(); \
29726 } \
29727 } while (0)
29728
29729 @@ -121,6 +218,11 @@ static inline void bpf_flush_icache(void *start, void *end)
29730 set_fs(old_fs);
29731 }
29732
29733 +struct bpf_jit_work {
29734 + struct work_struct work;
29735 + void *image;
29736 +};
29737 +
29738 #define CHOOSE_LOAD_FUNC(K, func) \
29739 ((int)K < 0 ? ((int)K >= SKF_LL_OFF ? func##_negative_offset : func) : func##_positive_offset)
29740
29741 @@ -146,7 +248,7 @@ static int pkt_type_offset(void)
29742
29743 void bpf_jit_compile(struct sk_filter *fp)
29744 {
29745 - u8 temp[64];
29746 + u8 temp[MAX_INSTR_CODE_SIZE];
29747 u8 *prog;
29748 unsigned int proglen, oldproglen = 0;
29749 int ilen, i;
29750 @@ -159,6 +261,9 @@ void bpf_jit_compile(struct sk_filter *fp)
29751 unsigned int *addrs;
29752 const struct sock_filter *filter = fp->insns;
29753 int flen = fp->len;
29754 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29755 + unsigned int randkey;
29756 +#endif
29757
29758 if (!bpf_jit_enable)
29759 return;
29760 @@ -167,11 +272,19 @@ void bpf_jit_compile(struct sk_filter *fp)
29761 if (addrs == NULL)
29762 return;
29763
29764 + fp->work = kmalloc(sizeof(*fp->work), GFP_KERNEL);
29765 + if (!fp->work)
29766 + goto out;
29767 +
29768 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29769 + randkey = get_random_int();
29770 +#endif
29771 +
29772 /* Before first pass, make a rough estimation of addrs[]
29773 - * each bpf instruction is translated to less than 64 bytes
29774 + * each bpf instruction is translated to less than MAX_INSTR_CODE_SIZE bytes
29775 */
29776 for (proglen = 0, i = 0; i < flen; i++) {
29777 - proglen += 64;
29778 + proglen += MAX_INSTR_CODE_SIZE;
29779 addrs[i] = proglen;
29780 }
29781 cleanup_addr = proglen; /* epilogue address */
29782 @@ -282,10 +395,8 @@ void bpf_jit_compile(struct sk_filter *fp)
29783 case BPF_S_ALU_MUL_K: /* A *= K */
29784 if (is_imm8(K))
29785 EMIT3(0x6b, 0xc0, K); /* imul imm8,%eax,%eax */
29786 - else {
29787 - EMIT2(0x69, 0xc0); /* imul imm32,%eax */
29788 - EMIT(K, 4);
29789 - }
29790 + else
29791 + EMIT2_off32(0x69, 0xc0, K); /* imul imm32,%eax */
29792 break;
29793 case BPF_S_ALU_DIV_X: /* A /= X; */
29794 seen |= SEEN_XREG;
29795 @@ -325,13 +436,23 @@ void bpf_jit_compile(struct sk_filter *fp)
29796 break;
29797 case BPF_S_ALU_MOD_K: /* A %= K; */
29798 EMIT2(0x31, 0xd2); /* xor %edx,%edx */
29799 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29800 + DILUTE_CONST_SEQUENCE(K, randkey);
29801 +#else
29802 EMIT1(0xb9);EMIT(K, 4); /* mov imm32,%ecx */
29803 +#endif
29804 EMIT2(0xf7, 0xf1); /* div %ecx */
29805 EMIT2(0x89, 0xd0); /* mov %edx,%eax */
29806 break;
29807 case BPF_S_ALU_DIV_K: /* A = reciprocal_divide(A, K); */
29808 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29809 + DILUTE_CONST_SEQUENCE(K, randkey);
29810 + // imul rax, rcx
29811 + EMIT4(0x48, 0x0f, 0xaf, 0xc1);
29812 +#else
29813 EMIT3(0x48, 0x69, 0xc0); /* imul imm32,%rax,%rax */
29814 EMIT(K, 4);
29815 +#endif
29816 EMIT4(0x48, 0xc1, 0xe8, 0x20); /* shr $0x20,%rax */
29817 break;
29818 case BPF_S_ALU_AND_X:
29819 @@ -602,8 +723,7 @@ common_load_ind: seen |= SEEN_DATAREF | SEEN_XREG;
29820 if (is_imm8(K)) {
29821 EMIT3(0x8d, 0x73, K); /* lea imm8(%rbx), %esi */
29822 } else {
29823 - EMIT2(0x8d, 0xb3); /* lea imm32(%rbx),%esi */
29824 - EMIT(K, 4);
29825 + EMIT2_off32(0x8d, 0xb3, K); /* lea imm32(%rbx),%esi */
29826 }
29827 } else {
29828 EMIT2(0x89,0xde); /* mov %ebx,%esi */
29829 @@ -686,17 +806,18 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
29830 break;
29831 default:
29832 /* hmm, too complex filter, give up with jit compiler */
29833 - goto out;
29834 + goto error;
29835 }
29836 ilen = prog - temp;
29837 if (image) {
29838 if (unlikely(proglen + ilen > oldproglen)) {
29839 pr_err("bpb_jit_compile fatal error\n");
29840 - kfree(addrs);
29841 - module_free(NULL, image);
29842 - return;
29843 + module_free_exec(NULL, image);
29844 + goto error;
29845 }
29846 + pax_open_kernel();
29847 memcpy(image + proglen, temp, ilen);
29848 + pax_close_kernel();
29849 }
29850 proglen += ilen;
29851 addrs[i] = proglen;
29852 @@ -717,11 +838,9 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
29853 break;
29854 }
29855 if (proglen == oldproglen) {
29856 - image = module_alloc(max_t(unsigned int,
29857 - proglen,
29858 - sizeof(struct work_struct)));
29859 + image = module_alloc_exec(proglen);
29860 if (!image)
29861 - goto out;
29862 + goto error;
29863 }
29864 oldproglen = proglen;
29865 }
29866 @@ -737,7 +856,10 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
29867 bpf_flush_icache(image, image + proglen);
29868
29869 fp->bpf_func = (void *)image;
29870 - }
29871 + } else
29872 +error:
29873 + kfree(fp->work);
29874 +
29875 out:
29876 kfree(addrs);
29877 return;
29878 @@ -745,18 +867,20 @@ out:
29879
29880 static void jit_free_defer(struct work_struct *arg)
29881 {
29882 - module_free(NULL, arg);
29883 + module_free_exec(NULL, ((struct bpf_jit_work *)arg)->image);
29884 + kfree(arg);
29885 }
29886
29887 /* run from softirq, we must use a work_struct to call
29888 - * module_free() from process context
29889 + * module_free_exec() from process context
29890 */
29891 void bpf_jit_free(struct sk_filter *fp)
29892 {
29893 if (fp->bpf_func != sk_run_filter) {
29894 - struct work_struct *work = (struct work_struct *)fp->bpf_func;
29895 + struct work_struct *work = &fp->work->work;
29896
29897 INIT_WORK(work, jit_free_defer);
29898 + fp->work->image = fp->bpf_func;
29899 schedule_work(work);
29900 }
29901 }
29902 diff --git a/arch/x86/oprofile/backtrace.c b/arch/x86/oprofile/backtrace.c
29903 index d6aa6e8..266395a 100644
29904 --- a/arch/x86/oprofile/backtrace.c
29905 +++ b/arch/x86/oprofile/backtrace.c
29906 @@ -46,11 +46,11 @@ dump_user_backtrace_32(struct stack_frame_ia32 *head)
29907 struct stack_frame_ia32 *fp;
29908 unsigned long bytes;
29909
29910 - bytes = copy_from_user_nmi(bufhead, head, sizeof(bufhead));
29911 + bytes = copy_from_user_nmi(bufhead, (const char __force_user *)head, sizeof(bufhead));
29912 if (bytes != sizeof(bufhead))
29913 return NULL;
29914
29915 - fp = (struct stack_frame_ia32 *) compat_ptr(bufhead[0].next_frame);
29916 + fp = (struct stack_frame_ia32 __force_kernel *) compat_ptr(bufhead[0].next_frame);
29917
29918 oprofile_add_trace(bufhead[0].return_address);
29919
29920 @@ -92,7 +92,7 @@ static struct stack_frame *dump_user_backtrace(struct stack_frame *head)
29921 struct stack_frame bufhead[2];
29922 unsigned long bytes;
29923
29924 - bytes = copy_from_user_nmi(bufhead, head, sizeof(bufhead));
29925 + bytes = copy_from_user_nmi(bufhead, (const char __force_user *)head, sizeof(bufhead));
29926 if (bytes != sizeof(bufhead))
29927 return NULL;
29928
29929 @@ -111,7 +111,7 @@ x86_backtrace(struct pt_regs * const regs, unsigned int depth)
29930 {
29931 struct stack_frame *head = (struct stack_frame *)frame_pointer(regs);
29932
29933 - if (!user_mode_vm(regs)) {
29934 + if (!user_mode(regs)) {
29935 unsigned long stack = kernel_stack_pointer(regs);
29936 if (depth)
29937 dump_trace(NULL, regs, (unsigned long *)stack, 0,
29938 diff --git a/arch/x86/oprofile/nmi_int.c b/arch/x86/oprofile/nmi_int.c
29939 index 48768df..ba9143c 100644
29940 --- a/arch/x86/oprofile/nmi_int.c
29941 +++ b/arch/x86/oprofile/nmi_int.c
29942 @@ -23,6 +23,7 @@
29943 #include <asm/nmi.h>
29944 #include <asm/msr.h>
29945 #include <asm/apic.h>
29946 +#include <asm/pgtable.h>
29947
29948 #include "op_counter.h"
29949 #include "op_x86_model.h"
29950 @@ -774,8 +775,11 @@ int __init op_nmi_init(struct oprofile_operations *ops)
29951 if (ret)
29952 return ret;
29953
29954 - if (!model->num_virt_counters)
29955 - model->num_virt_counters = model->num_counters;
29956 + if (!model->num_virt_counters) {
29957 + pax_open_kernel();
29958 + *(unsigned int *)&model->num_virt_counters = model->num_counters;
29959 + pax_close_kernel();
29960 + }
29961
29962 mux_init(ops);
29963
29964 diff --git a/arch/x86/oprofile/op_model_amd.c b/arch/x86/oprofile/op_model_amd.c
29965 index b2b9443..be58856 100644
29966 --- a/arch/x86/oprofile/op_model_amd.c
29967 +++ b/arch/x86/oprofile/op_model_amd.c
29968 @@ -519,9 +519,11 @@ static int op_amd_init(struct oprofile_operations *ops)
29969 num_counters = AMD64_NUM_COUNTERS;
29970 }
29971
29972 - op_amd_spec.num_counters = num_counters;
29973 - op_amd_spec.num_controls = num_counters;
29974 - op_amd_spec.num_virt_counters = max(num_counters, NUM_VIRT_COUNTERS);
29975 + pax_open_kernel();
29976 + *(unsigned int *)&op_amd_spec.num_counters = num_counters;
29977 + *(unsigned int *)&op_amd_spec.num_controls = num_counters;
29978 + *(unsigned int *)&op_amd_spec.num_virt_counters = max(num_counters, NUM_VIRT_COUNTERS);
29979 + pax_close_kernel();
29980
29981 return 0;
29982 }
29983 diff --git a/arch/x86/oprofile/op_model_ppro.c b/arch/x86/oprofile/op_model_ppro.c
29984 index d90528e..0127e2b 100644
29985 --- a/arch/x86/oprofile/op_model_ppro.c
29986 +++ b/arch/x86/oprofile/op_model_ppro.c
29987 @@ -19,6 +19,7 @@
29988 #include <asm/msr.h>
29989 #include <asm/apic.h>
29990 #include <asm/nmi.h>
29991 +#include <asm/pgtable.h>
29992
29993 #include "op_x86_model.h"
29994 #include "op_counter.h"
29995 @@ -221,8 +222,10 @@ static void arch_perfmon_setup_counters(void)
29996
29997 num_counters = min((int)eax.split.num_counters, OP_MAX_COUNTER);
29998
29999 - op_arch_perfmon_spec.num_counters = num_counters;
30000 - op_arch_perfmon_spec.num_controls = num_counters;
30001 + pax_open_kernel();
30002 + *(unsigned int *)&op_arch_perfmon_spec.num_counters = num_counters;
30003 + *(unsigned int *)&op_arch_perfmon_spec.num_controls = num_counters;
30004 + pax_close_kernel();
30005 }
30006
30007 static int arch_perfmon_init(struct oprofile_operations *ignore)
30008 diff --git a/arch/x86/oprofile/op_x86_model.h b/arch/x86/oprofile/op_x86_model.h
30009 index 71e8a67..6a313bb 100644
30010 --- a/arch/x86/oprofile/op_x86_model.h
30011 +++ b/arch/x86/oprofile/op_x86_model.h
30012 @@ -52,7 +52,7 @@ struct op_x86_model_spec {
30013 void (*switch_ctrl)(struct op_x86_model_spec const *model,
30014 struct op_msrs const * const msrs);
30015 #endif
30016 -};
30017 +} __do_const;
30018
30019 struct op_counter_config;
30020
30021 diff --git a/arch/x86/pci/amd_bus.c b/arch/x86/pci/amd_bus.c
30022 index e9e6ed5..e47ae67 100644
30023 --- a/arch/x86/pci/amd_bus.c
30024 +++ b/arch/x86/pci/amd_bus.c
30025 @@ -337,7 +337,7 @@ static int __cpuinit amd_cpu_notify(struct notifier_block *self,
30026 return NOTIFY_OK;
30027 }
30028
30029 -static struct notifier_block __cpuinitdata amd_cpu_notifier = {
30030 +static struct notifier_block amd_cpu_notifier = {
30031 .notifier_call = amd_cpu_notify,
30032 };
30033
30034 diff --git a/arch/x86/pci/irq.c b/arch/x86/pci/irq.c
30035 index 372e9b8..e775a6c 100644
30036 --- a/arch/x86/pci/irq.c
30037 +++ b/arch/x86/pci/irq.c
30038 @@ -50,7 +50,7 @@ struct irq_router {
30039 struct irq_router_handler {
30040 u16 vendor;
30041 int (*probe)(struct irq_router *r, struct pci_dev *router, u16 device);
30042 -};
30043 +} __do_const;
30044
30045 int (*pcibios_enable_irq)(struct pci_dev *dev) = pirq_enable_irq;
30046 void (*pcibios_disable_irq)(struct pci_dev *dev) = NULL;
30047 @@ -794,7 +794,7 @@ static __init int pico_router_probe(struct irq_router *r, struct pci_dev *router
30048 return 0;
30049 }
30050
30051 -static __initdata struct irq_router_handler pirq_routers[] = {
30052 +static __initconst const struct irq_router_handler pirq_routers[] = {
30053 { PCI_VENDOR_ID_INTEL, intel_router_probe },
30054 { PCI_VENDOR_ID_AL, ali_router_probe },
30055 { PCI_VENDOR_ID_ITE, ite_router_probe },
30056 @@ -821,7 +821,7 @@ static struct pci_dev *pirq_router_dev;
30057 static void __init pirq_find_router(struct irq_router *r)
30058 {
30059 struct irq_routing_table *rt = pirq_table;
30060 - struct irq_router_handler *h;
30061 + const struct irq_router_handler *h;
30062
30063 #ifdef CONFIG_PCI_BIOS
30064 if (!rt->signature) {
30065 @@ -1094,7 +1094,7 @@ static int __init fix_acer_tm360_irqrouting(const struct dmi_system_id *d)
30066 return 0;
30067 }
30068
30069 -static struct dmi_system_id __initdata pciirq_dmi_table[] = {
30070 +static const struct dmi_system_id __initconst pciirq_dmi_table[] = {
30071 {
30072 .callback = fix_broken_hp_bios_irq9,
30073 .ident = "HP Pavilion N5400 Series Laptop",
30074 diff --git a/arch/x86/pci/mrst.c b/arch/x86/pci/mrst.c
30075 index 6eb18c4..20d83de 100644
30076 --- a/arch/x86/pci/mrst.c
30077 +++ b/arch/x86/pci/mrst.c
30078 @@ -238,7 +238,9 @@ int __init pci_mrst_init(void)
30079 printk(KERN_INFO "Intel MID platform detected, using MID PCI ops\n");
30080 pci_mmcfg_late_init();
30081 pcibios_enable_irq = mrst_pci_irq_enable;
30082 - pci_root_ops = pci_mrst_ops;
30083 + pax_open_kernel();
30084 + memcpy((void *)&pci_root_ops, &pci_mrst_ops, sizeof(pci_mrst_ops));
30085 + pax_close_kernel();
30086 pci_soc_mode = 1;
30087 /* Continue with standard init */
30088 return 1;
30089 diff --git a/arch/x86/pci/pcbios.c b/arch/x86/pci/pcbios.c
30090 index c77b24a..c979855 100644
30091 --- a/arch/x86/pci/pcbios.c
30092 +++ b/arch/x86/pci/pcbios.c
30093 @@ -79,7 +79,7 @@ union bios32 {
30094 static struct {
30095 unsigned long address;
30096 unsigned short segment;
30097 -} bios32_indirect = { 0, __KERNEL_CS };
30098 +} bios32_indirect __read_only = { 0, __PCIBIOS_CS };
30099
30100 /*
30101 * Returns the entry point for the given service, NULL on error
30102 @@ -92,37 +92,80 @@ static unsigned long bios32_service(unsigned long service)
30103 unsigned long length; /* %ecx */
30104 unsigned long entry; /* %edx */
30105 unsigned long flags;
30106 + struct desc_struct d, *gdt;
30107
30108 local_irq_save(flags);
30109 - __asm__("lcall *(%%edi); cld"
30110 +
30111 + gdt = get_cpu_gdt_table(smp_processor_id());
30112 +
30113 + pack_descriptor(&d, 0UL, 0xFFFFFUL, 0x9B, 0xC);
30114 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_CS, &d, DESCTYPE_S);
30115 + pack_descriptor(&d, 0UL, 0xFFFFFUL, 0x93, 0xC);
30116 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_DS, &d, DESCTYPE_S);
30117 +
30118 + __asm__("movw %w7, %%ds; lcall *(%%edi); push %%ss; pop %%ds; cld"
30119 : "=a" (return_code),
30120 "=b" (address),
30121 "=c" (length),
30122 "=d" (entry)
30123 : "0" (service),
30124 "1" (0),
30125 - "D" (&bios32_indirect));
30126 + "D" (&bios32_indirect),
30127 + "r"(__PCIBIOS_DS)
30128 + : "memory");
30129 +
30130 + pax_open_kernel();
30131 + gdt[GDT_ENTRY_PCIBIOS_CS].a = 0;
30132 + gdt[GDT_ENTRY_PCIBIOS_CS].b = 0;
30133 + gdt[GDT_ENTRY_PCIBIOS_DS].a = 0;
30134 + gdt[GDT_ENTRY_PCIBIOS_DS].b = 0;
30135 + pax_close_kernel();
30136 +
30137 local_irq_restore(flags);
30138
30139 switch (return_code) {
30140 - case 0:
30141 - return address + entry;
30142 - case 0x80: /* Not present */
30143 - printk(KERN_WARNING "bios32_service(0x%lx): not present\n", service);
30144 - return 0;
30145 - default: /* Shouldn't happen */
30146 - printk(KERN_WARNING "bios32_service(0x%lx): returned 0x%x -- BIOS bug!\n",
30147 - service, return_code);
30148 + case 0: {
30149 + int cpu;
30150 + unsigned char flags;
30151 +
30152 + printk(KERN_INFO "bios32_service: base:%08lx length:%08lx entry:%08lx\n", address, length, entry);
30153 + if (address >= 0xFFFF0 || length > 0x100000 - address || length <= entry) {
30154 + printk(KERN_WARNING "bios32_service: not valid\n");
30155 return 0;
30156 + }
30157 + address = address + PAGE_OFFSET;
30158 + length += 16UL; /* some BIOSs underreport this... */
30159 + flags = 4;
30160 + if (length >= 64*1024*1024) {
30161 + length >>= PAGE_SHIFT;
30162 + flags |= 8;
30163 + }
30164 +
30165 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
30166 + gdt = get_cpu_gdt_table(cpu);
30167 + pack_descriptor(&d, address, length, 0x9b, flags);
30168 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_CS, &d, DESCTYPE_S);
30169 + pack_descriptor(&d, address, length, 0x93, flags);
30170 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_DS, &d, DESCTYPE_S);
30171 + }
30172 + return entry;
30173 + }
30174 + case 0x80: /* Not present */
30175 + printk(KERN_WARNING "bios32_service(0x%lx): not present\n", service);
30176 + return 0;
30177 + default: /* Shouldn't happen */
30178 + printk(KERN_WARNING "bios32_service(0x%lx): returned 0x%x -- BIOS bug!\n",
30179 + service, return_code);
30180 + return 0;
30181 }
30182 }
30183
30184 static struct {
30185 unsigned long address;
30186 unsigned short segment;
30187 -} pci_indirect = { 0, __KERNEL_CS };
30188 +} pci_indirect __read_only = { 0, __PCIBIOS_CS };
30189
30190 -static int pci_bios_present;
30191 +static int pci_bios_present __read_only;
30192
30193 static int check_pcibios(void)
30194 {
30195 @@ -131,11 +174,13 @@ static int check_pcibios(void)
30196 unsigned long flags, pcibios_entry;
30197
30198 if ((pcibios_entry = bios32_service(PCI_SERVICE))) {
30199 - pci_indirect.address = pcibios_entry + PAGE_OFFSET;
30200 + pci_indirect.address = pcibios_entry;
30201
30202 local_irq_save(flags);
30203 - __asm__(
30204 - "lcall *(%%edi); cld\n\t"
30205 + __asm__("movw %w6, %%ds\n\t"
30206 + "lcall *%%ss:(%%edi); cld\n\t"
30207 + "push %%ss\n\t"
30208 + "pop %%ds\n\t"
30209 "jc 1f\n\t"
30210 "xor %%ah, %%ah\n"
30211 "1:"
30212 @@ -144,7 +189,8 @@ static int check_pcibios(void)
30213 "=b" (ebx),
30214 "=c" (ecx)
30215 : "1" (PCIBIOS_PCI_BIOS_PRESENT),
30216 - "D" (&pci_indirect)
30217 + "D" (&pci_indirect),
30218 + "r" (__PCIBIOS_DS)
30219 : "memory");
30220 local_irq_restore(flags);
30221
30222 @@ -189,7 +235,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30223
30224 switch (len) {
30225 case 1:
30226 - __asm__("lcall *(%%esi); cld\n\t"
30227 + __asm__("movw %w6, %%ds\n\t"
30228 + "lcall *%%ss:(%%esi); cld\n\t"
30229 + "push %%ss\n\t"
30230 + "pop %%ds\n\t"
30231 "jc 1f\n\t"
30232 "xor %%ah, %%ah\n"
30233 "1:"
30234 @@ -198,7 +247,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30235 : "1" (PCIBIOS_READ_CONFIG_BYTE),
30236 "b" (bx),
30237 "D" ((long)reg),
30238 - "S" (&pci_indirect));
30239 + "S" (&pci_indirect),
30240 + "r" (__PCIBIOS_DS));
30241 /*
30242 * Zero-extend the result beyond 8 bits, do not trust the
30243 * BIOS having done it:
30244 @@ -206,7 +256,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30245 *value &= 0xff;
30246 break;
30247 case 2:
30248 - __asm__("lcall *(%%esi); cld\n\t"
30249 + __asm__("movw %w6, %%ds\n\t"
30250 + "lcall *%%ss:(%%esi); cld\n\t"
30251 + "push %%ss\n\t"
30252 + "pop %%ds\n\t"
30253 "jc 1f\n\t"
30254 "xor %%ah, %%ah\n"
30255 "1:"
30256 @@ -215,7 +268,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30257 : "1" (PCIBIOS_READ_CONFIG_WORD),
30258 "b" (bx),
30259 "D" ((long)reg),
30260 - "S" (&pci_indirect));
30261 + "S" (&pci_indirect),
30262 + "r" (__PCIBIOS_DS));
30263 /*
30264 * Zero-extend the result beyond 16 bits, do not trust the
30265 * BIOS having done it:
30266 @@ -223,7 +277,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30267 *value &= 0xffff;
30268 break;
30269 case 4:
30270 - __asm__("lcall *(%%esi); cld\n\t"
30271 + __asm__("movw %w6, %%ds\n\t"
30272 + "lcall *%%ss:(%%esi); cld\n\t"
30273 + "push %%ss\n\t"
30274 + "pop %%ds\n\t"
30275 "jc 1f\n\t"
30276 "xor %%ah, %%ah\n"
30277 "1:"
30278 @@ -232,7 +289,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30279 : "1" (PCIBIOS_READ_CONFIG_DWORD),
30280 "b" (bx),
30281 "D" ((long)reg),
30282 - "S" (&pci_indirect));
30283 + "S" (&pci_indirect),
30284 + "r" (__PCIBIOS_DS));
30285 break;
30286 }
30287
30288 @@ -256,7 +314,10 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
30289
30290 switch (len) {
30291 case 1:
30292 - __asm__("lcall *(%%esi); cld\n\t"
30293 + __asm__("movw %w6, %%ds\n\t"
30294 + "lcall *%%ss:(%%esi); cld\n\t"
30295 + "push %%ss\n\t"
30296 + "pop %%ds\n\t"
30297 "jc 1f\n\t"
30298 "xor %%ah, %%ah\n"
30299 "1:"
30300 @@ -265,10 +326,14 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
30301 "c" (value),
30302 "b" (bx),
30303 "D" ((long)reg),
30304 - "S" (&pci_indirect));
30305 + "S" (&pci_indirect),
30306 + "r" (__PCIBIOS_DS));
30307 break;
30308 case 2:
30309 - __asm__("lcall *(%%esi); cld\n\t"
30310 + __asm__("movw %w6, %%ds\n\t"
30311 + "lcall *%%ss:(%%esi); cld\n\t"
30312 + "push %%ss\n\t"
30313 + "pop %%ds\n\t"
30314 "jc 1f\n\t"
30315 "xor %%ah, %%ah\n"
30316 "1:"
30317 @@ -277,10 +342,14 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
30318 "c" (value),
30319 "b" (bx),
30320 "D" ((long)reg),
30321 - "S" (&pci_indirect));
30322 + "S" (&pci_indirect),
30323 + "r" (__PCIBIOS_DS));
30324 break;
30325 case 4:
30326 - __asm__("lcall *(%%esi); cld\n\t"
30327 + __asm__("movw %w6, %%ds\n\t"
30328 + "lcall *%%ss:(%%esi); cld\n\t"
30329 + "push %%ss\n\t"
30330 + "pop %%ds\n\t"
30331 "jc 1f\n\t"
30332 "xor %%ah, %%ah\n"
30333 "1:"
30334 @@ -289,7 +358,8 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
30335 "c" (value),
30336 "b" (bx),
30337 "D" ((long)reg),
30338 - "S" (&pci_indirect));
30339 + "S" (&pci_indirect),
30340 + "r" (__PCIBIOS_DS));
30341 break;
30342 }
30343
30344 @@ -394,10 +464,13 @@ struct irq_routing_table * pcibios_get_irq_routing_table(void)
30345
30346 DBG("PCI: Fetching IRQ routing table... ");
30347 __asm__("push %%es\n\t"
30348 + "movw %w8, %%ds\n\t"
30349 "push %%ds\n\t"
30350 "pop %%es\n\t"
30351 - "lcall *(%%esi); cld\n\t"
30352 + "lcall *%%ss:(%%esi); cld\n\t"
30353 "pop %%es\n\t"
30354 + "push %%ss\n\t"
30355 + "pop %%ds\n"
30356 "jc 1f\n\t"
30357 "xor %%ah, %%ah\n"
30358 "1:"
30359 @@ -408,7 +481,8 @@ struct irq_routing_table * pcibios_get_irq_routing_table(void)
30360 "1" (0),
30361 "D" ((long) &opt),
30362 "S" (&pci_indirect),
30363 - "m" (opt)
30364 + "m" (opt),
30365 + "r" (__PCIBIOS_DS)
30366 : "memory");
30367 DBG("OK ret=%d, size=%d, map=%x\n", ret, opt.size, map);
30368 if (ret & 0xff00)
30369 @@ -432,7 +506,10 @@ int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq)
30370 {
30371 int ret;
30372
30373 - __asm__("lcall *(%%esi); cld\n\t"
30374 + __asm__("movw %w5, %%ds\n\t"
30375 + "lcall *%%ss:(%%esi); cld\n\t"
30376 + "push %%ss\n\t"
30377 + "pop %%ds\n"
30378 "jc 1f\n\t"
30379 "xor %%ah, %%ah\n"
30380 "1:"
30381 @@ -440,7 +517,8 @@ int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq)
30382 : "0" (PCIBIOS_SET_PCI_HW_INT),
30383 "b" ((dev->bus->number << 8) | dev->devfn),
30384 "c" ((irq << 8) | (pin + 10)),
30385 - "S" (&pci_indirect));
30386 + "S" (&pci_indirect),
30387 + "r" (__PCIBIOS_DS));
30388 return !(ret & 0xff00);
30389 }
30390 EXPORT_SYMBOL(pcibios_set_irq_routing);
30391 diff --git a/arch/x86/platform/efi/efi_32.c b/arch/x86/platform/efi/efi_32.c
30392 index 40e4469..1ab536e 100644
30393 --- a/arch/x86/platform/efi/efi_32.c
30394 +++ b/arch/x86/platform/efi/efi_32.c
30395 @@ -44,11 +44,22 @@ void efi_call_phys_prelog(void)
30396 {
30397 struct desc_ptr gdt_descr;
30398
30399 +#ifdef CONFIG_PAX_KERNEXEC
30400 + struct desc_struct d;
30401 +#endif
30402 +
30403 local_irq_save(efi_rt_eflags);
30404
30405 load_cr3(initial_page_table);
30406 __flush_tlb_all();
30407
30408 +#ifdef CONFIG_PAX_KERNEXEC
30409 + pack_descriptor(&d, 0, 0xFFFFF, 0x9B, 0xC);
30410 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_CS, &d, DESCTYPE_S);
30411 + pack_descriptor(&d, 0, 0xFFFFF, 0x93, 0xC);
30412 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_DS, &d, DESCTYPE_S);
30413 +#endif
30414 +
30415 gdt_descr.address = __pa(get_cpu_gdt_table(0));
30416 gdt_descr.size = GDT_SIZE - 1;
30417 load_gdt(&gdt_descr);
30418 @@ -58,6 +69,14 @@ void efi_call_phys_epilog(void)
30419 {
30420 struct desc_ptr gdt_descr;
30421
30422 +#ifdef CONFIG_PAX_KERNEXEC
30423 + struct desc_struct d;
30424 +
30425 + memset(&d, 0, sizeof d);
30426 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_CS, &d, DESCTYPE_S);
30427 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_DS, &d, DESCTYPE_S);
30428 +#endif
30429 +
30430 gdt_descr.address = (unsigned long)get_cpu_gdt_table(0);
30431 gdt_descr.size = GDT_SIZE - 1;
30432 load_gdt(&gdt_descr);
30433 diff --git a/arch/x86/platform/efi/efi_stub_32.S b/arch/x86/platform/efi/efi_stub_32.S
30434 index fbe66e6..eae5e38 100644
30435 --- a/arch/x86/platform/efi/efi_stub_32.S
30436 +++ b/arch/x86/platform/efi/efi_stub_32.S
30437 @@ -6,7 +6,9 @@
30438 */
30439
30440 #include <linux/linkage.h>
30441 +#include <linux/init.h>
30442 #include <asm/page_types.h>
30443 +#include <asm/segment.h>
30444
30445 /*
30446 * efi_call_phys(void *, ...) is a function with variable parameters.
30447 @@ -20,7 +22,7 @@
30448 * service functions will comply with gcc calling convention, too.
30449 */
30450
30451 -.text
30452 +__INIT
30453 ENTRY(efi_call_phys)
30454 /*
30455 * 0. The function can only be called in Linux kernel. So CS has been
30456 @@ -36,10 +38,24 @@ ENTRY(efi_call_phys)
30457 * The mapping of lower virtual memory has been created in prelog and
30458 * epilog.
30459 */
30460 - movl $1f, %edx
30461 - subl $__PAGE_OFFSET, %edx
30462 - jmp *%edx
30463 +#ifdef CONFIG_PAX_KERNEXEC
30464 + movl $(__KERNEXEC_EFI_DS), %edx
30465 + mov %edx, %ds
30466 + mov %edx, %es
30467 + mov %edx, %ss
30468 + addl $2f,(1f)
30469 + ljmp *(1f)
30470 +
30471 +__INITDATA
30472 +1: .long __LOAD_PHYSICAL_ADDR, __KERNEXEC_EFI_CS
30473 +.previous
30474 +
30475 +2:
30476 + subl $2b,(1b)
30477 +#else
30478 + jmp 1f-__PAGE_OFFSET
30479 1:
30480 +#endif
30481
30482 /*
30483 * 2. Now on the top of stack is the return
30484 @@ -47,14 +63,8 @@ ENTRY(efi_call_phys)
30485 * parameter 2, ..., param n. To make things easy, we save the return
30486 * address of efi_call_phys in a global variable.
30487 */
30488 - popl %edx
30489 - movl %edx, saved_return_addr
30490 - /* get the function pointer into ECX*/
30491 - popl %ecx
30492 - movl %ecx, efi_rt_function_ptr
30493 - movl $2f, %edx
30494 - subl $__PAGE_OFFSET, %edx
30495 - pushl %edx
30496 + popl (saved_return_addr)
30497 + popl (efi_rt_function_ptr)
30498
30499 /*
30500 * 3. Clear PG bit in %CR0.
30501 @@ -73,9 +83,8 @@ ENTRY(efi_call_phys)
30502 /*
30503 * 5. Call the physical function.
30504 */
30505 - jmp *%ecx
30506 + call *(efi_rt_function_ptr-__PAGE_OFFSET)
30507
30508 -2:
30509 /*
30510 * 6. After EFI runtime service returns, control will return to
30511 * following instruction. We'd better readjust stack pointer first.
30512 @@ -88,35 +97,36 @@ ENTRY(efi_call_phys)
30513 movl %cr0, %edx
30514 orl $0x80000000, %edx
30515 movl %edx, %cr0
30516 - jmp 1f
30517 -1:
30518 +
30519 /*
30520 * 8. Now restore the virtual mode from flat mode by
30521 * adding EIP with PAGE_OFFSET.
30522 */
30523 - movl $1f, %edx
30524 - jmp *%edx
30525 +#ifdef CONFIG_PAX_KERNEXEC
30526 + movl $(__KERNEL_DS), %edx
30527 + mov %edx, %ds
30528 + mov %edx, %es
30529 + mov %edx, %ss
30530 + ljmp $(__KERNEL_CS),$1f
30531 +#else
30532 + jmp 1f+__PAGE_OFFSET
30533 +#endif
30534 1:
30535
30536 /*
30537 * 9. Balance the stack. And because EAX contain the return value,
30538 * we'd better not clobber it.
30539 */
30540 - leal efi_rt_function_ptr, %edx
30541 - movl (%edx), %ecx
30542 - pushl %ecx
30543 + pushl (efi_rt_function_ptr)
30544
30545 /*
30546 - * 10. Push the saved return address onto the stack and return.
30547 + * 10. Return to the saved return address.
30548 */
30549 - leal saved_return_addr, %edx
30550 - movl (%edx), %ecx
30551 - pushl %ecx
30552 - ret
30553 + jmpl *(saved_return_addr)
30554 ENDPROC(efi_call_phys)
30555 .previous
30556
30557 -.data
30558 +__INITDATA
30559 saved_return_addr:
30560 .long 0
30561 efi_rt_function_ptr:
30562 diff --git a/arch/x86/platform/efi/efi_stub_64.S b/arch/x86/platform/efi/efi_stub_64.S
30563 index 4c07cca..2c8427d 100644
30564 --- a/arch/x86/platform/efi/efi_stub_64.S
30565 +++ b/arch/x86/platform/efi/efi_stub_64.S
30566 @@ -7,6 +7,7 @@
30567 */
30568
30569 #include <linux/linkage.h>
30570 +#include <asm/alternative-asm.h>
30571
30572 #define SAVE_XMM \
30573 mov %rsp, %rax; \
30574 @@ -40,6 +41,7 @@ ENTRY(efi_call0)
30575 call *%rdi
30576 addq $32, %rsp
30577 RESTORE_XMM
30578 + pax_force_retaddr 0, 1
30579 ret
30580 ENDPROC(efi_call0)
30581
30582 @@ -50,6 +52,7 @@ ENTRY(efi_call1)
30583 call *%rdi
30584 addq $32, %rsp
30585 RESTORE_XMM
30586 + pax_force_retaddr 0, 1
30587 ret
30588 ENDPROC(efi_call1)
30589
30590 @@ -60,6 +63,7 @@ ENTRY(efi_call2)
30591 call *%rdi
30592 addq $32, %rsp
30593 RESTORE_XMM
30594 + pax_force_retaddr 0, 1
30595 ret
30596 ENDPROC(efi_call2)
30597
30598 @@ -71,6 +75,7 @@ ENTRY(efi_call3)
30599 call *%rdi
30600 addq $32, %rsp
30601 RESTORE_XMM
30602 + pax_force_retaddr 0, 1
30603 ret
30604 ENDPROC(efi_call3)
30605
30606 @@ -83,6 +88,7 @@ ENTRY(efi_call4)
30607 call *%rdi
30608 addq $32, %rsp
30609 RESTORE_XMM
30610 + pax_force_retaddr 0, 1
30611 ret
30612 ENDPROC(efi_call4)
30613
30614 @@ -96,6 +102,7 @@ ENTRY(efi_call5)
30615 call *%rdi
30616 addq $48, %rsp
30617 RESTORE_XMM
30618 + pax_force_retaddr 0, 1
30619 ret
30620 ENDPROC(efi_call5)
30621
30622 @@ -112,5 +119,6 @@ ENTRY(efi_call6)
30623 call *%rdi
30624 addq $48, %rsp
30625 RESTORE_XMM
30626 + pax_force_retaddr 0, 1
30627 ret
30628 ENDPROC(efi_call6)
30629 diff --git a/arch/x86/platform/mrst/mrst.c b/arch/x86/platform/mrst/mrst.c
30630 index e31bcd8..f12dc46 100644
30631 --- a/arch/x86/platform/mrst/mrst.c
30632 +++ b/arch/x86/platform/mrst/mrst.c
30633 @@ -78,13 +78,15 @@ struct sfi_rtc_table_entry sfi_mrtc_array[SFI_MRTC_MAX];
30634 EXPORT_SYMBOL_GPL(sfi_mrtc_array);
30635 int sfi_mrtc_num;
30636
30637 -static void mrst_power_off(void)
30638 +static __noreturn void mrst_power_off(void)
30639 {
30640 + BUG();
30641 }
30642
30643 -static void mrst_reboot(void)
30644 +static __noreturn void mrst_reboot(void)
30645 {
30646 intel_scu_ipc_simple_command(IPCMSG_COLD_BOOT, 0);
30647 + BUG();
30648 }
30649
30650 /* parse all the mtimer info to a static mtimer array */
30651 diff --git a/arch/x86/platform/olpc/olpc_dt.c b/arch/x86/platform/olpc/olpc_dt.c
30652 index d6ee929..3637cb5 100644
30653 --- a/arch/x86/platform/olpc/olpc_dt.c
30654 +++ b/arch/x86/platform/olpc/olpc_dt.c
30655 @@ -156,7 +156,7 @@ void * __init prom_early_alloc(unsigned long size)
30656 return res;
30657 }
30658
30659 -static struct of_pdt_ops prom_olpc_ops __initdata = {
30660 +static struct of_pdt_ops prom_olpc_ops __initconst = {
30661 .nextprop = olpc_dt_nextprop,
30662 .getproplen = olpc_dt_getproplen,
30663 .getproperty = olpc_dt_getproperty,
30664 diff --git a/arch/x86/power/cpu.c b/arch/x86/power/cpu.c
30665 index 3c68768..07e82b8 100644
30666 --- a/arch/x86/power/cpu.c
30667 +++ b/arch/x86/power/cpu.c
30668 @@ -134,7 +134,7 @@ static void do_fpu_end(void)
30669 static void fix_processor_context(void)
30670 {
30671 int cpu = smp_processor_id();
30672 - struct tss_struct *t = &per_cpu(init_tss, cpu);
30673 + struct tss_struct *t = init_tss + cpu;
30674
30675 set_tss_desc(cpu, t); /*
30676 * This just modifies memory; should not be
30677 @@ -144,8 +144,6 @@ static void fix_processor_context(void)
30678 */
30679
30680 #ifdef CONFIG_X86_64
30681 - get_cpu_gdt_table(cpu)[GDT_ENTRY_TSS].type = 9;
30682 -
30683 syscall_init(); /* This sets MSR_*STAR and related */
30684 #endif
30685 load_TR_desc(); /* This does ltr */
30686 diff --git a/arch/x86/realmode/init.c b/arch/x86/realmode/init.c
30687 index a44f457..9140171 100644
30688 --- a/arch/x86/realmode/init.c
30689 +++ b/arch/x86/realmode/init.c
30690 @@ -70,7 +70,13 @@ void __init setup_real_mode(void)
30691 __va(real_mode_header->trampoline_header);
30692
30693 #ifdef CONFIG_X86_32
30694 - trampoline_header->start = __pa_symbol(startup_32_smp);
30695 + trampoline_header->start = __pa_symbol(ktla_ktva(startup_32_smp));
30696 +
30697 +#ifdef CONFIG_PAX_KERNEXEC
30698 + trampoline_header->start -= LOAD_PHYSICAL_ADDR;
30699 +#endif
30700 +
30701 + trampoline_header->boot_cs = __BOOT_CS;
30702 trampoline_header->gdt_limit = __BOOT_DS + 7;
30703 trampoline_header->gdt_base = __pa_symbol(boot_gdt);
30704 #else
30705 @@ -86,7 +92,7 @@ void __init setup_real_mode(void)
30706 *trampoline_cr4_features = read_cr4();
30707
30708 trampoline_pgd = (u64 *) __va(real_mode_header->trampoline_pgd);
30709 - trampoline_pgd[0] = init_level4_pgt[pgd_index(__PAGE_OFFSET)].pgd;
30710 + trampoline_pgd[0] = init_level4_pgt[pgd_index(__PAGE_OFFSET)].pgd & ~_PAGE_NX;
30711 trampoline_pgd[511] = init_level4_pgt[511].pgd;
30712 #endif
30713 }
30714 diff --git a/arch/x86/realmode/rm/Makefile b/arch/x86/realmode/rm/Makefile
30715 index 8869287..d577672 100644
30716 --- a/arch/x86/realmode/rm/Makefile
30717 +++ b/arch/x86/realmode/rm/Makefile
30718 @@ -78,5 +78,8 @@ KBUILD_CFLAGS := $(LINUXINCLUDE) -m32 -g -Os -D_SETUP -D__KERNEL__ -D_WAKEUP \
30719 $(call cc-option, -fno-unit-at-a-time)) \
30720 $(call cc-option, -fno-stack-protector) \
30721 $(call cc-option, -mpreferred-stack-boundary=2)
30722 +ifdef CONSTIFY_PLUGIN
30723 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
30724 +endif
30725 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
30726 GCOV_PROFILE := n
30727 diff --git a/arch/x86/realmode/rm/header.S b/arch/x86/realmode/rm/header.S
30728 index a28221d..93c40f1 100644
30729 --- a/arch/x86/realmode/rm/header.S
30730 +++ b/arch/x86/realmode/rm/header.S
30731 @@ -30,7 +30,9 @@ GLOBAL(real_mode_header)
30732 #endif
30733 /* APM/BIOS reboot */
30734 .long pa_machine_real_restart_asm
30735 -#ifdef CONFIG_X86_64
30736 +#ifdef CONFIG_X86_32
30737 + .long __KERNEL_CS
30738 +#else
30739 .long __KERNEL32_CS
30740 #endif
30741 END(real_mode_header)
30742 diff --git a/arch/x86/realmode/rm/trampoline_32.S b/arch/x86/realmode/rm/trampoline_32.S
30743 index c1b2791..f9e31c7 100644
30744 --- a/arch/x86/realmode/rm/trampoline_32.S
30745 +++ b/arch/x86/realmode/rm/trampoline_32.S
30746 @@ -25,6 +25,12 @@
30747 #include <asm/page_types.h>
30748 #include "realmode.h"
30749
30750 +#ifdef CONFIG_PAX_KERNEXEC
30751 +#define ta(X) (X)
30752 +#else
30753 +#define ta(X) (pa_ ## X)
30754 +#endif
30755 +
30756 .text
30757 .code16
30758
30759 @@ -39,8 +45,6 @@ ENTRY(trampoline_start)
30760
30761 cli # We should be safe anyway
30762
30763 - movl tr_start, %eax # where we need to go
30764 -
30765 movl $0xA5A5A5A5, trampoline_status
30766 # write marker for master knows we're running
30767
30768 @@ -56,7 +60,7 @@ ENTRY(trampoline_start)
30769 movw $1, %dx # protected mode (PE) bit
30770 lmsw %dx # into protected mode
30771
30772 - ljmpl $__BOOT_CS, $pa_startup_32
30773 + ljmpl *(trampoline_header)
30774
30775 .section ".text32","ax"
30776 .code32
30777 @@ -67,7 +71,7 @@ ENTRY(startup_32) # note: also used from wakeup_asm.S
30778 .balign 8
30779 GLOBAL(trampoline_header)
30780 tr_start: .space 4
30781 - tr_gdt_pad: .space 2
30782 + tr_boot_cs: .space 2
30783 tr_gdt: .space 6
30784 END(trampoline_header)
30785
30786 diff --git a/arch/x86/realmode/rm/trampoline_64.S b/arch/x86/realmode/rm/trampoline_64.S
30787 index bb360dc..3e5945f 100644
30788 --- a/arch/x86/realmode/rm/trampoline_64.S
30789 +++ b/arch/x86/realmode/rm/trampoline_64.S
30790 @@ -107,7 +107,7 @@ ENTRY(startup_32)
30791 wrmsr
30792
30793 # Enable paging and in turn activate Long Mode
30794 - movl $(X86_CR0_PG | X86_CR0_WP | X86_CR0_PE), %eax
30795 + movl $(X86_CR0_PG | X86_CR0_PE), %eax
30796 movl %eax, %cr0
30797
30798 /*
30799 diff --git a/arch/x86/tools/relocs.c b/arch/x86/tools/relocs.c
30800 index 79d67bd..c7e1b90 100644
30801 --- a/arch/x86/tools/relocs.c
30802 +++ b/arch/x86/tools/relocs.c
30803 @@ -12,10 +12,13 @@
30804 #include <regex.h>
30805 #include <tools/le_byteshift.h>
30806
30807 +#include "../../../include/generated/autoconf.h"
30808 +
30809 static void die(char *fmt, ...);
30810
30811 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
30812 static Elf32_Ehdr ehdr;
30813 +static Elf32_Phdr *phdr;
30814 static unsigned long reloc_count, reloc_idx;
30815 static unsigned long *relocs;
30816 static unsigned long reloc16_count, reloc16_idx;
30817 @@ -330,9 +333,39 @@ static void read_ehdr(FILE *fp)
30818 }
30819 }
30820
30821 +static void read_phdrs(FILE *fp)
30822 +{
30823 + unsigned int i;
30824 +
30825 + phdr = calloc(ehdr.e_phnum, sizeof(Elf32_Phdr));
30826 + if (!phdr) {
30827 + die("Unable to allocate %d program headers\n",
30828 + ehdr.e_phnum);
30829 + }
30830 + if (fseek(fp, ehdr.e_phoff, SEEK_SET) < 0) {
30831 + die("Seek to %d failed: %s\n",
30832 + ehdr.e_phoff, strerror(errno));
30833 + }
30834 + if (fread(phdr, sizeof(*phdr), ehdr.e_phnum, fp) != ehdr.e_phnum) {
30835 + die("Cannot read ELF program headers: %s\n",
30836 + strerror(errno));
30837 + }
30838 + for(i = 0; i < ehdr.e_phnum; i++) {
30839 + phdr[i].p_type = elf32_to_cpu(phdr[i].p_type);
30840 + phdr[i].p_offset = elf32_to_cpu(phdr[i].p_offset);
30841 + phdr[i].p_vaddr = elf32_to_cpu(phdr[i].p_vaddr);
30842 + phdr[i].p_paddr = elf32_to_cpu(phdr[i].p_paddr);
30843 + phdr[i].p_filesz = elf32_to_cpu(phdr[i].p_filesz);
30844 + phdr[i].p_memsz = elf32_to_cpu(phdr[i].p_memsz);
30845 + phdr[i].p_flags = elf32_to_cpu(phdr[i].p_flags);
30846 + phdr[i].p_align = elf32_to_cpu(phdr[i].p_align);
30847 + }
30848 +
30849 +}
30850 +
30851 static void read_shdrs(FILE *fp)
30852 {
30853 - int i;
30854 + unsigned int i;
30855 Elf32_Shdr shdr;
30856
30857 secs = calloc(ehdr.e_shnum, sizeof(struct section));
30858 @@ -367,7 +400,7 @@ static void read_shdrs(FILE *fp)
30859
30860 static void read_strtabs(FILE *fp)
30861 {
30862 - int i;
30863 + unsigned int i;
30864 for (i = 0; i < ehdr.e_shnum; i++) {
30865 struct section *sec = &secs[i];
30866 if (sec->shdr.sh_type != SHT_STRTAB) {
30867 @@ -392,7 +425,7 @@ static void read_strtabs(FILE *fp)
30868
30869 static void read_symtabs(FILE *fp)
30870 {
30871 - int i,j;
30872 + unsigned int i,j;
30873 for (i = 0; i < ehdr.e_shnum; i++) {
30874 struct section *sec = &secs[i];
30875 if (sec->shdr.sh_type != SHT_SYMTAB) {
30876 @@ -423,9 +456,11 @@ static void read_symtabs(FILE *fp)
30877 }
30878
30879
30880 -static void read_relocs(FILE *fp)
30881 +static void read_relocs(FILE *fp, int use_real_mode)
30882 {
30883 - int i,j;
30884 + unsigned int i,j;
30885 + uint32_t base;
30886 +
30887 for (i = 0; i < ehdr.e_shnum; i++) {
30888 struct section *sec = &secs[i];
30889 if (sec->shdr.sh_type != SHT_REL) {
30890 @@ -445,9 +480,22 @@ static void read_relocs(FILE *fp)
30891 die("Cannot read symbol table: %s\n",
30892 strerror(errno));
30893 }
30894 + base = 0;
30895 +
30896 +#ifdef CONFIG_X86_32
30897 + for (j = 0; !use_real_mode && j < ehdr.e_phnum; j++) {
30898 + if (phdr[j].p_type != PT_LOAD )
30899 + continue;
30900 + 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)
30901 + continue;
30902 + base = CONFIG_PAGE_OFFSET + phdr[j].p_paddr - phdr[j].p_vaddr;
30903 + break;
30904 + }
30905 +#endif
30906 +
30907 for (j = 0; j < sec->shdr.sh_size/sizeof(Elf32_Rel); j++) {
30908 Elf32_Rel *rel = &sec->reltab[j];
30909 - rel->r_offset = elf32_to_cpu(rel->r_offset);
30910 + rel->r_offset = elf32_to_cpu(rel->r_offset) + base;
30911 rel->r_info = elf32_to_cpu(rel->r_info);
30912 }
30913 }
30914 @@ -456,13 +504,13 @@ static void read_relocs(FILE *fp)
30915
30916 static void print_absolute_symbols(void)
30917 {
30918 - int i;
30919 + unsigned int i;
30920 printf("Absolute symbols\n");
30921 printf(" Num: Value Size Type Bind Visibility Name\n");
30922 for (i = 0; i < ehdr.e_shnum; i++) {
30923 struct section *sec = &secs[i];
30924 char *sym_strtab;
30925 - int j;
30926 + unsigned int j;
30927
30928 if (sec->shdr.sh_type != SHT_SYMTAB) {
30929 continue;
30930 @@ -489,14 +537,14 @@ static void print_absolute_symbols(void)
30931
30932 static void print_absolute_relocs(void)
30933 {
30934 - int i, printed = 0;
30935 + unsigned int i, printed = 0;
30936
30937 for (i = 0; i < ehdr.e_shnum; i++) {
30938 struct section *sec = &secs[i];
30939 struct section *sec_applies, *sec_symtab;
30940 char *sym_strtab;
30941 Elf32_Sym *sh_symtab;
30942 - int j;
30943 + unsigned int j;
30944 if (sec->shdr.sh_type != SHT_REL) {
30945 continue;
30946 }
30947 @@ -558,13 +606,13 @@ static void print_absolute_relocs(void)
30948 static void walk_relocs(void (*visit)(Elf32_Rel *rel, Elf32_Sym *sym),
30949 int use_real_mode)
30950 {
30951 - int i;
30952 + unsigned int i;
30953 /* Walk through the relocations */
30954 for (i = 0; i < ehdr.e_shnum; i++) {
30955 char *sym_strtab;
30956 Elf32_Sym *sh_symtab;
30957 struct section *sec_applies, *sec_symtab;
30958 - int j;
30959 + unsigned int j;
30960 struct section *sec = &secs[i];
30961
30962 if (sec->shdr.sh_type != SHT_REL) {
30963 @@ -588,6 +636,24 @@ static void walk_relocs(void (*visit)(Elf32_Rel *rel, Elf32_Sym *sym),
30964 sym = &sh_symtab[ELF32_R_SYM(rel->r_info)];
30965 r_type = ELF32_R_TYPE(rel->r_info);
30966
30967 + if (!use_real_mode) {
30968 + /* Don't relocate actual per-cpu variables, they are absolute indices, not addresses */
30969 + if (!strcmp(sec_name(sym->st_shndx), ".data..percpu") && strcmp(sym_name(sym_strtab, sym), "__per_cpu_load"))
30970 + continue;
30971 +
30972 +#if defined(CONFIG_PAX_KERNEXEC) && defined(CONFIG_X86_32)
30973 + /* Don't relocate actual code, they are relocated implicitly by the base address of KERNEL_CS */
30974 + if (!strcmp(sec_name(sym->st_shndx), ".text.end") && !strcmp(sym_name(sym_strtab, sym), "_etext"))
30975 + continue;
30976 + if (!strcmp(sec_name(sym->st_shndx), ".init.text"))
30977 + continue;
30978 + if (!strcmp(sec_name(sym->st_shndx), ".exit.text"))
30979 + continue;
30980 + if (!strcmp(sec_name(sym->st_shndx), ".text") && strcmp(sym_name(sym_strtab, sym), "__LOAD_PHYSICAL_ADDR"))
30981 + continue;
30982 +#endif
30983 + }
30984 +
30985 shn_abs = sym->st_shndx == SHN_ABS;
30986
30987 switch (r_type) {
30988 @@ -681,7 +747,7 @@ static int write32(unsigned int v, FILE *f)
30989
30990 static void emit_relocs(int as_text, int use_real_mode)
30991 {
30992 - int i;
30993 + unsigned int i;
30994 /* Count how many relocations I have and allocate space for them. */
30995 reloc_count = 0;
30996 walk_relocs(count_reloc, use_real_mode);
30997 @@ -808,10 +874,11 @@ int main(int argc, char **argv)
30998 fname, strerror(errno));
30999 }
31000 read_ehdr(fp);
31001 + read_phdrs(fp);
31002 read_shdrs(fp);
31003 read_strtabs(fp);
31004 read_symtabs(fp);
31005 - read_relocs(fp);
31006 + read_relocs(fp, use_real_mode);
31007 if (show_absolute_syms) {
31008 print_absolute_symbols();
31009 goto out;
31010 diff --git a/arch/x86/vdso/Makefile b/arch/x86/vdso/Makefile
31011 index fd14be1..e3c79c0 100644
31012 --- a/arch/x86/vdso/Makefile
31013 +++ b/arch/x86/vdso/Makefile
31014 @@ -181,7 +181,7 @@ quiet_cmd_vdso = VDSO $@
31015 -Wl,-T,$(filter %.lds,$^) $(filter %.o,$^) && \
31016 sh $(srctree)/$(src)/checkundef.sh '$(NM)' '$@'
31017
31018 -VDSO_LDFLAGS = -fPIC -shared $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
31019 +VDSO_LDFLAGS = -fPIC -shared -Wl,--no-undefined $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
31020 GCOV_PROFILE := n
31021
31022 #
31023 diff --git a/arch/x86/vdso/vdso32-setup.c b/arch/x86/vdso/vdso32-setup.c
31024 index 0faad64..39ef157 100644
31025 --- a/arch/x86/vdso/vdso32-setup.c
31026 +++ b/arch/x86/vdso/vdso32-setup.c
31027 @@ -25,6 +25,7 @@
31028 #include <asm/tlbflush.h>
31029 #include <asm/vdso.h>
31030 #include <asm/proto.h>
31031 +#include <asm/mman.h>
31032
31033 enum {
31034 VDSO_DISABLED = 0,
31035 @@ -226,7 +227,7 @@ static inline void map_compat_vdso(int map)
31036 void enable_sep_cpu(void)
31037 {
31038 int cpu = get_cpu();
31039 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
31040 + struct tss_struct *tss = init_tss + cpu;
31041
31042 if (!boot_cpu_has(X86_FEATURE_SEP)) {
31043 put_cpu();
31044 @@ -249,7 +250,7 @@ static int __init gate_vma_init(void)
31045 gate_vma.vm_start = FIXADDR_USER_START;
31046 gate_vma.vm_end = FIXADDR_USER_END;
31047 gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;
31048 - gate_vma.vm_page_prot = __P101;
31049 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
31050
31051 return 0;
31052 }
31053 @@ -330,14 +331,14 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
31054 if (compat)
31055 addr = VDSO_HIGH_BASE;
31056 else {
31057 - addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, 0);
31058 + addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, MAP_EXECUTABLE);
31059 if (IS_ERR_VALUE(addr)) {
31060 ret = addr;
31061 goto up_fail;
31062 }
31063 }
31064
31065 - current->mm->context.vdso = (void *)addr;
31066 + current->mm->context.vdso = addr;
31067
31068 if (compat_uses_vma || !compat) {
31069 /*
31070 @@ -353,11 +354,11 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
31071 }
31072
31073 current_thread_info()->sysenter_return =
31074 - VDSO32_SYMBOL(addr, SYSENTER_RETURN);
31075 + (__force void __user *)VDSO32_SYMBOL(addr, SYSENTER_RETURN);
31076
31077 up_fail:
31078 if (ret)
31079 - current->mm->context.vdso = NULL;
31080 + current->mm->context.vdso = 0;
31081
31082 up_write(&mm->mmap_sem);
31083
31084 @@ -404,8 +405,14 @@ __initcall(ia32_binfmt_init);
31085
31086 const char *arch_vma_name(struct vm_area_struct *vma)
31087 {
31088 - if (vma->vm_mm && vma->vm_start == (long)vma->vm_mm->context.vdso)
31089 + if (vma->vm_mm && vma->vm_start == vma->vm_mm->context.vdso)
31090 return "[vdso]";
31091 +
31092 +#ifdef CONFIG_PAX_SEGMEXEC
31093 + if (vma->vm_mm && vma->vm_mirror && vma->vm_mirror->vm_start == vma->vm_mm->context.vdso)
31094 + return "[vdso]";
31095 +#endif
31096 +
31097 return NULL;
31098 }
31099
31100 @@ -415,7 +422,7 @@ struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
31101 * Check to see if the corresponding task was created in compat vdso
31102 * mode.
31103 */
31104 - if (mm && mm->context.vdso == (void *)VDSO_HIGH_BASE)
31105 + if (mm && mm->context.vdso == VDSO_HIGH_BASE)
31106 return &gate_vma;
31107 return NULL;
31108 }
31109 diff --git a/arch/x86/vdso/vma.c b/arch/x86/vdso/vma.c
31110 index 431e875..cbb23f3 100644
31111 --- a/arch/x86/vdso/vma.c
31112 +++ b/arch/x86/vdso/vma.c
31113 @@ -16,8 +16,6 @@
31114 #include <asm/vdso.h>
31115 #include <asm/page.h>
31116
31117 -unsigned int __read_mostly vdso_enabled = 1;
31118 -
31119 extern char vdso_start[], vdso_end[];
31120 extern unsigned short vdso_sync_cpuid;
31121
31122 @@ -141,7 +139,6 @@ static unsigned long vdso_addr(unsigned long start, unsigned len)
31123 * unaligned here as a result of stack start randomization.
31124 */
31125 addr = PAGE_ALIGN(addr);
31126 - addr = align_vdso_addr(addr);
31127
31128 return addr;
31129 }
31130 @@ -154,30 +151,31 @@ static int setup_additional_pages(struct linux_binprm *bprm,
31131 unsigned size)
31132 {
31133 struct mm_struct *mm = current->mm;
31134 - unsigned long addr;
31135 + unsigned long addr = 0;
31136 int ret;
31137
31138 - if (!vdso_enabled)
31139 - return 0;
31140 -
31141 down_write(&mm->mmap_sem);
31142 +
31143 +#ifdef CONFIG_PAX_RANDMMAP
31144 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
31145 +#endif
31146 +
31147 addr = vdso_addr(mm->start_stack, size);
31148 + addr = align_vdso_addr(addr);
31149 addr = get_unmapped_area(NULL, addr, size, 0, 0);
31150 if (IS_ERR_VALUE(addr)) {
31151 ret = addr;
31152 goto up_fail;
31153 }
31154
31155 - current->mm->context.vdso = (void *)addr;
31156 + mm->context.vdso = addr;
31157
31158 ret = install_special_mapping(mm, addr, size,
31159 VM_READ|VM_EXEC|
31160 VM_MAYREAD|VM_MAYWRITE|VM_MAYEXEC,
31161 pages);
31162 - if (ret) {
31163 - current->mm->context.vdso = NULL;
31164 - goto up_fail;
31165 - }
31166 + if (ret)
31167 + mm->context.vdso = 0;
31168
31169 up_fail:
31170 up_write(&mm->mmap_sem);
31171 @@ -197,10 +195,3 @@ int x32_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
31172 vdsox32_size);
31173 }
31174 #endif
31175 -
31176 -static __init int vdso_setup(char *s)
31177 -{
31178 - vdso_enabled = simple_strtoul(s, NULL, 0);
31179 - return 0;
31180 -}
31181 -__setup("vdso=", vdso_setup);
31182 diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
31183 index cf95e19..17e9f50 100644
31184 --- a/arch/x86/xen/enlighten.c
31185 +++ b/arch/x86/xen/enlighten.c
31186 @@ -100,8 +100,6 @@ EXPORT_SYMBOL_GPL(xen_start_info);
31187
31188 struct shared_info xen_dummy_shared_info;
31189
31190 -void *xen_initial_gdt;
31191 -
31192 RESERVE_BRK(shared_info_page_brk, PAGE_SIZE);
31193 __read_mostly int xen_have_vector_callback;
31194 EXPORT_SYMBOL_GPL(xen_have_vector_callback);
31195 @@ -511,8 +509,7 @@ static void xen_load_gdt(const struct desc_ptr *dtr)
31196 {
31197 unsigned long va = dtr->address;
31198 unsigned int size = dtr->size + 1;
31199 - unsigned pages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
31200 - unsigned long frames[pages];
31201 + unsigned long frames[65536 / PAGE_SIZE];
31202 int f;
31203
31204 /*
31205 @@ -560,8 +557,7 @@ static void __init xen_load_gdt_boot(const struct desc_ptr *dtr)
31206 {
31207 unsigned long va = dtr->address;
31208 unsigned int size = dtr->size + 1;
31209 - unsigned pages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
31210 - unsigned long frames[pages];
31211 + unsigned long frames[(GDT_SIZE + PAGE_SIZE - 1) / PAGE_SIZE];
31212 int f;
31213
31214 /*
31215 @@ -569,7 +565,7 @@ static void __init xen_load_gdt_boot(const struct desc_ptr *dtr)
31216 * 8-byte entries, or 16 4k pages..
31217 */
31218
31219 - BUG_ON(size > 65536);
31220 + BUG_ON(size > GDT_SIZE);
31221 BUG_ON(va & ~PAGE_MASK);
31222
31223 for (f = 0; va < dtr->address + size; va += PAGE_SIZE, f++) {
31224 @@ -954,7 +950,7 @@ static u32 xen_safe_apic_wait_icr_idle(void)
31225 return 0;
31226 }
31227
31228 -static void set_xen_basic_apic_ops(void)
31229 +static void __init set_xen_basic_apic_ops(void)
31230 {
31231 apic->read = xen_apic_read;
31232 apic->write = xen_apic_write;
31233 @@ -1260,30 +1256,30 @@ static const struct pv_apic_ops xen_apic_ops __initconst = {
31234 #endif
31235 };
31236
31237 -static void xen_reboot(int reason)
31238 +static __noreturn void xen_reboot(int reason)
31239 {
31240 struct sched_shutdown r = { .reason = reason };
31241
31242 - if (HYPERVISOR_sched_op(SCHEDOP_shutdown, &r))
31243 - BUG();
31244 + HYPERVISOR_sched_op(SCHEDOP_shutdown, &r);
31245 + BUG();
31246 }
31247
31248 -static void xen_restart(char *msg)
31249 +static __noreturn void xen_restart(char *msg)
31250 {
31251 xen_reboot(SHUTDOWN_reboot);
31252 }
31253
31254 -static void xen_emergency_restart(void)
31255 +static __noreturn void xen_emergency_restart(void)
31256 {
31257 xen_reboot(SHUTDOWN_reboot);
31258 }
31259
31260 -static void xen_machine_halt(void)
31261 +static __noreturn void xen_machine_halt(void)
31262 {
31263 xen_reboot(SHUTDOWN_poweroff);
31264 }
31265
31266 -static void xen_machine_power_off(void)
31267 +static __noreturn void xen_machine_power_off(void)
31268 {
31269 if (pm_power_off)
31270 pm_power_off();
31271 @@ -1385,7 +1381,17 @@ asmlinkage void __init xen_start_kernel(void)
31272 __userpte_alloc_gfp &= ~__GFP_HIGHMEM;
31273
31274 /* Work out if we support NX */
31275 - x86_configure_nx();
31276 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
31277 + if ((cpuid_eax(0x80000000) & 0xffff0000) == 0x80000000 &&
31278 + (cpuid_edx(0x80000001) & (1U << (X86_FEATURE_NX & 31)))) {
31279 + unsigned l, h;
31280 +
31281 + __supported_pte_mask |= _PAGE_NX;
31282 + rdmsr(MSR_EFER, l, h);
31283 + l |= EFER_NX;
31284 + wrmsr(MSR_EFER, l, h);
31285 + }
31286 +#endif
31287
31288 xen_setup_features();
31289
31290 @@ -1416,13 +1422,6 @@ asmlinkage void __init xen_start_kernel(void)
31291
31292 machine_ops = xen_machine_ops;
31293
31294 - /*
31295 - * The only reliable way to retain the initial address of the
31296 - * percpu gdt_page is to remember it here, so we can go and
31297 - * mark it RW later, when the initial percpu area is freed.
31298 - */
31299 - xen_initial_gdt = &per_cpu(gdt_page, 0);
31300 -
31301 xen_smp_init();
31302
31303 #ifdef CONFIG_ACPI_NUMA
31304 @@ -1616,7 +1615,7 @@ static int __cpuinit xen_hvm_cpu_notify(struct notifier_block *self,
31305 return NOTIFY_OK;
31306 }
31307
31308 -static struct notifier_block xen_hvm_cpu_notifier __cpuinitdata = {
31309 +static struct notifier_block xen_hvm_cpu_notifier = {
31310 .notifier_call = xen_hvm_cpu_notify,
31311 };
31312
31313 diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
31314 index e006c18..b9a7d6c 100644
31315 --- a/arch/x86/xen/mmu.c
31316 +++ b/arch/x86/xen/mmu.c
31317 @@ -1894,6 +1894,9 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
31318 /* L3_k[510] -> level2_kernel_pgt
31319 * L3_i[511] -> level2_fixmap_pgt */
31320 convert_pfn_mfn(level3_kernel_pgt);
31321 + convert_pfn_mfn(level3_vmalloc_start_pgt);
31322 + convert_pfn_mfn(level3_vmalloc_end_pgt);
31323 + convert_pfn_mfn(level3_vmemmap_pgt);
31324
31325 /* We get [511][511] and have Xen's version of level2_kernel_pgt */
31326 l3 = m2v(pgd[pgd_index(__START_KERNEL_map)].pgd);
31327 @@ -1923,8 +1926,12 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
31328 set_page_prot(init_level4_pgt, PAGE_KERNEL_RO);
31329 set_page_prot(level3_ident_pgt, PAGE_KERNEL_RO);
31330 set_page_prot(level3_kernel_pgt, PAGE_KERNEL_RO);
31331 + set_page_prot(level3_vmalloc_start_pgt, PAGE_KERNEL_RO);
31332 + set_page_prot(level3_vmalloc_end_pgt, PAGE_KERNEL_RO);
31333 + set_page_prot(level3_vmemmap_pgt, PAGE_KERNEL_RO);
31334 set_page_prot(level3_user_vsyscall, PAGE_KERNEL_RO);
31335 set_page_prot(level2_ident_pgt, PAGE_KERNEL_RO);
31336 + set_page_prot(level2_vmemmap_pgt, PAGE_KERNEL_RO);
31337 set_page_prot(level2_kernel_pgt, PAGE_KERNEL_RO);
31338 set_page_prot(level2_fixmap_pgt, PAGE_KERNEL_RO);
31339
31340 @@ -2110,6 +2117,7 @@ static void __init xen_post_allocator_init(void)
31341 pv_mmu_ops.set_pud = xen_set_pud;
31342 #if PAGETABLE_LEVELS == 4
31343 pv_mmu_ops.set_pgd = xen_set_pgd;
31344 + pv_mmu_ops.set_pgd_batched = xen_set_pgd;
31345 #endif
31346
31347 /* This will work as long as patching hasn't happened yet
31348 @@ -2188,6 +2196,7 @@ static const struct pv_mmu_ops xen_mmu_ops __initconst = {
31349 .pud_val = PV_CALLEE_SAVE(xen_pud_val),
31350 .make_pud = PV_CALLEE_SAVE(xen_make_pud),
31351 .set_pgd = xen_set_pgd_hyper,
31352 + .set_pgd_batched = xen_set_pgd_hyper,
31353
31354 .alloc_pud = xen_alloc_pmd_init,
31355 .release_pud = xen_release_pmd_init,
31356 diff --git a/arch/x86/xen/smp.c b/arch/x86/xen/smp.c
31357 index 22c800a..8915f1e 100644
31358 --- a/arch/x86/xen/smp.c
31359 +++ b/arch/x86/xen/smp.c
31360 @@ -229,11 +229,6 @@ static void __init xen_smp_prepare_boot_cpu(void)
31361 {
31362 BUG_ON(smp_processor_id() != 0);
31363 native_smp_prepare_boot_cpu();
31364 -
31365 - /* We've switched to the "real" per-cpu gdt, so make sure the
31366 - old memory can be recycled */
31367 - make_lowmem_page_readwrite(xen_initial_gdt);
31368 -
31369 xen_filter_cpu_maps();
31370 xen_setup_vcpu_info_placement();
31371 }
31372 @@ -303,7 +298,7 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle)
31373 ctxt->user_regs.ss = __KERNEL_DS;
31374 #ifdef CONFIG_X86_32
31375 ctxt->user_regs.fs = __KERNEL_PERCPU;
31376 - ctxt->user_regs.gs = __KERNEL_STACK_CANARY;
31377 + savesegment(gs, ctxt->user_regs.gs);
31378 #else
31379 ctxt->gs_base_kernel = per_cpu_offset(cpu);
31380 #endif
31381 @@ -313,8 +308,8 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle)
31382
31383 {
31384 ctxt->user_regs.eflags = 0x1000; /* IOPL_RING1 */
31385 - ctxt->user_regs.ds = __USER_DS;
31386 - ctxt->user_regs.es = __USER_DS;
31387 + ctxt->user_regs.ds = __KERNEL_DS;
31388 + ctxt->user_regs.es = __KERNEL_DS;
31389
31390 xen_copy_trap_info(ctxt->trap_ctxt);
31391
31392 @@ -359,13 +354,12 @@ static int __cpuinit xen_cpu_up(unsigned int cpu, struct task_struct *idle)
31393 int rc;
31394
31395 per_cpu(current_task, cpu) = idle;
31396 + per_cpu(current_tinfo, cpu) = &idle->tinfo;
31397 #ifdef CONFIG_X86_32
31398 irq_ctx_init(cpu);
31399 #else
31400 clear_tsk_thread_flag(idle, TIF_FORK);
31401 - per_cpu(kernel_stack, cpu) =
31402 - (unsigned long)task_stack_page(idle) -
31403 - KERNEL_STACK_OFFSET + THREAD_SIZE;
31404 + per_cpu(kernel_stack, cpu) = (unsigned long)task_stack_page(idle) - 16 + THREAD_SIZE;
31405 #endif
31406 xen_setup_runstate_info(cpu);
31407 xen_setup_timer(cpu);
31408 @@ -634,7 +628,7 @@ static const struct smp_ops xen_smp_ops __initconst = {
31409
31410 void __init xen_smp_init(void)
31411 {
31412 - smp_ops = xen_smp_ops;
31413 + memcpy((void *)&smp_ops, &xen_smp_ops, sizeof smp_ops);
31414 xen_fill_possible_map();
31415 xen_init_spinlocks();
31416 }
31417 diff --git a/arch/x86/xen/xen-asm_32.S b/arch/x86/xen/xen-asm_32.S
31418 index 33ca6e4..0ded929 100644
31419 --- a/arch/x86/xen/xen-asm_32.S
31420 +++ b/arch/x86/xen/xen-asm_32.S
31421 @@ -84,14 +84,14 @@ ENTRY(xen_iret)
31422 ESP_OFFSET=4 # bytes pushed onto stack
31423
31424 /*
31425 - * Store vcpu_info pointer for easy access. Do it this way to
31426 - * avoid having to reload %fs
31427 + * Store vcpu_info pointer for easy access.
31428 */
31429 #ifdef CONFIG_SMP
31430 - GET_THREAD_INFO(%eax)
31431 - movl %ss:TI_cpu(%eax), %eax
31432 - movl %ss:__per_cpu_offset(,%eax,4), %eax
31433 - mov %ss:xen_vcpu(%eax), %eax
31434 + push %fs
31435 + mov $(__KERNEL_PERCPU), %eax
31436 + mov %eax, %fs
31437 + mov PER_CPU_VAR(xen_vcpu), %eax
31438 + pop %fs
31439 #else
31440 movl %ss:xen_vcpu, %eax
31441 #endif
31442 diff --git a/arch/x86/xen/xen-head.S b/arch/x86/xen/xen-head.S
31443 index 7faed58..ba4427c 100644
31444 --- a/arch/x86/xen/xen-head.S
31445 +++ b/arch/x86/xen/xen-head.S
31446 @@ -19,6 +19,17 @@ ENTRY(startup_xen)
31447 #ifdef CONFIG_X86_32
31448 mov %esi,xen_start_info
31449 mov $init_thread_union+THREAD_SIZE,%esp
31450 +#ifdef CONFIG_SMP
31451 + movl $cpu_gdt_table,%edi
31452 + movl $__per_cpu_load,%eax
31453 + movw %ax,__KERNEL_PERCPU + 2(%edi)
31454 + rorl $16,%eax
31455 + movb %al,__KERNEL_PERCPU + 4(%edi)
31456 + movb %ah,__KERNEL_PERCPU + 7(%edi)
31457 + movl $__per_cpu_end - 1,%eax
31458 + subl $__per_cpu_start,%eax
31459 + movw %ax,__KERNEL_PERCPU + 0(%edi)
31460 +#endif
31461 #else
31462 mov %rsi,xen_start_info
31463 mov $init_thread_union+THREAD_SIZE,%rsp
31464 diff --git a/arch/x86/xen/xen-ops.h b/arch/x86/xen/xen-ops.h
31465 index a95b417..b6dbd0b 100644
31466 --- a/arch/x86/xen/xen-ops.h
31467 +++ b/arch/x86/xen/xen-ops.h
31468 @@ -10,8 +10,6 @@
31469 extern const char xen_hypervisor_callback[];
31470 extern const char xen_failsafe_callback[];
31471
31472 -extern void *xen_initial_gdt;
31473 -
31474 struct trap_info;
31475 void xen_copy_trap_info(struct trap_info *traps);
31476
31477 diff --git a/arch/xtensa/variants/dc232b/include/variant/core.h b/arch/xtensa/variants/dc232b/include/variant/core.h
31478 index 525bd3d..ef888b1 100644
31479 --- a/arch/xtensa/variants/dc232b/include/variant/core.h
31480 +++ b/arch/xtensa/variants/dc232b/include/variant/core.h
31481 @@ -119,9 +119,9 @@
31482 ----------------------------------------------------------------------*/
31483
31484 #define XCHAL_ICACHE_LINESIZE 32 /* I-cache line size in bytes */
31485 -#define XCHAL_DCACHE_LINESIZE 32 /* D-cache line size in bytes */
31486 #define XCHAL_ICACHE_LINEWIDTH 5 /* log2(I line size in bytes) */
31487 #define XCHAL_DCACHE_LINEWIDTH 5 /* log2(D line size in bytes) */
31488 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
31489
31490 #define XCHAL_ICACHE_SIZE 16384 /* I-cache size in bytes or 0 */
31491 #define XCHAL_DCACHE_SIZE 16384 /* D-cache size in bytes or 0 */
31492 diff --git a/arch/xtensa/variants/fsf/include/variant/core.h b/arch/xtensa/variants/fsf/include/variant/core.h
31493 index 2f33760..835e50a 100644
31494 --- a/arch/xtensa/variants/fsf/include/variant/core.h
31495 +++ b/arch/xtensa/variants/fsf/include/variant/core.h
31496 @@ -11,6 +11,7 @@
31497 #ifndef _XTENSA_CORE_H
31498 #define _XTENSA_CORE_H
31499
31500 +#include <linux/const.h>
31501
31502 /****************************************************************************
31503 Parameters Useful for Any Code, USER or PRIVILEGED
31504 @@ -112,9 +113,9 @@
31505 ----------------------------------------------------------------------*/
31506
31507 #define XCHAL_ICACHE_LINESIZE 16 /* I-cache line size in bytes */
31508 -#define XCHAL_DCACHE_LINESIZE 16 /* D-cache line size in bytes */
31509 #define XCHAL_ICACHE_LINEWIDTH 4 /* log2(I line size in bytes) */
31510 #define XCHAL_DCACHE_LINEWIDTH 4 /* log2(D line size in bytes) */
31511 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
31512
31513 #define XCHAL_ICACHE_SIZE 8192 /* I-cache size in bytes or 0 */
31514 #define XCHAL_DCACHE_SIZE 8192 /* D-cache size in bytes or 0 */
31515 diff --git a/arch/xtensa/variants/s6000/include/variant/core.h b/arch/xtensa/variants/s6000/include/variant/core.h
31516 index af00795..2bb8105 100644
31517 --- a/arch/xtensa/variants/s6000/include/variant/core.h
31518 +++ b/arch/xtensa/variants/s6000/include/variant/core.h
31519 @@ -11,6 +11,7 @@
31520 #ifndef _XTENSA_CORE_CONFIGURATION_H
31521 #define _XTENSA_CORE_CONFIGURATION_H
31522
31523 +#include <linux/const.h>
31524
31525 /****************************************************************************
31526 Parameters Useful for Any Code, USER or PRIVILEGED
31527 @@ -118,9 +119,9 @@
31528 ----------------------------------------------------------------------*/
31529
31530 #define XCHAL_ICACHE_LINESIZE 16 /* I-cache line size in bytes */
31531 -#define XCHAL_DCACHE_LINESIZE 16 /* D-cache line size in bytes */
31532 #define XCHAL_ICACHE_LINEWIDTH 4 /* log2(I line size in bytes) */
31533 #define XCHAL_DCACHE_LINEWIDTH 4 /* log2(D line size in bytes) */
31534 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
31535
31536 #define XCHAL_ICACHE_SIZE 32768 /* I-cache size in bytes or 0 */
31537 #define XCHAL_DCACHE_SIZE 32768 /* D-cache size in bytes or 0 */
31538 diff --git a/block/blk-iopoll.c b/block/blk-iopoll.c
31539 index 58916af..eb9dbcf6 100644
31540 --- a/block/blk-iopoll.c
31541 +++ b/block/blk-iopoll.c
31542 @@ -77,7 +77,7 @@ void blk_iopoll_complete(struct blk_iopoll *iopoll)
31543 }
31544 EXPORT_SYMBOL(blk_iopoll_complete);
31545
31546 -static void blk_iopoll_softirq(struct softirq_action *h)
31547 +static void blk_iopoll_softirq(void)
31548 {
31549 struct list_head *list = &__get_cpu_var(blk_cpu_iopoll);
31550 int rearm = 0, budget = blk_iopoll_budget;
31551 @@ -209,7 +209,7 @@ static int __cpuinit blk_iopoll_cpu_notify(struct notifier_block *self,
31552 return NOTIFY_OK;
31553 }
31554
31555 -static struct notifier_block __cpuinitdata blk_iopoll_cpu_notifier = {
31556 +static struct notifier_block blk_iopoll_cpu_notifier = {
31557 .notifier_call = blk_iopoll_cpu_notify,
31558 };
31559
31560 diff --git a/block/blk-map.c b/block/blk-map.c
31561 index 623e1cd..ca1e109 100644
31562 --- a/block/blk-map.c
31563 +++ b/block/blk-map.c
31564 @@ -302,7 +302,7 @@ int blk_rq_map_kern(struct request_queue *q, struct request *rq, void *kbuf,
31565 if (!len || !kbuf)
31566 return -EINVAL;
31567
31568 - do_copy = !blk_rq_aligned(q, addr, len) || object_is_on_stack(kbuf);
31569 + do_copy = !blk_rq_aligned(q, addr, len) || object_starts_on_stack(kbuf);
31570 if (do_copy)
31571 bio = bio_copy_kern(q, kbuf, len, gfp_mask, reading);
31572 else
31573 diff --git a/block/blk-softirq.c b/block/blk-softirq.c
31574 index 467c8de..f3628c5 100644
31575 --- a/block/blk-softirq.c
31576 +++ b/block/blk-softirq.c
31577 @@ -18,7 +18,7 @@ static DEFINE_PER_CPU(struct list_head, blk_cpu_done);
31578 * Softirq action handler - move entries to local list and loop over them
31579 * while passing them to the queue registered handler.
31580 */
31581 -static void blk_done_softirq(struct softirq_action *h)
31582 +static void blk_done_softirq(void)
31583 {
31584 struct list_head *cpu_list, local_list;
31585
31586 @@ -98,7 +98,7 @@ static int __cpuinit blk_cpu_notify(struct notifier_block *self,
31587 return NOTIFY_OK;
31588 }
31589
31590 -static struct notifier_block __cpuinitdata blk_cpu_notifier = {
31591 +static struct notifier_block blk_cpu_notifier = {
31592 .notifier_call = blk_cpu_notify,
31593 };
31594
31595 diff --git a/block/bsg.c b/block/bsg.c
31596 index 420a5a9..23834aa 100644
31597 --- a/block/bsg.c
31598 +++ b/block/bsg.c
31599 @@ -176,16 +176,24 @@ static int blk_fill_sgv4_hdr_rq(struct request_queue *q, struct request *rq,
31600 struct sg_io_v4 *hdr, struct bsg_device *bd,
31601 fmode_t has_write_perm)
31602 {
31603 + unsigned char tmpcmd[sizeof(rq->__cmd)];
31604 + unsigned char *cmdptr;
31605 +
31606 if (hdr->request_len > BLK_MAX_CDB) {
31607 rq->cmd = kzalloc(hdr->request_len, GFP_KERNEL);
31608 if (!rq->cmd)
31609 return -ENOMEM;
31610 - }
31611 + cmdptr = rq->cmd;
31612 + } else
31613 + cmdptr = tmpcmd;
31614
31615 - if (copy_from_user(rq->cmd, (void __user *)(unsigned long)hdr->request,
31616 + if (copy_from_user(cmdptr, (void __user *)(unsigned long)hdr->request,
31617 hdr->request_len))
31618 return -EFAULT;
31619
31620 + if (cmdptr != rq->cmd)
31621 + memcpy(rq->cmd, cmdptr, hdr->request_len);
31622 +
31623 if (hdr->subprotocol == BSG_SUB_PROTOCOL_SCSI_CMD) {
31624 if (blk_verify_command(rq->cmd, has_write_perm))
31625 return -EPERM;
31626 diff --git a/block/compat_ioctl.c b/block/compat_ioctl.c
31627 index 7c668c8..db3521c 100644
31628 --- a/block/compat_ioctl.c
31629 +++ b/block/compat_ioctl.c
31630 @@ -340,7 +340,7 @@ static int compat_fd_ioctl(struct block_device *bdev, fmode_t mode,
31631 err |= __get_user(f->spec1, &uf->spec1);
31632 err |= __get_user(f->fmt_gap, &uf->fmt_gap);
31633 err |= __get_user(name, &uf->name);
31634 - f->name = compat_ptr(name);
31635 + f->name = (void __force_kernel *)compat_ptr(name);
31636 if (err) {
31637 err = -EFAULT;
31638 goto out;
31639 diff --git a/block/partitions/efi.c b/block/partitions/efi.c
31640 index ff5804e..a88acad 100644
31641 --- a/block/partitions/efi.c
31642 +++ b/block/partitions/efi.c
31643 @@ -234,14 +234,14 @@ static gpt_entry *alloc_read_gpt_entries(struct parsed_partitions *state,
31644 if (!gpt)
31645 return NULL;
31646
31647 + if (!le32_to_cpu(gpt->num_partition_entries))
31648 + return NULL;
31649 + pte = kcalloc(le32_to_cpu(gpt->num_partition_entries), le32_to_cpu(gpt->sizeof_partition_entry), GFP_KERNEL);
31650 + if (!pte)
31651 + return NULL;
31652 +
31653 count = le32_to_cpu(gpt->num_partition_entries) *
31654 le32_to_cpu(gpt->sizeof_partition_entry);
31655 - if (!count)
31656 - return NULL;
31657 - pte = kzalloc(count, GFP_KERNEL);
31658 - if (!pte)
31659 - return NULL;
31660 -
31661 if (read_lba(state, le64_to_cpu(gpt->partition_entry_lba),
31662 (u8 *) pte,
31663 count) < count) {
31664 diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c
31665 index 9a87daa..fb17486 100644
31666 --- a/block/scsi_ioctl.c
31667 +++ b/block/scsi_ioctl.c
31668 @@ -223,8 +223,20 @@ EXPORT_SYMBOL(blk_verify_command);
31669 static int blk_fill_sghdr_rq(struct request_queue *q, struct request *rq,
31670 struct sg_io_hdr *hdr, fmode_t mode)
31671 {
31672 - if (copy_from_user(rq->cmd, hdr->cmdp, hdr->cmd_len))
31673 + unsigned char tmpcmd[sizeof(rq->__cmd)];
31674 + unsigned char *cmdptr;
31675 +
31676 + if (rq->cmd != rq->__cmd)
31677 + cmdptr = rq->cmd;
31678 + else
31679 + cmdptr = tmpcmd;
31680 +
31681 + if (copy_from_user(cmdptr, hdr->cmdp, hdr->cmd_len))
31682 return -EFAULT;
31683 +
31684 + if (cmdptr != rq->cmd)
31685 + memcpy(rq->cmd, cmdptr, hdr->cmd_len);
31686 +
31687 if (blk_verify_command(rq->cmd, mode & FMODE_WRITE))
31688 return -EPERM;
31689
31690 @@ -433,6 +445,8 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
31691 int err;
31692 unsigned int in_len, out_len, bytes, opcode, cmdlen;
31693 char *buffer = NULL, sense[SCSI_SENSE_BUFFERSIZE];
31694 + unsigned char tmpcmd[sizeof(rq->__cmd)];
31695 + unsigned char *cmdptr;
31696
31697 if (!sic)
31698 return -EINVAL;
31699 @@ -466,9 +480,18 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
31700 */
31701 err = -EFAULT;
31702 rq->cmd_len = cmdlen;
31703 - if (copy_from_user(rq->cmd, sic->data, cmdlen))
31704 +
31705 + if (rq->cmd != rq->__cmd)
31706 + cmdptr = rq->cmd;
31707 + else
31708 + cmdptr = tmpcmd;
31709 +
31710 + if (copy_from_user(cmdptr, sic->data, cmdlen))
31711 goto error;
31712
31713 + if (rq->cmd != cmdptr)
31714 + memcpy(rq->cmd, cmdptr, cmdlen);
31715 +
31716 if (in_len && copy_from_user(buffer, sic->data + cmdlen, in_len))
31717 goto error;
31718
31719 diff --git a/crypto/cryptd.c b/crypto/cryptd.c
31720 index 7bdd61b..afec999 100644
31721 --- a/crypto/cryptd.c
31722 +++ b/crypto/cryptd.c
31723 @@ -63,7 +63,7 @@ struct cryptd_blkcipher_ctx {
31724
31725 struct cryptd_blkcipher_request_ctx {
31726 crypto_completion_t complete;
31727 -};
31728 +} __no_const;
31729
31730 struct cryptd_hash_ctx {
31731 struct crypto_shash *child;
31732 @@ -80,7 +80,7 @@ struct cryptd_aead_ctx {
31733
31734 struct cryptd_aead_request_ctx {
31735 crypto_completion_t complete;
31736 -};
31737 +} __no_const;
31738
31739 static void cryptd_queue_worker(struct work_struct *work);
31740
31741 diff --git a/drivers/acpi/apei/apei-internal.h b/drivers/acpi/apei/apei-internal.h
31742 index f220d64..d359ad6 100644
31743 --- a/drivers/acpi/apei/apei-internal.h
31744 +++ b/drivers/acpi/apei/apei-internal.h
31745 @@ -20,7 +20,7 @@ typedef int (*apei_exec_ins_func_t)(struct apei_exec_context *ctx,
31746 struct apei_exec_ins_type {
31747 u32 flags;
31748 apei_exec_ins_func_t run;
31749 -};
31750 +} __do_const;
31751
31752 struct apei_exec_context {
31753 u32 ip;
31754 diff --git a/drivers/acpi/apei/cper.c b/drivers/acpi/apei/cper.c
31755 index fefc2ca..12a535d 100644
31756 --- a/drivers/acpi/apei/cper.c
31757 +++ b/drivers/acpi/apei/cper.c
31758 @@ -39,12 +39,12 @@
31759 */
31760 u64 cper_next_record_id(void)
31761 {
31762 - static atomic64_t seq;
31763 + static atomic64_unchecked_t seq;
31764
31765 - if (!atomic64_read(&seq))
31766 - atomic64_set(&seq, ((u64)get_seconds()) << 32);
31767 + if (!atomic64_read_unchecked(&seq))
31768 + atomic64_set_unchecked(&seq, ((u64)get_seconds()) << 32);
31769
31770 - return atomic64_inc_return(&seq);
31771 + return atomic64_inc_return_unchecked(&seq);
31772 }
31773 EXPORT_SYMBOL_GPL(cper_next_record_id);
31774
31775 diff --git a/drivers/acpi/bgrt.c b/drivers/acpi/bgrt.c
31776 index be60399..778b33e8 100644
31777 --- a/drivers/acpi/bgrt.c
31778 +++ b/drivers/acpi/bgrt.c
31779 @@ -87,8 +87,10 @@ static int __init bgrt_init(void)
31780 return -ENODEV;
31781
31782 sysfs_bin_attr_init(&image_attr);
31783 - image_attr.private = bgrt_image;
31784 - image_attr.size = bgrt_image_size;
31785 + pax_open_kernel();
31786 + *(void **)&image_attr.private = bgrt_image;
31787 + *(size_t *)&image_attr.size = bgrt_image_size;
31788 + pax_close_kernel();
31789
31790 bgrt_kobj = kobject_create_and_add("bgrt", acpi_kobj);
31791 if (!bgrt_kobj)
31792 diff --git a/drivers/acpi/blacklist.c b/drivers/acpi/blacklist.c
31793 index cb96296..b81293b 100644
31794 --- a/drivers/acpi/blacklist.c
31795 +++ b/drivers/acpi/blacklist.c
31796 @@ -52,7 +52,7 @@ struct acpi_blacklist_item {
31797 u32 is_critical_error;
31798 };
31799
31800 -static struct dmi_system_id acpi_osi_dmi_table[] __initdata;
31801 +static const struct dmi_system_id acpi_osi_dmi_table[] __initconst;
31802
31803 /*
31804 * POLICY: If *anything* doesn't work, put it on the blacklist.
31805 @@ -193,7 +193,7 @@ static int __init dmi_disable_osi_win7(const struct dmi_system_id *d)
31806 return 0;
31807 }
31808
31809 -static struct dmi_system_id acpi_osi_dmi_table[] __initdata = {
31810 +static const struct dmi_system_id acpi_osi_dmi_table[] __initconst = {
31811 {
31812 .callback = dmi_disable_osi_vista,
31813 .ident = "Fujitsu Siemens",
31814 diff --git a/drivers/acpi/ec_sys.c b/drivers/acpi/ec_sys.c
31815 index 7586544..636a2f0 100644
31816 --- a/drivers/acpi/ec_sys.c
31817 +++ b/drivers/acpi/ec_sys.c
31818 @@ -12,6 +12,7 @@
31819 #include <linux/acpi.h>
31820 #include <linux/debugfs.h>
31821 #include <linux/module.h>
31822 +#include <linux/uaccess.h>
31823 #include "internal.h"
31824
31825 MODULE_AUTHOR("Thomas Renninger <trenn@suse.de>");
31826 @@ -34,7 +35,7 @@ static ssize_t acpi_ec_read_io(struct file *f, char __user *buf,
31827 * struct acpi_ec *ec = ((struct seq_file *)f->private_data)->private;
31828 */
31829 unsigned int size = EC_SPACE_SIZE;
31830 - u8 *data = (u8 *) buf;
31831 + u8 data;
31832 loff_t init_off = *off;
31833 int err = 0;
31834
31835 @@ -47,9 +48,11 @@ static ssize_t acpi_ec_read_io(struct file *f, char __user *buf,
31836 size = count;
31837
31838 while (size) {
31839 - err = ec_read(*off, &data[*off - init_off]);
31840 + err = ec_read(*off, &data);
31841 if (err)
31842 return err;
31843 + if (put_user(data, &buf[*off - init_off]))
31844 + return -EFAULT;
31845 *off += 1;
31846 size--;
31847 }
31848 @@ -65,7 +68,6 @@ static ssize_t acpi_ec_write_io(struct file *f, const char __user *buf,
31849
31850 unsigned int size = count;
31851 loff_t init_off = *off;
31852 - u8 *data = (u8 *) buf;
31853 int err = 0;
31854
31855 if (*off >= EC_SPACE_SIZE)
31856 @@ -76,7 +78,9 @@ static ssize_t acpi_ec_write_io(struct file *f, const char __user *buf,
31857 }
31858
31859 while (size) {
31860 - u8 byte_write = data[*off - init_off];
31861 + u8 byte_write;
31862 + if (get_user(byte_write, &buf[*off - init_off]))
31863 + return -EFAULT;
31864 err = ec_write(*off, byte_write);
31865 if (err)
31866 return err;
31867 diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
31868 index ee255c6..747c68b 100644
31869 --- a/drivers/acpi/processor_idle.c
31870 +++ b/drivers/acpi/processor_idle.c
31871 @@ -986,7 +986,7 @@ static int acpi_processor_setup_cpuidle_states(struct acpi_processor *pr)
31872 {
31873 int i, count = CPUIDLE_DRIVER_STATE_START;
31874 struct acpi_processor_cx *cx;
31875 - struct cpuidle_state *state;
31876 + cpuidle_state_no_const *state;
31877 struct cpuidle_driver *drv = &acpi_idle_driver;
31878
31879 if (!pr->flags.power_setup_done)
31880 diff --git a/drivers/acpi/sysfs.c b/drivers/acpi/sysfs.c
31881 index 41c0504..f8c0836 100644
31882 --- a/drivers/acpi/sysfs.c
31883 +++ b/drivers/acpi/sysfs.c
31884 @@ -420,11 +420,11 @@ static u32 num_counters;
31885 static struct attribute **all_attrs;
31886 static u32 acpi_gpe_count;
31887
31888 -static struct attribute_group interrupt_stats_attr_group = {
31889 +static attribute_group_no_const interrupt_stats_attr_group = {
31890 .name = "interrupts",
31891 };
31892
31893 -static struct kobj_attribute *counter_attrs;
31894 +static kobj_attribute_no_const *counter_attrs;
31895
31896 static void delete_gpe_attr_array(void)
31897 {
31898 diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c
31899 index 34c8216..f56c828 100644
31900 --- a/drivers/ata/libahci.c
31901 +++ b/drivers/ata/libahci.c
31902 @@ -1230,7 +1230,7 @@ int ahci_kick_engine(struct ata_port *ap)
31903 }
31904 EXPORT_SYMBOL_GPL(ahci_kick_engine);
31905
31906 -static int ahci_exec_polled_cmd(struct ata_port *ap, int pmp,
31907 +static int __intentional_overflow(-1) ahci_exec_polled_cmd(struct ata_port *ap, int pmp,
31908 struct ata_taskfile *tf, int is_cmd, u16 flags,
31909 unsigned long timeout_msec)
31910 {
31911 diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
31912 index cf15aee..e0b7078 100644
31913 --- a/drivers/ata/libata-core.c
31914 +++ b/drivers/ata/libata-core.c
31915 @@ -4792,7 +4792,7 @@ void ata_qc_free(struct ata_queued_cmd *qc)
31916 struct ata_port *ap;
31917 unsigned int tag;
31918
31919 - WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
31920 + BUG_ON(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
31921 ap = qc->ap;
31922
31923 qc->flags = 0;
31924 @@ -4808,7 +4808,7 @@ void __ata_qc_complete(struct ata_queued_cmd *qc)
31925 struct ata_port *ap;
31926 struct ata_link *link;
31927
31928 - WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
31929 + BUG_ON(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
31930 WARN_ON_ONCE(!(qc->flags & ATA_QCFLAG_ACTIVE));
31931 ap = qc->ap;
31932 link = qc->dev->link;
31933 @@ -5926,6 +5926,7 @@ static void ata_finalize_port_ops(struct ata_port_operations *ops)
31934 return;
31935
31936 spin_lock(&lock);
31937 + pax_open_kernel();
31938
31939 for (cur = ops->inherits; cur; cur = cur->inherits) {
31940 void **inherit = (void **)cur;
31941 @@ -5939,8 +5940,9 @@ static void ata_finalize_port_ops(struct ata_port_operations *ops)
31942 if (IS_ERR(*pp))
31943 *pp = NULL;
31944
31945 - ops->inherits = NULL;
31946 + *(struct ata_port_operations **)&ops->inherits = NULL;
31947
31948 + pax_close_kernel();
31949 spin_unlock(&lock);
31950 }
31951
31952 diff --git a/drivers/ata/pata_arasan_cf.c b/drivers/ata/pata_arasan_cf.c
31953 index 405022d..fb70e53 100644
31954 --- a/drivers/ata/pata_arasan_cf.c
31955 +++ b/drivers/ata/pata_arasan_cf.c
31956 @@ -864,7 +864,9 @@ static int arasan_cf_probe(struct platform_device *pdev)
31957 /* Handle platform specific quirks */
31958 if (pdata->quirk) {
31959 if (pdata->quirk & CF_BROKEN_PIO) {
31960 - ap->ops->set_piomode = NULL;
31961 + pax_open_kernel();
31962 + *(void **)&ap->ops->set_piomode = NULL;
31963 + pax_close_kernel();
31964 ap->pio_mask = 0;
31965 }
31966 if (pdata->quirk & CF_BROKEN_MWDMA)
31967 diff --git a/drivers/atm/adummy.c b/drivers/atm/adummy.c
31968 index f9b983a..887b9d8 100644
31969 --- a/drivers/atm/adummy.c
31970 +++ b/drivers/atm/adummy.c
31971 @@ -114,7 +114,7 @@ adummy_send(struct atm_vcc *vcc, struct sk_buff *skb)
31972 vcc->pop(vcc, skb);
31973 else
31974 dev_kfree_skb_any(skb);
31975 - atomic_inc(&vcc->stats->tx);
31976 + atomic_inc_unchecked(&vcc->stats->tx);
31977
31978 return 0;
31979 }
31980 diff --git a/drivers/atm/ambassador.c b/drivers/atm/ambassador.c
31981 index 77a7480d..05cde58 100644
31982 --- a/drivers/atm/ambassador.c
31983 +++ b/drivers/atm/ambassador.c
31984 @@ -454,7 +454,7 @@ static void tx_complete (amb_dev * dev, tx_out * tx) {
31985 PRINTD (DBG_FLOW|DBG_TX, "tx_complete %p %p", dev, tx);
31986
31987 // VC layer stats
31988 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
31989 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
31990
31991 // free the descriptor
31992 kfree (tx_descr);
31993 @@ -495,7 +495,7 @@ static void rx_complete (amb_dev * dev, rx_out * rx) {
31994 dump_skb ("<<<", vc, skb);
31995
31996 // VC layer stats
31997 - atomic_inc(&atm_vcc->stats->rx);
31998 + atomic_inc_unchecked(&atm_vcc->stats->rx);
31999 __net_timestamp(skb);
32000 // end of our responsibility
32001 atm_vcc->push (atm_vcc, skb);
32002 @@ -510,7 +510,7 @@ static void rx_complete (amb_dev * dev, rx_out * rx) {
32003 } else {
32004 PRINTK (KERN_INFO, "dropped over-size frame");
32005 // should we count this?
32006 - atomic_inc(&atm_vcc->stats->rx_drop);
32007 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
32008 }
32009
32010 } else {
32011 @@ -1338,7 +1338,7 @@ static int amb_send (struct atm_vcc * atm_vcc, struct sk_buff * skb) {
32012 }
32013
32014 if (check_area (skb->data, skb->len)) {
32015 - atomic_inc(&atm_vcc->stats->tx_err);
32016 + atomic_inc_unchecked(&atm_vcc->stats->tx_err);
32017 return -ENOMEM; // ?
32018 }
32019
32020 diff --git a/drivers/atm/atmtcp.c b/drivers/atm/atmtcp.c
32021 index 0e3f8f9..765a7a5 100644
32022 --- a/drivers/atm/atmtcp.c
32023 +++ b/drivers/atm/atmtcp.c
32024 @@ -206,7 +206,7 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
32025 if (vcc->pop) vcc->pop(vcc,skb);
32026 else dev_kfree_skb(skb);
32027 if (dev_data) return 0;
32028 - atomic_inc(&vcc->stats->tx_err);
32029 + atomic_inc_unchecked(&vcc->stats->tx_err);
32030 return -ENOLINK;
32031 }
32032 size = skb->len+sizeof(struct atmtcp_hdr);
32033 @@ -214,7 +214,7 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
32034 if (!new_skb) {
32035 if (vcc->pop) vcc->pop(vcc,skb);
32036 else dev_kfree_skb(skb);
32037 - atomic_inc(&vcc->stats->tx_err);
32038 + atomic_inc_unchecked(&vcc->stats->tx_err);
32039 return -ENOBUFS;
32040 }
32041 hdr = (void *) skb_put(new_skb,sizeof(struct atmtcp_hdr));
32042 @@ -225,8 +225,8 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
32043 if (vcc->pop) vcc->pop(vcc,skb);
32044 else dev_kfree_skb(skb);
32045 out_vcc->push(out_vcc,new_skb);
32046 - atomic_inc(&vcc->stats->tx);
32047 - atomic_inc(&out_vcc->stats->rx);
32048 + atomic_inc_unchecked(&vcc->stats->tx);
32049 + atomic_inc_unchecked(&out_vcc->stats->rx);
32050 return 0;
32051 }
32052
32053 @@ -299,7 +299,7 @@ static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb)
32054 out_vcc = find_vcc(dev, ntohs(hdr->vpi), ntohs(hdr->vci));
32055 read_unlock(&vcc_sklist_lock);
32056 if (!out_vcc) {
32057 - atomic_inc(&vcc->stats->tx_err);
32058 + atomic_inc_unchecked(&vcc->stats->tx_err);
32059 goto done;
32060 }
32061 skb_pull(skb,sizeof(struct atmtcp_hdr));
32062 @@ -311,8 +311,8 @@ static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb)
32063 __net_timestamp(new_skb);
32064 skb_copy_from_linear_data(skb, skb_put(new_skb, skb->len), skb->len);
32065 out_vcc->push(out_vcc,new_skb);
32066 - atomic_inc(&vcc->stats->tx);
32067 - atomic_inc(&out_vcc->stats->rx);
32068 + atomic_inc_unchecked(&vcc->stats->tx);
32069 + atomic_inc_unchecked(&out_vcc->stats->rx);
32070 done:
32071 if (vcc->pop) vcc->pop(vcc,skb);
32072 else dev_kfree_skb(skb);
32073 diff --git a/drivers/atm/eni.c b/drivers/atm/eni.c
32074 index b1955ba..b179940 100644
32075 --- a/drivers/atm/eni.c
32076 +++ b/drivers/atm/eni.c
32077 @@ -522,7 +522,7 @@ static int rx_aal0(struct atm_vcc *vcc)
32078 DPRINTK(DEV_LABEL "(itf %d): trashing empty cell\n",
32079 vcc->dev->number);
32080 length = 0;
32081 - atomic_inc(&vcc->stats->rx_err);
32082 + atomic_inc_unchecked(&vcc->stats->rx_err);
32083 }
32084 else {
32085 length = ATM_CELL_SIZE-1; /* no HEC */
32086 @@ -577,7 +577,7 @@ static int rx_aal5(struct atm_vcc *vcc)
32087 size);
32088 }
32089 eff = length = 0;
32090 - atomic_inc(&vcc->stats->rx_err);
32091 + atomic_inc_unchecked(&vcc->stats->rx_err);
32092 }
32093 else {
32094 size = (descr & MID_RED_COUNT)*(ATM_CELL_PAYLOAD >> 2);
32095 @@ -594,7 +594,7 @@ static int rx_aal5(struct atm_vcc *vcc)
32096 "(VCI=%d,length=%ld,size=%ld (descr 0x%lx))\n",
32097 vcc->dev->number,vcc->vci,length,size << 2,descr);
32098 length = eff = 0;
32099 - atomic_inc(&vcc->stats->rx_err);
32100 + atomic_inc_unchecked(&vcc->stats->rx_err);
32101 }
32102 }
32103 skb = eff ? atm_alloc_charge(vcc,eff << 2,GFP_ATOMIC) : NULL;
32104 @@ -767,7 +767,7 @@ rx_dequeued++;
32105 vcc->push(vcc,skb);
32106 pushed++;
32107 }
32108 - atomic_inc(&vcc->stats->rx);
32109 + atomic_inc_unchecked(&vcc->stats->rx);
32110 }
32111 wake_up(&eni_dev->rx_wait);
32112 }
32113 @@ -1227,7 +1227,7 @@ static void dequeue_tx(struct atm_dev *dev)
32114 PCI_DMA_TODEVICE);
32115 if (vcc->pop) vcc->pop(vcc,skb);
32116 else dev_kfree_skb_irq(skb);
32117 - atomic_inc(&vcc->stats->tx);
32118 + atomic_inc_unchecked(&vcc->stats->tx);
32119 wake_up(&eni_dev->tx_wait);
32120 dma_complete++;
32121 }
32122 diff --git a/drivers/atm/firestream.c b/drivers/atm/firestream.c
32123 index b41c948..a002b17 100644
32124 --- a/drivers/atm/firestream.c
32125 +++ b/drivers/atm/firestream.c
32126 @@ -749,7 +749,7 @@ static void process_txdone_queue (struct fs_dev *dev, struct queue *q)
32127 }
32128 }
32129
32130 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
32131 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
32132
32133 fs_dprintk (FS_DEBUG_TXMEM, "i");
32134 fs_dprintk (FS_DEBUG_ALLOC, "Free t-skb: %p\n", skb);
32135 @@ -816,7 +816,7 @@ static void process_incoming (struct fs_dev *dev, struct queue *q)
32136 #endif
32137 skb_put (skb, qe->p1 & 0xffff);
32138 ATM_SKB(skb)->vcc = atm_vcc;
32139 - atomic_inc(&atm_vcc->stats->rx);
32140 + atomic_inc_unchecked(&atm_vcc->stats->rx);
32141 __net_timestamp(skb);
32142 fs_dprintk (FS_DEBUG_ALLOC, "Free rec-skb: %p (pushed)\n", skb);
32143 atm_vcc->push (atm_vcc, skb);
32144 @@ -837,12 +837,12 @@ static void process_incoming (struct fs_dev *dev, struct queue *q)
32145 kfree (pe);
32146 }
32147 if (atm_vcc)
32148 - atomic_inc(&atm_vcc->stats->rx_drop);
32149 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
32150 break;
32151 case 0x1f: /* Reassembly abort: no buffers. */
32152 /* Silently increment error counter. */
32153 if (atm_vcc)
32154 - atomic_inc(&atm_vcc->stats->rx_drop);
32155 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
32156 break;
32157 default: /* Hmm. Haven't written the code to handle the others yet... -- REW */
32158 printk (KERN_WARNING "Don't know what to do with RX status %x: %s.\n",
32159 diff --git a/drivers/atm/fore200e.c b/drivers/atm/fore200e.c
32160 index 204814e..cede831 100644
32161 --- a/drivers/atm/fore200e.c
32162 +++ b/drivers/atm/fore200e.c
32163 @@ -931,9 +931,9 @@ fore200e_tx_irq(struct fore200e* fore200e)
32164 #endif
32165 /* check error condition */
32166 if (*entry->status & STATUS_ERROR)
32167 - atomic_inc(&vcc->stats->tx_err);
32168 + atomic_inc_unchecked(&vcc->stats->tx_err);
32169 else
32170 - atomic_inc(&vcc->stats->tx);
32171 + atomic_inc_unchecked(&vcc->stats->tx);
32172 }
32173 }
32174
32175 @@ -1082,7 +1082,7 @@ fore200e_push_rpd(struct fore200e* fore200e, struct atm_vcc* vcc, struct rpd* rp
32176 if (skb == NULL) {
32177 DPRINTK(2, "unable to alloc new skb, rx PDU length = %d\n", pdu_len);
32178
32179 - atomic_inc(&vcc->stats->rx_drop);
32180 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32181 return -ENOMEM;
32182 }
32183
32184 @@ -1125,14 +1125,14 @@ fore200e_push_rpd(struct fore200e* fore200e, struct atm_vcc* vcc, struct rpd* rp
32185
32186 dev_kfree_skb_any(skb);
32187
32188 - atomic_inc(&vcc->stats->rx_drop);
32189 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32190 return -ENOMEM;
32191 }
32192
32193 ASSERT(atomic_read(&sk_atm(vcc)->sk_wmem_alloc) >= 0);
32194
32195 vcc->push(vcc, skb);
32196 - atomic_inc(&vcc->stats->rx);
32197 + atomic_inc_unchecked(&vcc->stats->rx);
32198
32199 ASSERT(atomic_read(&sk_atm(vcc)->sk_wmem_alloc) >= 0);
32200
32201 @@ -1210,7 +1210,7 @@ fore200e_rx_irq(struct fore200e* fore200e)
32202 DPRINTK(2, "damaged PDU on %d.%d.%d\n",
32203 fore200e->atm_dev->number,
32204 entry->rpd->atm_header.vpi, entry->rpd->atm_header.vci);
32205 - atomic_inc(&vcc->stats->rx_err);
32206 + atomic_inc_unchecked(&vcc->stats->rx_err);
32207 }
32208 }
32209
32210 @@ -1655,7 +1655,7 @@ fore200e_send(struct atm_vcc *vcc, struct sk_buff *skb)
32211 goto retry_here;
32212 }
32213
32214 - atomic_inc(&vcc->stats->tx_err);
32215 + atomic_inc_unchecked(&vcc->stats->tx_err);
32216
32217 fore200e->tx_sat++;
32218 DPRINTK(2, "tx queue of device %s is saturated, PDU dropped - heartbeat is %08x\n",
32219 diff --git a/drivers/atm/he.c b/drivers/atm/he.c
32220 index d689126..e78e412 100644
32221 --- a/drivers/atm/he.c
32222 +++ b/drivers/atm/he.c
32223 @@ -1698,7 +1698,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
32224
32225 if (RBRQ_HBUF_ERR(he_dev->rbrq_head)) {
32226 hprintk("HBUF_ERR! (cid 0x%x)\n", cid);
32227 - atomic_inc(&vcc->stats->rx_drop);
32228 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32229 goto return_host_buffers;
32230 }
32231
32232 @@ -1725,7 +1725,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
32233 RBRQ_LEN_ERR(he_dev->rbrq_head)
32234 ? "LEN_ERR" : "",
32235 vcc->vpi, vcc->vci);
32236 - atomic_inc(&vcc->stats->rx_err);
32237 + atomic_inc_unchecked(&vcc->stats->rx_err);
32238 goto return_host_buffers;
32239 }
32240
32241 @@ -1777,7 +1777,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
32242 vcc->push(vcc, skb);
32243 spin_lock(&he_dev->global_lock);
32244
32245 - atomic_inc(&vcc->stats->rx);
32246 + atomic_inc_unchecked(&vcc->stats->rx);
32247
32248 return_host_buffers:
32249 ++pdus_assembled;
32250 @@ -2103,7 +2103,7 @@ __enqueue_tpd(struct he_dev *he_dev, struct he_tpd *tpd, unsigned cid)
32251 tpd->vcc->pop(tpd->vcc, tpd->skb);
32252 else
32253 dev_kfree_skb_any(tpd->skb);
32254 - atomic_inc(&tpd->vcc->stats->tx_err);
32255 + atomic_inc_unchecked(&tpd->vcc->stats->tx_err);
32256 }
32257 pci_pool_free(he_dev->tpd_pool, tpd, TPD_ADDR(tpd->status));
32258 return;
32259 @@ -2515,7 +2515,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 return -EINVAL;
32266 }
32267
32268 @@ -2526,7 +2526,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32269 vcc->pop(vcc, skb);
32270 else
32271 dev_kfree_skb_any(skb);
32272 - atomic_inc(&vcc->stats->tx_err);
32273 + atomic_inc_unchecked(&vcc->stats->tx_err);
32274 return -EINVAL;
32275 }
32276 #endif
32277 @@ -2538,7 +2538,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32278 vcc->pop(vcc, skb);
32279 else
32280 dev_kfree_skb_any(skb);
32281 - atomic_inc(&vcc->stats->tx_err);
32282 + atomic_inc_unchecked(&vcc->stats->tx_err);
32283 spin_unlock_irqrestore(&he_dev->global_lock, flags);
32284 return -ENOMEM;
32285 }
32286 @@ -2580,7 +2580,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32287 vcc->pop(vcc, skb);
32288 else
32289 dev_kfree_skb_any(skb);
32290 - atomic_inc(&vcc->stats->tx_err);
32291 + atomic_inc_unchecked(&vcc->stats->tx_err);
32292 spin_unlock_irqrestore(&he_dev->global_lock, flags);
32293 return -ENOMEM;
32294 }
32295 @@ -2611,7 +2611,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32296 __enqueue_tpd(he_dev, tpd, cid);
32297 spin_unlock_irqrestore(&he_dev->global_lock, flags);
32298
32299 - atomic_inc(&vcc->stats->tx);
32300 + atomic_inc_unchecked(&vcc->stats->tx);
32301
32302 return 0;
32303 }
32304 diff --git a/drivers/atm/horizon.c b/drivers/atm/horizon.c
32305 index 1dc0519..1aadaf7 100644
32306 --- a/drivers/atm/horizon.c
32307 +++ b/drivers/atm/horizon.c
32308 @@ -1034,7 +1034,7 @@ static void rx_schedule (hrz_dev * dev, int irq) {
32309 {
32310 struct atm_vcc * vcc = ATM_SKB(skb)->vcc;
32311 // VC layer stats
32312 - atomic_inc(&vcc->stats->rx);
32313 + atomic_inc_unchecked(&vcc->stats->rx);
32314 __net_timestamp(skb);
32315 // end of our responsibility
32316 vcc->push (vcc, skb);
32317 @@ -1186,7 +1186,7 @@ static void tx_schedule (hrz_dev * const dev, int irq) {
32318 dev->tx_iovec = NULL;
32319
32320 // VC layer stats
32321 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
32322 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
32323
32324 // free the skb
32325 hrz_kfree_skb (skb);
32326 diff --git a/drivers/atm/idt77252.c b/drivers/atm/idt77252.c
32327 index 272f009..a18ba55 100644
32328 --- a/drivers/atm/idt77252.c
32329 +++ b/drivers/atm/idt77252.c
32330 @@ -812,7 +812,7 @@ drain_scq(struct idt77252_dev *card, struct vc_map *vc)
32331 else
32332 dev_kfree_skb(skb);
32333
32334 - atomic_inc(&vcc->stats->tx);
32335 + atomic_inc_unchecked(&vcc->stats->tx);
32336 }
32337
32338 atomic_dec(&scq->used);
32339 @@ -1075,13 +1075,13 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32340 if ((sb = dev_alloc_skb(64)) == NULL) {
32341 printk("%s: Can't allocate buffers for aal0.\n",
32342 card->name);
32343 - atomic_add(i, &vcc->stats->rx_drop);
32344 + atomic_add_unchecked(i, &vcc->stats->rx_drop);
32345 break;
32346 }
32347 if (!atm_charge(vcc, sb->truesize)) {
32348 RXPRINTK("%s: atm_charge() dropped aal0 packets.\n",
32349 card->name);
32350 - atomic_add(i - 1, &vcc->stats->rx_drop);
32351 + atomic_add_unchecked(i - 1, &vcc->stats->rx_drop);
32352 dev_kfree_skb(sb);
32353 break;
32354 }
32355 @@ -1098,7 +1098,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32356 ATM_SKB(sb)->vcc = vcc;
32357 __net_timestamp(sb);
32358 vcc->push(vcc, sb);
32359 - atomic_inc(&vcc->stats->rx);
32360 + atomic_inc_unchecked(&vcc->stats->rx);
32361
32362 cell += ATM_CELL_PAYLOAD;
32363 }
32364 @@ -1135,13 +1135,13 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32365 "(CDC: %08x)\n",
32366 card->name, len, rpp->len, readl(SAR_REG_CDC));
32367 recycle_rx_pool_skb(card, rpp);
32368 - atomic_inc(&vcc->stats->rx_err);
32369 + atomic_inc_unchecked(&vcc->stats->rx_err);
32370 return;
32371 }
32372 if (stat & SAR_RSQE_CRC) {
32373 RXPRINTK("%s: AAL5 CRC error.\n", card->name);
32374 recycle_rx_pool_skb(card, rpp);
32375 - atomic_inc(&vcc->stats->rx_err);
32376 + atomic_inc_unchecked(&vcc->stats->rx_err);
32377 return;
32378 }
32379 if (skb_queue_len(&rpp->queue) > 1) {
32380 @@ -1152,7 +1152,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32381 RXPRINTK("%s: Can't alloc RX skb.\n",
32382 card->name);
32383 recycle_rx_pool_skb(card, rpp);
32384 - atomic_inc(&vcc->stats->rx_err);
32385 + atomic_inc_unchecked(&vcc->stats->rx_err);
32386 return;
32387 }
32388 if (!atm_charge(vcc, skb->truesize)) {
32389 @@ -1171,7 +1171,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32390 __net_timestamp(skb);
32391
32392 vcc->push(vcc, skb);
32393 - atomic_inc(&vcc->stats->rx);
32394 + atomic_inc_unchecked(&vcc->stats->rx);
32395
32396 return;
32397 }
32398 @@ -1193,7 +1193,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32399 __net_timestamp(skb);
32400
32401 vcc->push(vcc, skb);
32402 - atomic_inc(&vcc->stats->rx);
32403 + atomic_inc_unchecked(&vcc->stats->rx);
32404
32405 if (skb->truesize > SAR_FB_SIZE_3)
32406 add_rx_skb(card, 3, SAR_FB_SIZE_3, 1);
32407 @@ -1304,14 +1304,14 @@ idt77252_rx_raw(struct idt77252_dev *card)
32408 if (vcc->qos.aal != ATM_AAL0) {
32409 RPRINTK("%s: raw cell for non AAL0 vc %u.%u\n",
32410 card->name, vpi, vci);
32411 - atomic_inc(&vcc->stats->rx_drop);
32412 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32413 goto drop;
32414 }
32415
32416 if ((sb = dev_alloc_skb(64)) == NULL) {
32417 printk("%s: Can't allocate buffers for AAL0.\n",
32418 card->name);
32419 - atomic_inc(&vcc->stats->rx_err);
32420 + atomic_inc_unchecked(&vcc->stats->rx_err);
32421 goto drop;
32422 }
32423
32424 @@ -1330,7 +1330,7 @@ idt77252_rx_raw(struct idt77252_dev *card)
32425 ATM_SKB(sb)->vcc = vcc;
32426 __net_timestamp(sb);
32427 vcc->push(vcc, sb);
32428 - atomic_inc(&vcc->stats->rx);
32429 + atomic_inc_unchecked(&vcc->stats->rx);
32430
32431 drop:
32432 skb_pull(queue, 64);
32433 @@ -1955,13 +1955,13 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
32434
32435 if (vc == NULL) {
32436 printk("%s: NULL connection in send().\n", card->name);
32437 - atomic_inc(&vcc->stats->tx_err);
32438 + atomic_inc_unchecked(&vcc->stats->tx_err);
32439 dev_kfree_skb(skb);
32440 return -EINVAL;
32441 }
32442 if (!test_bit(VCF_TX, &vc->flags)) {
32443 printk("%s: Trying to transmit on a non-tx VC.\n", card->name);
32444 - atomic_inc(&vcc->stats->tx_err);
32445 + atomic_inc_unchecked(&vcc->stats->tx_err);
32446 dev_kfree_skb(skb);
32447 return -EINVAL;
32448 }
32449 @@ -1973,14 +1973,14 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
32450 break;
32451 default:
32452 printk("%s: Unsupported AAL: %d\n", card->name, vcc->qos.aal);
32453 - atomic_inc(&vcc->stats->tx_err);
32454 + atomic_inc_unchecked(&vcc->stats->tx_err);
32455 dev_kfree_skb(skb);
32456 return -EINVAL;
32457 }
32458
32459 if (skb_shinfo(skb)->nr_frags != 0) {
32460 printk("%s: No scatter-gather yet.\n", card->name);
32461 - atomic_inc(&vcc->stats->tx_err);
32462 + atomic_inc_unchecked(&vcc->stats->tx_err);
32463 dev_kfree_skb(skb);
32464 return -EINVAL;
32465 }
32466 @@ -1988,7 +1988,7 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
32467
32468 err = queue_skb(card, vc, skb, oam);
32469 if (err) {
32470 - atomic_inc(&vcc->stats->tx_err);
32471 + atomic_inc_unchecked(&vcc->stats->tx_err);
32472 dev_kfree_skb(skb);
32473 return err;
32474 }
32475 @@ -2011,7 +2011,7 @@ idt77252_send_oam(struct atm_vcc *vcc, void *cell, int flags)
32476 skb = dev_alloc_skb(64);
32477 if (!skb) {
32478 printk("%s: Out of memory in send_oam().\n", card->name);
32479 - atomic_inc(&vcc->stats->tx_err);
32480 + atomic_inc_unchecked(&vcc->stats->tx_err);
32481 return -ENOMEM;
32482 }
32483 atomic_add(skb->truesize, &sk_atm(vcc)->sk_wmem_alloc);
32484 diff --git a/drivers/atm/iphase.c b/drivers/atm/iphase.c
32485 index 4217f29..88f547a 100644
32486 --- a/drivers/atm/iphase.c
32487 +++ b/drivers/atm/iphase.c
32488 @@ -1145,7 +1145,7 @@ static int rx_pkt(struct atm_dev *dev)
32489 status = (u_short) (buf_desc_ptr->desc_mode);
32490 if (status & (RX_CER | RX_PTE | RX_OFL))
32491 {
32492 - atomic_inc(&vcc->stats->rx_err);
32493 + atomic_inc_unchecked(&vcc->stats->rx_err);
32494 IF_ERR(printk("IA: bad packet, dropping it");)
32495 if (status & RX_CER) {
32496 IF_ERR(printk(" cause: packet CRC error\n");)
32497 @@ -1168,7 +1168,7 @@ static int rx_pkt(struct atm_dev *dev)
32498 len = dma_addr - buf_addr;
32499 if (len > iadev->rx_buf_sz) {
32500 printk("Over %d bytes sdu received, dropped!!!\n", iadev->rx_buf_sz);
32501 - atomic_inc(&vcc->stats->rx_err);
32502 + atomic_inc_unchecked(&vcc->stats->rx_err);
32503 goto out_free_desc;
32504 }
32505
32506 @@ -1318,7 +1318,7 @@ static void rx_dle_intr(struct atm_dev *dev)
32507 ia_vcc = INPH_IA_VCC(vcc);
32508 if (ia_vcc == NULL)
32509 {
32510 - atomic_inc(&vcc->stats->rx_err);
32511 + atomic_inc_unchecked(&vcc->stats->rx_err);
32512 atm_return(vcc, skb->truesize);
32513 dev_kfree_skb_any(skb);
32514 goto INCR_DLE;
32515 @@ -1330,7 +1330,7 @@ static void rx_dle_intr(struct atm_dev *dev)
32516 if ((length > iadev->rx_buf_sz) || (length >
32517 (skb->len - sizeof(struct cpcs_trailer))))
32518 {
32519 - atomic_inc(&vcc->stats->rx_err);
32520 + atomic_inc_unchecked(&vcc->stats->rx_err);
32521 IF_ERR(printk("rx_dle_intr: Bad AAL5 trailer %d (skb len %d)",
32522 length, skb->len);)
32523 atm_return(vcc, skb->truesize);
32524 @@ -1346,7 +1346,7 @@ static void rx_dle_intr(struct atm_dev *dev)
32525
32526 IF_RX(printk("rx_dle_intr: skb push");)
32527 vcc->push(vcc,skb);
32528 - atomic_inc(&vcc->stats->rx);
32529 + atomic_inc_unchecked(&vcc->stats->rx);
32530 iadev->rx_pkt_cnt++;
32531 }
32532 INCR_DLE:
32533 @@ -2826,15 +2826,15 @@ static int ia_ioctl(struct atm_dev *dev, unsigned int cmd, void __user *arg)
32534 {
32535 struct k_sonet_stats *stats;
32536 stats = &PRIV(_ia_dev[board])->sonet_stats;
32537 - printk("section_bip: %d\n", atomic_read(&stats->section_bip));
32538 - printk("line_bip : %d\n", atomic_read(&stats->line_bip));
32539 - printk("path_bip : %d\n", atomic_read(&stats->path_bip));
32540 - printk("line_febe : %d\n", atomic_read(&stats->line_febe));
32541 - printk("path_febe : %d\n", atomic_read(&stats->path_febe));
32542 - printk("corr_hcs : %d\n", atomic_read(&stats->corr_hcs));
32543 - printk("uncorr_hcs : %d\n", atomic_read(&stats->uncorr_hcs));
32544 - printk("tx_cells : %d\n", atomic_read(&stats->tx_cells));
32545 - printk("rx_cells : %d\n", atomic_read(&stats->rx_cells));
32546 + printk("section_bip: %d\n", atomic_read_unchecked(&stats->section_bip));
32547 + printk("line_bip : %d\n", atomic_read_unchecked(&stats->line_bip));
32548 + printk("path_bip : %d\n", atomic_read_unchecked(&stats->path_bip));
32549 + printk("line_febe : %d\n", atomic_read_unchecked(&stats->line_febe));
32550 + printk("path_febe : %d\n", atomic_read_unchecked(&stats->path_febe));
32551 + printk("corr_hcs : %d\n", atomic_read_unchecked(&stats->corr_hcs));
32552 + printk("uncorr_hcs : %d\n", atomic_read_unchecked(&stats->uncorr_hcs));
32553 + printk("tx_cells : %d\n", atomic_read_unchecked(&stats->tx_cells));
32554 + printk("rx_cells : %d\n", atomic_read_unchecked(&stats->rx_cells));
32555 }
32556 ia_cmds.status = 0;
32557 break;
32558 @@ -2939,7 +2939,7 @@ static int ia_pkt_tx (struct atm_vcc *vcc, struct sk_buff *skb) {
32559 if ((desc == 0) || (desc > iadev->num_tx_desc))
32560 {
32561 IF_ERR(printk(DEV_LABEL "invalid desc for send: %d\n", desc);)
32562 - atomic_inc(&vcc->stats->tx);
32563 + atomic_inc_unchecked(&vcc->stats->tx);
32564 if (vcc->pop)
32565 vcc->pop(vcc, skb);
32566 else
32567 @@ -3044,14 +3044,14 @@ static int ia_pkt_tx (struct atm_vcc *vcc, struct sk_buff *skb) {
32568 ATM_DESC(skb) = vcc->vci;
32569 skb_queue_tail(&iadev->tx_dma_q, skb);
32570
32571 - atomic_inc(&vcc->stats->tx);
32572 + atomic_inc_unchecked(&vcc->stats->tx);
32573 iadev->tx_pkt_cnt++;
32574 /* Increment transaction counter */
32575 writel(2, iadev->dma+IPHASE5575_TX_COUNTER);
32576
32577 #if 0
32578 /* add flow control logic */
32579 - if (atomic_read(&vcc->stats->tx) % 20 == 0) {
32580 + if (atomic_read_unchecked(&vcc->stats->tx) % 20 == 0) {
32581 if (iavcc->vc_desc_cnt > 10) {
32582 vcc->tx_quota = vcc->tx_quota * 3 / 4;
32583 printk("Tx1: vcc->tx_quota = %d \n", (u32)vcc->tx_quota );
32584 diff --git a/drivers/atm/lanai.c b/drivers/atm/lanai.c
32585 index fa7d701..1e404c7 100644
32586 --- a/drivers/atm/lanai.c
32587 +++ b/drivers/atm/lanai.c
32588 @@ -1303,7 +1303,7 @@ static void lanai_send_one_aal5(struct lanai_dev *lanai,
32589 vcc_tx_add_aal5_trailer(lvcc, skb->len, 0, 0);
32590 lanai_endtx(lanai, lvcc);
32591 lanai_free_skb(lvcc->tx.atmvcc, skb);
32592 - atomic_inc(&lvcc->tx.atmvcc->stats->tx);
32593 + atomic_inc_unchecked(&lvcc->tx.atmvcc->stats->tx);
32594 }
32595
32596 /* Try to fill the buffer - don't call unless there is backlog */
32597 @@ -1426,7 +1426,7 @@ static void vcc_rx_aal5(struct lanai_vcc *lvcc, int endptr)
32598 ATM_SKB(skb)->vcc = lvcc->rx.atmvcc;
32599 __net_timestamp(skb);
32600 lvcc->rx.atmvcc->push(lvcc->rx.atmvcc, skb);
32601 - atomic_inc(&lvcc->rx.atmvcc->stats->rx);
32602 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx);
32603 out:
32604 lvcc->rx.buf.ptr = end;
32605 cardvcc_write(lvcc, endptr, vcc_rxreadptr);
32606 @@ -1667,7 +1667,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
32607 DPRINTK("(itf %d) got RX service entry 0x%X for non-AAL5 "
32608 "vcc %d\n", lanai->number, (unsigned int) s, vci);
32609 lanai->stats.service_rxnotaal5++;
32610 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
32611 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
32612 return 0;
32613 }
32614 if (likely(!(s & (SERVICE_TRASH | SERVICE_STREAM | SERVICE_CRCERR)))) {
32615 @@ -1679,7 +1679,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
32616 int bytes;
32617 read_unlock(&vcc_sklist_lock);
32618 DPRINTK("got trashed rx pdu on vci %d\n", vci);
32619 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
32620 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
32621 lvcc->stats.x.aal5.service_trash++;
32622 bytes = (SERVICE_GET_END(s) * 16) -
32623 (((unsigned long) lvcc->rx.buf.ptr) -
32624 @@ -1691,7 +1691,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
32625 }
32626 if (s & SERVICE_STREAM) {
32627 read_unlock(&vcc_sklist_lock);
32628 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
32629 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
32630 lvcc->stats.x.aal5.service_stream++;
32631 printk(KERN_ERR DEV_LABEL "(itf %d): Got AAL5 stream "
32632 "PDU on VCI %d!\n", lanai->number, vci);
32633 @@ -1699,7 +1699,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
32634 return 0;
32635 }
32636 DPRINTK("got rx crc error on vci %d\n", vci);
32637 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
32638 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
32639 lvcc->stats.x.aal5.service_rxcrc++;
32640 lvcc->rx.buf.ptr = &lvcc->rx.buf.start[SERVICE_GET_END(s) * 4];
32641 cardvcc_write(lvcc, SERVICE_GET_END(s), vcc_rxreadptr);
32642 diff --git a/drivers/atm/nicstar.c b/drivers/atm/nicstar.c
32643 index 6587dc2..149833d 100644
32644 --- a/drivers/atm/nicstar.c
32645 +++ b/drivers/atm/nicstar.c
32646 @@ -1641,7 +1641,7 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
32647 if ((vc = (vc_map *) vcc->dev_data) == NULL) {
32648 printk("nicstar%d: vcc->dev_data == NULL on ns_send().\n",
32649 card->index);
32650 - atomic_inc(&vcc->stats->tx_err);
32651 + atomic_inc_unchecked(&vcc->stats->tx_err);
32652 dev_kfree_skb_any(skb);
32653 return -EINVAL;
32654 }
32655 @@ -1649,7 +1649,7 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
32656 if (!vc->tx) {
32657 printk("nicstar%d: Trying to transmit on a non-tx VC.\n",
32658 card->index);
32659 - atomic_inc(&vcc->stats->tx_err);
32660 + atomic_inc_unchecked(&vcc->stats->tx_err);
32661 dev_kfree_skb_any(skb);
32662 return -EINVAL;
32663 }
32664 @@ -1657,14 +1657,14 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
32665 if (vcc->qos.aal != ATM_AAL5 && vcc->qos.aal != ATM_AAL0) {
32666 printk("nicstar%d: Only AAL0 and AAL5 are supported.\n",
32667 card->index);
32668 - atomic_inc(&vcc->stats->tx_err);
32669 + atomic_inc_unchecked(&vcc->stats->tx_err);
32670 dev_kfree_skb_any(skb);
32671 return -EINVAL;
32672 }
32673
32674 if (skb_shinfo(skb)->nr_frags != 0) {
32675 printk("nicstar%d: No scatter-gather yet.\n", card->index);
32676 - atomic_inc(&vcc->stats->tx_err);
32677 + atomic_inc_unchecked(&vcc->stats->tx_err);
32678 dev_kfree_skb_any(skb);
32679 return -EINVAL;
32680 }
32681 @@ -1712,11 +1712,11 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
32682 }
32683
32684 if (push_scqe(card, vc, scq, &scqe, skb) != 0) {
32685 - atomic_inc(&vcc->stats->tx_err);
32686 + atomic_inc_unchecked(&vcc->stats->tx_err);
32687 dev_kfree_skb_any(skb);
32688 return -EIO;
32689 }
32690 - atomic_inc(&vcc->stats->tx);
32691 + atomic_inc_unchecked(&vcc->stats->tx);
32692
32693 return 0;
32694 }
32695 @@ -2033,14 +2033,14 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32696 printk
32697 ("nicstar%d: Can't allocate buffers for aal0.\n",
32698 card->index);
32699 - atomic_add(i, &vcc->stats->rx_drop);
32700 + atomic_add_unchecked(i, &vcc->stats->rx_drop);
32701 break;
32702 }
32703 if (!atm_charge(vcc, sb->truesize)) {
32704 RXPRINTK
32705 ("nicstar%d: atm_charge() dropped aal0 packets.\n",
32706 card->index);
32707 - atomic_add(i - 1, &vcc->stats->rx_drop); /* already increased by 1 */
32708 + atomic_add_unchecked(i - 1, &vcc->stats->rx_drop); /* already increased by 1 */
32709 dev_kfree_skb_any(sb);
32710 break;
32711 }
32712 @@ -2055,7 +2055,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32713 ATM_SKB(sb)->vcc = vcc;
32714 __net_timestamp(sb);
32715 vcc->push(vcc, sb);
32716 - atomic_inc(&vcc->stats->rx);
32717 + atomic_inc_unchecked(&vcc->stats->rx);
32718 cell += ATM_CELL_PAYLOAD;
32719 }
32720
32721 @@ -2072,7 +2072,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32722 if (iovb == NULL) {
32723 printk("nicstar%d: Out of iovec buffers.\n",
32724 card->index);
32725 - atomic_inc(&vcc->stats->rx_drop);
32726 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32727 recycle_rx_buf(card, skb);
32728 return;
32729 }
32730 @@ -2096,7 +2096,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32731 small or large buffer itself. */
32732 } else if (NS_PRV_IOVCNT(iovb) >= NS_MAX_IOVECS) {
32733 printk("nicstar%d: received too big AAL5 SDU.\n", card->index);
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_MAX_IOVECS);
32738 NS_PRV_IOVCNT(iovb) = 0;
32739 @@ -2116,7 +2116,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32740 ("nicstar%d: Expected a small buffer, and this is not one.\n",
32741 card->index);
32742 which_list(card, skb);
32743 - atomic_inc(&vcc->stats->rx_err);
32744 + atomic_inc_unchecked(&vcc->stats->rx_err);
32745 recycle_rx_buf(card, skb);
32746 vc->rx_iov = NULL;
32747 recycle_iov_buf(card, iovb);
32748 @@ -2129,7 +2129,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32749 ("nicstar%d: Expected a large buffer, and this is not one.\n",
32750 card->index);
32751 which_list(card, skb);
32752 - atomic_inc(&vcc->stats->rx_err);
32753 + atomic_inc_unchecked(&vcc->stats->rx_err);
32754 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
32755 NS_PRV_IOVCNT(iovb));
32756 vc->rx_iov = NULL;
32757 @@ -2152,7 +2152,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32758 printk(" - PDU size mismatch.\n");
32759 else
32760 printk(".\n");
32761 - atomic_inc(&vcc->stats->rx_err);
32762 + atomic_inc_unchecked(&vcc->stats->rx_err);
32763 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
32764 NS_PRV_IOVCNT(iovb));
32765 vc->rx_iov = NULL;
32766 @@ -2166,7 +2166,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32767 /* skb points to a small buffer */
32768 if (!atm_charge(vcc, skb->truesize)) {
32769 push_rxbufs(card, skb);
32770 - atomic_inc(&vcc->stats->rx_drop);
32771 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32772 } else {
32773 skb_put(skb, len);
32774 dequeue_sm_buf(card, skb);
32775 @@ -2176,7 +2176,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32776 ATM_SKB(skb)->vcc = vcc;
32777 __net_timestamp(skb);
32778 vcc->push(vcc, skb);
32779 - atomic_inc(&vcc->stats->rx);
32780 + atomic_inc_unchecked(&vcc->stats->rx);
32781 }
32782 } else if (NS_PRV_IOVCNT(iovb) == 2) { /* One small plus one large buffer */
32783 struct sk_buff *sb;
32784 @@ -2187,7 +2187,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32785 if (len <= NS_SMBUFSIZE) {
32786 if (!atm_charge(vcc, sb->truesize)) {
32787 push_rxbufs(card, sb);
32788 - atomic_inc(&vcc->stats->rx_drop);
32789 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32790 } else {
32791 skb_put(sb, len);
32792 dequeue_sm_buf(card, sb);
32793 @@ -2197,7 +2197,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32794 ATM_SKB(sb)->vcc = vcc;
32795 __net_timestamp(sb);
32796 vcc->push(vcc, sb);
32797 - atomic_inc(&vcc->stats->rx);
32798 + atomic_inc_unchecked(&vcc->stats->rx);
32799 }
32800
32801 push_rxbufs(card, skb);
32802 @@ -2206,7 +2206,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32803
32804 if (!atm_charge(vcc, skb->truesize)) {
32805 push_rxbufs(card, skb);
32806 - atomic_inc(&vcc->stats->rx_drop);
32807 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32808 } else {
32809 dequeue_lg_buf(card, skb);
32810 #ifdef NS_USE_DESTRUCTORS
32811 @@ -2219,7 +2219,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32812 ATM_SKB(skb)->vcc = vcc;
32813 __net_timestamp(skb);
32814 vcc->push(vcc, skb);
32815 - atomic_inc(&vcc->stats->rx);
32816 + atomic_inc_unchecked(&vcc->stats->rx);
32817 }
32818
32819 push_rxbufs(card, sb);
32820 @@ -2240,7 +2240,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32821 printk
32822 ("nicstar%d: Out of huge buffers.\n",
32823 card->index);
32824 - atomic_inc(&vcc->stats->rx_drop);
32825 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32826 recycle_iovec_rx_bufs(card,
32827 (struct iovec *)
32828 iovb->data,
32829 @@ -2291,7 +2291,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32830 card->hbpool.count++;
32831 } else
32832 dev_kfree_skb_any(hb);
32833 - atomic_inc(&vcc->stats->rx_drop);
32834 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32835 } else {
32836 /* Copy the small buffer to the huge buffer */
32837 sb = (struct sk_buff *)iov->iov_base;
32838 @@ -2328,7 +2328,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32839 #endif /* NS_USE_DESTRUCTORS */
32840 __net_timestamp(hb);
32841 vcc->push(vcc, hb);
32842 - atomic_inc(&vcc->stats->rx);
32843 + atomic_inc_unchecked(&vcc->stats->rx);
32844 }
32845 }
32846
32847 diff --git a/drivers/atm/solos-pci.c b/drivers/atm/solos-pci.c
32848 index 32784d1..4a8434a 100644
32849 --- a/drivers/atm/solos-pci.c
32850 +++ b/drivers/atm/solos-pci.c
32851 @@ -838,7 +838,7 @@ void solos_bh(unsigned long card_arg)
32852 }
32853 atm_charge(vcc, skb->truesize);
32854 vcc->push(vcc, skb);
32855 - atomic_inc(&vcc->stats->rx);
32856 + atomic_inc_unchecked(&vcc->stats->rx);
32857 break;
32858
32859 case PKT_STATUS:
32860 @@ -1116,7 +1116,7 @@ static uint32_t fpga_tx(struct solos_card *card)
32861 vcc = SKB_CB(oldskb)->vcc;
32862
32863 if (vcc) {
32864 - atomic_inc(&vcc->stats->tx);
32865 + atomic_inc_unchecked(&vcc->stats->tx);
32866 solos_pop(vcc, oldskb);
32867 } else {
32868 dev_kfree_skb_irq(oldskb);
32869 diff --git a/drivers/atm/suni.c b/drivers/atm/suni.c
32870 index 0215934..ce9f5b1 100644
32871 --- a/drivers/atm/suni.c
32872 +++ b/drivers/atm/suni.c
32873 @@ -49,8 +49,8 @@ static DEFINE_SPINLOCK(sunis_lock);
32874
32875
32876 #define ADD_LIMITED(s,v) \
32877 - atomic_add((v),&stats->s); \
32878 - if (atomic_read(&stats->s) < 0) atomic_set(&stats->s,INT_MAX);
32879 + atomic_add_unchecked((v),&stats->s); \
32880 + if (atomic_read_unchecked(&stats->s) < 0) atomic_set_unchecked(&stats->s,INT_MAX);
32881
32882
32883 static void suni_hz(unsigned long from_timer)
32884 diff --git a/drivers/atm/uPD98402.c b/drivers/atm/uPD98402.c
32885 index 5120a96..e2572bd 100644
32886 --- a/drivers/atm/uPD98402.c
32887 +++ b/drivers/atm/uPD98402.c
32888 @@ -42,7 +42,7 @@ static int fetch_stats(struct atm_dev *dev,struct sonet_stats __user *arg,int ze
32889 struct sonet_stats tmp;
32890 int error = 0;
32891
32892 - atomic_add(GET(HECCT),&PRIV(dev)->sonet_stats.uncorr_hcs);
32893 + atomic_add_unchecked(GET(HECCT),&PRIV(dev)->sonet_stats.uncorr_hcs);
32894 sonet_copy_stats(&PRIV(dev)->sonet_stats,&tmp);
32895 if (arg) error = copy_to_user(arg,&tmp,sizeof(tmp));
32896 if (zero && !error) {
32897 @@ -161,9 +161,9 @@ static int uPD98402_ioctl(struct atm_dev *dev,unsigned int cmd,void __user *arg)
32898
32899
32900 #define ADD_LIMITED(s,v) \
32901 - { atomic_add(GET(v),&PRIV(dev)->sonet_stats.s); \
32902 - if (atomic_read(&PRIV(dev)->sonet_stats.s) < 0) \
32903 - atomic_set(&PRIV(dev)->sonet_stats.s,INT_MAX); }
32904 + { atomic_add_unchecked(GET(v),&PRIV(dev)->sonet_stats.s); \
32905 + if (atomic_read_unchecked(&PRIV(dev)->sonet_stats.s) < 0) \
32906 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.s,INT_MAX); }
32907
32908
32909 static void stat_event(struct atm_dev *dev)
32910 @@ -194,7 +194,7 @@ static void uPD98402_int(struct atm_dev *dev)
32911 if (reason & uPD98402_INT_PFM) stat_event(dev);
32912 if (reason & uPD98402_INT_PCO) {
32913 (void) GET(PCOCR); /* clear interrupt cause */
32914 - atomic_add(GET(HECCT),
32915 + atomic_add_unchecked(GET(HECCT),
32916 &PRIV(dev)->sonet_stats.uncorr_hcs);
32917 }
32918 if ((reason & uPD98402_INT_RFO) &&
32919 @@ -222,9 +222,9 @@ static int uPD98402_start(struct atm_dev *dev)
32920 PUT(~(uPD98402_INT_PFM | uPD98402_INT_ALM | uPD98402_INT_RFO |
32921 uPD98402_INT_LOS),PIMR); /* enable them */
32922 (void) fetch_stats(dev,NULL,1); /* clear kernel counters */
32923 - atomic_set(&PRIV(dev)->sonet_stats.corr_hcs,-1);
32924 - atomic_set(&PRIV(dev)->sonet_stats.tx_cells,-1);
32925 - atomic_set(&PRIV(dev)->sonet_stats.rx_cells,-1);
32926 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.corr_hcs,-1);
32927 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.tx_cells,-1);
32928 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.rx_cells,-1);
32929 return 0;
32930 }
32931
32932 diff --git a/drivers/atm/zatm.c b/drivers/atm/zatm.c
32933 index 969c3c2..9b72956 100644
32934 --- a/drivers/atm/zatm.c
32935 +++ b/drivers/atm/zatm.c
32936 @@ -459,7 +459,7 @@ printk("dummy: 0x%08lx, 0x%08lx\n",dummy[0],dummy[1]);
32937 }
32938 if (!size) {
32939 dev_kfree_skb_irq(skb);
32940 - if (vcc) atomic_inc(&vcc->stats->rx_err);
32941 + if (vcc) atomic_inc_unchecked(&vcc->stats->rx_err);
32942 continue;
32943 }
32944 if (!atm_charge(vcc,skb->truesize)) {
32945 @@ -469,7 +469,7 @@ printk("dummy: 0x%08lx, 0x%08lx\n",dummy[0],dummy[1]);
32946 skb->len = size;
32947 ATM_SKB(skb)->vcc = vcc;
32948 vcc->push(vcc,skb);
32949 - atomic_inc(&vcc->stats->rx);
32950 + atomic_inc_unchecked(&vcc->stats->rx);
32951 }
32952 zout(pos & 0xffff,MTA(mbx));
32953 #if 0 /* probably a stupid idea */
32954 @@ -733,7 +733,7 @@ if (*ZATM_PRV_DSC(skb) != (uPD98401_TXPD_V | uPD98401_TXPD_DP |
32955 skb_queue_head(&zatm_vcc->backlog,skb);
32956 break;
32957 }
32958 - atomic_inc(&vcc->stats->tx);
32959 + atomic_inc_unchecked(&vcc->stats->tx);
32960 wake_up(&zatm_vcc->tx_wait);
32961 }
32962
32963 diff --git a/drivers/base/bus.c b/drivers/base/bus.c
32964 index 519865b..e540db3 100644
32965 --- a/drivers/base/bus.c
32966 +++ b/drivers/base/bus.c
32967 @@ -1163,7 +1163,7 @@ int subsys_interface_register(struct subsys_interface *sif)
32968 return -EINVAL;
32969
32970 mutex_lock(&subsys->p->mutex);
32971 - list_add_tail(&sif->node, &subsys->p->interfaces);
32972 + pax_list_add_tail((struct list_head *)&sif->node, &subsys->p->interfaces);
32973 if (sif->add_dev) {
32974 subsys_dev_iter_init(&iter, subsys, NULL, NULL);
32975 while ((dev = subsys_dev_iter_next(&iter)))
32976 @@ -1188,7 +1188,7 @@ void subsys_interface_unregister(struct subsys_interface *sif)
32977 subsys = sif->subsys;
32978
32979 mutex_lock(&subsys->p->mutex);
32980 - list_del_init(&sif->node);
32981 + pax_list_del_init((struct list_head *)&sif->node);
32982 if (sif->remove_dev) {
32983 subsys_dev_iter_init(&iter, subsys, NULL, NULL);
32984 while ((dev = subsys_dev_iter_next(&iter)))
32985 diff --git a/drivers/base/devtmpfs.c b/drivers/base/devtmpfs.c
32986 index 01fc5b0..917801f 100644
32987 --- a/drivers/base/devtmpfs.c
32988 +++ b/drivers/base/devtmpfs.c
32989 @@ -348,7 +348,7 @@ int devtmpfs_mount(const char *mntdir)
32990 if (!thread)
32991 return 0;
32992
32993 - err = sys_mount("devtmpfs", (char *)mntdir, "devtmpfs", MS_SILENT, NULL);
32994 + err = sys_mount((char __force_user *)"devtmpfs", (char __force_user *)mntdir, (char __force_user *)"devtmpfs", MS_SILENT, NULL);
32995 if (err)
32996 printk(KERN_INFO "devtmpfs: error mounting %i\n", err);
32997 else
32998 @@ -373,11 +373,11 @@ static int devtmpfsd(void *p)
32999 *err = sys_unshare(CLONE_NEWNS);
33000 if (*err)
33001 goto out;
33002 - *err = sys_mount("devtmpfs", "/", "devtmpfs", MS_SILENT, options);
33003 + *err = sys_mount((char __force_user *)"devtmpfs", (char __force_user *)"/", (char __force_user *)"devtmpfs", MS_SILENT, (char __force_user *)options);
33004 if (*err)
33005 goto out;
33006 - sys_chdir("/.."); /* will traverse into overmounted root */
33007 - sys_chroot(".");
33008 + sys_chdir((char __force_user *)"/.."); /* will traverse into overmounted root */
33009 + sys_chroot((char __force_user *)".");
33010 complete(&setup_done);
33011 while (1) {
33012 spin_lock(&req_lock);
33013 diff --git a/drivers/base/node.c b/drivers/base/node.c
33014 index fac124a..66bd4ab 100644
33015 --- a/drivers/base/node.c
33016 +++ b/drivers/base/node.c
33017 @@ -625,7 +625,7 @@ static ssize_t print_nodes_state(enum node_states state, char *buf)
33018 struct node_attr {
33019 struct device_attribute attr;
33020 enum node_states state;
33021 -};
33022 +} __do_const;
33023
33024 static ssize_t show_node_state(struct device *dev,
33025 struct device_attribute *attr, char *buf)
33026 diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
33027 index 9a6b05a..2fc8fb9 100644
33028 --- a/drivers/base/power/domain.c
33029 +++ b/drivers/base/power/domain.c
33030 @@ -1850,7 +1850,7 @@ int pm_genpd_attach_cpuidle(struct generic_pm_domain *genpd, int state)
33031 {
33032 struct cpuidle_driver *cpuidle_drv;
33033 struct gpd_cpu_data *cpu_data;
33034 - struct cpuidle_state *idle_state;
33035 + cpuidle_state_no_const *idle_state;
33036 int ret = 0;
33037
33038 if (IS_ERR_OR_NULL(genpd) || state < 0)
33039 @@ -1918,7 +1918,7 @@ int pm_genpd_name_attach_cpuidle(const char *name, int state)
33040 int pm_genpd_detach_cpuidle(struct generic_pm_domain *genpd)
33041 {
33042 struct gpd_cpu_data *cpu_data;
33043 - struct cpuidle_state *idle_state;
33044 + cpuidle_state_no_const *idle_state;
33045 int ret = 0;
33046
33047 if (IS_ERR_OR_NULL(genpd))
33048 diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c
33049 index 79715e7..df06b3b 100644
33050 --- a/drivers/base/power/wakeup.c
33051 +++ b/drivers/base/power/wakeup.c
33052 @@ -29,14 +29,14 @@ bool events_check_enabled __read_mostly;
33053 * They need to be modified together atomically, so it's better to use one
33054 * atomic variable to hold them both.
33055 */
33056 -static atomic_t combined_event_count = ATOMIC_INIT(0);
33057 +static atomic_unchecked_t combined_event_count = ATOMIC_INIT(0);
33058
33059 #define IN_PROGRESS_BITS (sizeof(int) * 4)
33060 #define MAX_IN_PROGRESS ((1 << IN_PROGRESS_BITS) - 1)
33061
33062 static void split_counters(unsigned int *cnt, unsigned int *inpr)
33063 {
33064 - unsigned int comb = atomic_read(&combined_event_count);
33065 + unsigned int comb = atomic_read_unchecked(&combined_event_count);
33066
33067 *cnt = (comb >> IN_PROGRESS_BITS);
33068 *inpr = comb & MAX_IN_PROGRESS;
33069 @@ -395,7 +395,7 @@ static void wakeup_source_activate(struct wakeup_source *ws)
33070 ws->start_prevent_time = ws->last_time;
33071
33072 /* Increment the counter of events in progress. */
33073 - cec = atomic_inc_return(&combined_event_count);
33074 + cec = atomic_inc_return_unchecked(&combined_event_count);
33075
33076 trace_wakeup_source_activate(ws->name, cec);
33077 }
33078 @@ -521,7 +521,7 @@ static void wakeup_source_deactivate(struct wakeup_source *ws)
33079 * Increment the counter of registered wakeup events and decrement the
33080 * couter of wakeup events in progress simultaneously.
33081 */
33082 - cec = atomic_add_return(MAX_IN_PROGRESS, &combined_event_count);
33083 + cec = atomic_add_return_unchecked(MAX_IN_PROGRESS, &combined_event_count);
33084 trace_wakeup_source_deactivate(ws->name, cec);
33085
33086 split_counters(&cnt, &inpr);
33087 diff --git a/drivers/base/syscore.c b/drivers/base/syscore.c
33088 index e8d11b6..7b1b36f 100644
33089 --- a/drivers/base/syscore.c
33090 +++ b/drivers/base/syscore.c
33091 @@ -21,7 +21,7 @@ static DEFINE_MUTEX(syscore_ops_lock);
33092 void register_syscore_ops(struct syscore_ops *ops)
33093 {
33094 mutex_lock(&syscore_ops_lock);
33095 - list_add_tail(&ops->node, &syscore_ops_list);
33096 + pax_list_add_tail((struct list_head *)&ops->node, &syscore_ops_list);
33097 mutex_unlock(&syscore_ops_lock);
33098 }
33099 EXPORT_SYMBOL_GPL(register_syscore_ops);
33100 @@ -33,7 +33,7 @@ EXPORT_SYMBOL_GPL(register_syscore_ops);
33101 void unregister_syscore_ops(struct syscore_ops *ops)
33102 {
33103 mutex_lock(&syscore_ops_lock);
33104 - list_del(&ops->node);
33105 + pax_list_del((struct list_head *)&ops->node);
33106 mutex_unlock(&syscore_ops_lock);
33107 }
33108 EXPORT_SYMBOL_GPL(unregister_syscore_ops);
33109 diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
33110 index 1c1b8e5..b7fc681 100644
33111 --- a/drivers/block/cciss.c
33112 +++ b/drivers/block/cciss.c
33113 @@ -1196,6 +1196,8 @@ static int cciss_ioctl32_passthru(struct block_device *bdev, fmode_t mode,
33114 int err;
33115 u32 cp;
33116
33117 + memset(&arg64, 0, sizeof(arg64));
33118 +
33119 err = 0;
33120 err |=
33121 copy_from_user(&arg64.LUN_info, &arg32->LUN_info,
33122 @@ -3005,7 +3007,7 @@ static void start_io(ctlr_info_t *h)
33123 while (!list_empty(&h->reqQ)) {
33124 c = list_entry(h->reqQ.next, CommandList_struct, list);
33125 /* can't do anything if fifo is full */
33126 - if ((h->access.fifo_full(h))) {
33127 + if ((h->access->fifo_full(h))) {
33128 dev_warn(&h->pdev->dev, "fifo full\n");
33129 break;
33130 }
33131 @@ -3015,7 +3017,7 @@ static void start_io(ctlr_info_t *h)
33132 h->Qdepth--;
33133
33134 /* Tell the controller execute command */
33135 - h->access.submit_command(h, c);
33136 + h->access->submit_command(h, c);
33137
33138 /* Put job onto the completed Q */
33139 addQ(&h->cmpQ, c);
33140 @@ -3441,17 +3443,17 @@ startio:
33141
33142 static inline unsigned long get_next_completion(ctlr_info_t *h)
33143 {
33144 - return h->access.command_completed(h);
33145 + return h->access->command_completed(h);
33146 }
33147
33148 static inline int interrupt_pending(ctlr_info_t *h)
33149 {
33150 - return h->access.intr_pending(h);
33151 + return h->access->intr_pending(h);
33152 }
33153
33154 static inline long interrupt_not_for_us(ctlr_info_t *h)
33155 {
33156 - return ((h->access.intr_pending(h) == 0) ||
33157 + return ((h->access->intr_pending(h) == 0) ||
33158 (h->interrupts_enabled == 0));
33159 }
33160
33161 @@ -3484,7 +3486,7 @@ static inline u32 next_command(ctlr_info_t *h)
33162 u32 a;
33163
33164 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant)))
33165 - return h->access.command_completed(h);
33166 + return h->access->command_completed(h);
33167
33168 if ((*(h->reply_pool_head) & 1) == (h->reply_pool_wraparound)) {
33169 a = *(h->reply_pool_head); /* Next cmd in ring buffer */
33170 @@ -4041,7 +4043,7 @@ static void cciss_put_controller_into_performant_mode(ctlr_info_t *h)
33171 trans_support & CFGTBL_Trans_use_short_tags);
33172
33173 /* Change the access methods to the performant access methods */
33174 - h->access = SA5_performant_access;
33175 + h->access = &SA5_performant_access;
33176 h->transMethod = CFGTBL_Trans_Performant;
33177
33178 return;
33179 @@ -4310,7 +4312,7 @@ static int cciss_pci_init(ctlr_info_t *h)
33180 if (prod_index < 0)
33181 return -ENODEV;
33182 h->product_name = products[prod_index].product_name;
33183 - h->access = *(products[prod_index].access);
33184 + h->access = products[prod_index].access;
33185
33186 if (cciss_board_disabled(h)) {
33187 dev_warn(&h->pdev->dev, "controller appears to be disabled\n");
33188 @@ -5032,7 +5034,7 @@ reinit_after_soft_reset:
33189 }
33190
33191 /* make sure the board interrupts are off */
33192 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
33193 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
33194 rc = cciss_request_irq(h, do_cciss_msix_intr, do_cciss_intx);
33195 if (rc)
33196 goto clean2;
33197 @@ -5082,7 +5084,7 @@ reinit_after_soft_reset:
33198 * fake ones to scoop up any residual completions.
33199 */
33200 spin_lock_irqsave(&h->lock, flags);
33201 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
33202 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
33203 spin_unlock_irqrestore(&h->lock, flags);
33204 free_irq(h->intr[h->intr_mode], h);
33205 rc = cciss_request_irq(h, cciss_msix_discard_completions,
33206 @@ -5102,9 +5104,9 @@ reinit_after_soft_reset:
33207 dev_info(&h->pdev->dev, "Board READY.\n");
33208 dev_info(&h->pdev->dev,
33209 "Waiting for stale completions to drain.\n");
33210 - h->access.set_intr_mask(h, CCISS_INTR_ON);
33211 + h->access->set_intr_mask(h, CCISS_INTR_ON);
33212 msleep(10000);
33213 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
33214 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
33215
33216 rc = controller_reset_failed(h->cfgtable);
33217 if (rc)
33218 @@ -5127,7 +5129,7 @@ reinit_after_soft_reset:
33219 cciss_scsi_setup(h);
33220
33221 /* Turn the interrupts on so we can service requests */
33222 - h->access.set_intr_mask(h, CCISS_INTR_ON);
33223 + h->access->set_intr_mask(h, CCISS_INTR_ON);
33224
33225 /* Get the firmware version */
33226 inq_buff = kzalloc(sizeof(InquiryData_struct), GFP_KERNEL);
33227 @@ -5199,7 +5201,7 @@ static void cciss_shutdown(struct pci_dev *pdev)
33228 kfree(flush_buf);
33229 if (return_code != IO_OK)
33230 dev_warn(&h->pdev->dev, "Error flushing cache\n");
33231 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
33232 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
33233 free_irq(h->intr[h->intr_mode], h);
33234 }
33235
33236 diff --git a/drivers/block/cciss.h b/drivers/block/cciss.h
33237 index 7fda30e..eb5dfe0 100644
33238 --- a/drivers/block/cciss.h
33239 +++ b/drivers/block/cciss.h
33240 @@ -101,7 +101,7 @@ struct ctlr_info
33241 /* information about each logical volume */
33242 drive_info_struct *drv[CISS_MAX_LUN];
33243
33244 - struct access_method access;
33245 + struct access_method *access;
33246
33247 /* queue and queue Info */
33248 struct list_head reqQ;
33249 diff --git a/drivers/block/cpqarray.c b/drivers/block/cpqarray.c
33250 index 3f08713..87d4b4a 100644
33251 --- a/drivers/block/cpqarray.c
33252 +++ b/drivers/block/cpqarray.c
33253 @@ -404,7 +404,7 @@ static int cpqarray_register_ctlr(int i, struct pci_dev *pdev)
33254 if (register_blkdev(COMPAQ_SMART2_MAJOR+i, hba[i]->devname)) {
33255 goto Enomem4;
33256 }
33257 - hba[i]->access.set_intr_mask(hba[i], 0);
33258 + hba[i]->access->set_intr_mask(hba[i], 0);
33259 if (request_irq(hba[i]->intr, do_ida_intr,
33260 IRQF_DISABLED|IRQF_SHARED, hba[i]->devname, hba[i]))
33261 {
33262 @@ -459,7 +459,7 @@ static int cpqarray_register_ctlr(int i, struct pci_dev *pdev)
33263 add_timer(&hba[i]->timer);
33264
33265 /* Enable IRQ now that spinlock and rate limit timer are set up */
33266 - hba[i]->access.set_intr_mask(hba[i], FIFO_NOT_EMPTY);
33267 + hba[i]->access->set_intr_mask(hba[i], FIFO_NOT_EMPTY);
33268
33269 for(j=0; j<NWD; j++) {
33270 struct gendisk *disk = ida_gendisk[i][j];
33271 @@ -694,7 +694,7 @@ DBGINFO(
33272 for(i=0; i<NR_PRODUCTS; i++) {
33273 if (board_id == products[i].board_id) {
33274 c->product_name = products[i].product_name;
33275 - c->access = *(products[i].access);
33276 + c->access = products[i].access;
33277 break;
33278 }
33279 }
33280 @@ -792,7 +792,7 @@ static int cpqarray_eisa_detect(void)
33281 hba[ctlr]->intr = intr;
33282 sprintf(hba[ctlr]->devname, "ida%d", nr_ctlr);
33283 hba[ctlr]->product_name = products[j].product_name;
33284 - hba[ctlr]->access = *(products[j].access);
33285 + hba[ctlr]->access = products[j].access;
33286 hba[ctlr]->ctlr = ctlr;
33287 hba[ctlr]->board_id = board_id;
33288 hba[ctlr]->pci_dev = NULL; /* not PCI */
33289 @@ -980,7 +980,7 @@ static void start_io(ctlr_info_t *h)
33290
33291 while((c = h->reqQ) != NULL) {
33292 /* Can't do anything if we're busy */
33293 - if (h->access.fifo_full(h) == 0)
33294 + if (h->access->fifo_full(h) == 0)
33295 return;
33296
33297 /* Get the first entry from the request Q */
33298 @@ -988,7 +988,7 @@ static void start_io(ctlr_info_t *h)
33299 h->Qdepth--;
33300
33301 /* Tell the controller to do our bidding */
33302 - h->access.submit_command(h, c);
33303 + h->access->submit_command(h, c);
33304
33305 /* Get onto the completion Q */
33306 addQ(&h->cmpQ, c);
33307 @@ -1050,7 +1050,7 @@ static irqreturn_t do_ida_intr(int irq, void *dev_id)
33308 unsigned long flags;
33309 __u32 a,a1;
33310
33311 - istat = h->access.intr_pending(h);
33312 + istat = h->access->intr_pending(h);
33313 /* Is this interrupt for us? */
33314 if (istat == 0)
33315 return IRQ_NONE;
33316 @@ -1061,7 +1061,7 @@ static irqreturn_t do_ida_intr(int irq, void *dev_id)
33317 */
33318 spin_lock_irqsave(IDA_LOCK(h->ctlr), flags);
33319 if (istat & FIFO_NOT_EMPTY) {
33320 - while((a = h->access.command_completed(h))) {
33321 + while((a = h->access->command_completed(h))) {
33322 a1 = a; a &= ~3;
33323 if ((c = h->cmpQ) == NULL)
33324 {
33325 @@ -1195,6 +1195,7 @@ out_passthru:
33326 ida_pci_info_struct pciinfo;
33327
33328 if (!arg) return -EINVAL;
33329 + memset(&pciinfo, 0, sizeof(pciinfo));
33330 pciinfo.bus = host->pci_dev->bus->number;
33331 pciinfo.dev_fn = host->pci_dev->devfn;
33332 pciinfo.board_id = host->board_id;
33333 @@ -1449,11 +1450,11 @@ static int sendcmd(
33334 /*
33335 * Disable interrupt
33336 */
33337 - info_p->access.set_intr_mask(info_p, 0);
33338 + info_p->access->set_intr_mask(info_p, 0);
33339 /* Make sure there is room in the command FIFO */
33340 /* Actually it should be completely empty at this time. */
33341 for (i = 200000; i > 0; i--) {
33342 - temp = info_p->access.fifo_full(info_p);
33343 + temp = info_p->access->fifo_full(info_p);
33344 if (temp != 0) {
33345 break;
33346 }
33347 @@ -1466,7 +1467,7 @@ DBG(
33348 /*
33349 * Send the cmd
33350 */
33351 - info_p->access.submit_command(info_p, c);
33352 + info_p->access->submit_command(info_p, c);
33353 complete = pollcomplete(ctlr);
33354
33355 pci_unmap_single(info_p->pci_dev, (dma_addr_t) c->req.sg[0].addr,
33356 @@ -1549,9 +1550,9 @@ static int revalidate_allvol(ctlr_info_t *host)
33357 * we check the new geometry. Then turn interrupts back on when
33358 * we're done.
33359 */
33360 - host->access.set_intr_mask(host, 0);
33361 + host->access->set_intr_mask(host, 0);
33362 getgeometry(ctlr);
33363 - host->access.set_intr_mask(host, FIFO_NOT_EMPTY);
33364 + host->access->set_intr_mask(host, FIFO_NOT_EMPTY);
33365
33366 for(i=0; i<NWD; i++) {
33367 struct gendisk *disk = ida_gendisk[ctlr][i];
33368 @@ -1591,7 +1592,7 @@ static int pollcomplete(int ctlr)
33369 /* Wait (up to 2 seconds) for a command to complete */
33370
33371 for (i = 200000; i > 0; i--) {
33372 - done = hba[ctlr]->access.command_completed(hba[ctlr]);
33373 + done = hba[ctlr]->access->command_completed(hba[ctlr]);
33374 if (done == 0) {
33375 udelay(10); /* a short fixed delay */
33376 } else
33377 diff --git a/drivers/block/cpqarray.h b/drivers/block/cpqarray.h
33378 index be73e9d..7fbf140 100644
33379 --- a/drivers/block/cpqarray.h
33380 +++ b/drivers/block/cpqarray.h
33381 @@ -99,7 +99,7 @@ struct ctlr_info {
33382 drv_info_t drv[NWD];
33383 struct proc_dir_entry *proc;
33384
33385 - struct access_method access;
33386 + struct access_method *access;
33387
33388 cmdlist_t *reqQ;
33389 cmdlist_t *cmpQ;
33390 diff --git a/drivers/block/drbd/drbd_int.h b/drivers/block/drbd/drbd_int.h
33391 index 6b51afa..17e1191 100644
33392 --- a/drivers/block/drbd/drbd_int.h
33393 +++ b/drivers/block/drbd/drbd_int.h
33394 @@ -582,7 +582,7 @@ struct drbd_epoch {
33395 struct drbd_tconn *tconn;
33396 struct list_head list;
33397 unsigned int barrier_nr;
33398 - atomic_t epoch_size; /* increased on every request added. */
33399 + atomic_unchecked_t epoch_size; /* increased on every request added. */
33400 atomic_t active; /* increased on every req. added, and dec on every finished. */
33401 unsigned long flags;
33402 };
33403 @@ -1011,7 +1011,7 @@ struct drbd_conf {
33404 int al_tr_cycle;
33405 int al_tr_pos; /* position of the next transaction in the journal */
33406 wait_queue_head_t seq_wait;
33407 - atomic_t packet_seq;
33408 + atomic_unchecked_t packet_seq;
33409 unsigned int peer_seq;
33410 spinlock_t peer_seq_lock;
33411 unsigned int minor;
33412 @@ -1527,7 +1527,7 @@ static inline int drbd_setsockopt(struct socket *sock, int level, int optname,
33413 char __user *uoptval;
33414 int err;
33415
33416 - uoptval = (char __user __force *)optval;
33417 + uoptval = (char __force_user *)optval;
33418
33419 set_fs(KERNEL_DS);
33420 if (level == SOL_SOCKET)
33421 diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c
33422 index 54d03d4..332f311 100644
33423 --- a/drivers/block/drbd/drbd_main.c
33424 +++ b/drivers/block/drbd/drbd_main.c
33425 @@ -1317,7 +1317,7 @@ static int _drbd_send_ack(struct drbd_conf *mdev, enum drbd_packet cmd,
33426 p->sector = sector;
33427 p->block_id = block_id;
33428 p->blksize = blksize;
33429 - p->seq_num = cpu_to_be32(atomic_inc_return(&mdev->packet_seq));
33430 + p->seq_num = cpu_to_be32(atomic_inc_return_unchecked(&mdev->packet_seq));
33431 return drbd_send_command(mdev, sock, cmd, sizeof(*p), NULL, 0);
33432 }
33433
33434 @@ -1619,7 +1619,7 @@ int drbd_send_dblock(struct drbd_conf *mdev, struct drbd_request *req)
33435 return -EIO;
33436 p->sector = cpu_to_be64(req->i.sector);
33437 p->block_id = (unsigned long)req;
33438 - p->seq_num = cpu_to_be32(atomic_inc_return(&mdev->packet_seq));
33439 + p->seq_num = cpu_to_be32(atomic_inc_return_unchecked(&mdev->packet_seq));
33440 dp_flags = bio_flags_to_wire(mdev, req->master_bio->bi_rw);
33441 if (mdev->state.conn >= C_SYNC_SOURCE &&
33442 mdev->state.conn <= C_PAUSED_SYNC_T)
33443 @@ -2574,8 +2574,8 @@ void conn_destroy(struct kref *kref)
33444 {
33445 struct drbd_tconn *tconn = container_of(kref, struct drbd_tconn, kref);
33446
33447 - if (atomic_read(&tconn->current_epoch->epoch_size) != 0)
33448 - conn_err(tconn, "epoch_size:%d\n", atomic_read(&tconn->current_epoch->epoch_size));
33449 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size) != 0)
33450 + conn_err(tconn, "epoch_size:%d\n", atomic_read_unchecked(&tconn->current_epoch->epoch_size));
33451 kfree(tconn->current_epoch);
33452
33453 idr_destroy(&tconn->volumes);
33454 diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c
33455 index 2f5fffd..b22a1ae 100644
33456 --- a/drivers/block/drbd/drbd_receiver.c
33457 +++ b/drivers/block/drbd/drbd_receiver.c
33458 @@ -833,7 +833,7 @@ int drbd_connected(struct drbd_conf *mdev)
33459 {
33460 int err;
33461
33462 - atomic_set(&mdev->packet_seq, 0);
33463 + atomic_set_unchecked(&mdev->packet_seq, 0);
33464 mdev->peer_seq = 0;
33465
33466 mdev->state_mutex = mdev->tconn->agreed_pro_version < 100 ?
33467 @@ -1191,7 +1191,7 @@ static enum finish_epoch drbd_may_finish_epoch(struct drbd_tconn *tconn,
33468 do {
33469 next_epoch = NULL;
33470
33471 - epoch_size = atomic_read(&epoch->epoch_size);
33472 + epoch_size = atomic_read_unchecked(&epoch->epoch_size);
33473
33474 switch (ev & ~EV_CLEANUP) {
33475 case EV_PUT:
33476 @@ -1231,7 +1231,7 @@ static enum finish_epoch drbd_may_finish_epoch(struct drbd_tconn *tconn,
33477 rv = FE_DESTROYED;
33478 } else {
33479 epoch->flags = 0;
33480 - atomic_set(&epoch->epoch_size, 0);
33481 + atomic_set_unchecked(&epoch->epoch_size, 0);
33482 /* atomic_set(&epoch->active, 0); is already zero */
33483 if (rv == FE_STILL_LIVE)
33484 rv = FE_RECYCLED;
33485 @@ -1449,7 +1449,7 @@ static int receive_Barrier(struct drbd_tconn *tconn, struct packet_info *pi)
33486 conn_wait_active_ee_empty(tconn);
33487 drbd_flush(tconn);
33488
33489 - if (atomic_read(&tconn->current_epoch->epoch_size)) {
33490 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size)) {
33491 epoch = kmalloc(sizeof(struct drbd_epoch), GFP_NOIO);
33492 if (epoch)
33493 break;
33494 @@ -1462,11 +1462,11 @@ static int receive_Barrier(struct drbd_tconn *tconn, struct packet_info *pi)
33495 }
33496
33497 epoch->flags = 0;
33498 - atomic_set(&epoch->epoch_size, 0);
33499 + atomic_set_unchecked(&epoch->epoch_size, 0);
33500 atomic_set(&epoch->active, 0);
33501
33502 spin_lock(&tconn->epoch_lock);
33503 - if (atomic_read(&tconn->current_epoch->epoch_size)) {
33504 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size)) {
33505 list_add(&epoch->list, &tconn->current_epoch->list);
33506 tconn->current_epoch = epoch;
33507 tconn->epochs++;
33508 @@ -2170,7 +2170,7 @@ static int receive_Data(struct drbd_tconn *tconn, struct packet_info *pi)
33509
33510 err = wait_for_and_update_peer_seq(mdev, peer_seq);
33511 drbd_send_ack_dp(mdev, P_NEG_ACK, p, pi->size);
33512 - atomic_inc(&tconn->current_epoch->epoch_size);
33513 + atomic_inc_unchecked(&tconn->current_epoch->epoch_size);
33514 err2 = drbd_drain_block(mdev, pi->size);
33515 if (!err)
33516 err = err2;
33517 @@ -2204,7 +2204,7 @@ static int receive_Data(struct drbd_tconn *tconn, struct packet_info *pi)
33518
33519 spin_lock(&tconn->epoch_lock);
33520 peer_req->epoch = tconn->current_epoch;
33521 - atomic_inc(&peer_req->epoch->epoch_size);
33522 + atomic_inc_unchecked(&peer_req->epoch->epoch_size);
33523 atomic_inc(&peer_req->epoch->active);
33524 spin_unlock(&tconn->epoch_lock);
33525
33526 @@ -4345,7 +4345,7 @@ struct data_cmd {
33527 int expect_payload;
33528 size_t pkt_size;
33529 int (*fn)(struct drbd_tconn *, struct packet_info *);
33530 -};
33531 +} __do_const;
33532
33533 static struct data_cmd drbd_cmd_handler[] = {
33534 [P_DATA] = { 1, sizeof(struct p_data), receive_Data },
33535 @@ -4465,7 +4465,7 @@ static void conn_disconnect(struct drbd_tconn *tconn)
33536 if (!list_empty(&tconn->current_epoch->list))
33537 conn_err(tconn, "ASSERTION FAILED: tconn->current_epoch->list not empty\n");
33538 /* ok, no more ee's on the fly, it is safe to reset the epoch_size */
33539 - atomic_set(&tconn->current_epoch->epoch_size, 0);
33540 + atomic_set_unchecked(&tconn->current_epoch->epoch_size, 0);
33541 tconn->send.seen_any_write_yet = false;
33542
33543 conn_info(tconn, "Connection closed\n");
33544 @@ -5221,7 +5221,7 @@ static int tconn_finish_peer_reqs(struct drbd_tconn *tconn)
33545 struct asender_cmd {
33546 size_t pkt_size;
33547 int (*fn)(struct drbd_tconn *tconn, struct packet_info *);
33548 -};
33549 +} __do_const;
33550
33551 static struct asender_cmd asender_tbl[] = {
33552 [P_PING] = { 0, got_Ping },
33553 diff --git a/drivers/block/loop.c b/drivers/block/loop.c
33554 index dfe7583..83768bb 100644
33555 --- a/drivers/block/loop.c
33556 +++ b/drivers/block/loop.c
33557 @@ -231,7 +231,7 @@ static int __do_lo_send_write(struct file *file,
33558 mm_segment_t old_fs = get_fs();
33559
33560 set_fs(get_ds());
33561 - bw = file->f_op->write(file, buf, len, &pos);
33562 + bw = file->f_op->write(file, (const char __force_user *)buf, len, &pos);
33563 set_fs(old_fs);
33564 if (likely(bw == len))
33565 return 0;
33566 diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
33567 index 2e7de7a..ed86dc0 100644
33568 --- a/drivers/block/pktcdvd.c
33569 +++ b/drivers/block/pktcdvd.c
33570 @@ -83,7 +83,7 @@
33571
33572 #define MAX_SPEED 0xffff
33573
33574 -#define ZONE(sector, pd) (((sector) + (pd)->offset) & ~((pd)->settings.size - 1))
33575 +#define ZONE(sector, pd) (((sector) + (pd)->offset) & ~((pd)->settings.size - 1UL))
33576
33577 static DEFINE_MUTEX(pktcdvd_mutex);
33578 static struct pktcdvd_device *pkt_devs[MAX_WRITERS];
33579 diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c
33580 index d620b44..e9abc80 100644
33581 --- a/drivers/cdrom/cdrom.c
33582 +++ b/drivers/cdrom/cdrom.c
33583 @@ -416,7 +416,6 @@ int register_cdrom(struct cdrom_device_info *cdi)
33584 ENSURE(reset, CDC_RESET);
33585 ENSURE(generic_packet, CDC_GENERIC_PACKET);
33586 cdi->mc_flags = 0;
33587 - cdo->n_minors = 0;
33588 cdi->options = CDO_USE_FFLAGS;
33589
33590 if (autoclose==1 && CDROM_CAN(CDC_CLOSE_TRAY))
33591 @@ -436,8 +435,11 @@ int register_cdrom(struct cdrom_device_info *cdi)
33592 else
33593 cdi->cdda_method = CDDA_OLD;
33594
33595 - if (!cdo->generic_packet)
33596 - cdo->generic_packet = cdrom_dummy_generic_packet;
33597 + if (!cdo->generic_packet) {
33598 + pax_open_kernel();
33599 + *(void **)&cdo->generic_packet = cdrom_dummy_generic_packet;
33600 + pax_close_kernel();
33601 + }
33602
33603 cdinfo(CD_REG_UNREG, "drive \"/dev/%s\" registered\n", cdi->name);
33604 mutex_lock(&cdrom_mutex);
33605 @@ -458,7 +460,6 @@ void unregister_cdrom(struct cdrom_device_info *cdi)
33606 if (cdi->exit)
33607 cdi->exit(cdi);
33608
33609 - cdi->ops->n_minors--;
33610 cdinfo(CD_REG_UNREG, "drive \"/dev/%s\" unregistered\n", cdi->name);
33611 }
33612
33613 @@ -2107,7 +2108,7 @@ static int cdrom_read_cdda_old(struct cdrom_device_info *cdi, __u8 __user *ubuf,
33614 */
33615 nr = nframes;
33616 do {
33617 - cgc.buffer = kmalloc(CD_FRAMESIZE_RAW * nr, GFP_KERNEL);
33618 + cgc.buffer = kzalloc(CD_FRAMESIZE_RAW * nr, GFP_KERNEL);
33619 if (cgc.buffer)
33620 break;
33621
33622 @@ -2882,7 +2883,7 @@ static noinline int mmc_ioctl_cdrom_read_data(struct cdrom_device_info *cdi,
33623 if (lba < 0)
33624 return -EINVAL;
33625
33626 - cgc->buffer = kmalloc(blocksize, GFP_KERNEL);
33627 + cgc->buffer = kzalloc(blocksize, GFP_KERNEL);
33628 if (cgc->buffer == NULL)
33629 return -ENOMEM;
33630
33631 diff --git a/drivers/cdrom/gdrom.c b/drivers/cdrom/gdrom.c
33632 index d59cdcb..11afddf 100644
33633 --- a/drivers/cdrom/gdrom.c
33634 +++ b/drivers/cdrom/gdrom.c
33635 @@ -491,7 +491,6 @@ static struct cdrom_device_ops gdrom_ops = {
33636 .audio_ioctl = gdrom_audio_ioctl,
33637 .capability = CDC_MULTI_SESSION | CDC_MEDIA_CHANGED |
33638 CDC_RESET | CDC_DRIVE_STATUS | CDC_CD_R,
33639 - .n_minors = 1,
33640 };
33641
33642 static int gdrom_bdops_open(struct block_device *bdev, fmode_t mode)
33643 diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
33644 index 3bb6fa3..34013fb 100644
33645 --- a/drivers/char/Kconfig
33646 +++ b/drivers/char/Kconfig
33647 @@ -8,7 +8,8 @@ source "drivers/tty/Kconfig"
33648
33649 config DEVKMEM
33650 bool "/dev/kmem virtual device support"
33651 - default y
33652 + default n
33653 + depends on !GRKERNSEC_KMEM
33654 help
33655 Say Y here if you want to support the /dev/kmem device. The
33656 /dev/kmem device is rarely used, but can be used for certain
33657 @@ -582,6 +583,7 @@ config DEVPORT
33658 bool
33659 depends on !M68K
33660 depends on ISA || PCI
33661 + depends on !GRKERNSEC_KMEM
33662 default y
33663
33664 source "drivers/s390/char/Kconfig"
33665 diff --git a/drivers/char/agp/compat_ioctl.c b/drivers/char/agp/compat_ioctl.c
33666 index a48e05b..6bac831 100644
33667 --- a/drivers/char/agp/compat_ioctl.c
33668 +++ b/drivers/char/agp/compat_ioctl.c
33669 @@ -108,7 +108,7 @@ static int compat_agpioc_reserve_wrap(struct agp_file_private *priv, void __user
33670 return -ENOMEM;
33671 }
33672
33673 - if (copy_from_user(usegment, (void __user *) ureserve.seg_list,
33674 + if (copy_from_user(usegment, (void __force_user *) ureserve.seg_list,
33675 sizeof(*usegment) * ureserve.seg_count)) {
33676 kfree(usegment);
33677 kfree(ksegment);
33678 diff --git a/drivers/char/agp/frontend.c b/drivers/char/agp/frontend.c
33679 index 2e04433..771f2cc 100644
33680 --- a/drivers/char/agp/frontend.c
33681 +++ b/drivers/char/agp/frontend.c
33682 @@ -817,7 +817,7 @@ static int agpioc_reserve_wrap(struct agp_file_private *priv, void __user *arg)
33683 if (copy_from_user(&reserve, arg, sizeof(struct agp_region)))
33684 return -EFAULT;
33685
33686 - if ((unsigned) reserve.seg_count >= ~0U/sizeof(struct agp_segment))
33687 + if ((unsigned) reserve.seg_count >= ~0U/sizeof(struct agp_segment_priv))
33688 return -EFAULT;
33689
33690 client = agp_find_client_by_pid(reserve.pid);
33691 @@ -847,7 +847,7 @@ static int agpioc_reserve_wrap(struct agp_file_private *priv, void __user *arg)
33692 if (segment == NULL)
33693 return -ENOMEM;
33694
33695 - if (copy_from_user(segment, (void __user *) reserve.seg_list,
33696 + if (copy_from_user(segment, (void __force_user *) reserve.seg_list,
33697 sizeof(struct agp_segment) * reserve.seg_count)) {
33698 kfree(segment);
33699 return -EFAULT;
33700 diff --git a/drivers/char/genrtc.c b/drivers/char/genrtc.c
33701 index 21cb980..f15107c 100644
33702 --- a/drivers/char/genrtc.c
33703 +++ b/drivers/char/genrtc.c
33704 @@ -272,6 +272,7 @@ static int gen_rtc_ioctl(struct file *file,
33705 switch (cmd) {
33706
33707 case RTC_PLL_GET:
33708 + memset(&pll, 0, sizeof(pll));
33709 if (get_rtc_pll(&pll))
33710 return -EINVAL;
33711 else
33712 diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c
33713 index d784650..e8bfd69 100644
33714 --- a/drivers/char/hpet.c
33715 +++ b/drivers/char/hpet.c
33716 @@ -559,7 +559,7 @@ static inline unsigned long hpet_time_div(struct hpets *hpets,
33717 }
33718
33719 static int
33720 -hpet_ioctl_common(struct hpet_dev *devp, int cmd, unsigned long arg,
33721 +hpet_ioctl_common(struct hpet_dev *devp, unsigned int cmd, unsigned long arg,
33722 struct hpet_info *info)
33723 {
33724 struct hpet_timer __iomem *timer;
33725 diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
33726 index 053201b0..8335cce 100644
33727 --- a/drivers/char/ipmi/ipmi_msghandler.c
33728 +++ b/drivers/char/ipmi/ipmi_msghandler.c
33729 @@ -420,7 +420,7 @@ struct ipmi_smi {
33730 struct proc_dir_entry *proc_dir;
33731 char proc_dir_name[10];
33732
33733 - atomic_t stats[IPMI_NUM_STATS];
33734 + atomic_unchecked_t stats[IPMI_NUM_STATS];
33735
33736 /*
33737 * run_to_completion duplicate of smb_info, smi_info
33738 @@ -453,9 +453,9 @@ static DEFINE_MUTEX(smi_watchers_mutex);
33739
33740
33741 #define ipmi_inc_stat(intf, stat) \
33742 - atomic_inc(&(intf)->stats[IPMI_STAT_ ## stat])
33743 + atomic_inc_unchecked(&(intf)->stats[IPMI_STAT_ ## stat])
33744 #define ipmi_get_stat(intf, stat) \
33745 - ((unsigned int) atomic_read(&(intf)->stats[IPMI_STAT_ ## stat]))
33746 + ((unsigned int) atomic_read_unchecked(&(intf)->stats[IPMI_STAT_ ## stat]))
33747
33748 static int is_lan_addr(struct ipmi_addr *addr)
33749 {
33750 @@ -2884,7 +2884,7 @@ int ipmi_register_smi(struct ipmi_smi_handlers *handlers,
33751 INIT_LIST_HEAD(&intf->cmd_rcvrs);
33752 init_waitqueue_head(&intf->waitq);
33753 for (i = 0; i < IPMI_NUM_STATS; i++)
33754 - atomic_set(&intf->stats[i], 0);
33755 + atomic_set_unchecked(&intf->stats[i], 0);
33756
33757 intf->proc_dir = NULL;
33758
33759 diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
33760 index 0ac9b45..6179fb5 100644
33761 --- a/drivers/char/ipmi/ipmi_si_intf.c
33762 +++ b/drivers/char/ipmi/ipmi_si_intf.c
33763 @@ -275,7 +275,7 @@ struct smi_info {
33764 unsigned char slave_addr;
33765
33766 /* Counters and things for the proc filesystem. */
33767 - atomic_t stats[SI_NUM_STATS];
33768 + atomic_unchecked_t stats[SI_NUM_STATS];
33769
33770 struct task_struct *thread;
33771
33772 @@ -284,9 +284,9 @@ struct smi_info {
33773 };
33774
33775 #define smi_inc_stat(smi, stat) \
33776 - atomic_inc(&(smi)->stats[SI_STAT_ ## stat])
33777 + atomic_inc_unchecked(&(smi)->stats[SI_STAT_ ## stat])
33778 #define smi_get_stat(smi, stat) \
33779 - ((unsigned int) atomic_read(&(smi)->stats[SI_STAT_ ## stat]))
33780 + ((unsigned int) atomic_read_unchecked(&(smi)->stats[SI_STAT_ ## stat]))
33781
33782 #define SI_MAX_PARMS 4
33783
33784 @@ -3254,7 +3254,7 @@ static int try_smi_init(struct smi_info *new_smi)
33785 atomic_set(&new_smi->req_events, 0);
33786 new_smi->run_to_completion = 0;
33787 for (i = 0; i < SI_NUM_STATS; i++)
33788 - atomic_set(&new_smi->stats[i], 0);
33789 + atomic_set_unchecked(&new_smi->stats[i], 0);
33790
33791 new_smi->interrupt_disabled = 1;
33792 atomic_set(&new_smi->stop_operation, 0);
33793 diff --git a/drivers/char/mem.c b/drivers/char/mem.c
33794 index 2c644af..d4d7f17 100644
33795 --- a/drivers/char/mem.c
33796 +++ b/drivers/char/mem.c
33797 @@ -18,6 +18,7 @@
33798 #include <linux/raw.h>
33799 #include <linux/tty.h>
33800 #include <linux/capability.h>
33801 +#include <linux/security.h>
33802 #include <linux/ptrace.h>
33803 #include <linux/device.h>
33804 #include <linux/highmem.h>
33805 @@ -37,6 +38,10 @@
33806
33807 #define DEVPORT_MINOR 4
33808
33809 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
33810 +extern const struct file_operations grsec_fops;
33811 +#endif
33812 +
33813 static inline unsigned long size_inside_page(unsigned long start,
33814 unsigned long size)
33815 {
33816 @@ -68,9 +73,13 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
33817
33818 while (cursor < to) {
33819 if (!devmem_is_allowed(pfn)) {
33820 +#ifdef CONFIG_GRKERNSEC_KMEM
33821 + gr_handle_mem_readwrite(from, to);
33822 +#else
33823 printk(KERN_INFO
33824 "Program %s tried to access /dev/mem between %Lx->%Lx.\n",
33825 current->comm, from, to);
33826 +#endif
33827 return 0;
33828 }
33829 cursor += PAGE_SIZE;
33830 @@ -78,6 +87,11 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
33831 }
33832 return 1;
33833 }
33834 +#elif defined(CONFIG_GRKERNSEC_KMEM)
33835 +static inline int range_is_allowed(unsigned long pfn, unsigned long size)
33836 +{
33837 + return 0;
33838 +}
33839 #else
33840 static inline int range_is_allowed(unsigned long pfn, unsigned long size)
33841 {
33842 @@ -120,6 +134,7 @@ static ssize_t read_mem(struct file *file, char __user *buf,
33843
33844 while (count > 0) {
33845 unsigned long remaining;
33846 + char *temp;
33847
33848 sz = size_inside_page(p, count);
33849
33850 @@ -135,7 +150,23 @@ static ssize_t read_mem(struct file *file, char __user *buf,
33851 if (!ptr)
33852 return -EFAULT;
33853
33854 - remaining = copy_to_user(buf, ptr, sz);
33855 +#ifdef CONFIG_PAX_USERCOPY
33856 + temp = kmalloc(sz, GFP_KERNEL|GFP_USERCOPY);
33857 + if (!temp) {
33858 + unxlate_dev_mem_ptr(p, ptr);
33859 + return -ENOMEM;
33860 + }
33861 + memcpy(temp, ptr, sz);
33862 +#else
33863 + temp = ptr;
33864 +#endif
33865 +
33866 + remaining = copy_to_user(buf, temp, sz);
33867 +
33868 +#ifdef CONFIG_PAX_USERCOPY
33869 + kfree(temp);
33870 +#endif
33871 +
33872 unxlate_dev_mem_ptr(p, ptr);
33873 if (remaining)
33874 return -EFAULT;
33875 @@ -378,7 +409,7 @@ static ssize_t read_oldmem(struct file *file, char __user *buf,
33876 else
33877 csize = count;
33878
33879 - rc = copy_oldmem_page(pfn, buf, csize, offset, 1);
33880 + rc = copy_oldmem_page(pfn, (char __force_kernel *)buf, csize, offset, 1);
33881 if (rc < 0)
33882 return rc;
33883 buf += csize;
33884 @@ -398,9 +429,8 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
33885 size_t count, loff_t *ppos)
33886 {
33887 unsigned long p = *ppos;
33888 - ssize_t low_count, read, sz;
33889 + ssize_t low_count, read, sz, err = 0;
33890 char *kbuf; /* k-addr because vread() takes vmlist_lock rwlock */
33891 - int err = 0;
33892
33893 read = 0;
33894 if (p < (unsigned long) high_memory) {
33895 @@ -422,6 +452,8 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
33896 }
33897 #endif
33898 while (low_count > 0) {
33899 + char *temp;
33900 +
33901 sz = size_inside_page(p, low_count);
33902
33903 /*
33904 @@ -431,7 +463,22 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
33905 */
33906 kbuf = xlate_dev_kmem_ptr((char *)p);
33907
33908 - if (copy_to_user(buf, kbuf, sz))
33909 +#ifdef CONFIG_PAX_USERCOPY
33910 + temp = kmalloc(sz, GFP_KERNEL|GFP_USERCOPY);
33911 + if (!temp)
33912 + return -ENOMEM;
33913 + memcpy(temp, kbuf, sz);
33914 +#else
33915 + temp = kbuf;
33916 +#endif
33917 +
33918 + err = copy_to_user(buf, temp, sz);
33919 +
33920 +#ifdef CONFIG_PAX_USERCOPY
33921 + kfree(temp);
33922 +#endif
33923 +
33924 + if (err)
33925 return -EFAULT;
33926 buf += sz;
33927 p += sz;
33928 @@ -833,6 +880,9 @@ static const struct memdev {
33929 #ifdef CONFIG_CRASH_DUMP
33930 [12] = { "oldmem", 0, &oldmem_fops, NULL },
33931 #endif
33932 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
33933 + [13] = { "grsec",S_IRUSR | S_IWUGO, &grsec_fops, NULL },
33934 +#endif
33935 };
33936
33937 static int memory_open(struct inode *inode, struct file *filp)
33938 diff --git a/drivers/char/mwave/tp3780i.c b/drivers/char/mwave/tp3780i.c
33939 index c689697..04e6d6a 100644
33940 --- a/drivers/char/mwave/tp3780i.c
33941 +++ b/drivers/char/mwave/tp3780i.c
33942 @@ -479,6 +479,7 @@ int tp3780I_QueryAbilities(THINKPAD_BD_DATA * pBDData, MW_ABILITIES * pAbilities
33943 PRINTK_2(TRACE_TP3780I,
33944 "tp3780i::tp3780I_QueryAbilities entry pBDData %p\n", pBDData);
33945
33946 + memset(pAbilities, 0, sizeof(*pAbilities));
33947 /* fill out standard constant fields */
33948 pAbilities->instr_per_sec = pBDData->rDspSettings.uIps;
33949 pAbilities->data_size = pBDData->rDspSettings.uDStoreSize;
33950 diff --git a/drivers/char/nvram.c b/drivers/char/nvram.c
33951 index 9df78e2..01ba9ae 100644
33952 --- a/drivers/char/nvram.c
33953 +++ b/drivers/char/nvram.c
33954 @@ -247,7 +247,7 @@ static ssize_t nvram_read(struct file *file, char __user *buf,
33955
33956 spin_unlock_irq(&rtc_lock);
33957
33958 - if (copy_to_user(buf, contents, tmp - contents))
33959 + if (tmp - contents > sizeof(contents) || copy_to_user(buf, contents, tmp - contents))
33960 return -EFAULT;
33961
33962 *ppos = i;
33963 diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c
33964 index 5c5cc00..ac9edb7 100644
33965 --- a/drivers/char/pcmcia/synclink_cs.c
33966 +++ b/drivers/char/pcmcia/synclink_cs.c
33967 @@ -2345,9 +2345,9 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp)
33968
33969 if (debug_level >= DEBUG_LEVEL_INFO)
33970 printk("%s(%d):mgslpc_close(%s) entry, count=%d\n",
33971 - __FILE__, __LINE__, info->device_name, port->count);
33972 + __FILE__, __LINE__, info->device_name, atomic_read(&port->count));
33973
33974 - WARN_ON(!port->count);
33975 + WARN_ON(!atomic_read(&port->count));
33976
33977 if (tty_port_close_start(port, tty, filp) == 0)
33978 goto cleanup;
33979 @@ -2365,7 +2365,7 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp)
33980 cleanup:
33981 if (debug_level >= DEBUG_LEVEL_INFO)
33982 printk("%s(%d):mgslpc_close(%s) exit, count=%d\n", __FILE__, __LINE__,
33983 - tty->driver->name, port->count);
33984 + tty->driver->name, atomic_read(&port->count));
33985 }
33986
33987 /* Wait until the transmitter is empty.
33988 @@ -2507,7 +2507,7 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp)
33989
33990 if (debug_level >= DEBUG_LEVEL_INFO)
33991 printk("%s(%d):mgslpc_open(%s), old ref count = %d\n",
33992 - __FILE__, __LINE__, tty->driver->name, port->count);
33993 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
33994
33995 /* If port is closing, signal caller to try again */
33996 if (tty_hung_up_p(filp) || port->flags & ASYNC_CLOSING){
33997 @@ -2527,11 +2527,11 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp)
33998 goto cleanup;
33999 }
34000 spin_lock(&port->lock);
34001 - port->count++;
34002 + atomic_inc(&port->count);
34003 spin_unlock(&port->lock);
34004 spin_unlock_irqrestore(&info->netlock, flags);
34005
34006 - if (port->count == 1) {
34007 + if (atomic_read(&port->count) == 1) {
34008 /* 1st open on this device, init hardware */
34009 retval = startup(info, tty);
34010 if (retval < 0)
34011 @@ -3920,7 +3920,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
34012 unsigned short new_crctype;
34013
34014 /* return error if TTY interface open */
34015 - if (info->port.count)
34016 + if (atomic_read(&info->port.count))
34017 return -EBUSY;
34018
34019 switch (encoding)
34020 @@ -4024,7 +4024,7 @@ static int hdlcdev_open(struct net_device *dev)
34021
34022 /* arbitrate between network and tty opens */
34023 spin_lock_irqsave(&info->netlock, flags);
34024 - if (info->port.count != 0 || info->netcount != 0) {
34025 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
34026 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
34027 spin_unlock_irqrestore(&info->netlock, flags);
34028 return -EBUSY;
34029 @@ -4114,7 +4114,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
34030 printk("%s:hdlcdev_ioctl(%s)\n", __FILE__, dev->name);
34031
34032 /* return error if TTY interface open */
34033 - if (info->port.count)
34034 + if (atomic_read(&info->port.count))
34035 return -EBUSY;
34036
34037 if (cmd != SIOCWANDEV)
34038 diff --git a/drivers/char/random.c b/drivers/char/random.c
34039 index eccd7cc..98038d5 100644
34040 --- a/drivers/char/random.c
34041 +++ b/drivers/char/random.c
34042 @@ -272,8 +272,13 @@
34043 /*
34044 * Configuration information
34045 */
34046 +#ifdef CONFIG_GRKERNSEC_RANDNET
34047 +#define INPUT_POOL_WORDS 512
34048 +#define OUTPUT_POOL_WORDS 128
34049 +#else
34050 #define INPUT_POOL_WORDS 128
34051 #define OUTPUT_POOL_WORDS 32
34052 +#endif
34053 #define SEC_XFER_SIZE 512
34054 #define EXTRACT_SIZE 10
34055
34056 @@ -313,10 +318,17 @@ static struct poolinfo {
34057 int poolwords;
34058 int tap1, tap2, tap3, tap4, tap5;
34059 } poolinfo_table[] = {
34060 +#ifdef CONFIG_GRKERNSEC_RANDNET
34061 + /* x^512 + x^411 + x^308 + x^208 +x^104 + x + 1 -- 225 */
34062 + { 512, 411, 308, 208, 104, 1 },
34063 + /* x^128 + x^103 + x^76 + x^51 + x^25 + x + 1 -- 105 */
34064 + { 128, 103, 76, 51, 25, 1 },
34065 +#else
34066 /* x^128 + x^103 + x^76 + x^51 +x^25 + x + 1 -- 105 */
34067 { 128, 103, 76, 51, 25, 1 },
34068 /* x^32 + x^26 + x^20 + x^14 + x^7 + x + 1 -- 15 */
34069 { 32, 26, 20, 14, 7, 1 },
34070 +#endif
34071 #if 0
34072 /* x^2048 + x^1638 + x^1231 + x^819 + x^411 + x + 1 -- 115 */
34073 { 2048, 1638, 1231, 819, 411, 1 },
34074 @@ -524,8 +536,8 @@ static void _mix_pool_bytes(struct entropy_store *r, const void *in,
34075 input_rotate += i ? 7 : 14;
34076 }
34077
34078 - ACCESS_ONCE(r->input_rotate) = input_rotate;
34079 - ACCESS_ONCE(r->add_ptr) = i;
34080 + ACCESS_ONCE_RW(r->input_rotate) = input_rotate;
34081 + ACCESS_ONCE_RW(r->add_ptr) = i;
34082 smp_wmb();
34083
34084 if (out)
34085 @@ -1032,7 +1044,7 @@ static ssize_t extract_entropy_user(struct entropy_store *r, void __user *buf,
34086
34087 extract_buf(r, tmp);
34088 i = min_t(int, nbytes, EXTRACT_SIZE);
34089 - if (copy_to_user(buf, tmp, i)) {
34090 + if (i > sizeof(tmp) || copy_to_user(buf, tmp, i)) {
34091 ret = -EFAULT;
34092 break;
34093 }
34094 @@ -1368,7 +1380,7 @@ EXPORT_SYMBOL(generate_random_uuid);
34095 #include <linux/sysctl.h>
34096
34097 static int min_read_thresh = 8, min_write_thresh;
34098 -static int max_read_thresh = INPUT_POOL_WORDS * 32;
34099 +static int max_read_thresh = OUTPUT_POOL_WORDS * 32;
34100 static int max_write_thresh = INPUT_POOL_WORDS * 32;
34101 static char sysctl_bootid[16];
34102
34103 @@ -1384,7 +1396,7 @@ static char sysctl_bootid[16];
34104 static int proc_do_uuid(ctl_table *table, int write,
34105 void __user *buffer, size_t *lenp, loff_t *ppos)
34106 {
34107 - ctl_table fake_table;
34108 + ctl_table_no_const fake_table;
34109 unsigned char buf[64], tmp_uuid[16], *uuid;
34110
34111 uuid = table->data;
34112 diff --git a/drivers/char/sonypi.c b/drivers/char/sonypi.c
34113 index bf2349db..5456d53 100644
34114 --- a/drivers/char/sonypi.c
34115 +++ b/drivers/char/sonypi.c
34116 @@ -54,6 +54,7 @@
34117
34118 #include <asm/uaccess.h>
34119 #include <asm/io.h>
34120 +#include <asm/local.h>
34121
34122 #include <linux/sonypi.h>
34123
34124 @@ -490,7 +491,7 @@ static struct sonypi_device {
34125 spinlock_t fifo_lock;
34126 wait_queue_head_t fifo_proc_list;
34127 struct fasync_struct *fifo_async;
34128 - int open_count;
34129 + local_t open_count;
34130 int model;
34131 struct input_dev *input_jog_dev;
34132 struct input_dev *input_key_dev;
34133 @@ -897,7 +898,7 @@ static int sonypi_misc_fasync(int fd, struct file *filp, int on)
34134 static int sonypi_misc_release(struct inode *inode, struct file *file)
34135 {
34136 mutex_lock(&sonypi_device.lock);
34137 - sonypi_device.open_count--;
34138 + local_dec(&sonypi_device.open_count);
34139 mutex_unlock(&sonypi_device.lock);
34140 return 0;
34141 }
34142 @@ -906,9 +907,9 @@ static int sonypi_misc_open(struct inode *inode, struct file *file)
34143 {
34144 mutex_lock(&sonypi_device.lock);
34145 /* Flush input queue on first open */
34146 - if (!sonypi_device.open_count)
34147 + if (!local_read(&sonypi_device.open_count))
34148 kfifo_reset(&sonypi_device.fifo);
34149 - sonypi_device.open_count++;
34150 + local_inc(&sonypi_device.open_count);
34151 mutex_unlock(&sonypi_device.lock);
34152
34153 return 0;
34154 diff --git a/drivers/char/tpm/tpm_acpi.c b/drivers/char/tpm/tpm_acpi.c
34155 index 64420b3..5c40b56 100644
34156 --- a/drivers/char/tpm/tpm_acpi.c
34157 +++ b/drivers/char/tpm/tpm_acpi.c
34158 @@ -98,11 +98,12 @@ int read_log(struct tpm_bios_log *log)
34159 virt = acpi_os_map_memory(start, len);
34160 if (!virt) {
34161 kfree(log->bios_event_log);
34162 + log->bios_event_log = NULL;
34163 printk("%s: ERROR - Unable to map memory\n", __func__);
34164 return -EIO;
34165 }
34166
34167 - memcpy_fromio(log->bios_event_log, virt, len);
34168 + memcpy_fromio(log->bios_event_log, (const char __force_kernel *)virt, len);
34169
34170 acpi_os_unmap_memory(virt, len);
34171 return 0;
34172 diff --git a/drivers/char/tpm/tpm_eventlog.c b/drivers/char/tpm/tpm_eventlog.c
34173 index 84ddc55..1d32f1e 100644
34174 --- a/drivers/char/tpm/tpm_eventlog.c
34175 +++ b/drivers/char/tpm/tpm_eventlog.c
34176 @@ -95,7 +95,7 @@ static void *tpm_bios_measurements_start(struct seq_file *m, loff_t *pos)
34177 event = addr;
34178
34179 if ((event->event_type == 0 && event->event_size == 0) ||
34180 - ((addr + sizeof(struct tcpa_event) + event->event_size) >= limit))
34181 + (event->event_size >= limit - addr - sizeof(struct tcpa_event)))
34182 return NULL;
34183
34184 return addr;
34185 @@ -120,7 +120,7 @@ static void *tpm_bios_measurements_next(struct seq_file *m, void *v,
34186 return NULL;
34187
34188 if ((event->event_type == 0 && event->event_size == 0) ||
34189 - ((v + sizeof(struct tcpa_event) + event->event_size) >= limit))
34190 + (event->event_size >= limit - v - sizeof(struct tcpa_event)))
34191 return NULL;
34192
34193 (*pos)++;
34194 @@ -213,7 +213,8 @@ static int tpm_binary_bios_measurements_show(struct seq_file *m, void *v)
34195 int i;
34196
34197 for (i = 0; i < sizeof(struct tcpa_event) + event->event_size; i++)
34198 - seq_putc(m, data[i]);
34199 + if (!seq_putc(m, data[i]))
34200 + return -EFAULT;
34201
34202 return 0;
34203 }
34204 diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
34205 index ce5f3fc..e2d3e55 100644
34206 --- a/drivers/char/virtio_console.c
34207 +++ b/drivers/char/virtio_console.c
34208 @@ -679,7 +679,7 @@ static ssize_t fill_readbuf(struct port *port, char *out_buf, size_t out_count,
34209 if (to_user) {
34210 ssize_t ret;
34211
34212 - ret = copy_to_user(out_buf, buf->buf + buf->offset, out_count);
34213 + ret = copy_to_user((char __force_user *)out_buf, buf->buf + buf->offset, out_count);
34214 if (ret)
34215 return -EFAULT;
34216 } else {
34217 @@ -778,7 +778,7 @@ static ssize_t port_fops_read(struct file *filp, char __user *ubuf,
34218 if (!port_has_data(port) && !port->host_connected)
34219 return 0;
34220
34221 - return fill_readbuf(port, ubuf, count, true);
34222 + return fill_readbuf(port, (char __force_kernel *)ubuf, count, true);
34223 }
34224
34225 static int wait_port_writable(struct port *port, bool nonblock)
34226 diff --git a/drivers/clocksource/arm_arch_timer.c b/drivers/clocksource/arm_arch_timer.c
34227 index d7ad425..3e3f81f 100644
34228 --- a/drivers/clocksource/arm_arch_timer.c
34229 +++ b/drivers/clocksource/arm_arch_timer.c
34230 @@ -262,7 +262,7 @@ static int __cpuinit arch_timer_cpu_notify(struct notifier_block *self,
34231 return NOTIFY_OK;
34232 }
34233
34234 -static struct notifier_block arch_timer_cpu_nb __cpuinitdata = {
34235 +static struct notifier_block arch_timer_cpu_nb = {
34236 .notifier_call = arch_timer_cpu_notify,
34237 };
34238
34239 diff --git a/drivers/clocksource/metag_generic.c b/drivers/clocksource/metag_generic.c
34240 index ade7513..069445f 100644
34241 --- a/drivers/clocksource/metag_generic.c
34242 +++ b/drivers/clocksource/metag_generic.c
34243 @@ -169,7 +169,7 @@ static int __cpuinit arch_timer_cpu_notify(struct notifier_block *self,
34244 return NOTIFY_OK;
34245 }
34246
34247 -static struct notifier_block __cpuinitdata arch_timer_cpu_nb = {
34248 +static struct notifier_block arch_timer_cpu_nb = {
34249 .notifier_call = arch_timer_cpu_notify,
34250 };
34251
34252 diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c
34253 index 57a8774..545e993 100644
34254 --- a/drivers/cpufreq/acpi-cpufreq.c
34255 +++ b/drivers/cpufreq/acpi-cpufreq.c
34256 @@ -172,7 +172,7 @@ static ssize_t show_global_boost(struct kobject *kobj,
34257 return sprintf(buf, "%u\n", boost_enabled);
34258 }
34259
34260 -static struct global_attr global_boost = __ATTR(boost, 0644,
34261 +static global_attr_no_const global_boost = __ATTR(boost, 0644,
34262 show_global_boost,
34263 store_global_boost);
34264
34265 @@ -712,8 +712,11 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
34266 data->acpi_data = per_cpu_ptr(acpi_perf_data, cpu);
34267 per_cpu(acfreq_data, cpu) = data;
34268
34269 - if (cpu_has(c, X86_FEATURE_CONSTANT_TSC))
34270 - acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS;
34271 + if (cpu_has(c, X86_FEATURE_CONSTANT_TSC)) {
34272 + pax_open_kernel();
34273 + *(u8 *)&acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS;
34274 + pax_close_kernel();
34275 + }
34276
34277 result = acpi_processor_register_performance(data->acpi_data, cpu);
34278 if (result)
34279 @@ -839,7 +842,9 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
34280 policy->cur = acpi_cpufreq_guess_freq(data, policy->cpu);
34281 break;
34282 case ACPI_ADR_SPACE_FIXED_HARDWARE:
34283 - acpi_cpufreq_driver.get = get_cur_freq_on_cpu;
34284 + pax_open_kernel();
34285 + *(void **)&acpi_cpufreq_driver.get = get_cur_freq_on_cpu;
34286 + pax_close_kernel();
34287 policy->cur = get_cur_freq_on_cpu(cpu);
34288 break;
34289 default:
34290 @@ -850,8 +855,11 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
34291 acpi_processor_notify_smm(THIS_MODULE);
34292
34293 /* Check for APERF/MPERF support in hardware */
34294 - if (boot_cpu_has(X86_FEATURE_APERFMPERF))
34295 - acpi_cpufreq_driver.getavg = cpufreq_get_measured_perf;
34296 + if (boot_cpu_has(X86_FEATURE_APERFMPERF)) {
34297 + pax_open_kernel();
34298 + *(void **)&acpi_cpufreq_driver.getavg = cpufreq_get_measured_perf;
34299 + pax_close_kernel();
34300 + }
34301
34302 pr_debug("CPU%u - ACPI performance management activated.\n", cpu);
34303 for (i = 0; i < perf->state_count; i++)
34304 diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
34305 index b02824d..51e44aa 100644
34306 --- a/drivers/cpufreq/cpufreq.c
34307 +++ b/drivers/cpufreq/cpufreq.c
34308 @@ -1813,7 +1813,7 @@ static int __cpuinit cpufreq_cpu_callback(struct notifier_block *nfb,
34309 return NOTIFY_OK;
34310 }
34311
34312 -static struct notifier_block __refdata cpufreq_cpu_notifier = {
34313 +static struct notifier_block cpufreq_cpu_notifier = {
34314 .notifier_call = cpufreq_cpu_callback,
34315 };
34316
34317 @@ -1845,8 +1845,11 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data)
34318
34319 pr_debug("trying to register driver %s\n", driver_data->name);
34320
34321 - if (driver_data->setpolicy)
34322 - driver_data->flags |= CPUFREQ_CONST_LOOPS;
34323 + if (driver_data->setpolicy) {
34324 + pax_open_kernel();
34325 + *(u8 *)&driver_data->flags |= CPUFREQ_CONST_LOOPS;
34326 + pax_close_kernel();
34327 + }
34328
34329 spin_lock_irqsave(&cpufreq_driver_lock, flags);
34330 if (cpufreq_driver) {
34331 diff --git a/drivers/cpufreq/cpufreq_governor.c b/drivers/cpufreq/cpufreq_governor.c
34332 index 5a76086..0f4d394 100644
34333 --- a/drivers/cpufreq/cpufreq_governor.c
34334 +++ b/drivers/cpufreq/cpufreq_governor.c
34335 @@ -201,8 +201,8 @@ int cpufreq_governor_dbs(struct dbs_data *dbs_data,
34336 {
34337 struct od_cpu_dbs_info_s *od_dbs_info = NULL;
34338 struct cs_cpu_dbs_info_s *cs_dbs_info = NULL;
34339 - struct cs_ops *cs_ops = NULL;
34340 - struct od_ops *od_ops = NULL;
34341 + const struct cs_ops *cs_ops = NULL;
34342 + const struct od_ops *od_ops = NULL;
34343 struct od_dbs_tuners *od_tuners = dbs_data->tuners;
34344 struct cs_dbs_tuners *cs_tuners = dbs_data->tuners;
34345 struct cpu_dbs_common_info *cpu_cdbs;
34346 diff --git a/drivers/cpufreq/cpufreq_governor.h b/drivers/cpufreq/cpufreq_governor.h
34347 index cc4bd2f..ad142bc 100644
34348 --- a/drivers/cpufreq/cpufreq_governor.h
34349 +++ b/drivers/cpufreq/cpufreq_governor.h
34350 @@ -142,7 +142,7 @@ struct dbs_data {
34351 void (*gov_check_cpu)(int cpu, unsigned int load);
34352
34353 /* Governor specific ops, see below */
34354 - void *gov_ops;
34355 + const void *gov_ops;
34356 };
34357
34358 /* Governor specific ops, will be passed to dbs_data->gov_ops */
34359 diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c
34360 index bfd6273..e39dd63 100644
34361 --- a/drivers/cpufreq/cpufreq_stats.c
34362 +++ b/drivers/cpufreq/cpufreq_stats.c
34363 @@ -365,7 +365,7 @@ static int __cpuinit cpufreq_stat_cpu_callback(struct notifier_block *nfb,
34364 }
34365
34366 /* priority=1 so this will get called before cpufreq_remove_dev */
34367 -static struct notifier_block cpufreq_stat_cpu_notifier __refdata = {
34368 +static struct notifier_block cpufreq_stat_cpu_notifier = {
34369 .notifier_call = cpufreq_stat_cpu_callback,
34370 .priority = 1,
34371 };
34372 diff --git a/drivers/cpufreq/p4-clockmod.c b/drivers/cpufreq/p4-clockmod.c
34373 index 827629c9..0bc6a03 100644
34374 --- a/drivers/cpufreq/p4-clockmod.c
34375 +++ b/drivers/cpufreq/p4-clockmod.c
34376 @@ -167,10 +167,14 @@ static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c)
34377 case 0x0F: /* Core Duo */
34378 case 0x16: /* Celeron Core */
34379 case 0x1C: /* Atom */
34380 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34381 + pax_open_kernel();
34382 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34383 + pax_close_kernel();
34384 return speedstep_get_frequency(SPEEDSTEP_CPU_PCORE);
34385 case 0x0D: /* Pentium M (Dothan) */
34386 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34387 + pax_open_kernel();
34388 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34389 + pax_close_kernel();
34390 /* fall through */
34391 case 0x09: /* Pentium M (Banias) */
34392 return speedstep_get_frequency(SPEEDSTEP_CPU_PM);
34393 @@ -182,7 +186,9 @@ static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c)
34394
34395 /* on P-4s, the TSC runs with constant frequency independent whether
34396 * throttling is active or not. */
34397 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34398 + pax_open_kernel();
34399 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34400 + pax_close_kernel();
34401
34402 if (speedstep_detect_processor() == SPEEDSTEP_CPU_P4M) {
34403 printk(KERN_WARNING PFX "Warning: Pentium 4-M detected. "
34404 diff --git a/drivers/cpufreq/speedstep-centrino.c b/drivers/cpufreq/speedstep-centrino.c
34405 index 3a953d5..f5993f6 100644
34406 --- a/drivers/cpufreq/speedstep-centrino.c
34407 +++ b/drivers/cpufreq/speedstep-centrino.c
34408 @@ -353,8 +353,11 @@ static int centrino_cpu_init(struct cpufreq_policy *policy)
34409 !cpu_has(cpu, X86_FEATURE_EST))
34410 return -ENODEV;
34411
34412 - if (cpu_has(cpu, X86_FEATURE_CONSTANT_TSC))
34413 - centrino_driver.flags |= CPUFREQ_CONST_LOOPS;
34414 + if (cpu_has(cpu, X86_FEATURE_CONSTANT_TSC)) {
34415 + pax_open_kernel();
34416 + *(u8 *)&centrino_driver.flags |= CPUFREQ_CONST_LOOPS;
34417 + pax_close_kernel();
34418 + }
34419
34420 if (policy->cpu != 0)
34421 return -ENODEV;
34422 diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
34423 index eba6929..0f53baf 100644
34424 --- a/drivers/cpuidle/cpuidle.c
34425 +++ b/drivers/cpuidle/cpuidle.c
34426 @@ -277,7 +277,7 @@ static int poll_idle(struct cpuidle_device *dev,
34427
34428 static void poll_idle_init(struct cpuidle_driver *drv)
34429 {
34430 - struct cpuidle_state *state = &drv->states[0];
34431 + cpuidle_state_no_const *state = &drv->states[0];
34432
34433 snprintf(state->name, CPUIDLE_NAME_LEN, "POLL");
34434 snprintf(state->desc, CPUIDLE_DESC_LEN, "CPUIDLE CORE POLL IDLE");
34435 diff --git a/drivers/cpuidle/governor.c b/drivers/cpuidle/governor.c
34436 index ea2f8e7..70ac501 100644
34437 --- a/drivers/cpuidle/governor.c
34438 +++ b/drivers/cpuidle/governor.c
34439 @@ -87,7 +87,7 @@ int cpuidle_register_governor(struct cpuidle_governor *gov)
34440 mutex_lock(&cpuidle_lock);
34441 if (__cpuidle_find_governor(gov->name) == NULL) {
34442 ret = 0;
34443 - list_add_tail(&gov->governor_list, &cpuidle_governors);
34444 + pax_list_add_tail((struct list_head *)&gov->governor_list, &cpuidle_governors);
34445 if (!cpuidle_curr_governor ||
34446 cpuidle_curr_governor->rating < gov->rating)
34447 cpuidle_switch_governor(gov);
34448 @@ -135,7 +135,7 @@ void cpuidle_unregister_governor(struct cpuidle_governor *gov)
34449 new_gov = cpuidle_replace_governor(gov->rating);
34450 cpuidle_switch_governor(new_gov);
34451 }
34452 - list_del(&gov->governor_list);
34453 + pax_list_del((struct list_head *)&gov->governor_list);
34454 mutex_unlock(&cpuidle_lock);
34455 }
34456
34457 diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c
34458 index 428754a..8bdf9cc 100644
34459 --- a/drivers/cpuidle/sysfs.c
34460 +++ b/drivers/cpuidle/sysfs.c
34461 @@ -131,7 +131,7 @@ static struct attribute *cpuidle_switch_attrs[] = {
34462 NULL
34463 };
34464
34465 -static struct attribute_group cpuidle_attr_group = {
34466 +static attribute_group_no_const cpuidle_attr_group = {
34467 .attrs = cpuidle_default_attrs,
34468 .name = "cpuidle",
34469 };
34470 diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
34471 index 3b36797..289c16a 100644
34472 --- a/drivers/devfreq/devfreq.c
34473 +++ b/drivers/devfreq/devfreq.c
34474 @@ -588,7 +588,7 @@ int devfreq_add_governor(struct devfreq_governor *governor)
34475 goto err_out;
34476 }
34477
34478 - list_add(&governor->node, &devfreq_governor_list);
34479 + pax_list_add((struct list_head *)&governor->node, &devfreq_governor_list);
34480
34481 list_for_each_entry(devfreq, &devfreq_list, node) {
34482 int ret = 0;
34483 @@ -676,7 +676,7 @@ int devfreq_remove_governor(struct devfreq_governor *governor)
34484 }
34485 }
34486
34487 - list_del(&governor->node);
34488 + pax_list_del((struct list_head *)&governor->node);
34489 err_out:
34490 mutex_unlock(&devfreq_list_lock);
34491
34492 diff --git a/drivers/dma/sh/shdma.c b/drivers/dma/sh/shdma.c
34493 index b70709b..1d8d02a 100644
34494 --- a/drivers/dma/sh/shdma.c
34495 +++ b/drivers/dma/sh/shdma.c
34496 @@ -476,7 +476,7 @@ static int sh_dmae_nmi_handler(struct notifier_block *self,
34497 return ret;
34498 }
34499
34500 -static struct notifier_block sh_dmae_nmi_notifier __read_mostly = {
34501 +static struct notifier_block sh_dmae_nmi_notifier = {
34502 .notifier_call = sh_dmae_nmi_handler,
34503
34504 /* Run before NMI debug handler and KGDB */
34505 diff --git a/drivers/edac/edac_mc_sysfs.c b/drivers/edac/edac_mc_sysfs.c
34506 index 769d92e..a3dcc1e 100644
34507 --- a/drivers/edac/edac_mc_sysfs.c
34508 +++ b/drivers/edac/edac_mc_sysfs.c
34509 @@ -148,7 +148,7 @@ static const char *edac_caps[] = {
34510 struct dev_ch_attribute {
34511 struct device_attribute attr;
34512 int channel;
34513 -};
34514 +} __do_const;
34515
34516 #define DEVICE_CHANNEL(_name, _mode, _show, _store, _var) \
34517 struct dev_ch_attribute dev_attr_legacy_##_name = \
34518 @@ -1003,14 +1003,16 @@ int edac_create_sysfs_mci_device(struct mem_ctl_info *mci)
34519 }
34520
34521 if (mci->set_sdram_scrub_rate || mci->get_sdram_scrub_rate) {
34522 + pax_open_kernel();
34523 if (mci->get_sdram_scrub_rate) {
34524 - dev_attr_sdram_scrub_rate.attr.mode |= S_IRUGO;
34525 - dev_attr_sdram_scrub_rate.show = &mci_sdram_scrub_rate_show;
34526 + *(umode_t *)&dev_attr_sdram_scrub_rate.attr.mode |= S_IRUGO;
34527 + *(void **)&dev_attr_sdram_scrub_rate.show = &mci_sdram_scrub_rate_show;
34528 }
34529 if (mci->set_sdram_scrub_rate) {
34530 - dev_attr_sdram_scrub_rate.attr.mode |= S_IWUSR;
34531 - dev_attr_sdram_scrub_rate.store = &mci_sdram_scrub_rate_store;
34532 + *(umode_t *)&dev_attr_sdram_scrub_rate.attr.mode |= S_IWUSR;
34533 + *(void **)&dev_attr_sdram_scrub_rate.store = &mci_sdram_scrub_rate_store;
34534 }
34535 + pax_close_kernel();
34536 err = device_create_file(&mci->dev,
34537 &dev_attr_sdram_scrub_rate);
34538 if (err) {
34539 diff --git a/drivers/edac/edac_pci_sysfs.c b/drivers/edac/edac_pci_sysfs.c
34540 index e8658e4..22746d6 100644
34541 --- a/drivers/edac/edac_pci_sysfs.c
34542 +++ b/drivers/edac/edac_pci_sysfs.c
34543 @@ -26,8 +26,8 @@ static int edac_pci_log_pe = 1; /* log PCI parity errors */
34544 static int edac_pci_log_npe = 1; /* log PCI non-parity error errors */
34545 static int edac_pci_poll_msec = 1000; /* one second workq period */
34546
34547 -static atomic_t pci_parity_count = ATOMIC_INIT(0);
34548 -static atomic_t pci_nonparity_count = ATOMIC_INIT(0);
34549 +static atomic_unchecked_t pci_parity_count = ATOMIC_INIT(0);
34550 +static atomic_unchecked_t pci_nonparity_count = ATOMIC_INIT(0);
34551
34552 static struct kobject *edac_pci_top_main_kobj;
34553 static atomic_t edac_pci_sysfs_refcount = ATOMIC_INIT(0);
34554 @@ -235,7 +235,7 @@ struct edac_pci_dev_attribute {
34555 void *value;
34556 ssize_t(*show) (void *, char *);
34557 ssize_t(*store) (void *, const char *, size_t);
34558 -};
34559 +} __do_const;
34560
34561 /* Set of show/store abstract level functions for PCI Parity object */
34562 static ssize_t edac_pci_dev_show(struct kobject *kobj, struct attribute *attr,
34563 @@ -579,7 +579,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34564 edac_printk(KERN_CRIT, EDAC_PCI,
34565 "Signaled System Error on %s\n",
34566 pci_name(dev));
34567 - atomic_inc(&pci_nonparity_count);
34568 + atomic_inc_unchecked(&pci_nonparity_count);
34569 }
34570
34571 if (status & (PCI_STATUS_PARITY)) {
34572 @@ -587,7 +587,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34573 "Master Data Parity Error on %s\n",
34574 pci_name(dev));
34575
34576 - atomic_inc(&pci_parity_count);
34577 + atomic_inc_unchecked(&pci_parity_count);
34578 }
34579
34580 if (status & (PCI_STATUS_DETECTED_PARITY)) {
34581 @@ -595,7 +595,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34582 "Detected Parity Error on %s\n",
34583 pci_name(dev));
34584
34585 - atomic_inc(&pci_parity_count);
34586 + atomic_inc_unchecked(&pci_parity_count);
34587 }
34588 }
34589
34590 @@ -618,7 +618,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34591 edac_printk(KERN_CRIT, EDAC_PCI, "Bridge "
34592 "Signaled System Error on %s\n",
34593 pci_name(dev));
34594 - atomic_inc(&pci_nonparity_count);
34595 + atomic_inc_unchecked(&pci_nonparity_count);
34596 }
34597
34598 if (status & (PCI_STATUS_PARITY)) {
34599 @@ -626,7 +626,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34600 "Master Data Parity Error on "
34601 "%s\n", pci_name(dev));
34602
34603 - atomic_inc(&pci_parity_count);
34604 + atomic_inc_unchecked(&pci_parity_count);
34605 }
34606
34607 if (status & (PCI_STATUS_DETECTED_PARITY)) {
34608 @@ -634,7 +634,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34609 "Detected Parity Error on %s\n",
34610 pci_name(dev));
34611
34612 - atomic_inc(&pci_parity_count);
34613 + atomic_inc_unchecked(&pci_parity_count);
34614 }
34615 }
34616 }
34617 @@ -672,7 +672,7 @@ void edac_pci_do_parity_check(void)
34618 if (!check_pci_errors)
34619 return;
34620
34621 - before_count = atomic_read(&pci_parity_count);
34622 + before_count = atomic_read_unchecked(&pci_parity_count);
34623
34624 /* scan all PCI devices looking for a Parity Error on devices and
34625 * bridges.
34626 @@ -684,7 +684,7 @@ void edac_pci_do_parity_check(void)
34627 /* Only if operator has selected panic on PCI Error */
34628 if (edac_pci_get_panic_on_pe()) {
34629 /* If the count is different 'after' from 'before' */
34630 - if (before_count != atomic_read(&pci_parity_count))
34631 + if (before_count != atomic_read_unchecked(&pci_parity_count))
34632 panic("EDAC: PCI Parity Error");
34633 }
34634 }
34635 diff --git a/drivers/edac/mce_amd.h b/drivers/edac/mce_amd.h
34636 index 51b7e3a..aa8a3e8 100644
34637 --- a/drivers/edac/mce_amd.h
34638 +++ b/drivers/edac/mce_amd.h
34639 @@ -77,7 +77,7 @@ struct amd_decoder_ops {
34640 bool (*mc0_mce)(u16, u8);
34641 bool (*mc1_mce)(u16, u8);
34642 bool (*mc2_mce)(u16, u8);
34643 -};
34644 +} __no_const;
34645
34646 void amd_report_gart_errors(bool);
34647 void amd_register_ecc_decoder(void (*f)(int, struct mce *));
34648 diff --git a/drivers/firewire/core-card.c b/drivers/firewire/core-card.c
34649 index 57ea7f4..789e3c3 100644
34650 --- a/drivers/firewire/core-card.c
34651 +++ b/drivers/firewire/core-card.c
34652 @@ -680,7 +680,7 @@ EXPORT_SYMBOL_GPL(fw_card_release);
34653
34654 void fw_core_remove_card(struct fw_card *card)
34655 {
34656 - struct fw_card_driver dummy_driver = dummy_driver_template;
34657 + fw_card_driver_no_const dummy_driver = dummy_driver_template;
34658
34659 card->driver->update_phy_reg(card, 4,
34660 PHY_LINK_ACTIVE | PHY_CONTENDER, 0);
34661 diff --git a/drivers/firewire/core-cdev.c b/drivers/firewire/core-cdev.c
34662 index 27ac423..13573e8 100644
34663 --- a/drivers/firewire/core-cdev.c
34664 +++ b/drivers/firewire/core-cdev.c
34665 @@ -1366,8 +1366,7 @@ static int init_iso_resource(struct client *client,
34666 int ret;
34667
34668 if ((request->channels == 0 && request->bandwidth == 0) ||
34669 - request->bandwidth > BANDWIDTH_AVAILABLE_INITIAL ||
34670 - request->bandwidth < 0)
34671 + request->bandwidth > BANDWIDTH_AVAILABLE_INITIAL)
34672 return -EINVAL;
34673
34674 r = kmalloc(sizeof(*r), GFP_KERNEL);
34675 diff --git a/drivers/firewire/core-device.c b/drivers/firewire/core-device.c
34676 index 03ce7d9..b70f5da 100644
34677 --- a/drivers/firewire/core-device.c
34678 +++ b/drivers/firewire/core-device.c
34679 @@ -232,7 +232,7 @@ EXPORT_SYMBOL(fw_device_enable_phys_dma);
34680 struct config_rom_attribute {
34681 struct device_attribute attr;
34682 u32 key;
34683 -};
34684 +} __do_const;
34685
34686 static ssize_t show_immediate(struct device *dev,
34687 struct device_attribute *dattr, char *buf)
34688 diff --git a/drivers/firewire/core-transaction.c b/drivers/firewire/core-transaction.c
34689 index 28a94c7..58da63a 100644
34690 --- a/drivers/firewire/core-transaction.c
34691 +++ b/drivers/firewire/core-transaction.c
34692 @@ -38,6 +38,7 @@
34693 #include <linux/timer.h>
34694 #include <linux/types.h>
34695 #include <linux/workqueue.h>
34696 +#include <linux/sched.h>
34697
34698 #include <asm/byteorder.h>
34699
34700 diff --git a/drivers/firewire/core.h b/drivers/firewire/core.h
34701 index 515a42c..5ecf3ba 100644
34702 --- a/drivers/firewire/core.h
34703 +++ b/drivers/firewire/core.h
34704 @@ -111,6 +111,7 @@ struct fw_card_driver {
34705
34706 int (*stop_iso)(struct fw_iso_context *ctx);
34707 };
34708 +typedef struct fw_card_driver __no_const fw_card_driver_no_const;
34709
34710 void fw_card_initialize(struct fw_card *card,
34711 const struct fw_card_driver *driver, struct device *device);
34712 diff --git a/drivers/firmware/dmi-id.c b/drivers/firmware/dmi-id.c
34713 index 94a58a0..f5eba42 100644
34714 --- a/drivers/firmware/dmi-id.c
34715 +++ b/drivers/firmware/dmi-id.c
34716 @@ -16,7 +16,7 @@
34717 struct dmi_device_attribute{
34718 struct device_attribute dev_attr;
34719 int field;
34720 -};
34721 +} __do_const;
34722 #define to_dmi_dev_attr(_dev_attr) \
34723 container_of(_dev_attr, struct dmi_device_attribute, dev_attr)
34724
34725 diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c
34726 index 4cd392d..4b629e1 100644
34727 --- a/drivers/firmware/dmi_scan.c
34728 +++ b/drivers/firmware/dmi_scan.c
34729 @@ -490,11 +490,6 @@ void __init dmi_scan_machine(void)
34730 }
34731 }
34732 else {
34733 - /*
34734 - * no iounmap() for that ioremap(); it would be a no-op, but
34735 - * it's so early in setup that sucker gets confused into doing
34736 - * what it shouldn't if we actually call it.
34737 - */
34738 p = dmi_ioremap(0xF0000, 0x10000);
34739 if (p == NULL)
34740 goto error;
34741 @@ -769,7 +764,7 @@ int dmi_walk(void (*decode)(const struct dmi_header *, void *),
34742 if (buf == NULL)
34743 return -1;
34744
34745 - dmi_table(buf, dmi_len, dmi_num, decode, private_data);
34746 + dmi_table((char __force_kernel *)buf, dmi_len, dmi_num, decode, private_data);
34747
34748 iounmap(buf);
34749 return 0;
34750 diff --git a/drivers/firmware/efivars.c b/drivers/firmware/efivars.c
34751 index f4baa11..7970c3a 100644
34752 --- a/drivers/firmware/efivars.c
34753 +++ b/drivers/firmware/efivars.c
34754 @@ -139,7 +139,7 @@ struct efivar_attribute {
34755 };
34756
34757 static struct efivars __efivars;
34758 -static struct efivar_operations ops;
34759 +static efivar_operations_no_const ops __read_only;
34760
34761 #define PSTORE_EFI_ATTRIBUTES \
34762 (EFI_VARIABLE_NON_VOLATILE | \
34763 @@ -1844,7 +1844,7 @@ efivar_create_sysfs_entry(struct efivars *efivars,
34764 static int
34765 create_efivars_bin_attributes(struct efivars *efivars)
34766 {
34767 - struct bin_attribute *attr;
34768 + bin_attribute_no_const *attr;
34769 int error;
34770
34771 /* new_var */
34772 diff --git a/drivers/firmware/google/memconsole.c b/drivers/firmware/google/memconsole.c
34773 index 2a90ba6..07f3733 100644
34774 --- a/drivers/firmware/google/memconsole.c
34775 +++ b/drivers/firmware/google/memconsole.c
34776 @@ -147,7 +147,9 @@ static int __init memconsole_init(void)
34777 if (!found_memconsole())
34778 return -ENODEV;
34779
34780 - memconsole_bin_attr.size = memconsole_length;
34781 + pax_open_kernel();
34782 + *(size_t *)&memconsole_bin_attr.size = memconsole_length;
34783 + pax_close_kernel();
34784
34785 ret = sysfs_create_bin_file(firmware_kobj, &memconsole_bin_attr);
34786
34787 diff --git a/drivers/gpio/gpio-ich.c b/drivers/gpio/gpio-ich.c
34788 index de3c317..b7cd029 100644
34789 --- a/drivers/gpio/gpio-ich.c
34790 +++ b/drivers/gpio/gpio-ich.c
34791 @@ -69,7 +69,7 @@ struct ichx_desc {
34792 /* Some chipsets have quirks, let these use their own request/get */
34793 int (*request)(struct gpio_chip *chip, unsigned offset);
34794 int (*get)(struct gpio_chip *chip, unsigned offset);
34795 -};
34796 +} __do_const;
34797
34798 static struct {
34799 spinlock_t lock;
34800 diff --git a/drivers/gpio/gpio-vr41xx.c b/drivers/gpio/gpio-vr41xx.c
34801 index 9902732..64b62dd 100644
34802 --- a/drivers/gpio/gpio-vr41xx.c
34803 +++ b/drivers/gpio/gpio-vr41xx.c
34804 @@ -204,7 +204,7 @@ static int giu_get_irq(unsigned int irq)
34805 printk(KERN_ERR "spurious GIU interrupt: %04x(%04x),%04x(%04x)\n",
34806 maskl, pendl, maskh, pendh);
34807
34808 - atomic_inc(&irq_err_count);
34809 + atomic_inc_unchecked(&irq_err_count);
34810
34811 return -EINVAL;
34812 }
34813 diff --git a/drivers/gpu/drm/drm_crtc_helper.c b/drivers/gpu/drm/drm_crtc_helper.c
34814 index 7b2d378..cc947ea 100644
34815 --- a/drivers/gpu/drm/drm_crtc_helper.c
34816 +++ b/drivers/gpu/drm/drm_crtc_helper.c
34817 @@ -319,7 +319,7 @@ static bool drm_encoder_crtc_ok(struct drm_encoder *encoder,
34818 struct drm_crtc *tmp;
34819 int crtc_mask = 1;
34820
34821 - WARN(!crtc, "checking null crtc?\n");
34822 + BUG_ON(!crtc);
34823
34824 dev = crtc->dev;
34825
34826 diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
34827 index 25f91cd..a376f55 100644
34828 --- a/drivers/gpu/drm/drm_drv.c
34829 +++ b/drivers/gpu/drm/drm_drv.c
34830 @@ -306,7 +306,7 @@ module_exit(drm_core_exit);
34831 /**
34832 * Copy and IOCTL return string to user space
34833 */
34834 -static int drm_copy_field(char *buf, size_t *buf_len, const char *value)
34835 +static int drm_copy_field(char __user *buf, size_t *buf_len, const char *value)
34836 {
34837 int len;
34838
34839 @@ -376,7 +376,7 @@ long drm_ioctl(struct file *filp,
34840 struct drm_file *file_priv = filp->private_data;
34841 struct drm_device *dev;
34842 struct drm_ioctl_desc *ioctl;
34843 - drm_ioctl_t *func;
34844 + drm_ioctl_no_const_t func;
34845 unsigned int nr = DRM_IOCTL_NR(cmd);
34846 int retcode = -EINVAL;
34847 char stack_kdata[128];
34848 @@ -389,7 +389,7 @@ long drm_ioctl(struct file *filp,
34849 return -ENODEV;
34850
34851 atomic_inc(&dev->ioctl_count);
34852 - atomic_inc(&dev->counts[_DRM_STAT_IOCTLS]);
34853 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_IOCTLS]);
34854 ++file_priv->ioctl_count;
34855
34856 DRM_DEBUG("pid=%d, cmd=0x%02x, nr=0x%02x, dev 0x%lx, auth=%d\n",
34857 diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
34858 index 429e07d..e681a2c 100644
34859 --- a/drivers/gpu/drm/drm_fops.c
34860 +++ b/drivers/gpu/drm/drm_fops.c
34861 @@ -71,7 +71,7 @@ static int drm_setup(struct drm_device * dev)
34862 }
34863
34864 for (i = 0; i < ARRAY_SIZE(dev->counts); i++)
34865 - atomic_set(&dev->counts[i], 0);
34866 + atomic_set_unchecked(&dev->counts[i], 0);
34867
34868 dev->sigdata.lock = NULL;
34869
34870 @@ -135,7 +135,7 @@ int drm_open(struct inode *inode, struct file *filp)
34871 if (drm_device_is_unplugged(dev))
34872 return -ENODEV;
34873
34874 - if (!dev->open_count++)
34875 + if (local_inc_return(&dev->open_count) == 1)
34876 need_setup = 1;
34877 mutex_lock(&dev->struct_mutex);
34878 old_imapping = inode->i_mapping;
34879 @@ -151,7 +151,7 @@ int drm_open(struct inode *inode, struct file *filp)
34880 retcode = drm_open_helper(inode, filp, dev);
34881 if (retcode)
34882 goto err_undo;
34883 - atomic_inc(&dev->counts[_DRM_STAT_OPENS]);
34884 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_OPENS]);
34885 if (need_setup) {
34886 retcode = drm_setup(dev);
34887 if (retcode)
34888 @@ -166,7 +166,7 @@ err_undo:
34889 iput(container_of(dev->dev_mapping, struct inode, i_data));
34890 dev->dev_mapping = old_mapping;
34891 mutex_unlock(&dev->struct_mutex);
34892 - dev->open_count--;
34893 + local_dec(&dev->open_count);
34894 return retcode;
34895 }
34896 EXPORT_SYMBOL(drm_open);
34897 @@ -441,7 +441,7 @@ int drm_release(struct inode *inode, struct file *filp)
34898
34899 mutex_lock(&drm_global_mutex);
34900
34901 - DRM_DEBUG("open_count = %d\n", dev->open_count);
34902 + DRM_DEBUG("open_count = %ld\n", local_read(&dev->open_count));
34903
34904 if (dev->driver->preclose)
34905 dev->driver->preclose(dev, file_priv);
34906 @@ -450,10 +450,10 @@ int drm_release(struct inode *inode, struct file *filp)
34907 * Begin inline drm_release
34908 */
34909
34910 - DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %d\n",
34911 + DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %ld\n",
34912 task_pid_nr(current),
34913 (long)old_encode_dev(file_priv->minor->device),
34914 - dev->open_count);
34915 + local_read(&dev->open_count));
34916
34917 /* Release any auth tokens that might point to this file_priv,
34918 (do that under the drm_global_mutex) */
34919 @@ -550,8 +550,8 @@ int drm_release(struct inode *inode, struct file *filp)
34920 * End inline drm_release
34921 */
34922
34923 - atomic_inc(&dev->counts[_DRM_STAT_CLOSES]);
34924 - if (!--dev->open_count) {
34925 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_CLOSES]);
34926 + if (local_dec_and_test(&dev->open_count)) {
34927 if (atomic_read(&dev->ioctl_count)) {
34928 DRM_ERROR("Device busy: %d\n",
34929 atomic_read(&dev->ioctl_count));
34930 diff --git a/drivers/gpu/drm/drm_global.c b/drivers/gpu/drm/drm_global.c
34931 index f731116..629842c 100644
34932 --- a/drivers/gpu/drm/drm_global.c
34933 +++ b/drivers/gpu/drm/drm_global.c
34934 @@ -36,7 +36,7 @@
34935 struct drm_global_item {
34936 struct mutex mutex;
34937 void *object;
34938 - int refcount;
34939 + atomic_t refcount;
34940 };
34941
34942 static struct drm_global_item glob[DRM_GLOBAL_NUM];
34943 @@ -49,7 +49,7 @@ void drm_global_init(void)
34944 struct drm_global_item *item = &glob[i];
34945 mutex_init(&item->mutex);
34946 item->object = NULL;
34947 - item->refcount = 0;
34948 + atomic_set(&item->refcount, 0);
34949 }
34950 }
34951
34952 @@ -59,7 +59,7 @@ void drm_global_release(void)
34953 for (i = 0; i < DRM_GLOBAL_NUM; ++i) {
34954 struct drm_global_item *item = &glob[i];
34955 BUG_ON(item->object != NULL);
34956 - BUG_ON(item->refcount != 0);
34957 + BUG_ON(atomic_read(&item->refcount) != 0);
34958 }
34959 }
34960
34961 @@ -70,7 +70,7 @@ int drm_global_item_ref(struct drm_global_reference *ref)
34962 void *object;
34963
34964 mutex_lock(&item->mutex);
34965 - if (item->refcount == 0) {
34966 + if (atomic_read(&item->refcount) == 0) {
34967 item->object = kzalloc(ref->size, GFP_KERNEL);
34968 if (unlikely(item->object == NULL)) {
34969 ret = -ENOMEM;
34970 @@ -83,7 +83,7 @@ int drm_global_item_ref(struct drm_global_reference *ref)
34971 goto out_err;
34972
34973 }
34974 - ++item->refcount;
34975 + atomic_inc(&item->refcount);
34976 ref->object = item->object;
34977 object = item->object;
34978 mutex_unlock(&item->mutex);
34979 @@ -100,9 +100,9 @@ void drm_global_item_unref(struct drm_global_reference *ref)
34980 struct drm_global_item *item = &glob[ref->global_type];
34981
34982 mutex_lock(&item->mutex);
34983 - BUG_ON(item->refcount == 0);
34984 + BUG_ON(atomic_read(&item->refcount) == 0);
34985 BUG_ON(ref->object != item->object);
34986 - if (--item->refcount == 0) {
34987 + if (atomic_dec_and_test(&item->refcount)) {
34988 ref->release(ref);
34989 item->object = NULL;
34990 }
34991 diff --git a/drivers/gpu/drm/drm_info.c b/drivers/gpu/drm/drm_info.c
34992 index d4b20ce..77a8d41 100644
34993 --- a/drivers/gpu/drm/drm_info.c
34994 +++ b/drivers/gpu/drm/drm_info.c
34995 @@ -75,10 +75,14 @@ int drm_vm_info(struct seq_file *m, void *data)
34996 struct drm_local_map *map;
34997 struct drm_map_list *r_list;
34998
34999 - /* Hardcoded from _DRM_FRAME_BUFFER,
35000 - _DRM_REGISTERS, _DRM_SHM, _DRM_AGP, and
35001 - _DRM_SCATTER_GATHER and _DRM_CONSISTENT */
35002 - const char *types[] = { "FB", "REG", "SHM", "AGP", "SG", "PCI" };
35003 + static const char * const types[] = {
35004 + [_DRM_FRAME_BUFFER] = "FB",
35005 + [_DRM_REGISTERS] = "REG",
35006 + [_DRM_SHM] = "SHM",
35007 + [_DRM_AGP] = "AGP",
35008 + [_DRM_SCATTER_GATHER] = "SG",
35009 + [_DRM_CONSISTENT] = "PCI",
35010 + [_DRM_GEM] = "GEM" };
35011 const char *type;
35012 int i;
35013
35014 @@ -89,7 +93,7 @@ int drm_vm_info(struct seq_file *m, void *data)
35015 map = r_list->map;
35016 if (!map)
35017 continue;
35018 - if (map->type < 0 || map->type > 5)
35019 + if (map->type >= ARRAY_SIZE(types))
35020 type = "??";
35021 else
35022 type = types[map->type];
35023 @@ -253,7 +257,11 @@ int drm_vma_info(struct seq_file *m, void *data)
35024 vma->vm_flags & VM_MAYSHARE ? 's' : 'p',
35025 vma->vm_flags & VM_LOCKED ? 'l' : '-',
35026 vma->vm_flags & VM_IO ? 'i' : '-',
35027 +#ifdef CONFIG_GRKERNSEC_HIDESYM
35028 + 0);
35029 +#else
35030 vma->vm_pgoff);
35031 +#endif
35032
35033 #if defined(__i386__)
35034 pgprot = pgprot_val(vma->vm_page_prot);
35035 diff --git a/drivers/gpu/drm/drm_ioc32.c b/drivers/gpu/drm/drm_ioc32.c
35036 index 2f4c434..dd12cd2 100644
35037 --- a/drivers/gpu/drm/drm_ioc32.c
35038 +++ b/drivers/gpu/drm/drm_ioc32.c
35039 @@ -457,7 +457,7 @@ static int compat_drm_infobufs(struct file *file, unsigned int cmd,
35040 request = compat_alloc_user_space(nbytes);
35041 if (!access_ok(VERIFY_WRITE, request, nbytes))
35042 return -EFAULT;
35043 - list = (struct drm_buf_desc *) (request + 1);
35044 + list = (struct drm_buf_desc __user *) (request + 1);
35045
35046 if (__put_user(count, &request->count)
35047 || __put_user(list, &request->list))
35048 @@ -518,7 +518,7 @@ static int compat_drm_mapbufs(struct file *file, unsigned int cmd,
35049 request = compat_alloc_user_space(nbytes);
35050 if (!access_ok(VERIFY_WRITE, request, nbytes))
35051 return -EFAULT;
35052 - list = (struct drm_buf_pub *) (request + 1);
35053 + list = (struct drm_buf_pub __user *) (request + 1);
35054
35055 if (__put_user(count, &request->count)
35056 || __put_user(list, &request->list))
35057 @@ -1016,7 +1016,7 @@ static int compat_drm_wait_vblank(struct file *file, unsigned int cmd,
35058 return 0;
35059 }
35060
35061 -drm_ioctl_compat_t *drm_compat_ioctls[] = {
35062 +drm_ioctl_compat_t drm_compat_ioctls[] = {
35063 [DRM_IOCTL_NR(DRM_IOCTL_VERSION32)] = compat_drm_version,
35064 [DRM_IOCTL_NR(DRM_IOCTL_GET_UNIQUE32)] = compat_drm_getunique,
35065 [DRM_IOCTL_NR(DRM_IOCTL_GET_MAP32)] = compat_drm_getmap,
35066 @@ -1062,7 +1062,6 @@ drm_ioctl_compat_t *drm_compat_ioctls[] = {
35067 long drm_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
35068 {
35069 unsigned int nr = DRM_IOCTL_NR(cmd);
35070 - drm_ioctl_compat_t *fn;
35071 int ret;
35072
35073 /* Assume that ioctls without an explicit compat routine will just
35074 @@ -1072,10 +1071,8 @@ long drm_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
35075 if (nr >= ARRAY_SIZE(drm_compat_ioctls))
35076 return drm_ioctl(filp, cmd, arg);
35077
35078 - fn = drm_compat_ioctls[nr];
35079 -
35080 - if (fn != NULL)
35081 - ret = (*fn) (filp, cmd, arg);
35082 + if (drm_compat_ioctls[nr] != NULL)
35083 + ret = (*drm_compat_ioctls[nr]) (filp, cmd, arg);
35084 else
35085 ret = drm_ioctl(filp, cmd, arg);
35086
35087 diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
35088 index e77bd8b..1571b85 100644
35089 --- a/drivers/gpu/drm/drm_ioctl.c
35090 +++ b/drivers/gpu/drm/drm_ioctl.c
35091 @@ -252,7 +252,7 @@ int drm_getstats(struct drm_device *dev, void *data,
35092 stats->data[i].value =
35093 (file_priv->master->lock.hw_lock ? file_priv->master->lock.hw_lock->lock : 0);
35094 else
35095 - stats->data[i].value = atomic_read(&dev->counts[i]);
35096 + stats->data[i].value = atomic_read_unchecked(&dev->counts[i]);
35097 stats->data[i].type = dev->types[i];
35098 }
35099
35100 diff --git a/drivers/gpu/drm/drm_lock.c b/drivers/gpu/drm/drm_lock.c
35101 index d752c96..fe08455 100644
35102 --- a/drivers/gpu/drm/drm_lock.c
35103 +++ b/drivers/gpu/drm/drm_lock.c
35104 @@ -86,7 +86,7 @@ int drm_lock(struct drm_device *dev, void *data, struct drm_file *file_priv)
35105 if (drm_lock_take(&master->lock, lock->context)) {
35106 master->lock.file_priv = file_priv;
35107 master->lock.lock_time = jiffies;
35108 - atomic_inc(&dev->counts[_DRM_STAT_LOCKS]);
35109 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_LOCKS]);
35110 break; /* Got lock */
35111 }
35112
35113 @@ -157,7 +157,7 @@ int drm_unlock(struct drm_device *dev, void *data, struct drm_file *file_priv)
35114 return -EINVAL;
35115 }
35116
35117 - atomic_inc(&dev->counts[_DRM_STAT_UNLOCKS]);
35118 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_UNLOCKS]);
35119
35120 if (drm_lock_free(&master->lock, lock->context)) {
35121 /* FIXME: Should really bail out here. */
35122 diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c
35123 index 7d30802..42c6cbb 100644
35124 --- a/drivers/gpu/drm/drm_stub.c
35125 +++ b/drivers/gpu/drm/drm_stub.c
35126 @@ -501,7 +501,7 @@ void drm_unplug_dev(struct drm_device *dev)
35127
35128 drm_device_set_unplugged(dev);
35129
35130 - if (dev->open_count == 0) {
35131 + if (local_read(&dev->open_count) == 0) {
35132 drm_put_dev(dev);
35133 }
35134 mutex_unlock(&drm_global_mutex);
35135 diff --git a/drivers/gpu/drm/i810/i810_dma.c b/drivers/gpu/drm/i810/i810_dma.c
35136 index 004ecdf..db1f6e0 100644
35137 --- a/drivers/gpu/drm/i810/i810_dma.c
35138 +++ b/drivers/gpu/drm/i810/i810_dma.c
35139 @@ -945,8 +945,8 @@ static int i810_dma_vertex(struct drm_device *dev, void *data,
35140 dma->buflist[vertex->idx],
35141 vertex->discard, vertex->used);
35142
35143 - atomic_add(vertex->used, &dev->counts[_DRM_STAT_SECONDARY]);
35144 - atomic_inc(&dev->counts[_DRM_STAT_DMA]);
35145 + atomic_add_unchecked(vertex->used, &dev->counts[_DRM_STAT_SECONDARY]);
35146 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_DMA]);
35147 sarea_priv->last_enqueue = dev_priv->counter - 1;
35148 sarea_priv->last_dispatch = (int)hw_status[5];
35149
35150 @@ -1106,8 +1106,8 @@ static int i810_dma_mc(struct drm_device *dev, void *data,
35151 i810_dma_dispatch_mc(dev, dma->buflist[mc->idx], mc->used,
35152 mc->last_render);
35153
35154 - atomic_add(mc->used, &dev->counts[_DRM_STAT_SECONDARY]);
35155 - atomic_inc(&dev->counts[_DRM_STAT_DMA]);
35156 + atomic_add_unchecked(mc->used, &dev->counts[_DRM_STAT_SECONDARY]);
35157 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_DMA]);
35158 sarea_priv->last_enqueue = dev_priv->counter - 1;
35159 sarea_priv->last_dispatch = (int)hw_status[5];
35160
35161 diff --git a/drivers/gpu/drm/i810/i810_drv.h b/drivers/gpu/drm/i810/i810_drv.h
35162 index 6e0acad..93c8289 100644
35163 --- a/drivers/gpu/drm/i810/i810_drv.h
35164 +++ b/drivers/gpu/drm/i810/i810_drv.h
35165 @@ -108,8 +108,8 @@ typedef struct drm_i810_private {
35166 int page_flipping;
35167
35168 wait_queue_head_t irq_queue;
35169 - atomic_t irq_received;
35170 - atomic_t irq_emitted;
35171 + atomic_unchecked_t irq_received;
35172 + atomic_unchecked_t irq_emitted;
35173
35174 int front_offset;
35175 } drm_i810_private_t;
35176 diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
35177 index 7299ea4..5314487 100644
35178 --- a/drivers/gpu/drm/i915/i915_debugfs.c
35179 +++ b/drivers/gpu/drm/i915/i915_debugfs.c
35180 @@ -499,7 +499,7 @@ static int i915_interrupt_info(struct seq_file *m, void *data)
35181 I915_READ(GTIMR));
35182 }
35183 seq_printf(m, "Interrupts received: %d\n",
35184 - atomic_read(&dev_priv->irq_received));
35185 + atomic_read_unchecked(&dev_priv->irq_received));
35186 for_each_ring(ring, dev_priv, i) {
35187 if (IS_GEN6(dev) || IS_GEN7(dev)) {
35188 seq_printf(m,
35189 diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
35190 index 4fa6beb..f930fec 100644
35191 --- a/drivers/gpu/drm/i915/i915_dma.c
35192 +++ b/drivers/gpu/drm/i915/i915_dma.c
35193 @@ -1259,7 +1259,7 @@ static bool i915_switcheroo_can_switch(struct pci_dev *pdev)
35194 bool can_switch;
35195
35196 spin_lock(&dev->count_lock);
35197 - can_switch = (dev->open_count == 0);
35198 + can_switch = (local_read(&dev->open_count) == 0);
35199 spin_unlock(&dev->count_lock);
35200 return can_switch;
35201 }
35202 diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
35203 index ef99b1c..09ce7fb 100644
35204 --- a/drivers/gpu/drm/i915/i915_drv.h
35205 +++ b/drivers/gpu/drm/i915/i915_drv.h
35206 @@ -893,7 +893,7 @@ typedef struct drm_i915_private {
35207 drm_dma_handle_t *status_page_dmah;
35208 struct resource mch_res;
35209
35210 - atomic_t irq_received;
35211 + atomic_unchecked_t irq_received;
35212
35213 /* protects the irq masks */
35214 spinlock_t irq_lock;
35215 @@ -1775,7 +1775,7 @@ extern struct i2c_adapter *intel_gmbus_get_adapter(
35216 struct drm_i915_private *dev_priv, unsigned port);
35217 extern void intel_gmbus_set_speed(struct i2c_adapter *adapter, int speed);
35218 extern void intel_gmbus_force_bit(struct i2c_adapter *adapter, bool force_bit);
35219 -extern inline bool intel_gmbus_is_forced_bit(struct i2c_adapter *adapter)
35220 +static inline bool intel_gmbus_is_forced_bit(struct i2c_adapter *adapter)
35221 {
35222 return container_of(adapter, struct intel_gmbus, adapter)->force_bit;
35223 }
35224 diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
35225 index 9a48e1a..f0cbc3e 100644
35226 --- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c
35227 +++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
35228 @@ -729,9 +729,9 @@ i915_gem_check_execbuffer(struct drm_i915_gem_execbuffer2 *exec)
35229
35230 static int
35231 validate_exec_list(struct drm_i915_gem_exec_object2 *exec,
35232 - int count)
35233 + unsigned int count)
35234 {
35235 - int i;
35236 + unsigned int i;
35237 int relocs_total = 0;
35238 int relocs_max = INT_MAX / sizeof(struct drm_i915_gem_relocation_entry);
35239
35240 @@ -1195,7 +1195,7 @@ i915_gem_execbuffer2(struct drm_device *dev, void *data,
35241 return -ENOMEM;
35242 }
35243 ret = copy_from_user(exec2_list,
35244 - (struct drm_i915_relocation_entry __user *)
35245 + (struct drm_i915_gem_exec_object2 __user *)
35246 (uintptr_t) args->buffers_ptr,
35247 sizeof(*exec2_list) * args->buffer_count);
35248 if (ret != 0) {
35249 diff --git a/drivers/gpu/drm/i915/i915_ioc32.c b/drivers/gpu/drm/i915/i915_ioc32.c
35250 index 3c59584..500f2e9 100644
35251 --- a/drivers/gpu/drm/i915/i915_ioc32.c
35252 +++ b/drivers/gpu/drm/i915/i915_ioc32.c
35253 @@ -181,7 +181,7 @@ static int compat_i915_alloc(struct file *file, unsigned int cmd,
35254 (unsigned long)request);
35255 }
35256
35257 -static drm_ioctl_compat_t *i915_compat_ioctls[] = {
35258 +static drm_ioctl_compat_t i915_compat_ioctls[] = {
35259 [DRM_I915_BATCHBUFFER] = compat_i915_batchbuffer,
35260 [DRM_I915_CMDBUFFER] = compat_i915_cmdbuffer,
35261 [DRM_I915_GETPARAM] = compat_i915_getparam,
35262 @@ -202,18 +202,15 @@ static drm_ioctl_compat_t *i915_compat_ioctls[] = {
35263 long i915_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
35264 {
35265 unsigned int nr = DRM_IOCTL_NR(cmd);
35266 - drm_ioctl_compat_t *fn = NULL;
35267 int ret;
35268
35269 if (nr < DRM_COMMAND_BASE)
35270 return drm_compat_ioctl(filp, cmd, arg);
35271
35272 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(i915_compat_ioctls))
35273 - fn = i915_compat_ioctls[nr - DRM_COMMAND_BASE];
35274 -
35275 - if (fn != NULL)
35276 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(i915_compat_ioctls)) {
35277 + drm_ioctl_compat_t fn = i915_compat_ioctls[nr - DRM_COMMAND_BASE];
35278 ret = (*fn) (filp, cmd, arg);
35279 - else
35280 + } else
35281 ret = drm_ioctl(filp, cmd, arg);
35282
35283 return ret;
35284 diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
35285 index 3c7bb04..182e049 100644
35286 --- a/drivers/gpu/drm/i915/i915_irq.c
35287 +++ b/drivers/gpu/drm/i915/i915_irq.c
35288 @@ -549,7 +549,7 @@ static irqreturn_t valleyview_irq_handler(int irq, void *arg)
35289 int pipe;
35290 u32 pipe_stats[I915_MAX_PIPES];
35291
35292 - atomic_inc(&dev_priv->irq_received);
35293 + atomic_inc_unchecked(&dev_priv->irq_received);
35294
35295 while (true) {
35296 iir = I915_READ(VLV_IIR);
35297 @@ -705,7 +705,7 @@ static irqreturn_t ivybridge_irq_handler(int irq, void *arg)
35298 irqreturn_t ret = IRQ_NONE;
35299 int i;
35300
35301 - atomic_inc(&dev_priv->irq_received);
35302 + atomic_inc_unchecked(&dev_priv->irq_received);
35303
35304 /* disable master interrupt before clearing iir */
35305 de_ier = I915_READ(DEIER);
35306 @@ -791,7 +791,7 @@ static irqreturn_t ironlake_irq_handler(int irq, void *arg)
35307 int ret = IRQ_NONE;
35308 u32 de_iir, gt_iir, de_ier, pm_iir, sde_ier;
35309
35310 - atomic_inc(&dev_priv->irq_received);
35311 + atomic_inc_unchecked(&dev_priv->irq_received);
35312
35313 /* disable master interrupt before clearing iir */
35314 de_ier = I915_READ(DEIER);
35315 @@ -1886,7 +1886,7 @@ static void ironlake_irq_preinstall(struct drm_device *dev)
35316 {
35317 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35318
35319 - atomic_set(&dev_priv->irq_received, 0);
35320 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35321
35322 I915_WRITE(HWSTAM, 0xeffe);
35323
35324 @@ -1912,7 +1912,7 @@ static void valleyview_irq_preinstall(struct drm_device *dev)
35325 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35326 int pipe;
35327
35328 - atomic_set(&dev_priv->irq_received, 0);
35329 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35330
35331 /* VLV magic */
35332 I915_WRITE(VLV_IMR, 0);
35333 @@ -2208,7 +2208,7 @@ static void i8xx_irq_preinstall(struct drm_device * dev)
35334 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35335 int pipe;
35336
35337 - atomic_set(&dev_priv->irq_received, 0);
35338 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35339
35340 for_each_pipe(pipe)
35341 I915_WRITE(PIPESTAT(pipe), 0);
35342 @@ -2259,7 +2259,7 @@ static irqreturn_t i8xx_irq_handler(int irq, void *arg)
35343 I915_DISPLAY_PLANE_A_FLIP_PENDING_INTERRUPT |
35344 I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT;
35345
35346 - atomic_inc(&dev_priv->irq_received);
35347 + atomic_inc_unchecked(&dev_priv->irq_received);
35348
35349 iir = I915_READ16(IIR);
35350 if (iir == 0)
35351 @@ -2344,7 +2344,7 @@ static void i915_irq_preinstall(struct drm_device * dev)
35352 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35353 int pipe;
35354
35355 - atomic_set(&dev_priv->irq_received, 0);
35356 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35357
35358 if (I915_HAS_HOTPLUG(dev)) {
35359 I915_WRITE(PORT_HOTPLUG_EN, 0);
35360 @@ -2448,7 +2448,7 @@ static irqreturn_t i915_irq_handler(int irq, void *arg)
35361 };
35362 int pipe, ret = IRQ_NONE;
35363
35364 - atomic_inc(&dev_priv->irq_received);
35365 + atomic_inc_unchecked(&dev_priv->irq_received);
35366
35367 iir = I915_READ(IIR);
35368 do {
35369 @@ -2574,7 +2574,7 @@ static void i965_irq_preinstall(struct drm_device * dev)
35370 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35371 int pipe;
35372
35373 - atomic_set(&dev_priv->irq_received, 0);
35374 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35375
35376 I915_WRITE(PORT_HOTPLUG_EN, 0);
35377 I915_WRITE(PORT_HOTPLUG_STAT, I915_READ(PORT_HOTPLUG_STAT));
35378 @@ -2690,7 +2690,7 @@ static irqreturn_t i965_irq_handler(int irq, void *arg)
35379 int irq_received;
35380 int ret = IRQ_NONE, pipe;
35381
35382 - atomic_inc(&dev_priv->irq_received);
35383 + atomic_inc_unchecked(&dev_priv->irq_received);
35384
35385 iir = I915_READ(IIR);
35386
35387 diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
35388 index c2d173a..f4357cc 100644
35389 --- a/drivers/gpu/drm/i915/intel_display.c
35390 +++ b/drivers/gpu/drm/i915/intel_display.c
35391 @@ -8722,13 +8722,13 @@ struct intel_quirk {
35392 int subsystem_vendor;
35393 int subsystem_device;
35394 void (*hook)(struct drm_device *dev);
35395 -};
35396 +} __do_const;
35397
35398 /* For systems that don't have a meaningful PCI subdevice/subvendor ID */
35399 struct intel_dmi_quirk {
35400 void (*hook)(struct drm_device *dev);
35401 const struct dmi_system_id (*dmi_id_list)[];
35402 -};
35403 +} __do_const;
35404
35405 static int intel_dmi_reverse_brightness(const struct dmi_system_id *id)
35406 {
35407 @@ -8736,18 +8736,20 @@ static int intel_dmi_reverse_brightness(const struct dmi_system_id *id)
35408 return 1;
35409 }
35410
35411 -static const struct intel_dmi_quirk intel_dmi_quirks[] = {
35412 +static const struct dmi_system_id intel_dmi_quirks_table[] = {
35413 {
35414 - .dmi_id_list = &(const struct dmi_system_id[]) {
35415 - {
35416 - .callback = intel_dmi_reverse_brightness,
35417 - .ident = "NCR Corporation",
35418 - .matches = {DMI_MATCH(DMI_SYS_VENDOR, "NCR Corporation"),
35419 - DMI_MATCH(DMI_PRODUCT_NAME, ""),
35420 - },
35421 - },
35422 - { } /* terminating entry */
35423 + .callback = intel_dmi_reverse_brightness,
35424 + .ident = "NCR Corporation",
35425 + .matches = {DMI_MATCH(DMI_SYS_VENDOR, "NCR Corporation"),
35426 + DMI_MATCH(DMI_PRODUCT_NAME, ""),
35427 },
35428 + },
35429 + { } /* terminating entry */
35430 +};
35431 +
35432 +static const struct intel_dmi_quirk intel_dmi_quirks[] = {
35433 + {
35434 + .dmi_id_list = &intel_dmi_quirks_table,
35435 .hook = quirk_invert_brightness,
35436 },
35437 };
35438 diff --git a/drivers/gpu/drm/mga/mga_drv.h b/drivers/gpu/drm/mga/mga_drv.h
35439 index 54558a0..2d97005 100644
35440 --- a/drivers/gpu/drm/mga/mga_drv.h
35441 +++ b/drivers/gpu/drm/mga/mga_drv.h
35442 @@ -120,9 +120,9 @@ typedef struct drm_mga_private {
35443 u32 clear_cmd;
35444 u32 maccess;
35445
35446 - atomic_t vbl_received; /**< Number of vblanks received. */
35447 + atomic_unchecked_t vbl_received; /**< Number of vblanks received. */
35448 wait_queue_head_t fence_queue;
35449 - atomic_t last_fence_retired;
35450 + atomic_unchecked_t last_fence_retired;
35451 u32 next_fence_to_post;
35452
35453 unsigned int fb_cpp;
35454 diff --git a/drivers/gpu/drm/mga/mga_ioc32.c b/drivers/gpu/drm/mga/mga_ioc32.c
35455 index 709e90d..89a1c0d 100644
35456 --- a/drivers/gpu/drm/mga/mga_ioc32.c
35457 +++ b/drivers/gpu/drm/mga/mga_ioc32.c
35458 @@ -189,7 +189,7 @@ static int compat_mga_dma_bootstrap(struct file *file, unsigned int cmd,
35459 return 0;
35460 }
35461
35462 -drm_ioctl_compat_t *mga_compat_ioctls[] = {
35463 +drm_ioctl_compat_t mga_compat_ioctls[] = {
35464 [DRM_MGA_INIT] = compat_mga_init,
35465 [DRM_MGA_GETPARAM] = compat_mga_getparam,
35466 [DRM_MGA_DMA_BOOTSTRAP] = compat_mga_dma_bootstrap,
35467 @@ -207,18 +207,15 @@ drm_ioctl_compat_t *mga_compat_ioctls[] = {
35468 long mga_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
35469 {
35470 unsigned int nr = DRM_IOCTL_NR(cmd);
35471 - drm_ioctl_compat_t *fn = NULL;
35472 int ret;
35473
35474 if (nr < DRM_COMMAND_BASE)
35475 return drm_compat_ioctl(filp, cmd, arg);
35476
35477 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(mga_compat_ioctls))
35478 - fn = mga_compat_ioctls[nr - DRM_COMMAND_BASE];
35479 -
35480 - if (fn != NULL)
35481 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(mga_compat_ioctls)) {
35482 + drm_ioctl_compat_t fn = mga_compat_ioctls[nr - DRM_COMMAND_BASE];
35483 ret = (*fn) (filp, cmd, arg);
35484 - else
35485 + } else
35486 ret = drm_ioctl(filp, cmd, arg);
35487
35488 return ret;
35489 diff --git a/drivers/gpu/drm/mga/mga_irq.c b/drivers/gpu/drm/mga/mga_irq.c
35490 index 598c281..60d590e 100644
35491 --- a/drivers/gpu/drm/mga/mga_irq.c
35492 +++ b/drivers/gpu/drm/mga/mga_irq.c
35493 @@ -43,7 +43,7 @@ u32 mga_get_vblank_counter(struct drm_device *dev, int crtc)
35494 if (crtc != 0)
35495 return 0;
35496
35497 - return atomic_read(&dev_priv->vbl_received);
35498 + return atomic_read_unchecked(&dev_priv->vbl_received);
35499 }
35500
35501
35502 @@ -59,7 +59,7 @@ irqreturn_t mga_driver_irq_handler(DRM_IRQ_ARGS)
35503 /* VBLANK interrupt */
35504 if (status & MGA_VLINEPEN) {
35505 MGA_WRITE(MGA_ICLEAR, MGA_VLINEICLR);
35506 - atomic_inc(&dev_priv->vbl_received);
35507 + atomic_inc_unchecked(&dev_priv->vbl_received);
35508 drm_handle_vblank(dev, 0);
35509 handled = 1;
35510 }
35511 @@ -78,7 +78,7 @@ irqreturn_t mga_driver_irq_handler(DRM_IRQ_ARGS)
35512 if ((prim_start & ~0x03) != (prim_end & ~0x03))
35513 MGA_WRITE(MGA_PRIMEND, prim_end);
35514
35515 - atomic_inc(&dev_priv->last_fence_retired);
35516 + atomic_inc_unchecked(&dev_priv->last_fence_retired);
35517 DRM_WAKEUP(&dev_priv->fence_queue);
35518 handled = 1;
35519 }
35520 @@ -129,7 +129,7 @@ int mga_driver_fence_wait(struct drm_device *dev, unsigned int *sequence)
35521 * using fences.
35522 */
35523 DRM_WAIT_ON(ret, dev_priv->fence_queue, 3 * DRM_HZ,
35524 - (((cur_fence = atomic_read(&dev_priv->last_fence_retired))
35525 + (((cur_fence = atomic_read_unchecked(&dev_priv->last_fence_retired))
35526 - *sequence) <= (1 << 23)));
35527
35528 *sequence = cur_fence;
35529 diff --git a/drivers/gpu/drm/nouveau/nouveau_bios.c b/drivers/gpu/drm/nouveau/nouveau_bios.c
35530 index 50a6dd0..ea66ed8 100644
35531 --- a/drivers/gpu/drm/nouveau/nouveau_bios.c
35532 +++ b/drivers/gpu/drm/nouveau/nouveau_bios.c
35533 @@ -965,7 +965,7 @@ static int parse_bit_tmds_tbl_entry(struct drm_device *dev, struct nvbios *bios,
35534 struct bit_table {
35535 const char id;
35536 int (* const parse_fn)(struct drm_device *, struct nvbios *, struct bit_entry *);
35537 -};
35538 +} __no_const;
35539
35540 #define BIT_TABLE(id, funcid) ((struct bit_table){ id, parse_bit_##funcid##_tbl_entry })
35541
35542 diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.h b/drivers/gpu/drm/nouveau/nouveau_drm.h
35543 index 9c39baf..30a22be 100644
35544 --- a/drivers/gpu/drm/nouveau/nouveau_drm.h
35545 +++ b/drivers/gpu/drm/nouveau/nouveau_drm.h
35546 @@ -81,7 +81,7 @@ struct nouveau_drm {
35547 struct drm_global_reference mem_global_ref;
35548 struct ttm_bo_global_ref bo_global_ref;
35549 struct ttm_bo_device bdev;
35550 - atomic_t validate_sequence;
35551 + atomic_unchecked_t validate_sequence;
35552 int (*move)(struct nouveau_channel *,
35553 struct ttm_buffer_object *,
35554 struct ttm_mem_reg *, struct ttm_mem_reg *);
35555 diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c b/drivers/gpu/drm/nouveau/nouveau_gem.c
35556 index b4b4d0c..b7edc15 100644
35557 --- a/drivers/gpu/drm/nouveau/nouveau_gem.c
35558 +++ b/drivers/gpu/drm/nouveau/nouveau_gem.c
35559 @@ -322,7 +322,7 @@ validate_init(struct nouveau_channel *chan, struct drm_file *file_priv,
35560 int ret, i;
35561 struct nouveau_bo *res_bo = NULL;
35562
35563 - sequence = atomic_add_return(1, &drm->ttm.validate_sequence);
35564 + sequence = atomic_add_return_unchecked(1, &drm->ttm.validate_sequence);
35565 retry:
35566 if (++trycnt > 100000) {
35567 NV_ERROR(cli, "%s failed and gave up.\n", __func__);
35568 @@ -359,7 +359,7 @@ retry:
35569 if (ret) {
35570 validate_fini(op, NULL);
35571 if (unlikely(ret == -EAGAIN)) {
35572 - sequence = atomic_add_return(1, &drm->ttm.validate_sequence);
35573 + sequence = atomic_add_return_unchecked(1, &drm->ttm.validate_sequence);
35574 ret = ttm_bo_reserve_slowpath(&nvbo->bo, true,
35575 sequence);
35576 if (!ret)
35577 diff --git a/drivers/gpu/drm/nouveau/nouveau_ioc32.c b/drivers/gpu/drm/nouveau/nouveau_ioc32.c
35578 index 08214bc..9208577 100644
35579 --- a/drivers/gpu/drm/nouveau/nouveau_ioc32.c
35580 +++ b/drivers/gpu/drm/nouveau/nouveau_ioc32.c
35581 @@ -50,7 +50,7 @@ long nouveau_compat_ioctl(struct file *filp, unsigned int cmd,
35582 unsigned long arg)
35583 {
35584 unsigned int nr = DRM_IOCTL_NR(cmd);
35585 - drm_ioctl_compat_t *fn = NULL;
35586 + drm_ioctl_compat_t fn = NULL;
35587 int ret;
35588
35589 if (nr < DRM_COMMAND_BASE)
35590 diff --git a/drivers/gpu/drm/nouveau/nouveau_vga.c b/drivers/gpu/drm/nouveau/nouveau_vga.c
35591 index 25d3495..d81aaf6 100644
35592 --- a/drivers/gpu/drm/nouveau/nouveau_vga.c
35593 +++ b/drivers/gpu/drm/nouveau/nouveau_vga.c
35594 @@ -62,7 +62,7 @@ nouveau_switcheroo_can_switch(struct pci_dev *pdev)
35595 bool can_switch;
35596
35597 spin_lock(&dev->count_lock);
35598 - can_switch = (dev->open_count == 0);
35599 + can_switch = (local_read(&dev->open_count) == 0);
35600 spin_unlock(&dev->count_lock);
35601 return can_switch;
35602 }
35603 diff --git a/drivers/gpu/drm/r128/r128_cce.c b/drivers/gpu/drm/r128/r128_cce.c
35604 index d4660cf..70dbe65 100644
35605 --- a/drivers/gpu/drm/r128/r128_cce.c
35606 +++ b/drivers/gpu/drm/r128/r128_cce.c
35607 @@ -377,7 +377,7 @@ static int r128_do_init_cce(struct drm_device *dev, drm_r128_init_t *init)
35608
35609 /* GH: Simple idle check.
35610 */
35611 - atomic_set(&dev_priv->idle_count, 0);
35612 + atomic_set_unchecked(&dev_priv->idle_count, 0);
35613
35614 /* We don't support anything other than bus-mastering ring mode,
35615 * but the ring can be in either AGP or PCI space for the ring
35616 diff --git a/drivers/gpu/drm/r128/r128_drv.h b/drivers/gpu/drm/r128/r128_drv.h
35617 index 930c71b..499aded 100644
35618 --- a/drivers/gpu/drm/r128/r128_drv.h
35619 +++ b/drivers/gpu/drm/r128/r128_drv.h
35620 @@ -90,14 +90,14 @@ typedef struct drm_r128_private {
35621 int is_pci;
35622 unsigned long cce_buffers_offset;
35623
35624 - atomic_t idle_count;
35625 + atomic_unchecked_t idle_count;
35626
35627 int page_flipping;
35628 int current_page;
35629 u32 crtc_offset;
35630 u32 crtc_offset_cntl;
35631
35632 - atomic_t vbl_received;
35633 + atomic_unchecked_t vbl_received;
35634
35635 u32 color_fmt;
35636 unsigned int front_offset;
35637 diff --git a/drivers/gpu/drm/r128/r128_ioc32.c b/drivers/gpu/drm/r128/r128_ioc32.c
35638 index a954c54..9cc595c 100644
35639 --- a/drivers/gpu/drm/r128/r128_ioc32.c
35640 +++ b/drivers/gpu/drm/r128/r128_ioc32.c
35641 @@ -177,7 +177,7 @@ static int compat_r128_getparam(struct file *file, unsigned int cmd,
35642 return drm_ioctl(file, DRM_IOCTL_R128_GETPARAM, (unsigned long)getparam);
35643 }
35644
35645 -drm_ioctl_compat_t *r128_compat_ioctls[] = {
35646 +drm_ioctl_compat_t r128_compat_ioctls[] = {
35647 [DRM_R128_INIT] = compat_r128_init,
35648 [DRM_R128_DEPTH] = compat_r128_depth,
35649 [DRM_R128_STIPPLE] = compat_r128_stipple,
35650 @@ -196,18 +196,15 @@ drm_ioctl_compat_t *r128_compat_ioctls[] = {
35651 long r128_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
35652 {
35653 unsigned int nr = DRM_IOCTL_NR(cmd);
35654 - drm_ioctl_compat_t *fn = NULL;
35655 int ret;
35656
35657 if (nr < DRM_COMMAND_BASE)
35658 return drm_compat_ioctl(filp, cmd, arg);
35659
35660 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(r128_compat_ioctls))
35661 - fn = r128_compat_ioctls[nr - DRM_COMMAND_BASE];
35662 -
35663 - if (fn != NULL)
35664 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(r128_compat_ioctls)) {
35665 + drm_ioctl_compat_t fn = r128_compat_ioctls[nr - DRM_COMMAND_BASE];
35666 ret = (*fn) (filp, cmd, arg);
35667 - else
35668 + } else
35669 ret = drm_ioctl(filp, cmd, arg);
35670
35671 return ret;
35672 diff --git a/drivers/gpu/drm/r128/r128_irq.c b/drivers/gpu/drm/r128/r128_irq.c
35673 index 2ea4f09..d391371 100644
35674 --- a/drivers/gpu/drm/r128/r128_irq.c
35675 +++ b/drivers/gpu/drm/r128/r128_irq.c
35676 @@ -41,7 +41,7 @@ u32 r128_get_vblank_counter(struct drm_device *dev, int crtc)
35677 if (crtc != 0)
35678 return 0;
35679
35680 - return atomic_read(&dev_priv->vbl_received);
35681 + return atomic_read_unchecked(&dev_priv->vbl_received);
35682 }
35683
35684 irqreturn_t r128_driver_irq_handler(DRM_IRQ_ARGS)
35685 @@ -55,7 +55,7 @@ irqreturn_t r128_driver_irq_handler(DRM_IRQ_ARGS)
35686 /* VBLANK interrupt */
35687 if (status & R128_CRTC_VBLANK_INT) {
35688 R128_WRITE(R128_GEN_INT_STATUS, R128_CRTC_VBLANK_INT_AK);
35689 - atomic_inc(&dev_priv->vbl_received);
35690 + atomic_inc_unchecked(&dev_priv->vbl_received);
35691 drm_handle_vblank(dev, 0);
35692 return IRQ_HANDLED;
35693 }
35694 diff --git a/drivers/gpu/drm/r128/r128_state.c b/drivers/gpu/drm/r128/r128_state.c
35695 index 19bb7e6..de7e2a2 100644
35696 --- a/drivers/gpu/drm/r128/r128_state.c
35697 +++ b/drivers/gpu/drm/r128/r128_state.c
35698 @@ -320,10 +320,10 @@ static void r128_clear_box(drm_r128_private_t *dev_priv,
35699
35700 static void r128_cce_performance_boxes(drm_r128_private_t *dev_priv)
35701 {
35702 - if (atomic_read(&dev_priv->idle_count) == 0)
35703 + if (atomic_read_unchecked(&dev_priv->idle_count) == 0)
35704 r128_clear_box(dev_priv, 64, 4, 8, 8, 0, 255, 0);
35705 else
35706 - atomic_set(&dev_priv->idle_count, 0);
35707 + atomic_set_unchecked(&dev_priv->idle_count, 0);
35708 }
35709
35710 #endif
35711 diff --git a/drivers/gpu/drm/radeon/mkregtable.c b/drivers/gpu/drm/radeon/mkregtable.c
35712 index 5a82b6b..9e69c73 100644
35713 --- a/drivers/gpu/drm/radeon/mkregtable.c
35714 +++ b/drivers/gpu/drm/radeon/mkregtable.c
35715 @@ -637,14 +637,14 @@ static int parser_auth(struct table *t, const char *filename)
35716 regex_t mask_rex;
35717 regmatch_t match[4];
35718 char buf[1024];
35719 - size_t end;
35720 + long end;
35721 int len;
35722 int done = 0;
35723 int r;
35724 unsigned o;
35725 struct offset *offset;
35726 char last_reg_s[10];
35727 - int last_reg;
35728 + unsigned long last_reg;
35729
35730 if (regcomp
35731 (&mask_rex, "(0x[0-9a-fA-F]*) *([_a-zA-Z0-9]*)", REG_EXTENDED)) {
35732 diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c
35733 index 5073665..31d15a6 100644
35734 --- a/drivers/gpu/drm/radeon/radeon_device.c
35735 +++ b/drivers/gpu/drm/radeon/radeon_device.c
35736 @@ -976,7 +976,7 @@ static bool radeon_switcheroo_can_switch(struct pci_dev *pdev)
35737 bool can_switch;
35738
35739 spin_lock(&dev->count_lock);
35740 - can_switch = (dev->open_count == 0);
35741 + can_switch = (local_read(&dev->open_count) == 0);
35742 spin_unlock(&dev->count_lock);
35743 return can_switch;
35744 }
35745 diff --git a/drivers/gpu/drm/radeon/radeon_drv.h b/drivers/gpu/drm/radeon/radeon_drv.h
35746 index b369d42..8dd04eb 100644
35747 --- a/drivers/gpu/drm/radeon/radeon_drv.h
35748 +++ b/drivers/gpu/drm/radeon/radeon_drv.h
35749 @@ -258,7 +258,7 @@ typedef struct drm_radeon_private {
35750
35751 /* SW interrupt */
35752 wait_queue_head_t swi_queue;
35753 - atomic_t swi_emitted;
35754 + atomic_unchecked_t swi_emitted;
35755 int vblank_crtc;
35756 uint32_t irq_enable_reg;
35757 uint32_t r500_disp_irq_reg;
35758 diff --git a/drivers/gpu/drm/radeon/radeon_ioc32.c b/drivers/gpu/drm/radeon/radeon_ioc32.c
35759 index c180df8..5fd8186 100644
35760 --- a/drivers/gpu/drm/radeon/radeon_ioc32.c
35761 +++ b/drivers/gpu/drm/radeon/radeon_ioc32.c
35762 @@ -358,7 +358,7 @@ static int compat_radeon_cp_setparam(struct file *file, unsigned int cmd,
35763 request = compat_alloc_user_space(sizeof(*request));
35764 if (!access_ok(VERIFY_WRITE, request, sizeof(*request))
35765 || __put_user(req32.param, &request->param)
35766 - || __put_user((void __user *)(unsigned long)req32.value,
35767 + || __put_user((unsigned long)req32.value,
35768 &request->value))
35769 return -EFAULT;
35770
35771 @@ -368,7 +368,7 @@ static int compat_radeon_cp_setparam(struct file *file, unsigned int cmd,
35772 #define compat_radeon_cp_setparam NULL
35773 #endif /* X86_64 || IA64 */
35774
35775 -static drm_ioctl_compat_t *radeon_compat_ioctls[] = {
35776 +static drm_ioctl_compat_t radeon_compat_ioctls[] = {
35777 [DRM_RADEON_CP_INIT] = compat_radeon_cp_init,
35778 [DRM_RADEON_CLEAR] = compat_radeon_cp_clear,
35779 [DRM_RADEON_STIPPLE] = compat_radeon_cp_stipple,
35780 @@ -393,18 +393,15 @@ static drm_ioctl_compat_t *radeon_compat_ioctls[] = {
35781 long radeon_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
35782 {
35783 unsigned int nr = DRM_IOCTL_NR(cmd);
35784 - drm_ioctl_compat_t *fn = NULL;
35785 int ret;
35786
35787 if (nr < DRM_COMMAND_BASE)
35788 return drm_compat_ioctl(filp, cmd, arg);
35789
35790 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(radeon_compat_ioctls))
35791 - fn = radeon_compat_ioctls[nr - DRM_COMMAND_BASE];
35792 -
35793 - if (fn != NULL)
35794 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(radeon_compat_ioctls)) {
35795 + drm_ioctl_compat_t fn = radeon_compat_ioctls[nr - DRM_COMMAND_BASE];
35796 ret = (*fn) (filp, cmd, arg);
35797 - else
35798 + } else
35799 ret = drm_ioctl(filp, cmd, arg);
35800
35801 return ret;
35802 diff --git a/drivers/gpu/drm/radeon/radeon_irq.c b/drivers/gpu/drm/radeon/radeon_irq.c
35803 index 8d68e97..9dcfed8 100644
35804 --- a/drivers/gpu/drm/radeon/radeon_irq.c
35805 +++ b/drivers/gpu/drm/radeon/radeon_irq.c
35806 @@ -226,8 +226,8 @@ static int radeon_emit_irq(struct drm_device * dev)
35807 unsigned int ret;
35808 RING_LOCALS;
35809
35810 - atomic_inc(&dev_priv->swi_emitted);
35811 - ret = atomic_read(&dev_priv->swi_emitted);
35812 + atomic_inc_unchecked(&dev_priv->swi_emitted);
35813 + ret = atomic_read_unchecked(&dev_priv->swi_emitted);
35814
35815 BEGIN_RING(4);
35816 OUT_RING_REG(RADEON_LAST_SWI_REG, ret);
35817 @@ -353,7 +353,7 @@ int radeon_driver_irq_postinstall(struct drm_device *dev)
35818 drm_radeon_private_t *dev_priv =
35819 (drm_radeon_private_t *) dev->dev_private;
35820
35821 - atomic_set(&dev_priv->swi_emitted, 0);
35822 + atomic_set_unchecked(&dev_priv->swi_emitted, 0);
35823 DRM_INIT_WAITQUEUE(&dev_priv->swi_queue);
35824
35825 dev->max_vblank_count = 0x001fffff;
35826 diff --git a/drivers/gpu/drm/radeon/radeon_state.c b/drivers/gpu/drm/radeon/radeon_state.c
35827 index 4d20910..6726b6d 100644
35828 --- a/drivers/gpu/drm/radeon/radeon_state.c
35829 +++ b/drivers/gpu/drm/radeon/radeon_state.c
35830 @@ -2168,7 +2168,7 @@ static int radeon_cp_clear(struct drm_device *dev, void *data, struct drm_file *
35831 if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS)
35832 sarea_priv->nbox = RADEON_NR_SAREA_CLIPRECTS;
35833
35834 - if (DRM_COPY_FROM_USER(&depth_boxes, clear->depth_boxes,
35835 + if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS || DRM_COPY_FROM_USER(&depth_boxes, clear->depth_boxes,
35836 sarea_priv->nbox * sizeof(depth_boxes[0])))
35837 return -EFAULT;
35838
35839 @@ -3031,7 +3031,7 @@ static int radeon_cp_getparam(struct drm_device *dev, void *data, struct drm_fil
35840 {
35841 drm_radeon_private_t *dev_priv = dev->dev_private;
35842 drm_radeon_getparam_t *param = data;
35843 - int value;
35844 + int value = 0;
35845
35846 DRM_DEBUG("pid=%d\n", DRM_CURRENTPID);
35847
35848 diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
35849 index 6c0ce89..66f6d65 100644
35850 --- a/drivers/gpu/drm/radeon/radeon_ttm.c
35851 +++ b/drivers/gpu/drm/radeon/radeon_ttm.c
35852 @@ -782,7 +782,7 @@ void radeon_ttm_set_active_vram_size(struct radeon_device *rdev, u64 size)
35853 man->size = size >> PAGE_SHIFT;
35854 }
35855
35856 -static struct vm_operations_struct radeon_ttm_vm_ops;
35857 +static vm_operations_struct_no_const radeon_ttm_vm_ops __read_only;
35858 static const struct vm_operations_struct *ttm_vm_ops = NULL;
35859
35860 static int radeon_ttm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
35861 @@ -823,8 +823,10 @@ int radeon_mmap(struct file *filp, struct vm_area_struct *vma)
35862 }
35863 if (unlikely(ttm_vm_ops == NULL)) {
35864 ttm_vm_ops = vma->vm_ops;
35865 + pax_open_kernel();
35866 radeon_ttm_vm_ops = *ttm_vm_ops;
35867 radeon_ttm_vm_ops.fault = &radeon_ttm_fault;
35868 + pax_close_kernel();
35869 }
35870 vma->vm_ops = &radeon_ttm_vm_ops;
35871 return 0;
35872 @@ -862,28 +864,33 @@ static int radeon_ttm_debugfs_init(struct radeon_device *rdev)
35873 sprintf(radeon_mem_types_names[i], "radeon_vram_mm");
35874 else
35875 sprintf(radeon_mem_types_names[i], "radeon_gtt_mm");
35876 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
35877 - radeon_mem_types_list[i].show = &radeon_mm_dump_table;
35878 - radeon_mem_types_list[i].driver_features = 0;
35879 + pax_open_kernel();
35880 + *(const char **)&radeon_mem_types_list[i].name = radeon_mem_types_names[i];
35881 + *(void **)&radeon_mem_types_list[i].show = &radeon_mm_dump_table;
35882 + *(u32 *)&radeon_mem_types_list[i].driver_features = 0;
35883 if (i == 0)
35884 - radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_VRAM].priv;
35885 + *(void **)&radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_VRAM].priv;
35886 else
35887 - radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_TT].priv;
35888 -
35889 + *(void **)&radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_TT].priv;
35890 + pax_close_kernel();
35891 }
35892 /* Add ttm page pool to debugfs */
35893 sprintf(radeon_mem_types_names[i], "ttm_page_pool");
35894 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
35895 - radeon_mem_types_list[i].show = &ttm_page_alloc_debugfs;
35896 - radeon_mem_types_list[i].driver_features = 0;
35897 - radeon_mem_types_list[i++].data = NULL;
35898 + pax_open_kernel();
35899 + *(const char **)&radeon_mem_types_list[i].name = radeon_mem_types_names[i];
35900 + *(void **)&radeon_mem_types_list[i].show = &ttm_page_alloc_debugfs;
35901 + *(u32 *)&radeon_mem_types_list[i].driver_features = 0;
35902 + *(void **)&radeon_mem_types_list[i++].data = NULL;
35903 + pax_close_kernel();
35904 #ifdef CONFIG_SWIOTLB
35905 if (swiotlb_nr_tbl()) {
35906 sprintf(radeon_mem_types_names[i], "ttm_dma_page_pool");
35907 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
35908 - radeon_mem_types_list[i].show = &ttm_dma_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_dma_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 }
35918 #endif
35919 return radeon_debugfs_add_files(rdev, radeon_mem_types_list, i);
35920 diff --git a/drivers/gpu/drm/radeon/rs690.c b/drivers/gpu/drm/radeon/rs690.c
35921 index 5706d2a..17aedaa 100644
35922 --- a/drivers/gpu/drm/radeon/rs690.c
35923 +++ b/drivers/gpu/drm/radeon/rs690.c
35924 @@ -304,9 +304,11 @@ static void rs690_crtc_bandwidth_compute(struct radeon_device *rdev,
35925 if (rdev->pm.max_bandwidth.full > rdev->pm.sideport_bandwidth.full &&
35926 rdev->pm.sideport_bandwidth.full)
35927 rdev->pm.max_bandwidth = rdev->pm.sideport_bandwidth;
35928 - read_delay_latency.full = dfixed_const(370 * 800 * 1000);
35929 + read_delay_latency.full = dfixed_const(800 * 1000);
35930 read_delay_latency.full = dfixed_div(read_delay_latency,
35931 rdev->pm.igp_sideport_mclk);
35932 + a.full = dfixed_const(370);
35933 + read_delay_latency.full = dfixed_mul(read_delay_latency, a);
35934 } else {
35935 if (rdev->pm.max_bandwidth.full > rdev->pm.k8_bandwidth.full &&
35936 rdev->pm.k8_bandwidth.full)
35937 diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc.c b/drivers/gpu/drm/ttm/ttm_page_alloc.c
35938 index bd2a3b4..122d9ad 100644
35939 --- a/drivers/gpu/drm/ttm/ttm_page_alloc.c
35940 +++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c
35941 @@ -394,9 +394,9 @@ static int ttm_pool_get_num_unused_pages(void)
35942 static int ttm_pool_mm_shrink(struct shrinker *shrink,
35943 struct shrink_control *sc)
35944 {
35945 - static atomic_t start_pool = ATOMIC_INIT(0);
35946 + static atomic_unchecked_t start_pool = ATOMIC_INIT(0);
35947 unsigned i;
35948 - unsigned pool_offset = atomic_add_return(1, &start_pool);
35949 + unsigned pool_offset = atomic_add_return_unchecked(1, &start_pool);
35950 struct ttm_page_pool *pool;
35951 int shrink_pages = sc->nr_to_scan;
35952
35953 diff --git a/drivers/gpu/drm/udl/udl_fb.c b/drivers/gpu/drm/udl/udl_fb.c
35954 index 9f4be3d..cbc9fcc 100644
35955 --- a/drivers/gpu/drm/udl/udl_fb.c
35956 +++ b/drivers/gpu/drm/udl/udl_fb.c
35957 @@ -367,7 +367,6 @@ static int udl_fb_release(struct fb_info *info, int user)
35958 fb_deferred_io_cleanup(info);
35959 kfree(info->fbdefio);
35960 info->fbdefio = NULL;
35961 - info->fbops->fb_mmap = udl_fb_mmap;
35962 }
35963
35964 pr_warn("released /dev/fb%d user=%d count=%d\n",
35965 diff --git a/drivers/gpu/drm/via/via_drv.h b/drivers/gpu/drm/via/via_drv.h
35966 index 893a650..6190d3b 100644
35967 --- a/drivers/gpu/drm/via/via_drv.h
35968 +++ b/drivers/gpu/drm/via/via_drv.h
35969 @@ -51,7 +51,7 @@ typedef struct drm_via_ring_buffer {
35970 typedef uint32_t maskarray_t[5];
35971
35972 typedef struct drm_via_irq {
35973 - atomic_t irq_received;
35974 + atomic_unchecked_t irq_received;
35975 uint32_t pending_mask;
35976 uint32_t enable_mask;
35977 wait_queue_head_t irq_queue;
35978 @@ -75,7 +75,7 @@ typedef struct drm_via_private {
35979 struct timeval last_vblank;
35980 int last_vblank_valid;
35981 unsigned usec_per_vblank;
35982 - atomic_t vbl_received;
35983 + atomic_unchecked_t vbl_received;
35984 drm_via_state_t hc_state;
35985 char pci_buf[VIA_PCI_BUF_SIZE];
35986 const uint32_t *fire_offsets[VIA_FIRE_BUF_SIZE];
35987 diff --git a/drivers/gpu/drm/via/via_irq.c b/drivers/gpu/drm/via/via_irq.c
35988 index ac98964..5dbf512 100644
35989 --- a/drivers/gpu/drm/via/via_irq.c
35990 +++ b/drivers/gpu/drm/via/via_irq.c
35991 @@ -101,7 +101,7 @@ u32 via_get_vblank_counter(struct drm_device *dev, int crtc)
35992 if (crtc != 0)
35993 return 0;
35994
35995 - return atomic_read(&dev_priv->vbl_received);
35996 + return atomic_read_unchecked(&dev_priv->vbl_received);
35997 }
35998
35999 irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
36000 @@ -116,8 +116,8 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
36001
36002 status = VIA_READ(VIA_REG_INTERRUPT);
36003 if (status & VIA_IRQ_VBLANK_PENDING) {
36004 - atomic_inc(&dev_priv->vbl_received);
36005 - if (!(atomic_read(&dev_priv->vbl_received) & 0x0F)) {
36006 + atomic_inc_unchecked(&dev_priv->vbl_received);
36007 + if (!(atomic_read_unchecked(&dev_priv->vbl_received) & 0x0F)) {
36008 do_gettimeofday(&cur_vblank);
36009 if (dev_priv->last_vblank_valid) {
36010 dev_priv->usec_per_vblank =
36011 @@ -127,7 +127,7 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
36012 dev_priv->last_vblank = cur_vblank;
36013 dev_priv->last_vblank_valid = 1;
36014 }
36015 - if (!(atomic_read(&dev_priv->vbl_received) & 0xFF)) {
36016 + if (!(atomic_read_unchecked(&dev_priv->vbl_received) & 0xFF)) {
36017 DRM_DEBUG("US per vblank is: %u\n",
36018 dev_priv->usec_per_vblank);
36019 }
36020 @@ -137,7 +137,7 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
36021
36022 for (i = 0; i < dev_priv->num_irqs; ++i) {
36023 if (status & cur_irq->pending_mask) {
36024 - atomic_inc(&cur_irq->irq_received);
36025 + atomic_inc_unchecked(&cur_irq->irq_received);
36026 DRM_WAKEUP(&cur_irq->irq_queue);
36027 handled = 1;
36028 if (dev_priv->irq_map[drm_via_irq_dma0_td] == i)
36029 @@ -242,11 +242,11 @@ via_driver_irq_wait(struct drm_device *dev, unsigned int irq, int force_sequence
36030 DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * DRM_HZ,
36031 ((VIA_READ(masks[irq][2]) & masks[irq][3]) ==
36032 masks[irq][4]));
36033 - cur_irq_sequence = atomic_read(&cur_irq->irq_received);
36034 + cur_irq_sequence = atomic_read_unchecked(&cur_irq->irq_received);
36035 } else {
36036 DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * DRM_HZ,
36037 (((cur_irq_sequence =
36038 - atomic_read(&cur_irq->irq_received)) -
36039 + atomic_read_unchecked(&cur_irq->irq_received)) -
36040 *sequence) <= (1 << 23)));
36041 }
36042 *sequence = cur_irq_sequence;
36043 @@ -284,7 +284,7 @@ void via_driver_irq_preinstall(struct drm_device *dev)
36044 }
36045
36046 for (i = 0; i < dev_priv->num_irqs; ++i) {
36047 - atomic_set(&cur_irq->irq_received, 0);
36048 + atomic_set_unchecked(&cur_irq->irq_received, 0);
36049 cur_irq->enable_mask = dev_priv->irq_masks[i][0];
36050 cur_irq->pending_mask = dev_priv->irq_masks[i][1];
36051 DRM_INIT_WAITQUEUE(&cur_irq->irq_queue);
36052 @@ -366,7 +366,7 @@ int via_wait_irq(struct drm_device *dev, void *data, struct drm_file *file_priv)
36053 switch (irqwait->request.type & ~VIA_IRQ_FLAGS_MASK) {
36054 case VIA_IRQ_RELATIVE:
36055 irqwait->request.sequence +=
36056 - atomic_read(&cur_irq->irq_received);
36057 + atomic_read_unchecked(&cur_irq->irq_received);
36058 irqwait->request.type &= ~_DRM_VBLANK_RELATIVE;
36059 case VIA_IRQ_ABSOLUTE:
36060 break;
36061 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
36062 index 13aeda7..4a952d1 100644
36063 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
36064 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
36065 @@ -290,7 +290,7 @@ struct vmw_private {
36066 * Fencing and IRQs.
36067 */
36068
36069 - atomic_t marker_seq;
36070 + atomic_unchecked_t marker_seq;
36071 wait_queue_head_t fence_queue;
36072 wait_queue_head_t fifo_queue;
36073 int fence_queue_waiters; /* Protected by hw_mutex */
36074 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
36075 index 3eb1486..0a47ee9 100644
36076 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
36077 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
36078 @@ -137,7 +137,7 @@ int vmw_fifo_init(struct vmw_private *dev_priv, struct vmw_fifo_state *fifo)
36079 (unsigned int) min,
36080 (unsigned int) fifo->capabilities);
36081
36082 - atomic_set(&dev_priv->marker_seq, dev_priv->last_read_seqno);
36083 + atomic_set_unchecked(&dev_priv->marker_seq, dev_priv->last_read_seqno);
36084 iowrite32(dev_priv->last_read_seqno, fifo_mem + SVGA_FIFO_FENCE);
36085 vmw_marker_queue_init(&fifo->marker_queue);
36086 return vmw_fifo_send_fence(dev_priv, &dummy);
36087 @@ -355,7 +355,7 @@ void *vmw_fifo_reserve(struct vmw_private *dev_priv, uint32_t bytes)
36088 if (reserveable)
36089 iowrite32(bytes, fifo_mem +
36090 SVGA_FIFO_RESERVED);
36091 - return fifo_mem + (next_cmd >> 2);
36092 + return (__le32 __force_kernel *)fifo_mem + (next_cmd >> 2);
36093 } else {
36094 need_bounce = true;
36095 }
36096 @@ -475,7 +475,7 @@ int vmw_fifo_send_fence(struct vmw_private *dev_priv, uint32_t *seqno)
36097
36098 fm = vmw_fifo_reserve(dev_priv, bytes);
36099 if (unlikely(fm == NULL)) {
36100 - *seqno = atomic_read(&dev_priv->marker_seq);
36101 + *seqno = atomic_read_unchecked(&dev_priv->marker_seq);
36102 ret = -ENOMEM;
36103 (void)vmw_fallback_wait(dev_priv, false, true, *seqno,
36104 false, 3*HZ);
36105 @@ -483,7 +483,7 @@ int vmw_fifo_send_fence(struct vmw_private *dev_priv, uint32_t *seqno)
36106 }
36107
36108 do {
36109 - *seqno = atomic_add_return(1, &dev_priv->marker_seq);
36110 + *seqno = atomic_add_return_unchecked(1, &dev_priv->marker_seq);
36111 } while (*seqno == 0);
36112
36113 if (!(fifo_state->capabilities & SVGA_FIFO_CAP_FENCE)) {
36114 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c b/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
36115 index c509d40..3b640c3 100644
36116 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
36117 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
36118 @@ -138,7 +138,7 @@ int vmw_present_ioctl(struct drm_device *dev, void *data,
36119 int ret;
36120
36121 num_clips = arg->num_clips;
36122 - clips_ptr = (struct drm_vmw_rect *)(unsigned long)arg->clips_ptr;
36123 + clips_ptr = (struct drm_vmw_rect __user *)(unsigned long)arg->clips_ptr;
36124
36125 if (unlikely(num_clips == 0))
36126 return 0;
36127 @@ -222,7 +222,7 @@ int vmw_present_readback_ioctl(struct drm_device *dev, void *data,
36128 int ret;
36129
36130 num_clips = arg->num_clips;
36131 - clips_ptr = (struct drm_vmw_rect *)(unsigned long)arg->clips_ptr;
36132 + clips_ptr = (struct drm_vmw_rect __user *)(unsigned long)arg->clips_ptr;
36133
36134 if (unlikely(num_clips == 0))
36135 return 0;
36136 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c b/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
36137 index 4640adb..e1384ed 100644
36138 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
36139 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
36140 @@ -107,7 +107,7 @@ bool vmw_seqno_passed(struct vmw_private *dev_priv,
36141 * emitted. Then the fence is stale and signaled.
36142 */
36143
36144 - ret = ((atomic_read(&dev_priv->marker_seq) - seqno)
36145 + ret = ((atomic_read_unchecked(&dev_priv->marker_seq) - seqno)
36146 > VMW_FENCE_WRAP);
36147
36148 return ret;
36149 @@ -138,7 +138,7 @@ int vmw_fallback_wait(struct vmw_private *dev_priv,
36150
36151 if (fifo_idle)
36152 down_read(&fifo_state->rwsem);
36153 - signal_seq = atomic_read(&dev_priv->marker_seq);
36154 + signal_seq = atomic_read_unchecked(&dev_priv->marker_seq);
36155 ret = 0;
36156
36157 for (;;) {
36158 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c b/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
36159 index 8a8725c2..afed796 100644
36160 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
36161 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
36162 @@ -151,7 +151,7 @@ int vmw_wait_lag(struct vmw_private *dev_priv,
36163 while (!vmw_lag_lt(queue, us)) {
36164 spin_lock(&queue->lock);
36165 if (list_empty(&queue->head))
36166 - seqno = atomic_read(&dev_priv->marker_seq);
36167 + seqno = atomic_read_unchecked(&dev_priv->marker_seq);
36168 else {
36169 marker = list_first_entry(&queue->head,
36170 struct vmw_marker, head);
36171 diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
36172 index e6dbf09..3dd2540 100644
36173 --- a/drivers/hid/hid-core.c
36174 +++ b/drivers/hid/hid-core.c
36175 @@ -2268,7 +2268,7 @@ EXPORT_SYMBOL_GPL(hid_ignore);
36176
36177 int hid_add_device(struct hid_device *hdev)
36178 {
36179 - static atomic_t id = ATOMIC_INIT(0);
36180 + static atomic_unchecked_t id = ATOMIC_INIT(0);
36181 int ret;
36182
36183 if (WARN_ON(hdev->status & HID_STAT_ADDED))
36184 @@ -2302,7 +2302,7 @@ int hid_add_device(struct hid_device *hdev)
36185 /* XXX hack, any other cleaner solution after the driver core
36186 * is converted to allow more than 20 bytes as the device name? */
36187 dev_set_name(&hdev->dev, "%04X:%04X:%04X.%04X", hdev->bus,
36188 - hdev->vendor, hdev->product, atomic_inc_return(&id));
36189 + hdev->vendor, hdev->product, atomic_inc_return_unchecked(&id));
36190
36191 hid_debug_register(hdev, dev_name(&hdev->dev));
36192 ret = device_add(&hdev->dev);
36193 diff --git a/drivers/hid/hid-wiimote-debug.c b/drivers/hid/hid-wiimote-debug.c
36194 index 90124ff..3761764 100644
36195 --- a/drivers/hid/hid-wiimote-debug.c
36196 +++ b/drivers/hid/hid-wiimote-debug.c
36197 @@ -66,7 +66,7 @@ static ssize_t wiidebug_eeprom_read(struct file *f, char __user *u, size_t s,
36198 else if (size == 0)
36199 return -EIO;
36200
36201 - if (copy_to_user(u, buf, size))
36202 + if (size > sizeof(buf) || copy_to_user(u, buf, size))
36203 return -EFAULT;
36204
36205 *off += size;
36206 diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
36207 index 0b122f8..b1d8160 100644
36208 --- a/drivers/hv/channel.c
36209 +++ b/drivers/hv/channel.c
36210 @@ -394,8 +394,8 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer,
36211 int ret = 0;
36212 int t;
36213
36214 - next_gpadl_handle = atomic_read(&vmbus_connection.next_gpadl_handle);
36215 - atomic_inc(&vmbus_connection.next_gpadl_handle);
36216 + next_gpadl_handle = atomic_read_unchecked(&vmbus_connection.next_gpadl_handle);
36217 + atomic_inc_unchecked(&vmbus_connection.next_gpadl_handle);
36218
36219 ret = create_gpadl_header(kbuffer, size, &msginfo, &msgcount);
36220 if (ret)
36221 diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c
36222 index 7311589..861e9ef 100644
36223 --- a/drivers/hv/hv.c
36224 +++ b/drivers/hv/hv.c
36225 @@ -112,7 +112,7 @@ static u64 do_hypercall(u64 control, void *input, void *output)
36226 u64 output_address = (output) ? virt_to_phys(output) : 0;
36227 u32 output_address_hi = output_address >> 32;
36228 u32 output_address_lo = output_address & 0xFFFFFFFF;
36229 - void *hypercall_page = hv_context.hypercall_page;
36230 + void *hypercall_page = ktva_ktla(hv_context.hypercall_page);
36231
36232 __asm__ __volatile__ ("call *%8" : "=d"(hv_status_hi),
36233 "=a"(hv_status_lo) : "d" (control_hi),
36234 diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h
36235 index 12f2f9e..679603c 100644
36236 --- a/drivers/hv/hyperv_vmbus.h
36237 +++ b/drivers/hv/hyperv_vmbus.h
36238 @@ -591,7 +591,7 @@ enum vmbus_connect_state {
36239 struct vmbus_connection {
36240 enum vmbus_connect_state conn_state;
36241
36242 - atomic_t next_gpadl_handle;
36243 + atomic_unchecked_t next_gpadl_handle;
36244
36245 /*
36246 * Represents channel interrupts. Each bit position represents a
36247 diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
36248 index bf421e0..ce2c897 100644
36249 --- a/drivers/hv/vmbus_drv.c
36250 +++ b/drivers/hv/vmbus_drv.c
36251 @@ -668,10 +668,10 @@ int vmbus_device_register(struct hv_device *child_device_obj)
36252 {
36253 int ret = 0;
36254
36255 - static atomic_t device_num = ATOMIC_INIT(0);
36256 + static atomic_unchecked_t device_num = ATOMIC_INIT(0);
36257
36258 dev_set_name(&child_device_obj->device, "vmbus_0_%d",
36259 - atomic_inc_return(&device_num));
36260 + atomic_inc_return_unchecked(&device_num));
36261
36262 child_device_obj->device.bus = &hv_bus;
36263 child_device_obj->device.parent = &hv_acpi_dev->dev;
36264 diff --git a/drivers/hwmon/acpi_power_meter.c b/drivers/hwmon/acpi_power_meter.c
36265 index 6351aba..dc4aaf4 100644
36266 --- a/drivers/hwmon/acpi_power_meter.c
36267 +++ b/drivers/hwmon/acpi_power_meter.c
36268 @@ -117,7 +117,7 @@ struct sensor_template {
36269 struct device_attribute *devattr,
36270 const char *buf, size_t count);
36271 int index;
36272 -};
36273 +} __do_const;
36274
36275 /* Averaging interval */
36276 static int update_avg_interval(struct acpi_power_meter_resource *resource)
36277 @@ -629,7 +629,7 @@ static int register_attrs(struct acpi_power_meter_resource *resource,
36278 struct sensor_template *attrs)
36279 {
36280 struct device *dev = &resource->acpi_dev->dev;
36281 - struct sensor_device_attribute *sensors =
36282 + sensor_device_attribute_no_const *sensors =
36283 &resource->sensors[resource->num_sensors];
36284 int res = 0;
36285
36286 diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
36287 index b41baff..4953e4d 100644
36288 --- a/drivers/hwmon/applesmc.c
36289 +++ b/drivers/hwmon/applesmc.c
36290 @@ -1084,7 +1084,7 @@ static int applesmc_create_nodes(struct applesmc_node_group *groups, int num)
36291 {
36292 struct applesmc_node_group *grp;
36293 struct applesmc_dev_attr *node;
36294 - struct attribute *attr;
36295 + attribute_no_const *attr;
36296 int ret, i;
36297
36298 for (grp = groups; grp->format; grp++) {
36299 diff --git a/drivers/hwmon/asus_atk0110.c b/drivers/hwmon/asus_atk0110.c
36300 index b25c643..a13460d 100644
36301 --- a/drivers/hwmon/asus_atk0110.c
36302 +++ b/drivers/hwmon/asus_atk0110.c
36303 @@ -152,10 +152,10 @@ MODULE_DEVICE_TABLE(acpi, atk_ids);
36304 struct atk_sensor_data {
36305 struct list_head list;
36306 struct atk_data *data;
36307 - struct device_attribute label_attr;
36308 - struct device_attribute input_attr;
36309 - struct device_attribute limit1_attr;
36310 - struct device_attribute limit2_attr;
36311 + device_attribute_no_const label_attr;
36312 + device_attribute_no_const input_attr;
36313 + device_attribute_no_const limit1_attr;
36314 + device_attribute_no_const limit2_attr;
36315 char label_attr_name[ATTR_NAME_SIZE];
36316 char input_attr_name[ATTR_NAME_SIZE];
36317 char limit1_attr_name[ATTR_NAME_SIZE];
36318 @@ -275,7 +275,7 @@ static ssize_t atk_name_show(struct device *dev,
36319 static struct device_attribute atk_name_attr =
36320 __ATTR(name, 0444, atk_name_show, NULL);
36321
36322 -static void atk_init_attribute(struct device_attribute *attr, char *name,
36323 +static void atk_init_attribute(device_attribute_no_const *attr, char *name,
36324 sysfs_show_func show)
36325 {
36326 sysfs_attr_init(&attr->attr);
36327 diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c
36328 index 3f1e297..a6cafb5 100644
36329 --- a/drivers/hwmon/coretemp.c
36330 +++ b/drivers/hwmon/coretemp.c
36331 @@ -791,7 +791,7 @@ static int __cpuinit coretemp_cpu_callback(struct notifier_block *nfb,
36332 return NOTIFY_OK;
36333 }
36334
36335 -static struct notifier_block coretemp_cpu_notifier __refdata = {
36336 +static struct notifier_block coretemp_cpu_notifier = {
36337 .notifier_call = coretemp_cpu_callback,
36338 };
36339
36340 diff --git a/drivers/hwmon/ibmaem.c b/drivers/hwmon/ibmaem.c
36341 index a14f634..2916ee2 100644
36342 --- a/drivers/hwmon/ibmaem.c
36343 +++ b/drivers/hwmon/ibmaem.c
36344 @@ -925,7 +925,7 @@ static int aem_register_sensors(struct aem_data *data,
36345 struct aem_rw_sensor_template *rw)
36346 {
36347 struct device *dev = &data->pdev->dev;
36348 - struct sensor_device_attribute *sensors = data->sensors;
36349 + sensor_device_attribute_no_const *sensors = data->sensors;
36350 int err;
36351
36352 /* Set up read-only sensors */
36353 diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c
36354 index 9add6092..ee7ba3f 100644
36355 --- a/drivers/hwmon/pmbus/pmbus_core.c
36356 +++ b/drivers/hwmon/pmbus/pmbus_core.c
36357 @@ -781,7 +781,7 @@ static int pmbus_add_attribute(struct pmbus_data *data, struct attribute *attr)
36358 return 0;
36359 }
36360
36361 -static void pmbus_dev_attr_init(struct device_attribute *dev_attr,
36362 +static void pmbus_dev_attr_init(device_attribute_no_const *dev_attr,
36363 const char *name,
36364 umode_t mode,
36365 ssize_t (*show)(struct device *dev,
36366 @@ -798,7 +798,7 @@ static void pmbus_dev_attr_init(struct device_attribute *dev_attr,
36367 dev_attr->store = store;
36368 }
36369
36370 -static void pmbus_attr_init(struct sensor_device_attribute *a,
36371 +static void pmbus_attr_init(sensor_device_attribute_no_const *a,
36372 const char *name,
36373 umode_t mode,
36374 ssize_t (*show)(struct device *dev,
36375 @@ -820,7 +820,7 @@ static int pmbus_add_boolean(struct pmbus_data *data,
36376 u16 reg, u8 mask)
36377 {
36378 struct pmbus_boolean *boolean;
36379 - struct sensor_device_attribute *a;
36380 + sensor_device_attribute_no_const *a;
36381
36382 boolean = devm_kzalloc(data->dev, sizeof(*boolean), GFP_KERNEL);
36383 if (!boolean)
36384 @@ -845,7 +845,7 @@ static struct pmbus_sensor *pmbus_add_sensor(struct pmbus_data *data,
36385 bool update, bool readonly)
36386 {
36387 struct pmbus_sensor *sensor;
36388 - struct device_attribute *a;
36389 + device_attribute_no_const *a;
36390
36391 sensor = devm_kzalloc(data->dev, sizeof(*sensor), GFP_KERNEL);
36392 if (!sensor)
36393 @@ -876,7 +876,7 @@ static int pmbus_add_label(struct pmbus_data *data,
36394 const char *lstring, int index)
36395 {
36396 struct pmbus_label *label;
36397 - struct device_attribute *a;
36398 + device_attribute_no_const *a;
36399
36400 label = devm_kzalloc(data->dev, sizeof(*label), GFP_KERNEL);
36401 if (!label)
36402 diff --git a/drivers/hwmon/sht15.c b/drivers/hwmon/sht15.c
36403 index 2507f90..1645765 100644
36404 --- a/drivers/hwmon/sht15.c
36405 +++ b/drivers/hwmon/sht15.c
36406 @@ -169,7 +169,7 @@ struct sht15_data {
36407 int supply_uv;
36408 bool supply_uv_valid;
36409 struct work_struct update_supply_work;
36410 - atomic_t interrupt_handled;
36411 + atomic_unchecked_t interrupt_handled;
36412 };
36413
36414 /**
36415 @@ -542,13 +542,13 @@ static int sht15_measurement(struct sht15_data *data,
36416 ret = gpio_direction_input(data->pdata->gpio_data);
36417 if (ret)
36418 return ret;
36419 - atomic_set(&data->interrupt_handled, 0);
36420 + atomic_set_unchecked(&data->interrupt_handled, 0);
36421
36422 enable_irq(gpio_to_irq(data->pdata->gpio_data));
36423 if (gpio_get_value(data->pdata->gpio_data) == 0) {
36424 disable_irq_nosync(gpio_to_irq(data->pdata->gpio_data));
36425 /* Only relevant if the interrupt hasn't occurred. */
36426 - if (!atomic_read(&data->interrupt_handled))
36427 + if (!atomic_read_unchecked(&data->interrupt_handled))
36428 schedule_work(&data->read_work);
36429 }
36430 ret = wait_event_timeout(data->wait_queue,
36431 @@ -820,7 +820,7 @@ static irqreturn_t sht15_interrupt_fired(int irq, void *d)
36432
36433 /* First disable the interrupt */
36434 disable_irq_nosync(irq);
36435 - atomic_inc(&data->interrupt_handled);
36436 + atomic_inc_unchecked(&data->interrupt_handled);
36437 /* Then schedule a reading work struct */
36438 if (data->state != SHT15_READING_NOTHING)
36439 schedule_work(&data->read_work);
36440 @@ -842,11 +842,11 @@ static void sht15_bh_read_data(struct work_struct *work_s)
36441 * If not, then start the interrupt again - care here as could
36442 * have gone low in meantime so verify it hasn't!
36443 */
36444 - atomic_set(&data->interrupt_handled, 0);
36445 + atomic_set_unchecked(&data->interrupt_handled, 0);
36446 enable_irq(gpio_to_irq(data->pdata->gpio_data));
36447 /* If still not occurred or another handler was scheduled */
36448 if (gpio_get_value(data->pdata->gpio_data)
36449 - || atomic_read(&data->interrupt_handled))
36450 + || atomic_read_unchecked(&data->interrupt_handled))
36451 return;
36452 }
36453
36454 diff --git a/drivers/hwmon/via-cputemp.c b/drivers/hwmon/via-cputemp.c
36455 index 76f157b..9c0db1b 100644
36456 --- a/drivers/hwmon/via-cputemp.c
36457 +++ b/drivers/hwmon/via-cputemp.c
36458 @@ -296,7 +296,7 @@ static int __cpuinit via_cputemp_cpu_callback(struct notifier_block *nfb,
36459 return NOTIFY_OK;
36460 }
36461
36462 -static struct notifier_block via_cputemp_cpu_notifier __refdata = {
36463 +static struct notifier_block via_cputemp_cpu_notifier = {
36464 .notifier_call = via_cputemp_cpu_callback,
36465 };
36466
36467 diff --git a/drivers/i2c/busses/i2c-amd756-s4882.c b/drivers/i2c/busses/i2c-amd756-s4882.c
36468 index 378fcb5..5e91fa8 100644
36469 --- a/drivers/i2c/busses/i2c-amd756-s4882.c
36470 +++ b/drivers/i2c/busses/i2c-amd756-s4882.c
36471 @@ -43,7 +43,7 @@
36472 extern struct i2c_adapter amd756_smbus;
36473
36474 static struct i2c_adapter *s4882_adapter;
36475 -static struct i2c_algorithm *s4882_algo;
36476 +static i2c_algorithm_no_const *s4882_algo;
36477
36478 /* Wrapper access functions for multiplexed SMBus */
36479 static DEFINE_MUTEX(amd756_lock);
36480 diff --git a/drivers/i2c/busses/i2c-nforce2-s4985.c b/drivers/i2c/busses/i2c-nforce2-s4985.c
36481 index 29015eb..af2d8e9 100644
36482 --- a/drivers/i2c/busses/i2c-nforce2-s4985.c
36483 +++ b/drivers/i2c/busses/i2c-nforce2-s4985.c
36484 @@ -41,7 +41,7 @@
36485 extern struct i2c_adapter *nforce2_smbus;
36486
36487 static struct i2c_adapter *s4985_adapter;
36488 -static struct i2c_algorithm *s4985_algo;
36489 +static i2c_algorithm_no_const *s4985_algo;
36490
36491 /* Wrapper access functions for multiplexed SMBus */
36492 static DEFINE_MUTEX(nforce2_lock);
36493 diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c
36494 index c3ccdea..5b3dc1a 100644
36495 --- a/drivers/i2c/i2c-dev.c
36496 +++ b/drivers/i2c/i2c-dev.c
36497 @@ -271,7 +271,7 @@ static noinline int i2cdev_ioctl_rdrw(struct i2c_client *client,
36498 break;
36499 }
36500
36501 - data_ptrs[i] = (u8 __user *)rdwr_pa[i].buf;
36502 + data_ptrs[i] = (u8 __force_user *)rdwr_pa[i].buf;
36503 rdwr_pa[i].buf = memdup_user(data_ptrs[i], rdwr_pa[i].len);
36504 if (IS_ERR(rdwr_pa[i].buf)) {
36505 res = PTR_ERR(rdwr_pa[i].buf);
36506 diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
36507 index 8126824..55a2798 100644
36508 --- a/drivers/ide/ide-cd.c
36509 +++ b/drivers/ide/ide-cd.c
36510 @@ -768,7 +768,7 @@ static void cdrom_do_block_pc(ide_drive_t *drive, struct request *rq)
36511 alignment = queue_dma_alignment(q) | q->dma_pad_mask;
36512 if ((unsigned long)buf & alignment
36513 || blk_rq_bytes(rq) & q->dma_pad_mask
36514 - || object_is_on_stack(buf))
36515 + || object_starts_on_stack(buf))
36516 drive->dma = 0;
36517 }
36518 }
36519 diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
36520 index 8848f16..f8e6dd8 100644
36521 --- a/drivers/iio/industrialio-core.c
36522 +++ b/drivers/iio/industrialio-core.c
36523 @@ -506,7 +506,7 @@ static ssize_t iio_write_channel_info(struct device *dev,
36524 }
36525
36526 static
36527 -int __iio_device_attr_init(struct device_attribute *dev_attr,
36528 +int __iio_device_attr_init(device_attribute_no_const *dev_attr,
36529 const char *postfix,
36530 struct iio_chan_spec const *chan,
36531 ssize_t (*readfunc)(struct device *dev,
36532 diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
36533 index 784b97c..c9ceadf 100644
36534 --- a/drivers/infiniband/core/cm.c
36535 +++ b/drivers/infiniband/core/cm.c
36536 @@ -114,7 +114,7 @@ static char const counter_group_names[CM_COUNTER_GROUPS]
36537
36538 struct cm_counter_group {
36539 struct kobject obj;
36540 - atomic_long_t counter[CM_ATTR_COUNT];
36541 + atomic_long_unchecked_t counter[CM_ATTR_COUNT];
36542 };
36543
36544 struct cm_counter_attribute {
36545 @@ -1395,7 +1395,7 @@ static void cm_dup_req_handler(struct cm_work *work,
36546 struct ib_mad_send_buf *msg = NULL;
36547 int ret;
36548
36549 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36550 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36551 counter[CM_REQ_COUNTER]);
36552
36553 /* Quick state check to discard duplicate REQs. */
36554 @@ -1779,7 +1779,7 @@ static void cm_dup_rep_handler(struct cm_work *work)
36555 if (!cm_id_priv)
36556 return;
36557
36558 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36559 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36560 counter[CM_REP_COUNTER]);
36561 ret = cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg);
36562 if (ret)
36563 @@ -1946,7 +1946,7 @@ static int cm_rtu_handler(struct cm_work *work)
36564 if (cm_id_priv->id.state != IB_CM_REP_SENT &&
36565 cm_id_priv->id.state != IB_CM_MRA_REP_RCVD) {
36566 spin_unlock_irq(&cm_id_priv->lock);
36567 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36568 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36569 counter[CM_RTU_COUNTER]);
36570 goto out;
36571 }
36572 @@ -2129,7 +2129,7 @@ static int cm_dreq_handler(struct cm_work *work)
36573 cm_id_priv = cm_acquire_id(dreq_msg->remote_comm_id,
36574 dreq_msg->local_comm_id);
36575 if (!cm_id_priv) {
36576 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36577 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36578 counter[CM_DREQ_COUNTER]);
36579 cm_issue_drep(work->port, work->mad_recv_wc);
36580 return -EINVAL;
36581 @@ -2154,7 +2154,7 @@ static int cm_dreq_handler(struct cm_work *work)
36582 case IB_CM_MRA_REP_RCVD:
36583 break;
36584 case IB_CM_TIMEWAIT:
36585 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36586 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36587 counter[CM_DREQ_COUNTER]);
36588 if (cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg))
36589 goto unlock;
36590 @@ -2168,7 +2168,7 @@ static int cm_dreq_handler(struct cm_work *work)
36591 cm_free_msg(msg);
36592 goto deref;
36593 case IB_CM_DREQ_RCVD:
36594 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36595 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36596 counter[CM_DREQ_COUNTER]);
36597 goto unlock;
36598 default:
36599 @@ -2535,7 +2535,7 @@ static int cm_mra_handler(struct cm_work *work)
36600 ib_modify_mad(cm_id_priv->av.port->mad_agent,
36601 cm_id_priv->msg, timeout)) {
36602 if (cm_id_priv->id.lap_state == IB_CM_MRA_LAP_RCVD)
36603 - atomic_long_inc(&work->port->
36604 + atomic_long_inc_unchecked(&work->port->
36605 counter_group[CM_RECV_DUPLICATES].
36606 counter[CM_MRA_COUNTER]);
36607 goto out;
36608 @@ -2544,7 +2544,7 @@ static int cm_mra_handler(struct cm_work *work)
36609 break;
36610 case IB_CM_MRA_REQ_RCVD:
36611 case IB_CM_MRA_REP_RCVD:
36612 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36613 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36614 counter[CM_MRA_COUNTER]);
36615 /* fall through */
36616 default:
36617 @@ -2706,7 +2706,7 @@ static int cm_lap_handler(struct cm_work *work)
36618 case IB_CM_LAP_IDLE:
36619 break;
36620 case IB_CM_MRA_LAP_SENT:
36621 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36622 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36623 counter[CM_LAP_COUNTER]);
36624 if (cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg))
36625 goto unlock;
36626 @@ -2722,7 +2722,7 @@ static int cm_lap_handler(struct cm_work *work)
36627 cm_free_msg(msg);
36628 goto deref;
36629 case IB_CM_LAP_RCVD:
36630 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36631 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36632 counter[CM_LAP_COUNTER]);
36633 goto unlock;
36634 default:
36635 @@ -3006,7 +3006,7 @@ static int cm_sidr_req_handler(struct cm_work *work)
36636 cur_cm_id_priv = cm_insert_remote_sidr(cm_id_priv);
36637 if (cur_cm_id_priv) {
36638 spin_unlock_irq(&cm.lock);
36639 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36640 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36641 counter[CM_SIDR_REQ_COUNTER]);
36642 goto out; /* Duplicate message. */
36643 }
36644 @@ -3218,10 +3218,10 @@ static void cm_send_handler(struct ib_mad_agent *mad_agent,
36645 if (!msg->context[0] && (attr_index != CM_REJ_COUNTER))
36646 msg->retries = 1;
36647
36648 - atomic_long_add(1 + msg->retries,
36649 + atomic_long_add_unchecked(1 + msg->retries,
36650 &port->counter_group[CM_XMIT].counter[attr_index]);
36651 if (msg->retries)
36652 - atomic_long_add(msg->retries,
36653 + atomic_long_add_unchecked(msg->retries,
36654 &port->counter_group[CM_XMIT_RETRIES].
36655 counter[attr_index]);
36656
36657 @@ -3431,7 +3431,7 @@ static void cm_recv_handler(struct ib_mad_agent *mad_agent,
36658 }
36659
36660 attr_id = be16_to_cpu(mad_recv_wc->recv_buf.mad->mad_hdr.attr_id);
36661 - atomic_long_inc(&port->counter_group[CM_RECV].
36662 + atomic_long_inc_unchecked(&port->counter_group[CM_RECV].
36663 counter[attr_id - CM_ATTR_ID_OFFSET]);
36664
36665 work = kmalloc(sizeof *work + sizeof(struct ib_sa_path_rec) * paths,
36666 @@ -3636,7 +3636,7 @@ static ssize_t cm_show_counter(struct kobject *obj, struct attribute *attr,
36667 cm_attr = container_of(attr, struct cm_counter_attribute, attr);
36668
36669 return sprintf(buf, "%ld\n",
36670 - atomic_long_read(&group->counter[cm_attr->index]));
36671 + atomic_long_read_unchecked(&group->counter[cm_attr->index]));
36672 }
36673
36674 static const struct sysfs_ops cm_counter_ops = {
36675 diff --git a/drivers/infiniband/core/fmr_pool.c b/drivers/infiniband/core/fmr_pool.c
36676 index 9f5ad7c..588cd84 100644
36677 --- a/drivers/infiniband/core/fmr_pool.c
36678 +++ b/drivers/infiniband/core/fmr_pool.c
36679 @@ -98,8 +98,8 @@ struct ib_fmr_pool {
36680
36681 struct task_struct *thread;
36682
36683 - atomic_t req_ser;
36684 - atomic_t flush_ser;
36685 + atomic_unchecked_t req_ser;
36686 + atomic_unchecked_t flush_ser;
36687
36688 wait_queue_head_t force_wait;
36689 };
36690 @@ -179,10 +179,10 @@ static int ib_fmr_cleanup_thread(void *pool_ptr)
36691 struct ib_fmr_pool *pool = pool_ptr;
36692
36693 do {
36694 - if (atomic_read(&pool->flush_ser) - atomic_read(&pool->req_ser) < 0) {
36695 + if (atomic_read_unchecked(&pool->flush_ser) - atomic_read_unchecked(&pool->req_ser) < 0) {
36696 ib_fmr_batch_release(pool);
36697
36698 - atomic_inc(&pool->flush_ser);
36699 + atomic_inc_unchecked(&pool->flush_ser);
36700 wake_up_interruptible(&pool->force_wait);
36701
36702 if (pool->flush_function)
36703 @@ -190,7 +190,7 @@ static int ib_fmr_cleanup_thread(void *pool_ptr)
36704 }
36705
36706 set_current_state(TASK_INTERRUPTIBLE);
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 !kthread_should_stop())
36710 schedule();
36711 __set_current_state(TASK_RUNNING);
36712 @@ -282,8 +282,8 @@ struct ib_fmr_pool *ib_create_fmr_pool(struct ib_pd *pd,
36713 pool->dirty_watermark = params->dirty_watermark;
36714 pool->dirty_len = 0;
36715 spin_lock_init(&pool->pool_lock);
36716 - atomic_set(&pool->req_ser, 0);
36717 - atomic_set(&pool->flush_ser, 0);
36718 + atomic_set_unchecked(&pool->req_ser, 0);
36719 + atomic_set_unchecked(&pool->flush_ser, 0);
36720 init_waitqueue_head(&pool->force_wait);
36721
36722 pool->thread = kthread_run(ib_fmr_cleanup_thread,
36723 @@ -411,11 +411,11 @@ int ib_flush_fmr_pool(struct ib_fmr_pool *pool)
36724 }
36725 spin_unlock_irq(&pool->pool_lock);
36726
36727 - serial = atomic_inc_return(&pool->req_ser);
36728 + serial = atomic_inc_return_unchecked(&pool->req_ser);
36729 wake_up_process(pool->thread);
36730
36731 if (wait_event_interruptible(pool->force_wait,
36732 - atomic_read(&pool->flush_ser) - serial >= 0))
36733 + atomic_read_unchecked(&pool->flush_ser) - serial >= 0))
36734 return -EINTR;
36735
36736 return 0;
36737 @@ -525,7 +525,7 @@ int ib_fmr_pool_unmap(struct ib_pool_fmr *fmr)
36738 } else {
36739 list_add_tail(&fmr->list, &pool->dirty_list);
36740 if (++pool->dirty_len >= pool->dirty_watermark) {
36741 - atomic_inc(&pool->req_ser);
36742 + atomic_inc_unchecked(&pool->req_ser);
36743 wake_up_process(pool->thread);
36744 }
36745 }
36746 diff --git a/drivers/infiniband/hw/cxgb4/mem.c b/drivers/infiniband/hw/cxgb4/mem.c
36747 index 903a92d..9262548 100644
36748 --- a/drivers/infiniband/hw/cxgb4/mem.c
36749 +++ b/drivers/infiniband/hw/cxgb4/mem.c
36750 @@ -122,7 +122,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,
36751 int err;
36752 struct fw_ri_tpte tpt;
36753 u32 stag_idx;
36754 - static atomic_t key;
36755 + static atomic_unchecked_t key;
36756
36757 if (c4iw_fatal_error(rdev))
36758 return -EIO;
36759 @@ -139,7 +139,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,
36760 if (rdev->stats.stag.cur > rdev->stats.stag.max)
36761 rdev->stats.stag.max = rdev->stats.stag.cur;
36762 mutex_unlock(&rdev->stats.lock);
36763 - *stag = (stag_idx << 8) | (atomic_inc_return(&key) & 0xff);
36764 + *stag = (stag_idx << 8) | (atomic_inc_return_unchecked(&key) & 0xff);
36765 }
36766 PDBG("%s stag_state 0x%0x type 0x%0x pdid 0x%0x, stag_idx 0x%x\n",
36767 __func__, stag_state, type, pdid, stag_idx);
36768 diff --git a/drivers/infiniband/hw/ipath/ipath_rc.c b/drivers/infiniband/hw/ipath/ipath_rc.c
36769 index 79b3dbc..96e5fcc 100644
36770 --- a/drivers/infiniband/hw/ipath/ipath_rc.c
36771 +++ b/drivers/infiniband/hw/ipath/ipath_rc.c
36772 @@ -1868,7 +1868,7 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
36773 struct ib_atomic_eth *ateth;
36774 struct ipath_ack_entry *e;
36775 u64 vaddr;
36776 - atomic64_t *maddr;
36777 + atomic64_unchecked_t *maddr;
36778 u64 sdata;
36779 u32 rkey;
36780 u8 next;
36781 @@ -1903,11 +1903,11 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
36782 IB_ACCESS_REMOTE_ATOMIC)))
36783 goto nack_acc_unlck;
36784 /* Perform atomic OP and save result. */
36785 - maddr = (atomic64_t *) qp->r_sge.sge.vaddr;
36786 + maddr = (atomic64_unchecked_t *) qp->r_sge.sge.vaddr;
36787 sdata = be64_to_cpu(ateth->swap_data);
36788 e = &qp->s_ack_queue[qp->r_head_ack_queue];
36789 e->atomic_data = (opcode == OP(FETCH_ADD)) ?
36790 - (u64) atomic64_add_return(sdata, maddr) - sdata :
36791 + (u64) atomic64_add_return_unchecked(sdata, maddr) - sdata :
36792 (u64) cmpxchg((u64 *) qp->r_sge.sge.vaddr,
36793 be64_to_cpu(ateth->compare_data),
36794 sdata);
36795 diff --git a/drivers/infiniband/hw/ipath/ipath_ruc.c b/drivers/infiniband/hw/ipath/ipath_ruc.c
36796 index 1f95bba..9530f87 100644
36797 --- a/drivers/infiniband/hw/ipath/ipath_ruc.c
36798 +++ b/drivers/infiniband/hw/ipath/ipath_ruc.c
36799 @@ -266,7 +266,7 @@ static void ipath_ruc_loopback(struct ipath_qp *sqp)
36800 unsigned long flags;
36801 struct ib_wc wc;
36802 u64 sdata;
36803 - atomic64_t *maddr;
36804 + atomic64_unchecked_t *maddr;
36805 enum ib_wc_status send_status;
36806
36807 /*
36808 @@ -382,11 +382,11 @@ again:
36809 IB_ACCESS_REMOTE_ATOMIC)))
36810 goto acc_err;
36811 /* Perform atomic OP and save result. */
36812 - maddr = (atomic64_t *) qp->r_sge.sge.vaddr;
36813 + maddr = (atomic64_unchecked_t *) qp->r_sge.sge.vaddr;
36814 sdata = wqe->wr.wr.atomic.compare_add;
36815 *(u64 *) sqp->s_sge.sge.vaddr =
36816 (wqe->wr.opcode == IB_WR_ATOMIC_FETCH_AND_ADD) ?
36817 - (u64) atomic64_add_return(sdata, maddr) - sdata :
36818 + (u64) atomic64_add_return_unchecked(sdata, maddr) - sdata :
36819 (u64) cmpxchg((u64 *) qp->r_sge.sge.vaddr,
36820 sdata, wqe->wr.wr.atomic.swap);
36821 goto send_comp;
36822 diff --git a/drivers/infiniband/hw/mthca/mthca_cmd.c b/drivers/infiniband/hw/mthca/mthca_cmd.c
36823 index 9d3e5c1..d9afe4a 100644
36824 --- a/drivers/infiniband/hw/mthca/mthca_cmd.c
36825 +++ b/drivers/infiniband/hw/mthca/mthca_cmd.c
36826 @@ -772,7 +772,7 @@ static void mthca_setup_cmd_doorbells(struct mthca_dev *dev, u64 base)
36827 mthca_dbg(dev, "Mapped doorbell page for posting FW commands\n");
36828 }
36829
36830 -int mthca_QUERY_FW(struct mthca_dev *dev)
36831 +int __intentional_overflow(-1) mthca_QUERY_FW(struct mthca_dev *dev)
36832 {
36833 struct mthca_mailbox *mailbox;
36834 u32 *outbox;
36835 diff --git a/drivers/infiniband/hw/mthca/mthca_mr.c b/drivers/infiniband/hw/mthca/mthca_mr.c
36836 index ed9a989..e0c5871 100644
36837 --- a/drivers/infiniband/hw/mthca/mthca_mr.c
36838 +++ b/drivers/infiniband/hw/mthca/mthca_mr.c
36839 @@ -426,7 +426,7 @@ static inline u32 adjust_key(struct mthca_dev *dev, u32 key)
36840 return key;
36841 }
36842
36843 -int mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift,
36844 +int __intentional_overflow(-1) mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift,
36845 u64 iova, u64 total_size, u32 access, struct mthca_mr *mr)
36846 {
36847 struct mthca_mailbox *mailbox;
36848 diff --git a/drivers/infiniband/hw/nes/nes.c b/drivers/infiniband/hw/nes/nes.c
36849 index 4291410..d2ab1fb 100644
36850 --- a/drivers/infiniband/hw/nes/nes.c
36851 +++ b/drivers/infiniband/hw/nes/nes.c
36852 @@ -98,7 +98,7 @@ MODULE_PARM_DESC(limit_maxrdreqsz, "Limit max read request size to 256 Bytes");
36853 LIST_HEAD(nes_adapter_list);
36854 static LIST_HEAD(nes_dev_list);
36855
36856 -atomic_t qps_destroyed;
36857 +atomic_unchecked_t qps_destroyed;
36858
36859 static unsigned int ee_flsh_adapter;
36860 static unsigned int sysfs_nonidx_addr;
36861 @@ -269,7 +269,7 @@ static void nes_cqp_rem_ref_callback(struct nes_device *nesdev, struct nes_cqp_r
36862 struct nes_qp *nesqp = cqp_request->cqp_callback_pointer;
36863 struct nes_adapter *nesadapter = nesdev->nesadapter;
36864
36865 - atomic_inc(&qps_destroyed);
36866 + atomic_inc_unchecked(&qps_destroyed);
36867
36868 /* Free the control structures */
36869
36870 diff --git a/drivers/infiniband/hw/nes/nes.h b/drivers/infiniband/hw/nes/nes.h
36871 index 33cc589..3bd6538 100644
36872 --- a/drivers/infiniband/hw/nes/nes.h
36873 +++ b/drivers/infiniband/hw/nes/nes.h
36874 @@ -177,17 +177,17 @@ extern unsigned int nes_debug_level;
36875 extern unsigned int wqm_quanta;
36876 extern struct list_head nes_adapter_list;
36877
36878 -extern atomic_t cm_connects;
36879 -extern atomic_t cm_accepts;
36880 -extern atomic_t cm_disconnects;
36881 -extern atomic_t cm_closes;
36882 -extern atomic_t cm_connecteds;
36883 -extern atomic_t cm_connect_reqs;
36884 -extern atomic_t cm_rejects;
36885 -extern atomic_t mod_qp_timouts;
36886 -extern atomic_t qps_created;
36887 -extern atomic_t qps_destroyed;
36888 -extern atomic_t sw_qps_destroyed;
36889 +extern atomic_unchecked_t cm_connects;
36890 +extern atomic_unchecked_t cm_accepts;
36891 +extern atomic_unchecked_t cm_disconnects;
36892 +extern atomic_unchecked_t cm_closes;
36893 +extern atomic_unchecked_t cm_connecteds;
36894 +extern atomic_unchecked_t cm_connect_reqs;
36895 +extern atomic_unchecked_t cm_rejects;
36896 +extern atomic_unchecked_t mod_qp_timouts;
36897 +extern atomic_unchecked_t qps_created;
36898 +extern atomic_unchecked_t qps_destroyed;
36899 +extern atomic_unchecked_t sw_qps_destroyed;
36900 extern u32 mh_detected;
36901 extern u32 mh_pauses_sent;
36902 extern u32 cm_packets_sent;
36903 @@ -196,16 +196,16 @@ extern u32 cm_packets_created;
36904 extern u32 cm_packets_received;
36905 extern u32 cm_packets_dropped;
36906 extern u32 cm_packets_retrans;
36907 -extern atomic_t cm_listens_created;
36908 -extern atomic_t cm_listens_destroyed;
36909 +extern atomic_unchecked_t cm_listens_created;
36910 +extern atomic_unchecked_t cm_listens_destroyed;
36911 extern u32 cm_backlog_drops;
36912 -extern atomic_t cm_loopbacks;
36913 -extern atomic_t cm_nodes_created;
36914 -extern atomic_t cm_nodes_destroyed;
36915 -extern atomic_t cm_accel_dropped_pkts;
36916 -extern atomic_t cm_resets_recvd;
36917 -extern atomic_t pau_qps_created;
36918 -extern atomic_t pau_qps_destroyed;
36919 +extern atomic_unchecked_t cm_loopbacks;
36920 +extern atomic_unchecked_t cm_nodes_created;
36921 +extern atomic_unchecked_t cm_nodes_destroyed;
36922 +extern atomic_unchecked_t cm_accel_dropped_pkts;
36923 +extern atomic_unchecked_t cm_resets_recvd;
36924 +extern atomic_unchecked_t pau_qps_created;
36925 +extern atomic_unchecked_t pau_qps_destroyed;
36926
36927 extern u32 int_mod_timer_init;
36928 extern u32 int_mod_cq_depth_256;
36929 diff --git a/drivers/infiniband/hw/nes/nes_cm.c b/drivers/infiniband/hw/nes/nes_cm.c
36930 index 24b9f1a..00fd004 100644
36931 --- a/drivers/infiniband/hw/nes/nes_cm.c
36932 +++ b/drivers/infiniband/hw/nes/nes_cm.c
36933 @@ -68,14 +68,14 @@ u32 cm_packets_dropped;
36934 u32 cm_packets_retrans;
36935 u32 cm_packets_created;
36936 u32 cm_packets_received;
36937 -atomic_t cm_listens_created;
36938 -atomic_t cm_listens_destroyed;
36939 +atomic_unchecked_t cm_listens_created;
36940 +atomic_unchecked_t cm_listens_destroyed;
36941 u32 cm_backlog_drops;
36942 -atomic_t cm_loopbacks;
36943 -atomic_t cm_nodes_created;
36944 -atomic_t cm_nodes_destroyed;
36945 -atomic_t cm_accel_dropped_pkts;
36946 -atomic_t cm_resets_recvd;
36947 +atomic_unchecked_t cm_loopbacks;
36948 +atomic_unchecked_t cm_nodes_created;
36949 +atomic_unchecked_t cm_nodes_destroyed;
36950 +atomic_unchecked_t cm_accel_dropped_pkts;
36951 +atomic_unchecked_t cm_resets_recvd;
36952
36953 static inline int mini_cm_accelerated(struct nes_cm_core *, struct nes_cm_node *);
36954 static struct nes_cm_listener *mini_cm_listen(struct nes_cm_core *, struct nes_vnic *, struct nes_cm_info *);
36955 @@ -148,13 +148,13 @@ static struct nes_cm_ops nes_cm_api = {
36956
36957 static struct nes_cm_core *g_cm_core;
36958
36959 -atomic_t cm_connects;
36960 -atomic_t cm_accepts;
36961 -atomic_t cm_disconnects;
36962 -atomic_t cm_closes;
36963 -atomic_t cm_connecteds;
36964 -atomic_t cm_connect_reqs;
36965 -atomic_t cm_rejects;
36966 +atomic_unchecked_t cm_connects;
36967 +atomic_unchecked_t cm_accepts;
36968 +atomic_unchecked_t cm_disconnects;
36969 +atomic_unchecked_t cm_closes;
36970 +atomic_unchecked_t cm_connecteds;
36971 +atomic_unchecked_t cm_connect_reqs;
36972 +atomic_unchecked_t cm_rejects;
36973
36974 int nes_add_ref_cm_node(struct nes_cm_node *cm_node)
36975 {
36976 @@ -1272,7 +1272,7 @@ static int mini_cm_dec_refcnt_listen(struct nes_cm_core *cm_core,
36977 kfree(listener);
36978 listener = NULL;
36979 ret = 0;
36980 - atomic_inc(&cm_listens_destroyed);
36981 + atomic_inc_unchecked(&cm_listens_destroyed);
36982 } else {
36983 spin_unlock_irqrestore(&cm_core->listen_list_lock, flags);
36984 }
36985 @@ -1466,7 +1466,7 @@ static struct nes_cm_node *make_cm_node(struct nes_cm_core *cm_core,
36986 cm_node->rem_mac);
36987
36988 add_hte_node(cm_core, cm_node);
36989 - atomic_inc(&cm_nodes_created);
36990 + atomic_inc_unchecked(&cm_nodes_created);
36991
36992 return cm_node;
36993 }
36994 @@ -1524,7 +1524,7 @@ static int rem_ref_cm_node(struct nes_cm_core *cm_core,
36995 }
36996
36997 atomic_dec(&cm_core->node_cnt);
36998 - atomic_inc(&cm_nodes_destroyed);
36999 + atomic_inc_unchecked(&cm_nodes_destroyed);
37000 nesqp = cm_node->nesqp;
37001 if (nesqp) {
37002 nesqp->cm_node = NULL;
37003 @@ -1588,7 +1588,7 @@ static int process_options(struct nes_cm_node *cm_node, u8 *optionsloc,
37004
37005 static void drop_packet(struct sk_buff *skb)
37006 {
37007 - atomic_inc(&cm_accel_dropped_pkts);
37008 + atomic_inc_unchecked(&cm_accel_dropped_pkts);
37009 dev_kfree_skb_any(skb);
37010 }
37011
37012 @@ -1651,7 +1651,7 @@ static void handle_rst_pkt(struct nes_cm_node *cm_node, struct sk_buff *skb,
37013 {
37014
37015 int reset = 0; /* whether to send reset in case of err.. */
37016 - atomic_inc(&cm_resets_recvd);
37017 + atomic_inc_unchecked(&cm_resets_recvd);
37018 nes_debug(NES_DBG_CM, "Received Reset, cm_node = %p, state = %u."
37019 " refcnt=%d\n", cm_node, cm_node->state,
37020 atomic_read(&cm_node->ref_count));
37021 @@ -2292,7 +2292,7 @@ static struct nes_cm_node *mini_cm_connect(struct nes_cm_core *cm_core,
37022 rem_ref_cm_node(cm_node->cm_core, cm_node);
37023 return NULL;
37024 }
37025 - atomic_inc(&cm_loopbacks);
37026 + atomic_inc_unchecked(&cm_loopbacks);
37027 loopbackremotenode->loopbackpartner = cm_node;
37028 loopbackremotenode->tcp_cntxt.rcv_wscale =
37029 NES_CM_DEFAULT_RCV_WND_SCALE;
37030 @@ -2567,7 +2567,7 @@ static int mini_cm_recv_pkt(struct nes_cm_core *cm_core,
37031 nes_queue_mgt_skbs(skb, nesvnic, cm_node->nesqp);
37032 else {
37033 rem_ref_cm_node(cm_core, cm_node);
37034 - atomic_inc(&cm_accel_dropped_pkts);
37035 + atomic_inc_unchecked(&cm_accel_dropped_pkts);
37036 dev_kfree_skb_any(skb);
37037 }
37038 break;
37039 @@ -2875,7 +2875,7 @@ static int nes_cm_disconn_true(struct nes_qp *nesqp)
37040
37041 if ((cm_id) && (cm_id->event_handler)) {
37042 if (issue_disconn) {
37043 - atomic_inc(&cm_disconnects);
37044 + atomic_inc_unchecked(&cm_disconnects);
37045 cm_event.event = IW_CM_EVENT_DISCONNECT;
37046 cm_event.status = disconn_status;
37047 cm_event.local_addr = cm_id->local_addr;
37048 @@ -2897,7 +2897,7 @@ static int nes_cm_disconn_true(struct nes_qp *nesqp)
37049 }
37050
37051 if (issue_close) {
37052 - atomic_inc(&cm_closes);
37053 + atomic_inc_unchecked(&cm_closes);
37054 nes_disconnect(nesqp, 1);
37055
37056 cm_id->provider_data = nesqp;
37057 @@ -3033,7 +3033,7 @@ int nes_accept(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
37058
37059 nes_debug(NES_DBG_CM, "QP%u, cm_node=%p, jiffies = %lu listener = %p\n",
37060 nesqp->hwqp.qp_id, cm_node, jiffies, cm_node->listener);
37061 - atomic_inc(&cm_accepts);
37062 + atomic_inc_unchecked(&cm_accepts);
37063
37064 nes_debug(NES_DBG_CM, "netdev refcnt = %u.\n",
37065 netdev_refcnt_read(nesvnic->netdev));
37066 @@ -3228,7 +3228,7 @@ int nes_reject(struct iw_cm_id *cm_id, const void *pdata, u8 pdata_len)
37067 struct nes_cm_core *cm_core;
37068 u8 *start_buff;
37069
37070 - atomic_inc(&cm_rejects);
37071 + atomic_inc_unchecked(&cm_rejects);
37072 cm_node = (struct nes_cm_node *)cm_id->provider_data;
37073 loopback = cm_node->loopbackpartner;
37074 cm_core = cm_node->cm_core;
37075 @@ -3288,7 +3288,7 @@ int nes_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
37076 ntohl(cm_id->local_addr.sin_addr.s_addr),
37077 ntohs(cm_id->local_addr.sin_port));
37078
37079 - atomic_inc(&cm_connects);
37080 + atomic_inc_unchecked(&cm_connects);
37081 nesqp->active_conn = 1;
37082
37083 /* cache the cm_id in the qp */
37084 @@ -3398,7 +3398,7 @@ int nes_create_listen(struct iw_cm_id *cm_id, int backlog)
37085 g_cm_core->api->stop_listener(g_cm_core, (void *)cm_node);
37086 return err;
37087 }
37088 - atomic_inc(&cm_listens_created);
37089 + atomic_inc_unchecked(&cm_listens_created);
37090 }
37091
37092 cm_id->add_ref(cm_id);
37093 @@ -3499,7 +3499,7 @@ static void cm_event_connected(struct nes_cm_event *event)
37094
37095 if (nesqp->destroyed)
37096 return;
37097 - atomic_inc(&cm_connecteds);
37098 + atomic_inc_unchecked(&cm_connecteds);
37099 nes_debug(NES_DBG_CM, "QP%u attempting to connect to 0x%08X:0x%04X on"
37100 " local port 0x%04X. jiffies = %lu.\n",
37101 nesqp->hwqp.qp_id,
37102 @@ -3679,7 +3679,7 @@ static void cm_event_reset(struct nes_cm_event *event)
37103
37104 cm_id->add_ref(cm_id);
37105 ret = cm_id->event_handler(cm_id, &cm_event);
37106 - atomic_inc(&cm_closes);
37107 + atomic_inc_unchecked(&cm_closes);
37108 cm_event.event = IW_CM_EVENT_CLOSE;
37109 cm_event.status = 0;
37110 cm_event.provider_data = cm_id->provider_data;
37111 @@ -3715,7 +3715,7 @@ static void cm_event_mpa_req(struct nes_cm_event *event)
37112 return;
37113 cm_id = cm_node->cm_id;
37114
37115 - atomic_inc(&cm_connect_reqs);
37116 + atomic_inc_unchecked(&cm_connect_reqs);
37117 nes_debug(NES_DBG_CM, "cm_node = %p - cm_id = %p, jiffies = %lu\n",
37118 cm_node, cm_id, jiffies);
37119
37120 @@ -3755,7 +3755,7 @@ static void cm_event_mpa_reject(struct nes_cm_event *event)
37121 return;
37122 cm_id = cm_node->cm_id;
37123
37124 - atomic_inc(&cm_connect_reqs);
37125 + atomic_inc_unchecked(&cm_connect_reqs);
37126 nes_debug(NES_DBG_CM, "cm_node = %p - cm_id = %p, jiffies = %lu\n",
37127 cm_node, cm_id, jiffies);
37128
37129 diff --git a/drivers/infiniband/hw/nes/nes_mgt.c b/drivers/infiniband/hw/nes/nes_mgt.c
37130 index 4166452..fc952c3 100644
37131 --- a/drivers/infiniband/hw/nes/nes_mgt.c
37132 +++ b/drivers/infiniband/hw/nes/nes_mgt.c
37133 @@ -40,8 +40,8 @@
37134 #include "nes.h"
37135 #include "nes_mgt.h"
37136
37137 -atomic_t pau_qps_created;
37138 -atomic_t pau_qps_destroyed;
37139 +atomic_unchecked_t pau_qps_created;
37140 +atomic_unchecked_t pau_qps_destroyed;
37141
37142 static void nes_replenish_mgt_rq(struct nes_vnic_mgt *mgtvnic)
37143 {
37144 @@ -621,7 +621,7 @@ void nes_destroy_pau_qp(struct nes_device *nesdev, struct nes_qp *nesqp)
37145 {
37146 struct sk_buff *skb;
37147 unsigned long flags;
37148 - atomic_inc(&pau_qps_destroyed);
37149 + atomic_inc_unchecked(&pau_qps_destroyed);
37150
37151 /* Free packets that have not yet been forwarded */
37152 /* Lock is acquired by skb_dequeue when removing the skb */
37153 @@ -810,7 +810,7 @@ static void nes_mgt_ce_handler(struct nes_device *nesdev, struct nes_hw_nic_cq *
37154 cq->cq_vbase[head].cqe_words[NES_NIC_CQE_HASH_RCVNXT]);
37155 skb_queue_head_init(&nesqp->pau_list);
37156 spin_lock_init(&nesqp->pau_lock);
37157 - atomic_inc(&pau_qps_created);
37158 + atomic_inc_unchecked(&pau_qps_created);
37159 nes_change_quad_hash(nesdev, mgtvnic->nesvnic, nesqp);
37160 }
37161
37162 diff --git a/drivers/infiniband/hw/nes/nes_nic.c b/drivers/infiniband/hw/nes/nes_nic.c
37163 index 85cf4d1..05d8e71 100644
37164 --- a/drivers/infiniband/hw/nes/nes_nic.c
37165 +++ b/drivers/infiniband/hw/nes/nes_nic.c
37166 @@ -1273,39 +1273,39 @@ static void nes_netdev_get_ethtool_stats(struct net_device *netdev,
37167 target_stat_values[++index] = mh_detected;
37168 target_stat_values[++index] = mh_pauses_sent;
37169 target_stat_values[++index] = nesvnic->endnode_ipv4_tcp_retransmits;
37170 - target_stat_values[++index] = atomic_read(&cm_connects);
37171 - target_stat_values[++index] = atomic_read(&cm_accepts);
37172 - target_stat_values[++index] = atomic_read(&cm_disconnects);
37173 - target_stat_values[++index] = atomic_read(&cm_connecteds);
37174 - target_stat_values[++index] = atomic_read(&cm_connect_reqs);
37175 - target_stat_values[++index] = atomic_read(&cm_rejects);
37176 - target_stat_values[++index] = atomic_read(&mod_qp_timouts);
37177 - target_stat_values[++index] = atomic_read(&qps_created);
37178 - target_stat_values[++index] = atomic_read(&sw_qps_destroyed);
37179 - target_stat_values[++index] = atomic_read(&qps_destroyed);
37180 - target_stat_values[++index] = atomic_read(&cm_closes);
37181 + target_stat_values[++index] = atomic_read_unchecked(&cm_connects);
37182 + target_stat_values[++index] = atomic_read_unchecked(&cm_accepts);
37183 + target_stat_values[++index] = atomic_read_unchecked(&cm_disconnects);
37184 + target_stat_values[++index] = atomic_read_unchecked(&cm_connecteds);
37185 + target_stat_values[++index] = atomic_read_unchecked(&cm_connect_reqs);
37186 + target_stat_values[++index] = atomic_read_unchecked(&cm_rejects);
37187 + target_stat_values[++index] = atomic_read_unchecked(&mod_qp_timouts);
37188 + target_stat_values[++index] = atomic_read_unchecked(&qps_created);
37189 + target_stat_values[++index] = atomic_read_unchecked(&sw_qps_destroyed);
37190 + target_stat_values[++index] = atomic_read_unchecked(&qps_destroyed);
37191 + target_stat_values[++index] = atomic_read_unchecked(&cm_closes);
37192 target_stat_values[++index] = cm_packets_sent;
37193 target_stat_values[++index] = cm_packets_bounced;
37194 target_stat_values[++index] = cm_packets_created;
37195 target_stat_values[++index] = cm_packets_received;
37196 target_stat_values[++index] = cm_packets_dropped;
37197 target_stat_values[++index] = cm_packets_retrans;
37198 - target_stat_values[++index] = atomic_read(&cm_listens_created);
37199 - target_stat_values[++index] = atomic_read(&cm_listens_destroyed);
37200 + target_stat_values[++index] = atomic_read_unchecked(&cm_listens_created);
37201 + target_stat_values[++index] = atomic_read_unchecked(&cm_listens_destroyed);
37202 target_stat_values[++index] = cm_backlog_drops;
37203 - target_stat_values[++index] = atomic_read(&cm_loopbacks);
37204 - target_stat_values[++index] = atomic_read(&cm_nodes_created);
37205 - target_stat_values[++index] = atomic_read(&cm_nodes_destroyed);
37206 - target_stat_values[++index] = atomic_read(&cm_accel_dropped_pkts);
37207 - target_stat_values[++index] = atomic_read(&cm_resets_recvd);
37208 + target_stat_values[++index] = atomic_read_unchecked(&cm_loopbacks);
37209 + target_stat_values[++index] = atomic_read_unchecked(&cm_nodes_created);
37210 + target_stat_values[++index] = atomic_read_unchecked(&cm_nodes_destroyed);
37211 + target_stat_values[++index] = atomic_read_unchecked(&cm_accel_dropped_pkts);
37212 + target_stat_values[++index] = atomic_read_unchecked(&cm_resets_recvd);
37213 target_stat_values[++index] = nesadapter->free_4kpbl;
37214 target_stat_values[++index] = nesadapter->free_256pbl;
37215 target_stat_values[++index] = int_mod_timer_init;
37216 target_stat_values[++index] = nesvnic->lro_mgr.stats.aggregated;
37217 target_stat_values[++index] = nesvnic->lro_mgr.stats.flushed;
37218 target_stat_values[++index] = nesvnic->lro_mgr.stats.no_desc;
37219 - target_stat_values[++index] = atomic_read(&pau_qps_created);
37220 - target_stat_values[++index] = atomic_read(&pau_qps_destroyed);
37221 + target_stat_values[++index] = atomic_read_unchecked(&pau_qps_created);
37222 + target_stat_values[++index] = atomic_read_unchecked(&pau_qps_destroyed);
37223 }
37224
37225 /**
37226 diff --git a/drivers/infiniband/hw/nes/nes_verbs.c b/drivers/infiniband/hw/nes/nes_verbs.c
37227 index 8f67fe2..8960859 100644
37228 --- a/drivers/infiniband/hw/nes/nes_verbs.c
37229 +++ b/drivers/infiniband/hw/nes/nes_verbs.c
37230 @@ -46,9 +46,9 @@
37231
37232 #include <rdma/ib_umem.h>
37233
37234 -atomic_t mod_qp_timouts;
37235 -atomic_t qps_created;
37236 -atomic_t sw_qps_destroyed;
37237 +atomic_unchecked_t mod_qp_timouts;
37238 +atomic_unchecked_t qps_created;
37239 +atomic_unchecked_t sw_qps_destroyed;
37240
37241 static void nes_unregister_ofa_device(struct nes_ib_device *nesibdev);
37242
37243 @@ -1134,7 +1134,7 @@ static struct ib_qp *nes_create_qp(struct ib_pd *ibpd,
37244 if (init_attr->create_flags)
37245 return ERR_PTR(-EINVAL);
37246
37247 - atomic_inc(&qps_created);
37248 + atomic_inc_unchecked(&qps_created);
37249 switch (init_attr->qp_type) {
37250 case IB_QPT_RC:
37251 if (nes_drv_opt & NES_DRV_OPT_NO_INLINE_DATA) {
37252 @@ -1465,7 +1465,7 @@ static int nes_destroy_qp(struct ib_qp *ibqp)
37253 struct iw_cm_event cm_event;
37254 int ret = 0;
37255
37256 - atomic_inc(&sw_qps_destroyed);
37257 + atomic_inc_unchecked(&sw_qps_destroyed);
37258 nesqp->destroyed = 1;
37259
37260 /* Blow away the connection if it exists. */
37261 diff --git a/drivers/infiniband/hw/qib/qib.h b/drivers/infiniband/hw/qib/qib.h
37262 index 4d11575..3e890e5 100644
37263 --- a/drivers/infiniband/hw/qib/qib.h
37264 +++ b/drivers/infiniband/hw/qib/qib.h
37265 @@ -51,6 +51,7 @@
37266 #include <linux/completion.h>
37267 #include <linux/kref.h>
37268 #include <linux/sched.h>
37269 +#include <linux/slab.h>
37270
37271 #include "qib_common.h"
37272 #include "qib_verbs.h"
37273 diff --git a/drivers/input/gameport/gameport.c b/drivers/input/gameport/gameport.c
37274 index da739d9..da1c7f4 100644
37275 --- a/drivers/input/gameport/gameport.c
37276 +++ b/drivers/input/gameport/gameport.c
37277 @@ -487,14 +487,14 @@ EXPORT_SYMBOL(gameport_set_phys);
37278 */
37279 static void gameport_init_port(struct gameport *gameport)
37280 {
37281 - static atomic_t gameport_no = ATOMIC_INIT(0);
37282 + static atomic_unchecked_t gameport_no = ATOMIC_INIT(0);
37283
37284 __module_get(THIS_MODULE);
37285
37286 mutex_init(&gameport->drv_mutex);
37287 device_initialize(&gameport->dev);
37288 dev_set_name(&gameport->dev, "gameport%lu",
37289 - (unsigned long)atomic_inc_return(&gameport_no) - 1);
37290 + (unsigned long)atomic_inc_return_unchecked(&gameport_no) - 1);
37291 gameport->dev.bus = &gameport_bus;
37292 gameport->dev.release = gameport_release_port;
37293 if (gameport->parent)
37294 diff --git a/drivers/input/input.c b/drivers/input/input.c
37295 index c044699..174d71a 100644
37296 --- a/drivers/input/input.c
37297 +++ b/drivers/input/input.c
37298 @@ -2019,7 +2019,7 @@ static void devm_input_device_unregister(struct device *dev, void *res)
37299 */
37300 int input_register_device(struct input_dev *dev)
37301 {
37302 - static atomic_t input_no = ATOMIC_INIT(0);
37303 + static atomic_unchecked_t input_no = ATOMIC_INIT(0);
37304 struct input_devres *devres = NULL;
37305 struct input_handler *handler;
37306 unsigned int packet_size;
37307 @@ -2074,7 +2074,7 @@ int input_register_device(struct input_dev *dev)
37308 dev->setkeycode = input_default_setkeycode;
37309
37310 dev_set_name(&dev->dev, "input%ld",
37311 - (unsigned long) atomic_inc_return(&input_no) - 1);
37312 + (unsigned long) atomic_inc_return_unchecked(&input_no) - 1);
37313
37314 error = device_add(&dev->dev);
37315 if (error)
37316 diff --git a/drivers/input/joystick/sidewinder.c b/drivers/input/joystick/sidewinder.c
37317 index 04c69af..5f92d00 100644
37318 --- a/drivers/input/joystick/sidewinder.c
37319 +++ b/drivers/input/joystick/sidewinder.c
37320 @@ -30,6 +30,7 @@
37321 #include <linux/kernel.h>
37322 #include <linux/module.h>
37323 #include <linux/slab.h>
37324 +#include <linux/sched.h>
37325 #include <linux/init.h>
37326 #include <linux/input.h>
37327 #include <linux/gameport.h>
37328 diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
37329 index d6cbfe9..6225402 100644
37330 --- a/drivers/input/joystick/xpad.c
37331 +++ b/drivers/input/joystick/xpad.c
37332 @@ -735,7 +735,7 @@ static void xpad_led_set(struct led_classdev *led_cdev,
37333
37334 static int xpad_led_probe(struct usb_xpad *xpad)
37335 {
37336 - static atomic_t led_seq = ATOMIC_INIT(0);
37337 + static atomic_unchecked_t led_seq = ATOMIC_INIT(0);
37338 long led_no;
37339 struct xpad_led *led;
37340 struct led_classdev *led_cdev;
37341 @@ -748,7 +748,7 @@ static int xpad_led_probe(struct usb_xpad *xpad)
37342 if (!led)
37343 return -ENOMEM;
37344
37345 - led_no = (long)atomic_inc_return(&led_seq) - 1;
37346 + led_no = (long)atomic_inc_return_unchecked(&led_seq) - 1;
37347
37348 snprintf(led->name, sizeof(led->name), "xpad%ld", led_no);
37349 led->xpad = xpad;
37350 diff --git a/drivers/input/mouse/psmouse.h b/drivers/input/mouse/psmouse.h
37351 index 2f0b39d..7370f13 100644
37352 --- a/drivers/input/mouse/psmouse.h
37353 +++ b/drivers/input/mouse/psmouse.h
37354 @@ -116,7 +116,7 @@ struct psmouse_attribute {
37355 ssize_t (*set)(struct psmouse *psmouse, void *data,
37356 const char *buf, size_t count);
37357 bool protect;
37358 -};
37359 +} __do_const;
37360 #define to_psmouse_attr(a) container_of((a), struct psmouse_attribute, dattr)
37361
37362 ssize_t psmouse_attr_show_helper(struct device *dev, struct device_attribute *attr,
37363 diff --git a/drivers/input/mousedev.c b/drivers/input/mousedev.c
37364 index 4c842c3..590b0bf 100644
37365 --- a/drivers/input/mousedev.c
37366 +++ b/drivers/input/mousedev.c
37367 @@ -738,7 +738,7 @@ static ssize_t mousedev_read(struct file *file, char __user *buffer,
37368
37369 spin_unlock_irq(&client->packet_lock);
37370
37371 - if (copy_to_user(buffer, data, count))
37372 + if (count > sizeof(data) || copy_to_user(buffer, data, count))
37373 return -EFAULT;
37374
37375 return count;
37376 diff --git a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c
37377 index 25fc597..558bf3b3 100644
37378 --- a/drivers/input/serio/serio.c
37379 +++ b/drivers/input/serio/serio.c
37380 @@ -496,7 +496,7 @@ static void serio_release_port(struct device *dev)
37381 */
37382 static void serio_init_port(struct serio *serio)
37383 {
37384 - static atomic_t serio_no = ATOMIC_INIT(0);
37385 + static atomic_unchecked_t serio_no = ATOMIC_INIT(0);
37386
37387 __module_get(THIS_MODULE);
37388
37389 @@ -507,7 +507,7 @@ static void serio_init_port(struct serio *serio)
37390 mutex_init(&serio->drv_mutex);
37391 device_initialize(&serio->dev);
37392 dev_set_name(&serio->dev, "serio%ld",
37393 - (long)atomic_inc_return(&serio_no) - 1);
37394 + (long)atomic_inc_return_unchecked(&serio_no) - 1);
37395 serio->dev.bus = &serio_bus;
37396 serio->dev.release = serio_release_port;
37397 serio->dev.groups = serio_device_attr_groups;
37398 diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
37399 index b972d43..8943713 100644
37400 --- a/drivers/iommu/iommu.c
37401 +++ b/drivers/iommu/iommu.c
37402 @@ -554,7 +554,7 @@ static struct notifier_block iommu_bus_nb = {
37403 static void iommu_bus_init(struct bus_type *bus, struct iommu_ops *ops)
37404 {
37405 bus_register_notifier(bus, &iommu_bus_nb);
37406 - bus_for_each_dev(bus, NULL, ops, add_iommu_group);
37407 + bus_for_each_dev(bus, NULL, (void *)ops, add_iommu_group);
37408 }
37409
37410 /**
37411 diff --git a/drivers/iommu/irq_remapping.c b/drivers/iommu/irq_remapping.c
37412 index 7c11ff3..5b2d7a7 100644
37413 --- a/drivers/iommu/irq_remapping.c
37414 +++ b/drivers/iommu/irq_remapping.c
37415 @@ -369,10 +369,12 @@ static void ir_print_prefix(struct irq_data *data, struct seq_file *p)
37416
37417 void irq_remap_modify_chip_defaults(struct irq_chip *chip)
37418 {
37419 - chip->irq_print_chip = ir_print_prefix;
37420 - chip->irq_ack = ir_ack_apic_edge;
37421 - chip->irq_eoi = ir_ack_apic_level;
37422 - chip->irq_set_affinity = x86_io_apic_ops.set_affinity;
37423 + pax_open_kernel();
37424 + *(void **)&chip->irq_print_chip = ir_print_prefix;
37425 + *(void **)&chip->irq_ack = ir_ack_apic_edge;
37426 + *(void **)&chip->irq_eoi = ir_ack_apic_level;
37427 + *(void **)&chip->irq_set_affinity = x86_io_apic_ops.set_affinity;
37428 + pax_close_kernel();
37429 }
37430
37431 bool setup_remapped_irq(int irq, struct irq_cfg *cfg, struct irq_chip *chip)
37432 diff --git a/drivers/irqchip/irq-gic.c b/drivers/irqchip/irq-gic.c
37433 index fc6aebf..762c5f5 100644
37434 --- a/drivers/irqchip/irq-gic.c
37435 +++ b/drivers/irqchip/irq-gic.c
37436 @@ -83,7 +83,7 @@ static u8 gic_cpu_map[NR_GIC_CPU_IF] __read_mostly;
37437 * Supported arch specific GIC irq extension.
37438 * Default make them NULL.
37439 */
37440 -struct irq_chip gic_arch_extn = {
37441 +irq_chip_no_const gic_arch_extn = {
37442 .irq_eoi = NULL,
37443 .irq_mask = NULL,
37444 .irq_unmask = NULL,
37445 @@ -332,7 +332,7 @@ static void gic_handle_cascade_irq(unsigned int irq, struct irq_desc *desc)
37446 chained_irq_exit(chip, desc);
37447 }
37448
37449 -static struct irq_chip gic_chip = {
37450 +static irq_chip_no_const gic_chip __read_only = {
37451 .name = "GIC",
37452 .irq_mask = gic_mask_irq,
37453 .irq_unmask = gic_unmask_irq,
37454 diff --git a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c
37455 index 89562a8..218999b 100644
37456 --- a/drivers/isdn/capi/capi.c
37457 +++ b/drivers/isdn/capi/capi.c
37458 @@ -81,8 +81,8 @@ struct capiminor {
37459
37460 struct capi20_appl *ap;
37461 u32 ncci;
37462 - atomic_t datahandle;
37463 - atomic_t msgid;
37464 + atomic_unchecked_t datahandle;
37465 + atomic_unchecked_t msgid;
37466
37467 struct tty_port port;
37468 int ttyinstop;
37469 @@ -391,7 +391,7 @@ gen_data_b3_resp_for(struct capiminor *mp, struct sk_buff *skb)
37470 capimsg_setu16(s, 2, mp->ap->applid);
37471 capimsg_setu8 (s, 4, CAPI_DATA_B3);
37472 capimsg_setu8 (s, 5, CAPI_RESP);
37473 - capimsg_setu16(s, 6, atomic_inc_return(&mp->msgid));
37474 + capimsg_setu16(s, 6, atomic_inc_return_unchecked(&mp->msgid));
37475 capimsg_setu32(s, 8, mp->ncci);
37476 capimsg_setu16(s, 12, datahandle);
37477 }
37478 @@ -512,14 +512,14 @@ static void handle_minor_send(struct capiminor *mp)
37479 mp->outbytes -= len;
37480 spin_unlock_bh(&mp->outlock);
37481
37482 - datahandle = atomic_inc_return(&mp->datahandle);
37483 + datahandle = atomic_inc_return_unchecked(&mp->datahandle);
37484 skb_push(skb, CAPI_DATA_B3_REQ_LEN);
37485 memset(skb->data, 0, CAPI_DATA_B3_REQ_LEN);
37486 capimsg_setu16(skb->data, 0, CAPI_DATA_B3_REQ_LEN);
37487 capimsg_setu16(skb->data, 2, mp->ap->applid);
37488 capimsg_setu8 (skb->data, 4, CAPI_DATA_B3);
37489 capimsg_setu8 (skb->data, 5, CAPI_REQ);
37490 - capimsg_setu16(skb->data, 6, atomic_inc_return(&mp->msgid));
37491 + capimsg_setu16(skb->data, 6, atomic_inc_return_unchecked(&mp->msgid));
37492 capimsg_setu32(skb->data, 8, mp->ncci); /* NCCI */
37493 capimsg_setu32(skb->data, 12, (u32)(long)skb->data);/* Data32 */
37494 capimsg_setu16(skb->data, 16, len); /* Data length */
37495 diff --git a/drivers/isdn/capi/kcapi.c b/drivers/isdn/capi/kcapi.c
37496 index 9b1b274..c123709 100644
37497 --- a/drivers/isdn/capi/kcapi.c
37498 +++ b/drivers/isdn/capi/kcapi.c
37499 @@ -93,7 +93,7 @@ capi_ctr_put(struct capi_ctr *ctr)
37500
37501 static inline struct capi_ctr *get_capi_ctr_by_nr(u16 contr)
37502 {
37503 - if (contr - 1 >= CAPI_MAXCONTR)
37504 + if (contr < 1 || contr - 1 >= CAPI_MAXCONTR)
37505 return NULL;
37506
37507 return capi_controller[contr - 1];
37508 @@ -103,7 +103,7 @@ static inline struct capi20_appl *__get_capi_appl_by_nr(u16 applid)
37509 {
37510 lockdep_assert_held(&capi_controller_lock);
37511
37512 - if (applid - 1 >= CAPI_MAXAPPL)
37513 + if (applid < 1 || applid - 1 >= CAPI_MAXAPPL)
37514 return NULL;
37515
37516 return capi_applications[applid - 1];
37517 @@ -111,7 +111,7 @@ static inline struct capi20_appl *__get_capi_appl_by_nr(u16 applid)
37518
37519 static inline struct capi20_appl *get_capi_appl_by_nr(u16 applid)
37520 {
37521 - if (applid - 1 >= CAPI_MAXAPPL)
37522 + if (applid < 1 || applid - 1 >= CAPI_MAXAPPL)
37523 return NULL;
37524
37525 return rcu_dereference(capi_applications[applid - 1]);
37526 diff --git a/drivers/isdn/gigaset/interface.c b/drivers/isdn/gigaset/interface.c
37527 index e2b5396..c5486dc 100644
37528 --- a/drivers/isdn/gigaset/interface.c
37529 +++ b/drivers/isdn/gigaset/interface.c
37530 @@ -130,9 +130,9 @@ static int if_open(struct tty_struct *tty, struct file *filp)
37531 }
37532 tty->driver_data = cs;
37533
37534 - ++cs->port.count;
37535 + atomic_inc(&cs->port.count);
37536
37537 - if (cs->port.count == 1) {
37538 + if (atomic_read(&cs->port.count) == 1) {
37539 tty_port_tty_set(&cs->port, tty);
37540 cs->port.low_latency = 1;
37541 }
37542 @@ -156,9 +156,9 @@ static void if_close(struct tty_struct *tty, struct file *filp)
37543
37544 if (!cs->connected)
37545 gig_dbg(DEBUG_IF, "not connected"); /* nothing to do */
37546 - else if (!cs->port.count)
37547 + else if (!atomic_read(&cs->port.count))
37548 dev_warn(cs->dev, "%s: device not opened\n", __func__);
37549 - else if (!--cs->port.count)
37550 + else if (!atomic_dec_return(&cs->port.count))
37551 tty_port_tty_set(&cs->port, NULL);
37552
37553 mutex_unlock(&cs->mutex);
37554 diff --git a/drivers/isdn/hardware/avm/b1.c b/drivers/isdn/hardware/avm/b1.c
37555 index 821f7ac..28d4030 100644
37556 --- a/drivers/isdn/hardware/avm/b1.c
37557 +++ b/drivers/isdn/hardware/avm/b1.c
37558 @@ -176,7 +176,7 @@ int b1_load_t4file(avmcard *card, capiloaddatapart *t4file)
37559 }
37560 if (left) {
37561 if (t4file->user) {
37562 - if (copy_from_user(buf, dp, left))
37563 + if (left > sizeof buf || copy_from_user(buf, dp, left))
37564 return -EFAULT;
37565 } else {
37566 memcpy(buf, dp, left);
37567 @@ -224,7 +224,7 @@ int b1_load_config(avmcard *card, capiloaddatapart *config)
37568 }
37569 if (left) {
37570 if (config->user) {
37571 - if (copy_from_user(buf, dp, left))
37572 + if (left > sizeof buf || copy_from_user(buf, dp, left))
37573 return -EFAULT;
37574 } else {
37575 memcpy(buf, dp, left);
37576 diff --git a/drivers/isdn/i4l/isdn_tty.c b/drivers/isdn/i4l/isdn_tty.c
37577 index ebaebdf..acd4405 100644
37578 --- a/drivers/isdn/i4l/isdn_tty.c
37579 +++ b/drivers/isdn/i4l/isdn_tty.c
37580 @@ -1511,9 +1511,9 @@ isdn_tty_open(struct tty_struct *tty, struct file *filp)
37581
37582 #ifdef ISDN_DEBUG_MODEM_OPEN
37583 printk(KERN_DEBUG "isdn_tty_open %s, count = %d\n", tty->name,
37584 - port->count);
37585 + atomic_read(&port->count));
37586 #endif
37587 - port->count++;
37588 + atomic_inc(&port->count);
37589 port->tty = tty;
37590 /*
37591 * Start up serial port
37592 @@ -1557,7 +1557,7 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
37593 #endif
37594 return;
37595 }
37596 - if ((tty->count == 1) && (port->count != 1)) {
37597 + if ((tty->count == 1) && (atomic_read(&port->count) != 1)) {
37598 /*
37599 * Uh, oh. tty->count is 1, which means that the tty
37600 * structure will be freed. Info->count should always
37601 @@ -1566,15 +1566,15 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
37602 * serial port won't be shutdown.
37603 */
37604 printk(KERN_ERR "isdn_tty_close: bad port count; tty->count is 1, "
37605 - "info->count is %d\n", port->count);
37606 - port->count = 1;
37607 + "info->count is %d\n", atomic_read(&port->count));
37608 + atomic_set(&port->count, 1);
37609 }
37610 - if (--port->count < 0) {
37611 + if (atomic_dec_return(&port->count) < 0) {
37612 printk(KERN_ERR "isdn_tty_close: bad port count for ttyi%d: %d\n",
37613 - info->line, port->count);
37614 - port->count = 0;
37615 + info->line, atomic_read(&port->count));
37616 + atomic_set(&port->count, 0);
37617 }
37618 - if (port->count) {
37619 + if (atomic_read(&port->count)) {
37620 #ifdef ISDN_DEBUG_MODEM_OPEN
37621 printk(KERN_DEBUG "isdn_tty_close after info->count != 0\n");
37622 #endif
37623 @@ -1628,7 +1628,7 @@ isdn_tty_hangup(struct tty_struct *tty)
37624 if (isdn_tty_paranoia_check(info, tty->name, "isdn_tty_hangup"))
37625 return;
37626 isdn_tty_shutdown(info);
37627 - port->count = 0;
37628 + atomic_set(&port->count, 0);
37629 port->flags &= ~ASYNC_NORMAL_ACTIVE;
37630 port->tty = NULL;
37631 wake_up_interruptible(&port->open_wait);
37632 @@ -1973,7 +1973,7 @@ isdn_tty_find_icall(int di, int ch, setup_parm *setup)
37633 for (i = 0; i < ISDN_MAX_CHANNELS; i++) {
37634 modem_info *info = &dev->mdm.info[i];
37635
37636 - if (info->port.count == 0)
37637 + if (atomic_read(&info->port.count) == 0)
37638 continue;
37639 if ((info->emu.mdmreg[REG_SI1] & si2bit[si1]) && /* SI1 is matching */
37640 (info->emu.mdmreg[REG_SI2] == si2)) { /* SI2 is matching */
37641 diff --git a/drivers/isdn/icn/icn.c b/drivers/isdn/icn/icn.c
37642 index e74df7c..03a03ba 100644
37643 --- a/drivers/isdn/icn/icn.c
37644 +++ b/drivers/isdn/icn/icn.c
37645 @@ -1045,7 +1045,7 @@ icn_writecmd(const u_char *buf, int len, int user, icn_card *card)
37646 if (count > len)
37647 count = len;
37648 if (user) {
37649 - if (copy_from_user(msg, buf, count))
37650 + if (count > sizeof msg || copy_from_user(msg, buf, count))
37651 return -EFAULT;
37652 } else
37653 memcpy(msg, buf, count);
37654 diff --git a/drivers/leds/leds-clevo-mail.c b/drivers/leds/leds-clevo-mail.c
37655 index 6a8405d..0bd1c7e 100644
37656 --- a/drivers/leds/leds-clevo-mail.c
37657 +++ b/drivers/leds/leds-clevo-mail.c
37658 @@ -40,7 +40,7 @@ static int __init clevo_mail_led_dmi_callback(const struct dmi_system_id *id)
37659 * detected as working, but in reality it is not) as low as
37660 * possible.
37661 */
37662 -static struct dmi_system_id __initdata clevo_mail_led_dmi_table[] = {
37663 +static const struct dmi_system_id __initconst clevo_mail_led_dmi_table[] = {
37664 {
37665 .callback = clevo_mail_led_dmi_callback,
37666 .ident = "Clevo D410J",
37667 diff --git a/drivers/leds/leds-ss4200.c b/drivers/leds/leds-ss4200.c
37668 index 64e204e..c6bf189 100644
37669 --- a/drivers/leds/leds-ss4200.c
37670 +++ b/drivers/leds/leds-ss4200.c
37671 @@ -91,7 +91,7 @@ MODULE_PARM_DESC(nodetect, "Skip DMI-based hardware detection");
37672 * detected as working, but in reality it is not) as low as
37673 * possible.
37674 */
37675 -static struct dmi_system_id __initdata nas_led_whitelist[] = {
37676 +static const struct dmi_system_id __initconst nas_led_whitelist[] = {
37677 {
37678 .callback = ss4200_led_dmi_callback,
37679 .ident = "Intel SS4200-E",
37680 diff --git a/drivers/lguest/core.c b/drivers/lguest/core.c
37681 index a5ebc00..982886f 100644
37682 --- a/drivers/lguest/core.c
37683 +++ b/drivers/lguest/core.c
37684 @@ -92,9 +92,17 @@ static __init int map_switcher(void)
37685 * it's worked so far. The end address needs +1 because __get_vm_area
37686 * allocates an extra guard page, so we need space for that.
37687 */
37688 +
37689 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
37690 + switcher_vma = __get_vm_area(TOTAL_SWITCHER_PAGES * PAGE_SIZE,
37691 + VM_ALLOC | VM_KERNEXEC, SWITCHER_ADDR, SWITCHER_ADDR
37692 + + (TOTAL_SWITCHER_PAGES+1) * PAGE_SIZE);
37693 +#else
37694 switcher_vma = __get_vm_area(TOTAL_SWITCHER_PAGES * PAGE_SIZE,
37695 VM_ALLOC, SWITCHER_ADDR, SWITCHER_ADDR
37696 + (TOTAL_SWITCHER_PAGES+1) * PAGE_SIZE);
37697 +#endif
37698 +
37699 if (!switcher_vma) {
37700 err = -ENOMEM;
37701 printk("lguest: could not map switcher pages high\n");
37702 @@ -119,7 +127,7 @@ static __init int map_switcher(void)
37703 * Now the Switcher is mapped at the right address, we can't fail!
37704 * Copy in the compiled-in Switcher code (from x86/switcher_32.S).
37705 */
37706 - memcpy(switcher_vma->addr, start_switcher_text,
37707 + memcpy(switcher_vma->addr, ktla_ktva(start_switcher_text),
37708 end_switcher_text - start_switcher_text);
37709
37710 printk(KERN_INFO "lguest: mapped switcher at %p\n",
37711 diff --git a/drivers/lguest/page_tables.c b/drivers/lguest/page_tables.c
37712 index 3b62be16..e33134a 100644
37713 --- a/drivers/lguest/page_tables.c
37714 +++ b/drivers/lguest/page_tables.c
37715 @@ -532,7 +532,7 @@ void pin_page(struct lg_cpu *cpu, unsigned long vaddr)
37716 /*:*/
37717
37718 #ifdef CONFIG_X86_PAE
37719 -static void release_pmd(pmd_t *spmd)
37720 +static void __intentional_overflow(-1) release_pmd(pmd_t *spmd)
37721 {
37722 /* If the entry's not present, there's nothing to release. */
37723 if (pmd_flags(*spmd) & _PAGE_PRESENT) {
37724 diff --git a/drivers/lguest/x86/core.c b/drivers/lguest/x86/core.c
37725 index 4af12e1..0e89afe 100644
37726 --- a/drivers/lguest/x86/core.c
37727 +++ b/drivers/lguest/x86/core.c
37728 @@ -59,7 +59,7 @@ static struct {
37729 /* Offset from where switcher.S was compiled to where we've copied it */
37730 static unsigned long switcher_offset(void)
37731 {
37732 - return SWITCHER_ADDR - (unsigned long)start_switcher_text;
37733 + return SWITCHER_ADDR - (unsigned long)ktla_ktva(start_switcher_text);
37734 }
37735
37736 /* This cpu's struct lguest_pages. */
37737 @@ -100,7 +100,13 @@ static void copy_in_guest_info(struct lg_cpu *cpu, struct lguest_pages *pages)
37738 * These copies are pretty cheap, so we do them unconditionally: */
37739 /* Save the current Host top-level page directory.
37740 */
37741 +
37742 +#ifdef CONFIG_PAX_PER_CPU_PGD
37743 + pages->state.host_cr3 = read_cr3();
37744 +#else
37745 pages->state.host_cr3 = __pa(current->mm->pgd);
37746 +#endif
37747 +
37748 /*
37749 * Set up the Guest's page tables to see this CPU's pages (and no
37750 * other CPU's pages).
37751 @@ -476,7 +482,7 @@ void __init lguest_arch_host_init(void)
37752 * compiled-in switcher code and the high-mapped copy we just made.
37753 */
37754 for (i = 0; i < IDT_ENTRIES; i++)
37755 - default_idt_entries[i] += switcher_offset();
37756 + default_idt_entries[i] = ktla_ktva(default_idt_entries[i]) + switcher_offset();
37757
37758 /*
37759 * Set up the Switcher's per-cpu areas.
37760 @@ -559,7 +565,7 @@ void __init lguest_arch_host_init(void)
37761 * it will be undisturbed when we switch. To change %cs and jump we
37762 * need this structure to feed to Intel's "lcall" instruction.
37763 */
37764 - lguest_entry.offset = (long)switch_to_guest + switcher_offset();
37765 + lguest_entry.offset = (long)ktla_ktva(switch_to_guest) + switcher_offset();
37766 lguest_entry.segment = LGUEST_CS;
37767
37768 /*
37769 diff --git a/drivers/lguest/x86/switcher_32.S b/drivers/lguest/x86/switcher_32.S
37770 index 40634b0..4f5855e 100644
37771 --- a/drivers/lguest/x86/switcher_32.S
37772 +++ b/drivers/lguest/x86/switcher_32.S
37773 @@ -87,6 +87,7 @@
37774 #include <asm/page.h>
37775 #include <asm/segment.h>
37776 #include <asm/lguest.h>
37777 +#include <asm/processor-flags.h>
37778
37779 // We mark the start of the code to copy
37780 // It's placed in .text tho it's never run here
37781 @@ -149,6 +150,13 @@ ENTRY(switch_to_guest)
37782 // Changes type when we load it: damn Intel!
37783 // For after we switch over our page tables
37784 // That entry will be read-only: we'd crash.
37785 +
37786 +#ifdef CONFIG_PAX_KERNEXEC
37787 + mov %cr0, %edx
37788 + xor $X86_CR0_WP, %edx
37789 + mov %edx, %cr0
37790 +#endif
37791 +
37792 movl $(GDT_ENTRY_TSS*8), %edx
37793 ltr %dx
37794
37795 @@ -157,9 +165,15 @@ ENTRY(switch_to_guest)
37796 // Let's clear it again for our return.
37797 // The GDT descriptor of the Host
37798 // Points to the table after two "size" bytes
37799 - movl (LGUEST_PAGES_host_gdt_desc+2)(%eax), %edx
37800 + movl (LGUEST_PAGES_host_gdt_desc+2)(%eax), %eax
37801 // Clear "used" from type field (byte 5, bit 2)
37802 - andb $0xFD, (GDT_ENTRY_TSS*8 + 5)(%edx)
37803 + andb $0xFD, (GDT_ENTRY_TSS*8 + 5)(%eax)
37804 +
37805 +#ifdef CONFIG_PAX_KERNEXEC
37806 + mov %cr0, %eax
37807 + xor $X86_CR0_WP, %eax
37808 + mov %eax, %cr0
37809 +#endif
37810
37811 // Once our page table's switched, the Guest is live!
37812 // The Host fades as we run this final step.
37813 @@ -295,13 +309,12 @@ deliver_to_host:
37814 // I consulted gcc, and it gave
37815 // These instructions, which I gladly credit:
37816 leal (%edx,%ebx,8), %eax
37817 - movzwl (%eax),%edx
37818 - movl 4(%eax), %eax
37819 - xorw %ax, %ax
37820 - orl %eax, %edx
37821 + movl 4(%eax), %edx
37822 + movw (%eax), %dx
37823 // Now the address of the handler's in %edx
37824 // We call it now: its "iret" drops us home.
37825 - jmp *%edx
37826 + ljmp $__KERNEL_CS, $1f
37827 +1: jmp *%edx
37828
37829 // Every interrupt can come to us here
37830 // But we must truly tell each apart.
37831 diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
37832 index 4fd9d6a..834fa03 100644
37833 --- a/drivers/md/bitmap.c
37834 +++ b/drivers/md/bitmap.c
37835 @@ -1779,7 +1779,7 @@ void bitmap_status(struct seq_file *seq, struct bitmap *bitmap)
37836 chunk_kb ? "KB" : "B");
37837 if (bitmap->storage.file) {
37838 seq_printf(seq, ", file: ");
37839 - seq_path(seq, &bitmap->storage.file->f_path, " \t\n");
37840 + seq_path(seq, &bitmap->storage.file->f_path, " \t\n\\");
37841 }
37842
37843 seq_printf(seq, "\n");
37844 diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
37845 index aa04f02..2a1309e 100644
37846 --- a/drivers/md/dm-ioctl.c
37847 +++ b/drivers/md/dm-ioctl.c
37848 @@ -1694,7 +1694,7 @@ static int validate_params(uint cmd, struct dm_ioctl *param)
37849 cmd == DM_LIST_VERSIONS_CMD)
37850 return 0;
37851
37852 - if ((cmd == DM_DEV_CREATE_CMD)) {
37853 + if (cmd == DM_DEV_CREATE_CMD) {
37854 if (!*param->name) {
37855 DMWARN("name not supplied when creating device");
37856 return -EINVAL;
37857 diff --git a/drivers/md/dm-raid1.c b/drivers/md/dm-raid1.c
37858 index d053098..05cc375 100644
37859 --- a/drivers/md/dm-raid1.c
37860 +++ b/drivers/md/dm-raid1.c
37861 @@ -40,7 +40,7 @@ enum dm_raid1_error {
37862
37863 struct mirror {
37864 struct mirror_set *ms;
37865 - atomic_t error_count;
37866 + atomic_unchecked_t error_count;
37867 unsigned long error_type;
37868 struct dm_dev *dev;
37869 sector_t offset;
37870 @@ -186,7 +186,7 @@ static struct mirror *get_valid_mirror(struct mirror_set *ms)
37871 struct mirror *m;
37872
37873 for (m = ms->mirror; m < ms->mirror + ms->nr_mirrors; m++)
37874 - if (!atomic_read(&m->error_count))
37875 + if (!atomic_read_unchecked(&m->error_count))
37876 return m;
37877
37878 return NULL;
37879 @@ -218,7 +218,7 @@ static void fail_mirror(struct mirror *m, enum dm_raid1_error error_type)
37880 * simple way to tell if a device has encountered
37881 * errors.
37882 */
37883 - atomic_inc(&m->error_count);
37884 + atomic_inc_unchecked(&m->error_count);
37885
37886 if (test_and_set_bit(error_type, &m->error_type))
37887 return;
37888 @@ -409,7 +409,7 @@ static struct mirror *choose_mirror(struct mirror_set *ms, sector_t sector)
37889 struct mirror *m = get_default_mirror(ms);
37890
37891 do {
37892 - if (likely(!atomic_read(&m->error_count)))
37893 + if (likely(!atomic_read_unchecked(&m->error_count)))
37894 return m;
37895
37896 if (m-- == ms->mirror)
37897 @@ -423,7 +423,7 @@ static int default_ok(struct mirror *m)
37898 {
37899 struct mirror *default_mirror = get_default_mirror(m->ms);
37900
37901 - return !atomic_read(&default_mirror->error_count);
37902 + return !atomic_read_unchecked(&default_mirror->error_count);
37903 }
37904
37905 static int mirror_available(struct mirror_set *ms, struct bio *bio)
37906 @@ -560,7 +560,7 @@ static void do_reads(struct mirror_set *ms, struct bio_list *reads)
37907 */
37908 if (likely(region_in_sync(ms, region, 1)))
37909 m = choose_mirror(ms, bio->bi_sector);
37910 - else if (m && atomic_read(&m->error_count))
37911 + else if (m && atomic_read_unchecked(&m->error_count))
37912 m = NULL;
37913
37914 if (likely(m))
37915 @@ -927,7 +927,7 @@ static int get_mirror(struct mirror_set *ms, struct dm_target *ti,
37916 }
37917
37918 ms->mirror[mirror].ms = ms;
37919 - atomic_set(&(ms->mirror[mirror].error_count), 0);
37920 + atomic_set_unchecked(&(ms->mirror[mirror].error_count), 0);
37921 ms->mirror[mirror].error_type = 0;
37922 ms->mirror[mirror].offset = offset;
37923
37924 @@ -1340,7 +1340,7 @@ static void mirror_resume(struct dm_target *ti)
37925 */
37926 static char device_status_char(struct mirror *m)
37927 {
37928 - if (!atomic_read(&(m->error_count)))
37929 + if (!atomic_read_unchecked(&(m->error_count)))
37930 return 'A';
37931
37932 return (test_bit(DM_RAID1_FLUSH_ERROR, &(m->error_type))) ? 'F' :
37933 diff --git a/drivers/md/dm-stripe.c b/drivers/md/dm-stripe.c
37934 index 7b8b2b9..9c7d145 100644
37935 --- a/drivers/md/dm-stripe.c
37936 +++ b/drivers/md/dm-stripe.c
37937 @@ -20,7 +20,7 @@ struct stripe {
37938 struct dm_dev *dev;
37939 sector_t physical_start;
37940
37941 - atomic_t error_count;
37942 + atomic_unchecked_t error_count;
37943 };
37944
37945 struct stripe_c {
37946 @@ -185,7 +185,7 @@ static int stripe_ctr(struct dm_target *ti, unsigned int argc, char **argv)
37947 kfree(sc);
37948 return r;
37949 }
37950 - atomic_set(&(sc->stripe[i].error_count), 0);
37951 + atomic_set_unchecked(&(sc->stripe[i].error_count), 0);
37952 }
37953
37954 ti->private = sc;
37955 @@ -326,7 +326,7 @@ static void stripe_status(struct dm_target *ti, status_type_t type,
37956 DMEMIT("%d ", sc->stripes);
37957 for (i = 0; i < sc->stripes; i++) {
37958 DMEMIT("%s ", sc->stripe[i].dev->name);
37959 - buffer[i] = atomic_read(&(sc->stripe[i].error_count)) ?
37960 + buffer[i] = atomic_read_unchecked(&(sc->stripe[i].error_count)) ?
37961 'D' : 'A';
37962 }
37963 buffer[i] = '\0';
37964 @@ -371,8 +371,8 @@ static int stripe_end_io(struct dm_target *ti, struct bio *bio, int error)
37965 */
37966 for (i = 0; i < sc->stripes; i++)
37967 if (!strcmp(sc->stripe[i].dev->name, major_minor)) {
37968 - atomic_inc(&(sc->stripe[i].error_count));
37969 - if (atomic_read(&(sc->stripe[i].error_count)) <
37970 + atomic_inc_unchecked(&(sc->stripe[i].error_count));
37971 + if (atomic_read_unchecked(&(sc->stripe[i].error_count)) <
37972 DM_IO_ERROR_THRESHOLD)
37973 schedule_work(&sc->trigger_event);
37974 }
37975 diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
37976 index 1ff252a..ee384c1 100644
37977 --- a/drivers/md/dm-table.c
37978 +++ b/drivers/md/dm-table.c
37979 @@ -389,7 +389,7 @@ static int device_area_is_invalid(struct dm_target *ti, struct dm_dev *dev,
37980 if (!dev_size)
37981 return 0;
37982
37983 - if ((start >= dev_size) || (start + len > dev_size)) {
37984 + if ((start >= dev_size) || (len > dev_size - start)) {
37985 DMWARN("%s: %s too small for target: "
37986 "start=%llu, len=%llu, dev_size=%llu",
37987 dm_device_name(ti->table->md), bdevname(bdev, b),
37988 diff --git a/drivers/md/dm-thin-metadata.c b/drivers/md/dm-thin-metadata.c
37989 index 00cee02..b89a29d 100644
37990 --- a/drivers/md/dm-thin-metadata.c
37991 +++ b/drivers/md/dm-thin-metadata.c
37992 @@ -397,7 +397,7 @@ static void __setup_btree_details(struct dm_pool_metadata *pmd)
37993 {
37994 pmd->info.tm = pmd->tm;
37995 pmd->info.levels = 2;
37996 - pmd->info.value_type.context = pmd->data_sm;
37997 + pmd->info.value_type.context = (dm_space_map_no_const *)pmd->data_sm;
37998 pmd->info.value_type.size = sizeof(__le64);
37999 pmd->info.value_type.inc = data_block_inc;
38000 pmd->info.value_type.dec = data_block_dec;
38001 @@ -416,7 +416,7 @@ static void __setup_btree_details(struct dm_pool_metadata *pmd)
38002
38003 pmd->bl_info.tm = pmd->tm;
38004 pmd->bl_info.levels = 1;
38005 - pmd->bl_info.value_type.context = pmd->data_sm;
38006 + pmd->bl_info.value_type.context = (dm_space_map_no_const *)pmd->data_sm;
38007 pmd->bl_info.value_type.size = sizeof(__le64);
38008 pmd->bl_info.value_type.inc = data_block_inc;
38009 pmd->bl_info.value_type.dec = data_block_dec;
38010 diff --git a/drivers/md/dm.c b/drivers/md/dm.c
38011 index 9a0bdad..4df9543 100644
38012 --- a/drivers/md/dm.c
38013 +++ b/drivers/md/dm.c
38014 @@ -169,9 +169,9 @@ struct mapped_device {
38015 /*
38016 * Event handling.
38017 */
38018 - atomic_t event_nr;
38019 + atomic_unchecked_t event_nr;
38020 wait_queue_head_t eventq;
38021 - atomic_t uevent_seq;
38022 + atomic_unchecked_t uevent_seq;
38023 struct list_head uevent_list;
38024 spinlock_t uevent_lock; /* Protect access to uevent_list */
38025
38026 @@ -1879,8 +1879,8 @@ static struct mapped_device *alloc_dev(int minor)
38027 rwlock_init(&md->map_lock);
38028 atomic_set(&md->holders, 1);
38029 atomic_set(&md->open_count, 0);
38030 - atomic_set(&md->event_nr, 0);
38031 - atomic_set(&md->uevent_seq, 0);
38032 + atomic_set_unchecked(&md->event_nr, 0);
38033 + atomic_set_unchecked(&md->uevent_seq, 0);
38034 INIT_LIST_HEAD(&md->uevent_list);
38035 spin_lock_init(&md->uevent_lock);
38036
38037 @@ -2028,7 +2028,7 @@ static void event_callback(void *context)
38038
38039 dm_send_uevents(&uevents, &disk_to_dev(md->disk)->kobj);
38040
38041 - atomic_inc(&md->event_nr);
38042 + atomic_inc_unchecked(&md->event_nr);
38043 wake_up(&md->eventq);
38044 }
38045
38046 @@ -2685,18 +2685,18 @@ int dm_kobject_uevent(struct mapped_device *md, enum kobject_action action,
38047
38048 uint32_t dm_next_uevent_seq(struct mapped_device *md)
38049 {
38050 - return atomic_add_return(1, &md->uevent_seq);
38051 + return atomic_add_return_unchecked(1, &md->uevent_seq);
38052 }
38053
38054 uint32_t dm_get_event_nr(struct mapped_device *md)
38055 {
38056 - return atomic_read(&md->event_nr);
38057 + return atomic_read_unchecked(&md->event_nr);
38058 }
38059
38060 int dm_wait_event(struct mapped_device *md, int event_nr)
38061 {
38062 return wait_event_interruptible(md->eventq,
38063 - (event_nr != atomic_read(&md->event_nr)));
38064 + (event_nr != atomic_read_unchecked(&md->event_nr)));
38065 }
38066
38067 void dm_uevent_add(struct mapped_device *md, struct list_head *elist)
38068 diff --git a/drivers/md/md.c b/drivers/md/md.c
38069 index a4a93b9..4747b63 100644
38070 --- a/drivers/md/md.c
38071 +++ b/drivers/md/md.c
38072 @@ -240,10 +240,10 @@ EXPORT_SYMBOL_GPL(md_trim_bio);
38073 * start build, activate spare
38074 */
38075 static DECLARE_WAIT_QUEUE_HEAD(md_event_waiters);
38076 -static atomic_t md_event_count;
38077 +static atomic_unchecked_t md_event_count;
38078 void md_new_event(struct mddev *mddev)
38079 {
38080 - atomic_inc(&md_event_count);
38081 + atomic_inc_unchecked(&md_event_count);
38082 wake_up(&md_event_waiters);
38083 }
38084 EXPORT_SYMBOL_GPL(md_new_event);
38085 @@ -253,7 +253,7 @@ EXPORT_SYMBOL_GPL(md_new_event);
38086 */
38087 static void md_new_event_inintr(struct mddev *mddev)
38088 {
38089 - atomic_inc(&md_event_count);
38090 + atomic_inc_unchecked(&md_event_count);
38091 wake_up(&md_event_waiters);
38092 }
38093
38094 @@ -1507,7 +1507,7 @@ static int super_1_load(struct md_rdev *rdev, struct md_rdev *refdev, int minor_
38095 if ((le32_to_cpu(sb->feature_map) & MD_FEATURE_RESHAPE_ACTIVE) &&
38096 (le32_to_cpu(sb->feature_map) & MD_FEATURE_NEW_OFFSET))
38097 rdev->new_data_offset += (s32)le32_to_cpu(sb->new_offset);
38098 - atomic_set(&rdev->corrected_errors, le32_to_cpu(sb->cnt_corrected_read));
38099 + atomic_set_unchecked(&rdev->corrected_errors, le32_to_cpu(sb->cnt_corrected_read));
38100
38101 rdev->sb_size = le32_to_cpu(sb->max_dev) * 2 + 256;
38102 bmask = queue_logical_block_size(rdev->bdev->bd_disk->queue)-1;
38103 @@ -1751,7 +1751,7 @@ static void super_1_sync(struct mddev *mddev, struct md_rdev *rdev)
38104 else
38105 sb->resync_offset = cpu_to_le64(0);
38106
38107 - sb->cnt_corrected_read = cpu_to_le32(atomic_read(&rdev->corrected_errors));
38108 + sb->cnt_corrected_read = cpu_to_le32(atomic_read_unchecked(&rdev->corrected_errors));
38109
38110 sb->raid_disks = cpu_to_le32(mddev->raid_disks);
38111 sb->size = cpu_to_le64(mddev->dev_sectors);
38112 @@ -2751,7 +2751,7 @@ __ATTR(state, S_IRUGO|S_IWUSR, state_show, state_store);
38113 static ssize_t
38114 errors_show(struct md_rdev *rdev, char *page)
38115 {
38116 - return sprintf(page, "%d\n", atomic_read(&rdev->corrected_errors));
38117 + return sprintf(page, "%d\n", atomic_read_unchecked(&rdev->corrected_errors));
38118 }
38119
38120 static ssize_t
38121 @@ -2760,7 +2760,7 @@ errors_store(struct md_rdev *rdev, const char *buf, size_t len)
38122 char *e;
38123 unsigned long n = simple_strtoul(buf, &e, 10);
38124 if (*buf && (*e == 0 || *e == '\n')) {
38125 - atomic_set(&rdev->corrected_errors, n);
38126 + atomic_set_unchecked(&rdev->corrected_errors, n);
38127 return len;
38128 }
38129 return -EINVAL;
38130 @@ -3210,8 +3210,8 @@ int md_rdev_init(struct md_rdev *rdev)
38131 rdev->sb_loaded = 0;
38132 rdev->bb_page = NULL;
38133 atomic_set(&rdev->nr_pending, 0);
38134 - atomic_set(&rdev->read_errors, 0);
38135 - atomic_set(&rdev->corrected_errors, 0);
38136 + atomic_set_unchecked(&rdev->read_errors, 0);
38137 + atomic_set_unchecked(&rdev->corrected_errors, 0);
38138
38139 INIT_LIST_HEAD(&rdev->same_set);
38140 init_waitqueue_head(&rdev->blocked_wait);
38141 @@ -6994,7 +6994,7 @@ static int md_seq_show(struct seq_file *seq, void *v)
38142
38143 spin_unlock(&pers_lock);
38144 seq_printf(seq, "\n");
38145 - seq->poll_event = atomic_read(&md_event_count);
38146 + seq->poll_event = atomic_read_unchecked(&md_event_count);
38147 return 0;
38148 }
38149 if (v == (void*)2) {
38150 @@ -7097,7 +7097,7 @@ static int md_seq_open(struct inode *inode, struct file *file)
38151 return error;
38152
38153 seq = file->private_data;
38154 - seq->poll_event = atomic_read(&md_event_count);
38155 + seq->poll_event = atomic_read_unchecked(&md_event_count);
38156 return error;
38157 }
38158
38159 @@ -7111,7 +7111,7 @@ static unsigned int mdstat_poll(struct file *filp, poll_table *wait)
38160 /* always allow read */
38161 mask = POLLIN | POLLRDNORM;
38162
38163 - if (seq->poll_event != atomic_read(&md_event_count))
38164 + if (seq->poll_event != atomic_read_unchecked(&md_event_count))
38165 mask |= POLLERR | POLLPRI;
38166 return mask;
38167 }
38168 @@ -7155,7 +7155,7 @@ static int is_mddev_idle(struct mddev *mddev, int init)
38169 struct gendisk *disk = rdev->bdev->bd_contains->bd_disk;
38170 curr_events = (int)part_stat_read(&disk->part0, sectors[0]) +
38171 (int)part_stat_read(&disk->part0, sectors[1]) -
38172 - atomic_read(&disk->sync_io);
38173 + atomic_read_unchecked(&disk->sync_io);
38174 /* sync IO will cause sync_io to increase before the disk_stats
38175 * as sync_io is counted when a request starts, and
38176 * disk_stats is counted when it completes.
38177 diff --git a/drivers/md/md.h b/drivers/md/md.h
38178 index d90fb1a..4174a2b 100644
38179 --- a/drivers/md/md.h
38180 +++ b/drivers/md/md.h
38181 @@ -94,13 +94,13 @@ struct md_rdev {
38182 * only maintained for arrays that
38183 * support hot removal
38184 */
38185 - atomic_t read_errors; /* number of consecutive read errors that
38186 + atomic_unchecked_t read_errors; /* number of consecutive read errors that
38187 * we have tried to ignore.
38188 */
38189 struct timespec last_read_error; /* monotonic time since our
38190 * last read error
38191 */
38192 - atomic_t corrected_errors; /* number of corrected read errors,
38193 + atomic_unchecked_t corrected_errors; /* number of corrected read errors,
38194 * for reporting to userspace and storing
38195 * in superblock.
38196 */
38197 @@ -434,7 +434,7 @@ static inline void rdev_dec_pending(struct md_rdev *rdev, struct mddev *mddev)
38198
38199 static inline void md_sync_acct(struct block_device *bdev, unsigned long nr_sectors)
38200 {
38201 - atomic_add(nr_sectors, &bdev->bd_contains->bd_disk->sync_io);
38202 + atomic_add_unchecked(nr_sectors, &bdev->bd_contains->bd_disk->sync_io);
38203 }
38204
38205 struct md_personality
38206 diff --git a/drivers/md/persistent-data/dm-space-map.h b/drivers/md/persistent-data/dm-space-map.h
38207 index 1cbfc6b..56e1dbb 100644
38208 --- a/drivers/md/persistent-data/dm-space-map.h
38209 +++ b/drivers/md/persistent-data/dm-space-map.h
38210 @@ -60,6 +60,7 @@ struct dm_space_map {
38211 int (*root_size)(struct dm_space_map *sm, size_t *result);
38212 int (*copy_root)(struct dm_space_map *sm, void *copy_to_here_le, size_t len);
38213 };
38214 +typedef struct dm_space_map __no_const dm_space_map_no_const;
38215
38216 /*----------------------------------------------------------------*/
38217
38218 diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
38219 index 6af167f..40c25a1 100644
38220 --- a/drivers/md/raid1.c
38221 +++ b/drivers/md/raid1.c
38222 @@ -1826,7 +1826,7 @@ static int fix_sync_read_error(struct r1bio *r1_bio)
38223 if (r1_sync_page_io(rdev, sect, s,
38224 bio->bi_io_vec[idx].bv_page,
38225 READ) != 0)
38226 - atomic_add(s, &rdev->corrected_errors);
38227 + atomic_add_unchecked(s, &rdev->corrected_errors);
38228 }
38229 sectors -= s;
38230 sect += s;
38231 @@ -2048,7 +2048,7 @@ static void fix_read_error(struct r1conf *conf, int read_disk,
38232 test_bit(In_sync, &rdev->flags)) {
38233 if (r1_sync_page_io(rdev, sect, s,
38234 conf->tmppage, READ)) {
38235 - atomic_add(s, &rdev->corrected_errors);
38236 + atomic_add_unchecked(s, &rdev->corrected_errors);
38237 printk(KERN_INFO
38238 "md/raid1:%s: read error corrected "
38239 "(%d sectors at %llu on %s)\n",
38240 diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
38241 index 46c14e5..4db5966 100644
38242 --- a/drivers/md/raid10.c
38243 +++ b/drivers/md/raid10.c
38244 @@ -1932,7 +1932,7 @@ static void end_sync_read(struct bio *bio, int error)
38245 /* The write handler will notice the lack of
38246 * R10BIO_Uptodate and record any errors etc
38247 */
38248 - atomic_add(r10_bio->sectors,
38249 + atomic_add_unchecked(r10_bio->sectors,
38250 &conf->mirrors[d].rdev->corrected_errors);
38251
38252 /* for reconstruct, we always reschedule after a read.
38253 @@ -2281,7 +2281,7 @@ static void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev)
38254 {
38255 struct timespec cur_time_mon;
38256 unsigned long hours_since_last;
38257 - unsigned int read_errors = atomic_read(&rdev->read_errors);
38258 + unsigned int read_errors = atomic_read_unchecked(&rdev->read_errors);
38259
38260 ktime_get_ts(&cur_time_mon);
38261
38262 @@ -2303,9 +2303,9 @@ static void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev)
38263 * overflowing the shift of read_errors by hours_since_last.
38264 */
38265 if (hours_since_last >= 8 * sizeof(read_errors))
38266 - atomic_set(&rdev->read_errors, 0);
38267 + atomic_set_unchecked(&rdev->read_errors, 0);
38268 else
38269 - atomic_set(&rdev->read_errors, read_errors >> hours_since_last);
38270 + atomic_set_unchecked(&rdev->read_errors, read_errors >> hours_since_last);
38271 }
38272
38273 static int r10_sync_page_io(struct md_rdev *rdev, sector_t sector,
38274 @@ -2359,8 +2359,8 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
38275 return;
38276
38277 check_decay_read_errors(mddev, rdev);
38278 - atomic_inc(&rdev->read_errors);
38279 - if (atomic_read(&rdev->read_errors) > max_read_errors) {
38280 + atomic_inc_unchecked(&rdev->read_errors);
38281 + if (atomic_read_unchecked(&rdev->read_errors) > max_read_errors) {
38282 char b[BDEVNAME_SIZE];
38283 bdevname(rdev->bdev, b);
38284
38285 @@ -2368,7 +2368,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
38286 "md/raid10:%s: %s: Raid device exceeded "
38287 "read_error threshold [cur %d:max %d]\n",
38288 mdname(mddev), b,
38289 - atomic_read(&rdev->read_errors), max_read_errors);
38290 + atomic_read_unchecked(&rdev->read_errors), max_read_errors);
38291 printk(KERN_NOTICE
38292 "md/raid10:%s: %s: Failing raid device\n",
38293 mdname(mddev), b);
38294 @@ -2523,7 +2523,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
38295 sect +
38296 choose_data_offset(r10_bio, rdev)),
38297 bdevname(rdev->bdev, b));
38298 - atomic_add(s, &rdev->corrected_errors);
38299 + atomic_add_unchecked(s, &rdev->corrected_errors);
38300 }
38301
38302 rdev_dec_pending(rdev, mddev);
38303 diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
38304 index f4e87bf..0d4ad3f 100644
38305 --- a/drivers/md/raid5.c
38306 +++ b/drivers/md/raid5.c
38307 @@ -1763,21 +1763,21 @@ static void raid5_end_read_request(struct bio * bi, int error)
38308 mdname(conf->mddev), STRIPE_SECTORS,
38309 (unsigned long long)s,
38310 bdevname(rdev->bdev, b));
38311 - atomic_add(STRIPE_SECTORS, &rdev->corrected_errors);
38312 + atomic_add_unchecked(STRIPE_SECTORS, &rdev->corrected_errors);
38313 clear_bit(R5_ReadError, &sh->dev[i].flags);
38314 clear_bit(R5_ReWrite, &sh->dev[i].flags);
38315 } else if (test_bit(R5_ReadNoMerge, &sh->dev[i].flags))
38316 clear_bit(R5_ReadNoMerge, &sh->dev[i].flags);
38317
38318 - if (atomic_read(&rdev->read_errors))
38319 - atomic_set(&rdev->read_errors, 0);
38320 + if (atomic_read_unchecked(&rdev->read_errors))
38321 + atomic_set_unchecked(&rdev->read_errors, 0);
38322 } else {
38323 const char *bdn = bdevname(rdev->bdev, b);
38324 int retry = 0;
38325 int set_bad = 0;
38326
38327 clear_bit(R5_UPTODATE, &sh->dev[i].flags);
38328 - atomic_inc(&rdev->read_errors);
38329 + atomic_inc_unchecked(&rdev->read_errors);
38330 if (test_bit(R5_ReadRepl, &sh->dev[i].flags))
38331 printk_ratelimited(
38332 KERN_WARNING
38333 @@ -1805,7 +1805,7 @@ static void raid5_end_read_request(struct bio * bi, int error)
38334 mdname(conf->mddev),
38335 (unsigned long long)s,
38336 bdn);
38337 - } else if (atomic_read(&rdev->read_errors)
38338 + } else if (atomic_read_unchecked(&rdev->read_errors)
38339 > conf->max_nr_stripes)
38340 printk(KERN_WARNING
38341 "md/raid:%s: Too many read errors, failing device %s.\n",
38342 diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
38343 index 401ef64..836e563 100644
38344 --- a/drivers/media/dvb-core/dvbdev.c
38345 +++ b/drivers/media/dvb-core/dvbdev.c
38346 @@ -192,7 +192,7 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
38347 const struct dvb_device *template, void *priv, int type)
38348 {
38349 struct dvb_device *dvbdev;
38350 - struct file_operations *dvbdevfops;
38351 + file_operations_no_const *dvbdevfops;
38352 struct device *clsdev;
38353 int minor;
38354 int id;
38355 diff --git a/drivers/media/dvb-frontends/dib3000.h b/drivers/media/dvb-frontends/dib3000.h
38356 index 9b6c3bb..baeb5c7 100644
38357 --- a/drivers/media/dvb-frontends/dib3000.h
38358 +++ b/drivers/media/dvb-frontends/dib3000.h
38359 @@ -39,7 +39,7 @@ struct dib_fe_xfer_ops
38360 int (*fifo_ctrl)(struct dvb_frontend *fe, int onoff);
38361 int (*pid_ctrl)(struct dvb_frontend *fe, int index, int pid, int onoff);
38362 int (*tuner_pass_ctrl)(struct dvb_frontend *fe, int onoff, u8 pll_ctrl);
38363 -};
38364 +} __no_const;
38365
38366 #if IS_ENABLED(CONFIG_DVB_DIB3000MB)
38367 extern struct dvb_frontend* dib3000mb_attach(const struct dib3000_config* config,
38368 diff --git a/drivers/media/pci/cx88/cx88-video.c b/drivers/media/pci/cx88/cx88-video.c
38369 index bc78354..42c9459 100644
38370 --- a/drivers/media/pci/cx88/cx88-video.c
38371 +++ b/drivers/media/pci/cx88/cx88-video.c
38372 @@ -50,9 +50,9 @@ MODULE_VERSION(CX88_VERSION);
38373
38374 /* ------------------------------------------------------------------ */
38375
38376 -static unsigned int video_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38377 -static unsigned int vbi_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38378 -static unsigned int radio_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38379 +static int video_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38380 +static int vbi_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38381 +static int radio_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38382
38383 module_param_array(video_nr, int, NULL, 0444);
38384 module_param_array(vbi_nr, int, NULL, 0444);
38385 diff --git a/drivers/media/platform/omap/omap_vout.c b/drivers/media/platform/omap/omap_vout.c
38386 index 96c4a17..1305a79 100644
38387 --- a/drivers/media/platform/omap/omap_vout.c
38388 +++ b/drivers/media/platform/omap/omap_vout.c
38389 @@ -63,7 +63,6 @@ enum omap_vout_channels {
38390 OMAP_VIDEO2,
38391 };
38392
38393 -static struct videobuf_queue_ops video_vbq_ops;
38394 /* Variables configurable through module params*/
38395 static u32 video1_numbuffers = 3;
38396 static u32 video2_numbuffers = 3;
38397 @@ -1012,6 +1011,12 @@ static int omap_vout_open(struct file *file)
38398 {
38399 struct videobuf_queue *q;
38400 struct omap_vout_device *vout = NULL;
38401 + static struct videobuf_queue_ops video_vbq_ops = {
38402 + .buf_setup = omap_vout_buffer_setup,
38403 + .buf_prepare = omap_vout_buffer_prepare,
38404 + .buf_release = omap_vout_buffer_release,
38405 + .buf_queue = omap_vout_buffer_queue,
38406 + };
38407
38408 vout = video_drvdata(file);
38409 v4l2_dbg(1, debug, &vout->vid_dev->v4l2_dev, "Entering %s\n", __func__);
38410 @@ -1029,10 +1034,6 @@ static int omap_vout_open(struct file *file)
38411 vout->type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
38412
38413 q = &vout->vbq;
38414 - video_vbq_ops.buf_setup = omap_vout_buffer_setup;
38415 - video_vbq_ops.buf_prepare = omap_vout_buffer_prepare;
38416 - video_vbq_ops.buf_release = omap_vout_buffer_release;
38417 - video_vbq_ops.buf_queue = omap_vout_buffer_queue;
38418 spin_lock_init(&vout->vbq_lock);
38419
38420 videobuf_queue_dma_contig_init(q, &video_vbq_ops, q->dev,
38421 diff --git a/drivers/media/platform/s5p-tv/mixer.h b/drivers/media/platform/s5p-tv/mixer.h
38422 index 04e6490..2df65bf 100644
38423 --- a/drivers/media/platform/s5p-tv/mixer.h
38424 +++ b/drivers/media/platform/s5p-tv/mixer.h
38425 @@ -156,7 +156,7 @@ struct mxr_layer {
38426 /** layer index (unique identifier) */
38427 int idx;
38428 /** callbacks for layer methods */
38429 - struct mxr_layer_ops ops;
38430 + struct mxr_layer_ops *ops;
38431 /** format array */
38432 const struct mxr_format **fmt_array;
38433 /** size of format array */
38434 diff --git a/drivers/media/platform/s5p-tv/mixer_grp_layer.c b/drivers/media/platform/s5p-tv/mixer_grp_layer.c
38435 index b93a21f..2535195 100644
38436 --- a/drivers/media/platform/s5p-tv/mixer_grp_layer.c
38437 +++ b/drivers/media/platform/s5p-tv/mixer_grp_layer.c
38438 @@ -235,7 +235,7 @@ struct mxr_layer *mxr_graph_layer_create(struct mxr_device *mdev, int idx)
38439 {
38440 struct mxr_layer *layer;
38441 int ret;
38442 - struct mxr_layer_ops ops = {
38443 + static struct mxr_layer_ops ops = {
38444 .release = mxr_graph_layer_release,
38445 .buffer_set = mxr_graph_buffer_set,
38446 .stream_set = mxr_graph_stream_set,
38447 diff --git a/drivers/media/platform/s5p-tv/mixer_reg.c b/drivers/media/platform/s5p-tv/mixer_reg.c
38448 index b713403..53cb5ad 100644
38449 --- a/drivers/media/platform/s5p-tv/mixer_reg.c
38450 +++ b/drivers/media/platform/s5p-tv/mixer_reg.c
38451 @@ -276,7 +276,7 @@ static void mxr_irq_layer_handle(struct mxr_layer *layer)
38452 layer->update_buf = next;
38453 }
38454
38455 - layer->ops.buffer_set(layer, layer->update_buf);
38456 + layer->ops->buffer_set(layer, layer->update_buf);
38457
38458 if (done && done != layer->shadow_buf)
38459 vb2_buffer_done(&done->vb, VB2_BUF_STATE_DONE);
38460 diff --git a/drivers/media/platform/s5p-tv/mixer_video.c b/drivers/media/platform/s5p-tv/mixer_video.c
38461 index 82142a2..6de47e8 100644
38462 --- a/drivers/media/platform/s5p-tv/mixer_video.c
38463 +++ b/drivers/media/platform/s5p-tv/mixer_video.c
38464 @@ -209,7 +209,7 @@ static void mxr_layer_default_geo(struct mxr_layer *layer)
38465 layer->geo.src.height = layer->geo.src.full_height;
38466
38467 mxr_geometry_dump(mdev, &layer->geo);
38468 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
38469 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
38470 mxr_geometry_dump(mdev, &layer->geo);
38471 }
38472
38473 @@ -227,7 +227,7 @@ static void mxr_layer_update_output(struct mxr_layer *layer)
38474 layer->geo.dst.full_width = mbus_fmt.width;
38475 layer->geo.dst.full_height = mbus_fmt.height;
38476 layer->geo.dst.field = mbus_fmt.field;
38477 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
38478 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
38479
38480 mxr_geometry_dump(mdev, &layer->geo);
38481 }
38482 @@ -333,7 +333,7 @@ static int mxr_s_fmt(struct file *file, void *priv,
38483 /* set source size to highest accepted value */
38484 geo->src.full_width = max(geo->dst.full_width, pix->width);
38485 geo->src.full_height = max(geo->dst.full_height, pix->height);
38486 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
38487 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
38488 mxr_geometry_dump(mdev, &layer->geo);
38489 /* set cropping to total visible screen */
38490 geo->src.width = pix->width;
38491 @@ -341,12 +341,12 @@ static int mxr_s_fmt(struct file *file, void *priv,
38492 geo->src.x_offset = 0;
38493 geo->src.y_offset = 0;
38494 /* assure consistency of geometry */
38495 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_CROP, MXR_NO_OFFSET);
38496 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_CROP, MXR_NO_OFFSET);
38497 mxr_geometry_dump(mdev, &layer->geo);
38498 /* set full size to lowest possible value */
38499 geo->src.full_width = 0;
38500 geo->src.full_height = 0;
38501 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
38502 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
38503 mxr_geometry_dump(mdev, &layer->geo);
38504
38505 /* returning results */
38506 @@ -473,7 +473,7 @@ static int mxr_s_selection(struct file *file, void *fh,
38507 target->width = s->r.width;
38508 target->height = s->r.height;
38509
38510 - layer->ops.fix_geometry(layer, stage, s->flags);
38511 + layer->ops->fix_geometry(layer, stage, s->flags);
38512
38513 /* retrieve update selection rectangle */
38514 res.left = target->x_offset;
38515 @@ -938,13 +938,13 @@ static int start_streaming(struct vb2_queue *vq, unsigned int count)
38516 mxr_output_get(mdev);
38517
38518 mxr_layer_update_output(layer);
38519 - layer->ops.format_set(layer);
38520 + layer->ops->format_set(layer);
38521 /* enabling layer in hardware */
38522 spin_lock_irqsave(&layer->enq_slock, flags);
38523 layer->state = MXR_LAYER_STREAMING;
38524 spin_unlock_irqrestore(&layer->enq_slock, flags);
38525
38526 - layer->ops.stream_set(layer, MXR_ENABLE);
38527 + layer->ops->stream_set(layer, MXR_ENABLE);
38528 mxr_streamer_get(mdev);
38529
38530 return 0;
38531 @@ -1014,7 +1014,7 @@ static int stop_streaming(struct vb2_queue *vq)
38532 spin_unlock_irqrestore(&layer->enq_slock, flags);
38533
38534 /* disabling layer in hardware */
38535 - layer->ops.stream_set(layer, MXR_DISABLE);
38536 + layer->ops->stream_set(layer, MXR_DISABLE);
38537 /* remove one streamer */
38538 mxr_streamer_put(mdev);
38539 /* allow changes in output configuration */
38540 @@ -1053,8 +1053,8 @@ void mxr_base_layer_unregister(struct mxr_layer *layer)
38541
38542 void mxr_layer_release(struct mxr_layer *layer)
38543 {
38544 - if (layer->ops.release)
38545 - layer->ops.release(layer);
38546 + if (layer->ops->release)
38547 + layer->ops->release(layer);
38548 }
38549
38550 void mxr_base_layer_release(struct mxr_layer *layer)
38551 @@ -1080,7 +1080,7 @@ struct mxr_layer *mxr_base_layer_create(struct mxr_device *mdev,
38552
38553 layer->mdev = mdev;
38554 layer->idx = idx;
38555 - layer->ops = *ops;
38556 + layer->ops = ops;
38557
38558 spin_lock_init(&layer->enq_slock);
38559 INIT_LIST_HEAD(&layer->enq_list);
38560 diff --git a/drivers/media/platform/s5p-tv/mixer_vp_layer.c b/drivers/media/platform/s5p-tv/mixer_vp_layer.c
38561 index 3d13a63..da31bf1 100644
38562 --- a/drivers/media/platform/s5p-tv/mixer_vp_layer.c
38563 +++ b/drivers/media/platform/s5p-tv/mixer_vp_layer.c
38564 @@ -206,7 +206,7 @@ struct mxr_layer *mxr_vp_layer_create(struct mxr_device *mdev, int idx)
38565 {
38566 struct mxr_layer *layer;
38567 int ret;
38568 - struct mxr_layer_ops ops = {
38569 + static struct mxr_layer_ops ops = {
38570 .release = mxr_vp_layer_release,
38571 .buffer_set = mxr_vp_buffer_set,
38572 .stream_set = mxr_vp_stream_set,
38573 diff --git a/drivers/media/radio/radio-cadet.c b/drivers/media/radio/radio-cadet.c
38574 index 643d80a..56bb96b 100644
38575 --- a/drivers/media/radio/radio-cadet.c
38576 +++ b/drivers/media/radio/radio-cadet.c
38577 @@ -302,6 +302,8 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo
38578 unsigned char readbuf[RDS_BUFFER];
38579 int i = 0;
38580
38581 + if (count > RDS_BUFFER)
38582 + return -EFAULT;
38583 mutex_lock(&dev->lock);
38584 if (dev->rdsstat == 0)
38585 cadet_start_rds(dev);
38586 @@ -317,7 +319,7 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo
38587 while (i < count && dev->rdsin != dev->rdsout)
38588 readbuf[i++] = dev->rdsbuf[dev->rdsout++];
38589
38590 - if (i && copy_to_user(data, readbuf, i))
38591 + if (i > sizeof(readbuf) || copy_to_user(data, readbuf, i))
38592 i = -EFAULT;
38593 unlock:
38594 mutex_unlock(&dev->lock);
38595 diff --git a/drivers/media/usb/dvb-usb/cxusb.c b/drivers/media/usb/dvb-usb/cxusb.c
38596 index 3940bb0..fb3952a 100644
38597 --- a/drivers/media/usb/dvb-usb/cxusb.c
38598 +++ b/drivers/media/usb/dvb-usb/cxusb.c
38599 @@ -1068,7 +1068,7 @@ static struct dib0070_config dib7070p_dib0070_config = {
38600
38601 struct dib0700_adapter_state {
38602 int (*set_param_save) (struct dvb_frontend *);
38603 -};
38604 +} __no_const;
38605
38606 static int dib7070_set_param_override(struct dvb_frontend *fe)
38607 {
38608 diff --git a/drivers/media/usb/dvb-usb/dw2102.c b/drivers/media/usb/dvb-usb/dw2102.c
38609 index 9578a67..31aa652 100644
38610 --- a/drivers/media/usb/dvb-usb/dw2102.c
38611 +++ b/drivers/media/usb/dvb-usb/dw2102.c
38612 @@ -115,7 +115,7 @@ struct su3000_state {
38613
38614 struct s6x0_state {
38615 int (*old_set_voltage)(struct dvb_frontend *f, fe_sec_voltage_t v);
38616 -};
38617 +} __no_const;
38618
38619 /* debug */
38620 static int dvb_usb_dw2102_debug;
38621 diff --git a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
38622 index 7157af3..139e91a 100644
38623 --- a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
38624 +++ b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
38625 @@ -326,7 +326,7 @@ struct v4l2_buffer32 {
38626 __u32 reserved;
38627 };
38628
38629 -static int get_v4l2_plane32(struct v4l2_plane *up, struct v4l2_plane32 *up32,
38630 +static int get_v4l2_plane32(struct v4l2_plane __user *up, struct v4l2_plane32 __user *up32,
38631 enum v4l2_memory memory)
38632 {
38633 void __user *up_pln;
38634 @@ -355,7 +355,7 @@ static int get_v4l2_plane32(struct v4l2_plane *up, struct v4l2_plane32 *up32,
38635 return 0;
38636 }
38637
38638 -static int put_v4l2_plane32(struct v4l2_plane *up, struct v4l2_plane32 *up32,
38639 +static int put_v4l2_plane32(struct v4l2_plane __user *up, struct v4l2_plane32 __user *up32,
38640 enum v4l2_memory memory)
38641 {
38642 if (copy_in_user(up32, up, 2 * sizeof(__u32)) ||
38643 @@ -772,7 +772,7 @@ static int put_v4l2_subdev_edid32(struct v4l2_subdev_edid *kp, struct v4l2_subde
38644 put_user(kp->start_block, &up->start_block) ||
38645 put_user(kp->blocks, &up->blocks) ||
38646 put_user(tmp, &up->edid) ||
38647 - copy_to_user(kp->reserved, up->reserved, sizeof(kp->reserved)))
38648 + copy_to_user(up->reserved, kp->reserved, sizeof(kp->reserved)))
38649 return -EFAULT;
38650 return 0;
38651 }
38652 diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
38653 index aa6e7c7..cb5de87 100644
38654 --- a/drivers/media/v4l2-core/v4l2-ioctl.c
38655 +++ b/drivers/media/v4l2-core/v4l2-ioctl.c
38656 @@ -236,7 +236,7 @@ static void v4l_print_format(const void *arg, bool write_only)
38657 const struct v4l2_vbi_format *vbi;
38658 const struct v4l2_sliced_vbi_format *sliced;
38659 const struct v4l2_window *win;
38660 - const struct v4l2_clip *clip;
38661 + const struct v4l2_clip __user *pclip;
38662 unsigned i;
38663
38664 pr_cont("type=%s", prt_names(p->type, v4l2_type_names));
38665 @@ -284,12 +284,16 @@ static void v4l_print_format(const void *arg, bool write_only)
38666 win->w.left, win->w.top,
38667 prt_names(win->field, v4l2_field_names),
38668 win->chromakey, win->bitmap, win->global_alpha);
38669 - clip = win->clips;
38670 + pclip = win->clips;
38671 for (i = 0; i < win->clipcount; i++) {
38672 + struct v4l2_clip clip;
38673 +
38674 + if (copy_from_user(&clip, pclip, sizeof clip))
38675 + break;
38676 printk(KERN_DEBUG "clip %u: wxh=%dx%d, x,y=%d,%d\n",
38677 - i, clip->c.width, clip->c.height,
38678 - clip->c.left, clip->c.top);
38679 - clip = clip->next;
38680 + i, clip.c.width, clip.c.height,
38681 + clip.c.left, clip.c.top);
38682 + pclip = clip.next;
38683 }
38684 break;
38685 case V4L2_BUF_TYPE_VBI_CAPTURE:
38686 @@ -1923,7 +1927,8 @@ struct v4l2_ioctl_info {
38687 struct file *file, void *fh, void *p);
38688 } u;
38689 void (*debug)(const void *arg, bool write_only);
38690 -};
38691 +} __do_const;
38692 +typedef struct v4l2_ioctl_info __no_const v4l2_ioctl_info_no_const;
38693
38694 /* This control needs a priority check */
38695 #define INFO_FL_PRIO (1 << 0)
38696 @@ -2108,7 +2113,7 @@ static long __video_do_ioctl(struct file *file,
38697 struct video_device *vfd = video_devdata(file);
38698 const struct v4l2_ioctl_ops *ops = vfd->ioctl_ops;
38699 bool write_only = false;
38700 - struct v4l2_ioctl_info default_info;
38701 + v4l2_ioctl_info_no_const default_info;
38702 const struct v4l2_ioctl_info *info;
38703 void *fh = file->private_data;
38704 struct v4l2_fh *vfh = NULL;
38705 @@ -2193,7 +2198,7 @@ done:
38706 }
38707
38708 static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
38709 - void * __user *user_ptr, void ***kernel_ptr)
38710 + void __user **user_ptr, void ***kernel_ptr)
38711 {
38712 int ret = 0;
38713
38714 @@ -2209,7 +2214,7 @@ static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
38715 ret = -EINVAL;
38716 break;
38717 }
38718 - *user_ptr = (void __user *)buf->m.planes;
38719 + *user_ptr = (void __force_user *)buf->m.planes;
38720 *kernel_ptr = (void *)&buf->m.planes;
38721 *array_size = sizeof(struct v4l2_plane) * buf->length;
38722 ret = 1;
38723 @@ -2244,7 +2249,7 @@ static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
38724 ret = -EINVAL;
38725 break;
38726 }
38727 - *user_ptr = (void __user *)ctrls->controls;
38728 + *user_ptr = (void __force_user *)ctrls->controls;
38729 *kernel_ptr = (void *)&ctrls->controls;
38730 *array_size = sizeof(struct v4l2_ext_control)
38731 * ctrls->count;
38732 diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
38733 index fb69baa..3aeea2e 100644
38734 --- a/drivers/message/fusion/mptbase.c
38735 +++ b/drivers/message/fusion/mptbase.c
38736 @@ -6755,8 +6755,13 @@ static int mpt_iocinfo_proc_show(struct seq_file *m, void *v)
38737 seq_printf(m, " MaxChainDepth = 0x%02x frames\n", ioc->facts.MaxChainDepth);
38738 seq_printf(m, " MinBlockSize = 0x%02x bytes\n", 4*ioc->facts.BlockSize);
38739
38740 +#ifdef CONFIG_GRKERNSEC_HIDESYM
38741 + seq_printf(m, " RequestFrames @ 0x%p (Dma @ 0x%p)\n", NULL, NULL);
38742 +#else
38743 seq_printf(m, " RequestFrames @ 0x%p (Dma @ 0x%p)\n",
38744 (void *)ioc->req_frames, (void *)(ulong)ioc->req_frames_dma);
38745 +#endif
38746 +
38747 /*
38748 * Rounding UP to nearest 4-kB boundary here...
38749 */
38750 @@ -6769,7 +6774,11 @@ static int mpt_iocinfo_proc_show(struct seq_file *m, void *v)
38751 ioc->facts.GlobalCredits);
38752
38753 seq_printf(m, " Frames @ 0x%p (Dma @ 0x%p)\n",
38754 +#ifdef CONFIG_GRKERNSEC_HIDESYM
38755 + NULL, NULL);
38756 +#else
38757 (void *)ioc->alloc, (void *)(ulong)ioc->alloc_dma);
38758 +#endif
38759 sz = (ioc->reply_sz * ioc->reply_depth) + 128;
38760 seq_printf(m, " {CurRepSz=%d} x {CurRepDepth=%d} = %d bytes ^= 0x%x\n",
38761 ioc->reply_sz, ioc->reply_depth, ioc->reply_sz*ioc->reply_depth, sz);
38762 diff --git a/drivers/message/fusion/mptsas.c b/drivers/message/fusion/mptsas.c
38763 index fa43c39..daeb158 100644
38764 --- a/drivers/message/fusion/mptsas.c
38765 +++ b/drivers/message/fusion/mptsas.c
38766 @@ -446,6 +446,23 @@ mptsas_is_end_device(struct mptsas_devinfo * attached)
38767 return 0;
38768 }
38769
38770 +static inline void
38771 +mptsas_set_rphy(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_rphy *rphy)
38772 +{
38773 + if (phy_info->port_details) {
38774 + phy_info->port_details->rphy = rphy;
38775 + dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sas_rphy_add: rphy=%p\n",
38776 + ioc->name, rphy));
38777 + }
38778 +
38779 + if (rphy) {
38780 + dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
38781 + &rphy->dev, MYIOC_s_FMT "add:", ioc->name));
38782 + dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rphy=%p release=%p\n",
38783 + ioc->name, rphy, rphy->dev.release));
38784 + }
38785 +}
38786 +
38787 /* no mutex */
38788 static void
38789 mptsas_port_delete(MPT_ADAPTER *ioc, struct mptsas_portinfo_details * port_details)
38790 @@ -484,23 +501,6 @@ mptsas_get_rphy(struct mptsas_phyinfo *phy_info)
38791 return NULL;
38792 }
38793
38794 -static inline void
38795 -mptsas_set_rphy(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_rphy *rphy)
38796 -{
38797 - if (phy_info->port_details) {
38798 - phy_info->port_details->rphy = rphy;
38799 - dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sas_rphy_add: rphy=%p\n",
38800 - ioc->name, rphy));
38801 - }
38802 -
38803 - if (rphy) {
38804 - dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
38805 - &rphy->dev, MYIOC_s_FMT "add:", ioc->name));
38806 - dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rphy=%p release=%p\n",
38807 - ioc->name, rphy, rphy->dev.release));
38808 - }
38809 -}
38810 -
38811 static inline struct sas_port *
38812 mptsas_get_port(struct mptsas_phyinfo *phy_info)
38813 {
38814 diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c
38815 index 164afa7..b6b2e74 100644
38816 --- a/drivers/message/fusion/mptscsih.c
38817 +++ b/drivers/message/fusion/mptscsih.c
38818 @@ -1271,15 +1271,16 @@ mptscsih_info(struct Scsi_Host *SChost)
38819
38820 h = shost_priv(SChost);
38821
38822 - if (h) {
38823 - if (h->info_kbuf == NULL)
38824 - if ((h->info_kbuf = kmalloc(0x1000 /* 4Kb */, GFP_KERNEL)) == NULL)
38825 - return h->info_kbuf;
38826 - h->info_kbuf[0] = '\0';
38827 + if (!h)
38828 + return NULL;
38829
38830 - mpt_print_ioc_summary(h->ioc, h->info_kbuf, &size, 0, 0);
38831 - h->info_kbuf[size-1] = '\0';
38832 - }
38833 + if (h->info_kbuf == NULL)
38834 + if ((h->info_kbuf = kmalloc(0x1000 /* 4Kb */, GFP_KERNEL)) == NULL)
38835 + return h->info_kbuf;
38836 + h->info_kbuf[0] = '\0';
38837 +
38838 + mpt_print_ioc_summary(h->ioc, h->info_kbuf, &size, 0, 0);
38839 + h->info_kbuf[size-1] = '\0';
38840
38841 return h->info_kbuf;
38842 }
38843 diff --git a/drivers/message/i2o/i2o_proc.c b/drivers/message/i2o/i2o_proc.c
38844 index 8001aa6..b137580 100644
38845 --- a/drivers/message/i2o/i2o_proc.c
38846 +++ b/drivers/message/i2o/i2o_proc.c
38847 @@ -255,12 +255,6 @@ static char *scsi_devices[] = {
38848 "Array Controller Device"
38849 };
38850
38851 -static char *chtostr(char *tmp, u8 *chars, int n)
38852 -{
38853 - tmp[0] = 0;
38854 - return strncat(tmp, (char *)chars, n);
38855 -}
38856 -
38857 static int i2o_report_query_status(struct seq_file *seq, int block_status,
38858 char *group)
38859 {
38860 @@ -790,7 +784,6 @@ static int i2o_seq_show_ddm_table(struct seq_file *seq, void *v)
38861 } *result;
38862
38863 i2o_exec_execute_ddm_table ddm_table;
38864 - char tmp[28 + 1];
38865
38866 result = kmalloc(sizeof(*result), GFP_KERNEL);
38867 if (!result)
38868 @@ -825,8 +818,7 @@ static int i2o_seq_show_ddm_table(struct seq_file *seq, void *v)
38869
38870 seq_printf(seq, "%-#7x", ddm_table.i2o_vendor_id);
38871 seq_printf(seq, "%-#8x", ddm_table.module_id);
38872 - seq_printf(seq, "%-29s",
38873 - chtostr(tmp, ddm_table.module_name_version, 28));
38874 + seq_printf(seq, "%-.28s", ddm_table.module_name_version);
38875 seq_printf(seq, "%9d ", ddm_table.data_size);
38876 seq_printf(seq, "%8d", ddm_table.code_size);
38877
38878 @@ -893,7 +885,6 @@ static int i2o_seq_show_drivers_stored(struct seq_file *seq, void *v)
38879
38880 i2o_driver_result_table *result;
38881 i2o_driver_store_table *dst;
38882 - char tmp[28 + 1];
38883
38884 result = kmalloc(sizeof(i2o_driver_result_table), GFP_KERNEL);
38885 if (result == NULL)
38886 @@ -928,9 +919,8 @@ static int i2o_seq_show_drivers_stored(struct seq_file *seq, void *v)
38887
38888 seq_printf(seq, "%-#7x", dst->i2o_vendor_id);
38889 seq_printf(seq, "%-#8x", dst->module_id);
38890 - seq_printf(seq, "%-29s",
38891 - chtostr(tmp, dst->module_name_version, 28));
38892 - seq_printf(seq, "%-9s", chtostr(tmp, dst->date, 8));
38893 + seq_printf(seq, "%-.28s", dst->module_name_version);
38894 + seq_printf(seq, "%-.8s", dst->date);
38895 seq_printf(seq, "%8d ", dst->module_size);
38896 seq_printf(seq, "%8d ", dst->mpb_size);
38897 seq_printf(seq, "0x%04x", dst->module_flags);
38898 @@ -1250,7 +1240,6 @@ static int i2o_seq_show_dev_identity(struct seq_file *seq, void *v)
38899 // == (allow) 512d bytes (max)
38900 static u16 *work16 = (u16 *) work32;
38901 int token;
38902 - char tmp[16 + 1];
38903
38904 token = i2o_parm_field_get(d, 0xF100, -1, &work32, sizeof(work32));
38905
38906 @@ -1262,14 +1251,10 @@ static int i2o_seq_show_dev_identity(struct seq_file *seq, void *v)
38907 seq_printf(seq, "Device Class : %s\n", i2o_get_class_name(work16[0]));
38908 seq_printf(seq, "Owner TID : %0#5x\n", work16[2]);
38909 seq_printf(seq, "Parent TID : %0#5x\n", work16[3]);
38910 - seq_printf(seq, "Vendor info : %s\n",
38911 - chtostr(tmp, (u8 *) (work32 + 2), 16));
38912 - seq_printf(seq, "Product info : %s\n",
38913 - chtostr(tmp, (u8 *) (work32 + 6), 16));
38914 - seq_printf(seq, "Description : %s\n",
38915 - chtostr(tmp, (u8 *) (work32 + 10), 16));
38916 - seq_printf(seq, "Product rev. : %s\n",
38917 - chtostr(tmp, (u8 *) (work32 + 14), 8));
38918 + seq_printf(seq, "Vendor info : %.16s\n", (u8 *) (work32 + 2));
38919 + seq_printf(seq, "Product info : %.16s\n", (u8 *) (work32 + 6));
38920 + seq_printf(seq, "Description : %.16s\n", (u8 *) (work32 + 10));
38921 + seq_printf(seq, "Product rev. : %.8s\n", (u8 *) (work32 + 14));
38922
38923 seq_printf(seq, "Serial number : ");
38924 print_serial_number(seq, (u8 *) (work32 + 16),
38925 @@ -1306,8 +1291,6 @@ static int i2o_seq_show_ddm_identity(struct seq_file *seq, void *v)
38926 u8 pad[256]; // allow up to 256 byte (max) serial number
38927 } result;
38928
38929 - char tmp[24 + 1];
38930 -
38931 token = i2o_parm_field_get(d, 0xF101, -1, &result, sizeof(result));
38932
38933 if (token < 0) {
38934 @@ -1316,10 +1299,8 @@ static int i2o_seq_show_ddm_identity(struct seq_file *seq, void *v)
38935 }
38936
38937 seq_printf(seq, "Registering DDM TID : 0x%03x\n", result.ddm_tid);
38938 - seq_printf(seq, "Module name : %s\n",
38939 - chtostr(tmp, result.module_name, 24));
38940 - seq_printf(seq, "Module revision : %s\n",
38941 - chtostr(tmp, result.module_rev, 8));
38942 + seq_printf(seq, "Module name : %.24s\n", result.module_name);
38943 + seq_printf(seq, "Module revision : %.8s\n", result.module_rev);
38944
38945 seq_printf(seq, "Serial number : ");
38946 print_serial_number(seq, result.serial_number, sizeof(result) - 36);
38947 @@ -1343,8 +1324,6 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
38948 u8 instance_number[4];
38949 } result;
38950
38951 - char tmp[64 + 1];
38952 -
38953 token = i2o_parm_field_get(d, 0xF102, -1, &result, sizeof(result));
38954
38955 if (token < 0) {
38956 @@ -1352,14 +1331,10 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
38957 return 0;
38958 }
38959
38960 - seq_printf(seq, "Device name : %s\n",
38961 - chtostr(tmp, result.device_name, 64));
38962 - seq_printf(seq, "Service name : %s\n",
38963 - chtostr(tmp, result.service_name, 64));
38964 - seq_printf(seq, "Physical name : %s\n",
38965 - chtostr(tmp, result.physical_location, 64));
38966 - seq_printf(seq, "Instance number : %s\n",
38967 - chtostr(tmp, result.instance_number, 4));
38968 + seq_printf(seq, "Device name : %.64s\n", result.device_name);
38969 + seq_printf(seq, "Service name : %.64s\n", result.service_name);
38970 + seq_printf(seq, "Physical name : %.64s\n", result.physical_location);
38971 + seq_printf(seq, "Instance number : %.4s\n", result.instance_number);
38972
38973 return 0;
38974 }
38975 diff --git a/drivers/message/i2o/iop.c b/drivers/message/i2o/iop.c
38976 index a8c08f3..155fe3d 100644
38977 --- a/drivers/message/i2o/iop.c
38978 +++ b/drivers/message/i2o/iop.c
38979 @@ -111,10 +111,10 @@ u32 i2o_cntxt_list_add(struct i2o_controller * c, void *ptr)
38980
38981 spin_lock_irqsave(&c->context_list_lock, flags);
38982
38983 - if (unlikely(atomic_inc_and_test(&c->context_list_counter)))
38984 - atomic_inc(&c->context_list_counter);
38985 + if (unlikely(atomic_inc_and_test_unchecked(&c->context_list_counter)))
38986 + atomic_inc_unchecked(&c->context_list_counter);
38987
38988 - entry->context = atomic_read(&c->context_list_counter);
38989 + entry->context = atomic_read_unchecked(&c->context_list_counter);
38990
38991 list_add(&entry->list, &c->context_list);
38992
38993 @@ -1077,7 +1077,7 @@ struct i2o_controller *i2o_iop_alloc(void)
38994
38995 #if BITS_PER_LONG == 64
38996 spin_lock_init(&c->context_list_lock);
38997 - atomic_set(&c->context_list_counter, 0);
38998 + atomic_set_unchecked(&c->context_list_counter, 0);
38999 INIT_LIST_HEAD(&c->context_list);
39000 #endif
39001
39002 diff --git a/drivers/mfd/janz-cmodio.c b/drivers/mfd/janz-cmodio.c
39003 index 45ece11..8efa218 100644
39004 --- a/drivers/mfd/janz-cmodio.c
39005 +++ b/drivers/mfd/janz-cmodio.c
39006 @@ -13,6 +13,7 @@
39007
39008 #include <linux/kernel.h>
39009 #include <linux/module.h>
39010 +#include <linux/slab.h>
39011 #include <linux/init.h>
39012 #include <linux/pci.h>
39013 #include <linux/interrupt.h>
39014 diff --git a/drivers/mfd/twl4030-irq.c b/drivers/mfd/twl4030-irq.c
39015 index a5f9888..1c0ed56 100644
39016 --- a/drivers/mfd/twl4030-irq.c
39017 +++ b/drivers/mfd/twl4030-irq.c
39018 @@ -35,6 +35,7 @@
39019 #include <linux/of.h>
39020 #include <linux/irqdomain.h>
39021 #include <linux/i2c/twl.h>
39022 +#include <asm/pgtable.h>
39023
39024 #include "twl-core.h"
39025
39026 @@ -728,10 +729,12 @@ int twl4030_init_irq(struct device *dev, int irq_num)
39027 * Install an irq handler for each of the SIH modules;
39028 * clone dummy irq_chip since PIH can't *do* anything
39029 */
39030 - twl4030_irq_chip = dummy_irq_chip;
39031 - twl4030_irq_chip.name = "twl4030";
39032 + pax_open_kernel();
39033 + memcpy((void *)&twl4030_irq_chip, &dummy_irq_chip, sizeof twl4030_irq_chip);
39034 + *(const char **)&twl4030_irq_chip.name = "twl4030";
39035
39036 - twl4030_sih_irq_chip.irq_ack = dummy_irq_chip.irq_ack;
39037 + *(void **)&twl4030_sih_irq_chip.irq_ack = dummy_irq_chip.irq_ack;
39038 + pax_close_kernel();
39039
39040 for (i = irq_base; i < irq_end; i++) {
39041 irq_set_chip_and_handler(i, &twl4030_irq_chip,
39042 diff --git a/drivers/mfd/twl6030-irq.c b/drivers/mfd/twl6030-irq.c
39043 index 277a8db..0e0b754 100644
39044 --- a/drivers/mfd/twl6030-irq.c
39045 +++ b/drivers/mfd/twl6030-irq.c
39046 @@ -387,10 +387,12 @@ int twl6030_init_irq(struct device *dev, int irq_num)
39047 * install an irq handler for each of the modules;
39048 * clone dummy irq_chip since PIH can't *do* anything
39049 */
39050 - twl6030_irq_chip = dummy_irq_chip;
39051 - twl6030_irq_chip.name = "twl6030";
39052 - twl6030_irq_chip.irq_set_type = NULL;
39053 - twl6030_irq_chip.irq_set_wake = twl6030_irq_set_wake;
39054 + pax_open_kernel();
39055 + memcpy((void *)&twl6030_irq_chip, &dummy_irq_chip, sizeof twl6030_irq_chip);
39056 + *(const char **)&twl6030_irq_chip.name = "twl6030";
39057 + *(void **)&twl6030_irq_chip.irq_set_type = NULL;
39058 + *(void **)&twl6030_irq_chip.irq_set_wake = twl6030_irq_set_wake;
39059 + pax_close_kernel();
39060
39061 for (i = irq_base; i < irq_end; i++) {
39062 irq_set_chip_and_handler(i, &twl6030_irq_chip,
39063 diff --git a/drivers/misc/c2port/core.c b/drivers/misc/c2port/core.c
39064 index f32550a..e3e52a2 100644
39065 --- a/drivers/misc/c2port/core.c
39066 +++ b/drivers/misc/c2port/core.c
39067 @@ -920,7 +920,9 @@ struct c2port_device *c2port_device_register(char *name,
39068 mutex_init(&c2dev->mutex);
39069
39070 /* Create binary file */
39071 - c2port_bin_attrs.size = ops->blocks_num * ops->block_size;
39072 + pax_open_kernel();
39073 + *(size_t *)&c2port_bin_attrs.size = ops->blocks_num * ops->block_size;
39074 + pax_close_kernel();
39075 ret = device_create_bin_file(c2dev->dev, &c2port_bin_attrs);
39076 if (unlikely(ret))
39077 goto error_device_create_bin_file;
39078 diff --git a/drivers/misc/kgdbts.c b/drivers/misc/kgdbts.c
39079 index 36f5d52..32311c3 100644
39080 --- a/drivers/misc/kgdbts.c
39081 +++ b/drivers/misc/kgdbts.c
39082 @@ -834,7 +834,7 @@ static void run_plant_and_detach_test(int is_early)
39083 char before[BREAK_INSTR_SIZE];
39084 char after[BREAK_INSTR_SIZE];
39085
39086 - probe_kernel_read(before, (char *)kgdbts_break_test,
39087 + probe_kernel_read(before, ktla_ktva((char *)kgdbts_break_test),
39088 BREAK_INSTR_SIZE);
39089 init_simple_test();
39090 ts.tst = plant_and_detach_test;
39091 @@ -842,7 +842,7 @@ static void run_plant_and_detach_test(int is_early)
39092 /* Activate test with initial breakpoint */
39093 if (!is_early)
39094 kgdb_breakpoint();
39095 - probe_kernel_read(after, (char *)kgdbts_break_test,
39096 + probe_kernel_read(after, ktla_ktva((char *)kgdbts_break_test),
39097 BREAK_INSTR_SIZE);
39098 if (memcmp(before, after, BREAK_INSTR_SIZE)) {
39099 printk(KERN_CRIT "kgdbts: ERROR kgdb corrupted memory\n");
39100 diff --git a/drivers/misc/lis3lv02d/lis3lv02d.c b/drivers/misc/lis3lv02d/lis3lv02d.c
39101 index 4a87e5c..76bdf5c 100644
39102 --- a/drivers/misc/lis3lv02d/lis3lv02d.c
39103 +++ b/drivers/misc/lis3lv02d/lis3lv02d.c
39104 @@ -498,7 +498,7 @@ static irqreturn_t lis302dl_interrupt(int irq, void *data)
39105 * the lid is closed. This leads to interrupts as soon as a little move
39106 * is done.
39107 */
39108 - atomic_inc(&lis3->count);
39109 + atomic_inc_unchecked(&lis3->count);
39110
39111 wake_up_interruptible(&lis3->misc_wait);
39112 kill_fasync(&lis3->async_queue, SIGIO, POLL_IN);
39113 @@ -584,7 +584,7 @@ static int lis3lv02d_misc_open(struct inode *inode, struct file *file)
39114 if (lis3->pm_dev)
39115 pm_runtime_get_sync(lis3->pm_dev);
39116
39117 - atomic_set(&lis3->count, 0);
39118 + atomic_set_unchecked(&lis3->count, 0);
39119 return 0;
39120 }
39121
39122 @@ -617,7 +617,7 @@ static ssize_t lis3lv02d_misc_read(struct file *file, char __user *buf,
39123 add_wait_queue(&lis3->misc_wait, &wait);
39124 while (true) {
39125 set_current_state(TASK_INTERRUPTIBLE);
39126 - data = atomic_xchg(&lis3->count, 0);
39127 + data = atomic_xchg_unchecked(&lis3->count, 0);
39128 if (data)
39129 break;
39130
39131 @@ -658,7 +658,7 @@ static unsigned int lis3lv02d_misc_poll(struct file *file, poll_table *wait)
39132 struct lis3lv02d, miscdev);
39133
39134 poll_wait(file, &lis3->misc_wait, wait);
39135 - if (atomic_read(&lis3->count))
39136 + if (atomic_read_unchecked(&lis3->count))
39137 return POLLIN | POLLRDNORM;
39138 return 0;
39139 }
39140 diff --git a/drivers/misc/lis3lv02d/lis3lv02d.h b/drivers/misc/lis3lv02d/lis3lv02d.h
39141 index c439c82..1f20f57 100644
39142 --- a/drivers/misc/lis3lv02d/lis3lv02d.h
39143 +++ b/drivers/misc/lis3lv02d/lis3lv02d.h
39144 @@ -297,7 +297,7 @@ struct lis3lv02d {
39145 struct input_polled_dev *idev; /* input device */
39146 struct platform_device *pdev; /* platform device */
39147 struct regulator_bulk_data regulators[2];
39148 - atomic_t count; /* interrupt count after last read */
39149 + atomic_unchecked_t count; /* interrupt count after last read */
39150 union axis_conversion ac; /* hw -> logical axis */
39151 int mapped_btns[3];
39152
39153 diff --git a/drivers/misc/sgi-gru/gruhandles.c b/drivers/misc/sgi-gru/gruhandles.c
39154 index 2f30bad..c4c13d0 100644
39155 --- a/drivers/misc/sgi-gru/gruhandles.c
39156 +++ b/drivers/misc/sgi-gru/gruhandles.c
39157 @@ -44,8 +44,8 @@ static void update_mcs_stats(enum mcs_op op, unsigned long clks)
39158 unsigned long nsec;
39159
39160 nsec = CLKS2NSEC(clks);
39161 - atomic_long_inc(&mcs_op_statistics[op].count);
39162 - atomic_long_add(nsec, &mcs_op_statistics[op].total);
39163 + atomic_long_inc_unchecked(&mcs_op_statistics[op].count);
39164 + atomic_long_add_unchecked(nsec, &mcs_op_statistics[op].total);
39165 if (mcs_op_statistics[op].max < nsec)
39166 mcs_op_statistics[op].max = nsec;
39167 }
39168 diff --git a/drivers/misc/sgi-gru/gruprocfs.c b/drivers/misc/sgi-gru/gruprocfs.c
39169 index 950dbe9..eeef0f8 100644
39170 --- a/drivers/misc/sgi-gru/gruprocfs.c
39171 +++ b/drivers/misc/sgi-gru/gruprocfs.c
39172 @@ -32,9 +32,9 @@
39173
39174 #define printstat(s, f) printstat_val(s, &gru_stats.f, #f)
39175
39176 -static void printstat_val(struct seq_file *s, atomic_long_t *v, char *id)
39177 +static void printstat_val(struct seq_file *s, atomic_long_unchecked_t *v, char *id)
39178 {
39179 - unsigned long val = atomic_long_read(v);
39180 + unsigned long val = atomic_long_read_unchecked(v);
39181
39182 seq_printf(s, "%16lu %s\n", val, id);
39183 }
39184 @@ -134,8 +134,8 @@ static int mcs_statistics_show(struct seq_file *s, void *p)
39185
39186 seq_printf(s, "%-20s%12s%12s%12s\n", "#id", "count", "aver-clks", "max-clks");
39187 for (op = 0; op < mcsop_last; op++) {
39188 - count = atomic_long_read(&mcs_op_statistics[op].count);
39189 - total = atomic_long_read(&mcs_op_statistics[op].total);
39190 + count = atomic_long_read_unchecked(&mcs_op_statistics[op].count);
39191 + total = atomic_long_read_unchecked(&mcs_op_statistics[op].total);
39192 max = mcs_op_statistics[op].max;
39193 seq_printf(s, "%-20s%12ld%12ld%12ld\n", id[op], count,
39194 count ? total / count : 0, max);
39195 diff --git a/drivers/misc/sgi-gru/grutables.h b/drivers/misc/sgi-gru/grutables.h
39196 index 5c3ce24..4915ccb 100644
39197 --- a/drivers/misc/sgi-gru/grutables.h
39198 +++ b/drivers/misc/sgi-gru/grutables.h
39199 @@ -167,82 +167,82 @@ extern unsigned int gru_max_gids;
39200 * GRU statistics.
39201 */
39202 struct gru_stats_s {
39203 - atomic_long_t vdata_alloc;
39204 - atomic_long_t vdata_free;
39205 - atomic_long_t gts_alloc;
39206 - atomic_long_t gts_free;
39207 - atomic_long_t gms_alloc;
39208 - atomic_long_t gms_free;
39209 - atomic_long_t gts_double_allocate;
39210 - atomic_long_t assign_context;
39211 - atomic_long_t assign_context_failed;
39212 - atomic_long_t free_context;
39213 - atomic_long_t load_user_context;
39214 - atomic_long_t load_kernel_context;
39215 - atomic_long_t lock_kernel_context;
39216 - atomic_long_t unlock_kernel_context;
39217 - atomic_long_t steal_user_context;
39218 - atomic_long_t steal_kernel_context;
39219 - atomic_long_t steal_context_failed;
39220 - atomic_long_t nopfn;
39221 - atomic_long_t asid_new;
39222 - atomic_long_t asid_next;
39223 - atomic_long_t asid_wrap;
39224 - atomic_long_t asid_reuse;
39225 - atomic_long_t intr;
39226 - atomic_long_t intr_cbr;
39227 - atomic_long_t intr_tfh;
39228 - atomic_long_t intr_spurious;
39229 - atomic_long_t intr_mm_lock_failed;
39230 - atomic_long_t call_os;
39231 - atomic_long_t call_os_wait_queue;
39232 - atomic_long_t user_flush_tlb;
39233 - atomic_long_t user_unload_context;
39234 - atomic_long_t user_exception;
39235 - atomic_long_t set_context_option;
39236 - atomic_long_t check_context_retarget_intr;
39237 - atomic_long_t check_context_unload;
39238 - atomic_long_t tlb_dropin;
39239 - atomic_long_t tlb_preload_page;
39240 - atomic_long_t tlb_dropin_fail_no_asid;
39241 - atomic_long_t tlb_dropin_fail_upm;
39242 - atomic_long_t tlb_dropin_fail_invalid;
39243 - atomic_long_t tlb_dropin_fail_range_active;
39244 - atomic_long_t tlb_dropin_fail_idle;
39245 - atomic_long_t tlb_dropin_fail_fmm;
39246 - atomic_long_t tlb_dropin_fail_no_exception;
39247 - atomic_long_t tfh_stale_on_fault;
39248 - atomic_long_t mmu_invalidate_range;
39249 - atomic_long_t mmu_invalidate_page;
39250 - atomic_long_t flush_tlb;
39251 - atomic_long_t flush_tlb_gru;
39252 - atomic_long_t flush_tlb_gru_tgh;
39253 - atomic_long_t flush_tlb_gru_zero_asid;
39254 + atomic_long_unchecked_t vdata_alloc;
39255 + atomic_long_unchecked_t vdata_free;
39256 + atomic_long_unchecked_t gts_alloc;
39257 + atomic_long_unchecked_t gts_free;
39258 + atomic_long_unchecked_t gms_alloc;
39259 + atomic_long_unchecked_t gms_free;
39260 + atomic_long_unchecked_t gts_double_allocate;
39261 + atomic_long_unchecked_t assign_context;
39262 + atomic_long_unchecked_t assign_context_failed;
39263 + atomic_long_unchecked_t free_context;
39264 + atomic_long_unchecked_t load_user_context;
39265 + atomic_long_unchecked_t load_kernel_context;
39266 + atomic_long_unchecked_t lock_kernel_context;
39267 + atomic_long_unchecked_t unlock_kernel_context;
39268 + atomic_long_unchecked_t steal_user_context;
39269 + atomic_long_unchecked_t steal_kernel_context;
39270 + atomic_long_unchecked_t steal_context_failed;
39271 + atomic_long_unchecked_t nopfn;
39272 + atomic_long_unchecked_t asid_new;
39273 + atomic_long_unchecked_t asid_next;
39274 + atomic_long_unchecked_t asid_wrap;
39275 + atomic_long_unchecked_t asid_reuse;
39276 + atomic_long_unchecked_t intr;
39277 + atomic_long_unchecked_t intr_cbr;
39278 + atomic_long_unchecked_t intr_tfh;
39279 + atomic_long_unchecked_t intr_spurious;
39280 + atomic_long_unchecked_t intr_mm_lock_failed;
39281 + atomic_long_unchecked_t call_os;
39282 + atomic_long_unchecked_t call_os_wait_queue;
39283 + atomic_long_unchecked_t user_flush_tlb;
39284 + atomic_long_unchecked_t user_unload_context;
39285 + atomic_long_unchecked_t user_exception;
39286 + atomic_long_unchecked_t set_context_option;
39287 + atomic_long_unchecked_t check_context_retarget_intr;
39288 + atomic_long_unchecked_t check_context_unload;
39289 + atomic_long_unchecked_t tlb_dropin;
39290 + atomic_long_unchecked_t tlb_preload_page;
39291 + atomic_long_unchecked_t tlb_dropin_fail_no_asid;
39292 + atomic_long_unchecked_t tlb_dropin_fail_upm;
39293 + atomic_long_unchecked_t tlb_dropin_fail_invalid;
39294 + atomic_long_unchecked_t tlb_dropin_fail_range_active;
39295 + atomic_long_unchecked_t tlb_dropin_fail_idle;
39296 + atomic_long_unchecked_t tlb_dropin_fail_fmm;
39297 + atomic_long_unchecked_t tlb_dropin_fail_no_exception;
39298 + atomic_long_unchecked_t tfh_stale_on_fault;
39299 + atomic_long_unchecked_t mmu_invalidate_range;
39300 + atomic_long_unchecked_t mmu_invalidate_page;
39301 + atomic_long_unchecked_t flush_tlb;
39302 + atomic_long_unchecked_t flush_tlb_gru;
39303 + atomic_long_unchecked_t flush_tlb_gru_tgh;
39304 + atomic_long_unchecked_t flush_tlb_gru_zero_asid;
39305
39306 - atomic_long_t copy_gpa;
39307 - atomic_long_t read_gpa;
39308 + atomic_long_unchecked_t copy_gpa;
39309 + atomic_long_unchecked_t read_gpa;
39310
39311 - atomic_long_t mesq_receive;
39312 - atomic_long_t mesq_receive_none;
39313 - atomic_long_t mesq_send;
39314 - atomic_long_t mesq_send_failed;
39315 - atomic_long_t mesq_noop;
39316 - atomic_long_t mesq_send_unexpected_error;
39317 - atomic_long_t mesq_send_lb_overflow;
39318 - atomic_long_t mesq_send_qlimit_reached;
39319 - atomic_long_t mesq_send_amo_nacked;
39320 - atomic_long_t mesq_send_put_nacked;
39321 - atomic_long_t mesq_page_overflow;
39322 - atomic_long_t mesq_qf_locked;
39323 - atomic_long_t mesq_qf_noop_not_full;
39324 - atomic_long_t mesq_qf_switch_head_failed;
39325 - atomic_long_t mesq_qf_unexpected_error;
39326 - atomic_long_t mesq_noop_unexpected_error;
39327 - atomic_long_t mesq_noop_lb_overflow;
39328 - atomic_long_t mesq_noop_qlimit_reached;
39329 - atomic_long_t mesq_noop_amo_nacked;
39330 - atomic_long_t mesq_noop_put_nacked;
39331 - atomic_long_t mesq_noop_page_overflow;
39332 + atomic_long_unchecked_t mesq_receive;
39333 + atomic_long_unchecked_t mesq_receive_none;
39334 + atomic_long_unchecked_t mesq_send;
39335 + atomic_long_unchecked_t mesq_send_failed;
39336 + atomic_long_unchecked_t mesq_noop;
39337 + atomic_long_unchecked_t mesq_send_unexpected_error;
39338 + atomic_long_unchecked_t mesq_send_lb_overflow;
39339 + atomic_long_unchecked_t mesq_send_qlimit_reached;
39340 + atomic_long_unchecked_t mesq_send_amo_nacked;
39341 + atomic_long_unchecked_t mesq_send_put_nacked;
39342 + atomic_long_unchecked_t mesq_page_overflow;
39343 + atomic_long_unchecked_t mesq_qf_locked;
39344 + atomic_long_unchecked_t mesq_qf_noop_not_full;
39345 + atomic_long_unchecked_t mesq_qf_switch_head_failed;
39346 + atomic_long_unchecked_t mesq_qf_unexpected_error;
39347 + atomic_long_unchecked_t mesq_noop_unexpected_error;
39348 + atomic_long_unchecked_t mesq_noop_lb_overflow;
39349 + atomic_long_unchecked_t mesq_noop_qlimit_reached;
39350 + atomic_long_unchecked_t mesq_noop_amo_nacked;
39351 + atomic_long_unchecked_t mesq_noop_put_nacked;
39352 + atomic_long_unchecked_t mesq_noop_page_overflow;
39353
39354 };
39355
39356 @@ -251,8 +251,8 @@ enum mcs_op {cchop_allocate, cchop_start, cchop_interrupt, cchop_interrupt_sync,
39357 tghop_invalidate, mcsop_last};
39358
39359 struct mcs_op_statistic {
39360 - atomic_long_t count;
39361 - atomic_long_t total;
39362 + atomic_long_unchecked_t count;
39363 + atomic_long_unchecked_t total;
39364 unsigned long max;
39365 };
39366
39367 @@ -275,7 +275,7 @@ extern struct mcs_op_statistic mcs_op_statistics[mcsop_last];
39368
39369 #define STAT(id) do { \
39370 if (gru_options & OPT_STATS) \
39371 - atomic_long_inc(&gru_stats.id); \
39372 + atomic_long_inc_unchecked(&gru_stats.id); \
39373 } while (0)
39374
39375 #ifdef CONFIG_SGI_GRU_DEBUG
39376 diff --git a/drivers/misc/sgi-xp/xp.h b/drivers/misc/sgi-xp/xp.h
39377 index c862cd4..0d176fe 100644
39378 --- a/drivers/misc/sgi-xp/xp.h
39379 +++ b/drivers/misc/sgi-xp/xp.h
39380 @@ -288,7 +288,7 @@ struct xpc_interface {
39381 xpc_notify_func, void *);
39382 void (*received) (short, int, void *);
39383 enum xp_retval (*partid_to_nasids) (short, void *);
39384 -};
39385 +} __no_const;
39386
39387 extern struct xpc_interface xpc_interface;
39388
39389 diff --git a/drivers/misc/sgi-xp/xpc.h b/drivers/misc/sgi-xp/xpc.h
39390 index b94d5f7..7f494c5 100644
39391 --- a/drivers/misc/sgi-xp/xpc.h
39392 +++ b/drivers/misc/sgi-xp/xpc.h
39393 @@ -835,6 +835,7 @@ struct xpc_arch_operations {
39394 void (*received_payload) (struct xpc_channel *, void *);
39395 void (*notify_senders_of_disconnect) (struct xpc_channel *);
39396 };
39397 +typedef struct xpc_arch_operations __no_const xpc_arch_operations_no_const;
39398
39399 /* struct xpc_partition act_state values (for XPC HB) */
39400
39401 @@ -876,7 +877,7 @@ extern struct xpc_registration xpc_registrations[];
39402 /* found in xpc_main.c */
39403 extern struct device *xpc_part;
39404 extern struct device *xpc_chan;
39405 -extern struct xpc_arch_operations xpc_arch_ops;
39406 +extern xpc_arch_operations_no_const xpc_arch_ops;
39407 extern int xpc_disengage_timelimit;
39408 extern int xpc_disengage_timedout;
39409 extern int xpc_activate_IRQ_rcvd;
39410 diff --git a/drivers/misc/sgi-xp/xpc_main.c b/drivers/misc/sgi-xp/xpc_main.c
39411 index d971817..33bdca5 100644
39412 --- a/drivers/misc/sgi-xp/xpc_main.c
39413 +++ b/drivers/misc/sgi-xp/xpc_main.c
39414 @@ -166,7 +166,7 @@ static struct notifier_block xpc_die_notifier = {
39415 .notifier_call = xpc_system_die,
39416 };
39417
39418 -struct xpc_arch_operations xpc_arch_ops;
39419 +xpc_arch_operations_no_const xpc_arch_ops;
39420
39421 /*
39422 * Timer function to enforce the timelimit on the partition disengage.
39423 @@ -1210,7 +1210,7 @@ xpc_system_die(struct notifier_block *nb, unsigned long event, void *_die_args)
39424
39425 if (((die_args->trapnr == X86_TRAP_MF) ||
39426 (die_args->trapnr == X86_TRAP_XF)) &&
39427 - !user_mode_vm(die_args->regs))
39428 + !user_mode(die_args->regs))
39429 xpc_die_deactivate();
39430
39431 break;
39432 diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c
39433 index 49f04bc..65660c2 100644
39434 --- a/drivers/mmc/core/mmc_ops.c
39435 +++ b/drivers/mmc/core/mmc_ops.c
39436 @@ -247,7 +247,7 @@ mmc_send_cxd_data(struct mmc_card *card, struct mmc_host *host,
39437 void *data_buf;
39438 int is_on_stack;
39439
39440 - is_on_stack = object_is_on_stack(buf);
39441 + is_on_stack = object_starts_on_stack(buf);
39442 if (is_on_stack) {
39443 /*
39444 * dma onto stack is unsafe/nonportable, but callers to this
39445 diff --git a/drivers/mmc/host/dw_mmc.h b/drivers/mmc/host/dw_mmc.h
39446 index 53b8fd9..615b462 100644
39447 --- a/drivers/mmc/host/dw_mmc.h
39448 +++ b/drivers/mmc/host/dw_mmc.h
39449 @@ -205,5 +205,5 @@ struct dw_mci_drv_data {
39450 int (*parse_dt)(struct dw_mci *host);
39451 int (*setup_bus)(struct dw_mci *host,
39452 struct device_node *slot_np, u8 bus_width);
39453 -};
39454 +} __do_const;
39455 #endif /* _DW_MMC_H_ */
39456 diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c
39457 index 7363efe..681558e 100644
39458 --- a/drivers/mmc/host/sdhci-s3c.c
39459 +++ b/drivers/mmc/host/sdhci-s3c.c
39460 @@ -720,9 +720,11 @@ static int sdhci_s3c_probe(struct platform_device *pdev)
39461 * we can use overriding functions instead of default.
39462 */
39463 if (host->quirks & SDHCI_QUIRK_NONSTANDARD_CLOCK) {
39464 - sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock;
39465 - sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock;
39466 - sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock;
39467 + pax_open_kernel();
39468 + *(void **)&sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock;
39469 + *(void **)&sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock;
39470 + *(void **)&sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock;
39471 + pax_close_kernel();
39472 }
39473
39474 /* It supports additional host capabilities if needed */
39475 diff --git a/drivers/mtd/devices/doc2000.c b/drivers/mtd/devices/doc2000.c
39476 index a4eb8b5..8c0628f 100644
39477 --- a/drivers/mtd/devices/doc2000.c
39478 +++ b/drivers/mtd/devices/doc2000.c
39479 @@ -753,7 +753,7 @@ static int doc_write(struct mtd_info *mtd, loff_t to, size_t len,
39480
39481 /* The ECC will not be calculated correctly if less than 512 is written */
39482 /* DBB-
39483 - if (len != 0x200 && eccbuf)
39484 + if (len != 0x200)
39485 printk(KERN_WARNING
39486 "ECC needs a full sector write (adr: %lx size %lx)\n",
39487 (long) to, (long) len);
39488 diff --git a/drivers/mtd/nand/denali.c b/drivers/mtd/nand/denali.c
39489 index 0c8bb6b..6f35deb 100644
39490 --- a/drivers/mtd/nand/denali.c
39491 +++ b/drivers/mtd/nand/denali.c
39492 @@ -24,6 +24,7 @@
39493 #include <linux/slab.h>
39494 #include <linux/mtd/mtd.h>
39495 #include <linux/module.h>
39496 +#include <linux/slab.h>
39497
39498 #include "denali.h"
39499
39500 diff --git a/drivers/mtd/nftlmount.c b/drivers/mtd/nftlmount.c
39501 index 51b9d6a..52af9a7 100644
39502 --- a/drivers/mtd/nftlmount.c
39503 +++ b/drivers/mtd/nftlmount.c
39504 @@ -24,6 +24,7 @@
39505 #include <asm/errno.h>
39506 #include <linux/delay.h>
39507 #include <linux/slab.h>
39508 +#include <linux/sched.h>
39509 #include <linux/mtd/mtd.h>
39510 #include <linux/mtd/nand.h>
39511 #include <linux/mtd/nftl.h>
39512 diff --git a/drivers/mtd/sm_ftl.c b/drivers/mtd/sm_ftl.c
39513 index 8dd6ba5..419cc1d 100644
39514 --- a/drivers/mtd/sm_ftl.c
39515 +++ b/drivers/mtd/sm_ftl.c
39516 @@ -56,7 +56,7 @@ ssize_t sm_attr_show(struct device *dev, struct device_attribute *attr,
39517 #define SM_CIS_VENDOR_OFFSET 0x59
39518 struct attribute_group *sm_create_sysfs_attributes(struct sm_ftl *ftl)
39519 {
39520 - struct attribute_group *attr_group;
39521 + attribute_group_no_const *attr_group;
39522 struct attribute **attributes;
39523 struct sm_sysfs_attribute *vendor_attribute;
39524
39525 diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
39526 index dbbea0e..3f4a0b1 100644
39527 --- a/drivers/net/bonding/bond_main.c
39528 +++ b/drivers/net/bonding/bond_main.c
39529 @@ -4822,7 +4822,7 @@ static unsigned int bond_get_num_tx_queues(void)
39530 return tx_queues;
39531 }
39532
39533 -static struct rtnl_link_ops bond_link_ops __read_mostly = {
39534 +static struct rtnl_link_ops bond_link_ops = {
39535 .kind = "bond",
39536 .priv_size = sizeof(struct bonding),
39537 .setup = bond_setup,
39538 @@ -4947,8 +4947,8 @@ static void __exit bonding_exit(void)
39539
39540 bond_destroy_debugfs();
39541
39542 - rtnl_link_unregister(&bond_link_ops);
39543 unregister_pernet_subsys(&bond_net_ops);
39544 + rtnl_link_unregister(&bond_link_ops);
39545
39546 #ifdef CONFIG_NET_POLL_CONTROLLER
39547 /*
39548 diff --git a/drivers/net/ethernet/8390/ax88796.c b/drivers/net/ethernet/8390/ax88796.c
39549 index e1d2643..7f4133b 100644
39550 --- a/drivers/net/ethernet/8390/ax88796.c
39551 +++ b/drivers/net/ethernet/8390/ax88796.c
39552 @@ -872,9 +872,11 @@ static int ax_probe(struct platform_device *pdev)
39553 if (ax->plat->reg_offsets)
39554 ei_local->reg_offset = ax->plat->reg_offsets;
39555 else {
39556 + resource_size_t _mem_size = mem_size;
39557 + do_div(_mem_size, 0x18);
39558 ei_local->reg_offset = ax->reg_offsets;
39559 for (ret = 0; ret < 0x18; ret++)
39560 - ax->reg_offsets[ret] = (mem_size / 0x18) * ret;
39561 + ax->reg_offsets[ret] = _mem_size * ret;
39562 }
39563
39564 if (!request_mem_region(mem->start, mem_size, pdev->name)) {
39565 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
39566 index aee7671..3ca2651 100644
39567 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
39568 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
39569 @@ -1093,7 +1093,7 @@ static inline u8 bnx2x_get_path_func_num(struct bnx2x *bp)
39570 static inline void bnx2x_init_bp_objs(struct bnx2x *bp)
39571 {
39572 /* RX_MODE controlling object */
39573 - bnx2x_init_rx_mode_obj(bp, &bp->rx_mode_obj);
39574 + bnx2x_init_rx_mode_obj(bp);
39575
39576 /* multicast configuration controlling object */
39577 bnx2x_init_mcast_obj(bp, &bp->mcast_obj, bp->fp->cl_id, bp->fp->cid,
39578 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
39579 index 7306416..5fb7fb5 100644
39580 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
39581 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
39582 @@ -2381,15 +2381,14 @@ int bnx2x_config_rx_mode(struct bnx2x *bp,
39583 return rc;
39584 }
39585
39586 -void bnx2x_init_rx_mode_obj(struct bnx2x *bp,
39587 - struct bnx2x_rx_mode_obj *o)
39588 +void bnx2x_init_rx_mode_obj(struct bnx2x *bp)
39589 {
39590 if (CHIP_IS_E1x(bp)) {
39591 - o->wait_comp = bnx2x_empty_rx_mode_wait;
39592 - o->config_rx_mode = bnx2x_set_rx_mode_e1x;
39593 + bp->rx_mode_obj.wait_comp = bnx2x_empty_rx_mode_wait;
39594 + bp->rx_mode_obj.config_rx_mode = bnx2x_set_rx_mode_e1x;
39595 } else {
39596 - o->wait_comp = bnx2x_wait_rx_mode_comp_e2;
39597 - o->config_rx_mode = bnx2x_set_rx_mode_e2;
39598 + bp->rx_mode_obj.wait_comp = bnx2x_wait_rx_mode_comp_e2;
39599 + bp->rx_mode_obj.config_rx_mode = bnx2x_set_rx_mode_e2;
39600 }
39601 }
39602
39603 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
39604 index ff90760..08d8aed 100644
39605 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
39606 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
39607 @@ -1306,8 +1306,7 @@ int bnx2x_vlan_mac_move(struct bnx2x *bp,
39608
39609 /********************* RX MODE ****************/
39610
39611 -void bnx2x_init_rx_mode_obj(struct bnx2x *bp,
39612 - struct bnx2x_rx_mode_obj *o);
39613 +void bnx2x_init_rx_mode_obj(struct bnx2x *bp);
39614
39615 /**
39616 * bnx2x_config_rx_mode - Send and RX_MODE ramrod according to the provided parameters.
39617 diff --git a/drivers/net/ethernet/broadcom/tg3.h b/drivers/net/ethernet/broadcom/tg3.h
39618 index 25309bf..fcfd54c 100644
39619 --- a/drivers/net/ethernet/broadcom/tg3.h
39620 +++ b/drivers/net/ethernet/broadcom/tg3.h
39621 @@ -147,6 +147,7 @@
39622 #define CHIPREV_ID_5750_A0 0x4000
39623 #define CHIPREV_ID_5750_A1 0x4001
39624 #define CHIPREV_ID_5750_A3 0x4003
39625 +#define CHIPREV_ID_5750_C1 0x4201
39626 #define CHIPREV_ID_5750_C2 0x4202
39627 #define CHIPREV_ID_5752_A0_HW 0x5000
39628 #define CHIPREV_ID_5752_A0 0x6000
39629 diff --git a/drivers/net/ethernet/chelsio/cxgb3/l2t.h b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
39630 index 8cffcdf..aadf043 100644
39631 --- a/drivers/net/ethernet/chelsio/cxgb3/l2t.h
39632 +++ b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
39633 @@ -87,7 +87,7 @@ typedef void (*arp_failure_handler_func)(struct t3cdev * dev,
39634 */
39635 struct l2t_skb_cb {
39636 arp_failure_handler_func arp_failure_handler;
39637 -};
39638 +} __no_const;
39639
39640 #define L2T_SKB_CB(skb) ((struct l2t_skb_cb *)(skb)->cb)
39641
39642 diff --git a/drivers/net/ethernet/dec/tulip/de4x5.c b/drivers/net/ethernet/dec/tulip/de4x5.c
39643 index 4c83003..2a2a5b9 100644
39644 --- a/drivers/net/ethernet/dec/tulip/de4x5.c
39645 +++ b/drivers/net/ethernet/dec/tulip/de4x5.c
39646 @@ -5388,7 +5388,7 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
39647 for (i=0; i<ETH_ALEN; i++) {
39648 tmp.addr[i] = dev->dev_addr[i];
39649 }
39650 - if (copy_to_user(ioc->data, tmp.addr, ioc->len)) return -EFAULT;
39651 + if (ioc->len > sizeof tmp.addr || copy_to_user(ioc->data, tmp.addr, ioc->len)) return -EFAULT;
39652 break;
39653
39654 case DE4X5_SET_HWADDR: /* Set the hardware address */
39655 @@ -5428,7 +5428,7 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
39656 spin_lock_irqsave(&lp->lock, flags);
39657 memcpy(&statbuf, &lp->pktStats, ioc->len);
39658 spin_unlock_irqrestore(&lp->lock, flags);
39659 - if (copy_to_user(ioc->data, &statbuf, ioc->len))
39660 + if (ioc->len > sizeof statbuf || copy_to_user(ioc->data, &statbuf, ioc->len))
39661 return -EFAULT;
39662 break;
39663 }
39664 diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c
39665 index 2886c9b..db71673 100644
39666 --- a/drivers/net/ethernet/emulex/benet/be_main.c
39667 +++ b/drivers/net/ethernet/emulex/benet/be_main.c
39668 @@ -455,7 +455,7 @@ static void accumulate_16bit_val(u32 *acc, u16 val)
39669
39670 if (wrapped)
39671 newacc += 65536;
39672 - ACCESS_ONCE(*acc) = newacc;
39673 + ACCESS_ONCE_RW(*acc) = newacc;
39674 }
39675
39676 void be_parse_stats(struct be_adapter *adapter)
39677 diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
39678 index 7c361d1..57e3ff1 100644
39679 --- a/drivers/net/ethernet/faraday/ftgmac100.c
39680 +++ b/drivers/net/ethernet/faraday/ftgmac100.c
39681 @@ -31,6 +31,8 @@
39682 #include <linux/netdevice.h>
39683 #include <linux/phy.h>
39684 #include <linux/platform_device.h>
39685 +#include <linux/interrupt.h>
39686 +#include <linux/irqreturn.h>
39687 #include <net/ip.h>
39688
39689 #include "ftgmac100.h"
39690 diff --git a/drivers/net/ethernet/faraday/ftmac100.c b/drivers/net/ethernet/faraday/ftmac100.c
39691 index b5ea8fb..bd25e9a 100644
39692 --- a/drivers/net/ethernet/faraday/ftmac100.c
39693 +++ b/drivers/net/ethernet/faraday/ftmac100.c
39694 @@ -31,6 +31,8 @@
39695 #include <linux/module.h>
39696 #include <linux/netdevice.h>
39697 #include <linux/platform_device.h>
39698 +#include <linux/interrupt.h>
39699 +#include <linux/irqreturn.h>
39700
39701 #include "ftmac100.h"
39702
39703 diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
39704 index 331987d..3be1135 100644
39705 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
39706 +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
39707 @@ -776,7 +776,7 @@ void ixgbe_ptp_start_cyclecounter(struct ixgbe_adapter *adapter)
39708 }
39709
39710 /* update the base incval used to calculate frequency adjustment */
39711 - ACCESS_ONCE(adapter->base_incval) = incval;
39712 + ACCESS_ONCE_RW(adapter->base_incval) = incval;
39713 smp_mb();
39714
39715 /* need lock to prevent incorrect read while modifying cyclecounter */
39716 diff --git a/drivers/net/ethernet/neterion/vxge/vxge-config.c b/drivers/net/ethernet/neterion/vxge/vxge-config.c
39717 index fbe5363..266b4e3 100644
39718 --- a/drivers/net/ethernet/neterion/vxge/vxge-config.c
39719 +++ b/drivers/net/ethernet/neterion/vxge/vxge-config.c
39720 @@ -3461,7 +3461,10 @@ __vxge_hw_fifo_create(struct __vxge_hw_vpath_handle *vp,
39721 struct __vxge_hw_fifo *fifo;
39722 struct vxge_hw_fifo_config *config;
39723 u32 txdl_size, txdl_per_memblock;
39724 - struct vxge_hw_mempool_cbs fifo_mp_callback;
39725 + static struct vxge_hw_mempool_cbs fifo_mp_callback = {
39726 + .item_func_alloc = __vxge_hw_fifo_mempool_item_alloc,
39727 + };
39728 +
39729 struct __vxge_hw_virtualpath *vpath;
39730
39731 if ((vp == NULL) || (attr == NULL)) {
39732 @@ -3544,8 +3547,6 @@ __vxge_hw_fifo_create(struct __vxge_hw_vpath_handle *vp,
39733 goto exit;
39734 }
39735
39736 - fifo_mp_callback.item_func_alloc = __vxge_hw_fifo_mempool_item_alloc;
39737 -
39738 fifo->mempool =
39739 __vxge_hw_mempool_create(vpath->hldev,
39740 fifo->config->memblock_size,
39741 diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
39742 index 5c033f2..7bbb0d8 100644
39743 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
39744 +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
39745 @@ -1894,7 +1894,9 @@ int qlcnic_83xx_config_default_opmode(struct qlcnic_adapter *adapter)
39746 op_mode = QLCRDX(ahw, QLC_83XX_DRV_OP_MODE);
39747
39748 if (op_mode == QLC_83XX_DEFAULT_OPMODE) {
39749 - adapter->nic_ops->init_driver = qlcnic_83xx_init_default_driver;
39750 + pax_open_kernel();
39751 + *(void **)&adapter->nic_ops->init_driver = qlcnic_83xx_init_default_driver;
39752 + pax_close_kernel();
39753 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
39754 } else {
39755 return -EIO;
39756 diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
39757 index b0c3de9..fc5857e 100644
39758 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
39759 +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
39760 @@ -200,15 +200,21 @@ int qlcnic_83xx_config_vnic_opmode(struct qlcnic_adapter *adapter)
39761 if (priv_level == QLCNIC_NON_PRIV_FUNC) {
39762 ahw->op_mode = QLCNIC_NON_PRIV_FUNC;
39763 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
39764 - nic_ops->init_driver = qlcnic_83xx_init_non_privileged_vnic;
39765 + pax_open_kernel();
39766 + *(void **)&nic_ops->init_driver = qlcnic_83xx_init_non_privileged_vnic;
39767 + pax_close_kernel();
39768 } else if (priv_level == QLCNIC_PRIV_FUNC) {
39769 ahw->op_mode = QLCNIC_PRIV_FUNC;
39770 ahw->idc.state_entry = qlcnic_83xx_idc_vnic_pf_entry;
39771 - nic_ops->init_driver = qlcnic_83xx_init_privileged_vnic;
39772 + pax_open_kernel();
39773 + *(void **)&nic_ops->init_driver = qlcnic_83xx_init_privileged_vnic;
39774 + pax_close_kernel();
39775 } else if (priv_level == QLCNIC_MGMT_FUNC) {
39776 ahw->op_mode = QLCNIC_MGMT_FUNC;
39777 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
39778 - nic_ops->init_driver = qlcnic_83xx_init_mgmt_vnic;
39779 + pax_open_kernel();
39780 + *(void **)&nic_ops->init_driver = qlcnic_83xx_init_mgmt_vnic;
39781 + pax_close_kernel();
39782 } else {
39783 return -EIO;
39784 }
39785 diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c
39786 index 15ba8c4..3f56838 100644
39787 --- a/drivers/net/ethernet/realtek/r8169.c
39788 +++ b/drivers/net/ethernet/realtek/r8169.c
39789 @@ -740,22 +740,22 @@ struct rtl8169_private {
39790 struct mdio_ops {
39791 void (*write)(struct rtl8169_private *, int, int);
39792 int (*read)(struct rtl8169_private *, int);
39793 - } mdio_ops;
39794 + } __no_const mdio_ops;
39795
39796 struct pll_power_ops {
39797 void (*down)(struct rtl8169_private *);
39798 void (*up)(struct rtl8169_private *);
39799 - } pll_power_ops;
39800 + } __no_const pll_power_ops;
39801
39802 struct jumbo_ops {
39803 void (*enable)(struct rtl8169_private *);
39804 void (*disable)(struct rtl8169_private *);
39805 - } jumbo_ops;
39806 + } __no_const jumbo_ops;
39807
39808 struct csi_ops {
39809 void (*write)(struct rtl8169_private *, int, int);
39810 u32 (*read)(struct rtl8169_private *, int);
39811 - } csi_ops;
39812 + } __no_const csi_ops;
39813
39814 int (*set_speed)(struct net_device *, u8 aneg, u16 sp, u8 dpx, u32 adv);
39815 int (*get_settings)(struct net_device *, struct ethtool_cmd *);
39816 diff --git a/drivers/net/ethernet/sfc/ptp.c b/drivers/net/ethernet/sfc/ptp.c
39817 index 3f93624..cf01144 100644
39818 --- a/drivers/net/ethernet/sfc/ptp.c
39819 +++ b/drivers/net/ethernet/sfc/ptp.c
39820 @@ -553,7 +553,7 @@ static int efx_ptp_synchronize(struct efx_nic *efx, unsigned int num_readings)
39821 (u32)((u64)ptp->start.dma_addr >> 32));
39822
39823 /* Clear flag that signals MC ready */
39824 - ACCESS_ONCE(*start) = 0;
39825 + ACCESS_ONCE_RW(*start) = 0;
39826 efx_mcdi_rpc_start(efx, MC_CMD_PTP, synch_buf,
39827 MC_CMD_PTP_IN_SYNCHRONIZE_LEN);
39828
39829 diff --git a/drivers/net/ethernet/stmicro/stmmac/mmc_core.c b/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
39830 index 50617c5..b13724c 100644
39831 --- a/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
39832 +++ b/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
39833 @@ -140,8 +140,8 @@ void dwmac_mmc_ctrl(void __iomem *ioaddr, unsigned int mode)
39834
39835 writel(value, ioaddr + MMC_CNTRL);
39836
39837 - pr_debug("stmmac: MMC ctrl register (offset 0x%x): 0x%08x\n",
39838 - MMC_CNTRL, value);
39839 +// pr_debug("stmmac: MMC ctrl register (offset 0x%x): 0x%08x\n",
39840 +// MMC_CNTRL, value);
39841 }
39842
39843 /* To mask all all interrupts.*/
39844 diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
39845 index e6fe0d8..2b7d752 100644
39846 --- a/drivers/net/hyperv/hyperv_net.h
39847 +++ b/drivers/net/hyperv/hyperv_net.h
39848 @@ -101,7 +101,7 @@ struct rndis_device {
39849
39850 enum rndis_device_state state;
39851 bool link_state;
39852 - atomic_t new_req_id;
39853 + atomic_unchecked_t new_req_id;
39854
39855 spinlock_t request_lock;
39856 struct list_head req_list;
39857 diff --git a/drivers/net/hyperv/rndis_filter.c b/drivers/net/hyperv/rndis_filter.c
39858 index 0775f0a..d4fb316 100644
39859 --- a/drivers/net/hyperv/rndis_filter.c
39860 +++ b/drivers/net/hyperv/rndis_filter.c
39861 @@ -104,7 +104,7 @@ static struct rndis_request *get_rndis_request(struct rndis_device *dev,
39862 * template
39863 */
39864 set = &rndis_msg->msg.set_req;
39865 - set->req_id = atomic_inc_return(&dev->new_req_id);
39866 + set->req_id = atomic_inc_return_unchecked(&dev->new_req_id);
39867
39868 /* Add to the request list */
39869 spin_lock_irqsave(&dev->request_lock, flags);
39870 @@ -752,7 +752,7 @@ static void rndis_filter_halt_device(struct rndis_device *dev)
39871
39872 /* Setup the rndis set */
39873 halt = &request->request_msg.msg.halt_req;
39874 - halt->req_id = atomic_inc_return(&dev->new_req_id);
39875 + halt->req_id = atomic_inc_return_unchecked(&dev->new_req_id);
39876
39877 /* Ignore return since this msg is optional. */
39878 rndis_filter_send_request(dev, request);
39879 diff --git a/drivers/net/ieee802154/fakehard.c b/drivers/net/ieee802154/fakehard.c
39880 index 8f1c256..a2991d1 100644
39881 --- a/drivers/net/ieee802154/fakehard.c
39882 +++ b/drivers/net/ieee802154/fakehard.c
39883 @@ -385,7 +385,7 @@ static int ieee802154fake_probe(struct platform_device *pdev)
39884 phy->transmit_power = 0xbf;
39885
39886 dev->netdev_ops = &fake_ops;
39887 - dev->ml_priv = &fake_mlme;
39888 + dev->ml_priv = (void *)&fake_mlme;
39889
39890 priv = netdev_priv(dev);
39891 priv->phy = phy;
39892 diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
39893 index 011062e..ada88e9 100644
39894 --- a/drivers/net/macvlan.c
39895 +++ b/drivers/net/macvlan.c
39896 @@ -892,13 +892,15 @@ static const struct nla_policy macvlan_policy[IFLA_MACVLAN_MAX + 1] = {
39897 int macvlan_link_register(struct rtnl_link_ops *ops)
39898 {
39899 /* common fields */
39900 - ops->priv_size = sizeof(struct macvlan_dev);
39901 - ops->validate = macvlan_validate;
39902 - ops->maxtype = IFLA_MACVLAN_MAX;
39903 - ops->policy = macvlan_policy;
39904 - ops->changelink = macvlan_changelink;
39905 - ops->get_size = macvlan_get_size;
39906 - ops->fill_info = macvlan_fill_info;
39907 + pax_open_kernel();
39908 + *(size_t *)&ops->priv_size = sizeof(struct macvlan_dev);
39909 + *(void **)&ops->validate = macvlan_validate;
39910 + *(int *)&ops->maxtype = IFLA_MACVLAN_MAX;
39911 + *(const void **)&ops->policy = macvlan_policy;
39912 + *(void **)&ops->changelink = macvlan_changelink;
39913 + *(void **)&ops->get_size = macvlan_get_size;
39914 + *(void **)&ops->fill_info = macvlan_fill_info;
39915 + pax_close_kernel();
39916
39917 return rtnl_link_register(ops);
39918 };
39919 @@ -954,7 +956,7 @@ static int macvlan_device_event(struct notifier_block *unused,
39920 return NOTIFY_DONE;
39921 }
39922
39923 -static struct notifier_block macvlan_notifier_block __read_mostly = {
39924 +static struct notifier_block macvlan_notifier_block = {
39925 .notifier_call = macvlan_device_event,
39926 };
39927
39928 diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c
39929 index a449439..1e468fe 100644
39930 --- a/drivers/net/macvtap.c
39931 +++ b/drivers/net/macvtap.c
39932 @@ -1090,7 +1090,7 @@ static int macvtap_device_event(struct notifier_block *unused,
39933 return NOTIFY_DONE;
39934 }
39935
39936 -static struct notifier_block macvtap_notifier_block __read_mostly = {
39937 +static struct notifier_block macvtap_notifier_block = {
39938 .notifier_call = macvtap_device_event,
39939 };
39940
39941 diff --git a/drivers/net/phy/mdio-bitbang.c b/drivers/net/phy/mdio-bitbang.c
39942 index daec9b0..6428fcb 100644
39943 --- a/drivers/net/phy/mdio-bitbang.c
39944 +++ b/drivers/net/phy/mdio-bitbang.c
39945 @@ -234,6 +234,7 @@ void free_mdio_bitbang(struct mii_bus *bus)
39946 struct mdiobb_ctrl *ctrl = bus->priv;
39947
39948 module_put(ctrl->ops->owner);
39949 + mdiobus_unregister(bus);
39950 mdiobus_free(bus);
39951 }
39952 EXPORT_SYMBOL(free_mdio_bitbang);
39953 diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c
39954 index 72ff14b..11d442d 100644
39955 --- a/drivers/net/ppp/ppp_generic.c
39956 +++ b/drivers/net/ppp/ppp_generic.c
39957 @@ -999,7 +999,6 @@ ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
39958 void __user *addr = (void __user *) ifr->ifr_ifru.ifru_data;
39959 struct ppp_stats stats;
39960 struct ppp_comp_stats cstats;
39961 - char *vers;
39962
39963 switch (cmd) {
39964 case SIOCGPPPSTATS:
39965 @@ -1021,8 +1020,7 @@ ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
39966 break;
39967
39968 case SIOCGPPPVER:
39969 - vers = PPP_VERSION;
39970 - if (copy_to_user(addr, vers, strlen(vers) + 1))
39971 + if (copy_to_user(addr, PPP_VERSION, sizeof(PPP_VERSION)))
39972 break;
39973 err = 0;
39974 break;
39975 diff --git a/drivers/net/slip/slhc.c b/drivers/net/slip/slhc.c
39976 index 1252d9c..80e660b 100644
39977 --- a/drivers/net/slip/slhc.c
39978 +++ b/drivers/net/slip/slhc.c
39979 @@ -488,7 +488,7 @@ slhc_uncompress(struct slcompress *comp, unsigned char *icp, int isize)
39980 register struct tcphdr *thp;
39981 register struct iphdr *ip;
39982 register struct cstate *cs;
39983 - int len, hdrlen;
39984 + long len, hdrlen;
39985 unsigned char *cp = icp;
39986
39987 /* We've got a compressed packet; read the change byte */
39988 diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c
39989 index bf34192..fba3500 100644
39990 --- a/drivers/net/team/team.c
39991 +++ b/drivers/net/team/team.c
39992 @@ -2668,7 +2668,7 @@ static int team_device_event(struct notifier_block *unused,
39993 return NOTIFY_DONE;
39994 }
39995
39996 -static struct notifier_block team_notifier_block __read_mostly = {
39997 +static struct notifier_block team_notifier_block = {
39998 .notifier_call = team_device_event,
39999 };
40000
40001 diff --git a/drivers/net/tun.c b/drivers/net/tun.c
40002 index 755fa9e..631fdce 100644
40003 --- a/drivers/net/tun.c
40004 +++ b/drivers/net/tun.c
40005 @@ -1841,7 +1841,7 @@ unlock:
40006 }
40007
40008 static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
40009 - unsigned long arg, int ifreq_len)
40010 + unsigned long arg, size_t ifreq_len)
40011 {
40012 struct tun_file *tfile = file->private_data;
40013 struct tun_struct *tun;
40014 @@ -1853,6 +1853,9 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
40015 int vnet_hdr_sz;
40016 int ret;
40017
40018 + if (ifreq_len > sizeof ifr)
40019 + return -EFAULT;
40020 +
40021 if (cmd == TUNSETIFF || cmd == TUNSETQUEUE || _IOC_TYPE(cmd) == 0x89) {
40022 if (copy_from_user(&ifr, argp, ifreq_len))
40023 return -EFAULT;
40024 diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
40025 index e2dd324..be92fcf 100644
40026 --- a/drivers/net/usb/hso.c
40027 +++ b/drivers/net/usb/hso.c
40028 @@ -71,7 +71,7 @@
40029 #include <asm/byteorder.h>
40030 #include <linux/serial_core.h>
40031 #include <linux/serial.h>
40032 -
40033 +#include <asm/local.h>
40034
40035 #define MOD_AUTHOR "Option Wireless"
40036 #define MOD_DESCRIPTION "USB High Speed Option driver"
40037 @@ -1180,7 +1180,7 @@ static void put_rxbuf_data_and_resubmit_ctrl_urb(struct hso_serial *serial)
40038 struct urb *urb;
40039
40040 urb = serial->rx_urb[0];
40041 - if (serial->port.count > 0) {
40042 + if (atomic_read(&serial->port.count) > 0) {
40043 count = put_rxbuf_data(urb, serial);
40044 if (count == -1)
40045 return;
40046 @@ -1216,7 +1216,7 @@ static void hso_std_serial_read_bulk_callback(struct urb *urb)
40047 DUMP1(urb->transfer_buffer, urb->actual_length);
40048
40049 /* Anyone listening? */
40050 - if (serial->port.count == 0)
40051 + if (atomic_read(&serial->port.count) == 0)
40052 return;
40053
40054 if (status == 0) {
40055 @@ -1298,8 +1298,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
40056 tty_port_tty_set(&serial->port, tty);
40057
40058 /* check for port already opened, if not set the termios */
40059 - serial->port.count++;
40060 - if (serial->port.count == 1) {
40061 + if (atomic_inc_return(&serial->port.count) == 1) {
40062 serial->rx_state = RX_IDLE;
40063 /* Force default termio settings */
40064 _hso_serial_set_termios(tty, NULL);
40065 @@ -1311,7 +1310,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
40066 result = hso_start_serial_device(serial->parent, GFP_KERNEL);
40067 if (result) {
40068 hso_stop_serial_device(serial->parent);
40069 - serial->port.count--;
40070 + atomic_dec(&serial->port.count);
40071 kref_put(&serial->parent->ref, hso_serial_ref_free);
40072 }
40073 } else {
40074 @@ -1348,10 +1347,10 @@ static void hso_serial_close(struct tty_struct *tty, struct file *filp)
40075
40076 /* reset the rts and dtr */
40077 /* do the actual close */
40078 - serial->port.count--;
40079 + atomic_dec(&serial->port.count);
40080
40081 - if (serial->port.count <= 0) {
40082 - serial->port.count = 0;
40083 + if (atomic_read(&serial->port.count) <= 0) {
40084 + atomic_set(&serial->port.count, 0);
40085 tty_port_tty_set(&serial->port, NULL);
40086 if (!usb_gone)
40087 hso_stop_serial_device(serial->parent);
40088 @@ -1427,7 +1426,7 @@ static void hso_serial_set_termios(struct tty_struct *tty, struct ktermios *old)
40089
40090 /* the actual setup */
40091 spin_lock_irqsave(&serial->serial_lock, flags);
40092 - if (serial->port.count)
40093 + if (atomic_read(&serial->port.count))
40094 _hso_serial_set_termios(tty, old);
40095 else
40096 tty->termios = *old;
40097 @@ -1886,7 +1885,7 @@ static void intr_callback(struct urb *urb)
40098 D1("Pending read interrupt on port %d\n", i);
40099 spin_lock(&serial->serial_lock);
40100 if (serial->rx_state == RX_IDLE &&
40101 - serial->port.count > 0) {
40102 + atomic_read(&serial->port.count) > 0) {
40103 /* Setup and send a ctrl req read on
40104 * port i */
40105 if (!serial->rx_urb_filled[0]) {
40106 @@ -3066,7 +3065,7 @@ static int hso_resume(struct usb_interface *iface)
40107 /* Start all serial ports */
40108 for (i = 0; i < HSO_SERIAL_TTY_MINORS; i++) {
40109 if (serial_table[i] && (serial_table[i]->interface == iface)) {
40110 - if (dev2ser(serial_table[i])->port.count) {
40111 + if (atomic_read(&dev2ser(serial_table[i])->port.count)) {
40112 result =
40113 hso_start_serial_device(serial_table[i], GFP_NOIO);
40114 hso_kick_transmit(dev2ser(serial_table[i]));
40115 diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
40116 index 7cee7a3..1eb9f3b 100644
40117 --- a/drivers/net/vxlan.c
40118 +++ b/drivers/net/vxlan.c
40119 @@ -1443,7 +1443,7 @@ nla_put_failure:
40120 return -EMSGSIZE;
40121 }
40122
40123 -static struct rtnl_link_ops vxlan_link_ops __read_mostly = {
40124 +static struct rtnl_link_ops vxlan_link_ops = {
40125 .kind = "vxlan",
40126 .maxtype = IFLA_VXLAN_MAX,
40127 .policy = vxlan_policy,
40128 diff --git a/drivers/net/wireless/at76c50x-usb.c b/drivers/net/wireless/at76c50x-usb.c
40129 index 5ac5f7a..5f82012 100644
40130 --- a/drivers/net/wireless/at76c50x-usb.c
40131 +++ b/drivers/net/wireless/at76c50x-usb.c
40132 @@ -353,7 +353,7 @@ static int at76_dfu_get_state(struct usb_device *udev, u8 *state)
40133 }
40134
40135 /* Convert timeout from the DFU status to jiffies */
40136 -static inline unsigned long at76_get_timeout(struct dfu_status *s)
40137 +static inline unsigned long __intentional_overflow(-1) at76_get_timeout(struct dfu_status *s)
40138 {
40139 return msecs_to_jiffies((s->poll_timeout[2] << 16)
40140 | (s->poll_timeout[1] << 8)
40141 diff --git a/drivers/net/wireless/ath/ath9k/ar9002_mac.c b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
40142 index 8d78253..bebbb68 100644
40143 --- a/drivers/net/wireless/ath/ath9k/ar9002_mac.c
40144 +++ b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
40145 @@ -184,8 +184,8 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40146 ads->ds_txstatus6 = ads->ds_txstatus7 = 0;
40147 ads->ds_txstatus8 = ads->ds_txstatus9 = 0;
40148
40149 - ACCESS_ONCE(ads->ds_link) = i->link;
40150 - ACCESS_ONCE(ads->ds_data) = i->buf_addr[0];
40151 + ACCESS_ONCE_RW(ads->ds_link) = i->link;
40152 + ACCESS_ONCE_RW(ads->ds_data) = i->buf_addr[0];
40153
40154 ctl1 = i->buf_len[0] | (i->is_last ? 0 : AR_TxMore);
40155 ctl6 = SM(i->keytype, AR_EncrType);
40156 @@ -199,26 +199,26 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40157
40158 if ((i->is_first || i->is_last) &&
40159 i->aggr != AGGR_BUF_MIDDLE && i->aggr != AGGR_BUF_LAST) {
40160 - ACCESS_ONCE(ads->ds_ctl2) = set11nTries(i->rates, 0)
40161 + ACCESS_ONCE_RW(ads->ds_ctl2) = set11nTries(i->rates, 0)
40162 | set11nTries(i->rates, 1)
40163 | set11nTries(i->rates, 2)
40164 | set11nTries(i->rates, 3)
40165 | (i->dur_update ? AR_DurUpdateEna : 0)
40166 | SM(0, AR_BurstDur);
40167
40168 - ACCESS_ONCE(ads->ds_ctl3) = set11nRate(i->rates, 0)
40169 + ACCESS_ONCE_RW(ads->ds_ctl3) = set11nRate(i->rates, 0)
40170 | set11nRate(i->rates, 1)
40171 | set11nRate(i->rates, 2)
40172 | set11nRate(i->rates, 3);
40173 } else {
40174 - ACCESS_ONCE(ads->ds_ctl2) = 0;
40175 - ACCESS_ONCE(ads->ds_ctl3) = 0;
40176 + ACCESS_ONCE_RW(ads->ds_ctl2) = 0;
40177 + ACCESS_ONCE_RW(ads->ds_ctl3) = 0;
40178 }
40179
40180 if (!i->is_first) {
40181 - ACCESS_ONCE(ads->ds_ctl0) = 0;
40182 - ACCESS_ONCE(ads->ds_ctl1) = ctl1;
40183 - ACCESS_ONCE(ads->ds_ctl6) = ctl6;
40184 + ACCESS_ONCE_RW(ads->ds_ctl0) = 0;
40185 + ACCESS_ONCE_RW(ads->ds_ctl1) = ctl1;
40186 + ACCESS_ONCE_RW(ads->ds_ctl6) = ctl6;
40187 return;
40188 }
40189
40190 @@ -243,7 +243,7 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40191 break;
40192 }
40193
40194 - ACCESS_ONCE(ads->ds_ctl0) = (i->pkt_len & AR_FrameLen)
40195 + ACCESS_ONCE_RW(ads->ds_ctl0) = (i->pkt_len & AR_FrameLen)
40196 | (i->flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
40197 | SM(i->txpower, AR_XmitPower)
40198 | (i->flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
40199 @@ -253,19 +253,19 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40200 | (i->flags & ATH9K_TXDESC_RTSENA ? AR_RTSEnable :
40201 (i->flags & ATH9K_TXDESC_CTSENA ? AR_CTSEnable : 0));
40202
40203 - ACCESS_ONCE(ads->ds_ctl1) = ctl1;
40204 - ACCESS_ONCE(ads->ds_ctl6) = ctl6;
40205 + ACCESS_ONCE_RW(ads->ds_ctl1) = ctl1;
40206 + ACCESS_ONCE_RW(ads->ds_ctl6) = ctl6;
40207
40208 if (i->aggr == AGGR_BUF_MIDDLE || i->aggr == AGGR_BUF_LAST)
40209 return;
40210
40211 - ACCESS_ONCE(ads->ds_ctl4) = set11nPktDurRTSCTS(i->rates, 0)
40212 + ACCESS_ONCE_RW(ads->ds_ctl4) = set11nPktDurRTSCTS(i->rates, 0)
40213 | set11nPktDurRTSCTS(i->rates, 1);
40214
40215 - ACCESS_ONCE(ads->ds_ctl5) = set11nPktDurRTSCTS(i->rates, 2)
40216 + ACCESS_ONCE_RW(ads->ds_ctl5) = set11nPktDurRTSCTS(i->rates, 2)
40217 | set11nPktDurRTSCTS(i->rates, 3);
40218
40219 - ACCESS_ONCE(ads->ds_ctl7) = set11nRateFlags(i->rates, 0)
40220 + ACCESS_ONCE_RW(ads->ds_ctl7) = set11nRateFlags(i->rates, 0)
40221 | set11nRateFlags(i->rates, 1)
40222 | set11nRateFlags(i->rates, 2)
40223 | set11nRateFlags(i->rates, 3)
40224 diff --git a/drivers/net/wireless/ath/ath9k/ar9003_mac.c b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
40225 index 301bf72..3f5654f 100644
40226 --- a/drivers/net/wireless/ath/ath9k/ar9003_mac.c
40227 +++ b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
40228 @@ -39,47 +39,47 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40229 (i->qcu << AR_TxQcuNum_S) | desc_len;
40230
40231 checksum += val;
40232 - ACCESS_ONCE(ads->info) = val;
40233 + ACCESS_ONCE_RW(ads->info) = val;
40234
40235 checksum += i->link;
40236 - ACCESS_ONCE(ads->link) = i->link;
40237 + ACCESS_ONCE_RW(ads->link) = i->link;
40238
40239 checksum += i->buf_addr[0];
40240 - ACCESS_ONCE(ads->data0) = i->buf_addr[0];
40241 + ACCESS_ONCE_RW(ads->data0) = i->buf_addr[0];
40242 checksum += i->buf_addr[1];
40243 - ACCESS_ONCE(ads->data1) = i->buf_addr[1];
40244 + ACCESS_ONCE_RW(ads->data1) = i->buf_addr[1];
40245 checksum += i->buf_addr[2];
40246 - ACCESS_ONCE(ads->data2) = i->buf_addr[2];
40247 + ACCESS_ONCE_RW(ads->data2) = i->buf_addr[2];
40248 checksum += i->buf_addr[3];
40249 - ACCESS_ONCE(ads->data3) = i->buf_addr[3];
40250 + ACCESS_ONCE_RW(ads->data3) = i->buf_addr[3];
40251
40252 checksum += (val = (i->buf_len[0] << AR_BufLen_S) & AR_BufLen);
40253 - ACCESS_ONCE(ads->ctl3) = val;
40254 + ACCESS_ONCE_RW(ads->ctl3) = val;
40255 checksum += (val = (i->buf_len[1] << AR_BufLen_S) & AR_BufLen);
40256 - ACCESS_ONCE(ads->ctl5) = val;
40257 + ACCESS_ONCE_RW(ads->ctl5) = val;
40258 checksum += (val = (i->buf_len[2] << AR_BufLen_S) & AR_BufLen);
40259 - ACCESS_ONCE(ads->ctl7) = val;
40260 + ACCESS_ONCE_RW(ads->ctl7) = val;
40261 checksum += (val = (i->buf_len[3] << AR_BufLen_S) & AR_BufLen);
40262 - ACCESS_ONCE(ads->ctl9) = val;
40263 + ACCESS_ONCE_RW(ads->ctl9) = val;
40264
40265 checksum = (u16) (((checksum & 0xffff) + (checksum >> 16)) & 0xffff);
40266 - ACCESS_ONCE(ads->ctl10) = checksum;
40267 + ACCESS_ONCE_RW(ads->ctl10) = checksum;
40268
40269 if (i->is_first || i->is_last) {
40270 - ACCESS_ONCE(ads->ctl13) = set11nTries(i->rates, 0)
40271 + ACCESS_ONCE_RW(ads->ctl13) = set11nTries(i->rates, 0)
40272 | set11nTries(i->rates, 1)
40273 | set11nTries(i->rates, 2)
40274 | set11nTries(i->rates, 3)
40275 | (i->dur_update ? AR_DurUpdateEna : 0)
40276 | SM(0, AR_BurstDur);
40277
40278 - ACCESS_ONCE(ads->ctl14) = set11nRate(i->rates, 0)
40279 + ACCESS_ONCE_RW(ads->ctl14) = set11nRate(i->rates, 0)
40280 | set11nRate(i->rates, 1)
40281 | set11nRate(i->rates, 2)
40282 | set11nRate(i->rates, 3);
40283 } else {
40284 - ACCESS_ONCE(ads->ctl13) = 0;
40285 - ACCESS_ONCE(ads->ctl14) = 0;
40286 + ACCESS_ONCE_RW(ads->ctl13) = 0;
40287 + ACCESS_ONCE_RW(ads->ctl14) = 0;
40288 }
40289
40290 ads->ctl20 = 0;
40291 @@ -89,17 +89,17 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40292
40293 ctl17 = SM(i->keytype, AR_EncrType);
40294 if (!i->is_first) {
40295 - ACCESS_ONCE(ads->ctl11) = 0;
40296 - ACCESS_ONCE(ads->ctl12) = i->is_last ? 0 : AR_TxMore;
40297 - ACCESS_ONCE(ads->ctl15) = 0;
40298 - ACCESS_ONCE(ads->ctl16) = 0;
40299 - ACCESS_ONCE(ads->ctl17) = ctl17;
40300 - ACCESS_ONCE(ads->ctl18) = 0;
40301 - ACCESS_ONCE(ads->ctl19) = 0;
40302 + ACCESS_ONCE_RW(ads->ctl11) = 0;
40303 + ACCESS_ONCE_RW(ads->ctl12) = i->is_last ? 0 : AR_TxMore;
40304 + ACCESS_ONCE_RW(ads->ctl15) = 0;
40305 + ACCESS_ONCE_RW(ads->ctl16) = 0;
40306 + ACCESS_ONCE_RW(ads->ctl17) = ctl17;
40307 + ACCESS_ONCE_RW(ads->ctl18) = 0;
40308 + ACCESS_ONCE_RW(ads->ctl19) = 0;
40309 return;
40310 }
40311
40312 - ACCESS_ONCE(ads->ctl11) = (i->pkt_len & AR_FrameLen)
40313 + ACCESS_ONCE_RW(ads->ctl11) = (i->pkt_len & AR_FrameLen)
40314 | (i->flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
40315 | SM(i->txpower, AR_XmitPower)
40316 | (i->flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
40317 @@ -135,22 +135,22 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40318 val = (i->flags & ATH9K_TXDESC_PAPRD) >> ATH9K_TXDESC_PAPRD_S;
40319 ctl12 |= SM(val, AR_PAPRDChainMask);
40320
40321 - ACCESS_ONCE(ads->ctl12) = ctl12;
40322 - ACCESS_ONCE(ads->ctl17) = ctl17;
40323 + ACCESS_ONCE_RW(ads->ctl12) = ctl12;
40324 + ACCESS_ONCE_RW(ads->ctl17) = ctl17;
40325
40326 - ACCESS_ONCE(ads->ctl15) = set11nPktDurRTSCTS(i->rates, 0)
40327 + ACCESS_ONCE_RW(ads->ctl15) = set11nPktDurRTSCTS(i->rates, 0)
40328 | set11nPktDurRTSCTS(i->rates, 1);
40329
40330 - ACCESS_ONCE(ads->ctl16) = set11nPktDurRTSCTS(i->rates, 2)
40331 + ACCESS_ONCE_RW(ads->ctl16) = set11nPktDurRTSCTS(i->rates, 2)
40332 | set11nPktDurRTSCTS(i->rates, 3);
40333
40334 - ACCESS_ONCE(ads->ctl18) = set11nRateFlags(i->rates, 0)
40335 + ACCESS_ONCE_RW(ads->ctl18) = set11nRateFlags(i->rates, 0)
40336 | set11nRateFlags(i->rates, 1)
40337 | set11nRateFlags(i->rates, 2)
40338 | set11nRateFlags(i->rates, 3)
40339 | SM(i->rtscts_rate, AR_RTSCTSRate);
40340
40341 - ACCESS_ONCE(ads->ctl19) = AR_Not_Sounding;
40342 + ACCESS_ONCE_RW(ads->ctl19) = AR_Not_Sounding;
40343 }
40344
40345 static u16 ar9003_calc_ptr_chksum(struct ar9003_txc *ads)
40346 diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h
40347 index 784e81c..349e01e 100644
40348 --- a/drivers/net/wireless/ath/ath9k/hw.h
40349 +++ b/drivers/net/wireless/ath/ath9k/hw.h
40350 @@ -653,7 +653,7 @@ struct ath_hw_private_ops {
40351
40352 /* ANI */
40353 void (*ani_cache_ini_regs)(struct ath_hw *ah);
40354 -};
40355 +} __no_const;
40356
40357 /**
40358 * struct ath_spec_scan - parameters for Atheros spectral scan
40359 @@ -722,7 +722,7 @@ struct ath_hw_ops {
40360 struct ath_spec_scan *param);
40361 void (*spectral_scan_trigger)(struct ath_hw *ah);
40362 void (*spectral_scan_wait)(struct ath_hw *ah);
40363 -};
40364 +} __no_const;
40365
40366 struct ath_nf_limits {
40367 s16 max;
40368 diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c
40369 index c353b5f..62aaca2 100644
40370 --- a/drivers/net/wireless/iwlegacy/3945-mac.c
40371 +++ b/drivers/net/wireless/iwlegacy/3945-mac.c
40372 @@ -3639,7 +3639,9 @@ il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
40373 */
40374 if (il3945_mod_params.disable_hw_scan) {
40375 D_INFO("Disabling hw_scan\n");
40376 - il3945_mac_ops.hw_scan = NULL;
40377 + pax_open_kernel();
40378 + *(void **)&il3945_mac_ops.hw_scan = NULL;
40379 + pax_close_kernel();
40380 }
40381
40382 D_INFO("*** LOAD DRIVER ***\n");
40383 diff --git a/drivers/net/wireless/iwlwifi/dvm/debugfs.c b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
40384 index 81d4071..f2071ea 100644
40385 --- a/drivers/net/wireless/iwlwifi/dvm/debugfs.c
40386 +++ b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
40387 @@ -203,7 +203,7 @@ static ssize_t iwl_dbgfs_sram_write(struct file *file,
40388 {
40389 struct iwl_priv *priv = file->private_data;
40390 char buf[64];
40391 - int buf_size;
40392 + size_t buf_size;
40393 u32 offset, len;
40394
40395 memset(buf, 0, sizeof(buf));
40396 @@ -473,7 +473,7 @@ static ssize_t iwl_dbgfs_rx_handlers_write(struct file *file,
40397 struct iwl_priv *priv = file->private_data;
40398
40399 char buf[8];
40400 - int buf_size;
40401 + size_t buf_size;
40402 u32 reset_flag;
40403
40404 memset(buf, 0, sizeof(buf));
40405 @@ -554,7 +554,7 @@ static ssize_t iwl_dbgfs_disable_ht40_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 ht40;
40412
40413 memset(buf, 0, sizeof(buf));
40414 @@ -606,7 +606,7 @@ static ssize_t iwl_dbgfs_sleep_level_override_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 value;
40421
40422 memset(buf, 0, sizeof(buf));
40423 @@ -1871,7 +1871,7 @@ static ssize_t iwl_dbgfs_clear_ucode_statistics_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 clear;
40430
40431 memset(buf, 0, sizeof(buf));
40432 @@ -1916,7 +1916,7 @@ static ssize_t iwl_dbgfs_ucode_tracing_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 trace;
40439
40440 memset(buf, 0, sizeof(buf));
40441 @@ -1987,7 +1987,7 @@ static ssize_t iwl_dbgfs_missed_beacon_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 missed;
40448
40449 memset(buf, 0, sizeof(buf));
40450 @@ -2028,7 +2028,7 @@ static ssize_t iwl_dbgfs_plcp_delta_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 plcp;
40457
40458 memset(buf, 0, sizeof(buf));
40459 @@ -2088,7 +2088,7 @@ static ssize_t iwl_dbgfs_txfifo_flush_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 int flush;
40466
40467 memset(buf, 0, sizeof(buf));
40468 @@ -2178,7 +2178,7 @@ static ssize_t iwl_dbgfs_protection_mode_write(struct file *file,
40469
40470 struct iwl_priv *priv = file->private_data;
40471 char buf[8];
40472 - int buf_size;
40473 + size_t buf_size;
40474 int rts;
40475
40476 if (!priv->cfg->ht_params)
40477 @@ -2220,7 +2220,7 @@ static ssize_t iwl_dbgfs_echo_test_write(struct file *file,
40478 {
40479 struct iwl_priv *priv = file->private_data;
40480 char buf[8];
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 @@ -2256,7 +2256,7 @@ static ssize_t iwl_dbgfs_log_event_write(struct file *file,
40487 struct iwl_priv *priv = file->private_data;
40488 u32 event_log_flag;
40489 char buf[8];
40490 - int buf_size;
40491 + size_t buf_size;
40492
40493 /* check that the interface is up */
40494 if (!iwl_is_ready(priv))
40495 @@ -2310,7 +2310,7 @@ static ssize_t iwl_dbgfs_calib_disabled_write(struct file *file,
40496 struct iwl_priv *priv = file->private_data;
40497 char buf[8];
40498 u32 calib_disabled;
40499 - int buf_size;
40500 + size_t buf_size;
40501
40502 memset(buf, 0, sizeof(buf));
40503 buf_size = min(count, sizeof(buf) - 1);
40504 diff --git a/drivers/net/wireless/iwlwifi/pcie/trans.c b/drivers/net/wireless/iwlwifi/pcie/trans.c
40505 index 12c4f31..484d948 100644
40506 --- a/drivers/net/wireless/iwlwifi/pcie/trans.c
40507 +++ b/drivers/net/wireless/iwlwifi/pcie/trans.c
40508 @@ -1328,7 +1328,7 @@ static ssize_t iwl_dbgfs_interrupt_write(struct file *file,
40509 struct isr_statistics *isr_stats = &trans_pcie->isr_stats;
40510
40511 char buf[8];
40512 - int buf_size;
40513 + size_t buf_size;
40514 u32 reset_flag;
40515
40516 memset(buf, 0, sizeof(buf));
40517 @@ -1349,7 +1349,7 @@ static ssize_t iwl_dbgfs_csr_write(struct file *file,
40518 {
40519 struct iwl_trans *trans = file->private_data;
40520 char buf[8];
40521 - int buf_size;
40522 + size_t buf_size;
40523 int csr;
40524
40525 memset(buf, 0, sizeof(buf));
40526 diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
40527 index 2b49f48..14fc244 100644
40528 --- a/drivers/net/wireless/mac80211_hwsim.c
40529 +++ b/drivers/net/wireless/mac80211_hwsim.c
40530 @@ -2143,25 +2143,19 @@ static int __init init_mac80211_hwsim(void)
40531
40532 if (channels > 1) {
40533 hwsim_if_comb.num_different_channels = channels;
40534 - mac80211_hwsim_ops.hw_scan = mac80211_hwsim_hw_scan;
40535 - mac80211_hwsim_ops.cancel_hw_scan =
40536 - mac80211_hwsim_cancel_hw_scan;
40537 - mac80211_hwsim_ops.sw_scan_start = NULL;
40538 - mac80211_hwsim_ops.sw_scan_complete = NULL;
40539 - mac80211_hwsim_ops.remain_on_channel =
40540 - mac80211_hwsim_roc;
40541 - mac80211_hwsim_ops.cancel_remain_on_channel =
40542 - mac80211_hwsim_croc;
40543 - mac80211_hwsim_ops.add_chanctx =
40544 - mac80211_hwsim_add_chanctx;
40545 - mac80211_hwsim_ops.remove_chanctx =
40546 - mac80211_hwsim_remove_chanctx;
40547 - mac80211_hwsim_ops.change_chanctx =
40548 - mac80211_hwsim_change_chanctx;
40549 - mac80211_hwsim_ops.assign_vif_chanctx =
40550 - mac80211_hwsim_assign_vif_chanctx;
40551 - mac80211_hwsim_ops.unassign_vif_chanctx =
40552 - mac80211_hwsim_unassign_vif_chanctx;
40553 + pax_open_kernel();
40554 + *(void **)&mac80211_hwsim_ops.hw_scan = mac80211_hwsim_hw_scan;
40555 + *(void **)&mac80211_hwsim_ops.cancel_hw_scan = mac80211_hwsim_cancel_hw_scan;
40556 + *(void **)&mac80211_hwsim_ops.sw_scan_start = NULL;
40557 + *(void **)&mac80211_hwsim_ops.sw_scan_complete = NULL;
40558 + *(void **)&mac80211_hwsim_ops.remain_on_channel = mac80211_hwsim_roc;
40559 + *(void **)&mac80211_hwsim_ops.cancel_remain_on_channel = mac80211_hwsim_croc;
40560 + *(void **)&mac80211_hwsim_ops.add_chanctx = mac80211_hwsim_add_chanctx;
40561 + *(void **)&mac80211_hwsim_ops.remove_chanctx = mac80211_hwsim_remove_chanctx;
40562 + *(void **)&mac80211_hwsim_ops.change_chanctx = mac80211_hwsim_change_chanctx;
40563 + *(void **)&mac80211_hwsim_ops.assign_vif_chanctx = mac80211_hwsim_assign_vif_chanctx;
40564 + *(void **)&mac80211_hwsim_ops.unassign_vif_chanctx = mac80211_hwsim_unassign_vif_chanctx;
40565 + pax_close_kernel();
40566 }
40567
40568 spin_lock_init(&hwsim_radio_lock);
40569 diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c
40570 index 525fd75..6c9f791 100644
40571 --- a/drivers/net/wireless/rndis_wlan.c
40572 +++ b/drivers/net/wireless/rndis_wlan.c
40573 @@ -1238,7 +1238,7 @@ static int set_rts_threshold(struct usbnet *usbdev, u32 rts_threshold)
40574
40575 netdev_dbg(usbdev->net, "%s(): %i\n", __func__, rts_threshold);
40576
40577 - if (rts_threshold < 0 || rts_threshold > 2347)
40578 + if (rts_threshold > 2347)
40579 rts_threshold = 2347;
40580
40581 tmp = cpu_to_le32(rts_threshold);
40582 diff --git a/drivers/net/wireless/rt2x00/rt2x00.h b/drivers/net/wireless/rt2x00/rt2x00.h
40583 index 086abb4..8279c30 100644
40584 --- a/drivers/net/wireless/rt2x00/rt2x00.h
40585 +++ b/drivers/net/wireless/rt2x00/rt2x00.h
40586 @@ -396,7 +396,7 @@ struct rt2x00_intf {
40587 * for hardware which doesn't support hardware
40588 * sequence counting.
40589 */
40590 - atomic_t seqno;
40591 + atomic_unchecked_t seqno;
40592 };
40593
40594 static inline struct rt2x00_intf* vif_to_intf(struct ieee80211_vif *vif)
40595 diff --git a/drivers/net/wireless/rt2x00/rt2x00queue.c b/drivers/net/wireless/rt2x00/rt2x00queue.c
40596 index 4d91795..62fccff 100644
40597 --- a/drivers/net/wireless/rt2x00/rt2x00queue.c
40598 +++ b/drivers/net/wireless/rt2x00/rt2x00queue.c
40599 @@ -251,9 +251,9 @@ static void rt2x00queue_create_tx_descriptor_seq(struct rt2x00_dev *rt2x00dev,
40600 * sequence counter given by mac80211.
40601 */
40602 if (test_bit(ENTRY_TXD_FIRST_FRAGMENT, &txdesc->flags))
40603 - seqno = atomic_add_return(0x10, &intf->seqno);
40604 + seqno = atomic_add_return_unchecked(0x10, &intf->seqno);
40605 else
40606 - seqno = atomic_read(&intf->seqno);
40607 + seqno = atomic_read_unchecked(&intf->seqno);
40608
40609 hdr->seq_ctrl &= cpu_to_le16(IEEE80211_SCTL_FRAG);
40610 hdr->seq_ctrl |= cpu_to_le16(seqno);
40611 diff --git a/drivers/net/wireless/ti/wl1251/sdio.c b/drivers/net/wireless/ti/wl1251/sdio.c
40612 index e57ee48..541cf6c 100644
40613 --- a/drivers/net/wireless/ti/wl1251/sdio.c
40614 +++ b/drivers/net/wireless/ti/wl1251/sdio.c
40615 @@ -269,13 +269,17 @@ static int wl1251_sdio_probe(struct sdio_func *func,
40616
40617 irq_set_irq_type(wl->irq, IRQ_TYPE_EDGE_RISING);
40618
40619 - wl1251_sdio_ops.enable_irq = wl1251_enable_line_irq;
40620 - wl1251_sdio_ops.disable_irq = wl1251_disable_line_irq;
40621 + pax_open_kernel();
40622 + *(void **)&wl1251_sdio_ops.enable_irq = wl1251_enable_line_irq;
40623 + *(void **)&wl1251_sdio_ops.disable_irq = wl1251_disable_line_irq;
40624 + pax_close_kernel();
40625
40626 wl1251_info("using dedicated interrupt line");
40627 } else {
40628 - wl1251_sdio_ops.enable_irq = wl1251_sdio_enable_irq;
40629 - wl1251_sdio_ops.disable_irq = wl1251_sdio_disable_irq;
40630 + pax_open_kernel();
40631 + *(void **)&wl1251_sdio_ops.enable_irq = wl1251_sdio_enable_irq;
40632 + *(void **)&wl1251_sdio_ops.disable_irq = wl1251_sdio_disable_irq;
40633 + pax_close_kernel();
40634
40635 wl1251_info("using SDIO interrupt");
40636 }
40637 diff --git a/drivers/net/wireless/ti/wl12xx/main.c b/drivers/net/wireless/ti/wl12xx/main.c
40638 index 09694e3..24ccec7 100644
40639 --- a/drivers/net/wireless/ti/wl12xx/main.c
40640 +++ b/drivers/net/wireless/ti/wl12xx/main.c
40641 @@ -656,7 +656,9 @@ static int wl12xx_identify_chip(struct wl1271 *wl)
40642 sizeof(wl->conf.mem));
40643
40644 /* read data preparation is only needed by wl127x */
40645 - wl->ops->prepare_read = wl127x_prepare_read;
40646 + pax_open_kernel();
40647 + *(void **)&wl->ops->prepare_read = wl127x_prepare_read;
40648 + pax_close_kernel();
40649
40650 wlcore_set_min_fw_ver(wl, WL127X_CHIP_VER,
40651 WL127X_IFTYPE_SR_VER, WL127X_MAJOR_SR_VER,
40652 @@ -681,7 +683,9 @@ static int wl12xx_identify_chip(struct wl1271 *wl)
40653 sizeof(wl->conf.mem));
40654
40655 /* read data preparation is only needed by wl127x */
40656 - wl->ops->prepare_read = wl127x_prepare_read;
40657 + pax_open_kernel();
40658 + *(void **)&wl->ops->prepare_read = wl127x_prepare_read;
40659 + pax_close_kernel();
40660
40661 wlcore_set_min_fw_ver(wl, WL127X_CHIP_VER,
40662 WL127X_IFTYPE_SR_VER, WL127X_MAJOR_SR_VER,
40663 diff --git a/drivers/net/wireless/ti/wl18xx/main.c b/drivers/net/wireless/ti/wl18xx/main.c
40664 index da3ef1b..4790b95 100644
40665 --- a/drivers/net/wireless/ti/wl18xx/main.c
40666 +++ b/drivers/net/wireless/ti/wl18xx/main.c
40667 @@ -1664,8 +1664,10 @@ static int wl18xx_setup(struct wl1271 *wl)
40668 }
40669
40670 if (!checksum_param) {
40671 - wl18xx_ops.set_rx_csum = NULL;
40672 - wl18xx_ops.init_vif = NULL;
40673 + pax_open_kernel();
40674 + *(void **)&wl18xx_ops.set_rx_csum = NULL;
40675 + *(void **)&wl18xx_ops.init_vif = NULL;
40676 + pax_close_kernel();
40677 }
40678
40679 /* Enable 11a Band only if we have 5G antennas */
40680 diff --git a/drivers/net/wireless/zd1211rw/zd_usb.c b/drivers/net/wireless/zd1211rw/zd_usb.c
40681 index 7ef0b4a..ff65c28 100644
40682 --- a/drivers/net/wireless/zd1211rw/zd_usb.c
40683 +++ b/drivers/net/wireless/zd1211rw/zd_usb.c
40684 @@ -386,7 +386,7 @@ static inline void handle_regs_int(struct urb *urb)
40685 {
40686 struct zd_usb *usb = urb->context;
40687 struct zd_usb_interrupt *intr = &usb->intr;
40688 - int len;
40689 + unsigned int len;
40690 u16 int_num;
40691
40692 ZD_ASSERT(in_interrupt());
40693 diff --git a/drivers/oprofile/buffer_sync.c b/drivers/oprofile/buffer_sync.c
40694 index d93b2b6..ae50401 100644
40695 --- a/drivers/oprofile/buffer_sync.c
40696 +++ b/drivers/oprofile/buffer_sync.c
40697 @@ -332,7 +332,7 @@ static void add_data(struct op_entry *entry, struct mm_struct *mm)
40698 if (cookie == NO_COOKIE)
40699 offset = pc;
40700 if (cookie == INVALID_COOKIE) {
40701 - atomic_inc(&oprofile_stats.sample_lost_no_mapping);
40702 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mapping);
40703 offset = pc;
40704 }
40705 if (cookie != last_cookie) {
40706 @@ -376,14 +376,14 @@ add_sample(struct mm_struct *mm, struct op_sample *s, int in_kernel)
40707 /* add userspace sample */
40708
40709 if (!mm) {
40710 - atomic_inc(&oprofile_stats.sample_lost_no_mm);
40711 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mm);
40712 return 0;
40713 }
40714
40715 cookie = lookup_dcookie(mm, s->eip, &offset);
40716
40717 if (cookie == INVALID_COOKIE) {
40718 - atomic_inc(&oprofile_stats.sample_lost_no_mapping);
40719 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mapping);
40720 return 0;
40721 }
40722
40723 @@ -552,7 +552,7 @@ void sync_buffer(int cpu)
40724 /* ignore backtraces if failed to add a sample */
40725 if (state == sb_bt_start) {
40726 state = sb_bt_ignore;
40727 - atomic_inc(&oprofile_stats.bt_lost_no_mapping);
40728 + atomic_inc_unchecked(&oprofile_stats.bt_lost_no_mapping);
40729 }
40730 }
40731 release_mm(mm);
40732 diff --git a/drivers/oprofile/event_buffer.c b/drivers/oprofile/event_buffer.c
40733 index c0cc4e7..44d4e54 100644
40734 --- a/drivers/oprofile/event_buffer.c
40735 +++ b/drivers/oprofile/event_buffer.c
40736 @@ -53,7 +53,7 @@ void add_event_entry(unsigned long value)
40737 }
40738
40739 if (buffer_pos == buffer_size) {
40740 - atomic_inc(&oprofile_stats.event_lost_overflow);
40741 + atomic_inc_unchecked(&oprofile_stats.event_lost_overflow);
40742 return;
40743 }
40744
40745 diff --git a/drivers/oprofile/oprof.c b/drivers/oprofile/oprof.c
40746 index ed2c3ec..deda85a 100644
40747 --- a/drivers/oprofile/oprof.c
40748 +++ b/drivers/oprofile/oprof.c
40749 @@ -110,7 +110,7 @@ static void switch_worker(struct work_struct *work)
40750 if (oprofile_ops.switch_events())
40751 return;
40752
40753 - atomic_inc(&oprofile_stats.multiplex_counter);
40754 + atomic_inc_unchecked(&oprofile_stats.multiplex_counter);
40755 start_switch_worker();
40756 }
40757
40758 diff --git a/drivers/oprofile/oprofile_files.c b/drivers/oprofile/oprofile_files.c
40759 index 84a208d..d61b0a1 100644
40760 --- a/drivers/oprofile/oprofile_files.c
40761 +++ b/drivers/oprofile/oprofile_files.c
40762 @@ -27,7 +27,7 @@ unsigned long oprofile_time_slice;
40763
40764 #ifdef CONFIG_OPROFILE_EVENT_MULTIPLEX
40765
40766 -static ssize_t timeout_read(struct file *file, char __user *buf,
40767 +static ssize_t __intentional_overflow(-1) timeout_read(struct file *file, char __user *buf,
40768 size_t count, loff_t *offset)
40769 {
40770 return oprofilefs_ulong_to_user(jiffies_to_msecs(oprofile_time_slice),
40771 diff --git a/drivers/oprofile/oprofile_stats.c b/drivers/oprofile/oprofile_stats.c
40772 index 917d28e..d62d981 100644
40773 --- a/drivers/oprofile/oprofile_stats.c
40774 +++ b/drivers/oprofile/oprofile_stats.c
40775 @@ -30,11 +30,11 @@ void oprofile_reset_stats(void)
40776 cpu_buf->sample_invalid_eip = 0;
40777 }
40778
40779 - atomic_set(&oprofile_stats.sample_lost_no_mm, 0);
40780 - atomic_set(&oprofile_stats.sample_lost_no_mapping, 0);
40781 - atomic_set(&oprofile_stats.event_lost_overflow, 0);
40782 - atomic_set(&oprofile_stats.bt_lost_no_mapping, 0);
40783 - atomic_set(&oprofile_stats.multiplex_counter, 0);
40784 + atomic_set_unchecked(&oprofile_stats.sample_lost_no_mm, 0);
40785 + atomic_set_unchecked(&oprofile_stats.sample_lost_no_mapping, 0);
40786 + atomic_set_unchecked(&oprofile_stats.event_lost_overflow, 0);
40787 + atomic_set_unchecked(&oprofile_stats.bt_lost_no_mapping, 0);
40788 + atomic_set_unchecked(&oprofile_stats.multiplex_counter, 0);
40789 }
40790
40791
40792 diff --git a/drivers/oprofile/oprofile_stats.h b/drivers/oprofile/oprofile_stats.h
40793 index 38b6fc0..b5cbfce 100644
40794 --- a/drivers/oprofile/oprofile_stats.h
40795 +++ b/drivers/oprofile/oprofile_stats.h
40796 @@ -13,11 +13,11 @@
40797 #include <linux/atomic.h>
40798
40799 struct oprofile_stat_struct {
40800 - atomic_t sample_lost_no_mm;
40801 - atomic_t sample_lost_no_mapping;
40802 - atomic_t bt_lost_no_mapping;
40803 - atomic_t event_lost_overflow;
40804 - atomic_t multiplex_counter;
40805 + atomic_unchecked_t sample_lost_no_mm;
40806 + atomic_unchecked_t sample_lost_no_mapping;
40807 + atomic_unchecked_t bt_lost_no_mapping;
40808 + atomic_unchecked_t event_lost_overflow;
40809 + atomic_unchecked_t multiplex_counter;
40810 };
40811
40812 extern struct oprofile_stat_struct oprofile_stats;
40813 diff --git a/drivers/oprofile/oprofilefs.c b/drivers/oprofile/oprofilefs.c
40814 index 7c12d9c..558bf3bb 100644
40815 --- a/drivers/oprofile/oprofilefs.c
40816 +++ b/drivers/oprofile/oprofilefs.c
40817 @@ -190,7 +190,7 @@ static const struct file_operations atomic_ro_fops = {
40818
40819
40820 int oprofilefs_create_ro_atomic(struct super_block *sb, struct dentry *root,
40821 - char const *name, atomic_t *val)
40822 + char const *name, atomic_unchecked_t *val)
40823 {
40824 return __oprofilefs_create_file(sb, root, name,
40825 &atomic_ro_fops, 0444, val);
40826 diff --git a/drivers/oprofile/timer_int.c b/drivers/oprofile/timer_int.c
40827 index 93404f7..4a313d8 100644
40828 --- a/drivers/oprofile/timer_int.c
40829 +++ b/drivers/oprofile/timer_int.c
40830 @@ -93,7 +93,7 @@ static int __cpuinit oprofile_cpu_notify(struct notifier_block *self,
40831 return NOTIFY_OK;
40832 }
40833
40834 -static struct notifier_block __refdata oprofile_cpu_notifier = {
40835 +static struct notifier_block oprofile_cpu_notifier = {
40836 .notifier_call = oprofile_cpu_notify,
40837 };
40838
40839 diff --git a/drivers/parport/procfs.c b/drivers/parport/procfs.c
40840 index 3f56bc0..707d642 100644
40841 --- a/drivers/parport/procfs.c
40842 +++ b/drivers/parport/procfs.c
40843 @@ -64,7 +64,7 @@ static int do_active_device(ctl_table *table, int write,
40844
40845 *ppos += len;
40846
40847 - return copy_to_user(result, buffer, len) ? -EFAULT : 0;
40848 + return (len > sizeof buffer || copy_to_user(result, buffer, len)) ? -EFAULT : 0;
40849 }
40850
40851 #ifdef CONFIG_PARPORT_1284
40852 @@ -106,7 +106,7 @@ static int do_autoprobe(ctl_table *table, int write,
40853
40854 *ppos += len;
40855
40856 - return copy_to_user (result, buffer, len) ? -EFAULT : 0;
40857 + return (len > sizeof buffer || copy_to_user (result, buffer, len)) ? -EFAULT : 0;
40858 }
40859 #endif /* IEEE1284.3 support. */
40860
40861 diff --git a/drivers/pci/hotplug/acpiphp_ibm.c b/drivers/pci/hotplug/acpiphp_ibm.c
40862 index c35e8ad..fc33beb 100644
40863 --- a/drivers/pci/hotplug/acpiphp_ibm.c
40864 +++ b/drivers/pci/hotplug/acpiphp_ibm.c
40865 @@ -464,7 +464,9 @@ static int __init ibm_acpiphp_init(void)
40866 goto init_cleanup;
40867 }
40868
40869 - ibm_apci_table_attr.size = ibm_get_table_from_acpi(NULL);
40870 + pax_open_kernel();
40871 + *(size_t *)&ibm_apci_table_attr.size = ibm_get_table_from_acpi(NULL);
40872 + pax_close_kernel();
40873 retval = sysfs_create_bin_file(sysdir, &ibm_apci_table_attr);
40874
40875 return retval;
40876 diff --git a/drivers/pci/hotplug/cpcihp_generic.c b/drivers/pci/hotplug/cpcihp_generic.c
40877 index a6a71c4..c91097b 100644
40878 --- a/drivers/pci/hotplug/cpcihp_generic.c
40879 +++ b/drivers/pci/hotplug/cpcihp_generic.c
40880 @@ -73,7 +73,6 @@ static u16 port;
40881 static unsigned int enum_bit;
40882 static u8 enum_mask;
40883
40884 -static struct cpci_hp_controller_ops generic_hpc_ops;
40885 static struct cpci_hp_controller generic_hpc;
40886
40887 static int __init validate_parameters(void)
40888 @@ -139,6 +138,10 @@ static int query_enum(void)
40889 return ((value & enum_mask) == enum_mask);
40890 }
40891
40892 +static struct cpci_hp_controller_ops generic_hpc_ops = {
40893 + .query_enum = query_enum,
40894 +};
40895 +
40896 static int __init cpcihp_generic_init(void)
40897 {
40898 int status;
40899 @@ -165,7 +168,6 @@ static int __init cpcihp_generic_init(void)
40900 pci_dev_put(dev);
40901
40902 memset(&generic_hpc, 0, sizeof (struct cpci_hp_controller));
40903 - generic_hpc_ops.query_enum = query_enum;
40904 generic_hpc.ops = &generic_hpc_ops;
40905
40906 status = cpci_hp_register_controller(&generic_hpc);
40907 diff --git a/drivers/pci/hotplug/cpcihp_zt5550.c b/drivers/pci/hotplug/cpcihp_zt5550.c
40908 index 449b4bb..257e2e8 100644
40909 --- a/drivers/pci/hotplug/cpcihp_zt5550.c
40910 +++ b/drivers/pci/hotplug/cpcihp_zt5550.c
40911 @@ -59,7 +59,6 @@
40912 /* local variables */
40913 static bool debug;
40914 static bool poll;
40915 -static struct cpci_hp_controller_ops zt5550_hpc_ops;
40916 static struct cpci_hp_controller zt5550_hpc;
40917
40918 /* Primary cPCI bus bridge device */
40919 @@ -205,6 +204,10 @@ static int zt5550_hc_disable_irq(void)
40920 return 0;
40921 }
40922
40923 +static struct cpci_hp_controller_ops zt5550_hpc_ops = {
40924 + .query_enum = zt5550_hc_query_enum,
40925 +};
40926 +
40927 static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
40928 {
40929 int status;
40930 @@ -216,16 +219,17 @@ static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id
40931 dbg("returned from zt5550_hc_config");
40932
40933 memset(&zt5550_hpc, 0, sizeof (struct cpci_hp_controller));
40934 - zt5550_hpc_ops.query_enum = zt5550_hc_query_enum;
40935 zt5550_hpc.ops = &zt5550_hpc_ops;
40936 if(!poll) {
40937 zt5550_hpc.irq = hc_dev->irq;
40938 zt5550_hpc.irq_flags = IRQF_SHARED;
40939 zt5550_hpc.dev_id = hc_dev;
40940
40941 - zt5550_hpc_ops.enable_irq = zt5550_hc_enable_irq;
40942 - zt5550_hpc_ops.disable_irq = zt5550_hc_disable_irq;
40943 - zt5550_hpc_ops.check_irq = zt5550_hc_check_irq;
40944 + pax_open_kernel();
40945 + *(void **)&zt5550_hpc_ops.enable_irq = zt5550_hc_enable_irq;
40946 + *(void **)&zt5550_hpc_ops.disable_irq = zt5550_hc_disable_irq;
40947 + *(void **)&zt5550_hpc_ops.check_irq = zt5550_hc_check_irq;
40948 + pax_open_kernel();
40949 } else {
40950 info("using ENUM# polling mode");
40951 }
40952 diff --git a/drivers/pci/hotplug/cpqphp_nvram.c b/drivers/pci/hotplug/cpqphp_nvram.c
40953 index 76ba8a1..20ca857 100644
40954 --- a/drivers/pci/hotplug/cpqphp_nvram.c
40955 +++ b/drivers/pci/hotplug/cpqphp_nvram.c
40956 @@ -428,9 +428,13 @@ static u32 store_HRT (void __iomem *rom_start)
40957
40958 void compaq_nvram_init (void __iomem *rom_start)
40959 {
40960 +
40961 +#ifndef CONFIG_PAX_KERNEXEC
40962 if (rom_start) {
40963 compaq_int15_entry_point = (rom_start + ROM_INT15_PHY_ADDR - ROM_PHY_ADDR);
40964 }
40965 +#endif
40966 +
40967 dbg("int15 entry = %p\n", compaq_int15_entry_point);
40968
40969 /* initialize our int15 lock */
40970 diff --git a/drivers/pci/hotplug/pci_hotplug_core.c b/drivers/pci/hotplug/pci_hotplug_core.c
40971 index 202f4a9..8ee47d0 100644
40972 --- a/drivers/pci/hotplug/pci_hotplug_core.c
40973 +++ b/drivers/pci/hotplug/pci_hotplug_core.c
40974 @@ -448,8 +448,10 @@ int __pci_hp_register(struct hotplug_slot *slot, struct pci_bus *bus,
40975 return -EINVAL;
40976 }
40977
40978 - slot->ops->owner = owner;
40979 - slot->ops->mod_name = mod_name;
40980 + pax_open_kernel();
40981 + *(struct module **)&slot->ops->owner = owner;
40982 + *(const char **)&slot->ops->mod_name = mod_name;
40983 + pax_close_kernel();
40984
40985 mutex_lock(&pci_hp_mutex);
40986 /*
40987 diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c
40988 index 7d72c5e..edce02c 100644
40989 --- a/drivers/pci/hotplug/pciehp_core.c
40990 +++ b/drivers/pci/hotplug/pciehp_core.c
40991 @@ -91,7 +91,7 @@ static int init_slot(struct controller *ctrl)
40992 struct slot *slot = ctrl->slot;
40993 struct hotplug_slot *hotplug = NULL;
40994 struct hotplug_slot_info *info = NULL;
40995 - struct hotplug_slot_ops *ops = NULL;
40996 + hotplug_slot_ops_no_const *ops = NULL;
40997 char name[SLOT_NAME_SIZE];
40998 int retval = -ENOMEM;
40999
41000 diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
41001 index 9c6e9bb..2916736 100644
41002 --- a/drivers/pci/pci-sysfs.c
41003 +++ b/drivers/pci/pci-sysfs.c
41004 @@ -1071,7 +1071,7 @@ static int pci_create_attr(struct pci_dev *pdev, int num, int write_combine)
41005 {
41006 /* allocate attribute structure, piggyback attribute name */
41007 int name_len = write_combine ? 13 : 10;
41008 - struct bin_attribute *res_attr;
41009 + bin_attribute_no_const *res_attr;
41010 int retval;
41011
41012 res_attr = kzalloc(sizeof(*res_attr) + name_len, GFP_ATOMIC);
41013 @@ -1256,7 +1256,7 @@ static struct device_attribute reset_attr = __ATTR(reset, 0200, NULL, reset_stor
41014 static int pci_create_capabilities_sysfs(struct pci_dev *dev)
41015 {
41016 int retval;
41017 - struct bin_attribute *attr;
41018 + bin_attribute_no_const *attr;
41019
41020 /* If the device has VPD, try to expose it in sysfs. */
41021 if (dev->vpd) {
41022 @@ -1303,7 +1303,7 @@ int __must_check pci_create_sysfs_dev_files (struct pci_dev *pdev)
41023 {
41024 int retval;
41025 int rom_size = 0;
41026 - struct bin_attribute *attr;
41027 + bin_attribute_no_const *attr;
41028
41029 if (!sysfs_initialized)
41030 return -EACCES;
41031 diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
41032 index 7346ee6..41520eb 100644
41033 --- a/drivers/pci/pci.h
41034 +++ b/drivers/pci/pci.h
41035 @@ -93,7 +93,7 @@ struct pci_vpd_ops {
41036 struct pci_vpd {
41037 unsigned int len;
41038 const struct pci_vpd_ops *ops;
41039 - struct bin_attribute *attr; /* descriptor for sysfs VPD entry */
41040 + bin_attribute_no_const *attr; /* descriptor for sysfs VPD entry */
41041 };
41042
41043 extern int pci_vpd_pci22_init(struct pci_dev *dev);
41044 diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c
41045 index d320df6..ca9a8f6 100644
41046 --- a/drivers/pci/pcie/aspm.c
41047 +++ b/drivers/pci/pcie/aspm.c
41048 @@ -27,9 +27,9 @@
41049 #define MODULE_PARAM_PREFIX "pcie_aspm."
41050
41051 /* Note: those are not register definitions */
41052 -#define ASPM_STATE_L0S_UP (1) /* Upstream direction L0s state */
41053 -#define ASPM_STATE_L0S_DW (2) /* Downstream direction L0s state */
41054 -#define ASPM_STATE_L1 (4) /* L1 state */
41055 +#define ASPM_STATE_L0S_UP (1U) /* Upstream direction L0s state */
41056 +#define ASPM_STATE_L0S_DW (2U) /* Downstream direction L0s state */
41057 +#define ASPM_STATE_L1 (4U) /* L1 state */
41058 #define ASPM_STATE_L0S (ASPM_STATE_L0S_UP | ASPM_STATE_L0S_DW)
41059 #define ASPM_STATE_ALL (ASPM_STATE_L0S | ASPM_STATE_L1)
41060
41061 diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
41062 index 5427787..8df273b 100644
41063 --- a/drivers/pci/probe.c
41064 +++ b/drivers/pci/probe.c
41065 @@ -173,7 +173,7 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type,
41066 struct pci_bus_region region;
41067 bool bar_too_big = false, bar_disabled = false;
41068
41069 - mask = type ? PCI_ROM_ADDRESS_MASK : ~0;
41070 + mask = type ? (u32)PCI_ROM_ADDRESS_MASK : ~0;
41071
41072 /* No printks while decoding is disabled! */
41073 if (!dev->mmio_always_on) {
41074 diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c
41075 index 0b00947..64f7c0a 100644
41076 --- a/drivers/pci/proc.c
41077 +++ b/drivers/pci/proc.c
41078 @@ -465,7 +465,16 @@ static const struct file_operations proc_bus_pci_dev_operations = {
41079 static int __init pci_proc_init(void)
41080 {
41081 struct pci_dev *dev = NULL;
41082 +
41083 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
41084 +#ifdef CONFIG_GRKERNSEC_PROC_USER
41085 + proc_bus_pci_dir = proc_mkdir_mode("bus/pci", S_IRUSR | S_IXUSR, NULL);
41086 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
41087 + proc_bus_pci_dir = proc_mkdir_mode("bus/pci", S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP, NULL);
41088 +#endif
41089 +#else
41090 proc_bus_pci_dir = proc_mkdir("bus/pci", NULL);
41091 +#endif
41092 proc_create("devices", 0, proc_bus_pci_dir,
41093 &proc_bus_pci_dev_operations);
41094 proc_initialized = 1;
41095 diff --git a/drivers/platform/x86/chromeos_laptop.c b/drivers/platform/x86/chromeos_laptop.c
41096 index 3e5b4497..dcdfb70 100644
41097 --- a/drivers/platform/x86/chromeos_laptop.c
41098 +++ b/drivers/platform/x86/chromeos_laptop.c
41099 @@ -301,7 +301,7 @@ static int __init setup_tsl2563_als(const struct dmi_system_id *id)
41100 return 0;
41101 }
41102
41103 -static struct dmi_system_id __initdata chromeos_laptop_dmi_table[] = {
41104 +static struct dmi_system_id __initconst chromeos_laptop_dmi_table[] = {
41105 {
41106 .ident = "Samsung Series 5 550 - Touchpad",
41107 .matches = {
41108 diff --git a/drivers/platform/x86/msi-laptop.c b/drivers/platform/x86/msi-laptop.c
41109 index 6b22938..bc9700e 100644
41110 --- a/drivers/platform/x86/msi-laptop.c
41111 +++ b/drivers/platform/x86/msi-laptop.c
41112 @@ -1000,12 +1000,14 @@ static int __init load_scm_model_init(struct platform_device *sdev)
41113
41114 if (!quirks->ec_read_only) {
41115 /* allow userland write sysfs file */
41116 - dev_attr_bluetooth.store = store_bluetooth;
41117 - dev_attr_wlan.store = store_wlan;
41118 - dev_attr_threeg.store = store_threeg;
41119 - dev_attr_bluetooth.attr.mode |= S_IWUSR;
41120 - dev_attr_wlan.attr.mode |= S_IWUSR;
41121 - dev_attr_threeg.attr.mode |= S_IWUSR;
41122 + pax_open_kernel();
41123 + *(void **)&dev_attr_bluetooth.store = store_bluetooth;
41124 + *(void **)&dev_attr_wlan.store = store_wlan;
41125 + *(void **)&dev_attr_threeg.store = store_threeg;
41126 + *(umode_t *)&dev_attr_bluetooth.attr.mode |= S_IWUSR;
41127 + *(umode_t *)&dev_attr_wlan.attr.mode |= S_IWUSR;
41128 + *(umode_t *)&dev_attr_threeg.attr.mode |= S_IWUSR;
41129 + pax_close_kernel();
41130 }
41131
41132 /* disable hardware control by fn key */
41133 diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
41134 index 14d4dce..b129917 100644
41135 --- a/drivers/platform/x86/sony-laptop.c
41136 +++ b/drivers/platform/x86/sony-laptop.c
41137 @@ -2465,7 +2465,7 @@ static void sony_nc_gfx_switch_cleanup(struct platform_device *pd)
41138 }
41139
41140 /* High speed charging function */
41141 -static struct device_attribute *hsc_handle;
41142 +static device_attribute_no_const *hsc_handle;
41143
41144 static ssize_t sony_nc_highspeed_charging_store(struct device *dev,
41145 struct device_attribute *attr,
41146 diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
41147 index edec135..59a24a3 100644
41148 --- a/drivers/platform/x86/thinkpad_acpi.c
41149 +++ b/drivers/platform/x86/thinkpad_acpi.c
41150 @@ -2093,7 +2093,7 @@ static int hotkey_mask_get(void)
41151 return 0;
41152 }
41153
41154 -void static hotkey_mask_warn_incomplete_mask(void)
41155 +static void hotkey_mask_warn_incomplete_mask(void)
41156 {
41157 /* log only what the user can fix... */
41158 const u32 wantedmask = hotkey_driver_mask &
41159 @@ -2324,11 +2324,6 @@ static void hotkey_read_nvram(struct tp_nvram_state *n, const u32 m)
41160 }
41161 }
41162
41163 -static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41164 - struct tp_nvram_state *newn,
41165 - const u32 event_mask)
41166 -{
41167 -
41168 #define TPACPI_COMPARE_KEY(__scancode, __member) \
41169 do { \
41170 if ((event_mask & (1 << __scancode)) && \
41171 @@ -2342,36 +2337,42 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41172 tpacpi_hotkey_send_key(__scancode); \
41173 } while (0)
41174
41175 - void issue_volchange(const unsigned int oldvol,
41176 - const unsigned int newvol)
41177 - {
41178 - unsigned int i = oldvol;
41179 +static void issue_volchange(const unsigned int oldvol,
41180 + const unsigned int newvol,
41181 + const u32 event_mask)
41182 +{
41183 + unsigned int i = oldvol;
41184
41185 - while (i > newvol) {
41186 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEDOWN);
41187 - i--;
41188 - }
41189 - while (i < newvol) {
41190 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
41191 - i++;
41192 - }
41193 + while (i > newvol) {
41194 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEDOWN);
41195 + i--;
41196 }
41197 + while (i < newvol) {
41198 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
41199 + i++;
41200 + }
41201 +}
41202
41203 - void issue_brightnesschange(const unsigned int oldbrt,
41204 - const unsigned int newbrt)
41205 - {
41206 - unsigned int i = oldbrt;
41207 +static void issue_brightnesschange(const unsigned int oldbrt,
41208 + const unsigned int newbrt,
41209 + const u32 event_mask)
41210 +{
41211 + unsigned int i = oldbrt;
41212
41213 - while (i > newbrt) {
41214 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNEND);
41215 - i--;
41216 - }
41217 - while (i < newbrt) {
41218 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
41219 - i++;
41220 - }
41221 + while (i > newbrt) {
41222 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNEND);
41223 + i--;
41224 + }
41225 + while (i < newbrt) {
41226 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
41227 + i++;
41228 }
41229 +}
41230
41231 +static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41232 + struct tp_nvram_state *newn,
41233 + const u32 event_mask)
41234 +{
41235 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_THINKPAD, thinkpad_toggle);
41236 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNSPACE, zoom_toggle);
41237 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNF7, display_toggle);
41238 @@ -2405,7 +2406,7 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41239 oldn->volume_level != newn->volume_level) {
41240 /* recently muted, or repeated mute keypress, or
41241 * multiple presses ending in mute */
41242 - issue_volchange(oldn->volume_level, newn->volume_level);
41243 + issue_volchange(oldn->volume_level, newn->volume_level, event_mask);
41244 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_MUTE);
41245 }
41246 } else {
41247 @@ -2415,7 +2416,7 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41248 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
41249 }
41250 if (oldn->volume_level != newn->volume_level) {
41251 - issue_volchange(oldn->volume_level, newn->volume_level);
41252 + issue_volchange(oldn->volume_level, newn->volume_level, event_mask);
41253 } else if (oldn->volume_toggle != newn->volume_toggle) {
41254 /* repeated vol up/down keypress at end of scale ? */
41255 if (newn->volume_level == 0)
41256 @@ -2428,7 +2429,8 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41257 /* handle brightness */
41258 if (oldn->brightness_level != newn->brightness_level) {
41259 issue_brightnesschange(oldn->brightness_level,
41260 - newn->brightness_level);
41261 + newn->brightness_level,
41262 + event_mask);
41263 } else if (oldn->brightness_toggle != newn->brightness_toggle) {
41264 /* repeated key presses that didn't change state */
41265 if (newn->brightness_level == 0)
41266 @@ -2437,10 +2439,10 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41267 && !tp_features.bright_unkfw)
41268 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
41269 }
41270 +}
41271
41272 #undef TPACPI_COMPARE_KEY
41273 #undef TPACPI_MAY_SEND_KEY
41274 -}
41275
41276 /*
41277 * Polling driver
41278 diff --git a/drivers/pnp/pnpbios/bioscalls.c b/drivers/pnp/pnpbios/bioscalls.c
41279 index 769d265..a3a05ca 100644
41280 --- a/drivers/pnp/pnpbios/bioscalls.c
41281 +++ b/drivers/pnp/pnpbios/bioscalls.c
41282 @@ -58,7 +58,7 @@ do { \
41283 set_desc_limit(&gdt[(selname) >> 3], (size) - 1); \
41284 } while(0)
41285
41286 -static struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4092,
41287 +static const struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4093,
41288 (unsigned long)__va(0x400UL), PAGE_SIZE - 0x400 - 1);
41289
41290 /*
41291 @@ -95,7 +95,10 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
41292
41293 cpu = get_cpu();
41294 save_desc_40 = get_cpu_gdt_table(cpu)[0x40 / 8];
41295 +
41296 + pax_open_kernel();
41297 get_cpu_gdt_table(cpu)[0x40 / 8] = bad_bios_desc;
41298 + pax_close_kernel();
41299
41300 /* On some boxes IRQ's during PnP BIOS calls are deadly. */
41301 spin_lock_irqsave(&pnp_bios_lock, flags);
41302 @@ -133,7 +136,10 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
41303 :"memory");
41304 spin_unlock_irqrestore(&pnp_bios_lock, flags);
41305
41306 + pax_open_kernel();
41307 get_cpu_gdt_table(cpu)[0x40 / 8] = save_desc_40;
41308 + pax_close_kernel();
41309 +
41310 put_cpu();
41311
41312 /* If we get here and this is set then the PnP BIOS faulted on us. */
41313 @@ -467,7 +473,7 @@ int pnp_bios_read_escd(char *data, u32 nvram_base)
41314 return status;
41315 }
41316
41317 -void pnpbios_calls_init(union pnp_bios_install_struct *header)
41318 +void __init pnpbios_calls_init(union pnp_bios_install_struct *header)
41319 {
41320 int i;
41321
41322 @@ -475,6 +481,8 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header)
41323 pnp_bios_callpoint.offset = header->fields.pm16offset;
41324 pnp_bios_callpoint.segment = PNP_CS16;
41325
41326 + pax_open_kernel();
41327 +
41328 for_each_possible_cpu(i) {
41329 struct desc_struct *gdt = get_cpu_gdt_table(i);
41330 if (!gdt)
41331 @@ -486,4 +494,6 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header)
41332 set_desc_base(&gdt[GDT_ENTRY_PNPBIOS_DS],
41333 (unsigned long)__va(header->fields.pm16dseg));
41334 }
41335 +
41336 + pax_close_kernel();
41337 }
41338 diff --git a/drivers/pnp/resource.c b/drivers/pnp/resource.c
41339 index 3e6db1c..1fbbdae 100644
41340 --- a/drivers/pnp/resource.c
41341 +++ b/drivers/pnp/resource.c
41342 @@ -360,7 +360,7 @@ int pnp_check_irq(struct pnp_dev *dev, struct resource *res)
41343 return 1;
41344
41345 /* check if the resource is valid */
41346 - if (*irq < 0 || *irq > 15)
41347 + if (*irq > 15)
41348 return 0;
41349
41350 /* check if the resource is reserved */
41351 @@ -424,7 +424,7 @@ int pnp_check_dma(struct pnp_dev *dev, struct resource *res)
41352 return 1;
41353
41354 /* check if the resource is valid */
41355 - if (*dma < 0 || *dma == 4 || *dma > 7)
41356 + if (*dma == 4 || *dma > 7)
41357 return 0;
41358
41359 /* check if the resource is reserved */
41360 diff --git a/drivers/power/pda_power.c b/drivers/power/pda_power.c
41361 index 7df7c5f..bd48c47 100644
41362 --- a/drivers/power/pda_power.c
41363 +++ b/drivers/power/pda_power.c
41364 @@ -37,7 +37,11 @@ static int polling;
41365
41366 #ifdef CONFIG_USB_OTG_UTILS
41367 static struct usb_phy *transceiver;
41368 -static struct notifier_block otg_nb;
41369 +static int otg_handle_notification(struct notifier_block *nb,
41370 + unsigned long event, void *unused);
41371 +static struct notifier_block otg_nb = {
41372 + .notifier_call = otg_handle_notification
41373 +};
41374 #endif
41375
41376 static struct regulator *ac_draw;
41377 @@ -369,7 +373,6 @@ static int pda_power_probe(struct platform_device *pdev)
41378
41379 #ifdef CONFIG_USB_OTG_UTILS
41380 if (!IS_ERR_OR_NULL(transceiver) && pdata->use_otg_notifier) {
41381 - otg_nb.notifier_call = otg_handle_notification;
41382 ret = usb_register_notifier(transceiver, &otg_nb);
41383 if (ret) {
41384 dev_err(dev, "failure to register otg notifier\n");
41385 diff --git a/drivers/power/power_supply.h b/drivers/power/power_supply.h
41386 index cc439fd..8fa30df 100644
41387 --- a/drivers/power/power_supply.h
41388 +++ b/drivers/power/power_supply.h
41389 @@ -16,12 +16,12 @@ struct power_supply;
41390
41391 #ifdef CONFIG_SYSFS
41392
41393 -extern void power_supply_init_attrs(struct device_type *dev_type);
41394 +extern void power_supply_init_attrs(void);
41395 extern int power_supply_uevent(struct device *dev, struct kobj_uevent_env *env);
41396
41397 #else
41398
41399 -static inline void power_supply_init_attrs(struct device_type *dev_type) {}
41400 +static inline void power_supply_init_attrs(void) {}
41401 #define power_supply_uevent NULL
41402
41403 #endif /* CONFIG_SYSFS */
41404 diff --git a/drivers/power/power_supply_core.c b/drivers/power/power_supply_core.c
41405 index 5deac43..608c5ff 100644
41406 --- a/drivers/power/power_supply_core.c
41407 +++ b/drivers/power/power_supply_core.c
41408 @@ -24,7 +24,10 @@
41409 struct class *power_supply_class;
41410 EXPORT_SYMBOL_GPL(power_supply_class);
41411
41412 -static struct device_type power_supply_dev_type;
41413 +extern const struct attribute_group *power_supply_attr_groups[];
41414 +static struct device_type power_supply_dev_type = {
41415 + .groups = power_supply_attr_groups,
41416 +};
41417
41418 static int __power_supply_changed_work(struct device *dev, void *data)
41419 {
41420 @@ -393,7 +396,7 @@ static int __init power_supply_class_init(void)
41421 return PTR_ERR(power_supply_class);
41422
41423 power_supply_class->dev_uevent = power_supply_uevent;
41424 - power_supply_init_attrs(&power_supply_dev_type);
41425 + power_supply_init_attrs();
41426
41427 return 0;
41428 }
41429 diff --git a/drivers/power/power_supply_sysfs.c b/drivers/power/power_supply_sysfs.c
41430 index 29178f7..c65f324 100644
41431 --- a/drivers/power/power_supply_sysfs.c
41432 +++ b/drivers/power/power_supply_sysfs.c
41433 @@ -230,17 +230,15 @@ static struct attribute_group power_supply_attr_group = {
41434 .is_visible = power_supply_attr_is_visible,
41435 };
41436
41437 -static const struct attribute_group *power_supply_attr_groups[] = {
41438 +const struct attribute_group *power_supply_attr_groups[] = {
41439 &power_supply_attr_group,
41440 NULL,
41441 };
41442
41443 -void power_supply_init_attrs(struct device_type *dev_type)
41444 +void power_supply_init_attrs(void)
41445 {
41446 int i;
41447
41448 - dev_type->groups = power_supply_attr_groups;
41449 -
41450 for (i = 0; i < ARRAY_SIZE(power_supply_attrs); i++)
41451 __power_supply_attrs[i] = &power_supply_attrs[i].attr;
41452 }
41453 diff --git a/drivers/regulator/max8660.c b/drivers/regulator/max8660.c
41454 index 4d7c635..9860196 100644
41455 --- a/drivers/regulator/max8660.c
41456 +++ b/drivers/regulator/max8660.c
41457 @@ -333,8 +333,10 @@ static int max8660_probe(struct i2c_client *client,
41458 max8660->shadow_regs[MAX8660_OVER1] = 5;
41459 } else {
41460 /* Otherwise devices can be toggled via software */
41461 - max8660_dcdc_ops.enable = max8660_dcdc_enable;
41462 - max8660_dcdc_ops.disable = max8660_dcdc_disable;
41463 + pax_open_kernel();
41464 + *(void **)&max8660_dcdc_ops.enable = max8660_dcdc_enable;
41465 + *(void **)&max8660_dcdc_ops.disable = max8660_dcdc_disable;
41466 + pax_close_kernel();
41467 }
41468
41469 /*
41470 diff --git a/drivers/regulator/max8973-regulator.c b/drivers/regulator/max8973-regulator.c
41471 index 9a8ea91..c483dd9 100644
41472 --- a/drivers/regulator/max8973-regulator.c
41473 +++ b/drivers/regulator/max8973-regulator.c
41474 @@ -401,9 +401,11 @@ static int max8973_probe(struct i2c_client *client,
41475 if (!pdata->enable_ext_control) {
41476 max->desc.enable_reg = MAX8973_VOUT;
41477 max->desc.enable_mask = MAX8973_VOUT_ENABLE;
41478 - max8973_dcdc_ops.enable = regulator_enable_regmap;
41479 - max8973_dcdc_ops.disable = regulator_disable_regmap;
41480 - max8973_dcdc_ops.is_enabled = regulator_is_enabled_regmap;
41481 + pax_open_kernel();
41482 + *(void **)&max8973_dcdc_ops.enable = regulator_enable_regmap;
41483 + *(void **)&max8973_dcdc_ops.disable = regulator_disable_regmap;
41484 + *(void **)&max8973_dcdc_ops.is_enabled = regulator_is_enabled_regmap;
41485 + pax_close_kernel();
41486 }
41487
41488 max->enable_external_control = pdata->enable_ext_control;
41489 diff --git a/drivers/regulator/mc13892-regulator.c b/drivers/regulator/mc13892-regulator.c
41490 index 9891aec..beb3083 100644
41491 --- a/drivers/regulator/mc13892-regulator.c
41492 +++ b/drivers/regulator/mc13892-regulator.c
41493 @@ -583,10 +583,12 @@ static int mc13892_regulator_probe(struct platform_device *pdev)
41494 }
41495 mc13xxx_unlock(mc13892);
41496
41497 - mc13892_regulators[MC13892_VCAM].desc.ops->set_mode
41498 + pax_open_kernel();
41499 + *(void **)&mc13892_regulators[MC13892_VCAM].desc.ops->set_mode
41500 = mc13892_vcam_set_mode;
41501 - mc13892_regulators[MC13892_VCAM].desc.ops->get_mode
41502 + *(void **)&mc13892_regulators[MC13892_VCAM].desc.ops->get_mode
41503 = mc13892_vcam_get_mode;
41504 + pax_close_kernel();
41505
41506 mc13xxx_data = mc13xxx_parse_regulators_dt(pdev, mc13892_regulators,
41507 ARRAY_SIZE(mc13892_regulators),
41508 diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c
41509 index cc5bea9..689f7d9 100644
41510 --- a/drivers/rtc/rtc-cmos.c
41511 +++ b/drivers/rtc/rtc-cmos.c
41512 @@ -724,7 +724,9 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq)
41513 hpet_rtc_timer_init();
41514
41515 /* export at least the first block of NVRAM */
41516 - nvram.size = address_space - NVRAM_OFFSET;
41517 + pax_open_kernel();
41518 + *(size_t *)&nvram.size = address_space - NVRAM_OFFSET;
41519 + pax_close_kernel();
41520 retval = sysfs_create_bin_file(&dev->kobj, &nvram);
41521 if (retval < 0) {
41522 dev_dbg(dev, "can't create nvram file? %d\n", retval);
41523 diff --git a/drivers/rtc/rtc-dev.c b/drivers/rtc/rtc-dev.c
41524 index d049393..bb20be0 100644
41525 --- a/drivers/rtc/rtc-dev.c
41526 +++ b/drivers/rtc/rtc-dev.c
41527 @@ -16,6 +16,7 @@
41528 #include <linux/module.h>
41529 #include <linux/rtc.h>
41530 #include <linux/sched.h>
41531 +#include <linux/grsecurity.h>
41532 #include "rtc-core.h"
41533
41534 static dev_t rtc_devt;
41535 @@ -347,6 +348,8 @@ static long rtc_dev_ioctl(struct file *file,
41536 if (copy_from_user(&tm, uarg, sizeof(tm)))
41537 return -EFAULT;
41538
41539 + gr_log_timechange();
41540 +
41541 return rtc_set_time(rtc, &tm);
41542
41543 case RTC_PIE_ON:
41544 diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
41545 index 970a236..3613169 100644
41546 --- a/drivers/rtc/rtc-ds1307.c
41547 +++ b/drivers/rtc/rtc-ds1307.c
41548 @@ -106,7 +106,7 @@ struct ds1307 {
41549 u8 offset; /* register's offset */
41550 u8 regs[11];
41551 u16 nvram_offset;
41552 - struct bin_attribute *nvram;
41553 + bin_attribute_no_const *nvram;
41554 enum ds_type type;
41555 unsigned long flags;
41556 #define HAS_NVRAM 0 /* bit 0 == sysfs file active */
41557 diff --git a/drivers/rtc/rtc-m48t59.c b/drivers/rtc/rtc-m48t59.c
41558 index 130f29a..6179d03 100644
41559 --- a/drivers/rtc/rtc-m48t59.c
41560 +++ b/drivers/rtc/rtc-m48t59.c
41561 @@ -482,7 +482,9 @@ static int m48t59_rtc_probe(struct platform_device *pdev)
41562 goto out;
41563 }
41564
41565 - m48t59_nvram_attr.size = pdata->offset;
41566 + pax_open_kernel();
41567 + *(size_t *)&m48t59_nvram_attr.size = pdata->offset;
41568 + pax_close_kernel();
41569
41570 ret = sysfs_create_bin_file(&pdev->dev.kobj, &m48t59_nvram_attr);
41571 if (ret) {
41572 diff --git a/drivers/scsi/bfa/bfa_fcpim.h b/drivers/scsi/bfa/bfa_fcpim.h
41573 index e693af6..2e525b6 100644
41574 --- a/drivers/scsi/bfa/bfa_fcpim.h
41575 +++ b/drivers/scsi/bfa/bfa_fcpim.h
41576 @@ -36,7 +36,7 @@ struct bfa_iotag_s {
41577
41578 struct bfa_itn_s {
41579 bfa_isr_func_t isr;
41580 -};
41581 +} __no_const;
41582
41583 void bfa_itn_create(struct bfa_s *bfa, struct bfa_rport_s *rport,
41584 void (*isr)(struct bfa_s *bfa, struct bfi_msg_s *m));
41585 diff --git a/drivers/scsi/bfa/bfa_ioc.h b/drivers/scsi/bfa/bfa_ioc.h
41586 index 23a90e7..9cf04ee 100644
41587 --- a/drivers/scsi/bfa/bfa_ioc.h
41588 +++ b/drivers/scsi/bfa/bfa_ioc.h
41589 @@ -258,7 +258,7 @@ struct bfa_ioc_cbfn_s {
41590 bfa_ioc_disable_cbfn_t disable_cbfn;
41591 bfa_ioc_hbfail_cbfn_t hbfail_cbfn;
41592 bfa_ioc_reset_cbfn_t reset_cbfn;
41593 -};
41594 +} __no_const;
41595
41596 /*
41597 * IOC event notification mechanism.
41598 @@ -346,7 +346,7 @@ struct bfa_ioc_hwif_s {
41599 void (*ioc_sync_ack) (struct bfa_ioc_s *ioc);
41600 bfa_boolean_t (*ioc_sync_complete) (struct bfa_ioc_s *ioc);
41601 bfa_boolean_t (*ioc_lpu_read_stat) (struct bfa_ioc_s *ioc);
41602 -};
41603 +} __no_const;
41604
41605 /*
41606 * Queue element to wait for room in request queue. FIFO order is
41607 diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
41608 index df0c3c7..b00e1d0 100644
41609 --- a/drivers/scsi/hosts.c
41610 +++ b/drivers/scsi/hosts.c
41611 @@ -42,7 +42,7 @@
41612 #include "scsi_logging.h"
41613
41614
41615 -static atomic_t scsi_host_next_hn = ATOMIC_INIT(0); /* host_no for next new host */
41616 +static atomic_unchecked_t scsi_host_next_hn = ATOMIC_INIT(0); /* host_no for next new host */
41617
41618
41619 static void scsi_host_cls_release(struct device *dev)
41620 @@ -361,7 +361,7 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize)
41621 * subtract one because we increment first then return, but we need to
41622 * know what the next host number was before increment
41623 */
41624 - shost->host_no = atomic_inc_return(&scsi_host_next_hn) - 1;
41625 + shost->host_no = atomic_inc_return_unchecked(&scsi_host_next_hn) - 1;
41626 shost->dma_channel = 0xff;
41627
41628 /* These three are default values which can be overridden */
41629 diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
41630 index 7f4f790..b75b92a 100644
41631 --- a/drivers/scsi/hpsa.c
41632 +++ b/drivers/scsi/hpsa.c
41633 @@ -554,7 +554,7 @@ static inline u32 next_command(struct ctlr_info *h, u8 q)
41634 unsigned long flags;
41635
41636 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant)))
41637 - return h->access.command_completed(h, q);
41638 + return h->access->command_completed(h, q);
41639
41640 if ((rq->head[rq->current_entry] & 1) == rq->wraparound) {
41641 a = rq->head[rq->current_entry];
41642 @@ -3422,7 +3422,7 @@ static void start_io(struct ctlr_info *h)
41643 while (!list_empty(&h->reqQ)) {
41644 c = list_entry(h->reqQ.next, struct CommandList, list);
41645 /* can't do anything if fifo is full */
41646 - if ((h->access.fifo_full(h))) {
41647 + if ((h->access->fifo_full(h))) {
41648 dev_warn(&h->pdev->dev, "fifo full\n");
41649 break;
41650 }
41651 @@ -3444,7 +3444,7 @@ static void start_io(struct ctlr_info *h)
41652
41653 /* Tell the controller execute command */
41654 spin_unlock_irqrestore(&h->lock, flags);
41655 - h->access.submit_command(h, c);
41656 + h->access->submit_command(h, c);
41657 spin_lock_irqsave(&h->lock, flags);
41658 }
41659 spin_unlock_irqrestore(&h->lock, flags);
41660 @@ -3452,17 +3452,17 @@ static void start_io(struct ctlr_info *h)
41661
41662 static inline unsigned long get_next_completion(struct ctlr_info *h, u8 q)
41663 {
41664 - return h->access.command_completed(h, q);
41665 + return h->access->command_completed(h, q);
41666 }
41667
41668 static inline bool interrupt_pending(struct ctlr_info *h)
41669 {
41670 - return h->access.intr_pending(h);
41671 + return h->access->intr_pending(h);
41672 }
41673
41674 static inline long interrupt_not_for_us(struct ctlr_info *h)
41675 {
41676 - return (h->access.intr_pending(h) == 0) ||
41677 + return (h->access->intr_pending(h) == 0) ||
41678 (h->interrupts_enabled == 0);
41679 }
41680
41681 @@ -4364,7 +4364,7 @@ static int hpsa_pci_init(struct ctlr_info *h)
41682 if (prod_index < 0)
41683 return -ENODEV;
41684 h->product_name = products[prod_index].product_name;
41685 - h->access = *(products[prod_index].access);
41686 + h->access = products[prod_index].access;
41687
41688 pci_disable_link_state(h->pdev, PCIE_LINK_STATE_L0S |
41689 PCIE_LINK_STATE_L1 | PCIE_LINK_STATE_CLKPM);
41690 @@ -4646,7 +4646,7 @@ static void controller_lockup_detected(struct ctlr_info *h)
41691
41692 assert_spin_locked(&lockup_detector_lock);
41693 remove_ctlr_from_lockup_detector_list(h);
41694 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
41695 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
41696 spin_lock_irqsave(&h->lock, flags);
41697 h->lockup_detected = readl(h->vaddr + SA5_SCRATCHPAD_OFFSET);
41698 spin_unlock_irqrestore(&h->lock, flags);
41699 @@ -4823,7 +4823,7 @@ reinit_after_soft_reset:
41700 }
41701
41702 /* make sure the board interrupts are off */
41703 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
41704 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
41705
41706 if (hpsa_request_irq(h, do_hpsa_intr_msi, do_hpsa_intr_intx))
41707 goto clean2;
41708 @@ -4857,7 +4857,7 @@ reinit_after_soft_reset:
41709 * fake ones to scoop up any residual completions.
41710 */
41711 spin_lock_irqsave(&h->lock, flags);
41712 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
41713 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
41714 spin_unlock_irqrestore(&h->lock, flags);
41715 free_irqs(h);
41716 rc = hpsa_request_irq(h, hpsa_msix_discard_completions,
41717 @@ -4876,9 +4876,9 @@ reinit_after_soft_reset:
41718 dev_info(&h->pdev->dev, "Board READY.\n");
41719 dev_info(&h->pdev->dev,
41720 "Waiting for stale completions to drain.\n");
41721 - h->access.set_intr_mask(h, HPSA_INTR_ON);
41722 + h->access->set_intr_mask(h, HPSA_INTR_ON);
41723 msleep(10000);
41724 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
41725 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
41726
41727 rc = controller_reset_failed(h->cfgtable);
41728 if (rc)
41729 @@ -4899,7 +4899,7 @@ reinit_after_soft_reset:
41730 }
41731
41732 /* Turn the interrupts on so we can service requests */
41733 - h->access.set_intr_mask(h, HPSA_INTR_ON);
41734 + h->access->set_intr_mask(h, HPSA_INTR_ON);
41735
41736 hpsa_hba_inquiry(h);
41737 hpsa_register_scsi(h); /* hook ourselves into SCSI subsystem */
41738 @@ -4954,7 +4954,7 @@ static void hpsa_shutdown(struct pci_dev *pdev)
41739 * To write all data in the battery backed cache to disks
41740 */
41741 hpsa_flush_cache(h);
41742 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
41743 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
41744 hpsa_free_irqs_and_disable_msix(h);
41745 }
41746
41747 @@ -5122,7 +5122,7 @@ static void hpsa_enter_performant_mode(struct ctlr_info *h, u32 use_short_tags)
41748 return;
41749 }
41750 /* Change the access methods to the performant access methods */
41751 - h->access = SA5_performant_access;
41752 + h->access = &SA5_performant_access;
41753 h->transMethod = CFGTBL_Trans_Performant;
41754 }
41755
41756 diff --git a/drivers/scsi/hpsa.h b/drivers/scsi/hpsa.h
41757 index 9816479..c5d4e97 100644
41758 --- a/drivers/scsi/hpsa.h
41759 +++ b/drivers/scsi/hpsa.h
41760 @@ -79,7 +79,7 @@ struct ctlr_info {
41761 unsigned int msix_vector;
41762 unsigned int msi_vector;
41763 int intr_mode; /* either PERF_MODE_INT or SIMPLE_MODE_INT */
41764 - struct access_method access;
41765 + struct access_method *access;
41766
41767 /* queue and queue Info */
41768 struct list_head reqQ;
41769 diff --git a/drivers/scsi/libfc/fc_exch.c b/drivers/scsi/libfc/fc_exch.c
41770 index c772d8d..35c362c 100644
41771 --- a/drivers/scsi/libfc/fc_exch.c
41772 +++ b/drivers/scsi/libfc/fc_exch.c
41773 @@ -100,12 +100,12 @@ struct fc_exch_mgr {
41774 u16 pool_max_index;
41775
41776 struct {
41777 - atomic_t no_free_exch;
41778 - atomic_t no_free_exch_xid;
41779 - atomic_t xid_not_found;
41780 - atomic_t xid_busy;
41781 - atomic_t seq_not_found;
41782 - atomic_t non_bls_resp;
41783 + atomic_unchecked_t no_free_exch;
41784 + atomic_unchecked_t no_free_exch_xid;
41785 + atomic_unchecked_t xid_not_found;
41786 + atomic_unchecked_t xid_busy;
41787 + atomic_unchecked_t seq_not_found;
41788 + atomic_unchecked_t non_bls_resp;
41789 } stats;
41790 };
41791
41792 @@ -725,7 +725,7 @@ static struct fc_exch *fc_exch_em_alloc(struct fc_lport *lport,
41793 /* allocate memory for exchange */
41794 ep = mempool_alloc(mp->ep_pool, GFP_ATOMIC);
41795 if (!ep) {
41796 - atomic_inc(&mp->stats.no_free_exch);
41797 + atomic_inc_unchecked(&mp->stats.no_free_exch);
41798 goto out;
41799 }
41800 memset(ep, 0, sizeof(*ep));
41801 @@ -786,7 +786,7 @@ out:
41802 return ep;
41803 err:
41804 spin_unlock_bh(&pool->lock);
41805 - atomic_inc(&mp->stats.no_free_exch_xid);
41806 + atomic_inc_unchecked(&mp->stats.no_free_exch_xid);
41807 mempool_free(ep, mp->ep_pool);
41808 return NULL;
41809 }
41810 @@ -929,7 +929,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
41811 xid = ntohs(fh->fh_ox_id); /* we originated exch */
41812 ep = fc_exch_find(mp, xid);
41813 if (!ep) {
41814 - atomic_inc(&mp->stats.xid_not_found);
41815 + atomic_inc_unchecked(&mp->stats.xid_not_found);
41816 reject = FC_RJT_OX_ID;
41817 goto out;
41818 }
41819 @@ -959,7 +959,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
41820 ep = fc_exch_find(mp, xid);
41821 if ((f_ctl & FC_FC_FIRST_SEQ) && fc_sof_is_init(fr_sof(fp))) {
41822 if (ep) {
41823 - atomic_inc(&mp->stats.xid_busy);
41824 + atomic_inc_unchecked(&mp->stats.xid_busy);
41825 reject = FC_RJT_RX_ID;
41826 goto rel;
41827 }
41828 @@ -970,7 +970,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
41829 }
41830 xid = ep->xid; /* get our XID */
41831 } else if (!ep) {
41832 - atomic_inc(&mp->stats.xid_not_found);
41833 + atomic_inc_unchecked(&mp->stats.xid_not_found);
41834 reject = FC_RJT_RX_ID; /* XID not found */
41835 goto out;
41836 }
41837 @@ -987,7 +987,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
41838 } else {
41839 sp = &ep->seq;
41840 if (sp->id != fh->fh_seq_id) {
41841 - atomic_inc(&mp->stats.seq_not_found);
41842 + atomic_inc_unchecked(&mp->stats.seq_not_found);
41843 if (f_ctl & FC_FC_END_SEQ) {
41844 /*
41845 * Update sequence_id based on incoming last
41846 @@ -1437,22 +1437,22 @@ static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
41847
41848 ep = fc_exch_find(mp, ntohs(fh->fh_ox_id));
41849 if (!ep) {
41850 - atomic_inc(&mp->stats.xid_not_found);
41851 + atomic_inc_unchecked(&mp->stats.xid_not_found);
41852 goto out;
41853 }
41854 if (ep->esb_stat & ESB_ST_COMPLETE) {
41855 - atomic_inc(&mp->stats.xid_not_found);
41856 + atomic_inc_unchecked(&mp->stats.xid_not_found);
41857 goto rel;
41858 }
41859 if (ep->rxid == FC_XID_UNKNOWN)
41860 ep->rxid = ntohs(fh->fh_rx_id);
41861 if (ep->sid != 0 && ep->sid != ntoh24(fh->fh_d_id)) {
41862 - atomic_inc(&mp->stats.xid_not_found);
41863 + atomic_inc_unchecked(&mp->stats.xid_not_found);
41864 goto rel;
41865 }
41866 if (ep->did != ntoh24(fh->fh_s_id) &&
41867 ep->did != FC_FID_FLOGI) {
41868 - atomic_inc(&mp->stats.xid_not_found);
41869 + atomic_inc_unchecked(&mp->stats.xid_not_found);
41870 goto rel;
41871 }
41872 sof = fr_sof(fp);
41873 @@ -1461,7 +1461,7 @@ static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
41874 sp->ssb_stat |= SSB_ST_RESP;
41875 sp->id = fh->fh_seq_id;
41876 } else if (sp->id != fh->fh_seq_id) {
41877 - atomic_inc(&mp->stats.seq_not_found);
41878 + atomic_inc_unchecked(&mp->stats.seq_not_found);
41879 goto rel;
41880 }
41881
41882 @@ -1525,9 +1525,9 @@ static void fc_exch_recv_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
41883 sp = fc_seq_lookup_orig(mp, fp); /* doesn't hold sequence */
41884
41885 if (!sp)
41886 - atomic_inc(&mp->stats.xid_not_found);
41887 + atomic_inc_unchecked(&mp->stats.xid_not_found);
41888 else
41889 - atomic_inc(&mp->stats.non_bls_resp);
41890 + atomic_inc_unchecked(&mp->stats.non_bls_resp);
41891
41892 fc_frame_free(fp);
41893 }
41894 @@ -2174,13 +2174,13 @@ void fc_exch_update_stats(struct fc_lport *lport)
41895
41896 list_for_each_entry(ema, &lport->ema_list, ema_list) {
41897 mp = ema->mp;
41898 - st->fc_no_free_exch += atomic_read(&mp->stats.no_free_exch);
41899 + st->fc_no_free_exch += atomic_read_unchecked(&mp->stats.no_free_exch);
41900 st->fc_no_free_exch_xid +=
41901 - atomic_read(&mp->stats.no_free_exch_xid);
41902 - st->fc_xid_not_found += atomic_read(&mp->stats.xid_not_found);
41903 - st->fc_xid_busy += atomic_read(&mp->stats.xid_busy);
41904 - st->fc_seq_not_found += atomic_read(&mp->stats.seq_not_found);
41905 - st->fc_non_bls_resp += atomic_read(&mp->stats.non_bls_resp);
41906 + atomic_read_unchecked(&mp->stats.no_free_exch_xid);
41907 + st->fc_xid_not_found += atomic_read_unchecked(&mp->stats.xid_not_found);
41908 + st->fc_xid_busy += atomic_read_unchecked(&mp->stats.xid_busy);
41909 + st->fc_seq_not_found += atomic_read_unchecked(&mp->stats.seq_not_found);
41910 + st->fc_non_bls_resp += atomic_read_unchecked(&mp->stats.non_bls_resp);
41911 }
41912 }
41913 EXPORT_SYMBOL(fc_exch_update_stats);
41914 diff --git a/drivers/scsi/libsas/sas_ata.c b/drivers/scsi/libsas/sas_ata.c
41915 index bdb81cd..d3c7c2c 100644
41916 --- a/drivers/scsi/libsas/sas_ata.c
41917 +++ b/drivers/scsi/libsas/sas_ata.c
41918 @@ -554,7 +554,7 @@ static struct ata_port_operations sas_sata_ops = {
41919 .postreset = ata_std_postreset,
41920 .error_handler = ata_std_error_handler,
41921 .post_internal_cmd = sas_ata_post_internal,
41922 - .qc_defer = ata_std_qc_defer,
41923 + .qc_defer = ata_std_qc_defer,
41924 .qc_prep = ata_noop_qc_prep,
41925 .qc_issue = sas_ata_qc_issue,
41926 .qc_fill_rtf = sas_ata_qc_fill_rtf,
41927 diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h
41928 index 7706c99..3b4fc0c 100644
41929 --- a/drivers/scsi/lpfc/lpfc.h
41930 +++ b/drivers/scsi/lpfc/lpfc.h
41931 @@ -424,7 +424,7 @@ struct lpfc_vport {
41932 struct dentry *debug_nodelist;
41933 struct dentry *vport_debugfs_root;
41934 struct lpfc_debugfs_trc *disc_trc;
41935 - atomic_t disc_trc_cnt;
41936 + atomic_unchecked_t disc_trc_cnt;
41937 #endif
41938 uint8_t stat_data_enabled;
41939 uint8_t stat_data_blocked;
41940 @@ -853,8 +853,8 @@ struct lpfc_hba {
41941 struct timer_list fabric_block_timer;
41942 unsigned long bit_flags;
41943 #define FABRIC_COMANDS_BLOCKED 0
41944 - atomic_t num_rsrc_err;
41945 - atomic_t num_cmd_success;
41946 + atomic_unchecked_t num_rsrc_err;
41947 + atomic_unchecked_t num_cmd_success;
41948 unsigned long last_rsrc_error_time;
41949 unsigned long last_ramp_down_time;
41950 unsigned long last_ramp_up_time;
41951 @@ -890,7 +890,7 @@ struct lpfc_hba {
41952
41953 struct dentry *debug_slow_ring_trc;
41954 struct lpfc_debugfs_trc *slow_ring_trc;
41955 - atomic_t slow_ring_trc_cnt;
41956 + atomic_unchecked_t slow_ring_trc_cnt;
41957 /* iDiag debugfs sub-directory */
41958 struct dentry *idiag_root;
41959 struct dentry *idiag_pci_cfg;
41960 diff --git a/drivers/scsi/lpfc/lpfc_debugfs.c b/drivers/scsi/lpfc/lpfc_debugfs.c
41961 index f63f5ff..de29189 100644
41962 --- a/drivers/scsi/lpfc/lpfc_debugfs.c
41963 +++ b/drivers/scsi/lpfc/lpfc_debugfs.c
41964 @@ -106,7 +106,7 @@ MODULE_PARM_DESC(lpfc_debugfs_mask_disc_trc,
41965
41966 #include <linux/debugfs.h>
41967
41968 -static atomic_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0);
41969 +static atomic_unchecked_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0);
41970 static unsigned long lpfc_debugfs_start_time = 0L;
41971
41972 /* iDiag */
41973 @@ -147,7 +147,7 @@ lpfc_debugfs_disc_trc_data(struct lpfc_vport *vport, char *buf, int size)
41974 lpfc_debugfs_enable = 0;
41975
41976 len = 0;
41977 - index = (atomic_read(&vport->disc_trc_cnt) + 1) &
41978 + index = (atomic_read_unchecked(&vport->disc_trc_cnt) + 1) &
41979 (lpfc_debugfs_max_disc_trc - 1);
41980 for (i = index; i < lpfc_debugfs_max_disc_trc; i++) {
41981 dtp = vport->disc_trc + i;
41982 @@ -213,7 +213,7 @@ lpfc_debugfs_slow_ring_trc_data(struct lpfc_hba *phba, char *buf, int size)
41983 lpfc_debugfs_enable = 0;
41984
41985 len = 0;
41986 - index = (atomic_read(&phba->slow_ring_trc_cnt) + 1) &
41987 + index = (atomic_read_unchecked(&phba->slow_ring_trc_cnt) + 1) &
41988 (lpfc_debugfs_max_slow_ring_trc - 1);
41989 for (i = index; i < lpfc_debugfs_max_slow_ring_trc; i++) {
41990 dtp = phba->slow_ring_trc + i;
41991 @@ -646,14 +646,14 @@ lpfc_debugfs_disc_trc(struct lpfc_vport *vport, int mask, char *fmt,
41992 !vport || !vport->disc_trc)
41993 return;
41994
41995 - index = atomic_inc_return(&vport->disc_trc_cnt) &
41996 + index = atomic_inc_return_unchecked(&vport->disc_trc_cnt) &
41997 (lpfc_debugfs_max_disc_trc - 1);
41998 dtp = vport->disc_trc + index;
41999 dtp->fmt = fmt;
42000 dtp->data1 = data1;
42001 dtp->data2 = data2;
42002 dtp->data3 = data3;
42003 - dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
42004 + dtp->seq_cnt = atomic_inc_return_unchecked(&lpfc_debugfs_seq_trc_cnt);
42005 dtp->jif = jiffies;
42006 #endif
42007 return;
42008 @@ -684,14 +684,14 @@ lpfc_debugfs_slow_ring_trc(struct lpfc_hba *phba, char *fmt,
42009 !phba || !phba->slow_ring_trc)
42010 return;
42011
42012 - index = atomic_inc_return(&phba->slow_ring_trc_cnt) &
42013 + index = atomic_inc_return_unchecked(&phba->slow_ring_trc_cnt) &
42014 (lpfc_debugfs_max_slow_ring_trc - 1);
42015 dtp = phba->slow_ring_trc + index;
42016 dtp->fmt = fmt;
42017 dtp->data1 = data1;
42018 dtp->data2 = data2;
42019 dtp->data3 = data3;
42020 - dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
42021 + dtp->seq_cnt = atomic_inc_return_unchecked(&lpfc_debugfs_seq_trc_cnt);
42022 dtp->jif = jiffies;
42023 #endif
42024 return;
42025 @@ -4182,7 +4182,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
42026 "slow_ring buffer\n");
42027 goto debug_failed;
42028 }
42029 - atomic_set(&phba->slow_ring_trc_cnt, 0);
42030 + atomic_set_unchecked(&phba->slow_ring_trc_cnt, 0);
42031 memset(phba->slow_ring_trc, 0,
42032 (sizeof(struct lpfc_debugfs_trc) *
42033 lpfc_debugfs_max_slow_ring_trc));
42034 @@ -4228,7 +4228,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
42035 "buffer\n");
42036 goto debug_failed;
42037 }
42038 - atomic_set(&vport->disc_trc_cnt, 0);
42039 + atomic_set_unchecked(&vport->disc_trc_cnt, 0);
42040
42041 snprintf(name, sizeof(name), "discovery_trace");
42042 vport->debug_disc_trc =
42043 diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
42044 index 314b4f6..7005d10 100644
42045 --- a/drivers/scsi/lpfc/lpfc_init.c
42046 +++ b/drivers/scsi/lpfc/lpfc_init.c
42047 @@ -10551,8 +10551,10 @@ lpfc_init(void)
42048 "misc_register returned with status %d", error);
42049
42050 if (lpfc_enable_npiv) {
42051 - lpfc_transport_functions.vport_create = lpfc_vport_create;
42052 - lpfc_transport_functions.vport_delete = lpfc_vport_delete;
42053 + pax_open_kernel();
42054 + *(void **)&lpfc_transport_functions.vport_create = lpfc_vport_create;
42055 + *(void **)&lpfc_transport_functions.vport_delete = lpfc_vport_delete;
42056 + pax_close_kernel();
42057 }
42058 lpfc_transport_template =
42059 fc_attach_transport(&lpfc_transport_functions);
42060 diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c
42061 index 98af07c..7625fb5 100644
42062 --- a/drivers/scsi/lpfc/lpfc_scsi.c
42063 +++ b/drivers/scsi/lpfc/lpfc_scsi.c
42064 @@ -325,7 +325,7 @@ lpfc_rampdown_queue_depth(struct lpfc_hba *phba)
42065 uint32_t evt_posted;
42066
42067 spin_lock_irqsave(&phba->hbalock, flags);
42068 - atomic_inc(&phba->num_rsrc_err);
42069 + atomic_inc_unchecked(&phba->num_rsrc_err);
42070 phba->last_rsrc_error_time = jiffies;
42071
42072 if ((phba->last_ramp_down_time + QUEUE_RAMP_DOWN_INTERVAL) > jiffies) {
42073 @@ -366,7 +366,7 @@ lpfc_rampup_queue_depth(struct lpfc_vport *vport,
42074 unsigned long flags;
42075 struct lpfc_hba *phba = vport->phba;
42076 uint32_t evt_posted;
42077 - atomic_inc(&phba->num_cmd_success);
42078 + atomic_inc_unchecked(&phba->num_cmd_success);
42079
42080 if (vport->cfg_lun_queue_depth <= queue_depth)
42081 return;
42082 @@ -410,8 +410,8 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
42083 unsigned long num_rsrc_err, num_cmd_success;
42084 int i;
42085
42086 - num_rsrc_err = atomic_read(&phba->num_rsrc_err);
42087 - num_cmd_success = atomic_read(&phba->num_cmd_success);
42088 + num_rsrc_err = atomic_read_unchecked(&phba->num_rsrc_err);
42089 + num_cmd_success = atomic_read_unchecked(&phba->num_cmd_success);
42090
42091 /*
42092 * The error and success command counters are global per
42093 @@ -439,8 +439,8 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
42094 }
42095 }
42096 lpfc_destroy_vport_work_array(phba, vports);
42097 - atomic_set(&phba->num_rsrc_err, 0);
42098 - atomic_set(&phba->num_cmd_success, 0);
42099 + atomic_set_unchecked(&phba->num_rsrc_err, 0);
42100 + atomic_set_unchecked(&phba->num_cmd_success, 0);
42101 }
42102
42103 /**
42104 @@ -474,8 +474,8 @@ lpfc_ramp_up_queue_handler(struct lpfc_hba *phba)
42105 }
42106 }
42107 lpfc_destroy_vport_work_array(phba, vports);
42108 - atomic_set(&phba->num_rsrc_err, 0);
42109 - atomic_set(&phba->num_cmd_success, 0);
42110 + atomic_set_unchecked(&phba->num_rsrc_err, 0);
42111 + atomic_set_unchecked(&phba->num_cmd_success, 0);
42112 }
42113
42114 /**
42115 diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c
42116 index b46f5e9..c4c4ccb 100644
42117 --- a/drivers/scsi/pmcraid.c
42118 +++ b/drivers/scsi/pmcraid.c
42119 @@ -200,8 +200,8 @@ static int pmcraid_slave_alloc(struct scsi_device *scsi_dev)
42120 res->scsi_dev = scsi_dev;
42121 scsi_dev->hostdata = res;
42122 res->change_detected = 0;
42123 - atomic_set(&res->read_failures, 0);
42124 - atomic_set(&res->write_failures, 0);
42125 + atomic_set_unchecked(&res->read_failures, 0);
42126 + atomic_set_unchecked(&res->write_failures, 0);
42127 rc = 0;
42128 }
42129 spin_unlock_irqrestore(&pinstance->resource_lock, lock_flags);
42130 @@ -2676,9 +2676,9 @@ static int pmcraid_error_handler(struct pmcraid_cmd *cmd)
42131
42132 /* If this was a SCSI read/write command keep count of errors */
42133 if (SCSI_CMD_TYPE(scsi_cmd->cmnd[0]) == SCSI_READ_CMD)
42134 - atomic_inc(&res->read_failures);
42135 + atomic_inc_unchecked(&res->read_failures);
42136 else if (SCSI_CMD_TYPE(scsi_cmd->cmnd[0]) == SCSI_WRITE_CMD)
42137 - atomic_inc(&res->write_failures);
42138 + atomic_inc_unchecked(&res->write_failures);
42139
42140 if (!RES_IS_GSCSI(res->cfg_entry) &&
42141 masked_ioasc != PMCRAID_IOASC_HW_DEVICE_BUS_STATUS_ERROR) {
42142 @@ -3534,7 +3534,7 @@ static int pmcraid_queuecommand_lck(
42143 * block of scsi_cmd which is re-used (e.g. cancel/abort), which uses
42144 * hrrq_id assigned here in queuecommand
42145 */
42146 - ioarcb->hrrq_id = atomic_add_return(1, &(pinstance->last_message_id)) %
42147 + ioarcb->hrrq_id = atomic_add_return_unchecked(1, &(pinstance->last_message_id)) %
42148 pinstance->num_hrrq;
42149 cmd->cmd_done = pmcraid_io_done;
42150
42151 @@ -3859,7 +3859,7 @@ static long pmcraid_ioctl_passthrough(
42152 * block of scsi_cmd which is re-used (e.g. cancel/abort), which uses
42153 * hrrq_id assigned here in queuecommand
42154 */
42155 - ioarcb->hrrq_id = atomic_add_return(1, &(pinstance->last_message_id)) %
42156 + ioarcb->hrrq_id = atomic_add_return_unchecked(1, &(pinstance->last_message_id)) %
42157 pinstance->num_hrrq;
42158
42159 if (request_size) {
42160 @@ -4497,7 +4497,7 @@ static void pmcraid_worker_function(struct work_struct *workp)
42161
42162 pinstance = container_of(workp, struct pmcraid_instance, worker_q);
42163 /* add resources only after host is added into system */
42164 - if (!atomic_read(&pinstance->expose_resources))
42165 + if (!atomic_read_unchecked(&pinstance->expose_resources))
42166 return;
42167
42168 fw_version = be16_to_cpu(pinstance->inq_data->fw_version);
42169 @@ -5324,8 +5324,8 @@ static int pmcraid_init_instance(struct pci_dev *pdev, struct Scsi_Host *host,
42170 init_waitqueue_head(&pinstance->reset_wait_q);
42171
42172 atomic_set(&pinstance->outstanding_cmds, 0);
42173 - atomic_set(&pinstance->last_message_id, 0);
42174 - atomic_set(&pinstance->expose_resources, 0);
42175 + atomic_set_unchecked(&pinstance->last_message_id, 0);
42176 + atomic_set_unchecked(&pinstance->expose_resources, 0);
42177
42178 INIT_LIST_HEAD(&pinstance->free_res_q);
42179 INIT_LIST_HEAD(&pinstance->used_res_q);
42180 @@ -6038,7 +6038,7 @@ static int pmcraid_probe(struct pci_dev *pdev,
42181 /* Schedule worker thread to handle CCN and take care of adding and
42182 * removing devices to OS
42183 */
42184 - atomic_set(&pinstance->expose_resources, 1);
42185 + atomic_set_unchecked(&pinstance->expose_resources, 1);
42186 schedule_work(&pinstance->worker_q);
42187 return rc;
42188
42189 diff --git a/drivers/scsi/pmcraid.h b/drivers/scsi/pmcraid.h
42190 index e1d150f..6c6df44 100644
42191 --- a/drivers/scsi/pmcraid.h
42192 +++ b/drivers/scsi/pmcraid.h
42193 @@ -748,7 +748,7 @@ struct pmcraid_instance {
42194 struct pmcraid_isr_param hrrq_vector[PMCRAID_NUM_MSIX_VECTORS];
42195
42196 /* Message id as filled in last fired IOARCB, used to identify HRRQ */
42197 - atomic_t last_message_id;
42198 + atomic_unchecked_t last_message_id;
42199
42200 /* configuration table */
42201 struct pmcraid_config_table *cfg_table;
42202 @@ -777,7 +777,7 @@ struct pmcraid_instance {
42203 atomic_t outstanding_cmds;
42204
42205 /* should add/delete resources to mid-layer now ?*/
42206 - atomic_t expose_resources;
42207 + atomic_unchecked_t expose_resources;
42208
42209
42210
42211 @@ -813,8 +813,8 @@ struct pmcraid_resource_entry {
42212 struct pmcraid_config_table_entry_ext cfg_entry_ext;
42213 };
42214 struct scsi_device *scsi_dev; /* Link scsi_device structure */
42215 - atomic_t read_failures; /* count of failed READ commands */
42216 - atomic_t write_failures; /* count of failed WRITE commands */
42217 + atomic_unchecked_t read_failures; /* count of failed READ commands */
42218 + atomic_unchecked_t write_failures; /* count of failed WRITE commands */
42219
42220 /* To indicate add/delete/modify during CCN */
42221 u8 change_detected;
42222 diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
42223 index b3db9dc..c3b1756 100644
42224 --- a/drivers/scsi/qla2xxx/qla_attr.c
42225 +++ b/drivers/scsi/qla2xxx/qla_attr.c
42226 @@ -1971,7 +1971,7 @@ qla24xx_vport_disable(struct fc_vport *fc_vport, bool disable)
42227 return 0;
42228 }
42229
42230 -struct fc_function_template qla2xxx_transport_functions = {
42231 +fc_function_template_no_const qla2xxx_transport_functions = {
42232
42233 .show_host_node_name = 1,
42234 .show_host_port_name = 1,
42235 @@ -2018,7 +2018,7 @@ struct fc_function_template qla2xxx_transport_functions = {
42236 .bsg_timeout = qla24xx_bsg_timeout,
42237 };
42238
42239 -struct fc_function_template qla2xxx_transport_vport_functions = {
42240 +fc_function_template_no_const qla2xxx_transport_vport_functions = {
42241
42242 .show_host_node_name = 1,
42243 .show_host_port_name = 1,
42244 diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h
42245 index b310fa9..b9b3944 100644
42246 --- a/drivers/scsi/qla2xxx/qla_gbl.h
42247 +++ b/drivers/scsi/qla2xxx/qla_gbl.h
42248 @@ -523,8 +523,8 @@ extern void qla2x00_get_sym_node_name(scsi_qla_host_t *, uint8_t *);
42249 struct device_attribute;
42250 extern struct device_attribute *qla2x00_host_attrs[];
42251 struct fc_function_template;
42252 -extern struct fc_function_template qla2xxx_transport_functions;
42253 -extern struct fc_function_template qla2xxx_transport_vport_functions;
42254 +extern fc_function_template_no_const qla2xxx_transport_functions;
42255 +extern fc_function_template_no_const qla2xxx_transport_vport_functions;
42256 extern void qla2x00_alloc_sysfs_attr(scsi_qla_host_t *);
42257 extern void qla2x00_free_sysfs_attr(scsi_qla_host_t *);
42258 extern void qla2x00_init_host_attr(scsi_qla_host_t *);
42259 diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
42260 index 2c6dd3d..e5ecd82 100644
42261 --- a/drivers/scsi/qla2xxx/qla_os.c
42262 +++ b/drivers/scsi/qla2xxx/qla_os.c
42263 @@ -1554,8 +1554,10 @@ qla2x00_config_dma_addressing(struct qla_hw_data *ha)
42264 !pci_set_consistent_dma_mask(ha->pdev, DMA_BIT_MASK(64))) {
42265 /* Ok, a 64bit DMA mask is applicable. */
42266 ha->flags.enable_64bit_addressing = 1;
42267 - ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64;
42268 - ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64;
42269 + pax_open_kernel();
42270 + *(void **)&ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64;
42271 + *(void **)&ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64;
42272 + pax_close_kernel();
42273 return;
42274 }
42275 }
42276 diff --git a/drivers/scsi/qla4xxx/ql4_def.h b/drivers/scsi/qla4xxx/ql4_def.h
42277 index 129f5dd..ade53e8 100644
42278 --- a/drivers/scsi/qla4xxx/ql4_def.h
42279 +++ b/drivers/scsi/qla4xxx/ql4_def.h
42280 @@ -275,7 +275,7 @@ struct ddb_entry {
42281 * (4000 only) */
42282 atomic_t relogin_timer; /* Max Time to wait for
42283 * relogin to complete */
42284 - atomic_t relogin_retry_count; /* Num of times relogin has been
42285 + atomic_unchecked_t relogin_retry_count; /* Num of times relogin has been
42286 * retried */
42287 uint32_t default_time2wait; /* Default Min time between
42288 * relogins (+aens) */
42289 diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
42290 index 6142729..b6a85c9 100644
42291 --- a/drivers/scsi/qla4xxx/ql4_os.c
42292 +++ b/drivers/scsi/qla4xxx/ql4_os.c
42293 @@ -2622,12 +2622,12 @@ static void qla4xxx_check_relogin_flash_ddb(struct iscsi_cls_session *cls_sess)
42294 */
42295 if (!iscsi_is_session_online(cls_sess)) {
42296 /* Reset retry relogin timer */
42297 - atomic_inc(&ddb_entry->relogin_retry_count);
42298 + atomic_inc_unchecked(&ddb_entry->relogin_retry_count);
42299 DEBUG2(ql4_printk(KERN_INFO, ha,
42300 "%s: index[%d] relogin timed out-retrying"
42301 " relogin (%d), retry (%d)\n", __func__,
42302 ddb_entry->fw_ddb_index,
42303 - atomic_read(&ddb_entry->relogin_retry_count),
42304 + atomic_read_unchecked(&ddb_entry->relogin_retry_count),
42305 ddb_entry->default_time2wait + 4));
42306 set_bit(DPC_RELOGIN_DEVICE, &ha->dpc_flags);
42307 atomic_set(&ddb_entry->retry_relogin_timer,
42308 @@ -4742,7 +4742,7 @@ static void qla4xxx_setup_flash_ddb_entry(struct scsi_qla_host *ha,
42309
42310 atomic_set(&ddb_entry->retry_relogin_timer, INVALID_ENTRY);
42311 atomic_set(&ddb_entry->relogin_timer, 0);
42312 - atomic_set(&ddb_entry->relogin_retry_count, 0);
42313 + atomic_set_unchecked(&ddb_entry->relogin_retry_count, 0);
42314 def_timeout = le16_to_cpu(ddb_entry->fw_ddb_entry.def_timeout);
42315 ddb_entry->default_relogin_timeout =
42316 (def_timeout > LOGIN_TOV) && (def_timeout < LOGIN_TOV * 10) ?
42317 diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
42318 index 2c0d0ec..4e8681a 100644
42319 --- a/drivers/scsi/scsi.c
42320 +++ b/drivers/scsi/scsi.c
42321 @@ -661,7 +661,7 @@ int scsi_dispatch_cmd(struct scsi_cmnd *cmd)
42322 unsigned long timeout;
42323 int rtn = 0;
42324
42325 - atomic_inc(&cmd->device->iorequest_cnt);
42326 + atomic_inc_unchecked(&cmd->device->iorequest_cnt);
42327
42328 /* check if the device is still usable */
42329 if (unlikely(cmd->device->sdev_state == SDEV_DEL)) {
42330 diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
42331 index c31187d..0ead8c3 100644
42332 --- a/drivers/scsi/scsi_lib.c
42333 +++ b/drivers/scsi/scsi_lib.c
42334 @@ -1459,7 +1459,7 @@ static void scsi_kill_request(struct request *req, struct request_queue *q)
42335 shost = sdev->host;
42336 scsi_init_cmd_errh(cmd);
42337 cmd->result = DID_NO_CONNECT << 16;
42338 - atomic_inc(&cmd->device->iorequest_cnt);
42339 + atomic_inc_unchecked(&cmd->device->iorequest_cnt);
42340
42341 /*
42342 * SCSI request completion path will do scsi_device_unbusy(),
42343 @@ -1485,9 +1485,9 @@ static void scsi_softirq_done(struct request *rq)
42344
42345 INIT_LIST_HEAD(&cmd->eh_entry);
42346
42347 - atomic_inc(&cmd->device->iodone_cnt);
42348 + atomic_inc_unchecked(&cmd->device->iodone_cnt);
42349 if (cmd->result)
42350 - atomic_inc(&cmd->device->ioerr_cnt);
42351 + atomic_inc_unchecked(&cmd->device->ioerr_cnt);
42352
42353 disposition = scsi_decide_disposition(cmd);
42354 if (disposition != SUCCESS &&
42355 diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
42356 index 931a7d9..0c2a754 100644
42357 --- a/drivers/scsi/scsi_sysfs.c
42358 +++ b/drivers/scsi/scsi_sysfs.c
42359 @@ -658,7 +658,7 @@ show_iostat_##field(struct device *dev, struct device_attribute *attr, \
42360 char *buf) \
42361 { \
42362 struct scsi_device *sdev = to_scsi_device(dev); \
42363 - unsigned long long count = atomic_read(&sdev->field); \
42364 + unsigned long long count = atomic_read_unchecked(&sdev->field); \
42365 return snprintf(buf, 20, "0x%llx\n", count); \
42366 } \
42367 static DEVICE_ATTR(field, S_IRUGO, show_iostat_##field, NULL)
42368 diff --git a/drivers/scsi/scsi_tgt_lib.c b/drivers/scsi/scsi_tgt_lib.c
42369 index 84a1fdf..693b0d6 100644
42370 --- a/drivers/scsi/scsi_tgt_lib.c
42371 +++ b/drivers/scsi/scsi_tgt_lib.c
42372 @@ -362,7 +362,7 @@ static int scsi_map_user_pages(struct scsi_tgt_cmd *tcmd, struct scsi_cmnd *cmd,
42373 int err;
42374
42375 dprintk("%lx %u\n", uaddr, len);
42376 - err = blk_rq_map_user(q, rq, NULL, (void *)uaddr, len, GFP_KERNEL);
42377 + err = blk_rq_map_user(q, rq, NULL, (void __user *)uaddr, len, GFP_KERNEL);
42378 if (err) {
42379 /*
42380 * TODO: need to fixup sg_tablesize, max_segment_size,
42381 diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c
42382 index e894ca7..de9d7660 100644
42383 --- a/drivers/scsi/scsi_transport_fc.c
42384 +++ b/drivers/scsi/scsi_transport_fc.c
42385 @@ -498,7 +498,7 @@ static DECLARE_TRANSPORT_CLASS(fc_vport_class,
42386 * Netlink Infrastructure
42387 */
42388
42389 -static atomic_t fc_event_seq;
42390 +static atomic_unchecked_t fc_event_seq;
42391
42392 /**
42393 * fc_get_event_number - Obtain the next sequential FC event number
42394 @@ -511,7 +511,7 @@ static atomic_t fc_event_seq;
42395 u32
42396 fc_get_event_number(void)
42397 {
42398 - return atomic_add_return(1, &fc_event_seq);
42399 + return atomic_add_return_unchecked(1, &fc_event_seq);
42400 }
42401 EXPORT_SYMBOL(fc_get_event_number);
42402
42403 @@ -659,7 +659,7 @@ static __init int fc_transport_init(void)
42404 {
42405 int error;
42406
42407 - atomic_set(&fc_event_seq, 0);
42408 + atomic_set_unchecked(&fc_event_seq, 0);
42409
42410 error = transport_class_register(&fc_host_class);
42411 if (error)
42412 @@ -849,7 +849,7 @@ static int fc_str_to_dev_loss(const char *buf, unsigned long *val)
42413 char *cp;
42414
42415 *val = simple_strtoul(buf, &cp, 0);
42416 - if ((*cp && (*cp != '\n')) || (*val < 0))
42417 + if (*cp && (*cp != '\n'))
42418 return -EINVAL;
42419 /*
42420 * Check for overflow; dev_loss_tmo is u32
42421 diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
42422 index 0a74b97..fa8d648 100644
42423 --- a/drivers/scsi/scsi_transport_iscsi.c
42424 +++ b/drivers/scsi/scsi_transport_iscsi.c
42425 @@ -79,7 +79,7 @@ struct iscsi_internal {
42426 struct transport_container session_cont;
42427 };
42428
42429 -static atomic_t iscsi_session_nr; /* sysfs session id for next new session */
42430 +static atomic_unchecked_t iscsi_session_nr; /* sysfs session id for next new session */
42431 static struct workqueue_struct *iscsi_eh_timer_workq;
42432
42433 static DEFINE_IDA(iscsi_sess_ida);
42434 @@ -1064,7 +1064,7 @@ int iscsi_add_session(struct iscsi_cls_session *session, unsigned int target_id)
42435 int err;
42436
42437 ihost = shost->shost_data;
42438 - session->sid = atomic_add_return(1, &iscsi_session_nr);
42439 + session->sid = atomic_add_return_unchecked(1, &iscsi_session_nr);
42440
42441 if (target_id == ISCSI_MAX_TARGET) {
42442 id = ida_simple_get(&iscsi_sess_ida, 0, 0, GFP_KERNEL);
42443 @@ -2955,7 +2955,7 @@ static __init int iscsi_transport_init(void)
42444 printk(KERN_INFO "Loading iSCSI transport class v%s.\n",
42445 ISCSI_TRANSPORT_VERSION);
42446
42447 - atomic_set(&iscsi_session_nr, 0);
42448 + atomic_set_unchecked(&iscsi_session_nr, 0);
42449
42450 err = class_register(&iscsi_transport_class);
42451 if (err)
42452 diff --git a/drivers/scsi/scsi_transport_srp.c b/drivers/scsi/scsi_transport_srp.c
42453 index f379c7f..e8fc69c 100644
42454 --- a/drivers/scsi/scsi_transport_srp.c
42455 +++ b/drivers/scsi/scsi_transport_srp.c
42456 @@ -33,7 +33,7 @@
42457 #include "scsi_transport_srp_internal.h"
42458
42459 struct srp_host_attrs {
42460 - atomic_t next_port_id;
42461 + atomic_unchecked_t next_port_id;
42462 };
42463 #define to_srp_host_attrs(host) ((struct srp_host_attrs *)(host)->shost_data)
42464
42465 @@ -61,7 +61,7 @@ static int srp_host_setup(struct transport_container *tc, struct device *dev,
42466 struct Scsi_Host *shost = dev_to_shost(dev);
42467 struct srp_host_attrs *srp_host = to_srp_host_attrs(shost);
42468
42469 - atomic_set(&srp_host->next_port_id, 0);
42470 + atomic_set_unchecked(&srp_host->next_port_id, 0);
42471 return 0;
42472 }
42473
42474 @@ -210,7 +210,7 @@ struct srp_rport *srp_rport_add(struct Scsi_Host *shost,
42475 memcpy(rport->port_id, ids->port_id, sizeof(rport->port_id));
42476 rport->roles = ids->roles;
42477
42478 - id = atomic_inc_return(&to_srp_host_attrs(shost)->next_port_id);
42479 + id = atomic_inc_return_unchecked(&to_srp_host_attrs(shost)->next_port_id);
42480 dev_set_name(&rport->dev, "port-%d:%d", shost->host_no, id);
42481
42482 transport_setup_device(&rport->dev);
42483 diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
42484 index 82910cc..7c350ad 100644
42485 --- a/drivers/scsi/sd.c
42486 +++ b/drivers/scsi/sd.c
42487 @@ -2929,7 +2929,7 @@ static int sd_probe(struct device *dev)
42488 sdkp->disk = gd;
42489 sdkp->index = index;
42490 atomic_set(&sdkp->openers, 0);
42491 - atomic_set(&sdkp->device->ioerr_cnt, 0);
42492 + atomic_set_unchecked(&sdkp->device->ioerr_cnt, 0);
42493
42494 if (!sdp->request_queue->rq_timeout) {
42495 if (sdp->type != TYPE_MOD)
42496 diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
42497 index 9f0c465..47194ee 100644
42498 --- a/drivers/scsi/sg.c
42499 +++ b/drivers/scsi/sg.c
42500 @@ -1101,7 +1101,7 @@ sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg)
42501 sdp->disk->disk_name,
42502 MKDEV(SCSI_GENERIC_MAJOR, sdp->index),
42503 NULL,
42504 - (char *)arg);
42505 + (char __user *)arg);
42506 case BLKTRACESTART:
42507 return blk_trace_startstop(sdp->device->request_queue, 1);
42508 case BLKTRACESTOP:
42509 diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
42510 index 004b10f..7c98d51 100644
42511 --- a/drivers/spi/spi.c
42512 +++ b/drivers/spi/spi.c
42513 @@ -1620,7 +1620,7 @@ int spi_bus_unlock(struct spi_master *master)
42514 EXPORT_SYMBOL_GPL(spi_bus_unlock);
42515
42516 /* portable code must never pass more than 32 bytes */
42517 -#define SPI_BUFSIZ max(32,SMP_CACHE_BYTES)
42518 +#define SPI_BUFSIZ max(32UL,SMP_CACHE_BYTES)
42519
42520 static u8 *buf;
42521
42522 diff --git a/drivers/staging/iio/iio_hwmon.c b/drivers/staging/iio/iio_hwmon.c
42523 index 93af756..a4bc5bf 100644
42524 --- a/drivers/staging/iio/iio_hwmon.c
42525 +++ b/drivers/staging/iio/iio_hwmon.c
42526 @@ -67,7 +67,7 @@ static int iio_hwmon_probe(struct platform_device *pdev)
42527 {
42528 struct device *dev = &pdev->dev;
42529 struct iio_hwmon_state *st;
42530 - struct sensor_device_attribute *a;
42531 + sensor_device_attribute_no_const *a;
42532 int ret, i;
42533 int in_i = 1, temp_i = 1, curr_i = 1;
42534 enum iio_chan_type type;
42535 diff --git a/drivers/staging/octeon/ethernet-rx.c b/drivers/staging/octeon/ethernet-rx.c
42536 index 34afc16..ffe44dd 100644
42537 --- a/drivers/staging/octeon/ethernet-rx.c
42538 +++ b/drivers/staging/octeon/ethernet-rx.c
42539 @@ -421,11 +421,11 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
42540 /* Increment RX stats for virtual ports */
42541 if (work->ipprt >= CVMX_PIP_NUM_INPUT_PORTS) {
42542 #ifdef CONFIG_64BIT
42543 - atomic64_add(1, (atomic64_t *)&priv->stats.rx_packets);
42544 - atomic64_add(skb->len, (atomic64_t *)&priv->stats.rx_bytes);
42545 + atomic64_add_unchecked(1, (atomic64_unchecked_t *)&priv->stats.rx_packets);
42546 + atomic64_add_unchecked(skb->len, (atomic64_unchecked_t *)&priv->stats.rx_bytes);
42547 #else
42548 - atomic_add(1, (atomic_t *)&priv->stats.rx_packets);
42549 - atomic_add(skb->len, (atomic_t *)&priv->stats.rx_bytes);
42550 + atomic_add_unchecked(1, (atomic_unchecked_t *)&priv->stats.rx_packets);
42551 + atomic_add_unchecked(skb->len, (atomic_unchecked_t *)&priv->stats.rx_bytes);
42552 #endif
42553 }
42554 netif_receive_skb(skb);
42555 @@ -437,9 +437,9 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
42556 dev->name);
42557 */
42558 #ifdef CONFIG_64BIT
42559 - atomic64_add(1, (atomic64_t *)&priv->stats.rx_dropped);
42560 + atomic64_unchecked_add(1, (atomic64_unchecked_t *)&priv->stats.rx_dropped);
42561 #else
42562 - atomic_add(1, (atomic_t *)&priv->stats.rx_dropped);
42563 + atomic_add_unchecked(1, (atomic_unchecked_t *)&priv->stats.rx_dropped);
42564 #endif
42565 dev_kfree_skb_irq(skb);
42566 }
42567 diff --git a/drivers/staging/octeon/ethernet.c b/drivers/staging/octeon/ethernet.c
42568 index c3a90e7..023619a 100644
42569 --- a/drivers/staging/octeon/ethernet.c
42570 +++ b/drivers/staging/octeon/ethernet.c
42571 @@ -252,11 +252,11 @@ static struct net_device_stats *cvm_oct_common_get_stats(struct net_device *dev)
42572 * since the RX tasklet also increments it.
42573 */
42574 #ifdef CONFIG_64BIT
42575 - atomic64_add(rx_status.dropped_packets,
42576 - (atomic64_t *)&priv->stats.rx_dropped);
42577 + atomic64_add_unchecked(rx_status.dropped_packets,
42578 + (atomic64_unchecked_t *)&priv->stats.rx_dropped);
42579 #else
42580 - atomic_add(rx_status.dropped_packets,
42581 - (atomic_t *)&priv->stats.rx_dropped);
42582 + atomic_add_unchecked(rx_status.dropped_packets,
42583 + (atomic_unchecked_t *)&priv->stats.rx_dropped);
42584 #endif
42585 }
42586
42587 diff --git a/drivers/staging/rtl8712/rtl871x_io.h b/drivers/staging/rtl8712/rtl871x_io.h
42588 index dc23395..cf7e9b1 100644
42589 --- a/drivers/staging/rtl8712/rtl871x_io.h
42590 +++ b/drivers/staging/rtl8712/rtl871x_io.h
42591 @@ -108,7 +108,7 @@ struct _io_ops {
42592 u8 *pmem);
42593 u32 (*_write_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt,
42594 u8 *pmem);
42595 -};
42596 +} __no_const;
42597
42598 struct io_req {
42599 struct list_head list;
42600 diff --git a/drivers/staging/sbe-2t3e3/netdev.c b/drivers/staging/sbe-2t3e3/netdev.c
42601 index 1f5088b..0e59820 100644
42602 --- a/drivers/staging/sbe-2t3e3/netdev.c
42603 +++ b/drivers/staging/sbe-2t3e3/netdev.c
42604 @@ -51,7 +51,7 @@ static int t3e3_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
42605 t3e3_if_config(sc, cmd_2t3e3, (char *)&param, &resp, &rlen);
42606
42607 if (rlen)
42608 - if (copy_to_user(data, &resp, rlen))
42609 + if (rlen > sizeof resp || copy_to_user(data, &resp, rlen))
42610 return -EFAULT;
42611
42612 return 0;
42613 diff --git a/drivers/staging/usbip/vhci.h b/drivers/staging/usbip/vhci.h
42614 index 5dddc4d..34fcb2f 100644
42615 --- a/drivers/staging/usbip/vhci.h
42616 +++ b/drivers/staging/usbip/vhci.h
42617 @@ -83,7 +83,7 @@ struct vhci_hcd {
42618 unsigned resuming:1;
42619 unsigned long re_timeout;
42620
42621 - atomic_t seqnum;
42622 + atomic_unchecked_t seqnum;
42623
42624 /*
42625 * NOTE:
42626 diff --git a/drivers/staging/usbip/vhci_hcd.c b/drivers/staging/usbip/vhci_hcd.c
42627 index f1ca084..7b5c0c3 100644
42628 --- a/drivers/staging/usbip/vhci_hcd.c
42629 +++ b/drivers/staging/usbip/vhci_hcd.c
42630 @@ -441,7 +441,7 @@ static void vhci_tx_urb(struct urb *urb)
42631
42632 spin_lock(&vdev->priv_lock);
42633
42634 - priv->seqnum = atomic_inc_return(&the_controller->seqnum);
42635 + priv->seqnum = atomic_inc_return_unchecked(&the_controller->seqnum);
42636 if (priv->seqnum == 0xffff)
42637 dev_info(&urb->dev->dev, "seqnum max\n");
42638
42639 @@ -687,7 +687,7 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
42640 return -ENOMEM;
42641 }
42642
42643 - unlink->seqnum = atomic_inc_return(&the_controller->seqnum);
42644 + unlink->seqnum = atomic_inc_return_unchecked(&the_controller->seqnum);
42645 if (unlink->seqnum == 0xffff)
42646 pr_info("seqnum max\n");
42647
42648 @@ -891,7 +891,7 @@ static int vhci_start(struct usb_hcd *hcd)
42649 vdev->rhport = rhport;
42650 }
42651
42652 - atomic_set(&vhci->seqnum, 0);
42653 + atomic_set_unchecked(&vhci->seqnum, 0);
42654 spin_lock_init(&vhci->lock);
42655
42656 hcd->power_budget = 0; /* no limit */
42657 diff --git a/drivers/staging/usbip/vhci_rx.c b/drivers/staging/usbip/vhci_rx.c
42658 index faf8e60..c46f8ab 100644
42659 --- a/drivers/staging/usbip/vhci_rx.c
42660 +++ b/drivers/staging/usbip/vhci_rx.c
42661 @@ -76,7 +76,7 @@ static void vhci_recv_ret_submit(struct vhci_device *vdev,
42662 if (!urb) {
42663 pr_err("cannot find a urb of seqnum %u\n", pdu->base.seqnum);
42664 pr_info("max seqnum %d\n",
42665 - atomic_read(&the_controller->seqnum));
42666 + atomic_read_unchecked(&the_controller->seqnum));
42667 usbip_event_add(ud, VDEV_EVENT_ERROR_TCP);
42668 return;
42669 }
42670 diff --git a/drivers/staging/vt6655/hostap.c b/drivers/staging/vt6655/hostap.c
42671 index 5f13890..36a044b 100644
42672 --- a/drivers/staging/vt6655/hostap.c
42673 +++ b/drivers/staging/vt6655/hostap.c
42674 @@ -73,14 +73,13 @@ static int msglevel =MSG_LEVEL_INFO;
42675 *
42676 */
42677
42678 +static net_device_ops_no_const apdev_netdev_ops;
42679 +
42680 static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
42681 {
42682 PSDevice apdev_priv;
42683 struct net_device *dev = pDevice->dev;
42684 int ret;
42685 - const struct net_device_ops apdev_netdev_ops = {
42686 - .ndo_start_xmit = pDevice->tx_80211,
42687 - };
42688
42689 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Enabling hostapd mode\n", dev->name);
42690
42691 @@ -92,6 +91,8 @@ static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
42692 *apdev_priv = *pDevice;
42693 memcpy(pDevice->apdev->dev_addr, dev->dev_addr, ETH_ALEN);
42694
42695 + /* only half broken now */
42696 + apdev_netdev_ops.ndo_start_xmit = pDevice->tx_80211;
42697 pDevice->apdev->netdev_ops = &apdev_netdev_ops;
42698
42699 pDevice->apdev->type = ARPHRD_IEEE80211;
42700 diff --git a/drivers/staging/vt6656/hostap.c b/drivers/staging/vt6656/hostap.c
42701 index a94e66f..31984d0 100644
42702 --- a/drivers/staging/vt6656/hostap.c
42703 +++ b/drivers/staging/vt6656/hostap.c
42704 @@ -60,14 +60,13 @@ static int msglevel =MSG_LEVEL_INFO;
42705 *
42706 */
42707
42708 +static net_device_ops_no_const apdev_netdev_ops;
42709 +
42710 static int hostap_enable_hostapd(struct vnt_private *pDevice, int rtnl_locked)
42711 {
42712 struct vnt_private *apdev_priv;
42713 struct net_device *dev = pDevice->dev;
42714 int ret;
42715 - const struct net_device_ops apdev_netdev_ops = {
42716 - .ndo_start_xmit = pDevice->tx_80211,
42717 - };
42718
42719 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Enabling hostapd mode\n", dev->name);
42720
42721 @@ -79,6 +78,8 @@ static int hostap_enable_hostapd(struct vnt_private *pDevice, int rtnl_locked)
42722 *apdev_priv = *pDevice;
42723 memcpy(pDevice->apdev->dev_addr, dev->dev_addr, ETH_ALEN);
42724
42725 + /* only half broken now */
42726 + apdev_netdev_ops.ndo_start_xmit = pDevice->tx_80211;
42727 pDevice->apdev->netdev_ops = &apdev_netdev_ops;
42728
42729 pDevice->apdev->type = ARPHRD_IEEE80211;
42730 diff --git a/drivers/staging/zcache/tmem.c b/drivers/staging/zcache/tmem.c
42731 index a2b7e03..9ff4bbd 100644
42732 --- a/drivers/staging/zcache/tmem.c
42733 +++ b/drivers/staging/zcache/tmem.c
42734 @@ -50,7 +50,7 @@
42735 * A tmem host implementation must use this function to register callbacks
42736 * for memory allocation.
42737 */
42738 -static struct tmem_hostops tmem_hostops;
42739 +static tmem_hostops_no_const tmem_hostops;
42740
42741 static void tmem_objnode_tree_init(void);
42742
42743 @@ -64,7 +64,7 @@ void tmem_register_hostops(struct tmem_hostops *m)
42744 * A tmem host implementation must use this function to register
42745 * callbacks for a page-accessible memory (PAM) implementation.
42746 */
42747 -static struct tmem_pamops tmem_pamops;
42748 +static tmem_pamops_no_const tmem_pamops;
42749
42750 void tmem_register_pamops(struct tmem_pamops *m)
42751 {
42752 diff --git a/drivers/staging/zcache/tmem.h b/drivers/staging/zcache/tmem.h
42753 index adbe5a8..d387359 100644
42754 --- a/drivers/staging/zcache/tmem.h
42755 +++ b/drivers/staging/zcache/tmem.h
42756 @@ -226,6 +226,7 @@ struct tmem_pamops {
42757 int (*replace_in_obj)(void *, struct tmem_obj *);
42758 #endif
42759 };
42760 +typedef struct tmem_pamops __no_const tmem_pamops_no_const;
42761 extern void tmem_register_pamops(struct tmem_pamops *m);
42762
42763 /* memory allocation methods provided by the host implementation */
42764 @@ -235,6 +236,7 @@ struct tmem_hostops {
42765 struct tmem_objnode *(*objnode_alloc)(struct tmem_pool *);
42766 void (*objnode_free)(struct tmem_objnode *, struct tmem_pool *);
42767 };
42768 +typedef struct tmem_hostops __no_const tmem_hostops_no_const;
42769 extern void tmem_register_hostops(struct tmem_hostops *m);
42770
42771 /* core tmem accessor functions */
42772 diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c
42773 index 2e4d655..fd72e68 100644
42774 --- a/drivers/target/target_core_device.c
42775 +++ b/drivers/target/target_core_device.c
42776 @@ -1414,7 +1414,7 @@ struct se_device *target_alloc_device(struct se_hba *hba, const char *name)
42777 spin_lock_init(&dev->se_port_lock);
42778 spin_lock_init(&dev->se_tmr_lock);
42779 spin_lock_init(&dev->qf_cmd_lock);
42780 - atomic_set(&dev->dev_ordered_id, 0);
42781 + atomic_set_unchecked(&dev->dev_ordered_id, 0);
42782 INIT_LIST_HEAD(&dev->t10_wwn.t10_vpd_list);
42783 spin_lock_init(&dev->t10_wwn.t10_vpd_lock);
42784 INIT_LIST_HEAD(&dev->t10_pr.registration_list);
42785 diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
42786 index fc9a5a0..1d5975e 100644
42787 --- a/drivers/target/target_core_transport.c
42788 +++ b/drivers/target/target_core_transport.c
42789 @@ -1081,7 +1081,7 @@ transport_check_alloc_task_attr(struct se_cmd *cmd)
42790 * Used to determine when ORDERED commands should go from
42791 * Dormant to Active status.
42792 */
42793 - cmd->se_ordered_id = atomic_inc_return(&dev->dev_ordered_id);
42794 + cmd->se_ordered_id = atomic_inc_return_unchecked(&dev->dev_ordered_id);
42795 smp_mb__after_atomic_inc();
42796 pr_debug("Allocated se_ordered_id: %u for Task Attr: 0x%02x on %s\n",
42797 cmd->se_ordered_id, cmd->sam_task_attr,
42798 diff --git a/drivers/tty/cyclades.c b/drivers/tty/cyclades.c
42799 index 345bd0e..61d5375 100644
42800 --- a/drivers/tty/cyclades.c
42801 +++ b/drivers/tty/cyclades.c
42802 @@ -1576,10 +1576,10 @@ static int cy_open(struct tty_struct *tty, struct file *filp)
42803 printk(KERN_DEBUG "cyc:cy_open ttyC%d, count = %d\n", info->line,
42804 info->port.count);
42805 #endif
42806 - info->port.count++;
42807 + atomic_inc(&info->port.count);
42808 #ifdef CY_DEBUG_COUNT
42809 printk(KERN_DEBUG "cyc:cy_open (%d): incrementing count to %d\n",
42810 - current->pid, info->port.count);
42811 + current->pid, atomic_read(&info->port.count));
42812 #endif
42813
42814 /*
42815 @@ -3978,7 +3978,7 @@ static int cyclades_proc_show(struct seq_file *m, void *v)
42816 for (j = 0; j < cy_card[i].nports; j++) {
42817 info = &cy_card[i].ports[j];
42818
42819 - if (info->port.count) {
42820 + if (atomic_read(&info->port.count)) {
42821 /* XXX is the ldisc num worth this? */
42822 struct tty_struct *tty;
42823 struct tty_ldisc *ld;
42824 diff --git a/drivers/tty/hvc/hvc_console.c b/drivers/tty/hvc/hvc_console.c
42825 index eb255e8..f637a57 100644
42826 --- a/drivers/tty/hvc/hvc_console.c
42827 +++ b/drivers/tty/hvc/hvc_console.c
42828 @@ -338,7 +338,7 @@ static int hvc_open(struct tty_struct *tty, struct file * filp)
42829
42830 spin_lock_irqsave(&hp->port.lock, flags);
42831 /* Check and then increment for fast path open. */
42832 - if (hp->port.count++ > 0) {
42833 + if (atomic_inc_return(&hp->port.count) > 1) {
42834 spin_unlock_irqrestore(&hp->port.lock, flags);
42835 hvc_kick();
42836 return 0;
42837 @@ -388,7 +388,7 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
42838
42839 spin_lock_irqsave(&hp->port.lock, flags);
42840
42841 - if (--hp->port.count == 0) {
42842 + if (atomic_dec_return(&hp->port.count) == 0) {
42843 spin_unlock_irqrestore(&hp->port.lock, flags);
42844 /* We are done with the tty pointer now. */
42845 tty_port_tty_set(&hp->port, NULL);
42846 @@ -406,9 +406,9 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
42847 */
42848 tty_wait_until_sent_from_close(tty, HVC_CLOSE_WAIT);
42849 } else {
42850 - if (hp->port.count < 0)
42851 + if (atomic_read(&hp->port.count) < 0)
42852 printk(KERN_ERR "hvc_close %X: oops, count is %d\n",
42853 - hp->vtermno, hp->port.count);
42854 + hp->vtermno, atomic_read(&hp->port.count));
42855 spin_unlock_irqrestore(&hp->port.lock, flags);
42856 }
42857 }
42858 @@ -438,12 +438,12 @@ static void hvc_hangup(struct tty_struct *tty)
42859 * open->hangup case this can be called after the final close so prevent
42860 * that from happening for now.
42861 */
42862 - if (hp->port.count <= 0) {
42863 + if (atomic_read(&hp->port.count) <= 0) {
42864 spin_unlock_irqrestore(&hp->port.lock, flags);
42865 return;
42866 }
42867
42868 - hp->port.count = 0;
42869 + atomic_set(&hp->port.count, 0);
42870 spin_unlock_irqrestore(&hp->port.lock, flags);
42871 tty_port_tty_set(&hp->port, NULL);
42872
42873 @@ -491,7 +491,7 @@ static int hvc_write(struct tty_struct *tty, const unsigned char *buf, int count
42874 return -EPIPE;
42875
42876 /* FIXME what's this (unprotected) check for? */
42877 - if (hp->port.count <= 0)
42878 + if (atomic_read(&hp->port.count) <= 0)
42879 return -EIO;
42880
42881 spin_lock_irqsave(&hp->lock, flags);
42882 diff --git a/drivers/tty/hvc/hvcs.c b/drivers/tty/hvc/hvcs.c
42883 index 81e939e..95ead10 100644
42884 --- a/drivers/tty/hvc/hvcs.c
42885 +++ b/drivers/tty/hvc/hvcs.c
42886 @@ -83,6 +83,7 @@
42887 #include <asm/hvcserver.h>
42888 #include <asm/uaccess.h>
42889 #include <asm/vio.h>
42890 +#include <asm/local.h>
42891
42892 /*
42893 * 1.3.0 -> 1.3.1 In hvcs_open memset(..,0x00,..) instead of memset(..,0x3F,00).
42894 @@ -416,7 +417,7 @@ static ssize_t hvcs_vterm_state_store(struct device *dev, struct device_attribut
42895
42896 spin_lock_irqsave(&hvcsd->lock, flags);
42897
42898 - if (hvcsd->port.count > 0) {
42899 + if (atomic_read(&hvcsd->port.count) > 0) {
42900 spin_unlock_irqrestore(&hvcsd->lock, flags);
42901 printk(KERN_INFO "HVCS: vterm state unchanged. "
42902 "The hvcs device node is still in use.\n");
42903 @@ -1127,7 +1128,7 @@ static int hvcs_install(struct tty_driver *driver, struct tty_struct *tty)
42904 }
42905 }
42906
42907 - hvcsd->port.count = 0;
42908 + atomic_set(&hvcsd->port.count, 0);
42909 hvcsd->port.tty = tty;
42910 tty->driver_data = hvcsd;
42911
42912 @@ -1180,7 +1181,7 @@ static int hvcs_open(struct tty_struct *tty, struct file *filp)
42913 unsigned long flags;
42914
42915 spin_lock_irqsave(&hvcsd->lock, flags);
42916 - hvcsd->port.count++;
42917 + atomic_inc(&hvcsd->port.count);
42918 hvcsd->todo_mask |= HVCS_SCHED_READ;
42919 spin_unlock_irqrestore(&hvcsd->lock, flags);
42920
42921 @@ -1216,7 +1217,7 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp)
42922 hvcsd = tty->driver_data;
42923
42924 spin_lock_irqsave(&hvcsd->lock, flags);
42925 - if (--hvcsd->port.count == 0) {
42926 + if (atomic_dec_and_test(&hvcsd->port.count)) {
42927
42928 vio_disable_interrupts(hvcsd->vdev);
42929
42930 @@ -1241,10 +1242,10 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp)
42931
42932 free_irq(irq, hvcsd);
42933 return;
42934 - } else if (hvcsd->port.count < 0) {
42935 + } else if (atomic_read(&hvcsd->port.count) < 0) {
42936 printk(KERN_ERR "HVCS: vty-server@%X open_count: %d"
42937 " is missmanaged.\n",
42938 - hvcsd->vdev->unit_address, hvcsd->port.count);
42939 + hvcsd->vdev->unit_address, atomic_read(&hvcsd->port.count));
42940 }
42941
42942 spin_unlock_irqrestore(&hvcsd->lock, flags);
42943 @@ -1266,7 +1267,7 @@ static void hvcs_hangup(struct tty_struct * tty)
42944
42945 spin_lock_irqsave(&hvcsd->lock, flags);
42946 /* Preserve this so that we know how many kref refs to put */
42947 - temp_open_count = hvcsd->port.count;
42948 + temp_open_count = atomic_read(&hvcsd->port.count);
42949
42950 /*
42951 * Don't kref put inside the spinlock because the destruction
42952 @@ -1281,7 +1282,7 @@ static void hvcs_hangup(struct tty_struct * tty)
42953 tty->driver_data = NULL;
42954 hvcsd->port.tty = NULL;
42955
42956 - hvcsd->port.count = 0;
42957 + atomic_set(&hvcsd->port.count, 0);
42958
42959 /* This will drop any buffered data on the floor which is OK in a hangup
42960 * scenario. */
42961 @@ -1352,7 +1353,7 @@ static int hvcs_write(struct tty_struct *tty,
42962 * the middle of a write operation? This is a crummy place to do this
42963 * but we want to keep it all in the spinlock.
42964 */
42965 - if (hvcsd->port.count <= 0) {
42966 + if (atomic_read(&hvcsd->port.count) <= 0) {
42967 spin_unlock_irqrestore(&hvcsd->lock, flags);
42968 return -ENODEV;
42969 }
42970 @@ -1426,7 +1427,7 @@ static int hvcs_write_room(struct tty_struct *tty)
42971 {
42972 struct hvcs_struct *hvcsd = tty->driver_data;
42973
42974 - if (!hvcsd || hvcsd->port.count <= 0)
42975 + if (!hvcsd || atomic_read(&hvcsd->port.count) <= 0)
42976 return 0;
42977
42978 return HVCS_BUFF_LEN - hvcsd->chars_in_buffer;
42979 diff --git a/drivers/tty/ipwireless/tty.c b/drivers/tty/ipwireless/tty.c
42980 index 8fd72ff..34a0bed 100644
42981 --- a/drivers/tty/ipwireless/tty.c
42982 +++ b/drivers/tty/ipwireless/tty.c
42983 @@ -29,6 +29,7 @@
42984 #include <linux/tty_driver.h>
42985 #include <linux/tty_flip.h>
42986 #include <linux/uaccess.h>
42987 +#include <asm/local.h>
42988
42989 #include "tty.h"
42990 #include "network.h"
42991 @@ -99,10 +100,10 @@ static int ipw_open(struct tty_struct *linux_tty, struct file *filp)
42992 mutex_unlock(&tty->ipw_tty_mutex);
42993 return -ENODEV;
42994 }
42995 - if (tty->port.count == 0)
42996 + if (atomic_read(&tty->port.count) == 0)
42997 tty->tx_bytes_queued = 0;
42998
42999 - tty->port.count++;
43000 + atomic_inc(&tty->port.count);
43001
43002 tty->port.tty = linux_tty;
43003 linux_tty->driver_data = tty;
43004 @@ -118,9 +119,7 @@ static int ipw_open(struct tty_struct *linux_tty, struct file *filp)
43005
43006 static void do_ipw_close(struct ipw_tty *tty)
43007 {
43008 - tty->port.count--;
43009 -
43010 - if (tty->port.count == 0) {
43011 + if (atomic_dec_return(&tty->port.count) == 0) {
43012 struct tty_struct *linux_tty = tty->port.tty;
43013
43014 if (linux_tty != NULL) {
43015 @@ -141,7 +140,7 @@ static void ipw_hangup(struct tty_struct *linux_tty)
43016 return;
43017
43018 mutex_lock(&tty->ipw_tty_mutex);
43019 - if (tty->port.count == 0) {
43020 + if (atomic_read(&tty->port.count) == 0) {
43021 mutex_unlock(&tty->ipw_tty_mutex);
43022 return;
43023 }
43024 @@ -164,7 +163,7 @@ void ipwireless_tty_received(struct ipw_tty *tty, unsigned char *data,
43025
43026 mutex_lock(&tty->ipw_tty_mutex);
43027
43028 - if (!tty->port.count) {
43029 + if (!atomic_read(&tty->port.count)) {
43030 mutex_unlock(&tty->ipw_tty_mutex);
43031 return;
43032 }
43033 @@ -206,7 +205,7 @@ static int ipw_write(struct tty_struct *linux_tty,
43034 return -ENODEV;
43035
43036 mutex_lock(&tty->ipw_tty_mutex);
43037 - if (!tty->port.count) {
43038 + if (!atomic_read(&tty->port.count)) {
43039 mutex_unlock(&tty->ipw_tty_mutex);
43040 return -EINVAL;
43041 }
43042 @@ -246,7 +245,7 @@ static int ipw_write_room(struct tty_struct *linux_tty)
43043 if (!tty)
43044 return -ENODEV;
43045
43046 - if (!tty->port.count)
43047 + if (!atomic_read(&tty->port.count))
43048 return -EINVAL;
43049
43050 room = IPWIRELESS_TX_QUEUE_SIZE - tty->tx_bytes_queued;
43051 @@ -288,7 +287,7 @@ static int ipw_chars_in_buffer(struct tty_struct *linux_tty)
43052 if (!tty)
43053 return 0;
43054
43055 - if (!tty->port.count)
43056 + if (!atomic_read(&tty->port.count))
43057 return 0;
43058
43059 return tty->tx_bytes_queued;
43060 @@ -369,7 +368,7 @@ static int ipw_tiocmget(struct tty_struct *linux_tty)
43061 if (!tty)
43062 return -ENODEV;
43063
43064 - if (!tty->port.count)
43065 + if (!atomic_read(&tty->port.count))
43066 return -EINVAL;
43067
43068 return get_control_lines(tty);
43069 @@ -385,7 +384,7 @@ ipw_tiocmset(struct tty_struct *linux_tty,
43070 if (!tty)
43071 return -ENODEV;
43072
43073 - if (!tty->port.count)
43074 + if (!atomic_read(&tty->port.count))
43075 return -EINVAL;
43076
43077 return set_control_lines(tty, set, clear);
43078 @@ -399,7 +398,7 @@ static int ipw_ioctl(struct tty_struct *linux_tty,
43079 if (!tty)
43080 return -ENODEV;
43081
43082 - if (!tty->port.count)
43083 + if (!atomic_read(&tty->port.count))
43084 return -EINVAL;
43085
43086 /* FIXME: Exactly how is the tty object locked here .. */
43087 @@ -555,7 +554,7 @@ void ipwireless_tty_free(struct ipw_tty *tty)
43088 * are gone */
43089 mutex_lock(&ttyj->ipw_tty_mutex);
43090 }
43091 - while (ttyj->port.count)
43092 + while (atomic_read(&ttyj->port.count))
43093 do_ipw_close(ttyj);
43094 ipwireless_disassociate_network_ttys(network,
43095 ttyj->channel_idx);
43096 diff --git a/drivers/tty/moxa.c b/drivers/tty/moxa.c
43097 index adeac25..787a0a1 100644
43098 --- a/drivers/tty/moxa.c
43099 +++ b/drivers/tty/moxa.c
43100 @@ -1193,7 +1193,7 @@ static int moxa_open(struct tty_struct *tty, struct file *filp)
43101 }
43102
43103 ch = &brd->ports[port % MAX_PORTS_PER_BOARD];
43104 - ch->port.count++;
43105 + atomic_inc(&ch->port.count);
43106 tty->driver_data = ch;
43107 tty_port_tty_set(&ch->port, tty);
43108 mutex_lock(&ch->port.mutex);
43109 diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
43110 index 4a43ef5d7..aa71f27 100644
43111 --- a/drivers/tty/n_gsm.c
43112 +++ b/drivers/tty/n_gsm.c
43113 @@ -1636,7 +1636,7 @@ static struct gsm_dlci *gsm_dlci_alloc(struct gsm_mux *gsm, int addr)
43114 spin_lock_init(&dlci->lock);
43115 mutex_init(&dlci->mutex);
43116 dlci->fifo = &dlci->_fifo;
43117 - if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL) < 0) {
43118 + if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL)) {
43119 kfree(dlci);
43120 return NULL;
43121 }
43122 @@ -2936,7 +2936,7 @@ static int gsmtty_open(struct tty_struct *tty, struct file *filp)
43123 struct gsm_dlci *dlci = tty->driver_data;
43124 struct tty_port *port = &dlci->port;
43125
43126 - port->count++;
43127 + atomic_inc(&port->count);
43128 dlci_get(dlci);
43129 dlci_get(dlci->gsm->dlci[0]);
43130 mux_get(dlci->gsm);
43131 diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
43132 index 1f8cba6..47b06c2 100644
43133 --- a/drivers/tty/n_tty.c
43134 +++ b/drivers/tty/n_tty.c
43135 @@ -2205,6 +2205,7 @@ void n_tty_inherit_ops(struct tty_ldisc_ops *ops)
43136 {
43137 *ops = tty_ldisc_N_TTY;
43138 ops->owner = NULL;
43139 - ops->refcount = ops->flags = 0;
43140 + atomic_set(&ops->refcount, 0);
43141 + ops->flags = 0;
43142 }
43143 EXPORT_SYMBOL_GPL(n_tty_inherit_ops);
43144 diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
43145 index 125e0fd..8c50690 100644
43146 --- a/drivers/tty/pty.c
43147 +++ b/drivers/tty/pty.c
43148 @@ -800,8 +800,10 @@ static void __init unix98_pty_init(void)
43149 panic("Couldn't register Unix98 pts driver");
43150
43151 /* Now create the /dev/ptmx special device */
43152 + pax_open_kernel();
43153 tty_default_fops(&ptmx_fops);
43154 - ptmx_fops.open = ptmx_open;
43155 + *(void **)&ptmx_fops.open = ptmx_open;
43156 + pax_close_kernel();
43157
43158 cdev_init(&ptmx_cdev, &ptmx_fops);
43159 if (cdev_add(&ptmx_cdev, MKDEV(TTYAUX_MAJOR, 2), 1) ||
43160 diff --git a/drivers/tty/rocket.c b/drivers/tty/rocket.c
43161 index 1d27003..959f452 100644
43162 --- a/drivers/tty/rocket.c
43163 +++ b/drivers/tty/rocket.c
43164 @@ -923,7 +923,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
43165 tty->driver_data = info;
43166 tty_port_tty_set(port, tty);
43167
43168 - if (port->count++ == 0) {
43169 + if (atomic_inc_return(&port->count) == 1) {
43170 atomic_inc(&rp_num_ports_open);
43171
43172 #ifdef ROCKET_DEBUG_OPEN
43173 @@ -932,7 +932,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
43174 #endif
43175 }
43176 #ifdef ROCKET_DEBUG_OPEN
43177 - printk(KERN_INFO "rp_open ttyR%d, count=%d\n", info->line, info->port.count);
43178 + printk(KERN_INFO "rp_open ttyR%d, count=%d\n", info->line, atomic-read(&info->port.count));
43179 #endif
43180
43181 /*
43182 @@ -1527,7 +1527,7 @@ static void rp_hangup(struct tty_struct *tty)
43183 spin_unlock_irqrestore(&info->port.lock, flags);
43184 return;
43185 }
43186 - if (info->port.count)
43187 + if (atomic_read(&info->port.count))
43188 atomic_dec(&rp_num_ports_open);
43189 clear_bit((info->aiop * 8) + info->chan, (void *) &xmit_flags[info->board]);
43190 spin_unlock_irqrestore(&info->port.lock, flags);
43191 diff --git a/drivers/tty/serial/kgdboc.c b/drivers/tty/serial/kgdboc.c
43192 index 1002054..dd644a8 100644
43193 --- a/drivers/tty/serial/kgdboc.c
43194 +++ b/drivers/tty/serial/kgdboc.c
43195 @@ -24,8 +24,9 @@
43196 #define MAX_CONFIG_LEN 40
43197
43198 static struct kgdb_io kgdboc_io_ops;
43199 +static struct kgdb_io kgdboc_io_ops_console;
43200
43201 -/* -1 = init not run yet, 0 = unconfigured, 1 = configured. */
43202 +/* -1 = init not run yet, 0 = unconfigured, 1/2 = configured. */
43203 static int configured = -1;
43204
43205 static char config[MAX_CONFIG_LEN];
43206 @@ -151,6 +152,8 @@ static void cleanup_kgdboc(void)
43207 kgdboc_unregister_kbd();
43208 if (configured == 1)
43209 kgdb_unregister_io_module(&kgdboc_io_ops);
43210 + else if (configured == 2)
43211 + kgdb_unregister_io_module(&kgdboc_io_ops_console);
43212 }
43213
43214 static int configure_kgdboc(void)
43215 @@ -160,13 +163,13 @@ static int configure_kgdboc(void)
43216 int err;
43217 char *cptr = config;
43218 struct console *cons;
43219 + int is_console = 0;
43220
43221 err = kgdboc_option_setup(config);
43222 if (err || !strlen(config) || isspace(config[0]))
43223 goto noconfig;
43224
43225 err = -ENODEV;
43226 - kgdboc_io_ops.is_console = 0;
43227 kgdb_tty_driver = NULL;
43228
43229 kgdboc_use_kms = 0;
43230 @@ -187,7 +190,7 @@ static int configure_kgdboc(void)
43231 int idx;
43232 if (cons->device && cons->device(cons, &idx) == p &&
43233 idx == tty_line) {
43234 - kgdboc_io_ops.is_console = 1;
43235 + is_console = 1;
43236 break;
43237 }
43238 cons = cons->next;
43239 @@ -197,7 +200,13 @@ static int configure_kgdboc(void)
43240 kgdb_tty_line = tty_line;
43241
43242 do_register:
43243 - err = kgdb_register_io_module(&kgdboc_io_ops);
43244 + if (is_console) {
43245 + err = kgdb_register_io_module(&kgdboc_io_ops_console);
43246 + configured = 2;
43247 + } else {
43248 + err = kgdb_register_io_module(&kgdboc_io_ops);
43249 + configured = 1;
43250 + }
43251 if (err)
43252 goto noconfig;
43253
43254 @@ -205,8 +214,6 @@ do_register:
43255 if (err)
43256 goto nmi_con_failed;
43257
43258 - configured = 1;
43259 -
43260 return 0;
43261
43262 nmi_con_failed:
43263 @@ -223,7 +230,7 @@ noconfig:
43264 static int __init init_kgdboc(void)
43265 {
43266 /* Already configured? */
43267 - if (configured == 1)
43268 + if (configured >= 1)
43269 return 0;
43270
43271 return configure_kgdboc();
43272 @@ -272,7 +279,7 @@ static int param_set_kgdboc_var(const char *kmessage, struct kernel_param *kp)
43273 if (config[len - 1] == '\n')
43274 config[len - 1] = '\0';
43275
43276 - if (configured == 1)
43277 + if (configured >= 1)
43278 cleanup_kgdboc();
43279
43280 /* Go and configure with the new params. */
43281 @@ -312,6 +319,15 @@ static struct kgdb_io kgdboc_io_ops = {
43282 .post_exception = kgdboc_post_exp_handler,
43283 };
43284
43285 +static struct kgdb_io kgdboc_io_ops_console = {
43286 + .name = "kgdboc",
43287 + .read_char = kgdboc_get_char,
43288 + .write_char = kgdboc_put_char,
43289 + .pre_exception = kgdboc_pre_exp_handler,
43290 + .post_exception = kgdboc_post_exp_handler,
43291 + .is_console = 1
43292 +};
43293 +
43294 #ifdef CONFIG_KGDB_SERIAL_CONSOLE
43295 /* This is only available if kgdboc is a built in for early debugging */
43296 static int __init kgdboc_early_init(char *opt)
43297 diff --git a/drivers/tty/serial/samsung.c b/drivers/tty/serial/samsung.c
43298 index 2769a38..f3dbe48 100644
43299 --- a/drivers/tty/serial/samsung.c
43300 +++ b/drivers/tty/serial/samsung.c
43301 @@ -451,11 +451,16 @@ static void s3c24xx_serial_shutdown(struct uart_port *port)
43302 }
43303 }
43304
43305 +static int s3c64xx_serial_startup(struct uart_port *port);
43306 static int s3c24xx_serial_startup(struct uart_port *port)
43307 {
43308 struct s3c24xx_uart_port *ourport = to_ourport(port);
43309 int ret;
43310
43311 + /* Startup sequence is different for s3c64xx and higher SoC's */
43312 + if (s3c24xx_serial_has_interrupt_mask(port))
43313 + return s3c64xx_serial_startup(port);
43314 +
43315 dbg("s3c24xx_serial_startup: port=%p (%08lx,%p)\n",
43316 port->mapbase, port->membase);
43317
43318 @@ -1120,10 +1125,6 @@ static int s3c24xx_serial_init_port(struct s3c24xx_uart_port *ourport,
43319 /* setup info for port */
43320 port->dev = &platdev->dev;
43321
43322 - /* Startup sequence is different for s3c64xx and higher SoC's */
43323 - if (s3c24xx_serial_has_interrupt_mask(port))
43324 - s3c24xx_serial_ops.startup = s3c64xx_serial_startup;
43325 -
43326 port->uartclk = 1;
43327
43328 if (cfg->uart_flags & UPF_CONS_FLOW) {
43329 diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
43330 index 8fbb6d2..822a9e6 100644
43331 --- a/drivers/tty/serial/serial_core.c
43332 +++ b/drivers/tty/serial/serial_core.c
43333 @@ -1454,7 +1454,7 @@ static void uart_hangup(struct tty_struct *tty)
43334 uart_flush_buffer(tty);
43335 uart_shutdown(tty, state);
43336 spin_lock_irqsave(&port->lock, flags);
43337 - port->count = 0;
43338 + atomic_set(&port->count, 0);
43339 clear_bit(ASYNCB_NORMAL_ACTIVE, &port->flags);
43340 spin_unlock_irqrestore(&port->lock, flags);
43341 tty_port_tty_set(port, NULL);
43342 @@ -1550,7 +1550,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
43343 goto end;
43344 }
43345
43346 - port->count++;
43347 + atomic_inc(&port->count);
43348 if (!state->uart_port || state->uart_port->flags & UPF_DEAD) {
43349 retval = -ENXIO;
43350 goto err_dec_count;
43351 @@ -1578,7 +1578,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
43352 /*
43353 * Make sure the device is in D0 state.
43354 */
43355 - if (port->count == 1)
43356 + if (atomic_read(&port->count) == 1)
43357 uart_change_pm(state, UART_PM_STATE_ON);
43358
43359 /*
43360 @@ -1596,7 +1596,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
43361 end:
43362 return retval;
43363 err_dec_count:
43364 - port->count--;
43365 + atomic_inc(&port->count);
43366 mutex_unlock(&port->mutex);
43367 goto end;
43368 }
43369 diff --git a/drivers/tty/synclink.c b/drivers/tty/synclink.c
43370 index 8983276..72a4090 100644
43371 --- a/drivers/tty/synclink.c
43372 +++ b/drivers/tty/synclink.c
43373 @@ -3093,7 +3093,7 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
43374
43375 if (debug_level >= DEBUG_LEVEL_INFO)
43376 printk("%s(%d):mgsl_close(%s) entry, count=%d\n",
43377 - __FILE__,__LINE__, info->device_name, info->port.count);
43378 + __FILE__,__LINE__, info->device_name, atomic_read(&info->port.count));
43379
43380 if (tty_port_close_start(&info->port, tty, filp) == 0)
43381 goto cleanup;
43382 @@ -3111,7 +3111,7 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
43383 cleanup:
43384 if (debug_level >= DEBUG_LEVEL_INFO)
43385 printk("%s(%d):mgsl_close(%s) exit, count=%d\n", __FILE__,__LINE__,
43386 - tty->driver->name, info->port.count);
43387 + tty->driver->name, atomic_read(&info->port.count));
43388
43389 } /* end of mgsl_close() */
43390
43391 @@ -3210,8 +3210,8 @@ static void mgsl_hangup(struct tty_struct *tty)
43392
43393 mgsl_flush_buffer(tty);
43394 shutdown(info);
43395 -
43396 - info->port.count = 0;
43397 +
43398 + atomic_set(&info->port.count, 0);
43399 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
43400 info->port.tty = NULL;
43401
43402 @@ -3300,12 +3300,12 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
43403
43404 if (debug_level >= DEBUG_LEVEL_INFO)
43405 printk("%s(%d):block_til_ready before block on %s count=%d\n",
43406 - __FILE__,__LINE__, tty->driver->name, port->count );
43407 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
43408
43409 spin_lock_irqsave(&info->irq_spinlock, flags);
43410 if (!tty_hung_up_p(filp)) {
43411 extra_count = true;
43412 - port->count--;
43413 + atomic_dec(&port->count);
43414 }
43415 spin_unlock_irqrestore(&info->irq_spinlock, flags);
43416 port->blocked_open++;
43417 @@ -3334,7 +3334,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
43418
43419 if (debug_level >= DEBUG_LEVEL_INFO)
43420 printk("%s(%d):block_til_ready blocking on %s count=%d\n",
43421 - __FILE__,__LINE__, tty->driver->name, port->count );
43422 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
43423
43424 tty_unlock(tty);
43425 schedule();
43426 @@ -3346,12 +3346,12 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
43427
43428 /* FIXME: Racy on hangup during close wait */
43429 if (extra_count)
43430 - port->count++;
43431 + atomic_inc(&port->count);
43432 port->blocked_open--;
43433
43434 if (debug_level >= DEBUG_LEVEL_INFO)
43435 printk("%s(%d):block_til_ready after blocking on %s count=%d\n",
43436 - __FILE__,__LINE__, tty->driver->name, port->count );
43437 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
43438
43439 if (!retval)
43440 port->flags |= ASYNC_NORMAL_ACTIVE;
43441 @@ -3403,7 +3403,7 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
43442
43443 if (debug_level >= DEBUG_LEVEL_INFO)
43444 printk("%s(%d):mgsl_open(%s), old ref count = %d\n",
43445 - __FILE__,__LINE__,tty->driver->name, info->port.count);
43446 + __FILE__,__LINE__,tty->driver->name, atomic_read(&info->port.count));
43447
43448 /* If port is closing, signal caller to try again */
43449 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
43450 @@ -3422,10 +3422,10 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
43451 spin_unlock_irqrestore(&info->netlock, flags);
43452 goto cleanup;
43453 }
43454 - info->port.count++;
43455 + atomic_inc(&info->port.count);
43456 spin_unlock_irqrestore(&info->netlock, flags);
43457
43458 - if (info->port.count == 1) {
43459 + if (atomic_read(&info->port.count) == 1) {
43460 /* 1st open on this device, init hardware */
43461 retval = startup(info);
43462 if (retval < 0)
43463 @@ -3449,8 +3449,8 @@ cleanup:
43464 if (retval) {
43465 if (tty->count == 1)
43466 info->port.tty = NULL; /* tty layer will release tty struct */
43467 - if(info->port.count)
43468 - info->port.count--;
43469 + if (atomic_read(&info->port.count))
43470 + atomic_dec(&info->port.count);
43471 }
43472
43473 return retval;
43474 @@ -7668,7 +7668,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
43475 unsigned short new_crctype;
43476
43477 /* return error if TTY interface open */
43478 - if (info->port.count)
43479 + if (atomic_read(&info->port.count))
43480 return -EBUSY;
43481
43482 switch (encoding)
43483 @@ -7763,7 +7763,7 @@ static int hdlcdev_open(struct net_device *dev)
43484
43485 /* arbitrate between network and tty opens */
43486 spin_lock_irqsave(&info->netlock, flags);
43487 - if (info->port.count != 0 || info->netcount != 0) {
43488 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
43489 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
43490 spin_unlock_irqrestore(&info->netlock, flags);
43491 return -EBUSY;
43492 @@ -7849,7 +7849,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
43493 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
43494
43495 /* return error if TTY interface open */
43496 - if (info->port.count)
43497 + if (atomic_read(&info->port.count))
43498 return -EBUSY;
43499
43500 if (cmd != SIOCWANDEV)
43501 diff --git a/drivers/tty/synclink_gt.c b/drivers/tty/synclink_gt.c
43502 index aa9eece..d8baaec 100644
43503 --- a/drivers/tty/synclink_gt.c
43504 +++ b/drivers/tty/synclink_gt.c
43505 @@ -670,7 +670,7 @@ static int open(struct tty_struct *tty, struct file *filp)
43506 tty->driver_data = info;
43507 info->port.tty = tty;
43508
43509 - DBGINFO(("%s open, old ref count = %d\n", info->device_name, info->port.count));
43510 + DBGINFO(("%s open, old ref count = %d\n", info->device_name, atomic_read(&info->port.count)));
43511
43512 /* If port is closing, signal caller to try again */
43513 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
43514 @@ -691,10 +691,10 @@ static int open(struct tty_struct *tty, struct file *filp)
43515 mutex_unlock(&info->port.mutex);
43516 goto cleanup;
43517 }
43518 - info->port.count++;
43519 + atomic_inc(&info->port.count);
43520 spin_unlock_irqrestore(&info->netlock, flags);
43521
43522 - if (info->port.count == 1) {
43523 + if (atomic_read(&info->port.count) == 1) {
43524 /* 1st open on this device, init hardware */
43525 retval = startup(info);
43526 if (retval < 0) {
43527 @@ -715,8 +715,8 @@ cleanup:
43528 if (retval) {
43529 if (tty->count == 1)
43530 info->port.tty = NULL; /* tty layer will release tty struct */
43531 - if(info->port.count)
43532 - info->port.count--;
43533 + if(atomic_read(&info->port.count))
43534 + atomic_dec(&info->port.count);
43535 }
43536
43537 DBGINFO(("%s open rc=%d\n", info->device_name, retval));
43538 @@ -729,7 +729,7 @@ static void close(struct tty_struct *tty, struct file *filp)
43539
43540 if (sanity_check(info, tty->name, "close"))
43541 return;
43542 - DBGINFO(("%s close entry, count=%d\n", info->device_name, info->port.count));
43543 + DBGINFO(("%s close entry, count=%d\n", info->device_name, atomic_read(&info->port.count)));
43544
43545 if (tty_port_close_start(&info->port, tty, filp) == 0)
43546 goto cleanup;
43547 @@ -746,7 +746,7 @@ static void close(struct tty_struct *tty, struct file *filp)
43548 tty_port_close_end(&info->port, tty);
43549 info->port.tty = NULL;
43550 cleanup:
43551 - DBGINFO(("%s close exit, count=%d\n", tty->driver->name, info->port.count));
43552 + DBGINFO(("%s close exit, count=%d\n", tty->driver->name, atomic_read(&info->port.count)));
43553 }
43554
43555 static void hangup(struct tty_struct *tty)
43556 @@ -764,7 +764,7 @@ static void hangup(struct tty_struct *tty)
43557 shutdown(info);
43558
43559 spin_lock_irqsave(&info->port.lock, flags);
43560 - info->port.count = 0;
43561 + atomic_set(&info->port.count, 0);
43562 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
43563 info->port.tty = NULL;
43564 spin_unlock_irqrestore(&info->port.lock, flags);
43565 @@ -1449,7 +1449,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
43566 unsigned short new_crctype;
43567
43568 /* return error if TTY interface open */
43569 - if (info->port.count)
43570 + if (atomic_read(&info->port.count))
43571 return -EBUSY;
43572
43573 DBGINFO(("%s hdlcdev_attach\n", info->device_name));
43574 @@ -1544,7 +1544,7 @@ static int hdlcdev_open(struct net_device *dev)
43575
43576 /* arbitrate between network and tty opens */
43577 spin_lock_irqsave(&info->netlock, flags);
43578 - if (info->port.count != 0 || info->netcount != 0) {
43579 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
43580 DBGINFO(("%s hdlc_open busy\n", dev->name));
43581 spin_unlock_irqrestore(&info->netlock, flags);
43582 return -EBUSY;
43583 @@ -1629,7 +1629,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
43584 DBGINFO(("%s hdlcdev_ioctl\n", dev->name));
43585
43586 /* return error if TTY interface open */
43587 - if (info->port.count)
43588 + if (atomic_read(&info->port.count))
43589 return -EBUSY;
43590
43591 if (cmd != SIOCWANDEV)
43592 @@ -2413,7 +2413,7 @@ static irqreturn_t slgt_interrupt(int dummy, void *dev_id)
43593 if (port == NULL)
43594 continue;
43595 spin_lock(&port->lock);
43596 - if ((port->port.count || port->netcount) &&
43597 + if ((atomic_read(&port->port.count) || port->netcount) &&
43598 port->pending_bh && !port->bh_running &&
43599 !port->bh_requested) {
43600 DBGISR(("%s bh queued\n", port->device_name));
43601 @@ -3302,7 +3302,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
43602 spin_lock_irqsave(&info->lock, flags);
43603 if (!tty_hung_up_p(filp)) {
43604 extra_count = true;
43605 - port->count--;
43606 + atomic_dec(&port->count);
43607 }
43608 spin_unlock_irqrestore(&info->lock, flags);
43609 port->blocked_open++;
43610 @@ -3339,7 +3339,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
43611 remove_wait_queue(&port->open_wait, &wait);
43612
43613 if (extra_count)
43614 - port->count++;
43615 + atomic_inc(&port->count);
43616 port->blocked_open--;
43617
43618 if (!retval)
43619 diff --git a/drivers/tty/synclinkmp.c b/drivers/tty/synclinkmp.c
43620 index 6d5780c..aa4d8cd 100644
43621 --- a/drivers/tty/synclinkmp.c
43622 +++ b/drivers/tty/synclinkmp.c
43623 @@ -750,7 +750,7 @@ static int open(struct tty_struct *tty, struct file *filp)
43624
43625 if (debug_level >= DEBUG_LEVEL_INFO)
43626 printk("%s(%d):%s open(), old ref count = %d\n",
43627 - __FILE__,__LINE__,tty->driver->name, info->port.count);
43628 + __FILE__,__LINE__,tty->driver->name, atomic_read(&info->port.count));
43629
43630 /* If port is closing, signal caller to try again */
43631 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
43632 @@ -769,10 +769,10 @@ static int open(struct tty_struct *tty, struct file *filp)
43633 spin_unlock_irqrestore(&info->netlock, flags);
43634 goto cleanup;
43635 }
43636 - info->port.count++;
43637 + atomic_inc(&info->port.count);
43638 spin_unlock_irqrestore(&info->netlock, flags);
43639
43640 - if (info->port.count == 1) {
43641 + if (atomic_read(&info->port.count) == 1) {
43642 /* 1st open on this device, init hardware */
43643 retval = startup(info);
43644 if (retval < 0)
43645 @@ -796,8 +796,8 @@ cleanup:
43646 if (retval) {
43647 if (tty->count == 1)
43648 info->port.tty = NULL; /* tty layer will release tty struct */
43649 - if(info->port.count)
43650 - info->port.count--;
43651 + if(atomic_read(&info->port.count))
43652 + atomic_dec(&info->port.count);
43653 }
43654
43655 return retval;
43656 @@ -815,7 +815,7 @@ static void close(struct tty_struct *tty, struct file *filp)
43657
43658 if (debug_level >= DEBUG_LEVEL_INFO)
43659 printk("%s(%d):%s close() entry, count=%d\n",
43660 - __FILE__,__LINE__, info->device_name, info->port.count);
43661 + __FILE__,__LINE__, info->device_name, atomic_read(&info->port.count));
43662
43663 if (tty_port_close_start(&info->port, tty, filp) == 0)
43664 goto cleanup;
43665 @@ -834,7 +834,7 @@ static void close(struct tty_struct *tty, struct file *filp)
43666 cleanup:
43667 if (debug_level >= DEBUG_LEVEL_INFO)
43668 printk("%s(%d):%s close() exit, count=%d\n", __FILE__,__LINE__,
43669 - tty->driver->name, info->port.count);
43670 + tty->driver->name, atomic_read(&info->port.count));
43671 }
43672
43673 /* Called by tty_hangup() when a hangup is signaled.
43674 @@ -857,7 +857,7 @@ static void hangup(struct tty_struct *tty)
43675 shutdown(info);
43676
43677 spin_lock_irqsave(&info->port.lock, flags);
43678 - info->port.count = 0;
43679 + atomic_set(&info->port.count, 0);
43680 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
43681 info->port.tty = NULL;
43682 spin_unlock_irqrestore(&info->port.lock, flags);
43683 @@ -1565,7 +1565,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
43684 unsigned short new_crctype;
43685
43686 /* return error if TTY interface open */
43687 - if (info->port.count)
43688 + if (atomic_read(&info->port.count))
43689 return -EBUSY;
43690
43691 switch (encoding)
43692 @@ -1660,7 +1660,7 @@ static int hdlcdev_open(struct net_device *dev)
43693
43694 /* arbitrate between network and tty opens */
43695 spin_lock_irqsave(&info->netlock, flags);
43696 - if (info->port.count != 0 || info->netcount != 0) {
43697 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
43698 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
43699 spin_unlock_irqrestore(&info->netlock, flags);
43700 return -EBUSY;
43701 @@ -1746,7 +1746,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
43702 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
43703
43704 /* return error if TTY interface open */
43705 - if (info->port.count)
43706 + if (atomic_read(&info->port.count))
43707 return -EBUSY;
43708
43709 if (cmd != SIOCWANDEV)
43710 @@ -2620,7 +2620,7 @@ static irqreturn_t synclinkmp_interrupt(int dummy, void *dev_id)
43711 * do not request bottom half processing if the
43712 * device is not open in a normal mode.
43713 */
43714 - if ( port && (port->port.count || port->netcount) &&
43715 + if ( port && (atomic_read(&port->port.count) || port->netcount) &&
43716 port->pending_bh && !port->bh_running &&
43717 !port->bh_requested ) {
43718 if ( debug_level >= DEBUG_LEVEL_ISR )
43719 @@ -3318,12 +3318,12 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
43720
43721 if (debug_level >= DEBUG_LEVEL_INFO)
43722 printk("%s(%d):%s block_til_ready() before block, count=%d\n",
43723 - __FILE__,__LINE__, tty->driver->name, port->count );
43724 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
43725
43726 spin_lock_irqsave(&info->lock, flags);
43727 if (!tty_hung_up_p(filp)) {
43728 extra_count = true;
43729 - port->count--;
43730 + atomic_dec(&port->count);
43731 }
43732 spin_unlock_irqrestore(&info->lock, flags);
43733 port->blocked_open++;
43734 @@ -3352,7 +3352,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
43735
43736 if (debug_level >= DEBUG_LEVEL_INFO)
43737 printk("%s(%d):%s block_til_ready() count=%d\n",
43738 - __FILE__,__LINE__, tty->driver->name, port->count );
43739 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
43740
43741 tty_unlock(tty);
43742 schedule();
43743 @@ -3363,12 +3363,12 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
43744 remove_wait_queue(&port->open_wait, &wait);
43745
43746 if (extra_count)
43747 - port->count++;
43748 + atomic_inc(&port->count);
43749 port->blocked_open--;
43750
43751 if (debug_level >= DEBUG_LEVEL_INFO)
43752 printk("%s(%d):%s block_til_ready() after, count=%d\n",
43753 - __FILE__,__LINE__, tty->driver->name, port->count );
43754 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
43755
43756 if (!retval)
43757 port->flags |= ASYNC_NORMAL_ACTIVE;
43758 diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c
43759 index 3687f0c..6b9b808 100644
43760 --- a/drivers/tty/sysrq.c
43761 +++ b/drivers/tty/sysrq.c
43762 @@ -995,7 +995,7 @@ EXPORT_SYMBOL(unregister_sysrq_key);
43763 static ssize_t write_sysrq_trigger(struct file *file, const char __user *buf,
43764 size_t count, loff_t *ppos)
43765 {
43766 - if (count) {
43767 + if (count && capable(CAP_SYS_ADMIN)) {
43768 char c;
43769
43770 if (get_user(c, buf))
43771 diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
43772 index a9cd0b9..47b9336 100644
43773 --- a/drivers/tty/tty_io.c
43774 +++ b/drivers/tty/tty_io.c
43775 @@ -3398,7 +3398,7 @@ EXPORT_SYMBOL_GPL(get_current_tty);
43776
43777 void tty_default_fops(struct file_operations *fops)
43778 {
43779 - *fops = tty_fops;
43780 + memcpy((void *)fops, &tty_fops, sizeof(tty_fops));
43781 }
43782
43783 /*
43784 diff --git a/drivers/tty/tty_ldisc.c b/drivers/tty/tty_ldisc.c
43785 index d794087..e4f49e5 100644
43786 --- a/drivers/tty/tty_ldisc.c
43787 +++ b/drivers/tty/tty_ldisc.c
43788 @@ -56,7 +56,7 @@ static void put_ldisc(struct tty_ldisc *ld)
43789 if (atomic_dec_and_test(&ld->users)) {
43790 struct tty_ldisc_ops *ldo = ld->ops;
43791
43792 - ldo->refcount--;
43793 + atomic_dec(&ldo->refcount);
43794 module_put(ldo->owner);
43795 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
43796
43797 @@ -93,7 +93,7 @@ int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc)
43798 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
43799 tty_ldiscs[disc] = new_ldisc;
43800 new_ldisc->num = disc;
43801 - new_ldisc->refcount = 0;
43802 + atomic_set(&new_ldisc->refcount, 0);
43803 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
43804
43805 return ret;
43806 @@ -121,7 +121,7 @@ int tty_unregister_ldisc(int disc)
43807 return -EINVAL;
43808
43809 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
43810 - if (tty_ldiscs[disc]->refcount)
43811 + if (atomic_read(&tty_ldiscs[disc]->refcount))
43812 ret = -EBUSY;
43813 else
43814 tty_ldiscs[disc] = NULL;
43815 @@ -142,7 +142,7 @@ static struct tty_ldisc_ops *get_ldops(int disc)
43816 if (ldops) {
43817 ret = ERR_PTR(-EAGAIN);
43818 if (try_module_get(ldops->owner)) {
43819 - ldops->refcount++;
43820 + atomic_inc(&ldops->refcount);
43821 ret = ldops;
43822 }
43823 }
43824 @@ -155,7 +155,7 @@ static void put_ldops(struct tty_ldisc_ops *ldops)
43825 unsigned long flags;
43826
43827 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
43828 - ldops->refcount--;
43829 + atomic_dec(&ldops->refcount);
43830 module_put(ldops->owner);
43831 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
43832 }
43833 diff --git a/drivers/tty/tty_port.c b/drivers/tty/tty_port.c
43834 index b7ff59d..7c6105e 100644
43835 --- a/drivers/tty/tty_port.c
43836 +++ b/drivers/tty/tty_port.c
43837 @@ -218,7 +218,7 @@ void tty_port_hangup(struct tty_port *port)
43838 unsigned long flags;
43839
43840 spin_lock_irqsave(&port->lock, flags);
43841 - port->count = 0;
43842 + atomic_set(&port->count, 0);
43843 port->flags &= ~ASYNC_NORMAL_ACTIVE;
43844 if (port->tty) {
43845 set_bit(TTY_IO_ERROR, &port->tty->flags);
43846 @@ -344,7 +344,7 @@ int tty_port_block_til_ready(struct tty_port *port,
43847 /* The port lock protects the port counts */
43848 spin_lock_irqsave(&port->lock, flags);
43849 if (!tty_hung_up_p(filp))
43850 - port->count--;
43851 + atomic_dec(&port->count);
43852 port->blocked_open++;
43853 spin_unlock_irqrestore(&port->lock, flags);
43854
43855 @@ -386,7 +386,7 @@ int tty_port_block_til_ready(struct tty_port *port,
43856 we must not mess that up further */
43857 spin_lock_irqsave(&port->lock, flags);
43858 if (!tty_hung_up_p(filp))
43859 - port->count++;
43860 + atomic_inc(&port->count);
43861 port->blocked_open--;
43862 if (retval == 0)
43863 port->flags |= ASYNC_NORMAL_ACTIVE;
43864 @@ -406,19 +406,19 @@ int tty_port_close_start(struct tty_port *port,
43865 return 0;
43866 }
43867
43868 - if (tty->count == 1 && port->count != 1) {
43869 + if (tty->count == 1 && atomic_read(&port->count) != 1) {
43870 printk(KERN_WARNING
43871 "tty_port_close_start: tty->count = 1 port count = %d.\n",
43872 - port->count);
43873 - port->count = 1;
43874 + atomic_read(&port->count));
43875 + atomic_set(&port->count, 1);
43876 }
43877 - if (--port->count < 0) {
43878 + if (atomic_dec_return(&port->count) < 0) {
43879 printk(KERN_WARNING "tty_port_close_start: count = %d\n",
43880 - port->count);
43881 - port->count = 0;
43882 + atomic_read(&port->count));
43883 + atomic_set(&port->count, 0);
43884 }
43885
43886 - if (port->count) {
43887 + if (atomic_read(&port->count)) {
43888 spin_unlock_irqrestore(&port->lock, flags);
43889 if (port->ops->drop)
43890 port->ops->drop(port);
43891 @@ -516,7 +516,7 @@ int tty_port_open(struct tty_port *port, struct tty_struct *tty,
43892 {
43893 spin_lock_irq(&port->lock);
43894 if (!tty_hung_up_p(filp))
43895 - ++port->count;
43896 + atomic_inc(&port->count);
43897 spin_unlock_irq(&port->lock);
43898 tty_port_tty_set(port, tty);
43899
43900 diff --git a/drivers/tty/vt/keyboard.c b/drivers/tty/vt/keyboard.c
43901 index a9af1b9a..1e08e7f 100644
43902 --- a/drivers/tty/vt/keyboard.c
43903 +++ b/drivers/tty/vt/keyboard.c
43904 @@ -647,6 +647,16 @@ static void k_spec(struct vc_data *vc, unsigned char value, char up_flag)
43905 kbd->kbdmode == VC_OFF) &&
43906 value != KVAL(K_SAK))
43907 return; /* SAK is allowed even in raw mode */
43908 +
43909 +#if defined(CONFIG_GRKERNSEC_PROC) || defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
43910 + {
43911 + void *func = fn_handler[value];
43912 + if (func == fn_show_state || func == fn_show_ptregs ||
43913 + func == fn_show_mem)
43914 + return;
43915 + }
43916 +#endif
43917 +
43918 fn_handler[value](vc);
43919 }
43920
43921 @@ -1795,9 +1805,6 @@ int vt_do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm,
43922 if (copy_from_user(&tmp, user_kbe, sizeof(struct kbentry)))
43923 return -EFAULT;
43924
43925 - if (!capable(CAP_SYS_TTY_CONFIG))
43926 - perm = 0;
43927 -
43928 switch (cmd) {
43929 case KDGKBENT:
43930 /* Ensure another thread doesn't free it under us */
43931 @@ -1812,6 +1819,9 @@ int vt_do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm,
43932 spin_unlock_irqrestore(&kbd_event_lock, flags);
43933 return put_user(val, &user_kbe->kb_value);
43934 case KDSKBENT:
43935 + if (!capable(CAP_SYS_TTY_CONFIG))
43936 + perm = 0;
43937 +
43938 if (!perm)
43939 return -EPERM;
43940 if (!i && v == K_NOSUCHMAP) {
43941 @@ -1902,9 +1912,6 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
43942 int i, j, k;
43943 int ret;
43944
43945 - if (!capable(CAP_SYS_TTY_CONFIG))
43946 - perm = 0;
43947 -
43948 kbs = kmalloc(sizeof(*kbs), GFP_KERNEL);
43949 if (!kbs) {
43950 ret = -ENOMEM;
43951 @@ -1938,6 +1945,9 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
43952 kfree(kbs);
43953 return ((p && *p) ? -EOVERFLOW : 0);
43954 case KDSKBSENT:
43955 + if (!capable(CAP_SYS_TTY_CONFIG))
43956 + perm = 0;
43957 +
43958 if (!perm) {
43959 ret = -EPERM;
43960 goto reterr;
43961 diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
43962 index c8b9262..7e824e6 100644
43963 --- a/drivers/uio/uio.c
43964 +++ b/drivers/uio/uio.c
43965 @@ -25,6 +25,7 @@
43966 #include <linux/kobject.h>
43967 #include <linux/cdev.h>
43968 #include <linux/uio_driver.h>
43969 +#include <asm/local.h>
43970
43971 #define UIO_MAX_DEVICES (1U << MINORBITS)
43972
43973 @@ -32,10 +33,10 @@ struct uio_device {
43974 struct module *owner;
43975 struct device *dev;
43976 int minor;
43977 - atomic_t event;
43978 + atomic_unchecked_t event;
43979 struct fasync_struct *async_queue;
43980 wait_queue_head_t wait;
43981 - int vma_count;
43982 + local_t vma_count;
43983 struct uio_info *info;
43984 struct kobject *map_dir;
43985 struct kobject *portio_dir;
43986 @@ -242,7 +243,7 @@ static ssize_t show_event(struct device *dev,
43987 struct device_attribute *attr, char *buf)
43988 {
43989 struct uio_device *idev = dev_get_drvdata(dev);
43990 - return sprintf(buf, "%u\n", (unsigned int)atomic_read(&idev->event));
43991 + return sprintf(buf, "%u\n", (unsigned int)atomic_read_unchecked(&idev->event));
43992 }
43993
43994 static struct device_attribute uio_class_attributes[] = {
43995 @@ -397,7 +398,7 @@ void uio_event_notify(struct uio_info *info)
43996 {
43997 struct uio_device *idev = info->uio_dev;
43998
43999 - atomic_inc(&idev->event);
44000 + atomic_inc_unchecked(&idev->event);
44001 wake_up_interruptible(&idev->wait);
44002 kill_fasync(&idev->async_queue, SIGIO, POLL_IN);
44003 }
44004 @@ -450,7 +451,7 @@ static int uio_open(struct inode *inode, struct file *filep)
44005 }
44006
44007 listener->dev = idev;
44008 - listener->event_count = atomic_read(&idev->event);
44009 + listener->event_count = atomic_read_unchecked(&idev->event);
44010 filep->private_data = listener;
44011
44012 if (idev->info->open) {
44013 @@ -501,7 +502,7 @@ static unsigned int uio_poll(struct file *filep, poll_table *wait)
44014 return -EIO;
44015
44016 poll_wait(filep, &idev->wait, wait);
44017 - if (listener->event_count != atomic_read(&idev->event))
44018 + if (listener->event_count != atomic_read_unchecked(&idev->event))
44019 return POLLIN | POLLRDNORM;
44020 return 0;
44021 }
44022 @@ -526,7 +527,7 @@ static ssize_t uio_read(struct file *filep, char __user *buf,
44023 do {
44024 set_current_state(TASK_INTERRUPTIBLE);
44025
44026 - event_count = atomic_read(&idev->event);
44027 + event_count = atomic_read_unchecked(&idev->event);
44028 if (event_count != listener->event_count) {
44029 if (copy_to_user(buf, &event_count, count))
44030 retval = -EFAULT;
44031 @@ -595,13 +596,13 @@ static int uio_find_mem_index(struct vm_area_struct *vma)
44032 static void uio_vma_open(struct vm_area_struct *vma)
44033 {
44034 struct uio_device *idev = vma->vm_private_data;
44035 - idev->vma_count++;
44036 + local_inc(&idev->vma_count);
44037 }
44038
44039 static void uio_vma_close(struct vm_area_struct *vma)
44040 {
44041 struct uio_device *idev = vma->vm_private_data;
44042 - idev->vma_count--;
44043 + local_dec(&idev->vma_count);
44044 }
44045
44046 static int uio_vma_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
44047 @@ -808,7 +809,7 @@ int __uio_register_device(struct module *owner,
44048 idev->owner = owner;
44049 idev->info = info;
44050 init_waitqueue_head(&idev->wait);
44051 - atomic_set(&idev->event, 0);
44052 + atomic_set_unchecked(&idev->event, 0);
44053
44054 ret = uio_get_minor(idev);
44055 if (ret)
44056 diff --git a/drivers/usb/atm/cxacru.c b/drivers/usb/atm/cxacru.c
44057 index 8a7eb77..c00402f 100644
44058 --- a/drivers/usb/atm/cxacru.c
44059 +++ b/drivers/usb/atm/cxacru.c
44060 @@ -473,7 +473,7 @@ static ssize_t cxacru_sysfs_store_adsl_config(struct device *dev,
44061 ret = sscanf(buf + pos, "%x=%x%n", &index, &value, &tmp);
44062 if (ret < 2)
44063 return -EINVAL;
44064 - if (index < 0 || index > 0x7f)
44065 + if (index > 0x7f)
44066 return -EINVAL;
44067 pos += tmp;
44068
44069 diff --git a/drivers/usb/atm/usbatm.c b/drivers/usb/atm/usbatm.c
44070 index 35f10bf..6a38a0b 100644
44071 --- a/drivers/usb/atm/usbatm.c
44072 +++ b/drivers/usb/atm/usbatm.c
44073 @@ -333,7 +333,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
44074 if (printk_ratelimit())
44075 atm_warn(instance, "%s: OAM not supported (vpi %d, vci %d)!\n",
44076 __func__, vpi, vci);
44077 - atomic_inc(&vcc->stats->rx_err);
44078 + atomic_inc_unchecked(&vcc->stats->rx_err);
44079 return;
44080 }
44081
44082 @@ -361,7 +361,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
44083 if (length > ATM_MAX_AAL5_PDU) {
44084 atm_rldbg(instance, "%s: bogus length %u (vcc: 0x%p)!\n",
44085 __func__, length, vcc);
44086 - atomic_inc(&vcc->stats->rx_err);
44087 + atomic_inc_unchecked(&vcc->stats->rx_err);
44088 goto out;
44089 }
44090
44091 @@ -370,14 +370,14 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
44092 if (sarb->len < pdu_length) {
44093 atm_rldbg(instance, "%s: bogus pdu_length %u (sarb->len: %u, vcc: 0x%p)!\n",
44094 __func__, pdu_length, sarb->len, vcc);
44095 - atomic_inc(&vcc->stats->rx_err);
44096 + atomic_inc_unchecked(&vcc->stats->rx_err);
44097 goto out;
44098 }
44099
44100 if (crc32_be(~0, skb_tail_pointer(sarb) - pdu_length, pdu_length) != 0xc704dd7b) {
44101 atm_rldbg(instance, "%s: packet failed crc check (vcc: 0x%p)!\n",
44102 __func__, vcc);
44103 - atomic_inc(&vcc->stats->rx_err);
44104 + atomic_inc_unchecked(&vcc->stats->rx_err);
44105 goto out;
44106 }
44107
44108 @@ -389,7 +389,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
44109 if (printk_ratelimit())
44110 atm_err(instance, "%s: no memory for skb (length: %u)!\n",
44111 __func__, length);
44112 - atomic_inc(&vcc->stats->rx_drop);
44113 + atomic_inc_unchecked(&vcc->stats->rx_drop);
44114 goto out;
44115 }
44116
44117 @@ -417,7 +417,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
44118
44119 vcc->push(vcc, skb);
44120
44121 - atomic_inc(&vcc->stats->rx);
44122 + atomic_inc_unchecked(&vcc->stats->rx);
44123 out:
44124 skb_trim(sarb, 0);
44125 }
44126 @@ -623,7 +623,7 @@ static void usbatm_tx_process(unsigned long data)
44127 struct atm_vcc *vcc = UDSL_SKB(skb)->atm.vcc;
44128
44129 usbatm_pop(vcc, skb);
44130 - atomic_inc(&vcc->stats->tx);
44131 + atomic_inc_unchecked(&vcc->stats->tx);
44132
44133 skb = skb_dequeue(&instance->sndqueue);
44134 }
44135 @@ -779,11 +779,11 @@ static int usbatm_atm_proc_read(struct atm_dev *atm_dev, loff_t * pos, char *pag
44136 if (!left--)
44137 return sprintf(page,
44138 "AAL5: tx %d ( %d err ), rx %d ( %d err, %d drop )\n",
44139 - atomic_read(&atm_dev->stats.aal5.tx),
44140 - atomic_read(&atm_dev->stats.aal5.tx_err),
44141 - atomic_read(&atm_dev->stats.aal5.rx),
44142 - atomic_read(&atm_dev->stats.aal5.rx_err),
44143 - atomic_read(&atm_dev->stats.aal5.rx_drop));
44144 + atomic_read_unchecked(&atm_dev->stats.aal5.tx),
44145 + atomic_read_unchecked(&atm_dev->stats.aal5.tx_err),
44146 + atomic_read_unchecked(&atm_dev->stats.aal5.rx),
44147 + atomic_read_unchecked(&atm_dev->stats.aal5.rx_err),
44148 + atomic_read_unchecked(&atm_dev->stats.aal5.rx_drop));
44149
44150 if (!left--) {
44151 if (instance->disconnected)
44152 diff --git a/drivers/usb/core/devices.c b/drivers/usb/core/devices.c
44153 index 2a3bbdf..91d72cf 100644
44154 --- a/drivers/usb/core/devices.c
44155 +++ b/drivers/usb/core/devices.c
44156 @@ -126,7 +126,7 @@ static const char format_endpt[] =
44157 * time it gets called.
44158 */
44159 static struct device_connect_event {
44160 - atomic_t count;
44161 + atomic_unchecked_t count;
44162 wait_queue_head_t wait;
44163 } device_event = {
44164 .count = ATOMIC_INIT(1),
44165 @@ -164,7 +164,7 @@ static const struct class_info clas_info[] = {
44166
44167 void usbfs_conn_disc_event(void)
44168 {
44169 - atomic_add(2, &device_event.count);
44170 + atomic_add_unchecked(2, &device_event.count);
44171 wake_up(&device_event.wait);
44172 }
44173
44174 @@ -652,7 +652,7 @@ static unsigned int usb_device_poll(struct file *file,
44175
44176 poll_wait(file, &device_event.wait, wait);
44177
44178 - event_count = atomic_read(&device_event.count);
44179 + event_count = atomic_read_unchecked(&device_event.count);
44180 if (file->f_version != event_count) {
44181 file->f_version = event_count;
44182 return POLLIN | POLLRDNORM;
44183 diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
44184 index f9ec44c..eb5779f 100644
44185 --- a/drivers/usb/core/hcd.c
44186 +++ b/drivers/usb/core/hcd.c
44187 @@ -1526,7 +1526,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
44188 */
44189 usb_get_urb(urb);
44190 atomic_inc(&urb->use_count);
44191 - atomic_inc(&urb->dev->urbnum);
44192 + atomic_inc_unchecked(&urb->dev->urbnum);
44193 usbmon_urb_submit(&hcd->self, urb);
44194
44195 /* NOTE requirements on root-hub callers (usbfs and the hub
44196 @@ -1553,7 +1553,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
44197 urb->hcpriv = NULL;
44198 INIT_LIST_HEAD(&urb->urb_list);
44199 atomic_dec(&urb->use_count);
44200 - atomic_dec(&urb->dev->urbnum);
44201 + atomic_dec_unchecked(&urb->dev->urbnum);
44202 if (atomic_read(&urb->reject))
44203 wake_up(&usb_kill_urb_queue);
44204 usb_put_urb(urb);
44205 diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
44206 index 444d30e..f15c850 100644
44207 --- a/drivers/usb/core/message.c
44208 +++ b/drivers/usb/core/message.c
44209 @@ -129,7 +129,7 @@ static int usb_internal_control_msg(struct usb_device *usb_dev,
44210 * method can wait for it to complete. Since you don't have a handle on the
44211 * URB used, you can't cancel the request.
44212 */
44213 -int usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request,
44214 +int __intentional_overflow(-1) usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request,
44215 __u8 requesttype, __u16 value, __u16 index, void *data,
44216 __u16 size, int timeout)
44217 {
44218 diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c
44219 index 3f81a3d..a3aa993 100644
44220 --- a/drivers/usb/core/sysfs.c
44221 +++ b/drivers/usb/core/sysfs.c
44222 @@ -239,7 +239,7 @@ show_urbnum(struct device *dev, struct device_attribute *attr, char *buf)
44223 struct usb_device *udev;
44224
44225 udev = to_usb_device(dev);
44226 - return sprintf(buf, "%d\n", atomic_read(&udev->urbnum));
44227 + return sprintf(buf, "%d\n", atomic_read_unchecked(&udev->urbnum));
44228 }
44229 static DEVICE_ATTR(urbnum, S_IRUGO, show_urbnum, NULL);
44230
44231 diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
44232 index f81b925..78d22ec 100644
44233 --- a/drivers/usb/core/usb.c
44234 +++ b/drivers/usb/core/usb.c
44235 @@ -388,7 +388,7 @@ struct usb_device *usb_alloc_dev(struct usb_device *parent,
44236 set_dev_node(&dev->dev, dev_to_node(bus->controller));
44237 dev->state = USB_STATE_ATTACHED;
44238 dev->lpm_disable_count = 1;
44239 - atomic_set(&dev->urbnum, 0);
44240 + atomic_set_unchecked(&dev->urbnum, 0);
44241
44242 INIT_LIST_HEAD(&dev->ep0.urb_list);
44243 dev->ep0.desc.bLength = USB_DT_ENDPOINT_SIZE;
44244 diff --git a/drivers/usb/early/ehci-dbgp.c b/drivers/usb/early/ehci-dbgp.c
44245 index 5e29dde..eca992f 100644
44246 --- a/drivers/usb/early/ehci-dbgp.c
44247 +++ b/drivers/usb/early/ehci-dbgp.c
44248 @@ -98,7 +98,8 @@ static inline u32 dbgp_len_update(u32 x, u32 len)
44249
44250 #ifdef CONFIG_KGDB
44251 static struct kgdb_io kgdbdbgp_io_ops;
44252 -#define dbgp_kgdb_mode (dbg_io_ops == &kgdbdbgp_io_ops)
44253 +static struct kgdb_io kgdbdbgp_io_ops_console;
44254 +#define dbgp_kgdb_mode (dbg_io_ops == &kgdbdbgp_io_ops || dbg_io_ops == &kgdbdbgp_io_ops_console)
44255 #else
44256 #define dbgp_kgdb_mode (0)
44257 #endif
44258 @@ -1047,6 +1048,13 @@ static struct kgdb_io kgdbdbgp_io_ops = {
44259 .write_char = kgdbdbgp_write_char,
44260 };
44261
44262 +static struct kgdb_io kgdbdbgp_io_ops_console = {
44263 + .name = "kgdbdbgp",
44264 + .read_char = kgdbdbgp_read_char,
44265 + .write_char = kgdbdbgp_write_char,
44266 + .is_console = 1
44267 +};
44268 +
44269 static int kgdbdbgp_wait_time;
44270
44271 static int __init kgdbdbgp_parse_config(char *str)
44272 @@ -1062,8 +1070,10 @@ static int __init kgdbdbgp_parse_config(char *str)
44273 ptr++;
44274 kgdbdbgp_wait_time = simple_strtoul(ptr, &ptr, 10);
44275 }
44276 - kgdb_register_io_module(&kgdbdbgp_io_ops);
44277 - kgdbdbgp_io_ops.is_console = early_dbgp_console.index != -1;
44278 + if (early_dbgp_console.index != -1)
44279 + kgdb_register_io_module(&kgdbdbgp_io_ops_console);
44280 + else
44281 + kgdb_register_io_module(&kgdbdbgp_io_ops);
44282
44283 return 0;
44284 }
44285 diff --git a/drivers/usb/gadget/u_serial.c b/drivers/usb/gadget/u_serial.c
44286 index b369292..9f3ba40 100644
44287 --- a/drivers/usb/gadget/u_serial.c
44288 +++ b/drivers/usb/gadget/u_serial.c
44289 @@ -733,9 +733,9 @@ static int gs_open(struct tty_struct *tty, struct file *file)
44290 spin_lock_irq(&port->port_lock);
44291
44292 /* already open? Great. */
44293 - if (port->port.count) {
44294 + if (atomic_read(&port->port.count)) {
44295 status = 0;
44296 - port->port.count++;
44297 + atomic_inc(&port->port.count);
44298
44299 /* currently opening/closing? wait ... */
44300 } else if (port->openclose) {
44301 @@ -794,7 +794,7 @@ static int gs_open(struct tty_struct *tty, struct file *file)
44302 tty->driver_data = port;
44303 port->port.tty = tty;
44304
44305 - port->port.count = 1;
44306 + atomic_set(&port->port.count, 1);
44307 port->openclose = false;
44308
44309 /* if connected, start the I/O stream */
44310 @@ -836,11 +836,11 @@ static void gs_close(struct tty_struct *tty, struct file *file)
44311
44312 spin_lock_irq(&port->port_lock);
44313
44314 - if (port->port.count != 1) {
44315 - if (port->port.count == 0)
44316 + if (atomic_read(&port->port.count) != 1) {
44317 + if (atomic_read(&port->port.count) == 0)
44318 WARN_ON(1);
44319 else
44320 - --port->port.count;
44321 + atomic_dec(&port->port.count);
44322 goto exit;
44323 }
44324
44325 @@ -850,7 +850,7 @@ static void gs_close(struct tty_struct *tty, struct file *file)
44326 * and sleep if necessary
44327 */
44328 port->openclose = true;
44329 - port->port.count = 0;
44330 + atomic_set(&port->port.count, 0);
44331
44332 gser = port->port_usb;
44333 if (gser && gser->disconnect)
44334 @@ -1066,7 +1066,7 @@ static int gs_closed(struct gs_port *port)
44335 int cond;
44336
44337 spin_lock_irq(&port->port_lock);
44338 - cond = (port->port.count == 0) && !port->openclose;
44339 + cond = (atomic_read(&port->port.count) == 0) && !port->openclose;
44340 spin_unlock_irq(&port->port_lock);
44341 return cond;
44342 }
44343 @@ -1209,7 +1209,7 @@ int gserial_connect(struct gserial *gser, u8 port_num)
44344 /* if it's already open, start I/O ... and notify the serial
44345 * protocol about open/close status (connect/disconnect).
44346 */
44347 - if (port->port.count) {
44348 + if (atomic_read(&port->port.count)) {
44349 pr_debug("gserial_connect: start ttyGS%d\n", port->port_num);
44350 gs_start_io(port);
44351 if (gser->connect)
44352 @@ -1256,7 +1256,7 @@ void gserial_disconnect(struct gserial *gser)
44353
44354 port->port_usb = NULL;
44355 gser->ioport = NULL;
44356 - if (port->port.count > 0 || port->openclose) {
44357 + if (atomic_read(&port->port.count) > 0 || port->openclose) {
44358 wake_up_interruptible(&port->drain_wait);
44359 if (port->port.tty)
44360 tty_hangup(port->port.tty);
44361 @@ -1272,7 +1272,7 @@ void gserial_disconnect(struct gserial *gser)
44362
44363 /* finally, free any unused/unusable I/O buffers */
44364 spin_lock_irqsave(&port->port_lock, flags);
44365 - if (port->port.count == 0 && !port->openclose)
44366 + if (atomic_read(&port->port.count) == 0 && !port->openclose)
44367 gs_buf_free(&port->port_write_buf);
44368 gs_free_requests(gser->out, &port->read_pool, NULL);
44369 gs_free_requests(gser->out, &port->read_queue, NULL);
44370 diff --git a/drivers/usb/serial/console.c b/drivers/usb/serial/console.c
44371 index 5f3bcd3..bfca43f 100644
44372 --- a/drivers/usb/serial/console.c
44373 +++ b/drivers/usb/serial/console.c
44374 @@ -124,7 +124,7 @@ static int usb_console_setup(struct console *co, char *options)
44375
44376 info->port = port;
44377
44378 - ++port->port.count;
44379 + atomic_inc(&port->port.count);
44380 if (!test_bit(ASYNCB_INITIALIZED, &port->port.flags)) {
44381 if (serial->type->set_termios) {
44382 /*
44383 @@ -174,7 +174,7 @@ static int usb_console_setup(struct console *co, char *options)
44384 }
44385 /* Now that any required fake tty operations are completed restore
44386 * the tty port count */
44387 - --port->port.count;
44388 + atomic_dec(&port->port.count);
44389 /* The console is special in terms of closing the device so
44390 * indicate this port is now acting as a system console. */
44391 port->port.console = 1;
44392 @@ -187,7 +187,7 @@ static int usb_console_setup(struct console *co, char *options)
44393 free_tty:
44394 kfree(tty);
44395 reset_open_count:
44396 - port->port.count = 0;
44397 + atomic_set(&port->port.count, 0);
44398 usb_autopm_put_interface(serial->interface);
44399 error_get_interface:
44400 usb_serial_put(serial);
44401 diff --git a/drivers/usb/storage/realtek_cr.c b/drivers/usb/storage/realtek_cr.c
44402 index 6c3586a..a94e621 100644
44403 --- a/drivers/usb/storage/realtek_cr.c
44404 +++ b/drivers/usb/storage/realtek_cr.c
44405 @@ -429,7 +429,7 @@ static int rts51x_read_status(struct us_data *us,
44406
44407 buf = kmalloc(len, GFP_NOIO);
44408 if (buf == NULL)
44409 - return USB_STOR_TRANSPORT_ERROR;
44410 + return -ENOMEM;
44411
44412 US_DEBUGP("%s, lun = %d\n", __func__, lun);
44413
44414 diff --git a/drivers/usb/storage/usb.h b/drivers/usb/storage/usb.h
44415 index 75f70f0..d467e1a 100644
44416 --- a/drivers/usb/storage/usb.h
44417 +++ b/drivers/usb/storage/usb.h
44418 @@ -63,7 +63,7 @@ struct us_unusual_dev {
44419 __u8 useProtocol;
44420 __u8 useTransport;
44421 int (*initFunction)(struct us_data *);
44422 -};
44423 +} __do_const;
44424
44425
44426 /* Dynamic bitflag definitions (us->dflags): used in set_bit() etc. */
44427 diff --git a/drivers/usb/wusbcore/wa-hc.h b/drivers/usb/wusbcore/wa-hc.h
44428 index d6bea3e..60b250e 100644
44429 --- a/drivers/usb/wusbcore/wa-hc.h
44430 +++ b/drivers/usb/wusbcore/wa-hc.h
44431 @@ -192,7 +192,7 @@ struct wahc {
44432 struct list_head xfer_delayed_list;
44433 spinlock_t xfer_list_lock;
44434 struct work_struct xfer_work;
44435 - atomic_t xfer_id_count;
44436 + atomic_unchecked_t xfer_id_count;
44437 };
44438
44439
44440 @@ -246,7 +246,7 @@ static inline void wa_init(struct wahc *wa)
44441 INIT_LIST_HEAD(&wa->xfer_delayed_list);
44442 spin_lock_init(&wa->xfer_list_lock);
44443 INIT_WORK(&wa->xfer_work, wa_urb_enqueue_run);
44444 - atomic_set(&wa->xfer_id_count, 1);
44445 + atomic_set_unchecked(&wa->xfer_id_count, 1);
44446 }
44447
44448 /**
44449 diff --git a/drivers/usb/wusbcore/wa-xfer.c b/drivers/usb/wusbcore/wa-xfer.c
44450 index 6ef94bc..1b41265 100644
44451 --- a/drivers/usb/wusbcore/wa-xfer.c
44452 +++ b/drivers/usb/wusbcore/wa-xfer.c
44453 @@ -296,7 +296,7 @@ out:
44454 */
44455 static void wa_xfer_id_init(struct wa_xfer *xfer)
44456 {
44457 - xfer->id = atomic_add_return(1, &xfer->wa->xfer_id_count);
44458 + xfer->id = atomic_add_return_unchecked(1, &xfer->wa->xfer_id_count);
44459 }
44460
44461 /*
44462 diff --git a/drivers/video/aty/aty128fb.c b/drivers/video/aty/aty128fb.c
44463 index 8c55011..eed4ae1a 100644
44464 --- a/drivers/video/aty/aty128fb.c
44465 +++ b/drivers/video/aty/aty128fb.c
44466 @@ -149,7 +149,7 @@ enum {
44467 };
44468
44469 /* Must match above enum */
44470 -static char * const r128_family[] = {
44471 +static const char * const r128_family[] = {
44472 "AGP",
44473 "PCI",
44474 "PRO AGP",
44475 diff --git a/drivers/video/aty/atyfb_base.c b/drivers/video/aty/atyfb_base.c
44476 index 4f27fdc..d3537e6 100644
44477 --- a/drivers/video/aty/atyfb_base.c
44478 +++ b/drivers/video/aty/atyfb_base.c
44479 @@ -1325,10 +1325,14 @@ static int atyfb_set_par(struct fb_info *info)
44480 par->accel_flags = var->accel_flags; /* hack */
44481
44482 if (var->accel_flags) {
44483 - info->fbops->fb_sync = atyfb_sync;
44484 + pax_open_kernel();
44485 + *(void **)&info->fbops->fb_sync = atyfb_sync;
44486 + pax_close_kernel();
44487 info->flags &= ~FBINFO_HWACCEL_DISABLED;
44488 } else {
44489 - info->fbops->fb_sync = NULL;
44490 + pax_open_kernel();
44491 + *(void **)&info->fbops->fb_sync = NULL;
44492 + pax_close_kernel();
44493 info->flags |= FBINFO_HWACCEL_DISABLED;
44494 }
44495
44496 diff --git a/drivers/video/aty/mach64_cursor.c b/drivers/video/aty/mach64_cursor.c
44497 index 95ec042..e6affdd 100644
44498 --- a/drivers/video/aty/mach64_cursor.c
44499 +++ b/drivers/video/aty/mach64_cursor.c
44500 @@ -7,6 +7,7 @@
44501 #include <linux/string.h>
44502
44503 #include <asm/io.h>
44504 +#include <asm/pgtable.h>
44505
44506 #ifdef __sparc__
44507 #include <asm/fbio.h>
44508 @@ -208,7 +209,9 @@ int aty_init_cursor(struct fb_info *info)
44509 info->sprite.buf_align = 16; /* and 64 lines tall. */
44510 info->sprite.flags = FB_PIXMAP_IO;
44511
44512 - info->fbops->fb_cursor = atyfb_cursor;
44513 + pax_open_kernel();
44514 + *(void **)&info->fbops->fb_cursor = atyfb_cursor;
44515 + pax_close_kernel();
44516
44517 return 0;
44518 }
44519 diff --git a/drivers/video/backlight/kb3886_bl.c b/drivers/video/backlight/kb3886_bl.c
44520 index 6c5ed6b..b727c88 100644
44521 --- a/drivers/video/backlight/kb3886_bl.c
44522 +++ b/drivers/video/backlight/kb3886_bl.c
44523 @@ -78,7 +78,7 @@ static struct kb3886bl_machinfo *bl_machinfo;
44524 static unsigned long kb3886bl_flags;
44525 #define KB3886BL_SUSPENDED 0x01
44526
44527 -static struct dmi_system_id __initdata kb3886bl_device_table[] = {
44528 +static const struct dmi_system_id __initconst kb3886bl_device_table[] = {
44529 {
44530 .ident = "Sahara Touch-iT",
44531 .matches = {
44532 diff --git a/drivers/video/fb_defio.c b/drivers/video/fb_defio.c
44533 index 900aa4e..6d49418 100644
44534 --- a/drivers/video/fb_defio.c
44535 +++ b/drivers/video/fb_defio.c
44536 @@ -206,7 +206,9 @@ void fb_deferred_io_init(struct fb_info *info)
44537
44538 BUG_ON(!fbdefio);
44539 mutex_init(&fbdefio->lock);
44540 - info->fbops->fb_mmap = fb_deferred_io_mmap;
44541 + pax_open_kernel();
44542 + *(void **)&info->fbops->fb_mmap = fb_deferred_io_mmap;
44543 + pax_close_kernel();
44544 INIT_DELAYED_WORK(&info->deferred_work, fb_deferred_io_work);
44545 INIT_LIST_HEAD(&fbdefio->pagelist);
44546 if (fbdefio->delay == 0) /* set a default of 1 s */
44547 @@ -237,7 +239,7 @@ void fb_deferred_io_cleanup(struct fb_info *info)
44548 page->mapping = NULL;
44549 }
44550
44551 - info->fbops->fb_mmap = NULL;
44552 + *(void **)&info->fbops->fb_mmap = NULL;
44553 mutex_destroy(&fbdefio->lock);
44554 }
44555 EXPORT_SYMBOL_GPL(fb_deferred_io_cleanup);
44556 diff --git a/drivers/video/fbcmap.c b/drivers/video/fbcmap.c
44557 index 5c3960d..15cf8fc 100644
44558 --- a/drivers/video/fbcmap.c
44559 +++ b/drivers/video/fbcmap.c
44560 @@ -285,8 +285,7 @@ int fb_set_user_cmap(struct fb_cmap_user *cmap, struct fb_info *info)
44561 rc = -ENODEV;
44562 goto out;
44563 }
44564 - if (cmap->start < 0 || (!info->fbops->fb_setcolreg &&
44565 - !info->fbops->fb_setcmap)) {
44566 + if (!info->fbops->fb_setcolreg && !info->fbops->fb_setcmap) {
44567 rc = -EINVAL;
44568 goto out1;
44569 }
44570 diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
44571 index 86291dc..7cc5962 100644
44572 --- a/drivers/video/fbmem.c
44573 +++ b/drivers/video/fbmem.c
44574 @@ -428,7 +428,7 @@ static void fb_do_show_logo(struct fb_info *info, struct fb_image *image,
44575 image->dx += image->width + 8;
44576 }
44577 } else if (rotate == FB_ROTATE_UD) {
44578 - for (x = 0; x < num && image->dx >= 0; x++) {
44579 + for (x = 0; x < num && (__s32)image->dx >= 0; x++) {
44580 info->fbops->fb_imageblit(info, image);
44581 image->dx -= image->width + 8;
44582 }
44583 @@ -440,7 +440,7 @@ static void fb_do_show_logo(struct fb_info *info, struct fb_image *image,
44584 image->dy += image->height + 8;
44585 }
44586 } else if (rotate == FB_ROTATE_CCW) {
44587 - for (x = 0; x < num && image->dy >= 0; x++) {
44588 + for (x = 0; x < num && (__s32)image->dy >= 0; x++) {
44589 info->fbops->fb_imageblit(info, image);
44590 image->dy -= image->height + 8;
44591 }
44592 @@ -1166,7 +1166,7 @@ static long do_fb_ioctl(struct fb_info *info, unsigned int cmd,
44593 return -EFAULT;
44594 if (con2fb.console < 1 || con2fb.console > MAX_NR_CONSOLES)
44595 return -EINVAL;
44596 - if (con2fb.framebuffer < 0 || con2fb.framebuffer >= FB_MAX)
44597 + if (con2fb.framebuffer >= FB_MAX)
44598 return -EINVAL;
44599 if (!registered_fb[con2fb.framebuffer])
44600 request_module("fb%d", con2fb.framebuffer);
44601 diff --git a/drivers/video/i810/i810_accel.c b/drivers/video/i810/i810_accel.c
44602 index 7672d2e..b56437f 100644
44603 --- a/drivers/video/i810/i810_accel.c
44604 +++ b/drivers/video/i810/i810_accel.c
44605 @@ -73,6 +73,7 @@ static inline int wait_for_space(struct fb_info *info, u32 space)
44606 }
44607 }
44608 printk("ringbuffer lockup!!!\n");
44609 + printk("head:%u tail:%u iring.size:%u space:%u\n", head, tail, par->iring.size, space);
44610 i810_report_error(mmio);
44611 par->dev_flags |= LOCKUP;
44612 info->pixmap.scan_align = 1;
44613 diff --git a/drivers/video/logo/logo_linux_clut224.ppm b/drivers/video/logo/logo_linux_clut224.ppm
44614 index 3c14e43..eafa544 100644
44615 --- a/drivers/video/logo/logo_linux_clut224.ppm
44616 +++ b/drivers/video/logo/logo_linux_clut224.ppm
44617 @@ -1,1604 +1,1123 @@
44618 P3
44619 -# Standard 224-color Linux logo
44620 80 80
44621 255
44622 - 0 0 0 0 0 0 0 0 0 0 0 0
44623 - 0 0 0 0 0 0 0 0 0 0 0 0
44624 - 0 0 0 0 0 0 0 0 0 0 0 0
44625 - 0 0 0 0 0 0 0 0 0 0 0 0
44626 - 0 0 0 0 0 0 0 0 0 0 0 0
44627 - 0 0 0 0 0 0 0 0 0 0 0 0
44628 - 0 0 0 0 0 0 0 0 0 0 0 0
44629 - 0 0 0 0 0 0 0 0 0 0 0 0
44630 - 0 0 0 0 0 0 0 0 0 0 0 0
44631 - 6 6 6 6 6 6 10 10 10 10 10 10
44632 - 10 10 10 6 6 6 6 6 6 6 6 6
44633 - 0 0 0 0 0 0 0 0 0 0 0 0
44634 - 0 0 0 0 0 0 0 0 0 0 0 0
44635 - 0 0 0 0 0 0 0 0 0 0 0 0
44636 - 0 0 0 0 0 0 0 0 0 0 0 0
44637 - 0 0 0 0 0 0 0 0 0 0 0 0
44638 - 0 0 0 0 0 0 0 0 0 0 0 0
44639 - 0 0 0 0 0 0 0 0 0 0 0 0
44640 - 0 0 0 0 0 0 0 0 0 0 0 0
44641 - 0 0 0 0 0 0 0 0 0 0 0 0
44642 - 0 0 0 0 0 0 0 0 0 0 0 0
44643 - 0 0 0 0 0 0 0 0 0 0 0 0
44644 - 0 0 0 0 0 0 0 0 0 0 0 0
44645 - 0 0 0 0 0 0 0 0 0 0 0 0
44646 - 0 0 0 0 0 0 0 0 0 0 0 0
44647 - 0 0 0 0 0 0 0 0 0 0 0 0
44648 - 0 0 0 0 0 0 0 0 0 0 0 0
44649 - 0 0 0 0 0 0 0 0 0 0 0 0
44650 - 0 0 0 6 6 6 10 10 10 14 14 14
44651 - 22 22 22 26 26 26 30 30 30 34 34 34
44652 - 30 30 30 30 30 30 26 26 26 18 18 18
44653 - 14 14 14 10 10 10 6 6 6 0 0 0
44654 - 0 0 0 0 0 0 0 0 0 0 0 0
44655 - 0 0 0 0 0 0 0 0 0 0 0 0
44656 - 0 0 0 0 0 0 0 0 0 0 0 0
44657 - 0 0 0 0 0 0 0 0 0 0 0 0
44658 - 0 0 0 0 0 0 0 0 0 0 0 0
44659 - 0 0 0 0 0 0 0 0 0 0 0 0
44660 - 0 0 0 0 0 0 0 0 0 0 0 0
44661 - 0 0 0 0 0 0 0 0 0 0 0 0
44662 - 0 0 0 0 0 0 0 0 0 0 0 0
44663 - 0 0 0 0 0 1 0 0 1 0 0 0
44664 - 0 0 0 0 0 0 0 0 0 0 0 0
44665 - 0 0 0 0 0 0 0 0 0 0 0 0
44666 - 0 0 0 0 0 0 0 0 0 0 0 0
44667 - 0 0 0 0 0 0 0 0 0 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 - 6 6 6 14 14 14 26 26 26 42 42 42
44671 - 54 54 54 66 66 66 78 78 78 78 78 78
44672 - 78 78 78 74 74 74 66 66 66 54 54 54
44673 - 42 42 42 26 26 26 18 18 18 10 10 10
44674 - 6 6 6 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 1 0 0 0 0 0 0 0 0 0
44684 - 0 0 0 0 0 0 0 0 0 0 0 0
44685 - 0 0 0 0 0 0 0 0 0 0 0 0
44686 - 0 0 0 0 0 0 0 0 0 0 0 0
44687 - 0 0 0 0 0 0 0 0 0 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 10 10 10
44690 - 22 22 22 42 42 42 66 66 66 86 86 86
44691 - 66 66 66 38 38 38 38 38 38 22 22 22
44692 - 26 26 26 34 34 34 54 54 54 66 66 66
44693 - 86 86 86 70 70 70 46 46 46 26 26 26
44694 - 14 14 14 6 6 6 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 0 0 0 0 0 0 0
44698 - 0 0 0 0 0 0 0 0 0 0 0 0
44699 - 0 0 0 0 0 0 0 0 0 0 0 0
44700 - 0 0 0 0 0 0 0 0 0 0 0 0
44701 - 0 0 0 0 0 0 0 0 0 0 0 0
44702 - 0 0 0 0 0 0 0 0 0 0 0 0
44703 - 0 0 1 0 0 1 0 0 1 0 0 0
44704 - 0 0 0 0 0 0 0 0 0 0 0 0
44705 - 0 0 0 0 0 0 0 0 0 0 0 0
44706 - 0 0 0 0 0 0 0 0 0 0 0 0
44707 - 0 0 0 0 0 0 0 0 0 0 0 0
44708 - 0 0 0 0 0 0 0 0 0 0 0 0
44709 - 0 0 0 0 0 0 10 10 10 26 26 26
44710 - 50 50 50 82 82 82 58 58 58 6 6 6
44711 - 2 2 6 2 2 6 2 2 6 2 2 6
44712 - 2 2 6 2 2 6 2 2 6 2 2 6
44713 - 6 6 6 54 54 54 86 86 86 66 66 66
44714 - 38 38 38 18 18 18 6 6 6 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 0 0 0 0 0 0 0 0 0 0
44718 - 0 0 0 0 0 0 0 0 0 0 0 0
44719 - 0 0 0 0 0 0 0 0 0 0 0 0
44720 - 0 0 0 0 0 0 0 0 0 0 0 0
44721 - 0 0 0 0 0 0 0 0 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 0 0 0
44724 - 0 0 0 0 0 0 0 0 0 0 0 0
44725 - 0 0 0 0 0 0 0 0 0 0 0 0
44726 - 0 0 0 0 0 0 0 0 0 0 0 0
44727 - 0 0 0 0 0 0 0 0 0 0 0 0
44728 - 0 0 0 0 0 0 0 0 0 0 0 0
44729 - 0 0 0 6 6 6 22 22 22 50 50 50
44730 - 78 78 78 34 34 34 2 2 6 2 2 6
44731 - 2 2 6 2 2 6 2 2 6 2 2 6
44732 - 2 2 6 2 2 6 2 2 6 2 2 6
44733 - 2 2 6 2 2 6 6 6 6 70 70 70
44734 - 78 78 78 46 46 46 22 22 22 6 6 6
44735 - 0 0 0 0 0 0 0 0 0 0 0 0
44736 - 0 0 0 0 0 0 0 0 0 0 0 0
44737 - 0 0 0 0 0 0 0 0 0 0 0 0
44738 - 0 0 0 0 0 0 0 0 0 0 0 0
44739 - 0 0 0 0 0 0 0 0 0 0 0 0
44740 - 0 0 0 0 0 0 0 0 0 0 0 0
44741 - 0 0 0 0 0 0 0 0 0 0 0 0
44742 - 0 0 0 0 0 0 0 0 0 0 0 0
44743 - 0 0 1 0 0 1 0 0 1 0 0 0
44744 - 0 0 0 0 0 0 0 0 0 0 0 0
44745 - 0 0 0 0 0 0 0 0 0 0 0 0
44746 - 0 0 0 0 0 0 0 0 0 0 0 0
44747 - 0 0 0 0 0 0 0 0 0 0 0 0
44748 - 0 0 0 0 0 0 0 0 0 0 0 0
44749 - 6 6 6 18 18 18 42 42 42 82 82 82
44750 - 26 26 26 2 2 6 2 2 6 2 2 6
44751 - 2 2 6 2 2 6 2 2 6 2 2 6
44752 - 2 2 6 2 2 6 2 2 6 14 14 14
44753 - 46 46 46 34 34 34 6 6 6 2 2 6
44754 - 42 42 42 78 78 78 42 42 42 18 18 18
44755 - 6 6 6 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 1 0 0 0 0 0 1 0 0 0
44764 - 0 0 0 0 0 0 0 0 0 0 0 0
44765 - 0 0 0 0 0 0 0 0 0 0 0 0
44766 - 0 0 0 0 0 0 0 0 0 0 0 0
44767 - 0 0 0 0 0 0 0 0 0 0 0 0
44768 - 0 0 0 0 0 0 0 0 0 0 0 0
44769 - 10 10 10 30 30 30 66 66 66 58 58 58
44770 - 2 2 6 2 2 6 2 2 6 2 2 6
44771 - 2 2 6 2 2 6 2 2 6 2 2 6
44772 - 2 2 6 2 2 6 2 2 6 26 26 26
44773 - 86 86 86 101 101 101 46 46 46 10 10 10
44774 - 2 2 6 58 58 58 70 70 70 34 34 34
44775 - 10 10 10 0 0 0 0 0 0 0 0 0
44776 - 0 0 0 0 0 0 0 0 0 0 0 0
44777 - 0 0 0 0 0 0 0 0 0 0 0 0
44778 - 0 0 0 0 0 0 0 0 0 0 0 0
44779 - 0 0 0 0 0 0 0 0 0 0 0 0
44780 - 0 0 0 0 0 0 0 0 0 0 0 0
44781 - 0 0 0 0 0 0 0 0 0 0 0 0
44782 - 0 0 0 0 0 0 0 0 0 0 0 0
44783 - 0 0 1 0 0 1 0 0 1 0 0 0
44784 - 0 0 0 0 0 0 0 0 0 0 0 0
44785 - 0 0 0 0 0 0 0 0 0 0 0 0
44786 - 0 0 0 0 0 0 0 0 0 0 0 0
44787 - 0 0 0 0 0 0 0 0 0 0 0 0
44788 - 0 0 0 0 0 0 0 0 0 0 0 0
44789 - 14 14 14 42 42 42 86 86 86 10 10 10
44790 - 2 2 6 2 2 6 2 2 6 2 2 6
44791 - 2 2 6 2 2 6 2 2 6 2 2 6
44792 - 2 2 6 2 2 6 2 2 6 30 30 30
44793 - 94 94 94 94 94 94 58 58 58 26 26 26
44794 - 2 2 6 6 6 6 78 78 78 54 54 54
44795 - 22 22 22 6 6 6 0 0 0 0 0 0
44796 - 0 0 0 0 0 0 0 0 0 0 0 0
44797 - 0 0 0 0 0 0 0 0 0 0 0 0
44798 - 0 0 0 0 0 0 0 0 0 0 0 0
44799 - 0 0 0 0 0 0 0 0 0 0 0 0
44800 - 0 0 0 0 0 0 0 0 0 0 0 0
44801 - 0 0 0 0 0 0 0 0 0 0 0 0
44802 - 0 0 0 0 0 0 0 0 0 0 0 0
44803 - 0 0 0 0 0 0 0 0 0 0 0 0
44804 - 0 0 0 0 0 0 0 0 0 0 0 0
44805 - 0 0 0 0 0 0 0 0 0 0 0 0
44806 - 0 0 0 0 0 0 0 0 0 0 0 0
44807 - 0 0 0 0 0 0 0 0 0 0 0 0
44808 - 0 0 0 0 0 0 0 0 0 6 6 6
44809 - 22 22 22 62 62 62 62 62 62 2 2 6
44810 - 2 2 6 2 2 6 2 2 6 2 2 6
44811 - 2 2 6 2 2 6 2 2 6 2 2 6
44812 - 2 2 6 2 2 6 2 2 6 26 26 26
44813 - 54 54 54 38 38 38 18 18 18 10 10 10
44814 - 2 2 6 2 2 6 34 34 34 82 82 82
44815 - 38 38 38 14 14 14 0 0 0 0 0 0
44816 - 0 0 0 0 0 0 0 0 0 0 0 0
44817 - 0 0 0 0 0 0 0 0 0 0 0 0
44818 - 0 0 0 0 0 0 0 0 0 0 0 0
44819 - 0 0 0 0 0 0 0 0 0 0 0 0
44820 - 0 0 0 0 0 0 0 0 0 0 0 0
44821 - 0 0 0 0 0 0 0 0 0 0 0 0
44822 - 0 0 0 0 0 0 0 0 0 0 0 0
44823 - 0 0 0 0 0 1 0 0 1 0 0 0
44824 - 0 0 0 0 0 0 0 0 0 0 0 0
44825 - 0 0 0 0 0 0 0 0 0 0 0 0
44826 - 0 0 0 0 0 0 0 0 0 0 0 0
44827 - 0 0 0 0 0 0 0 0 0 0 0 0
44828 - 0 0 0 0 0 0 0 0 0 6 6 6
44829 - 30 30 30 78 78 78 30 30 30 2 2 6
44830 - 2 2 6 2 2 6 2 2 6 2 2 6
44831 - 2 2 6 2 2 6 2 2 6 2 2 6
44832 - 2 2 6 2 2 6 2 2 6 10 10 10
44833 - 10 10 10 2 2 6 2 2 6 2 2 6
44834 - 2 2 6 2 2 6 2 2 6 78 78 78
44835 - 50 50 50 18 18 18 6 6 6 0 0 0
44836 - 0 0 0 0 0 0 0 0 0 0 0 0
44837 - 0 0 0 0 0 0 0 0 0 0 0 0
44838 - 0 0 0 0 0 0 0 0 0 0 0 0
44839 - 0 0 0 0 0 0 0 0 0 0 0 0
44840 - 0 0 0 0 0 0 0 0 0 0 0 0
44841 - 0 0 0 0 0 0 0 0 0 0 0 0
44842 - 0 0 0 0 0 0 0 0 0 0 0 0
44843 - 0 0 1 0 0 0 0 0 0 0 0 0
44844 - 0 0 0 0 0 0 0 0 0 0 0 0
44845 - 0 0 0 0 0 0 0 0 0 0 0 0
44846 - 0 0 0 0 0 0 0 0 0 0 0 0
44847 - 0 0 0 0 0 0 0 0 0 0 0 0
44848 - 0 0 0 0 0 0 0 0 0 10 10 10
44849 - 38 38 38 86 86 86 14 14 14 2 2 6
44850 - 2 2 6 2 2 6 2 2 6 2 2 6
44851 - 2 2 6 2 2 6 2 2 6 2 2 6
44852 - 2 2 6 2 2 6 2 2 6 2 2 6
44853 - 2 2 6 2 2 6 2 2 6 2 2 6
44854 - 2 2 6 2 2 6 2 2 6 54 54 54
44855 - 66 66 66 26 26 26 6 6 6 0 0 0
44856 - 0 0 0 0 0 0 0 0 0 0 0 0
44857 - 0 0 0 0 0 0 0 0 0 0 0 0
44858 - 0 0 0 0 0 0 0 0 0 0 0 0
44859 - 0 0 0 0 0 0 0 0 0 0 0 0
44860 - 0 0 0 0 0 0 0 0 0 0 0 0
44861 - 0 0 0 0 0 0 0 0 0 0 0 0
44862 - 0 0 0 0 0 0 0 0 0 0 0 0
44863 - 0 0 0 0 0 1 0 0 1 0 0 0
44864 - 0 0 0 0 0 0 0 0 0 0 0 0
44865 - 0 0 0 0 0 0 0 0 0 0 0 0
44866 - 0 0 0 0 0 0 0 0 0 0 0 0
44867 - 0 0 0 0 0 0 0 0 0 0 0 0
44868 - 0 0 0 0 0 0 0 0 0 14 14 14
44869 - 42 42 42 82 82 82 2 2 6 2 2 6
44870 - 2 2 6 6 6 6 10 10 10 2 2 6
44871 - 2 2 6 2 2 6 2 2 6 2 2 6
44872 - 2 2 6 2 2 6 2 2 6 6 6 6
44873 - 14 14 14 10 10 10 2 2 6 2 2 6
44874 - 2 2 6 2 2 6 2 2 6 18 18 18
44875 - 82 82 82 34 34 34 10 10 10 0 0 0
44876 - 0 0 0 0 0 0 0 0 0 0 0 0
44877 - 0 0 0 0 0 0 0 0 0 0 0 0
44878 - 0 0 0 0 0 0 0 0 0 0 0 0
44879 - 0 0 0 0 0 0 0 0 0 0 0 0
44880 - 0 0 0 0 0 0 0 0 0 0 0 0
44881 - 0 0 0 0 0 0 0 0 0 0 0 0
44882 - 0 0 0 0 0 0 0 0 0 0 0 0
44883 - 0 0 1 0 0 0 0 0 0 0 0 0
44884 - 0 0 0 0 0 0 0 0 0 0 0 0
44885 - 0 0 0 0 0 0 0 0 0 0 0 0
44886 - 0 0 0 0 0 0 0 0 0 0 0 0
44887 - 0 0 0 0 0 0 0 0 0 0 0 0
44888 - 0 0 0 0 0 0 0 0 0 14 14 14
44889 - 46 46 46 86 86 86 2 2 6 2 2 6
44890 - 6 6 6 6 6 6 22 22 22 34 34 34
44891 - 6 6 6 2 2 6 2 2 6 2 2 6
44892 - 2 2 6 2 2 6 18 18 18 34 34 34
44893 - 10 10 10 50 50 50 22 22 22 2 2 6
44894 - 2 2 6 2 2 6 2 2 6 10 10 10
44895 - 86 86 86 42 42 42 14 14 14 0 0 0
44896 - 0 0 0 0 0 0 0 0 0 0 0 0
44897 - 0 0 0 0 0 0 0 0 0 0 0 0
44898 - 0 0 0 0 0 0 0 0 0 0 0 0
44899 - 0 0 0 0 0 0 0 0 0 0 0 0
44900 - 0 0 0 0 0 0 0 0 0 0 0 0
44901 - 0 0 0 0 0 0 0 0 0 0 0 0
44902 - 0 0 0 0 0 0 0 0 0 0 0 0
44903 - 0 0 1 0 0 1 0 0 1 0 0 0
44904 - 0 0 0 0 0 0 0 0 0 0 0 0
44905 - 0 0 0 0 0 0 0 0 0 0 0 0
44906 - 0 0 0 0 0 0 0 0 0 0 0 0
44907 - 0 0 0 0 0 0 0 0 0 0 0 0
44908 - 0 0 0 0 0 0 0 0 0 14 14 14
44909 - 46 46 46 86 86 86 2 2 6 2 2 6
44910 - 38 38 38 116 116 116 94 94 94 22 22 22
44911 - 22 22 22 2 2 6 2 2 6 2 2 6
44912 - 14 14 14 86 86 86 138 138 138 162 162 162
44913 -154 154 154 38 38 38 26 26 26 6 6 6
44914 - 2 2 6 2 2 6 2 2 6 2 2 6
44915 - 86 86 86 46 46 46 14 14 14 0 0 0
44916 - 0 0 0 0 0 0 0 0 0 0 0 0
44917 - 0 0 0 0 0 0 0 0 0 0 0 0
44918 - 0 0 0 0 0 0 0 0 0 0 0 0
44919 - 0 0 0 0 0 0 0 0 0 0 0 0
44920 - 0 0 0 0 0 0 0 0 0 0 0 0
44921 - 0 0 0 0 0 0 0 0 0 0 0 0
44922 - 0 0 0 0 0 0 0 0 0 0 0 0
44923 - 0 0 0 0 0 0 0 0 0 0 0 0
44924 - 0 0 0 0 0 0 0 0 0 0 0 0
44925 - 0 0 0 0 0 0 0 0 0 0 0 0
44926 - 0 0 0 0 0 0 0 0 0 0 0 0
44927 - 0 0 0 0 0 0 0 0 0 0 0 0
44928 - 0 0 0 0 0 0 0 0 0 14 14 14
44929 - 46 46 46 86 86 86 2 2 6 14 14 14
44930 -134 134 134 198 198 198 195 195 195 116 116 116
44931 - 10 10 10 2 2 6 2 2 6 6 6 6
44932 -101 98 89 187 187 187 210 210 210 218 218 218
44933 -214 214 214 134 134 134 14 14 14 6 6 6
44934 - 2 2 6 2 2 6 2 2 6 2 2 6
44935 - 86 86 86 50 50 50 18 18 18 6 6 6
44936 - 0 0 0 0 0 0 0 0 0 0 0 0
44937 - 0 0 0 0 0 0 0 0 0 0 0 0
44938 - 0 0 0 0 0 0 0 0 0 0 0 0
44939 - 0 0 0 0 0 0 0 0 0 0 0 0
44940 - 0 0 0 0 0 0 0 0 0 0 0 0
44941 - 0 0 0 0 0 0 0 0 0 0 0 0
44942 - 0 0 0 0 0 0 0 0 1 0 0 0
44943 - 0 0 1 0 0 1 0 0 1 0 0 0
44944 - 0 0 0 0 0 0 0 0 0 0 0 0
44945 - 0 0 0 0 0 0 0 0 0 0 0 0
44946 - 0 0 0 0 0 0 0 0 0 0 0 0
44947 - 0 0 0 0 0 0 0 0 0 0 0 0
44948 - 0 0 0 0 0 0 0 0 0 14 14 14
44949 - 46 46 46 86 86 86 2 2 6 54 54 54
44950 -218 218 218 195 195 195 226 226 226 246 246 246
44951 - 58 58 58 2 2 6 2 2 6 30 30 30
44952 -210 210 210 253 253 253 174 174 174 123 123 123
44953 -221 221 221 234 234 234 74 74 74 2 2 6
44954 - 2 2 6 2 2 6 2 2 6 2 2 6
44955 - 70 70 70 58 58 58 22 22 22 6 6 6
44956 - 0 0 0 0 0 0 0 0 0 0 0 0
44957 - 0 0 0 0 0 0 0 0 0 0 0 0
44958 - 0 0 0 0 0 0 0 0 0 0 0 0
44959 - 0 0 0 0 0 0 0 0 0 0 0 0
44960 - 0 0 0 0 0 0 0 0 0 0 0 0
44961 - 0 0 0 0 0 0 0 0 0 0 0 0
44962 - 0 0 0 0 0 0 0 0 0 0 0 0
44963 - 0 0 0 0 0 0 0 0 0 0 0 0
44964 - 0 0 0 0 0 0 0 0 0 0 0 0
44965 - 0 0 0 0 0 0 0 0 0 0 0 0
44966 - 0 0 0 0 0 0 0 0 0 0 0 0
44967 - 0 0 0 0 0 0 0 0 0 0 0 0
44968 - 0 0 0 0 0 0 0 0 0 14 14 14
44969 - 46 46 46 82 82 82 2 2 6 106 106 106
44970 -170 170 170 26 26 26 86 86 86 226 226 226
44971 -123 123 123 10 10 10 14 14 14 46 46 46
44972 -231 231 231 190 190 190 6 6 6 70 70 70
44973 - 90 90 90 238 238 238 158 158 158 2 2 6
44974 - 2 2 6 2 2 6 2 2 6 2 2 6
44975 - 70 70 70 58 58 58 22 22 22 6 6 6
44976 - 0 0 0 0 0 0 0 0 0 0 0 0
44977 - 0 0 0 0 0 0 0 0 0 0 0 0
44978 - 0 0 0 0 0 0 0 0 0 0 0 0
44979 - 0 0 0 0 0 0 0 0 0 0 0 0
44980 - 0 0 0 0 0 0 0 0 0 0 0 0
44981 - 0 0 0 0 0 0 0 0 0 0 0 0
44982 - 0 0 0 0 0 0 0 0 1 0 0 0
44983 - 0 0 1 0 0 1 0 0 1 0 0 0
44984 - 0 0 0 0 0 0 0 0 0 0 0 0
44985 - 0 0 0 0 0 0 0 0 0 0 0 0
44986 - 0 0 0 0 0 0 0 0 0 0 0 0
44987 - 0 0 0 0 0 0 0 0 0 0 0 0
44988 - 0 0 0 0 0 0 0 0 0 14 14 14
44989 - 42 42 42 86 86 86 6 6 6 116 116 116
44990 -106 106 106 6 6 6 70 70 70 149 149 149
44991 -128 128 128 18 18 18 38 38 38 54 54 54
44992 -221 221 221 106 106 106 2 2 6 14 14 14
44993 - 46 46 46 190 190 190 198 198 198 2 2 6
44994 - 2 2 6 2 2 6 2 2 6 2 2 6
44995 - 74 74 74 62 62 62 22 22 22 6 6 6
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 1 0 0 0
45003 - 0 0 1 0 0 0 0 0 1 0 0 0
45004 - 0 0 0 0 0 0 0 0 0 0 0 0
45005 - 0 0 0 0 0 0 0 0 0 0 0 0
45006 - 0 0 0 0 0 0 0 0 0 0 0 0
45007 - 0 0 0 0 0 0 0 0 0 0 0 0
45008 - 0 0 0 0 0 0 0 0 0 14 14 14
45009 - 42 42 42 94 94 94 14 14 14 101 101 101
45010 -128 128 128 2 2 6 18 18 18 116 116 116
45011 -118 98 46 121 92 8 121 92 8 98 78 10
45012 -162 162 162 106 106 106 2 2 6 2 2 6
45013 - 2 2 6 195 195 195 195 195 195 6 6 6
45014 - 2 2 6 2 2 6 2 2 6 2 2 6
45015 - 74 74 74 62 62 62 22 22 22 6 6 6
45016 - 0 0 0 0 0 0 0 0 0 0 0 0
45017 - 0 0 0 0 0 0 0 0 0 0 0 0
45018 - 0 0 0 0 0 0 0 0 0 0 0 0
45019 - 0 0 0 0 0 0 0 0 0 0 0 0
45020 - 0 0 0 0 0 0 0 0 0 0 0 0
45021 - 0 0 0 0 0 0 0 0 0 0 0 0
45022 - 0 0 0 0 0 0 0 0 1 0 0 1
45023 - 0 0 1 0 0 0 0 0 1 0 0 0
45024 - 0 0 0 0 0 0 0 0 0 0 0 0
45025 - 0 0 0 0 0 0 0 0 0 0 0 0
45026 - 0 0 0 0 0 0 0 0 0 0 0 0
45027 - 0 0 0 0 0 0 0 0 0 0 0 0
45028 - 0 0 0 0 0 0 0 0 0 10 10 10
45029 - 38 38 38 90 90 90 14 14 14 58 58 58
45030 -210 210 210 26 26 26 54 38 6 154 114 10
45031 -226 170 11 236 186 11 225 175 15 184 144 12
45032 -215 174 15 175 146 61 37 26 9 2 2 6
45033 - 70 70 70 246 246 246 138 138 138 2 2 6
45034 - 2 2 6 2 2 6 2 2 6 2 2 6
45035 - 70 70 70 66 66 66 26 26 26 6 6 6
45036 - 0 0 0 0 0 0 0 0 0 0 0 0
45037 - 0 0 0 0 0 0 0 0 0 0 0 0
45038 - 0 0 0 0 0 0 0 0 0 0 0 0
45039 - 0 0 0 0 0 0 0 0 0 0 0 0
45040 - 0 0 0 0 0 0 0 0 0 0 0 0
45041 - 0 0 0 0 0 0 0 0 0 0 0 0
45042 - 0 0 0 0 0 0 0 0 0 0 0 0
45043 - 0 0 0 0 0 0 0 0 0 0 0 0
45044 - 0 0 0 0 0 0 0 0 0 0 0 0
45045 - 0 0 0 0 0 0 0 0 0 0 0 0
45046 - 0 0 0 0 0 0 0 0 0 0 0 0
45047 - 0 0 0 0 0 0 0 0 0 0 0 0
45048 - 0 0 0 0 0 0 0 0 0 10 10 10
45049 - 38 38 38 86 86 86 14 14 14 10 10 10
45050 -195 195 195 188 164 115 192 133 9 225 175 15
45051 -239 182 13 234 190 10 232 195 16 232 200 30
45052 -245 207 45 241 208 19 232 195 16 184 144 12
45053 -218 194 134 211 206 186 42 42 42 2 2 6
45054 - 2 2 6 2 2 6 2 2 6 2 2 6
45055 - 50 50 50 74 74 74 30 30 30 6 6 6
45056 - 0 0 0 0 0 0 0 0 0 0 0 0
45057 - 0 0 0 0 0 0 0 0 0 0 0 0
45058 - 0 0 0 0 0 0 0 0 0 0 0 0
45059 - 0 0 0 0 0 0 0 0 0 0 0 0
45060 - 0 0 0 0 0 0 0 0 0 0 0 0
45061 - 0 0 0 0 0 0 0 0 0 0 0 0
45062 - 0 0 0 0 0 0 0 0 0 0 0 0
45063 - 0 0 0 0 0 0 0 0 0 0 0 0
45064 - 0 0 0 0 0 0 0 0 0 0 0 0
45065 - 0 0 0 0 0 0 0 0 0 0 0 0
45066 - 0 0 0 0 0 0 0 0 0 0 0 0
45067 - 0 0 0 0 0 0 0 0 0 0 0 0
45068 - 0 0 0 0 0 0 0 0 0 10 10 10
45069 - 34 34 34 86 86 86 14 14 14 2 2 6
45070 -121 87 25 192 133 9 219 162 10 239 182 13
45071 -236 186 11 232 195 16 241 208 19 244 214 54
45072 -246 218 60 246 218 38 246 215 20 241 208 19
45073 -241 208 19 226 184 13 121 87 25 2 2 6
45074 - 2 2 6 2 2 6 2 2 6 2 2 6
45075 - 50 50 50 82 82 82 34 34 34 10 10 10
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 0 0 0
45083 - 0 0 0 0 0 0 0 0 0 0 0 0
45084 - 0 0 0 0 0 0 0 0 0 0 0 0
45085 - 0 0 0 0 0 0 0 0 0 0 0 0
45086 - 0 0 0 0 0 0 0 0 0 0 0 0
45087 - 0 0 0 0 0 0 0 0 0 0 0 0
45088 - 0 0 0 0 0 0 0 0 0 10 10 10
45089 - 34 34 34 82 82 82 30 30 30 61 42 6
45090 -180 123 7 206 145 10 230 174 11 239 182 13
45091 -234 190 10 238 202 15 241 208 19 246 218 74
45092 -246 218 38 246 215 20 246 215 20 246 215 20
45093 -226 184 13 215 174 15 184 144 12 6 6 6
45094 - 2 2 6 2 2 6 2 2 6 2 2 6
45095 - 26 26 26 94 94 94 42 42 42 14 14 14
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 0 0 0
45103 - 0 0 0 0 0 0 0 0 0 0 0 0
45104 - 0 0 0 0 0 0 0 0 0 0 0 0
45105 - 0 0 0 0 0 0 0 0 0 0 0 0
45106 - 0 0 0 0 0 0 0 0 0 0 0 0
45107 - 0 0 0 0 0 0 0 0 0 0 0 0
45108 - 0 0 0 0 0 0 0 0 0 10 10 10
45109 - 30 30 30 78 78 78 50 50 50 104 69 6
45110 -192 133 9 216 158 10 236 178 12 236 186 11
45111 -232 195 16 241 208 19 244 214 54 245 215 43
45112 -246 215 20 246 215 20 241 208 19 198 155 10
45113 -200 144 11 216 158 10 156 118 10 2 2 6
45114 - 2 2 6 2 2 6 2 2 6 2 2 6
45115 - 6 6 6 90 90 90 54 54 54 18 18 18
45116 - 6 6 6 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 0 0 0
45123 - 0 0 0 0 0 0 0 0 0 0 0 0
45124 - 0 0 0 0 0 0 0 0 0 0 0 0
45125 - 0 0 0 0 0 0 0 0 0 0 0 0
45126 - 0 0 0 0 0 0 0 0 0 0 0 0
45127 - 0 0 0 0 0 0 0 0 0 0 0 0
45128 - 0 0 0 0 0 0 0 0 0 10 10 10
45129 - 30 30 30 78 78 78 46 46 46 22 22 22
45130 -137 92 6 210 162 10 239 182 13 238 190 10
45131 -238 202 15 241 208 19 246 215 20 246 215 20
45132 -241 208 19 203 166 17 185 133 11 210 150 10
45133 -216 158 10 210 150 10 102 78 10 2 2 6
45134 - 6 6 6 54 54 54 14 14 14 2 2 6
45135 - 2 2 6 62 62 62 74 74 74 30 30 30
45136 - 10 10 10 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 0 0 0
45143 - 0 0 0 0 0 0 0 0 0 0 0 0
45144 - 0 0 0 0 0 0 0 0 0 0 0 0
45145 - 0 0 0 0 0 0 0 0 0 0 0 0
45146 - 0 0 0 0 0 0 0 0 0 0 0 0
45147 - 0 0 0 0 0 0 0 0 0 0 0 0
45148 - 0 0 0 0 0 0 0 0 0 10 10 10
45149 - 34 34 34 78 78 78 50 50 50 6 6 6
45150 - 94 70 30 139 102 15 190 146 13 226 184 13
45151 -232 200 30 232 195 16 215 174 15 190 146 13
45152 -168 122 10 192 133 9 210 150 10 213 154 11
45153 -202 150 34 182 157 106 101 98 89 2 2 6
45154 - 2 2 6 78 78 78 116 116 116 58 58 58
45155 - 2 2 6 22 22 22 90 90 90 46 46 46
45156 - 18 18 18 6 6 6 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 0 0 0
45163 - 0 0 0 0 0 0 0 0 0 0 0 0
45164 - 0 0 0 0 0 0 0 0 0 0 0 0
45165 - 0 0 0 0 0 0 0 0 0 0 0 0
45166 - 0 0 0 0 0 0 0 0 0 0 0 0
45167 - 0 0 0 0 0 0 0 0 0 0 0 0
45168 - 0 0 0 0 0 0 0 0 0 10 10 10
45169 - 38 38 38 86 86 86 50 50 50 6 6 6
45170 -128 128 128 174 154 114 156 107 11 168 122 10
45171 -198 155 10 184 144 12 197 138 11 200 144 11
45172 -206 145 10 206 145 10 197 138 11 188 164 115
45173 -195 195 195 198 198 198 174 174 174 14 14 14
45174 - 2 2 6 22 22 22 116 116 116 116 116 116
45175 - 22 22 22 2 2 6 74 74 74 70 70 70
45176 - 30 30 30 10 10 10 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 0 0 0
45183 - 0 0 0 0 0 0 0 0 0 0 0 0
45184 - 0 0 0 0 0 0 0 0 0 0 0 0
45185 - 0 0 0 0 0 0 0 0 0 0 0 0
45186 - 0 0 0 0 0 0 0 0 0 0 0 0
45187 - 0 0 0 0 0 0 0 0 0 0 0 0
45188 - 0 0 0 0 0 0 6 6 6 18 18 18
45189 - 50 50 50 101 101 101 26 26 26 10 10 10
45190 -138 138 138 190 190 190 174 154 114 156 107 11
45191 -197 138 11 200 144 11 197 138 11 192 133 9
45192 -180 123 7 190 142 34 190 178 144 187 187 187
45193 -202 202 202 221 221 221 214 214 214 66 66 66
45194 - 2 2 6 2 2 6 50 50 50 62 62 62
45195 - 6 6 6 2 2 6 10 10 10 90 90 90
45196 - 50 50 50 18 18 18 6 6 6 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 0 0 0
45203 - 0 0 0 0 0 0 0 0 0 0 0 0
45204 - 0 0 0 0 0 0 0 0 0 0 0 0
45205 - 0 0 0 0 0 0 0 0 0 0 0 0
45206 - 0 0 0 0 0 0 0 0 0 0 0 0
45207 - 0 0 0 0 0 0 0 0 0 0 0 0
45208 - 0 0 0 0 0 0 10 10 10 34 34 34
45209 - 74 74 74 74 74 74 2 2 6 6 6 6
45210 -144 144 144 198 198 198 190 190 190 178 166 146
45211 -154 121 60 156 107 11 156 107 11 168 124 44
45212 -174 154 114 187 187 187 190 190 190 210 210 210
45213 -246 246 246 253 253 253 253 253 253 182 182 182
45214 - 6 6 6 2 2 6 2 2 6 2 2 6
45215 - 2 2 6 2 2 6 2 2 6 62 62 62
45216 - 74 74 74 34 34 34 14 14 14 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 0 0 0 0 0 0
45223 - 0 0 0 0 0 0 0 0 0 0 0 0
45224 - 0 0 0 0 0 0 0 0 0 0 0 0
45225 - 0 0 0 0 0 0 0 0 0 0 0 0
45226 - 0 0 0 0 0 0 0 0 0 0 0 0
45227 - 0 0 0 0 0 0 0 0 0 0 0 0
45228 - 0 0 0 10 10 10 22 22 22 54 54 54
45229 - 94 94 94 18 18 18 2 2 6 46 46 46
45230 -234 234 234 221 221 221 190 190 190 190 190 190
45231 -190 190 190 187 187 187 187 187 187 190 190 190
45232 -190 190 190 195 195 195 214 214 214 242 242 242
45233 -253 253 253 253 253 253 253 253 253 253 253 253
45234 - 82 82 82 2 2 6 2 2 6 2 2 6
45235 - 2 2 6 2 2 6 2 2 6 14 14 14
45236 - 86 86 86 54 54 54 22 22 22 6 6 6
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 0 0 0 0 0 0
45243 - 0 0 0 0 0 0 0 0 0 0 0 0
45244 - 0 0 0 0 0 0 0 0 0 0 0 0
45245 - 0 0 0 0 0 0 0 0 0 0 0 0
45246 - 0 0 0 0 0 0 0 0 0 0 0 0
45247 - 0 0 0 0 0 0 0 0 0 0 0 0
45248 - 6 6 6 18 18 18 46 46 46 90 90 90
45249 - 46 46 46 18 18 18 6 6 6 182 182 182
45250 -253 253 253 246 246 246 206 206 206 190 190 190
45251 -190 190 190 190 190 190 190 190 190 190 190 190
45252 -206 206 206 231 231 231 250 250 250 253 253 253
45253 -253 253 253 253 253 253 253 253 253 253 253 253
45254 -202 202 202 14 14 14 2 2 6 2 2 6
45255 - 2 2 6 2 2 6 2 2 6 2 2 6
45256 - 42 42 42 86 86 86 42 42 42 18 18 18
45257 - 6 6 6 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 0 0 0 0 0 0 0 0 0
45263 - 0 0 0 0 0 0 0 0 0 0 0 0
45264 - 0 0 0 0 0 0 0 0 0 0 0 0
45265 - 0 0 0 0 0 0 0 0 0 0 0 0
45266 - 0 0 0 0 0 0 0 0 0 0 0 0
45267 - 0 0 0 0 0 0 0 0 0 6 6 6
45268 - 14 14 14 38 38 38 74 74 74 66 66 66
45269 - 2 2 6 6 6 6 90 90 90 250 250 250
45270 -253 253 253 253 253 253 238 238 238 198 198 198
45271 -190 190 190 190 190 190 195 195 195 221 221 221
45272 -246 246 246 253 253 253 253 253 253 253 253 253
45273 -253 253 253 253 253 253 253 253 253 253 253 253
45274 -253 253 253 82 82 82 2 2 6 2 2 6
45275 - 2 2 6 2 2 6 2 2 6 2 2 6
45276 - 2 2 6 78 78 78 70 70 70 34 34 34
45277 - 14 14 14 6 6 6 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 - 0 0 0 0 0 0 0 0 0 0 0 0
45283 - 0 0 0 0 0 0 0 0 0 0 0 0
45284 - 0 0 0 0 0 0 0 0 0 0 0 0
45285 - 0 0 0 0 0 0 0 0 0 0 0 0
45286 - 0 0 0 0 0 0 0 0 0 0 0 0
45287 - 0 0 0 0 0 0 0 0 0 14 14 14
45288 - 34 34 34 66 66 66 78 78 78 6 6 6
45289 - 2 2 6 18 18 18 218 218 218 253 253 253
45290 -253 253 253 253 253 253 253 253 253 246 246 246
45291 -226 226 226 231 231 231 246 246 246 253 253 253
45292 -253 253 253 253 253 253 253 253 253 253 253 253
45293 -253 253 253 253 253 253 253 253 253 253 253 253
45294 -253 253 253 178 178 178 2 2 6 2 2 6
45295 - 2 2 6 2 2 6 2 2 6 2 2 6
45296 - 2 2 6 18 18 18 90 90 90 62 62 62
45297 - 30 30 30 10 10 10 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 0 0 0
45302 - 0 0 0 0 0 0 0 0 0 0 0 0
45303 - 0 0 0 0 0 0 0 0 0 0 0 0
45304 - 0 0 0 0 0 0 0 0 0 0 0 0
45305 - 0 0 0 0 0 0 0 0 0 0 0 0
45306 - 0 0 0 0 0 0 0 0 0 0 0 0
45307 - 0 0 0 0 0 0 10 10 10 26 26 26
45308 - 58 58 58 90 90 90 18 18 18 2 2 6
45309 - 2 2 6 110 110 110 253 253 253 253 253 253
45310 -253 253 253 253 253 253 253 253 253 253 253 253
45311 -250 250 250 253 253 253 253 253 253 253 253 253
45312 -253 253 253 253 253 253 253 253 253 253 253 253
45313 -253 253 253 253 253 253 253 253 253 253 253 253
45314 -253 253 253 231 231 231 18 18 18 2 2 6
45315 - 2 2 6 2 2 6 2 2 6 2 2 6
45316 - 2 2 6 2 2 6 18 18 18 94 94 94
45317 - 54 54 54 26 26 26 10 10 10 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 0 0 0
45322 - 0 0 0 0 0 0 0 0 0 0 0 0
45323 - 0 0 0 0 0 0 0 0 0 0 0 0
45324 - 0 0 0 0 0 0 0 0 0 0 0 0
45325 - 0 0 0 0 0 0 0 0 0 0 0 0
45326 - 0 0 0 0 0 0 0 0 0 0 0 0
45327 - 0 0 0 6 6 6 22 22 22 50 50 50
45328 - 90 90 90 26 26 26 2 2 6 2 2 6
45329 - 14 14 14 195 195 195 250 250 250 253 253 253
45330 -253 253 253 253 253 253 253 253 253 253 253 253
45331 -253 253 253 253 253 253 253 253 253 253 253 253
45332 -253 253 253 253 253 253 253 253 253 253 253 253
45333 -253 253 253 253 253 253 253 253 253 253 253 253
45334 -250 250 250 242 242 242 54 54 54 2 2 6
45335 - 2 2 6 2 2 6 2 2 6 2 2 6
45336 - 2 2 6 2 2 6 2 2 6 38 38 38
45337 - 86 86 86 50 50 50 22 22 22 6 6 6
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 0 0 0 0 0 0
45342 - 0 0 0 0 0 0 0 0 0 0 0 0
45343 - 0 0 0 0 0 0 0 0 0 0 0 0
45344 - 0 0 0 0 0 0 0 0 0 0 0 0
45345 - 0 0 0 0 0 0 0 0 0 0 0 0
45346 - 0 0 0 0 0 0 0 0 0 0 0 0
45347 - 6 6 6 14 14 14 38 38 38 82 82 82
45348 - 34 34 34 2 2 6 2 2 6 2 2 6
45349 - 42 42 42 195 195 195 246 246 246 253 253 253
45350 -253 253 253 253 253 253 253 253 253 250 250 250
45351 -242 242 242 242 242 242 250 250 250 253 253 253
45352 -253 253 253 253 253 253 253 253 253 253 253 253
45353 -253 253 253 250 250 250 246 246 246 238 238 238
45354 -226 226 226 231 231 231 101 101 101 6 6 6
45355 - 2 2 6 2 2 6 2 2 6 2 2 6
45356 - 2 2 6 2 2 6 2 2 6 2 2 6
45357 - 38 38 38 82 82 82 42 42 42 14 14 14
45358 - 6 6 6 0 0 0 0 0 0 0 0 0
45359 - 0 0 0 0 0 0 0 0 0 0 0 0
45360 - 0 0 0 0 0 0 0 0 0 0 0 0
45361 - 0 0 0 0 0 0 0 0 0 0 0 0
45362 - 0 0 0 0 0 0 0 0 0 0 0 0
45363 - 0 0 0 0 0 0 0 0 0 0 0 0
45364 - 0 0 0 0 0 0 0 0 0 0 0 0
45365 - 0 0 0 0 0 0 0 0 0 0 0 0
45366 - 0 0 0 0 0 0 0 0 0 0 0 0
45367 - 10 10 10 26 26 26 62 62 62 66 66 66
45368 - 2 2 6 2 2 6 2 2 6 6 6 6
45369 - 70 70 70 170 170 170 206 206 206 234 234 234
45370 -246 246 246 250 250 250 250 250 250 238 238 238
45371 -226 226 226 231 231 231 238 238 238 250 250 250
45372 -250 250 250 250 250 250 246 246 246 231 231 231
45373 -214 214 214 206 206 206 202 202 202 202 202 202
45374 -198 198 198 202 202 202 182 182 182 18 18 18
45375 - 2 2 6 2 2 6 2 2 6 2 2 6
45376 - 2 2 6 2 2 6 2 2 6 2 2 6
45377 - 2 2 6 62 62 62 66 66 66 30 30 30
45378 - 10 10 10 0 0 0 0 0 0 0 0 0
45379 - 0 0 0 0 0 0 0 0 0 0 0 0
45380 - 0 0 0 0 0 0 0 0 0 0 0 0
45381 - 0 0 0 0 0 0 0 0 0 0 0 0
45382 - 0 0 0 0 0 0 0 0 0 0 0 0
45383 - 0 0 0 0 0 0 0 0 0 0 0 0
45384 - 0 0 0 0 0 0 0 0 0 0 0 0
45385 - 0 0 0 0 0 0 0 0 0 0 0 0
45386 - 0 0 0 0 0 0 0 0 0 0 0 0
45387 - 14 14 14 42 42 42 82 82 82 18 18 18
45388 - 2 2 6 2 2 6 2 2 6 10 10 10
45389 - 94 94 94 182 182 182 218 218 218 242 242 242
45390 -250 250 250 253 253 253 253 253 253 250 250 250
45391 -234 234 234 253 253 253 253 253 253 253 253 253
45392 -253 253 253 253 253 253 253 253 253 246 246 246
45393 -238 238 238 226 226 226 210 210 210 202 202 202
45394 -195 195 195 195 195 195 210 210 210 158 158 158
45395 - 6 6 6 14 14 14 50 50 50 14 14 14
45396 - 2 2 6 2 2 6 2 2 6 2 2 6
45397 - 2 2 6 6 6 6 86 86 86 46 46 46
45398 - 18 18 18 6 6 6 0 0 0 0 0 0
45399 - 0 0 0 0 0 0 0 0 0 0 0 0
45400 - 0 0 0 0 0 0 0 0 0 0 0 0
45401 - 0 0 0 0 0 0 0 0 0 0 0 0
45402 - 0 0 0 0 0 0 0 0 0 0 0 0
45403 - 0 0 0 0 0 0 0 0 0 0 0 0
45404 - 0 0 0 0 0 0 0 0 0 0 0 0
45405 - 0 0 0 0 0 0 0 0 0 0 0 0
45406 - 0 0 0 0 0 0 0 0 0 6 6 6
45407 - 22 22 22 54 54 54 70 70 70 2 2 6
45408 - 2 2 6 10 10 10 2 2 6 22 22 22
45409 -166 166 166 231 231 231 250 250 250 253 253 253
45410 -253 253 253 253 253 253 253 253 253 250 250 250
45411 -242 242 242 253 253 253 253 253 253 253 253 253
45412 -253 253 253 253 253 253 253 253 253 253 253 253
45413 -253 253 253 253 253 253 253 253 253 246 246 246
45414 -231 231 231 206 206 206 198 198 198 226 226 226
45415 - 94 94 94 2 2 6 6 6 6 38 38 38
45416 - 30 30 30 2 2 6 2 2 6 2 2 6
45417 - 2 2 6 2 2 6 62 62 62 66 66 66
45418 - 26 26 26 10 10 10 0 0 0 0 0 0
45419 - 0 0 0 0 0 0 0 0 0 0 0 0
45420 - 0 0 0 0 0 0 0 0 0 0 0 0
45421 - 0 0 0 0 0 0 0 0 0 0 0 0
45422 - 0 0 0 0 0 0 0 0 0 0 0 0
45423 - 0 0 0 0 0 0 0 0 0 0 0 0
45424 - 0 0 0 0 0 0 0 0 0 0 0 0
45425 - 0 0 0 0 0 0 0 0 0 0 0 0
45426 - 0 0 0 0 0 0 0 0 0 10 10 10
45427 - 30 30 30 74 74 74 50 50 50 2 2 6
45428 - 26 26 26 26 26 26 2 2 6 106 106 106
45429 -238 238 238 253 253 253 253 253 253 253 253 253
45430 -253 253 253 253 253 253 253 253 253 253 253 253
45431 -253 253 253 253 253 253 253 253 253 253 253 253
45432 -253 253 253 253 253 253 253 253 253 253 253 253
45433 -253 253 253 253 253 253 253 253 253 253 253 253
45434 -253 253 253 246 246 246 218 218 218 202 202 202
45435 -210 210 210 14 14 14 2 2 6 2 2 6
45436 - 30 30 30 22 22 22 2 2 6 2 2 6
45437 - 2 2 6 2 2 6 18 18 18 86 86 86
45438 - 42 42 42 14 14 14 0 0 0 0 0 0
45439 - 0 0 0 0 0 0 0 0 0 0 0 0
45440 - 0 0 0 0 0 0 0 0 0 0 0 0
45441 - 0 0 0 0 0 0 0 0 0 0 0 0
45442 - 0 0 0 0 0 0 0 0 0 0 0 0
45443 - 0 0 0 0 0 0 0 0 0 0 0 0
45444 - 0 0 0 0 0 0 0 0 0 0 0 0
45445 - 0 0 0 0 0 0 0 0 0 0 0 0
45446 - 0 0 0 0 0 0 0 0 0 14 14 14
45447 - 42 42 42 90 90 90 22 22 22 2 2 6
45448 - 42 42 42 2 2 6 18 18 18 218 218 218
45449 -253 253 253 253 253 253 253 253 253 253 253 253
45450 -253 253 253 253 253 253 253 253 253 253 253 253
45451 -253 253 253 253 253 253 253 253 253 253 253 253
45452 -253 253 253 253 253 253 253 253 253 253 253 253
45453 -253 253 253 253 253 253 253 253 253 253 253 253
45454 -253 253 253 253 253 253 250 250 250 221 221 221
45455 -218 218 218 101 101 101 2 2 6 14 14 14
45456 - 18 18 18 38 38 38 10 10 10 2 2 6
45457 - 2 2 6 2 2 6 2 2 6 78 78 78
45458 - 58 58 58 22 22 22 6 6 6 0 0 0
45459 - 0 0 0 0 0 0 0 0 0 0 0 0
45460 - 0 0 0 0 0 0 0 0 0 0 0 0
45461 - 0 0 0 0 0 0 0 0 0 0 0 0
45462 - 0 0 0 0 0 0 0 0 0 0 0 0
45463 - 0 0 0 0 0 0 0 0 0 0 0 0
45464 - 0 0 0 0 0 0 0 0 0 0 0 0
45465 - 0 0 0 0 0 0 0 0 0 0 0 0
45466 - 0 0 0 0 0 0 6 6 6 18 18 18
45467 - 54 54 54 82 82 82 2 2 6 26 26 26
45468 - 22 22 22 2 2 6 123 123 123 253 253 253
45469 -253 253 253 253 253 253 253 253 253 253 253 253
45470 -253 253 253 253 253 253 253 253 253 253 253 253
45471 -253 253 253 253 253 253 253 253 253 253 253 253
45472 -253 253 253 253 253 253 253 253 253 253 253 253
45473 -253 253 253 253 253 253 253 253 253 253 253 253
45474 -253 253 253 253 253 253 253 253 253 250 250 250
45475 -238 238 238 198 198 198 6 6 6 38 38 38
45476 - 58 58 58 26 26 26 38 38 38 2 2 6
45477 - 2 2 6 2 2 6 2 2 6 46 46 46
45478 - 78 78 78 30 30 30 10 10 10 0 0 0
45479 - 0 0 0 0 0 0 0 0 0 0 0 0
45480 - 0 0 0 0 0 0 0 0 0 0 0 0
45481 - 0 0 0 0 0 0 0 0 0 0 0 0
45482 - 0 0 0 0 0 0 0 0 0 0 0 0
45483 - 0 0 0 0 0 0 0 0 0 0 0 0
45484 - 0 0 0 0 0 0 0 0 0 0 0 0
45485 - 0 0 0 0 0 0 0 0 0 0 0 0
45486 - 0 0 0 0 0 0 10 10 10 30 30 30
45487 - 74 74 74 58 58 58 2 2 6 42 42 42
45488 - 2 2 6 22 22 22 231 231 231 253 253 253
45489 -253 253 253 253 253 253 253 253 253 253 253 253
45490 -253 253 253 253 253 253 253 253 253 250 250 250
45491 -253 253 253 253 253 253 253 253 253 253 253 253
45492 -253 253 253 253 253 253 253 253 253 253 253 253
45493 -253 253 253 253 253 253 253 253 253 253 253 253
45494 -253 253 253 253 253 253 253 253 253 253 253 253
45495 -253 253 253 246 246 246 46 46 46 38 38 38
45496 - 42 42 42 14 14 14 38 38 38 14 14 14
45497 - 2 2 6 2 2 6 2 2 6 6 6 6
45498 - 86 86 86 46 46 46 14 14 14 0 0 0
45499 - 0 0 0 0 0 0 0 0 0 0 0 0
45500 - 0 0 0 0 0 0 0 0 0 0 0 0
45501 - 0 0 0 0 0 0 0 0 0 0 0 0
45502 - 0 0 0 0 0 0 0 0 0 0 0 0
45503 - 0 0 0 0 0 0 0 0 0 0 0 0
45504 - 0 0 0 0 0 0 0 0 0 0 0 0
45505 - 0 0 0 0 0 0 0 0 0 0 0 0
45506 - 0 0 0 6 6 6 14 14 14 42 42 42
45507 - 90 90 90 18 18 18 18 18 18 26 26 26
45508 - 2 2 6 116 116 116 253 253 253 253 253 253
45509 -253 253 253 253 253 253 253 253 253 253 253 253
45510 -253 253 253 253 253 253 250 250 250 238 238 238
45511 -253 253 253 253 253 253 253 253 253 253 253 253
45512 -253 253 253 253 253 253 253 253 253 253 253 253
45513 -253 253 253 253 253 253 253 253 253 253 253 253
45514 -253 253 253 253 253 253 253 253 253 253 253 253
45515 -253 253 253 253 253 253 94 94 94 6 6 6
45516 - 2 2 6 2 2 6 10 10 10 34 34 34
45517 - 2 2 6 2 2 6 2 2 6 2 2 6
45518 - 74 74 74 58 58 58 22 22 22 6 6 6
45519 - 0 0 0 0 0 0 0 0 0 0 0 0
45520 - 0 0 0 0 0 0 0 0 0 0 0 0
45521 - 0 0 0 0 0 0 0 0 0 0 0 0
45522 - 0 0 0 0 0 0 0 0 0 0 0 0
45523 - 0 0 0 0 0 0 0 0 0 0 0 0
45524 - 0 0 0 0 0 0 0 0 0 0 0 0
45525 - 0 0 0 0 0 0 0 0 0 0 0 0
45526 - 0 0 0 10 10 10 26 26 26 66 66 66
45527 - 82 82 82 2 2 6 38 38 38 6 6 6
45528 - 14 14 14 210 210 210 253 253 253 253 253 253
45529 -253 253 253 253 253 253 253 253 253 253 253 253
45530 -253 253 253 253 253 253 246 246 246 242 242 242
45531 -253 253 253 253 253 253 253 253 253 253 253 253
45532 -253 253 253 253 253 253 253 253 253 253 253 253
45533 -253 253 253 253 253 253 253 253 253 253 253 253
45534 -253 253 253 253 253 253 253 253 253 253 253 253
45535 -253 253 253 253 253 253 144 144 144 2 2 6
45536 - 2 2 6 2 2 6 2 2 6 46 46 46
45537 - 2 2 6 2 2 6 2 2 6 2 2 6
45538 - 42 42 42 74 74 74 30 30 30 10 10 10
45539 - 0 0 0 0 0 0 0 0 0 0 0 0
45540 - 0 0 0 0 0 0 0 0 0 0 0 0
45541 - 0 0 0 0 0 0 0 0 0 0 0 0
45542 - 0 0 0 0 0 0 0 0 0 0 0 0
45543 - 0 0 0 0 0 0 0 0 0 0 0 0
45544 - 0 0 0 0 0 0 0 0 0 0 0 0
45545 - 0 0 0 0 0 0 0 0 0 0 0 0
45546 - 6 6 6 14 14 14 42 42 42 90 90 90
45547 - 26 26 26 6 6 6 42 42 42 2 2 6
45548 - 74 74 74 250 250 250 253 253 253 253 253 253
45549 -253 253 253 253 253 253 253 253 253 253 253 253
45550 -253 253 253 253 253 253 242 242 242 242 242 242
45551 -253 253 253 253 253 253 253 253 253 253 253 253
45552 -253 253 253 253 253 253 253 253 253 253 253 253
45553 -253 253 253 253 253 253 253 253 253 253 253 253
45554 -253 253 253 253 253 253 253 253 253 253 253 253
45555 -253 253 253 253 253 253 182 182 182 2 2 6
45556 - 2 2 6 2 2 6 2 2 6 46 46 46
45557 - 2 2 6 2 2 6 2 2 6 2 2 6
45558 - 10 10 10 86 86 86 38 38 38 10 10 10
45559 - 0 0 0 0 0 0 0 0 0 0 0 0
45560 - 0 0 0 0 0 0 0 0 0 0 0 0
45561 - 0 0 0 0 0 0 0 0 0 0 0 0
45562 - 0 0 0 0 0 0 0 0 0 0 0 0
45563 - 0 0 0 0 0 0 0 0 0 0 0 0
45564 - 0 0 0 0 0 0 0 0 0 0 0 0
45565 - 0 0 0 0 0 0 0 0 0 0 0 0
45566 - 10 10 10 26 26 26 66 66 66 82 82 82
45567 - 2 2 6 22 22 22 18 18 18 2 2 6
45568 -149 149 149 253 253 253 253 253 253 253 253 253
45569 -253 253 253 253 253 253 253 253 253 253 253 253
45570 -253 253 253 253 253 253 234 234 234 242 242 242
45571 -253 253 253 253 253 253 253 253 253 253 253 253
45572 -253 253 253 253 253 253 253 253 253 253 253 253
45573 -253 253 253 253 253 253 253 253 253 253 253 253
45574 -253 253 253 253 253 253 253 253 253 253 253 253
45575 -253 253 253 253 253 253 206 206 206 2 2 6
45576 - 2 2 6 2 2 6 2 2 6 38 38 38
45577 - 2 2 6 2 2 6 2 2 6 2 2 6
45578 - 6 6 6 86 86 86 46 46 46 14 14 14
45579 - 0 0 0 0 0 0 0 0 0 0 0 0
45580 - 0 0 0 0 0 0 0 0 0 0 0 0
45581 - 0 0 0 0 0 0 0 0 0 0 0 0
45582 - 0 0 0 0 0 0 0 0 0 0 0 0
45583 - 0 0 0 0 0 0 0 0 0 0 0 0
45584 - 0 0 0 0 0 0 0 0 0 0 0 0
45585 - 0 0 0 0 0 0 0 0 0 6 6 6
45586 - 18 18 18 46 46 46 86 86 86 18 18 18
45587 - 2 2 6 34 34 34 10 10 10 6 6 6
45588 -210 210 210 253 253 253 253 253 253 253 253 253
45589 -253 253 253 253 253 253 253 253 253 253 253 253
45590 -253 253 253 253 253 253 234 234 234 242 242 242
45591 -253 253 253 253 253 253 253 253 253 253 253 253
45592 -253 253 253 253 253 253 253 253 253 253 253 253
45593 -253 253 253 253 253 253 253 253 253 253 253 253
45594 -253 253 253 253 253 253 253 253 253 253 253 253
45595 -253 253 253 253 253 253 221 221 221 6 6 6
45596 - 2 2 6 2 2 6 6 6 6 30 30 30
45597 - 2 2 6 2 2 6 2 2 6 2 2 6
45598 - 2 2 6 82 82 82 54 54 54 18 18 18
45599 - 6 6 6 0 0 0 0 0 0 0 0 0
45600 - 0 0 0 0 0 0 0 0 0 0 0 0
45601 - 0 0 0 0 0 0 0 0 0 0 0 0
45602 - 0 0 0 0 0 0 0 0 0 0 0 0
45603 - 0 0 0 0 0 0 0 0 0 0 0 0
45604 - 0 0 0 0 0 0 0 0 0 0 0 0
45605 - 0 0 0 0 0 0 0 0 0 10 10 10
45606 - 26 26 26 66 66 66 62 62 62 2 2 6
45607 - 2 2 6 38 38 38 10 10 10 26 26 26
45608 -238 238 238 253 253 253 253 253 253 253 253 253
45609 -253 253 253 253 253 253 253 253 253 253 253 253
45610 -253 253 253 253 253 253 231 231 231 238 238 238
45611 -253 253 253 253 253 253 253 253 253 253 253 253
45612 -253 253 253 253 253 253 253 253 253 253 253 253
45613 -253 253 253 253 253 253 253 253 253 253 253 253
45614 -253 253 253 253 253 253 253 253 253 253 253 253
45615 -253 253 253 253 253 253 231 231 231 6 6 6
45616 - 2 2 6 2 2 6 10 10 10 30 30 30
45617 - 2 2 6 2 2 6 2 2 6 2 2 6
45618 - 2 2 6 66 66 66 58 58 58 22 22 22
45619 - 6 6 6 0 0 0 0 0 0 0 0 0
45620 - 0 0 0 0 0 0 0 0 0 0 0 0
45621 - 0 0 0 0 0 0 0 0 0 0 0 0
45622 - 0 0 0 0 0 0 0 0 0 0 0 0
45623 - 0 0 0 0 0 0 0 0 0 0 0 0
45624 - 0 0 0 0 0 0 0 0 0 0 0 0
45625 - 0 0 0 0 0 0 0 0 0 10 10 10
45626 - 38 38 38 78 78 78 6 6 6 2 2 6
45627 - 2 2 6 46 46 46 14 14 14 42 42 42
45628 -246 246 246 253 253 253 253 253 253 253 253 253
45629 -253 253 253 253 253 253 253 253 253 253 253 253
45630 -253 253 253 253 253 253 231 231 231 242 242 242
45631 -253 253 253 253 253 253 253 253 253 253 253 253
45632 -253 253 253 253 253 253 253 253 253 253 253 253
45633 -253 253 253 253 253 253 253 253 253 253 253 253
45634 -253 253 253 253 253 253 253 253 253 253 253 253
45635 -253 253 253 253 253 253 234 234 234 10 10 10
45636 - 2 2 6 2 2 6 22 22 22 14 14 14
45637 - 2 2 6 2 2 6 2 2 6 2 2 6
45638 - 2 2 6 66 66 66 62 62 62 22 22 22
45639 - 6 6 6 0 0 0 0 0 0 0 0 0
45640 - 0 0 0 0 0 0 0 0 0 0 0 0
45641 - 0 0 0 0 0 0 0 0 0 0 0 0
45642 - 0 0 0 0 0 0 0 0 0 0 0 0
45643 - 0 0 0 0 0 0 0 0 0 0 0 0
45644 - 0 0 0 0 0 0 0 0 0 0 0 0
45645 - 0 0 0 0 0 0 6 6 6 18 18 18
45646 - 50 50 50 74 74 74 2 2 6 2 2 6
45647 - 14 14 14 70 70 70 34 34 34 62 62 62
45648 -250 250 250 253 253 253 253 253 253 253 253 253
45649 -253 253 253 253 253 253 253 253 253 253 253 253
45650 -253 253 253 253 253 253 231 231 231 246 246 246
45651 -253 253 253 253 253 253 253 253 253 253 253 253
45652 -253 253 253 253 253 253 253 253 253 253 253 253
45653 -253 253 253 253 253 253 253 253 253 253 253 253
45654 -253 253 253 253 253 253 253 253 253 253 253 253
45655 -253 253 253 253 253 253 234 234 234 14 14 14
45656 - 2 2 6 2 2 6 30 30 30 2 2 6
45657 - 2 2 6 2 2 6 2 2 6 2 2 6
45658 - 2 2 6 66 66 66 62 62 62 22 22 22
45659 - 6 6 6 0 0 0 0 0 0 0 0 0
45660 - 0 0 0 0 0 0 0 0 0 0 0 0
45661 - 0 0 0 0 0 0 0 0 0 0 0 0
45662 - 0 0 0 0 0 0 0 0 0 0 0 0
45663 - 0 0 0 0 0 0 0 0 0 0 0 0
45664 - 0 0 0 0 0 0 0 0 0 0 0 0
45665 - 0 0 0 0 0 0 6 6 6 18 18 18
45666 - 54 54 54 62 62 62 2 2 6 2 2 6
45667 - 2 2 6 30 30 30 46 46 46 70 70 70
45668 -250 250 250 253 253 253 253 253 253 253 253 253
45669 -253 253 253 253 253 253 253 253 253 253 253 253
45670 -253 253 253 253 253 253 231 231 231 246 246 246
45671 -253 253 253 253 253 253 253 253 253 253 253 253
45672 -253 253 253 253 253 253 253 253 253 253 253 253
45673 -253 253 253 253 253 253 253 253 253 253 253 253
45674 -253 253 253 253 253 253 253 253 253 253 253 253
45675 -253 253 253 253 253 253 226 226 226 10 10 10
45676 - 2 2 6 6 6 6 30 30 30 2 2 6
45677 - 2 2 6 2 2 6 2 2 6 2 2 6
45678 - 2 2 6 66 66 66 58 58 58 22 22 22
45679 - 6 6 6 0 0 0 0 0 0 0 0 0
45680 - 0 0 0 0 0 0 0 0 0 0 0 0
45681 - 0 0 0 0 0 0 0 0 0 0 0 0
45682 - 0 0 0 0 0 0 0 0 0 0 0 0
45683 - 0 0 0 0 0 0 0 0 0 0 0 0
45684 - 0 0 0 0 0 0 0 0 0 0 0 0
45685 - 0 0 0 0 0 0 6 6 6 22 22 22
45686 - 58 58 58 62 62 62 2 2 6 2 2 6
45687 - 2 2 6 2 2 6 30 30 30 78 78 78
45688 -250 250 250 253 253 253 253 253 253 253 253 253
45689 -253 253 253 253 253 253 253 253 253 253 253 253
45690 -253 253 253 253 253 253 231 231 231 246 246 246
45691 -253 253 253 253 253 253 253 253 253 253 253 253
45692 -253 253 253 253 253 253 253 253 253 253 253 253
45693 -253 253 253 253 253 253 253 253 253 253 253 253
45694 -253 253 253 253 253 253 253 253 253 253 253 253
45695 -253 253 253 253 253 253 206 206 206 2 2 6
45696 - 22 22 22 34 34 34 18 14 6 22 22 22
45697 - 26 26 26 18 18 18 6 6 6 2 2 6
45698 - 2 2 6 82 82 82 54 54 54 18 18 18
45699 - 6 6 6 0 0 0 0 0 0 0 0 0
45700 - 0 0 0 0 0 0 0 0 0 0 0 0
45701 - 0 0 0 0 0 0 0 0 0 0 0 0
45702 - 0 0 0 0 0 0 0 0 0 0 0 0
45703 - 0 0 0 0 0 0 0 0 0 0 0 0
45704 - 0 0 0 0 0 0 0 0 0 0 0 0
45705 - 0 0 0 0 0 0 6 6 6 26 26 26
45706 - 62 62 62 106 106 106 74 54 14 185 133 11
45707 -210 162 10 121 92 8 6 6 6 62 62 62
45708 -238 238 238 253 253 253 253 253 253 253 253 253
45709 -253 253 253 253 253 253 253 253 253 253 253 253
45710 -253 253 253 253 253 253 231 231 231 246 246 246
45711 -253 253 253 253 253 253 253 253 253 253 253 253
45712 -253 253 253 253 253 253 253 253 253 253 253 253
45713 -253 253 253 253 253 253 253 253 253 253 253 253
45714 -253 253 253 253 253 253 253 253 253 253 253 253
45715 -253 253 253 253 253 253 158 158 158 18 18 18
45716 - 14 14 14 2 2 6 2 2 6 2 2 6
45717 - 6 6 6 18 18 18 66 66 66 38 38 38
45718 - 6 6 6 94 94 94 50 50 50 18 18 18
45719 - 6 6 6 0 0 0 0 0 0 0 0 0
45720 - 0 0 0 0 0 0 0 0 0 0 0 0
45721 - 0 0 0 0 0 0 0 0 0 0 0 0
45722 - 0 0 0 0 0 0 0 0 0 0 0 0
45723 - 0 0 0 0 0 0 0 0 0 0 0 0
45724 - 0 0 0 0 0 0 0 0 0 6 6 6
45725 - 10 10 10 10 10 10 18 18 18 38 38 38
45726 - 78 78 78 142 134 106 216 158 10 242 186 14
45727 -246 190 14 246 190 14 156 118 10 10 10 10
45728 - 90 90 90 238 238 238 253 253 253 253 253 253
45729 -253 253 253 253 253 253 253 253 253 253 253 253
45730 -253 253 253 253 253 253 231 231 231 250 250 250
45731 -253 253 253 253 253 253 253 253 253 253 253 253
45732 -253 253 253 253 253 253 253 253 253 253 253 253
45733 -253 253 253 253 253 253 253 253 253 253 253 253
45734 -253 253 253 253 253 253 253 253 253 246 230 190
45735 -238 204 91 238 204 91 181 142 44 37 26 9
45736 - 2 2 6 2 2 6 2 2 6 2 2 6
45737 - 2 2 6 2 2 6 38 38 38 46 46 46
45738 - 26 26 26 106 106 106 54 54 54 18 18 18
45739 - 6 6 6 0 0 0 0 0 0 0 0 0
45740 - 0 0 0 0 0 0 0 0 0 0 0 0
45741 - 0 0 0 0 0 0 0 0 0 0 0 0
45742 - 0 0 0 0 0 0 0 0 0 0 0 0
45743 - 0 0 0 0 0 0 0 0 0 0 0 0
45744 - 0 0 0 6 6 6 14 14 14 22 22 22
45745 - 30 30 30 38 38 38 50 50 50 70 70 70
45746 -106 106 106 190 142 34 226 170 11 242 186 14
45747 -246 190 14 246 190 14 246 190 14 154 114 10
45748 - 6 6 6 74 74 74 226 226 226 253 253 253
45749 -253 253 253 253 253 253 253 253 253 253 253 253
45750 -253 253 253 253 253 253 231 231 231 250 250 250
45751 -253 253 253 253 253 253 253 253 253 253 253 253
45752 -253 253 253 253 253 253 253 253 253 253 253 253
45753 -253 253 253 253 253 253 253 253 253 253 253 253
45754 -253 253 253 253 253 253 253 253 253 228 184 62
45755 -241 196 14 241 208 19 232 195 16 38 30 10
45756 - 2 2 6 2 2 6 2 2 6 2 2 6
45757 - 2 2 6 6 6 6 30 30 30 26 26 26
45758 -203 166 17 154 142 90 66 66 66 26 26 26
45759 - 6 6 6 0 0 0 0 0 0 0 0 0
45760 - 0 0 0 0 0 0 0 0 0 0 0 0
45761 - 0 0 0 0 0 0 0 0 0 0 0 0
45762 - 0 0 0 0 0 0 0 0 0 0 0 0
45763 - 0 0 0 0 0 0 0 0 0 0 0 0
45764 - 6 6 6 18 18 18 38 38 38 58 58 58
45765 - 78 78 78 86 86 86 101 101 101 123 123 123
45766 -175 146 61 210 150 10 234 174 13 246 186 14
45767 -246 190 14 246 190 14 246 190 14 238 190 10
45768 -102 78 10 2 2 6 46 46 46 198 198 198
45769 -253 253 253 253 253 253 253 253 253 253 253 253
45770 -253 253 253 253 253 253 234 234 234 242 242 242
45771 -253 253 253 253 253 253 253 253 253 253 253 253
45772 -253 253 253 253 253 253 253 253 253 253 253 253
45773 -253 253 253 253 253 253 253 253 253 253 253 253
45774 -253 253 253 253 253 253 253 253 253 224 178 62
45775 -242 186 14 241 196 14 210 166 10 22 18 6
45776 - 2 2 6 2 2 6 2 2 6 2 2 6
45777 - 2 2 6 2 2 6 6 6 6 121 92 8
45778 -238 202 15 232 195 16 82 82 82 34 34 34
45779 - 10 10 10 0 0 0 0 0 0 0 0 0
45780 - 0 0 0 0 0 0 0 0 0 0 0 0
45781 - 0 0 0 0 0 0 0 0 0 0 0 0
45782 - 0 0 0 0 0 0 0 0 0 0 0 0
45783 - 0 0 0 0 0 0 0 0 0 0 0 0
45784 - 14 14 14 38 38 38 70 70 70 154 122 46
45785 -190 142 34 200 144 11 197 138 11 197 138 11
45786 -213 154 11 226 170 11 242 186 14 246 190 14
45787 -246 190 14 246 190 14 246 190 14 246 190 14
45788 -225 175 15 46 32 6 2 2 6 22 22 22
45789 -158 158 158 250 250 250 253 253 253 253 253 253
45790 -253 253 253 253 253 253 253 253 253 253 253 253
45791 -253 253 253 253 253 253 253 253 253 253 253 253
45792 -253 253 253 253 253 253 253 253 253 253 253 253
45793 -253 253 253 253 253 253 253 253 253 253 253 253
45794 -253 253 253 250 250 250 242 242 242 224 178 62
45795 -239 182 13 236 186 11 213 154 11 46 32 6
45796 - 2 2 6 2 2 6 2 2 6 2 2 6
45797 - 2 2 6 2 2 6 61 42 6 225 175 15
45798 -238 190 10 236 186 11 112 100 78 42 42 42
45799 - 14 14 14 0 0 0 0 0 0 0 0 0
45800 - 0 0 0 0 0 0 0 0 0 0 0 0
45801 - 0 0 0 0 0 0 0 0 0 0 0 0
45802 - 0 0 0 0 0 0 0 0 0 0 0 0
45803 - 0 0 0 0 0 0 0 0 0 6 6 6
45804 - 22 22 22 54 54 54 154 122 46 213 154 11
45805 -226 170 11 230 174 11 226 170 11 226 170 11
45806 -236 178 12 242 186 14 246 190 14 246 190 14
45807 -246 190 14 246 190 14 246 190 14 246 190 14
45808 -241 196 14 184 144 12 10 10 10 2 2 6
45809 - 6 6 6 116 116 116 242 242 242 253 253 253
45810 -253 253 253 253 253 253 253 253 253 253 253 253
45811 -253 253 253 253 253 253 253 253 253 253 253 253
45812 -253 253 253 253 253 253 253 253 253 253 253 253
45813 -253 253 253 253 253 253 253 253 253 253 253 253
45814 -253 253 253 231 231 231 198 198 198 214 170 54
45815 -236 178 12 236 178 12 210 150 10 137 92 6
45816 - 18 14 6 2 2 6 2 2 6 2 2 6
45817 - 6 6 6 70 47 6 200 144 11 236 178 12
45818 -239 182 13 239 182 13 124 112 88 58 58 58
45819 - 22 22 22 6 6 6 0 0 0 0 0 0
45820 - 0 0 0 0 0 0 0 0 0 0 0 0
45821 - 0 0 0 0 0 0 0 0 0 0 0 0
45822 - 0 0 0 0 0 0 0 0 0 0 0 0
45823 - 0 0 0 0 0 0 0 0 0 10 10 10
45824 - 30 30 30 70 70 70 180 133 36 226 170 11
45825 -239 182 13 242 186 14 242 186 14 246 186 14
45826 -246 190 14 246 190 14 246 190 14 246 190 14
45827 -246 190 14 246 190 14 246 190 14 246 190 14
45828 -246 190 14 232 195 16 98 70 6 2 2 6
45829 - 2 2 6 2 2 6 66 66 66 221 221 221
45830 -253 253 253 253 253 253 253 253 253 253 253 253
45831 -253 253 253 253 253 253 253 253 253 253 253 253
45832 -253 253 253 253 253 253 253 253 253 253 253 253
45833 -253 253 253 253 253 253 253 253 253 253 253 253
45834 -253 253 253 206 206 206 198 198 198 214 166 58
45835 -230 174 11 230 174 11 216 158 10 192 133 9
45836 -163 110 8 116 81 8 102 78 10 116 81 8
45837 -167 114 7 197 138 11 226 170 11 239 182 13
45838 -242 186 14 242 186 14 162 146 94 78 78 78
45839 - 34 34 34 14 14 14 6 6 6 0 0 0
45840 - 0 0 0 0 0 0 0 0 0 0 0 0
45841 - 0 0 0 0 0 0 0 0 0 0 0 0
45842 - 0 0 0 0 0 0 0 0 0 0 0 0
45843 - 0 0 0 0 0 0 0 0 0 6 6 6
45844 - 30 30 30 78 78 78 190 142 34 226 170 11
45845 -239 182 13 246 190 14 246 190 14 246 190 14
45846 -246 190 14 246 190 14 246 190 14 246 190 14
45847 -246 190 14 246 190 14 246 190 14 246 190 14
45848 -246 190 14 241 196 14 203 166 17 22 18 6
45849 - 2 2 6 2 2 6 2 2 6 38 38 38
45850 -218 218 218 253 253 253 253 253 253 253 253 253
45851 -253 253 253 253 253 253 253 253 253 253 253 253
45852 -253 253 253 253 253 253 253 253 253 253 253 253
45853 -253 253 253 253 253 253 253 253 253 253 253 253
45854 -250 250 250 206 206 206 198 198 198 202 162 69
45855 -226 170 11 236 178 12 224 166 10 210 150 10
45856 -200 144 11 197 138 11 192 133 9 197 138 11
45857 -210 150 10 226 170 11 242 186 14 246 190 14
45858 -246 190 14 246 186 14 225 175 15 124 112 88
45859 - 62 62 62 30 30 30 14 14 14 6 6 6
45860 - 0 0 0 0 0 0 0 0 0 0 0 0
45861 - 0 0 0 0 0 0 0 0 0 0 0 0
45862 - 0 0 0 0 0 0 0 0 0 0 0 0
45863 - 0 0 0 0 0 0 0 0 0 10 10 10
45864 - 30 30 30 78 78 78 174 135 50 224 166 10
45865 -239 182 13 246 190 14 246 190 14 246 190 14
45866 -246 190 14 246 190 14 246 190 14 246 190 14
45867 -246 190 14 246 190 14 246 190 14 246 190 14
45868 -246 190 14 246 190 14 241 196 14 139 102 15
45869 - 2 2 6 2 2 6 2 2 6 2 2 6
45870 - 78 78 78 250 250 250 253 253 253 253 253 253
45871 -253 253 253 253 253 253 253 253 253 253 253 253
45872 -253 253 253 253 253 253 253 253 253 253 253 253
45873 -253 253 253 253 253 253 253 253 253 253 253 253
45874 -250 250 250 214 214 214 198 198 198 190 150 46
45875 -219 162 10 236 178 12 234 174 13 224 166 10
45876 -216 158 10 213 154 11 213 154 11 216 158 10
45877 -226 170 11 239 182 13 246 190 14 246 190 14
45878 -246 190 14 246 190 14 242 186 14 206 162 42
45879 -101 101 101 58 58 58 30 30 30 14 14 14
45880 - 6 6 6 0 0 0 0 0 0 0 0 0
45881 - 0 0 0 0 0 0 0 0 0 0 0 0
45882 - 0 0 0 0 0 0 0 0 0 0 0 0
45883 - 0 0 0 0 0 0 0 0 0 10 10 10
45884 - 30 30 30 74 74 74 174 135 50 216 158 10
45885 -236 178 12 246 190 14 246 190 14 246 190 14
45886 -246 190 14 246 190 14 246 190 14 246 190 14
45887 -246 190 14 246 190 14 246 190 14 246 190 14
45888 -246 190 14 246 190 14 241 196 14 226 184 13
45889 - 61 42 6 2 2 6 2 2 6 2 2 6
45890 - 22 22 22 238 238 238 253 253 253 253 253 253
45891 -253 253 253 253 253 253 253 253 253 253 253 253
45892 -253 253 253 253 253 253 253 253 253 253 253 253
45893 -253 253 253 253 253 253 253 253 253 253 253 253
45894 -253 253 253 226 226 226 187 187 187 180 133 36
45895 -216 158 10 236 178 12 239 182 13 236 178 12
45896 -230 174 11 226 170 11 226 170 11 230 174 11
45897 -236 178 12 242 186 14 246 190 14 246 190 14
45898 -246 190 14 246 190 14 246 186 14 239 182 13
45899 -206 162 42 106 106 106 66 66 66 34 34 34
45900 - 14 14 14 6 6 6 0 0 0 0 0 0
45901 - 0 0 0 0 0 0 0 0 0 0 0 0
45902 - 0 0 0 0 0 0 0 0 0 0 0 0
45903 - 0 0 0 0 0 0 0 0 0 6 6 6
45904 - 26 26 26 70 70 70 163 133 67 213 154 11
45905 -236 178 12 246 190 14 246 190 14 246 190 14
45906 -246 190 14 246 190 14 246 190 14 246 190 14
45907 -246 190 14 246 190 14 246 190 14 246 190 14
45908 -246 190 14 246 190 14 246 190 14 241 196 14
45909 -190 146 13 18 14 6 2 2 6 2 2 6
45910 - 46 46 46 246 246 246 253 253 253 253 253 253
45911 -253 253 253 253 253 253 253 253 253 253 253 253
45912 -253 253 253 253 253 253 253 253 253 253 253 253
45913 -253 253 253 253 253 253 253 253 253 253 253 253
45914 -253 253 253 221 221 221 86 86 86 156 107 11
45915 -216 158 10 236 178 12 242 186 14 246 186 14
45916 -242 186 14 239 182 13 239 182 13 242 186 14
45917 -242 186 14 246 186 14 246 190 14 246 190 14
45918 -246 190 14 246 190 14 246 190 14 246 190 14
45919 -242 186 14 225 175 15 142 122 72 66 66 66
45920 - 30 30 30 10 10 10 0 0 0 0 0 0
45921 - 0 0 0 0 0 0 0 0 0 0 0 0
45922 - 0 0 0 0 0 0 0 0 0 0 0 0
45923 - 0 0 0 0 0 0 0 0 0 6 6 6
45924 - 26 26 26 70 70 70 163 133 67 210 150 10
45925 -236 178 12 246 190 14 246 190 14 246 190 14
45926 -246 190 14 246 190 14 246 190 14 246 190 14
45927 -246 190 14 246 190 14 246 190 14 246 190 14
45928 -246 190 14 246 190 14 246 190 14 246 190 14
45929 -232 195 16 121 92 8 34 34 34 106 106 106
45930 -221 221 221 253 253 253 253 253 253 253 253 253
45931 -253 253 253 253 253 253 253 253 253 253 253 253
45932 -253 253 253 253 253 253 253 253 253 253 253 253
45933 -253 253 253 253 253 253 253 253 253 253 253 253
45934 -242 242 242 82 82 82 18 14 6 163 110 8
45935 -216 158 10 236 178 12 242 186 14 246 190 14
45936 -246 190 14 246 190 14 246 190 14 246 190 14
45937 -246 190 14 246 190 14 246 190 14 246 190 14
45938 -246 190 14 246 190 14 246 190 14 246 190 14
45939 -246 190 14 246 190 14 242 186 14 163 133 67
45940 - 46 46 46 18 18 18 6 6 6 0 0 0
45941 - 0 0 0 0 0 0 0 0 0 0 0 0
45942 - 0 0 0 0 0 0 0 0 0 0 0 0
45943 - 0 0 0 0 0 0 0 0 0 10 10 10
45944 - 30 30 30 78 78 78 163 133 67 210 150 10
45945 -236 178 12 246 186 14 246 190 14 246 190 14
45946 -246 190 14 246 190 14 246 190 14 246 190 14
45947 -246 190 14 246 190 14 246 190 14 246 190 14
45948 -246 190 14 246 190 14 246 190 14 246 190 14
45949 -241 196 14 215 174 15 190 178 144 253 253 253
45950 -253 253 253 253 253 253 253 253 253 253 253 253
45951 -253 253 253 253 253 253 253 253 253 253 253 253
45952 -253 253 253 253 253 253 253 253 253 253 253 253
45953 -253 253 253 253 253 253 253 253 253 218 218 218
45954 - 58 58 58 2 2 6 22 18 6 167 114 7
45955 -216 158 10 236 178 12 246 186 14 246 190 14
45956 -246 190 14 246 190 14 246 190 14 246 190 14
45957 -246 190 14 246 190 14 246 190 14 246 190 14
45958 -246 190 14 246 190 14 246 190 14 246 190 14
45959 -246 190 14 246 186 14 242 186 14 190 150 46
45960 - 54 54 54 22 22 22 6 6 6 0 0 0
45961 - 0 0 0 0 0 0 0 0 0 0 0 0
45962 - 0 0 0 0 0 0 0 0 0 0 0 0
45963 - 0 0 0 0 0 0 0 0 0 14 14 14
45964 - 38 38 38 86 86 86 180 133 36 213 154 11
45965 -236 178 12 246 186 14 246 190 14 246 190 14
45966 -246 190 14 246 190 14 246 190 14 246 190 14
45967 -246 190 14 246 190 14 246 190 14 246 190 14
45968 -246 190 14 246 190 14 246 190 14 246 190 14
45969 -246 190 14 232 195 16 190 146 13 214 214 214
45970 -253 253 253 253 253 253 253 253 253 253 253 253
45971 -253 253 253 253 253 253 253 253 253 253 253 253
45972 -253 253 253 253 253 253 253 253 253 253 253 253
45973 -253 253 253 250 250 250 170 170 170 26 26 26
45974 - 2 2 6 2 2 6 37 26 9 163 110 8
45975 -219 162 10 239 182 13 246 186 14 246 190 14
45976 -246 190 14 246 190 14 246 190 14 246 190 14
45977 -246 190 14 246 190 14 246 190 14 246 190 14
45978 -246 190 14 246 190 14 246 190 14 246 190 14
45979 -246 186 14 236 178 12 224 166 10 142 122 72
45980 - 46 46 46 18 18 18 6 6 6 0 0 0
45981 - 0 0 0 0 0 0 0 0 0 0 0 0
45982 - 0 0 0 0 0 0 0 0 0 0 0 0
45983 - 0 0 0 0 0 0 6 6 6 18 18 18
45984 - 50 50 50 109 106 95 192 133 9 224 166 10
45985 -242 186 14 246 190 14 246 190 14 246 190 14
45986 -246 190 14 246 190 14 246 190 14 246 190 14
45987 -246 190 14 246 190 14 246 190 14 246 190 14
45988 -246 190 14 246 190 14 246 190 14 246 190 14
45989 -242 186 14 226 184 13 210 162 10 142 110 46
45990 -226 226 226 253 253 253 253 253 253 253 253 253
45991 -253 253 253 253 253 253 253 253 253 253 253 253
45992 -253 253 253 253 253 253 253 253 253 253 253 253
45993 -198 198 198 66 66 66 2 2 6 2 2 6
45994 - 2 2 6 2 2 6 50 34 6 156 107 11
45995 -219 162 10 239 182 13 246 186 14 246 190 14
45996 -246 190 14 246 190 14 246 190 14 246 190 14
45997 -246 190 14 246 190 14 246 190 14 246 190 14
45998 -246 190 14 246 190 14 246 190 14 242 186 14
45999 -234 174 13 213 154 11 154 122 46 66 66 66
46000 - 30 30 30 10 10 10 0 0 0 0 0 0
46001 - 0 0 0 0 0 0 0 0 0 0 0 0
46002 - 0 0 0 0 0 0 0 0 0 0 0 0
46003 - 0 0 0 0 0 0 6 6 6 22 22 22
46004 - 58 58 58 154 121 60 206 145 10 234 174 13
46005 -242 186 14 246 186 14 246 190 14 246 190 14
46006 -246 190 14 246 190 14 246 190 14 246 190 14
46007 -246 190 14 246 190 14 246 190 14 246 190 14
46008 -246 190 14 246 190 14 246 190 14 246 190 14
46009 -246 186 14 236 178 12 210 162 10 163 110 8
46010 - 61 42 6 138 138 138 218 218 218 250 250 250
46011 -253 253 253 253 253 253 253 253 253 250 250 250
46012 -242 242 242 210 210 210 144 144 144 66 66 66
46013 - 6 6 6 2 2 6 2 2 6 2 2 6
46014 - 2 2 6 2 2 6 61 42 6 163 110 8
46015 -216 158 10 236 178 12 246 190 14 246 190 14
46016 -246 190 14 246 190 14 246 190 14 246 190 14
46017 -246 190 14 246 190 14 246 190 14 246 190 14
46018 -246 190 14 239 182 13 230 174 11 216 158 10
46019 -190 142 34 124 112 88 70 70 70 38 38 38
46020 - 18 18 18 6 6 6 0 0 0 0 0 0
46021 - 0 0 0 0 0 0 0 0 0 0 0 0
46022 - 0 0 0 0 0 0 0 0 0 0 0 0
46023 - 0 0 0 0 0 0 6 6 6 22 22 22
46024 - 62 62 62 168 124 44 206 145 10 224 166 10
46025 -236 178 12 239 182 13 242 186 14 242 186 14
46026 -246 186 14 246 190 14 246 190 14 246 190 14
46027 -246 190 14 246 190 14 246 190 14 246 190 14
46028 -246 190 14 246 190 14 246 190 14 246 190 14
46029 -246 190 14 236 178 12 216 158 10 175 118 6
46030 - 80 54 7 2 2 6 6 6 6 30 30 30
46031 - 54 54 54 62 62 62 50 50 50 38 38 38
46032 - 14 14 14 2 2 6 2 2 6 2 2 6
46033 - 2 2 6 2 2 6 2 2 6 2 2 6
46034 - 2 2 6 6 6 6 80 54 7 167 114 7
46035 -213 154 11 236 178 12 246 190 14 246 190 14
46036 -246 190 14 246 190 14 246 190 14 246 190 14
46037 -246 190 14 242 186 14 239 182 13 239 182 13
46038 -230 174 11 210 150 10 174 135 50 124 112 88
46039 - 82 82 82 54 54 54 34 34 34 18 18 18
46040 - 6 6 6 0 0 0 0 0 0 0 0 0
46041 - 0 0 0 0 0 0 0 0 0 0 0 0
46042 - 0 0 0 0 0 0 0 0 0 0 0 0
46043 - 0 0 0 0 0 0 6 6 6 18 18 18
46044 - 50 50 50 158 118 36 192 133 9 200 144 11
46045 -216 158 10 219 162 10 224 166 10 226 170 11
46046 -230 174 11 236 178 12 239 182 13 239 182 13
46047 -242 186 14 246 186 14 246 190 14 246 190 14
46048 -246 190 14 246 190 14 246 190 14 246 190 14
46049 -246 186 14 230 174 11 210 150 10 163 110 8
46050 -104 69 6 10 10 10 2 2 6 2 2 6
46051 - 2 2 6 2 2 6 2 2 6 2 2 6
46052 - 2 2 6 2 2 6 2 2 6 2 2 6
46053 - 2 2 6 2 2 6 2 2 6 2 2 6
46054 - 2 2 6 6 6 6 91 60 6 167 114 7
46055 -206 145 10 230 174 11 242 186 14 246 190 14
46056 -246 190 14 246 190 14 246 186 14 242 186 14
46057 -239 182 13 230 174 11 224 166 10 213 154 11
46058 -180 133 36 124 112 88 86 86 86 58 58 58
46059 - 38 38 38 22 22 22 10 10 10 6 6 6
46060 - 0 0 0 0 0 0 0 0 0 0 0 0
46061 - 0 0 0 0 0 0 0 0 0 0 0 0
46062 - 0 0 0 0 0 0 0 0 0 0 0 0
46063 - 0 0 0 0 0 0 0 0 0 14 14 14
46064 - 34 34 34 70 70 70 138 110 50 158 118 36
46065 -167 114 7 180 123 7 192 133 9 197 138 11
46066 -200 144 11 206 145 10 213 154 11 219 162 10
46067 -224 166 10 230 174 11 239 182 13 242 186 14
46068 -246 186 14 246 186 14 246 186 14 246 186 14
46069 -239 182 13 216 158 10 185 133 11 152 99 6
46070 -104 69 6 18 14 6 2 2 6 2 2 6
46071 - 2 2 6 2 2 6 2 2 6 2 2 6
46072 - 2 2 6 2 2 6 2 2 6 2 2 6
46073 - 2 2 6 2 2 6 2 2 6 2 2 6
46074 - 2 2 6 6 6 6 80 54 7 152 99 6
46075 -192 133 9 219 162 10 236 178 12 239 182 13
46076 -246 186 14 242 186 14 239 182 13 236 178 12
46077 -224 166 10 206 145 10 192 133 9 154 121 60
46078 - 94 94 94 62 62 62 42 42 42 22 22 22
46079 - 14 14 14 6 6 6 0 0 0 0 0 0
46080 - 0 0 0 0 0 0 0 0 0 0 0 0
46081 - 0 0 0 0 0 0 0 0 0 0 0 0
46082 - 0 0 0 0 0 0 0 0 0 0 0 0
46083 - 0 0 0 0 0 0 0 0 0 6 6 6
46084 - 18 18 18 34 34 34 58 58 58 78 78 78
46085 -101 98 89 124 112 88 142 110 46 156 107 11
46086 -163 110 8 167 114 7 175 118 6 180 123 7
46087 -185 133 11 197 138 11 210 150 10 219 162 10
46088 -226 170 11 236 178 12 236 178 12 234 174 13
46089 -219 162 10 197 138 11 163 110 8 130 83 6
46090 - 91 60 6 10 10 10 2 2 6 2 2 6
46091 - 18 18 18 38 38 38 38 38 38 38 38 38
46092 - 38 38 38 38 38 38 38 38 38 38 38 38
46093 - 38 38 38 38 38 38 26 26 26 2 2 6
46094 - 2 2 6 6 6 6 70 47 6 137 92 6
46095 -175 118 6 200 144 11 219 162 10 230 174 11
46096 -234 174 13 230 174 11 219 162 10 210 150 10
46097 -192 133 9 163 110 8 124 112 88 82 82 82
46098 - 50 50 50 30 30 30 14 14 14 6 6 6
46099 - 0 0 0 0 0 0 0 0 0 0 0 0
46100 - 0 0 0 0 0 0 0 0 0 0 0 0
46101 - 0 0 0 0 0 0 0 0 0 0 0 0
46102 - 0 0 0 0 0 0 0 0 0 0 0 0
46103 - 0 0 0 0 0 0 0 0 0 0 0 0
46104 - 6 6 6 14 14 14 22 22 22 34 34 34
46105 - 42 42 42 58 58 58 74 74 74 86 86 86
46106 -101 98 89 122 102 70 130 98 46 121 87 25
46107 -137 92 6 152 99 6 163 110 8 180 123 7
46108 -185 133 11 197 138 11 206 145 10 200 144 11
46109 -180 123 7 156 107 11 130 83 6 104 69 6
46110 - 50 34 6 54 54 54 110 110 110 101 98 89
46111 - 86 86 86 82 82 82 78 78 78 78 78 78
46112 - 78 78 78 78 78 78 78 78 78 78 78 78
46113 - 78 78 78 82 82 82 86 86 86 94 94 94
46114 -106 106 106 101 101 101 86 66 34 124 80 6
46115 -156 107 11 180 123 7 192 133 9 200 144 11
46116 -206 145 10 200 144 11 192 133 9 175 118 6
46117 -139 102 15 109 106 95 70 70 70 42 42 42
46118 - 22 22 22 10 10 10 0 0 0 0 0 0
46119 - 0 0 0 0 0 0 0 0 0 0 0 0
46120 - 0 0 0 0 0 0 0 0 0 0 0 0
46121 - 0 0 0 0 0 0 0 0 0 0 0 0
46122 - 0 0 0 0 0 0 0 0 0 0 0 0
46123 - 0 0 0 0 0 0 0 0 0 0 0 0
46124 - 0 0 0 0 0 0 6 6 6 10 10 10
46125 - 14 14 14 22 22 22 30 30 30 38 38 38
46126 - 50 50 50 62 62 62 74 74 74 90 90 90
46127 -101 98 89 112 100 78 121 87 25 124 80 6
46128 -137 92 6 152 99 6 152 99 6 152 99 6
46129 -138 86 6 124 80 6 98 70 6 86 66 30
46130 -101 98 89 82 82 82 58 58 58 46 46 46
46131 - 38 38 38 34 34 34 34 34 34 34 34 34
46132 - 34 34 34 34 34 34 34 34 34 34 34 34
46133 - 34 34 34 34 34 34 38 38 38 42 42 42
46134 - 54 54 54 82 82 82 94 86 76 91 60 6
46135 -134 86 6 156 107 11 167 114 7 175 118 6
46136 -175 118 6 167 114 7 152 99 6 121 87 25
46137 -101 98 89 62 62 62 34 34 34 18 18 18
46138 - 6 6 6 0 0 0 0 0 0 0 0 0
46139 - 0 0 0 0 0 0 0 0 0 0 0 0
46140 - 0 0 0 0 0 0 0 0 0 0 0 0
46141 - 0 0 0 0 0 0 0 0 0 0 0 0
46142 - 0 0 0 0 0 0 0 0 0 0 0 0
46143 - 0 0 0 0 0 0 0 0 0 0 0 0
46144 - 0 0 0 0 0 0 0 0 0 0 0 0
46145 - 0 0 0 6 6 6 6 6 6 10 10 10
46146 - 18 18 18 22 22 22 30 30 30 42 42 42
46147 - 50 50 50 66 66 66 86 86 86 101 98 89
46148 -106 86 58 98 70 6 104 69 6 104 69 6
46149 -104 69 6 91 60 6 82 62 34 90 90 90
46150 - 62 62 62 38 38 38 22 22 22 14 14 14
46151 - 10 10 10 10 10 10 10 10 10 10 10 10
46152 - 10 10 10 10 10 10 6 6 6 10 10 10
46153 - 10 10 10 10 10 10 10 10 10 14 14 14
46154 - 22 22 22 42 42 42 70 70 70 89 81 66
46155 - 80 54 7 104 69 6 124 80 6 137 92 6
46156 -134 86 6 116 81 8 100 82 52 86 86 86
46157 - 58 58 58 30 30 30 14 14 14 6 6 6
46158 - 0 0 0 0 0 0 0 0 0 0 0 0
46159 - 0 0 0 0 0 0 0 0 0 0 0 0
46160 - 0 0 0 0 0 0 0 0 0 0 0 0
46161 - 0 0 0 0 0 0 0 0 0 0 0 0
46162 - 0 0 0 0 0 0 0 0 0 0 0 0
46163 - 0 0 0 0 0 0 0 0 0 0 0 0
46164 - 0 0 0 0 0 0 0 0 0 0 0 0
46165 - 0 0 0 0 0 0 0 0 0 0 0 0
46166 - 0 0 0 6 6 6 10 10 10 14 14 14
46167 - 18 18 18 26 26 26 38 38 38 54 54 54
46168 - 70 70 70 86 86 86 94 86 76 89 81 66
46169 - 89 81 66 86 86 86 74 74 74 50 50 50
46170 - 30 30 30 14 14 14 6 6 6 0 0 0
46171 - 0 0 0 0 0 0 0 0 0 0 0 0
46172 - 0 0 0 0 0 0 0 0 0 0 0 0
46173 - 0 0 0 0 0 0 0 0 0 0 0 0
46174 - 6 6 6 18 18 18 34 34 34 58 58 58
46175 - 82 82 82 89 81 66 89 81 66 89 81 66
46176 - 94 86 66 94 86 76 74 74 74 50 50 50
46177 - 26 26 26 14 14 14 6 6 6 0 0 0
46178 - 0 0 0 0 0 0 0 0 0 0 0 0
46179 - 0 0 0 0 0 0 0 0 0 0 0 0
46180 - 0 0 0 0 0 0 0 0 0 0 0 0
46181 - 0 0 0 0 0 0 0 0 0 0 0 0
46182 - 0 0 0 0 0 0 0 0 0 0 0 0
46183 - 0 0 0 0 0 0 0 0 0 0 0 0
46184 - 0 0 0 0 0 0 0 0 0 0 0 0
46185 - 0 0 0 0 0 0 0 0 0 0 0 0
46186 - 0 0 0 0 0 0 0 0 0 0 0 0
46187 - 6 6 6 6 6 6 14 14 14 18 18 18
46188 - 30 30 30 38 38 38 46 46 46 54 54 54
46189 - 50 50 50 42 42 42 30 30 30 18 18 18
46190 - 10 10 10 0 0 0 0 0 0 0 0 0
46191 - 0 0 0 0 0 0 0 0 0 0 0 0
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 6 6 6 14 14 14 26 26 26
46195 - 38 38 38 50 50 50 58 58 58 58 58 58
46196 - 54 54 54 42 42 42 30 30 30 18 18 18
46197 - 10 10 10 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 0 0 0 0 0 0 0 0 0
46201 - 0 0 0 0 0 0 0 0 0 0 0 0
46202 - 0 0 0 0 0 0 0 0 0 0 0 0
46203 - 0 0 0 0 0 0 0 0 0 0 0 0
46204 - 0 0 0 0 0 0 0 0 0 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 6 6 6
46208 - 6 6 6 10 10 10 14 14 14 18 18 18
46209 - 18 18 18 14 14 14 10 10 10 6 6 6
46210 - 0 0 0 0 0 0 0 0 0 0 0 0
46211 - 0 0 0 0 0 0 0 0 0 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 6 6 6
46215 - 14 14 14 18 18 18 22 22 22 22 22 22
46216 - 18 18 18 14 14 14 10 10 10 6 6 6
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 - 0 0 0 0 0 0 0 0 0 0 0 0
46222 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46223 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46224 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46225 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46226 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46227 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46228 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46229 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46230 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46231 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46232 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46233 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46234 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46235 +4 4 4 4 4 4
46236 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46237 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46238 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46239 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46240 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46241 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46242 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46243 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46244 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46245 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46246 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46247 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46248 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46249 +4 4 4 4 4 4
46250 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46251 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46252 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46253 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46254 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46255 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
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
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 4 4 4 4 4 4 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
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 4 4 4 4 4 4 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
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 4 4 4 4 4 4 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
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 3 3 3 0 0 0 0 0 0
46311 +0 0 0 0 0 0 0 0 0 0 0 0 3 3 3 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 1 1 1 0 0 0
46316 +0 0 0 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4
46317 +4 4 4 4 4 4 4 4 4 2 1 0 2 1 0 3 2 2
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
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 2 2 2 0 0 0 3 4 3 26 28 28
46325 +37 38 37 37 38 37 14 17 19 2 2 2 0 0 0 2 2 2
46326 +5 5 5 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 3 3 3 0 0 0 1 1 1 6 6 6
46330 +2 2 2 0 0 0 3 3 3 4 4 4 4 4 4 4 4 4
46331 +4 4 5 3 3 3 1 0 0 0 0 0 1 0 0 0 0 0
46332 +1 1 1 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46333 +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 +2 2 2 0 0 0 0 0 0 14 17 19 60 74 84 137 136 137
46339 +153 152 153 137 136 137 125 124 125 60 73 81 6 6 6 3 1 0
46340 +0 0 0 3 3 3 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 0 0 0 4 4 4 41 54 63 125 124 125
46344 +60 73 81 6 6 6 4 0 0 3 3 3 4 4 4 4 4 4
46345 +4 4 4 0 0 0 6 9 11 41 54 63 41 65 82 22 30 35
46346 +2 2 2 2 1 0 4 4 4 4 4 4 4 4 4 4 4 4
46347 +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 4 4 4 4 4 4
46350 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46351 +4 4 4 4 4 4 5 5 5 5 5 5 2 2 2 0 0 0
46352 +4 0 0 6 6 6 41 54 63 137 136 137 174 174 174 167 166 167
46353 +165 164 165 165 164 165 163 162 163 163 162 163 125 124 125 41 54 63
46354 +1 1 1 0 0 0 0 0 0 3 3 3 5 5 5 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 5 5 5 5 5 5
46357 +3 3 3 2 0 0 4 0 0 60 73 81 156 155 156 167 166 167
46358 +163 162 163 85 115 134 5 7 8 0 0 0 4 4 4 5 5 5
46359 +0 0 0 2 5 5 55 98 126 90 154 193 90 154 193 72 125 159
46360 +37 51 59 2 0 0 1 1 1 4 5 5 4 4 4 4 4 4
46361 +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 4 4 4 4 4 4 4 4 4 4 4 4
46364 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46365 +4 4 4 5 5 5 4 4 4 1 1 1 0 0 0 3 3 3
46366 +37 38 37 125 124 125 163 162 163 174 174 174 158 157 158 158 157 158
46367 +156 155 156 156 155 156 158 157 158 165 164 165 174 174 174 166 165 166
46368 +125 124 125 16 19 21 1 0 0 0 0 0 0 0 0 4 4 4
46369 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
46370 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 1 1 1
46371 +0 0 0 0 0 0 37 38 37 153 152 153 174 174 174 158 157 158
46372 +174 174 174 163 162 163 37 38 37 4 3 3 4 0 0 1 1 1
46373 +0 0 0 22 40 52 101 161 196 101 161 196 90 154 193 101 161 196
46374 +64 123 161 14 17 19 0 0 0 4 4 4 4 4 4 4 4 4
46375 +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 4 4 4 4 4 4 4 4 4 4 4 4
46378 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
46379 +5 5 5 2 2 2 0 0 0 4 0 0 24 26 27 85 115 134
46380 +156 155 156 174 174 174 167 166 167 156 155 156 154 153 154 157 156 157
46381 +156 155 156 156 155 156 155 154 155 153 152 153 158 157 158 167 166 167
46382 +174 174 174 156 155 156 60 74 84 16 19 21 0 0 0 0 0 0
46383 +1 1 1 5 5 5 5 5 5 4 4 4 4 4 4 4 4 4
46384 +4 4 4 5 5 5 6 6 6 3 3 3 0 0 0 4 0 0
46385 +13 16 17 60 73 81 137 136 137 165 164 165 156 155 156 153 152 153
46386 +174 174 174 177 184 187 60 73 81 3 1 0 0 0 0 1 1 2
46387 +22 30 35 64 123 161 136 185 209 90 154 193 90 154 193 90 154 193
46388 +90 154 193 21 29 34 0 0 0 3 2 2 4 4 5 4 4 4
46389 +4 4 4 4 4 4
46390 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46391 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46392 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 3 3 3
46393 +0 0 0 0 0 0 10 13 16 60 74 84 157 156 157 174 174 174
46394 +174 174 174 158 157 158 153 152 153 154 153 154 156 155 156 155 154 155
46395 +156 155 156 155 154 155 154 153 154 157 156 157 154 153 154 153 152 153
46396 +163 162 163 174 174 174 177 184 187 137 136 137 60 73 81 13 16 17
46397 +4 0 0 0 0 0 3 3 3 5 5 5 4 4 4 4 4 4
46398 +5 5 5 4 4 4 1 1 1 0 0 0 3 3 3 41 54 63
46399 +131 129 131 174 174 174 174 174 174 174 174 174 167 166 167 174 174 174
46400 +190 197 201 137 136 137 24 26 27 4 0 0 16 21 25 50 82 103
46401 +90 154 193 136 185 209 90 154 193 101 161 196 101 161 196 101 161 196
46402 +31 91 132 3 6 7 0 0 0 4 4 4 4 4 4 4 4 4
46403 +4 4 4 4 4 4
46404 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46405 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46406 +4 4 4 4 4 4 4 4 4 2 2 2 0 0 0 4 0 0
46407 +4 0 0 43 57 68 137 136 137 177 184 187 174 174 174 163 162 163
46408 +155 154 155 155 154 155 156 155 156 155 154 155 158 157 158 165 164 165
46409 +167 166 167 166 165 166 163 162 163 157 156 157 155 154 155 155 154 155
46410 +153 152 153 156 155 156 167 166 167 174 174 174 174 174 174 131 129 131
46411 +41 54 63 5 5 5 0 0 0 0 0 0 3 3 3 4 4 4
46412 +1 1 1 0 0 0 1 0 0 26 28 28 125 124 125 174 174 174
46413 +177 184 187 174 174 174 174 174 174 156 155 156 131 129 131 137 136 137
46414 +125 124 125 24 26 27 4 0 0 41 65 82 90 154 193 136 185 209
46415 +136 185 209 101 161 196 53 118 160 37 112 160 90 154 193 34 86 122
46416 +7 12 15 0 0 0 4 4 4 4 4 4 4 4 4 4 4 4
46417 +4 4 4 4 4 4
46418 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46419 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46420 +4 4 4 3 3 3 0 0 0 0 0 0 5 5 5 37 38 37
46421 +125 124 125 167 166 167 174 174 174 167 166 167 158 157 158 155 154 155
46422 +156 155 156 156 155 156 156 155 156 163 162 163 167 166 167 155 154 155
46423 +137 136 137 153 152 153 156 155 156 165 164 165 163 162 163 156 155 156
46424 +156 155 156 156 155 156 155 154 155 158 157 158 166 165 166 174 174 174
46425 +167 166 167 125 124 125 37 38 37 1 0 0 0 0 0 0 0 0
46426 +0 0 0 24 26 27 60 74 84 158 157 158 174 174 174 174 174 174
46427 +166 165 166 158 157 158 125 124 125 41 54 63 13 16 17 6 6 6
46428 +6 6 6 37 38 37 80 127 157 136 185 209 101 161 196 101 161 196
46429 +90 154 193 28 67 93 6 10 14 13 20 25 13 20 25 6 10 14
46430 +1 1 2 4 3 3 4 4 4 4 4 4 4 4 4 4 4 4
46431 +4 4 4 4 4 4
46432 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46433 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46434 +1 1 1 1 0 0 4 3 3 37 38 37 60 74 84 153 152 153
46435 +167 166 167 167 166 167 158 157 158 154 153 154 155 154 155 156 155 156
46436 +157 156 157 158 157 158 167 166 167 167 166 167 131 129 131 43 57 68
46437 +26 28 28 37 38 37 60 73 81 131 129 131 165 164 165 166 165 166
46438 +158 157 158 155 154 155 156 155 156 156 155 156 156 155 156 158 157 158
46439 +165 164 165 174 174 174 163 162 163 60 74 84 16 19 21 13 16 17
46440 +60 73 81 131 129 131 174 174 174 174 174 174 167 166 167 165 164 165
46441 +137 136 137 60 73 81 24 26 27 4 0 0 4 0 0 16 19 21
46442 +52 104 138 101 161 196 136 185 209 136 185 209 90 154 193 27 99 146
46443 +13 20 25 4 5 7 2 5 5 4 5 7 1 1 2 0 0 0
46444 +4 4 4 4 4 4 3 3 3 2 2 2 2 2 2 4 4 4
46445 +4 4 4 4 4 4
46446 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46447 +4 4 4 4 4 4 4 4 4 4 4 4 3 3 3 0 0 0
46448 +0 0 0 13 16 17 60 73 81 137 136 137 174 174 174 166 165 166
46449 +158 157 158 156 155 156 157 156 157 156 155 156 155 154 155 158 157 158
46450 +167 166 167 174 174 174 153 152 153 60 73 81 16 19 21 4 0 0
46451 +4 0 0 4 0 0 6 6 6 26 28 28 60 74 84 158 157 158
46452 +174 174 174 166 165 166 157 156 157 155 154 155 156 155 156 156 155 156
46453 +155 154 155 158 157 158 167 166 167 167 166 167 131 129 131 125 124 125
46454 +137 136 137 167 166 167 167 166 167 174 174 174 158 157 158 125 124 125
46455 +16 19 21 4 0 0 4 0 0 10 13 16 49 76 92 107 159 188
46456 +136 185 209 136 185 209 90 154 193 26 108 161 22 40 52 6 10 14
46457 +2 3 3 1 1 2 1 1 2 4 4 5 4 4 5 4 4 5
46458 +4 4 5 2 2 1 0 0 0 0 0 0 0 0 0 2 2 2
46459 +4 4 4 4 4 4
46460 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46461 +4 4 4 5 5 5 3 3 3 0 0 0 1 0 0 4 0 0
46462 +37 51 59 131 129 131 167 166 167 167 166 167 163 162 163 157 156 157
46463 +157 156 157 155 154 155 153 152 153 157 156 157 167 166 167 174 174 174
46464 +153 152 153 125 124 125 37 38 37 4 0 0 4 0 0 4 0 0
46465 +4 3 3 4 3 3 4 0 0 6 6 6 4 0 0 37 38 37
46466 +125 124 125 174 174 174 174 174 174 165 164 165 156 155 156 154 153 154
46467 +156 155 156 156 155 156 155 154 155 163 162 163 158 157 158 163 162 163
46468 +174 174 174 174 174 174 174 174 174 125 124 125 37 38 37 0 0 0
46469 +4 0 0 6 9 11 41 54 63 90 154 193 136 185 209 146 190 211
46470 +136 185 209 37 112 160 22 40 52 6 10 14 3 6 7 1 1 2
46471 +1 1 2 3 3 3 1 1 2 3 3 3 4 4 4 4 4 4
46472 +2 2 2 2 0 0 16 19 21 37 38 37 24 26 27 0 0 0
46473 +0 0 0 4 4 4
46474 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
46475 +4 4 4 0 0 0 0 0 0 0 0 0 26 28 28 120 125 127
46476 +158 157 158 174 174 174 165 164 165 157 156 157 155 154 155 156 155 156
46477 +153 152 153 153 152 153 167 166 167 174 174 174 174 174 174 125 124 125
46478 +37 38 37 4 0 0 0 0 0 4 0 0 4 3 3 4 4 4
46479 +4 4 4 4 4 4 5 5 5 4 0 0 4 0 0 4 0 0
46480 +4 3 3 43 57 68 137 136 137 174 174 174 174 174 174 165 164 165
46481 +154 153 154 153 152 153 153 152 153 153 152 153 163 162 163 174 174 174
46482 +174 174 174 153 152 153 60 73 81 6 6 6 4 0 0 4 3 3
46483 +32 43 50 80 127 157 136 185 209 146 190 211 146 190 211 90 154 193
46484 +28 67 93 28 67 93 40 71 93 3 6 7 1 1 2 2 5 5
46485 +50 82 103 79 117 143 26 37 45 0 0 0 3 3 3 1 1 1
46486 +0 0 0 41 54 63 137 136 137 174 174 174 153 152 153 60 73 81
46487 +2 0 0 0 0 0
46488 +4 4 4 4 4 4 4 4 4 4 4 4 6 6 6 2 2 2
46489 +0 0 0 2 0 0 24 26 27 60 74 84 153 152 153 174 174 174
46490 +174 174 174 157 156 157 154 153 154 156 155 156 154 153 154 153 152 153
46491 +165 164 165 174 174 174 177 184 187 137 136 137 43 57 68 6 6 6
46492 +4 0 0 2 0 0 3 3 3 5 5 5 5 5 5 4 4 4
46493 +4 4 4 4 4 4 4 4 4 5 5 5 6 6 6 4 3 3
46494 +4 0 0 4 0 0 24 26 27 60 73 81 153 152 153 174 174 174
46495 +174 174 174 158 157 158 158 157 158 174 174 174 174 174 174 158 157 158
46496 +60 74 84 24 26 27 4 0 0 4 0 0 17 23 27 59 113 148
46497 +136 185 209 191 222 234 146 190 211 136 185 209 31 91 132 7 11 13
46498 +22 40 52 101 161 196 90 154 193 6 9 11 3 4 4 43 95 132
46499 +136 185 209 172 205 220 55 98 126 0 0 0 0 0 0 2 0 0
46500 +26 28 28 153 152 153 177 184 187 167 166 167 177 184 187 165 164 165
46501 +37 38 37 0 0 0
46502 +4 4 4 4 4 4 5 5 5 5 5 5 1 1 1 0 0 0
46503 +13 16 17 60 73 81 137 136 137 174 174 174 174 174 174 165 164 165
46504 +153 152 153 153 152 153 155 154 155 154 153 154 158 157 158 174 174 174
46505 +177 184 187 163 162 163 60 73 81 16 19 21 4 0 0 4 0 0
46506 +4 3 3 4 4 4 5 5 5 5 5 5 4 4 4 5 5 5
46507 +5 5 5 5 5 5 5 5 5 4 4 4 4 4 4 5 5 5
46508 +6 6 6 4 0 0 4 0 0 4 0 0 24 26 27 60 74 84
46509 +166 165 166 174 174 174 177 184 187 165 164 165 125 124 125 24 26 27
46510 +4 0 0 4 0 0 5 5 5 50 82 103 136 185 209 172 205 220
46511 +146 190 211 136 185 209 26 108 161 22 40 52 7 12 15 44 81 103
46512 +71 116 144 28 67 93 37 51 59 41 65 82 100 139 164 101 161 196
46513 +90 154 193 90 154 193 28 67 93 0 0 0 0 0 0 26 28 28
46514 +125 124 125 167 166 167 163 162 163 153 152 153 163 162 163 174 174 174
46515 +85 115 134 4 0 0
46516 +4 4 4 5 5 5 4 4 4 1 0 0 4 0 0 34 47 55
46517 +125 124 125 174 174 174 174 174 174 167 166 167 157 156 157 153 152 153
46518 +155 154 155 155 154 155 158 157 158 166 165 166 167 166 167 154 153 154
46519 +125 124 125 26 28 28 4 0 0 4 0 0 4 0 0 5 5 5
46520 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 1 1 1
46521 +0 0 0 0 0 0 1 1 1 4 4 4 4 4 4 4 4 4
46522 +5 5 5 5 5 5 4 3 3 4 0 0 4 0 0 6 6 6
46523 +37 38 37 131 129 131 137 136 137 37 38 37 0 0 0 4 0 0
46524 +4 5 5 43 61 72 90 154 193 172 205 220 146 190 211 136 185 209
46525 +90 154 193 28 67 93 13 20 25 43 61 72 71 116 144 44 81 103
46526 +2 5 5 7 11 13 59 113 148 101 161 196 90 154 193 28 67 93
46527 +13 20 25 6 10 14 0 0 0 13 16 17 60 73 81 137 136 137
46528 +166 165 166 158 157 158 156 155 156 154 153 154 167 166 167 174 174 174
46529 +60 73 81 4 0 0
46530 +4 4 4 4 4 4 0 0 0 3 3 3 60 74 84 174 174 174
46531 +174 174 174 167 166 167 163 162 163 155 154 155 157 156 157 155 154 155
46532 +156 155 156 163 162 163 167 166 167 158 157 158 125 124 125 37 38 37
46533 +4 3 3 4 0 0 4 0 0 6 6 6 6 6 6 5 5 5
46534 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 2 3 3
46535 +10 13 16 7 11 13 1 0 0 0 0 0 2 2 1 4 4 4
46536 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 4 0 0
46537 +4 0 0 7 11 13 13 16 17 4 0 0 3 3 3 34 47 55
46538 +80 127 157 146 190 211 172 205 220 136 185 209 136 185 209 136 185 209
46539 +28 67 93 22 40 52 55 98 126 55 98 126 21 29 34 7 11 13
46540 +50 82 103 101 161 196 101 161 196 35 83 115 13 20 25 2 2 1
46541 +1 1 2 1 1 2 37 51 59 131 129 131 174 174 174 174 174 174
46542 +167 166 167 163 162 163 163 162 163 167 166 167 174 174 174 125 124 125
46543 +16 19 21 4 0 0
46544 +4 4 4 4 0 0 4 0 0 60 74 84 174 174 174 174 174 174
46545 +158 157 158 155 154 155 155 154 155 156 155 156 155 154 155 158 157 158
46546 +167 166 167 165 164 165 131 129 131 60 73 81 13 16 17 4 0 0
46547 +4 0 0 4 3 3 6 6 6 4 3 3 5 5 5 4 4 4
46548 +4 4 4 3 2 2 0 0 0 0 0 0 7 11 13 45 69 86
46549 +80 127 157 71 116 144 43 61 72 7 11 13 0 0 0 1 1 1
46550 +4 3 3 4 4 4 4 4 4 4 4 4 6 6 6 5 5 5
46551 +3 2 2 4 0 0 1 0 0 21 29 34 59 113 148 136 185 209
46552 +146 190 211 136 185 209 136 185 209 136 185 209 136 185 209 136 185 209
46553 +68 124 159 44 81 103 22 40 52 13 16 17 43 61 72 90 154 193
46554 +136 185 209 59 113 148 21 29 34 3 4 3 1 1 1 0 0 0
46555 +24 26 27 125 124 125 163 162 163 174 174 174 166 165 166 165 164 165
46556 +163 162 163 125 124 125 125 124 125 125 124 125 125 124 125 26 28 28
46557 +4 0 0 4 3 3
46558 +3 3 3 0 0 0 24 26 27 153 152 153 177 184 187 158 157 158
46559 +156 155 156 156 155 156 155 154 155 155 154 155 165 164 165 174 174 174
46560 +155 154 155 60 74 84 26 28 28 4 0 0 4 0 0 3 1 0
46561 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 3 3
46562 +2 0 0 0 0 0 0 0 0 32 43 50 72 125 159 101 161 196
46563 +136 185 209 101 161 196 101 161 196 79 117 143 32 43 50 0 0 0
46564 +0 0 0 2 2 2 4 4 4 4 4 4 3 3 3 1 0 0
46565 +0 0 0 4 5 5 49 76 92 101 161 196 146 190 211 146 190 211
46566 +136 185 209 136 185 209 136 185 209 136 185 209 136 185 209 90 154 193
46567 +28 67 93 13 16 17 37 51 59 80 127 157 136 185 209 90 154 193
46568 +22 40 52 6 9 11 3 4 3 2 2 1 16 19 21 60 73 81
46569 +137 136 137 163 162 163 158 157 158 166 165 166 167 166 167 153 152 153
46570 +60 74 84 37 38 37 6 6 6 13 16 17 4 0 0 1 0 0
46571 +3 2 2 4 4 4
46572 +3 2 2 4 0 0 37 38 37 137 136 137 167 166 167 158 157 158
46573 +157 156 157 154 153 154 157 156 157 167 166 167 174 174 174 125 124 125
46574 +37 38 37 4 0 0 4 0 0 4 0 0 4 3 3 4 4 4
46575 +4 4 4 4 4 4 5 5 5 5 5 5 1 1 1 0 0 0
46576 +0 0 0 16 21 25 55 98 126 90 154 193 136 185 209 101 161 196
46577 +101 161 196 101 161 196 136 185 209 136 185 209 101 161 196 55 98 126
46578 +14 17 19 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
46579 +22 40 52 90 154 193 146 190 211 146 190 211 136 185 209 136 185 209
46580 +136 185 209 136 185 209 136 185 209 101 161 196 35 83 115 7 11 13
46581 +17 23 27 59 113 148 136 185 209 101 161 196 34 86 122 7 12 15
46582 +2 5 5 3 4 3 6 6 6 60 73 81 131 129 131 163 162 163
46583 +166 165 166 174 174 174 174 174 174 163 162 163 125 124 125 41 54 63
46584 +13 16 17 4 0 0 4 0 0 4 0 0 1 0 0 2 2 2
46585 +4 4 4 4 4 4
46586 +1 1 1 2 1 0 43 57 68 137 136 137 153 152 153 153 152 153
46587 +163 162 163 156 155 156 165 164 165 167 166 167 60 74 84 6 6 6
46588 +4 0 0 4 0 0 5 5 5 4 4 4 4 4 4 4 4 4
46589 +4 5 5 6 6 6 4 3 3 0 0 0 0 0 0 11 15 18
46590 +40 71 93 100 139 164 101 161 196 101 161 196 101 161 196 101 161 196
46591 +101 161 196 101 161 196 101 161 196 101 161 196 136 185 209 136 185 209
46592 +101 161 196 45 69 86 6 6 6 0 0 0 17 23 27 55 98 126
46593 +136 185 209 146 190 211 136 185 209 136 185 209 136 185 209 136 185 209
46594 +136 185 209 136 185 209 90 154 193 22 40 52 7 11 13 50 82 103
46595 +136 185 209 136 185 209 53 118 160 22 40 52 7 11 13 2 5 5
46596 +3 4 3 37 38 37 125 124 125 157 156 157 166 165 166 167 166 167
46597 +174 174 174 174 174 174 137 136 137 60 73 81 4 0 0 4 0 0
46598 +4 0 0 4 0 0 5 5 5 3 3 3 3 3 3 4 4 4
46599 +4 4 4 4 4 4
46600 +4 0 0 4 0 0 41 54 63 137 136 137 125 124 125 131 129 131
46601 +155 154 155 167 166 167 174 174 174 60 74 84 6 6 6 4 0 0
46602 +4 3 3 6 6 6 4 4 4 4 4 4 4 4 4 5 5 5
46603 +4 4 4 1 1 1 0 0 0 3 6 7 41 65 82 72 125 159
46604 +101 161 196 101 161 196 101 161 196 90 154 193 90 154 193 101 161 196
46605 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 136 185 209
46606 +136 185 209 136 185 209 80 127 157 55 98 126 101 161 196 146 190 211
46607 +136 185 209 136 185 209 136 185 209 101 161 196 136 185 209 101 161 196
46608 +136 185 209 101 161 196 35 83 115 22 30 35 101 161 196 172 205 220
46609 +90 154 193 28 67 93 7 11 13 2 5 5 3 4 3 13 16 17
46610 +85 115 134 167 166 167 174 174 174 174 174 174 174 174 174 174 174 174
46611 +167 166 167 60 74 84 13 16 17 4 0 0 4 0 0 4 3 3
46612 +6 6 6 5 5 5 4 4 4 5 5 5 4 4 4 5 5 5
46613 +5 5 5 5 5 5
46614 +1 1 1 4 0 0 41 54 63 137 136 137 137 136 137 125 124 125
46615 +131 129 131 167 166 167 157 156 157 37 38 37 6 6 6 4 0 0
46616 +6 6 6 5 5 5 4 4 4 4 4 4 4 5 5 2 2 1
46617 +0 0 0 0 0 0 26 37 45 58 111 146 101 161 196 101 161 196
46618 +101 161 196 90 154 193 90 154 193 90 154 193 101 161 196 101 161 196
46619 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
46620 +101 161 196 136 185 209 136 185 209 136 185 209 146 190 211 136 185 209
46621 +136 185 209 101 161 196 136 185 209 136 185 209 101 161 196 136 185 209
46622 +101 161 196 136 185 209 136 185 209 136 185 209 136 185 209 16 89 141
46623 +7 11 13 2 5 5 2 5 5 13 16 17 60 73 81 154 154 154
46624 +174 174 174 174 174 174 174 174 174 174 174 174 163 162 163 125 124 125
46625 +24 26 27 4 0 0 4 0 0 4 0 0 5 5 5 5 5 5
46626 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5
46627 +5 5 5 4 4 4
46628 +4 0 0 6 6 6 37 38 37 137 136 137 137 136 137 131 129 131
46629 +131 129 131 153 152 153 131 129 131 26 28 28 4 0 0 4 3 3
46630 +6 6 6 4 4 4 4 4 4 4 4 4 0 0 0 0 0 0
46631 +13 20 25 51 88 114 90 154 193 101 161 196 101 161 196 90 154 193
46632 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
46633 +101 161 196 101 161 196 101 161 196 101 161 196 136 185 209 101 161 196
46634 +101 161 196 136 185 209 101 161 196 136 185 209 136 185 209 101 161 196
46635 +136 185 209 101 161 196 136 185 209 101 161 196 101 161 196 101 161 196
46636 +136 185 209 136 185 209 136 185 209 37 112 160 21 29 34 5 7 8
46637 +2 5 5 13 16 17 43 57 68 131 129 131 174 174 174 174 174 174
46638 +174 174 174 167 166 167 157 156 157 125 124 125 37 38 37 4 0 0
46639 +4 0 0 4 0 0 5 5 5 5 5 5 4 4 4 4 4 4
46640 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46641 +4 4 4 4 4 4
46642 +1 1 1 4 0 0 41 54 63 153 152 153 137 136 137 137 136 137
46643 +137 136 137 153 152 153 125 124 125 24 26 27 4 0 0 3 2 2
46644 +4 4 4 4 4 4 4 3 3 4 0 0 3 6 7 43 61 72
46645 +64 123 161 101 161 196 90 154 193 90 154 193 90 154 193 90 154 193
46646 +90 154 193 90 154 193 90 154 193 90 154 193 101 161 196 90 154 193
46647 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
46648 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
46649 +136 185 209 101 161 196 101 161 196 136 185 209 136 185 209 101 161 196
46650 +101 161 196 90 154 193 28 67 93 13 16 17 7 11 13 3 6 7
46651 +37 51 59 125 124 125 163 162 163 174 174 174 167 166 167 166 165 166
46652 +167 166 167 131 129 131 60 73 81 4 0 0 4 0 0 4 0 0
46653 +3 3 3 5 5 5 6 6 6 4 4 4 4 4 4 4 4 4
46654 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46655 +4 4 4 4 4 4
46656 +4 0 0 4 0 0 41 54 63 137 136 137 153 152 153 137 136 137
46657 +153 152 153 157 156 157 125 124 125 24 26 27 0 0 0 2 2 2
46658 +4 4 4 4 4 4 2 0 0 0 0 0 28 67 93 90 154 193
46659 +90 154 193 90 154 193 90 154 193 90 154 193 64 123 161 90 154 193
46660 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
46661 +90 154 193 101 161 196 101 161 196 101 161 196 90 154 193 136 185 209
46662 +101 161 196 101 161 196 136 185 209 101 161 196 136 185 209 101 161 196
46663 +101 161 196 101 161 196 136 185 209 101 161 196 101 161 196 90 154 193
46664 +35 83 115 13 16 17 3 6 7 2 5 5 13 16 17 60 74 84
46665 +154 154 154 166 165 166 165 164 165 158 157 158 163 162 163 157 156 157
46666 +60 74 84 13 16 17 4 0 0 4 0 0 3 2 2 4 4 4
46667 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46668 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46669 +4 4 4 4 4 4
46670 +1 1 1 4 0 0 41 54 63 157 156 157 155 154 155 137 136 137
46671 +153 152 153 158 157 158 137 136 137 26 28 28 2 0 0 2 2 2
46672 +4 4 4 4 4 4 1 0 0 6 10 14 34 86 122 90 154 193
46673 +64 123 161 90 154 193 64 123 161 90 154 193 90 154 193 90 154 193
46674 +64 123 161 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
46675 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
46676 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
46677 +136 185 209 101 161 196 136 185 209 90 154 193 26 108 161 22 40 52
46678 +13 16 17 5 7 8 2 5 5 2 5 5 37 38 37 165 164 165
46679 +174 174 174 163 162 163 154 154 154 165 164 165 167 166 167 60 73 81
46680 +6 6 6 4 0 0 4 0 0 4 4 4 4 4 4 4 4 4
46681 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46682 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46683 +4 4 4 4 4 4
46684 +4 0 0 6 6 6 41 54 63 156 155 156 158 157 158 153 152 153
46685 +156 155 156 165 164 165 137 136 137 26 28 28 0 0 0 2 2 2
46686 +4 4 5 4 4 4 2 0 0 7 12 15 31 96 139 64 123 161
46687 +90 154 193 64 123 161 90 154 193 90 154 193 64 123 161 90 154 193
46688 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
46689 +90 154 193 90 154 193 90 154 193 101 161 196 101 161 196 101 161 196
46690 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 136 185 209
46691 +101 161 196 136 185 209 26 108 161 22 40 52 7 11 13 5 7 8
46692 +2 5 5 2 5 5 2 5 5 2 2 1 37 38 37 158 157 158
46693 +174 174 174 154 154 154 156 155 156 167 166 167 165 164 165 37 38 37
46694 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46695 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46696 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46697 +4 4 4 4 4 4
46698 +3 1 0 4 0 0 60 73 81 157 156 157 163 162 163 153 152 153
46699 +158 157 158 167 166 167 137 136 137 26 28 28 2 0 0 2 2 2
46700 +4 5 5 4 4 4 4 0 0 7 12 15 24 86 132 26 108 161
46701 +37 112 160 64 123 161 90 154 193 64 123 161 90 154 193 90 154 193
46702 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
46703 +90 154 193 101 161 196 90 154 193 101 161 196 101 161 196 101 161 196
46704 +101 161 196 101 161 196 101 161 196 136 185 209 101 161 196 136 185 209
46705 +90 154 193 35 83 115 13 16 17 13 16 17 7 11 13 3 6 7
46706 +5 7 8 6 6 6 3 4 3 2 2 1 30 32 34 154 154 154
46707 +167 166 167 154 154 154 154 154 154 174 174 174 165 164 165 37 38 37
46708 +6 6 6 4 0 0 6 6 6 4 4 4 4 4 4 4 4 4
46709 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46710 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46711 +4 4 4 4 4 4
46712 +4 0 0 4 0 0 41 54 63 163 162 163 166 165 166 154 154 154
46713 +163 162 163 174 174 174 137 136 137 26 28 28 0 0 0 2 2 2
46714 +4 5 5 4 4 5 1 1 2 6 10 14 28 67 93 18 97 151
46715 +18 97 151 18 97 151 26 108 161 37 112 160 37 112 160 90 154 193
46716 +64 123 161 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
46717 +90 154 193 101 161 196 101 161 196 90 154 193 101 161 196 101 161 196
46718 +101 161 196 101 161 196 101 161 196 136 185 209 90 154 193 16 89 141
46719 +13 20 25 7 11 13 5 7 8 5 7 8 2 5 5 4 5 5
46720 +3 4 3 4 5 5 3 4 3 0 0 0 37 38 37 158 157 158
46721 +174 174 174 158 157 158 158 157 158 167 166 167 174 174 174 41 54 63
46722 +4 0 0 3 2 2 5 5 5 4 4 4 4 4 4 4 4 4
46723 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46724 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46725 +4 4 4 4 4 4
46726 +1 1 1 4 0 0 60 73 81 165 164 165 174 174 174 158 157 158
46727 +167 166 167 174 174 174 153 152 153 26 28 28 2 0 0 2 2 2
46728 +4 5 5 4 4 4 4 0 0 7 12 15 10 87 144 10 87 144
46729 +18 97 151 18 97 151 18 97 151 26 108 161 26 108 161 26 108 161
46730 +26 108 161 37 112 160 53 118 160 90 154 193 90 154 193 90 154 193
46731 +90 154 193 90 154 193 101 161 196 101 161 196 101 161 196 101 161 196
46732 +101 161 196 136 185 209 90 154 193 26 108 161 22 40 52 13 16 17
46733 +7 11 13 3 6 7 5 7 8 5 7 8 2 5 5 4 5 5
46734 +4 5 5 6 6 6 3 4 3 0 0 0 30 32 34 158 157 158
46735 +174 174 174 156 155 156 155 154 155 165 164 165 154 153 154 37 38 37
46736 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46737 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46738 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46739 +4 4 4 4 4 4
46740 +4 0 0 4 0 0 60 73 81 167 166 167 174 174 174 163 162 163
46741 +174 174 174 174 174 174 153 152 153 26 28 28 0 0 0 3 3 3
46742 +5 5 5 4 4 4 1 1 2 7 12 15 28 67 93 18 97 151
46743 +18 97 151 18 97 151 18 97 151 18 97 151 18 97 151 26 108 161
46744 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
46745 +90 154 193 26 108 161 90 154 193 90 154 193 90 154 193 101 161 196
46746 +101 161 196 26 108 161 22 40 52 13 16 17 7 11 13 2 5 5
46747 +2 5 5 6 6 6 2 5 5 4 5 5 4 5 5 4 5 5
46748 +3 4 3 5 5 5 3 4 3 2 0 0 30 32 34 137 136 137
46749 +153 152 153 137 136 137 131 129 131 137 136 137 131 129 131 37 38 37
46750 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46751 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46752 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46753 +4 4 4 4 4 4
46754 +1 1 1 4 0 0 60 73 81 167 166 167 174 174 174 166 165 166
46755 +174 174 174 177 184 187 153 152 153 30 32 34 1 0 0 3 3 3
46756 +5 5 5 4 3 3 4 0 0 7 12 15 10 87 144 10 87 144
46757 +18 97 151 18 97 151 18 97 151 26 108 161 26 108 161 26 108 161
46758 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
46759 +26 108 161 26 108 161 26 108 161 90 154 193 90 154 193 26 108 161
46760 +35 83 115 13 16 17 7 11 13 5 7 8 3 6 7 5 7 8
46761 +2 5 5 6 6 6 4 5 5 4 5 5 3 4 3 4 5 5
46762 +3 4 3 6 6 6 3 4 3 0 0 0 26 28 28 125 124 125
46763 +131 129 131 125 124 125 125 124 125 131 129 131 131 129 131 37 38 37
46764 +4 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46765 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46766 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46767 +4 4 4 4 4 4
46768 +3 1 0 4 0 0 60 73 81 174 174 174 177 184 187 167 166 167
46769 +174 174 174 177 184 187 153 152 153 30 32 34 0 0 0 3 3 3
46770 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 18 97 151
46771 +18 97 151 18 97 151 18 97 151 18 97 151 18 97 151 26 108 161
46772 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
46773 +26 108 161 90 154 193 26 108 161 26 108 161 24 86 132 13 20 25
46774 +7 11 13 13 20 25 22 40 52 5 7 8 3 4 3 3 4 3
46775 +4 5 5 3 4 3 4 5 5 3 4 3 4 5 5 3 4 3
46776 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 125 124 125
46777 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46778 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46779 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46780 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46781 +4 4 4 4 4 4
46782 +1 1 1 4 0 0 60 73 81 174 174 174 177 184 187 174 174 174
46783 +174 174 174 190 197 201 157 156 157 30 32 34 1 0 0 3 3 3
46784 +5 5 5 4 3 3 4 0 0 7 12 15 10 87 144 10 87 144
46785 +18 97 151 19 95 150 19 95 150 18 97 151 18 97 151 26 108 161
46786 +18 97 151 26 108 161 26 108 161 26 108 161 26 108 161 90 154 193
46787 +26 108 161 26 108 161 26 108 161 22 40 52 2 5 5 3 4 3
46788 +28 67 93 37 112 160 34 86 122 2 5 5 3 4 3 3 4 3
46789 +3 4 3 3 4 3 3 4 3 2 2 1 3 4 3 4 4 4
46790 +4 5 5 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
46791 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46792 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46793 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46794 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46795 +4 4 4 4 4 4
46796 +4 0 0 4 0 0 60 73 81 174 174 174 177 184 187 174 174 174
46797 +174 174 174 190 197 201 158 157 158 30 32 34 0 0 0 2 2 2
46798 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 18 97 151
46799 +10 87 144 19 95 150 19 95 150 18 97 151 18 97 151 18 97 151
46800 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
46801 +18 97 151 22 40 52 2 5 5 2 2 1 22 40 52 26 108 161
46802 +90 154 193 37 112 160 22 40 52 3 4 3 13 20 25 22 30 35
46803 +3 6 7 1 1 1 2 2 2 6 9 11 5 5 5 4 3 3
46804 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
46805 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46806 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46807 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46808 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46809 +4 4 4 4 4 4
46810 +1 1 1 4 0 0 60 73 81 177 184 187 193 200 203 174 174 174
46811 +177 184 187 193 200 203 163 162 163 30 32 34 4 0 0 2 2 2
46812 +5 5 5 4 3 3 4 0 0 6 10 14 24 86 132 10 87 144
46813 +10 87 144 10 87 144 19 95 150 19 95 150 19 95 150 18 97 151
46814 +26 108 161 26 108 161 26 108 161 90 154 193 26 108 161 28 67 93
46815 +6 10 14 2 5 5 13 20 25 24 86 132 37 112 160 90 154 193
46816 +10 87 144 7 12 15 2 5 5 28 67 93 37 112 160 28 67 93
46817 +2 2 1 7 12 15 35 83 115 28 67 93 3 6 7 1 0 0
46818 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
46819 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46820 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46821 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46822 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46823 +4 4 4 4 4 4
46824 +4 0 0 4 0 0 60 73 81 174 174 174 190 197 201 174 174 174
46825 +177 184 187 193 200 203 163 162 163 30 32 34 0 0 0 2 2 2
46826 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
46827 +10 87 144 16 89 141 19 95 150 10 87 144 26 108 161 26 108 161
46828 +26 108 161 26 108 161 26 108 161 28 67 93 6 10 14 1 1 2
46829 +7 12 15 28 67 93 26 108 161 16 89 141 24 86 132 21 29 34
46830 +3 4 3 21 29 34 37 112 160 37 112 160 27 99 146 21 29 34
46831 +21 29 34 26 108 161 90 154 193 35 83 115 1 1 2 2 0 0
46832 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 125 124 125
46833 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46834 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46835 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46836 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46837 +4 4 4 4 4 4
46838 +3 1 0 4 0 0 60 73 81 193 200 203 193 200 203 174 174 174
46839 +190 197 201 193 200 203 165 164 165 37 38 37 4 0 0 2 2 2
46840 +5 5 5 4 3 3 4 0 0 6 10 14 24 86 132 10 87 144
46841 +10 87 144 10 87 144 16 89 141 18 97 151 18 97 151 10 87 144
46842 +24 86 132 24 86 132 13 20 25 4 5 7 4 5 7 22 40 52
46843 +18 97 151 37 112 160 26 108 161 7 12 15 1 1 1 0 0 0
46844 +28 67 93 37 112 160 26 108 161 28 67 93 22 40 52 28 67 93
46845 +26 108 161 90 154 193 26 108 161 10 87 144 0 0 0 2 0 0
46846 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
46847 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46848 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46849 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46850 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46851 +4 4 4 4 4 4
46852 +4 0 0 6 6 6 60 73 81 174 174 174 193 200 203 174 174 174
46853 +190 197 201 193 200 203 165 164 165 30 32 34 0 0 0 2 2 2
46854 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
46855 +10 87 144 10 87 144 10 87 144 18 97 151 28 67 93 6 10 14
46856 +0 0 0 1 1 2 4 5 7 13 20 25 16 89 141 26 108 161
46857 +26 108 161 26 108 161 24 86 132 6 9 11 2 3 3 22 40 52
46858 +37 112 160 16 89 141 22 40 52 28 67 93 26 108 161 26 108 161
46859 +90 154 193 26 108 161 26 108 161 28 67 93 1 1 1 4 0 0
46860 +4 4 4 5 5 5 3 3 3 4 0 0 26 28 28 124 126 130
46861 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46862 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46863 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46864 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46865 +4 4 4 4 4 4
46866 +4 0 0 4 0 0 60 73 81 193 200 203 193 200 203 174 174 174
46867 +193 200 203 193 200 203 167 166 167 37 38 37 4 0 0 2 2 2
46868 +5 5 5 4 4 4 4 0 0 6 10 14 28 67 93 10 87 144
46869 +10 87 144 10 87 144 18 97 151 10 87 144 13 20 25 4 5 7
46870 +1 1 2 1 1 1 22 40 52 26 108 161 26 108 161 26 108 161
46871 +26 108 161 26 108 161 26 108 161 24 86 132 22 40 52 22 40 52
46872 +22 40 52 22 40 52 10 87 144 26 108 161 26 108 161 26 108 161
46873 +26 108 161 26 108 161 90 154 193 10 87 144 0 0 0 4 0 0
46874 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
46875 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46876 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46877 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46878 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46879 +4 4 4 4 4 4
46880 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
46881 +190 197 201 205 212 215 167 166 167 30 32 34 0 0 0 2 2 2
46882 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
46883 +10 87 144 10 87 144 10 87 144 10 87 144 22 40 52 1 1 2
46884 +2 0 0 1 1 2 24 86 132 26 108 161 26 108 161 26 108 161
46885 +26 108 161 19 95 150 16 89 141 10 87 144 22 40 52 22 40 52
46886 +10 87 144 26 108 161 37 112 160 26 108 161 26 108 161 26 108 161
46887 +26 108 161 26 108 161 26 108 161 28 67 93 2 0 0 3 1 0
46888 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
46889 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46890 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46891 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46892 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46893 +4 4 4 4 4 4
46894 +4 0 0 4 0 0 60 73 81 220 221 221 190 197 201 174 174 174
46895 +193 200 203 193 200 203 174 174 174 37 38 37 4 0 0 2 2 2
46896 +5 5 5 4 4 4 3 2 2 1 1 2 13 20 25 10 87 144
46897 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 13 20 25
46898 +13 20 25 22 40 52 10 87 144 18 97 151 18 97 151 26 108 161
46899 +10 87 144 13 20 25 6 10 14 21 29 34 24 86 132 18 97 151
46900 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
46901 +26 108 161 90 154 193 18 97 151 13 20 25 0 0 0 4 3 3
46902 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
46903 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46904 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46905 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46906 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46907 +4 4 4 4 4 4
46908 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
46909 +190 197 201 220 221 221 167 166 167 30 32 34 1 0 0 2 2 2
46910 +5 5 5 4 4 4 4 4 5 2 5 5 4 5 7 13 20 25
46911 +28 67 93 10 87 144 10 87 144 10 87 144 10 87 144 10 87 144
46912 +10 87 144 10 87 144 18 97 151 10 87 144 18 97 151 18 97 151
46913 +28 67 93 2 3 3 0 0 0 28 67 93 26 108 161 26 108 161
46914 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
46915 +26 108 161 10 87 144 13 20 25 1 1 2 3 2 2 4 4 4
46916 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
46917 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46918 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46919 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46920 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46921 +4 4 4 4 4 4
46922 +4 0 0 4 0 0 60 73 81 220 221 221 190 197 201 174 174 174
46923 +193 200 203 193 200 203 174 174 174 26 28 28 4 0 0 4 3 3
46924 +5 5 5 4 4 4 4 4 4 4 4 5 1 1 2 2 5 5
46925 +4 5 7 22 40 52 10 87 144 10 87 144 18 97 151 10 87 144
46926 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 18 97 151
46927 +10 87 144 28 67 93 22 40 52 10 87 144 26 108 161 18 97 151
46928 +18 97 151 18 97 151 26 108 161 26 108 161 26 108 161 26 108 161
46929 +22 40 52 1 1 2 0 0 0 2 3 3 4 4 4 4 4 4
46930 +4 4 4 5 5 5 4 4 4 0 0 0 26 28 28 131 129 131
46931 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46932 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46933 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46934 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46935 +4 4 4 4 4 4
46936 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
46937 +190 197 201 220 221 221 190 197 201 41 54 63 4 0 0 2 2 2
46938 +6 6 6 4 4 4 4 4 4 4 4 5 4 4 5 3 3 3
46939 +1 1 2 1 1 2 6 10 14 22 40 52 10 87 144 18 97 151
46940 +18 97 151 10 87 144 10 87 144 10 87 144 18 97 151 10 87 144
46941 +10 87 144 18 97 151 26 108 161 18 97 151 18 97 151 10 87 144
46942 +26 108 161 26 108 161 26 108 161 10 87 144 28 67 93 6 10 14
46943 +1 1 2 1 1 2 4 3 3 4 4 5 4 4 4 4 4 4
46944 +5 5 5 5 5 5 1 1 1 4 0 0 37 51 59 137 136 137
46945 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46946 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46947 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46948 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46949 +4 4 4 4 4 4
46950 +4 0 0 4 0 0 60 73 81 220 221 221 193 200 203 174 174 174
46951 +193 200 203 193 200 203 220 221 221 137 136 137 13 16 17 4 0 0
46952 +2 2 2 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5
46953 +4 4 5 4 3 3 1 1 2 4 5 7 13 20 25 28 67 93
46954 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 10 87 144
46955 +10 87 144 18 97 151 18 97 151 10 87 144 18 97 151 26 108 161
46956 +26 108 161 18 97 151 28 67 93 6 10 14 0 0 0 0 0 0
46957 +2 3 3 4 5 5 4 4 5 4 4 4 4 4 4 5 5 5
46958 +3 3 3 1 1 1 0 0 0 16 19 21 125 124 125 137 136 137
46959 +131 129 131 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46960 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46961 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46962 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46963 +4 4 4 4 4 4
46964 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
46965 +193 200 203 190 197 201 220 221 221 220 221 221 153 152 153 30 32 34
46966 +0 0 0 0 0 0 2 2 2 4 4 4 4 4 4 4 4 4
46967 +4 4 4 4 5 5 4 5 7 1 1 2 1 1 2 4 5 7
46968 +13 20 25 28 67 93 10 87 144 18 97 151 10 87 144 10 87 144
46969 +10 87 144 10 87 144 10 87 144 18 97 151 26 108 161 18 97 151
46970 +28 67 93 7 12 15 0 0 0 0 0 0 2 2 1 4 4 4
46971 +4 5 5 4 5 5 4 4 4 4 4 4 3 3 3 0 0 0
46972 +0 0 0 0 0 0 37 38 37 125 124 125 158 157 158 131 129 131
46973 +125 124 125 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46974 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46975 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46976 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46977 +4 4 4 4 4 4
46978 +4 3 3 4 0 0 41 54 63 193 200 203 220 221 221 174 174 174
46979 +193 200 203 193 200 203 193 200 203 220 221 221 244 246 246 193 200 203
46980 +120 125 127 5 5 5 1 0 0 0 0 0 1 1 1 4 4 4
46981 +4 4 4 4 4 4 4 5 5 4 5 5 4 4 5 1 1 2
46982 +4 5 7 4 5 7 22 40 52 10 87 144 10 87 144 10 87 144
46983 +10 87 144 10 87 144 18 97 151 10 87 144 10 87 144 13 20 25
46984 +4 5 7 2 3 3 1 1 2 4 4 4 4 5 5 4 4 4
46985 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 1 1 2
46986 +24 26 27 60 74 84 153 152 153 163 162 163 137 136 137 125 124 125
46987 +125 124 125 125 124 125 125 124 125 137 136 137 125 124 125 26 28 28
46988 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46989 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46990 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46991 +4 4 4 4 4 4
46992 +4 0 0 6 6 6 26 28 28 156 155 156 220 221 221 220 221 221
46993 +174 174 174 193 200 203 193 200 203 193 200 203 205 212 215 220 221 221
46994 +220 221 221 167 166 167 60 73 81 7 11 13 0 0 0 0 0 0
46995 +3 3 3 4 4 4 4 4 4 4 4 4 4 4 5 4 4 5
46996 +4 4 5 1 1 2 1 1 2 4 5 7 22 40 52 10 87 144
46997 +10 87 144 10 87 144 10 87 144 22 40 52 4 5 7 1 1 2
46998 +1 1 2 4 4 5 4 4 4 4 4 4 4 4 4 4 4 4
46999 +5 5 5 2 2 2 0 0 0 4 0 0 16 19 21 60 73 81
47000 +137 136 137 167 166 167 158 157 158 137 136 137 131 129 131 131 129 131
47001 +125 124 125 125 124 125 131 129 131 155 154 155 60 74 84 5 7 8
47002 +0 0 0 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47003 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47004 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47005 +4 4 4 4 4 4
47006 +5 5 5 4 0 0 4 0 0 60 73 81 193 200 203 220 221 221
47007 +193 200 203 193 200 203 193 200 203 193 200 203 205 212 215 220 221 221
47008 +220 221 221 220 221 221 220 221 221 137 136 137 43 57 68 6 6 6
47009 +4 0 0 1 1 1 4 4 4 4 4 4 4 4 4 4 4 4
47010 +4 4 5 4 4 5 3 2 2 1 1 2 2 5 5 13 20 25
47011 +22 40 52 22 40 52 13 20 25 2 3 3 1 1 2 3 3 3
47012 +4 5 7 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47013 +1 1 1 0 0 0 2 3 3 41 54 63 131 129 131 166 165 166
47014 +166 165 166 155 154 155 153 152 153 137 136 137 137 136 137 125 124 125
47015 +125 124 125 137 136 137 137 136 137 125 124 125 37 38 37 4 3 3
47016 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
47017 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47018 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47019 +4 4 4 4 4 4
47020 +4 3 3 6 6 6 6 6 6 13 16 17 60 73 81 167 166 167
47021 +220 221 221 220 221 221 220 221 221 193 200 203 193 200 203 193 200 203
47022 +205 212 215 220 221 221 220 221 221 244 246 246 205 212 215 125 124 125
47023 +24 26 27 0 0 0 0 0 0 2 2 2 5 5 5 5 5 5
47024 +4 4 4 4 4 4 4 4 4 4 4 5 1 1 2 4 5 7
47025 +4 5 7 4 5 7 1 1 2 3 2 2 4 4 5 4 4 4
47026 +4 4 4 4 4 4 5 5 5 4 4 4 0 0 0 0 0 0
47027 +2 0 0 26 28 28 125 124 125 174 174 174 174 174 174 166 165 166
47028 +156 155 156 153 152 153 137 136 137 137 136 137 131 129 131 137 136 137
47029 +137 136 137 137 136 137 60 74 84 30 32 34 4 0 0 4 0 0
47030 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47031 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47032 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47033 +4 4 4 4 4 4
47034 +5 5 5 6 6 6 4 0 0 4 0 0 6 6 6 26 28 28
47035 +125 124 125 174 174 174 220 221 221 220 221 221 220 221 221 193 200 203
47036 +205 212 215 220 221 221 205 212 215 220 221 221 220 221 221 244 246 246
47037 +193 200 203 60 74 84 13 16 17 4 0 0 0 0 0 3 3 3
47038 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 5 3 3 3
47039 +1 1 2 3 3 3 4 4 5 4 4 5 4 4 4 4 4 4
47040 +5 5 5 5 5 5 2 2 2 0 0 0 0 0 0 13 16 17
47041 +60 74 84 174 174 174 193 200 203 174 174 174 167 166 167 163 162 163
47042 +153 152 153 153 152 153 137 136 137 137 136 137 153 152 153 137 136 137
47043 +125 124 125 41 54 63 24 26 27 4 0 0 4 0 0 5 5 5
47044 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47045 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47046 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47047 +4 4 4 4 4 4
47048 +4 3 3 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
47049 +6 6 6 37 38 37 131 129 131 220 221 221 220 221 221 220 221 221
47050 +193 200 203 193 200 203 220 221 221 205 212 215 220 221 221 244 246 246
47051 +244 246 246 244 246 246 174 174 174 41 54 63 0 0 0 0 0 0
47052 +0 0 0 4 4 4 5 5 5 5 5 5 4 4 4 4 4 5
47053 +4 4 5 4 4 5 4 4 4 4 4 4 6 6 6 6 6 6
47054 +3 3 3 0 0 0 2 0 0 13 16 17 60 73 81 156 155 156
47055 +220 221 221 193 200 203 174 174 174 165 164 165 163 162 163 154 153 154
47056 +153 152 153 153 152 153 158 157 158 163 162 163 137 136 137 60 73 81
47057 +13 16 17 4 0 0 4 0 0 4 3 3 4 4 4 4 4 4
47058 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47059 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47060 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47061 +4 4 4 4 4 4
47062 +5 5 5 4 3 3 4 3 3 6 6 6 6 6 6 6 6 6
47063 +6 6 6 6 6 6 6 6 6 37 38 37 167 166 167 244 246 246
47064 +244 246 246 220 221 221 205 212 215 205 212 215 220 221 221 193 200 203
47065 +220 221 221 244 246 246 244 246 246 244 246 246 137 136 137 37 38 37
47066 +3 2 2 0 0 0 1 1 1 5 5 5 5 5 5 4 4 4
47067 +4 4 4 4 4 4 4 4 4 5 5 5 4 4 4 1 1 1
47068 +0 0 0 5 5 5 43 57 68 153 152 153 193 200 203 220 221 221
47069 +177 184 187 174 174 174 167 166 167 166 165 166 158 157 158 157 156 157
47070 +158 157 158 166 165 166 156 155 156 85 115 134 13 16 17 4 0 0
47071 +4 0 0 4 0 0 5 5 5 5 5 5 4 4 4 4 4 4
47072 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47073 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47074 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47075 +4 4 4 4 4 4
47076 +5 5 5 4 3 3 6 6 6 6 6 6 4 0 0 6 6 6
47077 +6 6 6 6 6 6 6 6 6 6 6 6 13 16 17 60 73 81
47078 +177 184 187 220 221 221 220 221 221 220 221 221 205 212 215 220 221 221
47079 +220 221 221 205 212 215 220 221 221 244 246 246 244 246 246 205 212 215
47080 +125 124 125 30 32 34 0 0 0 0 0 0 2 2 2 5 5 5
47081 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 1 0 0
47082 +37 38 37 131 129 131 205 212 215 220 221 221 193 200 203 174 174 174
47083 +174 174 174 174 174 174 167 166 167 165 164 165 166 165 166 167 166 167
47084 +158 157 158 125 124 125 37 38 37 4 0 0 4 0 0 4 0 0
47085 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
47086 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47087 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47088 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47089 +4 4 4 4 4 4
47090 +4 4 4 5 5 5 4 3 3 4 3 3 6 6 6 6 6 6
47091 +4 0 0 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
47092 +26 28 28 125 124 125 205 212 215 220 221 221 220 221 221 220 221 221
47093 +205 212 215 220 221 221 205 212 215 220 221 221 220 221 221 244 246 246
47094 +244 246 246 190 197 201 60 74 84 16 19 21 4 0 0 0 0 0
47095 +0 0 0 0 0 0 0 0 0 0 0 0 16 19 21 120 125 127
47096 +177 184 187 220 221 221 205 212 215 177 184 187 174 174 174 177 184 187
47097 +174 174 174 174 174 174 167 166 167 174 174 174 166 165 166 137 136 137
47098 +60 73 81 13 16 17 4 0 0 4 0 0 4 3 3 6 6 6
47099 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47100 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47101 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47102 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47103 +4 4 4 4 4 4
47104 +5 5 5 4 3 3 5 5 5 4 3 3 6 6 6 4 0 0
47105 +6 6 6 6 6 6 4 0 0 6 6 6 4 0 0 6 6 6
47106 +6 6 6 6 6 6 37 38 37 137 136 137 193 200 203 220 221 221
47107 +220 221 221 205 212 215 220 221 221 205 212 215 205 212 215 220 221 221
47108 +220 221 221 220 221 221 244 246 246 166 165 166 43 57 68 2 2 2
47109 +0 0 0 4 0 0 16 19 21 60 73 81 157 156 157 202 210 214
47110 +220 221 221 193 200 203 177 184 187 177 184 187 177 184 187 174 174 174
47111 +174 174 174 174 174 174 174 174 174 157 156 157 60 74 84 24 26 27
47112 +4 0 0 4 0 0 4 0 0 6 6 6 4 4 4 4 4 4
47113 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47114 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47115 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47116 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47117 +4 4 4 4 4 4
47118 +4 4 4 4 4 4 5 5 5 4 3 3 5 5 5 6 6 6
47119 +6 6 6 4 0 0 6 6 6 6 6 6 6 6 6 4 0 0
47120 +4 0 0 4 0 0 6 6 6 24 26 27 60 73 81 167 166 167
47121 +220 221 221 220 221 221 220 221 221 205 212 215 205 212 215 205 212 215
47122 +205 212 215 220 221 221 220 221 221 220 221 221 205 212 215 137 136 137
47123 +60 74 84 125 124 125 137 136 137 190 197 201 220 221 221 193 200 203
47124 +177 184 187 177 184 187 177 184 187 174 174 174 174 174 174 177 184 187
47125 +190 197 201 174 174 174 125 124 125 37 38 37 6 6 6 4 0 0
47126 +4 0 0 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47127 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47128 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47129 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47130 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47131 +4 4 4 4 4 4
47132 +4 4 4 4 4 4 5 5 5 5 5 5 4 3 3 6 6 6
47133 +4 0 0 6 6 6 6 6 6 6 6 6 4 0 0 6 6 6
47134 +6 6 6 6 6 6 4 0 0 4 0 0 6 6 6 6 6 6
47135 +125 124 125 193 200 203 244 246 246 220 221 221 205 212 215 205 212 215
47136 +205 212 215 193 200 203 205 212 215 205 212 215 220 221 221 220 221 221
47137 +193 200 203 193 200 203 205 212 215 193 200 203 193 200 203 177 184 187
47138 +190 197 201 190 197 201 174 174 174 190 197 201 193 200 203 190 197 201
47139 +153 152 153 60 73 81 4 0 0 4 0 0 4 0 0 3 2 2
47140 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47141 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47142 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47143 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47144 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47145 +4 4 4 4 4 4
47146 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 4 3 3
47147 +6 6 6 4 3 3 4 3 3 4 3 3 6 6 6 6 6 6
47148 +4 0 0 6 6 6 6 6 6 6 6 6 4 0 0 4 0 0
47149 +4 0 0 26 28 28 131 129 131 220 221 221 244 246 246 220 221 221
47150 +205 212 215 193 200 203 205 212 215 193 200 203 193 200 203 205 212 215
47151 +220 221 221 193 200 203 193 200 203 193 200 203 190 197 201 174 174 174
47152 +174 174 174 190 197 201 193 200 203 193 200 203 167 166 167 125 124 125
47153 +6 6 6 4 0 0 4 0 0 4 3 3 4 4 4 4 4 4
47154 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47155 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47156 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47157 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47158 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47159 +4 4 4 4 4 4
47160 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
47161 +5 5 5 4 3 3 5 5 5 6 6 6 4 3 3 5 5 5
47162 +6 6 6 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
47163 +4 0 0 4 0 0 6 6 6 41 54 63 158 157 158 220 221 221
47164 +220 221 221 220 221 221 193 200 203 193 200 203 193 200 203 190 197 201
47165 +190 197 201 190 197 201 190 197 201 190 197 201 174 174 174 193 200 203
47166 +193 200 203 220 221 221 174 174 174 125 124 125 37 38 37 4 0 0
47167 +4 0 0 4 3 3 6 6 6 4 4 4 4 4 4 4 4 4
47168 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47169 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47170 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47171 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47172 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47173 +4 4 4 4 4 4
47174 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47175 +4 4 4 5 5 5 4 3 3 4 3 3 4 3 3 5 5 5
47176 +4 3 3 6 6 6 5 5 5 4 3 3 6 6 6 6 6 6
47177 +6 6 6 6 6 6 4 0 0 4 0 0 13 16 17 60 73 81
47178 +174 174 174 220 221 221 220 221 221 205 212 215 190 197 201 174 174 174
47179 +193 200 203 174 174 174 190 197 201 174 174 174 193 200 203 220 221 221
47180 +193 200 203 131 129 131 37 38 37 6 6 6 4 0 0 4 0 0
47181 +6 6 6 6 6 6 4 3 3 5 5 5 4 4 4 4 4 4
47182 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47183 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47184 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47185 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47186 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47187 +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 5 5 5 5 5 5 5 5 5
47190 +5 5 5 4 3 3 4 3 3 5 5 5 4 3 3 4 3 3
47191 +5 5 5 6 6 6 6 6 6 4 0 0 6 6 6 6 6 6
47192 +6 6 6 125 124 125 174 174 174 220 221 221 220 221 221 193 200 203
47193 +193 200 203 193 200 203 193 200 203 193 200 203 220 221 221 158 157 158
47194 +60 73 81 6 6 6 4 0 0 4 0 0 5 5 5 6 6 6
47195 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
47196 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47197 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47198 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47199 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47200 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47201 +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 5 5 5 5 5 5 4 3 3 5 5 5 4 3 3
47205 +5 5 5 5 5 5 6 6 6 6 6 6 4 0 0 4 0 0
47206 +4 0 0 4 0 0 26 28 28 125 124 125 174 174 174 193 200 203
47207 +193 200 203 174 174 174 193 200 203 167 166 167 125 124 125 6 6 6
47208 +6 6 6 6 6 6 4 0 0 6 6 6 6 6 6 5 5 5
47209 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
47210 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47211 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47212 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47213 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47214 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47215 +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 5 5 5
47219 +4 3 3 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
47220 +6 6 6 4 0 0 4 0 0 6 6 6 37 38 37 125 124 125
47221 +153 152 153 131 129 131 125 124 125 37 38 37 6 6 6 6 6 6
47222 +6 6 6 4 0 0 6 6 6 6 6 6 4 3 3 5 5 5
47223 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47224 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47225 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47226 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47227 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47228 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47229 +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 5 5 5 5 5 5 4 3 3 5 5 5 4 3 3
47234 +6 6 6 6 6 6 4 0 0 4 0 0 6 6 6 6 6 6
47235 +24 26 27 24 26 27 6 6 6 6 6 6 6 6 6 4 0 0
47236 +6 6 6 6 6 6 4 0 0 6 6 6 5 5 5 4 3 3
47237 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47238 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47239 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47240 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47241 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47242 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47243 +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 5 5 5 4 3 3 5 5 5 6 6 6
47248 +4 0 0 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
47249 +6 6 6 6 6 6 6 6 6 4 0 0 6 6 6 6 6 6
47250 +4 0 0 6 6 6 6 6 6 4 3 3 5 5 5 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 4 4 4
47253 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47254 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47255 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47256 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47257 +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 5 5 5 4 3 3 5 5 5
47262 +5 5 5 5 5 5 4 0 0 6 6 6 4 0 0 6 6 6
47263 +6 6 6 6 6 6 6 6 6 4 0 0 6 6 6 4 0 0
47264 +6 6 6 4 3 3 5 5 5 4 3 3 5 5 5 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 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47268 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47269 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47270 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47271 +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 5 5 5
47276 +4 3 3 6 6 6 4 3 3 6 6 6 6 6 6 6 6 6
47277 +4 0 0 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
47278 +6 6 6 4 3 3 5 5 5 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 4 4 4 4 4 4 4 4 4 4 4 4
47282 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47283 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47284 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47285 +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 5 5 5 4 3 3 5 5 5 4 0 0 6 6 6
47291 +6 6 6 4 0 0 6 6 6 6 6 6 4 0 0 6 6 6
47292 +4 3 3 5 5 5 5 5 5 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 4 4 4 4 4 4 4 4 4
47296 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47297 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47298 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47299 +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 5 5 5 4 3 3 5 5 5 6 6 6 4 3 3
47305 +4 3 3 6 6 6 6 6 6 4 3 3 6 6 6 4 3 3
47306 +5 5 5 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 4 4 4
47310 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47311 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47312 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47313 +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 5 5 5 4 3 3 6 6 6
47319 +5 5 5 4 3 3 4 3 3 4 3 3 5 5 5 5 5 5
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 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47325 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47326 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47327 +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 5 5 5 4 3 3
47333 +5 5 5 4 3 3 5 5 5 5 5 5 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 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47339 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47340 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47341 +4 4 4 4 4 4
47342 diff --git a/drivers/video/mb862xx/mb862xxfb_accel.c b/drivers/video/mb862xx/mb862xxfb_accel.c
47343 index fe92eed..106e085 100644
47344 --- a/drivers/video/mb862xx/mb862xxfb_accel.c
47345 +++ b/drivers/video/mb862xx/mb862xxfb_accel.c
47346 @@ -312,14 +312,18 @@ void mb862xxfb_init_accel(struct fb_info *info, int xres)
47347 struct mb862xxfb_par *par = info->par;
47348
47349 if (info->var.bits_per_pixel == 32) {
47350 - info->fbops->fb_fillrect = cfb_fillrect;
47351 - info->fbops->fb_copyarea = cfb_copyarea;
47352 - info->fbops->fb_imageblit = cfb_imageblit;
47353 + pax_open_kernel();
47354 + *(void **)&info->fbops->fb_fillrect = cfb_fillrect;
47355 + *(void **)&info->fbops->fb_copyarea = cfb_copyarea;
47356 + *(void **)&info->fbops->fb_imageblit = cfb_imageblit;
47357 + pax_close_kernel();
47358 } else {
47359 outreg(disp, GC_L0EM, 3);
47360 - info->fbops->fb_fillrect = mb86290fb_fillrect;
47361 - info->fbops->fb_copyarea = mb86290fb_copyarea;
47362 - info->fbops->fb_imageblit = mb86290fb_imageblit;
47363 + pax_open_kernel();
47364 + *(void **)&info->fbops->fb_fillrect = mb86290fb_fillrect;
47365 + *(void **)&info->fbops->fb_copyarea = mb86290fb_copyarea;
47366 + *(void **)&info->fbops->fb_imageblit = mb86290fb_imageblit;
47367 + pax_close_kernel();
47368 }
47369 outreg(draw, GDC_REG_DRAW_BASE, 0);
47370 outreg(draw, GDC_REG_MODE_MISC, 0x8000);
47371 diff --git a/drivers/video/nvidia/nvidia.c b/drivers/video/nvidia/nvidia.c
47372 index ff22871..b129bed 100644
47373 --- a/drivers/video/nvidia/nvidia.c
47374 +++ b/drivers/video/nvidia/nvidia.c
47375 @@ -669,19 +669,23 @@ static int nvidiafb_set_par(struct fb_info *info)
47376 info->fix.line_length = (info->var.xres_virtual *
47377 info->var.bits_per_pixel) >> 3;
47378 if (info->var.accel_flags) {
47379 - info->fbops->fb_imageblit = nvidiafb_imageblit;
47380 - info->fbops->fb_fillrect = nvidiafb_fillrect;
47381 - info->fbops->fb_copyarea = nvidiafb_copyarea;
47382 - info->fbops->fb_sync = nvidiafb_sync;
47383 + pax_open_kernel();
47384 + *(void **)&info->fbops->fb_imageblit = nvidiafb_imageblit;
47385 + *(void **)&info->fbops->fb_fillrect = nvidiafb_fillrect;
47386 + *(void **)&info->fbops->fb_copyarea = nvidiafb_copyarea;
47387 + *(void **)&info->fbops->fb_sync = nvidiafb_sync;
47388 + pax_close_kernel();
47389 info->pixmap.scan_align = 4;
47390 info->flags &= ~FBINFO_HWACCEL_DISABLED;
47391 info->flags |= FBINFO_READS_FAST;
47392 NVResetGraphics(info);
47393 } else {
47394 - info->fbops->fb_imageblit = cfb_imageblit;
47395 - info->fbops->fb_fillrect = cfb_fillrect;
47396 - info->fbops->fb_copyarea = cfb_copyarea;
47397 - info->fbops->fb_sync = NULL;
47398 + pax_open_kernel();
47399 + *(void **)&info->fbops->fb_imageblit = cfb_imageblit;
47400 + *(void **)&info->fbops->fb_fillrect = cfb_fillrect;
47401 + *(void **)&info->fbops->fb_copyarea = cfb_copyarea;
47402 + *(void **)&info->fbops->fb_sync = NULL;
47403 + pax_close_kernel();
47404 info->pixmap.scan_align = 1;
47405 info->flags |= FBINFO_HWACCEL_DISABLED;
47406 info->flags &= ~FBINFO_READS_FAST;
47407 @@ -1173,8 +1177,11 @@ static int nvidia_set_fbinfo(struct fb_info *info)
47408 info->pixmap.size = 8 * 1024;
47409 info->pixmap.flags = FB_PIXMAP_SYSTEM;
47410
47411 - if (!hwcur)
47412 - info->fbops->fb_cursor = NULL;
47413 + if (!hwcur) {
47414 + pax_open_kernel();
47415 + *(void **)&info->fbops->fb_cursor = NULL;
47416 + pax_close_kernel();
47417 + }
47418
47419 info->var.accel_flags = (!noaccel);
47420
47421 diff --git a/drivers/video/s1d13xxxfb.c b/drivers/video/s1d13xxxfb.c
47422 index 76d9053..dec2bfd 100644
47423 --- a/drivers/video/s1d13xxxfb.c
47424 +++ b/drivers/video/s1d13xxxfb.c
47425 @@ -881,8 +881,10 @@ static int s1d13xxxfb_probe(struct platform_device *pdev)
47426
47427 switch(prod_id) {
47428 case S1D13506_PROD_ID: /* activate acceleration */
47429 - s1d13xxxfb_fbops.fb_fillrect = s1d13xxxfb_bitblt_solidfill;
47430 - s1d13xxxfb_fbops.fb_copyarea = s1d13xxxfb_bitblt_copyarea;
47431 + pax_open_kernel();
47432 + *(void **)&s1d13xxxfb_fbops.fb_fillrect = s1d13xxxfb_bitblt_solidfill;
47433 + *(void **)&s1d13xxxfb_fbops.fb_copyarea = s1d13xxxfb_bitblt_copyarea;
47434 + pax_close_kernel();
47435 info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN |
47436 FBINFO_HWACCEL_FILLRECT | FBINFO_HWACCEL_COPYAREA;
47437 break;
47438 diff --git a/drivers/video/smscufx.c b/drivers/video/smscufx.c
47439 index 97bd662..39fab85 100644
47440 --- a/drivers/video/smscufx.c
47441 +++ b/drivers/video/smscufx.c
47442 @@ -1171,7 +1171,9 @@ static int ufx_ops_release(struct fb_info *info, int user)
47443 fb_deferred_io_cleanup(info);
47444 kfree(info->fbdefio);
47445 info->fbdefio = NULL;
47446 - info->fbops->fb_mmap = ufx_ops_mmap;
47447 + pax_open_kernel();
47448 + *(void **)&info->fbops->fb_mmap = ufx_ops_mmap;
47449 + pax_close_kernel();
47450 }
47451
47452 pr_debug("released /dev/fb%d user=%d count=%d",
47453 diff --git a/drivers/video/udlfb.c b/drivers/video/udlfb.c
47454 index 86d449e..8e04dc5 100644
47455 --- a/drivers/video/udlfb.c
47456 +++ b/drivers/video/udlfb.c
47457 @@ -619,11 +619,11 @@ int dlfb_handle_damage(struct dlfb_data *dev, int x, int y,
47458 dlfb_urb_completion(urb);
47459
47460 error:
47461 - atomic_add(bytes_sent, &dev->bytes_sent);
47462 - atomic_add(bytes_identical, &dev->bytes_identical);
47463 - atomic_add(width*height*2, &dev->bytes_rendered);
47464 + atomic_add_unchecked(bytes_sent, &dev->bytes_sent);
47465 + atomic_add_unchecked(bytes_identical, &dev->bytes_identical);
47466 + atomic_add_unchecked(width*height*2, &dev->bytes_rendered);
47467 end_cycles = get_cycles();
47468 - atomic_add(((unsigned int) ((end_cycles - start_cycles)
47469 + atomic_add_unchecked(((unsigned int) ((end_cycles - start_cycles)
47470 >> 10)), /* Kcycles */
47471 &dev->cpu_kcycles_used);
47472
47473 @@ -744,11 +744,11 @@ static void dlfb_dpy_deferred_io(struct fb_info *info,
47474 dlfb_urb_completion(urb);
47475
47476 error:
47477 - atomic_add(bytes_sent, &dev->bytes_sent);
47478 - atomic_add(bytes_identical, &dev->bytes_identical);
47479 - atomic_add(bytes_rendered, &dev->bytes_rendered);
47480 + atomic_add_unchecked(bytes_sent, &dev->bytes_sent);
47481 + atomic_add_unchecked(bytes_identical, &dev->bytes_identical);
47482 + atomic_add_unchecked(bytes_rendered, &dev->bytes_rendered);
47483 end_cycles = get_cycles();
47484 - atomic_add(((unsigned int) ((end_cycles - start_cycles)
47485 + atomic_add_unchecked(((unsigned int) ((end_cycles - start_cycles)
47486 >> 10)), /* Kcycles */
47487 &dev->cpu_kcycles_used);
47488 }
47489 @@ -989,7 +989,9 @@ static int dlfb_ops_release(struct fb_info *info, int user)
47490 fb_deferred_io_cleanup(info);
47491 kfree(info->fbdefio);
47492 info->fbdefio = NULL;
47493 - info->fbops->fb_mmap = dlfb_ops_mmap;
47494 + pax_open_kernel();
47495 + *(void **)&info->fbops->fb_mmap = dlfb_ops_mmap;
47496 + pax_close_kernel();
47497 }
47498
47499 pr_warn("released /dev/fb%d user=%d count=%d\n",
47500 @@ -1372,7 +1374,7 @@ static ssize_t metrics_bytes_rendered_show(struct device *fbdev,
47501 struct fb_info *fb_info = dev_get_drvdata(fbdev);
47502 struct dlfb_data *dev = fb_info->par;
47503 return snprintf(buf, PAGE_SIZE, "%u\n",
47504 - atomic_read(&dev->bytes_rendered));
47505 + atomic_read_unchecked(&dev->bytes_rendered));
47506 }
47507
47508 static ssize_t metrics_bytes_identical_show(struct device *fbdev,
47509 @@ -1380,7 +1382,7 @@ static ssize_t metrics_bytes_identical_show(struct device *fbdev,
47510 struct fb_info *fb_info = dev_get_drvdata(fbdev);
47511 struct dlfb_data *dev = fb_info->par;
47512 return snprintf(buf, PAGE_SIZE, "%u\n",
47513 - atomic_read(&dev->bytes_identical));
47514 + atomic_read_unchecked(&dev->bytes_identical));
47515 }
47516
47517 static ssize_t metrics_bytes_sent_show(struct device *fbdev,
47518 @@ -1388,7 +1390,7 @@ static ssize_t metrics_bytes_sent_show(struct device *fbdev,
47519 struct fb_info *fb_info = dev_get_drvdata(fbdev);
47520 struct dlfb_data *dev = fb_info->par;
47521 return snprintf(buf, PAGE_SIZE, "%u\n",
47522 - atomic_read(&dev->bytes_sent));
47523 + atomic_read_unchecked(&dev->bytes_sent));
47524 }
47525
47526 static ssize_t metrics_cpu_kcycles_used_show(struct device *fbdev,
47527 @@ -1396,7 +1398,7 @@ static ssize_t metrics_cpu_kcycles_used_show(struct device *fbdev,
47528 struct fb_info *fb_info = dev_get_drvdata(fbdev);
47529 struct dlfb_data *dev = fb_info->par;
47530 return snprintf(buf, PAGE_SIZE, "%u\n",
47531 - atomic_read(&dev->cpu_kcycles_used));
47532 + atomic_read_unchecked(&dev->cpu_kcycles_used));
47533 }
47534
47535 static ssize_t edid_show(
47536 @@ -1456,10 +1458,10 @@ static ssize_t metrics_reset_store(struct device *fbdev,
47537 struct fb_info *fb_info = dev_get_drvdata(fbdev);
47538 struct dlfb_data *dev = fb_info->par;
47539
47540 - atomic_set(&dev->bytes_rendered, 0);
47541 - atomic_set(&dev->bytes_identical, 0);
47542 - atomic_set(&dev->bytes_sent, 0);
47543 - atomic_set(&dev->cpu_kcycles_used, 0);
47544 + atomic_set_unchecked(&dev->bytes_rendered, 0);
47545 + atomic_set_unchecked(&dev->bytes_identical, 0);
47546 + atomic_set_unchecked(&dev->bytes_sent, 0);
47547 + atomic_set_unchecked(&dev->cpu_kcycles_used, 0);
47548
47549 return count;
47550 }
47551 diff --git a/drivers/video/uvesafb.c b/drivers/video/uvesafb.c
47552 index d428445..79a78df 100644
47553 --- a/drivers/video/uvesafb.c
47554 +++ b/drivers/video/uvesafb.c
47555 @@ -19,6 +19,7 @@
47556 #include <linux/io.h>
47557 #include <linux/mutex.h>
47558 #include <linux/slab.h>
47559 +#include <linux/moduleloader.h>
47560 #include <video/edid.h>
47561 #include <video/uvesafb.h>
47562 #ifdef CONFIG_X86
47563 @@ -569,10 +570,32 @@ static int uvesafb_vbe_getpmi(struct uvesafb_ktask *task,
47564 if ((task->t.regs.eax & 0xffff) != 0x4f || task->t.regs.es < 0xc000) {
47565 par->pmi_setpal = par->ypan = 0;
47566 } else {
47567 +
47568 +#ifdef CONFIG_PAX_KERNEXEC
47569 +#ifdef CONFIG_MODULES
47570 + par->pmi_code = module_alloc_exec((u16)task->t.regs.ecx);
47571 +#endif
47572 + if (!par->pmi_code) {
47573 + par->pmi_setpal = par->ypan = 0;
47574 + return 0;
47575 + }
47576 +#endif
47577 +
47578 par->pmi_base = (u16 *)phys_to_virt(((u32)task->t.regs.es << 4)
47579 + task->t.regs.edi);
47580 +
47581 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
47582 + pax_open_kernel();
47583 + memcpy(par->pmi_code, par->pmi_base, (u16)task->t.regs.ecx);
47584 + pax_close_kernel();
47585 +
47586 + par->pmi_start = ktva_ktla(par->pmi_code + par->pmi_base[1]);
47587 + par->pmi_pal = ktva_ktla(par->pmi_code + par->pmi_base[2]);
47588 +#else
47589 par->pmi_start = (u8 *)par->pmi_base + par->pmi_base[1];
47590 par->pmi_pal = (u8 *)par->pmi_base + par->pmi_base[2];
47591 +#endif
47592 +
47593 printk(KERN_INFO "uvesafb: protected mode interface info at "
47594 "%04x:%04x\n",
47595 (u16)task->t.regs.es, (u16)task->t.regs.edi);
47596 @@ -817,13 +840,14 @@ static int uvesafb_vbe_init(struct fb_info *info)
47597 par->ypan = ypan;
47598
47599 if (par->pmi_setpal || par->ypan) {
47600 +#if !defined(CONFIG_MODULES) || !defined(CONFIG_PAX_KERNEXEC)
47601 if (__supported_pte_mask & _PAGE_NX) {
47602 par->pmi_setpal = par->ypan = 0;
47603 printk(KERN_WARNING "uvesafb: NX protection is actively."
47604 "We have better not to use the PMI.\n");
47605 - } else {
47606 + } else
47607 +#endif
47608 uvesafb_vbe_getpmi(task, par);
47609 - }
47610 }
47611 #else
47612 /* The protected mode interface is not available on non-x86. */
47613 @@ -1457,8 +1481,11 @@ static void uvesafb_init_info(struct fb_info *info, struct vbe_mode_ib *mode)
47614 info->fix.ywrapstep = (par->ypan > 1) ? 1 : 0;
47615
47616 /* Disable blanking if the user requested so. */
47617 - if (!blank)
47618 - info->fbops->fb_blank = NULL;
47619 + if (!blank) {
47620 + pax_open_kernel();
47621 + *(void **)&info->fbops->fb_blank = NULL;
47622 + pax_close_kernel();
47623 + }
47624
47625 /*
47626 * Find out how much IO memory is required for the mode with
47627 @@ -1534,8 +1561,11 @@ static void uvesafb_init_info(struct fb_info *info, struct vbe_mode_ib *mode)
47628 info->flags = FBINFO_FLAG_DEFAULT |
47629 (par->ypan ? FBINFO_HWACCEL_YPAN : 0);
47630
47631 - if (!par->ypan)
47632 - info->fbops->fb_pan_display = NULL;
47633 + if (!par->ypan) {
47634 + pax_open_kernel();
47635 + *(void **)&info->fbops->fb_pan_display = NULL;
47636 + pax_close_kernel();
47637 + }
47638 }
47639
47640 static void uvesafb_init_mtrr(struct fb_info *info)
47641 @@ -1836,6 +1866,11 @@ out:
47642 if (par->vbe_modes)
47643 kfree(par->vbe_modes);
47644
47645 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
47646 + if (par->pmi_code)
47647 + module_free_exec(NULL, par->pmi_code);
47648 +#endif
47649 +
47650 framebuffer_release(info);
47651 return err;
47652 }
47653 @@ -1862,6 +1897,12 @@ static int uvesafb_remove(struct platform_device *dev)
47654 kfree(par->vbe_state_orig);
47655 if (par->vbe_state_saved)
47656 kfree(par->vbe_state_saved);
47657 +
47658 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
47659 + if (par->pmi_code)
47660 + module_free_exec(NULL, par->pmi_code);
47661 +#endif
47662 +
47663 }
47664
47665 framebuffer_release(info);
47666 diff --git a/drivers/video/vesafb.c b/drivers/video/vesafb.c
47667 index 501b340..d80aa17 100644
47668 --- a/drivers/video/vesafb.c
47669 +++ b/drivers/video/vesafb.c
47670 @@ -9,6 +9,7 @@
47671 */
47672
47673 #include <linux/module.h>
47674 +#include <linux/moduleloader.h>
47675 #include <linux/kernel.h>
47676 #include <linux/errno.h>
47677 #include <linux/string.h>
47678 @@ -52,8 +53,8 @@ static int vram_remap __initdata; /* Set amount of memory to be used */
47679 static int vram_total __initdata; /* Set total amount of memory */
47680 static int pmi_setpal __read_mostly = 1; /* pmi for palette changes ??? */
47681 static int ypan __read_mostly; /* 0..nothing, 1..ypan, 2..ywrap */
47682 -static void (*pmi_start)(void) __read_mostly;
47683 -static void (*pmi_pal) (void) __read_mostly;
47684 +static void (*pmi_start)(void) __read_only;
47685 +static void (*pmi_pal) (void) __read_only;
47686 static int depth __read_mostly;
47687 static int vga_compat __read_mostly;
47688 /* --------------------------------------------------------------------- */
47689 @@ -233,6 +234,7 @@ static int __init vesafb_probe(struct platform_device *dev)
47690 unsigned int size_vmode;
47691 unsigned int size_remap;
47692 unsigned int size_total;
47693 + void *pmi_code = NULL;
47694
47695 if (screen_info.orig_video_isVGA != VIDEO_TYPE_VLFB)
47696 return -ENODEV;
47697 @@ -275,10 +277,6 @@ static int __init vesafb_probe(struct platform_device *dev)
47698 size_remap = size_total;
47699 vesafb_fix.smem_len = size_remap;
47700
47701 -#ifndef __i386__
47702 - screen_info.vesapm_seg = 0;
47703 -#endif
47704 -
47705 if (!request_mem_region(vesafb_fix.smem_start, size_total, "vesafb")) {
47706 printk(KERN_WARNING
47707 "vesafb: cannot reserve video memory at 0x%lx\n",
47708 @@ -307,9 +305,21 @@ static int __init vesafb_probe(struct platform_device *dev)
47709 printk(KERN_INFO "vesafb: mode is %dx%dx%d, linelength=%d, pages=%d\n",
47710 vesafb_defined.xres, vesafb_defined.yres, vesafb_defined.bits_per_pixel, vesafb_fix.line_length, screen_info.pages);
47711
47712 +#ifdef __i386__
47713 +
47714 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
47715 + pmi_code = module_alloc_exec(screen_info.vesapm_size);
47716 + if (!pmi_code)
47717 +#elif !defined(CONFIG_PAX_KERNEXEC)
47718 + if (0)
47719 +#endif
47720 +
47721 +#endif
47722 + screen_info.vesapm_seg = 0;
47723 +
47724 if (screen_info.vesapm_seg) {
47725 - printk(KERN_INFO "vesafb: protected mode interface info at %04x:%04x\n",
47726 - screen_info.vesapm_seg,screen_info.vesapm_off);
47727 + printk(KERN_INFO "vesafb: protected mode interface info at %04x:%04x %04x bytes\n",
47728 + screen_info.vesapm_seg,screen_info.vesapm_off,screen_info.vesapm_size);
47729 }
47730
47731 if (screen_info.vesapm_seg < 0xc000)
47732 @@ -317,9 +327,25 @@ static int __init vesafb_probe(struct platform_device *dev)
47733
47734 if (ypan || pmi_setpal) {
47735 unsigned short *pmi_base;
47736 +
47737 pmi_base = (unsigned short*)phys_to_virt(((unsigned long)screen_info.vesapm_seg << 4) + screen_info.vesapm_off);
47738 - pmi_start = (void*)((char*)pmi_base + pmi_base[1]);
47739 - pmi_pal = (void*)((char*)pmi_base + pmi_base[2]);
47740 +
47741 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
47742 + pax_open_kernel();
47743 + memcpy(pmi_code, pmi_base, screen_info.vesapm_size);
47744 +#else
47745 + pmi_code = pmi_base;
47746 +#endif
47747 +
47748 + pmi_start = (void*)((char*)pmi_code + pmi_base[1]);
47749 + pmi_pal = (void*)((char*)pmi_code + pmi_base[2]);
47750 +
47751 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
47752 + pmi_start = ktva_ktla(pmi_start);
47753 + pmi_pal = ktva_ktla(pmi_pal);
47754 + pax_close_kernel();
47755 +#endif
47756 +
47757 printk(KERN_INFO "vesafb: pmi: set display start = %p, set palette = %p\n",pmi_start,pmi_pal);
47758 if (pmi_base[3]) {
47759 printk(KERN_INFO "vesafb: pmi: ports = ");
47760 @@ -472,8 +498,11 @@ static int __init vesafb_probe(struct platform_device *dev)
47761 info->flags = FBINFO_FLAG_DEFAULT | FBINFO_MISC_FIRMWARE |
47762 (ypan ? FBINFO_HWACCEL_YPAN : 0);
47763
47764 - if (!ypan)
47765 - info->fbops->fb_pan_display = NULL;
47766 + if (!ypan) {
47767 + pax_open_kernel();
47768 + *(void **)&info->fbops->fb_pan_display = NULL;
47769 + pax_close_kernel();
47770 + }
47771
47772 if (fb_alloc_cmap(&info->cmap, 256, 0) < 0) {
47773 err = -ENOMEM;
47774 @@ -488,6 +517,11 @@ static int __init vesafb_probe(struct platform_device *dev)
47775 info->node, info->fix.id);
47776 return 0;
47777 err:
47778 +
47779 +#if defined(__i386__) && defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
47780 + module_free_exec(NULL, pmi_code);
47781 +#endif
47782 +
47783 if (info->screen_base)
47784 iounmap(info->screen_base);
47785 framebuffer_release(info);
47786 diff --git a/drivers/video/via/via_clock.h b/drivers/video/via/via_clock.h
47787 index 88714ae..16c2e11 100644
47788 --- a/drivers/video/via/via_clock.h
47789 +++ b/drivers/video/via/via_clock.h
47790 @@ -56,7 +56,7 @@ struct via_clock {
47791
47792 void (*set_engine_pll_state)(u8 state);
47793 void (*set_engine_pll)(struct via_pll_config config);
47794 -};
47795 +} __no_const;
47796
47797
47798 static inline u32 get_pll_internal_frequency(u32 ref_freq,
47799 diff --git a/drivers/xen/xenfs/xenstored.c b/drivers/xen/xenfs/xenstored.c
47800 index fef20db..d28b1ab 100644
47801 --- a/drivers/xen/xenfs/xenstored.c
47802 +++ b/drivers/xen/xenfs/xenstored.c
47803 @@ -24,7 +24,12 @@ static int xsd_release(struct inode *inode, struct file *file)
47804 static int xsd_kva_open(struct inode *inode, struct file *file)
47805 {
47806 file->private_data = (void *)kasprintf(GFP_KERNEL, "0x%p",
47807 +#ifdef CONFIG_GRKERNSEC_HIDESYM
47808 + NULL);
47809 +#else
47810 xen_store_interface);
47811 +#endif
47812 +
47813 if (!file->private_data)
47814 return -ENOMEM;
47815 return 0;
47816 diff --git a/fs/9p/vfs_addr.c b/fs/9p/vfs_addr.c
47817 index 0ad61c6..f198bd7 100644
47818 --- a/fs/9p/vfs_addr.c
47819 +++ b/fs/9p/vfs_addr.c
47820 @@ -185,7 +185,7 @@ static int v9fs_vfs_writepage_locked(struct page *page)
47821
47822 retval = v9fs_file_write_internal(inode,
47823 v9inode->writeback_fid,
47824 - (__force const char __user *)buffer,
47825 + (const char __force_user *)buffer,
47826 len, &offset, 0);
47827 if (retval > 0)
47828 retval = 0;
47829 diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
47830 index d86edc8..40ff2fb 100644
47831 --- a/fs/9p/vfs_inode.c
47832 +++ b/fs/9p/vfs_inode.c
47833 @@ -1314,7 +1314,7 @@ static void *v9fs_vfs_follow_link(struct dentry *dentry, struct nameidata *nd)
47834 void
47835 v9fs_vfs_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
47836 {
47837 - char *s = nd_get_link(nd);
47838 + const char *s = nd_get_link(nd);
47839
47840 p9_debug(P9_DEBUG_VFS, " %s %s\n",
47841 dentry->d_name.name, IS_ERR(s) ? "<error>" : s);
47842 diff --git a/fs/Kconfig.binfmt b/fs/Kconfig.binfmt
47843 index 0efd152..b5802ad 100644
47844 --- a/fs/Kconfig.binfmt
47845 +++ b/fs/Kconfig.binfmt
47846 @@ -89,7 +89,7 @@ config HAVE_AOUT
47847
47848 config BINFMT_AOUT
47849 tristate "Kernel support for a.out and ECOFF binaries"
47850 - depends on HAVE_AOUT
47851 + depends on HAVE_AOUT && BROKEN
47852 ---help---
47853 A.out (Assembler.OUTput) is a set of formats for libraries and
47854 executables used in the earliest versions of UNIX. Linux used
47855 diff --git a/fs/aio.c b/fs/aio.c
47856 index 1dc8786..d3b29e8 100644
47857 --- a/fs/aio.c
47858 +++ b/fs/aio.c
47859 @@ -111,7 +111,7 @@ static int aio_setup_ring(struct kioctx *ctx)
47860 size += sizeof(struct io_event) * nr_events;
47861 nr_pages = (size + PAGE_SIZE-1) >> PAGE_SHIFT;
47862
47863 - if (nr_pages < 0)
47864 + if (nr_pages <= 0)
47865 return -EINVAL;
47866
47867 nr_events = (PAGE_SIZE * nr_pages - sizeof(struct aio_ring)) / sizeof(struct io_event);
47868 @@ -1375,18 +1375,19 @@ static ssize_t aio_fsync(struct kiocb *iocb)
47869 static ssize_t aio_setup_vectored_rw(int type, struct kiocb *kiocb, bool compat)
47870 {
47871 ssize_t ret;
47872 + struct iovec iovstack;
47873
47874 #ifdef CONFIG_COMPAT
47875 if (compat)
47876 ret = compat_rw_copy_check_uvector(type,
47877 (struct compat_iovec __user *)kiocb->ki_buf,
47878 - kiocb->ki_nbytes, 1, &kiocb->ki_inline_vec,
47879 + kiocb->ki_nbytes, 1, &iovstack,
47880 &kiocb->ki_iovec);
47881 else
47882 #endif
47883 ret = rw_copy_check_uvector(type,
47884 (struct iovec __user *)kiocb->ki_buf,
47885 - kiocb->ki_nbytes, 1, &kiocb->ki_inline_vec,
47886 + kiocb->ki_nbytes, 1, &iovstack,
47887 &kiocb->ki_iovec);
47888 if (ret < 0)
47889 goto out;
47890 @@ -1395,6 +1396,10 @@ static ssize_t aio_setup_vectored_rw(int type, struct kiocb *kiocb, bool compat)
47891 if (ret < 0)
47892 goto out;
47893
47894 + if (kiocb->ki_iovec == &iovstack) {
47895 + kiocb->ki_inline_vec = iovstack;
47896 + kiocb->ki_iovec = &kiocb->ki_inline_vec;
47897 + }
47898 kiocb->ki_nr_segs = kiocb->ki_nbytes;
47899 kiocb->ki_cur_seg = 0;
47900 /* ki_nbytes/left now reflect bytes instead of segs */
47901 diff --git a/fs/attr.c b/fs/attr.c
47902 index 1449adb..a2038c2 100644
47903 --- a/fs/attr.c
47904 +++ b/fs/attr.c
47905 @@ -102,6 +102,7 @@ int inode_newsize_ok(const struct inode *inode, loff_t offset)
47906 unsigned long limit;
47907
47908 limit = rlimit(RLIMIT_FSIZE);
47909 + gr_learn_resource(current, RLIMIT_FSIZE, (unsigned long)offset, 1);
47910 if (limit != RLIM_INFINITY && offset > limit)
47911 goto out_sig;
47912 if (offset > inode->i_sb->s_maxbytes)
47913 diff --git a/fs/autofs4/waitq.c b/fs/autofs4/waitq.c
47914 index 3db70da..7aeec5b 100644
47915 --- a/fs/autofs4/waitq.c
47916 +++ b/fs/autofs4/waitq.c
47917 @@ -59,7 +59,7 @@ static int autofs4_write(struct autofs_sb_info *sbi,
47918 {
47919 unsigned long sigpipe, flags;
47920 mm_segment_t fs;
47921 - const char *data = (const char *)addr;
47922 + const char __user *data = (const char __force_user *)addr;
47923 ssize_t wr = 0;
47924
47925 sigpipe = sigismember(&current->pending.signal, SIGPIPE);
47926 @@ -346,6 +346,10 @@ static int validate_request(struct autofs_wait_queue **wait,
47927 return 1;
47928 }
47929
47930 +#ifdef CONFIG_GRKERNSEC_HIDESYM
47931 +static atomic_unchecked_t autofs_dummy_name_id = ATOMIC_INIT(0);
47932 +#endif
47933 +
47934 int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
47935 enum autofs_notify notify)
47936 {
47937 @@ -379,7 +383,12 @@ int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
47938
47939 /* If this is a direct mount request create a dummy name */
47940 if (IS_ROOT(dentry) && autofs_type_trigger(sbi->type))
47941 +#ifdef CONFIG_GRKERNSEC_HIDESYM
47942 + /* this name does get written to userland via autofs4_write() */
47943 + qstr.len = sprintf(name, "%08x", atomic_inc_return_unchecked(&autofs_dummy_name_id));
47944 +#else
47945 qstr.len = sprintf(name, "%p", dentry);
47946 +#endif
47947 else {
47948 qstr.len = autofs4_getpath(sbi, dentry, &name);
47949 if (!qstr.len) {
47950 diff --git a/fs/befs/endian.h b/fs/befs/endian.h
47951 index 2722387..c8dd2a7 100644
47952 --- a/fs/befs/endian.h
47953 +++ b/fs/befs/endian.h
47954 @@ -11,7 +11,7 @@
47955
47956 #include <asm/byteorder.h>
47957
47958 -static inline u64
47959 +static inline u64 __intentional_overflow(-1)
47960 fs64_to_cpu(const struct super_block *sb, fs64 n)
47961 {
47962 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
47963 @@ -29,7 +29,7 @@ cpu_to_fs64(const struct super_block *sb, u64 n)
47964 return (__force fs64)cpu_to_be64(n);
47965 }
47966
47967 -static inline u32
47968 +static inline u32 __intentional_overflow(-1)
47969 fs32_to_cpu(const struct super_block *sb, fs32 n)
47970 {
47971 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
47972 diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c
47973 index 8615ee8..388ed68 100644
47974 --- a/fs/befs/linuxvfs.c
47975 +++ b/fs/befs/linuxvfs.c
47976 @@ -510,7 +510,7 @@ static void befs_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
47977 {
47978 befs_inode_info *befs_ino = BEFS_I(dentry->d_inode);
47979 if (befs_ino->i_flags & BEFS_LONG_SYMLINK) {
47980 - char *link = nd_get_link(nd);
47981 + const char *link = nd_get_link(nd);
47982 if (!IS_ERR(link))
47983 kfree(link);
47984 }
47985 diff --git a/fs/binfmt_aout.c b/fs/binfmt_aout.c
47986 index bbc8f88..7c7ac97 100644
47987 --- a/fs/binfmt_aout.c
47988 +++ b/fs/binfmt_aout.c
47989 @@ -16,6 +16,7 @@
47990 #include <linux/string.h>
47991 #include <linux/fs.h>
47992 #include <linux/file.h>
47993 +#include <linux/security.h>
47994 #include <linux/stat.h>
47995 #include <linux/fcntl.h>
47996 #include <linux/ptrace.h>
47997 @@ -59,6 +60,8 @@ static int aout_core_dump(struct coredump_params *cprm)
47998 #endif
47999 # define START_STACK(u) ((void __user *)u.start_stack)
48000
48001 + memset(&dump, 0, sizeof(dump));
48002 +
48003 fs = get_fs();
48004 set_fs(KERNEL_DS);
48005 has_dumped = 1;
48006 @@ -70,10 +73,12 @@ static int aout_core_dump(struct coredump_params *cprm)
48007
48008 /* If the size of the dump file exceeds the rlimit, then see what would happen
48009 if we wrote the stack, but not the data area. */
48010 + gr_learn_resource(current, RLIMIT_CORE, (dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE, 1);
48011 if ((dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE > cprm->limit)
48012 dump.u_dsize = 0;
48013
48014 /* Make sure we have enough room to write the stack and data areas. */
48015 + gr_learn_resource(current, RLIMIT_CORE, (dump.u_ssize + 1) * PAGE_SIZE, 1);
48016 if ((dump.u_ssize + 1) * PAGE_SIZE > cprm->limit)
48017 dump.u_ssize = 0;
48018
48019 @@ -234,6 +239,8 @@ static int load_aout_binary(struct linux_binprm * bprm)
48020 rlim = rlimit(RLIMIT_DATA);
48021 if (rlim >= RLIM_INFINITY)
48022 rlim = ~0;
48023 +
48024 + gr_learn_resource(current, RLIMIT_DATA, ex.a_data + ex.a_bss, 1);
48025 if (ex.a_data + ex.a_bss > rlim)
48026 return -ENOMEM;
48027
48028 @@ -268,6 +275,27 @@ static int load_aout_binary(struct linux_binprm * bprm)
48029
48030 install_exec_creds(bprm);
48031
48032 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
48033 + current->mm->pax_flags = 0UL;
48034 +#endif
48035 +
48036 +#ifdef CONFIG_PAX_PAGEEXEC
48037 + if (!(N_FLAGS(ex) & F_PAX_PAGEEXEC)) {
48038 + current->mm->pax_flags |= MF_PAX_PAGEEXEC;
48039 +
48040 +#ifdef CONFIG_PAX_EMUTRAMP
48041 + if (N_FLAGS(ex) & F_PAX_EMUTRAMP)
48042 + current->mm->pax_flags |= MF_PAX_EMUTRAMP;
48043 +#endif
48044 +
48045 +#ifdef CONFIG_PAX_MPROTECT
48046 + if (!(N_FLAGS(ex) & F_PAX_MPROTECT))
48047 + current->mm->pax_flags |= MF_PAX_MPROTECT;
48048 +#endif
48049 +
48050 + }
48051 +#endif
48052 +
48053 if (N_MAGIC(ex) == OMAGIC) {
48054 unsigned long text_addr, map_size;
48055 loff_t pos;
48056 @@ -333,7 +361,7 @@ static int load_aout_binary(struct linux_binprm * bprm)
48057 }
48058
48059 error = vm_mmap(bprm->file, N_DATADDR(ex), ex.a_data,
48060 - PROT_READ | PROT_WRITE | PROT_EXEC,
48061 + PROT_READ | PROT_WRITE,
48062 MAP_FIXED | MAP_PRIVATE | MAP_DENYWRITE | MAP_EXECUTABLE,
48063 fd_offset + ex.a_text);
48064 if (error != N_DATADDR(ex)) {
48065 diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
48066 index 86af964..5d53bf6 100644
48067 --- a/fs/binfmt_elf.c
48068 +++ b/fs/binfmt_elf.c
48069 @@ -34,6 +34,7 @@
48070 #include <linux/utsname.h>
48071 #include <linux/coredump.h>
48072 #include <linux/sched.h>
48073 +#include <linux/xattr.h>
48074 #include <asm/uaccess.h>
48075 #include <asm/param.h>
48076 #include <asm/page.h>
48077 @@ -60,6 +61,10 @@ static int elf_core_dump(struct coredump_params *cprm);
48078 #define elf_core_dump NULL
48079 #endif
48080
48081 +#ifdef CONFIG_PAX_MPROTECT
48082 +static void elf_handle_mprotect(struct vm_area_struct *vma, unsigned long newflags);
48083 +#endif
48084 +
48085 #if ELF_EXEC_PAGESIZE > PAGE_SIZE
48086 #define ELF_MIN_ALIGN ELF_EXEC_PAGESIZE
48087 #else
48088 @@ -79,6 +84,11 @@ static struct linux_binfmt elf_format = {
48089 .load_binary = load_elf_binary,
48090 .load_shlib = load_elf_library,
48091 .core_dump = elf_core_dump,
48092 +
48093 +#ifdef CONFIG_PAX_MPROTECT
48094 + .handle_mprotect= elf_handle_mprotect,
48095 +#endif
48096 +
48097 .min_coredump = ELF_EXEC_PAGESIZE,
48098 };
48099
48100 @@ -86,6 +96,8 @@ static struct linux_binfmt elf_format = {
48101
48102 static int set_brk(unsigned long start, unsigned long end)
48103 {
48104 + unsigned long e = end;
48105 +
48106 start = ELF_PAGEALIGN(start);
48107 end = ELF_PAGEALIGN(end);
48108 if (end > start) {
48109 @@ -94,7 +106,7 @@ static int set_brk(unsigned long start, unsigned long end)
48110 if (BAD_ADDR(addr))
48111 return addr;
48112 }
48113 - current->mm->start_brk = current->mm->brk = end;
48114 + current->mm->start_brk = current->mm->brk = e;
48115 return 0;
48116 }
48117
48118 @@ -155,12 +167,13 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
48119 elf_addr_t __user *u_rand_bytes;
48120 const char *k_platform = ELF_PLATFORM;
48121 const char *k_base_platform = ELF_BASE_PLATFORM;
48122 - unsigned char k_rand_bytes[16];
48123 + u32 k_rand_bytes[4];
48124 int items;
48125 elf_addr_t *elf_info;
48126 int ei_index = 0;
48127 const struct cred *cred = current_cred();
48128 struct vm_area_struct *vma;
48129 + unsigned long saved_auxv[AT_VECTOR_SIZE];
48130
48131 /*
48132 * In some cases (e.g. Hyper-Threading), we want to avoid L1
48133 @@ -202,8 +215,12 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
48134 * Generate 16 random bytes for userspace PRNG seeding.
48135 */
48136 get_random_bytes(k_rand_bytes, sizeof(k_rand_bytes));
48137 - u_rand_bytes = (elf_addr_t __user *)
48138 - STACK_ALLOC(p, sizeof(k_rand_bytes));
48139 + srandom32(k_rand_bytes[0] ^ random32());
48140 + srandom32(k_rand_bytes[1] ^ random32());
48141 + srandom32(k_rand_bytes[2] ^ random32());
48142 + srandom32(k_rand_bytes[3] ^ random32());
48143 + p = STACK_ROUND(p, sizeof(k_rand_bytes));
48144 + u_rand_bytes = (elf_addr_t __user *) p;
48145 if (__copy_to_user(u_rand_bytes, k_rand_bytes, sizeof(k_rand_bytes)))
48146 return -EFAULT;
48147
48148 @@ -315,9 +332,11 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
48149 return -EFAULT;
48150 current->mm->env_end = p;
48151
48152 + memcpy(saved_auxv, elf_info, ei_index * sizeof(elf_addr_t));
48153 +
48154 /* Put the elf_info on the stack in the right place. */
48155 sp = (elf_addr_t __user *)envp + 1;
48156 - if (copy_to_user(sp, elf_info, ei_index * sizeof(elf_addr_t)))
48157 + if (copy_to_user(sp, saved_auxv, ei_index * sizeof(elf_addr_t)))
48158 return -EFAULT;
48159 return 0;
48160 }
48161 @@ -385,15 +404,14 @@ static unsigned long total_mapping_size(struct elf_phdr *cmds, int nr)
48162 an ELF header */
48163
48164 static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
48165 - struct file *interpreter, unsigned long *interp_map_addr,
48166 - unsigned long no_base)
48167 + struct file *interpreter, unsigned long no_base)
48168 {
48169 struct elf_phdr *elf_phdata;
48170 struct elf_phdr *eppnt;
48171 - unsigned long load_addr = 0;
48172 + unsigned long load_addr = 0, pax_task_size = TASK_SIZE;
48173 int load_addr_set = 0;
48174 unsigned long last_bss = 0, elf_bss = 0;
48175 - unsigned long error = ~0UL;
48176 + unsigned long error = -EINVAL;
48177 unsigned long total_size;
48178 int retval, i, size;
48179
48180 @@ -439,6 +457,11 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
48181 goto out_close;
48182 }
48183
48184 +#ifdef CONFIG_PAX_SEGMEXEC
48185 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC)
48186 + pax_task_size = SEGMEXEC_TASK_SIZE;
48187 +#endif
48188 +
48189 eppnt = elf_phdata;
48190 for (i = 0; i < interp_elf_ex->e_phnum; i++, eppnt++) {
48191 if (eppnt->p_type == PT_LOAD) {
48192 @@ -462,8 +485,6 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
48193 map_addr = elf_map(interpreter, load_addr + vaddr,
48194 eppnt, elf_prot, elf_type, total_size);
48195 total_size = 0;
48196 - if (!*interp_map_addr)
48197 - *interp_map_addr = map_addr;
48198 error = map_addr;
48199 if (BAD_ADDR(map_addr))
48200 goto out_close;
48201 @@ -482,8 +503,8 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
48202 k = load_addr + eppnt->p_vaddr;
48203 if (BAD_ADDR(k) ||
48204 eppnt->p_filesz > eppnt->p_memsz ||
48205 - eppnt->p_memsz > TASK_SIZE ||
48206 - TASK_SIZE - eppnt->p_memsz < k) {
48207 + eppnt->p_memsz > pax_task_size ||
48208 + pax_task_size - eppnt->p_memsz < k) {
48209 error = -ENOMEM;
48210 goto out_close;
48211 }
48212 @@ -535,6 +556,315 @@ out:
48213 return error;
48214 }
48215
48216 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
48217 +#ifdef CONFIG_PAX_SOFTMODE
48218 +static unsigned long pax_parse_pt_pax_softmode(const struct elf_phdr * const elf_phdata)
48219 +{
48220 + unsigned long pax_flags = 0UL;
48221 +
48222 +#ifdef CONFIG_PAX_PAGEEXEC
48223 + if (elf_phdata->p_flags & PF_PAGEEXEC)
48224 + pax_flags |= MF_PAX_PAGEEXEC;
48225 +#endif
48226 +
48227 +#ifdef CONFIG_PAX_SEGMEXEC
48228 + if (elf_phdata->p_flags & PF_SEGMEXEC)
48229 + pax_flags |= MF_PAX_SEGMEXEC;
48230 +#endif
48231 +
48232 +#ifdef CONFIG_PAX_EMUTRAMP
48233 + if ((elf_phdata->p_flags & PF_EMUTRAMP) && (pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)))
48234 + pax_flags |= MF_PAX_EMUTRAMP;
48235 +#endif
48236 +
48237 +#ifdef CONFIG_PAX_MPROTECT
48238 + if (elf_phdata->p_flags & PF_MPROTECT)
48239 + pax_flags |= MF_PAX_MPROTECT;
48240 +#endif
48241 +
48242 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
48243 + if (randomize_va_space && (elf_phdata->p_flags & PF_RANDMMAP))
48244 + pax_flags |= MF_PAX_RANDMMAP;
48245 +#endif
48246 +
48247 + return pax_flags;
48248 +}
48249 +#endif
48250 +
48251 +static unsigned long pax_parse_pt_pax_hardmode(const struct elf_phdr * const elf_phdata)
48252 +{
48253 + unsigned long pax_flags = 0UL;
48254 +
48255 +#ifdef CONFIG_PAX_PAGEEXEC
48256 + if (!(elf_phdata->p_flags & PF_NOPAGEEXEC))
48257 + pax_flags |= MF_PAX_PAGEEXEC;
48258 +#endif
48259 +
48260 +#ifdef CONFIG_PAX_SEGMEXEC
48261 + if (!(elf_phdata->p_flags & PF_NOSEGMEXEC))
48262 + pax_flags |= MF_PAX_SEGMEXEC;
48263 +#endif
48264 +
48265 +#ifdef CONFIG_PAX_EMUTRAMP
48266 + if (!(elf_phdata->p_flags & PF_NOEMUTRAMP))
48267 + pax_flags |= MF_PAX_EMUTRAMP;
48268 +#endif
48269 +
48270 +#ifdef CONFIG_PAX_MPROTECT
48271 + if (!(elf_phdata->p_flags & PF_NOMPROTECT))
48272 + pax_flags |= MF_PAX_MPROTECT;
48273 +#endif
48274 +
48275 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
48276 + if (randomize_va_space && !(elf_phdata->p_flags & PF_NORANDMMAP))
48277 + pax_flags |= MF_PAX_RANDMMAP;
48278 +#endif
48279 +
48280 + return pax_flags;
48281 +}
48282 +#endif
48283 +
48284 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
48285 +#ifdef CONFIG_PAX_SOFTMODE
48286 +static unsigned long pax_parse_xattr_pax_softmode(unsigned long pax_flags_softmode)
48287 +{
48288 + unsigned long pax_flags = 0UL;
48289 +
48290 +#ifdef CONFIG_PAX_PAGEEXEC
48291 + if (pax_flags_softmode & MF_PAX_PAGEEXEC)
48292 + pax_flags |= MF_PAX_PAGEEXEC;
48293 +#endif
48294 +
48295 +#ifdef CONFIG_PAX_SEGMEXEC
48296 + if (pax_flags_softmode & MF_PAX_SEGMEXEC)
48297 + pax_flags |= MF_PAX_SEGMEXEC;
48298 +#endif
48299 +
48300 +#ifdef CONFIG_PAX_EMUTRAMP
48301 + if ((pax_flags_softmode & MF_PAX_EMUTRAMP) && (pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)))
48302 + pax_flags |= MF_PAX_EMUTRAMP;
48303 +#endif
48304 +
48305 +#ifdef CONFIG_PAX_MPROTECT
48306 + if (pax_flags_softmode & MF_PAX_MPROTECT)
48307 + pax_flags |= MF_PAX_MPROTECT;
48308 +#endif
48309 +
48310 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
48311 + if (randomize_va_space && (pax_flags_softmode & MF_PAX_RANDMMAP))
48312 + pax_flags |= MF_PAX_RANDMMAP;
48313 +#endif
48314 +
48315 + return pax_flags;
48316 +}
48317 +#endif
48318 +
48319 +static unsigned long pax_parse_xattr_pax_hardmode(unsigned long pax_flags_hardmode)
48320 +{
48321 + unsigned long pax_flags = 0UL;
48322 +
48323 +#ifdef CONFIG_PAX_PAGEEXEC
48324 + if (!(pax_flags_hardmode & MF_PAX_PAGEEXEC))
48325 + pax_flags |= MF_PAX_PAGEEXEC;
48326 +#endif
48327 +
48328 +#ifdef CONFIG_PAX_SEGMEXEC
48329 + if (!(pax_flags_hardmode & MF_PAX_SEGMEXEC))
48330 + pax_flags |= MF_PAX_SEGMEXEC;
48331 +#endif
48332 +
48333 +#ifdef CONFIG_PAX_EMUTRAMP
48334 + if (!(pax_flags_hardmode & MF_PAX_EMUTRAMP))
48335 + pax_flags |= MF_PAX_EMUTRAMP;
48336 +#endif
48337 +
48338 +#ifdef CONFIG_PAX_MPROTECT
48339 + if (!(pax_flags_hardmode & MF_PAX_MPROTECT))
48340 + pax_flags |= MF_PAX_MPROTECT;
48341 +#endif
48342 +
48343 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
48344 + if (randomize_va_space && !(pax_flags_hardmode & MF_PAX_RANDMMAP))
48345 + pax_flags |= MF_PAX_RANDMMAP;
48346 +#endif
48347 +
48348 + return pax_flags;
48349 +}
48350 +#endif
48351 +
48352 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
48353 +static unsigned long pax_parse_ei_pax(const struct elfhdr * const elf_ex)
48354 +{
48355 + unsigned long pax_flags = 0UL;
48356 +
48357 +#ifdef CONFIG_PAX_EI_PAX
48358 +
48359 +#ifdef CONFIG_PAX_PAGEEXEC
48360 + if (!(elf_ex->e_ident[EI_PAX] & EF_PAX_PAGEEXEC))
48361 + pax_flags |= MF_PAX_PAGEEXEC;
48362 +#endif
48363 +
48364 +#ifdef CONFIG_PAX_SEGMEXEC
48365 + if (!(elf_ex->e_ident[EI_PAX] & EF_PAX_SEGMEXEC))
48366 + pax_flags |= MF_PAX_SEGMEXEC;
48367 +#endif
48368 +
48369 +#ifdef CONFIG_PAX_EMUTRAMP
48370 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) && (elf_ex->e_ident[EI_PAX] & EF_PAX_EMUTRAMP))
48371 + pax_flags |= MF_PAX_EMUTRAMP;
48372 +#endif
48373 +
48374 +#ifdef CONFIG_PAX_MPROTECT
48375 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) && !(elf_ex->e_ident[EI_PAX] & EF_PAX_MPROTECT))
48376 + pax_flags |= MF_PAX_MPROTECT;
48377 +#endif
48378 +
48379 +#ifdef CONFIG_PAX_ASLR
48380 + if (randomize_va_space && !(elf_ex->e_ident[EI_PAX] & EF_PAX_RANDMMAP))
48381 + pax_flags |= MF_PAX_RANDMMAP;
48382 +#endif
48383 +
48384 +#else
48385 +
48386 +#ifdef CONFIG_PAX_PAGEEXEC
48387 + pax_flags |= MF_PAX_PAGEEXEC;
48388 +#endif
48389 +
48390 +#ifdef CONFIG_PAX_SEGMEXEC
48391 + pax_flags |= MF_PAX_SEGMEXEC;
48392 +#endif
48393 +
48394 +#ifdef CONFIG_PAX_MPROTECT
48395 + pax_flags |= MF_PAX_MPROTECT;
48396 +#endif
48397 +
48398 +#ifdef CONFIG_PAX_RANDMMAP
48399 + if (randomize_va_space)
48400 + pax_flags |= MF_PAX_RANDMMAP;
48401 +#endif
48402 +
48403 +#endif
48404 +
48405 + return pax_flags;
48406 +}
48407 +
48408 +static unsigned long pax_parse_pt_pax(const struct elfhdr * const elf_ex, const struct elf_phdr * const elf_phdata)
48409 +{
48410 +
48411 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
48412 + unsigned long i;
48413 +
48414 + for (i = 0UL; i < elf_ex->e_phnum; i++)
48415 + if (elf_phdata[i].p_type == PT_PAX_FLAGS) {
48416 + if (((elf_phdata[i].p_flags & PF_PAGEEXEC) && (elf_phdata[i].p_flags & PF_NOPAGEEXEC)) ||
48417 + ((elf_phdata[i].p_flags & PF_SEGMEXEC) && (elf_phdata[i].p_flags & PF_NOSEGMEXEC)) ||
48418 + ((elf_phdata[i].p_flags & PF_EMUTRAMP) && (elf_phdata[i].p_flags & PF_NOEMUTRAMP)) ||
48419 + ((elf_phdata[i].p_flags & PF_MPROTECT) && (elf_phdata[i].p_flags & PF_NOMPROTECT)) ||
48420 + ((elf_phdata[i].p_flags & PF_RANDMMAP) && (elf_phdata[i].p_flags & PF_NORANDMMAP)))
48421 + return ~0UL;
48422 +
48423 +#ifdef CONFIG_PAX_SOFTMODE
48424 + if (pax_softmode)
48425 + return pax_parse_pt_pax_softmode(&elf_phdata[i]);
48426 + else
48427 +#endif
48428 +
48429 + return pax_parse_pt_pax_hardmode(&elf_phdata[i]);
48430 + break;
48431 + }
48432 +#endif
48433 +
48434 + return ~0UL;
48435 +}
48436 +
48437 +static unsigned long pax_parse_xattr_pax(struct file * const file)
48438 +{
48439 +
48440 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
48441 + ssize_t xattr_size, i;
48442 + unsigned char xattr_value[sizeof("pemrs") - 1];
48443 + unsigned long pax_flags_hardmode = 0UL, pax_flags_softmode = 0UL;
48444 +
48445 + xattr_size = pax_getxattr(file->f_path.dentry, xattr_value, sizeof xattr_value);
48446 + if (xattr_size <= 0 || xattr_size > sizeof xattr_value)
48447 + return ~0UL;
48448 +
48449 + for (i = 0; i < xattr_size; i++)
48450 + switch (xattr_value[i]) {
48451 + default:
48452 + return ~0UL;
48453 +
48454 +#define parse_flag(option1, option2, flag) \
48455 + case option1: \
48456 + if (pax_flags_hardmode & MF_PAX_##flag) \
48457 + return ~0UL; \
48458 + pax_flags_hardmode |= MF_PAX_##flag; \
48459 + break; \
48460 + case option2: \
48461 + if (pax_flags_softmode & MF_PAX_##flag) \
48462 + return ~0UL; \
48463 + pax_flags_softmode |= MF_PAX_##flag; \
48464 + break;
48465 +
48466 + parse_flag('p', 'P', PAGEEXEC);
48467 + parse_flag('e', 'E', EMUTRAMP);
48468 + parse_flag('m', 'M', MPROTECT);
48469 + parse_flag('r', 'R', RANDMMAP);
48470 + parse_flag('s', 'S', SEGMEXEC);
48471 +
48472 +#undef parse_flag
48473 + }
48474 +
48475 + if (pax_flags_hardmode & pax_flags_softmode)
48476 + return ~0UL;
48477 +
48478 +#ifdef CONFIG_PAX_SOFTMODE
48479 + if (pax_softmode)
48480 + return pax_parse_xattr_pax_softmode(pax_flags_softmode);
48481 + else
48482 +#endif
48483 +
48484 + return pax_parse_xattr_pax_hardmode(pax_flags_hardmode);
48485 +#else
48486 + return ~0UL;
48487 +#endif
48488 +
48489 +}
48490 +
48491 +static long pax_parse_pax_flags(const struct elfhdr * const elf_ex, const struct elf_phdr * const elf_phdata, struct file * const file)
48492 +{
48493 + unsigned long pax_flags, pt_pax_flags, xattr_pax_flags;
48494 +
48495 + pax_flags = pax_parse_ei_pax(elf_ex);
48496 + pt_pax_flags = pax_parse_pt_pax(elf_ex, elf_phdata);
48497 + xattr_pax_flags = pax_parse_xattr_pax(file);
48498 +
48499 + if (pt_pax_flags == ~0UL)
48500 + pt_pax_flags = xattr_pax_flags;
48501 + else if (xattr_pax_flags == ~0UL)
48502 + xattr_pax_flags = pt_pax_flags;
48503 + if (pt_pax_flags != xattr_pax_flags)
48504 + return -EINVAL;
48505 + if (pt_pax_flags != ~0UL)
48506 + pax_flags = pt_pax_flags;
48507 +
48508 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_PAX_SEGMEXEC)
48509 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) == (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
48510 + if ((__supported_pte_mask & _PAGE_NX))
48511 + pax_flags &= ~MF_PAX_SEGMEXEC;
48512 + else
48513 + pax_flags &= ~MF_PAX_PAGEEXEC;
48514 + }
48515 +#endif
48516 +
48517 + if (0 > pax_check_flags(&pax_flags))
48518 + return -EINVAL;
48519 +
48520 + current->mm->pax_flags = pax_flags;
48521 + return 0;
48522 +}
48523 +#endif
48524 +
48525 /*
48526 * These are the functions used to load ELF style executables and shared
48527 * libraries. There is no binary dependent code anywhere else.
48528 @@ -551,6 +881,11 @@ static unsigned long randomize_stack_top(unsigned long stack_top)
48529 {
48530 unsigned int random_variable = 0;
48531
48532 +#ifdef CONFIG_PAX_RANDUSTACK
48533 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
48534 + return stack_top - current->mm->delta_stack;
48535 +#endif
48536 +
48537 if ((current->flags & PF_RANDOMIZE) &&
48538 !(current->personality & ADDR_NO_RANDOMIZE)) {
48539 random_variable = get_random_int() & STACK_RND_MASK;
48540 @@ -569,7 +904,7 @@ static int load_elf_binary(struct linux_binprm *bprm)
48541 unsigned long load_addr = 0, load_bias = 0;
48542 int load_addr_set = 0;
48543 char * elf_interpreter = NULL;
48544 - unsigned long error;
48545 + unsigned long error = 0;
48546 struct elf_phdr *elf_ppnt, *elf_phdata;
48547 unsigned long elf_bss, elf_brk;
48548 int retval, i;
48549 @@ -579,12 +914,12 @@ static int load_elf_binary(struct linux_binprm *bprm)
48550 unsigned long start_code, end_code, start_data, end_data;
48551 unsigned long reloc_func_desc __maybe_unused = 0;
48552 int executable_stack = EXSTACK_DEFAULT;
48553 - unsigned long def_flags = 0;
48554 struct pt_regs *regs = current_pt_regs();
48555 struct {
48556 struct elfhdr elf_ex;
48557 struct elfhdr interp_elf_ex;
48558 } *loc;
48559 + unsigned long pax_task_size = TASK_SIZE;
48560
48561 loc = kmalloc(sizeof(*loc), GFP_KERNEL);
48562 if (!loc) {
48563 @@ -720,11 +1055,81 @@ static int load_elf_binary(struct linux_binprm *bprm)
48564 goto out_free_dentry;
48565
48566 /* OK, This is the point of no return */
48567 - current->mm->def_flags = def_flags;
48568 +
48569 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
48570 + current->mm->pax_flags = 0UL;
48571 +#endif
48572 +
48573 +#ifdef CONFIG_PAX_DLRESOLVE
48574 + current->mm->call_dl_resolve = 0UL;
48575 +#endif
48576 +
48577 +#if defined(CONFIG_PPC32) && defined(CONFIG_PAX_EMUSIGRT)
48578 + current->mm->call_syscall = 0UL;
48579 +#endif
48580 +
48581 +#ifdef CONFIG_PAX_ASLR
48582 + current->mm->delta_mmap = 0UL;
48583 + current->mm->delta_stack = 0UL;
48584 +#endif
48585 +
48586 + current->mm->def_flags = 0;
48587 +
48588 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
48589 + if (0 > pax_parse_pax_flags(&loc->elf_ex, elf_phdata, bprm->file)) {
48590 + send_sig(SIGKILL, current, 0);
48591 + goto out_free_dentry;
48592 + }
48593 +#endif
48594 +
48595 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
48596 + pax_set_initial_flags(bprm);
48597 +#elif defined(CONFIG_PAX_HOOK_ACL_FLAGS)
48598 + if (pax_set_initial_flags_func)
48599 + (pax_set_initial_flags_func)(bprm);
48600 +#endif
48601 +
48602 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
48603 + if ((current->mm->pax_flags & MF_PAX_PAGEEXEC) && !(__supported_pte_mask & _PAGE_NX)) {
48604 + current->mm->context.user_cs_limit = PAGE_SIZE;
48605 + current->mm->def_flags |= VM_PAGEEXEC | VM_NOHUGEPAGE;
48606 + }
48607 +#endif
48608 +
48609 +#ifdef CONFIG_PAX_SEGMEXEC
48610 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
48611 + current->mm->context.user_cs_base = SEGMEXEC_TASK_SIZE;
48612 + current->mm->context.user_cs_limit = TASK_SIZE-SEGMEXEC_TASK_SIZE;
48613 + pax_task_size = SEGMEXEC_TASK_SIZE;
48614 + current->mm->def_flags |= VM_NOHUGEPAGE;
48615 + }
48616 +#endif
48617 +
48618 +#if defined(CONFIG_ARCH_TRACK_EXEC_LIMIT) || defined(CONFIG_PAX_SEGMEXEC)
48619 + if (current->mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
48620 + set_user_cs(current->mm->context.user_cs_base, current->mm->context.user_cs_limit, get_cpu());
48621 + put_cpu();
48622 + }
48623 +#endif
48624
48625 /* Do this immediately, since STACK_TOP as used in setup_arg_pages
48626 may depend on the personality. */
48627 SET_PERSONALITY(loc->elf_ex);
48628 +
48629 +#ifdef CONFIG_PAX_ASLR
48630 + if (current->mm->pax_flags & MF_PAX_RANDMMAP) {
48631 + current->mm->delta_mmap = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN)-1)) << PAGE_SHIFT;
48632 + current->mm->delta_stack = (pax_get_random_long() & ((1UL << PAX_DELTA_STACK_LEN)-1)) << PAGE_SHIFT;
48633 + }
48634 +#endif
48635 +
48636 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
48637 + if (current->mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
48638 + executable_stack = EXSTACK_DISABLE_X;
48639 + current->personality &= ~READ_IMPLIES_EXEC;
48640 + } else
48641 +#endif
48642 +
48643 if (elf_read_implies_exec(loc->elf_ex, executable_stack))
48644 current->personality |= READ_IMPLIES_EXEC;
48645
48646 @@ -815,6 +1220,20 @@ static int load_elf_binary(struct linux_binprm *bprm)
48647 #else
48648 load_bias = ELF_PAGESTART(ELF_ET_DYN_BASE - vaddr);
48649 #endif
48650 +
48651 +#ifdef CONFIG_PAX_RANDMMAP
48652 + /* PaX: randomize base address at the default exe base if requested */
48653 + if ((current->mm->pax_flags & MF_PAX_RANDMMAP) && elf_interpreter) {
48654 +#ifdef CONFIG_SPARC64
48655 + load_bias = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN) - 1)) << (PAGE_SHIFT+1);
48656 +#else
48657 + load_bias = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN) - 1)) << PAGE_SHIFT;
48658 +#endif
48659 + load_bias = ELF_PAGESTART(PAX_ELF_ET_DYN_BASE - vaddr + load_bias);
48660 + elf_flags |= MAP_FIXED;
48661 + }
48662 +#endif
48663 +
48664 }
48665
48666 error = elf_map(bprm->file, load_bias + vaddr, elf_ppnt,
48667 @@ -847,9 +1266,9 @@ static int load_elf_binary(struct linux_binprm *bprm)
48668 * allowed task size. Note that p_filesz must always be
48669 * <= p_memsz so it is only necessary to check p_memsz.
48670 */
48671 - if (BAD_ADDR(k) || elf_ppnt->p_filesz > elf_ppnt->p_memsz ||
48672 - elf_ppnt->p_memsz > TASK_SIZE ||
48673 - TASK_SIZE - elf_ppnt->p_memsz < k) {
48674 + if (k >= pax_task_size || elf_ppnt->p_filesz > elf_ppnt->p_memsz ||
48675 + elf_ppnt->p_memsz > pax_task_size ||
48676 + pax_task_size - elf_ppnt->p_memsz < k) {
48677 /* set_brk can never work. Avoid overflows. */
48678 send_sig(SIGKILL, current, 0);
48679 retval = -EINVAL;
48680 @@ -888,17 +1307,45 @@ static int load_elf_binary(struct linux_binprm *bprm)
48681 goto out_free_dentry;
48682 }
48683 if (likely(elf_bss != elf_brk) && unlikely(padzero(elf_bss))) {
48684 - send_sig(SIGSEGV, current, 0);
48685 - retval = -EFAULT; /* Nobody gets to see this, but.. */
48686 - goto out_free_dentry;
48687 + /*
48688 + * This bss-zeroing can fail if the ELF
48689 + * file specifies odd protections. So
48690 + * we don't check the return value
48691 + */
48692 }
48693
48694 +#ifdef CONFIG_PAX_RANDMMAP
48695 + if (current->mm->pax_flags & MF_PAX_RANDMMAP) {
48696 + unsigned long start, size, flags;
48697 + vm_flags_t vm_flags;
48698 +
48699 + start = ELF_PAGEALIGN(elf_brk);
48700 + size = PAGE_SIZE + ((pax_get_random_long() & ((1UL << 22) - 1UL)) << 4);
48701 + flags = MAP_FIXED | MAP_PRIVATE;
48702 + vm_flags = VM_DONTEXPAND | VM_DONTDUMP;
48703 +
48704 + down_write(&current->mm->mmap_sem);
48705 + start = get_unmapped_area(NULL, start, PAGE_ALIGN(size), 0, flags);
48706 + retval = -ENOMEM;
48707 + if (!IS_ERR_VALUE(start) && !find_vma_intersection(current->mm, start, start + size + PAGE_SIZE)) {
48708 +// if (current->personality & ADDR_NO_RANDOMIZE)
48709 +// vm_flags |= VM_READ | VM_MAYREAD;
48710 + start = mmap_region(NULL, start, PAGE_ALIGN(size), vm_flags, 0);
48711 + retval = IS_ERR_VALUE(start) ? start : 0;
48712 + }
48713 + up_write(&current->mm->mmap_sem);
48714 + if (retval == 0)
48715 + retval = set_brk(start + size, start + size + PAGE_SIZE);
48716 + if (retval < 0) {
48717 + send_sig(SIGKILL, current, 0);
48718 + goto out_free_dentry;
48719 + }
48720 + }
48721 +#endif
48722 +
48723 if (elf_interpreter) {
48724 - unsigned long interp_map_addr = 0;
48725 -
48726 elf_entry = load_elf_interp(&loc->interp_elf_ex,
48727 interpreter,
48728 - &interp_map_addr,
48729 load_bias);
48730 if (!IS_ERR((void *)elf_entry)) {
48731 /*
48732 @@ -1120,7 +1567,7 @@ static bool always_dump_vma(struct vm_area_struct *vma)
48733 * Decide what to dump of a segment, part, all or none.
48734 */
48735 static unsigned long vma_dump_size(struct vm_area_struct *vma,
48736 - unsigned long mm_flags)
48737 + unsigned long mm_flags, long signr)
48738 {
48739 #define FILTER(type) (mm_flags & (1UL << MMF_DUMP_##type))
48740
48741 @@ -1158,7 +1605,7 @@ static unsigned long vma_dump_size(struct vm_area_struct *vma,
48742 if (vma->vm_file == NULL)
48743 return 0;
48744
48745 - if (FILTER(MAPPED_PRIVATE))
48746 + if (signr == SIGKILL || FILTER(MAPPED_PRIVATE))
48747 goto whole;
48748
48749 /*
48750 @@ -1383,9 +1830,9 @@ static void fill_auxv_note(struct memelfnote *note, struct mm_struct *mm)
48751 {
48752 elf_addr_t *auxv = (elf_addr_t *) mm->saved_auxv;
48753 int i = 0;
48754 - do
48755 + do {
48756 i += 2;
48757 - while (auxv[i - 2] != AT_NULL);
48758 + } while (auxv[i - 2] != AT_NULL);
48759 fill_note(note, "CORE", NT_AUXV, i * sizeof(elf_addr_t), auxv);
48760 }
48761
48762 @@ -1394,7 +1841,7 @@ static void fill_siginfo_note(struct memelfnote *note, user_siginfo_t *csigdata,
48763 {
48764 mm_segment_t old_fs = get_fs();
48765 set_fs(KERNEL_DS);
48766 - copy_siginfo_to_user((user_siginfo_t __user *) csigdata, siginfo);
48767 + copy_siginfo_to_user((user_siginfo_t __force_user *) csigdata, siginfo);
48768 set_fs(old_fs);
48769 fill_note(note, "CORE", NT_SIGINFO, sizeof(*csigdata), csigdata);
48770 }
48771 @@ -2015,14 +2462,14 @@ static void fill_extnum_info(struct elfhdr *elf, struct elf_shdr *shdr4extnum,
48772 }
48773
48774 static size_t elf_core_vma_data_size(struct vm_area_struct *gate_vma,
48775 - unsigned long mm_flags)
48776 + struct coredump_params *cprm)
48777 {
48778 struct vm_area_struct *vma;
48779 size_t size = 0;
48780
48781 for (vma = first_vma(current, gate_vma); vma != NULL;
48782 vma = next_vma(vma, gate_vma))
48783 - size += vma_dump_size(vma, mm_flags);
48784 + size += vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
48785 return size;
48786 }
48787
48788 @@ -2116,7 +2563,7 @@ static int elf_core_dump(struct coredump_params *cprm)
48789
48790 dataoff = offset = roundup(offset, ELF_EXEC_PAGESIZE);
48791
48792 - offset += elf_core_vma_data_size(gate_vma, cprm->mm_flags);
48793 + offset += elf_core_vma_data_size(gate_vma, cprm);
48794 offset += elf_core_extra_data_size();
48795 e_shoff = offset;
48796
48797 @@ -2130,10 +2577,12 @@ static int elf_core_dump(struct coredump_params *cprm)
48798 offset = dataoff;
48799
48800 size += sizeof(*elf);
48801 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
48802 if (size > cprm->limit || !dump_write(cprm->file, elf, sizeof(*elf)))
48803 goto end_coredump;
48804
48805 size += sizeof(*phdr4note);
48806 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
48807 if (size > cprm->limit
48808 || !dump_write(cprm->file, phdr4note, sizeof(*phdr4note)))
48809 goto end_coredump;
48810 @@ -2147,7 +2596,7 @@ static int elf_core_dump(struct coredump_params *cprm)
48811 phdr.p_offset = offset;
48812 phdr.p_vaddr = vma->vm_start;
48813 phdr.p_paddr = 0;
48814 - phdr.p_filesz = vma_dump_size(vma, cprm->mm_flags);
48815 + phdr.p_filesz = vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
48816 phdr.p_memsz = vma->vm_end - vma->vm_start;
48817 offset += phdr.p_filesz;
48818 phdr.p_flags = vma->vm_flags & VM_READ ? PF_R : 0;
48819 @@ -2158,6 +2607,7 @@ static int elf_core_dump(struct coredump_params *cprm)
48820 phdr.p_align = ELF_EXEC_PAGESIZE;
48821
48822 size += sizeof(phdr);
48823 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
48824 if (size > cprm->limit
48825 || !dump_write(cprm->file, &phdr, sizeof(phdr)))
48826 goto end_coredump;
48827 @@ -2182,7 +2632,7 @@ static int elf_core_dump(struct coredump_params *cprm)
48828 unsigned long addr;
48829 unsigned long end;
48830
48831 - end = vma->vm_start + vma_dump_size(vma, cprm->mm_flags);
48832 + end = vma->vm_start + vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
48833
48834 for (addr = vma->vm_start; addr < end; addr += PAGE_SIZE) {
48835 struct page *page;
48836 @@ -2191,6 +2641,7 @@ static int elf_core_dump(struct coredump_params *cprm)
48837 page = get_dump_page(addr);
48838 if (page) {
48839 void *kaddr = kmap(page);
48840 + gr_learn_resource(current, RLIMIT_CORE, size + PAGE_SIZE, 1);
48841 stop = ((size += PAGE_SIZE) > cprm->limit) ||
48842 !dump_write(cprm->file, kaddr,
48843 PAGE_SIZE);
48844 @@ -2208,6 +2659,7 @@ static int elf_core_dump(struct coredump_params *cprm)
48845
48846 if (e_phnum == PN_XNUM) {
48847 size += sizeof(*shdr4extnum);
48848 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
48849 if (size > cprm->limit
48850 || !dump_write(cprm->file, shdr4extnum,
48851 sizeof(*shdr4extnum)))
48852 @@ -2228,6 +2680,97 @@ out:
48853
48854 #endif /* CONFIG_ELF_CORE */
48855
48856 +#ifdef CONFIG_PAX_MPROTECT
48857 +/* PaX: non-PIC ELF libraries need relocations on their executable segments
48858 + * therefore we'll grant them VM_MAYWRITE once during their life. Similarly
48859 + * we'll remove VM_MAYWRITE for good on RELRO segments.
48860 + *
48861 + * The checks favour ld-linux.so behaviour which operates on a per ELF segment
48862 + * basis because we want to allow the common case and not the special ones.
48863 + */
48864 +static void elf_handle_mprotect(struct vm_area_struct *vma, unsigned long newflags)
48865 +{
48866 + struct elfhdr elf_h;
48867 + struct elf_phdr elf_p;
48868 + unsigned long i;
48869 + unsigned long oldflags;
48870 + bool is_textrel_rw, is_textrel_rx, is_relro;
48871 +
48872 + if (!(vma->vm_mm->pax_flags & MF_PAX_MPROTECT))
48873 + return;
48874 +
48875 + oldflags = vma->vm_flags & (VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_EXEC | VM_WRITE | VM_READ);
48876 + newflags &= VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_EXEC | VM_WRITE | VM_READ;
48877 +
48878 +#ifdef CONFIG_PAX_ELFRELOCS
48879 + /* possible TEXTREL */
48880 + is_textrel_rw = vma->vm_file && !vma->anon_vma && oldflags == (VM_MAYEXEC | VM_MAYREAD | VM_EXEC | VM_READ) && newflags == (VM_WRITE | VM_READ);
48881 + 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);
48882 +#else
48883 + is_textrel_rw = false;
48884 + is_textrel_rx = false;
48885 +#endif
48886 +
48887 + /* possible RELRO */
48888 + is_relro = vma->vm_file && vma->anon_vma && oldflags == (VM_MAYWRITE | VM_MAYREAD | VM_READ) && newflags == (VM_MAYWRITE | VM_MAYREAD | VM_READ);
48889 +
48890 + if (!is_textrel_rw && !is_textrel_rx && !is_relro)
48891 + return;
48892 +
48893 + if (sizeof(elf_h) != kernel_read(vma->vm_file, 0UL, (char *)&elf_h, sizeof(elf_h)) ||
48894 + memcmp(elf_h.e_ident, ELFMAG, SELFMAG) ||
48895 +
48896 +#ifdef CONFIG_PAX_ETEXECRELOCS
48897 + ((is_textrel_rw || is_textrel_rx) && (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC)) ||
48898 +#else
48899 + ((is_textrel_rw || is_textrel_rx) && elf_h.e_type != ET_DYN) ||
48900 +#endif
48901 +
48902 + (is_relro && (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC)) ||
48903 + !elf_check_arch(&elf_h) ||
48904 + elf_h.e_phentsize != sizeof(struct elf_phdr) ||
48905 + elf_h.e_phnum > 65536UL / sizeof(struct elf_phdr))
48906 + return;
48907 +
48908 + for (i = 0UL; i < elf_h.e_phnum; i++) {
48909 + if (sizeof(elf_p) != kernel_read(vma->vm_file, elf_h.e_phoff + i*sizeof(elf_p), (char *)&elf_p, sizeof(elf_p)))
48910 + return;
48911 + switch (elf_p.p_type) {
48912 + case PT_DYNAMIC:
48913 + if (!is_textrel_rw && !is_textrel_rx)
48914 + continue;
48915 + i = 0UL;
48916 + while ((i+1) * sizeof(elf_dyn) <= elf_p.p_filesz) {
48917 + elf_dyn dyn;
48918 +
48919 + if (sizeof(dyn) != kernel_read(vma->vm_file, elf_p.p_offset + i*sizeof(dyn), (char *)&dyn, sizeof(dyn)))
48920 + return;
48921 + if (dyn.d_tag == DT_NULL)
48922 + return;
48923 + if (dyn.d_tag == DT_TEXTREL || (dyn.d_tag == DT_FLAGS && (dyn.d_un.d_val & DF_TEXTREL))) {
48924 + gr_log_textrel(vma);
48925 + if (is_textrel_rw)
48926 + vma->vm_flags |= VM_MAYWRITE;
48927 + else
48928 + /* PaX: disallow write access after relocs are done, hopefully noone else needs it... */
48929 + vma->vm_flags &= ~VM_MAYWRITE;
48930 + return;
48931 + }
48932 + i++;
48933 + }
48934 + return;
48935 +
48936 + case PT_GNU_RELRO:
48937 + if (!is_relro)
48938 + continue;
48939 + if ((elf_p.p_offset >> PAGE_SHIFT) == vma->vm_pgoff && ELF_PAGEALIGN(elf_p.p_memsz) == vma->vm_end - vma->vm_start)
48940 + vma->vm_flags &= ~VM_MAYWRITE;
48941 + return;
48942 + }
48943 + }
48944 +}
48945 +#endif
48946 +
48947 static int __init init_elf_binfmt(void)
48948 {
48949 register_binfmt(&elf_format);
48950 diff --git a/fs/binfmt_flat.c b/fs/binfmt_flat.c
48951 index 2036d21..b0430d0 100644
48952 --- a/fs/binfmt_flat.c
48953 +++ b/fs/binfmt_flat.c
48954 @@ -562,7 +562,9 @@ static int load_flat_file(struct linux_binprm * bprm,
48955 realdatastart = (unsigned long) -ENOMEM;
48956 printk("Unable to allocate RAM for process data, errno %d\n",
48957 (int)-realdatastart);
48958 + down_write(&current->mm->mmap_sem);
48959 vm_munmap(textpos, text_len);
48960 + up_write(&current->mm->mmap_sem);
48961 ret = realdatastart;
48962 goto err;
48963 }
48964 @@ -586,8 +588,10 @@ static int load_flat_file(struct linux_binprm * bprm,
48965 }
48966 if (IS_ERR_VALUE(result)) {
48967 printk("Unable to read data+bss, errno %d\n", (int)-result);
48968 + down_write(&current->mm->mmap_sem);
48969 vm_munmap(textpos, text_len);
48970 vm_munmap(realdatastart, len);
48971 + up_write(&current->mm->mmap_sem);
48972 ret = result;
48973 goto err;
48974 }
48975 @@ -654,8 +658,10 @@ static int load_flat_file(struct linux_binprm * bprm,
48976 }
48977 if (IS_ERR_VALUE(result)) {
48978 printk("Unable to read code+data+bss, errno %d\n",(int)-result);
48979 + down_write(&current->mm->mmap_sem);
48980 vm_munmap(textpos, text_len + data_len + extra +
48981 MAX_SHARED_LIBS * sizeof(unsigned long));
48982 + up_write(&current->mm->mmap_sem);
48983 ret = result;
48984 goto err;
48985 }
48986 diff --git a/fs/bio.c b/fs/bio.c
48987 index b96fc6c..431d628 100644
48988 --- a/fs/bio.c
48989 +++ b/fs/bio.c
48990 @@ -818,7 +818,7 @@ struct bio *bio_copy_user_iov(struct request_queue *q,
48991 /*
48992 * Overflow, abort
48993 */
48994 - if (end < start)
48995 + if (end < start || end - start > INT_MAX - nr_pages)
48996 return ERR_PTR(-EINVAL);
48997
48998 nr_pages += end - start;
48999 @@ -952,7 +952,7 @@ static struct bio *__bio_map_user_iov(struct request_queue *q,
49000 /*
49001 * Overflow, abort
49002 */
49003 - if (end < start)
49004 + if (end < start || end - start > INT_MAX - nr_pages)
49005 return ERR_PTR(-EINVAL);
49006
49007 nr_pages += end - start;
49008 @@ -1214,7 +1214,7 @@ static void bio_copy_kern_endio(struct bio *bio, int err)
49009 const int read = bio_data_dir(bio) == READ;
49010 struct bio_map_data *bmd = bio->bi_private;
49011 int i;
49012 - char *p = bmd->sgvecs[0].iov_base;
49013 + char *p = (char __force_kernel *)bmd->sgvecs[0].iov_base;
49014
49015 __bio_for_each_segment(bvec, bio, i, 0) {
49016 char *addr = page_address(bvec->bv_page);
49017 diff --git a/fs/block_dev.c b/fs/block_dev.c
49018 index aae187a..fd790ba 100644
49019 --- a/fs/block_dev.c
49020 +++ b/fs/block_dev.c
49021 @@ -652,7 +652,7 @@ static bool bd_may_claim(struct block_device *bdev, struct block_device *whole,
49022 else if (bdev->bd_contains == bdev)
49023 return true; /* is a whole device which isn't held */
49024
49025 - else if (whole->bd_holder == bd_may_claim)
49026 + else if (whole->bd_holder == (void *)bd_may_claim)
49027 return true; /* is a partition of a device that is being partitioned */
49028 else if (whole->bd_holder != NULL)
49029 return false; /* is a partition of a held device */
49030 diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
49031 index ca9d8f1..8c0142d 100644
49032 --- a/fs/btrfs/ctree.c
49033 +++ b/fs/btrfs/ctree.c
49034 @@ -1036,9 +1036,12 @@ static noinline int __btrfs_cow_block(struct btrfs_trans_handle *trans,
49035 free_extent_buffer(buf);
49036 add_root_to_dirty_list(root);
49037 } else {
49038 - if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID)
49039 - parent_start = parent->start;
49040 - else
49041 + if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID) {
49042 + if (parent)
49043 + parent_start = parent->start;
49044 + else
49045 + parent_start = 0;
49046 + } else
49047 parent_start = 0;
49048
49049 WARN_ON(trans->transid != btrfs_header_generation(parent));
49050 diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
49051 index f49b62f..07834ab 100644
49052 --- a/fs/btrfs/ioctl.c
49053 +++ b/fs/btrfs/ioctl.c
49054 @@ -3077,9 +3077,12 @@ long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg)
49055 for (i = 0; i < num_types; i++) {
49056 struct btrfs_space_info *tmp;
49057
49058 + /* Don't copy in more than we allocated */
49059 if (!slot_count)
49060 break;
49061
49062 + slot_count--;
49063 +
49064 info = NULL;
49065 rcu_read_lock();
49066 list_for_each_entry_rcu(tmp, &root->fs_info->space_info,
49067 @@ -3101,10 +3104,7 @@ long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg)
49068 memcpy(dest, &space, sizeof(space));
49069 dest++;
49070 space_args.total_spaces++;
49071 - slot_count--;
49072 }
49073 - if (!slot_count)
49074 - break;
49075 }
49076 up_read(&info->groups_sem);
49077 }
49078 diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
49079 index f6b8859..54fe8c5 100644
49080 --- a/fs/btrfs/super.c
49081 +++ b/fs/btrfs/super.c
49082 @@ -266,7 +266,7 @@ void __btrfs_abort_transaction(struct btrfs_trans_handle *trans,
49083 function, line, errstr);
49084 return;
49085 }
49086 - ACCESS_ONCE(trans->transaction->aborted) = errno;
49087 + ACCESS_ONCE_RW(trans->transaction->aborted) = errno;
49088 __btrfs_std_error(root->fs_info, function, line, errno, NULL);
49089 }
49090 /*
49091 diff --git a/fs/cachefiles/bind.c b/fs/cachefiles/bind.c
49092 index 622f469..e8d2d55 100644
49093 --- a/fs/cachefiles/bind.c
49094 +++ b/fs/cachefiles/bind.c
49095 @@ -39,13 +39,11 @@ int cachefiles_daemon_bind(struct cachefiles_cache *cache, char *args)
49096 args);
49097
49098 /* start by checking things over */
49099 - ASSERT(cache->fstop_percent >= 0 &&
49100 - cache->fstop_percent < cache->fcull_percent &&
49101 + ASSERT(cache->fstop_percent < cache->fcull_percent &&
49102 cache->fcull_percent < cache->frun_percent &&
49103 cache->frun_percent < 100);
49104
49105 - ASSERT(cache->bstop_percent >= 0 &&
49106 - cache->bstop_percent < cache->bcull_percent &&
49107 + ASSERT(cache->bstop_percent < cache->bcull_percent &&
49108 cache->bcull_percent < cache->brun_percent &&
49109 cache->brun_percent < 100);
49110
49111 diff --git a/fs/cachefiles/daemon.c b/fs/cachefiles/daemon.c
49112 index 0a1467b..6a53245 100644
49113 --- a/fs/cachefiles/daemon.c
49114 +++ b/fs/cachefiles/daemon.c
49115 @@ -196,7 +196,7 @@ static ssize_t cachefiles_daemon_read(struct file *file, char __user *_buffer,
49116 if (n > buflen)
49117 return -EMSGSIZE;
49118
49119 - if (copy_to_user(_buffer, buffer, n) != 0)
49120 + if (n > sizeof(buffer) || copy_to_user(_buffer, buffer, n) != 0)
49121 return -EFAULT;
49122
49123 return n;
49124 @@ -222,7 +222,7 @@ static ssize_t cachefiles_daemon_write(struct file *file,
49125 if (test_bit(CACHEFILES_DEAD, &cache->flags))
49126 return -EIO;
49127
49128 - if (datalen < 0 || datalen > PAGE_SIZE - 1)
49129 + if (datalen > PAGE_SIZE - 1)
49130 return -EOPNOTSUPP;
49131
49132 /* drag the command string into the kernel so we can parse it */
49133 @@ -386,7 +386,7 @@ static int cachefiles_daemon_fstop(struct cachefiles_cache *cache, char *args)
49134 if (args[0] != '%' || args[1] != '\0')
49135 return -EINVAL;
49136
49137 - if (fstop < 0 || fstop >= cache->fcull_percent)
49138 + if (fstop >= cache->fcull_percent)
49139 return cachefiles_daemon_range_error(cache, args);
49140
49141 cache->fstop_percent = fstop;
49142 @@ -458,7 +458,7 @@ static int cachefiles_daemon_bstop(struct cachefiles_cache *cache, char *args)
49143 if (args[0] != '%' || args[1] != '\0')
49144 return -EINVAL;
49145
49146 - if (bstop < 0 || bstop >= cache->bcull_percent)
49147 + if (bstop >= cache->bcull_percent)
49148 return cachefiles_daemon_range_error(cache, args);
49149
49150 cache->bstop_percent = bstop;
49151 diff --git a/fs/cachefiles/internal.h b/fs/cachefiles/internal.h
49152 index 4938251..7e01445 100644
49153 --- a/fs/cachefiles/internal.h
49154 +++ b/fs/cachefiles/internal.h
49155 @@ -59,7 +59,7 @@ struct cachefiles_cache {
49156 wait_queue_head_t daemon_pollwq; /* poll waitqueue for daemon */
49157 struct rb_root active_nodes; /* active nodes (can't be culled) */
49158 rwlock_t active_lock; /* lock for active_nodes */
49159 - atomic_t gravecounter; /* graveyard uniquifier */
49160 + atomic_unchecked_t gravecounter; /* graveyard uniquifier */
49161 unsigned frun_percent; /* when to stop culling (% files) */
49162 unsigned fcull_percent; /* when to start culling (% files) */
49163 unsigned fstop_percent; /* when to stop allocating (% files) */
49164 @@ -171,19 +171,19 @@ extern int cachefiles_check_in_use(struct cachefiles_cache *cache,
49165 * proc.c
49166 */
49167 #ifdef CONFIG_CACHEFILES_HISTOGRAM
49168 -extern atomic_t cachefiles_lookup_histogram[HZ];
49169 -extern atomic_t cachefiles_mkdir_histogram[HZ];
49170 -extern atomic_t cachefiles_create_histogram[HZ];
49171 +extern atomic_unchecked_t cachefiles_lookup_histogram[HZ];
49172 +extern atomic_unchecked_t cachefiles_mkdir_histogram[HZ];
49173 +extern atomic_unchecked_t cachefiles_create_histogram[HZ];
49174
49175 extern int __init cachefiles_proc_init(void);
49176 extern void cachefiles_proc_cleanup(void);
49177 static inline
49178 -void cachefiles_hist(atomic_t histogram[], unsigned long start_jif)
49179 +void cachefiles_hist(atomic_unchecked_t histogram[], unsigned long start_jif)
49180 {
49181 unsigned long jif = jiffies - start_jif;
49182 if (jif >= HZ)
49183 jif = HZ - 1;
49184 - atomic_inc(&histogram[jif]);
49185 + atomic_inc_unchecked(&histogram[jif]);
49186 }
49187
49188 #else
49189 diff --git a/fs/cachefiles/namei.c b/fs/cachefiles/namei.c
49190 index 8c01c5fc..15f982e 100644
49191 --- a/fs/cachefiles/namei.c
49192 +++ b/fs/cachefiles/namei.c
49193 @@ -317,7 +317,7 @@ try_again:
49194 /* first step is to make up a grave dentry in the graveyard */
49195 sprintf(nbuffer, "%08x%08x",
49196 (uint32_t) get_seconds(),
49197 - (uint32_t) atomic_inc_return(&cache->gravecounter));
49198 + (uint32_t) atomic_inc_return_unchecked(&cache->gravecounter));
49199
49200 /* do the multiway lock magic */
49201 trap = lock_rename(cache->graveyard, dir);
49202 diff --git a/fs/cachefiles/proc.c b/fs/cachefiles/proc.c
49203 index eccd339..4c1d995 100644
49204 --- a/fs/cachefiles/proc.c
49205 +++ b/fs/cachefiles/proc.c
49206 @@ -14,9 +14,9 @@
49207 #include <linux/seq_file.h>
49208 #include "internal.h"
49209
49210 -atomic_t cachefiles_lookup_histogram[HZ];
49211 -atomic_t cachefiles_mkdir_histogram[HZ];
49212 -atomic_t cachefiles_create_histogram[HZ];
49213 +atomic_unchecked_t cachefiles_lookup_histogram[HZ];
49214 +atomic_unchecked_t cachefiles_mkdir_histogram[HZ];
49215 +atomic_unchecked_t cachefiles_create_histogram[HZ];
49216
49217 /*
49218 * display the latency histogram
49219 @@ -35,9 +35,9 @@ static int cachefiles_histogram_show(struct seq_file *m, void *v)
49220 return 0;
49221 default:
49222 index = (unsigned long) v - 3;
49223 - x = atomic_read(&cachefiles_lookup_histogram[index]);
49224 - y = atomic_read(&cachefiles_mkdir_histogram[index]);
49225 - z = atomic_read(&cachefiles_create_histogram[index]);
49226 + x = atomic_read_unchecked(&cachefiles_lookup_histogram[index]);
49227 + y = atomic_read_unchecked(&cachefiles_mkdir_histogram[index]);
49228 + z = atomic_read_unchecked(&cachefiles_create_histogram[index]);
49229 if (x == 0 && y == 0 && z == 0)
49230 return 0;
49231
49232 diff --git a/fs/cachefiles/rdwr.c b/fs/cachefiles/rdwr.c
49233 index 4809922..aab2c39 100644
49234 --- a/fs/cachefiles/rdwr.c
49235 +++ b/fs/cachefiles/rdwr.c
49236 @@ -965,7 +965,7 @@ int cachefiles_write_page(struct fscache_storage *op, struct page *page)
49237 old_fs = get_fs();
49238 set_fs(KERNEL_DS);
49239 ret = file->f_op->write(
49240 - file, (const void __user *) data, len, &pos);
49241 + file, (const void __force_user *) data, len, &pos);
49242 set_fs(old_fs);
49243 kunmap(page);
49244 if (ret != len)
49245 diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c
49246 index 6d797f4..0ace2e5 100644
49247 --- a/fs/ceph/dir.c
49248 +++ b/fs/ceph/dir.c
49249 @@ -243,7 +243,7 @@ static int ceph_readdir(struct file *filp, void *dirent, filldir_t filldir)
49250 struct ceph_fs_client *fsc = ceph_inode_to_client(inode);
49251 struct ceph_mds_client *mdsc = fsc->mdsc;
49252 unsigned frag = fpos_frag(filp->f_pos);
49253 - int off = fpos_off(filp->f_pos);
49254 + unsigned int off = fpos_off(filp->f_pos);
49255 int err;
49256 u32 ftype;
49257 struct ceph_mds_reply_info_parsed *rinfo;
49258 diff --git a/fs/cifs/cifs_debug.c b/fs/cifs/cifs_debug.c
49259 index d9ea6ed..1e6c8ac 100644
49260 --- a/fs/cifs/cifs_debug.c
49261 +++ b/fs/cifs/cifs_debug.c
49262 @@ -267,8 +267,8 @@ static ssize_t cifs_stats_proc_write(struct file *file,
49263
49264 if (c == '1' || c == 'y' || c == 'Y' || c == '0') {
49265 #ifdef CONFIG_CIFS_STATS2
49266 - atomic_set(&totBufAllocCount, 0);
49267 - atomic_set(&totSmBufAllocCount, 0);
49268 + atomic_set_unchecked(&totBufAllocCount, 0);
49269 + atomic_set_unchecked(&totSmBufAllocCount, 0);
49270 #endif /* CONFIG_CIFS_STATS2 */
49271 spin_lock(&cifs_tcp_ses_lock);
49272 list_for_each(tmp1, &cifs_tcp_ses_list) {
49273 @@ -281,7 +281,7 @@ static ssize_t cifs_stats_proc_write(struct file *file,
49274 tcon = list_entry(tmp3,
49275 struct cifs_tcon,
49276 tcon_list);
49277 - atomic_set(&tcon->num_smbs_sent, 0);
49278 + atomic_set_unchecked(&tcon->num_smbs_sent, 0);
49279 if (server->ops->clear_stats)
49280 server->ops->clear_stats(tcon);
49281 }
49282 @@ -313,8 +313,8 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
49283 smBufAllocCount.counter, cifs_min_small);
49284 #ifdef CONFIG_CIFS_STATS2
49285 seq_printf(m, "Total Large %d Small %d Allocations\n",
49286 - atomic_read(&totBufAllocCount),
49287 - atomic_read(&totSmBufAllocCount));
49288 + atomic_read_unchecked(&totBufAllocCount),
49289 + atomic_read_unchecked(&totSmBufAllocCount));
49290 #endif /* CONFIG_CIFS_STATS2 */
49291
49292 seq_printf(m, "Operations (MIDs): %d\n", atomic_read(&midCount));
49293 @@ -343,7 +343,7 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
49294 if (tcon->need_reconnect)
49295 seq_puts(m, "\tDISCONNECTED ");
49296 seq_printf(m, "\nSMBs: %d",
49297 - atomic_read(&tcon->num_smbs_sent));
49298 + atomic_read_unchecked(&tcon->num_smbs_sent));
49299 if (server->ops->print_stats)
49300 server->ops->print_stats(m, tcon);
49301 }
49302 diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
49303 index 345fc89..b2acae5 100644
49304 --- a/fs/cifs/cifsfs.c
49305 +++ b/fs/cifs/cifsfs.c
49306 @@ -1033,7 +1033,7 @@ cifs_init_request_bufs(void)
49307 /* cERROR(1, "CIFSMaxBufSize %d 0x%x",CIFSMaxBufSize,CIFSMaxBufSize); */
49308 cifs_req_cachep = kmem_cache_create("cifs_request",
49309 CIFSMaxBufSize + max_hdr_size, 0,
49310 - SLAB_HWCACHE_ALIGN, NULL);
49311 + SLAB_HWCACHE_ALIGN | SLAB_USERCOPY, NULL);
49312 if (cifs_req_cachep == NULL)
49313 return -ENOMEM;
49314
49315 @@ -1060,7 +1060,7 @@ cifs_init_request_bufs(void)
49316 efficient to alloc 1 per page off the slab compared to 17K (5page)
49317 alloc of large cifs buffers even when page debugging is on */
49318 cifs_sm_req_cachep = kmem_cache_create("cifs_small_rq",
49319 - MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN,
49320 + MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN | SLAB_USERCOPY,
49321 NULL);
49322 if (cifs_sm_req_cachep == NULL) {
49323 mempool_destroy(cifs_req_poolp);
49324 @@ -1145,8 +1145,8 @@ init_cifs(void)
49325 atomic_set(&bufAllocCount, 0);
49326 atomic_set(&smBufAllocCount, 0);
49327 #ifdef CONFIG_CIFS_STATS2
49328 - atomic_set(&totBufAllocCount, 0);
49329 - atomic_set(&totSmBufAllocCount, 0);
49330 + atomic_set_unchecked(&totBufAllocCount, 0);
49331 + atomic_set_unchecked(&totSmBufAllocCount, 0);
49332 #endif /* CONFIG_CIFS_STATS2 */
49333
49334 atomic_set(&midCount, 0);
49335 diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
49336 index 4f07f6f..55de8ce 100644
49337 --- a/fs/cifs/cifsglob.h
49338 +++ b/fs/cifs/cifsglob.h
49339 @@ -751,35 +751,35 @@ struct cifs_tcon {
49340 __u16 Flags; /* optional support bits */
49341 enum statusEnum tidStatus;
49342 #ifdef CONFIG_CIFS_STATS
49343 - atomic_t num_smbs_sent;
49344 + atomic_unchecked_t num_smbs_sent;
49345 union {
49346 struct {
49347 - atomic_t num_writes;
49348 - atomic_t num_reads;
49349 - atomic_t num_flushes;
49350 - atomic_t num_oplock_brks;
49351 - atomic_t num_opens;
49352 - atomic_t num_closes;
49353 - atomic_t num_deletes;
49354 - atomic_t num_mkdirs;
49355 - atomic_t num_posixopens;
49356 - atomic_t num_posixmkdirs;
49357 - atomic_t num_rmdirs;
49358 - atomic_t num_renames;
49359 - atomic_t num_t2renames;
49360 - atomic_t num_ffirst;
49361 - atomic_t num_fnext;
49362 - atomic_t num_fclose;
49363 - atomic_t num_hardlinks;
49364 - atomic_t num_symlinks;
49365 - atomic_t num_locks;
49366 - atomic_t num_acl_get;
49367 - atomic_t num_acl_set;
49368 + atomic_unchecked_t num_writes;
49369 + atomic_unchecked_t num_reads;
49370 + atomic_unchecked_t num_flushes;
49371 + atomic_unchecked_t num_oplock_brks;
49372 + atomic_unchecked_t num_opens;
49373 + atomic_unchecked_t num_closes;
49374 + atomic_unchecked_t num_deletes;
49375 + atomic_unchecked_t num_mkdirs;
49376 + atomic_unchecked_t num_posixopens;
49377 + atomic_unchecked_t num_posixmkdirs;
49378 + atomic_unchecked_t num_rmdirs;
49379 + atomic_unchecked_t num_renames;
49380 + atomic_unchecked_t num_t2renames;
49381 + atomic_unchecked_t num_ffirst;
49382 + atomic_unchecked_t num_fnext;
49383 + atomic_unchecked_t num_fclose;
49384 + atomic_unchecked_t num_hardlinks;
49385 + atomic_unchecked_t num_symlinks;
49386 + atomic_unchecked_t num_locks;
49387 + atomic_unchecked_t num_acl_get;
49388 + atomic_unchecked_t num_acl_set;
49389 } cifs_stats;
49390 #ifdef CONFIG_CIFS_SMB2
49391 struct {
49392 - atomic_t smb2_com_sent[NUMBER_OF_SMB2_COMMANDS];
49393 - atomic_t smb2_com_failed[NUMBER_OF_SMB2_COMMANDS];
49394 + atomic_unchecked_t smb2_com_sent[NUMBER_OF_SMB2_COMMANDS];
49395 + atomic_unchecked_t smb2_com_failed[NUMBER_OF_SMB2_COMMANDS];
49396 } smb2_stats;
49397 #endif /* CONFIG_CIFS_SMB2 */
49398 } stats;
49399 @@ -1080,7 +1080,7 @@ convert_delimiter(char *path, char delim)
49400 }
49401
49402 #ifdef CONFIG_CIFS_STATS
49403 -#define cifs_stats_inc atomic_inc
49404 +#define cifs_stats_inc atomic_inc_unchecked
49405
49406 static inline void cifs_stats_bytes_written(struct cifs_tcon *tcon,
49407 unsigned int bytes)
49408 @@ -1445,8 +1445,8 @@ GLOBAL_EXTERN atomic_t tconInfoReconnectCount;
49409 /* Various Debug counters */
49410 GLOBAL_EXTERN atomic_t bufAllocCount; /* current number allocated */
49411 #ifdef CONFIG_CIFS_STATS2
49412 -GLOBAL_EXTERN atomic_t totBufAllocCount; /* total allocated over all time */
49413 -GLOBAL_EXTERN atomic_t totSmBufAllocCount;
49414 +GLOBAL_EXTERN atomic_unchecked_t totBufAllocCount; /* total allocated over all time */
49415 +GLOBAL_EXTERN atomic_unchecked_t totSmBufAllocCount;
49416 #endif
49417 GLOBAL_EXTERN atomic_t smBufAllocCount;
49418 GLOBAL_EXTERN atomic_t midCount;
49419 diff --git a/fs/cifs/link.c b/fs/cifs/link.c
49420 index 9f6c4c4..8de307a 100644
49421 --- a/fs/cifs/link.c
49422 +++ b/fs/cifs/link.c
49423 @@ -616,7 +616,7 @@ symlink_exit:
49424
49425 void cifs_put_link(struct dentry *direntry, struct nameidata *nd, void *cookie)
49426 {
49427 - char *p = nd_get_link(nd);
49428 + const char *p = nd_get_link(nd);
49429 if (!IS_ERR(p))
49430 kfree(p);
49431 }
49432 diff --git a/fs/cifs/misc.c b/fs/cifs/misc.c
49433 index 1b15bf8..1ce489e 100644
49434 --- a/fs/cifs/misc.c
49435 +++ b/fs/cifs/misc.c
49436 @@ -169,7 +169,7 @@ cifs_buf_get(void)
49437 memset(ret_buf, 0, buf_size + 3);
49438 atomic_inc(&bufAllocCount);
49439 #ifdef CONFIG_CIFS_STATS2
49440 - atomic_inc(&totBufAllocCount);
49441 + atomic_inc_unchecked(&totBufAllocCount);
49442 #endif /* CONFIG_CIFS_STATS2 */
49443 }
49444
49445 @@ -204,7 +204,7 @@ cifs_small_buf_get(void)
49446 /* memset(ret_buf, 0, sizeof(struct smb_hdr) + 27);*/
49447 atomic_inc(&smBufAllocCount);
49448 #ifdef CONFIG_CIFS_STATS2
49449 - atomic_inc(&totSmBufAllocCount);
49450 + atomic_inc_unchecked(&totSmBufAllocCount);
49451 #endif /* CONFIG_CIFS_STATS2 */
49452
49453 }
49454 diff --git a/fs/cifs/smb1ops.c b/fs/cifs/smb1ops.c
49455 index 47bc5a8..10decbe 100644
49456 --- a/fs/cifs/smb1ops.c
49457 +++ b/fs/cifs/smb1ops.c
49458 @@ -586,27 +586,27 @@ static void
49459 cifs_clear_stats(struct cifs_tcon *tcon)
49460 {
49461 #ifdef CONFIG_CIFS_STATS
49462 - atomic_set(&tcon->stats.cifs_stats.num_writes, 0);
49463 - atomic_set(&tcon->stats.cifs_stats.num_reads, 0);
49464 - atomic_set(&tcon->stats.cifs_stats.num_flushes, 0);
49465 - atomic_set(&tcon->stats.cifs_stats.num_oplock_brks, 0);
49466 - atomic_set(&tcon->stats.cifs_stats.num_opens, 0);
49467 - atomic_set(&tcon->stats.cifs_stats.num_posixopens, 0);
49468 - atomic_set(&tcon->stats.cifs_stats.num_posixmkdirs, 0);
49469 - atomic_set(&tcon->stats.cifs_stats.num_closes, 0);
49470 - atomic_set(&tcon->stats.cifs_stats.num_deletes, 0);
49471 - atomic_set(&tcon->stats.cifs_stats.num_mkdirs, 0);
49472 - atomic_set(&tcon->stats.cifs_stats.num_rmdirs, 0);
49473 - atomic_set(&tcon->stats.cifs_stats.num_renames, 0);
49474 - atomic_set(&tcon->stats.cifs_stats.num_t2renames, 0);
49475 - atomic_set(&tcon->stats.cifs_stats.num_ffirst, 0);
49476 - atomic_set(&tcon->stats.cifs_stats.num_fnext, 0);
49477 - atomic_set(&tcon->stats.cifs_stats.num_fclose, 0);
49478 - atomic_set(&tcon->stats.cifs_stats.num_hardlinks, 0);
49479 - atomic_set(&tcon->stats.cifs_stats.num_symlinks, 0);
49480 - atomic_set(&tcon->stats.cifs_stats.num_locks, 0);
49481 - atomic_set(&tcon->stats.cifs_stats.num_acl_get, 0);
49482 - atomic_set(&tcon->stats.cifs_stats.num_acl_set, 0);
49483 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_writes, 0);
49484 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_reads, 0);
49485 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_flushes, 0);
49486 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_oplock_brks, 0);
49487 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_opens, 0);
49488 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_posixopens, 0);
49489 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_posixmkdirs, 0);
49490 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_closes, 0);
49491 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_deletes, 0);
49492 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_mkdirs, 0);
49493 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_rmdirs, 0);
49494 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_renames, 0);
49495 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_t2renames, 0);
49496 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_ffirst, 0);
49497 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_fnext, 0);
49498 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_fclose, 0);
49499 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_hardlinks, 0);
49500 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_symlinks, 0);
49501 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_locks, 0);
49502 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_acl_get, 0);
49503 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_acl_set, 0);
49504 #endif
49505 }
49506
49507 @@ -615,36 +615,36 @@ cifs_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
49508 {
49509 #ifdef CONFIG_CIFS_STATS
49510 seq_printf(m, " Oplocks breaks: %d",
49511 - atomic_read(&tcon->stats.cifs_stats.num_oplock_brks));
49512 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_oplock_brks));
49513 seq_printf(m, "\nReads: %d Bytes: %llu",
49514 - atomic_read(&tcon->stats.cifs_stats.num_reads),
49515 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_reads),
49516 (long long)(tcon->bytes_read));
49517 seq_printf(m, "\nWrites: %d Bytes: %llu",
49518 - atomic_read(&tcon->stats.cifs_stats.num_writes),
49519 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_writes),
49520 (long long)(tcon->bytes_written));
49521 seq_printf(m, "\nFlushes: %d",
49522 - atomic_read(&tcon->stats.cifs_stats.num_flushes));
49523 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_flushes));
49524 seq_printf(m, "\nLocks: %d HardLinks: %d Symlinks: %d",
49525 - atomic_read(&tcon->stats.cifs_stats.num_locks),
49526 - atomic_read(&tcon->stats.cifs_stats.num_hardlinks),
49527 - atomic_read(&tcon->stats.cifs_stats.num_symlinks));
49528 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_locks),
49529 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_hardlinks),
49530 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_symlinks));
49531 seq_printf(m, "\nOpens: %d Closes: %d Deletes: %d",
49532 - atomic_read(&tcon->stats.cifs_stats.num_opens),
49533 - atomic_read(&tcon->stats.cifs_stats.num_closes),
49534 - atomic_read(&tcon->stats.cifs_stats.num_deletes));
49535 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_opens),
49536 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_closes),
49537 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_deletes));
49538 seq_printf(m, "\nPosix Opens: %d Posix Mkdirs: %d",
49539 - atomic_read(&tcon->stats.cifs_stats.num_posixopens),
49540 - atomic_read(&tcon->stats.cifs_stats.num_posixmkdirs));
49541 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_posixopens),
49542 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_posixmkdirs));
49543 seq_printf(m, "\nMkdirs: %d Rmdirs: %d",
49544 - atomic_read(&tcon->stats.cifs_stats.num_mkdirs),
49545 - atomic_read(&tcon->stats.cifs_stats.num_rmdirs));
49546 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_mkdirs),
49547 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_rmdirs));
49548 seq_printf(m, "\nRenames: %d T2 Renames %d",
49549 - atomic_read(&tcon->stats.cifs_stats.num_renames),
49550 - atomic_read(&tcon->stats.cifs_stats.num_t2renames));
49551 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_renames),
49552 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_t2renames));
49553 seq_printf(m, "\nFindFirst: %d FNext %d FClose %d",
49554 - atomic_read(&tcon->stats.cifs_stats.num_ffirst),
49555 - atomic_read(&tcon->stats.cifs_stats.num_fnext),
49556 - atomic_read(&tcon->stats.cifs_stats.num_fclose));
49557 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_ffirst),
49558 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_fnext),
49559 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_fclose));
49560 #endif
49561 }
49562
49563 diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
49564 index bceffe7..cd1ae59 100644
49565 --- a/fs/cifs/smb2ops.c
49566 +++ b/fs/cifs/smb2ops.c
49567 @@ -274,8 +274,8 @@ smb2_clear_stats(struct cifs_tcon *tcon)
49568 #ifdef CONFIG_CIFS_STATS
49569 int i;
49570 for (i = 0; i < NUMBER_OF_SMB2_COMMANDS; i++) {
49571 - atomic_set(&tcon->stats.smb2_stats.smb2_com_sent[i], 0);
49572 - atomic_set(&tcon->stats.smb2_stats.smb2_com_failed[i], 0);
49573 + atomic_set_unchecked(&tcon->stats.smb2_stats.smb2_com_sent[i], 0);
49574 + atomic_set_unchecked(&tcon->stats.smb2_stats.smb2_com_failed[i], 0);
49575 }
49576 #endif
49577 }
49578 @@ -284,66 +284,66 @@ static void
49579 smb2_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
49580 {
49581 #ifdef CONFIG_CIFS_STATS
49582 - atomic_t *sent = tcon->stats.smb2_stats.smb2_com_sent;
49583 - atomic_t *failed = tcon->stats.smb2_stats.smb2_com_failed;
49584 + atomic_unchecked_t *sent = tcon->stats.smb2_stats.smb2_com_sent;
49585 + atomic_unchecked_t *failed = tcon->stats.smb2_stats.smb2_com_failed;
49586 seq_printf(m, "\nNegotiates: %d sent %d failed",
49587 - atomic_read(&sent[SMB2_NEGOTIATE_HE]),
49588 - atomic_read(&failed[SMB2_NEGOTIATE_HE]));
49589 + atomic_read_unchecked(&sent[SMB2_NEGOTIATE_HE]),
49590 + atomic_read_unchecked(&failed[SMB2_NEGOTIATE_HE]));
49591 seq_printf(m, "\nSessionSetups: %d sent %d failed",
49592 - atomic_read(&sent[SMB2_SESSION_SETUP_HE]),
49593 - atomic_read(&failed[SMB2_SESSION_SETUP_HE]));
49594 + atomic_read_unchecked(&sent[SMB2_SESSION_SETUP_HE]),
49595 + atomic_read_unchecked(&failed[SMB2_SESSION_SETUP_HE]));
49596 #define SMB2LOGOFF 0x0002 /* trivial request/resp */
49597 seq_printf(m, "\nLogoffs: %d sent %d failed",
49598 - atomic_read(&sent[SMB2_LOGOFF_HE]),
49599 - atomic_read(&failed[SMB2_LOGOFF_HE]));
49600 + atomic_read_unchecked(&sent[SMB2_LOGOFF_HE]),
49601 + atomic_read_unchecked(&failed[SMB2_LOGOFF_HE]));
49602 seq_printf(m, "\nTreeConnects: %d sent %d failed",
49603 - atomic_read(&sent[SMB2_TREE_CONNECT_HE]),
49604 - atomic_read(&failed[SMB2_TREE_CONNECT_HE]));
49605 + atomic_read_unchecked(&sent[SMB2_TREE_CONNECT_HE]),
49606 + atomic_read_unchecked(&failed[SMB2_TREE_CONNECT_HE]));
49607 seq_printf(m, "\nTreeDisconnects: %d sent %d failed",
49608 - atomic_read(&sent[SMB2_TREE_DISCONNECT_HE]),
49609 - atomic_read(&failed[SMB2_TREE_DISCONNECT_HE]));
49610 + atomic_read_unchecked(&sent[SMB2_TREE_DISCONNECT_HE]),
49611 + atomic_read_unchecked(&failed[SMB2_TREE_DISCONNECT_HE]));
49612 seq_printf(m, "\nCreates: %d sent %d failed",
49613 - atomic_read(&sent[SMB2_CREATE_HE]),
49614 - atomic_read(&failed[SMB2_CREATE_HE]));
49615 + atomic_read_unchecked(&sent[SMB2_CREATE_HE]),
49616 + atomic_read_unchecked(&failed[SMB2_CREATE_HE]));
49617 seq_printf(m, "\nCloses: %d sent %d failed",
49618 - atomic_read(&sent[SMB2_CLOSE_HE]),
49619 - atomic_read(&failed[SMB2_CLOSE_HE]));
49620 + atomic_read_unchecked(&sent[SMB2_CLOSE_HE]),
49621 + atomic_read_unchecked(&failed[SMB2_CLOSE_HE]));
49622 seq_printf(m, "\nFlushes: %d sent %d failed",
49623 - atomic_read(&sent[SMB2_FLUSH_HE]),
49624 - atomic_read(&failed[SMB2_FLUSH_HE]));
49625 + atomic_read_unchecked(&sent[SMB2_FLUSH_HE]),
49626 + atomic_read_unchecked(&failed[SMB2_FLUSH_HE]));
49627 seq_printf(m, "\nReads: %d sent %d failed",
49628 - atomic_read(&sent[SMB2_READ_HE]),
49629 - atomic_read(&failed[SMB2_READ_HE]));
49630 + atomic_read_unchecked(&sent[SMB2_READ_HE]),
49631 + atomic_read_unchecked(&failed[SMB2_READ_HE]));
49632 seq_printf(m, "\nWrites: %d sent %d failed",
49633 - atomic_read(&sent[SMB2_WRITE_HE]),
49634 - atomic_read(&failed[SMB2_WRITE_HE]));
49635 + atomic_read_unchecked(&sent[SMB2_WRITE_HE]),
49636 + atomic_read_unchecked(&failed[SMB2_WRITE_HE]));
49637 seq_printf(m, "\nLocks: %d sent %d failed",
49638 - atomic_read(&sent[SMB2_LOCK_HE]),
49639 - atomic_read(&failed[SMB2_LOCK_HE]));
49640 + atomic_read_unchecked(&sent[SMB2_LOCK_HE]),
49641 + atomic_read_unchecked(&failed[SMB2_LOCK_HE]));
49642 seq_printf(m, "\nIOCTLs: %d sent %d failed",
49643 - atomic_read(&sent[SMB2_IOCTL_HE]),
49644 - atomic_read(&failed[SMB2_IOCTL_HE]));
49645 + atomic_read_unchecked(&sent[SMB2_IOCTL_HE]),
49646 + atomic_read_unchecked(&failed[SMB2_IOCTL_HE]));
49647 seq_printf(m, "\nCancels: %d sent %d failed",
49648 - atomic_read(&sent[SMB2_CANCEL_HE]),
49649 - atomic_read(&failed[SMB2_CANCEL_HE]));
49650 + atomic_read_unchecked(&sent[SMB2_CANCEL_HE]),
49651 + atomic_read_unchecked(&failed[SMB2_CANCEL_HE]));
49652 seq_printf(m, "\nEchos: %d sent %d failed",
49653 - atomic_read(&sent[SMB2_ECHO_HE]),
49654 - atomic_read(&failed[SMB2_ECHO_HE]));
49655 + atomic_read_unchecked(&sent[SMB2_ECHO_HE]),
49656 + atomic_read_unchecked(&failed[SMB2_ECHO_HE]));
49657 seq_printf(m, "\nQueryDirectories: %d sent %d failed",
49658 - atomic_read(&sent[SMB2_QUERY_DIRECTORY_HE]),
49659 - atomic_read(&failed[SMB2_QUERY_DIRECTORY_HE]));
49660 + atomic_read_unchecked(&sent[SMB2_QUERY_DIRECTORY_HE]),
49661 + atomic_read_unchecked(&failed[SMB2_QUERY_DIRECTORY_HE]));
49662 seq_printf(m, "\nChangeNotifies: %d sent %d failed",
49663 - atomic_read(&sent[SMB2_CHANGE_NOTIFY_HE]),
49664 - atomic_read(&failed[SMB2_CHANGE_NOTIFY_HE]));
49665 + atomic_read_unchecked(&sent[SMB2_CHANGE_NOTIFY_HE]),
49666 + atomic_read_unchecked(&failed[SMB2_CHANGE_NOTIFY_HE]));
49667 seq_printf(m, "\nQueryInfos: %d sent %d failed",
49668 - atomic_read(&sent[SMB2_QUERY_INFO_HE]),
49669 - atomic_read(&failed[SMB2_QUERY_INFO_HE]));
49670 + atomic_read_unchecked(&sent[SMB2_QUERY_INFO_HE]),
49671 + atomic_read_unchecked(&failed[SMB2_QUERY_INFO_HE]));
49672 seq_printf(m, "\nSetInfos: %d sent %d failed",
49673 - atomic_read(&sent[SMB2_SET_INFO_HE]),
49674 - atomic_read(&failed[SMB2_SET_INFO_HE]));
49675 + atomic_read_unchecked(&sent[SMB2_SET_INFO_HE]),
49676 + atomic_read_unchecked(&failed[SMB2_SET_INFO_HE]));
49677 seq_printf(m, "\nOplockBreaks: %d sent %d failed",
49678 - atomic_read(&sent[SMB2_OPLOCK_BREAK_HE]),
49679 - atomic_read(&failed[SMB2_OPLOCK_BREAK_HE]));
49680 + atomic_read_unchecked(&sent[SMB2_OPLOCK_BREAK_HE]),
49681 + atomic_read_unchecked(&failed[SMB2_OPLOCK_BREAK_HE]));
49682 #endif
49683 }
49684
49685 diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
49686 index 41d9d07..dbb4772 100644
49687 --- a/fs/cifs/smb2pdu.c
49688 +++ b/fs/cifs/smb2pdu.c
49689 @@ -1761,8 +1761,7 @@ SMB2_query_directory(const unsigned int xid, struct cifs_tcon *tcon,
49690 default:
49691 cERROR(1, "info level %u isn't supported",
49692 srch_inf->info_level);
49693 - rc = -EINVAL;
49694 - goto qdir_exit;
49695 + return -EINVAL;
49696 }
49697
49698 req->FileIndex = cpu_to_le32(index);
49699 diff --git a/fs/coda/cache.c b/fs/coda/cache.c
49700 index 1da168c..8bc7ff6 100644
49701 --- a/fs/coda/cache.c
49702 +++ b/fs/coda/cache.c
49703 @@ -24,7 +24,7 @@
49704 #include "coda_linux.h"
49705 #include "coda_cache.h"
49706
49707 -static atomic_t permission_epoch = ATOMIC_INIT(0);
49708 +static atomic_unchecked_t permission_epoch = ATOMIC_INIT(0);
49709
49710 /* replace or extend an acl cache hit */
49711 void coda_cache_enter(struct inode *inode, int mask)
49712 @@ -32,7 +32,7 @@ void coda_cache_enter(struct inode *inode, int mask)
49713 struct coda_inode_info *cii = ITOC(inode);
49714
49715 spin_lock(&cii->c_lock);
49716 - cii->c_cached_epoch = atomic_read(&permission_epoch);
49717 + cii->c_cached_epoch = atomic_read_unchecked(&permission_epoch);
49718 if (!uid_eq(cii->c_uid, current_fsuid())) {
49719 cii->c_uid = current_fsuid();
49720 cii->c_cached_perm = mask;
49721 @@ -46,14 +46,14 @@ void coda_cache_clear_inode(struct inode *inode)
49722 {
49723 struct coda_inode_info *cii = ITOC(inode);
49724 spin_lock(&cii->c_lock);
49725 - cii->c_cached_epoch = atomic_read(&permission_epoch) - 1;
49726 + cii->c_cached_epoch = atomic_read_unchecked(&permission_epoch) - 1;
49727 spin_unlock(&cii->c_lock);
49728 }
49729
49730 /* remove all acl caches */
49731 void coda_cache_clear_all(struct super_block *sb)
49732 {
49733 - atomic_inc(&permission_epoch);
49734 + atomic_inc_unchecked(&permission_epoch);
49735 }
49736
49737
49738 @@ -66,7 +66,7 @@ int coda_cache_check(struct inode *inode, int mask)
49739 spin_lock(&cii->c_lock);
49740 hit = (mask & cii->c_cached_perm) == mask &&
49741 uid_eq(cii->c_uid, current_fsuid()) &&
49742 - cii->c_cached_epoch == atomic_read(&permission_epoch);
49743 + cii->c_cached_epoch == atomic_read_unchecked(&permission_epoch);
49744 spin_unlock(&cii->c_lock);
49745
49746 return hit;
49747 diff --git a/fs/compat.c b/fs/compat.c
49748 index d487985..c9e04b1 100644
49749 --- a/fs/compat.c
49750 +++ b/fs/compat.c
49751 @@ -54,7 +54,7 @@
49752 #include <asm/ioctls.h>
49753 #include "internal.h"
49754
49755 -int compat_log = 1;
49756 +int compat_log = 0;
49757
49758 int compat_printk(const char *fmt, ...)
49759 {
49760 @@ -490,7 +490,7 @@ compat_sys_io_setup(unsigned nr_reqs, u32 __user *ctx32p)
49761
49762 set_fs(KERNEL_DS);
49763 /* The __user pointer cast is valid because of the set_fs() */
49764 - ret = sys_io_setup(nr_reqs, (aio_context_t __user *) &ctx64);
49765 + ret = sys_io_setup(nr_reqs, (aio_context_t __force_user *) &ctx64);
49766 set_fs(oldfs);
49767 /* truncating is ok because it's a user address */
49768 if (!ret)
49769 @@ -548,7 +548,7 @@ ssize_t compat_rw_copy_check_uvector(int type,
49770 goto out;
49771
49772 ret = -EINVAL;
49773 - if (nr_segs > UIO_MAXIOV || nr_segs < 0)
49774 + if (nr_segs > UIO_MAXIOV)
49775 goto out;
49776 if (nr_segs > fast_segs) {
49777 ret = -ENOMEM;
49778 @@ -835,6 +835,7 @@ struct compat_old_linux_dirent {
49779
49780 struct compat_readdir_callback {
49781 struct compat_old_linux_dirent __user *dirent;
49782 + struct file * file;
49783 int result;
49784 };
49785
49786 @@ -852,6 +853,10 @@ static int compat_fillonedir(void *__buf, const char *name, int namlen,
49787 buf->result = -EOVERFLOW;
49788 return -EOVERFLOW;
49789 }
49790 +
49791 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
49792 + return 0;
49793 +
49794 buf->result++;
49795 dirent = buf->dirent;
49796 if (!access_ok(VERIFY_WRITE, dirent,
49797 @@ -882,6 +887,7 @@ asmlinkage long compat_sys_old_readdir(unsigned int fd,
49798
49799 buf.result = 0;
49800 buf.dirent = dirent;
49801 + buf.file = f.file;
49802
49803 error = vfs_readdir(f.file, compat_fillonedir, &buf);
49804 if (buf.result)
49805 @@ -901,6 +907,7 @@ struct compat_linux_dirent {
49806 struct compat_getdents_callback {
49807 struct compat_linux_dirent __user *current_dir;
49808 struct compat_linux_dirent __user *previous;
49809 + struct file * file;
49810 int count;
49811 int error;
49812 };
49813 @@ -922,6 +929,10 @@ static int compat_filldir(void *__buf, const char *name, int namlen,
49814 buf->error = -EOVERFLOW;
49815 return -EOVERFLOW;
49816 }
49817 +
49818 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
49819 + return 0;
49820 +
49821 dirent = buf->previous;
49822 if (dirent) {
49823 if (__put_user(offset, &dirent->d_off))
49824 @@ -967,6 +978,7 @@ asmlinkage long compat_sys_getdents(unsigned int fd,
49825 buf.previous = NULL;
49826 buf.count = count;
49827 buf.error = 0;
49828 + buf.file = f.file;
49829
49830 error = vfs_readdir(f.file, compat_filldir, &buf);
49831 if (error >= 0)
49832 @@ -987,6 +999,7 @@ asmlinkage long compat_sys_getdents(unsigned int fd,
49833 struct compat_getdents_callback64 {
49834 struct linux_dirent64 __user *current_dir;
49835 struct linux_dirent64 __user *previous;
49836 + struct file * file;
49837 int count;
49838 int error;
49839 };
49840 @@ -1003,6 +1016,10 @@ static int compat_filldir64(void * __buf, const char * name, int namlen, loff_t
49841 buf->error = -EINVAL; /* only used if we fail.. */
49842 if (reclen > buf->count)
49843 return -EINVAL;
49844 +
49845 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
49846 + return 0;
49847 +
49848 dirent = buf->previous;
49849
49850 if (dirent) {
49851 @@ -1052,13 +1069,14 @@ asmlinkage long compat_sys_getdents64(unsigned int fd,
49852 buf.previous = NULL;
49853 buf.count = count;
49854 buf.error = 0;
49855 + buf.file = f.file;
49856
49857 error = vfs_readdir(f.file, compat_filldir64, &buf);
49858 if (error >= 0)
49859 error = buf.error;
49860 lastdirent = buf.previous;
49861 if (lastdirent) {
49862 - typeof(lastdirent->d_off) d_off = f.file->f_pos;
49863 + typeof(((struct linux_dirent64 *)0)->d_off) d_off = f.file->f_pos;
49864 if (__put_user_unaligned(d_off, &lastdirent->d_off))
49865 error = -EFAULT;
49866 else
49867 diff --git a/fs/compat_binfmt_elf.c b/fs/compat_binfmt_elf.c
49868 index a81147e..20bf2b5 100644
49869 --- a/fs/compat_binfmt_elf.c
49870 +++ b/fs/compat_binfmt_elf.c
49871 @@ -30,11 +30,13 @@
49872 #undef elf_phdr
49873 #undef elf_shdr
49874 #undef elf_note
49875 +#undef elf_dyn
49876 #undef elf_addr_t
49877 #define elfhdr elf32_hdr
49878 #define elf_phdr elf32_phdr
49879 #define elf_shdr elf32_shdr
49880 #define elf_note elf32_note
49881 +#define elf_dyn Elf32_Dyn
49882 #define elf_addr_t Elf32_Addr
49883
49884 /*
49885 diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
49886 index 3ced75f..b28d192 100644
49887 --- a/fs/compat_ioctl.c
49888 +++ b/fs/compat_ioctl.c
49889 @@ -623,7 +623,7 @@ static int serial_struct_ioctl(unsigned fd, unsigned cmd,
49890 return -EFAULT;
49891 if (__get_user(udata, &ss32->iomem_base))
49892 return -EFAULT;
49893 - ss.iomem_base = compat_ptr(udata);
49894 + ss.iomem_base = (unsigned char __force_kernel *)compat_ptr(udata);
49895 if (__get_user(ss.iomem_reg_shift, &ss32->iomem_reg_shift) ||
49896 __get_user(ss.port_high, &ss32->port_high))
49897 return -EFAULT;
49898 @@ -704,8 +704,8 @@ static int do_i2c_rdwr_ioctl(unsigned int fd, unsigned int cmd,
49899 for (i = 0; i < nmsgs; i++) {
49900 if (copy_in_user(&tmsgs[i].addr, &umsgs[i].addr, 3*sizeof(u16)))
49901 return -EFAULT;
49902 - if (get_user(datap, &umsgs[i].buf) ||
49903 - put_user(compat_ptr(datap), &tmsgs[i].buf))
49904 + if (get_user(datap, (u8 __user * __user *)&umsgs[i].buf) ||
49905 + put_user(compat_ptr(datap), (u8 __user * __user *)&tmsgs[i].buf))
49906 return -EFAULT;
49907 }
49908 return sys_ioctl(fd, cmd, (unsigned long)tdata);
49909 @@ -798,7 +798,7 @@ static int compat_ioctl_preallocate(struct file *file,
49910 copy_in_user(&p->l_len, &p32->l_len, sizeof(s64)) ||
49911 copy_in_user(&p->l_sysid, &p32->l_sysid, sizeof(s32)) ||
49912 copy_in_user(&p->l_pid, &p32->l_pid, sizeof(u32)) ||
49913 - copy_in_user(&p->l_pad, &p32->l_pad, 4*sizeof(u32)))
49914 + copy_in_user(p->l_pad, &p32->l_pad, 4*sizeof(u32)))
49915 return -EFAULT;
49916
49917 return ioctl_preallocate(file, p);
49918 @@ -1620,8 +1620,8 @@ asmlinkage long compat_sys_ioctl(unsigned int fd, unsigned int cmd,
49919 static int __init init_sys32_ioctl_cmp(const void *p, const void *q)
49920 {
49921 unsigned int a, b;
49922 - a = *(unsigned int *)p;
49923 - b = *(unsigned int *)q;
49924 + a = *(const unsigned int *)p;
49925 + b = *(const unsigned int *)q;
49926 if (a > b)
49927 return 1;
49928 if (a < b)
49929 diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c
49930 index 7aabc6a..34c1197 100644
49931 --- a/fs/configfs/dir.c
49932 +++ b/fs/configfs/dir.c
49933 @@ -1565,7 +1565,8 @@ static int configfs_readdir(struct file * filp, void * dirent, filldir_t filldir
49934 }
49935 for (p=q->next; p!= &parent_sd->s_children; p=p->next) {
49936 struct configfs_dirent *next;
49937 - const char * name;
49938 + const unsigned char * name;
49939 + char d_name[sizeof(next->s_dentry->d_iname)];
49940 int len;
49941 struct inode *inode = NULL;
49942
49943 @@ -1575,7 +1576,12 @@ static int configfs_readdir(struct file * filp, void * dirent, filldir_t filldir
49944 continue;
49945
49946 name = configfs_get_name(next);
49947 - len = strlen(name);
49948 + if (next->s_dentry && name == next->s_dentry->d_iname) {
49949 + len = next->s_dentry->d_name.len;
49950 + memcpy(d_name, name, len);
49951 + name = d_name;
49952 + } else
49953 + len = strlen(name);
49954
49955 /*
49956 * We'll have a dentry and an inode for
49957 diff --git a/fs/coredump.c b/fs/coredump.c
49958 index c647965..a77bff3 100644
49959 --- a/fs/coredump.c
49960 +++ b/fs/coredump.c
49961 @@ -52,7 +52,7 @@ struct core_name {
49962 char *corename;
49963 int used, size;
49964 };
49965 -static atomic_t call_count = ATOMIC_INIT(1);
49966 +static atomic_unchecked_t call_count = ATOMIC_INIT(1);
49967
49968 /* The maximal length of core_pattern is also specified in sysctl.c */
49969
49970 @@ -60,7 +60,7 @@ static int expand_corename(struct core_name *cn)
49971 {
49972 char *old_corename = cn->corename;
49973
49974 - cn->size = CORENAME_MAX_SIZE * atomic_inc_return(&call_count);
49975 + cn->size = CORENAME_MAX_SIZE * atomic_inc_return_unchecked(&call_count);
49976 cn->corename = krealloc(old_corename, cn->size, GFP_KERNEL);
49977
49978 if (!cn->corename) {
49979 @@ -157,7 +157,7 @@ static int format_corename(struct core_name *cn, struct coredump_params *cprm)
49980 int pid_in_pattern = 0;
49981 int err = 0;
49982
49983 - cn->size = CORENAME_MAX_SIZE * atomic_read(&call_count);
49984 + cn->size = CORENAME_MAX_SIZE * atomic_read_unchecked(&call_count);
49985 cn->corename = kmalloc(cn->size, GFP_KERNEL);
49986 cn->used = 0;
49987
49988 @@ -414,17 +414,17 @@ static void wait_for_dump_helpers(struct file *file)
49989 pipe = file_inode(file)->i_pipe;
49990
49991 pipe_lock(pipe);
49992 - pipe->readers++;
49993 - pipe->writers--;
49994 + atomic_inc(&pipe->readers);
49995 + atomic_dec(&pipe->writers);
49996
49997 - while ((pipe->readers > 1) && (!signal_pending(current))) {
49998 + while ((atomic_read(&pipe->readers) > 1) && (!signal_pending(current))) {
49999 wake_up_interruptible_sync(&pipe->wait);
50000 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
50001 pipe_wait(pipe);
50002 }
50003
50004 - pipe->readers--;
50005 - pipe->writers++;
50006 + atomic_dec(&pipe->readers);
50007 + atomic_inc(&pipe->writers);
50008 pipe_unlock(pipe);
50009
50010 }
50011 @@ -471,7 +471,8 @@ void do_coredump(siginfo_t *siginfo)
50012 int ispipe;
50013 struct files_struct *displaced;
50014 bool need_nonrelative = false;
50015 - static atomic_t core_dump_count = ATOMIC_INIT(0);
50016 + static atomic_unchecked_t core_dump_count = ATOMIC_INIT(0);
50017 + long signr = siginfo->si_signo;
50018 struct coredump_params cprm = {
50019 .siginfo = siginfo,
50020 .regs = signal_pt_regs(),
50021 @@ -484,7 +485,10 @@ void do_coredump(siginfo_t *siginfo)
50022 .mm_flags = mm->flags,
50023 };
50024
50025 - audit_core_dumps(siginfo->si_signo);
50026 + audit_core_dumps(signr);
50027 +
50028 + if (signr == SIGSEGV || signr == SIGBUS || signr == SIGKILL || signr == SIGILL)
50029 + gr_handle_brute_attach(cprm.mm_flags);
50030
50031 binfmt = mm->binfmt;
50032 if (!binfmt || !binfmt->core_dump)
50033 @@ -508,7 +512,7 @@ void do_coredump(siginfo_t *siginfo)
50034 need_nonrelative = true;
50035 }
50036
50037 - retval = coredump_wait(siginfo->si_signo, &core_state);
50038 + retval = coredump_wait(signr, &core_state);
50039 if (retval < 0)
50040 goto fail_creds;
50041
50042 @@ -556,7 +560,7 @@ void do_coredump(siginfo_t *siginfo)
50043 }
50044 cprm.limit = RLIM_INFINITY;
50045
50046 - dump_count = atomic_inc_return(&core_dump_count);
50047 + dump_count = atomic_inc_return_unchecked(&core_dump_count);
50048 if (core_pipe_limit && (core_pipe_limit < dump_count)) {
50049 printk(KERN_WARNING "Pid %d(%s) over core_pipe_limit\n",
50050 task_tgid_vnr(current), current->comm);
50051 @@ -583,6 +587,8 @@ void do_coredump(siginfo_t *siginfo)
50052 } else {
50053 struct inode *inode;
50054
50055 + gr_learn_resource(current, RLIMIT_CORE, binfmt->min_coredump, 1);
50056 +
50057 if (cprm.limit < binfmt->min_coredump)
50058 goto fail_unlock;
50059
50060 @@ -640,7 +646,7 @@ close_fail:
50061 filp_close(cprm.file, NULL);
50062 fail_dropcount:
50063 if (ispipe)
50064 - atomic_dec(&core_dump_count);
50065 + atomic_dec_unchecked(&core_dump_count);
50066 fail_unlock:
50067 kfree(cn.corename);
50068 fail_corename:
50069 @@ -659,7 +665,7 @@ fail:
50070 */
50071 int dump_write(struct file *file, const void *addr, int nr)
50072 {
50073 - return access_ok(VERIFY_READ, addr, nr) && file->f_op->write(file, addr, nr, &file->f_pos) == nr;
50074 + return access_ok(VERIFY_READ, addr, nr) && file->f_op->write(file, (const char __force_user *)addr, nr, &file->f_pos) == nr;
50075 }
50076 EXPORT_SYMBOL(dump_write);
50077
50078 diff --git a/fs/dcache.c b/fs/dcache.c
50079 index e689268..f36956e 100644
50080 --- a/fs/dcache.c
50081 +++ b/fs/dcache.c
50082 @@ -3100,7 +3100,7 @@ void __init vfs_caches_init(unsigned long mempages)
50083 mempages -= reserve;
50084
50085 names_cachep = kmem_cache_create("names_cache", PATH_MAX, 0,
50086 - SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
50087 + SLAB_HWCACHE_ALIGN|SLAB_PANIC|SLAB_USERCOPY, NULL);
50088
50089 dcache_init();
50090 inode_init();
50091 diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
50092 index 4888cb3..e0f7cf8 100644
50093 --- a/fs/debugfs/inode.c
50094 +++ b/fs/debugfs/inode.c
50095 @@ -415,7 +415,11 @@ EXPORT_SYMBOL_GPL(debugfs_create_file);
50096 */
50097 struct dentry *debugfs_create_dir(const char *name, struct dentry *parent)
50098 {
50099 +#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
50100 + return __create_file(name, S_IFDIR | S_IRWXU,
50101 +#else
50102 return __create_file(name, S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO,
50103 +#endif
50104 parent, NULL, NULL);
50105 }
50106 EXPORT_SYMBOL_GPL(debugfs_create_dir);
50107 diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
50108 index 5eab400..810a3f5 100644
50109 --- a/fs/ecryptfs/inode.c
50110 +++ b/fs/ecryptfs/inode.c
50111 @@ -674,7 +674,7 @@ static int ecryptfs_readlink_lower(struct dentry *dentry, char **buf,
50112 old_fs = get_fs();
50113 set_fs(get_ds());
50114 rc = lower_dentry->d_inode->i_op->readlink(lower_dentry,
50115 - (char __user *)lower_buf,
50116 + (char __force_user *)lower_buf,
50117 PATH_MAX);
50118 set_fs(old_fs);
50119 if (rc < 0)
50120 @@ -706,7 +706,7 @@ out:
50121 static void
50122 ecryptfs_put_link(struct dentry *dentry, struct nameidata *nd, void *ptr)
50123 {
50124 - char *buf = nd_get_link(nd);
50125 + const char *buf = nd_get_link(nd);
50126 if (!IS_ERR(buf)) {
50127 /* Free the char* */
50128 kfree(buf);
50129 diff --git a/fs/ecryptfs/miscdev.c b/fs/ecryptfs/miscdev.c
50130 index e4141f2..d8263e8 100644
50131 --- a/fs/ecryptfs/miscdev.c
50132 +++ b/fs/ecryptfs/miscdev.c
50133 @@ -304,7 +304,7 @@ check_list:
50134 goto out_unlock_msg_ctx;
50135 i = PKT_TYPE_SIZE + PKT_CTR_SIZE;
50136 if (msg_ctx->msg) {
50137 - if (copy_to_user(&buf[i], packet_length, packet_length_size))
50138 + if (packet_length_size > sizeof(packet_length) || copy_to_user(&buf[i], packet_length, packet_length_size))
50139 goto out_unlock_msg_ctx;
50140 i += packet_length_size;
50141 if (copy_to_user(&buf[i], msg_ctx->msg, msg_ctx->msg_size))
50142 diff --git a/fs/ecryptfs/read_write.c b/fs/ecryptfs/read_write.c
50143 index 6a16053..2155147 100644
50144 --- a/fs/ecryptfs/read_write.c
50145 +++ b/fs/ecryptfs/read_write.c
50146 @@ -240,7 +240,7 @@ int ecryptfs_read_lower(char *data, loff_t offset, size_t size,
50147 return -EIO;
50148 fs_save = get_fs();
50149 set_fs(get_ds());
50150 - rc = vfs_read(lower_file, data, size, &offset);
50151 + rc = vfs_read(lower_file, (char __force_user *)data, size, &offset);
50152 set_fs(fs_save);
50153 return rc;
50154 }
50155 diff --git a/fs/exec.c b/fs/exec.c
50156 index 6d56ff2..3bc6638 100644
50157 --- a/fs/exec.c
50158 +++ b/fs/exec.c
50159 @@ -55,8 +55,20 @@
50160 #include <linux/pipe_fs_i.h>
50161 #include <linux/oom.h>
50162 #include <linux/compat.h>
50163 +#include <linux/random.h>
50164 +#include <linux/seq_file.h>
50165 +#include <linux/coredump.h>
50166 +#include <linux/mman.h>
50167 +
50168 +#ifdef CONFIG_PAX_REFCOUNT
50169 +#include <linux/kallsyms.h>
50170 +#include <linux/kdebug.h>
50171 +#endif
50172 +
50173 +#include <trace/events/fs.h>
50174
50175 #include <asm/uaccess.h>
50176 +#include <asm/sections.h>
50177 #include <asm/mmu_context.h>
50178 #include <asm/tlb.h>
50179
50180 @@ -66,6 +78,18 @@
50181
50182 #include <trace/events/sched.h>
50183
50184 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
50185 +void __weak pax_set_initial_flags(struct linux_binprm *bprm)
50186 +{
50187 + 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");
50188 +}
50189 +#endif
50190 +
50191 +#ifdef CONFIG_PAX_HOOK_ACL_FLAGS
50192 +void (*pax_set_initial_flags_func)(struct linux_binprm *bprm);
50193 +EXPORT_SYMBOL(pax_set_initial_flags_func);
50194 +#endif
50195 +
50196 int suid_dumpable = 0;
50197
50198 static LIST_HEAD(formats);
50199 @@ -75,8 +99,8 @@ void __register_binfmt(struct linux_binfmt * fmt, int insert)
50200 {
50201 BUG_ON(!fmt);
50202 write_lock(&binfmt_lock);
50203 - insert ? list_add(&fmt->lh, &formats) :
50204 - list_add_tail(&fmt->lh, &formats);
50205 + insert ? pax_list_add((struct list_head *)&fmt->lh, &formats) :
50206 + pax_list_add_tail((struct list_head *)&fmt->lh, &formats);
50207 write_unlock(&binfmt_lock);
50208 }
50209
50210 @@ -85,7 +109,7 @@ EXPORT_SYMBOL(__register_binfmt);
50211 void unregister_binfmt(struct linux_binfmt * fmt)
50212 {
50213 write_lock(&binfmt_lock);
50214 - list_del(&fmt->lh);
50215 + pax_list_del((struct list_head *)&fmt->lh);
50216 write_unlock(&binfmt_lock);
50217 }
50218
50219 @@ -180,18 +204,10 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
50220 int write)
50221 {
50222 struct page *page;
50223 - int ret;
50224
50225 -#ifdef CONFIG_STACK_GROWSUP
50226 - if (write) {
50227 - ret = expand_downwards(bprm->vma, pos);
50228 - if (ret < 0)
50229 - return NULL;
50230 - }
50231 -#endif
50232 - ret = get_user_pages(current, bprm->mm, pos,
50233 - 1, write, 1, &page, NULL);
50234 - if (ret <= 0)
50235 + if (0 > expand_downwards(bprm->vma, pos))
50236 + return NULL;
50237 + if (0 >= get_user_pages(current, bprm->mm, pos, 1, write, 1, &page, NULL))
50238 return NULL;
50239
50240 if (write) {
50241 @@ -207,6 +223,17 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
50242 if (size <= ARG_MAX)
50243 return page;
50244
50245 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
50246 + // only allow 512KB for argv+env on suid/sgid binaries
50247 + // to prevent easy ASLR exhaustion
50248 + if (((!uid_eq(bprm->cred->euid, current_euid())) ||
50249 + (!gid_eq(bprm->cred->egid, current_egid()))) &&
50250 + (size > (512 * 1024))) {
50251 + put_page(page);
50252 + return NULL;
50253 + }
50254 +#endif
50255 +
50256 /*
50257 * Limit to 1/4-th the stack size for the argv+env strings.
50258 * This ensures that:
50259 @@ -266,6 +293,11 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
50260 vma->vm_end = STACK_TOP_MAX;
50261 vma->vm_start = vma->vm_end - PAGE_SIZE;
50262 vma->vm_flags = VM_STACK_FLAGS | VM_STACK_INCOMPLETE_SETUP;
50263 +
50264 +#ifdef CONFIG_PAX_SEGMEXEC
50265 + vma->vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
50266 +#endif
50267 +
50268 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
50269 INIT_LIST_HEAD(&vma->anon_vma_chain);
50270
50271 @@ -276,6 +308,12 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
50272 mm->stack_vm = mm->total_vm = 1;
50273 up_write(&mm->mmap_sem);
50274 bprm->p = vma->vm_end - sizeof(void *);
50275 +
50276 +#ifdef CONFIG_PAX_RANDUSTACK
50277 + if (randomize_va_space)
50278 + bprm->p ^= random32() & ~PAGE_MASK;
50279 +#endif
50280 +
50281 return 0;
50282 err:
50283 up_write(&mm->mmap_sem);
50284 @@ -396,7 +434,7 @@ struct user_arg_ptr {
50285 } ptr;
50286 };
50287
50288 -static const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
50289 +const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
50290 {
50291 const char __user *native;
50292
50293 @@ -405,14 +443,14 @@ static const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
50294 compat_uptr_t compat;
50295
50296 if (get_user(compat, argv.ptr.compat + nr))
50297 - return ERR_PTR(-EFAULT);
50298 + return (const char __force_user *)ERR_PTR(-EFAULT);
50299
50300 return compat_ptr(compat);
50301 }
50302 #endif
50303
50304 if (get_user(native, argv.ptr.native + nr))
50305 - return ERR_PTR(-EFAULT);
50306 + return (const char __force_user *)ERR_PTR(-EFAULT);
50307
50308 return native;
50309 }
50310 @@ -431,7 +469,7 @@ static int count(struct user_arg_ptr argv, int max)
50311 if (!p)
50312 break;
50313
50314 - if (IS_ERR(p))
50315 + if (IS_ERR((const char __force_kernel *)p))
50316 return -EFAULT;
50317
50318 if (i >= max)
50319 @@ -466,7 +504,7 @@ static int copy_strings(int argc, struct user_arg_ptr argv,
50320
50321 ret = -EFAULT;
50322 str = get_user_arg_ptr(argv, argc);
50323 - if (IS_ERR(str))
50324 + if (IS_ERR((const char __force_kernel *)str))
50325 goto out;
50326
50327 len = strnlen_user(str, MAX_ARG_STRLEN);
50328 @@ -548,7 +586,7 @@ int copy_strings_kernel(int argc, const char *const *__argv,
50329 int r;
50330 mm_segment_t oldfs = get_fs();
50331 struct user_arg_ptr argv = {
50332 - .ptr.native = (const char __user *const __user *)__argv,
50333 + .ptr.native = (const char __force_user * const __force_user *)__argv,
50334 };
50335
50336 set_fs(KERNEL_DS);
50337 @@ -583,7 +621,8 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
50338 unsigned long new_end = old_end - shift;
50339 struct mmu_gather tlb;
50340
50341 - BUG_ON(new_start > new_end);
50342 + if (new_start >= new_end || new_start < mmap_min_addr)
50343 + return -ENOMEM;
50344
50345 /*
50346 * ensure there are no vmas between where we want to go
50347 @@ -592,6 +631,10 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
50348 if (vma != find_vma(mm, new_start))
50349 return -EFAULT;
50350
50351 +#ifdef CONFIG_PAX_SEGMEXEC
50352 + BUG_ON(pax_find_mirror_vma(vma));
50353 +#endif
50354 +
50355 /*
50356 * cover the whole range: [new_start, old_end)
50357 */
50358 @@ -672,10 +715,6 @@ int setup_arg_pages(struct linux_binprm *bprm,
50359 stack_top = arch_align_stack(stack_top);
50360 stack_top = PAGE_ALIGN(stack_top);
50361
50362 - if (unlikely(stack_top < mmap_min_addr) ||
50363 - unlikely(vma->vm_end - vma->vm_start >= stack_top - mmap_min_addr))
50364 - return -ENOMEM;
50365 -
50366 stack_shift = vma->vm_end - stack_top;
50367
50368 bprm->p -= stack_shift;
50369 @@ -687,8 +726,28 @@ int setup_arg_pages(struct linux_binprm *bprm,
50370 bprm->exec -= stack_shift;
50371
50372 down_write(&mm->mmap_sem);
50373 +
50374 + /* Move stack pages down in memory. */
50375 + if (stack_shift) {
50376 + ret = shift_arg_pages(vma, stack_shift);
50377 + if (ret)
50378 + goto out_unlock;
50379 + }
50380 +
50381 vm_flags = VM_STACK_FLAGS;
50382
50383 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
50384 + if (mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
50385 + vm_flags &= ~VM_EXEC;
50386 +
50387 +#ifdef CONFIG_PAX_MPROTECT
50388 + if (mm->pax_flags & MF_PAX_MPROTECT)
50389 + vm_flags &= ~VM_MAYEXEC;
50390 +#endif
50391 +
50392 + }
50393 +#endif
50394 +
50395 /*
50396 * Adjust stack execute permissions; explicitly enable for
50397 * EXSTACK_ENABLE_X, disable for EXSTACK_DISABLE_X and leave alone
50398 @@ -707,13 +766,6 @@ int setup_arg_pages(struct linux_binprm *bprm,
50399 goto out_unlock;
50400 BUG_ON(prev != vma);
50401
50402 - /* Move stack pages down in memory. */
50403 - if (stack_shift) {
50404 - ret = shift_arg_pages(vma, stack_shift);
50405 - if (ret)
50406 - goto out_unlock;
50407 - }
50408 -
50409 /* mprotect_fixup is overkill to remove the temporary stack flags */
50410 vma->vm_flags &= ~VM_STACK_INCOMPLETE_SETUP;
50411
50412 @@ -737,6 +789,27 @@ int setup_arg_pages(struct linux_binprm *bprm,
50413 #endif
50414 current->mm->start_stack = bprm->p;
50415 ret = expand_stack(vma, stack_base);
50416 +
50417 +#if !defined(CONFIG_STACK_GROWSUP) && defined(CONFIG_PAX_RANDMMAP)
50418 + if (!ret && (mm->pax_flags & MF_PAX_RANDMMAP) && STACK_TOP <= 0xFFFFFFFFU && STACK_TOP > vma->vm_end) {
50419 + unsigned long size;
50420 + vm_flags_t vm_flags;
50421 +
50422 + size = STACK_TOP - vma->vm_end;
50423 + vm_flags = VM_NONE | VM_DONTEXPAND | VM_DONTDUMP;
50424 +
50425 + ret = vma->vm_end != mmap_region(NULL, vma->vm_end, size, vm_flags, 0);
50426 +
50427 +#ifdef CONFIG_X86
50428 + if (!ret) {
50429 + size = mmap_min_addr + ((mm->delta_mmap ^ mm->delta_stack) & (0xFFUL << PAGE_SHIFT));
50430 + ret = 0 != mmap_region(NULL, 0, PAGE_ALIGN(size), vm_flags, 0);
50431 + }
50432 +#endif
50433 +
50434 + }
50435 +#endif
50436 +
50437 if (ret)
50438 ret = -EFAULT;
50439
50440 @@ -772,6 +845,8 @@ struct file *open_exec(const char *name)
50441
50442 fsnotify_open(file);
50443
50444 + trace_open_exec(name);
50445 +
50446 err = deny_write_access(file);
50447 if (err)
50448 goto exit;
50449 @@ -795,7 +870,7 @@ int kernel_read(struct file *file, loff_t offset,
50450 old_fs = get_fs();
50451 set_fs(get_ds());
50452 /* The cast to a user pointer is valid due to the set_fs() */
50453 - result = vfs_read(file, (void __user *)addr, count, &pos);
50454 + result = vfs_read(file, (void __force_user *)addr, count, &pos);
50455 set_fs(old_fs);
50456 return result;
50457 }
50458 @@ -1250,7 +1325,7 @@ static int check_unsafe_exec(struct linux_binprm *bprm)
50459 }
50460 rcu_read_unlock();
50461
50462 - if (p->fs->users > n_fs) {
50463 + if (atomic_read(&p->fs->users) > n_fs) {
50464 bprm->unsafe |= LSM_UNSAFE_SHARE;
50465 } else {
50466 res = -EAGAIN;
50467 @@ -1450,6 +1525,31 @@ int search_binary_handler(struct linux_binprm *bprm)
50468
50469 EXPORT_SYMBOL(search_binary_handler);
50470
50471 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
50472 +static DEFINE_PER_CPU(u64, exec_counter);
50473 +static int __init init_exec_counters(void)
50474 +{
50475 + unsigned int cpu;
50476 +
50477 + for_each_possible_cpu(cpu) {
50478 + per_cpu(exec_counter, cpu) = (u64)cpu;
50479 + }
50480 +
50481 + return 0;
50482 +}
50483 +early_initcall(init_exec_counters);
50484 +static inline void increment_exec_counter(void)
50485 +{
50486 + BUILD_BUG_ON(NR_CPUS > (1 << 16));
50487 + current->exec_id = this_cpu_add_return(exec_counter, 1 << 16);
50488 +}
50489 +#else
50490 +static inline void increment_exec_counter(void) {}
50491 +#endif
50492 +
50493 +extern void gr_handle_exec_args(struct linux_binprm *bprm,
50494 + struct user_arg_ptr argv);
50495 +
50496 /*
50497 * sys_execve() executes a new program.
50498 */
50499 @@ -1457,6 +1557,11 @@ static int do_execve_common(const char *filename,
50500 struct user_arg_ptr argv,
50501 struct user_arg_ptr envp)
50502 {
50503 +#ifdef CONFIG_GRKERNSEC
50504 + struct file *old_exec_file;
50505 + struct acl_subject_label *old_acl;
50506 + struct rlimit old_rlim[RLIM_NLIMITS];
50507 +#endif
50508 struct linux_binprm *bprm;
50509 struct file *file;
50510 struct files_struct *displaced;
50511 @@ -1464,6 +1569,8 @@ static int do_execve_common(const char *filename,
50512 int retval;
50513 const struct cred *cred = current_cred();
50514
50515 + gr_learn_resource(current, RLIMIT_NPROC, atomic_read(&cred->user->processes), 1);
50516 +
50517 /*
50518 * We move the actual failure in case of RLIMIT_NPROC excess from
50519 * set*uid() to execve() because too many poorly written programs
50520 @@ -1504,12 +1611,27 @@ static int do_execve_common(const char *filename,
50521 if (IS_ERR(file))
50522 goto out_unmark;
50523
50524 + if (gr_ptrace_readexec(file, bprm->unsafe)) {
50525 + retval = -EPERM;
50526 + goto out_file;
50527 + }
50528 +
50529 sched_exec();
50530
50531 bprm->file = file;
50532 bprm->filename = filename;
50533 bprm->interp = filename;
50534
50535 + if (gr_process_user_ban()) {
50536 + retval = -EPERM;
50537 + goto out_file;
50538 + }
50539 +
50540 + if (!gr_acl_handle_execve(file->f_path.dentry, file->f_path.mnt)) {
50541 + retval = -EACCES;
50542 + goto out_file;
50543 + }
50544 +
50545 retval = bprm_mm_init(bprm);
50546 if (retval)
50547 goto out_file;
50548 @@ -1526,24 +1648,65 @@ static int do_execve_common(const char *filename,
50549 if (retval < 0)
50550 goto out;
50551
50552 +#ifdef CONFIG_GRKERNSEC
50553 + old_acl = current->acl;
50554 + memcpy(old_rlim, current->signal->rlim, sizeof(old_rlim));
50555 + old_exec_file = current->exec_file;
50556 + get_file(file);
50557 + current->exec_file = file;
50558 +#endif
50559 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
50560 + /* limit suid stack to 8MB
50561 + * we saved the old limits above and will restore them if this exec fails
50562 + */
50563 + if (((!uid_eq(bprm->cred->euid, current_euid())) || (!gid_eq(bprm->cred->egid, current_egid()))) &&
50564 + (old_rlim[RLIMIT_STACK].rlim_cur > (8 * 1024 * 1024)))
50565 + current->signal->rlim[RLIMIT_STACK].rlim_cur = 8 * 1024 * 1024;
50566 +#endif
50567 +
50568 + if (!gr_tpe_allow(file)) {
50569 + retval = -EACCES;
50570 + goto out_fail;
50571 + }
50572 +
50573 + if (gr_check_crash_exec(file)) {
50574 + retval = -EACCES;
50575 + goto out_fail;
50576 + }
50577 +
50578 + retval = gr_set_proc_label(file->f_path.dentry, file->f_path.mnt,
50579 + bprm->unsafe);
50580 + if (retval < 0)
50581 + goto out_fail;
50582 +
50583 retval = copy_strings_kernel(1, &bprm->filename, bprm);
50584 if (retval < 0)
50585 - goto out;
50586 + goto out_fail;
50587
50588 bprm->exec = bprm->p;
50589 retval = copy_strings(bprm->envc, envp, bprm);
50590 if (retval < 0)
50591 - goto out;
50592 + goto out_fail;
50593
50594 retval = copy_strings(bprm->argc, argv, bprm);
50595 if (retval < 0)
50596 - goto out;
50597 + goto out_fail;
50598 +
50599 + gr_log_chroot_exec(file->f_path.dentry, file->f_path.mnt);
50600 +
50601 + gr_handle_exec_args(bprm, argv);
50602
50603 retval = search_binary_handler(bprm);
50604 if (retval < 0)
50605 - goto out;
50606 + goto out_fail;
50607 +#ifdef CONFIG_GRKERNSEC
50608 + if (old_exec_file)
50609 + fput(old_exec_file);
50610 +#endif
50611
50612 /* execve succeeded */
50613 +
50614 + increment_exec_counter();
50615 current->fs->in_exec = 0;
50616 current->in_execve = 0;
50617 acct_update_integrals(current);
50618 @@ -1552,6 +1715,14 @@ static int do_execve_common(const char *filename,
50619 put_files_struct(displaced);
50620 return retval;
50621
50622 +out_fail:
50623 +#ifdef CONFIG_GRKERNSEC
50624 + current->acl = old_acl;
50625 + memcpy(current->signal->rlim, old_rlim, sizeof(old_rlim));
50626 + fput(current->exec_file);
50627 + current->exec_file = old_exec_file;
50628 +#endif
50629 +
50630 out:
50631 if (bprm->mm) {
50632 acct_arg_size(bprm, 0);
50633 @@ -1700,3 +1871,283 @@ asmlinkage long compat_sys_execve(const char __user * filename,
50634 return error;
50635 }
50636 #endif
50637 +
50638 +int pax_check_flags(unsigned long *flags)
50639 +{
50640 + int retval = 0;
50641 +
50642 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_SEGMEXEC)
50643 + if (*flags & MF_PAX_SEGMEXEC)
50644 + {
50645 + *flags &= ~MF_PAX_SEGMEXEC;
50646 + retval = -EINVAL;
50647 + }
50648 +#endif
50649 +
50650 + if ((*flags & MF_PAX_PAGEEXEC)
50651 +
50652 +#ifdef CONFIG_PAX_PAGEEXEC
50653 + && (*flags & MF_PAX_SEGMEXEC)
50654 +#endif
50655 +
50656 + )
50657 + {
50658 + *flags &= ~MF_PAX_PAGEEXEC;
50659 + retval = -EINVAL;
50660 + }
50661 +
50662 + if ((*flags & MF_PAX_MPROTECT)
50663 +
50664 +#ifdef CONFIG_PAX_MPROTECT
50665 + && !(*flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC))
50666 +#endif
50667 +
50668 + )
50669 + {
50670 + *flags &= ~MF_PAX_MPROTECT;
50671 + retval = -EINVAL;
50672 + }
50673 +
50674 + if ((*flags & MF_PAX_EMUTRAMP)
50675 +
50676 +#ifdef CONFIG_PAX_EMUTRAMP
50677 + && !(*flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC))
50678 +#endif
50679 +
50680 + )
50681 + {
50682 + *flags &= ~MF_PAX_EMUTRAMP;
50683 + retval = -EINVAL;
50684 + }
50685 +
50686 + return retval;
50687 +}
50688 +
50689 +EXPORT_SYMBOL(pax_check_flags);
50690 +
50691 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
50692 +void pax_report_fault(struct pt_regs *regs, void *pc, void *sp)
50693 +{
50694 + struct task_struct *tsk = current;
50695 + struct mm_struct *mm = current->mm;
50696 + char *buffer_exec = (char *)__get_free_page(GFP_KERNEL);
50697 + char *buffer_fault = (char *)__get_free_page(GFP_KERNEL);
50698 + char *path_exec = NULL;
50699 + char *path_fault = NULL;
50700 + unsigned long start = 0UL, end = 0UL, offset = 0UL;
50701 + siginfo_t info = { };
50702 +
50703 + if (buffer_exec && buffer_fault) {
50704 + struct vm_area_struct *vma, *vma_exec = NULL, *vma_fault = NULL;
50705 +
50706 + down_read(&mm->mmap_sem);
50707 + vma = mm->mmap;
50708 + while (vma && (!vma_exec || !vma_fault)) {
50709 + if (vma->vm_file && mm->exe_file == vma->vm_file && (vma->vm_flags & VM_EXEC))
50710 + vma_exec = vma;
50711 + if (vma->vm_start <= (unsigned long)pc && (unsigned long)pc < vma->vm_end)
50712 + vma_fault = vma;
50713 + vma = vma->vm_next;
50714 + }
50715 + if (vma_exec) {
50716 + path_exec = d_path(&vma_exec->vm_file->f_path, buffer_exec, PAGE_SIZE);
50717 + if (IS_ERR(path_exec))
50718 + path_exec = "<path too long>";
50719 + else {
50720 + path_exec = mangle_path(buffer_exec, path_exec, "\t\n\\");
50721 + if (path_exec) {
50722 + *path_exec = 0;
50723 + path_exec = buffer_exec;
50724 + } else
50725 + path_exec = "<path too long>";
50726 + }
50727 + }
50728 + if (vma_fault) {
50729 + start = vma_fault->vm_start;
50730 + end = vma_fault->vm_end;
50731 + offset = vma_fault->vm_pgoff << PAGE_SHIFT;
50732 + if (vma_fault->vm_file) {
50733 + path_fault = d_path(&vma_fault->vm_file->f_path, buffer_fault, PAGE_SIZE);
50734 + if (IS_ERR(path_fault))
50735 + path_fault = "<path too long>";
50736 + else {
50737 + path_fault = mangle_path(buffer_fault, path_fault, "\t\n\\");
50738 + if (path_fault) {
50739 + *path_fault = 0;
50740 + path_fault = buffer_fault;
50741 + } else
50742 + path_fault = "<path too long>";
50743 + }
50744 + } else
50745 + path_fault = "<anonymous mapping>";
50746 + }
50747 + up_read(&mm->mmap_sem);
50748 + }
50749 + if (tsk->signal->curr_ip)
50750 + printk(KERN_ERR "PAX: From %pI4: execution attempt in: %s, %08lx-%08lx %08lx\n", &tsk->signal->curr_ip, path_fault, start, end, offset);
50751 + else
50752 + printk(KERN_ERR "PAX: execution attempt in: %s, %08lx-%08lx %08lx\n", path_fault, start, end, offset);
50753 + 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),
50754 + from_kuid_munged(&init_user_ns, task_uid(tsk)), from_kuid_munged(&init_user_ns, task_euid(tsk)), pc, sp);
50755 + free_page((unsigned long)buffer_exec);
50756 + free_page((unsigned long)buffer_fault);
50757 + pax_report_insns(regs, pc, sp);
50758 + info.si_signo = SIGKILL;
50759 + info.si_errno = 0;
50760 + info.si_code = SI_KERNEL;
50761 + info.si_pid = 0;
50762 + info.si_uid = 0;
50763 + do_coredump(&info);
50764 +}
50765 +#endif
50766 +
50767 +#ifdef CONFIG_PAX_REFCOUNT
50768 +void pax_report_refcount_overflow(struct pt_regs *regs)
50769 +{
50770 + if (current->signal->curr_ip)
50771 + printk(KERN_ERR "PAX: From %pI4: refcount overflow detected in: %s:%d, uid/euid: %u/%u\n",
50772 + &current->signal->curr_ip, current->comm, task_pid_nr(current),
50773 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
50774 + else
50775 + printk(KERN_ERR "PAX: refcount overflow detected in: %s:%d, uid/euid: %u/%u\n", current->comm, task_pid_nr(current),
50776 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
50777 + print_symbol(KERN_ERR "PAX: refcount overflow occured at: %s\n", instruction_pointer(regs));
50778 + show_regs(regs);
50779 + force_sig_info(SIGKILL, SEND_SIG_FORCED, current);
50780 +}
50781 +#endif
50782 +
50783 +#ifdef CONFIG_PAX_USERCOPY
50784 +/* 0: not at all, 1: fully, 2: fully inside frame, -1: partially (implies an error) */
50785 +static noinline int check_stack_object(const void *obj, unsigned long len)
50786 +{
50787 + const void * const stack = task_stack_page(current);
50788 + const void * const stackend = stack + THREAD_SIZE;
50789 +
50790 +#if defined(CONFIG_FRAME_POINTER) && defined(CONFIG_X86)
50791 + const void *frame = NULL;
50792 + const void *oldframe;
50793 +#endif
50794 +
50795 + if (obj + len < obj)
50796 + return -1;
50797 +
50798 + if (obj + len <= stack || stackend <= obj)
50799 + return 0;
50800 +
50801 + if (obj < stack || stackend < obj + len)
50802 + return -1;
50803 +
50804 +#if defined(CONFIG_FRAME_POINTER) && defined(CONFIG_X86)
50805 + oldframe = __builtin_frame_address(1);
50806 + if (oldframe)
50807 + frame = __builtin_frame_address(2);
50808 + /*
50809 + low ----------------------------------------------> high
50810 + [saved bp][saved ip][args][local vars][saved bp][saved ip]
50811 + ^----------------^
50812 + allow copies only within here
50813 + */
50814 + while (stack <= frame && frame < stackend) {
50815 + /* if obj + len extends past the last frame, this
50816 + check won't pass and the next frame will be 0,
50817 + causing us to bail out and correctly report
50818 + the copy as invalid
50819 + */
50820 + if (obj + len <= frame)
50821 + return obj >= oldframe + 2 * sizeof(void *) ? 2 : -1;
50822 + oldframe = frame;
50823 + frame = *(const void * const *)frame;
50824 + }
50825 + return -1;
50826 +#else
50827 + return 1;
50828 +#endif
50829 +}
50830 +
50831 +static __noreturn void pax_report_usercopy(const void *ptr, unsigned long len, bool to_user, const char *type)
50832 +{
50833 + if (current->signal->curr_ip)
50834 + printk(KERN_ERR "PAX: From %pI4: kernel memory %s attempt detected %s %p (%s) (%lu bytes)\n",
50835 + &current->signal->curr_ip, to_user ? "leak" : "overwrite", to_user ? "from" : "to", ptr, type ? : "unknown", len);
50836 + else
50837 + printk(KERN_ERR "PAX: kernel memory %s attempt detected %s %p (%s) (%lu bytes)\n",
50838 + to_user ? "leak" : "overwrite", to_user ? "from" : "to", ptr, type ? : "unknown", len);
50839 + dump_stack();
50840 + gr_handle_kernel_exploit();
50841 + do_group_exit(SIGKILL);
50842 +}
50843 +#endif
50844 +
50845 +#ifdef CONFIG_PAX_USERCOPY
50846 +static inline bool check_kernel_text_object(unsigned long low, unsigned long high)
50847 +{
50848 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
50849 + unsigned long textlow = ktla_ktva((unsigned long)_stext);
50850 +#ifdef CONFIG_MODULES
50851 + unsigned long texthigh = (unsigned long)MODULES_EXEC_VADDR;
50852 +#else
50853 + unsigned long texthigh = ktla_ktva((unsigned long)_etext);
50854 +#endif
50855 +
50856 +#else
50857 + unsigned long textlow = (unsigned long)_stext;
50858 + unsigned long texthigh = (unsigned long)_etext;
50859 +#endif
50860 +
50861 + if (high <= textlow || low > texthigh)
50862 + return false;
50863 + else
50864 + return true;
50865 +}
50866 +#endif
50867 +
50868 +void __check_object_size(const void *ptr, unsigned long n, bool to_user)
50869 +{
50870 +
50871 +#ifdef CONFIG_PAX_USERCOPY
50872 + const char *type;
50873 +
50874 + if (!n)
50875 + return;
50876 +
50877 + type = check_heap_object(ptr, n);
50878 + if (!type) {
50879 + int ret = check_stack_object(ptr, n);
50880 + if (ret == 1 || ret == 2)
50881 + return;
50882 + if (ret == 0) {
50883 + if (check_kernel_text_object((unsigned long)ptr, (unsigned long)ptr + n))
50884 + type = "<kernel text>";
50885 + else
50886 + return;
50887 + } else
50888 + type = "<process stack>";
50889 + }
50890 +
50891 + pax_report_usercopy(ptr, n, to_user, type);
50892 +#endif
50893 +
50894 +}
50895 +EXPORT_SYMBOL(__check_object_size);
50896 +
50897 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
50898 +void pax_track_stack(void)
50899 +{
50900 + unsigned long sp = (unsigned long)&sp;
50901 + if (sp < current_thread_info()->lowest_stack &&
50902 + sp > (unsigned long)task_stack_page(current))
50903 + current_thread_info()->lowest_stack = sp;
50904 +}
50905 +EXPORT_SYMBOL(pax_track_stack);
50906 +#endif
50907 +
50908 +#ifdef CONFIG_PAX_SIZE_OVERFLOW
50909 +void report_size_overflow(const char *file, unsigned int line, const char *func, const char *ssa_name)
50910 +{
50911 + printk(KERN_ERR "PAX: size overflow detected in function %s %s:%u %s", func, file, line, ssa_name);
50912 + dump_stack();
50913 + do_group_exit(SIGKILL);
50914 +}
50915 +EXPORT_SYMBOL(report_size_overflow);
50916 +#endif
50917 diff --git a/fs/ext2/balloc.c b/fs/ext2/balloc.c
50918 index 9f9992b..8b59411 100644
50919 --- a/fs/ext2/balloc.c
50920 +++ b/fs/ext2/balloc.c
50921 @@ -1184,10 +1184,10 @@ static int ext2_has_free_blocks(struct ext2_sb_info *sbi)
50922
50923 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
50924 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
50925 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
50926 + if (free_blocks < root_blocks + 1 &&
50927 !uid_eq(sbi->s_resuid, current_fsuid()) &&
50928 (gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) ||
50929 - !in_group_p (sbi->s_resgid))) {
50930 + !in_group_p (sbi->s_resgid)) && !capable_nolog(CAP_SYS_RESOURCE)) {
50931 return 0;
50932 }
50933 return 1;
50934 diff --git a/fs/ext3/balloc.c b/fs/ext3/balloc.c
50935 index 22548f5..41521d8 100644
50936 --- a/fs/ext3/balloc.c
50937 +++ b/fs/ext3/balloc.c
50938 @@ -1438,10 +1438,10 @@ static int ext3_has_free_blocks(struct ext3_sb_info *sbi, int use_reservation)
50939
50940 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
50941 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
50942 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
50943 + if (free_blocks < root_blocks + 1 &&
50944 !use_reservation && !uid_eq(sbi->s_resuid, current_fsuid()) &&
50945 (gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) ||
50946 - !in_group_p (sbi->s_resgid))) {
50947 + !in_group_p (sbi->s_resgid)) && !capable_nolog(CAP_SYS_RESOURCE)) {
50948 return 0;
50949 }
50950 return 1;
50951 diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c
50952 index 92e68b3..115d987 100644
50953 --- a/fs/ext4/balloc.c
50954 +++ b/fs/ext4/balloc.c
50955 @@ -505,8 +505,8 @@ static int ext4_has_free_clusters(struct ext4_sb_info *sbi,
50956 /* Hm, nope. Are (enough) root reserved clusters available? */
50957 if (uid_eq(sbi->s_resuid, current_fsuid()) ||
50958 (!gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) && in_group_p(sbi->s_resgid)) ||
50959 - capable(CAP_SYS_RESOURCE) ||
50960 - (flags & EXT4_MB_USE_ROOT_BLOCKS)) {
50961 + (flags & EXT4_MB_USE_ROOT_BLOCKS) ||
50962 + capable_nolog(CAP_SYS_RESOURCE)) {
50963
50964 if (free_clusters >= (nclusters + dirty_clusters))
50965 return 1;
50966 diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
50967 index 3b83cd6..0f34dcd 100644
50968 --- a/fs/ext4/ext4.h
50969 +++ b/fs/ext4/ext4.h
50970 @@ -1254,19 +1254,19 @@ struct ext4_sb_info {
50971 unsigned long s_mb_last_start;
50972
50973 /* stats for buddy allocator */
50974 - atomic_t s_bal_reqs; /* number of reqs with len > 1 */
50975 - atomic_t s_bal_success; /* we found long enough chunks */
50976 - atomic_t s_bal_allocated; /* in blocks */
50977 - atomic_t s_bal_ex_scanned; /* total extents scanned */
50978 - atomic_t s_bal_goals; /* goal hits */
50979 - atomic_t s_bal_breaks; /* too long searches */
50980 - atomic_t s_bal_2orders; /* 2^order hits */
50981 + atomic_unchecked_t s_bal_reqs; /* number of reqs with len > 1 */
50982 + atomic_unchecked_t s_bal_success; /* we found long enough chunks */
50983 + atomic_unchecked_t s_bal_allocated; /* in blocks */
50984 + atomic_unchecked_t s_bal_ex_scanned; /* total extents scanned */
50985 + atomic_unchecked_t s_bal_goals; /* goal hits */
50986 + atomic_unchecked_t s_bal_breaks; /* too long searches */
50987 + atomic_unchecked_t s_bal_2orders; /* 2^order hits */
50988 spinlock_t s_bal_lock;
50989 unsigned long s_mb_buddies_generated;
50990 unsigned long long s_mb_generation_time;
50991 - atomic_t s_mb_lost_chunks;
50992 - atomic_t s_mb_preallocated;
50993 - atomic_t s_mb_discarded;
50994 + atomic_unchecked_t s_mb_lost_chunks;
50995 + atomic_unchecked_t s_mb_preallocated;
50996 + atomic_unchecked_t s_mb_discarded;
50997 atomic_t s_lock_busy;
50998
50999 /* locality groups */
51000 diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
51001 index f3190ab..84ffb21 100644
51002 --- a/fs/ext4/mballoc.c
51003 +++ b/fs/ext4/mballoc.c
51004 @@ -1754,7 +1754,7 @@ void ext4_mb_simple_scan_group(struct ext4_allocation_context *ac,
51005 BUG_ON(ac->ac_b_ex.fe_len != ac->ac_g_ex.fe_len);
51006
51007 if (EXT4_SB(sb)->s_mb_stats)
51008 - atomic_inc(&EXT4_SB(sb)->s_bal_2orders);
51009 + atomic_inc_unchecked(&EXT4_SB(sb)->s_bal_2orders);
51010
51011 break;
51012 }
51013 @@ -2059,7 +2059,7 @@ repeat:
51014 ac->ac_status = AC_STATUS_CONTINUE;
51015 ac->ac_flags |= EXT4_MB_HINT_FIRST;
51016 cr = 3;
51017 - atomic_inc(&sbi->s_mb_lost_chunks);
51018 + atomic_inc_unchecked(&sbi->s_mb_lost_chunks);
51019 goto repeat;
51020 }
51021 }
51022 @@ -2567,25 +2567,25 @@ int ext4_mb_release(struct super_block *sb)
51023 if (sbi->s_mb_stats) {
51024 ext4_msg(sb, KERN_INFO,
51025 "mballoc: %u blocks %u reqs (%u success)",
51026 - atomic_read(&sbi->s_bal_allocated),
51027 - atomic_read(&sbi->s_bal_reqs),
51028 - atomic_read(&sbi->s_bal_success));
51029 + atomic_read_unchecked(&sbi->s_bal_allocated),
51030 + atomic_read_unchecked(&sbi->s_bal_reqs),
51031 + atomic_read_unchecked(&sbi->s_bal_success));
51032 ext4_msg(sb, KERN_INFO,
51033 "mballoc: %u extents scanned, %u goal hits, "
51034 "%u 2^N hits, %u breaks, %u lost",
51035 - atomic_read(&sbi->s_bal_ex_scanned),
51036 - atomic_read(&sbi->s_bal_goals),
51037 - atomic_read(&sbi->s_bal_2orders),
51038 - atomic_read(&sbi->s_bal_breaks),
51039 - atomic_read(&sbi->s_mb_lost_chunks));
51040 + atomic_read_unchecked(&sbi->s_bal_ex_scanned),
51041 + atomic_read_unchecked(&sbi->s_bal_goals),
51042 + atomic_read_unchecked(&sbi->s_bal_2orders),
51043 + atomic_read_unchecked(&sbi->s_bal_breaks),
51044 + atomic_read_unchecked(&sbi->s_mb_lost_chunks));
51045 ext4_msg(sb, KERN_INFO,
51046 "mballoc: %lu generated and it took %Lu",
51047 sbi->s_mb_buddies_generated,
51048 sbi->s_mb_generation_time);
51049 ext4_msg(sb, KERN_INFO,
51050 "mballoc: %u preallocated, %u discarded",
51051 - atomic_read(&sbi->s_mb_preallocated),
51052 - atomic_read(&sbi->s_mb_discarded));
51053 + atomic_read_unchecked(&sbi->s_mb_preallocated),
51054 + atomic_read_unchecked(&sbi->s_mb_discarded));
51055 }
51056
51057 free_percpu(sbi->s_locality_groups);
51058 @@ -3039,16 +3039,16 @@ static void ext4_mb_collect_stats(struct ext4_allocation_context *ac)
51059 struct ext4_sb_info *sbi = EXT4_SB(ac->ac_sb);
51060
51061 if (sbi->s_mb_stats && ac->ac_g_ex.fe_len > 1) {
51062 - atomic_inc(&sbi->s_bal_reqs);
51063 - atomic_add(ac->ac_b_ex.fe_len, &sbi->s_bal_allocated);
51064 + atomic_inc_unchecked(&sbi->s_bal_reqs);
51065 + atomic_add_unchecked(ac->ac_b_ex.fe_len, &sbi->s_bal_allocated);
51066 if (ac->ac_b_ex.fe_len >= ac->ac_o_ex.fe_len)
51067 - atomic_inc(&sbi->s_bal_success);
51068 - atomic_add(ac->ac_found, &sbi->s_bal_ex_scanned);
51069 + atomic_inc_unchecked(&sbi->s_bal_success);
51070 + atomic_add_unchecked(ac->ac_found, &sbi->s_bal_ex_scanned);
51071 if (ac->ac_g_ex.fe_start == ac->ac_b_ex.fe_start &&
51072 ac->ac_g_ex.fe_group == ac->ac_b_ex.fe_group)
51073 - atomic_inc(&sbi->s_bal_goals);
51074 + atomic_inc_unchecked(&sbi->s_bal_goals);
51075 if (ac->ac_found > sbi->s_mb_max_to_scan)
51076 - atomic_inc(&sbi->s_bal_breaks);
51077 + atomic_inc_unchecked(&sbi->s_bal_breaks);
51078 }
51079
51080 if (ac->ac_op == EXT4_MB_HISTORY_ALLOC)
51081 @@ -3448,7 +3448,7 @@ ext4_mb_new_inode_pa(struct ext4_allocation_context *ac)
51082 trace_ext4_mb_new_inode_pa(ac, pa);
51083
51084 ext4_mb_use_inode_pa(ac, pa);
51085 - atomic_add(pa->pa_free, &sbi->s_mb_preallocated);
51086 + atomic_add_unchecked(pa->pa_free, &sbi->s_mb_preallocated);
51087
51088 ei = EXT4_I(ac->ac_inode);
51089 grp = ext4_get_group_info(sb, ac->ac_b_ex.fe_group);
51090 @@ -3508,7 +3508,7 @@ ext4_mb_new_group_pa(struct ext4_allocation_context *ac)
51091 trace_ext4_mb_new_group_pa(ac, pa);
51092
51093 ext4_mb_use_group_pa(ac, pa);
51094 - atomic_add(pa->pa_free, &EXT4_SB(sb)->s_mb_preallocated);
51095 + atomic_add_unchecked(pa->pa_free, &EXT4_SB(sb)->s_mb_preallocated);
51096
51097 grp = ext4_get_group_info(sb, ac->ac_b_ex.fe_group);
51098 lg = ac->ac_lg;
51099 @@ -3597,7 +3597,7 @@ ext4_mb_release_inode_pa(struct ext4_buddy *e4b, struct buffer_head *bitmap_bh,
51100 * from the bitmap and continue.
51101 */
51102 }
51103 - atomic_add(free, &sbi->s_mb_discarded);
51104 + atomic_add_unchecked(free, &sbi->s_mb_discarded);
51105
51106 return err;
51107 }
51108 @@ -3615,7 +3615,7 @@ ext4_mb_release_group_pa(struct ext4_buddy *e4b,
51109 ext4_get_group_no_and_offset(sb, pa->pa_pstart, &group, &bit);
51110 BUG_ON(group != e4b->bd_group && pa->pa_len != 0);
51111 mb_free_blocks(pa->pa_inode, e4b, bit, pa->pa_len);
51112 - atomic_add(pa->pa_len, &EXT4_SB(sb)->s_mb_discarded);
51113 + atomic_add_unchecked(pa->pa_len, &EXT4_SB(sb)->s_mb_discarded);
51114 trace_ext4_mballoc_discard(sb, NULL, group, bit, pa->pa_len);
51115
51116 return 0;
51117 diff --git a/fs/ext4/super.c b/fs/ext4/super.c
51118 index febbe0e..782c4fd 100644
51119 --- a/fs/ext4/super.c
51120 +++ b/fs/ext4/super.c
51121 @@ -2380,7 +2380,7 @@ struct ext4_attr {
51122 ssize_t (*store)(struct ext4_attr *, struct ext4_sb_info *,
51123 const char *, size_t);
51124 int offset;
51125 -};
51126 +} __do_const;
51127
51128 static int parse_strtoul(const char *buf,
51129 unsigned long max, unsigned long *value)
51130 diff --git a/fs/fcntl.c b/fs/fcntl.c
51131 index 6599222..e7bf0de 100644
51132 --- a/fs/fcntl.c
51133 +++ b/fs/fcntl.c
51134 @@ -107,6 +107,11 @@ int __f_setown(struct file *filp, struct pid *pid, enum pid_type type,
51135 if (err)
51136 return err;
51137
51138 + if (gr_handle_chroot_fowner(pid, type))
51139 + return -ENOENT;
51140 + if (gr_check_protected_task_fowner(pid, type))
51141 + return -EACCES;
51142 +
51143 f_modown(filp, pid, type, force);
51144 return 0;
51145 }
51146 diff --git a/fs/fhandle.c b/fs/fhandle.c
51147 index 999ff5c..41f4109 100644
51148 --- a/fs/fhandle.c
51149 +++ b/fs/fhandle.c
51150 @@ -67,8 +67,7 @@ static long do_sys_name_to_handle(struct path *path,
51151 } else
51152 retval = 0;
51153 /* copy the mount id */
51154 - if (copy_to_user(mnt_id, &real_mount(path->mnt)->mnt_id,
51155 - sizeof(*mnt_id)) ||
51156 + if (put_user(real_mount(path->mnt)->mnt_id, mnt_id) ||
51157 copy_to_user(ufh, handle,
51158 sizeof(struct file_handle) + handle_bytes))
51159 retval = -EFAULT;
51160 diff --git a/fs/fifo.c b/fs/fifo.c
51161 index cf6f434..3d7942c 100644
51162 --- a/fs/fifo.c
51163 +++ b/fs/fifo.c
51164 @@ -59,10 +59,10 @@ static int fifo_open(struct inode *inode, struct file *filp)
51165 */
51166 filp->f_op = &read_pipefifo_fops;
51167 pipe->r_counter++;
51168 - if (pipe->readers++ == 0)
51169 + if (atomic_inc_return(&pipe->readers) == 1)
51170 wake_up_partner(inode);
51171
51172 - if (!pipe->writers) {
51173 + if (!atomic_read(&pipe->writers)) {
51174 if ((filp->f_flags & O_NONBLOCK)) {
51175 /* suppress POLLHUP until we have
51176 * seen a writer */
51177 @@ -81,15 +81,15 @@ static int fifo_open(struct inode *inode, struct file *filp)
51178 * errno=ENXIO when there is no process reading the FIFO.
51179 */
51180 ret = -ENXIO;
51181 - if ((filp->f_flags & O_NONBLOCK) && !pipe->readers)
51182 + if ((filp->f_flags & O_NONBLOCK) && !atomic_read(&pipe->readers))
51183 goto err;
51184
51185 filp->f_op = &write_pipefifo_fops;
51186 pipe->w_counter++;
51187 - if (!pipe->writers++)
51188 + if (atomic_inc_return(&pipe->writers) == 1)
51189 wake_up_partner(inode);
51190
51191 - if (!pipe->readers) {
51192 + if (!atomic_read(&pipe->readers)) {
51193 if (wait_for_partner(inode, &pipe->r_counter))
51194 goto err_wr;
51195 }
51196 @@ -104,11 +104,11 @@ static int fifo_open(struct inode *inode, struct file *filp)
51197 */
51198 filp->f_op = &rdwr_pipefifo_fops;
51199
51200 - pipe->readers++;
51201 - pipe->writers++;
51202 + atomic_inc(&pipe->readers);
51203 + atomic_inc(&pipe->writers);
51204 pipe->r_counter++;
51205 pipe->w_counter++;
51206 - if (pipe->readers == 1 || pipe->writers == 1)
51207 + if (atomic_read(&pipe->readers) == 1 || atomic_read(&pipe->writers) == 1)
51208 wake_up_partner(inode);
51209 break;
51210
51211 @@ -122,19 +122,19 @@ static int fifo_open(struct inode *inode, struct file *filp)
51212 return 0;
51213
51214 err_rd:
51215 - if (!--pipe->readers)
51216 + if (atomic_dec_and_test(&pipe->readers))
51217 wake_up_interruptible(&pipe->wait);
51218 ret = -ERESTARTSYS;
51219 goto err;
51220
51221 err_wr:
51222 - if (!--pipe->writers)
51223 + if (atomic_dec_and_test(&pipe->writers))
51224 wake_up_interruptible(&pipe->wait);
51225 ret = -ERESTARTSYS;
51226 goto err;
51227
51228 err:
51229 - if (!pipe->readers && !pipe->writers)
51230 + if (!atomic_read(&pipe->readers) && !atomic_read(&pipe->writers))
51231 free_pipe_info(inode);
51232
51233 err_nocleanup:
51234 diff --git a/fs/file.c b/fs/file.c
51235 index 3906d95..5fe379b 100644
51236 --- a/fs/file.c
51237 +++ b/fs/file.c
51238 @@ -16,6 +16,7 @@
51239 #include <linux/slab.h>
51240 #include <linux/vmalloc.h>
51241 #include <linux/file.h>
51242 +#include <linux/security.h>
51243 #include <linux/fdtable.h>
51244 #include <linux/bitops.h>
51245 #include <linux/interrupt.h>
51246 @@ -892,6 +893,7 @@ int replace_fd(unsigned fd, struct file *file, unsigned flags)
51247 if (!file)
51248 return __close_fd(files, fd);
51249
51250 + gr_learn_resource(current, RLIMIT_NOFILE, fd, 0);
51251 if (fd >= rlimit(RLIMIT_NOFILE))
51252 return -EBADF;
51253
51254 @@ -918,6 +920,7 @@ SYSCALL_DEFINE3(dup3, unsigned int, oldfd, unsigned int, newfd, int, flags)
51255 if (unlikely(oldfd == newfd))
51256 return -EINVAL;
51257
51258 + gr_learn_resource(current, RLIMIT_NOFILE, newfd, 0);
51259 if (newfd >= rlimit(RLIMIT_NOFILE))
51260 return -EBADF;
51261
51262 @@ -973,6 +976,7 @@ SYSCALL_DEFINE1(dup, unsigned int, fildes)
51263 int f_dupfd(unsigned int from, struct file *file, unsigned flags)
51264 {
51265 int err;
51266 + gr_learn_resource(current, RLIMIT_NOFILE, from, 0);
51267 if (from >= rlimit(RLIMIT_NOFILE))
51268 return -EINVAL;
51269 err = alloc_fd(from, flags);
51270 diff --git a/fs/filesystems.c b/fs/filesystems.c
51271 index 92567d9..fcd8cbf 100644
51272 --- a/fs/filesystems.c
51273 +++ b/fs/filesystems.c
51274 @@ -273,7 +273,11 @@ struct file_system_type *get_fs_type(const char *name)
51275 int len = dot ? dot - name : strlen(name);
51276
51277 fs = __get_fs_type(name, len);
51278 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
51279 + if (!fs && (___request_module(true, "grsec_modharden_fs", "fs-%.*s", len, name) == 0))
51280 +#else
51281 if (!fs && (request_module("fs-%.*s", len, name) == 0))
51282 +#endif
51283 fs = __get_fs_type(name, len);
51284
51285 if (dot && fs && !(fs->fs_flags & FS_HAS_SUBTYPE)) {
51286 diff --git a/fs/fs_struct.c b/fs/fs_struct.c
51287 index d8ac61d..79a36f0 100644
51288 --- a/fs/fs_struct.c
51289 +++ b/fs/fs_struct.c
51290 @@ -4,6 +4,7 @@
51291 #include <linux/path.h>
51292 #include <linux/slab.h>
51293 #include <linux/fs_struct.h>
51294 +#include <linux/grsecurity.h>
51295 #include "internal.h"
51296
51297 /*
51298 @@ -19,6 +20,7 @@ void set_fs_root(struct fs_struct *fs, const struct path *path)
51299 write_seqcount_begin(&fs->seq);
51300 old_root = fs->root;
51301 fs->root = *path;
51302 + gr_set_chroot_entries(current, path);
51303 write_seqcount_end(&fs->seq);
51304 spin_unlock(&fs->lock);
51305 if (old_root.dentry)
51306 @@ -67,6 +69,10 @@ void chroot_fs_refs(const struct path *old_root, const struct path *new_root)
51307 int hits = 0;
51308 spin_lock(&fs->lock);
51309 write_seqcount_begin(&fs->seq);
51310 + /* this root replacement is only done by pivot_root,
51311 + leave grsec's chroot tagging alone for this task
51312 + so that a pivoted root isn't treated as a chroot
51313 + */
51314 hits += replace_path(&fs->root, old_root, new_root);
51315 hits += replace_path(&fs->pwd, old_root, new_root);
51316 write_seqcount_end(&fs->seq);
51317 @@ -99,7 +105,8 @@ void exit_fs(struct task_struct *tsk)
51318 task_lock(tsk);
51319 spin_lock(&fs->lock);
51320 tsk->fs = NULL;
51321 - kill = !--fs->users;
51322 + gr_clear_chroot_entries(tsk);
51323 + kill = !atomic_dec_return(&fs->users);
51324 spin_unlock(&fs->lock);
51325 task_unlock(tsk);
51326 if (kill)
51327 @@ -112,7 +119,7 @@ struct fs_struct *copy_fs_struct(struct fs_struct *old)
51328 struct fs_struct *fs = kmem_cache_alloc(fs_cachep, GFP_KERNEL);
51329 /* We don't need to lock fs - think why ;-) */
51330 if (fs) {
51331 - fs->users = 1;
51332 + atomic_set(&fs->users, 1);
51333 fs->in_exec = 0;
51334 spin_lock_init(&fs->lock);
51335 seqcount_init(&fs->seq);
51336 @@ -121,6 +128,9 @@ struct fs_struct *copy_fs_struct(struct fs_struct *old)
51337 spin_lock(&old->lock);
51338 fs->root = old->root;
51339 path_get(&fs->root);
51340 + /* instead of calling gr_set_chroot_entries here,
51341 + we call it from every caller of this function
51342 + */
51343 fs->pwd = old->pwd;
51344 path_get(&fs->pwd);
51345 spin_unlock(&old->lock);
51346 @@ -139,8 +149,9 @@ int unshare_fs_struct(void)
51347
51348 task_lock(current);
51349 spin_lock(&fs->lock);
51350 - kill = !--fs->users;
51351 + kill = !atomic_dec_return(&fs->users);
51352 current->fs = new_fs;
51353 + gr_set_chroot_entries(current, &new_fs->root);
51354 spin_unlock(&fs->lock);
51355 task_unlock(current);
51356
51357 @@ -153,13 +164,13 @@ EXPORT_SYMBOL_GPL(unshare_fs_struct);
51358
51359 int current_umask(void)
51360 {
51361 - return current->fs->umask;
51362 + return current->fs->umask | gr_acl_umask();
51363 }
51364 EXPORT_SYMBOL(current_umask);
51365
51366 /* to be mentioned only in INIT_TASK */
51367 struct fs_struct init_fs = {
51368 - .users = 1,
51369 + .users = ATOMIC_INIT(1),
51370 .lock = __SPIN_LOCK_UNLOCKED(init_fs.lock),
51371 .seq = SEQCNT_ZERO,
51372 .umask = 0022,
51373 diff --git a/fs/fscache/cookie.c b/fs/fscache/cookie.c
51374 index e2cba1f..17a25bb 100644
51375 --- a/fs/fscache/cookie.c
51376 +++ b/fs/fscache/cookie.c
51377 @@ -68,11 +68,11 @@ struct fscache_cookie *__fscache_acquire_cookie(
51378 parent ? (char *) parent->def->name : "<no-parent>",
51379 def->name, netfs_data);
51380
51381 - fscache_stat(&fscache_n_acquires);
51382 + fscache_stat_unchecked(&fscache_n_acquires);
51383
51384 /* if there's no parent cookie, then we don't create one here either */
51385 if (!parent) {
51386 - fscache_stat(&fscache_n_acquires_null);
51387 + fscache_stat_unchecked(&fscache_n_acquires_null);
51388 _leave(" [no parent]");
51389 return NULL;
51390 }
51391 @@ -87,7 +87,7 @@ struct fscache_cookie *__fscache_acquire_cookie(
51392 /* allocate and initialise a cookie */
51393 cookie = kmem_cache_alloc(fscache_cookie_jar, GFP_KERNEL);
51394 if (!cookie) {
51395 - fscache_stat(&fscache_n_acquires_oom);
51396 + fscache_stat_unchecked(&fscache_n_acquires_oom);
51397 _leave(" [ENOMEM]");
51398 return NULL;
51399 }
51400 @@ -109,13 +109,13 @@ struct fscache_cookie *__fscache_acquire_cookie(
51401
51402 switch (cookie->def->type) {
51403 case FSCACHE_COOKIE_TYPE_INDEX:
51404 - fscache_stat(&fscache_n_cookie_index);
51405 + fscache_stat_unchecked(&fscache_n_cookie_index);
51406 break;
51407 case FSCACHE_COOKIE_TYPE_DATAFILE:
51408 - fscache_stat(&fscache_n_cookie_data);
51409 + fscache_stat_unchecked(&fscache_n_cookie_data);
51410 break;
51411 default:
51412 - fscache_stat(&fscache_n_cookie_special);
51413 + fscache_stat_unchecked(&fscache_n_cookie_special);
51414 break;
51415 }
51416
51417 @@ -126,13 +126,13 @@ struct fscache_cookie *__fscache_acquire_cookie(
51418 if (fscache_acquire_non_index_cookie(cookie) < 0) {
51419 atomic_dec(&parent->n_children);
51420 __fscache_cookie_put(cookie);
51421 - fscache_stat(&fscache_n_acquires_nobufs);
51422 + fscache_stat_unchecked(&fscache_n_acquires_nobufs);
51423 _leave(" = NULL");
51424 return NULL;
51425 }
51426 }
51427
51428 - fscache_stat(&fscache_n_acquires_ok);
51429 + fscache_stat_unchecked(&fscache_n_acquires_ok);
51430 _leave(" = %p", cookie);
51431 return cookie;
51432 }
51433 @@ -168,7 +168,7 @@ static int fscache_acquire_non_index_cookie(struct fscache_cookie *cookie)
51434 cache = fscache_select_cache_for_object(cookie->parent);
51435 if (!cache) {
51436 up_read(&fscache_addremove_sem);
51437 - fscache_stat(&fscache_n_acquires_no_cache);
51438 + fscache_stat_unchecked(&fscache_n_acquires_no_cache);
51439 _leave(" = -ENOMEDIUM [no cache]");
51440 return -ENOMEDIUM;
51441 }
51442 @@ -255,12 +255,12 @@ static int fscache_alloc_object(struct fscache_cache *cache,
51443 object = cache->ops->alloc_object(cache, cookie);
51444 fscache_stat_d(&fscache_n_cop_alloc_object);
51445 if (IS_ERR(object)) {
51446 - fscache_stat(&fscache_n_object_no_alloc);
51447 + fscache_stat_unchecked(&fscache_n_object_no_alloc);
51448 ret = PTR_ERR(object);
51449 goto error;
51450 }
51451
51452 - fscache_stat(&fscache_n_object_alloc);
51453 + fscache_stat_unchecked(&fscache_n_object_alloc);
51454
51455 object->debug_id = atomic_inc_return(&fscache_object_debug_id);
51456
51457 @@ -376,7 +376,7 @@ void __fscache_invalidate(struct fscache_cookie *cookie)
51458
51459 _enter("{%s}", cookie->def->name);
51460
51461 - fscache_stat(&fscache_n_invalidates);
51462 + fscache_stat_unchecked(&fscache_n_invalidates);
51463
51464 /* Only permit invalidation of data files. Invalidating an index will
51465 * require the caller to release all its attachments to the tree rooted
51466 @@ -434,10 +434,10 @@ void __fscache_update_cookie(struct fscache_cookie *cookie)
51467 {
51468 struct fscache_object *object;
51469
51470 - fscache_stat(&fscache_n_updates);
51471 + fscache_stat_unchecked(&fscache_n_updates);
51472
51473 if (!cookie) {
51474 - fscache_stat(&fscache_n_updates_null);
51475 + fscache_stat_unchecked(&fscache_n_updates_null);
51476 _leave(" [no cookie]");
51477 return;
51478 }
51479 @@ -471,12 +471,12 @@ void __fscache_relinquish_cookie(struct fscache_cookie *cookie, int retire)
51480 struct fscache_object *object;
51481 unsigned long event;
51482
51483 - fscache_stat(&fscache_n_relinquishes);
51484 + fscache_stat_unchecked(&fscache_n_relinquishes);
51485 if (retire)
51486 - fscache_stat(&fscache_n_relinquishes_retire);
51487 + fscache_stat_unchecked(&fscache_n_relinquishes_retire);
51488
51489 if (!cookie) {
51490 - fscache_stat(&fscache_n_relinquishes_null);
51491 + fscache_stat_unchecked(&fscache_n_relinquishes_null);
51492 _leave(" [no cookie]");
51493 return;
51494 }
51495 @@ -492,7 +492,7 @@ void __fscache_relinquish_cookie(struct fscache_cookie *cookie, int retire)
51496
51497 /* wait for the cookie to finish being instantiated (or to fail) */
51498 if (test_bit(FSCACHE_COOKIE_CREATING, &cookie->flags)) {
51499 - fscache_stat(&fscache_n_relinquishes_waitcrt);
51500 + fscache_stat_unchecked(&fscache_n_relinquishes_waitcrt);
51501 wait_on_bit(&cookie->flags, FSCACHE_COOKIE_CREATING,
51502 fscache_wait_bit, TASK_UNINTERRUPTIBLE);
51503 }
51504 diff --git a/fs/fscache/internal.h b/fs/fscache/internal.h
51505 index ee38fef..0a326d4 100644
51506 --- a/fs/fscache/internal.h
51507 +++ b/fs/fscache/internal.h
51508 @@ -148,101 +148,101 @@ extern void fscache_proc_cleanup(void);
51509 * stats.c
51510 */
51511 #ifdef CONFIG_FSCACHE_STATS
51512 -extern atomic_t fscache_n_ops_processed[FSCACHE_MAX_THREADS];
51513 -extern atomic_t fscache_n_objs_processed[FSCACHE_MAX_THREADS];
51514 +extern atomic_unchecked_t fscache_n_ops_processed[FSCACHE_MAX_THREADS];
51515 +extern atomic_unchecked_t fscache_n_objs_processed[FSCACHE_MAX_THREADS];
51516
51517 -extern atomic_t fscache_n_op_pend;
51518 -extern atomic_t fscache_n_op_run;
51519 -extern atomic_t fscache_n_op_enqueue;
51520 -extern atomic_t fscache_n_op_deferred_release;
51521 -extern atomic_t fscache_n_op_release;
51522 -extern atomic_t fscache_n_op_gc;
51523 -extern atomic_t fscache_n_op_cancelled;
51524 -extern atomic_t fscache_n_op_rejected;
51525 +extern atomic_unchecked_t fscache_n_op_pend;
51526 +extern atomic_unchecked_t fscache_n_op_run;
51527 +extern atomic_unchecked_t fscache_n_op_enqueue;
51528 +extern atomic_unchecked_t fscache_n_op_deferred_release;
51529 +extern atomic_unchecked_t fscache_n_op_release;
51530 +extern atomic_unchecked_t fscache_n_op_gc;
51531 +extern atomic_unchecked_t fscache_n_op_cancelled;
51532 +extern atomic_unchecked_t fscache_n_op_rejected;
51533
51534 -extern atomic_t fscache_n_attr_changed;
51535 -extern atomic_t fscache_n_attr_changed_ok;
51536 -extern atomic_t fscache_n_attr_changed_nobufs;
51537 -extern atomic_t fscache_n_attr_changed_nomem;
51538 -extern atomic_t fscache_n_attr_changed_calls;
51539 +extern atomic_unchecked_t fscache_n_attr_changed;
51540 +extern atomic_unchecked_t fscache_n_attr_changed_ok;
51541 +extern atomic_unchecked_t fscache_n_attr_changed_nobufs;
51542 +extern atomic_unchecked_t fscache_n_attr_changed_nomem;
51543 +extern atomic_unchecked_t fscache_n_attr_changed_calls;
51544
51545 -extern atomic_t fscache_n_allocs;
51546 -extern atomic_t fscache_n_allocs_ok;
51547 -extern atomic_t fscache_n_allocs_wait;
51548 -extern atomic_t fscache_n_allocs_nobufs;
51549 -extern atomic_t fscache_n_allocs_intr;
51550 -extern atomic_t fscache_n_allocs_object_dead;
51551 -extern atomic_t fscache_n_alloc_ops;
51552 -extern atomic_t fscache_n_alloc_op_waits;
51553 +extern atomic_unchecked_t fscache_n_allocs;
51554 +extern atomic_unchecked_t fscache_n_allocs_ok;
51555 +extern atomic_unchecked_t fscache_n_allocs_wait;
51556 +extern atomic_unchecked_t fscache_n_allocs_nobufs;
51557 +extern atomic_unchecked_t fscache_n_allocs_intr;
51558 +extern atomic_unchecked_t fscache_n_allocs_object_dead;
51559 +extern atomic_unchecked_t fscache_n_alloc_ops;
51560 +extern atomic_unchecked_t fscache_n_alloc_op_waits;
51561
51562 -extern atomic_t fscache_n_retrievals;
51563 -extern atomic_t fscache_n_retrievals_ok;
51564 -extern atomic_t fscache_n_retrievals_wait;
51565 -extern atomic_t fscache_n_retrievals_nodata;
51566 -extern atomic_t fscache_n_retrievals_nobufs;
51567 -extern atomic_t fscache_n_retrievals_intr;
51568 -extern atomic_t fscache_n_retrievals_nomem;
51569 -extern atomic_t fscache_n_retrievals_object_dead;
51570 -extern atomic_t fscache_n_retrieval_ops;
51571 -extern atomic_t fscache_n_retrieval_op_waits;
51572 +extern atomic_unchecked_t fscache_n_retrievals;
51573 +extern atomic_unchecked_t fscache_n_retrievals_ok;
51574 +extern atomic_unchecked_t fscache_n_retrievals_wait;
51575 +extern atomic_unchecked_t fscache_n_retrievals_nodata;
51576 +extern atomic_unchecked_t fscache_n_retrievals_nobufs;
51577 +extern atomic_unchecked_t fscache_n_retrievals_intr;
51578 +extern atomic_unchecked_t fscache_n_retrievals_nomem;
51579 +extern atomic_unchecked_t fscache_n_retrievals_object_dead;
51580 +extern atomic_unchecked_t fscache_n_retrieval_ops;
51581 +extern atomic_unchecked_t fscache_n_retrieval_op_waits;
51582
51583 -extern atomic_t fscache_n_stores;
51584 -extern atomic_t fscache_n_stores_ok;
51585 -extern atomic_t fscache_n_stores_again;
51586 -extern atomic_t fscache_n_stores_nobufs;
51587 -extern atomic_t fscache_n_stores_oom;
51588 -extern atomic_t fscache_n_store_ops;
51589 -extern atomic_t fscache_n_store_calls;
51590 -extern atomic_t fscache_n_store_pages;
51591 -extern atomic_t fscache_n_store_radix_deletes;
51592 -extern atomic_t fscache_n_store_pages_over_limit;
51593 +extern atomic_unchecked_t fscache_n_stores;
51594 +extern atomic_unchecked_t fscache_n_stores_ok;
51595 +extern atomic_unchecked_t fscache_n_stores_again;
51596 +extern atomic_unchecked_t fscache_n_stores_nobufs;
51597 +extern atomic_unchecked_t fscache_n_stores_oom;
51598 +extern atomic_unchecked_t fscache_n_store_ops;
51599 +extern atomic_unchecked_t fscache_n_store_calls;
51600 +extern atomic_unchecked_t fscache_n_store_pages;
51601 +extern atomic_unchecked_t fscache_n_store_radix_deletes;
51602 +extern atomic_unchecked_t fscache_n_store_pages_over_limit;
51603
51604 -extern atomic_t fscache_n_store_vmscan_not_storing;
51605 -extern atomic_t fscache_n_store_vmscan_gone;
51606 -extern atomic_t fscache_n_store_vmscan_busy;
51607 -extern atomic_t fscache_n_store_vmscan_cancelled;
51608 -extern atomic_t fscache_n_store_vmscan_wait;
51609 +extern atomic_unchecked_t fscache_n_store_vmscan_not_storing;
51610 +extern atomic_unchecked_t fscache_n_store_vmscan_gone;
51611 +extern atomic_unchecked_t fscache_n_store_vmscan_busy;
51612 +extern atomic_unchecked_t fscache_n_store_vmscan_cancelled;
51613 +extern atomic_unchecked_t fscache_n_store_vmscan_wait;
51614
51615 -extern atomic_t fscache_n_marks;
51616 -extern atomic_t fscache_n_uncaches;
51617 +extern atomic_unchecked_t fscache_n_marks;
51618 +extern atomic_unchecked_t fscache_n_uncaches;
51619
51620 -extern atomic_t fscache_n_acquires;
51621 -extern atomic_t fscache_n_acquires_null;
51622 -extern atomic_t fscache_n_acquires_no_cache;
51623 -extern atomic_t fscache_n_acquires_ok;
51624 -extern atomic_t fscache_n_acquires_nobufs;
51625 -extern atomic_t fscache_n_acquires_oom;
51626 +extern atomic_unchecked_t fscache_n_acquires;
51627 +extern atomic_unchecked_t fscache_n_acquires_null;
51628 +extern atomic_unchecked_t fscache_n_acquires_no_cache;
51629 +extern atomic_unchecked_t fscache_n_acquires_ok;
51630 +extern atomic_unchecked_t fscache_n_acquires_nobufs;
51631 +extern atomic_unchecked_t fscache_n_acquires_oom;
51632
51633 -extern atomic_t fscache_n_invalidates;
51634 -extern atomic_t fscache_n_invalidates_run;
51635 +extern atomic_unchecked_t fscache_n_invalidates;
51636 +extern atomic_unchecked_t fscache_n_invalidates_run;
51637
51638 -extern atomic_t fscache_n_updates;
51639 -extern atomic_t fscache_n_updates_null;
51640 -extern atomic_t fscache_n_updates_run;
51641 +extern atomic_unchecked_t fscache_n_updates;
51642 +extern atomic_unchecked_t fscache_n_updates_null;
51643 +extern atomic_unchecked_t fscache_n_updates_run;
51644
51645 -extern atomic_t fscache_n_relinquishes;
51646 -extern atomic_t fscache_n_relinquishes_null;
51647 -extern atomic_t fscache_n_relinquishes_waitcrt;
51648 -extern atomic_t fscache_n_relinquishes_retire;
51649 +extern atomic_unchecked_t fscache_n_relinquishes;
51650 +extern atomic_unchecked_t fscache_n_relinquishes_null;
51651 +extern atomic_unchecked_t fscache_n_relinquishes_waitcrt;
51652 +extern atomic_unchecked_t fscache_n_relinquishes_retire;
51653
51654 -extern atomic_t fscache_n_cookie_index;
51655 -extern atomic_t fscache_n_cookie_data;
51656 -extern atomic_t fscache_n_cookie_special;
51657 +extern atomic_unchecked_t fscache_n_cookie_index;
51658 +extern atomic_unchecked_t fscache_n_cookie_data;
51659 +extern atomic_unchecked_t fscache_n_cookie_special;
51660
51661 -extern atomic_t fscache_n_object_alloc;
51662 -extern atomic_t fscache_n_object_no_alloc;
51663 -extern atomic_t fscache_n_object_lookups;
51664 -extern atomic_t fscache_n_object_lookups_negative;
51665 -extern atomic_t fscache_n_object_lookups_positive;
51666 -extern atomic_t fscache_n_object_lookups_timed_out;
51667 -extern atomic_t fscache_n_object_created;
51668 -extern atomic_t fscache_n_object_avail;
51669 -extern atomic_t fscache_n_object_dead;
51670 +extern atomic_unchecked_t fscache_n_object_alloc;
51671 +extern atomic_unchecked_t fscache_n_object_no_alloc;
51672 +extern atomic_unchecked_t fscache_n_object_lookups;
51673 +extern atomic_unchecked_t fscache_n_object_lookups_negative;
51674 +extern atomic_unchecked_t fscache_n_object_lookups_positive;
51675 +extern atomic_unchecked_t fscache_n_object_lookups_timed_out;
51676 +extern atomic_unchecked_t fscache_n_object_created;
51677 +extern atomic_unchecked_t fscache_n_object_avail;
51678 +extern atomic_unchecked_t fscache_n_object_dead;
51679
51680 -extern atomic_t fscache_n_checkaux_none;
51681 -extern atomic_t fscache_n_checkaux_okay;
51682 -extern atomic_t fscache_n_checkaux_update;
51683 -extern atomic_t fscache_n_checkaux_obsolete;
51684 +extern atomic_unchecked_t fscache_n_checkaux_none;
51685 +extern atomic_unchecked_t fscache_n_checkaux_okay;
51686 +extern atomic_unchecked_t fscache_n_checkaux_update;
51687 +extern atomic_unchecked_t fscache_n_checkaux_obsolete;
51688
51689 extern atomic_t fscache_n_cop_alloc_object;
51690 extern atomic_t fscache_n_cop_lookup_object;
51691 @@ -267,6 +267,11 @@ static inline void fscache_stat(atomic_t *stat)
51692 atomic_inc(stat);
51693 }
51694
51695 +static inline void fscache_stat_unchecked(atomic_unchecked_t *stat)
51696 +{
51697 + atomic_inc_unchecked(stat);
51698 +}
51699 +
51700 static inline void fscache_stat_d(atomic_t *stat)
51701 {
51702 atomic_dec(stat);
51703 @@ -279,6 +284,7 @@ extern const struct file_operations fscache_stats_fops;
51704
51705 #define __fscache_stat(stat) (NULL)
51706 #define fscache_stat(stat) do {} while (0)
51707 +#define fscache_stat_unchecked(stat) do {} while (0)
51708 #define fscache_stat_d(stat) do {} while (0)
51709 #endif
51710
51711 diff --git a/fs/fscache/object.c b/fs/fscache/object.c
51712 index 50d41c1..10ee117 100644
51713 --- a/fs/fscache/object.c
51714 +++ b/fs/fscache/object.c
51715 @@ -143,7 +143,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
51716 /* Invalidate an object on disk */
51717 case FSCACHE_OBJECT_INVALIDATING:
51718 clear_bit(FSCACHE_OBJECT_EV_INVALIDATE, &object->events);
51719 - fscache_stat(&fscache_n_invalidates_run);
51720 + fscache_stat_unchecked(&fscache_n_invalidates_run);
51721 fscache_stat(&fscache_n_cop_invalidate_object);
51722 fscache_invalidate_object(object);
51723 fscache_stat_d(&fscache_n_cop_invalidate_object);
51724 @@ -153,7 +153,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
51725 /* update the object metadata on disk */
51726 case FSCACHE_OBJECT_UPDATING:
51727 clear_bit(FSCACHE_OBJECT_EV_UPDATE, &object->events);
51728 - fscache_stat(&fscache_n_updates_run);
51729 + fscache_stat_unchecked(&fscache_n_updates_run);
51730 fscache_stat(&fscache_n_cop_update_object);
51731 object->cache->ops->update_object(object);
51732 fscache_stat_d(&fscache_n_cop_update_object);
51733 @@ -242,7 +242,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
51734 spin_lock(&object->lock);
51735 object->state = FSCACHE_OBJECT_DEAD;
51736 spin_unlock(&object->lock);
51737 - fscache_stat(&fscache_n_object_dead);
51738 + fscache_stat_unchecked(&fscache_n_object_dead);
51739 goto terminal_transit;
51740
51741 /* handle the parent cache of this object being withdrawn from
51742 @@ -257,7 +257,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
51743 spin_lock(&object->lock);
51744 object->state = FSCACHE_OBJECT_DEAD;
51745 spin_unlock(&object->lock);
51746 - fscache_stat(&fscache_n_object_dead);
51747 + fscache_stat_unchecked(&fscache_n_object_dead);
51748 goto terminal_transit;
51749
51750 /* complain about the object being woken up once it is
51751 @@ -495,7 +495,7 @@ static void fscache_lookup_object(struct fscache_object *object)
51752 parent->cookie->def->name, cookie->def->name,
51753 object->cache->tag->name);
51754
51755 - fscache_stat(&fscache_n_object_lookups);
51756 + fscache_stat_unchecked(&fscache_n_object_lookups);
51757 fscache_stat(&fscache_n_cop_lookup_object);
51758 ret = object->cache->ops->lookup_object(object);
51759 fscache_stat_d(&fscache_n_cop_lookup_object);
51760 @@ -506,7 +506,7 @@ static void fscache_lookup_object(struct fscache_object *object)
51761 if (ret == -ETIMEDOUT) {
51762 /* probably stuck behind another object, so move this one to
51763 * the back of the queue */
51764 - fscache_stat(&fscache_n_object_lookups_timed_out);
51765 + fscache_stat_unchecked(&fscache_n_object_lookups_timed_out);
51766 set_bit(FSCACHE_OBJECT_EV_REQUEUE, &object->events);
51767 }
51768
51769 @@ -529,7 +529,7 @@ void fscache_object_lookup_negative(struct fscache_object *object)
51770
51771 spin_lock(&object->lock);
51772 if (object->state == FSCACHE_OBJECT_LOOKING_UP) {
51773 - fscache_stat(&fscache_n_object_lookups_negative);
51774 + fscache_stat_unchecked(&fscache_n_object_lookups_negative);
51775
51776 /* transit here to allow write requests to begin stacking up
51777 * and read requests to begin returning ENODATA */
51778 @@ -575,7 +575,7 @@ void fscache_obtained_object(struct fscache_object *object)
51779 * result, in which case there may be data available */
51780 spin_lock(&object->lock);
51781 if (object->state == FSCACHE_OBJECT_LOOKING_UP) {
51782 - fscache_stat(&fscache_n_object_lookups_positive);
51783 + fscache_stat_unchecked(&fscache_n_object_lookups_positive);
51784
51785 clear_bit(FSCACHE_COOKIE_NO_DATA_YET, &cookie->flags);
51786
51787 @@ -589,7 +589,7 @@ void fscache_obtained_object(struct fscache_object *object)
51788 set_bit(FSCACHE_OBJECT_EV_REQUEUE, &object->events);
51789 } else {
51790 ASSERTCMP(object->state, ==, FSCACHE_OBJECT_CREATING);
51791 - fscache_stat(&fscache_n_object_created);
51792 + fscache_stat_unchecked(&fscache_n_object_created);
51793
51794 object->state = FSCACHE_OBJECT_AVAILABLE;
51795 spin_unlock(&object->lock);
51796 @@ -634,7 +634,7 @@ static void fscache_object_available(struct fscache_object *object)
51797 fscache_enqueue_dependents(object);
51798
51799 fscache_hist(fscache_obj_instantiate_histogram, object->lookup_jif);
51800 - fscache_stat(&fscache_n_object_avail);
51801 + fscache_stat_unchecked(&fscache_n_object_avail);
51802
51803 _leave("");
51804 }
51805 @@ -894,7 +894,7 @@ enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
51806 enum fscache_checkaux result;
51807
51808 if (!object->cookie->def->check_aux) {
51809 - fscache_stat(&fscache_n_checkaux_none);
51810 + fscache_stat_unchecked(&fscache_n_checkaux_none);
51811 return FSCACHE_CHECKAUX_OKAY;
51812 }
51813
51814 @@ -903,17 +903,17 @@ enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
51815 switch (result) {
51816 /* entry okay as is */
51817 case FSCACHE_CHECKAUX_OKAY:
51818 - fscache_stat(&fscache_n_checkaux_okay);
51819 + fscache_stat_unchecked(&fscache_n_checkaux_okay);
51820 break;
51821
51822 /* entry requires update */
51823 case FSCACHE_CHECKAUX_NEEDS_UPDATE:
51824 - fscache_stat(&fscache_n_checkaux_update);
51825 + fscache_stat_unchecked(&fscache_n_checkaux_update);
51826 break;
51827
51828 /* entry requires deletion */
51829 case FSCACHE_CHECKAUX_OBSOLETE:
51830 - fscache_stat(&fscache_n_checkaux_obsolete);
51831 + fscache_stat_unchecked(&fscache_n_checkaux_obsolete);
51832 break;
51833
51834 default:
51835 diff --git a/fs/fscache/operation.c b/fs/fscache/operation.c
51836 index 762a9ec..2023284 100644
51837 --- a/fs/fscache/operation.c
51838 +++ b/fs/fscache/operation.c
51839 @@ -17,7 +17,7 @@
51840 #include <linux/slab.h>
51841 #include "internal.h"
51842
51843 -atomic_t fscache_op_debug_id;
51844 +atomic_unchecked_t fscache_op_debug_id;
51845 EXPORT_SYMBOL(fscache_op_debug_id);
51846
51847 /**
51848 @@ -39,7 +39,7 @@ void fscache_enqueue_operation(struct fscache_operation *op)
51849 ASSERTCMP(atomic_read(&op->usage), >, 0);
51850 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_IN_PROGRESS);
51851
51852 - fscache_stat(&fscache_n_op_enqueue);
51853 + fscache_stat_unchecked(&fscache_n_op_enqueue);
51854 switch (op->flags & FSCACHE_OP_TYPE) {
51855 case FSCACHE_OP_ASYNC:
51856 _debug("queue async");
51857 @@ -73,7 +73,7 @@ static void fscache_run_op(struct fscache_object *object,
51858 wake_up_bit(&op->flags, FSCACHE_OP_WAITING);
51859 if (op->processor)
51860 fscache_enqueue_operation(op);
51861 - fscache_stat(&fscache_n_op_run);
51862 + fscache_stat_unchecked(&fscache_n_op_run);
51863 }
51864
51865 /*
51866 @@ -105,11 +105,11 @@ int fscache_submit_exclusive_op(struct fscache_object *object,
51867 if (object->n_in_progress > 0) {
51868 atomic_inc(&op->usage);
51869 list_add_tail(&op->pend_link, &object->pending_ops);
51870 - fscache_stat(&fscache_n_op_pend);
51871 + fscache_stat_unchecked(&fscache_n_op_pend);
51872 } else if (!list_empty(&object->pending_ops)) {
51873 atomic_inc(&op->usage);
51874 list_add_tail(&op->pend_link, &object->pending_ops);
51875 - fscache_stat(&fscache_n_op_pend);
51876 + fscache_stat_unchecked(&fscache_n_op_pend);
51877 fscache_start_operations(object);
51878 } else {
51879 ASSERTCMP(object->n_in_progress, ==, 0);
51880 @@ -125,7 +125,7 @@ int fscache_submit_exclusive_op(struct fscache_object *object,
51881 object->n_exclusive++; /* reads and writes must wait */
51882 atomic_inc(&op->usage);
51883 list_add_tail(&op->pend_link, &object->pending_ops);
51884 - fscache_stat(&fscache_n_op_pend);
51885 + fscache_stat_unchecked(&fscache_n_op_pend);
51886 ret = 0;
51887 } else {
51888 /* If we're in any other state, there must have been an I/O
51889 @@ -215,11 +215,11 @@ int fscache_submit_op(struct fscache_object *object,
51890 if (object->n_exclusive > 0) {
51891 atomic_inc(&op->usage);
51892 list_add_tail(&op->pend_link, &object->pending_ops);
51893 - fscache_stat(&fscache_n_op_pend);
51894 + fscache_stat_unchecked(&fscache_n_op_pend);
51895 } else if (!list_empty(&object->pending_ops)) {
51896 atomic_inc(&op->usage);
51897 list_add_tail(&op->pend_link, &object->pending_ops);
51898 - fscache_stat(&fscache_n_op_pend);
51899 + fscache_stat_unchecked(&fscache_n_op_pend);
51900 fscache_start_operations(object);
51901 } else {
51902 ASSERTCMP(object->n_exclusive, ==, 0);
51903 @@ -231,12 +231,12 @@ int fscache_submit_op(struct fscache_object *object,
51904 object->n_ops++;
51905 atomic_inc(&op->usage);
51906 list_add_tail(&op->pend_link, &object->pending_ops);
51907 - fscache_stat(&fscache_n_op_pend);
51908 + fscache_stat_unchecked(&fscache_n_op_pend);
51909 ret = 0;
51910 } else if (object->state == FSCACHE_OBJECT_DYING ||
51911 object->state == FSCACHE_OBJECT_LC_DYING ||
51912 object->state == FSCACHE_OBJECT_WITHDRAWING) {
51913 - fscache_stat(&fscache_n_op_rejected);
51914 + fscache_stat_unchecked(&fscache_n_op_rejected);
51915 op->state = FSCACHE_OP_ST_CANCELLED;
51916 ret = -ENOBUFS;
51917 } else if (!test_bit(FSCACHE_IOERROR, &object->cache->flags)) {
51918 @@ -315,7 +315,7 @@ int fscache_cancel_op(struct fscache_operation *op,
51919 ret = -EBUSY;
51920 if (op->state == FSCACHE_OP_ST_PENDING) {
51921 ASSERT(!list_empty(&op->pend_link));
51922 - fscache_stat(&fscache_n_op_cancelled);
51923 + fscache_stat_unchecked(&fscache_n_op_cancelled);
51924 list_del_init(&op->pend_link);
51925 if (do_cancel)
51926 do_cancel(op);
51927 @@ -347,7 +347,7 @@ void fscache_cancel_all_ops(struct fscache_object *object)
51928 while (!list_empty(&object->pending_ops)) {
51929 op = list_entry(object->pending_ops.next,
51930 struct fscache_operation, pend_link);
51931 - fscache_stat(&fscache_n_op_cancelled);
51932 + fscache_stat_unchecked(&fscache_n_op_cancelled);
51933 list_del_init(&op->pend_link);
51934
51935 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_PENDING);
51936 @@ -419,7 +419,7 @@ void fscache_put_operation(struct fscache_operation *op)
51937 op->state, ==, FSCACHE_OP_ST_CANCELLED);
51938 op->state = FSCACHE_OP_ST_DEAD;
51939
51940 - fscache_stat(&fscache_n_op_release);
51941 + fscache_stat_unchecked(&fscache_n_op_release);
51942
51943 if (op->release) {
51944 op->release(op);
51945 @@ -442,7 +442,7 @@ void fscache_put_operation(struct fscache_operation *op)
51946 * lock, and defer it otherwise */
51947 if (!spin_trylock(&object->lock)) {
51948 _debug("defer put");
51949 - fscache_stat(&fscache_n_op_deferred_release);
51950 + fscache_stat_unchecked(&fscache_n_op_deferred_release);
51951
51952 cache = object->cache;
51953 spin_lock(&cache->op_gc_list_lock);
51954 @@ -495,7 +495,7 @@ void fscache_operation_gc(struct work_struct *work)
51955
51956 _debug("GC DEFERRED REL OBJ%x OP%x",
51957 object->debug_id, op->debug_id);
51958 - fscache_stat(&fscache_n_op_gc);
51959 + fscache_stat_unchecked(&fscache_n_op_gc);
51960
51961 ASSERTCMP(atomic_read(&op->usage), ==, 0);
51962 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_DEAD);
51963 diff --git a/fs/fscache/page.c b/fs/fscache/page.c
51964 index ff000e5..c44ec6d 100644
51965 --- a/fs/fscache/page.c
51966 +++ b/fs/fscache/page.c
51967 @@ -61,7 +61,7 @@ try_again:
51968 val = radix_tree_lookup(&cookie->stores, page->index);
51969 if (!val) {
51970 rcu_read_unlock();
51971 - fscache_stat(&fscache_n_store_vmscan_not_storing);
51972 + fscache_stat_unchecked(&fscache_n_store_vmscan_not_storing);
51973 __fscache_uncache_page(cookie, page);
51974 return true;
51975 }
51976 @@ -91,11 +91,11 @@ try_again:
51977 spin_unlock(&cookie->stores_lock);
51978
51979 if (xpage) {
51980 - fscache_stat(&fscache_n_store_vmscan_cancelled);
51981 - fscache_stat(&fscache_n_store_radix_deletes);
51982 + fscache_stat_unchecked(&fscache_n_store_vmscan_cancelled);
51983 + fscache_stat_unchecked(&fscache_n_store_radix_deletes);
51984 ASSERTCMP(xpage, ==, page);
51985 } else {
51986 - fscache_stat(&fscache_n_store_vmscan_gone);
51987 + fscache_stat_unchecked(&fscache_n_store_vmscan_gone);
51988 }
51989
51990 wake_up_bit(&cookie->flags, 0);
51991 @@ -110,11 +110,11 @@ page_busy:
51992 * sleeping on memory allocation, so we may need to impose a timeout
51993 * too. */
51994 if (!(gfp & __GFP_WAIT)) {
51995 - fscache_stat(&fscache_n_store_vmscan_busy);
51996 + fscache_stat_unchecked(&fscache_n_store_vmscan_busy);
51997 return false;
51998 }
51999
52000 - fscache_stat(&fscache_n_store_vmscan_wait);
52001 + fscache_stat_unchecked(&fscache_n_store_vmscan_wait);
52002 __fscache_wait_on_page_write(cookie, page);
52003 gfp &= ~__GFP_WAIT;
52004 goto try_again;
52005 @@ -140,7 +140,7 @@ static void fscache_end_page_write(struct fscache_object *object,
52006 FSCACHE_COOKIE_STORING_TAG);
52007 if (!radix_tree_tag_get(&cookie->stores, page->index,
52008 FSCACHE_COOKIE_PENDING_TAG)) {
52009 - fscache_stat(&fscache_n_store_radix_deletes);
52010 + fscache_stat_unchecked(&fscache_n_store_radix_deletes);
52011 xpage = radix_tree_delete(&cookie->stores, page->index);
52012 }
52013 spin_unlock(&cookie->stores_lock);
52014 @@ -161,7 +161,7 @@ static void fscache_attr_changed_op(struct fscache_operation *op)
52015
52016 _enter("{OBJ%x OP%x}", object->debug_id, op->debug_id);
52017
52018 - fscache_stat(&fscache_n_attr_changed_calls);
52019 + fscache_stat_unchecked(&fscache_n_attr_changed_calls);
52020
52021 if (fscache_object_is_active(object)) {
52022 fscache_stat(&fscache_n_cop_attr_changed);
52023 @@ -187,11 +187,11 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
52024
52025 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
52026
52027 - fscache_stat(&fscache_n_attr_changed);
52028 + fscache_stat_unchecked(&fscache_n_attr_changed);
52029
52030 op = kzalloc(sizeof(*op), GFP_KERNEL);
52031 if (!op) {
52032 - fscache_stat(&fscache_n_attr_changed_nomem);
52033 + fscache_stat_unchecked(&fscache_n_attr_changed_nomem);
52034 _leave(" = -ENOMEM");
52035 return -ENOMEM;
52036 }
52037 @@ -209,7 +209,7 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
52038 if (fscache_submit_exclusive_op(object, op) < 0)
52039 goto nobufs;
52040 spin_unlock(&cookie->lock);
52041 - fscache_stat(&fscache_n_attr_changed_ok);
52042 + fscache_stat_unchecked(&fscache_n_attr_changed_ok);
52043 fscache_put_operation(op);
52044 _leave(" = 0");
52045 return 0;
52046 @@ -217,7 +217,7 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
52047 nobufs:
52048 spin_unlock(&cookie->lock);
52049 kfree(op);
52050 - fscache_stat(&fscache_n_attr_changed_nobufs);
52051 + fscache_stat_unchecked(&fscache_n_attr_changed_nobufs);
52052 _leave(" = %d", -ENOBUFS);
52053 return -ENOBUFS;
52054 }
52055 @@ -255,7 +255,7 @@ static struct fscache_retrieval *fscache_alloc_retrieval(
52056 /* allocate a retrieval operation and attempt to submit it */
52057 op = kzalloc(sizeof(*op), GFP_NOIO);
52058 if (!op) {
52059 - fscache_stat(&fscache_n_retrievals_nomem);
52060 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
52061 return NULL;
52062 }
52063
52064 @@ -283,13 +283,13 @@ static int fscache_wait_for_deferred_lookup(struct fscache_cookie *cookie)
52065 return 0;
52066 }
52067
52068 - fscache_stat(&fscache_n_retrievals_wait);
52069 + fscache_stat_unchecked(&fscache_n_retrievals_wait);
52070
52071 jif = jiffies;
52072 if (wait_on_bit(&cookie->flags, FSCACHE_COOKIE_LOOKING_UP,
52073 fscache_wait_bit_interruptible,
52074 TASK_INTERRUPTIBLE) != 0) {
52075 - fscache_stat(&fscache_n_retrievals_intr);
52076 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
52077 _leave(" = -ERESTARTSYS");
52078 return -ERESTARTSYS;
52079 }
52080 @@ -318,8 +318,8 @@ static void fscache_do_cancel_retrieval(struct fscache_operation *_op)
52081 */
52082 static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
52083 struct fscache_retrieval *op,
52084 - atomic_t *stat_op_waits,
52085 - atomic_t *stat_object_dead)
52086 + atomic_unchecked_t *stat_op_waits,
52087 + atomic_unchecked_t *stat_object_dead)
52088 {
52089 int ret;
52090
52091 @@ -327,7 +327,7 @@ static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
52092 goto check_if_dead;
52093
52094 _debug(">>> WT");
52095 - fscache_stat(stat_op_waits);
52096 + fscache_stat_unchecked(stat_op_waits);
52097 if (wait_on_bit(&op->op.flags, FSCACHE_OP_WAITING,
52098 fscache_wait_bit_interruptible,
52099 TASK_INTERRUPTIBLE) != 0) {
52100 @@ -344,14 +344,14 @@ static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
52101
52102 check_if_dead:
52103 if (op->op.state == FSCACHE_OP_ST_CANCELLED) {
52104 - fscache_stat(stat_object_dead);
52105 + fscache_stat_unchecked(stat_object_dead);
52106 _leave(" = -ENOBUFS [cancelled]");
52107 return -ENOBUFS;
52108 }
52109 if (unlikely(fscache_object_is_dead(object))) {
52110 pr_err("%s() = -ENOBUFS [obj dead %d]\n", __func__, op->op.state);
52111 fscache_cancel_op(&op->op, fscache_do_cancel_retrieval);
52112 - fscache_stat(stat_object_dead);
52113 + fscache_stat_unchecked(stat_object_dead);
52114 return -ENOBUFS;
52115 }
52116 return 0;
52117 @@ -378,7 +378,7 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
52118
52119 _enter("%p,%p,,,", cookie, page);
52120
52121 - fscache_stat(&fscache_n_retrievals);
52122 + fscache_stat_unchecked(&fscache_n_retrievals);
52123
52124 if (hlist_empty(&cookie->backing_objects))
52125 goto nobufs;
52126 @@ -417,7 +417,7 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
52127 goto nobufs_unlock_dec;
52128 spin_unlock(&cookie->lock);
52129
52130 - fscache_stat(&fscache_n_retrieval_ops);
52131 + fscache_stat_unchecked(&fscache_n_retrieval_ops);
52132
52133 /* pin the netfs read context in case we need to do the actual netfs
52134 * read because we've encountered a cache read failure */
52135 @@ -447,15 +447,15 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
52136
52137 error:
52138 if (ret == -ENOMEM)
52139 - fscache_stat(&fscache_n_retrievals_nomem);
52140 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
52141 else if (ret == -ERESTARTSYS)
52142 - fscache_stat(&fscache_n_retrievals_intr);
52143 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
52144 else if (ret == -ENODATA)
52145 - fscache_stat(&fscache_n_retrievals_nodata);
52146 + fscache_stat_unchecked(&fscache_n_retrievals_nodata);
52147 else if (ret < 0)
52148 - fscache_stat(&fscache_n_retrievals_nobufs);
52149 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
52150 else
52151 - fscache_stat(&fscache_n_retrievals_ok);
52152 + fscache_stat_unchecked(&fscache_n_retrievals_ok);
52153
52154 fscache_put_retrieval(op);
52155 _leave(" = %d", ret);
52156 @@ -467,7 +467,7 @@ nobufs_unlock:
52157 spin_unlock(&cookie->lock);
52158 kfree(op);
52159 nobufs:
52160 - fscache_stat(&fscache_n_retrievals_nobufs);
52161 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
52162 _leave(" = -ENOBUFS");
52163 return -ENOBUFS;
52164 }
52165 @@ -505,7 +505,7 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
52166
52167 _enter("%p,,%d,,,", cookie, *nr_pages);
52168
52169 - fscache_stat(&fscache_n_retrievals);
52170 + fscache_stat_unchecked(&fscache_n_retrievals);
52171
52172 if (hlist_empty(&cookie->backing_objects))
52173 goto nobufs;
52174 @@ -541,7 +541,7 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
52175 goto nobufs_unlock_dec;
52176 spin_unlock(&cookie->lock);
52177
52178 - fscache_stat(&fscache_n_retrieval_ops);
52179 + fscache_stat_unchecked(&fscache_n_retrieval_ops);
52180
52181 /* pin the netfs read context in case we need to do the actual netfs
52182 * read because we've encountered a cache read failure */
52183 @@ -571,15 +571,15 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
52184
52185 error:
52186 if (ret == -ENOMEM)
52187 - fscache_stat(&fscache_n_retrievals_nomem);
52188 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
52189 else if (ret == -ERESTARTSYS)
52190 - fscache_stat(&fscache_n_retrievals_intr);
52191 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
52192 else if (ret == -ENODATA)
52193 - fscache_stat(&fscache_n_retrievals_nodata);
52194 + fscache_stat_unchecked(&fscache_n_retrievals_nodata);
52195 else if (ret < 0)
52196 - fscache_stat(&fscache_n_retrievals_nobufs);
52197 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
52198 else
52199 - fscache_stat(&fscache_n_retrievals_ok);
52200 + fscache_stat_unchecked(&fscache_n_retrievals_ok);
52201
52202 fscache_put_retrieval(op);
52203 _leave(" = %d", ret);
52204 @@ -591,7 +591,7 @@ nobufs_unlock:
52205 spin_unlock(&cookie->lock);
52206 kfree(op);
52207 nobufs:
52208 - fscache_stat(&fscache_n_retrievals_nobufs);
52209 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
52210 _leave(" = -ENOBUFS");
52211 return -ENOBUFS;
52212 }
52213 @@ -615,7 +615,7 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
52214
52215 _enter("%p,%p,,,", cookie, page);
52216
52217 - fscache_stat(&fscache_n_allocs);
52218 + fscache_stat_unchecked(&fscache_n_allocs);
52219
52220 if (hlist_empty(&cookie->backing_objects))
52221 goto nobufs;
52222 @@ -647,7 +647,7 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
52223 goto nobufs_unlock;
52224 spin_unlock(&cookie->lock);
52225
52226 - fscache_stat(&fscache_n_alloc_ops);
52227 + fscache_stat_unchecked(&fscache_n_alloc_ops);
52228
52229 ret = fscache_wait_for_retrieval_activation(
52230 object, op,
52231 @@ -663,11 +663,11 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
52232
52233 error:
52234 if (ret == -ERESTARTSYS)
52235 - fscache_stat(&fscache_n_allocs_intr);
52236 + fscache_stat_unchecked(&fscache_n_allocs_intr);
52237 else if (ret < 0)
52238 - fscache_stat(&fscache_n_allocs_nobufs);
52239 + fscache_stat_unchecked(&fscache_n_allocs_nobufs);
52240 else
52241 - fscache_stat(&fscache_n_allocs_ok);
52242 + fscache_stat_unchecked(&fscache_n_allocs_ok);
52243
52244 fscache_put_retrieval(op);
52245 _leave(" = %d", ret);
52246 @@ -677,7 +677,7 @@ nobufs_unlock:
52247 spin_unlock(&cookie->lock);
52248 kfree(op);
52249 nobufs:
52250 - fscache_stat(&fscache_n_allocs_nobufs);
52251 + fscache_stat_unchecked(&fscache_n_allocs_nobufs);
52252 _leave(" = -ENOBUFS");
52253 return -ENOBUFS;
52254 }
52255 @@ -736,7 +736,7 @@ static void fscache_write_op(struct fscache_operation *_op)
52256
52257 spin_lock(&cookie->stores_lock);
52258
52259 - fscache_stat(&fscache_n_store_calls);
52260 + fscache_stat_unchecked(&fscache_n_store_calls);
52261
52262 /* find a page to store */
52263 page = NULL;
52264 @@ -747,7 +747,7 @@ static void fscache_write_op(struct fscache_operation *_op)
52265 page = results[0];
52266 _debug("gang %d [%lx]", n, page->index);
52267 if (page->index > op->store_limit) {
52268 - fscache_stat(&fscache_n_store_pages_over_limit);
52269 + fscache_stat_unchecked(&fscache_n_store_pages_over_limit);
52270 goto superseded;
52271 }
52272
52273 @@ -759,7 +759,7 @@ static void fscache_write_op(struct fscache_operation *_op)
52274 spin_unlock(&cookie->stores_lock);
52275 spin_unlock(&object->lock);
52276
52277 - fscache_stat(&fscache_n_store_pages);
52278 + fscache_stat_unchecked(&fscache_n_store_pages);
52279 fscache_stat(&fscache_n_cop_write_page);
52280 ret = object->cache->ops->write_page(op, page);
52281 fscache_stat_d(&fscache_n_cop_write_page);
52282 @@ -860,7 +860,7 @@ int __fscache_write_page(struct fscache_cookie *cookie,
52283 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
52284 ASSERT(PageFsCache(page));
52285
52286 - fscache_stat(&fscache_n_stores);
52287 + fscache_stat_unchecked(&fscache_n_stores);
52288
52289 if (test_bit(FSCACHE_COOKIE_INVALIDATING, &cookie->flags)) {
52290 _leave(" = -ENOBUFS [invalidating]");
52291 @@ -916,7 +916,7 @@ int __fscache_write_page(struct fscache_cookie *cookie,
52292 spin_unlock(&cookie->stores_lock);
52293 spin_unlock(&object->lock);
52294
52295 - op->op.debug_id = atomic_inc_return(&fscache_op_debug_id);
52296 + op->op.debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
52297 op->store_limit = object->store_limit;
52298
52299 if (fscache_submit_op(object, &op->op) < 0)
52300 @@ -924,8 +924,8 @@ int __fscache_write_page(struct fscache_cookie *cookie,
52301
52302 spin_unlock(&cookie->lock);
52303 radix_tree_preload_end();
52304 - fscache_stat(&fscache_n_store_ops);
52305 - fscache_stat(&fscache_n_stores_ok);
52306 + fscache_stat_unchecked(&fscache_n_store_ops);
52307 + fscache_stat_unchecked(&fscache_n_stores_ok);
52308
52309 /* the work queue now carries its own ref on the object */
52310 fscache_put_operation(&op->op);
52311 @@ -933,14 +933,14 @@ int __fscache_write_page(struct fscache_cookie *cookie,
52312 return 0;
52313
52314 already_queued:
52315 - fscache_stat(&fscache_n_stores_again);
52316 + fscache_stat_unchecked(&fscache_n_stores_again);
52317 already_pending:
52318 spin_unlock(&cookie->stores_lock);
52319 spin_unlock(&object->lock);
52320 spin_unlock(&cookie->lock);
52321 radix_tree_preload_end();
52322 kfree(op);
52323 - fscache_stat(&fscache_n_stores_ok);
52324 + fscache_stat_unchecked(&fscache_n_stores_ok);
52325 _leave(" = 0");
52326 return 0;
52327
52328 @@ -959,14 +959,14 @@ nobufs:
52329 spin_unlock(&cookie->lock);
52330 radix_tree_preload_end();
52331 kfree(op);
52332 - fscache_stat(&fscache_n_stores_nobufs);
52333 + fscache_stat_unchecked(&fscache_n_stores_nobufs);
52334 _leave(" = -ENOBUFS");
52335 return -ENOBUFS;
52336
52337 nomem_free:
52338 kfree(op);
52339 nomem:
52340 - fscache_stat(&fscache_n_stores_oom);
52341 + fscache_stat_unchecked(&fscache_n_stores_oom);
52342 _leave(" = -ENOMEM");
52343 return -ENOMEM;
52344 }
52345 @@ -984,7 +984,7 @@ void __fscache_uncache_page(struct fscache_cookie *cookie, struct page *page)
52346 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
52347 ASSERTCMP(page, !=, NULL);
52348
52349 - fscache_stat(&fscache_n_uncaches);
52350 + fscache_stat_unchecked(&fscache_n_uncaches);
52351
52352 /* cache withdrawal may beat us to it */
52353 if (!PageFsCache(page))
52354 @@ -1035,7 +1035,7 @@ void fscache_mark_page_cached(struct fscache_retrieval *op, struct page *page)
52355 struct fscache_cookie *cookie = op->op.object->cookie;
52356
52357 #ifdef CONFIG_FSCACHE_STATS
52358 - atomic_inc(&fscache_n_marks);
52359 + atomic_inc_unchecked(&fscache_n_marks);
52360 #endif
52361
52362 _debug("- mark %p{%lx}", page, page->index);
52363 diff --git a/fs/fscache/stats.c b/fs/fscache/stats.c
52364 index 40d13c7..ddf52b9 100644
52365 --- a/fs/fscache/stats.c
52366 +++ b/fs/fscache/stats.c
52367 @@ -18,99 +18,99 @@
52368 /*
52369 * operation counters
52370 */
52371 -atomic_t fscache_n_op_pend;
52372 -atomic_t fscache_n_op_run;
52373 -atomic_t fscache_n_op_enqueue;
52374 -atomic_t fscache_n_op_requeue;
52375 -atomic_t fscache_n_op_deferred_release;
52376 -atomic_t fscache_n_op_release;
52377 -atomic_t fscache_n_op_gc;
52378 -atomic_t fscache_n_op_cancelled;
52379 -atomic_t fscache_n_op_rejected;
52380 +atomic_unchecked_t fscache_n_op_pend;
52381 +atomic_unchecked_t fscache_n_op_run;
52382 +atomic_unchecked_t fscache_n_op_enqueue;
52383 +atomic_unchecked_t fscache_n_op_requeue;
52384 +atomic_unchecked_t fscache_n_op_deferred_release;
52385 +atomic_unchecked_t fscache_n_op_release;
52386 +atomic_unchecked_t fscache_n_op_gc;
52387 +atomic_unchecked_t fscache_n_op_cancelled;
52388 +atomic_unchecked_t fscache_n_op_rejected;
52389
52390 -atomic_t fscache_n_attr_changed;
52391 -atomic_t fscache_n_attr_changed_ok;
52392 -atomic_t fscache_n_attr_changed_nobufs;
52393 -atomic_t fscache_n_attr_changed_nomem;
52394 -atomic_t fscache_n_attr_changed_calls;
52395 +atomic_unchecked_t fscache_n_attr_changed;
52396 +atomic_unchecked_t fscache_n_attr_changed_ok;
52397 +atomic_unchecked_t fscache_n_attr_changed_nobufs;
52398 +atomic_unchecked_t fscache_n_attr_changed_nomem;
52399 +atomic_unchecked_t fscache_n_attr_changed_calls;
52400
52401 -atomic_t fscache_n_allocs;
52402 -atomic_t fscache_n_allocs_ok;
52403 -atomic_t fscache_n_allocs_wait;
52404 -atomic_t fscache_n_allocs_nobufs;
52405 -atomic_t fscache_n_allocs_intr;
52406 -atomic_t fscache_n_allocs_object_dead;
52407 -atomic_t fscache_n_alloc_ops;
52408 -atomic_t fscache_n_alloc_op_waits;
52409 +atomic_unchecked_t fscache_n_allocs;
52410 +atomic_unchecked_t fscache_n_allocs_ok;
52411 +atomic_unchecked_t fscache_n_allocs_wait;
52412 +atomic_unchecked_t fscache_n_allocs_nobufs;
52413 +atomic_unchecked_t fscache_n_allocs_intr;
52414 +atomic_unchecked_t fscache_n_allocs_object_dead;
52415 +atomic_unchecked_t fscache_n_alloc_ops;
52416 +atomic_unchecked_t fscache_n_alloc_op_waits;
52417
52418 -atomic_t fscache_n_retrievals;
52419 -atomic_t fscache_n_retrievals_ok;
52420 -atomic_t fscache_n_retrievals_wait;
52421 -atomic_t fscache_n_retrievals_nodata;
52422 -atomic_t fscache_n_retrievals_nobufs;
52423 -atomic_t fscache_n_retrievals_intr;
52424 -atomic_t fscache_n_retrievals_nomem;
52425 -atomic_t fscache_n_retrievals_object_dead;
52426 -atomic_t fscache_n_retrieval_ops;
52427 -atomic_t fscache_n_retrieval_op_waits;
52428 +atomic_unchecked_t fscache_n_retrievals;
52429 +atomic_unchecked_t fscache_n_retrievals_ok;
52430 +atomic_unchecked_t fscache_n_retrievals_wait;
52431 +atomic_unchecked_t fscache_n_retrievals_nodata;
52432 +atomic_unchecked_t fscache_n_retrievals_nobufs;
52433 +atomic_unchecked_t fscache_n_retrievals_intr;
52434 +atomic_unchecked_t fscache_n_retrievals_nomem;
52435 +atomic_unchecked_t fscache_n_retrievals_object_dead;
52436 +atomic_unchecked_t fscache_n_retrieval_ops;
52437 +atomic_unchecked_t fscache_n_retrieval_op_waits;
52438
52439 -atomic_t fscache_n_stores;
52440 -atomic_t fscache_n_stores_ok;
52441 -atomic_t fscache_n_stores_again;
52442 -atomic_t fscache_n_stores_nobufs;
52443 -atomic_t fscache_n_stores_oom;
52444 -atomic_t fscache_n_store_ops;
52445 -atomic_t fscache_n_store_calls;
52446 -atomic_t fscache_n_store_pages;
52447 -atomic_t fscache_n_store_radix_deletes;
52448 -atomic_t fscache_n_store_pages_over_limit;
52449 +atomic_unchecked_t fscache_n_stores;
52450 +atomic_unchecked_t fscache_n_stores_ok;
52451 +atomic_unchecked_t fscache_n_stores_again;
52452 +atomic_unchecked_t fscache_n_stores_nobufs;
52453 +atomic_unchecked_t fscache_n_stores_oom;
52454 +atomic_unchecked_t fscache_n_store_ops;
52455 +atomic_unchecked_t fscache_n_store_calls;
52456 +atomic_unchecked_t fscache_n_store_pages;
52457 +atomic_unchecked_t fscache_n_store_radix_deletes;
52458 +atomic_unchecked_t fscache_n_store_pages_over_limit;
52459
52460 -atomic_t fscache_n_store_vmscan_not_storing;
52461 -atomic_t fscache_n_store_vmscan_gone;
52462 -atomic_t fscache_n_store_vmscan_busy;
52463 -atomic_t fscache_n_store_vmscan_cancelled;
52464 -atomic_t fscache_n_store_vmscan_wait;
52465 +atomic_unchecked_t fscache_n_store_vmscan_not_storing;
52466 +atomic_unchecked_t fscache_n_store_vmscan_gone;
52467 +atomic_unchecked_t fscache_n_store_vmscan_busy;
52468 +atomic_unchecked_t fscache_n_store_vmscan_cancelled;
52469 +atomic_unchecked_t fscache_n_store_vmscan_wait;
52470
52471 -atomic_t fscache_n_marks;
52472 -atomic_t fscache_n_uncaches;
52473 +atomic_unchecked_t fscache_n_marks;
52474 +atomic_unchecked_t fscache_n_uncaches;
52475
52476 -atomic_t fscache_n_acquires;
52477 -atomic_t fscache_n_acquires_null;
52478 -atomic_t fscache_n_acquires_no_cache;
52479 -atomic_t fscache_n_acquires_ok;
52480 -atomic_t fscache_n_acquires_nobufs;
52481 -atomic_t fscache_n_acquires_oom;
52482 +atomic_unchecked_t fscache_n_acquires;
52483 +atomic_unchecked_t fscache_n_acquires_null;
52484 +atomic_unchecked_t fscache_n_acquires_no_cache;
52485 +atomic_unchecked_t fscache_n_acquires_ok;
52486 +atomic_unchecked_t fscache_n_acquires_nobufs;
52487 +atomic_unchecked_t fscache_n_acquires_oom;
52488
52489 -atomic_t fscache_n_invalidates;
52490 -atomic_t fscache_n_invalidates_run;
52491 +atomic_unchecked_t fscache_n_invalidates;
52492 +atomic_unchecked_t fscache_n_invalidates_run;
52493
52494 -atomic_t fscache_n_updates;
52495 -atomic_t fscache_n_updates_null;
52496 -atomic_t fscache_n_updates_run;
52497 +atomic_unchecked_t fscache_n_updates;
52498 +atomic_unchecked_t fscache_n_updates_null;
52499 +atomic_unchecked_t fscache_n_updates_run;
52500
52501 -atomic_t fscache_n_relinquishes;
52502 -atomic_t fscache_n_relinquishes_null;
52503 -atomic_t fscache_n_relinquishes_waitcrt;
52504 -atomic_t fscache_n_relinquishes_retire;
52505 +atomic_unchecked_t fscache_n_relinquishes;
52506 +atomic_unchecked_t fscache_n_relinquishes_null;
52507 +atomic_unchecked_t fscache_n_relinquishes_waitcrt;
52508 +atomic_unchecked_t fscache_n_relinquishes_retire;
52509
52510 -atomic_t fscache_n_cookie_index;
52511 -atomic_t fscache_n_cookie_data;
52512 -atomic_t fscache_n_cookie_special;
52513 +atomic_unchecked_t fscache_n_cookie_index;
52514 +atomic_unchecked_t fscache_n_cookie_data;
52515 +atomic_unchecked_t fscache_n_cookie_special;
52516
52517 -atomic_t fscache_n_object_alloc;
52518 -atomic_t fscache_n_object_no_alloc;
52519 -atomic_t fscache_n_object_lookups;
52520 -atomic_t fscache_n_object_lookups_negative;
52521 -atomic_t fscache_n_object_lookups_positive;
52522 -atomic_t fscache_n_object_lookups_timed_out;
52523 -atomic_t fscache_n_object_created;
52524 -atomic_t fscache_n_object_avail;
52525 -atomic_t fscache_n_object_dead;
52526 +atomic_unchecked_t fscache_n_object_alloc;
52527 +atomic_unchecked_t fscache_n_object_no_alloc;
52528 +atomic_unchecked_t fscache_n_object_lookups;
52529 +atomic_unchecked_t fscache_n_object_lookups_negative;
52530 +atomic_unchecked_t fscache_n_object_lookups_positive;
52531 +atomic_unchecked_t fscache_n_object_lookups_timed_out;
52532 +atomic_unchecked_t fscache_n_object_created;
52533 +atomic_unchecked_t fscache_n_object_avail;
52534 +atomic_unchecked_t fscache_n_object_dead;
52535
52536 -atomic_t fscache_n_checkaux_none;
52537 -atomic_t fscache_n_checkaux_okay;
52538 -atomic_t fscache_n_checkaux_update;
52539 -atomic_t fscache_n_checkaux_obsolete;
52540 +atomic_unchecked_t fscache_n_checkaux_none;
52541 +atomic_unchecked_t fscache_n_checkaux_okay;
52542 +atomic_unchecked_t fscache_n_checkaux_update;
52543 +atomic_unchecked_t fscache_n_checkaux_obsolete;
52544
52545 atomic_t fscache_n_cop_alloc_object;
52546 atomic_t fscache_n_cop_lookup_object;
52547 @@ -138,118 +138,118 @@ static int fscache_stats_show(struct seq_file *m, void *v)
52548 seq_puts(m, "FS-Cache statistics\n");
52549
52550 seq_printf(m, "Cookies: idx=%u dat=%u spc=%u\n",
52551 - atomic_read(&fscache_n_cookie_index),
52552 - atomic_read(&fscache_n_cookie_data),
52553 - atomic_read(&fscache_n_cookie_special));
52554 + atomic_read_unchecked(&fscache_n_cookie_index),
52555 + atomic_read_unchecked(&fscache_n_cookie_data),
52556 + atomic_read_unchecked(&fscache_n_cookie_special));
52557
52558 seq_printf(m, "Objects: alc=%u nal=%u avl=%u ded=%u\n",
52559 - atomic_read(&fscache_n_object_alloc),
52560 - atomic_read(&fscache_n_object_no_alloc),
52561 - atomic_read(&fscache_n_object_avail),
52562 - atomic_read(&fscache_n_object_dead));
52563 + atomic_read_unchecked(&fscache_n_object_alloc),
52564 + atomic_read_unchecked(&fscache_n_object_no_alloc),
52565 + atomic_read_unchecked(&fscache_n_object_avail),
52566 + atomic_read_unchecked(&fscache_n_object_dead));
52567 seq_printf(m, "ChkAux : non=%u ok=%u upd=%u obs=%u\n",
52568 - atomic_read(&fscache_n_checkaux_none),
52569 - atomic_read(&fscache_n_checkaux_okay),
52570 - atomic_read(&fscache_n_checkaux_update),
52571 - atomic_read(&fscache_n_checkaux_obsolete));
52572 + atomic_read_unchecked(&fscache_n_checkaux_none),
52573 + atomic_read_unchecked(&fscache_n_checkaux_okay),
52574 + atomic_read_unchecked(&fscache_n_checkaux_update),
52575 + atomic_read_unchecked(&fscache_n_checkaux_obsolete));
52576
52577 seq_printf(m, "Pages : mrk=%u unc=%u\n",
52578 - atomic_read(&fscache_n_marks),
52579 - atomic_read(&fscache_n_uncaches));
52580 + atomic_read_unchecked(&fscache_n_marks),
52581 + atomic_read_unchecked(&fscache_n_uncaches));
52582
52583 seq_printf(m, "Acquire: n=%u nul=%u noc=%u ok=%u nbf=%u"
52584 " oom=%u\n",
52585 - atomic_read(&fscache_n_acquires),
52586 - atomic_read(&fscache_n_acquires_null),
52587 - atomic_read(&fscache_n_acquires_no_cache),
52588 - atomic_read(&fscache_n_acquires_ok),
52589 - atomic_read(&fscache_n_acquires_nobufs),
52590 - atomic_read(&fscache_n_acquires_oom));
52591 + atomic_read_unchecked(&fscache_n_acquires),
52592 + atomic_read_unchecked(&fscache_n_acquires_null),
52593 + atomic_read_unchecked(&fscache_n_acquires_no_cache),
52594 + atomic_read_unchecked(&fscache_n_acquires_ok),
52595 + atomic_read_unchecked(&fscache_n_acquires_nobufs),
52596 + atomic_read_unchecked(&fscache_n_acquires_oom));
52597
52598 seq_printf(m, "Lookups: n=%u neg=%u pos=%u crt=%u tmo=%u\n",
52599 - atomic_read(&fscache_n_object_lookups),
52600 - atomic_read(&fscache_n_object_lookups_negative),
52601 - atomic_read(&fscache_n_object_lookups_positive),
52602 - atomic_read(&fscache_n_object_created),
52603 - atomic_read(&fscache_n_object_lookups_timed_out));
52604 + atomic_read_unchecked(&fscache_n_object_lookups),
52605 + atomic_read_unchecked(&fscache_n_object_lookups_negative),
52606 + atomic_read_unchecked(&fscache_n_object_lookups_positive),
52607 + atomic_read_unchecked(&fscache_n_object_created),
52608 + atomic_read_unchecked(&fscache_n_object_lookups_timed_out));
52609
52610 seq_printf(m, "Invals : n=%u run=%u\n",
52611 - atomic_read(&fscache_n_invalidates),
52612 - atomic_read(&fscache_n_invalidates_run));
52613 + atomic_read_unchecked(&fscache_n_invalidates),
52614 + atomic_read_unchecked(&fscache_n_invalidates_run));
52615
52616 seq_printf(m, "Updates: n=%u nul=%u run=%u\n",
52617 - atomic_read(&fscache_n_updates),
52618 - atomic_read(&fscache_n_updates_null),
52619 - atomic_read(&fscache_n_updates_run));
52620 + atomic_read_unchecked(&fscache_n_updates),
52621 + atomic_read_unchecked(&fscache_n_updates_null),
52622 + atomic_read_unchecked(&fscache_n_updates_run));
52623
52624 seq_printf(m, "Relinqs: n=%u nul=%u wcr=%u rtr=%u\n",
52625 - atomic_read(&fscache_n_relinquishes),
52626 - atomic_read(&fscache_n_relinquishes_null),
52627 - atomic_read(&fscache_n_relinquishes_waitcrt),
52628 - atomic_read(&fscache_n_relinquishes_retire));
52629 + atomic_read_unchecked(&fscache_n_relinquishes),
52630 + atomic_read_unchecked(&fscache_n_relinquishes_null),
52631 + atomic_read_unchecked(&fscache_n_relinquishes_waitcrt),
52632 + atomic_read_unchecked(&fscache_n_relinquishes_retire));
52633
52634 seq_printf(m, "AttrChg: n=%u ok=%u nbf=%u oom=%u run=%u\n",
52635 - atomic_read(&fscache_n_attr_changed),
52636 - atomic_read(&fscache_n_attr_changed_ok),
52637 - atomic_read(&fscache_n_attr_changed_nobufs),
52638 - atomic_read(&fscache_n_attr_changed_nomem),
52639 - atomic_read(&fscache_n_attr_changed_calls));
52640 + atomic_read_unchecked(&fscache_n_attr_changed),
52641 + atomic_read_unchecked(&fscache_n_attr_changed_ok),
52642 + atomic_read_unchecked(&fscache_n_attr_changed_nobufs),
52643 + atomic_read_unchecked(&fscache_n_attr_changed_nomem),
52644 + atomic_read_unchecked(&fscache_n_attr_changed_calls));
52645
52646 seq_printf(m, "Allocs : n=%u ok=%u wt=%u nbf=%u int=%u\n",
52647 - atomic_read(&fscache_n_allocs),
52648 - atomic_read(&fscache_n_allocs_ok),
52649 - atomic_read(&fscache_n_allocs_wait),
52650 - atomic_read(&fscache_n_allocs_nobufs),
52651 - atomic_read(&fscache_n_allocs_intr));
52652 + atomic_read_unchecked(&fscache_n_allocs),
52653 + atomic_read_unchecked(&fscache_n_allocs_ok),
52654 + atomic_read_unchecked(&fscache_n_allocs_wait),
52655 + atomic_read_unchecked(&fscache_n_allocs_nobufs),
52656 + atomic_read_unchecked(&fscache_n_allocs_intr));
52657 seq_printf(m, "Allocs : ops=%u owt=%u abt=%u\n",
52658 - atomic_read(&fscache_n_alloc_ops),
52659 - atomic_read(&fscache_n_alloc_op_waits),
52660 - atomic_read(&fscache_n_allocs_object_dead));
52661 + atomic_read_unchecked(&fscache_n_alloc_ops),
52662 + atomic_read_unchecked(&fscache_n_alloc_op_waits),
52663 + atomic_read_unchecked(&fscache_n_allocs_object_dead));
52664
52665 seq_printf(m, "Retrvls: n=%u ok=%u wt=%u nod=%u nbf=%u"
52666 " int=%u oom=%u\n",
52667 - atomic_read(&fscache_n_retrievals),
52668 - atomic_read(&fscache_n_retrievals_ok),
52669 - atomic_read(&fscache_n_retrievals_wait),
52670 - atomic_read(&fscache_n_retrievals_nodata),
52671 - atomic_read(&fscache_n_retrievals_nobufs),
52672 - atomic_read(&fscache_n_retrievals_intr),
52673 - atomic_read(&fscache_n_retrievals_nomem));
52674 + atomic_read_unchecked(&fscache_n_retrievals),
52675 + atomic_read_unchecked(&fscache_n_retrievals_ok),
52676 + atomic_read_unchecked(&fscache_n_retrievals_wait),
52677 + atomic_read_unchecked(&fscache_n_retrievals_nodata),
52678 + atomic_read_unchecked(&fscache_n_retrievals_nobufs),
52679 + atomic_read_unchecked(&fscache_n_retrievals_intr),
52680 + atomic_read_unchecked(&fscache_n_retrievals_nomem));
52681 seq_printf(m, "Retrvls: ops=%u owt=%u abt=%u\n",
52682 - atomic_read(&fscache_n_retrieval_ops),
52683 - atomic_read(&fscache_n_retrieval_op_waits),
52684 - atomic_read(&fscache_n_retrievals_object_dead));
52685 + atomic_read_unchecked(&fscache_n_retrieval_ops),
52686 + atomic_read_unchecked(&fscache_n_retrieval_op_waits),
52687 + atomic_read_unchecked(&fscache_n_retrievals_object_dead));
52688
52689 seq_printf(m, "Stores : n=%u ok=%u agn=%u nbf=%u oom=%u\n",
52690 - atomic_read(&fscache_n_stores),
52691 - atomic_read(&fscache_n_stores_ok),
52692 - atomic_read(&fscache_n_stores_again),
52693 - atomic_read(&fscache_n_stores_nobufs),
52694 - atomic_read(&fscache_n_stores_oom));
52695 + atomic_read_unchecked(&fscache_n_stores),
52696 + atomic_read_unchecked(&fscache_n_stores_ok),
52697 + atomic_read_unchecked(&fscache_n_stores_again),
52698 + atomic_read_unchecked(&fscache_n_stores_nobufs),
52699 + atomic_read_unchecked(&fscache_n_stores_oom));
52700 seq_printf(m, "Stores : ops=%u run=%u pgs=%u rxd=%u olm=%u\n",
52701 - atomic_read(&fscache_n_store_ops),
52702 - atomic_read(&fscache_n_store_calls),
52703 - atomic_read(&fscache_n_store_pages),
52704 - atomic_read(&fscache_n_store_radix_deletes),
52705 - atomic_read(&fscache_n_store_pages_over_limit));
52706 + atomic_read_unchecked(&fscache_n_store_ops),
52707 + atomic_read_unchecked(&fscache_n_store_calls),
52708 + atomic_read_unchecked(&fscache_n_store_pages),
52709 + atomic_read_unchecked(&fscache_n_store_radix_deletes),
52710 + atomic_read_unchecked(&fscache_n_store_pages_over_limit));
52711
52712 seq_printf(m, "VmScan : nos=%u gon=%u bsy=%u can=%u wt=%u\n",
52713 - atomic_read(&fscache_n_store_vmscan_not_storing),
52714 - atomic_read(&fscache_n_store_vmscan_gone),
52715 - atomic_read(&fscache_n_store_vmscan_busy),
52716 - atomic_read(&fscache_n_store_vmscan_cancelled),
52717 - atomic_read(&fscache_n_store_vmscan_wait));
52718 + atomic_read_unchecked(&fscache_n_store_vmscan_not_storing),
52719 + atomic_read_unchecked(&fscache_n_store_vmscan_gone),
52720 + atomic_read_unchecked(&fscache_n_store_vmscan_busy),
52721 + atomic_read_unchecked(&fscache_n_store_vmscan_cancelled),
52722 + atomic_read_unchecked(&fscache_n_store_vmscan_wait));
52723
52724 seq_printf(m, "Ops : pend=%u run=%u enq=%u can=%u rej=%u\n",
52725 - atomic_read(&fscache_n_op_pend),
52726 - atomic_read(&fscache_n_op_run),
52727 - atomic_read(&fscache_n_op_enqueue),
52728 - atomic_read(&fscache_n_op_cancelled),
52729 - atomic_read(&fscache_n_op_rejected));
52730 + atomic_read_unchecked(&fscache_n_op_pend),
52731 + atomic_read_unchecked(&fscache_n_op_run),
52732 + atomic_read_unchecked(&fscache_n_op_enqueue),
52733 + atomic_read_unchecked(&fscache_n_op_cancelled),
52734 + atomic_read_unchecked(&fscache_n_op_rejected));
52735 seq_printf(m, "Ops : dfr=%u rel=%u gc=%u\n",
52736 - atomic_read(&fscache_n_op_deferred_release),
52737 - atomic_read(&fscache_n_op_release),
52738 - atomic_read(&fscache_n_op_gc));
52739 + atomic_read_unchecked(&fscache_n_op_deferred_release),
52740 + atomic_read_unchecked(&fscache_n_op_release),
52741 + atomic_read_unchecked(&fscache_n_op_gc));
52742
52743 seq_printf(m, "CacheOp: alo=%d luo=%d luc=%d gro=%d\n",
52744 atomic_read(&fscache_n_cop_alloc_object),
52745 diff --git a/fs/fuse/cuse.c b/fs/fuse/cuse.c
52746 index 6f96a8d..6019bb9 100644
52747 --- a/fs/fuse/cuse.c
52748 +++ b/fs/fuse/cuse.c
52749 @@ -597,10 +597,12 @@ static int __init cuse_init(void)
52750 INIT_LIST_HEAD(&cuse_conntbl[i]);
52751
52752 /* inherit and extend fuse_dev_operations */
52753 - cuse_channel_fops = fuse_dev_operations;
52754 - cuse_channel_fops.owner = THIS_MODULE;
52755 - cuse_channel_fops.open = cuse_channel_open;
52756 - cuse_channel_fops.release = cuse_channel_release;
52757 + pax_open_kernel();
52758 + memcpy((void *)&cuse_channel_fops, &fuse_dev_operations, sizeof(fuse_dev_operations));
52759 + *(void **)&cuse_channel_fops.owner = THIS_MODULE;
52760 + *(void **)&cuse_channel_fops.open = cuse_channel_open;
52761 + *(void **)&cuse_channel_fops.release = cuse_channel_release;
52762 + pax_close_kernel();
52763
52764 cuse_class = class_create(THIS_MODULE, "cuse");
52765 if (IS_ERR(cuse_class))
52766 diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
52767 index 11dfa0c..6f64416 100644
52768 --- a/fs/fuse/dev.c
52769 +++ b/fs/fuse/dev.c
52770 @@ -1294,7 +1294,7 @@ static ssize_t fuse_dev_splice_read(struct file *in, loff_t *ppos,
52771 ret = 0;
52772 pipe_lock(pipe);
52773
52774 - if (!pipe->readers) {
52775 + if (!atomic_read(&pipe->readers)) {
52776 send_sig(SIGPIPE, current, 0);
52777 if (!ret)
52778 ret = -EPIPE;
52779 diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
52780 index 185c479..51b9986 100644
52781 --- a/fs/fuse/dir.c
52782 +++ b/fs/fuse/dir.c
52783 @@ -1415,7 +1415,7 @@ static char *read_link(struct dentry *dentry)
52784 return link;
52785 }
52786
52787 -static void free_link(char *link)
52788 +static void free_link(const char *link)
52789 {
52790 if (!IS_ERR(link))
52791 free_page((unsigned long) link);
52792 diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
52793 index cc00bd1..3edb692 100644
52794 --- a/fs/gfs2/inode.c
52795 +++ b/fs/gfs2/inode.c
52796 @@ -1500,7 +1500,7 @@ out:
52797
52798 static void gfs2_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
52799 {
52800 - char *s = nd_get_link(nd);
52801 + const char *s = nd_get_link(nd);
52802 if (!IS_ERR(s))
52803 kfree(s);
52804 }
52805 diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
52806 index a3f868a..bb308ae 100644
52807 --- a/fs/hugetlbfs/inode.c
52808 +++ b/fs/hugetlbfs/inode.c
52809 @@ -152,6 +152,7 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
52810 struct mm_struct *mm = current->mm;
52811 struct vm_area_struct *vma;
52812 struct hstate *h = hstate_file(file);
52813 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
52814 struct vm_unmapped_area_info info;
52815
52816 if (len & ~huge_page_mask(h))
52817 @@ -165,17 +166,26 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
52818 return addr;
52819 }
52820
52821 +#ifdef CONFIG_PAX_RANDMMAP
52822 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
52823 +#endif
52824 +
52825 if (addr) {
52826 addr = ALIGN(addr, huge_page_size(h));
52827 vma = find_vma(mm, addr);
52828 - if (TASK_SIZE - len >= addr &&
52829 - (!vma || addr + len <= vma->vm_start))
52830 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
52831 return addr;
52832 }
52833
52834 info.flags = 0;
52835 info.length = len;
52836 info.low_limit = TASK_UNMAPPED_BASE;
52837 +
52838 +#ifdef CONFIG_PAX_RANDMMAP
52839 + if (mm->pax_flags & MF_PAX_RANDMMAP)
52840 + info.low_limit += mm->delta_mmap;
52841 +#endif
52842 +
52843 info.high_limit = TASK_SIZE;
52844 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
52845 info.align_offset = 0;
52846 @@ -898,7 +908,7 @@ static struct file_system_type hugetlbfs_fs_type = {
52847 };
52848 MODULE_ALIAS_FS("hugetlbfs");
52849
52850 -static struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
52851 +struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
52852
52853 static int can_do_hugetlb_shm(void)
52854 {
52855 diff --git a/fs/inode.c b/fs/inode.c
52856 index a898b3d..9b5a214 100644
52857 --- a/fs/inode.c
52858 +++ b/fs/inode.c
52859 @@ -878,8 +878,8 @@ unsigned int get_next_ino(void)
52860
52861 #ifdef CONFIG_SMP
52862 if (unlikely((res & (LAST_INO_BATCH-1)) == 0)) {
52863 - static atomic_t shared_last_ino;
52864 - int next = atomic_add_return(LAST_INO_BATCH, &shared_last_ino);
52865 + static atomic_unchecked_t shared_last_ino;
52866 + int next = atomic_add_return_unchecked(LAST_INO_BATCH, &shared_last_ino);
52867
52868 res = next - LAST_INO_BATCH;
52869 }
52870 diff --git a/fs/jffs2/erase.c b/fs/jffs2/erase.c
52871 index 4a6cf28..d3a29d3 100644
52872 --- a/fs/jffs2/erase.c
52873 +++ b/fs/jffs2/erase.c
52874 @@ -452,7 +452,8 @@ static void jffs2_mark_erased_block(struct jffs2_sb_info *c, struct jffs2_eraseb
52875 struct jffs2_unknown_node marker = {
52876 .magic = cpu_to_je16(JFFS2_MAGIC_BITMASK),
52877 .nodetype = cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER),
52878 - .totlen = cpu_to_je32(c->cleanmarker_size)
52879 + .totlen = cpu_to_je32(c->cleanmarker_size),
52880 + .hdr_crc = cpu_to_je32(0)
52881 };
52882
52883 jffs2_prealloc_raw_node_refs(c, jeb, 1);
52884 diff --git a/fs/jffs2/wbuf.c b/fs/jffs2/wbuf.c
52885 index a6597d6..41b30ec 100644
52886 --- a/fs/jffs2/wbuf.c
52887 +++ b/fs/jffs2/wbuf.c
52888 @@ -1023,7 +1023,8 @@ static const struct jffs2_unknown_node oob_cleanmarker =
52889 {
52890 .magic = constant_cpu_to_je16(JFFS2_MAGIC_BITMASK),
52891 .nodetype = constant_cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER),
52892 - .totlen = constant_cpu_to_je32(8)
52893 + .totlen = constant_cpu_to_je32(8),
52894 + .hdr_crc = constant_cpu_to_je32(0)
52895 };
52896
52897 /*
52898 diff --git a/fs/jfs/super.c b/fs/jfs/super.c
52899 index 2003e83..40db287 100644
52900 --- a/fs/jfs/super.c
52901 +++ b/fs/jfs/super.c
52902 @@ -856,7 +856,7 @@ static int __init init_jfs_fs(void)
52903
52904 jfs_inode_cachep =
52905 kmem_cache_create("jfs_ip", sizeof(struct jfs_inode_info), 0,
52906 - SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD,
52907 + SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD|SLAB_USERCOPY,
52908 init_once);
52909 if (jfs_inode_cachep == NULL)
52910 return -ENOMEM;
52911 diff --git a/fs/libfs.c b/fs/libfs.c
52912 index 916da8c..1588998 100644
52913 --- a/fs/libfs.c
52914 +++ b/fs/libfs.c
52915 @@ -165,6 +165,9 @@ int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir)
52916
52917 for (p=q->next; p != &dentry->d_subdirs; p=p->next) {
52918 struct dentry *next;
52919 + char d_name[sizeof(next->d_iname)];
52920 + const unsigned char *name;
52921 +
52922 next = list_entry(p, struct dentry, d_u.d_child);
52923 spin_lock_nested(&next->d_lock, DENTRY_D_LOCK_NESTED);
52924 if (!simple_positive(next)) {
52925 @@ -174,7 +177,12 @@ int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir)
52926
52927 spin_unlock(&next->d_lock);
52928 spin_unlock(&dentry->d_lock);
52929 - if (filldir(dirent, next->d_name.name,
52930 + name = next->d_name.name;
52931 + if (name == next->d_iname) {
52932 + memcpy(d_name, name, next->d_name.len);
52933 + name = d_name;
52934 + }
52935 + if (filldir(dirent, name,
52936 next->d_name.len, filp->f_pos,
52937 next->d_inode->i_ino,
52938 dt_type(next->d_inode)) < 0)
52939 diff --git a/fs/lockd/clntproc.c b/fs/lockd/clntproc.c
52940 index 9760ecb..9b838ef 100644
52941 --- a/fs/lockd/clntproc.c
52942 +++ b/fs/lockd/clntproc.c
52943 @@ -36,11 +36,11 @@ static const struct rpc_call_ops nlmclnt_cancel_ops;
52944 /*
52945 * Cookie counter for NLM requests
52946 */
52947 -static atomic_t nlm_cookie = ATOMIC_INIT(0x1234);
52948 +static atomic_unchecked_t nlm_cookie = ATOMIC_INIT(0x1234);
52949
52950 void nlmclnt_next_cookie(struct nlm_cookie *c)
52951 {
52952 - u32 cookie = atomic_inc_return(&nlm_cookie);
52953 + u32 cookie = atomic_inc_return_unchecked(&nlm_cookie);
52954
52955 memcpy(c->data, &cookie, 4);
52956 c->len=4;
52957 diff --git a/fs/locks.c b/fs/locks.c
52958 index cb424a4..850e4dd 100644
52959 --- a/fs/locks.c
52960 +++ b/fs/locks.c
52961 @@ -2064,16 +2064,16 @@ void locks_remove_flock(struct file *filp)
52962 return;
52963
52964 if (filp->f_op && filp->f_op->flock) {
52965 - struct file_lock fl = {
52966 + struct file_lock flock = {
52967 .fl_pid = current->tgid,
52968 .fl_file = filp,
52969 .fl_flags = FL_FLOCK,
52970 .fl_type = F_UNLCK,
52971 .fl_end = OFFSET_MAX,
52972 };
52973 - filp->f_op->flock(filp, F_SETLKW, &fl);
52974 - if (fl.fl_ops && fl.fl_ops->fl_release_private)
52975 - fl.fl_ops->fl_release_private(&fl);
52976 + filp->f_op->flock(filp, F_SETLKW, &flock);
52977 + if (flock.fl_ops && flock.fl_ops->fl_release_private)
52978 + flock.fl_ops->fl_release_private(&flock);
52979 }
52980
52981 lock_flocks();
52982 diff --git a/fs/namei.c b/fs/namei.c
52983 index 85e40d1..b66744e 100644
52984 --- a/fs/namei.c
52985 +++ b/fs/namei.c
52986 @@ -319,16 +319,32 @@ int generic_permission(struct inode *inode, int mask)
52987 if (ret != -EACCES)
52988 return ret;
52989
52990 +#ifdef CONFIG_GRKERNSEC
52991 + /* we'll block if we have to log due to a denied capability use */
52992 + if (mask & MAY_NOT_BLOCK)
52993 + return -ECHILD;
52994 +#endif
52995 +
52996 if (S_ISDIR(inode->i_mode)) {
52997 /* DACs are overridable for directories */
52998 - if (inode_capable(inode, CAP_DAC_OVERRIDE))
52999 - return 0;
53000 if (!(mask & MAY_WRITE))
53001 - if (inode_capable(inode, CAP_DAC_READ_SEARCH))
53002 + if (inode_capable_nolog(inode, CAP_DAC_OVERRIDE) ||
53003 + inode_capable(inode, CAP_DAC_READ_SEARCH))
53004 return 0;
53005 + if (inode_capable(inode, CAP_DAC_OVERRIDE))
53006 + return 0;
53007 return -EACCES;
53008 }
53009 /*
53010 + * Searching includes executable on directories, else just read.
53011 + */
53012 + mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
53013 + if (mask == MAY_READ)
53014 + if (inode_capable_nolog(inode, CAP_DAC_OVERRIDE) ||
53015 + inode_capable(inode, CAP_DAC_READ_SEARCH))
53016 + return 0;
53017 +
53018 + /*
53019 * Read/write DACs are always overridable.
53020 * Executable DACs are overridable when there is
53021 * at least one exec bit set.
53022 @@ -337,14 +353,6 @@ int generic_permission(struct inode *inode, int mask)
53023 if (inode_capable(inode, CAP_DAC_OVERRIDE))
53024 return 0;
53025
53026 - /*
53027 - * Searching includes executable on directories, else just read.
53028 - */
53029 - mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
53030 - if (mask == MAY_READ)
53031 - if (inode_capable(inode, CAP_DAC_READ_SEARCH))
53032 - return 0;
53033 -
53034 return -EACCES;
53035 }
53036
53037 @@ -820,7 +828,7 @@ follow_link(struct path *link, struct nameidata *nd, void **p)
53038 {
53039 struct dentry *dentry = link->dentry;
53040 int error;
53041 - char *s;
53042 + const char *s;
53043
53044 BUG_ON(nd->flags & LOOKUP_RCU);
53045
53046 @@ -841,6 +849,12 @@ follow_link(struct path *link, struct nameidata *nd, void **p)
53047 if (error)
53048 goto out_put_nd_path;
53049
53050 + if (gr_handle_follow_link(dentry->d_parent->d_inode,
53051 + dentry->d_inode, dentry, nd->path.mnt)) {
53052 + error = -EACCES;
53053 + goto out_put_nd_path;
53054 + }
53055 +
53056 nd->last_type = LAST_BIND;
53057 *p = dentry->d_inode->i_op->follow_link(dentry, nd);
53058 error = PTR_ERR(*p);
53059 @@ -1588,6 +1602,8 @@ static inline int nested_symlink(struct path *path, struct nameidata *nd)
53060 if (res)
53061 break;
53062 res = walk_component(nd, path, LOOKUP_FOLLOW);
53063 + if (res >= 0 && gr_handle_symlink_owner(&link, nd->inode))
53064 + res = -EACCES;
53065 put_link(nd, &link, cookie);
53066 } while (res > 0);
53067
53068 @@ -1686,7 +1702,7 @@ EXPORT_SYMBOL(full_name_hash);
53069 static inline unsigned long hash_name(const char *name, unsigned int *hashp)
53070 {
53071 unsigned long a, b, adata, bdata, mask, hash, len;
53072 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
53073 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
53074
53075 hash = a = 0;
53076 len = -sizeof(unsigned long);
53077 @@ -1968,6 +1984,8 @@ static int path_lookupat(int dfd, const char *name,
53078 if (err)
53079 break;
53080 err = lookup_last(nd, &path);
53081 + if (!err && gr_handle_symlink_owner(&link, nd->inode))
53082 + err = -EACCES;
53083 put_link(nd, &link, cookie);
53084 }
53085 }
53086 @@ -1975,6 +1993,13 @@ static int path_lookupat(int dfd, const char *name,
53087 if (!err)
53088 err = complete_walk(nd);
53089
53090 + if (!err && !(nd->flags & LOOKUP_PARENT)) {
53091 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
53092 + path_put(&nd->path);
53093 + err = -ENOENT;
53094 + }
53095 + }
53096 +
53097 if (!err && nd->flags & LOOKUP_DIRECTORY) {
53098 if (!nd->inode->i_op->lookup) {
53099 path_put(&nd->path);
53100 @@ -2002,8 +2027,15 @@ static int filename_lookup(int dfd, struct filename *name,
53101 retval = path_lookupat(dfd, name->name,
53102 flags | LOOKUP_REVAL, nd);
53103
53104 - if (likely(!retval))
53105 + if (likely(!retval)) {
53106 audit_inode(name, nd->path.dentry, flags & LOOKUP_PARENT);
53107 + if (name->name[0] != '/' && nd->path.dentry && nd->inode) {
53108 + if (!gr_chroot_fchdir(nd->path.dentry, nd->path.mnt)) {
53109 + path_put(&nd->path);
53110 + return -ENOENT;
53111 + }
53112 + }
53113 + }
53114 return retval;
53115 }
53116
53117 @@ -2381,6 +2413,13 @@ static int may_open(struct path *path, int acc_mode, int flag)
53118 if (flag & O_NOATIME && !inode_owner_or_capable(inode))
53119 return -EPERM;
53120
53121 + if (gr_handle_rofs_blockwrite(dentry, path->mnt, acc_mode))
53122 + return -EPERM;
53123 + if (gr_handle_rawio(inode))
53124 + return -EPERM;
53125 + if (!gr_acl_handle_open(dentry, path->mnt, acc_mode))
53126 + return -EACCES;
53127 +
53128 return 0;
53129 }
53130
53131 @@ -2602,7 +2641,7 @@ looked_up:
53132 * cleared otherwise prior to returning.
53133 */
53134 static int lookup_open(struct nameidata *nd, struct path *path,
53135 - struct file *file,
53136 + struct path *link, struct file *file,
53137 const struct open_flags *op,
53138 bool got_write, int *opened)
53139 {
53140 @@ -2637,6 +2676,17 @@ static int lookup_open(struct nameidata *nd, struct path *path,
53141 /* Negative dentry, just create the file */
53142 if (!dentry->d_inode && (op->open_flag & O_CREAT)) {
53143 umode_t mode = op->mode;
53144 +
53145 + if (link && gr_handle_symlink_owner(link, dir->d_inode)) {
53146 + error = -EACCES;
53147 + goto out_dput;
53148 + }
53149 +
53150 + if (!gr_acl_handle_creat(dentry, dir, nd->path.mnt, op->open_flag, op->acc_mode, mode)) {
53151 + error = -EACCES;
53152 + goto out_dput;
53153 + }
53154 +
53155 if (!IS_POSIXACL(dir->d_inode))
53156 mode &= ~current_umask();
53157 /*
53158 @@ -2658,6 +2708,8 @@ static int lookup_open(struct nameidata *nd, struct path *path,
53159 nd->flags & LOOKUP_EXCL);
53160 if (error)
53161 goto out_dput;
53162 + else
53163 + gr_handle_create(dentry, nd->path.mnt);
53164 }
53165 out_no_open:
53166 path->dentry = dentry;
53167 @@ -2672,7 +2724,7 @@ out_dput:
53168 /*
53169 * Handle the last step of open()
53170 */
53171 -static int do_last(struct nameidata *nd, struct path *path,
53172 +static int do_last(struct nameidata *nd, struct path *path, struct path *link,
53173 struct file *file, const struct open_flags *op,
53174 int *opened, struct filename *name)
53175 {
53176 @@ -2701,16 +2753,32 @@ static int do_last(struct nameidata *nd, struct path *path,
53177 error = complete_walk(nd);
53178 if (error)
53179 return error;
53180 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
53181 + error = -ENOENT;
53182 + goto out;
53183 + }
53184 audit_inode(name, nd->path.dentry, 0);
53185 if (open_flag & O_CREAT) {
53186 error = -EISDIR;
53187 goto out;
53188 }
53189 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
53190 + error = -EACCES;
53191 + goto out;
53192 + }
53193 goto finish_open;
53194 case LAST_BIND:
53195 error = complete_walk(nd);
53196 if (error)
53197 return error;
53198 + if (!gr_acl_handle_hidden_file(dir, nd->path.mnt)) {
53199 + error = -ENOENT;
53200 + goto out;
53201 + }
53202 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
53203 + error = -EACCES;
53204 + goto out;
53205 + }
53206 audit_inode(name, dir, 0);
53207 goto finish_open;
53208 }
53209 @@ -2759,7 +2827,7 @@ retry_lookup:
53210 */
53211 }
53212 mutex_lock(&dir->d_inode->i_mutex);
53213 - error = lookup_open(nd, path, file, op, got_write, opened);
53214 + error = lookup_open(nd, path, link, file, op, got_write, opened);
53215 mutex_unlock(&dir->d_inode->i_mutex);
53216
53217 if (error <= 0) {
53218 @@ -2783,11 +2851,28 @@ retry_lookup:
53219 goto finish_open_created;
53220 }
53221
53222 + if (!gr_acl_handle_hidden_file(path->dentry, nd->path.mnt)) {
53223 + error = -ENOENT;
53224 + goto exit_dput;
53225 + }
53226 + if (link && gr_handle_symlink_owner(link, path->dentry->d_inode)) {
53227 + error = -EACCES;
53228 + goto exit_dput;
53229 + }
53230 +
53231 /*
53232 * create/update audit record if it already exists.
53233 */
53234 - if (path->dentry->d_inode)
53235 + if (path->dentry->d_inode) {
53236 + /* only check if O_CREAT is specified, all other checks need to go
53237 + into may_open */
53238 + if (gr_handle_fifo(path->dentry, path->mnt, dir, open_flag, acc_mode)) {
53239 + error = -EACCES;
53240 + goto exit_dput;
53241 + }
53242 +
53243 audit_inode(name, path->dentry, 0);
53244 + }
53245
53246 /*
53247 * If atomic_open() acquired write access it is dropped now due to
53248 @@ -2828,6 +2913,11 @@ finish_lookup:
53249 }
53250 }
53251 BUG_ON(inode != path->dentry->d_inode);
53252 + /* if we're resolving a symlink to another symlink */
53253 + if (link && gr_handle_symlink_owner(link, inode)) {
53254 + error = -EACCES;
53255 + goto out;
53256 + }
53257 return 1;
53258 }
53259
53260 @@ -2837,7 +2927,6 @@ finish_lookup:
53261 save_parent.dentry = nd->path.dentry;
53262 save_parent.mnt = mntget(path->mnt);
53263 nd->path.dentry = path->dentry;
53264 -
53265 }
53266 nd->inode = inode;
53267 /* Why this, you ask? _Now_ we might have grown LOOKUP_JUMPED... */
53268 @@ -2846,6 +2935,16 @@ finish_lookup:
53269 path_put(&save_parent);
53270 return error;
53271 }
53272 +
53273 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
53274 + error = -ENOENT;
53275 + goto out;
53276 + }
53277 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
53278 + error = -EACCES;
53279 + goto out;
53280 + }
53281 +
53282 error = -EISDIR;
53283 if ((open_flag & O_CREAT) && S_ISDIR(nd->inode->i_mode))
53284 goto out;
53285 @@ -2944,7 +3043,7 @@ static struct file *path_openat(int dfd, struct filename *pathname,
53286 if (unlikely(error))
53287 goto out;
53288
53289 - error = do_last(nd, &path, file, op, &opened, pathname);
53290 + error = do_last(nd, &path, NULL, file, op, &opened, pathname);
53291 while (unlikely(error > 0)) { /* trailing symlink */
53292 struct path link = path;
53293 void *cookie;
53294 @@ -2962,7 +3061,7 @@ static struct file *path_openat(int dfd, struct filename *pathname,
53295 error = follow_link(&link, nd, &cookie);
53296 if (unlikely(error))
53297 break;
53298 - error = do_last(nd, &path, file, op, &opened, pathname);
53299 + error = do_last(nd, &path, &link, file, op, &opened, pathname);
53300 put_link(nd, &link, cookie);
53301 }
53302 out:
53303 @@ -3062,8 +3161,12 @@ struct dentry *kern_path_create(int dfd, const char *pathname,
53304 goto unlock;
53305
53306 error = -EEXIST;
53307 - if (dentry->d_inode)
53308 + if (dentry->d_inode) {
53309 + if (!gr_acl_handle_hidden_file(dentry, nd.path.mnt)) {
53310 + error = -ENOENT;
53311 + }
53312 goto fail;
53313 + }
53314 /*
53315 * Special case - lookup gave negative, but... we had foo/bar/
53316 * From the vfs_mknod() POV we just have a negative dentry -
53317 @@ -3115,6 +3218,20 @@ struct dentry *user_path_create(int dfd, const char __user *pathname,
53318 }
53319 EXPORT_SYMBOL(user_path_create);
53320
53321 +static struct dentry *user_path_create_with_name(int dfd, const char __user *pathname, struct path *path, struct filename **to, unsigned int lookup_flags)
53322 +{
53323 + struct filename *tmp = getname(pathname);
53324 + struct dentry *res;
53325 + if (IS_ERR(tmp))
53326 + return ERR_CAST(tmp);
53327 + res = kern_path_create(dfd, tmp->name, path, lookup_flags);
53328 + if (IS_ERR(res))
53329 + putname(tmp);
53330 + else
53331 + *to = tmp;
53332 + return res;
53333 +}
53334 +
53335 int vfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev)
53336 {
53337 int error = may_create(dir, dentry);
53338 @@ -3177,6 +3294,17 @@ retry:
53339
53340 if (!IS_POSIXACL(path.dentry->d_inode))
53341 mode &= ~current_umask();
53342 +
53343 + if (gr_handle_chroot_mknod(dentry, path.mnt, mode)) {
53344 + error = -EPERM;
53345 + goto out;
53346 + }
53347 +
53348 + if (!gr_acl_handle_mknod(dentry, path.dentry, path.mnt, mode)) {
53349 + error = -EACCES;
53350 + goto out;
53351 + }
53352 +
53353 error = security_path_mknod(&path, dentry, mode, dev);
53354 if (error)
53355 goto out;
53356 @@ -3193,6 +3321,8 @@ retry:
53357 break;
53358 }
53359 out:
53360 + if (!error)
53361 + gr_handle_create(dentry, path.mnt);
53362 done_path_create(&path, dentry);
53363 if (retry_estale(error, lookup_flags)) {
53364 lookup_flags |= LOOKUP_REVAL;
53365 @@ -3245,9 +3375,16 @@ retry:
53366
53367 if (!IS_POSIXACL(path.dentry->d_inode))
53368 mode &= ~current_umask();
53369 + if (!gr_acl_handle_mkdir(dentry, path.dentry, path.mnt)) {
53370 + error = -EACCES;
53371 + goto out;
53372 + }
53373 error = security_path_mkdir(&path, dentry, mode);
53374 if (!error)
53375 error = vfs_mkdir(path.dentry->d_inode, dentry, mode);
53376 + if (!error)
53377 + gr_handle_create(dentry, path.mnt);
53378 +out:
53379 done_path_create(&path, dentry);
53380 if (retry_estale(error, lookup_flags)) {
53381 lookup_flags |= LOOKUP_REVAL;
53382 @@ -3328,6 +3465,8 @@ static long do_rmdir(int dfd, const char __user *pathname)
53383 struct filename *name;
53384 struct dentry *dentry;
53385 struct nameidata nd;
53386 + ino_t saved_ino = 0;
53387 + dev_t saved_dev = 0;
53388 unsigned int lookup_flags = 0;
53389 retry:
53390 name = user_path_parent(dfd, pathname, &nd, lookup_flags);
53391 @@ -3360,10 +3499,21 @@ retry:
53392 error = -ENOENT;
53393 goto exit3;
53394 }
53395 +
53396 + saved_ino = dentry->d_inode->i_ino;
53397 + saved_dev = gr_get_dev_from_dentry(dentry);
53398 +
53399 + if (!gr_acl_handle_rmdir(dentry, nd.path.mnt)) {
53400 + error = -EACCES;
53401 + goto exit3;
53402 + }
53403 +
53404 error = security_path_rmdir(&nd.path, dentry);
53405 if (error)
53406 goto exit3;
53407 error = vfs_rmdir(nd.path.dentry->d_inode, dentry);
53408 + if (!error && (saved_dev || saved_ino))
53409 + gr_handle_delete(saved_ino, saved_dev);
53410 exit3:
53411 dput(dentry);
53412 exit2:
53413 @@ -3429,6 +3579,8 @@ static long do_unlinkat(int dfd, const char __user *pathname)
53414 struct dentry *dentry;
53415 struct nameidata nd;
53416 struct inode *inode = NULL;
53417 + ino_t saved_ino = 0;
53418 + dev_t saved_dev = 0;
53419 unsigned int lookup_flags = 0;
53420 retry:
53421 name = user_path_parent(dfd, pathname, &nd, lookup_flags);
53422 @@ -3455,10 +3607,22 @@ retry:
53423 if (!inode)
53424 goto slashes;
53425 ihold(inode);
53426 +
53427 + if (inode->i_nlink <= 1) {
53428 + saved_ino = inode->i_ino;
53429 + saved_dev = gr_get_dev_from_dentry(dentry);
53430 + }
53431 + if (!gr_acl_handle_unlink(dentry, nd.path.mnt)) {
53432 + error = -EACCES;
53433 + goto exit2;
53434 + }
53435 +
53436 error = security_path_unlink(&nd.path, dentry);
53437 if (error)
53438 goto exit2;
53439 error = vfs_unlink(nd.path.dentry->d_inode, dentry);
53440 + if (!error && (saved_ino || saved_dev))
53441 + gr_handle_delete(saved_ino, saved_dev);
53442 exit2:
53443 dput(dentry);
53444 }
53445 @@ -3536,9 +3700,17 @@ retry:
53446 if (IS_ERR(dentry))
53447 goto out_putname;
53448
53449 + if (!gr_acl_handle_symlink(dentry, path.dentry, path.mnt, from)) {
53450 + error = -EACCES;
53451 + goto out;
53452 + }
53453 +
53454 error = security_path_symlink(&path, dentry, from->name);
53455 if (!error)
53456 error = vfs_symlink(path.dentry->d_inode, dentry, from->name);
53457 + if (!error)
53458 + gr_handle_create(dentry, path.mnt);
53459 +out:
53460 done_path_create(&path, dentry);
53461 if (retry_estale(error, lookup_flags)) {
53462 lookup_flags |= LOOKUP_REVAL;
53463 @@ -3612,6 +3784,7 @@ SYSCALL_DEFINE5(linkat, int, olddfd, const char __user *, oldname,
53464 {
53465 struct dentry *new_dentry;
53466 struct path old_path, new_path;
53467 + struct filename *to = NULL;
53468 int how = 0;
53469 int error;
53470
53471 @@ -3635,7 +3808,7 @@ retry:
53472 if (error)
53473 return error;
53474
53475 - new_dentry = user_path_create(newdfd, newname, &new_path,
53476 + new_dentry = user_path_create_with_name(newdfd, newname, &new_path, &to,
53477 (how & LOOKUP_REVAL));
53478 error = PTR_ERR(new_dentry);
53479 if (IS_ERR(new_dentry))
53480 @@ -3647,11 +3820,28 @@ retry:
53481 error = may_linkat(&old_path);
53482 if (unlikely(error))
53483 goto out_dput;
53484 +
53485 + if (gr_handle_hardlink(old_path.dentry, old_path.mnt,
53486 + old_path.dentry->d_inode,
53487 + old_path.dentry->d_inode->i_mode, to)) {
53488 + error = -EACCES;
53489 + goto out_dput;
53490 + }
53491 +
53492 + if (!gr_acl_handle_link(new_dentry, new_path.dentry, new_path.mnt,
53493 + old_path.dentry, old_path.mnt, to)) {
53494 + error = -EACCES;
53495 + goto out_dput;
53496 + }
53497 +
53498 error = security_path_link(old_path.dentry, &new_path, new_dentry);
53499 if (error)
53500 goto out_dput;
53501 error = vfs_link(old_path.dentry, new_path.dentry->d_inode, new_dentry);
53502 + if (!error)
53503 + gr_handle_create(new_dentry, new_path.mnt);
53504 out_dput:
53505 + putname(to);
53506 done_path_create(&new_path, new_dentry);
53507 if (retry_estale(error, how)) {
53508 how |= LOOKUP_REVAL;
53509 @@ -3897,12 +4087,21 @@ retry:
53510 if (new_dentry == trap)
53511 goto exit5;
53512
53513 + error = gr_acl_handle_rename(new_dentry, new_dir, newnd.path.mnt,
53514 + old_dentry, old_dir->d_inode, oldnd.path.mnt,
53515 + to);
53516 + if (error)
53517 + goto exit5;
53518 +
53519 error = security_path_rename(&oldnd.path, old_dentry,
53520 &newnd.path, new_dentry);
53521 if (error)
53522 goto exit5;
53523 error = vfs_rename(old_dir->d_inode, old_dentry,
53524 new_dir->d_inode, new_dentry);
53525 + if (!error)
53526 + gr_handle_rename(old_dir->d_inode, new_dir->d_inode, old_dentry,
53527 + new_dentry, oldnd.path.mnt, new_dentry->d_inode ? 1 : 0);
53528 exit5:
53529 dput(new_dentry);
53530 exit4:
53531 @@ -3934,6 +4133,8 @@ SYSCALL_DEFINE2(rename, const char __user *, oldname, const char __user *, newna
53532
53533 int vfs_readlink(struct dentry *dentry, char __user *buffer, int buflen, const char *link)
53534 {
53535 + char tmpbuf[64];
53536 + const char *newlink;
53537 int len;
53538
53539 len = PTR_ERR(link);
53540 @@ -3943,7 +4144,14 @@ int vfs_readlink(struct dentry *dentry, char __user *buffer, int buflen, const c
53541 len = strlen(link);
53542 if (len > (unsigned) buflen)
53543 len = buflen;
53544 - if (copy_to_user(buffer, link, len))
53545 +
53546 + if (len < sizeof(tmpbuf)) {
53547 + memcpy(tmpbuf, link, len);
53548 + newlink = tmpbuf;
53549 + } else
53550 + newlink = link;
53551 +
53552 + if (copy_to_user(buffer, newlink, len))
53553 len = -EFAULT;
53554 out:
53555 return len;
53556 diff --git a/fs/namespace.c b/fs/namespace.c
53557 index e945b81..fc018e2 100644
53558 --- a/fs/namespace.c
53559 +++ b/fs/namespace.c
53560 @@ -1219,6 +1219,9 @@ static int do_umount(struct mount *mnt, int flags)
53561 if (!(sb->s_flags & MS_RDONLY))
53562 retval = do_remount_sb(sb, MS_RDONLY, NULL, 0);
53563 up_write(&sb->s_umount);
53564 +
53565 + gr_log_remount(mnt->mnt_devname, retval);
53566 +
53567 return retval;
53568 }
53569
53570 @@ -1238,6 +1241,9 @@ static int do_umount(struct mount *mnt, int flags)
53571 br_write_unlock(&vfsmount_lock);
53572 up_write(&namespace_sem);
53573 release_mounts(&umount_list);
53574 +
53575 + gr_log_unmount(mnt->mnt_devname, retval);
53576 +
53577 return retval;
53578 }
53579
53580 @@ -1257,7 +1263,7 @@ static inline bool may_mount(void)
53581 * unixes. Our API is identical to OSF/1 to avoid making a mess of AMD
53582 */
53583
53584 -SYSCALL_DEFINE2(umount, char __user *, name, int, flags)
53585 +SYSCALL_DEFINE2(umount, const char __user *, name, int, flags)
53586 {
53587 struct path path;
53588 struct mount *mnt;
53589 @@ -1297,7 +1303,7 @@ out:
53590 /*
53591 * The 2.0 compatible umount. No flags.
53592 */
53593 -SYSCALL_DEFINE1(oldumount, char __user *, name)
53594 +SYSCALL_DEFINE1(oldumount, const char __user *, name)
53595 {
53596 return sys_umount(name, 0);
53597 }
53598 @@ -2267,6 +2273,16 @@ long do_mount(const char *dev_name, const char *dir_name,
53599 MS_NOATIME | MS_NODIRATIME | MS_RELATIME| MS_KERNMOUNT |
53600 MS_STRICTATIME);
53601
53602 + if (gr_handle_rofs_mount(path.dentry, path.mnt, mnt_flags)) {
53603 + retval = -EPERM;
53604 + goto dput_out;
53605 + }
53606 +
53607 + if (gr_handle_chroot_mount(path.dentry, path.mnt, dev_name)) {
53608 + retval = -EPERM;
53609 + goto dput_out;
53610 + }
53611 +
53612 if (flags & MS_REMOUNT)
53613 retval = do_remount(&path, flags & ~MS_REMOUNT, mnt_flags,
53614 data_page);
53615 @@ -2281,6 +2297,9 @@ long do_mount(const char *dev_name, const char *dir_name,
53616 dev_name, data_page);
53617 dput_out:
53618 path_put(&path);
53619 +
53620 + gr_log_mount(dev_name, dir_name, retval);
53621 +
53622 return retval;
53623 }
53624
53625 @@ -2454,8 +2473,8 @@ struct dentry *mount_subtree(struct vfsmount *mnt, const char *name)
53626 }
53627 EXPORT_SYMBOL(mount_subtree);
53628
53629 -SYSCALL_DEFINE5(mount, char __user *, dev_name, char __user *, dir_name,
53630 - char __user *, type, unsigned long, flags, void __user *, data)
53631 +SYSCALL_DEFINE5(mount, const char __user *, dev_name, const char __user *, dir_name,
53632 + const char __user *, type, unsigned long, flags, void __user *, data)
53633 {
53634 int ret;
53635 char *kernel_type;
53636 @@ -2567,6 +2586,11 @@ SYSCALL_DEFINE2(pivot_root, const char __user *, new_root,
53637 if (error)
53638 goto out2;
53639
53640 + if (gr_handle_chroot_pivot()) {
53641 + error = -EPERM;
53642 + goto out2;
53643 + }
53644 +
53645 get_fs_root(current->fs, &root);
53646 error = lock_mount(&old);
53647 if (error)
53648 @@ -2815,7 +2839,7 @@ static int mntns_install(struct nsproxy *nsproxy, void *ns)
53649 !nsown_capable(CAP_SYS_ADMIN))
53650 return -EPERM;
53651
53652 - if (fs->users != 1)
53653 + if (atomic_read(&fs->users) != 1)
53654 return -EINVAL;
53655
53656 get_mnt_ns(mnt_ns);
53657 diff --git a/fs/nfs/callback_xdr.c b/fs/nfs/callback_xdr.c
53658 index 59461c9..b17c57e 100644
53659 --- a/fs/nfs/callback_xdr.c
53660 +++ b/fs/nfs/callback_xdr.c
53661 @@ -51,7 +51,7 @@ struct callback_op {
53662 callback_decode_arg_t decode_args;
53663 callback_encode_res_t encode_res;
53664 long res_maxsize;
53665 -};
53666 +} __do_const;
53667
53668 static struct callback_op callback_ops[];
53669
53670 diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
53671 index 1f94167..79c4ce4 100644
53672 --- a/fs/nfs/inode.c
53673 +++ b/fs/nfs/inode.c
53674 @@ -1041,16 +1041,16 @@ static int nfs_size_need_update(const struct inode *inode, const struct nfs_fatt
53675 return nfs_size_to_loff_t(fattr->size) > i_size_read(inode);
53676 }
53677
53678 -static atomic_long_t nfs_attr_generation_counter;
53679 +static atomic_long_unchecked_t nfs_attr_generation_counter;
53680
53681 static unsigned long nfs_read_attr_generation_counter(void)
53682 {
53683 - return atomic_long_read(&nfs_attr_generation_counter);
53684 + return atomic_long_read_unchecked(&nfs_attr_generation_counter);
53685 }
53686
53687 unsigned long nfs_inc_attr_generation_counter(void)
53688 {
53689 - return atomic_long_inc_return(&nfs_attr_generation_counter);
53690 + return atomic_long_inc_return_unchecked(&nfs_attr_generation_counter);
53691 }
53692
53693 void nfs_fattr_init(struct nfs_fattr *fattr)
53694 diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
53695 index d401d01..10b3e62 100644
53696 --- a/fs/nfsd/nfs4proc.c
53697 +++ b/fs/nfsd/nfs4proc.c
53698 @@ -1109,7 +1109,7 @@ struct nfsd4_operation {
53699 nfsd4op_rsize op_rsize_bop;
53700 stateid_getter op_get_currentstateid;
53701 stateid_setter op_set_currentstateid;
53702 -};
53703 +} __do_const;
53704
53705 static struct nfsd4_operation nfsd4_ops[];
53706
53707 diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
53708 index 6eb0dc5..29067a9 100644
53709 --- a/fs/nfsd/nfs4xdr.c
53710 +++ b/fs/nfsd/nfs4xdr.c
53711 @@ -1457,7 +1457,7 @@ nfsd4_decode_notsupp(struct nfsd4_compoundargs *argp, void *p)
53712
53713 typedef __be32(*nfsd4_dec)(struct nfsd4_compoundargs *argp, void *);
53714
53715 -static nfsd4_dec nfsd4_dec_ops[] = {
53716 +static const nfsd4_dec nfsd4_dec_ops[] = {
53717 [OP_ACCESS] = (nfsd4_dec)nfsd4_decode_access,
53718 [OP_CLOSE] = (nfsd4_dec)nfsd4_decode_close,
53719 [OP_COMMIT] = (nfsd4_dec)nfsd4_decode_commit,
53720 @@ -1497,7 +1497,7 @@ static nfsd4_dec nfsd4_dec_ops[] = {
53721 [OP_RELEASE_LOCKOWNER] = (nfsd4_dec)nfsd4_decode_release_lockowner,
53722 };
53723
53724 -static nfsd4_dec nfsd41_dec_ops[] = {
53725 +static const nfsd4_dec nfsd41_dec_ops[] = {
53726 [OP_ACCESS] = (nfsd4_dec)nfsd4_decode_access,
53727 [OP_CLOSE] = (nfsd4_dec)nfsd4_decode_close,
53728 [OP_COMMIT] = (nfsd4_dec)nfsd4_decode_commit,
53729 @@ -1559,7 +1559,7 @@ static nfsd4_dec nfsd41_dec_ops[] = {
53730 };
53731
53732 struct nfsd4_minorversion_ops {
53733 - nfsd4_dec *decoders;
53734 + const nfsd4_dec *decoders;
53735 int nops;
53736 };
53737
53738 diff --git a/fs/nfsd/nfscache.c b/fs/nfsd/nfscache.c
53739 index ca05f6d..411a576 100644
53740 --- a/fs/nfsd/nfscache.c
53741 +++ b/fs/nfsd/nfscache.c
53742 @@ -461,13 +461,15 @@ nfsd_cache_update(struct svc_rqst *rqstp, int cachetype, __be32 *statp)
53743 {
53744 struct svc_cacherep *rp = rqstp->rq_cacherep;
53745 struct kvec *resv = &rqstp->rq_res.head[0], *cachv;
53746 - int len;
53747 + long len;
53748
53749 if (!rp)
53750 return;
53751
53752 - len = resv->iov_len - ((char*)statp - (char*)resv->iov_base);
53753 - len >>= 2;
53754 + if (statp) {
53755 + len = resv->iov_len - ((char*)statp - (char*)resv->iov_base);
53756 + len >>= 2;
53757 + }
53758
53759 /* Don't cache excessive amounts of data and XDR failures */
53760 if (!statp || len > (256 >> 2)) {
53761 diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
53762 index 2b2e239..c915b48 100644
53763 --- a/fs/nfsd/vfs.c
53764 +++ b/fs/nfsd/vfs.c
53765 @@ -939,7 +939,7 @@ nfsd_vfs_read(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
53766 } else {
53767 oldfs = get_fs();
53768 set_fs(KERNEL_DS);
53769 - host_err = vfs_readv(file, (struct iovec __user *)vec, vlen, &offset);
53770 + host_err = vfs_readv(file, (struct iovec __force_user *)vec, vlen, &offset);
53771 set_fs(oldfs);
53772 }
53773
53774 @@ -1026,7 +1026,7 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
53775
53776 /* Write the data. */
53777 oldfs = get_fs(); set_fs(KERNEL_DS);
53778 - host_err = vfs_writev(file, (struct iovec __user *)vec, vlen, &pos);
53779 + host_err = vfs_writev(file, (struct iovec __force_user *)vec, vlen, &pos);
53780 set_fs(oldfs);
53781 if (host_err < 0)
53782 goto out_nfserr;
53783 @@ -1572,7 +1572,7 @@ nfsd_readlink(struct svc_rqst *rqstp, struct svc_fh *fhp, char *buf, int *lenp)
53784 */
53785
53786 oldfs = get_fs(); set_fs(KERNEL_DS);
53787 - host_err = inode->i_op->readlink(path.dentry, (char __user *)buf, *lenp);
53788 + host_err = inode->i_op->readlink(path.dentry, (char __force_user *)buf, *lenp);
53789 set_fs(oldfs);
53790
53791 if (host_err < 0)
53792 diff --git a/fs/nls/nls_base.c b/fs/nls/nls_base.c
53793 index fea6bd5..8ee9d81 100644
53794 --- a/fs/nls/nls_base.c
53795 +++ b/fs/nls/nls_base.c
53796 @@ -234,20 +234,22 @@ EXPORT_SYMBOL(utf16s_to_utf8s);
53797
53798 int register_nls(struct nls_table * nls)
53799 {
53800 - struct nls_table ** tmp = &tables;
53801 + struct nls_table *tmp = tables;
53802
53803 if (nls->next)
53804 return -EBUSY;
53805
53806 spin_lock(&nls_lock);
53807 - while (*tmp) {
53808 - if (nls == *tmp) {
53809 + while (tmp) {
53810 + if (nls == tmp) {
53811 spin_unlock(&nls_lock);
53812 return -EBUSY;
53813 }
53814 - tmp = &(*tmp)->next;
53815 + tmp = tmp->next;
53816 }
53817 - nls->next = tables;
53818 + pax_open_kernel();
53819 + *(struct nls_table **)&nls->next = tables;
53820 + pax_close_kernel();
53821 tables = nls;
53822 spin_unlock(&nls_lock);
53823 return 0;
53824 @@ -255,12 +257,14 @@ int register_nls(struct nls_table * nls)
53825
53826 int unregister_nls(struct nls_table * nls)
53827 {
53828 - struct nls_table ** tmp = &tables;
53829 + struct nls_table * const * tmp = &tables;
53830
53831 spin_lock(&nls_lock);
53832 while (*tmp) {
53833 if (nls == *tmp) {
53834 - *tmp = nls->next;
53835 + pax_open_kernel();
53836 + *(struct nls_table **)tmp = nls->next;
53837 + pax_close_kernel();
53838 spin_unlock(&nls_lock);
53839 return 0;
53840 }
53841 diff --git a/fs/nls/nls_euc-jp.c b/fs/nls/nls_euc-jp.c
53842 index 7424929..35f6be5 100644
53843 --- a/fs/nls/nls_euc-jp.c
53844 +++ b/fs/nls/nls_euc-jp.c
53845 @@ -561,8 +561,10 @@ static int __init init_nls_euc_jp(void)
53846 p_nls = load_nls("cp932");
53847
53848 if (p_nls) {
53849 - table.charset2upper = p_nls->charset2upper;
53850 - table.charset2lower = p_nls->charset2lower;
53851 + pax_open_kernel();
53852 + *(const unsigned char **)&table.charset2upper = p_nls->charset2upper;
53853 + *(const unsigned char **)&table.charset2lower = p_nls->charset2lower;
53854 + pax_close_kernel();
53855 return register_nls(&table);
53856 }
53857
53858 diff --git a/fs/nls/nls_koi8-ru.c b/fs/nls/nls_koi8-ru.c
53859 index e7bc1d7..06bd4bb 100644
53860 --- a/fs/nls/nls_koi8-ru.c
53861 +++ b/fs/nls/nls_koi8-ru.c
53862 @@ -63,8 +63,10 @@ static int __init init_nls_koi8_ru(void)
53863 p_nls = load_nls("koi8-u");
53864
53865 if (p_nls) {
53866 - table.charset2upper = p_nls->charset2upper;
53867 - table.charset2lower = p_nls->charset2lower;
53868 + pax_open_kernel();
53869 + *(const unsigned char **)&table.charset2upper = p_nls->charset2upper;
53870 + *(const unsigned char **)&table.charset2lower = p_nls->charset2lower;
53871 + pax_close_kernel();
53872 return register_nls(&table);
53873 }
53874
53875 diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c
53876 index 5d84442..2c034ba 100644
53877 --- a/fs/notify/fanotify/fanotify_user.c
53878 +++ b/fs/notify/fanotify/fanotify_user.c
53879 @@ -121,6 +121,7 @@ static int fill_event_metadata(struct fsnotify_group *group,
53880 metadata->event_len = FAN_EVENT_METADATA_LEN;
53881 metadata->metadata_len = FAN_EVENT_METADATA_LEN;
53882 metadata->vers = FANOTIFY_METADATA_VERSION;
53883 + metadata->reserved = 0;
53884 metadata->mask = event->mask & FAN_ALL_OUTGOING_EVENTS;
53885 metadata->pid = pid_vnr(event->tgid);
53886 if (unlikely(event->mask & FAN_Q_OVERFLOW))
53887 @@ -251,8 +252,8 @@ static ssize_t copy_event_to_user(struct fsnotify_group *group,
53888
53889 fd = fanotify_event_metadata.fd;
53890 ret = -EFAULT;
53891 - if (copy_to_user(buf, &fanotify_event_metadata,
53892 - fanotify_event_metadata.event_len))
53893 + if (fanotify_event_metadata.event_len > sizeof fanotify_event_metadata ||
53894 + copy_to_user(buf, &fanotify_event_metadata, fanotify_event_metadata.event_len))
53895 goto out_close_fd;
53896
53897 ret = prepare_for_access_response(group, event, fd);
53898 diff --git a/fs/notify/notification.c b/fs/notify/notification.c
53899 index 7b51b05..5ea5ef6 100644
53900 --- a/fs/notify/notification.c
53901 +++ b/fs/notify/notification.c
53902 @@ -57,7 +57,7 @@ static struct kmem_cache *fsnotify_event_holder_cachep;
53903 * get set to 0 so it will never get 'freed'
53904 */
53905 static struct fsnotify_event *q_overflow_event;
53906 -static atomic_t fsnotify_sync_cookie = ATOMIC_INIT(0);
53907 +static atomic_unchecked_t fsnotify_sync_cookie = ATOMIC_INIT(0);
53908
53909 /**
53910 * fsnotify_get_cookie - return a unique cookie for use in synchronizing events.
53911 @@ -65,7 +65,7 @@ static atomic_t fsnotify_sync_cookie = ATOMIC_INIT(0);
53912 */
53913 u32 fsnotify_get_cookie(void)
53914 {
53915 - return atomic_inc_return(&fsnotify_sync_cookie);
53916 + return atomic_inc_return_unchecked(&fsnotify_sync_cookie);
53917 }
53918 EXPORT_SYMBOL_GPL(fsnotify_get_cookie);
53919
53920 diff --git a/fs/ntfs/dir.c b/fs/ntfs/dir.c
53921 index aa411c3..c260a84 100644
53922 --- a/fs/ntfs/dir.c
53923 +++ b/fs/ntfs/dir.c
53924 @@ -1329,7 +1329,7 @@ find_next_index_buffer:
53925 ia = (INDEX_ALLOCATION*)(kaddr + (ia_pos & ~PAGE_CACHE_MASK &
53926 ~(s64)(ndir->itype.index.block_size - 1)));
53927 /* Bounds checks. */
53928 - if (unlikely((u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE)) {
53929 + if (unlikely(!kaddr || (u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE)) {
53930 ntfs_error(sb, "Out of bounds check failed. Corrupt directory "
53931 "inode 0x%lx or driver bug.", vdir->i_ino);
53932 goto err_out;
53933 diff --git a/fs/ntfs/file.c b/fs/ntfs/file.c
53934 index 5b2d4f0..c6de396 100644
53935 --- a/fs/ntfs/file.c
53936 +++ b/fs/ntfs/file.c
53937 @@ -2242,6 +2242,6 @@ const struct inode_operations ntfs_file_inode_ops = {
53938 #endif /* NTFS_RW */
53939 };
53940
53941 -const struct file_operations ntfs_empty_file_ops = {};
53942 +const struct file_operations ntfs_empty_file_ops __read_only;
53943
53944 -const struct inode_operations ntfs_empty_inode_ops = {};
53945 +const struct inode_operations ntfs_empty_inode_ops __read_only;
53946 diff --git a/fs/ocfs2/localalloc.c b/fs/ocfs2/localalloc.c
53947 index aebeacd..0dcdd26 100644
53948 --- a/fs/ocfs2/localalloc.c
53949 +++ b/fs/ocfs2/localalloc.c
53950 @@ -1278,7 +1278,7 @@ static int ocfs2_local_alloc_slide_window(struct ocfs2_super *osb,
53951 goto bail;
53952 }
53953
53954 - atomic_inc(&osb->alloc_stats.moves);
53955 + atomic_inc_unchecked(&osb->alloc_stats.moves);
53956
53957 bail:
53958 if (handle)
53959 diff --git a/fs/ocfs2/ocfs2.h b/fs/ocfs2/ocfs2.h
53960 index d355e6e..578d905 100644
53961 --- a/fs/ocfs2/ocfs2.h
53962 +++ b/fs/ocfs2/ocfs2.h
53963 @@ -235,11 +235,11 @@ enum ocfs2_vol_state
53964
53965 struct ocfs2_alloc_stats
53966 {
53967 - atomic_t moves;
53968 - atomic_t local_data;
53969 - atomic_t bitmap_data;
53970 - atomic_t bg_allocs;
53971 - atomic_t bg_extends;
53972 + atomic_unchecked_t moves;
53973 + atomic_unchecked_t local_data;
53974 + atomic_unchecked_t bitmap_data;
53975 + atomic_unchecked_t bg_allocs;
53976 + atomic_unchecked_t bg_extends;
53977 };
53978
53979 enum ocfs2_local_alloc_state
53980 diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c
53981 index b7e74b5..19c6536 100644
53982 --- a/fs/ocfs2/suballoc.c
53983 +++ b/fs/ocfs2/suballoc.c
53984 @@ -872,7 +872,7 @@ static int ocfs2_reserve_suballoc_bits(struct ocfs2_super *osb,
53985 mlog_errno(status);
53986 goto bail;
53987 }
53988 - atomic_inc(&osb->alloc_stats.bg_extends);
53989 + atomic_inc_unchecked(&osb->alloc_stats.bg_extends);
53990
53991 /* You should never ask for this much metadata */
53992 BUG_ON(bits_wanted >
53993 @@ -2007,7 +2007,7 @@ int ocfs2_claim_metadata(handle_t *handle,
53994 mlog_errno(status);
53995 goto bail;
53996 }
53997 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
53998 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
53999
54000 *suballoc_loc = res.sr_bg_blkno;
54001 *suballoc_bit_start = res.sr_bit_offset;
54002 @@ -2171,7 +2171,7 @@ int ocfs2_claim_new_inode_at_loc(handle_t *handle,
54003 trace_ocfs2_claim_new_inode_at_loc((unsigned long long)di_blkno,
54004 res->sr_bits);
54005
54006 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
54007 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
54008
54009 BUG_ON(res->sr_bits != 1);
54010
54011 @@ -2213,7 +2213,7 @@ int ocfs2_claim_new_inode(handle_t *handle,
54012 mlog_errno(status);
54013 goto bail;
54014 }
54015 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
54016 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
54017
54018 BUG_ON(res.sr_bits != 1);
54019
54020 @@ -2317,7 +2317,7 @@ int __ocfs2_claim_clusters(handle_t *handle,
54021 cluster_start,
54022 num_clusters);
54023 if (!status)
54024 - atomic_inc(&osb->alloc_stats.local_data);
54025 + atomic_inc_unchecked(&osb->alloc_stats.local_data);
54026 } else {
54027 if (min_clusters > (osb->bitmap_cpg - 1)) {
54028 /* The only paths asking for contiguousness
54029 @@ -2343,7 +2343,7 @@ int __ocfs2_claim_clusters(handle_t *handle,
54030 ocfs2_desc_bitmap_to_cluster_off(ac->ac_inode,
54031 res.sr_bg_blkno,
54032 res.sr_bit_offset);
54033 - atomic_inc(&osb->alloc_stats.bitmap_data);
54034 + atomic_inc_unchecked(&osb->alloc_stats.bitmap_data);
54035 *num_clusters = res.sr_bits;
54036 }
54037 }
54038 diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
54039 index 01b8516..579c4df 100644
54040 --- a/fs/ocfs2/super.c
54041 +++ b/fs/ocfs2/super.c
54042 @@ -301,11 +301,11 @@ static int ocfs2_osb_dump(struct ocfs2_super *osb, char *buf, int len)
54043 "%10s => GlobalAllocs: %d LocalAllocs: %d "
54044 "SubAllocs: %d LAWinMoves: %d SAExtends: %d\n",
54045 "Stats",
54046 - atomic_read(&osb->alloc_stats.bitmap_data),
54047 - atomic_read(&osb->alloc_stats.local_data),
54048 - atomic_read(&osb->alloc_stats.bg_allocs),
54049 - atomic_read(&osb->alloc_stats.moves),
54050 - atomic_read(&osb->alloc_stats.bg_extends));
54051 + atomic_read_unchecked(&osb->alloc_stats.bitmap_data),
54052 + atomic_read_unchecked(&osb->alloc_stats.local_data),
54053 + atomic_read_unchecked(&osb->alloc_stats.bg_allocs),
54054 + atomic_read_unchecked(&osb->alloc_stats.moves),
54055 + atomic_read_unchecked(&osb->alloc_stats.bg_extends));
54056
54057 out += snprintf(buf + out, len - out,
54058 "%10s => State: %u Descriptor: %llu Size: %u bits "
54059 @@ -2122,11 +2122,11 @@ static int ocfs2_initialize_super(struct super_block *sb,
54060 spin_lock_init(&osb->osb_xattr_lock);
54061 ocfs2_init_steal_slots(osb);
54062
54063 - atomic_set(&osb->alloc_stats.moves, 0);
54064 - atomic_set(&osb->alloc_stats.local_data, 0);
54065 - atomic_set(&osb->alloc_stats.bitmap_data, 0);
54066 - atomic_set(&osb->alloc_stats.bg_allocs, 0);
54067 - atomic_set(&osb->alloc_stats.bg_extends, 0);
54068 + atomic_set_unchecked(&osb->alloc_stats.moves, 0);
54069 + atomic_set_unchecked(&osb->alloc_stats.local_data, 0);
54070 + atomic_set_unchecked(&osb->alloc_stats.bitmap_data, 0);
54071 + atomic_set_unchecked(&osb->alloc_stats.bg_allocs, 0);
54072 + atomic_set_unchecked(&osb->alloc_stats.bg_extends, 0);
54073
54074 /* Copy the blockcheck stats from the superblock probe */
54075 osb->osb_ecc_stats = *stats;
54076 diff --git a/fs/open.c b/fs/open.c
54077 index 6835446..eadf09f 100644
54078 --- a/fs/open.c
54079 +++ b/fs/open.c
54080 @@ -32,6 +32,8 @@
54081 #include <linux/dnotify.h>
54082 #include <linux/compat.h>
54083
54084 +#define CREATE_TRACE_POINTS
54085 +#include <trace/events/fs.h>
54086 #include "internal.h"
54087
54088 int do_truncate(struct dentry *dentry, loff_t length, unsigned int time_attrs,
54089 @@ -102,6 +104,8 @@ long vfs_truncate(struct path *path, loff_t length)
54090 error = locks_verify_truncate(inode, NULL, length);
54091 if (!error)
54092 error = security_path_truncate(path);
54093 + if (!error && !gr_acl_handle_truncate(path->dentry, path->mnt))
54094 + error = -EACCES;
54095 if (!error)
54096 error = do_truncate(path->dentry, length, 0, NULL);
54097
54098 @@ -186,6 +190,8 @@ static long do_sys_ftruncate(unsigned int fd, loff_t length, int small)
54099 error = locks_verify_truncate(inode, f.file, length);
54100 if (!error)
54101 error = security_path_truncate(&f.file->f_path);
54102 + if (!error && !gr_acl_handle_truncate(f.file->f_path.dentry, f.file->f_path.mnt))
54103 + error = -EACCES;
54104 if (!error)
54105 error = do_truncate(dentry, length, ATTR_MTIME|ATTR_CTIME, f.file);
54106 sb_end_write(inode->i_sb);
54107 @@ -388,6 +394,9 @@ retry:
54108 if (__mnt_is_readonly(path.mnt))
54109 res = -EROFS;
54110
54111 + if (!res && !gr_acl_handle_access(path.dentry, path.mnt, mode))
54112 + res = -EACCES;
54113 +
54114 out_path_release:
54115 path_put(&path);
54116 if (retry_estale(res, lookup_flags)) {
54117 @@ -419,6 +428,8 @@ retry:
54118 if (error)
54119 goto dput_and_out;
54120
54121 + gr_log_chdir(path.dentry, path.mnt);
54122 +
54123 set_fs_pwd(current->fs, &path);
54124
54125 dput_and_out:
54126 @@ -448,6 +459,13 @@ SYSCALL_DEFINE1(fchdir, unsigned int, fd)
54127 goto out_putf;
54128
54129 error = inode_permission(inode, MAY_EXEC | MAY_CHDIR);
54130 +
54131 + if (!error && !gr_chroot_fchdir(f.file->f_path.dentry, f.file->f_path.mnt))
54132 + error = -EPERM;
54133 +
54134 + if (!error)
54135 + gr_log_chdir(f.file->f_path.dentry, f.file->f_path.mnt);
54136 +
54137 if (!error)
54138 set_fs_pwd(current->fs, &f.file->f_path);
54139 out_putf:
54140 @@ -477,7 +495,13 @@ retry:
54141 if (error)
54142 goto dput_and_out;
54143
54144 + if (gr_handle_chroot_chroot(path.dentry, path.mnt))
54145 + goto dput_and_out;
54146 +
54147 set_fs_root(current->fs, &path);
54148 +
54149 + gr_handle_chroot_chdir(&path);
54150 +
54151 error = 0;
54152 dput_and_out:
54153 path_put(&path);
54154 @@ -499,6 +523,16 @@ static int chmod_common(struct path *path, umode_t mode)
54155 if (error)
54156 return error;
54157 mutex_lock(&inode->i_mutex);
54158 +
54159 + if (!gr_acl_handle_chmod(path->dentry, path->mnt, &mode)) {
54160 + error = -EACCES;
54161 + goto out_unlock;
54162 + }
54163 + if (gr_handle_chroot_chmod(path->dentry, path->mnt, mode)) {
54164 + error = -EACCES;
54165 + goto out_unlock;
54166 + }
54167 +
54168 error = security_path_chmod(path, mode);
54169 if (error)
54170 goto out_unlock;
54171 @@ -559,6 +593,9 @@ static int chown_common(struct path *path, uid_t user, gid_t group)
54172 uid = make_kuid(current_user_ns(), user);
54173 gid = make_kgid(current_user_ns(), group);
54174
54175 + if (!gr_acl_handle_chown(path->dentry, path->mnt))
54176 + return -EACCES;
54177 +
54178 newattrs.ia_valid = ATTR_CTIME;
54179 if (user != (uid_t) -1) {
54180 if (!uid_valid(uid))
54181 @@ -974,6 +1011,7 @@ long do_sys_open(int dfd, const char __user *filename, int flags, umode_t mode)
54182 } else {
54183 fsnotify_open(f);
54184 fd_install(fd, f);
54185 + trace_do_sys_open(tmp->name, flags, mode);
54186 }
54187 }
54188 putname(tmp);
54189 diff --git a/fs/pipe.c b/fs/pipe.c
54190 index 2234f3f..f9083a1 100644
54191 --- a/fs/pipe.c
54192 +++ b/fs/pipe.c
54193 @@ -438,9 +438,9 @@ redo:
54194 }
54195 if (bufs) /* More to do? */
54196 continue;
54197 - if (!pipe->writers)
54198 + if (!atomic_read(&pipe->writers))
54199 break;
54200 - if (!pipe->waiting_writers) {
54201 + if (!atomic_read(&pipe->waiting_writers)) {
54202 /* syscall merging: Usually we must not sleep
54203 * if O_NONBLOCK is set, or if we got some data.
54204 * But if a writer sleeps in kernel space, then
54205 @@ -504,7 +504,7 @@ pipe_write(struct kiocb *iocb, const struct iovec *_iov,
54206 mutex_lock(&inode->i_mutex);
54207 pipe = inode->i_pipe;
54208
54209 - if (!pipe->readers) {
54210 + if (!atomic_read(&pipe->readers)) {
54211 send_sig(SIGPIPE, current, 0);
54212 ret = -EPIPE;
54213 goto out;
54214 @@ -553,7 +553,7 @@ redo1:
54215 for (;;) {
54216 int bufs;
54217
54218 - if (!pipe->readers) {
54219 + if (!atomic_read(&pipe->readers)) {
54220 send_sig(SIGPIPE, current, 0);
54221 if (!ret)
54222 ret = -EPIPE;
54223 @@ -644,9 +644,9 @@ redo2:
54224 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
54225 do_wakeup = 0;
54226 }
54227 - pipe->waiting_writers++;
54228 + atomic_inc(&pipe->waiting_writers);
54229 pipe_wait(pipe);
54230 - pipe->waiting_writers--;
54231 + atomic_dec(&pipe->waiting_writers);
54232 }
54233 out:
54234 mutex_unlock(&inode->i_mutex);
54235 @@ -716,7 +716,7 @@ pipe_poll(struct file *filp, poll_table *wait)
54236 mask = 0;
54237 if (filp->f_mode & FMODE_READ) {
54238 mask = (nrbufs > 0) ? POLLIN | POLLRDNORM : 0;
54239 - if (!pipe->writers && filp->f_version != pipe->w_counter)
54240 + if (!atomic_read(&pipe->writers) && filp->f_version != pipe->w_counter)
54241 mask |= POLLHUP;
54242 }
54243
54244 @@ -726,7 +726,7 @@ pipe_poll(struct file *filp, poll_table *wait)
54245 * Most Unices do not set POLLERR for FIFOs but on Linux they
54246 * behave exactly like pipes for poll().
54247 */
54248 - if (!pipe->readers)
54249 + if (!atomic_read(&pipe->readers))
54250 mask |= POLLERR;
54251 }
54252
54253 @@ -740,10 +740,10 @@ pipe_release(struct inode *inode, int decr, int decw)
54254
54255 mutex_lock(&inode->i_mutex);
54256 pipe = inode->i_pipe;
54257 - pipe->readers -= decr;
54258 - pipe->writers -= decw;
54259 + atomic_sub(decr, &pipe->readers);
54260 + atomic_sub(decw, &pipe->writers);
54261
54262 - if (!pipe->readers && !pipe->writers) {
54263 + if (!atomic_read(&pipe->readers) && !atomic_read(&pipe->writers)) {
54264 free_pipe_info(inode);
54265 } else {
54266 wake_up_interruptible_sync_poll(&pipe->wait, POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM | POLLERR | POLLHUP);
54267 @@ -833,7 +833,7 @@ pipe_read_open(struct inode *inode, struct file *filp)
54268
54269 if (inode->i_pipe) {
54270 ret = 0;
54271 - inode->i_pipe->readers++;
54272 + atomic_inc(&inode->i_pipe->readers);
54273 }
54274
54275 mutex_unlock(&inode->i_mutex);
54276 @@ -850,7 +850,7 @@ pipe_write_open(struct inode *inode, struct file *filp)
54277
54278 if (inode->i_pipe) {
54279 ret = 0;
54280 - inode->i_pipe->writers++;
54281 + atomic_inc(&inode->i_pipe->writers);
54282 }
54283
54284 mutex_unlock(&inode->i_mutex);
54285 @@ -871,9 +871,9 @@ pipe_rdwr_open(struct inode *inode, struct file *filp)
54286 if (inode->i_pipe) {
54287 ret = 0;
54288 if (filp->f_mode & FMODE_READ)
54289 - inode->i_pipe->readers++;
54290 + atomic_inc(&inode->i_pipe->readers);
54291 if (filp->f_mode & FMODE_WRITE)
54292 - inode->i_pipe->writers++;
54293 + atomic_inc(&inode->i_pipe->writers);
54294 }
54295
54296 mutex_unlock(&inode->i_mutex);
54297 @@ -965,7 +965,7 @@ void free_pipe_info(struct inode *inode)
54298 inode->i_pipe = NULL;
54299 }
54300
54301 -static struct vfsmount *pipe_mnt __read_mostly;
54302 +struct vfsmount *pipe_mnt __read_mostly;
54303
54304 /*
54305 * pipefs_dname() is called from d_path().
54306 @@ -995,7 +995,8 @@ static struct inode * get_pipe_inode(void)
54307 goto fail_iput;
54308 inode->i_pipe = pipe;
54309
54310 - pipe->readers = pipe->writers = 1;
54311 + atomic_set(&pipe->readers, 1);
54312 + atomic_set(&pipe->writers, 1);
54313 inode->i_fop = &rdwr_pipefifo_fops;
54314
54315 /*
54316 diff --git a/fs/proc/Kconfig b/fs/proc/Kconfig
54317 index 15af622..0e9f4467 100644
54318 --- a/fs/proc/Kconfig
54319 +++ b/fs/proc/Kconfig
54320 @@ -30,12 +30,12 @@ config PROC_FS
54321
54322 config PROC_KCORE
54323 bool "/proc/kcore support" if !ARM
54324 - depends on PROC_FS && MMU
54325 + depends on PROC_FS && MMU && !GRKERNSEC_PROC_ADD
54326
54327 config PROC_VMCORE
54328 bool "/proc/vmcore support"
54329 - depends on PROC_FS && CRASH_DUMP
54330 - default y
54331 + depends on PROC_FS && CRASH_DUMP && !GRKERNSEC
54332 + default n
54333 help
54334 Exports the dump image of crashed kernel in ELF format.
54335
54336 @@ -59,8 +59,8 @@ config PROC_SYSCTL
54337 limited in memory.
54338
54339 config PROC_PAGE_MONITOR
54340 - default y
54341 - depends on PROC_FS && MMU
54342 + default n
54343 + depends on PROC_FS && MMU && !GRKERNSEC
54344 bool "Enable /proc page monitoring" if EXPERT
54345 help
54346 Various /proc files exist to monitor process memory utilization:
54347 diff --git a/fs/proc/array.c b/fs/proc/array.c
54348 index cbd0f1b..adec3f0 100644
54349 --- a/fs/proc/array.c
54350 +++ b/fs/proc/array.c
54351 @@ -60,6 +60,7 @@
54352 #include <linux/tty.h>
54353 #include <linux/string.h>
54354 #include <linux/mman.h>
54355 +#include <linux/grsecurity.h>
54356 #include <linux/proc_fs.h>
54357 #include <linux/ioport.h>
54358 #include <linux/uaccess.h>
54359 @@ -363,6 +364,21 @@ static void task_cpus_allowed(struct seq_file *m, struct task_struct *task)
54360 seq_putc(m, '\n');
54361 }
54362
54363 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
54364 +static inline void task_pax(struct seq_file *m, struct task_struct *p)
54365 +{
54366 + if (p->mm)
54367 + seq_printf(m, "PaX:\t%c%c%c%c%c\n",
54368 + p->mm->pax_flags & MF_PAX_PAGEEXEC ? 'P' : 'p',
54369 + p->mm->pax_flags & MF_PAX_EMUTRAMP ? 'E' : 'e',
54370 + p->mm->pax_flags & MF_PAX_MPROTECT ? 'M' : 'm',
54371 + p->mm->pax_flags & MF_PAX_RANDMMAP ? 'R' : 'r',
54372 + p->mm->pax_flags & MF_PAX_SEGMEXEC ? 'S' : 's');
54373 + else
54374 + seq_printf(m, "PaX:\t-----\n");
54375 +}
54376 +#endif
54377 +
54378 int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
54379 struct pid *pid, struct task_struct *task)
54380 {
54381 @@ -381,9 +397,24 @@ int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
54382 task_cpus_allowed(m, task);
54383 cpuset_task_status_allowed(m, task);
54384 task_context_switch_counts(m, task);
54385 +
54386 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
54387 + task_pax(m, task);
54388 +#endif
54389 +
54390 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
54391 + task_grsec_rbac(m, task);
54392 +#endif
54393 +
54394 return 0;
54395 }
54396
54397 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54398 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
54399 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
54400 + _mm->pax_flags & MF_PAX_SEGMEXEC))
54401 +#endif
54402 +
54403 static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
54404 struct pid *pid, struct task_struct *task, int whole)
54405 {
54406 @@ -405,6 +436,13 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
54407 char tcomm[sizeof(task->comm)];
54408 unsigned long flags;
54409
54410 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54411 + if (current->exec_id != m->exec_id) {
54412 + gr_log_badprocpid("stat");
54413 + return 0;
54414 + }
54415 +#endif
54416 +
54417 state = *get_task_state(task);
54418 vsize = eip = esp = 0;
54419 permitted = ptrace_may_access(task, PTRACE_MODE_READ | PTRACE_MODE_NOAUDIT);
54420 @@ -476,6 +514,19 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
54421 gtime = task_gtime(task);
54422 }
54423
54424 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54425 + if (PAX_RAND_FLAGS(mm)) {
54426 + eip = 0;
54427 + esp = 0;
54428 + wchan = 0;
54429 + }
54430 +#endif
54431 +#ifdef CONFIG_GRKERNSEC_HIDESYM
54432 + wchan = 0;
54433 + eip =0;
54434 + esp =0;
54435 +#endif
54436 +
54437 /* scale priority and nice values from timeslices to -20..20 */
54438 /* to make it look like a "normal" Unix priority/nice value */
54439 priority = task_prio(task);
54440 @@ -512,9 +563,15 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
54441 seq_put_decimal_ull(m, ' ', vsize);
54442 seq_put_decimal_ull(m, ' ', mm ? get_mm_rss(mm) : 0);
54443 seq_put_decimal_ull(m, ' ', rsslim);
54444 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54445 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 1 : (mm ? (permitted ? mm->start_code : 1) : 0));
54446 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 1 : (mm ? (permitted ? mm->end_code : 1) : 0));
54447 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 0 : ((permitted && mm) ? mm->start_stack : 0));
54448 +#else
54449 seq_put_decimal_ull(m, ' ', mm ? (permitted ? mm->start_code : 1) : 0);
54450 seq_put_decimal_ull(m, ' ', mm ? (permitted ? mm->end_code : 1) : 0);
54451 seq_put_decimal_ull(m, ' ', (permitted && mm) ? mm->start_stack : 0);
54452 +#endif
54453 seq_put_decimal_ull(m, ' ', esp);
54454 seq_put_decimal_ull(m, ' ', eip);
54455 /* The signal information here is obsolete.
54456 @@ -536,7 +593,11 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
54457 seq_put_decimal_ull(m, ' ', cputime_to_clock_t(gtime));
54458 seq_put_decimal_ll(m, ' ', cputime_to_clock_t(cgtime));
54459
54460 - if (mm && permitted) {
54461 + if (mm && permitted
54462 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54463 + && !PAX_RAND_FLAGS(mm)
54464 +#endif
54465 + ) {
54466 seq_put_decimal_ull(m, ' ', mm->start_data);
54467 seq_put_decimal_ull(m, ' ', mm->end_data);
54468 seq_put_decimal_ull(m, ' ', mm->start_brk);
54469 @@ -574,8 +635,15 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
54470 struct pid *pid, struct task_struct *task)
54471 {
54472 unsigned long size = 0, resident = 0, shared = 0, text = 0, data = 0;
54473 - struct mm_struct *mm = get_task_mm(task);
54474 + struct mm_struct *mm;
54475
54476 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54477 + if (current->exec_id != m->exec_id) {
54478 + gr_log_badprocpid("statm");
54479 + return 0;
54480 + }
54481 +#endif
54482 + mm = get_task_mm(task);
54483 if (mm) {
54484 size = task_statm(mm, &shared, &text, &data, &resident);
54485 mmput(mm);
54486 @@ -598,6 +666,13 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
54487 return 0;
54488 }
54489
54490 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
54491 +int proc_pid_ipaddr(struct task_struct *task, char *buffer)
54492 +{
54493 + return sprintf(buffer, "%pI4\n", &task->signal->curr_ip);
54494 +}
54495 +#endif
54496 +
54497 #ifdef CONFIG_CHECKPOINT_RESTORE
54498 static struct pid *
54499 get_children_pid(struct inode *inode, struct pid *pid_prev, loff_t pos)
54500 diff --git a/fs/proc/base.c b/fs/proc/base.c
54501 index 69078c7..3e12a75 100644
54502 --- a/fs/proc/base.c
54503 +++ b/fs/proc/base.c
54504 @@ -112,6 +112,14 @@ struct pid_entry {
54505 union proc_op op;
54506 };
54507
54508 +struct getdents_callback {
54509 + struct linux_dirent __user * current_dir;
54510 + struct linux_dirent __user * previous;
54511 + struct file * file;
54512 + int count;
54513 + int error;
54514 +};
54515 +
54516 #define NOD(NAME, MODE, IOP, FOP, OP) { \
54517 .name = (NAME), \
54518 .len = sizeof(NAME) - 1, \
54519 @@ -209,6 +217,9 @@ static int proc_pid_cmdline(struct task_struct *task, char * buffer)
54520 if (!mm->arg_end)
54521 goto out_mm; /* Shh! No looking before we're done */
54522
54523 + if (gr_acl_handle_procpidmem(task))
54524 + goto out_mm;
54525 +
54526 len = mm->arg_end - mm->arg_start;
54527
54528 if (len > PAGE_SIZE)
54529 @@ -236,12 +247,28 @@ out:
54530 return res;
54531 }
54532
54533 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54534 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
54535 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
54536 + _mm->pax_flags & MF_PAX_SEGMEXEC))
54537 +#endif
54538 +
54539 static int proc_pid_auxv(struct task_struct *task, char *buffer)
54540 {
54541 struct mm_struct *mm = mm_access(task, PTRACE_MODE_READ);
54542 int res = PTR_ERR(mm);
54543 if (mm && !IS_ERR(mm)) {
54544 unsigned int nwords = 0;
54545 +
54546 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54547 + /* allow if we're currently ptracing this task */
54548 + if (PAX_RAND_FLAGS(mm) &&
54549 + (!(task->ptrace & PT_PTRACED) || (task->parent != current))) {
54550 + mmput(mm);
54551 + return 0;
54552 + }
54553 +#endif
54554 +
54555 do {
54556 nwords += 2;
54557 } while (mm->saved_auxv[nwords - 2] != 0); /* AT_NULL */
54558 @@ -255,7 +282,7 @@ static int proc_pid_auxv(struct task_struct *task, char *buffer)
54559 }
54560
54561
54562 -#ifdef CONFIG_KALLSYMS
54563 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
54564 /*
54565 * Provides a wchan file via kallsyms in a proper one-value-per-file format.
54566 * Returns the resolved symbol. If that fails, simply return the address.
54567 @@ -294,7 +321,7 @@ static void unlock_trace(struct task_struct *task)
54568 mutex_unlock(&task->signal->cred_guard_mutex);
54569 }
54570
54571 -#ifdef CONFIG_STACKTRACE
54572 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
54573
54574 #define MAX_STACK_TRACE_DEPTH 64
54575
54576 @@ -486,7 +513,7 @@ static int proc_pid_limits(struct task_struct *task, char *buffer)
54577 return count;
54578 }
54579
54580 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
54581 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
54582 static int proc_pid_syscall(struct task_struct *task, char *buffer)
54583 {
54584 long nr;
54585 @@ -515,7 +542,7 @@ static int proc_pid_syscall(struct task_struct *task, char *buffer)
54586 /************************************************************************/
54587
54588 /* permission checks */
54589 -static int proc_fd_access_allowed(struct inode *inode)
54590 +static int proc_fd_access_allowed(struct inode *inode, unsigned int log)
54591 {
54592 struct task_struct *task;
54593 int allowed = 0;
54594 @@ -525,7 +552,10 @@ static int proc_fd_access_allowed(struct inode *inode)
54595 */
54596 task = get_proc_task(inode);
54597 if (task) {
54598 - allowed = ptrace_may_access(task, PTRACE_MODE_READ);
54599 + if (log)
54600 + allowed = ptrace_may_access(task, PTRACE_MODE_READ);
54601 + else
54602 + allowed = ptrace_may_access(task, PTRACE_MODE_READ | PTRACE_MODE_NOAUDIT);
54603 put_task_struct(task);
54604 }
54605 return allowed;
54606 @@ -556,10 +586,35 @@ static bool has_pid_permissions(struct pid_namespace *pid,
54607 struct task_struct *task,
54608 int hide_pid_min)
54609 {
54610 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
54611 + return false;
54612 +
54613 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
54614 + rcu_read_lock();
54615 + {
54616 + const struct cred *tmpcred = current_cred();
54617 + const struct cred *cred = __task_cred(task);
54618 +
54619 + if (uid_eq(tmpcred->uid, GLOBAL_ROOT_UID) || uid_eq(tmpcred->uid, cred->uid)
54620 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
54621 + || in_group_p(grsec_proc_gid)
54622 +#endif
54623 + ) {
54624 + rcu_read_unlock();
54625 + return true;
54626 + }
54627 + }
54628 + rcu_read_unlock();
54629 +
54630 + if (!pid->hide_pid)
54631 + return false;
54632 +#endif
54633 +
54634 if (pid->hide_pid < hide_pid_min)
54635 return true;
54636 if (in_group_p(pid->pid_gid))
54637 return true;
54638 +
54639 return ptrace_may_access(task, PTRACE_MODE_READ);
54640 }
54641
54642 @@ -577,7 +632,11 @@ static int proc_pid_permission(struct inode *inode, int mask)
54643 put_task_struct(task);
54644
54645 if (!has_perms) {
54646 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
54647 + {
54648 +#else
54649 if (pid->hide_pid == 2) {
54650 +#endif
54651 /*
54652 * Let's make getdents(), stat(), and open()
54653 * consistent with each other. If a process
54654 @@ -675,6 +734,11 @@ static int __mem_open(struct inode *inode, struct file *file, unsigned int mode)
54655 if (!task)
54656 return -ESRCH;
54657
54658 + if (gr_acl_handle_procpidmem(task)) {
54659 + put_task_struct(task);
54660 + return -EPERM;
54661 + }
54662 +
54663 mm = mm_access(task, mode);
54664 put_task_struct(task);
54665
54666 @@ -690,6 +754,10 @@ static int __mem_open(struct inode *inode, struct file *file, unsigned int mode)
54667
54668 file->private_data = mm;
54669
54670 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54671 + file->f_version = current->exec_id;
54672 +#endif
54673 +
54674 return 0;
54675 }
54676
54677 @@ -711,6 +779,17 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
54678 ssize_t copied;
54679 char *page;
54680
54681 +#ifdef CONFIG_GRKERNSEC
54682 + if (write)
54683 + return -EPERM;
54684 +#endif
54685 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54686 + if (file->f_version != current->exec_id) {
54687 + gr_log_badprocpid("mem");
54688 + return 0;
54689 + }
54690 +#endif
54691 +
54692 if (!mm)
54693 return 0;
54694
54695 @@ -723,7 +802,7 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
54696 goto free;
54697
54698 while (count > 0) {
54699 - int this_len = min_t(int, count, PAGE_SIZE);
54700 + ssize_t this_len = min_t(ssize_t, count, PAGE_SIZE);
54701
54702 if (write && copy_from_user(page, buf, this_len)) {
54703 copied = -EFAULT;
54704 @@ -815,6 +894,13 @@ static ssize_t environ_read(struct file *file, char __user *buf,
54705 if (!mm)
54706 return 0;
54707
54708 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54709 + if (file->f_version != current->exec_id) {
54710 + gr_log_badprocpid("environ");
54711 + return 0;
54712 + }
54713 +#endif
54714 +
54715 page = (char *)__get_free_page(GFP_TEMPORARY);
54716 if (!page)
54717 return -ENOMEM;
54718 @@ -824,7 +910,7 @@ static ssize_t environ_read(struct file *file, char __user *buf,
54719 goto free;
54720 while (count > 0) {
54721 size_t this_len, max_len;
54722 - int retval;
54723 + ssize_t retval;
54724
54725 if (src >= (mm->env_end - mm->env_start))
54726 break;
54727 @@ -1430,7 +1516,7 @@ static void *proc_pid_follow_link(struct dentry *dentry, struct nameidata *nd)
54728 int error = -EACCES;
54729
54730 /* Are we allowed to snoop on the tasks file descriptors? */
54731 - if (!proc_fd_access_allowed(inode))
54732 + if (!proc_fd_access_allowed(inode, 0))
54733 goto out;
54734
54735 error = PROC_I(inode)->op.proc_get_link(dentry, &path);
54736 @@ -1474,8 +1560,18 @@ static int proc_pid_readlink(struct dentry * dentry, char __user * buffer, int b
54737 struct path path;
54738
54739 /* Are we allowed to snoop on the tasks file descriptors? */
54740 - if (!proc_fd_access_allowed(inode))
54741 - goto out;
54742 + /* logging this is needed for learning on chromium to work properly,
54743 + but we don't want to flood the logs from 'ps' which does a readlink
54744 + on /proc/fd/2 of tasks in the listing, nor do we want 'ps' to learn
54745 + CAP_SYS_PTRACE as it's not necessary for its basic functionality
54746 + */
54747 + if (dentry->d_name.name[0] == '2' && dentry->d_name.name[1] == '\0') {
54748 + if (!proc_fd_access_allowed(inode,0))
54749 + goto out;
54750 + } else {
54751 + if (!proc_fd_access_allowed(inode,1))
54752 + goto out;
54753 + }
54754
54755 error = PROC_I(inode)->op.proc_get_link(dentry, &path);
54756 if (error)
54757 @@ -1525,7 +1621,11 @@ struct inode *proc_pid_make_inode(struct super_block * sb, struct task_struct *t
54758 rcu_read_lock();
54759 cred = __task_cred(task);
54760 inode->i_uid = cred->euid;
54761 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
54762 + inode->i_gid = grsec_proc_gid;
54763 +#else
54764 inode->i_gid = cred->egid;
54765 +#endif
54766 rcu_read_unlock();
54767 }
54768 security_task_to_inode(task, inode);
54769 @@ -1561,10 +1661,19 @@ int pid_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
54770 return -ENOENT;
54771 }
54772 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
54773 +#ifdef CONFIG_GRKERNSEC_PROC_USER
54774 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IXUSR)) ||
54775 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
54776 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP)) ||
54777 +#endif
54778 task_dumpable(task)) {
54779 cred = __task_cred(task);
54780 stat->uid = cred->euid;
54781 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
54782 + stat->gid = grsec_proc_gid;
54783 +#else
54784 stat->gid = cred->egid;
54785 +#endif
54786 }
54787 }
54788 rcu_read_unlock();
54789 @@ -1602,11 +1711,20 @@ int pid_revalidate(struct dentry *dentry, unsigned int flags)
54790
54791 if (task) {
54792 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
54793 +#ifdef CONFIG_GRKERNSEC_PROC_USER
54794 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IXUSR)) ||
54795 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
54796 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP)) ||
54797 +#endif
54798 task_dumpable(task)) {
54799 rcu_read_lock();
54800 cred = __task_cred(task);
54801 inode->i_uid = cred->euid;
54802 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
54803 + inode->i_gid = grsec_proc_gid;
54804 +#else
54805 inode->i_gid = cred->egid;
54806 +#endif
54807 rcu_read_unlock();
54808 } else {
54809 inode->i_uid = GLOBAL_ROOT_UID;
54810 @@ -2059,6 +2177,9 @@ static struct dentry *proc_pident_lookup(struct inode *dir,
54811 if (!task)
54812 goto out_no_task;
54813
54814 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
54815 + goto out;
54816 +
54817 /*
54818 * Yes, it does not scale. And it should not. Don't add
54819 * new entries into /proc/<tgid>/ without very good reasons.
54820 @@ -2103,6 +2224,9 @@ static int proc_pident_readdir(struct file *filp,
54821 if (!task)
54822 goto out_no_task;
54823
54824 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
54825 + goto out;
54826 +
54827 ret = 0;
54828 i = filp->f_pos;
54829 switch (i) {
54830 @@ -2516,7 +2640,7 @@ static const struct pid_entry tgid_base_stuff[] = {
54831 REG("autogroup", S_IRUGO|S_IWUSR, proc_pid_sched_autogroup_operations),
54832 #endif
54833 REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
54834 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
54835 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
54836 INF("syscall", S_IRUGO, proc_pid_syscall),
54837 #endif
54838 INF("cmdline", S_IRUGO, proc_pid_cmdline),
54839 @@ -2541,10 +2665,10 @@ static const struct pid_entry tgid_base_stuff[] = {
54840 #ifdef CONFIG_SECURITY
54841 DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations),
54842 #endif
54843 -#ifdef CONFIG_KALLSYMS
54844 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
54845 INF("wchan", S_IRUGO, proc_pid_wchan),
54846 #endif
54847 -#ifdef CONFIG_STACKTRACE
54848 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
54849 ONE("stack", S_IRUGO, proc_pid_stack),
54850 #endif
54851 #ifdef CONFIG_SCHEDSTATS
54852 @@ -2578,6 +2702,9 @@ static const struct pid_entry tgid_base_stuff[] = {
54853 #ifdef CONFIG_HARDWALL
54854 INF("hardwall", S_IRUGO, proc_pid_hardwall),
54855 #endif
54856 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
54857 + INF("ipaddr", S_IRUSR, proc_pid_ipaddr),
54858 +#endif
54859 #ifdef CONFIG_USER_NS
54860 REG("uid_map", S_IRUGO|S_IWUSR, proc_uid_map_operations),
54861 REG("gid_map", S_IRUGO|S_IWUSR, proc_gid_map_operations),
54862 @@ -2707,7 +2834,14 @@ static struct dentry *proc_pid_instantiate(struct inode *dir,
54863 if (!inode)
54864 goto out;
54865
54866 +#ifdef CONFIG_GRKERNSEC_PROC_USER
54867 + inode->i_mode = S_IFDIR|S_IRUSR|S_IXUSR;
54868 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
54869 + inode->i_gid = grsec_proc_gid;
54870 + inode->i_mode = S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP;
54871 +#else
54872 inode->i_mode = S_IFDIR|S_IRUGO|S_IXUGO;
54873 +#endif
54874 inode->i_op = &proc_tgid_base_inode_operations;
54875 inode->i_fop = &proc_tgid_base_operations;
54876 inode->i_flags|=S_IMMUTABLE;
54877 @@ -2745,7 +2879,11 @@ struct dentry *proc_pid_lookup(struct inode *dir, struct dentry * dentry, unsign
54878 if (!task)
54879 goto out;
54880
54881 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
54882 + goto out_put_task;
54883 +
54884 result = proc_pid_instantiate(dir, dentry, task, NULL);
54885 +out_put_task:
54886 put_task_struct(task);
54887 out:
54888 return result;
54889 @@ -2808,6 +2946,8 @@ static int proc_pid_fill_cache(struct file *filp, void *dirent, filldir_t filldi
54890 static int fake_filldir(void *buf, const char *name, int namelen,
54891 loff_t offset, u64 ino, unsigned d_type)
54892 {
54893 + struct getdents_callback * __buf = (struct getdents_callback *) buf;
54894 + __buf->error = -EINVAL;
54895 return 0;
54896 }
54897
54898 @@ -2859,7 +2999,7 @@ static const struct pid_entry tid_base_stuff[] = {
54899 REG("sched", S_IRUGO|S_IWUSR, proc_pid_sched_operations),
54900 #endif
54901 REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
54902 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
54903 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
54904 INF("syscall", S_IRUGO, proc_pid_syscall),
54905 #endif
54906 INF("cmdline", S_IRUGO, proc_pid_cmdline),
54907 @@ -2886,10 +3026,10 @@ static const struct pid_entry tid_base_stuff[] = {
54908 #ifdef CONFIG_SECURITY
54909 DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations),
54910 #endif
54911 -#ifdef CONFIG_KALLSYMS
54912 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
54913 INF("wchan", S_IRUGO, proc_pid_wchan),
54914 #endif
54915 -#ifdef CONFIG_STACKTRACE
54916 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
54917 ONE("stack", S_IRUGO, proc_pid_stack),
54918 #endif
54919 #ifdef CONFIG_SCHEDSTATS
54920 diff --git a/fs/proc/cmdline.c b/fs/proc/cmdline.c
54921 index 82676e3..5f8518a 100644
54922 --- a/fs/proc/cmdline.c
54923 +++ b/fs/proc/cmdline.c
54924 @@ -23,7 +23,11 @@ static const struct file_operations cmdline_proc_fops = {
54925
54926 static int __init proc_cmdline_init(void)
54927 {
54928 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
54929 + proc_create_grsec("cmdline", 0, NULL, &cmdline_proc_fops);
54930 +#else
54931 proc_create("cmdline", 0, NULL, &cmdline_proc_fops);
54932 +#endif
54933 return 0;
54934 }
54935 module_init(proc_cmdline_init);
54936 diff --git a/fs/proc/devices.c b/fs/proc/devices.c
54937 index b143471..bb105e5 100644
54938 --- a/fs/proc/devices.c
54939 +++ b/fs/proc/devices.c
54940 @@ -64,7 +64,11 @@ static const struct file_operations proc_devinfo_operations = {
54941
54942 static int __init proc_devices_init(void)
54943 {
54944 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
54945 + proc_create_grsec("devices", 0, NULL, &proc_devinfo_operations);
54946 +#else
54947 proc_create("devices", 0, NULL, &proc_devinfo_operations);
54948 +#endif
54949 return 0;
54950 }
54951 module_init(proc_devices_init);
54952 diff --git a/fs/proc/fd.c b/fs/proc/fd.c
54953 index d7a4a28..0201742 100644
54954 --- a/fs/proc/fd.c
54955 +++ b/fs/proc/fd.c
54956 @@ -25,7 +25,8 @@ static int seq_show(struct seq_file *m, void *v)
54957 if (!task)
54958 return -ENOENT;
54959
54960 - files = get_files_struct(task);
54961 + if (!gr_acl_handle_procpidmem(task))
54962 + files = get_files_struct(task);
54963 put_task_struct(task);
54964
54965 if (files) {
54966 @@ -302,11 +303,21 @@ static struct dentry *proc_lookupfd(struct inode *dir, struct dentry *dentry,
54967 */
54968 int proc_fd_permission(struct inode *inode, int mask)
54969 {
54970 + struct task_struct *task;
54971 int rv = generic_permission(inode, mask);
54972 - if (rv == 0)
54973 - return 0;
54974 +
54975 if (task_pid(current) == proc_pid(inode))
54976 rv = 0;
54977 +
54978 + task = get_proc_task(inode);
54979 + if (task == NULL)
54980 + return rv;
54981 +
54982 + if (gr_acl_handle_procpidmem(task))
54983 + rv = -EACCES;
54984 +
54985 + put_task_struct(task);
54986 +
54987 return rv;
54988 }
54989
54990 diff --git a/fs/proc/inode.c b/fs/proc/inode.c
54991 index 869116c..820cb27 100644
54992 --- a/fs/proc/inode.c
54993 +++ b/fs/proc/inode.c
54994 @@ -22,11 +22,17 @@
54995 #include <linux/seq_file.h>
54996 #include <linux/slab.h>
54997 #include <linux/mount.h>
54998 +#include <linux/grsecurity.h>
54999
55000 #include <asm/uaccess.h>
55001
55002 #include "internal.h"
55003
55004 +#ifdef CONFIG_PROC_SYSCTL
55005 +extern const struct inode_operations proc_sys_inode_operations;
55006 +extern const struct inode_operations proc_sys_dir_operations;
55007 +#endif
55008 +
55009 static void proc_evict_inode(struct inode *inode)
55010 {
55011 struct proc_dir_entry *de;
55012 @@ -54,6 +60,13 @@ static void proc_evict_inode(struct inode *inode)
55013 ns = PROC_I(inode)->ns;
55014 if (ns_ops && ns)
55015 ns_ops->put(ns);
55016 +
55017 +#ifdef CONFIG_PROC_SYSCTL
55018 + if (inode->i_op == &proc_sys_inode_operations ||
55019 + inode->i_op == &proc_sys_dir_operations)
55020 + gr_handle_delete(inode->i_ino, inode->i_sb->s_dev);
55021 +#endif
55022 +
55023 }
55024
55025 static struct kmem_cache * proc_inode_cachep;
55026 @@ -456,7 +469,11 @@ struct inode *proc_get_inode(struct super_block *sb, struct proc_dir_entry *de)
55027 if (de->mode) {
55028 inode->i_mode = de->mode;
55029 inode->i_uid = de->uid;
55030 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
55031 + inode->i_gid = grsec_proc_gid;
55032 +#else
55033 inode->i_gid = de->gid;
55034 +#endif
55035 }
55036 if (de->size)
55037 inode->i_size = de->size;
55038 diff --git a/fs/proc/internal.h b/fs/proc/internal.h
55039 index 85ff3a4..a512bd8 100644
55040 --- a/fs/proc/internal.h
55041 +++ b/fs/proc/internal.h
55042 @@ -56,6 +56,9 @@ extern int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
55043 struct pid *pid, struct task_struct *task);
55044 extern int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
55045 struct pid *pid, struct task_struct *task);
55046 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
55047 +extern int proc_pid_ipaddr(struct task_struct *task, char *buffer);
55048 +#endif
55049 extern loff_t mem_lseek(struct file *file, loff_t offset, int orig);
55050
55051 extern const struct file_operations proc_tid_children_operations;
55052 diff --git a/fs/proc/kcore.c b/fs/proc/kcore.c
55053 index eda6f01..006ae24 100644
55054 --- a/fs/proc/kcore.c
55055 +++ b/fs/proc/kcore.c
55056 @@ -481,9 +481,10 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
55057 * the addresses in the elf_phdr on our list.
55058 */
55059 start = kc_offset_to_vaddr(*fpos - elf_buflen);
55060 - if ((tsz = (PAGE_SIZE - (start & ~PAGE_MASK))) > buflen)
55061 + tsz = PAGE_SIZE - (start & ~PAGE_MASK);
55062 + if (tsz > buflen)
55063 tsz = buflen;
55064 -
55065 +
55066 while (buflen) {
55067 struct kcore_list *m;
55068
55069 @@ -512,20 +513,23 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
55070 kfree(elf_buf);
55071 } else {
55072 if (kern_addr_valid(start)) {
55073 - unsigned long n;
55074 + char *elf_buf;
55075 + mm_segment_t oldfs;
55076
55077 - n = copy_to_user(buffer, (char *)start, tsz);
55078 - /*
55079 - * We cannot distinguish between fault on source
55080 - * and fault on destination. When this happens
55081 - * we clear too and hope it will trigger the
55082 - * EFAULT again.
55083 - */
55084 - if (n) {
55085 - if (clear_user(buffer + tsz - n,
55086 - n))
55087 + elf_buf = kmalloc(tsz, GFP_KERNEL);
55088 + if (!elf_buf)
55089 + return -ENOMEM;
55090 + oldfs = get_fs();
55091 + set_fs(KERNEL_DS);
55092 + if (!__copy_from_user(elf_buf, (const void __user *)start, tsz)) {
55093 + set_fs(oldfs);
55094 + if (copy_to_user(buffer, elf_buf, tsz)) {
55095 + kfree(elf_buf);
55096 return -EFAULT;
55097 + }
55098 }
55099 + set_fs(oldfs);
55100 + kfree(elf_buf);
55101 } else {
55102 if (clear_user(buffer, tsz))
55103 return -EFAULT;
55104 @@ -545,6 +549,9 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
55105
55106 static int open_kcore(struct inode *inode, struct file *filp)
55107 {
55108 +#if defined(CONFIG_GRKERNSEC_PROC_ADD) || defined(CONFIG_GRKERNSEC_HIDESYM)
55109 + return -EPERM;
55110 +#endif
55111 if (!capable(CAP_SYS_RAWIO))
55112 return -EPERM;
55113 if (kcore_need_update)
55114 diff --git a/fs/proc/meminfo.c b/fs/proc/meminfo.c
55115 index 1efaaa1..834e49a 100644
55116 --- a/fs/proc/meminfo.c
55117 +++ b/fs/proc/meminfo.c
55118 @@ -158,7 +158,7 @@ static int meminfo_proc_show(struct seq_file *m, void *v)
55119 vmi.used >> 10,
55120 vmi.largest_chunk >> 10
55121 #ifdef CONFIG_MEMORY_FAILURE
55122 - ,atomic_long_read(&num_poisoned_pages) << (PAGE_SHIFT - 10)
55123 + ,atomic_long_read_unchecked(&num_poisoned_pages) << (PAGE_SHIFT - 10)
55124 #endif
55125 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
55126 ,K(global_page_state(NR_ANON_TRANSPARENT_HUGEPAGES) *
55127 diff --git a/fs/proc/nommu.c b/fs/proc/nommu.c
55128 index ccfd99b..1b7e255 100644
55129 --- a/fs/proc/nommu.c
55130 +++ b/fs/proc/nommu.c
55131 @@ -66,7 +66,7 @@ static int nommu_region_show(struct seq_file *m, struct vm_region *region)
55132 if (len < 1)
55133 len = 1;
55134 seq_printf(m, "%*c", len, ' ');
55135 - seq_path(m, &file->f_path, "");
55136 + seq_path(m, &file->f_path, "\n\\");
55137 }
55138
55139 seq_putc(m, '\n');
55140 diff --git a/fs/proc/proc_net.c b/fs/proc/proc_net.c
55141 index b4ac657..0842bd2 100644
55142 --- a/fs/proc/proc_net.c
55143 +++ b/fs/proc/proc_net.c
55144 @@ -23,6 +23,7 @@
55145 #include <linux/nsproxy.h>
55146 #include <net/net_namespace.h>
55147 #include <linux/seq_file.h>
55148 +#include <linux/grsecurity.h>
55149
55150 #include "internal.h"
55151
55152 @@ -105,6 +106,17 @@ static struct net *get_proc_task_net(struct inode *dir)
55153 struct task_struct *task;
55154 struct nsproxy *ns;
55155 struct net *net = NULL;
55156 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55157 + const struct cred *cred = current_cred();
55158 +#endif
55159 +
55160 +#ifdef CONFIG_GRKERNSEC_PROC_USER
55161 + if (!uid_eq(cred->fsuid, GLOBAL_ROOT_UID))
55162 + return net;
55163 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55164 + if (!uid_eq(cred->fsuid, GLOBAL_ROOT_UID) && !in_group_p(grsec_proc_gid))
55165 + return net;
55166 +#endif
55167
55168 rcu_read_lock();
55169 task = pid_task(proc_pid(dir), PIDTYPE_PID);
55170 diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
55171 index ac05f33..1e6dc7e 100644
55172 --- a/fs/proc/proc_sysctl.c
55173 +++ b/fs/proc/proc_sysctl.c
55174 @@ -13,11 +13,15 @@
55175 #include <linux/module.h>
55176 #include "internal.h"
55177
55178 +extern int gr_handle_chroot_sysctl(const int op);
55179 +extern int gr_handle_sysctl_mod(const char *dirname, const char *name,
55180 + const int op);
55181 +
55182 static const struct dentry_operations proc_sys_dentry_operations;
55183 static const struct file_operations proc_sys_file_operations;
55184 -static const struct inode_operations proc_sys_inode_operations;
55185 +const struct inode_operations proc_sys_inode_operations;
55186 static const struct file_operations proc_sys_dir_file_operations;
55187 -static const struct inode_operations proc_sys_dir_operations;
55188 +const struct inode_operations proc_sys_dir_operations;
55189
55190 void proc_sys_poll_notify(struct ctl_table_poll *poll)
55191 {
55192 @@ -467,6 +471,9 @@ static struct dentry *proc_sys_lookup(struct inode *dir, struct dentry *dentry,
55193
55194 err = NULL;
55195 d_set_d_op(dentry, &proc_sys_dentry_operations);
55196 +
55197 + gr_handle_proc_create(dentry, inode);
55198 +
55199 d_add(dentry, inode);
55200
55201 out:
55202 @@ -482,6 +489,7 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
55203 struct inode *inode = file_inode(filp);
55204 struct ctl_table_header *head = grab_header(inode);
55205 struct ctl_table *table = PROC_I(inode)->sysctl_entry;
55206 + int op = write ? MAY_WRITE : MAY_READ;
55207 ssize_t error;
55208 size_t res;
55209
55210 @@ -493,7 +501,7 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
55211 * and won't be until we finish.
55212 */
55213 error = -EPERM;
55214 - if (sysctl_perm(head, table, write ? MAY_WRITE : MAY_READ))
55215 + if (sysctl_perm(head, table, op))
55216 goto out;
55217
55218 /* if that can happen at all, it should be -EINVAL, not -EISDIR */
55219 @@ -501,6 +509,22 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
55220 if (!table->proc_handler)
55221 goto out;
55222
55223 +#ifdef CONFIG_GRKERNSEC
55224 + error = -EPERM;
55225 + if (gr_handle_chroot_sysctl(op))
55226 + goto out;
55227 + dget(filp->f_path.dentry);
55228 + if (gr_handle_sysctl_mod(filp->f_path.dentry->d_parent->d_name.name, table->procname, op)) {
55229 + dput(filp->f_path.dentry);
55230 + goto out;
55231 + }
55232 + dput(filp->f_path.dentry);
55233 + if (!gr_acl_handle_open(filp->f_path.dentry, filp->f_path.mnt, op))
55234 + goto out;
55235 + if (write && !capable(CAP_SYS_ADMIN))
55236 + goto out;
55237 +#endif
55238 +
55239 /* careful: calling conventions are nasty here */
55240 res = count;
55241 error = table->proc_handler(table, write, buf, &res, ppos);
55242 @@ -598,6 +622,9 @@ static int proc_sys_fill_cache(struct file *filp, void *dirent,
55243 return -ENOMEM;
55244 } else {
55245 d_set_d_op(child, &proc_sys_dentry_operations);
55246 +
55247 + gr_handle_proc_create(child, inode);
55248 +
55249 d_add(child, inode);
55250 }
55251 } else {
55252 @@ -641,6 +668,9 @@ static int scan(struct ctl_table_header *head, ctl_table *table,
55253 if ((*pos)++ < file->f_pos)
55254 return 0;
55255
55256 + if (!gr_acl_handle_hidden_file(file->f_path.dentry, file->f_path.mnt))
55257 + return 0;
55258 +
55259 if (unlikely(S_ISLNK(table->mode)))
55260 res = proc_sys_link_fill_cache(file, dirent, filldir, head, table);
55261 else
55262 @@ -751,6 +781,9 @@ static int proc_sys_getattr(struct vfsmount *mnt, struct dentry *dentry, struct
55263 if (IS_ERR(head))
55264 return PTR_ERR(head);
55265
55266 + if (table && !gr_acl_handle_hidden_file(dentry, mnt))
55267 + return -ENOENT;
55268 +
55269 generic_fillattr(inode, stat);
55270 if (table)
55271 stat->mode = (stat->mode & S_IFMT) | table->mode;
55272 @@ -773,13 +806,13 @@ static const struct file_operations proc_sys_dir_file_operations = {
55273 .llseek = generic_file_llseek,
55274 };
55275
55276 -static const struct inode_operations proc_sys_inode_operations = {
55277 +const struct inode_operations proc_sys_inode_operations = {
55278 .permission = proc_sys_permission,
55279 .setattr = proc_sys_setattr,
55280 .getattr = proc_sys_getattr,
55281 };
55282
55283 -static const struct inode_operations proc_sys_dir_operations = {
55284 +const struct inode_operations proc_sys_dir_operations = {
55285 .lookup = proc_sys_lookup,
55286 .permission = proc_sys_permission,
55287 .setattr = proc_sys_setattr,
55288 @@ -855,7 +888,7 @@ static struct ctl_dir *find_subdir(struct ctl_dir *dir,
55289 static struct ctl_dir *new_dir(struct ctl_table_set *set,
55290 const char *name, int namelen)
55291 {
55292 - struct ctl_table *table;
55293 + ctl_table_no_const *table;
55294 struct ctl_dir *new;
55295 struct ctl_node *node;
55296 char *new_name;
55297 @@ -867,7 +900,7 @@ static struct ctl_dir *new_dir(struct ctl_table_set *set,
55298 return NULL;
55299
55300 node = (struct ctl_node *)(new + 1);
55301 - table = (struct ctl_table *)(node + 1);
55302 + table = (ctl_table_no_const *)(node + 1);
55303 new_name = (char *)(table + 2);
55304 memcpy(new_name, name, namelen);
55305 new_name[namelen] = '\0';
55306 @@ -1036,7 +1069,8 @@ static int sysctl_check_table(const char *path, struct ctl_table *table)
55307 static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table *table,
55308 struct ctl_table_root *link_root)
55309 {
55310 - struct ctl_table *link_table, *entry, *link;
55311 + ctl_table_no_const *link_table, *link;
55312 + struct ctl_table *entry;
55313 struct ctl_table_header *links;
55314 struct ctl_node *node;
55315 char *link_name;
55316 @@ -1059,7 +1093,7 @@ static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table
55317 return NULL;
55318
55319 node = (struct ctl_node *)(links + 1);
55320 - link_table = (struct ctl_table *)(node + nr_entries);
55321 + link_table = (ctl_table_no_const *)(node + nr_entries);
55322 link_name = (char *)&link_table[nr_entries + 1];
55323
55324 for (link = link_table, entry = table; entry->procname; link++, entry++) {
55325 @@ -1307,8 +1341,8 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
55326 struct ctl_table_header ***subheader, struct ctl_table_set *set,
55327 struct ctl_table *table)
55328 {
55329 - struct ctl_table *ctl_table_arg = NULL;
55330 - struct ctl_table *entry, *files;
55331 + ctl_table_no_const *ctl_table_arg = NULL, *files = NULL;
55332 + struct ctl_table *entry;
55333 int nr_files = 0;
55334 int nr_dirs = 0;
55335 int err = -ENOMEM;
55336 @@ -1320,10 +1354,9 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
55337 nr_files++;
55338 }
55339
55340 - files = table;
55341 /* If there are mixed files and directories we need a new table */
55342 if (nr_dirs && nr_files) {
55343 - struct ctl_table *new;
55344 + ctl_table_no_const *new;
55345 files = kzalloc(sizeof(struct ctl_table) * (nr_files + 1),
55346 GFP_KERNEL);
55347 if (!files)
55348 @@ -1341,7 +1374,7 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
55349 /* Register everything except a directory full of subdirectories */
55350 if (nr_files || !nr_dirs) {
55351 struct ctl_table_header *header;
55352 - header = __register_sysctl_table(set, path, files);
55353 + header = __register_sysctl_table(set, path, files ? files : table);
55354 if (!header) {
55355 kfree(ctl_table_arg);
55356 goto out;
55357 diff --git a/fs/proc/root.c b/fs/proc/root.c
55358 index 9c7fab1..ed1c8e0 100644
55359 --- a/fs/proc/root.c
55360 +++ b/fs/proc/root.c
55361 @@ -180,7 +180,15 @@ void __init proc_root_init(void)
55362 #ifdef CONFIG_PROC_DEVICETREE
55363 proc_device_tree_init();
55364 #endif
55365 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
55366 +#ifdef CONFIG_GRKERNSEC_PROC_USER
55367 + proc_mkdir_mode("bus", S_IRUSR | S_IXUSR, NULL);
55368 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55369 + proc_mkdir_mode("bus", S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP, NULL);
55370 +#endif
55371 +#else
55372 proc_mkdir("bus", NULL);
55373 +#endif
55374 proc_sys_init();
55375 }
55376
55377 diff --git a/fs/proc/self.c b/fs/proc/self.c
55378 index aa5cc3b..c91a5d0 100644
55379 --- a/fs/proc/self.c
55380 +++ b/fs/proc/self.c
55381 @@ -37,7 +37,7 @@ static void *proc_self_follow_link(struct dentry *dentry, struct nameidata *nd)
55382 static void proc_self_put_link(struct dentry *dentry, struct nameidata *nd,
55383 void *cookie)
55384 {
55385 - char *s = nd_get_link(nd);
55386 + const char *s = nd_get_link(nd);
55387 if (!IS_ERR(s))
55388 kfree(s);
55389 }
55390 diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
55391 index 3e636d8..83e3b71 100644
55392 --- a/fs/proc/task_mmu.c
55393 +++ b/fs/proc/task_mmu.c
55394 @@ -11,12 +11,19 @@
55395 #include <linux/rmap.h>
55396 #include <linux/swap.h>
55397 #include <linux/swapops.h>
55398 +#include <linux/grsecurity.h>
55399
55400 #include <asm/elf.h>
55401 #include <asm/uaccess.h>
55402 #include <asm/tlbflush.h>
55403 #include "internal.h"
55404
55405 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55406 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
55407 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
55408 + _mm->pax_flags & MF_PAX_SEGMEXEC))
55409 +#endif
55410 +
55411 void task_mem(struct seq_file *m, struct mm_struct *mm)
55412 {
55413 unsigned long data, text, lib, swap;
55414 @@ -52,8 +59,13 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
55415 "VmExe:\t%8lu kB\n"
55416 "VmLib:\t%8lu kB\n"
55417 "VmPTE:\t%8lu kB\n"
55418 - "VmSwap:\t%8lu kB\n",
55419 - hiwater_vm << (PAGE_SHIFT-10),
55420 + "VmSwap:\t%8lu kB\n"
55421 +
55422 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
55423 + "CsBase:\t%8lx\nCsLim:\t%8lx\n"
55424 +#endif
55425 +
55426 + ,hiwater_vm << (PAGE_SHIFT-10),
55427 total_vm << (PAGE_SHIFT-10),
55428 mm->locked_vm << (PAGE_SHIFT-10),
55429 mm->pinned_vm << (PAGE_SHIFT-10),
55430 @@ -62,7 +74,19 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
55431 data << (PAGE_SHIFT-10),
55432 mm->stack_vm << (PAGE_SHIFT-10), text, lib,
55433 (PTRS_PER_PTE*sizeof(pte_t)*mm->nr_ptes) >> 10,
55434 - swap << (PAGE_SHIFT-10));
55435 + swap << (PAGE_SHIFT-10)
55436 +
55437 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
55438 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55439 + , PAX_RAND_FLAGS(mm) ? 0 : mm->context.user_cs_base
55440 + , PAX_RAND_FLAGS(mm) ? 0 : mm->context.user_cs_limit
55441 +#else
55442 + , mm->context.user_cs_base
55443 + , mm->context.user_cs_limit
55444 +#endif
55445 +#endif
55446 +
55447 + );
55448 }
55449
55450 unsigned long task_vsize(struct mm_struct *mm)
55451 @@ -277,13 +301,13 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
55452 pgoff = ((loff_t)vma->vm_pgoff) << PAGE_SHIFT;
55453 }
55454
55455 - /* We don't show the stack guard page in /proc/maps */
55456 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55457 + start = PAX_RAND_FLAGS(mm) ? 0UL : vma->vm_start;
55458 + end = PAX_RAND_FLAGS(mm) ? 0UL : vma->vm_end;
55459 +#else
55460 start = vma->vm_start;
55461 - if (stack_guard_page_start(vma, start))
55462 - start += PAGE_SIZE;
55463 end = vma->vm_end;
55464 - if (stack_guard_page_end(vma, end))
55465 - end -= PAGE_SIZE;
55466 +#endif
55467
55468 seq_printf(m, "%08lx-%08lx %c%c%c%c %08llx %02x:%02x %lu %n",
55469 start,
55470 @@ -292,7 +316,11 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
55471 flags & VM_WRITE ? 'w' : '-',
55472 flags & VM_EXEC ? 'x' : '-',
55473 flags & VM_MAYSHARE ? 's' : 'p',
55474 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55475 + PAX_RAND_FLAGS(mm) ? 0UL : pgoff,
55476 +#else
55477 pgoff,
55478 +#endif
55479 MAJOR(dev), MINOR(dev), ino, &len);
55480
55481 /*
55482 @@ -301,7 +329,7 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
55483 */
55484 if (file) {
55485 pad_len_spaces(m, len);
55486 - seq_path(m, &file->f_path, "\n");
55487 + seq_path(m, &file->f_path, "\n\\");
55488 goto done;
55489 }
55490
55491 @@ -327,8 +355,9 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
55492 * Thread stack in /proc/PID/task/TID/maps or
55493 * the main process stack.
55494 */
55495 - if (!is_pid || (vma->vm_start <= mm->start_stack &&
55496 - vma->vm_end >= mm->start_stack)) {
55497 + if (!is_pid || (vma->vm_flags & (VM_GROWSDOWN | VM_GROWSUP)) ||
55498 + (vma->vm_start <= mm->start_stack &&
55499 + vma->vm_end >= mm->start_stack)) {
55500 name = "[stack]";
55501 } else {
55502 /* Thread stack in /proc/PID/maps */
55503 @@ -352,6 +381,13 @@ static int show_map(struct seq_file *m, void *v, int is_pid)
55504 struct proc_maps_private *priv = m->private;
55505 struct task_struct *task = priv->task;
55506
55507 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55508 + if (current->exec_id != m->exec_id) {
55509 + gr_log_badprocpid("maps");
55510 + return 0;
55511 + }
55512 +#endif
55513 +
55514 show_map_vma(m, vma, is_pid);
55515
55516 if (m->count < m->size) /* vma is copied successfully */
55517 @@ -589,12 +625,23 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
55518 .private = &mss,
55519 };
55520
55521 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55522 + if (current->exec_id != m->exec_id) {
55523 + gr_log_badprocpid("smaps");
55524 + return 0;
55525 + }
55526 +#endif
55527 memset(&mss, 0, sizeof mss);
55528 - mss.vma = vma;
55529 - /* mmap_sem is held in m_start */
55530 - if (vma->vm_mm && !is_vm_hugetlb_page(vma))
55531 - walk_page_range(vma->vm_start, vma->vm_end, &smaps_walk);
55532 -
55533 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55534 + if (!PAX_RAND_FLAGS(vma->vm_mm)) {
55535 +#endif
55536 + mss.vma = vma;
55537 + /* mmap_sem is held in m_start */
55538 + if (vma->vm_mm && !is_vm_hugetlb_page(vma))
55539 + walk_page_range(vma->vm_start, vma->vm_end, &smaps_walk);
55540 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55541 + }
55542 +#endif
55543 show_map_vma(m, vma, is_pid);
55544
55545 seq_printf(m,
55546 @@ -612,7 +659,11 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
55547 "KernelPageSize: %8lu kB\n"
55548 "MMUPageSize: %8lu kB\n"
55549 "Locked: %8lu kB\n",
55550 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55551 + PAX_RAND_FLAGS(vma->vm_mm) ? 0UL : (vma->vm_end - vma->vm_start) >> 10,
55552 +#else
55553 (vma->vm_end - vma->vm_start) >> 10,
55554 +#endif
55555 mss.resident >> 10,
55556 (unsigned long)(mss.pss >> (10 + PSS_SHIFT)),
55557 mss.shared_clean >> 10,
55558 @@ -1264,6 +1315,13 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
55559 int n;
55560 char buffer[50];
55561
55562 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55563 + if (current->exec_id != m->exec_id) {
55564 + gr_log_badprocpid("numa_maps");
55565 + return 0;
55566 + }
55567 +#endif
55568 +
55569 if (!mm)
55570 return 0;
55571
55572 @@ -1281,11 +1339,15 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
55573 mpol_to_str(buffer, sizeof(buffer), pol);
55574 mpol_cond_put(pol);
55575
55576 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55577 + seq_printf(m, "%08lx %s", PAX_RAND_FLAGS(vma->vm_mm) ? 0UL : vma->vm_start, buffer);
55578 +#else
55579 seq_printf(m, "%08lx %s", vma->vm_start, buffer);
55580 +#endif
55581
55582 if (file) {
55583 seq_printf(m, " file=");
55584 - seq_path(m, &file->f_path, "\n\t= ");
55585 + seq_path(m, &file->f_path, "\n\t\\= ");
55586 } else if (vma->vm_start <= mm->brk && vma->vm_end >= mm->start_brk) {
55587 seq_printf(m, " heap");
55588 } else {
55589 diff --git a/fs/proc/task_nommu.c b/fs/proc/task_nommu.c
55590 index 56123a6..5a2f6ec 100644
55591 --- a/fs/proc/task_nommu.c
55592 +++ b/fs/proc/task_nommu.c
55593 @@ -51,7 +51,7 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
55594 else
55595 bytes += kobjsize(mm);
55596
55597 - if (current->fs && current->fs->users > 1)
55598 + if (current->fs && atomic_read(&current->fs->users) > 1)
55599 sbytes += kobjsize(current->fs);
55600 else
55601 bytes += kobjsize(current->fs);
55602 @@ -168,7 +168,7 @@ static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma,
55603
55604 if (file) {
55605 pad_len_spaces(m, len);
55606 - seq_path(m, &file->f_path, "");
55607 + seq_path(m, &file->f_path, "\n\\");
55608 } else if (mm) {
55609 pid_t tid = vm_is_stack(priv->task, vma, is_pid);
55610
55611 diff --git a/fs/proc/vmcore.c b/fs/proc/vmcore.c
55612 index b870f74..e9048df 100644
55613 --- a/fs/proc/vmcore.c
55614 +++ b/fs/proc/vmcore.c
55615 @@ -98,9 +98,13 @@ static ssize_t read_from_oldmem(char *buf, size_t count,
55616 nr_bytes = count;
55617
55618 /* If pfn is not ram, return zeros for sparse dump files */
55619 - if (pfn_is_ram(pfn) == 0)
55620 - memset(buf, 0, nr_bytes);
55621 - else {
55622 + if (pfn_is_ram(pfn) == 0) {
55623 + if (userbuf) {
55624 + if (clear_user((char __force_user *)buf, nr_bytes))
55625 + return -EFAULT;
55626 + } else
55627 + memset(buf, 0, nr_bytes);
55628 + } else {
55629 tmp = copy_oldmem_page(pfn, buf, nr_bytes,
55630 offset, userbuf);
55631 if (tmp < 0)
55632 @@ -185,7 +189,7 @@ static ssize_t read_vmcore(struct file *file, char __user *buffer,
55633 if (tsz > nr_bytes)
55634 tsz = nr_bytes;
55635
55636 - tmp = read_from_oldmem(buffer, tsz, &start, 1);
55637 + tmp = read_from_oldmem((char __force_kernel *)buffer, tsz, &start, 1);
55638 if (tmp < 0)
55639 return tmp;
55640 buflen -= tsz;
55641 diff --git a/fs/qnx6/qnx6.h b/fs/qnx6/qnx6.h
55642 index b00fcc9..e0c6381 100644
55643 --- a/fs/qnx6/qnx6.h
55644 +++ b/fs/qnx6/qnx6.h
55645 @@ -74,7 +74,7 @@ enum {
55646 BYTESEX_BE,
55647 };
55648
55649 -static inline __u64 fs64_to_cpu(struct qnx6_sb_info *sbi, __fs64 n)
55650 +static inline __u64 __intentional_overflow(-1) fs64_to_cpu(struct qnx6_sb_info *sbi, __fs64 n)
55651 {
55652 if (sbi->s_bytesex == BYTESEX_LE)
55653 return le64_to_cpu((__force __le64)n);
55654 @@ -90,7 +90,7 @@ static inline __fs64 cpu_to_fs64(struct qnx6_sb_info *sbi, __u64 n)
55655 return (__force __fs64)cpu_to_be64(n);
55656 }
55657
55658 -static inline __u32 fs32_to_cpu(struct qnx6_sb_info *sbi, __fs32 n)
55659 +static inline __u32 __intentional_overflow(-1) fs32_to_cpu(struct qnx6_sb_info *sbi, __fs32 n)
55660 {
55661 if (sbi->s_bytesex == BYTESEX_LE)
55662 return le32_to_cpu((__force __le32)n);
55663 diff --git a/fs/quota/netlink.c b/fs/quota/netlink.c
55664 index 16e8abb..2dcf914 100644
55665 --- a/fs/quota/netlink.c
55666 +++ b/fs/quota/netlink.c
55667 @@ -33,7 +33,7 @@ static struct genl_family quota_genl_family = {
55668 void quota_send_warning(struct kqid qid, dev_t dev,
55669 const char warntype)
55670 {
55671 - static atomic_t seq;
55672 + static atomic_unchecked_t seq;
55673 struct sk_buff *skb;
55674 void *msg_head;
55675 int ret;
55676 @@ -49,7 +49,7 @@ void quota_send_warning(struct kqid qid, dev_t dev,
55677 "VFS: Not enough memory to send quota warning.\n");
55678 return;
55679 }
55680 - msg_head = genlmsg_put(skb, 0, atomic_add_return(1, &seq),
55681 + msg_head = genlmsg_put(skb, 0, atomic_add_return_unchecked(1, &seq),
55682 &quota_genl_family, 0, QUOTA_NL_C_WARNING);
55683 if (!msg_head) {
55684 printk(KERN_ERR
55685 diff --git a/fs/read_write.c b/fs/read_write.c
55686 index e6ddc8d..9155227 100644
55687 --- a/fs/read_write.c
55688 +++ b/fs/read_write.c
55689 @@ -429,7 +429,7 @@ ssize_t __kernel_write(struct file *file, const char *buf, size_t count, loff_t
55690
55691 old_fs = get_fs();
55692 set_fs(get_ds());
55693 - p = (__force const char __user *)buf;
55694 + p = (const char __force_user *)buf;
55695 if (count > MAX_RW_COUNT)
55696 count = MAX_RW_COUNT;
55697 if (file->f_op->write)
55698 diff --git a/fs/readdir.c b/fs/readdir.c
55699 index fee38e0..12fdf47 100644
55700 --- a/fs/readdir.c
55701 +++ b/fs/readdir.c
55702 @@ -17,6 +17,7 @@
55703 #include <linux/security.h>
55704 #include <linux/syscalls.h>
55705 #include <linux/unistd.h>
55706 +#include <linux/namei.h>
55707
55708 #include <asm/uaccess.h>
55709
55710 @@ -67,6 +68,7 @@ struct old_linux_dirent {
55711
55712 struct readdir_callback {
55713 struct old_linux_dirent __user * dirent;
55714 + struct file * file;
55715 int result;
55716 };
55717
55718 @@ -84,6 +86,10 @@ static int fillonedir(void * __buf, const char * name, int namlen, loff_t offset
55719 buf->result = -EOVERFLOW;
55720 return -EOVERFLOW;
55721 }
55722 +
55723 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
55724 + return 0;
55725 +
55726 buf->result++;
55727 dirent = buf->dirent;
55728 if (!access_ok(VERIFY_WRITE, dirent,
55729 @@ -114,6 +120,7 @@ SYSCALL_DEFINE3(old_readdir, unsigned int, fd,
55730
55731 buf.result = 0;
55732 buf.dirent = dirent;
55733 + buf.file = f.file;
55734
55735 error = vfs_readdir(f.file, fillonedir, &buf);
55736 if (buf.result)
55737 @@ -139,6 +146,7 @@ struct linux_dirent {
55738 struct getdents_callback {
55739 struct linux_dirent __user * current_dir;
55740 struct linux_dirent __user * previous;
55741 + struct file * file;
55742 int count;
55743 int error;
55744 };
55745 @@ -160,6 +168,10 @@ static int filldir(void * __buf, const char * name, int namlen, loff_t offset,
55746 buf->error = -EOVERFLOW;
55747 return -EOVERFLOW;
55748 }
55749 +
55750 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
55751 + return 0;
55752 +
55753 dirent = buf->previous;
55754 if (dirent) {
55755 if (__put_user(offset, &dirent->d_off))
55756 @@ -205,6 +217,7 @@ SYSCALL_DEFINE3(getdents, unsigned int, fd,
55757 buf.previous = NULL;
55758 buf.count = count;
55759 buf.error = 0;
55760 + buf.file = f.file;
55761
55762 error = vfs_readdir(f.file, filldir, &buf);
55763 if (error >= 0)
55764 @@ -223,6 +236,7 @@ SYSCALL_DEFINE3(getdents, unsigned int, fd,
55765 struct getdents_callback64 {
55766 struct linux_dirent64 __user * current_dir;
55767 struct linux_dirent64 __user * previous;
55768 + struct file *file;
55769 int count;
55770 int error;
55771 };
55772 @@ -238,6 +252,10 @@ static int filldir64(void * __buf, const char * name, int namlen, loff_t offset,
55773 buf->error = -EINVAL; /* only used if we fail.. */
55774 if (reclen > buf->count)
55775 return -EINVAL;
55776 +
55777 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
55778 + return 0;
55779 +
55780 dirent = buf->previous;
55781 if (dirent) {
55782 if (__put_user(offset, &dirent->d_off))
55783 @@ -283,6 +301,7 @@ SYSCALL_DEFINE3(getdents64, unsigned int, fd,
55784
55785 buf.current_dir = dirent;
55786 buf.previous = NULL;
55787 + buf.file = f.file;
55788 buf.count = count;
55789 buf.error = 0;
55790
55791 @@ -291,7 +310,7 @@ SYSCALL_DEFINE3(getdents64, unsigned int, fd,
55792 error = buf.error;
55793 lastdirent = buf.previous;
55794 if (lastdirent) {
55795 - typeof(lastdirent->d_off) d_off = f.file->f_pos;
55796 + typeof(((struct linux_dirent64 *)0)->d_off) d_off = f.file->f_pos;
55797 if (__put_user(d_off, &lastdirent->d_off))
55798 error = -EFAULT;
55799 else
55800 diff --git a/fs/reiserfs/do_balan.c b/fs/reiserfs/do_balan.c
55801 index 2b7882b..1c5ef48 100644
55802 --- a/fs/reiserfs/do_balan.c
55803 +++ b/fs/reiserfs/do_balan.c
55804 @@ -2051,7 +2051,7 @@ void do_balance(struct tree_balance *tb, /* tree_balance structure */
55805 return;
55806 }
55807
55808 - atomic_inc(&(fs_generation(tb->tb_sb)));
55809 + atomic_inc_unchecked(&(fs_generation(tb->tb_sb)));
55810 do_balance_starts(tb);
55811
55812 /* balance leaf returns 0 except if combining L R and S into
55813 diff --git a/fs/reiserfs/procfs.c b/fs/reiserfs/procfs.c
55814 index 9cc0740a..46bf953 100644
55815 --- a/fs/reiserfs/procfs.c
55816 +++ b/fs/reiserfs/procfs.c
55817 @@ -112,7 +112,7 @@ static int show_super(struct seq_file *m, struct super_block *sb)
55818 "SMALL_TAILS " : "NO_TAILS ",
55819 replay_only(sb) ? "REPLAY_ONLY " : "",
55820 convert_reiserfs(sb) ? "CONV " : "",
55821 - atomic_read(&r->s_generation_counter),
55822 + atomic_read_unchecked(&r->s_generation_counter),
55823 SF(s_disk_reads), SF(s_disk_writes), SF(s_fix_nodes),
55824 SF(s_do_balance), SF(s_unneeded_left_neighbor),
55825 SF(s_good_search_by_key_reada), SF(s_bmaps),
55826 diff --git a/fs/reiserfs/reiserfs.h b/fs/reiserfs/reiserfs.h
55827 index 157e474..65a6114 100644
55828 --- a/fs/reiserfs/reiserfs.h
55829 +++ b/fs/reiserfs/reiserfs.h
55830 @@ -453,7 +453,7 @@ struct reiserfs_sb_info {
55831 /* Comment? -Hans */
55832 wait_queue_head_t s_wait;
55833 /* To be obsoleted soon by per buffer seals.. -Hans */
55834 - atomic_t s_generation_counter; // increased by one every time the
55835 + atomic_unchecked_t s_generation_counter; // increased by one every time the
55836 // tree gets re-balanced
55837 unsigned long s_properties; /* File system properties. Currently holds
55838 on-disk FS format */
55839 @@ -1978,7 +1978,7 @@ static inline loff_t max_reiserfs_offset(struct inode *inode)
55840 #define REISERFS_USER_MEM 1 /* reiserfs user memory mode */
55841
55842 #define fs_generation(s) (REISERFS_SB(s)->s_generation_counter)
55843 -#define get_generation(s) atomic_read (&fs_generation(s))
55844 +#define get_generation(s) atomic_read_unchecked (&fs_generation(s))
55845 #define FILESYSTEM_CHANGED_TB(tb) (get_generation((tb)->tb_sb) != (tb)->fs_gen)
55846 #define __fs_changed(gen,s) (gen != get_generation (s))
55847 #define fs_changed(gen,s) \
55848 diff --git a/fs/select.c b/fs/select.c
55849 index 8c1c96c..a0f9b6d 100644
55850 --- a/fs/select.c
55851 +++ b/fs/select.c
55852 @@ -20,6 +20,7 @@
55853 #include <linux/export.h>
55854 #include <linux/slab.h>
55855 #include <linux/poll.h>
55856 +#include <linux/security.h>
55857 #include <linux/personality.h> /* for STICKY_TIMEOUTS */
55858 #include <linux/file.h>
55859 #include <linux/fdtable.h>
55860 @@ -827,6 +828,7 @@ int do_sys_poll(struct pollfd __user *ufds, unsigned int nfds,
55861 struct poll_list *walk = head;
55862 unsigned long todo = nfds;
55863
55864 + gr_learn_resource(current, RLIMIT_NOFILE, nfds, 1);
55865 if (nfds > rlimit(RLIMIT_NOFILE))
55866 return -EINVAL;
55867
55868 diff --git a/fs/seq_file.c b/fs/seq_file.c
55869 index 38bb59f..a304f9d 100644
55870 --- a/fs/seq_file.c
55871 +++ b/fs/seq_file.c
55872 @@ -10,6 +10,7 @@
55873 #include <linux/seq_file.h>
55874 #include <linux/slab.h>
55875 #include <linux/cred.h>
55876 +#include <linux/sched.h>
55877
55878 #include <asm/uaccess.h>
55879 #include <asm/page.h>
55880 @@ -60,6 +61,9 @@ int seq_open(struct file *file, const struct seq_operations *op)
55881 #ifdef CONFIG_USER_NS
55882 p->user_ns = file->f_cred->user_ns;
55883 #endif
55884 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55885 + p->exec_id = current->exec_id;
55886 +#endif
55887
55888 /*
55889 * Wrappers around seq_open(e.g. swaps_open) need to be
55890 @@ -96,7 +100,7 @@ static int traverse(struct seq_file *m, loff_t offset)
55891 return 0;
55892 }
55893 if (!m->buf) {
55894 - m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL);
55895 + m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL | GFP_USERCOPY);
55896 if (!m->buf)
55897 return -ENOMEM;
55898 }
55899 @@ -136,7 +140,7 @@ static int traverse(struct seq_file *m, loff_t offset)
55900 Eoverflow:
55901 m->op->stop(m, p);
55902 kfree(m->buf);
55903 - m->buf = kmalloc(m->size <<= 1, GFP_KERNEL);
55904 + m->buf = kmalloc(m->size <<= 1, GFP_KERNEL | GFP_USERCOPY);
55905 return !m->buf ? -ENOMEM : -EAGAIN;
55906 }
55907
55908 @@ -191,7 +195,7 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
55909
55910 /* grab buffer if we didn't have one */
55911 if (!m->buf) {
55912 - m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL);
55913 + m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL | GFP_USERCOPY);
55914 if (!m->buf)
55915 goto Enomem;
55916 }
55917 @@ -232,7 +236,7 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
55918 goto Fill;
55919 m->op->stop(m, p);
55920 kfree(m->buf);
55921 - m->buf = kmalloc(m->size <<= 1, GFP_KERNEL);
55922 + m->buf = kmalloc(m->size <<= 1, GFP_KERNEL | GFP_USERCOPY);
55923 if (!m->buf)
55924 goto Enomem;
55925 m->count = 0;
55926 @@ -581,7 +585,7 @@ static void single_stop(struct seq_file *p, void *v)
55927 int single_open(struct file *file, int (*show)(struct seq_file *, void *),
55928 void *data)
55929 {
55930 - struct seq_operations *op = kmalloc(sizeof(*op), GFP_KERNEL);
55931 + seq_operations_no_const *op = kzalloc(sizeof(*op), GFP_KERNEL);
55932 int res = -ENOMEM;
55933
55934 if (op) {
55935 diff --git a/fs/splice.c b/fs/splice.c
55936 index 29e394e..b13c247 100644
55937 --- a/fs/splice.c
55938 +++ b/fs/splice.c
55939 @@ -195,7 +195,7 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
55940 pipe_lock(pipe);
55941
55942 for (;;) {
55943 - if (!pipe->readers) {
55944 + if (!atomic_read(&pipe->readers)) {
55945 send_sig(SIGPIPE, current, 0);
55946 if (!ret)
55947 ret = -EPIPE;
55948 @@ -249,9 +249,9 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
55949 do_wakeup = 0;
55950 }
55951
55952 - pipe->waiting_writers++;
55953 + atomic_inc(&pipe->waiting_writers);
55954 pipe_wait(pipe);
55955 - pipe->waiting_writers--;
55956 + atomic_dec(&pipe->waiting_writers);
55957 }
55958
55959 pipe_unlock(pipe);
55960 @@ -564,7 +564,7 @@ static ssize_t kernel_readv(struct file *file, const struct iovec *vec,
55961 old_fs = get_fs();
55962 set_fs(get_ds());
55963 /* The cast to a user pointer is valid due to the set_fs() */
55964 - res = vfs_readv(file, (const struct iovec __user *)vec, vlen, &pos);
55965 + res = vfs_readv(file, (const struct iovec __force_user *)vec, vlen, &pos);
55966 set_fs(old_fs);
55967
55968 return res;
55969 @@ -579,7 +579,7 @@ ssize_t kernel_write(struct file *file, const char *buf, size_t count,
55970 old_fs = get_fs();
55971 set_fs(get_ds());
55972 /* The cast to a user pointer is valid due to the set_fs() */
55973 - res = vfs_write(file, (__force const char __user *)buf, count, &pos);
55974 + res = vfs_write(file, (const char __force_user *)buf, count, &pos);
55975 set_fs(old_fs);
55976
55977 return res;
55978 @@ -632,7 +632,7 @@ ssize_t default_file_splice_read(struct file *in, loff_t *ppos,
55979 goto err;
55980
55981 this_len = min_t(size_t, len, PAGE_CACHE_SIZE - offset);
55982 - vec[i].iov_base = (void __user *) page_address(page);
55983 + vec[i].iov_base = (void __force_user *) page_address(page);
55984 vec[i].iov_len = this_len;
55985 spd.pages[i] = page;
55986 spd.nr_pages++;
55987 @@ -853,10 +853,10 @@ EXPORT_SYMBOL(splice_from_pipe_feed);
55988 int splice_from_pipe_next(struct pipe_inode_info *pipe, struct splice_desc *sd)
55989 {
55990 while (!pipe->nrbufs) {
55991 - if (!pipe->writers)
55992 + if (!atomic_read(&pipe->writers))
55993 return 0;
55994
55995 - if (!pipe->waiting_writers && sd->num_spliced)
55996 + if (!atomic_read(&pipe->waiting_writers) && sd->num_spliced)
55997 return 0;
55998
55999 if (sd->flags & SPLICE_F_NONBLOCK)
56000 @@ -1192,7 +1192,7 @@ ssize_t splice_direct_to_actor(struct file *in, struct splice_desc *sd,
56001 * out of the pipe right after the splice_to_pipe(). So set
56002 * PIPE_READERS appropriately.
56003 */
56004 - pipe->readers = 1;
56005 + atomic_set(&pipe->readers, 1);
56006
56007 current->splice_pipe = pipe;
56008 }
56009 @@ -1741,9 +1741,9 @@ static int ipipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
56010 ret = -ERESTARTSYS;
56011 break;
56012 }
56013 - if (!pipe->writers)
56014 + if (!atomic_read(&pipe->writers))
56015 break;
56016 - if (!pipe->waiting_writers) {
56017 + if (!atomic_read(&pipe->waiting_writers)) {
56018 if (flags & SPLICE_F_NONBLOCK) {
56019 ret = -EAGAIN;
56020 break;
56021 @@ -1775,7 +1775,7 @@ static int opipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
56022 pipe_lock(pipe);
56023
56024 while (pipe->nrbufs >= pipe->buffers) {
56025 - if (!pipe->readers) {
56026 + if (!atomic_read(&pipe->readers)) {
56027 send_sig(SIGPIPE, current, 0);
56028 ret = -EPIPE;
56029 break;
56030 @@ -1788,9 +1788,9 @@ static int opipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
56031 ret = -ERESTARTSYS;
56032 break;
56033 }
56034 - pipe->waiting_writers++;
56035 + atomic_inc(&pipe->waiting_writers);
56036 pipe_wait(pipe);
56037 - pipe->waiting_writers--;
56038 + atomic_dec(&pipe->waiting_writers);
56039 }
56040
56041 pipe_unlock(pipe);
56042 @@ -1826,14 +1826,14 @@ retry:
56043 pipe_double_lock(ipipe, opipe);
56044
56045 do {
56046 - if (!opipe->readers) {
56047 + if (!atomic_read(&opipe->readers)) {
56048 send_sig(SIGPIPE, current, 0);
56049 if (!ret)
56050 ret = -EPIPE;
56051 break;
56052 }
56053
56054 - if (!ipipe->nrbufs && !ipipe->writers)
56055 + if (!ipipe->nrbufs && !atomic_read(&ipipe->writers))
56056 break;
56057
56058 /*
56059 @@ -1930,7 +1930,7 @@ static int link_pipe(struct pipe_inode_info *ipipe,
56060 pipe_double_lock(ipipe, opipe);
56061
56062 do {
56063 - if (!opipe->readers) {
56064 + if (!atomic_read(&opipe->readers)) {
56065 send_sig(SIGPIPE, current, 0);
56066 if (!ret)
56067 ret = -EPIPE;
56068 @@ -1975,7 +1975,7 @@ static int link_pipe(struct pipe_inode_info *ipipe,
56069 * return EAGAIN if we have the potential of some data in the
56070 * future, otherwise just return 0
56071 */
56072 - if (!ret && ipipe->waiting_writers && (flags & SPLICE_F_NONBLOCK))
56073 + if (!ret && atomic_read(&ipipe->waiting_writers) && (flags & SPLICE_F_NONBLOCK))
56074 ret = -EAGAIN;
56075
56076 pipe_unlock(ipipe);
56077 diff --git a/fs/stat.c b/fs/stat.c
56078 index 04ce1ac..a13dd1e 100644
56079 --- a/fs/stat.c
56080 +++ b/fs/stat.c
56081 @@ -28,8 +28,13 @@ void generic_fillattr(struct inode *inode, struct kstat *stat)
56082 stat->gid = inode->i_gid;
56083 stat->rdev = inode->i_rdev;
56084 stat->size = i_size_read(inode);
56085 - stat->atime = inode->i_atime;
56086 - stat->mtime = inode->i_mtime;
56087 + if (is_sidechannel_device(inode) && !capable_nolog(CAP_MKNOD)) {
56088 + stat->atime = inode->i_ctime;
56089 + stat->mtime = inode->i_ctime;
56090 + } else {
56091 + stat->atime = inode->i_atime;
56092 + stat->mtime = inode->i_mtime;
56093 + }
56094 stat->ctime = inode->i_ctime;
56095 stat->blksize = (1 << inode->i_blkbits);
56096 stat->blocks = inode->i_blocks;
56097 @@ -46,8 +51,14 @@ int vfs_getattr(struct path *path, struct kstat *stat)
56098 if (retval)
56099 return retval;
56100
56101 - if (inode->i_op->getattr)
56102 - return inode->i_op->getattr(path->mnt, path->dentry, stat);
56103 + if (inode->i_op->getattr) {
56104 + retval = inode->i_op->getattr(path->mnt, path->dentry, stat);
56105 + if (!retval && is_sidechannel_device(inode) && !capable_nolog(CAP_MKNOD)) {
56106 + stat->atime = stat->ctime;
56107 + stat->mtime = stat->ctime;
56108 + }
56109 + return retval;
56110 + }
56111
56112 generic_fillattr(inode, stat);
56113 return 0;
56114 diff --git a/fs/sysfs/bin.c b/fs/sysfs/bin.c
56115 index 15c68f9..36a8b3e 100644
56116 --- a/fs/sysfs/bin.c
56117 +++ b/fs/sysfs/bin.c
56118 @@ -235,13 +235,13 @@ static int bin_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
56119 return ret;
56120 }
56121
56122 -static int bin_access(struct vm_area_struct *vma, unsigned long addr,
56123 - void *buf, int len, int write)
56124 +static ssize_t bin_access(struct vm_area_struct *vma, unsigned long addr,
56125 + void *buf, size_t len, int write)
56126 {
56127 struct file *file = vma->vm_file;
56128 struct bin_buffer *bb = file->private_data;
56129 struct sysfs_dirent *attr_sd = file->f_path.dentry->d_fsdata;
56130 - int ret;
56131 + ssize_t ret;
56132
56133 if (!bb->vm_ops)
56134 return -EINVAL;
56135 diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
56136 index 6f31590..3c87c8a 100644
56137 --- a/fs/sysfs/dir.c
56138 +++ b/fs/sysfs/dir.c
56139 @@ -40,7 +40,7 @@ static DEFINE_IDA(sysfs_ino_ida);
56140 *
56141 * Returns 31 bit hash of ns + name (so it fits in an off_t )
56142 */
56143 -static unsigned int sysfs_name_hash(const void *ns, const char *name)
56144 +static unsigned int sysfs_name_hash(const void *ns, const unsigned char *name)
56145 {
56146 unsigned long hash = init_name_hash();
56147 unsigned int len = strlen(name);
56148 @@ -685,6 +685,18 @@ static int create_dir(struct kobject *kobj, struct sysfs_dirent *parent_sd,
56149 struct sysfs_dirent *sd;
56150 int rc;
56151
56152 +#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
56153 + const char *parent_name = parent_sd->s_name;
56154 +
56155 + mode = S_IFDIR | S_IRWXU;
56156 +
56157 + if ((!strcmp(parent_name, "") && (!strcmp(name, "devices") || !strcmp(name, "fs"))) ||
56158 + (!strcmp(parent_name, "devices") && !strcmp(name, "system")) ||
56159 + (!strcmp(parent_name, "fs") && (!strcmp(name, "selinux") || !strcmp(name, "fuse"))) ||
56160 + (!strcmp(parent_name, "system") && !strcmp(name, "cpu")))
56161 + mode = S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO;
56162 +#endif
56163 +
56164 /* allocate */
56165 sd = sysfs_new_dirent(name, mode, SYSFS_DIR);
56166 if (!sd)
56167 diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
56168 index 602f56d..6853db8 100644
56169 --- a/fs/sysfs/file.c
56170 +++ b/fs/sysfs/file.c
56171 @@ -37,7 +37,7 @@ static DEFINE_SPINLOCK(sysfs_open_dirent_lock);
56172
56173 struct sysfs_open_dirent {
56174 atomic_t refcnt;
56175 - atomic_t event;
56176 + atomic_unchecked_t event;
56177 wait_queue_head_t poll;
56178 struct list_head buffers; /* goes through sysfs_buffer.list */
56179 };
56180 @@ -81,7 +81,7 @@ static int fill_read_buffer(struct dentry * dentry, struct sysfs_buffer * buffer
56181 if (!sysfs_get_active(attr_sd))
56182 return -ENODEV;
56183
56184 - buffer->event = atomic_read(&attr_sd->s_attr.open->event);
56185 + buffer->event = atomic_read_unchecked(&attr_sd->s_attr.open->event);
56186 count = ops->show(kobj, attr_sd->s_attr.attr, buffer->page);
56187
56188 sysfs_put_active(attr_sd);
56189 @@ -287,7 +287,7 @@ static int sysfs_get_open_dirent(struct sysfs_dirent *sd,
56190 return -ENOMEM;
56191
56192 atomic_set(&new_od->refcnt, 0);
56193 - atomic_set(&new_od->event, 1);
56194 + atomic_set_unchecked(&new_od->event, 1);
56195 init_waitqueue_head(&new_od->poll);
56196 INIT_LIST_HEAD(&new_od->buffers);
56197 goto retry;
56198 @@ -432,7 +432,7 @@ static unsigned int sysfs_poll(struct file *filp, poll_table *wait)
56199
56200 sysfs_put_active(attr_sd);
56201
56202 - if (buffer->event != atomic_read(&od->event))
56203 + if (buffer->event != atomic_read_unchecked(&od->event))
56204 goto trigger;
56205
56206 return DEFAULT_POLLMASK;
56207 @@ -451,7 +451,7 @@ void sysfs_notify_dirent(struct sysfs_dirent *sd)
56208
56209 od = sd->s_attr.open;
56210 if (od) {
56211 - atomic_inc(&od->event);
56212 + atomic_inc_unchecked(&od->event);
56213 wake_up_interruptible(&od->poll);
56214 }
56215
56216 diff --git a/fs/sysfs/symlink.c b/fs/sysfs/symlink.c
56217 index 8c940df..25b733e 100644
56218 --- a/fs/sysfs/symlink.c
56219 +++ b/fs/sysfs/symlink.c
56220 @@ -305,7 +305,7 @@ static void *sysfs_follow_link(struct dentry *dentry, struct nameidata *nd)
56221
56222 static void sysfs_put_link(struct dentry *dentry, struct nameidata *nd, void *cookie)
56223 {
56224 - char *page = nd_get_link(nd);
56225 + const char *page = nd_get_link(nd);
56226 if (!IS_ERR(page))
56227 free_page((unsigned long)page);
56228 }
56229 diff --git a/fs/sysv/sysv.h b/fs/sysv/sysv.h
56230 index 69d4889..a810bd4 100644
56231 --- a/fs/sysv/sysv.h
56232 +++ b/fs/sysv/sysv.h
56233 @@ -188,7 +188,7 @@ static inline u32 PDP_swab(u32 x)
56234 #endif
56235 }
56236
56237 -static inline __u32 fs32_to_cpu(struct sysv_sb_info *sbi, __fs32 n)
56238 +static inline __u32 __intentional_overflow(-1) fs32_to_cpu(struct sysv_sb_info *sbi, __fs32 n)
56239 {
56240 if (sbi->s_bytesex == BYTESEX_PDP)
56241 return PDP_swab((__force __u32)n);
56242 diff --git a/fs/ubifs/io.c b/fs/ubifs/io.c
56243 index e18b988..f1d4ad0f 100644
56244 --- a/fs/ubifs/io.c
56245 +++ b/fs/ubifs/io.c
56246 @@ -155,7 +155,7 @@ int ubifs_leb_change(struct ubifs_info *c, int lnum, const void *buf, int len)
56247 return err;
56248 }
56249
56250 -int ubifs_leb_unmap(struct ubifs_info *c, int lnum)
56251 +int __intentional_overflow(-1) ubifs_leb_unmap(struct ubifs_info *c, int lnum)
56252 {
56253 int err;
56254
56255 diff --git a/fs/udf/misc.c b/fs/udf/misc.c
56256 index c175b4d..8f36a16 100644
56257 --- a/fs/udf/misc.c
56258 +++ b/fs/udf/misc.c
56259 @@ -289,7 +289,7 @@ void udf_new_tag(char *data, uint16_t ident, uint16_t version, uint16_t snum,
56260
56261 u8 udf_tag_checksum(const struct tag *t)
56262 {
56263 - u8 *data = (u8 *)t;
56264 + const u8 *data = (const u8 *)t;
56265 u8 checksum = 0;
56266 int i;
56267 for (i = 0; i < sizeof(struct tag); ++i)
56268 diff --git a/fs/ufs/swab.h b/fs/ufs/swab.h
56269 index 8d974c4..b82f6ec 100644
56270 --- a/fs/ufs/swab.h
56271 +++ b/fs/ufs/swab.h
56272 @@ -22,7 +22,7 @@ enum {
56273 BYTESEX_BE
56274 };
56275
56276 -static inline u64
56277 +static inline u64 __intentional_overflow(-1)
56278 fs64_to_cpu(struct super_block *sbp, __fs64 n)
56279 {
56280 if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
56281 @@ -40,7 +40,7 @@ cpu_to_fs64(struct super_block *sbp, u64 n)
56282 return (__force __fs64)cpu_to_be64(n);
56283 }
56284
56285 -static inline u32
56286 +static inline u32 __intentional_overflow(-1)
56287 fs32_to_cpu(struct super_block *sbp, __fs32 n)
56288 {
56289 if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
56290 diff --git a/fs/utimes.c b/fs/utimes.c
56291 index f4fb7ec..3fe03c0 100644
56292 --- a/fs/utimes.c
56293 +++ b/fs/utimes.c
56294 @@ -1,6 +1,7 @@
56295 #include <linux/compiler.h>
56296 #include <linux/file.h>
56297 #include <linux/fs.h>
56298 +#include <linux/security.h>
56299 #include <linux/linkage.h>
56300 #include <linux/mount.h>
56301 #include <linux/namei.h>
56302 @@ -101,6 +102,12 @@ static int utimes_common(struct path *path, struct timespec *times)
56303 goto mnt_drop_write_and_out;
56304 }
56305 }
56306 +
56307 + if (!gr_acl_handle_utime(path->dentry, path->mnt)) {
56308 + error = -EACCES;
56309 + goto mnt_drop_write_and_out;
56310 + }
56311 +
56312 mutex_lock(&inode->i_mutex);
56313 error = notify_change(path->dentry, &newattrs);
56314 mutex_unlock(&inode->i_mutex);
56315 diff --git a/fs/xattr.c b/fs/xattr.c
56316 index 3377dff..4d074d9 100644
56317 --- a/fs/xattr.c
56318 +++ b/fs/xattr.c
56319 @@ -227,6 +227,27 @@ int vfs_xattr_cmp(struct dentry *dentry, const char *xattr_name,
56320 return rc;
56321 }
56322
56323 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
56324 +ssize_t
56325 +pax_getxattr(struct dentry *dentry, void *value, size_t size)
56326 +{
56327 + struct inode *inode = dentry->d_inode;
56328 + ssize_t error;
56329 +
56330 + error = inode_permission(inode, MAY_EXEC);
56331 + if (error)
56332 + return error;
56333 +
56334 + if (inode->i_op->getxattr)
56335 + error = inode->i_op->getxattr(dentry, XATTR_NAME_PAX_FLAGS, value, size);
56336 + else
56337 + error = -EOPNOTSUPP;
56338 +
56339 + return error;
56340 +}
56341 +EXPORT_SYMBOL(pax_getxattr);
56342 +#endif
56343 +
56344 ssize_t
56345 vfs_getxattr(struct dentry *dentry, const char *name, void *value, size_t size)
56346 {
56347 @@ -319,7 +340,7 @@ EXPORT_SYMBOL_GPL(vfs_removexattr);
56348 * Extended attribute SET operations
56349 */
56350 static long
56351 -setxattr(struct dentry *d, const char __user *name, const void __user *value,
56352 +setxattr(struct path *path, const char __user *name, const void __user *value,
56353 size_t size, int flags)
56354 {
56355 int error;
56356 @@ -355,7 +376,12 @@ setxattr(struct dentry *d, const char __user *name, const void __user *value,
56357 posix_acl_fix_xattr_from_user(kvalue, size);
56358 }
56359
56360 - error = vfs_setxattr(d, kname, kvalue, size, flags);
56361 + if (!gr_acl_handle_setxattr(path->dentry, path->mnt)) {
56362 + error = -EACCES;
56363 + goto out;
56364 + }
56365 +
56366 + error = vfs_setxattr(path->dentry, kname, kvalue, size, flags);
56367 out:
56368 if (vvalue)
56369 vfree(vvalue);
56370 @@ -377,7 +403,7 @@ retry:
56371 return error;
56372 error = mnt_want_write(path.mnt);
56373 if (!error) {
56374 - error = setxattr(path.dentry, name, value, size, flags);
56375 + error = setxattr(&path, name, value, size, flags);
56376 mnt_drop_write(path.mnt);
56377 }
56378 path_put(&path);
56379 @@ -401,7 +427,7 @@ retry:
56380 return error;
56381 error = mnt_want_write(path.mnt);
56382 if (!error) {
56383 - error = setxattr(path.dentry, name, value, size, flags);
56384 + error = setxattr(&path, name, value, size, flags);
56385 mnt_drop_write(path.mnt);
56386 }
56387 path_put(&path);
56388 @@ -416,16 +442,14 @@ SYSCALL_DEFINE5(fsetxattr, int, fd, const char __user *, name,
56389 const void __user *,value, size_t, size, int, flags)
56390 {
56391 struct fd f = fdget(fd);
56392 - struct dentry *dentry;
56393 int error = -EBADF;
56394
56395 if (!f.file)
56396 return error;
56397 - dentry = f.file->f_path.dentry;
56398 - audit_inode(NULL, dentry, 0);
56399 + audit_inode(NULL, f.file->f_path.dentry, 0);
56400 error = mnt_want_write_file(f.file);
56401 if (!error) {
56402 - error = setxattr(dentry, name, value, size, flags);
56403 + error = setxattr(&f.file->f_path, name, value, size, flags);
56404 mnt_drop_write_file(f.file);
56405 }
56406 fdput(f);
56407 diff --git a/fs/xattr_acl.c b/fs/xattr_acl.c
56408 index 9fbea87..6b19972 100644
56409 --- a/fs/xattr_acl.c
56410 +++ b/fs/xattr_acl.c
56411 @@ -76,8 +76,8 @@ struct posix_acl *
56412 posix_acl_from_xattr(struct user_namespace *user_ns,
56413 const void *value, size_t size)
56414 {
56415 - posix_acl_xattr_header *header = (posix_acl_xattr_header *)value;
56416 - posix_acl_xattr_entry *entry = (posix_acl_xattr_entry *)(header+1), *end;
56417 + const posix_acl_xattr_header *header = (const posix_acl_xattr_header *)value;
56418 + const posix_acl_xattr_entry *entry = (const posix_acl_xattr_entry *)(header+1), *end;
56419 int count;
56420 struct posix_acl *acl;
56421 struct posix_acl_entry *acl_e;
56422 diff --git a/fs/xfs/xfs_bmap.c b/fs/xfs/xfs_bmap.c
56423 index b44af92..06073da 100644
56424 --- a/fs/xfs/xfs_bmap.c
56425 +++ b/fs/xfs/xfs_bmap.c
56426 @@ -192,7 +192,7 @@ xfs_bmap_validate_ret(
56427 int nmap,
56428 int ret_nmap);
56429 #else
56430 -#define xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap)
56431 +#define xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap) do {} while (0)
56432 #endif /* DEBUG */
56433
56434 STATIC int
56435 diff --git a/fs/xfs/xfs_dir2_sf.c b/fs/xfs/xfs_dir2_sf.c
56436 index 1b9fc3e..e1bdde0 100644
56437 --- a/fs/xfs/xfs_dir2_sf.c
56438 +++ b/fs/xfs/xfs_dir2_sf.c
56439 @@ -851,7 +851,15 @@ xfs_dir2_sf_getdents(
56440 }
56441
56442 ino = xfs_dir2_sfe_get_ino(sfp, sfep);
56443 - if (filldir(dirent, (char *)sfep->name, sfep->namelen,
56444 + if (dp->i_df.if_u1.if_data == dp->i_df.if_u2.if_inline_data) {
56445 + char name[sfep->namelen];
56446 + memcpy(name, sfep->name, sfep->namelen);
56447 + if (filldir(dirent, name, sfep->namelen,
56448 + off & 0x7fffffff, ino, DT_UNKNOWN)) {
56449 + *offset = off & 0x7fffffff;
56450 + return 0;
56451 + }
56452 + } else if (filldir(dirent, (char *)sfep->name, sfep->namelen,
56453 off & 0x7fffffff, ino, DT_UNKNOWN)) {
56454 *offset = off & 0x7fffffff;
56455 return 0;
56456 diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
56457 index d681e34..2a3f5ab 100644
56458 --- a/fs/xfs/xfs_ioctl.c
56459 +++ b/fs/xfs/xfs_ioctl.c
56460 @@ -127,7 +127,7 @@ xfs_find_handle(
56461 }
56462
56463 error = -EFAULT;
56464 - if (copy_to_user(hreq->ohandle, &handle, hsize) ||
56465 + if (hsize > sizeof handle || copy_to_user(hreq->ohandle, &handle, hsize) ||
56466 copy_to_user(hreq->ohandlen, &hsize, sizeof(__s32)))
56467 goto out_put;
56468
56469 diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
56470 index ca9ecaa..60100c7 100644
56471 --- a/fs/xfs/xfs_iops.c
56472 +++ b/fs/xfs/xfs_iops.c
56473 @@ -395,7 +395,7 @@ xfs_vn_put_link(
56474 struct nameidata *nd,
56475 void *p)
56476 {
56477 - char *s = nd_get_link(nd);
56478 + const char *s = nd_get_link(nd);
56479
56480 if (!IS_ERR(s))
56481 kfree(s);
56482 diff --git a/grsecurity/Kconfig b/grsecurity/Kconfig
56483 new file mode 100644
56484 index 0000000..ba9c5e3
56485 --- /dev/null
56486 +++ b/grsecurity/Kconfig
56487 @@ -0,0 +1,1053 @@
56488 +#
56489 +# grecurity configuration
56490 +#
56491 +menu "Memory Protections"
56492 +depends on GRKERNSEC
56493 +
56494 +config GRKERNSEC_KMEM
56495 + bool "Deny reading/writing to /dev/kmem, /dev/mem, and /dev/port"
56496 + default y if GRKERNSEC_CONFIG_AUTO
56497 + select STRICT_DEVMEM if (X86 || ARM || TILE || S390)
56498 + help
56499 + If you say Y here, /dev/kmem and /dev/mem won't be allowed to
56500 + be written to or read from to modify or leak the contents of the running
56501 + kernel. /dev/port will also not be allowed to be opened and support
56502 + for /dev/cpu/*/msr will be removed. If you have module
56503 + support disabled, enabling this will close up five ways that are
56504 + currently used to insert malicious code into the running kernel.
56505 +
56506 + Even with all these features enabled, we still highly recommend that
56507 + you use the RBAC system, as it is still possible for an attacker to
56508 + modify the running kernel through privileged I/O granted by ioperm/iopl.
56509 +
56510 + If you are not using XFree86, you may be able to stop this additional
56511 + case by enabling the 'Disable privileged I/O' option. Though nothing
56512 + legitimately writes to /dev/kmem, XFree86 does need to write to /dev/mem,
56513 + but only to video memory, which is the only writing we allow in this
56514 + case. If /dev/kmem or /dev/mem are mmaped without PROT_WRITE, they will
56515 + not be allowed to mprotect it with PROT_WRITE later.
56516 + Enabling this feature will prevent the "cpupower" and "powertop" tools
56517 + from working.
56518 +
56519 + It is highly recommended that you say Y here if you meet all the
56520 + conditions above.
56521 +
56522 +config GRKERNSEC_VM86
56523 + bool "Restrict VM86 mode"
56524 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
56525 + depends on X86_32
56526 +
56527 + help
56528 + If you say Y here, only processes with CAP_SYS_RAWIO will be able to
56529 + make use of a special execution mode on 32bit x86 processors called
56530 + Virtual 8086 (VM86) mode. XFree86 may need vm86 mode for certain
56531 + video cards and will still work with this option enabled. The purpose
56532 + of the option is to prevent exploitation of emulation errors in
56533 + virtualization of vm86 mode like the one discovered in VMWare in 2009.
56534 + Nearly all users should be able to enable this option.
56535 +
56536 +config GRKERNSEC_IO
56537 + bool "Disable privileged I/O"
56538 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
56539 + depends on X86
56540 + select RTC_CLASS
56541 + select RTC_INTF_DEV
56542 + select RTC_DRV_CMOS
56543 +
56544 + help
56545 + If you say Y here, all ioperm and iopl calls will return an error.
56546 + Ioperm and iopl can be used to modify the running kernel.
56547 + Unfortunately, some programs need this access to operate properly,
56548 + the most notable of which are XFree86 and hwclock. hwclock can be
56549 + remedied by having RTC support in the kernel, so real-time
56550 + clock support is enabled if this option is enabled, to ensure
56551 + that hwclock operates correctly. XFree86 still will not
56552 + operate correctly with this option enabled, so DO NOT CHOOSE Y
56553 + IF YOU USE XFree86. If you use XFree86 and you still want to
56554 + protect your kernel against modification, use the RBAC system.
56555 +
56556 +config GRKERNSEC_JIT_HARDEN
56557 + bool "Harden BPF JIT against spray attacks"
56558 + default y if GRKERNSEC_CONFIG_AUTO
56559 + depends on BPF_JIT
56560 + help
56561 + If you say Y here, the native code generated by the kernel's Berkeley
56562 + Packet Filter (BPF) JIT engine will be hardened against JIT-spraying
56563 + attacks that attempt to fit attacker-beneficial instructions in
56564 + 32bit immediate fields of JIT-generated native instructions. The
56565 + attacker will generally aim to cause an unintended instruction sequence
56566 + of JIT-generated native code to execute by jumping into the middle of
56567 + a generated instruction. This feature effectively randomizes the 32bit
56568 + immediate constants present in the generated code to thwart such attacks.
56569 +
56570 + If you're using KERNEXEC, it's recommended that you enable this option
56571 + to supplement the hardening of the kernel.
56572 +
56573 +config GRKERNSEC_PERF_HARDEN
56574 + bool "Disable unprivileged PERF_EVENTS usage by default"
56575 + default y if GRKERNSEC_CONFIG_AUTO
56576 + depends on PERF_EVENTS
56577 + help
56578 + If you say Y here, the range of acceptable values for the
56579 + /proc/sys/kernel/perf_event_paranoid sysctl will be expanded to allow and
56580 + default to a new value: 3. When the sysctl is set to this value, no
56581 + unprivileged use of the PERF_EVENTS syscall interface will be permitted.
56582 +
56583 + Though PERF_EVENTS can be used legitimately for performance monitoring
56584 + and low-level application profiling, it is forced on regardless of
56585 + configuration, has been at fault for several vulnerabilities, and
56586 + creates new opportunities for side channels and other information leaks.
56587 +
56588 + This feature puts PERF_EVENTS into a secure default state and permits
56589 + the administrator to change out of it temporarily if unprivileged
56590 + application profiling is needed.
56591 +
56592 +config GRKERNSEC_RAND_THREADSTACK
56593 + bool "Insert random gaps between thread stacks"
56594 + default y if GRKERNSEC_CONFIG_AUTO
56595 + depends on PAX_RANDMMAP && !PPC && BROKEN
56596 + help
56597 + If you say Y here, a random-sized gap will be enforced between allocated
56598 + thread stacks. Glibc's NPTL and other threading libraries that
56599 + pass MAP_STACK to the kernel for thread stack allocation are supported.
56600 + The implementation currently provides 8 bits of entropy for the gap.
56601 +
56602 + Many distributions do not compile threaded remote services with the
56603 + -fstack-check argument to GCC, causing the variable-sized stack-based
56604 + allocator, alloca(), to not probe the stack on allocation. This
56605 + permits an unbounded alloca() to skip over any guard page and potentially
56606 + modify another thread's stack reliably. An enforced random gap
56607 + reduces the reliability of such an attack and increases the chance
56608 + that such a read/write to another thread's stack instead lands in
56609 + an unmapped area, causing a crash and triggering grsecurity's
56610 + anti-bruteforcing logic.
56611 +
56612 +config GRKERNSEC_PROC_MEMMAP
56613 + bool "Harden ASLR against information leaks and entropy reduction"
56614 + default y if (GRKERNSEC_CONFIG_AUTO || PAX_NOEXEC || PAX_ASLR)
56615 + depends on PAX_NOEXEC || PAX_ASLR
56616 + help
56617 + If you say Y here, the /proc/<pid>/maps and /proc/<pid>/stat files will
56618 + give no information about the addresses of its mappings if
56619 + PaX features that rely on random addresses are enabled on the task.
56620 + In addition to sanitizing this information and disabling other
56621 + dangerous sources of information, this option causes reads of sensitive
56622 + /proc/<pid> entries where the file descriptor was opened in a different
56623 + task than the one performing the read. Such attempts are logged.
56624 + This option also limits argv/env strings for suid/sgid binaries
56625 + to 512KB to prevent a complete exhaustion of the stack entropy provided
56626 + by ASLR. Finally, it places an 8MB stack resource limit on suid/sgid
56627 + binaries to prevent alternative mmap layouts from being abused.
56628 +
56629 + If you use PaX it is essential that you say Y here as it closes up
56630 + several holes that make full ASLR useless locally.
56631 +
56632 +config GRKERNSEC_BRUTE
56633 + bool "Deter exploit bruteforcing"
56634 + default y if GRKERNSEC_CONFIG_AUTO
56635 + help
56636 + If you say Y here, attempts to bruteforce exploits against forking
56637 + daemons such as apache or sshd, as well as against suid/sgid binaries
56638 + will be deterred. When a child of a forking daemon is killed by PaX
56639 + or crashes due to an illegal instruction or other suspicious signal,
56640 + the parent process will be delayed 30 seconds upon every subsequent
56641 + fork until the administrator is able to assess the situation and
56642 + restart the daemon.
56643 + In the suid/sgid case, the attempt is logged, the user has all their
56644 + processes terminated, and they are prevented from executing any further
56645 + processes for 15 minutes.
56646 + It is recommended that you also enable signal logging in the auditing
56647 + section so that logs are generated when a process triggers a suspicious
56648 + signal.
56649 + If the sysctl option is enabled, a sysctl option with name
56650 + "deter_bruteforce" is created.
56651 +
56652 +
56653 +config GRKERNSEC_MODHARDEN
56654 + bool "Harden module auto-loading"
56655 + default y if GRKERNSEC_CONFIG_AUTO
56656 + depends on MODULES
56657 + help
56658 + If you say Y here, module auto-loading in response to use of some
56659 + feature implemented by an unloaded module will be restricted to
56660 + root users. Enabling this option helps defend against attacks
56661 + by unprivileged users who abuse the auto-loading behavior to
56662 + cause a vulnerable module to load that is then exploited.
56663 +
56664 + If this option prevents a legitimate use of auto-loading for a
56665 + non-root user, the administrator can execute modprobe manually
56666 + with the exact name of the module mentioned in the alert log.
56667 + Alternatively, the administrator can add the module to the list
56668 + of modules loaded at boot by modifying init scripts.
56669 +
56670 + Modification of init scripts will most likely be needed on
56671 + Ubuntu servers with encrypted home directory support enabled,
56672 + as the first non-root user logging in will cause the ecb(aes),
56673 + ecb(aes)-all, cbc(aes), and cbc(aes)-all modules to be loaded.
56674 +
56675 +config GRKERNSEC_HIDESYM
56676 + bool "Hide kernel symbols"
56677 + default y if GRKERNSEC_CONFIG_AUTO
56678 + select PAX_USERCOPY_SLABS
56679 + help
56680 + If you say Y here, getting information on loaded modules, and
56681 + displaying all kernel symbols through a syscall will be restricted
56682 + to users with CAP_SYS_MODULE. For software compatibility reasons,
56683 + /proc/kallsyms will be restricted to the root user. The RBAC
56684 + system can hide that entry even from root.
56685 +
56686 + This option also prevents leaking of kernel addresses through
56687 + several /proc entries.
56688 +
56689 + Note that this option is only effective provided the following
56690 + conditions are met:
56691 + 1) The kernel using grsecurity is not precompiled by some distribution
56692 + 2) You have also enabled GRKERNSEC_DMESG
56693 + 3) You are using the RBAC system and hiding other files such as your
56694 + kernel image and System.map. Alternatively, enabling this option
56695 + causes the permissions on /boot, /lib/modules, and the kernel
56696 + source directory to change at compile time to prevent
56697 + reading by non-root users.
56698 + If the above conditions are met, this option will aid in providing a
56699 + useful protection against local kernel exploitation of overflows
56700 + and arbitrary read/write vulnerabilities.
56701 +
56702 + It is highly recommended that you enable GRKERNSEC_PERF_HARDEN
56703 + in addition to this feature.
56704 +
56705 +config GRKERNSEC_KERN_LOCKOUT
56706 + bool "Active kernel exploit response"
56707 + default y if GRKERNSEC_CONFIG_AUTO
56708 + depends on X86 || ARM || PPC || SPARC
56709 + help
56710 + If you say Y here, when a PaX alert is triggered due to suspicious
56711 + activity in the kernel (from KERNEXEC/UDEREF/USERCOPY)
56712 + or an OOPS occurs due to bad memory accesses, instead of just
56713 + terminating the offending process (and potentially allowing
56714 + a subsequent exploit from the same user), we will take one of two
56715 + actions:
56716 + If the user was root, we will panic the system
56717 + If the user was non-root, we will log the attempt, terminate
56718 + all processes owned by the user, then prevent them from creating
56719 + any new processes until the system is restarted
56720 + This deters repeated kernel exploitation/bruteforcing attempts
56721 + and is useful for later forensics.
56722 +
56723 +endmenu
56724 +menu "Role Based Access Control Options"
56725 +depends on GRKERNSEC
56726 +
56727 +config GRKERNSEC_RBAC_DEBUG
56728 + bool
56729 +
56730 +config GRKERNSEC_NO_RBAC
56731 + bool "Disable RBAC system"
56732 + help
56733 + If you say Y here, the /dev/grsec device will be removed from the kernel,
56734 + preventing the RBAC system from being enabled. You should only say Y
56735 + here if you have no intention of using the RBAC system, so as to prevent
56736 + an attacker with root access from misusing the RBAC system to hide files
56737 + and processes when loadable module support and /dev/[k]mem have been
56738 + locked down.
56739 +
56740 +config GRKERNSEC_ACL_HIDEKERN
56741 + bool "Hide kernel processes"
56742 + help
56743 + If you say Y here, all kernel threads will be hidden to all
56744 + processes but those whose subject has the "view hidden processes"
56745 + flag.
56746 +
56747 +config GRKERNSEC_ACL_MAXTRIES
56748 + int "Maximum tries before password lockout"
56749 + default 3
56750 + help
56751 + This option enforces the maximum number of times a user can attempt
56752 + to authorize themselves with the grsecurity RBAC system before being
56753 + denied the ability to attempt authorization again for a specified time.
56754 + The lower the number, the harder it will be to brute-force a password.
56755 +
56756 +config GRKERNSEC_ACL_TIMEOUT
56757 + int "Time to wait after max password tries, in seconds"
56758 + default 30
56759 + help
56760 + This option specifies the time the user must wait after attempting to
56761 + authorize to the RBAC system with the maximum number of invalid
56762 + passwords. The higher the number, the harder it will be to brute-force
56763 + a password.
56764 +
56765 +endmenu
56766 +menu "Filesystem Protections"
56767 +depends on GRKERNSEC
56768 +
56769 +config GRKERNSEC_PROC
56770 + bool "Proc restrictions"
56771 + default y if GRKERNSEC_CONFIG_AUTO
56772 + help
56773 + If you say Y here, the permissions of the /proc filesystem
56774 + will be altered to enhance system security and privacy. You MUST
56775 + choose either a user only restriction or a user and group restriction.
56776 + Depending upon the option you choose, you can either restrict users to
56777 + see only the processes they themselves run, or choose a group that can
56778 + view all processes and files normally restricted to root if you choose
56779 + the "restrict to user only" option. NOTE: If you're running identd or
56780 + ntpd as a non-root user, you will have to run it as the group you
56781 + specify here.
56782 +
56783 +config GRKERNSEC_PROC_USER
56784 + bool "Restrict /proc to user only"
56785 + depends on GRKERNSEC_PROC
56786 + help
56787 + If you say Y here, non-root users will only be able to view their own
56788 + processes, and restricts them from viewing network-related information,
56789 + and viewing kernel symbol and module information.
56790 +
56791 +config GRKERNSEC_PROC_USERGROUP
56792 + bool "Allow special group"
56793 + default y if GRKERNSEC_CONFIG_AUTO
56794 + depends on GRKERNSEC_PROC && !GRKERNSEC_PROC_USER
56795 + help
56796 + If you say Y here, you will be able to select a group that will be
56797 + able to view all processes and network-related information. If you've
56798 + enabled GRKERNSEC_HIDESYM, kernel and symbol information may still
56799 + remain hidden. This option is useful if you want to run identd as
56800 + a non-root user. The group you select may also be chosen at boot time
56801 + via "grsec_proc_gid=" on the kernel commandline.
56802 +
56803 +config GRKERNSEC_PROC_GID
56804 + int "GID for special group"
56805 + depends on GRKERNSEC_PROC_USERGROUP
56806 + default 1001
56807 +
56808 +config GRKERNSEC_PROC_ADD
56809 + bool "Additional restrictions"
56810 + default y if GRKERNSEC_CONFIG_AUTO
56811 + depends on GRKERNSEC_PROC_USER || GRKERNSEC_PROC_USERGROUP
56812 + help
56813 + If you say Y here, additional restrictions will be placed on
56814 + /proc that keep normal users from viewing device information and
56815 + slabinfo information that could be useful for exploits.
56816 +
56817 +config GRKERNSEC_LINK
56818 + bool "Linking restrictions"
56819 + default y if GRKERNSEC_CONFIG_AUTO
56820 + help
56821 + If you say Y here, /tmp race exploits will be prevented, since users
56822 + will no longer be able to follow symlinks owned by other users in
56823 + world-writable +t directories (e.g. /tmp), unless the owner of the
56824 + symlink is the owner of the directory. users will also not be
56825 + able to hardlink to files they do not own. If the sysctl option is
56826 + enabled, a sysctl option with name "linking_restrictions" is created.
56827 +
56828 +config GRKERNSEC_SYMLINKOWN
56829 + bool "Kernel-enforced SymlinksIfOwnerMatch"
56830 + default y if GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER
56831 + help
56832 + Apache's SymlinksIfOwnerMatch option has an inherent race condition
56833 + that prevents it from being used as a security feature. As Apache
56834 + verifies the symlink by performing a stat() against the target of
56835 + the symlink before it is followed, an attacker can setup a symlink
56836 + to point to a same-owned file, then replace the symlink with one
56837 + that targets another user's file just after Apache "validates" the
56838 + symlink -- a classic TOCTOU race. If you say Y here, a complete,
56839 + race-free replacement for Apache's "SymlinksIfOwnerMatch" option
56840 + will be in place for the group you specify. If the sysctl option
56841 + is enabled, a sysctl option with name "enforce_symlinksifowner" is
56842 + created.
56843 +
56844 +config GRKERNSEC_SYMLINKOWN_GID
56845 + int "GID for users with kernel-enforced SymlinksIfOwnerMatch"
56846 + depends on GRKERNSEC_SYMLINKOWN
56847 + default 1006
56848 + help
56849 + Setting this GID determines what group kernel-enforced
56850 + SymlinksIfOwnerMatch will be enabled for. If the sysctl option
56851 + is enabled, a sysctl option with name "symlinkown_gid" is created.
56852 +
56853 +config GRKERNSEC_FIFO
56854 + bool "FIFO restrictions"
56855 + default y if GRKERNSEC_CONFIG_AUTO
56856 + help
56857 + If you say Y here, users will not be able to write to FIFOs they don't
56858 + own in world-writable +t directories (e.g. /tmp), unless the owner of
56859 + the FIFO is the same owner of the directory it's held in. If the sysctl
56860 + option is enabled, a sysctl option with name "fifo_restrictions" is
56861 + created.
56862 +
56863 +config GRKERNSEC_SYSFS_RESTRICT
56864 + bool "Sysfs/debugfs restriction"
56865 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
56866 + depends on SYSFS
56867 + help
56868 + If you say Y here, sysfs (the pseudo-filesystem mounted at /sys) and
56869 + any filesystem normally mounted under it (e.g. debugfs) will be
56870 + mostly accessible only by root. These filesystems generally provide access
56871 + to hardware and debug information that isn't appropriate for unprivileged
56872 + users of the system. Sysfs and debugfs have also become a large source
56873 + of new vulnerabilities, ranging from infoleaks to local compromise.
56874 + There has been very little oversight with an eye toward security involved
56875 + in adding new exporters of information to these filesystems, so their
56876 + use is discouraged.
56877 + For reasons of compatibility, a few directories have been whitelisted
56878 + for access by non-root users:
56879 + /sys/fs/selinux
56880 + /sys/fs/fuse
56881 + /sys/devices/system/cpu
56882 +
56883 +config GRKERNSEC_ROFS
56884 + bool "Runtime read-only mount protection"
56885 + help
56886 + If you say Y here, a sysctl option with name "romount_protect" will
56887 + be created. By setting this option to 1 at runtime, filesystems
56888 + will be protected in the following ways:
56889 + * No new writable mounts will be allowed
56890 + * Existing read-only mounts won't be able to be remounted read/write
56891 + * Write operations will be denied on all block devices
56892 + This option acts independently of grsec_lock: once it is set to 1,
56893 + it cannot be turned off. Therefore, please be mindful of the resulting
56894 + behavior if this option is enabled in an init script on a read-only
56895 + filesystem. This feature is mainly intended for secure embedded systems.
56896 +
56897 +config GRKERNSEC_DEVICE_SIDECHANNEL
56898 + bool "Eliminate stat/notify-based device sidechannels"
56899 + default y if GRKERNSEC_CONFIG_AUTO
56900 + help
56901 + If you say Y here, timing analyses on block or character
56902 + devices like /dev/ptmx using stat or inotify/dnotify/fanotify
56903 + will be thwarted for unprivileged users. If a process without
56904 + CAP_MKNOD stats such a device, the last access and last modify times
56905 + will match the device's create time. No access or modify events
56906 + will be triggered through inotify/dnotify/fanotify for such devices.
56907 + This feature will prevent attacks that may at a minimum
56908 + allow an attacker to determine the administrator's password length.
56909 +
56910 +config GRKERNSEC_CHROOT
56911 + bool "Chroot jail restrictions"
56912 + default y if GRKERNSEC_CONFIG_AUTO
56913 + help
56914 + If you say Y here, you will be able to choose several options that will
56915 + make breaking out of a chrooted jail much more difficult. If you
56916 + encounter no software incompatibilities with the following options, it
56917 + is recommended that you enable each one.
56918 +
56919 +config GRKERNSEC_CHROOT_MOUNT
56920 + bool "Deny mounts"
56921 + default y if GRKERNSEC_CONFIG_AUTO
56922 + depends on GRKERNSEC_CHROOT
56923 + help
56924 + If you say Y here, processes inside a chroot will not be able to
56925 + mount or remount filesystems. If the sysctl option is enabled, a
56926 + sysctl option with name "chroot_deny_mount" is created.
56927 +
56928 +config GRKERNSEC_CHROOT_DOUBLE
56929 + bool "Deny double-chroots"
56930 + default y if GRKERNSEC_CONFIG_AUTO
56931 + depends on GRKERNSEC_CHROOT
56932 + help
56933 + If you say Y here, processes inside a chroot will not be able to chroot
56934 + again outside the chroot. This is a widely used method of breaking
56935 + out of a chroot jail and should not be allowed. If the sysctl
56936 + option is enabled, a sysctl option with name
56937 + "chroot_deny_chroot" is created.
56938 +
56939 +config GRKERNSEC_CHROOT_PIVOT
56940 + bool "Deny pivot_root in chroot"
56941 + default y if GRKERNSEC_CONFIG_AUTO
56942 + depends on GRKERNSEC_CHROOT
56943 + help
56944 + If you say Y here, processes inside a chroot will not be able to use
56945 + a function called pivot_root() that was introduced in Linux 2.3.41. It
56946 + works similar to chroot in that it changes the root filesystem. This
56947 + function could be misused in a chrooted process to attempt to break out
56948 + of the chroot, and therefore should not be allowed. If the sysctl
56949 + option is enabled, a sysctl option with name "chroot_deny_pivot" is
56950 + created.
56951 +
56952 +config GRKERNSEC_CHROOT_CHDIR
56953 + bool "Enforce chdir(\"/\") on all chroots"
56954 + default y if GRKERNSEC_CONFIG_AUTO
56955 + depends on GRKERNSEC_CHROOT
56956 + help
56957 + If you say Y here, the current working directory of all newly-chrooted
56958 + applications will be set to the the root directory of the chroot.
56959 + The man page on chroot(2) states:
56960 + Note that this call does not change the current working
56961 + directory, so that `.' can be outside the tree rooted at
56962 + `/'. In particular, the super-user can escape from a
56963 + `chroot jail' by doing `mkdir foo; chroot foo; cd ..'.
56964 +
56965 + It is recommended that you say Y here, since it's not known to break
56966 + any software. If the sysctl option is enabled, a sysctl option with
56967 + name "chroot_enforce_chdir" is created.
56968 +
56969 +config GRKERNSEC_CHROOT_CHMOD
56970 + bool "Deny (f)chmod +s"
56971 + default y if GRKERNSEC_CONFIG_AUTO
56972 + depends on GRKERNSEC_CHROOT
56973 + help
56974 + If you say Y here, processes inside a chroot will not be able to chmod
56975 + or fchmod files to make them have suid or sgid bits. This protects
56976 + against another published method of breaking a chroot. If the sysctl
56977 + option is enabled, a sysctl option with name "chroot_deny_chmod" is
56978 + created.
56979 +
56980 +config GRKERNSEC_CHROOT_FCHDIR
56981 + bool "Deny fchdir out of chroot"
56982 + default y if GRKERNSEC_CONFIG_AUTO
56983 + depends on GRKERNSEC_CHROOT
56984 + help
56985 + If you say Y here, a well-known method of breaking chroots by fchdir'ing
56986 + to a file descriptor of the chrooting process that points to a directory
56987 + outside the filesystem will be stopped. If the sysctl option
56988 + is enabled, a sysctl option with name "chroot_deny_fchdir" is created.
56989 +
56990 +config GRKERNSEC_CHROOT_MKNOD
56991 + bool "Deny mknod"
56992 + default y if GRKERNSEC_CONFIG_AUTO
56993 + depends on GRKERNSEC_CHROOT
56994 + help
56995 + If you say Y here, processes inside a chroot will not be allowed to
56996 + mknod. The problem with using mknod inside a chroot is that it
56997 + would allow an attacker to create a device entry that is the same
56998 + as one on the physical root of your system, which could range from
56999 + anything from the console device to a device for your harddrive (which
57000 + they could then use to wipe the drive or steal data). It is recommended
57001 + that you say Y here, unless you run into software incompatibilities.
57002 + If the sysctl option is enabled, a sysctl option with name
57003 + "chroot_deny_mknod" is created.
57004 +
57005 +config GRKERNSEC_CHROOT_SHMAT
57006 + bool "Deny shmat() out of chroot"
57007 + default y if GRKERNSEC_CONFIG_AUTO
57008 + depends on GRKERNSEC_CHROOT
57009 + help
57010 + If you say Y here, processes inside a chroot will not be able to attach
57011 + to shared memory segments that were created outside of the chroot jail.
57012 + It is recommended that you say Y here. If the sysctl option is enabled,
57013 + a sysctl option with name "chroot_deny_shmat" is created.
57014 +
57015 +config GRKERNSEC_CHROOT_UNIX
57016 + bool "Deny access to abstract AF_UNIX sockets out of chroot"
57017 + default y if GRKERNSEC_CONFIG_AUTO
57018 + depends on GRKERNSEC_CHROOT
57019 + help
57020 + If you say Y here, processes inside a chroot will not be able to
57021 + connect to abstract (meaning not belonging to a filesystem) Unix
57022 + domain sockets that were bound outside of a chroot. It is recommended
57023 + that you say Y here. If the sysctl option is enabled, a sysctl option
57024 + with name "chroot_deny_unix" is created.
57025 +
57026 +config GRKERNSEC_CHROOT_FINDTASK
57027 + bool "Protect outside processes"
57028 + default y if GRKERNSEC_CONFIG_AUTO
57029 + depends on GRKERNSEC_CHROOT
57030 + help
57031 + If you say Y here, processes inside a chroot will not be able to
57032 + kill, send signals with fcntl, ptrace, capget, getpgid, setpgid,
57033 + getsid, or view any process outside of the chroot. If the sysctl
57034 + option is enabled, a sysctl option with name "chroot_findtask" is
57035 + created.
57036 +
57037 +config GRKERNSEC_CHROOT_NICE
57038 + bool "Restrict priority changes"
57039 + default y if GRKERNSEC_CONFIG_AUTO
57040 + depends on GRKERNSEC_CHROOT
57041 + help
57042 + If you say Y here, processes inside a chroot will not be able to raise
57043 + the priority of processes in the chroot, or alter the priority of
57044 + processes outside the chroot. This provides more security than simply
57045 + removing CAP_SYS_NICE from the process' capability set. If the
57046 + sysctl option is enabled, a sysctl option with name "chroot_restrict_nice"
57047 + is created.
57048 +
57049 +config GRKERNSEC_CHROOT_SYSCTL
57050 + bool "Deny sysctl writes"
57051 + default y if GRKERNSEC_CONFIG_AUTO
57052 + depends on GRKERNSEC_CHROOT
57053 + help
57054 + If you say Y here, an attacker in a chroot will not be able to
57055 + write to sysctl entries, either by sysctl(2) or through a /proc
57056 + interface. It is strongly recommended that you say Y here. If the
57057 + sysctl option is enabled, a sysctl option with name
57058 + "chroot_deny_sysctl" is created.
57059 +
57060 +config GRKERNSEC_CHROOT_CAPS
57061 + bool "Capability restrictions"
57062 + default y if GRKERNSEC_CONFIG_AUTO
57063 + depends on GRKERNSEC_CHROOT
57064 + help
57065 + If you say Y here, the capabilities on all processes within a
57066 + chroot jail will be lowered to stop module insertion, raw i/o,
57067 + system and net admin tasks, rebooting the system, modifying immutable
57068 + files, modifying IPC owned by another, and changing the system time.
57069 + This is left an option because it can break some apps. Disable this
57070 + if your chrooted apps are having problems performing those kinds of
57071 + tasks. If the sysctl option is enabled, a sysctl option with
57072 + name "chroot_caps" is created.
57073 +
57074 +config GRKERNSEC_CHROOT_INITRD
57075 + bool "Exempt initrd tasks from restrictions"
57076 + default y if GRKERNSEC_CONFIG_AUTO
57077 + depends on GRKERNSEC_CHROOT && BLK_DEV_RAM
57078 + help
57079 + If you say Y here, tasks started prior to init will be exempted from
57080 + grsecurity's chroot restrictions. This option is mainly meant to
57081 + resolve Plymouth's performing privileged operations unnecessarily
57082 + in a chroot.
57083 +
57084 +endmenu
57085 +menu "Kernel Auditing"
57086 +depends on GRKERNSEC
57087 +
57088 +config GRKERNSEC_AUDIT_GROUP
57089 + bool "Single group for auditing"
57090 + help
57091 + If you say Y here, the exec and chdir logging features will only operate
57092 + on a group you specify. This option is recommended if you only want to
57093 + watch certain users instead of having a large amount of logs from the
57094 + entire system. If the sysctl option is enabled, a sysctl option with
57095 + name "audit_group" is created.
57096 +
57097 +config GRKERNSEC_AUDIT_GID
57098 + int "GID for auditing"
57099 + depends on GRKERNSEC_AUDIT_GROUP
57100 + default 1007
57101 +
57102 +config GRKERNSEC_EXECLOG
57103 + bool "Exec logging"
57104 + help
57105 + If you say Y here, all execve() calls will be logged (since the
57106 + other exec*() calls are frontends to execve(), all execution
57107 + will be logged). Useful for shell-servers that like to keep track
57108 + of their users. If the sysctl option is enabled, a sysctl option with
57109 + name "exec_logging" is created.
57110 + WARNING: This option when enabled will produce a LOT of logs, especially
57111 + on an active system.
57112 +
57113 +config GRKERNSEC_RESLOG
57114 + bool "Resource logging"
57115 + default y if GRKERNSEC_CONFIG_AUTO
57116 + help
57117 + If you say Y here, all attempts to overstep resource limits will
57118 + be logged with the resource name, the requested size, and the current
57119 + limit. It is highly recommended that you say Y here. If the sysctl
57120 + option is enabled, a sysctl option with name "resource_logging" is
57121 + created. If the RBAC system is enabled, the sysctl value is ignored.
57122 +
57123 +config GRKERNSEC_CHROOT_EXECLOG
57124 + bool "Log execs within chroot"
57125 + help
57126 + If you say Y here, all executions inside a chroot jail will be logged
57127 + to syslog. This can cause a large amount of logs if certain
57128 + applications (eg. djb's daemontools) are installed on the system, and
57129 + is therefore left as an option. If the sysctl option is enabled, a
57130 + sysctl option with name "chroot_execlog" is created.
57131 +
57132 +config GRKERNSEC_AUDIT_PTRACE
57133 + bool "Ptrace logging"
57134 + help
57135 + If you say Y here, all attempts to attach to a process via ptrace
57136 + will be logged. If the sysctl option is enabled, a sysctl option
57137 + with name "audit_ptrace" is created.
57138 +
57139 +config GRKERNSEC_AUDIT_CHDIR
57140 + bool "Chdir logging"
57141 + help
57142 + If you say Y here, all chdir() calls will be logged. If the sysctl
57143 + option is enabled, a sysctl option with name "audit_chdir" is created.
57144 +
57145 +config GRKERNSEC_AUDIT_MOUNT
57146 + bool "(Un)Mount logging"
57147 + help
57148 + If you say Y here, all mounts and unmounts will be logged. If the
57149 + sysctl option is enabled, a sysctl option with name "audit_mount" is
57150 + created.
57151 +
57152 +config GRKERNSEC_SIGNAL
57153 + bool "Signal logging"
57154 + default y if GRKERNSEC_CONFIG_AUTO
57155 + help
57156 + If you say Y here, certain important signals will be logged, such as
57157 + SIGSEGV, which will as a result inform you of when a error in a program
57158 + occurred, which in some cases could mean a possible exploit attempt.
57159 + If the sysctl option is enabled, a sysctl option with name
57160 + "signal_logging" is created.
57161 +
57162 +config GRKERNSEC_FORKFAIL
57163 + bool "Fork failure logging"
57164 + help
57165 + If you say Y here, all failed fork() attempts will be logged.
57166 + This could suggest a fork bomb, or someone attempting to overstep
57167 + their process limit. If the sysctl option is enabled, a sysctl option
57168 + with name "forkfail_logging" is created.
57169 +
57170 +config GRKERNSEC_TIME
57171 + bool "Time change logging"
57172 + default y if GRKERNSEC_CONFIG_AUTO
57173 + help
57174 + If you say Y here, any changes of the system clock will be logged.
57175 + If the sysctl option is enabled, a sysctl option with name
57176 + "timechange_logging" is created.
57177 +
57178 +config GRKERNSEC_PROC_IPADDR
57179 + bool "/proc/<pid>/ipaddr support"
57180 + default y if GRKERNSEC_CONFIG_AUTO
57181 + help
57182 + If you say Y here, a new entry will be added to each /proc/<pid>
57183 + directory that contains the IP address of the person using the task.
57184 + The IP is carried across local TCP and AF_UNIX stream sockets.
57185 + This information can be useful for IDS/IPSes to perform remote response
57186 + to a local attack. The entry is readable by only the owner of the
57187 + process (and root if he has CAP_DAC_OVERRIDE, which can be removed via
57188 + the RBAC system), and thus does not create privacy concerns.
57189 +
57190 +config GRKERNSEC_RWXMAP_LOG
57191 + bool 'Denied RWX mmap/mprotect logging'
57192 + default y if GRKERNSEC_CONFIG_AUTO
57193 + depends on PAX_MPROTECT && !PAX_EMUPLT && !PAX_EMUSIGRT
57194 + help
57195 + If you say Y here, calls to mmap() and mprotect() with explicit
57196 + usage of PROT_WRITE and PROT_EXEC together will be logged when
57197 + denied by the PAX_MPROTECT feature. If the sysctl option is
57198 + enabled, a sysctl option with name "rwxmap_logging" is created.
57199 +
57200 +config GRKERNSEC_AUDIT_TEXTREL
57201 + bool 'ELF text relocations logging (READ HELP)'
57202 + depends on PAX_MPROTECT
57203 + help
57204 + If you say Y here, text relocations will be logged with the filename
57205 + of the offending library or binary. The purpose of the feature is
57206 + to help Linux distribution developers get rid of libraries and
57207 + binaries that need text relocations which hinder the future progress
57208 + of PaX. Only Linux distribution developers should say Y here, and
57209 + never on a production machine, as this option creates an information
57210 + leak that could aid an attacker in defeating the randomization of
57211 + a single memory region. If the sysctl option is enabled, a sysctl
57212 + option with name "audit_textrel" is created.
57213 +
57214 +endmenu
57215 +
57216 +menu "Executable Protections"
57217 +depends on GRKERNSEC
57218 +
57219 +config GRKERNSEC_DMESG
57220 + bool "Dmesg(8) restriction"
57221 + default y if GRKERNSEC_CONFIG_AUTO
57222 + help
57223 + If you say Y here, non-root users will not be able to use dmesg(8)
57224 + to view the contents of the kernel's circular log buffer.
57225 + The kernel's log buffer often contains kernel addresses and other
57226 + identifying information useful to an attacker in fingerprinting a
57227 + system for a targeted exploit.
57228 + If the sysctl option is enabled, a sysctl option with name "dmesg" is
57229 + created.
57230 +
57231 +config GRKERNSEC_HARDEN_PTRACE
57232 + bool "Deter ptrace-based process snooping"
57233 + default y if GRKERNSEC_CONFIG_AUTO
57234 + help
57235 + If you say Y here, TTY sniffers and other malicious monitoring
57236 + programs implemented through ptrace will be defeated. If you
57237 + have been using the RBAC system, this option has already been
57238 + enabled for several years for all users, with the ability to make
57239 + fine-grained exceptions.
57240 +
57241 + This option only affects the ability of non-root users to ptrace
57242 + processes that are not a descendent of the ptracing process.
57243 + This means that strace ./binary and gdb ./binary will still work,
57244 + but attaching to arbitrary processes will not. If the sysctl
57245 + option is enabled, a sysctl option with name "harden_ptrace" is
57246 + created.
57247 +
57248 +config GRKERNSEC_PTRACE_READEXEC
57249 + bool "Require read access to ptrace sensitive binaries"
57250 + default y if GRKERNSEC_CONFIG_AUTO
57251 + help
57252 + If you say Y here, unprivileged users will not be able to ptrace unreadable
57253 + binaries. This option is useful in environments that
57254 + remove the read bits (e.g. file mode 4711) from suid binaries to
57255 + prevent infoleaking of their contents. This option adds
57256 + consistency to the use of that file mode, as the binary could normally
57257 + be read out when run without privileges while ptracing.
57258 +
57259 + If the sysctl option is enabled, a sysctl option with name "ptrace_readexec"
57260 + is created.
57261 +
57262 +config GRKERNSEC_SETXID
57263 + bool "Enforce consistent multithreaded privileges"
57264 + default y if GRKERNSEC_CONFIG_AUTO
57265 + depends on (X86 || SPARC64 || PPC || ARM || MIPS)
57266 + help
57267 + If you say Y here, a change from a root uid to a non-root uid
57268 + in a multithreaded application will cause the resulting uids,
57269 + gids, supplementary groups, and capabilities in that thread
57270 + to be propagated to the other threads of the process. In most
57271 + cases this is unnecessary, as glibc will emulate this behavior
57272 + on behalf of the application. Other libcs do not act in the
57273 + same way, allowing the other threads of the process to continue
57274 + running with root privileges. If the sysctl option is enabled,
57275 + a sysctl option with name "consistent_setxid" is created.
57276 +
57277 +config GRKERNSEC_TPE
57278 + bool "Trusted Path Execution (TPE)"
57279 + default y if GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER
57280 + help
57281 + If you say Y here, you will be able to choose a gid to add to the
57282 + supplementary groups of users you want to mark as "untrusted."
57283 + These users will not be able to execute any files that are not in
57284 + root-owned directories writable only by root. If the sysctl option
57285 + is enabled, a sysctl option with name "tpe" is created.
57286 +
57287 +config GRKERNSEC_TPE_ALL
57288 + bool "Partially restrict all non-root users"
57289 + depends on GRKERNSEC_TPE
57290 + help
57291 + If you say Y here, all non-root users will be covered under
57292 + a weaker TPE restriction. This is separate from, and in addition to,
57293 + the main TPE options that you have selected elsewhere. Thus, if a
57294 + "trusted" GID is chosen, this restriction applies to even that GID.
57295 + Under this restriction, all non-root users will only be allowed to
57296 + execute files in directories they own that are not group or
57297 + world-writable, or in directories owned by root and writable only by
57298 + root. If the sysctl option is enabled, a sysctl option with name
57299 + "tpe_restrict_all" is created.
57300 +
57301 +config GRKERNSEC_TPE_INVERT
57302 + bool "Invert GID option"
57303 + depends on GRKERNSEC_TPE
57304 + help
57305 + If you say Y here, the group you specify in the TPE configuration will
57306 + decide what group TPE restrictions will be *disabled* for. This
57307 + option is useful if you want TPE restrictions to be applied to most
57308 + users on the system. If the sysctl option is enabled, a sysctl option
57309 + with name "tpe_invert" is created. Unlike other sysctl options, this
57310 + entry will default to on for backward-compatibility.
57311 +
57312 +config GRKERNSEC_TPE_GID
57313 + int
57314 + default GRKERNSEC_TPE_UNTRUSTED_GID if (GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT)
57315 + default GRKERNSEC_TPE_TRUSTED_GID if (GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT)
57316 +
57317 +config GRKERNSEC_TPE_UNTRUSTED_GID
57318 + int "GID for TPE-untrusted users"
57319 + depends on GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT
57320 + default 1005
57321 + help
57322 + Setting this GID determines what group TPE restrictions will be
57323 + *enabled* for. If the sysctl option is enabled, a sysctl option
57324 + with name "tpe_gid" is created.
57325 +
57326 +config GRKERNSEC_TPE_TRUSTED_GID
57327 + int "GID for TPE-trusted users"
57328 + depends on GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT
57329 + default 1005
57330 + help
57331 + Setting this GID determines what group TPE restrictions will be
57332 + *disabled* for. If the sysctl option is enabled, a sysctl option
57333 + with name "tpe_gid" is created.
57334 +
57335 +endmenu
57336 +menu "Network Protections"
57337 +depends on GRKERNSEC
57338 +
57339 +config GRKERNSEC_RANDNET
57340 + bool "Larger entropy pools"
57341 + default y if GRKERNSEC_CONFIG_AUTO
57342 + help
57343 + If you say Y here, the entropy pools used for many features of Linux
57344 + and grsecurity will be doubled in size. Since several grsecurity
57345 + features use additional randomness, it is recommended that you say Y
57346 + here. Saying Y here has a similar effect as modifying
57347 + /proc/sys/kernel/random/poolsize.
57348 +
57349 +config GRKERNSEC_BLACKHOLE
57350 + bool "TCP/UDP blackhole and LAST_ACK DoS prevention"
57351 + default y if GRKERNSEC_CONFIG_AUTO
57352 + depends on NET
57353 + help
57354 + If you say Y here, neither TCP resets nor ICMP
57355 + destination-unreachable packets will be sent in response to packets
57356 + sent to ports for which no associated listening process exists.
57357 + This feature supports both IPV4 and IPV6 and exempts the
57358 + loopback interface from blackholing. Enabling this feature
57359 + makes a host more resilient to DoS attacks and reduces network
57360 + visibility against scanners.
57361 +
57362 + The blackhole feature as-implemented is equivalent to the FreeBSD
57363 + blackhole feature, as it prevents RST responses to all packets, not
57364 + just SYNs. Under most application behavior this causes no
57365 + problems, but applications (like haproxy) may not close certain
57366 + connections in a way that cleanly terminates them on the remote
57367 + end, leaving the remote host in LAST_ACK state. Because of this
57368 + side-effect and to prevent intentional LAST_ACK DoSes, this
57369 + feature also adds automatic mitigation against such attacks.
57370 + The mitigation drastically reduces the amount of time a socket
57371 + can spend in LAST_ACK state. If you're using haproxy and not
57372 + all servers it connects to have this option enabled, consider
57373 + disabling this feature on the haproxy host.
57374 +
57375 + If the sysctl option is enabled, two sysctl options with names
57376 + "ip_blackhole" and "lastack_retries" will be created.
57377 + While "ip_blackhole" takes the standard zero/non-zero on/off
57378 + toggle, "lastack_retries" uses the same kinds of values as
57379 + "tcp_retries1" and "tcp_retries2". The default value of 4
57380 + prevents a socket from lasting more than 45 seconds in LAST_ACK
57381 + state.
57382 +
57383 +config GRKERNSEC_NO_SIMULT_CONNECT
57384 + bool "Disable TCP Simultaneous Connect"
57385 + default y if GRKERNSEC_CONFIG_AUTO
57386 + depends on NET
57387 + help
57388 + If you say Y here, a feature by Willy Tarreau will be enabled that
57389 + removes a weakness in Linux's strict implementation of TCP that
57390 + allows two clients to connect to each other without either entering
57391 + a listening state. The weakness allows an attacker to easily prevent
57392 + a client from connecting to a known server provided the source port
57393 + for the connection is guessed correctly.
57394 +
57395 + As the weakness could be used to prevent an antivirus or IPS from
57396 + fetching updates, or prevent an SSL gateway from fetching a CRL,
57397 + it should be eliminated by enabling this option. Though Linux is
57398 + one of few operating systems supporting simultaneous connect, it
57399 + has no legitimate use in practice and is rarely supported by firewalls.
57400 +
57401 +config GRKERNSEC_SOCKET
57402 + bool "Socket restrictions"
57403 + depends on NET
57404 + help
57405 + If you say Y here, you will be able to choose from several options.
57406 + If you assign a GID on your system and add it to the supplementary
57407 + groups of users you want to restrict socket access to, this patch
57408 + will perform up to three things, based on the option(s) you choose.
57409 +
57410 +config GRKERNSEC_SOCKET_ALL
57411 + bool "Deny any sockets to group"
57412 + depends on GRKERNSEC_SOCKET
57413 + help
57414 + If you say Y here, you will be able to choose a GID of whose users will
57415 + be unable to connect to other hosts from your machine or run server
57416 + applications from your machine. If the sysctl option is enabled, a
57417 + sysctl option with name "socket_all" is created.
57418 +
57419 +config GRKERNSEC_SOCKET_ALL_GID
57420 + int "GID to deny all sockets for"
57421 + depends on GRKERNSEC_SOCKET_ALL
57422 + default 1004
57423 + help
57424 + Here you can choose the GID to disable socket access for. Remember to
57425 + add the users you want socket access disabled for to the GID
57426 + specified here. If the sysctl option is enabled, a sysctl option
57427 + with name "socket_all_gid" is created.
57428 +
57429 +config GRKERNSEC_SOCKET_CLIENT
57430 + bool "Deny client sockets to group"
57431 + depends on GRKERNSEC_SOCKET
57432 + help
57433 + If you say Y here, you will be able to choose a GID of whose users will
57434 + be unable to connect to other hosts from your machine, but will be
57435 + able to run servers. If this option is enabled, all users in the group
57436 + you specify will have to use passive mode when initiating ftp transfers
57437 + from the shell on your machine. If the sysctl option is enabled, a
57438 + sysctl option with name "socket_client" is created.
57439 +
57440 +config GRKERNSEC_SOCKET_CLIENT_GID
57441 + int "GID to deny client sockets for"
57442 + depends on GRKERNSEC_SOCKET_CLIENT
57443 + default 1003
57444 + help
57445 + Here you can choose the GID to disable client socket access for.
57446 + Remember to add the users you want client socket access disabled for to
57447 + the GID specified here. If the sysctl option is enabled, a sysctl
57448 + option with name "socket_client_gid" is created.
57449 +
57450 +config GRKERNSEC_SOCKET_SERVER
57451 + bool "Deny server sockets to group"
57452 + depends on GRKERNSEC_SOCKET
57453 + help
57454 + If you say Y here, you will be able to choose a GID of whose users will
57455 + be unable to run server applications from your machine. If the sysctl
57456 + option is enabled, a sysctl option with name "socket_server" is created.
57457 +
57458 +config GRKERNSEC_SOCKET_SERVER_GID
57459 + int "GID to deny server sockets for"
57460 + depends on GRKERNSEC_SOCKET_SERVER
57461 + default 1002
57462 + help
57463 + Here you can choose the GID to disable server socket access for.
57464 + Remember to add the users you want server socket access disabled for to
57465 + the GID specified here. If the sysctl option is enabled, a sysctl
57466 + option with name "socket_server_gid" is created.
57467 +
57468 +endmenu
57469 +menu "Sysctl Support"
57470 +depends on GRKERNSEC && SYSCTL
57471 +
57472 +config GRKERNSEC_SYSCTL
57473 + bool "Sysctl support"
57474 + default y if GRKERNSEC_CONFIG_AUTO
57475 + help
57476 + If you say Y here, you will be able to change the options that
57477 + grsecurity runs with at bootup, without having to recompile your
57478 + kernel. You can echo values to files in /proc/sys/kernel/grsecurity
57479 + to enable (1) or disable (0) various features. All the sysctl entries
57480 + are mutable until the "grsec_lock" entry is set to a non-zero value.
57481 + All features enabled in the kernel configuration are disabled at boot
57482 + if you do not say Y to the "Turn on features by default" option.
57483 + All options should be set at startup, and the grsec_lock entry should
57484 + be set to a non-zero value after all the options are set.
57485 + *THIS IS EXTREMELY IMPORTANT*
57486 +
57487 +config GRKERNSEC_SYSCTL_DISTRO
57488 + bool "Extra sysctl support for distro makers (READ HELP)"
57489 + depends on GRKERNSEC_SYSCTL && GRKERNSEC_IO
57490 + help
57491 + If you say Y here, additional sysctl options will be created
57492 + for features that affect processes running as root. Therefore,
57493 + it is critical when using this option that the grsec_lock entry be
57494 + enabled after boot. Only distros with prebuilt kernel packages
57495 + with this option enabled that can ensure grsec_lock is enabled
57496 + after boot should use this option.
57497 + *Failure to set grsec_lock after boot makes all grsec features
57498 + this option covers useless*
57499 +
57500 + Currently this option creates the following sysctl entries:
57501 + "Disable Privileged I/O": "disable_priv_io"
57502 +
57503 +config GRKERNSEC_SYSCTL_ON
57504 + bool "Turn on features by default"
57505 + default y if GRKERNSEC_CONFIG_AUTO
57506 + depends on GRKERNSEC_SYSCTL
57507 + help
57508 + If you say Y here, instead of having all features enabled in the
57509 + kernel configuration disabled at boot time, the features will be
57510 + enabled at boot time. It is recommended you say Y here unless
57511 + there is some reason you would want all sysctl-tunable features to
57512 + be disabled by default. As mentioned elsewhere, it is important
57513 + to enable the grsec_lock entry once you have finished modifying
57514 + the sysctl entries.
57515 +
57516 +endmenu
57517 +menu "Logging Options"
57518 +depends on GRKERNSEC
57519 +
57520 +config GRKERNSEC_FLOODTIME
57521 + int "Seconds in between log messages (minimum)"
57522 + default 10
57523 + help
57524 + This option allows you to enforce the number of seconds between
57525 + grsecurity log messages. The default should be suitable for most
57526 + people, however, if you choose to change it, choose a value small enough
57527 + to allow informative logs to be produced, but large enough to
57528 + prevent flooding.
57529 +
57530 +config GRKERNSEC_FLOODBURST
57531 + int "Number of messages in a burst (maximum)"
57532 + default 6
57533 + help
57534 + This option allows you to choose the maximum number of messages allowed
57535 + within the flood time interval you chose in a separate option. The
57536 + default should be suitable for most people, however if you find that
57537 + many of your logs are being interpreted as flooding, you may want to
57538 + raise this value.
57539 +
57540 +endmenu
57541 diff --git a/grsecurity/Makefile b/grsecurity/Makefile
57542 new file mode 100644
57543 index 0000000..1b9afa9
57544 --- /dev/null
57545 +++ b/grsecurity/Makefile
57546 @@ -0,0 +1,38 @@
57547 +# grsecurity's ACL system was originally written in 2001 by Michael Dalton
57548 +# during 2001-2009 it has been completely redesigned by Brad Spengler
57549 +# into an RBAC system
57550 +#
57551 +# All code in this directory and various hooks inserted throughout the kernel
57552 +# are copyright Brad Spengler - Open Source Security, Inc., and released
57553 +# under the GPL v2 or higher
57554 +
57555 +KBUILD_CFLAGS += -Werror
57556 +
57557 +obj-y = grsec_chdir.o grsec_chroot.o grsec_exec.o grsec_fifo.o grsec_fork.o \
57558 + grsec_mount.o grsec_sig.o grsec_sysctl.o \
57559 + grsec_time.o grsec_tpe.o grsec_link.o grsec_pax.o grsec_ptrace.o
57560 +
57561 +obj-$(CONFIG_GRKERNSEC) += grsec_init.o grsum.o gracl.o gracl_segv.o \
57562 + gracl_cap.o gracl_alloc.o gracl_shm.o grsec_mem.o gracl_fs.o \
57563 + gracl_learn.o grsec_log.o
57564 +obj-$(CONFIG_GRKERNSEC_RESLOG) += gracl_res.o
57565 +
57566 +ifdef CONFIG_NET
57567 +obj-y += grsec_sock.o
57568 +obj-$(CONFIG_GRKERNSEC) += gracl_ip.o
57569 +endif
57570 +
57571 +ifndef CONFIG_GRKERNSEC
57572 +obj-y += grsec_disabled.o
57573 +endif
57574 +
57575 +ifdef CONFIG_GRKERNSEC_HIDESYM
57576 +extra-y := grsec_hidesym.o
57577 +$(obj)/grsec_hidesym.o:
57578 + @-chmod -f 500 /boot
57579 + @-chmod -f 500 /lib/modules
57580 + @-chmod -f 500 /lib64/modules
57581 + @-chmod -f 500 /lib32/modules
57582 + @-chmod -f 700 .
57583 + @echo ' grsec: protected kernel image paths'
57584 +endif
57585 diff --git a/grsecurity/gracl.c b/grsecurity/gracl.c
57586 new file mode 100644
57587 index 0000000..1248ee0
57588 --- /dev/null
57589 +++ b/grsecurity/gracl.c
57590 @@ -0,0 +1,4073 @@
57591 +#include <linux/kernel.h>
57592 +#include <linux/module.h>
57593 +#include <linux/sched.h>
57594 +#include <linux/mm.h>
57595 +#include <linux/file.h>
57596 +#include <linux/fs.h>
57597 +#include <linux/namei.h>
57598 +#include <linux/mount.h>
57599 +#include <linux/tty.h>
57600 +#include <linux/proc_fs.h>
57601 +#include <linux/lglock.h>
57602 +#include <linux/slab.h>
57603 +#include <linux/vmalloc.h>
57604 +#include <linux/types.h>
57605 +#include <linux/sysctl.h>
57606 +#include <linux/netdevice.h>
57607 +#include <linux/ptrace.h>
57608 +#include <linux/gracl.h>
57609 +#include <linux/gralloc.h>
57610 +#include <linux/security.h>
57611 +#include <linux/grinternal.h>
57612 +#include <linux/pid_namespace.h>
57613 +#include <linux/stop_machine.h>
57614 +#include <linux/fdtable.h>
57615 +#include <linux/percpu.h>
57616 +#include <linux/lglock.h>
57617 +#include <linux/hugetlb.h>
57618 +#include <linux/posix-timers.h>
57619 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
57620 +#include <linux/magic.h>
57621 +#include <linux/pagemap.h>
57622 +#include "../fs/btrfs/async-thread.h"
57623 +#include "../fs/btrfs/ctree.h"
57624 +#include "../fs/btrfs/btrfs_inode.h"
57625 +#endif
57626 +#include "../fs/mount.h"
57627 +
57628 +#include <asm/uaccess.h>
57629 +#include <asm/errno.h>
57630 +#include <asm/mman.h>
57631 +
57632 +extern struct lglock vfsmount_lock;
57633 +
57634 +static struct acl_role_db acl_role_set;
57635 +static struct name_db name_set;
57636 +static struct inodev_db inodev_set;
57637 +
57638 +/* for keeping track of userspace pointers used for subjects, so we
57639 + can share references in the kernel as well
57640 +*/
57641 +
57642 +static struct path real_root;
57643 +
57644 +static struct acl_subj_map_db subj_map_set;
57645 +
57646 +static struct acl_role_label *default_role;
57647 +
57648 +static struct acl_role_label *role_list;
57649 +
57650 +static u16 acl_sp_role_value;
57651 +
57652 +extern char *gr_shared_page[4];
57653 +static DEFINE_MUTEX(gr_dev_mutex);
57654 +DEFINE_RWLOCK(gr_inode_lock);
57655 +
57656 +struct gr_arg *gr_usermode;
57657 +
57658 +static unsigned int gr_status __read_only = GR_STATUS_INIT;
57659 +
57660 +extern int chkpw(struct gr_arg *entry, unsigned char *salt, unsigned char *sum);
57661 +extern void gr_clear_learn_entries(void);
57662 +
57663 +unsigned char *gr_system_salt;
57664 +unsigned char *gr_system_sum;
57665 +
57666 +static struct sprole_pw **acl_special_roles = NULL;
57667 +static __u16 num_sprole_pws = 0;
57668 +
57669 +static struct acl_role_label *kernel_role = NULL;
57670 +
57671 +static unsigned int gr_auth_attempts = 0;
57672 +static unsigned long gr_auth_expires = 0UL;
57673 +
57674 +#ifdef CONFIG_NET
57675 +extern struct vfsmount *sock_mnt;
57676 +#endif
57677 +
57678 +extern struct vfsmount *pipe_mnt;
57679 +extern struct vfsmount *shm_mnt;
57680 +
57681 +#ifdef CONFIG_HUGETLBFS
57682 +extern struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
57683 +#endif
57684 +
57685 +static struct acl_object_label *fakefs_obj_rw;
57686 +static struct acl_object_label *fakefs_obj_rwx;
57687 +
57688 +extern int gr_init_uidset(void);
57689 +extern void gr_free_uidset(void);
57690 +extern void gr_remove_uid(uid_t uid);
57691 +extern int gr_find_uid(uid_t uid);
57692 +
57693 +__inline__ int
57694 +gr_acl_is_enabled(void)
57695 +{
57696 + return (gr_status & GR_READY);
57697 +}
57698 +
57699 +static inline dev_t __get_dev(const struct dentry *dentry)
57700 +{
57701 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
57702 + if (dentry->d_sb->s_magic == BTRFS_SUPER_MAGIC)
57703 + return BTRFS_I(dentry->d_inode)->root->anon_dev;
57704 + else
57705 +#endif
57706 + return dentry->d_sb->s_dev;
57707 +}
57708 +
57709 +dev_t gr_get_dev_from_dentry(struct dentry *dentry)
57710 +{
57711 + return __get_dev(dentry);
57712 +}
57713 +
57714 +static char gr_task_roletype_to_char(struct task_struct *task)
57715 +{
57716 + switch (task->role->roletype &
57717 + (GR_ROLE_DEFAULT | GR_ROLE_USER | GR_ROLE_GROUP |
57718 + GR_ROLE_SPECIAL)) {
57719 + case GR_ROLE_DEFAULT:
57720 + return 'D';
57721 + case GR_ROLE_USER:
57722 + return 'U';
57723 + case GR_ROLE_GROUP:
57724 + return 'G';
57725 + case GR_ROLE_SPECIAL:
57726 + return 'S';
57727 + }
57728 +
57729 + return 'X';
57730 +}
57731 +
57732 +char gr_roletype_to_char(void)
57733 +{
57734 + return gr_task_roletype_to_char(current);
57735 +}
57736 +
57737 +__inline__ int
57738 +gr_acl_tpe_check(void)
57739 +{
57740 + if (unlikely(!(gr_status & GR_READY)))
57741 + return 0;
57742 + if (current->role->roletype & GR_ROLE_TPE)
57743 + return 1;
57744 + else
57745 + return 0;
57746 +}
57747 +
57748 +int
57749 +gr_handle_rawio(const struct inode *inode)
57750 +{
57751 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
57752 + if (inode && S_ISBLK(inode->i_mode) &&
57753 + grsec_enable_chroot_caps && proc_is_chrooted(current) &&
57754 + !capable(CAP_SYS_RAWIO))
57755 + return 1;
57756 +#endif
57757 + return 0;
57758 +}
57759 +
57760 +static int
57761 +gr_streq(const char *a, const char *b, const unsigned int lena, const unsigned int lenb)
57762 +{
57763 + if (likely(lena != lenb))
57764 + return 0;
57765 +
57766 + return !memcmp(a, b, lena);
57767 +}
57768 +
57769 +static int prepend(char **buffer, int *buflen, const char *str, int namelen)
57770 +{
57771 + *buflen -= namelen;
57772 + if (*buflen < 0)
57773 + return -ENAMETOOLONG;
57774 + *buffer -= namelen;
57775 + memcpy(*buffer, str, namelen);
57776 + return 0;
57777 +}
57778 +
57779 +static int prepend_name(char **buffer, int *buflen, struct qstr *name)
57780 +{
57781 + return prepend(buffer, buflen, name->name, name->len);
57782 +}
57783 +
57784 +static int prepend_path(const struct path *path, struct path *root,
57785 + char **buffer, int *buflen)
57786 +{
57787 + struct dentry *dentry = path->dentry;
57788 + struct vfsmount *vfsmnt = path->mnt;
57789 + struct mount *mnt = real_mount(vfsmnt);
57790 + bool slash = false;
57791 + int error = 0;
57792 +
57793 + while (dentry != root->dentry || vfsmnt != root->mnt) {
57794 + struct dentry * parent;
57795 +
57796 + if (dentry == vfsmnt->mnt_root || IS_ROOT(dentry)) {
57797 + /* Global root? */
57798 + if (!mnt_has_parent(mnt)) {
57799 + goto out;
57800 + }
57801 + dentry = mnt->mnt_mountpoint;
57802 + mnt = mnt->mnt_parent;
57803 + vfsmnt = &mnt->mnt;
57804 + continue;
57805 + }
57806 + parent = dentry->d_parent;
57807 + prefetch(parent);
57808 + spin_lock(&dentry->d_lock);
57809 + error = prepend_name(buffer, buflen, &dentry->d_name);
57810 + spin_unlock(&dentry->d_lock);
57811 + if (!error)
57812 + error = prepend(buffer, buflen, "/", 1);
57813 + if (error)
57814 + break;
57815 +
57816 + slash = true;
57817 + dentry = parent;
57818 + }
57819 +
57820 +out:
57821 + if (!error && !slash)
57822 + error = prepend(buffer, buflen, "/", 1);
57823 +
57824 + return error;
57825 +}
57826 +
57827 +/* this must be called with vfsmount_lock and rename_lock held */
57828 +
57829 +static char *__our_d_path(const struct path *path, struct path *root,
57830 + char *buf, int buflen)
57831 +{
57832 + char *res = buf + buflen;
57833 + int error;
57834 +
57835 + prepend(&res, &buflen, "\0", 1);
57836 + error = prepend_path(path, root, &res, &buflen);
57837 + if (error)
57838 + return ERR_PTR(error);
57839 +
57840 + return res;
57841 +}
57842 +
57843 +static char *
57844 +gen_full_path(struct path *path, struct path *root, char *buf, int buflen)
57845 +{
57846 + char *retval;
57847 +
57848 + retval = __our_d_path(path, root, buf, buflen);
57849 + if (unlikely(IS_ERR(retval)))
57850 + retval = strcpy(buf, "<path too long>");
57851 + else if (unlikely(retval[1] == '/' && retval[2] == '\0'))
57852 + retval[1] = '\0';
57853 +
57854 + return retval;
57855 +}
57856 +
57857 +static char *
57858 +__d_real_path(const struct dentry *dentry, const struct vfsmount *vfsmnt,
57859 + char *buf, int buflen)
57860 +{
57861 + struct path path;
57862 + char *res;
57863 +
57864 + path.dentry = (struct dentry *)dentry;
57865 + path.mnt = (struct vfsmount *)vfsmnt;
57866 +
57867 + /* we can use real_root.dentry, real_root.mnt, because this is only called
57868 + by the RBAC system */
57869 + res = gen_full_path(&path, &real_root, buf, buflen);
57870 +
57871 + return res;
57872 +}
57873 +
57874 +static char *
57875 +d_real_path(const struct dentry *dentry, const struct vfsmount *vfsmnt,
57876 + char *buf, int buflen)
57877 +{
57878 + char *res;
57879 + struct path path;
57880 + struct path root;
57881 + struct task_struct *reaper = init_pid_ns.child_reaper;
57882 +
57883 + path.dentry = (struct dentry *)dentry;
57884 + path.mnt = (struct vfsmount *)vfsmnt;
57885 +
57886 + /* we can't use real_root.dentry, real_root.mnt, because they belong only to the RBAC system */
57887 + get_fs_root(reaper->fs, &root);
57888 +
57889 + br_read_lock(&vfsmount_lock);
57890 + write_seqlock(&rename_lock);
57891 + res = gen_full_path(&path, &root, buf, buflen);
57892 + write_sequnlock(&rename_lock);
57893 + br_read_unlock(&vfsmount_lock);
57894 +
57895 + path_put(&root);
57896 + return res;
57897 +}
57898 +
57899 +static char *
57900 +gr_to_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt)
57901 +{
57902 + char *ret;
57903 + br_read_lock(&vfsmount_lock);
57904 + write_seqlock(&rename_lock);
57905 + ret = __d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0],smp_processor_id()),
57906 + PAGE_SIZE);
57907 + write_sequnlock(&rename_lock);
57908 + br_read_unlock(&vfsmount_lock);
57909 + return ret;
57910 +}
57911 +
57912 +static char *
57913 +gr_to_proc_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt)
57914 +{
57915 + char *ret;
57916 + char *buf;
57917 + int buflen;
57918 +
57919 + br_read_lock(&vfsmount_lock);
57920 + write_seqlock(&rename_lock);
57921 + buf = per_cpu_ptr(gr_shared_page[0], smp_processor_id());
57922 + ret = __d_real_path(dentry, mnt, buf, PAGE_SIZE - 6);
57923 + buflen = (int)(ret - buf);
57924 + if (buflen >= 5)
57925 + prepend(&ret, &buflen, "/proc", 5);
57926 + else
57927 + ret = strcpy(buf, "<path too long>");
57928 + write_sequnlock(&rename_lock);
57929 + br_read_unlock(&vfsmount_lock);
57930 + return ret;
57931 +}
57932 +
57933 +char *
57934 +gr_to_filename_nolock(const struct dentry *dentry, const struct vfsmount *mnt)
57935 +{
57936 + return __d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0],smp_processor_id()),
57937 + PAGE_SIZE);
57938 +}
57939 +
57940 +char *
57941 +gr_to_filename(const struct dentry *dentry, const struct vfsmount *mnt)
57942 +{
57943 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0], smp_processor_id()),
57944 + PAGE_SIZE);
57945 +}
57946 +
57947 +char *
57948 +gr_to_filename1(const struct dentry *dentry, const struct vfsmount *mnt)
57949 +{
57950 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[1], smp_processor_id()),
57951 + PAGE_SIZE);
57952 +}
57953 +
57954 +char *
57955 +gr_to_filename2(const struct dentry *dentry, const struct vfsmount *mnt)
57956 +{
57957 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[2], smp_processor_id()),
57958 + PAGE_SIZE);
57959 +}
57960 +
57961 +char *
57962 +gr_to_filename3(const struct dentry *dentry, const struct vfsmount *mnt)
57963 +{
57964 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[3], smp_processor_id()),
57965 + PAGE_SIZE);
57966 +}
57967 +
57968 +__inline__ __u32
57969 +to_gr_audit(const __u32 reqmode)
57970 +{
57971 + /* masks off auditable permission flags, then shifts them to create
57972 + auditing flags, and adds the special case of append auditing if
57973 + we're requesting write */
57974 + return (((reqmode & ~GR_AUDITS) << 10) | ((reqmode & GR_WRITE) ? GR_AUDIT_APPEND : 0));
57975 +}
57976 +
57977 +struct acl_subject_label *
57978 +lookup_subject_map(const struct acl_subject_label *userp)
57979 +{
57980 + unsigned int index = gr_shash(userp, subj_map_set.s_size);
57981 + struct subject_map *match;
57982 +
57983 + match = subj_map_set.s_hash[index];
57984 +
57985 + while (match && match->user != userp)
57986 + match = match->next;
57987 +
57988 + if (match != NULL)
57989 + return match->kernel;
57990 + else
57991 + return NULL;
57992 +}
57993 +
57994 +static void
57995 +insert_subj_map_entry(struct subject_map *subjmap)
57996 +{
57997 + unsigned int index = gr_shash(subjmap->user, subj_map_set.s_size);
57998 + struct subject_map **curr;
57999 +
58000 + subjmap->prev = NULL;
58001 +
58002 + curr = &subj_map_set.s_hash[index];
58003 + if (*curr != NULL)
58004 + (*curr)->prev = subjmap;
58005 +
58006 + subjmap->next = *curr;
58007 + *curr = subjmap;
58008 +
58009 + return;
58010 +}
58011 +
58012 +static struct acl_role_label *
58013 +lookup_acl_role_label(const struct task_struct *task, const uid_t uid,
58014 + const gid_t gid)
58015 +{
58016 + unsigned int index = gr_rhash(uid, GR_ROLE_USER, acl_role_set.r_size);
58017 + struct acl_role_label *match;
58018 + struct role_allowed_ip *ipp;
58019 + unsigned int x;
58020 + u32 curr_ip = task->signal->curr_ip;
58021 +
58022 + task->signal->saved_ip = curr_ip;
58023 +
58024 + match = acl_role_set.r_hash[index];
58025 +
58026 + while (match) {
58027 + if ((match->roletype & (GR_ROLE_DOMAIN | GR_ROLE_USER)) == (GR_ROLE_DOMAIN | GR_ROLE_USER)) {
58028 + for (x = 0; x < match->domain_child_num; x++) {
58029 + if (match->domain_children[x] == uid)
58030 + goto found;
58031 + }
58032 + } else if (match->uidgid == uid && match->roletype & GR_ROLE_USER)
58033 + break;
58034 + match = match->next;
58035 + }
58036 +found:
58037 + if (match == NULL) {
58038 + try_group:
58039 + index = gr_rhash(gid, GR_ROLE_GROUP, acl_role_set.r_size);
58040 + match = acl_role_set.r_hash[index];
58041 +
58042 + while (match) {
58043 + if ((match->roletype & (GR_ROLE_DOMAIN | GR_ROLE_GROUP)) == (GR_ROLE_DOMAIN | GR_ROLE_GROUP)) {
58044 + for (x = 0; x < match->domain_child_num; x++) {
58045 + if (match->domain_children[x] == gid)
58046 + goto found2;
58047 + }
58048 + } else if (match->uidgid == gid && match->roletype & GR_ROLE_GROUP)
58049 + break;
58050 + match = match->next;
58051 + }
58052 +found2:
58053 + if (match == NULL)
58054 + match = default_role;
58055 + if (match->allowed_ips == NULL)
58056 + return match;
58057 + else {
58058 + for (ipp = match->allowed_ips; ipp; ipp = ipp->next) {
58059 + if (likely
58060 + ((ntohl(curr_ip) & ipp->netmask) ==
58061 + (ntohl(ipp->addr) & ipp->netmask)))
58062 + return match;
58063 + }
58064 + match = default_role;
58065 + }
58066 + } else if (match->allowed_ips == NULL) {
58067 + return match;
58068 + } else {
58069 + for (ipp = match->allowed_ips; ipp; ipp = ipp->next) {
58070 + if (likely
58071 + ((ntohl(curr_ip) & ipp->netmask) ==
58072 + (ntohl(ipp->addr) & ipp->netmask)))
58073 + return match;
58074 + }
58075 + goto try_group;
58076 + }
58077 +
58078 + return match;
58079 +}
58080 +
58081 +struct acl_subject_label *
58082 +lookup_acl_subj_label(const ino_t ino, const dev_t dev,
58083 + const struct acl_role_label *role)
58084 +{
58085 + unsigned int index = gr_fhash(ino, dev, role->subj_hash_size);
58086 + struct acl_subject_label *match;
58087 +
58088 + match = role->subj_hash[index];
58089 +
58090 + while (match && (match->inode != ino || match->device != dev ||
58091 + (match->mode & GR_DELETED))) {
58092 + match = match->next;
58093 + }
58094 +
58095 + if (match && !(match->mode & GR_DELETED))
58096 + return match;
58097 + else
58098 + return NULL;
58099 +}
58100 +
58101 +struct acl_subject_label *
58102 +lookup_acl_subj_label_deleted(const ino_t ino, const dev_t dev,
58103 + const struct acl_role_label *role)
58104 +{
58105 + unsigned int index = gr_fhash(ino, dev, role->subj_hash_size);
58106 + struct acl_subject_label *match;
58107 +
58108 + match = role->subj_hash[index];
58109 +
58110 + while (match && (match->inode != ino || match->device != dev ||
58111 + !(match->mode & GR_DELETED))) {
58112 + match = match->next;
58113 + }
58114 +
58115 + if (match && (match->mode & GR_DELETED))
58116 + return match;
58117 + else
58118 + return NULL;
58119 +}
58120 +
58121 +static struct acl_object_label *
58122 +lookup_acl_obj_label(const ino_t ino, const dev_t dev,
58123 + const struct acl_subject_label *subj)
58124 +{
58125 + unsigned int index = gr_fhash(ino, dev, subj->obj_hash_size);
58126 + struct acl_object_label *match;
58127 +
58128 + match = subj->obj_hash[index];
58129 +
58130 + while (match && (match->inode != ino || match->device != dev ||
58131 + (match->mode & GR_DELETED))) {
58132 + match = match->next;
58133 + }
58134 +
58135 + if (match && !(match->mode & GR_DELETED))
58136 + return match;
58137 + else
58138 + return NULL;
58139 +}
58140 +
58141 +static struct acl_object_label *
58142 +lookup_acl_obj_label_create(const ino_t ino, const dev_t dev,
58143 + const struct acl_subject_label *subj)
58144 +{
58145 + unsigned int index = gr_fhash(ino, dev, subj->obj_hash_size);
58146 + struct acl_object_label *match;
58147 +
58148 + match = subj->obj_hash[index];
58149 +
58150 + while (match && (match->inode != ino || match->device != dev ||
58151 + !(match->mode & GR_DELETED))) {
58152 + match = match->next;
58153 + }
58154 +
58155 + if (match && (match->mode & GR_DELETED))
58156 + return match;
58157 +
58158 + match = subj->obj_hash[index];
58159 +
58160 + while (match && (match->inode != ino || match->device != dev ||
58161 + (match->mode & GR_DELETED))) {
58162 + match = match->next;
58163 + }
58164 +
58165 + if (match && !(match->mode & GR_DELETED))
58166 + return match;
58167 + else
58168 + return NULL;
58169 +}
58170 +
58171 +static struct name_entry *
58172 +lookup_name_entry(const char *name)
58173 +{
58174 + unsigned int len = strlen(name);
58175 + unsigned int key = full_name_hash(name, len);
58176 + unsigned int index = key % name_set.n_size;
58177 + struct name_entry *match;
58178 +
58179 + match = name_set.n_hash[index];
58180 +
58181 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len)))
58182 + match = match->next;
58183 +
58184 + return match;
58185 +}
58186 +
58187 +static struct name_entry *
58188 +lookup_name_entry_create(const char *name)
58189 +{
58190 + unsigned int len = strlen(name);
58191 + unsigned int key = full_name_hash(name, len);
58192 + unsigned int index = key % name_set.n_size;
58193 + struct name_entry *match;
58194 +
58195 + match = name_set.n_hash[index];
58196 +
58197 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len) ||
58198 + !match->deleted))
58199 + match = match->next;
58200 +
58201 + if (match && match->deleted)
58202 + return match;
58203 +
58204 + match = name_set.n_hash[index];
58205 +
58206 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len) ||
58207 + match->deleted))
58208 + match = match->next;
58209 +
58210 + if (match && !match->deleted)
58211 + return match;
58212 + else
58213 + return NULL;
58214 +}
58215 +
58216 +static struct inodev_entry *
58217 +lookup_inodev_entry(const ino_t ino, const dev_t dev)
58218 +{
58219 + unsigned int index = gr_fhash(ino, dev, inodev_set.i_size);
58220 + struct inodev_entry *match;
58221 +
58222 + match = inodev_set.i_hash[index];
58223 +
58224 + while (match && (match->nentry->inode != ino || match->nentry->device != dev))
58225 + match = match->next;
58226 +
58227 + return match;
58228 +}
58229 +
58230 +static void
58231 +insert_inodev_entry(struct inodev_entry *entry)
58232 +{
58233 + unsigned int index = gr_fhash(entry->nentry->inode, entry->nentry->device,
58234 + inodev_set.i_size);
58235 + struct inodev_entry **curr;
58236 +
58237 + entry->prev = NULL;
58238 +
58239 + curr = &inodev_set.i_hash[index];
58240 + if (*curr != NULL)
58241 + (*curr)->prev = entry;
58242 +
58243 + entry->next = *curr;
58244 + *curr = entry;
58245 +
58246 + return;
58247 +}
58248 +
58249 +static void
58250 +__insert_acl_role_label(struct acl_role_label *role, uid_t uidgid)
58251 +{
58252 + unsigned int index =
58253 + gr_rhash(uidgid, role->roletype & (GR_ROLE_USER | GR_ROLE_GROUP), acl_role_set.r_size);
58254 + struct acl_role_label **curr;
58255 + struct acl_role_label *tmp, *tmp2;
58256 +
58257 + curr = &acl_role_set.r_hash[index];
58258 +
58259 + /* simple case, slot is empty, just set it to our role */
58260 + if (*curr == NULL) {
58261 + *curr = role;
58262 + } else {
58263 + /* example:
58264 + 1 -> 2 -> 3 (adding 2 -> 3 to here)
58265 + 2 -> 3
58266 + */
58267 + /* first check to see if we can already be reached via this slot */
58268 + tmp = *curr;
58269 + while (tmp && tmp != role)
58270 + tmp = tmp->next;
58271 + if (tmp == role) {
58272 + /* we don't need to add ourselves to this slot's chain */
58273 + return;
58274 + }
58275 + /* we need to add ourselves to this chain, two cases */
58276 + if (role->next == NULL) {
58277 + /* simple case, append the current chain to our role */
58278 + role->next = *curr;
58279 + *curr = role;
58280 + } else {
58281 + /* 1 -> 2 -> 3 -> 4
58282 + 2 -> 3 -> 4
58283 + 3 -> 4 (adding 1 -> 2 -> 3 -> 4 to here)
58284 + */
58285 + /* trickier case: walk our role's chain until we find
58286 + the role for the start of the current slot's chain */
58287 + tmp = role;
58288 + tmp2 = *curr;
58289 + while (tmp->next && tmp->next != tmp2)
58290 + tmp = tmp->next;
58291 + if (tmp->next == tmp2) {
58292 + /* from example above, we found 3, so just
58293 + replace this slot's chain with ours */
58294 + *curr = role;
58295 + } else {
58296 + /* we didn't find a subset of our role's chain
58297 + in the current slot's chain, so append their
58298 + chain to ours, and set us as the first role in
58299 + the slot's chain
58300 +
58301 + we could fold this case with the case above,
58302 + but making it explicit for clarity
58303 + */
58304 + tmp->next = tmp2;
58305 + *curr = role;
58306 + }
58307 + }
58308 + }
58309 +
58310 + return;
58311 +}
58312 +
58313 +static void
58314 +insert_acl_role_label(struct acl_role_label *role)
58315 +{
58316 + int i;
58317 +
58318 + if (role_list == NULL) {
58319 + role_list = role;
58320 + role->prev = NULL;
58321 + } else {
58322 + role->prev = role_list;
58323 + role_list = role;
58324 + }
58325 +
58326 + /* used for hash chains */
58327 + role->next = NULL;
58328 +
58329 + if (role->roletype & GR_ROLE_DOMAIN) {
58330 + for (i = 0; i < role->domain_child_num; i++)
58331 + __insert_acl_role_label(role, role->domain_children[i]);
58332 + } else
58333 + __insert_acl_role_label(role, role->uidgid);
58334 +}
58335 +
58336 +static int
58337 +insert_name_entry(char *name, const ino_t inode, const dev_t device, __u8 deleted)
58338 +{
58339 + struct name_entry **curr, *nentry;
58340 + struct inodev_entry *ientry;
58341 + unsigned int len = strlen(name);
58342 + unsigned int key = full_name_hash(name, len);
58343 + unsigned int index = key % name_set.n_size;
58344 +
58345 + curr = &name_set.n_hash[index];
58346 +
58347 + while (*curr && ((*curr)->key != key || !gr_streq((*curr)->name, name, (*curr)->len, len)))
58348 + curr = &((*curr)->next);
58349 +
58350 + if (*curr != NULL)
58351 + return 1;
58352 +
58353 + nentry = acl_alloc(sizeof (struct name_entry));
58354 + if (nentry == NULL)
58355 + return 0;
58356 + ientry = acl_alloc(sizeof (struct inodev_entry));
58357 + if (ientry == NULL)
58358 + return 0;
58359 + ientry->nentry = nentry;
58360 +
58361 + nentry->key = key;
58362 + nentry->name = name;
58363 + nentry->inode = inode;
58364 + nentry->device = device;
58365 + nentry->len = len;
58366 + nentry->deleted = deleted;
58367 +
58368 + nentry->prev = NULL;
58369 + curr = &name_set.n_hash[index];
58370 + if (*curr != NULL)
58371 + (*curr)->prev = nentry;
58372 + nentry->next = *curr;
58373 + *curr = nentry;
58374 +
58375 + /* insert us into the table searchable by inode/dev */
58376 + insert_inodev_entry(ientry);
58377 +
58378 + return 1;
58379 +}
58380 +
58381 +static void
58382 +insert_acl_obj_label(struct acl_object_label *obj,
58383 + struct acl_subject_label *subj)
58384 +{
58385 + unsigned int index =
58386 + gr_fhash(obj->inode, obj->device, subj->obj_hash_size);
58387 + struct acl_object_label **curr;
58388 +
58389 +
58390 + obj->prev = NULL;
58391 +
58392 + curr = &subj->obj_hash[index];
58393 + if (*curr != NULL)
58394 + (*curr)->prev = obj;
58395 +
58396 + obj->next = *curr;
58397 + *curr = obj;
58398 +
58399 + return;
58400 +}
58401 +
58402 +static void
58403 +insert_acl_subj_label(struct acl_subject_label *obj,
58404 + struct acl_role_label *role)
58405 +{
58406 + unsigned int index = gr_fhash(obj->inode, obj->device, role->subj_hash_size);
58407 + struct acl_subject_label **curr;
58408 +
58409 + obj->prev = NULL;
58410 +
58411 + curr = &role->subj_hash[index];
58412 + if (*curr != NULL)
58413 + (*curr)->prev = obj;
58414 +
58415 + obj->next = *curr;
58416 + *curr = obj;
58417 +
58418 + return;
58419 +}
58420 +
58421 +/* allocating chained hash tables, so optimal size is where lambda ~ 1 */
58422 +
58423 +static void *
58424 +create_table(__u32 * len, int elementsize)
58425 +{
58426 + unsigned int table_sizes[] = {
58427 + 7, 13, 31, 61, 127, 251, 509, 1021, 2039, 4093, 8191, 16381,
58428 + 32749, 65521, 131071, 262139, 524287, 1048573, 2097143,
58429 + 4194301, 8388593, 16777213, 33554393, 67108859
58430 + };
58431 + void *newtable = NULL;
58432 + unsigned int pwr = 0;
58433 +
58434 + while ((pwr < ((sizeof (table_sizes) / sizeof (table_sizes[0])) - 1)) &&
58435 + table_sizes[pwr] <= *len)
58436 + pwr++;
58437 +
58438 + if (table_sizes[pwr] <= *len || (table_sizes[pwr] > ULONG_MAX / elementsize))
58439 + return newtable;
58440 +
58441 + if ((table_sizes[pwr] * elementsize) <= PAGE_SIZE)
58442 + newtable =
58443 + kmalloc(table_sizes[pwr] * elementsize, GFP_KERNEL);
58444 + else
58445 + newtable = vmalloc(table_sizes[pwr] * elementsize);
58446 +
58447 + *len = table_sizes[pwr];
58448 +
58449 + return newtable;
58450 +}
58451 +
58452 +static int
58453 +init_variables(const struct gr_arg *arg)
58454 +{
58455 + struct task_struct *reaper = init_pid_ns.child_reaper;
58456 + unsigned int stacksize;
58457 +
58458 + subj_map_set.s_size = arg->role_db.num_subjects;
58459 + acl_role_set.r_size = arg->role_db.num_roles + arg->role_db.num_domain_children;
58460 + name_set.n_size = arg->role_db.num_objects;
58461 + inodev_set.i_size = arg->role_db.num_objects;
58462 +
58463 + if (!subj_map_set.s_size || !acl_role_set.r_size ||
58464 + !name_set.n_size || !inodev_set.i_size)
58465 + return 1;
58466 +
58467 + if (!gr_init_uidset())
58468 + return 1;
58469 +
58470 + /* set up the stack that holds allocation info */
58471 +
58472 + stacksize = arg->role_db.num_pointers + 5;
58473 +
58474 + if (!acl_alloc_stack_init(stacksize))
58475 + return 1;
58476 +
58477 + /* grab reference for the real root dentry and vfsmount */
58478 + get_fs_root(reaper->fs, &real_root);
58479 +
58480 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
58481 + printk(KERN_ALERT "Obtained real root device=%d, inode=%lu\n", __get_dev(real_root.dentry), real_root.dentry->d_inode->i_ino);
58482 +#endif
58483 +
58484 + fakefs_obj_rw = acl_alloc(sizeof(struct acl_object_label));
58485 + if (fakefs_obj_rw == NULL)
58486 + return 1;
58487 + fakefs_obj_rw->mode = GR_FIND | GR_READ | GR_WRITE;
58488 +
58489 + fakefs_obj_rwx = acl_alloc(sizeof(struct acl_object_label));
58490 + if (fakefs_obj_rwx == NULL)
58491 + return 1;
58492 + fakefs_obj_rwx->mode = GR_FIND | GR_READ | GR_WRITE | GR_EXEC;
58493 +
58494 + subj_map_set.s_hash =
58495 + (struct subject_map **) create_table(&subj_map_set.s_size, sizeof(void *));
58496 + acl_role_set.r_hash =
58497 + (struct acl_role_label **) create_table(&acl_role_set.r_size, sizeof(void *));
58498 + name_set.n_hash = (struct name_entry **) create_table(&name_set.n_size, sizeof(void *));
58499 + inodev_set.i_hash =
58500 + (struct inodev_entry **) create_table(&inodev_set.i_size, sizeof(void *));
58501 +
58502 + if (!subj_map_set.s_hash || !acl_role_set.r_hash ||
58503 + !name_set.n_hash || !inodev_set.i_hash)
58504 + return 1;
58505 +
58506 + memset(subj_map_set.s_hash, 0,
58507 + sizeof(struct subject_map *) * subj_map_set.s_size);
58508 + memset(acl_role_set.r_hash, 0,
58509 + sizeof (struct acl_role_label *) * acl_role_set.r_size);
58510 + memset(name_set.n_hash, 0,
58511 + sizeof (struct name_entry *) * name_set.n_size);
58512 + memset(inodev_set.i_hash, 0,
58513 + sizeof (struct inodev_entry *) * inodev_set.i_size);
58514 +
58515 + return 0;
58516 +}
58517 +
58518 +/* free information not needed after startup
58519 + currently contains user->kernel pointer mappings for subjects
58520 +*/
58521 +
58522 +static void
58523 +free_init_variables(void)
58524 +{
58525 + __u32 i;
58526 +
58527 + if (subj_map_set.s_hash) {
58528 + for (i = 0; i < subj_map_set.s_size; i++) {
58529 + if (subj_map_set.s_hash[i]) {
58530 + kfree(subj_map_set.s_hash[i]);
58531 + subj_map_set.s_hash[i] = NULL;
58532 + }
58533 + }
58534 +
58535 + if ((subj_map_set.s_size * sizeof (struct subject_map *)) <=
58536 + PAGE_SIZE)
58537 + kfree(subj_map_set.s_hash);
58538 + else
58539 + vfree(subj_map_set.s_hash);
58540 + }
58541 +
58542 + return;
58543 +}
58544 +
58545 +static void
58546 +free_variables(void)
58547 +{
58548 + struct acl_subject_label *s;
58549 + struct acl_role_label *r;
58550 + struct task_struct *task, *task2;
58551 + unsigned int x;
58552 +
58553 + gr_clear_learn_entries();
58554 +
58555 + read_lock(&tasklist_lock);
58556 + do_each_thread(task2, task) {
58557 + task->acl_sp_role = 0;
58558 + task->acl_role_id = 0;
58559 + task->acl = NULL;
58560 + task->role = NULL;
58561 + } while_each_thread(task2, task);
58562 + read_unlock(&tasklist_lock);
58563 +
58564 + /* release the reference to the real root dentry and vfsmount */
58565 + path_put(&real_root);
58566 + memset(&real_root, 0, sizeof(real_root));
58567 +
58568 + /* free all object hash tables */
58569 +
58570 + FOR_EACH_ROLE_START(r)
58571 + if (r->subj_hash == NULL)
58572 + goto next_role;
58573 + FOR_EACH_SUBJECT_START(r, s, x)
58574 + if (s->obj_hash == NULL)
58575 + break;
58576 + if ((s->obj_hash_size * sizeof (struct acl_object_label *)) <= PAGE_SIZE)
58577 + kfree(s->obj_hash);
58578 + else
58579 + vfree(s->obj_hash);
58580 + FOR_EACH_SUBJECT_END(s, x)
58581 + FOR_EACH_NESTED_SUBJECT_START(r, s)
58582 + if (s->obj_hash == NULL)
58583 + break;
58584 + if ((s->obj_hash_size * sizeof (struct acl_object_label *)) <= PAGE_SIZE)
58585 + kfree(s->obj_hash);
58586 + else
58587 + vfree(s->obj_hash);
58588 + FOR_EACH_NESTED_SUBJECT_END(s)
58589 + if ((r->subj_hash_size * sizeof (struct acl_subject_label *)) <= PAGE_SIZE)
58590 + kfree(r->subj_hash);
58591 + else
58592 + vfree(r->subj_hash);
58593 + r->subj_hash = NULL;
58594 +next_role:
58595 + FOR_EACH_ROLE_END(r)
58596 +
58597 + acl_free_all();
58598 +
58599 + if (acl_role_set.r_hash) {
58600 + if ((acl_role_set.r_size * sizeof (struct acl_role_label *)) <=
58601 + PAGE_SIZE)
58602 + kfree(acl_role_set.r_hash);
58603 + else
58604 + vfree(acl_role_set.r_hash);
58605 + }
58606 + if (name_set.n_hash) {
58607 + if ((name_set.n_size * sizeof (struct name_entry *)) <=
58608 + PAGE_SIZE)
58609 + kfree(name_set.n_hash);
58610 + else
58611 + vfree(name_set.n_hash);
58612 + }
58613 +
58614 + if (inodev_set.i_hash) {
58615 + if ((inodev_set.i_size * sizeof (struct inodev_entry *)) <=
58616 + PAGE_SIZE)
58617 + kfree(inodev_set.i_hash);
58618 + else
58619 + vfree(inodev_set.i_hash);
58620 + }
58621 +
58622 + gr_free_uidset();
58623 +
58624 + memset(&name_set, 0, sizeof (struct name_db));
58625 + memset(&inodev_set, 0, sizeof (struct inodev_db));
58626 + memset(&acl_role_set, 0, sizeof (struct acl_role_db));
58627 + memset(&subj_map_set, 0, sizeof (struct acl_subj_map_db));
58628 +
58629 + default_role = NULL;
58630 + kernel_role = NULL;
58631 + role_list = NULL;
58632 +
58633 + return;
58634 +}
58635 +
58636 +static __u32
58637 +count_user_objs(struct acl_object_label *userp)
58638 +{
58639 + struct acl_object_label o_tmp;
58640 + __u32 num = 0;
58641 +
58642 + while (userp) {
58643 + if (copy_from_user(&o_tmp, userp,
58644 + sizeof (struct acl_object_label)))
58645 + break;
58646 +
58647 + userp = o_tmp.prev;
58648 + num++;
58649 + }
58650 +
58651 + return num;
58652 +}
58653 +
58654 +static struct acl_subject_label *
58655 +do_copy_user_subj(struct acl_subject_label *userp, struct acl_role_label *role, int *already_copied);
58656 +
58657 +static int
58658 +copy_user_glob(struct acl_object_label *obj)
58659 +{
58660 + struct acl_object_label *g_tmp, **guser;
58661 + unsigned int len;
58662 + char *tmp;
58663 +
58664 + if (obj->globbed == NULL)
58665 + return 0;
58666 +
58667 + guser = &obj->globbed;
58668 + while (*guser) {
58669 + g_tmp = (struct acl_object_label *)
58670 + acl_alloc(sizeof (struct acl_object_label));
58671 + if (g_tmp == NULL)
58672 + return -ENOMEM;
58673 +
58674 + if (copy_from_user(g_tmp, *guser,
58675 + sizeof (struct acl_object_label)))
58676 + return -EFAULT;
58677 +
58678 + len = strnlen_user(g_tmp->filename, PATH_MAX);
58679 +
58680 + if (!len || len >= PATH_MAX)
58681 + return -EINVAL;
58682 +
58683 + if ((tmp = (char *) acl_alloc(len)) == NULL)
58684 + return -ENOMEM;
58685 +
58686 + if (copy_from_user(tmp, g_tmp->filename, len))
58687 + return -EFAULT;
58688 + tmp[len-1] = '\0';
58689 + g_tmp->filename = tmp;
58690 +
58691 + *guser = g_tmp;
58692 + guser = &(g_tmp->next);
58693 + }
58694 +
58695 + return 0;
58696 +}
58697 +
58698 +static int
58699 +copy_user_objs(struct acl_object_label *userp, struct acl_subject_label *subj,
58700 + struct acl_role_label *role)
58701 +{
58702 + struct acl_object_label *o_tmp;
58703 + unsigned int len;
58704 + int ret;
58705 + char *tmp;
58706 +
58707 + while (userp) {
58708 + if ((o_tmp = (struct acl_object_label *)
58709 + acl_alloc(sizeof (struct acl_object_label))) == NULL)
58710 + return -ENOMEM;
58711 +
58712 + if (copy_from_user(o_tmp, userp,
58713 + sizeof (struct acl_object_label)))
58714 + return -EFAULT;
58715 +
58716 + userp = o_tmp->prev;
58717 +
58718 + len = strnlen_user(o_tmp->filename, PATH_MAX);
58719 +
58720 + if (!len || len >= PATH_MAX)
58721 + return -EINVAL;
58722 +
58723 + if ((tmp = (char *) acl_alloc(len)) == NULL)
58724 + return -ENOMEM;
58725 +
58726 + if (copy_from_user(tmp, o_tmp->filename, len))
58727 + return -EFAULT;
58728 + tmp[len-1] = '\0';
58729 + o_tmp->filename = tmp;
58730 +
58731 + insert_acl_obj_label(o_tmp, subj);
58732 + if (!insert_name_entry(o_tmp->filename, o_tmp->inode,
58733 + o_tmp->device, (o_tmp->mode & GR_DELETED) ? 1 : 0))
58734 + return -ENOMEM;
58735 +
58736 + ret = copy_user_glob(o_tmp);
58737 + if (ret)
58738 + return ret;
58739 +
58740 + if (o_tmp->nested) {
58741 + int already_copied;
58742 +
58743 + o_tmp->nested = do_copy_user_subj(o_tmp->nested, role, &already_copied);
58744 + if (IS_ERR(o_tmp->nested))
58745 + return PTR_ERR(o_tmp->nested);
58746 +
58747 + /* insert into nested subject list if we haven't copied this one yet
58748 + to prevent duplicate entries */
58749 + if (!already_copied) {
58750 + o_tmp->nested->next = role->hash->first;
58751 + role->hash->first = o_tmp->nested;
58752 + }
58753 + }
58754 + }
58755 +
58756 + return 0;
58757 +}
58758 +
58759 +static __u32
58760 +count_user_subjs(struct acl_subject_label *userp)
58761 +{
58762 + struct acl_subject_label s_tmp;
58763 + __u32 num = 0;
58764 +
58765 + while (userp) {
58766 + if (copy_from_user(&s_tmp, userp,
58767 + sizeof (struct acl_subject_label)))
58768 + break;
58769 +
58770 + userp = s_tmp.prev;
58771 + }
58772 +
58773 + return num;
58774 +}
58775 +
58776 +static int
58777 +copy_user_allowedips(struct acl_role_label *rolep)
58778 +{
58779 + struct role_allowed_ip *ruserip, *rtmp = NULL, *rlast;
58780 +
58781 + ruserip = rolep->allowed_ips;
58782 +
58783 + while (ruserip) {
58784 + rlast = rtmp;
58785 +
58786 + if ((rtmp = (struct role_allowed_ip *)
58787 + acl_alloc(sizeof (struct role_allowed_ip))) == NULL)
58788 + return -ENOMEM;
58789 +
58790 + if (copy_from_user(rtmp, ruserip,
58791 + sizeof (struct role_allowed_ip)))
58792 + return -EFAULT;
58793 +
58794 + ruserip = rtmp->prev;
58795 +
58796 + if (!rlast) {
58797 + rtmp->prev = NULL;
58798 + rolep->allowed_ips = rtmp;
58799 + } else {
58800 + rlast->next = rtmp;
58801 + rtmp->prev = rlast;
58802 + }
58803 +
58804 + if (!ruserip)
58805 + rtmp->next = NULL;
58806 + }
58807 +
58808 + return 0;
58809 +}
58810 +
58811 +static int
58812 +copy_user_transitions(struct acl_role_label *rolep)
58813 +{
58814 + struct role_transition *rusertp, *rtmp = NULL, *rlast;
58815 +
58816 + unsigned int len;
58817 + char *tmp;
58818 +
58819 + rusertp = rolep->transitions;
58820 +
58821 + while (rusertp) {
58822 + rlast = rtmp;
58823 +
58824 + if ((rtmp = (struct role_transition *)
58825 + acl_alloc(sizeof (struct role_transition))) == NULL)
58826 + return -ENOMEM;
58827 +
58828 + if (copy_from_user(rtmp, rusertp,
58829 + sizeof (struct role_transition)))
58830 + return -EFAULT;
58831 +
58832 + rusertp = rtmp->prev;
58833 +
58834 + len = strnlen_user(rtmp->rolename, GR_SPROLE_LEN);
58835 +
58836 + if (!len || len >= GR_SPROLE_LEN)
58837 + return -EINVAL;
58838 +
58839 + if ((tmp = (char *) acl_alloc(len)) == NULL)
58840 + return -ENOMEM;
58841 +
58842 + if (copy_from_user(tmp, rtmp->rolename, len))
58843 + return -EFAULT;
58844 + tmp[len-1] = '\0';
58845 + rtmp->rolename = tmp;
58846 +
58847 + if (!rlast) {
58848 + rtmp->prev = NULL;
58849 + rolep->transitions = rtmp;
58850 + } else {
58851 + rlast->next = rtmp;
58852 + rtmp->prev = rlast;
58853 + }
58854 +
58855 + if (!rusertp)
58856 + rtmp->next = NULL;
58857 + }
58858 +
58859 + return 0;
58860 +}
58861 +
58862 +static struct acl_subject_label *
58863 +do_copy_user_subj(struct acl_subject_label *userp, struct acl_role_label *role, int *already_copied)
58864 +{
58865 + struct acl_subject_label *s_tmp = NULL, *s_tmp2;
58866 + unsigned int len;
58867 + char *tmp;
58868 + __u32 num_objs;
58869 + struct acl_ip_label **i_tmp, *i_utmp2;
58870 + struct gr_hash_struct ghash;
58871 + struct subject_map *subjmap;
58872 + unsigned int i_num;
58873 + int err;
58874 +
58875 + if (already_copied != NULL)
58876 + *already_copied = 0;
58877 +
58878 + s_tmp = lookup_subject_map(userp);
58879 +
58880 + /* we've already copied this subject into the kernel, just return
58881 + the reference to it, and don't copy it over again
58882 + */
58883 + if (s_tmp) {
58884 + if (already_copied != NULL)
58885 + *already_copied = 1;
58886 + return(s_tmp);
58887 + }
58888 +
58889 + if ((s_tmp = (struct acl_subject_label *)
58890 + acl_alloc(sizeof (struct acl_subject_label))) == NULL)
58891 + return ERR_PTR(-ENOMEM);
58892 +
58893 + subjmap = (struct subject_map *)kmalloc(sizeof (struct subject_map), GFP_KERNEL);
58894 + if (subjmap == NULL)
58895 + return ERR_PTR(-ENOMEM);
58896 +
58897 + subjmap->user = userp;
58898 + subjmap->kernel = s_tmp;
58899 + insert_subj_map_entry(subjmap);
58900 +
58901 + if (copy_from_user(s_tmp, userp,
58902 + sizeof (struct acl_subject_label)))
58903 + return ERR_PTR(-EFAULT);
58904 +
58905 + len = strnlen_user(s_tmp->filename, PATH_MAX);
58906 +
58907 + if (!len || len >= PATH_MAX)
58908 + return ERR_PTR(-EINVAL);
58909 +
58910 + if ((tmp = (char *) acl_alloc(len)) == NULL)
58911 + return ERR_PTR(-ENOMEM);
58912 +
58913 + if (copy_from_user(tmp, s_tmp->filename, len))
58914 + return ERR_PTR(-EFAULT);
58915 + tmp[len-1] = '\0';
58916 + s_tmp->filename = tmp;
58917 +
58918 + if (!strcmp(s_tmp->filename, "/"))
58919 + role->root_label = s_tmp;
58920 +
58921 + if (copy_from_user(&ghash, s_tmp->hash, sizeof(struct gr_hash_struct)))
58922 + return ERR_PTR(-EFAULT);
58923 +
58924 + /* copy user and group transition tables */
58925 +
58926 + if (s_tmp->user_trans_num) {
58927 + uid_t *uidlist;
58928 +
58929 + uidlist = (uid_t *)acl_alloc_num(s_tmp->user_trans_num, sizeof(uid_t));
58930 + if (uidlist == NULL)
58931 + return ERR_PTR(-ENOMEM);
58932 + if (copy_from_user(uidlist, s_tmp->user_transitions, s_tmp->user_trans_num * sizeof(uid_t)))
58933 + return ERR_PTR(-EFAULT);
58934 +
58935 + s_tmp->user_transitions = uidlist;
58936 + }
58937 +
58938 + if (s_tmp->group_trans_num) {
58939 + gid_t *gidlist;
58940 +
58941 + gidlist = (gid_t *)acl_alloc_num(s_tmp->group_trans_num, sizeof(gid_t));
58942 + if (gidlist == NULL)
58943 + return ERR_PTR(-ENOMEM);
58944 + if (copy_from_user(gidlist, s_tmp->group_transitions, s_tmp->group_trans_num * sizeof(gid_t)))
58945 + return ERR_PTR(-EFAULT);
58946 +
58947 + s_tmp->group_transitions = gidlist;
58948 + }
58949 +
58950 + /* set up object hash table */
58951 + num_objs = count_user_objs(ghash.first);
58952 +
58953 + s_tmp->obj_hash_size = num_objs;
58954 + s_tmp->obj_hash =
58955 + (struct acl_object_label **)
58956 + create_table(&(s_tmp->obj_hash_size), sizeof(void *));
58957 +
58958 + if (!s_tmp->obj_hash)
58959 + return ERR_PTR(-ENOMEM);
58960 +
58961 + memset(s_tmp->obj_hash, 0,
58962 + s_tmp->obj_hash_size *
58963 + sizeof (struct acl_object_label *));
58964 +
58965 + /* add in objects */
58966 + err = copy_user_objs(ghash.first, s_tmp, role);
58967 +
58968 + if (err)
58969 + return ERR_PTR(err);
58970 +
58971 + /* set pointer for parent subject */
58972 + if (s_tmp->parent_subject) {
58973 + s_tmp2 = do_copy_user_subj(s_tmp->parent_subject, role, NULL);
58974 +
58975 + if (IS_ERR(s_tmp2))
58976 + return s_tmp2;
58977 +
58978 + s_tmp->parent_subject = s_tmp2;
58979 + }
58980 +
58981 + /* add in ip acls */
58982 +
58983 + if (!s_tmp->ip_num) {
58984 + s_tmp->ips = NULL;
58985 + goto insert;
58986 + }
58987 +
58988 + i_tmp =
58989 + (struct acl_ip_label **) acl_alloc_num(s_tmp->ip_num,
58990 + sizeof (struct acl_ip_label *));
58991 +
58992 + if (!i_tmp)
58993 + return ERR_PTR(-ENOMEM);
58994 +
58995 + for (i_num = 0; i_num < s_tmp->ip_num; i_num++) {
58996 + *(i_tmp + i_num) =
58997 + (struct acl_ip_label *)
58998 + acl_alloc(sizeof (struct acl_ip_label));
58999 + if (!*(i_tmp + i_num))
59000 + return ERR_PTR(-ENOMEM);
59001 +
59002 + if (copy_from_user
59003 + (&i_utmp2, s_tmp->ips + i_num,
59004 + sizeof (struct acl_ip_label *)))
59005 + return ERR_PTR(-EFAULT);
59006 +
59007 + if (copy_from_user
59008 + (*(i_tmp + i_num), i_utmp2,
59009 + sizeof (struct acl_ip_label)))
59010 + return ERR_PTR(-EFAULT);
59011 +
59012 + if ((*(i_tmp + i_num))->iface == NULL)
59013 + continue;
59014 +
59015 + len = strnlen_user((*(i_tmp + i_num))->iface, IFNAMSIZ);
59016 + if (!len || len >= IFNAMSIZ)
59017 + return ERR_PTR(-EINVAL);
59018 + tmp = acl_alloc(len);
59019 + if (tmp == NULL)
59020 + return ERR_PTR(-ENOMEM);
59021 + if (copy_from_user(tmp, (*(i_tmp + i_num))->iface, len))
59022 + return ERR_PTR(-EFAULT);
59023 + (*(i_tmp + i_num))->iface = tmp;
59024 + }
59025 +
59026 + s_tmp->ips = i_tmp;
59027 +
59028 +insert:
59029 + if (!insert_name_entry(s_tmp->filename, s_tmp->inode,
59030 + s_tmp->device, (s_tmp->mode & GR_DELETED) ? 1 : 0))
59031 + return ERR_PTR(-ENOMEM);
59032 +
59033 + return s_tmp;
59034 +}
59035 +
59036 +static int
59037 +copy_user_subjs(struct acl_subject_label *userp, struct acl_role_label *role)
59038 +{
59039 + struct acl_subject_label s_pre;
59040 + struct acl_subject_label * ret;
59041 + int err;
59042 +
59043 + while (userp) {
59044 + if (copy_from_user(&s_pre, userp,
59045 + sizeof (struct acl_subject_label)))
59046 + return -EFAULT;
59047 +
59048 + ret = do_copy_user_subj(userp, role, NULL);
59049 +
59050 + err = PTR_ERR(ret);
59051 + if (IS_ERR(ret))
59052 + return err;
59053 +
59054 + insert_acl_subj_label(ret, role);
59055 +
59056 + userp = s_pre.prev;
59057 + }
59058 +
59059 + return 0;
59060 +}
59061 +
59062 +static int
59063 +copy_user_acl(struct gr_arg *arg)
59064 +{
59065 + struct acl_role_label *r_tmp = NULL, **r_utmp, *r_utmp2;
59066 + struct acl_subject_label *subj_list;
59067 + struct sprole_pw *sptmp;
59068 + struct gr_hash_struct *ghash;
59069 + uid_t *domainlist;
59070 + unsigned int r_num;
59071 + unsigned int len;
59072 + char *tmp;
59073 + int err = 0;
59074 + __u16 i;
59075 + __u32 num_subjs;
59076 +
59077 + /* we need a default and kernel role */
59078 + if (arg->role_db.num_roles < 2)
59079 + return -EINVAL;
59080 +
59081 + /* copy special role authentication info from userspace */
59082 +
59083 + num_sprole_pws = arg->num_sprole_pws;
59084 + acl_special_roles = (struct sprole_pw **) acl_alloc_num(num_sprole_pws, sizeof(struct sprole_pw *));
59085 +
59086 + if (!acl_special_roles && num_sprole_pws)
59087 + return -ENOMEM;
59088 +
59089 + for (i = 0; i < num_sprole_pws; i++) {
59090 + sptmp = (struct sprole_pw *) acl_alloc(sizeof(struct sprole_pw));
59091 + if (!sptmp)
59092 + return -ENOMEM;
59093 + if (copy_from_user(sptmp, arg->sprole_pws + i,
59094 + sizeof (struct sprole_pw)))
59095 + return -EFAULT;
59096 +
59097 + len = strnlen_user(sptmp->rolename, GR_SPROLE_LEN);
59098 +
59099 + if (!len || len >= GR_SPROLE_LEN)
59100 + return -EINVAL;
59101 +
59102 + if ((tmp = (char *) acl_alloc(len)) == NULL)
59103 + return -ENOMEM;
59104 +
59105 + if (copy_from_user(tmp, sptmp->rolename, len))
59106 + return -EFAULT;
59107 +
59108 + tmp[len-1] = '\0';
59109 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
59110 + printk(KERN_ALERT "Copying special role %s\n", tmp);
59111 +#endif
59112 + sptmp->rolename = tmp;
59113 + acl_special_roles[i] = sptmp;
59114 + }
59115 +
59116 + r_utmp = (struct acl_role_label **) arg->role_db.r_table;
59117 +
59118 + for (r_num = 0; r_num < arg->role_db.num_roles; r_num++) {
59119 + r_tmp = acl_alloc(sizeof (struct acl_role_label));
59120 +
59121 + if (!r_tmp)
59122 + return -ENOMEM;
59123 +
59124 + if (copy_from_user(&r_utmp2, r_utmp + r_num,
59125 + sizeof (struct acl_role_label *)))
59126 + return -EFAULT;
59127 +
59128 + if (copy_from_user(r_tmp, r_utmp2,
59129 + sizeof (struct acl_role_label)))
59130 + return -EFAULT;
59131 +
59132 + len = strnlen_user(r_tmp->rolename, GR_SPROLE_LEN);
59133 +
59134 + if (!len || len >= PATH_MAX)
59135 + return -EINVAL;
59136 +
59137 + if ((tmp = (char *) acl_alloc(len)) == NULL)
59138 + return -ENOMEM;
59139 +
59140 + if (copy_from_user(tmp, r_tmp->rolename, len))
59141 + return -EFAULT;
59142 +
59143 + tmp[len-1] = '\0';
59144 + r_tmp->rolename = tmp;
59145 +
59146 + if (!strcmp(r_tmp->rolename, "default")
59147 + && (r_tmp->roletype & GR_ROLE_DEFAULT)) {
59148 + default_role = r_tmp;
59149 + } else if (!strcmp(r_tmp->rolename, ":::kernel:::")) {
59150 + kernel_role = r_tmp;
59151 + }
59152 +
59153 + if ((ghash = (struct gr_hash_struct *) acl_alloc(sizeof(struct gr_hash_struct))) == NULL)
59154 + return -ENOMEM;
59155 +
59156 + if (copy_from_user(ghash, r_tmp->hash, sizeof(struct gr_hash_struct)))
59157 + return -EFAULT;
59158 +
59159 + r_tmp->hash = ghash;
59160 +
59161 + num_subjs = count_user_subjs(r_tmp->hash->first);
59162 +
59163 + r_tmp->subj_hash_size = num_subjs;
59164 + r_tmp->subj_hash =
59165 + (struct acl_subject_label **)
59166 + create_table(&(r_tmp->subj_hash_size), sizeof(void *));
59167 +
59168 + if (!r_tmp->subj_hash)
59169 + return -ENOMEM;
59170 +
59171 + err = copy_user_allowedips(r_tmp);
59172 + if (err)
59173 + return err;
59174 +
59175 + /* copy domain info */
59176 + if (r_tmp->domain_children != NULL) {
59177 + domainlist = acl_alloc_num(r_tmp->domain_child_num, sizeof(uid_t));
59178 + if (domainlist == NULL)
59179 + return -ENOMEM;
59180 +
59181 + if (copy_from_user(domainlist, r_tmp->domain_children, r_tmp->domain_child_num * sizeof(uid_t)))
59182 + return -EFAULT;
59183 +
59184 + r_tmp->domain_children = domainlist;
59185 + }
59186 +
59187 + err = copy_user_transitions(r_tmp);
59188 + if (err)
59189 + return err;
59190 +
59191 + memset(r_tmp->subj_hash, 0,
59192 + r_tmp->subj_hash_size *
59193 + sizeof (struct acl_subject_label *));
59194 +
59195 + /* acquire the list of subjects, then NULL out
59196 + the list prior to parsing the subjects for this role,
59197 + as during this parsing the list is replaced with a list
59198 + of *nested* subjects for the role
59199 + */
59200 + subj_list = r_tmp->hash->first;
59201 +
59202 + /* set nested subject list to null */
59203 + r_tmp->hash->first = NULL;
59204 +
59205 + err = copy_user_subjs(subj_list, r_tmp);
59206 +
59207 + if (err)
59208 + return err;
59209 +
59210 + insert_acl_role_label(r_tmp);
59211 + }
59212 +
59213 + if (default_role == NULL || kernel_role == NULL)
59214 + return -EINVAL;
59215 +
59216 + return err;
59217 +}
59218 +
59219 +static int
59220 +gracl_init(struct gr_arg *args)
59221 +{
59222 + int error = 0;
59223 +
59224 + memcpy(gr_system_salt, args->salt, GR_SALT_LEN);
59225 + memcpy(gr_system_sum, args->sum, GR_SHA_LEN);
59226 +
59227 + if (init_variables(args)) {
59228 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_INITF_ACL_MSG, GR_VERSION);
59229 + error = -ENOMEM;
59230 + free_variables();
59231 + goto out;
59232 + }
59233 +
59234 + error = copy_user_acl(args);
59235 + free_init_variables();
59236 + if (error) {
59237 + free_variables();
59238 + goto out;
59239 + }
59240 +
59241 + if ((error = gr_set_acls(0))) {
59242 + free_variables();
59243 + goto out;
59244 + }
59245 +
59246 + pax_open_kernel();
59247 + gr_status |= GR_READY;
59248 + pax_close_kernel();
59249 +
59250 + out:
59251 + return error;
59252 +}
59253 +
59254 +/* derived from glibc fnmatch() 0: match, 1: no match*/
59255 +
59256 +static int
59257 +glob_match(const char *p, const char *n)
59258 +{
59259 + char c;
59260 +
59261 + while ((c = *p++) != '\0') {
59262 + switch (c) {
59263 + case '?':
59264 + if (*n == '\0')
59265 + return 1;
59266 + else if (*n == '/')
59267 + return 1;
59268 + break;
59269 + case '\\':
59270 + if (*n != c)
59271 + return 1;
59272 + break;
59273 + case '*':
59274 + for (c = *p++; c == '?' || c == '*'; c = *p++) {
59275 + if (*n == '/')
59276 + return 1;
59277 + else if (c == '?') {
59278 + if (*n == '\0')
59279 + return 1;
59280 + else
59281 + ++n;
59282 + }
59283 + }
59284 + if (c == '\0') {
59285 + return 0;
59286 + } else {
59287 + const char *endp;
59288 +
59289 + if ((endp = strchr(n, '/')) == NULL)
59290 + endp = n + strlen(n);
59291 +
59292 + if (c == '[') {
59293 + for (--p; n < endp; ++n)
59294 + if (!glob_match(p, n))
59295 + return 0;
59296 + } else if (c == '/') {
59297 + while (*n != '\0' && *n != '/')
59298 + ++n;
59299 + if (*n == '/' && !glob_match(p, n + 1))
59300 + return 0;
59301 + } else {
59302 + for (--p; n < endp; ++n)
59303 + if (*n == c && !glob_match(p, n))
59304 + return 0;
59305 + }
59306 +
59307 + return 1;
59308 + }
59309 + case '[':
59310 + {
59311 + int not;
59312 + char cold;
59313 +
59314 + if (*n == '\0' || *n == '/')
59315 + return 1;
59316 +
59317 + not = (*p == '!' || *p == '^');
59318 + if (not)
59319 + ++p;
59320 +
59321 + c = *p++;
59322 + for (;;) {
59323 + unsigned char fn = (unsigned char)*n;
59324 +
59325 + if (c == '\0')
59326 + return 1;
59327 + else {
59328 + if (c == fn)
59329 + goto matched;
59330 + cold = c;
59331 + c = *p++;
59332 +
59333 + if (c == '-' && *p != ']') {
59334 + unsigned char cend = *p++;
59335 +
59336 + if (cend == '\0')
59337 + return 1;
59338 +
59339 + if (cold <= fn && fn <= cend)
59340 + goto matched;
59341 +
59342 + c = *p++;
59343 + }
59344 + }
59345 +
59346 + if (c == ']')
59347 + break;
59348 + }
59349 + if (!not)
59350 + return 1;
59351 + break;
59352 + matched:
59353 + while (c != ']') {
59354 + if (c == '\0')
59355 + return 1;
59356 +
59357 + c = *p++;
59358 + }
59359 + if (not)
59360 + return 1;
59361 + }
59362 + break;
59363 + default:
59364 + if (c != *n)
59365 + return 1;
59366 + }
59367 +
59368 + ++n;
59369 + }
59370 +
59371 + if (*n == '\0')
59372 + return 0;
59373 +
59374 + if (*n == '/')
59375 + return 0;
59376 +
59377 + return 1;
59378 +}
59379 +
59380 +static struct acl_object_label *
59381 +chk_glob_label(struct acl_object_label *globbed,
59382 + const struct dentry *dentry, const struct vfsmount *mnt, char **path)
59383 +{
59384 + struct acl_object_label *tmp;
59385 +
59386 + if (*path == NULL)
59387 + *path = gr_to_filename_nolock(dentry, mnt);
59388 +
59389 + tmp = globbed;
59390 +
59391 + while (tmp) {
59392 + if (!glob_match(tmp->filename, *path))
59393 + return tmp;
59394 + tmp = tmp->next;
59395 + }
59396 +
59397 + return NULL;
59398 +}
59399 +
59400 +static struct acl_object_label *
59401 +__full_lookup(const struct dentry *orig_dentry, const struct vfsmount *orig_mnt,
59402 + const ino_t curr_ino, const dev_t curr_dev,
59403 + const struct acl_subject_label *subj, char **path, const int checkglob)
59404 +{
59405 + struct acl_subject_label *tmpsubj;
59406 + struct acl_object_label *retval;
59407 + struct acl_object_label *retval2;
59408 +
59409 + tmpsubj = (struct acl_subject_label *) subj;
59410 + read_lock(&gr_inode_lock);
59411 + do {
59412 + retval = lookup_acl_obj_label(curr_ino, curr_dev, tmpsubj);
59413 + if (retval) {
59414 + if (checkglob && retval->globbed) {
59415 + retval2 = chk_glob_label(retval->globbed, orig_dentry, orig_mnt, path);
59416 + if (retval2)
59417 + retval = retval2;
59418 + }
59419 + break;
59420 + }
59421 + } while ((tmpsubj = tmpsubj->parent_subject));
59422 + read_unlock(&gr_inode_lock);
59423 +
59424 + return retval;
59425 +}
59426 +
59427 +static __inline__ struct acl_object_label *
59428 +full_lookup(const struct dentry *orig_dentry, const struct vfsmount *orig_mnt,
59429 + struct dentry *curr_dentry,
59430 + const struct acl_subject_label *subj, char **path, const int checkglob)
59431 +{
59432 + int newglob = checkglob;
59433 + ino_t inode;
59434 + dev_t device;
59435 +
59436 + /* if we aren't checking a subdirectory of the original path yet, don't do glob checking
59437 + as we don't want a / * rule to match instead of the / object
59438 + don't do this for create lookups that call this function though, since they're looking up
59439 + on the parent and thus need globbing checks on all paths
59440 + */
59441 + if (orig_dentry == curr_dentry && newglob != GR_CREATE_GLOB)
59442 + newglob = GR_NO_GLOB;
59443 +
59444 + spin_lock(&curr_dentry->d_lock);
59445 + inode = curr_dentry->d_inode->i_ino;
59446 + device = __get_dev(curr_dentry);
59447 + spin_unlock(&curr_dentry->d_lock);
59448 +
59449 + return __full_lookup(orig_dentry, orig_mnt, inode, device, subj, path, newglob);
59450 +}
59451 +
59452 +#ifdef CONFIG_HUGETLBFS
59453 +static inline bool
59454 +is_hugetlbfs_mnt(const struct vfsmount *mnt)
59455 +{
59456 + int i;
59457 + for (i = 0; i < HUGE_MAX_HSTATE; i++) {
59458 + if (unlikely(hugetlbfs_vfsmount[i] == mnt))
59459 + return true;
59460 + }
59461 +
59462 + return false;
59463 +}
59464 +#endif
59465 +
59466 +static struct acl_object_label *
59467 +__chk_obj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
59468 + const struct acl_subject_label *subj, char *path, const int checkglob)
59469 +{
59470 + struct dentry *dentry = (struct dentry *) l_dentry;
59471 + struct vfsmount *mnt = (struct vfsmount *) l_mnt;
59472 + struct mount *real_mnt = real_mount(mnt);
59473 + struct acl_object_label *retval;
59474 + struct dentry *parent;
59475 +
59476 + br_read_lock(&vfsmount_lock);
59477 + write_seqlock(&rename_lock);
59478 +
59479 + if (unlikely((mnt == shm_mnt && dentry->d_inode->i_nlink == 0) || mnt == pipe_mnt ||
59480 +#ifdef CONFIG_NET
59481 + mnt == sock_mnt ||
59482 +#endif
59483 +#ifdef CONFIG_HUGETLBFS
59484 + (is_hugetlbfs_mnt(mnt) && dentry->d_inode->i_nlink == 0) ||
59485 +#endif
59486 + /* ignore Eric Biederman */
59487 + IS_PRIVATE(l_dentry->d_inode))) {
59488 + retval = (subj->mode & GR_SHMEXEC) ? fakefs_obj_rwx : fakefs_obj_rw;
59489 + goto out;
59490 + }
59491 +
59492 + for (;;) {
59493 + if (dentry == real_root.dentry && mnt == real_root.mnt)
59494 + break;
59495 +
59496 + if (dentry == mnt->mnt_root || IS_ROOT(dentry)) {
59497 + if (!mnt_has_parent(real_mnt))
59498 + break;
59499 +
59500 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
59501 + if (retval != NULL)
59502 + goto out;
59503 +
59504 + dentry = real_mnt->mnt_mountpoint;
59505 + real_mnt = real_mnt->mnt_parent;
59506 + mnt = &real_mnt->mnt;
59507 + continue;
59508 + }
59509 +
59510 + parent = dentry->d_parent;
59511 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
59512 + if (retval != NULL)
59513 + goto out;
59514 +
59515 + dentry = parent;
59516 + }
59517 +
59518 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
59519 +
59520 + /* real_root is pinned so we don't have to hold a reference */
59521 + if (retval == NULL)
59522 + retval = full_lookup(l_dentry, l_mnt, real_root.dentry, subj, &path, checkglob);
59523 +out:
59524 + write_sequnlock(&rename_lock);
59525 + br_read_unlock(&vfsmount_lock);
59526 +
59527 + BUG_ON(retval == NULL);
59528 +
59529 + return retval;
59530 +}
59531 +
59532 +static __inline__ struct acl_object_label *
59533 +chk_obj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
59534 + const struct acl_subject_label *subj)
59535 +{
59536 + char *path = NULL;
59537 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_REG_GLOB);
59538 +}
59539 +
59540 +static __inline__ struct acl_object_label *
59541 +chk_obj_label_noglob(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
59542 + const struct acl_subject_label *subj)
59543 +{
59544 + char *path = NULL;
59545 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_NO_GLOB);
59546 +}
59547 +
59548 +static __inline__ struct acl_object_label *
59549 +chk_obj_create_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
59550 + const struct acl_subject_label *subj, char *path)
59551 +{
59552 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_CREATE_GLOB);
59553 +}
59554 +
59555 +static struct acl_subject_label *
59556 +chk_subj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
59557 + const struct acl_role_label *role)
59558 +{
59559 + struct dentry *dentry = (struct dentry *) l_dentry;
59560 + struct vfsmount *mnt = (struct vfsmount *) l_mnt;
59561 + struct mount *real_mnt = real_mount(mnt);
59562 + struct acl_subject_label *retval;
59563 + struct dentry *parent;
59564 +
59565 + br_read_lock(&vfsmount_lock);
59566 + write_seqlock(&rename_lock);
59567 +
59568 + for (;;) {
59569 + if (dentry == real_root.dentry && mnt == real_root.mnt)
59570 + break;
59571 + if (dentry == mnt->mnt_root || IS_ROOT(dentry)) {
59572 + if (!mnt_has_parent(real_mnt))
59573 + break;
59574 +
59575 + spin_lock(&dentry->d_lock);
59576 + read_lock(&gr_inode_lock);
59577 + retval =
59578 + lookup_acl_subj_label(dentry->d_inode->i_ino,
59579 + __get_dev(dentry), role);
59580 + read_unlock(&gr_inode_lock);
59581 + spin_unlock(&dentry->d_lock);
59582 + if (retval != NULL)
59583 + goto out;
59584 +
59585 + dentry = real_mnt->mnt_mountpoint;
59586 + real_mnt = real_mnt->mnt_parent;
59587 + mnt = &real_mnt->mnt;
59588 + continue;
59589 + }
59590 +
59591 + spin_lock(&dentry->d_lock);
59592 + read_lock(&gr_inode_lock);
59593 + retval = lookup_acl_subj_label(dentry->d_inode->i_ino,
59594 + __get_dev(dentry), role);
59595 + read_unlock(&gr_inode_lock);
59596 + parent = dentry->d_parent;
59597 + spin_unlock(&dentry->d_lock);
59598 +
59599 + if (retval != NULL)
59600 + goto out;
59601 +
59602 + dentry = parent;
59603 + }
59604 +
59605 + spin_lock(&dentry->d_lock);
59606 + read_lock(&gr_inode_lock);
59607 + retval = lookup_acl_subj_label(dentry->d_inode->i_ino,
59608 + __get_dev(dentry), role);
59609 + read_unlock(&gr_inode_lock);
59610 + spin_unlock(&dentry->d_lock);
59611 +
59612 + if (unlikely(retval == NULL)) {
59613 + /* real_root is pinned, we don't need to hold a reference */
59614 + read_lock(&gr_inode_lock);
59615 + retval = lookup_acl_subj_label(real_root.dentry->d_inode->i_ino,
59616 + __get_dev(real_root.dentry), role);
59617 + read_unlock(&gr_inode_lock);
59618 + }
59619 +out:
59620 + write_sequnlock(&rename_lock);
59621 + br_read_unlock(&vfsmount_lock);
59622 +
59623 + BUG_ON(retval == NULL);
59624 +
59625 + return retval;
59626 +}
59627 +
59628 +static void
59629 +gr_log_learn(const struct dentry *dentry, const struct vfsmount *mnt, const __u32 mode)
59630 +{
59631 + struct task_struct *task = current;
59632 + const struct cred *cred = current_cred();
59633 +
59634 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename, task->role->roletype,
59635 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
59636 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
59637 + 1UL, 1UL, gr_to_filename(dentry, mnt), (unsigned long) mode, &task->signal->saved_ip);
59638 +
59639 + return;
59640 +}
59641 +
59642 +static void
59643 +gr_log_learn_uid_change(const kuid_t real, const kuid_t effective, const kuid_t fs)
59644 +{
59645 + struct task_struct *task = current;
59646 + const struct cred *cred = current_cred();
59647 +
59648 + security_learn(GR_ID_LEARN_MSG, task->role->rolename, task->role->roletype,
59649 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
59650 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
59651 + 'u', GR_GLOBAL_UID(real), GR_GLOBAL_UID(effective), GR_GLOBAL_UID(fs), &task->signal->saved_ip);
59652 +
59653 + return;
59654 +}
59655 +
59656 +static void
59657 +gr_log_learn_gid_change(const kgid_t real, const kgid_t effective, const kgid_t fs)
59658 +{
59659 + struct task_struct *task = current;
59660 + const struct cred *cred = current_cred();
59661 +
59662 + security_learn(GR_ID_LEARN_MSG, task->role->rolename, task->role->roletype,
59663 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
59664 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
59665 + 'g', GR_GLOBAL_GID(real), GR_GLOBAL_GID(effective), GR_GLOBAL_GID(fs), &task->signal->saved_ip);
59666 +
59667 + return;
59668 +}
59669 +
59670 +__u32
59671 +gr_search_file(const struct dentry * dentry, const __u32 mode,
59672 + const struct vfsmount * mnt)
59673 +{
59674 + __u32 retval = mode;
59675 + struct acl_subject_label *curracl;
59676 + struct acl_object_label *currobj;
59677 +
59678 + if (unlikely(!(gr_status & GR_READY)))
59679 + return (mode & ~GR_AUDITS);
59680 +
59681 + curracl = current->acl;
59682 +
59683 + currobj = chk_obj_label(dentry, mnt, curracl);
59684 + retval = currobj->mode & mode;
59685 +
59686 + /* if we're opening a specified transfer file for writing
59687 + (e.g. /dev/initctl), then transfer our role to init
59688 + */
59689 + if (unlikely(currobj->mode & GR_INIT_TRANSFER && retval & GR_WRITE &&
59690 + current->role->roletype & GR_ROLE_PERSIST)) {
59691 + struct task_struct *task = init_pid_ns.child_reaper;
59692 +
59693 + if (task->role != current->role) {
59694 + task->acl_sp_role = 0;
59695 + task->acl_role_id = current->acl_role_id;
59696 + task->role = current->role;
59697 + rcu_read_lock();
59698 + read_lock(&grsec_exec_file_lock);
59699 + gr_apply_subject_to_task(task);
59700 + read_unlock(&grsec_exec_file_lock);
59701 + rcu_read_unlock();
59702 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_INIT_TRANSFER_MSG);
59703 + }
59704 + }
59705 +
59706 + if (unlikely
59707 + ((curracl->mode & (GR_LEARN | GR_INHERITLEARN)) && !(mode & GR_NOPTRACE)
59708 + && (retval != (mode & ~(GR_AUDITS | GR_SUPPRESS))))) {
59709 + __u32 new_mode = mode;
59710 +
59711 + new_mode &= ~(GR_AUDITS | GR_SUPPRESS);
59712 +
59713 + retval = new_mode;
59714 +
59715 + if (new_mode & GR_EXEC && curracl->mode & GR_INHERITLEARN)
59716 + new_mode |= GR_INHERIT;
59717 +
59718 + if (!(mode & GR_NOLEARN))
59719 + gr_log_learn(dentry, mnt, new_mode);
59720 + }
59721 +
59722 + return retval;
59723 +}
59724 +
59725 +struct acl_object_label *gr_get_create_object(const struct dentry *new_dentry,
59726 + const struct dentry *parent,
59727 + const struct vfsmount *mnt)
59728 +{
59729 + struct name_entry *match;
59730 + struct acl_object_label *matchpo;
59731 + struct acl_subject_label *curracl;
59732 + char *path;
59733 +
59734 + if (unlikely(!(gr_status & GR_READY)))
59735 + return NULL;
59736 +
59737 + preempt_disable();
59738 + path = gr_to_filename_rbac(new_dentry, mnt);
59739 + match = lookup_name_entry_create(path);
59740 +
59741 + curracl = current->acl;
59742 +
59743 + if (match) {
59744 + read_lock(&gr_inode_lock);
59745 + matchpo = lookup_acl_obj_label_create(match->inode, match->device, curracl);
59746 + read_unlock(&gr_inode_lock);
59747 +
59748 + if (matchpo) {
59749 + preempt_enable();
59750 + return matchpo;
59751 + }
59752 + }
59753 +
59754 + // lookup parent
59755 +
59756 + matchpo = chk_obj_create_label(parent, mnt, curracl, path);
59757 +
59758 + preempt_enable();
59759 + return matchpo;
59760 +}
59761 +
59762 +__u32
59763 +gr_check_create(const struct dentry * new_dentry, const struct dentry * parent,
59764 + const struct vfsmount * mnt, const __u32 mode)
59765 +{
59766 + struct acl_object_label *matchpo;
59767 + __u32 retval;
59768 +
59769 + if (unlikely(!(gr_status & GR_READY)))
59770 + return (mode & ~GR_AUDITS);
59771 +
59772 + matchpo = gr_get_create_object(new_dentry, parent, mnt);
59773 +
59774 + retval = matchpo->mode & mode;
59775 +
59776 + if ((retval != (mode & ~(GR_AUDITS | GR_SUPPRESS)))
59777 + && (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))) {
59778 + __u32 new_mode = mode;
59779 +
59780 + new_mode &= ~(GR_AUDITS | GR_SUPPRESS);
59781 +
59782 + gr_log_learn(new_dentry, mnt, new_mode);
59783 + return new_mode;
59784 + }
59785 +
59786 + return retval;
59787 +}
59788 +
59789 +__u32
59790 +gr_check_link(const struct dentry * new_dentry,
59791 + const struct dentry * parent_dentry,
59792 + const struct vfsmount * parent_mnt,
59793 + const struct dentry * old_dentry, const struct vfsmount * old_mnt)
59794 +{
59795 + struct acl_object_label *obj;
59796 + __u32 oldmode, newmode;
59797 + __u32 needmode;
59798 + __u32 checkmodes = GR_FIND | GR_APPEND | GR_WRITE | GR_EXEC | GR_SETID | GR_READ |
59799 + GR_DELETE | GR_INHERIT;
59800 +
59801 + if (unlikely(!(gr_status & GR_READY)))
59802 + return (GR_CREATE | GR_LINK);
59803 +
59804 + obj = chk_obj_label(old_dentry, old_mnt, current->acl);
59805 + oldmode = obj->mode;
59806 +
59807 + obj = gr_get_create_object(new_dentry, parent_dentry, parent_mnt);
59808 + newmode = obj->mode;
59809 +
59810 + needmode = newmode & checkmodes;
59811 +
59812 + // old name for hardlink must have at least the permissions of the new name
59813 + if ((oldmode & needmode) != needmode)
59814 + goto bad;
59815 +
59816 + // if old name had restrictions/auditing, make sure the new name does as well
59817 + needmode = oldmode & (GR_NOPTRACE | GR_PTRACERD | GR_INHERIT | GR_AUDITS);
59818 +
59819 + // don't allow hardlinking of suid/sgid/fcapped files without permission
59820 + if (is_privileged_binary(old_dentry))
59821 + needmode |= GR_SETID;
59822 +
59823 + if ((newmode & needmode) != needmode)
59824 + goto bad;
59825 +
59826 + // enforce minimum permissions
59827 + if ((newmode & (GR_CREATE | GR_LINK)) == (GR_CREATE | GR_LINK))
59828 + return newmode;
59829 +bad:
59830 + needmode = oldmode;
59831 + if (is_privileged_binary(old_dentry))
59832 + needmode |= GR_SETID;
59833 +
59834 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN)) {
59835 + gr_log_learn(old_dentry, old_mnt, needmode | GR_CREATE | GR_LINK);
59836 + return (GR_CREATE | GR_LINK);
59837 + } else if (newmode & GR_SUPPRESS)
59838 + return GR_SUPPRESS;
59839 + else
59840 + return 0;
59841 +}
59842 +
59843 +int
59844 +gr_check_hidden_task(const struct task_struct *task)
59845 +{
59846 + if (unlikely(!(gr_status & GR_READY)))
59847 + return 0;
59848 +
59849 + if (!(task->acl->mode & GR_PROCFIND) && !(current->acl->mode & GR_VIEW))
59850 + return 1;
59851 +
59852 + return 0;
59853 +}
59854 +
59855 +int
59856 +gr_check_protected_task(const struct task_struct *task)
59857 +{
59858 + if (unlikely(!(gr_status & GR_READY) || !task))
59859 + return 0;
59860 +
59861 + if ((task->acl->mode & GR_PROTECTED) && !(current->acl->mode & GR_KILL) &&
59862 + task->acl != current->acl)
59863 + return 1;
59864 +
59865 + return 0;
59866 +}
59867 +
59868 +int
59869 +gr_check_protected_task_fowner(struct pid *pid, enum pid_type type)
59870 +{
59871 + struct task_struct *p;
59872 + int ret = 0;
59873 +
59874 + if (unlikely(!(gr_status & GR_READY) || !pid))
59875 + return ret;
59876 +
59877 + read_lock(&tasklist_lock);
59878 + do_each_pid_task(pid, type, p) {
59879 + if ((p->acl->mode & GR_PROTECTED) && !(current->acl->mode & GR_KILL) &&
59880 + p->acl != current->acl) {
59881 + ret = 1;
59882 + goto out;
59883 + }
59884 + } while_each_pid_task(pid, type, p);
59885 +out:
59886 + read_unlock(&tasklist_lock);
59887 +
59888 + return ret;
59889 +}
59890 +
59891 +void
59892 +gr_copy_label(struct task_struct *tsk)
59893 +{
59894 + tsk->signal->used_accept = 0;
59895 + tsk->acl_sp_role = 0;
59896 + tsk->acl_role_id = current->acl_role_id;
59897 + tsk->acl = current->acl;
59898 + tsk->role = current->role;
59899 + tsk->signal->curr_ip = current->signal->curr_ip;
59900 + tsk->signal->saved_ip = current->signal->saved_ip;
59901 + if (current->exec_file)
59902 + get_file(current->exec_file);
59903 + tsk->exec_file = current->exec_file;
59904 + tsk->is_writable = current->is_writable;
59905 + if (unlikely(current->signal->used_accept)) {
59906 + current->signal->curr_ip = 0;
59907 + current->signal->saved_ip = 0;
59908 + }
59909 +
59910 + return;
59911 +}
59912 +
59913 +static void
59914 +gr_set_proc_res(struct task_struct *task)
59915 +{
59916 + struct acl_subject_label *proc;
59917 + unsigned short i;
59918 +
59919 + proc = task->acl;
59920 +
59921 + if (proc->mode & (GR_LEARN | GR_INHERITLEARN))
59922 + return;
59923 +
59924 + for (i = 0; i < RLIM_NLIMITS; i++) {
59925 + if (!(proc->resmask & (1U << i)))
59926 + continue;
59927 +
59928 + task->signal->rlim[i].rlim_cur = proc->res[i].rlim_cur;
59929 + task->signal->rlim[i].rlim_max = proc->res[i].rlim_max;
59930 +
59931 + if (i == RLIMIT_CPU)
59932 + update_rlimit_cpu(task, proc->res[i].rlim_cur);
59933 + }
59934 +
59935 + return;
59936 +}
59937 +
59938 +extern int __gr_process_user_ban(struct user_struct *user);
59939 +
59940 +int
59941 +gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs)
59942 +{
59943 + unsigned int i;
59944 + __u16 num;
59945 + uid_t *uidlist;
59946 + uid_t curuid;
59947 + int realok = 0;
59948 + int effectiveok = 0;
59949 + int fsok = 0;
59950 + uid_t globalreal, globaleffective, globalfs;
59951 +
59952 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT) || defined(CONFIG_GRKERNSEC_BRUTE)
59953 + struct user_struct *user;
59954 +
59955 + if (!uid_valid(real))
59956 + goto skipit;
59957 +
59958 + /* find user based on global namespace */
59959 +
59960 + globalreal = GR_GLOBAL_UID(real);
59961 +
59962 + user = find_user(make_kuid(&init_user_ns, globalreal));
59963 + if (user == NULL)
59964 + goto skipit;
59965 +
59966 + if (__gr_process_user_ban(user)) {
59967 + /* for find_user */
59968 + free_uid(user);
59969 + return 1;
59970 + }
59971 +
59972 + /* for find_user */
59973 + free_uid(user);
59974 +
59975 +skipit:
59976 +#endif
59977 +
59978 + if (unlikely(!(gr_status & GR_READY)))
59979 + return 0;
59980 +
59981 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))
59982 + gr_log_learn_uid_change(real, effective, fs);
59983 +
59984 + num = current->acl->user_trans_num;
59985 + uidlist = current->acl->user_transitions;
59986 +
59987 + if (uidlist == NULL)
59988 + return 0;
59989 +
59990 + if (!uid_valid(real)) {
59991 + realok = 1;
59992 + globalreal = (uid_t)-1;
59993 + } else {
59994 + globalreal = GR_GLOBAL_UID(real);
59995 + }
59996 + if (!uid_valid(effective)) {
59997 + effectiveok = 1;
59998 + globaleffective = (uid_t)-1;
59999 + } else {
60000 + globaleffective = GR_GLOBAL_UID(effective);
60001 + }
60002 + if (!uid_valid(fs)) {
60003 + fsok = 1;
60004 + globalfs = (uid_t)-1;
60005 + } else {
60006 + globalfs = GR_GLOBAL_UID(fs);
60007 + }
60008 +
60009 + if (current->acl->user_trans_type & GR_ID_ALLOW) {
60010 + for (i = 0; i < num; i++) {
60011 + curuid = uidlist[i];
60012 + if (globalreal == curuid)
60013 + realok = 1;
60014 + if (globaleffective == curuid)
60015 + effectiveok = 1;
60016 + if (globalfs == curuid)
60017 + fsok = 1;
60018 + }
60019 + } else if (current->acl->user_trans_type & GR_ID_DENY) {
60020 + for (i = 0; i < num; i++) {
60021 + curuid = uidlist[i];
60022 + if (globalreal == curuid)
60023 + break;
60024 + if (globaleffective == curuid)
60025 + break;
60026 + if (globalfs == curuid)
60027 + break;
60028 + }
60029 + /* not in deny list */
60030 + if (i == num) {
60031 + realok = 1;
60032 + effectiveok = 1;
60033 + fsok = 1;
60034 + }
60035 + }
60036 +
60037 + if (realok && effectiveok && fsok)
60038 + return 0;
60039 + else {
60040 + gr_log_int(GR_DONT_AUDIT, GR_USRCHANGE_ACL_MSG, realok ? (effectiveok ? (fsok ? 0 : globalfs) : globaleffective) : globalreal);
60041 + return 1;
60042 + }
60043 +}
60044 +
60045 +int
60046 +gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs)
60047 +{
60048 + unsigned int i;
60049 + __u16 num;
60050 + gid_t *gidlist;
60051 + gid_t curgid;
60052 + int realok = 0;
60053 + int effectiveok = 0;
60054 + int fsok = 0;
60055 + gid_t globalreal, globaleffective, globalfs;
60056 +
60057 + if (unlikely(!(gr_status & GR_READY)))
60058 + return 0;
60059 +
60060 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))
60061 + gr_log_learn_gid_change(real, effective, fs);
60062 +
60063 + num = current->acl->group_trans_num;
60064 + gidlist = current->acl->group_transitions;
60065 +
60066 + if (gidlist == NULL)
60067 + return 0;
60068 +
60069 + if (!gid_valid(real)) {
60070 + realok = 1;
60071 + globalreal = (gid_t)-1;
60072 + } else {
60073 + globalreal = GR_GLOBAL_GID(real);
60074 + }
60075 + if (!gid_valid(effective)) {
60076 + effectiveok = 1;
60077 + globaleffective = (gid_t)-1;
60078 + } else {
60079 + globaleffective = GR_GLOBAL_GID(effective);
60080 + }
60081 + if (!gid_valid(fs)) {
60082 + fsok = 1;
60083 + globalfs = (gid_t)-1;
60084 + } else {
60085 + globalfs = GR_GLOBAL_GID(fs);
60086 + }
60087 +
60088 + if (current->acl->group_trans_type & GR_ID_ALLOW) {
60089 + for (i = 0; i < num; i++) {
60090 + curgid = gidlist[i];
60091 + if (globalreal == curgid)
60092 + realok = 1;
60093 + if (globaleffective == curgid)
60094 + effectiveok = 1;
60095 + if (globalfs == curgid)
60096 + fsok = 1;
60097 + }
60098 + } else if (current->acl->group_trans_type & GR_ID_DENY) {
60099 + for (i = 0; i < num; i++) {
60100 + curgid = gidlist[i];
60101 + if (globalreal == curgid)
60102 + break;
60103 + if (globaleffective == curgid)
60104 + break;
60105 + if (globalfs == curgid)
60106 + break;
60107 + }
60108 + /* not in deny list */
60109 + if (i == num) {
60110 + realok = 1;
60111 + effectiveok = 1;
60112 + fsok = 1;
60113 + }
60114 + }
60115 +
60116 + if (realok && effectiveok && fsok)
60117 + return 0;
60118 + else {
60119 + gr_log_int(GR_DONT_AUDIT, GR_GRPCHANGE_ACL_MSG, realok ? (effectiveok ? (fsok ? 0 : globalfs) : globaleffective) : globalreal);
60120 + return 1;
60121 + }
60122 +}
60123 +
60124 +extern int gr_acl_is_capable(const int cap);
60125 +
60126 +void
60127 +gr_set_role_label(struct task_struct *task, const kuid_t kuid, const kgid_t kgid)
60128 +{
60129 + struct acl_role_label *role = task->role;
60130 + struct acl_subject_label *subj = NULL;
60131 + struct acl_object_label *obj;
60132 + struct file *filp;
60133 + uid_t uid;
60134 + gid_t gid;
60135 +
60136 + if (unlikely(!(gr_status & GR_READY)))
60137 + return;
60138 +
60139 + uid = GR_GLOBAL_UID(kuid);
60140 + gid = GR_GLOBAL_GID(kgid);
60141 +
60142 + filp = task->exec_file;
60143 +
60144 + /* kernel process, we'll give them the kernel role */
60145 + if (unlikely(!filp)) {
60146 + task->role = kernel_role;
60147 + task->acl = kernel_role->root_label;
60148 + return;
60149 + } else if (!task->role || !(task->role->roletype & GR_ROLE_SPECIAL))
60150 + role = lookup_acl_role_label(task, uid, gid);
60151 +
60152 + /* don't change the role if we're not a privileged process */
60153 + if (role && task->role != role &&
60154 + (((role->roletype & GR_ROLE_USER) && !gr_acl_is_capable(CAP_SETUID)) ||
60155 + ((role->roletype & GR_ROLE_GROUP) && !gr_acl_is_capable(CAP_SETGID))))
60156 + return;
60157 +
60158 + /* perform subject lookup in possibly new role
60159 + we can use this result below in the case where role == task->role
60160 + */
60161 + subj = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, role);
60162 +
60163 + /* if we changed uid/gid, but result in the same role
60164 + and are using inheritance, don't lose the inherited subject
60165 + if current subject is other than what normal lookup
60166 + would result in, we arrived via inheritance, don't
60167 + lose subject
60168 + */
60169 + if (role != task->role || (!(task->acl->mode & GR_INHERITLEARN) &&
60170 + (subj == task->acl)))
60171 + task->acl = subj;
60172 +
60173 + task->role = role;
60174 +
60175 + task->is_writable = 0;
60176 +
60177 + /* ignore additional mmap checks for processes that are writable
60178 + by the default ACL */
60179 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
60180 + if (unlikely(obj->mode & GR_WRITE))
60181 + task->is_writable = 1;
60182 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, task->role->root_label);
60183 + if (unlikely(obj->mode & GR_WRITE))
60184 + task->is_writable = 1;
60185 +
60186 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
60187 + 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);
60188 +#endif
60189 +
60190 + gr_set_proc_res(task);
60191 +
60192 + return;
60193 +}
60194 +
60195 +int
60196 +gr_set_proc_label(const struct dentry *dentry, const struct vfsmount *mnt,
60197 + const int unsafe_flags)
60198 +{
60199 + struct task_struct *task = current;
60200 + struct acl_subject_label *newacl;
60201 + struct acl_object_label *obj;
60202 + __u32 retmode;
60203 +
60204 + if (unlikely(!(gr_status & GR_READY)))
60205 + return 0;
60206 +
60207 + newacl = chk_subj_label(dentry, mnt, task->role);
60208 +
60209 + /* special handling for if we did an strace -f -p <pid> from an admin role, where pid then
60210 + did an exec
60211 + */
60212 + rcu_read_lock();
60213 + read_lock(&tasklist_lock);
60214 + if (task->ptrace && task->parent && ((task->parent->role->roletype & GR_ROLE_GOD) ||
60215 + (task->parent->acl->mode & GR_POVERRIDE))) {
60216 + read_unlock(&tasklist_lock);
60217 + rcu_read_unlock();
60218 + goto skip_check;
60219 + }
60220 + read_unlock(&tasklist_lock);
60221 + rcu_read_unlock();
60222 +
60223 + if (unsafe_flags && !(task->acl->mode & GR_POVERRIDE) && (task->acl != newacl) &&
60224 + !(task->role->roletype & GR_ROLE_GOD) &&
60225 + !gr_search_file(dentry, GR_PTRACERD, mnt) &&
60226 + !(task->acl->mode & (GR_LEARN | GR_INHERITLEARN))) {
60227 + if (unsafe_flags & LSM_UNSAFE_SHARE)
60228 + gr_log_fs_generic(GR_DONT_AUDIT, GR_UNSAFESHARE_EXEC_ACL_MSG, dentry, mnt);
60229 + else
60230 + gr_log_fs_generic(GR_DONT_AUDIT, GR_PTRACE_EXEC_ACL_MSG, dentry, mnt);
60231 + return -EACCES;
60232 + }
60233 +
60234 +skip_check:
60235 +
60236 + obj = chk_obj_label(dentry, mnt, task->acl);
60237 + retmode = obj->mode & (GR_INHERIT | GR_AUDIT_INHERIT);
60238 +
60239 + if (!(task->acl->mode & GR_INHERITLEARN) &&
60240 + ((newacl->mode & GR_LEARN) || !(retmode & GR_INHERIT))) {
60241 + if (obj->nested)
60242 + task->acl = obj->nested;
60243 + else
60244 + task->acl = newacl;
60245 + } else if (retmode & GR_INHERIT && retmode & GR_AUDIT_INHERIT)
60246 + gr_log_str_fs(GR_DO_AUDIT, GR_INHERIT_ACL_MSG, task->acl->filename, dentry, mnt);
60247 +
60248 + task->is_writable = 0;
60249 +
60250 + /* ignore additional mmap checks for processes that are writable
60251 + by the default ACL */
60252 + obj = chk_obj_label(dentry, mnt, default_role->root_label);
60253 + if (unlikely(obj->mode & GR_WRITE))
60254 + task->is_writable = 1;
60255 + obj = chk_obj_label(dentry, mnt, task->role->root_label);
60256 + if (unlikely(obj->mode & GR_WRITE))
60257 + task->is_writable = 1;
60258 +
60259 + gr_set_proc_res(task);
60260 +
60261 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
60262 + 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);
60263 +#endif
60264 + return 0;
60265 +}
60266 +
60267 +/* always called with valid inodev ptr */
60268 +static void
60269 +do_handle_delete(struct inodev_entry *inodev, const ino_t ino, const dev_t dev)
60270 +{
60271 + struct acl_object_label *matchpo;
60272 + struct acl_subject_label *matchps;
60273 + struct acl_subject_label *subj;
60274 + struct acl_role_label *role;
60275 + unsigned int x;
60276 +
60277 + FOR_EACH_ROLE_START(role)
60278 + FOR_EACH_SUBJECT_START(role, subj, x)
60279 + if ((matchpo = lookup_acl_obj_label(ino, dev, subj)) != NULL)
60280 + matchpo->mode |= GR_DELETED;
60281 + FOR_EACH_SUBJECT_END(subj,x)
60282 + FOR_EACH_NESTED_SUBJECT_START(role, subj)
60283 + /* nested subjects aren't in the role's subj_hash table */
60284 + if ((matchpo = lookup_acl_obj_label(ino, dev, subj)) != NULL)
60285 + matchpo->mode |= GR_DELETED;
60286 + FOR_EACH_NESTED_SUBJECT_END(subj)
60287 + if ((matchps = lookup_acl_subj_label(ino, dev, role)) != NULL)
60288 + matchps->mode |= GR_DELETED;
60289 + FOR_EACH_ROLE_END(role)
60290 +
60291 + inodev->nentry->deleted = 1;
60292 +
60293 + return;
60294 +}
60295 +
60296 +void
60297 +gr_handle_delete(const ino_t ino, const dev_t dev)
60298 +{
60299 + struct inodev_entry *inodev;
60300 +
60301 + if (unlikely(!(gr_status & GR_READY)))
60302 + return;
60303 +
60304 + write_lock(&gr_inode_lock);
60305 + inodev = lookup_inodev_entry(ino, dev);
60306 + if (inodev != NULL)
60307 + do_handle_delete(inodev, ino, dev);
60308 + write_unlock(&gr_inode_lock);
60309 +
60310 + return;
60311 +}
60312 +
60313 +static void
60314 +update_acl_obj_label(const ino_t oldinode, const dev_t olddevice,
60315 + const ino_t newinode, const dev_t newdevice,
60316 + struct acl_subject_label *subj)
60317 +{
60318 + unsigned int index = gr_fhash(oldinode, olddevice, subj->obj_hash_size);
60319 + struct acl_object_label *match;
60320 +
60321 + match = subj->obj_hash[index];
60322 +
60323 + while (match && (match->inode != oldinode ||
60324 + match->device != olddevice ||
60325 + !(match->mode & GR_DELETED)))
60326 + match = match->next;
60327 +
60328 + if (match && (match->inode == oldinode)
60329 + && (match->device == olddevice)
60330 + && (match->mode & GR_DELETED)) {
60331 + if (match->prev == NULL) {
60332 + subj->obj_hash[index] = match->next;
60333 + if (match->next != NULL)
60334 + match->next->prev = NULL;
60335 + } else {
60336 + match->prev->next = match->next;
60337 + if (match->next != NULL)
60338 + match->next->prev = match->prev;
60339 + }
60340 + match->prev = NULL;
60341 + match->next = NULL;
60342 + match->inode = newinode;
60343 + match->device = newdevice;
60344 + match->mode &= ~GR_DELETED;
60345 +
60346 + insert_acl_obj_label(match, subj);
60347 + }
60348 +
60349 + return;
60350 +}
60351 +
60352 +static void
60353 +update_acl_subj_label(const ino_t oldinode, const dev_t olddevice,
60354 + const ino_t newinode, const dev_t newdevice,
60355 + struct acl_role_label *role)
60356 +{
60357 + unsigned int index = gr_fhash(oldinode, olddevice, role->subj_hash_size);
60358 + struct acl_subject_label *match;
60359 +
60360 + match = role->subj_hash[index];
60361 +
60362 + while (match && (match->inode != oldinode ||
60363 + match->device != olddevice ||
60364 + !(match->mode & GR_DELETED)))
60365 + match = match->next;
60366 +
60367 + if (match && (match->inode == oldinode)
60368 + && (match->device == olddevice)
60369 + && (match->mode & GR_DELETED)) {
60370 + if (match->prev == NULL) {
60371 + role->subj_hash[index] = match->next;
60372 + if (match->next != NULL)
60373 + match->next->prev = NULL;
60374 + } else {
60375 + match->prev->next = match->next;
60376 + if (match->next != NULL)
60377 + match->next->prev = match->prev;
60378 + }
60379 + match->prev = NULL;
60380 + match->next = NULL;
60381 + match->inode = newinode;
60382 + match->device = newdevice;
60383 + match->mode &= ~GR_DELETED;
60384 +
60385 + insert_acl_subj_label(match, role);
60386 + }
60387 +
60388 + return;
60389 +}
60390 +
60391 +static void
60392 +update_inodev_entry(const ino_t oldinode, const dev_t olddevice,
60393 + const ino_t newinode, const dev_t newdevice)
60394 +{
60395 + unsigned int index = gr_fhash(oldinode, olddevice, inodev_set.i_size);
60396 + struct inodev_entry *match;
60397 +
60398 + match = inodev_set.i_hash[index];
60399 +
60400 + while (match && (match->nentry->inode != oldinode ||
60401 + match->nentry->device != olddevice || !match->nentry->deleted))
60402 + match = match->next;
60403 +
60404 + if (match && (match->nentry->inode == oldinode)
60405 + && (match->nentry->device == olddevice) &&
60406 + match->nentry->deleted) {
60407 + if (match->prev == NULL) {
60408 + inodev_set.i_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->nentry->inode = newinode;
60419 + match->nentry->device = newdevice;
60420 + match->nentry->deleted = 0;
60421 +
60422 + insert_inodev_entry(match);
60423 + }
60424 +
60425 + return;
60426 +}
60427 +
60428 +static void
60429 +__do_handle_create(const struct name_entry *matchn, ino_t ino, dev_t dev)
60430 +{
60431 + struct acl_subject_label *subj;
60432 + struct acl_role_label *role;
60433 + unsigned int x;
60434 +
60435 + FOR_EACH_ROLE_START(role)
60436 + update_acl_subj_label(matchn->inode, matchn->device, ino, dev, role);
60437 +
60438 + FOR_EACH_NESTED_SUBJECT_START(role, subj)
60439 + if ((subj->inode == ino) && (subj->device == dev)) {
60440 + subj->inode = ino;
60441 + subj->device = dev;
60442 + }
60443 + /* nested subjects aren't in the role's subj_hash table */
60444 + update_acl_obj_label(matchn->inode, matchn->device,
60445 + ino, dev, subj);
60446 + FOR_EACH_NESTED_SUBJECT_END(subj)
60447 + FOR_EACH_SUBJECT_START(role, subj, x)
60448 + update_acl_obj_label(matchn->inode, matchn->device,
60449 + ino, dev, subj);
60450 + FOR_EACH_SUBJECT_END(subj,x)
60451 + FOR_EACH_ROLE_END(role)
60452 +
60453 + update_inodev_entry(matchn->inode, matchn->device, ino, dev);
60454 +
60455 + return;
60456 +}
60457 +
60458 +static void
60459 +do_handle_create(const struct name_entry *matchn, const struct dentry *dentry,
60460 + const struct vfsmount *mnt)
60461 +{
60462 + ino_t ino = dentry->d_inode->i_ino;
60463 + dev_t dev = __get_dev(dentry);
60464 +
60465 + __do_handle_create(matchn, ino, dev);
60466 +
60467 + return;
60468 +}
60469 +
60470 +void
60471 +gr_handle_create(const struct dentry *dentry, const struct vfsmount *mnt)
60472 +{
60473 + struct name_entry *matchn;
60474 +
60475 + if (unlikely(!(gr_status & GR_READY)))
60476 + return;
60477 +
60478 + preempt_disable();
60479 + matchn = lookup_name_entry(gr_to_filename_rbac(dentry, mnt));
60480 +
60481 + if (unlikely((unsigned long)matchn)) {
60482 + write_lock(&gr_inode_lock);
60483 + do_handle_create(matchn, dentry, mnt);
60484 + write_unlock(&gr_inode_lock);
60485 + }
60486 + preempt_enable();
60487 +
60488 + return;
60489 +}
60490 +
60491 +void
60492 +gr_handle_proc_create(const struct dentry *dentry, const struct inode *inode)
60493 +{
60494 + struct name_entry *matchn;
60495 +
60496 + if (unlikely(!(gr_status & GR_READY)))
60497 + return;
60498 +
60499 + preempt_disable();
60500 + matchn = lookup_name_entry(gr_to_proc_filename_rbac(dentry, init_pid_ns.proc_mnt));
60501 +
60502 + if (unlikely((unsigned long)matchn)) {
60503 + write_lock(&gr_inode_lock);
60504 + __do_handle_create(matchn, inode->i_ino, inode->i_sb->s_dev);
60505 + write_unlock(&gr_inode_lock);
60506 + }
60507 + preempt_enable();
60508 +
60509 + return;
60510 +}
60511 +
60512 +void
60513 +gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
60514 + struct dentry *old_dentry,
60515 + struct dentry *new_dentry,
60516 + struct vfsmount *mnt, const __u8 replace)
60517 +{
60518 + struct name_entry *matchn;
60519 + struct inodev_entry *inodev;
60520 + struct inode *inode = new_dentry->d_inode;
60521 + ino_t old_ino = old_dentry->d_inode->i_ino;
60522 + dev_t old_dev = __get_dev(old_dentry);
60523 +
60524 + /* vfs_rename swaps the name and parent link for old_dentry and
60525 + new_dentry
60526 + at this point, old_dentry has the new name, parent link, and inode
60527 + for the renamed file
60528 + if a file is being replaced by a rename, new_dentry has the inode
60529 + and name for the replaced file
60530 + */
60531 +
60532 + if (unlikely(!(gr_status & GR_READY)))
60533 + return;
60534 +
60535 + preempt_disable();
60536 + matchn = lookup_name_entry(gr_to_filename_rbac(old_dentry, mnt));
60537 +
60538 + /* we wouldn't have to check d_inode if it weren't for
60539 + NFS silly-renaming
60540 + */
60541 +
60542 + write_lock(&gr_inode_lock);
60543 + if (unlikely(replace && inode)) {
60544 + ino_t new_ino = inode->i_ino;
60545 + dev_t new_dev = __get_dev(new_dentry);
60546 +
60547 + inodev = lookup_inodev_entry(new_ino, new_dev);
60548 + if (inodev != NULL && ((inode->i_nlink <= 1) || S_ISDIR(inode->i_mode)))
60549 + do_handle_delete(inodev, new_ino, new_dev);
60550 + }
60551 +
60552 + inodev = lookup_inodev_entry(old_ino, old_dev);
60553 + if (inodev != NULL && ((old_dentry->d_inode->i_nlink <= 1) || S_ISDIR(old_dentry->d_inode->i_mode)))
60554 + do_handle_delete(inodev, old_ino, old_dev);
60555 +
60556 + if (unlikely((unsigned long)matchn))
60557 + do_handle_create(matchn, old_dentry, mnt);
60558 +
60559 + write_unlock(&gr_inode_lock);
60560 + preempt_enable();
60561 +
60562 + return;
60563 +}
60564 +
60565 +static int
60566 +lookup_special_role_auth(__u16 mode, const char *rolename, unsigned char **salt,
60567 + unsigned char **sum)
60568 +{
60569 + struct acl_role_label *r;
60570 + struct role_allowed_ip *ipp;
60571 + struct role_transition *trans;
60572 + unsigned int i;
60573 + int found = 0;
60574 + u32 curr_ip = current->signal->curr_ip;
60575 +
60576 + current->signal->saved_ip = curr_ip;
60577 +
60578 + /* check transition table */
60579 +
60580 + for (trans = current->role->transitions; trans; trans = trans->next) {
60581 + if (!strcmp(rolename, trans->rolename)) {
60582 + found = 1;
60583 + break;
60584 + }
60585 + }
60586 +
60587 + if (!found)
60588 + return 0;
60589 +
60590 + /* handle special roles that do not require authentication
60591 + and check ip */
60592 +
60593 + FOR_EACH_ROLE_START(r)
60594 + if (!strcmp(rolename, r->rolename) &&
60595 + (r->roletype & GR_ROLE_SPECIAL)) {
60596 + found = 0;
60597 + if (r->allowed_ips != NULL) {
60598 + for (ipp = r->allowed_ips; ipp; ipp = ipp->next) {
60599 + if ((ntohl(curr_ip) & ipp->netmask) ==
60600 + (ntohl(ipp->addr) & ipp->netmask))
60601 + found = 1;
60602 + }
60603 + } else
60604 + found = 2;
60605 + if (!found)
60606 + return 0;
60607 +
60608 + if (((mode == GR_SPROLE) && (r->roletype & GR_ROLE_NOPW)) ||
60609 + ((mode == GR_SPROLEPAM) && (r->roletype & GR_ROLE_PAM))) {
60610 + *salt = NULL;
60611 + *sum = NULL;
60612 + return 1;
60613 + }
60614 + }
60615 + FOR_EACH_ROLE_END(r)
60616 +
60617 + for (i = 0; i < num_sprole_pws; i++) {
60618 + if (!strcmp(rolename, acl_special_roles[i]->rolename)) {
60619 + *salt = acl_special_roles[i]->salt;
60620 + *sum = acl_special_roles[i]->sum;
60621 + return 1;
60622 + }
60623 + }
60624 +
60625 + return 0;
60626 +}
60627 +
60628 +static void
60629 +assign_special_role(char *rolename)
60630 +{
60631 + struct acl_object_label *obj;
60632 + struct acl_role_label *r;
60633 + struct acl_role_label *assigned = NULL;
60634 + struct task_struct *tsk;
60635 + struct file *filp;
60636 +
60637 + FOR_EACH_ROLE_START(r)
60638 + if (!strcmp(rolename, r->rolename) &&
60639 + (r->roletype & GR_ROLE_SPECIAL)) {
60640 + assigned = r;
60641 + break;
60642 + }
60643 + FOR_EACH_ROLE_END(r)
60644 +
60645 + if (!assigned)
60646 + return;
60647 +
60648 + read_lock(&tasklist_lock);
60649 + read_lock(&grsec_exec_file_lock);
60650 +
60651 + tsk = current->real_parent;
60652 + if (tsk == NULL)
60653 + goto out_unlock;
60654 +
60655 + filp = tsk->exec_file;
60656 + if (filp == NULL)
60657 + goto out_unlock;
60658 +
60659 + tsk->is_writable = 0;
60660 +
60661 + tsk->acl_sp_role = 1;
60662 + tsk->acl_role_id = ++acl_sp_role_value;
60663 + tsk->role = assigned;
60664 + tsk->acl = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, tsk->role);
60665 +
60666 + /* ignore additional mmap checks for processes that are writable
60667 + by the default ACL */
60668 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
60669 + if (unlikely(obj->mode & GR_WRITE))
60670 + tsk->is_writable = 1;
60671 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, tsk->role->root_label);
60672 + if (unlikely(obj->mode & GR_WRITE))
60673 + tsk->is_writable = 1;
60674 +
60675 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
60676 + 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));
60677 +#endif
60678 +
60679 +out_unlock:
60680 + read_unlock(&grsec_exec_file_lock);
60681 + read_unlock(&tasklist_lock);
60682 + return;
60683 +}
60684 +
60685 +int gr_check_secure_terminal(struct task_struct *task)
60686 +{
60687 + struct task_struct *p, *p2, *p3;
60688 + struct files_struct *files;
60689 + struct fdtable *fdt;
60690 + struct file *our_file = NULL, *file;
60691 + int i;
60692 +
60693 + if (task->signal->tty == NULL)
60694 + return 1;
60695 +
60696 + files = get_files_struct(task);
60697 + if (files != NULL) {
60698 + rcu_read_lock();
60699 + fdt = files_fdtable(files);
60700 + for (i=0; i < fdt->max_fds; i++) {
60701 + file = fcheck_files(files, i);
60702 + if (file && (our_file == NULL) && (file->private_data == task->signal->tty)) {
60703 + get_file(file);
60704 + our_file = file;
60705 + }
60706 + }
60707 + rcu_read_unlock();
60708 + put_files_struct(files);
60709 + }
60710 +
60711 + if (our_file == NULL)
60712 + return 1;
60713 +
60714 + read_lock(&tasklist_lock);
60715 + do_each_thread(p2, p) {
60716 + files = get_files_struct(p);
60717 + if (files == NULL ||
60718 + (p->signal && p->signal->tty == task->signal->tty)) {
60719 + if (files != NULL)
60720 + put_files_struct(files);
60721 + continue;
60722 + }
60723 + rcu_read_lock();
60724 + fdt = files_fdtable(files);
60725 + for (i=0; i < fdt->max_fds; i++) {
60726 + file = fcheck_files(files, i);
60727 + if (file && S_ISCHR(file->f_path.dentry->d_inode->i_mode) &&
60728 + file->f_path.dentry->d_inode->i_rdev == our_file->f_path.dentry->d_inode->i_rdev) {
60729 + p3 = task;
60730 + while (task_pid_nr(p3) > 0) {
60731 + if (p3 == p)
60732 + break;
60733 + p3 = p3->real_parent;
60734 + }
60735 + if (p3 == p)
60736 + break;
60737 + gr_log_ttysniff(GR_DONT_AUDIT_GOOD, GR_TTYSNIFF_ACL_MSG, p);
60738 + gr_handle_alertkill(p);
60739 + rcu_read_unlock();
60740 + put_files_struct(files);
60741 + read_unlock(&tasklist_lock);
60742 + fput(our_file);
60743 + return 0;
60744 + }
60745 + }
60746 + rcu_read_unlock();
60747 + put_files_struct(files);
60748 + } while_each_thread(p2, p);
60749 + read_unlock(&tasklist_lock);
60750 +
60751 + fput(our_file);
60752 + return 1;
60753 +}
60754 +
60755 +static int gr_rbac_disable(void *unused)
60756 +{
60757 + pax_open_kernel();
60758 + gr_status &= ~GR_READY;
60759 + pax_close_kernel();
60760 +
60761 + return 0;
60762 +}
60763 +
60764 +ssize_t
60765 +write_grsec_handler(struct file *file, const char * buf, size_t count, loff_t *ppos)
60766 +{
60767 + struct gr_arg_wrapper uwrap;
60768 + unsigned char *sprole_salt = NULL;
60769 + unsigned char *sprole_sum = NULL;
60770 + int error = sizeof (struct gr_arg_wrapper);
60771 + int error2 = 0;
60772 +
60773 + mutex_lock(&gr_dev_mutex);
60774 +
60775 + if ((gr_status & GR_READY) && !(current->acl->mode & GR_KERNELAUTH)) {
60776 + error = -EPERM;
60777 + goto out;
60778 + }
60779 +
60780 + if (count != sizeof (struct gr_arg_wrapper)) {
60781 + gr_log_int_int(GR_DONT_AUDIT_GOOD, GR_DEV_ACL_MSG, (int)count, (int)sizeof(struct gr_arg_wrapper));
60782 + error = -EINVAL;
60783 + goto out;
60784 + }
60785 +
60786 +
60787 + if (gr_auth_expires && time_after_eq(get_seconds(), gr_auth_expires)) {
60788 + gr_auth_expires = 0;
60789 + gr_auth_attempts = 0;
60790 + }
60791 +
60792 + if (copy_from_user(&uwrap, buf, sizeof (struct gr_arg_wrapper))) {
60793 + error = -EFAULT;
60794 + goto out;
60795 + }
60796 +
60797 + if ((uwrap.version != GRSECURITY_VERSION) || (uwrap.size != sizeof(struct gr_arg))) {
60798 + error = -EINVAL;
60799 + goto out;
60800 + }
60801 +
60802 + if (copy_from_user(gr_usermode, uwrap.arg, sizeof (struct gr_arg))) {
60803 + error = -EFAULT;
60804 + goto out;
60805 + }
60806 +
60807 + if (gr_usermode->mode != GR_SPROLE && gr_usermode->mode != GR_SPROLEPAM &&
60808 + gr_auth_attempts >= CONFIG_GRKERNSEC_ACL_MAXTRIES &&
60809 + time_after(gr_auth_expires, get_seconds())) {
60810 + error = -EBUSY;
60811 + goto out;
60812 + }
60813 +
60814 + /* if non-root trying to do anything other than use a special role,
60815 + do not attempt authentication, do not count towards authentication
60816 + locking
60817 + */
60818 +
60819 + if (gr_usermode->mode != GR_SPROLE && gr_usermode->mode != GR_STATUS &&
60820 + gr_usermode->mode != GR_UNSPROLE && gr_usermode->mode != GR_SPROLEPAM &&
60821 + gr_is_global_nonroot(current_uid())) {
60822 + error = -EPERM;
60823 + goto out;
60824 + }
60825 +
60826 + /* ensure pw and special role name are null terminated */
60827 +
60828 + gr_usermode->pw[GR_PW_LEN - 1] = '\0';
60829 + gr_usermode->sp_role[GR_SPROLE_LEN - 1] = '\0';
60830 +
60831 + /* Okay.
60832 + * We have our enough of the argument structure..(we have yet
60833 + * to copy_from_user the tables themselves) . Copy the tables
60834 + * only if we need them, i.e. for loading operations. */
60835 +
60836 + switch (gr_usermode->mode) {
60837 + case GR_STATUS:
60838 + if (gr_status & GR_READY) {
60839 + error = 1;
60840 + if (!gr_check_secure_terminal(current))
60841 + error = 3;
60842 + } else
60843 + error = 2;
60844 + goto out;
60845 + case GR_SHUTDOWN:
60846 + if ((gr_status & GR_READY)
60847 + && !(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
60848 + stop_machine(gr_rbac_disable, NULL, NULL);
60849 + free_variables();
60850 + memset(gr_usermode, 0, sizeof (struct gr_arg));
60851 + memset(gr_system_salt, 0, GR_SALT_LEN);
60852 + memset(gr_system_sum, 0, GR_SHA_LEN);
60853 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SHUTS_ACL_MSG);
60854 + } else if (gr_status & GR_READY) {
60855 + gr_log_noargs(GR_DONT_AUDIT, GR_SHUTF_ACL_MSG);
60856 + error = -EPERM;
60857 + } else {
60858 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SHUTI_ACL_MSG);
60859 + error = -EAGAIN;
60860 + }
60861 + break;
60862 + case GR_ENABLE:
60863 + if (!(gr_status & GR_READY) && !(error2 = gracl_init(gr_usermode)))
60864 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_ENABLE_ACL_MSG, GR_VERSION);
60865 + else {
60866 + if (gr_status & GR_READY)
60867 + error = -EAGAIN;
60868 + else
60869 + error = error2;
60870 + gr_log_str(GR_DONT_AUDIT, GR_ENABLEF_ACL_MSG, GR_VERSION);
60871 + }
60872 + break;
60873 + case GR_RELOAD:
60874 + if (!(gr_status & GR_READY)) {
60875 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_RELOADI_ACL_MSG, GR_VERSION);
60876 + error = -EAGAIN;
60877 + } else if (!(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
60878 + stop_machine(gr_rbac_disable, NULL, NULL);
60879 + free_variables();
60880 + error2 = gracl_init(gr_usermode);
60881 + if (!error2)
60882 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_RELOAD_ACL_MSG, GR_VERSION);
60883 + else {
60884 + gr_log_str(GR_DONT_AUDIT, GR_RELOADF_ACL_MSG, GR_VERSION);
60885 + error = error2;
60886 + }
60887 + } else {
60888 + gr_log_str(GR_DONT_AUDIT, GR_RELOADF_ACL_MSG, GR_VERSION);
60889 + error = -EPERM;
60890 + }
60891 + break;
60892 + case GR_SEGVMOD:
60893 + if (unlikely(!(gr_status & GR_READY))) {
60894 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SEGVMODI_ACL_MSG);
60895 + error = -EAGAIN;
60896 + break;
60897 + }
60898 +
60899 + if (!(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
60900 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SEGVMODS_ACL_MSG);
60901 + if (gr_usermode->segv_device && gr_usermode->segv_inode) {
60902 + struct acl_subject_label *segvacl;
60903 + segvacl =
60904 + lookup_acl_subj_label(gr_usermode->segv_inode,
60905 + gr_usermode->segv_device,
60906 + current->role);
60907 + if (segvacl) {
60908 + segvacl->crashes = 0;
60909 + segvacl->expires = 0;
60910 + }
60911 + } else if (gr_find_uid(gr_usermode->segv_uid) >= 0) {
60912 + gr_remove_uid(gr_usermode->segv_uid);
60913 + }
60914 + } else {
60915 + gr_log_noargs(GR_DONT_AUDIT, GR_SEGVMODF_ACL_MSG);
60916 + error = -EPERM;
60917 + }
60918 + break;
60919 + case GR_SPROLE:
60920 + case GR_SPROLEPAM:
60921 + if (unlikely(!(gr_status & GR_READY))) {
60922 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SPROLEI_ACL_MSG);
60923 + error = -EAGAIN;
60924 + break;
60925 + }
60926 +
60927 + if (current->role->expires && time_after_eq(get_seconds(), current->role->expires)) {
60928 + current->role->expires = 0;
60929 + current->role->auth_attempts = 0;
60930 + }
60931 +
60932 + if (current->role->auth_attempts >= CONFIG_GRKERNSEC_ACL_MAXTRIES &&
60933 + time_after(current->role->expires, get_seconds())) {
60934 + error = -EBUSY;
60935 + goto out;
60936 + }
60937 +
60938 + if (lookup_special_role_auth
60939 + (gr_usermode->mode, gr_usermode->sp_role, &sprole_salt, &sprole_sum)
60940 + && ((!sprole_salt && !sprole_sum)
60941 + || !(chkpw(gr_usermode, sprole_salt, sprole_sum)))) {
60942 + char *p = "";
60943 + assign_special_role(gr_usermode->sp_role);
60944 + read_lock(&tasklist_lock);
60945 + if (current->real_parent)
60946 + p = current->real_parent->role->rolename;
60947 + read_unlock(&tasklist_lock);
60948 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_SPROLES_ACL_MSG,
60949 + p, acl_sp_role_value);
60950 + } else {
60951 + gr_log_str(GR_DONT_AUDIT, GR_SPROLEF_ACL_MSG, gr_usermode->sp_role);
60952 + error = -EPERM;
60953 + if(!(current->role->auth_attempts++))
60954 + current->role->expires = get_seconds() + CONFIG_GRKERNSEC_ACL_TIMEOUT;
60955 +
60956 + goto out;
60957 + }
60958 + break;
60959 + case GR_UNSPROLE:
60960 + if (unlikely(!(gr_status & GR_READY))) {
60961 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_UNSPROLEI_ACL_MSG);
60962 + error = -EAGAIN;
60963 + break;
60964 + }
60965 +
60966 + if (current->role->roletype & GR_ROLE_SPECIAL) {
60967 + char *p = "";
60968 + int i = 0;
60969 +
60970 + read_lock(&tasklist_lock);
60971 + if (current->real_parent) {
60972 + p = current->real_parent->role->rolename;
60973 + i = current->real_parent->acl_role_id;
60974 + }
60975 + read_unlock(&tasklist_lock);
60976 +
60977 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_UNSPROLES_ACL_MSG, p, i);
60978 + gr_set_acls(1);
60979 + } else {
60980 + error = -EPERM;
60981 + goto out;
60982 + }
60983 + break;
60984 + default:
60985 + gr_log_int(GR_DONT_AUDIT, GR_INVMODE_ACL_MSG, gr_usermode->mode);
60986 + error = -EINVAL;
60987 + break;
60988 + }
60989 +
60990 + if (error != -EPERM)
60991 + goto out;
60992 +
60993 + if(!(gr_auth_attempts++))
60994 + gr_auth_expires = get_seconds() + CONFIG_GRKERNSEC_ACL_TIMEOUT;
60995 +
60996 + out:
60997 + mutex_unlock(&gr_dev_mutex);
60998 + return error;
60999 +}
61000 +
61001 +/* must be called with
61002 + rcu_read_lock();
61003 + read_lock(&tasklist_lock);
61004 + read_lock(&grsec_exec_file_lock);
61005 +*/
61006 +int gr_apply_subject_to_task(struct task_struct *task)
61007 +{
61008 + struct acl_object_label *obj;
61009 + char *tmpname;
61010 + struct acl_subject_label *tmpsubj;
61011 + struct file *filp;
61012 + struct name_entry *nmatch;
61013 +
61014 + filp = task->exec_file;
61015 + if (filp == NULL)
61016 + return 0;
61017 +
61018 + /* the following is to apply the correct subject
61019 + on binaries running when the RBAC system
61020 + is enabled, when the binaries have been
61021 + replaced or deleted since their execution
61022 + -----
61023 + when the RBAC system starts, the inode/dev
61024 + from exec_file will be one the RBAC system
61025 + is unaware of. It only knows the inode/dev
61026 + of the present file on disk, or the absence
61027 + of it.
61028 + */
61029 + preempt_disable();
61030 + tmpname = gr_to_filename_rbac(filp->f_path.dentry, filp->f_path.mnt);
61031 +
61032 + nmatch = lookup_name_entry(tmpname);
61033 + preempt_enable();
61034 + tmpsubj = NULL;
61035 + if (nmatch) {
61036 + if (nmatch->deleted)
61037 + tmpsubj = lookup_acl_subj_label_deleted(nmatch->inode, nmatch->device, task->role);
61038 + else
61039 + tmpsubj = lookup_acl_subj_label(nmatch->inode, nmatch->device, task->role);
61040 + if (tmpsubj != NULL)
61041 + task->acl = tmpsubj;
61042 + }
61043 + if (tmpsubj == NULL)
61044 + task->acl = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt,
61045 + task->role);
61046 + if (task->acl) {
61047 + task->is_writable = 0;
61048 + /* ignore additional mmap checks for processes that are writable
61049 + by the default ACL */
61050 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
61051 + if (unlikely(obj->mode & GR_WRITE))
61052 + task->is_writable = 1;
61053 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, task->role->root_label);
61054 + if (unlikely(obj->mode & GR_WRITE))
61055 + task->is_writable = 1;
61056 +
61057 + gr_set_proc_res(task);
61058 +
61059 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
61060 + 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);
61061 +#endif
61062 + } else {
61063 + return 1;
61064 + }
61065 +
61066 + return 0;
61067 +}
61068 +
61069 +int
61070 +gr_set_acls(const int type)
61071 +{
61072 + struct task_struct *task, *task2;
61073 + struct acl_role_label *role = current->role;
61074 + __u16 acl_role_id = current->acl_role_id;
61075 + const struct cred *cred;
61076 + int ret;
61077 +
61078 + rcu_read_lock();
61079 + read_lock(&tasklist_lock);
61080 + read_lock(&grsec_exec_file_lock);
61081 + do_each_thread(task2, task) {
61082 + /* check to see if we're called from the exit handler,
61083 + if so, only replace ACLs that have inherited the admin
61084 + ACL */
61085 +
61086 + if (type && (task->role != role ||
61087 + task->acl_role_id != acl_role_id))
61088 + continue;
61089 +
61090 + task->acl_role_id = 0;
61091 + task->acl_sp_role = 0;
61092 +
61093 + if (task->exec_file) {
61094 + cred = __task_cred(task);
61095 + task->role = lookup_acl_role_label(task, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid));
61096 + ret = gr_apply_subject_to_task(task);
61097 + if (ret) {
61098 + read_unlock(&grsec_exec_file_lock);
61099 + read_unlock(&tasklist_lock);
61100 + rcu_read_unlock();
61101 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_DEFACL_MSG, task->comm, task_pid_nr(task));
61102 + return ret;
61103 + }
61104 + } else {
61105 + // it's a kernel process
61106 + task->role = kernel_role;
61107 + task->acl = kernel_role->root_label;
61108 +#ifdef CONFIG_GRKERNSEC_ACL_HIDEKERN
61109 + task->acl->mode &= ~GR_PROCFIND;
61110 +#endif
61111 + }
61112 + } while_each_thread(task2, task);
61113 + read_unlock(&grsec_exec_file_lock);
61114 + read_unlock(&tasklist_lock);
61115 + rcu_read_unlock();
61116 +
61117 + return 0;
61118 +}
61119 +
61120 +#if defined(CONFIG_GRKERNSEC_RESLOG) || !defined(CONFIG_GRKERNSEC_NO_RBAC)
61121 +static const unsigned long res_learn_bumps[GR_NLIMITS] = {
61122 + [RLIMIT_CPU] = GR_RLIM_CPU_BUMP,
61123 + [RLIMIT_FSIZE] = GR_RLIM_FSIZE_BUMP,
61124 + [RLIMIT_DATA] = GR_RLIM_DATA_BUMP,
61125 + [RLIMIT_STACK] = GR_RLIM_STACK_BUMP,
61126 + [RLIMIT_CORE] = GR_RLIM_CORE_BUMP,
61127 + [RLIMIT_RSS] = GR_RLIM_RSS_BUMP,
61128 + [RLIMIT_NPROC] = GR_RLIM_NPROC_BUMP,
61129 + [RLIMIT_NOFILE] = GR_RLIM_NOFILE_BUMP,
61130 + [RLIMIT_MEMLOCK] = GR_RLIM_MEMLOCK_BUMP,
61131 + [RLIMIT_AS] = GR_RLIM_AS_BUMP,
61132 + [RLIMIT_LOCKS] = GR_RLIM_LOCKS_BUMP,
61133 + [RLIMIT_SIGPENDING] = GR_RLIM_SIGPENDING_BUMP,
61134 + [RLIMIT_MSGQUEUE] = GR_RLIM_MSGQUEUE_BUMP,
61135 + [RLIMIT_NICE] = GR_RLIM_NICE_BUMP,
61136 + [RLIMIT_RTPRIO] = GR_RLIM_RTPRIO_BUMP,
61137 + [RLIMIT_RTTIME] = GR_RLIM_RTTIME_BUMP
61138 +};
61139 +
61140 +void
61141 +gr_learn_resource(const struct task_struct *task,
61142 + const int res, const unsigned long wanted, const int gt)
61143 +{
61144 + struct acl_subject_label *acl;
61145 + const struct cred *cred;
61146 +
61147 + if (unlikely((gr_status & GR_READY) &&
61148 + task->acl && (task->acl->mode & (GR_LEARN | GR_INHERITLEARN))))
61149 + goto skip_reslog;
61150 +
61151 + gr_log_resource(task, res, wanted, gt);
61152 +skip_reslog:
61153 +
61154 + if (unlikely(!(gr_status & GR_READY) || !wanted || res >= GR_NLIMITS))
61155 + return;
61156 +
61157 + acl = task->acl;
61158 +
61159 + if (likely(!acl || !(acl->mode & (GR_LEARN | GR_INHERITLEARN)) ||
61160 + !(acl->resmask & (1U << (unsigned short) res))))
61161 + return;
61162 +
61163 + if (wanted >= acl->res[res].rlim_cur) {
61164 + unsigned long res_add;
61165 +
61166 + res_add = wanted + res_learn_bumps[res];
61167 +
61168 + acl->res[res].rlim_cur = res_add;
61169 +
61170 + if (wanted > acl->res[res].rlim_max)
61171 + acl->res[res].rlim_max = res_add;
61172 +
61173 + /* only log the subject filename, since resource logging is supported for
61174 + single-subject learning only */
61175 + rcu_read_lock();
61176 + cred = __task_cred(task);
61177 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename,
61178 + task->role->roletype, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), acl->filename,
61179 + acl->filename, acl->res[res].rlim_cur, acl->res[res].rlim_max,
61180 + "", (unsigned long) res, &task->signal->saved_ip);
61181 + rcu_read_unlock();
61182 + }
61183 +
61184 + return;
61185 +}
61186 +EXPORT_SYMBOL(gr_learn_resource);
61187 +#endif
61188 +
61189 +#if defined(CONFIG_PAX_HAVE_ACL_FLAGS) && (defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR))
61190 +void
61191 +pax_set_initial_flags(struct linux_binprm *bprm)
61192 +{
61193 + struct task_struct *task = current;
61194 + struct acl_subject_label *proc;
61195 + unsigned long flags;
61196 +
61197 + if (unlikely(!(gr_status & GR_READY)))
61198 + return;
61199 +
61200 + flags = pax_get_flags(task);
61201 +
61202 + proc = task->acl;
61203 +
61204 + if (proc->pax_flags & GR_PAX_DISABLE_PAGEEXEC)
61205 + flags &= ~MF_PAX_PAGEEXEC;
61206 + if (proc->pax_flags & GR_PAX_DISABLE_SEGMEXEC)
61207 + flags &= ~MF_PAX_SEGMEXEC;
61208 + if (proc->pax_flags & GR_PAX_DISABLE_RANDMMAP)
61209 + flags &= ~MF_PAX_RANDMMAP;
61210 + if (proc->pax_flags & GR_PAX_DISABLE_EMUTRAMP)
61211 + flags &= ~MF_PAX_EMUTRAMP;
61212 + if (proc->pax_flags & GR_PAX_DISABLE_MPROTECT)
61213 + flags &= ~MF_PAX_MPROTECT;
61214 +
61215 + if (proc->pax_flags & GR_PAX_ENABLE_PAGEEXEC)
61216 + flags |= MF_PAX_PAGEEXEC;
61217 + if (proc->pax_flags & GR_PAX_ENABLE_SEGMEXEC)
61218 + flags |= MF_PAX_SEGMEXEC;
61219 + if (proc->pax_flags & GR_PAX_ENABLE_RANDMMAP)
61220 + flags |= MF_PAX_RANDMMAP;
61221 + if (proc->pax_flags & GR_PAX_ENABLE_EMUTRAMP)
61222 + flags |= MF_PAX_EMUTRAMP;
61223 + if (proc->pax_flags & GR_PAX_ENABLE_MPROTECT)
61224 + flags |= MF_PAX_MPROTECT;
61225 +
61226 + pax_set_flags(task, flags);
61227 +
61228 + return;
61229 +}
61230 +#endif
61231 +
61232 +int
61233 +gr_handle_proc_ptrace(struct task_struct *task)
61234 +{
61235 + struct file *filp;
61236 + struct task_struct *tmp = task;
61237 + struct task_struct *curtemp = current;
61238 + __u32 retmode;
61239 +
61240 +#ifndef CONFIG_GRKERNSEC_HARDEN_PTRACE
61241 + if (unlikely(!(gr_status & GR_READY)))
61242 + return 0;
61243 +#endif
61244 +
61245 + read_lock(&tasklist_lock);
61246 + read_lock(&grsec_exec_file_lock);
61247 + filp = task->exec_file;
61248 +
61249 + while (task_pid_nr(tmp) > 0) {
61250 + if (tmp == curtemp)
61251 + break;
61252 + tmp = tmp->real_parent;
61253 + }
61254 +
61255 + if (!filp || (task_pid_nr(tmp) == 0 && ((grsec_enable_harden_ptrace && gr_is_global_nonroot(current_uid()) && !(gr_status & GR_READY)) ||
61256 + ((gr_status & GR_READY) && !(current->acl->mode & GR_RELAXPTRACE))))) {
61257 + read_unlock(&grsec_exec_file_lock);
61258 + read_unlock(&tasklist_lock);
61259 + return 1;
61260 + }
61261 +
61262 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
61263 + if (!(gr_status & GR_READY)) {
61264 + read_unlock(&grsec_exec_file_lock);
61265 + read_unlock(&tasklist_lock);
61266 + return 0;
61267 + }
61268 +#endif
61269 +
61270 + retmode = gr_search_file(filp->f_path.dentry, GR_NOPTRACE, filp->f_path.mnt);
61271 + read_unlock(&grsec_exec_file_lock);
61272 + read_unlock(&tasklist_lock);
61273 +
61274 + if (retmode & GR_NOPTRACE)
61275 + return 1;
61276 +
61277 + if (!(current->acl->mode & GR_POVERRIDE) && !(current->role->roletype & GR_ROLE_GOD)
61278 + && (current->acl != task->acl || (current->acl != current->role->root_label
61279 + && task_pid_nr(current) != task_pid_nr(task))))
61280 + return 1;
61281 +
61282 + return 0;
61283 +}
61284 +
61285 +void task_grsec_rbac(struct seq_file *m, struct task_struct *p)
61286 +{
61287 + if (unlikely(!(gr_status & GR_READY)))
61288 + return;
61289 +
61290 + if (!(current->role->roletype & GR_ROLE_GOD))
61291 + return;
61292 +
61293 + seq_printf(m, "RBAC:\t%.64s:%c:%.950s\n",
61294 + p->role->rolename, gr_task_roletype_to_char(p),
61295 + p->acl->filename);
61296 +}
61297 +
61298 +int
61299 +gr_handle_ptrace(struct task_struct *task, const long request)
61300 +{
61301 + struct task_struct *tmp = task;
61302 + struct task_struct *curtemp = current;
61303 + __u32 retmode;
61304 +
61305 +#ifndef CONFIG_GRKERNSEC_HARDEN_PTRACE
61306 + if (unlikely(!(gr_status & GR_READY)))
61307 + return 0;
61308 +#endif
61309 + if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
61310 + read_lock(&tasklist_lock);
61311 + while (task_pid_nr(tmp) > 0) {
61312 + if (tmp == curtemp)
61313 + break;
61314 + tmp = tmp->real_parent;
61315 + }
61316 +
61317 + if (task_pid_nr(tmp) == 0 && ((grsec_enable_harden_ptrace && gr_is_global_nonroot(current_uid()) && !(gr_status & GR_READY)) ||
61318 + ((gr_status & GR_READY) && !(current->acl->mode & GR_RELAXPTRACE)))) {
61319 + read_unlock(&tasklist_lock);
61320 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
61321 + return 1;
61322 + }
61323 + read_unlock(&tasklist_lock);
61324 + }
61325 +
61326 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
61327 + if (!(gr_status & GR_READY))
61328 + return 0;
61329 +#endif
61330 +
61331 + read_lock(&grsec_exec_file_lock);
61332 + if (unlikely(!task->exec_file)) {
61333 + read_unlock(&grsec_exec_file_lock);
61334 + return 0;
61335 + }
61336 +
61337 + retmode = gr_search_file(task->exec_file->f_path.dentry, GR_PTRACERD | GR_NOPTRACE, task->exec_file->f_path.mnt);
61338 + read_unlock(&grsec_exec_file_lock);
61339 +
61340 + if (retmode & GR_NOPTRACE) {
61341 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
61342 + return 1;
61343 + }
61344 +
61345 + if (retmode & GR_PTRACERD) {
61346 + switch (request) {
61347 + case PTRACE_SEIZE:
61348 + case PTRACE_POKETEXT:
61349 + case PTRACE_POKEDATA:
61350 + case PTRACE_POKEUSR:
61351 +#if !defined(CONFIG_PPC32) && !defined(CONFIG_PPC64) && !defined(CONFIG_PARISC) && !defined(CONFIG_ALPHA) && !defined(CONFIG_IA64)
61352 + case PTRACE_SETREGS:
61353 + case PTRACE_SETFPREGS:
61354 +#endif
61355 +#ifdef CONFIG_X86
61356 + case PTRACE_SETFPXREGS:
61357 +#endif
61358 +#ifdef CONFIG_ALTIVEC
61359 + case PTRACE_SETVRREGS:
61360 +#endif
61361 + return 1;
61362 + default:
61363 + return 0;
61364 + }
61365 + } else if (!(current->acl->mode & GR_POVERRIDE) &&
61366 + !(current->role->roletype & GR_ROLE_GOD) &&
61367 + (current->acl != task->acl)) {
61368 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
61369 + return 1;
61370 + }
61371 +
61372 + return 0;
61373 +}
61374 +
61375 +static int is_writable_mmap(const struct file *filp)
61376 +{
61377 + struct task_struct *task = current;
61378 + struct acl_object_label *obj, *obj2;
61379 +
61380 + if (gr_status & GR_READY && !(task->acl->mode & GR_OVERRIDE) &&
61381 + !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))) {
61382 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
61383 + obj2 = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt,
61384 + task->role->root_label);
61385 + if (unlikely((obj->mode & GR_WRITE) || (obj2->mode & GR_WRITE))) {
61386 + gr_log_fs_generic(GR_DONT_AUDIT, GR_WRITLIB_ACL_MSG, filp->f_path.dentry, filp->f_path.mnt);
61387 + return 1;
61388 + }
61389 + }
61390 + return 0;
61391 +}
61392 +
61393 +int
61394 +gr_acl_handle_mmap(const struct file *file, const unsigned long prot)
61395 +{
61396 + __u32 mode;
61397 +
61398 + if (unlikely(!file || !(prot & PROT_EXEC)))
61399 + return 1;
61400 +
61401 + if (is_writable_mmap(file))
61402 + return 0;
61403 +
61404 + mode =
61405 + gr_search_file(file->f_path.dentry,
61406 + GR_EXEC | GR_AUDIT_EXEC | GR_SUPPRESS,
61407 + file->f_path.mnt);
61408 +
61409 + if (!gr_tpe_allow(file))
61410 + return 0;
61411 +
61412 + if (unlikely(!(mode & GR_EXEC) && !(mode & GR_SUPPRESS))) {
61413 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_MMAP_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
61414 + return 0;
61415 + } else if (unlikely(!(mode & GR_EXEC))) {
61416 + return 0;
61417 + } else if (unlikely(mode & GR_EXEC && mode & GR_AUDIT_EXEC)) {
61418 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_MMAP_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
61419 + return 1;
61420 + }
61421 +
61422 + return 1;
61423 +}
61424 +
61425 +int
61426 +gr_acl_handle_mprotect(const struct file *file, const unsigned long prot)
61427 +{
61428 + __u32 mode;
61429 +
61430 + if (unlikely(!file || !(prot & PROT_EXEC)))
61431 + return 1;
61432 +
61433 + if (is_writable_mmap(file))
61434 + return 0;
61435 +
61436 + mode =
61437 + gr_search_file(file->f_path.dentry,
61438 + GR_EXEC | GR_AUDIT_EXEC | GR_SUPPRESS,
61439 + file->f_path.mnt);
61440 +
61441 + if (!gr_tpe_allow(file))
61442 + return 0;
61443 +
61444 + if (unlikely(!(mode & GR_EXEC) && !(mode & GR_SUPPRESS))) {
61445 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_MPROTECT_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
61446 + return 0;
61447 + } else if (unlikely(!(mode & GR_EXEC))) {
61448 + return 0;
61449 + } else if (unlikely(mode & GR_EXEC && mode & GR_AUDIT_EXEC)) {
61450 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_MPROTECT_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
61451 + return 1;
61452 + }
61453 +
61454 + return 1;
61455 +}
61456 +
61457 +void
61458 +gr_acl_handle_psacct(struct task_struct *task, const long code)
61459 +{
61460 + unsigned long runtime;
61461 + unsigned long cputime;
61462 + unsigned int wday, cday;
61463 + __u8 whr, chr;
61464 + __u8 wmin, cmin;
61465 + __u8 wsec, csec;
61466 + struct timespec timeval;
61467 +
61468 + if (unlikely(!(gr_status & GR_READY) || !task->acl ||
61469 + !(task->acl->mode & GR_PROCACCT)))
61470 + return;
61471 +
61472 + do_posix_clock_monotonic_gettime(&timeval);
61473 + runtime = timeval.tv_sec - task->start_time.tv_sec;
61474 + wday = runtime / (3600 * 24);
61475 + runtime -= wday * (3600 * 24);
61476 + whr = runtime / 3600;
61477 + runtime -= whr * 3600;
61478 + wmin = runtime / 60;
61479 + runtime -= wmin * 60;
61480 + wsec = runtime;
61481 +
61482 + cputime = (task->utime + task->stime) / HZ;
61483 + cday = cputime / (3600 * 24);
61484 + cputime -= cday * (3600 * 24);
61485 + chr = cputime / 3600;
61486 + cputime -= chr * 3600;
61487 + cmin = cputime / 60;
61488 + cputime -= cmin * 60;
61489 + csec = cputime;
61490 +
61491 + gr_log_procacct(GR_DO_AUDIT, GR_ACL_PROCACCT_MSG, task, wday, whr, wmin, wsec, cday, chr, cmin, csec, code);
61492 +
61493 + return;
61494 +}
61495 +
61496 +void gr_set_kernel_label(struct task_struct *task)
61497 +{
61498 + if (gr_status & GR_READY) {
61499 + task->role = kernel_role;
61500 + task->acl = kernel_role->root_label;
61501 + }
61502 + return;
61503 +}
61504 +
61505 +#ifdef CONFIG_TASKSTATS
61506 +int gr_is_taskstats_denied(int pid)
61507 +{
61508 + struct task_struct *task;
61509 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
61510 + const struct cred *cred;
61511 +#endif
61512 + int ret = 0;
61513 +
61514 + /* restrict taskstats viewing to un-chrooted root users
61515 + who have the 'view' subject flag if the RBAC system is enabled
61516 + */
61517 +
61518 + rcu_read_lock();
61519 + read_lock(&tasklist_lock);
61520 + task = find_task_by_vpid(pid);
61521 + if (task) {
61522 +#ifdef CONFIG_GRKERNSEC_CHROOT
61523 + if (proc_is_chrooted(task))
61524 + ret = -EACCES;
61525 +#endif
61526 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
61527 + cred = __task_cred(task);
61528 +#ifdef CONFIG_GRKERNSEC_PROC_USER
61529 + if (gr_is_global_nonroot(cred->uid))
61530 + ret = -EACCES;
61531 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
61532 + if (gr_is_global_nonroot(cred->uid) && !groups_search(cred->group_info, grsec_proc_gid))
61533 + ret = -EACCES;
61534 +#endif
61535 +#endif
61536 + if (gr_status & GR_READY) {
61537 + if (!(task->acl->mode & GR_VIEW))
61538 + ret = -EACCES;
61539 + }
61540 + } else
61541 + ret = -ENOENT;
61542 +
61543 + read_unlock(&tasklist_lock);
61544 + rcu_read_unlock();
61545 +
61546 + return ret;
61547 +}
61548 +#endif
61549 +
61550 +/* AUXV entries are filled via a descendant of search_binary_handler
61551 + after we've already applied the subject for the target
61552 +*/
61553 +int gr_acl_enable_at_secure(void)
61554 +{
61555 + if (unlikely(!(gr_status & GR_READY)))
61556 + return 0;
61557 +
61558 + if (current->acl->mode & GR_ATSECURE)
61559 + return 1;
61560 +
61561 + return 0;
61562 +}
61563 +
61564 +int gr_acl_handle_filldir(const struct file *file, const char *name, const unsigned int namelen, const ino_t ino)
61565 +{
61566 + struct task_struct *task = current;
61567 + struct dentry *dentry = file->f_path.dentry;
61568 + struct vfsmount *mnt = file->f_path.mnt;
61569 + struct acl_object_label *obj, *tmp;
61570 + struct acl_subject_label *subj;
61571 + unsigned int bufsize;
61572 + int is_not_root;
61573 + char *path;
61574 + dev_t dev = __get_dev(dentry);
61575 +
61576 + if (unlikely(!(gr_status & GR_READY)))
61577 + return 1;
61578 +
61579 + if (task->acl->mode & (GR_LEARN | GR_INHERITLEARN))
61580 + return 1;
61581 +
61582 + /* ignore Eric Biederman */
61583 + if (IS_PRIVATE(dentry->d_inode))
61584 + return 1;
61585 +
61586 + subj = task->acl;
61587 + read_lock(&gr_inode_lock);
61588 + do {
61589 + obj = lookup_acl_obj_label(ino, dev, subj);
61590 + if (obj != NULL) {
61591 + read_unlock(&gr_inode_lock);
61592 + return (obj->mode & GR_FIND) ? 1 : 0;
61593 + }
61594 + } while ((subj = subj->parent_subject));
61595 + read_unlock(&gr_inode_lock);
61596 +
61597 + /* this is purely an optimization since we're looking for an object
61598 + for the directory we're doing a readdir on
61599 + if it's possible for any globbed object to match the entry we're
61600 + filling into the directory, then the object we find here will be
61601 + an anchor point with attached globbed objects
61602 + */
61603 + obj = chk_obj_label_noglob(dentry, mnt, task->acl);
61604 + if (obj->globbed == NULL)
61605 + return (obj->mode & GR_FIND) ? 1 : 0;
61606 +
61607 + is_not_root = ((obj->filename[0] == '/') &&
61608 + (obj->filename[1] == '\0')) ? 0 : 1;
61609 + bufsize = PAGE_SIZE - namelen - is_not_root;
61610 +
61611 + /* check bufsize > PAGE_SIZE || bufsize == 0 */
61612 + if (unlikely((bufsize - 1) > (PAGE_SIZE - 1)))
61613 + return 1;
61614 +
61615 + preempt_disable();
61616 + path = d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0], smp_processor_id()),
61617 + bufsize);
61618 +
61619 + bufsize = strlen(path);
61620 +
61621 + /* if base is "/", don't append an additional slash */
61622 + if (is_not_root)
61623 + *(path + bufsize) = '/';
61624 + memcpy(path + bufsize + is_not_root, name, namelen);
61625 + *(path + bufsize + namelen + is_not_root) = '\0';
61626 +
61627 + tmp = obj->globbed;
61628 + while (tmp) {
61629 + if (!glob_match(tmp->filename, path)) {
61630 + preempt_enable();
61631 + return (tmp->mode & GR_FIND) ? 1 : 0;
61632 + }
61633 + tmp = tmp->next;
61634 + }
61635 + preempt_enable();
61636 + return (obj->mode & GR_FIND) ? 1 : 0;
61637 +}
61638 +
61639 +void gr_put_exec_file(struct task_struct *task)
61640 +{
61641 + struct file *filp;
61642 +
61643 + write_lock(&grsec_exec_file_lock);
61644 + filp = task->exec_file;
61645 + task->exec_file = NULL;
61646 + write_unlock(&grsec_exec_file_lock);
61647 +
61648 + if (filp)
61649 + fput(filp);
61650 +
61651 + return;
61652 +}
61653 +
61654 +
61655 +#ifdef CONFIG_NETFILTER_XT_MATCH_GRADM_MODULE
61656 +EXPORT_SYMBOL(gr_acl_is_enabled);
61657 +#endif
61658 +EXPORT_SYMBOL(gr_set_kernel_label);
61659 +#ifdef CONFIG_SECURITY
61660 +EXPORT_SYMBOL(gr_check_user_change);
61661 +EXPORT_SYMBOL(gr_check_group_change);
61662 +#endif
61663 +
61664 diff --git a/grsecurity/gracl_alloc.c b/grsecurity/gracl_alloc.c
61665 new file mode 100644
61666 index 0000000..34fefda
61667 --- /dev/null
61668 +++ b/grsecurity/gracl_alloc.c
61669 @@ -0,0 +1,105 @@
61670 +#include <linux/kernel.h>
61671 +#include <linux/mm.h>
61672 +#include <linux/slab.h>
61673 +#include <linux/vmalloc.h>
61674 +#include <linux/gracl.h>
61675 +#include <linux/grsecurity.h>
61676 +
61677 +static unsigned long alloc_stack_next = 1;
61678 +static unsigned long alloc_stack_size = 1;
61679 +static void **alloc_stack;
61680 +
61681 +static __inline__ int
61682 +alloc_pop(void)
61683 +{
61684 + if (alloc_stack_next == 1)
61685 + return 0;
61686 +
61687 + kfree(alloc_stack[alloc_stack_next - 2]);
61688 +
61689 + alloc_stack_next--;
61690 +
61691 + return 1;
61692 +}
61693 +
61694 +static __inline__ int
61695 +alloc_push(void *buf)
61696 +{
61697 + if (alloc_stack_next >= alloc_stack_size)
61698 + return 1;
61699 +
61700 + alloc_stack[alloc_stack_next - 1] = buf;
61701 +
61702 + alloc_stack_next++;
61703 +
61704 + return 0;
61705 +}
61706 +
61707 +void *
61708 +acl_alloc(unsigned long len)
61709 +{
61710 + void *ret = NULL;
61711 +
61712 + if (!len || len > PAGE_SIZE)
61713 + goto out;
61714 +
61715 + ret = kmalloc(len, GFP_KERNEL);
61716 +
61717 + if (ret) {
61718 + if (alloc_push(ret)) {
61719 + kfree(ret);
61720 + ret = NULL;
61721 + }
61722 + }
61723 +
61724 +out:
61725 + return ret;
61726 +}
61727 +
61728 +void *
61729 +acl_alloc_num(unsigned long num, unsigned long len)
61730 +{
61731 + if (!len || (num > (PAGE_SIZE / len)))
61732 + return NULL;
61733 +
61734 + return acl_alloc(num * len);
61735 +}
61736 +
61737 +void
61738 +acl_free_all(void)
61739 +{
61740 + if (gr_acl_is_enabled() || !alloc_stack)
61741 + return;
61742 +
61743 + while (alloc_pop()) ;
61744 +
61745 + if (alloc_stack) {
61746 + if ((alloc_stack_size * sizeof (void *)) <= PAGE_SIZE)
61747 + kfree(alloc_stack);
61748 + else
61749 + vfree(alloc_stack);
61750 + }
61751 +
61752 + alloc_stack = NULL;
61753 + alloc_stack_size = 1;
61754 + alloc_stack_next = 1;
61755 +
61756 + return;
61757 +}
61758 +
61759 +int
61760 +acl_alloc_stack_init(unsigned long size)
61761 +{
61762 + if ((size * sizeof (void *)) <= PAGE_SIZE)
61763 + alloc_stack =
61764 + (void **) kmalloc(size * sizeof (void *), GFP_KERNEL);
61765 + else
61766 + alloc_stack = (void **) vmalloc(size * sizeof (void *));
61767 +
61768 + alloc_stack_size = size;
61769 +
61770 + if (!alloc_stack)
61771 + return 0;
61772 + else
61773 + return 1;
61774 +}
61775 diff --git a/grsecurity/gracl_cap.c b/grsecurity/gracl_cap.c
61776 new file mode 100644
61777 index 0000000..bdd51ea
61778 --- /dev/null
61779 +++ b/grsecurity/gracl_cap.c
61780 @@ -0,0 +1,110 @@
61781 +#include <linux/kernel.h>
61782 +#include <linux/module.h>
61783 +#include <linux/sched.h>
61784 +#include <linux/gracl.h>
61785 +#include <linux/grsecurity.h>
61786 +#include <linux/grinternal.h>
61787 +
61788 +extern const char *captab_log[];
61789 +extern int captab_log_entries;
61790 +
61791 +int gr_task_acl_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
61792 +{
61793 + struct acl_subject_label *curracl;
61794 + kernel_cap_t cap_drop = __cap_empty_set, cap_mask = __cap_empty_set;
61795 + kernel_cap_t cap_audit = __cap_empty_set;
61796 +
61797 + if (!gr_acl_is_enabled())
61798 + return 1;
61799 +
61800 + curracl = task->acl;
61801 +
61802 + cap_drop = curracl->cap_lower;
61803 + cap_mask = curracl->cap_mask;
61804 + cap_audit = curracl->cap_invert_audit;
61805 +
61806 + while ((curracl = curracl->parent_subject)) {
61807 + /* if the cap isn't specified in the current computed mask but is specified in the
61808 + current level subject, and is lowered in the current level subject, then add
61809 + it to the set of dropped capabilities
61810 + otherwise, add the current level subject's mask to the current computed mask
61811 + */
61812 + if (!cap_raised(cap_mask, cap) && cap_raised(curracl->cap_mask, cap)) {
61813 + cap_raise(cap_mask, cap);
61814 + if (cap_raised(curracl->cap_lower, cap))
61815 + cap_raise(cap_drop, cap);
61816 + if (cap_raised(curracl->cap_invert_audit, cap))
61817 + cap_raise(cap_audit, cap);
61818 + }
61819 + }
61820 +
61821 + if (!cap_raised(cap_drop, cap)) {
61822 + if (cap_raised(cap_audit, cap))
61823 + gr_log_cap(GR_DO_AUDIT, GR_CAP_ACL_MSG2, task, captab_log[cap]);
61824 + return 1;
61825 + }
61826 +
61827 + curracl = task->acl;
61828 +
61829 + if ((curracl->mode & (GR_LEARN | GR_INHERITLEARN))
61830 + && cap_raised(cred->cap_effective, cap)) {
61831 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename,
61832 + task->role->roletype, GR_GLOBAL_UID(cred->uid),
61833 + GR_GLOBAL_GID(cred->gid), task->exec_file ?
61834 + gr_to_filename(task->exec_file->f_path.dentry,
61835 + task->exec_file->f_path.mnt) : curracl->filename,
61836 + curracl->filename, 0UL,
61837 + 0UL, "", (unsigned long) cap, &task->signal->saved_ip);
61838 + return 1;
61839 + }
61840 +
61841 + if ((cap >= 0) && (cap < captab_log_entries) && cap_raised(cred->cap_effective, cap) && !cap_raised(cap_audit, cap))
61842 + gr_log_cap(GR_DONT_AUDIT, GR_CAP_ACL_MSG, task, captab_log[cap]);
61843 +
61844 + return 0;
61845 +}
61846 +
61847 +int
61848 +gr_acl_is_capable(const int cap)
61849 +{
61850 + return gr_task_acl_is_capable(current, current_cred(), cap);
61851 +}
61852 +
61853 +int gr_task_acl_is_capable_nolog(const struct task_struct *task, const int cap)
61854 +{
61855 + struct acl_subject_label *curracl;
61856 + kernel_cap_t cap_drop = __cap_empty_set, cap_mask = __cap_empty_set;
61857 +
61858 + if (!gr_acl_is_enabled())
61859 + return 1;
61860 +
61861 + curracl = task->acl;
61862 +
61863 + cap_drop = curracl->cap_lower;
61864 + cap_mask = curracl->cap_mask;
61865 +
61866 + while ((curracl = curracl->parent_subject)) {
61867 + /* if the cap isn't specified in the current computed mask but is specified in the
61868 + current level subject, and is lowered in the current level subject, then add
61869 + it to the set of dropped capabilities
61870 + otherwise, add the current level subject's mask to the current computed mask
61871 + */
61872 + if (!cap_raised(cap_mask, cap) && cap_raised(curracl->cap_mask, cap)) {
61873 + cap_raise(cap_mask, cap);
61874 + if (cap_raised(curracl->cap_lower, cap))
61875 + cap_raise(cap_drop, cap);
61876 + }
61877 + }
61878 +
61879 + if (!cap_raised(cap_drop, cap))
61880 + return 1;
61881 +
61882 + return 0;
61883 +}
61884 +
61885 +int
61886 +gr_acl_is_capable_nolog(const int cap)
61887 +{
61888 + return gr_task_acl_is_capable_nolog(current, cap);
61889 +}
61890 +
61891 diff --git a/grsecurity/gracl_fs.c b/grsecurity/gracl_fs.c
61892 new file mode 100644
61893 index 0000000..a340c17
61894 --- /dev/null
61895 +++ b/grsecurity/gracl_fs.c
61896 @@ -0,0 +1,431 @@
61897 +#include <linux/kernel.h>
61898 +#include <linux/sched.h>
61899 +#include <linux/types.h>
61900 +#include <linux/fs.h>
61901 +#include <linux/file.h>
61902 +#include <linux/stat.h>
61903 +#include <linux/grsecurity.h>
61904 +#include <linux/grinternal.h>
61905 +#include <linux/gracl.h>
61906 +
61907 +umode_t
61908 +gr_acl_umask(void)
61909 +{
61910 + if (unlikely(!gr_acl_is_enabled()))
61911 + return 0;
61912 +
61913 + return current->role->umask;
61914 +}
61915 +
61916 +__u32
61917 +gr_acl_handle_hidden_file(const struct dentry * dentry,
61918 + const struct vfsmount * mnt)
61919 +{
61920 + __u32 mode;
61921 +
61922 + if (unlikely(!dentry->d_inode))
61923 + return GR_FIND;
61924 +
61925 + mode =
61926 + gr_search_file(dentry, GR_FIND | GR_AUDIT_FIND | GR_SUPPRESS, mnt);
61927 +
61928 + if (unlikely(mode & GR_FIND && mode & GR_AUDIT_FIND)) {
61929 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_HIDDEN_ACL_MSG, dentry, mnt);
61930 + return mode;
61931 + } else if (unlikely(!(mode & GR_FIND) && !(mode & GR_SUPPRESS))) {
61932 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_HIDDEN_ACL_MSG, dentry, mnt);
61933 + return 0;
61934 + } else if (unlikely(!(mode & GR_FIND)))
61935 + return 0;
61936 +
61937 + return GR_FIND;
61938 +}
61939 +
61940 +__u32
61941 +gr_acl_handle_open(const struct dentry * dentry, const struct vfsmount * mnt,
61942 + int acc_mode)
61943 +{
61944 + __u32 reqmode = GR_FIND;
61945 + __u32 mode;
61946 +
61947 + if (unlikely(!dentry->d_inode))
61948 + return reqmode;
61949 +
61950 + if (acc_mode & MAY_APPEND)
61951 + reqmode |= GR_APPEND;
61952 + else if (acc_mode & MAY_WRITE)
61953 + reqmode |= GR_WRITE;
61954 + if ((acc_mode & MAY_READ) && !S_ISDIR(dentry->d_inode->i_mode))
61955 + reqmode |= GR_READ;
61956 +
61957 + mode =
61958 + gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS,
61959 + mnt);
61960 +
61961 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
61962 + gr_log_fs_rbac_mode2(GR_DO_AUDIT, GR_OPEN_ACL_MSG, dentry, mnt,
61963 + reqmode & GR_READ ? " reading" : "",
61964 + reqmode & GR_WRITE ? " writing" : reqmode &
61965 + GR_APPEND ? " appending" : "");
61966 + return reqmode;
61967 + } else
61968 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
61969 + {
61970 + gr_log_fs_rbac_mode2(GR_DONT_AUDIT, GR_OPEN_ACL_MSG, dentry, mnt,
61971 + reqmode & GR_READ ? " reading" : "",
61972 + reqmode & GR_WRITE ? " writing" : reqmode &
61973 + GR_APPEND ? " appending" : "");
61974 + return 0;
61975 + } else if (unlikely((mode & reqmode) != reqmode))
61976 + return 0;
61977 +
61978 + return reqmode;
61979 +}
61980 +
61981 +__u32
61982 +gr_acl_handle_creat(const struct dentry * dentry,
61983 + const struct dentry * p_dentry,
61984 + const struct vfsmount * p_mnt, int open_flags, int acc_mode,
61985 + const int imode)
61986 +{
61987 + __u32 reqmode = GR_WRITE | GR_CREATE;
61988 + __u32 mode;
61989 +
61990 + if (acc_mode & MAY_APPEND)
61991 + reqmode |= GR_APPEND;
61992 + // if a directory was required or the directory already exists, then
61993 + // don't count this open as a read
61994 + if ((acc_mode & MAY_READ) &&
61995 + !((open_flags & O_DIRECTORY) || (dentry->d_inode && S_ISDIR(dentry->d_inode->i_mode))))
61996 + reqmode |= GR_READ;
61997 + if ((open_flags & O_CREAT) &&
61998 + ((imode & S_ISUID) || ((imode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))
61999 + reqmode |= GR_SETID;
62000 +
62001 + mode =
62002 + gr_check_create(dentry, p_dentry, p_mnt,
62003 + reqmode | to_gr_audit(reqmode) | GR_SUPPRESS);
62004 +
62005 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
62006 + gr_log_fs_rbac_mode2(GR_DO_AUDIT, GR_CREATE_ACL_MSG, dentry, p_mnt,
62007 + reqmode & GR_READ ? " reading" : "",
62008 + reqmode & GR_WRITE ? " writing" : reqmode &
62009 + GR_APPEND ? " appending" : "");
62010 + return reqmode;
62011 + } else
62012 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
62013 + {
62014 + gr_log_fs_rbac_mode2(GR_DONT_AUDIT, GR_CREATE_ACL_MSG, dentry, p_mnt,
62015 + reqmode & GR_READ ? " reading" : "",
62016 + reqmode & GR_WRITE ? " writing" : reqmode &
62017 + GR_APPEND ? " appending" : "");
62018 + return 0;
62019 + } else if (unlikely((mode & reqmode) != reqmode))
62020 + return 0;
62021 +
62022 + return reqmode;
62023 +}
62024 +
62025 +__u32
62026 +gr_acl_handle_access(const struct dentry * dentry, const struct vfsmount * mnt,
62027 + const int fmode)
62028 +{
62029 + __u32 mode, reqmode = GR_FIND;
62030 +
62031 + if ((fmode & S_IXOTH) && !S_ISDIR(dentry->d_inode->i_mode))
62032 + reqmode |= GR_EXEC;
62033 + if (fmode & S_IWOTH)
62034 + reqmode |= GR_WRITE;
62035 + if (fmode & S_IROTH)
62036 + reqmode |= GR_READ;
62037 +
62038 + mode =
62039 + gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS,
62040 + mnt);
62041 +
62042 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
62043 + gr_log_fs_rbac_mode3(GR_DO_AUDIT, GR_ACCESS_ACL_MSG, dentry, mnt,
62044 + reqmode & GR_READ ? " reading" : "",
62045 + reqmode & GR_WRITE ? " writing" : "",
62046 + reqmode & GR_EXEC ? " executing" : "");
62047 + return reqmode;
62048 + } else
62049 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
62050 + {
62051 + gr_log_fs_rbac_mode3(GR_DONT_AUDIT, GR_ACCESS_ACL_MSG, dentry, mnt,
62052 + reqmode & GR_READ ? " reading" : "",
62053 + reqmode & GR_WRITE ? " writing" : "",
62054 + reqmode & GR_EXEC ? " executing" : "");
62055 + return 0;
62056 + } else if (unlikely((mode & reqmode) != reqmode))
62057 + return 0;
62058 +
62059 + return reqmode;
62060 +}
62061 +
62062 +static __u32 generic_fs_handler(const struct dentry *dentry, const struct vfsmount *mnt, __u32 reqmode, const char *fmt)
62063 +{
62064 + __u32 mode;
62065 +
62066 + mode = gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS, mnt);
62067 +
62068 + if (unlikely(((mode & (reqmode)) == (reqmode)) && mode & GR_AUDITS)) {
62069 + gr_log_fs_rbac_generic(GR_DO_AUDIT, fmt, dentry, mnt);
62070 + return mode;
62071 + } else if (unlikely((mode & (reqmode)) != (reqmode) && !(mode & GR_SUPPRESS))) {
62072 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, fmt, dentry, mnt);
62073 + return 0;
62074 + } else if (unlikely((mode & (reqmode)) != (reqmode)))
62075 + return 0;
62076 +
62077 + return (reqmode);
62078 +}
62079 +
62080 +__u32
62081 +gr_acl_handle_rmdir(const struct dentry * dentry, const struct vfsmount * mnt)
62082 +{
62083 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_DELETE , GR_RMDIR_ACL_MSG);
62084 +}
62085 +
62086 +__u32
62087 +gr_acl_handle_unlink(const struct dentry *dentry, const struct vfsmount *mnt)
62088 +{
62089 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_DELETE , GR_UNLINK_ACL_MSG);
62090 +}
62091 +
62092 +__u32
62093 +gr_acl_handle_truncate(const struct dentry *dentry, const struct vfsmount *mnt)
62094 +{
62095 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_TRUNCATE_ACL_MSG);
62096 +}
62097 +
62098 +__u32
62099 +gr_acl_handle_utime(const struct dentry *dentry, const struct vfsmount *mnt)
62100 +{
62101 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_ATIME_ACL_MSG);
62102 +}
62103 +
62104 +__u32
62105 +gr_acl_handle_chmod(const struct dentry *dentry, const struct vfsmount *mnt,
62106 + umode_t *modeptr)
62107 +{
62108 + umode_t mode;
62109 +
62110 + *modeptr &= ~gr_acl_umask();
62111 + mode = *modeptr;
62112 +
62113 + if (unlikely(dentry->d_inode && S_ISSOCK(dentry->d_inode->i_mode)))
62114 + return 1;
62115 +
62116 + if (unlikely(dentry->d_inode && !S_ISDIR(dentry->d_inode->i_mode) &&
62117 + ((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))) {
62118 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_SETID,
62119 + GR_CHMOD_ACL_MSG);
62120 + } else {
62121 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_CHMOD_ACL_MSG);
62122 + }
62123 +}
62124 +
62125 +__u32
62126 +gr_acl_handle_chown(const struct dentry *dentry, const struct vfsmount *mnt)
62127 +{
62128 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_CHOWN_ACL_MSG);
62129 +}
62130 +
62131 +__u32
62132 +gr_acl_handle_setxattr(const struct dentry *dentry, const struct vfsmount *mnt)
62133 +{
62134 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_SETXATTR_ACL_MSG);
62135 +}
62136 +
62137 +__u32
62138 +gr_acl_handle_execve(const struct dentry *dentry, const struct vfsmount *mnt)
62139 +{
62140 + return generic_fs_handler(dentry, mnt, GR_EXEC, GR_EXEC_ACL_MSG);
62141 +}
62142 +
62143 +__u32
62144 +gr_acl_handle_unix(const struct dentry *dentry, const struct vfsmount *mnt)
62145 +{
62146 + return generic_fs_handler(dentry, mnt, GR_READ | GR_WRITE,
62147 + GR_UNIXCONNECT_ACL_MSG);
62148 +}
62149 +
62150 +/* hardlinks require at minimum create and link permission,
62151 + any additional privilege required is based on the
62152 + privilege of the file being linked to
62153 +*/
62154 +__u32
62155 +gr_acl_handle_link(const struct dentry * new_dentry,
62156 + const struct dentry * parent_dentry,
62157 + const struct vfsmount * parent_mnt,
62158 + const struct dentry * old_dentry,
62159 + const struct vfsmount * old_mnt, const struct filename *to)
62160 +{
62161 + __u32 mode;
62162 + __u32 needmode = GR_CREATE | GR_LINK;
62163 + __u32 needaudit = GR_AUDIT_CREATE | GR_AUDIT_LINK;
62164 +
62165 + mode =
62166 + gr_check_link(new_dentry, parent_dentry, parent_mnt, old_dentry,
62167 + old_mnt);
62168 +
62169 + if (unlikely(((mode & needmode) == needmode) && (mode & needaudit))) {
62170 + gr_log_fs_rbac_str(GR_DO_AUDIT, GR_LINK_ACL_MSG, old_dentry, old_mnt, to->name);
62171 + return mode;
62172 + } else if (unlikely(((mode & needmode) != needmode) && !(mode & GR_SUPPRESS))) {
62173 + gr_log_fs_rbac_str(GR_DONT_AUDIT, GR_LINK_ACL_MSG, old_dentry, old_mnt, to->name);
62174 + return 0;
62175 + } else if (unlikely((mode & needmode) != needmode))
62176 + return 0;
62177 +
62178 + return 1;
62179 +}
62180 +
62181 +__u32
62182 +gr_acl_handle_symlink(const struct dentry * new_dentry,
62183 + const struct dentry * parent_dentry,
62184 + const struct vfsmount * parent_mnt, const struct filename *from)
62185 +{
62186 + __u32 needmode = GR_WRITE | GR_CREATE;
62187 + __u32 mode;
62188 +
62189 + mode =
62190 + gr_check_create(new_dentry, parent_dentry, parent_mnt,
62191 + GR_CREATE | GR_AUDIT_CREATE |
62192 + GR_WRITE | GR_AUDIT_WRITE | GR_SUPPRESS);
62193 +
62194 + if (unlikely(mode & GR_WRITE && mode & GR_AUDITS)) {
62195 + gr_log_fs_str_rbac(GR_DO_AUDIT, GR_SYMLINK_ACL_MSG, from->name, new_dentry, parent_mnt);
62196 + return mode;
62197 + } else if (unlikely(((mode & needmode) != needmode) && !(mode & GR_SUPPRESS))) {
62198 + gr_log_fs_str_rbac(GR_DONT_AUDIT, GR_SYMLINK_ACL_MSG, from->name, new_dentry, parent_mnt);
62199 + return 0;
62200 + } else if (unlikely((mode & needmode) != needmode))
62201 + return 0;
62202 +
62203 + return (GR_WRITE | GR_CREATE);
62204 +}
62205 +
62206 +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)
62207 +{
62208 + __u32 mode;
62209 +
62210 + mode = gr_check_create(new_dentry, parent_dentry, parent_mnt, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS);
62211 +
62212 + if (unlikely(((mode & (reqmode)) == (reqmode)) && mode & GR_AUDITS)) {
62213 + gr_log_fs_rbac_generic(GR_DO_AUDIT, fmt, new_dentry, parent_mnt);
62214 + return mode;
62215 + } else if (unlikely((mode & (reqmode)) != (reqmode) && !(mode & GR_SUPPRESS))) {
62216 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, fmt, new_dentry, parent_mnt);
62217 + return 0;
62218 + } else if (unlikely((mode & (reqmode)) != (reqmode)))
62219 + return 0;
62220 +
62221 + return (reqmode);
62222 +}
62223 +
62224 +__u32
62225 +gr_acl_handle_mknod(const struct dentry * new_dentry,
62226 + const struct dentry * parent_dentry,
62227 + const struct vfsmount * parent_mnt,
62228 + const int mode)
62229 +{
62230 + __u32 reqmode = GR_WRITE | GR_CREATE;
62231 + if (unlikely((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))
62232 + reqmode |= GR_SETID;
62233 +
62234 + return generic_fs_create_handler(new_dentry, parent_dentry, parent_mnt,
62235 + reqmode, GR_MKNOD_ACL_MSG);
62236 +}
62237 +
62238 +__u32
62239 +gr_acl_handle_mkdir(const struct dentry *new_dentry,
62240 + const struct dentry *parent_dentry,
62241 + const struct vfsmount *parent_mnt)
62242 +{
62243 + return generic_fs_create_handler(new_dentry, parent_dentry, parent_mnt,
62244 + GR_WRITE | GR_CREATE, GR_MKDIR_ACL_MSG);
62245 +}
62246 +
62247 +#define RENAME_CHECK_SUCCESS(old, new) \
62248 + (((old & (GR_WRITE | GR_READ)) == (GR_WRITE | GR_READ)) && \
62249 + ((new & (GR_WRITE | GR_READ)) == (GR_WRITE | GR_READ)))
62250 +
62251 +int
62252 +gr_acl_handle_rename(struct dentry *new_dentry,
62253 + struct dentry *parent_dentry,
62254 + const struct vfsmount *parent_mnt,
62255 + struct dentry *old_dentry,
62256 + struct inode *old_parent_inode,
62257 + struct vfsmount *old_mnt, const struct filename *newname)
62258 +{
62259 + __u32 comp1, comp2;
62260 + int error = 0;
62261 +
62262 + if (unlikely(!gr_acl_is_enabled()))
62263 + return 0;
62264 +
62265 + if (!new_dentry->d_inode) {
62266 + comp1 = gr_check_create(new_dentry, parent_dentry, parent_mnt,
62267 + GR_READ | GR_WRITE | GR_CREATE | GR_AUDIT_READ |
62268 + GR_AUDIT_WRITE | GR_AUDIT_CREATE | GR_SUPPRESS);
62269 + comp2 = gr_search_file(old_dentry, GR_READ | GR_WRITE |
62270 + GR_DELETE | GR_AUDIT_DELETE |
62271 + GR_AUDIT_READ | GR_AUDIT_WRITE |
62272 + GR_SUPPRESS, old_mnt);
62273 + } else {
62274 + comp1 = gr_search_file(new_dentry, GR_READ | GR_WRITE |
62275 + GR_CREATE | GR_DELETE |
62276 + GR_AUDIT_CREATE | GR_AUDIT_DELETE |
62277 + GR_AUDIT_READ | GR_AUDIT_WRITE |
62278 + GR_SUPPRESS, parent_mnt);
62279 + comp2 =
62280 + gr_search_file(old_dentry,
62281 + GR_READ | GR_WRITE | GR_AUDIT_READ |
62282 + GR_DELETE | GR_AUDIT_DELETE |
62283 + GR_AUDIT_WRITE | GR_SUPPRESS, old_mnt);
62284 + }
62285 +
62286 + if (RENAME_CHECK_SUCCESS(comp1, comp2) &&
62287 + ((comp1 & GR_AUDITS) || (comp2 & GR_AUDITS)))
62288 + gr_log_fs_rbac_str(GR_DO_AUDIT, GR_RENAME_ACL_MSG, old_dentry, old_mnt, newname->name);
62289 + else if (!RENAME_CHECK_SUCCESS(comp1, comp2) && !(comp1 & GR_SUPPRESS)
62290 + && !(comp2 & GR_SUPPRESS)) {
62291 + gr_log_fs_rbac_str(GR_DONT_AUDIT, GR_RENAME_ACL_MSG, old_dentry, old_mnt, newname->name);
62292 + error = -EACCES;
62293 + } else if (unlikely(!RENAME_CHECK_SUCCESS(comp1, comp2)))
62294 + error = -EACCES;
62295 +
62296 + return error;
62297 +}
62298 +
62299 +void
62300 +gr_acl_handle_exit(void)
62301 +{
62302 + u16 id;
62303 + char *rolename;
62304 +
62305 + if (unlikely(current->acl_sp_role && gr_acl_is_enabled() &&
62306 + !(current->role->roletype & GR_ROLE_PERSIST))) {
62307 + id = current->acl_role_id;
62308 + rolename = current->role->rolename;
62309 + gr_set_acls(1);
62310 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_SPROLEL_ACL_MSG, rolename, id);
62311 + }
62312 +
62313 + gr_put_exec_file(current);
62314 + return;
62315 +}
62316 +
62317 +int
62318 +gr_acl_handle_procpidmem(const struct task_struct *task)
62319 +{
62320 + if (unlikely(!gr_acl_is_enabled()))
62321 + return 0;
62322 +
62323 + if (task != current && task->acl->mode & GR_PROTPROCFD)
62324 + return -EACCES;
62325 +
62326 + return 0;
62327 +}
62328 diff --git a/grsecurity/gracl_ip.c b/grsecurity/gracl_ip.c
62329 new file mode 100644
62330 index 0000000..8132048
62331 --- /dev/null
62332 +++ b/grsecurity/gracl_ip.c
62333 @@ -0,0 +1,387 @@
62334 +#include <linux/kernel.h>
62335 +#include <asm/uaccess.h>
62336 +#include <asm/errno.h>
62337 +#include <net/sock.h>
62338 +#include <linux/file.h>
62339 +#include <linux/fs.h>
62340 +#include <linux/net.h>
62341 +#include <linux/in.h>
62342 +#include <linux/skbuff.h>
62343 +#include <linux/ip.h>
62344 +#include <linux/udp.h>
62345 +#include <linux/types.h>
62346 +#include <linux/sched.h>
62347 +#include <linux/netdevice.h>
62348 +#include <linux/inetdevice.h>
62349 +#include <linux/gracl.h>
62350 +#include <linux/grsecurity.h>
62351 +#include <linux/grinternal.h>
62352 +
62353 +#define GR_BIND 0x01
62354 +#define GR_CONNECT 0x02
62355 +#define GR_INVERT 0x04
62356 +#define GR_BINDOVERRIDE 0x08
62357 +#define GR_CONNECTOVERRIDE 0x10
62358 +#define GR_SOCK_FAMILY 0x20
62359 +
62360 +static const char * gr_protocols[IPPROTO_MAX] = {
62361 + "ip", "icmp", "igmp", "ggp", "ipencap", "st", "tcp", "cbt",
62362 + "egp", "igp", "bbn-rcc", "nvp", "pup", "argus", "emcon", "xnet",
62363 + "chaos", "udp", "mux", "dcn", "hmp", "prm", "xns-idp", "trunk-1",
62364 + "trunk-2", "leaf-1", "leaf-2", "rdp", "irtp", "iso-tp4", "netblt", "mfe-nsp",
62365 + "merit-inp", "sep", "3pc", "idpr", "xtp", "ddp", "idpr-cmtp", "tp++",
62366 + "il", "ipv6", "sdrp", "ipv6-route", "ipv6-frag", "idrp", "rsvp", "gre",
62367 + "mhrp", "bna", "ipv6-crypt", "ipv6-auth", "i-nlsp", "swipe", "narp", "mobile",
62368 + "tlsp", "skip", "ipv6-icmp", "ipv6-nonxt", "ipv6-opts", "unknown:61", "cftp", "unknown:63",
62369 + "sat-expak", "kryptolan", "rvd", "ippc", "unknown:68", "sat-mon", "visa", "ipcv",
62370 + "cpnx", "cphb", "wsn", "pvp", "br-sat-mon", "sun-nd", "wb-mon", "wb-expak",
62371 + "iso-ip", "vmtp", "secure-vmtp", "vines", "ttp", "nfsnet-igp", "dgp", "tcf",
62372 + "eigrp", "ospf", "sprite-rpc", "larp", "mtp", "ax.25", "ipip", "micp",
62373 + "scc-sp", "etherip", "encap", "unknown:99", "gmtp", "ifmp", "pnni", "pim",
62374 + "aris", "scps", "qnx", "a/n", "ipcomp", "snp", "compaq-peer", "ipx-in-ip",
62375 + "vrrp", "pgm", "unknown:114", "l2tp", "ddx", "iatp", "stp", "srp",
62376 + "uti", "smp", "sm", "ptp", "isis", "fire", "crtp", "crdup",
62377 + "sscopmce", "iplt", "sps", "pipe", "sctp", "fc", "unkown:134", "unknown:135",
62378 + "unknown:136", "unknown:137", "unknown:138", "unknown:139", "unknown:140", "unknown:141", "unknown:142", "unknown:143",
62379 + "unknown:144", "unknown:145", "unknown:146", "unknown:147", "unknown:148", "unknown:149", "unknown:150", "unknown:151",
62380 + "unknown:152", "unknown:153", "unknown:154", "unknown:155", "unknown:156", "unknown:157", "unknown:158", "unknown:159",
62381 + "unknown:160", "unknown:161", "unknown:162", "unknown:163", "unknown:164", "unknown:165", "unknown:166", "unknown:167",
62382 + "unknown:168", "unknown:169", "unknown:170", "unknown:171", "unknown:172", "unknown:173", "unknown:174", "unknown:175",
62383 + "unknown:176", "unknown:177", "unknown:178", "unknown:179", "unknown:180", "unknown:181", "unknown:182", "unknown:183",
62384 + "unknown:184", "unknown:185", "unknown:186", "unknown:187", "unknown:188", "unknown:189", "unknown:190", "unknown:191",
62385 + "unknown:192", "unknown:193", "unknown:194", "unknown:195", "unknown:196", "unknown:197", "unknown:198", "unknown:199",
62386 + "unknown:200", "unknown:201", "unknown:202", "unknown:203", "unknown:204", "unknown:205", "unknown:206", "unknown:207",
62387 + "unknown:208", "unknown:209", "unknown:210", "unknown:211", "unknown:212", "unknown:213", "unknown:214", "unknown:215",
62388 + "unknown:216", "unknown:217", "unknown:218", "unknown:219", "unknown:220", "unknown:221", "unknown:222", "unknown:223",
62389 + "unknown:224", "unknown:225", "unknown:226", "unknown:227", "unknown:228", "unknown:229", "unknown:230", "unknown:231",
62390 + "unknown:232", "unknown:233", "unknown:234", "unknown:235", "unknown:236", "unknown:237", "unknown:238", "unknown:239",
62391 + "unknown:240", "unknown:241", "unknown:242", "unknown:243", "unknown:244", "unknown:245", "unknown:246", "unknown:247",
62392 + "unknown:248", "unknown:249", "unknown:250", "unknown:251", "unknown:252", "unknown:253", "unknown:254", "unknown:255",
62393 + };
62394 +
62395 +static const char * gr_socktypes[SOCK_MAX] = {
62396 + "unknown:0", "stream", "dgram", "raw", "rdm", "seqpacket", "unknown:6",
62397 + "unknown:7", "unknown:8", "unknown:9", "packet"
62398 + };
62399 +
62400 +static const char * gr_sockfamilies[AF_MAX+1] = {
62401 + "unspec", "unix", "inet", "ax25", "ipx", "appletalk", "netrom", "bridge", "atmpvc", "x25",
62402 + "inet6", "rose", "decnet", "netbeui", "security", "key", "netlink", "packet", "ash",
62403 + "econet", "atmsvc", "rds", "sna", "irda", "ppox", "wanpipe", "llc", "fam_27", "fam_28",
62404 + "tipc", "bluetooth", "iucv", "rxrpc", "isdn", "phonet", "ieee802154", "ciaf"
62405 + };
62406 +
62407 +const char *
62408 +gr_proto_to_name(unsigned char proto)
62409 +{
62410 + return gr_protocols[proto];
62411 +}
62412 +
62413 +const char *
62414 +gr_socktype_to_name(unsigned char type)
62415 +{
62416 + return gr_socktypes[type];
62417 +}
62418 +
62419 +const char *
62420 +gr_sockfamily_to_name(unsigned char family)
62421 +{
62422 + return gr_sockfamilies[family];
62423 +}
62424 +
62425 +int
62426 +gr_search_socket(const int domain, const int type, const int protocol)
62427 +{
62428 + struct acl_subject_label *curr;
62429 + const struct cred *cred = current_cred();
62430 +
62431 + if (unlikely(!gr_acl_is_enabled()))
62432 + goto exit;
62433 +
62434 + if ((domain < 0) || (type < 0) || (protocol < 0) ||
62435 + (domain >= AF_MAX) || (type >= SOCK_MAX) || (protocol >= IPPROTO_MAX))
62436 + goto exit; // let the kernel handle it
62437 +
62438 + curr = current->acl;
62439 +
62440 + if (curr->sock_families[domain / 32] & (1U << (domain % 32))) {
62441 + /* the family is allowed, if this is PF_INET allow it only if
62442 + the extra sock type/protocol checks pass */
62443 + if (domain == PF_INET)
62444 + goto inet_check;
62445 + goto exit;
62446 + } else {
62447 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
62448 + __u32 fakeip = 0;
62449 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
62450 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
62451 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
62452 + gr_to_filename(current->exec_file->f_path.dentry,
62453 + current->exec_file->f_path.mnt) :
62454 + curr->filename, curr->filename,
62455 + &fakeip, domain, 0, 0, GR_SOCK_FAMILY,
62456 + &current->signal->saved_ip);
62457 + goto exit;
62458 + }
62459 + goto exit_fail;
62460 + }
62461 +
62462 +inet_check:
62463 + /* the rest of this checking is for IPv4 only */
62464 + if (!curr->ips)
62465 + goto exit;
62466 +
62467 + if ((curr->ip_type & (1U << type)) &&
62468 + (curr->ip_proto[protocol / 32] & (1U << (protocol % 32))))
62469 + goto exit;
62470 +
62471 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
62472 + /* we don't place acls on raw sockets , and sometimes
62473 + dgram/ip sockets are opened for ioctl and not
62474 + bind/connect, so we'll fake a bind learn log */
62475 + if (type == SOCK_RAW || type == SOCK_PACKET) {
62476 + __u32 fakeip = 0;
62477 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
62478 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
62479 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
62480 + gr_to_filename(current->exec_file->f_path.dentry,
62481 + current->exec_file->f_path.mnt) :
62482 + curr->filename, curr->filename,
62483 + &fakeip, 0, type,
62484 + protocol, GR_CONNECT, &current->signal->saved_ip);
62485 + } else if ((type == SOCK_DGRAM) && (protocol == IPPROTO_IP)) {
62486 + __u32 fakeip = 0;
62487 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
62488 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
62489 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
62490 + gr_to_filename(current->exec_file->f_path.dentry,
62491 + current->exec_file->f_path.mnt) :
62492 + curr->filename, curr->filename,
62493 + &fakeip, 0, type,
62494 + protocol, GR_BIND, &current->signal->saved_ip);
62495 + }
62496 + /* we'll log when they use connect or bind */
62497 + goto exit;
62498 + }
62499 +
62500 +exit_fail:
62501 + if (domain == PF_INET)
62502 + gr_log_str3(GR_DONT_AUDIT, GR_SOCK_MSG, gr_sockfamily_to_name(domain),
62503 + gr_socktype_to_name(type), gr_proto_to_name(protocol));
62504 + else
62505 +#ifndef CONFIG_IPV6
62506 + if (domain != PF_INET6)
62507 +#endif
62508 + gr_log_str2_int(GR_DONT_AUDIT, GR_SOCK_NOINET_MSG, gr_sockfamily_to_name(domain),
62509 + gr_socktype_to_name(type), protocol);
62510 +
62511 + return 0;
62512 +exit:
62513 + return 1;
62514 +}
62515 +
62516 +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)
62517 +{
62518 + if ((ip->mode & mode) &&
62519 + (ip_port >= ip->low) &&
62520 + (ip_port <= ip->high) &&
62521 + ((ntohl(ip_addr) & our_netmask) ==
62522 + (ntohl(our_addr) & our_netmask))
62523 + && (ip->proto[protocol / 32] & (1U << (protocol % 32)))
62524 + && (ip->type & (1U << type))) {
62525 + if (ip->mode & GR_INVERT)
62526 + return 2; // specifically denied
62527 + else
62528 + return 1; // allowed
62529 + }
62530 +
62531 + return 0; // not specifically allowed, may continue parsing
62532 +}
62533 +
62534 +static int
62535 +gr_search_connectbind(const int full_mode, struct sock *sk,
62536 + struct sockaddr_in *addr, const int type)
62537 +{
62538 + char iface[IFNAMSIZ] = {0};
62539 + struct acl_subject_label *curr;
62540 + struct acl_ip_label *ip;
62541 + struct inet_sock *isk;
62542 + struct net_device *dev;
62543 + struct in_device *idev;
62544 + unsigned long i;
62545 + int ret;
62546 + int mode = full_mode & (GR_BIND | GR_CONNECT);
62547 + __u32 ip_addr = 0;
62548 + __u32 our_addr;
62549 + __u32 our_netmask;
62550 + char *p;
62551 + __u16 ip_port = 0;
62552 + const struct cred *cred = current_cred();
62553 +
62554 + if (unlikely(!gr_acl_is_enabled() || sk->sk_family != PF_INET))
62555 + return 0;
62556 +
62557 + curr = current->acl;
62558 + isk = inet_sk(sk);
62559 +
62560 + /* INADDR_ANY overriding for binds, inaddr_any_override is already in network order */
62561 + if ((full_mode & GR_BINDOVERRIDE) && addr->sin_addr.s_addr == htonl(INADDR_ANY) && curr->inaddr_any_override != 0)
62562 + addr->sin_addr.s_addr = curr->inaddr_any_override;
62563 + if ((full_mode & GR_CONNECT) && isk->inet_saddr == htonl(INADDR_ANY) && curr->inaddr_any_override != 0) {
62564 + struct sockaddr_in saddr;
62565 + int err;
62566 +
62567 + saddr.sin_family = AF_INET;
62568 + saddr.sin_addr.s_addr = curr->inaddr_any_override;
62569 + saddr.sin_port = isk->inet_sport;
62570 +
62571 + err = security_socket_bind(sk->sk_socket, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in));
62572 + if (err)
62573 + return err;
62574 +
62575 + err = sk->sk_socket->ops->bind(sk->sk_socket, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in));
62576 + if (err)
62577 + return err;
62578 + }
62579 +
62580 + if (!curr->ips)
62581 + return 0;
62582 +
62583 + ip_addr = addr->sin_addr.s_addr;
62584 + ip_port = ntohs(addr->sin_port);
62585 +
62586 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
62587 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
62588 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
62589 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
62590 + gr_to_filename(current->exec_file->f_path.dentry,
62591 + current->exec_file->f_path.mnt) :
62592 + curr->filename, curr->filename,
62593 + &ip_addr, ip_port, type,
62594 + sk->sk_protocol, mode, &current->signal->saved_ip);
62595 + return 0;
62596 + }
62597 +
62598 + for (i = 0; i < curr->ip_num; i++) {
62599 + ip = *(curr->ips + i);
62600 + if (ip->iface != NULL) {
62601 + strncpy(iface, ip->iface, IFNAMSIZ - 1);
62602 + p = strchr(iface, ':');
62603 + if (p != NULL)
62604 + *p = '\0';
62605 + dev = dev_get_by_name(sock_net(sk), iface);
62606 + if (dev == NULL)
62607 + continue;
62608 + idev = in_dev_get(dev);
62609 + if (idev == NULL) {
62610 + dev_put(dev);
62611 + continue;
62612 + }
62613 + rcu_read_lock();
62614 + for_ifa(idev) {
62615 + if (!strcmp(ip->iface, ifa->ifa_label)) {
62616 + our_addr = ifa->ifa_address;
62617 + our_netmask = 0xffffffff;
62618 + ret = check_ip_policy(ip, ip_addr, ip_port, sk->sk_protocol, mode, type, our_addr, our_netmask);
62619 + if (ret == 1) {
62620 + rcu_read_unlock();
62621 + in_dev_put(idev);
62622 + dev_put(dev);
62623 + return 0;
62624 + } else if (ret == 2) {
62625 + rcu_read_unlock();
62626 + in_dev_put(idev);
62627 + dev_put(dev);
62628 + goto denied;
62629 + }
62630 + }
62631 + } endfor_ifa(idev);
62632 + rcu_read_unlock();
62633 + in_dev_put(idev);
62634 + dev_put(dev);
62635 + } else {
62636 + our_addr = ip->addr;
62637 + our_netmask = ip->netmask;
62638 + ret = check_ip_policy(ip, ip_addr, ip_port, sk->sk_protocol, mode, type, our_addr, our_netmask);
62639 + if (ret == 1)
62640 + return 0;
62641 + else if (ret == 2)
62642 + goto denied;
62643 + }
62644 + }
62645 +
62646 +denied:
62647 + if (mode == GR_BIND)
62648 + 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));
62649 + else if (mode == GR_CONNECT)
62650 + 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));
62651 +
62652 + return -EACCES;
62653 +}
62654 +
62655 +int
62656 +gr_search_connect(struct socket *sock, struct sockaddr_in *addr)
62657 +{
62658 + /* always allow disconnection of dgram sockets with connect */
62659 + if (addr->sin_family == AF_UNSPEC)
62660 + return 0;
62661 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sock->sk, addr, sock->type);
62662 +}
62663 +
62664 +int
62665 +gr_search_bind(struct socket *sock, struct sockaddr_in *addr)
62666 +{
62667 + return gr_search_connectbind(GR_BIND | GR_BINDOVERRIDE, sock->sk, addr, sock->type);
62668 +}
62669 +
62670 +int gr_search_listen(struct socket *sock)
62671 +{
62672 + struct sock *sk = sock->sk;
62673 + struct sockaddr_in addr;
62674 +
62675 + addr.sin_addr.s_addr = inet_sk(sk)->inet_saddr;
62676 + addr.sin_port = inet_sk(sk)->inet_sport;
62677 +
62678 + return gr_search_connectbind(GR_BIND | GR_CONNECTOVERRIDE, sock->sk, &addr, sock->type);
62679 +}
62680 +
62681 +int gr_search_accept(struct socket *sock)
62682 +{
62683 + struct sock *sk = sock->sk;
62684 + struct sockaddr_in addr;
62685 +
62686 + addr.sin_addr.s_addr = inet_sk(sk)->inet_saddr;
62687 + addr.sin_port = inet_sk(sk)->inet_sport;
62688 +
62689 + return gr_search_connectbind(GR_BIND | GR_CONNECTOVERRIDE, sock->sk, &addr, sock->type);
62690 +}
62691 +
62692 +int
62693 +gr_search_udp_sendmsg(struct sock *sk, struct sockaddr_in *addr)
62694 +{
62695 + if (addr)
62696 + return gr_search_connectbind(GR_CONNECT, sk, addr, SOCK_DGRAM);
62697 + else {
62698 + struct sockaddr_in sin;
62699 + const struct inet_sock *inet = inet_sk(sk);
62700 +
62701 + sin.sin_addr.s_addr = inet->inet_daddr;
62702 + sin.sin_port = inet->inet_dport;
62703 +
62704 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sk, &sin, SOCK_DGRAM);
62705 + }
62706 +}
62707 +
62708 +int
62709 +gr_search_udp_recvmsg(struct sock *sk, const struct sk_buff *skb)
62710 +{
62711 + struct sockaddr_in sin;
62712 +
62713 + if (unlikely(skb->len < sizeof (struct udphdr)))
62714 + return 0; // skip this packet
62715 +
62716 + sin.sin_addr.s_addr = ip_hdr(skb)->saddr;
62717 + sin.sin_port = udp_hdr(skb)->source;
62718 +
62719 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sk, &sin, SOCK_DGRAM);
62720 +}
62721 diff --git a/grsecurity/gracl_learn.c b/grsecurity/gracl_learn.c
62722 new file mode 100644
62723 index 0000000..25f54ef
62724 --- /dev/null
62725 +++ b/grsecurity/gracl_learn.c
62726 @@ -0,0 +1,207 @@
62727 +#include <linux/kernel.h>
62728 +#include <linux/mm.h>
62729 +#include <linux/sched.h>
62730 +#include <linux/poll.h>
62731 +#include <linux/string.h>
62732 +#include <linux/file.h>
62733 +#include <linux/types.h>
62734 +#include <linux/vmalloc.h>
62735 +#include <linux/grinternal.h>
62736 +
62737 +extern ssize_t write_grsec_handler(struct file * file, const char __user * buf,
62738 + size_t count, loff_t *ppos);
62739 +extern int gr_acl_is_enabled(void);
62740 +
62741 +static DECLARE_WAIT_QUEUE_HEAD(learn_wait);
62742 +static int gr_learn_attached;
62743 +
62744 +/* use a 512k buffer */
62745 +#define LEARN_BUFFER_SIZE (512 * 1024)
62746 +
62747 +static DEFINE_SPINLOCK(gr_learn_lock);
62748 +static DEFINE_MUTEX(gr_learn_user_mutex);
62749 +
62750 +/* we need to maintain two buffers, so that the kernel context of grlearn
62751 + uses a semaphore around the userspace copying, and the other kernel contexts
62752 + use a spinlock when copying into the buffer, since they cannot sleep
62753 +*/
62754 +static char *learn_buffer;
62755 +static char *learn_buffer_user;
62756 +static int learn_buffer_len;
62757 +static int learn_buffer_user_len;
62758 +
62759 +static ssize_t
62760 +read_learn(struct file *file, char __user * buf, size_t count, loff_t * ppos)
62761 +{
62762 + DECLARE_WAITQUEUE(wait, current);
62763 + ssize_t retval = 0;
62764 +
62765 + add_wait_queue(&learn_wait, &wait);
62766 + set_current_state(TASK_INTERRUPTIBLE);
62767 + do {
62768 + mutex_lock(&gr_learn_user_mutex);
62769 + spin_lock(&gr_learn_lock);
62770 + if (learn_buffer_len)
62771 + break;
62772 + spin_unlock(&gr_learn_lock);
62773 + mutex_unlock(&gr_learn_user_mutex);
62774 + if (file->f_flags & O_NONBLOCK) {
62775 + retval = -EAGAIN;
62776 + goto out;
62777 + }
62778 + if (signal_pending(current)) {
62779 + retval = -ERESTARTSYS;
62780 + goto out;
62781 + }
62782 +
62783 + schedule();
62784 + } while (1);
62785 +
62786 + memcpy(learn_buffer_user, learn_buffer, learn_buffer_len);
62787 + learn_buffer_user_len = learn_buffer_len;
62788 + retval = learn_buffer_len;
62789 + learn_buffer_len = 0;
62790 +
62791 + spin_unlock(&gr_learn_lock);
62792 +
62793 + if (copy_to_user(buf, learn_buffer_user, learn_buffer_user_len))
62794 + retval = -EFAULT;
62795 +
62796 + mutex_unlock(&gr_learn_user_mutex);
62797 +out:
62798 + set_current_state(TASK_RUNNING);
62799 + remove_wait_queue(&learn_wait, &wait);
62800 + return retval;
62801 +}
62802 +
62803 +static unsigned int
62804 +poll_learn(struct file * file, poll_table * wait)
62805 +{
62806 + poll_wait(file, &learn_wait, wait);
62807 +
62808 + if (learn_buffer_len)
62809 + return (POLLIN | POLLRDNORM);
62810 +
62811 + return 0;
62812 +}
62813 +
62814 +void
62815 +gr_clear_learn_entries(void)
62816 +{
62817 + char *tmp;
62818 +
62819 + mutex_lock(&gr_learn_user_mutex);
62820 + spin_lock(&gr_learn_lock);
62821 + tmp = learn_buffer;
62822 + learn_buffer = NULL;
62823 + spin_unlock(&gr_learn_lock);
62824 + if (tmp)
62825 + vfree(tmp);
62826 + if (learn_buffer_user != NULL) {
62827 + vfree(learn_buffer_user);
62828 + learn_buffer_user = NULL;
62829 + }
62830 + learn_buffer_len = 0;
62831 + mutex_unlock(&gr_learn_user_mutex);
62832 +
62833 + return;
62834 +}
62835 +
62836 +void
62837 +gr_add_learn_entry(const char *fmt, ...)
62838 +{
62839 + va_list args;
62840 + unsigned int len;
62841 +
62842 + if (!gr_learn_attached)
62843 + return;
62844 +
62845 + spin_lock(&gr_learn_lock);
62846 +
62847 + /* leave a gap at the end so we know when it's "full" but don't have to
62848 + compute the exact length of the string we're trying to append
62849 + */
62850 + if (learn_buffer_len > LEARN_BUFFER_SIZE - 16384) {
62851 + spin_unlock(&gr_learn_lock);
62852 + wake_up_interruptible(&learn_wait);
62853 + return;
62854 + }
62855 + if (learn_buffer == NULL) {
62856 + spin_unlock(&gr_learn_lock);
62857 + return;
62858 + }
62859 +
62860 + va_start(args, fmt);
62861 + len = vsnprintf(learn_buffer + learn_buffer_len, LEARN_BUFFER_SIZE - learn_buffer_len, fmt, args);
62862 + va_end(args);
62863 +
62864 + learn_buffer_len += len + 1;
62865 +
62866 + spin_unlock(&gr_learn_lock);
62867 + wake_up_interruptible(&learn_wait);
62868 +
62869 + return;
62870 +}
62871 +
62872 +static int
62873 +open_learn(struct inode *inode, struct file *file)
62874 +{
62875 + if (file->f_mode & FMODE_READ && gr_learn_attached)
62876 + return -EBUSY;
62877 + if (file->f_mode & FMODE_READ) {
62878 + int retval = 0;
62879 + mutex_lock(&gr_learn_user_mutex);
62880 + if (learn_buffer == NULL)
62881 + learn_buffer = vmalloc(LEARN_BUFFER_SIZE);
62882 + if (learn_buffer_user == NULL)
62883 + learn_buffer_user = vmalloc(LEARN_BUFFER_SIZE);
62884 + if (learn_buffer == NULL) {
62885 + retval = -ENOMEM;
62886 + goto out_error;
62887 + }
62888 + if (learn_buffer_user == NULL) {
62889 + retval = -ENOMEM;
62890 + goto out_error;
62891 + }
62892 + learn_buffer_len = 0;
62893 + learn_buffer_user_len = 0;
62894 + gr_learn_attached = 1;
62895 +out_error:
62896 + mutex_unlock(&gr_learn_user_mutex);
62897 + return retval;
62898 + }
62899 + return 0;
62900 +}
62901 +
62902 +static int
62903 +close_learn(struct inode *inode, struct file *file)
62904 +{
62905 + if (file->f_mode & FMODE_READ) {
62906 + char *tmp = NULL;
62907 + mutex_lock(&gr_learn_user_mutex);
62908 + spin_lock(&gr_learn_lock);
62909 + tmp = learn_buffer;
62910 + learn_buffer = NULL;
62911 + spin_unlock(&gr_learn_lock);
62912 + if (tmp)
62913 + vfree(tmp);
62914 + if (learn_buffer_user != NULL) {
62915 + vfree(learn_buffer_user);
62916 + learn_buffer_user = NULL;
62917 + }
62918 + learn_buffer_len = 0;
62919 + learn_buffer_user_len = 0;
62920 + gr_learn_attached = 0;
62921 + mutex_unlock(&gr_learn_user_mutex);
62922 + }
62923 +
62924 + return 0;
62925 +}
62926 +
62927 +const struct file_operations grsec_fops = {
62928 + .read = read_learn,
62929 + .write = write_grsec_handler,
62930 + .open = open_learn,
62931 + .release = close_learn,
62932 + .poll = poll_learn,
62933 +};
62934 diff --git a/grsecurity/gracl_res.c b/grsecurity/gracl_res.c
62935 new file mode 100644
62936 index 0000000..39645c9
62937 --- /dev/null
62938 +++ b/grsecurity/gracl_res.c
62939 @@ -0,0 +1,68 @@
62940 +#include <linux/kernel.h>
62941 +#include <linux/sched.h>
62942 +#include <linux/gracl.h>
62943 +#include <linux/grinternal.h>
62944 +
62945 +static const char *restab_log[] = {
62946 + [RLIMIT_CPU] = "RLIMIT_CPU",
62947 + [RLIMIT_FSIZE] = "RLIMIT_FSIZE",
62948 + [RLIMIT_DATA] = "RLIMIT_DATA",
62949 + [RLIMIT_STACK] = "RLIMIT_STACK",
62950 + [RLIMIT_CORE] = "RLIMIT_CORE",
62951 + [RLIMIT_RSS] = "RLIMIT_RSS",
62952 + [RLIMIT_NPROC] = "RLIMIT_NPROC",
62953 + [RLIMIT_NOFILE] = "RLIMIT_NOFILE",
62954 + [RLIMIT_MEMLOCK] = "RLIMIT_MEMLOCK",
62955 + [RLIMIT_AS] = "RLIMIT_AS",
62956 + [RLIMIT_LOCKS] = "RLIMIT_LOCKS",
62957 + [RLIMIT_SIGPENDING] = "RLIMIT_SIGPENDING",
62958 + [RLIMIT_MSGQUEUE] = "RLIMIT_MSGQUEUE",
62959 + [RLIMIT_NICE] = "RLIMIT_NICE",
62960 + [RLIMIT_RTPRIO] = "RLIMIT_RTPRIO",
62961 + [RLIMIT_RTTIME] = "RLIMIT_RTTIME",
62962 + [GR_CRASH_RES] = "RLIMIT_CRASH"
62963 +};
62964 +
62965 +void
62966 +gr_log_resource(const struct task_struct *task,
62967 + const int res, const unsigned long wanted, const int gt)
62968 +{
62969 + const struct cred *cred;
62970 + unsigned long rlim;
62971 +
62972 + if (!gr_acl_is_enabled() && !grsec_resource_logging)
62973 + return;
62974 +
62975 + // not yet supported resource
62976 + if (unlikely(!restab_log[res]))
62977 + return;
62978 +
62979 + if (res == RLIMIT_CPU || res == RLIMIT_RTTIME)
62980 + rlim = task_rlimit_max(task, res);
62981 + else
62982 + rlim = task_rlimit(task, res);
62983 +
62984 + if (likely((rlim == RLIM_INFINITY) || (gt && wanted <= rlim) || (!gt && wanted < rlim)))
62985 + return;
62986 +
62987 + rcu_read_lock();
62988 + cred = __task_cred(task);
62989 +
62990 + if (res == RLIMIT_NPROC &&
62991 + (cap_raised(cred->cap_effective, CAP_SYS_ADMIN) ||
62992 + cap_raised(cred->cap_effective, CAP_SYS_RESOURCE)))
62993 + goto out_rcu_unlock;
62994 + else if (res == RLIMIT_MEMLOCK &&
62995 + cap_raised(cred->cap_effective, CAP_IPC_LOCK))
62996 + goto out_rcu_unlock;
62997 + else if (res == RLIMIT_NICE && cap_raised(cred->cap_effective, CAP_SYS_NICE))
62998 + goto out_rcu_unlock;
62999 + rcu_read_unlock();
63000 +
63001 + gr_log_res_ulong2_str(GR_DONT_AUDIT, GR_RESOURCE_MSG, task, wanted, restab_log[res], rlim);
63002 +
63003 + return;
63004 +out_rcu_unlock:
63005 + rcu_read_unlock();
63006 + return;
63007 +}
63008 diff --git a/grsecurity/gracl_segv.c b/grsecurity/gracl_segv.c
63009 new file mode 100644
63010 index 0000000..4dcc92a
63011 --- /dev/null
63012 +++ b/grsecurity/gracl_segv.c
63013 @@ -0,0 +1,305 @@
63014 +#include <linux/kernel.h>
63015 +#include <linux/mm.h>
63016 +#include <asm/uaccess.h>
63017 +#include <asm/errno.h>
63018 +#include <asm/mman.h>
63019 +#include <net/sock.h>
63020 +#include <linux/file.h>
63021 +#include <linux/fs.h>
63022 +#include <linux/net.h>
63023 +#include <linux/in.h>
63024 +#include <linux/slab.h>
63025 +#include <linux/types.h>
63026 +#include <linux/sched.h>
63027 +#include <linux/timer.h>
63028 +#include <linux/gracl.h>
63029 +#include <linux/grsecurity.h>
63030 +#include <linux/grinternal.h>
63031 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
63032 +#include <linux/magic.h>
63033 +#include <linux/pagemap.h>
63034 +#include "../fs/btrfs/async-thread.h"
63035 +#include "../fs/btrfs/ctree.h"
63036 +#include "../fs/btrfs/btrfs_inode.h"
63037 +#endif
63038 +
63039 +static struct crash_uid *uid_set;
63040 +static unsigned short uid_used;
63041 +static DEFINE_SPINLOCK(gr_uid_lock);
63042 +extern rwlock_t gr_inode_lock;
63043 +extern struct acl_subject_label *
63044 + lookup_acl_subj_label(const ino_t inode, const dev_t dev,
63045 + struct acl_role_label *role);
63046 +
63047 +static inline dev_t __get_dev(const struct dentry *dentry)
63048 +{
63049 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
63050 + if (dentry->d_sb->s_magic == BTRFS_SUPER_MAGIC)
63051 + return BTRFS_I(dentry->d_inode)->root->anon_dev;
63052 + else
63053 +#endif
63054 + return dentry->d_sb->s_dev;
63055 +}
63056 +
63057 +int
63058 +gr_init_uidset(void)
63059 +{
63060 + uid_set =
63061 + kmalloc(GR_UIDTABLE_MAX * sizeof (struct crash_uid), GFP_KERNEL);
63062 + uid_used = 0;
63063 +
63064 + return uid_set ? 1 : 0;
63065 +}
63066 +
63067 +void
63068 +gr_free_uidset(void)
63069 +{
63070 + if (uid_set)
63071 + kfree(uid_set);
63072 +
63073 + return;
63074 +}
63075 +
63076 +int
63077 +gr_find_uid(const uid_t uid)
63078 +{
63079 + struct crash_uid *tmp = uid_set;
63080 + uid_t buid;
63081 + int low = 0, high = uid_used - 1, mid;
63082 +
63083 + while (high >= low) {
63084 + mid = (low + high) >> 1;
63085 + buid = tmp[mid].uid;
63086 + if (buid == uid)
63087 + return mid;
63088 + if (buid > uid)
63089 + high = mid - 1;
63090 + if (buid < uid)
63091 + low = mid + 1;
63092 + }
63093 +
63094 + return -1;
63095 +}
63096 +
63097 +static __inline__ void
63098 +gr_insertsort(void)
63099 +{
63100 + unsigned short i, j;
63101 + struct crash_uid index;
63102 +
63103 + for (i = 1; i < uid_used; i++) {
63104 + index = uid_set[i];
63105 + j = i;
63106 + while ((j > 0) && uid_set[j - 1].uid > index.uid) {
63107 + uid_set[j] = uid_set[j - 1];
63108 + j--;
63109 + }
63110 + uid_set[j] = index;
63111 + }
63112 +
63113 + return;
63114 +}
63115 +
63116 +static __inline__ void
63117 +gr_insert_uid(const kuid_t kuid, const unsigned long expires)
63118 +{
63119 + int loc;
63120 + uid_t uid = GR_GLOBAL_UID(kuid);
63121 +
63122 + if (uid_used == GR_UIDTABLE_MAX)
63123 + return;
63124 +
63125 + loc = gr_find_uid(uid);
63126 +
63127 + if (loc >= 0) {
63128 + uid_set[loc].expires = expires;
63129 + return;
63130 + }
63131 +
63132 + uid_set[uid_used].uid = uid;
63133 + uid_set[uid_used].expires = expires;
63134 + uid_used++;
63135 +
63136 + gr_insertsort();
63137 +
63138 + return;
63139 +}
63140 +
63141 +void
63142 +gr_remove_uid(const unsigned short loc)
63143 +{
63144 + unsigned short i;
63145 +
63146 + for (i = loc + 1; i < uid_used; i++)
63147 + uid_set[i - 1] = uid_set[i];
63148 +
63149 + uid_used--;
63150 +
63151 + return;
63152 +}
63153 +
63154 +int
63155 +gr_check_crash_uid(const kuid_t kuid)
63156 +{
63157 + int loc;
63158 + int ret = 0;
63159 + uid_t uid;
63160 +
63161 + if (unlikely(!gr_acl_is_enabled()))
63162 + return 0;
63163 +
63164 + uid = GR_GLOBAL_UID(kuid);
63165 +
63166 + spin_lock(&gr_uid_lock);
63167 + loc = gr_find_uid(uid);
63168 +
63169 + if (loc < 0)
63170 + goto out_unlock;
63171 +
63172 + if (time_before_eq(uid_set[loc].expires, get_seconds()))
63173 + gr_remove_uid(loc);
63174 + else
63175 + ret = 1;
63176 +
63177 +out_unlock:
63178 + spin_unlock(&gr_uid_lock);
63179 + return ret;
63180 +}
63181 +
63182 +static __inline__ int
63183 +proc_is_setxid(const struct cred *cred)
63184 +{
63185 + if (!uid_eq(cred->uid, cred->euid) || !uid_eq(cred->uid, cred->suid) ||
63186 + !uid_eq(cred->uid, cred->fsuid))
63187 + return 1;
63188 + if (!gid_eq(cred->gid, cred->egid) || !gid_eq(cred->gid, cred->sgid) ||
63189 + !gid_eq(cred->gid, cred->fsgid))
63190 + return 1;
63191 +
63192 + return 0;
63193 +}
63194 +
63195 +extern int gr_fake_force_sig(int sig, struct task_struct *t);
63196 +
63197 +void
63198 +gr_handle_crash(struct task_struct *task, const int sig)
63199 +{
63200 + struct acl_subject_label *curr;
63201 + struct task_struct *tsk, *tsk2;
63202 + const struct cred *cred;
63203 + const struct cred *cred2;
63204 +
63205 + if (sig != SIGSEGV && sig != SIGKILL && sig != SIGBUS && sig != SIGILL)
63206 + return;
63207 +
63208 + if (unlikely(!gr_acl_is_enabled()))
63209 + return;
63210 +
63211 + curr = task->acl;
63212 +
63213 + if (!(curr->resmask & (1U << GR_CRASH_RES)))
63214 + return;
63215 +
63216 + if (time_before_eq(curr->expires, get_seconds())) {
63217 + curr->expires = 0;
63218 + curr->crashes = 0;
63219 + }
63220 +
63221 + curr->crashes++;
63222 +
63223 + if (!curr->expires)
63224 + curr->expires = get_seconds() + curr->res[GR_CRASH_RES].rlim_max;
63225 +
63226 + if ((curr->crashes >= curr->res[GR_CRASH_RES].rlim_cur) &&
63227 + time_after(curr->expires, get_seconds())) {
63228 + rcu_read_lock();
63229 + cred = __task_cred(task);
63230 + if (gr_is_global_nonroot(cred->uid) && proc_is_setxid(cred)) {
63231 + gr_log_crash1(GR_DONT_AUDIT, GR_SEGVSTART_ACL_MSG, task, curr->res[GR_CRASH_RES].rlim_max);
63232 + spin_lock(&gr_uid_lock);
63233 + gr_insert_uid(cred->uid, curr->expires);
63234 + spin_unlock(&gr_uid_lock);
63235 + curr->expires = 0;
63236 + curr->crashes = 0;
63237 + read_lock(&tasklist_lock);
63238 + do_each_thread(tsk2, tsk) {
63239 + cred2 = __task_cred(tsk);
63240 + if (tsk != task && uid_eq(cred2->uid, cred->uid))
63241 + gr_fake_force_sig(SIGKILL, tsk);
63242 + } while_each_thread(tsk2, tsk);
63243 + read_unlock(&tasklist_lock);
63244 + } else {
63245 + gr_log_crash2(GR_DONT_AUDIT, GR_SEGVNOSUID_ACL_MSG, task, curr->res[GR_CRASH_RES].rlim_max);
63246 + read_lock(&tasklist_lock);
63247 + read_lock(&grsec_exec_file_lock);
63248 + do_each_thread(tsk2, tsk) {
63249 + if (likely(tsk != task)) {
63250 + // if this thread has the same subject as the one that triggered
63251 + // RES_CRASH and it's the same binary, kill it
63252 + if (tsk->acl == task->acl && tsk->exec_file == task->exec_file)
63253 + gr_fake_force_sig(SIGKILL, tsk);
63254 + }
63255 + } while_each_thread(tsk2, tsk);
63256 + read_unlock(&grsec_exec_file_lock);
63257 + read_unlock(&tasklist_lock);
63258 + }
63259 + rcu_read_unlock();
63260 + }
63261 +
63262 + return;
63263 +}
63264 +
63265 +int
63266 +gr_check_crash_exec(const struct file *filp)
63267 +{
63268 + struct acl_subject_label *curr;
63269 +
63270 + if (unlikely(!gr_acl_is_enabled()))
63271 + return 0;
63272 +
63273 + read_lock(&gr_inode_lock);
63274 + curr = lookup_acl_subj_label(filp->f_path.dentry->d_inode->i_ino,
63275 + __get_dev(filp->f_path.dentry),
63276 + current->role);
63277 + read_unlock(&gr_inode_lock);
63278 +
63279 + if (!curr || !(curr->resmask & (1U << GR_CRASH_RES)) ||
63280 + (!curr->crashes && !curr->expires))
63281 + return 0;
63282 +
63283 + if ((curr->crashes >= curr->res[GR_CRASH_RES].rlim_cur) &&
63284 + time_after(curr->expires, get_seconds()))
63285 + return 1;
63286 + else if (time_before_eq(curr->expires, get_seconds())) {
63287 + curr->crashes = 0;
63288 + curr->expires = 0;
63289 + }
63290 +
63291 + return 0;
63292 +}
63293 +
63294 +void
63295 +gr_handle_alertkill(struct task_struct *task)
63296 +{
63297 + struct acl_subject_label *curracl;
63298 + __u32 curr_ip;
63299 + struct task_struct *p, *p2;
63300 +
63301 + if (unlikely(!gr_acl_is_enabled()))
63302 + return;
63303 +
63304 + curracl = task->acl;
63305 + curr_ip = task->signal->curr_ip;
63306 +
63307 + if ((curracl->mode & GR_KILLIPPROC) && curr_ip) {
63308 + read_lock(&tasklist_lock);
63309 + do_each_thread(p2, p) {
63310 + if (p->signal->curr_ip == curr_ip)
63311 + gr_fake_force_sig(SIGKILL, p);
63312 + } while_each_thread(p2, p);
63313 + read_unlock(&tasklist_lock);
63314 + } else if (curracl->mode & GR_KILLPROC)
63315 + gr_fake_force_sig(SIGKILL, task);
63316 +
63317 + return;
63318 +}
63319 diff --git a/grsecurity/gracl_shm.c b/grsecurity/gracl_shm.c
63320 new file mode 100644
63321 index 0000000..98011b0
63322 --- /dev/null
63323 +++ b/grsecurity/gracl_shm.c
63324 @@ -0,0 +1,40 @@
63325 +#include <linux/kernel.h>
63326 +#include <linux/mm.h>
63327 +#include <linux/sched.h>
63328 +#include <linux/file.h>
63329 +#include <linux/ipc.h>
63330 +#include <linux/gracl.h>
63331 +#include <linux/grsecurity.h>
63332 +#include <linux/grinternal.h>
63333 +
63334 +int
63335 +gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
63336 + const time_t shm_createtime, const kuid_t cuid, const int shmid)
63337 +{
63338 + struct task_struct *task;
63339 +
63340 + if (!gr_acl_is_enabled())
63341 + return 1;
63342 +
63343 + rcu_read_lock();
63344 + read_lock(&tasklist_lock);
63345 +
63346 + task = find_task_by_vpid(shm_cprid);
63347 +
63348 + if (unlikely(!task))
63349 + task = find_task_by_vpid(shm_lapid);
63350 +
63351 + if (unlikely(task && (time_before_eq((unsigned long)task->start_time.tv_sec, (unsigned long)shm_createtime) ||
63352 + (task_pid_nr(task) == shm_lapid)) &&
63353 + (task->acl->mode & GR_PROTSHM) &&
63354 + (task->acl != current->acl))) {
63355 + read_unlock(&tasklist_lock);
63356 + rcu_read_unlock();
63357 + gr_log_int3(GR_DONT_AUDIT, GR_SHMAT_ACL_MSG, GR_GLOBAL_UID(cuid), shm_cprid, shmid);
63358 + return 0;
63359 + }
63360 + read_unlock(&tasklist_lock);
63361 + rcu_read_unlock();
63362 +
63363 + return 1;
63364 +}
63365 diff --git a/grsecurity/grsec_chdir.c b/grsecurity/grsec_chdir.c
63366 new file mode 100644
63367 index 0000000..bc0be01
63368 --- /dev/null
63369 +++ b/grsecurity/grsec_chdir.c
63370 @@ -0,0 +1,19 @@
63371 +#include <linux/kernel.h>
63372 +#include <linux/sched.h>
63373 +#include <linux/fs.h>
63374 +#include <linux/file.h>
63375 +#include <linux/grsecurity.h>
63376 +#include <linux/grinternal.h>
63377 +
63378 +void
63379 +gr_log_chdir(const struct dentry *dentry, const struct vfsmount *mnt)
63380 +{
63381 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
63382 + if ((grsec_enable_chdir && grsec_enable_group &&
63383 + in_group_p(grsec_audit_gid)) || (grsec_enable_chdir &&
63384 + !grsec_enable_group)) {
63385 + gr_log_fs_generic(GR_DO_AUDIT, GR_CHDIR_AUDIT_MSG, dentry, mnt);
63386 + }
63387 +#endif
63388 + return;
63389 +}
63390 diff --git a/grsecurity/grsec_chroot.c b/grsecurity/grsec_chroot.c
63391 new file mode 100644
63392 index 0000000..bd6e105
63393 --- /dev/null
63394 +++ b/grsecurity/grsec_chroot.c
63395 @@ -0,0 +1,370 @@
63396 +#include <linux/kernel.h>
63397 +#include <linux/module.h>
63398 +#include <linux/sched.h>
63399 +#include <linux/file.h>
63400 +#include <linux/fs.h>
63401 +#include <linux/mount.h>
63402 +#include <linux/types.h>
63403 +#include "../fs/mount.h"
63404 +#include <linux/grsecurity.h>
63405 +#include <linux/grinternal.h>
63406 +
63407 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
63408 +static int gr_init_ran;
63409 +#endif
63410 +
63411 +void gr_set_chroot_entries(struct task_struct *task, const struct path *path)
63412 +{
63413 +#ifdef CONFIG_GRKERNSEC
63414 + if (task_pid_nr(task) > 1 && path->dentry != init_task.fs->root.dentry &&
63415 + path->dentry != task->nsproxy->mnt_ns->root->mnt.mnt_root
63416 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
63417 + && gr_init_ran
63418 +#endif
63419 + )
63420 + task->gr_is_chrooted = 1;
63421 + else {
63422 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
63423 + if (task_pid_nr(task) == 1 && !gr_init_ran)
63424 + gr_init_ran = 1;
63425 +#endif
63426 + task->gr_is_chrooted = 0;
63427 + }
63428 +
63429 + task->gr_chroot_dentry = path->dentry;
63430 +#endif
63431 + return;
63432 +}
63433 +
63434 +void gr_clear_chroot_entries(struct task_struct *task)
63435 +{
63436 +#ifdef CONFIG_GRKERNSEC
63437 + task->gr_is_chrooted = 0;
63438 + task->gr_chroot_dentry = NULL;
63439 +#endif
63440 + return;
63441 +}
63442 +
63443 +int
63444 +gr_handle_chroot_unix(const pid_t pid)
63445 +{
63446 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
63447 + struct task_struct *p;
63448 +
63449 + if (unlikely(!grsec_enable_chroot_unix))
63450 + return 1;
63451 +
63452 + if (likely(!proc_is_chrooted(current)))
63453 + return 1;
63454 +
63455 + rcu_read_lock();
63456 + read_lock(&tasklist_lock);
63457 + p = find_task_by_vpid_unrestricted(pid);
63458 + if (unlikely(p && !have_same_root(current, p))) {
63459 + read_unlock(&tasklist_lock);
63460 + rcu_read_unlock();
63461 + gr_log_noargs(GR_DONT_AUDIT, GR_UNIX_CHROOT_MSG);
63462 + return 0;
63463 + }
63464 + read_unlock(&tasklist_lock);
63465 + rcu_read_unlock();
63466 +#endif
63467 + return 1;
63468 +}
63469 +
63470 +int
63471 +gr_handle_chroot_nice(void)
63472 +{
63473 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
63474 + if (grsec_enable_chroot_nice && proc_is_chrooted(current)) {
63475 + gr_log_noargs(GR_DONT_AUDIT, GR_NICE_CHROOT_MSG);
63476 + return -EPERM;
63477 + }
63478 +#endif
63479 + return 0;
63480 +}
63481 +
63482 +int
63483 +gr_handle_chroot_setpriority(struct task_struct *p, const int niceval)
63484 +{
63485 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
63486 + if (grsec_enable_chroot_nice && (niceval < task_nice(p))
63487 + && proc_is_chrooted(current)) {
63488 + gr_log_str_int(GR_DONT_AUDIT, GR_PRIORITY_CHROOT_MSG, p->comm, task_pid_nr(p));
63489 + return -EACCES;
63490 + }
63491 +#endif
63492 + return 0;
63493 +}
63494 +
63495 +int
63496 +gr_handle_chroot_fowner(struct pid *pid, enum pid_type type)
63497 +{
63498 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
63499 + struct task_struct *p;
63500 + int ret = 0;
63501 + if (!grsec_enable_chroot_findtask || !proc_is_chrooted(current) || !pid)
63502 + return ret;
63503 +
63504 + read_lock(&tasklist_lock);
63505 + do_each_pid_task(pid, type, p) {
63506 + if (!have_same_root(current, p)) {
63507 + ret = 1;
63508 + goto out;
63509 + }
63510 + } while_each_pid_task(pid, type, p);
63511 +out:
63512 + read_unlock(&tasklist_lock);
63513 + return ret;
63514 +#endif
63515 + return 0;
63516 +}
63517 +
63518 +int
63519 +gr_pid_is_chrooted(struct task_struct *p)
63520 +{
63521 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
63522 + if (!grsec_enable_chroot_findtask || !proc_is_chrooted(current) || p == NULL)
63523 + return 0;
63524 +
63525 + if ((p->exit_state & (EXIT_ZOMBIE | EXIT_DEAD)) ||
63526 + !have_same_root(current, p)) {
63527 + return 1;
63528 + }
63529 +#endif
63530 + return 0;
63531 +}
63532 +
63533 +EXPORT_SYMBOL(gr_pid_is_chrooted);
63534 +
63535 +#if defined(CONFIG_GRKERNSEC_CHROOT_DOUBLE) || defined(CONFIG_GRKERNSEC_CHROOT_FCHDIR)
63536 +int gr_is_outside_chroot(const struct dentry *u_dentry, const struct vfsmount *u_mnt)
63537 +{
63538 + struct path path, currentroot;
63539 + int ret = 0;
63540 +
63541 + path.dentry = (struct dentry *)u_dentry;
63542 + path.mnt = (struct vfsmount *)u_mnt;
63543 + get_fs_root(current->fs, &currentroot);
63544 + if (path_is_under(&path, &currentroot))
63545 + ret = 1;
63546 + path_put(&currentroot);
63547 +
63548 + return ret;
63549 +}
63550 +#endif
63551 +
63552 +int
63553 +gr_chroot_fchdir(struct dentry *u_dentry, struct vfsmount *u_mnt)
63554 +{
63555 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
63556 + if (!grsec_enable_chroot_fchdir)
63557 + return 1;
63558 +
63559 + if (!proc_is_chrooted(current))
63560 + return 1;
63561 + else if (!gr_is_outside_chroot(u_dentry, u_mnt)) {
63562 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHROOT_FCHDIR_MSG, u_dentry, u_mnt);
63563 + return 0;
63564 + }
63565 +#endif
63566 + return 1;
63567 +}
63568 +
63569 +int
63570 +gr_chroot_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
63571 + const time_t shm_createtime)
63572 +{
63573 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
63574 + struct task_struct *p;
63575 + time_t starttime;
63576 +
63577 + if (unlikely(!grsec_enable_chroot_shmat))
63578 + return 1;
63579 +
63580 + if (likely(!proc_is_chrooted(current)))
63581 + return 1;
63582 +
63583 + rcu_read_lock();
63584 + read_lock(&tasklist_lock);
63585 +
63586 + if ((p = find_task_by_vpid_unrestricted(shm_cprid))) {
63587 + starttime = p->start_time.tv_sec;
63588 + if (time_before_eq((unsigned long)starttime, (unsigned long)shm_createtime)) {
63589 + if (have_same_root(current, p)) {
63590 + goto allow;
63591 + } else {
63592 + read_unlock(&tasklist_lock);
63593 + rcu_read_unlock();
63594 + gr_log_noargs(GR_DONT_AUDIT, GR_SHMAT_CHROOT_MSG);
63595 + return 0;
63596 + }
63597 + }
63598 + /* creator exited, pid reuse, fall through to next check */
63599 + }
63600 + if ((p = find_task_by_vpid_unrestricted(shm_lapid))) {
63601 + if (unlikely(!have_same_root(current, p))) {
63602 + read_unlock(&tasklist_lock);
63603 + rcu_read_unlock();
63604 + gr_log_noargs(GR_DONT_AUDIT, GR_SHMAT_CHROOT_MSG);
63605 + return 0;
63606 + }
63607 + }
63608 +
63609 +allow:
63610 + read_unlock(&tasklist_lock);
63611 + rcu_read_unlock();
63612 +#endif
63613 + return 1;
63614 +}
63615 +
63616 +void
63617 +gr_log_chroot_exec(const struct dentry *dentry, const struct vfsmount *mnt)
63618 +{
63619 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
63620 + if (grsec_enable_chroot_execlog && proc_is_chrooted(current))
63621 + gr_log_fs_generic(GR_DO_AUDIT, GR_EXEC_CHROOT_MSG, dentry, mnt);
63622 +#endif
63623 + return;
63624 +}
63625 +
63626 +int
63627 +gr_handle_chroot_mknod(const struct dentry *dentry,
63628 + const struct vfsmount *mnt, const int mode)
63629 +{
63630 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
63631 + if (grsec_enable_chroot_mknod && !S_ISFIFO(mode) && !S_ISREG(mode) &&
63632 + proc_is_chrooted(current)) {
63633 + gr_log_fs_generic(GR_DONT_AUDIT, GR_MKNOD_CHROOT_MSG, dentry, mnt);
63634 + return -EPERM;
63635 + }
63636 +#endif
63637 + return 0;
63638 +}
63639 +
63640 +int
63641 +gr_handle_chroot_mount(const struct dentry *dentry,
63642 + const struct vfsmount *mnt, const char *dev_name)
63643 +{
63644 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
63645 + if (grsec_enable_chroot_mount && proc_is_chrooted(current)) {
63646 + gr_log_str_fs(GR_DONT_AUDIT, GR_MOUNT_CHROOT_MSG, dev_name ? dev_name : "none", dentry, mnt);
63647 + return -EPERM;
63648 + }
63649 +#endif
63650 + return 0;
63651 +}
63652 +
63653 +int
63654 +gr_handle_chroot_pivot(void)
63655 +{
63656 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
63657 + if (grsec_enable_chroot_pivot && proc_is_chrooted(current)) {
63658 + gr_log_noargs(GR_DONT_AUDIT, GR_PIVOT_CHROOT_MSG);
63659 + return -EPERM;
63660 + }
63661 +#endif
63662 + return 0;
63663 +}
63664 +
63665 +int
63666 +gr_handle_chroot_chroot(const struct dentry *dentry, const struct vfsmount *mnt)
63667 +{
63668 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
63669 + if (grsec_enable_chroot_double && proc_is_chrooted(current) &&
63670 + !gr_is_outside_chroot(dentry, mnt)) {
63671 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHROOT_CHROOT_MSG, dentry, mnt);
63672 + return -EPERM;
63673 + }
63674 +#endif
63675 + return 0;
63676 +}
63677 +
63678 +extern const char *captab_log[];
63679 +extern int captab_log_entries;
63680 +
63681 +int
63682 +gr_task_chroot_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
63683 +{
63684 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
63685 + if (grsec_enable_chroot_caps && proc_is_chrooted(task)) {
63686 + kernel_cap_t chroot_caps = GR_CHROOT_CAPS;
63687 + if (cap_raised(chroot_caps, cap)) {
63688 + if (cap_raised(cred->cap_effective, cap) && cap < captab_log_entries) {
63689 + gr_log_cap(GR_DONT_AUDIT, GR_CAP_CHROOT_MSG, task, captab_log[cap]);
63690 + }
63691 + return 0;
63692 + }
63693 + }
63694 +#endif
63695 + return 1;
63696 +}
63697 +
63698 +int
63699 +gr_chroot_is_capable(const int cap)
63700 +{
63701 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
63702 + return gr_task_chroot_is_capable(current, current_cred(), cap);
63703 +#endif
63704 + return 1;
63705 +}
63706 +
63707 +int
63708 +gr_task_chroot_is_capable_nolog(const struct task_struct *task, const int cap)
63709 +{
63710 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
63711 + if (grsec_enable_chroot_caps && proc_is_chrooted(task)) {
63712 + kernel_cap_t chroot_caps = GR_CHROOT_CAPS;
63713 + if (cap_raised(chroot_caps, cap)) {
63714 + return 0;
63715 + }
63716 + }
63717 +#endif
63718 + return 1;
63719 +}
63720 +
63721 +int
63722 +gr_chroot_is_capable_nolog(const int cap)
63723 +{
63724 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
63725 + return gr_task_chroot_is_capable_nolog(current, cap);
63726 +#endif
63727 + return 1;
63728 +}
63729 +
63730 +int
63731 +gr_handle_chroot_sysctl(const int op)
63732 +{
63733 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
63734 + if (grsec_enable_chroot_sysctl && (op & MAY_WRITE) &&
63735 + proc_is_chrooted(current))
63736 + return -EACCES;
63737 +#endif
63738 + return 0;
63739 +}
63740 +
63741 +void
63742 +gr_handle_chroot_chdir(const struct path *path)
63743 +{
63744 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
63745 + if (grsec_enable_chroot_chdir)
63746 + set_fs_pwd(current->fs, path);
63747 +#endif
63748 + return;
63749 +}
63750 +
63751 +int
63752 +gr_handle_chroot_chmod(const struct dentry *dentry,
63753 + const struct vfsmount *mnt, const int mode)
63754 +{
63755 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
63756 + /* allow chmod +s on directories, but not files */
63757 + if (grsec_enable_chroot_chmod && !S_ISDIR(dentry->d_inode->i_mode) &&
63758 + ((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))) &&
63759 + proc_is_chrooted(current)) {
63760 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHMOD_CHROOT_MSG, dentry, mnt);
63761 + return -EPERM;
63762 + }
63763 +#endif
63764 + return 0;
63765 +}
63766 diff --git a/grsecurity/grsec_disabled.c b/grsecurity/grsec_disabled.c
63767 new file mode 100644
63768 index 0000000..ce65ceb
63769 --- /dev/null
63770 +++ b/grsecurity/grsec_disabled.c
63771 @@ -0,0 +1,434 @@
63772 +#include <linux/kernel.h>
63773 +#include <linux/module.h>
63774 +#include <linux/sched.h>
63775 +#include <linux/file.h>
63776 +#include <linux/fs.h>
63777 +#include <linux/kdev_t.h>
63778 +#include <linux/net.h>
63779 +#include <linux/in.h>
63780 +#include <linux/ip.h>
63781 +#include <linux/skbuff.h>
63782 +#include <linux/sysctl.h>
63783 +
63784 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
63785 +void
63786 +pax_set_initial_flags(struct linux_binprm *bprm)
63787 +{
63788 + return;
63789 +}
63790 +#endif
63791 +
63792 +#ifdef CONFIG_SYSCTL
63793 +__u32
63794 +gr_handle_sysctl(const struct ctl_table * table, const int op)
63795 +{
63796 + return 0;
63797 +}
63798 +#endif
63799 +
63800 +#ifdef CONFIG_TASKSTATS
63801 +int gr_is_taskstats_denied(int pid)
63802 +{
63803 + return 0;
63804 +}
63805 +#endif
63806 +
63807 +int
63808 +gr_acl_is_enabled(void)
63809 +{
63810 + return 0;
63811 +}
63812 +
63813 +void
63814 +gr_handle_proc_create(const struct dentry *dentry, const struct inode *inode)
63815 +{
63816 + return;
63817 +}
63818 +
63819 +int
63820 +gr_handle_rawio(const struct inode *inode)
63821 +{
63822 + return 0;
63823 +}
63824 +
63825 +void
63826 +gr_acl_handle_psacct(struct task_struct *task, const long code)
63827 +{
63828 + return;
63829 +}
63830 +
63831 +int
63832 +gr_handle_ptrace(struct task_struct *task, const long request)
63833 +{
63834 + return 0;
63835 +}
63836 +
63837 +int
63838 +gr_handle_proc_ptrace(struct task_struct *task)
63839 +{
63840 + return 0;
63841 +}
63842 +
63843 +int
63844 +gr_set_acls(const int type)
63845 +{
63846 + return 0;
63847 +}
63848 +
63849 +int
63850 +gr_check_hidden_task(const struct task_struct *tsk)
63851 +{
63852 + return 0;
63853 +}
63854 +
63855 +int
63856 +gr_check_protected_task(const struct task_struct *task)
63857 +{
63858 + return 0;
63859 +}
63860 +
63861 +int
63862 +gr_check_protected_task_fowner(struct pid *pid, enum pid_type type)
63863 +{
63864 + return 0;
63865 +}
63866 +
63867 +void
63868 +gr_copy_label(struct task_struct *tsk)
63869 +{
63870 + return;
63871 +}
63872 +
63873 +void
63874 +gr_set_pax_flags(struct task_struct *task)
63875 +{
63876 + return;
63877 +}
63878 +
63879 +int
63880 +gr_set_proc_label(const struct dentry *dentry, const struct vfsmount *mnt,
63881 + const int unsafe_share)
63882 +{
63883 + return 0;
63884 +}
63885 +
63886 +void
63887 +gr_handle_delete(const ino_t ino, const dev_t dev)
63888 +{
63889 + return;
63890 +}
63891 +
63892 +void
63893 +gr_handle_create(const struct dentry *dentry, const struct vfsmount *mnt)
63894 +{
63895 + return;
63896 +}
63897 +
63898 +void
63899 +gr_handle_crash(struct task_struct *task, const int sig)
63900 +{
63901 + return;
63902 +}
63903 +
63904 +int
63905 +gr_check_crash_exec(const struct file *filp)
63906 +{
63907 + return 0;
63908 +}
63909 +
63910 +int
63911 +gr_check_crash_uid(const kuid_t uid)
63912 +{
63913 + return 0;
63914 +}
63915 +
63916 +void
63917 +gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
63918 + struct dentry *old_dentry,
63919 + struct dentry *new_dentry,
63920 + struct vfsmount *mnt, const __u8 replace)
63921 +{
63922 + return;
63923 +}
63924 +
63925 +int
63926 +gr_search_socket(const int family, const int type, const int protocol)
63927 +{
63928 + return 1;
63929 +}
63930 +
63931 +int
63932 +gr_search_connectbind(const int mode, const struct socket *sock,
63933 + const struct sockaddr_in *addr)
63934 +{
63935 + return 0;
63936 +}
63937 +
63938 +void
63939 +gr_handle_alertkill(struct task_struct *task)
63940 +{
63941 + return;
63942 +}
63943 +
63944 +__u32
63945 +gr_acl_handle_execve(const struct dentry * dentry, const struct vfsmount * mnt)
63946 +{
63947 + return 1;
63948 +}
63949 +
63950 +__u32
63951 +gr_acl_handle_hidden_file(const struct dentry * dentry,
63952 + const struct vfsmount * mnt)
63953 +{
63954 + return 1;
63955 +}
63956 +
63957 +__u32
63958 +gr_acl_handle_open(const struct dentry * dentry, const struct vfsmount * mnt,
63959 + int acc_mode)
63960 +{
63961 + return 1;
63962 +}
63963 +
63964 +__u32
63965 +gr_acl_handle_rmdir(const struct dentry * dentry, const struct vfsmount * mnt)
63966 +{
63967 + return 1;
63968 +}
63969 +
63970 +__u32
63971 +gr_acl_handle_unlink(const struct dentry * dentry, const struct vfsmount * mnt)
63972 +{
63973 + return 1;
63974 +}
63975 +
63976 +int
63977 +gr_acl_handle_mmap(const struct file *file, const unsigned long prot,
63978 + unsigned int *vm_flags)
63979 +{
63980 + return 1;
63981 +}
63982 +
63983 +__u32
63984 +gr_acl_handle_truncate(const struct dentry * dentry,
63985 + const struct vfsmount * mnt)
63986 +{
63987 + return 1;
63988 +}
63989 +
63990 +__u32
63991 +gr_acl_handle_utime(const struct dentry * dentry, const struct vfsmount * mnt)
63992 +{
63993 + return 1;
63994 +}
63995 +
63996 +__u32
63997 +gr_acl_handle_access(const struct dentry * dentry,
63998 + const struct vfsmount * mnt, const int fmode)
63999 +{
64000 + return 1;
64001 +}
64002 +
64003 +__u32
64004 +gr_acl_handle_chmod(const struct dentry * dentry, const struct vfsmount * mnt,
64005 + umode_t *mode)
64006 +{
64007 + return 1;
64008 +}
64009 +
64010 +__u32
64011 +gr_acl_handle_chown(const struct dentry * dentry, const struct vfsmount * mnt)
64012 +{
64013 + return 1;
64014 +}
64015 +
64016 +__u32
64017 +gr_acl_handle_setxattr(const struct dentry * dentry, const struct vfsmount * mnt)
64018 +{
64019 + return 1;
64020 +}
64021 +
64022 +void
64023 +grsecurity_init(void)
64024 +{
64025 + return;
64026 +}
64027 +
64028 +umode_t gr_acl_umask(void)
64029 +{
64030 + return 0;
64031 +}
64032 +
64033 +__u32
64034 +gr_acl_handle_mknod(const struct dentry * new_dentry,
64035 + const struct dentry * parent_dentry,
64036 + const struct vfsmount * parent_mnt,
64037 + const int mode)
64038 +{
64039 + return 1;
64040 +}
64041 +
64042 +__u32
64043 +gr_acl_handle_mkdir(const struct dentry * new_dentry,
64044 + const struct dentry * parent_dentry,
64045 + const struct vfsmount * parent_mnt)
64046 +{
64047 + return 1;
64048 +}
64049 +
64050 +__u32
64051 +gr_acl_handle_symlink(const struct dentry * new_dentry,
64052 + const struct dentry * parent_dentry,
64053 + const struct vfsmount * parent_mnt, const struct filename *from)
64054 +{
64055 + return 1;
64056 +}
64057 +
64058 +__u32
64059 +gr_acl_handle_link(const struct dentry * new_dentry,
64060 + const struct dentry * parent_dentry,
64061 + const struct vfsmount * parent_mnt,
64062 + const struct dentry * old_dentry,
64063 + const struct vfsmount * old_mnt, const struct filename *to)
64064 +{
64065 + return 1;
64066 +}
64067 +
64068 +int
64069 +gr_acl_handle_rename(const struct dentry *new_dentry,
64070 + const struct dentry *parent_dentry,
64071 + const struct vfsmount *parent_mnt,
64072 + const struct dentry *old_dentry,
64073 + const struct inode *old_parent_inode,
64074 + const struct vfsmount *old_mnt, const struct filename *newname)
64075 +{
64076 + return 0;
64077 +}
64078 +
64079 +int
64080 +gr_acl_handle_filldir(const struct file *file, const char *name,
64081 + const int namelen, const ino_t ino)
64082 +{
64083 + return 1;
64084 +}
64085 +
64086 +int
64087 +gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
64088 + const time_t shm_createtime, const kuid_t cuid, const int shmid)
64089 +{
64090 + return 1;
64091 +}
64092 +
64093 +int
64094 +gr_search_bind(const struct socket *sock, const struct sockaddr_in *addr)
64095 +{
64096 + return 0;
64097 +}
64098 +
64099 +int
64100 +gr_search_accept(const struct socket *sock)
64101 +{
64102 + return 0;
64103 +}
64104 +
64105 +int
64106 +gr_search_listen(const struct socket *sock)
64107 +{
64108 + return 0;
64109 +}
64110 +
64111 +int
64112 +gr_search_connect(const struct socket *sock, const struct sockaddr_in *addr)
64113 +{
64114 + return 0;
64115 +}
64116 +
64117 +__u32
64118 +gr_acl_handle_unix(const struct dentry * dentry, const struct vfsmount * mnt)
64119 +{
64120 + return 1;
64121 +}
64122 +
64123 +__u32
64124 +gr_acl_handle_creat(const struct dentry * dentry,
64125 + const struct dentry * p_dentry,
64126 + const struct vfsmount * p_mnt, int open_flags, int acc_mode,
64127 + const int imode)
64128 +{
64129 + return 1;
64130 +}
64131 +
64132 +void
64133 +gr_acl_handle_exit(void)
64134 +{
64135 + return;
64136 +}
64137 +
64138 +int
64139 +gr_acl_handle_mprotect(const struct file *file, const unsigned long prot)
64140 +{
64141 + return 1;
64142 +}
64143 +
64144 +void
64145 +gr_set_role_label(const kuid_t uid, const kgid_t gid)
64146 +{
64147 + return;
64148 +}
64149 +
64150 +int
64151 +gr_acl_handle_procpidmem(const struct task_struct *task)
64152 +{
64153 + return 0;
64154 +}
64155 +
64156 +int
64157 +gr_search_udp_recvmsg(const struct sock *sk, const struct sk_buff *skb)
64158 +{
64159 + return 0;
64160 +}
64161 +
64162 +int
64163 +gr_search_udp_sendmsg(const struct sock *sk, const struct sockaddr_in *addr)
64164 +{
64165 + return 0;
64166 +}
64167 +
64168 +void
64169 +gr_set_kernel_label(struct task_struct *task)
64170 +{
64171 + return;
64172 +}
64173 +
64174 +int
64175 +gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs)
64176 +{
64177 + return 0;
64178 +}
64179 +
64180 +int
64181 +gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs)
64182 +{
64183 + return 0;
64184 +}
64185 +
64186 +int gr_acl_enable_at_secure(void)
64187 +{
64188 + return 0;
64189 +}
64190 +
64191 +dev_t gr_get_dev_from_dentry(struct dentry *dentry)
64192 +{
64193 + return dentry->d_sb->s_dev;
64194 +}
64195 +
64196 +void gr_put_exec_file(struct task_struct *task)
64197 +{
64198 + return;
64199 +}
64200 +
64201 +EXPORT_SYMBOL(gr_set_kernel_label);
64202 +#ifdef CONFIG_SECURITY
64203 +EXPORT_SYMBOL(gr_check_user_change);
64204 +EXPORT_SYMBOL(gr_check_group_change);
64205 +#endif
64206 diff --git a/grsecurity/grsec_exec.c b/grsecurity/grsec_exec.c
64207 new file mode 100644
64208 index 0000000..387032b
64209 --- /dev/null
64210 +++ b/grsecurity/grsec_exec.c
64211 @@ -0,0 +1,187 @@
64212 +#include <linux/kernel.h>
64213 +#include <linux/sched.h>
64214 +#include <linux/file.h>
64215 +#include <linux/binfmts.h>
64216 +#include <linux/fs.h>
64217 +#include <linux/types.h>
64218 +#include <linux/grdefs.h>
64219 +#include <linux/grsecurity.h>
64220 +#include <linux/grinternal.h>
64221 +#include <linux/capability.h>
64222 +#include <linux/module.h>
64223 +#include <linux/compat.h>
64224 +
64225 +#include <asm/uaccess.h>
64226 +
64227 +#ifdef CONFIG_GRKERNSEC_EXECLOG
64228 +static char gr_exec_arg_buf[132];
64229 +static DEFINE_MUTEX(gr_exec_arg_mutex);
64230 +#endif
64231 +
64232 +struct user_arg_ptr {
64233 +#ifdef CONFIG_COMPAT
64234 + bool is_compat;
64235 +#endif
64236 + union {
64237 + const char __user *const __user *native;
64238 +#ifdef CONFIG_COMPAT
64239 + const compat_uptr_t __user *compat;
64240 +#endif
64241 + } ptr;
64242 +};
64243 +
64244 +extern const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr);
64245 +
64246 +void
64247 +gr_handle_exec_args(struct linux_binprm *bprm, struct user_arg_ptr argv)
64248 +{
64249 +#ifdef CONFIG_GRKERNSEC_EXECLOG
64250 + char *grarg = gr_exec_arg_buf;
64251 + unsigned int i, x, execlen = 0;
64252 + char c;
64253 +
64254 + if (!((grsec_enable_execlog && grsec_enable_group &&
64255 + in_group_p(grsec_audit_gid))
64256 + || (grsec_enable_execlog && !grsec_enable_group)))
64257 + return;
64258 +
64259 + mutex_lock(&gr_exec_arg_mutex);
64260 + memset(grarg, 0, sizeof(gr_exec_arg_buf));
64261 +
64262 + for (i = 0; i < bprm->argc && execlen < 128; i++) {
64263 + const char __user *p;
64264 + unsigned int len;
64265 +
64266 + p = get_user_arg_ptr(argv, i);
64267 + if (IS_ERR(p))
64268 + goto log;
64269 +
64270 + len = strnlen_user(p, 128 - execlen);
64271 + if (len > 128 - execlen)
64272 + len = 128 - execlen;
64273 + else if (len > 0)
64274 + len--;
64275 + if (copy_from_user(grarg + execlen, p, len))
64276 + goto log;
64277 +
64278 + /* rewrite unprintable characters */
64279 + for (x = 0; x < len; x++) {
64280 + c = *(grarg + execlen + x);
64281 + if (c < 32 || c > 126)
64282 + *(grarg + execlen + x) = ' ';
64283 + }
64284 +
64285 + execlen += len;
64286 + *(grarg + execlen) = ' ';
64287 + *(grarg + execlen + 1) = '\0';
64288 + execlen++;
64289 + }
64290 +
64291 + log:
64292 + gr_log_fs_str(GR_DO_AUDIT, GR_EXEC_AUDIT_MSG, bprm->file->f_path.dentry,
64293 + bprm->file->f_path.mnt, grarg);
64294 + mutex_unlock(&gr_exec_arg_mutex);
64295 +#endif
64296 + return;
64297 +}
64298 +
64299 +#ifdef CONFIG_GRKERNSEC
64300 +extern int gr_acl_is_capable(const int cap);
64301 +extern int gr_acl_is_capable_nolog(const int cap);
64302 +extern int gr_task_acl_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
64303 +extern int gr_task_acl_is_capable_nolog(const struct task_struct *task, const int cap);
64304 +extern int gr_chroot_is_capable(const int cap);
64305 +extern int gr_chroot_is_capable_nolog(const int cap);
64306 +extern int gr_task_chroot_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
64307 +extern int gr_task_chroot_is_capable_nolog(const struct task_struct *task, const int cap);
64308 +#endif
64309 +
64310 +const char *captab_log[] = {
64311 + "CAP_CHOWN",
64312 + "CAP_DAC_OVERRIDE",
64313 + "CAP_DAC_READ_SEARCH",
64314 + "CAP_FOWNER",
64315 + "CAP_FSETID",
64316 + "CAP_KILL",
64317 + "CAP_SETGID",
64318 + "CAP_SETUID",
64319 + "CAP_SETPCAP",
64320 + "CAP_LINUX_IMMUTABLE",
64321 + "CAP_NET_BIND_SERVICE",
64322 + "CAP_NET_BROADCAST",
64323 + "CAP_NET_ADMIN",
64324 + "CAP_NET_RAW",
64325 + "CAP_IPC_LOCK",
64326 + "CAP_IPC_OWNER",
64327 + "CAP_SYS_MODULE",
64328 + "CAP_SYS_RAWIO",
64329 + "CAP_SYS_CHROOT",
64330 + "CAP_SYS_PTRACE",
64331 + "CAP_SYS_PACCT",
64332 + "CAP_SYS_ADMIN",
64333 + "CAP_SYS_BOOT",
64334 + "CAP_SYS_NICE",
64335 + "CAP_SYS_RESOURCE",
64336 + "CAP_SYS_TIME",
64337 + "CAP_SYS_TTY_CONFIG",
64338 + "CAP_MKNOD",
64339 + "CAP_LEASE",
64340 + "CAP_AUDIT_WRITE",
64341 + "CAP_AUDIT_CONTROL",
64342 + "CAP_SETFCAP",
64343 + "CAP_MAC_OVERRIDE",
64344 + "CAP_MAC_ADMIN",
64345 + "CAP_SYSLOG",
64346 + "CAP_WAKE_ALARM"
64347 +};
64348 +
64349 +int captab_log_entries = sizeof(captab_log)/sizeof(captab_log[0]);
64350 +
64351 +int gr_is_capable(const int cap)
64352 +{
64353 +#ifdef CONFIG_GRKERNSEC
64354 + if (gr_acl_is_capable(cap) && gr_chroot_is_capable(cap))
64355 + return 1;
64356 + return 0;
64357 +#else
64358 + return 1;
64359 +#endif
64360 +}
64361 +
64362 +int gr_task_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
64363 +{
64364 +#ifdef CONFIG_GRKERNSEC
64365 + if (gr_task_acl_is_capable(task, cred, cap) && gr_task_chroot_is_capable(task, cred, cap))
64366 + return 1;
64367 + return 0;
64368 +#else
64369 + return 1;
64370 +#endif
64371 +}
64372 +
64373 +int gr_is_capable_nolog(const int cap)
64374 +{
64375 +#ifdef CONFIG_GRKERNSEC
64376 + if (gr_acl_is_capable_nolog(cap) && gr_chroot_is_capable_nolog(cap))
64377 + return 1;
64378 + return 0;
64379 +#else
64380 + return 1;
64381 +#endif
64382 +}
64383 +
64384 +int gr_task_is_capable_nolog(const struct task_struct *task, const int cap)
64385 +{
64386 +#ifdef CONFIG_GRKERNSEC
64387 + if (gr_task_acl_is_capable_nolog(task, cap) && gr_task_chroot_is_capable_nolog(task, cap))
64388 + return 1;
64389 + return 0;
64390 +#else
64391 + return 1;
64392 +#endif
64393 +}
64394 +
64395 +EXPORT_SYMBOL(gr_is_capable);
64396 +EXPORT_SYMBOL(gr_is_capable_nolog);
64397 +EXPORT_SYMBOL(gr_task_is_capable);
64398 +EXPORT_SYMBOL(gr_task_is_capable_nolog);
64399 diff --git a/grsecurity/grsec_fifo.c b/grsecurity/grsec_fifo.c
64400 new file mode 100644
64401 index 0000000..06cc6ea
64402 --- /dev/null
64403 +++ b/grsecurity/grsec_fifo.c
64404 @@ -0,0 +1,24 @@
64405 +#include <linux/kernel.h>
64406 +#include <linux/sched.h>
64407 +#include <linux/fs.h>
64408 +#include <linux/file.h>
64409 +#include <linux/grinternal.h>
64410 +
64411 +int
64412 +gr_handle_fifo(const struct dentry *dentry, const struct vfsmount *mnt,
64413 + const struct dentry *dir, const int flag, const int acc_mode)
64414 +{
64415 +#ifdef CONFIG_GRKERNSEC_FIFO
64416 + const struct cred *cred = current_cred();
64417 +
64418 + if (grsec_enable_fifo && S_ISFIFO(dentry->d_inode->i_mode) &&
64419 + !(flag & O_EXCL) && (dir->d_inode->i_mode & S_ISVTX) &&
64420 + !uid_eq(dentry->d_inode->i_uid, dir->d_inode->i_uid) &&
64421 + !uid_eq(cred->fsuid, dentry->d_inode->i_uid)) {
64422 + if (!inode_permission(dentry->d_inode, acc_mode))
64423 + 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));
64424 + return -EACCES;
64425 + }
64426 +#endif
64427 + return 0;
64428 +}
64429 diff --git a/grsecurity/grsec_fork.c b/grsecurity/grsec_fork.c
64430 new file mode 100644
64431 index 0000000..8ca18bf
64432 --- /dev/null
64433 +++ b/grsecurity/grsec_fork.c
64434 @@ -0,0 +1,23 @@
64435 +#include <linux/kernel.h>
64436 +#include <linux/sched.h>
64437 +#include <linux/grsecurity.h>
64438 +#include <linux/grinternal.h>
64439 +#include <linux/errno.h>
64440 +
64441 +void
64442 +gr_log_forkfail(const int retval)
64443 +{
64444 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
64445 + if (grsec_enable_forkfail && (retval == -EAGAIN || retval == -ENOMEM)) {
64446 + switch (retval) {
64447 + case -EAGAIN:
64448 + gr_log_str(GR_DONT_AUDIT, GR_FAILFORK_MSG, "EAGAIN");
64449 + break;
64450 + case -ENOMEM:
64451 + gr_log_str(GR_DONT_AUDIT, GR_FAILFORK_MSG, "ENOMEM");
64452 + break;
64453 + }
64454 + }
64455 +#endif
64456 + return;
64457 +}
64458 diff --git a/grsecurity/grsec_init.c b/grsecurity/grsec_init.c
64459 new file mode 100644
64460 index 0000000..a862e9f
64461 --- /dev/null
64462 +++ b/grsecurity/grsec_init.c
64463 @@ -0,0 +1,283 @@
64464 +#include <linux/kernel.h>
64465 +#include <linux/sched.h>
64466 +#include <linux/mm.h>
64467 +#include <linux/gracl.h>
64468 +#include <linux/slab.h>
64469 +#include <linux/vmalloc.h>
64470 +#include <linux/percpu.h>
64471 +#include <linux/module.h>
64472 +
64473 +int grsec_enable_ptrace_readexec;
64474 +int grsec_enable_setxid;
64475 +int grsec_enable_symlinkown;
64476 +kgid_t grsec_symlinkown_gid;
64477 +int grsec_enable_brute;
64478 +int grsec_enable_link;
64479 +int grsec_enable_dmesg;
64480 +int grsec_enable_harden_ptrace;
64481 +int grsec_enable_fifo;
64482 +int grsec_enable_execlog;
64483 +int grsec_enable_signal;
64484 +int grsec_enable_forkfail;
64485 +int grsec_enable_audit_ptrace;
64486 +int grsec_enable_time;
64487 +int grsec_enable_audit_textrel;
64488 +int grsec_enable_group;
64489 +kgid_t grsec_audit_gid;
64490 +int grsec_enable_chdir;
64491 +int grsec_enable_mount;
64492 +int grsec_enable_rofs;
64493 +int grsec_enable_chroot_findtask;
64494 +int grsec_enable_chroot_mount;
64495 +int grsec_enable_chroot_shmat;
64496 +int grsec_enable_chroot_fchdir;
64497 +int grsec_enable_chroot_double;
64498 +int grsec_enable_chroot_pivot;
64499 +int grsec_enable_chroot_chdir;
64500 +int grsec_enable_chroot_chmod;
64501 +int grsec_enable_chroot_mknod;
64502 +int grsec_enable_chroot_nice;
64503 +int grsec_enable_chroot_execlog;
64504 +int grsec_enable_chroot_caps;
64505 +int grsec_enable_chroot_sysctl;
64506 +int grsec_enable_chroot_unix;
64507 +int grsec_enable_tpe;
64508 +kgid_t grsec_tpe_gid;
64509 +int grsec_enable_blackhole;
64510 +#ifdef CONFIG_IPV6_MODULE
64511 +EXPORT_SYMBOL(grsec_enable_blackhole);
64512 +#endif
64513 +int grsec_lastack_retries;
64514 +int grsec_enable_tpe_all;
64515 +int grsec_enable_tpe_invert;
64516 +int grsec_enable_socket_all;
64517 +kgid_t grsec_socket_all_gid;
64518 +int grsec_enable_socket_client;
64519 +kgid_t grsec_socket_client_gid;
64520 +int grsec_enable_socket_server;
64521 +kgid_t grsec_socket_server_gid;
64522 +int grsec_resource_logging;
64523 +int grsec_disable_privio;
64524 +int grsec_enable_log_rwxmaps;
64525 +int grsec_lock;
64526 +
64527 +DEFINE_SPINLOCK(grsec_alert_lock);
64528 +unsigned long grsec_alert_wtime = 0;
64529 +unsigned long grsec_alert_fyet = 0;
64530 +
64531 +DEFINE_SPINLOCK(grsec_audit_lock);
64532 +
64533 +DEFINE_RWLOCK(grsec_exec_file_lock);
64534 +
64535 +char *gr_shared_page[4];
64536 +
64537 +char *gr_alert_log_fmt;
64538 +char *gr_audit_log_fmt;
64539 +char *gr_alert_log_buf;
64540 +char *gr_audit_log_buf;
64541 +
64542 +extern struct gr_arg *gr_usermode;
64543 +extern unsigned char *gr_system_salt;
64544 +extern unsigned char *gr_system_sum;
64545 +
64546 +void __init
64547 +grsecurity_init(void)
64548 +{
64549 + int j;
64550 + /* create the per-cpu shared pages */
64551 +
64552 +#ifdef CONFIG_X86
64553 + memset((char *)(0x41a + PAGE_OFFSET), 0, 36);
64554 +#endif
64555 +
64556 + for (j = 0; j < 4; j++) {
64557 + gr_shared_page[j] = (char *)__alloc_percpu(PAGE_SIZE, __alignof__(unsigned long long));
64558 + if (gr_shared_page[j] == NULL) {
64559 + panic("Unable to allocate grsecurity shared page");
64560 + return;
64561 + }
64562 + }
64563 +
64564 + /* allocate log buffers */
64565 + gr_alert_log_fmt = kmalloc(512, GFP_KERNEL);
64566 + if (!gr_alert_log_fmt) {
64567 + panic("Unable to allocate grsecurity alert log format buffer");
64568 + return;
64569 + }
64570 + gr_audit_log_fmt = kmalloc(512, GFP_KERNEL);
64571 + if (!gr_audit_log_fmt) {
64572 + panic("Unable to allocate grsecurity audit log format buffer");
64573 + return;
64574 + }
64575 + gr_alert_log_buf = (char *) get_zeroed_page(GFP_KERNEL);
64576 + if (!gr_alert_log_buf) {
64577 + panic("Unable to allocate grsecurity alert log buffer");
64578 + return;
64579 + }
64580 + gr_audit_log_buf = (char *) get_zeroed_page(GFP_KERNEL);
64581 + if (!gr_audit_log_buf) {
64582 + panic("Unable to allocate grsecurity audit log buffer");
64583 + return;
64584 + }
64585 +
64586 + /* allocate memory for authentication structure */
64587 + gr_usermode = kmalloc(sizeof(struct gr_arg), GFP_KERNEL);
64588 + gr_system_salt = kmalloc(GR_SALT_LEN, GFP_KERNEL);
64589 + gr_system_sum = kmalloc(GR_SHA_LEN, GFP_KERNEL);
64590 +
64591 + if (!gr_usermode || !gr_system_salt || !gr_system_sum) {
64592 + panic("Unable to allocate grsecurity authentication structure");
64593 + return;
64594 + }
64595 +
64596 +
64597 +#ifdef CONFIG_GRKERNSEC_IO
64598 +#if !defined(CONFIG_GRKERNSEC_SYSCTL_DISTRO)
64599 + grsec_disable_privio = 1;
64600 +#elif defined(CONFIG_GRKERNSEC_SYSCTL_ON)
64601 + grsec_disable_privio = 1;
64602 +#else
64603 + grsec_disable_privio = 0;
64604 +#endif
64605 +#endif
64606 +
64607 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
64608 + /* for backward compatibility, tpe_invert always defaults to on if
64609 + enabled in the kernel
64610 + */
64611 + grsec_enable_tpe_invert = 1;
64612 +#endif
64613 +
64614 +#if !defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_SYSCTL_ON)
64615 +#ifndef CONFIG_GRKERNSEC_SYSCTL
64616 + grsec_lock = 1;
64617 +#endif
64618 +
64619 +#ifdef CONFIG_GRKERNSEC_AUDIT_TEXTREL
64620 + grsec_enable_audit_textrel = 1;
64621 +#endif
64622 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
64623 + grsec_enable_log_rwxmaps = 1;
64624 +#endif
64625 +#ifdef CONFIG_GRKERNSEC_AUDIT_GROUP
64626 + grsec_enable_group = 1;
64627 + grsec_audit_gid = KGIDT_INIT(CONFIG_GRKERNSEC_AUDIT_GID);
64628 +#endif
64629 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
64630 + grsec_enable_ptrace_readexec = 1;
64631 +#endif
64632 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
64633 + grsec_enable_chdir = 1;
64634 +#endif
64635 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
64636 + grsec_enable_harden_ptrace = 1;
64637 +#endif
64638 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
64639 + grsec_enable_mount = 1;
64640 +#endif
64641 +#ifdef CONFIG_GRKERNSEC_LINK
64642 + grsec_enable_link = 1;
64643 +#endif
64644 +#ifdef CONFIG_GRKERNSEC_BRUTE
64645 + grsec_enable_brute = 1;
64646 +#endif
64647 +#ifdef CONFIG_GRKERNSEC_DMESG
64648 + grsec_enable_dmesg = 1;
64649 +#endif
64650 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
64651 + grsec_enable_blackhole = 1;
64652 + grsec_lastack_retries = 4;
64653 +#endif
64654 +#ifdef CONFIG_GRKERNSEC_FIFO
64655 + grsec_enable_fifo = 1;
64656 +#endif
64657 +#ifdef CONFIG_GRKERNSEC_EXECLOG
64658 + grsec_enable_execlog = 1;
64659 +#endif
64660 +#ifdef CONFIG_GRKERNSEC_SETXID
64661 + grsec_enable_setxid = 1;
64662 +#endif
64663 +#ifdef CONFIG_GRKERNSEC_SIGNAL
64664 + grsec_enable_signal = 1;
64665 +#endif
64666 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
64667 + grsec_enable_forkfail = 1;
64668 +#endif
64669 +#ifdef CONFIG_GRKERNSEC_TIME
64670 + grsec_enable_time = 1;
64671 +#endif
64672 +#ifdef CONFIG_GRKERNSEC_RESLOG
64673 + grsec_resource_logging = 1;
64674 +#endif
64675 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
64676 + grsec_enable_chroot_findtask = 1;
64677 +#endif
64678 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
64679 + grsec_enable_chroot_unix = 1;
64680 +#endif
64681 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
64682 + grsec_enable_chroot_mount = 1;
64683 +#endif
64684 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
64685 + grsec_enable_chroot_fchdir = 1;
64686 +#endif
64687 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
64688 + grsec_enable_chroot_shmat = 1;
64689 +#endif
64690 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
64691 + grsec_enable_audit_ptrace = 1;
64692 +#endif
64693 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
64694 + grsec_enable_chroot_double = 1;
64695 +#endif
64696 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
64697 + grsec_enable_chroot_pivot = 1;
64698 +#endif
64699 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
64700 + grsec_enable_chroot_chdir = 1;
64701 +#endif
64702 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
64703 + grsec_enable_chroot_chmod = 1;
64704 +#endif
64705 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
64706 + grsec_enable_chroot_mknod = 1;
64707 +#endif
64708 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
64709 + grsec_enable_chroot_nice = 1;
64710 +#endif
64711 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
64712 + grsec_enable_chroot_execlog = 1;
64713 +#endif
64714 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
64715 + grsec_enable_chroot_caps = 1;
64716 +#endif
64717 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
64718 + grsec_enable_chroot_sysctl = 1;
64719 +#endif
64720 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
64721 + grsec_enable_symlinkown = 1;
64722 + grsec_symlinkown_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SYMLINKOWN_GID);
64723 +#endif
64724 +#ifdef CONFIG_GRKERNSEC_TPE
64725 + grsec_enable_tpe = 1;
64726 + grsec_tpe_gid = KGIDT_INIT(CONFIG_GRKERNSEC_TPE_GID);
64727 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
64728 + grsec_enable_tpe_all = 1;
64729 +#endif
64730 +#endif
64731 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
64732 + grsec_enable_socket_all = 1;
64733 + grsec_socket_all_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_ALL_GID);
64734 +#endif
64735 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
64736 + grsec_enable_socket_client = 1;
64737 + grsec_socket_client_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_CLIENT_GID);
64738 +#endif
64739 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
64740 + grsec_enable_socket_server = 1;
64741 + grsec_socket_server_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_SERVER_GID);
64742 +#endif
64743 +#endif
64744 +
64745 + return;
64746 +}
64747 diff --git a/grsecurity/grsec_link.c b/grsecurity/grsec_link.c
64748 new file mode 100644
64749 index 0000000..5e05e20
64750 --- /dev/null
64751 +++ b/grsecurity/grsec_link.c
64752 @@ -0,0 +1,58 @@
64753 +#include <linux/kernel.h>
64754 +#include <linux/sched.h>
64755 +#include <linux/fs.h>
64756 +#include <linux/file.h>
64757 +#include <linux/grinternal.h>
64758 +
64759 +int gr_handle_symlink_owner(const struct path *link, const struct inode *target)
64760 +{
64761 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
64762 + const struct inode *link_inode = link->dentry->d_inode;
64763 +
64764 + if (grsec_enable_symlinkown && in_group_p(grsec_symlinkown_gid) &&
64765 + /* ignore root-owned links, e.g. /proc/self */
64766 + gr_is_global_nonroot(link_inode->i_uid) && target &&
64767 + !uid_eq(link_inode->i_uid, target->i_uid)) {
64768 + gr_log_fs_int2(GR_DONT_AUDIT, GR_SYMLINKOWNER_MSG, link->dentry, link->mnt, link_inode->i_uid, target->i_uid);
64769 + return 1;
64770 + }
64771 +#endif
64772 + return 0;
64773 +}
64774 +
64775 +int
64776 +gr_handle_follow_link(const struct inode *parent,
64777 + const struct inode *inode,
64778 + const struct dentry *dentry, const struct vfsmount *mnt)
64779 +{
64780 +#ifdef CONFIG_GRKERNSEC_LINK
64781 + const struct cred *cred = current_cred();
64782 +
64783 + if (grsec_enable_link && S_ISLNK(inode->i_mode) &&
64784 + (parent->i_mode & S_ISVTX) && !uid_eq(parent->i_uid, inode->i_uid) &&
64785 + (parent->i_mode & S_IWOTH) && !uid_eq(cred->fsuid, inode->i_uid)) {
64786 + gr_log_fs_int2(GR_DONT_AUDIT, GR_SYMLINK_MSG, dentry, mnt, inode->i_uid, inode->i_gid);
64787 + return -EACCES;
64788 + }
64789 +#endif
64790 + return 0;
64791 +}
64792 +
64793 +int
64794 +gr_handle_hardlink(const struct dentry *dentry,
64795 + const struct vfsmount *mnt,
64796 + struct inode *inode, const int mode, const struct filename *to)
64797 +{
64798 +#ifdef CONFIG_GRKERNSEC_LINK
64799 + const struct cred *cred = current_cred();
64800 +
64801 + if (grsec_enable_link && !uid_eq(cred->fsuid, inode->i_uid) &&
64802 + (!S_ISREG(mode) || is_privileged_binary(dentry) ||
64803 + (inode_permission(inode, MAY_READ | MAY_WRITE))) &&
64804 + !capable(CAP_FOWNER) && gr_is_global_nonroot(cred->uid)) {
64805 + gr_log_fs_int2_str(GR_DONT_AUDIT, GR_HARDLINK_MSG, dentry, mnt, inode->i_uid, inode->i_gid, to->name);
64806 + return -EPERM;
64807 + }
64808 +#endif
64809 + return 0;
64810 +}
64811 diff --git a/grsecurity/grsec_log.c b/grsecurity/grsec_log.c
64812 new file mode 100644
64813 index 0000000..7c06085
64814 --- /dev/null
64815 +++ b/grsecurity/grsec_log.c
64816 @@ -0,0 +1,326 @@
64817 +#include <linux/kernel.h>
64818 +#include <linux/sched.h>
64819 +#include <linux/file.h>
64820 +#include <linux/tty.h>
64821 +#include <linux/fs.h>
64822 +#include <linux/grinternal.h>
64823 +
64824 +#ifdef CONFIG_TREE_PREEMPT_RCU
64825 +#define DISABLE_PREEMPT() preempt_disable()
64826 +#define ENABLE_PREEMPT() preempt_enable()
64827 +#else
64828 +#define DISABLE_PREEMPT()
64829 +#define ENABLE_PREEMPT()
64830 +#endif
64831 +
64832 +#define BEGIN_LOCKS(x) \
64833 + DISABLE_PREEMPT(); \
64834 + rcu_read_lock(); \
64835 + read_lock(&tasklist_lock); \
64836 + read_lock(&grsec_exec_file_lock); \
64837 + if (x != GR_DO_AUDIT) \
64838 + spin_lock(&grsec_alert_lock); \
64839 + else \
64840 + spin_lock(&grsec_audit_lock)
64841 +
64842 +#define END_LOCKS(x) \
64843 + if (x != GR_DO_AUDIT) \
64844 + spin_unlock(&grsec_alert_lock); \
64845 + else \
64846 + spin_unlock(&grsec_audit_lock); \
64847 + read_unlock(&grsec_exec_file_lock); \
64848 + read_unlock(&tasklist_lock); \
64849 + rcu_read_unlock(); \
64850 + ENABLE_PREEMPT(); \
64851 + if (x == GR_DONT_AUDIT) \
64852 + gr_handle_alertkill(current)
64853 +
64854 +enum {
64855 + FLOODING,
64856 + NO_FLOODING
64857 +};
64858 +
64859 +extern char *gr_alert_log_fmt;
64860 +extern char *gr_audit_log_fmt;
64861 +extern char *gr_alert_log_buf;
64862 +extern char *gr_audit_log_buf;
64863 +
64864 +static int gr_log_start(int audit)
64865 +{
64866 + char *loglevel = (audit == GR_DO_AUDIT) ? KERN_INFO : KERN_ALERT;
64867 + char *fmt = (audit == GR_DO_AUDIT) ? gr_audit_log_fmt : gr_alert_log_fmt;
64868 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
64869 +#if (CONFIG_GRKERNSEC_FLOODTIME > 0 && CONFIG_GRKERNSEC_FLOODBURST > 0)
64870 + unsigned long curr_secs = get_seconds();
64871 +
64872 + if (audit == GR_DO_AUDIT)
64873 + goto set_fmt;
64874 +
64875 + if (!grsec_alert_wtime || time_after(curr_secs, grsec_alert_wtime + CONFIG_GRKERNSEC_FLOODTIME)) {
64876 + grsec_alert_wtime = curr_secs;
64877 + grsec_alert_fyet = 0;
64878 + } else if (time_before_eq(curr_secs, grsec_alert_wtime + CONFIG_GRKERNSEC_FLOODTIME)
64879 + && (grsec_alert_fyet < CONFIG_GRKERNSEC_FLOODBURST)) {
64880 + grsec_alert_fyet++;
64881 + } else if (grsec_alert_fyet == CONFIG_GRKERNSEC_FLOODBURST) {
64882 + grsec_alert_wtime = curr_secs;
64883 + grsec_alert_fyet++;
64884 + printk(KERN_ALERT "grsec: more alerts, logging disabled for %d seconds\n", CONFIG_GRKERNSEC_FLOODTIME);
64885 + return FLOODING;
64886 + }
64887 + else return FLOODING;
64888 +
64889 +set_fmt:
64890 +#endif
64891 + memset(buf, 0, PAGE_SIZE);
64892 + if (current->signal->curr_ip && gr_acl_is_enabled()) {
64893 + sprintf(fmt, "%s%s", loglevel, "grsec: From %pI4: (%.64s:%c:%.950s) ");
64894 + snprintf(buf, PAGE_SIZE - 1, fmt, &current->signal->curr_ip, current->role->rolename, gr_roletype_to_char(), current->acl->filename);
64895 + } else if (current->signal->curr_ip) {
64896 + sprintf(fmt, "%s%s", loglevel, "grsec: From %pI4: ");
64897 + snprintf(buf, PAGE_SIZE - 1, fmt, &current->signal->curr_ip);
64898 + } else if (gr_acl_is_enabled()) {
64899 + sprintf(fmt, "%s%s", loglevel, "grsec: (%.64s:%c:%.950s) ");
64900 + snprintf(buf, PAGE_SIZE - 1, fmt, current->role->rolename, gr_roletype_to_char(), current->acl->filename);
64901 + } else {
64902 + sprintf(fmt, "%s%s", loglevel, "grsec: ");
64903 + strcpy(buf, fmt);
64904 + }
64905 +
64906 + return NO_FLOODING;
64907 +}
64908 +
64909 +static void gr_log_middle(int audit, const char *msg, va_list ap)
64910 + __attribute__ ((format (printf, 2, 0)));
64911 +
64912 +static void gr_log_middle(int audit, const char *msg, va_list ap)
64913 +{
64914 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
64915 + unsigned int len = strlen(buf);
64916 +
64917 + vsnprintf(buf + len, PAGE_SIZE - len - 1, msg, ap);
64918 +
64919 + return;
64920 +}
64921 +
64922 +static void gr_log_middle_varargs(int audit, const char *msg, ...)
64923 + __attribute__ ((format (printf, 2, 3)));
64924 +
64925 +static void gr_log_middle_varargs(int audit, const char *msg, ...)
64926 +{
64927 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
64928 + unsigned int len = strlen(buf);
64929 + va_list ap;
64930 +
64931 + va_start(ap, msg);
64932 + vsnprintf(buf + len, PAGE_SIZE - len - 1, msg, ap);
64933 + va_end(ap);
64934 +
64935 + return;
64936 +}
64937 +
64938 +static void gr_log_end(int audit, int append_default)
64939 +{
64940 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
64941 + if (append_default) {
64942 + struct task_struct *task = current;
64943 + struct task_struct *parent = task->real_parent;
64944 + const struct cred *cred = __task_cred(task);
64945 + const struct cred *pcred = __task_cred(parent);
64946 + unsigned int len = strlen(buf);
64947 +
64948 + 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));
64949 + }
64950 +
64951 + printk("%s\n", buf);
64952 +
64953 + return;
64954 +}
64955 +
64956 +void gr_log_varargs(int audit, const char *msg, int argtypes, ...)
64957 +{
64958 + int logtype;
64959 + char *result = (audit == GR_DO_AUDIT) ? "successful" : "denied";
64960 + char *str1 = NULL, *str2 = NULL, *str3 = NULL;
64961 + void *voidptr = NULL;
64962 + int num1 = 0, num2 = 0;
64963 + unsigned long ulong1 = 0, ulong2 = 0;
64964 + struct dentry *dentry = NULL;
64965 + struct vfsmount *mnt = NULL;
64966 + struct file *file = NULL;
64967 + struct task_struct *task = NULL;
64968 + const struct cred *cred, *pcred;
64969 + va_list ap;
64970 +
64971 + BEGIN_LOCKS(audit);
64972 + logtype = gr_log_start(audit);
64973 + if (logtype == FLOODING) {
64974 + END_LOCKS(audit);
64975 + return;
64976 + }
64977 + va_start(ap, argtypes);
64978 + switch (argtypes) {
64979 + case GR_TTYSNIFF:
64980 + task = va_arg(ap, struct task_struct *);
64981 + 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));
64982 + break;
64983 + case GR_SYSCTL_HIDDEN:
64984 + str1 = va_arg(ap, char *);
64985 + gr_log_middle_varargs(audit, msg, result, str1);
64986 + break;
64987 + case GR_RBAC:
64988 + dentry = va_arg(ap, struct dentry *);
64989 + mnt = va_arg(ap, struct vfsmount *);
64990 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt));
64991 + break;
64992 + case GR_RBAC_STR:
64993 + dentry = va_arg(ap, struct dentry *);
64994 + mnt = va_arg(ap, struct vfsmount *);
64995 + str1 = va_arg(ap, char *);
64996 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1);
64997 + break;
64998 + case GR_STR_RBAC:
64999 + str1 = va_arg(ap, char *);
65000 + dentry = va_arg(ap, struct dentry *);
65001 + mnt = va_arg(ap, struct vfsmount *);
65002 + gr_log_middle_varargs(audit, msg, result, str1, gr_to_filename(dentry, mnt));
65003 + break;
65004 + case GR_RBAC_MODE2:
65005 + dentry = va_arg(ap, struct dentry *);
65006 + mnt = va_arg(ap, struct vfsmount *);
65007 + str1 = va_arg(ap, char *);
65008 + str2 = va_arg(ap, char *);
65009 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1, str2);
65010 + break;
65011 + case GR_RBAC_MODE3:
65012 + dentry = va_arg(ap, struct dentry *);
65013 + mnt = va_arg(ap, struct vfsmount *);
65014 + str1 = va_arg(ap, char *);
65015 + str2 = va_arg(ap, char *);
65016 + str3 = va_arg(ap, char *);
65017 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1, str2, str3);
65018 + break;
65019 + case GR_FILENAME:
65020 + dentry = va_arg(ap, struct dentry *);
65021 + mnt = va_arg(ap, struct vfsmount *);
65022 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt));
65023 + break;
65024 + case GR_STR_FILENAME:
65025 + str1 = va_arg(ap, char *);
65026 + dentry = va_arg(ap, struct dentry *);
65027 + mnt = va_arg(ap, struct vfsmount *);
65028 + gr_log_middle_varargs(audit, msg, str1, gr_to_filename(dentry, mnt));
65029 + break;
65030 + case GR_FILENAME_STR:
65031 + dentry = va_arg(ap, struct dentry *);
65032 + mnt = va_arg(ap, struct vfsmount *);
65033 + str1 = va_arg(ap, char *);
65034 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), str1);
65035 + break;
65036 + case GR_FILENAME_TWO_INT:
65037 + dentry = va_arg(ap, struct dentry *);
65038 + mnt = va_arg(ap, struct vfsmount *);
65039 + num1 = va_arg(ap, int);
65040 + num2 = va_arg(ap, int);
65041 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), num1, num2);
65042 + break;
65043 + case GR_FILENAME_TWO_INT_STR:
65044 + dentry = va_arg(ap, struct dentry *);
65045 + mnt = va_arg(ap, struct vfsmount *);
65046 + num1 = va_arg(ap, int);
65047 + num2 = va_arg(ap, int);
65048 + str1 = va_arg(ap, char *);
65049 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), num1, num2, str1);
65050 + break;
65051 + case GR_TEXTREL:
65052 + file = va_arg(ap, struct file *);
65053 + ulong1 = va_arg(ap, unsigned long);
65054 + ulong2 = va_arg(ap, unsigned long);
65055 + gr_log_middle_varargs(audit, msg, file ? gr_to_filename(file->f_path.dentry, file->f_path.mnt) : "<anonymous mapping>", ulong1, ulong2);
65056 + break;
65057 + case GR_PTRACE:
65058 + task = va_arg(ap, struct task_struct *);
65059 + 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));
65060 + break;
65061 + case GR_RESOURCE:
65062 + task = va_arg(ap, struct task_struct *);
65063 + cred = __task_cred(task);
65064 + pcred = __task_cred(task->real_parent);
65065 + ulong1 = va_arg(ap, unsigned long);
65066 + str1 = va_arg(ap, char *);
65067 + ulong2 = va_arg(ap, unsigned long);
65068 + 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));
65069 + break;
65070 + case GR_CAP:
65071 + task = va_arg(ap, struct task_struct *);
65072 + cred = __task_cred(task);
65073 + pcred = __task_cred(task->real_parent);
65074 + str1 = va_arg(ap, char *);
65075 + 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));
65076 + break;
65077 + case GR_SIG:
65078 + str1 = va_arg(ap, char *);
65079 + voidptr = va_arg(ap, void *);
65080 + gr_log_middle_varargs(audit, msg, str1, voidptr);
65081 + break;
65082 + case GR_SIG2:
65083 + task = va_arg(ap, struct task_struct *);
65084 + cred = __task_cred(task);
65085 + pcred = __task_cred(task->real_parent);
65086 + num1 = va_arg(ap, int);
65087 + 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));
65088 + break;
65089 + case GR_CRASH1:
65090 + task = va_arg(ap, struct task_struct *);
65091 + cred = __task_cred(task);
65092 + pcred = __task_cred(task->real_parent);
65093 + ulong1 = va_arg(ap, unsigned long);
65094 + 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);
65095 + break;
65096 + case GR_CRASH2:
65097 + task = va_arg(ap, struct task_struct *);
65098 + cred = __task_cred(task);
65099 + pcred = __task_cred(task->real_parent);
65100 + ulong1 = va_arg(ap, unsigned long);
65101 + 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);
65102 + break;
65103 + case GR_RWXMAP:
65104 + file = va_arg(ap, struct file *);
65105 + gr_log_middle_varargs(audit, msg, file ? gr_to_filename(file->f_path.dentry, file->f_path.mnt) : "<anonymous mapping>");
65106 + break;
65107 + case GR_PSACCT:
65108 + {
65109 + unsigned int wday, cday;
65110 + __u8 whr, chr;
65111 + __u8 wmin, cmin;
65112 + __u8 wsec, csec;
65113 + char cur_tty[64] = { 0 };
65114 + char parent_tty[64] = { 0 };
65115 +
65116 + task = va_arg(ap, struct task_struct *);
65117 + wday = va_arg(ap, unsigned int);
65118 + cday = va_arg(ap, unsigned int);
65119 + whr = va_arg(ap, int);
65120 + chr = va_arg(ap, int);
65121 + wmin = va_arg(ap, int);
65122 + cmin = va_arg(ap, int);
65123 + wsec = va_arg(ap, int);
65124 + csec = va_arg(ap, int);
65125 + ulong1 = va_arg(ap, unsigned long);
65126 + cred = __task_cred(task);
65127 + pcred = __task_cred(task->real_parent);
65128 +
65129 + 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));
65130 + }
65131 + break;
65132 + default:
65133 + gr_log_middle(audit, msg, ap);
65134 + }
65135 + va_end(ap);
65136 + // these don't need DEFAULTSECARGS printed on the end
65137 + if (argtypes == GR_CRASH1 || argtypes == GR_CRASH2)
65138 + gr_log_end(audit, 0);
65139 + else
65140 + gr_log_end(audit, 1);
65141 + END_LOCKS(audit);
65142 +}
65143 diff --git a/grsecurity/grsec_mem.c b/grsecurity/grsec_mem.c
65144 new file mode 100644
65145 index 0000000..f536303
65146 --- /dev/null
65147 +++ b/grsecurity/grsec_mem.c
65148 @@ -0,0 +1,40 @@
65149 +#include <linux/kernel.h>
65150 +#include <linux/sched.h>
65151 +#include <linux/mm.h>
65152 +#include <linux/mman.h>
65153 +#include <linux/grinternal.h>
65154 +
65155 +void
65156 +gr_handle_ioperm(void)
65157 +{
65158 + gr_log_noargs(GR_DONT_AUDIT, GR_IOPERM_MSG);
65159 + return;
65160 +}
65161 +
65162 +void
65163 +gr_handle_iopl(void)
65164 +{
65165 + gr_log_noargs(GR_DONT_AUDIT, GR_IOPL_MSG);
65166 + return;
65167 +}
65168 +
65169 +void
65170 +gr_handle_mem_readwrite(u64 from, u64 to)
65171 +{
65172 + gr_log_two_u64(GR_DONT_AUDIT, GR_MEM_READWRITE_MSG, from, to);
65173 + return;
65174 +}
65175 +
65176 +void
65177 +gr_handle_vm86(void)
65178 +{
65179 + gr_log_noargs(GR_DONT_AUDIT, GR_VM86_MSG);
65180 + return;
65181 +}
65182 +
65183 +void
65184 +gr_log_badprocpid(const char *entry)
65185 +{
65186 + gr_log_str(GR_DONT_AUDIT, GR_BADPROCPID_MSG, entry);
65187 + return;
65188 +}
65189 diff --git a/grsecurity/grsec_mount.c b/grsecurity/grsec_mount.c
65190 new file mode 100644
65191 index 0000000..2131422
65192 --- /dev/null
65193 +++ b/grsecurity/grsec_mount.c
65194 @@ -0,0 +1,62 @@
65195 +#include <linux/kernel.h>
65196 +#include <linux/sched.h>
65197 +#include <linux/mount.h>
65198 +#include <linux/grsecurity.h>
65199 +#include <linux/grinternal.h>
65200 +
65201 +void
65202 +gr_log_remount(const char *devname, const int retval)
65203 +{
65204 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
65205 + if (grsec_enable_mount && (retval >= 0))
65206 + gr_log_str(GR_DO_AUDIT, GR_REMOUNT_AUDIT_MSG, devname ? devname : "none");
65207 +#endif
65208 + return;
65209 +}
65210 +
65211 +void
65212 +gr_log_unmount(const char *devname, const int retval)
65213 +{
65214 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
65215 + if (grsec_enable_mount && (retval >= 0))
65216 + gr_log_str(GR_DO_AUDIT, GR_UNMOUNT_AUDIT_MSG, devname ? devname : "none");
65217 +#endif
65218 + return;
65219 +}
65220 +
65221 +void
65222 +gr_log_mount(const char *from, const char *to, const int retval)
65223 +{
65224 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
65225 + if (grsec_enable_mount && (retval >= 0))
65226 + gr_log_str_str(GR_DO_AUDIT, GR_MOUNT_AUDIT_MSG, from ? from : "none", to);
65227 +#endif
65228 + return;
65229 +}
65230 +
65231 +int
65232 +gr_handle_rofs_mount(struct dentry *dentry, struct vfsmount *mnt, int mnt_flags)
65233 +{
65234 +#ifdef CONFIG_GRKERNSEC_ROFS
65235 + if (grsec_enable_rofs && !(mnt_flags & MNT_READONLY)) {
65236 + gr_log_fs_generic(GR_DO_AUDIT, GR_ROFS_MOUNT_MSG, dentry, mnt);
65237 + return -EPERM;
65238 + } else
65239 + return 0;
65240 +#endif
65241 + return 0;
65242 +}
65243 +
65244 +int
65245 +gr_handle_rofs_blockwrite(struct dentry *dentry, struct vfsmount *mnt, int acc_mode)
65246 +{
65247 +#ifdef CONFIG_GRKERNSEC_ROFS
65248 + if (grsec_enable_rofs && (acc_mode & MAY_WRITE) &&
65249 + dentry->d_inode && S_ISBLK(dentry->d_inode->i_mode)) {
65250 + gr_log_fs_generic(GR_DO_AUDIT, GR_ROFS_BLOCKWRITE_MSG, dentry, mnt);
65251 + return -EPERM;
65252 + } else
65253 + return 0;
65254 +#endif
65255 + return 0;
65256 +}
65257 diff --git a/grsecurity/grsec_pax.c b/grsecurity/grsec_pax.c
65258 new file mode 100644
65259 index 0000000..a3b12a0
65260 --- /dev/null
65261 +++ b/grsecurity/grsec_pax.c
65262 @@ -0,0 +1,36 @@
65263 +#include <linux/kernel.h>
65264 +#include <linux/sched.h>
65265 +#include <linux/mm.h>
65266 +#include <linux/file.h>
65267 +#include <linux/grinternal.h>
65268 +#include <linux/grsecurity.h>
65269 +
65270 +void
65271 +gr_log_textrel(struct vm_area_struct * vma)
65272 +{
65273 +#ifdef CONFIG_GRKERNSEC_AUDIT_TEXTREL
65274 + if (grsec_enable_audit_textrel)
65275 + gr_log_textrel_ulong_ulong(GR_DO_AUDIT, GR_TEXTREL_AUDIT_MSG, vma->vm_file, vma->vm_start, vma->vm_pgoff);
65276 +#endif
65277 + return;
65278 +}
65279 +
65280 +void
65281 +gr_log_rwxmmap(struct file *file)
65282 +{
65283 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
65284 + if (grsec_enable_log_rwxmaps)
65285 + gr_log_rwxmap(GR_DONT_AUDIT, GR_RWXMMAP_MSG, file);
65286 +#endif
65287 + return;
65288 +}
65289 +
65290 +void
65291 +gr_log_rwxmprotect(struct file *file)
65292 +{
65293 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
65294 + if (grsec_enable_log_rwxmaps)
65295 + gr_log_rwxmap(GR_DONT_AUDIT, GR_RWXMPROTECT_MSG, file);
65296 +#endif
65297 + return;
65298 +}
65299 diff --git a/grsecurity/grsec_ptrace.c b/grsecurity/grsec_ptrace.c
65300 new file mode 100644
65301 index 0000000..f7f29aa
65302 --- /dev/null
65303 +++ b/grsecurity/grsec_ptrace.c
65304 @@ -0,0 +1,30 @@
65305 +#include <linux/kernel.h>
65306 +#include <linux/sched.h>
65307 +#include <linux/grinternal.h>
65308 +#include <linux/security.h>
65309 +
65310 +void
65311 +gr_audit_ptrace(struct task_struct *task)
65312 +{
65313 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
65314 + if (grsec_enable_audit_ptrace)
65315 + gr_log_ptrace(GR_DO_AUDIT, GR_PTRACE_AUDIT_MSG, task);
65316 +#endif
65317 + return;
65318 +}
65319 +
65320 +int
65321 +gr_ptrace_readexec(struct file *file, int unsafe_flags)
65322 +{
65323 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
65324 + const struct dentry *dentry = file->f_path.dentry;
65325 + const struct vfsmount *mnt = file->f_path.mnt;
65326 +
65327 + if (grsec_enable_ptrace_readexec && (unsafe_flags & LSM_UNSAFE_PTRACE) &&
65328 + (inode_permission(dentry->d_inode, MAY_READ) || !gr_acl_handle_open(dentry, mnt, MAY_READ))) {
65329 + gr_log_fs_generic(GR_DONT_AUDIT, GR_PTRACE_READEXEC_MSG, dentry, mnt);
65330 + return -EACCES;
65331 + }
65332 +#endif
65333 + return 0;
65334 +}
65335 diff --git a/grsecurity/grsec_sig.c b/grsecurity/grsec_sig.c
65336 new file mode 100644
65337 index 0000000..e09715a
65338 --- /dev/null
65339 +++ b/grsecurity/grsec_sig.c
65340 @@ -0,0 +1,222 @@
65341 +#include <linux/kernel.h>
65342 +#include <linux/sched.h>
65343 +#include <linux/delay.h>
65344 +#include <linux/grsecurity.h>
65345 +#include <linux/grinternal.h>
65346 +#include <linux/hardirq.h>
65347 +
65348 +char *signames[] = {
65349 + [SIGSEGV] = "Segmentation fault",
65350 + [SIGILL] = "Illegal instruction",
65351 + [SIGABRT] = "Abort",
65352 + [SIGBUS] = "Invalid alignment/Bus error"
65353 +};
65354 +
65355 +void
65356 +gr_log_signal(const int sig, const void *addr, const struct task_struct *t)
65357 +{
65358 +#ifdef CONFIG_GRKERNSEC_SIGNAL
65359 + if (grsec_enable_signal && ((sig == SIGSEGV) || (sig == SIGILL) ||
65360 + (sig == SIGABRT) || (sig == SIGBUS))) {
65361 + if (task_pid_nr(t) == task_pid_nr(current)) {
65362 + gr_log_sig_addr(GR_DONT_AUDIT_GOOD, GR_UNISIGLOG_MSG, signames[sig], addr);
65363 + } else {
65364 + gr_log_sig_task(GR_DONT_AUDIT_GOOD, GR_DUALSIGLOG_MSG, t, sig);
65365 + }
65366 + }
65367 +#endif
65368 + return;
65369 +}
65370 +
65371 +int
65372 +gr_handle_signal(const struct task_struct *p, const int sig)
65373 +{
65374 +#ifdef CONFIG_GRKERNSEC
65375 + /* ignore the 0 signal for protected task checks */
65376 + if (task_pid_nr(current) > 1 && sig && gr_check_protected_task(p)) {
65377 + gr_log_sig_task(GR_DONT_AUDIT, GR_SIG_ACL_MSG, p, sig);
65378 + return -EPERM;
65379 + } else if (gr_pid_is_chrooted((struct task_struct *)p)) {
65380 + return -EPERM;
65381 + }
65382 +#endif
65383 + return 0;
65384 +}
65385 +
65386 +#ifdef CONFIG_GRKERNSEC
65387 +extern int specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t);
65388 +
65389 +int gr_fake_force_sig(int sig, struct task_struct *t)
65390 +{
65391 + unsigned long int flags;
65392 + int ret, blocked, ignored;
65393 + struct k_sigaction *action;
65394 +
65395 + spin_lock_irqsave(&t->sighand->siglock, flags);
65396 + action = &t->sighand->action[sig-1];
65397 + ignored = action->sa.sa_handler == SIG_IGN;
65398 + blocked = sigismember(&t->blocked, sig);
65399 + if (blocked || ignored) {
65400 + action->sa.sa_handler = SIG_DFL;
65401 + if (blocked) {
65402 + sigdelset(&t->blocked, sig);
65403 + recalc_sigpending_and_wake(t);
65404 + }
65405 + }
65406 + if (action->sa.sa_handler == SIG_DFL)
65407 + t->signal->flags &= ~SIGNAL_UNKILLABLE;
65408 + ret = specific_send_sig_info(sig, SEND_SIG_PRIV, t);
65409 +
65410 + spin_unlock_irqrestore(&t->sighand->siglock, flags);
65411 +
65412 + return ret;
65413 +}
65414 +#endif
65415 +
65416 +#ifdef CONFIG_GRKERNSEC_BRUTE
65417 +#define GR_USER_BAN_TIME (15 * 60)
65418 +#define GR_DAEMON_BRUTE_TIME (30 * 60)
65419 +
65420 +static int __get_dumpable(unsigned long mm_flags)
65421 +{
65422 + int ret;
65423 +
65424 + ret = mm_flags & MMF_DUMPABLE_MASK;
65425 + return (ret >= 2) ? 2 : ret;
65426 +}
65427 +#endif
65428 +
65429 +void gr_handle_brute_attach(unsigned long mm_flags)
65430 +{
65431 +#ifdef CONFIG_GRKERNSEC_BRUTE
65432 + struct task_struct *p = current;
65433 + kuid_t uid = GLOBAL_ROOT_UID;
65434 + int daemon = 0;
65435 +
65436 + if (!grsec_enable_brute)
65437 + return;
65438 +
65439 + rcu_read_lock();
65440 + read_lock(&tasklist_lock);
65441 + read_lock(&grsec_exec_file_lock);
65442 + if (p->real_parent && p->real_parent->exec_file == p->exec_file) {
65443 + p->real_parent->brute_expires = get_seconds() + GR_DAEMON_BRUTE_TIME;
65444 + p->real_parent->brute = 1;
65445 + daemon = 1;
65446 + } else {
65447 + const struct cred *cred = __task_cred(p), *cred2;
65448 + struct task_struct *tsk, *tsk2;
65449 +
65450 + if (!__get_dumpable(mm_flags) && gr_is_global_nonroot(cred->uid)) {
65451 + struct user_struct *user;
65452 +
65453 + uid = cred->uid;
65454 +
65455 + /* this is put upon execution past expiration */
65456 + user = find_user(uid);
65457 + if (user == NULL)
65458 + goto unlock;
65459 + user->banned = 1;
65460 + user->ban_expires = get_seconds() + GR_USER_BAN_TIME;
65461 + if (user->ban_expires == ~0UL)
65462 + user->ban_expires--;
65463 +
65464 + do_each_thread(tsk2, tsk) {
65465 + cred2 = __task_cred(tsk);
65466 + if (tsk != p && uid_eq(cred2->uid, uid))
65467 + gr_fake_force_sig(SIGKILL, tsk);
65468 + } while_each_thread(tsk2, tsk);
65469 + }
65470 + }
65471 +unlock:
65472 + read_unlock(&grsec_exec_file_lock);
65473 + read_unlock(&tasklist_lock);
65474 + rcu_read_unlock();
65475 +
65476 + if (gr_is_global_nonroot(uid))
65477 + printk(KERN_ALERT "grsec: bruteforce prevention initiated against uid %u, banning for %d minutes\n",
65478 + GR_GLOBAL_UID(uid), GR_USER_BAN_TIME / 60);
65479 + else if (daemon)
65480 + gr_log_noargs(GR_DONT_AUDIT, GR_BRUTE_DAEMON_MSG);
65481 +
65482 +#endif
65483 + return;
65484 +}
65485 +
65486 +void gr_handle_brute_check(void)
65487 +{
65488 +#ifdef CONFIG_GRKERNSEC_BRUTE
65489 + struct task_struct *p = current;
65490 +
65491 + if (unlikely(p->brute)) {
65492 + if (!grsec_enable_brute)
65493 + p->brute = 0;
65494 + else if (time_before(get_seconds(), p->brute_expires))
65495 + msleep(30 * 1000);
65496 + }
65497 +#endif
65498 + return;
65499 +}
65500 +
65501 +void gr_handle_kernel_exploit(void)
65502 +{
65503 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
65504 + const struct cred *cred;
65505 + struct task_struct *tsk, *tsk2;
65506 + struct user_struct *user;
65507 + kuid_t uid;
65508 +
65509 + if (in_irq() || in_serving_softirq() || in_nmi())
65510 + panic("grsec: halting the system due to suspicious kernel crash caused in interrupt context");
65511 +
65512 + uid = current_uid();
65513 +
65514 + if (gr_is_global_root(uid))
65515 + panic("grsec: halting the system due to suspicious kernel crash caused by root");
65516 + else {
65517 + /* kill all the processes of this user, hold a reference
65518 + to their creds struct, and prevent them from creating
65519 + another process until system reset
65520 + */
65521 + printk(KERN_ALERT "grsec: banning user with uid %u until system restart for suspicious kernel crash\n",
65522 + GR_GLOBAL_UID(uid));
65523 + /* we intentionally leak this ref */
65524 + user = get_uid(current->cred->user);
65525 + if (user) {
65526 + user->banned = 1;
65527 + user->ban_expires = ~0UL;
65528 + }
65529 +
65530 + read_lock(&tasklist_lock);
65531 + do_each_thread(tsk2, tsk) {
65532 + cred = __task_cred(tsk);
65533 + if (uid_eq(cred->uid, uid))
65534 + gr_fake_force_sig(SIGKILL, tsk);
65535 + } while_each_thread(tsk2, tsk);
65536 + read_unlock(&tasklist_lock);
65537 + }
65538 +#endif
65539 +}
65540 +
65541 +int __gr_process_user_ban(struct user_struct *user)
65542 +{
65543 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT) || defined(CONFIG_GRKERNSEC_BRUTE)
65544 + if (unlikely(user->banned)) {
65545 + if (user->ban_expires != ~0UL && time_after_eq(get_seconds(), user->ban_expires)) {
65546 + user->banned = 0;
65547 + user->ban_expires = 0;
65548 + free_uid(user);
65549 + } else
65550 + return -EPERM;
65551 + }
65552 +#endif
65553 + return 0;
65554 +}
65555 +
65556 +int gr_process_user_ban(void)
65557 +{
65558 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT) || defined(CONFIG_GRKERNSEC_BRUTE)
65559 + return __gr_process_user_ban(current->cred->user);
65560 +#endif
65561 + return 0;
65562 +}
65563 diff --git a/grsecurity/grsec_sock.c b/grsecurity/grsec_sock.c
65564 new file mode 100644
65565 index 0000000..4030d57
65566 --- /dev/null
65567 +++ b/grsecurity/grsec_sock.c
65568 @@ -0,0 +1,244 @@
65569 +#include <linux/kernel.h>
65570 +#include <linux/module.h>
65571 +#include <linux/sched.h>
65572 +#include <linux/file.h>
65573 +#include <linux/net.h>
65574 +#include <linux/in.h>
65575 +#include <linux/ip.h>
65576 +#include <net/sock.h>
65577 +#include <net/inet_sock.h>
65578 +#include <linux/grsecurity.h>
65579 +#include <linux/grinternal.h>
65580 +#include <linux/gracl.h>
65581 +
65582 +extern int gr_search_udp_recvmsg(const struct sock *sk, const struct sk_buff *skb);
65583 +extern int gr_search_udp_sendmsg(const struct sock *sk, const struct sockaddr_in *addr);
65584 +
65585 +EXPORT_SYMBOL(gr_search_udp_recvmsg);
65586 +EXPORT_SYMBOL(gr_search_udp_sendmsg);
65587 +
65588 +#ifdef CONFIG_UNIX_MODULE
65589 +EXPORT_SYMBOL(gr_acl_handle_unix);
65590 +EXPORT_SYMBOL(gr_acl_handle_mknod);
65591 +EXPORT_SYMBOL(gr_handle_chroot_unix);
65592 +EXPORT_SYMBOL(gr_handle_create);
65593 +#endif
65594 +
65595 +#ifdef CONFIG_GRKERNSEC
65596 +#define gr_conn_table_size 32749
65597 +struct conn_table_entry {
65598 + struct conn_table_entry *next;
65599 + struct signal_struct *sig;
65600 +};
65601 +
65602 +struct conn_table_entry *gr_conn_table[gr_conn_table_size];
65603 +DEFINE_SPINLOCK(gr_conn_table_lock);
65604 +
65605 +extern const char * gr_socktype_to_name(unsigned char type);
65606 +extern const char * gr_proto_to_name(unsigned char proto);
65607 +extern const char * gr_sockfamily_to_name(unsigned char family);
65608 +
65609 +static __inline__ int
65610 +conn_hash(__u32 saddr, __u32 daddr, __u16 sport, __u16 dport, unsigned int size)
65611 +{
65612 + return ((daddr + saddr + (sport << 8) + (dport << 16)) % size);
65613 +}
65614 +
65615 +static __inline__ int
65616 +conn_match(const struct signal_struct *sig, __u32 saddr, __u32 daddr,
65617 + __u16 sport, __u16 dport)
65618 +{
65619 + if (unlikely(sig->gr_saddr == saddr && sig->gr_daddr == daddr &&
65620 + sig->gr_sport == sport && sig->gr_dport == dport))
65621 + return 1;
65622 + else
65623 + return 0;
65624 +}
65625 +
65626 +static void gr_add_to_task_ip_table_nolock(struct signal_struct *sig, struct conn_table_entry *newent)
65627 +{
65628 + struct conn_table_entry **match;
65629 + unsigned int index;
65630 +
65631 + index = conn_hash(sig->gr_saddr, sig->gr_daddr,
65632 + sig->gr_sport, sig->gr_dport,
65633 + gr_conn_table_size);
65634 +
65635 + newent->sig = sig;
65636 +
65637 + match = &gr_conn_table[index];
65638 + newent->next = *match;
65639 + *match = newent;
65640 +
65641 + return;
65642 +}
65643 +
65644 +static void gr_del_task_from_ip_table_nolock(struct signal_struct *sig)
65645 +{
65646 + struct conn_table_entry *match, *last = NULL;
65647 + unsigned int index;
65648 +
65649 + index = conn_hash(sig->gr_saddr, sig->gr_daddr,
65650 + sig->gr_sport, sig->gr_dport,
65651 + gr_conn_table_size);
65652 +
65653 + match = gr_conn_table[index];
65654 + while (match && !conn_match(match->sig,
65655 + sig->gr_saddr, sig->gr_daddr, sig->gr_sport,
65656 + sig->gr_dport)) {
65657 + last = match;
65658 + match = match->next;
65659 + }
65660 +
65661 + if (match) {
65662 + if (last)
65663 + last->next = match->next;
65664 + else
65665 + gr_conn_table[index] = NULL;
65666 + kfree(match);
65667 + }
65668 +
65669 + return;
65670 +}
65671 +
65672 +static struct signal_struct * gr_lookup_task_ip_table(__u32 saddr, __u32 daddr,
65673 + __u16 sport, __u16 dport)
65674 +{
65675 + struct conn_table_entry *match;
65676 + unsigned int index;
65677 +
65678 + index = conn_hash(saddr, daddr, sport, dport, gr_conn_table_size);
65679 +
65680 + match = gr_conn_table[index];
65681 + while (match && !conn_match(match->sig, saddr, daddr, sport, dport))
65682 + match = match->next;
65683 +
65684 + if (match)
65685 + return match->sig;
65686 + else
65687 + return NULL;
65688 +}
65689 +
65690 +#endif
65691 +
65692 +void gr_update_task_in_ip_table(struct task_struct *task, const struct inet_sock *inet)
65693 +{
65694 +#ifdef CONFIG_GRKERNSEC
65695 + struct signal_struct *sig = task->signal;
65696 + struct conn_table_entry *newent;
65697 +
65698 + newent = kmalloc(sizeof(struct conn_table_entry), GFP_ATOMIC);
65699 + if (newent == NULL)
65700 + return;
65701 + /* no bh lock needed since we are called with bh disabled */
65702 + spin_lock(&gr_conn_table_lock);
65703 + gr_del_task_from_ip_table_nolock(sig);
65704 + sig->gr_saddr = inet->inet_rcv_saddr;
65705 + sig->gr_daddr = inet->inet_daddr;
65706 + sig->gr_sport = inet->inet_sport;
65707 + sig->gr_dport = inet->inet_dport;
65708 + gr_add_to_task_ip_table_nolock(sig, newent);
65709 + spin_unlock(&gr_conn_table_lock);
65710 +#endif
65711 + return;
65712 +}
65713 +
65714 +void gr_del_task_from_ip_table(struct task_struct *task)
65715 +{
65716 +#ifdef CONFIG_GRKERNSEC
65717 + spin_lock_bh(&gr_conn_table_lock);
65718 + gr_del_task_from_ip_table_nolock(task->signal);
65719 + spin_unlock_bh(&gr_conn_table_lock);
65720 +#endif
65721 + return;
65722 +}
65723 +
65724 +void
65725 +gr_attach_curr_ip(const struct sock *sk)
65726 +{
65727 +#ifdef CONFIG_GRKERNSEC
65728 + struct signal_struct *p, *set;
65729 + const struct inet_sock *inet = inet_sk(sk);
65730 +
65731 + if (unlikely(sk->sk_protocol != IPPROTO_TCP))
65732 + return;
65733 +
65734 + set = current->signal;
65735 +
65736 + spin_lock_bh(&gr_conn_table_lock);
65737 + p = gr_lookup_task_ip_table(inet->inet_daddr, inet->inet_rcv_saddr,
65738 + inet->inet_dport, inet->inet_sport);
65739 + if (unlikely(p != NULL)) {
65740 + set->curr_ip = p->curr_ip;
65741 + set->used_accept = 1;
65742 + gr_del_task_from_ip_table_nolock(p);
65743 + spin_unlock_bh(&gr_conn_table_lock);
65744 + return;
65745 + }
65746 + spin_unlock_bh(&gr_conn_table_lock);
65747 +
65748 + set->curr_ip = inet->inet_daddr;
65749 + set->used_accept = 1;
65750 +#endif
65751 + return;
65752 +}
65753 +
65754 +int
65755 +gr_handle_sock_all(const int family, const int type, const int protocol)
65756 +{
65757 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
65758 + if (grsec_enable_socket_all && in_group_p(grsec_socket_all_gid) &&
65759 + (family != AF_UNIX)) {
65760 + if (family == AF_INET)
65761 + gr_log_str3(GR_DONT_AUDIT, GR_SOCK_MSG, gr_sockfamily_to_name(family), gr_socktype_to_name(type), gr_proto_to_name(protocol));
65762 + else
65763 + gr_log_str2_int(GR_DONT_AUDIT, GR_SOCK_NOINET_MSG, gr_sockfamily_to_name(family), gr_socktype_to_name(type), protocol);
65764 + return -EACCES;
65765 + }
65766 +#endif
65767 + return 0;
65768 +}
65769 +
65770 +int
65771 +gr_handle_sock_server(const struct sockaddr *sck)
65772 +{
65773 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
65774 + if (grsec_enable_socket_server &&
65775 + in_group_p(grsec_socket_server_gid) &&
65776 + sck && (sck->sa_family != AF_UNIX) &&
65777 + (sck->sa_family != AF_LOCAL)) {
65778 + gr_log_noargs(GR_DONT_AUDIT, GR_BIND_MSG);
65779 + return -EACCES;
65780 + }
65781 +#endif
65782 + return 0;
65783 +}
65784 +
65785 +int
65786 +gr_handle_sock_server_other(const struct sock *sck)
65787 +{
65788 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
65789 + if (grsec_enable_socket_server &&
65790 + in_group_p(grsec_socket_server_gid) &&
65791 + sck && (sck->sk_family != AF_UNIX) &&
65792 + (sck->sk_family != AF_LOCAL)) {
65793 + gr_log_noargs(GR_DONT_AUDIT, GR_BIND_MSG);
65794 + return -EACCES;
65795 + }
65796 +#endif
65797 + return 0;
65798 +}
65799 +
65800 +int
65801 +gr_handle_sock_client(const struct sockaddr *sck)
65802 +{
65803 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
65804 + if (grsec_enable_socket_client && in_group_p(grsec_socket_client_gid) &&
65805 + sck && (sck->sa_family != AF_UNIX) &&
65806 + (sck->sa_family != AF_LOCAL)) {
65807 + gr_log_noargs(GR_DONT_AUDIT, GR_CONNECT_MSG);
65808 + return -EACCES;
65809 + }
65810 +#endif
65811 + return 0;
65812 +}
65813 diff --git a/grsecurity/grsec_sysctl.c b/grsecurity/grsec_sysctl.c
65814 new file mode 100644
65815 index 0000000..f55ef0f
65816 --- /dev/null
65817 +++ b/grsecurity/grsec_sysctl.c
65818 @@ -0,0 +1,469 @@
65819 +#include <linux/kernel.h>
65820 +#include <linux/sched.h>
65821 +#include <linux/sysctl.h>
65822 +#include <linux/grsecurity.h>
65823 +#include <linux/grinternal.h>
65824 +
65825 +int
65826 +gr_handle_sysctl_mod(const char *dirname, const char *name, const int op)
65827 +{
65828 +#ifdef CONFIG_GRKERNSEC_SYSCTL
65829 + if (dirname == NULL || name == NULL)
65830 + return 0;
65831 + if (!strcmp(dirname, "grsecurity") && grsec_lock && (op & MAY_WRITE)) {
65832 + gr_log_str(GR_DONT_AUDIT, GR_SYSCTL_MSG, name);
65833 + return -EACCES;
65834 + }
65835 +#endif
65836 + return 0;
65837 +}
65838 +
65839 +#ifdef CONFIG_GRKERNSEC_ROFS
65840 +static int __maybe_unused one = 1;
65841 +#endif
65842 +
65843 +#if defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_ROFS)
65844 +struct ctl_table grsecurity_table[] = {
65845 +#ifdef CONFIG_GRKERNSEC_SYSCTL
65846 +#ifdef CONFIG_GRKERNSEC_SYSCTL_DISTRO
65847 +#ifdef CONFIG_GRKERNSEC_IO
65848 + {
65849 + .procname = "disable_priv_io",
65850 + .data = &grsec_disable_privio,
65851 + .maxlen = sizeof(int),
65852 + .mode = 0600,
65853 + .proc_handler = &proc_dointvec,
65854 + },
65855 +#endif
65856 +#endif
65857 +#ifdef CONFIG_GRKERNSEC_LINK
65858 + {
65859 + .procname = "linking_restrictions",
65860 + .data = &grsec_enable_link,
65861 + .maxlen = sizeof(int),
65862 + .mode = 0600,
65863 + .proc_handler = &proc_dointvec,
65864 + },
65865 +#endif
65866 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
65867 + {
65868 + .procname = "enforce_symlinksifowner",
65869 + .data = &grsec_enable_symlinkown,
65870 + .maxlen = sizeof(int),
65871 + .mode = 0600,
65872 + .proc_handler = &proc_dointvec,
65873 + },
65874 + {
65875 + .procname = "symlinkown_gid",
65876 + .data = &grsec_symlinkown_gid,
65877 + .maxlen = sizeof(int),
65878 + .mode = 0600,
65879 + .proc_handler = &proc_dointvec,
65880 + },
65881 +#endif
65882 +#ifdef CONFIG_GRKERNSEC_BRUTE
65883 + {
65884 + .procname = "deter_bruteforce",
65885 + .data = &grsec_enable_brute,
65886 + .maxlen = sizeof(int),
65887 + .mode = 0600,
65888 + .proc_handler = &proc_dointvec,
65889 + },
65890 +#endif
65891 +#ifdef CONFIG_GRKERNSEC_FIFO
65892 + {
65893 + .procname = "fifo_restrictions",
65894 + .data = &grsec_enable_fifo,
65895 + .maxlen = sizeof(int),
65896 + .mode = 0600,
65897 + .proc_handler = &proc_dointvec,
65898 + },
65899 +#endif
65900 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
65901 + {
65902 + .procname = "ptrace_readexec",
65903 + .data = &grsec_enable_ptrace_readexec,
65904 + .maxlen = sizeof(int),
65905 + .mode = 0600,
65906 + .proc_handler = &proc_dointvec,
65907 + },
65908 +#endif
65909 +#ifdef CONFIG_GRKERNSEC_SETXID
65910 + {
65911 + .procname = "consistent_setxid",
65912 + .data = &grsec_enable_setxid,
65913 + .maxlen = sizeof(int),
65914 + .mode = 0600,
65915 + .proc_handler = &proc_dointvec,
65916 + },
65917 +#endif
65918 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
65919 + {
65920 + .procname = "ip_blackhole",
65921 + .data = &grsec_enable_blackhole,
65922 + .maxlen = sizeof(int),
65923 + .mode = 0600,
65924 + .proc_handler = &proc_dointvec,
65925 + },
65926 + {
65927 + .procname = "lastack_retries",
65928 + .data = &grsec_lastack_retries,
65929 + .maxlen = sizeof(int),
65930 + .mode = 0600,
65931 + .proc_handler = &proc_dointvec,
65932 + },
65933 +#endif
65934 +#ifdef CONFIG_GRKERNSEC_EXECLOG
65935 + {
65936 + .procname = "exec_logging",
65937 + .data = &grsec_enable_execlog,
65938 + .maxlen = sizeof(int),
65939 + .mode = 0600,
65940 + .proc_handler = &proc_dointvec,
65941 + },
65942 +#endif
65943 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
65944 + {
65945 + .procname = "rwxmap_logging",
65946 + .data = &grsec_enable_log_rwxmaps,
65947 + .maxlen = sizeof(int),
65948 + .mode = 0600,
65949 + .proc_handler = &proc_dointvec,
65950 + },
65951 +#endif
65952 +#ifdef CONFIG_GRKERNSEC_SIGNAL
65953 + {
65954 + .procname = "signal_logging",
65955 + .data = &grsec_enable_signal,
65956 + .maxlen = sizeof(int),
65957 + .mode = 0600,
65958 + .proc_handler = &proc_dointvec,
65959 + },
65960 +#endif
65961 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
65962 + {
65963 + .procname = "forkfail_logging",
65964 + .data = &grsec_enable_forkfail,
65965 + .maxlen = sizeof(int),
65966 + .mode = 0600,
65967 + .proc_handler = &proc_dointvec,
65968 + },
65969 +#endif
65970 +#ifdef CONFIG_GRKERNSEC_TIME
65971 + {
65972 + .procname = "timechange_logging",
65973 + .data = &grsec_enable_time,
65974 + .maxlen = sizeof(int),
65975 + .mode = 0600,
65976 + .proc_handler = &proc_dointvec,
65977 + },
65978 +#endif
65979 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
65980 + {
65981 + .procname = "chroot_deny_shmat",
65982 + .data = &grsec_enable_chroot_shmat,
65983 + .maxlen = sizeof(int),
65984 + .mode = 0600,
65985 + .proc_handler = &proc_dointvec,
65986 + },
65987 +#endif
65988 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
65989 + {
65990 + .procname = "chroot_deny_unix",
65991 + .data = &grsec_enable_chroot_unix,
65992 + .maxlen = sizeof(int),
65993 + .mode = 0600,
65994 + .proc_handler = &proc_dointvec,
65995 + },
65996 +#endif
65997 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
65998 + {
65999 + .procname = "chroot_deny_mount",
66000 + .data = &grsec_enable_chroot_mount,
66001 + .maxlen = sizeof(int),
66002 + .mode = 0600,
66003 + .proc_handler = &proc_dointvec,
66004 + },
66005 +#endif
66006 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
66007 + {
66008 + .procname = "chroot_deny_fchdir",
66009 + .data = &grsec_enable_chroot_fchdir,
66010 + .maxlen = sizeof(int),
66011 + .mode = 0600,
66012 + .proc_handler = &proc_dointvec,
66013 + },
66014 +#endif
66015 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
66016 + {
66017 + .procname = "chroot_deny_chroot",
66018 + .data = &grsec_enable_chroot_double,
66019 + .maxlen = sizeof(int),
66020 + .mode = 0600,
66021 + .proc_handler = &proc_dointvec,
66022 + },
66023 +#endif
66024 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
66025 + {
66026 + .procname = "chroot_deny_pivot",
66027 + .data = &grsec_enable_chroot_pivot,
66028 + .maxlen = sizeof(int),
66029 + .mode = 0600,
66030 + .proc_handler = &proc_dointvec,
66031 + },
66032 +#endif
66033 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
66034 + {
66035 + .procname = "chroot_enforce_chdir",
66036 + .data = &grsec_enable_chroot_chdir,
66037 + .maxlen = sizeof(int),
66038 + .mode = 0600,
66039 + .proc_handler = &proc_dointvec,
66040 + },
66041 +#endif
66042 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
66043 + {
66044 + .procname = "chroot_deny_chmod",
66045 + .data = &grsec_enable_chroot_chmod,
66046 + .maxlen = sizeof(int),
66047 + .mode = 0600,
66048 + .proc_handler = &proc_dointvec,
66049 + },
66050 +#endif
66051 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
66052 + {
66053 + .procname = "chroot_deny_mknod",
66054 + .data = &grsec_enable_chroot_mknod,
66055 + .maxlen = sizeof(int),
66056 + .mode = 0600,
66057 + .proc_handler = &proc_dointvec,
66058 + },
66059 +#endif
66060 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
66061 + {
66062 + .procname = "chroot_restrict_nice",
66063 + .data = &grsec_enable_chroot_nice,
66064 + .maxlen = sizeof(int),
66065 + .mode = 0600,
66066 + .proc_handler = &proc_dointvec,
66067 + },
66068 +#endif
66069 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
66070 + {
66071 + .procname = "chroot_execlog",
66072 + .data = &grsec_enable_chroot_execlog,
66073 + .maxlen = sizeof(int),
66074 + .mode = 0600,
66075 + .proc_handler = &proc_dointvec,
66076 + },
66077 +#endif
66078 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
66079 + {
66080 + .procname = "chroot_caps",
66081 + .data = &grsec_enable_chroot_caps,
66082 + .maxlen = sizeof(int),
66083 + .mode = 0600,
66084 + .proc_handler = &proc_dointvec,
66085 + },
66086 +#endif
66087 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
66088 + {
66089 + .procname = "chroot_deny_sysctl",
66090 + .data = &grsec_enable_chroot_sysctl,
66091 + .maxlen = sizeof(int),
66092 + .mode = 0600,
66093 + .proc_handler = &proc_dointvec,
66094 + },
66095 +#endif
66096 +#ifdef CONFIG_GRKERNSEC_TPE
66097 + {
66098 + .procname = "tpe",
66099 + .data = &grsec_enable_tpe,
66100 + .maxlen = sizeof(int),
66101 + .mode = 0600,
66102 + .proc_handler = &proc_dointvec,
66103 + },
66104 + {
66105 + .procname = "tpe_gid",
66106 + .data = &grsec_tpe_gid,
66107 + .maxlen = sizeof(int),
66108 + .mode = 0600,
66109 + .proc_handler = &proc_dointvec,
66110 + },
66111 +#endif
66112 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
66113 + {
66114 + .procname = "tpe_invert",
66115 + .data = &grsec_enable_tpe_invert,
66116 + .maxlen = sizeof(int),
66117 + .mode = 0600,
66118 + .proc_handler = &proc_dointvec,
66119 + },
66120 +#endif
66121 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
66122 + {
66123 + .procname = "tpe_restrict_all",
66124 + .data = &grsec_enable_tpe_all,
66125 + .maxlen = sizeof(int),
66126 + .mode = 0600,
66127 + .proc_handler = &proc_dointvec,
66128 + },
66129 +#endif
66130 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
66131 + {
66132 + .procname = "socket_all",
66133 + .data = &grsec_enable_socket_all,
66134 + .maxlen = sizeof(int),
66135 + .mode = 0600,
66136 + .proc_handler = &proc_dointvec,
66137 + },
66138 + {
66139 + .procname = "socket_all_gid",
66140 + .data = &grsec_socket_all_gid,
66141 + .maxlen = sizeof(int),
66142 + .mode = 0600,
66143 + .proc_handler = &proc_dointvec,
66144 + },
66145 +#endif
66146 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
66147 + {
66148 + .procname = "socket_client",
66149 + .data = &grsec_enable_socket_client,
66150 + .maxlen = sizeof(int),
66151 + .mode = 0600,
66152 + .proc_handler = &proc_dointvec,
66153 + },
66154 + {
66155 + .procname = "socket_client_gid",
66156 + .data = &grsec_socket_client_gid,
66157 + .maxlen = sizeof(int),
66158 + .mode = 0600,
66159 + .proc_handler = &proc_dointvec,
66160 + },
66161 +#endif
66162 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
66163 + {
66164 + .procname = "socket_server",
66165 + .data = &grsec_enable_socket_server,
66166 + .maxlen = sizeof(int),
66167 + .mode = 0600,
66168 + .proc_handler = &proc_dointvec,
66169 + },
66170 + {
66171 + .procname = "socket_server_gid",
66172 + .data = &grsec_socket_server_gid,
66173 + .maxlen = sizeof(int),
66174 + .mode = 0600,
66175 + .proc_handler = &proc_dointvec,
66176 + },
66177 +#endif
66178 +#ifdef CONFIG_GRKERNSEC_AUDIT_GROUP
66179 + {
66180 + .procname = "audit_group",
66181 + .data = &grsec_enable_group,
66182 + .maxlen = sizeof(int),
66183 + .mode = 0600,
66184 + .proc_handler = &proc_dointvec,
66185 + },
66186 + {
66187 + .procname = "audit_gid",
66188 + .data = &grsec_audit_gid,
66189 + .maxlen = sizeof(int),
66190 + .mode = 0600,
66191 + .proc_handler = &proc_dointvec,
66192 + },
66193 +#endif
66194 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
66195 + {
66196 + .procname = "audit_chdir",
66197 + .data = &grsec_enable_chdir,
66198 + .maxlen = sizeof(int),
66199 + .mode = 0600,
66200 + .proc_handler = &proc_dointvec,
66201 + },
66202 +#endif
66203 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
66204 + {
66205 + .procname = "audit_mount",
66206 + .data = &grsec_enable_mount,
66207 + .maxlen = sizeof(int),
66208 + .mode = 0600,
66209 + .proc_handler = &proc_dointvec,
66210 + },
66211 +#endif
66212 +#ifdef CONFIG_GRKERNSEC_AUDIT_TEXTREL
66213 + {
66214 + .procname = "audit_textrel",
66215 + .data = &grsec_enable_audit_textrel,
66216 + .maxlen = sizeof(int),
66217 + .mode = 0600,
66218 + .proc_handler = &proc_dointvec,
66219 + },
66220 +#endif
66221 +#ifdef CONFIG_GRKERNSEC_DMESG
66222 + {
66223 + .procname = "dmesg",
66224 + .data = &grsec_enable_dmesg,
66225 + .maxlen = sizeof(int),
66226 + .mode = 0600,
66227 + .proc_handler = &proc_dointvec,
66228 + },
66229 +#endif
66230 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
66231 + {
66232 + .procname = "chroot_findtask",
66233 + .data = &grsec_enable_chroot_findtask,
66234 + .maxlen = sizeof(int),
66235 + .mode = 0600,
66236 + .proc_handler = &proc_dointvec,
66237 + },
66238 +#endif
66239 +#ifdef CONFIG_GRKERNSEC_RESLOG
66240 + {
66241 + .procname = "resource_logging",
66242 + .data = &grsec_resource_logging,
66243 + .maxlen = sizeof(int),
66244 + .mode = 0600,
66245 + .proc_handler = &proc_dointvec,
66246 + },
66247 +#endif
66248 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
66249 + {
66250 + .procname = "audit_ptrace",
66251 + .data = &grsec_enable_audit_ptrace,
66252 + .maxlen = sizeof(int),
66253 + .mode = 0600,
66254 + .proc_handler = &proc_dointvec,
66255 + },
66256 +#endif
66257 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
66258 + {
66259 + .procname = "harden_ptrace",
66260 + .data = &grsec_enable_harden_ptrace,
66261 + .maxlen = sizeof(int),
66262 + .mode = 0600,
66263 + .proc_handler = &proc_dointvec,
66264 + },
66265 +#endif
66266 + {
66267 + .procname = "grsec_lock",
66268 + .data = &grsec_lock,
66269 + .maxlen = sizeof(int),
66270 + .mode = 0600,
66271 + .proc_handler = &proc_dointvec,
66272 + },
66273 +#endif
66274 +#ifdef CONFIG_GRKERNSEC_ROFS
66275 + {
66276 + .procname = "romount_protect",
66277 + .data = &grsec_enable_rofs,
66278 + .maxlen = sizeof(int),
66279 + .mode = 0600,
66280 + .proc_handler = &proc_dointvec_minmax,
66281 + .extra1 = &one,
66282 + .extra2 = &one,
66283 + },
66284 +#endif
66285 + { }
66286 +};
66287 +#endif
66288 diff --git a/grsecurity/grsec_time.c b/grsecurity/grsec_time.c
66289 new file mode 100644
66290 index 0000000..0dc13c3
66291 --- /dev/null
66292 +++ b/grsecurity/grsec_time.c
66293 @@ -0,0 +1,16 @@
66294 +#include <linux/kernel.h>
66295 +#include <linux/sched.h>
66296 +#include <linux/grinternal.h>
66297 +#include <linux/module.h>
66298 +
66299 +void
66300 +gr_log_timechange(void)
66301 +{
66302 +#ifdef CONFIG_GRKERNSEC_TIME
66303 + if (grsec_enable_time)
66304 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_TIME_MSG);
66305 +#endif
66306 + return;
66307 +}
66308 +
66309 +EXPORT_SYMBOL(gr_log_timechange);
66310 diff --git a/grsecurity/grsec_tpe.c b/grsecurity/grsec_tpe.c
66311 new file mode 100644
66312 index 0000000..ee57dcf
66313 --- /dev/null
66314 +++ b/grsecurity/grsec_tpe.c
66315 @@ -0,0 +1,73 @@
66316 +#include <linux/kernel.h>
66317 +#include <linux/sched.h>
66318 +#include <linux/file.h>
66319 +#include <linux/fs.h>
66320 +#include <linux/grinternal.h>
66321 +
66322 +extern int gr_acl_tpe_check(void);
66323 +
66324 +int
66325 +gr_tpe_allow(const struct file *file)
66326 +{
66327 +#ifdef CONFIG_GRKERNSEC
66328 + struct inode *inode = file->f_path.dentry->d_parent->d_inode;
66329 + const struct cred *cred = current_cred();
66330 + char *msg = NULL;
66331 + char *msg2 = NULL;
66332 +
66333 + // never restrict root
66334 + if (gr_is_global_root(cred->uid))
66335 + return 1;
66336 +
66337 + if (grsec_enable_tpe) {
66338 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
66339 + if (grsec_enable_tpe_invert && !in_group_p(grsec_tpe_gid))
66340 + msg = "not being in trusted group";
66341 + else if (!grsec_enable_tpe_invert && in_group_p(grsec_tpe_gid))
66342 + msg = "being in untrusted group";
66343 +#else
66344 + if (in_group_p(grsec_tpe_gid))
66345 + msg = "being in untrusted group";
66346 +#endif
66347 + }
66348 + if (!msg && gr_acl_tpe_check())
66349 + msg = "being in untrusted role";
66350 +
66351 + // not in any affected group/role
66352 + if (!msg)
66353 + goto next_check;
66354 +
66355 + if (gr_is_global_nonroot(inode->i_uid))
66356 + msg2 = "file in non-root-owned directory";
66357 + else if (inode->i_mode & S_IWOTH)
66358 + msg2 = "file in world-writable directory";
66359 + else if (inode->i_mode & S_IWGRP)
66360 + msg2 = "file in group-writable directory";
66361 +
66362 + if (msg && msg2) {
66363 + char fullmsg[70] = {0};
66364 + snprintf(fullmsg, sizeof(fullmsg)-1, "%s and %s", msg, msg2);
66365 + gr_log_str_fs(GR_DONT_AUDIT, GR_EXEC_TPE_MSG, fullmsg, file->f_path.dentry, file->f_path.mnt);
66366 + return 0;
66367 + }
66368 + msg = NULL;
66369 +next_check:
66370 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
66371 + if (!grsec_enable_tpe || !grsec_enable_tpe_all)
66372 + return 1;
66373 +
66374 + if (gr_is_global_nonroot(inode->i_uid) && !uid_eq(inode->i_uid, cred->uid))
66375 + msg = "directory not owned by user";
66376 + else if (inode->i_mode & S_IWOTH)
66377 + msg = "file in world-writable directory";
66378 + else if (inode->i_mode & S_IWGRP)
66379 + msg = "file in group-writable directory";
66380 +
66381 + if (msg) {
66382 + gr_log_str_fs(GR_DONT_AUDIT, GR_EXEC_TPE_MSG, msg, file->f_path.dentry, file->f_path.mnt);
66383 + return 0;
66384 + }
66385 +#endif
66386 +#endif
66387 + return 1;
66388 +}
66389 diff --git a/grsecurity/grsum.c b/grsecurity/grsum.c
66390 new file mode 100644
66391 index 0000000..9f7b1ac
66392 --- /dev/null
66393 +++ b/grsecurity/grsum.c
66394 @@ -0,0 +1,61 @@
66395 +#include <linux/err.h>
66396 +#include <linux/kernel.h>
66397 +#include <linux/sched.h>
66398 +#include <linux/mm.h>
66399 +#include <linux/scatterlist.h>
66400 +#include <linux/crypto.h>
66401 +#include <linux/gracl.h>
66402 +
66403 +
66404 +#if !defined(CONFIG_CRYPTO) || defined(CONFIG_CRYPTO_MODULE) || !defined(CONFIG_CRYPTO_SHA256) || defined(CONFIG_CRYPTO_SHA256_MODULE)
66405 +#error "crypto and sha256 must be built into the kernel"
66406 +#endif
66407 +
66408 +int
66409 +chkpw(struct gr_arg *entry, unsigned char *salt, unsigned char *sum)
66410 +{
66411 + char *p;
66412 + struct crypto_hash *tfm;
66413 + struct hash_desc desc;
66414 + struct scatterlist sg;
66415 + unsigned char temp_sum[GR_SHA_LEN];
66416 + volatile int retval = 0;
66417 + volatile int dummy = 0;
66418 + unsigned int i;
66419 +
66420 + sg_init_table(&sg, 1);
66421 +
66422 + tfm = crypto_alloc_hash("sha256", 0, CRYPTO_ALG_ASYNC);
66423 + if (IS_ERR(tfm)) {
66424 + /* should never happen, since sha256 should be built in */
66425 + return 1;
66426 + }
66427 +
66428 + desc.tfm = tfm;
66429 + desc.flags = 0;
66430 +
66431 + crypto_hash_init(&desc);
66432 +
66433 + p = salt;
66434 + sg_set_buf(&sg, p, GR_SALT_LEN);
66435 + crypto_hash_update(&desc, &sg, sg.length);
66436 +
66437 + p = entry->pw;
66438 + sg_set_buf(&sg, p, strlen(p));
66439 +
66440 + crypto_hash_update(&desc, &sg, sg.length);
66441 +
66442 + crypto_hash_final(&desc, temp_sum);
66443 +
66444 + memset(entry->pw, 0, GR_PW_LEN);
66445 +
66446 + for (i = 0; i < GR_SHA_LEN; i++)
66447 + if (sum[i] != temp_sum[i])
66448 + retval = 1;
66449 + else
66450 + dummy = 1; // waste a cycle
66451 +
66452 + crypto_free_hash(tfm);
66453 +
66454 + return retval;
66455 +}
66456 diff --git a/include/asm-generic/4level-fixup.h b/include/asm-generic/4level-fixup.h
66457 index 77ff547..181834f 100644
66458 --- a/include/asm-generic/4level-fixup.h
66459 +++ b/include/asm-generic/4level-fixup.h
66460 @@ -13,8 +13,10 @@
66461 #define pmd_alloc(mm, pud, address) \
66462 ((unlikely(pgd_none(*(pud))) && __pmd_alloc(mm, pud, address))? \
66463 NULL: pmd_offset(pud, address))
66464 +#define pmd_alloc_kernel(mm, pud, address) pmd_alloc((mm), (pud), (address))
66465
66466 #define pud_alloc(mm, pgd, address) (pgd)
66467 +#define pud_alloc_kernel(mm, pgd, address) pud_alloc((mm), (pgd), (address))
66468 #define pud_offset(pgd, start) (pgd)
66469 #define pud_none(pud) 0
66470 #define pud_bad(pud) 0
66471 diff --git a/include/asm-generic/atomic-long.h b/include/asm-generic/atomic-long.h
66472 index b7babf0..04ad282 100644
66473 --- a/include/asm-generic/atomic-long.h
66474 +++ b/include/asm-generic/atomic-long.h
66475 @@ -22,6 +22,12 @@
66476
66477 typedef atomic64_t atomic_long_t;
66478
66479 +#ifdef CONFIG_PAX_REFCOUNT
66480 +typedef atomic64_unchecked_t atomic_long_unchecked_t;
66481 +#else
66482 +typedef atomic64_t atomic_long_unchecked_t;
66483 +#endif
66484 +
66485 #define ATOMIC_LONG_INIT(i) ATOMIC64_INIT(i)
66486
66487 static inline long atomic_long_read(atomic_long_t *l)
66488 @@ -31,6 +37,15 @@ static inline long atomic_long_read(atomic_long_t *l)
66489 return (long)atomic64_read(v);
66490 }
66491
66492 +#ifdef CONFIG_PAX_REFCOUNT
66493 +static inline long atomic_long_read_unchecked(atomic_long_unchecked_t *l)
66494 +{
66495 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
66496 +
66497 + return (long)atomic64_read_unchecked(v);
66498 +}
66499 +#endif
66500 +
66501 static inline void atomic_long_set(atomic_long_t *l, long i)
66502 {
66503 atomic64_t *v = (atomic64_t *)l;
66504 @@ -38,6 +53,15 @@ static inline void atomic_long_set(atomic_long_t *l, long i)
66505 atomic64_set(v, i);
66506 }
66507
66508 +#ifdef CONFIG_PAX_REFCOUNT
66509 +static inline void atomic_long_set_unchecked(atomic_long_unchecked_t *l, long i)
66510 +{
66511 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
66512 +
66513 + atomic64_set_unchecked(v, i);
66514 +}
66515 +#endif
66516 +
66517 static inline void atomic_long_inc(atomic_long_t *l)
66518 {
66519 atomic64_t *v = (atomic64_t *)l;
66520 @@ -45,6 +69,15 @@ static inline void atomic_long_inc(atomic_long_t *l)
66521 atomic64_inc(v);
66522 }
66523
66524 +#ifdef CONFIG_PAX_REFCOUNT
66525 +static inline void atomic_long_inc_unchecked(atomic_long_unchecked_t *l)
66526 +{
66527 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
66528 +
66529 + atomic64_inc_unchecked(v);
66530 +}
66531 +#endif
66532 +
66533 static inline void atomic_long_dec(atomic_long_t *l)
66534 {
66535 atomic64_t *v = (atomic64_t *)l;
66536 @@ -52,6 +85,15 @@ static inline void atomic_long_dec(atomic_long_t *l)
66537 atomic64_dec(v);
66538 }
66539
66540 +#ifdef CONFIG_PAX_REFCOUNT
66541 +static inline void atomic_long_dec_unchecked(atomic_long_unchecked_t *l)
66542 +{
66543 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
66544 +
66545 + atomic64_dec_unchecked(v);
66546 +}
66547 +#endif
66548 +
66549 static inline void atomic_long_add(long i, atomic_long_t *l)
66550 {
66551 atomic64_t *v = (atomic64_t *)l;
66552 @@ -59,6 +101,15 @@ static inline void atomic_long_add(long i, atomic_long_t *l)
66553 atomic64_add(i, v);
66554 }
66555
66556 +#ifdef CONFIG_PAX_REFCOUNT
66557 +static inline void atomic_long_add_unchecked(long i, atomic_long_unchecked_t *l)
66558 +{
66559 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
66560 +
66561 + atomic64_add_unchecked(i, v);
66562 +}
66563 +#endif
66564 +
66565 static inline void atomic_long_sub(long i, atomic_long_t *l)
66566 {
66567 atomic64_t *v = (atomic64_t *)l;
66568 @@ -66,6 +117,15 @@ static inline void atomic_long_sub(long i, atomic_long_t *l)
66569 atomic64_sub(i, v);
66570 }
66571
66572 +#ifdef CONFIG_PAX_REFCOUNT
66573 +static inline void atomic_long_sub_unchecked(long i, atomic_long_unchecked_t *l)
66574 +{
66575 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
66576 +
66577 + atomic64_sub_unchecked(i, v);
66578 +}
66579 +#endif
66580 +
66581 static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
66582 {
66583 atomic64_t *v = (atomic64_t *)l;
66584 @@ -101,6 +161,15 @@ static inline long atomic_long_add_return(long i, atomic_long_t *l)
66585 return (long)atomic64_add_return(i, v);
66586 }
66587
66588 +#ifdef CONFIG_PAX_REFCOUNT
66589 +static inline long atomic_long_add_return_unchecked(long i, atomic_long_unchecked_t *l)
66590 +{
66591 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
66592 +
66593 + return (long)atomic64_add_return_unchecked(i, v);
66594 +}
66595 +#endif
66596 +
66597 static inline long atomic_long_sub_return(long i, atomic_long_t *l)
66598 {
66599 atomic64_t *v = (atomic64_t *)l;
66600 @@ -115,6 +184,15 @@ static inline long atomic_long_inc_return(atomic_long_t *l)
66601 return (long)atomic64_inc_return(v);
66602 }
66603
66604 +#ifdef CONFIG_PAX_REFCOUNT
66605 +static inline long atomic_long_inc_return_unchecked(atomic_long_unchecked_t *l)
66606 +{
66607 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
66608 +
66609 + return (long)atomic64_inc_return_unchecked(v);
66610 +}
66611 +#endif
66612 +
66613 static inline long atomic_long_dec_return(atomic_long_t *l)
66614 {
66615 atomic64_t *v = (atomic64_t *)l;
66616 @@ -140,6 +218,12 @@ static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
66617
66618 typedef atomic_t atomic_long_t;
66619
66620 +#ifdef CONFIG_PAX_REFCOUNT
66621 +typedef atomic_unchecked_t atomic_long_unchecked_t;
66622 +#else
66623 +typedef atomic_t atomic_long_unchecked_t;
66624 +#endif
66625 +
66626 #define ATOMIC_LONG_INIT(i) ATOMIC_INIT(i)
66627 static inline long atomic_long_read(atomic_long_t *l)
66628 {
66629 @@ -148,6 +232,15 @@ static inline long atomic_long_read(atomic_long_t *l)
66630 return (long)atomic_read(v);
66631 }
66632
66633 +#ifdef CONFIG_PAX_REFCOUNT
66634 +static inline long atomic_long_read_unchecked(atomic_long_unchecked_t *l)
66635 +{
66636 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
66637 +
66638 + return (long)atomic_read_unchecked(v);
66639 +}
66640 +#endif
66641 +
66642 static inline void atomic_long_set(atomic_long_t *l, long i)
66643 {
66644 atomic_t *v = (atomic_t *)l;
66645 @@ -155,6 +248,15 @@ static inline void atomic_long_set(atomic_long_t *l, long i)
66646 atomic_set(v, i);
66647 }
66648
66649 +#ifdef CONFIG_PAX_REFCOUNT
66650 +static inline void atomic_long_set_unchecked(atomic_long_unchecked_t *l, long i)
66651 +{
66652 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
66653 +
66654 + atomic_set_unchecked(v, i);
66655 +}
66656 +#endif
66657 +
66658 static inline void atomic_long_inc(atomic_long_t *l)
66659 {
66660 atomic_t *v = (atomic_t *)l;
66661 @@ -162,6 +264,15 @@ static inline void atomic_long_inc(atomic_long_t *l)
66662 atomic_inc(v);
66663 }
66664
66665 +#ifdef CONFIG_PAX_REFCOUNT
66666 +static inline void atomic_long_inc_unchecked(atomic_long_unchecked_t *l)
66667 +{
66668 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
66669 +
66670 + atomic_inc_unchecked(v);
66671 +}
66672 +#endif
66673 +
66674 static inline void atomic_long_dec(atomic_long_t *l)
66675 {
66676 atomic_t *v = (atomic_t *)l;
66677 @@ -169,6 +280,15 @@ static inline void atomic_long_dec(atomic_long_t *l)
66678 atomic_dec(v);
66679 }
66680
66681 +#ifdef CONFIG_PAX_REFCOUNT
66682 +static inline void atomic_long_dec_unchecked(atomic_long_unchecked_t *l)
66683 +{
66684 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
66685 +
66686 + atomic_dec_unchecked(v);
66687 +}
66688 +#endif
66689 +
66690 static inline void atomic_long_add(long i, atomic_long_t *l)
66691 {
66692 atomic_t *v = (atomic_t *)l;
66693 @@ -176,6 +296,15 @@ static inline void atomic_long_add(long i, atomic_long_t *l)
66694 atomic_add(i, v);
66695 }
66696
66697 +#ifdef CONFIG_PAX_REFCOUNT
66698 +static inline void atomic_long_add_unchecked(long i, atomic_long_unchecked_t *l)
66699 +{
66700 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
66701 +
66702 + atomic_add_unchecked(i, v);
66703 +}
66704 +#endif
66705 +
66706 static inline void atomic_long_sub(long i, atomic_long_t *l)
66707 {
66708 atomic_t *v = (atomic_t *)l;
66709 @@ -183,6 +312,15 @@ static inline void atomic_long_sub(long i, atomic_long_t *l)
66710 atomic_sub(i, v);
66711 }
66712
66713 +#ifdef CONFIG_PAX_REFCOUNT
66714 +static inline void atomic_long_sub_unchecked(long i, atomic_long_unchecked_t *l)
66715 +{
66716 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
66717 +
66718 + atomic_sub_unchecked(i, v);
66719 +}
66720 +#endif
66721 +
66722 static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
66723 {
66724 atomic_t *v = (atomic_t *)l;
66725 @@ -218,6 +356,16 @@ static inline long atomic_long_add_return(long i, atomic_long_t *l)
66726 return (long)atomic_add_return(i, v);
66727 }
66728
66729 +#ifdef CONFIG_PAX_REFCOUNT
66730 +static inline long atomic_long_add_return_unchecked(long i, atomic_long_unchecked_t *l)
66731 +{
66732 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
66733 +
66734 + return (long)atomic_add_return_unchecked(i, v);
66735 +}
66736 +
66737 +#endif
66738 +
66739 static inline long atomic_long_sub_return(long i, atomic_long_t *l)
66740 {
66741 atomic_t *v = (atomic_t *)l;
66742 @@ -232,6 +380,15 @@ static inline long atomic_long_inc_return(atomic_long_t *l)
66743 return (long)atomic_inc_return(v);
66744 }
66745
66746 +#ifdef CONFIG_PAX_REFCOUNT
66747 +static inline long atomic_long_inc_return_unchecked(atomic_long_unchecked_t *l)
66748 +{
66749 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
66750 +
66751 + return (long)atomic_inc_return_unchecked(v);
66752 +}
66753 +#endif
66754 +
66755 static inline long atomic_long_dec_return(atomic_long_t *l)
66756 {
66757 atomic_t *v = (atomic_t *)l;
66758 @@ -255,4 +412,57 @@ static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
66759
66760 #endif /* BITS_PER_LONG == 64 */
66761
66762 +#ifdef CONFIG_PAX_REFCOUNT
66763 +static inline void pax_refcount_needs_these_functions(void)
66764 +{
66765 + atomic_read_unchecked((atomic_unchecked_t *)NULL);
66766 + atomic_set_unchecked((atomic_unchecked_t *)NULL, 0);
66767 + atomic_add_unchecked(0, (atomic_unchecked_t *)NULL);
66768 + atomic_sub_unchecked(0, (atomic_unchecked_t *)NULL);
66769 + atomic_inc_unchecked((atomic_unchecked_t *)NULL);
66770 + (void)atomic_inc_and_test_unchecked((atomic_unchecked_t *)NULL);
66771 + atomic_inc_return_unchecked((atomic_unchecked_t *)NULL);
66772 + atomic_add_return_unchecked(0, (atomic_unchecked_t *)NULL);
66773 + atomic_dec_unchecked((atomic_unchecked_t *)NULL);
66774 + atomic_cmpxchg_unchecked((atomic_unchecked_t *)NULL, 0, 0);
66775 + (void)atomic_xchg_unchecked((atomic_unchecked_t *)NULL, 0);
66776 +#ifdef CONFIG_X86
66777 + atomic_clear_mask_unchecked(0, NULL);
66778 + atomic_set_mask_unchecked(0, NULL);
66779 +#endif
66780 +
66781 + atomic_long_read_unchecked((atomic_long_unchecked_t *)NULL);
66782 + atomic_long_set_unchecked((atomic_long_unchecked_t *)NULL, 0);
66783 + atomic_long_add_unchecked(0, (atomic_long_unchecked_t *)NULL);
66784 + atomic_long_sub_unchecked(0, (atomic_long_unchecked_t *)NULL);
66785 + atomic_long_inc_unchecked((atomic_long_unchecked_t *)NULL);
66786 + atomic_long_add_return_unchecked(0, (atomic_long_unchecked_t *)NULL);
66787 + atomic_long_inc_return_unchecked((atomic_long_unchecked_t *)NULL);
66788 + atomic_long_dec_unchecked((atomic_long_unchecked_t *)NULL);
66789 +}
66790 +#else
66791 +#define atomic_read_unchecked(v) atomic_read(v)
66792 +#define atomic_set_unchecked(v, i) atomic_set((v), (i))
66793 +#define atomic_add_unchecked(i, v) atomic_add((i), (v))
66794 +#define atomic_sub_unchecked(i, v) atomic_sub((i), (v))
66795 +#define atomic_inc_unchecked(v) atomic_inc(v)
66796 +#define atomic_inc_and_test_unchecked(v) atomic_inc_and_test(v)
66797 +#define atomic_inc_return_unchecked(v) atomic_inc_return(v)
66798 +#define atomic_add_return_unchecked(i, v) atomic_add_return((i), (v))
66799 +#define atomic_dec_unchecked(v) atomic_dec(v)
66800 +#define atomic_cmpxchg_unchecked(v, o, n) atomic_cmpxchg((v), (o), (n))
66801 +#define atomic_xchg_unchecked(v, i) atomic_xchg((v), (i))
66802 +#define atomic_clear_mask_unchecked(mask, v) atomic_clear_mask((mask), (v))
66803 +#define atomic_set_mask_unchecked(mask, v) atomic_set_mask((mask), (v))
66804 +
66805 +#define atomic_long_read_unchecked(v) atomic_long_read(v)
66806 +#define atomic_long_set_unchecked(v, i) atomic_long_set((v), (i))
66807 +#define atomic_long_add_unchecked(i, v) atomic_long_add((i), (v))
66808 +#define atomic_long_sub_unchecked(i, v) atomic_long_sub((i), (v))
66809 +#define atomic_long_inc_unchecked(v) atomic_long_inc(v)
66810 +#define atomic_long_add_return_unchecked(i, v) atomic_long_add_return((i), (v))
66811 +#define atomic_long_inc_return_unchecked(v) atomic_long_inc_return(v)
66812 +#define atomic_long_dec_unchecked(v) atomic_long_dec(v)
66813 +#endif
66814 +
66815 #endif /* _ASM_GENERIC_ATOMIC_LONG_H */
66816 diff --git a/include/asm-generic/atomic.h b/include/asm-generic/atomic.h
66817 index 33bd2de..f31bff97 100644
66818 --- a/include/asm-generic/atomic.h
66819 +++ b/include/asm-generic/atomic.h
66820 @@ -153,7 +153,7 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
66821 * Atomically clears the bits set in @mask from @v
66822 */
66823 #ifndef atomic_clear_mask
66824 -static inline void atomic_clear_mask(unsigned long mask, atomic_t *v)
66825 +static inline void atomic_clear_mask(unsigned int mask, atomic_t *v)
66826 {
66827 unsigned long flags;
66828
66829 diff --git a/include/asm-generic/atomic64.h b/include/asm-generic/atomic64.h
66830 index b18ce4f..2ee2843 100644
66831 --- a/include/asm-generic/atomic64.h
66832 +++ b/include/asm-generic/atomic64.h
66833 @@ -16,6 +16,8 @@ typedef struct {
66834 long long counter;
66835 } atomic64_t;
66836
66837 +typedef atomic64_t atomic64_unchecked_t;
66838 +
66839 #define ATOMIC64_INIT(i) { (i) }
66840
66841 extern long long atomic64_read(const atomic64_t *v);
66842 @@ -39,4 +41,14 @@ extern int atomic64_add_unless(atomic64_t *v, long long a, long long u);
66843 #define atomic64_dec_and_test(v) (atomic64_dec_return((v)) == 0)
66844 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1LL, 0LL)
66845
66846 +#define atomic64_read_unchecked(v) atomic64_read(v)
66847 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
66848 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
66849 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
66850 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
66851 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
66852 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
66853 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
66854 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
66855 +
66856 #endif /* _ASM_GENERIC_ATOMIC64_H */
66857 diff --git a/include/asm-generic/cache.h b/include/asm-generic/cache.h
66858 index 1bfcfe5..e04c5c9 100644
66859 --- a/include/asm-generic/cache.h
66860 +++ b/include/asm-generic/cache.h
66861 @@ -6,7 +6,7 @@
66862 * cache lines need to provide their own cache.h.
66863 */
66864
66865 -#define L1_CACHE_SHIFT 5
66866 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
66867 +#define L1_CACHE_SHIFT 5UL
66868 +#define L1_CACHE_BYTES (1UL << L1_CACHE_SHIFT)
66869
66870 #endif /* __ASM_GENERIC_CACHE_H */
66871 diff --git a/include/asm-generic/emergency-restart.h b/include/asm-generic/emergency-restart.h
66872 index 0d68a1e..b74a761 100644
66873 --- a/include/asm-generic/emergency-restart.h
66874 +++ b/include/asm-generic/emergency-restart.h
66875 @@ -1,7 +1,7 @@
66876 #ifndef _ASM_GENERIC_EMERGENCY_RESTART_H
66877 #define _ASM_GENERIC_EMERGENCY_RESTART_H
66878
66879 -static inline void machine_emergency_restart(void)
66880 +static inline __noreturn void machine_emergency_restart(void)
66881 {
66882 machine_restart(NULL);
66883 }
66884 diff --git a/include/asm-generic/kmap_types.h b/include/asm-generic/kmap_types.h
66885 index 90f99c7..00ce236 100644
66886 --- a/include/asm-generic/kmap_types.h
66887 +++ b/include/asm-generic/kmap_types.h
66888 @@ -2,9 +2,9 @@
66889 #define _ASM_GENERIC_KMAP_TYPES_H
66890
66891 #ifdef __WITH_KM_FENCE
66892 -# define KM_TYPE_NR 41
66893 +# define KM_TYPE_NR 42
66894 #else
66895 -# define KM_TYPE_NR 20
66896 +# define KM_TYPE_NR 21
66897 #endif
66898
66899 #endif
66900 diff --git a/include/asm-generic/local.h b/include/asm-generic/local.h
66901 index 9ceb03b..62b0b8f 100644
66902 --- a/include/asm-generic/local.h
66903 +++ b/include/asm-generic/local.h
66904 @@ -23,24 +23,37 @@ typedef struct
66905 atomic_long_t a;
66906 } local_t;
66907
66908 +typedef struct {
66909 + atomic_long_unchecked_t a;
66910 +} local_unchecked_t;
66911 +
66912 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
66913
66914 #define local_read(l) atomic_long_read(&(l)->a)
66915 +#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
66916 #define local_set(l,i) atomic_long_set((&(l)->a),(i))
66917 +#define local_set_unchecked(l,i) atomic_long_set_unchecked((&(l)->a),(i))
66918 #define local_inc(l) atomic_long_inc(&(l)->a)
66919 +#define local_inc_unchecked(l) atomic_long_inc_unchecked(&(l)->a)
66920 #define local_dec(l) atomic_long_dec(&(l)->a)
66921 +#define local_dec_unchecked(l) atomic_long_dec_unchecked(&(l)->a)
66922 #define local_add(i,l) atomic_long_add((i),(&(l)->a))
66923 +#define local_add_unchecked(i,l) atomic_long_add_unchecked((i),(&(l)->a))
66924 #define local_sub(i,l) atomic_long_sub((i),(&(l)->a))
66925 +#define local_sub_unchecked(i,l) atomic_long_sub_unchecked((i),(&(l)->a))
66926
66927 #define local_sub_and_test(i, l) atomic_long_sub_and_test((i), (&(l)->a))
66928 #define local_dec_and_test(l) atomic_long_dec_and_test(&(l)->a)
66929 #define local_inc_and_test(l) atomic_long_inc_and_test(&(l)->a)
66930 #define local_add_negative(i, l) atomic_long_add_negative((i), (&(l)->a))
66931 #define local_add_return(i, l) atomic_long_add_return((i), (&(l)->a))
66932 +#define local_add_return_unchecked(i, l) atomic_long_add_return_unchecked((i), (&(l)->a))
66933 #define local_sub_return(i, l) atomic_long_sub_return((i), (&(l)->a))
66934 #define local_inc_return(l) atomic_long_inc_return(&(l)->a)
66935 +#define local_dec_return(l) atomic_long_dec_return(&(l)->a)
66936
66937 #define local_cmpxchg(l, o, n) atomic_long_cmpxchg((&(l)->a), (o), (n))
66938 +#define local_cmpxchg_unchecked(l, o, n) atomic_long_cmpxchg((&(l)->a), (o), (n))
66939 #define local_xchg(l, n) atomic_long_xchg((&(l)->a), (n))
66940 #define local_add_unless(l, _a, u) atomic_long_add_unless((&(l)->a), (_a), (u))
66941 #define local_inc_not_zero(l) atomic_long_inc_not_zero(&(l)->a)
66942 diff --git a/include/asm-generic/pgtable-nopmd.h b/include/asm-generic/pgtable-nopmd.h
66943 index 725612b..9cc513a 100644
66944 --- a/include/asm-generic/pgtable-nopmd.h
66945 +++ b/include/asm-generic/pgtable-nopmd.h
66946 @@ -1,14 +1,19 @@
66947 #ifndef _PGTABLE_NOPMD_H
66948 #define _PGTABLE_NOPMD_H
66949
66950 -#ifndef __ASSEMBLY__
66951 -
66952 #include <asm-generic/pgtable-nopud.h>
66953
66954 -struct mm_struct;
66955 -
66956 #define __PAGETABLE_PMD_FOLDED
66957
66958 +#define PMD_SHIFT PUD_SHIFT
66959 +#define PTRS_PER_PMD 1
66960 +#define PMD_SIZE (_AC(1,UL) << PMD_SHIFT)
66961 +#define PMD_MASK (~(PMD_SIZE-1))
66962 +
66963 +#ifndef __ASSEMBLY__
66964 +
66965 +struct mm_struct;
66966 +
66967 /*
66968 * Having the pmd type consist of a pud gets the size right, and allows
66969 * us to conceptually access the pud entry that this pmd is folded into
66970 @@ -16,11 +21,6 @@ struct mm_struct;
66971 */
66972 typedef struct { pud_t pud; } pmd_t;
66973
66974 -#define PMD_SHIFT PUD_SHIFT
66975 -#define PTRS_PER_PMD 1
66976 -#define PMD_SIZE (1UL << PMD_SHIFT)
66977 -#define PMD_MASK (~(PMD_SIZE-1))
66978 -
66979 /*
66980 * The "pud_xxx()" functions here are trivial for a folded two-level
66981 * setup: the pmd is never bad, and a pmd always exists (as it's folded
66982 diff --git a/include/asm-generic/pgtable-nopud.h b/include/asm-generic/pgtable-nopud.h
66983 index 810431d..0ec4804f 100644
66984 --- a/include/asm-generic/pgtable-nopud.h
66985 +++ b/include/asm-generic/pgtable-nopud.h
66986 @@ -1,10 +1,15 @@
66987 #ifndef _PGTABLE_NOPUD_H
66988 #define _PGTABLE_NOPUD_H
66989
66990 -#ifndef __ASSEMBLY__
66991 -
66992 #define __PAGETABLE_PUD_FOLDED
66993
66994 +#define PUD_SHIFT PGDIR_SHIFT
66995 +#define PTRS_PER_PUD 1
66996 +#define PUD_SIZE (_AC(1,UL) << PUD_SHIFT)
66997 +#define PUD_MASK (~(PUD_SIZE-1))
66998 +
66999 +#ifndef __ASSEMBLY__
67000 +
67001 /*
67002 * Having the pud type consist of a pgd gets the size right, and allows
67003 * us to conceptually access the pgd entry that this pud is folded into
67004 @@ -12,11 +17,6 @@
67005 */
67006 typedef struct { pgd_t pgd; } pud_t;
67007
67008 -#define PUD_SHIFT PGDIR_SHIFT
67009 -#define PTRS_PER_PUD 1
67010 -#define PUD_SIZE (1UL << PUD_SHIFT)
67011 -#define PUD_MASK (~(PUD_SIZE-1))
67012 -
67013 /*
67014 * The "pgd_xxx()" functions here are trivial for a folded two-level
67015 * setup: the pud is never bad, and a pud always exists (as it's folded
67016 @@ -29,6 +29,7 @@ static inline void pgd_clear(pgd_t *pgd) { }
67017 #define pud_ERROR(pud) (pgd_ERROR((pud).pgd))
67018
67019 #define pgd_populate(mm, pgd, pud) do { } while (0)
67020 +#define pgd_populate_kernel(mm, pgd, pud) do { } while (0)
67021 /*
67022 * (puds are folded into pgds so this doesn't get actually called,
67023 * but the define is needed for a generic inline function.)
67024 diff --git a/include/asm-generic/pgtable.h b/include/asm-generic/pgtable.h
67025 index a59ff51..2594a70 100644
67026 --- a/include/asm-generic/pgtable.h
67027 +++ b/include/asm-generic/pgtable.h
67028 @@ -688,6 +688,14 @@ static inline pmd_t pmd_mknuma(pmd_t pmd)
67029 }
67030 #endif /* CONFIG_NUMA_BALANCING */
67031
67032 +#ifndef __HAVE_ARCH_PAX_OPEN_KERNEL
67033 +static inline unsigned long pax_open_kernel(void) { return 0; }
67034 +#endif
67035 +
67036 +#ifndef __HAVE_ARCH_PAX_CLOSE_KERNEL
67037 +static inline unsigned long pax_close_kernel(void) { return 0; }
67038 +#endif
67039 +
67040 #endif /* CONFIG_MMU */
67041
67042 #endif /* !__ASSEMBLY__ */
67043 diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
67044 index afa12c7..99d4da0 100644
67045 --- a/include/asm-generic/vmlinux.lds.h
67046 +++ b/include/asm-generic/vmlinux.lds.h
67047 @@ -245,6 +245,7 @@
67048 .rodata : AT(ADDR(.rodata) - LOAD_OFFSET) { \
67049 VMLINUX_SYMBOL(__start_rodata) = .; \
67050 *(.rodata) *(.rodata.*) \
67051 + *(.data..read_only) \
67052 *(__vermagic) /* Kernel version magic */ \
67053 . = ALIGN(8); \
67054 VMLINUX_SYMBOL(__start___tracepoints_ptrs) = .; \
67055 @@ -755,17 +756,18 @@
67056 * section in the linker script will go there too. @phdr should have
67057 * a leading colon.
67058 *
67059 - * Note that this macros defines __per_cpu_load as an absolute symbol.
67060 + * Note that this macros defines per_cpu_load as an absolute symbol.
67061 * If there is no need to put the percpu section at a predetermined
67062 * address, use PERCPU_SECTION.
67063 */
67064 #define PERCPU_VADDR(cacheline, vaddr, phdr) \
67065 - VMLINUX_SYMBOL(__per_cpu_load) = .; \
67066 - .data..percpu vaddr : AT(VMLINUX_SYMBOL(__per_cpu_load) \
67067 + per_cpu_load = .; \
67068 + .data..percpu vaddr : AT(VMLINUX_SYMBOL(per_cpu_load) \
67069 - LOAD_OFFSET) { \
67070 + VMLINUX_SYMBOL(__per_cpu_load) = . + per_cpu_load; \
67071 PERCPU_INPUT(cacheline) \
67072 } phdr \
67073 - . = VMLINUX_SYMBOL(__per_cpu_load) + SIZEOF(.data..percpu);
67074 + . = VMLINUX_SYMBOL(per_cpu_load) + SIZEOF(.data..percpu);
67075
67076 /**
67077 * PERCPU_SECTION - define output section for percpu area, simple version
67078 diff --git a/include/crypto/algapi.h b/include/crypto/algapi.h
67079 index 418d270..bfd2794 100644
67080 --- a/include/crypto/algapi.h
67081 +++ b/include/crypto/algapi.h
67082 @@ -34,7 +34,7 @@ struct crypto_type {
67083 unsigned int maskclear;
67084 unsigned int maskset;
67085 unsigned int tfmsize;
67086 -};
67087 +} __do_const;
67088
67089 struct crypto_instance {
67090 struct crypto_alg alg;
67091 diff --git a/include/drm/drmP.h b/include/drm/drmP.h
67092 index f1ce786..086a7a5 100644
67093 --- a/include/drm/drmP.h
67094 +++ b/include/drm/drmP.h
67095 @@ -72,6 +72,7 @@
67096 #include <linux/workqueue.h>
67097 #include <linux/poll.h>
67098 #include <asm/pgalloc.h>
67099 +#include <asm/local.h>
67100 #include <drm/drm.h>
67101 #include <drm/drm_sarea.h>
67102
67103 @@ -296,10 +297,12 @@ do { \
67104 * \param cmd command.
67105 * \param arg argument.
67106 */
67107 -typedef int drm_ioctl_t(struct drm_device *dev, void *data,
67108 +typedef int (* const drm_ioctl_t)(struct drm_device *dev, void *data,
67109 + struct drm_file *file_priv);
67110 +typedef int (* drm_ioctl_no_const_t)(struct drm_device *dev, void *data,
67111 struct drm_file *file_priv);
67112
67113 -typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
67114 +typedef int (* const drm_ioctl_compat_t)(struct file *filp, unsigned int cmd,
67115 unsigned long arg);
67116
67117 #define DRM_IOCTL_NR(n) _IOC_NR(n)
67118 @@ -314,9 +317,9 @@ typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
67119 struct drm_ioctl_desc {
67120 unsigned int cmd;
67121 int flags;
67122 - drm_ioctl_t *func;
67123 + drm_ioctl_t func;
67124 unsigned int cmd_drv;
67125 -};
67126 +} __do_const;
67127
67128 /**
67129 * Creates a driver or general drm_ioctl_desc array entry for the given
67130 @@ -1014,7 +1017,7 @@ struct drm_info_list {
67131 int (*show)(struct seq_file*, void*); /** show callback */
67132 u32 driver_features; /**< Required driver features for this entry */
67133 void *data;
67134 -};
67135 +} __do_const;
67136
67137 /**
67138 * debugfs node structure. This structure represents a debugfs file.
67139 @@ -1087,7 +1090,7 @@ struct drm_device {
67140
67141 /** \name Usage Counters */
67142 /*@{ */
67143 - int open_count; /**< Outstanding files open */
67144 + local_t open_count; /**< Outstanding files open */
67145 atomic_t ioctl_count; /**< Outstanding IOCTLs pending */
67146 atomic_t vma_count; /**< Outstanding vma areas open */
67147 int buf_use; /**< Buffers in use -- cannot alloc */
67148 @@ -1098,7 +1101,7 @@ struct drm_device {
67149 /*@{ */
67150 unsigned long counters;
67151 enum drm_stat_type types[15];
67152 - atomic_t counts[15];
67153 + atomic_unchecked_t counts[15];
67154 /*@} */
67155
67156 struct list_head filelist;
67157 diff --git a/include/drm/drm_crtc_helper.h b/include/drm/drm_crtc_helper.h
67158 index f43d556..94d9343 100644
67159 --- a/include/drm/drm_crtc_helper.h
67160 +++ b/include/drm/drm_crtc_helper.h
67161 @@ -109,7 +109,7 @@ struct drm_encoder_helper_funcs {
67162 struct drm_connector *connector);
67163 /* disable encoder when not in use - more explicit than dpms off */
67164 void (*disable)(struct drm_encoder *encoder);
67165 -};
67166 +} __no_const;
67167
67168 /**
67169 * drm_connector_helper_funcs - helper operations for connectors
67170 diff --git a/include/drm/ttm/ttm_memory.h b/include/drm/ttm/ttm_memory.h
67171 index 72dcbe8..8db58d7 100644
67172 --- a/include/drm/ttm/ttm_memory.h
67173 +++ b/include/drm/ttm/ttm_memory.h
67174 @@ -48,7 +48,7 @@
67175
67176 struct ttm_mem_shrink {
67177 int (*do_shrink) (struct ttm_mem_shrink *);
67178 -};
67179 +} __no_const;
67180
67181 /**
67182 * struct ttm_mem_global - Global memory accounting structure.
67183 diff --git a/include/keys/asymmetric-subtype.h b/include/keys/asymmetric-subtype.h
67184 index 4b840e8..155d235 100644
67185 --- a/include/keys/asymmetric-subtype.h
67186 +++ b/include/keys/asymmetric-subtype.h
67187 @@ -37,7 +37,7 @@ struct asymmetric_key_subtype {
67188 /* Verify the signature on a key of this subtype (optional) */
67189 int (*verify_signature)(const struct key *key,
67190 const struct public_key_signature *sig);
67191 -};
67192 +} __do_const;
67193
67194 /**
67195 * asymmetric_key_subtype - Get the subtype from an asymmetric key
67196 diff --git a/include/linux/atmdev.h b/include/linux/atmdev.h
67197 index c1da539..1dcec55 100644
67198 --- a/include/linux/atmdev.h
67199 +++ b/include/linux/atmdev.h
67200 @@ -28,7 +28,7 @@ struct compat_atm_iobuf {
67201 #endif
67202
67203 struct k_atm_aal_stats {
67204 -#define __HANDLE_ITEM(i) atomic_t i
67205 +#define __HANDLE_ITEM(i) atomic_unchecked_t i
67206 __AAL_STAT_ITEMS
67207 #undef __HANDLE_ITEM
67208 };
67209 @@ -200,7 +200,7 @@ struct atmdev_ops { /* only send is required */
67210 int (*change_qos)(struct atm_vcc *vcc,struct atm_qos *qos,int flags);
67211 int (*proc_read)(struct atm_dev *dev,loff_t *pos,char *page);
67212 struct module *owner;
67213 -};
67214 +} __do_const ;
67215
67216 struct atmphy_ops {
67217 int (*start)(struct atm_dev *dev);
67218 diff --git a/include/linux/binfmts.h b/include/linux/binfmts.h
67219 index c3a0914..ec5d48a 100644
67220 --- a/include/linux/binfmts.h
67221 +++ b/include/linux/binfmts.h
67222 @@ -73,8 +73,9 @@ struct linux_binfmt {
67223 int (*load_binary)(struct linux_binprm *);
67224 int (*load_shlib)(struct file *);
67225 int (*core_dump)(struct coredump_params *cprm);
67226 + void (*handle_mprotect)(struct vm_area_struct *vma, unsigned long newflags);
67227 unsigned long min_coredump; /* minimal dump size */
67228 -};
67229 +} __do_const;
67230
67231 extern void __register_binfmt(struct linux_binfmt *fmt, int insert);
67232
67233 diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
67234 index 33f358f..7f2c27f 100644
67235 --- a/include/linux/blkdev.h
67236 +++ b/include/linux/blkdev.h
67237 @@ -1499,7 +1499,7 @@ struct block_device_operations {
67238 /* this callback is with swap_lock and sometimes page table lock held */
67239 void (*swap_slot_free_notify) (struct block_device *, unsigned long);
67240 struct module *owner;
67241 -};
67242 +} __do_const;
67243
67244 extern int __blkdev_driver_ioctl(struct block_device *, fmode_t, unsigned int,
67245 unsigned long);
67246 diff --git a/include/linux/blktrace_api.h b/include/linux/blktrace_api.h
67247 index 7c2e030..b72475d 100644
67248 --- a/include/linux/blktrace_api.h
67249 +++ b/include/linux/blktrace_api.h
67250 @@ -23,7 +23,7 @@ struct blk_trace {
67251 struct dentry *dir;
67252 struct dentry *dropped_file;
67253 struct dentry *msg_file;
67254 - atomic_t dropped;
67255 + atomic_unchecked_t dropped;
67256 };
67257
67258 extern int blk_trace_ioctl(struct block_device *, unsigned, char __user *);
67259 diff --git a/include/linux/cache.h b/include/linux/cache.h
67260 index 4c57065..4307975 100644
67261 --- a/include/linux/cache.h
67262 +++ b/include/linux/cache.h
67263 @@ -16,6 +16,10 @@
67264 #define __read_mostly
67265 #endif
67266
67267 +#ifndef __read_only
67268 +#define __read_only __read_mostly
67269 +#endif
67270 +
67271 #ifndef ____cacheline_aligned
67272 #define ____cacheline_aligned __attribute__((__aligned__(SMP_CACHE_BYTES)))
67273 #endif
67274 diff --git a/include/linux/capability.h b/include/linux/capability.h
67275 index d9a4f7f4..19f77d6 100644
67276 --- a/include/linux/capability.h
67277 +++ b/include/linux/capability.h
67278 @@ -213,8 +213,13 @@ extern bool ns_capable(struct user_namespace *ns, int cap);
67279 extern bool nsown_capable(int cap);
67280 extern bool inode_capable(const struct inode *inode, int cap);
67281 extern bool file_ns_capable(const struct file *file, struct user_namespace *ns, int cap);
67282 +extern bool capable_nolog(int cap);
67283 +extern bool ns_capable_nolog(struct user_namespace *ns, int cap);
67284 +extern bool inode_capable_nolog(const struct inode *inode, int cap);
67285
67286 /* audit system wants to get cap info from files as well */
67287 extern int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data *cpu_caps);
67288
67289 +extern int is_privileged_binary(const struct dentry *dentry);
67290 +
67291 #endif /* !_LINUX_CAPABILITY_H */
67292 diff --git a/include/linux/cdrom.h b/include/linux/cdrom.h
67293 index 8609d57..86e4d79 100644
67294 --- a/include/linux/cdrom.h
67295 +++ b/include/linux/cdrom.h
67296 @@ -87,7 +87,6 @@ struct cdrom_device_ops {
67297
67298 /* driver specifications */
67299 const int capability; /* capability flags */
67300 - int n_minors; /* number of active minor devices */
67301 /* handle uniform packets for scsi type devices (scsi,atapi) */
67302 int (*generic_packet) (struct cdrom_device_info *,
67303 struct packet_command *);
67304 diff --git a/include/linux/cleancache.h b/include/linux/cleancache.h
67305 index 42e55de..1cd0e66 100644
67306 --- a/include/linux/cleancache.h
67307 +++ b/include/linux/cleancache.h
67308 @@ -31,7 +31,7 @@ struct cleancache_ops {
67309 void (*invalidate_page)(int, struct cleancache_filekey, pgoff_t);
67310 void (*invalidate_inode)(int, struct cleancache_filekey);
67311 void (*invalidate_fs)(int);
67312 -};
67313 +} __no_const;
67314
67315 extern struct cleancache_ops
67316 cleancache_register_ops(struct cleancache_ops *ops);
67317 diff --git a/include/linux/compat.h b/include/linux/compat.h
67318 index 377cd8c..2479845 100644
67319 --- a/include/linux/compat.h
67320 +++ b/include/linux/compat.h
67321 @@ -332,14 +332,14 @@ long compat_sys_msgsnd(int first, int second, int third, void __user *uptr);
67322 long compat_sys_msgrcv(int first, int second, int msgtyp, int third,
67323 int version, void __user *uptr);
67324 long compat_sys_shmat(int first, int second, compat_uptr_t third, int version,
67325 - void __user *uptr);
67326 + void __user *uptr) __intentional_overflow(0);
67327 #else
67328 long compat_sys_semctl(int semid, int semnum, int cmd, int arg);
67329 long compat_sys_msgsnd(int msqid, struct compat_msgbuf __user *msgp,
67330 compat_ssize_t msgsz, int msgflg);
67331 long compat_sys_msgrcv(int msqid, struct compat_msgbuf __user *msgp,
67332 compat_ssize_t msgsz, long msgtyp, int msgflg);
67333 -long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg);
67334 +long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg) __intentional_overflow(0);
67335 #endif
67336 long compat_sys_msgctl(int first, int second, void __user *uptr);
67337 long compat_sys_shmctl(int first, int second, void __user *uptr);
67338 @@ -442,7 +442,7 @@ extern int compat_ptrace_request(struct task_struct *child,
67339 extern long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
67340 compat_ulong_t addr, compat_ulong_t data);
67341 asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
67342 - compat_long_t addr, compat_long_t data);
67343 + compat_ulong_t addr, compat_ulong_t data);
67344
67345 /*
67346 * epoll (fs/eventpoll.c) compat bits follow ...
67347 diff --git a/include/linux/compiler-gcc4.h b/include/linux/compiler-gcc4.h
67348 index 68b162d..660f5f0 100644
67349 --- a/include/linux/compiler-gcc4.h
67350 +++ b/include/linux/compiler-gcc4.h
67351 @@ -39,9 +39,29 @@
67352 # define __compiletime_warning(message) __attribute__((warning(message)))
67353 # define __compiletime_error(message) __attribute__((error(message)))
67354 #endif /* __CHECKER__ */
67355 +
67356 +#define __alloc_size(...) __attribute((alloc_size(__VA_ARGS__)))
67357 +#define __bos(ptr, arg) __builtin_object_size((ptr), (arg))
67358 +#define __bos0(ptr) __bos((ptr), 0)
67359 +#define __bos1(ptr) __bos((ptr), 1)
67360 #endif /* GCC_VERSION >= 40300 */
67361
67362 #if GCC_VERSION >= 40500
67363 +
67364 +#ifdef CONSTIFY_PLUGIN
67365 +#define __no_const __attribute__((no_const))
67366 +#define __do_const __attribute__((do_const))
67367 +#endif
67368 +
67369 +#ifdef SIZE_OVERFLOW_PLUGIN
67370 +#define __size_overflow(...) __attribute__((size_overflow(__VA_ARGS__)))
67371 +#define __intentional_overflow(...) __attribute__((intentional_overflow(__VA_ARGS__)))
67372 +#endif
67373 +
67374 +#ifdef LATENT_ENTROPY_PLUGIN
67375 +#define __latent_entropy __attribute__((latent_entropy))
67376 +#endif
67377 +
67378 /*
67379 * Mark a position in code as unreachable. This can be used to
67380 * suppress control flow warnings after asm blocks that transfer
67381 diff --git a/include/linux/compiler.h b/include/linux/compiler.h
67382 index 10b8f23..5e0b083 100644
67383 --- a/include/linux/compiler.h
67384 +++ b/include/linux/compiler.h
67385 @@ -5,11 +5,14 @@
67386
67387 #ifdef __CHECKER__
67388 # define __user __attribute__((noderef, address_space(1)))
67389 +# define __force_user __force __user
67390 # define __kernel __attribute__((address_space(0)))
67391 +# define __force_kernel __force __kernel
67392 # define __safe __attribute__((safe))
67393 # define __force __attribute__((force))
67394 # define __nocast __attribute__((nocast))
67395 # define __iomem __attribute__((noderef, address_space(2)))
67396 +# define __force_iomem __force __iomem
67397 # define __must_hold(x) __attribute__((context(x,1,1)))
67398 # define __acquires(x) __attribute__((context(x,0,1)))
67399 # define __releases(x) __attribute__((context(x,1,0)))
67400 @@ -17,20 +20,37 @@
67401 # define __release(x) __context__(x,-1)
67402 # define __cond_lock(x,c) ((c) ? ({ __acquire(x); 1; }) : 0)
67403 # define __percpu __attribute__((noderef, address_space(3)))
67404 +# define __force_percpu __force __percpu
67405 #ifdef CONFIG_SPARSE_RCU_POINTER
67406 # define __rcu __attribute__((noderef, address_space(4)))
67407 +# define __force_rcu __force __rcu
67408 #else
67409 # define __rcu
67410 +# define __force_rcu
67411 #endif
67412 extern void __chk_user_ptr(const volatile void __user *);
67413 extern void __chk_io_ptr(const volatile void __iomem *);
67414 #else
67415 -# define __user
67416 -# define __kernel
67417 +# ifdef CHECKER_PLUGIN
67418 +//# define __user
67419 +//# define __force_user
67420 +//# define __kernel
67421 +//# define __force_kernel
67422 +# else
67423 +# ifdef STRUCTLEAK_PLUGIN
67424 +# define __user __attribute__((user))
67425 +# else
67426 +# define __user
67427 +# endif
67428 +# define __force_user
67429 +# define __kernel
67430 +# define __force_kernel
67431 +# endif
67432 # define __safe
67433 # define __force
67434 # define __nocast
67435 # define __iomem
67436 +# define __force_iomem
67437 # define __chk_user_ptr(x) (void)0
67438 # define __chk_io_ptr(x) (void)0
67439 # define __builtin_warning(x, y...) (1)
67440 @@ -41,7 +61,9 @@ extern void __chk_io_ptr(const volatile void __iomem *);
67441 # define __release(x) (void)0
67442 # define __cond_lock(x,c) (c)
67443 # define __percpu
67444 +# define __force_percpu
67445 # define __rcu
67446 +# define __force_rcu
67447 #endif
67448
67449 /* Indirect macros required for expanded argument pasting, eg. __LINE__. */
67450 @@ -275,6 +297,26 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
67451 # define __attribute_const__ /* unimplemented */
67452 #endif
67453
67454 +#ifndef __no_const
67455 +# define __no_const
67456 +#endif
67457 +
67458 +#ifndef __do_const
67459 +# define __do_const
67460 +#endif
67461 +
67462 +#ifndef __size_overflow
67463 +# define __size_overflow(...)
67464 +#endif
67465 +
67466 +#ifndef __intentional_overflow
67467 +# define __intentional_overflow(...)
67468 +#endif
67469 +
67470 +#ifndef __latent_entropy
67471 +# define __latent_entropy
67472 +#endif
67473 +
67474 /*
67475 * Tell gcc if a function is cold. The compiler will assume any path
67476 * directly leading to the call is unlikely.
67477 @@ -284,6 +326,22 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
67478 #define __cold
67479 #endif
67480
67481 +#ifndef __alloc_size
67482 +#define __alloc_size(...)
67483 +#endif
67484 +
67485 +#ifndef __bos
67486 +#define __bos(ptr, arg)
67487 +#endif
67488 +
67489 +#ifndef __bos0
67490 +#define __bos0(ptr)
67491 +#endif
67492 +
67493 +#ifndef __bos1
67494 +#define __bos1(ptr)
67495 +#endif
67496 +
67497 /* Simple shorthand for a section definition */
67498 #ifndef __section
67499 # define __section(S) __attribute__ ((__section__(#S)))
67500 @@ -349,6 +407,7 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
67501 * use is to mediate communication between process-level code and irq/NMI
67502 * handlers, all running on the same CPU.
67503 */
67504 -#define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x))
67505 +#define ACCESS_ONCE(x) (*(volatile const typeof(x) *)&(x))
67506 +#define ACCESS_ONCE_RW(x) (*(volatile typeof(x) *)&(x))
67507
67508 #endif /* __LINUX_COMPILER_H */
67509 diff --git a/include/linux/completion.h b/include/linux/completion.h
67510 index 33f0280..35c6568 100644
67511 --- a/include/linux/completion.h
67512 +++ b/include/linux/completion.h
67513 @@ -79,15 +79,15 @@ static inline void init_completion(struct completion *x)
67514 extern void wait_for_completion(struct completion *);
67515 extern void wait_for_completion_io(struct completion *);
67516 extern int wait_for_completion_interruptible(struct completion *x);
67517 -extern int wait_for_completion_killable(struct completion *x);
67518 +extern int wait_for_completion_killable(struct completion *x) __intentional_overflow(-1);
67519 extern unsigned long wait_for_completion_timeout(struct completion *x,
67520 unsigned long timeout);
67521 extern unsigned long wait_for_completion_io_timeout(struct completion *x,
67522 unsigned long timeout);
67523 extern long wait_for_completion_interruptible_timeout(
67524 - struct completion *x, unsigned long timeout);
67525 + struct completion *x, unsigned long timeout) __intentional_overflow(-1);
67526 extern long wait_for_completion_killable_timeout(
67527 - struct completion *x, unsigned long timeout);
67528 + struct completion *x, unsigned long timeout) __intentional_overflow(-1);
67529 extern bool try_wait_for_completion(struct completion *x);
67530 extern bool completion_done(struct completion *x);
67531
67532 diff --git a/include/linux/configfs.h b/include/linux/configfs.h
67533 index 34025df..d94bbbc 100644
67534 --- a/include/linux/configfs.h
67535 +++ b/include/linux/configfs.h
67536 @@ -125,7 +125,7 @@ struct configfs_attribute {
67537 const char *ca_name;
67538 struct module *ca_owner;
67539 umode_t ca_mode;
67540 -};
67541 +} __do_const;
67542
67543 /*
67544 * Users often need to create attribute structures for their configurable
67545 diff --git a/include/linux/cpu.h b/include/linux/cpu.h
67546 index ce7a074..01ab8ac 100644
67547 --- a/include/linux/cpu.h
67548 +++ b/include/linux/cpu.h
67549 @@ -115,7 +115,7 @@ enum {
67550 /* Need to know about CPUs going up/down? */
67551 #if defined(CONFIG_HOTPLUG_CPU) || !defined(MODULE)
67552 #define cpu_notifier(fn, pri) { \
67553 - static struct notifier_block fn##_nb __cpuinitdata = \
67554 + static struct notifier_block fn##_nb = \
67555 { .notifier_call = fn, .priority = pri }; \
67556 register_cpu_notifier(&fn##_nb); \
67557 }
67558 diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
67559 index a22944c..4e695fe 100644
67560 --- a/include/linux/cpufreq.h
67561 +++ b/include/linux/cpufreq.h
67562 @@ -252,7 +252,7 @@ struct cpufreq_driver {
67563 int (*suspend) (struct cpufreq_policy *policy);
67564 int (*resume) (struct cpufreq_policy *policy);
67565 struct freq_attr **attr;
67566 -};
67567 +} __do_const;
67568
67569 /* flags */
67570
67571 @@ -311,6 +311,7 @@ struct global_attr {
67572 ssize_t (*store)(struct kobject *a, struct attribute *b,
67573 const char *c, size_t count);
67574 };
67575 +typedef struct global_attr __no_const global_attr_no_const;
67576
67577 #define define_one_global_ro(_name) \
67578 static struct global_attr _name = \
67579 diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h
67580 index 480c14d..552896f 100644
67581 --- a/include/linux/cpuidle.h
67582 +++ b/include/linux/cpuidle.h
67583 @@ -52,7 +52,8 @@ struct cpuidle_state {
67584 int index);
67585
67586 int (*enter_dead) (struct cpuidle_device *dev, int index);
67587 -};
67588 +} __do_const;
67589 +typedef struct cpuidle_state __no_const cpuidle_state_no_const;
67590
67591 /* Idle State Flags */
67592 #define CPUIDLE_FLAG_TIME_VALID (0x01) /* is residency time measurable? */
67593 @@ -194,7 +195,7 @@ struct cpuidle_governor {
67594 void (*reflect) (struct cpuidle_device *dev, int index);
67595
67596 struct module *owner;
67597 -};
67598 +} __do_const;
67599
67600 #ifdef CONFIG_CPU_IDLE
67601
67602 diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
67603 index 0325602..5e9feff 100644
67604 --- a/include/linux/cpumask.h
67605 +++ b/include/linux/cpumask.h
67606 @@ -118,17 +118,17 @@ static inline unsigned int cpumask_first(const struct cpumask *srcp)
67607 }
67608
67609 /* Valid inputs for n are -1 and 0. */
67610 -static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
67611 +static inline unsigned int __intentional_overflow(-1) cpumask_next(int n, const struct cpumask *srcp)
67612 {
67613 return n+1;
67614 }
67615
67616 -static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
67617 +static inline unsigned int __intentional_overflow(-1) cpumask_next_zero(int n, const struct cpumask *srcp)
67618 {
67619 return n+1;
67620 }
67621
67622 -static inline unsigned int cpumask_next_and(int n,
67623 +static inline unsigned int __intentional_overflow(-1) cpumask_next_and(int n,
67624 const struct cpumask *srcp,
67625 const struct cpumask *andp)
67626 {
67627 @@ -167,7 +167,7 @@ static inline unsigned int cpumask_first(const struct cpumask *srcp)
67628 *
67629 * Returns >= nr_cpu_ids if no further cpus set.
67630 */
67631 -static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
67632 +static inline unsigned int __intentional_overflow(-1) cpumask_next(int n, const struct cpumask *srcp)
67633 {
67634 /* -1 is a legal arg here. */
67635 if (n != -1)
67636 @@ -182,7 +182,7 @@ static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
67637 *
67638 * Returns >= nr_cpu_ids if no further cpus unset.
67639 */
67640 -static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
67641 +static inline unsigned int __intentional_overflow(-1) cpumask_next_zero(int n, const struct cpumask *srcp)
67642 {
67643 /* -1 is a legal arg here. */
67644 if (n != -1)
67645 @@ -190,7 +190,7 @@ static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
67646 return find_next_zero_bit(cpumask_bits(srcp), nr_cpumask_bits, n+1);
67647 }
67648
67649 -int cpumask_next_and(int n, const struct cpumask *, const struct cpumask *);
67650 +int cpumask_next_and(int n, const struct cpumask *, const struct cpumask *) __intentional_overflow(-1);
67651 int cpumask_any_but(const struct cpumask *mask, unsigned int cpu);
67652
67653 /**
67654 diff --git a/include/linux/cred.h b/include/linux/cred.h
67655 index 04421e8..6bce4ef 100644
67656 --- a/include/linux/cred.h
67657 +++ b/include/linux/cred.h
67658 @@ -194,6 +194,9 @@ static inline void validate_creds_for_do_exit(struct task_struct *tsk)
67659 static inline void validate_process_creds(void)
67660 {
67661 }
67662 +static inline void validate_task_creds(struct task_struct *task)
67663 +{
67664 +}
67665 #endif
67666
67667 /**
67668 diff --git a/include/linux/crypto.h b/include/linux/crypto.h
67669 index b92eadf..b4ecdc1 100644
67670 --- a/include/linux/crypto.h
67671 +++ b/include/linux/crypto.h
67672 @@ -373,7 +373,7 @@ struct cipher_tfm {
67673 const u8 *key, unsigned int keylen);
67674 void (*cit_encrypt_one)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
67675 void (*cit_decrypt_one)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
67676 -};
67677 +} __no_const;
67678
67679 struct hash_tfm {
67680 int (*init)(struct hash_desc *desc);
67681 @@ -394,13 +394,13 @@ struct compress_tfm {
67682 int (*cot_decompress)(struct crypto_tfm *tfm,
67683 const u8 *src, unsigned int slen,
67684 u8 *dst, unsigned int *dlen);
67685 -};
67686 +} __no_const;
67687
67688 struct rng_tfm {
67689 int (*rng_gen_random)(struct crypto_rng *tfm, u8 *rdata,
67690 unsigned int dlen);
67691 int (*rng_reset)(struct crypto_rng *tfm, u8 *seed, unsigned int slen);
67692 -};
67693 +} __no_const;
67694
67695 #define crt_ablkcipher crt_u.ablkcipher
67696 #define crt_aead crt_u.aead
67697 diff --git a/include/linux/ctype.h b/include/linux/ctype.h
67698 index 8acfe31..6ffccd63 100644
67699 --- a/include/linux/ctype.h
67700 +++ b/include/linux/ctype.h
67701 @@ -56,7 +56,7 @@ static inline unsigned char __toupper(unsigned char c)
67702 * Fast implementation of tolower() for internal usage. Do not use in your
67703 * code.
67704 */
67705 -static inline char _tolower(const char c)
67706 +static inline unsigned char _tolower(const unsigned char c)
67707 {
67708 return c | 0x20;
67709 }
67710 diff --git a/include/linux/decompress/mm.h b/include/linux/decompress/mm.h
67711 index 7925bf0..d5143d2 100644
67712 --- a/include/linux/decompress/mm.h
67713 +++ b/include/linux/decompress/mm.h
67714 @@ -77,7 +77,7 @@ static void free(void *where)
67715 * warnings when not needed (indeed large_malloc / large_free are not
67716 * needed by inflate */
67717
67718 -#define malloc(a) kmalloc(a, GFP_KERNEL)
67719 +#define malloc(a) kmalloc((a), GFP_KERNEL)
67720 #define free(a) kfree(a)
67721
67722 #define large_malloc(a) vmalloc(a)
67723 diff --git a/include/linux/devfreq.h b/include/linux/devfreq.h
67724 index fe8c447..bdc1f33 100644
67725 --- a/include/linux/devfreq.h
67726 +++ b/include/linux/devfreq.h
67727 @@ -114,7 +114,7 @@ struct devfreq_governor {
67728 int (*get_target_freq)(struct devfreq *this, unsigned long *freq);
67729 int (*event_handler)(struct devfreq *devfreq,
67730 unsigned int event, void *data);
67731 -};
67732 +} __do_const;
67733
67734 /**
67735 * struct devfreq - Device devfreq structure
67736 diff --git a/include/linux/device.h b/include/linux/device.h
67737 index 9d6464e..8a5cc92 100644
67738 --- a/include/linux/device.h
67739 +++ b/include/linux/device.h
67740 @@ -295,7 +295,7 @@ struct subsys_interface {
67741 struct list_head node;
67742 int (*add_dev)(struct device *dev, struct subsys_interface *sif);
67743 int (*remove_dev)(struct device *dev, struct subsys_interface *sif);
67744 -};
67745 +} __do_const;
67746
67747 int subsys_interface_register(struct subsys_interface *sif);
67748 void subsys_interface_unregister(struct subsys_interface *sif);
67749 @@ -475,7 +475,7 @@ struct device_type {
67750 void (*release)(struct device *dev);
67751
67752 const struct dev_pm_ops *pm;
67753 -};
67754 +} __do_const;
67755
67756 /* interface for exporting device attributes */
67757 struct device_attribute {
67758 @@ -485,11 +485,12 @@ struct device_attribute {
67759 ssize_t (*store)(struct device *dev, struct device_attribute *attr,
67760 const char *buf, size_t count);
67761 };
67762 +typedef struct device_attribute __no_const device_attribute_no_const;
67763
67764 struct dev_ext_attribute {
67765 struct device_attribute attr;
67766 void *var;
67767 -};
67768 +} __do_const;
67769
67770 ssize_t device_show_ulong(struct device *dev, struct device_attribute *attr,
67771 char *buf);
67772 diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
67773 index 94af418..b1ca7a2 100644
67774 --- a/include/linux/dma-mapping.h
67775 +++ b/include/linux/dma-mapping.h
67776 @@ -54,7 +54,7 @@ struct dma_map_ops {
67777 u64 (*get_required_mask)(struct device *dev);
67778 #endif
67779 int is_phys;
67780 -};
67781 +} __do_const;
67782
67783 #define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1))
67784
67785 diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
67786 index 91ac8da..a841318 100644
67787 --- a/include/linux/dmaengine.h
67788 +++ b/include/linux/dmaengine.h
67789 @@ -1034,9 +1034,9 @@ struct dma_pinned_list {
67790 struct dma_pinned_list *dma_pin_iovec_pages(struct iovec *iov, size_t len);
67791 void dma_unpin_iovec_pages(struct dma_pinned_list* pinned_list);
67792
67793 -dma_cookie_t dma_memcpy_to_iovec(struct dma_chan *chan, struct iovec *iov,
67794 +dma_cookie_t __intentional_overflow(0) dma_memcpy_to_iovec(struct dma_chan *chan, struct iovec *iov,
67795 struct dma_pinned_list *pinned_list, unsigned char *kdata, size_t len);
67796 -dma_cookie_t dma_memcpy_pg_to_iovec(struct dma_chan *chan, struct iovec *iov,
67797 +dma_cookie_t __intentional_overflow(0) dma_memcpy_pg_to_iovec(struct dma_chan *chan, struct iovec *iov,
67798 struct dma_pinned_list *pinned_list, struct page *page,
67799 unsigned int offset, size_t len);
67800
67801 diff --git a/include/linux/efi.h b/include/linux/efi.h
67802 index 3d7df3d..301f024 100644
67803 --- a/include/linux/efi.h
67804 +++ b/include/linux/efi.h
67805 @@ -740,6 +740,7 @@ struct efivar_operations {
67806 efi_set_variable_t *set_variable;
67807 efi_query_variable_store_t *query_variable_store;
67808 };
67809 +typedef struct efivar_operations __no_const efivar_operations_no_const;
67810
67811 struct efivars {
67812 /*
67813 diff --git a/include/linux/elf.h b/include/linux/elf.h
67814 index 40a3c0e..4c45a38 100644
67815 --- a/include/linux/elf.h
67816 +++ b/include/linux/elf.h
67817 @@ -24,6 +24,7 @@ extern Elf32_Dyn _DYNAMIC [];
67818 #define elf_note elf32_note
67819 #define elf_addr_t Elf32_Off
67820 #define Elf_Half Elf32_Half
67821 +#define elf_dyn Elf32_Dyn
67822
67823 #else
67824
67825 @@ -34,6 +35,7 @@ extern Elf64_Dyn _DYNAMIC [];
67826 #define elf_note elf64_note
67827 #define elf_addr_t Elf64_Off
67828 #define Elf_Half Elf64_Half
67829 +#define elf_dyn Elf64_Dyn
67830
67831 #endif
67832
67833 diff --git a/include/linux/err.h b/include/linux/err.h
67834 index f2edce2..cc2082c 100644
67835 --- a/include/linux/err.h
67836 +++ b/include/linux/err.h
67837 @@ -19,12 +19,12 @@
67838
67839 #define IS_ERR_VALUE(x) unlikely((x) >= (unsigned long)-MAX_ERRNO)
67840
67841 -static inline void * __must_check ERR_PTR(long error)
67842 +static inline void * __must_check __intentional_overflow(-1) ERR_PTR(long error)
67843 {
67844 return (void *) error;
67845 }
67846
67847 -static inline long __must_check PTR_ERR(const void *ptr)
67848 +static inline long __must_check __intentional_overflow(-1) PTR_ERR(const void *ptr)
67849 {
67850 return (long) ptr;
67851 }
67852 diff --git a/include/linux/extcon.h b/include/linux/extcon.h
67853 index fcb51c8..bdafcf6 100644
67854 --- a/include/linux/extcon.h
67855 +++ b/include/linux/extcon.h
67856 @@ -134,7 +134,7 @@ struct extcon_dev {
67857 /* /sys/class/extcon/.../mutually_exclusive/... */
67858 struct attribute_group attr_g_muex;
67859 struct attribute **attrs_muex;
67860 - struct device_attribute *d_attrs_muex;
67861 + device_attribute_no_const *d_attrs_muex;
67862 };
67863
67864 /**
67865 diff --git a/include/linux/fb.h b/include/linux/fb.h
67866 index 58b9860..58e5516 100644
67867 --- a/include/linux/fb.h
67868 +++ b/include/linux/fb.h
67869 @@ -304,7 +304,7 @@ struct fb_ops {
67870 /* called at KDB enter and leave time to prepare the console */
67871 int (*fb_debug_enter)(struct fb_info *info);
67872 int (*fb_debug_leave)(struct fb_info *info);
67873 -};
67874 +} __do_const;
67875
67876 #ifdef CONFIG_FB_TILEBLITTING
67877 #define FB_TILE_CURSOR_NONE 0
67878 diff --git a/include/linux/filter.h b/include/linux/filter.h
67879 index c45eabc..baa0be5 100644
67880 --- a/include/linux/filter.h
67881 +++ b/include/linux/filter.h
67882 @@ -20,6 +20,7 @@ struct compat_sock_fprog {
67883
67884 struct sk_buff;
67885 struct sock;
67886 +struct bpf_jit_work;
67887
67888 struct sk_filter
67889 {
67890 @@ -27,6 +28,9 @@ struct sk_filter
67891 unsigned int len; /* Number of filter blocks */
67892 unsigned int (*bpf_func)(const struct sk_buff *skb,
67893 const struct sock_filter *filter);
67894 +#ifdef CONFIG_BPF_JIT
67895 + struct bpf_jit_work *work;
67896 +#endif
67897 struct rcu_head rcu;
67898 struct sock_filter insns[0];
67899 };
67900 diff --git a/include/linux/frontswap.h b/include/linux/frontswap.h
67901 index 3044254..9767f41 100644
67902 --- a/include/linux/frontswap.h
67903 +++ b/include/linux/frontswap.h
67904 @@ -11,7 +11,7 @@ struct frontswap_ops {
67905 int (*load)(unsigned, pgoff_t, struct page *);
67906 void (*invalidate_page)(unsigned, pgoff_t);
67907 void (*invalidate_area)(unsigned);
67908 -};
67909 +} __no_const;
67910
67911 extern bool frontswap_enabled;
67912 extern struct frontswap_ops
67913 diff --git a/include/linux/fs.h b/include/linux/fs.h
67914 index 2c28271..8d3d74c 100644
67915 --- a/include/linux/fs.h
67916 +++ b/include/linux/fs.h
67917 @@ -1541,7 +1541,8 @@ struct file_operations {
67918 long (*fallocate)(struct file *file, int mode, loff_t offset,
67919 loff_t len);
67920 int (*show_fdinfo)(struct seq_file *m, struct file *f);
67921 -};
67922 +} __do_const;
67923 +typedef struct file_operations __no_const file_operations_no_const;
67924
67925 struct inode_operations {
67926 struct dentry * (*lookup) (struct inode *,struct dentry *, unsigned int);
67927 @@ -2672,4 +2673,14 @@ static inline void inode_has_no_xattr(struct inode *inode)
67928 inode->i_flags |= S_NOSEC;
67929 }
67930
67931 +static inline bool is_sidechannel_device(const struct inode *inode)
67932 +{
67933 +#ifdef CONFIG_GRKERNSEC_DEVICE_SIDECHANNEL
67934 + umode_t mode = inode->i_mode;
67935 + return ((S_ISCHR(mode) || S_ISBLK(mode)) && (mode & (S_IROTH | S_IWOTH)));
67936 +#else
67937 + return false;
67938 +#endif
67939 +}
67940 +
67941 #endif /* _LINUX_FS_H */
67942 diff --git a/include/linux/fs_struct.h b/include/linux/fs_struct.h
67943 index 2b93a9a..855d94a 100644
67944 --- a/include/linux/fs_struct.h
67945 +++ b/include/linux/fs_struct.h
67946 @@ -6,7 +6,7 @@
67947 #include <linux/seqlock.h>
67948
67949 struct fs_struct {
67950 - int users;
67951 + atomic_t users;
67952 spinlock_t lock;
67953 seqcount_t seq;
67954 int umask;
67955 diff --git a/include/linux/fscache-cache.h b/include/linux/fscache-cache.h
67956 index 5dfa0aa..6acf322 100644
67957 --- a/include/linux/fscache-cache.h
67958 +++ b/include/linux/fscache-cache.h
67959 @@ -112,7 +112,7 @@ struct fscache_operation {
67960 fscache_operation_release_t release;
67961 };
67962
67963 -extern atomic_t fscache_op_debug_id;
67964 +extern atomic_unchecked_t fscache_op_debug_id;
67965 extern void fscache_op_work_func(struct work_struct *work);
67966
67967 extern void fscache_enqueue_operation(struct fscache_operation *);
67968 @@ -134,7 +134,7 @@ static inline void fscache_operation_init(struct fscache_operation *op,
67969 INIT_WORK(&op->work, fscache_op_work_func);
67970 atomic_set(&op->usage, 1);
67971 op->state = FSCACHE_OP_ST_INITIALISED;
67972 - op->debug_id = atomic_inc_return(&fscache_op_debug_id);
67973 + op->debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
67974 op->processor = processor;
67975 op->release = release;
67976 INIT_LIST_HEAD(&op->pend_link);
67977 diff --git a/include/linux/fscache.h b/include/linux/fscache.h
67978 index 7a08623..4c07b0f 100644
67979 --- a/include/linux/fscache.h
67980 +++ b/include/linux/fscache.h
67981 @@ -152,7 +152,7 @@ struct fscache_cookie_def {
67982 * - this is mandatory for any object that may have data
67983 */
67984 void (*now_uncached)(void *cookie_netfs_data);
67985 -};
67986 +} __do_const;
67987
67988 /*
67989 * fscache cached network filesystem type
67990 diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h
67991 index a78680a..87bd73e 100644
67992 --- a/include/linux/fsnotify.h
67993 +++ b/include/linux/fsnotify.h
67994 @@ -195,6 +195,9 @@ static inline void fsnotify_access(struct file *file)
67995 struct inode *inode = path->dentry->d_inode;
67996 __u32 mask = FS_ACCESS;
67997
67998 + if (is_sidechannel_device(inode))
67999 + return;
68000 +
68001 if (S_ISDIR(inode->i_mode))
68002 mask |= FS_ISDIR;
68003
68004 @@ -213,6 +216,9 @@ static inline void fsnotify_modify(struct file *file)
68005 struct inode *inode = path->dentry->d_inode;
68006 __u32 mask = FS_MODIFY;
68007
68008 + if (is_sidechannel_device(inode))
68009 + return;
68010 +
68011 if (S_ISDIR(inode->i_mode))
68012 mask |= FS_ISDIR;
68013
68014 @@ -315,7 +321,7 @@ static inline void fsnotify_change(struct dentry *dentry, unsigned int ia_valid)
68015 */
68016 static inline const unsigned char *fsnotify_oldname_init(const unsigned char *name)
68017 {
68018 - return kstrdup(name, GFP_KERNEL);
68019 + return (const unsigned char *)kstrdup((const char *)name, GFP_KERNEL);
68020 }
68021
68022 /*
68023 diff --git a/include/linux/ftrace_event.h b/include/linux/ftrace_event.h
68024 index 13a54d0..c6ce2a7 100644
68025 --- a/include/linux/ftrace_event.h
68026 +++ b/include/linux/ftrace_event.h
68027 @@ -274,7 +274,7 @@ extern int trace_define_field(struct ftrace_event_call *call, const char *type,
68028 extern int trace_add_event_call(struct ftrace_event_call *call);
68029 extern void trace_remove_event_call(struct ftrace_event_call *call);
68030
68031 -#define is_signed_type(type) (((type)(-1)) < (type)0)
68032 +#define is_signed_type(type) (((type)(-1)) < (type)1)
68033
68034 int trace_set_clr_event(const char *system, const char *event, int set);
68035
68036 diff --git a/include/linux/genhd.h b/include/linux/genhd.h
68037 index 9f3c275..911b591 100644
68038 --- a/include/linux/genhd.h
68039 +++ b/include/linux/genhd.h
68040 @@ -194,7 +194,7 @@ struct gendisk {
68041 struct kobject *slave_dir;
68042
68043 struct timer_rand_state *random;
68044 - atomic_t sync_io; /* RAID */
68045 + atomic_unchecked_t sync_io; /* RAID */
68046 struct disk_events *ev;
68047 #ifdef CONFIG_BLK_DEV_INTEGRITY
68048 struct blk_integrity *integrity;
68049 diff --git a/include/linux/genl_magic_func.h b/include/linux/genl_magic_func.h
68050 index 023bc34..b02b46a 100644
68051 --- a/include/linux/genl_magic_func.h
68052 +++ b/include/linux/genl_magic_func.h
68053 @@ -246,7 +246,7 @@ const char *CONCAT_(GENL_MAGIC_FAMILY, _genl_cmd_to_str)(__u8 cmd)
68054 },
68055
68056 #define ZZZ_genl_ops CONCAT_(GENL_MAGIC_FAMILY, _genl_ops)
68057 -static struct genl_ops ZZZ_genl_ops[] __read_mostly = {
68058 +static struct genl_ops ZZZ_genl_ops[] = {
68059 #include GENL_MAGIC_INCLUDE_FILE
68060 };
68061
68062 diff --git a/include/linux/gfp.h b/include/linux/gfp.h
68063 index 0f615eb..5c3832f 100644
68064 --- a/include/linux/gfp.h
68065 +++ b/include/linux/gfp.h
68066 @@ -35,6 +35,13 @@ struct vm_area_struct;
68067 #define ___GFP_NO_KSWAPD 0x400000u
68068 #define ___GFP_OTHER_NODE 0x800000u
68069 #define ___GFP_WRITE 0x1000000u
68070 +
68071 +#ifdef CONFIG_PAX_USERCOPY_SLABS
68072 +#define ___GFP_USERCOPY 0x2000000u
68073 +#else
68074 +#define ___GFP_USERCOPY 0
68075 +#endif
68076 +
68077 /* If the above are modified, __GFP_BITS_SHIFT may need updating */
68078
68079 /*
68080 @@ -92,6 +99,7 @@ struct vm_area_struct;
68081 #define __GFP_OTHER_NODE ((__force gfp_t)___GFP_OTHER_NODE) /* On behalf of other node */
68082 #define __GFP_KMEMCG ((__force gfp_t)___GFP_KMEMCG) /* Allocation comes from a memcg-accounted resource */
68083 #define __GFP_WRITE ((__force gfp_t)___GFP_WRITE) /* Allocator intends to dirty page */
68084 +#define __GFP_USERCOPY ((__force gfp_t)___GFP_USERCOPY)/* Allocator intends to copy page to/from userland */
68085
68086 /*
68087 * This may seem redundant, but it's a way of annotating false positives vs.
68088 @@ -99,7 +107,7 @@ struct vm_area_struct;
68089 */
68090 #define __GFP_NOTRACK_FALSE_POSITIVE (__GFP_NOTRACK)
68091
68092 -#define __GFP_BITS_SHIFT 25 /* Room for N __GFP_FOO bits */
68093 +#define __GFP_BITS_SHIFT 26 /* Room for N __GFP_FOO bits */
68094 #define __GFP_BITS_MASK ((__force gfp_t)((1 << __GFP_BITS_SHIFT) - 1))
68095
68096 /* This equals 0, but use constants in case they ever change */
68097 @@ -153,6 +161,8 @@ struct vm_area_struct;
68098 /* 4GB DMA on some platforms */
68099 #define GFP_DMA32 __GFP_DMA32
68100
68101 +#define GFP_USERCOPY __GFP_USERCOPY
68102 +
68103 /* Convert GFP flags to their corresponding migrate type */
68104 static inline int allocflags_to_migratetype(gfp_t gfp_flags)
68105 {
68106 diff --git a/include/linux/gracl.h b/include/linux/gracl.h
68107 new file mode 100644
68108 index 0000000..ebe6d72
68109 --- /dev/null
68110 +++ b/include/linux/gracl.h
68111 @@ -0,0 +1,319 @@
68112 +#ifndef GR_ACL_H
68113 +#define GR_ACL_H
68114 +
68115 +#include <linux/grdefs.h>
68116 +#include <linux/resource.h>
68117 +#include <linux/capability.h>
68118 +#include <linux/dcache.h>
68119 +#include <asm/resource.h>
68120 +
68121 +/* Major status information */
68122 +
68123 +#define GR_VERSION "grsecurity 2.9.1"
68124 +#define GRSECURITY_VERSION 0x2901
68125 +
68126 +enum {
68127 + GR_SHUTDOWN = 0,
68128 + GR_ENABLE = 1,
68129 + GR_SPROLE = 2,
68130 + GR_RELOAD = 3,
68131 + GR_SEGVMOD = 4,
68132 + GR_STATUS = 5,
68133 + GR_UNSPROLE = 6,
68134 + GR_PASSSET = 7,
68135 + GR_SPROLEPAM = 8,
68136 +};
68137 +
68138 +/* Password setup definitions
68139 + * kernel/grhash.c */
68140 +enum {
68141 + GR_PW_LEN = 128,
68142 + GR_SALT_LEN = 16,
68143 + GR_SHA_LEN = 32,
68144 +};
68145 +
68146 +enum {
68147 + GR_SPROLE_LEN = 64,
68148 +};
68149 +
68150 +enum {
68151 + GR_NO_GLOB = 0,
68152 + GR_REG_GLOB,
68153 + GR_CREATE_GLOB
68154 +};
68155 +
68156 +#define GR_NLIMITS 32
68157 +
68158 +/* Begin Data Structures */
68159 +
68160 +struct sprole_pw {
68161 + unsigned char *rolename;
68162 + unsigned char salt[GR_SALT_LEN];
68163 + unsigned char sum[GR_SHA_LEN]; /* 256-bit SHA hash of the password */
68164 +};
68165 +
68166 +struct name_entry {
68167 + __u32 key;
68168 + ino_t inode;
68169 + dev_t device;
68170 + char *name;
68171 + __u16 len;
68172 + __u8 deleted;
68173 + struct name_entry *prev;
68174 + struct name_entry *next;
68175 +};
68176 +
68177 +struct inodev_entry {
68178 + struct name_entry *nentry;
68179 + struct inodev_entry *prev;
68180 + struct inodev_entry *next;
68181 +};
68182 +
68183 +struct acl_role_db {
68184 + struct acl_role_label **r_hash;
68185 + __u32 r_size;
68186 +};
68187 +
68188 +struct inodev_db {
68189 + struct inodev_entry **i_hash;
68190 + __u32 i_size;
68191 +};
68192 +
68193 +struct name_db {
68194 + struct name_entry **n_hash;
68195 + __u32 n_size;
68196 +};
68197 +
68198 +struct crash_uid {
68199 + uid_t uid;
68200 + unsigned long expires;
68201 +};
68202 +
68203 +struct gr_hash_struct {
68204 + void **table;
68205 + void **nametable;
68206 + void *first;
68207 + __u32 table_size;
68208 + __u32 used_size;
68209 + int type;
68210 +};
68211 +
68212 +/* Userspace Grsecurity ACL data structures */
68213 +
68214 +struct acl_subject_label {
68215 + char *filename;
68216 + ino_t inode;
68217 + dev_t device;
68218 + __u32 mode;
68219 + kernel_cap_t cap_mask;
68220 + kernel_cap_t cap_lower;
68221 + kernel_cap_t cap_invert_audit;
68222 +
68223 + struct rlimit res[GR_NLIMITS];
68224 + __u32 resmask;
68225 +
68226 + __u8 user_trans_type;
68227 + __u8 group_trans_type;
68228 + uid_t *user_transitions;
68229 + gid_t *group_transitions;
68230 + __u16 user_trans_num;
68231 + __u16 group_trans_num;
68232 +
68233 + __u32 sock_families[2];
68234 + __u32 ip_proto[8];
68235 + __u32 ip_type;
68236 + struct acl_ip_label **ips;
68237 + __u32 ip_num;
68238 + __u32 inaddr_any_override;
68239 +
68240 + __u32 crashes;
68241 + unsigned long expires;
68242 +
68243 + struct acl_subject_label *parent_subject;
68244 + struct gr_hash_struct *hash;
68245 + struct acl_subject_label *prev;
68246 + struct acl_subject_label *next;
68247 +
68248 + struct acl_object_label **obj_hash;
68249 + __u32 obj_hash_size;
68250 + __u16 pax_flags;
68251 +};
68252 +
68253 +struct role_allowed_ip {
68254 + __u32 addr;
68255 + __u32 netmask;
68256 +
68257 + struct role_allowed_ip *prev;
68258 + struct role_allowed_ip *next;
68259 +};
68260 +
68261 +struct role_transition {
68262 + char *rolename;
68263 +
68264 + struct role_transition *prev;
68265 + struct role_transition *next;
68266 +};
68267 +
68268 +struct acl_role_label {
68269 + char *rolename;
68270 + uid_t uidgid;
68271 + __u16 roletype;
68272 +
68273 + __u16 auth_attempts;
68274 + unsigned long expires;
68275 +
68276 + struct acl_subject_label *root_label;
68277 + struct gr_hash_struct *hash;
68278 +
68279 + struct acl_role_label *prev;
68280 + struct acl_role_label *next;
68281 +
68282 + struct role_transition *transitions;
68283 + struct role_allowed_ip *allowed_ips;
68284 + uid_t *domain_children;
68285 + __u16 domain_child_num;
68286 +
68287 + umode_t umask;
68288 +
68289 + struct acl_subject_label **subj_hash;
68290 + __u32 subj_hash_size;
68291 +};
68292 +
68293 +struct user_acl_role_db {
68294 + struct acl_role_label **r_table;
68295 + __u32 num_pointers; /* Number of allocations to track */
68296 + __u32 num_roles; /* Number of roles */
68297 + __u32 num_domain_children; /* Number of domain children */
68298 + __u32 num_subjects; /* Number of subjects */
68299 + __u32 num_objects; /* Number of objects */
68300 +};
68301 +
68302 +struct acl_object_label {
68303 + char *filename;
68304 + ino_t inode;
68305 + dev_t device;
68306 + __u32 mode;
68307 +
68308 + struct acl_subject_label *nested;
68309 + struct acl_object_label *globbed;
68310 +
68311 + /* next two structures not used */
68312 +
68313 + struct acl_object_label *prev;
68314 + struct acl_object_label *next;
68315 +};
68316 +
68317 +struct acl_ip_label {
68318 + char *iface;
68319 + __u32 addr;
68320 + __u32 netmask;
68321 + __u16 low, high;
68322 + __u8 mode;
68323 + __u32 type;
68324 + __u32 proto[8];
68325 +
68326 + /* next two structures not used */
68327 +
68328 + struct acl_ip_label *prev;
68329 + struct acl_ip_label *next;
68330 +};
68331 +
68332 +struct gr_arg {
68333 + struct user_acl_role_db role_db;
68334 + unsigned char pw[GR_PW_LEN];
68335 + unsigned char salt[GR_SALT_LEN];
68336 + unsigned char sum[GR_SHA_LEN];
68337 + unsigned char sp_role[GR_SPROLE_LEN];
68338 + struct sprole_pw *sprole_pws;
68339 + dev_t segv_device;
68340 + ino_t segv_inode;
68341 + uid_t segv_uid;
68342 + __u16 num_sprole_pws;
68343 + __u16 mode;
68344 +};
68345 +
68346 +struct gr_arg_wrapper {
68347 + struct gr_arg *arg;
68348 + __u32 version;
68349 + __u32 size;
68350 +};
68351 +
68352 +struct subject_map {
68353 + struct acl_subject_label *user;
68354 + struct acl_subject_label *kernel;
68355 + struct subject_map *prev;
68356 + struct subject_map *next;
68357 +};
68358 +
68359 +struct acl_subj_map_db {
68360 + struct subject_map **s_hash;
68361 + __u32 s_size;
68362 +};
68363 +
68364 +/* End Data Structures Section */
68365 +
68366 +/* Hash functions generated by empirical testing by Brad Spengler
68367 + Makes good use of the low bits of the inode. Generally 0-1 times
68368 + in loop for successful match. 0-3 for unsuccessful match.
68369 + Shift/add algorithm with modulus of table size and an XOR*/
68370 +
68371 +static __inline__ unsigned int
68372 +gr_rhash(const uid_t uid, const __u16 type, const unsigned int sz)
68373 +{
68374 + return ((((uid + type) << (16 + type)) ^ uid) % sz);
68375 +}
68376 +
68377 + static __inline__ unsigned int
68378 +gr_shash(const struct acl_subject_label *userp, const unsigned int sz)
68379 +{
68380 + return ((const unsigned long)userp % sz);
68381 +}
68382 +
68383 +static __inline__ unsigned int
68384 +gr_fhash(const ino_t ino, const dev_t dev, const unsigned int sz)
68385 +{
68386 + return (((ino + dev) ^ ((ino << 13) + (ino << 23) + (dev << 9))) % sz);
68387 +}
68388 +
68389 +static __inline__ unsigned int
68390 +gr_nhash(const char *name, const __u16 len, const unsigned int sz)
68391 +{
68392 + return full_name_hash((const unsigned char *)name, len) % sz;
68393 +}
68394 +
68395 +#define FOR_EACH_ROLE_START(role) \
68396 + role = role_list; \
68397 + while (role) {
68398 +
68399 +#define FOR_EACH_ROLE_END(role) \
68400 + role = role->prev; \
68401 + }
68402 +
68403 +#define FOR_EACH_SUBJECT_START(role,subj,iter) \
68404 + subj = NULL; \
68405 + iter = 0; \
68406 + while (iter < role->subj_hash_size) { \
68407 + if (subj == NULL) \
68408 + subj = role->subj_hash[iter]; \
68409 + if (subj == NULL) { \
68410 + iter++; \
68411 + continue; \
68412 + }
68413 +
68414 +#define FOR_EACH_SUBJECT_END(subj,iter) \
68415 + subj = subj->next; \
68416 + if (subj == NULL) \
68417 + iter++; \
68418 + }
68419 +
68420 +
68421 +#define FOR_EACH_NESTED_SUBJECT_START(role,subj) \
68422 + subj = role->hash->first; \
68423 + while (subj != NULL) {
68424 +
68425 +#define FOR_EACH_NESTED_SUBJECT_END(subj) \
68426 + subj = subj->next; \
68427 + }
68428 +
68429 +#endif
68430 +
68431 diff --git a/include/linux/gralloc.h b/include/linux/gralloc.h
68432 new file mode 100644
68433 index 0000000..323ecf2
68434 --- /dev/null
68435 +++ b/include/linux/gralloc.h
68436 @@ -0,0 +1,9 @@
68437 +#ifndef __GRALLOC_H
68438 +#define __GRALLOC_H
68439 +
68440 +void acl_free_all(void);
68441 +int acl_alloc_stack_init(unsigned long size);
68442 +void *acl_alloc(unsigned long len);
68443 +void *acl_alloc_num(unsigned long num, unsigned long len);
68444 +
68445 +#endif
68446 diff --git a/include/linux/grdefs.h b/include/linux/grdefs.h
68447 new file mode 100644
68448 index 0000000..be66033
68449 --- /dev/null
68450 +++ b/include/linux/grdefs.h
68451 @@ -0,0 +1,140 @@
68452 +#ifndef GRDEFS_H
68453 +#define GRDEFS_H
68454 +
68455 +/* Begin grsecurity status declarations */
68456 +
68457 +enum {
68458 + GR_READY = 0x01,
68459 + GR_STATUS_INIT = 0x00 // disabled state
68460 +};
68461 +
68462 +/* Begin ACL declarations */
68463 +
68464 +/* Role flags */
68465 +
68466 +enum {
68467 + GR_ROLE_USER = 0x0001,
68468 + GR_ROLE_GROUP = 0x0002,
68469 + GR_ROLE_DEFAULT = 0x0004,
68470 + GR_ROLE_SPECIAL = 0x0008,
68471 + GR_ROLE_AUTH = 0x0010,
68472 + GR_ROLE_NOPW = 0x0020,
68473 + GR_ROLE_GOD = 0x0040,
68474 + GR_ROLE_LEARN = 0x0080,
68475 + GR_ROLE_TPE = 0x0100,
68476 + GR_ROLE_DOMAIN = 0x0200,
68477 + GR_ROLE_PAM = 0x0400,
68478 + GR_ROLE_PERSIST = 0x0800
68479 +};
68480 +
68481 +/* ACL Subject and Object mode flags */
68482 +enum {
68483 + GR_DELETED = 0x80000000
68484 +};
68485 +
68486 +/* ACL Object-only mode flags */
68487 +enum {
68488 + GR_READ = 0x00000001,
68489 + GR_APPEND = 0x00000002,
68490 + GR_WRITE = 0x00000004,
68491 + GR_EXEC = 0x00000008,
68492 + GR_FIND = 0x00000010,
68493 + GR_INHERIT = 0x00000020,
68494 + GR_SETID = 0x00000040,
68495 + GR_CREATE = 0x00000080,
68496 + GR_DELETE = 0x00000100,
68497 + GR_LINK = 0x00000200,
68498 + GR_AUDIT_READ = 0x00000400,
68499 + GR_AUDIT_APPEND = 0x00000800,
68500 + GR_AUDIT_WRITE = 0x00001000,
68501 + GR_AUDIT_EXEC = 0x00002000,
68502 + GR_AUDIT_FIND = 0x00004000,
68503 + GR_AUDIT_INHERIT= 0x00008000,
68504 + GR_AUDIT_SETID = 0x00010000,
68505 + GR_AUDIT_CREATE = 0x00020000,
68506 + GR_AUDIT_DELETE = 0x00040000,
68507 + GR_AUDIT_LINK = 0x00080000,
68508 + GR_PTRACERD = 0x00100000,
68509 + GR_NOPTRACE = 0x00200000,
68510 + GR_SUPPRESS = 0x00400000,
68511 + GR_NOLEARN = 0x00800000,
68512 + GR_INIT_TRANSFER= 0x01000000
68513 +};
68514 +
68515 +#define GR_AUDITS (GR_AUDIT_READ | GR_AUDIT_WRITE | GR_AUDIT_APPEND | GR_AUDIT_EXEC | \
68516 + GR_AUDIT_FIND | GR_AUDIT_INHERIT | GR_AUDIT_SETID | \
68517 + GR_AUDIT_CREATE | GR_AUDIT_DELETE | GR_AUDIT_LINK)
68518 +
68519 +/* ACL subject-only mode flags */
68520 +enum {
68521 + GR_KILL = 0x00000001,
68522 + GR_VIEW = 0x00000002,
68523 + GR_PROTECTED = 0x00000004,
68524 + GR_LEARN = 0x00000008,
68525 + GR_OVERRIDE = 0x00000010,
68526 + /* just a placeholder, this mode is only used in userspace */
68527 + GR_DUMMY = 0x00000020,
68528 + GR_PROTSHM = 0x00000040,
68529 + GR_KILLPROC = 0x00000080,
68530 + GR_KILLIPPROC = 0x00000100,
68531 + /* just a placeholder, this mode is only used in userspace */
68532 + GR_NOTROJAN = 0x00000200,
68533 + GR_PROTPROCFD = 0x00000400,
68534 + GR_PROCACCT = 0x00000800,
68535 + GR_RELAXPTRACE = 0x00001000,
68536 + //GR_NESTED = 0x00002000,
68537 + GR_INHERITLEARN = 0x00004000,
68538 + GR_PROCFIND = 0x00008000,
68539 + GR_POVERRIDE = 0x00010000,
68540 + GR_KERNELAUTH = 0x00020000,
68541 + GR_ATSECURE = 0x00040000,
68542 + GR_SHMEXEC = 0x00080000
68543 +};
68544 +
68545 +enum {
68546 + GR_PAX_ENABLE_SEGMEXEC = 0x0001,
68547 + GR_PAX_ENABLE_PAGEEXEC = 0x0002,
68548 + GR_PAX_ENABLE_MPROTECT = 0x0004,
68549 + GR_PAX_ENABLE_RANDMMAP = 0x0008,
68550 + GR_PAX_ENABLE_EMUTRAMP = 0x0010,
68551 + GR_PAX_DISABLE_SEGMEXEC = 0x0100,
68552 + GR_PAX_DISABLE_PAGEEXEC = 0x0200,
68553 + GR_PAX_DISABLE_MPROTECT = 0x0400,
68554 + GR_PAX_DISABLE_RANDMMAP = 0x0800,
68555 + GR_PAX_DISABLE_EMUTRAMP = 0x1000,
68556 +};
68557 +
68558 +enum {
68559 + GR_ID_USER = 0x01,
68560 + GR_ID_GROUP = 0x02,
68561 +};
68562 +
68563 +enum {
68564 + GR_ID_ALLOW = 0x01,
68565 + GR_ID_DENY = 0x02,
68566 +};
68567 +
68568 +#define GR_CRASH_RES 31
68569 +#define GR_UIDTABLE_MAX 500
68570 +
68571 +/* begin resource learning section */
68572 +enum {
68573 + GR_RLIM_CPU_BUMP = 60,
68574 + GR_RLIM_FSIZE_BUMP = 50000,
68575 + GR_RLIM_DATA_BUMP = 10000,
68576 + GR_RLIM_STACK_BUMP = 1000,
68577 + GR_RLIM_CORE_BUMP = 10000,
68578 + GR_RLIM_RSS_BUMP = 500000,
68579 + GR_RLIM_NPROC_BUMP = 1,
68580 + GR_RLIM_NOFILE_BUMP = 5,
68581 + GR_RLIM_MEMLOCK_BUMP = 50000,
68582 + GR_RLIM_AS_BUMP = 500000,
68583 + GR_RLIM_LOCKS_BUMP = 2,
68584 + GR_RLIM_SIGPENDING_BUMP = 5,
68585 + GR_RLIM_MSGQUEUE_BUMP = 10000,
68586 + GR_RLIM_NICE_BUMP = 1,
68587 + GR_RLIM_RTPRIO_BUMP = 1,
68588 + GR_RLIM_RTTIME_BUMP = 1000000
68589 +};
68590 +
68591 +#endif
68592 diff --git a/include/linux/grinternal.h b/include/linux/grinternal.h
68593 new file mode 100644
68594 index 0000000..5402bce
68595 --- /dev/null
68596 +++ b/include/linux/grinternal.h
68597 @@ -0,0 +1,215 @@
68598 +#ifndef __GRINTERNAL_H
68599 +#define __GRINTERNAL_H
68600 +
68601 +#ifdef CONFIG_GRKERNSEC
68602 +
68603 +#include <linux/fs.h>
68604 +#include <linux/mnt_namespace.h>
68605 +#include <linux/nsproxy.h>
68606 +#include <linux/gracl.h>
68607 +#include <linux/grdefs.h>
68608 +#include <linux/grmsg.h>
68609 +
68610 +void gr_add_learn_entry(const char *fmt, ...)
68611 + __attribute__ ((format (printf, 1, 2)));
68612 +__u32 gr_search_file(const struct dentry *dentry, const __u32 mode,
68613 + const struct vfsmount *mnt);
68614 +__u32 gr_check_create(const struct dentry *new_dentry,
68615 + const struct dentry *parent,
68616 + const struct vfsmount *mnt, const __u32 mode);
68617 +int gr_check_protected_task(const struct task_struct *task);
68618 +__u32 to_gr_audit(const __u32 reqmode);
68619 +int gr_set_acls(const int type);
68620 +int gr_apply_subject_to_task(struct task_struct *task);
68621 +int gr_acl_is_enabled(void);
68622 +char gr_roletype_to_char(void);
68623 +
68624 +void gr_handle_alertkill(struct task_struct *task);
68625 +char *gr_to_filename(const struct dentry *dentry,
68626 + const struct vfsmount *mnt);
68627 +char *gr_to_filename1(const struct dentry *dentry,
68628 + const struct vfsmount *mnt);
68629 +char *gr_to_filename2(const struct dentry *dentry,
68630 + const struct vfsmount *mnt);
68631 +char *gr_to_filename3(const struct dentry *dentry,
68632 + const struct vfsmount *mnt);
68633 +
68634 +extern int grsec_enable_ptrace_readexec;
68635 +extern int grsec_enable_harden_ptrace;
68636 +extern int grsec_enable_link;
68637 +extern int grsec_enable_fifo;
68638 +extern int grsec_enable_execve;
68639 +extern int grsec_enable_shm;
68640 +extern int grsec_enable_execlog;
68641 +extern int grsec_enable_signal;
68642 +extern int grsec_enable_audit_ptrace;
68643 +extern int grsec_enable_forkfail;
68644 +extern int grsec_enable_time;
68645 +extern int grsec_enable_rofs;
68646 +extern int grsec_enable_chroot_shmat;
68647 +extern int grsec_enable_chroot_mount;
68648 +extern int grsec_enable_chroot_double;
68649 +extern int grsec_enable_chroot_pivot;
68650 +extern int grsec_enable_chroot_chdir;
68651 +extern int grsec_enable_chroot_chmod;
68652 +extern int grsec_enable_chroot_mknod;
68653 +extern int grsec_enable_chroot_fchdir;
68654 +extern int grsec_enable_chroot_nice;
68655 +extern int grsec_enable_chroot_execlog;
68656 +extern int grsec_enable_chroot_caps;
68657 +extern int grsec_enable_chroot_sysctl;
68658 +extern int grsec_enable_chroot_unix;
68659 +extern int grsec_enable_symlinkown;
68660 +extern kgid_t grsec_symlinkown_gid;
68661 +extern int grsec_enable_tpe;
68662 +extern kgid_t grsec_tpe_gid;
68663 +extern int grsec_enable_tpe_all;
68664 +extern int grsec_enable_tpe_invert;
68665 +extern int grsec_enable_socket_all;
68666 +extern kgid_t grsec_socket_all_gid;
68667 +extern int grsec_enable_socket_client;
68668 +extern kgid_t grsec_socket_client_gid;
68669 +extern int grsec_enable_socket_server;
68670 +extern kgid_t grsec_socket_server_gid;
68671 +extern kgid_t grsec_audit_gid;
68672 +extern int grsec_enable_group;
68673 +extern int grsec_enable_audit_textrel;
68674 +extern int grsec_enable_log_rwxmaps;
68675 +extern int grsec_enable_mount;
68676 +extern int grsec_enable_chdir;
68677 +extern int grsec_resource_logging;
68678 +extern int grsec_enable_blackhole;
68679 +extern int grsec_lastack_retries;
68680 +extern int grsec_enable_brute;
68681 +extern int grsec_lock;
68682 +
68683 +extern spinlock_t grsec_alert_lock;
68684 +extern unsigned long grsec_alert_wtime;
68685 +extern unsigned long grsec_alert_fyet;
68686 +
68687 +extern spinlock_t grsec_audit_lock;
68688 +
68689 +extern rwlock_t grsec_exec_file_lock;
68690 +
68691 +#define gr_task_fullpath(tsk) ((tsk)->exec_file ? \
68692 + gr_to_filename2((tsk)->exec_file->f_path.dentry, \
68693 + (tsk)->exec_file->f_path.mnt) : "/")
68694 +
68695 +#define gr_parent_task_fullpath(tsk) ((tsk)->real_parent->exec_file ? \
68696 + gr_to_filename3((tsk)->real_parent->exec_file->f_path.dentry, \
68697 + (tsk)->real_parent->exec_file->f_path.mnt) : "/")
68698 +
68699 +#define gr_task_fullpath0(tsk) ((tsk)->exec_file ? \
68700 + gr_to_filename((tsk)->exec_file->f_path.dentry, \
68701 + (tsk)->exec_file->f_path.mnt) : "/")
68702 +
68703 +#define gr_parent_task_fullpath0(tsk) ((tsk)->real_parent->exec_file ? \
68704 + gr_to_filename1((tsk)->real_parent->exec_file->f_path.dentry, \
68705 + (tsk)->real_parent->exec_file->f_path.mnt) : "/")
68706 +
68707 +#define proc_is_chrooted(tsk_a) ((tsk_a)->gr_is_chrooted)
68708 +
68709 +#define have_same_root(tsk_a,tsk_b) ((tsk_a)->gr_chroot_dentry == (tsk_b)->gr_chroot_dentry)
68710 +
68711 +#define GR_CHROOT_CAPS {{ \
68712 + CAP_TO_MASK(CAP_LINUX_IMMUTABLE) | CAP_TO_MASK(CAP_NET_ADMIN) | \
68713 + CAP_TO_MASK(CAP_SYS_MODULE) | CAP_TO_MASK(CAP_SYS_RAWIO) | \
68714 + CAP_TO_MASK(CAP_SYS_PACCT) | CAP_TO_MASK(CAP_SYS_ADMIN) | \
68715 + CAP_TO_MASK(CAP_SYS_BOOT) | CAP_TO_MASK(CAP_SYS_TIME) | \
68716 + CAP_TO_MASK(CAP_NET_RAW) | CAP_TO_MASK(CAP_SYS_TTY_CONFIG) | \
68717 + CAP_TO_MASK(CAP_IPC_OWNER) | CAP_TO_MASK(CAP_SETFCAP), \
68718 + CAP_TO_MASK(CAP_SYSLOG) | CAP_TO_MASK(CAP_MAC_ADMIN) }}
68719 +
68720 +#define security_learn(normal_msg,args...) \
68721 +({ \
68722 + read_lock(&grsec_exec_file_lock); \
68723 + gr_add_learn_entry(normal_msg "\n", ## args); \
68724 + read_unlock(&grsec_exec_file_lock); \
68725 +})
68726 +
68727 +enum {
68728 + GR_DO_AUDIT,
68729 + GR_DONT_AUDIT,
68730 + /* used for non-audit messages that we shouldn't kill the task on */
68731 + GR_DONT_AUDIT_GOOD
68732 +};
68733 +
68734 +enum {
68735 + GR_TTYSNIFF,
68736 + GR_RBAC,
68737 + GR_RBAC_STR,
68738 + GR_STR_RBAC,
68739 + GR_RBAC_MODE2,
68740 + GR_RBAC_MODE3,
68741 + GR_FILENAME,
68742 + GR_SYSCTL_HIDDEN,
68743 + GR_NOARGS,
68744 + GR_ONE_INT,
68745 + GR_ONE_INT_TWO_STR,
68746 + GR_ONE_STR,
68747 + GR_STR_INT,
68748 + GR_TWO_STR_INT,
68749 + GR_TWO_INT,
68750 + GR_TWO_U64,
68751 + GR_THREE_INT,
68752 + GR_FIVE_INT_TWO_STR,
68753 + GR_TWO_STR,
68754 + GR_THREE_STR,
68755 + GR_FOUR_STR,
68756 + GR_STR_FILENAME,
68757 + GR_FILENAME_STR,
68758 + GR_FILENAME_TWO_INT,
68759 + GR_FILENAME_TWO_INT_STR,
68760 + GR_TEXTREL,
68761 + GR_PTRACE,
68762 + GR_RESOURCE,
68763 + GR_CAP,
68764 + GR_SIG,
68765 + GR_SIG2,
68766 + GR_CRASH1,
68767 + GR_CRASH2,
68768 + GR_PSACCT,
68769 + GR_RWXMAP
68770 +};
68771 +
68772 +#define gr_log_hidden_sysctl(audit, msg, str) gr_log_varargs(audit, msg, GR_SYSCTL_HIDDEN, str)
68773 +#define gr_log_ttysniff(audit, msg, task) gr_log_varargs(audit, msg, GR_TTYSNIFF, task)
68774 +#define gr_log_fs_rbac_generic(audit, msg, dentry, mnt) gr_log_varargs(audit, msg, GR_RBAC, dentry, mnt)
68775 +#define gr_log_fs_rbac_str(audit, msg, dentry, mnt, str) gr_log_varargs(audit, msg, GR_RBAC_STR, dentry, mnt, str)
68776 +#define gr_log_fs_str_rbac(audit, msg, str, dentry, mnt) gr_log_varargs(audit, msg, GR_STR_RBAC, str, dentry, mnt)
68777 +#define gr_log_fs_rbac_mode2(audit, msg, dentry, mnt, str1, str2) gr_log_varargs(audit, msg, GR_RBAC_MODE2, dentry, mnt, str1, str2)
68778 +#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)
68779 +#define gr_log_fs_generic(audit, msg, dentry, mnt) gr_log_varargs(audit, msg, GR_FILENAME, dentry, mnt)
68780 +#define gr_log_noargs(audit, msg) gr_log_varargs(audit, msg, GR_NOARGS)
68781 +#define gr_log_int(audit, msg, num) gr_log_varargs(audit, msg, GR_ONE_INT, num)
68782 +#define gr_log_int_str2(audit, msg, num, str1, str2) gr_log_varargs(audit, msg, GR_ONE_INT_TWO_STR, num, str1, str2)
68783 +#define gr_log_str(audit, msg, str) gr_log_varargs(audit, msg, GR_ONE_STR, str)
68784 +#define gr_log_str_int(audit, msg, str, num) gr_log_varargs(audit, msg, GR_STR_INT, str, num)
68785 +#define gr_log_int_int(audit, msg, num1, num2) gr_log_varargs(audit, msg, GR_TWO_INT, num1, num2)
68786 +#define gr_log_two_u64(audit, msg, num1, num2) gr_log_varargs(audit, msg, GR_TWO_U64, num1, num2)
68787 +#define gr_log_int3(audit, msg, num1, num2, num3) gr_log_varargs(audit, msg, GR_THREE_INT, num1, num2, num3)
68788 +#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)
68789 +#define gr_log_str_str(audit, msg, str1, str2) gr_log_varargs(audit, msg, GR_TWO_STR, str1, str2)
68790 +#define gr_log_str2_int(audit, msg, str1, str2, num) gr_log_varargs(audit, msg, GR_TWO_STR_INT, str1, str2, num)
68791 +#define gr_log_str3(audit, msg, str1, str2, str3) gr_log_varargs(audit, msg, GR_THREE_STR, str1, str2, str3)
68792 +#define gr_log_str4(audit, msg, str1, str2, str3, str4) gr_log_varargs(audit, msg, GR_FOUR_STR, str1, str2, str3, str4)
68793 +#define gr_log_str_fs(audit, msg, str, dentry, mnt) gr_log_varargs(audit, msg, GR_STR_FILENAME, str, dentry, mnt)
68794 +#define gr_log_fs_str(audit, msg, dentry, mnt, str) gr_log_varargs(audit, msg, GR_FILENAME_STR, dentry, mnt, str)
68795 +#define gr_log_fs_int2(audit, msg, dentry, mnt, num1, num2) gr_log_varargs(audit, msg, GR_FILENAME_TWO_INT, dentry, mnt, num1, num2)
68796 +#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)
68797 +#define gr_log_textrel_ulong_ulong(audit, msg, file, ulong1, ulong2) gr_log_varargs(audit, msg, GR_TEXTREL, file, ulong1, ulong2)
68798 +#define gr_log_ptrace(audit, msg, task) gr_log_varargs(audit, msg, GR_PTRACE, task)
68799 +#define gr_log_res_ulong2_str(audit, msg, task, ulong1, str, ulong2) gr_log_varargs(audit, msg, GR_RESOURCE, task, ulong1, str, ulong2)
68800 +#define gr_log_cap(audit, msg, task, str) gr_log_varargs(audit, msg, GR_CAP, task, str)
68801 +#define gr_log_sig_addr(audit, msg, str, addr) gr_log_varargs(audit, msg, GR_SIG, str, addr)
68802 +#define gr_log_sig_task(audit, msg, task, num) gr_log_varargs(audit, msg, GR_SIG2, task, num)
68803 +#define gr_log_crash1(audit, msg, task, ulong) gr_log_varargs(audit, msg, GR_CRASH1, task, ulong)
68804 +#define gr_log_crash2(audit, msg, task, ulong1) gr_log_varargs(audit, msg, GR_CRASH2, task, ulong1)
68805 +#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)
68806 +#define gr_log_rwxmap(audit, msg, str) gr_log_varargs(audit, msg, GR_RWXMAP, str)
68807 +
68808 +void gr_log_varargs(int audit, const char *msg, int argtypes, ...);
68809 +
68810 +#endif
68811 +
68812 +#endif
68813 diff --git a/include/linux/grmsg.h b/include/linux/grmsg.h
68814 new file mode 100644
68815 index 0000000..2bd4c8d
68816 --- /dev/null
68817 +++ b/include/linux/grmsg.h
68818 @@ -0,0 +1,111 @@
68819 +#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"
68820 +#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"
68821 +#define GR_PTRACE_ACL_MSG "denied ptrace of %.950s(%.16s:%d) by "
68822 +#define GR_STOPMOD_MSG "denied modification of module state by "
68823 +#define GR_ROFS_BLOCKWRITE_MSG "denied write to block device %.950s by "
68824 +#define GR_ROFS_MOUNT_MSG "denied writable mount of %.950s by "
68825 +#define GR_IOPERM_MSG "denied use of ioperm() by "
68826 +#define GR_IOPL_MSG "denied use of iopl() by "
68827 +#define GR_SHMAT_ACL_MSG "denied attach of shared memory of UID %u, PID %d, ID %u by "
68828 +#define GR_UNIX_CHROOT_MSG "denied connect() to abstract AF_UNIX socket outside of chroot by "
68829 +#define GR_SHMAT_CHROOT_MSG "denied attach of shared memory outside of chroot by "
68830 +#define GR_MEM_READWRITE_MSG "denied access of range %Lx -> %Lx in /dev/mem by "
68831 +#define GR_SYMLINK_MSG "not following symlink %.950s owned by %d.%d by "
68832 +#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"
68833 +#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"
68834 +#define GR_HIDDEN_ACL_MSG "%s access to hidden file %.950s by "
68835 +#define GR_OPEN_ACL_MSG "%s open of %.950s for%s%s by "
68836 +#define GR_CREATE_ACL_MSG "%s create of %.950s for%s%s by "
68837 +#define GR_FIFO_MSG "denied writing FIFO %.950s of %d.%d by "
68838 +#define GR_MKNOD_CHROOT_MSG "denied mknod of %.950s from chroot by "
68839 +#define GR_MKNOD_ACL_MSG "%s mknod of %.950s by "
68840 +#define GR_UNIXCONNECT_ACL_MSG "%s connect() to the unix domain socket %.950s by "
68841 +#define GR_TTYSNIFF_ACL_MSG "terminal being sniffed by IP:%pI4 %.480s[%.16s:%d], parent %.480s[%.16s:%d] against "
68842 +#define GR_MKDIR_ACL_MSG "%s mkdir of %.950s by "
68843 +#define GR_RMDIR_ACL_MSG "%s rmdir of %.950s by "
68844 +#define GR_UNLINK_ACL_MSG "%s unlink of %.950s by "
68845 +#define GR_SYMLINK_ACL_MSG "%s symlink from %.480s to %.480s by "
68846 +#define GR_HARDLINK_MSG "denied hardlink of %.930s (owned by %d.%d) to %.30s for "
68847 +#define GR_LINK_ACL_MSG "%s link of %.480s to %.480s by "
68848 +#define GR_INHERIT_ACL_MSG "successful inherit of %.480s's ACL for %.480s by "
68849 +#define GR_RENAME_ACL_MSG "%s rename of %.480s to %.480s by "
68850 +#define GR_UNSAFESHARE_EXEC_ACL_MSG "denied exec with cloned fs of %.950s by "
68851 +#define GR_PTRACE_EXEC_ACL_MSG "denied ptrace of %.950s by "
68852 +#define GR_EXEC_ACL_MSG "%s execution of %.950s by "
68853 +#define GR_EXEC_TPE_MSG "denied untrusted exec (due to %.70s) of %.950s by "
68854 +#define GR_SEGVSTART_ACL_MSG "possible exploit bruteforcing on " DEFAULTSECMSG " banning uid %u from login for %lu seconds"
68855 +#define GR_SEGVNOSUID_ACL_MSG "possible exploit bruteforcing on " DEFAULTSECMSG " banning execution for %lu seconds"
68856 +#define GR_MOUNT_CHROOT_MSG "denied mount of %.256s as %.930s from chroot by "
68857 +#define GR_PIVOT_CHROOT_MSG "denied pivot_root from chroot by "
68858 +#define GR_TRUNCATE_ACL_MSG "%s truncate of %.950s by "
68859 +#define GR_ATIME_ACL_MSG "%s access time change of %.950s by "
68860 +#define GR_ACCESS_ACL_MSG "%s access of %.950s for%s%s%s by "
68861 +#define GR_CHROOT_CHROOT_MSG "denied double chroot to %.950s by "
68862 +#define GR_CHMOD_CHROOT_MSG "denied chmod +s of %.950s by "
68863 +#define GR_CHMOD_ACL_MSG "%s chmod of %.950s by "
68864 +#define GR_CHROOT_FCHDIR_MSG "denied fchdir outside of chroot to %.950s by "
68865 +#define GR_CHOWN_ACL_MSG "%s chown of %.950s by "
68866 +#define GR_SETXATTR_ACL_MSG "%s setting extended attributes of %.950s by "
68867 +#define GR_WRITLIB_ACL_MSG "denied load of writable library %.950s by "
68868 +#define GR_INITF_ACL_MSG "init_variables() failed %s by "
68869 +#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"
68870 +#define GR_DEV_ACL_MSG "/dev/grsec: %d bytes sent %d required, being fed garbage by "
68871 +#define GR_SHUTS_ACL_MSG "shutdown auth success for "
68872 +#define GR_SHUTF_ACL_MSG "shutdown auth failure for "
68873 +#define GR_SHUTI_ACL_MSG "ignoring shutdown for disabled RBAC system for "
68874 +#define GR_SEGVMODS_ACL_MSG "segvmod auth success for "
68875 +#define GR_SEGVMODF_ACL_MSG "segvmod auth failure for "
68876 +#define GR_SEGVMODI_ACL_MSG "ignoring segvmod for disabled RBAC system for "
68877 +#define GR_ENABLE_ACL_MSG "%s RBAC system loaded by "
68878 +#define GR_ENABLEF_ACL_MSG "unable to load %s for "
68879 +#define GR_RELOADI_ACL_MSG "ignoring reload request for disabled RBAC system"
68880 +#define GR_RELOAD_ACL_MSG "%s RBAC system reloaded by "
68881 +#define GR_RELOADF_ACL_MSG "failed reload of %s for "
68882 +#define GR_SPROLEI_ACL_MSG "ignoring change to special role for disabled RBAC system for "
68883 +#define GR_SPROLES_ACL_MSG "successful change to special role %s (id %d) by "
68884 +#define GR_SPROLEL_ACL_MSG "special role %s (id %d) exited by "
68885 +#define GR_SPROLEF_ACL_MSG "special role %s failure for "
68886 +#define GR_UNSPROLEI_ACL_MSG "ignoring unauth of special role for disabled RBAC system for "
68887 +#define GR_UNSPROLES_ACL_MSG "successful unauth of special role %s (id %d) by "
68888 +#define GR_INVMODE_ACL_MSG "invalid mode %d by "
68889 +#define GR_PRIORITY_CHROOT_MSG "denied priority change of process (%.16s:%d) by "
68890 +#define GR_FAILFORK_MSG "failed fork with errno %s by "
68891 +#define GR_NICE_CHROOT_MSG "denied priority change by "
68892 +#define GR_UNISIGLOG_MSG "%.32s occurred at %p in "
68893 +#define GR_DUALSIGLOG_MSG "signal %d sent to " DEFAULTSECMSG " by "
68894 +#define GR_SIG_ACL_MSG "denied send of signal %d to protected task " DEFAULTSECMSG " by "
68895 +#define GR_SYSCTL_MSG "denied modification of grsecurity sysctl value : %.32s by "
68896 +#define GR_SYSCTL_ACL_MSG "%s sysctl of %.950s for%s%s by "
68897 +#define GR_TIME_MSG "time set by "
68898 +#define GR_DEFACL_MSG "fatal: unable to find subject for (%.16s:%d), loaded by "
68899 +#define GR_MMAP_ACL_MSG "%s executable mmap of %.950s by "
68900 +#define GR_MPROTECT_ACL_MSG "%s executable mprotect of %.950s by "
68901 +#define GR_SOCK_MSG "denied socket(%.16s,%.16s,%.16s) by "
68902 +#define GR_SOCK_NOINET_MSG "denied socket(%.16s,%.16s,%d) by "
68903 +#define GR_BIND_MSG "denied bind() by "
68904 +#define GR_CONNECT_MSG "denied connect() by "
68905 +#define GR_BIND_ACL_MSG "denied bind() to %pI4 port %u sock type %.16s protocol %.16s by "
68906 +#define GR_CONNECT_ACL_MSG "denied connect() to %pI4 port %u sock type %.16s protocol %.16s by "
68907 +#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"
68908 +#define GR_EXEC_CHROOT_MSG "exec of %.980s within chroot by process "
68909 +#define GR_CAP_ACL_MSG "use of %s denied for "
68910 +#define GR_CAP_CHROOT_MSG "use of %s in chroot denied for "
68911 +#define GR_CAP_ACL_MSG2 "use of %s permitted for "
68912 +#define GR_USRCHANGE_ACL_MSG "change to uid %u denied for "
68913 +#define GR_GRPCHANGE_ACL_MSG "change to gid %u denied for "
68914 +#define GR_REMOUNT_AUDIT_MSG "remount of %.256s by "
68915 +#define GR_UNMOUNT_AUDIT_MSG "unmount of %.256s by "
68916 +#define GR_MOUNT_AUDIT_MSG "mount of %.256s to %.256s by "
68917 +#define GR_CHDIR_AUDIT_MSG "chdir to %.980s by "
68918 +#define GR_EXEC_AUDIT_MSG "exec of %.930s (%.128s) by "
68919 +#define GR_RESOURCE_MSG "denied resource overstep by requesting %lu for %.16s against limit %lu for "
68920 +#define GR_RWXMMAP_MSG "denied RWX mmap of %.950s by "
68921 +#define GR_RWXMPROTECT_MSG "denied RWX mprotect of %.950s by "
68922 +#define GR_TEXTREL_AUDIT_MSG "text relocation in %s, VMA:0x%08lx 0x%08lx by "
68923 +#define GR_VM86_MSG "denied use of vm86 by "
68924 +#define GR_PTRACE_AUDIT_MSG "process %.950s(%.16s:%d) attached to via ptrace by "
68925 +#define GR_PTRACE_READEXEC_MSG "denied ptrace of unreadable binary %.950s by "
68926 +#define GR_INIT_TRANSFER_MSG "persistent special role transferred privilege to init by "
68927 +#define GR_BADPROCPID_MSG "denied read of sensitive /proc/pid/%s entry via fd passed across exec by "
68928 +#define GR_SYMLINKOWNER_MSG "denied following symlink %.950s since symlink owner %u does not match target owner %u, by "
68929 +#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 "
68930 diff --git a/include/linux/grsecurity.h b/include/linux/grsecurity.h
68931 new file mode 100644
68932 index 0000000..d7ef0ac
68933 --- /dev/null
68934 +++ b/include/linux/grsecurity.h
68935 @@ -0,0 +1,242 @@
68936 +#ifndef GR_SECURITY_H
68937 +#define GR_SECURITY_H
68938 +#include <linux/fs.h>
68939 +#include <linux/fs_struct.h>
68940 +#include <linux/binfmts.h>
68941 +#include <linux/gracl.h>
68942 +
68943 +/* notify of brain-dead configs */
68944 +#if defined(CONFIG_GRKERNSEC_PROC_USER) && defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
68945 +#error "CONFIG_GRKERNSEC_PROC_USER and CONFIG_GRKERNSEC_PROC_USERGROUP cannot both be enabled."
68946 +#endif
68947 +#if defined(CONFIG_PAX_NOEXEC) && !defined(CONFIG_PAX_PAGEEXEC) && !defined(CONFIG_PAX_SEGMEXEC) && !defined(CONFIG_PAX_KERNEXEC)
68948 +#error "CONFIG_PAX_NOEXEC enabled, but PAGEEXEC, SEGMEXEC, and KERNEXEC are disabled."
68949 +#endif
68950 +#if defined(CONFIG_PAX_ASLR) && !defined(CONFIG_PAX_RANDKSTACK) && !defined(CONFIG_PAX_RANDUSTACK) && !defined(CONFIG_PAX_RANDMMAP)
68951 +#error "CONFIG_PAX_ASLR enabled, but RANDKSTACK, RANDUSTACK, and RANDMMAP are disabled."
68952 +#endif
68953 +#if defined(CONFIG_PAX) && !defined(CONFIG_PAX_NOEXEC) && !defined(CONFIG_PAX_ASLR)
68954 +#error "CONFIG_PAX enabled, but no PaX options are enabled."
68955 +#endif
68956 +
68957 +void gr_handle_brute_attach(unsigned long mm_flags);
68958 +void gr_handle_brute_check(void);
68959 +void gr_handle_kernel_exploit(void);
68960 +int gr_process_user_ban(void);
68961 +
68962 +char gr_roletype_to_char(void);
68963 +
68964 +int gr_acl_enable_at_secure(void);
68965 +
68966 +int gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs);
68967 +int gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs);
68968 +
68969 +void gr_del_task_from_ip_table(struct task_struct *p);
68970 +
68971 +int gr_pid_is_chrooted(struct task_struct *p);
68972 +int gr_handle_chroot_fowner(struct pid *pid, enum pid_type type);
68973 +int gr_handle_chroot_nice(void);
68974 +int gr_handle_chroot_sysctl(const int op);
68975 +int gr_handle_chroot_setpriority(struct task_struct *p,
68976 + const int niceval);
68977 +int gr_chroot_fchdir(struct dentry *u_dentry, struct vfsmount *u_mnt);
68978 +int gr_handle_chroot_chroot(const struct dentry *dentry,
68979 + const struct vfsmount *mnt);
68980 +void gr_handle_chroot_chdir(const struct path *path);
68981 +int gr_handle_chroot_chmod(const struct dentry *dentry,
68982 + const struct vfsmount *mnt, const int mode);
68983 +int gr_handle_chroot_mknod(const struct dentry *dentry,
68984 + const struct vfsmount *mnt, const int mode);
68985 +int gr_handle_chroot_mount(const struct dentry *dentry,
68986 + const struct vfsmount *mnt,
68987 + const char *dev_name);
68988 +int gr_handle_chroot_pivot(void);
68989 +int gr_handle_chroot_unix(const pid_t pid);
68990 +
68991 +int gr_handle_rawio(const struct inode *inode);
68992 +
68993 +void gr_handle_ioperm(void);
68994 +void gr_handle_iopl(void);
68995 +
68996 +umode_t gr_acl_umask(void);
68997 +
68998 +int gr_tpe_allow(const struct file *file);
68999 +
69000 +void gr_set_chroot_entries(struct task_struct *task, const struct path *path);
69001 +void gr_clear_chroot_entries(struct task_struct *task);
69002 +
69003 +void gr_log_forkfail(const int retval);
69004 +void gr_log_timechange(void);
69005 +void gr_log_signal(const int sig, const void *addr, const struct task_struct *t);
69006 +void gr_log_chdir(const struct dentry *dentry,
69007 + const struct vfsmount *mnt);
69008 +void gr_log_chroot_exec(const struct dentry *dentry,
69009 + const struct vfsmount *mnt);
69010 +void gr_log_remount(const char *devname, const int retval);
69011 +void gr_log_unmount(const char *devname, const int retval);
69012 +void gr_log_mount(const char *from, const char *to, const int retval);
69013 +void gr_log_textrel(struct vm_area_struct *vma);
69014 +void gr_log_rwxmmap(struct file *file);
69015 +void gr_log_rwxmprotect(struct file *file);
69016 +
69017 +int gr_handle_follow_link(const struct inode *parent,
69018 + const struct inode *inode,
69019 + const struct dentry *dentry,
69020 + const struct vfsmount *mnt);
69021 +int gr_handle_fifo(const struct dentry *dentry,
69022 + const struct vfsmount *mnt,
69023 + const struct dentry *dir, const int flag,
69024 + const int acc_mode);
69025 +int gr_handle_hardlink(const struct dentry *dentry,
69026 + const struct vfsmount *mnt,
69027 + struct inode *inode,
69028 + const int mode, const struct filename *to);
69029 +
69030 +int gr_is_capable(const int cap);
69031 +int gr_is_capable_nolog(const int cap);
69032 +int gr_task_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
69033 +int gr_task_is_capable_nolog(const struct task_struct *task, const int cap);
69034 +
69035 +void gr_copy_label(struct task_struct *tsk);
69036 +void gr_handle_crash(struct task_struct *task, const int sig);
69037 +int gr_handle_signal(const struct task_struct *p, const int sig);
69038 +int gr_check_crash_uid(const kuid_t uid);
69039 +int gr_check_protected_task(const struct task_struct *task);
69040 +int gr_check_protected_task_fowner(struct pid *pid, enum pid_type type);
69041 +int gr_acl_handle_mmap(const struct file *file,
69042 + const unsigned long prot);
69043 +int gr_acl_handle_mprotect(const struct file *file,
69044 + const unsigned long prot);
69045 +int gr_check_hidden_task(const struct task_struct *tsk);
69046 +__u32 gr_acl_handle_truncate(const struct dentry *dentry,
69047 + const struct vfsmount *mnt);
69048 +__u32 gr_acl_handle_utime(const struct dentry *dentry,
69049 + const struct vfsmount *mnt);
69050 +__u32 gr_acl_handle_access(const struct dentry *dentry,
69051 + const struct vfsmount *mnt, const int fmode);
69052 +__u32 gr_acl_handle_chmod(const struct dentry *dentry,
69053 + const struct vfsmount *mnt, umode_t *mode);
69054 +__u32 gr_acl_handle_chown(const struct dentry *dentry,
69055 + const struct vfsmount *mnt);
69056 +__u32 gr_acl_handle_setxattr(const struct dentry *dentry,
69057 + const struct vfsmount *mnt);
69058 +int gr_handle_ptrace(struct task_struct *task, const long request);
69059 +int gr_handle_proc_ptrace(struct task_struct *task);
69060 +__u32 gr_acl_handle_execve(const struct dentry *dentry,
69061 + const struct vfsmount *mnt);
69062 +int gr_check_crash_exec(const struct file *filp);
69063 +int gr_acl_is_enabled(void);
69064 +void gr_set_kernel_label(struct task_struct *task);
69065 +void gr_set_role_label(struct task_struct *task, const kuid_t uid,
69066 + const kgid_t gid);
69067 +int gr_set_proc_label(const struct dentry *dentry,
69068 + const struct vfsmount *mnt,
69069 + const int unsafe_flags);
69070 +__u32 gr_acl_handle_hidden_file(const struct dentry *dentry,
69071 + const struct vfsmount *mnt);
69072 +__u32 gr_acl_handle_open(const struct dentry *dentry,
69073 + const struct vfsmount *mnt, int acc_mode);
69074 +__u32 gr_acl_handle_creat(const struct dentry *dentry,
69075 + const struct dentry *p_dentry,
69076 + const struct vfsmount *p_mnt,
69077 + int open_flags, int acc_mode, const int imode);
69078 +void gr_handle_create(const struct dentry *dentry,
69079 + const struct vfsmount *mnt);
69080 +void gr_handle_proc_create(const struct dentry *dentry,
69081 + const struct inode *inode);
69082 +__u32 gr_acl_handle_mknod(const struct dentry *new_dentry,
69083 + const struct dentry *parent_dentry,
69084 + const struct vfsmount *parent_mnt,
69085 + const int mode);
69086 +__u32 gr_acl_handle_mkdir(const struct dentry *new_dentry,
69087 + const struct dentry *parent_dentry,
69088 + const struct vfsmount *parent_mnt);
69089 +__u32 gr_acl_handle_rmdir(const struct dentry *dentry,
69090 + const struct vfsmount *mnt);
69091 +void gr_handle_delete(const ino_t ino, const dev_t dev);
69092 +__u32 gr_acl_handle_unlink(const struct dentry *dentry,
69093 + const struct vfsmount *mnt);
69094 +__u32 gr_acl_handle_symlink(const struct dentry *new_dentry,
69095 + const struct dentry *parent_dentry,
69096 + const struct vfsmount *parent_mnt,
69097 + const struct filename *from);
69098 +__u32 gr_acl_handle_link(const struct dentry *new_dentry,
69099 + const struct dentry *parent_dentry,
69100 + const struct vfsmount *parent_mnt,
69101 + const struct dentry *old_dentry,
69102 + const struct vfsmount *old_mnt, const struct filename *to);
69103 +int gr_handle_symlink_owner(const struct path *link, const struct inode *target);
69104 +int gr_acl_handle_rename(struct dentry *new_dentry,
69105 + struct dentry *parent_dentry,
69106 + const struct vfsmount *parent_mnt,
69107 + struct dentry *old_dentry,
69108 + struct inode *old_parent_inode,
69109 + struct vfsmount *old_mnt, const struct filename *newname);
69110 +void gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
69111 + struct dentry *old_dentry,
69112 + struct dentry *new_dentry,
69113 + struct vfsmount *mnt, const __u8 replace);
69114 +__u32 gr_check_link(const struct dentry *new_dentry,
69115 + const struct dentry *parent_dentry,
69116 + const struct vfsmount *parent_mnt,
69117 + const struct dentry *old_dentry,
69118 + const struct vfsmount *old_mnt);
69119 +int gr_acl_handle_filldir(const struct file *file, const char *name,
69120 + const unsigned int namelen, const ino_t ino);
69121 +
69122 +__u32 gr_acl_handle_unix(const struct dentry *dentry,
69123 + const struct vfsmount *mnt);
69124 +void gr_acl_handle_exit(void);
69125 +void gr_acl_handle_psacct(struct task_struct *task, const long code);
69126 +int gr_acl_handle_procpidmem(const struct task_struct *task);
69127 +int gr_handle_rofs_mount(struct dentry *dentry, struct vfsmount *mnt, int mnt_flags);
69128 +int gr_handle_rofs_blockwrite(struct dentry *dentry, struct vfsmount *mnt, int acc_mode);
69129 +void gr_audit_ptrace(struct task_struct *task);
69130 +dev_t gr_get_dev_from_dentry(struct dentry *dentry);
69131 +void gr_put_exec_file(struct task_struct *task);
69132 +
69133 +int gr_ptrace_readexec(struct file *file, int unsafe_flags);
69134 +
69135 +#if defined(CONFIG_GRKERNSEC) && (defined(CONFIG_GRKERNSEC_RESLOG) || !defined(CONFIG_GRKERNSEC_NO_RBAC))
69136 +extern void gr_learn_resource(const struct task_struct *task, const int res,
69137 + const unsigned long wanted, const int gt);
69138 +#else
69139 +static inline void gr_learn_resource(const struct task_struct *task, const int res,
69140 + const unsigned long wanted, const int gt)
69141 +{
69142 +}
69143 +#endif
69144 +
69145 +#ifdef CONFIG_GRKERNSEC_RESLOG
69146 +extern void gr_log_resource(const struct task_struct *task, const int res,
69147 + const unsigned long wanted, const int gt);
69148 +#else
69149 +static inline void gr_log_resource(const struct task_struct *task, const int res,
69150 + const unsigned long wanted, const int gt)
69151 +{
69152 +}
69153 +#endif
69154 +
69155 +#ifdef CONFIG_GRKERNSEC
69156 +void task_grsec_rbac(struct seq_file *m, struct task_struct *p);
69157 +void gr_handle_vm86(void);
69158 +void gr_handle_mem_readwrite(u64 from, u64 to);
69159 +
69160 +void gr_log_badprocpid(const char *entry);
69161 +
69162 +extern int grsec_enable_dmesg;
69163 +extern int grsec_disable_privio;
69164 +
69165 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
69166 +extern kgid_t grsec_proc_gid;
69167 +#endif
69168 +
69169 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
69170 +extern int grsec_enable_chroot_findtask;
69171 +#endif
69172 +#ifdef CONFIG_GRKERNSEC_SETXID
69173 +extern int grsec_enable_setxid;
69174 +#endif
69175 +#endif
69176 +
69177 +#endif
69178 diff --git a/include/linux/grsock.h b/include/linux/grsock.h
69179 new file mode 100644
69180 index 0000000..e7ffaaf
69181 --- /dev/null
69182 +++ b/include/linux/grsock.h
69183 @@ -0,0 +1,19 @@
69184 +#ifndef __GRSOCK_H
69185 +#define __GRSOCK_H
69186 +
69187 +extern void gr_attach_curr_ip(const struct sock *sk);
69188 +extern int gr_handle_sock_all(const int family, const int type,
69189 + const int protocol);
69190 +extern int gr_handle_sock_server(const struct sockaddr *sck);
69191 +extern int gr_handle_sock_server_other(const struct sock *sck);
69192 +extern int gr_handle_sock_client(const struct sockaddr *sck);
69193 +extern int gr_search_connect(struct socket * sock,
69194 + struct sockaddr_in * addr);
69195 +extern int gr_search_bind(struct socket * sock,
69196 + struct sockaddr_in * addr);
69197 +extern int gr_search_listen(struct socket * sock);
69198 +extern int gr_search_accept(struct socket * sock);
69199 +extern int gr_search_socket(const int domain, const int type,
69200 + const int protocol);
69201 +
69202 +#endif
69203 diff --git a/include/linux/highmem.h b/include/linux/highmem.h
69204 index 7fb31da..08b5114 100644
69205 --- a/include/linux/highmem.h
69206 +++ b/include/linux/highmem.h
69207 @@ -189,6 +189,18 @@ static inline void clear_highpage(struct page *page)
69208 kunmap_atomic(kaddr);
69209 }
69210
69211 +static inline void sanitize_highpage(struct page *page)
69212 +{
69213 + void *kaddr;
69214 + unsigned long flags;
69215 +
69216 + local_irq_save(flags);
69217 + kaddr = kmap_atomic(page);
69218 + clear_page(kaddr);
69219 + kunmap_atomic(kaddr);
69220 + local_irq_restore(flags);
69221 +}
69222 +
69223 static inline void zero_user_segments(struct page *page,
69224 unsigned start1, unsigned end1,
69225 unsigned start2, unsigned end2)
69226 diff --git a/include/linux/hwmon-sysfs.h b/include/linux/hwmon-sysfs.h
69227 index 1c7b89a..7f52502 100644
69228 --- a/include/linux/hwmon-sysfs.h
69229 +++ b/include/linux/hwmon-sysfs.h
69230 @@ -25,7 +25,8 @@
69231 struct sensor_device_attribute{
69232 struct device_attribute dev_attr;
69233 int index;
69234 -};
69235 +} __do_const;
69236 +typedef struct sensor_device_attribute __no_const sensor_device_attribute_no_const;
69237 #define to_sensor_dev_attr(_dev_attr) \
69238 container_of(_dev_attr, struct sensor_device_attribute, dev_attr)
69239
69240 @@ -41,7 +42,7 @@ struct sensor_device_attribute_2 {
69241 struct device_attribute dev_attr;
69242 u8 index;
69243 u8 nr;
69244 -};
69245 +} __do_const;
69246 #define to_sensor_dev_attr_2(_dev_attr) \
69247 container_of(_dev_attr, struct sensor_device_attribute_2, dev_attr)
69248
69249 diff --git a/include/linux/i2c.h b/include/linux/i2c.h
69250 index d0c4db7..61b3577 100644
69251 --- a/include/linux/i2c.h
69252 +++ b/include/linux/i2c.h
69253 @@ -369,6 +369,7 @@ struct i2c_algorithm {
69254 /* To determine what the adapter supports */
69255 u32 (*functionality) (struct i2c_adapter *);
69256 };
69257 +typedef struct i2c_algorithm __no_const i2c_algorithm_no_const;
69258
69259 /*
69260 * i2c_adapter is the structure used to identify a physical i2c bus along
69261 diff --git a/include/linux/i2o.h b/include/linux/i2o.h
69262 index d23c3c2..eb63c81 100644
69263 --- a/include/linux/i2o.h
69264 +++ b/include/linux/i2o.h
69265 @@ -565,7 +565,7 @@ struct i2o_controller {
69266 struct i2o_device *exec; /* Executive */
69267 #if BITS_PER_LONG == 64
69268 spinlock_t context_list_lock; /* lock for context_list */
69269 - atomic_t context_list_counter; /* needed for unique contexts */
69270 + atomic_unchecked_t context_list_counter; /* needed for unique contexts */
69271 struct list_head context_list; /* list of context id's
69272 and pointers */
69273 #endif
69274 diff --git a/include/linux/if_pppox.h b/include/linux/if_pppox.h
69275 index aff7ad8..3942bbd 100644
69276 --- a/include/linux/if_pppox.h
69277 +++ b/include/linux/if_pppox.h
69278 @@ -76,7 +76,7 @@ struct pppox_proto {
69279 int (*ioctl)(struct socket *sock, unsigned int cmd,
69280 unsigned long arg);
69281 struct module *owner;
69282 -};
69283 +} __do_const;
69284
69285 extern int register_pppox_proto(int proto_num, const struct pppox_proto *pp);
69286 extern void unregister_pppox_proto(int proto_num);
69287 diff --git a/include/linux/init.h b/include/linux/init.h
69288 index 8618147..0821126 100644
69289 --- a/include/linux/init.h
69290 +++ b/include/linux/init.h
69291 @@ -39,9 +39,36 @@
69292 * Also note, that this data cannot be "const".
69293 */
69294
69295 +#ifdef MODULE
69296 +#define add_init_latent_entropy
69297 +#define add_devinit_latent_entropy
69298 +#define add_cpuinit_latent_entropy
69299 +#define add_meminit_latent_entropy
69300 +#else
69301 +#define add_init_latent_entropy __latent_entropy
69302 +
69303 +#ifdef CONFIG_HOTPLUG
69304 +#define add_devinit_latent_entropy
69305 +#else
69306 +#define add_devinit_latent_entropy __latent_entropy
69307 +#endif
69308 +
69309 +#ifdef CONFIG_HOTPLUG_CPU
69310 +#define add_cpuinit_latent_entropy
69311 +#else
69312 +#define add_cpuinit_latent_entropy __latent_entropy
69313 +#endif
69314 +
69315 +#ifdef CONFIG_MEMORY_HOTPLUG
69316 +#define add_meminit_latent_entropy
69317 +#else
69318 +#define add_meminit_latent_entropy __latent_entropy
69319 +#endif
69320 +#endif
69321 +
69322 /* These are for everybody (although not all archs will actually
69323 discard it in modules) */
69324 -#define __init __section(.init.text) __cold notrace
69325 +#define __init __section(.init.text) __cold notrace add_init_latent_entropy
69326 #define __initdata __section(.init.data)
69327 #define __initconst __constsection(.init.rodata)
69328 #define __exitdata __section(.exit.data)
69329 @@ -94,7 +121,7 @@
69330 #define __exit __section(.exit.text) __exitused __cold notrace
69331
69332 /* Used for HOTPLUG_CPU */
69333 -#define __cpuinit __section(.cpuinit.text) __cold notrace
69334 +#define __cpuinit __section(.cpuinit.text) __cold notrace add_cpuinit_latent_entropy
69335 #define __cpuinitdata __section(.cpuinit.data)
69336 #define __cpuinitconst __constsection(.cpuinit.rodata)
69337 #define __cpuexit __section(.cpuexit.text) __exitused __cold notrace
69338 @@ -102,7 +129,7 @@
69339 #define __cpuexitconst __constsection(.cpuexit.rodata)
69340
69341 /* Used for MEMORY_HOTPLUG */
69342 -#define __meminit __section(.meminit.text) __cold notrace
69343 +#define __meminit __section(.meminit.text) __cold notrace add_meminit_latent_entropy
69344 #define __meminitdata __section(.meminit.data)
69345 #define __meminitconst __constsection(.meminit.rodata)
69346 #define __memexit __section(.memexit.text) __exitused __cold notrace
69347 diff --git a/include/linux/init_task.h b/include/linux/init_task.h
69348 index 5cd0f09..c9f67cc 100644
69349 --- a/include/linux/init_task.h
69350 +++ b/include/linux/init_task.h
69351 @@ -154,6 +154,12 @@ extern struct task_group root_task_group;
69352
69353 #define INIT_TASK_COMM "swapper"
69354
69355 +#ifdef CONFIG_X86
69356 +#define INIT_TASK_THREAD_INFO .tinfo = INIT_THREAD_INFO,
69357 +#else
69358 +#define INIT_TASK_THREAD_INFO
69359 +#endif
69360 +
69361 /*
69362 * INIT_TASK is used to set up the first task table, touch at
69363 * your own risk!. Base=0, limit=0x1fffff (=2MB)
69364 @@ -193,6 +199,7 @@ extern struct task_group root_task_group;
69365 RCU_POINTER_INITIALIZER(cred, &init_cred), \
69366 .comm = INIT_TASK_COMM, \
69367 .thread = INIT_THREAD, \
69368 + INIT_TASK_THREAD_INFO \
69369 .fs = &init_fs, \
69370 .files = &init_files, \
69371 .signal = &init_signals, \
69372 diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
69373 index 5fa5afe..ac55b25 100644
69374 --- a/include/linux/interrupt.h
69375 +++ b/include/linux/interrupt.h
69376 @@ -430,7 +430,7 @@ enum
69377 /* map softirq index to softirq name. update 'softirq_to_name' in
69378 * kernel/softirq.c when adding a new softirq.
69379 */
69380 -extern char *softirq_to_name[NR_SOFTIRQS];
69381 +extern const char * const softirq_to_name[NR_SOFTIRQS];
69382
69383 /* softirq mask and active fields moved to irq_cpustat_t in
69384 * asm/hardirq.h to get better cache usage. KAO
69385 @@ -438,12 +438,12 @@ extern char *softirq_to_name[NR_SOFTIRQS];
69386
69387 struct softirq_action
69388 {
69389 - void (*action)(struct softirq_action *);
69390 -};
69391 + void (*action)(void);
69392 +} __no_const;
69393
69394 asmlinkage void do_softirq(void);
69395 asmlinkage void __do_softirq(void);
69396 -extern void open_softirq(int nr, void (*action)(struct softirq_action *));
69397 +extern void open_softirq(int nr, void (*action)(void));
69398 extern void softirq_init(void);
69399 extern void __raise_softirq_irqoff(unsigned int nr);
69400
69401 diff --git a/include/linux/iommu.h b/include/linux/iommu.h
69402 index ba3b8a9..7e14ed8 100644
69403 --- a/include/linux/iommu.h
69404 +++ b/include/linux/iommu.h
69405 @@ -113,7 +113,7 @@ struct iommu_ops {
69406 u32 (*domain_get_windows)(struct iommu_domain *domain);
69407
69408 unsigned long pgsize_bitmap;
69409 -};
69410 +} __do_const;
69411
69412 #define IOMMU_GROUP_NOTIFY_ADD_DEVICE 1 /* Device added */
69413 #define IOMMU_GROUP_NOTIFY_DEL_DEVICE 2 /* Pre Device removed */
69414 diff --git a/include/linux/ioport.h b/include/linux/ioport.h
69415 index 85ac9b9b..e5759ab 100644
69416 --- a/include/linux/ioport.h
69417 +++ b/include/linux/ioport.h
69418 @@ -161,7 +161,7 @@ struct resource *lookup_resource(struct resource *root, resource_size_t start);
69419 int adjust_resource(struct resource *res, resource_size_t start,
69420 resource_size_t size);
69421 resource_size_t resource_alignment(struct resource *res);
69422 -static inline resource_size_t resource_size(const struct resource *res)
69423 +static inline resource_size_t __intentional_overflow(-1) resource_size(const struct resource *res)
69424 {
69425 return res->end - res->start + 1;
69426 }
69427 diff --git a/include/linux/irq.h b/include/linux/irq.h
69428 index bc4e066..50468a9 100644
69429 --- a/include/linux/irq.h
69430 +++ b/include/linux/irq.h
69431 @@ -328,7 +328,8 @@ struct irq_chip {
69432 void (*irq_print_chip)(struct irq_data *data, struct seq_file *p);
69433
69434 unsigned long flags;
69435 -};
69436 +} __do_const;
69437 +typedef struct irq_chip __no_const irq_chip_no_const;
69438
69439 /*
69440 * irq_chip specific flags
69441 diff --git a/include/linux/irqchip/arm-gic.h b/include/linux/irqchip/arm-gic.h
69442 index 3fd8e42..a73e966 100644
69443 --- a/include/linux/irqchip/arm-gic.h
69444 +++ b/include/linux/irqchip/arm-gic.h
69445 @@ -59,9 +59,11 @@
69446
69447 #ifndef __ASSEMBLY__
69448
69449 +#include <linux/irq.h>
69450 +
69451 struct device_node;
69452
69453 -extern struct irq_chip gic_arch_extn;
69454 +extern irq_chip_no_const gic_arch_extn;
69455
69456 void gic_init_bases(unsigned int, int, void __iomem *, void __iomem *,
69457 u32 offset, struct device_node *);
69458 diff --git a/include/linux/kallsyms.h b/include/linux/kallsyms.h
69459 index 6883e19..06992b1 100644
69460 --- a/include/linux/kallsyms.h
69461 +++ b/include/linux/kallsyms.h
69462 @@ -15,7 +15,8 @@
69463
69464 struct module;
69465
69466 -#ifdef CONFIG_KALLSYMS
69467 +#if !defined(__INCLUDED_BY_HIDESYM) || !defined(CONFIG_KALLSYMS)
69468 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
69469 /* Lookup the address for a symbol. Returns 0 if not found. */
69470 unsigned long kallsyms_lookup_name(const char *name);
69471
69472 @@ -106,6 +107,17 @@ static inline int lookup_symbol_attrs(unsigned long addr, unsigned long *size, u
69473 /* Stupid that this does nothing, but I didn't create this mess. */
69474 #define __print_symbol(fmt, addr)
69475 #endif /*CONFIG_KALLSYMS*/
69476 +#else /* when included by kallsyms.c, vsnprintf.c, or
69477 + arch/x86/kernel/dumpstack.c, with HIDESYM enabled */
69478 +extern void __print_symbol(const char *fmt, unsigned long address);
69479 +extern int sprint_backtrace(char *buffer, unsigned long address);
69480 +extern int sprint_symbol(char *buffer, unsigned long address);
69481 +extern int sprint_symbol_no_offset(char *buffer, unsigned long address);
69482 +const char *kallsyms_lookup(unsigned long addr,
69483 + unsigned long *symbolsize,
69484 + unsigned long *offset,
69485 + char **modname, char *namebuf);
69486 +#endif
69487
69488 /* This macro allows us to keep printk typechecking */
69489 static __printf(1, 2)
69490 diff --git a/include/linux/key-type.h b/include/linux/key-type.h
69491 index 518a53a..5e28358 100644
69492 --- a/include/linux/key-type.h
69493 +++ b/include/linux/key-type.h
69494 @@ -125,7 +125,7 @@ struct key_type {
69495 /* internal fields */
69496 struct list_head link; /* link in types list */
69497 struct lock_class_key lock_class; /* key->sem lock class */
69498 -};
69499 +} __do_const;
69500
69501 extern struct key_type key_type_keyring;
69502
69503 diff --git a/include/linux/kgdb.h b/include/linux/kgdb.h
69504 index c6e091b..a940adf 100644
69505 --- a/include/linux/kgdb.h
69506 +++ b/include/linux/kgdb.h
69507 @@ -52,7 +52,7 @@ extern int kgdb_connected;
69508 extern int kgdb_io_module_registered;
69509
69510 extern atomic_t kgdb_setting_breakpoint;
69511 -extern atomic_t kgdb_cpu_doing_single_step;
69512 +extern atomic_unchecked_t kgdb_cpu_doing_single_step;
69513
69514 extern struct task_struct *kgdb_usethread;
69515 extern struct task_struct *kgdb_contthread;
69516 @@ -254,7 +254,7 @@ struct kgdb_arch {
69517 void (*correct_hw_break)(void);
69518
69519 void (*enable_nmi)(bool on);
69520 -};
69521 +} __do_const;
69522
69523 /**
69524 * struct kgdb_io - Describe the interface for an I/O driver to talk with KGDB.
69525 @@ -279,7 +279,7 @@ struct kgdb_io {
69526 void (*pre_exception) (void);
69527 void (*post_exception) (void);
69528 int is_console;
69529 -};
69530 +} __do_const;
69531
69532 extern struct kgdb_arch arch_kgdb_ops;
69533
69534 diff --git a/include/linux/kmod.h b/include/linux/kmod.h
69535 index 5398d58..5883a34 100644
69536 --- a/include/linux/kmod.h
69537 +++ b/include/linux/kmod.h
69538 @@ -34,6 +34,8 @@ extern char modprobe_path[]; /* for sysctl */
69539 * usually useless though. */
69540 extern __printf(2, 3)
69541 int __request_module(bool wait, const char *name, ...);
69542 +extern __printf(3, 4)
69543 +int ___request_module(bool wait, char *param_name, const char *name, ...);
69544 #define request_module(mod...) __request_module(true, mod)
69545 #define request_module_nowait(mod...) __request_module(false, mod)
69546 #define try_then_request_module(x, mod...) \
69547 diff --git a/include/linux/kobject.h b/include/linux/kobject.h
69548 index 939b112..ed6ed51 100644
69549 --- a/include/linux/kobject.h
69550 +++ b/include/linux/kobject.h
69551 @@ -111,7 +111,7 @@ struct kobj_type {
69552 struct attribute **default_attrs;
69553 const struct kobj_ns_type_operations *(*child_ns_type)(struct kobject *kobj);
69554 const void *(*namespace)(struct kobject *kobj);
69555 -};
69556 +} __do_const;
69557
69558 struct kobj_uevent_env {
69559 char *envp[UEVENT_NUM_ENVP];
69560 @@ -134,6 +134,7 @@ struct kobj_attribute {
69561 ssize_t (*store)(struct kobject *kobj, struct kobj_attribute *attr,
69562 const char *buf, size_t count);
69563 };
69564 +typedef struct kobj_attribute __no_const kobj_attribute_no_const;
69565
69566 extern const struct sysfs_ops kobj_sysfs_ops;
69567
69568 diff --git a/include/linux/kobject_ns.h b/include/linux/kobject_ns.h
69569 index f66b065..c2c29b4 100644
69570 --- a/include/linux/kobject_ns.h
69571 +++ b/include/linux/kobject_ns.h
69572 @@ -43,7 +43,7 @@ struct kobj_ns_type_operations {
69573 const void *(*netlink_ns)(struct sock *sk);
69574 const void *(*initial_ns)(void);
69575 void (*drop_ns)(void *);
69576 -};
69577 +} __do_const;
69578
69579 int kobj_ns_type_register(const struct kobj_ns_type_operations *ops);
69580 int kobj_ns_type_registered(enum kobj_ns_type type);
69581 diff --git a/include/linux/kref.h b/include/linux/kref.h
69582 index 7419c02..aa2f02d 100644
69583 --- a/include/linux/kref.h
69584 +++ b/include/linux/kref.h
69585 @@ -65,7 +65,7 @@ static inline void kref_get(struct kref *kref)
69586 static inline int kref_sub(struct kref *kref, unsigned int count,
69587 void (*release)(struct kref *kref))
69588 {
69589 - WARN_ON(release == NULL);
69590 + BUG_ON(release == NULL);
69591
69592 if (atomic_sub_and_test((int) count, &kref->refcount)) {
69593 release(kref);
69594 diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
69595 index c139582..0b5b102 100644
69596 --- a/include/linux/kvm_host.h
69597 +++ b/include/linux/kvm_host.h
69598 @@ -424,7 +424,7 @@ void kvm_vcpu_uninit(struct kvm_vcpu *vcpu);
69599 int __must_check vcpu_load(struct kvm_vcpu *vcpu);
69600 void vcpu_put(struct kvm_vcpu *vcpu);
69601
69602 -int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
69603 +int kvm_init(const void *opaque, unsigned vcpu_size, unsigned vcpu_align,
69604 struct module *module);
69605 void kvm_exit(void);
69606
69607 @@ -582,7 +582,7 @@ int kvm_arch_vcpu_ioctl_set_guest_debug(struct kvm_vcpu *vcpu,
69608 struct kvm_guest_debug *dbg);
69609 int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run);
69610
69611 -int kvm_arch_init(void *opaque);
69612 +int kvm_arch_init(const void *opaque);
69613 void kvm_arch_exit(void);
69614
69615 int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu);
69616 diff --git a/include/linux/libata.h b/include/linux/libata.h
69617 index eae7a05..2cdd875 100644
69618 --- a/include/linux/libata.h
69619 +++ b/include/linux/libata.h
69620 @@ -919,7 +919,7 @@ struct ata_port_operations {
69621 * fields must be pointers.
69622 */
69623 const struct ata_port_operations *inherits;
69624 -};
69625 +} __do_const;
69626
69627 struct ata_port_info {
69628 unsigned long flags;
69629 diff --git a/include/linux/list.h b/include/linux/list.h
69630 index 6a1f8df..eaec1ff 100644
69631 --- a/include/linux/list.h
69632 +++ b/include/linux/list.h
69633 @@ -112,6 +112,19 @@ extern void __list_del_entry(struct list_head *entry);
69634 extern void list_del(struct list_head *entry);
69635 #endif
69636
69637 +extern void __pax_list_add(struct list_head *new,
69638 + struct list_head *prev,
69639 + struct list_head *next);
69640 +static inline void pax_list_add(struct list_head *new, struct list_head *head)
69641 +{
69642 + __pax_list_add(new, head, head->next);
69643 +}
69644 +static inline void pax_list_add_tail(struct list_head *new, struct list_head *head)
69645 +{
69646 + __pax_list_add(new, head->prev, head);
69647 +}
69648 +extern void pax_list_del(struct list_head *entry);
69649 +
69650 /**
69651 * list_replace - replace old entry by new one
69652 * @old : the element to be replaced
69653 @@ -145,6 +158,8 @@ static inline void list_del_init(struct list_head *entry)
69654 INIT_LIST_HEAD(entry);
69655 }
69656
69657 +extern void pax_list_del_init(struct list_head *entry);
69658 +
69659 /**
69660 * list_move - delete from one list and add as another's head
69661 * @list: the entry to move
69662 diff --git a/include/linux/math64.h b/include/linux/math64.h
69663 index b8ba855..0148090 100644
69664 --- a/include/linux/math64.h
69665 +++ b/include/linux/math64.h
69666 @@ -14,7 +14,7 @@
69667 * This is commonly provided by 32bit archs to provide an optimized 64bit
69668 * divide.
69669 */
69670 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
69671 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
69672 {
69673 *remainder = dividend % divisor;
69674 return dividend / divisor;
69675 @@ -50,7 +50,7 @@ static inline s64 div64_s64(s64 dividend, s64 divisor)
69676 #define div64_long(x,y) div_s64((x),(y))
69677
69678 #ifndef div_u64_rem
69679 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
69680 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
69681 {
69682 *remainder = do_div(dividend, divisor);
69683 return dividend;
69684 @@ -79,7 +79,7 @@ extern s64 div64_s64(s64 dividend, s64 divisor);
69685 * divide.
69686 */
69687 #ifndef div_u64
69688 -static inline u64 div_u64(u64 dividend, u32 divisor)
69689 +static inline u64 __intentional_overflow(-1) div_u64(u64 dividend, u32 divisor)
69690 {
69691 u32 remainder;
69692 return div_u64_rem(dividend, divisor, &remainder);
69693 diff --git a/include/linux/mm.h b/include/linux/mm.h
69694 index e2091b8..821db54 100644
69695 --- a/include/linux/mm.h
69696 +++ b/include/linux/mm.h
69697 @@ -101,6 +101,11 @@ extern unsigned int kobjsize(const void *objp);
69698 #define VM_HUGETLB 0x00400000 /* Huge TLB Page VM */
69699 #define VM_NONLINEAR 0x00800000 /* Is non-linear (remap_file_pages) */
69700 #define VM_ARCH_1 0x01000000 /* Architecture-specific flag */
69701 +
69702 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
69703 +#define VM_PAGEEXEC 0x02000000 /* vma->vm_page_prot needs special handling */
69704 +#endif
69705 +
69706 #define VM_DONTDUMP 0x04000000 /* Do not include in the core dump */
69707
69708 #define VM_MIXEDMAP 0x10000000 /* Can contain "struct page" and pure PFN pages */
69709 @@ -202,8 +207,8 @@ struct vm_operations_struct {
69710 /* called by access_process_vm when get_user_pages() fails, typically
69711 * for use by special VMAs that can switch between memory and hardware
69712 */
69713 - int (*access)(struct vm_area_struct *vma, unsigned long addr,
69714 - void *buf, int len, int write);
69715 + ssize_t (*access)(struct vm_area_struct *vma, unsigned long addr,
69716 + void *buf, size_t len, int write);
69717 #ifdef CONFIG_NUMA
69718 /*
69719 * set_policy() op must add a reference to any non-NULL @new mempolicy
69720 @@ -233,6 +238,7 @@ struct vm_operations_struct {
69721 int (*remap_pages)(struct vm_area_struct *vma, unsigned long addr,
69722 unsigned long size, pgoff_t pgoff);
69723 };
69724 +typedef struct vm_operations_struct __no_const vm_operations_struct_no_const;
69725
69726 struct mmu_gather;
69727 struct inode;
69728 @@ -970,8 +976,8 @@ int follow_pfn(struct vm_area_struct *vma, unsigned long address,
69729 unsigned long *pfn);
69730 int follow_phys(struct vm_area_struct *vma, unsigned long address,
69731 unsigned int flags, unsigned long *prot, resource_size_t *phys);
69732 -int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
69733 - void *buf, int len, int write);
69734 +ssize_t generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
69735 + void *buf, size_t len, int write);
69736
69737 static inline void unmap_shared_mapping_range(struct address_space *mapping,
69738 loff_t const holebegin, loff_t const holelen)
69739 @@ -1010,9 +1016,9 @@ static inline int fixup_user_fault(struct task_struct *tsk,
69740 }
69741 #endif
69742
69743 -extern int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write);
69744 -extern int access_remote_vm(struct mm_struct *mm, unsigned long addr,
69745 - void *buf, int len, int write);
69746 +extern ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, size_t len, int write);
69747 +extern ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
69748 + void *buf, size_t len, int write);
69749
69750 long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
69751 unsigned long start, unsigned long nr_pages,
69752 @@ -1043,34 +1049,6 @@ int set_page_dirty(struct page *page);
69753 int set_page_dirty_lock(struct page *page);
69754 int clear_page_dirty_for_io(struct page *page);
69755
69756 -/* Is the vma a continuation of the stack vma above it? */
69757 -static inline int vma_growsdown(struct vm_area_struct *vma, unsigned long addr)
69758 -{
69759 - return vma && (vma->vm_end == addr) && (vma->vm_flags & VM_GROWSDOWN);
69760 -}
69761 -
69762 -static inline int stack_guard_page_start(struct vm_area_struct *vma,
69763 - unsigned long addr)
69764 -{
69765 - return (vma->vm_flags & VM_GROWSDOWN) &&
69766 - (vma->vm_start == addr) &&
69767 - !vma_growsdown(vma->vm_prev, addr);
69768 -}
69769 -
69770 -/* Is the vma a continuation of the stack vma below it? */
69771 -static inline int vma_growsup(struct vm_area_struct *vma, unsigned long addr)
69772 -{
69773 - return vma && (vma->vm_start == addr) && (vma->vm_flags & VM_GROWSUP);
69774 -}
69775 -
69776 -static inline int stack_guard_page_end(struct vm_area_struct *vma,
69777 - unsigned long addr)
69778 -{
69779 - return (vma->vm_flags & VM_GROWSUP) &&
69780 - (vma->vm_end == addr) &&
69781 - !vma_growsup(vma->vm_next, addr);
69782 -}
69783 -
69784 extern pid_t
69785 vm_is_stack(struct task_struct *task, struct vm_area_struct *vma, int in_group);
69786
69787 @@ -1173,6 +1151,15 @@ static inline void sync_mm_rss(struct mm_struct *mm)
69788 }
69789 #endif
69790
69791 +#ifdef CONFIG_MMU
69792 +pgprot_t vm_get_page_prot(vm_flags_t vm_flags);
69793 +#else
69794 +static inline pgprot_t vm_get_page_prot(vm_flags_t vm_flags)
69795 +{
69796 + return __pgprot(0);
69797 +}
69798 +#endif
69799 +
69800 int vma_wants_writenotify(struct vm_area_struct *vma);
69801
69802 extern pte_t *__get_locked_pte(struct mm_struct *mm, unsigned long addr,
69803 @@ -1191,8 +1178,15 @@ static inline int __pud_alloc(struct mm_struct *mm, pgd_t *pgd,
69804 {
69805 return 0;
69806 }
69807 +
69808 +static inline int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd,
69809 + unsigned long address)
69810 +{
69811 + return 0;
69812 +}
69813 #else
69814 int __pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address);
69815 +int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address);
69816 #endif
69817
69818 #ifdef __PAGETABLE_PMD_FOLDED
69819 @@ -1201,8 +1195,15 @@ static inline int __pmd_alloc(struct mm_struct *mm, pud_t *pud,
69820 {
69821 return 0;
69822 }
69823 +
69824 +static inline int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud,
69825 + unsigned long address)
69826 +{
69827 + return 0;
69828 +}
69829 #else
69830 int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address);
69831 +int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address);
69832 #endif
69833
69834 int __pte_alloc(struct mm_struct *mm, struct vm_area_struct *vma,
69835 @@ -1220,11 +1221,23 @@ static inline pud_t *pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long a
69836 NULL: pud_offset(pgd, address);
69837 }
69838
69839 +static inline pud_t *pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
69840 +{
69841 + return (unlikely(pgd_none(*pgd)) && __pud_alloc_kernel(mm, pgd, address))?
69842 + NULL: pud_offset(pgd, address);
69843 +}
69844 +
69845 static inline pmd_t *pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
69846 {
69847 return (unlikely(pud_none(*pud)) && __pmd_alloc(mm, pud, address))?
69848 NULL: pmd_offset(pud, address);
69849 }
69850 +
69851 +static inline pmd_t *pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address)
69852 +{
69853 + return (unlikely(pud_none(*pud)) && __pmd_alloc_kernel(mm, pud, address))?
69854 + NULL: pmd_offset(pud, address);
69855 +}
69856 #endif /* CONFIG_MMU && !__ARCH_HAS_4LEVEL_HACK */
69857
69858 #if USE_SPLIT_PTLOCKS
69859 @@ -1455,6 +1468,7 @@ extern unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
69860 unsigned long len, unsigned long prot, unsigned long flags,
69861 unsigned long pgoff, unsigned long *populate);
69862 extern int do_munmap(struct mm_struct *, unsigned long, size_t);
69863 +extern int __do_munmap(struct mm_struct *, unsigned long, size_t);
69864
69865 #ifdef CONFIG_MMU
69866 extern int __mm_populate(unsigned long addr, unsigned long len,
69867 @@ -1483,6 +1497,7 @@ struct vm_unmapped_area_info {
69868 unsigned long high_limit;
69869 unsigned long align_mask;
69870 unsigned long align_offset;
69871 + unsigned long threadstack_offset;
69872 };
69873
69874 extern unsigned long unmapped_area(struct vm_unmapped_area_info *info);
69875 @@ -1561,6 +1576,10 @@ extern struct vm_area_struct * find_vma(struct mm_struct * mm, unsigned long add
69876 extern struct vm_area_struct * find_vma_prev(struct mm_struct * mm, unsigned long addr,
69877 struct vm_area_struct **pprev);
69878
69879 +extern struct vm_area_struct *pax_find_mirror_vma(struct vm_area_struct *vma);
69880 +extern __must_check long pax_mirror_vma(struct vm_area_struct *vma_m, struct vm_area_struct *vma);
69881 +extern void pax_mirror_file_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl);
69882 +
69883 /* Look up the first VMA which intersects the interval start_addr..end_addr-1,
69884 NULL if none. Assume start_addr < end_addr. */
69885 static inline struct vm_area_struct * find_vma_intersection(struct mm_struct * mm, unsigned long start_addr, unsigned long end_addr)
69886 @@ -1589,15 +1608,6 @@ static inline struct vm_area_struct *find_exact_vma(struct mm_struct *mm,
69887 return vma;
69888 }
69889
69890 -#ifdef CONFIG_MMU
69891 -pgprot_t vm_get_page_prot(unsigned long vm_flags);
69892 -#else
69893 -static inline pgprot_t vm_get_page_prot(unsigned long vm_flags)
69894 -{
69895 - return __pgprot(0);
69896 -}
69897 -#endif
69898 -
69899 #ifdef CONFIG_ARCH_USES_NUMA_PROT_NONE
69900 unsigned long change_prot_numa(struct vm_area_struct *vma,
69901 unsigned long start, unsigned long end);
69902 @@ -1649,6 +1659,11 @@ void vm_stat_account(struct mm_struct *, unsigned long, struct file *, long);
69903 static inline void vm_stat_account(struct mm_struct *mm,
69904 unsigned long flags, struct file *file, long pages)
69905 {
69906 +
69907 +#ifdef CONFIG_PAX_RANDMMAP
69908 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
69909 +#endif
69910 +
69911 mm->total_vm += pages;
69912 }
69913 #endif /* CONFIG_PROC_FS */
69914 @@ -1725,7 +1740,7 @@ extern int unpoison_memory(unsigned long pfn);
69915 extern int sysctl_memory_failure_early_kill;
69916 extern int sysctl_memory_failure_recovery;
69917 extern void shake_page(struct page *p, int access);
69918 -extern atomic_long_t num_poisoned_pages;
69919 +extern atomic_long_unchecked_t num_poisoned_pages;
69920 extern int soft_offline_page(struct page *page, int flags);
69921
69922 extern void dump_page(struct page *page);
69923 @@ -1756,5 +1771,11 @@ static inline unsigned int debug_guardpage_minorder(void) { return 0; }
69924 static inline bool page_is_guard(struct page *page) { return false; }
69925 #endif /* CONFIG_DEBUG_PAGEALLOC */
69926
69927 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
69928 +extern void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot);
69929 +#else
69930 +static inline void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot) {}
69931 +#endif
69932 +
69933 #endif /* __KERNEL__ */
69934 #endif /* _LINUX_MM_H */
69935 diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
69936 index ace9a5f..81bdb59 100644
69937 --- a/include/linux/mm_types.h
69938 +++ b/include/linux/mm_types.h
69939 @@ -289,6 +289,8 @@ struct vm_area_struct {
69940 #ifdef CONFIG_NUMA
69941 struct mempolicy *vm_policy; /* NUMA policy for the VMA */
69942 #endif
69943 +
69944 + struct vm_area_struct *vm_mirror;/* PaX: mirror vma or NULL */
69945 };
69946
69947 struct core_thread {
69948 @@ -437,6 +439,24 @@ struct mm_struct {
69949 int first_nid;
69950 #endif
69951 struct uprobes_state uprobes_state;
69952 +
69953 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
69954 + unsigned long pax_flags;
69955 +#endif
69956 +
69957 +#ifdef CONFIG_PAX_DLRESOLVE
69958 + unsigned long call_dl_resolve;
69959 +#endif
69960 +
69961 +#if defined(CONFIG_PPC32) && defined(CONFIG_PAX_EMUSIGRT)
69962 + unsigned long call_syscall;
69963 +#endif
69964 +
69965 +#ifdef CONFIG_PAX_ASLR
69966 + unsigned long delta_mmap; /* randomized offset */
69967 + unsigned long delta_stack; /* randomized offset */
69968 +#endif
69969 +
69970 };
69971
69972 /* first nid will either be a valid NID or one of these values */
69973 diff --git a/include/linux/mmiotrace.h b/include/linux/mmiotrace.h
69974 index c5d5278..f0b68c8 100644
69975 --- a/include/linux/mmiotrace.h
69976 +++ b/include/linux/mmiotrace.h
69977 @@ -46,7 +46,7 @@ extern int kmmio_handler(struct pt_regs *regs, unsigned long addr);
69978 /* Called from ioremap.c */
69979 extern void mmiotrace_ioremap(resource_size_t offset, unsigned long size,
69980 void __iomem *addr);
69981 -extern void mmiotrace_iounmap(volatile void __iomem *addr);
69982 +extern void mmiotrace_iounmap(const volatile void __iomem *addr);
69983
69984 /* For anyone to insert markers. Remember trailing newline. */
69985 extern __printf(1, 2) int mmiotrace_printk(const char *fmt, ...);
69986 @@ -66,7 +66,7 @@ static inline void mmiotrace_ioremap(resource_size_t offset,
69987 {
69988 }
69989
69990 -static inline void mmiotrace_iounmap(volatile void __iomem *addr)
69991 +static inline void mmiotrace_iounmap(const volatile void __iomem *addr)
69992 {
69993 }
69994
69995 diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
69996 index c74092e..b663967 100644
69997 --- a/include/linux/mmzone.h
69998 +++ b/include/linux/mmzone.h
69999 @@ -396,7 +396,7 @@ struct zone {
70000 unsigned long flags; /* zone flags, see below */
70001
70002 /* Zone statistics */
70003 - atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
70004 + atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
70005
70006 /*
70007 * The target ratio of ACTIVE_ANON to INACTIVE_ANON pages on
70008 diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
70009 index 779cf7c..e6768240 100644
70010 --- a/include/linux/mod_devicetable.h
70011 +++ b/include/linux/mod_devicetable.h
70012 @@ -12,7 +12,7 @@
70013 typedef unsigned long kernel_ulong_t;
70014 #endif
70015
70016 -#define PCI_ANY_ID (~0)
70017 +#define PCI_ANY_ID ((__u16)~0)
70018
70019 struct pci_device_id {
70020 __u32 vendor, device; /* Vendor and device ID or PCI_ANY_ID*/
70021 @@ -138,7 +138,7 @@ struct usb_device_id {
70022 #define USB_DEVICE_ID_MATCH_INT_PROTOCOL 0x0200
70023 #define USB_DEVICE_ID_MATCH_INT_NUMBER 0x0400
70024
70025 -#define HID_ANY_ID (~0)
70026 +#define HID_ANY_ID (~0U)
70027 #define HID_BUS_ANY 0xffff
70028 #define HID_GROUP_ANY 0x0000
70029
70030 @@ -464,7 +464,7 @@ struct dmi_system_id {
70031 const char *ident;
70032 struct dmi_strmatch matches[4];
70033 void *driver_data;
70034 -};
70035 +} __do_const;
70036 /*
70037 * struct dmi_device_id appears during expansion of
70038 * "MODULE_DEVICE_TABLE(dmi, x)". Compiler doesn't look inside it
70039 diff --git a/include/linux/module.h b/include/linux/module.h
70040 index ead1b57..81a3b6c 100644
70041 --- a/include/linux/module.h
70042 +++ b/include/linux/module.h
70043 @@ -17,9 +17,11 @@
70044 #include <linux/moduleparam.h>
70045 #include <linux/tracepoint.h>
70046 #include <linux/export.h>
70047 +#include <linux/fs.h>
70048
70049 #include <linux/percpu.h>
70050 #include <asm/module.h>
70051 +#include <asm/pgtable.h>
70052
70053 /* In stripped ARM and x86-64 modules, ~ is surprisingly rare. */
70054 #define MODULE_SIG_STRING "~Module signature appended~\n"
70055 @@ -54,12 +56,13 @@ struct module_attribute {
70056 int (*test)(struct module *);
70057 void (*free)(struct module *);
70058 };
70059 +typedef struct module_attribute __no_const module_attribute_no_const;
70060
70061 struct module_version_attribute {
70062 struct module_attribute mattr;
70063 const char *module_name;
70064 const char *version;
70065 -} __attribute__ ((__aligned__(sizeof(void *))));
70066 +} __do_const __attribute__ ((__aligned__(sizeof(void *))));
70067
70068 extern ssize_t __modver_version_show(struct module_attribute *,
70069 struct module_kobject *, char *);
70070 @@ -232,7 +235,7 @@ struct module
70071
70072 /* Sysfs stuff. */
70073 struct module_kobject mkobj;
70074 - struct module_attribute *modinfo_attrs;
70075 + module_attribute_no_const *modinfo_attrs;
70076 const char *version;
70077 const char *srcversion;
70078 struct kobject *holders_dir;
70079 @@ -281,19 +284,16 @@ struct module
70080 int (*init)(void);
70081
70082 /* If this is non-NULL, vfree after init() returns */
70083 - void *module_init;
70084 + void *module_init_rx, *module_init_rw;
70085
70086 /* Here is the actual code + data, vfree'd on unload. */
70087 - void *module_core;
70088 + void *module_core_rx, *module_core_rw;
70089
70090 /* Here are the sizes of the init and core sections */
70091 - unsigned int init_size, core_size;
70092 + unsigned int init_size_rw, core_size_rw;
70093
70094 /* The size of the executable code in each section. */
70095 - unsigned int init_text_size, core_text_size;
70096 -
70097 - /* Size of RO sections of the module (text+rodata) */
70098 - unsigned int init_ro_size, core_ro_size;
70099 + unsigned int init_size_rx, core_size_rx;
70100
70101 /* Arch-specific module values */
70102 struct mod_arch_specific arch;
70103 @@ -349,6 +349,10 @@ struct module
70104 #ifdef CONFIG_EVENT_TRACING
70105 struct ftrace_event_call **trace_events;
70106 unsigned int num_trace_events;
70107 + struct file_operations trace_id;
70108 + struct file_operations trace_enable;
70109 + struct file_operations trace_format;
70110 + struct file_operations trace_filter;
70111 #endif
70112 #ifdef CONFIG_FTRACE_MCOUNT_RECORD
70113 unsigned int num_ftrace_callsites;
70114 @@ -396,16 +400,46 @@ bool is_module_address(unsigned long addr);
70115 bool is_module_percpu_address(unsigned long addr);
70116 bool is_module_text_address(unsigned long addr);
70117
70118 +static inline int within_module_range(unsigned long addr, void *start, unsigned long size)
70119 +{
70120 +
70121 +#ifdef CONFIG_PAX_KERNEXEC
70122 + if (ktla_ktva(addr) >= (unsigned long)start &&
70123 + ktla_ktva(addr) < (unsigned long)start + size)
70124 + return 1;
70125 +#endif
70126 +
70127 + return ((void *)addr >= start && (void *)addr < start + size);
70128 +}
70129 +
70130 +static inline int within_module_core_rx(unsigned long addr, const struct module *mod)
70131 +{
70132 + return within_module_range(addr, mod->module_core_rx, mod->core_size_rx);
70133 +}
70134 +
70135 +static inline int within_module_core_rw(unsigned long addr, const struct module *mod)
70136 +{
70137 + return within_module_range(addr, mod->module_core_rw, mod->core_size_rw);
70138 +}
70139 +
70140 +static inline int within_module_init_rx(unsigned long addr, const struct module *mod)
70141 +{
70142 + return within_module_range(addr, mod->module_init_rx, mod->init_size_rx);
70143 +}
70144 +
70145 +static inline int within_module_init_rw(unsigned long addr, const struct module *mod)
70146 +{
70147 + return within_module_range(addr, mod->module_init_rw, mod->init_size_rw);
70148 +}
70149 +
70150 static inline int within_module_core(unsigned long addr, const struct module *mod)
70151 {
70152 - return (unsigned long)mod->module_core <= addr &&
70153 - addr < (unsigned long)mod->module_core + mod->core_size;
70154 + return within_module_core_rx(addr, mod) || within_module_core_rw(addr, mod);
70155 }
70156
70157 static inline int within_module_init(unsigned long addr, const struct module *mod)
70158 {
70159 - return (unsigned long)mod->module_init <= addr &&
70160 - addr < (unsigned long)mod->module_init + mod->init_size;
70161 + return within_module_init_rx(addr, mod) || within_module_init_rw(addr, mod);
70162 }
70163
70164 /* Search for module by name: must hold module_mutex. */
70165 diff --git a/include/linux/moduleloader.h b/include/linux/moduleloader.h
70166 index 560ca53..ef621ef 100644
70167 --- a/include/linux/moduleloader.h
70168 +++ b/include/linux/moduleloader.h
70169 @@ -25,9 +25,21 @@ unsigned int arch_mod_section_prepend(struct module *mod, unsigned int section);
70170 sections. Returns NULL on failure. */
70171 void *module_alloc(unsigned long size);
70172
70173 +#ifdef CONFIG_PAX_KERNEXEC
70174 +void *module_alloc_exec(unsigned long size);
70175 +#else
70176 +#define module_alloc_exec(x) module_alloc(x)
70177 +#endif
70178 +
70179 /* Free memory returned from module_alloc. */
70180 void module_free(struct module *mod, void *module_region);
70181
70182 +#ifdef CONFIG_PAX_KERNEXEC
70183 +void module_free_exec(struct module *mod, void *module_region);
70184 +#else
70185 +#define module_free_exec(x, y) module_free((x), (y))
70186 +#endif
70187 +
70188 /*
70189 * Apply the given relocation to the (simplified) ELF. Return -error
70190 * or 0.
70191 @@ -45,7 +57,9 @@ static inline int apply_relocate(Elf_Shdr *sechdrs,
70192 unsigned int relsec,
70193 struct module *me)
70194 {
70195 +#ifdef CONFIG_MODULES
70196 printk(KERN_ERR "module %s: REL relocation unsupported\n", me->name);
70197 +#endif
70198 return -ENOEXEC;
70199 }
70200 #endif
70201 @@ -67,7 +81,9 @@ static inline int apply_relocate_add(Elf_Shdr *sechdrs,
70202 unsigned int relsec,
70203 struct module *me)
70204 {
70205 +#ifdef CONFIG_MODULES
70206 printk(KERN_ERR "module %s: REL relocation unsupported\n", me->name);
70207 +#endif
70208 return -ENOEXEC;
70209 }
70210 #endif
70211 diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h
70212 index 137b419..fe663ec 100644
70213 --- a/include/linux/moduleparam.h
70214 +++ b/include/linux/moduleparam.h
70215 @@ -284,7 +284,7 @@ static inline void __kernel_param_unlock(void)
70216 * @len is usually just sizeof(string).
70217 */
70218 #define module_param_string(name, string, len, perm) \
70219 - static const struct kparam_string __param_string_##name \
70220 + static const struct kparam_string __param_string_##name __used \
70221 = { len, string }; \
70222 __module_param_call(MODULE_PARAM_PREFIX, name, \
70223 &param_ops_string, \
70224 @@ -423,7 +423,7 @@ extern int param_set_bint(const char *val, const struct kernel_param *kp);
70225 */
70226 #define module_param_array_named(name, array, type, nump, perm) \
70227 param_check_##type(name, &(array)[0]); \
70228 - static const struct kparam_array __param_arr_##name \
70229 + static const struct kparam_array __param_arr_##name __used \
70230 = { .max = ARRAY_SIZE(array), .num = nump, \
70231 .ops = &param_ops_##type, \
70232 .elemsize = sizeof(array[0]), .elem = array }; \
70233 diff --git a/include/linux/namei.h b/include/linux/namei.h
70234 index 5a5ff57..5ae5070 100644
70235 --- a/include/linux/namei.h
70236 +++ b/include/linux/namei.h
70237 @@ -19,7 +19,7 @@ struct nameidata {
70238 unsigned seq;
70239 int last_type;
70240 unsigned depth;
70241 - char *saved_names[MAX_NESTED_LINKS + 1];
70242 + const char *saved_names[MAX_NESTED_LINKS + 1];
70243 };
70244
70245 /*
70246 @@ -84,12 +84,12 @@ extern void unlock_rename(struct dentry *, struct dentry *);
70247
70248 extern void nd_jump_link(struct nameidata *nd, struct path *path);
70249
70250 -static inline void nd_set_link(struct nameidata *nd, char *path)
70251 +static inline void nd_set_link(struct nameidata *nd, const char *path)
70252 {
70253 nd->saved_names[nd->depth] = path;
70254 }
70255
70256 -static inline char *nd_get_link(struct nameidata *nd)
70257 +static inline const char *nd_get_link(const struct nameidata *nd)
70258 {
70259 return nd->saved_names[nd->depth];
70260 }
70261 diff --git a/include/linux/net.h b/include/linux/net.h
70262 index aa16731..514b875 100644
70263 --- a/include/linux/net.h
70264 +++ b/include/linux/net.h
70265 @@ -183,7 +183,7 @@ struct net_proto_family {
70266 int (*create)(struct net *net, struct socket *sock,
70267 int protocol, int kern);
70268 struct module *owner;
70269 -};
70270 +} __do_const;
70271
70272 struct iovec;
70273 struct kvec;
70274 diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
70275 index 6151e90..2e0afb0 100644
70276 --- a/include/linux/netdevice.h
70277 +++ b/include/linux/netdevice.h
70278 @@ -1028,6 +1028,7 @@ struct net_device_ops {
70279 int (*ndo_change_carrier)(struct net_device *dev,
70280 bool new_carrier);
70281 };
70282 +typedef struct net_device_ops __no_const net_device_ops_no_const;
70283
70284 /*
70285 * The DEVICE structure.
70286 @@ -1094,7 +1095,7 @@ struct net_device {
70287 int iflink;
70288
70289 struct net_device_stats stats;
70290 - atomic_long_t rx_dropped; /* dropped packets by core network
70291 + atomic_long_unchecked_t rx_dropped; /* dropped packets by core network
70292 * Do not use this in drivers.
70293 */
70294
70295 diff --git a/include/linux/netfilter.h b/include/linux/netfilter.h
70296 index ee14284..bc65d63 100644
70297 --- a/include/linux/netfilter.h
70298 +++ b/include/linux/netfilter.h
70299 @@ -82,7 +82,7 @@ struct nf_sockopt_ops {
70300 #endif
70301 /* Use the module struct to lock set/get code in place */
70302 struct module *owner;
70303 -};
70304 +} __do_const;
70305
70306 /* Function to register/unregister hook points. */
70307 int nf_register_hook(struct nf_hook_ops *reg);
70308 diff --git a/include/linux/netfilter/ipset/ip_set.h b/include/linux/netfilter/ipset/ip_set.h
70309 index 7958e84..ed74d7a 100644
70310 --- a/include/linux/netfilter/ipset/ip_set.h
70311 +++ b/include/linux/netfilter/ipset/ip_set.h
70312 @@ -98,7 +98,7 @@ struct ip_set_type_variant {
70313 /* Return true if "b" set is the same as "a"
70314 * according to the create set parameters */
70315 bool (*same_set)(const struct ip_set *a, const struct ip_set *b);
70316 -};
70317 +} __do_const;
70318
70319 /* The core set type structure */
70320 struct ip_set_type {
70321 diff --git a/include/linux/netfilter/nfnetlink.h b/include/linux/netfilter/nfnetlink.h
70322 index ecbb8e4..8a1c4e1 100644
70323 --- a/include/linux/netfilter/nfnetlink.h
70324 +++ b/include/linux/netfilter/nfnetlink.h
70325 @@ -16,7 +16,7 @@ struct nfnl_callback {
70326 const struct nlattr * const cda[]);
70327 const struct nla_policy *policy; /* netlink attribute policy */
70328 const u_int16_t attr_count; /* number of nlattr's */
70329 -};
70330 +} __do_const;
70331
70332 struct nfnetlink_subsystem {
70333 const char *name;
70334 diff --git a/include/linux/netfilter/xt_gradm.h b/include/linux/netfilter/xt_gradm.h
70335 new file mode 100644
70336 index 0000000..33f4af8
70337 --- /dev/null
70338 +++ b/include/linux/netfilter/xt_gradm.h
70339 @@ -0,0 +1,9 @@
70340 +#ifndef _LINUX_NETFILTER_XT_GRADM_H
70341 +#define _LINUX_NETFILTER_XT_GRADM_H 1
70342 +
70343 +struct xt_gradm_mtinfo {
70344 + __u16 flags;
70345 + __u16 invflags;
70346 +};
70347 +
70348 +#endif
70349 diff --git a/include/linux/nls.h b/include/linux/nls.h
70350 index 5dc635f..35f5e11 100644
70351 --- a/include/linux/nls.h
70352 +++ b/include/linux/nls.h
70353 @@ -31,7 +31,7 @@ struct nls_table {
70354 const unsigned char *charset2upper;
70355 struct module *owner;
70356 struct nls_table *next;
70357 -};
70358 +} __do_const;
70359
70360 /* this value hold the maximum octet of charset */
70361 #define NLS_MAX_CHARSET_SIZE 6 /* for UTF-8 */
70362 diff --git a/include/linux/notifier.h b/include/linux/notifier.h
70363 index d65746e..62e72c2 100644
70364 --- a/include/linux/notifier.h
70365 +++ b/include/linux/notifier.h
70366 @@ -51,7 +51,8 @@ struct notifier_block {
70367 int (*notifier_call)(struct notifier_block *, unsigned long, void *);
70368 struct notifier_block __rcu *next;
70369 int priority;
70370 -};
70371 +} __do_const;
70372 +typedef struct notifier_block __no_const notifier_block_no_const;
70373
70374 struct atomic_notifier_head {
70375 spinlock_t lock;
70376 diff --git a/include/linux/oprofile.h b/include/linux/oprofile.h
70377 index a4c5624..79d6d88 100644
70378 --- a/include/linux/oprofile.h
70379 +++ b/include/linux/oprofile.h
70380 @@ -139,9 +139,9 @@ int oprofilefs_create_ulong(struct super_block * sb, struct dentry * root,
70381 int oprofilefs_create_ro_ulong(struct super_block * sb, struct dentry * root,
70382 char const * name, ulong * val);
70383
70384 -/** Create a file for read-only access to an atomic_t. */
70385 +/** Create a file for read-only access to an atomic_unchecked_t. */
70386 int oprofilefs_create_ro_atomic(struct super_block * sb, struct dentry * root,
70387 - char const * name, atomic_t * val);
70388 + char const * name, atomic_unchecked_t * val);
70389
70390 /** create a directory */
70391 struct dentry * oprofilefs_mkdir(struct super_block * sb, struct dentry * root,
70392 diff --git a/include/linux/pci_hotplug.h b/include/linux/pci_hotplug.h
70393 index 45fc162..01a4068 100644
70394 --- a/include/linux/pci_hotplug.h
70395 +++ b/include/linux/pci_hotplug.h
70396 @@ -80,7 +80,8 @@ struct hotplug_slot_ops {
70397 int (*get_attention_status) (struct hotplug_slot *slot, u8 *value);
70398 int (*get_latch_status) (struct hotplug_slot *slot, u8 *value);
70399 int (*get_adapter_status) (struct hotplug_slot *slot, u8 *value);
70400 -};
70401 +} __do_const;
70402 +typedef struct hotplug_slot_ops __no_const hotplug_slot_ops_no_const;
70403
70404 /**
70405 * struct hotplug_slot_info - used to notify the hotplug pci core of the state of the slot
70406 diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
70407 index 1d795df..b0a6449 100644
70408 --- a/include/linux/perf_event.h
70409 +++ b/include/linux/perf_event.h
70410 @@ -333,8 +333,8 @@ struct perf_event {
70411
70412 enum perf_event_active_state state;
70413 unsigned int attach_state;
70414 - local64_t count;
70415 - atomic64_t child_count;
70416 + local64_t count; /* PaX: fix it one day */
70417 + atomic64_unchecked_t child_count;
70418
70419 /*
70420 * These are the total time in nanoseconds that the event
70421 @@ -385,8 +385,8 @@ struct perf_event {
70422 * These accumulate total time (in nanoseconds) that children
70423 * events have been enabled and running, respectively.
70424 */
70425 - atomic64_t child_total_time_enabled;
70426 - atomic64_t child_total_time_running;
70427 + atomic64_unchecked_t child_total_time_enabled;
70428 + atomic64_unchecked_t child_total_time_running;
70429
70430 /*
70431 * Protect attach/detach and child_list:
70432 @@ -704,7 +704,7 @@ static inline void perf_callchain_store(struct perf_callchain_entry *entry, u64
70433 entry->ip[entry->nr++] = ip;
70434 }
70435
70436 -extern int sysctl_perf_event_paranoid;
70437 +extern int sysctl_perf_event_legitimately_concerned;
70438 extern int sysctl_perf_event_mlock;
70439 extern int sysctl_perf_event_sample_rate;
70440
70441 @@ -712,19 +712,24 @@ extern int perf_proc_update_handler(struct ctl_table *table, int write,
70442 void __user *buffer, size_t *lenp,
70443 loff_t *ppos);
70444
70445 +static inline bool perf_paranoid_any(void)
70446 +{
70447 + return sysctl_perf_event_legitimately_concerned > 2;
70448 +}
70449 +
70450 static inline bool perf_paranoid_tracepoint_raw(void)
70451 {
70452 - return sysctl_perf_event_paranoid > -1;
70453 + return sysctl_perf_event_legitimately_concerned > -1;
70454 }
70455
70456 static inline bool perf_paranoid_cpu(void)
70457 {
70458 - return sysctl_perf_event_paranoid > 0;
70459 + return sysctl_perf_event_legitimately_concerned > 0;
70460 }
70461
70462 static inline bool perf_paranoid_kernel(void)
70463 {
70464 - return sysctl_perf_event_paranoid > 1;
70465 + return sysctl_perf_event_legitimately_concerned > 1;
70466 }
70467
70468 extern void perf_event_init(void);
70469 @@ -812,7 +817,7 @@ static inline void perf_restore_debug_store(void) { }
70470 */
70471 #define perf_cpu_notifier(fn) \
70472 do { \
70473 - static struct notifier_block fn##_nb __cpuinitdata = \
70474 + static struct notifier_block fn##_nb = \
70475 { .notifier_call = fn, .priority = CPU_PRI_PERF }; \
70476 unsigned long cpu = smp_processor_id(); \
70477 unsigned long flags; \
70478 @@ -831,7 +836,7 @@ do { \
70479 struct perf_pmu_events_attr {
70480 struct device_attribute attr;
70481 u64 id;
70482 -};
70483 +} __do_const;
70484
70485 #define PMU_EVENT_ATTR(_name, _var, _id, _show) \
70486 static struct perf_pmu_events_attr _var = { \
70487 diff --git a/include/linux/pipe_fs_i.h b/include/linux/pipe_fs_i.h
70488 index ad1a427..6419649 100644
70489 --- a/include/linux/pipe_fs_i.h
70490 +++ b/include/linux/pipe_fs_i.h
70491 @@ -45,9 +45,9 @@ struct pipe_buffer {
70492 struct pipe_inode_info {
70493 wait_queue_head_t wait;
70494 unsigned int nrbufs, curbuf, buffers;
70495 - unsigned int readers;
70496 - unsigned int writers;
70497 - unsigned int waiting_writers;
70498 + atomic_t readers;
70499 + atomic_t writers;
70500 + atomic_t waiting_writers;
70501 unsigned int r_counter;
70502 unsigned int w_counter;
70503 struct page *tmp_page;
70504 diff --git a/include/linux/platform_data/usb-ehci-s5p.h b/include/linux/platform_data/usb-ehci-s5p.h
70505 index 5f28cae..3d23723 100644
70506 --- a/include/linux/platform_data/usb-ehci-s5p.h
70507 +++ b/include/linux/platform_data/usb-ehci-s5p.h
70508 @@ -14,7 +14,7 @@
70509 struct s5p_ehci_platdata {
70510 int (*phy_init)(struct platform_device *pdev, int type);
70511 int (*phy_exit)(struct platform_device *pdev, int type);
70512 -};
70513 +} __no_const;
70514
70515 extern void s5p_ehci_set_platdata(struct s5p_ehci_platdata *pd);
70516
70517 diff --git a/include/linux/platform_data/usb-exynos.h b/include/linux/platform_data/usb-exynos.h
70518 index c256c59..8ea94c7 100644
70519 --- a/include/linux/platform_data/usb-exynos.h
70520 +++ b/include/linux/platform_data/usb-exynos.h
70521 @@ -14,7 +14,7 @@
70522 struct exynos4_ohci_platdata {
70523 int (*phy_init)(struct platform_device *pdev, int type);
70524 int (*phy_exit)(struct platform_device *pdev, int type);
70525 -};
70526 +} __no_const;
70527
70528 extern void exynos4_ohci_set_platdata(struct exynos4_ohci_platdata *pd);
70529
70530 diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h
70531 index 7c1d252..c5c773e 100644
70532 --- a/include/linux/pm_domain.h
70533 +++ b/include/linux/pm_domain.h
70534 @@ -48,7 +48,7 @@ struct gpd_dev_ops {
70535
70536 struct gpd_cpu_data {
70537 unsigned int saved_exit_latency;
70538 - struct cpuidle_state *idle_state;
70539 + cpuidle_state_no_const *idle_state;
70540 };
70541
70542 struct generic_pm_domain {
70543 diff --git a/include/linux/pm_runtime.h b/include/linux/pm_runtime.h
70544 index 7d7e09e..8671ef8 100644
70545 --- a/include/linux/pm_runtime.h
70546 +++ b/include/linux/pm_runtime.h
70547 @@ -104,7 +104,7 @@ static inline bool pm_runtime_callbacks_present(struct device *dev)
70548
70549 static inline void pm_runtime_mark_last_busy(struct device *dev)
70550 {
70551 - ACCESS_ONCE(dev->power.last_busy) = jiffies;
70552 + ACCESS_ONCE_RW(dev->power.last_busy) = jiffies;
70553 }
70554
70555 #else /* !CONFIG_PM_RUNTIME */
70556 diff --git a/include/linux/pnp.h b/include/linux/pnp.h
70557 index 195aafc..49a7bc2 100644
70558 --- a/include/linux/pnp.h
70559 +++ b/include/linux/pnp.h
70560 @@ -297,7 +297,7 @@ static inline void pnp_set_drvdata(struct pnp_dev *pdev, void *data)
70561 struct pnp_fixup {
70562 char id[7];
70563 void (*quirk_function) (struct pnp_dev * dev); /* fixup function */
70564 -};
70565 +} __do_const;
70566
70567 /* config parameters */
70568 #define PNP_CONFIG_NORMAL 0x0001
70569 diff --git a/include/linux/poison.h b/include/linux/poison.h
70570 index 2110a81..13a11bb 100644
70571 --- a/include/linux/poison.h
70572 +++ b/include/linux/poison.h
70573 @@ -19,8 +19,8 @@
70574 * under normal circumstances, used to verify that nobody uses
70575 * non-initialized list entries.
70576 */
70577 -#define LIST_POISON1 ((void *) 0x00100100 + POISON_POINTER_DELTA)
70578 -#define LIST_POISON2 ((void *) 0x00200200 + POISON_POINTER_DELTA)
70579 +#define LIST_POISON1 ((void *) (long)0xFFFFFF01)
70580 +#define LIST_POISON2 ((void *) (long)0xFFFFFF02)
70581
70582 /********** include/linux/timer.h **********/
70583 /*
70584 diff --git a/include/linux/power/smartreflex.h b/include/linux/power/smartreflex.h
70585 index c0f44c2..1572583 100644
70586 --- a/include/linux/power/smartreflex.h
70587 +++ b/include/linux/power/smartreflex.h
70588 @@ -238,7 +238,7 @@ struct omap_sr_class_data {
70589 int (*notify)(struct omap_sr *sr, u32 status);
70590 u8 notify_flags;
70591 u8 class_type;
70592 -};
70593 +} __do_const;
70594
70595 /**
70596 * struct omap_sr_nvalue_table - Smartreflex n-target value info
70597 diff --git a/include/linux/ppp-comp.h b/include/linux/ppp-comp.h
70598 index 4ea1d37..80f4b33 100644
70599 --- a/include/linux/ppp-comp.h
70600 +++ b/include/linux/ppp-comp.h
70601 @@ -84,7 +84,7 @@ struct compressor {
70602 struct module *owner;
70603 /* Extra skb space needed by the compressor algorithm */
70604 unsigned int comp_extra;
70605 -};
70606 +} __do_const;
70607
70608 /*
70609 * The return value from decompress routine is the length of the
70610 diff --git a/include/linux/printk.h b/include/linux/printk.h
70611 index 822171f..12b30e8 100644
70612 --- a/include/linux/printk.h
70613 +++ b/include/linux/printk.h
70614 @@ -98,6 +98,8 @@ int no_printk(const char *fmt, ...)
70615 extern asmlinkage __printf(1, 2)
70616 void early_printk(const char *fmt, ...);
70617
70618 +extern int kptr_restrict;
70619 +
70620 #ifdef CONFIG_PRINTK
70621 asmlinkage __printf(5, 0)
70622 int vprintk_emit(int facility, int level,
70623 @@ -132,7 +134,6 @@ extern bool printk_timed_ratelimit(unsigned long *caller_jiffies,
70624
70625 extern int printk_delay_msec;
70626 extern int dmesg_restrict;
70627 -extern int kptr_restrict;
70628
70629 extern void wake_up_klogd(void);
70630
70631 diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h
70632 index 94dfb2a..88b9d3b 100644
70633 --- a/include/linux/proc_fs.h
70634 +++ b/include/linux/proc_fs.h
70635 @@ -165,6 +165,18 @@ static inline struct proc_dir_entry *proc_create(const char *name, umode_t mode,
70636 return proc_create_data(name, mode, parent, proc_fops, NULL);
70637 }
70638
70639 +static inline struct proc_dir_entry *proc_create_grsec(const char *name, umode_t mode,
70640 + struct proc_dir_entry *parent, const struct file_operations *proc_fops)
70641 +{
70642 +#ifdef CONFIG_GRKERNSEC_PROC_USER
70643 + return proc_create_data(name, S_IRUSR, parent, proc_fops, NULL);
70644 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
70645 + return proc_create_data(name, S_IRUSR | S_IRGRP, parent, proc_fops, NULL);
70646 +#else
70647 + return proc_create_data(name, mode, parent, proc_fops, NULL);
70648 +#endif
70649 +}
70650 +
70651 static inline struct proc_dir_entry *create_proc_read_entry(const char *name,
70652 umode_t mode, struct proc_dir_entry *base,
70653 read_proc_t *read_proc, void * data)
70654 @@ -266,7 +278,7 @@ struct proc_ns_operations {
70655 void (*put)(void *ns);
70656 int (*install)(struct nsproxy *nsproxy, void *ns);
70657 unsigned int (*inum)(void *ns);
70658 -};
70659 +} __do_const;
70660 extern const struct proc_ns_operations netns_operations;
70661 extern const struct proc_ns_operations utsns_operations;
70662 extern const struct proc_ns_operations ipcns_operations;
70663 diff --git a/include/linux/random.h b/include/linux/random.h
70664 index 347ce55..880f97c 100644
70665 --- a/include/linux/random.h
70666 +++ b/include/linux/random.h
70667 @@ -39,6 +39,11 @@ void prandom_seed(u32 seed);
70668 u32 prandom_u32_state(struct rnd_state *);
70669 void prandom_bytes_state(struct rnd_state *state, void *buf, int nbytes);
70670
70671 +static inline unsigned long pax_get_random_long(void)
70672 +{
70673 + return prandom_u32() + (sizeof(long) > 4 ? (unsigned long)prandom_u32() << 32 : 0);
70674 +}
70675 +
70676 /*
70677 * Handle minimum values for seeds
70678 */
70679 diff --git a/include/linux/rculist.h b/include/linux/rculist.h
70680 index 8089e35..3a0d59a 100644
70681 --- a/include/linux/rculist.h
70682 +++ b/include/linux/rculist.h
70683 @@ -44,6 +44,9 @@ extern void __list_add_rcu(struct list_head *new,
70684 struct list_head *prev, struct list_head *next);
70685 #endif
70686
70687 +extern void __pax_list_add_rcu(struct list_head *new,
70688 + struct list_head *prev, struct list_head *next);
70689 +
70690 /**
70691 * list_add_rcu - add a new entry to rcu-protected list
70692 * @new: new entry to be added
70693 @@ -65,6 +68,11 @@ static inline void list_add_rcu(struct list_head *new, struct list_head *head)
70694 __list_add_rcu(new, head, head->next);
70695 }
70696
70697 +static inline void pax_list_add_rcu(struct list_head *new, struct list_head *head)
70698 +{
70699 + __pax_list_add_rcu(new, head, head->next);
70700 +}
70701 +
70702 /**
70703 * list_add_tail_rcu - add a new entry to rcu-protected list
70704 * @new: new entry to be added
70705 @@ -87,6 +95,12 @@ static inline void list_add_tail_rcu(struct list_head *new,
70706 __list_add_rcu(new, head->prev, head);
70707 }
70708
70709 +static inline void pax_list_add_tail_rcu(struct list_head *new,
70710 + struct list_head *head)
70711 +{
70712 + __pax_list_add_rcu(new, head->prev, head);
70713 +}
70714 +
70715 /**
70716 * list_del_rcu - deletes entry from list without re-initialization
70717 * @entry: the element to delete from the list.
70718 @@ -117,6 +131,8 @@ static inline void list_del_rcu(struct list_head *entry)
70719 entry->prev = LIST_POISON2;
70720 }
70721
70722 +extern void pax_list_del_rcu(struct list_head *entry);
70723 +
70724 /**
70725 * hlist_del_init_rcu - deletes entry from hash list with re-initialization
70726 * @n: the element to delete from the hash list.
70727 diff --git a/include/linux/reboot.h b/include/linux/reboot.h
70728 index 23b3630..e1bc12b 100644
70729 --- a/include/linux/reboot.h
70730 +++ b/include/linux/reboot.h
70731 @@ -18,9 +18,9 @@ extern int unregister_reboot_notifier(struct notifier_block *);
70732 * Architecture-specific implementations of sys_reboot commands.
70733 */
70734
70735 -extern void machine_restart(char *cmd);
70736 -extern void machine_halt(void);
70737 -extern void machine_power_off(void);
70738 +extern void machine_restart(char *cmd) __noreturn;
70739 +extern void machine_halt(void) __noreturn;
70740 +extern void machine_power_off(void) __noreturn;
70741
70742 extern void machine_shutdown(void);
70743 struct pt_regs;
70744 @@ -31,9 +31,9 @@ extern void machine_crash_shutdown(struct pt_regs *);
70745 */
70746
70747 extern void kernel_restart_prepare(char *cmd);
70748 -extern void kernel_restart(char *cmd);
70749 -extern void kernel_halt(void);
70750 -extern void kernel_power_off(void);
70751 +extern void kernel_restart(char *cmd) __noreturn;
70752 +extern void kernel_halt(void) __noreturn;
70753 +extern void kernel_power_off(void) __noreturn;
70754
70755 extern int C_A_D; /* for sysctl */
70756 void ctrl_alt_del(void);
70757 @@ -47,7 +47,7 @@ extern int orderly_poweroff(bool force);
70758 * Emergency restart, callable from an interrupt handler.
70759 */
70760
70761 -extern void emergency_restart(void);
70762 +extern void emergency_restart(void) __noreturn;
70763 #include <asm/emergency-restart.h>
70764
70765 #endif /* _LINUX_REBOOT_H */
70766 diff --git a/include/linux/regset.h b/include/linux/regset.h
70767 index 8e0c9fe..ac4d221 100644
70768 --- a/include/linux/regset.h
70769 +++ b/include/linux/regset.h
70770 @@ -161,7 +161,8 @@ struct user_regset {
70771 unsigned int align;
70772 unsigned int bias;
70773 unsigned int core_note_type;
70774 -};
70775 +} __do_const;
70776 +typedef struct user_regset __no_const user_regset_no_const;
70777
70778 /**
70779 * struct user_regset_view - available regsets
70780 diff --git a/include/linux/relay.h b/include/linux/relay.h
70781 index 91cacc3..b55ff74 100644
70782 --- a/include/linux/relay.h
70783 +++ b/include/linux/relay.h
70784 @@ -160,7 +160,7 @@ struct rchan_callbacks
70785 * The callback should return 0 if successful, negative if not.
70786 */
70787 int (*remove_buf_file)(struct dentry *dentry);
70788 -};
70789 +} __no_const;
70790
70791 /*
70792 * CONFIG_RELAY kernel API, kernel/relay.c
70793 diff --git a/include/linux/rio.h b/include/linux/rio.h
70794 index a3e7842..d973ca6 100644
70795 --- a/include/linux/rio.h
70796 +++ b/include/linux/rio.h
70797 @@ -339,7 +339,7 @@ struct rio_ops {
70798 int (*map_inb)(struct rio_mport *mport, dma_addr_t lstart,
70799 u64 rstart, u32 size, u32 flags);
70800 void (*unmap_inb)(struct rio_mport *mport, dma_addr_t lstart);
70801 -};
70802 +} __no_const;
70803
70804 #define RIO_RESOURCE_MEM 0x00000100
70805 #define RIO_RESOURCE_DOORBELL 0x00000200
70806 diff --git a/include/linux/rmap.h b/include/linux/rmap.h
70807 index 6dacb93..6174423 100644
70808 --- a/include/linux/rmap.h
70809 +++ b/include/linux/rmap.h
70810 @@ -145,8 +145,8 @@ static inline void anon_vma_unlock_read(struct anon_vma *anon_vma)
70811 void anon_vma_init(void); /* create anon_vma_cachep */
70812 int anon_vma_prepare(struct vm_area_struct *);
70813 void unlink_anon_vmas(struct vm_area_struct *);
70814 -int anon_vma_clone(struct vm_area_struct *, struct vm_area_struct *);
70815 -int anon_vma_fork(struct vm_area_struct *, struct vm_area_struct *);
70816 +int anon_vma_clone(struct vm_area_struct *, const struct vm_area_struct *);
70817 +int anon_vma_fork(struct vm_area_struct *, const struct vm_area_struct *);
70818
70819 static inline void anon_vma_merge(struct vm_area_struct *vma,
70820 struct vm_area_struct *next)
70821 diff --git a/include/linux/sched.h b/include/linux/sched.h
70822 index be4e742..7f9d593 100644
70823 --- a/include/linux/sched.h
70824 +++ b/include/linux/sched.h
70825 @@ -62,6 +62,7 @@ struct bio_list;
70826 struct fs_struct;
70827 struct perf_event_context;
70828 struct blk_plug;
70829 +struct linux_binprm;
70830
70831 /*
70832 * List of flags we want to share for kernel threads,
70833 @@ -315,7 +316,7 @@ extern char __sched_text_start[], __sched_text_end[];
70834 extern int in_sched_functions(unsigned long addr);
70835
70836 #define MAX_SCHEDULE_TIMEOUT LONG_MAX
70837 -extern signed long schedule_timeout(signed long timeout);
70838 +extern signed long schedule_timeout(signed long timeout) __intentional_overflow(-1);
70839 extern signed long schedule_timeout_interruptible(signed long timeout);
70840 extern signed long schedule_timeout_killable(signed long timeout);
70841 extern signed long schedule_timeout_uninterruptible(signed long timeout);
70842 @@ -329,6 +330,18 @@ struct user_namespace;
70843 #include <linux/aio.h>
70844
70845 #ifdef CONFIG_MMU
70846 +
70847 +#ifdef CONFIG_GRKERNSEC_RAND_THREADSTACK
70848 +extern unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags);
70849 +#else
70850 +static inline unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags)
70851 +{
70852 + return 0;
70853 +}
70854 +#endif
70855 +
70856 +extern bool check_heap_stack_gap(const struct vm_area_struct *vma, unsigned long addr, unsigned long len, unsigned long offset);
70857 +extern unsigned long skip_heap_stack_gap(const struct vm_area_struct *vma, unsigned long len, unsigned long offset);
70858 extern void arch_pick_mmap_layout(struct mm_struct *mm);
70859 extern unsigned long
70860 arch_get_unmapped_area(struct file *, unsigned long, unsigned long,
70861 @@ -605,6 +618,17 @@ struct signal_struct {
70862 #ifdef CONFIG_TASKSTATS
70863 struct taskstats *stats;
70864 #endif
70865 +
70866 +#ifdef CONFIG_GRKERNSEC
70867 + u32 curr_ip;
70868 + u32 saved_ip;
70869 + u32 gr_saddr;
70870 + u32 gr_daddr;
70871 + u16 gr_sport;
70872 + u16 gr_dport;
70873 + u8 used_accept:1;
70874 +#endif
70875 +
70876 #ifdef CONFIG_AUDIT
70877 unsigned audit_tty;
70878 struct tty_audit_buf *tty_audit_buf;
70879 @@ -683,6 +707,11 @@ struct user_struct {
70880 struct key *session_keyring; /* UID's default session keyring */
70881 #endif
70882
70883 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT) || defined(CONFIG_GRKERNSEC_BRUTE)
70884 + unsigned int banned;
70885 + unsigned long ban_expires;
70886 +#endif
70887 +
70888 /* Hash table maintenance information */
70889 struct hlist_node uidhash_node;
70890 kuid_t uid;
70891 @@ -1082,7 +1111,7 @@ struct sched_class {
70892 #ifdef CONFIG_FAIR_GROUP_SCHED
70893 void (*task_move_group) (struct task_struct *p, int on_rq);
70894 #endif
70895 -};
70896 +} __do_const;
70897
70898 struct load_weight {
70899 unsigned long weight, inv_weight;
70900 @@ -1323,8 +1352,8 @@ struct task_struct {
70901 struct list_head thread_group;
70902
70903 struct completion *vfork_done; /* for vfork() */
70904 - int __user *set_child_tid; /* CLONE_CHILD_SETTID */
70905 - int __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */
70906 + pid_t __user *set_child_tid; /* CLONE_CHILD_SETTID */
70907 + pid_t __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */
70908
70909 cputime_t utime, stime, utimescaled, stimescaled;
70910 cputime_t gtime;
70911 @@ -1349,11 +1378,6 @@ struct task_struct {
70912 struct task_cputime cputime_expires;
70913 struct list_head cpu_timers[3];
70914
70915 -/* process credentials */
70916 - const struct cred __rcu *real_cred; /* objective and real subjective task
70917 - * credentials (COW) */
70918 - const struct cred __rcu *cred; /* effective (overridable) subjective task
70919 - * credentials (COW) */
70920 char comm[TASK_COMM_LEN]; /* executable name excluding path
70921 - access with [gs]et_task_comm (which lock
70922 it with task_lock())
70923 @@ -1370,6 +1394,10 @@ struct task_struct {
70924 #endif
70925 /* CPU-specific state of this task */
70926 struct thread_struct thread;
70927 +/* thread_info moved to task_struct */
70928 +#ifdef CONFIG_X86
70929 + struct thread_info tinfo;
70930 +#endif
70931 /* filesystem information */
70932 struct fs_struct *fs;
70933 /* open file information */
70934 @@ -1443,6 +1471,10 @@ struct task_struct {
70935 gfp_t lockdep_reclaim_gfp;
70936 #endif
70937
70938 +/* process credentials */
70939 + const struct cred __rcu *real_cred; /* objective and real subjective task
70940 + * credentials (COW) */
70941 +
70942 /* journalling filesystem info */
70943 void *journal_info;
70944
70945 @@ -1481,6 +1513,10 @@ struct task_struct {
70946 /* cg_list protected by css_set_lock and tsk->alloc_lock */
70947 struct list_head cg_list;
70948 #endif
70949 +
70950 + const struct cred __rcu *cred; /* effective (overridable) subjective task
70951 + * credentials (COW) */
70952 +
70953 #ifdef CONFIG_FUTEX
70954 struct robust_list_head __user *robust_list;
70955 #ifdef CONFIG_COMPAT
70956 @@ -1577,8 +1613,74 @@ struct task_struct {
70957 #ifdef CONFIG_UPROBES
70958 struct uprobe_task *utask;
70959 #endif
70960 +
70961 +#ifdef CONFIG_GRKERNSEC
70962 + /* grsecurity */
70963 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
70964 + u64 exec_id;
70965 +#endif
70966 +#ifdef CONFIG_GRKERNSEC_SETXID
70967 + const struct cred *delayed_cred;
70968 +#endif
70969 + struct dentry *gr_chroot_dentry;
70970 + struct acl_subject_label *acl;
70971 + struct acl_role_label *role;
70972 + struct file *exec_file;
70973 + unsigned long brute_expires;
70974 + u16 acl_role_id;
70975 + /* is this the task that authenticated to the special role */
70976 + u8 acl_sp_role;
70977 + u8 is_writable;
70978 + u8 brute;
70979 + u8 gr_is_chrooted;
70980 +#endif
70981 +
70982 };
70983
70984 +#define MF_PAX_PAGEEXEC 0x01000000 /* Paging based non-executable pages */
70985 +#define MF_PAX_EMUTRAMP 0x02000000 /* Emulate trampolines */
70986 +#define MF_PAX_MPROTECT 0x04000000 /* Restrict mprotect() */
70987 +#define MF_PAX_RANDMMAP 0x08000000 /* Randomize mmap() base */
70988 +/*#define MF_PAX_RANDEXEC 0x10000000*/ /* Randomize ET_EXEC base */
70989 +#define MF_PAX_SEGMEXEC 0x20000000 /* Segmentation based non-executable pages */
70990 +
70991 +#ifdef CONFIG_PAX_SOFTMODE
70992 +extern int pax_softmode;
70993 +#endif
70994 +
70995 +extern int pax_check_flags(unsigned long *);
70996 +
70997 +/* if tsk != current then task_lock must be held on it */
70998 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
70999 +static inline unsigned long pax_get_flags(struct task_struct *tsk)
71000 +{
71001 + if (likely(tsk->mm))
71002 + return tsk->mm->pax_flags;
71003 + else
71004 + return 0UL;
71005 +}
71006 +
71007 +/* if tsk != current then task_lock must be held on it */
71008 +static inline long pax_set_flags(struct task_struct *tsk, unsigned long flags)
71009 +{
71010 + if (likely(tsk->mm)) {
71011 + tsk->mm->pax_flags = flags;
71012 + return 0;
71013 + }
71014 + return -EINVAL;
71015 +}
71016 +#endif
71017 +
71018 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
71019 +extern void pax_set_initial_flags(struct linux_binprm *bprm);
71020 +#elif defined(CONFIG_PAX_HOOK_ACL_FLAGS)
71021 +extern void (*pax_set_initial_flags_func)(struct linux_binprm *bprm);
71022 +#endif
71023 +
71024 +extern void pax_report_fault(struct pt_regs *regs, void *pc, void *sp);
71025 +extern void pax_report_insns(struct pt_regs *regs, void *pc, void *sp);
71026 +extern void pax_report_refcount_overflow(struct pt_regs *regs);
71027 +
71028 /* Future-safe accessor for struct task_struct's cpus_allowed. */
71029 #define tsk_cpus_allowed(tsk) (&(tsk)->cpus_allowed)
71030
71031 @@ -1637,7 +1739,7 @@ struct pid_namespace;
71032 pid_t __task_pid_nr_ns(struct task_struct *task, enum pid_type type,
71033 struct pid_namespace *ns);
71034
71035 -static inline pid_t task_pid_nr(struct task_struct *tsk)
71036 +static inline pid_t task_pid_nr(const struct task_struct *tsk)
71037 {
71038 return tsk->pid;
71039 }
71040 @@ -2073,7 +2175,9 @@ void yield(void);
71041 extern struct exec_domain default_exec_domain;
71042
71043 union thread_union {
71044 +#ifndef CONFIG_X86
71045 struct thread_info thread_info;
71046 +#endif
71047 unsigned long stack[THREAD_SIZE/sizeof(long)];
71048 };
71049
71050 @@ -2106,6 +2210,7 @@ extern struct pid_namespace init_pid_ns;
71051 */
71052
71053 extern struct task_struct *find_task_by_vpid(pid_t nr);
71054 +extern struct task_struct *find_task_by_vpid_unrestricted(pid_t nr);
71055 extern struct task_struct *find_task_by_pid_ns(pid_t nr,
71056 struct pid_namespace *ns);
71057
71058 @@ -2272,7 +2377,7 @@ extern void __cleanup_sighand(struct sighand_struct *);
71059 extern void exit_itimers(struct signal_struct *);
71060 extern void flush_itimer_signals(void);
71061
71062 -extern void do_group_exit(int);
71063 +extern __noreturn void do_group_exit(int);
71064
71065 extern int allow_signal(int);
71066 extern int disallow_signal(int);
71067 @@ -2463,9 +2568,9 @@ static inline unsigned long *end_of_stack(struct task_struct *p)
71068
71069 #endif
71070
71071 -static inline int object_is_on_stack(void *obj)
71072 +static inline int object_starts_on_stack(void *obj)
71073 {
71074 - void *stack = task_stack_page(current);
71075 + const void *stack = task_stack_page(current);
71076
71077 return (obj >= stack) && (obj < (stack + THREAD_SIZE));
71078 }
71079 diff --git a/include/linux/sched/sysctl.h b/include/linux/sched/sysctl.h
71080 index bf8086b..962b035 100644
71081 --- a/include/linux/sched/sysctl.h
71082 +++ b/include/linux/sched/sysctl.h
71083 @@ -30,6 +30,7 @@ enum { sysctl_hung_task_timeout_secs = 0 };
71084 #define DEFAULT_MAX_MAP_COUNT (USHRT_MAX - MAPCOUNT_ELF_CORE_MARGIN)
71085
71086 extern int sysctl_max_map_count;
71087 +extern unsigned long sysctl_heap_stack_gap;
71088
71089 extern unsigned int sysctl_sched_latency;
71090 extern unsigned int sysctl_sched_min_granularity;
71091 diff --git a/include/linux/security.h b/include/linux/security.h
71092 index 032c366..2c1c2dc2 100644
71093 --- a/include/linux/security.h
71094 +++ b/include/linux/security.h
71095 @@ -26,6 +26,7 @@
71096 #include <linux/capability.h>
71097 #include <linux/slab.h>
71098 #include <linux/err.h>
71099 +#include <linux/grsecurity.h>
71100
71101 struct linux_binprm;
71102 struct cred;
71103 diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h
71104 index 68a04a3..866e6a1 100644
71105 --- a/include/linux/seq_file.h
71106 +++ b/include/linux/seq_file.h
71107 @@ -26,6 +26,9 @@ struct seq_file {
71108 struct mutex lock;
71109 const struct seq_operations *op;
71110 int poll_event;
71111 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
71112 + u64 exec_id;
71113 +#endif
71114 #ifdef CONFIG_USER_NS
71115 struct user_namespace *user_ns;
71116 #endif
71117 @@ -38,6 +41,7 @@ struct seq_operations {
71118 void * (*next) (struct seq_file *m, void *v, loff_t *pos);
71119 int (*show) (struct seq_file *m, void *v);
71120 };
71121 +typedef struct seq_operations __no_const seq_operations_no_const;
71122
71123 #define SEQ_SKIP 1
71124
71125 diff --git a/include/linux/shm.h b/include/linux/shm.h
71126 index 429c199..4d42e38 100644
71127 --- a/include/linux/shm.h
71128 +++ b/include/linux/shm.h
71129 @@ -21,6 +21,10 @@ struct shmid_kernel /* private to the kernel */
71130
71131 /* The task created the shm object. NULL if the task is dead. */
71132 struct task_struct *shm_creator;
71133 +#ifdef CONFIG_GRKERNSEC
71134 + time_t shm_createtime;
71135 + pid_t shm_lapid;
71136 +#endif
71137 };
71138
71139 /* shm_mode upper byte flags */
71140 diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
71141 index b8292d8..96db310 100644
71142 --- a/include/linux/skbuff.h
71143 +++ b/include/linux/skbuff.h
71144 @@ -599,7 +599,7 @@ extern bool skb_try_coalesce(struct sk_buff *to, struct sk_buff *from,
71145 extern struct sk_buff *__alloc_skb(unsigned int size,
71146 gfp_t priority, int flags, int node);
71147 extern struct sk_buff *build_skb(void *data, unsigned int frag_size);
71148 -static inline struct sk_buff *alloc_skb(unsigned int size,
71149 +static inline struct sk_buff * __intentional_overflow(0) alloc_skb(unsigned int size,
71150 gfp_t priority)
71151 {
71152 return __alloc_skb(size, priority, 0, NUMA_NO_NODE);
71153 @@ -709,7 +709,7 @@ static inline struct skb_shared_hwtstamps *skb_hwtstamps(struct sk_buff *skb)
71154 */
71155 static inline int skb_queue_empty(const struct sk_buff_head *list)
71156 {
71157 - return list->next == (struct sk_buff *)list;
71158 + return list->next == (const struct sk_buff *)list;
71159 }
71160
71161 /**
71162 @@ -722,7 +722,7 @@ static inline int skb_queue_empty(const struct sk_buff_head *list)
71163 static inline bool skb_queue_is_last(const struct sk_buff_head *list,
71164 const struct sk_buff *skb)
71165 {
71166 - return skb->next == (struct sk_buff *)list;
71167 + return skb->next == (const struct sk_buff *)list;
71168 }
71169
71170 /**
71171 @@ -735,7 +735,7 @@ static inline bool skb_queue_is_last(const struct sk_buff_head *list,
71172 static inline bool skb_queue_is_first(const struct sk_buff_head *list,
71173 const struct sk_buff *skb)
71174 {
71175 - return skb->prev == (struct sk_buff *)list;
71176 + return skb->prev == (const struct sk_buff *)list;
71177 }
71178
71179 /**
71180 @@ -1756,7 +1756,7 @@ static inline int pskb_network_may_pull(struct sk_buff *skb, unsigned int len)
71181 * NET_IP_ALIGN(2) + ethernet_header(14) + IP_header(20/40) + ports(8)
71182 */
71183 #ifndef NET_SKB_PAD
71184 -#define NET_SKB_PAD max(32, L1_CACHE_BYTES)
71185 +#define NET_SKB_PAD max(_AC(32,UL), L1_CACHE_BYTES)
71186 #endif
71187
71188 extern int ___pskb_trim(struct sk_buff *skb, unsigned int len);
71189 @@ -2351,7 +2351,7 @@ extern struct sk_buff *skb_recv_datagram(struct sock *sk, unsigned flags,
71190 int noblock, int *err);
71191 extern unsigned int datagram_poll(struct file *file, struct socket *sock,
71192 struct poll_table_struct *wait);
71193 -extern int skb_copy_datagram_iovec(const struct sk_buff *from,
71194 +extern int __intentional_overflow(0) skb_copy_datagram_iovec(const struct sk_buff *from,
71195 int offset, struct iovec *to,
71196 int size);
71197 extern int skb_copy_and_csum_datagram_iovec(struct sk_buff *skb,
71198 @@ -2641,6 +2641,9 @@ static inline void nf_reset(struct sk_buff *skb)
71199 nf_bridge_put(skb->nf_bridge);
71200 skb->nf_bridge = NULL;
71201 #endif
71202 +#if IS_ENABLED(CONFIG_NETFILTER_XT_TARGET_TRACE)
71203 + skb->nf_trace = 0;
71204 +#endif
71205 }
71206
71207 static inline void nf_reset_trace(struct sk_buff *skb)
71208 diff --git a/include/linux/slab.h b/include/linux/slab.h
71209 index 5d168d7..720bff3 100644
71210 --- a/include/linux/slab.h
71211 +++ b/include/linux/slab.h
71212 @@ -12,13 +12,20 @@
71213 #include <linux/gfp.h>
71214 #include <linux/types.h>
71215 #include <linux/workqueue.h>
71216 -
71217 +#include <linux/err.h>
71218
71219 /*
71220 * Flags to pass to kmem_cache_create().
71221 * The ones marked DEBUG are only valid if CONFIG_SLAB_DEBUG is set.
71222 */
71223 #define SLAB_DEBUG_FREE 0x00000100UL /* DEBUG: Perform (expensive) checks on free */
71224 +
71225 +#ifdef CONFIG_PAX_USERCOPY_SLABS
71226 +#define SLAB_USERCOPY 0x00000200UL /* PaX: Allow copying objs to/from userland */
71227 +#else
71228 +#define SLAB_USERCOPY 0x00000000UL
71229 +#endif
71230 +
71231 #define SLAB_RED_ZONE 0x00000400UL /* DEBUG: Red zone objs in a cache */
71232 #define SLAB_POISON 0x00000800UL /* DEBUG: Poison objects */
71233 #define SLAB_HWCACHE_ALIGN 0x00002000UL /* Align objs on cache lines */
71234 @@ -89,10 +96,13 @@
71235 * ZERO_SIZE_PTR can be passed to kfree though in the same way that NULL can.
71236 * Both make kfree a no-op.
71237 */
71238 -#define ZERO_SIZE_PTR ((void *)16)
71239 +#define ZERO_SIZE_PTR \
71240 +({ \
71241 + BUILD_BUG_ON(!(MAX_ERRNO & ~PAGE_MASK));\
71242 + (void *)(-MAX_ERRNO-1L); \
71243 +})
71244
71245 -#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) <= \
71246 - (unsigned long)ZERO_SIZE_PTR)
71247 +#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) - 1 >= (unsigned long)ZERO_SIZE_PTR - 1)
71248
71249 /*
71250 * Common fields provided in kmem_cache by all slab allocators
71251 @@ -112,7 +122,7 @@ struct kmem_cache {
71252 unsigned int align; /* Alignment as calculated */
71253 unsigned long flags; /* Active flags on the slab */
71254 const char *name; /* Slab name for sysfs */
71255 - int refcount; /* Use counter */
71256 + atomic_t refcount; /* Use counter */
71257 void (*ctor)(void *); /* Called on object slot creation */
71258 struct list_head list; /* List of all slab caches on the system */
71259 };
71260 @@ -232,6 +242,8 @@ void * __must_check krealloc(const void *, size_t, gfp_t);
71261 void kfree(const void *);
71262 void kzfree(const void *);
71263 size_t ksize(const void *);
71264 +const char *check_heap_object(const void *ptr, unsigned long n);
71265 +bool is_usercopy_object(const void *ptr);
71266
71267 /*
71268 * Allocator specific definitions. These are mainly used to establish optimized
71269 @@ -311,6 +323,7 @@ size_t ksize(const void *);
71270 * for general use, and so are not documented here. For a full list of
71271 * potential flags, always refer to linux/gfp.h.
71272 */
71273 +
71274 static inline void *kmalloc_array(size_t n, size_t size, gfp_t flags)
71275 {
71276 if (size != 0 && n > SIZE_MAX / size)
71277 @@ -370,7 +383,7 @@ static inline void *kmem_cache_alloc_node(struct kmem_cache *cachep,
71278 #if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB) || \
71279 (defined(CONFIG_SLAB) && defined(CONFIG_TRACING)) || \
71280 (defined(CONFIG_SLOB) && defined(CONFIG_TRACING))
71281 -extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long);
71282 +extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long) __size_overflow(1);
71283 #define kmalloc_track_caller(size, flags) \
71284 __kmalloc_track_caller(size, flags, _RET_IP_)
71285 #else
71286 @@ -390,7 +403,7 @@ extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long);
71287 #if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB) || \
71288 (defined(CONFIG_SLAB) && defined(CONFIG_TRACING)) || \
71289 (defined(CONFIG_SLOB) && defined(CONFIG_TRACING))
71290 -extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, unsigned long);
71291 +extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, unsigned long) __size_overflow(1);
71292 #define kmalloc_node_track_caller(size, flags, node) \
71293 __kmalloc_node_track_caller(size, flags, node, \
71294 _RET_IP_)
71295 diff --git a/include/linux/slab_def.h b/include/linux/slab_def.h
71296 index 8bb6e0e..8eb0dbe 100644
71297 --- a/include/linux/slab_def.h
71298 +++ b/include/linux/slab_def.h
71299 @@ -52,7 +52,7 @@ struct kmem_cache {
71300 /* 4) cache creation/removal */
71301 const char *name;
71302 struct list_head list;
71303 - int refcount;
71304 + atomic_t refcount;
71305 int object_size;
71306 int align;
71307
71308 @@ -68,10 +68,10 @@ struct kmem_cache {
71309 unsigned long node_allocs;
71310 unsigned long node_frees;
71311 unsigned long node_overflow;
71312 - atomic_t allochit;
71313 - atomic_t allocmiss;
71314 - atomic_t freehit;
71315 - atomic_t freemiss;
71316 + atomic_unchecked_t allochit;
71317 + atomic_unchecked_t allocmiss;
71318 + atomic_unchecked_t freehit;
71319 + atomic_unchecked_t freemiss;
71320
71321 /*
71322 * If debugging is enabled, then the allocator can add additional
71323 @@ -111,11 +111,16 @@ struct cache_sizes {
71324 #ifdef CONFIG_ZONE_DMA
71325 struct kmem_cache *cs_dmacachep;
71326 #endif
71327 +
71328 +#ifdef CONFIG_PAX_USERCOPY_SLABS
71329 + struct kmem_cache *cs_usercopycachep;
71330 +#endif
71331 +
71332 };
71333 extern struct cache_sizes malloc_sizes[];
71334
71335 void *kmem_cache_alloc(struct kmem_cache *, gfp_t);
71336 -void *__kmalloc(size_t size, gfp_t flags);
71337 +void *__kmalloc(size_t size, gfp_t flags) __size_overflow(1);
71338
71339 #ifdef CONFIG_TRACING
71340 extern void *kmem_cache_alloc_trace(struct kmem_cache *, gfp_t, size_t);
71341 @@ -152,6 +157,13 @@ found:
71342 cachep = malloc_sizes[i].cs_dmacachep;
71343 else
71344 #endif
71345 +
71346 +#ifdef CONFIG_PAX_USERCOPY_SLABS
71347 + if (flags & GFP_USERCOPY)
71348 + cachep = malloc_sizes[i].cs_usercopycachep;
71349 + else
71350 +#endif
71351 +
71352 cachep = malloc_sizes[i].cs_cachep;
71353
71354 ret = kmem_cache_alloc_trace(cachep, flags, size);
71355 @@ -162,7 +174,7 @@ found:
71356 }
71357
71358 #ifdef CONFIG_NUMA
71359 -extern void *__kmalloc_node(size_t size, gfp_t flags, int node);
71360 +extern void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
71361 extern void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
71362
71363 #ifdef CONFIG_TRACING
71364 @@ -205,6 +217,13 @@ found:
71365 cachep = malloc_sizes[i].cs_dmacachep;
71366 else
71367 #endif
71368 +
71369 +#ifdef CONFIG_PAX_USERCOPY_SLABS
71370 + if (flags & GFP_USERCOPY)
71371 + cachep = malloc_sizes[i].cs_usercopycachep;
71372 + else
71373 +#endif
71374 +
71375 cachep = malloc_sizes[i].cs_cachep;
71376
71377 return kmem_cache_alloc_node_trace(cachep, flags, node, size);
71378 diff --git a/include/linux/slob_def.h b/include/linux/slob_def.h
71379 index f28e14a..7831211 100644
71380 --- a/include/linux/slob_def.h
71381 +++ b/include/linux/slob_def.h
71382 @@ -11,7 +11,7 @@ static __always_inline void *kmem_cache_alloc(struct kmem_cache *cachep,
71383 return kmem_cache_alloc_node(cachep, flags, NUMA_NO_NODE);
71384 }
71385
71386 -void *__kmalloc_node(size_t size, gfp_t flags, int node);
71387 +void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
71388
71389 static __always_inline void *kmalloc_node(size_t size, gfp_t flags, int node)
71390 {
71391 @@ -31,7 +31,7 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
71392 return __kmalloc_node(size, flags, NUMA_NO_NODE);
71393 }
71394
71395 -static __always_inline void *__kmalloc(size_t size, gfp_t flags)
71396 +static __always_inline __size_overflow(1) void *__kmalloc(size_t size, gfp_t flags)
71397 {
71398 return kmalloc(size, flags);
71399 }
71400 diff --git a/include/linux/slub_def.h b/include/linux/slub_def.h
71401 index 9db4825..ed42fb5 100644
71402 --- a/include/linux/slub_def.h
71403 +++ b/include/linux/slub_def.h
71404 @@ -91,7 +91,7 @@ struct kmem_cache {
71405 struct kmem_cache_order_objects max;
71406 struct kmem_cache_order_objects min;
71407 gfp_t allocflags; /* gfp flags to use on each alloc */
71408 - int refcount; /* Refcount for slab cache destroy */
71409 + atomic_t refcount; /* Refcount for slab cache destroy */
71410 void (*ctor)(void *);
71411 int inuse; /* Offset to metadata */
71412 int align; /* Alignment */
71413 @@ -156,7 +156,7 @@ extern struct kmem_cache *kmalloc_caches[SLUB_PAGE_SHIFT];
71414 * Sorry that the following has to be that ugly but some versions of GCC
71415 * have trouble with constant propagation and loops.
71416 */
71417 -static __always_inline int kmalloc_index(size_t size)
71418 +static __always_inline __size_overflow(1) int kmalloc_index(size_t size)
71419 {
71420 if (!size)
71421 return 0;
71422 @@ -221,7 +221,7 @@ static __always_inline struct kmem_cache *kmalloc_slab(size_t size)
71423 }
71424
71425 void *kmem_cache_alloc(struct kmem_cache *, gfp_t);
71426 -void *__kmalloc(size_t size, gfp_t flags);
71427 +void *__kmalloc(size_t size, gfp_t flags) __alloc_size(1) __size_overflow(1);
71428
71429 static __always_inline void *
71430 kmalloc_order(size_t size, gfp_t flags, unsigned int order)
71431 @@ -265,7 +265,7 @@ kmalloc_order_trace(size_t size, gfp_t flags, unsigned int order)
71432 }
71433 #endif
71434
71435 -static __always_inline void *kmalloc_large(size_t size, gfp_t flags)
71436 +static __always_inline __size_overflow(1) void *kmalloc_large(size_t size, gfp_t flags)
71437 {
71438 unsigned int order = get_order(size);
71439 return kmalloc_order_trace(size, flags, order);
71440 @@ -290,7 +290,7 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
71441 }
71442
71443 #ifdef CONFIG_NUMA
71444 -void *__kmalloc_node(size_t size, gfp_t flags, int node);
71445 +void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
71446 void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
71447
71448 #ifdef CONFIG_TRACING
71449 diff --git a/include/linux/sock_diag.h b/include/linux/sock_diag.h
71450 index e8d702e..0a56eb4 100644
71451 --- a/include/linux/sock_diag.h
71452 +++ b/include/linux/sock_diag.h
71453 @@ -10,7 +10,7 @@ struct sock;
71454 struct sock_diag_handler {
71455 __u8 family;
71456 int (*dump)(struct sk_buff *skb, struct nlmsghdr *nlh);
71457 -};
71458 +} __do_const;
71459
71460 int sock_diag_register(const struct sock_diag_handler *h);
71461 void sock_diag_unregister(const struct sock_diag_handler *h);
71462 diff --git a/include/linux/sonet.h b/include/linux/sonet.h
71463 index 680f9a3..f13aeb0 100644
71464 --- a/include/linux/sonet.h
71465 +++ b/include/linux/sonet.h
71466 @@ -7,7 +7,7 @@
71467 #include <uapi/linux/sonet.h>
71468
71469 struct k_sonet_stats {
71470 -#define __HANDLE_ITEM(i) atomic_t i
71471 +#define __HANDLE_ITEM(i) atomic_unchecked_t i
71472 __SONET_ITEMS
71473 #undef __HANDLE_ITEM
71474 };
71475 diff --git a/include/linux/sunrpc/addr.h b/include/linux/sunrpc/addr.h
71476 index 07d8e53..dc934c9 100644
71477 --- a/include/linux/sunrpc/addr.h
71478 +++ b/include/linux/sunrpc/addr.h
71479 @@ -23,9 +23,9 @@ static inline unsigned short rpc_get_port(const struct sockaddr *sap)
71480 {
71481 switch (sap->sa_family) {
71482 case AF_INET:
71483 - return ntohs(((struct sockaddr_in *)sap)->sin_port);
71484 + return ntohs(((const struct sockaddr_in *)sap)->sin_port);
71485 case AF_INET6:
71486 - return ntohs(((struct sockaddr_in6 *)sap)->sin6_port);
71487 + return ntohs(((const struct sockaddr_in6 *)sap)->sin6_port);
71488 }
71489 return 0;
71490 }
71491 @@ -58,7 +58,7 @@ static inline bool __rpc_cmp_addr4(const struct sockaddr *sap1,
71492 static inline bool __rpc_copy_addr4(struct sockaddr *dst,
71493 const struct sockaddr *src)
71494 {
71495 - const struct sockaddr_in *ssin = (struct sockaddr_in *) src;
71496 + const struct sockaddr_in *ssin = (const struct sockaddr_in *) src;
71497 struct sockaddr_in *dsin = (struct sockaddr_in *) dst;
71498
71499 dsin->sin_family = ssin->sin_family;
71500 @@ -164,7 +164,7 @@ static inline u32 rpc_get_scope_id(const struct sockaddr *sa)
71501 if (sa->sa_family != AF_INET6)
71502 return 0;
71503
71504 - return ((struct sockaddr_in6 *) sa)->sin6_scope_id;
71505 + return ((const struct sockaddr_in6 *) sa)->sin6_scope_id;
71506 }
71507
71508 #endif /* _LINUX_SUNRPC_ADDR_H */
71509 diff --git a/include/linux/sunrpc/clnt.h b/include/linux/sunrpc/clnt.h
71510 index 2cf4ffa..470d140 100644
71511 --- a/include/linux/sunrpc/clnt.h
71512 +++ b/include/linux/sunrpc/clnt.h
71513 @@ -96,7 +96,7 @@ struct rpc_procinfo {
71514 unsigned int p_timer; /* Which RTT timer to use */
71515 u32 p_statidx; /* Which procedure to account */
71516 const char * p_name; /* name of procedure */
71517 -};
71518 +} __do_const;
71519
71520 #ifdef __KERNEL__
71521
71522 diff --git a/include/linux/sunrpc/svc.h b/include/linux/sunrpc/svc.h
71523 index 1f0216b..6a4fa50 100644
71524 --- a/include/linux/sunrpc/svc.h
71525 +++ b/include/linux/sunrpc/svc.h
71526 @@ -411,7 +411,7 @@ struct svc_procedure {
71527 unsigned int pc_count; /* call count */
71528 unsigned int pc_cachetype; /* cache info (NFS) */
71529 unsigned int pc_xdrressize; /* maximum size of XDR reply */
71530 -};
71531 +} __do_const;
71532
71533 /*
71534 * Function prototypes.
71535 diff --git a/include/linux/sunrpc/svc_rdma.h b/include/linux/sunrpc/svc_rdma.h
71536 index 0b8e3e6..33e0a01 100644
71537 --- a/include/linux/sunrpc/svc_rdma.h
71538 +++ b/include/linux/sunrpc/svc_rdma.h
71539 @@ -53,15 +53,15 @@ extern unsigned int svcrdma_ord;
71540 extern unsigned int svcrdma_max_requests;
71541 extern unsigned int svcrdma_max_req_size;
71542
71543 -extern atomic_t rdma_stat_recv;
71544 -extern atomic_t rdma_stat_read;
71545 -extern atomic_t rdma_stat_write;
71546 -extern atomic_t rdma_stat_sq_starve;
71547 -extern atomic_t rdma_stat_rq_starve;
71548 -extern atomic_t rdma_stat_rq_poll;
71549 -extern atomic_t rdma_stat_rq_prod;
71550 -extern atomic_t rdma_stat_sq_poll;
71551 -extern atomic_t rdma_stat_sq_prod;
71552 +extern atomic_unchecked_t rdma_stat_recv;
71553 +extern atomic_unchecked_t rdma_stat_read;
71554 +extern atomic_unchecked_t rdma_stat_write;
71555 +extern atomic_unchecked_t rdma_stat_sq_starve;
71556 +extern atomic_unchecked_t rdma_stat_rq_starve;
71557 +extern atomic_unchecked_t rdma_stat_rq_poll;
71558 +extern atomic_unchecked_t rdma_stat_rq_prod;
71559 +extern atomic_unchecked_t rdma_stat_sq_poll;
71560 +extern atomic_unchecked_t rdma_stat_sq_prod;
71561
71562 #define RPCRDMA_VERSION 1
71563
71564 diff --git a/include/linux/sunrpc/svcauth.h b/include/linux/sunrpc/svcauth.h
71565 index ff374ab..7fd2ecb 100644
71566 --- a/include/linux/sunrpc/svcauth.h
71567 +++ b/include/linux/sunrpc/svcauth.h
71568 @@ -109,7 +109,7 @@ struct auth_ops {
71569 int (*release)(struct svc_rqst *rq);
71570 void (*domain_release)(struct auth_domain *);
71571 int (*set_client)(struct svc_rqst *rq);
71572 -};
71573 +} __do_const;
71574
71575 #define SVC_GARBAGE 1
71576 #define SVC_SYSERR 2
71577 diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h
71578 index a5ffd32..0935dea 100644
71579 --- a/include/linux/swiotlb.h
71580 +++ b/include/linux/swiotlb.h
71581 @@ -60,7 +60,8 @@ extern void
71582
71583 extern void
71584 swiotlb_free_coherent(struct device *hwdev, size_t size,
71585 - void *vaddr, dma_addr_t dma_handle);
71586 + void *vaddr, dma_addr_t dma_handle,
71587 + struct dma_attrs *attrs);
71588
71589 extern dma_addr_t swiotlb_map_page(struct device *dev, struct page *page,
71590 unsigned long offset, size_t size,
71591 diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
71592 index 313a8e0..6b273a9 100644
71593 --- a/include/linux/syscalls.h
71594 +++ b/include/linux/syscalls.h
71595 @@ -418,11 +418,11 @@ asmlinkage long sys_sync(void);
71596 asmlinkage long sys_fsync(unsigned int fd);
71597 asmlinkage long sys_fdatasync(unsigned int fd);
71598 asmlinkage long sys_bdflush(int func, long data);
71599 -asmlinkage long sys_mount(char __user *dev_name, char __user *dir_name,
71600 - char __user *type, unsigned long flags,
71601 +asmlinkage long sys_mount(const char __user *dev_name, const char __user *dir_name,
71602 + const char __user *type, unsigned long flags,
71603 void __user *data);
71604 -asmlinkage long sys_umount(char __user *name, int flags);
71605 -asmlinkage long sys_oldumount(char __user *name);
71606 +asmlinkage long sys_umount(const char __user *name, int flags);
71607 +asmlinkage long sys_oldumount(const char __user *name);
71608 asmlinkage long sys_truncate(const char __user *path, long length);
71609 asmlinkage long sys_ftruncate(unsigned int fd, unsigned long length);
71610 asmlinkage long sys_stat(const char __user *filename,
71611 @@ -634,7 +634,7 @@ asmlinkage long sys_getsockname(int, struct sockaddr __user *, int __user *);
71612 asmlinkage long sys_getpeername(int, struct sockaddr __user *, int __user *);
71613 asmlinkage long sys_send(int, void __user *, size_t, unsigned);
71614 asmlinkage long sys_sendto(int, void __user *, size_t, unsigned,
71615 - struct sockaddr __user *, int);
71616 + struct sockaddr __user *, int) __intentional_overflow(0);
71617 asmlinkage long sys_sendmsg(int fd, struct msghdr __user *msg, unsigned flags);
71618 asmlinkage long sys_sendmmsg(int fd, struct mmsghdr __user *msg,
71619 unsigned int vlen, unsigned flags);
71620 diff --git a/include/linux/syscore_ops.h b/include/linux/syscore_ops.h
71621 index 27b3b0b..e093dd9 100644
71622 --- a/include/linux/syscore_ops.h
71623 +++ b/include/linux/syscore_ops.h
71624 @@ -16,7 +16,7 @@ struct syscore_ops {
71625 int (*suspend)(void);
71626 void (*resume)(void);
71627 void (*shutdown)(void);
71628 -};
71629 +} __do_const;
71630
71631 extern void register_syscore_ops(struct syscore_ops *ops);
71632 extern void unregister_syscore_ops(struct syscore_ops *ops);
71633 diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
71634 index 14a8ff2..af52bad 100644
71635 --- a/include/linux/sysctl.h
71636 +++ b/include/linux/sysctl.h
71637 @@ -34,13 +34,13 @@ struct ctl_table_root;
71638 struct ctl_table_header;
71639 struct ctl_dir;
71640
71641 -typedef struct ctl_table ctl_table;
71642 -
71643 typedef int proc_handler (struct ctl_table *ctl, int write,
71644 void __user *buffer, size_t *lenp, loff_t *ppos);
71645
71646 extern int proc_dostring(struct ctl_table *, int,
71647 void __user *, size_t *, loff_t *);
71648 +extern int proc_dostring_modpriv(struct ctl_table *, int,
71649 + void __user *, size_t *, loff_t *);
71650 extern int proc_dointvec(struct ctl_table *, int,
71651 void __user *, size_t *, loff_t *);
71652 extern int proc_dointvec_minmax(struct ctl_table *, int,
71653 @@ -115,7 +115,9 @@ struct ctl_table
71654 struct ctl_table_poll *poll;
71655 void *extra1;
71656 void *extra2;
71657 -};
71658 +} __do_const;
71659 +typedef struct ctl_table __no_const ctl_table_no_const;
71660 +typedef struct ctl_table ctl_table;
71661
71662 struct ctl_node {
71663 struct rb_node node;
71664 diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
71665 index e2cee22..3ddb921 100644
71666 --- a/include/linux/sysfs.h
71667 +++ b/include/linux/sysfs.h
71668 @@ -31,7 +31,8 @@ struct attribute {
71669 struct lock_class_key *key;
71670 struct lock_class_key skey;
71671 #endif
71672 -};
71673 +} __do_const;
71674 +typedef struct attribute __no_const attribute_no_const;
71675
71676 /**
71677 * sysfs_attr_init - initialize a dynamically allocated sysfs attribute
71678 @@ -59,8 +60,8 @@ struct attribute_group {
71679 umode_t (*is_visible)(struct kobject *,
71680 struct attribute *, int);
71681 struct attribute **attrs;
71682 -};
71683 -
71684 +} __do_const;
71685 +typedef struct attribute_group __no_const attribute_group_no_const;
71686
71687
71688 /**
71689 @@ -107,7 +108,8 @@ struct bin_attribute {
71690 char *, loff_t, size_t);
71691 int (*mmap)(struct file *, struct kobject *, struct bin_attribute *attr,
71692 struct vm_area_struct *vma);
71693 -};
71694 +} __do_const;
71695 +typedef struct bin_attribute __no_const bin_attribute_no_const;
71696
71697 /**
71698 * sysfs_bin_attr_init - initialize a dynamically allocated bin_attribute
71699 diff --git a/include/linux/sysrq.h b/include/linux/sysrq.h
71700 index 7faf933..9b85a0c 100644
71701 --- a/include/linux/sysrq.h
71702 +++ b/include/linux/sysrq.h
71703 @@ -16,6 +16,7 @@
71704
71705 #include <linux/errno.h>
71706 #include <linux/types.h>
71707 +#include <linux/compiler.h>
71708
71709 /* Enable/disable SYSRQ support by default (0==no, 1==yes). */
71710 #define SYSRQ_DEFAULT_ENABLE 1
71711 @@ -36,7 +37,7 @@ struct sysrq_key_op {
71712 char *help_msg;
71713 char *action_msg;
71714 int enable_mask;
71715 -};
71716 +} __do_const;
71717
71718 #ifdef CONFIG_MAGIC_SYSRQ
71719
71720 diff --git a/include/linux/thread_info.h b/include/linux/thread_info.h
71721 index e7e0473..7989295 100644
71722 --- a/include/linux/thread_info.h
71723 +++ b/include/linux/thread_info.h
71724 @@ -148,6 +148,15 @@ static inline bool test_and_clear_restore_sigmask(void)
71725 #error "no set_restore_sigmask() provided and default one won't work"
71726 #endif
71727
71728 +extern void __check_object_size(const void *ptr, unsigned long n, bool to_user);
71729 +static inline void check_object_size(const void *ptr, unsigned long n, bool to_user)
71730 +{
71731 +#ifndef CONFIG_PAX_USERCOPY_DEBUG
71732 + if (!__builtin_constant_p(n))
71733 +#endif
71734 + __check_object_size(ptr, n, to_user);
71735 +}
71736 +
71737 #endif /* __KERNEL__ */
71738
71739 #endif /* _LINUX_THREAD_INFO_H */
71740 diff --git a/include/linux/tty.h b/include/linux/tty.h
71741 index c75d886..04cb148 100644
71742 --- a/include/linux/tty.h
71743 +++ b/include/linux/tty.h
71744 @@ -194,7 +194,7 @@ struct tty_port {
71745 const struct tty_port_operations *ops; /* Port operations */
71746 spinlock_t lock; /* Lock protecting tty field */
71747 int blocked_open; /* Waiting to open */
71748 - int count; /* Usage count */
71749 + atomic_t count; /* Usage count */
71750 wait_queue_head_t open_wait; /* Open waiters */
71751 wait_queue_head_t close_wait; /* Close waiters */
71752 wait_queue_head_t delta_msr_wait; /* Modem status change */
71753 @@ -515,7 +515,7 @@ extern int tty_port_open(struct tty_port *port,
71754 struct tty_struct *tty, struct file *filp);
71755 static inline int tty_port_users(struct tty_port *port)
71756 {
71757 - return port->count + port->blocked_open;
71758 + return atomic_read(&port->count) + port->blocked_open;
71759 }
71760
71761 extern int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc);
71762 diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h
71763 index 756a609..b302dd6 100644
71764 --- a/include/linux/tty_driver.h
71765 +++ b/include/linux/tty_driver.h
71766 @@ -285,7 +285,7 @@ struct tty_operations {
71767 void (*poll_put_char)(struct tty_driver *driver, int line, char ch);
71768 #endif
71769 const struct file_operations *proc_fops;
71770 -};
71771 +} __do_const;
71772
71773 struct tty_driver {
71774 int magic; /* magic number for this structure */
71775 diff --git a/include/linux/tty_ldisc.h b/include/linux/tty_ldisc.h
71776 index 455a0d7..bf97ff5 100644
71777 --- a/include/linux/tty_ldisc.h
71778 +++ b/include/linux/tty_ldisc.h
71779 @@ -146,7 +146,7 @@ struct tty_ldisc_ops {
71780
71781 struct module *owner;
71782
71783 - int refcount;
71784 + atomic_t refcount;
71785 };
71786
71787 struct tty_ldisc {
71788 diff --git a/include/linux/types.h b/include/linux/types.h
71789 index 4d118ba..c3ee9bf 100644
71790 --- a/include/linux/types.h
71791 +++ b/include/linux/types.h
71792 @@ -176,10 +176,26 @@ typedef struct {
71793 int counter;
71794 } atomic_t;
71795
71796 +#ifdef CONFIG_PAX_REFCOUNT
71797 +typedef struct {
71798 + int counter;
71799 +} atomic_unchecked_t;
71800 +#else
71801 +typedef atomic_t atomic_unchecked_t;
71802 +#endif
71803 +
71804 #ifdef CONFIG_64BIT
71805 typedef struct {
71806 long counter;
71807 } atomic64_t;
71808 +
71809 +#ifdef CONFIG_PAX_REFCOUNT
71810 +typedef struct {
71811 + long counter;
71812 +} atomic64_unchecked_t;
71813 +#else
71814 +typedef atomic64_t atomic64_unchecked_t;
71815 +#endif
71816 #endif
71817
71818 struct list_head {
71819 diff --git a/include/linux/uaccess.h b/include/linux/uaccess.h
71820 index 5ca0951..ab496a5 100644
71821 --- a/include/linux/uaccess.h
71822 +++ b/include/linux/uaccess.h
71823 @@ -76,11 +76,11 @@ static inline unsigned long __copy_from_user_nocache(void *to,
71824 long ret; \
71825 mm_segment_t old_fs = get_fs(); \
71826 \
71827 - set_fs(KERNEL_DS); \
71828 pagefault_disable(); \
71829 - ret = __copy_from_user_inatomic(&(retval), (__force typeof(retval) __user *)(addr), sizeof(retval)); \
71830 - pagefault_enable(); \
71831 + set_fs(KERNEL_DS); \
71832 + ret = __copy_from_user_inatomic(&(retval), (typeof(retval) __force_user *)(addr), sizeof(retval)); \
71833 set_fs(old_fs); \
71834 + pagefault_enable(); \
71835 ret; \
71836 })
71837
71838 diff --git a/include/linux/uidgid.h b/include/linux/uidgid.h
71839 index 8e522cbc..aa8572d 100644
71840 --- a/include/linux/uidgid.h
71841 +++ b/include/linux/uidgid.h
71842 @@ -197,4 +197,9 @@ static inline bool kgid_has_mapping(struct user_namespace *ns, kgid_t gid)
71843
71844 #endif /* CONFIG_USER_NS */
71845
71846 +#define GR_GLOBAL_UID(x) from_kuid_munged(&init_user_ns, (x))
71847 +#define GR_GLOBAL_GID(x) from_kgid_munged(&init_user_ns, (x))
71848 +#define gr_is_global_root(x) uid_eq((x), GLOBAL_ROOT_UID)
71849 +#define gr_is_global_nonroot(x) (!uid_eq((x), GLOBAL_ROOT_UID))
71850 +
71851 #endif /* _LINUX_UIDGID_H */
71852 diff --git a/include/linux/unaligned/access_ok.h b/include/linux/unaligned/access_ok.h
71853 index 99c1b4d..562e6f3 100644
71854 --- a/include/linux/unaligned/access_ok.h
71855 +++ b/include/linux/unaligned/access_ok.h
71856 @@ -4,34 +4,34 @@
71857 #include <linux/kernel.h>
71858 #include <asm/byteorder.h>
71859
71860 -static inline u16 get_unaligned_le16(const void *p)
71861 +static inline u16 __intentional_overflow(-1) get_unaligned_le16(const void *p)
71862 {
71863 - return le16_to_cpup((__le16 *)p);
71864 + return le16_to_cpup((const __le16 *)p);
71865 }
71866
71867 -static inline u32 get_unaligned_le32(const void *p)
71868 +static inline u32 __intentional_overflow(-1) get_unaligned_le32(const void *p)
71869 {
71870 - return le32_to_cpup((__le32 *)p);
71871 + return le32_to_cpup((const __le32 *)p);
71872 }
71873
71874 -static inline u64 get_unaligned_le64(const void *p)
71875 +static inline u64 __intentional_overflow(-1) get_unaligned_le64(const void *p)
71876 {
71877 - return le64_to_cpup((__le64 *)p);
71878 + return le64_to_cpup((const __le64 *)p);
71879 }
71880
71881 -static inline u16 get_unaligned_be16(const void *p)
71882 +static inline u16 __intentional_overflow(-1) get_unaligned_be16(const void *p)
71883 {
71884 - return be16_to_cpup((__be16 *)p);
71885 + return be16_to_cpup((const __be16 *)p);
71886 }
71887
71888 -static inline u32 get_unaligned_be32(const void *p)
71889 +static inline u32 __intentional_overflow(-1) get_unaligned_be32(const void *p)
71890 {
71891 - return be32_to_cpup((__be32 *)p);
71892 + return be32_to_cpup((const __be32 *)p);
71893 }
71894
71895 -static inline u64 get_unaligned_be64(const void *p)
71896 +static inline u64 __intentional_overflow(-1) get_unaligned_be64(const void *p)
71897 {
71898 - return be64_to_cpup((__be64 *)p);
71899 + return be64_to_cpup((const __be64 *)p);
71900 }
71901
71902 static inline void put_unaligned_le16(u16 val, void *p)
71903 diff --git a/include/linux/usb.h b/include/linux/usb.h
71904 index 4d22d0f..8d0e8f8 100644
71905 --- a/include/linux/usb.h
71906 +++ b/include/linux/usb.h
71907 @@ -554,7 +554,7 @@ struct usb_device {
71908 int maxchild;
71909
71910 u32 quirks;
71911 - atomic_t urbnum;
71912 + atomic_unchecked_t urbnum;
71913
71914 unsigned long active_duration;
71915
71916 @@ -1604,7 +1604,7 @@ void usb_buffer_unmap_sg(const struct usb_device *dev, int is_in,
71917
71918 extern int usb_control_msg(struct usb_device *dev, unsigned int pipe,
71919 __u8 request, __u8 requesttype, __u16 value, __u16 index,
71920 - void *data, __u16 size, int timeout);
71921 + void *data, __u16 size, int timeout) __intentional_overflow(-1);
71922 extern int usb_interrupt_msg(struct usb_device *usb_dev, unsigned int pipe,
71923 void *data, int len, int *actual_length, int timeout);
71924 extern int usb_bulk_msg(struct usb_device *usb_dev, unsigned int pipe,
71925 diff --git a/include/linux/usb/renesas_usbhs.h b/include/linux/usb/renesas_usbhs.h
71926 index c5d36c6..108f4f9 100644
71927 --- a/include/linux/usb/renesas_usbhs.h
71928 +++ b/include/linux/usb/renesas_usbhs.h
71929 @@ -39,7 +39,7 @@ enum {
71930 */
71931 struct renesas_usbhs_driver_callback {
71932 int (*notify_hotplug)(struct platform_device *pdev);
71933 -};
71934 +} __no_const;
71935
71936 /*
71937 * callback functions for platform
71938 diff --git a/include/linux/vermagic.h b/include/linux/vermagic.h
71939 index 6f8fbcf..8259001 100644
71940 --- a/include/linux/vermagic.h
71941 +++ b/include/linux/vermagic.h
71942 @@ -25,9 +25,35 @@
71943 #define MODULE_ARCH_VERMAGIC ""
71944 #endif
71945
71946 +#ifdef CONFIG_PAX_REFCOUNT
71947 +#define MODULE_PAX_REFCOUNT "REFCOUNT "
71948 +#else
71949 +#define MODULE_PAX_REFCOUNT ""
71950 +#endif
71951 +
71952 +#ifdef CONSTIFY_PLUGIN
71953 +#define MODULE_CONSTIFY_PLUGIN "CONSTIFY_PLUGIN "
71954 +#else
71955 +#define MODULE_CONSTIFY_PLUGIN ""
71956 +#endif
71957 +
71958 +#ifdef STACKLEAK_PLUGIN
71959 +#define MODULE_STACKLEAK_PLUGIN "STACKLEAK_PLUGIN "
71960 +#else
71961 +#define MODULE_STACKLEAK_PLUGIN ""
71962 +#endif
71963 +
71964 +#ifdef CONFIG_GRKERNSEC
71965 +#define MODULE_GRSEC "GRSEC "
71966 +#else
71967 +#define MODULE_GRSEC ""
71968 +#endif
71969 +
71970 #define VERMAGIC_STRING \
71971 UTS_RELEASE " " \
71972 MODULE_VERMAGIC_SMP MODULE_VERMAGIC_PREEMPT \
71973 MODULE_VERMAGIC_MODULE_UNLOAD MODULE_VERMAGIC_MODVERSIONS \
71974 - MODULE_ARCH_VERMAGIC
71975 + MODULE_ARCH_VERMAGIC \
71976 + MODULE_PAX_REFCOUNT MODULE_CONSTIFY_PLUGIN MODULE_STACKLEAK_PLUGIN \
71977 + MODULE_GRSEC
71978
71979 diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h
71980 index 6071e91..ca6a489 100644
71981 --- a/include/linux/vmalloc.h
71982 +++ b/include/linux/vmalloc.h
71983 @@ -14,6 +14,11 @@ struct vm_area_struct; /* vma defining user mapping in mm_types.h */
71984 #define VM_USERMAP 0x00000008 /* suitable for remap_vmalloc_range */
71985 #define VM_VPAGES 0x00000010 /* buffer for pages was vmalloc'ed */
71986 #define VM_UNLIST 0x00000020 /* vm_struct is not listed in vmlist */
71987 +
71988 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
71989 +#define VM_KERNEXEC 0x00000040 /* allocate from executable kernel memory range */
71990 +#endif
71991 +
71992 /* bits [20..32] reserved for arch specific ioremap internals */
71993
71994 /*
71995 @@ -62,7 +67,7 @@ extern void *vmalloc_32_user(unsigned long size);
71996 extern void *__vmalloc(unsigned long size, gfp_t gfp_mask, pgprot_t prot);
71997 extern void *__vmalloc_node_range(unsigned long size, unsigned long align,
71998 unsigned long start, unsigned long end, gfp_t gfp_mask,
71999 - pgprot_t prot, int node, const void *caller);
72000 + pgprot_t prot, int node, const void *caller) __size_overflow(1);
72001 extern void vfree(const void *addr);
72002
72003 extern void *vmap(struct page **pages, unsigned int count,
72004 @@ -124,8 +129,8 @@ extern struct vm_struct *alloc_vm_area(size_t size, pte_t **ptes);
72005 extern void free_vm_area(struct vm_struct *area);
72006
72007 /* for /dev/kmem */
72008 -extern long vread(char *buf, char *addr, unsigned long count);
72009 -extern long vwrite(char *buf, char *addr, unsigned long count);
72010 +extern long vread(char *buf, char *addr, unsigned long count) __size_overflow(3);
72011 +extern long vwrite(char *buf, char *addr, unsigned long count) __size_overflow(3);
72012
72013 /*
72014 * Internals. Dont't use..
72015 diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h
72016 index 5fd71a7..e5ef9a9 100644
72017 --- a/include/linux/vmstat.h
72018 +++ b/include/linux/vmstat.h
72019 @@ -95,18 +95,18 @@ static inline void vm_events_fold_cpu(int cpu)
72020 /*
72021 * Zone based page accounting with per cpu differentials.
72022 */
72023 -extern atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
72024 +extern atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
72025
72026 static inline void zone_page_state_add(long x, struct zone *zone,
72027 enum zone_stat_item item)
72028 {
72029 - atomic_long_add(x, &zone->vm_stat[item]);
72030 - atomic_long_add(x, &vm_stat[item]);
72031 + atomic_long_add_unchecked(x, &zone->vm_stat[item]);
72032 + atomic_long_add_unchecked(x, &vm_stat[item]);
72033 }
72034
72035 static inline unsigned long global_page_state(enum zone_stat_item item)
72036 {
72037 - long x = atomic_long_read(&vm_stat[item]);
72038 + long x = atomic_long_read_unchecked(&vm_stat[item]);
72039 #ifdef CONFIG_SMP
72040 if (x < 0)
72041 x = 0;
72042 @@ -117,7 +117,7 @@ static inline unsigned long global_page_state(enum zone_stat_item item)
72043 static inline unsigned long zone_page_state(struct zone *zone,
72044 enum zone_stat_item item)
72045 {
72046 - long x = atomic_long_read(&zone->vm_stat[item]);
72047 + long x = atomic_long_read_unchecked(&zone->vm_stat[item]);
72048 #ifdef CONFIG_SMP
72049 if (x < 0)
72050 x = 0;
72051 @@ -134,7 +134,7 @@ static inline unsigned long zone_page_state(struct zone *zone,
72052 static inline unsigned long zone_page_state_snapshot(struct zone *zone,
72053 enum zone_stat_item item)
72054 {
72055 - long x = atomic_long_read(&zone->vm_stat[item]);
72056 + long x = atomic_long_read_unchecked(&zone->vm_stat[item]);
72057
72058 #ifdef CONFIG_SMP
72059 int cpu;
72060 @@ -226,8 +226,8 @@ static inline void __mod_zone_page_state(struct zone *zone,
72061
72062 static inline void __inc_zone_state(struct zone *zone, enum zone_stat_item item)
72063 {
72064 - atomic_long_inc(&zone->vm_stat[item]);
72065 - atomic_long_inc(&vm_stat[item]);
72066 + atomic_long_inc_unchecked(&zone->vm_stat[item]);
72067 + atomic_long_inc_unchecked(&vm_stat[item]);
72068 }
72069
72070 static inline void __inc_zone_page_state(struct page *page,
72071 @@ -238,8 +238,8 @@ static inline void __inc_zone_page_state(struct page *page,
72072
72073 static inline void __dec_zone_state(struct zone *zone, enum zone_stat_item item)
72074 {
72075 - atomic_long_dec(&zone->vm_stat[item]);
72076 - atomic_long_dec(&vm_stat[item]);
72077 + atomic_long_dec_unchecked(&zone->vm_stat[item]);
72078 + atomic_long_dec_unchecked(&vm_stat[item]);
72079 }
72080
72081 static inline void __dec_zone_page_state(struct page *page,
72082 diff --git a/include/linux/xattr.h b/include/linux/xattr.h
72083 index fdbafc6..49dfe4f 100644
72084 --- a/include/linux/xattr.h
72085 +++ b/include/linux/xattr.h
72086 @@ -28,7 +28,7 @@ struct xattr_handler {
72087 size_t size, int handler_flags);
72088 int (*set)(struct dentry *dentry, const char *name, const void *buffer,
72089 size_t size, int flags, int handler_flags);
72090 -};
72091 +} __do_const;
72092
72093 struct xattr {
72094 char *name;
72095 @@ -37,6 +37,9 @@ struct xattr {
72096 };
72097
72098 ssize_t xattr_getsecurity(struct inode *, const char *, void *, size_t);
72099 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
72100 +ssize_t pax_getxattr(struct dentry *, void *, size_t);
72101 +#endif
72102 ssize_t vfs_getxattr(struct dentry *, const char *, void *, size_t);
72103 ssize_t vfs_listxattr(struct dentry *d, char *list, size_t size);
72104 int __vfs_setxattr_noperm(struct dentry *, const char *, const void *, size_t, int);
72105 diff --git a/include/linux/zlib.h b/include/linux/zlib.h
72106 index 9c5a6b4..09c9438 100644
72107 --- a/include/linux/zlib.h
72108 +++ b/include/linux/zlib.h
72109 @@ -31,6 +31,7 @@
72110 #define _ZLIB_H
72111
72112 #include <linux/zconf.h>
72113 +#include <linux/compiler.h>
72114
72115 /* zlib deflate based on ZLIB_VERSION "1.1.3" */
72116 /* zlib inflate based on ZLIB_VERSION "1.2.3" */
72117 @@ -179,7 +180,7 @@ typedef z_stream *z_streamp;
72118
72119 /* basic functions */
72120
72121 -extern int zlib_deflate_workspacesize (int windowBits, int memLevel);
72122 +extern int zlib_deflate_workspacesize (int windowBits, int memLevel) __intentional_overflow(0);
72123 /*
72124 Returns the number of bytes that needs to be allocated for a per-
72125 stream workspace with the specified parameters. A pointer to this
72126 diff --git a/include/media/v4l2-dev.h b/include/media/v4l2-dev.h
72127 index 95d1c91..6798cca 100644
72128 --- a/include/media/v4l2-dev.h
72129 +++ b/include/media/v4l2-dev.h
72130 @@ -76,7 +76,7 @@ struct v4l2_file_operations {
72131 int (*mmap) (struct file *, struct vm_area_struct *);
72132 int (*open) (struct file *);
72133 int (*release) (struct file *);
72134 -};
72135 +} __do_const;
72136
72137 /*
72138 * Newer version of video_device, handled by videodev2.c
72139 diff --git a/include/media/v4l2-ioctl.h b/include/media/v4l2-ioctl.h
72140 index 4118ad1..cb7e25f 100644
72141 --- a/include/media/v4l2-ioctl.h
72142 +++ b/include/media/v4l2-ioctl.h
72143 @@ -284,7 +284,6 @@ struct v4l2_ioctl_ops {
72144 bool valid_prio, int cmd, void *arg);
72145 };
72146
72147 -
72148 /* v4l debugging and diagnostics */
72149
72150 /* Debug bitmask flags to be used on V4L2 */
72151 diff --git a/include/net/9p/transport.h b/include/net/9p/transport.h
72152 index adcbb20..62c2559 100644
72153 --- a/include/net/9p/transport.h
72154 +++ b/include/net/9p/transport.h
72155 @@ -57,7 +57,7 @@ struct p9_trans_module {
72156 int (*cancel) (struct p9_client *, struct p9_req_t *req);
72157 int (*zc_request)(struct p9_client *, struct p9_req_t *,
72158 char *, char *, int , int, int, int);
72159 -};
72160 +} __do_const;
72161
72162 void v9fs_register_trans(struct p9_trans_module *m);
72163 void v9fs_unregister_trans(struct p9_trans_module *m);
72164 diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
72165 index cdd3302..76f8ede 100644
72166 --- a/include/net/bluetooth/l2cap.h
72167 +++ b/include/net/bluetooth/l2cap.h
72168 @@ -551,7 +551,7 @@ struct l2cap_ops {
72169 void (*defer) (struct l2cap_chan *chan);
72170 struct sk_buff *(*alloc_skb) (struct l2cap_chan *chan,
72171 unsigned long len, int nb);
72172 -};
72173 +} __do_const;
72174
72175 struct l2cap_conn {
72176 struct hci_conn *hcon;
72177 diff --git a/include/net/caif/cfctrl.h b/include/net/caif/cfctrl.h
72178 index 9e5425b..8136ffc 100644
72179 --- a/include/net/caif/cfctrl.h
72180 +++ b/include/net/caif/cfctrl.h
72181 @@ -52,7 +52,7 @@ struct cfctrl_rsp {
72182 void (*radioset_rsp)(void);
72183 void (*reject_rsp)(struct cflayer *layer, u8 linkid,
72184 struct cflayer *client_layer);
72185 -};
72186 +} __no_const;
72187
72188 /* Link Setup Parameters for CAIF-Links. */
72189 struct cfctrl_link_param {
72190 @@ -101,8 +101,8 @@ struct cfctrl_request_info {
72191 struct cfctrl {
72192 struct cfsrvl serv;
72193 struct cfctrl_rsp res;
72194 - atomic_t req_seq_no;
72195 - atomic_t rsp_seq_no;
72196 + atomic_unchecked_t req_seq_no;
72197 + atomic_unchecked_t rsp_seq_no;
72198 struct list_head list;
72199 /* Protects from simultaneous access to first_req list */
72200 spinlock_t info_list_lock;
72201 diff --git a/include/net/flow.h b/include/net/flow.h
72202 index 628e11b..4c475df 100644
72203 --- a/include/net/flow.h
72204 +++ b/include/net/flow.h
72205 @@ -221,6 +221,6 @@ extern struct flow_cache_object *flow_cache_lookup(
72206
72207 extern void flow_cache_flush(void);
72208 extern void flow_cache_flush_deferred(void);
72209 -extern atomic_t flow_cache_genid;
72210 +extern atomic_unchecked_t flow_cache_genid;
72211
72212 #endif
72213 diff --git a/include/net/genetlink.h b/include/net/genetlink.h
72214 index bdfbe68..4402ebe 100644
72215 --- a/include/net/genetlink.h
72216 +++ b/include/net/genetlink.h
72217 @@ -118,7 +118,7 @@ struct genl_ops {
72218 struct netlink_callback *cb);
72219 int (*done)(struct netlink_callback *cb);
72220 struct list_head ops_list;
72221 -};
72222 +} __do_const;
72223
72224 extern int genl_register_family(struct genl_family *family);
72225 extern int genl_register_family_with_ops(struct genl_family *family,
72226 diff --git a/include/net/gro_cells.h b/include/net/gro_cells.h
72227 index 734d9b5..48a9a4b 100644
72228 --- a/include/net/gro_cells.h
72229 +++ b/include/net/gro_cells.h
72230 @@ -29,7 +29,7 @@ static inline void gro_cells_receive(struct gro_cells *gcells, struct sk_buff *s
72231 cell += skb_get_rx_queue(skb) & gcells->gro_cells_mask;
72232
72233 if (skb_queue_len(&cell->napi_skbs) > netdev_max_backlog) {
72234 - atomic_long_inc(&dev->rx_dropped);
72235 + atomic_long_inc_unchecked(&dev->rx_dropped);
72236 kfree_skb(skb);
72237 return;
72238 }
72239 diff --git a/include/net/inet_connection_sock.h b/include/net/inet_connection_sock.h
72240 index 1832927..ce39aea 100644
72241 --- a/include/net/inet_connection_sock.h
72242 +++ b/include/net/inet_connection_sock.h
72243 @@ -62,7 +62,7 @@ struct inet_connection_sock_af_ops {
72244 void (*addr2sockaddr)(struct sock *sk, struct sockaddr *);
72245 int (*bind_conflict)(const struct sock *sk,
72246 const struct inet_bind_bucket *tb, bool relax);
72247 -};
72248 +} __do_const;
72249
72250 /** inet_connection_sock - INET connection oriented sock
72251 *
72252 diff --git a/include/net/inetpeer.h b/include/net/inetpeer.h
72253 index 53f464d..ba76aaa 100644
72254 --- a/include/net/inetpeer.h
72255 +++ b/include/net/inetpeer.h
72256 @@ -47,8 +47,8 @@ struct inet_peer {
72257 */
72258 union {
72259 struct {
72260 - atomic_t rid; /* Frag reception counter */
72261 - atomic_t ip_id_count; /* IP ID for the next packet */
72262 + atomic_unchecked_t rid; /* Frag reception counter */
72263 + atomic_unchecked_t ip_id_count; /* IP ID for the next packet */
72264 };
72265 struct rcu_head rcu;
72266 struct inet_peer *gc_next;
72267 @@ -182,11 +182,11 @@ static inline int inet_getid(struct inet_peer *p, int more)
72268 more++;
72269 inet_peer_refcheck(p);
72270 do {
72271 - old = atomic_read(&p->ip_id_count);
72272 + old = atomic_read_unchecked(&p->ip_id_count);
72273 new = old + more;
72274 if (!new)
72275 new = 1;
72276 - } while (atomic_cmpxchg(&p->ip_id_count, old, new) != old);
72277 + } while (atomic_cmpxchg_unchecked(&p->ip_id_count, old, new) != old);
72278 return new;
72279 }
72280
72281 diff --git a/include/net/ip.h b/include/net/ip.h
72282 index a68f838..74518ab 100644
72283 --- a/include/net/ip.h
72284 +++ b/include/net/ip.h
72285 @@ -202,7 +202,7 @@ extern struct local_ports {
72286 } sysctl_local_ports;
72287 extern void inet_get_local_port_range(int *low, int *high);
72288
72289 -extern unsigned long *sysctl_local_reserved_ports;
72290 +extern unsigned long sysctl_local_reserved_ports[65536 / 8 / sizeof(unsigned long)];
72291 static inline int inet_is_reserved_local_port(int port)
72292 {
72293 return test_bit(port, sysctl_local_reserved_ports);
72294 diff --git a/include/net/ip_fib.h b/include/net/ip_fib.h
72295 index e49db91..76a81de 100644
72296 --- a/include/net/ip_fib.h
72297 +++ b/include/net/ip_fib.h
72298 @@ -167,7 +167,7 @@ extern __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh);
72299
72300 #define FIB_RES_SADDR(net, res) \
72301 ((FIB_RES_NH(res).nh_saddr_genid == \
72302 - atomic_read(&(net)->ipv4.dev_addr_genid)) ? \
72303 + atomic_read_unchecked(&(net)->ipv4.dev_addr_genid)) ? \
72304 FIB_RES_NH(res).nh_saddr : \
72305 fib_info_update_nh_saddr((net), &FIB_RES_NH(res)))
72306 #define FIB_RES_GW(res) (FIB_RES_NH(res).nh_gw)
72307 diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h
72308 index fce8e6b..3ca4916 100644
72309 --- a/include/net/ip_vs.h
72310 +++ b/include/net/ip_vs.h
72311 @@ -599,7 +599,7 @@ struct ip_vs_conn {
72312 struct ip_vs_conn *control; /* Master control connection */
72313 atomic_t n_control; /* Number of controlled ones */
72314 struct ip_vs_dest *dest; /* real server */
72315 - atomic_t in_pkts; /* incoming packet counter */
72316 + atomic_unchecked_t in_pkts; /* incoming packet counter */
72317
72318 /* packet transmitter for different forwarding methods. If it
72319 mangles the packet, it must return NF_DROP or better NF_STOLEN,
72320 @@ -737,7 +737,7 @@ struct ip_vs_dest {
72321 __be16 port; /* port number of the server */
72322 union nf_inet_addr addr; /* IP address of the server */
72323 volatile unsigned int flags; /* dest status flags */
72324 - atomic_t conn_flags; /* flags to copy to conn */
72325 + atomic_unchecked_t conn_flags; /* flags to copy to conn */
72326 atomic_t weight; /* server weight */
72327
72328 atomic_t refcnt; /* reference counter */
72329 @@ -981,11 +981,11 @@ struct netns_ipvs {
72330 /* ip_vs_lblc */
72331 int sysctl_lblc_expiration;
72332 struct ctl_table_header *lblc_ctl_header;
72333 - struct ctl_table *lblc_ctl_table;
72334 + ctl_table_no_const *lblc_ctl_table;
72335 /* ip_vs_lblcr */
72336 int sysctl_lblcr_expiration;
72337 struct ctl_table_header *lblcr_ctl_header;
72338 - struct ctl_table *lblcr_ctl_table;
72339 + ctl_table_no_const *lblcr_ctl_table;
72340 /* ip_vs_est */
72341 struct list_head est_list; /* estimator list */
72342 spinlock_t est_lock;
72343 diff --git a/include/net/irda/ircomm_tty.h b/include/net/irda/ircomm_tty.h
72344 index 80ffde3..968b0f4 100644
72345 --- a/include/net/irda/ircomm_tty.h
72346 +++ b/include/net/irda/ircomm_tty.h
72347 @@ -35,6 +35,7 @@
72348 #include <linux/termios.h>
72349 #include <linux/timer.h>
72350 #include <linux/tty.h> /* struct tty_struct */
72351 +#include <asm/local.h>
72352
72353 #include <net/irda/irias_object.h>
72354 #include <net/irda/ircomm_core.h>
72355 diff --git a/include/net/iucv/af_iucv.h b/include/net/iucv/af_iucv.h
72356 index 714cc9a..ea05f3e 100644
72357 --- a/include/net/iucv/af_iucv.h
72358 +++ b/include/net/iucv/af_iucv.h
72359 @@ -149,7 +149,7 @@ struct iucv_skb_cb {
72360 struct iucv_sock_list {
72361 struct hlist_head head;
72362 rwlock_t lock;
72363 - atomic_t autobind_name;
72364 + atomic_unchecked_t autobind_name;
72365 };
72366
72367 unsigned int iucv_sock_poll(struct file *file, struct socket *sock,
72368 diff --git a/include/net/llc_c_ac.h b/include/net/llc_c_ac.h
72369 index df83f69..9b640b8 100644
72370 --- a/include/net/llc_c_ac.h
72371 +++ b/include/net/llc_c_ac.h
72372 @@ -87,7 +87,7 @@
72373 #define LLC_CONN_AC_STOP_SENDACK_TMR 70
72374 #define LLC_CONN_AC_START_SENDACK_TMR_IF_NOT_RUNNING 71
72375
72376 -typedef int (*llc_conn_action_t)(struct sock *sk, struct sk_buff *skb);
72377 +typedef int (* const llc_conn_action_t)(struct sock *sk, struct sk_buff *skb);
72378
72379 extern int llc_conn_ac_clear_remote_busy(struct sock *sk, struct sk_buff *skb);
72380 extern int llc_conn_ac_conn_ind(struct sock *sk, struct sk_buff *skb);
72381 diff --git a/include/net/llc_c_ev.h b/include/net/llc_c_ev.h
72382 index 6ca3113..f8026dd 100644
72383 --- a/include/net/llc_c_ev.h
72384 +++ b/include/net/llc_c_ev.h
72385 @@ -125,8 +125,8 @@ static __inline__ struct llc_conn_state_ev *llc_conn_ev(struct sk_buff *skb)
72386 return (struct llc_conn_state_ev *)skb->cb;
72387 }
72388
72389 -typedef int (*llc_conn_ev_t)(struct sock *sk, struct sk_buff *skb);
72390 -typedef int (*llc_conn_ev_qfyr_t)(struct sock *sk, struct sk_buff *skb);
72391 +typedef int (* const llc_conn_ev_t)(struct sock *sk, struct sk_buff *skb);
72392 +typedef int (* const llc_conn_ev_qfyr_t)(struct sock *sk, struct sk_buff *skb);
72393
72394 extern int llc_conn_ev_conn_req(struct sock *sk, struct sk_buff *skb);
72395 extern int llc_conn_ev_data_req(struct sock *sk, struct sk_buff *skb);
72396 diff --git a/include/net/llc_c_st.h b/include/net/llc_c_st.h
72397 index 0e79cfb..f46db31 100644
72398 --- a/include/net/llc_c_st.h
72399 +++ b/include/net/llc_c_st.h
72400 @@ -37,7 +37,7 @@ struct llc_conn_state_trans {
72401 u8 next_state;
72402 llc_conn_ev_qfyr_t *ev_qualifiers;
72403 llc_conn_action_t *ev_actions;
72404 -};
72405 +} __do_const;
72406
72407 struct llc_conn_state {
72408 u8 current_state;
72409 diff --git a/include/net/llc_s_ac.h b/include/net/llc_s_ac.h
72410 index 37a3bbd..55a4241 100644
72411 --- a/include/net/llc_s_ac.h
72412 +++ b/include/net/llc_s_ac.h
72413 @@ -23,7 +23,7 @@
72414 #define SAP_ACT_TEST_IND 9
72415
72416 /* All action functions must look like this */
72417 -typedef int (*llc_sap_action_t)(struct llc_sap *sap, struct sk_buff *skb);
72418 +typedef int (* const llc_sap_action_t)(struct llc_sap *sap, struct sk_buff *skb);
72419
72420 extern int llc_sap_action_unitdata_ind(struct llc_sap *sap,
72421 struct sk_buff *skb);
72422 diff --git a/include/net/llc_s_st.h b/include/net/llc_s_st.h
72423 index 567c681..cd73ac0 100644
72424 --- a/include/net/llc_s_st.h
72425 +++ b/include/net/llc_s_st.h
72426 @@ -20,7 +20,7 @@ struct llc_sap_state_trans {
72427 llc_sap_ev_t ev;
72428 u8 next_state;
72429 llc_sap_action_t *ev_actions;
72430 -};
72431 +} __do_const;
72432
72433 struct llc_sap_state {
72434 u8 curr_state;
72435 diff --git a/include/net/mac80211.h b/include/net/mac80211.h
72436 index f7eba13..91ed983 100644
72437 --- a/include/net/mac80211.h
72438 +++ b/include/net/mac80211.h
72439 @@ -4119,7 +4119,7 @@ struct rate_control_ops {
72440 void (*add_sta_debugfs)(void *priv, void *priv_sta,
72441 struct dentry *dir);
72442 void (*remove_sta_debugfs)(void *priv, void *priv_sta);
72443 -};
72444 +} __do_const;
72445
72446 static inline int rate_supported(struct ieee80211_sta *sta,
72447 enum ieee80211_band band,
72448 diff --git a/include/net/neighbour.h b/include/net/neighbour.h
72449 index 7e748ad..5c6229b 100644
72450 --- a/include/net/neighbour.h
72451 +++ b/include/net/neighbour.h
72452 @@ -123,7 +123,7 @@ struct neigh_ops {
72453 void (*error_report)(struct neighbour *, struct sk_buff *);
72454 int (*output)(struct neighbour *, struct sk_buff *);
72455 int (*connected_output)(struct neighbour *, struct sk_buff *);
72456 -};
72457 +} __do_const;
72458
72459 struct pneigh_entry {
72460 struct pneigh_entry *next;
72461 diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h
72462 index de644bc..dfbcc4c 100644
72463 --- a/include/net/net_namespace.h
72464 +++ b/include/net/net_namespace.h
72465 @@ -115,7 +115,7 @@ struct net {
72466 #endif
72467 struct netns_ipvs *ipvs;
72468 struct sock *diag_nlsk;
72469 - atomic_t rt_genid;
72470 + atomic_unchecked_t rt_genid;
72471 };
72472
72473 /*
72474 @@ -272,7 +272,11 @@ static inline struct net *read_pnet(struct net * const *pnet)
72475 #define __net_init __init
72476 #define __net_exit __exit_refok
72477 #define __net_initdata __initdata
72478 +#ifdef CONSTIFY_PLUGIN
72479 #define __net_initconst __initconst
72480 +#else
72481 +#define __net_initconst __initdata
72482 +#endif
72483 #endif
72484
72485 struct pernet_operations {
72486 @@ -282,7 +286,7 @@ struct pernet_operations {
72487 void (*exit_batch)(struct list_head *net_exit_list);
72488 int *id;
72489 size_t size;
72490 -};
72491 +} __do_const;
72492
72493 /*
72494 * Use these carefully. If you implement a network device and it
72495 @@ -330,12 +334,12 @@ static inline void unregister_net_sysctl_table(struct ctl_table_header *header)
72496
72497 static inline int rt_genid(struct net *net)
72498 {
72499 - return atomic_read(&net->rt_genid);
72500 + return atomic_read_unchecked(&net->rt_genid);
72501 }
72502
72503 static inline void rt_genid_bump(struct net *net)
72504 {
72505 - atomic_inc(&net->rt_genid);
72506 + atomic_inc_unchecked(&net->rt_genid);
72507 }
72508
72509 #endif /* __NET_NET_NAMESPACE_H */
72510 diff --git a/include/net/netdma.h b/include/net/netdma.h
72511 index 8ba8ce2..99b7fff 100644
72512 --- a/include/net/netdma.h
72513 +++ b/include/net/netdma.h
72514 @@ -24,7 +24,7 @@
72515 #include <linux/dmaengine.h>
72516 #include <linux/skbuff.h>
72517
72518 -int dma_skb_copy_datagram_iovec(struct dma_chan* chan,
72519 +int __intentional_overflow(3,5) dma_skb_copy_datagram_iovec(struct dma_chan* chan,
72520 struct sk_buff *skb, int offset, struct iovec *to,
72521 size_t len, struct dma_pinned_list *pinned_list);
72522
72523 diff --git a/include/net/netlink.h b/include/net/netlink.h
72524 index 9690b0f..87aded7 100644
72525 --- a/include/net/netlink.h
72526 +++ b/include/net/netlink.h
72527 @@ -534,7 +534,7 @@ static inline void *nlmsg_get_pos(struct sk_buff *skb)
72528 static inline void nlmsg_trim(struct sk_buff *skb, const void *mark)
72529 {
72530 if (mark)
72531 - skb_trim(skb, (unsigned char *) mark - skb->data);
72532 + skb_trim(skb, (const unsigned char *) mark - skb->data);
72533 }
72534
72535 /**
72536 diff --git a/include/net/netns/conntrack.h b/include/net/netns/conntrack.h
72537 index c9c0c53..53f24c3 100644
72538 --- a/include/net/netns/conntrack.h
72539 +++ b/include/net/netns/conntrack.h
72540 @@ -12,10 +12,10 @@ struct nf_conntrack_ecache;
72541 struct nf_proto_net {
72542 #ifdef CONFIG_SYSCTL
72543 struct ctl_table_header *ctl_table_header;
72544 - struct ctl_table *ctl_table;
72545 + ctl_table_no_const *ctl_table;
72546 #ifdef CONFIG_NF_CONNTRACK_PROC_COMPAT
72547 struct ctl_table_header *ctl_compat_header;
72548 - struct ctl_table *ctl_compat_table;
72549 + ctl_table_no_const *ctl_compat_table;
72550 #endif
72551 #endif
72552 unsigned int users;
72553 @@ -58,7 +58,7 @@ struct nf_ip_net {
72554 struct nf_icmp_net icmpv6;
72555 #if defined(CONFIG_SYSCTL) && defined(CONFIG_NF_CONNTRACK_PROC_COMPAT)
72556 struct ctl_table_header *ctl_table_header;
72557 - struct ctl_table *ctl_table;
72558 + ctl_table_no_const *ctl_table;
72559 #endif
72560 };
72561
72562 diff --git a/include/net/netns/ipv4.h b/include/net/netns/ipv4.h
72563 index 2ba9de8..47bd6c7 100644
72564 --- a/include/net/netns/ipv4.h
72565 +++ b/include/net/netns/ipv4.h
72566 @@ -67,7 +67,7 @@ struct netns_ipv4 {
72567 kgid_t sysctl_ping_group_range[2];
72568 long sysctl_tcp_mem[3];
72569
72570 - atomic_t dev_addr_genid;
72571 + atomic_unchecked_t dev_addr_genid;
72572
72573 #ifdef CONFIG_IP_MROUTE
72574 #ifndef CONFIG_IP_MROUTE_MULTIPLE_TABLES
72575 diff --git a/include/net/protocol.h b/include/net/protocol.h
72576 index 047c047..b9dad15 100644
72577 --- a/include/net/protocol.h
72578 +++ b/include/net/protocol.h
72579 @@ -44,7 +44,7 @@ struct net_protocol {
72580 void (*err_handler)(struct sk_buff *skb, u32 info);
72581 unsigned int no_policy:1,
72582 netns_ok:1;
72583 -};
72584 +} __do_const;
72585
72586 #if IS_ENABLED(CONFIG_IPV6)
72587 struct inet6_protocol {
72588 @@ -57,7 +57,7 @@ struct inet6_protocol {
72589 u8 type, u8 code, int offset,
72590 __be32 info);
72591 unsigned int flags; /* INET6_PROTO_xxx */
72592 -};
72593 +} __do_const;
72594
72595 #define INET6_PROTO_NOPOLICY 0x1
72596 #define INET6_PROTO_FINAL 0x2
72597 diff --git a/include/net/rtnetlink.h b/include/net/rtnetlink.h
72598 index 5a15fab..d799ea7 100644
72599 --- a/include/net/rtnetlink.h
72600 +++ b/include/net/rtnetlink.h
72601 @@ -81,7 +81,7 @@ struct rtnl_link_ops {
72602 const struct net_device *dev);
72603 unsigned int (*get_num_tx_queues)(void);
72604 unsigned int (*get_num_rx_queues)(void);
72605 -};
72606 +} __do_const;
72607
72608 extern int __rtnl_link_register(struct rtnl_link_ops *ops);
72609 extern void __rtnl_link_unregister(struct rtnl_link_ops *ops);
72610 diff --git a/include/net/sctp/sctp.h b/include/net/sctp/sctp.h
72611 index df85a0c..19ac300 100644
72612 --- a/include/net/sctp/sctp.h
72613 +++ b/include/net/sctp/sctp.h
72614 @@ -330,9 +330,9 @@ do { \
72615
72616 #else /* SCTP_DEBUG */
72617
72618 -#define SCTP_DEBUG_PRINTK(whatever...)
72619 -#define SCTP_DEBUG_PRINTK_CONT(fmt, args...)
72620 -#define SCTP_DEBUG_PRINTK_IPADDR(whatever...)
72621 +#define SCTP_DEBUG_PRINTK(whatever...) do {} while (0)
72622 +#define SCTP_DEBUG_PRINTK_CONT(fmt, args...) do {} while (0)
72623 +#define SCTP_DEBUG_PRINTK_IPADDR(whatever...) do {} while (0)
72624 #define SCTP_ENABLE_DEBUG
72625 #define SCTP_DISABLE_DEBUG
72626 #define SCTP_ASSERT(expr, str, func)
72627 diff --git a/include/net/sctp/sm.h b/include/net/sctp/sm.h
72628 index 2a82d13..62a31c2 100644
72629 --- a/include/net/sctp/sm.h
72630 +++ b/include/net/sctp/sm.h
72631 @@ -87,7 +87,7 @@ typedef void (sctp_timer_event_t) (unsigned long);
72632 typedef struct {
72633 sctp_state_fn_t *fn;
72634 const char *name;
72635 -} sctp_sm_table_entry_t;
72636 +} __do_const sctp_sm_table_entry_t;
72637
72638 /* A naming convention of "sctp_sf_xxx" applies to all the state functions
72639 * currently in use.
72640 @@ -299,7 +299,7 @@ __u32 sctp_generate_tag(const struct sctp_endpoint *);
72641 __u32 sctp_generate_tsn(const struct sctp_endpoint *);
72642
72643 /* Extern declarations for major data structures. */
72644 -extern sctp_timer_event_t *sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES];
72645 +extern sctp_timer_event_t * const sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES];
72646
72647
72648 /* Get the size of a DATA chunk payload. */
72649 diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h
72650 index 0e0f9d2..cd05ebb 100644
72651 --- a/include/net/sctp/structs.h
72652 +++ b/include/net/sctp/structs.h
72653 @@ -517,7 +517,7 @@ struct sctp_pf {
72654 struct sctp_association *asoc);
72655 void (*addr_v4map) (struct sctp_sock *, union sctp_addr *);
72656 struct sctp_af *af;
72657 -};
72658 +} __do_const;
72659
72660
72661 /* Structure to track chunk fragments that have been acked, but peer
72662 diff --git a/include/net/secure_seq.h b/include/net/secure_seq.h
72663 index c2e542b..6ca975b 100644
72664 --- a/include/net/secure_seq.h
72665 +++ b/include/net/secure_seq.h
72666 @@ -3,6 +3,7 @@
72667
72668 #include <linux/types.h>
72669
72670 +extern void net_secret_init(void);
72671 extern __u32 secure_ip_id(__be32 daddr);
72672 extern __u32 secure_ipv6_id(const __be32 daddr[4]);
72673 extern u32 secure_ipv4_port_ephemeral(__be32 saddr, __be32 daddr, __be16 dport);
72674 diff --git a/include/net/sock.h b/include/net/sock.h
72675 index 0be480a..586232f 100644
72676 --- a/include/net/sock.h
72677 +++ b/include/net/sock.h
72678 @@ -325,7 +325,7 @@ struct sock {
72679 #ifdef CONFIG_RPS
72680 __u32 sk_rxhash;
72681 #endif
72682 - atomic_t sk_drops;
72683 + atomic_unchecked_t sk_drops;
72684 int sk_rcvbuf;
72685
72686 struct sk_filter __rcu *sk_filter;
72687 @@ -1796,7 +1796,7 @@ static inline void sk_nocaps_add(struct sock *sk, netdev_features_t flags)
72688 }
72689
72690 static inline int skb_do_copy_data_nocache(struct sock *sk, struct sk_buff *skb,
72691 - char __user *from, char *to,
72692 + char __user *from, unsigned char *to,
72693 int copy, int offset)
72694 {
72695 if (skb->ip_summed == CHECKSUM_NONE) {
72696 @@ -2055,7 +2055,7 @@ static inline void sk_stream_moderate_sndbuf(struct sock *sk)
72697 }
72698 }
72699
72700 -struct sk_buff *sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp);
72701 +struct sk_buff * __intentional_overflow(0) sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp);
72702
72703 /**
72704 * sk_page_frag - return an appropriate page_frag
72705 diff --git a/include/net/tcp.h b/include/net/tcp.h
72706 index a345480..3c65cf4 100644
72707 --- a/include/net/tcp.h
72708 +++ b/include/net/tcp.h
72709 @@ -529,7 +529,7 @@ extern void tcp_retransmit_timer(struct sock *sk);
72710 extern void tcp_xmit_retransmit_queue(struct sock *);
72711 extern void tcp_simple_retransmit(struct sock *);
72712 extern int tcp_trim_head(struct sock *, struct sk_buff *, u32);
72713 -extern int tcp_fragment(struct sock *, struct sk_buff *, u32, unsigned int);
72714 +extern int __intentional_overflow(3) tcp_fragment(struct sock *, struct sk_buff *, u32, unsigned int);
72715
72716 extern void tcp_send_probe0(struct sock *);
72717 extern void tcp_send_partial(struct sock *);
72718 @@ -700,8 +700,8 @@ struct tcp_skb_cb {
72719 struct inet6_skb_parm h6;
72720 #endif
72721 } header; /* For incoming frames */
72722 - __u32 seq; /* Starting sequence number */
72723 - __u32 end_seq; /* SEQ + FIN + SYN + datalen */
72724 + __u32 seq __intentional_overflow(0); /* Starting sequence number */
72725 + __u32 end_seq __intentional_overflow(0); /* SEQ + FIN + SYN + datalen */
72726 __u32 when; /* used to compute rtt's */
72727 __u8 tcp_flags; /* TCP header flags. (tcp[13]) */
72728
72729 @@ -715,7 +715,7 @@ struct tcp_skb_cb {
72730
72731 __u8 ip_dsfield; /* IPv4 tos or IPv6 dsfield */
72732 /* 1 byte hole */
72733 - __u32 ack_seq; /* Sequence number ACK'd */
72734 + __u32 ack_seq __intentional_overflow(0); /* Sequence number ACK'd */
72735 };
72736
72737 #define TCP_SKB_CB(__skb) ((struct tcp_skb_cb *)&((__skb)->cb[0]))
72738 diff --git a/include/net/xfrm.h b/include/net/xfrm.h
72739 index 24c8886..e6fb816 100644
72740 --- a/include/net/xfrm.h
72741 +++ b/include/net/xfrm.h
72742 @@ -304,7 +304,7 @@ struct xfrm_policy_afinfo {
72743 struct net_device *dev,
72744 const struct flowi *fl);
72745 struct dst_entry *(*blackhole_route)(struct net *net, struct dst_entry *orig);
72746 -};
72747 +} __do_const;
72748
72749 extern int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo);
72750 extern int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo);
72751 @@ -340,7 +340,7 @@ struct xfrm_state_afinfo {
72752 struct sk_buff *skb);
72753 int (*transport_finish)(struct sk_buff *skb,
72754 int async);
72755 -};
72756 +} __do_const;
72757
72758 extern int xfrm_state_register_afinfo(struct xfrm_state_afinfo *afinfo);
72759 extern int xfrm_state_unregister_afinfo(struct xfrm_state_afinfo *afinfo);
72760 @@ -423,7 +423,7 @@ struct xfrm_mode {
72761 struct module *owner;
72762 unsigned int encap;
72763 int flags;
72764 -};
72765 +} __do_const;
72766
72767 /* Flags for xfrm_mode. */
72768 enum {
72769 @@ -520,7 +520,7 @@ struct xfrm_policy {
72770 struct timer_list timer;
72771
72772 struct flow_cache_object flo;
72773 - atomic_t genid;
72774 + atomic_unchecked_t genid;
72775 u32 priority;
72776 u32 index;
72777 struct xfrm_mark mark;
72778 diff --git a/include/rdma/iw_cm.h b/include/rdma/iw_cm.h
72779 index 1a046b1..ee0bef0 100644
72780 --- a/include/rdma/iw_cm.h
72781 +++ b/include/rdma/iw_cm.h
72782 @@ -122,7 +122,7 @@ struct iw_cm_verbs {
72783 int backlog);
72784
72785 int (*destroy_listen)(struct iw_cm_id *cm_id);
72786 -};
72787 +} __no_const;
72788
72789 /**
72790 * iw_create_cm_id - Create an IW CM identifier.
72791 diff --git a/include/scsi/libfc.h b/include/scsi/libfc.h
72792 index e1379b4..67eafbe 100644
72793 --- a/include/scsi/libfc.h
72794 +++ b/include/scsi/libfc.h
72795 @@ -762,6 +762,7 @@ struct libfc_function_template {
72796 */
72797 void (*disc_stop_final) (struct fc_lport *);
72798 };
72799 +typedef struct libfc_function_template __no_const libfc_function_template_no_const;
72800
72801 /**
72802 * struct fc_disc - Discovery context
72803 @@ -866,7 +867,7 @@ struct fc_lport {
72804 struct fc_vport *vport;
72805
72806 /* Operational Information */
72807 - struct libfc_function_template tt;
72808 + libfc_function_template_no_const tt;
72809 u8 link_up;
72810 u8 qfull;
72811 enum fc_lport_state state;
72812 diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
72813 index a7f9cba..b1f44d0 100644
72814 --- a/include/scsi/scsi_device.h
72815 +++ b/include/scsi/scsi_device.h
72816 @@ -171,9 +171,9 @@ struct scsi_device {
72817 unsigned int max_device_blocked; /* what device_blocked counts down from */
72818 #define SCSI_DEFAULT_DEVICE_BLOCKED 3
72819
72820 - atomic_t iorequest_cnt;
72821 - atomic_t iodone_cnt;
72822 - atomic_t ioerr_cnt;
72823 + atomic_unchecked_t iorequest_cnt;
72824 + atomic_unchecked_t iodone_cnt;
72825 + atomic_unchecked_t ioerr_cnt;
72826
72827 struct device sdev_gendev,
72828 sdev_dev;
72829 diff --git a/include/scsi/scsi_transport_fc.h b/include/scsi/scsi_transport_fc.h
72830 index b797e8f..8e2c3aa 100644
72831 --- a/include/scsi/scsi_transport_fc.h
72832 +++ b/include/scsi/scsi_transport_fc.h
72833 @@ -751,7 +751,8 @@ struct fc_function_template {
72834 unsigned long show_host_system_hostname:1;
72835
72836 unsigned long disable_target_scan:1;
72837 -};
72838 +} __do_const;
72839 +typedef struct fc_function_template __no_const fc_function_template_no_const;
72840
72841
72842 /**
72843 diff --git a/include/sound/compress_driver.h b/include/sound/compress_driver.h
72844 index ff6c741..393815f 100644
72845 --- a/include/sound/compress_driver.h
72846 +++ b/include/sound/compress_driver.h
72847 @@ -130,7 +130,7 @@ struct snd_compr_ops {
72848 struct snd_compr_caps *caps);
72849 int (*get_codec_caps) (struct snd_compr_stream *stream,
72850 struct snd_compr_codec_caps *codec);
72851 -};
72852 +} __no_const;
72853
72854 /**
72855 * struct snd_compr: Compressed device
72856 diff --git a/include/sound/soc.h b/include/sound/soc.h
72857 index a6a059c..2243336 100644
72858 --- a/include/sound/soc.h
72859 +++ b/include/sound/soc.h
72860 @@ -771,7 +771,7 @@ struct snd_soc_codec_driver {
72861 /* probe ordering - for components with runtime dependencies */
72862 int probe_order;
72863 int remove_order;
72864 -};
72865 +} __do_const;
72866
72867 /* SoC platform interface */
72868 struct snd_soc_platform_driver {
72869 @@ -817,7 +817,7 @@ struct snd_soc_platform_driver {
72870 unsigned int (*read)(struct snd_soc_platform *, unsigned int);
72871 int (*write)(struct snd_soc_platform *, unsigned int, unsigned int);
72872 int (*bespoke_trigger)(struct snd_pcm_substream *, int);
72873 -};
72874 +} __do_const;
72875
72876 struct snd_soc_platform {
72877 const char *name;
72878 diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h
72879 index f8640f3..b72d113 100644
72880 --- a/include/target/target_core_base.h
72881 +++ b/include/target/target_core_base.h
72882 @@ -658,7 +658,7 @@ struct se_device {
72883 spinlock_t stats_lock;
72884 /* Active commands on this virtual SE device */
72885 atomic_t simple_cmds;
72886 - atomic_t dev_ordered_id;
72887 + atomic_unchecked_t dev_ordered_id;
72888 atomic_t dev_ordered_sync;
72889 atomic_t dev_qf_count;
72890 int export_count;
72891 diff --git a/include/trace/events/fs.h b/include/trace/events/fs.h
72892 new file mode 100644
72893 index 0000000..fb634b7
72894 --- /dev/null
72895 +++ b/include/trace/events/fs.h
72896 @@ -0,0 +1,53 @@
72897 +#undef TRACE_SYSTEM
72898 +#define TRACE_SYSTEM fs
72899 +
72900 +#if !defined(_TRACE_FS_H) || defined(TRACE_HEADER_MULTI_READ)
72901 +#define _TRACE_FS_H
72902 +
72903 +#include <linux/fs.h>
72904 +#include <linux/tracepoint.h>
72905 +
72906 +TRACE_EVENT(do_sys_open,
72907 +
72908 + TP_PROTO(const char *filename, int flags, int mode),
72909 +
72910 + TP_ARGS(filename, flags, mode),
72911 +
72912 + TP_STRUCT__entry(
72913 + __string( filename, filename )
72914 + __field( int, flags )
72915 + __field( int, mode )
72916 + ),
72917 +
72918 + TP_fast_assign(
72919 + __assign_str(filename, filename);
72920 + __entry->flags = flags;
72921 + __entry->mode = mode;
72922 + ),
72923 +
72924 + TP_printk("\"%s\" %x %o",
72925 + __get_str(filename), __entry->flags, __entry->mode)
72926 +);
72927 +
72928 +TRACE_EVENT(open_exec,
72929 +
72930 + TP_PROTO(const char *filename),
72931 +
72932 + TP_ARGS(filename),
72933 +
72934 + TP_STRUCT__entry(
72935 + __string( filename, filename )
72936 + ),
72937 +
72938 + TP_fast_assign(
72939 + __assign_str(filename, filename);
72940 + ),
72941 +
72942 + TP_printk("\"%s\"",
72943 + __get_str(filename))
72944 +);
72945 +
72946 +#endif /* _TRACE_FS_H */
72947 +
72948 +/* This part must be outside protection */
72949 +#include <trace/define_trace.h>
72950 diff --git a/include/trace/events/irq.h b/include/trace/events/irq.h
72951 index 1c09820..7f5ec79 100644
72952 --- a/include/trace/events/irq.h
72953 +++ b/include/trace/events/irq.h
72954 @@ -36,7 +36,7 @@ struct softirq_action;
72955 */
72956 TRACE_EVENT(irq_handler_entry,
72957
72958 - TP_PROTO(int irq, struct irqaction *action),
72959 + TP_PROTO(int irq, const struct irqaction *action),
72960
72961 TP_ARGS(irq, action),
72962
72963 @@ -66,7 +66,7 @@ TRACE_EVENT(irq_handler_entry,
72964 */
72965 TRACE_EVENT(irq_handler_exit,
72966
72967 - TP_PROTO(int irq, struct irqaction *action, int ret),
72968 + TP_PROTO(int irq, const struct irqaction *action, int ret),
72969
72970 TP_ARGS(irq, action, ret),
72971
72972 diff --git a/include/uapi/linux/a.out.h b/include/uapi/linux/a.out.h
72973 index 7caf44c..23c6f27 100644
72974 --- a/include/uapi/linux/a.out.h
72975 +++ b/include/uapi/linux/a.out.h
72976 @@ -39,6 +39,14 @@ enum machine_type {
72977 M_MIPS2 = 152 /* MIPS R6000/R4000 binary */
72978 };
72979
72980 +/* Constants for the N_FLAGS field */
72981 +#define F_PAX_PAGEEXEC 1 /* Paging based non-executable pages */
72982 +#define F_PAX_EMUTRAMP 2 /* Emulate trampolines */
72983 +#define F_PAX_MPROTECT 4 /* Restrict mprotect() */
72984 +#define F_PAX_RANDMMAP 8 /* Randomize mmap() base */
72985 +/*#define F_PAX_RANDEXEC 16*/ /* Randomize ET_EXEC base */
72986 +#define F_PAX_SEGMEXEC 32 /* Segmentation based non-executable pages */
72987 +
72988 #if !defined (N_MAGIC)
72989 #define N_MAGIC(exec) ((exec).a_info & 0xffff)
72990 #endif
72991 diff --git a/include/uapi/linux/byteorder/little_endian.h b/include/uapi/linux/byteorder/little_endian.h
72992 index d876736..ccce5c0 100644
72993 --- a/include/uapi/linux/byteorder/little_endian.h
72994 +++ b/include/uapi/linux/byteorder/little_endian.h
72995 @@ -42,51 +42,51 @@
72996
72997 static inline __le64 __cpu_to_le64p(const __u64 *p)
72998 {
72999 - return (__force __le64)*p;
73000 + return (__force const __le64)*p;
73001 }
73002 -static inline __u64 __le64_to_cpup(const __le64 *p)
73003 +static inline __u64 __intentional_overflow(-1) __le64_to_cpup(const __le64 *p)
73004 {
73005 - return (__force __u64)*p;
73006 + return (__force const __u64)*p;
73007 }
73008 static inline __le32 __cpu_to_le32p(const __u32 *p)
73009 {
73010 - return (__force __le32)*p;
73011 + return (__force const __le32)*p;
73012 }
73013 static inline __u32 __le32_to_cpup(const __le32 *p)
73014 {
73015 - return (__force __u32)*p;
73016 + return (__force const __u32)*p;
73017 }
73018 static inline __le16 __cpu_to_le16p(const __u16 *p)
73019 {
73020 - return (__force __le16)*p;
73021 + return (__force const __le16)*p;
73022 }
73023 static inline __u16 __le16_to_cpup(const __le16 *p)
73024 {
73025 - return (__force __u16)*p;
73026 + return (__force const __u16)*p;
73027 }
73028 static inline __be64 __cpu_to_be64p(const __u64 *p)
73029 {
73030 - return (__force __be64)__swab64p(p);
73031 + return (__force const __be64)__swab64p(p);
73032 }
73033 static inline __u64 __be64_to_cpup(const __be64 *p)
73034 {
73035 - return __swab64p((__u64 *)p);
73036 + return __swab64p((const __u64 *)p);
73037 }
73038 static inline __be32 __cpu_to_be32p(const __u32 *p)
73039 {
73040 - return (__force __be32)__swab32p(p);
73041 + return (__force const __be32)__swab32p(p);
73042 }
73043 -static inline __u32 __be32_to_cpup(const __be32 *p)
73044 +static inline __u32 __intentional_overflow(-1) __be32_to_cpup(const __be32 *p)
73045 {
73046 - return __swab32p((__u32 *)p);
73047 + return __swab32p((const __u32 *)p);
73048 }
73049 static inline __be16 __cpu_to_be16p(const __u16 *p)
73050 {
73051 - return (__force __be16)__swab16p(p);
73052 + return (__force const __be16)__swab16p(p);
73053 }
73054 static inline __u16 __be16_to_cpup(const __be16 *p)
73055 {
73056 - return __swab16p((__u16 *)p);
73057 + return __swab16p((const __u16 *)p);
73058 }
73059 #define __cpu_to_le64s(x) do { (void)(x); } while (0)
73060 #define __le64_to_cpus(x) do { (void)(x); } while (0)
73061 diff --git a/include/uapi/linux/elf.h b/include/uapi/linux/elf.h
73062 index 8072d35..e77aeb8 100644
73063 --- a/include/uapi/linux/elf.h
73064 +++ b/include/uapi/linux/elf.h
73065 @@ -37,6 +37,17 @@ typedef __s64 Elf64_Sxword;
73066 #define PT_GNU_EH_FRAME 0x6474e550
73067
73068 #define PT_GNU_STACK (PT_LOOS + 0x474e551)
73069 +#define PT_GNU_RELRO (PT_LOOS + 0x474e552)
73070 +
73071 +#define PT_PAX_FLAGS (PT_LOOS + 0x5041580)
73072 +
73073 +/* Constants for the e_flags field */
73074 +#define EF_PAX_PAGEEXEC 1 /* Paging based non-executable pages */
73075 +#define EF_PAX_EMUTRAMP 2 /* Emulate trampolines */
73076 +#define EF_PAX_MPROTECT 4 /* Restrict mprotect() */
73077 +#define EF_PAX_RANDMMAP 8 /* Randomize mmap() base */
73078 +/*#define EF_PAX_RANDEXEC 16*/ /* Randomize ET_EXEC base */
73079 +#define EF_PAX_SEGMEXEC 32 /* Segmentation based non-executable pages */
73080
73081 /*
73082 * Extended Numbering
73083 @@ -94,6 +105,8 @@ typedef __s64 Elf64_Sxword;
73084 #define DT_DEBUG 21
73085 #define DT_TEXTREL 22
73086 #define DT_JMPREL 23
73087 +#define DT_FLAGS 30
73088 + #define DF_TEXTREL 0x00000004
73089 #define DT_ENCODING 32
73090 #define OLD_DT_LOOS 0x60000000
73091 #define DT_LOOS 0x6000000d
73092 @@ -240,6 +253,19 @@ typedef struct elf64_hdr {
73093 #define PF_W 0x2
73094 #define PF_X 0x1
73095
73096 +#define PF_PAGEEXEC (1U << 4) /* Enable PAGEEXEC */
73097 +#define PF_NOPAGEEXEC (1U << 5) /* Disable PAGEEXEC */
73098 +#define PF_SEGMEXEC (1U << 6) /* Enable SEGMEXEC */
73099 +#define PF_NOSEGMEXEC (1U << 7) /* Disable SEGMEXEC */
73100 +#define PF_MPROTECT (1U << 8) /* Enable MPROTECT */
73101 +#define PF_NOMPROTECT (1U << 9) /* Disable MPROTECT */
73102 +/*#define PF_RANDEXEC (1U << 10)*/ /* Enable RANDEXEC */
73103 +/*#define PF_NORANDEXEC (1U << 11)*/ /* Disable RANDEXEC */
73104 +#define PF_EMUTRAMP (1U << 12) /* Enable EMUTRAMP */
73105 +#define PF_NOEMUTRAMP (1U << 13) /* Disable EMUTRAMP */
73106 +#define PF_RANDMMAP (1U << 14) /* Enable RANDMMAP */
73107 +#define PF_NORANDMMAP (1U << 15) /* Disable RANDMMAP */
73108 +
73109 typedef struct elf32_phdr{
73110 Elf32_Word p_type;
73111 Elf32_Off p_offset;
73112 @@ -332,6 +358,8 @@ typedef struct elf64_shdr {
73113 #define EI_OSABI 7
73114 #define EI_PAD 8
73115
73116 +#define EI_PAX 14
73117 +
73118 #define ELFMAG0 0x7f /* EI_MAG */
73119 #define ELFMAG1 'E'
73120 #define ELFMAG2 'L'
73121 diff --git a/include/uapi/linux/personality.h b/include/uapi/linux/personality.h
73122 index aa169c4..6a2771d 100644
73123 --- a/include/uapi/linux/personality.h
73124 +++ b/include/uapi/linux/personality.h
73125 @@ -30,6 +30,7 @@ enum {
73126 #define PER_CLEAR_ON_SETID (READ_IMPLIES_EXEC | \
73127 ADDR_NO_RANDOMIZE | \
73128 ADDR_COMPAT_LAYOUT | \
73129 + ADDR_LIMIT_3GB | \
73130 MMAP_PAGE_ZERO)
73131
73132 /*
73133 diff --git a/include/uapi/linux/screen_info.h b/include/uapi/linux/screen_info.h
73134 index 7530e74..e714828 100644
73135 --- a/include/uapi/linux/screen_info.h
73136 +++ b/include/uapi/linux/screen_info.h
73137 @@ -43,7 +43,8 @@ struct screen_info {
73138 __u16 pages; /* 0x32 */
73139 __u16 vesa_attributes; /* 0x34 */
73140 __u32 capabilities; /* 0x36 */
73141 - __u8 _reserved[6]; /* 0x3a */
73142 + __u16 vesapm_size; /* 0x3a */
73143 + __u8 _reserved[4]; /* 0x3c */
73144 } __attribute__((packed));
73145
73146 #define VIDEO_TYPE_MDA 0x10 /* Monochrome Text Display */
73147 diff --git a/include/uapi/linux/swab.h b/include/uapi/linux/swab.h
73148 index 0e011eb..82681b1 100644
73149 --- a/include/uapi/linux/swab.h
73150 +++ b/include/uapi/linux/swab.h
73151 @@ -43,7 +43,7 @@
73152 * ___swab16, ___swab32, ___swab64, ___swahw32, ___swahb32
73153 */
73154
73155 -static inline __attribute_const__ __u16 __fswab16(__u16 val)
73156 +static inline __intentional_overflow(-1) __attribute_const__ __u16 __fswab16(__u16 val)
73157 {
73158 #ifdef __HAVE_BUILTIN_BSWAP16__
73159 return __builtin_bswap16(val);
73160 @@ -54,7 +54,7 @@ static inline __attribute_const__ __u16 __fswab16(__u16 val)
73161 #endif
73162 }
73163
73164 -static inline __attribute_const__ __u32 __fswab32(__u32 val)
73165 +static inline __intentional_overflow(-1) __attribute_const__ __u32 __fswab32(__u32 val)
73166 {
73167 #ifdef __HAVE_BUILTIN_BSWAP32__
73168 return __builtin_bswap32(val);
73169 @@ -65,7 +65,7 @@ static inline __attribute_const__ __u32 __fswab32(__u32 val)
73170 #endif
73171 }
73172
73173 -static inline __attribute_const__ __u64 __fswab64(__u64 val)
73174 +static inline __intentional_overflow(-1) __attribute_const__ __u64 __fswab64(__u64 val)
73175 {
73176 #ifdef __HAVE_BUILTIN_BSWAP64__
73177 return __builtin_bswap64(val);
73178 diff --git a/include/uapi/linux/sysctl.h b/include/uapi/linux/sysctl.h
73179 index 6d67213..8dab561 100644
73180 --- a/include/uapi/linux/sysctl.h
73181 +++ b/include/uapi/linux/sysctl.h
73182 @@ -155,7 +155,11 @@ enum
73183 KERN_PANIC_ON_NMI=76, /* int: whether we will panic on an unrecovered */
73184 };
73185
73186 -
73187 +#ifdef CONFIG_PAX_SOFTMODE
73188 +enum {
73189 + PAX_SOFTMODE=1 /* PaX: disable/enable soft mode */
73190 +};
73191 +#endif
73192
73193 /* CTL_VM names: */
73194 enum
73195 diff --git a/include/uapi/linux/xattr.h b/include/uapi/linux/xattr.h
73196 index e4629b9..6958086 100644
73197 --- a/include/uapi/linux/xattr.h
73198 +++ b/include/uapi/linux/xattr.h
73199 @@ -63,5 +63,9 @@
73200 #define XATTR_POSIX_ACL_DEFAULT "posix_acl_default"
73201 #define XATTR_NAME_POSIX_ACL_DEFAULT XATTR_SYSTEM_PREFIX XATTR_POSIX_ACL_DEFAULT
73202
73203 +/* User namespace */
73204 +#define XATTR_PAX_PREFIX XATTR_USER_PREFIX "pax."
73205 +#define XATTR_PAX_FLAGS_SUFFIX "flags"
73206 +#define XATTR_NAME_PAX_FLAGS XATTR_PAX_PREFIX XATTR_PAX_FLAGS_SUFFIX
73207
73208 #endif /* _UAPI_LINUX_XATTR_H */
73209 diff --git a/include/video/udlfb.h b/include/video/udlfb.h
73210 index f9466fa..f4e2b81 100644
73211 --- a/include/video/udlfb.h
73212 +++ b/include/video/udlfb.h
73213 @@ -53,10 +53,10 @@ struct dlfb_data {
73214 u32 pseudo_palette[256];
73215 int blank_mode; /*one of FB_BLANK_ */
73216 /* blit-only rendering path metrics, exposed through sysfs */
73217 - atomic_t bytes_rendered; /* raw pixel-bytes driver asked to render */
73218 - atomic_t bytes_identical; /* saved effort with backbuffer comparison */
73219 - atomic_t bytes_sent; /* to usb, after compression including overhead */
73220 - atomic_t cpu_kcycles_used; /* transpired during pixel processing */
73221 + atomic_unchecked_t bytes_rendered; /* raw pixel-bytes driver asked to render */
73222 + atomic_unchecked_t bytes_identical; /* saved effort with backbuffer comparison */
73223 + atomic_unchecked_t bytes_sent; /* to usb, after compression including overhead */
73224 + atomic_unchecked_t cpu_kcycles_used; /* transpired during pixel processing */
73225 };
73226
73227 #define NR_USB_REQUEST_I2C_SUB_IO 0x02
73228 diff --git a/include/video/uvesafb.h b/include/video/uvesafb.h
73229 index 1a91850..28573f8 100644
73230 --- a/include/video/uvesafb.h
73231 +++ b/include/video/uvesafb.h
73232 @@ -122,6 +122,7 @@ struct uvesafb_par {
73233 u8 ypan; /* 0 - nothing, 1 - ypan, 2 - ywrap */
73234 u8 pmi_setpal; /* PMI for palette changes */
73235 u16 *pmi_base; /* protected mode interface location */
73236 + u8 *pmi_code; /* protected mode code location */
73237 void *pmi_start;
73238 void *pmi_pal;
73239 u8 *vbe_state_orig; /*
73240 diff --git a/init/Kconfig b/init/Kconfig
73241 index 5341d72..153f24f 100644
73242 --- a/init/Kconfig
73243 +++ b/init/Kconfig
73244 @@ -984,6 +984,7 @@ endif # CGROUPS
73245
73246 config CHECKPOINT_RESTORE
73247 bool "Checkpoint/restore support" if EXPERT
73248 + depends on !GRKERNSEC
73249 default n
73250 help
73251 Enables additional kernel features in a sake of checkpoint/restore.
73252 @@ -1471,7 +1472,7 @@ config SLUB_DEBUG
73253
73254 config COMPAT_BRK
73255 bool "Disable heap randomization"
73256 - default y
73257 + default n
73258 help
73259 Randomizing heap placement makes heap exploits harder, but it
73260 also breaks ancient binaries (including anything libc5 based).
73261 @@ -1734,7 +1735,7 @@ config INIT_ALL_POSSIBLE
73262 config STOP_MACHINE
73263 bool
73264 default y
73265 - depends on (SMP && MODULE_UNLOAD) || HOTPLUG_CPU
73266 + depends on (SMP && MODULE_UNLOAD) || HOTPLUG_CPU || GRKERNSEC
73267 help
73268 Need stop_machine() primitive.
73269
73270 diff --git a/init/Makefile b/init/Makefile
73271 index 7bc47ee..6da2dc7 100644
73272 --- a/init/Makefile
73273 +++ b/init/Makefile
73274 @@ -2,6 +2,9 @@
73275 # Makefile for the linux kernel.
73276 #
73277
73278 +ccflags-y := $(GCC_PLUGINS_CFLAGS)
73279 +asflags-y := $(GCC_PLUGINS_AFLAGS)
73280 +
73281 obj-y := main.o version.o mounts.o
73282 ifneq ($(CONFIG_BLK_DEV_INITRD),y)
73283 obj-y += noinitramfs.o
73284 diff --git a/init/do_mounts.c b/init/do_mounts.c
73285 index a2b49f2..03a0e17c 100644
73286 --- a/init/do_mounts.c
73287 +++ b/init/do_mounts.c
73288 @@ -355,11 +355,11 @@ static void __init get_fs_names(char *page)
73289 static int __init do_mount_root(char *name, char *fs, int flags, void *data)
73290 {
73291 struct super_block *s;
73292 - int err = sys_mount(name, "/root", fs, flags, data);
73293 + int err = sys_mount((char __force_user *)name, (char __force_user *)"/root", (char __force_user *)fs, flags, (void __force_user *)data);
73294 if (err)
73295 return err;
73296
73297 - sys_chdir("/root");
73298 + sys_chdir((const char __force_user *)"/root");
73299 s = current->fs->pwd.dentry->d_sb;
73300 ROOT_DEV = s->s_dev;
73301 printk(KERN_INFO
73302 @@ -480,18 +480,18 @@ void __init change_floppy(char *fmt, ...)
73303 va_start(args, fmt);
73304 vsprintf(buf, fmt, args);
73305 va_end(args);
73306 - fd = sys_open("/dev/root", O_RDWR | O_NDELAY, 0);
73307 + fd = sys_open((char __user *)"/dev/root", O_RDWR | O_NDELAY, 0);
73308 if (fd >= 0) {
73309 sys_ioctl(fd, FDEJECT, 0);
73310 sys_close(fd);
73311 }
73312 printk(KERN_NOTICE "VFS: Insert %s and press ENTER\n", buf);
73313 - fd = sys_open("/dev/console", O_RDWR, 0);
73314 + fd = sys_open((__force const char __user *)"/dev/console", O_RDWR, 0);
73315 if (fd >= 0) {
73316 sys_ioctl(fd, TCGETS, (long)&termios);
73317 termios.c_lflag &= ~ICANON;
73318 sys_ioctl(fd, TCSETSF, (long)&termios);
73319 - sys_read(fd, &c, 1);
73320 + sys_read(fd, (char __user *)&c, 1);
73321 termios.c_lflag |= ICANON;
73322 sys_ioctl(fd, TCSETSF, (long)&termios);
73323 sys_close(fd);
73324 @@ -585,6 +585,6 @@ void __init prepare_namespace(void)
73325 mount_root();
73326 out:
73327 devtmpfs_mount("dev");
73328 - sys_mount(".", "/", NULL, MS_MOVE, NULL);
73329 - sys_chroot(".");
73330 + sys_mount((char __force_user *)".", (char __force_user *)"/", NULL, MS_MOVE, NULL);
73331 + sys_chroot((const char __force_user *)".");
73332 }
73333 diff --git a/init/do_mounts.h b/init/do_mounts.h
73334 index f5b978a..69dbfe8 100644
73335 --- a/init/do_mounts.h
73336 +++ b/init/do_mounts.h
73337 @@ -15,15 +15,15 @@ extern int root_mountflags;
73338
73339 static inline int create_dev(char *name, dev_t dev)
73340 {
73341 - sys_unlink(name);
73342 - return sys_mknod(name, S_IFBLK|0600, new_encode_dev(dev));
73343 + sys_unlink((char __force_user *)name);
73344 + return sys_mknod((char __force_user *)name, S_IFBLK|0600, new_encode_dev(dev));
73345 }
73346
73347 #if BITS_PER_LONG == 32
73348 static inline u32 bstat(char *name)
73349 {
73350 struct stat64 stat;
73351 - if (sys_stat64(name, &stat) != 0)
73352 + if (sys_stat64((char __force_user *)name, (struct stat64 __force_user *)&stat) != 0)
73353 return 0;
73354 if (!S_ISBLK(stat.st_mode))
73355 return 0;
73356 @@ -35,7 +35,7 @@ static inline u32 bstat(char *name)
73357 static inline u32 bstat(char *name)
73358 {
73359 struct stat stat;
73360 - if (sys_newstat(name, &stat) != 0)
73361 + if (sys_newstat((const char __force_user *)name, (struct stat __force_user *)&stat) != 0)
73362 return 0;
73363 if (!S_ISBLK(stat.st_mode))
73364 return 0;
73365 diff --git a/init/do_mounts_initrd.c b/init/do_mounts_initrd.c
73366 index a32ec1c..60a6659 100644
73367 --- a/init/do_mounts_initrd.c
73368 +++ b/init/do_mounts_initrd.c
73369 @@ -37,13 +37,13 @@ static int init_linuxrc(struct subprocess_info *info, struct cred *new)
73370 {
73371 sys_unshare(CLONE_FS | CLONE_FILES);
73372 /* stdin/stdout/stderr for /linuxrc */
73373 - sys_open("/dev/console", O_RDWR, 0);
73374 + sys_open((const char __force_user *)"/dev/console", O_RDWR, 0);
73375 sys_dup(0);
73376 sys_dup(0);
73377 /* move initrd over / and chdir/chroot in initrd root */
73378 - sys_chdir("/root");
73379 - sys_mount(".", "/", NULL, MS_MOVE, NULL);
73380 - sys_chroot(".");
73381 + sys_chdir((const char __force_user *)"/root");
73382 + sys_mount((char __force_user *)".", (char __force_user *)"/", NULL, MS_MOVE, NULL);
73383 + sys_chroot((const char __force_user *)".");
73384 sys_setsid();
73385 return 0;
73386 }
73387 @@ -58,8 +58,8 @@ static void __init handle_initrd(void)
73388 create_dev("/dev/root.old", Root_RAM0);
73389 /* mount initrd on rootfs' /root */
73390 mount_block_root("/dev/root.old", root_mountflags & ~MS_RDONLY);
73391 - sys_mkdir("/old", 0700);
73392 - sys_chdir("/old");
73393 + sys_mkdir((const char __force_user *)"/old", 0700);
73394 + sys_chdir((const char __force_user *)"/old");
73395
73396 /* try loading default modules from initrd */
73397 load_default_modules();
73398 @@ -76,31 +76,31 @@ static void __init handle_initrd(void)
73399 current->flags &= ~PF_FREEZER_SKIP;
73400
73401 /* move initrd to rootfs' /old */
73402 - sys_mount("..", ".", NULL, MS_MOVE, NULL);
73403 + sys_mount((char __force_user *)"..", (char __force_user *)".", NULL, MS_MOVE, NULL);
73404 /* switch root and cwd back to / of rootfs */
73405 - sys_chroot("..");
73406 + sys_chroot((const char __force_user *)"..");
73407
73408 if (new_decode_dev(real_root_dev) == Root_RAM0) {
73409 - sys_chdir("/old");
73410 + sys_chdir((const char __force_user *)"/old");
73411 return;
73412 }
73413
73414 - sys_chdir("/");
73415 + sys_chdir((const char __force_user *)"/");
73416 ROOT_DEV = new_decode_dev(real_root_dev);
73417 mount_root();
73418
73419 printk(KERN_NOTICE "Trying to move old root to /initrd ... ");
73420 - error = sys_mount("/old", "/root/initrd", NULL, MS_MOVE, NULL);
73421 + error = sys_mount((char __force_user *)"/old", (char __force_user *)"/root/initrd", NULL, MS_MOVE, NULL);
73422 if (!error)
73423 printk("okay\n");
73424 else {
73425 - int fd = sys_open("/dev/root.old", O_RDWR, 0);
73426 + int fd = sys_open((const char __force_user *)"/dev/root.old", O_RDWR, 0);
73427 if (error == -ENOENT)
73428 printk("/initrd does not exist. Ignored.\n");
73429 else
73430 printk("failed\n");
73431 printk(KERN_NOTICE "Unmounting old root\n");
73432 - sys_umount("/old", MNT_DETACH);
73433 + sys_umount((char __force_user *)"/old", MNT_DETACH);
73434 printk(KERN_NOTICE "Trying to free ramdisk memory ... ");
73435 if (fd < 0) {
73436 error = fd;
73437 @@ -123,11 +123,11 @@ int __init initrd_load(void)
73438 * mounted in the normal path.
73439 */
73440 if (rd_load_image("/initrd.image") && ROOT_DEV != Root_RAM0) {
73441 - sys_unlink("/initrd.image");
73442 + sys_unlink((const char __force_user *)"/initrd.image");
73443 handle_initrd();
73444 return 1;
73445 }
73446 }
73447 - sys_unlink("/initrd.image");
73448 + sys_unlink((const char __force_user *)"/initrd.image");
73449 return 0;
73450 }
73451 diff --git a/init/do_mounts_md.c b/init/do_mounts_md.c
73452 index 8cb6db5..d729f50 100644
73453 --- a/init/do_mounts_md.c
73454 +++ b/init/do_mounts_md.c
73455 @@ -180,7 +180,7 @@ static void __init md_setup_drive(void)
73456 partitioned ? "_d" : "", minor,
73457 md_setup_args[ent].device_names);
73458
73459 - fd = sys_open(name, 0, 0);
73460 + fd = sys_open((char __force_user *)name, 0, 0);
73461 if (fd < 0) {
73462 printk(KERN_ERR "md: open failed - cannot start "
73463 "array %s\n", name);
73464 @@ -243,7 +243,7 @@ static void __init md_setup_drive(void)
73465 * array without it
73466 */
73467 sys_close(fd);
73468 - fd = sys_open(name, 0, 0);
73469 + fd = sys_open((char __force_user *)name, 0, 0);
73470 sys_ioctl(fd, BLKRRPART, 0);
73471 }
73472 sys_close(fd);
73473 @@ -293,7 +293,7 @@ static void __init autodetect_raid(void)
73474
73475 wait_for_device_probe();
73476
73477 - fd = sys_open("/dev/md0", 0, 0);
73478 + fd = sys_open((const char __force_user *) "/dev/md0", 0, 0);
73479 if (fd >= 0) {
73480 sys_ioctl(fd, RAID_AUTORUN, raid_autopart);
73481 sys_close(fd);
73482 diff --git a/init/init_task.c b/init/init_task.c
73483 index ba0a7f36..2bcf1d5 100644
73484 --- a/init/init_task.c
73485 +++ b/init/init_task.c
73486 @@ -22,5 +22,9 @@ EXPORT_SYMBOL(init_task);
73487 * Initial thread structure. Alignment of this is handled by a special
73488 * linker map entry.
73489 */
73490 +#ifdef CONFIG_X86
73491 +union thread_union init_thread_union __init_task_data;
73492 +#else
73493 union thread_union init_thread_union __init_task_data =
73494 { INIT_THREAD_INFO(init_task) };
73495 +#endif
73496 diff --git a/init/initramfs.c b/init/initramfs.c
73497 index a67ef9d..3d88592 100644
73498 --- a/init/initramfs.c
73499 +++ b/init/initramfs.c
73500 @@ -84,7 +84,7 @@ static void __init free_hash(void)
73501 }
73502 }
73503
73504 -static long __init do_utime(char *filename, time_t mtime)
73505 +static long __init do_utime(char __force_user *filename, time_t mtime)
73506 {
73507 struct timespec t[2];
73508
73509 @@ -119,7 +119,7 @@ static void __init dir_utime(void)
73510 struct dir_entry *de, *tmp;
73511 list_for_each_entry_safe(de, tmp, &dir_list, list) {
73512 list_del(&de->list);
73513 - do_utime(de->name, de->mtime);
73514 + do_utime((char __force_user *)de->name, de->mtime);
73515 kfree(de->name);
73516 kfree(de);
73517 }
73518 @@ -281,7 +281,7 @@ static int __init maybe_link(void)
73519 if (nlink >= 2) {
73520 char *old = find_link(major, minor, ino, mode, collected);
73521 if (old)
73522 - return (sys_link(old, collected) < 0) ? -1 : 1;
73523 + return (sys_link((char __force_user *)old, (char __force_user *)collected) < 0) ? -1 : 1;
73524 }
73525 return 0;
73526 }
73527 @@ -290,11 +290,11 @@ static void __init clean_path(char *path, umode_t mode)
73528 {
73529 struct stat st;
73530
73531 - if (!sys_newlstat(path, &st) && (st.st_mode^mode) & S_IFMT) {
73532 + if (!sys_newlstat((char __force_user *)path, (struct stat __force_user *)&st) && (st.st_mode^mode) & S_IFMT) {
73533 if (S_ISDIR(st.st_mode))
73534 - sys_rmdir(path);
73535 + sys_rmdir((char __force_user *)path);
73536 else
73537 - sys_unlink(path);
73538 + sys_unlink((char __force_user *)path);
73539 }
73540 }
73541
73542 @@ -315,7 +315,7 @@ static int __init do_name(void)
73543 int openflags = O_WRONLY|O_CREAT;
73544 if (ml != 1)
73545 openflags |= O_TRUNC;
73546 - wfd = sys_open(collected, openflags, mode);
73547 + wfd = sys_open((char __force_user *)collected, openflags, mode);
73548
73549 if (wfd >= 0) {
73550 sys_fchown(wfd, uid, gid);
73551 @@ -327,17 +327,17 @@ static int __init do_name(void)
73552 }
73553 }
73554 } else if (S_ISDIR(mode)) {
73555 - sys_mkdir(collected, mode);
73556 - sys_chown(collected, uid, gid);
73557 - sys_chmod(collected, mode);
73558 + sys_mkdir((char __force_user *)collected, mode);
73559 + sys_chown((char __force_user *)collected, uid, gid);
73560 + sys_chmod((char __force_user *)collected, mode);
73561 dir_add(collected, mtime);
73562 } else if (S_ISBLK(mode) || S_ISCHR(mode) ||
73563 S_ISFIFO(mode) || S_ISSOCK(mode)) {
73564 if (maybe_link() == 0) {
73565 - sys_mknod(collected, mode, rdev);
73566 - sys_chown(collected, uid, gid);
73567 - sys_chmod(collected, mode);
73568 - do_utime(collected, mtime);
73569 + sys_mknod((char __force_user *)collected, mode, rdev);
73570 + sys_chown((char __force_user *)collected, uid, gid);
73571 + sys_chmod((char __force_user *)collected, mode);
73572 + do_utime((char __force_user *)collected, mtime);
73573 }
73574 }
73575 return 0;
73576 @@ -346,15 +346,15 @@ static int __init do_name(void)
73577 static int __init do_copy(void)
73578 {
73579 if (count >= body_len) {
73580 - sys_write(wfd, victim, body_len);
73581 + sys_write(wfd, (char __force_user *)victim, body_len);
73582 sys_close(wfd);
73583 - do_utime(vcollected, mtime);
73584 + do_utime((char __force_user *)vcollected, mtime);
73585 kfree(vcollected);
73586 eat(body_len);
73587 state = SkipIt;
73588 return 0;
73589 } else {
73590 - sys_write(wfd, victim, count);
73591 + sys_write(wfd, (char __force_user *)victim, count);
73592 body_len -= count;
73593 eat(count);
73594 return 1;
73595 @@ -365,9 +365,9 @@ static int __init do_symlink(void)
73596 {
73597 collected[N_ALIGN(name_len) + body_len] = '\0';
73598 clean_path(collected, 0);
73599 - sys_symlink(collected + N_ALIGN(name_len), collected);
73600 - sys_lchown(collected, uid, gid);
73601 - do_utime(collected, mtime);
73602 + sys_symlink((char __force_user *)collected + N_ALIGN(name_len), (char __force_user *)collected);
73603 + sys_lchown((char __force_user *)collected, uid, gid);
73604 + do_utime((char __force_user *)collected, mtime);
73605 state = SkipIt;
73606 next_state = Reset;
73607 return 0;
73608 diff --git a/init/main.c b/init/main.c
73609 index 63534a1..85feae2 100644
73610 --- a/init/main.c
73611 +++ b/init/main.c
73612 @@ -98,6 +98,8 @@ static inline void mark_rodata_ro(void) { }
73613 extern void tc_init(void);
73614 #endif
73615
73616 +extern void grsecurity_init(void);
73617 +
73618 /*
73619 * Debug helper: via this flag we know that we are in 'early bootup code'
73620 * where only the boot processor is running with IRQ disabled. This means
73621 @@ -151,6 +153,64 @@ static int __init set_reset_devices(char *str)
73622
73623 __setup("reset_devices", set_reset_devices);
73624
73625 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
73626 +kgid_t grsec_proc_gid = KGIDT_INIT(CONFIG_GRKERNSEC_PROC_GID);
73627 +static int __init setup_grsec_proc_gid(char *str)
73628 +{
73629 + grsec_proc_gid = KGIDT_INIT(simple_strtol(str, NULL, 0));
73630 + return 1;
73631 +}
73632 +__setup("grsec_proc_gid=", setup_grsec_proc_gid);
73633 +#endif
73634 +
73635 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
73636 +unsigned long pax_user_shadow_base __read_only = 1UL << TASK_SIZE_MAX_SHIFT;
73637 +EXPORT_SYMBOL(pax_user_shadow_base);
73638 +extern char pax_enter_kernel_user[];
73639 +extern char pax_exit_kernel_user[];
73640 +extern pgdval_t clone_pgd_mask;
73641 +#endif
73642 +
73643 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_MEMORY_UDEREF)
73644 +static int __init setup_pax_nouderef(char *str)
73645 +{
73646 +#ifdef CONFIG_X86_32
73647 + unsigned int cpu;
73648 + struct desc_struct *gdt;
73649 +
73650 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
73651 + gdt = get_cpu_gdt_table(cpu);
73652 + gdt[GDT_ENTRY_KERNEL_DS].type = 3;
73653 + gdt[GDT_ENTRY_KERNEL_DS].limit = 0xf;
73654 + gdt[GDT_ENTRY_DEFAULT_USER_CS].limit = 0xf;
73655 + gdt[GDT_ENTRY_DEFAULT_USER_DS].limit = 0xf;
73656 + }
73657 + loadsegment(ds, __KERNEL_DS);
73658 + loadsegment(es, __KERNEL_DS);
73659 + loadsegment(ss, __KERNEL_DS);
73660 +#else
73661 + memcpy(pax_enter_kernel_user, (unsigned char []){0xc3}, 1);
73662 + memcpy(pax_exit_kernel_user, (unsigned char []){0xc3}, 1);
73663 + clone_pgd_mask = ~(pgdval_t)0UL;
73664 + pax_user_shadow_base = 0UL;
73665 +#endif
73666 +
73667 + return 0;
73668 +}
73669 +early_param("pax_nouderef", setup_pax_nouderef);
73670 +#endif
73671 +
73672 +#ifdef CONFIG_PAX_SOFTMODE
73673 +int pax_softmode;
73674 +
73675 +static int __init setup_pax_softmode(char *str)
73676 +{
73677 + get_option(&str, &pax_softmode);
73678 + return 1;
73679 +}
73680 +__setup("pax_softmode=", setup_pax_softmode);
73681 +#endif
73682 +
73683 static const char * argv_init[MAX_INIT_ARGS+2] = { "init", NULL, };
73684 const char * envp_init[MAX_INIT_ENVS+2] = { "HOME=/", "TERM=linux", NULL, };
73685 static const char *panic_later, *panic_param;
73686 @@ -683,6 +743,7 @@ int __init_or_module do_one_initcall(initcall_t fn)
73687 {
73688 int count = preempt_count();
73689 int ret;
73690 + const char *msg1 = "", *msg2 = "";
73691
73692 if (initcall_debug)
73693 ret = do_one_initcall_debug(fn);
73694 @@ -695,15 +756,15 @@ int __init_or_module do_one_initcall(initcall_t fn)
73695 sprintf(msgbuf, "error code %d ", ret);
73696
73697 if (preempt_count() != count) {
73698 - strlcat(msgbuf, "preemption imbalance ", sizeof(msgbuf));
73699 + msg1 = " preemption imbalance";
73700 preempt_count() = count;
73701 }
73702 if (irqs_disabled()) {
73703 - strlcat(msgbuf, "disabled interrupts ", sizeof(msgbuf));
73704 + msg2 = " disabled interrupts";
73705 local_irq_enable();
73706 }
73707 - if (msgbuf[0]) {
73708 - printk("initcall %pF returned with %s\n", fn, msgbuf);
73709 + if (msgbuf[0] || *msg1 || *msg2) {
73710 + printk("initcall %pF returned with %s%s%s\n", fn, msgbuf, msg1, msg2);
73711 }
73712
73713 return ret;
73714 @@ -757,8 +818,14 @@ static void __init do_initcall_level(int level)
73715 level, level,
73716 &repair_env_string);
73717
73718 - for (fn = initcall_levels[level]; fn < initcall_levels[level+1]; fn++)
73719 + for (fn = initcall_levels[level]; fn < initcall_levels[level+1]; fn++) {
73720 do_one_initcall(*fn);
73721 +
73722 +#ifdef LATENT_ENTROPY_PLUGIN
73723 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
73724 +#endif
73725 +
73726 + }
73727 }
73728
73729 static void __init do_initcalls(void)
73730 @@ -792,8 +859,14 @@ static void __init do_pre_smp_initcalls(void)
73731 {
73732 initcall_t *fn;
73733
73734 - for (fn = __initcall_start; fn < __initcall0_start; fn++)
73735 + for (fn = __initcall_start; fn < __initcall0_start; fn++) {
73736 do_one_initcall(*fn);
73737 +
73738 +#ifdef LATENT_ENTROPY_PLUGIN
73739 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
73740 +#endif
73741 +
73742 + }
73743 }
73744
73745 /*
73746 @@ -811,8 +884,8 @@ static int run_init_process(const char *init_filename)
73747 {
73748 argv_init[0] = init_filename;
73749 return do_execve(init_filename,
73750 - (const char __user *const __user *)argv_init,
73751 - (const char __user *const __user *)envp_init);
73752 + (const char __user *const __force_user *)argv_init,
73753 + (const char __user *const __force_user *)envp_init);
73754 }
73755
73756 static noinline void __init kernel_init_freeable(void);
73757 @@ -890,7 +963,7 @@ static noinline void __init kernel_init_freeable(void)
73758 do_basic_setup();
73759
73760 /* Open the /dev/console on the rootfs, this should never fail */
73761 - if (sys_open((const char __user *) "/dev/console", O_RDWR, 0) < 0)
73762 + if (sys_open((const char __force_user *) "/dev/console", O_RDWR, 0) < 0)
73763 printk(KERN_WARNING "Warning: unable to open an initial console.\n");
73764
73765 (void) sys_dup(0);
73766 @@ -903,11 +976,13 @@ static noinline void __init kernel_init_freeable(void)
73767 if (!ramdisk_execute_command)
73768 ramdisk_execute_command = "/init";
73769
73770 - if (sys_access((const char __user *) ramdisk_execute_command, 0) != 0) {
73771 + if (sys_access((const char __force_user *) ramdisk_execute_command, 0) != 0) {
73772 ramdisk_execute_command = NULL;
73773 prepare_namespace();
73774 }
73775
73776 + grsecurity_init();
73777 +
73778 /*
73779 * Ok, we have completed the initial bootup, and
73780 * we're essentially up and running. Get rid of the
73781 diff --git a/ipc/ipc_sysctl.c b/ipc/ipc_sysctl.c
73782 index 130dfec..cc88451 100644
73783 --- a/ipc/ipc_sysctl.c
73784 +++ b/ipc/ipc_sysctl.c
73785 @@ -30,7 +30,7 @@ static void *get_ipc(ctl_table *table)
73786 static int proc_ipc_dointvec(ctl_table *table, int write,
73787 void __user *buffer, size_t *lenp, loff_t *ppos)
73788 {
73789 - struct ctl_table ipc_table;
73790 + ctl_table_no_const ipc_table;
73791
73792 memcpy(&ipc_table, table, sizeof(ipc_table));
73793 ipc_table.data = get_ipc(table);
73794 @@ -41,7 +41,7 @@ static int proc_ipc_dointvec(ctl_table *table, int write,
73795 static int proc_ipc_dointvec_minmax(ctl_table *table, int write,
73796 void __user *buffer, size_t *lenp, loff_t *ppos)
73797 {
73798 - struct ctl_table ipc_table;
73799 + ctl_table_no_const ipc_table;
73800
73801 memcpy(&ipc_table, table, sizeof(ipc_table));
73802 ipc_table.data = get_ipc(table);
73803 @@ -65,7 +65,7 @@ static int proc_ipc_dointvec_minmax_orphans(ctl_table *table, int write,
73804 static int proc_ipc_callback_dointvec(ctl_table *table, int write,
73805 void __user *buffer, size_t *lenp, loff_t *ppos)
73806 {
73807 - struct ctl_table ipc_table;
73808 + ctl_table_no_const ipc_table;
73809 size_t lenp_bef = *lenp;
73810 int rc;
73811
73812 @@ -88,7 +88,7 @@ static int proc_ipc_callback_dointvec(ctl_table *table, int write,
73813 static int proc_ipc_doulongvec_minmax(ctl_table *table, int write,
73814 void __user *buffer, size_t *lenp, loff_t *ppos)
73815 {
73816 - struct ctl_table ipc_table;
73817 + ctl_table_no_const ipc_table;
73818 memcpy(&ipc_table, table, sizeof(ipc_table));
73819 ipc_table.data = get_ipc(table);
73820
73821 @@ -122,7 +122,7 @@ static void ipc_auto_callback(int val)
73822 static int proc_ipcauto_dointvec_minmax(ctl_table *table, int write,
73823 void __user *buffer, size_t *lenp, loff_t *ppos)
73824 {
73825 - struct ctl_table ipc_table;
73826 + ctl_table_no_const ipc_table;
73827 size_t lenp_bef = *lenp;
73828 int oldval;
73829 int rc;
73830 diff --git a/ipc/mq_sysctl.c b/ipc/mq_sysctl.c
73831 index 383d638..943fdbb 100644
73832 --- a/ipc/mq_sysctl.c
73833 +++ b/ipc/mq_sysctl.c
73834 @@ -25,7 +25,7 @@ static void *get_mq(ctl_table *table)
73835 static int proc_mq_dointvec_minmax(ctl_table *table, int write,
73836 void __user *buffer, size_t *lenp, loff_t *ppos)
73837 {
73838 - struct ctl_table mq_table;
73839 + ctl_table_no_const mq_table;
73840 memcpy(&mq_table, table, sizeof(mq_table));
73841 mq_table.data = get_mq(table);
73842
73843 diff --git a/ipc/mqueue.c b/ipc/mqueue.c
73844 index e4e47f6..a85e0ad 100644
73845 --- a/ipc/mqueue.c
73846 +++ b/ipc/mqueue.c
73847 @@ -278,6 +278,7 @@ static struct inode *mqueue_get_inode(struct super_block *sb,
73848 mq_bytes = mq_treesize + (info->attr.mq_maxmsg *
73849 info->attr.mq_msgsize);
73850
73851 + gr_learn_resource(current, RLIMIT_MSGQUEUE, u->mq_bytes + mq_bytes, 1);
73852 spin_lock(&mq_lock);
73853 if (u->mq_bytes + mq_bytes < u->mq_bytes ||
73854 u->mq_bytes + mq_bytes > rlimit(RLIMIT_MSGQUEUE)) {
73855 diff --git a/ipc/msg.c b/ipc/msg.c
73856 index fede1d0..9778e0f8 100644
73857 --- a/ipc/msg.c
73858 +++ b/ipc/msg.c
73859 @@ -309,18 +309,19 @@ static inline int msg_security(struct kern_ipc_perm *ipcp, int msgflg)
73860 return security_msg_queue_associate(msq, msgflg);
73861 }
73862
73863 +static struct ipc_ops msg_ops = {
73864 + .getnew = newque,
73865 + .associate = msg_security,
73866 + .more_checks = NULL
73867 +};
73868 +
73869 SYSCALL_DEFINE2(msgget, key_t, key, int, msgflg)
73870 {
73871 struct ipc_namespace *ns;
73872 - struct ipc_ops msg_ops;
73873 struct ipc_params msg_params;
73874
73875 ns = current->nsproxy->ipc_ns;
73876
73877 - msg_ops.getnew = newque;
73878 - msg_ops.associate = msg_security;
73879 - msg_ops.more_checks = NULL;
73880 -
73881 msg_params.key = key;
73882 msg_params.flg = msgflg;
73883
73884 diff --git a/ipc/sem.c b/ipc/sem.c
73885 index 58d31f1..cce7a55 100644
73886 --- a/ipc/sem.c
73887 +++ b/ipc/sem.c
73888 @@ -364,10 +364,15 @@ static inline int sem_more_checks(struct kern_ipc_perm *ipcp,
73889 return 0;
73890 }
73891
73892 +static struct ipc_ops sem_ops = {
73893 + .getnew = newary,
73894 + .associate = sem_security,
73895 + .more_checks = sem_more_checks
73896 +};
73897 +
73898 SYSCALL_DEFINE3(semget, key_t, key, int, nsems, int, semflg)
73899 {
73900 struct ipc_namespace *ns;
73901 - struct ipc_ops sem_ops;
73902 struct ipc_params sem_params;
73903
73904 ns = current->nsproxy->ipc_ns;
73905 @@ -375,10 +380,6 @@ SYSCALL_DEFINE3(semget, key_t, key, int, nsems, int, semflg)
73906 if (nsems < 0 || nsems > ns->sc_semmsl)
73907 return -EINVAL;
73908
73909 - sem_ops.getnew = newary;
73910 - sem_ops.associate = sem_security;
73911 - sem_ops.more_checks = sem_more_checks;
73912 -
73913 sem_params.key = key;
73914 sem_params.flg = semflg;
73915 sem_params.u.nsems = nsems;
73916 diff --git a/ipc/shm.c b/ipc/shm.c
73917 index 7e199fa..180a1ca 100644
73918 --- a/ipc/shm.c
73919 +++ b/ipc/shm.c
73920 @@ -69,6 +69,14 @@ static void shm_destroy (struct ipc_namespace *ns, struct shmid_kernel *shp);
73921 static int sysvipc_shm_proc_show(struct seq_file *s, void *it);
73922 #endif
73923
73924 +#ifdef CONFIG_GRKERNSEC
73925 +extern int gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
73926 + const time_t shm_createtime, const kuid_t cuid,
73927 + const int shmid);
73928 +extern int gr_chroot_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
73929 + const time_t shm_createtime);
73930 +#endif
73931 +
73932 void shm_init_ns(struct ipc_namespace *ns)
73933 {
73934 ns->shm_ctlmax = SHMMAX;
73935 @@ -531,6 +539,14 @@ static int newseg(struct ipc_namespace *ns, struct ipc_params *params)
73936 shp->shm_lprid = 0;
73937 shp->shm_atim = shp->shm_dtim = 0;
73938 shp->shm_ctim = get_seconds();
73939 +#ifdef CONFIG_GRKERNSEC
73940 + {
73941 + struct timespec timeval;
73942 + do_posix_clock_monotonic_gettime(&timeval);
73943 +
73944 + shp->shm_createtime = timeval.tv_sec;
73945 + }
73946 +#endif
73947 shp->shm_segsz = size;
73948 shp->shm_nattch = 0;
73949 shp->shm_file = file;
73950 @@ -582,18 +598,19 @@ static inline int shm_more_checks(struct kern_ipc_perm *ipcp,
73951 return 0;
73952 }
73953
73954 +static struct ipc_ops shm_ops = {
73955 + .getnew = newseg,
73956 + .associate = shm_security,
73957 + .more_checks = shm_more_checks
73958 +};
73959 +
73960 SYSCALL_DEFINE3(shmget, key_t, key, size_t, size, int, shmflg)
73961 {
73962 struct ipc_namespace *ns;
73963 - struct ipc_ops shm_ops;
73964 struct ipc_params shm_params;
73965
73966 ns = current->nsproxy->ipc_ns;
73967
73968 - shm_ops.getnew = newseg;
73969 - shm_ops.associate = shm_security;
73970 - shm_ops.more_checks = shm_more_checks;
73971 -
73972 shm_params.key = key;
73973 shm_params.flg = shmflg;
73974 shm_params.u.size = size;
73975 @@ -1014,6 +1031,12 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
73976 f_mode = FMODE_READ | FMODE_WRITE;
73977 }
73978 if (shmflg & SHM_EXEC) {
73979 +
73980 +#ifdef CONFIG_PAX_MPROTECT
73981 + if (current->mm->pax_flags & MF_PAX_MPROTECT)
73982 + goto out;
73983 +#endif
73984 +
73985 prot |= PROT_EXEC;
73986 acc_mode |= S_IXUGO;
73987 }
73988 @@ -1037,9 +1060,21 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
73989 if (err)
73990 goto out_unlock;
73991
73992 +#ifdef CONFIG_GRKERNSEC
73993 + if (!gr_handle_shmat(shp->shm_cprid, shp->shm_lapid, shp->shm_createtime,
73994 + shp->shm_perm.cuid, shmid) ||
73995 + !gr_chroot_shmat(shp->shm_cprid, shp->shm_lapid, shp->shm_createtime)) {
73996 + err = -EACCES;
73997 + goto out_unlock;
73998 + }
73999 +#endif
74000 +
74001 path = shp->shm_file->f_path;
74002 path_get(&path);
74003 shp->shm_nattch++;
74004 +#ifdef CONFIG_GRKERNSEC
74005 + shp->shm_lapid = current->pid;
74006 +#endif
74007 size = i_size_read(path.dentry->d_inode);
74008 shm_unlock(shp);
74009
74010 diff --git a/kernel/acct.c b/kernel/acct.c
74011 index b9bd7f0..1762b4a 100644
74012 --- a/kernel/acct.c
74013 +++ b/kernel/acct.c
74014 @@ -550,7 +550,7 @@ static void do_acct_process(struct bsd_acct_struct *acct,
74015 */
74016 flim = current->signal->rlim[RLIMIT_FSIZE].rlim_cur;
74017 current->signal->rlim[RLIMIT_FSIZE].rlim_cur = RLIM_INFINITY;
74018 - file->f_op->write(file, (char *)&ac,
74019 + file->f_op->write(file, (char __force_user *)&ac,
74020 sizeof(acct_t), &file->f_pos);
74021 current->signal->rlim[RLIMIT_FSIZE].rlim_cur = flim;
74022 set_fs(fs);
74023 diff --git a/kernel/audit.c b/kernel/audit.c
74024 index d596e53..dbef3c3 100644
74025 --- a/kernel/audit.c
74026 +++ b/kernel/audit.c
74027 @@ -116,7 +116,7 @@ u32 audit_sig_sid = 0;
74028 3) suppressed due to audit_rate_limit
74029 4) suppressed due to audit_backlog_limit
74030 */
74031 -static atomic_t audit_lost = ATOMIC_INIT(0);
74032 +static atomic_unchecked_t audit_lost = ATOMIC_INIT(0);
74033
74034 /* The netlink socket. */
74035 static struct sock *audit_sock;
74036 @@ -238,7 +238,7 @@ void audit_log_lost(const char *message)
74037 unsigned long now;
74038 int print;
74039
74040 - atomic_inc(&audit_lost);
74041 + atomic_inc_unchecked(&audit_lost);
74042
74043 print = (audit_failure == AUDIT_FAIL_PANIC || !audit_rate_limit);
74044
74045 @@ -257,7 +257,7 @@ void audit_log_lost(const char *message)
74046 printk(KERN_WARNING
74047 "audit: audit_lost=%d audit_rate_limit=%d "
74048 "audit_backlog_limit=%d\n",
74049 - atomic_read(&audit_lost),
74050 + atomic_read_unchecked(&audit_lost),
74051 audit_rate_limit,
74052 audit_backlog_limit);
74053 audit_panic(message);
74054 @@ -681,7 +681,7 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
74055 status_set.pid = audit_pid;
74056 status_set.rate_limit = audit_rate_limit;
74057 status_set.backlog_limit = audit_backlog_limit;
74058 - status_set.lost = atomic_read(&audit_lost);
74059 + status_set.lost = atomic_read_unchecked(&audit_lost);
74060 status_set.backlog = skb_queue_len(&audit_skb_queue);
74061 audit_send_reply(NETLINK_CB(skb).portid, seq, AUDIT_GET, 0, 0,
74062 &status_set, sizeof(status_set));
74063 diff --git a/kernel/auditsc.c b/kernel/auditsc.c
74064 index c4b72b0..8654c4e 100644
74065 --- a/kernel/auditsc.c
74066 +++ b/kernel/auditsc.c
74067 @@ -2295,7 +2295,7 @@ int auditsc_get_stamp(struct audit_context *ctx,
74068 }
74069
74070 /* global counter which is incremented every time something logs in */
74071 -static atomic_t session_id = ATOMIC_INIT(0);
74072 +static atomic_unchecked_t session_id = ATOMIC_INIT(0);
74073
74074 /**
74075 * audit_set_loginuid - set current task's audit_context loginuid
74076 @@ -2319,7 +2319,7 @@ int audit_set_loginuid(kuid_t loginuid)
74077 return -EPERM;
74078 #endif /* CONFIG_AUDIT_LOGINUID_IMMUTABLE */
74079
74080 - sessionid = atomic_inc_return(&session_id);
74081 + sessionid = atomic_inc_return_unchecked(&session_id);
74082 if (context && context->in_syscall) {
74083 struct audit_buffer *ab;
74084
74085 diff --git a/kernel/capability.c b/kernel/capability.c
74086 index f6c2ce5..982c0f9 100644
74087 --- a/kernel/capability.c
74088 +++ b/kernel/capability.c
74089 @@ -202,6 +202,9 @@ SYSCALL_DEFINE2(capget, cap_user_header_t, header, cap_user_data_t, dataptr)
74090 * before modification is attempted and the application
74091 * fails.
74092 */
74093 + if (tocopy > ARRAY_SIZE(kdata))
74094 + return -EFAULT;
74095 +
74096 if (copy_to_user(dataptr, kdata, tocopy
74097 * sizeof(struct __user_cap_data_struct))) {
74098 return -EFAULT;
74099 @@ -303,10 +306,11 @@ bool has_ns_capability(struct task_struct *t,
74100 int ret;
74101
74102 rcu_read_lock();
74103 - ret = security_capable(__task_cred(t), ns, cap);
74104 + ret = security_capable(__task_cred(t), ns, cap) == 0 &&
74105 + gr_task_is_capable(t, __task_cred(t), cap);
74106 rcu_read_unlock();
74107
74108 - return (ret == 0);
74109 + return ret;
74110 }
74111
74112 /**
74113 @@ -343,10 +347,10 @@ bool has_ns_capability_noaudit(struct task_struct *t,
74114 int ret;
74115
74116 rcu_read_lock();
74117 - ret = security_capable_noaudit(__task_cred(t), ns, cap);
74118 + ret = security_capable_noaudit(__task_cred(t), ns, cap) == 0 && gr_task_is_capable_nolog(t, cap);
74119 rcu_read_unlock();
74120
74121 - return (ret == 0);
74122 + return ret;
74123 }
74124
74125 /**
74126 @@ -384,7 +388,7 @@ bool ns_capable(struct user_namespace *ns, int cap)
74127 BUG();
74128 }
74129
74130 - if (security_capable(current_cred(), ns, cap) == 0) {
74131 + if (security_capable(current_cred(), ns, cap) == 0 && gr_is_capable(cap)) {
74132 current->flags |= PF_SUPERPRIV;
74133 return true;
74134 }
74135 @@ -392,6 +396,21 @@ bool ns_capable(struct user_namespace *ns, int cap)
74136 }
74137 EXPORT_SYMBOL(ns_capable);
74138
74139 +bool ns_capable_nolog(struct user_namespace *ns, int cap)
74140 +{
74141 + if (unlikely(!cap_valid(cap))) {
74142 + printk(KERN_CRIT "capable_nolog() called with invalid cap=%u\n", cap);
74143 + BUG();
74144 + }
74145 +
74146 + if (security_capable_noaudit(current_cred(), ns, cap) == 0 && gr_is_capable_nolog(cap)) {
74147 + current->flags |= PF_SUPERPRIV;
74148 + return true;
74149 + }
74150 + return false;
74151 +}
74152 +EXPORT_SYMBOL(ns_capable_nolog);
74153 +
74154 /**
74155 * file_ns_capable - Determine if the file's opener had a capability in effect
74156 * @file: The file we want to check
74157 @@ -432,6 +451,12 @@ bool capable(int cap)
74158 }
74159 EXPORT_SYMBOL(capable);
74160
74161 +bool capable_nolog(int cap)
74162 +{
74163 + return ns_capable_nolog(&init_user_ns, cap);
74164 +}
74165 +EXPORT_SYMBOL(capable_nolog);
74166 +
74167 /**
74168 * nsown_capable - Check superior capability to one's own user_ns
74169 * @cap: The capability in question
74170 @@ -464,3 +489,10 @@ bool inode_capable(const struct inode *inode, int cap)
74171
74172 return ns_capable(ns, cap) && kuid_has_mapping(ns, inode->i_uid);
74173 }
74174 +
74175 +bool inode_capable_nolog(const struct inode *inode, int cap)
74176 +{
74177 + struct user_namespace *ns = current_user_ns();
74178 +
74179 + return ns_capable_nolog(ns, cap) && kuid_has_mapping(ns, inode->i_uid);
74180 +}
74181 diff --git a/kernel/cgroup.c b/kernel/cgroup.c
74182 index a48de6a..df24bfe 100644
74183 --- a/kernel/cgroup.c
74184 +++ b/kernel/cgroup.c
74185 @@ -5567,7 +5567,7 @@ static int cgroup_css_links_read(struct cgroup *cont,
74186 struct css_set *cg = link->cg;
74187 struct task_struct *task;
74188 int count = 0;
74189 - seq_printf(seq, "css_set %p\n", cg);
74190 + seq_printf(seq, "css_set %pK\n", cg);
74191 list_for_each_entry(task, &cg->tasks, cg_list) {
74192 if (count++ > MAX_TASKS_SHOWN_PER_CSS) {
74193 seq_puts(seq, " ...\n");
74194 diff --git a/kernel/compat.c b/kernel/compat.c
74195 index 19971d8..02fe2df 100644
74196 --- a/kernel/compat.c
74197 +++ b/kernel/compat.c
74198 @@ -13,6 +13,7 @@
74199
74200 #include <linux/linkage.h>
74201 #include <linux/compat.h>
74202 +#include <linux/module.h>
74203 #include <linux/errno.h>
74204 #include <linux/time.h>
74205 #include <linux/signal.h>
74206 @@ -220,7 +221,7 @@ static long compat_nanosleep_restart(struct restart_block *restart)
74207 mm_segment_t oldfs;
74208 long ret;
74209
74210 - restart->nanosleep.rmtp = (struct timespec __user *) &rmt;
74211 + restart->nanosleep.rmtp = (struct timespec __force_user *) &rmt;
74212 oldfs = get_fs();
74213 set_fs(KERNEL_DS);
74214 ret = hrtimer_nanosleep_restart(restart);
74215 @@ -252,7 +253,7 @@ asmlinkage long compat_sys_nanosleep(struct compat_timespec __user *rqtp,
74216 oldfs = get_fs();
74217 set_fs(KERNEL_DS);
74218 ret = hrtimer_nanosleep(&tu,
74219 - rmtp ? (struct timespec __user *)&rmt : NULL,
74220 + rmtp ? (struct timespec __force_user *)&rmt : NULL,
74221 HRTIMER_MODE_REL, CLOCK_MONOTONIC);
74222 set_fs(oldfs);
74223
74224 @@ -361,7 +362,7 @@ asmlinkage long compat_sys_sigpending(compat_old_sigset_t __user *set)
74225 mm_segment_t old_fs = get_fs();
74226
74227 set_fs(KERNEL_DS);
74228 - ret = sys_sigpending((old_sigset_t __user *) &s);
74229 + ret = sys_sigpending((old_sigset_t __force_user *) &s);
74230 set_fs(old_fs);
74231 if (ret == 0)
74232 ret = put_user(s, set);
74233 @@ -451,7 +452,7 @@ asmlinkage long compat_sys_old_getrlimit(unsigned int resource,
74234 mm_segment_t old_fs = get_fs();
74235
74236 set_fs(KERNEL_DS);
74237 - ret = sys_old_getrlimit(resource, &r);
74238 + ret = sys_old_getrlimit(resource, (struct rlimit __force_user *)&r);
74239 set_fs(old_fs);
74240
74241 if (!ret) {
74242 @@ -523,7 +524,7 @@ asmlinkage long compat_sys_getrusage(int who, struct compat_rusage __user *ru)
74243 mm_segment_t old_fs = get_fs();
74244
74245 set_fs(KERNEL_DS);
74246 - ret = sys_getrusage(who, (struct rusage __user *) &r);
74247 + ret = sys_getrusage(who, (struct rusage __force_user *) &r);
74248 set_fs(old_fs);
74249
74250 if (ret)
74251 @@ -552,8 +553,8 @@ COMPAT_SYSCALL_DEFINE4(wait4,
74252 set_fs (KERNEL_DS);
74253 ret = sys_wait4(pid,
74254 (stat_addr ?
74255 - (unsigned int __user *) &status : NULL),
74256 - options, (struct rusage __user *) &r);
74257 + (unsigned int __force_user *) &status : NULL),
74258 + options, (struct rusage __force_user *) &r);
74259 set_fs (old_fs);
74260
74261 if (ret > 0) {
74262 @@ -579,8 +580,8 @@ COMPAT_SYSCALL_DEFINE5(waitid,
74263 memset(&info, 0, sizeof(info));
74264
74265 set_fs(KERNEL_DS);
74266 - ret = sys_waitid(which, pid, (siginfo_t __user *)&info, options,
74267 - uru ? (struct rusage __user *)&ru : NULL);
74268 + ret = sys_waitid(which, pid, (siginfo_t __force_user *)&info, options,
74269 + uru ? (struct rusage __force_user *)&ru : NULL);
74270 set_fs(old_fs);
74271
74272 if ((ret < 0) || (info.si_signo == 0))
74273 @@ -714,8 +715,8 @@ long compat_sys_timer_settime(timer_t timer_id, int flags,
74274 oldfs = get_fs();
74275 set_fs(KERNEL_DS);
74276 err = sys_timer_settime(timer_id, flags,
74277 - (struct itimerspec __user *) &newts,
74278 - (struct itimerspec __user *) &oldts);
74279 + (struct itimerspec __force_user *) &newts,
74280 + (struct itimerspec __force_user *) &oldts);
74281 set_fs(oldfs);
74282 if (!err && old && put_compat_itimerspec(old, &oldts))
74283 return -EFAULT;
74284 @@ -732,7 +733,7 @@ long compat_sys_timer_gettime(timer_t timer_id,
74285 oldfs = get_fs();
74286 set_fs(KERNEL_DS);
74287 err = sys_timer_gettime(timer_id,
74288 - (struct itimerspec __user *) &ts);
74289 + (struct itimerspec __force_user *) &ts);
74290 set_fs(oldfs);
74291 if (!err && put_compat_itimerspec(setting, &ts))
74292 return -EFAULT;
74293 @@ -751,7 +752,7 @@ long compat_sys_clock_settime(clockid_t which_clock,
74294 oldfs = get_fs();
74295 set_fs(KERNEL_DS);
74296 err = sys_clock_settime(which_clock,
74297 - (struct timespec __user *) &ts);
74298 + (struct timespec __force_user *) &ts);
74299 set_fs(oldfs);
74300 return err;
74301 }
74302 @@ -766,7 +767,7 @@ long compat_sys_clock_gettime(clockid_t which_clock,
74303 oldfs = get_fs();
74304 set_fs(KERNEL_DS);
74305 err = sys_clock_gettime(which_clock,
74306 - (struct timespec __user *) &ts);
74307 + (struct timespec __force_user *) &ts);
74308 set_fs(oldfs);
74309 if (!err && put_compat_timespec(&ts, tp))
74310 return -EFAULT;
74311 @@ -786,7 +787,7 @@ long compat_sys_clock_adjtime(clockid_t which_clock,
74312
74313 oldfs = get_fs();
74314 set_fs(KERNEL_DS);
74315 - ret = sys_clock_adjtime(which_clock, (struct timex __user *) &txc);
74316 + ret = sys_clock_adjtime(which_clock, (struct timex __force_user *) &txc);
74317 set_fs(oldfs);
74318
74319 err = compat_put_timex(utp, &txc);
74320 @@ -806,7 +807,7 @@ long compat_sys_clock_getres(clockid_t which_clock,
74321 oldfs = get_fs();
74322 set_fs(KERNEL_DS);
74323 err = sys_clock_getres(which_clock,
74324 - (struct timespec __user *) &ts);
74325 + (struct timespec __force_user *) &ts);
74326 set_fs(oldfs);
74327 if (!err && tp && put_compat_timespec(&ts, tp))
74328 return -EFAULT;
74329 @@ -818,9 +819,9 @@ static long compat_clock_nanosleep_restart(struct restart_block *restart)
74330 long err;
74331 mm_segment_t oldfs;
74332 struct timespec tu;
74333 - struct compat_timespec *rmtp = restart->nanosleep.compat_rmtp;
74334 + struct compat_timespec __user *rmtp = restart->nanosleep.compat_rmtp;
74335
74336 - restart->nanosleep.rmtp = (struct timespec __user *) &tu;
74337 + restart->nanosleep.rmtp = (struct timespec __force_user *) &tu;
74338 oldfs = get_fs();
74339 set_fs(KERNEL_DS);
74340 err = clock_nanosleep_restart(restart);
74341 @@ -852,8 +853,8 @@ long compat_sys_clock_nanosleep(clockid_t which_clock, int flags,
74342 oldfs = get_fs();
74343 set_fs(KERNEL_DS);
74344 err = sys_clock_nanosleep(which_clock, flags,
74345 - (struct timespec __user *) &in,
74346 - (struct timespec __user *) &out);
74347 + (struct timespec __force_user *) &in,
74348 + (struct timespec __force_user *) &out);
74349 set_fs(oldfs);
74350
74351 if ((err == -ERESTART_RESTARTBLOCK) && rmtp &&
74352 diff --git a/kernel/configs.c b/kernel/configs.c
74353 index 42e8fa0..9e7406b 100644
74354 --- a/kernel/configs.c
74355 +++ b/kernel/configs.c
74356 @@ -74,8 +74,19 @@ static int __init ikconfig_init(void)
74357 struct proc_dir_entry *entry;
74358
74359 /* create the current config file */
74360 +#if defined(CONFIG_GRKERNSEC_PROC_ADD) || defined(CONFIG_GRKERNSEC_HIDESYM)
74361 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_HIDESYM)
74362 + entry = proc_create("config.gz", S_IFREG | S_IRUSR, NULL,
74363 + &ikconfig_file_ops);
74364 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
74365 + entry = proc_create("config.gz", S_IFREG | S_IRUSR | S_IRGRP, NULL,
74366 + &ikconfig_file_ops);
74367 +#endif
74368 +#else
74369 entry = proc_create("config.gz", S_IFREG | S_IRUGO, NULL,
74370 &ikconfig_file_ops);
74371 +#endif
74372 +
74373 if (!entry)
74374 return -ENOMEM;
74375
74376 diff --git a/kernel/cred.c b/kernel/cred.c
74377 index e0573a4..3874e41 100644
74378 --- a/kernel/cred.c
74379 +++ b/kernel/cred.c
74380 @@ -164,6 +164,16 @@ void exit_creds(struct task_struct *tsk)
74381 validate_creds(cred);
74382 alter_cred_subscribers(cred, -1);
74383 put_cred(cred);
74384 +
74385 +#ifdef CONFIG_GRKERNSEC_SETXID
74386 + cred = (struct cred *) tsk->delayed_cred;
74387 + if (cred != NULL) {
74388 + tsk->delayed_cred = NULL;
74389 + validate_creds(cred);
74390 + alter_cred_subscribers(cred, -1);
74391 + put_cred(cred);
74392 + }
74393 +#endif
74394 }
74395
74396 /**
74397 @@ -411,7 +421,7 @@ static bool cred_cap_issubset(const struct cred *set, const struct cred *subset)
74398 * Always returns 0 thus allowing this function to be tail-called at the end
74399 * of, say, sys_setgid().
74400 */
74401 -int commit_creds(struct cred *new)
74402 +static int __commit_creds(struct cred *new)
74403 {
74404 struct task_struct *task = current;
74405 const struct cred *old = task->real_cred;
74406 @@ -430,6 +440,8 @@ int commit_creds(struct cred *new)
74407
74408 get_cred(new); /* we will require a ref for the subj creds too */
74409
74410 + gr_set_role_label(task, new->uid, new->gid);
74411 +
74412 /* dumpability changes */
74413 if (!uid_eq(old->euid, new->euid) ||
74414 !gid_eq(old->egid, new->egid) ||
74415 @@ -479,6 +491,102 @@ int commit_creds(struct cred *new)
74416 put_cred(old);
74417 return 0;
74418 }
74419 +#ifdef CONFIG_GRKERNSEC_SETXID
74420 +extern int set_user(struct cred *new);
74421 +
74422 +void gr_delayed_cred_worker(void)
74423 +{
74424 + const struct cred *new = current->delayed_cred;
74425 + struct cred *ncred;
74426 +
74427 + current->delayed_cred = NULL;
74428 +
74429 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID) && new != NULL) {
74430 + // from doing get_cred on it when queueing this
74431 + put_cred(new);
74432 + return;
74433 + } else if (new == NULL)
74434 + return;
74435 +
74436 + ncred = prepare_creds();
74437 + if (!ncred)
74438 + goto die;
74439 + // uids
74440 + ncred->uid = new->uid;
74441 + ncred->euid = new->euid;
74442 + ncred->suid = new->suid;
74443 + ncred->fsuid = new->fsuid;
74444 + // gids
74445 + ncred->gid = new->gid;
74446 + ncred->egid = new->egid;
74447 + ncred->sgid = new->sgid;
74448 + ncred->fsgid = new->fsgid;
74449 + // groups
74450 + if (set_groups(ncred, new->group_info) < 0) {
74451 + abort_creds(ncred);
74452 + goto die;
74453 + }
74454 + // caps
74455 + ncred->securebits = new->securebits;
74456 + ncred->cap_inheritable = new->cap_inheritable;
74457 + ncred->cap_permitted = new->cap_permitted;
74458 + ncred->cap_effective = new->cap_effective;
74459 + ncred->cap_bset = new->cap_bset;
74460 +
74461 + if (set_user(ncred)) {
74462 + abort_creds(ncred);
74463 + goto die;
74464 + }
74465 +
74466 + // from doing get_cred on it when queueing this
74467 + put_cred(new);
74468 +
74469 + __commit_creds(ncred);
74470 + return;
74471 +die:
74472 + // from doing get_cred on it when queueing this
74473 + put_cred(new);
74474 + do_group_exit(SIGKILL);
74475 +}
74476 +#endif
74477 +
74478 +int commit_creds(struct cred *new)
74479 +{
74480 +#ifdef CONFIG_GRKERNSEC_SETXID
74481 + int ret;
74482 + int schedule_it = 0;
74483 + struct task_struct *t;
74484 +
74485 + /* we won't get called with tasklist_lock held for writing
74486 + and interrupts disabled as the cred struct in that case is
74487 + init_cred
74488 + */
74489 + if (grsec_enable_setxid && !current_is_single_threaded() &&
74490 + uid_eq(current_uid(), GLOBAL_ROOT_UID) &&
74491 + !uid_eq(new->uid, GLOBAL_ROOT_UID)) {
74492 + schedule_it = 1;
74493 + }
74494 + ret = __commit_creds(new);
74495 + if (schedule_it) {
74496 + rcu_read_lock();
74497 + read_lock(&tasklist_lock);
74498 + for (t = next_thread(current); t != current;
74499 + t = next_thread(t)) {
74500 + if (t->delayed_cred == NULL) {
74501 + t->delayed_cred = get_cred(new);
74502 + set_tsk_thread_flag(t, TIF_GRSEC_SETXID);
74503 + set_tsk_need_resched(t);
74504 + }
74505 + }
74506 + read_unlock(&tasklist_lock);
74507 + rcu_read_unlock();
74508 + }
74509 + return ret;
74510 +#else
74511 + return __commit_creds(new);
74512 +#endif
74513 +}
74514 +
74515 EXPORT_SYMBOL(commit_creds);
74516
74517 /**
74518 diff --git a/kernel/debug/debug_core.c b/kernel/debug/debug_core.c
74519 index c26278f..e323fb8 100644
74520 --- a/kernel/debug/debug_core.c
74521 +++ b/kernel/debug/debug_core.c
74522 @@ -123,7 +123,7 @@ static DEFINE_RAW_SPINLOCK(dbg_slave_lock);
74523 */
74524 static atomic_t masters_in_kgdb;
74525 static atomic_t slaves_in_kgdb;
74526 -static atomic_t kgdb_break_tasklet_var;
74527 +static atomic_unchecked_t kgdb_break_tasklet_var;
74528 atomic_t kgdb_setting_breakpoint;
74529
74530 struct task_struct *kgdb_usethread;
74531 @@ -133,7 +133,7 @@ int kgdb_single_step;
74532 static pid_t kgdb_sstep_pid;
74533
74534 /* to keep track of the CPU which is doing the single stepping*/
74535 -atomic_t kgdb_cpu_doing_single_step = ATOMIC_INIT(-1);
74536 +atomic_unchecked_t kgdb_cpu_doing_single_step = ATOMIC_INIT(-1);
74537
74538 /*
74539 * If you are debugging a problem where roundup (the collection of
74540 @@ -541,7 +541,7 @@ return_normal:
74541 * kernel will only try for the value of sstep_tries before
74542 * giving up and continuing on.
74543 */
74544 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1 &&
74545 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1 &&
74546 (kgdb_info[cpu].task &&
74547 kgdb_info[cpu].task->pid != kgdb_sstep_pid) && --sstep_tries) {
74548 atomic_set(&kgdb_active, -1);
74549 @@ -635,8 +635,8 @@ cpu_master_loop:
74550 }
74551
74552 kgdb_restore:
74553 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1) {
74554 - int sstep_cpu = atomic_read(&kgdb_cpu_doing_single_step);
74555 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1) {
74556 + int sstep_cpu = atomic_read_unchecked(&kgdb_cpu_doing_single_step);
74557 if (kgdb_info[sstep_cpu].task)
74558 kgdb_sstep_pid = kgdb_info[sstep_cpu].task->pid;
74559 else
74560 @@ -888,18 +888,18 @@ static void kgdb_unregister_callbacks(void)
74561 static void kgdb_tasklet_bpt(unsigned long ing)
74562 {
74563 kgdb_breakpoint();
74564 - atomic_set(&kgdb_break_tasklet_var, 0);
74565 + atomic_set_unchecked(&kgdb_break_tasklet_var, 0);
74566 }
74567
74568 static DECLARE_TASKLET(kgdb_tasklet_breakpoint, kgdb_tasklet_bpt, 0);
74569
74570 void kgdb_schedule_breakpoint(void)
74571 {
74572 - if (atomic_read(&kgdb_break_tasklet_var) ||
74573 + if (atomic_read_unchecked(&kgdb_break_tasklet_var) ||
74574 atomic_read(&kgdb_active) != -1 ||
74575 atomic_read(&kgdb_setting_breakpoint))
74576 return;
74577 - atomic_inc(&kgdb_break_tasklet_var);
74578 + atomic_inc_unchecked(&kgdb_break_tasklet_var);
74579 tasklet_schedule(&kgdb_tasklet_breakpoint);
74580 }
74581 EXPORT_SYMBOL_GPL(kgdb_schedule_breakpoint);
74582 diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c
74583 index 00eb8f7..d7e3244 100644
74584 --- a/kernel/debug/kdb/kdb_main.c
74585 +++ b/kernel/debug/kdb/kdb_main.c
74586 @@ -1974,7 +1974,7 @@ static int kdb_lsmod(int argc, const char **argv)
74587 continue;
74588
74589 kdb_printf("%-20s%8u 0x%p ", mod->name,
74590 - mod->core_size, (void *)mod);
74591 + mod->core_size_rx + mod->core_size_rw, (void *)mod);
74592 #ifdef CONFIG_MODULE_UNLOAD
74593 kdb_printf("%4ld ", module_refcount(mod));
74594 #endif
74595 @@ -1984,7 +1984,7 @@ static int kdb_lsmod(int argc, const char **argv)
74596 kdb_printf(" (Loading)");
74597 else
74598 kdb_printf(" (Live)");
74599 - kdb_printf(" 0x%p", mod->module_core);
74600 + kdb_printf(" 0x%p 0x%p", mod->module_core_rx, mod->module_core_rw);
74601
74602 #ifdef CONFIG_MODULE_UNLOAD
74603 {
74604 diff --git a/kernel/events/core.c b/kernel/events/core.c
74605 index 9fcb094..8370228 100644
74606 --- a/kernel/events/core.c
74607 +++ b/kernel/events/core.c
74608 @@ -154,8 +154,15 @@ static struct srcu_struct pmus_srcu;
74609 * 0 - disallow raw tracepoint access for unpriv
74610 * 1 - disallow cpu events for unpriv
74611 * 2 - disallow kernel profiling for unpriv
74612 + * 3 - disallow all unpriv perf event use
74613 */
74614 -int sysctl_perf_event_paranoid __read_mostly = 1;
74615 +#ifdef CONFIG_GRKERNSEC_PERF_HARDEN
74616 +int sysctl_perf_event_legitimately_concerned __read_mostly = 3;
74617 +#elif CONFIG_GRKERNSEC_HIDESYM
74618 +int sysctl_perf_event_legitimately_concerned __read_mostly = 2;
74619 +#else
74620 +int sysctl_perf_event_legitimately_concerned __read_mostly = 1;
74621 +#endif
74622
74623 /* Minimum for 512 kiB + 1 user control page */
74624 int sysctl_perf_event_mlock __read_mostly = 512 + (PAGE_SIZE / 1024); /* 'free' kiB per user */
74625 @@ -182,7 +189,7 @@ int perf_proc_update_handler(struct ctl_table *table, int write,
74626 return 0;
74627 }
74628
74629 -static atomic64_t perf_event_id;
74630 +static atomic64_unchecked_t perf_event_id;
74631
74632 static void cpu_ctx_sched_out(struct perf_cpu_context *cpuctx,
74633 enum event_type_t event_type);
74634 @@ -2677,7 +2684,7 @@ static void __perf_event_read(void *info)
74635
74636 static inline u64 perf_event_count(struct perf_event *event)
74637 {
74638 - return local64_read(&event->count) + atomic64_read(&event->child_count);
74639 + return local64_read(&event->count) + atomic64_read_unchecked(&event->child_count);
74640 }
74641
74642 static u64 perf_event_read(struct perf_event *event)
74643 @@ -3007,9 +3014,9 @@ u64 perf_event_read_value(struct perf_event *event, u64 *enabled, u64 *running)
74644 mutex_lock(&event->child_mutex);
74645 total += perf_event_read(event);
74646 *enabled += event->total_time_enabled +
74647 - atomic64_read(&event->child_total_time_enabled);
74648 + atomic64_read_unchecked(&event->child_total_time_enabled);
74649 *running += event->total_time_running +
74650 - atomic64_read(&event->child_total_time_running);
74651 + atomic64_read_unchecked(&event->child_total_time_running);
74652
74653 list_for_each_entry(child, &event->child_list, child_list) {
74654 total += perf_event_read(child);
74655 @@ -3412,10 +3419,10 @@ void perf_event_update_userpage(struct perf_event *event)
74656 userpg->offset -= local64_read(&event->hw.prev_count);
74657
74658 userpg->time_enabled = enabled +
74659 - atomic64_read(&event->child_total_time_enabled);
74660 + atomic64_read_unchecked(&event->child_total_time_enabled);
74661
74662 userpg->time_running = running +
74663 - atomic64_read(&event->child_total_time_running);
74664 + atomic64_read_unchecked(&event->child_total_time_running);
74665
74666 arch_perf_update_userpage(userpg, now);
74667
74668 @@ -3886,7 +3893,7 @@ perf_output_sample_ustack(struct perf_output_handle *handle, u64 dump_size,
74669
74670 /* Data. */
74671 sp = perf_user_stack_pointer(regs);
74672 - rem = __output_copy_user(handle, (void *) sp, dump_size);
74673 + rem = __output_copy_user(handle, (void __user *) sp, dump_size);
74674 dyn_size = dump_size - rem;
74675
74676 perf_output_skip(handle, rem);
74677 @@ -3974,11 +3981,11 @@ static void perf_output_read_one(struct perf_output_handle *handle,
74678 values[n++] = perf_event_count(event);
74679 if (read_format & PERF_FORMAT_TOTAL_TIME_ENABLED) {
74680 values[n++] = enabled +
74681 - atomic64_read(&event->child_total_time_enabled);
74682 + atomic64_read_unchecked(&event->child_total_time_enabled);
74683 }
74684 if (read_format & PERF_FORMAT_TOTAL_TIME_RUNNING) {
74685 values[n++] = running +
74686 - atomic64_read(&event->child_total_time_running);
74687 + atomic64_read_unchecked(&event->child_total_time_running);
74688 }
74689 if (read_format & PERF_FORMAT_ID)
74690 values[n++] = primary_event_id(event);
74691 @@ -4726,12 +4733,12 @@ static void perf_event_mmap_event(struct perf_mmap_event *mmap_event)
74692 * need to add enough zero bytes after the string to handle
74693 * the 64bit alignment we do later.
74694 */
74695 - buf = kzalloc(PATH_MAX + sizeof(u64), GFP_KERNEL);
74696 + buf = kzalloc(PATH_MAX, GFP_KERNEL);
74697 if (!buf) {
74698 name = strncpy(tmp, "//enomem", sizeof(tmp));
74699 goto got_name;
74700 }
74701 - name = d_path(&file->f_path, buf, PATH_MAX);
74702 + name = d_path(&file->f_path, buf, PATH_MAX - sizeof(u64));
74703 if (IS_ERR(name)) {
74704 name = strncpy(tmp, "//toolong", sizeof(tmp));
74705 goto got_name;
74706 @@ -6167,7 +6174,7 @@ perf_event_alloc(struct perf_event_attr *attr, int cpu,
74707 event->parent = parent_event;
74708
74709 event->ns = get_pid_ns(task_active_pid_ns(current));
74710 - event->id = atomic64_inc_return(&perf_event_id);
74711 + event->id = atomic64_inc_return_unchecked(&perf_event_id);
74712
74713 event->state = PERF_EVENT_STATE_INACTIVE;
74714
74715 @@ -6463,6 +6470,11 @@ SYSCALL_DEFINE5(perf_event_open,
74716 if (flags & ~PERF_FLAG_ALL)
74717 return -EINVAL;
74718
74719 +#ifdef CONFIG_GRKERNSEC_PERF_HARDEN
74720 + if (perf_paranoid_any() && !capable(CAP_SYS_ADMIN))
74721 + return -EACCES;
74722 +#endif
74723 +
74724 err = perf_copy_attr(attr_uptr, &attr);
74725 if (err)
74726 return err;
74727 @@ -6795,10 +6807,10 @@ static void sync_child_event(struct perf_event *child_event,
74728 /*
74729 * Add back the child's count to the parent's count:
74730 */
74731 - atomic64_add(child_val, &parent_event->child_count);
74732 - atomic64_add(child_event->total_time_enabled,
74733 + atomic64_add_unchecked(child_val, &parent_event->child_count);
74734 + atomic64_add_unchecked(child_event->total_time_enabled,
74735 &parent_event->child_total_time_enabled);
74736 - atomic64_add(child_event->total_time_running,
74737 + atomic64_add_unchecked(child_event->total_time_running,
74738 &parent_event->child_total_time_running);
74739
74740 /*
74741 diff --git a/kernel/events/internal.h b/kernel/events/internal.h
74742 index eb675c4..54912ff 100644
74743 --- a/kernel/events/internal.h
74744 +++ b/kernel/events/internal.h
74745 @@ -77,10 +77,10 @@ static inline unsigned long perf_data_size(struct ring_buffer *rb)
74746 return rb->nr_pages << (PAGE_SHIFT + page_order(rb));
74747 }
74748
74749 -#define DEFINE_OUTPUT_COPY(func_name, memcpy_func) \
74750 +#define DEFINE_OUTPUT_COPY(func_name, memcpy_func, user) \
74751 static inline unsigned int \
74752 func_name(struct perf_output_handle *handle, \
74753 - const void *buf, unsigned int len) \
74754 + const void user *buf, unsigned int len) \
74755 { \
74756 unsigned long size, written; \
74757 \
74758 @@ -112,17 +112,17 @@ static inline int memcpy_common(void *dst, const void *src, size_t n)
74759 return n;
74760 }
74761
74762 -DEFINE_OUTPUT_COPY(__output_copy, memcpy_common)
74763 +DEFINE_OUTPUT_COPY(__output_copy, memcpy_common, )
74764
74765 #define MEMCPY_SKIP(dst, src, n) (n)
74766
74767 -DEFINE_OUTPUT_COPY(__output_skip, MEMCPY_SKIP)
74768 +DEFINE_OUTPUT_COPY(__output_skip, MEMCPY_SKIP, )
74769
74770 #ifndef arch_perf_out_copy_user
74771 #define arch_perf_out_copy_user __copy_from_user_inatomic
74772 #endif
74773
74774 -DEFINE_OUTPUT_COPY(__output_copy_user, arch_perf_out_copy_user)
74775 +DEFINE_OUTPUT_COPY(__output_copy_user, arch_perf_out_copy_user, __user)
74776
74777 /* Callchain handling */
74778 extern struct perf_callchain_entry *
74779 diff --git a/kernel/exit.c b/kernel/exit.c
74780 index 60bc027..ca6d727 100644
74781 --- a/kernel/exit.c
74782 +++ b/kernel/exit.c
74783 @@ -172,6 +172,10 @@ void release_task(struct task_struct * p)
74784 struct task_struct *leader;
74785 int zap_leader;
74786 repeat:
74787 +#ifdef CONFIG_NET
74788 + gr_del_task_from_ip_table(p);
74789 +#endif
74790 +
74791 /* don't need to get the RCU readlock here - the process is dead and
74792 * can't be modifying its own credentials. But shut RCU-lockdep up */
74793 rcu_read_lock();
74794 @@ -340,7 +344,7 @@ int allow_signal(int sig)
74795 * know it'll be handled, so that they don't get converted to
74796 * SIGKILL or just silently dropped.
74797 */
74798 - current->sighand->action[(sig)-1].sa.sa_handler = (void __user *)2;
74799 + current->sighand->action[(sig)-1].sa.sa_handler = (__force void __user *)2;
74800 recalc_sigpending();
74801 spin_unlock_irq(&current->sighand->siglock);
74802 return 0;
74803 @@ -710,6 +714,8 @@ void do_exit(long code)
74804 struct task_struct *tsk = current;
74805 int group_dead;
74806
74807 + set_fs(USER_DS);
74808 +
74809 profile_task_exit(tsk);
74810
74811 WARN_ON(blk_needs_flush_plug(tsk));
74812 @@ -726,7 +732,6 @@ void do_exit(long code)
74813 * mm_release()->clear_child_tid() from writing to a user-controlled
74814 * kernel address.
74815 */
74816 - set_fs(USER_DS);
74817
74818 ptrace_event(PTRACE_EVENT_EXIT, code);
74819
74820 @@ -785,6 +790,9 @@ void do_exit(long code)
74821 tsk->exit_code = code;
74822 taskstats_exit(tsk, group_dead);
74823
74824 + gr_acl_handle_psacct(tsk, code);
74825 + gr_acl_handle_exit();
74826 +
74827 exit_mm(tsk);
74828
74829 if (group_dead)
74830 @@ -905,7 +913,7 @@ SYSCALL_DEFINE1(exit, int, error_code)
74831 * Take down every thread in the group. This is called by fatal signals
74832 * as well as by sys_exit_group (below).
74833 */
74834 -void
74835 +__noreturn void
74836 do_group_exit(int exit_code)
74837 {
74838 struct signal_struct *sig = current->signal;
74839 diff --git a/kernel/fork.c b/kernel/fork.c
74840 index 1766d32..c0e44e2 100644
74841 --- a/kernel/fork.c
74842 +++ b/kernel/fork.c
74843 @@ -318,7 +318,7 @@ static struct task_struct *dup_task_struct(struct task_struct *orig)
74844 *stackend = STACK_END_MAGIC; /* for overflow detection */
74845
74846 #ifdef CONFIG_CC_STACKPROTECTOR
74847 - tsk->stack_canary = get_random_int();
74848 + tsk->stack_canary = pax_get_random_long();
74849 #endif
74850
74851 /*
74852 @@ -344,13 +344,81 @@ free_tsk:
74853 }
74854
74855 #ifdef CONFIG_MMU
74856 +static struct vm_area_struct *dup_vma(struct mm_struct *mm, struct mm_struct *oldmm, struct vm_area_struct *mpnt)
74857 +{
74858 + struct vm_area_struct *tmp;
74859 + unsigned long charge;
74860 + struct mempolicy *pol;
74861 + struct file *file;
74862 +
74863 + charge = 0;
74864 + if (mpnt->vm_flags & VM_ACCOUNT) {
74865 + unsigned long len = vma_pages(mpnt);
74866 +
74867 + if (security_vm_enough_memory_mm(oldmm, len)) /* sic */
74868 + goto fail_nomem;
74869 + charge = len;
74870 + }
74871 + tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
74872 + if (!tmp)
74873 + goto fail_nomem;
74874 + *tmp = *mpnt;
74875 + tmp->vm_mm = mm;
74876 + INIT_LIST_HEAD(&tmp->anon_vma_chain);
74877 + pol = mpol_dup(vma_policy(mpnt));
74878 + if (IS_ERR(pol))
74879 + goto fail_nomem_policy;
74880 + vma_set_policy(tmp, pol);
74881 + if (anon_vma_fork(tmp, mpnt))
74882 + goto fail_nomem_anon_vma_fork;
74883 + tmp->vm_flags &= ~VM_LOCKED;
74884 + tmp->vm_next = tmp->vm_prev = NULL;
74885 + tmp->vm_mirror = NULL;
74886 + file = tmp->vm_file;
74887 + if (file) {
74888 + struct inode *inode = file_inode(file);
74889 + struct address_space *mapping = file->f_mapping;
74890 +
74891 + get_file(file);
74892 + if (tmp->vm_flags & VM_DENYWRITE)
74893 + atomic_dec(&inode->i_writecount);
74894 + mutex_lock(&mapping->i_mmap_mutex);
74895 + if (tmp->vm_flags & VM_SHARED)
74896 + mapping->i_mmap_writable++;
74897 + flush_dcache_mmap_lock(mapping);
74898 + /* insert tmp into the share list, just after mpnt */
74899 + if (unlikely(tmp->vm_flags & VM_NONLINEAR))
74900 + vma_nonlinear_insert(tmp, &mapping->i_mmap_nonlinear);
74901 + else
74902 + vma_interval_tree_insert_after(tmp, mpnt, &mapping->i_mmap);
74903 + flush_dcache_mmap_unlock(mapping);
74904 + mutex_unlock(&mapping->i_mmap_mutex);
74905 + }
74906 +
74907 + /*
74908 + * Clear hugetlb-related page reserves for children. This only
74909 + * affects MAP_PRIVATE mappings. Faults generated by the child
74910 + * are not guaranteed to succeed, even if read-only
74911 + */
74912 + if (is_vm_hugetlb_page(tmp))
74913 + reset_vma_resv_huge_pages(tmp);
74914 +
74915 + return tmp;
74916 +
74917 +fail_nomem_anon_vma_fork:
74918 + mpol_put(pol);
74919 +fail_nomem_policy:
74920 + kmem_cache_free(vm_area_cachep, tmp);
74921 +fail_nomem:
74922 + vm_unacct_memory(charge);
74923 + return NULL;
74924 +}
74925 +
74926 static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
74927 {
74928 struct vm_area_struct *mpnt, *tmp, *prev, **pprev;
74929 struct rb_node **rb_link, *rb_parent;
74930 int retval;
74931 - unsigned long charge;
74932 - struct mempolicy *pol;
74933
74934 uprobe_start_dup_mmap();
74935 down_write(&oldmm->mmap_sem);
74936 @@ -364,8 +432,8 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
74937 mm->locked_vm = 0;
74938 mm->mmap = NULL;
74939 mm->mmap_cache = NULL;
74940 - mm->free_area_cache = oldmm->mmap_base;
74941 - mm->cached_hole_size = ~0UL;
74942 + mm->free_area_cache = oldmm->free_area_cache;
74943 + mm->cached_hole_size = oldmm->cached_hole_size;
74944 mm->map_count = 0;
74945 cpumask_clear(mm_cpumask(mm));
74946 mm->mm_rb = RB_ROOT;
74947 @@ -381,57 +449,15 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
74948
74949 prev = NULL;
74950 for (mpnt = oldmm->mmap; mpnt; mpnt = mpnt->vm_next) {
74951 - struct file *file;
74952 -
74953 if (mpnt->vm_flags & VM_DONTCOPY) {
74954 vm_stat_account(mm, mpnt->vm_flags, mpnt->vm_file,
74955 -vma_pages(mpnt));
74956 continue;
74957 }
74958 - charge = 0;
74959 - if (mpnt->vm_flags & VM_ACCOUNT) {
74960 - unsigned long len = vma_pages(mpnt);
74961 -
74962 - if (security_vm_enough_memory_mm(oldmm, len)) /* sic */
74963 - goto fail_nomem;
74964 - charge = len;
74965 - }
74966 - tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
74967 - if (!tmp)
74968 - goto fail_nomem;
74969 - *tmp = *mpnt;
74970 - INIT_LIST_HEAD(&tmp->anon_vma_chain);
74971 - pol = mpol_dup(vma_policy(mpnt));
74972 - retval = PTR_ERR(pol);
74973 - if (IS_ERR(pol))
74974 - goto fail_nomem_policy;
74975 - vma_set_policy(tmp, pol);
74976 - tmp->vm_mm = mm;
74977 - if (anon_vma_fork(tmp, mpnt))
74978 - goto fail_nomem_anon_vma_fork;
74979 - tmp->vm_flags &= ~VM_LOCKED;
74980 - tmp->vm_next = tmp->vm_prev = NULL;
74981 - file = tmp->vm_file;
74982 - if (file) {
74983 - struct inode *inode = file_inode(file);
74984 - struct address_space *mapping = file->f_mapping;
74985 -
74986 - get_file(file);
74987 - if (tmp->vm_flags & VM_DENYWRITE)
74988 - atomic_dec(&inode->i_writecount);
74989 - mutex_lock(&mapping->i_mmap_mutex);
74990 - if (tmp->vm_flags & VM_SHARED)
74991 - mapping->i_mmap_writable++;
74992 - flush_dcache_mmap_lock(mapping);
74993 - /* insert tmp into the share list, just after mpnt */
74994 - if (unlikely(tmp->vm_flags & VM_NONLINEAR))
74995 - vma_nonlinear_insert(tmp,
74996 - &mapping->i_mmap_nonlinear);
74997 - else
74998 - vma_interval_tree_insert_after(tmp, mpnt,
74999 - &mapping->i_mmap);
75000 - flush_dcache_mmap_unlock(mapping);
75001 - mutex_unlock(&mapping->i_mmap_mutex);
75002 + tmp = dup_vma(mm, oldmm, mpnt);
75003 + if (!tmp) {
75004 + retval = -ENOMEM;
75005 + goto out;
75006 }
75007
75008 /*
75009 @@ -463,6 +489,31 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
75010 if (retval)
75011 goto out;
75012 }
75013 +
75014 +#ifdef CONFIG_PAX_SEGMEXEC
75015 + if (oldmm->pax_flags & MF_PAX_SEGMEXEC) {
75016 + struct vm_area_struct *mpnt_m;
75017 +
75018 + for (mpnt = oldmm->mmap, mpnt_m = mm->mmap; mpnt; mpnt = mpnt->vm_next, mpnt_m = mpnt_m->vm_next) {
75019 + BUG_ON(!mpnt_m || mpnt_m->vm_mirror || mpnt->vm_mm != oldmm || mpnt_m->vm_mm != mm);
75020 +
75021 + if (!mpnt->vm_mirror)
75022 + continue;
75023 +
75024 + if (mpnt->vm_end <= SEGMEXEC_TASK_SIZE) {
75025 + BUG_ON(mpnt->vm_mirror->vm_mirror != mpnt);
75026 + mpnt->vm_mirror = mpnt_m;
75027 + } else {
75028 + BUG_ON(mpnt->vm_mirror->vm_mirror == mpnt || mpnt->vm_mirror->vm_mirror->vm_mm != mm);
75029 + mpnt_m->vm_mirror = mpnt->vm_mirror->vm_mirror;
75030 + mpnt_m->vm_mirror->vm_mirror = mpnt_m;
75031 + mpnt->vm_mirror->vm_mirror = mpnt;
75032 + }
75033 + }
75034 + BUG_ON(mpnt_m);
75035 + }
75036 +#endif
75037 +
75038 /* a new mm has just been created */
75039 arch_dup_mmap(oldmm, mm);
75040 retval = 0;
75041 @@ -472,14 +523,6 @@ out:
75042 up_write(&oldmm->mmap_sem);
75043 uprobe_end_dup_mmap();
75044 return retval;
75045 -fail_nomem_anon_vma_fork:
75046 - mpol_put(pol);
75047 -fail_nomem_policy:
75048 - kmem_cache_free(vm_area_cachep, tmp);
75049 -fail_nomem:
75050 - retval = -ENOMEM;
75051 - vm_unacct_memory(charge);
75052 - goto out;
75053 }
75054
75055 static inline int mm_alloc_pgd(struct mm_struct *mm)
75056 @@ -694,8 +737,8 @@ struct mm_struct *mm_access(struct task_struct *task, unsigned int mode)
75057 return ERR_PTR(err);
75058
75059 mm = get_task_mm(task);
75060 - if (mm && mm != current->mm &&
75061 - !ptrace_may_access(task, mode)) {
75062 + if (mm && ((mm != current->mm && !ptrace_may_access(task, mode)) ||
75063 + (mode == PTRACE_MODE_ATTACH && (gr_handle_proc_ptrace(task) || gr_acl_handle_procpidmem(task))))) {
75064 mmput(mm);
75065 mm = ERR_PTR(-EACCES);
75066 }
75067 @@ -917,13 +960,20 @@ static int copy_fs(unsigned long clone_flags, struct task_struct *tsk)
75068 spin_unlock(&fs->lock);
75069 return -EAGAIN;
75070 }
75071 - fs->users++;
75072 + atomic_inc(&fs->users);
75073 spin_unlock(&fs->lock);
75074 return 0;
75075 }
75076 tsk->fs = copy_fs_struct(fs);
75077 if (!tsk->fs)
75078 return -ENOMEM;
75079 + /* Carry through gr_chroot_dentry and is_chrooted instead
75080 + of recomputing it here. Already copied when the task struct
75081 + is duplicated. This allows pivot_root to not be treated as
75082 + a chroot
75083 + */
75084 + //gr_set_chroot_entries(tsk, &tsk->fs->root);
75085 +
75086 return 0;
75087 }
75088
75089 @@ -1196,6 +1246,9 @@ static struct task_struct *copy_process(unsigned long clone_flags,
75090 DEBUG_LOCKS_WARN_ON(!p->softirqs_enabled);
75091 #endif
75092 retval = -EAGAIN;
75093 +
75094 + gr_learn_resource(p, RLIMIT_NPROC, atomic_read(&p->real_cred->user->processes), 0);
75095 +
75096 if (atomic_read(&p->real_cred->user->processes) >=
75097 task_rlimit(p, RLIMIT_NPROC)) {
75098 if (!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_RESOURCE) &&
75099 @@ -1441,6 +1494,11 @@ static struct task_struct *copy_process(unsigned long clone_flags,
75100 goto bad_fork_free_pid;
75101 }
75102
75103 + /* synchronizes with gr_set_acls()
75104 + we need to call this past the point of no return for fork()
75105 + */
75106 + gr_copy_label(p);
75107 +
75108 if (clone_flags & CLONE_THREAD) {
75109 current->signal->nr_threads++;
75110 atomic_inc(&current->signal->live);
75111 @@ -1524,6 +1582,8 @@ bad_fork_cleanup_count:
75112 bad_fork_free:
75113 free_task(p);
75114 fork_out:
75115 + gr_log_forkfail(retval);
75116 +
75117 return ERR_PTR(retval);
75118 }
75119
75120 @@ -1574,6 +1634,23 @@ long do_fork(unsigned long clone_flags,
75121 return -EINVAL;
75122 }
75123
75124 +#ifdef CONFIG_GRKERNSEC
75125 + if (clone_flags & CLONE_NEWUSER) {
75126 + /*
75127 + * This doesn't really inspire confidence:
75128 + * http://marc.info/?l=linux-kernel&m=135543612731939&w=2
75129 + * http://marc.info/?l=linux-kernel&m=135545831607095&w=2
75130 + * Increases kernel attack surface in areas developers
75131 + * previously cared little about ("low importance due
75132 + * to requiring "root" capability")
75133 + * To be removed when this code receives *proper* review
75134 + */
75135 + if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SETUID) ||
75136 + !capable(CAP_SETGID))
75137 + return -EPERM;
75138 + }
75139 +#endif
75140 +
75141 /*
75142 * Determine whether and which event to report to ptracer. When
75143 * called from kernel_thread or CLONE_UNTRACED is explicitly
75144 @@ -1608,6 +1685,8 @@ long do_fork(unsigned long clone_flags,
75145 if (clone_flags & CLONE_PARENT_SETTID)
75146 put_user(nr, parent_tidptr);
75147
75148 + gr_handle_brute_check();
75149 +
75150 if (clone_flags & CLONE_VFORK) {
75151 p->vfork_done = &vfork;
75152 init_completion(&vfork);
75153 @@ -1761,7 +1840,7 @@ static int unshare_fs(unsigned long unshare_flags, struct fs_struct **new_fsp)
75154 return 0;
75155
75156 /* don't need lock here; in the worst case we'll do useless copy */
75157 - if (fs->users == 1)
75158 + if (atomic_read(&fs->users) == 1)
75159 return 0;
75160
75161 *new_fsp = copy_fs_struct(fs);
75162 @@ -1873,7 +1952,8 @@ SYSCALL_DEFINE1(unshare, unsigned long, unshare_flags)
75163 fs = current->fs;
75164 spin_lock(&fs->lock);
75165 current->fs = new_fs;
75166 - if (--fs->users)
75167 + gr_set_chroot_entries(current, &current->fs->root);
75168 + if (atomic_dec_return(&fs->users))
75169 new_fs = NULL;
75170 else
75171 new_fs = fs;
75172 diff --git a/kernel/futex.c b/kernel/futex.c
75173 index b26dcfc..39e266a 100644
75174 --- a/kernel/futex.c
75175 +++ b/kernel/futex.c
75176 @@ -54,6 +54,7 @@
75177 #include <linux/mount.h>
75178 #include <linux/pagemap.h>
75179 #include <linux/syscalls.h>
75180 +#include <linux/ptrace.h>
75181 #include <linux/signal.h>
75182 #include <linux/export.h>
75183 #include <linux/magic.h>
75184 @@ -241,6 +242,11 @@ get_futex_key(u32 __user *uaddr, int fshared, union futex_key *key, int rw)
75185 struct page *page, *page_head;
75186 int err, ro = 0;
75187
75188 +#ifdef CONFIG_PAX_SEGMEXEC
75189 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && address >= SEGMEXEC_TASK_SIZE)
75190 + return -EFAULT;
75191 +#endif
75192 +
75193 /*
75194 * The futex address must be "naturally" aligned.
75195 */
75196 @@ -2732,6 +2738,7 @@ static int __init futex_init(void)
75197 {
75198 u32 curval;
75199 int i;
75200 + mm_segment_t oldfs;
75201
75202 /*
75203 * This will fail and we want it. Some arch implementations do
75204 @@ -2743,8 +2750,11 @@ static int __init futex_init(void)
75205 * implementation, the non-functional ones will return
75206 * -ENOSYS.
75207 */
75208 + oldfs = get_fs();
75209 + set_fs(USER_DS);
75210 if (cmpxchg_futex_value_locked(&curval, NULL, 0, 0) == -EFAULT)
75211 futex_cmpxchg_enabled = 1;
75212 + set_fs(oldfs);
75213
75214 for (i = 0; i < ARRAY_SIZE(futex_queues); i++) {
75215 plist_head_init(&futex_queues[i].chain);
75216 diff --git a/kernel/futex_compat.c b/kernel/futex_compat.c
75217 index f9f44fd..29885e4 100644
75218 --- a/kernel/futex_compat.c
75219 +++ b/kernel/futex_compat.c
75220 @@ -32,7 +32,7 @@ fetch_robust_entry(compat_uptr_t *uentry, struct robust_list __user **entry,
75221 return 0;
75222 }
75223
75224 -static void __user *futex_uaddr(struct robust_list __user *entry,
75225 +static void __user __intentional_overflow(-1) *futex_uaddr(struct robust_list __user *entry,
75226 compat_long_t futex_offset)
75227 {
75228 compat_uptr_t base = ptr_to_compat(entry);
75229 diff --git a/kernel/gcov/base.c b/kernel/gcov/base.c
75230 index 9b22d03..6295b62 100644
75231 --- a/kernel/gcov/base.c
75232 +++ b/kernel/gcov/base.c
75233 @@ -102,11 +102,6 @@ void gcov_enable_events(void)
75234 }
75235
75236 #ifdef CONFIG_MODULES
75237 -static inline int within(void *addr, void *start, unsigned long size)
75238 -{
75239 - return ((addr >= start) && (addr < start + size));
75240 -}
75241 -
75242 /* Update list and generate events when modules are unloaded. */
75243 static int gcov_module_notifier(struct notifier_block *nb, unsigned long event,
75244 void *data)
75245 @@ -121,7 +116,7 @@ static int gcov_module_notifier(struct notifier_block *nb, unsigned long event,
75246 prev = NULL;
75247 /* Remove entries located in module from linked list. */
75248 for (info = gcov_info_head; info; info = info->next) {
75249 - if (within(info, mod->module_core, mod->core_size)) {
75250 + if (within_module_core_rw((unsigned long)info, mod)) {
75251 if (prev)
75252 prev->next = info->next;
75253 else
75254 diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c
75255 index 7ef5556..8247f11 100644
75256 --- a/kernel/hrtimer.c
75257 +++ b/kernel/hrtimer.c
75258 @@ -1416,7 +1416,7 @@ void hrtimer_peek_ahead_timers(void)
75259 local_irq_restore(flags);
75260 }
75261
75262 -static void run_hrtimer_softirq(struct softirq_action *h)
75263 +static void run_hrtimer_softirq(void)
75264 {
75265 struct hrtimer_cpu_base *cpu_base = &__get_cpu_var(hrtimer_bases);
75266
75267 @@ -1758,7 +1758,7 @@ static int __cpuinit hrtimer_cpu_notify(struct notifier_block *self,
75268 return NOTIFY_OK;
75269 }
75270
75271 -static struct notifier_block __cpuinitdata hrtimers_nb = {
75272 +static struct notifier_block hrtimers_nb = {
75273 .notifier_call = hrtimer_cpu_notify,
75274 };
75275
75276 diff --git a/kernel/irq_work.c b/kernel/irq_work.c
75277 index 55fcce6..0e4cf34 100644
75278 --- a/kernel/irq_work.c
75279 +++ b/kernel/irq_work.c
75280 @@ -189,12 +189,13 @@ static int irq_work_cpu_notify(struct notifier_block *self,
75281 return NOTIFY_OK;
75282 }
75283
75284 -static struct notifier_block cpu_notify;
75285 +static struct notifier_block cpu_notify = {
75286 + .notifier_call = irq_work_cpu_notify,
75287 + .priority = 0,
75288 +};
75289
75290 static __init int irq_work_init_cpu_notifier(void)
75291 {
75292 - cpu_notify.notifier_call = irq_work_cpu_notify;
75293 - cpu_notify.priority = 0;
75294 register_cpu_notifier(&cpu_notify);
75295 return 0;
75296 }
75297 diff --git a/kernel/jump_label.c b/kernel/jump_label.c
75298 index 60f48fa..7f3a770 100644
75299 --- a/kernel/jump_label.c
75300 +++ b/kernel/jump_label.c
75301 @@ -13,6 +13,7 @@
75302 #include <linux/sort.h>
75303 #include <linux/err.h>
75304 #include <linux/static_key.h>
75305 +#include <linux/mm.h>
75306
75307 #ifdef HAVE_JUMP_LABEL
75308
75309 @@ -50,7 +51,9 @@ jump_label_sort_entries(struct jump_entry *start, struct jump_entry *stop)
75310
75311 size = (((unsigned long)stop - (unsigned long)start)
75312 / sizeof(struct jump_entry));
75313 + pax_open_kernel();
75314 sort(start, size, sizeof(struct jump_entry), jump_label_cmp, NULL);
75315 + pax_close_kernel();
75316 }
75317
75318 static void jump_label_update(struct static_key *key, int enable);
75319 @@ -357,10 +360,12 @@ static void jump_label_invalidate_module_init(struct module *mod)
75320 struct jump_entry *iter_stop = iter_start + mod->num_jump_entries;
75321 struct jump_entry *iter;
75322
75323 + pax_open_kernel();
75324 for (iter = iter_start; iter < iter_stop; iter++) {
75325 if (within_module_init(iter->code, mod))
75326 iter->code = 0;
75327 }
75328 + pax_close_kernel();
75329 }
75330
75331 static int
75332 diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c
75333 index 2169fee..706ccca 100644
75334 --- a/kernel/kallsyms.c
75335 +++ b/kernel/kallsyms.c
75336 @@ -11,6 +11,9 @@
75337 * Changed the compression method from stem compression to "table lookup"
75338 * compression (see scripts/kallsyms.c for a more complete description)
75339 */
75340 +#ifdef CONFIG_GRKERNSEC_HIDESYM
75341 +#define __INCLUDED_BY_HIDESYM 1
75342 +#endif
75343 #include <linux/kallsyms.h>
75344 #include <linux/module.h>
75345 #include <linux/init.h>
75346 @@ -53,12 +56,33 @@ extern const unsigned long kallsyms_markers[] __attribute__((weak));
75347
75348 static inline int is_kernel_inittext(unsigned long addr)
75349 {
75350 + if (system_state != SYSTEM_BOOTING)
75351 + return 0;
75352 +
75353 if (addr >= (unsigned long)_sinittext
75354 && addr <= (unsigned long)_einittext)
75355 return 1;
75356 return 0;
75357 }
75358
75359 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
75360 +#ifdef CONFIG_MODULES
75361 +static inline int is_module_text(unsigned long addr)
75362 +{
75363 + if ((unsigned long)MODULES_EXEC_VADDR <= addr && addr <= (unsigned long)MODULES_EXEC_END)
75364 + return 1;
75365 +
75366 + addr = ktla_ktva(addr);
75367 + return (unsigned long)MODULES_EXEC_VADDR <= addr && addr <= (unsigned long)MODULES_EXEC_END;
75368 +}
75369 +#else
75370 +static inline int is_module_text(unsigned long addr)
75371 +{
75372 + return 0;
75373 +}
75374 +#endif
75375 +#endif
75376 +
75377 static inline int is_kernel_text(unsigned long addr)
75378 {
75379 if ((addr >= (unsigned long)_stext && addr <= (unsigned long)_etext) ||
75380 @@ -69,13 +93,28 @@ static inline int is_kernel_text(unsigned long addr)
75381
75382 static inline int is_kernel(unsigned long addr)
75383 {
75384 +
75385 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
75386 + if (is_kernel_text(addr) || is_kernel_inittext(addr))
75387 + return 1;
75388 +
75389 + if (ktla_ktva((unsigned long)_text) <= addr && addr < (unsigned long)_end)
75390 +#else
75391 if (addr >= (unsigned long)_stext && addr <= (unsigned long)_end)
75392 +#endif
75393 +
75394 return 1;
75395 return in_gate_area_no_mm(addr);
75396 }
75397
75398 static int is_ksym_addr(unsigned long addr)
75399 {
75400 +
75401 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
75402 + if (is_module_text(addr))
75403 + return 0;
75404 +#endif
75405 +
75406 if (all_var)
75407 return is_kernel(addr);
75408
75409 @@ -470,7 +509,6 @@ static unsigned long get_ksymbol_core(struct kallsym_iter *iter)
75410
75411 static void reset_iter(struct kallsym_iter *iter, loff_t new_pos)
75412 {
75413 - iter->name[0] = '\0';
75414 iter->nameoff = get_symbol_offset(new_pos);
75415 iter->pos = new_pos;
75416 }
75417 @@ -518,6 +556,11 @@ static int s_show(struct seq_file *m, void *p)
75418 {
75419 struct kallsym_iter *iter = m->private;
75420
75421 +#ifdef CONFIG_GRKERNSEC_HIDESYM
75422 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID))
75423 + return 0;
75424 +#endif
75425 +
75426 /* Some debugging symbols have no name. Ignore them. */
75427 if (!iter->name[0])
75428 return 0;
75429 @@ -531,6 +574,7 @@ static int s_show(struct seq_file *m, void *p)
75430 */
75431 type = iter->exported ? toupper(iter->type) :
75432 tolower(iter->type);
75433 +
75434 seq_printf(m, "%pK %c %s\t[%s]\n", (void *)iter->value,
75435 type, iter->name, iter->module_name);
75436 } else
75437 @@ -556,7 +600,7 @@ static int kallsyms_open(struct inode *inode, struct file *file)
75438 struct kallsym_iter *iter;
75439 int ret;
75440
75441 - iter = kmalloc(sizeof(*iter), GFP_KERNEL);
75442 + iter = kzalloc(sizeof(*iter), GFP_KERNEL);
75443 if (!iter)
75444 return -ENOMEM;
75445 reset_iter(iter, 0);
75446 diff --git a/kernel/kcmp.c b/kernel/kcmp.c
75447 index e30ac0f..3528cac 100644
75448 --- a/kernel/kcmp.c
75449 +++ b/kernel/kcmp.c
75450 @@ -99,6 +99,10 @@ SYSCALL_DEFINE5(kcmp, pid_t, pid1, pid_t, pid2, int, type,
75451 struct task_struct *task1, *task2;
75452 int ret;
75453
75454 +#ifdef CONFIG_GRKERNSEC
75455 + return -ENOSYS;
75456 +#endif
75457 +
75458 rcu_read_lock();
75459
75460 /*
75461 diff --git a/kernel/kexec.c b/kernel/kexec.c
75462 index ffd4e11..c3ff6bf 100644
75463 --- a/kernel/kexec.c
75464 +++ b/kernel/kexec.c
75465 @@ -1048,7 +1048,8 @@ asmlinkage long compat_sys_kexec_load(unsigned long entry,
75466 unsigned long flags)
75467 {
75468 struct compat_kexec_segment in;
75469 - struct kexec_segment out, __user *ksegments;
75470 + struct kexec_segment out;
75471 + struct kexec_segment __user *ksegments;
75472 unsigned long i, result;
75473
75474 /* Don't allow clients that don't understand the native
75475 diff --git a/kernel/kmod.c b/kernel/kmod.c
75476 index 8985c87..f539dbe 100644
75477 --- a/kernel/kmod.c
75478 +++ b/kernel/kmod.c
75479 @@ -75,7 +75,7 @@ static void free_modprobe_argv(struct subprocess_info *info)
75480 kfree(info->argv);
75481 }
75482
75483 -static int call_modprobe(char *module_name, int wait)
75484 +static int call_modprobe(char *module_name, char *module_param, int wait)
75485 {
75486 static char *envp[] = {
75487 "HOME=/",
75488 @@ -84,7 +84,7 @@ static int call_modprobe(char *module_name, int wait)
75489 NULL
75490 };
75491
75492 - char **argv = kmalloc(sizeof(char *[5]), GFP_KERNEL);
75493 + char **argv = kmalloc(sizeof(char *[6]), GFP_KERNEL);
75494 if (!argv)
75495 goto out;
75496
75497 @@ -96,7 +96,8 @@ static int call_modprobe(char *module_name, int wait)
75498 argv[1] = "-q";
75499 argv[2] = "--";
75500 argv[3] = module_name; /* check free_modprobe_argv() */
75501 - argv[4] = NULL;
75502 + argv[4] = module_param;
75503 + argv[5] = NULL;
75504
75505 return call_usermodehelper_fns(modprobe_path, argv, envp,
75506 wait | UMH_KILLABLE, NULL, free_modprobe_argv, NULL);
75507 @@ -121,9 +122,8 @@ out:
75508 * If module auto-loading support is disabled then this function
75509 * becomes a no-operation.
75510 */
75511 -int __request_module(bool wait, const char *fmt, ...)
75512 +static int ____request_module(bool wait, char *module_param, const char *fmt, va_list ap)
75513 {
75514 - va_list args;
75515 char module_name[MODULE_NAME_LEN];
75516 unsigned int max_modprobes;
75517 int ret;
75518 @@ -139,9 +139,7 @@ int __request_module(bool wait, const char *fmt, ...)
75519 */
75520 WARN_ON_ONCE(wait && current_is_async());
75521
75522 - va_start(args, fmt);
75523 - ret = vsnprintf(module_name, MODULE_NAME_LEN, fmt, args);
75524 - va_end(args);
75525 + ret = vsnprintf(module_name, MODULE_NAME_LEN, fmt, ap);
75526 if (ret >= MODULE_NAME_LEN)
75527 return -ENAMETOOLONG;
75528
75529 @@ -149,6 +147,20 @@ int __request_module(bool wait, const char *fmt, ...)
75530 if (ret)
75531 return ret;
75532
75533 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
75534 + if (uid_eq(current_uid(), GLOBAL_ROOT_UID)) {
75535 + /* hack to workaround consolekit/udisks stupidity */
75536 + read_lock(&tasklist_lock);
75537 + if (!strcmp(current->comm, "mount") &&
75538 + current->real_parent && !strncmp(current->real_parent->comm, "udisk", 5)) {
75539 + read_unlock(&tasklist_lock);
75540 + printk(KERN_ALERT "grsec: denied attempt to auto-load fs module %.64s by udisks\n", module_name);
75541 + return -EPERM;
75542 + }
75543 + read_unlock(&tasklist_lock);
75544 + }
75545 +#endif
75546 +
75547 /* If modprobe needs a service that is in a module, we get a recursive
75548 * loop. Limit the number of running kmod threads to max_threads/2 or
75549 * MAX_KMOD_CONCURRENT, whichever is the smaller. A cleaner method
75550 @@ -177,11 +189,52 @@ int __request_module(bool wait, const char *fmt, ...)
75551
75552 trace_module_request(module_name, wait, _RET_IP_);
75553
75554 - ret = call_modprobe(module_name, wait ? UMH_WAIT_PROC : UMH_WAIT_EXEC);
75555 + ret = call_modprobe(module_name, module_param, wait ? UMH_WAIT_PROC : UMH_WAIT_EXEC);
75556
75557 atomic_dec(&kmod_concurrent);
75558 return ret;
75559 }
75560 +
75561 +int ___request_module(bool wait, char *module_param, const char *fmt, ...)
75562 +{
75563 + va_list args;
75564 + int ret;
75565 +
75566 + va_start(args, fmt);
75567 + ret = ____request_module(wait, module_param, fmt, args);
75568 + va_end(args);
75569 +
75570 + return ret;
75571 +}
75572 +
75573 +int __request_module(bool wait, const char *fmt, ...)
75574 +{
75575 + va_list args;
75576 + int ret;
75577 +
75578 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
75579 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID)) {
75580 + char module_param[MODULE_NAME_LEN];
75581 +
75582 + memset(module_param, 0, sizeof(module_param));
75583 +
75584 + snprintf(module_param, sizeof(module_param) - 1, "grsec_modharden_normal%u_", GR_GLOBAL_UID(current_uid()));
75585 +
75586 + va_start(args, fmt);
75587 + ret = ____request_module(wait, module_param, fmt, args);
75588 + va_end(args);
75589 +
75590 + return ret;
75591 + }
75592 +#endif
75593 +
75594 + va_start(args, fmt);
75595 + ret = ____request_module(wait, NULL, fmt, args);
75596 + va_end(args);
75597 +
75598 + return ret;
75599 +}
75600 +
75601 EXPORT_SYMBOL(__request_module);
75602 #endif /* CONFIG_MODULES */
75603
75604 @@ -292,7 +345,7 @@ static int wait_for_helper(void *data)
75605 *
75606 * Thus the __user pointer cast is valid here.
75607 */
75608 - sys_wait4(pid, (int __user *)&ret, 0, NULL);
75609 + sys_wait4(pid, (int __force_user *)&ret, 0, NULL);
75610
75611 /*
75612 * If ret is 0, either ____call_usermodehelper failed and the
75613 @@ -649,7 +702,7 @@ EXPORT_SYMBOL(call_usermodehelper_fns);
75614 static int proc_cap_handler(struct ctl_table *table, int write,
75615 void __user *buffer, size_t *lenp, loff_t *ppos)
75616 {
75617 - struct ctl_table t;
75618 + ctl_table_no_const t;
75619 unsigned long cap_array[_KERNEL_CAPABILITY_U32S];
75620 kernel_cap_t new_cap;
75621 int err, i;
75622 diff --git a/kernel/kprobes.c b/kernel/kprobes.c
75623 index 3fed7f0..a3f95ed 100644
75624 --- a/kernel/kprobes.c
75625 +++ b/kernel/kprobes.c
75626 @@ -185,7 +185,7 @@ static kprobe_opcode_t __kprobes *__get_insn_slot(struct kprobe_insn_cache *c)
75627 * kernel image and loaded module images reside. This is required
75628 * so x86_64 can correctly handle the %rip-relative fixups.
75629 */
75630 - kip->insns = module_alloc(PAGE_SIZE);
75631 + kip->insns = module_alloc_exec(PAGE_SIZE);
75632 if (!kip->insns) {
75633 kfree(kip);
75634 return NULL;
75635 @@ -225,7 +225,7 @@ static int __kprobes collect_one_slot(struct kprobe_insn_page *kip, int idx)
75636 */
75637 if (!list_is_singular(&kip->list)) {
75638 list_del(&kip->list);
75639 - module_free(NULL, kip->insns);
75640 + module_free_exec(NULL, kip->insns);
75641 kfree(kip);
75642 }
75643 return 1;
75644 @@ -2073,7 +2073,7 @@ static int __init init_kprobes(void)
75645 {
75646 int i, err = 0;
75647 unsigned long offset = 0, size = 0;
75648 - char *modname, namebuf[128];
75649 + char *modname, namebuf[KSYM_NAME_LEN];
75650 const char *symbol_name;
75651 void *addr;
75652 struct kprobe_blackpoint *kb;
75653 @@ -2158,11 +2158,11 @@ static void __kprobes report_probe(struct seq_file *pi, struct kprobe *p,
75654 kprobe_type = "k";
75655
75656 if (sym)
75657 - seq_printf(pi, "%p %s %s+0x%x %s ",
75658 + seq_printf(pi, "%pK %s %s+0x%x %s ",
75659 p->addr, kprobe_type, sym, offset,
75660 (modname ? modname : " "));
75661 else
75662 - seq_printf(pi, "%p %s %p ",
75663 + seq_printf(pi, "%pK %s %pK ",
75664 p->addr, kprobe_type, p->addr);
75665
75666 if (!pp)
75667 @@ -2199,7 +2199,7 @@ static int __kprobes show_kprobe_addr(struct seq_file *pi, void *v)
75668 const char *sym = NULL;
75669 unsigned int i = *(loff_t *) v;
75670 unsigned long offset = 0;
75671 - char *modname, namebuf[128];
75672 + char *modname, namebuf[KSYM_NAME_LEN];
75673
75674 head = &kprobe_table[i];
75675 preempt_disable();
75676 diff --git a/kernel/ksysfs.c b/kernel/ksysfs.c
75677 index 6ada93c..dce7d5d 100644
75678 --- a/kernel/ksysfs.c
75679 +++ b/kernel/ksysfs.c
75680 @@ -46,6 +46,8 @@ static ssize_t uevent_helper_store(struct kobject *kobj,
75681 {
75682 if (count+1 > UEVENT_HELPER_PATH_LEN)
75683 return -ENOENT;
75684 + if (!capable(CAP_SYS_ADMIN))
75685 + return -EPERM;
75686 memcpy(uevent_helper, buf, count);
75687 uevent_helper[count] = '\0';
75688 if (count && uevent_helper[count-1] == '\n')
75689 @@ -172,7 +174,7 @@ static ssize_t notes_read(struct file *filp, struct kobject *kobj,
75690 return count;
75691 }
75692
75693 -static struct bin_attribute notes_attr = {
75694 +static bin_attribute_no_const notes_attr __read_only = {
75695 .attr = {
75696 .name = "notes",
75697 .mode = S_IRUGO,
75698 diff --git a/kernel/lockdep.c b/kernel/lockdep.c
75699 index 8a0efac..56f1e2d 100644
75700 --- a/kernel/lockdep.c
75701 +++ b/kernel/lockdep.c
75702 @@ -590,6 +590,10 @@ static int static_obj(void *obj)
75703 end = (unsigned long) &_end,
75704 addr = (unsigned long) obj;
75705
75706 +#ifdef CONFIG_PAX_KERNEXEC
75707 + start = ktla_ktva(start);
75708 +#endif
75709 +
75710 /*
75711 * static variable?
75712 */
75713 @@ -730,6 +734,7 @@ register_lock_class(struct lockdep_map *lock, unsigned int subclass, int force)
75714 if (!static_obj(lock->key)) {
75715 debug_locks_off();
75716 printk("INFO: trying to register non-static key.\n");
75717 + printk("lock:%pS key:%pS.\n", lock, lock->key);
75718 printk("the code is fine but needs lockdep annotation.\n");
75719 printk("turning off the locking correctness validator.\n");
75720 dump_stack();
75721 @@ -3078,7 +3083,7 @@ static int __lock_acquire(struct lockdep_map *lock, unsigned int subclass,
75722 if (!class)
75723 return 0;
75724 }
75725 - atomic_inc((atomic_t *)&class->ops);
75726 + atomic_inc_unchecked((atomic_unchecked_t *)&class->ops);
75727 if (very_verbose(class)) {
75728 printk("\nacquire class [%p] %s", class->key, class->name);
75729 if (class->name_version > 1)
75730 diff --git a/kernel/lockdep_proc.c b/kernel/lockdep_proc.c
75731 index b2c71c5..7b88d63 100644
75732 --- a/kernel/lockdep_proc.c
75733 +++ b/kernel/lockdep_proc.c
75734 @@ -65,7 +65,7 @@ static int l_show(struct seq_file *m, void *v)
75735 return 0;
75736 }
75737
75738 - seq_printf(m, "%p", class->key);
75739 + seq_printf(m, "%pK", class->key);
75740 #ifdef CONFIG_DEBUG_LOCKDEP
75741 seq_printf(m, " OPS:%8ld", class->ops);
75742 #endif
75743 @@ -83,7 +83,7 @@ static int l_show(struct seq_file *m, void *v)
75744
75745 list_for_each_entry(entry, &class->locks_after, entry) {
75746 if (entry->distance == 1) {
75747 - seq_printf(m, " -> [%p] ", entry->class->key);
75748 + seq_printf(m, " -> [%pK] ", entry->class->key);
75749 print_name(m, entry->class);
75750 seq_puts(m, "\n");
75751 }
75752 @@ -152,7 +152,7 @@ static int lc_show(struct seq_file *m, void *v)
75753 if (!class->key)
75754 continue;
75755
75756 - seq_printf(m, "[%p] ", class->key);
75757 + seq_printf(m, "[%pK] ", class->key);
75758 print_name(m, class);
75759 seq_puts(m, "\n");
75760 }
75761 @@ -495,7 +495,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
75762 if (!i)
75763 seq_line(m, '-', 40-namelen, namelen);
75764
75765 - snprintf(ip, sizeof(ip), "[<%p>]",
75766 + snprintf(ip, sizeof(ip), "[<%pK>]",
75767 (void *)class->contention_point[i]);
75768 seq_printf(m, "%40s %14lu %29s %pS\n",
75769 name, stats->contention_point[i],
75770 @@ -510,7 +510,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
75771 if (!i)
75772 seq_line(m, '-', 40-namelen, namelen);
75773
75774 - snprintf(ip, sizeof(ip), "[<%p>]",
75775 + snprintf(ip, sizeof(ip), "[<%pK>]",
75776 (void *)class->contending_point[i]);
75777 seq_printf(m, "%40s %14lu %29s %pS\n",
75778 name, stats->contending_point[i],
75779 diff --git a/kernel/module.c b/kernel/module.c
75780 index 97f202c..109575f 100644
75781 --- a/kernel/module.c
75782 +++ b/kernel/module.c
75783 @@ -61,6 +61,7 @@
75784 #include <linux/pfn.h>
75785 #include <linux/bsearch.h>
75786 #include <linux/fips.h>
75787 +#include <linux/grsecurity.h>
75788 #include <uapi/linux/module.h>
75789 #include "module-internal.h"
75790
75791 @@ -156,7 +157,8 @@ static BLOCKING_NOTIFIER_HEAD(module_notify_list);
75792
75793 /* Bounds of module allocation, for speeding __module_address.
75794 * Protected by module_mutex. */
75795 -static unsigned long module_addr_min = -1UL, module_addr_max = 0;
75796 +static unsigned long module_addr_min_rw = -1UL, module_addr_max_rw = 0;
75797 +static unsigned long module_addr_min_rx = -1UL, module_addr_max_rx = 0;
75798
75799 int register_module_notifier(struct notifier_block * nb)
75800 {
75801 @@ -323,7 +325,7 @@ bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
75802 return true;
75803
75804 list_for_each_entry_rcu(mod, &modules, list) {
75805 - struct symsearch arr[] = {
75806 + struct symsearch modarr[] = {
75807 { mod->syms, mod->syms + mod->num_syms, mod->crcs,
75808 NOT_GPL_ONLY, false },
75809 { mod->gpl_syms, mod->gpl_syms + mod->num_gpl_syms,
75810 @@ -348,7 +350,7 @@ bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
75811 if (mod->state == MODULE_STATE_UNFORMED)
75812 continue;
75813
75814 - if (each_symbol_in_section(arr, ARRAY_SIZE(arr), mod, fn, data))
75815 + if (each_symbol_in_section(modarr, ARRAY_SIZE(modarr), mod, fn, data))
75816 return true;
75817 }
75818 return false;
75819 @@ -485,7 +487,7 @@ static inline void __percpu *mod_percpu(struct module *mod)
75820 static int percpu_modalloc(struct module *mod,
75821 unsigned long size, unsigned long align)
75822 {
75823 - if (align > PAGE_SIZE) {
75824 + if (align-1 >= PAGE_SIZE) {
75825 printk(KERN_WARNING "%s: per-cpu alignment %li > %li\n",
75826 mod->name, align, PAGE_SIZE);
75827 align = PAGE_SIZE;
75828 @@ -1089,7 +1091,7 @@ struct module_attribute module_uevent =
75829 static ssize_t show_coresize(struct module_attribute *mattr,
75830 struct module_kobject *mk, char *buffer)
75831 {
75832 - return sprintf(buffer, "%u\n", mk->mod->core_size);
75833 + return sprintf(buffer, "%u\n", mk->mod->core_size_rx + mk->mod->core_size_rw);
75834 }
75835
75836 static struct module_attribute modinfo_coresize =
75837 @@ -1098,7 +1100,7 @@ static struct module_attribute modinfo_coresize =
75838 static ssize_t show_initsize(struct module_attribute *mattr,
75839 struct module_kobject *mk, char *buffer)
75840 {
75841 - return sprintf(buffer, "%u\n", mk->mod->init_size);
75842 + return sprintf(buffer, "%u\n", mk->mod->init_size_rx + mk->mod->init_size_rw);
75843 }
75844
75845 static struct module_attribute modinfo_initsize =
75846 @@ -1312,7 +1314,7 @@ resolve_symbol_wait(struct module *mod,
75847 */
75848 #ifdef CONFIG_SYSFS
75849
75850 -#ifdef CONFIG_KALLSYMS
75851 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
75852 static inline bool sect_empty(const Elf_Shdr *sect)
75853 {
75854 return !(sect->sh_flags & SHF_ALLOC) || sect->sh_size == 0;
75855 @@ -1452,7 +1454,7 @@ static void add_notes_attrs(struct module *mod, const struct load_info *info)
75856 {
75857 unsigned int notes, loaded, i;
75858 struct module_notes_attrs *notes_attrs;
75859 - struct bin_attribute *nattr;
75860 + bin_attribute_no_const *nattr;
75861
75862 /* failed to create section attributes, so can't create notes */
75863 if (!mod->sect_attrs)
75864 @@ -1564,7 +1566,7 @@ static void del_usage_links(struct module *mod)
75865 static int module_add_modinfo_attrs(struct module *mod)
75866 {
75867 struct module_attribute *attr;
75868 - struct module_attribute *temp_attr;
75869 + module_attribute_no_const *temp_attr;
75870 int error = 0;
75871 int i;
75872
75873 @@ -1778,21 +1780,21 @@ static void set_section_ro_nx(void *base,
75874
75875 static void unset_module_core_ro_nx(struct module *mod)
75876 {
75877 - set_page_attributes(mod->module_core + mod->core_text_size,
75878 - mod->module_core + mod->core_size,
75879 + set_page_attributes(mod->module_core_rw,
75880 + mod->module_core_rw + mod->core_size_rw,
75881 set_memory_x);
75882 - set_page_attributes(mod->module_core,
75883 - mod->module_core + mod->core_ro_size,
75884 + set_page_attributes(mod->module_core_rx,
75885 + mod->module_core_rx + mod->core_size_rx,
75886 set_memory_rw);
75887 }
75888
75889 static void unset_module_init_ro_nx(struct module *mod)
75890 {
75891 - set_page_attributes(mod->module_init + mod->init_text_size,
75892 - mod->module_init + mod->init_size,
75893 + set_page_attributes(mod->module_init_rw,
75894 + mod->module_init_rw + mod->init_size_rw,
75895 set_memory_x);
75896 - set_page_attributes(mod->module_init,
75897 - mod->module_init + mod->init_ro_size,
75898 + set_page_attributes(mod->module_init_rx,
75899 + mod->module_init_rx + mod->init_size_rx,
75900 set_memory_rw);
75901 }
75902
75903 @@ -1805,14 +1807,14 @@ void set_all_modules_text_rw(void)
75904 list_for_each_entry_rcu(mod, &modules, list) {
75905 if (mod->state == MODULE_STATE_UNFORMED)
75906 continue;
75907 - if ((mod->module_core) && (mod->core_text_size)) {
75908 - set_page_attributes(mod->module_core,
75909 - mod->module_core + mod->core_text_size,
75910 + if ((mod->module_core_rx) && (mod->core_size_rx)) {
75911 + set_page_attributes(mod->module_core_rx,
75912 + mod->module_core_rx + mod->core_size_rx,
75913 set_memory_rw);
75914 }
75915 - if ((mod->module_init) && (mod->init_text_size)) {
75916 - set_page_attributes(mod->module_init,
75917 - mod->module_init + mod->init_text_size,
75918 + if ((mod->module_init_rx) && (mod->init_size_rx)) {
75919 + set_page_attributes(mod->module_init_rx,
75920 + mod->module_init_rx + mod->init_size_rx,
75921 set_memory_rw);
75922 }
75923 }
75924 @@ -1828,14 +1830,14 @@ void set_all_modules_text_ro(void)
75925 list_for_each_entry_rcu(mod, &modules, list) {
75926 if (mod->state == MODULE_STATE_UNFORMED)
75927 continue;
75928 - if ((mod->module_core) && (mod->core_text_size)) {
75929 - set_page_attributes(mod->module_core,
75930 - mod->module_core + mod->core_text_size,
75931 + if ((mod->module_core_rx) && (mod->core_size_rx)) {
75932 + set_page_attributes(mod->module_core_rx,
75933 + mod->module_core_rx + mod->core_size_rx,
75934 set_memory_ro);
75935 }
75936 - if ((mod->module_init) && (mod->init_text_size)) {
75937 - set_page_attributes(mod->module_init,
75938 - mod->module_init + mod->init_text_size,
75939 + if ((mod->module_init_rx) && (mod->init_size_rx)) {
75940 + set_page_attributes(mod->module_init_rx,
75941 + mod->module_init_rx + mod->init_size_rx,
75942 set_memory_ro);
75943 }
75944 }
75945 @@ -1886,16 +1888,19 @@ static void free_module(struct module *mod)
75946
75947 /* This may be NULL, but that's OK */
75948 unset_module_init_ro_nx(mod);
75949 - module_free(mod, mod->module_init);
75950 + module_free(mod, mod->module_init_rw);
75951 + module_free_exec(mod, mod->module_init_rx);
75952 kfree(mod->args);
75953 percpu_modfree(mod);
75954
75955 /* Free lock-classes: */
75956 - lockdep_free_key_range(mod->module_core, mod->core_size);
75957 + lockdep_free_key_range(mod->module_core_rx, mod->core_size_rx);
75958 + lockdep_free_key_range(mod->module_core_rw, mod->core_size_rw);
75959
75960 /* Finally, free the core (containing the module structure) */
75961 unset_module_core_ro_nx(mod);
75962 - module_free(mod, mod->module_core);
75963 + module_free_exec(mod, mod->module_core_rx);
75964 + module_free(mod, mod->module_core_rw);
75965
75966 #ifdef CONFIG_MPU
75967 update_protections(current->mm);
75968 @@ -1965,9 +1970,31 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
75969 int ret = 0;
75970 const struct kernel_symbol *ksym;
75971
75972 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
75973 + int is_fs_load = 0;
75974 + int register_filesystem_found = 0;
75975 + char *p;
75976 +
75977 + p = strstr(mod->args, "grsec_modharden_fs");
75978 + if (p) {
75979 + char *endptr = p + sizeof("grsec_modharden_fs") - 1;
75980 + /* copy \0 as well */
75981 + memmove(p, endptr, strlen(mod->args) - (unsigned int)(endptr - mod->args) + 1);
75982 + is_fs_load = 1;
75983 + }
75984 +#endif
75985 +
75986 for (i = 1; i < symsec->sh_size / sizeof(Elf_Sym); i++) {
75987 const char *name = info->strtab + sym[i].st_name;
75988
75989 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
75990 + /* it's a real shame this will never get ripped and copied
75991 + upstream! ;(
75992 + */
75993 + if (is_fs_load && !strcmp(name, "register_filesystem"))
75994 + register_filesystem_found = 1;
75995 +#endif
75996 +
75997 switch (sym[i].st_shndx) {
75998 case SHN_COMMON:
75999 /* We compiled with -fno-common. These are not
76000 @@ -1988,7 +2015,9 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
76001 ksym = resolve_symbol_wait(mod, info, name);
76002 /* Ok if resolved. */
76003 if (ksym && !IS_ERR(ksym)) {
76004 + pax_open_kernel();
76005 sym[i].st_value = ksym->value;
76006 + pax_close_kernel();
76007 break;
76008 }
76009
76010 @@ -2007,11 +2036,20 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
76011 secbase = (unsigned long)mod_percpu(mod);
76012 else
76013 secbase = info->sechdrs[sym[i].st_shndx].sh_addr;
76014 + pax_open_kernel();
76015 sym[i].st_value += secbase;
76016 + pax_close_kernel();
76017 break;
76018 }
76019 }
76020
76021 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
76022 + if (is_fs_load && !register_filesystem_found) {
76023 + printk(KERN_ALERT "grsec: Denied attempt to load non-fs module %.64s through mount\n", mod->name);
76024 + ret = -EPERM;
76025 + }
76026 +#endif
76027 +
76028 return ret;
76029 }
76030
76031 @@ -2095,22 +2133,12 @@ static void layout_sections(struct module *mod, struct load_info *info)
76032 || s->sh_entsize != ~0UL
76033 || strstarts(sname, ".init"))
76034 continue;
76035 - s->sh_entsize = get_offset(mod, &mod->core_size, s, i);
76036 + if ((s->sh_flags & SHF_WRITE) || !(s->sh_flags & SHF_ALLOC))
76037 + s->sh_entsize = get_offset(mod, &mod->core_size_rw, s, i);
76038 + else
76039 + s->sh_entsize = get_offset(mod, &mod->core_size_rx, s, i);
76040 pr_debug("\t%s\n", sname);
76041 }
76042 - switch (m) {
76043 - case 0: /* executable */
76044 - mod->core_size = debug_align(mod->core_size);
76045 - mod->core_text_size = mod->core_size;
76046 - break;
76047 - case 1: /* RO: text and ro-data */
76048 - mod->core_size = debug_align(mod->core_size);
76049 - mod->core_ro_size = mod->core_size;
76050 - break;
76051 - case 3: /* whole core */
76052 - mod->core_size = debug_align(mod->core_size);
76053 - break;
76054 - }
76055 }
76056
76057 pr_debug("Init section allocation order:\n");
76058 @@ -2124,23 +2152,13 @@ static void layout_sections(struct module *mod, struct load_info *info)
76059 || s->sh_entsize != ~0UL
76060 || !strstarts(sname, ".init"))
76061 continue;
76062 - s->sh_entsize = (get_offset(mod, &mod->init_size, s, i)
76063 - | INIT_OFFSET_MASK);
76064 + if ((s->sh_flags & SHF_WRITE) || !(s->sh_flags & SHF_ALLOC))
76065 + s->sh_entsize = get_offset(mod, &mod->init_size_rw, s, i);
76066 + else
76067 + s->sh_entsize = get_offset(mod, &mod->init_size_rx, s, i);
76068 + s->sh_entsize |= INIT_OFFSET_MASK;
76069 pr_debug("\t%s\n", sname);
76070 }
76071 - switch (m) {
76072 - case 0: /* executable */
76073 - mod->init_size = debug_align(mod->init_size);
76074 - mod->init_text_size = mod->init_size;
76075 - break;
76076 - case 1: /* RO: text and ro-data */
76077 - mod->init_size = debug_align(mod->init_size);
76078 - mod->init_ro_size = mod->init_size;
76079 - break;
76080 - case 3: /* whole init */
76081 - mod->init_size = debug_align(mod->init_size);
76082 - break;
76083 - }
76084 }
76085 }
76086
76087 @@ -2313,7 +2331,7 @@ static void layout_symtab(struct module *mod, struct load_info *info)
76088
76089 /* Put symbol section at end of init part of module. */
76090 symsect->sh_flags |= SHF_ALLOC;
76091 - symsect->sh_entsize = get_offset(mod, &mod->init_size, symsect,
76092 + symsect->sh_entsize = get_offset(mod, &mod->init_size_rx, symsect,
76093 info->index.sym) | INIT_OFFSET_MASK;
76094 pr_debug("\t%s\n", info->secstrings + symsect->sh_name);
76095
76096 @@ -2330,13 +2348,13 @@ static void layout_symtab(struct module *mod, struct load_info *info)
76097 }
76098
76099 /* Append room for core symbols at end of core part. */
76100 - info->symoffs = ALIGN(mod->core_size, symsect->sh_addralign ?: 1);
76101 - info->stroffs = mod->core_size = info->symoffs + ndst * sizeof(Elf_Sym);
76102 - mod->core_size += strtab_size;
76103 + info->symoffs = ALIGN(mod->core_size_rx, symsect->sh_addralign ?: 1);
76104 + info->stroffs = mod->core_size_rx = info->symoffs + ndst * sizeof(Elf_Sym);
76105 + mod->core_size_rx += strtab_size;
76106
76107 /* Put string table section at end of init part of module. */
76108 strsect->sh_flags |= SHF_ALLOC;
76109 - strsect->sh_entsize = get_offset(mod, &mod->init_size, strsect,
76110 + strsect->sh_entsize = get_offset(mod, &mod->init_size_rx, strsect,
76111 info->index.str) | INIT_OFFSET_MASK;
76112 pr_debug("\t%s\n", info->secstrings + strsect->sh_name);
76113 }
76114 @@ -2354,12 +2372,14 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
76115 /* Make sure we get permanent strtab: don't use info->strtab. */
76116 mod->strtab = (void *)info->sechdrs[info->index.str].sh_addr;
76117
76118 + pax_open_kernel();
76119 +
76120 /* Set types up while we still have access to sections. */
76121 for (i = 0; i < mod->num_symtab; i++)
76122 mod->symtab[i].st_info = elf_type(&mod->symtab[i], info);
76123
76124 - mod->core_symtab = dst = mod->module_core + info->symoffs;
76125 - mod->core_strtab = s = mod->module_core + info->stroffs;
76126 + mod->core_symtab = dst = mod->module_core_rx + info->symoffs;
76127 + mod->core_strtab = s = mod->module_core_rx + info->stroffs;
76128 src = mod->symtab;
76129 for (ndst = i = 0; i < mod->num_symtab; i++) {
76130 if (i == 0 ||
76131 @@ -2371,6 +2391,8 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
76132 }
76133 }
76134 mod->core_num_syms = ndst;
76135 +
76136 + pax_close_kernel();
76137 }
76138 #else
76139 static inline void layout_symtab(struct module *mod, struct load_info *info)
76140 @@ -2404,17 +2426,33 @@ void * __weak module_alloc(unsigned long size)
76141 return vmalloc_exec(size);
76142 }
76143
76144 -static void *module_alloc_update_bounds(unsigned long size)
76145 +static void *module_alloc_update_bounds_rw(unsigned long size)
76146 {
76147 void *ret = module_alloc(size);
76148
76149 if (ret) {
76150 mutex_lock(&module_mutex);
76151 /* Update module bounds. */
76152 - if ((unsigned long)ret < module_addr_min)
76153 - module_addr_min = (unsigned long)ret;
76154 - if ((unsigned long)ret + size > module_addr_max)
76155 - module_addr_max = (unsigned long)ret + size;
76156 + if ((unsigned long)ret < module_addr_min_rw)
76157 + module_addr_min_rw = (unsigned long)ret;
76158 + if ((unsigned long)ret + size > module_addr_max_rw)
76159 + module_addr_max_rw = (unsigned long)ret + size;
76160 + mutex_unlock(&module_mutex);
76161 + }
76162 + return ret;
76163 +}
76164 +
76165 +static void *module_alloc_update_bounds_rx(unsigned long size)
76166 +{
76167 + void *ret = module_alloc_exec(size);
76168 +
76169 + if (ret) {
76170 + mutex_lock(&module_mutex);
76171 + /* Update module bounds. */
76172 + if ((unsigned long)ret < module_addr_min_rx)
76173 + module_addr_min_rx = (unsigned long)ret;
76174 + if ((unsigned long)ret + size > module_addr_max_rx)
76175 + module_addr_max_rx = (unsigned long)ret + size;
76176 mutex_unlock(&module_mutex);
76177 }
76178 return ret;
76179 @@ -2690,8 +2728,14 @@ static struct module *setup_load_info(struct load_info *info, int flags)
76180 static int check_modinfo(struct module *mod, struct load_info *info, int flags)
76181 {
76182 const char *modmagic = get_modinfo(info, "vermagic");
76183 + const char *license = get_modinfo(info, "license");
76184 int err;
76185
76186 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
76187 + if (!license || !license_is_gpl_compatible(license))
76188 + return -ENOEXEC;
76189 +#endif
76190 +
76191 if (flags & MODULE_INIT_IGNORE_VERMAGIC)
76192 modmagic = NULL;
76193
76194 @@ -2717,7 +2761,7 @@ static int check_modinfo(struct module *mod, struct load_info *info, int flags)
76195 }
76196
76197 /* Set up license info based on the info section */
76198 - set_license(mod, get_modinfo(info, "license"));
76199 + set_license(mod, license);
76200
76201 return 0;
76202 }
76203 @@ -2811,7 +2855,7 @@ static int move_module(struct module *mod, struct load_info *info)
76204 void *ptr;
76205
76206 /* Do the allocs. */
76207 - ptr = module_alloc_update_bounds(mod->core_size);
76208 + ptr = module_alloc_update_bounds_rw(mod->core_size_rw);
76209 /*
76210 * The pointer to this block is stored in the module structure
76211 * which is inside the block. Just mark it as not being a
76212 @@ -2821,11 +2865,11 @@ static int move_module(struct module *mod, struct load_info *info)
76213 if (!ptr)
76214 return -ENOMEM;
76215
76216 - memset(ptr, 0, mod->core_size);
76217 - mod->module_core = ptr;
76218 + memset(ptr, 0, mod->core_size_rw);
76219 + mod->module_core_rw = ptr;
76220
76221 - if (mod->init_size) {
76222 - ptr = module_alloc_update_bounds(mod->init_size);
76223 + if (mod->init_size_rw) {
76224 + ptr = module_alloc_update_bounds_rw(mod->init_size_rw);
76225 /*
76226 * The pointer to this block is stored in the module structure
76227 * which is inside the block. This block doesn't need to be
76228 @@ -2834,13 +2878,45 @@ static int move_module(struct module *mod, struct load_info *info)
76229 */
76230 kmemleak_ignore(ptr);
76231 if (!ptr) {
76232 - module_free(mod, mod->module_core);
76233 + module_free(mod, mod->module_core_rw);
76234 return -ENOMEM;
76235 }
76236 - memset(ptr, 0, mod->init_size);
76237 - mod->module_init = ptr;
76238 + memset(ptr, 0, mod->init_size_rw);
76239 + mod->module_init_rw = ptr;
76240 } else
76241 - mod->module_init = NULL;
76242 + mod->module_init_rw = NULL;
76243 +
76244 + ptr = module_alloc_update_bounds_rx(mod->core_size_rx);
76245 + kmemleak_not_leak(ptr);
76246 + if (!ptr) {
76247 + if (mod->module_init_rw)
76248 + module_free(mod, mod->module_init_rw);
76249 + module_free(mod, mod->module_core_rw);
76250 + return -ENOMEM;
76251 + }
76252 +
76253 + pax_open_kernel();
76254 + memset(ptr, 0, mod->core_size_rx);
76255 + pax_close_kernel();
76256 + mod->module_core_rx = ptr;
76257 +
76258 + if (mod->init_size_rx) {
76259 + ptr = module_alloc_update_bounds_rx(mod->init_size_rx);
76260 + kmemleak_ignore(ptr);
76261 + if (!ptr && mod->init_size_rx) {
76262 + module_free_exec(mod, mod->module_core_rx);
76263 + if (mod->module_init_rw)
76264 + module_free(mod, mod->module_init_rw);
76265 + module_free(mod, mod->module_core_rw);
76266 + return -ENOMEM;
76267 + }
76268 +
76269 + pax_open_kernel();
76270 + memset(ptr, 0, mod->init_size_rx);
76271 + pax_close_kernel();
76272 + mod->module_init_rx = ptr;
76273 + } else
76274 + mod->module_init_rx = NULL;
76275
76276 /* Transfer each section which specifies SHF_ALLOC */
76277 pr_debug("final section addresses:\n");
76278 @@ -2851,16 +2927,45 @@ static int move_module(struct module *mod, struct load_info *info)
76279 if (!(shdr->sh_flags & SHF_ALLOC))
76280 continue;
76281
76282 - if (shdr->sh_entsize & INIT_OFFSET_MASK)
76283 - dest = mod->module_init
76284 - + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
76285 - else
76286 - dest = mod->module_core + shdr->sh_entsize;
76287 + if (shdr->sh_entsize & INIT_OFFSET_MASK) {
76288 + if ((shdr->sh_flags & SHF_WRITE) || !(shdr->sh_flags & SHF_ALLOC))
76289 + dest = mod->module_init_rw
76290 + + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
76291 + else
76292 + dest = mod->module_init_rx
76293 + + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
76294 + } else {
76295 + if ((shdr->sh_flags & SHF_WRITE) || !(shdr->sh_flags & SHF_ALLOC))
76296 + dest = mod->module_core_rw + shdr->sh_entsize;
76297 + else
76298 + dest = mod->module_core_rx + shdr->sh_entsize;
76299 + }
76300 +
76301 + if (shdr->sh_type != SHT_NOBITS) {
76302 +
76303 +#ifdef CONFIG_PAX_KERNEXEC
76304 +#ifdef CONFIG_X86_64
76305 + if ((shdr->sh_flags & SHF_WRITE) && (shdr->sh_flags & SHF_EXECINSTR))
76306 + set_memory_x((unsigned long)dest, (shdr->sh_size + PAGE_SIZE) >> PAGE_SHIFT);
76307 +#endif
76308 + if (!(shdr->sh_flags & SHF_WRITE) && (shdr->sh_flags & SHF_ALLOC)) {
76309 + pax_open_kernel();
76310 + memcpy(dest, (void *)shdr->sh_addr, shdr->sh_size);
76311 + pax_close_kernel();
76312 + } else
76313 +#endif
76314
76315 - if (shdr->sh_type != SHT_NOBITS)
76316 memcpy(dest, (void *)shdr->sh_addr, shdr->sh_size);
76317 + }
76318 /* Update sh_addr to point to copy in image. */
76319 - shdr->sh_addr = (unsigned long)dest;
76320 +
76321 +#ifdef CONFIG_PAX_KERNEXEC
76322 + if (shdr->sh_flags & SHF_EXECINSTR)
76323 + shdr->sh_addr = ktva_ktla((unsigned long)dest);
76324 + else
76325 +#endif
76326 +
76327 + shdr->sh_addr = (unsigned long)dest;
76328 pr_debug("\t0x%lx %s\n",
76329 (long)shdr->sh_addr, info->secstrings + shdr->sh_name);
76330 }
76331 @@ -2917,12 +3022,12 @@ static void flush_module_icache(const struct module *mod)
76332 * Do it before processing of module parameters, so the module
76333 * can provide parameter accessor functions of its own.
76334 */
76335 - if (mod->module_init)
76336 - flush_icache_range((unsigned long)mod->module_init,
76337 - (unsigned long)mod->module_init
76338 - + mod->init_size);
76339 - flush_icache_range((unsigned long)mod->module_core,
76340 - (unsigned long)mod->module_core + mod->core_size);
76341 + if (mod->module_init_rx)
76342 + flush_icache_range((unsigned long)mod->module_init_rx,
76343 + (unsigned long)mod->module_init_rx
76344 + + mod->init_size_rx);
76345 + flush_icache_range((unsigned long)mod->module_core_rx,
76346 + (unsigned long)mod->module_core_rx + mod->core_size_rx);
76347
76348 set_fs(old_fs);
76349 }
76350 @@ -2992,8 +3097,10 @@ out:
76351 static void module_deallocate(struct module *mod, struct load_info *info)
76352 {
76353 percpu_modfree(mod);
76354 - module_free(mod, mod->module_init);
76355 - module_free(mod, mod->module_core);
76356 + module_free_exec(mod, mod->module_init_rx);
76357 + module_free_exec(mod, mod->module_core_rx);
76358 + module_free(mod, mod->module_init_rw);
76359 + module_free(mod, mod->module_core_rw);
76360 }
76361
76362 int __weak module_finalize(const Elf_Ehdr *hdr,
76363 @@ -3006,7 +3113,9 @@ int __weak module_finalize(const Elf_Ehdr *hdr,
76364 static int post_relocation(struct module *mod, const struct load_info *info)
76365 {
76366 /* Sort exception table now relocations are done. */
76367 + pax_open_kernel();
76368 sort_extable(mod->extable, mod->extable + mod->num_exentries);
76369 + pax_close_kernel();
76370
76371 /* Copy relocated percpu area over. */
76372 percpu_modcopy(mod, (void *)info->sechdrs[info->index.pcpu].sh_addr,
76373 @@ -3060,16 +3169,16 @@ static int do_init_module(struct module *mod)
76374 MODULE_STATE_COMING, mod);
76375
76376 /* Set RO and NX regions for core */
76377 - set_section_ro_nx(mod->module_core,
76378 - mod->core_text_size,
76379 - mod->core_ro_size,
76380 - mod->core_size);
76381 + set_section_ro_nx(mod->module_core_rx,
76382 + mod->core_size_rx,
76383 + mod->core_size_rx,
76384 + mod->core_size_rx);
76385
76386 /* Set RO and NX regions for init */
76387 - set_section_ro_nx(mod->module_init,
76388 - mod->init_text_size,
76389 - mod->init_ro_size,
76390 - mod->init_size);
76391 + set_section_ro_nx(mod->module_init_rx,
76392 + mod->init_size_rx,
76393 + mod->init_size_rx,
76394 + mod->init_size_rx);
76395
76396 do_mod_ctors(mod);
76397 /* Start the module */
76398 @@ -3131,11 +3240,12 @@ static int do_init_module(struct module *mod)
76399 mod->strtab = mod->core_strtab;
76400 #endif
76401 unset_module_init_ro_nx(mod);
76402 - module_free(mod, mod->module_init);
76403 - mod->module_init = NULL;
76404 - mod->init_size = 0;
76405 - mod->init_ro_size = 0;
76406 - mod->init_text_size = 0;
76407 + module_free(mod, mod->module_init_rw);
76408 + module_free_exec(mod, mod->module_init_rx);
76409 + mod->module_init_rw = NULL;
76410 + mod->module_init_rx = NULL;
76411 + mod->init_size_rw = 0;
76412 + mod->init_size_rx = 0;
76413 mutex_unlock(&module_mutex);
76414 wake_up_all(&module_wq);
76415
76416 @@ -3262,9 +3372,38 @@ static int load_module(struct load_info *info, const char __user *uargs,
76417 if (err)
76418 goto free_unload;
76419
76420 + /* Now copy in args */
76421 + mod->args = strndup_user(uargs, ~0UL >> 1);
76422 + if (IS_ERR(mod->args)) {
76423 + err = PTR_ERR(mod->args);
76424 + goto free_unload;
76425 + }
76426 +
76427 /* Set up MODINFO_ATTR fields */
76428 setup_modinfo(mod, info);
76429
76430 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
76431 + {
76432 + char *p, *p2;
76433 +
76434 + if (strstr(mod->args, "grsec_modharden_netdev")) {
76435 + 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);
76436 + err = -EPERM;
76437 + goto free_modinfo;
76438 + } else if ((p = strstr(mod->args, "grsec_modharden_normal"))) {
76439 + p += sizeof("grsec_modharden_normal") - 1;
76440 + p2 = strstr(p, "_");
76441 + if (p2) {
76442 + *p2 = '\0';
76443 + printk(KERN_ALERT "grsec: denied kernel module auto-load of %.64s by uid %.9s\n", mod->name, p);
76444 + *p2 = '_';
76445 + }
76446 + err = -EPERM;
76447 + goto free_modinfo;
76448 + }
76449 + }
76450 +#endif
76451 +
76452 /* Fix up syms, so that st_value is a pointer to location. */
76453 err = simplify_symbols(mod, info);
76454 if (err < 0)
76455 @@ -3280,13 +3419,6 @@ static int load_module(struct load_info *info, const char __user *uargs,
76456
76457 flush_module_icache(mod);
76458
76459 - /* Now copy in args */
76460 - mod->args = strndup_user(uargs, ~0UL >> 1);
76461 - if (IS_ERR(mod->args)) {
76462 - err = PTR_ERR(mod->args);
76463 - goto free_arch_cleanup;
76464 - }
76465 -
76466 dynamic_debug_setup(info->debug, info->num_debug);
76467
76468 /* Finally it's fully formed, ready to start executing. */
76469 @@ -3321,11 +3453,10 @@ static int load_module(struct load_info *info, const char __user *uargs,
76470 ddebug_cleanup:
76471 dynamic_debug_remove(info->debug);
76472 synchronize_sched();
76473 - kfree(mod->args);
76474 - free_arch_cleanup:
76475 module_arch_cleanup(mod);
76476 free_modinfo:
76477 free_modinfo(mod);
76478 + kfree(mod->args);
76479 free_unload:
76480 module_unload_free(mod);
76481 unlink_mod:
76482 @@ -3408,10 +3539,16 @@ static const char *get_ksymbol(struct module *mod,
76483 unsigned long nextval;
76484
76485 /* At worse, next value is at end of module */
76486 - if (within_module_init(addr, mod))
76487 - nextval = (unsigned long)mod->module_init+mod->init_text_size;
76488 + if (within_module_init_rx(addr, mod))
76489 + nextval = (unsigned long)mod->module_init_rx+mod->init_size_rx;
76490 + else if (within_module_init_rw(addr, mod))
76491 + nextval = (unsigned long)mod->module_init_rw+mod->init_size_rw;
76492 + else if (within_module_core_rx(addr, mod))
76493 + nextval = (unsigned long)mod->module_core_rx+mod->core_size_rx;
76494 + else if (within_module_core_rw(addr, mod))
76495 + nextval = (unsigned long)mod->module_core_rw+mod->core_size_rw;
76496 else
76497 - nextval = (unsigned long)mod->module_core+mod->core_text_size;
76498 + return NULL;
76499
76500 /* Scan for closest preceding symbol, and next symbol. (ELF
76501 starts real symbols at 1). */
76502 @@ -3664,7 +3801,7 @@ static int m_show(struct seq_file *m, void *p)
76503 return 0;
76504
76505 seq_printf(m, "%s %u",
76506 - mod->name, mod->init_size + mod->core_size);
76507 + mod->name, mod->init_size_rx + mod->init_size_rw + mod->core_size_rx + mod->core_size_rw);
76508 print_unload_info(m, mod);
76509
76510 /* Informative for users. */
76511 @@ -3673,7 +3810,7 @@ static int m_show(struct seq_file *m, void *p)
76512 mod->state == MODULE_STATE_COMING ? "Loading":
76513 "Live");
76514 /* Used by oprofile and other similar tools. */
76515 - seq_printf(m, " 0x%pK", mod->module_core);
76516 + seq_printf(m, " 0x%pK 0x%pK", mod->module_core_rx, mod->module_core_rw);
76517
76518 /* Taints info */
76519 if (mod->taints)
76520 @@ -3709,7 +3846,17 @@ static const struct file_operations proc_modules_operations = {
76521
76522 static int __init proc_modules_init(void)
76523 {
76524 +#ifndef CONFIG_GRKERNSEC_HIDESYM
76525 +#ifdef CONFIG_GRKERNSEC_PROC_USER
76526 + proc_create("modules", S_IRUSR, NULL, &proc_modules_operations);
76527 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
76528 + proc_create("modules", S_IRUSR | S_IRGRP, NULL, &proc_modules_operations);
76529 +#else
76530 proc_create("modules", 0, NULL, &proc_modules_operations);
76531 +#endif
76532 +#else
76533 + proc_create("modules", S_IRUSR, NULL, &proc_modules_operations);
76534 +#endif
76535 return 0;
76536 }
76537 module_init(proc_modules_init);
76538 @@ -3770,14 +3917,14 @@ struct module *__module_address(unsigned long addr)
76539 {
76540 struct module *mod;
76541
76542 - if (addr < module_addr_min || addr > module_addr_max)
76543 + if ((addr < module_addr_min_rx || addr > module_addr_max_rx) &&
76544 + (addr < module_addr_min_rw || addr > module_addr_max_rw))
76545 return NULL;
76546
76547 list_for_each_entry_rcu(mod, &modules, list) {
76548 if (mod->state == MODULE_STATE_UNFORMED)
76549 continue;
76550 - if (within_module_core(addr, mod)
76551 - || within_module_init(addr, mod))
76552 + if (within_module_init(addr, mod) || within_module_core(addr, mod))
76553 return mod;
76554 }
76555 return NULL;
76556 @@ -3812,11 +3959,20 @@ bool is_module_text_address(unsigned long addr)
76557 */
76558 struct module *__module_text_address(unsigned long addr)
76559 {
76560 - struct module *mod = __module_address(addr);
76561 + struct module *mod;
76562 +
76563 +#ifdef CONFIG_X86_32
76564 + addr = ktla_ktva(addr);
76565 +#endif
76566 +
76567 + if (addr < module_addr_min_rx || addr > module_addr_max_rx)
76568 + return NULL;
76569 +
76570 + mod = __module_address(addr);
76571 +
76572 if (mod) {
76573 /* Make sure it's within the text section. */
76574 - if (!within(addr, mod->module_init, mod->init_text_size)
76575 - && !within(addr, mod->module_core, mod->core_text_size))
76576 + if (!within_module_init_rx(addr, mod) && !within_module_core_rx(addr, mod))
76577 mod = NULL;
76578 }
76579 return mod;
76580 diff --git a/kernel/mutex-debug.c b/kernel/mutex-debug.c
76581 index 7e3443f..b2a1e6b 100644
76582 --- a/kernel/mutex-debug.c
76583 +++ b/kernel/mutex-debug.c
76584 @@ -49,21 +49,21 @@ void debug_mutex_free_waiter(struct mutex_waiter *waiter)
76585 }
76586
76587 void debug_mutex_add_waiter(struct mutex *lock, struct mutex_waiter *waiter,
76588 - struct thread_info *ti)
76589 + struct task_struct *task)
76590 {
76591 SMP_DEBUG_LOCKS_WARN_ON(!spin_is_locked(&lock->wait_lock));
76592
76593 /* Mark the current thread as blocked on the lock: */
76594 - ti->task->blocked_on = waiter;
76595 + task->blocked_on = waiter;
76596 }
76597
76598 void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
76599 - struct thread_info *ti)
76600 + struct task_struct *task)
76601 {
76602 DEBUG_LOCKS_WARN_ON(list_empty(&waiter->list));
76603 - DEBUG_LOCKS_WARN_ON(waiter->task != ti->task);
76604 - DEBUG_LOCKS_WARN_ON(ti->task->blocked_on != waiter);
76605 - ti->task->blocked_on = NULL;
76606 + DEBUG_LOCKS_WARN_ON(waiter->task != task);
76607 + DEBUG_LOCKS_WARN_ON(task->blocked_on != waiter);
76608 + task->blocked_on = NULL;
76609
76610 list_del_init(&waiter->list);
76611 waiter->task = NULL;
76612 diff --git a/kernel/mutex-debug.h b/kernel/mutex-debug.h
76613 index 0799fd3..d06ae3b 100644
76614 --- a/kernel/mutex-debug.h
76615 +++ b/kernel/mutex-debug.h
76616 @@ -20,9 +20,9 @@ extern void debug_mutex_wake_waiter(struct mutex *lock,
76617 extern void debug_mutex_free_waiter(struct mutex_waiter *waiter);
76618 extern void debug_mutex_add_waiter(struct mutex *lock,
76619 struct mutex_waiter *waiter,
76620 - struct thread_info *ti);
76621 + struct task_struct *task);
76622 extern void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
76623 - struct thread_info *ti);
76624 + struct task_struct *task);
76625 extern void debug_mutex_unlock(struct mutex *lock);
76626 extern void debug_mutex_init(struct mutex *lock, const char *name,
76627 struct lock_class_key *key);
76628 diff --git a/kernel/mutex.c b/kernel/mutex.c
76629 index 52f2301..73f7528 100644
76630 --- a/kernel/mutex.c
76631 +++ b/kernel/mutex.c
76632 @@ -199,7 +199,7 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
76633 spin_lock_mutex(&lock->wait_lock, flags);
76634
76635 debug_mutex_lock_common(lock, &waiter);
76636 - debug_mutex_add_waiter(lock, &waiter, task_thread_info(task));
76637 + debug_mutex_add_waiter(lock, &waiter, task);
76638
76639 /* add waiting tasks to the end of the waitqueue (FIFO): */
76640 list_add_tail(&waiter.list, &lock->wait_list);
76641 @@ -228,8 +228,7 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
76642 * TASK_UNINTERRUPTIBLE case.)
76643 */
76644 if (unlikely(signal_pending_state(state, task))) {
76645 - mutex_remove_waiter(lock, &waiter,
76646 - task_thread_info(task));
76647 + mutex_remove_waiter(lock, &waiter, task);
76648 mutex_release(&lock->dep_map, 1, ip);
76649 spin_unlock_mutex(&lock->wait_lock, flags);
76650
76651 @@ -248,7 +247,7 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
76652 done:
76653 lock_acquired(&lock->dep_map, ip);
76654 /* got the lock - rejoice! */
76655 - mutex_remove_waiter(lock, &waiter, current_thread_info());
76656 + mutex_remove_waiter(lock, &waiter, task);
76657 mutex_set_owner(lock);
76658
76659 /* set it to 0 if there are no waiters left: */
76660 diff --git a/kernel/notifier.c b/kernel/notifier.c
76661 index 2d5cc4c..d9ea600 100644
76662 --- a/kernel/notifier.c
76663 +++ b/kernel/notifier.c
76664 @@ -5,6 +5,7 @@
76665 #include <linux/rcupdate.h>
76666 #include <linux/vmalloc.h>
76667 #include <linux/reboot.h>
76668 +#include <linux/mm.h>
76669
76670 /*
76671 * Notifier list for kernel code which wants to be called
76672 @@ -24,10 +25,12 @@ static int notifier_chain_register(struct notifier_block **nl,
76673 while ((*nl) != NULL) {
76674 if (n->priority > (*nl)->priority)
76675 break;
76676 - nl = &((*nl)->next);
76677 + nl = (struct notifier_block **)&((*nl)->next);
76678 }
76679 - n->next = *nl;
76680 + pax_open_kernel();
76681 + *(const void **)&n->next = *nl;
76682 rcu_assign_pointer(*nl, n);
76683 + pax_close_kernel();
76684 return 0;
76685 }
76686
76687 @@ -39,10 +42,12 @@ static int notifier_chain_cond_register(struct notifier_block **nl,
76688 return 0;
76689 if (n->priority > (*nl)->priority)
76690 break;
76691 - nl = &((*nl)->next);
76692 + nl = (struct notifier_block **)&((*nl)->next);
76693 }
76694 - n->next = *nl;
76695 + pax_open_kernel();
76696 + *(const void **)&n->next = *nl;
76697 rcu_assign_pointer(*nl, n);
76698 + pax_close_kernel();
76699 return 0;
76700 }
76701
76702 @@ -51,10 +56,12 @@ static int notifier_chain_unregister(struct notifier_block **nl,
76703 {
76704 while ((*nl) != NULL) {
76705 if ((*nl) == n) {
76706 + pax_open_kernel();
76707 rcu_assign_pointer(*nl, n->next);
76708 + pax_close_kernel();
76709 return 0;
76710 }
76711 - nl = &((*nl)->next);
76712 + nl = (struct notifier_block **)&((*nl)->next);
76713 }
76714 return -ENOENT;
76715 }
76716 diff --git a/kernel/panic.c b/kernel/panic.c
76717 index 7c57cc9..28f1b3f 100644
76718 --- a/kernel/panic.c
76719 +++ b/kernel/panic.c
76720 @@ -403,7 +403,7 @@ static void warn_slowpath_common(const char *file, int line, void *caller,
76721 const char *board;
76722
76723 printk(KERN_WARNING "------------[ cut here ]------------\n");
76724 - printk(KERN_WARNING "WARNING: at %s:%d %pS()\n", file, line, caller);
76725 + printk(KERN_WARNING "WARNING: at %s:%d %pA()\n", file, line, caller);
76726 board = dmi_get_system_info(DMI_PRODUCT_NAME);
76727 if (board)
76728 printk(KERN_WARNING "Hardware name: %s\n", board);
76729 @@ -459,7 +459,8 @@ EXPORT_SYMBOL(warn_slowpath_null);
76730 */
76731 void __stack_chk_fail(void)
76732 {
76733 - panic("stack-protector: Kernel stack is corrupted in: %p\n",
76734 + dump_stack();
76735 + panic("stack-protector: Kernel stack is corrupted in: %pA\n",
76736 __builtin_return_address(0));
76737 }
76738 EXPORT_SYMBOL(__stack_chk_fail);
76739 diff --git a/kernel/pid.c b/kernel/pid.c
76740 index 047dc62..418d74b 100644
76741 --- a/kernel/pid.c
76742 +++ b/kernel/pid.c
76743 @@ -33,6 +33,7 @@
76744 #include <linux/rculist.h>
76745 #include <linux/bootmem.h>
76746 #include <linux/hash.h>
76747 +#include <linux/security.h>
76748 #include <linux/pid_namespace.h>
76749 #include <linux/init_task.h>
76750 #include <linux/syscalls.h>
76751 @@ -46,7 +47,7 @@ struct pid init_struct_pid = INIT_STRUCT_PID;
76752
76753 int pid_max = PID_MAX_DEFAULT;
76754
76755 -#define RESERVED_PIDS 300
76756 +#define RESERVED_PIDS 500
76757
76758 int pid_max_min = RESERVED_PIDS + 1;
76759 int pid_max_max = PID_MAX_LIMIT;
76760 @@ -440,10 +441,18 @@ EXPORT_SYMBOL(pid_task);
76761 */
76762 struct task_struct *find_task_by_pid_ns(pid_t nr, struct pid_namespace *ns)
76763 {
76764 + struct task_struct *task;
76765 +
76766 rcu_lockdep_assert(rcu_read_lock_held(),
76767 "find_task_by_pid_ns() needs rcu_read_lock()"
76768 " protection");
76769 - return pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
76770 +
76771 + task = pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
76772 +
76773 + if (gr_pid_is_chrooted(task))
76774 + return NULL;
76775 +
76776 + return task;
76777 }
76778
76779 struct task_struct *find_task_by_vpid(pid_t vnr)
76780 @@ -451,6 +460,14 @@ struct task_struct *find_task_by_vpid(pid_t vnr)
76781 return find_task_by_pid_ns(vnr, task_active_pid_ns(current));
76782 }
76783
76784 +struct task_struct *find_task_by_vpid_unrestricted(pid_t vnr)
76785 +{
76786 + rcu_lockdep_assert(rcu_read_lock_held(),
76787 + "find_task_by_pid_ns() needs rcu_read_lock()"
76788 + " protection");
76789 + return pid_task(find_pid_ns(vnr, task_active_pid_ns(current)), PIDTYPE_PID);
76790 +}
76791 +
76792 struct pid *get_task_pid(struct task_struct *task, enum pid_type type)
76793 {
76794 struct pid *pid;
76795 diff --git a/kernel/pid_namespace.c b/kernel/pid_namespace.c
76796 index bea15bd..789f3d0 100644
76797 --- a/kernel/pid_namespace.c
76798 +++ b/kernel/pid_namespace.c
76799 @@ -249,7 +249,7 @@ static int pid_ns_ctl_handler(struct ctl_table *table, int write,
76800 void __user *buffer, size_t *lenp, loff_t *ppos)
76801 {
76802 struct pid_namespace *pid_ns = task_active_pid_ns(current);
76803 - struct ctl_table tmp = *table;
76804 + ctl_table_no_const tmp = *table;
76805
76806 if (write && !ns_capable(pid_ns->user_ns, CAP_SYS_ADMIN))
76807 return -EPERM;
76808 diff --git a/kernel/posix-cpu-timers.c b/kernel/posix-cpu-timers.c
76809 index 8fd709c..542bf4b 100644
76810 --- a/kernel/posix-cpu-timers.c
76811 +++ b/kernel/posix-cpu-timers.c
76812 @@ -1592,14 +1592,14 @@ struct k_clock clock_posix_cpu = {
76813
76814 static __init int init_posix_cpu_timers(void)
76815 {
76816 - struct k_clock process = {
76817 + static struct k_clock process = {
76818 .clock_getres = process_cpu_clock_getres,
76819 .clock_get = process_cpu_clock_get,
76820 .timer_create = process_cpu_timer_create,
76821 .nsleep = process_cpu_nsleep,
76822 .nsleep_restart = process_cpu_nsleep_restart,
76823 };
76824 - struct k_clock thread = {
76825 + static struct k_clock thread = {
76826 .clock_getres = thread_cpu_clock_getres,
76827 .clock_get = thread_cpu_clock_get,
76828 .timer_create = thread_cpu_timer_create,
76829 diff --git a/kernel/posix-timers.c b/kernel/posix-timers.c
76830 index 6edbb2c..334f085 100644
76831 --- a/kernel/posix-timers.c
76832 +++ b/kernel/posix-timers.c
76833 @@ -43,6 +43,7 @@
76834 #include <linux/idr.h>
76835 #include <linux/posix-clock.h>
76836 #include <linux/posix-timers.h>
76837 +#include <linux/grsecurity.h>
76838 #include <linux/syscalls.h>
76839 #include <linux/wait.h>
76840 #include <linux/workqueue.h>
76841 @@ -129,7 +130,7 @@ static DEFINE_SPINLOCK(idr_lock);
76842 * which we beg off on and pass to do_sys_settimeofday().
76843 */
76844
76845 -static struct k_clock posix_clocks[MAX_CLOCKS];
76846 +static struct k_clock *posix_clocks[MAX_CLOCKS];
76847
76848 /*
76849 * These ones are defined below.
76850 @@ -227,7 +228,7 @@ static int posix_get_boottime(const clockid_t which_clock, struct timespec *tp)
76851 */
76852 static __init int init_posix_timers(void)
76853 {
76854 - struct k_clock clock_realtime = {
76855 + static struct k_clock clock_realtime = {
76856 .clock_getres = hrtimer_get_res,
76857 .clock_get = posix_clock_realtime_get,
76858 .clock_set = posix_clock_realtime_set,
76859 @@ -239,7 +240,7 @@ static __init int init_posix_timers(void)
76860 .timer_get = common_timer_get,
76861 .timer_del = common_timer_del,
76862 };
76863 - struct k_clock clock_monotonic = {
76864 + static struct k_clock clock_monotonic = {
76865 .clock_getres = hrtimer_get_res,
76866 .clock_get = posix_ktime_get_ts,
76867 .nsleep = common_nsleep,
76868 @@ -249,19 +250,19 @@ static __init int init_posix_timers(void)
76869 .timer_get = common_timer_get,
76870 .timer_del = common_timer_del,
76871 };
76872 - struct k_clock clock_monotonic_raw = {
76873 + static struct k_clock clock_monotonic_raw = {
76874 .clock_getres = hrtimer_get_res,
76875 .clock_get = posix_get_monotonic_raw,
76876 };
76877 - struct k_clock clock_realtime_coarse = {
76878 + static struct k_clock clock_realtime_coarse = {
76879 .clock_getres = posix_get_coarse_res,
76880 .clock_get = posix_get_realtime_coarse,
76881 };
76882 - struct k_clock clock_monotonic_coarse = {
76883 + static struct k_clock clock_monotonic_coarse = {
76884 .clock_getres = posix_get_coarse_res,
76885 .clock_get = posix_get_monotonic_coarse,
76886 };
76887 - struct k_clock clock_boottime = {
76888 + static struct k_clock clock_boottime = {
76889 .clock_getres = hrtimer_get_res,
76890 .clock_get = posix_get_boottime,
76891 .nsleep = common_nsleep,
76892 @@ -473,7 +474,7 @@ void posix_timers_register_clock(const clockid_t clock_id,
76893 return;
76894 }
76895
76896 - posix_clocks[clock_id] = *new_clock;
76897 + posix_clocks[clock_id] = new_clock;
76898 }
76899 EXPORT_SYMBOL_GPL(posix_timers_register_clock);
76900
76901 @@ -519,9 +520,9 @@ static struct k_clock *clockid_to_kclock(const clockid_t id)
76902 return (id & CLOCKFD_MASK) == CLOCKFD ?
76903 &clock_posix_dynamic : &clock_posix_cpu;
76904
76905 - if (id >= MAX_CLOCKS || !posix_clocks[id].clock_getres)
76906 + if (id >= MAX_CLOCKS || !posix_clocks[id] || !posix_clocks[id]->clock_getres)
76907 return NULL;
76908 - return &posix_clocks[id];
76909 + return posix_clocks[id];
76910 }
76911
76912 static int common_timer_create(struct k_itimer *new_timer)
76913 @@ -964,6 +965,13 @@ SYSCALL_DEFINE2(clock_settime, const clockid_t, which_clock,
76914 if (copy_from_user(&new_tp, tp, sizeof (*tp)))
76915 return -EFAULT;
76916
76917 + /* only the CLOCK_REALTIME clock can be set, all other clocks
76918 + have their clock_set fptr set to a nosettime dummy function
76919 + CLOCK_REALTIME has a NULL clock_set fptr which causes it to
76920 + call common_clock_set, which calls do_sys_settimeofday, which
76921 + we hook
76922 + */
76923 +
76924 return kc->clock_set(which_clock, &new_tp);
76925 }
76926
76927 diff --git a/kernel/power/process.c b/kernel/power/process.c
76928 index 98088e0..aaf95c0 100644
76929 --- a/kernel/power/process.c
76930 +++ b/kernel/power/process.c
76931 @@ -33,6 +33,7 @@ static int try_to_freeze_tasks(bool user_only)
76932 u64 elapsed_csecs64;
76933 unsigned int elapsed_csecs;
76934 bool wakeup = false;
76935 + bool timedout = false;
76936
76937 do_gettimeofday(&start);
76938
76939 @@ -43,13 +44,20 @@ static int try_to_freeze_tasks(bool user_only)
76940
76941 while (true) {
76942 todo = 0;
76943 + if (time_after(jiffies, end_time))
76944 + timedout = true;
76945 read_lock(&tasklist_lock);
76946 do_each_thread(g, p) {
76947 if (p == current || !freeze_task(p))
76948 continue;
76949
76950 - if (!freezer_should_skip(p))
76951 + if (!freezer_should_skip(p)) {
76952 todo++;
76953 + if (timedout) {
76954 + printk(KERN_ERR "Task refusing to freeze:\n");
76955 + sched_show_task(p);
76956 + }
76957 + }
76958 } while_each_thread(g, p);
76959 read_unlock(&tasklist_lock);
76960
76961 @@ -58,7 +66,7 @@ static int try_to_freeze_tasks(bool user_only)
76962 todo += wq_busy;
76963 }
76964
76965 - if (!todo || time_after(jiffies, end_time))
76966 + if (!todo || timedout)
76967 break;
76968
76969 if (pm_wakeup_pending()) {
76970 diff --git a/kernel/printk.c b/kernel/printk.c
76971 index abbdd9e..f294251 100644
76972 --- a/kernel/printk.c
76973 +++ b/kernel/printk.c
76974 @@ -615,11 +615,17 @@ static unsigned int devkmsg_poll(struct file *file, poll_table *wait)
76975 return ret;
76976 }
76977
76978 +static int check_syslog_permissions(int type, bool from_file);
76979 +
76980 static int devkmsg_open(struct inode *inode, struct file *file)
76981 {
76982 struct devkmsg_user *user;
76983 int err;
76984
76985 + err = check_syslog_permissions(SYSLOG_ACTION_OPEN, SYSLOG_FROM_FILE);
76986 + if (err)
76987 + return err;
76988 +
76989 /* write-only does not need any file context */
76990 if ((file->f_flags & O_ACCMODE) == O_WRONLY)
76991 return 0;
76992 @@ -828,7 +834,7 @@ static int syslog_action_restricted(int type)
76993 if (dmesg_restrict)
76994 return 1;
76995 /* Unless restricted, we allow "read all" and "get buffer size" for everybody */
76996 - return type != SYSLOG_ACTION_READ_ALL && type != SYSLOG_ACTION_SIZE_BUFFER;
76997 + return type != SYSLOG_ACTION_OPEN && type != SYSLOG_ACTION_READ_ALL && type != SYSLOG_ACTION_SIZE_BUFFER;
76998 }
76999
77000 static int check_syslog_permissions(int type, bool from_file)
77001 @@ -840,6 +846,11 @@ static int check_syslog_permissions(int type, bool from_file)
77002 if (from_file && type != SYSLOG_ACTION_OPEN)
77003 return 0;
77004
77005 +#ifdef CONFIG_GRKERNSEC_DMESG
77006 + if (grsec_enable_dmesg && !capable(CAP_SYSLOG) && !capable_nolog(CAP_SYS_ADMIN))
77007 + return -EPERM;
77008 +#endif
77009 +
77010 if (syslog_action_restricted(type)) {
77011 if (capable(CAP_SYSLOG))
77012 return 0;
77013 diff --git a/kernel/profile.c b/kernel/profile.c
77014 index dc3384e..0de5b49 100644
77015 --- a/kernel/profile.c
77016 +++ b/kernel/profile.c
77017 @@ -37,7 +37,7 @@ struct profile_hit {
77018 #define NR_PROFILE_HIT (PAGE_SIZE/sizeof(struct profile_hit))
77019 #define NR_PROFILE_GRP (NR_PROFILE_HIT/PROFILE_GRPSZ)
77020
77021 -static atomic_t *prof_buffer;
77022 +static atomic_unchecked_t *prof_buffer;
77023 static unsigned long prof_len, prof_shift;
77024
77025 int prof_on __read_mostly;
77026 @@ -260,7 +260,7 @@ static void profile_flip_buffers(void)
77027 hits[i].pc = 0;
77028 continue;
77029 }
77030 - atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
77031 + atomic_add_unchecked(hits[i].hits, &prof_buffer[hits[i].pc]);
77032 hits[i].hits = hits[i].pc = 0;
77033 }
77034 }
77035 @@ -321,9 +321,9 @@ static void do_profile_hits(int type, void *__pc, unsigned int nr_hits)
77036 * Add the current hit(s) and flush the write-queue out
77037 * to the global buffer:
77038 */
77039 - atomic_add(nr_hits, &prof_buffer[pc]);
77040 + atomic_add_unchecked(nr_hits, &prof_buffer[pc]);
77041 for (i = 0; i < NR_PROFILE_HIT; ++i) {
77042 - atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
77043 + atomic_add_unchecked(hits[i].hits, &prof_buffer[hits[i].pc]);
77044 hits[i].pc = hits[i].hits = 0;
77045 }
77046 out:
77047 @@ -398,7 +398,7 @@ static void do_profile_hits(int type, void *__pc, unsigned int nr_hits)
77048 {
77049 unsigned long pc;
77050 pc = ((unsigned long)__pc - (unsigned long)_stext) >> prof_shift;
77051 - atomic_add(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
77052 + atomic_add_unchecked(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
77053 }
77054 #endif /* !CONFIG_SMP */
77055
77056 @@ -494,7 +494,7 @@ read_profile(struct file *file, char __user *buf, size_t count, loff_t *ppos)
77057 return -EFAULT;
77058 buf++; p++; count--; read++;
77059 }
77060 - pnt = (char *)prof_buffer + p - sizeof(atomic_t);
77061 + pnt = (char *)prof_buffer + p - sizeof(atomic_unchecked_t);
77062 if (copy_to_user(buf, (void *)pnt, count))
77063 return -EFAULT;
77064 read += count;
77065 @@ -525,7 +525,7 @@ static ssize_t write_profile(struct file *file, const char __user *buf,
77066 }
77067 #endif
77068 profile_discard_flip_buffers();
77069 - memset(prof_buffer, 0, prof_len * sizeof(atomic_t));
77070 + memset(prof_buffer, 0, prof_len * sizeof(atomic_unchecked_t));
77071 return count;
77072 }
77073
77074 diff --git a/kernel/ptrace.c b/kernel/ptrace.c
77075 index acbd284..00bb0c9 100644
77076 --- a/kernel/ptrace.c
77077 +++ b/kernel/ptrace.c
77078 @@ -324,7 +324,7 @@ static int ptrace_attach(struct task_struct *task, long request,
77079 if (seize)
77080 flags |= PT_SEIZED;
77081 rcu_read_lock();
77082 - if (ns_capable(__task_cred(task)->user_ns, CAP_SYS_PTRACE))
77083 + if (ns_capable_nolog(__task_cred(task)->user_ns, CAP_SYS_PTRACE))
77084 flags |= PT_PTRACE_CAP;
77085 rcu_read_unlock();
77086 task->ptrace = flags;
77087 @@ -535,7 +535,7 @@ int ptrace_readdata(struct task_struct *tsk, unsigned long src, char __user *dst
77088 break;
77089 return -EIO;
77090 }
77091 - if (copy_to_user(dst, buf, retval))
77092 + if (retval > sizeof(buf) || copy_to_user(dst, buf, retval))
77093 return -EFAULT;
77094 copied += retval;
77095 src += retval;
77096 @@ -726,7 +726,7 @@ int ptrace_request(struct task_struct *child, long request,
77097 bool seized = child->ptrace & PT_SEIZED;
77098 int ret = -EIO;
77099 siginfo_t siginfo, *si;
77100 - void __user *datavp = (void __user *) data;
77101 + void __user *datavp = (__force void __user *) data;
77102 unsigned long __user *datalp = datavp;
77103 unsigned long flags;
77104
77105 @@ -928,14 +928,21 @@ SYSCALL_DEFINE4(ptrace, long, request, long, pid, unsigned long, addr,
77106 goto out;
77107 }
77108
77109 + if (gr_handle_ptrace(child, request)) {
77110 + ret = -EPERM;
77111 + goto out_put_task_struct;
77112 + }
77113 +
77114 if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
77115 ret = ptrace_attach(child, request, addr, data);
77116 /*
77117 * Some architectures need to do book-keeping after
77118 * a ptrace attach.
77119 */
77120 - if (!ret)
77121 + if (!ret) {
77122 arch_ptrace_attach(child);
77123 + gr_audit_ptrace(child);
77124 + }
77125 goto out_put_task_struct;
77126 }
77127
77128 @@ -963,7 +970,7 @@ int generic_ptrace_peekdata(struct task_struct *tsk, unsigned long addr,
77129 copied = access_process_vm(tsk, addr, &tmp, sizeof(tmp), 0);
77130 if (copied != sizeof(tmp))
77131 return -EIO;
77132 - return put_user(tmp, (unsigned long __user *)data);
77133 + return put_user(tmp, (__force unsigned long __user *)data);
77134 }
77135
77136 int generic_ptrace_pokedata(struct task_struct *tsk, unsigned long addr,
77137 @@ -1057,7 +1064,7 @@ int compat_ptrace_request(struct task_struct *child, compat_long_t request,
77138 }
77139
77140 asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
77141 - compat_long_t addr, compat_long_t data)
77142 + compat_ulong_t addr, compat_ulong_t data)
77143 {
77144 struct task_struct *child;
77145 long ret;
77146 @@ -1073,14 +1080,21 @@ asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
77147 goto out;
77148 }
77149
77150 + if (gr_handle_ptrace(child, request)) {
77151 + ret = -EPERM;
77152 + goto out_put_task_struct;
77153 + }
77154 +
77155 if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
77156 ret = ptrace_attach(child, request, addr, data);
77157 /*
77158 * Some architectures need to do book-keeping after
77159 * a ptrace attach.
77160 */
77161 - if (!ret)
77162 + if (!ret) {
77163 arch_ptrace_attach(child);
77164 + gr_audit_ptrace(child);
77165 + }
77166 goto out_put_task_struct;
77167 }
77168
77169 diff --git a/kernel/rcupdate.c b/kernel/rcupdate.c
77170 index 48ab703..07561d4 100644
77171 --- a/kernel/rcupdate.c
77172 +++ b/kernel/rcupdate.c
77173 @@ -439,10 +439,10 @@ int rcu_jiffies_till_stall_check(void)
77174 * for CONFIG_RCU_CPU_STALL_TIMEOUT.
77175 */
77176 if (till_stall_check < 3) {
77177 - ACCESS_ONCE(rcu_cpu_stall_timeout) = 3;
77178 + ACCESS_ONCE_RW(rcu_cpu_stall_timeout) = 3;
77179 till_stall_check = 3;
77180 } else if (till_stall_check > 300) {
77181 - ACCESS_ONCE(rcu_cpu_stall_timeout) = 300;
77182 + ACCESS_ONCE_RW(rcu_cpu_stall_timeout) = 300;
77183 till_stall_check = 300;
77184 }
77185 return till_stall_check * HZ + RCU_STALL_DELAY_DELTA;
77186 diff --git a/kernel/rcutiny.c b/kernel/rcutiny.c
77187 index a0714a5..2ab5e34 100644
77188 --- a/kernel/rcutiny.c
77189 +++ b/kernel/rcutiny.c
77190 @@ -46,7 +46,7 @@
77191 struct rcu_ctrlblk;
77192 static void invoke_rcu_callbacks(void);
77193 static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp);
77194 -static void rcu_process_callbacks(struct softirq_action *unused);
77195 +static void rcu_process_callbacks(void);
77196 static void __call_rcu(struct rcu_head *head,
77197 void (*func)(struct rcu_head *rcu),
77198 struct rcu_ctrlblk *rcp);
77199 @@ -312,7 +312,7 @@ static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp)
77200 rcu_is_callbacks_kthread()));
77201 }
77202
77203 -static void rcu_process_callbacks(struct softirq_action *unused)
77204 +static void rcu_process_callbacks(void)
77205 {
77206 __rcu_process_callbacks(&rcu_sched_ctrlblk);
77207 __rcu_process_callbacks(&rcu_bh_ctrlblk);
77208 diff --git a/kernel/rcutiny_plugin.h b/kernel/rcutiny_plugin.h
77209 index 8a23300..4255818 100644
77210 --- a/kernel/rcutiny_plugin.h
77211 +++ b/kernel/rcutiny_plugin.h
77212 @@ -945,7 +945,7 @@ static int rcu_kthread(void *arg)
77213 have_rcu_kthread_work = morework;
77214 local_irq_restore(flags);
77215 if (work)
77216 - rcu_process_callbacks(NULL);
77217 + rcu_process_callbacks();
77218 schedule_timeout_interruptible(1); /* Leave CPU for others. */
77219 }
77220
77221 diff --git a/kernel/rcutorture.c b/kernel/rcutorture.c
77222 index e1f3a8c..42c94a2 100644
77223 --- a/kernel/rcutorture.c
77224 +++ b/kernel/rcutorture.c
77225 @@ -164,12 +164,12 @@ static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1], rcu_torture_count) =
77226 { 0 };
77227 static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1], rcu_torture_batch) =
77228 { 0 };
77229 -static atomic_t rcu_torture_wcount[RCU_TORTURE_PIPE_LEN + 1];
77230 -static atomic_t n_rcu_torture_alloc;
77231 -static atomic_t n_rcu_torture_alloc_fail;
77232 -static atomic_t n_rcu_torture_free;
77233 -static atomic_t n_rcu_torture_mberror;
77234 -static atomic_t n_rcu_torture_error;
77235 +static atomic_unchecked_t rcu_torture_wcount[RCU_TORTURE_PIPE_LEN + 1];
77236 +static atomic_unchecked_t n_rcu_torture_alloc;
77237 +static atomic_unchecked_t n_rcu_torture_alloc_fail;
77238 +static atomic_unchecked_t n_rcu_torture_free;
77239 +static atomic_unchecked_t n_rcu_torture_mberror;
77240 +static atomic_unchecked_t n_rcu_torture_error;
77241 static long n_rcu_torture_barrier_error;
77242 static long n_rcu_torture_boost_ktrerror;
77243 static long n_rcu_torture_boost_rterror;
77244 @@ -287,11 +287,11 @@ rcu_torture_alloc(void)
77245
77246 spin_lock_bh(&rcu_torture_lock);
77247 if (list_empty(&rcu_torture_freelist)) {
77248 - atomic_inc(&n_rcu_torture_alloc_fail);
77249 + atomic_inc_unchecked(&n_rcu_torture_alloc_fail);
77250 spin_unlock_bh(&rcu_torture_lock);
77251 return NULL;
77252 }
77253 - atomic_inc(&n_rcu_torture_alloc);
77254 + atomic_inc_unchecked(&n_rcu_torture_alloc);
77255 p = rcu_torture_freelist.next;
77256 list_del_init(p);
77257 spin_unlock_bh(&rcu_torture_lock);
77258 @@ -304,7 +304,7 @@ rcu_torture_alloc(void)
77259 static void
77260 rcu_torture_free(struct rcu_torture *p)
77261 {
77262 - atomic_inc(&n_rcu_torture_free);
77263 + atomic_inc_unchecked(&n_rcu_torture_free);
77264 spin_lock_bh(&rcu_torture_lock);
77265 list_add_tail(&p->rtort_free, &rcu_torture_freelist);
77266 spin_unlock_bh(&rcu_torture_lock);
77267 @@ -424,7 +424,7 @@ rcu_torture_cb(struct rcu_head *p)
77268 i = rp->rtort_pipe_count;
77269 if (i > RCU_TORTURE_PIPE_LEN)
77270 i = RCU_TORTURE_PIPE_LEN;
77271 - atomic_inc(&rcu_torture_wcount[i]);
77272 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
77273 if (++rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) {
77274 rp->rtort_mbtest = 0;
77275 rcu_torture_free(rp);
77276 @@ -472,7 +472,7 @@ static void rcu_sync_torture_deferred_free(struct rcu_torture *p)
77277 i = rp->rtort_pipe_count;
77278 if (i > RCU_TORTURE_PIPE_LEN)
77279 i = RCU_TORTURE_PIPE_LEN;
77280 - atomic_inc(&rcu_torture_wcount[i]);
77281 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
77282 if (++rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) {
77283 rp->rtort_mbtest = 0;
77284 list_del(&rp->rtort_free);
77285 @@ -990,7 +990,7 @@ rcu_torture_writer(void *arg)
77286 i = old_rp->rtort_pipe_count;
77287 if (i > RCU_TORTURE_PIPE_LEN)
77288 i = RCU_TORTURE_PIPE_LEN;
77289 - atomic_inc(&rcu_torture_wcount[i]);
77290 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
77291 old_rp->rtort_pipe_count++;
77292 cur_ops->deferred_free(old_rp);
77293 }
77294 @@ -1076,7 +1076,7 @@ static void rcu_torture_timer(unsigned long unused)
77295 return;
77296 }
77297 if (p->rtort_mbtest == 0)
77298 - atomic_inc(&n_rcu_torture_mberror);
77299 + atomic_inc_unchecked(&n_rcu_torture_mberror);
77300 spin_lock(&rand_lock);
77301 cur_ops->read_delay(&rand);
77302 n_rcu_torture_timers++;
77303 @@ -1146,7 +1146,7 @@ rcu_torture_reader(void *arg)
77304 continue;
77305 }
77306 if (p->rtort_mbtest == 0)
77307 - atomic_inc(&n_rcu_torture_mberror);
77308 + atomic_inc_unchecked(&n_rcu_torture_mberror);
77309 cur_ops->read_delay(&rand);
77310 preempt_disable();
77311 pipe_count = p->rtort_pipe_count;
77312 @@ -1209,11 +1209,11 @@ rcu_torture_printk(char *page)
77313 rcu_torture_current,
77314 rcu_torture_current_version,
77315 list_empty(&rcu_torture_freelist),
77316 - atomic_read(&n_rcu_torture_alloc),
77317 - atomic_read(&n_rcu_torture_alloc_fail),
77318 - atomic_read(&n_rcu_torture_free));
77319 + atomic_read_unchecked(&n_rcu_torture_alloc),
77320 + atomic_read_unchecked(&n_rcu_torture_alloc_fail),
77321 + atomic_read_unchecked(&n_rcu_torture_free));
77322 cnt += sprintf(&page[cnt], "rtmbe: %d rtbke: %ld rtbre: %ld ",
77323 - atomic_read(&n_rcu_torture_mberror),
77324 + atomic_read_unchecked(&n_rcu_torture_mberror),
77325 n_rcu_torture_boost_ktrerror,
77326 n_rcu_torture_boost_rterror);
77327 cnt += sprintf(&page[cnt], "rtbf: %ld rtb: %ld nt: %ld ",
77328 @@ -1232,14 +1232,14 @@ rcu_torture_printk(char *page)
77329 n_barrier_attempts,
77330 n_rcu_torture_barrier_error);
77331 cnt += sprintf(&page[cnt], "\n%s%s ", torture_type, TORTURE_FLAG);
77332 - if (atomic_read(&n_rcu_torture_mberror) != 0 ||
77333 + if (atomic_read_unchecked(&n_rcu_torture_mberror) != 0 ||
77334 n_rcu_torture_barrier_error != 0 ||
77335 n_rcu_torture_boost_ktrerror != 0 ||
77336 n_rcu_torture_boost_rterror != 0 ||
77337 n_rcu_torture_boost_failure != 0 ||
77338 i > 1) {
77339 cnt += sprintf(&page[cnt], "!!! ");
77340 - atomic_inc(&n_rcu_torture_error);
77341 + atomic_inc_unchecked(&n_rcu_torture_error);
77342 WARN_ON_ONCE(1);
77343 }
77344 cnt += sprintf(&page[cnt], "Reader Pipe: ");
77345 @@ -1253,7 +1253,7 @@ rcu_torture_printk(char *page)
77346 cnt += sprintf(&page[cnt], "Free-Block Circulation: ");
77347 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
77348 cnt += sprintf(&page[cnt], " %d",
77349 - atomic_read(&rcu_torture_wcount[i]));
77350 + atomic_read_unchecked(&rcu_torture_wcount[i]));
77351 }
77352 cnt += sprintf(&page[cnt], "\n");
77353 if (cur_ops->stats)
77354 @@ -1962,7 +1962,7 @@ rcu_torture_cleanup(void)
77355
77356 rcu_torture_stats_print(); /* -After- the stats thread is stopped! */
77357
77358 - if (atomic_read(&n_rcu_torture_error) || n_rcu_torture_barrier_error)
77359 + if (atomic_read_unchecked(&n_rcu_torture_error) || n_rcu_torture_barrier_error)
77360 rcu_torture_print_module_parms(cur_ops, "End of test: FAILURE");
77361 else if (n_online_successes != n_online_attempts ||
77362 n_offline_successes != n_offline_attempts)
77363 @@ -2031,18 +2031,18 @@ rcu_torture_init(void)
77364
77365 rcu_torture_current = NULL;
77366 rcu_torture_current_version = 0;
77367 - atomic_set(&n_rcu_torture_alloc, 0);
77368 - atomic_set(&n_rcu_torture_alloc_fail, 0);
77369 - atomic_set(&n_rcu_torture_free, 0);
77370 - atomic_set(&n_rcu_torture_mberror, 0);
77371 - atomic_set(&n_rcu_torture_error, 0);
77372 + atomic_set_unchecked(&n_rcu_torture_alloc, 0);
77373 + atomic_set_unchecked(&n_rcu_torture_alloc_fail, 0);
77374 + atomic_set_unchecked(&n_rcu_torture_free, 0);
77375 + atomic_set_unchecked(&n_rcu_torture_mberror, 0);
77376 + atomic_set_unchecked(&n_rcu_torture_error, 0);
77377 n_rcu_torture_barrier_error = 0;
77378 n_rcu_torture_boost_ktrerror = 0;
77379 n_rcu_torture_boost_rterror = 0;
77380 n_rcu_torture_boost_failure = 0;
77381 n_rcu_torture_boosts = 0;
77382 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++)
77383 - atomic_set(&rcu_torture_wcount[i], 0);
77384 + atomic_set_unchecked(&rcu_torture_wcount[i], 0);
77385 for_each_possible_cpu(cpu) {
77386 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
77387 per_cpu(rcu_torture_count, cpu)[i] = 0;
77388 diff --git a/kernel/rcutree.c b/kernel/rcutree.c
77389 index 5b8ad82..17274d1 100644
77390 --- a/kernel/rcutree.c
77391 +++ b/kernel/rcutree.c
77392 @@ -353,9 +353,9 @@ static void rcu_eqs_enter_common(struct rcu_dynticks *rdtp, long long oldval,
77393 rcu_prepare_for_idle(smp_processor_id());
77394 /* CPUs seeing atomic_inc() must see prior RCU read-side crit sects */
77395 smp_mb__before_atomic_inc(); /* See above. */
77396 - atomic_inc(&rdtp->dynticks);
77397 + atomic_inc_unchecked(&rdtp->dynticks);
77398 smp_mb__after_atomic_inc(); /* Force ordering with next sojourn. */
77399 - WARN_ON_ONCE(atomic_read(&rdtp->dynticks) & 0x1);
77400 + WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks) & 0x1);
77401
77402 /*
77403 * It is illegal to enter an extended quiescent state while
77404 @@ -491,10 +491,10 @@ static void rcu_eqs_exit_common(struct rcu_dynticks *rdtp, long long oldval,
77405 int user)
77406 {
77407 smp_mb__before_atomic_inc(); /* Force ordering w/previous sojourn. */
77408 - atomic_inc(&rdtp->dynticks);
77409 + atomic_inc_unchecked(&rdtp->dynticks);
77410 /* CPUs seeing atomic_inc() must see later RCU read-side crit sects */
77411 smp_mb__after_atomic_inc(); /* See above. */
77412 - WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks) & 0x1));
77413 + WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks) & 0x1));
77414 rcu_cleanup_after_idle(smp_processor_id());
77415 trace_rcu_dyntick("End", oldval, rdtp->dynticks_nesting);
77416 if (!user && !is_idle_task(current)) {
77417 @@ -633,14 +633,14 @@ void rcu_nmi_enter(void)
77418 struct rcu_dynticks *rdtp = &__get_cpu_var(rcu_dynticks);
77419
77420 if (rdtp->dynticks_nmi_nesting == 0 &&
77421 - (atomic_read(&rdtp->dynticks) & 0x1))
77422 + (atomic_read_unchecked(&rdtp->dynticks) & 0x1))
77423 return;
77424 rdtp->dynticks_nmi_nesting++;
77425 smp_mb__before_atomic_inc(); /* Force delay from prior write. */
77426 - atomic_inc(&rdtp->dynticks);
77427 + atomic_inc_unchecked(&rdtp->dynticks);
77428 /* CPUs seeing atomic_inc() must see later RCU read-side crit sects */
77429 smp_mb__after_atomic_inc(); /* See above. */
77430 - WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks) & 0x1));
77431 + WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks) & 0x1));
77432 }
77433
77434 /**
77435 @@ -659,9 +659,9 @@ void rcu_nmi_exit(void)
77436 return;
77437 /* CPUs seeing atomic_inc() must see prior RCU read-side crit sects */
77438 smp_mb__before_atomic_inc(); /* See above. */
77439 - atomic_inc(&rdtp->dynticks);
77440 + atomic_inc_unchecked(&rdtp->dynticks);
77441 smp_mb__after_atomic_inc(); /* Force delay to next write. */
77442 - WARN_ON_ONCE(atomic_read(&rdtp->dynticks) & 0x1);
77443 + WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks) & 0x1);
77444 }
77445
77446 /**
77447 @@ -675,7 +675,7 @@ int rcu_is_cpu_idle(void)
77448 int ret;
77449
77450 preempt_disable();
77451 - ret = (atomic_read(&__get_cpu_var(rcu_dynticks).dynticks) & 0x1) == 0;
77452 + ret = (atomic_read_unchecked(&__get_cpu_var(rcu_dynticks).dynticks) & 0x1) == 0;
77453 preempt_enable();
77454 return ret;
77455 }
77456 @@ -743,7 +743,7 @@ static int rcu_is_cpu_rrupt_from_idle(void)
77457 */
77458 static int dyntick_save_progress_counter(struct rcu_data *rdp)
77459 {
77460 - rdp->dynticks_snap = atomic_add_return(0, &rdp->dynticks->dynticks);
77461 + rdp->dynticks_snap = atomic_add_return_unchecked(0, &rdp->dynticks->dynticks);
77462 return (rdp->dynticks_snap & 0x1) == 0;
77463 }
77464
77465 @@ -758,7 +758,7 @@ static int rcu_implicit_dynticks_qs(struct rcu_data *rdp)
77466 unsigned int curr;
77467 unsigned int snap;
77468
77469 - curr = (unsigned int)atomic_add_return(0, &rdp->dynticks->dynticks);
77470 + curr = (unsigned int)atomic_add_return_unchecked(0, &rdp->dynticks->dynticks);
77471 snap = (unsigned int)rdp->dynticks_snap;
77472
77473 /*
77474 @@ -1698,7 +1698,7 @@ rcu_send_cbs_to_orphanage(int cpu, struct rcu_state *rsp,
77475 rsp->qlen += rdp->qlen;
77476 rdp->n_cbs_orphaned += rdp->qlen;
77477 rdp->qlen_lazy = 0;
77478 - ACCESS_ONCE(rdp->qlen) = 0;
77479 + ACCESS_ONCE_RW(rdp->qlen) = 0;
77480 }
77481
77482 /*
77483 @@ -1944,7 +1944,7 @@ static void rcu_do_batch(struct rcu_state *rsp, struct rcu_data *rdp)
77484 }
77485 smp_mb(); /* List handling before counting for rcu_barrier(). */
77486 rdp->qlen_lazy -= count_lazy;
77487 - ACCESS_ONCE(rdp->qlen) -= count;
77488 + ACCESS_ONCE_RW(rdp->qlen) -= count;
77489 rdp->n_cbs_invoked += count;
77490
77491 /* Reinstate batch limit if we have worked down the excess. */
77492 @@ -2137,7 +2137,7 @@ __rcu_process_callbacks(struct rcu_state *rsp)
77493 /*
77494 * Do RCU core processing for the current CPU.
77495 */
77496 -static void rcu_process_callbacks(struct softirq_action *unused)
77497 +static void rcu_process_callbacks(void)
77498 {
77499 struct rcu_state *rsp;
77500
77501 @@ -2260,7 +2260,7 @@ __call_rcu(struct rcu_head *head, void (*func)(struct rcu_head *rcu),
77502 local_irq_restore(flags);
77503 return;
77504 }
77505 - ACCESS_ONCE(rdp->qlen)++;
77506 + ACCESS_ONCE_RW(rdp->qlen)++;
77507 if (lazy)
77508 rdp->qlen_lazy++;
77509 else
77510 @@ -2469,11 +2469,11 @@ void synchronize_sched_expedited(void)
77511 * counter wrap on a 32-bit system. Quite a few more CPUs would of
77512 * course be required on a 64-bit system.
77513 */
77514 - if (ULONG_CMP_GE((ulong)atomic_long_read(&rsp->expedited_start),
77515 + if (ULONG_CMP_GE((ulong)atomic_long_read_unchecked(&rsp->expedited_start),
77516 (ulong)atomic_long_read(&rsp->expedited_done) +
77517 ULONG_MAX / 8)) {
77518 synchronize_sched();
77519 - atomic_long_inc(&rsp->expedited_wrap);
77520 + atomic_long_inc_unchecked(&rsp->expedited_wrap);
77521 return;
77522 }
77523
77524 @@ -2481,7 +2481,7 @@ void synchronize_sched_expedited(void)
77525 * Take a ticket. Note that atomic_inc_return() implies a
77526 * full memory barrier.
77527 */
77528 - snap = atomic_long_inc_return(&rsp->expedited_start);
77529 + snap = atomic_long_inc_return_unchecked(&rsp->expedited_start);
77530 firstsnap = snap;
77531 get_online_cpus();
77532 WARN_ON_ONCE(cpu_is_offline(raw_smp_processor_id()));
77533 @@ -2494,14 +2494,14 @@ void synchronize_sched_expedited(void)
77534 synchronize_sched_expedited_cpu_stop,
77535 NULL) == -EAGAIN) {
77536 put_online_cpus();
77537 - atomic_long_inc(&rsp->expedited_tryfail);
77538 + atomic_long_inc_unchecked(&rsp->expedited_tryfail);
77539
77540 /* Check to see if someone else did our work for us. */
77541 s = atomic_long_read(&rsp->expedited_done);
77542 if (ULONG_CMP_GE((ulong)s, (ulong)firstsnap)) {
77543 /* ensure test happens before caller kfree */
77544 smp_mb__before_atomic_inc(); /* ^^^ */
77545 - atomic_long_inc(&rsp->expedited_workdone1);
77546 + atomic_long_inc_unchecked(&rsp->expedited_workdone1);
77547 return;
77548 }
77549
77550 @@ -2510,7 +2510,7 @@ void synchronize_sched_expedited(void)
77551 udelay(trycount * num_online_cpus());
77552 } else {
77553 wait_rcu_gp(call_rcu_sched);
77554 - atomic_long_inc(&rsp->expedited_normal);
77555 + atomic_long_inc_unchecked(&rsp->expedited_normal);
77556 return;
77557 }
77558
77559 @@ -2519,7 +2519,7 @@ void synchronize_sched_expedited(void)
77560 if (ULONG_CMP_GE((ulong)s, (ulong)firstsnap)) {
77561 /* ensure test happens before caller kfree */
77562 smp_mb__before_atomic_inc(); /* ^^^ */
77563 - atomic_long_inc(&rsp->expedited_workdone2);
77564 + atomic_long_inc_unchecked(&rsp->expedited_workdone2);
77565 return;
77566 }
77567
77568 @@ -2531,10 +2531,10 @@ void synchronize_sched_expedited(void)
77569 * period works for us.
77570 */
77571 get_online_cpus();
77572 - snap = atomic_long_read(&rsp->expedited_start);
77573 + snap = atomic_long_read_unchecked(&rsp->expedited_start);
77574 smp_mb(); /* ensure read is before try_stop_cpus(). */
77575 }
77576 - atomic_long_inc(&rsp->expedited_stoppedcpus);
77577 + atomic_long_inc_unchecked(&rsp->expedited_stoppedcpus);
77578
77579 /*
77580 * Everyone up to our most recent fetch is covered by our grace
77581 @@ -2543,16 +2543,16 @@ void synchronize_sched_expedited(void)
77582 * than we did already did their update.
77583 */
77584 do {
77585 - atomic_long_inc(&rsp->expedited_done_tries);
77586 + atomic_long_inc_unchecked(&rsp->expedited_done_tries);
77587 s = atomic_long_read(&rsp->expedited_done);
77588 if (ULONG_CMP_GE((ulong)s, (ulong)snap)) {
77589 /* ensure test happens before caller kfree */
77590 smp_mb__before_atomic_inc(); /* ^^^ */
77591 - atomic_long_inc(&rsp->expedited_done_lost);
77592 + atomic_long_inc_unchecked(&rsp->expedited_done_lost);
77593 break;
77594 }
77595 } while (atomic_long_cmpxchg(&rsp->expedited_done, s, snap) != s);
77596 - atomic_long_inc(&rsp->expedited_done_exit);
77597 + atomic_long_inc_unchecked(&rsp->expedited_done_exit);
77598
77599 put_online_cpus();
77600 }
77601 @@ -2726,7 +2726,7 @@ static void _rcu_barrier(struct rcu_state *rsp)
77602 * ACCESS_ONCE() to prevent the compiler from speculating
77603 * the increment to precede the early-exit check.
77604 */
77605 - ACCESS_ONCE(rsp->n_barrier_done)++;
77606 + ACCESS_ONCE_RW(rsp->n_barrier_done)++;
77607 WARN_ON_ONCE((rsp->n_barrier_done & 0x1) != 1);
77608 _rcu_barrier_trace(rsp, "Inc1", -1, rsp->n_barrier_done);
77609 smp_mb(); /* Order ->n_barrier_done increment with below mechanism. */
77610 @@ -2776,7 +2776,7 @@ static void _rcu_barrier(struct rcu_state *rsp)
77611
77612 /* Increment ->n_barrier_done to prevent duplicate work. */
77613 smp_mb(); /* Keep increment after above mechanism. */
77614 - ACCESS_ONCE(rsp->n_barrier_done)++;
77615 + ACCESS_ONCE_RW(rsp->n_barrier_done)++;
77616 WARN_ON_ONCE((rsp->n_barrier_done & 0x1) != 0);
77617 _rcu_barrier_trace(rsp, "Inc2", -1, rsp->n_barrier_done);
77618 smp_mb(); /* Keep increment before caller's subsequent code. */
77619 @@ -2821,10 +2821,10 @@ rcu_boot_init_percpu_data(int cpu, struct rcu_state *rsp)
77620 rdp->grpmask = 1UL << (cpu - rdp->mynode->grplo);
77621 init_callback_list(rdp);
77622 rdp->qlen_lazy = 0;
77623 - ACCESS_ONCE(rdp->qlen) = 0;
77624 + ACCESS_ONCE_RW(rdp->qlen) = 0;
77625 rdp->dynticks = &per_cpu(rcu_dynticks, cpu);
77626 WARN_ON_ONCE(rdp->dynticks->dynticks_nesting != DYNTICK_TASK_EXIT_IDLE);
77627 - WARN_ON_ONCE(atomic_read(&rdp->dynticks->dynticks) != 1);
77628 + WARN_ON_ONCE(atomic_read_unchecked(&rdp->dynticks->dynticks) != 1);
77629 rdp->cpu = cpu;
77630 rdp->rsp = rsp;
77631 rcu_boot_init_nocb_percpu_data(rdp);
77632 @@ -2857,8 +2857,8 @@ rcu_init_percpu_data(int cpu, struct rcu_state *rsp, int preemptible)
77633 rdp->blimit = blimit;
77634 init_callback_list(rdp); /* Re-enable callbacks on this CPU. */
77635 rdp->dynticks->dynticks_nesting = DYNTICK_TASK_EXIT_IDLE;
77636 - atomic_set(&rdp->dynticks->dynticks,
77637 - (atomic_read(&rdp->dynticks->dynticks) & ~0x1) + 1);
77638 + atomic_set_unchecked(&rdp->dynticks->dynticks,
77639 + (atomic_read_unchecked(&rdp->dynticks->dynticks) & ~0x1) + 1);
77640 rcu_prepare_for_idle_init(cpu);
77641 raw_spin_unlock(&rnp->lock); /* irqs remain disabled. */
77642
77643 diff --git a/kernel/rcutree.h b/kernel/rcutree.h
77644 index c896b50..c357252 100644
77645 --- a/kernel/rcutree.h
77646 +++ b/kernel/rcutree.h
77647 @@ -86,7 +86,7 @@ struct rcu_dynticks {
77648 long long dynticks_nesting; /* Track irq/process nesting level. */
77649 /* Process level is worth LLONG_MAX/2. */
77650 int dynticks_nmi_nesting; /* Track NMI nesting level. */
77651 - atomic_t dynticks; /* Even value for idle, else odd. */
77652 + atomic_unchecked_t dynticks;/* Even value for idle, else odd. */
77653 #ifdef CONFIG_RCU_FAST_NO_HZ
77654 int dyntick_drain; /* Prepare-for-idle state variable. */
77655 unsigned long dyntick_holdoff;
77656 @@ -416,17 +416,17 @@ struct rcu_state {
77657 /* _rcu_barrier(). */
77658 /* End of fields guarded by barrier_mutex. */
77659
77660 - atomic_long_t expedited_start; /* Starting ticket. */
77661 - atomic_long_t expedited_done; /* Done ticket. */
77662 - atomic_long_t expedited_wrap; /* # near-wrap incidents. */
77663 - atomic_long_t expedited_tryfail; /* # acquisition failures. */
77664 - atomic_long_t expedited_workdone1; /* # done by others #1. */
77665 - atomic_long_t expedited_workdone2; /* # done by others #2. */
77666 - atomic_long_t expedited_normal; /* # fallbacks to normal. */
77667 - atomic_long_t expedited_stoppedcpus; /* # successful stop_cpus. */
77668 - atomic_long_t expedited_done_tries; /* # tries to update _done. */
77669 - atomic_long_t expedited_done_lost; /* # times beaten to _done. */
77670 - atomic_long_t expedited_done_exit; /* # times exited _done loop. */
77671 + atomic_long_unchecked_t expedited_start; /* Starting ticket. */
77672 + atomic_long_t expedited_done; /* Done ticket. */
77673 + atomic_long_unchecked_t expedited_wrap; /* # near-wrap incidents. */
77674 + atomic_long_unchecked_t expedited_tryfail; /* # acquisition failures. */
77675 + atomic_long_unchecked_t expedited_workdone1; /* # done by others #1. */
77676 + atomic_long_unchecked_t expedited_workdone2; /* # done by others #2. */
77677 + atomic_long_unchecked_t expedited_normal; /* # fallbacks to normal. */
77678 + atomic_long_unchecked_t expedited_stoppedcpus; /* # successful stop_cpus. */
77679 + atomic_long_unchecked_t expedited_done_tries; /* # tries to update _done. */
77680 + atomic_long_unchecked_t expedited_done_lost; /* # times beaten to _done. */
77681 + atomic_long_unchecked_t expedited_done_exit; /* # times exited _done loop. */
77682
77683 unsigned long jiffies_force_qs; /* Time at which to invoke */
77684 /* force_quiescent_state(). */
77685 diff --git a/kernel/rcutree_plugin.h b/kernel/rcutree_plugin.h
77686 index c1cc7e1..f62e436 100644
77687 --- a/kernel/rcutree_plugin.h
77688 +++ b/kernel/rcutree_plugin.h
77689 @@ -892,7 +892,7 @@ void synchronize_rcu_expedited(void)
77690
77691 /* Clean up and exit. */
77692 smp_mb(); /* ensure expedited GP seen before counter increment. */
77693 - ACCESS_ONCE(sync_rcu_preempt_exp_count)++;
77694 + ACCESS_ONCE_RW(sync_rcu_preempt_exp_count)++;
77695 unlock_mb_ret:
77696 mutex_unlock(&sync_rcu_preempt_exp_mutex);
77697 mb_ret:
77698 @@ -1440,7 +1440,7 @@ static void rcu_boost_kthread_setaffinity(struct rcu_node *rnp, int outgoingcpu)
77699 free_cpumask_var(cm);
77700 }
77701
77702 -static struct smp_hotplug_thread rcu_cpu_thread_spec = {
77703 +static struct smp_hotplug_thread rcu_cpu_thread_spec __read_only = {
77704 .store = &rcu_cpu_kthread_task,
77705 .thread_should_run = rcu_cpu_kthread_should_run,
77706 .thread_fn = rcu_cpu_kthread,
77707 @@ -2072,7 +2072,7 @@ static void print_cpu_stall_info(struct rcu_state *rsp, int cpu)
77708 print_cpu_stall_fast_no_hz(fast_no_hz, cpu);
77709 printk(KERN_ERR "\t%d: (%lu %s) idle=%03x/%llx/%d %s\n",
77710 cpu, ticks_value, ticks_title,
77711 - atomic_read(&rdtp->dynticks) & 0xfff,
77712 + atomic_read_unchecked(&rdtp->dynticks) & 0xfff,
77713 rdtp->dynticks_nesting, rdtp->dynticks_nmi_nesting,
77714 fast_no_hz);
77715 }
77716 @@ -2192,7 +2192,7 @@ static void __call_rcu_nocb_enqueue(struct rcu_data *rdp,
77717
77718 /* Enqueue the callback on the nocb list and update counts. */
77719 old_rhpp = xchg(&rdp->nocb_tail, rhtp);
77720 - ACCESS_ONCE(*old_rhpp) = rhp;
77721 + ACCESS_ONCE_RW(*old_rhpp) = rhp;
77722 atomic_long_add(rhcount, &rdp->nocb_q_count);
77723 atomic_long_add(rhcount_lazy, &rdp->nocb_q_count_lazy);
77724
77725 @@ -2384,12 +2384,12 @@ static int rcu_nocb_kthread(void *arg)
77726 * Extract queued callbacks, update counts, and wait
77727 * for a grace period to elapse.
77728 */
77729 - ACCESS_ONCE(rdp->nocb_head) = NULL;
77730 + ACCESS_ONCE_RW(rdp->nocb_head) = NULL;
77731 tail = xchg(&rdp->nocb_tail, &rdp->nocb_head);
77732 c = atomic_long_xchg(&rdp->nocb_q_count, 0);
77733 cl = atomic_long_xchg(&rdp->nocb_q_count_lazy, 0);
77734 - ACCESS_ONCE(rdp->nocb_p_count) += c;
77735 - ACCESS_ONCE(rdp->nocb_p_count_lazy) += cl;
77736 + ACCESS_ONCE_RW(rdp->nocb_p_count) += c;
77737 + ACCESS_ONCE_RW(rdp->nocb_p_count_lazy) += cl;
77738 wait_rcu_gp(rdp->rsp->call_remote);
77739
77740 /* Each pass through the following loop invokes a callback. */
77741 @@ -2411,8 +2411,8 @@ static int rcu_nocb_kthread(void *arg)
77742 list = next;
77743 }
77744 trace_rcu_batch_end(rdp->rsp->name, c, !!list, 0, 0, 1);
77745 - ACCESS_ONCE(rdp->nocb_p_count) -= c;
77746 - ACCESS_ONCE(rdp->nocb_p_count_lazy) -= cl;
77747 + ACCESS_ONCE_RW(rdp->nocb_p_count) -= c;
77748 + ACCESS_ONCE_RW(rdp->nocb_p_count_lazy) -= cl;
77749 rdp->n_nocbs_invoked += c;
77750 }
77751 return 0;
77752 @@ -2438,7 +2438,7 @@ static void __init rcu_spawn_nocb_kthreads(struct rcu_state *rsp)
77753 rdp = per_cpu_ptr(rsp->rda, cpu);
77754 t = kthread_run(rcu_nocb_kthread, rdp, "rcuo%d", cpu);
77755 BUG_ON(IS_ERR(t));
77756 - ACCESS_ONCE(rdp->nocb_kthread) = t;
77757 + ACCESS_ONCE_RW(rdp->nocb_kthread) = t;
77758 }
77759 }
77760
77761 diff --git a/kernel/rcutree_trace.c b/kernel/rcutree_trace.c
77762 index 93f8e8f..cf812ae 100644
77763 --- a/kernel/rcutree_trace.c
77764 +++ b/kernel/rcutree_trace.c
77765 @@ -123,7 +123,7 @@ static void print_one_rcu_data(struct seq_file *m, struct rcu_data *rdp)
77766 ulong2long(rdp->completed), ulong2long(rdp->gpnum),
77767 rdp->passed_quiesce, rdp->qs_pending);
77768 seq_printf(m, " dt=%d/%llx/%d df=%lu",
77769 - atomic_read(&rdp->dynticks->dynticks),
77770 + atomic_read_unchecked(&rdp->dynticks->dynticks),
77771 rdp->dynticks->dynticks_nesting,
77772 rdp->dynticks->dynticks_nmi_nesting,
77773 rdp->dynticks_fqs);
77774 @@ -184,17 +184,17 @@ static int show_rcuexp(struct seq_file *m, void *v)
77775 struct rcu_state *rsp = (struct rcu_state *)m->private;
77776
77777 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",
77778 - atomic_long_read(&rsp->expedited_start),
77779 + atomic_long_read_unchecked(&rsp->expedited_start),
77780 atomic_long_read(&rsp->expedited_done),
77781 - atomic_long_read(&rsp->expedited_wrap),
77782 - atomic_long_read(&rsp->expedited_tryfail),
77783 - atomic_long_read(&rsp->expedited_workdone1),
77784 - atomic_long_read(&rsp->expedited_workdone2),
77785 - atomic_long_read(&rsp->expedited_normal),
77786 - atomic_long_read(&rsp->expedited_stoppedcpus),
77787 - atomic_long_read(&rsp->expedited_done_tries),
77788 - atomic_long_read(&rsp->expedited_done_lost),
77789 - atomic_long_read(&rsp->expedited_done_exit));
77790 + atomic_long_read_unchecked(&rsp->expedited_wrap),
77791 + atomic_long_read_unchecked(&rsp->expedited_tryfail),
77792 + atomic_long_read_unchecked(&rsp->expedited_workdone1),
77793 + atomic_long_read_unchecked(&rsp->expedited_workdone2),
77794 + atomic_long_read_unchecked(&rsp->expedited_normal),
77795 + atomic_long_read_unchecked(&rsp->expedited_stoppedcpus),
77796 + atomic_long_read_unchecked(&rsp->expedited_done_tries),
77797 + atomic_long_read_unchecked(&rsp->expedited_done_lost),
77798 + atomic_long_read_unchecked(&rsp->expedited_done_exit));
77799 return 0;
77800 }
77801
77802 diff --git a/kernel/resource.c b/kernel/resource.c
77803 index 73f35d4..4684fc4 100644
77804 --- a/kernel/resource.c
77805 +++ b/kernel/resource.c
77806 @@ -143,8 +143,18 @@ static const struct file_operations proc_iomem_operations = {
77807
77808 static int __init ioresources_init(void)
77809 {
77810 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
77811 +#ifdef CONFIG_GRKERNSEC_PROC_USER
77812 + proc_create("ioports", S_IRUSR, NULL, &proc_ioports_operations);
77813 + proc_create("iomem", S_IRUSR, NULL, &proc_iomem_operations);
77814 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
77815 + proc_create("ioports", S_IRUSR | S_IRGRP, NULL, &proc_ioports_operations);
77816 + proc_create("iomem", S_IRUSR | S_IRGRP, NULL, &proc_iomem_operations);
77817 +#endif
77818 +#else
77819 proc_create("ioports", 0, NULL, &proc_ioports_operations);
77820 proc_create("iomem", 0, NULL, &proc_iomem_operations);
77821 +#endif
77822 return 0;
77823 }
77824 __initcall(ioresources_init);
77825 diff --git a/kernel/rtmutex-tester.c b/kernel/rtmutex-tester.c
77826 index 7890b10..8b68605f 100644
77827 --- a/kernel/rtmutex-tester.c
77828 +++ b/kernel/rtmutex-tester.c
77829 @@ -21,7 +21,7 @@
77830 #define MAX_RT_TEST_MUTEXES 8
77831
77832 static spinlock_t rttest_lock;
77833 -static atomic_t rttest_event;
77834 +static atomic_unchecked_t rttest_event;
77835
77836 struct test_thread_data {
77837 int opcode;
77838 @@ -62,7 +62,7 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
77839
77840 case RTTEST_LOCKCONT:
77841 td->mutexes[td->opdata] = 1;
77842 - td->event = atomic_add_return(1, &rttest_event);
77843 + td->event = atomic_add_return_unchecked(1, &rttest_event);
77844 return 0;
77845
77846 case RTTEST_RESET:
77847 @@ -75,7 +75,7 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
77848 return 0;
77849
77850 case RTTEST_RESETEVENT:
77851 - atomic_set(&rttest_event, 0);
77852 + atomic_set_unchecked(&rttest_event, 0);
77853 return 0;
77854
77855 default:
77856 @@ -92,9 +92,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
77857 return ret;
77858
77859 td->mutexes[id] = 1;
77860 - td->event = atomic_add_return(1, &rttest_event);
77861 + td->event = atomic_add_return_unchecked(1, &rttest_event);
77862 rt_mutex_lock(&mutexes[id]);
77863 - td->event = atomic_add_return(1, &rttest_event);
77864 + td->event = atomic_add_return_unchecked(1, &rttest_event);
77865 td->mutexes[id] = 4;
77866 return 0;
77867
77868 @@ -105,9 +105,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
77869 return ret;
77870
77871 td->mutexes[id] = 1;
77872 - td->event = atomic_add_return(1, &rttest_event);
77873 + td->event = atomic_add_return_unchecked(1, &rttest_event);
77874 ret = rt_mutex_lock_interruptible(&mutexes[id], 0);
77875 - td->event = atomic_add_return(1, &rttest_event);
77876 + td->event = atomic_add_return_unchecked(1, &rttest_event);
77877 td->mutexes[id] = ret ? 0 : 4;
77878 return ret ? -EINTR : 0;
77879
77880 @@ -116,9 +116,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
77881 if (id < 0 || id >= MAX_RT_TEST_MUTEXES || td->mutexes[id] != 4)
77882 return ret;
77883
77884 - td->event = atomic_add_return(1, &rttest_event);
77885 + td->event = atomic_add_return_unchecked(1, &rttest_event);
77886 rt_mutex_unlock(&mutexes[id]);
77887 - td->event = atomic_add_return(1, &rttest_event);
77888 + td->event = atomic_add_return_unchecked(1, &rttest_event);
77889 td->mutexes[id] = 0;
77890 return 0;
77891
77892 @@ -165,7 +165,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
77893 break;
77894
77895 td->mutexes[dat] = 2;
77896 - td->event = atomic_add_return(1, &rttest_event);
77897 + td->event = atomic_add_return_unchecked(1, &rttest_event);
77898 break;
77899
77900 default:
77901 @@ -185,7 +185,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
77902 return;
77903
77904 td->mutexes[dat] = 3;
77905 - td->event = atomic_add_return(1, &rttest_event);
77906 + td->event = atomic_add_return_unchecked(1, &rttest_event);
77907 break;
77908
77909 case RTTEST_LOCKNOWAIT:
77910 @@ -197,7 +197,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
77911 return;
77912
77913 td->mutexes[dat] = 1;
77914 - td->event = atomic_add_return(1, &rttest_event);
77915 + td->event = atomic_add_return_unchecked(1, &rttest_event);
77916 return;
77917
77918 default:
77919 diff --git a/kernel/sched/auto_group.c b/kernel/sched/auto_group.c
77920 index 64de5f8..7735e12 100644
77921 --- a/kernel/sched/auto_group.c
77922 +++ b/kernel/sched/auto_group.c
77923 @@ -11,7 +11,7 @@
77924
77925 unsigned int __read_mostly sysctl_sched_autogroup_enabled = 1;
77926 static struct autogroup autogroup_default;
77927 -static atomic_t autogroup_seq_nr;
77928 +static atomic_unchecked_t autogroup_seq_nr;
77929
77930 void __init autogroup_init(struct task_struct *init_task)
77931 {
77932 @@ -81,7 +81,7 @@ static inline struct autogroup *autogroup_create(void)
77933
77934 kref_init(&ag->kref);
77935 init_rwsem(&ag->lock);
77936 - ag->id = atomic_inc_return(&autogroup_seq_nr);
77937 + ag->id = atomic_inc_return_unchecked(&autogroup_seq_nr);
77938 ag->tg = tg;
77939 #ifdef CONFIG_RT_GROUP_SCHED
77940 /*
77941 diff --git a/kernel/sched/core.c b/kernel/sched/core.c
77942 index 67d0465..4cf9361 100644
77943 --- a/kernel/sched/core.c
77944 +++ b/kernel/sched/core.c
77945 @@ -3406,7 +3406,7 @@ EXPORT_SYMBOL(wait_for_completion_interruptible);
77946 * The return value is -ERESTARTSYS if interrupted, 0 if timed out,
77947 * positive (at least 1, or number of jiffies left till timeout) if completed.
77948 */
77949 -long __sched
77950 +long __sched __intentional_overflow(-1)
77951 wait_for_completion_interruptible_timeout(struct completion *x,
77952 unsigned long timeout)
77953 {
77954 @@ -3423,7 +3423,7 @@ EXPORT_SYMBOL(wait_for_completion_interruptible_timeout);
77955 *
77956 * The return value is -ERESTARTSYS if interrupted, 0 if completed.
77957 */
77958 -int __sched wait_for_completion_killable(struct completion *x)
77959 +int __sched __intentional_overflow(-1) wait_for_completion_killable(struct completion *x)
77960 {
77961 long t = wait_for_common(x, MAX_SCHEDULE_TIMEOUT, TASK_KILLABLE);
77962 if (t == -ERESTARTSYS)
77963 @@ -3444,7 +3444,7 @@ EXPORT_SYMBOL(wait_for_completion_killable);
77964 * The return value is -ERESTARTSYS if interrupted, 0 if timed out,
77965 * positive (at least 1, or number of jiffies left till timeout) if completed.
77966 */
77967 -long __sched
77968 +long __sched __intentional_overflow(-1)
77969 wait_for_completion_killable_timeout(struct completion *x,
77970 unsigned long timeout)
77971 {
77972 @@ -3670,6 +3670,8 @@ int can_nice(const struct task_struct *p, const int nice)
77973 /* convert nice value [19,-20] to rlimit style value [1,40] */
77974 int nice_rlim = 20 - nice;
77975
77976 + gr_learn_resource(p, RLIMIT_NICE, nice_rlim, 1);
77977 +
77978 return (nice_rlim <= task_rlimit(p, RLIMIT_NICE) ||
77979 capable(CAP_SYS_NICE));
77980 }
77981 @@ -3703,7 +3705,8 @@ SYSCALL_DEFINE1(nice, int, increment)
77982 if (nice > 19)
77983 nice = 19;
77984
77985 - if (increment < 0 && !can_nice(current, nice))
77986 + if (increment < 0 && (!can_nice(current, nice) ||
77987 + gr_handle_chroot_nice()))
77988 return -EPERM;
77989
77990 retval = security_task_setnice(current, nice);
77991 @@ -3857,6 +3860,7 @@ recheck:
77992 unsigned long rlim_rtprio =
77993 task_rlimit(p, RLIMIT_RTPRIO);
77994
77995 + gr_learn_resource(p, RLIMIT_RTPRIO, param->sched_priority, 1);
77996 /* can't set/change the rt policy */
77997 if (policy != p->policy && !rlim_rtprio)
77998 return -EPERM;
77999 @@ -4954,7 +4958,7 @@ static void migrate_tasks(unsigned int dead_cpu)
78000
78001 #if defined(CONFIG_SCHED_DEBUG) && defined(CONFIG_SYSCTL)
78002
78003 -static struct ctl_table sd_ctl_dir[] = {
78004 +static ctl_table_no_const sd_ctl_dir[] __read_only = {
78005 {
78006 .procname = "sched_domain",
78007 .mode = 0555,
78008 @@ -4971,17 +4975,17 @@ static struct ctl_table sd_ctl_root[] = {
78009 {}
78010 };
78011
78012 -static struct ctl_table *sd_alloc_ctl_entry(int n)
78013 +static ctl_table_no_const *sd_alloc_ctl_entry(int n)
78014 {
78015 - struct ctl_table *entry =
78016 + ctl_table_no_const *entry =
78017 kcalloc(n, sizeof(struct ctl_table), GFP_KERNEL);
78018
78019 return entry;
78020 }
78021
78022 -static void sd_free_ctl_entry(struct ctl_table **tablep)
78023 +static void sd_free_ctl_entry(ctl_table_no_const *tablep)
78024 {
78025 - struct ctl_table *entry;
78026 + ctl_table_no_const *entry;
78027
78028 /*
78029 * In the intermediate directories, both the child directory and
78030 @@ -4989,22 +4993,25 @@ static void sd_free_ctl_entry(struct ctl_table **tablep)
78031 * will always be set. In the lowest directory the names are
78032 * static strings and all have proc handlers.
78033 */
78034 - for (entry = *tablep; entry->mode; entry++) {
78035 - if (entry->child)
78036 - sd_free_ctl_entry(&entry->child);
78037 + for (entry = tablep; entry->mode; entry++) {
78038 + if (entry->child) {
78039 + sd_free_ctl_entry(entry->child);
78040 + pax_open_kernel();
78041 + entry->child = NULL;
78042 + pax_close_kernel();
78043 + }
78044 if (entry->proc_handler == NULL)
78045 kfree(entry->procname);
78046 }
78047
78048 - kfree(*tablep);
78049 - *tablep = NULL;
78050 + kfree(tablep);
78051 }
78052
78053 static int min_load_idx = 0;
78054 static int max_load_idx = CPU_LOAD_IDX_MAX-1;
78055
78056 static void
78057 -set_table_entry(struct ctl_table *entry,
78058 +set_table_entry(ctl_table_no_const *entry,
78059 const char *procname, void *data, int maxlen,
78060 umode_t mode, proc_handler *proc_handler,
78061 bool load_idx)
78062 @@ -5024,7 +5031,7 @@ set_table_entry(struct ctl_table *entry,
78063 static struct ctl_table *
78064 sd_alloc_ctl_domain_table(struct sched_domain *sd)
78065 {
78066 - struct ctl_table *table = sd_alloc_ctl_entry(13);
78067 + ctl_table_no_const *table = sd_alloc_ctl_entry(13);
78068
78069 if (table == NULL)
78070 return NULL;
78071 @@ -5059,9 +5066,9 @@ sd_alloc_ctl_domain_table(struct sched_domain *sd)
78072 return table;
78073 }
78074
78075 -static ctl_table *sd_alloc_ctl_cpu_table(int cpu)
78076 +static ctl_table_no_const *sd_alloc_ctl_cpu_table(int cpu)
78077 {
78078 - struct ctl_table *entry, *table;
78079 + ctl_table_no_const *entry, *table;
78080 struct sched_domain *sd;
78081 int domain_num = 0, i;
78082 char buf[32];
78083 @@ -5088,11 +5095,13 @@ static struct ctl_table_header *sd_sysctl_header;
78084 static void register_sched_domain_sysctl(void)
78085 {
78086 int i, cpu_num = num_possible_cpus();
78087 - struct ctl_table *entry = sd_alloc_ctl_entry(cpu_num + 1);
78088 + ctl_table_no_const *entry = sd_alloc_ctl_entry(cpu_num + 1);
78089 char buf[32];
78090
78091 WARN_ON(sd_ctl_dir[0].child);
78092 + pax_open_kernel();
78093 sd_ctl_dir[0].child = entry;
78094 + pax_close_kernel();
78095
78096 if (entry == NULL)
78097 return;
78098 @@ -5115,8 +5124,12 @@ static void unregister_sched_domain_sysctl(void)
78099 if (sd_sysctl_header)
78100 unregister_sysctl_table(sd_sysctl_header);
78101 sd_sysctl_header = NULL;
78102 - if (sd_ctl_dir[0].child)
78103 - sd_free_ctl_entry(&sd_ctl_dir[0].child);
78104 + if (sd_ctl_dir[0].child) {
78105 + sd_free_ctl_entry(sd_ctl_dir[0].child);
78106 + pax_open_kernel();
78107 + sd_ctl_dir[0].child = NULL;
78108 + pax_close_kernel();
78109 + }
78110 }
78111 #else
78112 static void register_sched_domain_sysctl(void)
78113 @@ -5215,7 +5228,7 @@ migration_call(struct notifier_block *nfb, unsigned long action, void *hcpu)
78114 * happens before everything else. This has to be lower priority than
78115 * the notifier in the perf_event subsystem, though.
78116 */
78117 -static struct notifier_block __cpuinitdata migration_notifier = {
78118 +static struct notifier_block migration_notifier = {
78119 .notifier_call = migration_call,
78120 .priority = CPU_PRI_MIGRATION,
78121 };
78122 diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
78123 index 7a33e59..2f7730c 100644
78124 --- a/kernel/sched/fair.c
78125 +++ b/kernel/sched/fair.c
78126 @@ -830,7 +830,7 @@ void task_numa_fault(int node, int pages, bool migrated)
78127
78128 static void reset_ptenuma_scan(struct task_struct *p)
78129 {
78130 - ACCESS_ONCE(p->mm->numa_scan_seq)++;
78131 + ACCESS_ONCE_RW(p->mm->numa_scan_seq)++;
78132 p->mm->numa_scan_offset = 0;
78133 }
78134
78135 @@ -5654,7 +5654,7 @@ static void nohz_idle_balance(int this_cpu, enum cpu_idle_type idle) { }
78136 * run_rebalance_domains is triggered when needed from the scheduler tick.
78137 * Also triggered for nohz idle balancing (with nohz_balancing_kick set).
78138 */
78139 -static void run_rebalance_domains(struct softirq_action *h)
78140 +static void run_rebalance_domains(void)
78141 {
78142 int this_cpu = smp_processor_id();
78143 struct rq *this_rq = cpu_rq(this_cpu);
78144 diff --git a/kernel/signal.c b/kernel/signal.c
78145 index 598dc06..471310a 100644
78146 --- a/kernel/signal.c
78147 +++ b/kernel/signal.c
78148 @@ -50,12 +50,12 @@ static struct kmem_cache *sigqueue_cachep;
78149
78150 int print_fatal_signals __read_mostly;
78151
78152 -static void __user *sig_handler(struct task_struct *t, int sig)
78153 +static __sighandler_t sig_handler(struct task_struct *t, int sig)
78154 {
78155 return t->sighand->action[sig - 1].sa.sa_handler;
78156 }
78157
78158 -static int sig_handler_ignored(void __user *handler, int sig)
78159 +static int sig_handler_ignored(__sighandler_t handler, int sig)
78160 {
78161 /* Is it explicitly or implicitly ignored? */
78162 return handler == SIG_IGN ||
78163 @@ -64,7 +64,7 @@ static int sig_handler_ignored(void __user *handler, int sig)
78164
78165 static int sig_task_ignored(struct task_struct *t, int sig, bool force)
78166 {
78167 - void __user *handler;
78168 + __sighandler_t handler;
78169
78170 handler = sig_handler(t, sig);
78171
78172 @@ -368,6 +368,9 @@ __sigqueue_alloc(int sig, struct task_struct *t, gfp_t flags, int override_rlimi
78173 atomic_inc(&user->sigpending);
78174 rcu_read_unlock();
78175
78176 + if (!override_rlimit)
78177 + gr_learn_resource(t, RLIMIT_SIGPENDING, atomic_read(&user->sigpending), 1);
78178 +
78179 if (override_rlimit ||
78180 atomic_read(&user->sigpending) <=
78181 task_rlimit(t, RLIMIT_SIGPENDING)) {
78182 @@ -495,7 +498,7 @@ flush_signal_handlers(struct task_struct *t, int force_default)
78183
78184 int unhandled_signal(struct task_struct *tsk, int sig)
78185 {
78186 - void __user *handler = tsk->sighand->action[sig-1].sa.sa_handler;
78187 + __sighandler_t handler = tsk->sighand->action[sig-1].sa.sa_handler;
78188 if (is_global_init(tsk))
78189 return 1;
78190 if (handler != SIG_IGN && handler != SIG_DFL)
78191 @@ -815,6 +818,13 @@ static int check_kill_permission(int sig, struct siginfo *info,
78192 }
78193 }
78194
78195 + /* allow glibc communication via tgkill to other threads in our
78196 + thread group */
78197 + if ((info == SEND_SIG_NOINFO || info->si_code != SI_TKILL ||
78198 + sig != (SIGRTMIN+1) || task_tgid_vnr(t) != info->si_pid)
78199 + && gr_handle_signal(t, sig))
78200 + return -EPERM;
78201 +
78202 return security_task_kill(t, info, sig, 0);
78203 }
78204
78205 @@ -1197,7 +1207,7 @@ __group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
78206 return send_signal(sig, info, p, 1);
78207 }
78208
78209 -static int
78210 +int
78211 specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t)
78212 {
78213 return send_signal(sig, info, t, 0);
78214 @@ -1234,6 +1244,7 @@ force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
78215 unsigned long int flags;
78216 int ret, blocked, ignored;
78217 struct k_sigaction *action;
78218 + int is_unhandled = 0;
78219
78220 spin_lock_irqsave(&t->sighand->siglock, flags);
78221 action = &t->sighand->action[sig-1];
78222 @@ -1248,9 +1259,18 @@ force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
78223 }
78224 if (action->sa.sa_handler == SIG_DFL)
78225 t->signal->flags &= ~SIGNAL_UNKILLABLE;
78226 + if (action->sa.sa_handler == SIG_IGN || action->sa.sa_handler == SIG_DFL)
78227 + is_unhandled = 1;
78228 ret = specific_send_sig_info(sig, info, t);
78229 spin_unlock_irqrestore(&t->sighand->siglock, flags);
78230
78231 + /* only deal with unhandled signals, java etc trigger SIGSEGV during
78232 + normal operation */
78233 + if (is_unhandled) {
78234 + gr_log_signal(sig, !is_si_special(info) ? info->si_addr : NULL, t);
78235 + gr_handle_crash(t, sig);
78236 + }
78237 +
78238 return ret;
78239 }
78240
78241 @@ -1317,8 +1337,11 @@ int group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
78242 ret = check_kill_permission(sig, info, p);
78243 rcu_read_unlock();
78244
78245 - if (!ret && sig)
78246 + if (!ret && sig) {
78247 ret = do_send_sig_info(sig, info, p, true);
78248 + if (!ret)
78249 + gr_log_signal(sig, !is_si_special(info) ? info->si_addr : NULL, p);
78250 + }
78251
78252 return ret;
78253 }
78254 @@ -2923,7 +2946,15 @@ do_send_specific(pid_t tgid, pid_t pid, int sig, struct siginfo *info)
78255 int error = -ESRCH;
78256
78257 rcu_read_lock();
78258 - p = find_task_by_vpid(pid);
78259 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
78260 + /* allow glibc communication via tgkill to other threads in our
78261 + thread group */
78262 + if (grsec_enable_chroot_findtask && info->si_code == SI_TKILL &&
78263 + sig == (SIGRTMIN+1) && tgid == info->si_pid)
78264 + p = find_task_by_vpid_unrestricted(pid);
78265 + else
78266 +#endif
78267 + p = find_task_by_vpid(pid);
78268 if (p && (tgid <= 0 || task_tgid_vnr(p) == tgid)) {
78269 error = check_kill_permission(sig, info, p);
78270 /*
78271 @@ -3237,8 +3268,8 @@ COMPAT_SYSCALL_DEFINE2(sigaltstack,
78272 }
78273 seg = get_fs();
78274 set_fs(KERNEL_DS);
78275 - ret = do_sigaltstack((stack_t __force __user *) (uss_ptr ? &uss : NULL),
78276 - (stack_t __force __user *) &uoss,
78277 + ret = do_sigaltstack((stack_t __force_user *) (uss_ptr ? &uss : NULL),
78278 + (stack_t __force_user *) &uoss,
78279 compat_user_stack_pointer());
78280 set_fs(seg);
78281 if (ret >= 0 && uoss_ptr) {
78282 diff --git a/kernel/smp.c b/kernel/smp.c
78283 index 8e451f3..8322029 100644
78284 --- a/kernel/smp.c
78285 +++ b/kernel/smp.c
78286 @@ -73,7 +73,7 @@ hotplug_cfd(struct notifier_block *nfb, unsigned long action, void *hcpu)
78287 return NOTIFY_OK;
78288 }
78289
78290 -static struct notifier_block __cpuinitdata hotplug_cfd_notifier = {
78291 +static struct notifier_block hotplug_cfd_notifier = {
78292 .notifier_call = hotplug_cfd,
78293 };
78294
78295 diff --git a/kernel/smpboot.c b/kernel/smpboot.c
78296 index 02fc5c9..e54c335 100644
78297 --- a/kernel/smpboot.c
78298 +++ b/kernel/smpboot.c
78299 @@ -288,7 +288,7 @@ int smpboot_register_percpu_thread(struct smp_hotplug_thread *plug_thread)
78300 }
78301 smpboot_unpark_thread(plug_thread, cpu);
78302 }
78303 - list_add(&plug_thread->list, &hotplug_threads);
78304 + pax_list_add(&plug_thread->list, &hotplug_threads);
78305 out:
78306 mutex_unlock(&smpboot_threads_lock);
78307 return ret;
78308 @@ -305,7 +305,7 @@ void smpboot_unregister_percpu_thread(struct smp_hotplug_thread *plug_thread)
78309 {
78310 get_online_cpus();
78311 mutex_lock(&smpboot_threads_lock);
78312 - list_del(&plug_thread->list);
78313 + pax_list_del(&plug_thread->list);
78314 smpboot_destroy_threads(plug_thread);
78315 mutex_unlock(&smpboot_threads_lock);
78316 put_online_cpus();
78317 diff --git a/kernel/softirq.c b/kernel/softirq.c
78318 index 14d7758..012121f 100644
78319 --- a/kernel/softirq.c
78320 +++ b/kernel/softirq.c
78321 @@ -53,11 +53,11 @@ irq_cpustat_t irq_stat[NR_CPUS] ____cacheline_aligned;
78322 EXPORT_SYMBOL(irq_stat);
78323 #endif
78324
78325 -static struct softirq_action softirq_vec[NR_SOFTIRQS] __cacheline_aligned_in_smp;
78326 +static struct softirq_action softirq_vec[NR_SOFTIRQS] __read_only __aligned(PAGE_SIZE);
78327
78328 DEFINE_PER_CPU(struct task_struct *, ksoftirqd);
78329
78330 -char *softirq_to_name[NR_SOFTIRQS] = {
78331 +const char * const softirq_to_name[NR_SOFTIRQS] = {
78332 "HI", "TIMER", "NET_TX", "NET_RX", "BLOCK", "BLOCK_IOPOLL",
78333 "TASKLET", "SCHED", "HRTIMER", "RCU"
78334 };
78335 @@ -244,7 +244,7 @@ restart:
78336 kstat_incr_softirqs_this_cpu(vec_nr);
78337
78338 trace_softirq_entry(vec_nr);
78339 - h->action(h);
78340 + h->action();
78341 trace_softirq_exit(vec_nr);
78342 if (unlikely(prev_count != preempt_count())) {
78343 printk(KERN_ERR "huh, entered softirq %u %s %p"
78344 @@ -389,7 +389,7 @@ void __raise_softirq_irqoff(unsigned int nr)
78345 or_softirq_pending(1UL << nr);
78346 }
78347
78348 -void open_softirq(int nr, void (*action)(struct softirq_action *))
78349 +void __init open_softirq(int nr, void (*action)(void))
78350 {
78351 softirq_vec[nr].action = action;
78352 }
78353 @@ -445,7 +445,7 @@ void __tasklet_hi_schedule_first(struct tasklet_struct *t)
78354
78355 EXPORT_SYMBOL(__tasklet_hi_schedule_first);
78356
78357 -static void tasklet_action(struct softirq_action *a)
78358 +static void tasklet_action(void)
78359 {
78360 struct tasklet_struct *list;
78361
78362 @@ -480,7 +480,7 @@ static void tasklet_action(struct softirq_action *a)
78363 }
78364 }
78365
78366 -static void tasklet_hi_action(struct softirq_action *a)
78367 +static void tasklet_hi_action(void)
78368 {
78369 struct tasklet_struct *list;
78370
78371 @@ -716,7 +716,7 @@ static int __cpuinit remote_softirq_cpu_notify(struct notifier_block *self,
78372 return NOTIFY_OK;
78373 }
78374
78375 -static struct notifier_block __cpuinitdata remote_softirq_cpu_notifier = {
78376 +static struct notifier_block remote_softirq_cpu_notifier = {
78377 .notifier_call = remote_softirq_cpu_notify,
78378 };
78379
78380 @@ -833,11 +833,11 @@ static int __cpuinit cpu_callback(struct notifier_block *nfb,
78381 return NOTIFY_OK;
78382 }
78383
78384 -static struct notifier_block __cpuinitdata cpu_nfb = {
78385 +static struct notifier_block cpu_nfb = {
78386 .notifier_call = cpu_callback
78387 };
78388
78389 -static struct smp_hotplug_thread softirq_threads = {
78390 +static struct smp_hotplug_thread softirq_threads __read_only = {
78391 .store = &ksoftirqd,
78392 .thread_should_run = ksoftirqd_should_run,
78393 .thread_fn = run_ksoftirqd,
78394 diff --git a/kernel/srcu.c b/kernel/srcu.c
78395 index 01d5ccb..cdcbee6 100644
78396 --- a/kernel/srcu.c
78397 +++ b/kernel/srcu.c
78398 @@ -300,9 +300,9 @@ int __srcu_read_lock(struct srcu_struct *sp)
78399
78400 idx = ACCESS_ONCE(sp->completed) & 0x1;
78401 preempt_disable();
78402 - ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) += 1;
78403 + ACCESS_ONCE_RW(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) += 1;
78404 smp_mb(); /* B */ /* Avoid leaking the critical section. */
78405 - ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->seq[idx]) += 1;
78406 + ACCESS_ONCE_RW(this_cpu_ptr(sp->per_cpu_ref)->seq[idx]) += 1;
78407 preempt_enable();
78408 return idx;
78409 }
78410 diff --git a/kernel/sys.c b/kernel/sys.c
78411 index 0da73cf..5c2af3c 100644
78412 --- a/kernel/sys.c
78413 +++ b/kernel/sys.c
78414 @@ -158,6 +158,12 @@ static int set_one_prio(struct task_struct *p, int niceval, int error)
78415 error = -EACCES;
78416 goto out;
78417 }
78418 +
78419 + if (gr_handle_chroot_setpriority(p, niceval)) {
78420 + error = -EACCES;
78421 + goto out;
78422 + }
78423 +
78424 no_nice = security_task_setnice(p, niceval);
78425 if (no_nice) {
78426 error = no_nice;
78427 @@ -598,6 +604,9 @@ SYSCALL_DEFINE2(setregid, gid_t, rgid, gid_t, egid)
78428 goto error;
78429 }
78430
78431 + if (gr_check_group_change(new->gid, new->egid, INVALID_GID))
78432 + goto error;
78433 +
78434 if (rgid != (gid_t) -1 ||
78435 (egid != (gid_t) -1 && !gid_eq(kegid, old->gid)))
78436 new->sgid = new->egid;
78437 @@ -633,6 +642,10 @@ SYSCALL_DEFINE1(setgid, gid_t, gid)
78438 old = current_cred();
78439
78440 retval = -EPERM;
78441 +
78442 + if (gr_check_group_change(kgid, kgid, kgid))
78443 + goto error;
78444 +
78445 if (nsown_capable(CAP_SETGID))
78446 new->gid = new->egid = new->sgid = new->fsgid = kgid;
78447 else if (gid_eq(kgid, old->gid) || gid_eq(kgid, old->sgid))
78448 @@ -650,7 +663,7 @@ error:
78449 /*
78450 * change the user struct in a credentials set to match the new UID
78451 */
78452 -static int set_user(struct cred *new)
78453 +int set_user(struct cred *new)
78454 {
78455 struct user_struct *new_user;
78456
78457 @@ -730,6 +743,9 @@ SYSCALL_DEFINE2(setreuid, uid_t, ruid, uid_t, euid)
78458 goto error;
78459 }
78460
78461 + if (gr_check_user_change(new->uid, new->euid, INVALID_UID))
78462 + goto error;
78463 +
78464 if (!uid_eq(new->uid, old->uid)) {
78465 retval = set_user(new);
78466 if (retval < 0)
78467 @@ -780,6 +796,12 @@ SYSCALL_DEFINE1(setuid, uid_t, uid)
78468 old = current_cred();
78469
78470 retval = -EPERM;
78471 +
78472 + if (gr_check_crash_uid(kuid))
78473 + goto error;
78474 + if (gr_check_user_change(kuid, kuid, kuid))
78475 + goto error;
78476 +
78477 if (nsown_capable(CAP_SETUID)) {
78478 new->suid = new->uid = kuid;
78479 if (!uid_eq(kuid, old->uid)) {
78480 @@ -849,6 +871,9 @@ SYSCALL_DEFINE3(setresuid, uid_t, ruid, uid_t, euid, uid_t, suid)
78481 goto error;
78482 }
78483
78484 + if (gr_check_user_change(kruid, keuid, INVALID_UID))
78485 + goto error;
78486 +
78487 if (ruid != (uid_t) -1) {
78488 new->uid = kruid;
78489 if (!uid_eq(kruid, old->uid)) {
78490 @@ -931,6 +956,9 @@ SYSCALL_DEFINE3(setresgid, gid_t, rgid, gid_t, egid, gid_t, sgid)
78491 goto error;
78492 }
78493
78494 + if (gr_check_group_change(krgid, kegid, INVALID_GID))
78495 + goto error;
78496 +
78497 if (rgid != (gid_t) -1)
78498 new->gid = krgid;
78499 if (egid != (gid_t) -1)
78500 @@ -992,12 +1020,16 @@ SYSCALL_DEFINE1(setfsuid, uid_t, uid)
78501 uid_eq(kuid, old->suid) || uid_eq(kuid, old->fsuid) ||
78502 nsown_capable(CAP_SETUID)) {
78503 if (!uid_eq(kuid, old->fsuid)) {
78504 + if (gr_check_user_change(INVALID_UID, INVALID_UID, kuid))
78505 + goto error;
78506 +
78507 new->fsuid = kuid;
78508 if (security_task_fix_setuid(new, old, LSM_SETID_FS) == 0)
78509 goto change_okay;
78510 }
78511 }
78512
78513 +error:
78514 abort_creds(new);
78515 return old_fsuid;
78516
78517 @@ -1030,12 +1062,16 @@ SYSCALL_DEFINE1(setfsgid, gid_t, gid)
78518 if (gid_eq(kgid, old->gid) || gid_eq(kgid, old->egid) ||
78519 gid_eq(kgid, old->sgid) || gid_eq(kgid, old->fsgid) ||
78520 nsown_capable(CAP_SETGID)) {
78521 + if (gr_check_group_change(INVALID_GID, INVALID_GID, kgid))
78522 + goto error;
78523 +
78524 if (!gid_eq(kgid, old->fsgid)) {
78525 new->fsgid = kgid;
78526 goto change_okay;
78527 }
78528 }
78529
78530 +error:
78531 abort_creds(new);
78532 return old_fsgid;
78533
78534 @@ -1343,19 +1379,19 @@ SYSCALL_DEFINE1(olduname, struct oldold_utsname __user *, name)
78535 return -EFAULT;
78536
78537 down_read(&uts_sem);
78538 - error = __copy_to_user(&name->sysname, &utsname()->sysname,
78539 + error = __copy_to_user(name->sysname, &utsname()->sysname,
78540 __OLD_UTS_LEN);
78541 error |= __put_user(0, name->sysname + __OLD_UTS_LEN);
78542 - error |= __copy_to_user(&name->nodename, &utsname()->nodename,
78543 + error |= __copy_to_user(name->nodename, &utsname()->nodename,
78544 __OLD_UTS_LEN);
78545 error |= __put_user(0, name->nodename + __OLD_UTS_LEN);
78546 - error |= __copy_to_user(&name->release, &utsname()->release,
78547 + error |= __copy_to_user(name->release, &utsname()->release,
78548 __OLD_UTS_LEN);
78549 error |= __put_user(0, name->release + __OLD_UTS_LEN);
78550 - error |= __copy_to_user(&name->version, &utsname()->version,
78551 + error |= __copy_to_user(name->version, &utsname()->version,
78552 __OLD_UTS_LEN);
78553 error |= __put_user(0, name->version + __OLD_UTS_LEN);
78554 - error |= __copy_to_user(&name->machine, &utsname()->machine,
78555 + error |= __copy_to_user(name->machine, &utsname()->machine,
78556 __OLD_UTS_LEN);
78557 error |= __put_user(0, name->machine + __OLD_UTS_LEN);
78558 up_read(&uts_sem);
78559 @@ -1557,6 +1593,13 @@ int do_prlimit(struct task_struct *tsk, unsigned int resource,
78560 */
78561 new_rlim->rlim_cur = 1;
78562 }
78563 + /* Handle the case where a fork and setuid occur and then RLIMIT_NPROC
78564 + is changed to a lower value. Since tasks can be created by the same
78565 + user in between this limit change and an execve by this task, force
78566 + a recheck only for this task by setting PF_NPROC_EXCEEDED
78567 + */
78568 + if (resource == RLIMIT_NPROC && tsk->real_cred->user != INIT_USER)
78569 + tsk->flags |= PF_NPROC_EXCEEDED;
78570 }
78571 if (!retval) {
78572 if (old_rlim)
78573 diff --git a/kernel/sysctl.c b/kernel/sysctl.c
78574 index afc1dc6..f6cf355 100644
78575 --- a/kernel/sysctl.c
78576 +++ b/kernel/sysctl.c
78577 @@ -93,7 +93,6 @@
78578
78579
78580 #if defined(CONFIG_SYSCTL)
78581 -
78582 /* External variables not in a header file. */
78583 extern int sysctl_overcommit_memory;
78584 extern int sysctl_overcommit_ratio;
78585 @@ -120,18 +119,18 @@ extern int blk_iopoll_enabled;
78586
78587 /* Constants used for minimum and maximum */
78588 #ifdef CONFIG_LOCKUP_DETECTOR
78589 -static int sixty = 60;
78590 -static int neg_one = -1;
78591 +static int sixty __read_only = 60;
78592 #endif
78593
78594 -static int zero;
78595 -static int __maybe_unused one = 1;
78596 -static int __maybe_unused two = 2;
78597 -static int __maybe_unused three = 3;
78598 -static unsigned long one_ul = 1;
78599 -static int one_hundred = 100;
78600 +static int neg_one __read_only = -1;
78601 +static int zero __read_only = 0;
78602 +static int __maybe_unused one __read_only = 1;
78603 +static int __maybe_unused two __read_only = 2;
78604 +static int __maybe_unused three __read_only = 3;
78605 +static unsigned long one_ul __read_only = 1;
78606 +static int one_hundred __read_only = 100;
78607 #ifdef CONFIG_PRINTK
78608 -static int ten_thousand = 10000;
78609 +static int ten_thousand __read_only = 10000;
78610 #endif
78611
78612 /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
78613 @@ -178,10 +177,8 @@ static int proc_taint(struct ctl_table *table, int write,
78614 void __user *buffer, size_t *lenp, loff_t *ppos);
78615 #endif
78616
78617 -#ifdef CONFIG_PRINTK
78618 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
78619 void __user *buffer, size_t *lenp, loff_t *ppos);
78620 -#endif
78621
78622 static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
78623 void __user *buffer, size_t *lenp, loff_t *ppos);
78624 @@ -212,6 +209,8 @@ static int sysrq_sysctl_handler(ctl_table *table, int write,
78625
78626 #endif
78627
78628 +extern struct ctl_table grsecurity_table[];
78629 +
78630 static struct ctl_table kern_table[];
78631 static struct ctl_table vm_table[];
78632 static struct ctl_table fs_table[];
78633 @@ -226,6 +225,20 @@ extern struct ctl_table epoll_table[];
78634 int sysctl_legacy_va_layout;
78635 #endif
78636
78637 +#ifdef CONFIG_PAX_SOFTMODE
78638 +static ctl_table pax_table[] = {
78639 + {
78640 + .procname = "softmode",
78641 + .data = &pax_softmode,
78642 + .maxlen = sizeof(unsigned int),
78643 + .mode = 0600,
78644 + .proc_handler = &proc_dointvec,
78645 + },
78646 +
78647 + { }
78648 +};
78649 +#endif
78650 +
78651 /* The default sysctl tables: */
78652
78653 static struct ctl_table sysctl_base_table[] = {
78654 @@ -274,6 +287,22 @@ static int max_extfrag_threshold = 1000;
78655 #endif
78656
78657 static struct ctl_table kern_table[] = {
78658 +#if defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_ROFS)
78659 + {
78660 + .procname = "grsecurity",
78661 + .mode = 0500,
78662 + .child = grsecurity_table,
78663 + },
78664 +#endif
78665 +
78666 +#ifdef CONFIG_PAX_SOFTMODE
78667 + {
78668 + .procname = "pax",
78669 + .mode = 0500,
78670 + .child = pax_table,
78671 + },
78672 +#endif
78673 +
78674 {
78675 .procname = "sched_child_runs_first",
78676 .data = &sysctl_sched_child_runs_first,
78677 @@ -608,7 +637,7 @@ static struct ctl_table kern_table[] = {
78678 .data = &modprobe_path,
78679 .maxlen = KMOD_PATH_LEN,
78680 .mode = 0644,
78681 - .proc_handler = proc_dostring,
78682 + .proc_handler = proc_dostring_modpriv,
78683 },
78684 {
78685 .procname = "modules_disabled",
78686 @@ -775,16 +804,20 @@ static struct ctl_table kern_table[] = {
78687 .extra1 = &zero,
78688 .extra2 = &one,
78689 },
78690 +#endif
78691 {
78692 .procname = "kptr_restrict",
78693 .data = &kptr_restrict,
78694 .maxlen = sizeof(int),
78695 .mode = 0644,
78696 .proc_handler = proc_dointvec_minmax_sysadmin,
78697 +#ifdef CONFIG_GRKERNSEC_HIDESYM
78698 + .extra1 = &two,
78699 +#else
78700 .extra1 = &zero,
78701 +#endif
78702 .extra2 = &two,
78703 },
78704 -#endif
78705 {
78706 .procname = "ngroups_max",
78707 .data = &ngroups_max,
78708 @@ -1026,10 +1059,17 @@ static struct ctl_table kern_table[] = {
78709 */
78710 {
78711 .procname = "perf_event_paranoid",
78712 - .data = &sysctl_perf_event_paranoid,
78713 - .maxlen = sizeof(sysctl_perf_event_paranoid),
78714 + .data = &sysctl_perf_event_legitimately_concerned,
78715 + .maxlen = sizeof(sysctl_perf_event_legitimately_concerned),
78716 .mode = 0644,
78717 - .proc_handler = proc_dointvec,
78718 + /* go ahead, be a hero */
78719 + .proc_handler = proc_dointvec_minmax_sysadmin,
78720 + .extra1 = &neg_one,
78721 +#ifdef CONFIG_GRKERNSEC_PERF_HARDEN
78722 + .extra2 = &three,
78723 +#else
78724 + .extra2 = &two,
78725 +#endif
78726 },
78727 {
78728 .procname = "perf_event_mlock_kb",
78729 @@ -1283,6 +1323,13 @@ static struct ctl_table vm_table[] = {
78730 .proc_handler = proc_dointvec_minmax,
78731 .extra1 = &zero,
78732 },
78733 + {
78734 + .procname = "heap_stack_gap",
78735 + .data = &sysctl_heap_stack_gap,
78736 + .maxlen = sizeof(sysctl_heap_stack_gap),
78737 + .mode = 0644,
78738 + .proc_handler = proc_doulongvec_minmax,
78739 + },
78740 #else
78741 {
78742 .procname = "nr_trim_pages",
78743 @@ -1733,6 +1780,16 @@ int proc_dostring(struct ctl_table *table, int write,
78744 buffer, lenp, ppos);
78745 }
78746
78747 +int proc_dostring_modpriv(struct ctl_table *table, int write,
78748 + void __user *buffer, size_t *lenp, loff_t *ppos)
78749 +{
78750 + if (write && !capable(CAP_SYS_MODULE))
78751 + return -EPERM;
78752 +
78753 + return _proc_do_string(table->data, table->maxlen, write,
78754 + buffer, lenp, ppos);
78755 +}
78756 +
78757 static size_t proc_skip_spaces(char **buf)
78758 {
78759 size_t ret;
78760 @@ -1838,6 +1895,8 @@ static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
78761 len = strlen(tmp);
78762 if (len > *size)
78763 len = *size;
78764 + if (len > sizeof(tmp))
78765 + len = sizeof(tmp);
78766 if (copy_to_user(*buf, tmp, len))
78767 return -EFAULT;
78768 *size -= len;
78769 @@ -2002,7 +2061,7 @@ int proc_dointvec(struct ctl_table *table, int write,
78770 static int proc_taint(struct ctl_table *table, int write,
78771 void __user *buffer, size_t *lenp, loff_t *ppos)
78772 {
78773 - struct ctl_table t;
78774 + ctl_table_no_const t;
78775 unsigned long tmptaint = get_taint();
78776 int err;
78777
78778 @@ -2030,7 +2089,6 @@ static int proc_taint(struct ctl_table *table, int write,
78779 return err;
78780 }
78781
78782 -#ifdef CONFIG_PRINTK
78783 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
78784 void __user *buffer, size_t *lenp, loff_t *ppos)
78785 {
78786 @@ -2039,7 +2097,6 @@ static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
78787
78788 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
78789 }
78790 -#endif
78791
78792 struct do_proc_dointvec_minmax_conv_param {
78793 int *min;
78794 @@ -2186,8 +2243,11 @@ static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int
78795 *i = val;
78796 } else {
78797 val = convdiv * (*i) / convmul;
78798 - if (!first)
78799 + if (!first) {
78800 err = proc_put_char(&buffer, &left, '\t');
78801 + if (err)
78802 + break;
78803 + }
78804 err = proc_put_long(&buffer, &left, val, false);
78805 if (err)
78806 break;
78807 @@ -2579,6 +2639,12 @@ int proc_dostring(struct ctl_table *table, int write,
78808 return -ENOSYS;
78809 }
78810
78811 +int proc_dostring_modpriv(struct ctl_table *table, int write,
78812 + void __user *buffer, size_t *lenp, loff_t *ppos)
78813 +{
78814 + return -ENOSYS;
78815 +}
78816 +
78817 int proc_dointvec(struct ctl_table *table, int write,
78818 void __user *buffer, size_t *lenp, loff_t *ppos)
78819 {
78820 @@ -2635,5 +2701,6 @@ EXPORT_SYMBOL(proc_dointvec_minmax);
78821 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
78822 EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
78823 EXPORT_SYMBOL(proc_dostring);
78824 +EXPORT_SYMBOL(proc_dostring_modpriv);
78825 EXPORT_SYMBOL(proc_doulongvec_minmax);
78826 EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
78827 diff --git a/kernel/taskstats.c b/kernel/taskstats.c
78828 index 145bb4d..b2aa969 100644
78829 --- a/kernel/taskstats.c
78830 +++ b/kernel/taskstats.c
78831 @@ -28,9 +28,12 @@
78832 #include <linux/fs.h>
78833 #include <linux/file.h>
78834 #include <linux/pid_namespace.h>
78835 +#include <linux/grsecurity.h>
78836 #include <net/genetlink.h>
78837 #include <linux/atomic.h>
78838
78839 +extern int gr_is_taskstats_denied(int pid);
78840 +
78841 /*
78842 * Maximum length of a cpumask that can be specified in
78843 * the TASKSTATS_CMD_ATTR_REGISTER/DEREGISTER_CPUMASK attribute
78844 @@ -570,6 +573,9 @@ err:
78845
78846 static int taskstats_user_cmd(struct sk_buff *skb, struct genl_info *info)
78847 {
78848 + if (gr_is_taskstats_denied(current->pid))
78849 + return -EACCES;
78850 +
78851 if (info->attrs[TASKSTATS_CMD_ATTR_REGISTER_CPUMASK])
78852 return cmd_attr_register_cpumask(info);
78853 else if (info->attrs[TASKSTATS_CMD_ATTR_DEREGISTER_CPUMASK])
78854 diff --git a/kernel/time.c b/kernel/time.c
78855 index f8342a4..288f13b 100644
78856 --- a/kernel/time.c
78857 +++ b/kernel/time.c
78858 @@ -171,6 +171,11 @@ int do_sys_settimeofday(const struct timespec *tv, const struct timezone *tz)
78859 return error;
78860
78861 if (tz) {
78862 + /* we log in do_settimeofday called below, so don't log twice
78863 + */
78864 + if (!tv)
78865 + gr_log_timechange();
78866 +
78867 sys_tz = *tz;
78868 update_vsyscall_tz();
78869 if (firsttime) {
78870 @@ -501,7 +506,7 @@ EXPORT_SYMBOL(usecs_to_jiffies);
78871 * The >> (NSEC_JIFFIE_SC - SEC_JIFFIE_SC) converts the scaled nsec
78872 * value to a scaled second value.
78873 */
78874 -unsigned long
78875 +unsigned long __intentional_overflow(-1)
78876 timespec_to_jiffies(const struct timespec *value)
78877 {
78878 unsigned long sec = value->tv_sec;
78879 diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
78880 index f11d83b..d016d91 100644
78881 --- a/kernel/time/alarmtimer.c
78882 +++ b/kernel/time/alarmtimer.c
78883 @@ -750,7 +750,7 @@ static int __init alarmtimer_init(void)
78884 struct platform_device *pdev;
78885 int error = 0;
78886 int i;
78887 - struct k_clock alarm_clock = {
78888 + static struct k_clock alarm_clock = {
78889 .clock_getres = alarm_clock_getres,
78890 .clock_get = alarm_clock_get,
78891 .timer_create = alarm_timer_create,
78892 diff --git a/kernel/time/tick-broadcast.c b/kernel/time/tick-broadcast.c
78893 index 90ad470..1814e9a 100644
78894 --- a/kernel/time/tick-broadcast.c
78895 +++ b/kernel/time/tick-broadcast.c
78896 @@ -138,7 +138,7 @@ int tick_device_uses_broadcast(struct clock_event_device *dev, int cpu)
78897 * then clear the broadcast bit.
78898 */
78899 if (!(dev->features & CLOCK_EVT_FEAT_C3STOP)) {
78900 - int cpu = smp_processor_id();
78901 + cpu = smp_processor_id();
78902 cpumask_clear_cpu(cpu, tick_get_broadcast_mask());
78903 tick_broadcast_clear_oneshot(cpu);
78904 } else {
78905 diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
78906 index 9a0bc98..fceb7d0 100644
78907 --- a/kernel/time/timekeeping.c
78908 +++ b/kernel/time/timekeeping.c
78909 @@ -15,6 +15,7 @@
78910 #include <linux/init.h>
78911 #include <linux/mm.h>
78912 #include <linux/sched.h>
78913 +#include <linux/grsecurity.h>
78914 #include <linux/syscore_ops.h>
78915 #include <linux/clocksource.h>
78916 #include <linux/jiffies.h>
78917 @@ -448,6 +449,8 @@ int do_settimeofday(const struct timespec *tv)
78918 if (!timespec_valid_strict(tv))
78919 return -EINVAL;
78920
78921 + gr_log_timechange();
78922 +
78923 write_seqlock_irqsave(&tk->lock, flags);
78924
78925 timekeeping_forward_now(tk);
78926 diff --git a/kernel/time/timer_list.c b/kernel/time/timer_list.c
78927 index af5a7e9..715611a 100644
78928 --- a/kernel/time/timer_list.c
78929 +++ b/kernel/time/timer_list.c
78930 @@ -38,12 +38,16 @@ DECLARE_PER_CPU(struct hrtimer_cpu_base, hrtimer_bases);
78931
78932 static void print_name_offset(struct seq_file *m, void *sym)
78933 {
78934 +#ifdef CONFIG_GRKERNSEC_HIDESYM
78935 + SEQ_printf(m, "<%p>", NULL);
78936 +#else
78937 char symname[KSYM_NAME_LEN];
78938
78939 if (lookup_symbol_name((unsigned long)sym, symname) < 0)
78940 SEQ_printf(m, "<%pK>", sym);
78941 else
78942 SEQ_printf(m, "%s", symname);
78943 +#endif
78944 }
78945
78946 static void
78947 @@ -112,7 +116,11 @@ next_one:
78948 static void
78949 print_base(struct seq_file *m, struct hrtimer_clock_base *base, u64 now)
78950 {
78951 +#ifdef CONFIG_GRKERNSEC_HIDESYM
78952 + SEQ_printf(m, " .base: %p\n", NULL);
78953 +#else
78954 SEQ_printf(m, " .base: %pK\n", base);
78955 +#endif
78956 SEQ_printf(m, " .index: %d\n",
78957 base->index);
78958 SEQ_printf(m, " .resolution: %Lu nsecs\n",
78959 @@ -293,7 +301,11 @@ static int __init init_timer_list_procfs(void)
78960 {
78961 struct proc_dir_entry *pe;
78962
78963 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
78964 + pe = proc_create("timer_list", 0400, NULL, &timer_list_fops);
78965 +#else
78966 pe = proc_create("timer_list", 0444, NULL, &timer_list_fops);
78967 +#endif
78968 if (!pe)
78969 return -ENOMEM;
78970 return 0;
78971 diff --git a/kernel/time/timer_stats.c b/kernel/time/timer_stats.c
78972 index 0b537f2..40d6c20 100644
78973 --- a/kernel/time/timer_stats.c
78974 +++ b/kernel/time/timer_stats.c
78975 @@ -116,7 +116,7 @@ static ktime_t time_start, time_stop;
78976 static unsigned long nr_entries;
78977 static struct entry entries[MAX_ENTRIES];
78978
78979 -static atomic_t overflow_count;
78980 +static atomic_unchecked_t overflow_count;
78981
78982 /*
78983 * The entries are in a hash-table, for fast lookup:
78984 @@ -140,7 +140,7 @@ static void reset_entries(void)
78985 nr_entries = 0;
78986 memset(entries, 0, sizeof(entries));
78987 memset(tstat_hash_table, 0, sizeof(tstat_hash_table));
78988 - atomic_set(&overflow_count, 0);
78989 + atomic_set_unchecked(&overflow_count, 0);
78990 }
78991
78992 static struct entry *alloc_entry(void)
78993 @@ -261,7 +261,7 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
78994 if (likely(entry))
78995 entry->count++;
78996 else
78997 - atomic_inc(&overflow_count);
78998 + atomic_inc_unchecked(&overflow_count);
78999
79000 out_unlock:
79001 raw_spin_unlock_irqrestore(lock, flags);
79002 @@ -269,12 +269,16 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
79003
79004 static void print_name_offset(struct seq_file *m, unsigned long addr)
79005 {
79006 +#ifdef CONFIG_GRKERNSEC_HIDESYM
79007 + seq_printf(m, "<%p>", NULL);
79008 +#else
79009 char symname[KSYM_NAME_LEN];
79010
79011 if (lookup_symbol_name(addr, symname) < 0)
79012 - seq_printf(m, "<%p>", (void *)addr);
79013 + seq_printf(m, "<%pK>", (void *)addr);
79014 else
79015 seq_printf(m, "%s", symname);
79016 +#endif
79017 }
79018
79019 static int tstats_show(struct seq_file *m, void *v)
79020 @@ -300,9 +304,9 @@ static int tstats_show(struct seq_file *m, void *v)
79021
79022 seq_puts(m, "Timer Stats Version: v0.2\n");
79023 seq_printf(m, "Sample period: %ld.%03ld s\n", period.tv_sec, ms);
79024 - if (atomic_read(&overflow_count))
79025 + if (atomic_read_unchecked(&overflow_count))
79026 seq_printf(m, "Overflow: %d entries\n",
79027 - atomic_read(&overflow_count));
79028 + atomic_read_unchecked(&overflow_count));
79029
79030 for (i = 0; i < nr_entries; i++) {
79031 entry = entries + i;
79032 @@ -417,7 +421,11 @@ static int __init init_tstats_procfs(void)
79033 {
79034 struct proc_dir_entry *pe;
79035
79036 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
79037 + pe = proc_create("timer_stats", 0600, NULL, &tstats_fops);
79038 +#else
79039 pe = proc_create("timer_stats", 0644, NULL, &tstats_fops);
79040 +#endif
79041 if (!pe)
79042 return -ENOMEM;
79043 return 0;
79044 diff --git a/kernel/timer.c b/kernel/timer.c
79045 index 1b399c8..90e1849 100644
79046 --- a/kernel/timer.c
79047 +++ b/kernel/timer.c
79048 @@ -1363,7 +1363,7 @@ void update_process_times(int user_tick)
79049 /*
79050 * This function runs timers and the timer-tq in bottom half context.
79051 */
79052 -static void run_timer_softirq(struct softirq_action *h)
79053 +static void run_timer_softirq(void)
79054 {
79055 struct tvec_base *base = __this_cpu_read(tvec_bases);
79056
79057 @@ -1481,7 +1481,7 @@ static void process_timeout(unsigned long __data)
79058 *
79059 * In all cases the return value is guaranteed to be non-negative.
79060 */
79061 -signed long __sched schedule_timeout(signed long timeout)
79062 +signed long __sched __intentional_overflow(-1) schedule_timeout(signed long timeout)
79063 {
79064 struct timer_list timer;
79065 unsigned long expire;
79066 @@ -1772,7 +1772,7 @@ static int __cpuinit timer_cpu_notify(struct notifier_block *self,
79067 return NOTIFY_OK;
79068 }
79069
79070 -static struct notifier_block __cpuinitdata timers_nb = {
79071 +static struct notifier_block timers_nb = {
79072 .notifier_call = timer_cpu_notify,
79073 };
79074
79075 diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
79076 index 5a0f781..1497f95 100644
79077 --- a/kernel/trace/blktrace.c
79078 +++ b/kernel/trace/blktrace.c
79079 @@ -317,7 +317,7 @@ static ssize_t blk_dropped_read(struct file *filp, char __user *buffer,
79080 struct blk_trace *bt = filp->private_data;
79081 char buf[16];
79082
79083 - snprintf(buf, sizeof(buf), "%u\n", atomic_read(&bt->dropped));
79084 + snprintf(buf, sizeof(buf), "%u\n", atomic_read_unchecked(&bt->dropped));
79085
79086 return simple_read_from_buffer(buffer, count, ppos, buf, strlen(buf));
79087 }
79088 @@ -375,7 +375,7 @@ static int blk_subbuf_start_callback(struct rchan_buf *buf, void *subbuf,
79089 return 1;
79090
79091 bt = buf->chan->private_data;
79092 - atomic_inc(&bt->dropped);
79093 + atomic_inc_unchecked(&bt->dropped);
79094 return 0;
79095 }
79096
79097 @@ -476,7 +476,7 @@ int do_blk_trace_setup(struct request_queue *q, char *name, dev_t dev,
79098
79099 bt->dir = dir;
79100 bt->dev = dev;
79101 - atomic_set(&bt->dropped, 0);
79102 + atomic_set_unchecked(&bt->dropped, 0);
79103
79104 ret = -EIO;
79105 bt->dropped_file = debugfs_create_file("dropped", 0444, dir, bt,
79106 diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
79107 index 0a0e2a6..943495e 100644
79108 --- a/kernel/trace/ftrace.c
79109 +++ b/kernel/trace/ftrace.c
79110 @@ -1909,12 +1909,17 @@ ftrace_code_disable(struct module *mod, struct dyn_ftrace *rec)
79111 if (unlikely(ftrace_disabled))
79112 return 0;
79113
79114 + ret = ftrace_arch_code_modify_prepare();
79115 + FTRACE_WARN_ON(ret);
79116 + if (ret)
79117 + return 0;
79118 +
79119 ret = ftrace_make_nop(mod, rec, MCOUNT_ADDR);
79120 + FTRACE_WARN_ON(ftrace_arch_code_modify_post_process());
79121 if (ret) {
79122 ftrace_bug(ret, ip);
79123 - return 0;
79124 }
79125 - return 1;
79126 + return ret ? 0 : 1;
79127 }
79128
79129 /*
79130 @@ -2986,7 +2991,7 @@ static void ftrace_free_entry_rcu(struct rcu_head *rhp)
79131
79132 int
79133 register_ftrace_function_probe(char *glob, struct ftrace_probe_ops *ops,
79134 - void *data)
79135 + void *data)
79136 {
79137 struct ftrace_func_probe *entry;
79138 struct ftrace_page *pg;
79139 @@ -3854,8 +3859,10 @@ static int ftrace_process_locs(struct module *mod,
79140 if (!count)
79141 return 0;
79142
79143 + pax_open_kernel();
79144 sort(start, count, sizeof(*start),
79145 ftrace_cmp_ips, ftrace_swap_ips);
79146 + pax_close_kernel();
79147
79148 start_pg = ftrace_allocate_pages(count);
79149 if (!start_pg)
79150 @@ -4574,8 +4581,6 @@ ftrace_enable_sysctl(struct ctl_table *table, int write,
79151 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
79152
79153 static int ftrace_graph_active;
79154 -static struct notifier_block ftrace_suspend_notifier;
79155 -
79156 int ftrace_graph_entry_stub(struct ftrace_graph_ent *trace)
79157 {
79158 return 0;
79159 @@ -4719,6 +4724,10 @@ ftrace_suspend_notifier_call(struct notifier_block *bl, unsigned long state,
79160 return NOTIFY_DONE;
79161 }
79162
79163 +static struct notifier_block ftrace_suspend_notifier = {
79164 + .notifier_call = ftrace_suspend_notifier_call
79165 +};
79166 +
79167 int register_ftrace_graph(trace_func_graph_ret_t retfunc,
79168 trace_func_graph_ent_t entryfunc)
79169 {
79170 @@ -4732,7 +4741,6 @@ int register_ftrace_graph(trace_func_graph_ret_t retfunc,
79171 goto out;
79172 }
79173
79174 - ftrace_suspend_notifier.notifier_call = ftrace_suspend_notifier_call;
79175 register_pm_notifier(&ftrace_suspend_notifier);
79176
79177 ftrace_graph_active++;
79178 diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
79179 index 6989df2..c2265cf 100644
79180 --- a/kernel/trace/ring_buffer.c
79181 +++ b/kernel/trace/ring_buffer.c
79182 @@ -349,9 +349,9 @@ struct buffer_data_page {
79183 */
79184 struct buffer_page {
79185 struct list_head list; /* list of buffer pages */
79186 - local_t write; /* index for next write */
79187 + local_unchecked_t write; /* index for next write */
79188 unsigned read; /* index for next read */
79189 - local_t entries; /* entries on this page */
79190 + local_unchecked_t entries; /* entries on this page */
79191 unsigned long real_end; /* real end of data */
79192 struct buffer_data_page *page; /* Actual data page */
79193 };
79194 @@ -464,8 +464,8 @@ struct ring_buffer_per_cpu {
79195 unsigned long last_overrun;
79196 local_t entries_bytes;
79197 local_t entries;
79198 - local_t overrun;
79199 - local_t commit_overrun;
79200 + local_unchecked_t overrun;
79201 + local_unchecked_t commit_overrun;
79202 local_t dropped_events;
79203 local_t committing;
79204 local_t commits;
79205 @@ -864,8 +864,8 @@ static int rb_tail_page_update(struct ring_buffer_per_cpu *cpu_buffer,
79206 *
79207 * We add a counter to the write field to denote this.
79208 */
79209 - old_write = local_add_return(RB_WRITE_INTCNT, &next_page->write);
79210 - old_entries = local_add_return(RB_WRITE_INTCNT, &next_page->entries);
79211 + old_write = local_add_return_unchecked(RB_WRITE_INTCNT, &next_page->write);
79212 + old_entries = local_add_return_unchecked(RB_WRITE_INTCNT, &next_page->entries);
79213
79214 /*
79215 * Just make sure we have seen our old_write and synchronize
79216 @@ -893,8 +893,8 @@ static int rb_tail_page_update(struct ring_buffer_per_cpu *cpu_buffer,
79217 * cmpxchg to only update if an interrupt did not already
79218 * do it for us. If the cmpxchg fails, we don't care.
79219 */
79220 - (void)local_cmpxchg(&next_page->write, old_write, val);
79221 - (void)local_cmpxchg(&next_page->entries, old_entries, eval);
79222 + (void)local_cmpxchg_unchecked(&next_page->write, old_write, val);
79223 + (void)local_cmpxchg_unchecked(&next_page->entries, old_entries, eval);
79224
79225 /*
79226 * No need to worry about races with clearing out the commit.
79227 @@ -1253,12 +1253,12 @@ static void rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer);
79228
79229 static inline unsigned long rb_page_entries(struct buffer_page *bpage)
79230 {
79231 - return local_read(&bpage->entries) & RB_WRITE_MASK;
79232 + return local_read_unchecked(&bpage->entries) & RB_WRITE_MASK;
79233 }
79234
79235 static inline unsigned long rb_page_write(struct buffer_page *bpage)
79236 {
79237 - return local_read(&bpage->write) & RB_WRITE_MASK;
79238 + return local_read_unchecked(&bpage->write) & RB_WRITE_MASK;
79239 }
79240
79241 static int
79242 @@ -1353,7 +1353,7 @@ rb_remove_pages(struct ring_buffer_per_cpu *cpu_buffer, unsigned int nr_pages)
79243 * bytes consumed in ring buffer from here.
79244 * Increment overrun to account for the lost events.
79245 */
79246 - local_add(page_entries, &cpu_buffer->overrun);
79247 + local_add_unchecked(page_entries, &cpu_buffer->overrun);
79248 local_sub(BUF_PAGE_SIZE, &cpu_buffer->entries_bytes);
79249 }
79250
79251 @@ -1909,7 +1909,7 @@ rb_handle_head_page(struct ring_buffer_per_cpu *cpu_buffer,
79252 * it is our responsibility to update
79253 * the counters.
79254 */
79255 - local_add(entries, &cpu_buffer->overrun);
79256 + local_add_unchecked(entries, &cpu_buffer->overrun);
79257 local_sub(BUF_PAGE_SIZE, &cpu_buffer->entries_bytes);
79258
79259 /*
79260 @@ -2059,7 +2059,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
79261 if (tail == BUF_PAGE_SIZE)
79262 tail_page->real_end = 0;
79263
79264 - local_sub(length, &tail_page->write);
79265 + local_sub_unchecked(length, &tail_page->write);
79266 return;
79267 }
79268
79269 @@ -2094,7 +2094,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
79270 rb_event_set_padding(event);
79271
79272 /* Set the write back to the previous setting */
79273 - local_sub(length, &tail_page->write);
79274 + local_sub_unchecked(length, &tail_page->write);
79275 return;
79276 }
79277
79278 @@ -2106,7 +2106,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
79279
79280 /* Set write to end of buffer */
79281 length = (tail + length) - BUF_PAGE_SIZE;
79282 - local_sub(length, &tail_page->write);
79283 + local_sub_unchecked(length, &tail_page->write);
79284 }
79285
79286 /*
79287 @@ -2132,7 +2132,7 @@ rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer,
79288 * about it.
79289 */
79290 if (unlikely(next_page == commit_page)) {
79291 - local_inc(&cpu_buffer->commit_overrun);
79292 + local_inc_unchecked(&cpu_buffer->commit_overrun);
79293 goto out_reset;
79294 }
79295
79296 @@ -2188,7 +2188,7 @@ rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer,
79297 cpu_buffer->tail_page) &&
79298 (cpu_buffer->commit_page ==
79299 cpu_buffer->reader_page))) {
79300 - local_inc(&cpu_buffer->commit_overrun);
79301 + local_inc_unchecked(&cpu_buffer->commit_overrun);
79302 goto out_reset;
79303 }
79304 }
79305 @@ -2236,7 +2236,7 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
79306 length += RB_LEN_TIME_EXTEND;
79307
79308 tail_page = cpu_buffer->tail_page;
79309 - write = local_add_return(length, &tail_page->write);
79310 + write = local_add_return_unchecked(length, &tail_page->write);
79311
79312 /* set write to only the index of the write */
79313 write &= RB_WRITE_MASK;
79314 @@ -2253,7 +2253,7 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
79315 kmemcheck_annotate_bitfield(event, bitfield);
79316 rb_update_event(cpu_buffer, event, length, add_timestamp, delta);
79317
79318 - local_inc(&tail_page->entries);
79319 + local_inc_unchecked(&tail_page->entries);
79320
79321 /*
79322 * If this is the first commit on the page, then update
79323 @@ -2286,7 +2286,7 @@ rb_try_to_discard(struct ring_buffer_per_cpu *cpu_buffer,
79324
79325 if (bpage->page == (void *)addr && rb_page_write(bpage) == old_index) {
79326 unsigned long write_mask =
79327 - local_read(&bpage->write) & ~RB_WRITE_MASK;
79328 + local_read_unchecked(&bpage->write) & ~RB_WRITE_MASK;
79329 unsigned long event_length = rb_event_length(event);
79330 /*
79331 * This is on the tail page. It is possible that
79332 @@ -2296,7 +2296,7 @@ rb_try_to_discard(struct ring_buffer_per_cpu *cpu_buffer,
79333 */
79334 old_index += write_mask;
79335 new_index += write_mask;
79336 - index = local_cmpxchg(&bpage->write, old_index, new_index);
79337 + index = local_cmpxchg_unchecked(&bpage->write, old_index, new_index);
79338 if (index == old_index) {
79339 /* update counters */
79340 local_sub(event_length, &cpu_buffer->entries_bytes);
79341 @@ -2670,7 +2670,7 @@ rb_decrement_entry(struct ring_buffer_per_cpu *cpu_buffer,
79342
79343 /* Do the likely case first */
79344 if (likely(bpage->page == (void *)addr)) {
79345 - local_dec(&bpage->entries);
79346 + local_dec_unchecked(&bpage->entries);
79347 return;
79348 }
79349
79350 @@ -2682,7 +2682,7 @@ rb_decrement_entry(struct ring_buffer_per_cpu *cpu_buffer,
79351 start = bpage;
79352 do {
79353 if (bpage->page == (void *)addr) {
79354 - local_dec(&bpage->entries);
79355 + local_dec_unchecked(&bpage->entries);
79356 return;
79357 }
79358 rb_inc_page(cpu_buffer, &bpage);
79359 @@ -2964,7 +2964,7 @@ static inline unsigned long
79360 rb_num_of_entries(struct ring_buffer_per_cpu *cpu_buffer)
79361 {
79362 return local_read(&cpu_buffer->entries) -
79363 - (local_read(&cpu_buffer->overrun) + cpu_buffer->read);
79364 + (local_read_unchecked(&cpu_buffer->overrun) + cpu_buffer->read);
79365 }
79366
79367 /**
79368 @@ -3053,7 +3053,7 @@ unsigned long ring_buffer_overrun_cpu(struct ring_buffer *buffer, int cpu)
79369 return 0;
79370
79371 cpu_buffer = buffer->buffers[cpu];
79372 - ret = local_read(&cpu_buffer->overrun);
79373 + ret = local_read_unchecked(&cpu_buffer->overrun);
79374
79375 return ret;
79376 }
79377 @@ -3076,7 +3076,7 @@ ring_buffer_commit_overrun_cpu(struct ring_buffer *buffer, int cpu)
79378 return 0;
79379
79380 cpu_buffer = buffer->buffers[cpu];
79381 - ret = local_read(&cpu_buffer->commit_overrun);
79382 + ret = local_read_unchecked(&cpu_buffer->commit_overrun);
79383
79384 return ret;
79385 }
79386 @@ -3161,7 +3161,7 @@ unsigned long ring_buffer_overruns(struct ring_buffer *buffer)
79387 /* if you care about this being correct, lock the buffer */
79388 for_each_buffer_cpu(buffer, cpu) {
79389 cpu_buffer = buffer->buffers[cpu];
79390 - overruns += local_read(&cpu_buffer->overrun);
79391 + overruns += local_read_unchecked(&cpu_buffer->overrun);
79392 }
79393
79394 return overruns;
79395 @@ -3337,8 +3337,8 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
79396 /*
79397 * Reset the reader page to size zero.
79398 */
79399 - local_set(&cpu_buffer->reader_page->write, 0);
79400 - local_set(&cpu_buffer->reader_page->entries, 0);
79401 + local_set_unchecked(&cpu_buffer->reader_page->write, 0);
79402 + local_set_unchecked(&cpu_buffer->reader_page->entries, 0);
79403 local_set(&cpu_buffer->reader_page->page->commit, 0);
79404 cpu_buffer->reader_page->real_end = 0;
79405
79406 @@ -3372,7 +3372,7 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
79407 * want to compare with the last_overrun.
79408 */
79409 smp_mb();
79410 - overwrite = local_read(&(cpu_buffer->overrun));
79411 + overwrite = local_read_unchecked(&(cpu_buffer->overrun));
79412
79413 /*
79414 * Here's the tricky part.
79415 @@ -3942,8 +3942,8 @@ rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer)
79416
79417 cpu_buffer->head_page
79418 = list_entry(cpu_buffer->pages, struct buffer_page, list);
79419 - local_set(&cpu_buffer->head_page->write, 0);
79420 - local_set(&cpu_buffer->head_page->entries, 0);
79421 + local_set_unchecked(&cpu_buffer->head_page->write, 0);
79422 + local_set_unchecked(&cpu_buffer->head_page->entries, 0);
79423 local_set(&cpu_buffer->head_page->page->commit, 0);
79424
79425 cpu_buffer->head_page->read = 0;
79426 @@ -3953,14 +3953,14 @@ rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer)
79427
79428 INIT_LIST_HEAD(&cpu_buffer->reader_page->list);
79429 INIT_LIST_HEAD(&cpu_buffer->new_pages);
79430 - local_set(&cpu_buffer->reader_page->write, 0);
79431 - local_set(&cpu_buffer->reader_page->entries, 0);
79432 + local_set_unchecked(&cpu_buffer->reader_page->write, 0);
79433 + local_set_unchecked(&cpu_buffer->reader_page->entries, 0);
79434 local_set(&cpu_buffer->reader_page->page->commit, 0);
79435 cpu_buffer->reader_page->read = 0;
79436
79437 local_set(&cpu_buffer->entries_bytes, 0);
79438 - local_set(&cpu_buffer->overrun, 0);
79439 - local_set(&cpu_buffer->commit_overrun, 0);
79440 + local_set_unchecked(&cpu_buffer->overrun, 0);
79441 + local_set_unchecked(&cpu_buffer->commit_overrun, 0);
79442 local_set(&cpu_buffer->dropped_events, 0);
79443 local_set(&cpu_buffer->entries, 0);
79444 local_set(&cpu_buffer->committing, 0);
79445 @@ -4364,8 +4364,8 @@ int ring_buffer_read_page(struct ring_buffer *buffer,
79446 rb_init_page(bpage);
79447 bpage = reader->page;
79448 reader->page = *data_page;
79449 - local_set(&reader->write, 0);
79450 - local_set(&reader->entries, 0);
79451 + local_set_unchecked(&reader->write, 0);
79452 + local_set_unchecked(&reader->entries, 0);
79453 reader->read = 0;
79454 *data_page = bpage;
79455
79456 diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
79457 index 3f28192..a29e8b0 100644
79458 --- a/kernel/trace/trace.c
79459 +++ b/kernel/trace/trace.c
79460 @@ -2893,7 +2893,7 @@ int trace_keep_overwrite(struct tracer *tracer, u32 mask, int set)
79461 return 0;
79462 }
79463
79464 -int set_tracer_flag(unsigned int mask, int enabled)
79465 +int set_tracer_flag(unsigned long mask, int enabled)
79466 {
79467 /* do nothing if flag is already set */
79468 if (!!(trace_flags & mask) == !!enabled)
79469 @@ -4637,10 +4637,9 @@ static const struct file_operations tracing_dyn_info_fops = {
79470 };
79471 #endif
79472
79473 -static struct dentry *d_tracer;
79474 -
79475 struct dentry *tracing_init_dentry(void)
79476 {
79477 + static struct dentry *d_tracer;
79478 static int once;
79479
79480 if (d_tracer)
79481 @@ -4660,10 +4659,9 @@ struct dentry *tracing_init_dentry(void)
79482 return d_tracer;
79483 }
79484
79485 -static struct dentry *d_percpu;
79486 -
79487 static struct dentry *tracing_dentry_percpu(void)
79488 {
79489 + static struct dentry *d_percpu;
79490 static int once;
79491 struct dentry *d_tracer;
79492
79493 diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
79494 index 2081971..09f861e 100644
79495 --- a/kernel/trace/trace.h
79496 +++ b/kernel/trace/trace.h
79497 @@ -948,7 +948,7 @@ extern const char *__stop___trace_bprintk_fmt[];
79498 void trace_printk_init_buffers(void);
79499 void trace_printk_start_comm(void);
79500 int trace_keep_overwrite(struct tracer *tracer, u32 mask, int set);
79501 -int set_tracer_flag(unsigned int mask, int enabled);
79502 +int set_tracer_flag(unsigned long mask, int enabled);
79503
79504 #undef FTRACE_ENTRY
79505 #define FTRACE_ENTRY(call, struct_name, id, tstruct, print, filter) \
79506 diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
79507 index 57e9b28..eebe41c 100644
79508 --- a/kernel/trace/trace_events.c
79509 +++ b/kernel/trace/trace_events.c
79510 @@ -1329,10 +1329,6 @@ static LIST_HEAD(ftrace_module_file_list);
79511 struct ftrace_module_file_ops {
79512 struct list_head list;
79513 struct module *mod;
79514 - struct file_operations id;
79515 - struct file_operations enable;
79516 - struct file_operations format;
79517 - struct file_operations filter;
79518 };
79519
79520 static struct ftrace_module_file_ops *
79521 @@ -1353,17 +1349,12 @@ trace_create_file_ops(struct module *mod)
79522
79523 file_ops->mod = mod;
79524
79525 - file_ops->id = ftrace_event_id_fops;
79526 - file_ops->id.owner = mod;
79527 -
79528 - file_ops->enable = ftrace_enable_fops;
79529 - file_ops->enable.owner = mod;
79530 -
79531 - file_ops->filter = ftrace_event_filter_fops;
79532 - file_ops->filter.owner = mod;
79533 -
79534 - file_ops->format = ftrace_event_format_fops;
79535 - file_ops->format.owner = mod;
79536 + pax_open_kernel();
79537 + mod->trace_id.owner = mod;
79538 + mod->trace_enable.owner = mod;
79539 + mod->trace_filter.owner = mod;
79540 + mod->trace_format.owner = mod;
79541 + pax_close_kernel();
79542
79543 list_add(&file_ops->list, &ftrace_module_file_list);
79544
79545 @@ -1387,8 +1378,8 @@ static void trace_module_add_events(struct module *mod)
79546
79547 for_each_event(call, start, end) {
79548 __trace_add_event_call(*call, mod,
79549 - &file_ops->id, &file_ops->enable,
79550 - &file_ops->filter, &file_ops->format);
79551 + &mod->trace_id, &mod->trace_enable,
79552 + &mod->trace_filter, &mod->trace_format);
79553 }
79554 }
79555
79556 diff --git a/kernel/trace/trace_mmiotrace.c b/kernel/trace/trace_mmiotrace.c
79557 index fd3c8aa..5f324a6 100644
79558 --- a/kernel/trace/trace_mmiotrace.c
79559 +++ b/kernel/trace/trace_mmiotrace.c
79560 @@ -24,7 +24,7 @@ struct header_iter {
79561 static struct trace_array *mmio_trace_array;
79562 static bool overrun_detected;
79563 static unsigned long prev_overruns;
79564 -static atomic_t dropped_count;
79565 +static atomic_unchecked_t dropped_count;
79566
79567 static void mmio_reset_data(struct trace_array *tr)
79568 {
79569 @@ -127,7 +127,7 @@ static void mmio_close(struct trace_iterator *iter)
79570
79571 static unsigned long count_overruns(struct trace_iterator *iter)
79572 {
79573 - unsigned long cnt = atomic_xchg(&dropped_count, 0);
79574 + unsigned long cnt = atomic_xchg_unchecked(&dropped_count, 0);
79575 unsigned long over = ring_buffer_overruns(iter->tr->buffer);
79576
79577 if (over > prev_overruns)
79578 @@ -317,7 +317,7 @@ static void __trace_mmiotrace_rw(struct trace_array *tr,
79579 event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_RW,
79580 sizeof(*entry), 0, pc);
79581 if (!event) {
79582 - atomic_inc(&dropped_count);
79583 + atomic_inc_unchecked(&dropped_count);
79584 return;
79585 }
79586 entry = ring_buffer_event_data(event);
79587 @@ -347,7 +347,7 @@ static void __trace_mmiotrace_map(struct trace_array *tr,
79588 event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_MAP,
79589 sizeof(*entry), 0, pc);
79590 if (!event) {
79591 - atomic_inc(&dropped_count);
79592 + atomic_inc_unchecked(&dropped_count);
79593 return;
79594 }
79595 entry = ring_buffer_event_data(event);
79596 diff --git a/kernel/trace/trace_output.c b/kernel/trace/trace_output.c
79597 index 697e88d..1a79993 100644
79598 --- a/kernel/trace/trace_output.c
79599 +++ b/kernel/trace/trace_output.c
79600 @@ -278,7 +278,7 @@ int trace_seq_path(struct trace_seq *s, const struct path *path)
79601
79602 p = d_path(path, s->buffer + s->len, PAGE_SIZE - s->len);
79603 if (!IS_ERR(p)) {
79604 - p = mangle_path(s->buffer + s->len, p, "\n");
79605 + p = mangle_path(s->buffer + s->len, p, "\n\\");
79606 if (p) {
79607 s->len = p - s->buffer;
79608 return 1;
79609 @@ -851,14 +851,16 @@ int register_ftrace_event(struct trace_event *event)
79610 goto out;
79611 }
79612
79613 + pax_open_kernel();
79614 if (event->funcs->trace == NULL)
79615 - event->funcs->trace = trace_nop_print;
79616 + *(void **)&event->funcs->trace = trace_nop_print;
79617 if (event->funcs->raw == NULL)
79618 - event->funcs->raw = trace_nop_print;
79619 + *(void **)&event->funcs->raw = trace_nop_print;
79620 if (event->funcs->hex == NULL)
79621 - event->funcs->hex = trace_nop_print;
79622 + *(void **)&event->funcs->hex = trace_nop_print;
79623 if (event->funcs->binary == NULL)
79624 - event->funcs->binary = trace_nop_print;
79625 + *(void **)&event->funcs->binary = trace_nop_print;
79626 + pax_close_kernel();
79627
79628 key = event->type & (EVENT_HASHSIZE - 1);
79629
79630 diff --git a/kernel/trace/trace_stack.c b/kernel/trace/trace_stack.c
79631 index b20428c..4845a10 100644
79632 --- a/kernel/trace/trace_stack.c
79633 +++ b/kernel/trace/trace_stack.c
79634 @@ -68,7 +68,7 @@ check_stack(unsigned long ip, unsigned long *stack)
79635 return;
79636
79637 /* we do not handle interrupt stacks yet */
79638 - if (!object_is_on_stack(stack))
79639 + if (!object_starts_on_stack(stack))
79640 return;
79641
79642 local_irq_save(flags);
79643 diff --git a/kernel/user_namespace.c b/kernel/user_namespace.c
79644 index e134d8f..a018cdd 100644
79645 --- a/kernel/user_namespace.c
79646 +++ b/kernel/user_namespace.c
79647 @@ -853,7 +853,7 @@ static int userns_install(struct nsproxy *nsproxy, void *ns)
79648 if (atomic_read(&current->mm->mm_users) > 1)
79649 return -EINVAL;
79650
79651 - if (current->fs->users != 1)
79652 + if (atomic_read(&current->fs->users) != 1)
79653 return -EINVAL;
79654
79655 if (!ns_capable(user_ns, CAP_SYS_ADMIN))
79656 diff --git a/kernel/utsname_sysctl.c b/kernel/utsname_sysctl.c
79657 index 4f69f9a..7c6f8f8 100644
79658 --- a/kernel/utsname_sysctl.c
79659 +++ b/kernel/utsname_sysctl.c
79660 @@ -47,7 +47,7 @@ static void put_uts(ctl_table *table, int write, void *which)
79661 static int proc_do_uts_string(ctl_table *table, int write,
79662 void __user *buffer, size_t *lenp, loff_t *ppos)
79663 {
79664 - struct ctl_table uts_table;
79665 + ctl_table_no_const uts_table;
79666 int r;
79667 memcpy(&uts_table, table, sizeof(uts_table));
79668 uts_table.data = get_uts(table, write);
79669 diff --git a/kernel/watchdog.c b/kernel/watchdog.c
79670 index 4a94467..80a6f9c 100644
79671 --- a/kernel/watchdog.c
79672 +++ b/kernel/watchdog.c
79673 @@ -526,7 +526,7 @@ int proc_dowatchdog(struct ctl_table *table, int write,
79674 }
79675 #endif /* CONFIG_SYSCTL */
79676
79677 -static struct smp_hotplug_thread watchdog_threads = {
79678 +static struct smp_hotplug_thread watchdog_threads __read_only = {
79679 .store = &softlockup_watchdog,
79680 .thread_should_run = watchdog_should_run,
79681 .thread_fn = watchdog,
79682 diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
79683 index 28be08c..47bab92 100644
79684 --- a/lib/Kconfig.debug
79685 +++ b/lib/Kconfig.debug
79686 @@ -549,7 +549,7 @@ config DEBUG_MUTEXES
79687
79688 config DEBUG_LOCK_ALLOC
79689 bool "Lock debugging: detect incorrect freeing of live locks"
79690 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
79691 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
79692 select DEBUG_SPINLOCK
79693 select DEBUG_MUTEXES
79694 select LOCKDEP
79695 @@ -563,7 +563,7 @@ config DEBUG_LOCK_ALLOC
79696
79697 config PROVE_LOCKING
79698 bool "Lock debugging: prove locking correctness"
79699 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
79700 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
79701 select LOCKDEP
79702 select DEBUG_SPINLOCK
79703 select DEBUG_MUTEXES
79704 @@ -614,7 +614,7 @@ config LOCKDEP
79705
79706 config LOCK_STAT
79707 bool "Lock usage statistics"
79708 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
79709 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
79710 select LOCKDEP
79711 select DEBUG_SPINLOCK
79712 select DEBUG_MUTEXES
79713 @@ -1282,6 +1282,7 @@ config LATENCYTOP
79714 depends on DEBUG_KERNEL
79715 depends on STACKTRACE_SUPPORT
79716 depends on PROC_FS
79717 + depends on !GRKERNSEC_HIDESYM
79718 select FRAME_POINTER if !MIPS && !PPC && !S390 && !MICROBLAZE && !ARM_UNWIND
79719 select KALLSYMS
79720 select KALLSYMS_ALL
79721 @@ -1310,7 +1311,7 @@ config INTERVAL_TREE_TEST
79722
79723 config PROVIDE_OHCI1394_DMA_INIT
79724 bool "Remote debugging over FireWire early on boot"
79725 - depends on PCI && X86
79726 + depends on PCI && X86 && !GRKERNSEC
79727 help
79728 If you want to debug problems which hang or crash the kernel early
79729 on boot and the crashing machine has a FireWire port, you can use
79730 @@ -1339,7 +1340,7 @@ config PROVIDE_OHCI1394_DMA_INIT
79731
79732 config FIREWIRE_OHCI_REMOTE_DMA
79733 bool "Remote debugging over FireWire with firewire-ohci"
79734 - depends on FIREWIRE_OHCI
79735 + depends on FIREWIRE_OHCI && !GRKERNSEC
79736 help
79737 This option lets you use the FireWire bus for remote debugging
79738 with help of the firewire-ohci driver. It enables unfiltered
79739 diff --git a/lib/Makefile b/lib/Makefile
79740 index 6e2cc56..9b13738 100644
79741 --- a/lib/Makefile
79742 +++ b/lib/Makefile
79743 @@ -47,7 +47,7 @@ obj-$(CONFIG_GENERIC_HWEIGHT) += hweight.o
79744
79745 obj-$(CONFIG_BTREE) += btree.o
79746 obj-$(CONFIG_DEBUG_PREEMPT) += smp_processor_id.o
79747 -obj-$(CONFIG_DEBUG_LIST) += list_debug.o
79748 +obj-y += list_debug.o
79749 obj-$(CONFIG_DEBUG_OBJECTS) += debugobjects.o
79750
79751 ifneq ($(CONFIG_HAVE_DEC_LOCK),y)
79752 diff --git a/lib/bitmap.c b/lib/bitmap.c
79753 index 06f7e4f..f3cf2b0 100644
79754 --- a/lib/bitmap.c
79755 +++ b/lib/bitmap.c
79756 @@ -422,7 +422,7 @@ int __bitmap_parse(const char *buf, unsigned int buflen,
79757 {
79758 int c, old_c, totaldigits, ndigits, nchunks, nbits;
79759 u32 chunk;
79760 - const char __user __force *ubuf = (const char __user __force *)buf;
79761 + const char __user *ubuf = (const char __force_user *)buf;
79762
79763 bitmap_zero(maskp, nmaskbits);
79764
79765 @@ -507,7 +507,7 @@ int bitmap_parse_user(const char __user *ubuf,
79766 {
79767 if (!access_ok(VERIFY_READ, ubuf, ulen))
79768 return -EFAULT;
79769 - return __bitmap_parse((const char __force *)ubuf,
79770 + return __bitmap_parse((const char __force_kernel *)ubuf,
79771 ulen, 1, maskp, nmaskbits);
79772
79773 }
79774 @@ -598,7 +598,7 @@ static int __bitmap_parselist(const char *buf, unsigned int buflen,
79775 {
79776 unsigned a, b;
79777 int c, old_c, totaldigits;
79778 - const char __user __force *ubuf = (const char __user __force *)buf;
79779 + const char __user *ubuf = (const char __force_user *)buf;
79780 int exp_digit, in_range;
79781
79782 totaldigits = c = 0;
79783 @@ -698,7 +698,7 @@ int bitmap_parselist_user(const char __user *ubuf,
79784 {
79785 if (!access_ok(VERIFY_READ, ubuf, ulen))
79786 return -EFAULT;
79787 - return __bitmap_parselist((const char __force *)ubuf,
79788 + return __bitmap_parselist((const char __force_kernel *)ubuf,
79789 ulen, 1, maskp, nmaskbits);
79790 }
79791 EXPORT_SYMBOL(bitmap_parselist_user);
79792 diff --git a/lib/bug.c b/lib/bug.c
79793 index 1686034..a9c00c8 100644
79794 --- a/lib/bug.c
79795 +++ b/lib/bug.c
79796 @@ -134,6 +134,8 @@ enum bug_trap_type report_bug(unsigned long bugaddr, struct pt_regs *regs)
79797 return BUG_TRAP_TYPE_NONE;
79798
79799 bug = find_bug(bugaddr);
79800 + if (!bug)
79801 + return BUG_TRAP_TYPE_NONE;
79802
79803 file = NULL;
79804 line = 0;
79805 diff --git a/lib/debugobjects.c b/lib/debugobjects.c
79806 index 37061ed..da83f48 100644
79807 --- a/lib/debugobjects.c
79808 +++ b/lib/debugobjects.c
79809 @@ -286,7 +286,7 @@ static void debug_object_is_on_stack(void *addr, int onstack)
79810 if (limit > 4)
79811 return;
79812
79813 - is_on_stack = object_is_on_stack(addr);
79814 + is_on_stack = object_starts_on_stack(addr);
79815 if (is_on_stack == onstack)
79816 return;
79817
79818 diff --git a/lib/devres.c b/lib/devres.c
79819 index 8235331..5881053 100644
79820 --- a/lib/devres.c
79821 +++ b/lib/devres.c
79822 @@ -81,7 +81,7 @@ EXPORT_SYMBOL(devm_ioremap_nocache);
79823 void devm_iounmap(struct device *dev, void __iomem *addr)
79824 {
79825 WARN_ON(devres_destroy(dev, devm_ioremap_release, devm_ioremap_match,
79826 - (void *)addr));
79827 + (void __force *)addr));
79828 iounmap(addr);
79829 }
79830 EXPORT_SYMBOL(devm_iounmap);
79831 @@ -224,7 +224,7 @@ void devm_ioport_unmap(struct device *dev, void __iomem *addr)
79832 {
79833 ioport_unmap(addr);
79834 WARN_ON(devres_destroy(dev, devm_ioport_map_release,
79835 - devm_ioport_map_match, (void *)addr));
79836 + devm_ioport_map_match, (void __force *)addr));
79837 }
79838 EXPORT_SYMBOL(devm_ioport_unmap);
79839 #endif /* CONFIG_HAS_IOPORT */
79840 diff --git a/lib/div64.c b/lib/div64.c
79841 index a163b6c..9618fa5 100644
79842 --- a/lib/div64.c
79843 +++ b/lib/div64.c
79844 @@ -59,7 +59,7 @@ uint32_t __attribute__((weak)) __div64_32(uint64_t *n, uint32_t base)
79845 EXPORT_SYMBOL(__div64_32);
79846
79847 #ifndef div_s64_rem
79848 -s64 div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
79849 +s64 __intentional_overflow(-1) div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
79850 {
79851 u64 quotient;
79852
79853 @@ -90,7 +90,7 @@ EXPORT_SYMBOL(div_s64_rem);
79854 * 'http://www.hackersdelight.org/HDcode/newCode/divDouble.c.txt'
79855 */
79856 #ifndef div64_u64
79857 -u64 div64_u64(u64 dividend, u64 divisor)
79858 +u64 __intentional_overflow(-1) div64_u64(u64 dividend, u64 divisor)
79859 {
79860 u32 high = divisor >> 32;
79861 u64 quot;
79862 diff --git a/lib/dma-debug.c b/lib/dma-debug.c
79863 index d87a17a..ac0d79a 100644
79864 --- a/lib/dma-debug.c
79865 +++ b/lib/dma-debug.c
79866 @@ -768,7 +768,7 @@ static int dma_debug_device_change(struct notifier_block *nb, unsigned long acti
79867
79868 void dma_debug_add_bus(struct bus_type *bus)
79869 {
79870 - struct notifier_block *nb;
79871 + notifier_block_no_const *nb;
79872
79873 if (global_disable)
79874 return;
79875 @@ -945,7 +945,7 @@ static void check_unmap(struct dma_debug_entry *ref)
79876
79877 static void check_for_stack(struct device *dev, void *addr)
79878 {
79879 - if (object_is_on_stack(addr))
79880 + if (object_starts_on_stack(addr))
79881 err_printk(dev, NULL, "DMA-API: device driver maps memory from"
79882 "stack [addr=%p]\n", addr);
79883 }
79884 diff --git a/lib/inflate.c b/lib/inflate.c
79885 index 013a761..c28f3fc 100644
79886 --- a/lib/inflate.c
79887 +++ b/lib/inflate.c
79888 @@ -269,7 +269,7 @@ static void free(void *where)
79889 malloc_ptr = free_mem_ptr;
79890 }
79891 #else
79892 -#define malloc(a) kmalloc(a, GFP_KERNEL)
79893 +#define malloc(a) kmalloc((a), GFP_KERNEL)
79894 #define free(a) kfree(a)
79895 #endif
79896
79897 diff --git a/lib/ioremap.c b/lib/ioremap.c
79898 index 0c9216c..863bd89 100644
79899 --- a/lib/ioremap.c
79900 +++ b/lib/ioremap.c
79901 @@ -38,7 +38,7 @@ static inline int ioremap_pmd_range(pud_t *pud, unsigned long addr,
79902 unsigned long next;
79903
79904 phys_addr -= addr;
79905 - pmd = pmd_alloc(&init_mm, pud, addr);
79906 + pmd = pmd_alloc_kernel(&init_mm, pud, addr);
79907 if (!pmd)
79908 return -ENOMEM;
79909 do {
79910 @@ -56,7 +56,7 @@ static inline int ioremap_pud_range(pgd_t *pgd, unsigned long addr,
79911 unsigned long next;
79912
79913 phys_addr -= addr;
79914 - pud = pud_alloc(&init_mm, pgd, addr);
79915 + pud = pud_alloc_kernel(&init_mm, pgd, addr);
79916 if (!pud)
79917 return -ENOMEM;
79918 do {
79919 diff --git a/lib/is_single_threaded.c b/lib/is_single_threaded.c
79920 index bd2bea9..6b3c95e 100644
79921 --- a/lib/is_single_threaded.c
79922 +++ b/lib/is_single_threaded.c
79923 @@ -22,6 +22,9 @@ bool current_is_single_threaded(void)
79924 struct task_struct *p, *t;
79925 bool ret;
79926
79927 + if (!mm)
79928 + return true;
79929 +
79930 if (atomic_read(&task->signal->live) != 1)
79931 return false;
79932
79933 diff --git a/lib/kobject.c b/lib/kobject.c
79934 index a654866..a4fd13d 100644
79935 --- a/lib/kobject.c
79936 +++ b/lib/kobject.c
79937 @@ -859,9 +859,9 @@ EXPORT_SYMBOL_GPL(kset_create_and_add);
79938
79939
79940 static DEFINE_SPINLOCK(kobj_ns_type_lock);
79941 -static const struct kobj_ns_type_operations *kobj_ns_ops_tbl[KOBJ_NS_TYPES];
79942 +static const struct kobj_ns_type_operations *kobj_ns_ops_tbl[KOBJ_NS_TYPES] __read_only;
79943
79944 -int kobj_ns_type_register(const struct kobj_ns_type_operations *ops)
79945 +int __init kobj_ns_type_register(const struct kobj_ns_type_operations *ops)
79946 {
79947 enum kobj_ns_type type = ops->type;
79948 int error;
79949 diff --git a/lib/list_debug.c b/lib/list_debug.c
79950 index c24c2f7..06e070b 100644
79951 --- a/lib/list_debug.c
79952 +++ b/lib/list_debug.c
79953 @@ -11,7 +11,9 @@
79954 #include <linux/bug.h>
79955 #include <linux/kernel.h>
79956 #include <linux/rculist.h>
79957 +#include <linux/mm.h>
79958
79959 +#ifdef CONFIG_DEBUG_LIST
79960 /*
79961 * Insert a new entry between two known consecutive entries.
79962 *
79963 @@ -19,21 +21,32 @@
79964 * the prev/next entries already!
79965 */
79966
79967 -void __list_add(struct list_head *new,
79968 - struct list_head *prev,
79969 - struct list_head *next)
79970 +static bool __list_add_debug(struct list_head *new,
79971 + struct list_head *prev,
79972 + struct list_head *next)
79973 {
79974 - WARN(next->prev != prev,
79975 + if (WARN(next->prev != prev,
79976 "list_add corruption. next->prev should be "
79977 "prev (%p), but was %p. (next=%p).\n",
79978 - prev, next->prev, next);
79979 - WARN(prev->next != next,
79980 + prev, next->prev, next) ||
79981 + WARN(prev->next != next,
79982 "list_add corruption. prev->next should be "
79983 "next (%p), but was %p. (prev=%p).\n",
79984 - next, prev->next, prev);
79985 - WARN(new == prev || new == next,
79986 - "list_add double add: new=%p, prev=%p, next=%p.\n",
79987 - new, prev, next);
79988 + next, prev->next, prev) ||
79989 + WARN(new == prev || new == next,
79990 + "list_add double add: new=%p, prev=%p, next=%p.\n",
79991 + new, prev, next))
79992 + return false;
79993 + return true;
79994 +}
79995 +
79996 +void __list_add(struct list_head *new,
79997 + struct list_head *prev,
79998 + struct list_head *next)
79999 +{
80000 + if (!__list_add_debug(new, prev, next))
80001 + return;
80002 +
80003 next->prev = new;
80004 new->next = next;
80005 new->prev = prev;
80006 @@ -41,7 +54,7 @@ void __list_add(struct list_head *new,
80007 }
80008 EXPORT_SYMBOL(__list_add);
80009
80010 -void __list_del_entry(struct list_head *entry)
80011 +static bool __list_del_entry_debug(struct list_head *entry)
80012 {
80013 struct list_head *prev, *next;
80014
80015 @@ -60,9 +73,16 @@ void __list_del_entry(struct list_head *entry)
80016 WARN(next->prev != entry,
80017 "list_del corruption. next->prev should be %p, "
80018 "but was %p\n", entry, next->prev))
80019 + return false;
80020 + return true;
80021 +}
80022 +
80023 +void __list_del_entry(struct list_head *entry)
80024 +{
80025 + if (!__list_del_entry_debug(entry))
80026 return;
80027
80028 - __list_del(prev, next);
80029 + __list_del(entry->prev, entry->next);
80030 }
80031 EXPORT_SYMBOL(__list_del_entry);
80032
80033 @@ -86,15 +106,85 @@ EXPORT_SYMBOL(list_del);
80034 void __list_add_rcu(struct list_head *new,
80035 struct list_head *prev, struct list_head *next)
80036 {
80037 - WARN(next->prev != prev,
80038 - "list_add_rcu corruption. next->prev should be prev (%p), but was %p. (next=%p).\n",
80039 - prev, next->prev, next);
80040 - WARN(prev->next != next,
80041 - "list_add_rcu corruption. prev->next should be next (%p), but was %p. (prev=%p).\n",
80042 - next, prev->next, prev);
80043 + if (!__list_add_debug(new, prev, next))
80044 + return;
80045 +
80046 new->next = next;
80047 new->prev = prev;
80048 rcu_assign_pointer(list_next_rcu(prev), new);
80049 next->prev = new;
80050 }
80051 EXPORT_SYMBOL(__list_add_rcu);
80052 +#endif
80053 +
80054 +void __pax_list_add(struct list_head *new, struct list_head *prev, struct list_head *next)
80055 +{
80056 +#ifdef CONFIG_DEBUG_LIST
80057 + if (!__list_add_debug(new, prev, next))
80058 + return;
80059 +#endif
80060 +
80061 + pax_open_kernel();
80062 + next->prev = new;
80063 + new->next = next;
80064 + new->prev = prev;
80065 + prev->next = new;
80066 + pax_close_kernel();
80067 +}
80068 +EXPORT_SYMBOL(__pax_list_add);
80069 +
80070 +void pax_list_del(struct list_head *entry)
80071 +{
80072 +#ifdef CONFIG_DEBUG_LIST
80073 + if (!__list_del_entry_debug(entry))
80074 + return;
80075 +#endif
80076 +
80077 + pax_open_kernel();
80078 + __list_del(entry->prev, entry->next);
80079 + entry->next = LIST_POISON1;
80080 + entry->prev = LIST_POISON2;
80081 + pax_close_kernel();
80082 +}
80083 +EXPORT_SYMBOL(pax_list_del);
80084 +
80085 +void pax_list_del_init(struct list_head *entry)
80086 +{
80087 + pax_open_kernel();
80088 + __list_del(entry->prev, entry->next);
80089 + INIT_LIST_HEAD(entry);
80090 + pax_close_kernel();
80091 +}
80092 +EXPORT_SYMBOL(pax_list_del_init);
80093 +
80094 +void __pax_list_add_rcu(struct list_head *new,
80095 + struct list_head *prev, struct list_head *next)
80096 +{
80097 +#ifdef CONFIG_DEBUG_LIST
80098 + if (!__list_add_debug(new, prev, next))
80099 + return;
80100 +#endif
80101 +
80102 + pax_open_kernel();
80103 + new->next = next;
80104 + new->prev = prev;
80105 + rcu_assign_pointer(list_next_rcu(prev), new);
80106 + next->prev = new;
80107 + pax_close_kernel();
80108 +}
80109 +EXPORT_SYMBOL(__pax_list_add_rcu);
80110 +
80111 +void pax_list_del_rcu(struct list_head *entry)
80112 +{
80113 +#ifdef CONFIG_DEBUG_LIST
80114 + if (!__list_del_entry_debug(entry))
80115 + return;
80116 +#endif
80117 +
80118 + pax_open_kernel();
80119 + __list_del(entry->prev, entry->next);
80120 + entry->next = LIST_POISON1;
80121 + entry->prev = LIST_POISON2;
80122 + pax_close_kernel();
80123 +}
80124 +EXPORT_SYMBOL(pax_list_del_rcu);
80125 diff --git a/lib/radix-tree.c b/lib/radix-tree.c
80126 index e796429..6e38f9f 100644
80127 --- a/lib/radix-tree.c
80128 +++ b/lib/radix-tree.c
80129 @@ -92,7 +92,7 @@ struct radix_tree_preload {
80130 int nr;
80131 struct radix_tree_node *nodes[RADIX_TREE_PRELOAD_SIZE];
80132 };
80133 -static DEFINE_PER_CPU(struct radix_tree_preload, radix_tree_preloads) = { 0, };
80134 +static DEFINE_PER_CPU(struct radix_tree_preload, radix_tree_preloads);
80135
80136 static inline void *ptr_to_indirect(void *ptr)
80137 {
80138 diff --git a/lib/strncpy_from_user.c b/lib/strncpy_from_user.c
80139 index bb2b201..46abaf9 100644
80140 --- a/lib/strncpy_from_user.c
80141 +++ b/lib/strncpy_from_user.c
80142 @@ -21,7 +21,7 @@
80143 */
80144 static inline long do_strncpy_from_user(char *dst, const char __user *src, long count, unsigned long max)
80145 {
80146 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
80147 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
80148 long res = 0;
80149
80150 /*
80151 diff --git a/lib/strnlen_user.c b/lib/strnlen_user.c
80152 index a28df52..3d55877 100644
80153 --- a/lib/strnlen_user.c
80154 +++ b/lib/strnlen_user.c
80155 @@ -26,7 +26,7 @@
80156 */
80157 static inline long do_strnlen_user(const char __user *src, unsigned long count, unsigned long max)
80158 {
80159 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
80160 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
80161 long align, res = 0;
80162 unsigned long c;
80163
80164 diff --git a/lib/swiotlb.c b/lib/swiotlb.c
80165 index d23762e..e21eab2 100644
80166 --- a/lib/swiotlb.c
80167 +++ b/lib/swiotlb.c
80168 @@ -664,7 +664,7 @@ EXPORT_SYMBOL(swiotlb_alloc_coherent);
80169
80170 void
80171 swiotlb_free_coherent(struct device *hwdev, size_t size, void *vaddr,
80172 - dma_addr_t dev_addr)
80173 + dma_addr_t dev_addr, struct dma_attrs *attrs)
80174 {
80175 phys_addr_t paddr = dma_to_phys(hwdev, dev_addr);
80176
80177 diff --git a/lib/vsprintf.c b/lib/vsprintf.c
80178 index 0d62fd7..b7bc911 100644
80179 --- a/lib/vsprintf.c
80180 +++ b/lib/vsprintf.c
80181 @@ -16,6 +16,9 @@
80182 * - scnprintf and vscnprintf
80183 */
80184
80185 +#ifdef CONFIG_GRKERNSEC_HIDESYM
80186 +#define __INCLUDED_BY_HIDESYM 1
80187 +#endif
80188 #include <stdarg.h>
80189 #include <linux/module.h> /* for KSYM_SYMBOL_LEN */
80190 #include <linux/types.h>
80191 @@ -974,7 +977,11 @@ char *netdev_feature_string(char *buf, char *end, const u8 *addr,
80192 return number(buf, end, *(const netdev_features_t *)addr, spec);
80193 }
80194
80195 +#ifdef CONFIG_GRKERNSEC_HIDESYM
80196 +int kptr_restrict __read_mostly = 2;
80197 +#else
80198 int kptr_restrict __read_mostly;
80199 +#endif
80200
80201 /*
80202 * Show a '%p' thing. A kernel extension is that the '%p' is followed
80203 @@ -988,6 +995,8 @@ int kptr_restrict __read_mostly;
80204 * - 'S' For symbolic direct pointers with offset
80205 * - 's' For symbolic direct pointers without offset
80206 * - 'B' For backtraced symbolic direct pointers with offset
80207 + * - 'A' For symbolic direct pointers with offset approved for use with GRKERNSEC_HIDESYM
80208 + * - 'a' For symbolic direct pointers without offset approved for use with GRKERNSEC_HIDESYM
80209 * - 'R' For decoded struct resource, e.g., [mem 0x0-0x1f 64bit pref]
80210 * - 'r' For raw struct resource, e.g., [mem 0x0-0x1f flags 0x201]
80211 * - 'M' For a 6-byte MAC address, it prints the address in the
80212 @@ -1044,12 +1053,12 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
80213
80214 if (!ptr && *fmt != 'K') {
80215 /*
80216 - * Print (null) with the same width as a pointer so it makes
80217 + * Print (nil) with the same width as a pointer so it makes
80218 * tabular output look nice.
80219 */
80220 if (spec.field_width == -1)
80221 spec.field_width = default_width;
80222 - return string(buf, end, "(null)", spec);
80223 + return string(buf, end, "(nil)", spec);
80224 }
80225
80226 switch (*fmt) {
80227 @@ -1059,6 +1068,12 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
80228 /* Fallthrough */
80229 case 'S':
80230 case 's':
80231 +#ifdef CONFIG_GRKERNSEC_HIDESYM
80232 + break;
80233 +#else
80234 + return symbol_string(buf, end, ptr, spec, *fmt);
80235 +#endif
80236 + case 'A':
80237 case 'B':
80238 return symbol_string(buf, end, ptr, spec, *fmt);
80239 case 'R':
80240 @@ -1099,6 +1114,8 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
80241 va_end(va);
80242 return buf;
80243 }
80244 + case 'P':
80245 + break;
80246 case 'K':
80247 /*
80248 * %pK cannot be used in IRQ context because its test
80249 @@ -1128,6 +1145,21 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
80250 return number(buf, end,
80251 (unsigned long long) *((phys_addr_t *)ptr), spec);
80252 }
80253 +
80254 +#ifdef CONFIG_GRKERNSEC_HIDESYM
80255 + /* 'P' = approved pointers to copy to userland,
80256 + as in the /proc/kallsyms case, as we make it display nothing
80257 + for non-root users, and the real contents for root users
80258 + Also ignore 'K' pointers, since we force their NULLing for non-root users
80259 + above
80260 + */
80261 + if ((unsigned long)ptr > TASK_SIZE && *fmt != 'P' && *fmt != 'K' && is_usercopy_object(buf)) {
80262 + printk(KERN_ALERT "grsec: kernel infoleak detected! Please report this log to spender@grsecurity.net.\n");
80263 + dump_stack();
80264 + ptr = NULL;
80265 + }
80266 +#endif
80267 +
80268 spec.flags |= SMALL;
80269 if (spec.field_width == -1) {
80270 spec.field_width = default_width;
80271 @@ -1849,11 +1881,11 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
80272 typeof(type) value; \
80273 if (sizeof(type) == 8) { \
80274 args = PTR_ALIGN(args, sizeof(u32)); \
80275 - *(u32 *)&value = *(u32 *)args; \
80276 - *((u32 *)&value + 1) = *(u32 *)(args + 4); \
80277 + *(u32 *)&value = *(const u32 *)args; \
80278 + *((u32 *)&value + 1) = *(const u32 *)(args + 4); \
80279 } else { \
80280 args = PTR_ALIGN(args, sizeof(type)); \
80281 - value = *(typeof(type) *)args; \
80282 + value = *(const typeof(type) *)args; \
80283 } \
80284 args += sizeof(type); \
80285 value; \
80286 @@ -1916,7 +1948,7 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
80287 case FORMAT_TYPE_STR: {
80288 const char *str_arg = args;
80289 args += strlen(str_arg) + 1;
80290 - str = string(str, end, (char *)str_arg, spec);
80291 + str = string(str, end, str_arg, spec);
80292 break;
80293 }
80294
80295 diff --git a/localversion-grsec b/localversion-grsec
80296 new file mode 100644
80297 index 0000000..7cd6065
80298 --- /dev/null
80299 +++ b/localversion-grsec
80300 @@ -0,0 +1 @@
80301 +-grsec
80302 diff --git a/mm/Kconfig b/mm/Kconfig
80303 index 3bea74f..e821c99 100644
80304 --- a/mm/Kconfig
80305 +++ b/mm/Kconfig
80306 @@ -311,10 +311,10 @@ config KSM
80307 root has set /sys/kernel/mm/ksm/run to 1 (if CONFIG_SYSFS is set).
80308
80309 config DEFAULT_MMAP_MIN_ADDR
80310 - int "Low address space to protect from user allocation"
80311 + int "Low address space to protect from user allocation"
80312 depends on MMU
80313 - default 4096
80314 - help
80315 + default 65536
80316 + help
80317 This is the portion of low virtual memory which should be protected
80318 from userspace allocation. Keeping a user from writing to low pages
80319 can help reduce the impact of kernel NULL pointer bugs.
80320 @@ -345,7 +345,7 @@ config MEMORY_FAILURE
80321
80322 config HWPOISON_INJECT
80323 tristate "HWPoison pages injector"
80324 - depends on MEMORY_FAILURE && DEBUG_KERNEL && PROC_FS
80325 + depends on MEMORY_FAILURE && DEBUG_KERNEL && PROC_FS && !GRKERNSEC
80326 select PROC_PAGE_MONITOR
80327
80328 config NOMMU_INITIAL_TRIM_EXCESS
80329 diff --git a/mm/filemap.c b/mm/filemap.c
80330 index e1979fd..dda5120 100644
80331 --- a/mm/filemap.c
80332 +++ b/mm/filemap.c
80333 @@ -1748,7 +1748,7 @@ int generic_file_mmap(struct file * file, struct vm_area_struct * vma)
80334 struct address_space *mapping = file->f_mapping;
80335
80336 if (!mapping->a_ops->readpage)
80337 - return -ENOEXEC;
80338 + return -ENODEV;
80339 file_accessed(file);
80340 vma->vm_ops = &generic_file_vm_ops;
80341 return 0;
80342 @@ -2088,6 +2088,7 @@ inline int generic_write_checks(struct file *file, loff_t *pos, size_t *count, i
80343 *pos = i_size_read(inode);
80344
80345 if (limit != RLIM_INFINITY) {
80346 + gr_learn_resource(current, RLIMIT_FSIZE,*pos, 0);
80347 if (*pos >= limit) {
80348 send_sig(SIGXFSZ, current, 0);
80349 return -EFBIG;
80350 diff --git a/mm/fremap.c b/mm/fremap.c
80351 index 87da359..3f41cb1 100644
80352 --- a/mm/fremap.c
80353 +++ b/mm/fremap.c
80354 @@ -158,6 +158,11 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size,
80355 retry:
80356 vma = find_vma(mm, start);
80357
80358 +#ifdef CONFIG_PAX_SEGMEXEC
80359 + if (vma && (mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_flags & VM_MAYEXEC))
80360 + goto out;
80361 +#endif
80362 +
80363 /*
80364 * Make sure the vma is shared, that it supports prefaulting,
80365 * and that the remapped range is valid and fully within
80366 diff --git a/mm/highmem.c b/mm/highmem.c
80367 index b32b70c..e512eb0 100644
80368 --- a/mm/highmem.c
80369 +++ b/mm/highmem.c
80370 @@ -138,8 +138,9 @@ static void flush_all_zero_pkmaps(void)
80371 * So no dangers, even with speculative execution.
80372 */
80373 page = pte_page(pkmap_page_table[i]);
80374 + pax_open_kernel();
80375 pte_clear(&init_mm, PKMAP_ADDR(i), &pkmap_page_table[i]);
80376 -
80377 + pax_close_kernel();
80378 set_page_address(page, NULL);
80379 need_flush = 1;
80380 }
80381 @@ -198,9 +199,11 @@ start:
80382 }
80383 }
80384 vaddr = PKMAP_ADDR(last_pkmap_nr);
80385 +
80386 + pax_open_kernel();
80387 set_pte_at(&init_mm, vaddr,
80388 &(pkmap_page_table[last_pkmap_nr]), mk_pte(page, kmap_prot));
80389 -
80390 + pax_close_kernel();
80391 pkmap_count[last_pkmap_nr] = 1;
80392 set_page_address(page, (void *)vaddr);
80393
80394 diff --git a/mm/hugetlb.c b/mm/hugetlb.c
80395 index 1a12f5b..a85b8fc 100644
80396 --- a/mm/hugetlb.c
80397 +++ b/mm/hugetlb.c
80398 @@ -2005,15 +2005,17 @@ static int hugetlb_sysctl_handler_common(bool obey_mempolicy,
80399 struct hstate *h = &default_hstate;
80400 unsigned long tmp;
80401 int ret;
80402 + ctl_table_no_const hugetlb_table;
80403
80404 tmp = h->max_huge_pages;
80405
80406 if (write && h->order >= MAX_ORDER)
80407 return -EINVAL;
80408
80409 - table->data = &tmp;
80410 - table->maxlen = sizeof(unsigned long);
80411 - ret = proc_doulongvec_minmax(table, write, buffer, length, ppos);
80412 + hugetlb_table = *table;
80413 + hugetlb_table.data = &tmp;
80414 + hugetlb_table.maxlen = sizeof(unsigned long);
80415 + ret = proc_doulongvec_minmax(&hugetlb_table, write, buffer, length, ppos);
80416 if (ret)
80417 goto out;
80418
80419 @@ -2070,15 +2072,17 @@ int hugetlb_overcommit_handler(struct ctl_table *table, int write,
80420 struct hstate *h = &default_hstate;
80421 unsigned long tmp;
80422 int ret;
80423 + ctl_table_no_const hugetlb_table;
80424
80425 tmp = h->nr_overcommit_huge_pages;
80426
80427 if (write && h->order >= MAX_ORDER)
80428 return -EINVAL;
80429
80430 - table->data = &tmp;
80431 - table->maxlen = sizeof(unsigned long);
80432 - ret = proc_doulongvec_minmax(table, write, buffer, length, ppos);
80433 + hugetlb_table = *table;
80434 + hugetlb_table.data = &tmp;
80435 + hugetlb_table.maxlen = sizeof(unsigned long);
80436 + ret = proc_doulongvec_minmax(&hugetlb_table, write, buffer, length, ppos);
80437 if (ret)
80438 goto out;
80439
80440 @@ -2512,6 +2516,27 @@ static int unmap_ref_private(struct mm_struct *mm, struct vm_area_struct *vma,
80441 return 1;
80442 }
80443
80444 +#ifdef CONFIG_PAX_SEGMEXEC
80445 +static void pax_mirror_huge_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m)
80446 +{
80447 + struct mm_struct *mm = vma->vm_mm;
80448 + struct vm_area_struct *vma_m;
80449 + unsigned long address_m;
80450 + pte_t *ptep_m;
80451 +
80452 + vma_m = pax_find_mirror_vma(vma);
80453 + if (!vma_m)
80454 + return;
80455 +
80456 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
80457 + address_m = address + SEGMEXEC_TASK_SIZE;
80458 + ptep_m = huge_pte_offset(mm, address_m & HPAGE_MASK);
80459 + get_page(page_m);
80460 + hugepage_add_anon_rmap(page_m, vma_m, address_m);
80461 + set_huge_pte_at(mm, address_m, ptep_m, make_huge_pte(vma_m, page_m, 0));
80462 +}
80463 +#endif
80464 +
80465 /*
80466 * Hugetlb_cow() should be called with page lock of the original hugepage held.
80467 * Called with hugetlb_instantiation_mutex held and pte_page locked so we
80468 @@ -2630,6 +2655,11 @@ retry_avoidcopy:
80469 make_huge_pte(vma, new_page, 1));
80470 page_remove_rmap(old_page);
80471 hugepage_add_new_anon_rmap(new_page, vma, address);
80472 +
80473 +#ifdef CONFIG_PAX_SEGMEXEC
80474 + pax_mirror_huge_pte(vma, address, new_page);
80475 +#endif
80476 +
80477 /* Make the old page be freed below */
80478 new_page = old_page;
80479 }
80480 @@ -2788,6 +2818,10 @@ retry:
80481 && (vma->vm_flags & VM_SHARED)));
80482 set_huge_pte_at(mm, address, ptep, new_pte);
80483
80484 +#ifdef CONFIG_PAX_SEGMEXEC
80485 + pax_mirror_huge_pte(vma, address, page);
80486 +#endif
80487 +
80488 if ((flags & FAULT_FLAG_WRITE) && !(vma->vm_flags & VM_SHARED)) {
80489 /* Optimization, do the COW without a second fault */
80490 ret = hugetlb_cow(mm, vma, address, ptep, new_pte, page);
80491 @@ -2817,6 +2851,10 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
80492 static DEFINE_MUTEX(hugetlb_instantiation_mutex);
80493 struct hstate *h = hstate_vma(vma);
80494
80495 +#ifdef CONFIG_PAX_SEGMEXEC
80496 + struct vm_area_struct *vma_m;
80497 +#endif
80498 +
80499 address &= huge_page_mask(h);
80500
80501 ptep = huge_pte_offset(mm, address);
80502 @@ -2830,6 +2868,26 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
80503 VM_FAULT_SET_HINDEX(hstate_index(h));
80504 }
80505
80506 +#ifdef CONFIG_PAX_SEGMEXEC
80507 + vma_m = pax_find_mirror_vma(vma);
80508 + if (vma_m) {
80509 + unsigned long address_m;
80510 +
80511 + if (vma->vm_start > vma_m->vm_start) {
80512 + address_m = address;
80513 + address -= SEGMEXEC_TASK_SIZE;
80514 + vma = vma_m;
80515 + h = hstate_vma(vma);
80516 + } else
80517 + address_m = address + SEGMEXEC_TASK_SIZE;
80518 +
80519 + if (!huge_pte_alloc(mm, address_m, huge_page_size(h)))
80520 + return VM_FAULT_OOM;
80521 + address_m &= HPAGE_MASK;
80522 + unmap_hugepage_range(vma, address_m, address_m + HPAGE_SIZE, NULL);
80523 + }
80524 +#endif
80525 +
80526 ptep = huge_pte_alloc(mm, address, huge_page_size(h));
80527 if (!ptep)
80528 return VM_FAULT_OOM;
80529 diff --git a/mm/internal.h b/mm/internal.h
80530 index 8562de0..7fdfe92 100644
80531 --- a/mm/internal.h
80532 +++ b/mm/internal.h
80533 @@ -100,6 +100,7 @@ extern pmd_t *mm_find_pmd(struct mm_struct *mm, unsigned long address);
80534 * in mm/page_alloc.c
80535 */
80536 extern void __free_pages_bootmem(struct page *page, unsigned int order);
80537 +extern void free_compound_page(struct page *page);
80538 extern void prep_compound_page(struct page *page, unsigned long order);
80539 #ifdef CONFIG_MEMORY_FAILURE
80540 extern bool is_free_buddy_page(struct page *page);
80541 diff --git a/mm/kmemleak.c b/mm/kmemleak.c
80542 index c8d7f31..2dbeffd 100644
80543 --- a/mm/kmemleak.c
80544 +++ b/mm/kmemleak.c
80545 @@ -363,7 +363,7 @@ static void print_unreferenced(struct seq_file *seq,
80546
80547 for (i = 0; i < object->trace_len; i++) {
80548 void *ptr = (void *)object->trace[i];
80549 - seq_printf(seq, " [<%p>] %pS\n", ptr, ptr);
80550 + seq_printf(seq, " [<%pP>] %pA\n", ptr, ptr);
80551 }
80552 }
80553
80554 @@ -1851,7 +1851,7 @@ static int __init kmemleak_late_init(void)
80555 return -ENOMEM;
80556 }
80557
80558 - dentry = debugfs_create_file("kmemleak", S_IRUGO, NULL, NULL,
80559 + dentry = debugfs_create_file("kmemleak", S_IRUSR, NULL, NULL,
80560 &kmemleak_fops);
80561 if (!dentry)
80562 pr_warning("Failed to create the debugfs kmemleak file\n");
80563 diff --git a/mm/maccess.c b/mm/maccess.c
80564 index d53adf9..03a24bf 100644
80565 --- a/mm/maccess.c
80566 +++ b/mm/maccess.c
80567 @@ -26,7 +26,7 @@ long __probe_kernel_read(void *dst, const void *src, size_t size)
80568 set_fs(KERNEL_DS);
80569 pagefault_disable();
80570 ret = __copy_from_user_inatomic(dst,
80571 - (__force const void __user *)src, size);
80572 + (const void __force_user *)src, size);
80573 pagefault_enable();
80574 set_fs(old_fs);
80575
80576 @@ -53,7 +53,7 @@ long __probe_kernel_write(void *dst, const void *src, size_t size)
80577
80578 set_fs(KERNEL_DS);
80579 pagefault_disable();
80580 - ret = __copy_to_user_inatomic((__force void __user *)dst, src, size);
80581 + ret = __copy_to_user_inatomic((void __force_user *)dst, src, size);
80582 pagefault_enable();
80583 set_fs(old_fs);
80584
80585 diff --git a/mm/madvise.c b/mm/madvise.c
80586 index c58c94b..86ec14e 100644
80587 --- a/mm/madvise.c
80588 +++ b/mm/madvise.c
80589 @@ -51,6 +51,10 @@ static long madvise_behavior(struct vm_area_struct * vma,
80590 pgoff_t pgoff;
80591 unsigned long new_flags = vma->vm_flags;
80592
80593 +#ifdef CONFIG_PAX_SEGMEXEC
80594 + struct vm_area_struct *vma_m;
80595 +#endif
80596 +
80597 switch (behavior) {
80598 case MADV_NORMAL:
80599 new_flags = new_flags & ~VM_RAND_READ & ~VM_SEQ_READ;
80600 @@ -126,6 +130,13 @@ success:
80601 /*
80602 * vm_flags is protected by the mmap_sem held in write mode.
80603 */
80604 +
80605 +#ifdef CONFIG_PAX_SEGMEXEC
80606 + vma_m = pax_find_mirror_vma(vma);
80607 + if (vma_m)
80608 + vma_m->vm_flags = new_flags & ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT);
80609 +#endif
80610 +
80611 vma->vm_flags = new_flags;
80612
80613 out:
80614 @@ -274,6 +285,11 @@ static long madvise_dontneed(struct vm_area_struct * vma,
80615 struct vm_area_struct ** prev,
80616 unsigned long start, unsigned long end)
80617 {
80618 +
80619 +#ifdef CONFIG_PAX_SEGMEXEC
80620 + struct vm_area_struct *vma_m;
80621 +#endif
80622 +
80623 *prev = vma;
80624 if (vma->vm_flags & (VM_LOCKED|VM_HUGETLB|VM_PFNMAP))
80625 return -EINVAL;
80626 @@ -286,6 +302,21 @@ static long madvise_dontneed(struct vm_area_struct * vma,
80627 zap_page_range(vma, start, end - start, &details);
80628 } else
80629 zap_page_range(vma, start, end - start, NULL);
80630 +
80631 +#ifdef CONFIG_PAX_SEGMEXEC
80632 + vma_m = pax_find_mirror_vma(vma);
80633 + if (vma_m) {
80634 + if (unlikely(vma->vm_flags & VM_NONLINEAR)) {
80635 + struct zap_details details = {
80636 + .nonlinear_vma = vma_m,
80637 + .last_index = ULONG_MAX,
80638 + };
80639 + zap_page_range(vma, start + SEGMEXEC_TASK_SIZE, end - start, &details);
80640 + } else
80641 + zap_page_range(vma, start + SEGMEXEC_TASK_SIZE, end - start, NULL);
80642 + }
80643 +#endif
80644 +
80645 return 0;
80646 }
80647
80648 @@ -491,6 +522,16 @@ SYSCALL_DEFINE3(madvise, unsigned long, start, size_t, len_in, int, behavior)
80649 if (end < start)
80650 goto out;
80651
80652 +#ifdef CONFIG_PAX_SEGMEXEC
80653 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
80654 + if (end > SEGMEXEC_TASK_SIZE)
80655 + goto out;
80656 + } else
80657 +#endif
80658 +
80659 + if (end > TASK_SIZE)
80660 + goto out;
80661 +
80662 error = 0;
80663 if (end == start)
80664 goto out;
80665 diff --git a/mm/memory-failure.c b/mm/memory-failure.c
80666 index df0694c..bc95539 100644
80667 --- a/mm/memory-failure.c
80668 +++ b/mm/memory-failure.c
80669 @@ -61,7 +61,7 @@ int sysctl_memory_failure_early_kill __read_mostly = 0;
80670
80671 int sysctl_memory_failure_recovery __read_mostly = 1;
80672
80673 -atomic_long_t num_poisoned_pages __read_mostly = ATOMIC_LONG_INIT(0);
80674 +atomic_long_unchecked_t num_poisoned_pages __read_mostly = ATOMIC_LONG_INIT(0);
80675
80676 #if defined(CONFIG_HWPOISON_INJECT) || defined(CONFIG_HWPOISON_INJECT_MODULE)
80677
80678 @@ -202,7 +202,7 @@ static int kill_proc(struct task_struct *t, unsigned long addr, int trapno,
80679 pfn, t->comm, t->pid);
80680 si.si_signo = SIGBUS;
80681 si.si_errno = 0;
80682 - si.si_addr = (void *)addr;
80683 + si.si_addr = (void __user *)addr;
80684 #ifdef __ARCH_SI_TRAPNO
80685 si.si_trapno = trapno;
80686 #endif
80687 @@ -760,7 +760,7 @@ static struct page_state {
80688 unsigned long res;
80689 char *msg;
80690 int (*action)(struct page *p, unsigned long pfn);
80691 -} error_states[] = {
80692 +} __do_const error_states[] = {
80693 { reserved, reserved, "reserved kernel", me_kernel },
80694 /*
80695 * free pages are specially detected outside this table:
80696 @@ -1051,7 +1051,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
80697 nr_pages = 1 << compound_order(hpage);
80698 else /* normal page or thp */
80699 nr_pages = 1;
80700 - atomic_long_add(nr_pages, &num_poisoned_pages);
80701 + atomic_long_add_unchecked(nr_pages, &num_poisoned_pages);
80702
80703 /*
80704 * We need/can do nothing about count=0 pages.
80705 @@ -1081,7 +1081,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
80706 if (!PageHWPoison(hpage)
80707 || (hwpoison_filter(p) && TestClearPageHWPoison(p))
80708 || (p != hpage && TestSetPageHWPoison(hpage))) {
80709 - atomic_long_sub(nr_pages, &num_poisoned_pages);
80710 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
80711 return 0;
80712 }
80713 set_page_hwpoison_huge_page(hpage);
80714 @@ -1148,7 +1148,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
80715 }
80716 if (hwpoison_filter(p)) {
80717 if (TestClearPageHWPoison(p))
80718 - atomic_long_sub(nr_pages, &num_poisoned_pages);
80719 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
80720 unlock_page(hpage);
80721 put_page(hpage);
80722 return 0;
80723 @@ -1350,7 +1350,7 @@ int unpoison_memory(unsigned long pfn)
80724 return 0;
80725 }
80726 if (TestClearPageHWPoison(p))
80727 - atomic_long_sub(nr_pages, &num_poisoned_pages);
80728 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
80729 pr_info("MCE: Software-unpoisoned free page %#lx\n", pfn);
80730 return 0;
80731 }
80732 @@ -1364,7 +1364,7 @@ int unpoison_memory(unsigned long pfn)
80733 */
80734 if (TestClearPageHWPoison(page)) {
80735 pr_info("MCE: Software-unpoisoned page %#lx\n", pfn);
80736 - atomic_long_sub(nr_pages, &num_poisoned_pages);
80737 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
80738 freeit = 1;
80739 if (PageHuge(page))
80740 clear_page_hwpoison_huge_page(page);
80741 @@ -1491,7 +1491,7 @@ static int soft_offline_huge_page(struct page *page, int flags)
80742 } else {
80743 set_page_hwpoison_huge_page(hpage);
80744 dequeue_hwpoisoned_huge_page(hpage);
80745 - atomic_long_add(1 << compound_trans_order(hpage),
80746 + atomic_long_add_unchecked(1 << compound_trans_order(hpage),
80747 &num_poisoned_pages);
80748 }
80749 /* keep elevated page count for bad page */
80750 @@ -1552,11 +1552,11 @@ int soft_offline_page(struct page *page, int flags)
80751 if (PageHuge(page)) {
80752 set_page_hwpoison_huge_page(hpage);
80753 dequeue_hwpoisoned_huge_page(hpage);
80754 - atomic_long_add(1 << compound_trans_order(hpage),
80755 + atomic_long_add_unchecked(1 << compound_trans_order(hpage),
80756 &num_poisoned_pages);
80757 } else {
80758 SetPageHWPoison(page);
80759 - atomic_long_inc(&num_poisoned_pages);
80760 + atomic_long_inc_unchecked(&num_poisoned_pages);
80761 }
80762 }
80763 /* keep elevated page count for bad page */
80764 @@ -1596,7 +1596,7 @@ static int __soft_offline_page(struct page *page, int flags)
80765 put_page(page);
80766 pr_info("soft_offline: %#lx: invalidated\n", pfn);
80767 SetPageHWPoison(page);
80768 - atomic_long_inc(&num_poisoned_pages);
80769 + atomic_long_inc_unchecked(&num_poisoned_pages);
80770 return 0;
80771 }
80772
80773 @@ -1626,7 +1626,7 @@ static int __soft_offline_page(struct page *page, int flags)
80774 ret = -EIO;
80775 } else {
80776 SetPageHWPoison(page);
80777 - atomic_long_inc(&num_poisoned_pages);
80778 + atomic_long_inc_unchecked(&num_poisoned_pages);
80779 }
80780 } else {
80781 pr_info("soft offline: %#lx: isolation failed: %d, page count %d, type %lx\n",
80782 diff --git a/mm/memory.c b/mm/memory.c
80783 index ba94dec..08ffe0d 100644
80784 --- a/mm/memory.c
80785 +++ b/mm/memory.c
80786 @@ -438,6 +438,7 @@ static inline void free_pmd_range(struct mmu_gather *tlb, pud_t *pud,
80787 free_pte_range(tlb, pmd, addr);
80788 } while (pmd++, addr = next, addr != end);
80789
80790 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_PER_CPU_PGD)
80791 start &= PUD_MASK;
80792 if (start < floor)
80793 return;
80794 @@ -452,6 +453,8 @@ static inline void free_pmd_range(struct mmu_gather *tlb, pud_t *pud,
80795 pmd = pmd_offset(pud, start);
80796 pud_clear(pud);
80797 pmd_free_tlb(tlb, pmd, start);
80798 +#endif
80799 +
80800 }
80801
80802 static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
80803 @@ -471,6 +474,7 @@ static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
80804 free_pmd_range(tlb, pud, addr, next, floor, ceiling);
80805 } while (pud++, addr = next, addr != end);
80806
80807 +#if !defined(CONFIG_X86_64) || !defined(CONFIG_PAX_PER_CPU_PGD)
80808 start &= PGDIR_MASK;
80809 if (start < floor)
80810 return;
80811 @@ -485,6 +489,8 @@ static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
80812 pud = pud_offset(pgd, start);
80813 pgd_clear(pgd);
80814 pud_free_tlb(tlb, pud, start);
80815 +#endif
80816 +
80817 }
80818
80819 /*
80820 @@ -1644,12 +1650,6 @@ no_page_table:
80821 return page;
80822 }
80823
80824 -static inline int stack_guard_page(struct vm_area_struct *vma, unsigned long addr)
80825 -{
80826 - return stack_guard_page_start(vma, addr) ||
80827 - stack_guard_page_end(vma, addr+PAGE_SIZE);
80828 -}
80829 -
80830 /**
80831 * __get_user_pages() - pin user pages in memory
80832 * @tsk: task_struct of target task
80833 @@ -1736,10 +1736,10 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
80834
80835 i = 0;
80836
80837 - do {
80838 + while (nr_pages) {
80839 struct vm_area_struct *vma;
80840
80841 - vma = find_extend_vma(mm, start);
80842 + vma = find_vma(mm, start);
80843 if (!vma && in_gate_area(mm, start)) {
80844 unsigned long pg = start & PAGE_MASK;
80845 pgd_t *pgd;
80846 @@ -1788,7 +1788,7 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
80847 goto next_page;
80848 }
80849
80850 - if (!vma ||
80851 + if (!vma || start < vma->vm_start ||
80852 (vma->vm_flags & (VM_IO | VM_PFNMAP)) ||
80853 !(vm_flags & vma->vm_flags))
80854 return i ? : -EFAULT;
80855 @@ -1817,11 +1817,6 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
80856 int ret;
80857 unsigned int fault_flags = 0;
80858
80859 - /* For mlock, just skip the stack guard page. */
80860 - if (foll_flags & FOLL_MLOCK) {
80861 - if (stack_guard_page(vma, start))
80862 - goto next_page;
80863 - }
80864 if (foll_flags & FOLL_WRITE)
80865 fault_flags |= FAULT_FLAG_WRITE;
80866 if (nonblocking)
80867 @@ -1901,7 +1896,7 @@ next_page:
80868 start += page_increm * PAGE_SIZE;
80869 nr_pages -= page_increm;
80870 } while (nr_pages && start < vma->vm_end);
80871 - } while (nr_pages);
80872 + }
80873 return i;
80874 }
80875 EXPORT_SYMBOL(__get_user_pages);
80876 @@ -2108,6 +2103,10 @@ static int insert_page(struct vm_area_struct *vma, unsigned long addr,
80877 page_add_file_rmap(page);
80878 set_pte_at(mm, addr, pte, mk_pte(page, prot));
80879
80880 +#ifdef CONFIG_PAX_SEGMEXEC
80881 + pax_mirror_file_pte(vma, addr, page, ptl);
80882 +#endif
80883 +
80884 retval = 0;
80885 pte_unmap_unlock(pte, ptl);
80886 return retval;
80887 @@ -2152,9 +2151,21 @@ int vm_insert_page(struct vm_area_struct *vma, unsigned long addr,
80888 if (!page_count(page))
80889 return -EINVAL;
80890 if (!(vma->vm_flags & VM_MIXEDMAP)) {
80891 +
80892 +#ifdef CONFIG_PAX_SEGMEXEC
80893 + struct vm_area_struct *vma_m;
80894 +#endif
80895 +
80896 BUG_ON(down_read_trylock(&vma->vm_mm->mmap_sem));
80897 BUG_ON(vma->vm_flags & VM_PFNMAP);
80898 vma->vm_flags |= VM_MIXEDMAP;
80899 +
80900 +#ifdef CONFIG_PAX_SEGMEXEC
80901 + vma_m = pax_find_mirror_vma(vma);
80902 + if (vma_m)
80903 + vma_m->vm_flags |= VM_MIXEDMAP;
80904 +#endif
80905 +
80906 }
80907 return insert_page(vma, addr, page, vma->vm_page_prot);
80908 }
80909 @@ -2237,6 +2248,7 @@ int vm_insert_mixed(struct vm_area_struct *vma, unsigned long addr,
80910 unsigned long pfn)
80911 {
80912 BUG_ON(!(vma->vm_flags & VM_MIXEDMAP));
80913 + BUG_ON(vma->vm_mirror);
80914
80915 if (addr < vma->vm_start || addr >= vma->vm_end)
80916 return -EFAULT;
80917 @@ -2484,7 +2496,9 @@ static int apply_to_pmd_range(struct mm_struct *mm, pud_t *pud,
80918
80919 BUG_ON(pud_huge(*pud));
80920
80921 - pmd = pmd_alloc(mm, pud, addr);
80922 + pmd = (mm == &init_mm) ?
80923 + pmd_alloc_kernel(mm, pud, addr) :
80924 + pmd_alloc(mm, pud, addr);
80925 if (!pmd)
80926 return -ENOMEM;
80927 do {
80928 @@ -2504,7 +2518,9 @@ static int apply_to_pud_range(struct mm_struct *mm, pgd_t *pgd,
80929 unsigned long next;
80930 int err;
80931
80932 - pud = pud_alloc(mm, pgd, addr);
80933 + pud = (mm == &init_mm) ?
80934 + pud_alloc_kernel(mm, pgd, addr) :
80935 + pud_alloc(mm, pgd, addr);
80936 if (!pud)
80937 return -ENOMEM;
80938 do {
80939 @@ -2592,6 +2608,186 @@ static inline void cow_user_page(struct page *dst, struct page *src, unsigned lo
80940 copy_user_highpage(dst, src, va, vma);
80941 }
80942
80943 +#ifdef CONFIG_PAX_SEGMEXEC
80944 +static void pax_unmap_mirror_pte(struct vm_area_struct *vma, unsigned long address, pmd_t *pmd)
80945 +{
80946 + struct mm_struct *mm = vma->vm_mm;
80947 + spinlock_t *ptl;
80948 + pte_t *pte, entry;
80949 +
80950 + pte = pte_offset_map_lock(mm, pmd, address, &ptl);
80951 + entry = *pte;
80952 + if (!pte_present(entry)) {
80953 + if (!pte_none(entry)) {
80954 + BUG_ON(pte_file(entry));
80955 + free_swap_and_cache(pte_to_swp_entry(entry));
80956 + pte_clear_not_present_full(mm, address, pte, 0);
80957 + }
80958 + } else {
80959 + struct page *page;
80960 +
80961 + flush_cache_page(vma, address, pte_pfn(entry));
80962 + entry = ptep_clear_flush(vma, address, pte);
80963 + BUG_ON(pte_dirty(entry));
80964 + page = vm_normal_page(vma, address, entry);
80965 + if (page) {
80966 + update_hiwater_rss(mm);
80967 + if (PageAnon(page))
80968 + dec_mm_counter_fast(mm, MM_ANONPAGES);
80969 + else
80970 + dec_mm_counter_fast(mm, MM_FILEPAGES);
80971 + page_remove_rmap(page);
80972 + page_cache_release(page);
80973 + }
80974 + }
80975 + pte_unmap_unlock(pte, ptl);
80976 +}
80977 +
80978 +/* PaX: if vma is mirrored, synchronize the mirror's PTE
80979 + *
80980 + * the ptl of the lower mapped page is held on entry and is not released on exit
80981 + * or inside to ensure atomic changes to the PTE states (swapout, mremap, munmap, etc)
80982 + */
80983 +static void pax_mirror_anon_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl)
80984 +{
80985 + struct mm_struct *mm = vma->vm_mm;
80986 + unsigned long address_m;
80987 + spinlock_t *ptl_m;
80988 + struct vm_area_struct *vma_m;
80989 + pmd_t *pmd_m;
80990 + pte_t *pte_m, entry_m;
80991 +
80992 + BUG_ON(!page_m || !PageAnon(page_m));
80993 +
80994 + vma_m = pax_find_mirror_vma(vma);
80995 + if (!vma_m)
80996 + return;
80997 +
80998 + BUG_ON(!PageLocked(page_m));
80999 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
81000 + address_m = address + SEGMEXEC_TASK_SIZE;
81001 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
81002 + pte_m = pte_offset_map(pmd_m, address_m);
81003 + ptl_m = pte_lockptr(mm, pmd_m);
81004 + if (ptl != ptl_m) {
81005 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
81006 + if (!pte_none(*pte_m))
81007 + goto out;
81008 + }
81009 +
81010 + entry_m = pfn_pte(page_to_pfn(page_m), vma_m->vm_page_prot);
81011 + page_cache_get(page_m);
81012 + page_add_anon_rmap(page_m, vma_m, address_m);
81013 + inc_mm_counter_fast(mm, MM_ANONPAGES);
81014 + set_pte_at(mm, address_m, pte_m, entry_m);
81015 + update_mmu_cache(vma_m, address_m, pte_m);
81016 +out:
81017 + if (ptl != ptl_m)
81018 + spin_unlock(ptl_m);
81019 + pte_unmap(pte_m);
81020 + unlock_page(page_m);
81021 +}
81022 +
81023 +void pax_mirror_file_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl)
81024 +{
81025 + struct mm_struct *mm = vma->vm_mm;
81026 + unsigned long address_m;
81027 + spinlock_t *ptl_m;
81028 + struct vm_area_struct *vma_m;
81029 + pmd_t *pmd_m;
81030 + pte_t *pte_m, entry_m;
81031 +
81032 + BUG_ON(!page_m || PageAnon(page_m));
81033 +
81034 + vma_m = pax_find_mirror_vma(vma);
81035 + if (!vma_m)
81036 + return;
81037 +
81038 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
81039 + address_m = address + SEGMEXEC_TASK_SIZE;
81040 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
81041 + pte_m = pte_offset_map(pmd_m, address_m);
81042 + ptl_m = pte_lockptr(mm, pmd_m);
81043 + if (ptl != ptl_m) {
81044 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
81045 + if (!pte_none(*pte_m))
81046 + goto out;
81047 + }
81048 +
81049 + entry_m = pfn_pte(page_to_pfn(page_m), vma_m->vm_page_prot);
81050 + page_cache_get(page_m);
81051 + page_add_file_rmap(page_m);
81052 + inc_mm_counter_fast(mm, MM_FILEPAGES);
81053 + set_pte_at(mm, address_m, pte_m, entry_m);
81054 + update_mmu_cache(vma_m, address_m, pte_m);
81055 +out:
81056 + if (ptl != ptl_m)
81057 + spin_unlock(ptl_m);
81058 + pte_unmap(pte_m);
81059 +}
81060 +
81061 +static void pax_mirror_pfn_pte(struct vm_area_struct *vma, unsigned long address, unsigned long pfn_m, spinlock_t *ptl)
81062 +{
81063 + struct mm_struct *mm = vma->vm_mm;
81064 + unsigned long address_m;
81065 + spinlock_t *ptl_m;
81066 + struct vm_area_struct *vma_m;
81067 + pmd_t *pmd_m;
81068 + pte_t *pte_m, entry_m;
81069 +
81070 + vma_m = pax_find_mirror_vma(vma);
81071 + if (!vma_m)
81072 + return;
81073 +
81074 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
81075 + address_m = address + SEGMEXEC_TASK_SIZE;
81076 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
81077 + pte_m = pte_offset_map(pmd_m, address_m);
81078 + ptl_m = pte_lockptr(mm, pmd_m);
81079 + if (ptl != ptl_m) {
81080 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
81081 + if (!pte_none(*pte_m))
81082 + goto out;
81083 + }
81084 +
81085 + entry_m = pfn_pte(pfn_m, vma_m->vm_page_prot);
81086 + set_pte_at(mm, address_m, pte_m, entry_m);
81087 +out:
81088 + if (ptl != ptl_m)
81089 + spin_unlock(ptl_m);
81090 + pte_unmap(pte_m);
81091 +}
81092 +
81093 +static void pax_mirror_pte(struct vm_area_struct *vma, unsigned long address, pte_t *pte, pmd_t *pmd, spinlock_t *ptl)
81094 +{
81095 + struct page *page_m;
81096 + pte_t entry;
81097 +
81098 + if (!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC))
81099 + goto out;
81100 +
81101 + entry = *pte;
81102 + page_m = vm_normal_page(vma, address, entry);
81103 + if (!page_m)
81104 + pax_mirror_pfn_pte(vma, address, pte_pfn(entry), ptl);
81105 + else if (PageAnon(page_m)) {
81106 + if (pax_find_mirror_vma(vma)) {
81107 + pte_unmap_unlock(pte, ptl);
81108 + lock_page(page_m);
81109 + pte = pte_offset_map_lock(vma->vm_mm, pmd, address, &ptl);
81110 + if (pte_same(entry, *pte))
81111 + pax_mirror_anon_pte(vma, address, page_m, ptl);
81112 + else
81113 + unlock_page(page_m);
81114 + }
81115 + } else
81116 + pax_mirror_file_pte(vma, address, page_m, ptl);
81117 +
81118 +out:
81119 + pte_unmap_unlock(pte, ptl);
81120 +}
81121 +#endif
81122 +
81123 /*
81124 * This routine handles present pages, when users try to write
81125 * to a shared page. It is done by copying the page to a new address
81126 @@ -2808,6 +3004,12 @@ gotten:
81127 */
81128 page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
81129 if (likely(pte_same(*page_table, orig_pte))) {
81130 +
81131 +#ifdef CONFIG_PAX_SEGMEXEC
81132 + if (pax_find_mirror_vma(vma))
81133 + BUG_ON(!trylock_page(new_page));
81134 +#endif
81135 +
81136 if (old_page) {
81137 if (!PageAnon(old_page)) {
81138 dec_mm_counter_fast(mm, MM_FILEPAGES);
81139 @@ -2859,6 +3061,10 @@ gotten:
81140 page_remove_rmap(old_page);
81141 }
81142
81143 +#ifdef CONFIG_PAX_SEGMEXEC
81144 + pax_mirror_anon_pte(vma, address, new_page, ptl);
81145 +#endif
81146 +
81147 /* Free the old page.. */
81148 new_page = old_page;
81149 ret |= VM_FAULT_WRITE;
81150 @@ -3134,6 +3340,11 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
81151 swap_free(entry);
81152 if (vm_swap_full() || (vma->vm_flags & VM_LOCKED) || PageMlocked(page))
81153 try_to_free_swap(page);
81154 +
81155 +#ifdef CONFIG_PAX_SEGMEXEC
81156 + if ((flags & FAULT_FLAG_WRITE) || !pax_find_mirror_vma(vma))
81157 +#endif
81158 +
81159 unlock_page(page);
81160 if (page != swapcache) {
81161 /*
81162 @@ -3157,6 +3368,11 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
81163
81164 /* No need to invalidate - it was non-present before */
81165 update_mmu_cache(vma, address, page_table);
81166 +
81167 +#ifdef CONFIG_PAX_SEGMEXEC
81168 + pax_mirror_anon_pte(vma, address, page, ptl);
81169 +#endif
81170 +
81171 unlock:
81172 pte_unmap_unlock(page_table, ptl);
81173 out:
81174 @@ -3176,40 +3392,6 @@ out_release:
81175 }
81176
81177 /*
81178 - * This is like a special single-page "expand_{down|up}wards()",
81179 - * except we must first make sure that 'address{-|+}PAGE_SIZE'
81180 - * doesn't hit another vma.
81181 - */
81182 -static inline int check_stack_guard_page(struct vm_area_struct *vma, unsigned long address)
81183 -{
81184 - address &= PAGE_MASK;
81185 - if ((vma->vm_flags & VM_GROWSDOWN) && address == vma->vm_start) {
81186 - struct vm_area_struct *prev = vma->vm_prev;
81187 -
81188 - /*
81189 - * Is there a mapping abutting this one below?
81190 - *
81191 - * That's only ok if it's the same stack mapping
81192 - * that has gotten split..
81193 - */
81194 - if (prev && prev->vm_end == address)
81195 - return prev->vm_flags & VM_GROWSDOWN ? 0 : -ENOMEM;
81196 -
81197 - expand_downwards(vma, address - PAGE_SIZE);
81198 - }
81199 - if ((vma->vm_flags & VM_GROWSUP) && address + PAGE_SIZE == vma->vm_end) {
81200 - struct vm_area_struct *next = vma->vm_next;
81201 -
81202 - /* As VM_GROWSDOWN but s/below/above/ */
81203 - if (next && next->vm_start == address + PAGE_SIZE)
81204 - return next->vm_flags & VM_GROWSUP ? 0 : -ENOMEM;
81205 -
81206 - expand_upwards(vma, address + PAGE_SIZE);
81207 - }
81208 - return 0;
81209 -}
81210 -
81211 -/*
81212 * We enter with non-exclusive mmap_sem (to exclude vma changes,
81213 * but allow concurrent faults), and pte mapped but not yet locked.
81214 * We return with mmap_sem still held, but pte unmapped and unlocked.
81215 @@ -3218,27 +3400,23 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
81216 unsigned long address, pte_t *page_table, pmd_t *pmd,
81217 unsigned int flags)
81218 {
81219 - struct page *page;
81220 + struct page *page = NULL;
81221 spinlock_t *ptl;
81222 pte_t entry;
81223
81224 - pte_unmap(page_table);
81225 -
81226 - /* Check if we need to add a guard page to the stack */
81227 - if (check_stack_guard_page(vma, address) < 0)
81228 - return VM_FAULT_SIGBUS;
81229 -
81230 - /* Use the zero-page for reads */
81231 if (!(flags & FAULT_FLAG_WRITE)) {
81232 entry = pte_mkspecial(pfn_pte(my_zero_pfn(address),
81233 vma->vm_page_prot));
81234 - page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
81235 + ptl = pte_lockptr(mm, pmd);
81236 + spin_lock(ptl);
81237 if (!pte_none(*page_table))
81238 goto unlock;
81239 goto setpte;
81240 }
81241
81242 /* Allocate our own private page. */
81243 + pte_unmap(page_table);
81244 +
81245 if (unlikely(anon_vma_prepare(vma)))
81246 goto oom;
81247 page = alloc_zeroed_user_highpage_movable(vma, address);
81248 @@ -3257,6 +3435,11 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
81249 if (!pte_none(*page_table))
81250 goto release;
81251
81252 +#ifdef CONFIG_PAX_SEGMEXEC
81253 + if (pax_find_mirror_vma(vma))
81254 + BUG_ON(!trylock_page(page));
81255 +#endif
81256 +
81257 inc_mm_counter_fast(mm, MM_ANONPAGES);
81258 page_add_new_anon_rmap(page, vma, address);
81259 setpte:
81260 @@ -3264,6 +3447,12 @@ setpte:
81261
81262 /* No need to invalidate - it was non-present before */
81263 update_mmu_cache(vma, address, page_table);
81264 +
81265 +#ifdef CONFIG_PAX_SEGMEXEC
81266 + if (page)
81267 + pax_mirror_anon_pte(vma, address, page, ptl);
81268 +#endif
81269 +
81270 unlock:
81271 pte_unmap_unlock(page_table, ptl);
81272 return 0;
81273 @@ -3407,6 +3596,12 @@ static int __do_fault(struct mm_struct *mm, struct vm_area_struct *vma,
81274 */
81275 /* Only go through if we didn't race with anybody else... */
81276 if (likely(pte_same(*page_table, orig_pte))) {
81277 +
81278 +#ifdef CONFIG_PAX_SEGMEXEC
81279 + if (anon && pax_find_mirror_vma(vma))
81280 + BUG_ON(!trylock_page(page));
81281 +#endif
81282 +
81283 flush_icache_page(vma, page);
81284 entry = mk_pte(page, vma->vm_page_prot);
81285 if (flags & FAULT_FLAG_WRITE)
81286 @@ -3426,6 +3621,14 @@ static int __do_fault(struct mm_struct *mm, struct vm_area_struct *vma,
81287
81288 /* no need to invalidate: a not-present page won't be cached */
81289 update_mmu_cache(vma, address, page_table);
81290 +
81291 +#ifdef CONFIG_PAX_SEGMEXEC
81292 + if (anon)
81293 + pax_mirror_anon_pte(vma, address, page, ptl);
81294 + else
81295 + pax_mirror_file_pte(vma, address, page, ptl);
81296 +#endif
81297 +
81298 } else {
81299 if (cow_page)
81300 mem_cgroup_uncharge_page(cow_page);
81301 @@ -3747,6 +3950,12 @@ int handle_pte_fault(struct mm_struct *mm,
81302 if (flags & FAULT_FLAG_WRITE)
81303 flush_tlb_fix_spurious_fault(vma, address);
81304 }
81305 +
81306 +#ifdef CONFIG_PAX_SEGMEXEC
81307 + pax_mirror_pte(vma, address, pte, pmd, ptl);
81308 + return 0;
81309 +#endif
81310 +
81311 unlock:
81312 pte_unmap_unlock(pte, ptl);
81313 return 0;
81314 @@ -3763,6 +3972,10 @@ int handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,
81315 pmd_t *pmd;
81316 pte_t *pte;
81317
81318 +#ifdef CONFIG_PAX_SEGMEXEC
81319 + struct vm_area_struct *vma_m;
81320 +#endif
81321 +
81322 __set_current_state(TASK_RUNNING);
81323
81324 count_vm_event(PGFAULT);
81325 @@ -3774,6 +3987,34 @@ int handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,
81326 if (unlikely(is_vm_hugetlb_page(vma)))
81327 return hugetlb_fault(mm, vma, address, flags);
81328
81329 +#ifdef CONFIG_PAX_SEGMEXEC
81330 + vma_m = pax_find_mirror_vma(vma);
81331 + if (vma_m) {
81332 + unsigned long address_m;
81333 + pgd_t *pgd_m;
81334 + pud_t *pud_m;
81335 + pmd_t *pmd_m;
81336 +
81337 + if (vma->vm_start > vma_m->vm_start) {
81338 + address_m = address;
81339 + address -= SEGMEXEC_TASK_SIZE;
81340 + vma = vma_m;
81341 + } else
81342 + address_m = address + SEGMEXEC_TASK_SIZE;
81343 +
81344 + pgd_m = pgd_offset(mm, address_m);
81345 + pud_m = pud_alloc(mm, pgd_m, address_m);
81346 + if (!pud_m)
81347 + return VM_FAULT_OOM;
81348 + pmd_m = pmd_alloc(mm, pud_m, address_m);
81349 + if (!pmd_m)
81350 + return VM_FAULT_OOM;
81351 + if (!pmd_present(*pmd_m) && __pte_alloc(mm, vma_m, pmd_m, address_m))
81352 + return VM_FAULT_OOM;
81353 + pax_unmap_mirror_pte(vma_m, address_m, pmd_m);
81354 + }
81355 +#endif
81356 +
81357 retry:
81358 pgd = pgd_offset(mm, address);
81359 pud = pud_alloc(mm, pgd, address);
81360 @@ -3872,6 +4113,23 @@ int __pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
81361 spin_unlock(&mm->page_table_lock);
81362 return 0;
81363 }
81364 +
81365 +int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
81366 +{
81367 + pud_t *new = pud_alloc_one(mm, address);
81368 + if (!new)
81369 + return -ENOMEM;
81370 +
81371 + smp_wmb(); /* See comment in __pte_alloc */
81372 +
81373 + spin_lock(&mm->page_table_lock);
81374 + if (pgd_present(*pgd)) /* Another has populated it */
81375 + pud_free(mm, new);
81376 + else
81377 + pgd_populate_kernel(mm, pgd, new);
81378 + spin_unlock(&mm->page_table_lock);
81379 + return 0;
81380 +}
81381 #endif /* __PAGETABLE_PUD_FOLDED */
81382
81383 #ifndef __PAGETABLE_PMD_FOLDED
81384 @@ -3902,6 +4160,30 @@ int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
81385 spin_unlock(&mm->page_table_lock);
81386 return 0;
81387 }
81388 +
81389 +int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address)
81390 +{
81391 + pmd_t *new = pmd_alloc_one(mm, address);
81392 + if (!new)
81393 + return -ENOMEM;
81394 +
81395 + smp_wmb(); /* See comment in __pte_alloc */
81396 +
81397 + spin_lock(&mm->page_table_lock);
81398 +#ifndef __ARCH_HAS_4LEVEL_HACK
81399 + if (pud_present(*pud)) /* Another has populated it */
81400 + pmd_free(mm, new);
81401 + else
81402 + pud_populate_kernel(mm, pud, new);
81403 +#else
81404 + if (pgd_present(*pud)) /* Another has populated it */
81405 + pmd_free(mm, new);
81406 + else
81407 + pgd_populate_kernel(mm, pud, new);
81408 +#endif /* __ARCH_HAS_4LEVEL_HACK */
81409 + spin_unlock(&mm->page_table_lock);
81410 + return 0;
81411 +}
81412 #endif /* __PAGETABLE_PMD_FOLDED */
81413
81414 #if !defined(__HAVE_ARCH_GATE_AREA)
81415 @@ -3915,7 +4197,7 @@ static int __init gate_vma_init(void)
81416 gate_vma.vm_start = FIXADDR_USER_START;
81417 gate_vma.vm_end = FIXADDR_USER_END;
81418 gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;
81419 - gate_vma.vm_page_prot = __P101;
81420 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
81421
81422 return 0;
81423 }
81424 @@ -4049,8 +4331,8 @@ out:
81425 return ret;
81426 }
81427
81428 -int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
81429 - void *buf, int len, int write)
81430 +ssize_t generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
81431 + void *buf, size_t len, int write)
81432 {
81433 resource_size_t phys_addr;
81434 unsigned long prot = 0;
81435 @@ -4075,8 +4357,8 @@ int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
81436 * Access another process' address space as given in mm. If non-NULL, use the
81437 * given task for page fault accounting.
81438 */
81439 -static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
81440 - unsigned long addr, void *buf, int len, int write)
81441 +static ssize_t __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
81442 + unsigned long addr, void *buf, size_t len, int write)
81443 {
81444 struct vm_area_struct *vma;
81445 void *old_buf = buf;
81446 @@ -4084,7 +4366,7 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
81447 down_read(&mm->mmap_sem);
81448 /* ignore errors, just check how much was successfully transferred */
81449 while (len) {
81450 - int bytes, ret, offset;
81451 + ssize_t bytes, ret, offset;
81452 void *maddr;
81453 struct page *page = NULL;
81454
81455 @@ -4143,8 +4425,8 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
81456 *
81457 * The caller must hold a reference on @mm.
81458 */
81459 -int access_remote_vm(struct mm_struct *mm, unsigned long addr,
81460 - void *buf, int len, int write)
81461 +ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
81462 + void *buf, size_t len, int write)
81463 {
81464 return __access_remote_vm(NULL, mm, addr, buf, len, write);
81465 }
81466 @@ -4154,11 +4436,11 @@ int access_remote_vm(struct mm_struct *mm, unsigned long addr,
81467 * Source/target buffer must be kernel space,
81468 * Do not walk the page table directly, use get_user_pages
81469 */
81470 -int access_process_vm(struct task_struct *tsk, unsigned long addr,
81471 - void *buf, int len, int write)
81472 +ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr,
81473 + void *buf, size_t len, int write)
81474 {
81475 struct mm_struct *mm;
81476 - int ret;
81477 + ssize_t ret;
81478
81479 mm = get_task_mm(tsk);
81480 if (!mm)
81481 diff --git a/mm/mempolicy.c b/mm/mempolicy.c
81482 index 7431001..0f8344e 100644
81483 --- a/mm/mempolicy.c
81484 +++ b/mm/mempolicy.c
81485 @@ -708,6 +708,10 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
81486 unsigned long vmstart;
81487 unsigned long vmend;
81488
81489 +#ifdef CONFIG_PAX_SEGMEXEC
81490 + struct vm_area_struct *vma_m;
81491 +#endif
81492 +
81493 vma = find_vma(mm, start);
81494 if (!vma || vma->vm_start > start)
81495 return -EFAULT;
81496 @@ -744,9 +748,20 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
81497 if (err)
81498 goto out;
81499 }
81500 +
81501 err = vma_replace_policy(vma, new_pol);
81502 if (err)
81503 goto out;
81504 +
81505 +#ifdef CONFIG_PAX_SEGMEXEC
81506 + vma_m = pax_find_mirror_vma(vma);
81507 + if (vma_m) {
81508 + err = vma_replace_policy(vma_m, new_pol);
81509 + if (err)
81510 + goto out;
81511 + }
81512 +#endif
81513 +
81514 }
81515
81516 out:
81517 @@ -1202,6 +1217,17 @@ static long do_mbind(unsigned long start, unsigned long len,
81518
81519 if (end < start)
81520 return -EINVAL;
81521 +
81522 +#ifdef CONFIG_PAX_SEGMEXEC
81523 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
81524 + if (end > SEGMEXEC_TASK_SIZE)
81525 + return -EINVAL;
81526 + } else
81527 +#endif
81528 +
81529 + if (end > TASK_SIZE)
81530 + return -EINVAL;
81531 +
81532 if (end == start)
81533 return 0;
81534
81535 @@ -1430,8 +1456,7 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
81536 */
81537 tcred = __task_cred(task);
81538 if (!uid_eq(cred->euid, tcred->suid) && !uid_eq(cred->euid, tcred->uid) &&
81539 - !uid_eq(cred->uid, tcred->suid) && !uid_eq(cred->uid, tcred->uid) &&
81540 - !capable(CAP_SYS_NICE)) {
81541 + !uid_eq(cred->uid, tcred->suid) && !capable(CAP_SYS_NICE)) {
81542 rcu_read_unlock();
81543 err = -EPERM;
81544 goto out_put;
81545 @@ -1462,6 +1487,15 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
81546 goto out;
81547 }
81548
81549 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
81550 + if (mm != current->mm &&
81551 + (mm->pax_flags & MF_PAX_RANDMMAP || mm->pax_flags & MF_PAX_SEGMEXEC)) {
81552 + mmput(mm);
81553 + err = -EPERM;
81554 + goto out;
81555 + }
81556 +#endif
81557 +
81558 err = do_migrate_pages(mm, old, new,
81559 capable(CAP_SYS_NICE) ? MPOL_MF_MOVE_ALL : MPOL_MF_MOVE);
81560
81561 diff --git a/mm/migrate.c b/mm/migrate.c
81562 index 22ed5c1..87c424c 100644
81563 --- a/mm/migrate.c
81564 +++ b/mm/migrate.c
81565 @@ -1382,8 +1382,7 @@ SYSCALL_DEFINE6(move_pages, pid_t, pid, unsigned long, nr_pages,
81566 */
81567 tcred = __task_cred(task);
81568 if (!uid_eq(cred->euid, tcred->suid) && !uid_eq(cred->euid, tcred->uid) &&
81569 - !uid_eq(cred->uid, tcred->suid) && !uid_eq(cred->uid, tcred->uid) &&
81570 - !capable(CAP_SYS_NICE)) {
81571 + !uid_eq(cred->uid, tcred->suid) && !capable(CAP_SYS_NICE)) {
81572 rcu_read_unlock();
81573 err = -EPERM;
81574 goto out;
81575 diff --git a/mm/mlock.c b/mm/mlock.c
81576 index 79b7cf7..9944291 100644
81577 --- a/mm/mlock.c
81578 +++ b/mm/mlock.c
81579 @@ -13,6 +13,7 @@
81580 #include <linux/pagemap.h>
81581 #include <linux/mempolicy.h>
81582 #include <linux/syscalls.h>
81583 +#include <linux/security.h>
81584 #include <linux/sched.h>
81585 #include <linux/export.h>
81586 #include <linux/rmap.h>
81587 @@ -334,7 +335,7 @@ static int do_mlock(unsigned long start, size_t len, int on)
81588 {
81589 unsigned long nstart, end, tmp;
81590 struct vm_area_struct * vma, * prev;
81591 - int error;
81592 + int error = 0;
81593
81594 VM_BUG_ON(start & ~PAGE_MASK);
81595 VM_BUG_ON(len != PAGE_ALIGN(len));
81596 @@ -343,6 +344,9 @@ static int do_mlock(unsigned long start, size_t len, int on)
81597 return -EINVAL;
81598 if (end == start)
81599 return 0;
81600 + if (end > TASK_SIZE)
81601 + return -EINVAL;
81602 +
81603 vma = find_vma(current->mm, start);
81604 if (!vma || vma->vm_start > start)
81605 return -ENOMEM;
81606 @@ -354,6 +358,11 @@ static int do_mlock(unsigned long start, size_t len, int on)
81607 for (nstart = start ; ; ) {
81608 vm_flags_t newflags;
81609
81610 +#ifdef CONFIG_PAX_SEGMEXEC
81611 + if ((current->mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE))
81612 + break;
81613 +#endif
81614 +
81615 /* Here we know that vma->vm_start <= nstart < vma->vm_end. */
81616
81617 newflags = vma->vm_flags & ~VM_LOCKED;
81618 @@ -466,6 +475,7 @@ SYSCALL_DEFINE2(mlock, unsigned long, start, size_t, len)
81619 lock_limit >>= PAGE_SHIFT;
81620
81621 /* check against resource limits */
81622 + gr_learn_resource(current, RLIMIT_MEMLOCK, (current->mm->locked_vm << PAGE_SHIFT) + len, 1);
81623 if ((locked <= lock_limit) || capable(CAP_IPC_LOCK))
81624 error = do_mlock(start, len, 1);
81625 up_write(&current->mm->mmap_sem);
81626 @@ -500,6 +510,11 @@ static int do_mlockall(int flags)
81627 for (vma = current->mm->mmap; vma ; vma = prev->vm_next) {
81628 vm_flags_t newflags;
81629
81630 +#ifdef CONFIG_PAX_SEGMEXEC
81631 + if ((current->mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE))
81632 + break;
81633 +#endif
81634 +
81635 newflags = vma->vm_flags & ~VM_LOCKED;
81636 if (flags & MCL_CURRENT)
81637 newflags |= VM_LOCKED;
81638 @@ -532,6 +547,7 @@ SYSCALL_DEFINE1(mlockall, int, flags)
81639 lock_limit >>= PAGE_SHIFT;
81640
81641 ret = -ENOMEM;
81642 + gr_learn_resource(current, RLIMIT_MEMLOCK, current->mm->total_vm << PAGE_SHIFT, 1);
81643 if (!(flags & MCL_CURRENT) || (current->mm->total_vm <= lock_limit) ||
81644 capable(CAP_IPC_LOCK))
81645 ret = do_mlockall(flags);
81646 diff --git a/mm/mmap.c b/mm/mmap.c
81647 index 0dceed8..671951c 100644
81648 --- a/mm/mmap.c
81649 +++ b/mm/mmap.c
81650 @@ -33,6 +33,7 @@
81651 #include <linux/uprobes.h>
81652 #include <linux/rbtree_augmented.h>
81653 #include <linux/sched/sysctl.h>
81654 +#include <linux/random.h>
81655
81656 #include <asm/uaccess.h>
81657 #include <asm/cacheflush.h>
81658 @@ -49,6 +50,16 @@
81659 #define arch_rebalance_pgtables(addr, len) (addr)
81660 #endif
81661
81662 +static inline void verify_mm_writelocked(struct mm_struct *mm)
81663 +{
81664 +#if defined(CONFIG_DEBUG_VM) || defined(CONFIG_PAX)
81665 + if (unlikely(down_read_trylock(&mm->mmap_sem))) {
81666 + up_read(&mm->mmap_sem);
81667 + BUG();
81668 + }
81669 +#endif
81670 +}
81671 +
81672 static void unmap_region(struct mm_struct *mm,
81673 struct vm_area_struct *vma, struct vm_area_struct *prev,
81674 unsigned long start, unsigned long end);
81675 @@ -68,22 +79,32 @@ static void unmap_region(struct mm_struct *mm,
81676 * x: (no) no x: (no) yes x: (no) yes x: (yes) yes
81677 *
81678 */
81679 -pgprot_t protection_map[16] = {
81680 +pgprot_t protection_map[16] __read_only = {
81681 __P000, __P001, __P010, __P011, __P100, __P101, __P110, __P111,
81682 __S000, __S001, __S010, __S011, __S100, __S101, __S110, __S111
81683 };
81684
81685 -pgprot_t vm_get_page_prot(unsigned long vm_flags)
81686 +pgprot_t vm_get_page_prot(vm_flags_t vm_flags)
81687 {
81688 - return __pgprot(pgprot_val(protection_map[vm_flags &
81689 + pgprot_t prot = __pgprot(pgprot_val(protection_map[vm_flags &
81690 (VM_READ|VM_WRITE|VM_EXEC|VM_SHARED)]) |
81691 pgprot_val(arch_vm_get_page_prot(vm_flags)));
81692 +
81693 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
81694 + if (!(__supported_pte_mask & _PAGE_NX) &&
81695 + (vm_flags & (VM_PAGEEXEC | VM_EXEC)) == VM_PAGEEXEC &&
81696 + (vm_flags & (VM_READ | VM_WRITE)))
81697 + prot = __pgprot(pte_val(pte_exprotect(__pte(pgprot_val(prot)))));
81698 +#endif
81699 +
81700 + return prot;
81701 }
81702 EXPORT_SYMBOL(vm_get_page_prot);
81703
81704 int sysctl_overcommit_memory __read_mostly = OVERCOMMIT_GUESS; /* heuristic overcommit */
81705 int sysctl_overcommit_ratio __read_mostly = 50; /* default is 50% */
81706 int sysctl_max_map_count __read_mostly = DEFAULT_MAX_MAP_COUNT;
81707 +unsigned long sysctl_heap_stack_gap __read_mostly = 64*1024;
81708 /*
81709 * Make sure vm_committed_as in one cacheline and not cacheline shared with
81710 * other variables. It can be updated by several CPUs frequently.
81711 @@ -239,6 +260,7 @@ static struct vm_area_struct *remove_vma(struct vm_area_struct *vma)
81712 struct vm_area_struct *next = vma->vm_next;
81713
81714 might_sleep();
81715 + BUG_ON(vma->vm_mirror);
81716 if (vma->vm_ops && vma->vm_ops->close)
81717 vma->vm_ops->close(vma);
81718 if (vma->vm_file)
81719 @@ -283,6 +305,7 @@ SYSCALL_DEFINE1(brk, unsigned long, brk)
81720 * not page aligned -Ram Gupta
81721 */
81722 rlim = rlimit(RLIMIT_DATA);
81723 + gr_learn_resource(current, RLIMIT_DATA, (brk - mm->start_brk) + (mm->end_data - mm->start_data), 1);
81724 if (rlim < RLIM_INFINITY && (brk - mm->start_brk) +
81725 (mm->end_data - mm->start_data) > rlim)
81726 goto out;
81727 @@ -897,6 +920,12 @@ static int
81728 can_vma_merge_before(struct vm_area_struct *vma, unsigned long vm_flags,
81729 struct anon_vma *anon_vma, struct file *file, pgoff_t vm_pgoff)
81730 {
81731 +
81732 +#ifdef CONFIG_PAX_SEGMEXEC
81733 + if ((vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_start == SEGMEXEC_TASK_SIZE)
81734 + return 0;
81735 +#endif
81736 +
81737 if (is_mergeable_vma(vma, file, vm_flags) &&
81738 is_mergeable_anon_vma(anon_vma, vma->anon_vma, vma)) {
81739 if (vma->vm_pgoff == vm_pgoff)
81740 @@ -916,6 +945,12 @@ static int
81741 can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags,
81742 struct anon_vma *anon_vma, struct file *file, pgoff_t vm_pgoff)
81743 {
81744 +
81745 +#ifdef CONFIG_PAX_SEGMEXEC
81746 + if ((vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_end == SEGMEXEC_TASK_SIZE)
81747 + return 0;
81748 +#endif
81749 +
81750 if (is_mergeable_vma(vma, file, vm_flags) &&
81751 is_mergeable_anon_vma(anon_vma, vma->anon_vma, vma)) {
81752 pgoff_t vm_pglen;
81753 @@ -958,13 +993,20 @@ can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags,
81754 struct vm_area_struct *vma_merge(struct mm_struct *mm,
81755 struct vm_area_struct *prev, unsigned long addr,
81756 unsigned long end, unsigned long vm_flags,
81757 - struct anon_vma *anon_vma, struct file *file,
81758 + struct anon_vma *anon_vma, struct file *file,
81759 pgoff_t pgoff, struct mempolicy *policy)
81760 {
81761 pgoff_t pglen = (end - addr) >> PAGE_SHIFT;
81762 struct vm_area_struct *area, *next;
81763 int err;
81764
81765 +#ifdef CONFIG_PAX_SEGMEXEC
81766 + unsigned long addr_m = addr + SEGMEXEC_TASK_SIZE, end_m = end + SEGMEXEC_TASK_SIZE;
81767 + struct vm_area_struct *area_m = NULL, *next_m = NULL, *prev_m = NULL;
81768 +
81769 + BUG_ON((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE < end);
81770 +#endif
81771 +
81772 /*
81773 * We later require that vma->vm_flags == vm_flags,
81774 * so this tests vma->vm_flags & VM_SPECIAL, too.
81775 @@ -980,6 +1022,15 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
81776 if (next && next->vm_end == end) /* cases 6, 7, 8 */
81777 next = next->vm_next;
81778
81779 +#ifdef CONFIG_PAX_SEGMEXEC
81780 + if (prev)
81781 + prev_m = pax_find_mirror_vma(prev);
81782 + if (area)
81783 + area_m = pax_find_mirror_vma(area);
81784 + if (next)
81785 + next_m = pax_find_mirror_vma(next);
81786 +#endif
81787 +
81788 /*
81789 * Can it merge with the predecessor?
81790 */
81791 @@ -999,9 +1050,24 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
81792 /* cases 1, 6 */
81793 err = vma_adjust(prev, prev->vm_start,
81794 next->vm_end, prev->vm_pgoff, NULL);
81795 - } else /* cases 2, 5, 7 */
81796 +
81797 +#ifdef CONFIG_PAX_SEGMEXEC
81798 + if (!err && prev_m)
81799 + err = vma_adjust(prev_m, prev_m->vm_start,
81800 + next_m->vm_end, prev_m->vm_pgoff, NULL);
81801 +#endif
81802 +
81803 + } else { /* cases 2, 5, 7 */
81804 err = vma_adjust(prev, prev->vm_start,
81805 end, prev->vm_pgoff, NULL);
81806 +
81807 +#ifdef CONFIG_PAX_SEGMEXEC
81808 + if (!err && prev_m)
81809 + err = vma_adjust(prev_m, prev_m->vm_start,
81810 + end_m, prev_m->vm_pgoff, NULL);
81811 +#endif
81812 +
81813 + }
81814 if (err)
81815 return NULL;
81816 khugepaged_enter_vma_merge(prev);
81817 @@ -1015,12 +1081,27 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
81818 mpol_equal(policy, vma_policy(next)) &&
81819 can_vma_merge_before(next, vm_flags,
81820 anon_vma, file, pgoff+pglen)) {
81821 - if (prev && addr < prev->vm_end) /* case 4 */
81822 + if (prev && addr < prev->vm_end) { /* case 4 */
81823 err = vma_adjust(prev, prev->vm_start,
81824 addr, prev->vm_pgoff, NULL);
81825 - else /* cases 3, 8 */
81826 +
81827 +#ifdef CONFIG_PAX_SEGMEXEC
81828 + if (!err && prev_m)
81829 + err = vma_adjust(prev_m, prev_m->vm_start,
81830 + addr_m, prev_m->vm_pgoff, NULL);
81831 +#endif
81832 +
81833 + } else { /* cases 3, 8 */
81834 err = vma_adjust(area, addr, next->vm_end,
81835 next->vm_pgoff - pglen, NULL);
81836 +
81837 +#ifdef CONFIG_PAX_SEGMEXEC
81838 + if (!err && area_m)
81839 + err = vma_adjust(area_m, addr_m, next_m->vm_end,
81840 + next_m->vm_pgoff - pglen, NULL);
81841 +#endif
81842 +
81843 + }
81844 if (err)
81845 return NULL;
81846 khugepaged_enter_vma_merge(area);
81847 @@ -1129,8 +1210,10 @@ none:
81848 void vm_stat_account(struct mm_struct *mm, unsigned long flags,
81849 struct file *file, long pages)
81850 {
81851 - const unsigned long stack_flags
81852 - = VM_STACK_FLAGS & (VM_GROWSUP|VM_GROWSDOWN);
81853 +
81854 +#ifdef CONFIG_PAX_RANDMMAP
81855 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
81856 +#endif
81857
81858 mm->total_vm += pages;
81859
81860 @@ -1138,7 +1221,7 @@ void vm_stat_account(struct mm_struct *mm, unsigned long flags,
81861 mm->shared_vm += pages;
81862 if ((flags & (VM_EXEC|VM_WRITE)) == VM_EXEC)
81863 mm->exec_vm += pages;
81864 - } else if (flags & stack_flags)
81865 + } else if (flags & (VM_GROWSUP|VM_GROWSDOWN))
81866 mm->stack_vm += pages;
81867 }
81868 #endif /* CONFIG_PROC_FS */
81869 @@ -1177,7 +1260,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
81870 * (the exception is when the underlying filesystem is noexec
81871 * mounted, in which case we dont add PROT_EXEC.)
81872 */
81873 - if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
81874 + if ((prot & (PROT_READ | PROT_WRITE)) && (current->personality & READ_IMPLIES_EXEC))
81875 if (!(file && (file->f_path.mnt->mnt_flags & MNT_NOEXEC)))
81876 prot |= PROT_EXEC;
81877
81878 @@ -1203,7 +1286,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
81879 /* Obtain the address to map to. we verify (or select) it and ensure
81880 * that it represents a valid section of the address space.
81881 */
81882 - addr = get_unmapped_area(file, addr, len, pgoff, flags);
81883 + addr = get_unmapped_area(file, addr, len, pgoff, flags | ((prot & PROT_EXEC) ? MAP_EXECUTABLE : 0));
81884 if (addr & ~PAGE_MASK)
81885 return addr;
81886
81887 @@ -1214,6 +1297,36 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
81888 vm_flags = calc_vm_prot_bits(prot) | calc_vm_flag_bits(flags) |
81889 mm->def_flags | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC;
81890
81891 +#ifdef CONFIG_PAX_MPROTECT
81892 + if (mm->pax_flags & MF_PAX_MPROTECT) {
81893 +#ifndef CONFIG_PAX_MPROTECT_COMPAT
81894 + if ((vm_flags & (VM_WRITE | VM_EXEC)) == (VM_WRITE | VM_EXEC)) {
81895 + gr_log_rwxmmap(file);
81896 +
81897 +#ifdef CONFIG_PAX_EMUPLT
81898 + vm_flags &= ~VM_EXEC;
81899 +#else
81900 + return -EPERM;
81901 +#endif
81902 +
81903 + }
81904 +
81905 + if (!(vm_flags & VM_EXEC))
81906 + vm_flags &= ~VM_MAYEXEC;
81907 +#else
81908 + if ((vm_flags & (VM_WRITE | VM_EXEC)) != VM_EXEC)
81909 + vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
81910 +#endif
81911 + else
81912 + vm_flags &= ~VM_MAYWRITE;
81913 + }
81914 +#endif
81915 +
81916 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
81917 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && file)
81918 + vm_flags &= ~VM_PAGEEXEC;
81919 +#endif
81920 +
81921 if (flags & MAP_LOCKED)
81922 if (!can_do_mlock())
81923 return -EPERM;
81924 @@ -1225,6 +1338,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
81925 locked += mm->locked_vm;
81926 lock_limit = rlimit(RLIMIT_MEMLOCK);
81927 lock_limit >>= PAGE_SHIFT;
81928 + gr_learn_resource(current, RLIMIT_MEMLOCK, locked << PAGE_SHIFT, 1);
81929 if (locked > lock_limit && !capable(CAP_IPC_LOCK))
81930 return -EAGAIN;
81931 }
81932 @@ -1305,6 +1419,9 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
81933 vm_flags |= VM_NORESERVE;
81934 }
81935
81936 + if (!gr_acl_handle_mmap(file, prot))
81937 + return -EACCES;
81938 +
81939 addr = mmap_region(file, addr, len, vm_flags, pgoff);
81940 if (!IS_ERR_VALUE(addr) &&
81941 ((vm_flags & VM_LOCKED) ||
81942 @@ -1396,7 +1513,7 @@ int vma_wants_writenotify(struct vm_area_struct *vma)
81943 vm_flags_t vm_flags = vma->vm_flags;
81944
81945 /* If it was private or non-writable, the write bit is already clear */
81946 - if ((vm_flags & (VM_WRITE|VM_SHARED)) != ((VM_WRITE|VM_SHARED)))
81947 + if ((vm_flags & (VM_WRITE|VM_SHARED)) != (VM_WRITE|VM_SHARED))
81948 return 0;
81949
81950 /* The backer wishes to know when pages are first written to? */
81951 @@ -1444,16 +1561,30 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
81952 unsigned long charged = 0;
81953 struct inode *inode = file ? file_inode(file) : NULL;
81954
81955 +#ifdef CONFIG_PAX_SEGMEXEC
81956 + struct vm_area_struct *vma_m = NULL;
81957 +#endif
81958 +
81959 + /*
81960 + * mm->mmap_sem is required to protect against another thread
81961 + * changing the mappings in case we sleep.
81962 + */
81963 + verify_mm_writelocked(mm);
81964 +
81965 /* Clear old maps */
81966 error = -ENOMEM;
81967 -munmap_back:
81968 if (find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent)) {
81969 if (do_munmap(mm, addr, len))
81970 return -ENOMEM;
81971 - goto munmap_back;
81972 + BUG_ON(find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent));
81973 }
81974
81975 /* Check against address space limit. */
81976 +
81977 +#ifdef CONFIG_PAX_RANDMMAP
81978 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (vm_flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
81979 +#endif
81980 +
81981 if (!may_expand_vm(mm, len >> PAGE_SHIFT))
81982 return -ENOMEM;
81983
81984 @@ -1485,6 +1616,16 @@ munmap_back:
81985 goto unacct_error;
81986 }
81987
81988 +#ifdef CONFIG_PAX_SEGMEXEC
81989 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vm_flags & VM_EXEC)) {
81990 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
81991 + if (!vma_m) {
81992 + error = -ENOMEM;
81993 + goto free_vma;
81994 + }
81995 + }
81996 +#endif
81997 +
81998 vma->vm_mm = mm;
81999 vma->vm_start = addr;
82000 vma->vm_end = addr + len;
82001 @@ -1509,6 +1650,13 @@ munmap_back:
82002 if (error)
82003 goto unmap_and_free_vma;
82004
82005 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
82006 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && !(vma->vm_flags & VM_SPECIAL)) {
82007 + vma->vm_flags |= VM_PAGEEXEC;
82008 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
82009 + }
82010 +#endif
82011 +
82012 /* Can addr have changed??
82013 *
82014 * Answer: Yes, several device drivers can do it in their
82015 @@ -1547,6 +1695,11 @@ munmap_back:
82016 vma_link(mm, vma, prev, rb_link, rb_parent);
82017 file = vma->vm_file;
82018
82019 +#ifdef CONFIG_PAX_SEGMEXEC
82020 + if (vma_m)
82021 + BUG_ON(pax_mirror_vma(vma_m, vma));
82022 +#endif
82023 +
82024 /* Once vma denies write, undo our temporary denial count */
82025 if (correct_wcount)
82026 atomic_inc(&inode->i_writecount);
82027 @@ -1554,6 +1707,7 @@ out:
82028 perf_event_mmap(vma);
82029
82030 vm_stat_account(mm, vm_flags, file, len >> PAGE_SHIFT);
82031 + track_exec_limit(mm, addr, addr + len, vm_flags);
82032 if (vm_flags & VM_LOCKED) {
82033 if (!((vm_flags & VM_SPECIAL) || is_vm_hugetlb_page(vma) ||
82034 vma == get_gate_vma(current->mm)))
82035 @@ -1577,6 +1731,12 @@ unmap_and_free_vma:
82036 unmap_region(mm, vma, prev, vma->vm_start, vma->vm_end);
82037 charged = 0;
82038 free_vma:
82039 +
82040 +#ifdef CONFIG_PAX_SEGMEXEC
82041 + if (vma_m)
82042 + kmem_cache_free(vm_area_cachep, vma_m);
82043 +#endif
82044 +
82045 kmem_cache_free(vm_area_cachep, vma);
82046 unacct_error:
82047 if (charged)
82048 @@ -1584,6 +1744,62 @@ unacct_error:
82049 return error;
82050 }
82051
82052 +#ifdef CONFIG_GRKERNSEC_RAND_THREADSTACK
82053 +unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags)
82054 +{
82055 + if ((mm->pax_flags & MF_PAX_RANDMMAP) && !filp && (flags & MAP_STACK))
82056 + return (random32() & 0xFF) << PAGE_SHIFT;
82057 +
82058 + return 0;
82059 +}
82060 +#endif
82061 +
82062 +bool check_heap_stack_gap(const struct vm_area_struct *vma, unsigned long addr, unsigned long len, unsigned long offset)
82063 +{
82064 + if (!vma) {
82065 +#ifdef CONFIG_STACK_GROWSUP
82066 + if (addr > sysctl_heap_stack_gap)
82067 + vma = find_vma(current->mm, addr - sysctl_heap_stack_gap);
82068 + else
82069 + vma = find_vma(current->mm, 0);
82070 + if (vma && (vma->vm_flags & VM_GROWSUP))
82071 + return false;
82072 +#endif
82073 + return true;
82074 + }
82075 +
82076 + if (addr + len > vma->vm_start)
82077 + return false;
82078 +
82079 + if (vma->vm_flags & VM_GROWSDOWN)
82080 + return sysctl_heap_stack_gap <= vma->vm_start - addr - len;
82081 +#ifdef CONFIG_STACK_GROWSUP
82082 + else if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP))
82083 + return addr - vma->vm_prev->vm_end <= sysctl_heap_stack_gap;
82084 +#endif
82085 + else if (offset)
82086 + return offset <= vma->vm_start - addr - len;
82087 +
82088 + return true;
82089 +}
82090 +
82091 +unsigned long skip_heap_stack_gap(const struct vm_area_struct *vma, unsigned long len, unsigned long offset)
82092 +{
82093 + if (vma->vm_start < len)
82094 + return -ENOMEM;
82095 +
82096 + if (!(vma->vm_flags & VM_GROWSDOWN)) {
82097 + if (offset <= vma->vm_start - len)
82098 + return vma->vm_start - len - offset;
82099 + else
82100 + return -ENOMEM;
82101 + }
82102 +
82103 + if (sysctl_heap_stack_gap <= vma->vm_start - len)
82104 + return vma->vm_start - len - sysctl_heap_stack_gap;
82105 + return -ENOMEM;
82106 +}
82107 +
82108 unsigned long unmapped_area(struct vm_unmapped_area_info *info)
82109 {
82110 /*
82111 @@ -1803,6 +2019,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
82112 struct mm_struct *mm = current->mm;
82113 struct vm_area_struct *vma;
82114 struct vm_unmapped_area_info info;
82115 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
82116
82117 if (len > TASK_SIZE)
82118 return -ENOMEM;
82119 @@ -1810,29 +2027,45 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
82120 if (flags & MAP_FIXED)
82121 return addr;
82122
82123 +#ifdef CONFIG_PAX_RANDMMAP
82124 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
82125 +#endif
82126 +
82127 if (addr) {
82128 addr = PAGE_ALIGN(addr);
82129 vma = find_vma(mm, addr);
82130 - if (TASK_SIZE - len >= addr &&
82131 - (!vma || addr + len <= vma->vm_start))
82132 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
82133 return addr;
82134 }
82135
82136 info.flags = 0;
82137 info.length = len;
82138 info.low_limit = TASK_UNMAPPED_BASE;
82139 +
82140 +#ifdef CONFIG_PAX_RANDMMAP
82141 + if (mm->pax_flags & MF_PAX_RANDMMAP)
82142 + info.low_limit += mm->delta_mmap;
82143 +#endif
82144 +
82145 info.high_limit = TASK_SIZE;
82146 info.align_mask = 0;
82147 + info.threadstack_offset = offset;
82148 return vm_unmapped_area(&info);
82149 }
82150 #endif
82151
82152 void arch_unmap_area(struct mm_struct *mm, unsigned long addr)
82153 {
82154 +
82155 +#ifdef CONFIG_PAX_SEGMEXEC
82156 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE <= addr)
82157 + return;
82158 +#endif
82159 +
82160 /*
82161 * Is this a new hole at the lowest possible address?
82162 */
82163 - if (addr >= TASK_UNMAPPED_BASE && addr < mm->free_area_cache)
82164 + if (addr >= mm->mmap_base && addr < mm->free_area_cache)
82165 mm->free_area_cache = addr;
82166 }
82167
82168 @@ -1850,6 +2083,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
82169 struct mm_struct *mm = current->mm;
82170 unsigned long addr = addr0;
82171 struct vm_unmapped_area_info info;
82172 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
82173
82174 /* requested length too big for entire address space */
82175 if (len > TASK_SIZE)
82176 @@ -1858,12 +2092,15 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
82177 if (flags & MAP_FIXED)
82178 return addr;
82179
82180 +#ifdef CONFIG_PAX_RANDMMAP
82181 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
82182 +#endif
82183 +
82184 /* requesting a specific address */
82185 if (addr) {
82186 addr = PAGE_ALIGN(addr);
82187 vma = find_vma(mm, addr);
82188 - if (TASK_SIZE - len >= addr &&
82189 - (!vma || addr + len <= vma->vm_start))
82190 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
82191 return addr;
82192 }
82193
82194 @@ -1872,6 +2109,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
82195 info.low_limit = PAGE_SIZE;
82196 info.high_limit = mm->mmap_base;
82197 info.align_mask = 0;
82198 + info.threadstack_offset = offset;
82199 addr = vm_unmapped_area(&info);
82200
82201 /*
82202 @@ -1884,6 +2122,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
82203 VM_BUG_ON(addr != -ENOMEM);
82204 info.flags = 0;
82205 info.low_limit = TASK_UNMAPPED_BASE;
82206 +
82207 +#ifdef CONFIG_PAX_RANDMMAP
82208 + if (mm->pax_flags & MF_PAX_RANDMMAP)
82209 + info.low_limit += mm->delta_mmap;
82210 +#endif
82211 +
82212 info.high_limit = TASK_SIZE;
82213 addr = vm_unmapped_area(&info);
82214 }
82215 @@ -1894,6 +2138,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
82216
82217 void arch_unmap_area_topdown(struct mm_struct *mm, unsigned long addr)
82218 {
82219 +
82220 +#ifdef CONFIG_PAX_SEGMEXEC
82221 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE <= addr)
82222 + return;
82223 +#endif
82224 +
82225 /*
82226 * Is this a new hole at the highest possible address?
82227 */
82228 @@ -1901,8 +2151,10 @@ void arch_unmap_area_topdown(struct mm_struct *mm, unsigned long addr)
82229 mm->free_area_cache = addr;
82230
82231 /* dont allow allocations above current base */
82232 - if (mm->free_area_cache > mm->mmap_base)
82233 + if (mm->free_area_cache > mm->mmap_base) {
82234 mm->free_area_cache = mm->mmap_base;
82235 + mm->cached_hole_size = ~0UL;
82236 + }
82237 }
82238
82239 unsigned long
82240 @@ -2001,6 +2253,28 @@ find_vma_prev(struct mm_struct *mm, unsigned long addr,
82241 return vma;
82242 }
82243
82244 +#ifdef CONFIG_PAX_SEGMEXEC
82245 +struct vm_area_struct *pax_find_mirror_vma(struct vm_area_struct *vma)
82246 +{
82247 + struct vm_area_struct *vma_m;
82248 +
82249 + BUG_ON(!vma || vma->vm_start >= vma->vm_end);
82250 + if (!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) || !(vma->vm_flags & VM_EXEC)) {
82251 + BUG_ON(vma->vm_mirror);
82252 + return NULL;
82253 + }
82254 + BUG_ON(vma->vm_start < SEGMEXEC_TASK_SIZE && SEGMEXEC_TASK_SIZE < vma->vm_end);
82255 + vma_m = vma->vm_mirror;
82256 + BUG_ON(!vma_m || vma_m->vm_mirror != vma);
82257 + BUG_ON(vma->vm_file != vma_m->vm_file);
82258 + BUG_ON(vma->vm_end - vma->vm_start != vma_m->vm_end - vma_m->vm_start);
82259 + BUG_ON(vma->vm_pgoff != vma_m->vm_pgoff);
82260 + BUG_ON(vma->anon_vma != vma_m->anon_vma && vma->anon_vma->root != vma_m->anon_vma->root);
82261 + BUG_ON((vma->vm_flags ^ vma_m->vm_flags) & ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT | VM_LOCKED));
82262 + return vma_m;
82263 +}
82264 +#endif
82265 +
82266 /*
82267 * Verify that the stack growth is acceptable and
82268 * update accounting. This is shared with both the
82269 @@ -2017,6 +2291,7 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
82270 return -ENOMEM;
82271
82272 /* Stack limit test */
82273 + gr_learn_resource(current, RLIMIT_STACK, size, 1);
82274 if (size > ACCESS_ONCE(rlim[RLIMIT_STACK].rlim_cur))
82275 return -ENOMEM;
82276
82277 @@ -2027,6 +2302,7 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
82278 locked = mm->locked_vm + grow;
82279 limit = ACCESS_ONCE(rlim[RLIMIT_MEMLOCK].rlim_cur);
82280 limit >>= PAGE_SHIFT;
82281 + gr_learn_resource(current, RLIMIT_MEMLOCK, locked << PAGE_SHIFT, 1);
82282 if (locked > limit && !capable(CAP_IPC_LOCK))
82283 return -ENOMEM;
82284 }
82285 @@ -2056,37 +2332,48 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
82286 * PA-RISC uses this for its stack; IA64 for its Register Backing Store.
82287 * vma is the last one with address > vma->vm_end. Have to extend vma.
82288 */
82289 +#ifndef CONFIG_IA64
82290 +static
82291 +#endif
82292 int expand_upwards(struct vm_area_struct *vma, unsigned long address)
82293 {
82294 int error;
82295 + bool locknext;
82296
82297 if (!(vma->vm_flags & VM_GROWSUP))
82298 return -EFAULT;
82299
82300 + /* Also guard against wrapping around to address 0. */
82301 + if (address < PAGE_ALIGN(address+1))
82302 + address = PAGE_ALIGN(address+1);
82303 + else
82304 + return -ENOMEM;
82305 +
82306 /*
82307 * We must make sure the anon_vma is allocated
82308 * so that the anon_vma locking is not a noop.
82309 */
82310 if (unlikely(anon_vma_prepare(vma)))
82311 return -ENOMEM;
82312 + locknext = vma->vm_next && (vma->vm_next->vm_flags & VM_GROWSDOWN);
82313 + if (locknext && anon_vma_prepare(vma->vm_next))
82314 + return -ENOMEM;
82315 vma_lock_anon_vma(vma);
82316 + if (locknext)
82317 + vma_lock_anon_vma(vma->vm_next);
82318
82319 /*
82320 * vma->vm_start/vm_end cannot change under us because the caller
82321 * is required to hold the mmap_sem in read mode. We need the
82322 - * anon_vma lock to serialize against concurrent expand_stacks.
82323 - * Also guard against wrapping around to address 0.
82324 + * anon_vma locks to serialize against concurrent expand_stacks
82325 + * and expand_upwards.
82326 */
82327 - if (address < PAGE_ALIGN(address+4))
82328 - address = PAGE_ALIGN(address+4);
82329 - else {
82330 - vma_unlock_anon_vma(vma);
82331 - return -ENOMEM;
82332 - }
82333 error = 0;
82334
82335 /* Somebody else might have raced and expanded it already */
82336 - if (address > vma->vm_end) {
82337 + 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)
82338 + error = -ENOMEM;
82339 + else if (address > vma->vm_end && (!locknext || vma->vm_next->vm_start >= address)) {
82340 unsigned long size, grow;
82341
82342 size = address - vma->vm_start;
82343 @@ -2121,6 +2408,8 @@ int expand_upwards(struct vm_area_struct *vma, unsigned long address)
82344 }
82345 }
82346 }
82347 + if (locknext)
82348 + vma_unlock_anon_vma(vma->vm_next);
82349 vma_unlock_anon_vma(vma);
82350 khugepaged_enter_vma_merge(vma);
82351 validate_mm(vma->vm_mm);
82352 @@ -2135,6 +2424,8 @@ int expand_downwards(struct vm_area_struct *vma,
82353 unsigned long address)
82354 {
82355 int error;
82356 + bool lockprev = false;
82357 + struct vm_area_struct *prev;
82358
82359 /*
82360 * We must make sure the anon_vma is allocated
82361 @@ -2148,6 +2439,15 @@ int expand_downwards(struct vm_area_struct *vma,
82362 if (error)
82363 return error;
82364
82365 + prev = vma->vm_prev;
82366 +#if defined(CONFIG_STACK_GROWSUP) || defined(CONFIG_IA64)
82367 + lockprev = prev && (prev->vm_flags & VM_GROWSUP);
82368 +#endif
82369 + if (lockprev && anon_vma_prepare(prev))
82370 + return -ENOMEM;
82371 + if (lockprev)
82372 + vma_lock_anon_vma(prev);
82373 +
82374 vma_lock_anon_vma(vma);
82375
82376 /*
82377 @@ -2157,9 +2457,17 @@ int expand_downwards(struct vm_area_struct *vma,
82378 */
82379
82380 /* Somebody else might have raced and expanded it already */
82381 - if (address < vma->vm_start) {
82382 + if (prev && (prev->vm_flags & (VM_READ | VM_WRITE | VM_EXEC)) && address - prev->vm_end < sysctl_heap_stack_gap)
82383 + error = -ENOMEM;
82384 + else if (address < vma->vm_start && (!lockprev || prev->vm_end <= address)) {
82385 unsigned long size, grow;
82386
82387 +#ifdef CONFIG_PAX_SEGMEXEC
82388 + struct vm_area_struct *vma_m;
82389 +
82390 + vma_m = pax_find_mirror_vma(vma);
82391 +#endif
82392 +
82393 size = vma->vm_end - address;
82394 grow = (vma->vm_start - address) >> PAGE_SHIFT;
82395
82396 @@ -2184,6 +2492,18 @@ int expand_downwards(struct vm_area_struct *vma,
82397 vma->vm_pgoff -= grow;
82398 anon_vma_interval_tree_post_update_vma(vma);
82399 vma_gap_update(vma);
82400 + track_exec_limit(vma->vm_mm, vma->vm_start, vma->vm_end, vma->vm_flags);
82401 +
82402 +#ifdef CONFIG_PAX_SEGMEXEC
82403 + if (vma_m) {
82404 + anon_vma_interval_tree_pre_update_vma(vma_m);
82405 + vma_m->vm_start -= grow << PAGE_SHIFT;
82406 + vma_m->vm_pgoff -= grow;
82407 + anon_vma_interval_tree_post_update_vma(vma_m);
82408 + vma_gap_update(vma_m);
82409 + }
82410 +#endif
82411 +
82412 spin_unlock(&vma->vm_mm->page_table_lock);
82413
82414 perf_event_mmap(vma);
82415 @@ -2288,6 +2608,13 @@ static void remove_vma_list(struct mm_struct *mm, struct vm_area_struct *vma)
82416 do {
82417 long nrpages = vma_pages(vma);
82418
82419 +#ifdef CONFIG_PAX_SEGMEXEC
82420 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE)) {
82421 + vma = remove_vma(vma);
82422 + continue;
82423 + }
82424 +#endif
82425 +
82426 if (vma->vm_flags & VM_ACCOUNT)
82427 nr_accounted += nrpages;
82428 vm_stat_account(mm, vma->vm_flags, vma->vm_file, -nrpages);
82429 @@ -2333,6 +2660,16 @@ detach_vmas_to_be_unmapped(struct mm_struct *mm, struct vm_area_struct *vma,
82430 insertion_point = (prev ? &prev->vm_next : &mm->mmap);
82431 vma->vm_prev = NULL;
82432 do {
82433 +
82434 +#ifdef CONFIG_PAX_SEGMEXEC
82435 + if (vma->vm_mirror) {
82436 + BUG_ON(!vma->vm_mirror->vm_mirror || vma->vm_mirror->vm_mirror != vma);
82437 + vma->vm_mirror->vm_mirror = NULL;
82438 + vma->vm_mirror->vm_flags &= ~VM_EXEC;
82439 + vma->vm_mirror = NULL;
82440 + }
82441 +#endif
82442 +
82443 vma_rb_erase(vma, &mm->mm_rb);
82444 mm->map_count--;
82445 tail_vma = vma;
82446 @@ -2364,14 +2701,33 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
82447 struct vm_area_struct *new;
82448 int err = -ENOMEM;
82449
82450 +#ifdef CONFIG_PAX_SEGMEXEC
82451 + struct vm_area_struct *vma_m, *new_m = NULL;
82452 + unsigned long addr_m = addr + SEGMEXEC_TASK_SIZE;
82453 +#endif
82454 +
82455 if (is_vm_hugetlb_page(vma) && (addr &
82456 ~(huge_page_mask(hstate_vma(vma)))))
82457 return -EINVAL;
82458
82459 +#ifdef CONFIG_PAX_SEGMEXEC
82460 + vma_m = pax_find_mirror_vma(vma);
82461 +#endif
82462 +
82463 new = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
82464 if (!new)
82465 goto out_err;
82466
82467 +#ifdef CONFIG_PAX_SEGMEXEC
82468 + if (vma_m) {
82469 + new_m = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
82470 + if (!new_m) {
82471 + kmem_cache_free(vm_area_cachep, new);
82472 + goto out_err;
82473 + }
82474 + }
82475 +#endif
82476 +
82477 /* most fields are the same, copy all, and then fixup */
82478 *new = *vma;
82479
82480 @@ -2384,6 +2740,22 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
82481 new->vm_pgoff += ((addr - vma->vm_start) >> PAGE_SHIFT);
82482 }
82483
82484 +#ifdef CONFIG_PAX_SEGMEXEC
82485 + if (vma_m) {
82486 + *new_m = *vma_m;
82487 + INIT_LIST_HEAD(&new_m->anon_vma_chain);
82488 + new_m->vm_mirror = new;
82489 + new->vm_mirror = new_m;
82490 +
82491 + if (new_below)
82492 + new_m->vm_end = addr_m;
82493 + else {
82494 + new_m->vm_start = addr_m;
82495 + new_m->vm_pgoff += ((addr_m - vma_m->vm_start) >> PAGE_SHIFT);
82496 + }
82497 + }
82498 +#endif
82499 +
82500 pol = mpol_dup(vma_policy(vma));
82501 if (IS_ERR(pol)) {
82502 err = PTR_ERR(pol);
82503 @@ -2406,6 +2778,36 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
82504 else
82505 err = vma_adjust(vma, vma->vm_start, addr, vma->vm_pgoff, new);
82506
82507 +#ifdef CONFIG_PAX_SEGMEXEC
82508 + if (!err && vma_m) {
82509 + if (anon_vma_clone(new_m, vma_m))
82510 + goto out_free_mpol;
82511 +
82512 + mpol_get(pol);
82513 + vma_set_policy(new_m, pol);
82514 +
82515 + if (new_m->vm_file)
82516 + get_file(new_m->vm_file);
82517 +
82518 + if (new_m->vm_ops && new_m->vm_ops->open)
82519 + new_m->vm_ops->open(new_m);
82520 +
82521 + if (new_below)
82522 + err = vma_adjust(vma_m, addr_m, vma_m->vm_end, vma_m->vm_pgoff +
82523 + ((addr_m - new_m->vm_start) >> PAGE_SHIFT), new_m);
82524 + else
82525 + err = vma_adjust(vma_m, vma_m->vm_start, addr_m, vma_m->vm_pgoff, new_m);
82526 +
82527 + if (err) {
82528 + if (new_m->vm_ops && new_m->vm_ops->close)
82529 + new_m->vm_ops->close(new_m);
82530 + if (new_m->vm_file)
82531 + fput(new_m->vm_file);
82532 + mpol_put(pol);
82533 + }
82534 + }
82535 +#endif
82536 +
82537 /* Success. */
82538 if (!err)
82539 return 0;
82540 @@ -2415,10 +2817,18 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
82541 new->vm_ops->close(new);
82542 if (new->vm_file)
82543 fput(new->vm_file);
82544 - unlink_anon_vmas(new);
82545 out_free_mpol:
82546 mpol_put(pol);
82547 out_free_vma:
82548 +
82549 +#ifdef CONFIG_PAX_SEGMEXEC
82550 + if (new_m) {
82551 + unlink_anon_vmas(new_m);
82552 + kmem_cache_free(vm_area_cachep, new_m);
82553 + }
82554 +#endif
82555 +
82556 + unlink_anon_vmas(new);
82557 kmem_cache_free(vm_area_cachep, new);
82558 out_err:
82559 return err;
82560 @@ -2431,6 +2841,15 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
82561 int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
82562 unsigned long addr, int new_below)
82563 {
82564 +
82565 +#ifdef CONFIG_PAX_SEGMEXEC
82566 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
82567 + BUG_ON(vma->vm_end > SEGMEXEC_TASK_SIZE);
82568 + if (mm->map_count >= sysctl_max_map_count-1)
82569 + return -ENOMEM;
82570 + } else
82571 +#endif
82572 +
82573 if (mm->map_count >= sysctl_max_map_count)
82574 return -ENOMEM;
82575
82576 @@ -2442,11 +2861,30 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
82577 * work. This now handles partial unmappings.
82578 * Jeremy Fitzhardinge <jeremy@goop.org>
82579 */
82580 +#ifdef CONFIG_PAX_SEGMEXEC
82581 int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
82582 {
82583 + int ret = __do_munmap(mm, start, len);
82584 + if (ret || !(mm->pax_flags & MF_PAX_SEGMEXEC))
82585 + return ret;
82586 +
82587 + return __do_munmap(mm, start + SEGMEXEC_TASK_SIZE, len);
82588 +}
82589 +
82590 +int __do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
82591 +#else
82592 +int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
82593 +#endif
82594 +{
82595 unsigned long end;
82596 struct vm_area_struct *vma, *prev, *last;
82597
82598 + /*
82599 + * mm->mmap_sem is required to protect against another thread
82600 + * changing the mappings in case we sleep.
82601 + */
82602 + verify_mm_writelocked(mm);
82603 +
82604 if ((start & ~PAGE_MASK) || start > TASK_SIZE || len > TASK_SIZE-start)
82605 return -EINVAL;
82606
82607 @@ -2521,6 +2959,8 @@ int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
82608 /* Fix up all other VM information */
82609 remove_vma_list(mm, vma);
82610
82611 + track_exec_limit(mm, start, end, 0UL);
82612 +
82613 return 0;
82614 }
82615
82616 @@ -2529,6 +2969,13 @@ int vm_munmap(unsigned long start, size_t len)
82617 int ret;
82618 struct mm_struct *mm = current->mm;
82619
82620 +
82621 +#ifdef CONFIG_PAX_SEGMEXEC
82622 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) &&
82623 + (len > SEGMEXEC_TASK_SIZE || start > SEGMEXEC_TASK_SIZE-len))
82624 + return -EINVAL;
82625 +#endif
82626 +
82627 down_write(&mm->mmap_sem);
82628 ret = do_munmap(mm, start, len);
82629 up_write(&mm->mmap_sem);
82630 @@ -2542,16 +2989,6 @@ SYSCALL_DEFINE2(munmap, unsigned long, addr, size_t, len)
82631 return vm_munmap(addr, len);
82632 }
82633
82634 -static inline void verify_mm_writelocked(struct mm_struct *mm)
82635 -{
82636 -#ifdef CONFIG_DEBUG_VM
82637 - if (unlikely(down_read_trylock(&mm->mmap_sem))) {
82638 - WARN_ON(1);
82639 - up_read(&mm->mmap_sem);
82640 - }
82641 -#endif
82642 -}
82643 -
82644 /*
82645 * this is really a simplified "do_mmap". it only handles
82646 * anonymous maps. eventually we may be able to do some
82647 @@ -2565,6 +3002,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
82648 struct rb_node ** rb_link, * rb_parent;
82649 pgoff_t pgoff = addr >> PAGE_SHIFT;
82650 int error;
82651 + unsigned long charged;
82652
82653 len = PAGE_ALIGN(len);
82654 if (!len)
82655 @@ -2572,16 +3010,30 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
82656
82657 flags = VM_DATA_DEFAULT_FLAGS | VM_ACCOUNT | mm->def_flags;
82658
82659 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
82660 + if (mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
82661 + flags &= ~VM_EXEC;
82662 +
82663 +#ifdef CONFIG_PAX_MPROTECT
82664 + if (mm->pax_flags & MF_PAX_MPROTECT)
82665 + flags &= ~VM_MAYEXEC;
82666 +#endif
82667 +
82668 + }
82669 +#endif
82670 +
82671 error = get_unmapped_area(NULL, addr, len, 0, MAP_FIXED);
82672 if (error & ~PAGE_MASK)
82673 return error;
82674
82675 + charged = len >> PAGE_SHIFT;
82676 +
82677 /*
82678 * mlock MCL_FUTURE?
82679 */
82680 if (mm->def_flags & VM_LOCKED) {
82681 unsigned long locked, lock_limit;
82682 - locked = len >> PAGE_SHIFT;
82683 + locked = charged;
82684 locked += mm->locked_vm;
82685 lock_limit = rlimit(RLIMIT_MEMLOCK);
82686 lock_limit >>= PAGE_SHIFT;
82687 @@ -2598,21 +3050,20 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
82688 /*
82689 * Clear old maps. this also does some error checking for us
82690 */
82691 - munmap_back:
82692 if (find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent)) {
82693 if (do_munmap(mm, addr, len))
82694 return -ENOMEM;
82695 - goto munmap_back;
82696 + BUG_ON(find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent));
82697 }
82698
82699 /* Check against address space limits *after* clearing old maps... */
82700 - if (!may_expand_vm(mm, len >> PAGE_SHIFT))
82701 + if (!may_expand_vm(mm, charged))
82702 return -ENOMEM;
82703
82704 if (mm->map_count > sysctl_max_map_count)
82705 return -ENOMEM;
82706
82707 - if (security_vm_enough_memory_mm(mm, len >> PAGE_SHIFT))
82708 + if (security_vm_enough_memory_mm(mm, charged))
82709 return -ENOMEM;
82710
82711 /* Can we just expand an old private anonymous mapping? */
82712 @@ -2626,7 +3077,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
82713 */
82714 vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
82715 if (!vma) {
82716 - vm_unacct_memory(len >> PAGE_SHIFT);
82717 + vm_unacct_memory(charged);
82718 return -ENOMEM;
82719 }
82720
82721 @@ -2640,9 +3091,10 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
82722 vma_link(mm, vma, prev, rb_link, rb_parent);
82723 out:
82724 perf_event_mmap(vma);
82725 - mm->total_vm += len >> PAGE_SHIFT;
82726 + mm->total_vm += charged;
82727 if (flags & VM_LOCKED)
82728 - mm->locked_vm += (len >> PAGE_SHIFT);
82729 + mm->locked_vm += charged;
82730 + track_exec_limit(mm, addr, addr + len, flags);
82731 return addr;
82732 }
82733
82734 @@ -2704,6 +3156,7 @@ void exit_mmap(struct mm_struct *mm)
82735 while (vma) {
82736 if (vma->vm_flags & VM_ACCOUNT)
82737 nr_accounted += vma_pages(vma);
82738 + vma->vm_mirror = NULL;
82739 vma = remove_vma(vma);
82740 }
82741 vm_unacct_memory(nr_accounted);
82742 @@ -2720,6 +3173,13 @@ int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
82743 struct vm_area_struct *prev;
82744 struct rb_node **rb_link, *rb_parent;
82745
82746 +#ifdef CONFIG_PAX_SEGMEXEC
82747 + struct vm_area_struct *vma_m = NULL;
82748 +#endif
82749 +
82750 + if (security_mmap_addr(vma->vm_start))
82751 + return -EPERM;
82752 +
82753 /*
82754 * The vm_pgoff of a purely anonymous vma should be irrelevant
82755 * until its first write fault, when page's anon_vma and index
82756 @@ -2743,7 +3203,21 @@ int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
82757 security_vm_enough_memory_mm(mm, vma_pages(vma)))
82758 return -ENOMEM;
82759
82760 +#ifdef CONFIG_PAX_SEGMEXEC
82761 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_flags & VM_EXEC)) {
82762 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
82763 + if (!vma_m)
82764 + return -ENOMEM;
82765 + }
82766 +#endif
82767 +
82768 vma_link(mm, vma, prev, rb_link, rb_parent);
82769 +
82770 +#ifdef CONFIG_PAX_SEGMEXEC
82771 + if (vma_m)
82772 + BUG_ON(pax_mirror_vma(vma_m, vma));
82773 +#endif
82774 +
82775 return 0;
82776 }
82777
82778 @@ -2763,6 +3237,8 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
82779 struct mempolicy *pol;
82780 bool faulted_in_anon_vma = true;
82781
82782 + BUG_ON(vma->vm_mirror);
82783 +
82784 /*
82785 * If anonymous vma has not yet been faulted, update new pgoff
82786 * to match new location, to increase its chance of merging.
82787 @@ -2829,6 +3305,39 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
82788 return NULL;
82789 }
82790
82791 +#ifdef CONFIG_PAX_SEGMEXEC
82792 +long pax_mirror_vma(struct vm_area_struct *vma_m, struct vm_area_struct *vma)
82793 +{
82794 + struct vm_area_struct *prev_m;
82795 + struct rb_node **rb_link_m, *rb_parent_m;
82796 + struct mempolicy *pol_m;
82797 +
82798 + BUG_ON(!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) || !(vma->vm_flags & VM_EXEC));
82799 + BUG_ON(vma->vm_mirror || vma_m->vm_mirror);
82800 + BUG_ON(!mpol_equal(vma_policy(vma), vma_policy(vma_m)));
82801 + *vma_m = *vma;
82802 + INIT_LIST_HEAD(&vma_m->anon_vma_chain);
82803 + if (anon_vma_clone(vma_m, vma))
82804 + return -ENOMEM;
82805 + pol_m = vma_policy(vma_m);
82806 + mpol_get(pol_m);
82807 + vma_set_policy(vma_m, pol_m);
82808 + vma_m->vm_start += SEGMEXEC_TASK_SIZE;
82809 + vma_m->vm_end += SEGMEXEC_TASK_SIZE;
82810 + vma_m->vm_flags &= ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT | VM_LOCKED);
82811 + vma_m->vm_page_prot = vm_get_page_prot(vma_m->vm_flags);
82812 + if (vma_m->vm_file)
82813 + get_file(vma_m->vm_file);
82814 + if (vma_m->vm_ops && vma_m->vm_ops->open)
82815 + vma_m->vm_ops->open(vma_m);
82816 + BUG_ON(find_vma_links(vma->vm_mm, vma_m->vm_start, vma_m->vm_end, &prev_m, &rb_link_m, &rb_parent_m));
82817 + vma_link(vma->vm_mm, vma_m, prev_m, rb_link_m, rb_parent_m);
82818 + vma_m->vm_mirror = vma;
82819 + vma->vm_mirror = vma_m;
82820 + return 0;
82821 +}
82822 +#endif
82823 +
82824 /*
82825 * Return true if the calling process may expand its vm space by the passed
82826 * number of pages
82827 @@ -2840,6 +3349,7 @@ int may_expand_vm(struct mm_struct *mm, unsigned long npages)
82828
82829 lim = rlimit(RLIMIT_AS) >> PAGE_SHIFT;
82830
82831 + gr_learn_resource(current, RLIMIT_AS, (cur + npages) << PAGE_SHIFT, 1);
82832 if (cur + npages > lim)
82833 return 0;
82834 return 1;
82835 @@ -2910,6 +3420,22 @@ int install_special_mapping(struct mm_struct *mm,
82836 vma->vm_start = addr;
82837 vma->vm_end = addr + len;
82838
82839 +#ifdef CONFIG_PAX_MPROTECT
82840 + if (mm->pax_flags & MF_PAX_MPROTECT) {
82841 +#ifndef CONFIG_PAX_MPROTECT_COMPAT
82842 + if ((vm_flags & (VM_WRITE | VM_EXEC)) == (VM_WRITE | VM_EXEC))
82843 + return -EPERM;
82844 + if (!(vm_flags & VM_EXEC))
82845 + vm_flags &= ~VM_MAYEXEC;
82846 +#else
82847 + if ((vm_flags & (VM_WRITE | VM_EXEC)) != VM_EXEC)
82848 + vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
82849 +#endif
82850 + else
82851 + vm_flags &= ~VM_MAYWRITE;
82852 + }
82853 +#endif
82854 +
82855 vma->vm_flags = vm_flags | mm->def_flags | VM_DONTEXPAND;
82856 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
82857
82858 diff --git a/mm/mprotect.c b/mm/mprotect.c
82859 index 94722a4..07d9926 100644
82860 --- a/mm/mprotect.c
82861 +++ b/mm/mprotect.c
82862 @@ -23,10 +23,18 @@
82863 #include <linux/mmu_notifier.h>
82864 #include <linux/migrate.h>
82865 #include <linux/perf_event.h>
82866 +#include <linux/sched/sysctl.h>
82867 +
82868 +#ifdef CONFIG_PAX_MPROTECT
82869 +#include <linux/elf.h>
82870 +#include <linux/binfmts.h>
82871 +#endif
82872 +
82873 #include <asm/uaccess.h>
82874 #include <asm/pgtable.h>
82875 #include <asm/cacheflush.h>
82876 #include <asm/tlbflush.h>
82877 +#include <asm/mmu_context.h>
82878
82879 #ifndef pgprot_modify
82880 static inline pgprot_t pgprot_modify(pgprot_t oldprot, pgprot_t newprot)
82881 @@ -233,6 +241,48 @@ unsigned long change_protection(struct vm_area_struct *vma, unsigned long start,
82882 return pages;
82883 }
82884
82885 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
82886 +/* called while holding the mmap semaphor for writing except stack expansion */
82887 +void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot)
82888 +{
82889 + unsigned long oldlimit, newlimit = 0UL;
82890 +
82891 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || (__supported_pte_mask & _PAGE_NX))
82892 + return;
82893 +
82894 + spin_lock(&mm->page_table_lock);
82895 + oldlimit = mm->context.user_cs_limit;
82896 + if ((prot & VM_EXEC) && oldlimit < end)
82897 + /* USER_CS limit moved up */
82898 + newlimit = end;
82899 + else if (!(prot & VM_EXEC) && start < oldlimit && oldlimit <= end)
82900 + /* USER_CS limit moved down */
82901 + newlimit = start;
82902 +
82903 + if (newlimit) {
82904 + mm->context.user_cs_limit = newlimit;
82905 +
82906 +#ifdef CONFIG_SMP
82907 + wmb();
82908 + cpus_clear(mm->context.cpu_user_cs_mask);
82909 + cpu_set(smp_processor_id(), mm->context.cpu_user_cs_mask);
82910 +#endif
82911 +
82912 + set_user_cs(mm->context.user_cs_base, mm->context.user_cs_limit, smp_processor_id());
82913 + }
82914 + spin_unlock(&mm->page_table_lock);
82915 + if (newlimit == end) {
82916 + struct vm_area_struct *vma = find_vma(mm, oldlimit);
82917 +
82918 + for (; vma && vma->vm_start < end; vma = vma->vm_next)
82919 + if (is_vm_hugetlb_page(vma))
82920 + hugetlb_change_protection(vma, vma->vm_start, vma->vm_end, vma->vm_page_prot);
82921 + else
82922 + change_protection(vma, vma->vm_start, vma->vm_end, vma->vm_page_prot, vma_wants_writenotify(vma), 0);
82923 + }
82924 +}
82925 +#endif
82926 +
82927 int
82928 mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
82929 unsigned long start, unsigned long end, unsigned long newflags)
82930 @@ -245,11 +295,29 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
82931 int error;
82932 int dirty_accountable = 0;
82933
82934 +#ifdef CONFIG_PAX_SEGMEXEC
82935 + struct vm_area_struct *vma_m = NULL;
82936 + unsigned long start_m, end_m;
82937 +
82938 + start_m = start + SEGMEXEC_TASK_SIZE;
82939 + end_m = end + SEGMEXEC_TASK_SIZE;
82940 +#endif
82941 +
82942 if (newflags == oldflags) {
82943 *pprev = vma;
82944 return 0;
82945 }
82946
82947 + if (newflags & (VM_READ | VM_WRITE | VM_EXEC)) {
82948 + struct vm_area_struct *prev = vma->vm_prev, *next = vma->vm_next;
82949 +
82950 + if (next && (next->vm_flags & VM_GROWSDOWN) && sysctl_heap_stack_gap > next->vm_start - end)
82951 + return -ENOMEM;
82952 +
82953 + if (prev && (prev->vm_flags & VM_GROWSUP) && sysctl_heap_stack_gap > start - prev->vm_end)
82954 + return -ENOMEM;
82955 + }
82956 +
82957 /*
82958 * If we make a private mapping writable we increase our commit;
82959 * but (without finer accounting) cannot reduce our commit if we
82960 @@ -266,6 +334,42 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
82961 }
82962 }
82963
82964 +#ifdef CONFIG_PAX_SEGMEXEC
82965 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && ((oldflags ^ newflags) & VM_EXEC)) {
82966 + if (start != vma->vm_start) {
82967 + error = split_vma(mm, vma, start, 1);
82968 + if (error)
82969 + goto fail;
82970 + BUG_ON(!*pprev || (*pprev)->vm_next == vma);
82971 + *pprev = (*pprev)->vm_next;
82972 + }
82973 +
82974 + if (end != vma->vm_end) {
82975 + error = split_vma(mm, vma, end, 0);
82976 + if (error)
82977 + goto fail;
82978 + }
82979 +
82980 + if (pax_find_mirror_vma(vma)) {
82981 + error = __do_munmap(mm, start_m, end_m - start_m);
82982 + if (error)
82983 + goto fail;
82984 + } else {
82985 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
82986 + if (!vma_m) {
82987 + error = -ENOMEM;
82988 + goto fail;
82989 + }
82990 + vma->vm_flags = newflags;
82991 + error = pax_mirror_vma(vma_m, vma);
82992 + if (error) {
82993 + vma->vm_flags = oldflags;
82994 + goto fail;
82995 + }
82996 + }
82997 + }
82998 +#endif
82999 +
83000 /*
83001 * First try to merge with previous and/or next vma.
83002 */
83003 @@ -296,9 +400,21 @@ success:
83004 * vm_flags and vm_page_prot are protected by the mmap_sem
83005 * held in write mode.
83006 */
83007 +
83008 +#ifdef CONFIG_PAX_SEGMEXEC
83009 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (newflags & VM_EXEC) && ((vma->vm_flags ^ newflags) & VM_READ))
83010 + pax_find_mirror_vma(vma)->vm_flags ^= VM_READ;
83011 +#endif
83012 +
83013 vma->vm_flags = newflags;
83014 +
83015 +#ifdef CONFIG_PAX_MPROTECT
83016 + if (mm->binfmt && mm->binfmt->handle_mprotect)
83017 + mm->binfmt->handle_mprotect(vma, newflags);
83018 +#endif
83019 +
83020 vma->vm_page_prot = pgprot_modify(vma->vm_page_prot,
83021 - vm_get_page_prot(newflags));
83022 + vm_get_page_prot(vma->vm_flags));
83023
83024 if (vma_wants_writenotify(vma)) {
83025 vma->vm_page_prot = vm_get_page_prot(newflags & ~VM_SHARED);
83026 @@ -337,6 +453,17 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
83027 end = start + len;
83028 if (end <= start)
83029 return -ENOMEM;
83030 +
83031 +#ifdef CONFIG_PAX_SEGMEXEC
83032 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
83033 + if (end > SEGMEXEC_TASK_SIZE)
83034 + return -EINVAL;
83035 + } else
83036 +#endif
83037 +
83038 + if (end > TASK_SIZE)
83039 + return -EINVAL;
83040 +
83041 if (!arch_validate_prot(prot))
83042 return -EINVAL;
83043
83044 @@ -344,7 +471,7 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
83045 /*
83046 * Does the application expect PROT_READ to imply PROT_EXEC:
83047 */
83048 - if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
83049 + if ((prot & (PROT_READ | PROT_WRITE)) && (current->personality & READ_IMPLIES_EXEC))
83050 prot |= PROT_EXEC;
83051
83052 vm_flags = calc_vm_prot_bits(prot);
83053 @@ -376,6 +503,11 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
83054 if (start > vma->vm_start)
83055 prev = vma;
83056
83057 +#ifdef CONFIG_PAX_MPROTECT
83058 + if (current->mm->binfmt && current->mm->binfmt->handle_mprotect)
83059 + current->mm->binfmt->handle_mprotect(vma, vm_flags);
83060 +#endif
83061 +
83062 for (nstart = start ; ; ) {
83063 unsigned long newflags;
83064
83065 @@ -386,6 +518,14 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
83066
83067 /* newflags >> 4 shift VM_MAY% in place of VM_% */
83068 if ((newflags & ~(newflags >> 4)) & (VM_READ | VM_WRITE | VM_EXEC)) {
83069 + if (prot & (PROT_WRITE | PROT_EXEC))
83070 + gr_log_rwxmprotect(vma->vm_file);
83071 +
83072 + error = -EACCES;
83073 + goto out;
83074 + }
83075 +
83076 + if (!gr_acl_handle_mprotect(vma->vm_file, prot)) {
83077 error = -EACCES;
83078 goto out;
83079 }
83080 @@ -400,6 +540,9 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
83081 error = mprotect_fixup(vma, &prev, nstart, tmp, newflags);
83082 if (error)
83083 goto out;
83084 +
83085 + track_exec_limit(current->mm, nstart, tmp, vm_flags);
83086 +
83087 nstart = tmp;
83088
83089 if (nstart < prev->vm_end)
83090 diff --git a/mm/mremap.c b/mm/mremap.c
83091 index 463a257..c0c7a92 100644
83092 --- a/mm/mremap.c
83093 +++ b/mm/mremap.c
83094 @@ -126,6 +126,12 @@ static void move_ptes(struct vm_area_struct *vma, pmd_t *old_pmd,
83095 continue;
83096 pte = ptep_get_and_clear(mm, old_addr, old_pte);
83097 pte = move_pte(pte, new_vma->vm_page_prot, old_addr, new_addr);
83098 +
83099 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
83100 + if (!(__supported_pte_mask & _PAGE_NX) && (new_vma->vm_flags & (VM_PAGEEXEC | VM_EXEC)) == VM_PAGEEXEC)
83101 + pte = pte_exprotect(pte);
83102 +#endif
83103 +
83104 set_pte_at(mm, new_addr, new_pte, pte);
83105 }
83106
83107 @@ -318,6 +324,11 @@ static struct vm_area_struct *vma_to_resize(unsigned long addr,
83108 if (is_vm_hugetlb_page(vma))
83109 goto Einval;
83110
83111 +#ifdef CONFIG_PAX_SEGMEXEC
83112 + if (pax_find_mirror_vma(vma))
83113 + goto Einval;
83114 +#endif
83115 +
83116 /* We can't remap across vm area boundaries */
83117 if (old_len > vma->vm_end - addr)
83118 goto Efault;
83119 @@ -373,20 +384,25 @@ static unsigned long mremap_to(unsigned long addr, unsigned long old_len,
83120 unsigned long ret = -EINVAL;
83121 unsigned long charged = 0;
83122 unsigned long map_flags;
83123 + unsigned long pax_task_size = TASK_SIZE;
83124
83125 if (new_addr & ~PAGE_MASK)
83126 goto out;
83127
83128 - if (new_len > TASK_SIZE || new_addr > TASK_SIZE - new_len)
83129 +#ifdef CONFIG_PAX_SEGMEXEC
83130 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
83131 + pax_task_size = SEGMEXEC_TASK_SIZE;
83132 +#endif
83133 +
83134 + pax_task_size -= PAGE_SIZE;
83135 +
83136 + if (new_len > TASK_SIZE || new_addr > pax_task_size - new_len)
83137 goto out;
83138
83139 /* Check if the location we're moving into overlaps the
83140 * old location at all, and fail if it does.
83141 */
83142 - if ((new_addr <= addr) && (new_addr+new_len) > addr)
83143 - goto out;
83144 -
83145 - if ((addr <= new_addr) && (addr+old_len) > new_addr)
83146 + if (addr + old_len > new_addr && new_addr + new_len > addr)
83147 goto out;
83148
83149 ret = do_munmap(mm, new_addr, new_len);
83150 @@ -455,6 +471,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
83151 unsigned long ret = -EINVAL;
83152 unsigned long charged = 0;
83153 bool locked = false;
83154 + unsigned long pax_task_size = TASK_SIZE;
83155
83156 down_write(&current->mm->mmap_sem);
83157
83158 @@ -475,6 +492,17 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
83159 if (!new_len)
83160 goto out;
83161
83162 +#ifdef CONFIG_PAX_SEGMEXEC
83163 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
83164 + pax_task_size = SEGMEXEC_TASK_SIZE;
83165 +#endif
83166 +
83167 + pax_task_size -= PAGE_SIZE;
83168 +
83169 + if (new_len > pax_task_size || addr > pax_task_size-new_len ||
83170 + old_len > pax_task_size || addr > pax_task_size-old_len)
83171 + goto out;
83172 +
83173 if (flags & MREMAP_FIXED) {
83174 if (flags & MREMAP_MAYMOVE)
83175 ret = mremap_to(addr, old_len, new_addr, new_len,
83176 @@ -524,6 +552,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
83177 new_addr = addr;
83178 }
83179 ret = addr;
83180 + track_exec_limit(vma->vm_mm, vma->vm_start, addr + new_len, vma->vm_flags);
83181 goto out;
83182 }
83183 }
83184 @@ -547,7 +576,12 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
83185 goto out;
83186 }
83187
83188 + map_flags = vma->vm_flags;
83189 ret = move_vma(vma, addr, old_len, new_len, new_addr, &locked);
83190 + if (!(ret & ~PAGE_MASK)) {
83191 + track_exec_limit(current->mm, addr, addr + old_len, 0UL);
83192 + track_exec_limit(current->mm, new_addr, new_addr + new_len, map_flags);
83193 + }
83194 }
83195 out:
83196 if (ret & ~PAGE_MASK)
83197 diff --git a/mm/nommu.c b/mm/nommu.c
83198 index e001768..9b52b30 100644
83199 --- a/mm/nommu.c
83200 +++ b/mm/nommu.c
83201 @@ -63,7 +63,6 @@ int sysctl_overcommit_memory = OVERCOMMIT_GUESS; /* heuristic overcommit */
83202 int sysctl_overcommit_ratio = 50; /* default is 50% */
83203 int sysctl_max_map_count = DEFAULT_MAX_MAP_COUNT;
83204 int sysctl_nr_trim_pages = CONFIG_NOMMU_INITIAL_TRIM_EXCESS;
83205 -int heap_stack_gap = 0;
83206
83207 atomic_long_t mmap_pages_allocated;
83208
83209 @@ -841,15 +840,6 @@ struct vm_area_struct *find_vma(struct mm_struct *mm, unsigned long addr)
83210 EXPORT_SYMBOL(find_vma);
83211
83212 /*
83213 - * find a VMA
83214 - * - we don't extend stack VMAs under NOMMU conditions
83215 - */
83216 -struct vm_area_struct *find_extend_vma(struct mm_struct *mm, unsigned long addr)
83217 -{
83218 - return find_vma(mm, addr);
83219 -}
83220 -
83221 -/*
83222 * expand a stack to a given address
83223 * - not supported under NOMMU conditions
83224 */
83225 @@ -1560,6 +1550,7 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
83226
83227 /* most fields are the same, copy all, and then fixup */
83228 *new = *vma;
83229 + INIT_LIST_HEAD(&new->anon_vma_chain);
83230 *region = *vma->vm_region;
83231 new->vm_region = region;
83232
83233 @@ -1992,8 +1983,8 @@ int generic_file_remap_pages(struct vm_area_struct *vma, unsigned long addr,
83234 }
83235 EXPORT_SYMBOL(generic_file_remap_pages);
83236
83237 -static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
83238 - unsigned long addr, void *buf, int len, int write)
83239 +static ssize_t __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
83240 + unsigned long addr, void *buf, size_t len, int write)
83241 {
83242 struct vm_area_struct *vma;
83243
83244 @@ -2034,8 +2025,8 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
83245 *
83246 * The caller must hold a reference on @mm.
83247 */
83248 -int access_remote_vm(struct mm_struct *mm, unsigned long addr,
83249 - void *buf, int len, int write)
83250 +ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
83251 + void *buf, size_t len, int write)
83252 {
83253 return __access_remote_vm(NULL, mm, addr, buf, len, write);
83254 }
83255 @@ -2044,7 +2035,7 @@ int access_remote_vm(struct mm_struct *mm, unsigned long addr,
83256 * Access another process' address space.
83257 * - source/target buffer must be kernel space
83258 */
83259 -int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write)
83260 +ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, size_t len, int write)
83261 {
83262 struct mm_struct *mm;
83263
83264 diff --git a/mm/page-writeback.c b/mm/page-writeback.c
83265 index efe6814..64b4701 100644
83266 --- a/mm/page-writeback.c
83267 +++ b/mm/page-writeback.c
83268 @@ -659,7 +659,7 @@ unsigned long bdi_dirty_limit(struct backing_dev_info *bdi, unsigned long dirty)
83269 * card's bdi_dirty may rush to many times higher than bdi_setpoint.
83270 * - the bdi dirty thresh drops quickly due to change of JBOD workload
83271 */
83272 -static unsigned long bdi_position_ratio(struct backing_dev_info *bdi,
83273 +static unsigned long __intentional_overflow(-1) bdi_position_ratio(struct backing_dev_info *bdi,
83274 unsigned long thresh,
83275 unsigned long bg_thresh,
83276 unsigned long dirty,
83277 @@ -1634,7 +1634,7 @@ ratelimit_handler(struct notifier_block *self, unsigned long action,
83278 }
83279 }
83280
83281 -static struct notifier_block __cpuinitdata ratelimit_nb = {
83282 +static struct notifier_block ratelimit_nb = {
83283 .notifier_call = ratelimit_handler,
83284 .next = NULL,
83285 };
83286 diff --git a/mm/page_alloc.c b/mm/page_alloc.c
83287 index 8fcced7..ebcd481 100644
83288 --- a/mm/page_alloc.c
83289 +++ b/mm/page_alloc.c
83290 @@ -59,6 +59,7 @@
83291 #include <linux/migrate.h>
83292 #include <linux/page-debug-flags.h>
83293 #include <linux/sched/rt.h>
83294 +#include <linux/random.h>
83295
83296 #include <asm/tlbflush.h>
83297 #include <asm/div64.h>
83298 @@ -344,7 +345,7 @@ out:
83299 * This usage means that zero-order pages may not be compound.
83300 */
83301
83302 -static void free_compound_page(struct page *page)
83303 +void free_compound_page(struct page *page)
83304 {
83305 __free_pages_ok(page, compound_order(page));
83306 }
83307 @@ -701,6 +702,10 @@ static bool free_pages_prepare(struct page *page, unsigned int order)
83308 int i;
83309 int bad = 0;
83310
83311 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
83312 + unsigned long index = 1UL << order;
83313 +#endif
83314 +
83315 trace_mm_page_free(page, order);
83316 kmemcheck_free_shadow(page, order);
83317
83318 @@ -716,6 +721,12 @@ static bool free_pages_prepare(struct page *page, unsigned int order)
83319 debug_check_no_obj_freed(page_address(page),
83320 PAGE_SIZE << order);
83321 }
83322 +
83323 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
83324 + for (; index; --index)
83325 + sanitize_highpage(page + index - 1);
83326 +#endif
83327 +
83328 arch_free_page(page, order);
83329 kernel_map_pages(page, 1 << order, 0);
83330
83331 @@ -738,6 +749,19 @@ static void __free_pages_ok(struct page *page, unsigned int order)
83332 local_irq_restore(flags);
83333 }
83334
83335 +#ifdef CONFIG_PAX_LATENT_ENTROPY
83336 +bool __meminitdata extra_latent_entropy;
83337 +
83338 +static int __init setup_pax_extra_latent_entropy(char *str)
83339 +{
83340 + extra_latent_entropy = true;
83341 + return 0;
83342 +}
83343 +early_param("pax_extra_latent_entropy", setup_pax_extra_latent_entropy);
83344 +
83345 +volatile u64 latent_entropy;
83346 +#endif
83347 +
83348 /*
83349 * Read access to zone->managed_pages is safe because it's unsigned long,
83350 * but we still need to serialize writers. Currently all callers of
83351 @@ -760,6 +784,19 @@ void __meminit __free_pages_bootmem(struct page *page, unsigned int order)
83352 set_page_count(p, 0);
83353 }
83354
83355 +#ifdef CONFIG_PAX_LATENT_ENTROPY
83356 + if (extra_latent_entropy && !PageHighMem(page) && page_to_pfn(page) < 0x100000) {
83357 + u64 hash = 0;
83358 + size_t index, end = PAGE_SIZE * nr_pages / sizeof hash;
83359 + const u64 *data = lowmem_page_address(page);
83360 +
83361 + for (index = 0; index < end; index++)
83362 + hash ^= hash + data[index];
83363 + latent_entropy ^= hash;
83364 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
83365 + }
83366 +#endif
83367 +
83368 page_zone(page)->managed_pages += 1 << order;
83369 set_page_refcounted(page);
83370 __free_pages(page, order);
83371 @@ -869,8 +906,10 @@ static int prep_new_page(struct page *page, int order, gfp_t gfp_flags)
83372 arch_alloc_page(page, order);
83373 kernel_map_pages(page, 1 << order, 1);
83374
83375 +#ifndef CONFIG_PAX_MEMORY_SANITIZE
83376 if (gfp_flags & __GFP_ZERO)
83377 prep_zero_page(page, order, gfp_flags);
83378 +#endif
83379
83380 if (order && (gfp_flags & __GFP_COMP))
83381 prep_compound_page(page, order);
83382 diff --git a/mm/page_io.c b/mm/page_io.c
83383 index 6182870..4bba6a2 100644
83384 --- a/mm/page_io.c
83385 +++ b/mm/page_io.c
83386 @@ -205,7 +205,7 @@ int swap_writepage(struct page *page, struct writeback_control *wbc)
83387 struct file *swap_file = sis->swap_file;
83388 struct address_space *mapping = swap_file->f_mapping;
83389 struct iovec iov = {
83390 - .iov_base = kmap(page),
83391 + .iov_base = (void __force_user *)kmap(page),
83392 .iov_len = PAGE_SIZE,
83393 };
83394
83395 diff --git a/mm/percpu.c b/mm/percpu.c
83396 index 8c8e08f..73a5cda 100644
83397 --- a/mm/percpu.c
83398 +++ b/mm/percpu.c
83399 @@ -122,7 +122,7 @@ static unsigned int pcpu_low_unit_cpu __read_mostly;
83400 static unsigned int pcpu_high_unit_cpu __read_mostly;
83401
83402 /* the address of the first chunk which starts with the kernel static area */
83403 -void *pcpu_base_addr __read_mostly;
83404 +void *pcpu_base_addr __read_only;
83405 EXPORT_SYMBOL_GPL(pcpu_base_addr);
83406
83407 static const int *pcpu_unit_map __read_mostly; /* cpu -> unit */
83408 diff --git a/mm/process_vm_access.c b/mm/process_vm_access.c
83409 index fd26d04..0cea1b0 100644
83410 --- a/mm/process_vm_access.c
83411 +++ b/mm/process_vm_access.c
83412 @@ -13,6 +13,7 @@
83413 #include <linux/uio.h>
83414 #include <linux/sched.h>
83415 #include <linux/highmem.h>
83416 +#include <linux/security.h>
83417 #include <linux/ptrace.h>
83418 #include <linux/slab.h>
83419 #include <linux/syscalls.h>
83420 @@ -258,19 +259,19 @@ static ssize_t process_vm_rw_core(pid_t pid, const struct iovec *lvec,
83421 size_t iov_l_curr_offset = 0;
83422 ssize_t iov_len;
83423
83424 + return -ENOSYS; // PaX: until properly audited
83425 +
83426 /*
83427 * Work out how many pages of struct pages we're going to need
83428 * when eventually calling get_user_pages
83429 */
83430 for (i = 0; i < riovcnt; i++) {
83431 iov_len = rvec[i].iov_len;
83432 - if (iov_len > 0) {
83433 - nr_pages_iov = ((unsigned long)rvec[i].iov_base
83434 - + iov_len)
83435 - / PAGE_SIZE - (unsigned long)rvec[i].iov_base
83436 - / PAGE_SIZE + 1;
83437 - nr_pages = max(nr_pages, nr_pages_iov);
83438 - }
83439 + if (iov_len <= 0)
83440 + continue;
83441 + nr_pages_iov = ((unsigned long)rvec[i].iov_base + iov_len) / PAGE_SIZE -
83442 + (unsigned long)rvec[i].iov_base / PAGE_SIZE + 1;
83443 + nr_pages = max(nr_pages, nr_pages_iov);
83444 }
83445
83446 if (nr_pages == 0)
83447 @@ -298,6 +299,11 @@ static ssize_t process_vm_rw_core(pid_t pid, const struct iovec *lvec,
83448 goto free_proc_pages;
83449 }
83450
83451 + if (gr_handle_ptrace(task, vm_write ? PTRACE_POKETEXT : PTRACE_ATTACH)) {
83452 + rc = -EPERM;
83453 + goto put_task_struct;
83454 + }
83455 +
83456 mm = mm_access(task, PTRACE_MODE_ATTACH);
83457 if (!mm || IS_ERR(mm)) {
83458 rc = IS_ERR(mm) ? PTR_ERR(mm) : -ESRCH;
83459 diff --git a/mm/rmap.c b/mm/rmap.c
83460 index 807c96b..0e05279 100644
83461 --- a/mm/rmap.c
83462 +++ b/mm/rmap.c
83463 @@ -163,6 +163,10 @@ int anon_vma_prepare(struct vm_area_struct *vma)
83464 struct anon_vma *anon_vma = vma->anon_vma;
83465 struct anon_vma_chain *avc;
83466
83467 +#ifdef CONFIG_PAX_SEGMEXEC
83468 + struct anon_vma_chain *avc_m = NULL;
83469 +#endif
83470 +
83471 might_sleep();
83472 if (unlikely(!anon_vma)) {
83473 struct mm_struct *mm = vma->vm_mm;
83474 @@ -172,6 +176,12 @@ int anon_vma_prepare(struct vm_area_struct *vma)
83475 if (!avc)
83476 goto out_enomem;
83477
83478 +#ifdef CONFIG_PAX_SEGMEXEC
83479 + avc_m = anon_vma_chain_alloc(GFP_KERNEL);
83480 + if (!avc_m)
83481 + goto out_enomem_free_avc;
83482 +#endif
83483 +
83484 anon_vma = find_mergeable_anon_vma(vma);
83485 allocated = NULL;
83486 if (!anon_vma) {
83487 @@ -185,6 +195,18 @@ int anon_vma_prepare(struct vm_area_struct *vma)
83488 /* page_table_lock to protect against threads */
83489 spin_lock(&mm->page_table_lock);
83490 if (likely(!vma->anon_vma)) {
83491 +
83492 +#ifdef CONFIG_PAX_SEGMEXEC
83493 + struct vm_area_struct *vma_m = pax_find_mirror_vma(vma);
83494 +
83495 + if (vma_m) {
83496 + BUG_ON(vma_m->anon_vma);
83497 + vma_m->anon_vma = anon_vma;
83498 + anon_vma_chain_link(vma_m, avc_m, anon_vma);
83499 + avc_m = NULL;
83500 + }
83501 +#endif
83502 +
83503 vma->anon_vma = anon_vma;
83504 anon_vma_chain_link(vma, avc, anon_vma);
83505 allocated = NULL;
83506 @@ -195,12 +217,24 @@ int anon_vma_prepare(struct vm_area_struct *vma)
83507
83508 if (unlikely(allocated))
83509 put_anon_vma(allocated);
83510 +
83511 +#ifdef CONFIG_PAX_SEGMEXEC
83512 + if (unlikely(avc_m))
83513 + anon_vma_chain_free(avc_m);
83514 +#endif
83515 +
83516 if (unlikely(avc))
83517 anon_vma_chain_free(avc);
83518 }
83519 return 0;
83520
83521 out_enomem_free_avc:
83522 +
83523 +#ifdef CONFIG_PAX_SEGMEXEC
83524 + if (avc_m)
83525 + anon_vma_chain_free(avc_m);
83526 +#endif
83527 +
83528 anon_vma_chain_free(avc);
83529 out_enomem:
83530 return -ENOMEM;
83531 @@ -236,7 +270,7 @@ static inline void unlock_anon_vma_root(struct anon_vma *root)
83532 * Attach the anon_vmas from src to dst.
83533 * Returns 0 on success, -ENOMEM on failure.
83534 */
83535 -int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
83536 +int anon_vma_clone(struct vm_area_struct *dst, const struct vm_area_struct *src)
83537 {
83538 struct anon_vma_chain *avc, *pavc;
83539 struct anon_vma *root = NULL;
83540 @@ -269,7 +303,7 @@ int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
83541 * the corresponding VMA in the parent process is attached to.
83542 * Returns 0 on success, non-zero on failure.
83543 */
83544 -int anon_vma_fork(struct vm_area_struct *vma, struct vm_area_struct *pvma)
83545 +int anon_vma_fork(struct vm_area_struct *vma, const struct vm_area_struct *pvma)
83546 {
83547 struct anon_vma_chain *avc;
83548 struct anon_vma *anon_vma;
83549 diff --git a/mm/shmem.c b/mm/shmem.c
83550 index 1c44af7..cefe9a6 100644
83551 --- a/mm/shmem.c
83552 +++ b/mm/shmem.c
83553 @@ -31,7 +31,7 @@
83554 #include <linux/export.h>
83555 #include <linux/swap.h>
83556
83557 -static struct vfsmount *shm_mnt;
83558 +struct vfsmount *shm_mnt;
83559
83560 #ifdef CONFIG_SHMEM
83561 /*
83562 @@ -75,7 +75,7 @@ static struct vfsmount *shm_mnt;
83563 #define BOGO_DIRENT_SIZE 20
83564
83565 /* Symlink up to this size is kmalloc'ed instead of using a swappable page */
83566 -#define SHORT_SYMLINK_LEN 128
83567 +#define SHORT_SYMLINK_LEN 64
83568
83569 /*
83570 * shmem_fallocate and shmem_writepage communicate via inode->i_private
83571 @@ -2201,6 +2201,11 @@ static const struct xattr_handler *shmem_xattr_handlers[] = {
83572 static int shmem_xattr_validate(const char *name)
83573 {
83574 struct { const char *prefix; size_t len; } arr[] = {
83575 +
83576 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
83577 + { XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN},
83578 +#endif
83579 +
83580 { XATTR_SECURITY_PREFIX, XATTR_SECURITY_PREFIX_LEN },
83581 { XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN }
83582 };
83583 @@ -2256,6 +2261,15 @@ static int shmem_setxattr(struct dentry *dentry, const char *name,
83584 if (err)
83585 return err;
83586
83587 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
83588 + if (!strncmp(name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN)) {
83589 + if (strcmp(name, XATTR_NAME_PAX_FLAGS))
83590 + return -EOPNOTSUPP;
83591 + if (size > 8)
83592 + return -EINVAL;
83593 + }
83594 +#endif
83595 +
83596 return simple_xattr_set(&info->xattrs, name, value, size, flags);
83597 }
83598
83599 @@ -2568,8 +2582,7 @@ int shmem_fill_super(struct super_block *sb, void *data, int silent)
83600 int err = -ENOMEM;
83601
83602 /* Round up to L1_CACHE_BYTES to resist false sharing */
83603 - sbinfo = kzalloc(max((int)sizeof(struct shmem_sb_info),
83604 - L1_CACHE_BYTES), GFP_KERNEL);
83605 + sbinfo = kzalloc(max(sizeof(struct shmem_sb_info), L1_CACHE_BYTES), GFP_KERNEL);
83606 if (!sbinfo)
83607 return -ENOMEM;
83608
83609 diff --git a/mm/slab.c b/mm/slab.c
83610 index 856e4a1..fafb820 100644
83611 --- a/mm/slab.c
83612 +++ b/mm/slab.c
83613 @@ -306,7 +306,7 @@ struct kmem_list3 {
83614 * Need this for bootstrapping a per node allocator.
83615 */
83616 #define NUM_INIT_LISTS (3 * MAX_NUMNODES)
83617 -static struct kmem_list3 __initdata initkmem_list3[NUM_INIT_LISTS];
83618 +static struct kmem_list3 initkmem_list3[NUM_INIT_LISTS];
83619 #define CACHE_CACHE 0
83620 #define SIZE_AC MAX_NUMNODES
83621 #define SIZE_L3 (2 * MAX_NUMNODES)
83622 @@ -407,10 +407,10 @@ static void kmem_list3_init(struct kmem_list3 *parent)
83623 if ((x)->max_freeable < i) \
83624 (x)->max_freeable = i; \
83625 } while (0)
83626 -#define STATS_INC_ALLOCHIT(x) atomic_inc(&(x)->allochit)
83627 -#define STATS_INC_ALLOCMISS(x) atomic_inc(&(x)->allocmiss)
83628 -#define STATS_INC_FREEHIT(x) atomic_inc(&(x)->freehit)
83629 -#define STATS_INC_FREEMISS(x) atomic_inc(&(x)->freemiss)
83630 +#define STATS_INC_ALLOCHIT(x) atomic_inc_unchecked(&(x)->allochit)
83631 +#define STATS_INC_ALLOCMISS(x) atomic_inc_unchecked(&(x)->allocmiss)
83632 +#define STATS_INC_FREEHIT(x) atomic_inc_unchecked(&(x)->freehit)
83633 +#define STATS_INC_FREEMISS(x) atomic_inc_unchecked(&(x)->freemiss)
83634 #else
83635 #define STATS_INC_ACTIVE(x) do { } while (0)
83636 #define STATS_DEC_ACTIVE(x) do { } while (0)
83637 @@ -518,7 +518,7 @@ static inline void *index_to_obj(struct kmem_cache *cache, struct slab *slab,
83638 * reciprocal_divide(offset, cache->reciprocal_buffer_size)
83639 */
83640 static inline unsigned int obj_to_index(const struct kmem_cache *cache,
83641 - const struct slab *slab, void *obj)
83642 + const struct slab *slab, const void *obj)
83643 {
83644 u32 offset = (obj - slab->s_mem);
83645 return reciprocal_divide(offset, cache->reciprocal_buffer_size);
83646 @@ -539,12 +539,13 @@ EXPORT_SYMBOL(malloc_sizes);
83647 struct cache_names {
83648 char *name;
83649 char *name_dma;
83650 + char *name_usercopy;
83651 };
83652
83653 static struct cache_names __initdata cache_names[] = {
83654 -#define CACHE(x) { .name = "size-" #x, .name_dma = "size-" #x "(DMA)" },
83655 +#define CACHE(x) { .name = "size-" #x, .name_dma = "size-" #x "(DMA)", .name_usercopy = "size-" #x "(USERCOPY)" },
83656 #include <linux/kmalloc_sizes.h>
83657 - {NULL,}
83658 + {NULL}
83659 #undef CACHE
83660 };
83661
83662 @@ -729,6 +730,12 @@ static inline struct kmem_cache *__find_general_cachep(size_t size,
83663 if (unlikely(gfpflags & GFP_DMA))
83664 return csizep->cs_dmacachep;
83665 #endif
83666 +
83667 +#ifdef CONFIG_PAX_USERCOPY_SLABS
83668 + if (unlikely(gfpflags & GFP_USERCOPY))
83669 + return csizep->cs_usercopycachep;
83670 +#endif
83671 +
83672 return csizep->cs_cachep;
83673 }
83674
83675 @@ -1482,7 +1489,7 @@ static int __cpuinit cpuup_callback(struct notifier_block *nfb,
83676 return notifier_from_errno(err);
83677 }
83678
83679 -static struct notifier_block __cpuinitdata cpucache_notifier = {
83680 +static struct notifier_block cpucache_notifier = {
83681 &cpuup_callback, NULL, 0
83682 };
83683
83684 @@ -1667,12 +1674,12 @@ void __init kmem_cache_init(void)
83685 */
83686
83687 sizes[INDEX_AC].cs_cachep = create_kmalloc_cache(names[INDEX_AC].name,
83688 - sizes[INDEX_AC].cs_size, ARCH_KMALLOC_FLAGS);
83689 + sizes[INDEX_AC].cs_size, ARCH_KMALLOC_FLAGS|SLAB_USERCOPY);
83690
83691 if (INDEX_AC != INDEX_L3)
83692 sizes[INDEX_L3].cs_cachep =
83693 create_kmalloc_cache(names[INDEX_L3].name,
83694 - sizes[INDEX_L3].cs_size, ARCH_KMALLOC_FLAGS);
83695 + sizes[INDEX_L3].cs_size, ARCH_KMALLOC_FLAGS|SLAB_USERCOPY);
83696
83697 slab_early_init = 0;
83698
83699 @@ -1686,13 +1693,20 @@ void __init kmem_cache_init(void)
83700 */
83701 if (!sizes->cs_cachep)
83702 sizes->cs_cachep = create_kmalloc_cache(names->name,
83703 - sizes->cs_size, ARCH_KMALLOC_FLAGS);
83704 + sizes->cs_size, ARCH_KMALLOC_FLAGS|SLAB_USERCOPY);
83705
83706 #ifdef CONFIG_ZONE_DMA
83707 sizes->cs_dmacachep = create_kmalloc_cache(
83708 names->name_dma, sizes->cs_size,
83709 SLAB_CACHE_DMA|ARCH_KMALLOC_FLAGS);
83710 #endif
83711 +
83712 +#ifdef CONFIG_PAX_USERCOPY_SLABS
83713 + sizes->cs_usercopycachep = create_kmalloc_cache(
83714 + names->name_usercopy, sizes->cs_size,
83715 + ARCH_KMALLOC_FLAGS|SLAB_USERCOPY);
83716 +#endif
83717 +
83718 sizes++;
83719 names++;
83720 }
83721 @@ -3924,6 +3938,7 @@ void kfree(const void *objp)
83722
83723 if (unlikely(ZERO_OR_NULL_PTR(objp)))
83724 return;
83725 + VM_BUG_ON(!virt_addr_valid(objp));
83726 local_irq_save(flags);
83727 kfree_debugcheck(objp);
83728 c = virt_to_cache(objp);
83729 @@ -4365,10 +4380,10 @@ void slabinfo_show_stats(struct seq_file *m, struct kmem_cache *cachep)
83730 }
83731 /* cpu stats */
83732 {
83733 - unsigned long allochit = atomic_read(&cachep->allochit);
83734 - unsigned long allocmiss = atomic_read(&cachep->allocmiss);
83735 - unsigned long freehit = atomic_read(&cachep->freehit);
83736 - unsigned long freemiss = atomic_read(&cachep->freemiss);
83737 + unsigned long allochit = atomic_read_unchecked(&cachep->allochit);
83738 + unsigned long allocmiss = atomic_read_unchecked(&cachep->allocmiss);
83739 + unsigned long freehit = atomic_read_unchecked(&cachep->freehit);
83740 + unsigned long freemiss = atomic_read_unchecked(&cachep->freemiss);
83741
83742 seq_printf(m, " : cpustat %6lu %6lu %6lu %6lu",
83743 allochit, allocmiss, freehit, freemiss);
83744 @@ -4600,13 +4615,71 @@ static const struct file_operations proc_slabstats_operations = {
83745 static int __init slab_proc_init(void)
83746 {
83747 #ifdef CONFIG_DEBUG_SLAB_LEAK
83748 - proc_create("slab_allocators", 0, NULL, &proc_slabstats_operations);
83749 + proc_create("slab_allocators", S_IRUSR, NULL, &proc_slabstats_operations);
83750 #endif
83751 return 0;
83752 }
83753 module_init(slab_proc_init);
83754 #endif
83755
83756 +bool is_usercopy_object(const void *ptr)
83757 +{
83758 + struct page *page;
83759 + struct kmem_cache *cachep;
83760 +
83761 + if (ZERO_OR_NULL_PTR(ptr))
83762 + return false;
83763 +
83764 + if (!slab_is_available())
83765 + return false;
83766 +
83767 + if (!virt_addr_valid(ptr))
83768 + return false;
83769 +
83770 + page = virt_to_head_page(ptr);
83771 +
83772 + if (!PageSlab(page))
83773 + return false;
83774 +
83775 + cachep = page->slab_cache;
83776 + return cachep->flags & SLAB_USERCOPY;
83777 +}
83778 +
83779 +#ifdef CONFIG_PAX_USERCOPY
83780 +const char *check_heap_object(const void *ptr, unsigned long n)
83781 +{
83782 + struct page *page;
83783 + struct kmem_cache *cachep;
83784 + struct slab *slabp;
83785 + unsigned int objnr;
83786 + unsigned long offset;
83787 +
83788 + if (ZERO_OR_NULL_PTR(ptr))
83789 + return "<null>";
83790 +
83791 + if (!virt_addr_valid(ptr))
83792 + return NULL;
83793 +
83794 + page = virt_to_head_page(ptr);
83795 +
83796 + if (!PageSlab(page))
83797 + return NULL;
83798 +
83799 + cachep = page->slab_cache;
83800 + if (!(cachep->flags & SLAB_USERCOPY))
83801 + return cachep->name;
83802 +
83803 + slabp = page->slab_page;
83804 + objnr = obj_to_index(cachep, slabp, ptr);
83805 + BUG_ON(objnr >= cachep->num);
83806 + offset = ptr - index_to_obj(cachep, slabp, objnr) - obj_offset(cachep);
83807 + if (offset <= cachep->object_size && n <= cachep->object_size - offset)
83808 + return NULL;
83809 +
83810 + return cachep->name;
83811 +}
83812 +#endif
83813 +
83814 /**
83815 * ksize - get the actual amount of memory allocated for a given object
83816 * @objp: Pointer to the object
83817 diff --git a/mm/slab.h b/mm/slab.h
83818 index 34a98d6..73633d1 100644
83819 --- a/mm/slab.h
83820 +++ b/mm/slab.h
83821 @@ -58,7 +58,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
83822
83823 /* Legal flag mask for kmem_cache_create(), for various configurations */
83824 #define SLAB_CORE_FLAGS (SLAB_HWCACHE_ALIGN | SLAB_CACHE_DMA | SLAB_PANIC | \
83825 - SLAB_DESTROY_BY_RCU | SLAB_DEBUG_OBJECTS )
83826 + SLAB_DESTROY_BY_RCU | SLAB_DEBUG_OBJECTS | SLAB_USERCOPY)
83827
83828 #if defined(CONFIG_DEBUG_SLAB)
83829 #define SLAB_DEBUG_FLAGS (SLAB_RED_ZONE | SLAB_POISON | SLAB_STORE_USER)
83830 @@ -220,6 +220,9 @@ static inline struct kmem_cache *cache_from_obj(struct kmem_cache *s, void *x)
83831 return s;
83832
83833 page = virt_to_head_page(x);
83834 +
83835 + BUG_ON(!PageSlab(page));
83836 +
83837 cachep = page->slab_cache;
83838 if (slab_equal_or_root(cachep, s))
83839 return cachep;
83840 diff --git a/mm/slab_common.c b/mm/slab_common.c
83841 index 3f3cd97..93b0236 100644
83842 --- a/mm/slab_common.c
83843 +++ b/mm/slab_common.c
83844 @@ -22,7 +22,7 @@
83845
83846 #include "slab.h"
83847
83848 -enum slab_state slab_state;
83849 +enum slab_state slab_state __read_only;
83850 LIST_HEAD(slab_caches);
83851 DEFINE_MUTEX(slab_mutex);
83852 struct kmem_cache *kmem_cache;
83853 @@ -209,7 +209,7 @@ kmem_cache_create_memcg(struct mem_cgroup *memcg, const char *name, size_t size,
83854
83855 err = __kmem_cache_create(s, flags);
83856 if (!err) {
83857 - s->refcount = 1;
83858 + atomic_set(&s->refcount, 1);
83859 list_add(&s->list, &slab_caches);
83860 memcg_cache_list_add(memcg, s);
83861 } else {
83862 @@ -255,8 +255,7 @@ void kmem_cache_destroy(struct kmem_cache *s)
83863
83864 get_online_cpus();
83865 mutex_lock(&slab_mutex);
83866 - s->refcount--;
83867 - if (!s->refcount) {
83868 + if (atomic_dec_and_test(&s->refcount)) {
83869 list_del(&s->list);
83870
83871 if (!__kmem_cache_shutdown(s)) {
83872 @@ -302,7 +301,7 @@ void __init create_boot_cache(struct kmem_cache *s, const char *name, size_t siz
83873 panic("Creation of kmalloc slab %s size=%zd failed. Reason %d\n",
83874 name, size, err);
83875
83876 - s->refcount = -1; /* Exempt from merging for now */
83877 + atomic_set(&s->refcount, -1); /* Exempt from merging for now */
83878 }
83879
83880 struct kmem_cache *__init create_kmalloc_cache(const char *name, size_t size,
83881 @@ -315,7 +314,7 @@ struct kmem_cache *__init create_kmalloc_cache(const char *name, size_t size,
83882
83883 create_boot_cache(s, name, size, flags);
83884 list_add(&s->list, &slab_caches);
83885 - s->refcount = 1;
83886 + atomic_set(&s->refcount, 1);
83887 return s;
83888 }
83889
83890 diff --git a/mm/slob.c b/mm/slob.c
83891 index eeed4a0..6ee34ec 100644
83892 --- a/mm/slob.c
83893 +++ b/mm/slob.c
83894 @@ -157,7 +157,7 @@ static void set_slob(slob_t *s, slobidx_t size, slob_t *next)
83895 /*
83896 * Return the size of a slob block.
83897 */
83898 -static slobidx_t slob_units(slob_t *s)
83899 +static slobidx_t slob_units(const slob_t *s)
83900 {
83901 if (s->units > 0)
83902 return s->units;
83903 @@ -167,7 +167,7 @@ static slobidx_t slob_units(slob_t *s)
83904 /*
83905 * Return the next free slob block pointer after this one.
83906 */
83907 -static slob_t *slob_next(slob_t *s)
83908 +static slob_t *slob_next(const slob_t *s)
83909 {
83910 slob_t *base = (slob_t *)((unsigned long)s & PAGE_MASK);
83911 slobidx_t next;
83912 @@ -182,14 +182,14 @@ static slob_t *slob_next(slob_t *s)
83913 /*
83914 * Returns true if s is the last free block in its page.
83915 */
83916 -static int slob_last(slob_t *s)
83917 +static int slob_last(const slob_t *s)
83918 {
83919 return !((unsigned long)slob_next(s) & ~PAGE_MASK);
83920 }
83921
83922 -static void *slob_new_pages(gfp_t gfp, int order, int node)
83923 +static struct page *slob_new_pages(gfp_t gfp, unsigned int order, int node)
83924 {
83925 - void *page;
83926 + struct page *page;
83927
83928 #ifdef CONFIG_NUMA
83929 if (node != NUMA_NO_NODE)
83930 @@ -201,14 +201,18 @@ static void *slob_new_pages(gfp_t gfp, int order, int node)
83931 if (!page)
83932 return NULL;
83933
83934 - return page_address(page);
83935 + __SetPageSlab(page);
83936 + return page;
83937 }
83938
83939 -static void slob_free_pages(void *b, int order)
83940 +static void slob_free_pages(struct page *sp, int order)
83941 {
83942 if (current->reclaim_state)
83943 current->reclaim_state->reclaimed_slab += 1 << order;
83944 - free_pages((unsigned long)b, order);
83945 + __ClearPageSlab(sp);
83946 + reset_page_mapcount(sp);
83947 + sp->private = 0;
83948 + __free_pages(sp, order);
83949 }
83950
83951 /*
83952 @@ -313,15 +317,15 @@ static void *slob_alloc(size_t size, gfp_t gfp, int align, int node)
83953
83954 /* Not enough space: must allocate a new page */
83955 if (!b) {
83956 - b = slob_new_pages(gfp & ~__GFP_ZERO, 0, node);
83957 - if (!b)
83958 + sp = slob_new_pages(gfp & ~__GFP_ZERO, 0, node);
83959 + if (!sp)
83960 return NULL;
83961 - sp = virt_to_page(b);
83962 - __SetPageSlab(sp);
83963 + b = page_address(sp);
83964
83965 spin_lock_irqsave(&slob_lock, flags);
83966 sp->units = SLOB_UNITS(PAGE_SIZE);
83967 sp->freelist = b;
83968 + sp->private = 0;
83969 INIT_LIST_HEAD(&sp->list);
83970 set_slob(b, SLOB_UNITS(PAGE_SIZE), b + SLOB_UNITS(PAGE_SIZE));
83971 set_slob_page_free(sp, slob_list);
83972 @@ -359,9 +363,7 @@ static void slob_free(void *block, int size)
83973 if (slob_page_free(sp))
83974 clear_slob_page_free(sp);
83975 spin_unlock_irqrestore(&slob_lock, flags);
83976 - __ClearPageSlab(sp);
83977 - page_mapcount_reset(sp);
83978 - slob_free_pages(b, 0);
83979 + slob_free_pages(sp, 0);
83980 return;
83981 }
83982
83983 @@ -424,11 +426,10 @@ out:
83984 */
83985
83986 static __always_inline void *
83987 -__do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
83988 +__do_kmalloc_node_align(size_t size, gfp_t gfp, int node, unsigned long caller, int align)
83989 {
83990 - unsigned int *m;
83991 - int align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
83992 - void *ret;
83993 + slob_t *m;
83994 + void *ret = NULL;
83995
83996 gfp &= gfp_allowed_mask;
83997
83998 @@ -442,23 +443,41 @@ __do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
83999
84000 if (!m)
84001 return NULL;
84002 - *m = size;
84003 + BUILD_BUG_ON(ARCH_KMALLOC_MINALIGN < 2 * SLOB_UNIT);
84004 + BUILD_BUG_ON(ARCH_SLAB_MINALIGN < 2 * SLOB_UNIT);
84005 + m[0].units = size;
84006 + m[1].units = align;
84007 ret = (void *)m + align;
84008
84009 trace_kmalloc_node(caller, ret,
84010 size, size + align, gfp, node);
84011 } else {
84012 unsigned int order = get_order(size);
84013 + struct page *page;
84014
84015 if (likely(order))
84016 gfp |= __GFP_COMP;
84017 - ret = slob_new_pages(gfp, order, node);
84018 + page = slob_new_pages(gfp, order, node);
84019 + if (page) {
84020 + ret = page_address(page);
84021 + page->private = size;
84022 + }
84023
84024 trace_kmalloc_node(caller, ret,
84025 size, PAGE_SIZE << order, gfp, node);
84026 }
84027
84028 - kmemleak_alloc(ret, size, 1, gfp);
84029 + return ret;
84030 +}
84031 +
84032 +static __always_inline void *
84033 +__do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
84034 +{
84035 + int align = max(ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
84036 + void *ret = __do_kmalloc_node_align(size, gfp, node, caller, align);
84037 +
84038 + if (!ZERO_OR_NULL_PTR(ret))
84039 + kmemleak_alloc(ret, size, 1, gfp);
84040 return ret;
84041 }
84042
84043 @@ -493,34 +512,112 @@ void kfree(const void *block)
84044 return;
84045 kmemleak_free(block);
84046
84047 + VM_BUG_ON(!virt_addr_valid(block));
84048 sp = virt_to_page(block);
84049 - if (PageSlab(sp)) {
84050 + VM_BUG_ON(!PageSlab(sp));
84051 + if (!sp->private) {
84052 int align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
84053 - unsigned int *m = (unsigned int *)(block - align);
84054 - slob_free(m, *m + align);
84055 - } else
84056 + slob_t *m = (slob_t *)(block - align);
84057 + slob_free(m, m[0].units + align);
84058 + } else {
84059 + __ClearPageSlab(sp);
84060 + reset_page_mapcount(sp);
84061 + sp->private = 0;
84062 __free_pages(sp, compound_order(sp));
84063 + }
84064 }
84065 EXPORT_SYMBOL(kfree);
84066
84067 +bool is_usercopy_object(const void *ptr)
84068 +{
84069 + if (!slab_is_available())
84070 + return false;
84071 +
84072 + // PAX: TODO
84073 +
84074 + return false;
84075 +}
84076 +
84077 +#ifdef CONFIG_PAX_USERCOPY
84078 +const char *check_heap_object(const void *ptr, unsigned long n)
84079 +{
84080 + struct page *page;
84081 + const slob_t *free;
84082 + const void *base;
84083 + unsigned long flags;
84084 +
84085 + if (ZERO_OR_NULL_PTR(ptr))
84086 + return "<null>";
84087 +
84088 + if (!virt_addr_valid(ptr))
84089 + return NULL;
84090 +
84091 + page = virt_to_head_page(ptr);
84092 + if (!PageSlab(page))
84093 + return NULL;
84094 +
84095 + if (page->private) {
84096 + base = page;
84097 + if (base <= ptr && n <= page->private - (ptr - base))
84098 + return NULL;
84099 + return "<slob>";
84100 + }
84101 +
84102 + /* some tricky double walking to find the chunk */
84103 + spin_lock_irqsave(&slob_lock, flags);
84104 + base = (void *)((unsigned long)ptr & PAGE_MASK);
84105 + free = page->freelist;
84106 +
84107 + while (!slob_last(free) && (void *)free <= ptr) {
84108 + base = free + slob_units(free);
84109 + free = slob_next(free);
84110 + }
84111 +
84112 + while (base < (void *)free) {
84113 + slobidx_t m = ((slob_t *)base)[0].units, align = ((slob_t *)base)[1].units;
84114 + int size = SLOB_UNIT * SLOB_UNITS(m + align);
84115 + int offset;
84116 +
84117 + if (ptr < base + align)
84118 + break;
84119 +
84120 + offset = ptr - base - align;
84121 + if (offset >= m) {
84122 + base += size;
84123 + continue;
84124 + }
84125 +
84126 + if (n > m - offset)
84127 + break;
84128 +
84129 + spin_unlock_irqrestore(&slob_lock, flags);
84130 + return NULL;
84131 + }
84132 +
84133 + spin_unlock_irqrestore(&slob_lock, flags);
84134 + return "<slob>";
84135 +}
84136 +#endif
84137 +
84138 /* can't use ksize for kmem_cache_alloc memory, only kmalloc */
84139 size_t ksize(const void *block)
84140 {
84141 struct page *sp;
84142 int align;
84143 - unsigned int *m;
84144 + slob_t *m;
84145
84146 BUG_ON(!block);
84147 if (unlikely(block == ZERO_SIZE_PTR))
84148 return 0;
84149
84150 sp = virt_to_page(block);
84151 - if (unlikely(!PageSlab(sp)))
84152 - return PAGE_SIZE << compound_order(sp);
84153 + VM_BUG_ON(!PageSlab(sp));
84154 + if (sp->private)
84155 + return sp->private;
84156
84157 align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
84158 - m = (unsigned int *)(block - align);
84159 - return SLOB_UNITS(*m) * SLOB_UNIT;
84160 + m = (slob_t *)(block - align);
84161 + return SLOB_UNITS(m[0].units) * SLOB_UNIT;
84162 }
84163 EXPORT_SYMBOL(ksize);
84164
84165 @@ -536,23 +633,33 @@ int __kmem_cache_create(struct kmem_cache *c, unsigned long flags)
84166
84167 void *kmem_cache_alloc_node(struct kmem_cache *c, gfp_t flags, int node)
84168 {
84169 - void *b;
84170 + void *b = NULL;
84171
84172 flags &= gfp_allowed_mask;
84173
84174 lockdep_trace_alloc(flags);
84175
84176 +#ifdef CONFIG_PAX_USERCOPY_SLABS
84177 + b = __do_kmalloc_node_align(c->size, flags, node, _RET_IP_, c->align);
84178 +#else
84179 if (c->size < PAGE_SIZE) {
84180 b = slob_alloc(c->size, flags, c->align, node);
84181 trace_kmem_cache_alloc_node(_RET_IP_, b, c->object_size,
84182 SLOB_UNITS(c->size) * SLOB_UNIT,
84183 flags, node);
84184 } else {
84185 - b = slob_new_pages(flags, get_order(c->size), node);
84186 + struct page *sp;
84187 +
84188 + sp = slob_new_pages(flags, get_order(c->size), node);
84189 + if (sp) {
84190 + b = page_address(sp);
84191 + sp->private = c->size;
84192 + }
84193 trace_kmem_cache_alloc_node(_RET_IP_, b, c->object_size,
84194 PAGE_SIZE << get_order(c->size),
84195 flags, node);
84196 }
84197 +#endif
84198
84199 if (c->ctor)
84200 c->ctor(b);
84201 @@ -564,10 +671,14 @@ EXPORT_SYMBOL(kmem_cache_alloc_node);
84202
84203 static void __kmem_cache_free(void *b, int size)
84204 {
84205 - if (size < PAGE_SIZE)
84206 + struct page *sp;
84207 +
84208 + sp = virt_to_page(b);
84209 + BUG_ON(!PageSlab(sp));
84210 + if (!sp->private)
84211 slob_free(b, size);
84212 else
84213 - slob_free_pages(b, get_order(size));
84214 + slob_free_pages(sp, get_order(size));
84215 }
84216
84217 static void kmem_rcu_free(struct rcu_head *head)
84218 @@ -580,17 +691,31 @@ static void kmem_rcu_free(struct rcu_head *head)
84219
84220 void kmem_cache_free(struct kmem_cache *c, void *b)
84221 {
84222 + int size = c->size;
84223 +
84224 +#ifdef CONFIG_PAX_USERCOPY_SLABS
84225 + if (size + c->align < PAGE_SIZE) {
84226 + size += c->align;
84227 + b -= c->align;
84228 + }
84229 +#endif
84230 +
84231 kmemleak_free_recursive(b, c->flags);
84232 if (unlikely(c->flags & SLAB_DESTROY_BY_RCU)) {
84233 struct slob_rcu *slob_rcu;
84234 - slob_rcu = b + (c->size - sizeof(struct slob_rcu));
84235 - slob_rcu->size = c->size;
84236 + slob_rcu = b + (size - sizeof(struct slob_rcu));
84237 + slob_rcu->size = size;
84238 call_rcu(&slob_rcu->head, kmem_rcu_free);
84239 } else {
84240 - __kmem_cache_free(b, c->size);
84241 + __kmem_cache_free(b, size);
84242 }
84243
84244 +#ifdef CONFIG_PAX_USERCOPY_SLABS
84245 + trace_kfree(_RET_IP_, b);
84246 +#else
84247 trace_kmem_cache_free(_RET_IP_, b);
84248 +#endif
84249 +
84250 }
84251 EXPORT_SYMBOL(kmem_cache_free);
84252
84253 diff --git a/mm/slub.c b/mm/slub.c
84254 index 4aec537..a64753d 100644
84255 --- a/mm/slub.c
84256 +++ b/mm/slub.c
84257 @@ -197,7 +197,7 @@ struct track {
84258
84259 enum track_item { TRACK_ALLOC, TRACK_FREE };
84260
84261 -#ifdef CONFIG_SYSFS
84262 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
84263 static int sysfs_slab_add(struct kmem_cache *);
84264 static int sysfs_slab_alias(struct kmem_cache *, const char *);
84265 static void sysfs_slab_remove(struct kmem_cache *);
84266 @@ -518,7 +518,7 @@ static void print_track(const char *s, struct track *t)
84267 if (!t->addr)
84268 return;
84269
84270 - printk(KERN_ERR "INFO: %s in %pS age=%lu cpu=%u pid=%d\n",
84271 + printk(KERN_ERR "INFO: %s in %pA age=%lu cpu=%u pid=%d\n",
84272 s, (void *)t->addr, jiffies - t->when, t->cpu, t->pid);
84273 #ifdef CONFIG_STACKTRACE
84274 {
84275 @@ -2653,7 +2653,7 @@ static int slub_min_objects;
84276 * Merge control. If this is set then no merging of slab caches will occur.
84277 * (Could be removed. This was introduced to pacify the merge skeptics.)
84278 */
84279 -static int slub_nomerge;
84280 +static int slub_nomerge = 1;
84281
84282 /*
84283 * Calculate the order of allocation given an slab object size.
84284 @@ -3181,6 +3181,10 @@ EXPORT_SYMBOL(kmalloc_caches);
84285 static struct kmem_cache *kmalloc_dma_caches[SLUB_PAGE_SHIFT];
84286 #endif
84287
84288 +#ifdef CONFIG_PAX_USERCOPY_SLABS
84289 +static struct kmem_cache *kmalloc_usercopy_caches[SLUB_PAGE_SHIFT];
84290 +#endif
84291 +
84292 static int __init setup_slub_min_order(char *str)
84293 {
84294 get_option(&str, &slub_min_order);
84295 @@ -3272,6 +3276,13 @@ static struct kmem_cache *get_slab(size_t size, gfp_t flags)
84296 return kmalloc_dma_caches[index];
84297
84298 #endif
84299 +
84300 +#ifdef CONFIG_PAX_USERCOPY_SLABS
84301 + if (flags & SLAB_USERCOPY)
84302 + return kmalloc_usercopy_caches[index];
84303 +
84304 +#endif
84305 +
84306 return kmalloc_caches[index];
84307 }
84308
84309 @@ -3340,6 +3351,59 @@ void *__kmalloc_node(size_t size, gfp_t flags, int node)
84310 EXPORT_SYMBOL(__kmalloc_node);
84311 #endif
84312
84313 +bool is_usercopy_object(const void *ptr)
84314 +{
84315 + struct page *page;
84316 + struct kmem_cache *s;
84317 +
84318 + if (ZERO_OR_NULL_PTR(ptr))
84319 + return false;
84320 +
84321 + if (!slab_is_available())
84322 + return false;
84323 +
84324 + if (!virt_addr_valid(ptr))
84325 + return false;
84326 +
84327 + page = virt_to_head_page(ptr);
84328 +
84329 + if (!PageSlab(page))
84330 + return false;
84331 +
84332 + s = page->slab_cache;
84333 + return s->flags & SLAB_USERCOPY;
84334 +}
84335 +
84336 +#ifdef CONFIG_PAX_USERCOPY
84337 +const char *check_heap_object(const void *ptr, unsigned long n)
84338 +{
84339 + struct page *page;
84340 + struct kmem_cache *s;
84341 + unsigned long offset;
84342 +
84343 + if (ZERO_OR_NULL_PTR(ptr))
84344 + return "<null>";
84345 +
84346 + if (!virt_addr_valid(ptr))
84347 + return NULL;
84348 +
84349 + page = virt_to_head_page(ptr);
84350 +
84351 + if (!PageSlab(page))
84352 + return NULL;
84353 +
84354 + s = page->slab_cache;
84355 + if (!(s->flags & SLAB_USERCOPY))
84356 + return s->name;
84357 +
84358 + offset = (ptr - page_address(page)) % s->size;
84359 + if (offset <= s->object_size && n <= s->object_size - offset)
84360 + return NULL;
84361 +
84362 + return s->name;
84363 +}
84364 +#endif
84365 +
84366 size_t ksize(const void *object)
84367 {
84368 struct page *page;
84369 @@ -3404,6 +3468,7 @@ void kfree(const void *x)
84370 if (unlikely(ZERO_OR_NULL_PTR(x)))
84371 return;
84372
84373 + VM_BUG_ON(!virt_addr_valid(x));
84374 page = virt_to_head_page(x);
84375 if (unlikely(!PageSlab(page))) {
84376 BUG_ON(!PageCompound(page));
84377 @@ -3712,17 +3777,17 @@ void __init kmem_cache_init(void)
84378
84379 /* Caches that are not of the two-to-the-power-of size */
84380 if (KMALLOC_MIN_SIZE <= 32) {
84381 - kmalloc_caches[1] = create_kmalloc_cache("kmalloc-96", 96, 0);
84382 + kmalloc_caches[1] = create_kmalloc_cache("kmalloc-96", 96, SLAB_USERCOPY);
84383 caches++;
84384 }
84385
84386 if (KMALLOC_MIN_SIZE <= 64) {
84387 - kmalloc_caches[2] = create_kmalloc_cache("kmalloc-192", 192, 0);
84388 + kmalloc_caches[2] = create_kmalloc_cache("kmalloc-192", 192, SLAB_USERCOPY);
84389 caches++;
84390 }
84391
84392 for (i = KMALLOC_SHIFT_LOW; i < SLUB_PAGE_SHIFT; i++) {
84393 - kmalloc_caches[i] = create_kmalloc_cache("kmalloc", 1 << i, 0);
84394 + kmalloc_caches[i] = create_kmalloc_cache("kmalloc", 1 << i, SLAB_USERCOPY);
84395 caches++;
84396 }
84397
84398 @@ -3764,6 +3829,22 @@ void __init kmem_cache_init(void)
84399 }
84400 }
84401 #endif
84402 +
84403 +#ifdef CONFIG_PAX_USERCOPY_SLABS
84404 + for (i = 0; i < SLUB_PAGE_SHIFT; i++) {
84405 + struct kmem_cache *s = kmalloc_caches[i];
84406 +
84407 + if (s && s->size) {
84408 + char *name = kasprintf(GFP_NOWAIT,
84409 + "usercopy-kmalloc-%d", s->object_size);
84410 +
84411 + BUG_ON(!name);
84412 + kmalloc_usercopy_caches[i] = create_kmalloc_cache(name,
84413 + s->object_size, SLAB_USERCOPY);
84414 + }
84415 + }
84416 +#endif
84417 +
84418 printk(KERN_INFO
84419 "SLUB: Genslabs=%d, HWalign=%d, Order=%d-%d, MinObjects=%d,"
84420 " CPUs=%d, Nodes=%d\n",
84421 @@ -3790,7 +3871,7 @@ static int slab_unmergeable(struct kmem_cache *s)
84422 /*
84423 * We may have set a slab to be unmergeable during bootstrap.
84424 */
84425 - if (s->refcount < 0)
84426 + if (atomic_read(&s->refcount) < 0)
84427 return 1;
84428
84429 return 0;
84430 @@ -3848,7 +3929,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
84431
84432 s = find_mergeable(memcg, size, align, flags, name, ctor);
84433 if (s) {
84434 - s->refcount++;
84435 + atomic_inc(&s->refcount);
84436 /*
84437 * Adjust the object sizes so that we clear
84438 * the complete object on kzalloc.
84439 @@ -3857,7 +3938,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
84440 s->inuse = max_t(int, s->inuse, ALIGN(size, sizeof(void *)));
84441
84442 if (sysfs_slab_alias(s, name)) {
84443 - s->refcount--;
84444 + atomic_dec(&s->refcount);
84445 s = NULL;
84446 }
84447 }
84448 @@ -3919,7 +4000,7 @@ static int __cpuinit slab_cpuup_callback(struct notifier_block *nfb,
84449 return NOTIFY_OK;
84450 }
84451
84452 -static struct notifier_block __cpuinitdata slab_notifier = {
84453 +static struct notifier_block slab_notifier = {
84454 .notifier_call = slab_cpuup_callback
84455 };
84456
84457 @@ -3977,7 +4058,7 @@ void *__kmalloc_node_track_caller(size_t size, gfp_t gfpflags,
84458 }
84459 #endif
84460
84461 -#ifdef CONFIG_SYSFS
84462 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
84463 static int count_inuse(struct page *page)
84464 {
84465 return page->inuse;
84466 @@ -4364,12 +4445,12 @@ static void resiliency_test(void)
84467 validate_slab_cache(kmalloc_caches[9]);
84468 }
84469 #else
84470 -#ifdef CONFIG_SYSFS
84471 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
84472 static void resiliency_test(void) {};
84473 #endif
84474 #endif
84475
84476 -#ifdef CONFIG_SYSFS
84477 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
84478 enum slab_stat_type {
84479 SL_ALL, /* All slabs */
84480 SL_PARTIAL, /* Only partially allocated slabs */
84481 @@ -4613,7 +4694,7 @@ SLAB_ATTR_RO(ctor);
84482
84483 static ssize_t aliases_show(struct kmem_cache *s, char *buf)
84484 {
84485 - return sprintf(buf, "%d\n", s->refcount - 1);
84486 + return sprintf(buf, "%d\n", atomic_read(&s->refcount) - 1);
84487 }
84488 SLAB_ATTR_RO(aliases);
84489
84490 @@ -5266,6 +5347,7 @@ static char *create_unique_id(struct kmem_cache *s)
84491 return name;
84492 }
84493
84494 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
84495 static int sysfs_slab_add(struct kmem_cache *s)
84496 {
84497 int err;
84498 @@ -5323,6 +5405,7 @@ static void sysfs_slab_remove(struct kmem_cache *s)
84499 kobject_del(&s->kobj);
84500 kobject_put(&s->kobj);
84501 }
84502 +#endif
84503
84504 /*
84505 * Need to buffer aliases during bootup until sysfs becomes
84506 @@ -5336,6 +5419,7 @@ struct saved_alias {
84507
84508 static struct saved_alias *alias_list;
84509
84510 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
84511 static int sysfs_slab_alias(struct kmem_cache *s, const char *name)
84512 {
84513 struct saved_alias *al;
84514 @@ -5358,6 +5442,7 @@ static int sysfs_slab_alias(struct kmem_cache *s, const char *name)
84515 alias_list = al;
84516 return 0;
84517 }
84518 +#endif
84519
84520 static int __init slab_sysfs_init(void)
84521 {
84522 diff --git a/mm/sparse-vmemmap.c b/mm/sparse-vmemmap.c
84523 index 1b7e22a..3fcd4f3 100644
84524 --- a/mm/sparse-vmemmap.c
84525 +++ b/mm/sparse-vmemmap.c
84526 @@ -128,7 +128,7 @@ pud_t * __meminit vmemmap_pud_populate(pgd_t *pgd, unsigned long addr, int node)
84527 void *p = vmemmap_alloc_block(PAGE_SIZE, node);
84528 if (!p)
84529 return NULL;
84530 - pud_populate(&init_mm, pud, p);
84531 + pud_populate_kernel(&init_mm, pud, p);
84532 }
84533 return pud;
84534 }
84535 @@ -140,7 +140,7 @@ pgd_t * __meminit vmemmap_pgd_populate(unsigned long addr, int node)
84536 void *p = vmemmap_alloc_block(PAGE_SIZE, node);
84537 if (!p)
84538 return NULL;
84539 - pgd_populate(&init_mm, pgd, p);
84540 + pgd_populate_kernel(&init_mm, pgd, p);
84541 }
84542 return pgd;
84543 }
84544 diff --git a/mm/sparse.c b/mm/sparse.c
84545 index 7ca6dc8..6472aa1 100644
84546 --- a/mm/sparse.c
84547 +++ b/mm/sparse.c
84548 @@ -783,7 +783,7 @@ static void clear_hwpoisoned_pages(struct page *memmap, int nr_pages)
84549
84550 for (i = 0; i < PAGES_PER_SECTION; i++) {
84551 if (PageHWPoison(&memmap[i])) {
84552 - atomic_long_sub(1, &num_poisoned_pages);
84553 + atomic_long_sub_unchecked(1, &num_poisoned_pages);
84554 ClearPageHWPoison(&memmap[i]);
84555 }
84556 }
84557 diff --git a/mm/swap.c b/mm/swap.c
84558 index 8a529a0..154ef26 100644
84559 --- a/mm/swap.c
84560 +++ b/mm/swap.c
84561 @@ -30,6 +30,7 @@
84562 #include <linux/backing-dev.h>
84563 #include <linux/memcontrol.h>
84564 #include <linux/gfp.h>
84565 +#include <linux/hugetlb.h>
84566
84567 #include "internal.h"
84568
84569 @@ -72,6 +73,8 @@ static void __put_compound_page(struct page *page)
84570
84571 __page_cache_release(page);
84572 dtor = get_compound_page_dtor(page);
84573 + if (!PageHuge(page))
84574 + BUG_ON(dtor != free_compound_page);
84575 (*dtor)(page);
84576 }
84577
84578 diff --git a/mm/swapfile.c b/mm/swapfile.c
84579 index a1f7772..9e982ac 100644
84580 --- a/mm/swapfile.c
84581 +++ b/mm/swapfile.c
84582 @@ -66,7 +66,7 @@ static DEFINE_MUTEX(swapon_mutex);
84583
84584 static DECLARE_WAIT_QUEUE_HEAD(proc_poll_wait);
84585 /* Activity counter to indicate that a swapon or swapoff has occurred */
84586 -static atomic_t proc_poll_event = ATOMIC_INIT(0);
84587 +static atomic_unchecked_t proc_poll_event = ATOMIC_INIT(0);
84588
84589 static inline unsigned char swap_count(unsigned char ent)
84590 {
84591 @@ -1683,7 +1683,7 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile)
84592 }
84593 filp_close(swap_file, NULL);
84594 err = 0;
84595 - atomic_inc(&proc_poll_event);
84596 + atomic_inc_unchecked(&proc_poll_event);
84597 wake_up_interruptible(&proc_poll_wait);
84598
84599 out_dput:
84600 @@ -1700,8 +1700,8 @@ static unsigned swaps_poll(struct file *file, poll_table *wait)
84601
84602 poll_wait(file, &proc_poll_wait, wait);
84603
84604 - if (seq->poll_event != atomic_read(&proc_poll_event)) {
84605 - seq->poll_event = atomic_read(&proc_poll_event);
84606 + if (seq->poll_event != atomic_read_unchecked(&proc_poll_event)) {
84607 + seq->poll_event = atomic_read_unchecked(&proc_poll_event);
84608 return POLLIN | POLLRDNORM | POLLERR | POLLPRI;
84609 }
84610
84611 @@ -1799,7 +1799,7 @@ static int swaps_open(struct inode *inode, struct file *file)
84612 return ret;
84613
84614 seq = file->private_data;
84615 - seq->poll_event = atomic_read(&proc_poll_event);
84616 + seq->poll_event = atomic_read_unchecked(&proc_poll_event);
84617 return 0;
84618 }
84619
84620 @@ -2142,7 +2142,7 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
84621 (frontswap_map) ? "FS" : "");
84622
84623 mutex_unlock(&swapon_mutex);
84624 - atomic_inc(&proc_poll_event);
84625 + atomic_inc_unchecked(&proc_poll_event);
84626 wake_up_interruptible(&proc_poll_wait);
84627
84628 if (S_ISREG(inode->i_mode))
84629 diff --git a/mm/util.c b/mm/util.c
84630 index ab1424d..7c5bd5a 100644
84631 --- a/mm/util.c
84632 +++ b/mm/util.c
84633 @@ -294,6 +294,12 @@ done:
84634 void arch_pick_mmap_layout(struct mm_struct *mm)
84635 {
84636 mm->mmap_base = TASK_UNMAPPED_BASE;
84637 +
84638 +#ifdef CONFIG_PAX_RANDMMAP
84639 + if (mm->pax_flags & MF_PAX_RANDMMAP)
84640 + mm->mmap_base += mm->delta_mmap;
84641 +#endif
84642 +
84643 mm->get_unmapped_area = arch_get_unmapped_area;
84644 mm->unmap_area = arch_unmap_area;
84645 }
84646 diff --git a/mm/vmalloc.c b/mm/vmalloc.c
84647 index 0f751f2..ef398a0 100644
84648 --- a/mm/vmalloc.c
84649 +++ b/mm/vmalloc.c
84650 @@ -39,8 +39,19 @@ static void vunmap_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end)
84651
84652 pte = pte_offset_kernel(pmd, addr);
84653 do {
84654 - pte_t ptent = ptep_get_and_clear(&init_mm, addr, pte);
84655 - WARN_ON(!pte_none(ptent) && !pte_present(ptent));
84656 +
84657 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
84658 + if ((unsigned long)MODULES_EXEC_VADDR <= addr && addr < (unsigned long)MODULES_EXEC_END) {
84659 + BUG_ON(!pte_exec(*pte));
84660 + set_pte_at(&init_mm, addr, pte, pfn_pte(__pa(addr) >> PAGE_SHIFT, PAGE_KERNEL_EXEC));
84661 + continue;
84662 + }
84663 +#endif
84664 +
84665 + {
84666 + pte_t ptent = ptep_get_and_clear(&init_mm, addr, pte);
84667 + WARN_ON(!pte_none(ptent) && !pte_present(ptent));
84668 + }
84669 } while (pte++, addr += PAGE_SIZE, addr != end);
84670 }
84671
84672 @@ -100,16 +111,29 @@ static int vmap_pte_range(pmd_t *pmd, unsigned long addr,
84673 pte = pte_alloc_kernel(pmd, addr);
84674 if (!pte)
84675 return -ENOMEM;
84676 +
84677 + pax_open_kernel();
84678 do {
84679 struct page *page = pages[*nr];
84680
84681 - if (WARN_ON(!pte_none(*pte)))
84682 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
84683 + if (pgprot_val(prot) & _PAGE_NX)
84684 +#endif
84685 +
84686 + if (!pte_none(*pte)) {
84687 + pax_close_kernel();
84688 + WARN_ON(1);
84689 return -EBUSY;
84690 - if (WARN_ON(!page))
84691 + }
84692 + if (!page) {
84693 + pax_close_kernel();
84694 + WARN_ON(1);
84695 return -ENOMEM;
84696 + }
84697 set_pte_at(&init_mm, addr, pte, mk_pte(page, prot));
84698 (*nr)++;
84699 } while (pte++, addr += PAGE_SIZE, addr != end);
84700 + pax_close_kernel();
84701 return 0;
84702 }
84703
84704 @@ -119,7 +143,7 @@ static int vmap_pmd_range(pud_t *pud, unsigned long addr,
84705 pmd_t *pmd;
84706 unsigned long next;
84707
84708 - pmd = pmd_alloc(&init_mm, pud, addr);
84709 + pmd = pmd_alloc_kernel(&init_mm, pud, addr);
84710 if (!pmd)
84711 return -ENOMEM;
84712 do {
84713 @@ -136,7 +160,7 @@ static int vmap_pud_range(pgd_t *pgd, unsigned long addr,
84714 pud_t *pud;
84715 unsigned long next;
84716
84717 - pud = pud_alloc(&init_mm, pgd, addr);
84718 + pud = pud_alloc_kernel(&init_mm, pgd, addr);
84719 if (!pud)
84720 return -ENOMEM;
84721 do {
84722 @@ -191,11 +215,20 @@ int is_vmalloc_or_module_addr(const void *x)
84723 * and fall back on vmalloc() if that fails. Others
84724 * just put it in the vmalloc space.
84725 */
84726 -#if defined(CONFIG_MODULES) && defined(MODULES_VADDR)
84727 +#ifdef CONFIG_MODULES
84728 +#ifdef MODULES_VADDR
84729 unsigned long addr = (unsigned long)x;
84730 if (addr >= MODULES_VADDR && addr < MODULES_END)
84731 return 1;
84732 #endif
84733 +
84734 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
84735 + if (x >= (const void *)MODULES_EXEC_VADDR && x < (const void *)MODULES_EXEC_END)
84736 + return 1;
84737 +#endif
84738 +
84739 +#endif
84740 +
84741 return is_vmalloc_addr(x);
84742 }
84743
84744 @@ -216,8 +249,14 @@ struct page *vmalloc_to_page(const void *vmalloc_addr)
84745
84746 if (!pgd_none(*pgd)) {
84747 pud_t *pud = pud_offset(pgd, addr);
84748 +#ifdef CONFIG_X86
84749 + if (!pud_large(*pud))
84750 +#endif
84751 if (!pud_none(*pud)) {
84752 pmd_t *pmd = pmd_offset(pud, addr);
84753 +#ifdef CONFIG_X86
84754 + if (!pmd_large(*pmd))
84755 +#endif
84756 if (!pmd_none(*pmd)) {
84757 pte_t *ptep, pte;
84758
84759 @@ -329,7 +368,7 @@ static void purge_vmap_area_lazy(void);
84760 * Allocate a region of KVA of the specified size and alignment, within the
84761 * vstart and vend.
84762 */
84763 -static struct vmap_area *alloc_vmap_area(unsigned long size,
84764 +static __size_overflow(1) struct vmap_area *alloc_vmap_area(unsigned long size,
84765 unsigned long align,
84766 unsigned long vstart, unsigned long vend,
84767 int node, gfp_t gfp_mask)
84768 @@ -1328,6 +1367,16 @@ static struct vm_struct *__get_vm_area_node(unsigned long size,
84769 struct vm_struct *area;
84770
84771 BUG_ON(in_interrupt());
84772 +
84773 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
84774 + if (flags & VM_KERNEXEC) {
84775 + if (start != VMALLOC_START || end != VMALLOC_END)
84776 + return NULL;
84777 + start = (unsigned long)MODULES_EXEC_VADDR;
84778 + end = (unsigned long)MODULES_EXEC_END;
84779 + }
84780 +#endif
84781 +
84782 if (flags & VM_IOREMAP) {
84783 int bit = fls(size);
84784
84785 @@ -1569,6 +1618,11 @@ void *vmap(struct page **pages, unsigned int count,
84786 if (count > totalram_pages)
84787 return NULL;
84788
84789 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
84790 + if (!(pgprot_val(prot) & _PAGE_NX))
84791 + flags |= VM_KERNEXEC;
84792 +#endif
84793 +
84794 area = get_vm_area_caller((count << PAGE_SHIFT), flags,
84795 __builtin_return_address(0));
84796 if (!area)
84797 @@ -1670,6 +1724,13 @@ void *__vmalloc_node_range(unsigned long size, unsigned long align,
84798 if (!size || (size >> PAGE_SHIFT) > totalram_pages)
84799 goto fail;
84800
84801 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
84802 + if (!(pgprot_val(prot) & _PAGE_NX))
84803 + area = __get_vm_area_node(size, align, VM_ALLOC | VM_UNLIST | VM_KERNEXEC,
84804 + VMALLOC_START, VMALLOC_END, node, gfp_mask, caller);
84805 + else
84806 +#endif
84807 +
84808 area = __get_vm_area_node(size, align, VM_ALLOC | VM_UNLIST,
84809 start, end, node, gfp_mask, caller);
84810 if (!area)
84811 @@ -1845,10 +1906,9 @@ EXPORT_SYMBOL(vzalloc_node);
84812 * For tight control over page level allocator and protection flags
84813 * use __vmalloc() instead.
84814 */
84815 -
84816 void *vmalloc_exec(unsigned long size)
84817 {
84818 - return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL_EXEC,
84819 + return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, PAGE_KERNEL_EXEC,
84820 NUMA_NO_NODE, __builtin_return_address(0));
84821 }
84822
84823 @@ -2139,6 +2199,8 @@ int remap_vmalloc_range(struct vm_area_struct *vma, void *addr,
84824 unsigned long uaddr = vma->vm_start;
84825 unsigned long usize = vma->vm_end - vma->vm_start;
84826
84827 + BUG_ON(vma->vm_mirror);
84828 +
84829 if ((PAGE_SIZE-1) & (unsigned long)addr)
84830 return -EINVAL;
84831
84832 @@ -2578,7 +2640,11 @@ static int s_show(struct seq_file *m, void *p)
84833 v->addr, v->addr + v->size, v->size);
84834
84835 if (v->caller)
84836 +#ifdef CONFIG_GRKERNSEC_HIDESYM
84837 + seq_printf(m, " %pK", v->caller);
84838 +#else
84839 seq_printf(m, " %pS", v->caller);
84840 +#endif
84841
84842 if (v->nr_pages)
84843 seq_printf(m, " pages=%d", v->nr_pages);
84844 diff --git a/mm/vmstat.c b/mm/vmstat.c
84845 index e1d8ed1..253fa3c 100644
84846 --- a/mm/vmstat.c
84847 +++ b/mm/vmstat.c
84848 @@ -78,7 +78,7 @@ void vm_events_fold_cpu(int cpu)
84849 *
84850 * vm_stat contains the global counters
84851 */
84852 -atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS] __cacheline_aligned_in_smp;
84853 +atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS] __cacheline_aligned_in_smp;
84854 EXPORT_SYMBOL(vm_stat);
84855
84856 #ifdef CONFIG_SMP
84857 @@ -454,7 +454,7 @@ void refresh_cpu_vm_stats(int cpu)
84858 v = p->vm_stat_diff[i];
84859 p->vm_stat_diff[i] = 0;
84860 local_irq_restore(flags);
84861 - atomic_long_add(v, &zone->vm_stat[i]);
84862 + atomic_long_add_unchecked(v, &zone->vm_stat[i]);
84863 global_diff[i] += v;
84864 #ifdef CONFIG_NUMA
84865 /* 3 seconds idle till flush */
84866 @@ -492,7 +492,7 @@ void refresh_cpu_vm_stats(int cpu)
84867
84868 for (i = 0; i < NR_VM_ZONE_STAT_ITEMS; i++)
84869 if (global_diff[i])
84870 - atomic_long_add(global_diff[i], &vm_stat[i]);
84871 + atomic_long_add_unchecked(global_diff[i], &vm_stat[i]);
84872 }
84873
84874 void drain_zonestat(struct zone *zone, struct per_cpu_pageset *pset)
84875 @@ -503,8 +503,8 @@ void drain_zonestat(struct zone *zone, struct per_cpu_pageset *pset)
84876 if (pset->vm_stat_diff[i]) {
84877 int v = pset->vm_stat_diff[i];
84878 pset->vm_stat_diff[i] = 0;
84879 - atomic_long_add(v, &zone->vm_stat[i]);
84880 - atomic_long_add(v, &vm_stat[i]);
84881 + atomic_long_add_unchecked(v, &zone->vm_stat[i]);
84882 + atomic_long_add_unchecked(v, &vm_stat[i]);
84883 }
84884 }
84885 #endif
84886 @@ -1224,7 +1224,7 @@ static int __cpuinit vmstat_cpuup_callback(struct notifier_block *nfb,
84887 return NOTIFY_OK;
84888 }
84889
84890 -static struct notifier_block __cpuinitdata vmstat_notifier =
84891 +static struct notifier_block vmstat_notifier =
84892 { &vmstat_cpuup_callback, NULL, 0 };
84893 #endif
84894
84895 @@ -1239,10 +1239,20 @@ static int __init setup_vmstat(void)
84896 start_cpu_timer(cpu);
84897 #endif
84898 #ifdef CONFIG_PROC_FS
84899 - proc_create("buddyinfo", S_IRUGO, NULL, &fragmentation_file_operations);
84900 - proc_create("pagetypeinfo", S_IRUGO, NULL, &pagetypeinfo_file_ops);
84901 - proc_create("vmstat", S_IRUGO, NULL, &proc_vmstat_file_operations);
84902 - proc_create("zoneinfo", S_IRUGO, NULL, &proc_zoneinfo_file_operations);
84903 + {
84904 + mode_t gr_mode = S_IRUGO;
84905 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
84906 + gr_mode = S_IRUSR;
84907 +#endif
84908 + proc_create("buddyinfo", gr_mode, NULL, &fragmentation_file_operations);
84909 + proc_create("pagetypeinfo", gr_mode, NULL, &pagetypeinfo_file_ops);
84910 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
84911 + proc_create("vmstat", gr_mode | S_IRGRP, NULL, &proc_vmstat_file_operations);
84912 +#else
84913 + proc_create("vmstat", gr_mode, NULL, &proc_vmstat_file_operations);
84914 +#endif
84915 + proc_create("zoneinfo", gr_mode, NULL, &proc_zoneinfo_file_operations);
84916 + }
84917 #endif
84918 return 0;
84919 }
84920 diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
84921 index 85addcd..c429a13 100644
84922 --- a/net/8021q/vlan.c
84923 +++ b/net/8021q/vlan.c
84924 @@ -114,6 +114,13 @@ void unregister_vlan_dev(struct net_device *dev, struct list_head *head)
84925 if (vlan_id)
84926 vlan_vid_del(real_dev, vlan_id);
84927
84928 + /* Take it out of our own structures, but be sure to interlock with
84929 + * HW accelerating devices or SW vlan input packet processing if
84930 + * VLAN is not 0 (leave it there for 802.1p).
84931 + */
84932 + if (vlan_id)
84933 + vlan_vid_del(real_dev, vlan_id);
84934 +
84935 /* Get rid of the vlan's reference to real_dev */
84936 dev_put(real_dev);
84937 }
84938 @@ -496,7 +503,7 @@ out:
84939 return NOTIFY_DONE;
84940 }
84941
84942 -static struct notifier_block vlan_notifier_block __read_mostly = {
84943 +static struct notifier_block vlan_notifier_block = {
84944 .notifier_call = vlan_device_event,
84945 };
84946
84947 @@ -571,8 +578,7 @@ static int vlan_ioctl_handler(struct net *net, void __user *arg)
84948 err = -EPERM;
84949 if (!ns_capable(net->user_ns, CAP_NET_ADMIN))
84950 break;
84951 - if ((args.u.name_type >= 0) &&
84952 - (args.u.name_type < VLAN_NAME_TYPE_HIGHEST)) {
84953 + if (args.u.name_type < VLAN_NAME_TYPE_HIGHEST) {
84954 struct vlan_net *vn;
84955
84956 vn = net_generic(net, vlan_net_id);
84957 diff --git a/net/9p/mod.c b/net/9p/mod.c
84958 index 6ab36ae..6f1841b 100644
84959 --- a/net/9p/mod.c
84960 +++ b/net/9p/mod.c
84961 @@ -84,7 +84,7 @@ static LIST_HEAD(v9fs_trans_list);
84962 void v9fs_register_trans(struct p9_trans_module *m)
84963 {
84964 spin_lock(&v9fs_trans_lock);
84965 - list_add_tail(&m->list, &v9fs_trans_list);
84966 + pax_list_add_tail((struct list_head *)&m->list, &v9fs_trans_list);
84967 spin_unlock(&v9fs_trans_lock);
84968 }
84969 EXPORT_SYMBOL(v9fs_register_trans);
84970 @@ -97,7 +97,7 @@ EXPORT_SYMBOL(v9fs_register_trans);
84971 void v9fs_unregister_trans(struct p9_trans_module *m)
84972 {
84973 spin_lock(&v9fs_trans_lock);
84974 - list_del_init(&m->list);
84975 + pax_list_del_init((struct list_head *)&m->list);
84976 spin_unlock(&v9fs_trans_lock);
84977 }
84978 EXPORT_SYMBOL(v9fs_unregister_trans);
84979 diff --git a/net/9p/trans_fd.c b/net/9p/trans_fd.c
84980 index 02efb25..41541a9 100644
84981 --- a/net/9p/trans_fd.c
84982 +++ b/net/9p/trans_fd.c
84983 @@ -425,7 +425,7 @@ static int p9_fd_write(struct p9_client *client, void *v, int len)
84984 oldfs = get_fs();
84985 set_fs(get_ds());
84986 /* The cast to a user pointer is valid due to the set_fs() */
84987 - ret = vfs_write(ts->wr, (__force void __user *)v, len, &ts->wr->f_pos);
84988 + ret = vfs_write(ts->wr, (void __force_user *)v, len, &ts->wr->f_pos);
84989 set_fs(oldfs);
84990
84991 if (ret <= 0 && ret != -ERESTARTSYS && ret != -EAGAIN)
84992 diff --git a/net/atm/atm_misc.c b/net/atm/atm_misc.c
84993 index 876fbe8..8bbea9f 100644
84994 --- a/net/atm/atm_misc.c
84995 +++ b/net/atm/atm_misc.c
84996 @@ -17,7 +17,7 @@ int atm_charge(struct atm_vcc *vcc, int truesize)
84997 if (atomic_read(&sk_atm(vcc)->sk_rmem_alloc) <= sk_atm(vcc)->sk_rcvbuf)
84998 return 1;
84999 atm_return(vcc, truesize);
85000 - atomic_inc(&vcc->stats->rx_drop);
85001 + atomic_inc_unchecked(&vcc->stats->rx_drop);
85002 return 0;
85003 }
85004 EXPORT_SYMBOL(atm_charge);
85005 @@ -39,7 +39,7 @@ struct sk_buff *atm_alloc_charge(struct atm_vcc *vcc, int pdu_size,
85006 }
85007 }
85008 atm_return(vcc, guess);
85009 - atomic_inc(&vcc->stats->rx_drop);
85010 + atomic_inc_unchecked(&vcc->stats->rx_drop);
85011 return NULL;
85012 }
85013 EXPORT_SYMBOL(atm_alloc_charge);
85014 @@ -86,7 +86,7 @@ EXPORT_SYMBOL(atm_pcr_goal);
85015
85016 void sonet_copy_stats(struct k_sonet_stats *from, struct sonet_stats *to)
85017 {
85018 -#define __HANDLE_ITEM(i) to->i = atomic_read(&from->i)
85019 +#define __HANDLE_ITEM(i) to->i = atomic_read_unchecked(&from->i)
85020 __SONET_ITEMS
85021 #undef __HANDLE_ITEM
85022 }
85023 @@ -94,7 +94,7 @@ EXPORT_SYMBOL(sonet_copy_stats);
85024
85025 void sonet_subtract_stats(struct k_sonet_stats *from, struct sonet_stats *to)
85026 {
85027 -#define __HANDLE_ITEM(i) atomic_sub(to->i, &from->i)
85028 +#define __HANDLE_ITEM(i) atomic_sub_unchecked(to->i,&from->i)
85029 __SONET_ITEMS
85030 #undef __HANDLE_ITEM
85031 }
85032 diff --git a/net/atm/lec.h b/net/atm/lec.h
85033 index a86aff9..3a0d6f6 100644
85034 --- a/net/atm/lec.h
85035 +++ b/net/atm/lec.h
85036 @@ -48,7 +48,7 @@ struct lane2_ops {
85037 const u8 *tlvs, u32 sizeoftlvs);
85038 void (*associate_indicator) (struct net_device *dev, const u8 *mac_addr,
85039 const u8 *tlvs, u32 sizeoftlvs);
85040 -};
85041 +} __no_const;
85042
85043 /*
85044 * ATM LAN Emulation supports both LLC & Dix Ethernet EtherType
85045 diff --git a/net/atm/proc.c b/net/atm/proc.c
85046 index 6ac35ff..ac0e136 100644
85047 --- a/net/atm/proc.c
85048 +++ b/net/atm/proc.c
85049 @@ -45,9 +45,9 @@ static void add_stats(struct seq_file *seq, const char *aal,
85050 const struct k_atm_aal_stats *stats)
85051 {
85052 seq_printf(seq, "%s ( %d %d %d %d %d )", aal,
85053 - atomic_read(&stats->tx), atomic_read(&stats->tx_err),
85054 - atomic_read(&stats->rx), atomic_read(&stats->rx_err),
85055 - atomic_read(&stats->rx_drop));
85056 + atomic_read_unchecked(&stats->tx),atomic_read_unchecked(&stats->tx_err),
85057 + atomic_read_unchecked(&stats->rx),atomic_read_unchecked(&stats->rx_err),
85058 + atomic_read_unchecked(&stats->rx_drop));
85059 }
85060
85061 static void atm_dev_info(struct seq_file *seq, const struct atm_dev *dev)
85062 diff --git a/net/atm/resources.c b/net/atm/resources.c
85063 index 0447d5d..3cf4728 100644
85064 --- a/net/atm/resources.c
85065 +++ b/net/atm/resources.c
85066 @@ -160,7 +160,7 @@ EXPORT_SYMBOL(atm_dev_deregister);
85067 static void copy_aal_stats(struct k_atm_aal_stats *from,
85068 struct atm_aal_stats *to)
85069 {
85070 -#define __HANDLE_ITEM(i) to->i = atomic_read(&from->i)
85071 +#define __HANDLE_ITEM(i) to->i = atomic_read_unchecked(&from->i)
85072 __AAL_STAT_ITEMS
85073 #undef __HANDLE_ITEM
85074 }
85075 @@ -168,7 +168,7 @@ static void copy_aal_stats(struct k_atm_aal_stats *from,
85076 static void subtract_aal_stats(struct k_atm_aal_stats *from,
85077 struct atm_aal_stats *to)
85078 {
85079 -#define __HANDLE_ITEM(i) atomic_sub(to->i, &from->i)
85080 +#define __HANDLE_ITEM(i) atomic_sub_unchecked(to->i, &from->i)
85081 __AAL_STAT_ITEMS
85082 #undef __HANDLE_ITEM
85083 }
85084 diff --git a/net/ax25/sysctl_net_ax25.c b/net/ax25/sysctl_net_ax25.c
85085 index d5744b7..506bae3 100644
85086 --- a/net/ax25/sysctl_net_ax25.c
85087 +++ b/net/ax25/sysctl_net_ax25.c
85088 @@ -152,7 +152,7 @@ int ax25_register_dev_sysctl(ax25_dev *ax25_dev)
85089 {
85090 char path[sizeof("net/ax25/") + IFNAMSIZ];
85091 int k;
85092 - struct ctl_table *table;
85093 + ctl_table_no_const *table;
85094
85095 table = kmemdup(ax25_param_table, sizeof(ax25_param_table), GFP_KERNEL);
85096 if (!table)
85097 diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
85098 index a5bb0a7..e1d8b97 100644
85099 --- a/net/batman-adv/bat_iv_ogm.c
85100 +++ b/net/batman-adv/bat_iv_ogm.c
85101 @@ -63,7 +63,7 @@ static int batadv_iv_ogm_iface_enable(struct batadv_hard_iface *hard_iface)
85102
85103 /* randomize initial seqno to avoid collision */
85104 get_random_bytes(&random_seqno, sizeof(random_seqno));
85105 - atomic_set(&hard_iface->bat_iv.ogm_seqno, random_seqno);
85106 + atomic_set_unchecked(&hard_iface->bat_iv.ogm_seqno, random_seqno);
85107
85108 hard_iface->bat_iv.ogm_buff_len = BATADV_OGM_HLEN;
85109 ogm_buff = kmalloc(hard_iface->bat_iv.ogm_buff_len, GFP_ATOMIC);
85110 @@ -611,9 +611,9 @@ static void batadv_iv_ogm_schedule(struct batadv_hard_iface *hard_iface)
85111 batadv_ogm_packet = (struct batadv_ogm_packet *)(*ogm_buff);
85112
85113 /* change sequence number to network order */
85114 - seqno = (uint32_t)atomic_read(&hard_iface->bat_iv.ogm_seqno);
85115 + seqno = (uint32_t)atomic_read_unchecked(&hard_iface->bat_iv.ogm_seqno);
85116 batadv_ogm_packet->seqno = htonl(seqno);
85117 - atomic_inc(&hard_iface->bat_iv.ogm_seqno);
85118 + atomic_inc_unchecked(&hard_iface->bat_iv.ogm_seqno);
85119
85120 batadv_ogm_packet->ttvn = atomic_read(&bat_priv->tt.vn);
85121 batadv_ogm_packet->tt_crc = htons(bat_priv->tt.local_crc);
85122 @@ -1013,7 +1013,7 @@ static void batadv_iv_ogm_process(const struct ethhdr *ethhdr,
85123 return;
85124
85125 /* could be changed by schedule_own_packet() */
85126 - if_incoming_seqno = atomic_read(&if_incoming->bat_iv.ogm_seqno);
85127 + if_incoming_seqno = atomic_read_unchecked(&if_incoming->bat_iv.ogm_seqno);
85128
85129 if (batadv_ogm_packet->flags & BATADV_DIRECTLINK)
85130 has_directlink_flag = 1;
85131 diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c
85132 index 368219e..53f56f9 100644
85133 --- a/net/batman-adv/hard-interface.c
85134 +++ b/net/batman-adv/hard-interface.c
85135 @@ -370,7 +370,7 @@ int batadv_hardif_enable_interface(struct batadv_hard_iface *hard_iface,
85136 hard_iface->batman_adv_ptype.dev = hard_iface->net_dev;
85137 dev_add_pack(&hard_iface->batman_adv_ptype);
85138
85139 - atomic_set(&hard_iface->frag_seqno, 1);
85140 + atomic_set_unchecked(&hard_iface->frag_seqno, 1);
85141 batadv_info(hard_iface->soft_iface, "Adding interface: %s\n",
85142 hard_iface->net_dev->name);
85143
85144 @@ -514,7 +514,7 @@ batadv_hardif_add_interface(struct net_device *net_dev)
85145 /* This can't be called via a bat_priv callback because
85146 * we have no bat_priv yet.
85147 */
85148 - atomic_set(&hard_iface->bat_iv.ogm_seqno, 1);
85149 + atomic_set_unchecked(&hard_iface->bat_iv.ogm_seqno, 1);
85150 hard_iface->bat_iv.ogm_buff = NULL;
85151
85152 return hard_iface;
85153 diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
85154 index 2711e87..4ca48fa 100644
85155 --- a/net/batman-adv/soft-interface.c
85156 +++ b/net/batman-adv/soft-interface.c
85157 @@ -252,7 +252,7 @@ static int batadv_interface_tx(struct sk_buff *skb,
85158 primary_if->net_dev->dev_addr, ETH_ALEN);
85159
85160 /* set broadcast sequence number */
85161 - seqno = atomic_inc_return(&bat_priv->bcast_seqno);
85162 + seqno = atomic_inc_return_unchecked(&bat_priv->bcast_seqno);
85163 bcast_packet->seqno = htonl(seqno);
85164
85165 batadv_add_bcast_packet_to_list(bat_priv, skb, brd_delay);
85166 @@ -527,7 +527,7 @@ struct net_device *batadv_softif_create(const char *name)
85167 atomic_set(&bat_priv->batman_queue_left, BATADV_BATMAN_QUEUE_LEN);
85168
85169 atomic_set(&bat_priv->mesh_state, BATADV_MESH_INACTIVE);
85170 - atomic_set(&bat_priv->bcast_seqno, 1);
85171 + atomic_set_unchecked(&bat_priv->bcast_seqno, 1);
85172 atomic_set(&bat_priv->tt.vn, 0);
85173 atomic_set(&bat_priv->tt.local_changes, 0);
85174 atomic_set(&bat_priv->tt.ogm_append_cnt, 0);
85175 diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h
85176 index 4cd87a0..348e705 100644
85177 --- a/net/batman-adv/types.h
85178 +++ b/net/batman-adv/types.h
85179 @@ -51,7 +51,7 @@
85180 struct batadv_hard_iface_bat_iv {
85181 unsigned char *ogm_buff;
85182 int ogm_buff_len;
85183 - atomic_t ogm_seqno;
85184 + atomic_unchecked_t ogm_seqno;
85185 };
85186
85187 /**
85188 @@ -75,7 +75,7 @@ struct batadv_hard_iface {
85189 int16_t if_num;
85190 char if_status;
85191 struct net_device *net_dev;
85192 - atomic_t frag_seqno;
85193 + atomic_unchecked_t frag_seqno;
85194 struct kobject *hardif_obj;
85195 atomic_t refcount;
85196 struct packet_type batman_adv_ptype;
85197 @@ -495,7 +495,7 @@ struct batadv_priv {
85198 #ifdef CONFIG_BATMAN_ADV_DEBUG
85199 atomic_t log_level;
85200 #endif
85201 - atomic_t bcast_seqno;
85202 + atomic_unchecked_t bcast_seqno;
85203 atomic_t bcast_queue_left;
85204 atomic_t batman_queue_left;
85205 char num_ifaces;
85206 diff --git a/net/batman-adv/unicast.c b/net/batman-adv/unicast.c
85207 index 50e079f..49ce2d2 100644
85208 --- a/net/batman-adv/unicast.c
85209 +++ b/net/batman-adv/unicast.c
85210 @@ -270,7 +270,7 @@ int batadv_frag_send_skb(struct sk_buff *skb, struct batadv_priv *bat_priv,
85211 frag1->flags = BATADV_UNI_FRAG_HEAD | large_tail;
85212 frag2->flags = large_tail;
85213
85214 - seqno = atomic_add_return(2, &hard_iface->frag_seqno);
85215 + seqno = atomic_add_return_unchecked(2, &hard_iface->frag_seqno);
85216 frag1->seqno = htons(seqno - 1);
85217 frag2->seqno = htons(seqno);
85218
85219 diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c
85220 index 6a93614..1415549 100644
85221 --- a/net/bluetooth/hci_sock.c
85222 +++ b/net/bluetooth/hci_sock.c
85223 @@ -929,7 +929,7 @@ static int hci_sock_setsockopt(struct socket *sock, int level, int optname,
85224 uf.event_mask[1] = *((u32 *) f->event_mask + 1);
85225 }
85226
85227 - len = min_t(unsigned int, len, sizeof(uf));
85228 + len = min((size_t)len, sizeof(uf));
85229 if (copy_from_user(&uf, optval, len)) {
85230 err = -EFAULT;
85231 break;
85232 diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
85233 index 7c7e932..7a7815d 100644
85234 --- a/net/bluetooth/l2cap_core.c
85235 +++ b/net/bluetooth/l2cap_core.c
85236 @@ -3395,8 +3395,10 @@ static int l2cap_parse_conf_rsp(struct l2cap_chan *chan, void *rsp, int len,
85237 break;
85238
85239 case L2CAP_CONF_RFC:
85240 - if (olen == sizeof(rfc))
85241 - memcpy(&rfc, (void *)val, olen);
85242 + if (olen != sizeof(rfc))
85243 + break;
85244 +
85245 + memcpy(&rfc, (void *)val, olen);
85246
85247 if (test_bit(CONF_STATE2_DEVICE, &chan->conf_state) &&
85248 rfc.mode != chan->mode)
85249 diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
85250 index 1bcfb84..dad9f98 100644
85251 --- a/net/bluetooth/l2cap_sock.c
85252 +++ b/net/bluetooth/l2cap_sock.c
85253 @@ -479,7 +479,8 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname,
85254 struct sock *sk = sock->sk;
85255 struct l2cap_chan *chan = l2cap_pi(sk)->chan;
85256 struct l2cap_options opts;
85257 - int len, err = 0;
85258 + int err = 0;
85259 + size_t len = optlen;
85260 u32 opt;
85261
85262 BT_DBG("sk %p", sk);
85263 @@ -501,7 +502,7 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname,
85264 opts.max_tx = chan->max_tx;
85265 opts.txwin_size = chan->tx_win;
85266
85267 - len = min_t(unsigned int, sizeof(opts), optlen);
85268 + len = min(sizeof(opts), len);
85269 if (copy_from_user((char *) &opts, optval, len)) {
85270 err = -EFAULT;
85271 break;
85272 @@ -581,7 +582,8 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
85273 struct bt_security sec;
85274 struct bt_power pwr;
85275 struct l2cap_conn *conn;
85276 - int len, err = 0;
85277 + int err = 0;
85278 + size_t len = optlen;
85279 u32 opt;
85280
85281 BT_DBG("sk %p", sk);
85282 @@ -604,7 +606,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
85283
85284 sec.level = BT_SECURITY_LOW;
85285
85286 - len = min_t(unsigned int, sizeof(sec), optlen);
85287 + len = min(sizeof(sec), len);
85288 if (copy_from_user((char *) &sec, optval, len)) {
85289 err = -EFAULT;
85290 break;
85291 @@ -701,7 +703,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
85292
85293 pwr.force_active = BT_POWER_FORCE_ACTIVE_ON;
85294
85295 - len = min_t(unsigned int, sizeof(pwr), optlen);
85296 + len = min(sizeof(pwr), len);
85297 if (copy_from_user((char *) &pwr, optval, len)) {
85298 err = -EFAULT;
85299 break;
85300 diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c
85301 index 7c9224b..381009e 100644
85302 --- a/net/bluetooth/rfcomm/sock.c
85303 +++ b/net/bluetooth/rfcomm/sock.c
85304 @@ -666,7 +666,7 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, c
85305 struct sock *sk = sock->sk;
85306 struct bt_security sec;
85307 int err = 0;
85308 - size_t len;
85309 + size_t len = optlen;
85310 u32 opt;
85311
85312 BT_DBG("sk %p", sk);
85313 @@ -688,7 +688,7 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, c
85314
85315 sec.level = BT_SECURITY_LOW;
85316
85317 - len = min_t(unsigned int, sizeof(sec), optlen);
85318 + len = min(sizeof(sec), len);
85319 if (copy_from_user((char *) &sec, optval, len)) {
85320 err = -EFAULT;
85321 break;
85322 diff --git a/net/bluetooth/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c
85323 index b6e44ad..5b0d514 100644
85324 --- a/net/bluetooth/rfcomm/tty.c
85325 +++ b/net/bluetooth/rfcomm/tty.c
85326 @@ -309,7 +309,7 @@ static void rfcomm_dev_del(struct rfcomm_dev *dev)
85327 BUG_ON(test_and_set_bit(RFCOMM_TTY_RELEASED, &dev->flags));
85328
85329 spin_lock_irqsave(&dev->port.lock, flags);
85330 - if (dev->port.count > 0) {
85331 + if (atomic_read(&dev->port.count) > 0) {
85332 spin_unlock_irqrestore(&dev->port.lock, flags);
85333 return;
85334 }
85335 @@ -659,10 +659,10 @@ static int rfcomm_tty_open(struct tty_struct *tty, struct file *filp)
85336 return -ENODEV;
85337
85338 BT_DBG("dev %p dst %pMR channel %d opened %d", dev, &dev->dst,
85339 - dev->channel, dev->port.count);
85340 + dev->channel, atomic_read(&dev->port.count));
85341
85342 spin_lock_irqsave(&dev->port.lock, flags);
85343 - if (++dev->port.count > 1) {
85344 + if (atomic_inc_return(&dev->port.count) > 1) {
85345 spin_unlock_irqrestore(&dev->port.lock, flags);
85346 return 0;
85347 }
85348 @@ -727,10 +727,10 @@ static void rfcomm_tty_close(struct tty_struct *tty, struct file *filp)
85349 return;
85350
85351 BT_DBG("tty %p dev %p dlc %p opened %d", tty, dev, dev->dlc,
85352 - dev->port.count);
85353 + atomic_read(&dev->port.count));
85354
85355 spin_lock_irqsave(&dev->port.lock, flags);
85356 - if (!--dev->port.count) {
85357 + if (!atomic_dec_return(&dev->port.count)) {
85358 spin_unlock_irqrestore(&dev->port.lock, flags);
85359 if (dev->tty_dev->parent)
85360 device_move(dev->tty_dev, NULL, DPM_ORDER_DEV_LAST);
85361 diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c
85362 index 8d493c9..3849e49 100644
85363 --- a/net/bridge/netfilter/ebtables.c
85364 +++ b/net/bridge/netfilter/ebtables.c
85365 @@ -1525,7 +1525,7 @@ static int do_ebt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
85366 tmp.valid_hooks = t->table->valid_hooks;
85367 }
85368 mutex_unlock(&ebt_mutex);
85369 - if (copy_to_user(user, &tmp, *len) != 0){
85370 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0){
85371 BUGPRINT("c2u Didn't work\n");
85372 ret = -EFAULT;
85373 break;
85374 @@ -2331,7 +2331,7 @@ static int compat_do_ebt_get_ctl(struct sock *sk, int cmd,
85375 goto out;
85376 tmp.valid_hooks = t->valid_hooks;
85377
85378 - if (copy_to_user(user, &tmp, *len) != 0) {
85379 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0) {
85380 ret = -EFAULT;
85381 break;
85382 }
85383 @@ -2342,7 +2342,7 @@ static int compat_do_ebt_get_ctl(struct sock *sk, int cmd,
85384 tmp.entries_size = t->table->entries_size;
85385 tmp.valid_hooks = t->table->valid_hooks;
85386
85387 - if (copy_to_user(user, &tmp, *len) != 0) {
85388 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0) {
85389 ret = -EFAULT;
85390 break;
85391 }
85392 diff --git a/net/caif/cfctrl.c b/net/caif/cfctrl.c
85393 index a376ec1..1fbd6be 100644
85394 --- a/net/caif/cfctrl.c
85395 +++ b/net/caif/cfctrl.c
85396 @@ -10,6 +10,7 @@
85397 #include <linux/spinlock.h>
85398 #include <linux/slab.h>
85399 #include <linux/pkt_sched.h>
85400 +#include <linux/sched.h>
85401 #include <net/caif/caif_layer.h>
85402 #include <net/caif/cfpkt.h>
85403 #include <net/caif/cfctrl.h>
85404 @@ -43,8 +44,8 @@ struct cflayer *cfctrl_create(void)
85405 memset(&dev_info, 0, sizeof(dev_info));
85406 dev_info.id = 0xff;
85407 cfsrvl_init(&this->serv, 0, &dev_info, false);
85408 - atomic_set(&this->req_seq_no, 1);
85409 - atomic_set(&this->rsp_seq_no, 1);
85410 + atomic_set_unchecked(&this->req_seq_no, 1);
85411 + atomic_set_unchecked(&this->rsp_seq_no, 1);
85412 this->serv.layer.receive = cfctrl_recv;
85413 sprintf(this->serv.layer.name, "ctrl");
85414 this->serv.layer.ctrlcmd = cfctrl_ctrlcmd;
85415 @@ -130,8 +131,8 @@ static void cfctrl_insert_req(struct cfctrl *ctrl,
85416 struct cfctrl_request_info *req)
85417 {
85418 spin_lock_bh(&ctrl->info_list_lock);
85419 - atomic_inc(&ctrl->req_seq_no);
85420 - req->sequence_no = atomic_read(&ctrl->req_seq_no);
85421 + atomic_inc_unchecked(&ctrl->req_seq_no);
85422 + req->sequence_no = atomic_read_unchecked(&ctrl->req_seq_no);
85423 list_add_tail(&req->list, &ctrl->list);
85424 spin_unlock_bh(&ctrl->info_list_lock);
85425 }
85426 @@ -149,7 +150,7 @@ static struct cfctrl_request_info *cfctrl_remove_req(struct cfctrl *ctrl,
85427 if (p != first)
85428 pr_warn("Requests are not received in order\n");
85429
85430 - atomic_set(&ctrl->rsp_seq_no,
85431 + atomic_set_unchecked(&ctrl->rsp_seq_no,
85432 p->sequence_no);
85433 list_del(&p->list);
85434 goto out;
85435 diff --git a/net/can/af_can.c b/net/can/af_can.c
85436 index c48e522..1223690 100644
85437 --- a/net/can/af_can.c
85438 +++ b/net/can/af_can.c
85439 @@ -870,7 +870,7 @@ static const struct net_proto_family can_family_ops = {
85440 };
85441
85442 /* notifier block for netdevice event */
85443 -static struct notifier_block can_netdev_notifier __read_mostly = {
85444 +static struct notifier_block can_netdev_notifier = {
85445 .notifier_call = can_notifier,
85446 };
85447
85448 diff --git a/net/can/gw.c b/net/can/gw.c
85449 index 117814a..ad4fb73 100644
85450 --- a/net/can/gw.c
85451 +++ b/net/can/gw.c
85452 @@ -80,7 +80,6 @@ MODULE_PARM_DESC(max_hops,
85453 "default: " __stringify(CGW_DEFAULT_HOPS) ")");
85454
85455 static HLIST_HEAD(cgw_list);
85456 -static struct notifier_block notifier;
85457
85458 static struct kmem_cache *cgw_cache __read_mostly;
85459
85460 @@ -928,6 +927,10 @@ static int cgw_remove_job(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
85461 return err;
85462 }
85463
85464 +static struct notifier_block notifier = {
85465 + .notifier_call = cgw_notifier
85466 +};
85467 +
85468 static __init int cgw_module_init(void)
85469 {
85470 /* sanitize given module parameter */
85471 @@ -943,7 +946,6 @@ static __init int cgw_module_init(void)
85472 return -ENOMEM;
85473
85474 /* set notifier */
85475 - notifier.notifier_call = cgw_notifier;
85476 register_netdevice_notifier(&notifier);
85477
85478 if (__rtnl_register(PF_CAN, RTM_GETROUTE, NULL, cgw_dump_jobs, NULL)) {
85479 diff --git a/net/compat.c b/net/compat.c
85480 index 79ae884..17c5c09 100644
85481 --- a/net/compat.c
85482 +++ b/net/compat.c
85483 @@ -71,9 +71,9 @@ int get_compat_msghdr(struct msghdr *kmsg, struct compat_msghdr __user *umsg)
85484 __get_user(kmsg->msg_controllen, &umsg->msg_controllen) ||
85485 __get_user(kmsg->msg_flags, &umsg->msg_flags))
85486 return -EFAULT;
85487 - kmsg->msg_name = compat_ptr(tmp1);
85488 - kmsg->msg_iov = compat_ptr(tmp2);
85489 - kmsg->msg_control = compat_ptr(tmp3);
85490 + kmsg->msg_name = (void __force_kernel *)compat_ptr(tmp1);
85491 + kmsg->msg_iov = (void __force_kernel *)compat_ptr(tmp2);
85492 + kmsg->msg_control = (void __force_kernel *)compat_ptr(tmp3);
85493 return 0;
85494 }
85495
85496 @@ -85,7 +85,7 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
85497
85498 if (kern_msg->msg_namelen) {
85499 if (mode == VERIFY_READ) {
85500 - int err = move_addr_to_kernel(kern_msg->msg_name,
85501 + int err = move_addr_to_kernel((void __force_user *)kern_msg->msg_name,
85502 kern_msg->msg_namelen,
85503 kern_address);
85504 if (err < 0)
85505 @@ -96,7 +96,7 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
85506 kern_msg->msg_name = NULL;
85507
85508 tot_len = iov_from_user_compat_to_kern(kern_iov,
85509 - (struct compat_iovec __user *)kern_msg->msg_iov,
85510 + (struct compat_iovec __force_user *)kern_msg->msg_iov,
85511 kern_msg->msg_iovlen);
85512 if (tot_len >= 0)
85513 kern_msg->msg_iov = kern_iov;
85514 @@ -116,20 +116,20 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
85515
85516 #define CMSG_COMPAT_FIRSTHDR(msg) \
85517 (((msg)->msg_controllen) >= sizeof(struct compat_cmsghdr) ? \
85518 - (struct compat_cmsghdr __user *)((msg)->msg_control) : \
85519 + (struct compat_cmsghdr __force_user *)((msg)->msg_control) : \
85520 (struct compat_cmsghdr __user *)NULL)
85521
85522 #define CMSG_COMPAT_OK(ucmlen, ucmsg, mhdr) \
85523 ((ucmlen) >= sizeof(struct compat_cmsghdr) && \
85524 (ucmlen) <= (unsigned long) \
85525 ((mhdr)->msg_controllen - \
85526 - ((char *)(ucmsg) - (char *)(mhdr)->msg_control)))
85527 + ((char __force_kernel *)(ucmsg) - (char *)(mhdr)->msg_control)))
85528
85529 static inline struct compat_cmsghdr __user *cmsg_compat_nxthdr(struct msghdr *msg,
85530 struct compat_cmsghdr __user *cmsg, int cmsg_len)
85531 {
85532 char __user *ptr = (char __user *)cmsg + CMSG_COMPAT_ALIGN(cmsg_len);
85533 - if ((unsigned long)(ptr + 1 - (char __user *)msg->msg_control) >
85534 + if ((unsigned long)(ptr + 1 - (char __force_user *)msg->msg_control) >
85535 msg->msg_controllen)
85536 return NULL;
85537 return (struct compat_cmsghdr __user *)ptr;
85538 @@ -219,7 +219,7 @@ Efault:
85539
85540 int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *data)
85541 {
85542 - struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control;
85543 + struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __force_user *) kmsg->msg_control;
85544 struct compat_cmsghdr cmhdr;
85545 struct compat_timeval ctv;
85546 struct compat_timespec cts[3];
85547 @@ -275,7 +275,7 @@ int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *dat
85548
85549 void scm_detach_fds_compat(struct msghdr *kmsg, struct scm_cookie *scm)
85550 {
85551 - struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control;
85552 + struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __force_user *) kmsg->msg_control;
85553 int fdmax = (kmsg->msg_controllen - sizeof(struct compat_cmsghdr)) / sizeof(int);
85554 int fdnum = scm->fp->count;
85555 struct file **fp = scm->fp->fp;
85556 @@ -363,7 +363,7 @@ static int do_set_sock_timeout(struct socket *sock, int level,
85557 return -EFAULT;
85558 old_fs = get_fs();
85559 set_fs(KERNEL_DS);
85560 - err = sock_setsockopt(sock, level, optname, (char *)&ktime, sizeof(ktime));
85561 + err = sock_setsockopt(sock, level, optname, (char __force_user *)&ktime, sizeof(ktime));
85562 set_fs(old_fs);
85563
85564 return err;
85565 @@ -424,7 +424,7 @@ static int do_get_sock_timeout(struct socket *sock, int level, int optname,
85566 len = sizeof(ktime);
85567 old_fs = get_fs();
85568 set_fs(KERNEL_DS);
85569 - err = sock_getsockopt(sock, level, optname, (char *) &ktime, &len);
85570 + err = sock_getsockopt(sock, level, optname, (char __force_user *) &ktime, (int __force_user *)&len);
85571 set_fs(old_fs);
85572
85573 if (!err) {
85574 @@ -567,7 +567,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
85575 case MCAST_JOIN_GROUP:
85576 case MCAST_LEAVE_GROUP:
85577 {
85578 - struct compat_group_req __user *gr32 = (void *)optval;
85579 + struct compat_group_req __user *gr32 = (void __user *)optval;
85580 struct group_req __user *kgr =
85581 compat_alloc_user_space(sizeof(struct group_req));
85582 u32 interface;
85583 @@ -588,7 +588,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
85584 case MCAST_BLOCK_SOURCE:
85585 case MCAST_UNBLOCK_SOURCE:
85586 {
85587 - struct compat_group_source_req __user *gsr32 = (void *)optval;
85588 + struct compat_group_source_req __user *gsr32 = (void __user *)optval;
85589 struct group_source_req __user *kgsr = compat_alloc_user_space(
85590 sizeof(struct group_source_req));
85591 u32 interface;
85592 @@ -609,7 +609,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
85593 }
85594 case MCAST_MSFILTER:
85595 {
85596 - struct compat_group_filter __user *gf32 = (void *)optval;
85597 + struct compat_group_filter __user *gf32 = (void __user *)optval;
85598 struct group_filter __user *kgf;
85599 u32 interface, fmode, numsrc;
85600
85601 @@ -647,7 +647,7 @@ int compat_mc_getsockopt(struct sock *sock, int level, int optname,
85602 char __user *optval, int __user *optlen,
85603 int (*getsockopt)(struct sock *, int, int, char __user *, int __user *))
85604 {
85605 - struct compat_group_filter __user *gf32 = (void *)optval;
85606 + struct compat_group_filter __user *gf32 = (void __user *)optval;
85607 struct group_filter __user *kgf;
85608 int __user *koptlen;
85609 u32 interface, fmode, numsrc;
85610 @@ -796,7 +796,7 @@ asmlinkage long compat_sys_socketcall(int call, u32 __user *args)
85611
85612 if (call < SYS_SOCKET || call > SYS_SENDMMSG)
85613 return -EINVAL;
85614 - if (copy_from_user(a, args, nas[call]))
85615 + if (nas[call] > sizeof a || copy_from_user(a, args, nas[call]))
85616 return -EFAULT;
85617 a0 = a[0];
85618 a1 = a[1];
85619 diff --git a/net/core/datagram.c b/net/core/datagram.c
85620 index 368f9c3..f82d4a3 100644
85621 --- a/net/core/datagram.c
85622 +++ b/net/core/datagram.c
85623 @@ -289,7 +289,7 @@ int skb_kill_datagram(struct sock *sk, struct sk_buff *skb, unsigned int flags)
85624 }
85625
85626 kfree_skb(skb);
85627 - atomic_inc(&sk->sk_drops);
85628 + atomic_inc_unchecked(&sk->sk_drops);
85629 sk_mem_reclaim_partial(sk);
85630
85631 return err;
85632 diff --git a/net/core/dev.c b/net/core/dev.c
85633 index 9a278e9..15f2b9e 100644
85634 --- a/net/core/dev.c
85635 +++ b/net/core/dev.c
85636 @@ -1617,7 +1617,7 @@ int dev_forward_skb(struct net_device *dev, struct sk_buff *skb)
85637 {
85638 if (skb_shinfo(skb)->tx_flags & SKBTX_DEV_ZEROCOPY) {
85639 if (skb_copy_ubufs(skb, GFP_ATOMIC)) {
85640 - atomic_long_inc(&dev->rx_dropped);
85641 + atomic_long_inc_unchecked(&dev->rx_dropped);
85642 kfree_skb(skb);
85643 return NET_RX_DROP;
85644 }
85645 @@ -1626,7 +1626,7 @@ int dev_forward_skb(struct net_device *dev, struct sk_buff *skb)
85646 skb_orphan(skb);
85647
85648 if (unlikely(!is_skb_forwardable(dev, skb))) {
85649 - atomic_long_inc(&dev->rx_dropped);
85650 + atomic_long_inc_unchecked(&dev->rx_dropped);
85651 kfree_skb(skb);
85652 return NET_RX_DROP;
85653 }
85654 @@ -2351,7 +2351,7 @@ static int illegal_highdma(struct net_device *dev, struct sk_buff *skb)
85655
85656 struct dev_gso_cb {
85657 void (*destructor)(struct sk_buff *skb);
85658 -};
85659 +} __no_const;
85660
85661 #define DEV_GSO_CB(skb) ((struct dev_gso_cb *)(skb)->cb)
85662
85663 @@ -3093,7 +3093,7 @@ enqueue:
85664
85665 local_irq_restore(flags);
85666
85667 - atomic_long_inc(&skb->dev->rx_dropped);
85668 + atomic_long_inc_unchecked(&skb->dev->rx_dropped);
85669 kfree_skb(skb);
85670 return NET_RX_DROP;
85671 }
85672 @@ -3165,7 +3165,7 @@ int netif_rx_ni(struct sk_buff *skb)
85673 }
85674 EXPORT_SYMBOL(netif_rx_ni);
85675
85676 -static void net_tx_action(struct softirq_action *h)
85677 +static void net_tx_action(void)
85678 {
85679 struct softnet_data *sd = &__get_cpu_var(softnet_data);
85680
85681 @@ -3490,7 +3490,7 @@ ncls:
85682 ret = pt_prev->func(skb, skb->dev, pt_prev, orig_dev);
85683 } else {
85684 drop:
85685 - atomic_long_inc(&skb->dev->rx_dropped);
85686 + atomic_long_inc_unchecked(&skb->dev->rx_dropped);
85687 kfree_skb(skb);
85688 /* Jamal, now you will not able to escape explaining
85689 * me how you were going to use this. :-)
85690 @@ -4095,7 +4095,7 @@ void netif_napi_del(struct napi_struct *napi)
85691 }
85692 EXPORT_SYMBOL(netif_napi_del);
85693
85694 -static void net_rx_action(struct softirq_action *h)
85695 +static void net_rx_action(void)
85696 {
85697 struct softnet_data *sd = &__get_cpu_var(softnet_data);
85698 unsigned long time_limit = jiffies + 2;
85699 @@ -5522,7 +5522,7 @@ struct rtnl_link_stats64 *dev_get_stats(struct net_device *dev,
85700 } else {
85701 netdev_stats_to_stats64(storage, &dev->stats);
85702 }
85703 - storage->rx_dropped += atomic_long_read(&dev->rx_dropped);
85704 + storage->rx_dropped += atomic_long_read_unchecked(&dev->rx_dropped);
85705 return storage;
85706 }
85707 EXPORT_SYMBOL(dev_get_stats);
85708 diff --git a/net/core/dev_ioctl.c b/net/core/dev_ioctl.c
85709 index 6cc0481..59cfb00 100644
85710 --- a/net/core/dev_ioctl.c
85711 +++ b/net/core/dev_ioctl.c
85712 @@ -376,9 +376,13 @@ void dev_load(struct net *net, const char *name)
85713 if (no_module && capable(CAP_NET_ADMIN))
85714 no_module = request_module("netdev-%s", name);
85715 if (no_module && capable(CAP_SYS_MODULE)) {
85716 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
85717 + ___request_module(true, "grsec_modharden_netdev", "%s", name);
85718 +#else
85719 if (!request_module("%s", name))
85720 pr_warn("Loading kernel module for a network device with CAP_SYS_MODULE (deprecated). Use CAP_NET_ADMIN and alias netdev-%s instead.\n",
85721 name);
85722 +#endif
85723 }
85724 }
85725 EXPORT_SYMBOL(dev_load);
85726 diff --git a/net/core/flow.c b/net/core/flow.c
85727 index 2bfd081..53c6058 100644
85728 --- a/net/core/flow.c
85729 +++ b/net/core/flow.c
85730 @@ -61,7 +61,7 @@ struct flow_cache {
85731 struct timer_list rnd_timer;
85732 };
85733
85734 -atomic_t flow_cache_genid = ATOMIC_INIT(0);
85735 +atomic_unchecked_t flow_cache_genid = ATOMIC_INIT(0);
85736 EXPORT_SYMBOL(flow_cache_genid);
85737 static struct flow_cache flow_cache_global;
85738 static struct kmem_cache *flow_cachep __read_mostly;
85739 @@ -86,7 +86,7 @@ static void flow_cache_new_hashrnd(unsigned long arg)
85740
85741 static int flow_entry_valid(struct flow_cache_entry *fle)
85742 {
85743 - if (atomic_read(&flow_cache_genid) != fle->genid)
85744 + if (atomic_read_unchecked(&flow_cache_genid) != fle->genid)
85745 return 0;
85746 if (fle->object && !fle->object->ops->check(fle->object))
85747 return 0;
85748 @@ -258,7 +258,7 @@ flow_cache_lookup(struct net *net, const struct flowi *key, u16 family, u8 dir,
85749 hlist_add_head(&fle->u.hlist, &fcp->hash_table[hash]);
85750 fcp->hash_count++;
85751 }
85752 - } else if (likely(fle->genid == atomic_read(&flow_cache_genid))) {
85753 + } else if (likely(fle->genid == atomic_read_unchecked(&flow_cache_genid))) {
85754 flo = fle->object;
85755 if (!flo)
85756 goto ret_object;
85757 @@ -279,7 +279,7 @@ nocache:
85758 }
85759 flo = resolver(net, key, family, dir, flo, ctx);
85760 if (fle) {
85761 - fle->genid = atomic_read(&flow_cache_genid);
85762 + fle->genid = atomic_read_unchecked(&flow_cache_genid);
85763 if (!IS_ERR(flo))
85764 fle->object = flo;
85765 else
85766 diff --git a/net/core/iovec.c b/net/core/iovec.c
85767 index 7e7aeb0..2a998cb 100644
85768 --- a/net/core/iovec.c
85769 +++ b/net/core/iovec.c
85770 @@ -42,7 +42,7 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr_storage *a
85771 if (m->msg_namelen) {
85772 if (mode == VERIFY_READ) {
85773 void __user *namep;
85774 - namep = (void __user __force *) m->msg_name;
85775 + namep = (void __force_user *) m->msg_name;
85776 err = move_addr_to_kernel(namep, m->msg_namelen,
85777 address);
85778 if (err < 0)
85779 @@ -54,7 +54,7 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr_storage *a
85780 }
85781
85782 size = m->msg_iovlen * sizeof(struct iovec);
85783 - if (copy_from_user(iov, (void __user __force *) m->msg_iov, size))
85784 + if (copy_from_user(iov, (void __force_user *) m->msg_iov, size))
85785 return -EFAULT;
85786
85787 m->msg_iov = iov;
85788 diff --git a/net/core/neighbour.c b/net/core/neighbour.c
85789 index 3863b8f..85c99a6 100644
85790 --- a/net/core/neighbour.c
85791 +++ b/net/core/neighbour.c
85792 @@ -2778,7 +2778,7 @@ static int proc_unres_qlen(ctl_table *ctl, int write, void __user *buffer,
85793 size_t *lenp, loff_t *ppos)
85794 {
85795 int size, ret;
85796 - ctl_table tmp = *ctl;
85797 + ctl_table_no_const tmp = *ctl;
85798
85799 tmp.extra1 = &zero;
85800 tmp.extra2 = &unres_qlen_max;
85801 diff --git a/net/core/net-procfs.c b/net/core/net-procfs.c
85802 index 3174f19..5810985 100644
85803 --- a/net/core/net-procfs.c
85804 +++ b/net/core/net-procfs.c
85805 @@ -271,8 +271,13 @@ static int ptype_seq_show(struct seq_file *seq, void *v)
85806 else
85807 seq_printf(seq, "%04x", ntohs(pt->type));
85808
85809 +#ifdef CONFIG_GRKERNSEC_HIDESYM
85810 + seq_printf(seq, " %-8s %pF\n",
85811 + pt->dev ? pt->dev->name : "", NULL);
85812 +#else
85813 seq_printf(seq, " %-8s %pF\n",
85814 pt->dev ? pt->dev->name : "", pt->func);
85815 +#endif
85816 }
85817
85818 return 0;
85819 diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
85820 index 7427ab5..389f411 100644
85821 --- a/net/core/net-sysfs.c
85822 +++ b/net/core/net-sysfs.c
85823 @@ -1321,7 +1321,7 @@ void netdev_class_remove_file(struct class_attribute *class_attr)
85824 }
85825 EXPORT_SYMBOL(netdev_class_remove_file);
85826
85827 -int netdev_kobject_init(void)
85828 +int __init netdev_kobject_init(void)
85829 {
85830 kobj_ns_type_register(&net_ns_type_operations);
85831 return class_register(&net_class);
85832 diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
85833 index 80e271d..2980cc2 100644
85834 --- a/net/core/net_namespace.c
85835 +++ b/net/core/net_namespace.c
85836 @@ -442,7 +442,7 @@ static int __register_pernet_operations(struct list_head *list,
85837 int error;
85838 LIST_HEAD(net_exit_list);
85839
85840 - list_add_tail(&ops->list, list);
85841 + pax_list_add_tail((struct list_head *)&ops->list, list);
85842 if (ops->init || (ops->id && ops->size)) {
85843 for_each_net(net) {
85844 error = ops_init(ops, net);
85845 @@ -455,7 +455,7 @@ static int __register_pernet_operations(struct list_head *list,
85846
85847 out_undo:
85848 /* If I have an error cleanup all namespaces I initialized */
85849 - list_del(&ops->list);
85850 + pax_list_del((struct list_head *)&ops->list);
85851 ops_exit_list(ops, &net_exit_list);
85852 ops_free_list(ops, &net_exit_list);
85853 return error;
85854 @@ -466,7 +466,7 @@ static void __unregister_pernet_operations(struct pernet_operations *ops)
85855 struct net *net;
85856 LIST_HEAD(net_exit_list);
85857
85858 - list_del(&ops->list);
85859 + pax_list_del((struct list_head *)&ops->list);
85860 for_each_net(net)
85861 list_add_tail(&net->exit_list, &net_exit_list);
85862 ops_exit_list(ops, &net_exit_list);
85863 @@ -600,7 +600,7 @@ int register_pernet_device(struct pernet_operations *ops)
85864 mutex_lock(&net_mutex);
85865 error = register_pernet_operations(&pernet_list, ops);
85866 if (!error && (first_device == &pernet_list))
85867 - first_device = &ops->list;
85868 + first_device = (struct list_head *)&ops->list;
85869 mutex_unlock(&net_mutex);
85870 return error;
85871 }
85872 diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
85873 index 23854b5..ff4fda4 100644
85874 --- a/net/core/rtnetlink.c
85875 +++ b/net/core/rtnetlink.c
85876 @@ -58,7 +58,7 @@ struct rtnl_link {
85877 rtnl_doit_func doit;
85878 rtnl_dumpit_func dumpit;
85879 rtnl_calcit_func calcit;
85880 -};
85881 +} __no_const;
85882
85883 static DEFINE_MUTEX(rtnl_mutex);
85884
85885 @@ -299,10 +299,13 @@ int __rtnl_link_register(struct rtnl_link_ops *ops)
85886 if (rtnl_link_ops_get(ops->kind))
85887 return -EEXIST;
85888
85889 - if (!ops->dellink)
85890 - ops->dellink = unregister_netdevice_queue;
85891 + if (!ops->dellink) {
85892 + pax_open_kernel();
85893 + *(void **)&ops->dellink = unregister_netdevice_queue;
85894 + pax_close_kernel();
85895 + }
85896
85897 - list_add_tail(&ops->list, &link_ops);
85898 + pax_list_add_tail((struct list_head *)&ops->list, &link_ops);
85899 return 0;
85900 }
85901 EXPORT_SYMBOL_GPL(__rtnl_link_register);
85902 @@ -349,7 +352,7 @@ void __rtnl_link_unregister(struct rtnl_link_ops *ops)
85903 for_each_net(net) {
85904 __rtnl_kill_links(net, ops);
85905 }
85906 - list_del(&ops->list);
85907 + pax_list_del((struct list_head *)&ops->list);
85908 }
85909 EXPORT_SYMBOL_GPL(__rtnl_link_unregister);
85910
85911 diff --git a/net/core/scm.c b/net/core/scm.c
85912 index 2dc6cda..2159524 100644
85913 --- a/net/core/scm.c
85914 +++ b/net/core/scm.c
85915 @@ -226,7 +226,7 @@ EXPORT_SYMBOL(__scm_send);
85916 int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
85917 {
85918 struct cmsghdr __user *cm
85919 - = (__force struct cmsghdr __user *)msg->msg_control;
85920 + = (struct cmsghdr __force_user *)msg->msg_control;
85921 struct cmsghdr cmhdr;
85922 int cmlen = CMSG_LEN(len);
85923 int err;
85924 @@ -249,7 +249,7 @@ int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
85925 err = -EFAULT;
85926 if (copy_to_user(cm, &cmhdr, sizeof cmhdr))
85927 goto out;
85928 - if (copy_to_user(CMSG_DATA(cm), data, cmlen - sizeof(struct cmsghdr)))
85929 + if (copy_to_user((void __force_user *)CMSG_DATA((void __force_kernel *)cm), data, cmlen - sizeof(struct cmsghdr)))
85930 goto out;
85931 cmlen = CMSG_SPACE(len);
85932 if (msg->msg_controllen < cmlen)
85933 @@ -265,7 +265,7 @@ EXPORT_SYMBOL(put_cmsg);
85934 void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
85935 {
85936 struct cmsghdr __user *cm
85937 - = (__force struct cmsghdr __user*)msg->msg_control;
85938 + = (struct cmsghdr __force_user *)msg->msg_control;
85939
85940 int fdmax = 0;
85941 int fdnum = scm->fp->count;
85942 @@ -285,7 +285,7 @@ void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
85943 if (fdnum < fdmax)
85944 fdmax = fdnum;
85945
85946 - for (i=0, cmfptr=(__force int __user *)CMSG_DATA(cm); i<fdmax;
85947 + for (i=0, cmfptr=(int __force_user *)CMSG_DATA((void __force_kernel *)cm); i<fdmax;
85948 i++, cmfptr++)
85949 {
85950 struct socket *sock;
85951 diff --git a/net/core/secure_seq.c b/net/core/secure_seq.c
85952 index e61a8bb..6a2f13c 100644
85953 --- a/net/core/secure_seq.c
85954 +++ b/net/core/secure_seq.c
85955 @@ -12,12 +12,10 @@
85956
85957 static u32 net_secret[MD5_MESSAGE_BYTES / 4] ____cacheline_aligned;
85958
85959 -static int __init net_secret_init(void)
85960 +void net_secret_init(void)
85961 {
85962 get_random_bytes(net_secret, sizeof(net_secret));
85963 - return 0;
85964 }
85965 -late_initcall(net_secret_init);
85966
85967 #ifdef CONFIG_INET
85968 static u32 seq_scale(u32 seq)
85969 diff --git a/net/core/sock.c b/net/core/sock.c
85970 index 1432266..1a0d4a1 100644
85971 --- a/net/core/sock.c
85972 +++ b/net/core/sock.c
85973 @@ -390,7 +390,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
85974 struct sk_buff_head *list = &sk->sk_receive_queue;
85975
85976 if (atomic_read(&sk->sk_rmem_alloc) >= sk->sk_rcvbuf) {
85977 - atomic_inc(&sk->sk_drops);
85978 + atomic_inc_unchecked(&sk->sk_drops);
85979 trace_sock_rcvqueue_full(sk, skb);
85980 return -ENOMEM;
85981 }
85982 @@ -400,7 +400,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
85983 return err;
85984
85985 if (!sk_rmem_schedule(sk, skb, skb->truesize)) {
85986 - atomic_inc(&sk->sk_drops);
85987 + atomic_inc_unchecked(&sk->sk_drops);
85988 return -ENOBUFS;
85989 }
85990
85991 @@ -420,7 +420,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
85992 skb_dst_force(skb);
85993
85994 spin_lock_irqsave(&list->lock, flags);
85995 - skb->dropcount = atomic_read(&sk->sk_drops);
85996 + skb->dropcount = atomic_read_unchecked(&sk->sk_drops);
85997 __skb_queue_tail(list, skb);
85998 spin_unlock_irqrestore(&list->lock, flags);
85999
86000 @@ -440,7 +440,7 @@ int sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested)
86001 skb->dev = NULL;
86002
86003 if (sk_rcvqueues_full(sk, skb, sk->sk_rcvbuf)) {
86004 - atomic_inc(&sk->sk_drops);
86005 + atomic_inc_unchecked(&sk->sk_drops);
86006 goto discard_and_relse;
86007 }
86008 if (nested)
86009 @@ -458,7 +458,7 @@ int sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested)
86010 mutex_release(&sk->sk_lock.dep_map, 1, _RET_IP_);
86011 } else if (sk_add_backlog(sk, skb, sk->sk_rcvbuf)) {
86012 bh_unlock_sock(sk);
86013 - atomic_inc(&sk->sk_drops);
86014 + atomic_inc_unchecked(&sk->sk_drops);
86015 goto discard_and_relse;
86016 }
86017
86018 @@ -942,12 +942,12 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
86019 struct timeval tm;
86020 } v;
86021
86022 - int lv = sizeof(int);
86023 - int len;
86024 + unsigned int lv = sizeof(int);
86025 + unsigned int len;
86026
86027 if (get_user(len, optlen))
86028 return -EFAULT;
86029 - if (len < 0)
86030 + if (len > INT_MAX)
86031 return -EINVAL;
86032
86033 memset(&v, 0, sizeof(v));
86034 @@ -1099,11 +1099,11 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
86035
86036 case SO_PEERNAME:
86037 {
86038 - char address[128];
86039 + char address[_K_SS_MAXSIZE];
86040
86041 if (sock->ops->getname(sock, (struct sockaddr *)address, &lv, 2))
86042 return -ENOTCONN;
86043 - if (lv < len)
86044 + if (lv < len || sizeof address < len)
86045 return -EINVAL;
86046 if (copy_to_user(optval, address, len))
86047 return -EFAULT;
86048 @@ -1166,7 +1166,7 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
86049
86050 if (len > lv)
86051 len = lv;
86052 - if (copy_to_user(optval, &v, len))
86053 + if (len > sizeof(v) || copy_to_user(optval, &v, len))
86054 return -EFAULT;
86055 lenout:
86056 if (put_user(len, optlen))
86057 @@ -2284,7 +2284,7 @@ void sock_init_data(struct socket *sock, struct sock *sk)
86058 */
86059 smp_wmb();
86060 atomic_set(&sk->sk_refcnt, 1);
86061 - atomic_set(&sk->sk_drops, 0);
86062 + atomic_set_unchecked(&sk->sk_drops, 0);
86063 }
86064 EXPORT_SYMBOL(sock_init_data);
86065
86066 diff --git a/net/core/sock_diag.c b/net/core/sock_diag.c
86067 index a29e90c..922399c 100644
86068 --- a/net/core/sock_diag.c
86069 +++ b/net/core/sock_diag.c
86070 @@ -9,26 +9,33 @@
86071 #include <linux/inet_diag.h>
86072 #include <linux/sock_diag.h>
86073
86074 -static const struct sock_diag_handler *sock_diag_handlers[AF_MAX];
86075 +static const struct sock_diag_handler *sock_diag_handlers[AF_MAX] __read_only;
86076 static int (*inet_rcv_compat)(struct sk_buff *skb, struct nlmsghdr *nlh);
86077 static DEFINE_MUTEX(sock_diag_table_mutex);
86078
86079 int sock_diag_check_cookie(void *sk, __u32 *cookie)
86080 {
86081 +#ifndef CONFIG_GRKERNSEC_HIDESYM
86082 if ((cookie[0] != INET_DIAG_NOCOOKIE ||
86083 cookie[1] != INET_DIAG_NOCOOKIE) &&
86084 ((u32)(unsigned long)sk != cookie[0] ||
86085 (u32)((((unsigned long)sk) >> 31) >> 1) != cookie[1]))
86086 return -ESTALE;
86087 else
86088 +#endif
86089 return 0;
86090 }
86091 EXPORT_SYMBOL_GPL(sock_diag_check_cookie);
86092
86093 void sock_diag_save_cookie(void *sk, __u32 *cookie)
86094 {
86095 +#ifdef CONFIG_GRKERNSEC_HIDESYM
86096 + cookie[0] = 0;
86097 + cookie[1] = 0;
86098 +#else
86099 cookie[0] = (u32)(unsigned long)sk;
86100 cookie[1] = (u32)(((unsigned long)sk >> 31) >> 1);
86101 +#endif
86102 }
86103 EXPORT_SYMBOL_GPL(sock_diag_save_cookie);
86104
86105 @@ -75,8 +82,11 @@ int sock_diag_register(const struct sock_diag_handler *hndl)
86106 mutex_lock(&sock_diag_table_mutex);
86107 if (sock_diag_handlers[hndl->family])
86108 err = -EBUSY;
86109 - else
86110 + else {
86111 + pax_open_kernel();
86112 sock_diag_handlers[hndl->family] = hndl;
86113 + pax_close_kernel();
86114 + }
86115 mutex_unlock(&sock_diag_table_mutex);
86116
86117 return err;
86118 @@ -92,7 +102,9 @@ void sock_diag_unregister(const struct sock_diag_handler *hnld)
86119
86120 mutex_lock(&sock_diag_table_mutex);
86121 BUG_ON(sock_diag_handlers[family] != hnld);
86122 + pax_open_kernel();
86123 sock_diag_handlers[family] = NULL;
86124 + pax_close_kernel();
86125 mutex_unlock(&sock_diag_table_mutex);
86126 }
86127 EXPORT_SYMBOL_GPL(sock_diag_unregister);
86128 diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c
86129 index cfdb46a..cef55e1 100644
86130 --- a/net/core/sysctl_net_core.c
86131 +++ b/net/core/sysctl_net_core.c
86132 @@ -28,7 +28,7 @@ static int rps_sock_flow_sysctl(ctl_table *table, int write,
86133 {
86134 unsigned int orig_size, size;
86135 int ret, i;
86136 - ctl_table tmp = {
86137 + ctl_table_no_const tmp = {
86138 .data = &size,
86139 .maxlen = sizeof(size),
86140 .mode = table->mode
86141 @@ -211,13 +211,12 @@ static struct ctl_table netns_core_table[] = {
86142
86143 static __net_init int sysctl_core_net_init(struct net *net)
86144 {
86145 - struct ctl_table *tbl;
86146 + ctl_table_no_const *tbl = NULL;
86147
86148 net->core.sysctl_somaxconn = SOMAXCONN;
86149
86150 - tbl = netns_core_table;
86151 if (!net_eq(net, &init_net)) {
86152 - tbl = kmemdup(tbl, sizeof(netns_core_table), GFP_KERNEL);
86153 + tbl = kmemdup(netns_core_table, sizeof(netns_core_table), GFP_KERNEL);
86154 if (tbl == NULL)
86155 goto err_dup;
86156
86157 @@ -227,17 +226,16 @@ static __net_init int sysctl_core_net_init(struct net *net)
86158 if (net->user_ns != &init_user_ns) {
86159 tbl[0].procname = NULL;
86160 }
86161 - }
86162 -
86163 - net->core.sysctl_hdr = register_net_sysctl(net, "net/core", tbl);
86164 + net->core.sysctl_hdr = register_net_sysctl(net, "net/core", tbl);
86165 + } else
86166 + net->core.sysctl_hdr = register_net_sysctl(net, "net/core", netns_core_table);
86167 if (net->core.sysctl_hdr == NULL)
86168 goto err_reg;
86169
86170 return 0;
86171
86172 err_reg:
86173 - if (tbl != netns_core_table)
86174 - kfree(tbl);
86175 + kfree(tbl);
86176 err_dup:
86177 return -ENOMEM;
86178 }
86179 @@ -252,7 +250,7 @@ static __net_exit void sysctl_core_net_exit(struct net *net)
86180 kfree(tbl);
86181 }
86182
86183 -static __net_initdata struct pernet_operations sysctl_core_ops = {
86184 +static __net_initconst struct pernet_operations sysctl_core_ops = {
86185 .init = sysctl_core_net_init,
86186 .exit = sysctl_core_net_exit,
86187 };
86188 diff --git a/net/decnet/af_decnet.c b/net/decnet/af_decnet.c
86189 index c21f200..bc4565b 100644
86190 --- a/net/decnet/af_decnet.c
86191 +++ b/net/decnet/af_decnet.c
86192 @@ -465,6 +465,7 @@ static struct proto dn_proto = {
86193 .sysctl_rmem = sysctl_decnet_rmem,
86194 .max_header = DN_MAX_NSP_DATA_HEADER + 64,
86195 .obj_size = sizeof(struct dn_sock),
86196 + .slab_flags = SLAB_USERCOPY,
86197 };
86198
86199 static struct sock *dn_alloc_sock(struct net *net, struct socket *sock, gfp_t gfp)
86200 diff --git a/net/decnet/sysctl_net_decnet.c b/net/decnet/sysctl_net_decnet.c
86201 index a55eecc..dd8428c 100644
86202 --- a/net/decnet/sysctl_net_decnet.c
86203 +++ b/net/decnet/sysctl_net_decnet.c
86204 @@ -174,7 +174,7 @@ static int dn_node_address_handler(ctl_table *table, int write,
86205
86206 if (len > *lenp) len = *lenp;
86207
86208 - if (copy_to_user(buffer, addr, len))
86209 + if (len > sizeof addr || copy_to_user(buffer, addr, len))
86210 return -EFAULT;
86211
86212 *lenp = len;
86213 @@ -237,7 +237,7 @@ static int dn_def_dev_handler(ctl_table *table, int write,
86214
86215 if (len > *lenp) len = *lenp;
86216
86217 - if (copy_to_user(buffer, devname, len))
86218 + if (len > sizeof devname || copy_to_user(buffer, devname, len))
86219 return -EFAULT;
86220
86221 *lenp = len;
86222 diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
86223 index c929d9c..df10cde 100644
86224 --- a/net/ipv4/af_inet.c
86225 +++ b/net/ipv4/af_inet.c
86226 @@ -115,6 +115,7 @@
86227 #include <net/inet_common.h>
86228 #include <net/xfrm.h>
86229 #include <net/net_namespace.h>
86230 +#include <net/secure_seq.h>
86231 #ifdef CONFIG_IP_MROUTE
86232 #include <linux/mroute.h>
86233 #endif
86234 @@ -263,8 +264,10 @@ void build_ehash_secret(void)
86235 get_random_bytes(&rnd, sizeof(rnd));
86236 } while (rnd == 0);
86237
86238 - if (cmpxchg(&inet_ehash_secret, 0, rnd) == 0)
86239 + if (cmpxchg(&inet_ehash_secret, 0, rnd) == 0) {
86240 get_random_bytes(&ipv6_hash_secret, sizeof(ipv6_hash_secret));
86241 + net_secret_init();
86242 + }
86243 }
86244 EXPORT_SYMBOL(build_ehash_secret);
86245
86246 @@ -1699,13 +1702,9 @@ static int __init inet_init(void)
86247
86248 BUILD_BUG_ON(sizeof(struct inet_skb_parm) > FIELD_SIZEOF(struct sk_buff, cb));
86249
86250 - sysctl_local_reserved_ports = kzalloc(65536 / 8, GFP_KERNEL);
86251 - if (!sysctl_local_reserved_ports)
86252 - goto out;
86253 -
86254 rc = proto_register(&tcp_prot, 1);
86255 if (rc)
86256 - goto out_free_reserved_ports;
86257 + goto out;
86258
86259 rc = proto_register(&udp_prot, 1);
86260 if (rc)
86261 @@ -1814,8 +1813,6 @@ out_unregister_udp_proto:
86262 proto_unregister(&udp_prot);
86263 out_unregister_tcp_proto:
86264 proto_unregister(&tcp_prot);
86265 -out_free_reserved_ports:
86266 - kfree(sysctl_local_reserved_ports);
86267 goto out;
86268 }
86269
86270 diff --git a/net/ipv4/ah4.c b/net/ipv4/ah4.c
86271 index 2e7f194..0fa4d6d 100644
86272 --- a/net/ipv4/ah4.c
86273 +++ b/net/ipv4/ah4.c
86274 @@ -420,7 +420,7 @@ static void ah4_err(struct sk_buff *skb, u32 info)
86275 return;
86276
86277 if (icmp_hdr(skb)->type == ICMP_DEST_UNREACH) {
86278 - atomic_inc(&flow_cache_genid);
86279 + atomic_inc_unchecked(&flow_cache_genid);
86280 rt_genid_bump(net);
86281
86282 ipv4_update_pmtu(skb, net, info, 0, 0, IPPROTO_AH, 0);
86283 diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
86284 index c6287cd..e9bc96a 100644
86285 --- a/net/ipv4/devinet.c
86286 +++ b/net/ipv4/devinet.c
86287 @@ -1992,7 +1992,7 @@ static int ipv4_doint_and_flush(ctl_table *ctl, int write,
86288 #define DEVINET_SYSCTL_FLUSHING_ENTRY(attr, name) \
86289 DEVINET_SYSCTL_COMPLEX_ENTRY(attr, name, ipv4_doint_and_flush)
86290
86291 -static struct devinet_sysctl_table {
86292 +static const struct devinet_sysctl_table {
86293 struct ctl_table_header *sysctl_header;
86294 struct ctl_table devinet_vars[__IPV4_DEVCONF_MAX];
86295 } devinet_sysctl = {
86296 @@ -2110,7 +2110,7 @@ static __net_init int devinet_init_net(struct net *net)
86297 int err;
86298 struct ipv4_devconf *all, *dflt;
86299 #ifdef CONFIG_SYSCTL
86300 - struct ctl_table *tbl = ctl_forward_entry;
86301 + ctl_table_no_const *tbl = NULL;
86302 struct ctl_table_header *forw_hdr;
86303 #endif
86304
86305 @@ -2128,7 +2128,7 @@ static __net_init int devinet_init_net(struct net *net)
86306 goto err_alloc_dflt;
86307
86308 #ifdef CONFIG_SYSCTL
86309 - tbl = kmemdup(tbl, sizeof(ctl_forward_entry), GFP_KERNEL);
86310 + tbl = kmemdup(ctl_forward_entry, sizeof(ctl_forward_entry), GFP_KERNEL);
86311 if (tbl == NULL)
86312 goto err_alloc_ctl;
86313
86314 @@ -2148,7 +2148,10 @@ static __net_init int devinet_init_net(struct net *net)
86315 goto err_reg_dflt;
86316
86317 err = -ENOMEM;
86318 - forw_hdr = register_net_sysctl(net, "net/ipv4", tbl);
86319 + if (!net_eq(net, &init_net))
86320 + forw_hdr = register_net_sysctl(net, "net/ipv4", tbl);
86321 + else
86322 + forw_hdr = register_net_sysctl(net, "net/ipv4", ctl_forward_entry);
86323 if (forw_hdr == NULL)
86324 goto err_reg_ctl;
86325 net->ipv4.forw_hdr = forw_hdr;
86326 @@ -2164,8 +2167,7 @@ err_reg_ctl:
86327 err_reg_dflt:
86328 __devinet_sysctl_unregister(all);
86329 err_reg_all:
86330 - if (tbl != ctl_forward_entry)
86331 - kfree(tbl);
86332 + kfree(tbl);
86333 err_alloc_ctl:
86334 #endif
86335 if (dflt != &ipv4_devconf_dflt)
86336 diff --git a/net/ipv4/esp4.c b/net/ipv4/esp4.c
86337 index 4cfe34d..a6ba66e 100644
86338 --- a/net/ipv4/esp4.c
86339 +++ b/net/ipv4/esp4.c
86340 @@ -503,7 +503,7 @@ static void esp4_err(struct sk_buff *skb, u32 info)
86341 return;
86342
86343 if (icmp_hdr(skb)->type == ICMP_DEST_UNREACH) {
86344 - atomic_inc(&flow_cache_genid);
86345 + atomic_inc_unchecked(&flow_cache_genid);
86346 rt_genid_bump(net);
86347
86348 ipv4_update_pmtu(skb, net, info, 0, 0, IPPROTO_ESP, 0);
86349 diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
86350 index eb4bb12..ee4ec7d 100644
86351 --- a/net/ipv4/fib_frontend.c
86352 +++ b/net/ipv4/fib_frontend.c
86353 @@ -1017,12 +1017,12 @@ static int fib_inetaddr_event(struct notifier_block *this, unsigned long event,
86354 #ifdef CONFIG_IP_ROUTE_MULTIPATH
86355 fib_sync_up(dev);
86356 #endif
86357 - atomic_inc(&net->ipv4.dev_addr_genid);
86358 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
86359 rt_cache_flush(dev_net(dev));
86360 break;
86361 case NETDEV_DOWN:
86362 fib_del_ifaddr(ifa, NULL);
86363 - atomic_inc(&net->ipv4.dev_addr_genid);
86364 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
86365 if (ifa->ifa_dev->ifa_list == NULL) {
86366 /* Last address was deleted from this interface.
86367 * Disable IP.
86368 @@ -1058,7 +1058,7 @@ static int fib_netdev_event(struct notifier_block *this, unsigned long event, vo
86369 #ifdef CONFIG_IP_ROUTE_MULTIPATH
86370 fib_sync_up(dev);
86371 #endif
86372 - atomic_inc(&net->ipv4.dev_addr_genid);
86373 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
86374 rt_cache_flush(net);
86375 break;
86376 case NETDEV_DOWN:
86377 diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
86378 index 8f6cb7a..34507f9 100644
86379 --- a/net/ipv4/fib_semantics.c
86380 +++ b/net/ipv4/fib_semantics.c
86381 @@ -765,7 +765,7 @@ __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh)
86382 nh->nh_saddr = inet_select_addr(nh->nh_dev,
86383 nh->nh_gw,
86384 nh->nh_parent->fib_scope);
86385 - nh->nh_saddr_genid = atomic_read(&net->ipv4.dev_addr_genid);
86386 + nh->nh_saddr_genid = atomic_read_unchecked(&net->ipv4.dev_addr_genid);
86387
86388 return nh->nh_saddr;
86389 }
86390 diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c
86391 index 786d97a..1889c0d 100644
86392 --- a/net/ipv4/inet_connection_sock.c
86393 +++ b/net/ipv4/inet_connection_sock.c
86394 @@ -37,7 +37,7 @@ struct local_ports sysctl_local_ports __read_mostly = {
86395 .range = { 32768, 61000 },
86396 };
86397
86398 -unsigned long *sysctl_local_reserved_ports;
86399 +unsigned long sysctl_local_reserved_ports[65536 / 8 / sizeof(unsigned long)];
86400 EXPORT_SYMBOL(sysctl_local_reserved_ports);
86401
86402 void inet_get_local_port_range(int *low, int *high)
86403 diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c
86404 index 6af375a..c493c74 100644
86405 --- a/net/ipv4/inet_hashtables.c
86406 +++ b/net/ipv4/inet_hashtables.c
86407 @@ -18,12 +18,15 @@
86408 #include <linux/sched.h>
86409 #include <linux/slab.h>
86410 #include <linux/wait.h>
86411 +#include <linux/security.h>
86412
86413 #include <net/inet_connection_sock.h>
86414 #include <net/inet_hashtables.h>
86415 #include <net/secure_seq.h>
86416 #include <net/ip.h>
86417
86418 +extern void gr_update_task_in_ip_table(struct task_struct *task, const struct inet_sock *inet);
86419 +
86420 /*
86421 * Allocate and initialize a new local port bind bucket.
86422 * The bindhash mutex for snum's hash chain must be held here.
86423 @@ -554,6 +557,8 @@ ok:
86424 twrefcnt += inet_twsk_bind_unhash(tw, hinfo);
86425 spin_unlock(&head->lock);
86426
86427 + gr_update_task_in_ip_table(current, inet_sk(sk));
86428 +
86429 if (tw) {
86430 inet_twsk_deschedule(tw, death_row);
86431 while (twrefcnt) {
86432 diff --git a/net/ipv4/inetpeer.c b/net/ipv4/inetpeer.c
86433 index 000e3d2..5472da3 100644
86434 --- a/net/ipv4/inetpeer.c
86435 +++ b/net/ipv4/inetpeer.c
86436 @@ -503,8 +503,8 @@ relookup:
86437 if (p) {
86438 p->daddr = *daddr;
86439 atomic_set(&p->refcnt, 1);
86440 - atomic_set(&p->rid, 0);
86441 - atomic_set(&p->ip_id_count,
86442 + atomic_set_unchecked(&p->rid, 0);
86443 + atomic_set_unchecked(&p->ip_id_count,
86444 (daddr->family == AF_INET) ?
86445 secure_ip_id(daddr->addr.a4) :
86446 secure_ipv6_id(daddr->addr.a6));
86447 diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c
86448 index 52c273e..579060b 100644
86449 --- a/net/ipv4/ip_fragment.c
86450 +++ b/net/ipv4/ip_fragment.c
86451 @@ -311,7 +311,7 @@ static inline int ip_frag_too_far(struct ipq *qp)
86452 return 0;
86453
86454 start = qp->rid;
86455 - end = atomic_inc_return(&peer->rid);
86456 + end = atomic_inc_return_unchecked(&peer->rid);
86457 qp->rid = end;
86458
86459 rc = qp->q.fragments && (end - start) > max;
86460 @@ -788,12 +788,11 @@ static struct ctl_table ip4_frags_ctl_table[] = {
86461
86462 static int __net_init ip4_frags_ns_ctl_register(struct net *net)
86463 {
86464 - struct ctl_table *table;
86465 + ctl_table_no_const *table = NULL;
86466 struct ctl_table_header *hdr;
86467
86468 - table = ip4_frags_ns_ctl_table;
86469 if (!net_eq(net, &init_net)) {
86470 - table = kmemdup(table, sizeof(ip4_frags_ns_ctl_table), GFP_KERNEL);
86471 + table = kmemdup(ip4_frags_ns_ctl_table, sizeof(ip4_frags_ns_ctl_table), GFP_KERNEL);
86472 if (table == NULL)
86473 goto err_alloc;
86474
86475 @@ -804,9 +803,10 @@ static int __net_init ip4_frags_ns_ctl_register(struct net *net)
86476 /* Don't export sysctls to unprivileged users */
86477 if (net->user_ns != &init_user_ns)
86478 table[0].procname = NULL;
86479 - }
86480 + hdr = register_net_sysctl(net, "net/ipv4", table);
86481 + } else
86482 + hdr = register_net_sysctl(net, "net/ipv4", ip4_frags_ns_ctl_table);
86483
86484 - hdr = register_net_sysctl(net, "net/ipv4", table);
86485 if (hdr == NULL)
86486 goto err_reg;
86487
86488 @@ -814,8 +814,7 @@ static int __net_init ip4_frags_ns_ctl_register(struct net *net)
86489 return 0;
86490
86491 err_reg:
86492 - if (!net_eq(net, &init_net))
86493 - kfree(table);
86494 + kfree(table);
86495 err_alloc:
86496 return -ENOMEM;
86497 }
86498 diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
86499 index 91d66db..4af7d99 100644
86500 --- a/net/ipv4/ip_gre.c
86501 +++ b/net/ipv4/ip_gre.c
86502 @@ -124,7 +124,7 @@ static bool log_ecn_error = true;
86503 module_param(log_ecn_error, bool, 0644);
86504 MODULE_PARM_DESC(log_ecn_error, "Log packets received with corrupted ECN");
86505
86506 -static struct rtnl_link_ops ipgre_link_ops __read_mostly;
86507 +static struct rtnl_link_ops ipgre_link_ops;
86508 static int ipgre_tunnel_init(struct net_device *dev);
86509 static void ipgre_tunnel_setup(struct net_device *dev);
86510 static int ipgre_tunnel_bind_dev(struct net_device *dev);
86511 @@ -1823,7 +1823,7 @@ static const struct nla_policy ipgre_policy[IFLA_GRE_MAX + 1] = {
86512 [IFLA_GRE_PMTUDISC] = { .type = NLA_U8 },
86513 };
86514
86515 -static struct rtnl_link_ops ipgre_link_ops __read_mostly = {
86516 +static struct rtnl_link_ops ipgre_link_ops = {
86517 .kind = "gre",
86518 .maxtype = IFLA_GRE_MAX,
86519 .policy = ipgre_policy,
86520 @@ -1836,7 +1836,7 @@ static struct rtnl_link_ops ipgre_link_ops __read_mostly = {
86521 .fill_info = ipgre_fill_info,
86522 };
86523
86524 -static struct rtnl_link_ops ipgre_tap_ops __read_mostly = {
86525 +static struct rtnl_link_ops ipgre_tap_ops = {
86526 .kind = "gretap",
86527 .maxtype = IFLA_GRE_MAX,
86528 .policy = ipgre_policy,
86529 diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c
86530 index d9c4f11..02b82dbc 100644
86531 --- a/net/ipv4/ip_sockglue.c
86532 +++ b/net/ipv4/ip_sockglue.c
86533 @@ -1152,7 +1152,8 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
86534 len = min_t(unsigned int, len, opt->optlen);
86535 if (put_user(len, optlen))
86536 return -EFAULT;
86537 - if (copy_to_user(optval, opt->__data, len))
86538 + if ((len > (sizeof(optbuf) - sizeof(struct ip_options))) ||
86539 + copy_to_user(optval, opt->__data, len))
86540 return -EFAULT;
86541 return 0;
86542 }
86543 @@ -1283,7 +1284,7 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
86544 if (sk->sk_type != SOCK_STREAM)
86545 return -ENOPROTOOPT;
86546
86547 - msg.msg_control = optval;
86548 + msg.msg_control = (void __force_kernel *)optval;
86549 msg.msg_controllen = len;
86550 msg.msg_flags = flags;
86551
86552 diff --git a/net/ipv4/ip_vti.c b/net/ipv4/ip_vti.c
86553 index c3a4233..1412161 100644
86554 --- a/net/ipv4/ip_vti.c
86555 +++ b/net/ipv4/ip_vti.c
86556 @@ -47,7 +47,7 @@
86557 #define HASH_SIZE 16
86558 #define HASH(addr) (((__force u32)addr^((__force u32)addr>>4))&(HASH_SIZE-1))
86559
86560 -static struct rtnl_link_ops vti_link_ops __read_mostly;
86561 +static struct rtnl_link_ops vti_link_ops;
86562
86563 static int vti_net_id __read_mostly;
86564 struct vti_net {
86565 @@ -886,7 +886,7 @@ static const struct nla_policy vti_policy[IFLA_VTI_MAX + 1] = {
86566 [IFLA_VTI_REMOTE] = { .len = FIELD_SIZEOF(struct iphdr, daddr) },
86567 };
86568
86569 -static struct rtnl_link_ops vti_link_ops __read_mostly = {
86570 +static struct rtnl_link_ops vti_link_ops = {
86571 .kind = "vti",
86572 .maxtype = IFLA_VTI_MAX,
86573 .policy = vti_policy,
86574 diff --git a/net/ipv4/ipcomp.c b/net/ipv4/ipcomp.c
86575 index f01d1b1..8fe03ad 100644
86576 --- a/net/ipv4/ipcomp.c
86577 +++ b/net/ipv4/ipcomp.c
86578 @@ -48,7 +48,7 @@ static void ipcomp4_err(struct sk_buff *skb, u32 info)
86579 return;
86580
86581 if (icmp_hdr(skb)->type == ICMP_DEST_UNREACH) {
86582 - atomic_inc(&flow_cache_genid);
86583 + atomic_inc_unchecked(&flow_cache_genid);
86584 rt_genid_bump(net);
86585
86586 ipv4_update_pmtu(skb, net, info, 0, 0, IPPROTO_COMP, 0);
86587 diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c
86588 index bf6c5cf..ab2e9c6 100644
86589 --- a/net/ipv4/ipconfig.c
86590 +++ b/net/ipv4/ipconfig.c
86591 @@ -323,7 +323,7 @@ static int __init ic_devinet_ioctl(unsigned int cmd, struct ifreq *arg)
86592
86593 mm_segment_t oldfs = get_fs();
86594 set_fs(get_ds());
86595 - res = devinet_ioctl(&init_net, cmd, (struct ifreq __user *) arg);
86596 + res = devinet_ioctl(&init_net, cmd, (struct ifreq __force_user *) arg);
86597 set_fs(oldfs);
86598 return res;
86599 }
86600 @@ -334,7 +334,7 @@ static int __init ic_dev_ioctl(unsigned int cmd, struct ifreq *arg)
86601
86602 mm_segment_t oldfs = get_fs();
86603 set_fs(get_ds());
86604 - res = dev_ioctl(&init_net, cmd, (struct ifreq __user *) arg);
86605 + res = dev_ioctl(&init_net, cmd, (struct ifreq __force_user *) arg);
86606 set_fs(oldfs);
86607 return res;
86608 }
86609 @@ -345,7 +345,7 @@ static int __init ic_route_ioctl(unsigned int cmd, struct rtentry *arg)
86610
86611 mm_segment_t oldfs = get_fs();
86612 set_fs(get_ds());
86613 - res = ip_rt_ioctl(&init_net, cmd, (void __user *) arg);
86614 + res = ip_rt_ioctl(&init_net, cmd, (void __force_user *) arg);
86615 set_fs(oldfs);
86616 return res;
86617 }
86618 diff --git a/net/ipv4/ipip.c b/net/ipv4/ipip.c
86619 index 8f024d4..8b3500c 100644
86620 --- a/net/ipv4/ipip.c
86621 +++ b/net/ipv4/ipip.c
86622 @@ -138,7 +138,7 @@ struct ipip_net {
86623 static int ipip_tunnel_init(struct net_device *dev);
86624 static void ipip_tunnel_setup(struct net_device *dev);
86625 static void ipip_dev_free(struct net_device *dev);
86626 -static struct rtnl_link_ops ipip_link_ops __read_mostly;
86627 +static struct rtnl_link_ops ipip_link_ops;
86628
86629 static struct rtnl_link_stats64 *ipip_get_stats64(struct net_device *dev,
86630 struct rtnl_link_stats64 *tot)
86631 @@ -974,7 +974,7 @@ static const struct nla_policy ipip_policy[IFLA_IPTUN_MAX + 1] = {
86632 [IFLA_IPTUN_PMTUDISC] = { .type = NLA_U8 },
86633 };
86634
86635 -static struct rtnl_link_ops ipip_link_ops __read_mostly = {
86636 +static struct rtnl_link_ops ipip_link_ops = {
86637 .kind = "ipip",
86638 .maxtype = IFLA_IPTUN_MAX,
86639 .policy = ipip_policy,
86640 diff --git a/net/ipv4/netfilter/arp_tables.c b/net/ipv4/netfilter/arp_tables.c
86641 index 7dc6a97..229c61b 100644
86642 --- a/net/ipv4/netfilter/arp_tables.c
86643 +++ b/net/ipv4/netfilter/arp_tables.c
86644 @@ -879,14 +879,14 @@ static int compat_table_info(const struct xt_table_info *info,
86645 #endif
86646
86647 static int get_info(struct net *net, void __user *user,
86648 - const int *len, int compat)
86649 + int len, int compat)
86650 {
86651 char name[XT_TABLE_MAXNAMELEN];
86652 struct xt_table *t;
86653 int ret;
86654
86655 - if (*len != sizeof(struct arpt_getinfo)) {
86656 - duprintf("length %u != %Zu\n", *len,
86657 + if (len != sizeof(struct arpt_getinfo)) {
86658 + duprintf("length %u != %Zu\n", len,
86659 sizeof(struct arpt_getinfo));
86660 return -EINVAL;
86661 }
86662 @@ -923,7 +923,7 @@ static int get_info(struct net *net, void __user *user,
86663 info.size = private->size;
86664 strcpy(info.name, name);
86665
86666 - if (copy_to_user(user, &info, *len) != 0)
86667 + if (copy_to_user(user, &info, len) != 0)
86668 ret = -EFAULT;
86669 else
86670 ret = 0;
86671 @@ -1682,7 +1682,7 @@ static int compat_do_arpt_get_ctl(struct sock *sk, int cmd, void __user *user,
86672
86673 switch (cmd) {
86674 case ARPT_SO_GET_INFO:
86675 - ret = get_info(sock_net(sk), user, len, 1);
86676 + ret = get_info(sock_net(sk), user, *len, 1);
86677 break;
86678 case ARPT_SO_GET_ENTRIES:
86679 ret = compat_get_entries(sock_net(sk), user, len);
86680 @@ -1727,7 +1727,7 @@ static int do_arpt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len
86681
86682 switch (cmd) {
86683 case ARPT_SO_GET_INFO:
86684 - ret = get_info(sock_net(sk), user, len, 0);
86685 + ret = get_info(sock_net(sk), user, *len, 0);
86686 break;
86687
86688 case ARPT_SO_GET_ENTRIES:
86689 diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c
86690 index 3efcf87..5247916 100644
86691 --- a/net/ipv4/netfilter/ip_tables.c
86692 +++ b/net/ipv4/netfilter/ip_tables.c
86693 @@ -1068,14 +1068,14 @@ static int compat_table_info(const struct xt_table_info *info,
86694 #endif
86695
86696 static int get_info(struct net *net, void __user *user,
86697 - const int *len, int compat)
86698 + int len, int compat)
86699 {
86700 char name[XT_TABLE_MAXNAMELEN];
86701 struct xt_table *t;
86702 int ret;
86703
86704 - if (*len != sizeof(struct ipt_getinfo)) {
86705 - duprintf("length %u != %zu\n", *len,
86706 + if (len != sizeof(struct ipt_getinfo)) {
86707 + duprintf("length %u != %zu\n", len,
86708 sizeof(struct ipt_getinfo));
86709 return -EINVAL;
86710 }
86711 @@ -1112,7 +1112,7 @@ static int get_info(struct net *net, void __user *user,
86712 info.size = private->size;
86713 strcpy(info.name, name);
86714
86715 - if (copy_to_user(user, &info, *len) != 0)
86716 + if (copy_to_user(user, &info, len) != 0)
86717 ret = -EFAULT;
86718 else
86719 ret = 0;
86720 @@ -1966,7 +1966,7 @@ compat_do_ipt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
86721
86722 switch (cmd) {
86723 case IPT_SO_GET_INFO:
86724 - ret = get_info(sock_net(sk), user, len, 1);
86725 + ret = get_info(sock_net(sk), user, *len, 1);
86726 break;
86727 case IPT_SO_GET_ENTRIES:
86728 ret = compat_get_entries(sock_net(sk), user, len);
86729 @@ -2013,7 +2013,7 @@ do_ipt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
86730
86731 switch (cmd) {
86732 case IPT_SO_GET_INFO:
86733 - ret = get_info(sock_net(sk), user, len, 0);
86734 + ret = get_info(sock_net(sk), user, *len, 0);
86735 break;
86736
86737 case IPT_SO_GET_ENTRIES:
86738 diff --git a/net/ipv4/ping.c b/net/ipv4/ping.c
86739 index 2e91006..f084394 100644
86740 --- a/net/ipv4/ping.c
86741 +++ b/net/ipv4/ping.c
86742 @@ -844,7 +844,7 @@ static void ping_format_sock(struct sock *sp, struct seq_file *f,
86743 from_kuid_munged(seq_user_ns(f), sock_i_uid(sp)),
86744 0, sock_i_ino(sp),
86745 atomic_read(&sp->sk_refcnt), sp,
86746 - atomic_read(&sp->sk_drops), len);
86747 + atomic_read_unchecked(&sp->sk_drops), len);
86748 }
86749
86750 static int ping_seq_show(struct seq_file *seq, void *v)
86751 diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
86752 index dd44e0a..06dcca4 100644
86753 --- a/net/ipv4/raw.c
86754 +++ b/net/ipv4/raw.c
86755 @@ -309,7 +309,7 @@ static int raw_rcv_skb(struct sock *sk, struct sk_buff *skb)
86756 int raw_rcv(struct sock *sk, struct sk_buff *skb)
86757 {
86758 if (!xfrm4_policy_check(sk, XFRM_POLICY_IN, skb)) {
86759 - atomic_inc(&sk->sk_drops);
86760 + atomic_inc_unchecked(&sk->sk_drops);
86761 kfree_skb(skb);
86762 return NET_RX_DROP;
86763 }
86764 @@ -745,16 +745,20 @@ static int raw_init(struct sock *sk)
86765
86766 static int raw_seticmpfilter(struct sock *sk, char __user *optval, int optlen)
86767 {
86768 + struct icmp_filter filter;
86769 +
86770 if (optlen > sizeof(struct icmp_filter))
86771 optlen = sizeof(struct icmp_filter);
86772 - if (copy_from_user(&raw_sk(sk)->filter, optval, optlen))
86773 + if (copy_from_user(&filter, optval, optlen))
86774 return -EFAULT;
86775 + raw_sk(sk)->filter = filter;
86776 return 0;
86777 }
86778
86779 static int raw_geticmpfilter(struct sock *sk, char __user *optval, int __user *optlen)
86780 {
86781 int len, ret = -EFAULT;
86782 + struct icmp_filter filter;
86783
86784 if (get_user(len, optlen))
86785 goto out;
86786 @@ -764,8 +768,8 @@ static int raw_geticmpfilter(struct sock *sk, char __user *optval, int __user *o
86787 if (len > sizeof(struct icmp_filter))
86788 len = sizeof(struct icmp_filter);
86789 ret = -EFAULT;
86790 - if (put_user(len, optlen) ||
86791 - copy_to_user(optval, &raw_sk(sk)->filter, len))
86792 + filter = raw_sk(sk)->filter;
86793 + if (put_user(len, optlen) || len > sizeof filter || copy_to_user(optval, &filter, len))
86794 goto out;
86795 ret = 0;
86796 out: return ret;
86797 @@ -994,7 +998,7 @@ static void raw_sock_seq_show(struct seq_file *seq, struct sock *sp, int i)
86798 0, 0L, 0,
86799 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sp)),
86800 0, sock_i_ino(sp),
86801 - atomic_read(&sp->sk_refcnt), sp, atomic_read(&sp->sk_drops));
86802 + atomic_read(&sp->sk_refcnt), sp, atomic_read_unchecked(&sp->sk_drops));
86803 }
86804
86805 static int raw_seq_show(struct seq_file *seq, void *v)
86806 diff --git a/net/ipv4/route.c b/net/ipv4/route.c
86807 index 6e28514..5e1b055 100644
86808 --- a/net/ipv4/route.c
86809 +++ b/net/ipv4/route.c
86810 @@ -2553,34 +2553,34 @@ static struct ctl_table ipv4_route_flush_table[] = {
86811 .maxlen = sizeof(int),
86812 .mode = 0200,
86813 .proc_handler = ipv4_sysctl_rtcache_flush,
86814 + .extra1 = &init_net,
86815 },
86816 { },
86817 };
86818
86819 static __net_init int sysctl_route_net_init(struct net *net)
86820 {
86821 - struct ctl_table *tbl;
86822 + ctl_table_no_const *tbl = NULL;
86823
86824 - tbl = ipv4_route_flush_table;
86825 if (!net_eq(net, &init_net)) {
86826 - tbl = kmemdup(tbl, sizeof(ipv4_route_flush_table), GFP_KERNEL);
86827 + tbl = kmemdup(ipv4_route_flush_table, sizeof(ipv4_route_flush_table), GFP_KERNEL);
86828 if (tbl == NULL)
86829 goto err_dup;
86830
86831 /* Don't export sysctls to unprivileged users */
86832 if (net->user_ns != &init_user_ns)
86833 tbl[0].procname = NULL;
86834 - }
86835 - tbl[0].extra1 = net;
86836 + tbl[0].extra1 = net;
86837 + net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", tbl);
86838 + } else
86839 + net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", ipv4_route_flush_table);
86840
86841 - net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", tbl);
86842 if (net->ipv4.route_hdr == NULL)
86843 goto err_reg;
86844 return 0;
86845
86846 err_reg:
86847 - if (tbl != ipv4_route_flush_table)
86848 - kfree(tbl);
86849 + kfree(tbl);
86850 err_dup:
86851 return -ENOMEM;
86852 }
86853 @@ -2603,7 +2603,7 @@ static __net_initdata struct pernet_operations sysctl_route_ops = {
86854
86855 static __net_init int rt_genid_init(struct net *net)
86856 {
86857 - atomic_set(&net->rt_genid, 0);
86858 + atomic_set_unchecked(&net->rt_genid, 0);
86859 get_random_bytes(&net->ipv4.dev_addr_genid,
86860 sizeof(net->ipv4.dev_addr_genid));
86861 return 0;
86862 diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c
86863 index 960fd29..d55bf64 100644
86864 --- a/net/ipv4/sysctl_net_ipv4.c
86865 +++ b/net/ipv4/sysctl_net_ipv4.c
86866 @@ -55,7 +55,7 @@ static int ipv4_local_port_range(ctl_table *table, int write,
86867 {
86868 int ret;
86869 int range[2];
86870 - ctl_table tmp = {
86871 + ctl_table_no_const tmp = {
86872 .data = &range,
86873 .maxlen = sizeof(range),
86874 .mode = table->mode,
86875 @@ -108,7 +108,7 @@ static int ipv4_ping_group_range(ctl_table *table, int write,
86876 int ret;
86877 gid_t urange[2];
86878 kgid_t low, high;
86879 - ctl_table tmp = {
86880 + ctl_table_no_const tmp = {
86881 .data = &urange,
86882 .maxlen = sizeof(urange),
86883 .mode = table->mode,
86884 @@ -139,7 +139,7 @@ static int proc_tcp_congestion_control(ctl_table *ctl, int write,
86885 void __user *buffer, size_t *lenp, loff_t *ppos)
86886 {
86887 char val[TCP_CA_NAME_MAX];
86888 - ctl_table tbl = {
86889 + ctl_table_no_const tbl = {
86890 .data = val,
86891 .maxlen = TCP_CA_NAME_MAX,
86892 };
86893 @@ -158,7 +158,7 @@ static int proc_tcp_available_congestion_control(ctl_table *ctl,
86894 void __user *buffer, size_t *lenp,
86895 loff_t *ppos)
86896 {
86897 - ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX, };
86898 + ctl_table_no_const tbl = { .maxlen = TCP_CA_BUF_MAX, };
86899 int ret;
86900
86901 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
86902 @@ -175,7 +175,7 @@ static int proc_allowed_congestion_control(ctl_table *ctl,
86903 void __user *buffer, size_t *lenp,
86904 loff_t *ppos)
86905 {
86906 - ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX };
86907 + ctl_table_no_const tbl = { .maxlen = TCP_CA_BUF_MAX };
86908 int ret;
86909
86910 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
86911 @@ -201,15 +201,17 @@ static int ipv4_tcp_mem(ctl_table *ctl, int write,
86912 struct mem_cgroup *memcg;
86913 #endif
86914
86915 - ctl_table tmp = {
86916 + ctl_table_no_const tmp = {
86917 .data = &vec,
86918 .maxlen = sizeof(vec),
86919 .mode = ctl->mode,
86920 };
86921
86922 if (!write) {
86923 - ctl->data = &net->ipv4.sysctl_tcp_mem;
86924 - return proc_doulongvec_minmax(ctl, write, buffer, lenp, ppos);
86925 + ctl_table_no_const tcp_mem = *ctl;
86926 +
86927 + tcp_mem.data = &net->ipv4.sysctl_tcp_mem;
86928 + return proc_doulongvec_minmax(&tcp_mem, write, buffer, lenp, ppos);
86929 }
86930
86931 ret = proc_doulongvec_minmax(&tmp, write, buffer, lenp, ppos);
86932 @@ -236,7 +238,7 @@ static int ipv4_tcp_mem(ctl_table *ctl, int write,
86933 static int proc_tcp_fastopen_key(ctl_table *ctl, int write, void __user *buffer,
86934 size_t *lenp, loff_t *ppos)
86935 {
86936 - ctl_table tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) };
86937 + ctl_table_no_const tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) };
86938 struct tcp_fastopen_context *ctxt;
86939 int ret;
86940 u32 user_key[4]; /* 16 bytes, matching TCP_FASTOPEN_KEY_LENGTH */
86941 @@ -477,7 +479,7 @@ static struct ctl_table ipv4_table[] = {
86942 },
86943 {
86944 .procname = "ip_local_reserved_ports",
86945 - .data = NULL, /* initialized in sysctl_ipv4_init */
86946 + .data = sysctl_local_reserved_ports,
86947 .maxlen = 65536,
86948 .mode = 0644,
86949 .proc_handler = proc_do_large_bitmap,
86950 @@ -856,11 +858,10 @@ static struct ctl_table ipv4_net_table[] = {
86951
86952 static __net_init int ipv4_sysctl_init_net(struct net *net)
86953 {
86954 - struct ctl_table *table;
86955 + ctl_table_no_const *table = NULL;
86956
86957 - table = ipv4_net_table;
86958 if (!net_eq(net, &init_net)) {
86959 - table = kmemdup(table, sizeof(ipv4_net_table), GFP_KERNEL);
86960 + table = kmemdup(ipv4_net_table, sizeof(ipv4_net_table), GFP_KERNEL);
86961 if (table == NULL)
86962 goto err_alloc;
86963
86964 @@ -895,15 +896,17 @@ static __net_init int ipv4_sysctl_init_net(struct net *net)
86965
86966 tcp_init_mem(net);
86967
86968 - net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
86969 + if (!net_eq(net, &init_net))
86970 + net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
86971 + else
86972 + net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", ipv4_net_table);
86973 if (net->ipv4.ipv4_hdr == NULL)
86974 goto err_reg;
86975
86976 return 0;
86977
86978 err_reg:
86979 - if (!net_eq(net, &init_net))
86980 - kfree(table);
86981 + kfree(table);
86982 err_alloc:
86983 return -ENOMEM;
86984 }
86985 @@ -925,16 +928,6 @@ static __net_initdata struct pernet_operations ipv4_sysctl_ops = {
86986 static __init int sysctl_ipv4_init(void)
86987 {
86988 struct ctl_table_header *hdr;
86989 - struct ctl_table *i;
86990 -
86991 - for (i = ipv4_table; i->procname; i++) {
86992 - if (strcmp(i->procname, "ip_local_reserved_ports") == 0) {
86993 - i->data = sysctl_local_reserved_ports;
86994 - break;
86995 - }
86996 - }
86997 - if (!i->procname)
86998 - return -EINVAL;
86999
87000 hdr = register_net_sysctl(&init_net, "net/ipv4", ipv4_table);
87001 if (hdr == NULL)
87002 diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
87003 index e220207..cdeb839 100644
87004 --- a/net/ipv4/tcp.c
87005 +++ b/net/ipv4/tcp.c
87006 @@ -3383,8 +3383,11 @@ int tcp_md5_hash_skb_data(struct tcp_md5sig_pool *hp,
87007
87008 for (i = 0; i < shi->nr_frags; ++i) {
87009 const struct skb_frag_struct *f = &shi->frags[i];
87010 - struct page *page = skb_frag_page(f);
87011 - sg_set_page(&sg, page, skb_frag_size(f), f->page_offset);
87012 + unsigned int offset = f->page_offset;
87013 + struct page *page = skb_frag_page(f) + (offset >> PAGE_SHIFT);
87014 +
87015 + sg_set_page(&sg, page, skb_frag_size(f),
87016 + offset_in_page(offset));
87017 if (crypto_hash_update(desc, &sg, skb_frag_size(f)))
87018 return 1;
87019 }
87020 diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
87021 index 13b9c08..d33a8d0 100644
87022 --- a/net/ipv4/tcp_input.c
87023 +++ b/net/ipv4/tcp_input.c
87024 @@ -4724,7 +4724,7 @@ static struct sk_buff *tcp_collapse_one(struct sock *sk, struct sk_buff *skb,
87025 * simplifies code)
87026 */
87027 static void
87028 -tcp_collapse(struct sock *sk, struct sk_buff_head *list,
87029 +__intentional_overflow(5,6) tcp_collapse(struct sock *sk, struct sk_buff_head *list,
87030 struct sk_buff *head, struct sk_buff *tail,
87031 u32 start, u32 end)
87032 {
87033 @@ -5838,6 +5838,7 @@ discard:
87034 tcp_paws_reject(&tp->rx_opt, 0))
87035 goto discard_and_undo;
87036
87037 +#ifndef CONFIG_GRKERNSEC_NO_SIMULT_CONNECT
87038 if (th->syn) {
87039 /* We see SYN without ACK. It is attempt of
87040 * simultaneous connect with crossed SYNs.
87041 @@ -5888,6 +5889,7 @@ discard:
87042 goto discard;
87043 #endif
87044 }
87045 +#endif
87046 /* "fifth, if neither of the SYN or RST bits is set then
87047 * drop the segment and return."
87048 */
87049 @@ -5932,7 +5934,7 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
87050 goto discard;
87051
87052 if (th->syn) {
87053 - if (th->fin)
87054 + if (th->fin || th->urg || th->psh)
87055 goto discard;
87056 if (icsk->icsk_af_ops->conn_request(sk, skb) < 0)
87057 return 1;
87058 diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
87059 index d09203c..fd5cc91 100644
87060 --- a/net/ipv4/tcp_ipv4.c
87061 +++ b/net/ipv4/tcp_ipv4.c
87062 @@ -90,6 +90,10 @@ int sysctl_tcp_low_latency __read_mostly;
87063 EXPORT_SYMBOL(sysctl_tcp_low_latency);
87064
87065
87066 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87067 +extern int grsec_enable_blackhole;
87068 +#endif
87069 +
87070 #ifdef CONFIG_TCP_MD5SIG
87071 static int tcp_v4_md5_hash_hdr(char *md5_hash, const struct tcp_md5sig_key *key,
87072 __be32 daddr, __be32 saddr, const struct tcphdr *th);
87073 @@ -1897,6 +1901,9 @@ int tcp_v4_do_rcv(struct sock *sk, struct sk_buff *skb)
87074 return 0;
87075
87076 reset:
87077 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87078 + if (!grsec_enable_blackhole)
87079 +#endif
87080 tcp_v4_send_reset(rsk, skb);
87081 discard:
87082 kfree_skb(skb);
87083 @@ -1996,12 +2003,19 @@ int tcp_v4_rcv(struct sk_buff *skb)
87084 TCP_SKB_CB(skb)->sacked = 0;
87085
87086 sk = __inet_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest);
87087 - if (!sk)
87088 + if (!sk) {
87089 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87090 + ret = 1;
87091 +#endif
87092 goto no_tcp_socket;
87093 -
87094 + }
87095 process:
87096 - if (sk->sk_state == TCP_TIME_WAIT)
87097 + if (sk->sk_state == TCP_TIME_WAIT) {
87098 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87099 + ret = 2;
87100 +#endif
87101 goto do_time_wait;
87102 + }
87103
87104 if (unlikely(iph->ttl < inet_sk(sk)->min_ttl)) {
87105 NET_INC_STATS_BH(net, LINUX_MIB_TCPMINTTLDROP);
87106 @@ -2052,6 +2066,10 @@ no_tcp_socket:
87107 bad_packet:
87108 TCP_INC_STATS_BH(net, TCP_MIB_INERRS);
87109 } else {
87110 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87111 + if (!grsec_enable_blackhole || (ret == 1 &&
87112 + (skb->dev->flags & IFF_LOOPBACK)))
87113 +#endif
87114 tcp_v4_send_reset(NULL, skb);
87115 }
87116
87117 diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c
87118 index 2f672e7..b8895e9 100644
87119 --- a/net/ipv4/tcp_minisocks.c
87120 +++ b/net/ipv4/tcp_minisocks.c
87121 @@ -27,6 +27,10 @@
87122 #include <net/inet_common.h>
87123 #include <net/xfrm.h>
87124
87125 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87126 +extern int grsec_enable_blackhole;
87127 +#endif
87128 +
87129 int sysctl_tcp_syncookies __read_mostly = 1;
87130 EXPORT_SYMBOL(sysctl_tcp_syncookies);
87131
87132 @@ -749,7 +753,10 @@ embryonic_reset:
87133 * avoid becoming vulnerable to outside attack aiming at
87134 * resetting legit local connections.
87135 */
87136 - req->rsk_ops->send_reset(sk, skb);
87137 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87138 + if (!grsec_enable_blackhole)
87139 +#endif
87140 + req->rsk_ops->send_reset(sk, skb);
87141 } else if (fastopen) { /* received a valid RST pkt */
87142 reqsk_fastopen_remove(sk, req, true);
87143 tcp_reset(sk);
87144 diff --git a/net/ipv4/tcp_probe.c b/net/ipv4/tcp_probe.c
87145 index d4943f6..e7a74a5 100644
87146 --- a/net/ipv4/tcp_probe.c
87147 +++ b/net/ipv4/tcp_probe.c
87148 @@ -204,7 +204,7 @@ static ssize_t tcpprobe_read(struct file *file, char __user *buf,
87149 if (cnt + width >= len)
87150 break;
87151
87152 - if (copy_to_user(buf + cnt, tbuf, width))
87153 + if (width > sizeof tbuf || copy_to_user(buf + cnt, tbuf, width))
87154 return -EFAULT;
87155 cnt += width;
87156 }
87157 diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c
87158 index b78aac3..e18230b 100644
87159 --- a/net/ipv4/tcp_timer.c
87160 +++ b/net/ipv4/tcp_timer.c
87161 @@ -22,6 +22,10 @@
87162 #include <linux/gfp.h>
87163 #include <net/tcp.h>
87164
87165 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87166 +extern int grsec_lastack_retries;
87167 +#endif
87168 +
87169 int sysctl_tcp_syn_retries __read_mostly = TCP_SYN_RETRIES;
87170 int sysctl_tcp_synack_retries __read_mostly = TCP_SYNACK_RETRIES;
87171 int sysctl_tcp_keepalive_time __read_mostly = TCP_KEEPALIVE_TIME;
87172 @@ -185,6 +189,13 @@ static int tcp_write_timeout(struct sock *sk)
87173 }
87174 }
87175
87176 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87177 + if ((sk->sk_state == TCP_LAST_ACK) &&
87178 + (grsec_lastack_retries > 0) &&
87179 + (grsec_lastack_retries < retry_until))
87180 + retry_until = grsec_lastack_retries;
87181 +#endif
87182 +
87183 if (retransmits_timed_out(sk, retry_until,
87184 syn_set ? 0 : icsk->icsk_user_timeout, syn_set)) {
87185 /* Has it gone just too far? */
87186 diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
87187 index 0a073a2..ddf6279 100644
87188 --- a/net/ipv4/udp.c
87189 +++ b/net/ipv4/udp.c
87190 @@ -87,6 +87,7 @@
87191 #include <linux/types.h>
87192 #include <linux/fcntl.h>
87193 #include <linux/module.h>
87194 +#include <linux/security.h>
87195 #include <linux/socket.h>
87196 #include <linux/sockios.h>
87197 #include <linux/igmp.h>
87198 @@ -111,6 +112,10 @@
87199 #include <trace/events/skb.h>
87200 #include "udp_impl.h"
87201
87202 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87203 +extern int grsec_enable_blackhole;
87204 +#endif
87205 +
87206 struct udp_table udp_table __read_mostly;
87207 EXPORT_SYMBOL(udp_table);
87208
87209 @@ -594,6 +599,9 @@ found:
87210 return s;
87211 }
87212
87213 +extern int gr_search_udp_recvmsg(struct sock *sk, const struct sk_buff *skb);
87214 +extern int gr_search_udp_sendmsg(struct sock *sk, struct sockaddr_in *addr);
87215 +
87216 /*
87217 * This routine is called by the ICMP module when it gets some
87218 * sort of error condition. If err < 0 then the socket should
87219 @@ -889,9 +897,18 @@ int udp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
87220 dport = usin->sin_port;
87221 if (dport == 0)
87222 return -EINVAL;
87223 +
87224 + err = gr_search_udp_sendmsg(sk, usin);
87225 + if (err)
87226 + return err;
87227 } else {
87228 if (sk->sk_state != TCP_ESTABLISHED)
87229 return -EDESTADDRREQ;
87230 +
87231 + err = gr_search_udp_sendmsg(sk, NULL);
87232 + if (err)
87233 + return err;
87234 +
87235 daddr = inet->inet_daddr;
87236 dport = inet->inet_dport;
87237 /* Open fast path for connected socket.
87238 @@ -1133,7 +1150,7 @@ static unsigned int first_packet_length(struct sock *sk)
87239 udp_lib_checksum_complete(skb)) {
87240 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
87241 IS_UDPLITE(sk));
87242 - atomic_inc(&sk->sk_drops);
87243 + atomic_inc_unchecked(&sk->sk_drops);
87244 __skb_unlink(skb, rcvq);
87245 __skb_queue_tail(&list_kill, skb);
87246 }
87247 @@ -1219,6 +1236,10 @@ try_again:
87248 if (!skb)
87249 goto out;
87250
87251 + err = gr_search_udp_recvmsg(sk, skb);
87252 + if (err)
87253 + goto out_free;
87254 +
87255 ulen = skb->len - sizeof(struct udphdr);
87256 copied = len;
87257 if (copied > ulen)
87258 @@ -1252,7 +1273,7 @@ try_again:
87259 if (unlikely(err)) {
87260 trace_kfree_skb(skb, udp_recvmsg);
87261 if (!peeked) {
87262 - atomic_inc(&sk->sk_drops);
87263 + atomic_inc_unchecked(&sk->sk_drops);
87264 UDP_INC_STATS_USER(sock_net(sk),
87265 UDP_MIB_INERRORS, is_udplite);
87266 }
87267 @@ -1535,7 +1556,7 @@ int udp_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
87268
87269 drop:
87270 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
87271 - atomic_inc(&sk->sk_drops);
87272 + atomic_inc_unchecked(&sk->sk_drops);
87273 kfree_skb(skb);
87274 return -1;
87275 }
87276 @@ -1554,7 +1575,7 @@ static void flush_stack(struct sock **stack, unsigned int count,
87277 skb1 = (i == final) ? skb : skb_clone(skb, GFP_ATOMIC);
87278
87279 if (!skb1) {
87280 - atomic_inc(&sk->sk_drops);
87281 + atomic_inc_unchecked(&sk->sk_drops);
87282 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_RCVBUFERRORS,
87283 IS_UDPLITE(sk));
87284 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
87285 @@ -1723,6 +1744,9 @@ int __udp4_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
87286 goto csum_error;
87287
87288 UDP_INC_STATS_BH(net, UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE);
87289 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87290 + if (!grsec_enable_blackhole || (skb->dev->flags & IFF_LOOPBACK))
87291 +#endif
87292 icmp_send(skb, ICMP_DEST_UNREACH, ICMP_PORT_UNREACH, 0);
87293
87294 /*
87295 @@ -2152,7 +2176,7 @@ static void udp4_format_sock(struct sock *sp, struct seq_file *f,
87296 from_kuid_munged(seq_user_ns(f), sock_i_uid(sp)),
87297 0, sock_i_ino(sp),
87298 atomic_read(&sp->sk_refcnt), sp,
87299 - atomic_read(&sp->sk_drops), len);
87300 + atomic_read_unchecked(&sp->sk_drops), len);
87301 }
87302
87303 int udp4_seq_show(struct seq_file *seq, void *v)
87304 diff --git a/net/ipv4/xfrm4_policy.c b/net/ipv4/xfrm4_policy.c
87305 index 9a459be..086b866 100644
87306 --- a/net/ipv4/xfrm4_policy.c
87307 +++ b/net/ipv4/xfrm4_policy.c
87308 @@ -264,19 +264,18 @@ static struct ctl_table xfrm4_policy_table[] = {
87309
87310 static int __net_init xfrm4_net_init(struct net *net)
87311 {
87312 - struct ctl_table *table;
87313 + ctl_table_no_const *table = NULL;
87314 struct ctl_table_header *hdr;
87315
87316 - table = xfrm4_policy_table;
87317 if (!net_eq(net, &init_net)) {
87318 - table = kmemdup(table, sizeof(xfrm4_policy_table), GFP_KERNEL);
87319 + table = kmemdup(xfrm4_policy_table, sizeof(xfrm4_policy_table), GFP_KERNEL);
87320 if (!table)
87321 goto err_alloc;
87322
87323 table[0].data = &net->xfrm.xfrm4_dst_ops.gc_thresh;
87324 - }
87325 -
87326 - hdr = register_net_sysctl(net, "net/ipv4", table);
87327 + hdr = register_net_sysctl(net, "net/ipv4", table);
87328 + } else
87329 + hdr = register_net_sysctl(net, "net/ipv4", xfrm4_policy_table);
87330 if (!hdr)
87331 goto err_reg;
87332
87333 @@ -284,8 +283,7 @@ static int __net_init xfrm4_net_init(struct net *net)
87334 return 0;
87335
87336 err_reg:
87337 - if (!net_eq(net, &init_net))
87338 - kfree(table);
87339 + kfree(table);
87340 err_alloc:
87341 return -ENOMEM;
87342 }
87343 diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
87344 index dae802c..bfa4baa 100644
87345 --- a/net/ipv6/addrconf.c
87346 +++ b/net/ipv6/addrconf.c
87347 @@ -2274,7 +2274,7 @@ int addrconf_set_dstaddr(struct net *net, void __user *arg)
87348 p.iph.ihl = 5;
87349 p.iph.protocol = IPPROTO_IPV6;
87350 p.iph.ttl = 64;
87351 - ifr.ifr_ifru.ifru_data = (__force void __user *)&p;
87352 + ifr.ifr_ifru.ifru_data = (void __force_user *)&p;
87353
87354 if (ops->ndo_do_ioctl) {
87355 mm_segment_t oldfs = get_fs();
87356 @@ -4410,7 +4410,7 @@ int addrconf_sysctl_forward(ctl_table *ctl, int write,
87357 int *valp = ctl->data;
87358 int val = *valp;
87359 loff_t pos = *ppos;
87360 - ctl_table lctl;
87361 + ctl_table_no_const lctl;
87362 int ret;
87363
87364 /*
87365 @@ -4492,7 +4492,7 @@ int addrconf_sysctl_disable(ctl_table *ctl, int write,
87366 int *valp = ctl->data;
87367 int val = *valp;
87368 loff_t pos = *ppos;
87369 - ctl_table lctl;
87370 + ctl_table_no_const lctl;
87371 int ret;
87372
87373 /*
87374 diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c
87375 index fff5bdd..15194fb 100644
87376 --- a/net/ipv6/icmp.c
87377 +++ b/net/ipv6/icmp.c
87378 @@ -973,7 +973,7 @@ ctl_table ipv6_icmp_table_template[] = {
87379
87380 struct ctl_table * __net_init ipv6_icmp_sysctl_init(struct net *net)
87381 {
87382 - struct ctl_table *table;
87383 + ctl_table_no_const *table;
87384
87385 table = kmemdup(ipv6_icmp_table_template,
87386 sizeof(ipv6_icmp_table_template),
87387 diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
87388 index 95d13c7..791fe2f 100644
87389 --- a/net/ipv6/ip6_gre.c
87390 +++ b/net/ipv6/ip6_gre.c
87391 @@ -73,7 +73,7 @@ struct ip6gre_net {
87392 struct net_device *fb_tunnel_dev;
87393 };
87394
87395 -static struct rtnl_link_ops ip6gre_link_ops __read_mostly;
87396 +static struct rtnl_link_ops ip6gre_link_ops;
87397 static int ip6gre_tunnel_init(struct net_device *dev);
87398 static void ip6gre_tunnel_setup(struct net_device *dev);
87399 static void ip6gre_tunnel_link(struct ip6gre_net *ign, struct ip6_tnl *t);
87400 @@ -1337,7 +1337,7 @@ static void ip6gre_fb_tunnel_init(struct net_device *dev)
87401 }
87402
87403
87404 -static struct inet6_protocol ip6gre_protocol __read_mostly = {
87405 +static struct inet6_protocol ip6gre_protocol = {
87406 .handler = ip6gre_rcv,
87407 .err_handler = ip6gre_err,
87408 .flags = INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL,
87409 @@ -1671,7 +1671,7 @@ static const struct nla_policy ip6gre_policy[IFLA_GRE_MAX + 1] = {
87410 [IFLA_GRE_FLAGS] = { .type = NLA_U32 },
87411 };
87412
87413 -static struct rtnl_link_ops ip6gre_link_ops __read_mostly = {
87414 +static struct rtnl_link_ops ip6gre_link_ops = {
87415 .kind = "ip6gre",
87416 .maxtype = IFLA_GRE_MAX,
87417 .policy = ip6gre_policy,
87418 @@ -1684,7 +1684,7 @@ static struct rtnl_link_ops ip6gre_link_ops __read_mostly = {
87419 .fill_info = ip6gre_fill_info,
87420 };
87421
87422 -static struct rtnl_link_ops ip6gre_tap_ops __read_mostly = {
87423 +static struct rtnl_link_ops ip6gre_tap_ops = {
87424 .kind = "ip6gretap",
87425 .maxtype = IFLA_GRE_MAX,
87426 .policy = ip6gre_policy,
87427 diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
87428 index 155eccf..851fdae 100644
87429 --- a/net/ipv6/ip6_output.c
87430 +++ b/net/ipv6/ip6_output.c
87431 @@ -1147,7 +1147,7 @@ int ip6_append_data(struct sock *sk, int getfrag(void *from, char *to,
87432 if (WARN_ON(np->cork.opt))
87433 return -EINVAL;
87434
87435 - np->cork.opt = kmalloc(opt->tot_len, sk->sk_allocation);
87436 + np->cork.opt = kzalloc(opt->tot_len, sk->sk_allocation);
87437 if (unlikely(np->cork.opt == NULL))
87438 return -ENOBUFS;
87439
87440 diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
87441 index fff83cb..82d49dd 100644
87442 --- a/net/ipv6/ip6_tunnel.c
87443 +++ b/net/ipv6/ip6_tunnel.c
87444 @@ -87,7 +87,7 @@ static u32 HASH(const struct in6_addr *addr1, const struct in6_addr *addr2)
87445
87446 static int ip6_tnl_dev_init(struct net_device *dev);
87447 static void ip6_tnl_dev_setup(struct net_device *dev);
87448 -static struct rtnl_link_ops ip6_link_ops __read_mostly;
87449 +static struct rtnl_link_ops ip6_link_ops;
87450
87451 static int ip6_tnl_net_id __read_mostly;
87452 struct ip6_tnl_net {
87453 @@ -1684,7 +1684,7 @@ static const struct nla_policy ip6_tnl_policy[IFLA_IPTUN_MAX + 1] = {
87454 [IFLA_IPTUN_PROTO] = { .type = NLA_U8 },
87455 };
87456
87457 -static struct rtnl_link_ops ip6_link_ops __read_mostly = {
87458 +static struct rtnl_link_ops ip6_link_ops = {
87459 .kind = "ip6tnl",
87460 .maxtype = IFLA_IPTUN_MAX,
87461 .policy = ip6_tnl_policy,
87462 diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
87463 index d1e2e8e..51c19ae 100644
87464 --- a/net/ipv6/ipv6_sockglue.c
87465 +++ b/net/ipv6/ipv6_sockglue.c
87466 @@ -991,7 +991,7 @@ static int do_ipv6_getsockopt(struct sock *sk, int level, int optname,
87467 if (sk->sk_type != SOCK_STREAM)
87468 return -ENOPROTOOPT;
87469
87470 - msg.msg_control = optval;
87471 + msg.msg_control = (void __force_kernel *)optval;
87472 msg.msg_controllen = len;
87473 msg.msg_flags = flags;
87474
87475 diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c
87476 index 341b54a..591e8ed 100644
87477 --- a/net/ipv6/netfilter/ip6_tables.c
87478 +++ b/net/ipv6/netfilter/ip6_tables.c
87479 @@ -1076,14 +1076,14 @@ static int compat_table_info(const struct xt_table_info *info,
87480 #endif
87481
87482 static int get_info(struct net *net, void __user *user,
87483 - const int *len, int compat)
87484 + int len, int compat)
87485 {
87486 char name[XT_TABLE_MAXNAMELEN];
87487 struct xt_table *t;
87488 int ret;
87489
87490 - if (*len != sizeof(struct ip6t_getinfo)) {
87491 - duprintf("length %u != %zu\n", *len,
87492 + if (len != sizeof(struct ip6t_getinfo)) {
87493 + duprintf("length %u != %zu\n", len,
87494 sizeof(struct ip6t_getinfo));
87495 return -EINVAL;
87496 }
87497 @@ -1120,7 +1120,7 @@ static int get_info(struct net *net, void __user *user,
87498 info.size = private->size;
87499 strcpy(info.name, name);
87500
87501 - if (copy_to_user(user, &info, *len) != 0)
87502 + if (copy_to_user(user, &info, len) != 0)
87503 ret = -EFAULT;
87504 else
87505 ret = 0;
87506 @@ -1974,7 +1974,7 @@ compat_do_ip6t_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
87507
87508 switch (cmd) {
87509 case IP6T_SO_GET_INFO:
87510 - ret = get_info(sock_net(sk), user, len, 1);
87511 + ret = get_info(sock_net(sk), user, *len, 1);
87512 break;
87513 case IP6T_SO_GET_ENTRIES:
87514 ret = compat_get_entries(sock_net(sk), user, len);
87515 @@ -2021,7 +2021,7 @@ do_ip6t_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
87516
87517 switch (cmd) {
87518 case IP6T_SO_GET_INFO:
87519 - ret = get_info(sock_net(sk), user, len, 0);
87520 + ret = get_info(sock_net(sk), user, *len, 0);
87521 break;
87522
87523 case IP6T_SO_GET_ENTRIES:
87524 diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c b/net/ipv6/netfilter/nf_conntrack_reasm.c
87525 index 6700069..1e50f42 100644
87526 --- a/net/ipv6/netfilter/nf_conntrack_reasm.c
87527 +++ b/net/ipv6/netfilter/nf_conntrack_reasm.c
87528 @@ -89,12 +89,11 @@ static struct ctl_table nf_ct_frag6_sysctl_table[] = {
87529
87530 static int nf_ct_frag6_sysctl_register(struct net *net)
87531 {
87532 - struct ctl_table *table;
87533 + ctl_table_no_const *table = NULL;
87534 struct ctl_table_header *hdr;
87535
87536 - table = nf_ct_frag6_sysctl_table;
87537 if (!net_eq(net, &init_net)) {
87538 - table = kmemdup(table, sizeof(nf_ct_frag6_sysctl_table),
87539 + table = kmemdup(nf_ct_frag6_sysctl_table, sizeof(nf_ct_frag6_sysctl_table),
87540 GFP_KERNEL);
87541 if (table == NULL)
87542 goto err_alloc;
87543 @@ -102,9 +101,9 @@ static int nf_ct_frag6_sysctl_register(struct net *net)
87544 table[0].data = &net->nf_frag.frags.timeout;
87545 table[1].data = &net->nf_frag.frags.low_thresh;
87546 table[2].data = &net->nf_frag.frags.high_thresh;
87547 - }
87548 -
87549 - hdr = register_net_sysctl(net, "net/netfilter", table);
87550 + hdr = register_net_sysctl(net, "net/netfilter", table);
87551 + } else
87552 + hdr = register_net_sysctl(net, "net/netfilter", nf_ct_frag6_sysctl_table);
87553 if (hdr == NULL)
87554 goto err_reg;
87555
87556 @@ -112,8 +111,7 @@ static int nf_ct_frag6_sysctl_register(struct net *net)
87557 return 0;
87558
87559 err_reg:
87560 - if (!net_eq(net, &init_net))
87561 - kfree(table);
87562 + kfree(table);
87563 err_alloc:
87564 return -ENOMEM;
87565 }
87566 diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c
87567 index 330b5e7..796fbf1 100644
87568 --- a/net/ipv6/raw.c
87569 +++ b/net/ipv6/raw.c
87570 @@ -378,7 +378,7 @@ static inline int rawv6_rcv_skb(struct sock *sk, struct sk_buff *skb)
87571 {
87572 if ((raw6_sk(sk)->checksum || rcu_access_pointer(sk->sk_filter)) &&
87573 skb_checksum_complete(skb)) {
87574 - atomic_inc(&sk->sk_drops);
87575 + atomic_inc_unchecked(&sk->sk_drops);
87576 kfree_skb(skb);
87577 return NET_RX_DROP;
87578 }
87579 @@ -406,7 +406,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
87580 struct raw6_sock *rp = raw6_sk(sk);
87581
87582 if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb)) {
87583 - atomic_inc(&sk->sk_drops);
87584 + atomic_inc_unchecked(&sk->sk_drops);
87585 kfree_skb(skb);
87586 return NET_RX_DROP;
87587 }
87588 @@ -430,7 +430,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
87589
87590 if (inet->hdrincl) {
87591 if (skb_checksum_complete(skb)) {
87592 - atomic_inc(&sk->sk_drops);
87593 + atomic_inc_unchecked(&sk->sk_drops);
87594 kfree_skb(skb);
87595 return NET_RX_DROP;
87596 }
87597 @@ -603,7 +603,7 @@ out:
87598 return err;
87599 }
87600
87601 -static int rawv6_send_hdrinc(struct sock *sk, void *from, int length,
87602 +static int rawv6_send_hdrinc(struct sock *sk, void *from, unsigned int length,
87603 struct flowi6 *fl6, struct dst_entry **dstp,
87604 unsigned int flags)
87605 {
87606 @@ -915,12 +915,15 @@ do_confirm:
87607 static int rawv6_seticmpfilter(struct sock *sk, int level, int optname,
87608 char __user *optval, int optlen)
87609 {
87610 + struct icmp6_filter filter;
87611 +
87612 switch (optname) {
87613 case ICMPV6_FILTER:
87614 if (optlen > sizeof(struct icmp6_filter))
87615 optlen = sizeof(struct icmp6_filter);
87616 - if (copy_from_user(&raw6_sk(sk)->filter, optval, optlen))
87617 + if (copy_from_user(&filter, optval, optlen))
87618 return -EFAULT;
87619 + raw6_sk(sk)->filter = filter;
87620 return 0;
87621 default:
87622 return -ENOPROTOOPT;
87623 @@ -933,6 +936,7 @@ static int rawv6_geticmpfilter(struct sock *sk, int level, int optname,
87624 char __user *optval, int __user *optlen)
87625 {
87626 int len;
87627 + struct icmp6_filter filter;
87628
87629 switch (optname) {
87630 case ICMPV6_FILTER:
87631 @@ -944,7 +948,8 @@ static int rawv6_geticmpfilter(struct sock *sk, int level, int optname,
87632 len = sizeof(struct icmp6_filter);
87633 if (put_user(len, optlen))
87634 return -EFAULT;
87635 - if (copy_to_user(optval, &raw6_sk(sk)->filter, len))
87636 + filter = raw6_sk(sk)->filter;
87637 + if (len > sizeof filter || copy_to_user(optval, &filter, len))
87638 return -EFAULT;
87639 return 0;
87640 default:
87641 @@ -1252,7 +1257,7 @@ static void raw6_sock_seq_show(struct seq_file *seq, struct sock *sp, int i)
87642 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sp)),
87643 0,
87644 sock_i_ino(sp),
87645 - atomic_read(&sp->sk_refcnt), sp, atomic_read(&sp->sk_drops));
87646 + atomic_read(&sp->sk_refcnt), sp, atomic_read_unchecked(&sp->sk_drops));
87647 }
87648
87649 static int raw6_seq_show(struct seq_file *seq, void *v)
87650 diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c
87651 index 0ba10e5..c14a4f6 100644
87652 --- a/net/ipv6/reassembly.c
87653 +++ b/net/ipv6/reassembly.c
87654 @@ -602,12 +602,11 @@ static struct ctl_table ip6_frags_ctl_table[] = {
87655
87656 static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
87657 {
87658 - struct ctl_table *table;
87659 + ctl_table_no_const *table = NULL;
87660 struct ctl_table_header *hdr;
87661
87662 - table = ip6_frags_ns_ctl_table;
87663 if (!net_eq(net, &init_net)) {
87664 - table = kmemdup(table, sizeof(ip6_frags_ns_ctl_table), GFP_KERNEL);
87665 + table = kmemdup(ip6_frags_ns_ctl_table, sizeof(ip6_frags_ns_ctl_table), GFP_KERNEL);
87666 if (table == NULL)
87667 goto err_alloc;
87668
87669 @@ -618,9 +617,10 @@ static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
87670 /* Don't export sysctls to unprivileged users */
87671 if (net->user_ns != &init_user_ns)
87672 table[0].procname = NULL;
87673 - }
87674 + hdr = register_net_sysctl(net, "net/ipv6", table);
87675 + } else
87676 + hdr = register_net_sysctl(net, "net/ipv6", ip6_frags_ns_ctl_table);
87677
87678 - hdr = register_net_sysctl(net, "net/ipv6", table);
87679 if (hdr == NULL)
87680 goto err_reg;
87681
87682 @@ -628,8 +628,7 @@ static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
87683 return 0;
87684
87685 err_reg:
87686 - if (!net_eq(net, &init_net))
87687 - kfree(table);
87688 + kfree(table);
87689 err_alloc:
87690 return -ENOMEM;
87691 }
87692 diff --git a/net/ipv6/route.c b/net/ipv6/route.c
87693 index e5fe004..9fe3e8e 100644
87694 --- a/net/ipv6/route.c
87695 +++ b/net/ipv6/route.c
87696 @@ -2881,7 +2881,7 @@ ctl_table ipv6_route_table_template[] = {
87697
87698 struct ctl_table * __net_init ipv6_route_sysctl_init(struct net *net)
87699 {
87700 - struct ctl_table *table;
87701 + ctl_table_no_const *table;
87702
87703 table = kmemdup(ipv6_route_table_template,
87704 sizeof(ipv6_route_table_template),
87705 diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
87706 index 02f96dc..4a5a6e5 100644
87707 --- a/net/ipv6/sit.c
87708 +++ b/net/ipv6/sit.c
87709 @@ -74,7 +74,7 @@ static void ipip6_tunnel_setup(struct net_device *dev);
87710 static void ipip6_dev_free(struct net_device *dev);
87711 static bool check_6rd(struct ip_tunnel *tunnel, const struct in6_addr *v6dst,
87712 __be32 *v4dst);
87713 -static struct rtnl_link_ops sit_link_ops __read_mostly;
87714 +static struct rtnl_link_ops sit_link_ops;
87715
87716 static int sit_net_id __read_mostly;
87717 struct sit_net {
87718 @@ -1486,7 +1486,7 @@ static const struct nla_policy ipip6_policy[IFLA_IPTUN_MAX + 1] = {
87719 #endif
87720 };
87721
87722 -static struct rtnl_link_ops sit_link_ops __read_mostly = {
87723 +static struct rtnl_link_ops sit_link_ops = {
87724 .kind = "sit",
87725 .maxtype = IFLA_IPTUN_MAX,
87726 .policy = ipip6_policy,
87727 diff --git a/net/ipv6/sysctl_net_ipv6.c b/net/ipv6/sysctl_net_ipv6.c
87728 index e85c48b..b8268d3 100644
87729 --- a/net/ipv6/sysctl_net_ipv6.c
87730 +++ b/net/ipv6/sysctl_net_ipv6.c
87731 @@ -40,7 +40,7 @@ static ctl_table ipv6_rotable[] = {
87732
87733 static int __net_init ipv6_sysctl_net_init(struct net *net)
87734 {
87735 - struct ctl_table *ipv6_table;
87736 + ctl_table_no_const *ipv6_table;
87737 struct ctl_table *ipv6_route_table;
87738 struct ctl_table *ipv6_icmp_table;
87739 int err;
87740 diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
87741 index 0fce928..c52a518 100644
87742 --- a/net/ipv6/tcp_ipv6.c
87743 +++ b/net/ipv6/tcp_ipv6.c
87744 @@ -103,6 +103,10 @@ static void inet6_sk_rx_dst_set(struct sock *sk, const struct sk_buff *skb)
87745 inet6_sk(sk)->rx_dst_cookie = rt->rt6i_node->fn_sernum;
87746 }
87747
87748 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87749 +extern int grsec_enable_blackhole;
87750 +#endif
87751 +
87752 static void tcp_v6_hash(struct sock *sk)
87753 {
87754 if (sk->sk_state != TCP_CLOSE) {
87755 @@ -1446,6 +1450,9 @@ static int tcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb)
87756 return 0;
87757
87758 reset:
87759 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87760 + if (!grsec_enable_blackhole)
87761 +#endif
87762 tcp_v6_send_reset(sk, skb);
87763 discard:
87764 if (opt_skb)
87765 @@ -1527,12 +1534,20 @@ static int tcp_v6_rcv(struct sk_buff *skb)
87766 TCP_SKB_CB(skb)->sacked = 0;
87767
87768 sk = __inet6_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest);
87769 - if (!sk)
87770 + if (!sk) {
87771 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87772 + ret = 1;
87773 +#endif
87774 goto no_tcp_socket;
87775 + }
87776
87777 process:
87778 - if (sk->sk_state == TCP_TIME_WAIT)
87779 + if (sk->sk_state == TCP_TIME_WAIT) {
87780 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87781 + ret = 2;
87782 +#endif
87783 goto do_time_wait;
87784 + }
87785
87786 if (hdr->hop_limit < inet6_sk(sk)->min_hopcount) {
87787 NET_INC_STATS_BH(net, LINUX_MIB_TCPMINTTLDROP);
87788 @@ -1581,6 +1596,10 @@ no_tcp_socket:
87789 bad_packet:
87790 TCP_INC_STATS_BH(net, TCP_MIB_INERRS);
87791 } else {
87792 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87793 + if (!grsec_enable_blackhole || (ret == 1 &&
87794 + (skb->dev->flags & IFF_LOOPBACK)))
87795 +#endif
87796 tcp_v6_send_reset(NULL, skb);
87797 }
87798
87799 diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
87800 index 27f0f8e..949e7ee 100644
87801 --- a/net/ipv6/udp.c
87802 +++ b/net/ipv6/udp.c
87803 @@ -52,6 +52,10 @@
87804 #include <trace/events/skb.h>
87805 #include "udp_impl.h"
87806
87807 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87808 +extern int grsec_enable_blackhole;
87809 +#endif
87810 +
87811 int ipv6_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2)
87812 {
87813 const struct in6_addr *sk_rcv_saddr6 = &inet6_sk(sk)->rcv_saddr;
87814 @@ -419,7 +423,7 @@ try_again:
87815 if (unlikely(err)) {
87816 trace_kfree_skb(skb, udpv6_recvmsg);
87817 if (!peeked) {
87818 - atomic_inc(&sk->sk_drops);
87819 + atomic_inc_unchecked(&sk->sk_drops);
87820 if (is_udp4)
87821 UDP_INC_STATS_USER(sock_net(sk),
87822 UDP_MIB_INERRORS,
87823 @@ -657,7 +661,7 @@ int udpv6_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
87824 return rc;
87825 drop:
87826 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
87827 - atomic_inc(&sk->sk_drops);
87828 + atomic_inc_unchecked(&sk->sk_drops);
87829 kfree_skb(skb);
87830 return -1;
87831 }
87832 @@ -715,7 +719,7 @@ static void flush_stack(struct sock **stack, unsigned int count,
87833 if (likely(skb1 == NULL))
87834 skb1 = (i == final) ? skb : skb_clone(skb, GFP_ATOMIC);
87835 if (!skb1) {
87836 - atomic_inc(&sk->sk_drops);
87837 + atomic_inc_unchecked(&sk->sk_drops);
87838 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_RCVBUFERRORS,
87839 IS_UDPLITE(sk));
87840 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
87841 @@ -852,6 +856,9 @@ int __udp6_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
87842 goto discard;
87843
87844 UDP6_INC_STATS_BH(net, UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE);
87845 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87846 + if (!grsec_enable_blackhole || (skb->dev->flags & IFF_LOOPBACK))
87847 +#endif
87848 icmpv6_send(skb, ICMPV6_DEST_UNREACH, ICMPV6_PORT_UNREACH, 0);
87849
87850 kfree_skb(skb);
87851 @@ -1377,7 +1384,7 @@ static void udp6_sock_seq_show(struct seq_file *seq, struct sock *sp, int bucket
87852 0,
87853 sock_i_ino(sp),
87854 atomic_read(&sp->sk_refcnt), sp,
87855 - atomic_read(&sp->sk_drops));
87856 + atomic_read_unchecked(&sp->sk_drops));
87857 }
87858
87859 int udp6_seq_show(struct seq_file *seq, void *v)
87860 diff --git a/net/ipv6/xfrm6_policy.c b/net/ipv6/xfrm6_policy.c
87861 index 23ed03d..465a71d 100644
87862 --- a/net/ipv6/xfrm6_policy.c
87863 +++ b/net/ipv6/xfrm6_policy.c
87864 @@ -324,19 +324,19 @@ static struct ctl_table xfrm6_policy_table[] = {
87865
87866 static int __net_init xfrm6_net_init(struct net *net)
87867 {
87868 - struct ctl_table *table;
87869 + ctl_table_no_const *table = NULL;
87870 struct ctl_table_header *hdr;
87871
87872 - table = xfrm6_policy_table;
87873 if (!net_eq(net, &init_net)) {
87874 - table = kmemdup(table, sizeof(xfrm6_policy_table), GFP_KERNEL);
87875 + table = kmemdup(xfrm6_policy_table, sizeof(xfrm6_policy_table), GFP_KERNEL);
87876 if (!table)
87877 goto err_alloc;
87878
87879 table[0].data = &net->xfrm.xfrm6_dst_ops.gc_thresh;
87880 - }
87881 + hdr = register_net_sysctl(net, "net/ipv6", table);
87882 + } else
87883 + hdr = register_net_sysctl(net, "net/ipv6", xfrm6_policy_table);
87884
87885 - hdr = register_net_sysctl(net, "net/ipv6", table);
87886 if (!hdr)
87887 goto err_reg;
87888
87889 @@ -344,8 +344,7 @@ static int __net_init xfrm6_net_init(struct net *net)
87890 return 0;
87891
87892 err_reg:
87893 - if (!net_eq(net, &init_net))
87894 - kfree(table);
87895 + kfree(table);
87896 err_alloc:
87897 return -ENOMEM;
87898 }
87899 diff --git a/net/irda/ircomm/ircomm_tty.c b/net/irda/ircomm/ircomm_tty.c
87900 index 362ba47..66196f4 100644
87901 --- a/net/irda/ircomm/ircomm_tty.c
87902 +++ b/net/irda/ircomm/ircomm_tty.c
87903 @@ -319,11 +319,11 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
87904 add_wait_queue(&port->open_wait, &wait);
87905
87906 IRDA_DEBUG(2, "%s(%d):block_til_ready before block on %s open_count=%d\n",
87907 - __FILE__, __LINE__, tty->driver->name, port->count);
87908 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
87909
87910 spin_lock_irqsave(&port->lock, flags);
87911 if (!tty_hung_up_p(filp))
87912 - port->count--;
87913 + atomic_dec(&port->count);
87914 port->blocked_open++;
87915 spin_unlock_irqrestore(&port->lock, flags);
87916
87917 @@ -358,7 +358,7 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
87918 }
87919
87920 IRDA_DEBUG(1, "%s(%d):block_til_ready blocking on %s open_count=%d\n",
87921 - __FILE__, __LINE__, tty->driver->name, port->count);
87922 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
87923
87924 schedule();
87925 }
87926 @@ -368,12 +368,12 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
87927
87928 spin_lock_irqsave(&port->lock, flags);
87929 if (!tty_hung_up_p(filp))
87930 - port->count++;
87931 + atomic_inc(&port->count);
87932 port->blocked_open--;
87933 spin_unlock_irqrestore(&port->lock, flags);
87934
87935 IRDA_DEBUG(1, "%s(%d):block_til_ready after blocking on %s open_count=%d\n",
87936 - __FILE__, __LINE__, tty->driver->name, port->count);
87937 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
87938
87939 if (!retval)
87940 port->flags |= ASYNC_NORMAL_ACTIVE;
87941 @@ -447,12 +447,12 @@ static int ircomm_tty_open(struct tty_struct *tty, struct file *filp)
87942
87943 /* ++ is not atomic, so this should be protected - Jean II */
87944 spin_lock_irqsave(&self->port.lock, flags);
87945 - self->port.count++;
87946 + atomic_inc(&self->port.count);
87947 spin_unlock_irqrestore(&self->port.lock, flags);
87948 tty_port_tty_set(&self->port, tty);
87949
87950 IRDA_DEBUG(1, "%s(), %s%d, count = %d\n", __func__ , tty->driver->name,
87951 - self->line, self->port.count);
87952 + self->line, atomic_read(&self->port.count));
87953
87954 /* Not really used by us, but lets do it anyway */
87955 self->port.low_latency = (self->port.flags & ASYNC_LOW_LATENCY) ? 1 : 0;
87956 @@ -989,7 +989,7 @@ static void ircomm_tty_hangup(struct tty_struct *tty)
87957 tty_kref_put(port->tty);
87958 }
87959 port->tty = NULL;
87960 - port->count = 0;
87961 + atomic_set(&port->count, 0);
87962 spin_unlock_irqrestore(&port->lock, flags);
87963
87964 wake_up_interruptible(&port->open_wait);
87965 @@ -1346,7 +1346,7 @@ static void ircomm_tty_line_info(struct ircomm_tty_cb *self, struct seq_file *m)
87966 seq_putc(m, '\n');
87967
87968 seq_printf(m, "Role: %s\n", self->client ? "client" : "server");
87969 - seq_printf(m, "Open count: %d\n", self->port.count);
87970 + seq_printf(m, "Open count: %d\n", atomic_read(&self->port.count));
87971 seq_printf(m, "Max data size: %d\n", self->max_data_size);
87972 seq_printf(m, "Max header size: %d\n", self->max_header_size);
87973
87974 diff --git a/net/irda/irlap_frame.c b/net/irda/irlap_frame.c
87975 index 8c00416..9ea0c93 100644
87976 --- a/net/irda/irlap_frame.c
87977 +++ b/net/irda/irlap_frame.c
87978 @@ -544,7 +544,7 @@ static void irlap_recv_discovery_xid_cmd(struct irlap_cb *self,
87979 /*
87980 * We now have some discovery info to deliver!
87981 */
87982 - discovery = kmalloc(sizeof(discovery_t), GFP_ATOMIC);
87983 + discovery = kzalloc(sizeof(discovery_t), GFP_ATOMIC);
87984 if (!discovery) {
87985 IRDA_WARNING("%s: unable to malloc!\n", __func__);
87986 return;
87987 diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c
87988 index 206ce6d..cfb27cd 100644
87989 --- a/net/iucv/af_iucv.c
87990 +++ b/net/iucv/af_iucv.c
87991 @@ -773,10 +773,10 @@ static int iucv_sock_autobind(struct sock *sk)
87992
87993 write_lock_bh(&iucv_sk_list.lock);
87994
87995 - sprintf(name, "%08x", atomic_inc_return(&iucv_sk_list.autobind_name));
87996 + sprintf(name, "%08x", atomic_inc_return_unchecked(&iucv_sk_list.autobind_name));
87997 while (__iucv_get_sock_by_name(name)) {
87998 sprintf(name, "%08x",
87999 - atomic_inc_return(&iucv_sk_list.autobind_name));
88000 + atomic_inc_return_unchecked(&iucv_sk_list.autobind_name));
88001 }
88002
88003 write_unlock_bh(&iucv_sk_list.lock);
88004 diff --git a/net/iucv/iucv.c b/net/iucv/iucv.c
88005 index 4fe76ff..426a904 100644
88006 --- a/net/iucv/iucv.c
88007 +++ b/net/iucv/iucv.c
88008 @@ -690,7 +690,7 @@ static int __cpuinit iucv_cpu_notify(struct notifier_block *self,
88009 return NOTIFY_OK;
88010 }
88011
88012 -static struct notifier_block __refdata iucv_cpu_notifier = {
88013 +static struct notifier_block iucv_cpu_notifier = {
88014 .notifier_call = iucv_cpu_notify,
88015 };
88016
88017 diff --git a/net/key/af_key.c b/net/key/af_key.c
88018 index 5b1e5af..2358147 100644
88019 --- a/net/key/af_key.c
88020 +++ b/net/key/af_key.c
88021 @@ -3041,10 +3041,10 @@ static int pfkey_send_policy_notify(struct xfrm_policy *xp, int dir, const struc
88022 static u32 get_acqseq(void)
88023 {
88024 u32 res;
88025 - static atomic_t acqseq;
88026 + static atomic_unchecked_t acqseq;
88027
88028 do {
88029 - res = atomic_inc_return(&acqseq);
88030 + res = atomic_inc_return_unchecked(&acqseq);
88031 } while (!res);
88032 return res;
88033 }
88034 diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
88035 index 843d8c4..cb04fa1 100644
88036 --- a/net/mac80211/cfg.c
88037 +++ b/net/mac80211/cfg.c
88038 @@ -799,7 +799,7 @@ static int ieee80211_set_monitor_channel(struct wiphy *wiphy,
88039 ret = ieee80211_vif_use_channel(sdata, chandef,
88040 IEEE80211_CHANCTX_EXCLUSIVE);
88041 }
88042 - } else if (local->open_count == local->monitors) {
88043 + } else if (local_read(&local->open_count) == local->monitors) {
88044 local->_oper_channel = chandef->chan;
88045 local->_oper_channel_type = cfg80211_get_chandef_type(chandef);
88046 ieee80211_hw_config(local, 0);
88047 @@ -2834,7 +2834,7 @@ static void ieee80211_mgmt_frame_register(struct wiphy *wiphy,
88048 else
88049 local->probe_req_reg--;
88050
88051 - if (!local->open_count)
88052 + if (!local_read(&local->open_count))
88053 break;
88054
88055 ieee80211_queue_work(&local->hw, &local->reconfig_filter);
88056 @@ -3297,8 +3297,8 @@ static int ieee80211_cfg_get_channel(struct wiphy *wiphy,
88057 if (chanctx_conf) {
88058 *chandef = chanctx_conf->def;
88059 ret = 0;
88060 - } else if (local->open_count > 0 &&
88061 - local->open_count == local->monitors &&
88062 + } else if (local_read(&local->open_count) > 0 &&
88063 + local_read(&local->open_count) == local->monitors &&
88064 sdata->vif.type == NL80211_IFTYPE_MONITOR) {
88065 if (local->use_chanctx)
88066 *chandef = local->monitor_chandef;
88067 diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
88068 index 5672533..6738c93 100644
88069 --- a/net/mac80211/ieee80211_i.h
88070 +++ b/net/mac80211/ieee80211_i.h
88071 @@ -28,6 +28,7 @@
88072 #include <net/ieee80211_radiotap.h>
88073 #include <net/cfg80211.h>
88074 #include <net/mac80211.h>
88075 +#include <asm/local.h>
88076 #include "key.h"
88077 #include "sta_info.h"
88078 #include "debug.h"
88079 @@ -897,7 +898,7 @@ struct ieee80211_local {
88080 /* also used to protect ampdu_ac_queue and amdpu_ac_stop_refcnt */
88081 spinlock_t queue_stop_reason_lock;
88082
88083 - int open_count;
88084 + local_t open_count;
88085 int monitors, cooked_mntrs;
88086 /* number of interfaces with corresponding FIF_ flags */
88087 int fif_fcsfail, fif_plcpfail, fif_control, fif_other_bss, fif_pspoll,
88088 diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
88089 index 9cbebc2..14879bb 100644
88090 --- a/net/mac80211/iface.c
88091 +++ b/net/mac80211/iface.c
88092 @@ -495,7 +495,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
88093 break;
88094 }
88095
88096 - if (local->open_count == 0) {
88097 + if (local_read(&local->open_count) == 0) {
88098 res = drv_start(local);
88099 if (res)
88100 goto err_del_bss;
88101 @@ -540,7 +540,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
88102 break;
88103 }
88104
88105 - if (local->monitors == 0 && local->open_count == 0) {
88106 + if (local->monitors == 0 && local_read(&local->open_count) == 0) {
88107 res = ieee80211_add_virtual_monitor(local);
88108 if (res)
88109 goto err_stop;
88110 @@ -649,7 +649,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
88111 atomic_inc(&local->iff_promiscs);
88112
88113 if (coming_up)
88114 - local->open_count++;
88115 + local_inc(&local->open_count);
88116
88117 if (hw_reconf_flags)
88118 ieee80211_hw_config(local, hw_reconf_flags);
88119 @@ -663,7 +663,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
88120 err_del_interface:
88121 drv_remove_interface(local, sdata);
88122 err_stop:
88123 - if (!local->open_count)
88124 + if (!local_read(&local->open_count))
88125 drv_stop(local);
88126 err_del_bss:
88127 sdata->bss = NULL;
88128 @@ -806,7 +806,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
88129 }
88130
88131 if (going_down)
88132 - local->open_count--;
88133 + local_dec(&local->open_count);
88134
88135 switch (sdata->vif.type) {
88136 case NL80211_IFTYPE_AP_VLAN:
88137 @@ -871,7 +871,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
88138
88139 ieee80211_recalc_ps(local, -1);
88140
88141 - if (local->open_count == 0) {
88142 + if (local_read(&local->open_count) == 0) {
88143 if (local->ops->napi_poll)
88144 napi_disable(&local->napi);
88145 ieee80211_clear_tx_pending(local);
88146 @@ -897,7 +897,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
88147 }
88148 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags);
88149
88150 - if (local->monitors == local->open_count && local->monitors > 0)
88151 + if (local->monitors == local_read(&local->open_count) && local->monitors > 0)
88152 ieee80211_add_virtual_monitor(local);
88153 }
88154
88155 diff --git a/net/mac80211/main.c b/net/mac80211/main.c
88156 index 1a8591b..ef5db54 100644
88157 --- a/net/mac80211/main.c
88158 +++ b/net/mac80211/main.c
88159 @@ -180,7 +180,7 @@ int ieee80211_hw_config(struct ieee80211_local *local, u32 changed)
88160 changed &= ~(IEEE80211_CONF_CHANGE_CHANNEL |
88161 IEEE80211_CONF_CHANGE_POWER);
88162
88163 - if (changed && local->open_count) {
88164 + if (changed && local_read(&local->open_count)) {
88165 ret = drv_config(local, changed);
88166 /*
88167 * Goal:
88168 diff --git a/net/mac80211/pm.c b/net/mac80211/pm.c
88169 index 835584c..be46e67 100644
88170 --- a/net/mac80211/pm.c
88171 +++ b/net/mac80211/pm.c
88172 @@ -33,7 +33,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
88173 struct sta_info *sta;
88174 struct ieee80211_chanctx *ctx;
88175
88176 - if (!local->open_count)
88177 + if (!local_read(&local->open_count))
88178 goto suspend;
88179
88180 ieee80211_scan_cancel(local);
88181 @@ -75,7 +75,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
88182 cancel_work_sync(&local->dynamic_ps_enable_work);
88183 del_timer_sync(&local->dynamic_ps_timer);
88184
88185 - local->wowlan = wowlan && local->open_count;
88186 + local->wowlan = wowlan && local_read(&local->open_count);
88187 if (local->wowlan) {
88188 int err = drv_suspend(local, wowlan);
88189 if (err < 0) {
88190 @@ -214,7 +214,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
88191 mutex_unlock(&local->chanctx_mtx);
88192
88193 /* stop hardware - this must stop RX */
88194 - if (local->open_count)
88195 + if (local_read(&local->open_count))
88196 ieee80211_stop_device(local);
88197
88198 suspend:
88199 diff --git a/net/mac80211/rate.c b/net/mac80211/rate.c
88200 index dd88381..eef4dd6 100644
88201 --- a/net/mac80211/rate.c
88202 +++ b/net/mac80211/rate.c
88203 @@ -493,7 +493,7 @@ int ieee80211_init_rate_ctrl_alg(struct ieee80211_local *local,
88204
88205 ASSERT_RTNL();
88206
88207 - if (local->open_count)
88208 + if (local_read(&local->open_count))
88209 return -EBUSY;
88210
88211 if (local->hw.flags & IEEE80211_HW_HAS_RATE_CONTROL) {
88212 diff --git a/net/mac80211/rc80211_pid_debugfs.c b/net/mac80211/rc80211_pid_debugfs.c
88213 index c97a065..ff61928 100644
88214 --- a/net/mac80211/rc80211_pid_debugfs.c
88215 +++ b/net/mac80211/rc80211_pid_debugfs.c
88216 @@ -193,7 +193,7 @@ static ssize_t rate_control_pid_events_read(struct file *file, char __user *buf,
88217
88218 spin_unlock_irqrestore(&events->lock, status);
88219
88220 - if (copy_to_user(buf, pb, p))
88221 + if (p > sizeof(pb) || copy_to_user(buf, pb, p))
88222 return -EFAULT;
88223
88224 return p;
88225 diff --git a/net/mac80211/util.c b/net/mac80211/util.c
88226 index 0f38f43..e53d4a8 100644
88227 --- a/net/mac80211/util.c
88228 +++ b/net/mac80211/util.c
88229 @@ -1388,7 +1388,7 @@ int ieee80211_reconfig(struct ieee80211_local *local)
88230 }
88231 #endif
88232 /* everything else happens only if HW was up & running */
88233 - if (!local->open_count)
88234 + if (!local_read(&local->open_count))
88235 goto wake_up;
88236
88237 /*
88238 diff --git a/net/netfilter/Kconfig b/net/netfilter/Kconfig
88239 index 56d22ca..87c778f 100644
88240 --- a/net/netfilter/Kconfig
88241 +++ b/net/netfilter/Kconfig
88242 @@ -958,6 +958,16 @@ config NETFILTER_XT_MATCH_ESP
88243
88244 To compile it as a module, choose M here. If unsure, say N.
88245
88246 +config NETFILTER_XT_MATCH_GRADM
88247 + tristate '"gradm" match support'
88248 + depends on NETFILTER_XTABLES && NETFILTER_ADVANCED
88249 + depends on GRKERNSEC && !GRKERNSEC_NO_RBAC
88250 + ---help---
88251 + The gradm match allows to match on grsecurity RBAC being enabled.
88252 + It is useful when iptables rules are applied early on bootup to
88253 + prevent connections to the machine (except from a trusted host)
88254 + while the RBAC system is disabled.
88255 +
88256 config NETFILTER_XT_MATCH_HASHLIMIT
88257 tristate '"hashlimit" match support'
88258 depends on (IP6_NF_IPTABLES || IP6_NF_IPTABLES=n)
88259 diff --git a/net/netfilter/Makefile b/net/netfilter/Makefile
88260 index a1abf87..dbcb7ee 100644
88261 --- a/net/netfilter/Makefile
88262 +++ b/net/netfilter/Makefile
88263 @@ -112,6 +112,7 @@ obj-$(CONFIG_NETFILTER_XT_MATCH_DEVGROUP) += xt_devgroup.o
88264 obj-$(CONFIG_NETFILTER_XT_MATCH_DSCP) += xt_dscp.o
88265 obj-$(CONFIG_NETFILTER_XT_MATCH_ECN) += xt_ecn.o
88266 obj-$(CONFIG_NETFILTER_XT_MATCH_ESP) += xt_esp.o
88267 +obj-$(CONFIG_NETFILTER_XT_MATCH_GRADM) += xt_gradm.o
88268 obj-$(CONFIG_NETFILTER_XT_MATCH_HASHLIMIT) += xt_hashlimit.o
88269 obj-$(CONFIG_NETFILTER_XT_MATCH_HELPER) += xt_helper.o
88270 obj-$(CONFIG_NETFILTER_XT_MATCH_HL) += xt_hl.o
88271 diff --git a/net/netfilter/ipset/ip_set_core.c b/net/netfilter/ipset/ip_set_core.c
88272 index 1ba9dbc..e39f4ca 100644
88273 --- a/net/netfilter/ipset/ip_set_core.c
88274 +++ b/net/netfilter/ipset/ip_set_core.c
88275 @@ -1801,7 +1801,7 @@ done:
88276 return ret;
88277 }
88278
88279 -static struct nf_sockopt_ops so_set __read_mostly = {
88280 +static struct nf_sockopt_ops so_set = {
88281 .pf = PF_INET,
88282 .get_optmin = SO_IP_SET,
88283 .get_optmax = SO_IP_SET + 1,
88284 diff --git a/net/netfilter/ipvs/ip_vs_conn.c b/net/netfilter/ipvs/ip_vs_conn.c
88285 index 704e514..d644cc2 100644
88286 --- a/net/netfilter/ipvs/ip_vs_conn.c
88287 +++ b/net/netfilter/ipvs/ip_vs_conn.c
88288 @@ -551,7 +551,7 @@ ip_vs_bind_dest(struct ip_vs_conn *cp, struct ip_vs_dest *dest)
88289 /* Increase the refcnt counter of the dest */
88290 atomic_inc(&dest->refcnt);
88291
88292 - conn_flags = atomic_read(&dest->conn_flags);
88293 + conn_flags = atomic_read_unchecked(&dest->conn_flags);
88294 if (cp->protocol != IPPROTO_UDP)
88295 conn_flags &= ~IP_VS_CONN_F_ONE_PACKET;
88296 flags = cp->flags;
88297 @@ -895,7 +895,7 @@ ip_vs_conn_new(const struct ip_vs_conn_param *p,
88298 atomic_set(&cp->refcnt, 1);
88299
88300 atomic_set(&cp->n_control, 0);
88301 - atomic_set(&cp->in_pkts, 0);
88302 + atomic_set_unchecked(&cp->in_pkts, 0);
88303
88304 atomic_inc(&ipvs->conn_count);
88305 if (flags & IP_VS_CONN_F_NO_CPORT)
88306 @@ -1174,7 +1174,7 @@ static inline int todrop_entry(struct ip_vs_conn *cp)
88307
88308 /* Don't drop the entry if its number of incoming packets is not
88309 located in [0, 8] */
88310 - i = atomic_read(&cp->in_pkts);
88311 + i = atomic_read_unchecked(&cp->in_pkts);
88312 if (i > 8 || i < 0) return 0;
88313
88314 if (!todrop_rate[i]) return 0;
88315 diff --git a/net/netfilter/ipvs/ip_vs_core.c b/net/netfilter/ipvs/ip_vs_core.c
88316 index 61f49d2..6c8c5bc 100644
88317 --- a/net/netfilter/ipvs/ip_vs_core.c
88318 +++ b/net/netfilter/ipvs/ip_vs_core.c
88319 @@ -559,7 +559,7 @@ int ip_vs_leave(struct ip_vs_service *svc, struct sk_buff *skb,
88320 ret = cp->packet_xmit(skb, cp, pd->pp, iph);
88321 /* do not touch skb anymore */
88322
88323 - atomic_inc(&cp->in_pkts);
88324 + atomic_inc_unchecked(&cp->in_pkts);
88325 ip_vs_conn_put(cp);
88326 return ret;
88327 }
88328 @@ -1689,7 +1689,7 @@ ip_vs_in(unsigned int hooknum, struct sk_buff *skb, int af)
88329 if (cp->flags & IP_VS_CONN_F_ONE_PACKET)
88330 pkts = sysctl_sync_threshold(ipvs);
88331 else
88332 - pkts = atomic_add_return(1, &cp->in_pkts);
88333 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
88334
88335 if (ipvs->sync_state & IP_VS_STATE_MASTER)
88336 ip_vs_sync_conn(net, cp, pkts);
88337 diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c
88338 index 9e2d1cc..7f8f569 100644
88339 --- a/net/netfilter/ipvs/ip_vs_ctl.c
88340 +++ b/net/netfilter/ipvs/ip_vs_ctl.c
88341 @@ -787,7 +787,7 @@ __ip_vs_update_dest(struct ip_vs_service *svc, struct ip_vs_dest *dest,
88342 ip_vs_rs_hash(ipvs, dest);
88343 write_unlock_bh(&ipvs->rs_lock);
88344 }
88345 - atomic_set(&dest->conn_flags, conn_flags);
88346 + atomic_set_unchecked(&dest->conn_flags, conn_flags);
88347
88348 /* bind the service */
88349 if (!dest->svc) {
88350 @@ -1688,7 +1688,7 @@ proc_do_sync_ports(ctl_table *table, int write,
88351 * align with netns init in ip_vs_control_net_init()
88352 */
88353
88354 -static struct ctl_table vs_vars[] = {
88355 +static ctl_table_no_const vs_vars[] __read_only = {
88356 {
88357 .procname = "amemthresh",
88358 .maxlen = sizeof(int),
88359 @@ -2087,7 +2087,7 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)
88360 " %-7s %-6d %-10d %-10d\n",
88361 &dest->addr.in6,
88362 ntohs(dest->port),
88363 - ip_vs_fwd_name(atomic_read(&dest->conn_flags)),
88364 + ip_vs_fwd_name(atomic_read_unchecked(&dest->conn_flags)),
88365 atomic_read(&dest->weight),
88366 atomic_read(&dest->activeconns),
88367 atomic_read(&dest->inactconns));
88368 @@ -2098,7 +2098,7 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)
88369 "%-7s %-6d %-10d %-10d\n",
88370 ntohl(dest->addr.ip),
88371 ntohs(dest->port),
88372 - ip_vs_fwd_name(atomic_read(&dest->conn_flags)),
88373 + ip_vs_fwd_name(atomic_read_unchecked(&dest->conn_flags)),
88374 atomic_read(&dest->weight),
88375 atomic_read(&dest->activeconns),
88376 atomic_read(&dest->inactconns));
88377 @@ -2568,7 +2568,7 @@ __ip_vs_get_dest_entries(struct net *net, const struct ip_vs_get_dests *get,
88378
88379 entry.addr = dest->addr.ip;
88380 entry.port = dest->port;
88381 - entry.conn_flags = atomic_read(&dest->conn_flags);
88382 + entry.conn_flags = atomic_read_unchecked(&dest->conn_flags);
88383 entry.weight = atomic_read(&dest->weight);
88384 entry.u_threshold = dest->u_threshold;
88385 entry.l_threshold = dest->l_threshold;
88386 @@ -3104,7 +3104,7 @@ static int ip_vs_genl_fill_dest(struct sk_buff *skb, struct ip_vs_dest *dest)
88387 if (nla_put(skb, IPVS_DEST_ATTR_ADDR, sizeof(dest->addr), &dest->addr) ||
88388 nla_put_u16(skb, IPVS_DEST_ATTR_PORT, dest->port) ||
88389 nla_put_u32(skb, IPVS_DEST_ATTR_FWD_METHOD,
88390 - (atomic_read(&dest->conn_flags) &
88391 + (atomic_read_unchecked(&dest->conn_flags) &
88392 IP_VS_CONN_F_FWD_MASK)) ||
88393 nla_put_u32(skb, IPVS_DEST_ATTR_WEIGHT,
88394 atomic_read(&dest->weight)) ||
88395 @@ -3694,7 +3694,7 @@ static int __net_init ip_vs_control_net_init_sysctl(struct net *net)
88396 {
88397 int idx;
88398 struct netns_ipvs *ipvs = net_ipvs(net);
88399 - struct ctl_table *tbl;
88400 + ctl_table_no_const *tbl;
88401
88402 atomic_set(&ipvs->dropentry, 0);
88403 spin_lock_init(&ipvs->dropentry_lock);
88404 diff --git a/net/netfilter/ipvs/ip_vs_lblc.c b/net/netfilter/ipvs/ip_vs_lblc.c
88405 index fdd89b9..bd96aa9 100644
88406 --- a/net/netfilter/ipvs/ip_vs_lblc.c
88407 +++ b/net/netfilter/ipvs/ip_vs_lblc.c
88408 @@ -115,7 +115,7 @@ struct ip_vs_lblc_table {
88409 * IPVS LBLC sysctl table
88410 */
88411 #ifdef CONFIG_SYSCTL
88412 -static ctl_table vs_vars_table[] = {
88413 +static ctl_table_no_const vs_vars_table[] __read_only = {
88414 {
88415 .procname = "lblc_expiration",
88416 .data = NULL,
88417 diff --git a/net/netfilter/ipvs/ip_vs_lblcr.c b/net/netfilter/ipvs/ip_vs_lblcr.c
88418 index c03b6a3..8ce3681 100644
88419 --- a/net/netfilter/ipvs/ip_vs_lblcr.c
88420 +++ b/net/netfilter/ipvs/ip_vs_lblcr.c
88421 @@ -288,7 +288,7 @@ struct ip_vs_lblcr_table {
88422 * IPVS LBLCR sysctl table
88423 */
88424
88425 -static ctl_table vs_vars_table[] = {
88426 +static ctl_table_no_const vs_vars_table[] __read_only = {
88427 {
88428 .procname = "lblcr_expiration",
88429 .data = NULL,
88430 diff --git a/net/netfilter/ipvs/ip_vs_sync.c b/net/netfilter/ipvs/ip_vs_sync.c
88431 index 44fd10c..2a163b3 100644
88432 --- a/net/netfilter/ipvs/ip_vs_sync.c
88433 +++ b/net/netfilter/ipvs/ip_vs_sync.c
88434 @@ -596,7 +596,7 @@ static void ip_vs_sync_conn_v0(struct net *net, struct ip_vs_conn *cp,
88435 cp = cp->control;
88436 if (cp) {
88437 if (cp->flags & IP_VS_CONN_F_TEMPLATE)
88438 - pkts = atomic_add_return(1, &cp->in_pkts);
88439 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
88440 else
88441 pkts = sysctl_sync_threshold(ipvs);
88442 ip_vs_sync_conn(net, cp->control, pkts);
88443 @@ -758,7 +758,7 @@ control:
88444 if (!cp)
88445 return;
88446 if (cp->flags & IP_VS_CONN_F_TEMPLATE)
88447 - pkts = atomic_add_return(1, &cp->in_pkts);
88448 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
88449 else
88450 pkts = sysctl_sync_threshold(ipvs);
88451 goto sloop;
88452 @@ -885,7 +885,7 @@ static void ip_vs_proc_conn(struct net *net, struct ip_vs_conn_param *param,
88453
88454 if (opt)
88455 memcpy(&cp->in_seq, opt, sizeof(*opt));
88456 - atomic_set(&cp->in_pkts, sysctl_sync_threshold(ipvs));
88457 + atomic_set_unchecked(&cp->in_pkts, sysctl_sync_threshold(ipvs));
88458 cp->state = state;
88459 cp->old_state = cp->state;
88460 /*
88461 diff --git a/net/netfilter/ipvs/ip_vs_xmit.c b/net/netfilter/ipvs/ip_vs_xmit.c
88462 index ee6b7a9..f9a89f6 100644
88463 --- a/net/netfilter/ipvs/ip_vs_xmit.c
88464 +++ b/net/netfilter/ipvs/ip_vs_xmit.c
88465 @@ -1210,7 +1210,7 @@ ip_vs_icmp_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,
88466 else
88467 rc = NF_ACCEPT;
88468 /* do not touch skb anymore */
88469 - atomic_inc(&cp->in_pkts);
88470 + atomic_inc_unchecked(&cp->in_pkts);
88471 goto out;
88472 }
88473
88474 @@ -1332,7 +1332,7 @@ ip_vs_icmp_xmit_v6(struct sk_buff *skb, struct ip_vs_conn *cp,
88475 else
88476 rc = NF_ACCEPT;
88477 /* do not touch skb anymore */
88478 - atomic_inc(&cp->in_pkts);
88479 + atomic_inc_unchecked(&cp->in_pkts);
88480 goto out;
88481 }
88482
88483 diff --git a/net/netfilter/nf_conntrack_acct.c b/net/netfilter/nf_conntrack_acct.c
88484 index 2d3030a..7ba1c0a 100644
88485 --- a/net/netfilter/nf_conntrack_acct.c
88486 +++ b/net/netfilter/nf_conntrack_acct.c
88487 @@ -60,7 +60,7 @@ static struct nf_ct_ext_type acct_extend __read_mostly = {
88488 #ifdef CONFIG_SYSCTL
88489 static int nf_conntrack_acct_init_sysctl(struct net *net)
88490 {
88491 - struct ctl_table *table;
88492 + ctl_table_no_const *table;
88493
88494 table = kmemdup(acct_sysctl_table, sizeof(acct_sysctl_table),
88495 GFP_KERNEL);
88496 diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
88497 index c8e001a..f842a8b 100644
88498 --- a/net/netfilter/nf_conntrack_core.c
88499 +++ b/net/netfilter/nf_conntrack_core.c
88500 @@ -1594,6 +1594,10 @@ void nf_conntrack_init_end(void)
88501 #define DYING_NULLS_VAL ((1<<30)+1)
88502 #define TEMPLATE_NULLS_VAL ((1<<30)+2)
88503
88504 +#ifdef CONFIG_GRKERNSEC_HIDESYM
88505 +static atomic_unchecked_t conntrack_cache_id = ATOMIC_INIT(0);
88506 +#endif
88507 +
88508 int nf_conntrack_init_net(struct net *net)
88509 {
88510 int ret;
88511 @@ -1608,7 +1612,11 @@ int nf_conntrack_init_net(struct net *net)
88512 goto err_stat;
88513 }
88514
88515 +#ifdef CONFIG_GRKERNSEC_HIDESYM
88516 + net->ct.slabname = kasprintf(GFP_KERNEL, "nf_conntrack_%08lx", atomic_inc_return_unchecked(&conntrack_cache_id));
88517 +#else
88518 net->ct.slabname = kasprintf(GFP_KERNEL, "nf_conntrack_%p", net);
88519 +#endif
88520 if (!net->ct.slabname) {
88521 ret = -ENOMEM;
88522 goto err_slabname;
88523 diff --git a/net/netfilter/nf_conntrack_ecache.c b/net/netfilter/nf_conntrack_ecache.c
88524 index b5d2eb8..61ef19a 100644
88525 --- a/net/netfilter/nf_conntrack_ecache.c
88526 +++ b/net/netfilter/nf_conntrack_ecache.c
88527 @@ -186,7 +186,7 @@ static struct nf_ct_ext_type event_extend __read_mostly = {
88528 #ifdef CONFIG_SYSCTL
88529 static int nf_conntrack_event_init_sysctl(struct net *net)
88530 {
88531 - struct ctl_table *table;
88532 + ctl_table_no_const *table;
88533
88534 table = kmemdup(event_sysctl_table, sizeof(event_sysctl_table),
88535 GFP_KERNEL);
88536 diff --git a/net/netfilter/nf_conntrack_helper.c b/net/netfilter/nf_conntrack_helper.c
88537 index 94b4b98..97cf0ad 100644
88538 --- a/net/netfilter/nf_conntrack_helper.c
88539 +++ b/net/netfilter/nf_conntrack_helper.c
88540 @@ -56,7 +56,7 @@ static struct ctl_table helper_sysctl_table[] = {
88541
88542 static int nf_conntrack_helper_init_sysctl(struct net *net)
88543 {
88544 - struct ctl_table *table;
88545 + ctl_table_no_const *table;
88546
88547 table = kmemdup(helper_sysctl_table, sizeof(helper_sysctl_table),
88548 GFP_KERNEL);
88549 diff --git a/net/netfilter/nf_conntrack_proto.c b/net/netfilter/nf_conntrack_proto.c
88550 index 58ab405..50eb8d3 100644
88551 --- a/net/netfilter/nf_conntrack_proto.c
88552 +++ b/net/netfilter/nf_conntrack_proto.c
88553 @@ -51,7 +51,7 @@ nf_ct_register_sysctl(struct net *net,
88554
88555 static void
88556 nf_ct_unregister_sysctl(struct ctl_table_header **header,
88557 - struct ctl_table **table,
88558 + ctl_table_no_const **table,
88559 unsigned int users)
88560 {
88561 if (users > 0)
88562 diff --git a/net/netfilter/nf_conntrack_standalone.c b/net/netfilter/nf_conntrack_standalone.c
88563 index fedee39..d62a93d 100644
88564 --- a/net/netfilter/nf_conntrack_standalone.c
88565 +++ b/net/netfilter/nf_conntrack_standalone.c
88566 @@ -470,7 +470,7 @@ static ctl_table nf_ct_netfilter_table[] = {
88567
88568 static int nf_conntrack_standalone_init_sysctl(struct net *net)
88569 {
88570 - struct ctl_table *table;
88571 + ctl_table_no_const *table;
88572
88573 table = kmemdup(nf_ct_sysctl_table, sizeof(nf_ct_sysctl_table),
88574 GFP_KERNEL);
88575 diff --git a/net/netfilter/nf_conntrack_timestamp.c b/net/netfilter/nf_conntrack_timestamp.c
88576 index 902fb0a..87f7fdb 100644
88577 --- a/net/netfilter/nf_conntrack_timestamp.c
88578 +++ b/net/netfilter/nf_conntrack_timestamp.c
88579 @@ -42,7 +42,7 @@ static struct nf_ct_ext_type tstamp_extend __read_mostly = {
88580 #ifdef CONFIG_SYSCTL
88581 static int nf_conntrack_tstamp_init_sysctl(struct net *net)
88582 {
88583 - struct ctl_table *table;
88584 + ctl_table_no_const *table;
88585
88586 table = kmemdup(tstamp_sysctl_table, sizeof(tstamp_sysctl_table),
88587 GFP_KERNEL);
88588 diff --git a/net/netfilter/nf_log.c b/net/netfilter/nf_log.c
88589 index 9e31269..bc4c1b7 100644
88590 --- a/net/netfilter/nf_log.c
88591 +++ b/net/netfilter/nf_log.c
88592 @@ -215,7 +215,7 @@ static const struct file_operations nflog_file_ops = {
88593
88594 #ifdef CONFIG_SYSCTL
88595 static char nf_log_sysctl_fnames[NFPROTO_NUMPROTO-NFPROTO_UNSPEC][3];
88596 -static struct ctl_table nf_log_sysctl_table[NFPROTO_NUMPROTO+1];
88597 +static ctl_table_no_const nf_log_sysctl_table[NFPROTO_NUMPROTO+1] __read_only;
88598 static struct ctl_table_header *nf_log_dir_header;
88599
88600 static int nf_log_proc_dostring(ctl_table *table, int write,
88601 @@ -246,14 +246,16 @@ static int nf_log_proc_dostring(ctl_table *table, int write,
88602 rcu_assign_pointer(nf_loggers[tindex], logger);
88603 mutex_unlock(&nf_log_mutex);
88604 } else {
88605 + ctl_table_no_const nf_log_table = *table;
88606 +
88607 mutex_lock(&nf_log_mutex);
88608 logger = rcu_dereference_protected(nf_loggers[tindex],
88609 lockdep_is_held(&nf_log_mutex));
88610 if (!logger)
88611 - table->data = "NONE";
88612 + nf_log_table.data = "NONE";
88613 else
88614 - table->data = logger->name;
88615 - r = proc_dostring(table, write, buffer, lenp, ppos);
88616 + nf_log_table.data = logger->name;
88617 + r = proc_dostring(&nf_log_table, write, buffer, lenp, ppos);
88618 mutex_unlock(&nf_log_mutex);
88619 }
88620
88621 diff --git a/net/netfilter/nf_sockopt.c b/net/netfilter/nf_sockopt.c
88622 index f042ae5..30ea486 100644
88623 --- a/net/netfilter/nf_sockopt.c
88624 +++ b/net/netfilter/nf_sockopt.c
88625 @@ -45,7 +45,7 @@ int nf_register_sockopt(struct nf_sockopt_ops *reg)
88626 }
88627 }
88628
88629 - list_add(&reg->list, &nf_sockopts);
88630 + pax_list_add((struct list_head *)&reg->list, &nf_sockopts);
88631 out:
88632 mutex_unlock(&nf_sockopt_mutex);
88633 return ret;
88634 @@ -55,7 +55,7 @@ EXPORT_SYMBOL(nf_register_sockopt);
88635 void nf_unregister_sockopt(struct nf_sockopt_ops *reg)
88636 {
88637 mutex_lock(&nf_sockopt_mutex);
88638 - list_del(&reg->list);
88639 + pax_list_del((struct list_head *)&reg->list);
88640 mutex_unlock(&nf_sockopt_mutex);
88641 }
88642 EXPORT_SYMBOL(nf_unregister_sockopt);
88643 diff --git a/net/netfilter/nfnetlink_log.c b/net/netfilter/nfnetlink_log.c
88644 index f248db5..3778ad9 100644
88645 --- a/net/netfilter/nfnetlink_log.c
88646 +++ b/net/netfilter/nfnetlink_log.c
88647 @@ -72,7 +72,7 @@ struct nfulnl_instance {
88648 };
88649
88650 static DEFINE_SPINLOCK(instances_lock);
88651 -static atomic_t global_seq;
88652 +static atomic_unchecked_t global_seq;
88653
88654 #define INSTANCE_BUCKETS 16
88655 static struct hlist_head instance_table[INSTANCE_BUCKETS];
88656 @@ -536,7 +536,7 @@ __build_packet_message(struct nfulnl_instance *inst,
88657 /* global sequence number */
88658 if ((inst->flags & NFULNL_CFG_F_SEQ_GLOBAL) &&
88659 nla_put_be32(inst->skb, NFULA_SEQ_GLOBAL,
88660 - htonl(atomic_inc_return(&global_seq))))
88661 + htonl(atomic_inc_return_unchecked(&global_seq))))
88662 goto nla_put_failure;
88663
88664 if (data_len) {
88665 diff --git a/net/netfilter/xt_gradm.c b/net/netfilter/xt_gradm.c
88666 new file mode 100644
88667 index 0000000..c566332
88668 --- /dev/null
88669 +++ b/net/netfilter/xt_gradm.c
88670 @@ -0,0 +1,51 @@
88671 +/*
88672 + * gradm match for netfilter
88673 + * Copyright © Zbigniew Krzystolik, 2010
88674 + *
88675 + * This program is free software; you can redistribute it and/or modify
88676 + * it under the terms of the GNU General Public License; either version
88677 + * 2 or 3 as published by the Free Software Foundation.
88678 + */
88679 +#include <linux/module.h>
88680 +#include <linux/moduleparam.h>
88681 +#include <linux/skbuff.h>
88682 +#include <linux/netfilter/x_tables.h>
88683 +#include <linux/grsecurity.h>
88684 +#include <linux/netfilter/xt_gradm.h>
88685 +
88686 +static bool
88687 +gradm_mt(const struct sk_buff *skb, struct xt_action_param *par)
88688 +{
88689 + const struct xt_gradm_mtinfo *info = par->matchinfo;
88690 + bool retval = false;
88691 + if (gr_acl_is_enabled())
88692 + retval = true;
88693 + return retval ^ info->invflags;
88694 +}
88695 +
88696 +static struct xt_match gradm_mt_reg __read_mostly = {
88697 + .name = "gradm",
88698 + .revision = 0,
88699 + .family = NFPROTO_UNSPEC,
88700 + .match = gradm_mt,
88701 + .matchsize = XT_ALIGN(sizeof(struct xt_gradm_mtinfo)),
88702 + .me = THIS_MODULE,
88703 +};
88704 +
88705 +static int __init gradm_mt_init(void)
88706 +{
88707 + return xt_register_match(&gradm_mt_reg);
88708 +}
88709 +
88710 +static void __exit gradm_mt_exit(void)
88711 +{
88712 + xt_unregister_match(&gradm_mt_reg);
88713 +}
88714 +
88715 +module_init(gradm_mt_init);
88716 +module_exit(gradm_mt_exit);
88717 +MODULE_AUTHOR("Zbigniew Krzystolik <zbyniu@destrukcja.pl>");
88718 +MODULE_DESCRIPTION("Xtables: Grsecurity RBAC match");
88719 +MODULE_LICENSE("GPL");
88720 +MODULE_ALIAS("ipt_gradm");
88721 +MODULE_ALIAS("ip6t_gradm");
88722 diff --git a/net/netfilter/xt_statistic.c b/net/netfilter/xt_statistic.c
88723 index 4fe4fb4..87a89e5 100644
88724 --- a/net/netfilter/xt_statistic.c
88725 +++ b/net/netfilter/xt_statistic.c
88726 @@ -19,7 +19,7 @@
88727 #include <linux/module.h>
88728
88729 struct xt_statistic_priv {
88730 - atomic_t count;
88731 + atomic_unchecked_t count;
88732 } ____cacheline_aligned_in_smp;
88733
88734 MODULE_LICENSE("GPL");
88735 @@ -42,9 +42,9 @@ statistic_mt(const struct sk_buff *skb, struct xt_action_param *par)
88736 break;
88737 case XT_STATISTIC_MODE_NTH:
88738 do {
88739 - oval = atomic_read(&info->master->count);
88740 + oval = atomic_read_unchecked(&info->master->count);
88741 nval = (oval == info->u.nth.every) ? 0 : oval + 1;
88742 - } while (atomic_cmpxchg(&info->master->count, oval, nval) != oval);
88743 + } while (atomic_cmpxchg_unchecked(&info->master->count, oval, nval) != oval);
88744 if (nval == 0)
88745 ret = !ret;
88746 break;
88747 @@ -64,7 +64,7 @@ static int statistic_mt_check(const struct xt_mtchk_param *par)
88748 info->master = kzalloc(sizeof(*info->master), GFP_KERNEL);
88749 if (info->master == NULL)
88750 return -ENOMEM;
88751 - atomic_set(&info->master->count, info->u.nth.count);
88752 + atomic_set_unchecked(&info->master->count, info->u.nth.count);
88753
88754 return 0;
88755 }
88756 diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
88757 index 1e3fd5b..ad397ea 100644
88758 --- a/net/netlink/af_netlink.c
88759 +++ b/net/netlink/af_netlink.c
88760 @@ -781,7 +781,7 @@ static void netlink_overrun(struct sock *sk)
88761 sk->sk_error_report(sk);
88762 }
88763 }
88764 - atomic_inc(&sk->sk_drops);
88765 + atomic_inc_unchecked(&sk->sk_drops);
88766 }
88767
88768 static struct sock *netlink_getsockbyportid(struct sock *ssk, u32 portid)
88769 @@ -2063,7 +2063,7 @@ static int netlink_seq_show(struct seq_file *seq, void *v)
88770 sk_wmem_alloc_get(s),
88771 nlk->cb,
88772 atomic_read(&s->sk_refcnt),
88773 - atomic_read(&s->sk_drops),
88774 + atomic_read_unchecked(&s->sk_drops),
88775 sock_i_ino(s)
88776 );
88777
88778 diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c
88779 index 5a55be3..7630745 100644
88780 --- a/net/netlink/genetlink.c
88781 +++ b/net/netlink/genetlink.c
88782 @@ -296,18 +296,20 @@ int genl_register_ops(struct genl_family *family, struct genl_ops *ops)
88783 goto errout;
88784 }
88785
88786 + pax_open_kernel();
88787 if (ops->dumpit)
88788 - ops->flags |= GENL_CMD_CAP_DUMP;
88789 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_DUMP;
88790 if (ops->doit)
88791 - ops->flags |= GENL_CMD_CAP_DO;
88792 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_DO;
88793 if (ops->policy)
88794 - ops->flags |= GENL_CMD_CAP_HASPOL;
88795 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_HASPOL;
88796 + pax_close_kernel();
88797
88798 genl_lock();
88799 - list_add_tail(&ops->ops_list, &family->ops_list);
88800 + pax_list_add_tail((struct list_head *)&ops->ops_list, &family->ops_list);
88801 genl_unlock();
88802
88803 - genl_ctrl_event(CTRL_CMD_NEWOPS, ops);
88804 + genl_ctrl_event(CTRL_CMD_NEWOPS, (void *)ops);
88805 err = 0;
88806 errout:
88807 return err;
88808 @@ -337,9 +339,9 @@ int genl_unregister_ops(struct genl_family *family, struct genl_ops *ops)
88809 genl_lock();
88810 list_for_each_entry(rc, &family->ops_list, ops_list) {
88811 if (rc == ops) {
88812 - list_del(&ops->ops_list);
88813 + pax_list_del((struct list_head *)&ops->ops_list);
88814 genl_unlock();
88815 - genl_ctrl_event(CTRL_CMD_DELOPS, ops);
88816 + genl_ctrl_event(CTRL_CMD_DELOPS, (void *)ops);
88817 return 0;
88818 }
88819 }
88820 diff --git a/net/netrom/af_netrom.c b/net/netrom/af_netrom.c
88821 index 103bd70..f21aad3 100644
88822 --- a/net/netrom/af_netrom.c
88823 +++ b/net/netrom/af_netrom.c
88824 @@ -834,6 +834,7 @@ static int nr_getname(struct socket *sock, struct sockaddr *uaddr,
88825 struct sock *sk = sock->sk;
88826 struct nr_sock *nr = nr_sk(sk);
88827
88828 + memset(sax, 0, sizeof(*sax));
88829 lock_sock(sk);
88830 if (peer != 0) {
88831 if (sk->sk_state != TCP_ESTABLISHED) {
88832 @@ -848,7 +849,6 @@ static int nr_getname(struct socket *sock, struct sockaddr *uaddr,
88833 *uaddr_len = sizeof(struct full_sockaddr_ax25);
88834 } else {
88835 sax->fsa_ax25.sax25_family = AF_NETROM;
88836 - sax->fsa_ax25.sax25_ndigis = 0;
88837 sax->fsa_ax25.sax25_call = nr->source_addr;
88838 *uaddr_len = sizeof(struct sockaddr_ax25);
88839 }
88840 diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
88841 index f83e172..b57140d 100644
88842 --- a/net/packet/af_packet.c
88843 +++ b/net/packet/af_packet.c
88844 @@ -1571,7 +1571,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
88845
88846 spin_lock(&sk->sk_receive_queue.lock);
88847 po->stats.tp_packets++;
88848 - skb->dropcount = atomic_read(&sk->sk_drops);
88849 + skb->dropcount = atomic_read_unchecked(&sk->sk_drops);
88850 __skb_queue_tail(&sk->sk_receive_queue, skb);
88851 spin_unlock(&sk->sk_receive_queue.lock);
88852 sk->sk_data_ready(sk, skb->len);
88853 @@ -1580,7 +1580,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
88854 drop_n_acct:
88855 spin_lock(&sk->sk_receive_queue.lock);
88856 po->stats.tp_drops++;
88857 - atomic_inc(&sk->sk_drops);
88858 + atomic_inc_unchecked(&sk->sk_drops);
88859 spin_unlock(&sk->sk_receive_queue.lock);
88860
88861 drop_n_restore:
88862 @@ -2558,6 +2558,7 @@ out:
88863
88864 static int packet_recv_error(struct sock *sk, struct msghdr *msg, int len)
88865 {
88866 + struct sock_extended_err ee;
88867 struct sock_exterr_skb *serr;
88868 struct sk_buff *skb, *skb2;
88869 int copied, err;
88870 @@ -2579,8 +2580,9 @@ static int packet_recv_error(struct sock *sk, struct msghdr *msg, int len)
88871 sock_recv_timestamp(msg, sk, skb);
88872
88873 serr = SKB_EXT_ERR(skb);
88874 + ee = serr->ee;
88875 put_cmsg(msg, SOL_PACKET, PACKET_TX_TIMESTAMP,
88876 - sizeof(serr->ee), &serr->ee);
88877 + sizeof ee, &ee);
88878
88879 msg->msg_flags |= MSG_ERRQUEUE;
88880 err = copied;
88881 @@ -3205,7 +3207,7 @@ static int packet_getsockopt(struct socket *sock, int level, int optname,
88882 case PACKET_HDRLEN:
88883 if (len > sizeof(int))
88884 len = sizeof(int);
88885 - if (copy_from_user(&val, optval, len))
88886 + if (len > sizeof(val) || copy_from_user(&val, optval, len))
88887 return -EFAULT;
88888 switch (val) {
88889 case TPACKET_V1:
88890 @@ -3247,7 +3249,7 @@ static int packet_getsockopt(struct socket *sock, int level, int optname,
88891 len = lv;
88892 if (put_user(len, optlen))
88893 return -EFAULT;
88894 - if (copy_to_user(optval, data, len))
88895 + if (len > sizeof(st) || copy_to_user(optval, data, len))
88896 return -EFAULT;
88897 return 0;
88898 }
88899 diff --git a/net/phonet/af_phonet.c b/net/phonet/af_phonet.c
88900 index 5a940db..d6a502d 100644
88901 --- a/net/phonet/af_phonet.c
88902 +++ b/net/phonet/af_phonet.c
88903 @@ -469,7 +469,7 @@ int __init_or_module phonet_proto_register(unsigned int protocol,
88904 {
88905 int err = 0;
88906
88907 - if (protocol >= PHONET_NPROTO)
88908 + if (protocol < 0 || protocol >= PHONET_NPROTO)
88909 return -EINVAL;
88910
88911 err = proto_register(pp->prot, 1);
88912 diff --git a/net/phonet/pep.c b/net/phonet/pep.c
88913 index e774117..900b8b7 100644
88914 --- a/net/phonet/pep.c
88915 +++ b/net/phonet/pep.c
88916 @@ -388,7 +388,7 @@ static int pipe_do_rcv(struct sock *sk, struct sk_buff *skb)
88917
88918 case PNS_PEP_CTRL_REQ:
88919 if (skb_queue_len(&pn->ctrlreq_queue) >= PNPIPE_CTRLREQ_MAX) {
88920 - atomic_inc(&sk->sk_drops);
88921 + atomic_inc_unchecked(&sk->sk_drops);
88922 break;
88923 }
88924 __skb_pull(skb, 4);
88925 @@ -409,7 +409,7 @@ static int pipe_do_rcv(struct sock *sk, struct sk_buff *skb)
88926 }
88927
88928 if (pn->rx_credits == 0) {
88929 - atomic_inc(&sk->sk_drops);
88930 + atomic_inc_unchecked(&sk->sk_drops);
88931 err = -ENOBUFS;
88932 break;
88933 }
88934 @@ -580,7 +580,7 @@ static int pipe_handler_do_rcv(struct sock *sk, struct sk_buff *skb)
88935 }
88936
88937 if (pn->rx_credits == 0) {
88938 - atomic_inc(&sk->sk_drops);
88939 + atomic_inc_unchecked(&sk->sk_drops);
88940 err = NET_RX_DROP;
88941 break;
88942 }
88943 diff --git a/net/phonet/socket.c b/net/phonet/socket.c
88944 index 1afd138..0b42453 100644
88945 --- a/net/phonet/socket.c
88946 +++ b/net/phonet/socket.c
88947 @@ -612,7 +612,7 @@ static int pn_sock_seq_show(struct seq_file *seq, void *v)
88948 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sk)),
88949 sock_i_ino(sk),
88950 atomic_read(&sk->sk_refcnt), sk,
88951 - atomic_read(&sk->sk_drops), &len);
88952 + atomic_read_unchecked(&sk->sk_drops), &len);
88953 }
88954 seq_printf(seq, "%*s\n", 127 - len, "");
88955 return 0;
88956 diff --git a/net/phonet/sysctl.c b/net/phonet/sysctl.c
88957 index d6bbbbd..61561e4 100644
88958 --- a/net/phonet/sysctl.c
88959 +++ b/net/phonet/sysctl.c
88960 @@ -67,7 +67,7 @@ static int proc_local_port_range(ctl_table *table, int write,
88961 {
88962 int ret;
88963 int range[2] = {local_port_range[0], local_port_range[1]};
88964 - ctl_table tmp = {
88965 + ctl_table_no_const tmp = {
88966 .data = &range,
88967 .maxlen = sizeof(range),
88968 .mode = table->mode,
88969 diff --git a/net/rds/cong.c b/net/rds/cong.c
88970 index e5b65ac..f3b6fb7 100644
88971 --- a/net/rds/cong.c
88972 +++ b/net/rds/cong.c
88973 @@ -78,7 +78,7 @@
88974 * finds that the saved generation number is smaller than the global generation
88975 * number, it wakes up the process.
88976 */
88977 -static atomic_t rds_cong_generation = ATOMIC_INIT(0);
88978 +static atomic_unchecked_t rds_cong_generation = ATOMIC_INIT(0);
88979
88980 /*
88981 * Congestion monitoring
88982 @@ -233,7 +233,7 @@ void rds_cong_map_updated(struct rds_cong_map *map, uint64_t portmask)
88983 rdsdebug("waking map %p for %pI4\n",
88984 map, &map->m_addr);
88985 rds_stats_inc(s_cong_update_received);
88986 - atomic_inc(&rds_cong_generation);
88987 + atomic_inc_unchecked(&rds_cong_generation);
88988 if (waitqueue_active(&map->m_waitq))
88989 wake_up(&map->m_waitq);
88990 if (waitqueue_active(&rds_poll_waitq))
88991 @@ -259,7 +259,7 @@ EXPORT_SYMBOL_GPL(rds_cong_map_updated);
88992
88993 int rds_cong_updated_since(unsigned long *recent)
88994 {
88995 - unsigned long gen = atomic_read(&rds_cong_generation);
88996 + unsigned long gen = atomic_read_unchecked(&rds_cong_generation);
88997
88998 if (likely(*recent == gen))
88999 return 0;
89000 diff --git a/net/rds/ib.h b/net/rds/ib.h
89001 index 7280ab8..e04f4ea 100644
89002 --- a/net/rds/ib.h
89003 +++ b/net/rds/ib.h
89004 @@ -128,7 +128,7 @@ struct rds_ib_connection {
89005 /* sending acks */
89006 unsigned long i_ack_flags;
89007 #ifdef KERNEL_HAS_ATOMIC64
89008 - atomic64_t i_ack_next; /* next ACK to send */
89009 + atomic64_unchecked_t i_ack_next; /* next ACK to send */
89010 #else
89011 spinlock_t i_ack_lock; /* protect i_ack_next */
89012 u64 i_ack_next; /* next ACK to send */
89013 diff --git a/net/rds/ib_cm.c b/net/rds/ib_cm.c
89014 index 31b74f5..dc1fbfa 100644
89015 --- a/net/rds/ib_cm.c
89016 +++ b/net/rds/ib_cm.c
89017 @@ -717,7 +717,7 @@ void rds_ib_conn_shutdown(struct rds_connection *conn)
89018 /* Clear the ACK state */
89019 clear_bit(IB_ACK_IN_FLIGHT, &ic->i_ack_flags);
89020 #ifdef KERNEL_HAS_ATOMIC64
89021 - atomic64_set(&ic->i_ack_next, 0);
89022 + atomic64_set_unchecked(&ic->i_ack_next, 0);
89023 #else
89024 ic->i_ack_next = 0;
89025 #endif
89026 diff --git a/net/rds/ib_recv.c b/net/rds/ib_recv.c
89027 index 8eb9501..0c386ff 100644
89028 --- a/net/rds/ib_recv.c
89029 +++ b/net/rds/ib_recv.c
89030 @@ -597,7 +597,7 @@ static u64 rds_ib_get_ack(struct rds_ib_connection *ic)
89031 static void rds_ib_set_ack(struct rds_ib_connection *ic, u64 seq,
89032 int ack_required)
89033 {
89034 - atomic64_set(&ic->i_ack_next, seq);
89035 + atomic64_set_unchecked(&ic->i_ack_next, seq);
89036 if (ack_required) {
89037 smp_mb__before_clear_bit();
89038 set_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
89039 @@ -609,7 +609,7 @@ static u64 rds_ib_get_ack(struct rds_ib_connection *ic)
89040 clear_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
89041 smp_mb__after_clear_bit();
89042
89043 - return atomic64_read(&ic->i_ack_next);
89044 + return atomic64_read_unchecked(&ic->i_ack_next);
89045 }
89046 #endif
89047
89048 diff --git a/net/rds/iw.h b/net/rds/iw.h
89049 index 04ce3b1..48119a6 100644
89050 --- a/net/rds/iw.h
89051 +++ b/net/rds/iw.h
89052 @@ -134,7 +134,7 @@ struct rds_iw_connection {
89053 /* sending acks */
89054 unsigned long i_ack_flags;
89055 #ifdef KERNEL_HAS_ATOMIC64
89056 - atomic64_t i_ack_next; /* next ACK to send */
89057 + atomic64_unchecked_t i_ack_next; /* next ACK to send */
89058 #else
89059 spinlock_t i_ack_lock; /* protect i_ack_next */
89060 u64 i_ack_next; /* next ACK to send */
89061 diff --git a/net/rds/iw_cm.c b/net/rds/iw_cm.c
89062 index a91e1db..cf3053f 100644
89063 --- a/net/rds/iw_cm.c
89064 +++ b/net/rds/iw_cm.c
89065 @@ -663,7 +663,7 @@ void rds_iw_conn_shutdown(struct rds_connection *conn)
89066 /* Clear the ACK state */
89067 clear_bit(IB_ACK_IN_FLIGHT, &ic->i_ack_flags);
89068 #ifdef KERNEL_HAS_ATOMIC64
89069 - atomic64_set(&ic->i_ack_next, 0);
89070 + atomic64_set_unchecked(&ic->i_ack_next, 0);
89071 #else
89072 ic->i_ack_next = 0;
89073 #endif
89074 diff --git a/net/rds/iw_recv.c b/net/rds/iw_recv.c
89075 index 4503335..db566b4 100644
89076 --- a/net/rds/iw_recv.c
89077 +++ b/net/rds/iw_recv.c
89078 @@ -427,7 +427,7 @@ static u64 rds_iw_get_ack(struct rds_iw_connection *ic)
89079 static void rds_iw_set_ack(struct rds_iw_connection *ic, u64 seq,
89080 int ack_required)
89081 {
89082 - atomic64_set(&ic->i_ack_next, seq);
89083 + atomic64_set_unchecked(&ic->i_ack_next, seq);
89084 if (ack_required) {
89085 smp_mb__before_clear_bit();
89086 set_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
89087 @@ -439,7 +439,7 @@ static u64 rds_iw_get_ack(struct rds_iw_connection *ic)
89088 clear_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
89089 smp_mb__after_clear_bit();
89090
89091 - return atomic64_read(&ic->i_ack_next);
89092 + return atomic64_read_unchecked(&ic->i_ack_next);
89093 }
89094 #endif
89095
89096 diff --git a/net/rds/rds.h b/net/rds/rds.h
89097 index ec1d731..90a3a8d 100644
89098 --- a/net/rds/rds.h
89099 +++ b/net/rds/rds.h
89100 @@ -449,7 +449,7 @@ struct rds_transport {
89101 void (*sync_mr)(void *trans_private, int direction);
89102 void (*free_mr)(void *trans_private, int invalidate);
89103 void (*flush_mrs)(void);
89104 -};
89105 +} __do_const;
89106
89107 struct rds_sock {
89108 struct sock rs_sk;
89109 diff --git a/net/rds/tcp.c b/net/rds/tcp.c
89110 index edac9ef..16bcb98 100644
89111 --- a/net/rds/tcp.c
89112 +++ b/net/rds/tcp.c
89113 @@ -59,7 +59,7 @@ void rds_tcp_nonagle(struct socket *sock)
89114 int val = 1;
89115
89116 set_fs(KERNEL_DS);
89117 - sock->ops->setsockopt(sock, SOL_TCP, TCP_NODELAY, (char __user *)&val,
89118 + sock->ops->setsockopt(sock, SOL_TCP, TCP_NODELAY, (char __force_user *)&val,
89119 sizeof(val));
89120 set_fs(oldfs);
89121 }
89122 diff --git a/net/rds/tcp_send.c b/net/rds/tcp_send.c
89123 index 81cf5a4..b5826ff 100644
89124 --- a/net/rds/tcp_send.c
89125 +++ b/net/rds/tcp_send.c
89126 @@ -43,7 +43,7 @@ static void rds_tcp_cork(struct socket *sock, int val)
89127
89128 oldfs = get_fs();
89129 set_fs(KERNEL_DS);
89130 - sock->ops->setsockopt(sock, SOL_TCP, TCP_CORK, (char __user *)&val,
89131 + sock->ops->setsockopt(sock, SOL_TCP, TCP_CORK, (char __force_user *)&val,
89132 sizeof(val));
89133 set_fs(oldfs);
89134 }
89135 diff --git a/net/rxrpc/af_rxrpc.c b/net/rxrpc/af_rxrpc.c
89136 index e61aa60..f07cc89 100644
89137 --- a/net/rxrpc/af_rxrpc.c
89138 +++ b/net/rxrpc/af_rxrpc.c
89139 @@ -40,7 +40,7 @@ static const struct proto_ops rxrpc_rpc_ops;
89140 __be32 rxrpc_epoch;
89141
89142 /* current debugging ID */
89143 -atomic_t rxrpc_debug_id;
89144 +atomic_unchecked_t rxrpc_debug_id;
89145
89146 /* count of skbs currently in use */
89147 atomic_t rxrpc_n_skbs;
89148 diff --git a/net/rxrpc/ar-ack.c b/net/rxrpc/ar-ack.c
89149 index e4d9cbc..b229649 100644
89150 --- a/net/rxrpc/ar-ack.c
89151 +++ b/net/rxrpc/ar-ack.c
89152 @@ -175,7 +175,7 @@ static void rxrpc_resend(struct rxrpc_call *call)
89153
89154 _enter("{%d,%d,%d,%d},",
89155 call->acks_hard, call->acks_unacked,
89156 - atomic_read(&call->sequence),
89157 + atomic_read_unchecked(&call->sequence),
89158 CIRC_CNT(call->acks_head, call->acks_tail, call->acks_winsz));
89159
89160 stop = 0;
89161 @@ -199,7 +199,7 @@ static void rxrpc_resend(struct rxrpc_call *call)
89162
89163 /* each Tx packet has a new serial number */
89164 sp->hdr.serial =
89165 - htonl(atomic_inc_return(&call->conn->serial));
89166 + htonl(atomic_inc_return_unchecked(&call->conn->serial));
89167
89168 hdr = (struct rxrpc_header *) txb->head;
89169 hdr->serial = sp->hdr.serial;
89170 @@ -403,7 +403,7 @@ static void rxrpc_rotate_tx_window(struct rxrpc_call *call, u32 hard)
89171 */
89172 static void rxrpc_clear_tx_window(struct rxrpc_call *call)
89173 {
89174 - rxrpc_rotate_tx_window(call, atomic_read(&call->sequence));
89175 + rxrpc_rotate_tx_window(call, atomic_read_unchecked(&call->sequence));
89176 }
89177
89178 /*
89179 @@ -629,7 +629,7 @@ process_further:
89180
89181 latest = ntohl(sp->hdr.serial);
89182 hard = ntohl(ack.firstPacket);
89183 - tx = atomic_read(&call->sequence);
89184 + tx = atomic_read_unchecked(&call->sequence);
89185
89186 _proto("Rx ACK %%%u { m=%hu f=#%u p=#%u s=%%%u r=%s n=%u }",
89187 latest,
89188 @@ -1161,7 +1161,7 @@ void rxrpc_process_call(struct work_struct *work)
89189 goto maybe_reschedule;
89190
89191 send_ACK_with_skew:
89192 - ack.maxSkew = htons(atomic_read(&call->conn->hi_serial) -
89193 + ack.maxSkew = htons(atomic_read_unchecked(&call->conn->hi_serial) -
89194 ntohl(ack.serial));
89195 send_ACK:
89196 mtu = call->conn->trans->peer->if_mtu;
89197 @@ -1173,7 +1173,7 @@ send_ACK:
89198 ackinfo.rxMTU = htonl(5692);
89199 ackinfo.jumbo_max = htonl(4);
89200
89201 - hdr.serial = htonl(atomic_inc_return(&call->conn->serial));
89202 + hdr.serial = htonl(atomic_inc_return_unchecked(&call->conn->serial));
89203 _proto("Tx ACK %%%u { m=%hu f=#%u p=#%u s=%%%u r=%s n=%u }",
89204 ntohl(hdr.serial),
89205 ntohs(ack.maxSkew),
89206 @@ -1191,7 +1191,7 @@ send_ACK:
89207 send_message:
89208 _debug("send message");
89209
89210 - hdr.serial = htonl(atomic_inc_return(&call->conn->serial));
89211 + hdr.serial = htonl(atomic_inc_return_unchecked(&call->conn->serial));
89212 _proto("Tx %s %%%u", rxrpc_pkts[hdr.type], ntohl(hdr.serial));
89213 send_message_2:
89214
89215 diff --git a/net/rxrpc/ar-call.c b/net/rxrpc/ar-call.c
89216 index a3bbb36..3341fb9 100644
89217 --- a/net/rxrpc/ar-call.c
89218 +++ b/net/rxrpc/ar-call.c
89219 @@ -83,7 +83,7 @@ static struct rxrpc_call *rxrpc_alloc_call(gfp_t gfp)
89220 spin_lock_init(&call->lock);
89221 rwlock_init(&call->state_lock);
89222 atomic_set(&call->usage, 1);
89223 - call->debug_id = atomic_inc_return(&rxrpc_debug_id);
89224 + call->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
89225 call->state = RXRPC_CALL_CLIENT_SEND_REQUEST;
89226
89227 memset(&call->sock_node, 0xed, sizeof(call->sock_node));
89228 diff --git a/net/rxrpc/ar-connection.c b/net/rxrpc/ar-connection.c
89229 index 4106ca9..a338d7a 100644
89230 --- a/net/rxrpc/ar-connection.c
89231 +++ b/net/rxrpc/ar-connection.c
89232 @@ -206,7 +206,7 @@ static struct rxrpc_connection *rxrpc_alloc_connection(gfp_t gfp)
89233 rwlock_init(&conn->lock);
89234 spin_lock_init(&conn->state_lock);
89235 atomic_set(&conn->usage, 1);
89236 - conn->debug_id = atomic_inc_return(&rxrpc_debug_id);
89237 + conn->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
89238 conn->avail_calls = RXRPC_MAXCALLS;
89239 conn->size_align = 4;
89240 conn->header_size = sizeof(struct rxrpc_header);
89241 diff --git a/net/rxrpc/ar-connevent.c b/net/rxrpc/ar-connevent.c
89242 index e7ed43a..6afa140 100644
89243 --- a/net/rxrpc/ar-connevent.c
89244 +++ b/net/rxrpc/ar-connevent.c
89245 @@ -109,7 +109,7 @@ static int rxrpc_abort_connection(struct rxrpc_connection *conn,
89246
89247 len = iov[0].iov_len + iov[1].iov_len;
89248
89249 - hdr.serial = htonl(atomic_inc_return(&conn->serial));
89250 + hdr.serial = htonl(atomic_inc_return_unchecked(&conn->serial));
89251 _proto("Tx CONN ABORT %%%u { %d }", ntohl(hdr.serial), abort_code);
89252
89253 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 2, len);
89254 diff --git a/net/rxrpc/ar-input.c b/net/rxrpc/ar-input.c
89255 index 529572f..c758ca7 100644
89256 --- a/net/rxrpc/ar-input.c
89257 +++ b/net/rxrpc/ar-input.c
89258 @@ -340,9 +340,9 @@ void rxrpc_fast_process_packet(struct rxrpc_call *call, struct sk_buff *skb)
89259 /* track the latest serial number on this connection for ACK packet
89260 * information */
89261 serial = ntohl(sp->hdr.serial);
89262 - hi_serial = atomic_read(&call->conn->hi_serial);
89263 + hi_serial = atomic_read_unchecked(&call->conn->hi_serial);
89264 while (serial > hi_serial)
89265 - hi_serial = atomic_cmpxchg(&call->conn->hi_serial, hi_serial,
89266 + hi_serial = atomic_cmpxchg_unchecked(&call->conn->hi_serial, hi_serial,
89267 serial);
89268
89269 /* request ACK generation for any ACK or DATA packet that requests
89270 diff --git a/net/rxrpc/ar-internal.h b/net/rxrpc/ar-internal.h
89271 index a693aca..81e7293 100644
89272 --- a/net/rxrpc/ar-internal.h
89273 +++ b/net/rxrpc/ar-internal.h
89274 @@ -272,8 +272,8 @@ struct rxrpc_connection {
89275 int error; /* error code for local abort */
89276 int debug_id; /* debug ID for printks */
89277 unsigned int call_counter; /* call ID counter */
89278 - atomic_t serial; /* packet serial number counter */
89279 - atomic_t hi_serial; /* highest serial number received */
89280 + atomic_unchecked_t serial; /* packet serial number counter */
89281 + atomic_unchecked_t hi_serial; /* highest serial number received */
89282 u8 avail_calls; /* number of calls available */
89283 u8 size_align; /* data size alignment (for security) */
89284 u8 header_size; /* rxrpc + security header size */
89285 @@ -346,7 +346,7 @@ struct rxrpc_call {
89286 spinlock_t lock;
89287 rwlock_t state_lock; /* lock for state transition */
89288 atomic_t usage;
89289 - atomic_t sequence; /* Tx data packet sequence counter */
89290 + atomic_unchecked_t sequence; /* Tx data packet sequence counter */
89291 u32 abort_code; /* local/remote abort code */
89292 enum { /* current state of call */
89293 RXRPC_CALL_CLIENT_SEND_REQUEST, /* - client sending request phase */
89294 @@ -420,7 +420,7 @@ static inline void rxrpc_abort_call(struct rxrpc_call *call, u32 abort_code)
89295 */
89296 extern atomic_t rxrpc_n_skbs;
89297 extern __be32 rxrpc_epoch;
89298 -extern atomic_t rxrpc_debug_id;
89299 +extern atomic_unchecked_t rxrpc_debug_id;
89300 extern struct workqueue_struct *rxrpc_workqueue;
89301
89302 /*
89303 diff --git a/net/rxrpc/ar-local.c b/net/rxrpc/ar-local.c
89304 index 87f7135..74d3703 100644
89305 --- a/net/rxrpc/ar-local.c
89306 +++ b/net/rxrpc/ar-local.c
89307 @@ -45,7 +45,7 @@ struct rxrpc_local *rxrpc_alloc_local(struct sockaddr_rxrpc *srx)
89308 spin_lock_init(&local->lock);
89309 rwlock_init(&local->services_lock);
89310 atomic_set(&local->usage, 1);
89311 - local->debug_id = atomic_inc_return(&rxrpc_debug_id);
89312 + local->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
89313 memcpy(&local->srx, srx, sizeof(*srx));
89314 }
89315
89316 diff --git a/net/rxrpc/ar-output.c b/net/rxrpc/ar-output.c
89317 index e1ac183..b43e10e 100644
89318 --- a/net/rxrpc/ar-output.c
89319 +++ b/net/rxrpc/ar-output.c
89320 @@ -682,9 +682,9 @@ static int rxrpc_send_data(struct kiocb *iocb,
89321 sp->hdr.cid = call->cid;
89322 sp->hdr.callNumber = call->call_id;
89323 sp->hdr.seq =
89324 - htonl(atomic_inc_return(&call->sequence));
89325 + htonl(atomic_inc_return_unchecked(&call->sequence));
89326 sp->hdr.serial =
89327 - htonl(atomic_inc_return(&conn->serial));
89328 + htonl(atomic_inc_return_unchecked(&conn->serial));
89329 sp->hdr.type = RXRPC_PACKET_TYPE_DATA;
89330 sp->hdr.userStatus = 0;
89331 sp->hdr.securityIndex = conn->security_ix;
89332 diff --git a/net/rxrpc/ar-peer.c b/net/rxrpc/ar-peer.c
89333 index bebaa43..2644591 100644
89334 --- a/net/rxrpc/ar-peer.c
89335 +++ b/net/rxrpc/ar-peer.c
89336 @@ -72,7 +72,7 @@ static struct rxrpc_peer *rxrpc_alloc_peer(struct sockaddr_rxrpc *srx,
89337 INIT_LIST_HEAD(&peer->error_targets);
89338 spin_lock_init(&peer->lock);
89339 atomic_set(&peer->usage, 1);
89340 - peer->debug_id = atomic_inc_return(&rxrpc_debug_id);
89341 + peer->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
89342 memcpy(&peer->srx, srx, sizeof(*srx));
89343
89344 rxrpc_assess_MTU_size(peer);
89345 diff --git a/net/rxrpc/ar-proc.c b/net/rxrpc/ar-proc.c
89346 index 38047f7..9f48511 100644
89347 --- a/net/rxrpc/ar-proc.c
89348 +++ b/net/rxrpc/ar-proc.c
89349 @@ -164,8 +164,8 @@ static int rxrpc_connection_seq_show(struct seq_file *seq, void *v)
89350 atomic_read(&conn->usage),
89351 rxrpc_conn_states[conn->state],
89352 key_serial(conn->key),
89353 - atomic_read(&conn->serial),
89354 - atomic_read(&conn->hi_serial));
89355 + atomic_read_unchecked(&conn->serial),
89356 + atomic_read_unchecked(&conn->hi_serial));
89357
89358 return 0;
89359 }
89360 diff --git a/net/rxrpc/ar-transport.c b/net/rxrpc/ar-transport.c
89361 index 92df566..87ec1bf 100644
89362 --- a/net/rxrpc/ar-transport.c
89363 +++ b/net/rxrpc/ar-transport.c
89364 @@ -47,7 +47,7 @@ static struct rxrpc_transport *rxrpc_alloc_transport(struct rxrpc_local *local,
89365 spin_lock_init(&trans->client_lock);
89366 rwlock_init(&trans->conn_lock);
89367 atomic_set(&trans->usage, 1);
89368 - trans->debug_id = atomic_inc_return(&rxrpc_debug_id);
89369 + trans->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
89370
89371 if (peer->srx.transport.family == AF_INET) {
89372 switch (peer->srx.transport_type) {
89373 diff --git a/net/rxrpc/rxkad.c b/net/rxrpc/rxkad.c
89374 index f226709..0e735a8 100644
89375 --- a/net/rxrpc/rxkad.c
89376 +++ b/net/rxrpc/rxkad.c
89377 @@ -610,7 +610,7 @@ static int rxkad_issue_challenge(struct rxrpc_connection *conn)
89378
89379 len = iov[0].iov_len + iov[1].iov_len;
89380
89381 - hdr.serial = htonl(atomic_inc_return(&conn->serial));
89382 + hdr.serial = htonl(atomic_inc_return_unchecked(&conn->serial));
89383 _proto("Tx CHALLENGE %%%u", ntohl(hdr.serial));
89384
89385 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 2, len);
89386 @@ -660,7 +660,7 @@ static int rxkad_send_response(struct rxrpc_connection *conn,
89387
89388 len = iov[0].iov_len + iov[1].iov_len + iov[2].iov_len;
89389
89390 - hdr->serial = htonl(atomic_inc_return(&conn->serial));
89391 + hdr->serial = htonl(atomic_inc_return_unchecked(&conn->serial));
89392 _proto("Tx RESPONSE %%%u", ntohl(hdr->serial));
89393
89394 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 3, len);
89395 diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c
89396 index 391a245..296b3d7 100644
89397 --- a/net/sctp/ipv6.c
89398 +++ b/net/sctp/ipv6.c
89399 @@ -981,7 +981,7 @@ static const struct inet6_protocol sctpv6_protocol = {
89400 .flags = INET6_PROTO_NOPOLICY | INET6_PROTO_FINAL,
89401 };
89402
89403 -static struct sctp_af sctp_af_inet6 = {
89404 +static struct sctp_af sctp_af_inet6 __read_only = {
89405 .sa_family = AF_INET6,
89406 .sctp_xmit = sctp_v6_xmit,
89407 .setsockopt = ipv6_setsockopt,
89408 @@ -1013,7 +1013,7 @@ static struct sctp_af sctp_af_inet6 = {
89409 #endif
89410 };
89411
89412 -static struct sctp_pf sctp_pf_inet6 = {
89413 +static struct sctp_pf sctp_pf_inet6 __read_only = {
89414 .event_msgname = sctp_inet6_event_msgname,
89415 .skb_msgname = sctp_inet6_skb_msgname,
89416 .af_supported = sctp_inet6_af_supported,
89417 @@ -1038,7 +1038,7 @@ void sctp_v6_pf_init(void)
89418
89419 void sctp_v6_pf_exit(void)
89420 {
89421 - list_del(&sctp_af_inet6.list);
89422 + pax_list_del(&sctp_af_inet6.list);
89423 }
89424
89425 /* Initialize IPv6 support and register with socket layer. */
89426 diff --git a/net/sctp/probe.c b/net/sctp/probe.c
89427 index ad0dba8..e62c225 100644
89428 --- a/net/sctp/probe.c
89429 +++ b/net/sctp/probe.c
89430 @@ -63,7 +63,7 @@ static struct {
89431 struct timespec tstart;
89432 } sctpw;
89433
89434 -static void printl(const char *fmt, ...)
89435 +static __printf(1, 2) void printl(const char *fmt, ...)
89436 {
89437 va_list args;
89438 int len;
89439 diff --git a/net/sctp/proc.c b/net/sctp/proc.c
89440 index ab3bba8..2fbab4e 100644
89441 --- a/net/sctp/proc.c
89442 +++ b/net/sctp/proc.c
89443 @@ -336,7 +336,8 @@ static int sctp_assocs_seq_show(struct seq_file *seq, void *v)
89444 seq_printf(seq,
89445 "%8pK %8pK %-3d %-3d %-2d %-4d "
89446 "%4d %8d %8d %7d %5lu %-5d %5d ",
89447 - assoc, sk, sctp_sk(sk)->type, sk->sk_state,
89448 + assoc, sk,
89449 + sctp_sk(sk)->type, sk->sk_state,
89450 assoc->state, hash,
89451 assoc->assoc_id,
89452 assoc->sndbuf_used,
89453 diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
89454 index 1c2e46c..f91cf5e 100644
89455 --- a/net/sctp/protocol.c
89456 +++ b/net/sctp/protocol.c
89457 @@ -834,8 +834,10 @@ int sctp_register_af(struct sctp_af *af)
89458 return 0;
89459 }
89460
89461 + pax_open_kernel();
89462 INIT_LIST_HEAD(&af->list);
89463 - list_add_tail(&af->list, &sctp_address_families);
89464 + pax_close_kernel();
89465 + pax_list_add_tail(&af->list, &sctp_address_families);
89466 return 1;
89467 }
89468
89469 @@ -966,7 +968,7 @@ static inline int sctp_v4_xmit(struct sk_buff *skb,
89470
89471 static struct sctp_af sctp_af_inet;
89472
89473 -static struct sctp_pf sctp_pf_inet = {
89474 +static struct sctp_pf sctp_pf_inet __read_only = {
89475 .event_msgname = sctp_inet_event_msgname,
89476 .skb_msgname = sctp_inet_skb_msgname,
89477 .af_supported = sctp_inet_af_supported,
89478 @@ -1037,7 +1039,7 @@ static const struct net_protocol sctp_protocol = {
89479 };
89480
89481 /* IPv4 address related functions. */
89482 -static struct sctp_af sctp_af_inet = {
89483 +static struct sctp_af sctp_af_inet __read_only = {
89484 .sa_family = AF_INET,
89485 .sctp_xmit = sctp_v4_xmit,
89486 .setsockopt = ip_setsockopt,
89487 @@ -1122,7 +1124,7 @@ static void sctp_v4_pf_init(void)
89488
89489 static void sctp_v4_pf_exit(void)
89490 {
89491 - list_del(&sctp_af_inet.list);
89492 + pax_list_del(&sctp_af_inet.list);
89493 }
89494
89495 static int sctp_v4_protosw_init(void)
89496 diff --git a/net/sctp/sm_sideeffect.c b/net/sctp/sm_sideeffect.c
89497 index 8aab894..f6b7e7d 100644
89498 --- a/net/sctp/sm_sideeffect.c
89499 +++ b/net/sctp/sm_sideeffect.c
89500 @@ -447,7 +447,7 @@ static void sctp_generate_sack_event(unsigned long data)
89501 sctp_generate_timeout_event(asoc, SCTP_EVENT_TIMEOUT_SACK);
89502 }
89503
89504 -sctp_timer_event_t *sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES] = {
89505 +sctp_timer_event_t * const sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES] = {
89506 NULL,
89507 sctp_generate_t1_cookie_event,
89508 sctp_generate_t1_init_event,
89509 diff --git a/net/sctp/socket.c b/net/sctp/socket.c
89510 index b907073..57fef6c 100644
89511 --- a/net/sctp/socket.c
89512 +++ b/net/sctp/socket.c
89513 @@ -2166,11 +2166,13 @@ static int sctp_setsockopt_events(struct sock *sk, char __user *optval,
89514 {
89515 struct sctp_association *asoc;
89516 struct sctp_ulpevent *event;
89517 + struct sctp_event_subscribe subscribe;
89518
89519 if (optlen > sizeof(struct sctp_event_subscribe))
89520 return -EINVAL;
89521 - if (copy_from_user(&sctp_sk(sk)->subscribe, optval, optlen))
89522 + if (copy_from_user(&subscribe, optval, optlen))
89523 return -EFAULT;
89524 + sctp_sk(sk)->subscribe = subscribe;
89525
89526 /*
89527 * At the time when a user app subscribes to SCTP_SENDER_DRY_EVENT,
89528 @@ -4215,13 +4217,16 @@ static int sctp_getsockopt_disable_fragments(struct sock *sk, int len,
89529 static int sctp_getsockopt_events(struct sock *sk, int len, char __user *optval,
89530 int __user *optlen)
89531 {
89532 + struct sctp_event_subscribe subscribe;
89533 +
89534 if (len <= 0)
89535 return -EINVAL;
89536 if (len > sizeof(struct sctp_event_subscribe))
89537 len = sizeof(struct sctp_event_subscribe);
89538 if (put_user(len, optlen))
89539 return -EFAULT;
89540 - if (copy_to_user(optval, &sctp_sk(sk)->subscribe, len))
89541 + subscribe = sctp_sk(sk)->subscribe;
89542 + if (copy_to_user(optval, &subscribe, len))
89543 return -EFAULT;
89544 return 0;
89545 }
89546 @@ -4239,6 +4244,8 @@ static int sctp_getsockopt_events(struct sock *sk, int len, char __user *optval,
89547 */
89548 static int sctp_getsockopt_autoclose(struct sock *sk, int len, char __user *optval, int __user *optlen)
89549 {
89550 + __u32 autoclose;
89551 +
89552 /* Applicable to UDP-style socket only */
89553 if (sctp_style(sk, TCP))
89554 return -EOPNOTSUPP;
89555 @@ -4247,7 +4254,8 @@ static int sctp_getsockopt_autoclose(struct sock *sk, int len, char __user *optv
89556 len = sizeof(int);
89557 if (put_user(len, optlen))
89558 return -EFAULT;
89559 - if (copy_to_user(optval, &sctp_sk(sk)->autoclose, sizeof(int)))
89560 + autoclose = sctp_sk(sk)->autoclose;
89561 + if (copy_to_user(optval, &autoclose, sizeof(int)))
89562 return -EFAULT;
89563 return 0;
89564 }
89565 @@ -4619,12 +4627,15 @@ static int sctp_getsockopt_delayed_ack(struct sock *sk, int len,
89566 */
89567 static int sctp_getsockopt_initmsg(struct sock *sk, int len, char __user *optval, int __user *optlen)
89568 {
89569 + struct sctp_initmsg initmsg;
89570 +
89571 if (len < sizeof(struct sctp_initmsg))
89572 return -EINVAL;
89573 len = sizeof(struct sctp_initmsg);
89574 if (put_user(len, optlen))
89575 return -EFAULT;
89576 - if (copy_to_user(optval, &sctp_sk(sk)->initmsg, len))
89577 + initmsg = sctp_sk(sk)->initmsg;
89578 + if (copy_to_user(optval, &initmsg, len))
89579 return -EFAULT;
89580 return 0;
89581 }
89582 @@ -4665,6 +4676,8 @@ static int sctp_getsockopt_peer_addrs(struct sock *sk, int len,
89583 addrlen = sctp_get_af_specific(temp.sa.sa_family)->sockaddr_len;
89584 if (space_left < addrlen)
89585 return -ENOMEM;
89586 + if (addrlen > sizeof(temp) || addrlen < 0)
89587 + return -EFAULT;
89588 if (copy_to_user(to, &temp, addrlen))
89589 return -EFAULT;
89590 to += addrlen;
89591 diff --git a/net/sctp/sysctl.c b/net/sctp/sysctl.c
89592 index bf3c6e8..376d8d0 100644
89593 --- a/net/sctp/sysctl.c
89594 +++ b/net/sctp/sysctl.c
89595 @@ -307,7 +307,7 @@ static int proc_sctp_do_hmac_alg(ctl_table *ctl,
89596 {
89597 struct net *net = current->nsproxy->net_ns;
89598 char tmp[8];
89599 - ctl_table tbl;
89600 + ctl_table_no_const tbl;
89601 int ret;
89602 int changed = 0;
89603 char *none = "none";
89604 @@ -350,7 +350,7 @@ static int proc_sctp_do_hmac_alg(ctl_table *ctl,
89605
89606 int sctp_sysctl_net_register(struct net *net)
89607 {
89608 - struct ctl_table *table;
89609 + ctl_table_no_const *table;
89610 int i;
89611
89612 table = kmemdup(sctp_net_table, sizeof(sctp_net_table), GFP_KERNEL);
89613 diff --git a/net/socket.c b/net/socket.c
89614 index 88f759a..c6933de 100644
89615 --- a/net/socket.c
89616 +++ b/net/socket.c
89617 @@ -88,6 +88,7 @@
89618 #include <linux/magic.h>
89619 #include <linux/slab.h>
89620 #include <linux/xattr.h>
89621 +#include <linux/in.h>
89622
89623 #include <asm/uaccess.h>
89624 #include <asm/unistd.h>
89625 @@ -105,6 +106,8 @@
89626 #include <linux/sockios.h>
89627 #include <linux/atalk.h>
89628
89629 +#include <linux/grsock.h>
89630 +
89631 static int sock_no_open(struct inode *irrelevant, struct file *dontcare);
89632 static ssize_t sock_aio_read(struct kiocb *iocb, const struct iovec *iov,
89633 unsigned long nr_segs, loff_t pos);
89634 @@ -321,7 +324,7 @@ static struct dentry *sockfs_mount(struct file_system_type *fs_type,
89635 &sockfs_dentry_operations, SOCKFS_MAGIC);
89636 }
89637
89638 -static struct vfsmount *sock_mnt __read_mostly;
89639 +struct vfsmount *sock_mnt __read_mostly;
89640
89641 static struct file_system_type sock_fs_type = {
89642 .name = "sockfs",
89643 @@ -1268,6 +1271,8 @@ int __sock_create(struct net *net, int family, int type, int protocol,
89644 return -EAFNOSUPPORT;
89645 if (type < 0 || type >= SOCK_MAX)
89646 return -EINVAL;
89647 + if (protocol < 0)
89648 + return -EINVAL;
89649
89650 /* Compatibility.
89651
89652 @@ -1399,6 +1404,16 @@ SYSCALL_DEFINE3(socket, int, family, int, type, int, protocol)
89653 if (SOCK_NONBLOCK != O_NONBLOCK && (flags & SOCK_NONBLOCK))
89654 flags = (flags & ~SOCK_NONBLOCK) | O_NONBLOCK;
89655
89656 + if(!gr_search_socket(family, type, protocol)) {
89657 + retval = -EACCES;
89658 + goto out;
89659 + }
89660 +
89661 + if (gr_handle_sock_all(family, type, protocol)) {
89662 + retval = -EACCES;
89663 + goto out;
89664 + }
89665 +
89666 retval = sock_create(family, type, protocol, &sock);
89667 if (retval < 0)
89668 goto out;
89669 @@ -1526,6 +1541,14 @@ SYSCALL_DEFINE3(bind, int, fd, struct sockaddr __user *, umyaddr, int, addrlen)
89670 if (sock) {
89671 err = move_addr_to_kernel(umyaddr, addrlen, &address);
89672 if (err >= 0) {
89673 + if (gr_handle_sock_server((struct sockaddr *)&address)) {
89674 + err = -EACCES;
89675 + goto error;
89676 + }
89677 + err = gr_search_bind(sock, (struct sockaddr_in *)&address);
89678 + if (err)
89679 + goto error;
89680 +
89681 err = security_socket_bind(sock,
89682 (struct sockaddr *)&address,
89683 addrlen);
89684 @@ -1534,6 +1557,7 @@ SYSCALL_DEFINE3(bind, int, fd, struct sockaddr __user *, umyaddr, int, addrlen)
89685 (struct sockaddr *)
89686 &address, addrlen);
89687 }
89688 +error:
89689 fput_light(sock->file, fput_needed);
89690 }
89691 return err;
89692 @@ -1557,10 +1581,20 @@ SYSCALL_DEFINE2(listen, int, fd, int, backlog)
89693 if ((unsigned int)backlog > somaxconn)
89694 backlog = somaxconn;
89695
89696 + if (gr_handle_sock_server_other(sock->sk)) {
89697 + err = -EPERM;
89698 + goto error;
89699 + }
89700 +
89701 + err = gr_search_listen(sock);
89702 + if (err)
89703 + goto error;
89704 +
89705 err = security_socket_listen(sock, backlog);
89706 if (!err)
89707 err = sock->ops->listen(sock, backlog);
89708
89709 +error:
89710 fput_light(sock->file, fput_needed);
89711 }
89712 return err;
89713 @@ -1604,6 +1638,18 @@ SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr,
89714 newsock->type = sock->type;
89715 newsock->ops = sock->ops;
89716
89717 + if (gr_handle_sock_server_other(sock->sk)) {
89718 + err = -EPERM;
89719 + sock_release(newsock);
89720 + goto out_put;
89721 + }
89722 +
89723 + err = gr_search_accept(sock);
89724 + if (err) {
89725 + sock_release(newsock);
89726 + goto out_put;
89727 + }
89728 +
89729 /*
89730 * We don't need try_module_get here, as the listening socket (sock)
89731 * has the protocol module (sock->ops->owner) held.
89732 @@ -1649,6 +1695,8 @@ SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr,
89733 fd_install(newfd, newfile);
89734 err = newfd;
89735
89736 + gr_attach_curr_ip(newsock->sk);
89737 +
89738 out_put:
89739 fput_light(sock->file, fput_needed);
89740 out:
89741 @@ -1681,6 +1729,7 @@ SYSCALL_DEFINE3(connect, int, fd, struct sockaddr __user *, uservaddr,
89742 int, addrlen)
89743 {
89744 struct socket *sock;
89745 + struct sockaddr *sck;
89746 struct sockaddr_storage address;
89747 int err, fput_needed;
89748
89749 @@ -1691,6 +1740,17 @@ SYSCALL_DEFINE3(connect, int, fd, struct sockaddr __user *, uservaddr,
89750 if (err < 0)
89751 goto out_put;
89752
89753 + sck = (struct sockaddr *)&address;
89754 +
89755 + if (gr_handle_sock_client(sck)) {
89756 + err = -EACCES;
89757 + goto out_put;
89758 + }
89759 +
89760 + err = gr_search_connect(sock, (struct sockaddr_in *)sck);
89761 + if (err)
89762 + goto out_put;
89763 +
89764 err =
89765 security_socket_connect(sock, (struct sockaddr *)&address, addrlen);
89766 if (err)
89767 @@ -1772,6 +1832,8 @@ SYSCALL_DEFINE3(getpeername, int, fd, struct sockaddr __user *, usockaddr,
89768 * the protocol.
89769 */
89770
89771 +asmlinkage long sys_sendto(int, void *, size_t, unsigned, struct sockaddr *, int);
89772 +
89773 SYSCALL_DEFINE6(sendto, int, fd, void __user *, buff, size_t, len,
89774 unsigned int, flags, struct sockaddr __user *, addr,
89775 int, addr_len)
89776 @@ -1838,7 +1900,7 @@ SYSCALL_DEFINE6(recvfrom, int, fd, void __user *, ubuf, size_t, size,
89777 struct socket *sock;
89778 struct iovec iov;
89779 struct msghdr msg;
89780 - struct sockaddr_storage address;
89781 + struct sockaddr_storage address = { };
89782 int err, err2;
89783 int fput_needed;
89784
89785 @@ -2045,7 +2107,7 @@ static int __sys_sendmsg(struct socket *sock, struct msghdr __user *msg,
89786 * checking falls down on this.
89787 */
89788 if (copy_from_user(ctl_buf,
89789 - (void __user __force *)msg_sys->msg_control,
89790 + (void __force_user *)msg_sys->msg_control,
89791 ctl_len))
89792 goto out_freectl;
89793 msg_sys->msg_control = ctl_buf;
89794 @@ -2185,7 +2247,7 @@ static int __sys_recvmsg(struct socket *sock, struct msghdr __user *msg,
89795 int err, total_len, len;
89796
89797 /* kernel mode address */
89798 - struct sockaddr_storage addr;
89799 + struct sockaddr_storage addr = { };
89800
89801 /* user mode address pointers */
89802 struct sockaddr __user *uaddr;
89803 @@ -2213,7 +2275,7 @@ static int __sys_recvmsg(struct socket *sock, struct msghdr __user *msg,
89804 * kernel msghdr to use the kernel address space)
89805 */
89806
89807 - uaddr = (__force void __user *)msg_sys->msg_name;
89808 + uaddr = (void __force_user *)msg_sys->msg_name;
89809 uaddr_len = COMPAT_NAMELEN(msg);
89810 if (MSG_CMSG_COMPAT & flags) {
89811 err = verify_compat_iovec(msg_sys, iov, &addr, VERIFY_WRITE);
89812 @@ -2952,7 +3014,7 @@ static int bond_ioctl(struct net *net, unsigned int cmd,
89813 old_fs = get_fs();
89814 set_fs(KERNEL_DS);
89815 err = dev_ioctl(net, cmd,
89816 - (struct ifreq __user __force *) &kifr);
89817 + (struct ifreq __force_user *) &kifr);
89818 set_fs(old_fs);
89819
89820 return err;
89821 @@ -3061,7 +3123,7 @@ static int compat_sioc_ifmap(struct net *net, unsigned int cmd,
89822
89823 old_fs = get_fs();
89824 set_fs(KERNEL_DS);
89825 - err = dev_ioctl(net, cmd, (void __user __force *)&ifr);
89826 + err = dev_ioctl(net, cmd, (void __force_user *)&ifr);
89827 set_fs(old_fs);
89828
89829 if (cmd == SIOCGIFMAP && !err) {
89830 @@ -3166,7 +3228,7 @@ static int routing_ioctl(struct net *net, struct socket *sock,
89831 ret |= __get_user(rtdev, &(ur4->rt_dev));
89832 if (rtdev) {
89833 ret |= copy_from_user(devname, compat_ptr(rtdev), 15);
89834 - r4.rt_dev = (char __user __force *)devname;
89835 + r4.rt_dev = (char __force_user *)devname;
89836 devname[15] = 0;
89837 } else
89838 r4.rt_dev = NULL;
89839 @@ -3392,8 +3454,8 @@ int kernel_getsockopt(struct socket *sock, int level, int optname,
89840 int __user *uoptlen;
89841 int err;
89842
89843 - uoptval = (char __user __force *) optval;
89844 - uoptlen = (int __user __force *) optlen;
89845 + uoptval = (char __force_user *) optval;
89846 + uoptlen = (int __force_user *) optlen;
89847
89848 set_fs(KERNEL_DS);
89849 if (level == SOL_SOCKET)
89850 @@ -3413,7 +3475,7 @@ int kernel_setsockopt(struct socket *sock, int level, int optname,
89851 char __user *uoptval;
89852 int err;
89853
89854 - uoptval = (char __user __force *) optval;
89855 + uoptval = (char __force_user *) optval;
89856
89857 set_fs(KERNEL_DS);
89858 if (level == SOL_SOCKET)
89859 diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
89860 index d5f35f1..da2680b5 100644
89861 --- a/net/sunrpc/clnt.c
89862 +++ b/net/sunrpc/clnt.c
89863 @@ -1283,7 +1283,9 @@ call_start(struct rpc_task *task)
89864 (RPC_IS_ASYNC(task) ? "async" : "sync"));
89865
89866 /* Increment call count */
89867 - task->tk_msg.rpc_proc->p_count++;
89868 + pax_open_kernel();
89869 + (*(unsigned int *)&task->tk_msg.rpc_proc->p_count)++;
89870 + pax_close_kernel();
89871 clnt->cl_stats->rpccnt++;
89872 task->tk_action = call_reserve;
89873 }
89874 diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c
89875 index 5356b12..c0f4c29 100644
89876 --- a/net/sunrpc/sched.c
89877 +++ b/net/sunrpc/sched.c
89878 @@ -261,9 +261,9 @@ static int rpc_wait_bit_killable(void *word)
89879 #ifdef RPC_DEBUG
89880 static void rpc_task_set_debuginfo(struct rpc_task *task)
89881 {
89882 - static atomic_t rpc_pid;
89883 + static atomic_unchecked_t rpc_pid;
89884
89885 - task->tk_pid = atomic_inc_return(&rpc_pid);
89886 + task->tk_pid = atomic_inc_return_unchecked(&rpc_pid);
89887 }
89888 #else
89889 static inline void rpc_task_set_debuginfo(struct rpc_task *task)
89890 diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c
89891 index 89a588b..ba2cef8 100644
89892 --- a/net/sunrpc/svc.c
89893 +++ b/net/sunrpc/svc.c
89894 @@ -1160,7 +1160,9 @@ svc_process_common(struct svc_rqst *rqstp, struct kvec *argv, struct kvec *resv)
89895 svc_putnl(resv, RPC_SUCCESS);
89896
89897 /* Bump per-procedure stats counter */
89898 - procp->pc_count++;
89899 + pax_open_kernel();
89900 + (*(unsigned int *)&procp->pc_count)++;
89901 + pax_close_kernel();
89902
89903 /* Initialize storage for argp and resp */
89904 memset(rqstp->rq_argp, 0, procp->pc_argsize);
89905 diff --git a/net/sunrpc/xprtrdma/svc_rdma.c b/net/sunrpc/xprtrdma/svc_rdma.c
89906 index 8343737..677025e 100644
89907 --- a/net/sunrpc/xprtrdma/svc_rdma.c
89908 +++ b/net/sunrpc/xprtrdma/svc_rdma.c
89909 @@ -62,15 +62,15 @@ unsigned int svcrdma_max_req_size = RPCRDMA_MAX_REQ_SIZE;
89910 static unsigned int min_max_inline = 4096;
89911 static unsigned int max_max_inline = 65536;
89912
89913 -atomic_t rdma_stat_recv;
89914 -atomic_t rdma_stat_read;
89915 -atomic_t rdma_stat_write;
89916 -atomic_t rdma_stat_sq_starve;
89917 -atomic_t rdma_stat_rq_starve;
89918 -atomic_t rdma_stat_rq_poll;
89919 -atomic_t rdma_stat_rq_prod;
89920 -atomic_t rdma_stat_sq_poll;
89921 -atomic_t rdma_stat_sq_prod;
89922 +atomic_unchecked_t rdma_stat_recv;
89923 +atomic_unchecked_t rdma_stat_read;
89924 +atomic_unchecked_t rdma_stat_write;
89925 +atomic_unchecked_t rdma_stat_sq_starve;
89926 +atomic_unchecked_t rdma_stat_rq_starve;
89927 +atomic_unchecked_t rdma_stat_rq_poll;
89928 +atomic_unchecked_t rdma_stat_rq_prod;
89929 +atomic_unchecked_t rdma_stat_sq_poll;
89930 +atomic_unchecked_t rdma_stat_sq_prod;
89931
89932 /* Temporary NFS request map and context caches */
89933 struct kmem_cache *svc_rdma_map_cachep;
89934 @@ -110,7 +110,7 @@ static int read_reset_stat(ctl_table *table, int write,
89935 len -= *ppos;
89936 if (len > *lenp)
89937 len = *lenp;
89938 - if (len && copy_to_user(buffer, str_buf, len))
89939 + if (len > sizeof str_buf || (len && copy_to_user(buffer, str_buf, len)))
89940 return -EFAULT;
89941 *lenp = len;
89942 *ppos += len;
89943 @@ -151,63 +151,63 @@ static ctl_table svcrdma_parm_table[] = {
89944 {
89945 .procname = "rdma_stat_read",
89946 .data = &rdma_stat_read,
89947 - .maxlen = sizeof(atomic_t),
89948 + .maxlen = sizeof(atomic_unchecked_t),
89949 .mode = 0644,
89950 .proc_handler = read_reset_stat,
89951 },
89952 {
89953 .procname = "rdma_stat_recv",
89954 .data = &rdma_stat_recv,
89955 - .maxlen = sizeof(atomic_t),
89956 + .maxlen = sizeof(atomic_unchecked_t),
89957 .mode = 0644,
89958 .proc_handler = read_reset_stat,
89959 },
89960 {
89961 .procname = "rdma_stat_write",
89962 .data = &rdma_stat_write,
89963 - .maxlen = sizeof(atomic_t),
89964 + .maxlen = sizeof(atomic_unchecked_t),
89965 .mode = 0644,
89966 .proc_handler = read_reset_stat,
89967 },
89968 {
89969 .procname = "rdma_stat_sq_starve",
89970 .data = &rdma_stat_sq_starve,
89971 - .maxlen = sizeof(atomic_t),
89972 + .maxlen = sizeof(atomic_unchecked_t),
89973 .mode = 0644,
89974 .proc_handler = read_reset_stat,
89975 },
89976 {
89977 .procname = "rdma_stat_rq_starve",
89978 .data = &rdma_stat_rq_starve,
89979 - .maxlen = sizeof(atomic_t),
89980 + .maxlen = sizeof(atomic_unchecked_t),
89981 .mode = 0644,
89982 .proc_handler = read_reset_stat,
89983 },
89984 {
89985 .procname = "rdma_stat_rq_poll",
89986 .data = &rdma_stat_rq_poll,
89987 - .maxlen = sizeof(atomic_t),
89988 + .maxlen = sizeof(atomic_unchecked_t),
89989 .mode = 0644,
89990 .proc_handler = read_reset_stat,
89991 },
89992 {
89993 .procname = "rdma_stat_rq_prod",
89994 .data = &rdma_stat_rq_prod,
89995 - .maxlen = sizeof(atomic_t),
89996 + .maxlen = sizeof(atomic_unchecked_t),
89997 .mode = 0644,
89998 .proc_handler = read_reset_stat,
89999 },
90000 {
90001 .procname = "rdma_stat_sq_poll",
90002 .data = &rdma_stat_sq_poll,
90003 - .maxlen = sizeof(atomic_t),
90004 + .maxlen = sizeof(atomic_unchecked_t),
90005 .mode = 0644,
90006 .proc_handler = read_reset_stat,
90007 },
90008 {
90009 .procname = "rdma_stat_sq_prod",
90010 .data = &rdma_stat_sq_prod,
90011 - .maxlen = sizeof(atomic_t),
90012 + .maxlen = sizeof(atomic_unchecked_t),
90013 .mode = 0644,
90014 .proc_handler = read_reset_stat,
90015 },
90016 diff --git a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
90017 index 0ce7552..d074459 100644
90018 --- a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
90019 +++ b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
90020 @@ -501,7 +501,7 @@ next_sge:
90021 svc_rdma_put_context(ctxt, 0);
90022 goto out;
90023 }
90024 - atomic_inc(&rdma_stat_read);
90025 + atomic_inc_unchecked(&rdma_stat_read);
90026
90027 if (read_wr.num_sge < chl_map->ch[ch_no].count) {
90028 chl_map->ch[ch_no].count -= read_wr.num_sge;
90029 @@ -611,7 +611,7 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp)
90030 dto_q);
90031 list_del_init(&ctxt->dto_q);
90032 } else {
90033 - atomic_inc(&rdma_stat_rq_starve);
90034 + atomic_inc_unchecked(&rdma_stat_rq_starve);
90035 clear_bit(XPT_DATA, &xprt->xpt_flags);
90036 ctxt = NULL;
90037 }
90038 @@ -631,7 +631,7 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp)
90039 dprintk("svcrdma: processing ctxt=%p on xprt=%p, rqstp=%p, status=%d\n",
90040 ctxt, rdma_xprt, rqstp, ctxt->wc_status);
90041 BUG_ON(ctxt->wc_status != IB_WC_SUCCESS);
90042 - atomic_inc(&rdma_stat_recv);
90043 + atomic_inc_unchecked(&rdma_stat_recv);
90044
90045 /* Build up the XDR from the receive buffers. */
90046 rdma_build_arg_xdr(rqstp, ctxt, ctxt->byte_len);
90047 diff --git a/net/sunrpc/xprtrdma/svc_rdma_sendto.c b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
90048 index c1d124d..acfc59e 100644
90049 --- a/net/sunrpc/xprtrdma/svc_rdma_sendto.c
90050 +++ b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
90051 @@ -362,7 +362,7 @@ static int send_write(struct svcxprt_rdma *xprt, struct svc_rqst *rqstp,
90052 write_wr.wr.rdma.remote_addr = to;
90053
90054 /* Post It */
90055 - atomic_inc(&rdma_stat_write);
90056 + atomic_inc_unchecked(&rdma_stat_write);
90057 if (svc_rdma_send(xprt, &write_wr))
90058 goto err;
90059 return 0;
90060 diff --git a/net/sunrpc/xprtrdma/svc_rdma_transport.c b/net/sunrpc/xprtrdma/svc_rdma_transport.c
90061 index 62e4f9b..dd3f2d7 100644
90062 --- a/net/sunrpc/xprtrdma/svc_rdma_transport.c
90063 +++ b/net/sunrpc/xprtrdma/svc_rdma_transport.c
90064 @@ -292,7 +292,7 @@ static void rq_cq_reap(struct svcxprt_rdma *xprt)
90065 return;
90066
90067 ib_req_notify_cq(xprt->sc_rq_cq, IB_CQ_NEXT_COMP);
90068 - atomic_inc(&rdma_stat_rq_poll);
90069 + atomic_inc_unchecked(&rdma_stat_rq_poll);
90070
90071 while ((ret = ib_poll_cq(xprt->sc_rq_cq, 1, &wc)) > 0) {
90072 ctxt = (struct svc_rdma_op_ctxt *)(unsigned long)wc.wr_id;
90073 @@ -314,7 +314,7 @@ static void rq_cq_reap(struct svcxprt_rdma *xprt)
90074 }
90075
90076 if (ctxt)
90077 - atomic_inc(&rdma_stat_rq_prod);
90078 + atomic_inc_unchecked(&rdma_stat_rq_prod);
90079
90080 set_bit(XPT_DATA, &xprt->sc_xprt.xpt_flags);
90081 /*
90082 @@ -386,7 +386,7 @@ static void sq_cq_reap(struct svcxprt_rdma *xprt)
90083 return;
90084
90085 ib_req_notify_cq(xprt->sc_sq_cq, IB_CQ_NEXT_COMP);
90086 - atomic_inc(&rdma_stat_sq_poll);
90087 + atomic_inc_unchecked(&rdma_stat_sq_poll);
90088 while ((ret = ib_poll_cq(cq, 1, &wc)) > 0) {
90089 if (wc.status != IB_WC_SUCCESS)
90090 /* Close the transport */
90091 @@ -404,7 +404,7 @@ static void sq_cq_reap(struct svcxprt_rdma *xprt)
90092 }
90093
90094 if (ctxt)
90095 - atomic_inc(&rdma_stat_sq_prod);
90096 + atomic_inc_unchecked(&rdma_stat_sq_prod);
90097 }
90098
90099 static void sq_comp_handler(struct ib_cq *cq, void *cq_context)
90100 @@ -1262,7 +1262,7 @@ int svc_rdma_send(struct svcxprt_rdma *xprt, struct ib_send_wr *wr)
90101 spin_lock_bh(&xprt->sc_lock);
90102 if (xprt->sc_sq_depth < atomic_read(&xprt->sc_sq_count) + wr_count) {
90103 spin_unlock_bh(&xprt->sc_lock);
90104 - atomic_inc(&rdma_stat_sq_starve);
90105 + atomic_inc_unchecked(&rdma_stat_sq_starve);
90106
90107 /* See if we can opportunistically reap SQ WR to make room */
90108 sq_cq_reap(xprt);
90109 diff --git a/net/sysctl_net.c b/net/sysctl_net.c
90110 index 9bc6db0..47ac8c0 100644
90111 --- a/net/sysctl_net.c
90112 +++ b/net/sysctl_net.c
90113 @@ -46,7 +46,7 @@ static int net_ctl_permissions(struct ctl_table_header *head,
90114 kgid_t root_gid = make_kgid(net->user_ns, 0);
90115
90116 /* Allow network administrator to have same access as root. */
90117 - if (ns_capable(net->user_ns, CAP_NET_ADMIN) ||
90118 + if (ns_capable_nolog(net->user_ns, CAP_NET_ADMIN) ||
90119 uid_eq(root_uid, current_uid())) {
90120 int mode = (table->mode >> 6) & 7;
90121 return (mode << 6) | (mode << 3) | mode;
90122 diff --git a/net/tipc/link.c b/net/tipc/link.c
90123 index daa6080..2bbbe70 100644
90124 --- a/net/tipc/link.c
90125 +++ b/net/tipc/link.c
90126 @@ -1201,7 +1201,7 @@ static int link_send_sections_long(struct tipc_port *sender,
90127 struct tipc_msg fragm_hdr;
90128 struct sk_buff *buf, *buf_chain, *prev;
90129 u32 fragm_crs, fragm_rest, hsz, sect_rest;
90130 - const unchar *sect_crs;
90131 + const unchar __user *sect_crs;
90132 int curr_sect;
90133 u32 fragm_no;
90134
90135 @@ -1242,7 +1242,7 @@ again:
90136
90137 if (!sect_rest) {
90138 sect_rest = msg_sect[++curr_sect].iov_len;
90139 - sect_crs = (const unchar *)msg_sect[curr_sect].iov_base;
90140 + sect_crs = (const unchar __user *)msg_sect[curr_sect].iov_base;
90141 }
90142
90143 if (sect_rest < fragm_rest)
90144 @@ -1261,7 +1261,7 @@ error:
90145 }
90146 } else
90147 skb_copy_to_linear_data_offset(buf, fragm_crs,
90148 - sect_crs, sz);
90149 + (const void __force_kernel *)sect_crs, sz);
90150 sect_crs += sz;
90151 sect_rest -= sz;
90152 fragm_crs += sz;
90153 @@ -2306,8 +2306,11 @@ static int link_recv_changeover_msg(struct tipc_link **l_ptr,
90154 struct tipc_msg *tunnel_msg = buf_msg(tunnel_buf);
90155 u32 msg_typ = msg_type(tunnel_msg);
90156 u32 msg_count = msg_msgcnt(tunnel_msg);
90157 + u32 bearer_id = msg_bearer_id(tunnel_msg);
90158
90159 - dest_link = (*l_ptr)->owner->links[msg_bearer_id(tunnel_msg)];
90160 + if (bearer_id >= MAX_BEARERS)
90161 + goto exit;
90162 + dest_link = (*l_ptr)->owner->links[bearer_id];
90163 if (!dest_link)
90164 goto exit;
90165 if (dest_link == *l_ptr) {
90166 @@ -2521,14 +2524,16 @@ int tipc_link_recv_fragment(struct sk_buff **pending, struct sk_buff **fb,
90167 struct tipc_msg *imsg = (struct tipc_msg *)msg_data(fragm);
90168 u32 msg_sz = msg_size(imsg);
90169 u32 fragm_sz = msg_data_sz(fragm);
90170 - u32 exp_fragm_cnt = msg_sz/fragm_sz + !!(msg_sz % fragm_sz);
90171 + u32 exp_fragm_cnt;
90172 u32 max = TIPC_MAX_USER_MSG_SIZE + NAMED_H_SIZE;
90173 +
90174 if (msg_type(imsg) == TIPC_MCAST_MSG)
90175 max = TIPC_MAX_USER_MSG_SIZE + MCAST_H_SIZE;
90176 - if (msg_size(imsg) > max) {
90177 + if (fragm_sz == 0 || msg_size(imsg) > max) {
90178 kfree_skb(fbuf);
90179 return 0;
90180 }
90181 + exp_fragm_cnt = msg_sz / fragm_sz + !!(msg_sz % fragm_sz);
90182 pbuf = tipc_buf_acquire(msg_size(imsg));
90183 if (pbuf != NULL) {
90184 pbuf->next = *pending;
90185 diff --git a/net/tipc/msg.c b/net/tipc/msg.c
90186 index f2db8a8..9245aa4 100644
90187 --- a/net/tipc/msg.c
90188 +++ b/net/tipc/msg.c
90189 @@ -98,7 +98,7 @@ int tipc_msg_build(struct tipc_msg *hdr, struct iovec const *msg_sect,
90190 msg_sect[cnt].iov_len);
90191 else
90192 skb_copy_to_linear_data_offset(*buf, pos,
90193 - msg_sect[cnt].iov_base,
90194 + (const void __force_kernel *)msg_sect[cnt].iov_base,
90195 msg_sect[cnt].iov_len);
90196 pos += msg_sect[cnt].iov_len;
90197 }
90198 diff --git a/net/tipc/subscr.c b/net/tipc/subscr.c
90199 index 6b42d47..2ac24d5 100644
90200 --- a/net/tipc/subscr.c
90201 +++ b/net/tipc/subscr.c
90202 @@ -96,7 +96,7 @@ static void subscr_send_event(struct tipc_subscription *sub,
90203 {
90204 struct iovec msg_sect;
90205
90206 - msg_sect.iov_base = (void *)&sub->evt;
90207 + msg_sect.iov_base = (void __force_user *)&sub->evt;
90208 msg_sect.iov_len = sizeof(struct tipc_event);
90209
90210 sub->evt.event = htohl(event, sub->swap);
90211 diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
90212 index 2db702d..09a77488 100644
90213 --- a/net/unix/af_unix.c
90214 +++ b/net/unix/af_unix.c
90215 @@ -783,6 +783,12 @@ static struct sock *unix_find_other(struct net *net,
90216 err = -ECONNREFUSED;
90217 if (!S_ISSOCK(inode->i_mode))
90218 goto put_fail;
90219 +
90220 + if (!gr_acl_handle_unix(path.dentry, path.mnt)) {
90221 + err = -EACCES;
90222 + goto put_fail;
90223 + }
90224 +
90225 u = unix_find_socket_byinode(inode);
90226 if (!u)
90227 goto put_fail;
90228 @@ -803,6 +809,13 @@ static struct sock *unix_find_other(struct net *net,
90229 if (u) {
90230 struct dentry *dentry;
90231 dentry = unix_sk(u)->path.dentry;
90232 +
90233 + if (!gr_handle_chroot_unix(pid_vnr(u->sk_peer_pid))) {
90234 + err = -EPERM;
90235 + sock_put(u);
90236 + goto fail;
90237 + }
90238 +
90239 if (dentry)
90240 touch_atime(&unix_sk(u)->path);
90241 } else
90242 @@ -836,12 +849,18 @@ static int unix_mknod(const char *sun_path, umode_t mode, struct path *res)
90243 */
90244 err = security_path_mknod(&path, dentry, mode, 0);
90245 if (!err) {
90246 + if (!gr_acl_handle_mknod(dentry, path.dentry, path.mnt, mode)) {
90247 + err = -EACCES;
90248 + goto out;
90249 + }
90250 err = vfs_mknod(path.dentry->d_inode, dentry, mode, 0);
90251 if (!err) {
90252 res->mnt = mntget(path.mnt);
90253 res->dentry = dget(dentry);
90254 + gr_handle_create(dentry, path.mnt);
90255 }
90256 }
90257 +out:
90258 done_path_create(&path, dentry);
90259 return err;
90260 }
90261 @@ -2323,9 +2342,13 @@ static int unix_seq_show(struct seq_file *seq, void *v)
90262 seq_puts(seq, "Num RefCount Protocol Flags Type St "
90263 "Inode Path\n");
90264 else {
90265 - struct sock *s = v;
90266 + struct sock *s = v, *peer;
90267 struct unix_sock *u = unix_sk(s);
90268 unix_state_lock(s);
90269 + peer = unix_peer(s);
90270 + unix_state_unlock(s);
90271 +
90272 + unix_state_double_lock(s, peer);
90273
90274 seq_printf(seq, "%pK: %08X %08X %08X %04X %02X %5lu",
90275 s,
90276 @@ -2352,8 +2375,10 @@ static int unix_seq_show(struct seq_file *seq, void *v)
90277 }
90278 for ( ; i < len; i++)
90279 seq_putc(seq, u->addr->name->sun_path[i]);
90280 - }
90281 - unix_state_unlock(s);
90282 + } else if (peer)
90283 + seq_printf(seq, " P%lu", sock_i_ino(peer));
90284 +
90285 + unix_state_double_unlock(s, peer);
90286 seq_putc(seq, '\n');
90287 }
90288
90289 diff --git a/net/unix/sysctl_net_unix.c b/net/unix/sysctl_net_unix.c
90290 index 8800604..0526440 100644
90291 --- a/net/unix/sysctl_net_unix.c
90292 +++ b/net/unix/sysctl_net_unix.c
90293 @@ -28,7 +28,7 @@ static ctl_table unix_table[] = {
90294
90295 int __net_init unix_sysctl_register(struct net *net)
90296 {
90297 - struct ctl_table *table;
90298 + ctl_table_no_const *table;
90299
90300 table = kmemdup(unix_table, sizeof(unix_table), GFP_KERNEL);
90301 if (table == NULL)
90302 diff --git a/net/wireless/wext-core.c b/net/wireless/wext-core.c
90303 index c8717c1..08539f5 100644
90304 --- a/net/wireless/wext-core.c
90305 +++ b/net/wireless/wext-core.c
90306 @@ -748,8 +748,7 @@ static int ioctl_standard_iw_point(struct iw_point *iwp, unsigned int cmd,
90307 */
90308
90309 /* Support for very large requests */
90310 - if ((descr->flags & IW_DESCR_FLAG_NOMAX) &&
90311 - (user_length > descr->max_tokens)) {
90312 + if (user_length > descr->max_tokens) {
90313 /* Allow userspace to GET more than max so
90314 * we can support any size GET requests.
90315 * There is still a limit : -ENOMEM.
90316 @@ -788,22 +787,6 @@ static int ioctl_standard_iw_point(struct iw_point *iwp, unsigned int cmd,
90317 }
90318 }
90319
90320 - if (IW_IS_GET(cmd) && !(descr->flags & IW_DESCR_FLAG_NOMAX)) {
90321 - /*
90322 - * If this is a GET, but not NOMAX, it means that the extra
90323 - * data is not bounded by userspace, but by max_tokens. Thus
90324 - * set the length to max_tokens. This matches the extra data
90325 - * allocation.
90326 - * The driver should fill it with the number of tokens it
90327 - * provided, and it may check iwp->length rather than having
90328 - * knowledge of max_tokens. If the driver doesn't change the
90329 - * iwp->length, this ioctl just copies back max_token tokens
90330 - * filled with zeroes. Hopefully the driver isn't claiming
90331 - * them to be valid data.
90332 - */
90333 - iwp->length = descr->max_tokens;
90334 - }
90335 -
90336 err = handler(dev, info, (union iwreq_data *) iwp, extra);
90337
90338 iwp->length += essid_compat;
90339 diff --git a/net/xfrm/xfrm_output.c b/net/xfrm/xfrm_output.c
90340 index bcfda89..0cf003d 100644
90341 --- a/net/xfrm/xfrm_output.c
90342 +++ b/net/xfrm/xfrm_output.c
90343 @@ -64,6 +64,7 @@ static int xfrm_output_one(struct sk_buff *skb, int err)
90344
90345 if (unlikely(x->km.state != XFRM_STATE_VALID)) {
90346 XFRM_INC_STATS(net, LINUX_MIB_XFRMOUTSTATEINVALID);
90347 + err = -EINVAL;
90348 goto error;
90349 }
90350
90351 diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
90352 index 167c67d..3f2ae427 100644
90353 --- a/net/xfrm/xfrm_policy.c
90354 +++ b/net/xfrm/xfrm_policy.c
90355 @@ -334,7 +334,7 @@ static void xfrm_policy_kill(struct xfrm_policy *policy)
90356 {
90357 policy->walk.dead = 1;
90358
90359 - atomic_inc(&policy->genid);
90360 + atomic_inc_unchecked(&policy->genid);
90361
90362 del_timer(&policy->polq.hold_timer);
90363 xfrm_queue_purge(&policy->polq.hold_queue);
90364 @@ -659,7 +659,7 @@ int xfrm_policy_insert(int dir, struct xfrm_policy *policy, int excl)
90365 hlist_add_head(&policy->bydst, chain);
90366 xfrm_pol_hold(policy);
90367 net->xfrm.policy_count[dir]++;
90368 - atomic_inc(&flow_cache_genid);
90369 + atomic_inc_unchecked(&flow_cache_genid);
90370 rt_genid_bump(net);
90371 if (delpol) {
90372 xfrm_policy_requeue(delpol, policy);
90373 @@ -1611,7 +1611,7 @@ free_dst:
90374 goto out;
90375 }
90376
90377 -static int inline
90378 +static inline int
90379 xfrm_dst_alloc_copy(void **target, const void *src, int size)
90380 {
90381 if (!*target) {
90382 @@ -1623,7 +1623,7 @@ xfrm_dst_alloc_copy(void **target, const void *src, int size)
90383 return 0;
90384 }
90385
90386 -static int inline
90387 +static inline int
90388 xfrm_dst_update_parent(struct dst_entry *dst, const struct xfrm_selector *sel)
90389 {
90390 #ifdef CONFIG_XFRM_SUB_POLICY
90391 @@ -1635,7 +1635,7 @@ xfrm_dst_update_parent(struct dst_entry *dst, const struct xfrm_selector *sel)
90392 #endif
90393 }
90394
90395 -static int inline
90396 +static inline int
90397 xfrm_dst_update_origin(struct dst_entry *dst, const struct flowi *fl)
90398 {
90399 #ifdef CONFIG_XFRM_SUB_POLICY
90400 @@ -1729,7 +1729,7 @@ xfrm_resolve_and_create_bundle(struct xfrm_policy **pols, int num_pols,
90401
90402 xdst->num_pols = num_pols;
90403 memcpy(xdst->pols, pols, sizeof(struct xfrm_policy*) * num_pols);
90404 - xdst->policy_genid = atomic_read(&pols[0]->genid);
90405 + xdst->policy_genid = atomic_read_unchecked(&pols[0]->genid);
90406
90407 return xdst;
90408 }
90409 @@ -2598,7 +2598,7 @@ static int xfrm_bundle_ok(struct xfrm_dst *first)
90410 if (xdst->xfrm_genid != dst->xfrm->genid)
90411 return 0;
90412 if (xdst->num_pols > 0 &&
90413 - xdst->policy_genid != atomic_read(&xdst->pols[0]->genid))
90414 + xdst->policy_genid != atomic_read_unchecked(&xdst->pols[0]->genid))
90415 return 0;
90416
90417 mtu = dst_mtu(dst->child);
90418 @@ -2686,8 +2686,11 @@ int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo)
90419 dst_ops->link_failure = xfrm_link_failure;
90420 if (likely(dst_ops->neigh_lookup == NULL))
90421 dst_ops->neigh_lookup = xfrm_neigh_lookup;
90422 - if (likely(afinfo->garbage_collect == NULL))
90423 - afinfo->garbage_collect = xfrm_garbage_collect_deferred;
90424 + if (likely(afinfo->garbage_collect == NULL)) {
90425 + pax_open_kernel();
90426 + *(void **)&afinfo->garbage_collect = xfrm_garbage_collect_deferred;
90427 + pax_close_kernel();
90428 + }
90429 rcu_assign_pointer(xfrm_policy_afinfo[afinfo->family], afinfo);
90430 }
90431 spin_unlock(&xfrm_policy_afinfo_lock);
90432 @@ -2741,7 +2744,9 @@ int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo)
90433 dst_ops->check = NULL;
90434 dst_ops->negative_advice = NULL;
90435 dst_ops->link_failure = NULL;
90436 - afinfo->garbage_collect = NULL;
90437 + pax_open_kernel();
90438 + *(void **)&afinfo->garbage_collect = NULL;
90439 + pax_close_kernel();
90440 }
90441 return err;
90442 }
90443 @@ -3124,7 +3129,7 @@ static int xfrm_policy_migrate(struct xfrm_policy *pol,
90444 sizeof(pol->xfrm_vec[i].saddr));
90445 pol->xfrm_vec[i].encap_family = mp->new_family;
90446 /* flush bundles */
90447 - atomic_inc(&pol->genid);
90448 + atomic_inc_unchecked(&pol->genid);
90449 }
90450 }
90451
90452 diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
90453 index 2c341bd..4404211 100644
90454 --- a/net/xfrm/xfrm_state.c
90455 +++ b/net/xfrm/xfrm_state.c
90456 @@ -177,12 +177,14 @@ int xfrm_register_type(const struct xfrm_type *type, unsigned short family)
90457
90458 if (unlikely(afinfo == NULL))
90459 return -EAFNOSUPPORT;
90460 - typemap = afinfo->type_map;
90461 + typemap = (const struct xfrm_type **)afinfo->type_map;
90462 spin_lock_bh(&xfrm_type_lock);
90463
90464 - if (likely(typemap[type->proto] == NULL))
90465 + if (likely(typemap[type->proto] == NULL)) {
90466 + pax_open_kernel();
90467 typemap[type->proto] = type;
90468 - else
90469 + pax_close_kernel();
90470 + } else
90471 err = -EEXIST;
90472 spin_unlock_bh(&xfrm_type_lock);
90473 xfrm_state_put_afinfo(afinfo);
90474 @@ -198,13 +200,16 @@ int xfrm_unregister_type(const struct xfrm_type *type, unsigned short family)
90475
90476 if (unlikely(afinfo == NULL))
90477 return -EAFNOSUPPORT;
90478 - typemap = afinfo->type_map;
90479 + typemap = (const struct xfrm_type **)afinfo->type_map;
90480 spin_lock_bh(&xfrm_type_lock);
90481
90482 if (unlikely(typemap[type->proto] != type))
90483 err = -ENOENT;
90484 - else
90485 + else {
90486 + pax_open_kernel();
90487 typemap[type->proto] = NULL;
90488 + pax_close_kernel();
90489 + }
90490 spin_unlock_bh(&xfrm_type_lock);
90491 xfrm_state_put_afinfo(afinfo);
90492 return err;
90493 @@ -214,7 +219,6 @@ EXPORT_SYMBOL(xfrm_unregister_type);
90494 static const struct xfrm_type *xfrm_get_type(u8 proto, unsigned short family)
90495 {
90496 struct xfrm_state_afinfo *afinfo;
90497 - const struct xfrm_type **typemap;
90498 const struct xfrm_type *type;
90499 int modload_attempted = 0;
90500
90501 @@ -222,9 +226,8 @@ retry:
90502 afinfo = xfrm_state_get_afinfo(family);
90503 if (unlikely(afinfo == NULL))
90504 return NULL;
90505 - typemap = afinfo->type_map;
90506
90507 - type = typemap[proto];
90508 + type = afinfo->type_map[proto];
90509 if (unlikely(type && !try_module_get(type->owner)))
90510 type = NULL;
90511 if (!type && !modload_attempted) {
90512 @@ -258,7 +261,7 @@ int xfrm_register_mode(struct xfrm_mode *mode, int family)
90513 return -EAFNOSUPPORT;
90514
90515 err = -EEXIST;
90516 - modemap = afinfo->mode_map;
90517 + modemap = (struct xfrm_mode **)afinfo->mode_map;
90518 spin_lock_bh(&xfrm_mode_lock);
90519 if (modemap[mode->encap])
90520 goto out;
90521 @@ -267,8 +270,10 @@ int xfrm_register_mode(struct xfrm_mode *mode, int family)
90522 if (!try_module_get(afinfo->owner))
90523 goto out;
90524
90525 - mode->afinfo = afinfo;
90526 + pax_open_kernel();
90527 + *(const void **)&mode->afinfo = afinfo;
90528 modemap[mode->encap] = mode;
90529 + pax_close_kernel();
90530 err = 0;
90531
90532 out:
90533 @@ -292,10 +297,12 @@ int xfrm_unregister_mode(struct xfrm_mode *mode, int family)
90534 return -EAFNOSUPPORT;
90535
90536 err = -ENOENT;
90537 - modemap = afinfo->mode_map;
90538 + modemap = (struct xfrm_mode **)afinfo->mode_map;
90539 spin_lock_bh(&xfrm_mode_lock);
90540 if (likely(modemap[mode->encap] == mode)) {
90541 + pax_open_kernel();
90542 modemap[mode->encap] = NULL;
90543 + pax_close_kernel();
90544 module_put(mode->afinfo->owner);
90545 err = 0;
90546 }
90547 diff --git a/net/xfrm/xfrm_sysctl.c b/net/xfrm/xfrm_sysctl.c
90548 index 05a6e3d..6716ec9 100644
90549 --- a/net/xfrm/xfrm_sysctl.c
90550 +++ b/net/xfrm/xfrm_sysctl.c
90551 @@ -42,7 +42,7 @@ static struct ctl_table xfrm_table[] = {
90552
90553 int __net_init xfrm_sysctl_init(struct net *net)
90554 {
90555 - struct ctl_table *table;
90556 + ctl_table_no_const *table;
90557
90558 __xfrm_sysctl_init(net);
90559
90560 diff --git a/scripts/Makefile.build b/scripts/Makefile.build
90561 index 0e801c3..5c8ad3b 100644
90562 --- a/scripts/Makefile.build
90563 +++ b/scripts/Makefile.build
90564 @@ -111,7 +111,7 @@ endif
90565 endif
90566
90567 # Do not include host rules unless needed
90568 -ifneq ($(hostprogs-y)$(hostprogs-m),)
90569 +ifneq ($(hostprogs-y)$(hostprogs-m)$(hostlibs-y)$(hostlibs-m)$(hostcxxlibs-y)$(hostcxxlibs-m),)
90570 include scripts/Makefile.host
90571 endif
90572
90573 diff --git a/scripts/Makefile.clean b/scripts/Makefile.clean
90574 index 686cb0d..9d653bf 100644
90575 --- a/scripts/Makefile.clean
90576 +++ b/scripts/Makefile.clean
90577 @@ -43,7 +43,8 @@ subdir-ymn := $(addprefix $(obj)/,$(subdir-ymn))
90578 __clean-files := $(extra-y) $(always) \
90579 $(targets) $(clean-files) \
90580 $(host-progs) \
90581 - $(hostprogs-y) $(hostprogs-m) $(hostprogs-)
90582 + $(hostprogs-y) $(hostprogs-m) $(hostprogs-) \
90583 + $(hostlibs-y) $(hostlibs-m) $(hostlibs-)
90584
90585 __clean-files := $(filter-out $(no-clean-files), $(__clean-files))
90586
90587 diff --git a/scripts/Makefile.host b/scripts/Makefile.host
90588 index 1ac414f..38575f7 100644
90589 --- a/scripts/Makefile.host
90590 +++ b/scripts/Makefile.host
90591 @@ -31,6 +31,8 @@
90592 # Note: Shared libraries consisting of C++ files are not supported
90593
90594 __hostprogs := $(sort $(hostprogs-y) $(hostprogs-m))
90595 +__hostlibs := $(sort $(hostlibs-y) $(hostlibs-m))
90596 +__hostcxxlibs := $(sort $(hostcxxlibs-y) $(hostcxxlibs-m))
90597
90598 # C code
90599 # Executables compiled from a single .c file
90600 @@ -54,11 +56,15 @@ host-cxxobjs := $(sort $(foreach m,$(host-cxxmulti),$($(m)-cxxobjs)))
90601 # Shared libaries (only .c supported)
90602 # Shared libraries (.so) - all .so files referenced in "xxx-objs"
90603 host-cshlib := $(sort $(filter %.so, $(host-cobjs)))
90604 +host-cshlib += $(sort $(filter %.so, $(__hostlibs)))
90605 +host-cxxshlib := $(sort $(filter %.so, $(__hostcxxlibs)))
90606 # Remove .so files from "xxx-objs"
90607 host-cobjs := $(filter-out %.so,$(host-cobjs))
90608 +host-cxxobjs := $(filter-out %.so,$(host-cxxobjs))
90609
90610 -#Object (.o) files used by the shared libaries
90611 +# Object (.o) files used by the shared libaries
90612 host-cshobjs := $(sort $(foreach m,$(host-cshlib),$($(m:.so=-objs))))
90613 +host-cxxshobjs := $(sort $(foreach m,$(host-cxxshlib),$($(m:.so=-objs))))
90614
90615 # output directory for programs/.o files
90616 # hostprogs-y := tools/build may have been specified. Retrieve directory
90617 @@ -82,7 +88,9 @@ host-cobjs := $(addprefix $(obj)/,$(host-cobjs))
90618 host-cxxmulti := $(addprefix $(obj)/,$(host-cxxmulti))
90619 host-cxxobjs := $(addprefix $(obj)/,$(host-cxxobjs))
90620 host-cshlib := $(addprefix $(obj)/,$(host-cshlib))
90621 +host-cxxshlib := $(addprefix $(obj)/,$(host-cxxshlib))
90622 host-cshobjs := $(addprefix $(obj)/,$(host-cshobjs))
90623 +host-cxxshobjs := $(addprefix $(obj)/,$(host-cxxshobjs))
90624 host-objdirs := $(addprefix $(obj)/,$(host-objdirs))
90625
90626 obj-dirs += $(host-objdirs)
90627 @@ -156,6 +164,13 @@ quiet_cmd_host-cshobjs = HOSTCC -fPIC $@
90628 $(host-cshobjs): $(obj)/%.o: $(src)/%.c FORCE
90629 $(call if_changed_dep,host-cshobjs)
90630
90631 +# Compile .c file, create position independent .o file
90632 +# host-cxxshobjs -> .o
90633 +quiet_cmd_host-cxxshobjs = HOSTCXX -fPIC $@
90634 + cmd_host-cxxshobjs = $(HOSTCXX) $(hostcxx_flags) -fPIC -c -o $@ $<
90635 +$(host-cxxshobjs): $(obj)/%.o: $(src)/%.c FORCE
90636 + $(call if_changed_dep,host-cxxshobjs)
90637 +
90638 # Link a shared library, based on position independent .o files
90639 # *.o -> .so shared library (host-cshlib)
90640 quiet_cmd_host-cshlib = HOSTLLD -shared $@
90641 @@ -165,6 +180,15 @@ quiet_cmd_host-cshlib = HOSTLLD -shared $@
90642 $(host-cshlib): $(obj)/%: $(host-cshobjs) FORCE
90643 $(call if_changed,host-cshlib)
90644
90645 +# Link a shared library, based on position independent .o files
90646 +# *.o -> .so shared library (host-cxxshlib)
90647 +quiet_cmd_host-cxxshlib = HOSTLLD -shared $@
90648 + cmd_host-cxxshlib = $(HOSTCXX) $(HOSTLDFLAGS) -shared -o $@ \
90649 + $(addprefix $(obj)/,$($(@F:.so=-objs))) \
90650 + $(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F))
90651 +$(host-cxxshlib): $(obj)/%: $(host-cxxshobjs) FORCE
90652 + $(call if_changed,host-cxxshlib)
90653 +
90654 targets += $(host-csingle) $(host-cmulti) $(host-cobjs)\
90655 - $(host-cxxmulti) $(host-cxxobjs) $(host-cshlib) $(host-cshobjs)
90656 + $(host-cxxmulti) $(host-cxxobjs) $(host-cshlib) $(host-cshobjs) $(host-cxxshlib) $(host-cxxshobjs)
90657
90658 diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c
90659 index 7f6425e..9864506 100644
90660 --- a/scripts/basic/fixdep.c
90661 +++ b/scripts/basic/fixdep.c
90662 @@ -161,7 +161,7 @@ static unsigned int strhash(const char *str, unsigned int sz)
90663 /*
90664 * Lookup a value in the configuration string.
90665 */
90666 -static int is_defined_config(const char *name, int len, unsigned int hash)
90667 +static int is_defined_config(const char *name, unsigned int len, unsigned int hash)
90668 {
90669 struct item *aux;
90670
90671 @@ -211,10 +211,10 @@ static void clear_config(void)
90672 /*
90673 * Record the use of a CONFIG_* word.
90674 */
90675 -static void use_config(const char *m, int slen)
90676 +static void use_config(const char *m, unsigned int slen)
90677 {
90678 unsigned int hash = strhash(m, slen);
90679 - int c, i;
90680 + unsigned int c, i;
90681
90682 if (is_defined_config(m, slen, hash))
90683 return;
90684 @@ -235,9 +235,9 @@ static void use_config(const char *m, int slen)
90685
90686 static void parse_config_file(const char *map, size_t len)
90687 {
90688 - const int *end = (const int *) (map + len);
90689 + const unsigned int *end = (const unsigned int *) (map + len);
90690 /* start at +1, so that p can never be < map */
90691 - const int *m = (const int *) map + 1;
90692 + const unsigned int *m = (const unsigned int *) map + 1;
90693 const char *p, *q;
90694
90695 for (; m < end; m++) {
90696 @@ -406,7 +406,7 @@ static void print_deps(void)
90697 static void traps(void)
90698 {
90699 static char test[] __attribute__((aligned(sizeof(int)))) = "CONF";
90700 - int *p = (int *)test;
90701 + unsigned int *p = (unsigned int *)test;
90702
90703 if (*p != INT_CONF) {
90704 fprintf(stderr, "fixdep: sizeof(int) != 4 or wrong endianness? %#x\n",
90705 diff --git a/scripts/gcc-plugin.sh b/scripts/gcc-plugin.sh
90706 new file mode 100644
90707 index 0000000..5e0222d
90708 --- /dev/null
90709 +++ b/scripts/gcc-plugin.sh
90710 @@ -0,0 +1,17 @@
90711 +#!/bin/bash
90712 +plugincc=`$1 -E -shared - -o /dev/null -I\`$3 -print-file-name=plugin\`/include 2>&1 <<EOF
90713 +#include "gcc-plugin.h"
90714 +#include "tree.h"
90715 +#include "tm.h"
90716 +#include "rtl.h"
90717 +#ifdef ENABLE_BUILD_WITH_CXX
90718 +#warning $2
90719 +#else
90720 +#warning $1
90721 +#endif
90722 +EOF`
90723 +if [ $? -eq 0 ]
90724 +then
90725 + [[ "$plugincc" =~ "$1" ]] && echo "$1"
90726 + [[ "$plugincc" =~ "$2" ]] && echo "$2"
90727 +fi
90728 diff --git a/scripts/headers_install.pl b/scripts/headers_install.pl
90729 index 581ca99..a6ff02e 100644
90730 --- a/scripts/headers_install.pl
90731 +++ b/scripts/headers_install.pl
90732 @@ -35,6 +35,7 @@ foreach my $filename (@files) {
90733 $line =~ s/([\s(])__user\s/$1/g;
90734 $line =~ s/([\s(])__force\s/$1/g;
90735 $line =~ s/([\s(])__iomem\s/$1/g;
90736 + $line =~ s/(\s?)__intentional_overflow\([-\d\s,]*\)\s?/$1/g;
90737 $line =~ s/\s__attribute_const__\s/ /g;
90738 $line =~ s/\s__attribute_const__$//g;
90739 $line =~ s/\b__packed\b/__attribute__((packed))/g;
90740 diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
90741 index 3d569d6..0c09522 100644
90742 --- a/scripts/link-vmlinux.sh
90743 +++ b/scripts/link-vmlinux.sh
90744 @@ -159,7 +159,7 @@ else
90745 fi;
90746
90747 # final build of init/
90748 -${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init
90749 +${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init GCC_PLUGINS_CFLAGS="${GCC_PLUGINS_CFLAGS}" GCC_PLUGINS_AFLAGS="${GCC_PLUGINS_AFLAGS}"
90750
90751 kallsymso=""
90752 kallsyms_vmlinux=""
90753 diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
90754 index 771ac17..9f0d3ee 100644
90755 --- a/scripts/mod/file2alias.c
90756 +++ b/scripts/mod/file2alias.c
90757 @@ -140,7 +140,7 @@ static void device_id_check(const char *modname, const char *device_id,
90758 unsigned long size, unsigned long id_size,
90759 void *symval)
90760 {
90761 - int i;
90762 + unsigned int i;
90763
90764 if (size % id_size || size < id_size) {
90765 fatal("%s: sizeof(struct %s_device_id)=%lu is not a modulo "
90766 @@ -168,7 +168,7 @@ static void device_id_check(const char *modname, const char *device_id,
90767 /* USB is special because the bcdDevice can be matched against a numeric range */
90768 /* Looks like "usb:vNpNdNdcNdscNdpNicNiscNipNinN" */
90769 static void do_usb_entry(void *symval,
90770 - unsigned int bcdDevice_initial, int bcdDevice_initial_digits,
90771 + unsigned int bcdDevice_initial, unsigned int bcdDevice_initial_digits,
90772 unsigned char range_lo, unsigned char range_hi,
90773 unsigned char max, struct module *mod)
90774 {
90775 @@ -278,7 +278,7 @@ static void do_usb_entry_multi(void *symval, struct module *mod)
90776 {
90777 unsigned int devlo, devhi;
90778 unsigned char chi, clo, max;
90779 - int ndigits;
90780 + unsigned int ndigits;
90781
90782 DEF_FIELD(symval, usb_device_id, match_flags);
90783 DEF_FIELD(symval, usb_device_id, idVendor);
90784 @@ -531,7 +531,7 @@ static void do_pnp_device_entry(void *symval, unsigned long size,
90785 for (i = 0; i < count; i++) {
90786 DEF_FIELD_ADDR(symval + i*id_size, pnp_device_id, id);
90787 char acpi_id[sizeof(*id)];
90788 - int j;
90789 + unsigned int j;
90790
90791 buf_printf(&mod->dev_table_buf,
90792 "MODULE_ALIAS(\"pnp:d%s*\");\n", *id);
90793 @@ -560,7 +560,7 @@ static void do_pnp_card_entries(void *symval, unsigned long size,
90794
90795 for (j = 0; j < PNP_MAX_DEVICES; j++) {
90796 const char *id = (char *)(*devs)[j].id;
90797 - int i2, j2;
90798 + unsigned int i2, j2;
90799 int dup = 0;
90800
90801 if (!id[0])
90802 @@ -586,7 +586,7 @@ static void do_pnp_card_entries(void *symval, unsigned long size,
90803 /* add an individual alias for every device entry */
90804 if (!dup) {
90805 char acpi_id[PNP_ID_LEN];
90806 - int k;
90807 + unsigned int k;
90808
90809 buf_printf(&mod->dev_table_buf,
90810 "MODULE_ALIAS(\"pnp:d%s*\");\n", id);
90811 @@ -938,7 +938,7 @@ static void dmi_ascii_filter(char *d, const char *s)
90812 static int do_dmi_entry(const char *filename, void *symval,
90813 char *alias)
90814 {
90815 - int i, j;
90816 + unsigned int i, j;
90817 DEF_FIELD_ADDR(symval, dmi_system_id, matches);
90818 sprintf(alias, "dmi*");
90819
90820 diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
90821 index 78b30c1..536850d 100644
90822 --- a/scripts/mod/modpost.c
90823 +++ b/scripts/mod/modpost.c
90824 @@ -931,6 +931,7 @@ enum mismatch {
90825 ANY_INIT_TO_ANY_EXIT,
90826 ANY_EXIT_TO_ANY_INIT,
90827 EXPORT_TO_INIT_EXIT,
90828 + DATA_TO_TEXT
90829 };
90830
90831 struct sectioncheck {
90832 @@ -1045,6 +1046,12 @@ const struct sectioncheck sectioncheck[] = {
90833 .tosec = { INIT_SECTIONS, EXIT_SECTIONS, NULL },
90834 .mismatch = EXPORT_TO_INIT_EXIT,
90835 .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL },
90836 +},
90837 +/* Do not reference code from writable data */
90838 +{
90839 + .fromsec = { DATA_SECTIONS, NULL },
90840 + .tosec = { TEXT_SECTIONS, NULL },
90841 + .mismatch = DATA_TO_TEXT
90842 }
90843 };
90844
90845 @@ -1167,10 +1174,10 @@ static Elf_Sym *find_elf_symbol(struct elf_info *elf, Elf64_Sword addr,
90846 continue;
90847 if (ELF_ST_TYPE(sym->st_info) == STT_SECTION)
90848 continue;
90849 - if (sym->st_value == addr)
90850 - return sym;
90851 /* Find a symbol nearby - addr are maybe negative */
90852 d = sym->st_value - addr;
90853 + if (d == 0)
90854 + return sym;
90855 if (d < 0)
90856 d = addr - sym->st_value;
90857 if (d < distance) {
90858 @@ -1449,6 +1456,14 @@ static void report_sec_mismatch(const char *modname,
90859 tosym, prl_to, prl_to, tosym);
90860 free(prl_to);
90861 break;
90862 + case DATA_TO_TEXT:
90863 +#if 0
90864 + fprintf(stderr,
90865 + "The %s %s:%s references\n"
90866 + "the %s %s:%s%s\n",
90867 + from, fromsec, fromsym, to, tosec, tosym, to_p);
90868 +#endif
90869 + break;
90870 }
90871 fprintf(stderr, "\n");
90872 }
90873 @@ -1683,7 +1698,7 @@ static void section_rel(const char *modname, struct elf_info *elf,
90874 static void check_sec_ref(struct module *mod, const char *modname,
90875 struct elf_info *elf)
90876 {
90877 - int i;
90878 + unsigned int i;
90879 Elf_Shdr *sechdrs = elf->sechdrs;
90880
90881 /* Walk through all sections */
90882 @@ -1781,7 +1796,7 @@ void __attribute__((format(printf, 2, 3))) buf_printf(struct buffer *buf,
90883 va_end(ap);
90884 }
90885
90886 -void buf_write(struct buffer *buf, const char *s, int len)
90887 +void buf_write(struct buffer *buf, const char *s, unsigned int len)
90888 {
90889 if (buf->size - buf->pos < len) {
90890 buf->size += len + SZ;
90891 @@ -1999,7 +2014,7 @@ static void write_if_changed(struct buffer *b, const char *fname)
90892 if (fstat(fileno(file), &st) < 0)
90893 goto close_write;
90894
90895 - if (st.st_size != b->pos)
90896 + if (st.st_size != (off_t)b->pos)
90897 goto close_write;
90898
90899 tmp = NOFAIL(malloc(b->pos));
90900 diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h
90901 index 51207e4..f7d603d 100644
90902 --- a/scripts/mod/modpost.h
90903 +++ b/scripts/mod/modpost.h
90904 @@ -92,15 +92,15 @@ void *do_nofail(void *ptr, const char *expr);
90905
90906 struct buffer {
90907 char *p;
90908 - int pos;
90909 - int size;
90910 + unsigned int pos;
90911 + unsigned int size;
90912 };
90913
90914 void __attribute__((format(printf, 2, 3)))
90915 buf_printf(struct buffer *buf, const char *fmt, ...);
90916
90917 void
90918 -buf_write(struct buffer *buf, const char *s, int len);
90919 +buf_write(struct buffer *buf, const char *s, unsigned int len);
90920
90921 struct module {
90922 struct module *next;
90923 diff --git a/scripts/mod/sumversion.c b/scripts/mod/sumversion.c
90924 index 9dfcd6d..099068e 100644
90925 --- a/scripts/mod/sumversion.c
90926 +++ b/scripts/mod/sumversion.c
90927 @@ -470,7 +470,7 @@ static void write_version(const char *filename, const char *sum,
90928 goto out;
90929 }
90930
90931 - if (write(fd, sum, strlen(sum)+1) != strlen(sum)+1) {
90932 + if (write(fd, sum, strlen(sum)+1) != (ssize_t)strlen(sum)+1) {
90933 warn("writing sum in %s failed: %s\n",
90934 filename, strerror(errno));
90935 goto out;
90936 diff --git a/scripts/package/builddeb b/scripts/package/builddeb
90937 index acb8650..b8c5f02 100644
90938 --- a/scripts/package/builddeb
90939 +++ b/scripts/package/builddeb
90940 @@ -246,6 +246,7 @@ fi
90941 (cd $srctree; find . -name Makefile\* -o -name Kconfig\* -o -name \*.pl > "$objtree/debian/hdrsrcfiles")
90942 (cd $srctree; find arch/$SRCARCH/include include scripts -type f >> "$objtree/debian/hdrsrcfiles")
90943 (cd $objtree; find arch/$SRCARCH/include .config Module.symvers include scripts -type f >> "$objtree/debian/hdrobjfiles")
90944 +(cd $objtree; find tools/gcc -name \*.so >> "$objtree/debian/hdrobjfiles")
90945 destdir=$kernel_headers_dir/usr/src/linux-headers-$version
90946 mkdir -p "$destdir"
90947 (cd $srctree; tar -c -f - -T "$objtree/debian/hdrsrcfiles") | (cd $destdir; tar -xf -)
90948 diff --git a/scripts/pnmtologo.c b/scripts/pnmtologo.c
90949 index 68bb4ef..2f419e1 100644
90950 --- a/scripts/pnmtologo.c
90951 +++ b/scripts/pnmtologo.c
90952 @@ -244,14 +244,14 @@ static void write_header(void)
90953 fprintf(out, " * Linux logo %s\n", logoname);
90954 fputs(" */\n\n", out);
90955 fputs("#include <linux/linux_logo.h>\n\n", out);
90956 - fprintf(out, "static unsigned char %s_data[] __initdata = {\n",
90957 + fprintf(out, "static unsigned char %s_data[] = {\n",
90958 logoname);
90959 }
90960
90961 static void write_footer(void)
90962 {
90963 fputs("\n};\n\n", out);
90964 - fprintf(out, "const struct linux_logo %s __initconst = {\n", logoname);
90965 + fprintf(out, "const struct linux_logo %s = {\n", logoname);
90966 fprintf(out, "\t.type\t\t= %s,\n", logo_types[logo_type]);
90967 fprintf(out, "\t.width\t\t= %d,\n", logo_width);
90968 fprintf(out, "\t.height\t\t= %d,\n", logo_height);
90969 @@ -381,7 +381,7 @@ static void write_logo_clut224(void)
90970 fputs("\n};\n\n", out);
90971
90972 /* write logo clut */
90973 - fprintf(out, "static unsigned char %s_clut[] __initdata = {\n",
90974 + fprintf(out, "static unsigned char %s_clut[] = {\n",
90975 logoname);
90976 write_hex_cnt = 0;
90977 for (i = 0; i < logo_clutsize; i++) {
90978 diff --git a/scripts/sortextable.h b/scripts/sortextable.h
90979 index f5eb43d..1814de8 100644
90980 --- a/scripts/sortextable.h
90981 +++ b/scripts/sortextable.h
90982 @@ -106,9 +106,9 @@ do_func(Elf_Ehdr *ehdr, char const *const fname, table_sort_t custom_sort)
90983 const char *secstrtab;
90984 const char *strtab;
90985 char *extab_image;
90986 - int extab_index = 0;
90987 - int i;
90988 - int idx;
90989 + unsigned int extab_index = 0;
90990 + unsigned int i;
90991 + unsigned int idx;
90992
90993 shdr = (Elf_Shdr *)((char *)ehdr + _r(&ehdr->e_shoff));
90994 shstrtab_sec = shdr + r2(&ehdr->e_shstrndx);
90995 diff --git a/security/Kconfig b/security/Kconfig
90996 index e9c6ac7..e6254cf 100644
90997 --- a/security/Kconfig
90998 +++ b/security/Kconfig
90999 @@ -4,6 +4,944 @@
91000
91001 menu "Security options"
91002
91003 +menu "Grsecurity"
91004 +
91005 + config ARCH_TRACK_EXEC_LIMIT
91006 + bool
91007 +
91008 + config PAX_KERNEXEC_PLUGIN
91009 + bool
91010 +
91011 + config PAX_PER_CPU_PGD
91012 + bool
91013 +
91014 + config TASK_SIZE_MAX_SHIFT
91015 + int
91016 + depends on X86_64
91017 + default 47 if !PAX_PER_CPU_PGD
91018 + default 42 if PAX_PER_CPU_PGD
91019 +
91020 + config PAX_ENABLE_PAE
91021 + bool
91022 + default y if (X86_32 && (MPENTIUM4 || MK8 || MPSC || MCORE2 || MATOM))
91023 +
91024 + config PAX_USERCOPY_SLABS
91025 + bool
91026 +
91027 +config GRKERNSEC
91028 + bool "Grsecurity"
91029 + select CRYPTO
91030 + select CRYPTO_SHA256
91031 + select PROC_FS
91032 + select STOP_MACHINE
91033 + select TTY
91034 + help
91035 + If you say Y here, you will be able to configure many features
91036 + that will enhance the security of your system. It is highly
91037 + recommended that you say Y here and read through the help
91038 + for each option so that you fully understand the features and
91039 + can evaluate their usefulness for your machine.
91040 +
91041 +choice
91042 + prompt "Configuration Method"
91043 + depends on GRKERNSEC
91044 + default GRKERNSEC_CONFIG_CUSTOM
91045 + help
91046 +
91047 +config GRKERNSEC_CONFIG_AUTO
91048 + bool "Automatic"
91049 + help
91050 + If you choose this configuration method, you'll be able to answer a small
91051 + number of simple questions about how you plan to use this kernel.
91052 + The settings of grsecurity and PaX will be automatically configured for
91053 + the highest commonly-used settings within the provided constraints.
91054 +
91055 + If you require additional configuration, custom changes can still be made
91056 + from the "custom configuration" menu.
91057 +
91058 +config GRKERNSEC_CONFIG_CUSTOM
91059 + bool "Custom"
91060 + help
91061 + If you choose this configuration method, you'll be able to configure all
91062 + grsecurity and PaX settings manually. Via this method, no options are
91063 + automatically enabled.
91064 +
91065 +endchoice
91066 +
91067 +choice
91068 + prompt "Usage Type"
91069 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
91070 + default GRKERNSEC_CONFIG_SERVER
91071 + help
91072 +
91073 +config GRKERNSEC_CONFIG_SERVER
91074 + bool "Server"
91075 + help
91076 + Choose this option if you plan to use this kernel on a server.
91077 +
91078 +config GRKERNSEC_CONFIG_DESKTOP
91079 + bool "Desktop"
91080 + help
91081 + Choose this option if you plan to use this kernel on a desktop.
91082 +
91083 +endchoice
91084 +
91085 +choice
91086 + prompt "Virtualization Type"
91087 + depends on (GRKERNSEC && X86 && GRKERNSEC_CONFIG_AUTO)
91088 + default GRKERNSEC_CONFIG_VIRT_NONE
91089 + help
91090 +
91091 +config GRKERNSEC_CONFIG_VIRT_NONE
91092 + bool "None"
91093 + help
91094 + Choose this option if this kernel will be run on bare metal.
91095 +
91096 +config GRKERNSEC_CONFIG_VIRT_GUEST
91097 + bool "Guest"
91098 + help
91099 + Choose this option if this kernel will be run as a VM guest.
91100 +
91101 +config GRKERNSEC_CONFIG_VIRT_HOST
91102 + bool "Host"
91103 + help
91104 + Choose this option if this kernel will be run as a VM host.
91105 +
91106 +endchoice
91107 +
91108 +choice
91109 + prompt "Virtualization Hardware"
91110 + depends on (GRKERNSEC && X86 && GRKERNSEC_CONFIG_AUTO && (GRKERNSEC_CONFIG_VIRT_GUEST || GRKERNSEC_CONFIG_VIRT_HOST))
91111 + help
91112 +
91113 +config GRKERNSEC_CONFIG_VIRT_EPT
91114 + bool "EPT/RVI Processor Support"
91115 + depends on X86
91116 + help
91117 + Choose this option if your CPU supports the EPT or RVI features of 2nd-gen
91118 + hardware virtualization. This allows for additional kernel hardening protections
91119 + to operate without additional performance impact.
91120 +
91121 + To see if your Intel processor supports EPT, see:
91122 + http://ark.intel.com/Products/VirtualizationTechnology
91123 + (Most Core i3/5/7 support EPT)
91124 +
91125 + To see if your AMD processor supports RVI, see:
91126 + http://support.amd.com/us/kbarticles/Pages/GPU120AMDRVICPUsHyperVWin8.aspx
91127 +
91128 +config GRKERNSEC_CONFIG_VIRT_SOFT
91129 + bool "First-gen/No Hardware Virtualization"
91130 + help
91131 + Choose this option if you use an Atom/Pentium/Core 2 processor that either doesn't
91132 + support hardware virtualization or doesn't support the EPT/RVI extensions.
91133 +
91134 +endchoice
91135 +
91136 +choice
91137 + prompt "Virtualization Software"
91138 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO && (GRKERNSEC_CONFIG_VIRT_GUEST || GRKERNSEC_CONFIG_VIRT_HOST))
91139 + help
91140 +
91141 +config GRKERNSEC_CONFIG_VIRT_XEN
91142 + bool "Xen"
91143 + help
91144 + Choose this option if this kernel is running as a Xen guest or host.
91145 +
91146 +config GRKERNSEC_CONFIG_VIRT_VMWARE
91147 + bool "VMWare"
91148 + help
91149 + Choose this option if this kernel is running as a VMWare guest or host.
91150 +
91151 +config GRKERNSEC_CONFIG_VIRT_KVM
91152 + bool "KVM"
91153 + help
91154 + Choose this option if this kernel is running as a KVM guest or host.
91155 +
91156 +config GRKERNSEC_CONFIG_VIRT_VIRTUALBOX
91157 + bool "VirtualBox"
91158 + help
91159 + Choose this option if this kernel is running as a VirtualBox guest or host.
91160 +
91161 +endchoice
91162 +
91163 +choice
91164 + prompt "Required Priorities"
91165 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
91166 + default GRKERNSEC_CONFIG_PRIORITY_PERF
91167 + help
91168 +
91169 +config GRKERNSEC_CONFIG_PRIORITY_PERF
91170 + bool "Performance"
91171 + help
91172 + Choose this option if performance is of highest priority for this deployment
91173 + of grsecurity. Features like UDEREF on a 64bit kernel, kernel stack clearing,
91174 + clearing of structures intended for userland, and freed memory sanitizing will
91175 + be disabled.
91176 +
91177 +config GRKERNSEC_CONFIG_PRIORITY_SECURITY
91178 + bool "Security"
91179 + help
91180 + Choose this option if security is of highest priority for this deployment of
91181 + grsecurity. UDEREF, kernel stack clearing, clearing of structures intended
91182 + for userland, and freed memory sanitizing will be enabled for this kernel.
91183 + In a worst-case scenario, these features can introduce a 20% performance hit
91184 + (UDEREF on x64 contributing half of this hit).
91185 +
91186 +endchoice
91187 +
91188 +menu "Default Special Groups"
91189 +depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
91190 +
91191 +config GRKERNSEC_PROC_GID
91192 + int "GID exempted from /proc restrictions"
91193 + default 1001
91194 + help
91195 + Setting this GID determines which group will be exempted from
91196 + grsecurity's /proc restrictions, allowing users of the specified
91197 + group to view network statistics and the existence of other users'
91198 + processes on the system. This GID may also be chosen at boot time
91199 + via "grsec_proc_gid=" on the kernel commandline.
91200 +
91201 +config GRKERNSEC_TPE_UNTRUSTED_GID
91202 + int "GID for TPE-untrusted users"
91203 + depends on GRKERNSEC_CONFIG_SERVER && GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT
91204 + default 1005
91205 + help
91206 + Setting this GID determines which group untrusted users should
91207 + be added to. These users will be placed under grsecurity's Trusted Path
91208 + Execution mechanism, preventing them from executing their own binaries.
91209 + The users will only be able to execute binaries in directories owned and
91210 + writable only by the root user. If the sysctl option is enabled, a sysctl
91211 + option with name "tpe_gid" is created.
91212 +
91213 +config GRKERNSEC_TPE_TRUSTED_GID
91214 + int "GID for TPE-trusted users"
91215 + depends on GRKERNSEC_CONFIG_SERVER && GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT
91216 + default 1005
91217 + help
91218 + Setting this GID determines what group TPE restrictions will be
91219 + *disabled* for. If the sysctl option is enabled, a sysctl option
91220 + with name "tpe_gid" is created.
91221 +
91222 +config GRKERNSEC_SYMLINKOWN_GID
91223 + int "GID for users with kernel-enforced SymlinksIfOwnerMatch"
91224 + depends on GRKERNSEC_CONFIG_SERVER
91225 + default 1006
91226 + help
91227 + Setting this GID determines what group kernel-enforced
91228 + SymlinksIfOwnerMatch will be enabled for. If the sysctl option
91229 + is enabled, a sysctl option with name "symlinkown_gid" is created.
91230 +
91231 +
91232 +endmenu
91233 +
91234 +menu "Customize Configuration"
91235 +depends on GRKERNSEC
91236 +
91237 +menu "PaX"
91238 +
91239 +config PAX
91240 + bool "Enable various PaX features"
91241 + default y if GRKERNSEC_CONFIG_AUTO
91242 + depends on GRKERNSEC && (ALPHA || ARM || AVR32 || IA64 || MIPS || PARISC || PPC || SPARC || X86)
91243 + help
91244 + This allows you to enable various PaX features. PaX adds
91245 + intrusion prevention mechanisms to the kernel that reduce
91246 + the risks posed by exploitable memory corruption bugs.
91247 +
91248 +menu "PaX Control"
91249 + depends on PAX
91250 +
91251 +config PAX_SOFTMODE
91252 + bool 'Support soft mode'
91253 + help
91254 + Enabling this option will allow you to run PaX in soft mode, that
91255 + is, PaX features will not be enforced by default, only on executables
91256 + marked explicitly. You must also enable PT_PAX_FLAGS or XATTR_PAX_FLAGS
91257 + support as they are the only way to mark executables for soft mode use.
91258 +
91259 + Soft mode can be activated by using the "pax_softmode=1" kernel command
91260 + line option on boot. Furthermore you can control various PaX features
91261 + at runtime via the entries in /proc/sys/kernel/pax.
91262 +
91263 +config PAX_EI_PAX
91264 + bool 'Use legacy ELF header marking'
91265 + default y if GRKERNSEC_CONFIG_AUTO
91266 + help
91267 + Enabling this option will allow you to control PaX features on
91268 + a per executable basis via the 'chpax' utility available at
91269 + http://pax.grsecurity.net/. The control flags will be read from
91270 + an otherwise reserved part of the ELF header. This marking has
91271 + numerous drawbacks (no support for soft-mode, toolchain does not
91272 + know about the non-standard use of the ELF header) therefore it
91273 + has been deprecated in favour of PT_PAX_FLAGS and XATTR_PAX_FLAGS
91274 + support.
91275 +
91276 + Note that if you enable PT_PAX_FLAGS or XATTR_PAX_FLAGS marking
91277 + support as well, they will override the legacy EI_PAX marks.
91278 +
91279 + If you enable none of the marking options then all applications
91280 + will run with PaX enabled on them by default.
91281 +
91282 +config PAX_PT_PAX_FLAGS
91283 + bool 'Use ELF program header marking'
91284 + default y if GRKERNSEC_CONFIG_AUTO
91285 + help
91286 + Enabling this option will allow you to control PaX features on
91287 + a per executable basis via the 'paxctl' utility available at
91288 + http://pax.grsecurity.net/. The control flags will be read from
91289 + a PaX specific ELF program header (PT_PAX_FLAGS). This marking
91290 + has the benefits of supporting both soft mode and being fully
91291 + integrated into the toolchain (the binutils patch is available
91292 + from http://pax.grsecurity.net).
91293 +
91294 + Note that if you enable the legacy EI_PAX marking support as well,
91295 + the EI_PAX marks will be overridden by the PT_PAX_FLAGS marks.
91296 +
91297 + If you enable both PT_PAX_FLAGS and XATTR_PAX_FLAGS support then you
91298 + must make sure that the marks are the same if a binary has both marks.
91299 +
91300 + If you enable none of the marking options then all applications
91301 + will run with PaX enabled on them by default.
91302 +
91303 +config PAX_XATTR_PAX_FLAGS
91304 + bool 'Use filesystem extended attributes marking'
91305 + default y if GRKERNSEC_CONFIG_AUTO
91306 + select CIFS_XATTR if CIFS
91307 + select EXT2_FS_XATTR if EXT2_FS
91308 + select EXT3_FS_XATTR if EXT3_FS
91309 + select EXT4_FS_XATTR if EXT4_FS
91310 + select JFFS2_FS_XATTR if JFFS2_FS
91311 + select REISERFS_FS_XATTR if REISERFS_FS
91312 + select SQUASHFS_XATTR if SQUASHFS
91313 + select TMPFS_XATTR if TMPFS
91314 + select UBIFS_FS_XATTR if UBIFS_FS
91315 + help
91316 + Enabling this option will allow you to control PaX features on
91317 + a per executable basis via the 'setfattr' utility. The control
91318 + flags will be read from the user.pax.flags extended attribute of
91319 + the file. This marking has the benefit of supporting binary-only
91320 + applications that self-check themselves (e.g., skype) and would
91321 + not tolerate chpax/paxctl changes. The main drawback is that
91322 + extended attributes are not supported by some filesystems (e.g.,
91323 + isofs, udf, vfat) so copying files through such filesystems will
91324 + lose the extended attributes and these PaX markings.
91325 +
91326 + Note that if you enable the legacy EI_PAX marking support as well,
91327 + the EI_PAX marks will be overridden by the XATTR_PAX_FLAGS marks.
91328 +
91329 + If you enable both PT_PAX_FLAGS and XATTR_PAX_FLAGS support then you
91330 + must make sure that the marks are the same if a binary has both marks.
91331 +
91332 + If you enable none of the marking options then all applications
91333 + will run with PaX enabled on them by default.
91334 +
91335 +choice
91336 + prompt 'MAC system integration'
91337 + default PAX_HAVE_ACL_FLAGS
91338 + help
91339 + Mandatory Access Control systems have the option of controlling
91340 + PaX flags on a per executable basis, choose the method supported
91341 + by your particular system.
91342 +
91343 + - "none": if your MAC system does not interact with PaX,
91344 + - "direct": if your MAC system defines pax_set_initial_flags() itself,
91345 + - "hook": if your MAC system uses the pax_set_initial_flags_func callback.
91346 +
91347 + NOTE: this option is for developers/integrators only.
91348 +
91349 + config PAX_NO_ACL_FLAGS
91350 + bool 'none'
91351 +
91352 + config PAX_HAVE_ACL_FLAGS
91353 + bool 'direct'
91354 +
91355 + config PAX_HOOK_ACL_FLAGS
91356 + bool 'hook'
91357 +endchoice
91358 +
91359 +endmenu
91360 +
91361 +menu "Non-executable pages"
91362 + depends on PAX
91363 +
91364 +config PAX_NOEXEC
91365 + bool "Enforce non-executable pages"
91366 + default y if GRKERNSEC_CONFIG_AUTO
91367 + depends on ALPHA || (ARM && (CPU_V6 || CPU_V7)) || IA64 || MIPS || PARISC || PPC || S390 || SPARC || X86
91368 + help
91369 + By design some architectures do not allow for protecting memory
91370 + pages against execution or even if they do, Linux does not make
91371 + use of this feature. In practice this means that if a page is
91372 + readable (such as the stack or heap) it is also executable.
91373 +
91374 + There is a well known exploit technique that makes use of this
91375 + fact and a common programming mistake where an attacker can
91376 + introduce code of his choice somewhere in the attacked program's
91377 + memory (typically the stack or the heap) and then execute it.
91378 +
91379 + If the attacked program was running with different (typically
91380 + higher) privileges than that of the attacker, then he can elevate
91381 + his own privilege level (e.g. get a root shell, write to files for
91382 + which he does not have write access to, etc).
91383 +
91384 + Enabling this option will let you choose from various features
91385 + that prevent the injection and execution of 'foreign' code in
91386 + a program.
91387 +
91388 + This will also break programs that rely on the old behaviour and
91389 + expect that dynamically allocated memory via the malloc() family
91390 + of functions is executable (which it is not). Notable examples
91391 + are the XFree86 4.x server, the java runtime and wine.
91392 +
91393 +config PAX_PAGEEXEC
91394 + bool "Paging based non-executable pages"
91395 + default y if GRKERNSEC_CONFIG_AUTO
91396 + 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)
91397 + select S390_SWITCH_AMODE if S390
91398 + select S390_EXEC_PROTECT if S390
91399 + select ARCH_TRACK_EXEC_LIMIT if X86_32
91400 + help
91401 + This implementation is based on the paging feature of the CPU.
91402 + On i386 without hardware non-executable bit support there is a
91403 + variable but usually low performance impact, however on Intel's
91404 + P4 core based CPUs it is very high so you should not enable this
91405 + for kernels meant to be used on such CPUs.
91406 +
91407 + On alpha, avr32, ia64, parisc, sparc, sparc64, x86_64 and i386
91408 + with hardware non-executable bit support there is no performance
91409 + impact, on ppc the impact is negligible.
91410 +
91411 + Note that several architectures require various emulations due to
91412 + badly designed userland ABIs, this will cause a performance impact
91413 + but will disappear as soon as userland is fixed. For example, ppc
91414 + userland MUST have been built with secure-plt by a recent toolchain.
91415 +
91416 +config PAX_SEGMEXEC
91417 + bool "Segmentation based non-executable pages"
91418 + default y if GRKERNSEC_CONFIG_AUTO
91419 + depends on PAX_NOEXEC && X86_32
91420 + help
91421 + This implementation is based on the segmentation feature of the
91422 + CPU and has a very small performance impact, however applications
91423 + will be limited to a 1.5 GB address space instead of the normal
91424 + 3 GB.
91425 +
91426 +config PAX_EMUTRAMP
91427 + bool "Emulate trampolines" if (PAX_PAGEEXEC || PAX_SEGMEXEC) && (PARISC || X86)
91428 + default y if PARISC
91429 + help
91430 + There are some programs and libraries that for one reason or
91431 + another attempt to execute special small code snippets from
91432 + non-executable memory pages. Most notable examples are the
91433 + signal handler return code generated by the kernel itself and
91434 + the GCC trampolines.
91435 +
91436 + If you enabled CONFIG_PAX_PAGEEXEC or CONFIG_PAX_SEGMEXEC then
91437 + such programs will no longer work under your kernel.
91438 +
91439 + As a remedy you can say Y here and use the 'chpax' or 'paxctl'
91440 + utilities to enable trampoline emulation for the affected programs
91441 + yet still have the protection provided by the non-executable pages.
91442 +
91443 + On parisc you MUST enable this option and EMUSIGRT as well, otherwise
91444 + your system will not even boot.
91445 +
91446 + Alternatively you can say N here and use the 'chpax' or 'paxctl'
91447 + utilities to disable CONFIG_PAX_PAGEEXEC and CONFIG_PAX_SEGMEXEC
91448 + for the affected files.
91449 +
91450 + NOTE: enabling this feature *may* open up a loophole in the
91451 + protection provided by non-executable pages that an attacker
91452 + could abuse. Therefore the best solution is to not have any
91453 + files on your system that would require this option. This can
91454 + be achieved by not using libc5 (which relies on the kernel
91455 + signal handler return code) and not using or rewriting programs
91456 + that make use of the nested function implementation of GCC.
91457 + Skilled users can just fix GCC itself so that it implements
91458 + nested function calls in a way that does not interfere with PaX.
91459 +
91460 +config PAX_EMUSIGRT
91461 + bool "Automatically emulate sigreturn trampolines"
91462 + depends on PAX_EMUTRAMP && PARISC
91463 + default y
91464 + help
91465 + Enabling this option will have the kernel automatically detect
91466 + and emulate signal return trampolines executing on the stack
91467 + that would otherwise lead to task termination.
91468 +
91469 + This solution is intended as a temporary one for users with
91470 + legacy versions of libc (libc5, glibc 2.0, uClibc before 0.9.17,
91471 + Modula-3 runtime, etc) or executables linked to such, basically
91472 + everything that does not specify its own SA_RESTORER function in
91473 + normal executable memory like glibc 2.1+ does.
91474 +
91475 + On parisc you MUST enable this option, otherwise your system will
91476 + not even boot.
91477 +
91478 + NOTE: this feature cannot be disabled on a per executable basis
91479 + and since it *does* open up a loophole in the protection provided
91480 + by non-executable pages, the best solution is to not have any
91481 + files on your system that would require this option.
91482 +
91483 +config PAX_MPROTECT
91484 + bool "Restrict mprotect()"
91485 + default y if GRKERNSEC_CONFIG_AUTO
91486 + depends on (PAX_PAGEEXEC || PAX_SEGMEXEC)
91487 + help
91488 + Enabling this option will prevent programs from
91489 + - changing the executable status of memory pages that were
91490 + not originally created as executable,
91491 + - making read-only executable pages writable again,
91492 + - creating executable pages from anonymous memory,
91493 + - making read-only-after-relocations (RELRO) data pages writable again.
91494 +
91495 + You should say Y here to complete the protection provided by
91496 + the enforcement of non-executable pages.
91497 +
91498 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control
91499 + this feature on a per file basis.
91500 +
91501 +config PAX_MPROTECT_COMPAT
91502 + bool "Use legacy/compat protection demoting (read help)"
91503 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_DESKTOP)
91504 + depends on PAX_MPROTECT
91505 + help
91506 + The current implementation of PAX_MPROTECT denies RWX allocations/mprotects
91507 + by sending the proper error code to the application. For some broken
91508 + userland, this can cause problems with Python or other applications. The
91509 + current implementation however allows for applications like clamav to
91510 + detect if JIT compilation/execution is allowed and to fall back gracefully
91511 + to an interpreter-based mode if it does not. While we encourage everyone
91512 + to use the current implementation as-is and push upstream to fix broken
91513 + userland (note that the RWX logging option can assist with this), in some
91514 + environments this may not be possible. Having to disable MPROTECT
91515 + completely on certain binaries reduces the security benefit of PaX,
91516 + so this option is provided for those environments to revert to the old
91517 + behavior.
91518 +
91519 +config PAX_ELFRELOCS
91520 + bool "Allow ELF text relocations (read help)"
91521 + depends on PAX_MPROTECT
91522 + default n
91523 + help
91524 + Non-executable pages and mprotect() restrictions are effective
91525 + in preventing the introduction of new executable code into an
91526 + attacked task's address space. There remain only two venues
91527 + for this kind of attack: if the attacker can execute already
91528 + existing code in the attacked task then he can either have it
91529 + create and mmap() a file containing his code or have it mmap()
91530 + an already existing ELF library that does not have position
91531 + independent code in it and use mprotect() on it to make it
91532 + writable and copy his code there. While protecting against
91533 + the former approach is beyond PaX, the latter can be prevented
91534 + by having only PIC ELF libraries on one's system (which do not
91535 + need to relocate their code). If you are sure this is your case,
91536 + as is the case with all modern Linux distributions, then leave
91537 + this option disabled. You should say 'n' here.
91538 +
91539 +config PAX_ETEXECRELOCS
91540 + bool "Allow ELF ET_EXEC text relocations"
91541 + depends on PAX_MPROTECT && (ALPHA || IA64 || PARISC)
91542 + select PAX_ELFRELOCS
91543 + default y
91544 + help
91545 + On some architectures there are incorrectly created applications
91546 + that require text relocations and would not work without enabling
91547 + this option. If you are an alpha, ia64 or parisc user, you should
91548 + enable this option and disable it once you have made sure that
91549 + none of your applications need it.
91550 +
91551 +config PAX_EMUPLT
91552 + bool "Automatically emulate ELF PLT"
91553 + depends on PAX_MPROTECT && (ALPHA || PARISC || SPARC)
91554 + default y
91555 + help
91556 + Enabling this option will have the kernel automatically detect
91557 + and emulate the Procedure Linkage Table entries in ELF files.
91558 + On some architectures such entries are in writable memory, and
91559 + become non-executable leading to task termination. Therefore
91560 + it is mandatory that you enable this option on alpha, parisc,
91561 + sparc and sparc64, otherwise your system would not even boot.
91562 +
91563 + NOTE: this feature *does* open up a loophole in the protection
91564 + provided by the non-executable pages, therefore the proper
91565 + solution is to modify the toolchain to produce a PLT that does
91566 + not need to be writable.
91567 +
91568 +config PAX_DLRESOLVE
91569 + bool 'Emulate old glibc resolver stub'
91570 + depends on PAX_EMUPLT && SPARC
91571 + default n
91572 + help
91573 + This option is needed if userland has an old glibc (before 2.4)
91574 + that puts a 'save' instruction into the runtime generated resolver
91575 + stub that needs special emulation.
91576 +
91577 +config PAX_KERNEXEC
91578 + bool "Enforce non-executable kernel pages"
91579 + 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))
91580 + depends on (X86 || (ARM && (CPU_V6 || CPU_V7) && !(ARM_LPAE && MODULES))) && !XEN
91581 + select PAX_PER_CPU_PGD if X86_64 || (X86_32 && X86_PAE)
91582 + select PAX_KERNEXEC_PLUGIN if X86_64
91583 + help
91584 + This is the kernel land equivalent of PAGEEXEC and MPROTECT,
91585 + that is, enabling this option will make it harder to inject
91586 + and execute 'foreign' code in kernel memory itself.
91587 +
91588 +choice
91589 + prompt "Return Address Instrumentation Method"
91590 + default PAX_KERNEXEC_PLUGIN_METHOD_BTS
91591 + depends on PAX_KERNEXEC_PLUGIN
91592 + help
91593 + Select the method used to instrument function pointer dereferences.
91594 + Note that binary modules cannot be instrumented by this approach.
91595 +
91596 + Note that the implementation requires a gcc with plugin support,
91597 + i.e., gcc 4.5 or newer. You may need to install the supporting
91598 + headers explicitly in addition to the normal gcc package.
91599 +
91600 + config PAX_KERNEXEC_PLUGIN_METHOD_BTS
91601 + bool "bts"
91602 + help
91603 + This method is compatible with binary only modules but has
91604 + a higher runtime overhead.
91605 +
91606 + config PAX_KERNEXEC_PLUGIN_METHOD_OR
91607 + bool "or"
91608 + depends on !PARAVIRT
91609 + help
91610 + This method is incompatible with binary only modules but has
91611 + a lower runtime overhead.
91612 +endchoice
91613 +
91614 +config PAX_KERNEXEC_PLUGIN_METHOD
91615 + string
91616 + default "bts" if PAX_KERNEXEC_PLUGIN_METHOD_BTS
91617 + default "or" if PAX_KERNEXEC_PLUGIN_METHOD_OR
91618 + default ""
91619 +
91620 +config PAX_KERNEXEC_MODULE_TEXT
91621 + int "Minimum amount of memory reserved for module code"
91622 + default "4" if (!GRKERNSEC_CONFIG_AUTO || GRKERNSEC_CONFIG_SERVER)
91623 + default "12" if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_DESKTOP)
91624 + depends on PAX_KERNEXEC && X86_32 && MODULES
91625 + help
91626 + Due to implementation details the kernel must reserve a fixed
91627 + amount of memory for module code at compile time that cannot be
91628 + changed at runtime. Here you can specify the minimum amount
91629 + in MB that will be reserved. Due to the same implementation
91630 + details this size will always be rounded up to the next 2/4 MB
91631 + boundary (depends on PAE) so the actually available memory for
91632 + module code will usually be more than this minimum.
91633 +
91634 + The default 4 MB should be enough for most users but if you have
91635 + an excessive number of modules (e.g., most distribution configs
91636 + compile many drivers as modules) or use huge modules such as
91637 + nvidia's kernel driver, you will need to adjust this amount.
91638 + A good rule of thumb is to look at your currently loaded kernel
91639 + modules and add up their sizes.
91640 +
91641 +endmenu
91642 +
91643 +menu "Address Space Layout Randomization"
91644 + depends on PAX
91645 +
91646 +config PAX_ASLR
91647 + bool "Address Space Layout Randomization"
91648 + default y if GRKERNSEC_CONFIG_AUTO
91649 + help
91650 + Many if not most exploit techniques rely on the knowledge of
91651 + certain addresses in the attacked program. The following options
91652 + will allow the kernel to apply a certain amount of randomization
91653 + to specific parts of the program thereby forcing an attacker to
91654 + guess them in most cases. Any failed guess will most likely crash
91655 + the attacked program which allows the kernel to detect such attempts
91656 + and react on them. PaX itself provides no reaction mechanisms,
91657 + instead it is strongly encouraged that you make use of Nergal's
91658 + segvguard (ftp://ftp.pl.openwall.com/misc/segvguard/) or grsecurity's
91659 + (http://www.grsecurity.net/) built-in crash detection features or
91660 + develop one yourself.
91661 +
91662 + By saying Y here you can choose to randomize the following areas:
91663 + - top of the task's kernel stack
91664 + - top of the task's userland stack
91665 + - base address for mmap() requests that do not specify one
91666 + (this includes all libraries)
91667 + - base address of the main executable
91668 +
91669 + It is strongly recommended to say Y here as address space layout
91670 + randomization has negligible impact on performance yet it provides
91671 + a very effective protection.
91672 +
91673 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control
91674 + this feature on a per file basis.
91675 +
91676 +config PAX_RANDKSTACK
91677 + bool "Randomize kernel stack base"
91678 + default y if GRKERNSEC_CONFIG_AUTO
91679 + depends on X86_TSC && X86
91680 + help
91681 + By saying Y here the kernel will randomize every task's kernel
91682 + stack on every system call. This will not only force an attacker
91683 + to guess it but also prevent him from making use of possible
91684 + leaked information about it.
91685 +
91686 + Since the kernel stack is a rather scarce resource, randomization
91687 + may cause unexpected stack overflows, therefore you should very
91688 + carefully test your system. Note that once enabled in the kernel
91689 + configuration, this feature cannot be disabled on a per file basis.
91690 +
91691 +config PAX_RANDUSTACK
91692 + bool "Randomize user stack base"
91693 + default y if GRKERNSEC_CONFIG_AUTO
91694 + depends on PAX_ASLR
91695 + help
91696 + By saying Y here the kernel will randomize every task's userland
91697 + stack. The randomization is done in two steps where the second
91698 + one may apply a big amount of shift to the top of the stack and
91699 + cause problems for programs that want to use lots of memory (more
91700 + than 2.5 GB if SEGMEXEC is not active, or 1.25 GB when it is).
91701 + For this reason the second step can be controlled by 'chpax' or
91702 + 'paxctl' on a per file basis.
91703 +
91704 +config PAX_RANDMMAP
91705 + bool "Randomize mmap() base"
91706 + default y if GRKERNSEC_CONFIG_AUTO
91707 + depends on PAX_ASLR
91708 + help
91709 + By saying Y here the kernel will use a randomized base address for
91710 + mmap() requests that do not specify one themselves. As a result
91711 + all dynamically loaded libraries will appear at random addresses
91712 + and therefore be harder to exploit by a technique where an attacker
91713 + attempts to execute library code for his purposes (e.g. spawn a
91714 + shell from an exploited program that is running at an elevated
91715 + privilege level).
91716 +
91717 + Furthermore, if a program is relinked as a dynamic ELF file, its
91718 + base address will be randomized as well, completing the full
91719 + randomization of the address space layout. Attacking such programs
91720 + becomes a guess game. You can find an example of doing this at
91721 + http://pax.grsecurity.net/et_dyn.tar.gz and practical samples at
91722 + http://www.grsecurity.net/grsec-gcc-specs.tar.gz .
91723 +
91724 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control this
91725 + feature on a per file basis.
91726 +
91727 +endmenu
91728 +
91729 +menu "Miscellaneous hardening features"
91730 +
91731 +config PAX_MEMORY_SANITIZE
91732 + bool "Sanitize all freed memory"
91733 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
91734 + depends on !HIBERNATION
91735 + help
91736 + By saying Y here the kernel will erase memory pages as soon as they
91737 + are freed. This in turn reduces the lifetime of data stored in the
91738 + pages, making it less likely that sensitive information such as
91739 + passwords, cryptographic secrets, etc stay in memory for too long.
91740 +
91741 + This is especially useful for programs whose runtime is short, long
91742 + lived processes and the kernel itself benefit from this as long as
91743 + they operate on whole memory pages and ensure timely freeing of pages
91744 + that may hold sensitive information.
91745 +
91746 + The tradeoff is performance impact, on a single CPU system kernel
91747 + compilation sees a 3% slowdown, other systems and workloads may vary
91748 + and you are advised to test this feature on your expected workload
91749 + before deploying it.
91750 +
91751 + Note that this feature does not protect data stored in live pages,
91752 + e.g., process memory swapped to disk may stay there for a long time.
91753 +
91754 +config PAX_MEMORY_STACKLEAK
91755 + bool "Sanitize kernel stack"
91756 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
91757 + depends on X86
91758 + help
91759 + By saying Y here the kernel will erase the kernel stack before it
91760 + returns from a system call. This in turn reduces the information
91761 + that a kernel stack leak bug can reveal.
91762 +
91763 + Note that such a bug can still leak information that was put on
91764 + the stack by the current system call (the one eventually triggering
91765 + the bug) but traces of earlier system calls on the kernel stack
91766 + cannot leak anymore.
91767 +
91768 + The tradeoff is performance impact: on a single CPU system kernel
91769 + compilation sees a 1% slowdown, other systems and workloads may vary
91770 + and you are advised to test this feature on your expected workload
91771 + before deploying it.
91772 +
91773 + Note that the full feature requires a gcc with plugin support,
91774 + i.e., gcc 4.5 or newer. You may need to install the supporting
91775 + headers explicitly in addition to the normal gcc package. Using
91776 + older gcc versions means that functions with large enough stack
91777 + frames may leave uninitialized memory behind that may be exposed
91778 + to a later syscall leaking the stack.
91779 +
91780 +config PAX_MEMORY_STRUCTLEAK
91781 + bool "Forcibly initialize local variables copied to userland"
91782 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
91783 + help
91784 + By saying Y here the kernel will zero initialize some local
91785 + variables that are going to be copied to userland. This in
91786 + turn prevents unintended information leakage from the kernel
91787 + stack should later code forget to explicitly set all parts of
91788 + the copied variable.
91789 +
91790 + The tradeoff is less performance impact than PAX_MEMORY_STACKLEAK
91791 + at a much smaller coverage.
91792 +
91793 + Note that the implementation requires a gcc with plugin support,
91794 + i.e., gcc 4.5 or newer. You may need to install the supporting
91795 + headers explicitly in addition to the normal gcc package.
91796 +
91797 +config PAX_MEMORY_UDEREF
91798 + bool "Prevent invalid userland pointer dereference"
91799 + default y if GRKERNSEC_CONFIG_AUTO && !(X86_64 && GRKERNSEC_CONFIG_PRIORITY_PERF) && (GRKERNSEC_CONFIG_VIRT_NONE || GRKERNSEC_CONFIG_VIRT_EPT)
91800 + depends on (X86 || (ARM && (CPU_V6 || CPU_V7) && !ARM_LPAE)) && !UML_X86 && !XEN
91801 + select PAX_PER_CPU_PGD if X86_64
91802 + help
91803 + By saying Y here the kernel will be prevented from dereferencing
91804 + userland pointers in contexts where the kernel expects only kernel
91805 + pointers. This is both a useful runtime debugging feature and a
91806 + security measure that prevents exploiting a class of kernel bugs.
91807 +
91808 + The tradeoff is that some virtualization solutions may experience
91809 + a huge slowdown and therefore you should not enable this feature
91810 + for kernels meant to run in such environments. Whether a given VM
91811 + solution is affected or not is best determined by simply trying it
91812 + out, the performance impact will be obvious right on boot as this
91813 + mechanism engages from very early on. A good rule of thumb is that
91814 + VMs running on CPUs without hardware virtualization support (i.e.,
91815 + the majority of IA-32 CPUs) will likely experience the slowdown.
91816 +
91817 +config PAX_REFCOUNT
91818 + bool "Prevent various kernel object reference counter overflows"
91819 + default y if GRKERNSEC_CONFIG_AUTO
91820 + depends on GRKERNSEC && ((ARM && (CPU_32v6 || CPU_32v6K || CPU_32v7)) || SPARC64 || X86)
91821 + help
91822 + By saying Y here the kernel will detect and prevent overflowing
91823 + various (but not all) kinds of object reference counters. Such
91824 + overflows can normally occur due to bugs only and are often, if
91825 + not always, exploitable.
91826 +
91827 + The tradeoff is that data structures protected by an overflowed
91828 + refcount will never be freed and therefore will leak memory. Note
91829 + that this leak also happens even without this protection but in
91830 + that case the overflow can eventually trigger the freeing of the
91831 + data structure while it is still being used elsewhere, resulting
91832 + in the exploitable situation that this feature prevents.
91833 +
91834 + Since this has a negligible performance impact, you should enable
91835 + this feature.
91836 +
91837 +config PAX_CONSTIFY_PLUGIN
91838 + bool "Automatically constify eligible structures"
91839 + default y
91840 + depends on !UML && PAX_KERNEXEC
91841 + help
91842 + By saying Y here the compiler will automatically constify a class
91843 + of types that contain only function pointers. This reduces the
91844 + kernel's attack surface and also produces a better memory layout.
91845 +
91846 + Note that the implementation requires a gcc with plugin support,
91847 + i.e., gcc 4.5 or newer. You may need to install the supporting
91848 + headers explicitly in addition to the normal gcc package.
91849 +
91850 + Note that if some code really has to modify constified variables
91851 + then the source code will have to be patched to allow it. Examples
91852 + can be found in PaX itself (the no_const attribute) and for some
91853 + out-of-tree modules at http://www.grsecurity.net/~paxguy1/ .
91854 +
91855 +config PAX_USERCOPY
91856 + bool "Harden heap object copies between kernel and userland"
91857 + default y if GRKERNSEC_CONFIG_AUTO
91858 + depends on ARM || IA64 || PPC || SPARC || X86
91859 + depends on GRKERNSEC && (SLAB || SLUB || SLOB)
91860 + select PAX_USERCOPY_SLABS
91861 + help
91862 + By saying Y here the kernel will enforce the size of heap objects
91863 + when they are copied in either direction between the kernel and
91864 + userland, even if only a part of the heap object is copied.
91865 +
91866 + Specifically, this checking prevents information leaking from the
91867 + kernel heap during kernel to userland copies (if the kernel heap
91868 + object is otherwise fully initialized) and prevents kernel heap
91869 + overflows during userland to kernel copies.
91870 +
91871 + Note that the current implementation provides the strictest bounds
91872 + checks for the SLUB allocator.
91873 +
91874 + Enabling this option also enables per-slab cache protection against
91875 + data in a given cache being copied into/out of via userland
91876 + accessors. Though the whitelist of regions will be reduced over
91877 + time, it notably protects important data structures like task structs.
91878 +
91879 + If frame pointers are enabled on x86, this option will also restrict
91880 + copies into and out of the kernel stack to local variables within a
91881 + single frame.
91882 +
91883 + Since this has a negligible performance impact, you should enable
91884 + this feature.
91885 +
91886 +config PAX_USERCOPY_DEBUG
91887 + bool
91888 + depends on X86 && PAX_USERCOPY
91889 + default n
91890 +
91891 +config PAX_SIZE_OVERFLOW
91892 + bool "Prevent various integer overflows in function size parameters"
91893 + default y if GRKERNSEC_CONFIG_AUTO
91894 + depends on X86
91895 + help
91896 + By saying Y here the kernel recomputes expressions of function
91897 + arguments marked by a size_overflow attribute with double integer
91898 + precision (DImode/TImode for 32/64 bit integer types).
91899 +
91900 + The recomputed argument is checked against TYPE_MAX and an event
91901 + is logged on overflow and the triggering process is killed.
91902 +
91903 + Homepage: http://www.grsecurity.net/~ephox/overflow_plugin/
91904 +
91905 + Note that the implementation requires a gcc with plugin support,
91906 + i.e., gcc 4.5 or newer. You may need to install the supporting
91907 + headers explicitly in addition to the normal gcc package.
91908 +
91909 +config PAX_LATENT_ENTROPY
91910 + bool "Generate some entropy during boot"
91911 + default y if GRKERNSEC_CONFIG_AUTO
91912 + help
91913 + By saying Y here the kernel will instrument early boot code to
91914 + extract some entropy from both original and artificially created
91915 + program state. This will help especially embedded systems where
91916 + there is little 'natural' source of entropy normally. The cost
91917 + is some slowdown of the boot process.
91918 +
91919 + When pax_extra_latent_entropy is passed on the kernel command line,
91920 + entropy will be extracted from up to the first 4GB of RAM while the
91921 + runtime memory allocator is being initialized. This costs even more
91922 + slowdown of the boot process.
91923 +
91924 + Note that the implementation requires a gcc with plugin support,
91925 + i.e., gcc 4.5 or newer. You may need to install the supporting
91926 + headers explicitly in addition to the normal gcc package.
91927 +
91928 + Note that entropy extracted this way is not cryptographically
91929 + secure!
91930 +
91931 +endmenu
91932 +
91933 +endmenu
91934 +
91935 +source grsecurity/Kconfig
91936 +
91937 +endmenu
91938 +
91939 +endmenu
91940 +
91941 source security/keys/Kconfig
91942
91943 config SECURITY_DMESG_RESTRICT
91944 @@ -103,7 +1041,7 @@ config INTEL_TXT
91945 config LSM_MMAP_MIN_ADDR
91946 int "Low address space for LSM to protect from user allocation"
91947 depends on SECURITY && SECURITY_SELINUX
91948 - default 32768 if ARM
91949 + default 32768 if ALPHA || ARM || PARISC || SPARC32
91950 default 65536
91951 help
91952 This is the portion of low virtual memory which should be protected
91953 diff --git a/security/apparmor/lsm.c b/security/apparmor/lsm.c
91954 index b21830e..a7d1a17 100644
91955 --- a/security/apparmor/lsm.c
91956 +++ b/security/apparmor/lsm.c
91957 @@ -614,7 +614,7 @@ static int apparmor_task_setrlimit(struct task_struct *task,
91958 return error;
91959 }
91960
91961 -static struct security_operations apparmor_ops = {
91962 +static struct security_operations apparmor_ops __read_only = {
91963 .name = "apparmor",
91964
91965 .ptrace_access_check = apparmor_ptrace_access_check,
91966 diff --git a/security/commoncap.c b/security/commoncap.c
91967 index c44b6fe..932df30 100644
91968 --- a/security/commoncap.c
91969 +++ b/security/commoncap.c
91970 @@ -424,6 +424,32 @@ int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data
91971 return 0;
91972 }
91973
91974 +/* returns:
91975 + 1 for suid privilege
91976 + 2 for sgid privilege
91977 + 3 for fscap privilege
91978 +*/
91979 +int is_privileged_binary(const struct dentry *dentry)
91980 +{
91981 + struct cpu_vfs_cap_data capdata;
91982 + struct inode *inode = dentry->d_inode;
91983 +
91984 + if (!inode || S_ISDIR(inode->i_mode))
91985 + return 0;
91986 +
91987 + if (inode->i_mode & S_ISUID)
91988 + return 1;
91989 + if ((inode->i_mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))
91990 + return 2;
91991 +
91992 + if (!get_vfs_caps_from_disk(dentry, &capdata)) {
91993 + if (!cap_isclear(capdata.inheritable) || !cap_isclear(capdata.permitted))
91994 + return 3;
91995 + }
91996 +
91997 + return 0;
91998 +}
91999 +
92000 /*
92001 * Attempt to get the on-exec apply capability sets for an executable file from
92002 * its xattrs and, if present, apply them to the proposed credentials being
92003 @@ -592,6 +618,9 @@ int cap_bprm_secureexec(struct linux_binprm *bprm)
92004 const struct cred *cred = current_cred();
92005 kuid_t root_uid = make_kuid(cred->user_ns, 0);
92006
92007 + if (gr_acl_enable_at_secure())
92008 + return 1;
92009 +
92010 if (!uid_eq(cred->uid, root_uid)) {
92011 if (bprm->cap_effective)
92012 return 1;
92013 diff --git a/security/integrity/ima/ima.h b/security/integrity/ima/ima.h
92014 index a41c9c1..83da6dd 100644
92015 --- a/security/integrity/ima/ima.h
92016 +++ b/security/integrity/ima/ima.h
92017 @@ -97,8 +97,8 @@ int ima_init_crypto(void);
92018 extern spinlock_t ima_queue_lock;
92019
92020 struct ima_h_table {
92021 - atomic_long_t len; /* number of stored measurements in the list */
92022 - atomic_long_t violations;
92023 + atomic_long_unchecked_t len; /* number of stored measurements in the list */
92024 + atomic_long_unchecked_t violations;
92025 struct hlist_head queue[IMA_MEASURE_HTABLE_SIZE];
92026 };
92027 extern struct ima_h_table ima_htable;
92028 diff --git a/security/integrity/ima/ima_api.c b/security/integrity/ima/ima_api.c
92029 index 1c03e8f1..398a941 100644
92030 --- a/security/integrity/ima/ima_api.c
92031 +++ b/security/integrity/ima/ima_api.c
92032 @@ -79,7 +79,7 @@ void ima_add_violation(struct inode *inode, const unsigned char *filename,
92033 int result;
92034
92035 /* can overflow, only indicator */
92036 - atomic_long_inc(&ima_htable.violations);
92037 + atomic_long_inc_unchecked(&ima_htable.violations);
92038
92039 entry = kmalloc(sizeof(*entry), GFP_KERNEL);
92040 if (!entry) {
92041 diff --git a/security/integrity/ima/ima_fs.c b/security/integrity/ima/ima_fs.c
92042 index 38477c9..87a60c7 100644
92043 --- a/security/integrity/ima/ima_fs.c
92044 +++ b/security/integrity/ima/ima_fs.c
92045 @@ -28,12 +28,12 @@
92046 static int valid_policy = 1;
92047 #define TMPBUFLEN 12
92048 static ssize_t ima_show_htable_value(char __user *buf, size_t count,
92049 - loff_t *ppos, atomic_long_t *val)
92050 + loff_t *ppos, atomic_long_unchecked_t *val)
92051 {
92052 char tmpbuf[TMPBUFLEN];
92053 ssize_t len;
92054
92055 - len = scnprintf(tmpbuf, TMPBUFLEN, "%li\n", atomic_long_read(val));
92056 + len = scnprintf(tmpbuf, TMPBUFLEN, "%li\n", atomic_long_read_unchecked(val));
92057 return simple_read_from_buffer(buf, count, ppos, tmpbuf, len);
92058 }
92059
92060 diff --git a/security/integrity/ima/ima_queue.c b/security/integrity/ima/ima_queue.c
92061 index ff63fe0..809cd96 100644
92062 --- a/security/integrity/ima/ima_queue.c
92063 +++ b/security/integrity/ima/ima_queue.c
92064 @@ -80,7 +80,7 @@ static int ima_add_digest_entry(struct ima_template_entry *entry)
92065 INIT_LIST_HEAD(&qe->later);
92066 list_add_tail_rcu(&qe->later, &ima_measurements);
92067
92068 - atomic_long_inc(&ima_htable.len);
92069 + atomic_long_inc_unchecked(&ima_htable.len);
92070 key = ima_hash_key(entry->digest);
92071 hlist_add_head_rcu(&qe->hnext, &ima_htable.queue[key]);
92072 return 0;
92073 diff --git a/security/keys/compat.c b/security/keys/compat.c
92074 index d65fa7f..cbfe366 100644
92075 --- a/security/keys/compat.c
92076 +++ b/security/keys/compat.c
92077 @@ -44,7 +44,7 @@ static long compat_keyctl_instantiate_key_iov(
92078 if (ret == 0)
92079 goto no_payload_free;
92080
92081 - ret = keyctl_instantiate_key_common(id, iov, ioc, ret, ringid);
92082 + ret = keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, ioc, ret, ringid);
92083 err:
92084 if (iov != iovstack)
92085 kfree(iov);
92086 diff --git a/security/keys/internal.h b/security/keys/internal.h
92087 index 8bbefc3..299d03f 100644
92088 --- a/security/keys/internal.h
92089 +++ b/security/keys/internal.h
92090 @@ -240,7 +240,7 @@ extern long keyctl_instantiate_key_iov(key_serial_t,
92091 extern long keyctl_invalidate_key(key_serial_t);
92092
92093 extern long keyctl_instantiate_key_common(key_serial_t,
92094 - const struct iovec *,
92095 + const struct iovec __user *,
92096 unsigned, size_t, key_serial_t);
92097
92098 /*
92099 diff --git a/security/keys/key.c b/security/keys/key.c
92100 index 8fb7c7b..ba3610d 100644
92101 --- a/security/keys/key.c
92102 +++ b/security/keys/key.c
92103 @@ -284,7 +284,7 @@ struct key *key_alloc(struct key_type *type, const char *desc,
92104
92105 atomic_set(&key->usage, 1);
92106 init_rwsem(&key->sem);
92107 - lockdep_set_class(&key->sem, &type->lock_class);
92108 + lockdep_set_class(&key->sem, (struct lock_class_key *)&type->lock_class);
92109 key->type = type;
92110 key->user = user;
92111 key->quotalen = quotalen;
92112 @@ -1032,7 +1032,9 @@ int register_key_type(struct key_type *ktype)
92113 struct key_type *p;
92114 int ret;
92115
92116 - memset(&ktype->lock_class, 0, sizeof(ktype->lock_class));
92117 + pax_open_kernel();
92118 + memset((void *)&ktype->lock_class, 0, sizeof(ktype->lock_class));
92119 + pax_close_kernel();
92120
92121 ret = -EEXIST;
92122 down_write(&key_types_sem);
92123 @@ -1044,7 +1046,7 @@ int register_key_type(struct key_type *ktype)
92124 }
92125
92126 /* store the type */
92127 - list_add(&ktype->link, &key_types_list);
92128 + pax_list_add((struct list_head *)&ktype->link, &key_types_list);
92129
92130 pr_notice("Key type %s registered\n", ktype->name);
92131 ret = 0;
92132 @@ -1066,7 +1068,7 @@ EXPORT_SYMBOL(register_key_type);
92133 void unregister_key_type(struct key_type *ktype)
92134 {
92135 down_write(&key_types_sem);
92136 - list_del_init(&ktype->link);
92137 + pax_list_del_init((struct list_head *)&ktype->link);
92138 downgrade_write(&key_types_sem);
92139 key_gc_keytype(ktype);
92140 pr_notice("Key type %s unregistered\n", ktype->name);
92141 @@ -1084,10 +1086,10 @@ void __init key_init(void)
92142 0, SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
92143
92144 /* add the special key types */
92145 - list_add_tail(&key_type_keyring.link, &key_types_list);
92146 - list_add_tail(&key_type_dead.link, &key_types_list);
92147 - list_add_tail(&key_type_user.link, &key_types_list);
92148 - list_add_tail(&key_type_logon.link, &key_types_list);
92149 + pax_list_add_tail((struct list_head *)&key_type_keyring.link, &key_types_list);
92150 + pax_list_add_tail((struct list_head *)&key_type_dead.link, &key_types_list);
92151 + pax_list_add_tail((struct list_head *)&key_type_user.link, &key_types_list);
92152 + pax_list_add_tail((struct list_head *)&key_type_logon.link, &key_types_list);
92153
92154 /* record the root user tracking */
92155 rb_link_node(&root_key_user.node,
92156 diff --git a/security/keys/keyctl.c b/security/keys/keyctl.c
92157 index 4b5c948..2054dc1 100644
92158 --- a/security/keys/keyctl.c
92159 +++ b/security/keys/keyctl.c
92160 @@ -986,7 +986,7 @@ static int keyctl_change_reqkey_auth(struct key *key)
92161 /*
92162 * Copy the iovec data from userspace
92163 */
92164 -static long copy_from_user_iovec(void *buffer, const struct iovec *iov,
92165 +static long copy_from_user_iovec(void *buffer, const struct iovec __user *iov,
92166 unsigned ioc)
92167 {
92168 for (; ioc > 0; ioc--) {
92169 @@ -1008,7 +1008,7 @@ static long copy_from_user_iovec(void *buffer, const struct iovec *iov,
92170 * If successful, 0 will be returned.
92171 */
92172 long keyctl_instantiate_key_common(key_serial_t id,
92173 - const struct iovec *payload_iov,
92174 + const struct iovec __user *payload_iov,
92175 unsigned ioc,
92176 size_t plen,
92177 key_serial_t ringid)
92178 @@ -1103,7 +1103,7 @@ long keyctl_instantiate_key(key_serial_t id,
92179 [0].iov_len = plen
92180 };
92181
92182 - return keyctl_instantiate_key_common(id, iov, 1, plen, ringid);
92183 + return keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, 1, plen, ringid);
92184 }
92185
92186 return keyctl_instantiate_key_common(id, NULL, 0, 0, ringid);
92187 @@ -1136,7 +1136,7 @@ long keyctl_instantiate_key_iov(key_serial_t id,
92188 if (ret == 0)
92189 goto no_payload_free;
92190
92191 - ret = keyctl_instantiate_key_common(id, iov, ioc, ret, ringid);
92192 + ret = keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, ioc, ret, ringid);
92193 err:
92194 if (iov != iovstack)
92195 kfree(iov);
92196 diff --git a/security/keys/keyring.c b/security/keys/keyring.c
92197 index 6ece7f2..ecdb55c 100644
92198 --- a/security/keys/keyring.c
92199 +++ b/security/keys/keyring.c
92200 @@ -227,16 +227,16 @@ static long keyring_read(const struct key *keyring,
92201 ret = -EFAULT;
92202
92203 for (loop = 0; loop < klist->nkeys; loop++) {
92204 + key_serial_t serial;
92205 key = rcu_deref_link_locked(klist, loop,
92206 keyring);
92207 + serial = key->serial;
92208
92209 tmp = sizeof(key_serial_t);
92210 if (tmp > buflen)
92211 tmp = buflen;
92212
92213 - if (copy_to_user(buffer,
92214 - &key->serial,
92215 - tmp) != 0)
92216 + if (copy_to_user(buffer, &serial, tmp))
92217 goto error;
92218
92219 buflen -= tmp;
92220 diff --git a/security/min_addr.c b/security/min_addr.c
92221 index f728728..6457a0c 100644
92222 --- a/security/min_addr.c
92223 +++ b/security/min_addr.c
92224 @@ -14,6 +14,7 @@ unsigned long dac_mmap_min_addr = CONFIG_DEFAULT_MMAP_MIN_ADDR;
92225 */
92226 static void update_mmap_min_addr(void)
92227 {
92228 +#ifndef SPARC
92229 #ifdef CONFIG_LSM_MMAP_MIN_ADDR
92230 if (dac_mmap_min_addr > CONFIG_LSM_MMAP_MIN_ADDR)
92231 mmap_min_addr = dac_mmap_min_addr;
92232 @@ -22,6 +23,7 @@ static void update_mmap_min_addr(void)
92233 #else
92234 mmap_min_addr = dac_mmap_min_addr;
92235 #endif
92236 +#endif
92237 }
92238
92239 /*
92240 diff --git a/security/security.c b/security/security.c
92241 index 03f248b..5710c33 100644
92242 --- a/security/security.c
92243 +++ b/security/security.c
92244 @@ -20,6 +20,7 @@
92245 #include <linux/ima.h>
92246 #include <linux/evm.h>
92247 #include <linux/fsnotify.h>
92248 +#include <linux/mm.h>
92249 #include <linux/mman.h>
92250 #include <linux/mount.h>
92251 #include <linux/personality.h>
92252 @@ -32,8 +33,8 @@
92253 static __initdata char chosen_lsm[SECURITY_NAME_MAX + 1] =
92254 CONFIG_DEFAULT_SECURITY;
92255
92256 -static struct security_operations *security_ops;
92257 -static struct security_operations default_security_ops = {
92258 +static struct security_operations *security_ops __read_only;
92259 +static struct security_operations default_security_ops __read_only = {
92260 .name = "default",
92261 };
92262
92263 @@ -74,7 +75,9 @@ int __init security_init(void)
92264
92265 void reset_security_ops(void)
92266 {
92267 + pax_open_kernel();
92268 security_ops = &default_security_ops;
92269 + pax_close_kernel();
92270 }
92271
92272 /* Save user chosen LSM */
92273 diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
92274 index 7171a95..c35e879 100644
92275 --- a/security/selinux/hooks.c
92276 +++ b/security/selinux/hooks.c
92277 @@ -96,8 +96,6 @@
92278
92279 #define NUM_SEL_MNT_OPTS 5
92280
92281 -extern struct security_operations *security_ops;
92282 -
92283 /* SECMARK reference count */
92284 static atomic_t selinux_secmark_refcount = ATOMIC_INIT(0);
92285
92286 @@ -5498,7 +5496,7 @@ static int selinux_key_getsecurity(struct key *key, char **_buffer)
92287
92288 #endif
92289
92290 -static struct security_operations selinux_ops = {
92291 +static struct security_operations selinux_ops __read_only = {
92292 .name = "selinux",
92293
92294 .ptrace_access_check = selinux_ptrace_access_check,
92295 diff --git a/security/selinux/include/xfrm.h b/security/selinux/include/xfrm.h
92296 index 65f67cb..3f141ef 100644
92297 --- a/security/selinux/include/xfrm.h
92298 +++ b/security/selinux/include/xfrm.h
92299 @@ -50,7 +50,7 @@ int selinux_xfrm_decode_session(struct sk_buff *skb, u32 *sid, int ckall);
92300
92301 static inline void selinux_xfrm_notify_policyload(void)
92302 {
92303 - atomic_inc(&flow_cache_genid);
92304 + atomic_inc_unchecked(&flow_cache_genid);
92305 rt_genid_bump(&init_net);
92306 }
92307 #else
92308 diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
92309 index fa64740..bc95b74 100644
92310 --- a/security/smack/smack_lsm.c
92311 +++ b/security/smack/smack_lsm.c
92312 @@ -3392,7 +3392,7 @@ static int smack_inode_getsecctx(struct inode *inode, void **ctx, u32 *ctxlen)
92313 return 0;
92314 }
92315
92316 -struct security_operations smack_ops = {
92317 +struct security_operations smack_ops __read_only = {
92318 .name = "smack",
92319
92320 .ptrace_access_check = smack_ptrace_access_check,
92321 diff --git a/security/tomoyo/mount.c b/security/tomoyo/mount.c
92322 index 390c646..f2f8db3 100644
92323 --- a/security/tomoyo/mount.c
92324 +++ b/security/tomoyo/mount.c
92325 @@ -118,6 +118,10 @@ static int tomoyo_mount_acl(struct tomoyo_request_info *r,
92326 type == tomoyo_mounts[TOMOYO_MOUNT_MOVE]) {
92327 need_dev = -1; /* dev_name is a directory */
92328 } else {
92329 + if (!capable(CAP_SYS_ADMIN)) {
92330 + error = -EPERM;
92331 + goto out;
92332 + }
92333 fstype = get_fs_type(type);
92334 if (!fstype) {
92335 error = -ENODEV;
92336 diff --git a/security/tomoyo/tomoyo.c b/security/tomoyo/tomoyo.c
92337 index a2ee362..5754f34 100644
92338 --- a/security/tomoyo/tomoyo.c
92339 +++ b/security/tomoyo/tomoyo.c
92340 @@ -503,7 +503,7 @@ static int tomoyo_socket_sendmsg(struct socket *sock, struct msghdr *msg,
92341 * tomoyo_security_ops is a "struct security_operations" which is used for
92342 * registering TOMOYO.
92343 */
92344 -static struct security_operations tomoyo_security_ops = {
92345 +static struct security_operations tomoyo_security_ops __read_only = {
92346 .name = "tomoyo",
92347 .cred_alloc_blank = tomoyo_cred_alloc_blank,
92348 .cred_prepare = tomoyo_cred_prepare,
92349 diff --git a/security/yama/Kconfig b/security/yama/Kconfig
92350 index 20ef514..4182bed 100644
92351 --- a/security/yama/Kconfig
92352 +++ b/security/yama/Kconfig
92353 @@ -1,6 +1,6 @@
92354 config SECURITY_YAMA
92355 bool "Yama support"
92356 - depends on SECURITY
92357 + depends on SECURITY && !GRKERNSEC
92358 select SECURITYFS
92359 select SECURITY_PATH
92360 default n
92361 diff --git a/security/yama/yama_lsm.c b/security/yama/yama_lsm.c
92362 index 13c88fbc..f8c115e 100644
92363 --- a/security/yama/yama_lsm.c
92364 +++ b/security/yama/yama_lsm.c
92365 @@ -365,7 +365,7 @@ int yama_ptrace_traceme(struct task_struct *parent)
92366 }
92367
92368 #ifndef CONFIG_SECURITY_YAMA_STACKED
92369 -static struct security_operations yama_ops = {
92370 +static struct security_operations yama_ops __read_only = {
92371 .name = "yama",
92372
92373 .ptrace_access_check = yama_ptrace_access_check,
92374 @@ -376,28 +376,24 @@ static struct security_operations yama_ops = {
92375 #endif
92376
92377 #ifdef CONFIG_SYSCTL
92378 +static int zero __read_only;
92379 +static int max_scope __read_only = YAMA_SCOPE_NO_ATTACH;
92380 +
92381 static int yama_dointvec_minmax(struct ctl_table *table, int write,
92382 void __user *buffer, size_t *lenp, loff_t *ppos)
92383 {
92384 - int rc;
92385 + ctl_table_no_const yama_table;
92386
92387 if (write && !capable(CAP_SYS_PTRACE))
92388 return -EPERM;
92389
92390 - rc = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
92391 - if (rc)
92392 - return rc;
92393 -
92394 + yama_table = *table;
92395 /* Lock the max value if it ever gets set. */
92396 - if (write && *(int *)table->data == *(int *)table->extra2)
92397 - table->extra1 = table->extra2;
92398 -
92399 - return rc;
92400 + if (ptrace_scope == max_scope)
92401 + yama_table.extra1 = &max_scope;
92402 + return proc_dointvec_minmax(&yama_table, write, buffer, lenp, ppos);
92403 }
92404
92405 -static int zero;
92406 -static int max_scope = YAMA_SCOPE_NO_ATTACH;
92407 -
92408 struct ctl_path yama_sysctl_path[] = {
92409 { .procname = "kernel", },
92410 { .procname = "yama", },
92411 diff --git a/sound/aoa/codecs/onyx.c b/sound/aoa/codecs/onyx.c
92412 index 4cedc69..e59d8a3 100644
92413 --- a/sound/aoa/codecs/onyx.c
92414 +++ b/sound/aoa/codecs/onyx.c
92415 @@ -54,7 +54,7 @@ struct onyx {
92416 spdif_locked:1,
92417 analog_locked:1,
92418 original_mute:2;
92419 - int open_count;
92420 + local_t open_count;
92421 struct codec_info *codec_info;
92422
92423 /* mutex serializes concurrent access to the device
92424 @@ -753,7 +753,7 @@ static int onyx_open(struct codec_info_item *cii,
92425 struct onyx *onyx = cii->codec_data;
92426
92427 mutex_lock(&onyx->mutex);
92428 - onyx->open_count++;
92429 + local_inc(&onyx->open_count);
92430 mutex_unlock(&onyx->mutex);
92431
92432 return 0;
92433 @@ -765,8 +765,7 @@ static int onyx_close(struct codec_info_item *cii,
92434 struct onyx *onyx = cii->codec_data;
92435
92436 mutex_lock(&onyx->mutex);
92437 - onyx->open_count--;
92438 - if (!onyx->open_count)
92439 + if (local_dec_and_test(&onyx->open_count))
92440 onyx->spdif_locked = onyx->analog_locked = 0;
92441 mutex_unlock(&onyx->mutex);
92442
92443 diff --git a/sound/aoa/codecs/onyx.h b/sound/aoa/codecs/onyx.h
92444 index ffd2025..df062c9 100644
92445 --- a/sound/aoa/codecs/onyx.h
92446 +++ b/sound/aoa/codecs/onyx.h
92447 @@ -11,6 +11,7 @@
92448 #include <linux/i2c.h>
92449 #include <asm/pmac_low_i2c.h>
92450 #include <asm/prom.h>
92451 +#include <asm/local.h>
92452
92453 /* PCM3052 register definitions */
92454
92455 diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c
92456 index 4c1cc51..16040040 100644
92457 --- a/sound/core/oss/pcm_oss.c
92458 +++ b/sound/core/oss/pcm_oss.c
92459 @@ -1189,10 +1189,10 @@ snd_pcm_sframes_t snd_pcm_oss_write3(struct snd_pcm_substream *substream, const
92460 if (in_kernel) {
92461 mm_segment_t fs;
92462 fs = snd_enter_user();
92463 - ret = snd_pcm_lib_write(substream, (void __force __user *)ptr, frames);
92464 + ret = snd_pcm_lib_write(substream, (void __force_user *)ptr, frames);
92465 snd_leave_user(fs);
92466 } else {
92467 - ret = snd_pcm_lib_write(substream, (void __force __user *)ptr, frames);
92468 + ret = snd_pcm_lib_write(substream, (void __force_user *)ptr, frames);
92469 }
92470 if (ret != -EPIPE && ret != -ESTRPIPE)
92471 break;
92472 @@ -1234,10 +1234,10 @@ snd_pcm_sframes_t snd_pcm_oss_read3(struct snd_pcm_substream *substream, char *p
92473 if (in_kernel) {
92474 mm_segment_t fs;
92475 fs = snd_enter_user();
92476 - ret = snd_pcm_lib_read(substream, (void __force __user *)ptr, frames);
92477 + ret = snd_pcm_lib_read(substream, (void __force_user *)ptr, frames);
92478 snd_leave_user(fs);
92479 } else {
92480 - ret = snd_pcm_lib_read(substream, (void __force __user *)ptr, frames);
92481 + ret = snd_pcm_lib_read(substream, (void __force_user *)ptr, frames);
92482 }
92483 if (ret == -EPIPE) {
92484 if (runtime->status->state == SNDRV_PCM_STATE_DRAINING) {
92485 @@ -1337,7 +1337,7 @@ static ssize_t snd_pcm_oss_write2(struct snd_pcm_substream *substream, const cha
92486 struct snd_pcm_plugin_channel *channels;
92487 size_t oss_frame_bytes = (runtime->oss.plugin_first->src_width * runtime->oss.plugin_first->src_format.channels) / 8;
92488 if (!in_kernel) {
92489 - if (copy_from_user(runtime->oss.buffer, (const char __force __user *)buf, bytes))
92490 + if (copy_from_user(runtime->oss.buffer, (const char __force_user *)buf, bytes))
92491 return -EFAULT;
92492 buf = runtime->oss.buffer;
92493 }
92494 @@ -1407,7 +1407,7 @@ static ssize_t snd_pcm_oss_write1(struct snd_pcm_substream *substream, const cha
92495 }
92496 } else {
92497 tmp = snd_pcm_oss_write2(substream,
92498 - (const char __force *)buf,
92499 + (const char __force_kernel *)buf,
92500 runtime->oss.period_bytes, 0);
92501 if (tmp <= 0)
92502 goto err;
92503 @@ -1433,7 +1433,7 @@ static ssize_t snd_pcm_oss_read2(struct snd_pcm_substream *substream, char *buf,
92504 struct snd_pcm_runtime *runtime = substream->runtime;
92505 snd_pcm_sframes_t frames, frames1;
92506 #ifdef CONFIG_SND_PCM_OSS_PLUGINS
92507 - char __user *final_dst = (char __force __user *)buf;
92508 + char __user *final_dst = (char __force_user *)buf;
92509 if (runtime->oss.plugin_first) {
92510 struct snd_pcm_plugin_channel *channels;
92511 size_t oss_frame_bytes = (runtime->oss.plugin_last->dst_width * runtime->oss.plugin_last->dst_format.channels) / 8;
92512 @@ -1495,7 +1495,7 @@ static ssize_t snd_pcm_oss_read1(struct snd_pcm_substream *substream, char __use
92513 xfer += tmp;
92514 runtime->oss.buffer_used -= tmp;
92515 } else {
92516 - tmp = snd_pcm_oss_read2(substream, (char __force *)buf,
92517 + tmp = snd_pcm_oss_read2(substream, (char __force_kernel *)buf,
92518 runtime->oss.period_bytes, 0);
92519 if (tmp <= 0)
92520 goto err;
92521 @@ -1663,7 +1663,7 @@ static int snd_pcm_oss_sync(struct snd_pcm_oss_file *pcm_oss_file)
92522 size1);
92523 size1 /= runtime->channels; /* frames */
92524 fs = snd_enter_user();
92525 - snd_pcm_lib_write(substream, (void __force __user *)runtime->oss.buffer, size1);
92526 + snd_pcm_lib_write(substream, (void __force_user *)runtime->oss.buffer, size1);
92527 snd_leave_user(fs);
92528 }
92529 } else if (runtime->access == SNDRV_PCM_ACCESS_RW_NONINTERLEAVED) {
92530 diff --git a/sound/core/pcm_compat.c b/sound/core/pcm_compat.c
92531 index af49721..e85058e 100644
92532 --- a/sound/core/pcm_compat.c
92533 +++ b/sound/core/pcm_compat.c
92534 @@ -31,7 +31,7 @@ static int snd_pcm_ioctl_delay_compat(struct snd_pcm_substream *substream,
92535 int err;
92536
92537 fs = snd_enter_user();
92538 - err = snd_pcm_delay(substream, &delay);
92539 + err = snd_pcm_delay(substream, (snd_pcm_sframes_t __force_user *)&delay);
92540 snd_leave_user(fs);
92541 if (err < 0)
92542 return err;
92543 diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
92544 index eb560fa..69a4995 100644
92545 --- a/sound/core/pcm_native.c
92546 +++ b/sound/core/pcm_native.c
92547 @@ -2806,11 +2806,11 @@ int snd_pcm_kernel_ioctl(struct snd_pcm_substream *substream,
92548 switch (substream->stream) {
92549 case SNDRV_PCM_STREAM_PLAYBACK:
92550 result = snd_pcm_playback_ioctl1(NULL, substream, cmd,
92551 - (void __user *)arg);
92552 + (void __force_user *)arg);
92553 break;
92554 case SNDRV_PCM_STREAM_CAPTURE:
92555 result = snd_pcm_capture_ioctl1(NULL, substream, cmd,
92556 - (void __user *)arg);
92557 + (void __force_user *)arg);
92558 break;
92559 default:
92560 result = -EINVAL;
92561 diff --git a/sound/core/seq/seq_device.c b/sound/core/seq/seq_device.c
92562 index 040c60e..989a19a 100644
92563 --- a/sound/core/seq/seq_device.c
92564 +++ b/sound/core/seq/seq_device.c
92565 @@ -64,7 +64,7 @@ struct ops_list {
92566 int argsize; /* argument size */
92567
92568 /* operators */
92569 - struct snd_seq_dev_ops ops;
92570 + struct snd_seq_dev_ops *ops;
92571
92572 /* registered devices */
92573 struct list_head dev_list; /* list of devices */
92574 @@ -333,7 +333,7 @@ int snd_seq_device_register_driver(char *id, struct snd_seq_dev_ops *entry,
92575
92576 mutex_lock(&ops->reg_mutex);
92577 /* copy driver operators */
92578 - ops->ops = *entry;
92579 + ops->ops = entry;
92580 ops->driver |= DRIVER_LOADED;
92581 ops->argsize = argsize;
92582
92583 @@ -463,7 +463,7 @@ static int init_device(struct snd_seq_device *dev, struct ops_list *ops)
92584 dev->name, ops->id, ops->argsize, dev->argsize);
92585 return -EINVAL;
92586 }
92587 - if (ops->ops.init_device(dev) >= 0) {
92588 + if (ops->ops->init_device(dev) >= 0) {
92589 dev->status = SNDRV_SEQ_DEVICE_REGISTERED;
92590 ops->num_init_devices++;
92591 } else {
92592 @@ -490,7 +490,7 @@ static int free_device(struct snd_seq_device *dev, struct ops_list *ops)
92593 dev->name, ops->id, ops->argsize, dev->argsize);
92594 return -EINVAL;
92595 }
92596 - if ((result = ops->ops.free_device(dev)) >= 0 || result == -ENXIO) {
92597 + if ((result = ops->ops->free_device(dev)) >= 0 || result == -ENXIO) {
92598 dev->status = SNDRV_SEQ_DEVICE_FREE;
92599 dev->driver_data = NULL;
92600 ops->num_init_devices--;
92601 diff --git a/sound/drivers/mts64.c b/sound/drivers/mts64.c
92602 index 4e0dd22..7a1f32c 100644
92603 --- a/sound/drivers/mts64.c
92604 +++ b/sound/drivers/mts64.c
92605 @@ -29,6 +29,7 @@
92606 #include <sound/initval.h>
92607 #include <sound/rawmidi.h>
92608 #include <sound/control.h>
92609 +#include <asm/local.h>
92610
92611 #define CARD_NAME "Miditerminal 4140"
92612 #define DRIVER_NAME "MTS64"
92613 @@ -67,7 +68,7 @@ struct mts64 {
92614 struct pardevice *pardev;
92615 int pardev_claimed;
92616
92617 - int open_count;
92618 + local_t open_count;
92619 int current_midi_output_port;
92620 int current_midi_input_port;
92621 u8 mode[MTS64_NUM_INPUT_PORTS];
92622 @@ -697,7 +698,7 @@ static int snd_mts64_rawmidi_open(struct snd_rawmidi_substream *substream)
92623 {
92624 struct mts64 *mts = substream->rmidi->private_data;
92625
92626 - if (mts->open_count == 0) {
92627 + if (local_read(&mts->open_count) == 0) {
92628 /* We don't need a spinlock here, because this is just called
92629 if the device has not been opened before.
92630 So there aren't any IRQs from the device */
92631 @@ -705,7 +706,7 @@ static int snd_mts64_rawmidi_open(struct snd_rawmidi_substream *substream)
92632
92633 msleep(50);
92634 }
92635 - ++(mts->open_count);
92636 + local_inc(&mts->open_count);
92637
92638 return 0;
92639 }
92640 @@ -715,8 +716,7 @@ static int snd_mts64_rawmidi_close(struct snd_rawmidi_substream *substream)
92641 struct mts64 *mts = substream->rmidi->private_data;
92642 unsigned long flags;
92643
92644 - --(mts->open_count);
92645 - if (mts->open_count == 0) {
92646 + if (local_dec_return(&mts->open_count) == 0) {
92647 /* We need the spinlock_irqsave here because we can still
92648 have IRQs at this point */
92649 spin_lock_irqsave(&mts->lock, flags);
92650 @@ -725,8 +725,8 @@ static int snd_mts64_rawmidi_close(struct snd_rawmidi_substream *substream)
92651
92652 msleep(500);
92653
92654 - } else if (mts->open_count < 0)
92655 - mts->open_count = 0;
92656 + } else if (local_read(&mts->open_count) < 0)
92657 + local_set(&mts->open_count, 0);
92658
92659 return 0;
92660 }
92661 diff --git a/sound/drivers/opl4/opl4_lib.c b/sound/drivers/opl4/opl4_lib.c
92662 index b953fb4..1999c01 100644
92663 --- a/sound/drivers/opl4/opl4_lib.c
92664 +++ b/sound/drivers/opl4/opl4_lib.c
92665 @@ -29,7 +29,7 @@ MODULE_AUTHOR("Clemens Ladisch <clemens@ladisch.de>");
92666 MODULE_DESCRIPTION("OPL4 driver");
92667 MODULE_LICENSE("GPL");
92668
92669 -static void inline snd_opl4_wait(struct snd_opl4 *opl4)
92670 +static inline void snd_opl4_wait(struct snd_opl4 *opl4)
92671 {
92672 int timeout = 10;
92673 while ((inb(opl4->fm_port) & OPL4_STATUS_BUSY) && --timeout > 0)
92674 diff --git a/sound/drivers/portman2x4.c b/sound/drivers/portman2x4.c
92675 index 991018d..8984740 100644
92676 --- a/sound/drivers/portman2x4.c
92677 +++ b/sound/drivers/portman2x4.c
92678 @@ -48,6 +48,7 @@
92679 #include <sound/initval.h>
92680 #include <sound/rawmidi.h>
92681 #include <sound/control.h>
92682 +#include <asm/local.h>
92683
92684 #define CARD_NAME "Portman 2x4"
92685 #define DRIVER_NAME "portman"
92686 @@ -85,7 +86,7 @@ struct portman {
92687 struct pardevice *pardev;
92688 int pardev_claimed;
92689
92690 - int open_count;
92691 + local_t open_count;
92692 int mode[PORTMAN_NUM_INPUT_PORTS];
92693 struct snd_rawmidi_substream *midi_input[PORTMAN_NUM_INPUT_PORTS];
92694 };
92695 diff --git a/sound/firewire/amdtp.c b/sound/firewire/amdtp.c
92696 index ea995af..f1bfa37 100644
92697 --- a/sound/firewire/amdtp.c
92698 +++ b/sound/firewire/amdtp.c
92699 @@ -389,7 +389,7 @@ static void queue_out_packet(struct amdtp_out_stream *s, unsigned int cycle)
92700 ptr = s->pcm_buffer_pointer + data_blocks;
92701 if (ptr >= pcm->runtime->buffer_size)
92702 ptr -= pcm->runtime->buffer_size;
92703 - ACCESS_ONCE(s->pcm_buffer_pointer) = ptr;
92704 + ACCESS_ONCE_RW(s->pcm_buffer_pointer) = ptr;
92705
92706 s->pcm_period_pointer += data_blocks;
92707 if (s->pcm_period_pointer >= pcm->runtime->period_size) {
92708 @@ -557,7 +557,7 @@ EXPORT_SYMBOL(amdtp_out_stream_pcm_pointer);
92709 */
92710 void amdtp_out_stream_update(struct amdtp_out_stream *s)
92711 {
92712 - ACCESS_ONCE(s->source_node_id_field) =
92713 + ACCESS_ONCE_RW(s->source_node_id_field) =
92714 (fw_parent_device(s->unit)->card->node_id & 0x3f) << 24;
92715 }
92716 EXPORT_SYMBOL(amdtp_out_stream_update);
92717 diff --git a/sound/firewire/amdtp.h b/sound/firewire/amdtp.h
92718 index b680c5e..061b7a0 100644
92719 --- a/sound/firewire/amdtp.h
92720 +++ b/sound/firewire/amdtp.h
92721 @@ -139,7 +139,7 @@ static inline bool amdtp_out_streaming_error(struct amdtp_out_stream *s)
92722 static inline void amdtp_out_stream_pcm_trigger(struct amdtp_out_stream *s,
92723 struct snd_pcm_substream *pcm)
92724 {
92725 - ACCESS_ONCE(s->pcm) = pcm;
92726 + ACCESS_ONCE_RW(s->pcm) = pcm;
92727 }
92728
92729 static inline bool cip_sfc_is_base_44100(enum cip_sfc sfc)
92730 diff --git a/sound/firewire/isight.c b/sound/firewire/isight.c
92731 index d428ffe..751ef78 100644
92732 --- a/sound/firewire/isight.c
92733 +++ b/sound/firewire/isight.c
92734 @@ -96,7 +96,7 @@ static void isight_update_pointers(struct isight *isight, unsigned int count)
92735 ptr += count;
92736 if (ptr >= runtime->buffer_size)
92737 ptr -= runtime->buffer_size;
92738 - ACCESS_ONCE(isight->buffer_pointer) = ptr;
92739 + ACCESS_ONCE_RW(isight->buffer_pointer) = ptr;
92740
92741 isight->period_counter += count;
92742 if (isight->period_counter >= runtime->period_size) {
92743 @@ -307,7 +307,7 @@ static int isight_hw_params(struct snd_pcm_substream *substream,
92744 if (err < 0)
92745 return err;
92746
92747 - ACCESS_ONCE(isight->pcm_active) = true;
92748 + ACCESS_ONCE_RW(isight->pcm_active) = true;
92749
92750 return 0;
92751 }
92752 @@ -340,7 +340,7 @@ static int isight_hw_free(struct snd_pcm_substream *substream)
92753 {
92754 struct isight *isight = substream->private_data;
92755
92756 - ACCESS_ONCE(isight->pcm_active) = false;
92757 + ACCESS_ONCE_RW(isight->pcm_active) = false;
92758
92759 mutex_lock(&isight->mutex);
92760 isight_stop_streaming(isight);
92761 @@ -433,10 +433,10 @@ static int isight_trigger(struct snd_pcm_substream *substream, int cmd)
92762
92763 switch (cmd) {
92764 case SNDRV_PCM_TRIGGER_START:
92765 - ACCESS_ONCE(isight->pcm_running) = true;
92766 + ACCESS_ONCE_RW(isight->pcm_running) = true;
92767 break;
92768 case SNDRV_PCM_TRIGGER_STOP:
92769 - ACCESS_ONCE(isight->pcm_running) = false;
92770 + ACCESS_ONCE_RW(isight->pcm_running) = false;
92771 break;
92772 default:
92773 return -EINVAL;
92774 diff --git a/sound/firewire/scs1x.c b/sound/firewire/scs1x.c
92775 index 844a555..985ab83 100644
92776 --- a/sound/firewire/scs1x.c
92777 +++ b/sound/firewire/scs1x.c
92778 @@ -74,7 +74,7 @@ static void scs_output_trigger(struct snd_rawmidi_substream *stream, int up)
92779 {
92780 struct scs *scs = stream->rmidi->private_data;
92781
92782 - ACCESS_ONCE(scs->output) = up ? stream : NULL;
92783 + ACCESS_ONCE_RW(scs->output) = up ? stream : NULL;
92784 if (up) {
92785 scs->output_idle = false;
92786 tasklet_schedule(&scs->tasklet);
92787 @@ -257,7 +257,7 @@ static void scs_input_trigger(struct snd_rawmidi_substream *stream, int up)
92788 {
92789 struct scs *scs = stream->rmidi->private_data;
92790
92791 - ACCESS_ONCE(scs->input) = up ? stream : NULL;
92792 + ACCESS_ONCE_RW(scs->input) = up ? stream : NULL;
92793 }
92794
92795 static void scs_input_escaped_byte(struct snd_rawmidi_substream *stream,
92796 @@ -457,8 +457,8 @@ static int scs_remove(struct device *dev)
92797
92798 snd_card_disconnect(scs->card);
92799
92800 - ACCESS_ONCE(scs->output) = NULL;
92801 - ACCESS_ONCE(scs->input) = NULL;
92802 + ACCESS_ONCE_RW(scs->output) = NULL;
92803 + ACCESS_ONCE_RW(scs->input) = NULL;
92804
92805 wait_event(scs->idle_wait, scs->output_idle);
92806
92807 diff --git a/sound/oss/sb_audio.c b/sound/oss/sb_audio.c
92808 index 048439a..3be9f6f 100644
92809 --- a/sound/oss/sb_audio.c
92810 +++ b/sound/oss/sb_audio.c
92811 @@ -904,7 +904,7 @@ sb16_copy_from_user(int dev,
92812 buf16 = (signed short *)(localbuf + localoffs);
92813 while (c)
92814 {
92815 - locallen = (c >= LBUFCOPYSIZE ? LBUFCOPYSIZE : c);
92816 + locallen = ((unsigned)c >= LBUFCOPYSIZE ? LBUFCOPYSIZE : c);
92817 if (copy_from_user(lbuf8,
92818 userbuf+useroffs + p,
92819 locallen))
92820 diff --git a/sound/oss/swarm_cs4297a.c b/sound/oss/swarm_cs4297a.c
92821 index 7d8803a..559f8d0 100644
92822 --- a/sound/oss/swarm_cs4297a.c
92823 +++ b/sound/oss/swarm_cs4297a.c
92824 @@ -2621,7 +2621,6 @@ static int __init cs4297a_init(void)
92825 {
92826 struct cs4297a_state *s;
92827 u32 pwr, id;
92828 - mm_segment_t fs;
92829 int rval;
92830 #ifndef CONFIG_BCM_CS4297A_CSWARM
92831 u64 cfg;
92832 @@ -2711,22 +2710,23 @@ static int __init cs4297a_init(void)
92833 if (!rval) {
92834 char *sb1250_duart_present;
92835
92836 +#if 0
92837 + mm_segment_t fs;
92838 fs = get_fs();
92839 set_fs(KERNEL_DS);
92840 -#if 0
92841 val = SOUND_MASK_LINE;
92842 mixer_ioctl(s, SOUND_MIXER_WRITE_RECSRC, (unsigned long) &val);
92843 for (i = 0; i < ARRAY_SIZE(initvol); i++) {
92844 val = initvol[i].vol;
92845 mixer_ioctl(s, initvol[i].mixch, (unsigned long) &val);
92846 }
92847 + set_fs(fs);
92848 // cs4297a_write_ac97(s, 0x18, 0x0808);
92849 #else
92850 // cs4297a_write_ac97(s, 0x5e, 0x180);
92851 cs4297a_write_ac97(s, 0x02, 0x0808);
92852 cs4297a_write_ac97(s, 0x18, 0x0808);
92853 #endif
92854 - set_fs(fs);
92855
92856 list_add(&s->list, &cs4297a_devs);
92857
92858 diff --git a/sound/pci/ymfpci/ymfpci.h b/sound/pci/ymfpci/ymfpci.h
92859 index 4631a23..001ae57 100644
92860 --- a/sound/pci/ymfpci/ymfpci.h
92861 +++ b/sound/pci/ymfpci/ymfpci.h
92862 @@ -358,7 +358,7 @@ struct snd_ymfpci {
92863 spinlock_t reg_lock;
92864 spinlock_t voice_lock;
92865 wait_queue_head_t interrupt_sleep;
92866 - atomic_t interrupt_sleep_count;
92867 + atomic_unchecked_t interrupt_sleep_count;
92868 struct snd_info_entry *proc_entry;
92869 const struct firmware *dsp_microcode;
92870 const struct firmware *controller_microcode;
92871 diff --git a/sound/pci/ymfpci/ymfpci_main.c b/sound/pci/ymfpci/ymfpci_main.c
92872 index 22056c5..25d3244 100644
92873 --- a/sound/pci/ymfpci/ymfpci_main.c
92874 +++ b/sound/pci/ymfpci/ymfpci_main.c
92875 @@ -202,8 +202,8 @@ static void snd_ymfpci_hw_stop(struct snd_ymfpci *chip)
92876 if ((snd_ymfpci_readl(chip, YDSXGR_STATUS) & 2) == 0)
92877 break;
92878 }
92879 - if (atomic_read(&chip->interrupt_sleep_count)) {
92880 - atomic_set(&chip->interrupt_sleep_count, 0);
92881 + if (atomic_read_unchecked(&chip->interrupt_sleep_count)) {
92882 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
92883 wake_up(&chip->interrupt_sleep);
92884 }
92885 __end:
92886 @@ -787,7 +787,7 @@ static void snd_ymfpci_irq_wait(struct snd_ymfpci *chip)
92887 continue;
92888 init_waitqueue_entry(&wait, current);
92889 add_wait_queue(&chip->interrupt_sleep, &wait);
92890 - atomic_inc(&chip->interrupt_sleep_count);
92891 + atomic_inc_unchecked(&chip->interrupt_sleep_count);
92892 schedule_timeout_uninterruptible(msecs_to_jiffies(50));
92893 remove_wait_queue(&chip->interrupt_sleep, &wait);
92894 }
92895 @@ -825,8 +825,8 @@ static irqreturn_t snd_ymfpci_interrupt(int irq, void *dev_id)
92896 snd_ymfpci_writel(chip, YDSXGR_MODE, mode);
92897 spin_unlock(&chip->reg_lock);
92898
92899 - if (atomic_read(&chip->interrupt_sleep_count)) {
92900 - atomic_set(&chip->interrupt_sleep_count, 0);
92901 + if (atomic_read_unchecked(&chip->interrupt_sleep_count)) {
92902 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
92903 wake_up(&chip->interrupt_sleep);
92904 }
92905 }
92906 @@ -2421,7 +2421,7 @@ int snd_ymfpci_create(struct snd_card *card,
92907 spin_lock_init(&chip->reg_lock);
92908 spin_lock_init(&chip->voice_lock);
92909 init_waitqueue_head(&chip->interrupt_sleep);
92910 - atomic_set(&chip->interrupt_sleep_count, 0);
92911 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
92912 chip->card = card;
92913 chip->pci = pci;
92914 chip->irq = -1;
92915 diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c
92916 index 7decbd9..d17d9d0 100644
92917 --- a/sound/soc/fsl/fsl_ssi.c
92918 +++ b/sound/soc/fsl/fsl_ssi.c
92919 @@ -643,7 +643,7 @@ static int fsl_ssi_probe(struct platform_device *pdev)
92920 {
92921 struct fsl_ssi_private *ssi_private;
92922 int ret = 0;
92923 - struct device_attribute *dev_attr = NULL;
92924 + device_attribute_no_const *dev_attr = NULL;
92925 struct device_node *np = pdev->dev.of_node;
92926 const char *p, *sprop;
92927 const uint32_t *iprop;
92928 diff --git a/tools/gcc/.gitignore b/tools/gcc/.gitignore
92929 new file mode 100644
92930 index 0000000..50f2f2f
92931 --- /dev/null
92932 +++ b/tools/gcc/.gitignore
92933 @@ -0,0 +1 @@
92934 +size_overflow_hash.h
92935 diff --git a/tools/gcc/Makefile b/tools/gcc/Makefile
92936 new file mode 100644
92937 index 0000000..144dbee
92938 --- /dev/null
92939 +++ b/tools/gcc/Makefile
92940 @@ -0,0 +1,45 @@
92941 +#CC := gcc
92942 +#PLUGIN_SOURCE_FILES := pax_plugin.c
92943 +#PLUGIN_OBJECT_FILES := $(patsubst %.c,%.o,$(PLUGIN_SOURCE_FILES))
92944 +GCCPLUGINS_DIR := $(shell $(CC) -print-file-name=plugin)
92945 +#CFLAGS += -I$(GCCPLUGINS_DIR)/include -fPIC -O2 -Wall -W -std=gnu99
92946 +
92947 +ifeq ($(PLUGINCC),$(HOSTCC))
92948 +HOSTLIBS := hostlibs
92949 +HOST_EXTRACFLAGS += -I$(GCCPLUGINS_DIR)/include -std=gnu99 -ggdb
92950 +else
92951 +HOSTLIBS := hostcxxlibs
92952 +HOST_EXTRACXXFLAGS += -I$(GCCPLUGINS_DIR)/include -std=gnu++98 -ggdb -Wno-unused-parameter
92953 +endif
92954 +
92955 +$(HOSTLIBS)-$(CONFIG_PAX_CONSTIFY_PLUGIN) := constify_plugin.so
92956 +$(HOSTLIBS)-$(CONFIG_PAX_MEMORY_STACKLEAK) += stackleak_plugin.so
92957 +$(HOSTLIBS)-$(CONFIG_KALLOCSTAT_PLUGIN) += kallocstat_plugin.so
92958 +$(HOSTLIBS)-$(CONFIG_PAX_KERNEXEC_PLUGIN) += kernexec_plugin.so
92959 +$(HOSTLIBS)-$(CONFIG_CHECKER_PLUGIN) += checker_plugin.so
92960 +$(HOSTLIBS)-y += colorize_plugin.so
92961 +$(HOSTLIBS)-$(CONFIG_PAX_SIZE_OVERFLOW) += size_overflow_plugin.so
92962 +$(HOSTLIBS)-$(CONFIG_PAX_LATENT_ENTROPY) += latent_entropy_plugin.so
92963 +$(HOSTLIBS)-$(CONFIG_PAX_MEMORY_STRUCTLEAK) += structleak_plugin.so
92964 +
92965 +always := $($(HOSTLIBS)-y)
92966 +
92967 +constify_plugin-objs := constify_plugin.o
92968 +stackleak_plugin-objs := stackleak_plugin.o
92969 +kallocstat_plugin-objs := kallocstat_plugin.o
92970 +kernexec_plugin-objs := kernexec_plugin.o
92971 +checker_plugin-objs := checker_plugin.o
92972 +colorize_plugin-objs := colorize_plugin.o
92973 +size_overflow_plugin-objs := size_overflow_plugin.o
92974 +latent_entropy_plugin-objs := latent_entropy_plugin.o
92975 +structleak_plugin-objs := structleak_plugin.o
92976 +
92977 +$(obj)/size_overflow_plugin.o: $(objtree)/$(obj)/size_overflow_hash.h
92978 +
92979 +quiet_cmd_build_size_overflow_hash = GENHASH $@
92980 + cmd_build_size_overflow_hash = \
92981 + $(CONFIG_SHELL) $(srctree)/$(src)/generate_size_overflow_hash.sh -d $< -o $@
92982 +$(objtree)/$(obj)/size_overflow_hash.h: $(src)/size_overflow_hash.data FORCE
92983 + $(call if_changed,build_size_overflow_hash)
92984 +
92985 +targets += size_overflow_hash.h
92986 diff --git a/tools/gcc/checker_plugin.c b/tools/gcc/checker_plugin.c
92987 new file mode 100644
92988 index 0000000..22f03c0
92989 --- /dev/null
92990 +++ b/tools/gcc/checker_plugin.c
92991 @@ -0,0 +1,172 @@
92992 +/*
92993 + * Copyright 2011 by the PaX Team <pageexec@freemail.hu>
92994 + * Licensed under the GPL v2
92995 + *
92996 + * Note: the choice of the license means that the compilation process is
92997 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
92998 + * but for the kernel it doesn't matter since it doesn't link against
92999 + * any of the gcc libraries
93000 + *
93001 + * gcc plugin to implement various sparse (source code checker) features
93002 + *
93003 + * TODO:
93004 + * - define separate __iomem, __percpu and __rcu address spaces (lots of code to patch)
93005 + *
93006 + * BUGS:
93007 + * - none known
93008 + */
93009 +#include "gcc-plugin.h"
93010 +#include "config.h"
93011 +#include "system.h"
93012 +#include "coretypes.h"
93013 +#include "tree.h"
93014 +#include "tree-pass.h"
93015 +#include "flags.h"
93016 +#include "intl.h"
93017 +#include "toplev.h"
93018 +#include "plugin.h"
93019 +//#include "expr.h" where are you...
93020 +#include "diagnostic.h"
93021 +#include "plugin-version.h"
93022 +#include "tm.h"
93023 +#include "function.h"
93024 +#include "basic-block.h"
93025 +#include "gimple.h"
93026 +#include "rtl.h"
93027 +#include "emit-rtl.h"
93028 +#include "tree-flow.h"
93029 +#include "target.h"
93030 +
93031 +extern void c_register_addr_space (const char *str, addr_space_t as);
93032 +extern enum machine_mode default_addr_space_pointer_mode (addr_space_t);
93033 +extern enum machine_mode default_addr_space_address_mode (addr_space_t);
93034 +extern bool default_addr_space_valid_pointer_mode(enum machine_mode mode, addr_space_t as);
93035 +extern bool default_addr_space_legitimate_address_p(enum machine_mode mode, rtx mem, bool strict, addr_space_t as);
93036 +extern rtx default_addr_space_legitimize_address(rtx x, rtx oldx, enum machine_mode mode, addr_space_t as);
93037 +
93038 +extern void print_gimple_stmt(FILE *, gimple, int, int);
93039 +extern rtx emit_move_insn(rtx x, rtx y);
93040 +
93041 +int plugin_is_GPL_compatible;
93042 +
93043 +static struct plugin_info checker_plugin_info = {
93044 + .version = "201111150100",
93045 + .help = NULL,
93046 +};
93047 +
93048 +#define ADDR_SPACE_KERNEL 0
93049 +#define ADDR_SPACE_FORCE_KERNEL 1
93050 +#define ADDR_SPACE_USER 2
93051 +#define ADDR_SPACE_FORCE_USER 3
93052 +#define ADDR_SPACE_IOMEM 0
93053 +#define ADDR_SPACE_FORCE_IOMEM 0
93054 +#define ADDR_SPACE_PERCPU 0
93055 +#define ADDR_SPACE_FORCE_PERCPU 0
93056 +#define ADDR_SPACE_RCU 0
93057 +#define ADDR_SPACE_FORCE_RCU 0
93058 +
93059 +static enum machine_mode checker_addr_space_pointer_mode(addr_space_t addrspace)
93060 +{
93061 + return default_addr_space_pointer_mode(ADDR_SPACE_GENERIC);
93062 +}
93063 +
93064 +static enum machine_mode checker_addr_space_address_mode(addr_space_t addrspace)
93065 +{
93066 + return default_addr_space_address_mode(ADDR_SPACE_GENERIC);
93067 +}
93068 +
93069 +static bool checker_addr_space_valid_pointer_mode(enum machine_mode mode, addr_space_t as)
93070 +{
93071 + return default_addr_space_valid_pointer_mode(mode, as);
93072 +}
93073 +
93074 +static bool checker_addr_space_legitimate_address_p(enum machine_mode mode, rtx mem, bool strict, addr_space_t as)
93075 +{
93076 + return default_addr_space_legitimate_address_p(mode, mem, strict, ADDR_SPACE_GENERIC);
93077 +}
93078 +
93079 +static rtx checker_addr_space_legitimize_address(rtx x, rtx oldx, enum machine_mode mode, addr_space_t as)
93080 +{
93081 + return default_addr_space_legitimize_address(x, oldx, mode, as);
93082 +}
93083 +
93084 +static bool checker_addr_space_subset_p(addr_space_t subset, addr_space_t superset)
93085 +{
93086 + if (subset == ADDR_SPACE_FORCE_KERNEL && superset == ADDR_SPACE_KERNEL)
93087 + return true;
93088 +
93089 + if (subset == ADDR_SPACE_FORCE_USER && superset == ADDR_SPACE_USER)
93090 + return true;
93091 +
93092 + if (subset == ADDR_SPACE_FORCE_IOMEM && superset == ADDR_SPACE_IOMEM)
93093 + return true;
93094 +
93095 + if (subset == ADDR_SPACE_KERNEL && superset == ADDR_SPACE_FORCE_USER)
93096 + return true;
93097 +
93098 + if (subset == ADDR_SPACE_KERNEL && superset == ADDR_SPACE_FORCE_IOMEM)
93099 + return true;
93100 +
93101 + if (subset == ADDR_SPACE_USER && superset == ADDR_SPACE_FORCE_KERNEL)
93102 + return true;
93103 +
93104 + if (subset == ADDR_SPACE_IOMEM && superset == ADDR_SPACE_FORCE_KERNEL)
93105 + return true;
93106 +
93107 + return subset == superset;
93108 +}
93109 +
93110 +static rtx checker_addr_space_convert(rtx op, tree from_type, tree to_type)
93111 +{
93112 +// addr_space_t from_as = TYPE_ADDR_SPACE(TREE_TYPE(from_type));
93113 +// addr_space_t to_as = TYPE_ADDR_SPACE(TREE_TYPE(to_type));
93114 +
93115 + return op;
93116 +}
93117 +
93118 +static void register_checker_address_spaces(void *event_data, void *data)
93119 +{
93120 + c_register_addr_space("__kernel", ADDR_SPACE_KERNEL);
93121 + c_register_addr_space("__force_kernel", ADDR_SPACE_FORCE_KERNEL);
93122 + c_register_addr_space("__user", ADDR_SPACE_USER);
93123 + c_register_addr_space("__force_user", ADDR_SPACE_FORCE_USER);
93124 +// c_register_addr_space("__iomem", ADDR_SPACE_IOMEM);
93125 +// c_register_addr_space("__force_iomem", ADDR_SPACE_FORCE_IOMEM);
93126 +// c_register_addr_space("__percpu", ADDR_SPACE_PERCPU);
93127 +// c_register_addr_space("__force_percpu", ADDR_SPACE_FORCE_PERCPU);
93128 +// c_register_addr_space("__rcu", ADDR_SPACE_RCU);
93129 +// c_register_addr_space("__force_rcu", ADDR_SPACE_FORCE_RCU);
93130 +
93131 + targetm.addr_space.pointer_mode = checker_addr_space_pointer_mode;
93132 + targetm.addr_space.address_mode = checker_addr_space_address_mode;
93133 + targetm.addr_space.valid_pointer_mode = checker_addr_space_valid_pointer_mode;
93134 + targetm.addr_space.legitimate_address_p = checker_addr_space_legitimate_address_p;
93135 +// targetm.addr_space.legitimize_address = checker_addr_space_legitimize_address;
93136 + targetm.addr_space.subset_p = checker_addr_space_subset_p;
93137 + targetm.addr_space.convert = checker_addr_space_convert;
93138 +}
93139 +
93140 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
93141 +{
93142 + const char * const plugin_name = plugin_info->base_name;
93143 + const int argc = plugin_info->argc;
93144 + const struct plugin_argument * const argv = plugin_info->argv;
93145 + int i;
93146 +
93147 + if (!plugin_default_version_check(version, &gcc_version)) {
93148 + error(G_("incompatible gcc/plugin versions"));
93149 + return 1;
93150 + }
93151 +
93152 + register_callback(plugin_name, PLUGIN_INFO, NULL, &checker_plugin_info);
93153 +
93154 + for (i = 0; i < argc; ++i)
93155 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
93156 +
93157 + if (TARGET_64BIT == 0)
93158 + return 0;
93159 +
93160 + register_callback(plugin_name, PLUGIN_PRAGMAS, register_checker_address_spaces, NULL);
93161 +
93162 + return 0;
93163 +}
93164 diff --git a/tools/gcc/colorize_plugin.c b/tools/gcc/colorize_plugin.c
93165 new file mode 100644
93166 index 0000000..414fe5e
93167 --- /dev/null
93168 +++ b/tools/gcc/colorize_plugin.c
93169 @@ -0,0 +1,151 @@
93170 +/*
93171 + * Copyright 2012-2013 by PaX Team <pageexec@freemail.hu>
93172 + * Licensed under the GPL v2
93173 + *
93174 + * Note: the choice of the license means that the compilation process is
93175 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
93176 + * but for the kernel it doesn't matter since it doesn't link against
93177 + * any of the gcc libraries
93178 + *
93179 + * gcc plugin to colorize diagnostic output
93180 + *
93181 + */
93182 +
93183 +#include "gcc-plugin.h"
93184 +#include "config.h"
93185 +#include "system.h"
93186 +#include "coretypes.h"
93187 +#include "tree.h"
93188 +#include "tree-pass.h"
93189 +#include "flags.h"
93190 +#include "intl.h"
93191 +#include "toplev.h"
93192 +#include "plugin.h"
93193 +#include "diagnostic.h"
93194 +#include "plugin-version.h"
93195 +#include "tm.h"
93196 +
93197 +int plugin_is_GPL_compatible;
93198 +
93199 +static struct plugin_info colorize_plugin_info = {
93200 + .version = "201302112000",
93201 + .help = NULL,
93202 +};
93203 +
93204 +#define GREEN "\033[32m\033[2m"
93205 +#define LIGHTGREEN "\033[32m\033[1m"
93206 +#define YELLOW "\033[33m\033[2m"
93207 +#define LIGHTYELLOW "\033[33m\033[1m"
93208 +#define RED "\033[31m\033[2m"
93209 +#define LIGHTRED "\033[31m\033[1m"
93210 +#define BLUE "\033[34m\033[2m"
93211 +#define LIGHTBLUE "\033[34m\033[1m"
93212 +#define BRIGHT "\033[m\033[1m"
93213 +#define NORMAL "\033[m"
93214 +
93215 +static diagnostic_starter_fn old_starter;
93216 +static diagnostic_finalizer_fn old_finalizer;
93217 +
93218 +static void start_colorize(diagnostic_context *context, diagnostic_info *diagnostic)
93219 +{
93220 + const char *color;
93221 + char *newprefix;
93222 +
93223 + switch (diagnostic->kind) {
93224 + case DK_NOTE:
93225 + color = LIGHTBLUE;
93226 + break;
93227 +
93228 + case DK_PEDWARN:
93229 + case DK_WARNING:
93230 + color = LIGHTYELLOW;
93231 + break;
93232 +
93233 + case DK_ERROR:
93234 + case DK_FATAL:
93235 + case DK_ICE:
93236 + case DK_PERMERROR:
93237 + case DK_SORRY:
93238 + color = LIGHTRED;
93239 + break;
93240 +
93241 + default:
93242 + color = NORMAL;
93243 + }
93244 +
93245 + old_starter(context, diagnostic);
93246 + if (-1 == asprintf(&newprefix, "%s%s" NORMAL, color, context->printer->prefix))
93247 + return;
93248 + pp_destroy_prefix(context->printer);
93249 + pp_set_prefix(context->printer, newprefix);
93250 +}
93251 +
93252 +static void finalize_colorize(diagnostic_context *context, diagnostic_info *diagnostic)
93253 +{
93254 + old_finalizer(context, diagnostic);
93255 +}
93256 +
93257 +static void colorize_arm(void)
93258 +{
93259 + old_starter = diagnostic_starter(global_dc);
93260 + old_finalizer = diagnostic_finalizer(global_dc);
93261 +
93262 + diagnostic_starter(global_dc) = start_colorize;
93263 + diagnostic_finalizer(global_dc) = finalize_colorize;
93264 +}
93265 +
93266 +static unsigned int execute_colorize_rearm(void)
93267 +{
93268 + if (diagnostic_starter(global_dc) == start_colorize)
93269 + return 0;
93270 +
93271 + colorize_arm();
93272 + return 0;
93273 +}
93274 +
93275 +struct simple_ipa_opt_pass pass_ipa_colorize_rearm = {
93276 + .pass = {
93277 + .type = SIMPLE_IPA_PASS,
93278 + .name = "colorize_rearm",
93279 +#if BUILDING_GCC_VERSION >= 4008
93280 + .optinfo_flags = OPTGROUP_NONE,
93281 +#endif
93282 + .gate = NULL,
93283 + .execute = execute_colorize_rearm,
93284 + .sub = NULL,
93285 + .next = NULL,
93286 + .static_pass_number = 0,
93287 + .tv_id = TV_NONE,
93288 + .properties_required = 0,
93289 + .properties_provided = 0,
93290 + .properties_destroyed = 0,
93291 + .todo_flags_start = 0,
93292 + .todo_flags_finish = 0
93293 + }
93294 +};
93295 +
93296 +static void colorize_start_unit(void *gcc_data, void *user_data)
93297 +{
93298 + colorize_arm();
93299 +}
93300 +
93301 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
93302 +{
93303 + const char * const plugin_name = plugin_info->base_name;
93304 + struct register_pass_info colorize_rearm_pass_info = {
93305 + .pass = &pass_ipa_colorize_rearm.pass,
93306 + .reference_pass_name = "*free_lang_data",
93307 + .ref_pass_instance_number = 1,
93308 + .pos_op = PASS_POS_INSERT_AFTER
93309 + };
93310 +
93311 + if (!plugin_default_version_check(version, &gcc_version)) {
93312 + error(G_("incompatible gcc/plugin versions"));
93313 + return 1;
93314 + }
93315 +
93316 + register_callback(plugin_name, PLUGIN_INFO, NULL, &colorize_plugin_info);
93317 + register_callback(plugin_name, PLUGIN_START_UNIT, &colorize_start_unit, NULL);
93318 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &colorize_rearm_pass_info);
93319 + return 0;
93320 +}
93321 diff --git a/tools/gcc/constify_plugin.c b/tools/gcc/constify_plugin.c
93322 new file mode 100644
93323 index 0000000..c17312d
93324 --- /dev/null
93325 +++ b/tools/gcc/constify_plugin.c
93326 @@ -0,0 +1,560 @@
93327 +/*
93328 + * Copyright 2011 by Emese Revfy <re.emese@gmail.com>
93329 + * Copyright 2011-2013 by PaX Team <pageexec@freemail.hu>
93330 + * Licensed under the GPL v2, or (at your option) v3
93331 + *
93332 + * This gcc plugin constifies all structures which contain only function pointers or are explicitly marked for constification.
93333 + *
93334 + * Homepage:
93335 + * http://www.grsecurity.net/~ephox/const_plugin/
93336 + *
93337 + * Usage:
93338 + * $ gcc -I`gcc -print-file-name=plugin`/include -fPIC -shared -O2 -o constify_plugin.so constify_plugin.c
93339 + * $ gcc -fplugin=constify_plugin.so test.c -O2
93340 + */
93341 +
93342 +#include "gcc-plugin.h"
93343 +#include "config.h"
93344 +#include "system.h"
93345 +#include "coretypes.h"
93346 +#include "tree.h"
93347 +#include "tree-pass.h"
93348 +#include "flags.h"
93349 +#include "intl.h"
93350 +#include "toplev.h"
93351 +#include "plugin.h"
93352 +#include "diagnostic.h"
93353 +#include "plugin-version.h"
93354 +#include "tm.h"
93355 +#include "function.h"
93356 +#include "basic-block.h"
93357 +#include "gimple.h"
93358 +#include "rtl.h"
93359 +#include "emit-rtl.h"
93360 +#include "tree-flow.h"
93361 +#include "target.h"
93362 +#include "langhooks.h"
93363 +
93364 +// should come from c-tree.h if only it were installed for gcc 4.5...
93365 +#define C_TYPE_FIELDS_READONLY(TYPE) TREE_LANG_FLAG_1(TYPE)
93366 +
93367 +// unused type flag in all versions 4.5-4.8
93368 +#define TYPE_CONSTIFY_VISITED(TYPE) TYPE_LANG_FLAG_4(TYPE)
93369 +
93370 +int plugin_is_GPL_compatible;
93371 +
93372 +static struct plugin_info const_plugin_info = {
93373 + .version = "201305231310",
93374 + .help = "no-constify\tturn off constification\n",
93375 +};
93376 +
93377 +typedef struct {
93378 + bool has_fptr_field;
93379 + bool has_writable_field;
93380 + bool has_do_const_field;
93381 + bool has_no_const_field;
93382 +} constify_info;
93383 +
93384 +static const_tree get_field_type(const_tree field)
93385 +{
93386 + return strip_array_types(TREE_TYPE(field));
93387 +}
93388 +
93389 +static bool is_fptr(const_tree field)
93390 +{
93391 + const_tree ptr = get_field_type(field);
93392 +
93393 + if (TREE_CODE(ptr) != POINTER_TYPE)
93394 + return false;
93395 +
93396 + return TREE_CODE(TREE_TYPE(ptr)) == FUNCTION_TYPE;
93397 +}
93398 +
93399 +/*
93400 + * determine whether the given structure type meets the requirements for automatic constification,
93401 + * including the constification attributes on nested structure types
93402 + */
93403 +static void constifiable(const_tree node, constify_info *cinfo)
93404 +{
93405 + const_tree field;
93406 +
93407 + gcc_assert(TREE_CODE(node) == RECORD_TYPE || TREE_CODE(node) == UNION_TYPE);
93408 +
93409 + // e.g., pointer to structure fields while still constructing the structure type
93410 + if (TYPE_FIELDS(node) == NULL_TREE)
93411 + return;
93412 +
93413 + for (field = TYPE_FIELDS(node); field; field = TREE_CHAIN(field)) {
93414 + const_tree type = get_field_type(field);
93415 + enum tree_code code = TREE_CODE(type);
93416 +
93417 + if (node == type)
93418 + continue;
93419 +
93420 + if (is_fptr(field))
93421 + cinfo->has_fptr_field = true;
93422 + else if (!TREE_READONLY(field))
93423 + cinfo->has_writable_field = true;
93424 +
93425 + if (code == RECORD_TYPE || code == UNION_TYPE) {
93426 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
93427 + cinfo->has_do_const_field = true;
93428 + else if (lookup_attribute("no_const", TYPE_ATTRIBUTES(type)))
93429 + cinfo->has_no_const_field = true;
93430 + else
93431 + constifiable(type, cinfo);
93432 + }
93433 + }
93434 +}
93435 +
93436 +static bool constified(const_tree node)
93437 +{
93438 + constify_info cinfo = {
93439 + .has_fptr_field = false,
93440 + .has_writable_field = false,
93441 + .has_do_const_field = false,
93442 + .has_no_const_field = false
93443 + };
93444 +
93445 + gcc_assert(TREE_CODE(node) == RECORD_TYPE || TREE_CODE(node) == UNION_TYPE);
93446 +
93447 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(node))) {
93448 + gcc_assert(!TYPE_READONLY(node));
93449 + return false;
93450 + }
93451 +
93452 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(node))) {
93453 + gcc_assert(TYPE_READONLY(node));
93454 + return true;
93455 + }
93456 +
93457 + constifiable(node, &cinfo);
93458 + if ((!cinfo.has_fptr_field || cinfo.has_writable_field) && !cinfo.has_do_const_field)
93459 + return false;
93460 +
93461 + return TYPE_READONLY(node);
93462 +}
93463 +
93464 +static void deconstify_tree(tree node);
93465 +
93466 +static void deconstify_type(tree type)
93467 +{
93468 + tree field;
93469 +
93470 + gcc_assert(TREE_CODE(type) == RECORD_TYPE || TREE_CODE(type) == UNION_TYPE);
93471 +
93472 + for (field = TYPE_FIELDS(type); field; field = TREE_CHAIN(field)) {
93473 + const_tree fieldtype = get_field_type(field);
93474 +
93475 + // special case handling of simple ptr-to-same-array-type members
93476 + if (TREE_CODE(TREE_TYPE(field)) == POINTER_TYPE) {
93477 + const_tree ptrtype = TREE_TYPE(TREE_TYPE(field));
93478 +
93479 + if (TREE_CODE(ptrtype) != RECORD_TYPE && TREE_CODE(ptrtype) != UNION_TYPE)
93480 + continue;
93481 + if (TREE_TYPE(TREE_TYPE(field)) == type)
93482 + continue;
93483 + if (TYPE_MAIN_VARIANT(ptrtype) == TYPE_MAIN_VARIANT(type)) {
93484 + TREE_TYPE(field) = copy_node(TREE_TYPE(field));
93485 + TREE_TYPE(TREE_TYPE(field)) = type;
93486 + }
93487 + continue;
93488 + }
93489 + if (TREE_CODE(fieldtype) != RECORD_TYPE && TREE_CODE(fieldtype) != UNION_TYPE)
93490 + continue;
93491 + if (!constified(fieldtype))
93492 + continue;
93493 +
93494 + deconstify_tree(field);
93495 + TREE_READONLY(field) = 0;
93496 + }
93497 + TYPE_READONLY(type) = 0;
93498 + C_TYPE_FIELDS_READONLY(type) = 0;
93499 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
93500 + TYPE_ATTRIBUTES(type) = remove_attribute("do_const", TYPE_ATTRIBUTES(type));
93501 +}
93502 +
93503 +static void deconstify_tree(tree node)
93504 +{
93505 + tree old_type, new_type, field;
93506 +
93507 + old_type = TREE_TYPE(node);
93508 + while (TREE_CODE(old_type) == ARRAY_TYPE && TREE_CODE(TREE_TYPE(old_type)) != ARRAY_TYPE) {
93509 + node = TREE_TYPE(node) = copy_node(old_type);
93510 + old_type = TREE_TYPE(old_type);
93511 + }
93512 +
93513 + gcc_assert(TREE_CODE(old_type) == RECORD_TYPE || TREE_CODE(old_type) == UNION_TYPE);
93514 + gcc_assert(TYPE_READONLY(old_type) && (TYPE_QUALS(old_type) & TYPE_QUAL_CONST));
93515 +
93516 + new_type = build_qualified_type(old_type, TYPE_QUALS(old_type) & ~TYPE_QUAL_CONST);
93517 + TYPE_FIELDS(new_type) = copy_list(TYPE_FIELDS(new_type));
93518 + for (field = TYPE_FIELDS(new_type); field; field = TREE_CHAIN(field))
93519 + DECL_FIELD_CONTEXT(field) = new_type;
93520 +
93521 + deconstify_type(new_type);
93522 +
93523 + TREE_TYPE(node) = new_type;
93524 +}
93525 +
93526 +static tree handle_no_const_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
93527 +{
93528 + tree type;
93529 + constify_info cinfo = {
93530 + .has_fptr_field = false,
93531 + .has_writable_field = false,
93532 + .has_do_const_field = false,
93533 + .has_no_const_field = false
93534 + };
93535 +
93536 + *no_add_attrs = true;
93537 + if (TREE_CODE(*node) == FUNCTION_DECL) {
93538 + error("%qE attribute does not apply to functions", name);
93539 + return NULL_TREE;
93540 + }
93541 +
93542 + if (TREE_CODE(*node) == PARM_DECL) {
93543 + error("%qE attribute does not apply to function parameters", name);
93544 + return NULL_TREE;
93545 + }
93546 +
93547 + if (TREE_CODE(*node) == VAR_DECL) {
93548 + error("%qE attribute does not apply to variables", name);
93549 + return NULL_TREE;
93550 + }
93551 +
93552 + if (TYPE_P(*node)) {
93553 + *no_add_attrs = false;
93554 + type = *node;
93555 + } else {
93556 + gcc_assert(TREE_CODE(*node) == TYPE_DECL);
93557 + type = TREE_TYPE(*node);
93558 + }
93559 +
93560 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE) {
93561 + error("%qE attribute applies to struct and union types only", name);
93562 + return NULL_TREE;
93563 + }
93564 +
93565 + if (lookup_attribute(IDENTIFIER_POINTER(name), TYPE_ATTRIBUTES(type))) {
93566 + error("%qE attribute is already applied to the type", name);
93567 + return NULL_TREE;
93568 + }
93569 +
93570 + if (TYPE_P(*node)) {
93571 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
93572 + error("%qE attribute is incompatible with 'do_const'", name);
93573 + return NULL_TREE;
93574 + }
93575 +
93576 + constifiable(type, &cinfo);
93577 + if ((cinfo.has_fptr_field && !cinfo.has_writable_field) || lookup_attribute("do_const", TYPE_ATTRIBUTES(type))) {
93578 + deconstify_tree(*node);
93579 + TYPE_CONSTIFY_VISITED(TREE_TYPE(*node)) = 1;
93580 + return NULL_TREE;
93581 + }
93582 +
93583 + error("%qE attribute used on type that is not constified", name);
93584 + return NULL_TREE;
93585 +}
93586 +
93587 +static void constify_type(tree type)
93588 +{
93589 + TYPE_READONLY(type) = 1;
93590 + C_TYPE_FIELDS_READONLY(type) = 1;
93591 + TYPE_CONSTIFY_VISITED(type) = 1;
93592 +// TYPE_ATTRIBUTES(type) = tree_cons(get_identifier("do_const"), NULL_TREE, TYPE_ATTRIBUTES(type));
93593 +}
93594 +
93595 +static tree handle_do_const_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
93596 +{
93597 + *no_add_attrs = true;
93598 + if (!TYPE_P(*node)) {
93599 + error("%qE attribute applies to types only", name);
93600 + return NULL_TREE;
93601 + }
93602 +
93603 + if (TREE_CODE(*node) != RECORD_TYPE && TREE_CODE(*node) != UNION_TYPE) {
93604 + error("%qE attribute applies to struct and union types only", name);
93605 + return NULL_TREE;
93606 + }
93607 +
93608 + if (lookup_attribute(IDENTIFIER_POINTER(name), TYPE_ATTRIBUTES(*node))) {
93609 + error("%qE attribute is already applied to the type", name);
93610 + return NULL_TREE;
93611 + }
93612 +
93613 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(*node))) {
93614 + error("%qE attribute is incompatible with 'no_const'", name);
93615 + return NULL_TREE;
93616 + }
93617 +
93618 + *no_add_attrs = false;
93619 + return NULL_TREE;
93620 +}
93621 +
93622 +static struct attribute_spec no_const_attr = {
93623 + .name = "no_const",
93624 + .min_length = 0,
93625 + .max_length = 0,
93626 + .decl_required = false,
93627 + .type_required = false,
93628 + .function_type_required = false,
93629 + .handler = handle_no_const_attribute,
93630 +#if BUILDING_GCC_VERSION >= 4007
93631 + .affects_type_identity = true
93632 +#endif
93633 +};
93634 +
93635 +static struct attribute_spec do_const_attr = {
93636 + .name = "do_const",
93637 + .min_length = 0,
93638 + .max_length = 0,
93639 + .decl_required = false,
93640 + .type_required = false,
93641 + .function_type_required = false,
93642 + .handler = handle_do_const_attribute,
93643 +#if BUILDING_GCC_VERSION >= 4007
93644 + .affects_type_identity = true
93645 +#endif
93646 +};
93647 +
93648 +static void register_attributes(void *event_data, void *data)
93649 +{
93650 + register_attribute(&no_const_attr);
93651 + register_attribute(&do_const_attr);
93652 +}
93653 +
93654 +static void finish_type(void *event_data, void *data)
93655 +{
93656 + tree type = (tree)event_data;
93657 + constify_info cinfo = {
93658 + .has_fptr_field = false,
93659 + .has_writable_field = false,
93660 + .has_do_const_field = false,
93661 + .has_no_const_field = false
93662 + };
93663 +
93664 + if (type == NULL_TREE || type == error_mark_node)
93665 + return;
93666 +
93667 + if (TYPE_FIELDS(type) == NULL_TREE || TYPE_CONSTIFY_VISITED(type))
93668 + return;
93669 +
93670 + constifiable(type, &cinfo);
93671 +
93672 + if (TYPE_READONLY(type) && C_TYPE_FIELDS_READONLY(type)) {
93673 + if (!lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
93674 + return;
93675 + if (cinfo.has_writable_field)
93676 + return;
93677 + error("'do_const' attribute used on type that is%sconstified", cinfo.has_fptr_field ? " " : " not ");
93678 + return;
93679 + }
93680 +
93681 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(type))) {
93682 + if ((cinfo.has_fptr_field && !cinfo.has_writable_field) || cinfo.has_do_const_field) {
93683 + deconstify_type(type);
93684 + TYPE_CONSTIFY_VISITED(type) = 1;
93685 + } else
93686 + error("'no_const' attribute used on type that is not constified");
93687 + return;
93688 + }
93689 +
93690 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type))) {
93691 + constify_type(type);
93692 + return;
93693 + }
93694 +
93695 + if (cinfo.has_fptr_field && !cinfo.has_writable_field) {
93696 + constify_type(type);
93697 + return;
93698 + }
93699 +
93700 + deconstify_type(type);
93701 + TYPE_CONSTIFY_VISITED(type) = 1;
93702 +}
93703 +
93704 +static void check_global_variables(void)
93705 +{
93706 + struct varpool_node *node;
93707 +
93708 +#if BUILDING_GCC_VERSION <= 4007
93709 + for (node = varpool_nodes; node; node = node->next) {
93710 + tree var = node->decl;
93711 +#else
93712 + FOR_EACH_VARIABLE(node) {
93713 + tree var = node->symbol.decl;
93714 +#endif
93715 + tree type = TREE_TYPE(var);
93716 +
93717 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
93718 + continue;
93719 +
93720 + if (!TYPE_READONLY(type) || !C_TYPE_FIELDS_READONLY(type))
93721 + continue;
93722 +
93723 + if (!TYPE_CONSTIFY_VISITED(type))
93724 + continue;
93725 +
93726 + if (DECL_EXTERNAL(var))
93727 + continue;
93728 +
93729 + if (DECL_INITIAL(var))
93730 + continue;
93731 +
93732 + // this works around a gcc bug/feature where uninitialized globals
93733 + // are moved into the .bss section regardless of any constification
93734 + DECL_INITIAL(var) = build_constructor(type, NULL);
93735 +// inform(DECL_SOURCE_LOCATION(var), "constified variable %qE moved into .rodata", var);
93736 + }
93737 +}
93738 +
93739 +static unsigned int check_local_variables(void)
93740 +{
93741 + unsigned int ret = 0;
93742 + tree var;
93743 +
93744 +#if BUILDING_GCC_VERSION == 4005
93745 + tree vars;
93746 +#else
93747 + unsigned int i;
93748 +#endif
93749 +
93750 +#if BUILDING_GCC_VERSION == 4005
93751 + for (vars = cfun->local_decls; vars; vars = TREE_CHAIN(vars)) {
93752 + var = TREE_VALUE(vars);
93753 +#else
93754 + FOR_EACH_LOCAL_DECL(cfun, i, var) {
93755 +#endif
93756 + tree type = TREE_TYPE(var);
93757 +
93758 + gcc_assert(DECL_P(var));
93759 + if (is_global_var(var))
93760 + continue;
93761 +
93762 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
93763 + continue;
93764 +
93765 + if (!TYPE_READONLY(type) || !C_TYPE_FIELDS_READONLY(type))
93766 + continue;
93767 +
93768 + if (!TYPE_CONSTIFY_VISITED(type))
93769 + continue;
93770 +
93771 + error_at(DECL_SOURCE_LOCATION(var), "constified variable %qE cannot be local", var);
93772 + ret = 1;
93773 + }
93774 + return ret;
93775 +}
93776 +
93777 +static unsigned int check_variables(void)
93778 +{
93779 + check_global_variables();
93780 + return check_local_variables();
93781 +}
93782 +
93783 + unsigned int ret = 0;
93784 +static struct gimple_opt_pass pass_local_variable = {
93785 + {
93786 + .type = GIMPLE_PASS,
93787 + .name = "check_variables",
93788 +#if BUILDING_GCC_VERSION >= 4008
93789 + .optinfo_flags = OPTGROUP_NONE,
93790 +#endif
93791 + .gate = NULL,
93792 + .execute = check_variables,
93793 + .sub = NULL,
93794 + .next = NULL,
93795 + .static_pass_number = 0,
93796 + .tv_id = TV_NONE,
93797 + .properties_required = 0,
93798 + .properties_provided = 0,
93799 + .properties_destroyed = 0,
93800 + .todo_flags_start = 0,
93801 + .todo_flags_finish = 0
93802 + }
93803 +};
93804 +
93805 +static struct {
93806 + const char *name;
93807 + const char *asm_op;
93808 +} sections[] = {
93809 + {".init.rodata", "\t.section\t.init.rodata,\"a\""},
93810 + {".ref.rodata", "\t.section\t.ref.rodata,\"a\""},
93811 + {".devinit.rodata", "\t.section\t.devinit.rodata,\"a\""},
93812 + {".devexit.rodata", "\t.section\t.devexit.rodata,\"a\""},
93813 + {".cpuinit.rodata", "\t.section\t.cpuinit.rodata,\"a\""},
93814 + {".cpuexit.rodata", "\t.section\t.cpuexit.rodata,\"a\""},
93815 + {".meminit.rodata", "\t.section\t.meminit.rodata,\"a\""},
93816 + {".memexit.rodata", "\t.section\t.memexit.rodata,\"a\""},
93817 + {".data..read_only", "\t.section\t.data..read_only,\"a\""},
93818 +};
93819 +
93820 +static unsigned int (*old_section_type_flags)(tree decl, const char *name, int reloc);
93821 +
93822 +static unsigned int constify_section_type_flags(tree decl, const char *name, int reloc)
93823 +{
93824 + size_t i;
93825 +
93826 + for (i = 0; i < ARRAY_SIZE(sections); i++)
93827 + if (!strcmp(sections[i].name, name))
93828 + return 0;
93829 + return old_section_type_flags(decl, name, reloc);
93830 +}
93831 +
93832 +static void constify_start_unit(void *gcc_data, void *user_data)
93833 +{
93834 +// size_t i;
93835 +
93836 +// for (i = 0; i < ARRAY_SIZE(sections); i++)
93837 +// sections[i].section = get_unnamed_section(0, output_section_asm_op, sections[i].asm_op);
93838 +// sections[i].section = get_section(sections[i].name, 0, NULL);
93839 +
93840 + old_section_type_flags = targetm.section_type_flags;
93841 + targetm.section_type_flags = constify_section_type_flags;
93842 +}
93843 +
93844 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
93845 +{
93846 + const char * const plugin_name = plugin_info->base_name;
93847 + const int argc = plugin_info->argc;
93848 + const struct plugin_argument * const argv = plugin_info->argv;
93849 + int i;
93850 + bool constify = true;
93851 +
93852 + struct register_pass_info local_variable_pass_info = {
93853 + .pass = &pass_local_variable.pass,
93854 + .reference_pass_name = "ssa",
93855 + .ref_pass_instance_number = 1,
93856 + .pos_op = PASS_POS_INSERT_BEFORE
93857 + };
93858 +
93859 + if (!plugin_default_version_check(version, &gcc_version)) {
93860 + error(G_("incompatible gcc/plugin versions"));
93861 + return 1;
93862 + }
93863 +
93864 + for (i = 0; i < argc; ++i) {
93865 + if (!(strcmp(argv[i].key, "no-constify"))) {
93866 + constify = false;
93867 + continue;
93868 + }
93869 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
93870 + }
93871 +
93872 + if (strcmp(lang_hooks.name, "GNU C")) {
93873 + inform(UNKNOWN_LOCATION, G_("%s supports C only"), plugin_name);
93874 + constify = false;
93875 + }
93876 +
93877 + register_callback(plugin_name, PLUGIN_INFO, NULL, &const_plugin_info);
93878 + if (constify) {
93879 + register_callback(plugin_name, PLUGIN_FINISH_TYPE, finish_type, NULL);
93880 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &local_variable_pass_info);
93881 + register_callback(plugin_name, PLUGIN_START_UNIT, constify_start_unit, NULL);
93882 + }
93883 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
93884 +
93885 + return 0;
93886 +}
93887 diff --git a/tools/gcc/generate_size_overflow_hash.sh b/tools/gcc/generate_size_overflow_hash.sh
93888 new file mode 100644
93889 index 0000000..e518932
93890 --- /dev/null
93891 +++ b/tools/gcc/generate_size_overflow_hash.sh
93892 @@ -0,0 +1,94 @@
93893 +#!/bin/bash
93894 +
93895 +# This script generates the hash table (size_overflow_hash.h) for the size_overflow gcc plugin (size_overflow_plugin.c).
93896 +
93897 +header1="size_overflow_hash.h"
93898 +database="size_overflow_hash.data"
93899 +n=65536
93900 +
93901 +usage() {
93902 +cat <<EOF
93903 +usage: $0 options
93904 +OPTIONS:
93905 + -h|--help help
93906 + -o header file
93907 + -d database file
93908 + -n hash array size
93909 +EOF
93910 + return 0
93911 +}
93912 +
93913 +while true
93914 +do
93915 + case "$1" in
93916 + -h|--help) usage && exit 0;;
93917 + -n) n=$2; shift 2;;
93918 + -o) header1="$2"; shift 2;;
93919 + -d) database="$2"; shift 2;;
93920 + --) shift 1; break ;;
93921 + *) break ;;
93922 + esac
93923 +done
93924 +
93925 +create_defines() {
93926 + for i in `seq 0 31`
93927 + do
93928 + echo -e "#define PARAM"$i" (1U << "$i")" >> "$header1"
93929 + done
93930 + echo >> "$header1"
93931 +}
93932 +
93933 +create_structs() {
93934 + rm -f "$header1"
93935 +
93936 + create_defines
93937 +
93938 + cat "$database" | while read data
93939 + do
93940 + data_array=($data)
93941 + struct_hash_name="${data_array[0]}"
93942 + funcn="${data_array[1]}"
93943 + params="${data_array[2]}"
93944 + next="${data_array[4]}"
93945 +
93946 + echo "const struct size_overflow_hash $struct_hash_name = {" >> "$header1"
93947 +
93948 + echo -e "\t.next\t= $next,\n\t.name\t= \"$funcn\"," >> "$header1"
93949 + echo -en "\t.param\t= " >> "$header1"
93950 + line=
93951 + for param_num in ${params//-/ };
93952 + do
93953 + line="${line}PARAM"$param_num"|"
93954 + done
93955 +
93956 + echo -e "${line%?},\n};\n" >> "$header1"
93957 + done
93958 +}
93959 +
93960 +create_headers() {
93961 + echo "const struct size_overflow_hash * const size_overflow_hash[$n] = {" >> "$header1"
93962 +}
93963 +
93964 +create_array_elements() {
93965 + index=0
93966 + grep -v "nohasharray" $database | sort -n -k 4 | while read data
93967 + do
93968 + data_array=($data)
93969 + i="${data_array[3]}"
93970 + hash="${data_array[0]}"
93971 + while [[ $index -lt $i ]]
93972 + do
93973 + echo -e "\t["$index"]\t= NULL," >> "$header1"
93974 + index=$(($index + 1))
93975 + done
93976 + index=$(($index + 1))
93977 + echo -e "\t["$i"]\t= &"$hash"," >> "$header1"
93978 + done
93979 + echo '};' >> $header1
93980 +}
93981 +
93982 +create_structs
93983 +create_headers
93984 +create_array_elements
93985 +
93986 +exit 0
93987 diff --git a/tools/gcc/kallocstat_plugin.c b/tools/gcc/kallocstat_plugin.c
93988 new file mode 100644
93989 index 0000000..568b360
93990 --- /dev/null
93991 +++ b/tools/gcc/kallocstat_plugin.c
93992 @@ -0,0 +1,170 @@
93993 +/*
93994 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
93995 + * Licensed under the GPL v2
93996 + *
93997 + * Note: the choice of the license means that the compilation process is
93998 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
93999 + * but for the kernel it doesn't matter since it doesn't link against
94000 + * any of the gcc libraries
94001 + *
94002 + * gcc plugin to find the distribution of k*alloc sizes
94003 + *
94004 + * TODO:
94005 + *
94006 + * BUGS:
94007 + * - none known
94008 + */
94009 +#include "gcc-plugin.h"
94010 +#include "config.h"
94011 +#include "system.h"
94012 +#include "coretypes.h"
94013 +#include "tree.h"
94014 +#include "tree-pass.h"
94015 +#include "flags.h"
94016 +#include "intl.h"
94017 +#include "toplev.h"
94018 +#include "plugin.h"
94019 +//#include "expr.h" where are you...
94020 +#include "diagnostic.h"
94021 +#include "plugin-version.h"
94022 +#include "tm.h"
94023 +#include "function.h"
94024 +#include "basic-block.h"
94025 +#include "gimple.h"
94026 +#include "rtl.h"
94027 +#include "emit-rtl.h"
94028 +
94029 +extern void print_gimple_stmt(FILE *, gimple, int, int);
94030 +
94031 +int plugin_is_GPL_compatible;
94032 +
94033 +static const char * const kalloc_functions[] = {
94034 + "__kmalloc",
94035 + "kmalloc",
94036 + "kmalloc_large",
94037 + "kmalloc_node",
94038 + "kmalloc_order",
94039 + "kmalloc_order_trace",
94040 + "kmalloc_slab",
94041 + "kzalloc",
94042 + "kzalloc_node",
94043 +};
94044 +
94045 +static struct plugin_info kallocstat_plugin_info = {
94046 + .version = "201302112000",
94047 +};
94048 +
94049 +static unsigned int execute_kallocstat(void);
94050 +
94051 +static struct gimple_opt_pass kallocstat_pass = {
94052 + .pass = {
94053 + .type = GIMPLE_PASS,
94054 + .name = "kallocstat",
94055 +#if BUILDING_GCC_VERSION >= 4008
94056 + .optinfo_flags = OPTGROUP_NONE,
94057 +#endif
94058 + .gate = NULL,
94059 + .execute = execute_kallocstat,
94060 + .sub = NULL,
94061 + .next = NULL,
94062 + .static_pass_number = 0,
94063 + .tv_id = TV_NONE,
94064 + .properties_required = 0,
94065 + .properties_provided = 0,
94066 + .properties_destroyed = 0,
94067 + .todo_flags_start = 0,
94068 + .todo_flags_finish = 0
94069 + }
94070 +};
94071 +
94072 +static bool is_kalloc(const char *fnname)
94073 +{
94074 + size_t i;
94075 +
94076 + for (i = 0; i < ARRAY_SIZE(kalloc_functions); i++)
94077 + if (!strcmp(fnname, kalloc_functions[i]))
94078 + return true;
94079 + return false;
94080 +}
94081 +
94082 +static unsigned int execute_kallocstat(void)
94083 +{
94084 + basic_block bb;
94085 +
94086 + // 1. loop through BBs and GIMPLE statements
94087 + FOR_EACH_BB(bb) {
94088 + gimple_stmt_iterator gsi;
94089 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
94090 + // gimple match:
94091 + tree fndecl, size;
94092 + gimple call_stmt;
94093 + const char *fnname;
94094 +
94095 + // is it a call
94096 + call_stmt = gsi_stmt(gsi);
94097 + if (!is_gimple_call(call_stmt))
94098 + continue;
94099 + fndecl = gimple_call_fndecl(call_stmt);
94100 + if (fndecl == NULL_TREE)
94101 + continue;
94102 + if (TREE_CODE(fndecl) != FUNCTION_DECL)
94103 + continue;
94104 +
94105 + // is it a call to k*alloc
94106 + fnname = IDENTIFIER_POINTER(DECL_NAME(fndecl));
94107 + if (!is_kalloc(fnname))
94108 + continue;
94109 +
94110 + // is the size arg the result of a simple const assignment
94111 + size = gimple_call_arg(call_stmt, 0);
94112 + while (true) {
94113 + gimple def_stmt;
94114 + expanded_location xloc;
94115 + size_t size_val;
94116 +
94117 + if (TREE_CODE(size) != SSA_NAME)
94118 + break;
94119 + def_stmt = SSA_NAME_DEF_STMT(size);
94120 + if (!def_stmt || !is_gimple_assign(def_stmt))
94121 + break;
94122 + if (gimple_num_ops(def_stmt) != 2)
94123 + break;
94124 + size = gimple_assign_rhs1(def_stmt);
94125 + if (!TREE_CONSTANT(size))
94126 + continue;
94127 + xloc = expand_location(gimple_location(def_stmt));
94128 + if (!xloc.file)
94129 + xloc = expand_location(DECL_SOURCE_LOCATION(current_function_decl));
94130 + size_val = TREE_INT_CST_LOW(size);
94131 + fprintf(stderr, "kallocsize: %8zu %8zx %s %s:%u\n", size_val, size_val, fnname, xloc.file, xloc.line);
94132 + break;
94133 + }
94134 +//print_gimple_stmt(stderr, call_stmt, 0, TDF_LINENO);
94135 +//debug_tree(gimple_call_fn(call_stmt));
94136 +//print_node(stderr, "pax", fndecl, 4);
94137 + }
94138 + }
94139 +
94140 + return 0;
94141 +}
94142 +
94143 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
94144 +{
94145 + const char * const plugin_name = plugin_info->base_name;
94146 + struct register_pass_info kallocstat_pass_info = {
94147 + .pass = &kallocstat_pass.pass,
94148 + .reference_pass_name = "ssa",
94149 + .ref_pass_instance_number = 1,
94150 + .pos_op = PASS_POS_INSERT_AFTER
94151 + };
94152 +
94153 + if (!plugin_default_version_check(version, &gcc_version)) {
94154 + error(G_("incompatible gcc/plugin versions"));
94155 + return 1;
94156 + }
94157 +
94158 + register_callback(plugin_name, PLUGIN_INFO, NULL, &kallocstat_plugin_info);
94159 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kallocstat_pass_info);
94160 +
94161 + return 0;
94162 +}
94163 diff --git a/tools/gcc/kernexec_plugin.c b/tools/gcc/kernexec_plugin.c
94164 new file mode 100644
94165 index 0000000..0408e06
94166 --- /dev/null
94167 +++ b/tools/gcc/kernexec_plugin.c
94168 @@ -0,0 +1,465 @@
94169 +/*
94170 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
94171 + * Licensed under the GPL v2
94172 + *
94173 + * Note: the choice of the license means that the compilation process is
94174 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
94175 + * but for the kernel it doesn't matter since it doesn't link against
94176 + * any of the gcc libraries
94177 + *
94178 + * gcc plugin to make KERNEXEC/amd64 almost as good as it is on i386
94179 + *
94180 + * TODO:
94181 + *
94182 + * BUGS:
94183 + * - none known
94184 + */
94185 +#include "gcc-plugin.h"
94186 +#include "config.h"
94187 +#include "system.h"
94188 +#include "coretypes.h"
94189 +#include "tree.h"
94190 +#include "tree-pass.h"
94191 +#include "flags.h"
94192 +#include "intl.h"
94193 +#include "toplev.h"
94194 +#include "plugin.h"
94195 +//#include "expr.h" where are you...
94196 +#include "diagnostic.h"
94197 +#include "plugin-version.h"
94198 +#include "tm.h"
94199 +#include "function.h"
94200 +#include "basic-block.h"
94201 +#include "gimple.h"
94202 +#include "rtl.h"
94203 +#include "emit-rtl.h"
94204 +#include "tree-flow.h"
94205 +
94206 +extern void print_gimple_stmt(FILE *, gimple, int, int);
94207 +extern rtx emit_move_insn(rtx x, rtx y);
94208 +
94209 +#if BUILDING_GCC_VERSION <= 4006
94210 +#define ANY_RETURN_P(rtx) (GET_CODE(rtx) == RETURN)
94211 +#endif
94212 +
94213 +#if BUILDING_GCC_VERSION >= 4008
94214 +#define TODO_dump_func 0
94215 +#endif
94216 +
94217 +int plugin_is_GPL_compatible;
94218 +
94219 +static struct plugin_info kernexec_plugin_info = {
94220 + .version = "201302112000",
94221 + .help = "method=[bts|or]\tinstrumentation method\n"
94222 +};
94223 +
94224 +static unsigned int execute_kernexec_reload(void);
94225 +static unsigned int execute_kernexec_fptr(void);
94226 +static unsigned int execute_kernexec_retaddr(void);
94227 +static bool kernexec_cmodel_check(void);
94228 +
94229 +static void (*kernexec_instrument_fptr)(gimple_stmt_iterator *);
94230 +static void (*kernexec_instrument_retaddr)(rtx);
94231 +
94232 +static struct gimple_opt_pass kernexec_reload_pass = {
94233 + .pass = {
94234 + .type = GIMPLE_PASS,
94235 + .name = "kernexec_reload",
94236 +#if BUILDING_GCC_VERSION >= 4008
94237 + .optinfo_flags = OPTGROUP_NONE,
94238 +#endif
94239 + .gate = kernexec_cmodel_check,
94240 + .execute = execute_kernexec_reload,
94241 + .sub = NULL,
94242 + .next = NULL,
94243 + .static_pass_number = 0,
94244 + .tv_id = TV_NONE,
94245 + .properties_required = 0,
94246 + .properties_provided = 0,
94247 + .properties_destroyed = 0,
94248 + .todo_flags_start = 0,
94249 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_remove_unused_locals | TODO_update_ssa_no_phi
94250 + }
94251 +};
94252 +
94253 +static struct gimple_opt_pass kernexec_fptr_pass = {
94254 + .pass = {
94255 + .type = GIMPLE_PASS,
94256 + .name = "kernexec_fptr",
94257 +#if BUILDING_GCC_VERSION >= 4008
94258 + .optinfo_flags = OPTGROUP_NONE,
94259 +#endif
94260 + .gate = kernexec_cmodel_check,
94261 + .execute = execute_kernexec_fptr,
94262 + .sub = NULL,
94263 + .next = NULL,
94264 + .static_pass_number = 0,
94265 + .tv_id = TV_NONE,
94266 + .properties_required = 0,
94267 + .properties_provided = 0,
94268 + .properties_destroyed = 0,
94269 + .todo_flags_start = 0,
94270 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_remove_unused_locals | TODO_update_ssa_no_phi
94271 + }
94272 +};
94273 +
94274 +static struct rtl_opt_pass kernexec_retaddr_pass = {
94275 + .pass = {
94276 + .type = RTL_PASS,
94277 + .name = "kernexec_retaddr",
94278 +#if BUILDING_GCC_VERSION >= 4008
94279 + .optinfo_flags = OPTGROUP_NONE,
94280 +#endif
94281 + .gate = kernexec_cmodel_check,
94282 + .execute = execute_kernexec_retaddr,
94283 + .sub = NULL,
94284 + .next = NULL,
94285 + .static_pass_number = 0,
94286 + .tv_id = TV_NONE,
94287 + .properties_required = 0,
94288 + .properties_provided = 0,
94289 + .properties_destroyed = 0,
94290 + .todo_flags_start = 0,
94291 + .todo_flags_finish = TODO_dump_func | TODO_ggc_collect
94292 + }
94293 +};
94294 +
94295 +static bool kernexec_cmodel_check(void)
94296 +{
94297 + tree section;
94298 +
94299 + if (ix86_cmodel != CM_KERNEL)
94300 + return false;
94301 +
94302 + section = lookup_attribute("section", DECL_ATTRIBUTES(current_function_decl));
94303 + if (!section || !TREE_VALUE(section))
94304 + return true;
94305 +
94306 + section = TREE_VALUE(TREE_VALUE(section));
94307 + if (strncmp(TREE_STRING_POINTER(section), ".vsyscall_", 10))
94308 + return true;
94309 +
94310 + return false;
94311 +}
94312 +
94313 +/*
94314 + * add special KERNEXEC instrumentation: reload %r10 after it has been clobbered
94315 + */
94316 +static void kernexec_reload_fptr_mask(gimple_stmt_iterator *gsi)
94317 +{
94318 + gimple asm_movabs_stmt;
94319 +
94320 + // build asm volatile("movabs $0x8000000000000000, %%r10\n\t" : : : );
94321 + asm_movabs_stmt = gimple_build_asm_vec("movabs $0x8000000000000000, %%r10\n\t", NULL, NULL, NULL, NULL);
94322 + gimple_asm_set_volatile(asm_movabs_stmt, true);
94323 + gsi_insert_after(gsi, asm_movabs_stmt, GSI_CONTINUE_LINKING);
94324 + update_stmt(asm_movabs_stmt);
94325 +}
94326 +
94327 +/*
94328 + * find all asm() stmts that clobber r10 and add a reload of r10
94329 + */
94330 +static unsigned int execute_kernexec_reload(void)
94331 +{
94332 + basic_block bb;
94333 +
94334 + // 1. loop through BBs and GIMPLE statements
94335 + FOR_EACH_BB(bb) {
94336 + gimple_stmt_iterator gsi;
94337 +
94338 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
94339 + // gimple match: __asm__ ("" : : : "r10");
94340 + gimple asm_stmt;
94341 + size_t nclobbers;
94342 +
94343 + // is it an asm ...
94344 + asm_stmt = gsi_stmt(gsi);
94345 + if (gimple_code(asm_stmt) != GIMPLE_ASM)
94346 + continue;
94347 +
94348 + // ... clobbering r10
94349 + nclobbers = gimple_asm_nclobbers(asm_stmt);
94350 + while (nclobbers--) {
94351 + tree op = gimple_asm_clobber_op(asm_stmt, nclobbers);
94352 + if (strcmp(TREE_STRING_POINTER(TREE_VALUE(op)), "r10"))
94353 + continue;
94354 + kernexec_reload_fptr_mask(&gsi);
94355 +//print_gimple_stmt(stderr, asm_stmt, 0, TDF_LINENO);
94356 + break;
94357 + }
94358 + }
94359 + }
94360 +
94361 + return 0;
94362 +}
94363 +
94364 +/*
94365 + * add special KERNEXEC instrumentation: force MSB of fptr to 1, which will produce
94366 + * a non-canonical address from a userland ptr and will just trigger a GPF on dereference
94367 + */
94368 +static void kernexec_instrument_fptr_bts(gimple_stmt_iterator *gsi)
94369 +{
94370 + gimple assign_intptr, assign_new_fptr, call_stmt;
94371 + tree intptr, old_fptr, new_fptr, kernexec_mask;
94372 +
94373 + call_stmt = gsi_stmt(*gsi);
94374 + old_fptr = gimple_call_fn(call_stmt);
94375 +
94376 + // create temporary unsigned long variable used for bitops and cast fptr to it
94377 + intptr = create_tmp_var(long_unsigned_type_node, "kernexec_bts");
94378 +#if BUILDING_GCC_VERSION <= 4007
94379 + add_referenced_var(intptr);
94380 + mark_sym_for_renaming(intptr);
94381 +#endif
94382 + assign_intptr = gimple_build_assign(intptr, fold_convert(long_unsigned_type_node, old_fptr));
94383 + gsi_insert_before(gsi, assign_intptr, GSI_SAME_STMT);
94384 + update_stmt(assign_intptr);
94385 +
94386 + // apply logical or to temporary unsigned long and bitmask
94387 + kernexec_mask = build_int_cstu(long_long_unsigned_type_node, 0x8000000000000000LL);
94388 +// kernexec_mask = build_int_cstu(long_long_unsigned_type_node, 0xffffffff80000000LL);
94389 + assign_intptr = gimple_build_assign(intptr, fold_build2(BIT_IOR_EXPR, long_long_unsigned_type_node, intptr, kernexec_mask));
94390 + gsi_insert_before(gsi, assign_intptr, GSI_SAME_STMT);
94391 + update_stmt(assign_intptr);
94392 +
94393 + // cast temporary unsigned long back to a temporary fptr variable
94394 + new_fptr = create_tmp_var(TREE_TYPE(old_fptr), "kernexec_fptr");
94395 +#if BUILDING_GCC_VERSION <= 4007
94396 + add_referenced_var(new_fptr);
94397 + mark_sym_for_renaming(new_fptr);
94398 +#endif
94399 + assign_new_fptr = gimple_build_assign(new_fptr, fold_convert(TREE_TYPE(old_fptr), intptr));
94400 + gsi_insert_before(gsi, assign_new_fptr, GSI_SAME_STMT);
94401 + update_stmt(assign_new_fptr);
94402 +
94403 + // replace call stmt fn with the new fptr
94404 + gimple_call_set_fn(call_stmt, new_fptr);
94405 + update_stmt(call_stmt);
94406 +}
94407 +
94408 +static void kernexec_instrument_fptr_or(gimple_stmt_iterator *gsi)
94409 +{
94410 + gimple asm_or_stmt, call_stmt;
94411 + tree old_fptr, new_fptr, input, output;
94412 +#if BUILDING_GCC_VERSION <= 4007
94413 + VEC(tree, gc) *inputs = NULL;
94414 + VEC(tree, gc) *outputs = NULL;
94415 +#else
94416 + vec<tree, va_gc> *inputs = NULL;
94417 + vec<tree, va_gc> *outputs = NULL;
94418 +#endif
94419 +
94420 + call_stmt = gsi_stmt(*gsi);
94421 + old_fptr = gimple_call_fn(call_stmt);
94422 +
94423 + // create temporary fptr variable
94424 + new_fptr = create_tmp_var(TREE_TYPE(old_fptr), "kernexec_or");
94425 +#if BUILDING_GCC_VERSION <= 4007
94426 + add_referenced_var(new_fptr);
94427 + mark_sym_for_renaming(new_fptr);
94428 +#endif
94429 +
94430 + // build asm volatile("orq %%r10, %0\n\t" : "=r"(new_fptr) : "0"(old_fptr));
94431 + input = build_tree_list(NULL_TREE, build_string(2, "0"));
94432 + input = chainon(NULL_TREE, build_tree_list(input, old_fptr));
94433 + output = build_tree_list(NULL_TREE, build_string(3, "=r"));
94434 + output = chainon(NULL_TREE, build_tree_list(output, new_fptr));
94435 +#if BUILDING_GCC_VERSION <= 4007
94436 + VEC_safe_push(tree, gc, inputs, input);
94437 + VEC_safe_push(tree, gc, outputs, output);
94438 +#else
94439 + vec_safe_push(inputs, input);
94440 + vec_safe_push(outputs, output);
94441 +#endif
94442 + asm_or_stmt = gimple_build_asm_vec("orq %%r10, %0\n\t", inputs, outputs, NULL, NULL);
94443 + gimple_asm_set_volatile(asm_or_stmt, true);
94444 + gsi_insert_before(gsi, asm_or_stmt, GSI_SAME_STMT);
94445 + update_stmt(asm_or_stmt);
94446 +
94447 + // replace call stmt fn with the new fptr
94448 + gimple_call_set_fn(call_stmt, new_fptr);
94449 + update_stmt(call_stmt);
94450 +}
94451 +
94452 +/*
94453 + * find all C level function pointer dereferences and forcibly set the highest bit of the pointer
94454 + */
94455 +static unsigned int execute_kernexec_fptr(void)
94456 +{
94457 + basic_block bb;
94458 +
94459 + // 1. loop through BBs and GIMPLE statements
94460 + FOR_EACH_BB(bb) {
94461 + gimple_stmt_iterator gsi;
94462 +
94463 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
94464 + // gimple match: h_1 = get_fptr (); D.2709_3 = h_1 (x_2(D));
94465 + tree fn;
94466 + gimple call_stmt;
94467 +
94468 + // is it a call ...
94469 + call_stmt = gsi_stmt(gsi);
94470 + if (!is_gimple_call(call_stmt))
94471 + continue;
94472 + fn = gimple_call_fn(call_stmt);
94473 + if (TREE_CODE(fn) == ADDR_EXPR)
94474 + continue;
94475 + if (TREE_CODE(fn) != SSA_NAME)
94476 + gcc_unreachable();
94477 +
94478 + // ... through a function pointer
94479 + if (SSA_NAME_VAR(fn) != NULL_TREE) {
94480 + fn = SSA_NAME_VAR(fn);
94481 + if (TREE_CODE(fn) != VAR_DECL && TREE_CODE(fn) != PARM_DECL) {
94482 + debug_tree(fn);
94483 + gcc_unreachable();
94484 + }
94485 + }
94486 + fn = TREE_TYPE(fn);
94487 + if (TREE_CODE(fn) != POINTER_TYPE)
94488 + continue;
94489 + fn = TREE_TYPE(fn);
94490 + if (TREE_CODE(fn) != FUNCTION_TYPE)
94491 + continue;
94492 +
94493 + kernexec_instrument_fptr(&gsi);
94494 +
94495 +//debug_tree(gimple_call_fn(call_stmt));
94496 +//print_gimple_stmt(stderr, call_stmt, 0, TDF_LINENO);
94497 + }
94498 + }
94499 +
94500 + return 0;
94501 +}
94502 +
94503 +// add special KERNEXEC instrumentation: btsq $63,(%rsp) just before retn
94504 +static void kernexec_instrument_retaddr_bts(rtx insn)
94505 +{
94506 + rtx btsq;
94507 + rtvec argvec, constraintvec, labelvec;
94508 + int line;
94509 +
94510 + // create asm volatile("btsq $63,(%%rsp)":::)
94511 + argvec = rtvec_alloc(0);
94512 + constraintvec = rtvec_alloc(0);
94513 + labelvec = rtvec_alloc(0);
94514 + line = expand_location(RTL_LOCATION(insn)).line;
94515 + btsq = gen_rtx_ASM_OPERANDS(VOIDmode, "btsq $63,(%%rsp)", empty_string, 0, argvec, constraintvec, labelvec, line);
94516 + MEM_VOLATILE_P(btsq) = 1;
94517 +// RTX_FRAME_RELATED_P(btsq) = 1; // not for ASM_OPERANDS
94518 + emit_insn_before(btsq, insn);
94519 +}
94520 +
94521 +// add special KERNEXEC instrumentation: orq %r10,(%rsp) just before retn
94522 +static void kernexec_instrument_retaddr_or(rtx insn)
94523 +{
94524 + rtx orq;
94525 + rtvec argvec, constraintvec, labelvec;
94526 + int line;
94527 +
94528 + // create asm volatile("orq %%r10,(%%rsp)":::)
94529 + argvec = rtvec_alloc(0);
94530 + constraintvec = rtvec_alloc(0);
94531 + labelvec = rtvec_alloc(0);
94532 + line = expand_location(RTL_LOCATION(insn)).line;
94533 + orq = gen_rtx_ASM_OPERANDS(VOIDmode, "orq %%r10,(%%rsp)", empty_string, 0, argvec, constraintvec, labelvec, line);
94534 + MEM_VOLATILE_P(orq) = 1;
94535 +// RTX_FRAME_RELATED_P(orq) = 1; // not for ASM_OPERANDS
94536 + emit_insn_before(orq, insn);
94537 +}
94538 +
94539 +/*
94540 + * find all asm level function returns and forcibly set the highest bit of the return address
94541 + */
94542 +static unsigned int execute_kernexec_retaddr(void)
94543 +{
94544 + rtx insn;
94545 +
94546 + // 1. find function returns
94547 + for (insn = get_insns(); insn; insn = NEXT_INSN(insn)) {
94548 + // rtl match: (jump_insn 41 40 42 2 (return) fptr.c:42 634 {return_internal} (nil))
94549 + // (jump_insn 12 9 11 2 (parallel [ (return) (unspec [ (0) ] UNSPEC_REP) ]) fptr.c:46 635 {return_internal_long} (nil))
94550 + // (jump_insn 97 96 98 6 (simple_return) fptr.c:50 -1 (nil) -> simple_return)
94551 + rtx body;
94552 +
94553 + // is it a retn
94554 + if (!JUMP_P(insn))
94555 + continue;
94556 + body = PATTERN(insn);
94557 + if (GET_CODE(body) == PARALLEL)
94558 + body = XVECEXP(body, 0, 0);
94559 + if (!ANY_RETURN_P(body))
94560 + continue;
94561 + kernexec_instrument_retaddr(insn);
94562 + }
94563 +
94564 +// print_simple_rtl(stderr, get_insns());
94565 +// print_rtl(stderr, get_insns());
94566 +
94567 + return 0;
94568 +}
94569 +
94570 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
94571 +{
94572 + const char * const plugin_name = plugin_info->base_name;
94573 + const int argc = plugin_info->argc;
94574 + const struct plugin_argument * const argv = plugin_info->argv;
94575 + int i;
94576 + struct register_pass_info kernexec_reload_pass_info = {
94577 + .pass = &kernexec_reload_pass.pass,
94578 + .reference_pass_name = "ssa",
94579 + .ref_pass_instance_number = 1,
94580 + .pos_op = PASS_POS_INSERT_AFTER
94581 + };
94582 + struct register_pass_info kernexec_fptr_pass_info = {
94583 + .pass = &kernexec_fptr_pass.pass,
94584 + .reference_pass_name = "ssa",
94585 + .ref_pass_instance_number = 1,
94586 + .pos_op = PASS_POS_INSERT_AFTER
94587 + };
94588 + struct register_pass_info kernexec_retaddr_pass_info = {
94589 + .pass = &kernexec_retaddr_pass.pass,
94590 + .reference_pass_name = "pro_and_epilogue",
94591 + .ref_pass_instance_number = 1,
94592 + .pos_op = PASS_POS_INSERT_AFTER
94593 + };
94594 +
94595 + if (!plugin_default_version_check(version, &gcc_version)) {
94596 + error(G_("incompatible gcc/plugin versions"));
94597 + return 1;
94598 + }
94599 +
94600 + register_callback(plugin_name, PLUGIN_INFO, NULL, &kernexec_plugin_info);
94601 +
94602 + if (TARGET_64BIT == 0)
94603 + return 0;
94604 +
94605 + for (i = 0; i < argc; ++i) {
94606 + if (!strcmp(argv[i].key, "method")) {
94607 + if (!argv[i].value) {
94608 + error(G_("no value supplied for option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
94609 + continue;
94610 + }
94611 + if (!strcmp(argv[i].value, "bts")) {
94612 + kernexec_instrument_fptr = kernexec_instrument_fptr_bts;
94613 + kernexec_instrument_retaddr = kernexec_instrument_retaddr_bts;
94614 + } else if (!strcmp(argv[i].value, "or")) {
94615 + kernexec_instrument_fptr = kernexec_instrument_fptr_or;
94616 + kernexec_instrument_retaddr = kernexec_instrument_retaddr_or;
94617 + fix_register("r10", 1, 1);
94618 + } else
94619 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
94620 + continue;
94621 + }
94622 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
94623 + }
94624 + if (!kernexec_instrument_fptr || !kernexec_instrument_retaddr)
94625 + error(G_("no instrumentation method was selected via '-fplugin-arg-%s-method'"), plugin_name);
94626 +
94627 + if (kernexec_instrument_fptr == kernexec_instrument_fptr_or)
94628 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_reload_pass_info);
94629 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_fptr_pass_info);
94630 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_retaddr_pass_info);
94631 +
94632 + return 0;
94633 +}
94634 diff --git a/tools/gcc/latent_entropy_plugin.c b/tools/gcc/latent_entropy_plugin.c
94635 new file mode 100644
94636 index 0000000..b5395ba
94637 --- /dev/null
94638 +++ b/tools/gcc/latent_entropy_plugin.c
94639 @@ -0,0 +1,327 @@
94640 +/*
94641 + * Copyright 2012-2013 by the PaX Team <pageexec@freemail.hu>
94642 + * Licensed under the GPL v2
94643 + *
94644 + * Note: the choice of the license means that the compilation process is
94645 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
94646 + * but for the kernel it doesn't matter since it doesn't link against
94647 + * any of the gcc libraries
94648 + *
94649 + * gcc plugin to help generate a little bit of entropy from program state,
94650 + * used during boot in the kernel
94651 + *
94652 + * TODO:
94653 + * - add ipa pass to identify not explicitly marked candidate functions
94654 + * - mix in more program state (function arguments/return values, loop variables, etc)
94655 + * - more instrumentation control via attribute parameters
94656 + *
94657 + * BUGS:
94658 + * - LTO needs -flto-partition=none for now
94659 + */
94660 +#include "gcc-plugin.h"
94661 +#include "config.h"
94662 +#include "system.h"
94663 +#include "coretypes.h"
94664 +#include "tree.h"
94665 +#include "tree-pass.h"
94666 +#include "flags.h"
94667 +#include "intl.h"
94668 +#include "toplev.h"
94669 +#include "plugin.h"
94670 +//#include "expr.h" where are you...
94671 +#include "diagnostic.h"
94672 +#include "plugin-version.h"
94673 +#include "tm.h"
94674 +#include "function.h"
94675 +#include "basic-block.h"
94676 +#include "gimple.h"
94677 +#include "rtl.h"
94678 +#include "emit-rtl.h"
94679 +#include "tree-flow.h"
94680 +#include "langhooks.h"
94681 +
94682 +#if BUILDING_GCC_VERSION >= 4008
94683 +#define TODO_dump_func 0
94684 +#endif
94685 +
94686 +int plugin_is_GPL_compatible;
94687 +
94688 +static tree latent_entropy_decl;
94689 +
94690 +static struct plugin_info latent_entropy_plugin_info = {
94691 + .version = "201303102320",
94692 + .help = NULL
94693 +};
94694 +
94695 +static unsigned int execute_latent_entropy(void);
94696 +static bool gate_latent_entropy(void);
94697 +
94698 +static struct gimple_opt_pass latent_entropy_pass = {
94699 + .pass = {
94700 + .type = GIMPLE_PASS,
94701 + .name = "latent_entropy",
94702 +#if BUILDING_GCC_VERSION >= 4008
94703 + .optinfo_flags = OPTGROUP_NONE,
94704 +#endif
94705 + .gate = gate_latent_entropy,
94706 + .execute = execute_latent_entropy,
94707 + .sub = NULL,
94708 + .next = NULL,
94709 + .static_pass_number = 0,
94710 + .tv_id = TV_NONE,
94711 + .properties_required = PROP_gimple_leh | PROP_cfg,
94712 + .properties_provided = 0,
94713 + .properties_destroyed = 0,
94714 + .todo_flags_start = 0, //TODO_verify_ssa | TODO_verify_flow | TODO_verify_stmts,
94715 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_update_ssa
94716 + }
94717 +};
94718 +
94719 +static tree handle_latent_entropy_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
94720 +{
94721 + if (TREE_CODE(*node) != FUNCTION_DECL) {
94722 + *no_add_attrs = true;
94723 + error("%qE attribute only applies to functions", name);
94724 + }
94725 + return NULL_TREE;
94726 +}
94727 +
94728 +static struct attribute_spec latent_entropy_attr = {
94729 + .name = "latent_entropy",
94730 + .min_length = 0,
94731 + .max_length = 0,
94732 + .decl_required = true,
94733 + .type_required = false,
94734 + .function_type_required = false,
94735 + .handler = handle_latent_entropy_attribute,
94736 +#if BUILDING_GCC_VERSION >= 4007
94737 + .affects_type_identity = false
94738 +#endif
94739 +};
94740 +
94741 +static void register_attributes(void *event_data, void *data)
94742 +{
94743 + register_attribute(&latent_entropy_attr);
94744 +}
94745 +
94746 +static bool gate_latent_entropy(void)
94747 +{
94748 + tree latent_entropy_attr;
94749 +
94750 + latent_entropy_attr = lookup_attribute("latent_entropy", DECL_ATTRIBUTES(current_function_decl));
94751 + return latent_entropy_attr != NULL_TREE;
94752 +}
94753 +
94754 +static unsigned HOST_WIDE_INT seed;
94755 +static unsigned HOST_WIDE_INT get_random_const(void)
94756 +{
94757 + seed = (seed >> 1U) ^ (-(seed & 1ULL) & 0xD800000000000000ULL);
94758 + return seed;
94759 +}
94760 +
94761 +static enum tree_code get_op(tree *rhs)
94762 +{
94763 + static enum tree_code op;
94764 + unsigned HOST_WIDE_INT random_const;
94765 +
94766 + random_const = get_random_const();
94767 +
94768 + switch (op) {
94769 + case BIT_XOR_EXPR:
94770 + op = PLUS_EXPR;
94771 + break;
94772 +
94773 + case PLUS_EXPR:
94774 + if (rhs) {
94775 + op = LROTATE_EXPR;
94776 + random_const &= HOST_BITS_PER_WIDE_INT - 1;
94777 + break;
94778 + }
94779 +
94780 + case LROTATE_EXPR:
94781 + default:
94782 + op = BIT_XOR_EXPR;
94783 + break;
94784 + }
94785 + if (rhs)
94786 + *rhs = build_int_cstu(unsigned_intDI_type_node, random_const);
94787 + return op;
94788 +}
94789 +
94790 +static void perturb_local_entropy(basic_block bb, tree local_entropy)
94791 +{
94792 + gimple_stmt_iterator gsi;
94793 + gimple assign;
94794 + tree addxorrol, rhs;
94795 + enum tree_code op;
94796 +
94797 + op = get_op(&rhs);
94798 + addxorrol = fold_build2_loc(UNKNOWN_LOCATION, op, unsigned_intDI_type_node, local_entropy, rhs);
94799 + assign = gimple_build_assign(local_entropy, addxorrol);
94800 +#if BUILDING_GCC_VERSION <= 4007
94801 + find_referenced_vars_in(assign);
94802 +#endif
94803 +//debug_bb(bb);
94804 + gsi = gsi_after_labels(bb);
94805 + gsi_insert_before(&gsi, assign, GSI_NEW_STMT);
94806 + update_stmt(assign);
94807 +}
94808 +
94809 +static void perturb_latent_entropy(basic_block bb, tree rhs)
94810 +{
94811 + gimple_stmt_iterator gsi;
94812 + gimple assign;
94813 + tree addxorrol, temp;
94814 +
94815 + // 1. create temporary copy of latent_entropy
94816 + temp = create_tmp_var(unsigned_intDI_type_node, "temp_latent_entropy");
94817 +#if BUILDING_GCC_VERSION <= 4007
94818 + add_referenced_var(temp);
94819 + mark_sym_for_renaming(temp);
94820 +#endif
94821 +
94822 + // 2. read...
94823 + assign = gimple_build_assign(temp, latent_entropy_decl);
94824 +#if BUILDING_GCC_VERSION <= 4007
94825 + find_referenced_vars_in(assign);
94826 +#endif
94827 + gsi = gsi_after_labels(bb);
94828 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
94829 + update_stmt(assign);
94830 +
94831 + // 3. ...modify...
94832 + addxorrol = fold_build2_loc(UNKNOWN_LOCATION, get_op(NULL), unsigned_intDI_type_node, temp, rhs);
94833 + assign = gimple_build_assign(temp, addxorrol);
94834 +#if BUILDING_GCC_VERSION <= 4007
94835 + find_referenced_vars_in(assign);
94836 +#endif
94837 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
94838 + update_stmt(assign);
94839 +
94840 + // 4. ...write latent_entropy
94841 + assign = gimple_build_assign(latent_entropy_decl, temp);
94842 +#if BUILDING_GCC_VERSION <= 4007
94843 + find_referenced_vars_in(assign);
94844 +#endif
94845 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
94846 + update_stmt(assign);
94847 +}
94848 +
94849 +static unsigned int execute_latent_entropy(void)
94850 +{
94851 + basic_block bb;
94852 + gimple assign;
94853 + gimple_stmt_iterator gsi;
94854 + tree local_entropy;
94855 +
94856 + if (!latent_entropy_decl) {
94857 + struct varpool_node *node;
94858 +
94859 +#if BUILDING_GCC_VERSION <= 4007
94860 + for (node = varpool_nodes; node; node = node->next) {
94861 + tree var = node->decl;
94862 +#else
94863 + FOR_EACH_VARIABLE(node) {
94864 + tree var = node->symbol.decl;
94865 +#endif
94866 + if (strcmp(IDENTIFIER_POINTER(DECL_NAME(var)), "latent_entropy"))
94867 + continue;
94868 + latent_entropy_decl = var;
94869 +// debug_tree(var);
94870 + break;
94871 + }
94872 + if (!latent_entropy_decl) {
94873 +// debug_tree(current_function_decl);
94874 + return 0;
94875 + }
94876 + }
94877 +
94878 +//fprintf(stderr, "latent_entropy: %s\n", IDENTIFIER_POINTER(DECL_NAME(current_function_decl)));
94879 +
94880 + // 1. create local entropy variable
94881 + local_entropy = create_tmp_var(unsigned_intDI_type_node, "local_entropy");
94882 +#if BUILDING_GCC_VERSION <= 4007
94883 + add_referenced_var(local_entropy);
94884 + mark_sym_for_renaming(local_entropy);
94885 +#endif
94886 +
94887 + // 2. initialize local entropy variable
94888 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
94889 + if (dom_info_available_p(CDI_DOMINATORS))
94890 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
94891 + gsi = gsi_start_bb(bb);
94892 +
94893 + assign = gimple_build_assign(local_entropy, build_int_cstu(unsigned_intDI_type_node, get_random_const()));
94894 +// gimple_set_location(assign, loc);
94895 +#if BUILDING_GCC_VERSION <= 4007
94896 + find_referenced_vars_in(assign);
94897 +#endif
94898 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
94899 + update_stmt(assign);
94900 + bb = bb->next_bb;
94901 +
94902 + // 3. instrument each BB with an operation on the local entropy variable
94903 + while (bb != EXIT_BLOCK_PTR) {
94904 + perturb_local_entropy(bb, local_entropy);
94905 + bb = bb->next_bb;
94906 + };
94907 +
94908 + // 4. mix local entropy into the global entropy variable
94909 + perturb_latent_entropy(EXIT_BLOCK_PTR->prev_bb, local_entropy);
94910 + return 0;
94911 +}
94912 +
94913 +static void start_unit_callback(void *gcc_data, void *user_data)
94914 +{
94915 + tree latent_entropy_type;
94916 +
94917 +#if BUILDING_GCC_VERSION >= 4007
94918 + seed = get_random_seed(false);
94919 +#else
94920 + sscanf(get_random_seed(false), "%" HOST_WIDE_INT_PRINT "x", &seed);
94921 + seed *= seed;
94922 +#endif
94923 +
94924 + if (in_lto_p)
94925 + return;
94926 +
94927 + // extern volatile u64 latent_entropy
94928 + gcc_assert(TYPE_PRECISION(long_long_unsigned_type_node) == 64);
94929 + latent_entropy_type = build_qualified_type(long_long_unsigned_type_node, TYPE_QUALS(long_long_unsigned_type_node) | TYPE_QUAL_VOLATILE);
94930 + latent_entropy_decl = build_decl(UNKNOWN_LOCATION, VAR_DECL, get_identifier("latent_entropy"), latent_entropy_type);
94931 +
94932 + TREE_STATIC(latent_entropy_decl) = 1;
94933 + TREE_PUBLIC(latent_entropy_decl) = 1;
94934 + TREE_USED(latent_entropy_decl) = 1;
94935 + TREE_THIS_VOLATILE(latent_entropy_decl) = 1;
94936 + DECL_EXTERNAL(latent_entropy_decl) = 1;
94937 + DECL_ARTIFICIAL(latent_entropy_decl) = 1;
94938 + DECL_INITIAL(latent_entropy_decl) = NULL;
94939 + lang_hooks.decls.pushdecl(latent_entropy_decl);
94940 +// DECL_ASSEMBLER_NAME(latent_entropy_decl);
94941 +// varpool_finalize_decl(latent_entropy_decl);
94942 +// varpool_mark_needed_node(latent_entropy_decl);
94943 +}
94944 +
94945 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
94946 +{
94947 + const char * const plugin_name = plugin_info->base_name;
94948 + struct register_pass_info latent_entropy_pass_info = {
94949 + .pass = &latent_entropy_pass.pass,
94950 + .reference_pass_name = "optimized",
94951 + .ref_pass_instance_number = 1,
94952 + .pos_op = PASS_POS_INSERT_BEFORE
94953 + };
94954 +
94955 + if (!plugin_default_version_check(version, &gcc_version)) {
94956 + error(G_("incompatible gcc/plugin versions"));
94957 + return 1;
94958 + }
94959 +
94960 + register_callback(plugin_name, PLUGIN_INFO, NULL, &latent_entropy_plugin_info);
94961 + register_callback ("start_unit", PLUGIN_START_UNIT, &start_unit_callback, NULL);
94962 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &latent_entropy_pass_info);
94963 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
94964 +
94965 + return 0;
94966 +}
94967 diff --git a/tools/gcc/size_overflow_hash.data b/tools/gcc/size_overflow_hash.data
94968 new file mode 100644
94969 index 0000000..7982a0c
94970 --- /dev/null
94971 +++ b/tools/gcc/size_overflow_hash.data
94972 @@ -0,0 +1,5893 @@
94973 +intel_fake_agp_alloc_by_type_1 intel_fake_agp_alloc_by_type 1 1 NULL
94974 +batadv_orig_node_del_if_4 batadv_orig_node_del_if 2 4 NULL
94975 +storvsc_connect_to_vsp_22 storvsc_connect_to_vsp 2 22 NULL
94976 +compat_sock_setsockopt_23 compat_sock_setsockopt 5 23 NULL
94977 +carl9170_alloc_27 carl9170_alloc 1 27 NULL
94978 +sel_read_policyvers_55 sel_read_policyvers 3 55 NULL nohasharray
94979 +padzero_55 padzero 1 55 &sel_read_policyvers_55
94980 +cfg80211_disconnected_57 cfg80211_disconnected 4 57 NULL
94981 +__skb_to_sgvec_72 __skb_to_sgvec 0 72 NULL
94982 +crypto_authenc_setkey_80 crypto_authenc_setkey 3 80 NULL
94983 +snd_korg1212_copy_to_92 snd_korg1212_copy_to 6 92 NULL
94984 +load_msg_95 load_msg 2 95 NULL
94985 +device_flush_iotlb_115 device_flush_iotlb 2-3 115 NULL
94986 +init_q_132 init_q 4 132 NULL
94987 +memstick_alloc_host_142 memstick_alloc_host 1 142 NULL
94988 +hva_to_gfn_memslot_149 hva_to_gfn_memslot 0-1 149 NULL
94989 +tracing_trace_options_write_153 tracing_trace_options_write 3 153 NULL
94990 +nvme_create_queue_170 nvme_create_queue 3 170 NULL
94991 +xfs_buf_item_get_format_189 xfs_buf_item_get_format 2 189 NULL
94992 +iscsi_session_setup_196 iscsi_session_setup 4-5 196 NULL
94993 +virtblk_add_req_197 virtblk_add_req 2-3 197 NULL
94994 +proc_scsi_write_proc_267 proc_scsi_write_proc 3 267 NULL
94995 +br_port_info_size_268 br_port_info_size 0 268 NULL
94996 +generic_file_direct_write_291 generic_file_direct_write 0 291 NULL
94997 +read_file_war_stats_292 read_file_war_stats 3 292 NULL
94998 +syslog_print_307 syslog_print 2 307 NULL
94999 +platform_device_add_data_310 platform_device_add_data 3 310 NULL
95000 +dn_setsockopt_314 dn_setsockopt 5 314 NULL
95001 +next_node_allowed_318 next_node_allowed 1 318 NULL
95002 +compat_sys_ioctl_333 compat_sys_ioctl 3 333 NULL
95003 +btmrvl_txdnldready_read_413 btmrvl_txdnldready_read 3 413 NULL
95004 +lbs_rdmac_read_418 lbs_rdmac_read 3 418 NULL
95005 +snd_ca0106_ptr_read_467 snd_ca0106_ptr_read 0 467 NULL
95006 +_alloc_get_attr_desc_470 _alloc_get_attr_desc 2 470 NULL
95007 +dccp_manip_pkt_476 dccp_manip_pkt 4 476 NULL
95008 +pidlist_resize_496 pidlist_resize 2 496 NULL
95009 +read_vbt_r0_503 read_vbt_r0 1 503 NULL
95010 +rx_rx_defrag_end_read_505 rx_rx_defrag_end_read 3 505 NULL
95011 +ocfs2_validate_meta_ecc_bhs_527 ocfs2_validate_meta_ecc_bhs 0 527 NULL
95012 +zlib_deflate_workspacesize_537 zlib_deflate_workspacesize 0 537 NULL
95013 +iwl_dbgfs_wowlan_sram_read_540 iwl_dbgfs_wowlan_sram_read 3 540 NULL
95014 +dle_count_543 dle_count 0 543 NULL
95015 +devres_alloc_551 devres_alloc 2 551 NULL
95016 +snd_aw2_saa7146_get_hw_ptr_playback_558 snd_aw2_saa7146_get_hw_ptr_playback 0 558 NULL
95017 +dev_hard_header_565 dev_hard_header 0 565 NULL nohasharray
95018 +start_isoc_chain_565 start_isoc_chain 2 565 &dev_hard_header_565
95019 +compat_sys_preadv_583 compat_sys_preadv 3 583 NULL
95020 +smk_write_load_self2_591 smk_write_load_self2 3 591 NULL
95021 +ni_gpct_device_construct_610 ni_gpct_device_construct 5 610 NULL
95022 +fuse_request_alloc_nofs_617 fuse_request_alloc_nofs 1 617 NULL
95023 +compat_sys_shmat_620 compat_sys_shmat 3 620 NULL
95024 +isp1760_register_628 isp1760_register 1-2 628 NULL
95025 +clone_split_bio_633 clone_split_bio 6 633 NULL
95026 +remap_to_cache_640 remap_to_cache 3 640 NULL
95027 +drbd_bm_find_next_643 drbd_bm_find_next 2 643 NULL
95028 +unlink_queued_645 unlink_queued 3-4 645 NULL
95029 +dtim_interval_read_654 dtim_interval_read 3 654 NULL
95030 +mem_rx_free_mem_blks_read_675 mem_rx_free_mem_blks_read 3 675 NULL
95031 +rtl8169_try_rx_copy_705 rtl8169_try_rx_copy 3 705 NULL
95032 +persistent_ram_vmap_709 persistent_ram_vmap 1-2 709 NULL
95033 +ipath_resize_cq_712 ipath_resize_cq 2 712 NULL
95034 +disk_max_parts_719 disk_max_parts 0 719 NULL
95035 +sctp_setsockopt_peer_addr_params_734 sctp_setsockopt_peer_addr_params 3 734 NULL
95036 +dvb_video_write_754 dvb_video_write 3 754 NULL
95037 +if_writecmd_815 if_writecmd 2 815 NULL
95038 +aac_change_queue_depth_825 aac_change_queue_depth 2 825 NULL
95039 +read_fifo_826 read_fifo 3 826 NULL
95040 +um_idi_read_850 um_idi_read 3 850 NULL
95041 +ieee80211_if_fmt_rc_rateidx_mcs_mask_5ghz_856 ieee80211_if_fmt_rc_rateidx_mcs_mask_5ghz 3 856 NULL
95042 +o2net_send_message_vec_879 o2net_send_message_vec 4 879 NULL nohasharray
95043 +iwl_dbgfs_fh_reg_read_879 iwl_dbgfs_fh_reg_read 3 879 &o2net_send_message_vec_879
95044 +snd_pcm_action_single_905 snd_pcm_action_single 0 905 NULL
95045 +btmrvl_hsstate_read_920 btmrvl_hsstate_read 3 920 NULL
95046 +carl9170_cmd_buf_950 carl9170_cmd_buf 3 950 NULL
95047 +get_ramdisk_size_954 get_ramdisk_size 0 954 NULL
95048 +__nodes_weight_956 __nodes_weight 2-0 956 NULL
95049 +sys_msgrcv_959 sys_msgrcv 3 959 NULL
95050 +pte_prefetch_gfn_to_pfn_997 pte_prefetch_gfn_to_pfn 2 997 NULL nohasharray
95051 +hdlcdev_rx_997 hdlcdev_rx 3 997 &pte_prefetch_gfn_to_pfn_997
95052 +dm_cache_set_dirty_1016 dm_cache_set_dirty 2 1016 NULL
95053 +smk_write_cipso2_1021 smk_write_cipso2 3 1021 NULL
95054 +gigaset_initdriver_1060 gigaset_initdriver 2 1060 NULL
95055 +Read_hfc16_1070 Read_hfc16 0 1070 NULL
95056 +mce_request_packet_1073 mce_request_packet 3 1073 NULL
95057 +agp_create_memory_1075 agp_create_memory 1 1075 NULL
95058 +_scsih_adjust_queue_depth_1083 _scsih_adjust_queue_depth 2 1083 NULL
95059 +nfs_pgarray_set_1085 nfs_pgarray_set 2 1085 NULL
95060 +llcp_sock_sendmsg_1092 llcp_sock_sendmsg 4 1092 NULL
95061 +nfs4_init_nonuniform_client_string_1097 nfs4_init_nonuniform_client_string 3 1097 NULL
95062 +sys_mremap_1107 sys_mremap 5-1-2 1107 NULL
95063 +cfg80211_report_obss_beacon_1133 cfg80211_report_obss_beacon 3 1133 NULL
95064 +vmalloc_32_1135 vmalloc_32 1 1135 NULL
95065 +i2400m_rx_ctl_1157 i2400m_rx_ctl 4 1157 NULL
95066 +ipc_alloc_1192 ipc_alloc 1 1192 NULL
95067 +ib_create_send_mad_1196 ib_create_send_mad 5 1196 NULL
95068 +i2400m_rx_ctl_ack_1199 i2400m_rx_ctl_ack 3 1199 NULL
95069 +dgrp_dpa_read_1204 dgrp_dpa_read 3 1204 NULL
95070 +i2cdev_read_1206 i2cdev_read 3 1206 NULL
95071 +ipw_packet_received_skb_1230 ipw_packet_received_skb 2 1230 NULL
95072 +acpi_battery_write_alarm_1240 acpi_battery_write_alarm 3 1240 NULL
95073 +nested_get_page_1252 nested_get_page 2 1252 NULL
95074 +ocfs2_extend_file_1266 ocfs2_extend_file 3 1266 NULL
95075 +qla4xxx_change_queue_depth_1268 qla4xxx_change_queue_depth 2 1268 NULL
95076 +ioctl_private_iw_point_1273 ioctl_private_iw_point 7 1273 NULL
95077 +batadv_tt_prepare_packet_buff_1280 batadv_tt_prepare_packet_buff 4 1280 NULL
95078 +tx_frag_in_process_called_read_1290 tx_frag_in_process_called_read 3 1290 NULL
95079 +wm_adsp_buf_alloc_1317 wm_adsp_buf_alloc 2 1317 NULL
95080 +compat_put_u64_1319 compat_put_u64 1 1319 NULL
95081 +ffs_1322 ffs 0 1322 NULL
95082 +carl9170_rx_stream_1334 carl9170_rx_stream 3 1334 NULL
95083 +btrfs_submit_compressed_write_1347 btrfs_submit_compressed_write 5 1347 NULL
95084 +gen_pool_best_fit_1348 gen_pool_best_fit 2-3-4 1348 NULL
95085 +io_mapping_create_wc_1354 io_mapping_create_wc 1-2 1354 NULL
95086 +snd_pcm_lib_write1_1358 snd_pcm_lib_write1 0-3 1358 NULL
95087 +ipx_sendmsg_1362 ipx_sendmsg 4 1362 NULL
95088 +iov_num_pages_1364 iov_num_pages 0 1364 NULL
95089 +fw_stats_raw_read_1369 fw_stats_raw_read 3 1369 NULL
95090 +ocfs2_prepare_inode_for_write_1372 ocfs2_prepare_inode_for_write 3 1372 NULL
95091 +sctp_setsockopt_initmsg_1383 sctp_setsockopt_initmsg 3 1383 NULL
95092 +do_msgsnd_1387 do_msgsnd 4 1387 NULL
95093 +zone_page_state_1393 zone_page_state 0 1393 NULL
95094 +file_read_actor_1401 file_read_actor 4 1401 NULL
95095 +vb2_dc_get_user_pages_1442 vb2_dc_get_user_pages 1-3 1442 NULL
95096 +stack_max_size_read_1445 stack_max_size_read 3 1445 NULL
95097 +tx_queue_len_read_1463 tx_queue_len_read 3 1463 NULL
95098 +xprt_alloc_1475 xprt_alloc 2 1475 NULL
95099 +sta_num_ps_buf_frames_read_1488 sta_num_ps_buf_frames_read 3 1488 NULL
95100 +posix_acl_permission_1495 posix_acl_permission 0 1495 NULL
95101 +tomoyo_round2_1518 tomoyo_round2 0 1518 NULL
95102 +__vfio_dma_map_1523 __vfio_dma_map 3 1523 NULL
95103 +alloc_perm_bits_1532 alloc_perm_bits 2 1532 NULL
95104 +ieee80211_if_read_dot11MeshHWMPnetDiameterTraversalTime_1589 ieee80211_if_read_dot11MeshHWMPnetDiameterTraversalTime 3 1589 NULL
95105 +fc_frame_alloc_1596 fc_frame_alloc 2 1596 NULL
95106 +packet_buffer_init_1607 packet_buffer_init 2 1607 NULL
95107 +btmrvl_hscmd_read_1614 btmrvl_hscmd_read 3 1614 NULL
95108 +v9fs_fid_xattr_get_1618 v9fs_fid_xattr_get 0 1618 NULL
95109 +btmrvl_hsmode_read_1647 btmrvl_hsmode_read 3 1647 NULL
95110 +ikconfig_read_current_1658 ikconfig_read_current 3 1658 NULL
95111 +netdev_feature_string_1667 netdev_feature_string 0 1667 NULL
95112 +compat_x25_ioctl_1674 compat_x25_ioctl 3 1674 NULL
95113 +rmap_add_1677 rmap_add 3 1677 NULL
95114 +configfs_read_file_1683 configfs_read_file 3 1683 NULL
95115 +coda_psdev_write_1711 coda_psdev_write 3 1711 NULL
95116 +btrfs_dir_data_len_1714 btrfs_dir_data_len 0 1714 NULL
95117 +dma_memcpy_pg_to_iovec_1725 dma_memcpy_pg_to_iovec 6 1725 NULL
95118 +tx_frag_called_read_1748 tx_frag_called_read 3 1748 NULL
95119 +compat_cdrom_generic_command_1756 compat_cdrom_generic_command 4 1756 NULL
95120 +ieee80211_new_mesh_header_1761 ieee80211_new_mesh_header 0 1761 NULL
95121 +ebt_size_mwt_1768 ebt_size_mwt 0 1768 NULL
95122 +cosa_write_1774 cosa_write 3 1774 NULL
95123 +update_macheader_1775 update_macheader 7 1775 NULL
95124 +fcoe_ctlr_device_add_1793 fcoe_ctlr_device_add 3 1793 NULL
95125 +__nodelist_scnprintf_1815 __nodelist_scnprintf 0-2-4 1815 NULL
95126 +alloc_pages_exact_1892 alloc_pages_exact 1 1892 NULL
95127 +rx_defrag_called_read_1897 rx_defrag_called_read 3 1897 NULL
95128 +nfs_parse_server_name_1899 nfs_parse_server_name 2 1899 NULL
95129 +tx_tx_retry_data_read_1926 tx_tx_retry_data_read 3 1926 NULL
95130 +memblock_alloc_base_1938 memblock_alloc_base 1-2 1938 NULL
95131 +cyttsp_probe_1940 cyttsp_probe 4 1940 NULL
95132 +ieee80211_if_fmt_dot11MeshConfirmTimeout_1945 ieee80211_if_fmt_dot11MeshConfirmTimeout 3 1945 NULL
95133 +read_swap_header_1957 read_swap_header 0 1957 NULL
95134 +ivtv_v4l2_read_1964 ivtv_v4l2_read 3 1964 NULL
95135 +sel_read_avc_hash_stats_1984 sel_read_avc_hash_stats 3 1984 NULL
95136 +__alloc_bootmem_node_1992 __alloc_bootmem_node 2-3 1992 NULL
95137 +atomic_read_unchecked_1995 atomic_read_unchecked 0 1995 NULL
95138 +batadv_tt_commit_changes_2008 batadv_tt_commit_changes 4 2008 NULL
95139 +sep_prepare_input_dma_table_2009 sep_prepare_input_dma_table 2-3 2009 NULL
95140 +rx_rx_defrag_read_2010 rx_rx_defrag_read 3 2010 NULL
95141 +ocfs2_global_qinit_alloc_2018 ocfs2_global_qinit_alloc 0 2018 NULL
95142 +write_flush_pipefs_2021 write_flush_pipefs 3 2021 NULL
95143 +BcmCopySection_2035 BcmCopySection 5 2035 NULL
95144 +devm_ioremap_nocache_2036 devm_ioremap_nocache 2-3 2036 NULL
95145 +ath6kl_fwlog_mask_read_2050 ath6kl_fwlog_mask_read 3 2050 NULL
95146 +ocfs2_expand_inline_dir_2063 ocfs2_expand_inline_dir 3 2063 NULL
95147 +subbuf_read_actor_2071 subbuf_read_actor 3 2071 NULL
95148 +iwl_dbgfs_current_sleep_command_read_2081 iwl_dbgfs_current_sleep_command_read 3 2081 NULL
95149 +idetape_chrdev_read_2097 idetape_chrdev_read 3 2097 NULL
95150 +audit_expand_2098 audit_expand 2 2098 NULL
95151 +num_pages_spanned_2105 num_pages_spanned 0 2105 NULL
95152 +iwl_dbgfs_log_event_read_2107 iwl_dbgfs_log_event_read 3 2107 NULL
95153 +ecryptfs_encrypt_and_encode_filename_2109 ecryptfs_encrypt_and_encode_filename 6 2109 NULL
95154 +__find_xattr_2117 __find_xattr 6 2117 NULL nohasharray
95155 +enable_read_2117 enable_read 3 2117 &__find_xattr_2117
95156 +pcf50633_write_block_2124 pcf50633_write_block 2-3 2124 NULL
95157 +check_load_and_stores_2143 check_load_and_stores 2 2143 NULL
95158 +lp_gpio_irq_map_2149 lp_gpio_irq_map 2 2149 NULL
95159 +mlx4_init_icm_table_2151 mlx4_init_icm_table 5-4 2151 NULL
95160 +iov_iter_count_2152 iov_iter_count 0 2152 NULL
95161 +_ore_get_io_state_2166 _ore_get_io_state 3-4-5 2166 NULL
95162 +ssb_bus_ssbbus_register_2217 ssb_bus_ssbbus_register 2 2217 NULL
95163 +u32_array_read_2219 u32_array_read 3 2219 NULL
95164 +vhci_write_2224 vhci_write 3 2224 NULL
95165 +efx_tsoh_page_count_2225 efx_tsoh_page_count 0 2225 NULL
95166 +lowpan_get_mac_header_length_2231 lowpan_get_mac_header_length 0 2231 NULL
95167 +ieee80211_if_read_dot11MeshHWMPRannInterval_2249 ieee80211_if_read_dot11MeshHWMPRannInterval 3 2249 NULL
95168 +netlbl_secattr_catmap_walk_2255 netlbl_secattr_catmap_walk 0-2 2255 NULL
95169 +sel_write_avc_cache_threshold_2256 sel_write_avc_cache_threshold 3 2256 NULL
95170 +do_update_counters_2259 do_update_counters 4 2259 NULL
95171 +ath6kl_wmi_bssinfo_event_rx_2275 ath6kl_wmi_bssinfo_event_rx 3 2275 NULL
95172 +debug_debug5_read_2291 debug_debug5_read 3 2291 NULL
95173 +kvm_clear_guest_page_2308 kvm_clear_guest_page 4-2 2308 NULL
95174 +intel_sdvo_set_value_2311 intel_sdvo_set_value 4 2311 NULL
95175 +picolcd_fb_write_2318 picolcd_fb_write 3 2318 NULL
95176 +gart_map_page_2325 gart_map_page 3-4 2325 NULL
95177 +__erst_read_to_erange_2341 __erst_read_to_erange 0 2341 NULL
95178 +zr364xx_read_2354 zr364xx_read 3 2354 NULL
95179 +viafb_iga2_odev_proc_write_2363 viafb_iga2_odev_proc_write 3 2363 NULL
95180 +xfs_buf_map_from_irec_2368 xfs_buf_map_from_irec 5 2368 NULL
95181 +il_dbgfs_sensitivity_read_2370 il_dbgfs_sensitivity_read 3 2370 NULL
95182 +rtl_port_map_2385 rtl_port_map 1-2 2385 NULL
95183 +rxpipe_rx_prep_beacon_drop_read_2403 rxpipe_rx_prep_beacon_drop_read 3 2403 NULL
95184 +isdn_v110_open_2418 isdn_v110_open 3 2418 NULL
95185 +raid1_size_2419 raid1_size 0-2 2419 NULL
95186 +roccat_common2_send_2422 roccat_common2_send 4 2422 NULL
95187 +hfcpci_empty_fifo_2427 hfcpci_empty_fifo 4 2427 NULL
95188 +ioremap_nocache_2439 ioremap_nocache 1-2 2439 NULL
95189 +tty_buffer_find_2443 tty_buffer_find 2 2443 NULL
95190 +ath6kl_usb_bmi_write_2454 ath6kl_usb_bmi_write 3 2454 NULL
95191 +b43legacy_debugfs_read_2473 b43legacy_debugfs_read 3 2473 NULL
95192 +update_pmkid_2481 update_pmkid 4 2481 NULL
95193 +wiphy_new_2482 wiphy_new 2 2482 NULL
95194 +bio_alloc_bioset_2484 bio_alloc_bioset 2 2484 NULL
95195 +lookup_cache_entry_2494 lookup_cache_entry 2 2494 NULL
95196 +squashfs_read_fragment_index_table_2506 squashfs_read_fragment_index_table 4 2506 NULL
95197 +dm_write_2513 dm_write 3 2513 NULL
95198 +v9fs_cached_file_read_2514 v9fs_cached_file_read 3 2514 NULL
95199 +ext4_get_inode_loc_2516 ext4_get_inode_loc 0 2516 NULL
95200 +gspca_dev_probe_2570 gspca_dev_probe 4 2570 NULL
95201 +i915_next_seqno_write_2572 i915_next_seqno_write 3 2572 NULL
95202 +pcm_sanity_check_2574 pcm_sanity_check 0 2574 NULL
95203 +smk_write_logging_2618 smk_write_logging 3 2618 NULL
95204 +kvm_gfn_to_hva_cache_init_2636 kvm_gfn_to_hva_cache_init 3 2636 NULL
95205 +lro_gen_skb_2644 lro_gen_skb 6 2644 NULL
95206 +nfc_llcp_send_ui_frame_2702 nfc_llcp_send_ui_frame 5 2702 NULL
95207 +memcpy_fromiovecend_2707 memcpy_fromiovecend 3-4 2707 NULL
95208 +__xip_file_write_2733 __xip_file_write 4-3 2733 NULL
95209 +hid_report_raw_event_2762 hid_report_raw_event 4 2762 NULL
95210 +mon_bin_ioctl_2771 mon_bin_ioctl 3 2771 NULL
95211 +__next_cpu_2782 __next_cpu 1 2782 NULL
95212 +set_msr_hyperv_pw_2785 set_msr_hyperv_pw 3 2785 NULL
95213 +sel_read_enforce_2828 sel_read_enforce 3 2828 NULL
95214 +vb2_dc_get_userptr_2829 vb2_dc_get_userptr 2-3 2829 NULL
95215 +wait_for_avail_2847 wait_for_avail 0 2847 NULL
95216 +ufs_free_fragments_2857 ufs_free_fragments 2 2857 NULL
95217 +sfq_alloc_2861 sfq_alloc 1 2861 NULL
95218 +move_addr_to_user_2868 move_addr_to_user 2 2868 NULL
95219 +mq_map_2871 mq_map 2 2871 NULL
95220 +nla_padlen_2883 nla_padlen 1 2883 NULL
95221 +cmm_write_2896 cmm_write 3 2896 NULL
95222 +alloc_page_cgroup_2919 alloc_page_cgroup 1 2919 NULL
95223 +xfs_trans_get_buf_map_2927 xfs_trans_get_buf_map 4 2927 NULL
95224 +nes_read_indexed_2946 nes_read_indexed 0 2946 NULL
95225 +tm6000_i2c_recv_regs16_2949 tm6000_i2c_recv_regs16 5 2949 NULL
95226 +ppp_cp_event_2965 ppp_cp_event 6 2965 NULL
95227 +do_strnlen_user_2976 do_strnlen_user 0-2 2976 NULL
95228 +p9_nr_pages_2992 p9_nr_pages 0-2 2992 NULL
95229 +do_dmabuf_dirty_sou_3017 do_dmabuf_dirty_sou 7 3017 NULL
95230 +depth_write_3021 depth_write 3 3021 NULL
95231 +snd_azf3328_codec_inl_3022 snd_azf3328_codec_inl 0 3022 NULL
95232 +xfrm_dst_alloc_copy_3034 xfrm_dst_alloc_copy 3 3034 NULL
95233 +iwl_dbgfs_sleep_level_override_read_3038 iwl_dbgfs_sleep_level_override_read 3 3038 NULL
95234 +nr_free_buffer_pages_3044 nr_free_buffer_pages 0 3044 NULL
95235 +il3945_ucode_rx_stats_read_3048 il3945_ucode_rx_stats_read 3 3048 NULL
95236 +qp_alloc_ppn_set_3068 qp_alloc_ppn_set 2-4 3068 NULL
95237 +__blk_end_bidi_request_3070 __blk_end_bidi_request 3-4 3070 NULL
95238 +dac960_user_command_proc_write_3071 dac960_user_command_proc_write 3 3071 NULL
95239 +free_coherent_3082 free_coherent 4-2 3082 NULL
95240 +clone_bio_3100 clone_bio 6 3100 NULL nohasharray
95241 +ttusb2_msg_3100 ttusb2_msg 4 3100 &clone_bio_3100
95242 +rb_alloc_3102 rb_alloc 1 3102 NULL
95243 +simple_write_to_buffer_3122 simple_write_to_buffer 5-2 3122 NULL
95244 +print_time_3132 print_time 0 3132 NULL
95245 +fill_write_buffer_3142 fill_write_buffer 3 3142 NULL
95246 +CIFSSMBSetPosixACL_3154 CIFSSMBSetPosixACL 5 3154 NULL
95247 +compat_sys_migrate_pages_3157 compat_sys_migrate_pages 2 3157 NULL
95248 +uv_num_possible_blades_3177 uv_num_possible_blades 0 3177 NULL
95249 +uvc_video_stats_dump_3181 uvc_video_stats_dump 3 3181 NULL
95250 +compat_do_ip6t_set_ctl_3184 compat_do_ip6t_set_ctl 4 3184 NULL
95251 +mempool_create_node_3191 mempool_create_node 1 3191 NULL
95252 +alloc_context_3194 alloc_context 1 3194 NULL
95253 +shmem_pread_slow_3198 shmem_pread_slow 3 3198 NULL
95254 +kimage_crash_alloc_3233 kimage_crash_alloc 3 3233 NULL
95255 +do_read_log_to_user_3236 do_read_log_to_user 4 3236 NULL
95256 +ext3_xattr_find_entry_3237 ext3_xattr_find_entry 0 3237 NULL
95257 +key_key_read_3241 key_key_read 3 3241 NULL
95258 +number_3243 number 0 3243 NULL
95259 +check_vendor_extension_3254 check_vendor_extension 1 3254 NULL
95260 +__ilog2_u64_3284 __ilog2_u64 0 3284 NULL
95261 +arvo_sysfs_write_3311 arvo_sysfs_write 6 3311 NULL
95262 +dbDiscardAG_3322 dbDiscardAG 3 3322 NULL
95263 +compat_sys_setsockopt_3326 compat_sys_setsockopt 5 3326 NULL
95264 +aac_rkt_ioremap_3333 aac_rkt_ioremap 2 3333 NULL
95265 +read_from_oldmem_3337 read_from_oldmem 2 3337 NULL
95266 +tty_port_register_device_attr_3341 tty_port_register_device_attr 3 3341 NULL
95267 +il_dbgfs_interrupt_read_3351 il_dbgfs_interrupt_read 3 3351 NULL
95268 +gsm_control_rls_3353 gsm_control_rls 3 3353 NULL
95269 +scnprintf_3360 scnprintf 0-2 3360 NULL
95270 +x86_emulate_instruction_3389 x86_emulate_instruction 2 3389 NULL
95271 +mtdchar_writeoob_3393 mtdchar_writeoob 4 3393 NULL
95272 +send_stream_3397 send_stream 4 3397 NULL
95273 +isdn_readbchan_3401 isdn_readbchan 0-5 3401 NULL
95274 +msix_map_region_3411 msix_map_region 3 3411 NULL
95275 +mei_io_cb_alloc_resp_buf_3414 mei_io_cb_alloc_resp_buf 2 3414 NULL
95276 +pci_add_cap_save_buffer_3426 pci_add_cap_save_buffer 3 3426 NULL
95277 +crystalhd_create_dio_pool_3427 crystalhd_create_dio_pool 2 3427 NULL
95278 +pipe_iov_copy_to_user_3447 pipe_iov_copy_to_user 3 3447 NULL
95279 +percpu_modalloc_3448 percpu_modalloc 2-3 3448 NULL
95280 +map_single_3449 map_single 0-2 3449 NULL
95281 +jffs2_acl_setxattr_3464 jffs2_acl_setxattr 4 3464 NULL nohasharray
95282 +snd_pcm_lib_readv_transfer_3464 snd_pcm_lib_readv_transfer 4-2-5 3464 &jffs2_acl_setxattr_3464
95283 +alloc_skb_fclone_3467 alloc_skb_fclone 1 3467 NULL
95284 +security_context_to_sid_default_3492 security_context_to_sid_default 2 3492 NULL
95285 +xfrm_migrate_msgsize_3496 xfrm_migrate_msgsize 1 3496 NULL
95286 +kvm_handle_bad_page_3503 kvm_handle_bad_page 2 3503 NULL
95287 +mem_tx_free_mem_blks_read_3521 mem_tx_free_mem_blks_read 3 3521 NULL nohasharray
95288 +ieee80211_wx_set_gen_ie_rsl_3521 ieee80211_wx_set_gen_ie_rsl 3 3521 &mem_tx_free_mem_blks_read_3521
95289 +btrfs_dir_name_len_3549 btrfs_dir_name_len 0 3549 NULL
95290 +b43legacy_read16_3561 b43legacy_read16 0 3561 NULL
95291 +alloc_smp_resp_3566 alloc_smp_resp 1 3566 NULL
95292 +evtchn_read_3569 evtchn_read 3 3569 NULL
95293 +vc_resize_3585 vc_resize 2-3 3585 NULL
95294 +compat_sys_semtimedop_3606 compat_sys_semtimedop 3 3606 NULL
95295 +sctp_getsockopt_events_3607 sctp_getsockopt_events 2 3607 NULL
95296 +edac_mc_alloc_3611 edac_mc_alloc 4 3611 NULL
95297 +tx_tx_starts_read_3617 tx_tx_starts_read 3 3617 NULL
95298 +aligned_kmalloc_3628 aligned_kmalloc 1 3628 NULL
95299 +cm_copy_private_data_3649 cm_copy_private_data 2 3649 NULL
95300 +ath6kl_disconnect_timeout_read_3650 ath6kl_disconnect_timeout_read 3 3650 NULL
95301 +i915_compat_ioctl_3656 i915_compat_ioctl 2 3656 NULL
95302 +create_irq_3703 create_irq 0 3703 NULL nohasharray
95303 +btmrvl_psmode_write_3703 btmrvl_psmode_write 3 3703 &create_irq_3703 nohasharray
95304 +snd_m3_assp_read_3703 snd_m3_assp_read 0 3703 &btmrvl_psmode_write_3703
95305 +videobuf_pages_to_sg_3708 videobuf_pages_to_sg 2 3708 NULL
95306 +ci_ll_write_3740 ci_ll_write 4 3740 NULL nohasharray
95307 +ath6kl_mgmt_tx_3740 ath6kl_mgmt_tx 7 3740 &ci_ll_write_3740
95308 +sctp_setsockopt_auth_key_3793 sctp_setsockopt_auth_key 3 3793 NULL
95309 +ncp_file_write_3813 ncp_file_write 3 3813 NULL
95310 +read_file_tx_chainmask_3829 read_file_tx_chainmask 3 3829 NULL
95311 +stringify_nodemap_3842 stringify_nodemap 2 3842 NULL
95312 +ubi_eba_read_leb_3847 ubi_eba_read_leb 0 3847 NULL
95313 +create_one_cdev_3852 create_one_cdev 2 3852 NULL
95314 +smk_read_onlycap_3855 smk_read_onlycap 3 3855 NULL
95315 +get_fd_set_3866 get_fd_set 1 3866 NULL
95316 +garp_attr_create_3883 garp_attr_create 3 3883 NULL
95317 +uea_send_modem_cmd_3888 uea_send_modem_cmd 3 3888 NULL
95318 +efivarfs_file_read_3893 efivarfs_file_read 3 3893 NULL
95319 +nvram_write_3894 nvram_write 3 3894 NULL
95320 +pipeline_pre_proc_swi_read_3898 pipeline_pre_proc_swi_read 3 3898 NULL
95321 +comedi_buf_read_n_available_3899 comedi_buf_read_n_available 0 3899 NULL
95322 +vcs_write_3910 vcs_write 3 3910 NULL
95323 +atalk_compat_ioctl_3991 atalk_compat_ioctl 3 3991 NULL
95324 +do_add_counters_3992 do_add_counters 3 3992 NULL
95325 +userspace_status_4004 userspace_status 4 4004 NULL
95326 +mei_write_4005 mei_write 3 4005 NULL nohasharray
95327 +xfs_check_block_4005 xfs_check_block 4 4005 &mei_write_4005
95328 +snd_hdsp_capture_copy_4011 snd_hdsp_capture_copy 5 4011 NULL
95329 +mm_populate_4016 mm_populate 1 4016 NULL
95330 +blk_end_request_4024 blk_end_request 3 4024 NULL
95331 +ext4_xattr_find_entry_4025 ext4_xattr_find_entry 0 4025 NULL
95332 +usbnet_write_cmd_async_4035 usbnet_write_cmd_async 7 4035 NULL
95333 +read_file_queues_4078 read_file_queues 3 4078 NULL
95334 +fbcon_do_set_font_4079 fbcon_do_set_font 2-3 4079 NULL
95335 +da9052_free_irq_4090 da9052_free_irq 2 4090 NULL
95336 +ntb_netdev_change_mtu_4147 ntb_netdev_change_mtu 2 4147 NULL
95337 +tm6000_read_4151 tm6000_read 3 4151 NULL
95338 +mpt_raid_phys_disk_get_num_paths_4155 mpt_raid_phys_disk_get_num_paths 0 4155 NULL
95339 +msg_bits_4158 msg_bits 0-3-4 4158 NULL
95340 +get_alua_req_4166 get_alua_req 3 4166 NULL
95341 +blk_dropped_read_4168 blk_dropped_read 3 4168 NULL
95342 +read_file_bool_4180 read_file_bool 3 4180 NULL
95343 +f1x_determine_channel_4202 f1x_determine_channel 2 4202 NULL
95344 +_osd_req_list_objects_4204 _osd_req_list_objects 6 4204 NULL
95345 +__snd_gf1_read_addr_4210 __snd_gf1_read_addr 0 4210 NULL
95346 +goldfish_audio_write_4284 goldfish_audio_write 3 4284 NULL
95347 +paging32_page_fault_4288 paging32_page_fault 2 4288 NULL
95348 +xt_compat_add_offset_4289 xt_compat_add_offset 0 4289 NULL
95349 +__usbnet_read_cmd_4299 __usbnet_read_cmd 7 4299 NULL
95350 +dvb_ringbuffer_pkt_read_user_4303 dvb_ringbuffer_pkt_read_user 3-2-5 4303 NULL
95351 +nouveau_fifo_create__4327 nouveau_fifo_create_ 5-6 4327 NULL
95352 +snd_rawmidi_kernel_read_4328 snd_rawmidi_kernel_read 3 4328 NULL
95353 +__copy_from_user_inatomic_4365 __copy_from_user_inatomic 3 4365 NULL
95354 +sys_setdomainname_4373 sys_setdomainname 2 4373 NULL
95355 +irda_sendmsg_4388 irda_sendmsg 4 4388 NULL
95356 +access_process_vm_4412 access_process_vm 0-2-4 4412 NULL nohasharray
95357 +cxacru_cm_get_array_4412 cxacru_cm_get_array 4 4412 &access_process_vm_4412
95358 +libfc_vport_create_4415 libfc_vport_create 2 4415 NULL
95359 +do_pages_stat_4437 do_pages_stat 2 4437 NULL
95360 +memparse_4444 memparse 0 4444 NULL
95361 +at76_set_card_command_4471 at76_set_card_command 4 4471 NULL
95362 +snd_seq_expand_var_event_4481 snd_seq_expand_var_event 0-5 4481 NULL
95363 +sys_semtimedop_4486 sys_semtimedop 3 4486 NULL
95364 +vmbus_establish_gpadl_4495 vmbus_establish_gpadl 3 4495 NULL
95365 +set_link_security_4502 set_link_security 4 4502 NULL
95366 +dm_cache_remove_mapping_4513 dm_cache_remove_mapping 2 4513 NULL
95367 +__gfn_to_pfn_memslot_4530 __gfn_to_pfn_memslot 2 4530 NULL
95368 +sys_llistxattr_4532 sys_llistxattr 3 4532 NULL
95369 +da9052_group_write_4534 da9052_group_write 2-3 4534 NULL
95370 +tty_register_device_4544 tty_register_device 2 4544 NULL
95371 +videobuf_vmalloc_to_sg_4548 videobuf_vmalloc_to_sg 2 4548 NULL
95372 +btrfs_file_extent_inline_item_len_4575 btrfs_file_extent_inline_item_len 0 4575 NULL
95373 +xfs_buf_get_maps_4581 xfs_buf_get_maps 2 4581 NULL
95374 +bch_alloc_4593 bch_alloc 1 4593 NULL
95375 +__wb_force_remove_mapping_4622 __wb_force_remove_mapping 2 4622 NULL
95376 +iwl_dbgfs_tx_queue_read_4635 iwl_dbgfs_tx_queue_read 3 4635 NULL
95377 +skb_add_data_nocache_4682 skb_add_data_nocache 4 4682 NULL
95378 +cx18_read_pos_4683 cx18_read_pos 3 4683 NULL
95379 +short_retry_limit_read_4687 short_retry_limit_read 3 4687 NULL
95380 +kone_receive_4690 kone_receive 4 4690 NULL
95381 +round_pipe_size_4701 round_pipe_size 0 4701 NULL
95382 +cxgbi_alloc_big_mem_4707 cxgbi_alloc_big_mem 1 4707 NULL
95383 +btmrvl_gpiogap_read_4718 btmrvl_gpiogap_read 3 4718 NULL
95384 +ati_create_gatt_pages_4722 ati_create_gatt_pages 1 4722 NULL nohasharray
95385 +show_header_4722 show_header 3 4722 &ati_create_gatt_pages_4722
95386 +__find_free_cblock_4741 __find_free_cblock 2 4741 NULL
95387 +memblock_find_in_range_4759 memblock_find_in_range 3-4 4759 NULL
95388 +pwr_rcvd_bcns_cnt_read_4774 pwr_rcvd_bcns_cnt_read 3 4774 NULL
95389 +create_subvol_4791 create_subvol 4 4791 NULL
95390 +ncp__vol2io_4804 ncp__vol2io 5 4804 NULL
95391 +repair_io_failure_4815 repair_io_failure 4 4815 NULL
95392 +gigaset_if_receive_4861 gigaset_if_receive 3 4861 NULL
95393 +key_tx_spec_read_4862 key_tx_spec_read 3 4862 NULL
95394 +ocfs2_defrag_extent_4873 ocfs2_defrag_extent 3 4873 NULL
95395 +hid_register_field_4874 hid_register_field 2-3 4874 NULL
95396 +vga_arb_read_4886 vga_arb_read 3 4886 NULL
95397 +sys_ipc_4889 sys_ipc 3 4889 NULL
95398 +sys_process_vm_writev_4928 sys_process_vm_writev 3-5 4928 NULL
95399 +ntfs_rl_insert_4931 ntfs_rl_insert 2-4 4931 NULL
95400 +ieee80211_if_fmt_ave_beacon_4941 ieee80211_if_fmt_ave_beacon 3 4941 NULL
95401 +devm_kzalloc_4966 devm_kzalloc 2 4966 NULL
95402 +compat_rawv6_setsockopt_4967 compat_rawv6_setsockopt 5 4967 NULL
95403 +skb_network_header_len_4971 skb_network_header_len 0 4971 NULL
95404 +ieee80211_if_fmt_dot11MeshHWMPconfirmationInterval_4976 ieee80211_if_fmt_dot11MeshHWMPconfirmationInterval 3 4976 NULL
95405 +vmw_surface_define_size_4993 vmw_surface_define_size 0 4993 NULL
95406 +qla82xx_pci_mem_write_direct_5008 qla82xx_pci_mem_write_direct 2 5008 NULL
95407 +do_mincore_5018 do_mincore 0-1 5018 NULL
95408 +mtd_device_parse_register_5024 mtd_device_parse_register 5 5024 NULL
95409 +ocfs2_check_range_for_holes_5066 ocfs2_check_range_for_holes 2-3 5066 NULL
95410 +snd_mixart_BA1_read_5082 snd_mixart_BA1_read 5 5082 NULL
95411 +snd_emu10k1_ptr20_read_5087 snd_emu10k1_ptr20_read 0 5087 NULL
95412 +get_random_bytes_5091 get_random_bytes 2 5091 NULL nohasharray
95413 +kfifo_copy_from_user_5091 kfifo_copy_from_user 3 5091 &get_random_bytes_5091 nohasharray
95414 +blk_rq_sectors_5091 blk_rq_sectors 0 5091 &kfifo_copy_from_user_5091
95415 +mpol_to_str_5093 mpol_to_str 2 5093 NULL
95416 +sound_write_5102 sound_write 3 5102 NULL
95417 +clear_dirty_5105 clear_dirty 3 5105 NULL
95418 +ufs_add_fragments_5144 ufs_add_fragments 2 5144 NULL
95419 +compat_ptr_5159 compat_ptr 0-1 5159 NULL
95420 +__uwb_addr_print_5161 __uwb_addr_print 2 5161 NULL
95421 +iwl_dbgfs_status_read_5171 iwl_dbgfs_status_read 3 5171 NULL
95422 +acpi_pcc_get_sqty_5176 acpi_pcc_get_sqty 0 5176 NULL
95423 +sfi_map_memory_5183 sfi_map_memory 1-2 5183 NULL
95424 +skb_network_header_5203 skb_network_header 0 5203 NULL
95425 +pipe_set_size_5204 pipe_set_size 2 5204 NULL
95426 +ppp_cp_parse_cr_5214 ppp_cp_parse_cr 4 5214 NULL
95427 +ath6kl_debug_roam_tbl_event_5224 ath6kl_debug_roam_tbl_event 3 5224 NULL
95428 +ssb_ioremap_5228 ssb_ioremap 2 5228 NULL
95429 +isdn_ppp_skb_push_5236 isdn_ppp_skb_push 2 5236 NULL
95430 +do_atmif_sioc_5247 do_atmif_sioc 3 5247 NULL
95431 +gfn_to_hva_memslot_5265 gfn_to_hva_memslot 2 5265 NULL
95432 +alloc_cache_blocks_with_hash_5285 alloc_cache_blocks_with_hash 2 5285 NULL
95433 +__gfn_to_hva_memslot_5304 __gfn_to_hva_memslot 0-2 5304 NULL
95434 +sbc_get_write_same_sectors_5317 sbc_get_write_same_sectors 0 5317 NULL
95435 +pwr_elp_enter_read_5324 pwr_elp_enter_read 3 5324 NULL
95436 +allocate_cnodes_5329 allocate_cnodes 1 5329 NULL
95437 +ps_pspoll_utilization_read_5361 ps_pspoll_utilization_read 3 5361 NULL
95438 +cciss_allocate_sg_chain_blocks_5368 cciss_allocate_sg_chain_blocks 3-2 5368 NULL
95439 +kvm_pin_pages_5369 kvm_pin_pages 2 5369 NULL
95440 +bitmap_fold_5396 bitmap_fold 4 5396 NULL
95441 +nilfs_palloc_entries_per_group_5418 nilfs_palloc_entries_per_group 0 5418 NULL
95442 +sfi_map_table_5462 sfi_map_table 1 5462 NULL
95443 +xfs_efd_init_5463 xfs_efd_init 3 5463 NULL
95444 +xfs_efi_init_5476 xfs_efi_init 2 5476 NULL
95445 +ubi_leb_write_5478 ubi_leb_write 4-5 5478 NULL
95446 +cifs_security_flags_proc_write_5484 cifs_security_flags_proc_write 3 5484 NULL
95447 +tty_write_5494 tty_write 3 5494 NULL
95448 +tomoyo_update_domain_5498 tomoyo_update_domain 2 5498 NULL nohasharray
95449 +ieee80211_if_fmt_last_beacon_5498 ieee80211_if_fmt_last_beacon 3 5498 &tomoyo_update_domain_5498
95450 +__max_nr_grant_frames_5505 __max_nr_grant_frames 0 5505 NULL
95451 +spidev_message_5518 spidev_message 3 5518 NULL
95452 +ieee80211_if_fmt_auto_open_plinks_5534 ieee80211_if_fmt_auto_open_plinks 3 5534 NULL
95453 +brcmu_pkt_buf_get_skb_5556 brcmu_pkt_buf_get_skb 1 5556 NULL
95454 +le_readq_5557 le_readq 0 5557 NULL
95455 +inw_5558 inw 0 5558 NULL
95456 +fir16_create_5574 fir16_create 3 5574 NULL
95457 +bioset_create_5580 bioset_create 1 5580 NULL
95458 +oz_ep_alloc_5587 oz_ep_alloc 2 5587 NULL
95459 +usb_dump_device_descriptor_5599 usb_dump_device_descriptor 0 5599 NULL
95460 +ldm_frag_add_5611 ldm_frag_add 2 5611 NULL
95461 +compat_copy_entries_5617 compat_copy_entries 0 5617 NULL
95462 +ext4_xattr_get_5661 ext4_xattr_get 0 5661 NULL
95463 +posix_clock_register_5662 posix_clock_register 2 5662 NULL
95464 +mthca_map_reg_5664 mthca_map_reg 2-3 5664 NULL
95465 +__videobuf_alloc_vb_5665 __videobuf_alloc_vb 1 5665 NULL
95466 +wb_clear_dirty_5684 wb_clear_dirty 2 5684 NULL
95467 +get_arg_5694 get_arg 3 5694 NULL
95468 +vmw_kms_readback_5727 vmw_kms_readback 6 5727 NULL
95469 +reexecute_instruction_5733 reexecute_instruction 2 5733 NULL
95470 +rts51x_transfer_data_partial_5735 rts51x_transfer_data_partial 6 5735 NULL
95471 +ubi_cdev_compat_ioctl_5746 ubi_cdev_compat_ioctl 3 5746 NULL
95472 +sctp_setsockopt_autoclose_5775 sctp_setsockopt_autoclose 3 5775 NULL
95473 +compat_sys_writev_5784 compat_sys_writev 3 5784 NULL
95474 +__vxge_hw_blockpool_malloc_5786 __vxge_hw_blockpool_malloc 2 5786 NULL
95475 +skb_copy_datagram_iovec_5806 skb_copy_datagram_iovec 2-4 5806 NULL
95476 +nv50_disp_pioc_create__5812 nv50_disp_pioc_create_ 5 5812 NULL
95477 +ceph_x_encrypt_buflen_5829 ceph_x_encrypt_buflen 0-1 5829 NULL
95478 +autofs4_root_compat_ioctl_5838 autofs4_root_compat_ioctl 3 5838 NULL
95479 +ceph_msg_new_5846 ceph_msg_new 2 5846 NULL
95480 +ixgb_check_copybreak_5847 ixgb_check_copybreak 3 5847 NULL
95481 +setup_req_5848 setup_req 3 5848 NULL
95482 +rx_filter_max_arp_queue_dep_read_5851 rx_filter_max_arp_queue_dep_read 3 5851 NULL
95483 +compat_sys_move_pages_5861 compat_sys_move_pages 2 5861 NULL nohasharray
95484 +uinput_compat_ioctl_5861 uinput_compat_ioctl 3 5861 &compat_sys_move_pages_5861
95485 +paging64_walk_addr_5887 paging64_walk_addr 3 5887 NULL
95486 +port_show_regs_5904 port_show_regs 3 5904 NULL
95487 +uhci_debug_read_5911 uhci_debug_read 3 5911 NULL
95488 +qla82xx_pci_mem_read_2M_5912 qla82xx_pci_mem_read_2M 2 5912 NULL
95489 +ttm_bo_kmap_ttm_5922 ttm_bo_kmap_ttm 3 5922 NULL
95490 +lbs_highsnr_read_5931 lbs_highsnr_read 3 5931 NULL
95491 +ps_poll_ps_poll_timeouts_read_5934 ps_poll_ps_poll_timeouts_read 3 5934 NULL
95492 +edac_device_alloc_ctl_info_5941 edac_device_alloc_ctl_info 1 5941 NULL
95493 +tipc_subseq_alloc_5957 tipc_subseq_alloc 1 5957 NULL
95494 +__apu_get_register_5967 __apu_get_register 0 5967 NULL
95495 +ieee80211_if_fmt_rc_rateidx_mask_5ghz_5971 ieee80211_if_fmt_rc_rateidx_mask_5ghz 3 5971 NULL
95496 +native_pte_val_5978 native_pte_val 0 5978 NULL
95497 +ntfs_rl_append_6037 ntfs_rl_append 2-4 6037 NULL
95498 +da9052_request_irq_6058 da9052_request_irq 2 6058 NULL
95499 +sctp_setsockopt_connectx_6073 sctp_setsockopt_connectx 3 6073 NULL
95500 +rts51x_ms_rw_multi_sector_6076 rts51x_ms_rw_multi_sector 3-4 6076 NULL
95501 +ipmi_addr_length_6110 ipmi_addr_length 0 6110 NULL
95502 +dfs_global_file_write_6112 dfs_global_file_write 3 6112 NULL
95503 +matrix_keypad_build_keymap_6129 matrix_keypad_build_keymap 3 6129 NULL
95504 +nouveau_parent_create__6131 nouveau_parent_create_ 7 6131 NULL
95505 +ivtv_copy_buf_to_user_6159 ivtv_copy_buf_to_user 4 6159 NULL
95506 +vdma_mem_alloc_6171 vdma_mem_alloc 1 6171 NULL
95507 +wl1251_cmd_template_set_6172 wl1251_cmd_template_set 4 6172 NULL
95508 +paging64_walk_addr_generic_6180 paging64_walk_addr_generic 4 6180 NULL
95509 +qp_host_get_user_memory_6189 qp_host_get_user_memory 1-2 6189 NULL
95510 +mxt_show_instance_6207 mxt_show_instance 2-0 6207 NULL
95511 +v4l2_ctrl_new_std_menu_6221 v4l2_ctrl_new_std_menu 4 6221 NULL
95512 +mqueue_read_file_6228 mqueue_read_file 3 6228 NULL
95513 +f_hidg_read_6238 f_hidg_read 3 6238 NULL
95514 +fbcon_prepare_logo_6246 fbcon_prepare_logo 5 6246 NULL
95515 +pcpu_next_pop_6277 pcpu_next_pop 4 6277 NULL
95516 +tx_tx_start_null_frame_read_6281 tx_tx_start_null_frame_read 3 6281 NULL
95517 +snd_hda_override_conn_list_6282 snd_hda_override_conn_list 3 6282 NULL nohasharray
95518 +xenbus_file_write_6282 xenbus_file_write 3 6282 &snd_hda_override_conn_list_6282
95519 +posix_acl_fix_xattr_to_user_6283 posix_acl_fix_xattr_to_user 2 6283 NULL
95520 +paging64_gva_to_gpa_nested_6287 paging64_gva_to_gpa_nested 2 6287 NULL
95521 +nf_nat_ipv6_manip_pkt_6289 nf_nat_ipv6_manip_pkt 2 6289 NULL
95522 +nf_nat_sack_adjust_6297 nf_nat_sack_adjust 2 6297 NULL
95523 +mid_get_vbt_data_r10_6308 mid_get_vbt_data_r10 2 6308 NULL
95524 +ucs2_strnlen_6342 ucs2_strnlen 0 6342 NULL
95525 +_proc_do_string_6376 _proc_do_string 2 6376 NULL
95526 +osd_req_read_sg_kern_6378 osd_req_read_sg_kern 5 6378 NULL
95527 +posix_acl_fix_xattr_userns_6420 posix_acl_fix_xattr_userns 4 6420 NULL
95528 +ipr_change_queue_depth_6431 ipr_change_queue_depth 2 6431 NULL
95529 +__alloc_bootmem_node_nopanic_6432 __alloc_bootmem_node_nopanic 2-3 6432 NULL
95530 +paging32_gva_to_gpa_nested_6442 paging32_gva_to_gpa_nested 2 6442 NULL
95531 +mlx4_ib_reg_user_mr_6471 mlx4_ib_reg_user_mr 2-3 6471 NULL nohasharray
95532 +ext4_compat_ioctl_6471 ext4_compat_ioctl 3 6471 &mlx4_ib_reg_user_mr_6471
95533 +ieee80211_if_fmt_dot11MeshMaxRetries_6476 ieee80211_if_fmt_dot11MeshMaxRetries 3 6476 NULL
95534 +qp_memcpy_from_queue_6479 qp_memcpy_from_queue 4-5 6479 NULL
95535 +cipso_v4_map_lvl_hton_6490 cipso_v4_map_lvl_hton 0 6490 NULL
95536 +dbg_intr_buf_6501 dbg_intr_buf 2 6501 NULL
95537 +mei_read_6507 mei_read 3 6507 NULL
95538 +read_file_disable_ani_6536 read_file_disable_ani 3 6536 NULL
95539 +rndis_set_oid_6547 rndis_set_oid 4 6547 NULL
95540 +wdm_read_6549 wdm_read 3 6549 NULL
95541 +fb_alloc_cmap_6554 fb_alloc_cmap 2 6554 NULL
95542 +snmp_mib_init_6604 snmp_mib_init 2-3 6604 NULL
95543 +ecryptfs_filldir_6622 ecryptfs_filldir 3 6622 NULL
95544 +virtscsi_alloc_tgt_6643 virtscsi_alloc_tgt 2 6643 NULL
95545 +aac_srcv_ioremap_6659 aac_srcv_ioremap 2 6659 NULL
95546 +process_rcvd_data_6679 process_rcvd_data 3 6679 NULL
95547 +ql_process_mac_rx_skb_6689 ql_process_mac_rx_skb 4 6689 NULL
95548 +btrfs_lookup_csums_range_6696 btrfs_lookup_csums_range 2 6696 NULL
95549 +ps_pspoll_max_apturn_read_6699 ps_pspoll_max_apturn_read 3 6699 NULL
95550 +bnad_debugfs_write_regrd_6706 bnad_debugfs_write_regrd 3 6706 NULL
95551 +mpeg_read_6708 mpeg_read 3 6708 NULL
95552 +set_orig_insn_6712 set_orig_insn 3 6712 NULL
95553 +video_proc_write_6724 video_proc_write 3 6724 NULL
95554 +posix_acl_xattr_count_6725 posix_acl_xattr_count 0-1 6725 NULL
95555 +rds_rdma_pages_6735 rds_rdma_pages 0 6735 NULL
95556 +sfi_check_table_6772 sfi_check_table 1 6772 NULL
95557 +iwl_dbgfs_channels_read_6784 iwl_dbgfs_channels_read 3 6784 NULL
95558 +ieee80211_if_read_6785 ieee80211_if_read 3 6785 NULL
95559 +hdlcdrv_register_6792 hdlcdrv_register 2 6792 NULL
95560 +tx_tx_done_data_read_6799 tx_tx_done_data_read 3 6799 NULL
95561 +make_8259A_irq_6828 make_8259A_irq 1 6828 NULL
95562 +calc_pages_for_6838 calc_pages_for 0-1-2 6838 NULL
95563 +mon_bin_read_6841 mon_bin_read 3 6841 NULL
95564 +snd_cs4281_BA0_read_6847 snd_cs4281_BA0_read 5 6847 NULL
95565 +ieee80211_if_fmt_path_refresh_time_6888 ieee80211_if_fmt_path_refresh_time 3 6888 NULL nohasharray
95566 +raw_seticmpfilter_6888 raw_seticmpfilter 3 6888 &ieee80211_if_fmt_path_refresh_time_6888
95567 +dlmfs_file_write_6892 dlmfs_file_write 3 6892 NULL
95568 +spi_show_regs_6911 spi_show_regs 3 6911 NULL nohasharray
95569 +proc_sessionid_read_6911 proc_sessionid_read 3 6911 &spi_show_regs_6911 nohasharray
95570 +acm_alloc_minor_6911 acm_alloc_minor 0 6911 &proc_sessionid_read_6911
95571 +__kfifo_dma_in_finish_r_6913 __kfifo_dma_in_finish_r 2-3 6913 NULL
95572 +do_msgrcv_6921 do_msgrcv 3 6921 NULL
95573 +cache_do_downcall_6926 cache_do_downcall 3 6926 NULL
95574 +qsfp_cks_6945 qsfp_cks 0-2 6945 NULL
95575 +pch_uart_hal_read_6961 pch_uart_hal_read 0 6961 NULL
95576 +videobuf_dma_init_kernel_6963 videobuf_dma_init_kernel 3 6963 NULL
95577 +rsa_extract_mpi_6973 rsa_extract_mpi 5 6973 NULL
95578 +crypto_authenc_esn_setkey_6985 crypto_authenc_esn_setkey 3 6985 NULL
95579 +request_key_async_6990 request_key_async 4 6990 NULL
95580 +r871x_set_wpa_ie_7000 r871x_set_wpa_ie 3 7000 NULL
95581 +cipso_v4_gentag_enum_7006 cipso_v4_gentag_enum 0 7006 NULL
95582 +tracing_cpumask_read_7010 tracing_cpumask_read 3 7010 NULL
95583 +wimax_msg_7030 wimax_msg 4 7030 NULL
95584 +ipath_get_base_info_7043 ipath_get_base_info 3 7043 NULL
95585 +snd_pcm_oss_bytes_7051 snd_pcm_oss_bytes 2 7051 NULL
95586 +event_enable_read_7074 event_enable_read 3 7074 NULL
95587 +beacon_interval_read_7091 beacon_interval_read 3 7091 NULL
95588 +lp_compat_ioctl_7098 lp_compat_ioctl 3 7098 NULL
95589 +pipeline_enc_rx_stat_fifo_int_read_7107 pipeline_enc_rx_stat_fifo_int_read 3 7107 NULL
95590 +check_header_7108 check_header 0 7108 NULL
95591 +qlcnic_enable_msix_7144 qlcnic_enable_msix 2 7144 NULL
95592 +__alloc_objio_seg_7203 __alloc_objio_seg 1 7203 NULL
95593 +sys32_ipc_7238 sys32_ipc 3-5-6 7238 NULL
95594 +get_param_h_7247 get_param_h 0 7247 NULL
95595 +af_alg_make_sg_7254 af_alg_make_sg 3 7254 NULL
95596 +vm_mmap_pgoff_7259 vm_mmap_pgoff 0 7259 NULL
95597 +dma_ops_alloc_addresses_7272 dma_ops_alloc_addresses 3-4-5 7272 NULL
95598 +rx_rate_rx_frames_per_rates_read_7282 rx_rate_rx_frames_per_rates_read 3 7282 NULL
95599 +wb_remove_mapping_7307 wb_remove_mapping 2 7307 NULL
95600 +mgmt_control_7349 mgmt_control 3 7349 NULL
95601 +ext3_free_blocks_7362 ext3_free_blocks 3-4 7362 NULL
95602 +ieee80211_if_read_dot11MeshHWMPactivePathTimeout_7368 ieee80211_if_read_dot11MeshHWMPactivePathTimeout 3 7368 NULL
95603 +hweight_long_7388 hweight_long 0-1 7388 NULL
95604 +vhost_scsi_compat_ioctl_7393 vhost_scsi_compat_ioctl 3 7393 NULL
95605 +sl_change_mtu_7396 sl_change_mtu 2 7396 NULL
95606 +readb_7401 readb 0 7401 NULL
95607 +drm_property_create_blob_7414 drm_property_create_blob 2 7414 NULL
95608 +ip_options_get_alloc_7448 ip_options_get_alloc 1 7448 NULL
95609 +numa_emulation_7466 numa_emulation 2 7466 NULL
95610 +__mutex_lock_common_7469 __mutex_lock_common 0 7469 NULL
95611 +garp_request_join_7471 garp_request_join 4 7471 NULL
95612 +compat_sys_msgrcv_7482 compat_sys_msgrcv 2 7482 NULL
95613 +snd_pcm_lib_read1_7491 snd_pcm_lib_read1 0-3 7491 NULL
95614 +sdhci_alloc_host_7509 sdhci_alloc_host 2 7509 NULL nohasharray
95615 +ahash_instance_headroom_7509 ahash_instance_headroom 0 7509 &sdhci_alloc_host_7509
95616 +array_zalloc_7519 array_zalloc 1-2 7519 NULL
95617 +goal_in_my_reservation_7553 goal_in_my_reservation 3 7553 NULL
95618 +smk_read_mapped_7562 smk_read_mapped 3 7562 NULL
95619 +ext3_try_to_allocate_7590 ext3_try_to_allocate 5-3 7590 NULL
95620 +groups_alloc_7614 groups_alloc 1 7614 NULL
95621 +sg_virt_7616 sg_virt 0 7616 NULL
95622 +skb_copy_expand_7685 skb_copy_expand 2-3 7685 NULL nohasharray
95623 +acpi_ex_allocate_name_string_7685 acpi_ex_allocate_name_string 2-1 7685 &skb_copy_expand_7685
95624 +acpi_ns_get_pathname_length_7699 acpi_ns_get_pathname_length 0 7699 NULL
95625 +dev_write_7708 dev_write 3 7708 NULL
95626 +brcmf_sdcard_send_buf_7713 brcmf_sdcard_send_buf 6 7713 NULL
95627 +set_bypass_pwup_pfs_7742 set_bypass_pwup_pfs 3 7742 NULL
95628 +vxge_device_register_7752 vxge_device_register 4 7752 NULL
95629 +osdv2_attr_list_elem_size_7763 osdv2_attr_list_elem_size 0-1 7763 NULL
95630 +ubi_io_read_vid_hdr_7766 ubi_io_read_vid_hdr 0 7766 NULL
95631 +ioread32be_7773 ioread32be 0 7773 NULL
95632 +alloc_candev_7776 alloc_candev 1-2 7776 NULL
95633 +dfs_global_file_read_7787 dfs_global_file_read 3 7787 NULL
95634 +bnx2_nvram_write_7790 bnx2_nvram_write 4-2 7790 NULL
95635 +diva_os_copy_from_user_7792 diva_os_copy_from_user 4 7792 NULL
95636 +ubifs_leb_read_7828 ubifs_leb_read 0 7828 NULL
95637 +dvb_dmxdev_read_sec_7892 dvb_dmxdev_read_sec 4 7892 NULL
95638 +xfs_trans_get_efi_7898 xfs_trans_get_efi 2 7898 NULL
95639 +gfs2_tune_get_i_7903 gfs2_tune_get_i 0 7903 NULL
95640 +ext3_group_extend_7911 ext3_group_extend 3 7911 NULL
95641 +libfc_host_alloc_7917 libfc_host_alloc 2 7917 NULL
95642 +f_hidg_write_7932 f_hidg_write 3 7932 NULL
95643 +io_apic_setup_irq_pin_once_7934 io_apic_setup_irq_pin_once 1 7934 NULL
95644 +integrity_digsig_verify_7956 integrity_digsig_verify 3 7956 NULL
95645 +smk_write_load_self_7958 smk_write_load_self 3 7958 NULL
95646 +sys_mbind_7990 sys_mbind 5 7990 NULL
95647 +tt3650_ci_msg_locked_8013 tt3650_ci_msg_locked 4 8013 NULL
95648 +vcs_read_8017 vcs_read 3 8017 NULL
95649 +normalize_up_8037 normalize_up 0-1-2 8037 NULL
95650 +vhost_add_used_and_signal_n_8038 vhost_add_used_and_signal_n 4 8038 NULL
95651 +ms_read_multiple_pages_8052 ms_read_multiple_pages 5-4 8052 NULL
95652 +dgrp_mon_read_8065 dgrp_mon_read 3 8065 NULL
95653 +leb_read_lock_8070 leb_read_lock 0 8070 NULL
95654 +alloc_targets_8074 alloc_targets 2 8074 NULL nohasharray
95655 +qla4xxx_post_ping_evt_work_8074 qla4xxx_post_ping_evt_work 4 8074 &alloc_targets_8074
95656 +venus_lookup_8121 venus_lookup 4 8121 NULL
95657 +ieee80211_if_fmt_num_buffered_multicast_8127 ieee80211_if_fmt_num_buffered_multicast 3 8127 NULL
95658 +dma_map_area_8178 dma_map_area 5-2-3 8178 NULL
95659 +__sk_mem_schedule_8185 __sk_mem_schedule 2 8185 NULL
95660 +ieee80211_if_fmt_dot11MeshHoldingTimeout_8187 ieee80211_if_fmt_dot11MeshHoldingTimeout 3 8187 NULL
95661 +recent_mt_proc_write_8206 recent_mt_proc_write 3 8206 NULL
95662 +rt2x00debug_write_bbp_8212 rt2x00debug_write_bbp 3 8212 NULL
95663 +ad7879_spi_multi_read_8218 ad7879_spi_multi_read 3 8218 NULL
95664 +play_iframe_8219 play_iframe 3 8219 NULL
95665 +create_log_8225 create_log 2 8225 NULL nohasharray
95666 +kvm_mmu_page_set_gfn_8225 kvm_mmu_page_set_gfn 2 8225 &create_log_8225
95667 +sctp_ssnmap_size_8228 sctp_ssnmap_size 0-1-2 8228 NULL
95668 +bnx2x_iov_get_max_queue_count_8235 bnx2x_iov_get_max_queue_count 0 8235 NULL
95669 +check_xattr_ref_inode_8244 check_xattr_ref_inode 0 8244 NULL
95670 +add_rx_skb_8257 add_rx_skb 3 8257 NULL
95671 +t3_init_l2t_8261 t3_init_l2t 1 8261 NULL
95672 +init_cdev_8274 init_cdev 1 8274 NULL
95673 +rproc_recovery_write_8281 rproc_recovery_write 3 8281 NULL
95674 +qib_decode_7220_err_8315 qib_decode_7220_err 3 8315 NULL
95675 +construct_key_and_link_8321 construct_key_and_link 4 8321 NULL
95676 +ipwireless_send_packet_8328 ipwireless_send_packet 4 8328 NULL
95677 +tracing_entries_read_8345 tracing_entries_read 3 8345 NULL
95678 +ieee80211_if_fmt_ht_opmode_8347 ieee80211_if_fmt_ht_opmode 3 8347 NULL
95679 +ping_getfrag_8360 ping_getfrag 4-3 8360 NULL
95680 +uvc_v4l2_compat_ioctl32_8375 uvc_v4l2_compat_ioctl32 3 8375 NULL
95681 +xdi_copy_from_user_8395 xdi_copy_from_user 4 8395 NULL
95682 +zd_rf_scnprint_id_8406 zd_rf_scnprint_id 0-3 8406 NULL
95683 +uvc_v4l2_ioctl_8411 uvc_v4l2_ioctl 2 8411 NULL
95684 +pca953x_gpio_to_irq_8424 pca953x_gpio_to_irq 2 8424 NULL
95685 +snd_usb_ctl_msg_8436 snd_usb_ctl_msg 8 8436 NULL
95686 +irq_create_mapping_8437 irq_create_mapping 2 8437 NULL
95687 +afs_cell_lookup_8482 afs_cell_lookup 2 8482 NULL
95688 +batadv_tt_len_8502 batadv_tt_len 0-1 8502 NULL
95689 +dev_config_8506 dev_config 3 8506 NULL
95690 +ACL_to_cifs_posix_8509 ACL_to_cifs_posix 3 8509 NULL
95691 +opticon_process_data_packet_8524 opticon_process_data_packet 3 8524 NULL
95692 +pnp_resource_len_8532 pnp_resource_len 0 8532 NULL
95693 +alloc_pg_vec_8533 alloc_pg_vec 2 8533 NULL
95694 +ocfs2_read_virt_blocks_8538 ocfs2_read_virt_blocks 2-3 8538 NULL
95695 +profile_remove_8556 profile_remove 3 8556 NULL
95696 +cache_slow_downcall_8570 cache_slow_downcall 2 8570 NULL
95697 +mga_ioremap_8571 mga_ioremap 1-2 8571 NULL
95698 +isr_dma0_done_read_8574 isr_dma0_done_read 3 8574 NULL
95699 +tower_write_8580 tower_write 3 8580 NULL
95700 +rtllib_MFIE_rate_len_8606 rtllib_MFIE_rate_len 0 8606 NULL
95701 +shash_setkey_unaligned_8620 shash_setkey_unaligned 3 8620 NULL
95702 +it821x_firmware_command_8628 it821x_firmware_command 3 8628 NULL
95703 +scsi_dma_map_8632 scsi_dma_map 0 8632 NULL
95704 +fuse_send_write_pages_8636 fuse_send_write_pages 0 8636 NULL
95705 +generic_acl_set_8658 generic_acl_set 4 8658 NULL
95706 +dio_bio_alloc_8677 dio_bio_alloc 5 8677 NULL
95707 +lbs_bcnmiss_read_8678 lbs_bcnmiss_read 3 8678 NULL
95708 +tc3589x_gpio_irq_unmap_8680 tc3589x_gpio_irq_unmap 2 8680 NULL
95709 +rproc_trace_read_8686 rproc_trace_read 3 8686 NULL
95710 +skb_frag_size_8695 skb_frag_size 0 8695 NULL
95711 +arcfb_write_8702 arcfb_write 3 8702 NULL
95712 +i_size_read_8703 i_size_read 0 8703 NULL nohasharray
95713 +init_header_8703 init_header 0 8703 &i_size_read_8703
95714 +ctrl_out_8712 ctrl_out 3-5 8712 NULL
95715 +jffs2_acl_count_8729 jffs2_acl_count 0-1 8729 NULL
95716 +f_dupfd_8730 f_dupfd 1 8730 NULL
95717 +__create_irqs_8733 __create_irqs 2-1 8733 NULL
95718 +pca953x_gpio_irq_map_8737 pca953x_gpio_irq_map 2 8737 NULL
95719 +tx_tx_exch_expiry_read_8749 tx_tx_exch_expiry_read 3 8749 NULL
95720 +joydev_compat_ioctl_8765 joydev_compat_ioctl 2 8765 NULL
95721 +sys_prctl_8766 sys_prctl 4 8766 NULL
95722 +x32_arch_ptrace_8767 x32_arch_ptrace 3-4 8767 NULL
95723 +paging32_prefetch_gpte_8783 paging32_prefetch_gpte 4 8783 NULL
95724 +ext4_try_to_write_inline_data_8785 ext4_try_to_write_inline_data 3-4 8785 NULL
95725 +__bitmap_weight_8796 __bitmap_weight 0-2 8796 NULL
95726 +cpuset_common_file_read_8800 cpuset_common_file_read 5 8800 NULL
95727 +metronomefb_write_8823 metronomefb_write 3 8823 NULL
95728 +icmpv6_manip_pkt_8833 icmpv6_manip_pkt 4 8833 NULL nohasharray
95729 +get_queue_depth_8833 get_queue_depth 0 8833 &icmpv6_manip_pkt_8833
95730 +dvb_ringbuffer_pkt_next_8834 dvb_ringbuffer_pkt_next 0-2 8834 NULL
95731 +usb_ep_queue_8839 usb_ep_queue 0 8839 NULL
95732 +clear_bitset_8840 clear_bitset 2 8840 NULL
95733 +debug_debug1_read_8856 debug_debug1_read 3 8856 NULL
95734 +wa_nep_queue_8858 wa_nep_queue 2 8858 NULL
95735 +compressed_bio_size_8887 compressed_bio_size 0-2 8887 NULL
95736 +tracing_max_lat_read_8890 tracing_max_lat_read 3 8890 NULL
95737 +sdio_max_byte_size_8907 sdio_max_byte_size 0 8907 NULL
95738 +layout_commit_8926 layout_commit 3 8926 NULL
95739 +adjust_priv_size_8935 adjust_priv_size 0-1 8935 NULL
95740 +driver_stats_read_8944 driver_stats_read 3 8944 NULL
95741 +read_file_tgt_stats_8959 read_file_tgt_stats 3 8959 NULL
95742 +seq_bitmap_list_8963 seq_bitmap_list 3 8963 NULL
95743 +usb_allocate_stream_buffers_8964 usb_allocate_stream_buffers 3 8964 NULL
95744 +qib_qsfp_dump_8966 qib_qsfp_dump 0-3 8966 NULL
95745 +venus_mkdir_8967 venus_mkdir 4 8967 NULL
95746 +vol_cdev_read_8968 vol_cdev_read 3 8968 NULL nohasharray
95747 +seq_open_net_8968 seq_open_net 4 8968 &vol_cdev_read_8968
95748 +bio_integrity_get_tag_8974 bio_integrity_get_tag 3 8974 NULL
95749 +snd_emu10k1_ptr_read_9026 snd_emu10k1_ptr_read 0-2 9026 NULL
95750 +__pskb_copy_9038 __pskb_copy 2 9038 NULL
95751 +nla_put_9042 nla_put 3 9042 NULL
95752 +snd_emu10k1_synth_copy_from_user_9061 snd_emu10k1_synth_copy_from_user 3-5 9061 NULL
95753 +snd_gus_dram_peek_9062 snd_gus_dram_peek 4 9062 NULL
95754 +fib_info_hash_alloc_9075 fib_info_hash_alloc 1 9075 NULL
95755 +string_9080 string 0 9080 NULL
95756 +create_queues_9088 create_queues 2-3 9088 NULL
95757 +ftdi_prepare_write_buffer_9093 ftdi_prepare_write_buffer 3 9093 NULL
95758 +caif_stream_sendmsg_9110 caif_stream_sendmsg 4 9110 NULL nohasharray
95759 +gfn_to_rmap_9110 gfn_to_rmap 2-3 9110 &caif_stream_sendmsg_9110
95760 +pmcraid_change_queue_depth_9116 pmcraid_change_queue_depth 2 9116 NULL
95761 +mq_remove_mapping_9124 mq_remove_mapping 2 9124 NULL
95762 +mlx4_alloc_resize_umem_9132 mlx4_alloc_resize_umem 3 9132 NULL
95763 +ext4_list_backups_9138 ext4_list_backups 0 9138 NULL
95764 +dbg_command_buf_9165 dbg_command_buf 2 9165 NULL
95765 +isr_irqs_read_9181 isr_irqs_read 3 9181 NULL
95766 +count_leading_zeros_9183 count_leading_zeros 0 9183 NULL
95767 +alloc_group_attrs_9194 alloc_group_attrs 2 9194 NULL nohasharray
95768 +altera_swap_ir_9194 altera_swap_ir 2 9194 &alloc_group_attrs_9194
95769 +gx1_gx_base_9198 gx1_gx_base 0 9198 NULL
95770 +snd_m3_get_pointer_9206 snd_m3_get_pointer 0 9206 NULL
95771 +get_pfn_9207 get_pfn 1 9207 NULL
95772 +tx_tx_prepared_descs_read_9221 tx_tx_prepared_descs_read 3 9221 NULL
95773 +sctp_getsockopt_delayed_ack_9232 sctp_getsockopt_delayed_ack 2 9232 NULL
95774 +ocfs2_clear_ext_refcount_9256 ocfs2_clear_ext_refcount 4 9256 NULL
95775 +tcf_csum_ipv4_icmp_9258 tcf_csum_ipv4_icmp 3 9258 NULL
95776 +sparse_early_usemaps_alloc_node_9269 sparse_early_usemaps_alloc_node 4 9269 NULL
95777 +hdpvr_read_9273 hdpvr_read 3 9273 NULL
95778 +flakey_status_9274 flakey_status 5 9274 NULL
95779 +qla82xx_pci_set_window_9303 qla82xx_pci_set_window 0-2 9303 NULL
95780 +iwl_dbgfs_stations_read_9309 iwl_dbgfs_stations_read 3 9309 NULL
95781 +ceph_sync_setxattr_9310 ceph_sync_setxattr 4 9310 NULL
95782 +memblock_find_in_range_node_9328 memblock_find_in_range_node 0-3-4 9328 NULL
95783 +ieee80211_if_fmt_txpower_9334 ieee80211_if_fmt_txpower 3 9334 NULL
95784 +ocfs2_orphan_for_truncate_9342 ocfs2_orphan_for_truncate 4 9342 NULL
95785 +read_9397 read 3 9397 NULL
95786 +nf_nat_sip_expect_9418 nf_nat_sip_expect 8 9418 NULL
95787 +bm_realloc_pages_9431 bm_realloc_pages 2 9431 NULL
95788 +ffs_ep0_write_9438 ffs_ep0_write 3 9438 NULL
95789 +kmalloc_array_9444 kmalloc_array 1-2 9444 NULL
95790 +ieee80211_if_fmt_fwded_unicast_9454 ieee80211_if_fmt_fwded_unicast 3 9454 NULL
95791 +mcs_unwrap_mir_9455 mcs_unwrap_mir 3 9455 NULL
95792 +ext3_xattr_set_acl_9467 ext3_xattr_set_acl 4 9467 NULL
95793 +agp_generic_alloc_user_9470 agp_generic_alloc_user 1 9470 NULL
95794 +__alloc_preds_9492 __alloc_preds 2 9492 NULL nohasharray
95795 +crypt_status_9492 crypt_status 5 9492 &__alloc_preds_9492
95796 +lp_write_9511 lp_write 3 9511 NULL
95797 +xen_remap_exchanged_ptes_9513 xen_remap_exchanged_ptes 1 9513 NULL
95798 +scsi_tgt_kspace_exec_9522 scsi_tgt_kspace_exec 8 9522 NULL
95799 +read_file_dma_9530 read_file_dma 3 9530 NULL
95800 +ext3_alloc_branch_9534 ext3_alloc_branch 5 9534 NULL
95801 +audit_log_n_untrustedstring_9548 audit_log_n_untrustedstring 3 9548 NULL
95802 +fw_node_create_9559 fw_node_create 2 9559 NULL
95803 +ipath_get_user_pages_9561 ipath_get_user_pages 1-2 9561 NULL
95804 +kobj_map_9566 kobj_map 2-3 9566 NULL
95805 +f2fs_read_data_pages_9574 f2fs_read_data_pages 4 9574 NULL
95806 +biovec_create_pools_9575 biovec_create_pools 2 9575 NULL
95807 +ieee80211_tdls_mgmt_9581 ieee80211_tdls_mgmt 8 9581 NULL
95808 +do_sync_9604 do_sync 1 9604 NULL
95809 +snd_emu10k1_fx8010_read_9605 snd_emu10k1_fx8010_read 5-6 9605 NULL
95810 +saa7164_buffer_alloc_user_9627 saa7164_buffer_alloc_user 2 9627 NULL
95811 +ceph_copy_user_to_page_vector_9635 ceph_copy_user_to_page_vector 4-3 9635 NULL
95812 +compat_sys_keyctl_9639 compat_sys_keyctl 4-2-3 9639 NULL
95813 +ocfs2_xattr_get_rec_9652 ocfs2_xattr_get_rec 0 9652 NULL
95814 +uvc_alloc_buffers_9656 uvc_alloc_buffers 2-3 9656 NULL
95815 +queue_received_packet_9657 queue_received_packet 5 9657 NULL
95816 +snd_opl4_mem_proc_write_9670 snd_opl4_mem_proc_write 5 9670 NULL
95817 +ks8842_read16_9676 ks8842_read16 0 9676 NULL nohasharray
95818 +dns_query_9676 dns_query 3 9676 &ks8842_read16_9676
95819 +qib_7322_handle_hwerrors_9678 qib_7322_handle_hwerrors 3 9678 NULL
95820 +__erst_read_from_storage_9690 __erst_read_from_storage 0 9690 NULL
95821 +is_hole_9694 is_hole 2 9694 NULL nohasharray
95822 +x25_asy_compat_ioctl_9694 x25_asy_compat_ioctl 4 9694 &is_hole_9694
95823 +fnb_9703 fnb 2-3 9703 NULL
95824 +fuse_iter_npages_9705 fuse_iter_npages 0 9705 NULL nohasharray
95825 +ieee80211_if_read_aid_9705 ieee80211_if_read_aid 3 9705 &fuse_iter_npages_9705
95826 +ieee80211_if_fmt_num_mcast_sta_9738 ieee80211_if_fmt_num_mcast_sta 3 9738 NULL
95827 +ddb_input_read_9743 ddb_input_read 3 9743 NULL
95828 +sta_last_ack_signal_read_9751 sta_last_ack_signal_read 3 9751 NULL
95829 +btrfs_super_root_9763 btrfs_super_root 0 9763 NULL
95830 +__alloc_percpu_9764 __alloc_percpu 1-2 9764 NULL
95831 +__blk_queue_init_tags_9778 __blk_queue_init_tags 2 9778 NULL
95832 +snd_mem_proc_write_9786 snd_mem_proc_write 3 9786 NULL
95833 +ttm_bo_fbdev_io_9805 ttm_bo_fbdev_io 4 9805 NULL
95834 +ieee80211_if_read_state_9813 ieee80211_if_read_state 3 9813 NULL
95835 +pnp_mem_start_9817 pnp_mem_start 0 9817 NULL
95836 +kernel_physical_mapping_init_9818 kernel_physical_mapping_init 0-2-1 9818 NULL
95837 +dvb_dvr_set_buffer_size_9840 dvb_dvr_set_buffer_size 2 9840 NULL
95838 +cfg80211_send_deauth_9862 cfg80211_send_deauth 3 9862 NULL
95839 +pmcraid_alloc_sglist_9864 pmcraid_alloc_sglist 1 9864 NULL
95840 +btrfs_free_reserved_extent_9867 btrfs_free_reserved_extent 2 9867 NULL
95841 +f1x_translate_sysaddr_to_cs_9868 f1x_translate_sysaddr_to_cs 2 9868 NULL
95842 +mlx4_bitmap_alloc_range_9876 mlx4_bitmap_alloc_range 2-3 9876 NULL
95843 +wil_read_file_ioblob_9878 wil_read_file_ioblob 3 9878 NULL
95844 +bm_register_write_9893 bm_register_write 3 9893 NULL nohasharray
95845 +snd_midi_event_new_9893 snd_midi_event_new 1 9893 &bm_register_write_9893
95846 +snd_gf1_pcm_playback_copy_9895 snd_gf1_pcm_playback_copy 3-5 9895 NULL
95847 +nonpaging_page_fault_9908 nonpaging_page_fault 2 9908 NULL
95848 +gen6_get_total_gtt_size_9913 gen6_get_total_gtt_size 0-1 9913 NULL
95849 +pstore_ftrace_knob_read_9947 pstore_ftrace_knob_read 3 9947 NULL
95850 +read_file_misc_9948 read_file_misc 3 9948 NULL
95851 +set_rxd_buffer_pointer_9950 set_rxd_buffer_pointer 8 9950 NULL
95852 +ext2_new_blocks_9954 ext2_new_blocks 2 9954 NULL
95853 +csum_partial_copy_fromiovecend_9957 csum_partial_copy_fromiovecend 3-4 9957 NULL
95854 +get_free_serial_index_9969 get_free_serial_index 0 9969 NULL
95855 +btrfs_add_link_9973 btrfs_add_link 5 9973 NULL
95856 +ath6kl_usb_submit_ctrl_out_9978 ath6kl_usb_submit_ctrl_out 6 9978 NULL
95857 +aat2870_dump_reg_10019 aat2870_dump_reg 0 10019 NULL
95858 +handle_request_10024 handle_request 9 10024 NULL
95859 +batadv_orig_hash_add_if_10033 batadv_orig_hash_add_if 2 10033 NULL
95860 +ieee80211_probereq_get_10040 ieee80211_probereq_get 4-5 10040 NULL
95861 +xen_destroy_contiguous_region_10054 xen_destroy_contiguous_region 1 10054 NULL
95862 +ieee80211_set_probe_resp_10077 ieee80211_set_probe_resp 3 10077 NULL
95863 +ufs_bitmap_search_10105 ufs_bitmap_search 0-3 10105 NULL
95864 +get_elem_size_10110 get_elem_size 0-2 10110 NULL nohasharray
95865 +dynamic_ps_timeout_read_10110 dynamic_ps_timeout_read 3 10110 &get_elem_size_10110
95866 +jbd_alloc_10112 jbd_alloc 0 10112 NULL nohasharray
95867 +gfs2_meta_read_10112 gfs2_meta_read 0 10112 &jbd_alloc_10112
95868 +offset_to_bit_10134 offset_to_bit 0 10134 NULL
95869 +aes_decrypt_packets_read_10155 aes_decrypt_packets_read 3 10155 NULL
95870 +rx_out_of_mem_read_10157 rx_out_of_mem_read 3 10157 NULL
95871 +hidg_alloc_ep_req_10159 hidg_alloc_ep_req 2 10159 NULL nohasharray
95872 +ol_chunk_entries_10159 ol_chunk_entries 0 10159 &hidg_alloc_ep_req_10159
95873 +stmpe_irq_unmap_10164 stmpe_irq_unmap 2 10164 NULL
95874 +asd_store_update_bios_10165 asd_store_update_bios 4 10165 NULL
95875 +proc_pid_attr_read_10173 proc_pid_attr_read 3 10173 NULL
95876 +jffs2_user_setxattr_10182 jffs2_user_setxattr 4 10182 NULL
95877 +do_ioctl_trans_10194 do_ioctl_trans 3 10194 NULL
95878 +cciss_proc_write_10259 cciss_proc_write 3 10259 NULL
95879 +snd_rme9652_capture_copy_10287 snd_rme9652_capture_copy 5 10287 NULL
95880 +ubi_leb_change_10289 ubi_leb_change 4 10289 NULL
95881 +read_emulate_10310 read_emulate 2-4 10310 NULL
95882 +read_file_spectral_count_10320 read_file_spectral_count 3 10320 NULL
95883 +ttm_object_device_init_10321 ttm_object_device_init 2 10321 NULL
95884 +ubi_leb_read_10328 ubi_leb_read 0 10328 NULL
95885 +tun_sendmsg_10337 tun_sendmsg 4 10337 NULL
95886 +get_dump_page_10338 get_dump_page 1 10338 NULL
95887 +ufx_alloc_urb_list_10349 ufx_alloc_urb_list 3 10349 NULL
95888 +dbAllocAny_10354 dbAllocAny 0 10354 NULL
95889 +ath6kl_listen_int_read_10355 ath6kl_listen_int_read 3 10355 NULL
95890 +ms_write_multiple_pages_10362 ms_write_multiple_pages 6-5 10362 NULL
95891 +sta_ht_capa_read_10366 sta_ht_capa_read 3 10366 NULL
95892 +ecryptfs_decode_and_decrypt_filename_10379 ecryptfs_decode_and_decrypt_filename 5 10379 NULL
95893 +do_compat_pselect_10398 do_compat_pselect 1 10398 NULL
95894 +fwtty_rx_10434 fwtty_rx 3 10434 NULL
95895 +event_phy_transmit_error_read_10471 event_phy_transmit_error_read 3 10471 NULL
95896 +ca91cx42_alloc_resource_10502 ca91cx42_alloc_resource 2 10502 NULL
95897 +qib_alloc_fast_reg_page_list_10507 qib_alloc_fast_reg_page_list 2 10507 NULL
95898 +sel_write_disable_10511 sel_write_disable 3 10511 NULL
95899 +osd_req_write_sg_kern_10514 osd_req_write_sg_kern 5 10514 NULL
95900 +rds_message_alloc_10517 rds_message_alloc 1 10517 NULL
95901 +ocfs2_add_refcounted_extent_10526 ocfs2_add_refcounted_extent 6 10526 NULL
95902 +get_vm_area_caller_10527 get_vm_area_caller 1 10527 NULL
95903 +snd_pcm_lib_read_10536 snd_pcm_lib_read 0-3 10536 NULL
95904 +ieee80211_send_probe_req_10539 ieee80211_send_probe_req 4-6 10539 NULL
95905 +ext4_write_begin_10576 ext4_write_begin 3-4 10576 NULL
95906 +scrub_remap_extent_10588 scrub_remap_extent 2 10588 NULL
95907 +otp_read_10594 otp_read 2-4-5 10594 NULL
95908 +supply_map_read_file_10608 supply_map_read_file 3 10608 NULL
95909 +ima_show_htable_violations_10619 ima_show_htable_violations 3 10619 NULL
95910 +alloc_coherent_10632 alloc_coherent 2 10632 NULL
95911 +nfs_idmap_lookup_id_10660 nfs_idmap_lookup_id 2 10660 NULL
95912 +parport_write_10669 parport_write 0 10669 NULL
95913 +inl_10708 inl 0 10708 NULL nohasharray
95914 +selinux_inode_setxattr_10708 selinux_inode_setxattr 4 10708 &inl_10708
95915 +pvr2_ioread_read_10720 pvr2_ioread_read 3 10720 NULL nohasharray
95916 +shash_async_setkey_10720 shash_async_setkey 3 10720 &pvr2_ioread_read_10720
95917 +spi_sync_10731 spi_sync 0 10731 NULL
95918 +sctp_getsockopt_maxseg_10737 sctp_getsockopt_maxseg 2 10737 NULL nohasharray
95919 +apu_get_register_10737 apu_get_register 0 10737 &sctp_getsockopt_maxseg_10737
95920 +compat_sys_msgsnd_10738 compat_sys_msgsnd 2 10738 NULL
95921 +sys_syslog_10746 sys_syslog 3 10746 NULL
95922 +alloc_one_pg_vec_page_10747 alloc_one_pg_vec_page 1 10747 NULL
95923 +vhost_add_used_n_10760 vhost_add_used_n 3 10760 NULL
95924 +kvm_read_guest_atomic_10765 kvm_read_guest_atomic 4-2 10765 NULL
95925 +wb_set_dirty_10778 wb_set_dirty 2 10778 NULL
95926 +__qp_memcpy_to_queue_10779 __qp_memcpy_to_queue 2-4 10779 NULL
95927 +sys_bind_10799 sys_bind 3 10799 NULL
95928 +compat_put_int_10828 compat_put_int 1 10828 NULL
95929 +lbs_sleepparams_read_10840 lbs_sleepparams_read 3 10840 NULL
95930 +ida_get_new_above_10853 ida_get_new_above 2 10853 NULL
95931 +fuse_conn_max_background_read_10855 fuse_conn_max_background_read 3 10855 NULL
95932 +ol_chunk_blocks_10864 ol_chunk_blocks 0 10864 NULL
95933 +snd_pcm_oss_write1_10872 snd_pcm_oss_write1 3 10872 NULL
95934 +mid_get_vbt_data_r0_10876 mid_get_vbt_data_r0 2 10876 NULL
95935 +bl_mark_for_commit_10879 bl_mark_for_commit 2-3 10879 NULL
95936 +get_scq_10897 get_scq 2 10897 NULL
95937 +cgroup_write_string_10900 cgroup_write_string 5 10900 NULL
95938 +tifm_alloc_adapter_10903 tifm_alloc_adapter 1 10903 NULL
95939 +__copy_from_user_10918 __copy_from_user 3 10918 NULL
95940 +da9052_map_irq_10952 da9052_map_irq 2 10952 NULL
95941 +bm_entry_read_10976 bm_entry_read 3 10976 NULL
95942 +i915_min_freq_write_10981 i915_min_freq_write 3 10981 NULL
95943 +sched_autogroup_write_10984 sched_autogroup_write 3 10984 NULL
95944 +__hci_num_ctrl_10985 __hci_num_ctrl 0 10985 NULL
95945 +xfrm_hash_alloc_10997 xfrm_hash_alloc 1 10997 NULL
95946 +rx_filter_accum_arp_pend_requests_read_11003 rx_filter_accum_arp_pend_requests_read 3 11003 NULL
95947 +SetLineNumber_11023 SetLineNumber 0 11023 NULL
95948 +mb_find_next_bit_11037 mb_find_next_bit 2-3-0 11037 NULL
95949 +tda10048_writeregbulk_11050 tda10048_writeregbulk 4 11050 NULL
95950 +tcp_send_mss_11079 tcp_send_mss 0 11079 NULL
95951 +count_argc_11083 count_argc 0 11083 NULL
95952 +kvm_write_guest_cached_11106 kvm_write_guest_cached 4 11106 NULL
95953 +stmpe_gpio_to_irq_11110 stmpe_gpio_to_irq 2 11110 NULL
95954 +tw_change_queue_depth_11116 tw_change_queue_depth 2 11116 NULL
95955 +page_offset_11120 page_offset 0 11120 NULL
95956 +tracing_buffers_read_11124 tracing_buffers_read 3 11124 NULL
95957 +acpi_os_map_memory_11161 acpi_os_map_memory 1-2 11161 NULL
95958 +ioat2_alloc_ring_11172 ioat2_alloc_ring 2 11172 NULL nohasharray
95959 +snd_gf1_pcm_playback_silence_11172 snd_gf1_pcm_playback_silence 3-4 11172 &ioat2_alloc_ring_11172
95960 +__swab16p_11220 __swab16p 0 11220 NULL
95961 +il_dbgfs_rx_queue_read_11221 il_dbgfs_rx_queue_read 3 11221 NULL
95962 +mmap_region_11247 mmap_region 0-2 11247 NULL
95963 +ubifs_write_node_11258 ubifs_write_node 5-3 11258 NULL
95964 +dm_cache_discard_bitset_resize_11262 dm_cache_discard_bitset_resize 3 11262 NULL
95965 +hugetlbfs_read_11268 hugetlbfs_read 3 11268 NULL
95966 +cru_detect_11272 cru_detect 1 11272 NULL
95967 +ext4_xattr_check_names_11314 ext4_xattr_check_names 0 11314 NULL
95968 +tcp_send_rcvq_11316 tcp_send_rcvq 3 11316 NULL
95969 +construct_key_11329 construct_key 3 11329 NULL nohasharray
95970 +__kfifo_out_peek_11329 __kfifo_out_peek 0-3 11329 &construct_key_11329
95971 +next_segment_11330 next_segment 0-2-1 11330 NULL
95972 +persistent_ram_buffer_map_11332 persistent_ram_buffer_map 1-2 11332 NULL
95973 +ext4_get_inline_size_11349 ext4_get_inline_size 0 11349 NULL
95974 +i915_max_freq_write_11350 i915_max_freq_write 3 11350 NULL
95975 +sel_write_create_11353 sel_write_create 3 11353 NULL
95976 +handle_unit_11355 handle_unit 0-1 11355 NULL
95977 +batadv_skb_head_push_11360 batadv_skb_head_push 2 11360 NULL
95978 +drm_vblank_init_11362 drm_vblank_init 2 11362 NULL
95979 +qib_get_base_info_11369 qib_get_base_info 3 11369 NULL
95980 +dev_irnet_write_11398 dev_irnet_write 3 11398 NULL
95981 +___alloc_bootmem_11410 ___alloc_bootmem 1-2 11410 NULL
95982 +str_to_user_11411 str_to_user 2 11411 NULL
95983 +mem_fw_gen_free_mem_blks_read_11413 mem_fw_gen_free_mem_blks_read 3 11413 NULL
95984 +ath6kl_wmi_test_rx_11414 ath6kl_wmi_test_rx 3 11414 NULL
95985 +adis16480_show_firmware_revision_11417 adis16480_show_firmware_revision 3 11417 NULL
95986 +trace_options_read_11419 trace_options_read 3 11419 NULL
95987 +xd_read_multiple_pages_11422 xd_read_multiple_pages 5-4 11422 NULL
95988 +prepare_image_11424 prepare_image 0 11424 NULL
95989 +vring_size_11426 vring_size 0-1-2 11426 NULL
95990 +bttv_read_11432 bttv_read 3 11432 NULL
95991 +create_zero_mask_11453 create_zero_mask 0-1 11453 NULL
95992 +swp_offset_11475 swp_offset 0 11475 NULL
95993 +sca3000_read_first_n_hw_rb_11479 sca3000_read_first_n_hw_rb 2 11479 NULL
95994 +xfs_file_buffered_aio_write_11492 xfs_file_buffered_aio_write 4 11492 NULL
95995 +sd_do_mode_sense_11507 sd_do_mode_sense 5 11507 NULL
95996 +kmem_zalloc_11510 kmem_zalloc 1 11510 NULL
95997 +twl_direction_in_11527 twl_direction_in 2 11527 NULL
95998 +setup_IO_APIC_irq_extra_11537 setup_IO_APIC_irq_extra 1 11537 NULL
95999 +skb_cow_data_11565 skb_cow_data 0-2 11565 NULL
96000 +mlx4_init_cmpt_table_11569 mlx4_init_cmpt_table 3 11569 NULL
96001 +oprofilefs_ulong_to_user_11582 oprofilefs_ulong_to_user 3 11582 NULL
96002 +snd_pcm_action_11589 snd_pcm_action 0 11589 NULL
96003 +fw_device_op_ioctl_11595 fw_device_op_ioctl 2 11595 NULL
96004 +sisusb_send_bridge_packet_11649 sisusb_send_bridge_packet 2 11649 NULL
96005 +nla_total_size_11658 nla_total_size 0-1 11658 NULL
96006 +ide_queue_pc_tail_11673 ide_queue_pc_tail 5 11673 NULL
96007 +btrfs_alloc_delayed_item_11678 btrfs_alloc_delayed_item 1 11678 NULL
96008 +dsp_buffer_alloc_11684 dsp_buffer_alloc 2 11684 NULL
96009 +sctp_setsockopt_hmac_ident_11687 sctp_setsockopt_hmac_ident 3 11687 NULL
96010 +split_11691 split 2 11691 NULL
96011 +snd_ctl_elem_user_tlv_11695 snd_ctl_elem_user_tlv 3 11695 NULL
96012 +blk_rq_cur_bytes_11723 blk_rq_cur_bytes 0 11723 NULL
96013 +tcf_csum_ipv6_icmp_11738 tcf_csum_ipv6_icmp 4 11738 NULL
96014 +nfsd4_get_drc_mem_11748 nfsd4_get_drc_mem 0-1-2 11748 NULL
96015 +dm_bio_prison_create_11749 dm_bio_prison_create 1 11749 NULL
96016 +iwl_dbgfs_qos_read_11753 iwl_dbgfs_qos_read 3 11753 NULL
96017 +ps_pspoll_timeouts_read_11776 ps_pspoll_timeouts_read 3 11776 NULL
96018 +ebt_buf_add_11779 ebt_buf_add 0 11779 NULL
96019 +btrfs_key_blockptr_11786 btrfs_key_blockptr 0 11786 NULL
96020 +pcpu_fc_alloc_11818 pcpu_fc_alloc 2-3 11818 NULL
96021 +zerocopy_sg_from_iovec_11828 zerocopy_sg_from_iovec 3 11828 NULL
96022 +sctp_setsockopt_maxseg_11829 sctp_setsockopt_maxseg 3 11829 NULL
96023 +rts51x_read_status_11830 rts51x_read_status 4 11830 NULL
96024 +unix_stream_connect_11844 unix_stream_connect 3 11844 NULL
96025 +nf_nat_sdp_media_11863 nf_nat_sdp_media 9 11863 NULL
96026 +ecryptfs_copy_filename_11868 ecryptfs_copy_filename 4 11868 NULL
96027 +ieee80211_rx_bss_info_11887 ieee80211_rx_bss_info 3 11887 NULL
96028 +kmalloc_slab_11917 kmalloc_slab 1 11917 NULL
96029 +fs_devrw_entry_11924 fs_devrw_entry 3 11924 NULL
96030 +bitmap_remap_11929 bitmap_remap 5 11929 NULL
96031 +atomic_sub_return_11939 atomic_sub_return 0-1 11939 NULL
96032 +dccp_feat_clone_sp_val_11942 dccp_feat_clone_sp_val 3 11942 NULL
96033 +f1x_swap_interleaved_region_11970 f1x_swap_interleaved_region 0-2 11970 NULL
96034 +atmel_read16_11981 atmel_read16 0 11981 NULL
96035 +read_and_add_raw_conns_11987 read_and_add_raw_conns 0 11987 NULL
96036 +ftdi_elan_total_command_size_12045 ftdi_elan_total_command_size 0 12045 NULL
96037 +ieee80211_if_read_user_power_level_12050 ieee80211_if_read_user_power_level 3 12050 NULL
96038 +il4965_ucode_tx_stats_read_12064 il4965_ucode_tx_stats_read 3 12064 NULL
96039 +ptc_proc_write_12076 ptc_proc_write 3 12076 NULL
96040 +ubifs_recover_log_leb_12079 ubifs_recover_log_leb 3 12079 NULL
96041 +pse36_gfn_delta_12087 pse36_gfn_delta 0-1 12087 NULL
96042 +alloc_bulk_urbs_generic_12127 alloc_bulk_urbs_generic 5 12127 NULL
96043 +set_powered_12129 set_powered 4 12129 NULL
96044 +nfs_writedata_alloc_12133 nfs_writedata_alloc 2 12133 NULL
96045 +ramoops_init_prz_12134 ramoops_init_prz 5 12134 NULL
96046 +xfs_handle_to_dentry_12135 xfs_handle_to_dentry 3 12135 NULL
96047 +batadv_add_packet_12136 batadv_add_packet 3 12136 NULL
96048 +rawv6_seticmpfilter_12137 rawv6_seticmpfilter 5 12137 NULL
96049 +vmw_fifo_reserve_12141 vmw_fifo_reserve 2 12141 NULL
96050 +get_idx_gc_leb_12148 get_idx_gc_leb 0 12148 NULL
96051 +btmrvl_sdio_host_to_card_12152 btmrvl_sdio_host_to_card 3 12152 NULL
96052 +vmbus_open_12154 vmbus_open 2-3 12154 NULL
96053 +wil_rxdesc_phy_length_12165 wil_rxdesc_phy_length 0 12165 NULL
96054 +dma_memcpy_to_iovec_12173 dma_memcpy_to_iovec 5 12173 NULL
96055 +ddp_make_gl_12179 ddp_make_gl 1 12179 NULL
96056 +compat_do_arpt_set_ctl_12184 compat_do_arpt_set_ctl 4 12184 NULL
96057 +ip_generic_getfrag_12187 ip_generic_getfrag 3-4 12187 NULL
96058 +bl_is_sector_init_12199 bl_is_sector_init 2 12199 NULL
96059 +free_initrd_mem_12203 free_initrd_mem 1 12203 NULL
96060 +receive_copy_12216 receive_copy 3 12216 NULL
96061 +snd_pcm_kernel_ioctl_12219 snd_pcm_kernel_ioctl 0 12219 NULL
96062 +fuse_get_req_12221 fuse_get_req 2 12221 NULL nohasharray
96063 +aat2870_reg_read_file_12221 aat2870_reg_read_file 3 12221 &fuse_get_req_12221
96064 +__alloc_bootmem_low_nopanic_12235 __alloc_bootmem_low_nopanic 1-2 12235 NULL
96065 +ib_uverbs_unmarshall_recv_12251 ib_uverbs_unmarshall_recv 5 12251 NULL
96066 +ath_descdma_setup_12257 ath_descdma_setup 5 12257 NULL
96067 +shash_compat_setkey_12267 shash_compat_setkey 3 12267 NULL
96068 +add_sctp_bind_addr_12269 add_sctp_bind_addr 3 12269 NULL
96069 +note_last_dentry_12285 note_last_dentry 3 12285 NULL
96070 +roundup_to_multiple_of_64_12288 roundup_to_multiple_of_64 0-1 12288 NULL nohasharray
96071 +il_dbgfs_nvm_read_12288 il_dbgfs_nvm_read 3 12288 &roundup_to_multiple_of_64_12288
96072 +vxge_get_num_vfs_12302 vxge_get_num_vfs 0 12302 NULL
96073 +tipc_msg_build_12326 tipc_msg_build 4 12326 NULL
96074 +pcbit_writecmd_12332 pcbit_writecmd 2 12332 NULL
96075 +mptctl_ioctl_12355 mptctl_ioctl 2 12355 NULL
96076 +paging32_walk_addr_12359 paging32_walk_addr 3 12359 NULL
96077 +__nf_ct_ext_add_length_12364 __nf_ct_ext_add_length 3 12364 NULL
96078 +xfs_iext_inline_to_direct_12384 xfs_iext_inline_to_direct 2 12384 NULL
96079 +btrfs_file_extent_ram_bytes_12391 btrfs_file_extent_ram_bytes 0 12391 NULL
96080 +ieee80211_if_read_num_mcast_sta_12419 ieee80211_if_read_num_mcast_sta 3 12419 NULL
96081 +skb_do_copy_data_nocache_12465 skb_do_copy_data_nocache 5 12465 NULL
96082 +qla4_82xx_pci_mem_write_direct_12479 qla4_82xx_pci_mem_write_direct 2 12479 NULL
96083 +x25_sendmsg_12487 x25_sendmsg 4 12487 NULL
96084 +rtllib_auth_challenge_12493 rtllib_auth_challenge 3 12493 NULL
96085 +fnic_trace_ctrl_read_12497 fnic_trace_ctrl_read 3 12497 NULL
96086 +nfs_readdir_make_qstr_12509 nfs_readdir_make_qstr 3 12509 NULL
96087 +qib_alloc_fast_reg_mr_12526 qib_alloc_fast_reg_mr 2 12526 NULL
96088 +kvm_setup_async_pf_12555 kvm_setup_async_pf 3 12555 NULL
96089 +ib_umem_get_12557 ib_umem_get 2-3 12557 NULL
96090 +hvc_alloc_12579 hvc_alloc 4 12579 NULL
96091 +snd_pcm_plugin_alloc_12580 snd_pcm_plugin_alloc 2 12580 NULL
96092 +macvtap_compat_ioctl_12587 macvtap_compat_ioctl 3 12587 NULL
96093 +pcpu_extend_area_map_12589 pcpu_extend_area_map 2 12589 NULL
96094 +ipv6_get_l4proto_12600 ipv6_get_l4proto 2 12600 NULL
96095 +vhci_put_user_12604 vhci_put_user 4 12604 NULL
96096 +fc_fcp_frame_alloc_12624 fc_fcp_frame_alloc 2 12624 NULL
96097 +pwr_rcvd_awake_bcns_cnt_read_12632 pwr_rcvd_awake_bcns_cnt_read 3 12632 NULL
96098 +ctrl_cdev_compat_ioctl_12634 ctrl_cdev_compat_ioctl 3 12634 NULL
96099 +pn_sendmsg_12640 pn_sendmsg 4 12640 NULL
96100 +wb_create_12651 wb_create 1 12651 NULL
96101 +ocfs2_read_block_12659 ocfs2_read_block 0 12659 NULL
96102 +sel_read_class_12669 sel_read_class 3 12669 NULL nohasharray
96103 +sparse_mem_maps_populate_node_12669 sparse_mem_maps_populate_node 4 12669 &sel_read_class_12669
96104 +ieee80211_if_read_num_buffered_multicast_12716 ieee80211_if_read_num_buffered_multicast 3 12716 NULL
96105 +ivtv_write_12721 ivtv_write 3 12721 NULL
96106 +key_rx_spec_read_12736 key_rx_spec_read 3 12736 NULL
96107 +__videobuf_alloc_cached_12740 __videobuf_alloc_cached 1 12740 NULL
96108 +ieee80211_if_read_dot11MeshMaxRetries_12756 ieee80211_if_read_dot11MeshMaxRetries 3 12756 NULL
96109 +listxattr_12769 listxattr 3 12769 NULL
96110 +sctp_ssnmap_init_12772 sctp_ssnmap_init 2-3 12772 NULL
96111 +ieee80211_rx_mgmt_beacon_12780 ieee80211_rx_mgmt_beacon 3 12780 NULL
96112 +platform_create_bundle_12785 platform_create_bundle 4-6 12785 NULL
96113 +scsi_adjust_queue_depth_12802 scsi_adjust_queue_depth 3 12802 NULL
96114 +xfs_inumbers_fmt_12817 xfs_inumbers_fmt 3 12817 NULL
96115 +readq_12825 readq 0 12825 NULL
96116 +TSS_authhmac_12839 TSS_authhmac 3 12839 NULL
96117 +spidev_sync_12842 spidev_sync 0 12842 NULL nohasharray
96118 +ath6kl_wmi_add_wow_pattern_cmd_12842 ath6kl_wmi_add_wow_pattern_cmd 4 12842 &spidev_sync_12842
96119 +spidev_ioctl_12846 spidev_ioctl 2 12846 NULL
96120 +get_leb_cnt_12892 get_leb_cnt 0-2 12892 NULL
96121 +ocfs2_hamming_encode_block_12904 ocfs2_hamming_encode_block 2 12904 NULL
96122 +get_virtual_node_size_12908 get_virtual_node_size 0 12908 NULL
96123 +rds_pages_in_vec_12922 rds_pages_in_vec 0 12922 NULL
96124 +ci_ll_init_12930 ci_ll_init 3 12930 NULL
96125 +do_inode_permission_12946 do_inode_permission 0 12946 NULL
96126 +bm_status_write_12964 bm_status_write 3 12964 NULL
96127 +_drbd_md_first_sector_12984 _drbd_md_first_sector 0 12984 NULL
96128 +raid56_parity_recover_12987 raid56_parity_recover 5 12987 NULL
96129 +acpi_tb_install_table_12988 acpi_tb_install_table 1 12988 NULL
96130 +TransmitTcb_12989 TransmitTcb 4 12989 NULL
96131 +sk_peek_offset_12991 sk_peek_offset 0 12991 NULL
96132 +subsystem_filter_write_13022 subsystem_filter_write 3 13022 NULL
96133 +generic_segment_checks_13041 generic_segment_checks 0 13041 NULL
96134 +ocfs2_write_begin_13045 ocfs2_write_begin 3-4 13045 NULL
96135 +__dn_setsockopt_13060 __dn_setsockopt 5 13060 NULL
96136 +irq_set_chip_and_handler_13088 irq_set_chip_and_handler 1 13088 NULL
96137 +xattr_getsecurity_13090 xattr_getsecurity 0 13090 NULL
96138 +blk_rq_map_sg_13092 blk_rq_map_sg 0 13092 NULL
96139 +mb_find_next_zero_bit_13100 mb_find_next_zero_bit 2-3 13100 NULL
96140 +ubifs_compat_ioctl_13108 ubifs_compat_ioctl 3 13108 NULL
96141 +snd_rme96_playback_copy_13111 snd_rme96_playback_copy 5 13111 NULL
96142 +xen_allocate_irq_dynamic_13116 xen_allocate_irq_dynamic 0 13116 NULL
96143 +bfad_debugfs_read_13119 bfad_debugfs_read 3 13119 NULL
96144 +blk_update_request_13146 blk_update_request 3 13146 NULL
96145 +caif_stream_recvmsg_13173 caif_stream_recvmsg 4 13173 NULL
96146 +pwr_disable_ps_read_13176 pwr_disable_ps_read 3 13176 NULL
96147 +ucs2_strlen_13178 ucs2_strlen 0 13178 NULL
96148 +dgrp_net_ioctl_13183 dgrp_net_ioctl 2 13183 NULL
96149 +create_trace_uprobe_13184 create_trace_uprobe 1 13184 NULL
96150 +compat_put_ulong_13186 compat_put_ulong 1 13186 NULL
96151 +__cmpxchg64_13187 __cmpxchg64 0 13187 NULL
96152 +comedi_read_13199 comedi_read 3 13199 NULL
96153 +mmc_ext_csd_read_13205 mmc_ext_csd_read 3 13205 NULL
96154 +__nodes_fold_13215 __nodes_fold 4 13215 NULL
96155 +svm_msrpm_offset_13220 svm_msrpm_offset 0-1 13220 NULL
96156 +fnic_trace_ctrl_write_13229 fnic_trace_ctrl_write 3 13229 NULL
96157 +asix_read_cmd_13245 asix_read_cmd 5 13245 NULL
96158 +fw_download_code_13249 fw_download_code 3 13249 NULL nohasharray
96159 +kvm_lapic_enable_pv_eoi_13249 kvm_lapic_enable_pv_eoi 2 13249 &fw_download_code_13249
96160 +init_tid_tabs_13252 init_tid_tabs 2-3-4 13252 NULL
96161 +hostap_80211_get_hdrlen_13255 hostap_80211_get_hdrlen 0 13255 NULL
96162 +bio_integrity_trim_13259 bio_integrity_trim 3 13259 NULL
96163 +c4iw_reg_user_mr_13269 c4iw_reg_user_mr 2-3 13269 NULL
96164 +carl9170_rx_13272 carl9170_rx 3 13272 NULL
96165 +pmcraid_notify_aen_13274 pmcraid_notify_aen 3 13274 NULL
96166 +il4965_stats_flag_13281 il4965_stats_flag 0-3 13281 NULL
96167 +lpfc_idiag_mbxacc_get_setup_13282 lpfc_idiag_mbxacc_get_setup 0 13282 NULL
96168 +platform_device_add_resources_13289 platform_device_add_resources 3 13289 NULL
96169 +i915_drop_caches_write_13308 i915_drop_caches_write 3 13308 NULL
96170 +us122l_ctl_msg_13330 us122l_ctl_msg 8 13330 NULL
96171 +__clone_and_map_data_bio_13334 __clone_and_map_data_bio 4-8 13334 NULL
96172 +kvm_read_nested_guest_page_13337 kvm_read_nested_guest_page 5-2 13337 NULL
96173 +cache_ctr_13364 cache_ctr 2 13364 NULL
96174 +mthca_alloc_mtt_range_13371 mthca_alloc_mtt_range 2 13371 NULL
96175 +iso_sched_alloc_13377 iso_sched_alloc 1 13377 NULL nohasharray
96176 +wep_key_not_found_read_13377 wep_key_not_found_read 3 13377 &iso_sched_alloc_13377
96177 +carl9170_rx_untie_data_13405 carl9170_rx_untie_data 3 13405 NULL
96178 +sky2_receive_13407 sky2_receive 2 13407 NULL
96179 +netxen_alloc_sds_rings_13417 netxen_alloc_sds_rings 2 13417 NULL
96180 +keyring_read_13438 keyring_read 3 13438 NULL
96181 +sctp_setsockopt_peer_primary_addr_13440 sctp_setsockopt_peer_primary_addr 3 13440 NULL nohasharray
96182 +set_tap_pwup_pfs_13440 set_tap_pwup_pfs 3 13440 &sctp_setsockopt_peer_primary_addr_13440
96183 +ath6kl_cfg80211_connect_event_13443 ath6kl_cfg80211_connect_event 8-9-7 13443 NULL
96184 +mthca_buddy_alloc_13454 mthca_buddy_alloc 2 13454 NULL
96185 +ocfs2_align_bytes_to_blocks_13512 ocfs2_align_bytes_to_blocks 2 13512 NULL
96186 +core_status_13515 core_status 4 13515 NULL
96187 +smk_write_mapped_13519 smk_write_mapped 3 13519 NULL
96188 +bm_init_13529 bm_init 2 13529 NULL
96189 +non_atomic_pte_lookup_13540 non_atomic_pte_lookup 2 13540 NULL
96190 +ieee80211_if_read_ap_power_level_13558 ieee80211_if_read_ap_power_level 3 13558 NULL
96191 +ubifs_get_idx_gc_leb_13566 ubifs_get_idx_gc_leb 0 13566 NULL
96192 +sys_madvise_13569 sys_madvise 1 13569 NULL
96193 +read_file_antenna_13574 read_file_antenna 3 13574 NULL
96194 +cache_write_13589 cache_write 3 13589 NULL
96195 +mpt_lan_receive_post_turbo_13592 mpt_lan_receive_post_turbo 2 13592 NULL
96196 +aac_sa_ioremap_13596 aac_sa_ioremap 2 13596 NULL nohasharray
96197 +irias_new_octseq_value_13596 irias_new_octseq_value 2 13596 &aac_sa_ioremap_13596
96198 +usb_dump_interface_descriptor_13603 usb_dump_interface_descriptor 0 13603 NULL
96199 +swap_cgroup_swapon_13614 swap_cgroup_swapon 2 13614 NULL
96200 +wm8994_bulk_write_13615 wm8994_bulk_write 2-3 13615 NULL
96201 +pmcraid_get_minor_13619 pmcraid_get_minor 0 13619 NULL
96202 +iio_device_add_event_sysfs_13627 iio_device_add_event_sysfs 0 13627 NULL
96203 +packet_snd_13634 packet_snd 3 13634 NULL
96204 +blk_msg_write_13655 blk_msg_write 3 13655 NULL
96205 +cache_downcall_13666 cache_downcall 3 13666 NULL
96206 +fw_iso_buffer_alloc_13704 fw_iso_buffer_alloc 2 13704 NULL
96207 +audit_unpack_string_13748 audit_unpack_string 3 13748 NULL
96208 +ufs_dtog_13750 ufs_dtog 0-2 13750 NULL
96209 +ieee802154_alloc_device_13767 ieee802154_alloc_device 1 13767 NULL
96210 +fb_sys_read_13778 fb_sys_read 3 13778 NULL
96211 +ath6kl_mgmt_powersave_ap_13791 ath6kl_mgmt_powersave_ap 6 13791 NULL
96212 +random_read_13815 random_read 3 13815 NULL
96213 +hsi_register_board_info_13820 hsi_register_board_info 2 13820 NULL
96214 +evdev_ioctl_compat_13851 evdev_ioctl_compat 2-3 13851 NULL
96215 +compat_ip_setsockopt_13870 compat_ip_setsockopt 5 13870 NULL nohasharray
96216 +alloc_trace_uprobe_13870 alloc_trace_uprobe 3 13870 &compat_ip_setsockopt_13870
96217 +qp_memcpy_to_queue_13886 qp_memcpy_to_queue 2-5 13886 NULL
96218 +snd_pcm_aio_read_13900 snd_pcm_aio_read 3 13900 NULL
96219 +ext3_xattr_block_get_13936 ext3_xattr_block_get 0 13936 NULL
96220 +ieee80211_if_read_dot11MeshForwarding_13940 ieee80211_if_read_dot11MeshForwarding 3 13940 NULL nohasharray
96221 +ocfs2_xa_value_truncate_13940 ocfs2_xa_value_truncate 2 13940 &ieee80211_if_read_dot11MeshForwarding_13940
96222 +iwl_dbgfs_protection_mode_read_13943 iwl_dbgfs_protection_mode_read 3 13943 NULL
96223 +compat_chaninfo_13945 compat_chaninfo 2 13945 NULL
96224 +ieee80211_if_read_min_discovery_timeout_13946 ieee80211_if_read_min_discovery_timeout 3 13946 NULL
96225 +lpfc_idiag_queacc_read_13950 lpfc_idiag_queacc_read 3 13950 NULL
96226 +snd_pcm_plug_slave_size_13967 snd_pcm_plug_slave_size 0-2 13967 NULL
96227 +com90xx_found_13974 com90xx_found 3 13974 NULL
96228 +qcam_read_13977 qcam_read 3 13977 NULL
96229 +dsp_read_13980 dsp_read 2 13980 NULL
96230 +bm_block_bits_13981 bm_block_bits 0 13981 NULL nohasharray
96231 +dvb_demux_read_13981 dvb_demux_read 3 13981 &bm_block_bits_13981
96232 +btrfs_get_blocks_direct_14016 btrfs_get_blocks_direct 2 14016 NULL
96233 +_rtl92s_firmware_downloadcode_14021 _rtl92s_firmware_downloadcode 3 14021 NULL
96234 +dvb_usercopy_14036 dvb_usercopy 2 14036 NULL
96235 +read_def_modal_eeprom_14041 read_def_modal_eeprom 3 14041 NULL
96236 +ieee80211_if_fmt_aid_14055 ieee80211_if_fmt_aid 3 14055 NULL
96237 +sta_agg_status_read_14058 sta_agg_status_read 3 14058 NULL
96238 +i915_drop_caches_read_14060 i915_drop_caches_read 3 14060 NULL
96239 +do_proc_readlink_14096 do_proc_readlink 3 14096 NULL
96240 +compat_sys_pselect6_14105 compat_sys_pselect6 1 14105 NULL
96241 +nlmsg_len_14115 nlmsg_len 0 14115 NULL
96242 +vfio_fops_compat_ioctl_14130 vfio_fops_compat_ioctl 3 14130 NULL
96243 +ntfs_rl_replace_14136 ntfs_rl_replace 2-4 14136 NULL
96244 +em_canid_change_14150 em_canid_change 3 14150 NULL
96245 +gsm_dlci_data_14155 gsm_dlci_data 3 14155 NULL
96246 +print_input_mask_14168 print_input_mask 3-0 14168 NULL
96247 +ocfs2_xattr_value_truncate_14183 ocfs2_xattr_value_truncate 3 14183 NULL
96248 +alloc_async_14208 alloc_async 1 14208 NULL
96249 +sys_kexec_load_14222 sys_kexec_load 2 14222 NULL
96250 +ieee80211_if_write_uapsd_max_sp_len_14233 ieee80211_if_write_uapsd_max_sp_len 3 14233 NULL
96251 +dma_declare_coherent_memory_14244 dma_declare_coherent_memory 4-2 14244 NULL
96252 +snd_soc_hw_bulk_write_raw_14245 snd_soc_hw_bulk_write_raw 2-4 14245 NULL
96253 +reiserfs_compat_ioctl_14265 reiserfs_compat_ioctl 3 14265 NULL
96254 +ath6kl_connect_event_14267 ath6kl_connect_event 8-9-7 14267 NULL
96255 +add_numbered_child_14273 add_numbered_child 5 14273 NULL
96256 +OS_mem_token_alloc_14276 OS_mem_token_alloc 1 14276 NULL
96257 +snd_seq_oss_readq_new_14283 snd_seq_oss_readq_new 2 14283 NULL
96258 +rr_status_14293 rr_status 5 14293 NULL
96259 +read_default_ldt_14302 read_default_ldt 2 14302 NULL
96260 +oo_objects_14319 oo_objects 0 14319 NULL
96261 +p9_client_zc_rpc_14345 p9_client_zc_rpc 7 14345 NULL
96262 +scsi2int_14358 scsi2int 0 14358 NULL
96263 +snd_pcm_lib_readv_14363 snd_pcm_lib_readv 0-3 14363 NULL
96264 +acpi_get_override_irq_14381 acpi_get_override_irq 1 14381 NULL
96265 +ath6kl_regdump_read_14393 ath6kl_regdump_read 3 14393 NULL
96266 +smk_write_onlycap_14400 smk_write_onlycap 3 14400 NULL
96267 +mtd_concat_create_14416 mtd_concat_create 2 14416 NULL
96268 +get_kcore_size_14425 get_kcore_size 0 14425 NULL
96269 +check_lpt_crc_14442 check_lpt_crc 0 14442 NULL
96270 +block_size_14443 block_size 0 14443 NULL
96271 +ci13xxx_add_device_14456 ci13xxx_add_device 3 14456 NULL
96272 +snd_emu10k1_proc_spdif_status_14457 snd_emu10k1_proc_spdif_status 4-5 14457 NULL
96273 +udplite_getfrag_14479 udplite_getfrag 3-4 14479 NULL
96274 +ieee80211_if_read_dot11MeshGateAnnouncementProtocol_14486 ieee80211_if_read_dot11MeshGateAnnouncementProtocol 3 14486 NULL
96275 +ocfs2_debug_read_14507 ocfs2_debug_read 3 14507 NULL
96276 +dataflash_read_user_otp_14536 dataflash_read_user_otp 2-3 14536 NULL nohasharray
96277 +ep0_write_14536 ep0_write 3 14536 &dataflash_read_user_otp_14536
96278 +picolcd_debug_eeprom_read_14549 picolcd_debug_eeprom_read 3 14549 NULL
96279 +drm_vmalloc_dma_14550 drm_vmalloc_dma 1 14550 NULL
96280 +usb_dump_desc_14553 usb_dump_desc 0 14553 NULL
96281 +qp_host_alloc_queue_14566 qp_host_alloc_queue 1 14566 NULL
96282 +remap_to_origin_then_cache_14583 remap_to_origin_then_cache 3 14583 NULL
96283 +idmap_pipe_downcall_14591 idmap_pipe_downcall 3 14591 NULL
96284 +ceph_osdc_alloc_request_14597 ceph_osdc_alloc_request 3 14597 NULL
96285 +ocfs2_trim_group_14641 ocfs2_trim_group 4-3 14641 NULL
96286 +dbJoin_14644 dbJoin 0 14644 NULL
96287 +profile_replace_14652 profile_replace 3 14652 NULL
96288 +pipeline_enc_tx_stat_fifo_int_read_14680 pipeline_enc_tx_stat_fifo_int_read 3 14680 NULL
96289 +ieee80211_if_fmt_rc_rateidx_mask_2ghz_14683 ieee80211_if_fmt_rc_rateidx_mask_2ghz 3 14683 NULL
96290 +tsi148_master_set_14685 tsi148_master_set 4 14685 NULL
96291 +u_audio_playback_14709 u_audio_playback 3 14709 NULL
96292 +get_bio_block_14714 get_bio_block 0 14714 NULL
96293 +vfd_write_14717 vfd_write 3 14717 NULL
96294 +__blk_end_request_14729 __blk_end_request 3 14729 NULL
96295 +raid1_resize_14740 raid1_resize 2 14740 NULL
96296 +btrfs_inode_extref_name_len_14752 btrfs_inode_extref_name_len 0 14752 NULL
96297 +rx_rx_cmplt_read_14753 rx_rx_cmplt_read 3 14753 NULL
96298 +qla82xx_pci_mem_write_2M_14765 qla82xx_pci_mem_write_2M 2 14765 NULL
96299 +regmap_range_read_file_14775 regmap_range_read_file 3 14775 NULL
96300 +sta_dev_read_14782 sta_dev_read 3 14782 NULL
96301 +ext4_kvmalloc_14796 ext4_kvmalloc 1 14796 NULL
96302 +hpet_readl_14801 hpet_readl 0 14801 NULL nohasharray
96303 +snd_als300_gcr_read_14801 snd_als300_gcr_read 0 14801 &hpet_readl_14801
96304 +bcma_scan_read32_14802 bcma_scan_read32 0 14802 NULL
96305 +__mutex_fastpath_lock_retval_14844 __mutex_fastpath_lock_retval 0 14844 NULL
96306 +mrp_attr_create_14853 mrp_attr_create 3 14853 NULL
96307 +lcd_write_14857 lcd_write 3 14857 NULL nohasharray
96308 +__krealloc_14857 __krealloc 2 14857 &lcd_write_14857
96309 +get_user_cpu_mask_14861 get_user_cpu_mask 2 14861 NULL
96310 +sriov_enable_migration_14889 sriov_enable_migration 2 14889 NULL
96311 +acpi_os_allocate_14892 acpi_os_allocate 1 14892 NULL
96312 +unifi_read_14899 unifi_read 3 14899 NULL
96313 +krealloc_14908 krealloc 2 14908 NULL
96314 +regmap_irq_get_virq_14910 regmap_irq_get_virq 2 14910 NULL
96315 +__arch_hweight64_14923 __arch_hweight64 0 14923 NULL nohasharray
96316 +qp_memcpy_to_queue_iov_14923 qp_memcpy_to_queue_iov 2-5 14923 &__arch_hweight64_14923
96317 +ocfs2_expand_nonsparse_inode_14936 ocfs2_expand_nonsparse_inode 3-4 14936 NULL
96318 +queue_cnt_14951 queue_cnt 0 14951 NULL
96319 +videobuf_read_stream_14956 videobuf_read_stream 3 14956 NULL
96320 +mce_flush_rx_buffer_14976 mce_flush_rx_buffer 2 14976 NULL
96321 +setkey_14987 setkey 3 14987 NULL nohasharray
96322 +gpio_twl4030_write_14987 gpio_twl4030_write 1 14987 &setkey_14987
96323 +vmap_15025 vmap 2 15025 NULL
96324 +blk_integrity_tuple_size_15027 blk_integrity_tuple_size 0 15027 NULL
96325 +irq_get_next_irq_15053 irq_get_next_irq 1 15053 NULL
96326 +cld_pipe_downcall_15058 cld_pipe_downcall 3 15058 NULL
96327 +ieee80211_if_read_uapsd_max_sp_len_15067 ieee80211_if_read_uapsd_max_sp_len 3 15067 NULL
96328 +nfs4_write_cached_acl_15070 nfs4_write_cached_acl 4 15070 NULL
96329 +ntfs_copy_from_user_15072 ntfs_copy_from_user 3-5 15072 NULL
96330 +hex_dump_to_buffer_15121 hex_dump_to_buffer 6 15121 NULL
96331 +start_port_15124 start_port 0 15124 NULL
96332 +memchr_15126 memchr 0 15126 NULL
96333 +ipwireless_ppp_mru_15153 ipwireless_ppp_mru 0 15153 NULL
96334 +self_check_not_bad_15175 self_check_not_bad 0 15175 NULL
96335 +iscsi_create_endpoint_15193 iscsi_create_endpoint 1 15193 NULL
96336 +reserve_resources_15194 reserve_resources 3 15194 NULL
96337 +bfad_debugfs_write_regrd_15218 bfad_debugfs_write_regrd 3 15218 NULL
96338 +il_dbgfs_rx_stats_read_15243 il_dbgfs_rx_stats_read 3 15243 NULL
96339 +compat_raw_ioctl_15290 compat_raw_ioctl 3 15290 NULL
96340 +sys_connect_15291 sys_connect 3 15291 NULL nohasharray
96341 +xlate_dev_mem_ptr_15291 xlate_dev_mem_ptr 1 15291 &sys_connect_15291
96342 +arch_enable_uv_irq_15294 arch_enable_uv_irq 2 15294 NULL
96343 +acpi_ev_create_gpe_block_15297 acpi_ev_create_gpe_block 5 15297 NULL
96344 +tpm_tis_init_15304 tpm_tis_init 2-3 15304 NULL
96345 +fcoe_ctlr_send_keep_alive_15308 fcoe_ctlr_send_keep_alive 3 15308 NULL
96346 +__ocfs2_remove_xattr_range_15330 __ocfs2_remove_xattr_range 4-5-3 15330 NULL
96347 +kovaplus_sysfs_read_15337 kovaplus_sysfs_read 6 15337 NULL
96348 +ioread16_15342 ioread16 0 15342 NULL
96349 +alloc_ring_15345 alloc_ring 2-4 15345 NULL
96350 +acpi_ut_create_string_object_15360 acpi_ut_create_string_object 1 15360 NULL
96351 +graph_depth_read_15371 graph_depth_read 3 15371 NULL
96352 +compat_sys_process_vm_readv_15374 compat_sys_process_vm_readv 3-5 15374 NULL
96353 +fq_codel_zalloc_15378 fq_codel_zalloc 1 15378 NULL
96354 +domain_flush_pages_15379 domain_flush_pages 2-3 15379 NULL
96355 +alloc_fddidev_15382 alloc_fddidev 1 15382 NULL
96356 +btrfs_level_size_15392 btrfs_level_size 0 15392 NULL
96357 +pipeline_csum_to_rx_xfer_swi_read_15403 pipeline_csum_to_rx_xfer_swi_read 3 15403 NULL
96358 +get_modalias_15406 get_modalias 2 15406 NULL
96359 +dm_cache_resize_15422 dm_cache_resize 2 15422 NULL
96360 +__videobuf_copy_to_user_15423 __videobuf_copy_to_user 4 15423 NULL
96361 +tcp_mtu_to_mss_15438 tcp_mtu_to_mss 2 15438 NULL
96362 +hpsa_change_queue_depth_15449 hpsa_change_queue_depth 2 15449 NULL
96363 +memweight_15450 memweight 2 15450 NULL
96364 +vmalloc_15464 vmalloc 1 15464 NULL
96365 +zd_chip_is_zd1211b_15518 zd_chip_is_zd1211b 0 15518 NULL
96366 +da9052_bat_irq_15533 da9052_bat_irq 1 15533 NULL
96367 +p9_check_zc_errors_15534 p9_check_zc_errors 4 15534 NULL
96368 +ql_process_mac_rx_page_15543 ql_process_mac_rx_page 4 15543 NULL
96369 +ieee80211_amsdu_to_8023s_15561 ieee80211_amsdu_to_8023s 5 15561 NULL
96370 +persistent_status_15574 persistent_status 4 15574 NULL
96371 +bnx2fc_process_unsol_compl_15576 bnx2fc_process_unsol_compl 2 15576 NULL
96372 +vme_user_write_15587 vme_user_write 3 15587 NULL
96373 +ocfs2_truncate_rec_15595 ocfs2_truncate_rec 7 15595 NULL
96374 +sx150x_install_irq_chip_15609 sx150x_install_irq_chip 3 15609 NULL
96375 +iommu_device_max_index_15620 iommu_device_max_index 0-3-2-1 15620 NULL nohasharray
96376 +compat_fillonedir_15620 compat_fillonedir 3 15620 &iommu_device_max_index_15620
96377 +set_dis_tap_pfs_15621 set_dis_tap_pfs 3 15621 NULL
96378 +proc_loginuid_read_15631 proc_loginuid_read 3 15631 NULL
96379 +tomoyo_scan_bprm_15642 tomoyo_scan_bprm 2-4 15642 NULL nohasharray
96380 +sk_memory_allocated_add_15642 sk_memory_allocated_add 2 15642 &tomoyo_scan_bprm_15642 nohasharray
96381 +pipeline_hs_tx_stat_fifo_int_read_15642 pipeline_hs_tx_stat_fifo_int_read 3 15642 &sk_memory_allocated_add_15642
96382 +fs_path_add_15648 fs_path_add 3 15648 NULL
96383 +xsd_read_15653 xsd_read 3 15653 NULL
96384 +compat_sys_fcntl_15654 compat_sys_fcntl 3 15654 NULL
96385 +unix_bind_15668 unix_bind 3 15668 NULL
96386 +dm_read_15674 dm_read 3 15674 NULL
96387 +pstore_mkfile_15675 pstore_mkfile 6 15675 NULL
96388 +uf_sme_queue_message_15697 uf_sme_queue_message 3 15697 NULL
96389 +ocfs2_split_tree_15716 ocfs2_split_tree 5 15716 NULL
96390 +HiSax_readstatus_15752 HiSax_readstatus 2 15752 NULL
96391 +bitmap_search_next_usable_block_15762 bitmap_search_next_usable_block 3-1 15762 NULL
96392 +do_test_15766 do_test 1 15766 NULL
96393 +set_std_nic_pfs_15792 set_std_nic_pfs 3 15792 NULL
96394 +smk_read_direct_15803 smk_read_direct 3 15803 NULL
96395 +snd_pcm_ioctl_compat_15804 snd_pcm_ioctl_compat 3 15804 NULL
96396 +gx1_read_conf_reg_15817 gx1_read_conf_reg 0 15817 NULL nohasharray
96397 +nameseq_list_15817 nameseq_list 3 15817 &gx1_read_conf_reg_15817 nohasharray
96398 +gnttab_expand_15817 gnttab_expand 1 15817 &nameseq_list_15817
96399 +afs_proc_rootcell_write_15822 afs_proc_rootcell_write 3 15822 NULL
96400 +brcmf_sdbrcm_died_dump_15841 brcmf_sdbrcm_died_dump 3 15841 NULL
96401 +table_size_15851 table_size 0-1-2 15851 NULL
96402 +ubi_io_write_15870 ubi_io_write 5-4 15870 NULL nohasharray
96403 +media_entity_init_15870 media_entity_init 2-4 15870 &ubi_io_write_15870
96404 +__mptctl_ioctl_15875 __mptctl_ioctl 2 15875 NULL
96405 +nfs_map_group_to_gid_15892 nfs_map_group_to_gid 3 15892 NULL
96406 +native_read_msr_15905 native_read_msr 0 15905 NULL
96407 +parse_audio_stream_data_15937 parse_audio_stream_data 3 15937 NULL
96408 +power_read_15939 power_read 3 15939 NULL
96409 +lpfc_idiag_drbacc_read_15948 lpfc_idiag_drbacc_read 3 15948 NULL
96410 +snd_pcm_lib_read_transfer_15952 snd_pcm_lib_read_transfer 4-2-5 15952 NULL
96411 +remap_pci_mem_15966 remap_pci_mem 1-2 15966 NULL
96412 +frame_alloc_15981 frame_alloc 4 15981 NULL
96413 +alloc_vm_area_15989 alloc_vm_area 1 15989 NULL
96414 +hdpvr_register_videodev_16010 hdpvr_register_videodev 3 16010 NULL
96415 +viafb_vt1636_proc_write_16018 viafb_vt1636_proc_write 3 16018 NULL
96416 +got_frame_16028 got_frame 2 16028 NULL
96417 +read_file_spectral_period_16057 read_file_spectral_period 3 16057 NULL
96418 +isr_tx_exch_complete_read_16103 isr_tx_exch_complete_read 3 16103 NULL
96419 +dma_tx_requested_read_16110 dma_tx_requested_read 3 16110 NULL nohasharray
96420 +isr_hw_pm_mode_changes_read_16110 isr_hw_pm_mode_changes_read 3 16110 &dma_tx_requested_read_16110
96421 +irq_set_chip_and_handler_name_16111 irq_set_chip_and_handler_name 1 16111 NULL
96422 +snd_dma_pointer_16126 snd_dma_pointer 0-2 16126 NULL
96423 +compat_sys_select_16131 compat_sys_select 1 16131 NULL
96424 +fsm_init_16134 fsm_init 2 16134 NULL
96425 +hysdn_rx_netpkt_16136 hysdn_rx_netpkt 3 16136 NULL
96426 +ext4_xattr_block_get_16148 ext4_xattr_block_get 0 16148 NULL
96427 +bnx2i_get_cid_num_16166 bnx2i_get_cid_num 0 16166 NULL
96428 +mapping_level_16188 mapping_level 2 16188 NULL
96429 +cipso_v4_map_cat_rng_hton_16203 cipso_v4_map_cat_rng_hton 0 16203 NULL
96430 +create_table_16213 create_table 2 16213 NULL
96431 +atomic_read_file_16227 atomic_read_file 3 16227 NULL
96432 +BcmGetSectionValStartOffset_16235 BcmGetSectionValStartOffset 0 16235 NULL
96433 +swiotlb_sync_single_for_device_16247 swiotlb_sync_single_for_device 2 16247 NULL nohasharray
96434 +btrfs_dev_extent_chunk_offset_16247 btrfs_dev_extent_chunk_offset 0 16247 &swiotlb_sync_single_for_device_16247
96435 +mark_written_sectors_16262 mark_written_sectors 2 16262 NULL
96436 +reiserfs_acl_count_16265 reiserfs_acl_count 0-1 16265 NULL
96437 +set_disc_pfs_16270 set_disc_pfs 3 16270 NULL
96438 +mq_force_mapping_16277 mq_force_mapping 2 16277 NULL
96439 +ocfs2_xattr_bucket_value_truncate_16279 ocfs2_xattr_bucket_value_truncate 4 16279 NULL
96440 +drbd_setsockopt_16280 drbd_setsockopt 5 16280 NULL nohasharray
96441 +nand_bch_init_16280 nand_bch_init 3-2 16280 &drbd_setsockopt_16280
96442 +account_16283 account 0-2-4 16283 NULL nohasharray
96443 +mirror_status_16283 mirror_status 5 16283 &account_16283
96444 +retry_instruction_16285 retry_instruction 2 16285 NULL
96445 +stk_allocate_buffers_16291 stk_allocate_buffers 2 16291 NULL
96446 +rsc_mgr_init_16299 rsc_mgr_init 3 16299 NULL
96447 +wb_map_16301 wb_map 2 16301 NULL
96448 +vmw_cursor_update_image_16332 vmw_cursor_update_image 3-4 16332 NULL
96449 +total_ps_buffered_read_16365 total_ps_buffered_read 3 16365 NULL
96450 +iscsi_tcp_conn_setup_16376 iscsi_tcp_conn_setup 2 16376 NULL
96451 +nl80211_send_unprot_deauth_16378 nl80211_send_unprot_deauth 4 16378 NULL
96452 +diva_os_malloc_16406 diva_os_malloc 2 16406 NULL
96453 +ieee80211_if_read_tsf_16420 ieee80211_if_read_tsf 3 16420 NULL
96454 +rxrpc_server_keyring_16431 rxrpc_server_keyring 3 16431 NULL
96455 +netlink_change_ngroups_16457 netlink_change_ngroups 2 16457 NULL
96456 +tracing_readme_read_16493 tracing_readme_read 3 16493 NULL
96457 +snd_interval_max_16529 snd_interval_max 0 16529 NULL
96458 +raid10_resize_16537 raid10_resize 2 16537 NULL
96459 +tcp_manip_pkt_16563 tcp_manip_pkt 4 16563 NULL
96460 +lpfc_debugfs_read_16566 lpfc_debugfs_read 3 16566 NULL
96461 +agp_allocate_memory_wrap_16576 agp_allocate_memory_wrap 1 16576 NULL
96462 +virt_to_scatterlist_16582 virt_to_scatterlist 2 16582 NULL
96463 +palmas_irq_get_virq_16613 palmas_irq_get_virq 2 16613 NULL
96464 +btrfs_get_token_32_16651 btrfs_get_token_32 0 16651 NULL
96465 +mfd_add_devices_16668 mfd_add_devices 4 16668 NULL
96466 +ax88179_write_cmd_async_16671 ax88179_write_cmd_async 5 16671 NULL
96467 +arcmsr_adjust_disk_queue_depth_16756 arcmsr_adjust_disk_queue_depth 2 16756 NULL
96468 +compat_blkdev_driver_ioctl_16769 compat_blkdev_driver_ioctl 4 16769 NULL
96469 +blk_rq_map_user_iov_16772 blk_rq_map_user_iov 5 16772 NULL
96470 +i2o_parm_issue_16790 i2o_parm_issue 0 16790 NULL
96471 +get_server_iovec_16804 get_server_iovec 2 16804 NULL
96472 +tipc_send2name_16809 tipc_send2name 6 16809 NULL
96473 +dm_vcalloc_16814 dm_vcalloc 1-2 16814 NULL
96474 +drm_malloc_ab_16831 drm_malloc_ab 1-2 16831 NULL
96475 +scsi_mode_sense_16835 scsi_mode_sense 5 16835 NULL
96476 +hfsplus_min_io_size_16859 hfsplus_min_io_size 0 16859 NULL
96477 +alloc_idx_lebs_16872 alloc_idx_lebs 2 16872 NULL
96478 +carl9170_debugfs_ampdu_state_read_16873 carl9170_debugfs_ampdu_state_read 3 16873 NULL
96479 +st_write_16874 st_write 3 16874 NULL
96480 +__kfifo_peek_n_16877 __kfifo_peek_n 0 16877 NULL
96481 +idx_to_pfn_16919 idx_to_pfn 0 16919 NULL
96482 +psb_unlocked_ioctl_16926 psb_unlocked_ioctl 2 16926 NULL nohasharray
96483 +snd_gf1_mem_proc_dump_16926 snd_gf1_mem_proc_dump 5 16926 &psb_unlocked_ioctl_16926
96484 +_sp2d_alloc_16944 _sp2d_alloc 1-2-3 16944 NULL
96485 +squashfs_read_table_16945 squashfs_read_table 3 16945 NULL
96486 +cfg80211_send_unprot_disassoc_16951 cfg80211_send_unprot_disassoc 3 16951 NULL
96487 +keyctl_instantiate_key_iov_16969 keyctl_instantiate_key_iov 3 16969 NULL
96488 +ceph_read_dir_17005 ceph_read_dir 3 17005 NULL
96489 +copy_counters_to_user_17027 copy_counters_to_user 5 17027 NULL
96490 +jffs2_trusted_setxattr_17048 jffs2_trusted_setxattr 4 17048 NULL
96491 +__arch_hweight32_17060 __arch_hweight32 0 17060 NULL
96492 +dvb_dvr_read_17073 dvb_dvr_read 3 17073 NULL
96493 +simple_transaction_read_17076 simple_transaction_read 3 17076 NULL
96494 +__kmalloc_reserve_17080 __kmalloc_reserve 1 17080 NULL
96495 +carl9170_debugfs_mem_usage_read_17084 carl9170_debugfs_mem_usage_read 3 17084 NULL
96496 +mac_address_string_17091 mac_address_string 0 17091 NULL
96497 +entry_length_17093 entry_length 0 17093 NULL
96498 +sys_preadv_17100 sys_preadv 3 17100 NULL
96499 +pvr2_hdw_state_report_17121 pvr2_hdw_state_report 3 17121 NULL
96500 +mwifiex_get_common_rates_17131 mwifiex_get_common_rates 3 17131 NULL
96501 +nouveau_instobj_create__17144 nouveau_instobj_create_ 4 17144 NULL
96502 +sep_read_17161 sep_read 3 17161 NULL
96503 +befs_nls2utf_17163 befs_nls2utf 3 17163 NULL
96504 +tx_tx_start_templates_read_17164 tx_tx_start_templates_read 3 17164 NULL
96505 +UniStrnlen_17169 UniStrnlen 0 17169 NULL
96506 +access_remote_vm_17189 access_remote_vm 0-2-4 17189 NULL
96507 +driver_state_read_17194 driver_state_read 3 17194 NULL nohasharray
96508 +iscsit_find_cmd_from_itt_or_dump_17194 iscsit_find_cmd_from_itt_or_dump 3 17194 &driver_state_read_17194
96509 +dn_recvmsg_17213 dn_recvmsg 4 17213 NULL
96510 +to_oblock_17254 to_oblock 0-1 17254 NULL
96511 +unpack_value_17259 unpack_value 1 17259 NULL
96512 +__be16_to_cpup_17261 __be16_to_cpup 0 17261 NULL
96513 +error_error_frame_cts_nul_flid_read_17262 error_error_frame_cts_nul_flid_read 3 17262 NULL
96514 +alloc_ep_17269 alloc_ep 1 17269 NULL
96515 +pg_read_17276 pg_read 3 17276 NULL
96516 +raw_recvmsg_17277 raw_recvmsg 4 17277 NULL
96517 +hmac_sha256_17278 hmac_sha256 2 17278 NULL
96518 +neigh_hash_grow_17283 neigh_hash_grow 2 17283 NULL
96519 +minstrel_stats_read_17290 minstrel_stats_read 3 17290 NULL
96520 +install_breakpoint_17292 install_breakpoint 4 17292 NULL
96521 +ieee80211_if_fmt_dot11MeshForwarding_17301 ieee80211_if_fmt_dot11MeshForwarding 3 17301 NULL
96522 +skb_pad_17302 skb_pad 2 17302 NULL
96523 +mb_cache_create_17307 mb_cache_create 2 17307 NULL
96524 +gnttab_map_frames_v2_17314 gnttab_map_frames_v2 2 17314 NULL
96525 +ata_host_alloc_pinfo_17325 ata_host_alloc_pinfo 3 17325 NULL
96526 +ieee80211_if_read_dot11MeshHWMPperrMinInterval_17346 ieee80211_if_read_dot11MeshHWMPperrMinInterval 3 17346 NULL
96527 +ath6kl_wmi_send_mgmt_cmd_17347 ath6kl_wmi_send_mgmt_cmd 7 17347 NULL
96528 +_fd_dma_mem_free_17406 _fd_dma_mem_free 1 17406 NULL
96529 +lpfc_debugfs_dif_err_write_17424 lpfc_debugfs_dif_err_write 3 17424 NULL
96530 +sta_connected_time_read_17435 sta_connected_time_read 3 17435 NULL
96531 +nla_get_u32_17455 nla_get_u32 0 17455 NULL
96532 +__ref_totlen_17461 __ref_totlen 0 17461 NULL
96533 +compat_cmd_17465 compat_cmd 2 17465 NULL
96534 +probe_bios_17467 probe_bios 1 17467 NULL
96535 +probe_kernel_write_17481 probe_kernel_write 3 17481 NULL
96536 +__alloc_session_17485 __alloc_session 2-1 17485 NULL
96537 +TSS_rawhmac_17486 TSS_rawhmac 3 17486 NULL
96538 +bitmap_pos_to_ord_17503 bitmap_pos_to_ord 3 17503 NULL
96539 +__copy_to_user_17551 __copy_to_user 0-3 17551 NULL
96540 +copy_from_user_17559 copy_from_user 3 17559 NULL
96541 +acpi_ut_create_package_object_17594 acpi_ut_create_package_object 1 17594 NULL
96542 +neigh_hash_alloc_17595 neigh_hash_alloc 1 17595 NULL
96543 +rts51x_write_mem_17598 rts51x_write_mem 4 17598 NULL
96544 +iwl_dump_nic_event_log_17601 iwl_dump_nic_event_log 0 17601 NULL
96545 +wm8994_gpio_to_irq_17604 wm8994_gpio_to_irq 2 17604 NULL
96546 +osst_execute_17607 osst_execute 7-6 17607 NULL
96547 +ocfs2_mark_extent_written_17615 ocfs2_mark_extent_written 6 17615 NULL
96548 +ieee80211_if_read_dot11MeshHWMPactivePathToRootTimeout_17618 ieee80211_if_read_dot11MeshHWMPactivePathToRootTimeout 3 17618 NULL
96549 +twl4030_set_gpio_direction_17645 twl4030_set_gpio_direction 1 17645 NULL
96550 +packet_setsockopt_17662 packet_setsockopt 5 17662 NULL nohasharray
96551 +ubi_io_read_data_17662 ubi_io_read_data 0 17662 &packet_setsockopt_17662
96552 +pwr_enable_ps_read_17686 pwr_enable_ps_read 3 17686 NULL
96553 +gfn_to_pfn_memslot_17693 gfn_to_pfn_memslot 2 17693 NULL
96554 +__einj_error_trigger_17707 __einj_error_trigger 1 17707 NULL nohasharray
96555 +venus_rename_17707 venus_rename 5-4 17707 &__einj_error_trigger_17707
96556 +exofs_read_lookup_dev_table_17733 exofs_read_lookup_dev_table 3 17733 NULL
96557 +sctpprobe_read_17741 sctpprobe_read 3 17741 NULL
96558 +mark_unsafe_pages_17759 mark_unsafe_pages 0 17759 NULL
96559 +brcmf_usb_attach_17766 brcmf_usb_attach 2-3 17766 NULL
96560 +ubifs_leb_change_17789 ubifs_leb_change 4 17789 NULL
96561 +_snd_pcm_lib_alloc_vmalloc_buffer_17820 _snd_pcm_lib_alloc_vmalloc_buffer 2 17820 NULL
96562 +gnet_stats_copy_app_17821 gnet_stats_copy_app 3 17821 NULL
96563 +cipso_v4_gentag_rbm_17836 cipso_v4_gentag_rbm 0 17836 NULL
96564 +count_leafs_17842 count_leafs 0 17842 NULL
96565 +sisusb_send_bulk_msg_17864 sisusb_send_bulk_msg 3 17864 NULL
96566 +alloc_sja1000dev_17868 alloc_sja1000dev 1 17868 NULL
96567 +ray_cs_essid_proc_write_17875 ray_cs_essid_proc_write 3 17875 NULL
96568 +orinoco_set_key_17878 orinoco_set_key 5-7 17878 NULL
96569 +init_per_cpu_17880 init_per_cpu 1 17880 NULL
96570 +ieee80211_if_fmt_dot11MeshMaxPeerLinks_17883 ieee80211_if_fmt_dot11MeshMaxPeerLinks 3 17883 NULL
96571 +compat_sys_pwritev_17886 compat_sys_pwritev 3 17886 NULL
96572 +ieee80211_if_fmt_dot11MeshHWMPRootMode_17890 ieee80211_if_fmt_dot11MeshHWMPRootMode 3 17890 NULL
96573 +ocfs2_clusters_to_blocks_17896 ocfs2_clusters_to_blocks 0-2 17896 NULL
96574 +recover_head_17904 recover_head 3 17904 NULL
96575 +dccp_feat_register_sp_17914 dccp_feat_register_sp 5 17914 NULL
96576 +xfs_buf_associate_memory_17915 xfs_buf_associate_memory 3 17915 NULL
96577 +srp_iu_pool_alloc_17920 srp_iu_pool_alloc 2 17920 NULL
96578 +scsi_bufflen_17933 scsi_bufflen 0 17933 NULL
96579 +ufs_free_blocks_17963 ufs_free_blocks 2-3 17963 NULL
96580 +calc_nr_buckets_17976 calc_nr_buckets 0 17976 NULL
96581 +smk_write_cipso_17989 smk_write_cipso 3 17989 NULL
96582 +gnttab_max_grant_frames_17993 gnttab_max_grant_frames 0 17993 NULL
96583 +ext4_num_overhead_clusters_18001 ext4_num_overhead_clusters 2 18001 NULL
96584 +pvr2_v4l2_read_18006 pvr2_v4l2_read 3 18006 NULL
96585 +alloc_rx_desc_ring_18016 alloc_rx_desc_ring 2 18016 NULL
96586 +fill_read_18019 fill_read 0 18019 NULL
96587 +o2hb_highest_node_18034 o2hb_highest_node 2 18034 NULL
96588 +cryptd_alloc_instance_18048 cryptd_alloc_instance 2-3 18048 NULL
96589 +find_next_inuse_18051 find_next_inuse 2-3 18051 NULL
96590 +ddebug_proc_write_18055 ddebug_proc_write 3 18055 NULL
96591 +lua_sysfs_read_18062 lua_sysfs_read 6 18062 NULL
96592 +hex_byte_pack_18064 hex_byte_pack 0 18064 NULL
96593 +packet_came_18072 packet_came 3 18072 NULL
96594 +kvm_read_guest_page_18074 kvm_read_guest_page 5-2 18074 NULL
96595 +get_vm_area_18080 get_vm_area 1 18080 NULL
96596 +mpi_alloc_18094 mpi_alloc 1 18094 NULL
96597 +dfs_file_read_18116 dfs_file_read 3 18116 NULL
96598 +svc_getnl_18120 svc_getnl 0 18120 NULL
96599 +paging32_gpte_to_gfn_lvl_18131 paging32_gpte_to_gfn_lvl 0-1-2 18131 NULL
96600 +vmw_surface_dma_size_18132 vmw_surface_dma_size 0 18132 NULL
96601 +selinux_inode_setsecurity_18148 selinux_inode_setsecurity 4 18148 NULL
96602 +_has_tag_18169 _has_tag 2 18169 NULL
96603 +pccard_store_cis_18176 pccard_store_cis 6 18176 NULL
96604 +orinoco_add_extscan_result_18207 orinoco_add_extscan_result 3 18207 NULL
96605 +gsm_control_message_18209 gsm_control_message 4 18209 NULL
96606 +do_ipv6_setsockopt_18215 do_ipv6_setsockopt 5 18215 NULL
96607 +gnttab_alloc_grant_references_18240 gnttab_alloc_grant_references 1 18240 NULL
96608 +snd_ctl_ioctl_compat_18250 snd_ctl_ioctl_compat 3 18250 NULL
96609 +qdisc_class_hash_alloc_18262 qdisc_class_hash_alloc 1 18262 NULL
96610 +gfs2_alloc_sort_buffer_18275 gfs2_alloc_sort_buffer 1 18275 NULL
96611 +alloc_ring_18278 alloc_ring 2-4 18278 NULL
96612 +find_dirty_idx_leb_18280 find_dirty_idx_leb 0 18280 NULL
96613 +nouveau_subdev_create__18281 nouveau_subdev_create_ 7 18281 NULL nohasharray
96614 +bio_phys_segments_18281 bio_phys_segments 0 18281 &nouveau_subdev_create__18281
96615 +ext4_readpages_18283 ext4_readpages 4 18283 NULL
96616 +mmc_send_bus_test_18285 mmc_send_bus_test 4 18285 NULL
96617 +um_idi_write_18293 um_idi_write 3 18293 NULL
96618 +nouveau_disp_create__18305 nouveau_disp_create_ 4-7 18305 NULL
96619 +ip6ip6_err_18308 ip6ip6_err 5 18308 NULL
96620 +vga_r_18310 vga_r 0 18310 NULL
96621 +ecryptfs_send_message_18322 ecryptfs_send_message 2 18322 NULL
96622 +bio_integrity_advance_18324 bio_integrity_advance 2 18324 NULL
96623 +pwr_power_save_off_read_18355 pwr_power_save_off_read 3 18355 NULL
96624 +xlbd_reserve_minors_18365 xlbd_reserve_minors 1-2 18365 NULL
96625 +ep_io_18367 ep_io 0 18367 NULL
96626 +qib_user_sdma_num_pages_18371 qib_user_sdma_num_pages 0 18371 NULL
96627 +__video_register_device_18399 __video_register_device 3 18399 NULL
96628 +adis16136_show_serial_18402 adis16136_show_serial 3 18402 NULL
96629 +crystalhd_user_data_18407 crystalhd_user_data 3 18407 NULL
96630 +usbnet_write_cmd_nopm_18426 usbnet_write_cmd_nopm 7 18426 NULL
96631 +batadv_orig_node_add_if_18433 batadv_orig_node_add_if 2 18433 NULL
96632 +snd_hda_get_connections_18437 snd_hda_get_connections 0 18437 NULL
96633 +fuse_perform_write_18457 fuse_perform_write 4 18457 NULL
96634 +regset_tls_set_18459 regset_tls_set 4 18459 NULL
96635 +dma_alloc_from_contiguous_18466 dma_alloc_from_contiguous 3-2 18466 NULL
96636 +pci_vpd_lrdt_size_18479 pci_vpd_lrdt_size 0 18479 NULL
96637 +udpv6_setsockopt_18487 udpv6_setsockopt 5 18487 NULL
96638 +snd_gus_dram_poke_18525 snd_gus_dram_poke 4 18525 NULL
96639 +nouveau_fifo_channel_create__18530 nouveau_fifo_channel_create_ 5-6-9 18530 NULL
96640 +seq_copy_in_user_18543 seq_copy_in_user 3 18543 NULL
96641 +acpi_register_gsi_ioapic_18550 acpi_register_gsi_ioapic 2 18550 NULL
96642 +sas_change_queue_depth_18555 sas_change_queue_depth 2 18555 NULL
96643 +smk_write_rules_list_18565 smk_write_rules_list 3 18565 NULL
96644 +debug_output_18575 debug_output 3 18575 NULL
96645 +check_lpt_type_18577 check_lpt_type 0 18577 NULL
96646 +__netdev_alloc_skb_18595 __netdev_alloc_skb 2 18595 NULL
96647 +filemap_fdatawait_range_18600 filemap_fdatawait_range 0 18600 NULL
96648 +iowarrior_write_18604 iowarrior_write 3 18604 NULL
96649 +batadv_arp_get_type_18609 batadv_arp_get_type 3 18609 NULL
96650 +from_buffer_18625 from_buffer 3 18625 NULL
96651 +snd_pcm_oss_write3_18657 snd_pcm_oss_write3 0-3 18657 NULL
96652 +ieee80211_if_fmt_rssi_threshold_18664 ieee80211_if_fmt_rssi_threshold 3 18664 NULL
96653 +unmap_page_18665 unmap_page 2-3 18665 NULL
96654 +xfs_iext_insert_18667 xfs_iext_insert 3 18667 NULL
96655 +replay_log_leb_18704 replay_log_leb 3 18704 NULL
96656 +iwl_dbgfs_rx_handlers_read_18708 iwl_dbgfs_rx_handlers_read 3 18708 NULL
96657 +ceph_alloc_page_vector_18710 ceph_alloc_page_vector 1 18710 NULL
96658 +ocfs2_trim_extent_18711 ocfs2_trim_extent 4-3 18711 NULL
96659 +blk_rq_bytes_18715 blk_rq_bytes 0 18715 NULL
96660 +snd_als4k_gcr_read_addr_18741 snd_als4k_gcr_read_addr 0 18741 NULL
96661 +o2hb_debug_create_18744 o2hb_debug_create 4 18744 NULL
96662 +__erst_read_to_erange_from_nvram_18748 __erst_read_to_erange_from_nvram 0 18748 NULL
96663 +wep_packets_read_18751 wep_packets_read 3 18751 NULL
96664 +md_compat_ioctl_18764 md_compat_ioctl 4 18764 NULL
96665 +read_file_dump_nfcal_18766 read_file_dump_nfcal 3 18766 NULL
96666 +ffs_epfile_read_18775 ffs_epfile_read 3 18775 NULL
96667 +alloc_fcdev_18780 alloc_fcdev 1 18780 NULL
96668 +fat_compat_dir_ioctl_18800 fat_compat_dir_ioctl 3 18800 NULL
96669 +ieee80211_auth_challenge_18810 ieee80211_auth_challenge 3 18810 NULL
96670 +madvise_hwpoison_18812 madvise_hwpoison 2 18812 NULL
96671 +setup_ioapic_irq_18813 setup_ioapic_irq 1 18813 NULL
96672 +sys_modify_ldt_18824 sys_modify_ldt 3 18824 NULL
96673 +mtf_test_write_18844 mtf_test_write 3 18844 NULL
96674 +drm_ht_create_18853 drm_ht_create 2 18853 NULL
96675 +sctp_setsockopt_events_18862 sctp_setsockopt_events 3 18862 NULL
96676 +ieee80211_if_read_element_ttl_18869 ieee80211_if_read_element_ttl 3 18869 NULL
96677 +xlog_find_verify_log_record_18870 xlog_find_verify_log_record 2 18870 NULL
96678 +___alloc_bootmem_node_18882 ___alloc_bootmem_node 2-3 18882 NULL
96679 +width_to_agaw_18883 width_to_agaw 0-1 18883 NULL
96680 +ceph_setxattr_18913 ceph_setxattr 4 18913 NULL
96681 +mangle_packet_18920 mangle_packet 7-9 18920 NULL
96682 +snapshot_write_next_18937 snapshot_write_next 0 18937 NULL
96683 +__nla_reserve_18974 __nla_reserve 3 18974 NULL
96684 +gfn_to_pfn_atomic_18981 gfn_to_pfn_atomic 2 18981 NULL
96685 +find_dirtiest_idx_leb_19001 find_dirtiest_idx_leb 0 19001 NULL
96686 +layout_in_gaps_19006 layout_in_gaps 2 19006 NULL
96687 +huge_page_size_19008 huge_page_size 0 19008 NULL
96688 +usbdev_compat_ioctl_19026 usbdev_compat_ioctl 3 19026 NULL
96689 +prepare_highmem_image_19028 prepare_highmem_image 0 19028 NULL
96690 +revalidate_19043 revalidate 2 19043 NULL
96691 +drm_fb_helper_init_19044 drm_fb_helper_init 3-4 19044 NULL
96692 +create_gpadl_header_19064 create_gpadl_header 2 19064 NULL
96693 +ieee80211_key_alloc_19065 ieee80211_key_alloc 3 19065 NULL
96694 +sys_process_vm_readv_19090 sys_process_vm_readv 3-5 19090 NULL nohasharray
96695 +brcmf_usbdev_qinit_19090 brcmf_usbdev_qinit 2 19090 &sys_process_vm_readv_19090
96696 +sta_last_seq_ctrl_read_19106 sta_last_seq_ctrl_read 3 19106 NULL
96697 +cifs_readv_from_socket_19109 cifs_readv_from_socket 3 19109 NULL
96698 +skb_gro_offset_19123 skb_gro_offset 0 19123 NULL
96699 +ext4_inode_table_19125 ext4_inode_table 0 19125 NULL
96700 +snd_als4k_iobase_readl_19136 snd_als4k_iobase_readl 0 19136 NULL
96701 +alloc_irdadev_19140 alloc_irdadev 1 19140 NULL
96702 +sleep_auth_read_19159 sleep_auth_read 3 19159 NULL
96703 +smk_write_access2_19170 smk_write_access2 3 19170 NULL
96704 +iwl_dbgfs_reply_tx_error_read_19205 iwl_dbgfs_reply_tx_error_read 3 19205 NULL
96705 +vmw_unlocked_ioctl_19212 vmw_unlocked_ioctl 2 19212 NULL
96706 +__copy_to_user_inatomic_19214 __copy_to_user_inatomic 3 19214 NULL
96707 +dev_counters_read_19216 dev_counters_read 3 19216 NULL
96708 +wbcir_tx_19219 wbcir_tx 3 19219 NULL
96709 +gsi_to_irq_19220 gsi_to_irq 0-1 19220 NULL
96710 +snd_mask_max_19224 snd_mask_max 0 19224 NULL
96711 +bio_alloc_mddev_19238 bio_alloc_mddev 2 19238 NULL
96712 +sys_fcntl_19267 sys_fcntl 3 19267 NULL
96713 +il_dbgfs_rxon_filter_flags_read_19281 il_dbgfs_rxon_filter_flags_read 3 19281 NULL
96714 +io_mapping_map_wc_19284 io_mapping_map_wc 2 19284 NULL
96715 +qc_capture_19298 qc_capture 3 19298 NULL
96716 +ocfs2_prepare_inode_for_refcount_19303 ocfs2_prepare_inode_for_refcount 3-4 19303 NULL
96717 +event_tx_stuck_read_19305 event_tx_stuck_read 3 19305 NULL
96718 +gfn_to_gpa_19320 gfn_to_gpa 0-1 19320 NULL
96719 +debug_read_19322 debug_read 3 19322 NULL
96720 +cfg80211_inform_bss_19332 cfg80211_inform_bss 8 19332 NULL
96721 +read_zero_19366 read_zero 3 19366 NULL
96722 +interpret_user_input_19393 interpret_user_input 2 19393 NULL
96723 +get_n_events_by_type_19401 get_n_events_by_type 0 19401 NULL
96724 +dvbdmx_write_19423 dvbdmx_write 3 19423 NULL
96725 +__phys_addr_19434 __phys_addr 0 19434 NULL
96726 +xfrm_alg_auth_len_19454 xfrm_alg_auth_len 0 19454 NULL
96727 +hpet_compat_ioctl_19455 hpet_compat_ioctl 3 19455 NULL
96728 +gnet_stats_copy_19458 gnet_stats_copy 4 19458 NULL
96729 +sky2_read16_19475 sky2_read16 0 19475 NULL
96730 +efivar_create_sysfs_entry_19485 efivar_create_sysfs_entry 2 19485 NULL
96731 +ext4_add_new_descs_19509 ext4_add_new_descs 3 19509 NULL
96732 +skb_realloc_headroom_19516 skb_realloc_headroom 2 19516 NULL
96733 +dev_alloc_skb_19517 dev_alloc_skb 1 19517 NULL
96734 +nfc_llcp_build_tlv_19536 nfc_llcp_build_tlv 3 19536 NULL
96735 +gfn_to_index_19558 gfn_to_index 0-1-3-2 19558 NULL
96736 +ocfs2_control_message_19564 ocfs2_control_message 3 19564 NULL
96737 +ieee80211_if_read_tkip_mic_test_19565 ieee80211_if_read_tkip_mic_test 3 19565 NULL nohasharray
96738 +wlcore_hw_get_rx_packet_len_19565 wlcore_hw_get_rx_packet_len 0 19565 &ieee80211_if_read_tkip_mic_test_19565
96739 +nfsd_read_19568 nfsd_read 5 19568 NULL
96740 +cgroup_read_s64_19570 cgroup_read_s64 5 19570 NULL
96741 +bm_status_read_19583 bm_status_read 3 19583 NULL
96742 +batadv_tt_update_orig_19586 batadv_tt_update_orig 4 19586 NULL
96743 +load_xattr_datum_19594 load_xattr_datum 0 19594 NULL
96744 +usbvision_rvmalloc_19655 usbvision_rvmalloc 1 19655 NULL
96745 +LoadBitmap_19658 LoadBitmap 2 19658 NULL
96746 +usbnet_write_cmd_19679 usbnet_write_cmd 7 19679 NULL
96747 +bio_detain_19690 bio_detain 2 19690 NULL
96748 +read_reg_19723 read_reg 0 19723 NULL
96749 +wm8350_block_write_19727 wm8350_block_write 3-2 19727 NULL
96750 +memcpy_toiovecend_19736 memcpy_toiovecend 4-3 19736 NULL
96751 +snd_es1968_get_dma_ptr_19747 snd_es1968_get_dma_ptr 0 19747 NULL
96752 +p9_client_read_19750 p9_client_read 5 19750 NULL
96753 +pnpbios_proc_write_19758 pnpbios_proc_write 3 19758 NULL
96754 +ocfs2_readpages_19759 ocfs2_readpages 4 19759 NULL
96755 +jffs2_acl_from_medium_19762 jffs2_acl_from_medium 2 19762 NULL
96756 +__set_print_fmt_19776 __set_print_fmt 0 19776 NULL
96757 +saa7146_vmalloc_build_pgtable_19780 saa7146_vmalloc_build_pgtable 2 19780 NULL
96758 +irda_setsockopt_19824 irda_setsockopt 5 19824 NULL
96759 +pcpu_next_unpop_19831 pcpu_next_unpop 4 19831 NULL
96760 +vfs_getxattr_19832 vfs_getxattr 0 19832 NULL
96761 +security_context_to_sid_19839 security_context_to_sid 2 19839 NULL
96762 +crypt_alloc_buffer_19846 crypt_alloc_buffer 2 19846 NULL
96763 +cfg80211_mlme_register_mgmt_19852 cfg80211_mlme_register_mgmt 5 19852 NULL
96764 +__nla_put_19857 __nla_put 3 19857 NULL
96765 +ip6gre_err_19869 ip6gre_err 5 19869 NULL
96766 +mrp_request_join_19882 mrp_request_join 4 19882 NULL
96767 +aes_decrypt_interrupt_read_19910 aes_decrypt_interrupt_read 3 19910 NULL
96768 +ps_upsd_max_apturn_read_19918 ps_upsd_max_apturn_read 3 19918 NULL
96769 +cgroup_task_count_19930 cgroup_task_count 0 19930 NULL
96770 +iwl_dbgfs_rx_queue_read_19943 iwl_dbgfs_rx_queue_read 3 19943 NULL
96771 +attach_hdlc_protocol_19986 attach_hdlc_protocol 3 19986 NULL
96772 +diva_um_idi_read_20003 diva_um_idi_read 0 20003 NULL
96773 +split_scan_timeout_read_20029 split_scan_timeout_read 3 20029 NULL
96774 +alloc_ieee80211_20063 alloc_ieee80211 1 20063 NULL
96775 +rawv6_sendmsg_20080 rawv6_sendmsg 4 20080 NULL
96776 +fuse_conn_limit_read_20084 fuse_conn_limit_read 3 20084 NULL
96777 +team_options_register_20091 team_options_register 3 20091 NULL
96778 +qla2x00_adjust_sdev_qdepth_up_20097 qla2x00_adjust_sdev_qdepth_up 2 20097 NULL
96779 +hptiop_adjust_disk_queue_depth_20122 hptiop_adjust_disk_queue_depth 2 20122 NULL
96780 +tomoyo_commit_ok_20167 tomoyo_commit_ok 2 20167 NULL
96781 +read_flush_pipefs_20171 read_flush_pipefs 3 20171 NULL
96782 +wep_addr_key_count_read_20174 wep_addr_key_count_read 3 20174 NULL
96783 +create_trace_probe_20175 create_trace_probe 1 20175 NULL
96784 +crystalhd_map_dio_20181 crystalhd_map_dio 3 20181 NULL
96785 +udf_bitmap_new_block_20214 udf_bitmap_new_block 4 20214 NULL
96786 +pvr2_ctrl_value_to_sym_20229 pvr2_ctrl_value_to_sym 5 20229 NULL
96787 +rose_sendmsg_20249 rose_sendmsg 4 20249 NULL
96788 +tm6000_i2c_send_regs_20250 tm6000_i2c_send_regs 5 20250 NULL
96789 +pcpu_alloc_20255 pcpu_alloc 1-2 20255 NULL
96790 +_rtl92s_get_h2c_cmdlen_20312 _rtl92s_get_h2c_cmdlen 0 20312 NULL
96791 +tx_tx_burst_programmed_read_20320 tx_tx_burst_programmed_read 3 20320 NULL
96792 +snd_cs4281_BA1_read_20323 snd_cs4281_BA1_read 5 20323 NULL
96793 +gfs2_glock_nq_m_20347 gfs2_glock_nq_m 1 20347 NULL
96794 +handle_arr_calc_size_20355 handle_arr_calc_size 0-1 20355 NULL
96795 +qla82xx_pci_mem_read_direct_20368 qla82xx_pci_mem_read_direct 2 20368 NULL
96796 +smk_set_cipso_20379 smk_set_cipso 3 20379 NULL
96797 +u64_to_uptr_20384 u64_to_uptr 1 20384 NULL
96798 +snd_nm256_readl_20394 snd_nm256_readl 0 20394 NULL
96799 +__kfifo_from_user_20399 __kfifo_from_user 3 20399 NULL
96800 +xen_create_contiguous_region_20457 xen_create_contiguous_region 1 20457 NULL
96801 +nfs3_setxattr_20458 nfs3_setxattr 4 20458 NULL
96802 +compat_ipv6_setsockopt_20468 compat_ipv6_setsockopt 5 20468 NULL
96803 +read_buf_20469 read_buf 2 20469 NULL
96804 +btrfs_get_32_20476 btrfs_get_32 0 20476 NULL
96805 +fast_user_write_20494 fast_user_write 5 20494 NULL
96806 +ocfs2_db_frozen_trigger_20503 ocfs2_db_frozen_trigger 4 20503 NULL nohasharray
96807 +hidraw_report_event_20503 hidraw_report_event 3 20503 &ocfs2_db_frozen_trigger_20503
96808 +pcpu_alloc_area_20511 pcpu_alloc_area 0-3 20511 NULL
96809 +pcpu_depopulate_chunk_20517 pcpu_depopulate_chunk 2-3 20517 NULL
96810 +xfs_iext_realloc_direct_20521 xfs_iext_realloc_direct 2 20521 NULL
96811 +drbd_bm_resize_20522 drbd_bm_resize 2 20522 NULL
96812 +amd_create_gatt_pages_20537 amd_create_gatt_pages 1 20537 NULL
96813 +scsi_report_opcode_20551 scsi_report_opcode 3 20551 NULL
96814 +venus_create_20555 venus_create 4 20555 NULL
96815 +btrfs_super_log_root_20565 btrfs_super_log_root 0 20565 NULL
96816 +crypto_ahash_reqsize_20569 crypto_ahash_reqsize 0 20569 NULL
96817 +i915_max_freq_read_20581 i915_max_freq_read 3 20581 NULL
96818 +batadv_tt_append_diff_20588 batadv_tt_append_diff 4 20588 NULL
96819 +lirc_write_20604 lirc_write 3 20604 NULL
96820 +qib_qsfp_write_20614 qib_qsfp_write 0-4-2 20614 NULL
96821 +snd_pcm_oss_prepare_20641 snd_pcm_oss_prepare 0 20641 NULL
96822 +kfifo_copy_to_user_20646 kfifo_copy_to_user 3 20646 NULL
96823 +cpulist_scnprintf_20648 cpulist_scnprintf 0-2 20648 NULL
96824 +oz_add_farewell_20652 oz_add_farewell 5 20652 NULL
96825 +oz_cdev_read_20659 oz_cdev_read 3 20659 NULL
96826 +snd_hdsp_playback_copy_20676 snd_hdsp_playback_copy 5 20676 NULL
96827 +get_user_page_nowait_20682 get_user_page_nowait 3 20682 NULL nohasharray
96828 +dvb_dmxdev_buffer_read_20682 dvb_dmxdev_buffer_read 0-4 20682 &get_user_page_nowait_20682
96829 +cpumask_size_20683 cpumask_size 0 20683 NULL
96830 +btrfs_node_blockptr_20685 btrfs_node_blockptr 0 20685 NULL
96831 +gru_vtop_20689 gru_vtop 2 20689 NULL
96832 +read_file_tgt_int_stats_20697 read_file_tgt_int_stats 3 20697 NULL
96833 +__maestro_read_20700 __maestro_read 0 20700 NULL
96834 +cipso_v4_gentag_rng_20703 cipso_v4_gentag_rng 0 20703 NULL
96835 +pcpu_page_first_chunk_20712 pcpu_page_first_chunk 1 20712 NULL
96836 +ocfs2_read_xattr_bucket_20722 ocfs2_read_xattr_bucket 0 20722 NULL
96837 +security_context_to_sid_force_20724 security_context_to_sid_force 2 20724 NULL
96838 +vring_add_indirect_20737 vring_add_indirect 3-4 20737 NULL
96839 +io_apic_set_pci_routing_20740 io_apic_set_pci_routing 2 20740 NULL
96840 +vol_cdev_direct_write_20751 vol_cdev_direct_write 3 20751 NULL
96841 +ocfs2_align_bytes_to_clusters_20754 ocfs2_align_bytes_to_clusters 2 20754 NULL
96842 +brcmf_p2p_escan_20763 brcmf_p2p_escan 2 20763 NULL
96843 +ubi_io_read_20767 ubi_io_read 0 20767 NULL
96844 +fb_alloc_cmap_gfp_20792 fb_alloc_cmap_gfp 2 20792 NULL
96845 +iommu_range_alloc_20794 iommu_range_alloc 3 20794 NULL
96846 +iwl_dbgfs_rxon_flags_read_20795 iwl_dbgfs_rxon_flags_read 3 20795 NULL
96847 +sys_sendto_20809 sys_sendto 6 20809 NULL
96848 +strndup_user_20819 strndup_user 2 20819 NULL
96849 +calc_layout_20829 calc_layout 3 20829 NULL
96850 +wl1271_format_buffer_20834 wl1271_format_buffer 2 20834 NULL
96851 +uvc_alloc_entity_20836 uvc_alloc_entity 3-4 20836 NULL
96852 +snd_pcm_capture_avail_20867 snd_pcm_capture_avail 0 20867 NULL
96853 +ocfs2_bmap_20874 ocfs2_bmap 2 20874 NULL
96854 +skb_tail_pointer_20878 skb_tail_pointer 0 20878 NULL
96855 +sisusb_send_packet_20891 sisusb_send_packet 2 20891 NULL
96856 +key_icverrors_read_20895 key_icverrors_read 3 20895 NULL
96857 +vfio_msi_enable_20906 vfio_msi_enable 2 20906 NULL
96858 +compat_sys_readv_20911 compat_sys_readv 3 20911 NULL
96859 +htable_bits_20933 htable_bits 0 20933 NULL
96860 +altera_set_ir_post_20948 altera_set_ir_post 2 20948 NULL
96861 +rx_rx_phy_hdr_read_20950 rx_rx_phy_hdr_read 3 20950 NULL
96862 +nfs_map_name_to_uid_20962 nfs_map_name_to_uid 3 20962 NULL
96863 +snd_rme9652_playback_copy_20970 snd_rme9652_playback_copy 5 20970 NULL
96864 +brcmf_tx_frame_20978 brcmf_tx_frame 3 20978 NULL
96865 +alg_setsockopt_20985 alg_setsockopt 5 20985 NULL
96866 +ocfs2_free_clusters_21001 ocfs2_free_clusters 4 21001 NULL
96867 +ceph_osdc_new_request_21017 ceph_osdc_new_request 14-4 21017 NULL
96868 +btrfs_inode_ref_name_len_21024 btrfs_inode_ref_name_len 0 21024 NULL
96869 +rx_defrag_tkip_called_read_21031 rx_defrag_tkip_called_read 3 21031 NULL
96870 +lbs_threshold_read_21046 lbs_threshold_read 5 21046 NULL
96871 +proc_fault_inject_write_21058 proc_fault_inject_write 3 21058 NULL
96872 +event_calibration_read_21083 event_calibration_read 3 21083 NULL
96873 +compat_sock_ioctl_trans_21092 compat_sock_ioctl_trans 4 21092 NULL
96874 +multipath_status_21094 multipath_status 5 21094 NULL
96875 +__cfg80211_send_disassoc_21096 __cfg80211_send_disassoc 3 21096 NULL
96876 +ext2_valid_block_bitmap_21101 ext2_valid_block_bitmap 3 21101 NULL
96877 +ath6kl_send_go_probe_resp_21113 ath6kl_send_go_probe_resp 3 21113 NULL
96878 +bitset_size_in_bytes_21124 bitset_size_in_bytes 0-1 21124 NULL
96879 +i2400m_rx_trace_21127 i2400m_rx_trace 3 21127 NULL
96880 +tps6586x_irq_init_21144 tps6586x_irq_init 3 21144 NULL
96881 +ocfs2_block_check_validate_21149 ocfs2_block_check_validate 2 21149 NULL
96882 +cx18_v4l2_read_21196 cx18_v4l2_read 3 21196 NULL
96883 +ipc_rcu_alloc_21208 ipc_rcu_alloc 1 21208 NULL
96884 +_ocfs2_free_clusters_21220 _ocfs2_free_clusters 4 21220 NULL
96885 +get_numpages_21227 get_numpages 0-1-2 21227 NULL
96886 +input_ff_create_21240 input_ff_create 2 21240 NULL
96887 +cfg80211_notify_new_peer_candidate_21242 cfg80211_notify_new_peer_candidate 4 21242 NULL
96888 +ocfs2_blocks_for_bytes_21268 ocfs2_blocks_for_bytes 0-2 21268 NULL
96889 +ip_vs_icmp_xmit_21269 ip_vs_icmp_xmit 4 21269 NULL
96890 +make_alloc_exact_21279 make_alloc_exact 1-3 21279 NULL
96891 +vmw_gmr2_bind_21305 vmw_gmr2_bind 3 21305 NULL
96892 +do_msg_fill_21307 do_msg_fill 3 21307 NULL
96893 +add_res_range_21310 add_res_range 4 21310 NULL
96894 +get_zeroed_page_21322 get_zeroed_page 0 21322 NULL
96895 +ftrace_profile_read_21327 ftrace_profile_read 3 21327 NULL
96896 +gfs2_ea_get_copy_21353 gfs2_ea_get_copy 0 21353 NULL
96897 +max77693_irq_domain_map_21357 max77693_irq_domain_map 2 21357 NULL
96898 +alloc_orinocodev_21371 alloc_orinocodev 1 21371 NULL
96899 +video_ioctl2_21380 video_ioctl2 2 21380 NULL
96900 +diva_get_driver_dbg_mask_21399 diva_get_driver_dbg_mask 0 21399 NULL
96901 +snd_m3_inw_21406 snd_m3_inw 0 21406 NULL
96902 +snapshot_read_next_21426 snapshot_read_next 0 21426 NULL
96903 +tcp_bound_to_half_wnd_21429 tcp_bound_to_half_wnd 0-2 21429 NULL
96904 +tracing_saved_cmdlines_read_21434 tracing_saved_cmdlines_read 3 21434 NULL
96905 +aggr_size_tx_agg_vs_rate_read_21438 aggr_size_tx_agg_vs_rate_read 3 21438 NULL
96906 +__ertm_hdr_size_21450 __ertm_hdr_size 0 21450 NULL
96907 +concat_writev_21451 concat_writev 3 21451 NULL
96908 +read_file_xmit_21487 read_file_xmit 3 21487 NULL
96909 +mmc_alloc_sg_21504 mmc_alloc_sg 1 21504 NULL
96910 +btrfs_file_aio_write_21520 btrfs_file_aio_write 4 21520 NULL
96911 +il_dbgfs_stations_read_21532 il_dbgfs_stations_read 3 21532 NULL
96912 +cipso_v4_map_cat_enum_hton_21540 cipso_v4_map_cat_enum_hton 0 21540 NULL
96913 +rxrpc_send_data_21553 rxrpc_send_data 5 21553 NULL
96914 +rx_rx_beacon_early_term_read_21559 rx_rx_beacon_early_term_read 3 21559 NULL
96915 +xfs_buf_read_uncached_21585 xfs_buf_read_uncached 3 21585 NULL
96916 +ocfs2_acl_from_xattr_21604 ocfs2_acl_from_xattr 2 21604 NULL
96917 +__jfs_getxattr_21631 __jfs_getxattr 0 21631 NULL
96918 +validate_nnode_21638 validate_nnode 0 21638 NULL
96919 +__irq_alloc_descs_21639 __irq_alloc_descs 2-1-3 21639 NULL
96920 +carl9170_rx_copy_data_21656 carl9170_rx_copy_data 2 21656 NULL
96921 +atalk_sendmsg_21677 atalk_sendmsg 4 21677 NULL
96922 +ocfs2_xattr_get_nolock_21678 ocfs2_xattr_get_nolock 0 21678 NULL
96923 +regmap_register_patch_21681 regmap_register_patch 3 21681 NULL
96924 +rtllib_alloc_txb_21687 rtllib_alloc_txb 1-2 21687 NULL
96925 +evdev_ioctl_handler_21705 evdev_ioctl_handler 2 21705 NULL
96926 +reiserfs_allocate_list_bitmaps_21732 reiserfs_allocate_list_bitmaps 3 21732 NULL
96927 +vm_brk_21739 vm_brk 1 21739 NULL
96928 +__nf_nat_mangle_tcp_packet_21744 __nf_nat_mangle_tcp_packet 8-6 21744 NULL
96929 +mthca_alloc_init_21754 mthca_alloc_init 2 21754 NULL
96930 +gen_pool_add_21776 gen_pool_add 3 21776 NULL
96931 +xfs_da_grow_inode_int_21785 xfs_da_grow_inode_int 3 21785 NULL
96932 +__ioremap_caller_21800 __ioremap_caller 1-2 21800 NULL
96933 +min_odd_21802 min_odd 0 21802 NULL
96934 +dvb_generic_ioctl_21810 dvb_generic_ioctl 2 21810 NULL
96935 +wm8994_request_irq_21822 wm8994_request_irq 2 21822 NULL
96936 +oom_adj_read_21847 oom_adj_read 3 21847 NULL
96937 +acpi_tb_check_xsdt_21862 acpi_tb_check_xsdt 1 21862 NULL
96938 +lpfc_idiag_extacc_avail_get_21865 lpfc_idiag_extacc_avail_get 0-3 21865 NULL
96939 +brcms_debugfs_hardware_read_21867 brcms_debugfs_hardware_read 3 21867 NULL
96940 +sisusbcon_bmove_21873 sisusbcon_bmove 6-5-7 21873 NULL nohasharray
96941 +tcp_cookie_size_check_21873 tcp_cookie_size_check 0-1 21873 &sisusbcon_bmove_21873
96942 +xen_swiotlb_map_page_21886 xen_swiotlb_map_page 3 21886 NULL
96943 +__alloc_reserved_percpu_21895 __alloc_reserved_percpu 1-2 21895 NULL
96944 +rio_destid_first_21900 rio_destid_first 0 21900 NULL
96945 +dbAllocCtl_21911 dbAllocCtl 0 21911 NULL
96946 +qsfp_1_read_21915 qsfp_1_read 3 21915 NULL
96947 +security_mmap_addr_21970 security_mmap_addr 0 21970 NULL
96948 +alloc_ldt_21972 alloc_ldt 2 21972 NULL
96949 +rxpipe_descr_host_int_trig_rx_data_read_22001 rxpipe_descr_host_int_trig_rx_data_read 3 22001 NULL nohasharray
96950 +compat_rw_copy_check_uvector_22001 compat_rw_copy_check_uvector 0-3 22001 &rxpipe_descr_host_int_trig_rx_data_read_22001
96951 +btrfs_get_16_22023 btrfs_get_16 0 22023 NULL
96952 +zd_usb_read_fw_22049 zd_usb_read_fw 4 22049 NULL
96953 +ieee80211_if_fmt_dropped_frames_ttl_22054 ieee80211_if_fmt_dropped_frames_ttl 3 22054 NULL
96954 +btrfs_reloc_clone_csums_22077 btrfs_reloc_clone_csums 2 22077 NULL
96955 +write_opcode_22082 write_opcode 2 22082 NULL
96956 +mem_rw_22085 mem_rw 3 22085 NULL
96957 +is_swbp_at_addr_22089 is_swbp_at_addr 2 22089 NULL
96958 +lowpan_fragment_xmit_22095 lowpan_fragment_xmit 3-4 22095 NULL
96959 +sys_remap_file_pages_22124 sys_remap_file_pages 1 22124 NULL
96960 +__bitmap_size_22138 __bitmap_size 0 22138 NULL
96961 +compat_insn_22142 compat_insn 2 22142 NULL
96962 +do_tcp_sendpages_22155 do_tcp_sendpages 4 22155 NULL
96963 +__kfifo_alloc_22173 __kfifo_alloc 3 22173 NULL
96964 +fls_22210 fls 0 22210 NULL
96965 +mem_write_22232 mem_write 3 22232 NULL
96966 +p9_virtio_zc_request_22240 p9_virtio_zc_request 6-5 22240 NULL
96967 +atomic64_xchg_22246 atomic64_xchg 0 22246 NULL
96968 +compat_process_vm_rw_22254 compat_process_vm_rw 3-5 22254 NULL
96969 +__btrfs_direct_write_22273 __btrfs_direct_write 4 22273 NULL
96970 +queue_max_sectors_22280 queue_max_sectors 0 22280 NULL
96971 +pci_vpd_srdt_size_22300 pci_vpd_srdt_size 0 22300 NULL nohasharray
96972 +__tun_chr_ioctl_22300 __tun_chr_ioctl 4 22300 &pci_vpd_srdt_size_22300
96973 +extend_brk_22301 extend_brk 0 22301 NULL
96974 +mesh_table_alloc_22305 mesh_table_alloc 1 22305 NULL
96975 +get_segment_base_22324 get_segment_base 0 22324 NULL
96976 +radix_tree_find_next_bit_22334 radix_tree_find_next_bit 2-3 22334 NULL
96977 +atomic_read_22342 atomic_read 0 22342 NULL
96978 +mlx4_db_alloc_22358 mlx4_db_alloc 3 22358 NULL
96979 +irq_reserve_irq_22360 irq_reserve_irq 1 22360 NULL nohasharray
96980 +memcg_size_22360 memcg_size 0 22360 &irq_reserve_irq_22360
96981 +snd_pcm_alsa_frames_22363 snd_pcm_alsa_frames 2 22363 NULL
96982 +tps6586x_gpio_to_irq_22365 tps6586x_gpio_to_irq 2 22365 NULL
96983 +evdev_ioctl_22371 evdev_ioctl 2 22371 NULL
96984 +alloc_large_system_hash_22391 alloc_large_system_hash 2 22391 NULL
96985 +btmrvl_psmode_read_22395 btmrvl_psmode_read 3 22395 NULL
96986 +crash_shrink_memory_22401 crash_shrink_memory 1 22401 NULL
96987 +zoran_write_22404 zoran_write 3 22404 NULL
96988 +queue_reply_22416 queue_reply 3 22416 NULL
96989 +__set_enter_print_fmt_22431 __set_enter_print_fmt 0 22431 NULL
96990 +queue_max_segments_22441 queue_max_segments 0 22441 NULL
96991 +handle_received_packet_22457 handle_received_packet 3 22457 NULL
96992 +mem_cgroup_read_22461 mem_cgroup_read 5 22461 NULL
96993 +batadv_check_unicast_packet_22468 batadv_check_unicast_packet 3 22468 NULL
96994 +cache_write_procfs_22491 cache_write_procfs 3 22491 NULL
96995 +mp_find_ioapic_pin_22499 mp_find_ioapic_pin 0-2 22499 NULL
96996 +mutex_lock_interruptible_22505 mutex_lock_interruptible 0 22505 NULL
96997 +ip4_addr_string_22511 ip4_addr_string 0 22511 NULL
96998 +swiotlb_tbl_unmap_single_22522 swiotlb_tbl_unmap_single 2 22522 NULL nohasharray
96999 +usb_dump_config_descriptor_22522 usb_dump_config_descriptor 0 22522 &swiotlb_tbl_unmap_single_22522
97000 +pskb_may_pull_22546 pskb_may_pull 2 22546 NULL
97001 +ocfs2_read_extent_block_22550 ocfs2_read_extent_block 0 22550 NULL
97002 +atomic_long_read_unchecked_22551 atomic_long_read_unchecked 0 22551 NULL
97003 +agp_alloc_page_array_22554 agp_alloc_page_array 1 22554 NULL
97004 +dbFindCtl_22587 dbFindCtl 0 22587 NULL
97005 +snapshot_read_22601 snapshot_read 3 22601 NULL
97006 +remove_breakpoint_22628 remove_breakpoint 3 22628 NULL
97007 +sctp_setsockopt_connectx_old_22631 sctp_setsockopt_connectx_old 3 22631 NULL
97008 +ide_core_cp_entry_22636 ide_core_cp_entry 3 22636 NULL
97009 +wl1271_rx_filter_get_fields_size_22638 wl1271_rx_filter_get_fields_size 0 22638 NULL
97010 +pwr_wake_on_timer_exp_read_22640 pwr_wake_on_timer_exp_read 3 22640 NULL
97011 +iwl_dbgfs_calib_disabled_read_22649 iwl_dbgfs_calib_disabled_read 3 22649 NULL
97012 +ubifs_leb_write_22679 ubifs_leb_write 4-5 22679 NULL
97013 +ocfs2_get_block_22687 ocfs2_get_block 2 22687 NULL
97014 +compat_fd_ioctl_22694 compat_fd_ioctl 4 22694 NULL
97015 +map_22700 map 2 22700 NULL
97016 +alloc_libipw_22708 alloc_libipw 1 22708 NULL
97017 +brcmf_sdbrcm_read_control_22721 brcmf_sdbrcm_read_control 3 22721 NULL
97018 +cx18_copy_buf_to_user_22735 cx18_copy_buf_to_user 4 22735 NULL
97019 +ceph_decode_32_22738 ceph_decode_32 0 22738 NULL
97020 +iio_debugfs_write_reg_22742 iio_debugfs_write_reg 3 22742 NULL
97021 +print_frame_22769 print_frame 0 22769 NULL
97022 +ftrace_arch_read_dyn_info_22773 ftrace_arch_read_dyn_info 0 22773 NULL
97023 +compat_blkdev_ioctl_22841 compat_blkdev_ioctl 3 22841 NULL
97024 +clone_bio_integrity_22842 clone_bio_integrity 4 22842 NULL
97025 +read_file_rcstat_22854 read_file_rcstat 3 22854 NULL
97026 +do_atm_iobuf_22857 do_atm_iobuf 3 22857 NULL
97027 +create_attr_set_22861 create_attr_set 1 22861 NULL
97028 +vmw_execbuf_process_22885 vmw_execbuf_process 5 22885 NULL
97029 +usblp_new_writeurb_22894 usblp_new_writeurb 2 22894 NULL
97030 +mdc800_device_read_22896 mdc800_device_read 3 22896 NULL
97031 +policy_emit_config_values_22900 policy_emit_config_values 3 22900 NULL
97032 +pcpu_mem_zalloc_22948 pcpu_mem_zalloc 1 22948 NULL
97033 +alloc_sglist_22960 alloc_sglist 1-2-3 22960 NULL
97034 +caif_seqpkt_sendmsg_22961 caif_seqpkt_sendmsg 4 22961 NULL
97035 +vme_get_size_22964 vme_get_size 0 22964 NULL
97036 +tx_frag_key_not_found_read_22971 tx_frag_key_not_found_read 3 22971 NULL
97037 +page_table_range_init_count_22977 page_table_range_init_count 0 22977 NULL
97038 +usb_get_langid_22983 usb_get_langid 0 22983 NULL
97039 +set_msr_hyperv_22985 set_msr_hyperv 3 22985 NULL
97040 +remote_settings_file_write_22987 remote_settings_file_write 3 22987 NULL
97041 +viafb_dvp0_proc_write_23023 viafb_dvp0_proc_write 3 23023 NULL
97042 +cifs_local_to_utf16_bytes_23025 cifs_local_to_utf16_bytes 0 23025 NULL
97043 +st_status_23032 st_status 5 23032 NULL
97044 +nv50_disp_chan_create__23056 nv50_disp_chan_create_ 5 23056 NULL
97045 +reiserfs_add_entry_23062 reiserfs_add_entry 4 23062 NULL
97046 +kvm_mmu_gva_to_gpa_write_23075 kvm_mmu_gva_to_gpa_write 0 23075 NULL
97047 +vm_map_ram_23078 vm_map_ram 2 23078 NULL nohasharray
97048 +raw_sendmsg_23078 raw_sendmsg 4 23078 &vm_map_ram_23078
97049 +qla4_82xx_pci_mem_read_2M_23081 qla4_82xx_pci_mem_read_2M 2 23081 NULL
97050 +isr_tx_procs_read_23084 isr_tx_procs_read 3 23084 NULL
97051 +lnw_gpio_irq_map_23087 lnw_gpio_irq_map 2 23087 NULL
97052 +rt2x00debug_write_eeprom_23091 rt2x00debug_write_eeprom 3 23091 NULL
97053 +fls_long_23096 fls_long 0 23096 NULL
97054 +ntfs_ucstonls_23097 ntfs_ucstonls 3-5 23097 NULL
97055 +pipe_iov_copy_from_user_23102 pipe_iov_copy_from_user 3 23102 NULL
97056 +mwl8k_cmd_set_beacon_23110 mwl8k_cmd_set_beacon 4 23110 NULL
97057 +nl80211_send_rx_auth_23111 nl80211_send_rx_auth 4 23111 NULL
97058 +__clear_user_23118 __clear_user 0 23118 NULL
97059 +dm_write_async_23120 dm_write_async 3 23120 NULL
97060 +drm_mode_create_tv_properties_23122 drm_mode_create_tv_properties 2 23122 NULL
97061 +ca91cx42_master_set_23146 ca91cx42_master_set 4 23146 NULL
97062 +read_file_ani_23161 read_file_ani 3 23161 NULL
97063 +ioremap_23172 ioremap 1-2 23172 NULL
97064 +usblp_write_23178 usblp_write 3 23178 NULL
97065 +msnd_fifo_alloc_23179 msnd_fifo_alloc 2 23179 NULL
97066 +gss_pipe_downcall_23182 gss_pipe_downcall 3 23182 NULL
97067 +ieee80211_get_mesh_hdrlen_23183 ieee80211_get_mesh_hdrlen 0 23183 NULL
97068 +fix_unclean_leb_23188 fix_unclean_leb 3 23188 NULL
97069 +mpi_alloc_limb_space_23190 mpi_alloc_limb_space 1 23190 NULL
97070 +convert_ip_to_linear_23198 convert_ip_to_linear 0 23198 NULL
97071 +pm80x_free_irq_23210 pm80x_free_irq 2 23210 NULL nohasharray
97072 +compat_rawv6_ioctl_23210 compat_rawv6_ioctl 3 23210 &pm80x_free_irq_23210
97073 +tty_buffer_request_room_23228 tty_buffer_request_room 2 23228 NULL
97074 +xlog_get_bp_23229 xlog_get_bp 2 23229 NULL
97075 +rxrpc_client_sendmsg_23236 rxrpc_client_sendmsg 5 23236 NULL
97076 +__gfn_to_rmap_23240 __gfn_to_rmap 1-2 23240 NULL
97077 +uwb_dev_addr_print_23282 uwb_dev_addr_print 2 23282 NULL
97078 +ipv6_skip_exthdr_23283 ipv6_skip_exthdr 0-2 23283 NULL
97079 +doc_probe_23285 doc_probe 1 23285 NULL
97080 +diva_get_trace_filter_23286 diva_get_trace_filter 0 23286 NULL
97081 +perf_mmap_free_page_23302 perf_mmap_free_page 1 23302 NULL
97082 +i2cdev_write_23310 i2cdev_write 3 23310 NULL
97083 +mc13xxx_get_num_regulators_dt_23344 mc13xxx_get_num_regulators_dt 0 23344 NULL
97084 +page_readlink_23346 page_readlink 3 23346 NULL
97085 +get_dst_timing_23358 get_dst_timing 0 23358 NULL
97086 +fd_setup_write_same_buf_23369 fd_setup_write_same_buf 3 23369 NULL
97087 +iscsi_change_queue_depth_23416 iscsi_change_queue_depth 2 23416 NULL
97088 +vga_mm_r_23419 vga_mm_r 0 23419 NULL
97089 +vzalloc_node_23424 vzalloc_node 1 23424 NULL
97090 +ocfs2_zero_tail_23447 ocfs2_zero_tail 3 23447 NULL
97091 +hidraw_send_report_23449 hidraw_send_report 3 23449 NULL
97092 +linear_conf_23485 linear_conf 2 23485 NULL nohasharray
97093 +divasa_remap_pci_bar_23485 divasa_remap_pci_bar 3-4 23485 &linear_conf_23485
97094 +event_filter_read_23494 event_filter_read 3 23494 NULL
97095 +__gfn_to_hva_many_23508 __gfn_to_hva_many 0-2 23508 NULL
97096 +ima_show_measurements_count_23536 ima_show_measurements_count 3 23536 NULL
97097 +xen_allocate_irq_gsi_23546 xen_allocate_irq_gsi 1-0 23546 NULL
97098 +tcp_current_mss_23552 tcp_current_mss 0 23552 NULL
97099 +dbg_leb_change_23555 dbg_leb_change 4 23555 NULL
97100 +venus_symlink_23570 venus_symlink 4-6 23570 NULL
97101 +iwl_dbgfs_interrupt_read_23574 iwl_dbgfs_interrupt_read 3 23574 NULL
97102 +snd_interval_min_23590 snd_interval_min 0 23590 NULL
97103 +do_mmap_pgoff_23600 do_mmap_pgoff 0 23600 NULL
97104 +_alloc_cdb_cont_23609 _alloc_cdb_cont 2 23609 NULL
97105 +islpci_mgt_transaction_23610 islpci_mgt_transaction 5 23610 NULL
97106 +__i2400mu_send_barker_23652 __i2400mu_send_barker 3 23652 NULL
97107 +ext3_compat_ioctl_23659 ext3_compat_ioctl 3 23659 NULL
97108 +sInW_23663 sInW 0 23663 NULL
97109 +proc_ioctl_compat_23682 proc_ioctl_compat 2 23682 NULL
97110 +nftl_partscan_23688 nftl_partscan 0 23688 NULL
97111 +cx18_read_23699 cx18_read 3 23699 NULL
97112 +mp_config_acpi_gsi_23728 mp_config_acpi_gsi 2 23728 NULL
97113 +pack_sg_list_p_23739 pack_sg_list_p 0-2 23739 NULL
97114 +rx_rx_dropped_frame_read_23748 rx_rx_dropped_frame_read 3 23748 NULL
97115 +__kfifo_max_r_23768 __kfifo_max_r 0-2-1 23768 NULL
97116 +security_inode_getxattr_23781 security_inode_getxattr 0 23781 NULL
97117 +diva_alloc_dma_map_23798 diva_alloc_dma_map 2 23798 NULL
97118 +rx_path_reset_read_23801 rx_path_reset_read 3 23801 NULL
97119 +__earlyonly_bootmem_alloc_23824 __earlyonly_bootmem_alloc 2-3 23824 NULL
97120 +ceph_copy_page_vector_to_user_23829 ceph_copy_page_vector_to_user 3-4 23829 NULL
97121 +xfs_dir2_leaf_getdents_23841 xfs_dir2_leaf_getdents 3 23841 NULL
97122 +pgdat_end_pfn_23842 pgdat_end_pfn 0 23842 NULL
97123 +iwl_dbgfs_nvm_read_23845 iwl_dbgfs_nvm_read 3 23845 NULL
97124 +p54_init_common_23850 p54_init_common 1 23850 NULL
97125 +gart_alloc_coherent_23852 gart_alloc_coherent 2 23852 NULL
97126 +bin_to_hex_dup_23853 bin_to_hex_dup 2 23853 NULL
97127 +ocfs2_xattr_get_clusters_23857 ocfs2_xattr_get_clusters 0 23857 NULL
97128 +ieee80211_if_read_dot11MeshMaxPeerLinks_23878 ieee80211_if_read_dot11MeshMaxPeerLinks 3 23878 NULL
97129 +nes_alloc_resource_23891 nes_alloc_resource 3 23891 NULL
97130 +tipc_snprintf_23893 tipc_snprintf 2 23893 NULL
97131 +add_new_gdb_meta_bg_23911 add_new_gdb_meta_bg 3 23911 NULL nohasharray
97132 +ieee80211_if_read_hw_queues_23911 ieee80211_if_read_hw_queues 3 23911 &add_new_gdb_meta_bg_23911
97133 +f2fs_getxattr_23917 f2fs_getxattr 0 23917 NULL
97134 +ipath_reg_phys_mr_23918 ipath_reg_phys_mr 3 23918 NULL nohasharray
97135 +mpihelp_mul_karatsuba_case_23918 mpihelp_mul_karatsuba_case 5-3 23918 &ipath_reg_phys_mr_23918
97136 +kvm_read_guest_23928 kvm_read_guest 4-2 23928 NULL
97137 +__alloc_skb_23940 __alloc_skb 1 23940 NULL
97138 +uvc_endpoint_max_bpi_23944 uvc_endpoint_max_bpi 0 23944 NULL
97139 +cifs_setxattr_23957 cifs_setxattr 4 23957 NULL
97140 +zd_usb_iowrite16v_async_23984 zd_usb_iowrite16v_async 3 23984 NULL
97141 +cxgb_alloc_mem_24007 cxgb_alloc_mem 1 24007 NULL
97142 +dgrp_send_24028 dgrp_send 0-2 24028 NULL
97143 +ocfs2_mark_extent_refcounted_24035 ocfs2_mark_extent_refcounted 6 24035 NULL
97144 +adis16400_show_serial_number_24037 adis16400_show_serial_number 3 24037 NULL
97145 +afs_cell_alloc_24052 afs_cell_alloc 2 24052 NULL
97146 +blkcipher_copy_iv_24075 blkcipher_copy_iv 3 24075 NULL
97147 +vb2_fop_read_24080 vb2_fop_read 3 24080 NULL
97148 +pipeline_post_proc_swi_read_24108 pipeline_post_proc_swi_read 3 24108 NULL
97149 +request_key_auth_read_24109 request_key_auth_read 3 24109 NULL
97150 +mpu401_read_24126 mpu401_read 3 24126 NULL
97151 +irnet_ctrl_write_24139 irnet_ctrl_write 3 24139 NULL
97152 +trim_bitmaps_24158 trim_bitmaps 3 24158 NULL
97153 +set_discard_24162 set_discard 2 24162 NULL
97154 +adu_read_24177 adu_read 3 24177 NULL
97155 +safe_prepare_write_buffer_24187 safe_prepare_write_buffer 3 24187 NULL
97156 +ieee80211_if_read_dot11MeshHWMPpreqMinInterval_24208 ieee80211_if_read_dot11MeshHWMPpreqMinInterval 3 24208 NULL
97157 +efx_vf_size_24213 efx_vf_size 0 24213 NULL
97158 +tcpprobe_sprint_24222 tcpprobe_sprint 0-2 24222 NULL
97159 +pcpu_embed_first_chunk_24224 pcpu_embed_first_chunk 1-2-3 24224 NULL nohasharray
97160 +mei_amthif_read_24224 mei_amthif_read 4 24224 &pcpu_embed_first_chunk_24224
97161 +pci_num_vf_24235 pci_num_vf 0 24235 NULL
97162 +sel_read_bool_24236 sel_read_bool 3 24236 NULL
97163 +dm_cache_save_hint_24257 dm_cache_save_hint 2 24257 NULL
97164 +em28xx_alloc_urbs_24260 em28xx_alloc_urbs 4-6 24260 NULL
97165 +thin_status_24278 thin_status 5 24278 NULL
97166 +compat_sys_preadv64_24283 compat_sys_preadv64 3 24283 NULL
97167 +msg_size_24288 msg_size 0 24288 NULL
97168 +ext2_free_blocks_24292 ext2_free_blocks 2-3 24292 NULL
97169 +map_page_24298 map_page 3-4 24298 NULL
97170 +btmrvl_pscmd_read_24308 btmrvl_pscmd_read 3 24308 NULL
97171 +ath6kl_add_bss_if_needed_24317 ath6kl_add_bss_if_needed 6 24317 NULL
97172 +ocfs2_direct_IO_get_blocks_24333 ocfs2_direct_IO_get_blocks 2 24333 NULL
97173 +kzalloc_node_24352 kzalloc_node 1 24352 NULL
97174 +qla2x00_handle_queue_full_24365 qla2x00_handle_queue_full 2 24365 NULL
97175 +cfi_read_pri_24366 cfi_read_pri 3 24366 NULL
97176 +btrfs_item_size_nr_24367 btrfs_item_size_nr 0 24367 NULL
97177 +igetword_24373 igetword 0 24373 NULL
97178 +pvr2_v4l2_ioctl_24398 pvr2_v4l2_ioctl 2 24398 NULL nohasharray
97179 +getxattr_24398 getxattr 4 24398 &pvr2_v4l2_ioctl_24398
97180 +blk_update_bidi_request_24415 blk_update_bidi_request 3-4 24415 NULL
97181 +b43_debugfs_read_24425 b43_debugfs_read 3 24425 NULL
97182 +iwl_nvm_read_section_24438 iwl_nvm_read_section 0 24438 NULL
97183 +ixgbe_alloc_q_vector_24439 ixgbe_alloc_q_vector 4-6 24439 NULL
97184 +smk_user_access_24440 smk_user_access 3 24440 NULL
97185 +page_address_24444 page_address 0 24444 NULL
97186 +evdev_do_ioctl_24459 evdev_do_ioctl 2 24459 NULL
97187 +ocfs2_write_cluster_by_desc_24466 ocfs2_write_cluster_by_desc 5-6 24466 NULL
97188 +read_file_spec_scan_ctl_24491 read_file_spec_scan_ctl 3 24491 NULL
97189 +pd_video_read_24510 pd_video_read 3 24510 NULL
97190 +request_key_with_auxdata_24515 request_key_with_auxdata 4 24515 NULL
97191 +xfs_buf_get_map_24522 xfs_buf_get_map 3 24522 NULL
97192 +named_prepare_buf_24532 named_prepare_buf 2 24532 NULL
97193 +do_mpage_readpage_24536 do_mpage_readpage 3 24536 NULL
97194 +write_cache_pages_24562 write_cache_pages 0 24562 NULL
97195 +tsi148_alloc_resource_24563 tsi148_alloc_resource 2 24563 NULL
97196 +udf_compute_nr_groups_24594 udf_compute_nr_groups 0 24594 NULL
97197 +count_preds_24600 count_preds 0 24600 NULL
97198 +sensor_hub_get_physical_device_count_24605 sensor_hub_get_physical_device_count 0 24605 NULL
97199 +kvm_pv_enable_async_pf_24637 kvm_pv_enable_async_pf 2 24637 NULL
97200 +context_alloc_24645 context_alloc 3 24645 NULL
97201 +blk_rq_err_bytes_24650 blk_rq_err_bytes 0 24650 NULL
97202 +unifi_net_data_malloc_24716 unifi_net_data_malloc 3 24716 NULL
97203 +read_fs_24717 read_fs 0 24717 NULL
97204 +simple_attr_read_24738 simple_attr_read 3 24738 NULL
97205 +qla2x00_change_queue_depth_24742 qla2x00_change_queue_depth 2 24742 NULL
97206 +ath_rxbuf_alloc_24745 ath_rxbuf_alloc 2 24745 NULL
97207 +get_dma_residue_24749 get_dma_residue 0 24749 NULL
97208 +kgdb_hex2mem_24755 kgdb_hex2mem 3 24755 NULL
97209 +nfsd4_sanitize_slot_size_24756 nfsd4_sanitize_slot_size 0-1 24756 NULL
97210 +i915_cache_sharing_read_24775 i915_cache_sharing_read 3 24775 NULL
97211 +ocfs2_read_blocks_24777 ocfs2_read_blocks 0 24777 NULL
97212 +skb_make_writable_24783 skb_make_writable 2 24783 NULL
97213 +datablob_hmac_verify_24786 datablob_hmac_verify 4 24786 NULL
97214 +cache_read_24790 cache_read 3 24790 NULL
97215 +unpack_str_24798 unpack_str 0 24798 NULL
97216 +__next_cpu_nr_24805 __next_cpu_nr 1 24805 NULL
97217 +comedi_buf_alloc_24822 comedi_buf_alloc 3 24822 NULL
97218 +snd_als4k_gcr_read_24840 snd_als4k_gcr_read 0 24840 NULL
97219 +snd_pcm_lib_buffer_bytes_24865 snd_pcm_lib_buffer_bytes 0 24865 NULL
97220 +pnp_alloc_24869 pnp_alloc 1 24869 NULL nohasharray
97221 +l2cap_create_basic_pdu_24869 l2cap_create_basic_pdu 3 24869 &pnp_alloc_24869
97222 +setup_buffering_24872 setup_buffering 3 24872 NULL
97223 +bnx2fc_cmd_mgr_alloc_24873 bnx2fc_cmd_mgr_alloc 3-2 24873 NULL
97224 +queues_read_24877 queues_read 3 24877 NULL
97225 +codec_list_read_file_24910 codec_list_read_file 3 24910 NULL
97226 +v4l2_ctrl_new_24927 v4l2_ctrl_new 7 24927 NULL
97227 +next_token_24929 next_token 0 24929 NULL
97228 +uf_create_device_nodes_24948 uf_create_device_nodes 2 24948 NULL
97229 +ocfs2_fiemap_24949 ocfs2_fiemap 3-4 24949 NULL
97230 +packet_sendmsg_24954 packet_sendmsg 4 24954 NULL
97231 +sys_rt_sigpending_24961 sys_rt_sigpending 2 24961 NULL
97232 +ensure_wear_leveling_24971 ensure_wear_leveling 0 24971 NULL
97233 +twl_i2c_write_u8_24976 twl_i2c_write_u8 3 24976 NULL
97234 +nf_nat_sdp_port_24977 nf_nat_sdp_port 7 24977 NULL
97235 +llc_ui_sendmsg_24987 llc_ui_sendmsg 4 24987 NULL
97236 +key_conf_hw_key_idx_read_25003 key_conf_hw_key_idx_read 3 25003 NULL
97237 +il_dbgfs_channels_read_25005 il_dbgfs_channels_read 3 25005 NULL
97238 +ni_660x_num_counters_25031 ni_660x_num_counters 0 25031 NULL
97239 +nfs_dns_resolve_name_25036 nfs_dns_resolve_name 3 25036 NULL
97240 +gs_buf_alloc_25067 gs_buf_alloc 2 25067 NULL
97241 +ceph_osdc_writepages_25085 ceph_osdc_writepages 5 25085 NULL
97242 +snd_rawmidi_kernel_write_25106 snd_rawmidi_kernel_write 3 25106 NULL
97243 +sys_fgetxattr_25166 sys_fgetxattr 4 25166 NULL
97244 +ipath_init_qp_table_25167 ipath_init_qp_table 2 25167 NULL
97245 +sctp_getsockopt_local_addrs_25178 sctp_getsockopt_local_addrs 2 25178 NULL
97246 +ks8851_rdreg32_25187 ks8851_rdreg32 0 25187 NULL
97247 +ocfs2_block_check_compute_25223 ocfs2_block_check_compute 2 25223 NULL
97248 +free_memcg_kmem_pages_25228 free_memcg_kmem_pages 1 25228 NULL
97249 +mon_stat_read_25238 mon_stat_read 3 25238 NULL
97250 +tcf_csum_ipv6_udp_25241 tcf_csum_ipv6_udp 4 25241 NULL
97251 +nilfs_palloc_find_available_slot_25245 nilfs_palloc_find_available_slot 3-5 25245 NULL
97252 +stripe_status_25259 stripe_status 5 25259 NULL
97253 +snd_pcm_start_25273 snd_pcm_start 0 25273 NULL
97254 +crypto_alloc_instance2_25277 crypto_alloc_instance2 3 25277 NULL
97255 +vfs_writev_25278 vfs_writev 3 25278 NULL
97256 +l2tp_session_create_25286 l2tp_session_create 1 25286 NULL
97257 +snd_seq_ioctl_compat_25307 snd_seq_ioctl_compat 3 25307 NULL
97258 +help_25316 help 5 25316 NULL nohasharray
97259 +ath9k_debugfs_read_buf_25316 ath9k_debugfs_read_buf 3 25316 &help_25316
97260 +rng_buffer_size_25348 rng_buffer_size 0 25348 NULL
97261 +rio_destid_next_25368 rio_destid_next 2 25368 NULL nohasharray
97262 +unix_mkname_25368 unix_mkname 0-2 25368 &rio_destid_next_25368
97263 +sel_read_mls_25369 sel_read_mls 3 25369 NULL
97264 +tc3589x_gpio_to_irq_25371 tc3589x_gpio_to_irq 2 25371 NULL
97265 +ebt_buf_add_pad_25413 ebt_buf_add_pad 0 25413 NULL
97266 +dai_list_read_file_25421 dai_list_read_file 3 25421 NULL
97267 +ath6kl_wmi_beginscan_cmd_25462 ath6kl_wmi_beginscan_cmd 8 25462 NULL
97268 +generic_file_buffered_write_25464 generic_file_buffered_write 4 25464 NULL
97269 +crypto_hash_digestsize_25469 crypto_hash_digestsize 0 25469 NULL
97270 +ocfs2_hamming_encode_25501 ocfs2_hamming_encode 3 25501 NULL
97271 +ivtv_buf_copy_from_user_25502 ivtv_buf_copy_from_user 4 25502 NULL
97272 +snd_pcm_plugin_build_25505 snd_pcm_plugin_build 5 25505 NULL
97273 +sb_permission_25523 sb_permission 0 25523 NULL
97274 +ext3_get_inode_loc_25542 ext3_get_inode_loc 0 25542 NULL
97275 +ieee80211_if_read_path_refresh_time_25545 ieee80211_if_read_path_refresh_time 3 25545 NULL
97276 +wimax_addr_scnprint_25548 wimax_addr_scnprint 2 25548 NULL
97277 +ht_print_chan_25556 ht_print_chan 0 25556 NULL
97278 +skb_tailroom_25567 skb_tailroom 0 25567 NULL
97279 +find_extend_vma_25597 find_extend_vma 2 25597 NULL
97280 +__devres_alloc_25598 __devres_alloc 2 25598 NULL
97281 +copy_user_generic_25611 copy_user_generic 0 25611 NULL
97282 +proc_coredump_filter_write_25625 proc_coredump_filter_write 3 25625 NULL
97283 +__get_user_pages_25628 __get_user_pages 0-3-4 25628 NULL nohasharray
97284 +befs_utf2nls_25628 befs_utf2nls 3 25628 &__get_user_pages_25628
97285 +__direct_map_25647 __direct_map 5-6 25647 NULL
97286 +ext2_try_to_allocate_25667 ext2_try_to_allocate 4-2 25667 NULL
97287 +aircable_prepare_write_buffer_25669 aircable_prepare_write_buffer 3 25669 NULL
97288 +sta_inactive_ms_read_25690 sta_inactive_ms_read 3 25690 NULL
97289 +ebitmap_start_positive_25703 ebitmap_start_positive 0 25703 NULL
97290 +rx_filter_mc_filter_read_25712 rx_filter_mc_filter_read 3 25712 NULL
97291 +ibmasm_new_command_25714 ibmasm_new_command 2 25714 NULL
97292 +sel_write_context_25726 sel_write_context 3 25726 NULL nohasharray
97293 +__alloc_bootmem_low_node_25726 __alloc_bootmem_low_node 2-3 25726 &sel_write_context_25726
97294 +mcs_unwrap_fir_25733 mcs_unwrap_fir 3 25733 NULL
97295 +ext2_find_near_25734 ext2_find_near 0 25734 NULL
97296 +__set_clear_dirty_25744 __set_clear_dirty 2 25744 NULL
97297 +cxgbi_device_portmap_create_25747 cxgbi_device_portmap_create 3 25747 NULL
97298 +event_rx_pool_read_25792 event_rx_pool_read 3 25792 NULL
97299 +sg_read_25799 sg_read 3 25799 NULL
97300 +system_enable_read_25815 system_enable_read 3 25815 NULL
97301 +realloc_buffer_25816 realloc_buffer 2 25816 NULL
97302 +mthca_map_user_db_25823 mthca_map_user_db 5 25823 NULL
97303 +pwr_missing_bcns_read_25824 pwr_missing_bcns_read 3 25824 NULL
97304 +parport_read_25855 parport_read 0 25855 NULL
97305 +xfs_dir2_sf_hdr_size_25858 xfs_dir2_sf_hdr_size 0 25858 NULL
97306 +uf_ap_process_data_pdu_25860 uf_ap_process_data_pdu 7 25860 NULL
97307 +ath6kl_regread_read_25884 ath6kl_regread_read 3 25884 NULL
97308 +run_delalloc_nocow_25896 run_delalloc_nocow 3 25896 NULL
97309 +sisusbcon_scroll_area_25899 sisusbcon_scroll_area 4-3 25899 NULL
97310 +lpfc_change_queue_depth_25905 lpfc_change_queue_depth 2 25905 NULL
97311 +do_jffs2_setxattr_25910 do_jffs2_setxattr 5 25910 NULL
97312 +rcname_read_25919 rcname_read 3 25919 NULL
97313 +snd_es1938_capture_copy_25930 snd_es1938_capture_copy 5 25930 NULL
97314 +key_flags_read_25931 key_flags_read 3 25931 NULL
97315 +copy_play_buf_25932 copy_play_buf 3 25932 NULL
97316 +flush_25957 flush 2 25957 NULL
97317 +video_register_device_25971 video_register_device 3 25971 NULL
97318 +udp_setsockopt_25985 udp_setsockopt 5 25985 NULL
97319 +ebt_compat_entry_padsize_26001 ebt_compat_entry_padsize 0 26001 NULL
97320 +lpfc_sli_probe_sriov_nr_virtfn_26004 lpfc_sli_probe_sriov_nr_virtfn 2 26004 NULL
97321 +irq_create_strict_mappings_26025 irq_create_strict_mappings 2-4 26025 NULL
97322 +xfs_xattr_acl_set_26028 xfs_xattr_acl_set 4 26028 NULL
97323 +skb_mac_header_26034 skb_mac_header 0 26034 NULL
97324 +mptscsih_change_queue_depth_26036 mptscsih_change_queue_depth 2 26036 NULL
97325 +selinux_inode_post_setxattr_26037 selinux_inode_post_setxattr 4 26037 NULL
97326 +tun_do_read_26047 tun_do_read 5 26047 NULL
97327 +__alloc_memory_core_early_26053 __alloc_memory_core_early 2-3 26053 NULL
97328 +keyctl_update_key_26061 keyctl_update_key 3 26061 NULL
97329 +rx_rx_wa_density_dropped_frame_read_26095 rx_rx_wa_density_dropped_frame_read 3 26095 NULL
97330 +skb_cow_26138 skb_cow 2 26138 NULL
97331 +usb_dump_device_strings_26146 usb_dump_device_strings 0 26146 NULL
97332 +copy_oldmem_page_26164 copy_oldmem_page 3-1 26164 NULL
97333 +gfs2_xattr_acl_get_26166 gfs2_xattr_acl_get 0 26166 NULL nohasharray
97334 +ath6kl_roam_table_read_26166 ath6kl_roam_table_read 3 26166 &gfs2_xattr_acl_get_26166
97335 +mid_get_vbt_data_r1_26170 mid_get_vbt_data_r1 2 26170 NULL
97336 +disk_devt_26180 disk_devt 0 26180 NULL
97337 +get_registers_26187 get_registers 3 26187 NULL
97338 +cgroup_setxattr_26188 cgroup_setxattr 4 26188 NULL
97339 +ieee80211_if_fmt_dot11MeshTTL_26198 ieee80211_if_fmt_dot11MeshTTL 3 26198 NULL
97340 +xfs_idata_realloc_26199 xfs_idata_realloc 2 26199 NULL
97341 +mce_write_26201 mce_write 3 26201 NULL
97342 +_scsih_change_queue_depth_26230 _scsih_change_queue_depth 2 26230 NULL
97343 +bio_split_26235 bio_split 2 26235 NULL
97344 +crypto_ctxsize_26278 crypto_ctxsize 0 26278 NULL
97345 +wacom_set_device_mode_26280 wacom_set_device_mode 3 26280 NULL
97346 +ext2_find_goal_26306 ext2_find_goal 0 26306 NULL
97347 +snd_pcm_plug_client_channels_buf_26309 snd_pcm_plug_client_channels_buf 0-3 26309 NULL nohasharray
97348 +pax_get_random_long_26309 pax_get_random_long 0 26309 &snd_pcm_plug_client_channels_buf_26309
97349 +pwr_wake_on_host_read_26321 pwr_wake_on_host_read 3 26321 NULL
97350 +ocfs2_duplicate_clusters_by_page_26357 ocfs2_duplicate_clusters_by_page 5 26357 NULL
97351 +cifs_readdata_alloc_26360 cifs_readdata_alloc 1 26360 NULL
97352 +dup_to_netobj_26363 dup_to_netobj 3 26363 NULL
97353 +invalidate_inode_pages2_range_26403 invalidate_inode_pages2_range 0 26403 NULL
97354 +dma_declare_contiguous_26455 dma_declare_contiguous 2 26455 NULL
97355 +ib_alloc_device_26483 ib_alloc_device 1 26483 NULL
97356 +ulong_write_file_26485 ulong_write_file 3 26485 NULL
97357 +dvb_ca_en50221_io_ioctl_26490 dvb_ca_en50221_io_ioctl 2 26490 NULL
97358 +read_vmcore_26501 read_vmcore 3 26501 NULL
97359 +vfio_pci_set_msi_trigger_26507 vfio_pci_set_msi_trigger 3-4 26507 NULL
97360 +iwl_dbgfs_rf_reset_read_26512 iwl_dbgfs_rf_reset_read 3 26512 NULL
97361 +__vhost_add_used_n_26554 __vhost_add_used_n 3 26554 NULL
97362 +ip6_addr_string_26568 ip6_addr_string 0 26568 NULL
97363 +kvm_iommu_put_pages_26571 kvm_iommu_put_pages 2 26571 NULL
97364 +rts51x_read_mem_26577 rts51x_read_mem 4 26577 NULL nohasharray
97365 +batadv_receive_server_sync_packet_26577 batadv_receive_server_sync_packet 3 26577 &rts51x_read_mem_26577
97366 +cirrusfb_get_memsize_26597 cirrusfb_get_memsize 0 26597 NULL
97367 +__unmap_single_26604 __unmap_single 2-3 26604 NULL
97368 +iommu_alloc_26621 iommu_alloc 4 26621 NULL
97369 +pack_value_26625 pack_value 1 26625 NULL
97370 +pwr_fix_tsf_ps_read_26627 pwr_fix_tsf_ps_read 3 26627 NULL
97371 +irq_alloc_generic_chip_26650 irq_alloc_generic_chip 2 26650 NULL nohasharray
97372 +inb_p_26650 inb_p 0 26650 &irq_alloc_generic_chip_26650
97373 +cipso_v4_map_cat_rbm_hton_26680 cipso_v4_map_cat_rbm_hton 0 26680 NULL
97374 +__alloc_pred_stack_26687 __alloc_pred_stack 2 26687 NULL
97375 +rtllib_authentication_req_26713 rtllib_authentication_req 3 26713 NULL
97376 +aty_ld_le32_26720 aty_ld_le32 0 26720 NULL
97377 +nouveau_namedb_create__26732 nouveau_namedb_create_ 7 26732 NULL
97378 +pipeline_tcp_rx_stat_fifo_int_read_26745 pipeline_tcp_rx_stat_fifo_int_read 3 26745 NULL
97379 +srp_ring_alloc_26760 srp_ring_alloc 2 26760 NULL
97380 +snd_hda_get_raw_connections_26762 snd_hda_get_raw_connections 0 26762 NULL
97381 +qlcnic_alloc_sds_rings_26795 qlcnic_alloc_sds_rings 2 26795 NULL
97382 +cipso_v4_genopt_26812 cipso_v4_genopt 0 26812 NULL
97383 +iwl_trans_read_mem32_26825 iwl_trans_read_mem32 0 26825 NULL
97384 +smk_write_load_26829 smk_write_load 3 26829 NULL
97385 +sizeof_pwm_leds_priv_26830 sizeof_pwm_leds_priv 0-1 26830 NULL
97386 +slgt_compat_ioctl_26834 slgt_compat_ioctl 3 26834 NULL
97387 +__nodes_onto_26838 __nodes_onto 4 26838 NULL
97388 +scnprint_id_26842 scnprint_id 3 26842 NULL
97389 +ecryptfs_miscdev_write_26847 ecryptfs_miscdev_write 3 26847 NULL
97390 +netxen_nic_hw_read_wx_128M_26858 netxen_nic_hw_read_wx_128M 2 26858 NULL
97391 +svc_print_xprts_26881 svc_print_xprts 0 26881 NULL
97392 +ext2_compat_ioctl_26883 ext2_compat_ioctl 3 26883 NULL
97393 +slhc_uncompress_26905 slhc_uncompress 0-3 26905 NULL
97394 +x25_asy_change_mtu_26928 x25_asy_change_mtu 2 26928 NULL
97395 +compat_mtw_from_user_26932 compat_mtw_from_user 0 26932 NULL
97396 +scsi_tgt_copy_sense_26933 scsi_tgt_copy_sense 3 26933 NULL
97397 +pwr_ps_enter_read_26935 pwr_ps_enter_read 3 26935 NULL nohasharray
97398 +sctp_setsockopt_adaptation_layer_26935 sctp_setsockopt_adaptation_layer 3 26935 &pwr_ps_enter_read_26935
97399 +carl9170_handle_mpdu_26940 carl9170_handle_mpdu 3 26940 NULL nohasharray
97400 +create_bm_block_list_26940 create_bm_block_list 0 26940 &carl9170_handle_mpdu_26940
97401 +hecubafb_write_26942 hecubafb_write 3 26942 NULL
97402 +extract_entropy_user_26952 extract_entropy_user 3 26952 NULL nohasharray
97403 +do_trimming_26952 do_trimming 3 26952 &extract_entropy_user_26952
97404 +pcf857x_irq_domain_map_26998 pcf857x_irq_domain_map 2 26998 NULL
97405 +swiotlb_bounce_27046 swiotlb_bounce 2-1 27046 NULL
97406 +ufs_alloc_fragments_27059 ufs_alloc_fragments 3-0-2 27059 NULL
97407 +__videobuf_alloc_vb_27062 __videobuf_alloc_vb 1 27062 NULL
97408 +snd_pcm_lib_period_bytes_27071 snd_pcm_lib_period_bytes 0 27071 NULL
97409 +paravirt_read_msr_27077 paravirt_read_msr 0 27077 NULL
97410 +alloc_fdmem_27083 alloc_fdmem 1 27083 NULL
97411 +find_first_bit_27088 find_first_bit 0-2 27088 NULL
97412 +btmrvl_hscmd_write_27089 btmrvl_hscmd_write 3 27089 NULL
97413 +nes_reg_user_mr_27106 nes_reg_user_mr 2-3 27106 NULL
97414 +__devcgroup_inode_permission_27108 __devcgroup_inode_permission 0 27108 NULL
97415 +get_kernel_page_27133 get_kernel_page 0 27133 NULL
97416 +drbd_get_capacity_27141 drbd_get_capacity 0 27141 NULL
97417 +pms_capture_27142 pms_capture 4 27142 NULL
97418 +btmrvl_hscfgcmd_write_27143 btmrvl_hscfgcmd_write 3 27143 NULL
97419 +snd_compr_calc_avail_27165 snd_compr_calc_avail 0 27165 NULL
97420 +i2400m_net_rx_27170 i2400m_net_rx 5 27170 NULL
97421 +ieee80211_if_read_rc_rateidx_mask_5ghz_27183 ieee80211_if_read_rc_rateidx_mask_5ghz 3 27183 NULL
97422 +mmc_blk_compat_ioctl_27194 mmc_blk_compat_ioctl 4 27194 NULL
97423 +dbAllocAG_27228 dbAllocAG 0 27228 NULL
97424 +rxrpc_request_key_27235 rxrpc_request_key 3 27235 NULL
97425 +cfpkt_add_trail_27260 cfpkt_add_trail 3 27260 NULL
97426 +__dma_map_cont_27289 __dma_map_cont 5 27289 NULL
97427 +hpi_read_reg_27302 hpi_read_reg 0 27302 NULL
97428 +copy_from_buf_27308 copy_from_buf 4-2 27308 NULL
97429 +ath6kl_wmi_test_cmd_27312 ath6kl_wmi_test_cmd 3 27312 NULL
97430 +ocfs2_blocks_to_clusters_27327 ocfs2_blocks_to_clusters 0-2 27327 NULL
97431 +snd_pcm_oss_write2_27332 snd_pcm_oss_write2 3-0 27332 NULL
97432 +afs_cell_create_27346 afs_cell_create 2 27346 NULL
97433 +pcbit_stat_27364 pcbit_stat 2 27364 NULL
97434 +init_memory_mapping_27395 init_memory_mapping 0 27395 NULL
97435 +phys_pte_init_27411 phys_pte_init 0-3-2 27411 NULL
97436 +ib_dma_map_sg_27413 ib_dma_map_sg 0 27413 NULL
97437 +acpi_os_get_root_pointer_27416 acpi_os_get_root_pointer 0 27416 NULL nohasharray
97438 +ieee80211_if_read_smps_27416 ieee80211_if_read_smps 3 27416 &acpi_os_get_root_pointer_27416
97439 +pack_sg_list_27425 pack_sg_list 0-2 27425 NULL
97440 +v4l2_ctrl_new_std_menu_items_27487 v4l2_ctrl_new_std_menu_items 4 27487 NULL
97441 +set_tpl_pfs_27490 set_tpl_pfs 3 27490 NULL
97442 +hcd_buffer_alloc_27495 hcd_buffer_alloc 2 27495 NULL
97443 +qib_create_cq_27497 qib_create_cq 2 27497 NULL
97444 +ip_set_get_h32_27498 ip_set_get_h32 0 27498 NULL
97445 +btrfs_get_64_27499 btrfs_get_64 0 27499 NULL
97446 +__usbnet_write_cmd_27500 __usbnet_write_cmd 7 27500 NULL
97447 +garmin_read_process_27509 garmin_read_process 3 27509 NULL
97448 +ib_copy_to_udata_27525 ib_copy_to_udata 3 27525 NULL
97449 +snd_sonicvibes_getdmaa_27552 snd_sonicvibes_getdmaa 0 27552 NULL
97450 +libipw_alloc_txb_27579 libipw_alloc_txb 1-2-3 27579 NULL
97451 +read_flush_procfs_27642 read_flush_procfs 3 27642 NULL nohasharray
97452 +nl80211_send_connect_result_27642 nl80211_send_connect_result 5-7 27642 &read_flush_procfs_27642 nohasharray
97453 +ocfs2_xattr_ibody_get_27642 ocfs2_xattr_ibody_get 0 27642 &nl80211_send_connect_result_27642
97454 +add_new_gdb_27643 add_new_gdb 3 27643 NULL
97455 +qnx6_readpages_27657 qnx6_readpages 4 27657 NULL
97456 +cdrom_read_cdda_old_27664 cdrom_read_cdda_old 4 27664 NULL
97457 +set_bypass_pwoff_pfs_27669 set_bypass_pwoff_pfs 3 27669 NULL
97458 +qword_get_27670 qword_get 0 27670 NULL
97459 +ocfs2_extend_dir_27695 ocfs2_extend_dir 4 27695 NULL
97460 +fs_path_add_from_extent_buffer_27702 fs_path_add_from_extent_buffer 4 27702 NULL
97461 +evm_write_key_27715 evm_write_key 3 27715 NULL
97462 +ieee80211_if_fmt_dot11MeshGateAnnouncementProtocol_27722 ieee80211_if_fmt_dot11MeshGateAnnouncementProtocol 3 27722 NULL
97463 +reg_w_buf_27724 reg_w_buf 3 27724 NULL
97464 +xfs_dir2_block_sfsize_27727 xfs_dir2_block_sfsize 0 27727 NULL
97465 +a4t_cs_init_27734 a4t_cs_init 3 27734 NULL
97466 +kcalloc_27770 kcalloc 1-2 27770 NULL
97467 +twl4030_set_gpio_dataout_27792 twl4030_set_gpio_dataout 1 27792 NULL
97468 +DivaSTraceGetMemotyRequirement_27797 DivaSTraceGetMemotyRequirement 0-1 27797 NULL
97469 +ttm_object_file_init_27804 ttm_object_file_init 2 27804 NULL
97470 +mpihelp_mul_27805 mpihelp_mul 5-3 27805 NULL
97471 +fwtty_buffer_rx_27821 fwtty_buffer_rx 3 27821 NULL
97472 +init_header_complete_27833 init_header_complete 0 27833 NULL nohasharray
97473 +sys_listxattr_27833 sys_listxattr 3 27833 &init_header_complete_27833
97474 +read_profile_27859 read_profile 3 27859 NULL
97475 +sky2_pci_read16_27863 sky2_pci_read16 0 27863 NULL
97476 +ieee80211_if_read_dot11MeshHWMProotInterval_27873 ieee80211_if_read_dot11MeshHWMProotInterval 3 27873 NULL
97477 +unix_seqpacket_sendmsg_27893 unix_seqpacket_sendmsg 4 27893 NULL
97478 +gluebi_write_27905 gluebi_write 3 27905 NULL
97479 +bm_find_next_27929 bm_find_next 2 27929 NULL
97480 +tracing_clock_write_27961 tracing_clock_write 3 27961 NULL
97481 +tipc_media_addr_printf_27971 tipc_media_addr_printf 2 27971 NULL
97482 +mic_rx_pkts_read_27972 mic_rx_pkts_read 3 27972 NULL
97483 +f2fs_bio_alloc_27983 f2fs_bio_alloc 2 27983 NULL
97484 +edt_ft5x06_debugfs_raw_data_read_28002 edt_ft5x06_debugfs_raw_data_read 3 28002 NULL
97485 +snd_rawmidi_write_28008 snd_rawmidi_write 3 28008 NULL
97486 +serial8250_port_size_28019 serial8250_port_size 0 28019 NULL
97487 +sctp_setsockopt_maxburst_28041 sctp_setsockopt_maxburst 3 28041 NULL
97488 +rts51x_xd_rw_28046 rts51x_xd_rw 3-4 28046 NULL
97489 +cx231xx_init_vbi_isoc_28053 cx231xx_init_vbi_isoc 3-2 28053 NULL
97490 +pool_status_28055 pool_status 5 28055 NULL
97491 +lpfc_idiag_mbxacc_read_28061 lpfc_idiag_mbxacc_read 3 28061 NULL
97492 +tx_frag_bad_mblk_num_read_28064 tx_frag_bad_mblk_num_read 3 28064 NULL
97493 +ext4_read_block_bitmap_nowait_28078 ext4_read_block_bitmap_nowait 2 28078 NULL
97494 +GetRecvByte_28082 GetRecvByte 0 28082 NULL
97495 +platform_get_irq_28088 platform_get_irq 0 28088 NULL
97496 +gdth_init_isa_28091 gdth_init_isa 1 28091 NULL
97497 +mmc_test_alloc_mem_28102 mmc_test_alloc_mem 3-2 28102 NULL
97498 +rx_defrag_need_defrag_read_28117 rx_defrag_need_defrag_read 3 28117 NULL
97499 +vgacon_adjust_height_28124 vgacon_adjust_height 2 28124 NULL
97500 +video_read_28148 video_read 3 28148 NULL
97501 +snd_midi_channel_alloc_set_28153 snd_midi_channel_alloc_set 1 28153 NULL
97502 +stats_dot11FCSErrorCount_read_28154 stats_dot11FCSErrorCount_read 3 28154 NULL
97503 +vread_28173 vread 0 28173 NULL
97504 +macvtap_get_user_28185 macvtap_get_user 4 28185 NULL
97505 +d_path_28198 d_path 0 28198 NULL
97506 +nouveau_mxm_create__28200 nouveau_mxm_create_ 4 28200 NULL
97507 +__qp_memcpy_from_queue_28220 __qp_memcpy_from_queue 3-4 28220 NULL
97508 +line6_alloc_sysex_buffer_28225 line6_alloc_sysex_buffer 4 28225 NULL nohasharray
97509 +set_dis_disc_pfs_28225 set_dis_disc_pfs 3 28225 &line6_alloc_sysex_buffer_28225
97510 +amd_nb_num_28228 amd_nb_num 0 28228 NULL
97511 +ext4_validate_block_bitmap_28243 ext4_validate_block_bitmap 3 28243 NULL
97512 +usemap_size_28281 usemap_size 0 28281 NULL
97513 +dma_map_sg_attrs_28289 dma_map_sg_attrs 0 28289 NULL
97514 +acpi_register_gsi_xen_28305 acpi_register_gsi_xen 2 28305 NULL nohasharray
97515 +nouveau_compat_ioctl_28305 nouveau_compat_ioctl 2 28305 &acpi_register_gsi_xen_28305
97516 +__mlock_vma_pages_range_28315 __mlock_vma_pages_range 2-3 28315 NULL
97517 +snd_pcm_oss_read_28317 snd_pcm_oss_read 3 28317 NULL
97518 +bm_entry_write_28338 bm_entry_write 3 28338 NULL
97519 +snapshot_write_28351 snapshot_write 3 28351 NULL
97520 +sys_writev_28384 sys_writev 3 28384 NULL
97521 +dlmfs_file_read_28385 dlmfs_file_read 3 28385 NULL
97522 +tx_frag_cache_miss_read_28394 tx_frag_cache_miss_read 3 28394 NULL
97523 +set_bypass_pfs_28395 set_bypass_pfs 3 28395 NULL
97524 +subdev_ioctl_28417 subdev_ioctl 2 28417 NULL
97525 +__split_large_page_28429 __split_large_page 2 28429 NULL
97526 +mpage_readpages_28436 mpage_readpages 3 28436 NULL
97527 +set_memory_uc_28439 set_memory_uc 1 28439 NULL
97528 +snd_emu10k1_efx_read_28452 snd_emu10k1_efx_read 2 28452 NULL
97529 +key_mic_failures_read_28457 key_mic_failures_read 3 28457 NULL
97530 +alloc_irq_cpu_rmap_28459 alloc_irq_cpu_rmap 1 28459 NULL
97531 +vmw_du_crtc_cursor_set_28479 vmw_du_crtc_cursor_set 4-5 28479 NULL
97532 +ocfs2_backup_super_blkno_28484 ocfs2_backup_super_blkno 0-2 28484 NULL
97533 +max_response_pages_28492 max_response_pages 0 28492 NULL
97534 +clear_discard_28494 clear_discard 2 28494 NULL
97535 +ps_poll_upsd_utilization_read_28519 ps_poll_upsd_utilization_read 3 28519 NULL
97536 +__next_node_28521 __next_node 1 28521 NULL
97537 +i2400m_tx_stats_read_28527 i2400m_tx_stats_read 3 28527 NULL
97538 +sel_read_policycap_28544 sel_read_policycap 3 28544 NULL
97539 +run_delalloc_range_28545 run_delalloc_range 3 28545 NULL nohasharray
97540 +mptctl_getiocinfo_28545 mptctl_getiocinfo 2 28545 &run_delalloc_range_28545
97541 +b43legacy_debugfs_write_28556 b43legacy_debugfs_write 3 28556 NULL
97542 +asymmetric_verify_28567 asymmetric_verify 3 28567 NULL
97543 +phys_pud_init_28574 phys_pud_init 0-3-2 28574 NULL
97544 +cfg80211_send_rx_auth_28580 cfg80211_send_rx_auth 3 28580 NULL
97545 +oxygen_read32_28582 oxygen_read32 0 28582 NULL
97546 +ocfs2_read_dir_block_28587 ocfs2_read_dir_block 2 28587 NULL
97547 +extract_entropy_28604 extract_entropy 3-5 28604 NULL
97548 +kfifo_unused_28612 kfifo_unused 0 28612 NULL
97549 +mp_override_legacy_irq_28618 mp_override_legacy_irq 4 28618 NULL
97550 +snd_nm256_capture_copy_28622 snd_nm256_capture_copy 5-3 28622 NULL
97551 +_set_range_28627 _set_range 3 28627 NULL
97552 +v4l2_compat_ioctl32_28630 v4l2_compat_ioctl32 3 28630 NULL
97553 +setup_usemap_28636 setup_usemap 3-4 28636 NULL
97554 +blk_queue_resize_tags_28670 blk_queue_resize_tags 2 28670 NULL
97555 +__dev_alloc_skb_28681 __dev_alloc_skb 1 28681 NULL
97556 +nl80211_send_new_peer_candidate_28692 nl80211_send_new_peer_candidate 5 28692 NULL nohasharray
97557 +kvm_mmu_get_page_28692 kvm_mmu_get_page 2 28692 &nl80211_send_new_peer_candidate_28692
97558 +drm_plane_init_28731 drm_plane_init 6 28731 NULL
97559 +spi_execute_28736 spi_execute 5 28736 NULL
97560 +snd_pcm_aio_write_28738 snd_pcm_aio_write 3 28738 NULL nohasharray
97561 +phantom_compat_ioctl_28738 phantom_compat_ioctl 3 28738 &snd_pcm_aio_write_28738
97562 +read_file_btcoex_28743 read_file_btcoex 3 28743 NULL
97563 +ath6kl_get_num_reg_28780 ath6kl_get_num_reg 0 28780 NULL
97564 +dvb_net_sec_callback_28786 dvb_net_sec_callback 2 28786 NULL
97565 +sel_write_member_28800 sel_write_member 3 28800 NULL
97566 +cgroup_file_read_28804 cgroup_file_read 3 28804 NULL
97567 +btrfs_ref_to_path_28809 btrfs_ref_to_path 0 28809 NULL
97568 +memory_bm_create_28814 memory_bm_create 0 28814 NULL
97569 +iwl_dbgfs_rxon_filter_flags_read_28832 iwl_dbgfs_rxon_filter_flags_read 3 28832 NULL
97570 +vp_request_msix_vectors_28849 vp_request_msix_vectors 2 28849 NULL
97571 +ipv6_renew_options_28867 ipv6_renew_options 5 28867 NULL
97572 +packet_sendmsg_spkt_28885 packet_sendmsg_spkt 4 28885 NULL
97573 +to_cblock_28899 to_cblock 0-1 28899 NULL
97574 +da9055_group_write_28904 da9055_group_write 2-3 28904 NULL
97575 +ps_upsd_timeouts_read_28924 ps_upsd_timeouts_read 3 28924 NULL
97576 +ocfs2_frozen_trigger_28929 ocfs2_frozen_trigger 4 28929 NULL
97577 +push_rx_28939 push_rx 3 28939 NULL
97578 +btrfs_trim_block_group_28963 btrfs_trim_block_group 3 28963 NULL
97579 +alloc_sched_domains_28972 alloc_sched_domains 1 28972 NULL
97580 +ext4_mb_add_groupinfo_28988 ext4_mb_add_groupinfo 2 28988 NULL
97581 +bin_uuid_28999 bin_uuid 3 28999 NULL
97582 +xz_dec_init_29029 xz_dec_init 2 29029 NULL
97583 +sys_fcntl64_29031 sys_fcntl64 3 29031 NULL
97584 +ieee80211_if_read_ht_opmode_29044 ieee80211_if_read_ht_opmode 3 29044 NULL
97585 +rxrpc_sendmsg_29049 rxrpc_sendmsg 4 29049 NULL
97586 +iso_packets_buffer_init_29061 iso_packets_buffer_init 3-4 29061 NULL
97587 +lpfc_idiag_extacc_drivr_get_29067 lpfc_idiag_extacc_drivr_get 0-3 29067 NULL
97588 +memblock_alloc_base_nid_29072 memblock_alloc_base_nid 1-2 29072 NULL
97589 +sctp_getsockopt_assoc_stats_29074 sctp_getsockopt_assoc_stats 2 29074 NULL
97590 +mark_extents_written_29082 mark_extents_written 2 29082 NULL
97591 +isdn_ppp_write_29109 isdn_ppp_write 4 29109 NULL
97592 +snprintf_29125 snprintf 0 29125 NULL
97593 +iov_shorten_29130 iov_shorten 0 29130 NULL
97594 +proc_scsi_write_29142 proc_scsi_write 3 29142 NULL
97595 +reshape_ring_29147 reshape_ring 2 29147 NULL
97596 +alloc_irqs_from_29152 alloc_irqs_from 1-2 29152 NULL
97597 +drm_property_create_enum_29201 drm_property_create_enum 5 29201 NULL
97598 +wusb_prf_256_29203 wusb_prf_256 7 29203 NULL nohasharray
97599 +alloc_group_attrs_29203 alloc_group_attrs 3 29203 &wusb_prf_256_29203
97600 +__mm_populate_29204 __mm_populate 1 29204 NULL
97601 +comedi_alloc_subdevices_29207 comedi_alloc_subdevices 2 29207 NULL
97602 +do_shrinker_shrink_29208 do_shrinker_shrink 0 29208 NULL
97603 +iwl_dbgfs_temperature_read_29224 iwl_dbgfs_temperature_read 3 29224 NULL
97604 +devm_ioremap_29235 devm_ioremap 2-3 29235 NULL
97605 +irq_domain_add_linear_29236 irq_domain_add_linear 2 29236 NULL
97606 +recover_peb_29238 recover_peb 6-7 29238 NULL
97607 +security_context_to_sid_core_29248 security_context_to_sid_core 2 29248 NULL
97608 +block_div_29268 block_div 0-1-2 29268 NULL
97609 +prism2_set_genericelement_29277 prism2_set_genericelement 3 29277 NULL
97610 +bitmap_ord_to_pos_29279 bitmap_ord_to_pos 3 29279 NULL
97611 +sn9c102_read_29305 sn9c102_read 3 29305 NULL
97612 +lo_compat_ioctl_29336 lo_compat_ioctl 4 29336 NULL
97613 +tun_put_user_29337 tun_put_user 5 29337 NULL
97614 +__alloc_ei_netdev_29338 __alloc_ei_netdev 1 29338 NULL
97615 +alloc_and_copy_ftrace_hash_29368 alloc_and_copy_ftrace_hash 1 29368 NULL
97616 +mwifiex_cfg80211_mgmt_tx_29387 mwifiex_cfg80211_mgmt_tx 7 29387 NULL
97617 +pca953x_irq_setup_29407 pca953x_irq_setup 3 29407 NULL
97618 +mempool_create_29437 mempool_create 1 29437 NULL
97619 +crypto_ahash_alignmask_29445 crypto_ahash_alignmask 0 29445 NULL
97620 +apei_exec_ctx_get_output_29457 apei_exec_ctx_get_output 0 29457 NULL
97621 +validate_scan_freqs_29462 validate_scan_freqs 0 29462 NULL
97622 +do_register_entry_29478 do_register_entry 4 29478 NULL
97623 +simple_strtoul_29480 simple_strtoul 0 29480 NULL
97624 +btmrvl_pscmd_write_29504 btmrvl_pscmd_write 3 29504 NULL
97625 +btrfs_file_extent_disk_bytenr_29505 btrfs_file_extent_disk_bytenr 0 29505 NULL
97626 +atk_debugfs_ggrp_read_29522 atk_debugfs_ggrp_read 3 29522 NULL
97627 +_regmap_raw_write_29541 _regmap_raw_write 4-2 29541 NULL
97628 +set_brk_29551 set_brk 1 29551 NULL nohasharray
97629 +ftrace_write_29551 ftrace_write 3 29551 &set_brk_29551
97630 +idetape_queue_rw_tail_29562 idetape_queue_rw_tail 3 29562 NULL
97631 +leaf_dealloc_29566 leaf_dealloc 3 29566 NULL nohasharray
97632 +alloc_empty_pages_29566 alloc_empty_pages 2 29566 &leaf_dealloc_29566
97633 +lbs_lowsnr_read_29571 lbs_lowsnr_read 3 29571 NULL
97634 +pvr2_hdw_report_unlocked_29589 pvr2_hdw_report_unlocked 4 29589 NULL
97635 +slots_per_page_29601 slots_per_page 0 29601 NULL
97636 +qla4_82xx_pci_set_window_29605 qla4_82xx_pci_set_window 0-2 29605 NULL
97637 +alloc_low_pages_29623 alloc_low_pages 1 29623 NULL
97638 +nla_get_u16_29624 nla_get_u16 0 29624 NULL
97639 +tx_frag_cache_hit_read_29639 tx_frag_cache_hit_read 3 29639 NULL
97640 +lowmem_page_address_29649 lowmem_page_address 0 29649 NULL
97641 +sctp_make_abort_user_29654 sctp_make_abort_user 3 29654 NULL
97642 +br_send_bpdu_29669 br_send_bpdu 3 29669 NULL
97643 +sisusb_write_mem_bulk_29678 sisusb_write_mem_bulk 4 29678 NULL
97644 +sd_alloc_ctl_entry_29708 sd_alloc_ctl_entry 1 29708 NULL nohasharray
97645 +posix_acl_from_xattr_29708 posix_acl_from_xattr 3 29708 &sd_alloc_ctl_entry_29708
97646 +probes_write_29711 probes_write 3 29711 NULL
97647 +emi62_writememory_29731 emi62_writememory 4 29731 NULL
97648 +read_cis_cache_29735 read_cis_cache 4 29735 NULL
97649 +ip_vs_conn_fill_param_sync_29771 ip_vs_conn_fill_param_sync 6 29771 NULL
97650 +dbAlloc_29794 dbAlloc 0 29794 NULL
97651 +ext4_trim_all_free_29806 ext4_trim_all_free 4-3-2 29806 NULL
97652 +tcp_sendpage_29829 tcp_sendpage 4 29829 NULL
97653 +scan_bitmap_block_29840 scan_bitmap_block 4 29840 NULL
97654 +__probe_kernel_write_29842 __probe_kernel_write 3 29842 NULL
97655 +kvm_read_hva_atomic_29848 kvm_read_hva_atomic 3 29848 NULL
97656 +ipv6_setsockopt_29871 ipv6_setsockopt 5 29871 NULL
97657 +scsi_end_request_29876 scsi_end_request 3 29876 NULL
97658 +crypto_aead_alignmask_29885 crypto_aead_alignmask 0 29885 NULL
97659 +nfc_targets_found_29886 nfc_targets_found 3 29886 NULL
97660 +ext4_xattr_set_acl_29930 ext4_xattr_set_acl 4 29930 NULL
97661 +__btrfs_getxattr_29947 __btrfs_getxattr 0 29947 NULL
97662 +irias_add_octseq_attrib_29983 irias_add_octseq_attrib 4 29983 NULL nohasharray
97663 +diva_os_get_context_size_29983 diva_os_get_context_size 0 29983 &irias_add_octseq_attrib_29983
97664 +arch_setup_dmar_msi_29992 arch_setup_dmar_msi 1 29992 NULL
97665 +vmci_host_setup_notify_30002 vmci_host_setup_notify 2 30002 NULL
97666 +utf32_to_utf8_30028 utf32_to_utf8 0 30028 NULL
97667 +alloc_netdev_mqs_30030 alloc_netdev_mqs 1 30030 NULL
97668 +scsi_vpd_inquiry_30040 scsi_vpd_inquiry 4 30040 NULL
97669 +drp_wmove_30043 drp_wmove 4 30043 NULL
97670 +cxgbi_ddp_reserve_30091 cxgbi_ddp_reserve 4 30091 NULL
97671 +snd_midi_channel_init_set_30092 snd_midi_channel_init_set 1 30092 NULL
97672 +tg3_run_loopback_30093 tg3_run_loopback 2 30093 NULL
97673 +rx_filter_data_filter_read_30098 rx_filter_data_filter_read 3 30098 NULL nohasharray
97674 +dma_to_phys_30098 dma_to_phys 0-2 30098 &rx_filter_data_filter_read_30098
97675 +skb_pagelen_30113 skb_pagelen 0 30113 NULL
97676 +spi_async_locked_30117 spi_async_locked 0 30117 NULL
97677 +calgary_unmap_page_30130 calgary_unmap_page 2-3 30130 NULL
97678 +_osd_req_sizeof_alist_header_30134 _osd_req_sizeof_alist_header 0 30134 NULL
97679 +u_memcpya_30139 u_memcpya 2-3 30139 NULL
97680 +cx25821_video_ioctl_30188 cx25821_video_ioctl 2 30188 NULL
97681 +mempool_create_page_pool_30189 mempool_create_page_pool 1 30189 NULL
97682 +drm_property_create_bitmask_30195 drm_property_create_bitmask 5 30195 NULL
97683 +usblp_ioctl_30203 usblp_ioctl 2 30203 NULL
97684 +nfs_idmap_request_key_30208 nfs_idmap_request_key 3 30208 NULL
97685 +read_4k_modal_eeprom_30212 read_4k_modal_eeprom 3 30212 NULL
97686 +snd_ac97_pcm_assign_30218 snd_ac97_pcm_assign 2 30218 NULL
97687 +f2fs_compat_ioctl_30261 f2fs_compat_ioctl 3 30261 NULL
97688 +isr_pci_pm_read_30271 isr_pci_pm_read 3 30271 NULL
97689 +compat_readv_30273 compat_readv 3 30273 NULL
97690 +lapic_register_intr_30279 lapic_register_intr 1 30279 NULL
97691 +skcipher_sendmsg_30290 skcipher_sendmsg 4 30290 NULL
97692 +pipeline_sec_frag_swi_read_30294 pipeline_sec_frag_swi_read 3 30294 NULL
97693 +tcp_sendmsg_30296 tcp_sendmsg 4 30296 NULL
97694 +ext4_acl_from_disk_30320 ext4_acl_from_disk 2 30320 NULL
97695 +generic_ptrace_pokedata_30338 generic_ptrace_pokedata 2 30338 NULL
97696 +resource_from_user_30341 resource_from_user 3 30341 NULL
97697 +__vmalloc_node_flags_30352 __vmalloc_node_flags 1 30352 NULL
97698 +sys_get_mempolicy_30379 sys_get_mempolicy 3-4 30379 NULL
97699 +mangle_sdp_packet_30381 mangle_sdp_packet 10 30381 NULL
97700 +c4iw_init_resource_30393 c4iw_init_resource 2-3 30393 NULL
97701 +get_kernel_pages_30397 get_kernel_pages 0 30397 NULL
97702 +_drbd_bm_find_next_zero_30415 _drbd_bm_find_next_zero 2 30415 NULL
97703 +vb2_fop_write_30420 vb2_fop_write 3 30420 NULL
97704 +tx_tx_template_prepared_read_30424 tx_tx_template_prepared_read 3 30424 NULL
97705 +mq_create_30425 mq_create 1 30425 NULL
97706 +enable_write_30456 enable_write 3 30456 NULL
97707 +tx_tx_template_programmed_read_30461 tx_tx_template_programmed_read 3 30461 NULL
97708 +urandom_read_30462 urandom_read 3 30462 NULL
97709 +zoran_ioctl_30465 zoran_ioctl 2 30465 NULL
97710 +ocrdma_reg_user_mr_30474 ocrdma_reg_user_mr 2-3 30474 NULL
97711 +write_head_30481 write_head 4 30481 NULL
97712 +adu_write_30487 adu_write 3 30487 NULL
97713 +debug_debug2_read_30526 debug_debug2_read 3 30526 NULL
97714 +batadv_dat_snoop_incoming_arp_request_30548 batadv_dat_snoop_incoming_arp_request 3 30548 NULL
97715 +disk_expand_part_tbl_30561 disk_expand_part_tbl 2 30561 NULL
97716 +set_le_30581 set_le 4 30581 NULL
97717 +from_cblock_30582 from_cblock 0-1 30582 NULL
97718 +blk_init_tags_30592 blk_init_tags 1 30592 NULL
97719 +i2c_hid_get_report_length_30598 i2c_hid_get_report_length 0 30598 NULL
97720 +sgl_map_user_pages_30610 sgl_map_user_pages 2-3-4 30610 NULL
97721 +macvtap_sendmsg_30629 macvtap_sendmsg 4 30629 NULL
97722 +ieee80211_if_read_dot11MeshAwakeWindowDuration_30631 ieee80211_if_read_dot11MeshAwakeWindowDuration 3 30631 NULL
97723 +compat_raw_setsockopt_30634 compat_raw_setsockopt 5 30634 NULL
97724 +agp_remap_30665 agp_remap 2 30665 NULL
97725 +jffs2_flash_read_30667 jffs2_flash_read 0 30667 NULL
97726 +il_free_pages_30692 il_free_pages 2 30692 NULL
97727 +dccp_setsockopt_ccid_30701 dccp_setsockopt_ccid 4 30701 NULL
97728 +lbs_debugfs_read_30721 lbs_debugfs_read 3 30721 NULL
97729 +snd_nm256_playback_silence_30727 snd_nm256_playback_silence 4-3 30727 NULL
97730 +snapshot_status_30744 snapshot_status 5 30744 NULL
97731 +tcf_csum_ipv4_udp_30777 tcf_csum_ipv4_udp 4 30777 NULL
97732 +smk_read_doi_30813 smk_read_doi 3 30813 NULL
97733 +get_kobj_path_length_30831 get_kobj_path_length 0 30831 NULL
97734 +sctp_setsockopt_auth_chunk_30843 sctp_setsockopt_auth_chunk 3 30843 NULL
97735 +cfg80211_rx_mgmt_30844 cfg80211_rx_mgmt 5 30844 NULL
97736 +hda_hwdep_ioctl_compat_30847 hda_hwdep_ioctl_compat 4 30847 NULL
97737 +ieee80211_if_fmt_dropped_frames_no_route_30884 ieee80211_if_fmt_dropped_frames_no_route 3 30884 NULL
97738 +iommu_map_mmio_space_30919 iommu_map_mmio_space 1 30919 NULL
97739 +sctp_setsockopt_rtoinfo_30941 sctp_setsockopt_rtoinfo 3 30941 NULL
97740 +tty_insert_flip_string_flags_30969 tty_insert_flip_string_flags 4 30969 NULL
97741 +huge_page_mask_30981 huge_page_mask 0 30981 NULL
97742 +i2400mu_rx_size_grow_30989 i2400mu_rx_size_grow 0 30989 NULL
97743 +lbs_host_sleep_read_31013 lbs_host_sleep_read 3 31013 NULL
97744 +phys_pmd_init_31024 phys_pmd_init 0-3-2 31024 NULL
97745 +compat_sys_mq_timedsend_31060 compat_sys_mq_timedsend 3 31060 NULL
97746 +lbs_failcount_read_31063 lbs_failcount_read 3 31063 NULL
97747 +find_next_bit_le_31064 find_next_bit_le 0-2-3 31064 NULL
97748 +sys_mincore_31079 sys_mincore 1 31079 NULL
97749 +ttm_bo_ioremap_31082 ttm_bo_ioremap 2-3 31082 NULL
97750 +sctp_setsockopt_context_31091 sctp_setsockopt_context 3 31091 NULL
97751 +compat_sys_get_mempolicy_31109 compat_sys_get_mempolicy 3-4 31109 NULL
97752 +depth_read_31112 depth_read 3 31112 NULL
97753 +ssb_read16_31139 ssb_read16 0 31139 NULL
97754 +kimage_normal_alloc_31140 kimage_normal_alloc 3 31140 NULL
97755 +size_inside_page_31141 size_inside_page 0 31141 NULL
97756 +w9966_v4l_read_31148 w9966_v4l_read 3 31148 NULL
97757 +ch_do_scsi_31171 ch_do_scsi 4 31171 NULL
97758 +acpi_ex_system_memory_space_handler_31192 acpi_ex_system_memory_space_handler 2 31192 NULL
97759 +r592_read_fifo_pio_31198 r592_read_fifo_pio 3 31198 NULL
97760 +mtdchar_readoob_31200 mtdchar_readoob 4 31200 NULL
97761 +__btrfs_free_reserved_extent_31207 __btrfs_free_reserved_extent 2 31207 NULL
97762 +kvm_mmu_page_fault_31213 kvm_mmu_page_fault 2 31213 NULL
97763 +cpumask_weight_31215 cpumask_weight 0 31215 NULL
97764 +__read_reg_31216 __read_reg 0 31216 NULL
97765 +atm_get_addr_31221 atm_get_addr 3 31221 NULL
97766 +cyy_readb_31240 cyy_readb 0 31240 NULL
97767 +_create_sg_bios_31244 _create_sg_bios 4 31244 NULL
97768 +ieee80211_if_read_last_beacon_31257 ieee80211_if_read_last_beacon 3 31257 NULL
97769 +sctp_tsnmap_find_gap_ack_31272 sctp_tsnmap_find_gap_ack 3-2 31272 NULL
97770 +uvc_simplify_fraction_31303 uvc_simplify_fraction 3 31303 NULL
97771 +sisusbcon_scroll_31315 sisusbcon_scroll 5-2-3 31315 NULL
97772 +command_file_write_31318 command_file_write 3 31318 NULL
97773 +em28xx_init_usb_xfer_31337 em28xx_init_usb_xfer 4-6 31337 NULL
97774 +xprt_rdma_allocate_31372 xprt_rdma_allocate 2 31372 NULL
97775 +vb2_vmalloc_get_userptr_31374 vb2_vmalloc_get_userptr 3-2 31374 NULL
97776 +trace_parser_get_init_31379 trace_parser_get_init 2 31379 NULL
97777 +inb_31388 inb 0 31388 NULL
97778 +key_ifindex_read_31411 key_ifindex_read 3 31411 NULL
97779 +mcs7830_set_reg_31413 mcs7830_set_reg 3 31413 NULL
97780 +TSS_checkhmac1_31429 TSS_checkhmac1 5 31429 NULL
97781 +snd_aw2_saa7146_get_hw_ptr_capture_31431 snd_aw2_saa7146_get_hw_ptr_capture 0 31431 NULL
97782 +acpi_sci_ioapic_setup_31445 acpi_sci_ioapic_setup 4 31445 NULL
97783 +opera1_xilinx_rw_31453 opera1_xilinx_rw 5 31453 NULL
97784 +input_get_new_minor_31464 input_get_new_minor 1 31464 NULL
97785 +do_fcntl_31468 do_fcntl 3 31468 NULL
97786 +xfs_btree_get_numrecs_31477 xfs_btree_get_numrecs 0 31477 NULL
97787 +alg_setkey_31485 alg_setkey 3 31485 NULL
97788 +rds_message_map_pages_31487 rds_message_map_pages 2 31487 NULL
97789 +qsfp_2_read_31491 qsfp_2_read 3 31491 NULL
97790 +__alloc_bootmem_31498 __alloc_bootmem 1-2 31498 NULL
97791 +rmode_tss_base_31510 rmode_tss_base 0 31510 NULL
97792 +hidraw_write_31536 hidraw_write 3 31536 NULL
97793 +mtd_div_by_eb_31543 mtd_div_by_eb 0-1 31543 NULL
97794 +usbvision_read_31555 usbvision_read 3 31555 NULL
97795 +normalize_31566 normalize 0-1-2 31566 NULL
97796 +tx_frag_tkip_called_read_31575 tx_frag_tkip_called_read 3 31575 NULL
97797 +get_max_inline_xattr_value_size_31578 get_max_inline_xattr_value_size 0 31578 NULL
97798 +osst_write_31581 osst_write 3 31581 NULL
97799 +snd_compr_get_avail_31584 snd_compr_get_avail 0 31584 NULL
97800 +iwl_dbgfs_ucode_tx_stats_read_31611 iwl_dbgfs_ucode_tx_stats_read 3 31611 NULL
97801 +mtd_get_user_prot_info_31616 mtd_get_user_prot_info 0 31616 NULL
97802 +arvo_sysfs_read_31617 arvo_sysfs_read 6 31617 NULL
97803 +videobuf_read_one_31637 videobuf_read_one 3 31637 NULL
97804 +pod_alloc_sysex_buffer_31651 pod_alloc_sysex_buffer 3 31651 NULL
97805 +xfer_secondary_pool_31661 xfer_secondary_pool 2 31661 NULL
97806 +emulator_set_cr_31665 emulator_set_cr 3 31665 NULL
97807 +__lgread_31668 __lgread 4 31668 NULL
97808 +symbol_string_31670 symbol_string 0 31670 NULL
97809 +_usb_writeN_sync_31682 _usb_writeN_sync 4 31682 NULL
97810 +forced_ps_read_31685 forced_ps_read 3 31685 NULL
97811 +reiserfs_in_journal_31689 reiserfs_in_journal 3 31689 NULL
97812 +audit_log_n_string_31705 audit_log_n_string 3 31705 NULL
97813 +ath6kl_wmi_send_probe_response_cmd_31728 ath6kl_wmi_send_probe_response_cmd 6 31728 NULL nohasharray
97814 +gfn_to_hva_read_31728 gfn_to_hva_read 2 31728 &ath6kl_wmi_send_probe_response_cmd_31728
97815 +utf16s_to_utf8s_31735 utf16s_to_utf8s 0 31735 NULL
97816 +shmem_pwrite_slow_31741 shmem_pwrite_slow 3 31741 NULL
97817 +NCR_700_change_queue_depth_31742 NCR_700_change_queue_depth 2 31742 NULL nohasharray
97818 +input_abs_get_max_31742 input_abs_get_max 0 31742 &NCR_700_change_queue_depth_31742
97819 +bcm_char_read_31750 bcm_char_read 3 31750 NULL
97820 +snd_seq_device_new_31753 snd_seq_device_new 4 31753 NULL
97821 +set_memory_wb_31761 set_memory_wb 1 31761 NULL
97822 +usblp_cache_device_id_string_31790 usblp_cache_device_id_string 0 31790 NULL
97823 +get_count_order_31800 get_count_order 0 31800 NULL
97824 +ecryptfs_send_message_locked_31801 ecryptfs_send_message_locked 2 31801 NULL
97825 +isr_rx_procs_read_31804 isr_rx_procs_read 3 31804 NULL
97826 +strnlen_user_31815 strnlen_user 0-2 31815 NULL
97827 +sta_last_signal_read_31818 sta_last_signal_read 3 31818 NULL
97828 +drm_mode_crtc_set_gamma_size_31881 drm_mode_crtc_set_gamma_size 2 31881 NULL
97829 +ddb_output_write_31902 ddb_output_write 3 31902 NULL
97830 +xattr_permission_31907 xattr_permission 0 31907 NULL
97831 +new_dir_31919 new_dir 3 31919 NULL
97832 +kmem_alloc_31920 kmem_alloc 1 31920 NULL
97833 +guestwidth_to_adjustwidth_31937 guestwidth_to_adjustwidth 0-1 31937 NULL
97834 +iov_iter_copy_from_user_31942 iov_iter_copy_from_user 4 31942 NULL
97835 +vb2_write_31948 vb2_write 3 31948 NULL
97836 +pvr2_ctrl_get_valname_31951 pvr2_ctrl_get_valname 4 31951 NULL
97837 +copy_from_user_toio_31966 copy_from_user_toio 3 31966 NULL
97838 +mtd_add_partition_31971 mtd_add_partition 3 31971 NULL
97839 +find_next_zero_bit_31990 find_next_zero_bit 0-2-3 31990 NULL
97840 +default_setup_hpet_msi_31991 default_setup_hpet_msi 1 31991 NULL
97841 +tps6586x_irq_map_32002 tps6586x_irq_map 2 32002 NULL
97842 +calc_hmac_32010 calc_hmac 3 32010 NULL
97843 +vmcs_read64_32012 vmcs_read64 0 32012 NULL
97844 +aead_len_32021 aead_len 0 32021 NULL
97845 +ocfs2_remove_extent_32032 ocfs2_remove_extent 4-3 32032 NULL
97846 +posix_acl_set_32037 posix_acl_set 4 32037 NULL
97847 +vmw_cursor_update_dmabuf_32045 vmw_cursor_update_dmabuf 3-4 32045 NULL
97848 +sys_sched_setaffinity_32046 sys_sched_setaffinity 2 32046 NULL
97849 +proc_scsi_devinfo_write_32064 proc_scsi_devinfo_write 3 32064 NULL
97850 +cfg80211_send_unprot_deauth_32080 cfg80211_send_unprot_deauth 3 32080 NULL
97851 +bio_alloc_32095 bio_alloc 2 32095 NULL
97852 +alloc_pwms_32100 alloc_pwms 1-2 32100 NULL
97853 +ath6kl_fwlog_read_32101 ath6kl_fwlog_read 3 32101 NULL
97854 +disk_status_32120 disk_status 4 32120 NULL
97855 +venus_link_32165 venus_link 5 32165 NULL
97856 +do_writepages_32173 do_writepages 0 32173 NULL nohasharray
97857 +ntfs_rl_realloc_nofail_32173 ntfs_rl_realloc_nofail 3 32173 &do_writepages_32173
97858 +load_header_32183 load_header 0 32183 NULL
97859 +ubi_wl_scrub_peb_32196 ubi_wl_scrub_peb 0 32196 NULL
97860 +wusb_ccm_mac_32199 wusb_ccm_mac 7 32199 NULL
97861 +riva_get_cmap_len_32218 riva_get_cmap_len 0 32218 NULL
97862 +lbs_lowrssi_read_32242 lbs_lowrssi_read 3 32242 NULL
97863 +ocfs2_xattr_find_entry_32260 ocfs2_xattr_find_entry 0 32260 NULL
97864 +fb_compat_ioctl_32265 fb_compat_ioctl 3 32265 NULL
97865 +vmalloc_user_32308 vmalloc_user 1 32308 NULL
97866 +hex_string_32310 hex_string 0 32310 NULL
97867 +nouveau_bar_create__32332 nouveau_bar_create_ 4 32332 NULL
97868 +nl80211_send_mlme_event_32337 nl80211_send_mlme_event 4 32337 NULL
97869 +t4_alloc_mem_32342 t4_alloc_mem 1 32342 NULL
97870 +dispatch_ioctl_32357 dispatch_ioctl 2 32357 NULL
97871 +sel_read_initcon_32362 sel_read_initcon 3 32362 NULL
97872 +_drbd_bm_find_next_32372 _drbd_bm_find_next 2 32372 NULL
97873 +usbtmc_read_32377 usbtmc_read 3 32377 NULL
97874 +qla4_82xx_pci_mem_write_2M_32398 qla4_82xx_pci_mem_write_2M 2 32398 NULL
97875 +xfs_iext_add_indirect_multi_32400 xfs_iext_add_indirect_multi 3 32400 NULL
97876 +vmci_qp_alloc_32405 vmci_qp_alloc 3-5 32405 NULL
97877 +log_text_32428 log_text 0 32428 NULL
97878 +regmap_irq_map_32429 regmap_irq_map 2 32429 NULL
97879 +hid_input_report_32458 hid_input_report 4 32458 NULL
97880 +cache_status_32462 cache_status 5 32462 NULL
97881 +ieee80211_fill_mesh_addresses_32465 ieee80211_fill_mesh_addresses 0 32465 NULL
97882 +ide_driver_proc_write_32493 ide_driver_proc_write 3 32493 NULL
97883 +ctrl_std_val_to_sym_32516 ctrl_std_val_to_sym 5 32516 NULL
97884 +disconnect_32521 disconnect 4 32521 NULL
97885 +qsfp_read_32522 qsfp_read 0-4-2 32522 NULL
97886 +ilo_read_32531 ilo_read 3 32531 NULL
97887 +ieee80211_if_read_estab_plinks_32533 ieee80211_if_read_estab_plinks 3 32533 NULL
97888 +gnttab_set_unmap_op_32534 gnttab_set_unmap_op 2 32534 NULL
97889 +ieee80211_send_auth_32543 ieee80211_send_auth 6 32543 NULL
97890 +format_devstat_counter_32550 format_devstat_counter 3 32550 NULL
97891 +__first_node_32558 __first_node 0 32558 NULL
97892 +aes_encrypt_fail_read_32562 aes_encrypt_fail_read 3 32562 NULL
97893 +pnp_mem_len_32584 pnp_mem_len 0 32584 NULL
97894 +mem_swapout_entry_32586 mem_swapout_entry 3 32586 NULL
97895 +pipeline_tcp_tx_stat_fifo_int_read_32589 pipeline_tcp_tx_stat_fifo_int_read 3 32589 NULL
97896 +read_file_beacon_32595 read_file_beacon 3 32595 NULL
97897 +ieee80211_if_read_dropped_frames_congestion_32603 ieee80211_if_read_dropped_frames_congestion 3 32603 NULL
97898 +sys_set_mempolicy_32608 sys_set_mempolicy 3 32608 NULL
97899 +cfg80211_roamed_32632 cfg80211_roamed 5-7 32632 NULL
97900 +ieee80211_hdrlen_32637 ieee80211_hdrlen 0 32637 NULL
97901 +ite_decode_bytes_32642 ite_decode_bytes 3 32642 NULL
97902 +kvmalloc_32646 kvmalloc 1 32646 NULL
97903 +ib_sg_dma_len_32649 ib_sg_dma_len 0 32649 NULL
97904 +generic_readlink_32654 generic_readlink 3 32654 NULL
97905 +move_addr_to_kernel_32673 move_addr_to_kernel 2 32673 NULL
97906 +jfs_readpages_32702 jfs_readpages 4 32702 NULL
97907 +snd_hwdep_ioctl_compat_32736 snd_hwdep_ioctl_compat 3 32736 NULL
97908 +get_arg_page_32746 get_arg_page 2 32746 NULL
97909 +megasas_change_queue_depth_32747 megasas_change_queue_depth 2 32747 NULL
97910 +stats_read_ul_32751 stats_read_ul 3 32751 NULL
97911 +tty_compat_ioctl_32761 tty_compat_ioctl 3 32761 NULL
97912 +sctp_tsnmap_grow_32784 sctp_tsnmap_grow 2 32784 NULL
97913 +firmwareUpload_32794 firmwareUpload 3 32794 NULL
97914 +rproc_name_read_32805 rproc_name_read 3 32805 NULL
97915 +vga_rseq_32848 vga_rseq 0 32848 NULL
97916 +new_tape_buffer_32866 new_tape_buffer 2 32866 NULL
97917 +io_apic_setup_irq_pin_32868 io_apic_setup_irq_pin 1 32868 NULL
97918 +ath6kl_usb_submit_ctrl_in_32880 ath6kl_usb_submit_ctrl_in 6 32880 NULL nohasharray
97919 +cifs_writedata_alloc_32880 cifs_writedata_alloc 1 32880 &ath6kl_usb_submit_ctrl_in_32880
97920 +ath6kl_usb_post_recv_transfers_32892 ath6kl_usb_post_recv_transfers 2 32892 NULL
97921 +il_dbgfs_tx_stats_read_32913 il_dbgfs_tx_stats_read 3 32913 NULL
97922 +zlib_inflate_workspacesize_32927 zlib_inflate_workspacesize 0 32927 NULL
97923 +rmap_recycle_32938 rmap_recycle 3 32938 NULL
97924 +irq_reserve_irqs_32946 irq_reserve_irqs 1-2 32946 NULL
97925 +ext4_valid_block_bitmap_32958 ext4_valid_block_bitmap 3 32958 NULL
97926 +arch_ptrace_32981 arch_ptrace 3 32981 NULL
97927 +compat_filldir_32999 compat_filldir 3 32999 NULL
97928 +ext3_alloc_blocks_33007 ext3_alloc_blocks 3 33007 NULL
97929 +pipeline_dec_packet_in_fifo_full_read_33052 pipeline_dec_packet_in_fifo_full_read 3 33052 NULL
97930 +ebt_compat_match_offset_33053 ebt_compat_match_offset 0-2 33053 NULL
97931 +bitmap_resize_33054 bitmap_resize 2 33054 NULL
97932 +stats_dot11RTSSuccessCount_read_33065 stats_dot11RTSSuccessCount_read 3 33065 NULL
97933 +sel_read_checkreqprot_33068 sel_read_checkreqprot 3 33068 NULL
97934 +alloc_tio_33077 alloc_tio 3 33077 NULL
97935 +acl_permission_check_33083 acl_permission_check 0 33083 NULL
97936 +ieee80211_fragment_33112 ieee80211_fragment 4 33112 NULL
97937 +write_node_33121 write_node 4 33121 NULL
97938 +calc_patch_size_33124 calc_patch_size 0 33124 NULL
97939 +fb_sys_write_33130 fb_sys_write 3 33130 NULL
97940 +__len_within_target_33132 __len_within_target 0 33132 NULL
97941 +debug_debug6_read_33168 debug_debug6_read 3 33168 NULL
97942 +dataflash_read_fact_otp_33204 dataflash_read_fact_otp 2-3 33204 NULL
97943 +pp_read_33210 pp_read 3 33210 NULL
97944 +xfs_file_aio_write_33234 xfs_file_aio_write 4 33234 NULL
97945 +build_completion_wait_33242 build_completion_wait 2 33242 NULL
97946 +snd_pcm_plug_client_size_33267 snd_pcm_plug_client_size 0-2 33267 NULL
97947 +sched_find_first_bit_33270 sched_find_first_bit 0 33270 NULL
97948 +cachefiles_cook_key_33274 cachefiles_cook_key 2 33274 NULL
97949 +mei_compat_ioctl_33275 mei_compat_ioctl 3 33275 NULL
97950 +mcs7830_get_reg_33308 mcs7830_get_reg 3 33308 NULL
97951 +ath6kl_usb_ctrl_msg_exchange_33327 ath6kl_usb_ctrl_msg_exchange 4 33327 NULL
97952 +gsm_mux_rx_netchar_33336 gsm_mux_rx_netchar 3 33336 NULL
97953 +joydev_ioctl_33343 joydev_ioctl 2 33343 NULL
97954 +create_xattr_datum_33356 create_xattr_datum 5 33356 NULL nohasharray
97955 +irq_pkt_threshold_read_33356 irq_pkt_threshold_read 3 33356 &create_xattr_datum_33356
97956 +read_file_regidx_33370 read_file_regidx 3 33370 NULL
97957 +ocfs2_quota_read_33382 ocfs2_quota_read 5 33382 NULL
97958 +ieee80211_if_read_dropped_frames_no_route_33383 ieee80211_if_read_dropped_frames_no_route 3 33383 NULL
97959 +scsi_varlen_cdb_length_33385 scsi_varlen_cdb_length 0 33385 NULL
97960 +ocfs2_allocate_unwritten_extents_33394 ocfs2_allocate_unwritten_extents 2-3 33394 NULL
97961 +ext4_meta_bg_first_block_no_33408 ext4_meta_bg_first_block_no 2 33408 NULL nohasharray
97962 +snd_pcm_capture_ioctl1_33408 snd_pcm_capture_ioctl1 0 33408 &ext4_meta_bg_first_block_no_33408
97963 +ufs_getfrag_block_33409 ufs_getfrag_block 2 33409 NULL
97964 +ubh_scanc_33436 ubh_scanc 0-4-3 33436 NULL
97965 +ovs_vport_alloc_33475 ovs_vport_alloc 1 33475 NULL
97966 +create_entry_33479 create_entry 2 33479 NULL
97967 +ip_setsockopt_33487 ip_setsockopt 5 33487 NULL nohasharray
97968 +elf_map_33487 elf_map 0-2 33487 &ip_setsockopt_33487
97969 +netxen_nic_hw_write_wx_128M_33488 netxen_nic_hw_write_wx_128M 2 33488 NULL
97970 +ol_dqblk_chunk_off_33489 ol_dqblk_chunk_off 2 33489 NULL
97971 +res_counter_read_33499 res_counter_read 4 33499 NULL
97972 +fb_read_33506 fb_read 3 33506 NULL
97973 +musb_test_mode_write_33518 musb_test_mode_write 3 33518 NULL
97974 +ahash_setkey_unaligned_33521 ahash_setkey_unaligned 3 33521 NULL
97975 +nes_alloc_fast_reg_page_list_33523 nes_alloc_fast_reg_page_list 2 33523 NULL
97976 +aggr_size_rx_size_read_33526 aggr_size_rx_size_read 3 33526 NULL
97977 +acpi_gsi_to_irq_33533 acpi_gsi_to_irq 1 33533 NULL
97978 +tomoyo_read_self_33539 tomoyo_read_self 3 33539 NULL
97979 +dup_array_33551 dup_array 3 33551 NULL
97980 +solo_enc_read_33553 solo_enc_read 3 33553 NULL
97981 +count_subheaders_33591 count_subheaders 0 33591 NULL
97982 +scsi_execute_33596 scsi_execute 5 33596 NULL
97983 +comedi_buf_write_n_allocated_33604 comedi_buf_write_n_allocated 0 33604 NULL
97984 +xt_compat_target_offset_33608 xt_compat_target_offset 0 33608 NULL nohasharray
97985 +ip6_find_1stfragopt_33608 ip6_find_1stfragopt 0 33608 &xt_compat_target_offset_33608
97986 +usb_gstrings_attach_33615 usb_gstrings_attach 3 33615 NULL nohasharray
97987 +il_dbgfs_qos_read_33615 il_dbgfs_qos_read 3 33615 &usb_gstrings_attach_33615
97988 +irq_blk_threshold_read_33666 irq_blk_threshold_read 3 33666 NULL
97989 +inw_p_33668 inw_p 0 33668 NULL
97990 +arp_hdr_len_33671 arp_hdr_len 0 33671 NULL
97991 +i2c_hid_alloc_buffers_33673 i2c_hid_alloc_buffers 2 33673 NULL
97992 +ath6kl_wmi_startscan_cmd_33674 ath6kl_wmi_startscan_cmd 8 33674 NULL
97993 +nv50_disp_dmac_create__33696 nv50_disp_dmac_create_ 6 33696 NULL
97994 +compat_insnlist_33706 compat_insnlist 2 33706 NULL
97995 +sys_keyctl_33708 sys_keyctl 4 33708 NULL nohasharray
97996 +netlink_sendmsg_33708 netlink_sendmsg 4 33708 &sys_keyctl_33708
97997 +tipc_link_stats_33716 tipc_link_stats 3 33716 NULL
97998 +pvr2_stream_buffer_count_33719 pvr2_stream_buffer_count 2 33719 NULL
97999 +ocfs2_extent_map_get_blocks_33720 ocfs2_extent_map_get_blocks 2 33720 NULL
98000 +__mutex_lock_interruptible_slowpath_33735 __mutex_lock_interruptible_slowpath 0 33735 NULL
98001 +Read_hfc_33755 Read_hfc 0 33755 NULL
98002 +vifs_state_read_33762 vifs_state_read 3 33762 NULL
98003 +hashtab_create_33769 hashtab_create 3 33769 NULL
98004 +midibuf_message_length_33770 midibuf_message_length 0 33770 NULL
98005 +if_sdio_read_rx_len_33800 if_sdio_read_rx_len 0 33800 NULL
98006 +find_next_offset_33804 find_next_offset 3 33804 NULL
98007 +sky2_rx_pad_33819 sky2_rx_pad 0 33819 NULL
98008 +sep_create_msgarea_context_33829 sep_create_msgarea_context 4 33829 NULL
98009 +scrub_setup_recheck_block_33831 scrub_setup_recheck_block 5-4 33831 NULL
98010 +udplite_manip_pkt_33832 udplite_manip_pkt 4 33832 NULL
98011 +usb_dump_endpoint_descriptor_33849 usb_dump_endpoint_descriptor 0 33849 NULL
98012 +calgary_alloc_coherent_33851 calgary_alloc_coherent 2 33851 NULL
98013 +oz_cdev_write_33852 oz_cdev_write 3 33852 NULL
98014 +cap_mmap_addr_33853 cap_mmap_addr 0 33853 NULL
98015 +get_user_pages_33908 get_user_pages 0-3-4 33908 NULL
98016 +queue_logical_block_size_33918 queue_logical_block_size 0 33918 NULL
98017 +sel_read_avc_cache_threshold_33942 sel_read_avc_cache_threshold 3 33942 NULL
98018 +lpfc_idiag_ctlacc_read_33943 lpfc_idiag_ctlacc_read 3 33943 NULL
98019 +read_file_tgt_rx_stats_33944 read_file_tgt_rx_stats 3 33944 NULL
98020 +vga_switcheroo_debugfs_write_33984 vga_switcheroo_debugfs_write 3 33984 NULL
98021 +__ntfs_malloc_34022 __ntfs_malloc 1 34022 NULL
98022 +ppp_write_34034 ppp_write 3 34034 NULL
98023 +tty_insert_flip_string_34042 tty_insert_flip_string 3 34042 NULL
98024 +__domain_flush_pages_34045 __domain_flush_pages 2-3 34045 NULL
98025 +acpi_dev_get_irqresource_34064 acpi_dev_get_irqresource 2 34064 NULL
98026 +memcg_update_all_caches_34068 memcg_update_all_caches 1 34068 NULL
98027 +read_file_ant_diversity_34071 read_file_ant_diversity 3 34071 NULL
98028 +compat_hdio_ioctl_34088 compat_hdio_ioctl 4 34088 NULL
98029 +pipeline_pipeline_fifo_full_read_34095 pipeline_pipeline_fifo_full_read 3 34095 NULL
98030 +is_discarded_oblock_34120 is_discarded_oblock 2 34120 NULL
98031 +islpci_mgt_transmit_34133 islpci_mgt_transmit 5 34133 NULL
98032 +ttm_dma_page_pool_free_34135 ttm_dma_page_pool_free 2 34135 NULL
98033 +cdc_mbim_process_dgram_34136 cdc_mbim_process_dgram 3 34136 NULL
98034 +ixgbe_dbg_netdev_ops_write_34141 ixgbe_dbg_netdev_ops_write 3 34141 NULL
98035 +shmem_pread_fast_34147 shmem_pread_fast 3 34147 NULL
98036 +skb_to_sgvec_34171 skb_to_sgvec 0 34171 NULL
98037 +ext4_da_write_begin_34215 ext4_da_write_begin 3-4 34215 NULL
98038 +bl_pipe_downcall_34264 bl_pipe_downcall 3 34264 NULL
98039 +pcf857x_to_irq_34273 pcf857x_to_irq 2 34273 NULL
98040 +zone_spanned_pages_in_node_34299 zone_spanned_pages_in_node 0 34299 NULL
98041 +iov_iter_single_seg_count_34326 iov_iter_single_seg_count 0 34326 NULL nohasharray
98042 +pcpu_need_to_extend_34326 pcpu_need_to_extend 0 34326 &iov_iter_single_seg_count_34326
98043 +__insert_34349 __insert 2-3 34349 NULL
98044 +crypto_ablkcipher_ivsize_34363 crypto_ablkcipher_ivsize 0 34363 NULL
98045 +rngapi_reset_34366 rngapi_reset 3 34366 NULL nohasharray
98046 +p54_alloc_skb_34366 p54_alloc_skb 3 34366 &rngapi_reset_34366
98047 +reiserfs_resize_34377 reiserfs_resize 2 34377 NULL
98048 +ea_read_34378 ea_read 0 34378 NULL
98049 +av7110_vbi_write_34384 av7110_vbi_write 3 34384 NULL
98050 +usbvision_v4l2_read_34386 usbvision_v4l2_read 3 34386 NULL
98051 +read_rbu_image_type_34387 read_rbu_image_type 6 34387 NULL
98052 +iwl_calib_set_34400 iwl_calib_set 3 34400 NULL nohasharray
98053 +ivtv_read_pos_34400 ivtv_read_pos 3 34400 &iwl_calib_set_34400
98054 +nl80211_send_disassoc_34424 nl80211_send_disassoc 4 34424 NULL
98055 +usbtest_alloc_urb_34446 usbtest_alloc_urb 3-5 34446 NULL
98056 +mwifiex_regrdwr_read_34472 mwifiex_regrdwr_read 3 34472 NULL
98057 +skcipher_sndbuf_34476 skcipher_sndbuf 0 34476 NULL
98058 +i2o_parm_field_get_34477 i2o_parm_field_get 5 34477 NULL
98059 +security_inode_permission_34488 security_inode_permission 0 34488 NULL
98060 +tracing_stats_read_34537 tracing_stats_read 3 34537 NULL
98061 +hugetlbfs_read_actor_34547 hugetlbfs_read_actor 0-2-5-4 34547 NULL
98062 +dbBackSplit_34561 dbBackSplit 0 34561 NULL
98063 +alloc_ieee80211_rsl_34564 alloc_ieee80211_rsl 1 34564 NULL
98064 +velocity_rx_copy_34583 velocity_rx_copy 2 34583 NULL
98065 +init_send_hfcd_34586 init_send_hfcd 1 34586 NULL
98066 +inet6_ifla6_size_34591 inet6_ifla6_size 0 34591 NULL
98067 +ceph_msgpool_init_34599 ceph_msgpool_init 4 34599 NULL
98068 +brcmf_cfg80211_mgmt_tx_34608 brcmf_cfg80211_mgmt_tx 7 34608 NULL
98069 +__jffs2_ref_totlen_34609 __jffs2_ref_totlen 0 34609 NULL
98070 +__cfg80211_disconnected_34622 __cfg80211_disconnected 3 34622 NULL
98071 +cnic_alloc_dma_34641 cnic_alloc_dma 3 34641 NULL
98072 +tomoyo_dump_page_34649 tomoyo_dump_page 2 34649 NULL
98073 +nf_nat_mangle_udp_packet_34661 nf_nat_mangle_udp_packet 8-6 34661 NULL
98074 +isr_fiqs_read_34687 isr_fiqs_read 3 34687 NULL
98075 +port_print_34704 port_print 3 34704 NULL
98076 +alloc_irq_and_cfg_at_34706 alloc_irq_and_cfg_at 1 34706 NULL
98077 +ieee80211_if_read_num_sta_ps_34722 ieee80211_if_read_num_sta_ps 3 34722 NULL
98078 +platform_list_read_file_34734 platform_list_read_file 3 34734 NULL
98079 +reg_w_ixbuf_34736 reg_w_ixbuf 4 34736 NULL
98080 +qib_cdev_init_34778 qib_cdev_init 1 34778 NULL
98081 +__copy_in_user_34790 __copy_in_user 3 34790 NULL
98082 +drbd_get_max_capacity_34804 drbd_get_max_capacity 0 34804 NULL
98083 +b43_debugfs_write_34838 b43_debugfs_write 3 34838 NULL
98084 +nl_portid_hash_zalloc_34843 nl_portid_hash_zalloc 1 34843 NULL
98085 +acpi_system_write_wakeup_device_34853 acpi_system_write_wakeup_device 3 34853 NULL
98086 +usb_serial_generic_prepare_write_buffer_34857 usb_serial_generic_prepare_write_buffer 3 34857 NULL
98087 +ieee80211_if_read_txpower_34871 ieee80211_if_read_txpower 3 34871 NULL
98088 +msg_print_text_34889 msg_print_text 0 34889 NULL
98089 +ieee80211_if_write_34894 ieee80211_if_write 3 34894 NULL
98090 +compat_put_uint_34905 compat_put_uint 1 34905 NULL
98091 +__inode_permission_34925 __inode_permission 0 34925 NULL nohasharray
98092 +btrfs_super_chunk_root_34925 btrfs_super_chunk_root 0 34925 &__inode_permission_34925
98093 +skb_gro_header_slow_34958 skb_gro_header_slow 2 34958 NULL
98094 +Realloc_34961 Realloc 2 34961 NULL
98095 +mq_lookup_34990 mq_lookup 2 34990 NULL
98096 +rx_rx_hdr_overflow_read_35002 rx_rx_hdr_overflow_read 3 35002 NULL
98097 +l2cap_skbuff_fromiovec_35003 l2cap_skbuff_fromiovec 4-3 35003 NULL
98098 +dm_cache_insert_mapping_35005 dm_cache_insert_mapping 2-3 35005 NULL
98099 +sisusb_copy_memory_35016 sisusb_copy_memory 4 35016 NULL
98100 +alloc_p2m_page_35025 alloc_p2m_page 0 35025 NULL
98101 +coda_psdev_read_35029 coda_psdev_read 3 35029 NULL
98102 +btmrvl_gpiogap_write_35053 btmrvl_gpiogap_write 3 35053 NULL
98103 +pwr_connection_out_of_sync_read_35061 pwr_connection_out_of_sync_read 3 35061 NULL
98104 +store_ifalias_35088 store_ifalias 4 35088 NULL
98105 +__kfifo_uint_must_check_helper_35097 __kfifo_uint_must_check_helper 0-1 35097 NULL
98106 +capi_write_35104 capi_write 3 35104 NULL nohasharray
98107 +tx_tx_done_template_read_35104 tx_tx_done_template_read 3 35104 &capi_write_35104
98108 +ide_settings_proc_write_35110 ide_settings_proc_write 3 35110 NULL
98109 +pointer_35138 pointer 0 35138 NULL
98110 +gntdev_alloc_map_35145 gntdev_alloc_map 2 35145 NULL
98111 +iscsi_conn_setup_35159 iscsi_conn_setup 2 35159 NULL
98112 +ieee80211_if_read_bssid_35161 ieee80211_if_read_bssid 3 35161 NULL
98113 +mlx4_ib_get_cq_umem_35184 mlx4_ib_get_cq_umem 5-6 35184 NULL
98114 +iwl_nvm_read_chunk_35198 iwl_nvm_read_chunk 0 35198 NULL
98115 +uprobe_get_swbp_addr_35201 uprobe_get_swbp_addr 0 35201 NULL
98116 +unix_stream_recvmsg_35210 unix_stream_recvmsg 4 35210 NULL
98117 +_osd_req_alist_elem_size_35216 _osd_req_alist_elem_size 0-2 35216 NULL
98118 +striped_read_35218 striped_read 0-2-8-3 35218 NULL nohasharray
98119 +security_key_getsecurity_35218 security_key_getsecurity 0 35218 &striped_read_35218
98120 +rx_rx_cmplt_task_read_35226 rx_rx_cmplt_task_read 3 35226 NULL nohasharray
98121 +video_register_device_no_warn_35226 video_register_device_no_warn 3 35226 &rx_rx_cmplt_task_read_35226
98122 +gfn_to_page_many_atomic_35234 gfn_to_page_many_atomic 2 35234 NULL
98123 +set_fd_set_35249 set_fd_set 1 35249 NULL
98124 +ioapic_setup_resources_35255 ioapic_setup_resources 1 35255 NULL
98125 +dma_show_regs_35266 dma_show_regs 3 35266 NULL
98126 +irda_recvmsg_stream_35280 irda_recvmsg_stream 4 35280 NULL
98127 +i2o_block_end_request_35282 i2o_block_end_request 3 35282 NULL
98128 +isr_rx_rdys_read_35283 isr_rx_rdys_read 3 35283 NULL
98129 +brcmf_sdio_forensic_read_35311 brcmf_sdio_forensic_read 3 35311 NULL nohasharray
98130 +__btrfs_buffered_write_35311 __btrfs_buffered_write 3 35311 &brcmf_sdio_forensic_read_35311
98131 +tracing_read_pipe_35312 tracing_read_pipe 3 35312 NULL
98132 +sys_setsockopt_35320 sys_setsockopt 5 35320 NULL
98133 +irq_domain_disassociate_many_35325 irq_domain_disassociate_many 2-3 35325 NULL
98134 +fallback_on_nodma_alloc_35332 fallback_on_nodma_alloc 2 35332 NULL
98135 +pskb_network_may_pull_35336 pskb_network_may_pull 2 35336 NULL
98136 +ieee80211_if_fmt_ap_power_level_35347 ieee80211_if_fmt_ap_power_level 3 35347 NULL
98137 +nouveau_devinit_create__35348 nouveau_devinit_create_ 4 35348 NULL
98138 +hpi_alloc_control_cache_35351 hpi_alloc_control_cache 1 35351 NULL
98139 +compat_filldir64_35354 compat_filldir64 3 35354 NULL
98140 +rawv6_send_hdrinc_35425 rawv6_send_hdrinc 3 35425 NULL
98141 +__set_test_and_free_35436 __set_test_and_free 2 35436 NULL
98142 +buffer_to_user_35439 buffer_to_user 3 35439 NULL
98143 +i915_wedged_read_35474 i915_wedged_read 3 35474 NULL
98144 +ecryptfs_get_zeroed_pages_35483 ecryptfs_get_zeroed_pages 0 35483 NULL
98145 +do_atm_ioctl_35519 do_atm_ioctl 3 35519 NULL
98146 +async_setkey_35521 async_setkey 3 35521 NULL
98147 +__filemap_fdatawrite_range_35528 __filemap_fdatawrite_range 0 35528 NULL
98148 +iwl_dbgfs_bt_traffic_read_35534 iwl_dbgfs_bt_traffic_read 3 35534 NULL
98149 +rxpipe_tx_xfr_host_int_trig_rx_data_read_35538 rxpipe_tx_xfr_host_int_trig_rx_data_read 3 35538 NULL
98150 +ibnl_put_attr_35541 ibnl_put_attr 3 35541 NULL
98151 +ieee80211_if_write_smps_35550 ieee80211_if_write_smps 3 35550 NULL
98152 +ext2_acl_from_disk_35580 ext2_acl_from_disk 2 35580 NULL
98153 +spk_msg_set_35586 spk_msg_set 3 35586 NULL
98154 +ReadZReg_35604 ReadZReg 0 35604 NULL
98155 +kernel_readv_35617 kernel_readv 3 35617 NULL
98156 +ixgbe_pci_sriov_configure_35624 ixgbe_pci_sriov_configure 2 35624 NULL
98157 +reiserfs_readpages_35629 reiserfs_readpages 4 35629 NULL
98158 +spi_register_board_info_35651 spi_register_board_info 2 35651 NULL
98159 +store_debug_level_35652 store_debug_level 3 35652 NULL
98160 +rdmaltWithLock_35669 rdmaltWithLock 0 35669 NULL
98161 +compat_sys_kexec_load_35674 compat_sys_kexec_load 2 35674 NULL
98162 +dm_table_create_35687 dm_table_create 3 35687 NULL
98163 +rds_page_copy_user_35691 rds_page_copy_user 4 35691 NULL
98164 +pci_enable_sriov_35745 pci_enable_sriov 2 35745 NULL
98165 +iwl_dbgfs_disable_ht40_read_35761 iwl_dbgfs_disable_ht40_read 3 35761 NULL
98166 +udf_alloc_i_data_35786 udf_alloc_i_data 2 35786 NULL
98167 +pvr2_hdw_cpufw_get_35824 pvr2_hdw_cpufw_get 0-4-2 35824 NULL
98168 +tx_tx_cmplt_read_35854 tx_tx_cmplt_read 3 35854 NULL
98169 +mthca_buf_alloc_35861 mthca_buf_alloc 2 35861 NULL
98170 +fls64_35862 fls64 0 35862 NULL
98171 +kvm_dirty_bitmap_bytes_35886 kvm_dirty_bitmap_bytes 0 35886 NULL
98172 +ieee80211_if_fmt_dot11MeshRetryTimeout_35890 ieee80211_if_fmt_dot11MeshRetryTimeout 3 35890 NULL
98173 +uwb_rc_cmd_done_35892 uwb_rc_cmd_done 4 35892 NULL
98174 +kernel_setsockopt_35913 kernel_setsockopt 5 35913 NULL
98175 +rbio_nr_pages_35916 rbio_nr_pages 0-1-2 35916 NULL
98176 +vol_cdev_compat_ioctl_35923 vol_cdev_compat_ioctl 3 35923 NULL
98177 +sctp_tsnmap_mark_35929 sctp_tsnmap_mark 2 35929 NULL
98178 +rx_defrag_init_called_read_35935 rx_defrag_init_called_read 3 35935 NULL
98179 +put_cmsg_compat_35937 put_cmsg_compat 4 35937 NULL
98180 +ext_rts51x_sd_execute_write_data_35971 ext_rts51x_sd_execute_write_data 9 35971 NULL
98181 +ceph_buffer_new_35974 ceph_buffer_new 1 35974 NULL
98182 +acl_alloc_35979 acl_alloc 1 35979 NULL
98183 +generic_file_aio_read_35987 generic_file_aio_read 0 35987 NULL
98184 +koneplus_sysfs_write_35993 koneplus_sysfs_write 6 35993 NULL
98185 +il3945_ucode_tx_stats_read_36016 il3945_ucode_tx_stats_read 3 36016 NULL
98186 +ubi_eba_write_leb_36029 ubi_eba_write_leb 5-6 36029 NULL
98187 +account_shadowed_36048 account_shadowed 2 36048 NULL
98188 +gpio_power_read_36059 gpio_power_read 3 36059 NULL
98189 +write_emulate_36065 write_emulate 2-4 36065 NULL
98190 +radeon_vm_num_pdes_36070 radeon_vm_num_pdes 0 36070 NULL
98191 +ieee80211_if_fmt_peer_36071 ieee80211_if_fmt_peer 3 36071 NULL
98192 +ext3_new_blocks_36073 ext3_new_blocks 3 36073 NULL
98193 +ieee80211_if_write_tsf_36077 ieee80211_if_write_tsf 3 36077 NULL
98194 +snd_pcm_plug_read_transfer_36080 snd_pcm_plug_read_transfer 0-3 36080 NULL
98195 +vga_arb_write_36112 vga_arb_write 3 36112 NULL
98196 +simple_xattr_alloc_36118 simple_xattr_alloc 2 36118 NULL
98197 +compat_ptrace_request_36131 compat_ptrace_request 3-4 36131 NULL
98198 +vmalloc_exec_36132 vmalloc_exec 1 36132 NULL
98199 +max8925_irq_domain_map_36133 max8925_irq_domain_map 2 36133 NULL
98200 +ext3_readpages_36144 ext3_readpages 4 36144 NULL
98201 +alloc_vm_area_36149 alloc_vm_area 1 36149 NULL
98202 +twl_set_36154 twl_set 2 36154 NULL
98203 +b1_alloc_card_36155 b1_alloc_card 1 36155 NULL
98204 +btrfs_file_extent_inline_len_36158 btrfs_file_extent_inline_len 0 36158 NULL
98205 +snd_korg1212_copy_from_36169 snd_korg1212_copy_from 6 36169 NULL
98206 +ubifs_read_nnode_36221 ubifs_read_nnode 0 36221 NULL
98207 +is_dirty_36223 is_dirty 2 36223 NULL
98208 +dma_alloc_attrs_36225 dma_alloc_attrs 0 36225 NULL
98209 +nfqnl_mangle_36226 nfqnl_mangle 4-2 36226 NULL
98210 +atomic_stats_read_36228 atomic_stats_read 3 36228 NULL
98211 +viafb_iga1_odev_proc_write_36241 viafb_iga1_odev_proc_write 3 36241 NULL
98212 +rproc_recovery_read_36245 rproc_recovery_read 3 36245 NULL
98213 +scrub_stripe_36248 scrub_stripe 5-4 36248 NULL
98214 +compat_sys_mbind_36256 compat_sys_mbind 5 36256 NULL
98215 +usb_buffer_alloc_36276 usb_buffer_alloc 2 36276 NULL
98216 +codec_reg_read_file_36280 codec_reg_read_file 3 36280 NULL
98217 +crypto_shash_digestsize_36284 crypto_shash_digestsize 0 36284 NULL
98218 +nouveau_cli_create_36293 nouveau_cli_create 3 36293 NULL
98219 +lpfc_debugfs_dif_err_read_36303 lpfc_debugfs_dif_err_read 3 36303 NULL
98220 +ad7879_spi_xfer_36311 ad7879_spi_xfer 3 36311 NULL
98221 +fuse_get_user_addr_36312 fuse_get_user_addr 0 36312 NULL
98222 +fat_compat_ioctl_filldir_36328 fat_compat_ioctl_filldir 3 36328 NULL
98223 +lc_create_36332 lc_create 4 36332 NULL
98224 +jbd2_journal_init_revoke_table_36336 jbd2_journal_init_revoke_table 1 36336 NULL
98225 +v9fs_file_readn_36353 v9fs_file_readn 4 36353 NULL nohasharray
98226 +xz_dec_lzma2_create_36353 xz_dec_lzma2_create 2 36353 &v9fs_file_readn_36353
98227 +to_sector_36361 to_sector 0-1 36361 NULL
98228 +tunables_read_36385 tunables_read 3 36385 NULL
98229 +afs_alloc_flat_call_36399 afs_alloc_flat_call 2-3 36399 NULL
98230 +sctp_tsnmap_init_36446 sctp_tsnmap_init 2 36446 NULL
98231 +alloc_etherdev_mqs_36450 alloc_etherdev_mqs 1 36450 NULL
98232 +b43_nphy_load_samples_36481 b43_nphy_load_samples 3 36481 NULL
98233 +tx_tx_checksum_result_read_36490 tx_tx_checksum_result_read 3 36490 NULL
98234 +__hwahc_op_set_ptk_36510 __hwahc_op_set_ptk 5 36510 NULL
98235 +mcam_v4l_read_36513 mcam_v4l_read 3 36513 NULL
98236 +get_param_l_36518 get_param_l 0 36518 NULL
98237 +ieee80211_if_read_fwded_frames_36520 ieee80211_if_read_fwded_frames 3 36520 NULL
98238 +lguest_setup_irq_36531 lguest_setup_irq 1 36531 NULL
98239 +crypto_aead_authsize_36537 crypto_aead_authsize 0 36537 NULL
98240 +cpu_type_read_36540 cpu_type_read 3 36540 NULL
98241 +get_entry_len_36549 get_entry_len 0 36549 NULL
98242 +__kfifo_to_user_36555 __kfifo_to_user 3 36555 NULL nohasharray
98243 +macvtap_do_read_36555 macvtap_do_read 4 36555 &__kfifo_to_user_36555
98244 +btrfs_get_token_64_36572 btrfs_get_token_64 0 36572 NULL
98245 +ssb_bus_scan_36578 ssb_bus_scan 2 36578 NULL
98246 +__erst_read_36579 __erst_read 0 36579 NULL
98247 +put_cmsg_36589 put_cmsg 4 36589 NULL
98248 +pcnet32_realloc_rx_ring_36598 pcnet32_realloc_rx_ring 3 36598 NULL
98249 +fat_ioctl_filldir_36621 fat_ioctl_filldir 3 36621 NULL
98250 +vxge_config_vpaths_36636 vxge_config_vpaths 0 36636 NULL
98251 +format_decode_36638 format_decode 0 36638 NULL
98252 +ced_ioctl_36647 ced_ioctl 2 36647 NULL
98253 +lpfc_idiag_extacc_alloc_get_36648 lpfc_idiag_extacc_alloc_get 0-3 36648 NULL
98254 +osd_req_list_collection_objects_36664 osd_req_list_collection_objects 5 36664 NULL
98255 +iscsi_host_alloc_36671 iscsi_host_alloc 2 36671 NULL
98256 +ptr_to_compat_36680 ptr_to_compat 0 36680 NULL
98257 +ext4_mb_discard_group_preallocations_36685 ext4_mb_discard_group_preallocations 2 36685 NULL
98258 +extract_icmp6_fields_36732 extract_icmp6_fields 2 36732 NULL
98259 +snd_rawmidi_kernel_read1_36740 snd_rawmidi_kernel_read1 4 36740 NULL
98260 +cxgbi_device_register_36746 cxgbi_device_register 1-2 36746 NULL
98261 +ps_poll_upsd_timeouts_read_36755 ps_poll_upsd_timeouts_read 3 36755 NULL
98262 +ip4ip6_err_36772 ip4ip6_err 5 36772 NULL
98263 +ptp_filter_init_36780 ptp_filter_init 2 36780 NULL
98264 +proc_fault_inject_read_36802 proc_fault_inject_read 3 36802 NULL
98265 +hiddev_ioctl_36816 hiddev_ioctl 2 36816 NULL
98266 +int_hardware_entry_36833 int_hardware_entry 3 36833 NULL
98267 +fc_change_queue_depth_36841 fc_change_queue_depth 2 36841 NULL
98268 +keyctl_describe_key_36853 keyctl_describe_key 3 36853 NULL
98269 +cm_write_36858 cm_write 3 36858 NULL
98270 +tx_tx_data_programmed_read_36871 tx_tx_data_programmed_read 3 36871 NULL
98271 +svc_setsockopt_36876 svc_setsockopt 5 36876 NULL
98272 +raid56_parity_write_36877 raid56_parity_write 5 36877 NULL
98273 +__btrfs_map_block_36883 __btrfs_map_block 3 36883 NULL
98274 +ib_ucm_alloc_data_36885 ib_ucm_alloc_data 3 36885 NULL
98275 +selinux_inode_notifysecctx_36896 selinux_inode_notifysecctx 3 36896 NULL
98276 +OS_kmalloc_36909 OS_kmalloc 1 36909 NULL
98277 +build_key_36931 build_key 1 36931 NULL
98278 +crypto_blkcipher_ivsize_36944 crypto_blkcipher_ivsize 0 36944 NULL
98279 +write_leb_36957 write_leb 5 36957 NULL
98280 +ntfs_external_attr_find_36963 ntfs_external_attr_find 0 36963 NULL
98281 +sparse_early_mem_maps_alloc_node_36971 sparse_early_mem_maps_alloc_node 4 36971 NULL
98282 +drbd_new_dev_size_36998 drbd_new_dev_size 0-3 36998 NULL
98283 +auok190xfb_write_37001 auok190xfb_write 3 37001 NULL
98284 +setxattr_37006 setxattr 4 37006 NULL
98285 +qp_broker_create_37053 qp_broker_create 6-5 37053 NULL nohasharray
98286 +ieee80211_if_read_drop_unencrypted_37053 ieee80211_if_read_drop_unencrypted 3 37053 &qp_broker_create_37053
98287 +parse_command_37079 parse_command 2 37079 NULL
98288 +pipeline_cs_rx_packet_in_read_37089 pipeline_cs_rx_packet_in_read 3 37089 NULL
98289 +tun_get_user_37094 tun_get_user 5 37094 NULL
98290 +has_wrprotected_page_37123 has_wrprotected_page 2-3 37123 NULL
98291 +snd_hda_get_conn_list_37132 snd_hda_get_conn_list 0 37132 NULL
98292 +msg_word_37164 msg_word 0 37164 NULL
98293 +can_set_xattr_37182 can_set_xattr 4 37182 NULL
98294 +crypto_shash_descsize_37212 crypto_shash_descsize 0 37212 NULL
98295 +regmap_access_read_file_37223 regmap_access_read_file 3 37223 NULL
98296 +__do_replace_37227 __do_replace 5 37227 NULL
98297 +rx_filter_dup_filter_read_37238 rx_filter_dup_filter_read 3 37238 NULL
98298 +prot_queue_del_37258 prot_queue_del 0 37258 NULL
98299 +ath6kl_wmi_set_ie_cmd_37260 ath6kl_wmi_set_ie_cmd 6 37260 NULL
98300 +exofs_max_io_pages_37263 exofs_max_io_pages 0-2 37263 NULL
98301 +nested_svm_map_37268 nested_svm_map 2 37268 NULL
98302 +c101_run_37279 c101_run 2 37279 NULL
98303 +srp_target_alloc_37288 srp_target_alloc 3 37288 NULL
98304 +ieee80211_if_read_power_mode_37305 ieee80211_if_read_power_mode 3 37305 NULL
98305 +jffs2_write_dirent_37311 jffs2_write_dirent 5 37311 NULL
98306 +send_msg_37323 send_msg 4 37323 NULL
98307 +brcmf_sdbrcm_membytes_37324 brcmf_sdbrcm_membytes 3-5 37324 NULL
98308 +l2cap_create_connless_pdu_37327 l2cap_create_connless_pdu 3 37327 NULL
98309 +scsi_mode_select_37330 scsi_mode_select 6 37330 NULL
98310 +rxrpc_server_sendmsg_37331 rxrpc_server_sendmsg 4 37331 NULL
98311 +security_inode_getsecurity_37354 security_inode_getsecurity 0 37354 NULL
98312 +iommu_num_pages_37391 iommu_num_pages 0-1-3-2 37391 NULL
98313 +sys_getxattr_37418 sys_getxattr 4 37418 NULL
98314 +hci_sock_sendmsg_37420 hci_sock_sendmsg 4 37420 NULL
98315 +acpi_os_allocate_zeroed_37422 acpi_os_allocate_zeroed 1 37422 NULL nohasharray
98316 +find_next_bit_37422 find_next_bit 0-2-3 37422 &acpi_os_allocate_zeroed_37422
98317 +tty_insert_flip_string_fixed_flag_37428 tty_insert_flip_string_fixed_flag 4 37428 NULL
98318 +iwl_print_last_event_logs_37433 iwl_print_last_event_logs 0-7-9 37433 NULL
98319 +tcp_established_options_37450 tcp_established_options 0 37450 NULL
98320 +brcmf_sdio_dump_console_37455 brcmf_sdio_dump_console 4 37455 NULL
98321 +__remove_37457 __remove 2 37457 NULL
98322 +ufs_data_ptr_to_cpu_37475 ufs_data_ptr_to_cpu 0 37475 NULL
98323 +get_est_timing_37484 get_est_timing 0 37484 NULL
98324 +kmem_realloc_37489 kmem_realloc 2 37489 NULL
98325 +kvm_vcpu_compat_ioctl_37500 kvm_vcpu_compat_ioctl 3 37500 NULL
98326 +vmalloc_32_user_37519 vmalloc_32_user 1 37519 NULL
98327 +fault_inject_read_37534 fault_inject_read 3 37534 NULL
98328 +hdr_size_37536 hdr_size 0 37536 NULL
98329 +a2p_37544 a2p 0-1 37544 NULL
98330 +sep_create_dcb_dmatables_context_37551 sep_create_dcb_dmatables_context 6 37551 NULL nohasharray
98331 +nf_nat_mangle_tcp_packet_37551 nf_nat_mangle_tcp_packet 6-8 37551 &sep_create_dcb_dmatables_context_37551
98332 +xhci_alloc_streams_37586 xhci_alloc_streams 5 37586 NULL
98333 +mlx4_get_mgm_entry_size_37607 mlx4_get_mgm_entry_size 0 37607 NULL
98334 +kvm_read_guest_page_mmu_37611 kvm_read_guest_page_mmu 6-3 37611 NULL
98335 +policy_residency_37629 policy_residency 0 37629 NULL
98336 +check_pt_base_37635 check_pt_base 3 37635 NULL
98337 +alloc_fd_37637 alloc_fd 1 37637 NULL
98338 +bio_copy_user_iov_37660 bio_copy_user_iov 4 37660 NULL
98339 +rfcomm_sock_sendmsg_37661 rfcomm_sock_sendmsg 4 37661 NULL nohasharray
98340 +vmw_framebuffer_dmabuf_dirty_37661 vmw_framebuffer_dmabuf_dirty 6 37661 &rfcomm_sock_sendmsg_37661
98341 +lnw_gpio_to_irq_37665 lnw_gpio_to_irq 2 37665 NULL
98342 +ieee80211_if_read_rc_rateidx_mcs_mask_2ghz_37675 ieee80211_if_read_rc_rateidx_mcs_mask_2ghz 3 37675 NULL
98343 +regmap_map_read_file_37685 regmap_map_read_file 3 37685 NULL
98344 +nametbl_header_37698 nametbl_header 2 37698 NULL
98345 +__le32_to_cpup_37702 __le32_to_cpup 0 37702 NULL
98346 +dm_thin_remove_block_37724 dm_thin_remove_block 2 37724 NULL
98347 +find_active_uprobe_37733 find_active_uprobe 1 37733 NULL
98348 +read_enabled_file_bool_37744 read_enabled_file_bool 3 37744 NULL
98349 +ocfs2_duplicate_clusters_by_jbd_37749 ocfs2_duplicate_clusters_by_jbd 6-4-5 37749 NULL
98350 +ocfs2_control_cfu_37750 ocfs2_control_cfu 2 37750 NULL
98351 +ipath_cdev_init_37752 ipath_cdev_init 1 37752 NULL
98352 +dccp_setsockopt_cscov_37766 dccp_setsockopt_cscov 2 37766 NULL
98353 +dma_pte_addr_37784 dma_pte_addr 0 37784 NULL
98354 +il4965_rs_sta_dbgfs_rate_scale_data_read_37792 il4965_rs_sta_dbgfs_rate_scale_data_read 3 37792 NULL
98355 +smk_read_logging_37804 smk_read_logging 3 37804 NULL
98356 +deny_write_access_37813 deny_write_access 0 37813 NULL
98357 +rx_decrypt_key_not_found_read_37820 rx_decrypt_key_not_found_read 3 37820 NULL
98358 +bitmap_find_next_zero_area_37827 bitmap_find_next_zero_area 2-3-5-4 37827 NULL
98359 +o2hb_debug_read_37851 o2hb_debug_read 3 37851 NULL
98360 +xfs_dir2_block_to_sf_37868 xfs_dir2_block_to_sf 3 37868 NULL
98361 +sys_setxattr_37880 sys_setxattr 4 37880 NULL
98362 +dvb_net_sec_37884 dvb_net_sec 3 37884 NULL
98363 +max77686_irq_domain_map_37897 max77686_irq_domain_map 2 37897 NULL
98364 +compat_sys_rt_sigpending_37899 compat_sys_rt_sigpending 2 37899 NULL
98365 +tipc_link_send_sections_fast_37920 tipc_link_send_sections_fast 4 37920 NULL
98366 +pkt_alloc_packet_data_37928 pkt_alloc_packet_data 1 37928 NULL
98367 +read_rbu_packet_size_37939 read_rbu_packet_size 6 37939 NULL
98368 +fifo_alloc_37961 fifo_alloc 1 37961 NULL
98369 +ext3_free_blocks_sb_37967 ext3_free_blocks_sb 3-4 37967 NULL
98370 +rds_rdma_extra_size_37990 rds_rdma_extra_size 0 37990 NULL
98371 +persistent_ram_old_size_37997 persistent_ram_old_size 0 37997 NULL
98372 +vfs_readv_38011 vfs_readv 3 38011 NULL
98373 +aggr_recv_addba_req_evt_38037 aggr_recv_addba_req_evt 4 38037 NULL
98374 +klsi_105_prepare_write_buffer_38044 klsi_105_prepare_write_buffer 3 38044 NULL nohasharray
98375 +il_dbgfs_chain_noise_read_38044 il_dbgfs_chain_noise_read 3 38044 &klsi_105_prepare_write_buffer_38044
98376 +_xfs_buf_alloc_38058 _xfs_buf_alloc 3 38058 NULL nohasharray
98377 +is_discarded_38058 is_discarded 2 38058 &_xfs_buf_alloc_38058
98378 +nsm_create_handle_38060 nsm_create_handle 4 38060 NULL
98379 +alloc_ltalkdev_38071 alloc_ltalkdev 1 38071 NULL
98380 +xfs_buf_readahead_map_38081 xfs_buf_readahead_map 3 38081 NULL
98381 +uwb_mac_addr_print_38085 uwb_mac_addr_print 2 38085 NULL
98382 +request_key_auth_new_38092 request_key_auth_new 3 38092 NULL
98383 +proc_self_readlink_38094 proc_self_readlink 3 38094 NULL
98384 +ep0_read_38095 ep0_read 3 38095 NULL
98385 +sk_wmem_schedule_38096 sk_wmem_schedule 2 38096 NULL
98386 +rbd_obj_read_sync_38098 rbd_obj_read_sync 3-4 38098 NULL
98387 +snd_pcm_oss_write_38108 snd_pcm_oss_write 3 38108 NULL
98388 +vmw_kms_present_38130 vmw_kms_present 9 38130 NULL
98389 +__ntfs_copy_from_user_iovec_inatomic_38153 __ntfs_copy_from_user_iovec_inatomic 3-4 38153 NULL
98390 +kvm_clear_guest_38164 kvm_clear_guest 3-2 38164 NULL
98391 +cdev_add_38176 cdev_add 2-3 38176 NULL
98392 +brcmf_sdcard_recv_buf_38179 brcmf_sdcard_recv_buf 6 38179 NULL
98393 +rt2x00debug_write_rf_38195 rt2x00debug_write_rf 3 38195 NULL
98394 +get_ucode_user_38202 get_ucode_user 3 38202 NULL
98395 +ext3_new_block_38208 ext3_new_block 3 38208 NULL
98396 +stmpe_gpio_irq_map_38222 stmpe_gpio_irq_map 3 38222 NULL
98397 +osd_req_list_partition_collections_38223 osd_req_list_partition_collections 5 38223 NULL
98398 +palmas_gpio_to_irq_38235 palmas_gpio_to_irq 2 38235 NULL
98399 +vhost_net_compat_ioctl_38237 vhost_net_compat_ioctl 3 38237 NULL
98400 +_ipw_read_reg32_38245 _ipw_read_reg32 0 38245 NULL
98401 +from_dblock_38256 from_dblock 0-1 38256 NULL
98402 +vmci_qp_broker_set_page_store_38260 vmci_qp_broker_set_page_store 2-3 38260 NULL
98403 +ieee80211_if_read_auto_open_plinks_38268 ieee80211_if_read_auto_open_plinks 3 38268 NULL nohasharray
98404 +mthca_alloc_icm_table_38268 mthca_alloc_icm_table 4-3 38268 &ieee80211_if_read_auto_open_plinks_38268
98405 +xfs_bmbt_to_bmdr_38275 xfs_bmbt_to_bmdr 3 38275 NULL nohasharray
98406 +xfs_bmdr_to_bmbt_38275 xfs_bmdr_to_bmbt 5 38275 &xfs_bmbt_to_bmdr_38275
98407 +ftdi_process_packet_38281 ftdi_process_packet 4 38281 NULL nohasharray
98408 +swiotlb_sync_single_for_cpu_38281 swiotlb_sync_single_for_cpu 2 38281 &ftdi_process_packet_38281
98409 +gpa_to_gfn_38291 gpa_to_gfn 0-1 38291 NULL
98410 +zd_mac_rx_38296 zd_mac_rx 3 38296 NULL
98411 +isr_rx_headers_read_38325 isr_rx_headers_read 3 38325 NULL
98412 +ida_simple_get_38326 ida_simple_get 2 38326 NULL
98413 +__snd_gf1_look8_38333 __snd_gf1_look8 0 38333 NULL
98414 +pyra_sysfs_write_38370 pyra_sysfs_write 6 38370 NULL
98415 +dn_sendmsg_38390 dn_sendmsg 4 38390 NULL
98416 +get_valid_node_allowed_38412 get_valid_node_allowed 1-0 38412 NULL
98417 +ocfs2_which_cluster_group_38413 ocfs2_which_cluster_group 2 38413 NULL
98418 +ht_destroy_irq_38418 ht_destroy_irq 1 38418 NULL
98419 +ieee80211_if_read_dtim_count_38419 ieee80211_if_read_dtim_count 3 38419 NULL
98420 +asix_write_cmd_async_38420 asix_write_cmd_async 5 38420 NULL
98421 +pcnet32_realloc_tx_ring_38428 pcnet32_realloc_tx_ring 3 38428 NULL
98422 +pmcraid_copy_sglist_38431 pmcraid_copy_sglist 3 38431 NULL
98423 +kvm_write_guest_38454 kvm_write_guest 4-2 38454 NULL
98424 +i915_min_freq_read_38470 i915_min_freq_read 3 38470 NULL
98425 +kvm_arch_setup_async_pf_38481 kvm_arch_setup_async_pf 3 38481 NULL
98426 +blk_end_bidi_request_38482 blk_end_bidi_request 3-4 38482 NULL
98427 +dev_names_read_38509 dev_names_read 3 38509 NULL
98428 +iscsi_create_iface_38510 iscsi_create_iface 5 38510 NULL
98429 +event_rx_mismatch_read_38518 event_rx_mismatch_read 3 38518 NULL
98430 +set_queue_count_38519 set_queue_count 0 38519 NULL
98431 +mlx4_ib_db_map_user_38529 mlx4_ib_db_map_user 2 38529 NULL
98432 +ubifs_idx_node_sz_38546 ubifs_idx_node_sz 0-2 38546 NULL
98433 +btrfs_discard_extent_38547 btrfs_discard_extent 2 38547 NULL
98434 +irda_sendmsg_dgram_38563 irda_sendmsg_dgram 4 38563 NULL
98435 +il4965_rs_sta_dbgfs_scale_table_read_38564 il4965_rs_sta_dbgfs_scale_table_read 3 38564 NULL
98436 +_ipw_read32_38565 _ipw_read32 0 38565 NULL
98437 +snd_nm256_playback_copy_38567 snd_nm256_playback_copy 5-3 38567 NULL
98438 +copy_ctl_value_to_user_38587 copy_ctl_value_to_user 4 38587 NULL
98439 +cosa_net_setup_rx_38594 cosa_net_setup_rx 2 38594 NULL
98440 +compat_sys_ptrace_38595 compat_sys_ptrace 3-4 38595 NULL
98441 +icn_writecmd_38629 icn_writecmd 2 38629 NULL
98442 +ext2_readpages_38640 ext2_readpages 4 38640 NULL
98443 +cma_create_area_38642 cma_create_area 2 38642 NULL
98444 +audit_init_entry_38644 audit_init_entry 1 38644 NULL
98445 +qp_broker_alloc_38646 qp_broker_alloc 5-6 38646 NULL
98446 +mmc_send_cxd_data_38655 mmc_send_cxd_data 5 38655 NULL
98447 +nouveau_instmem_create__38664 nouveau_instmem_create_ 4 38664 NULL
98448 +cfg80211_send_disassoc_38678 cfg80211_send_disassoc 3 38678 NULL
98449 +iscsit_dump_data_payload_38683 iscsit_dump_data_payload 2 38683 NULL
98450 +ext4_wait_block_bitmap_38695 ext4_wait_block_bitmap 2 38695 NULL
98451 +rbio_add_io_page_38700 rbio_add_io_page 6 38700 NULL
98452 +find_next_usable_block_38716 find_next_usable_block 1-3 38716 NULL
98453 +alloc_trace_probe_38720 alloc_trace_probe 6 38720 NULL
98454 +phys_to_virt_38757 phys_to_virt 0-1 38757 NULL
98455 +udf_readpages_38761 udf_readpages 4 38761 NULL
98456 +iwl_dbgfs_thermal_throttling_read_38779 iwl_dbgfs_thermal_throttling_read 3 38779 NULL
98457 +snd_gus_dram_write_38784 snd_gus_dram_write 4 38784 NULL
98458 +err_decode_38804 err_decode 2 38804 NULL
98459 +ipv6_renew_option_38813 ipv6_renew_option 3 38813 NULL
98460 +sys_select_38827 sys_select 1 38827 NULL
98461 +b43_txhdr_size_38832 b43_txhdr_size 0 38832 NULL
98462 +direct_entry_38836 direct_entry 3 38836 NULL
98463 +compat_udp_setsockopt_38840 compat_udp_setsockopt 5 38840 NULL
98464 +interfaces_38859 interfaces 2 38859 NULL
98465 +pci_msix_table_size_38867 pci_msix_table_size 0 38867 NULL
98466 +sizeof_gpio_leds_priv_38882 sizeof_gpio_leds_priv 0-1 38882 NULL
98467 +dbgfs_state_38894 dbgfs_state 3 38894 NULL
98468 +f2fs_xattr_set_acl_38895 f2fs_xattr_set_acl 4 38895 NULL
98469 +process_bulk_data_command_38906 process_bulk_data_command 4 38906 NULL
98470 +ext3_trim_all_free_38929 ext3_trim_all_free 3-4-2 38929 NULL
98471 +sbp_count_se_tpg_luns_38943 sbp_count_se_tpg_luns 0 38943 NULL
98472 +__ath6kl_wmi_send_mgmt_cmd_38971 __ath6kl_wmi_send_mgmt_cmd 7 38971 NULL
98473 +usb_maxpacket_38977 usb_maxpacket 0 38977 NULL
98474 +OSDSetBlock_38986 OSDSetBlock 4-2 38986 NULL
98475 +udf_new_block_38999 udf_new_block 4 38999 NULL
98476 +get_nodes_39012 get_nodes 3 39012 NULL
98477 +twl6030_interrupt_unmask_39013 twl6030_interrupt_unmask 2 39013 NULL
98478 +acpi_install_gpe_block_39031 acpi_install_gpe_block 4 39031 NULL
98479 +_zd_iowrite32v_async_locked_39034 _zd_iowrite32v_async_locked 3 39034 NULL
98480 +line6_midibuf_read_39067 line6_midibuf_read 0-3 39067 NULL
98481 +ext4_init_block_bitmap_39071 ext4_init_block_bitmap 3 39071 NULL
98482 +tomoyo_truncate_39105 tomoyo_truncate 0 39105 NULL
98483 +__kfifo_to_user_r_39123 __kfifo_to_user_r 3 39123 NULL
98484 +ea_foreach_39133 ea_foreach 0 39133 NULL
98485 +generic_permission_39150 generic_permission 0 39150 NULL
98486 +alloc_ring_39151 alloc_ring 2-4 39151 NULL
98487 +proc_coredump_filter_read_39153 proc_coredump_filter_read 3 39153 NULL
98488 +create_bounce_buffer_39155 create_bounce_buffer 3 39155 NULL
98489 +ext3_xattr_check_names_39174 ext3_xattr_check_names 0 39174 NULL
98490 +init_list_set_39188 init_list_set 2-3 39188 NULL
98491 +ubi_more_update_data_39189 ubi_more_update_data 4 39189 NULL
98492 +qcam_read_bytes_39205 qcam_read_bytes 0 39205 NULL
98493 +qla4_82xx_pci_mem_read_direct_39208 qla4_82xx_pci_mem_read_direct 2 39208 NULL
98494 +vfio_group_fops_compat_ioctl_39219 vfio_group_fops_compat_ioctl 3 39219 NULL
98495 +ivtv_v4l2_write_39226 ivtv_v4l2_write 3 39226 NULL
98496 +batadv_tt_response_fill_table_39236 batadv_tt_response_fill_table 1 39236 NULL
98497 +posix_acl_to_xattr_39237 posix_acl_to_xattr 0 39237 NULL
98498 +drm_order_39244 drm_order 0 39244 NULL
98499 +r128_compat_ioctl_39250 r128_compat_ioctl 2 39250 NULL nohasharray
98500 +pwr_cont_miss_bcns_spread_read_39250 pwr_cont_miss_bcns_spread_read 3 39250 &r128_compat_ioctl_39250
98501 +__skb_cow_39254 __skb_cow 2 39254 NULL
98502 +ath6kl_wmi_set_appie_cmd_39266 ath6kl_wmi_set_appie_cmd 5 39266 NULL
98503 +rx_filter_protection_filter_read_39282 rx_filter_protection_filter_read 3 39282 NULL
98504 +__vmalloc_node_39308 __vmalloc_node 1 39308 NULL
98505 +__cfg80211_connect_result_39326 __cfg80211_connect_result 4-6 39326 NULL
98506 +wimax_msg_alloc_39343 wimax_msg_alloc 4 39343 NULL
98507 +__cfg80211_send_deauth_39344 __cfg80211_send_deauth 3 39344 NULL
98508 +__copy_from_user_nocache_39351 __copy_from_user_nocache 3 39351 NULL
98509 +ide_complete_rq_39354 ide_complete_rq 3 39354 NULL
98510 +do_write_log_from_user_39362 do_write_log_from_user 3 39362 NULL
98511 +vortex_wtdma_getlinearpos_39371 vortex_wtdma_getlinearpos 0 39371 NULL
98512 +regmap_name_read_file_39379 regmap_name_read_file 3 39379 NULL
98513 +fnic_trace_debugfs_read_39380 fnic_trace_debugfs_read 3 39380 NULL
98514 +ps_poll_ps_poll_utilization_read_39383 ps_poll_ps_poll_utilization_read 3 39383 NULL
98515 +__send_to_port_39386 __send_to_port 3 39386 NULL
98516 +user_power_read_39414 user_power_read 3 39414 NULL
98517 +alloc_agpphysmem_i8xx_39427 alloc_agpphysmem_i8xx 1 39427 NULL
98518 +sys_semop_39457 sys_semop 3 39457 NULL
98519 +setkey_unaligned_39474 setkey_unaligned 3 39474 NULL
98520 +do_get_mempolicy_39485 do_get_mempolicy 3 39485 NULL
98521 +ieee80211_if_fmt_dot11MeshHWMPmaxPREQretries_39499 ieee80211_if_fmt_dot11MeshHWMPmaxPREQretries 3 39499 NULL
98522 +atomic64_read_unchecked_39505 atomic64_read_unchecked 0 39505 NULL
98523 +int_proc_write_39542 int_proc_write 3 39542 NULL
98524 +pp_write_39554 pp_write 3 39554 NULL
98525 +ol_dqblk_block_39558 ol_dqblk_block 0-3-2 39558 NULL
98526 +datablob_format_39571 datablob_format 2 39571 NULL nohasharray
98527 +ieee80211_if_read_fwded_mcast_39571 ieee80211_if_read_fwded_mcast 3 39571 &datablob_format_39571
98528 +handle_response_icmp_39574 handle_response_icmp 7 39574 NULL
98529 +mtdchar_compat_ioctl_39602 mtdchar_compat_ioctl 3 39602 NULL
98530 +n_tty_compat_ioctl_helper_39605 n_tty_compat_ioctl_helper 4 39605 NULL
98531 +ext_depth_39607 ext_depth 0 39607 NULL
98532 +nfs_idmap_get_key_39616 nfs_idmap_get_key 2 39616 NULL
98533 +sdio_readb_39618 sdio_readb 0 39618 NULL
98534 +set_dev_class_39645 set_dev_class 4 39645 NULL nohasharray
98535 +dm_exception_table_init_39645 dm_exception_table_init 2 39645 &set_dev_class_39645
98536 +snd_rme32_capture_copy_39653 snd_rme32_capture_copy 5 39653 NULL
98537 +tcp_try_rmem_schedule_39657 tcp_try_rmem_schedule 3 39657 NULL nohasharray
98538 +prism2_info_hostscanresults_39657 prism2_info_hostscanresults 3 39657 &tcp_try_rmem_schedule_39657
98539 +kvm_read_guest_cached_39666 kvm_read_guest_cached 4 39666 NULL
98540 +v4l_stk_read_39672 v4l_stk_read 3 39672 NULL
98541 +hsc_msg_len_get_39673 hsc_msg_len_get 0 39673 NULL
98542 +do_surface_dirty_sou_39678 do_surface_dirty_sou 7 39678 NULL
98543 +ftrace_pid_write_39710 ftrace_pid_write 3 39710 NULL
98544 +tcf_csum_ipv4_tcp_39713 tcf_csum_ipv4_tcp 4 39713 NULL
98545 +remap_to_origin_clear_discard_39767 remap_to_origin_clear_discard 3 39767 NULL
98546 +ocfs2_pages_per_cluster_39790 ocfs2_pages_per_cluster 0 39790 NULL
98547 +crypto_ablkcipher_blocksize_39811 crypto_ablkcipher_blocksize 0 39811 NULL
98548 +security_inode_listsecurity_39812 security_inode_listsecurity 0 39812 NULL
98549 +snd_pcm_oss_writev3_39818 snd_pcm_oss_writev3 3 39818 NULL
98550 +sys_migrate_pages_39825 sys_migrate_pages 2 39825 NULL
98551 +get_priv_size_39828 get_priv_size 0-1 39828 NULL
98552 +pkt_add_39897 pkt_add 3 39897 NULL
98553 +read_file_modal_eeprom_39909 read_file_modal_eeprom 3 39909 NULL
98554 +gen_pool_add_virt_39913 gen_pool_add_virt 4 39913 NULL
98555 +dw210x_op_rw_39915 dw210x_op_rw 6 39915 NULL
98556 +aes_encrypt_interrupt_read_39919 aes_encrypt_interrupt_read 3 39919 NULL
98557 +exofs_read_kern_39921 exofs_read_kern 6 39921 NULL nohasharray
98558 +oom_score_adj_read_39921 oom_score_adj_read 3 39921 &exofs_read_kern_39921
98559 +__spi_async_39932 __spi_async 0 39932 NULL
98560 +__get_order_39935 __get_order 0 39935 NULL
98561 +error_error_frame_read_39947 error_error_frame_read 3 39947 NULL nohasharray
98562 +fwnet_pd_new_39947 fwnet_pd_new 4 39947 &error_error_frame_read_39947
98563 +tty_prepare_flip_string_39955 tty_prepare_flip_string 3 39955 NULL
98564 +dma_push_rx_39973 dma_push_rx 2 39973 NULL
98565 +broadsheetfb_write_39976 broadsheetfb_write 3 39976 NULL
98566 +mthca_array_init_39987 mthca_array_init 2 39987 NULL
98567 +xen_hvm_config_40018 xen_hvm_config 2 40018 NULL
98568 +nf_nat_icmpv6_reply_translation_40023 nf_nat_icmpv6_reply_translation 5 40023 NULL nohasharray
98569 +ivtvfb_write_40023 ivtvfb_write 3 40023 &nf_nat_icmpv6_reply_translation_40023
98570 +ea_foreach_i_40028 ea_foreach_i 0 40028 NULL
98571 +datablob_hmac_append_40038 datablob_hmac_append 3 40038 NULL
98572 +regmap_add_irq_chip_40042 regmap_add_irq_chip 4 40042 NULL
98573 +add_tty_40055 add_tty 1 40055 NULL nohasharray
98574 +l2cap_create_iframe_pdu_40055 l2cap_create_iframe_pdu 3 40055 &add_tty_40055
98575 +atomic_xchg_40070 atomic_xchg 0 40070 NULL
98576 +gen_pool_first_fit_40110 gen_pool_first_fit 2-3-4 40110 NULL
98577 +sctp_setsockopt_delayed_ack_40129 sctp_setsockopt_delayed_ack 3 40129 NULL
98578 +rx_rx_frame_checksum_read_40140 rx_rx_frame_checksum_read 3 40140 NULL
98579 +iwch_alloc_fastreg_pbl_40153 iwch_alloc_fastreg_pbl 2 40153 NULL
98580 +pt_write_40159 pt_write 3 40159 NULL
98581 +scsi_sg_count_40182 scsi_sg_count 0 40182 NULL
98582 +ipr_alloc_ucode_buffer_40199 ipr_alloc_ucode_buffer 1 40199 NULL nohasharray
98583 +devnode_find_40199 devnode_find 3-2 40199 &ipr_alloc_ucode_buffer_40199
98584 +allocate_probes_40204 allocate_probes 1 40204 NULL
98585 +compat_put_long_40214 compat_put_long 1 40214 NULL
98586 +au0828_v4l2_read_40220 au0828_v4l2_read 3 40220 NULL
98587 +osst_read_40237 osst_read 3 40237 NULL
98588 +lpage_info_slot_40243 lpage_info_slot 1-3 40243 NULL
98589 +ocfs2_zero_extend_get_range_40248 ocfs2_zero_extend_get_range 4 40248 NULL
98590 +of_get_child_count_40254 of_get_child_count 0 40254 NULL
98591 +rs_sta_dbgfs_scale_table_read_40262 rs_sta_dbgfs_scale_table_read 3 40262 NULL
98592 +usbnet_read_cmd_40275 usbnet_read_cmd 7 40275 NULL
98593 +rx_xfr_hint_trig_read_40283 rx_xfr_hint_trig_read 3 40283 NULL
98594 +crash_free_reserved_phys_range_40292 crash_free_reserved_phys_range 1 40292 NULL
98595 +ubi_io_write_data_40305 ubi_io_write_data 4-5 40305 NULL
98596 +batadv_tt_changes_fill_buff_40323 batadv_tt_changes_fill_buff 4 40323 NULL
98597 +ib_get_mad_data_offset_40336 ib_get_mad_data_offset 0 40336 NULL
98598 +mmio_read_40348 mmio_read 4 40348 NULL
98599 +usb_dump_interface_40353 usb_dump_interface 0 40353 NULL
98600 +ocfs2_release_clusters_40355 ocfs2_release_clusters 4 40355 NULL
98601 +event_rx_mem_empty_read_40363 event_rx_mem_empty_read 3 40363 NULL
98602 +ocfs2_check_range_for_refcount_40365 ocfs2_check_range_for_refcount 2-3 40365 NULL
98603 +fwnet_incoming_packet_40380 fwnet_incoming_packet 3 40380 NULL
98604 +brcmf_sdbrcm_get_image_40397 brcmf_sdbrcm_get_image 0-2 40397 NULL
98605 +atmel_rmem16_40450 atmel_rmem16 0 40450 NULL
98606 +tomoyo_update_policy_40458 tomoyo_update_policy 2 40458 NULL
98607 +zd_usb_scnprint_id_40459 zd_usb_scnprint_id 0-3 40459 NULL
98608 +batadv_hash_new_40491 batadv_hash_new 1 40491 NULL
98609 +devcgroup_inode_permission_40492 devcgroup_inode_permission 0 40492 NULL
98610 +tty_write_room_40495 tty_write_room 0 40495 NULL
98611 +persistent_ram_new_40501 persistent_ram_new 1-2 40501 NULL
98612 +sg_phys_40507 sg_phys 0 40507 NULL
98613 +TSS_checkhmac2_40520 TSS_checkhmac2 5-7 40520 NULL
98614 +ixgbe_dbg_reg_ops_read_40540 ixgbe_dbg_reg_ops_read 3 40540 NULL
98615 +ima_write_policy_40548 ima_write_policy 3 40548 NULL
98616 +esp_alloc_tmp_40558 esp_alloc_tmp 3-2 40558 NULL
98617 +ufs_inode_getfrag_40560 ufs_inode_getfrag 2-4 40560 NULL
98618 +skge_rx_get_40598 skge_rx_get 3 40598 NULL
98619 +get_priv_descr_and_size_40612 get_priv_descr_and_size 0 40612 NULL
98620 +bl_mark_sectors_init_40613 bl_mark_sectors_init 2-3 40613 NULL
98621 +cpuset_sprintf_cpulist_40627 cpuset_sprintf_cpulist 0 40627 NULL
98622 +twl4030_kpwrite_u8_40665 twl4030_kpwrite_u8 3 40665 NULL
98623 +__cfg80211_roamed_40668 __cfg80211_roamed 4-6 40668 NULL
98624 +pipeline_rx_complete_stat_fifo_int_read_40671 pipeline_rx_complete_stat_fifo_int_read 3 40671 NULL
98625 +fops_read_40672 fops_read 3 40672 NULL
98626 +alloc_rbio_40676 alloc_rbio 4 40676 NULL
98627 +videobuf_dma_init_user_locked_40678 videobuf_dma_init_user_locked 3 40678 NULL
98628 +nfc_hci_set_param_40697 nfc_hci_set_param 5 40697 NULL
98629 +__seq_open_private_40715 __seq_open_private 3 40715 NULL
98630 +fuse_readpages_40737 fuse_readpages 4 40737 NULL
98631 +xfs_iext_remove_direct_40744 xfs_iext_remove_direct 3 40744 NULL nohasharray
98632 +find_next_zero_bit_le_40744 find_next_zero_bit_le 0-2-3 40744 &xfs_iext_remove_direct_40744
98633 +security_inode_listxattr_40752 security_inode_listxattr 0 40752 NULL
98634 +fat_generic_compat_ioctl_40755 fat_generic_compat_ioctl 3 40755 NULL
98635 +card_send_command_40757 card_send_command 3 40757 NULL
98636 +ad1889_readl_40765 ad1889_readl 0 40765 NULL
98637 +pg_write_40766 pg_write 3 40766 NULL
98638 +show_list_40775 show_list 3 40775 NULL
98639 +kfifo_out_copy_r_40784 kfifo_out_copy_r 0-3 40784 NULL
98640 +bitmap_weight_40791 bitmap_weight 0-2 40791 NULL
98641 +pyra_sysfs_read_40795 pyra_sysfs_read 6 40795 NULL
98642 +netdev_alloc_skb_ip_align_40811 netdev_alloc_skb_ip_align 2 40811 NULL
98643 +nl80211_send_roamed_40825 nl80211_send_roamed 5-7 40825 NULL
98644 +__mlx4_qp_reserve_range_40847 __mlx4_qp_reserve_range 2-3 40847 NULL
98645 +ocfs2_zero_partial_clusters_40856 ocfs2_zero_partial_clusters 2-3 40856 NULL
98646 +v9fs_file_read_40858 v9fs_file_read 3 40858 NULL
98647 +read_file_queue_40895 read_file_queue 3 40895 NULL
98648 +waiters_read_40902 waiters_read 3 40902 NULL
98649 +isdn_add_channels_40905 isdn_add_channels 3 40905 NULL
98650 +gfs2_ea_find_40913 gfs2_ea_find 0 40913 NULL
98651 +vol_cdev_write_40915 vol_cdev_write 3 40915 NULL
98652 +snd_vx_create_40948 snd_vx_create 4 40948 NULL
98653 +skb_end_offset_40949 skb_end_offset 0 40949 NULL
98654 +wm8994_free_irq_40951 wm8994_free_irq 2 40951 NULL
98655 +rds_sendmsg_40976 rds_sendmsg 4 40976 NULL
98656 +il_dbgfs_fh_reg_read_40993 il_dbgfs_fh_reg_read 3 40993 NULL
98657 +mac80211_format_buffer_41010 mac80211_format_buffer 2 41010 NULL
98658 +mtd_block_isbad_41015 mtd_block_isbad 0 41015 NULL
98659 +_req_append_segment_41031 _req_append_segment 2 41031 NULL
98660 +mISDN_sock_sendmsg_41035 mISDN_sock_sendmsg 4 41035 NULL
98661 +ocfs2_xattr_index_block_find_41040 ocfs2_xattr_index_block_find 0 41040 NULL
98662 +vfs_listxattr_41062 vfs_listxattr 0 41062 NULL
98663 +cfg80211_inform_bss_frame_41078 cfg80211_inform_bss_frame 4 41078 NULL
98664 +roccat_read_41093 roccat_read 3 41093 NULL nohasharray
98665 +nvme_map_user_pages_41093 nvme_map_user_pages 3-4 41093 &roccat_read_41093
98666 +dma_attach_41094 dma_attach 5-6 41094 NULL
98667 +provide_user_output_41105 provide_user_output 3 41105 NULL
98668 +f_audio_buffer_alloc_41110 f_audio_buffer_alloc 1 41110 NULL
98669 +v4l2_ctrl_new_int_menu_41151 v4l2_ctrl_new_int_menu 4 41151 NULL
98670 +tx_frag_mpdu_alloc_failed_read_41167 tx_frag_mpdu_alloc_failed_read 3 41167 NULL
98671 +dvb_ca_write_41171 dvb_ca_write 3 41171 NULL
98672 +ol_quota_chunk_block_41177 ol_quota_chunk_block 0-2 41177 NULL
98673 +netif_get_num_default_rss_queues_41187 netif_get_num_default_rss_queues 0 41187 NULL
98674 +compat_sys_process_vm_writev_41194 compat_sys_process_vm_writev 3-5 41194 NULL
98675 +dfs_file_write_41196 dfs_file_write 3 41196 NULL
98676 +xfs_readdir_41200 xfs_readdir 3 41200 NULL
98677 +ocfs2_read_quota_block_41207 ocfs2_read_quota_block 2 41207 NULL
98678 +nfs_page_array_len_41219 nfs_page_array_len 0-2-1 41219 NULL
98679 +hiddev_compat_ioctl_41255 hiddev_compat_ioctl 2-3 41255 NULL
98680 +erst_read_41260 erst_read 0 41260 NULL
98681 +__fprog_create_41263 __fprog_create 2 41263 NULL
98682 +alloc_context_41283 alloc_context 1 41283 NULL
98683 +arch_gnttab_map_shared_41306 arch_gnttab_map_shared 3 41306 NULL
98684 +twl_change_queue_depth_41342 twl_change_queue_depth 2 41342 NULL
98685 +cnic_init_id_tbl_41354 cnic_init_id_tbl 2 41354 NULL
98686 +jbd2_alloc_41359 jbd2_alloc 1 41359 NULL
98687 +kmp_init_41373 kmp_init 2 41373 NULL
98688 +isr_commands_read_41398 isr_commands_read 3 41398 NULL
98689 +is_writethrough_io_41406 is_writethrough_io 3 41406 NULL
98690 +sys_flistxattr_41407 sys_flistxattr 3 41407 NULL
98691 +rx_defrag_decrypt_failed_read_41411 rx_defrag_decrypt_failed_read 3 41411 NULL
98692 +xfs_iext_add_41422 xfs_iext_add 3 41422 NULL
98693 +vsock_dev_compat_ioctl_41427 vsock_dev_compat_ioctl 3 41427 NULL
98694 +isdn_ppp_fill_rq_41428 isdn_ppp_fill_rq 2 41428 NULL
98695 +lbs_rdrf_read_41431 lbs_rdrf_read 3 41431 NULL
98696 +iio_device_alloc_41440 iio_device_alloc 1 41440 NULL
98697 +ntfs_file_buffered_write_41442 ntfs_file_buffered_write 4-6 41442 NULL
98698 +pcpu_build_alloc_info_41443 pcpu_build_alloc_info 1-2-3 41443 NULL
98699 +layout_leb_in_gaps_41470 layout_leb_in_gaps 0 41470 NULL
98700 +rt2x00debug_write_rfcsr_41473 rt2x00debug_write_rfcsr 3 41473 NULL
98701 +wep_interrupt_read_41492 wep_interrupt_read 3 41492 NULL
98702 +hpfs_translate_name_41497 hpfs_translate_name 3 41497 NULL
98703 +xfrm_hash_new_size_41505 xfrm_hash_new_size 0-1 41505 NULL
98704 +ldisc_receive_41516 ldisc_receive 4 41516 NULL
98705 +tx_tx_frame_checksum_read_41553 tx_tx_frame_checksum_read 3 41553 NULL
98706 +ath6kl_endpoint_stats_read_41554 ath6kl_endpoint_stats_read 3 41554 NULL
98707 +nr_status_frames_41559 nr_status_frames 0-1 41559 NULL
98708 +batadv_receive_client_update_packet_41578 batadv_receive_client_update_packet 3 41578 NULL
98709 +rng_dev_read_41581 rng_dev_read 3 41581 NULL
98710 +read_file_rx_chainmask_41605 read_file_rx_chainmask 3 41605 NULL
98711 +vga_io_r_41609 vga_io_r 0 41609 NULL
98712 +tcp_hdrlen_41610 tcp_hdrlen 0 41610 NULL
98713 +usb_endpoint_maxp_41613 usb_endpoint_maxp 0 41613 NULL
98714 +a2mp_send_41615 a2mp_send 4 41615 NULL
98715 +mempool_create_kmalloc_pool_41650 mempool_create_kmalloc_pool 1 41650 NULL
98716 +rx_rx_pre_complt_read_41653 rx_rx_pre_complt_read 3 41653 NULL
98717 +get_std_timing_41654 get_std_timing 0 41654 NULL
98718 +squashfs_cache_init_41656 squashfs_cache_init 2 41656 NULL
98719 +ieee80211_if_fmt_bssid_41677 ieee80211_if_fmt_bssid 3 41677 NULL
98720 +params_period_bytes_41683 params_period_bytes 0 41683 NULL
98721 +aac_src_ioremap_41688 aac_src_ioremap 2 41688 NULL
98722 +bdx_tx_db_init_41719 bdx_tx_db_init 2 41719 NULL
98723 +sys_pwritev_41722 sys_pwritev 3 41722 NULL
98724 +get_bios_ebda_41730 get_bios_ebda 0 41730 NULL
98725 +fillonedir_41746 fillonedir 3 41746 NULL
98726 +ocfs2_dx_dir_rebalance_41793 ocfs2_dx_dir_rebalance 7 41793 NULL
98727 +hsi_alloc_controller_41802 hsi_alloc_controller 1 41802 NULL
98728 +da9052_enable_irq_41814 da9052_enable_irq 2 41814 NULL
98729 +sco_send_frame_41815 sco_send_frame 3 41815 NULL
98730 +lp_gpio_to_irq_41822 lp_gpio_to_irq 2 41822 NULL
98731 +ixgbe_dbg_netdev_ops_read_41839 ixgbe_dbg_netdev_ops_read 3 41839 NULL
98732 +do_ip_setsockopt_41852 do_ip_setsockopt 5 41852 NULL
98733 +keyctl_instantiate_key_41855 keyctl_instantiate_key 3 41855 NULL
98734 +ieee80211_rx_radiotap_space_41870 ieee80211_rx_radiotap_space 0 41870 NULL
98735 +get_fdb_entries_41916 get_fdb_entries 3 41916 NULL
98736 +find_ge_pid_41918 find_ge_pid 1 41918 NULL
98737 +build_inv_iotlb_pages_41922 build_inv_iotlb_pages 4-5 41922 NULL
98738 +nfsd_getxattr_41934 nfsd_getxattr 0 41934 NULL
98739 +ext4_da_write_inline_data_begin_41935 ext4_da_write_inline_data_begin 3-4 41935 NULL
98740 +ocfs2_xattr_bucket_get_name_value_41949 ocfs2_xattr_bucket_get_name_value 0 41949 NULL
98741 +portnames_read_41958 portnames_read 3 41958 NULL
98742 +ubi_self_check_all_ff_41959 ubi_self_check_all_ff 4 41959 NULL
98743 +dst_mtu_41969 dst_mtu 0 41969 NULL
98744 +cx24116_writeregN_41975 cx24116_writeregN 4 41975 NULL
98745 +ubi_io_is_bad_41983 ubi_io_is_bad 0 41983 NULL
98746 +lguest_map_42008 lguest_map 1-2 42008 NULL
98747 +pool_allocate_42012 pool_allocate 3 42012 NULL
98748 +spidev_sync_read_42014 spidev_sync_read 0 42014 NULL
98749 +acpi_ut_create_buffer_object_42030 acpi_ut_create_buffer_object 1 42030 NULL
98750 +__hwahc_op_set_gtk_42038 __hwahc_op_set_gtk 4 42038 NULL
98751 +irda_sendmsg_ultra_42047 irda_sendmsg_ultra 4 42047 NULL
98752 +dma_generic_alloc_coherent_42048 dma_generic_alloc_coherent 2 42048 NULL nohasharray
98753 +jffs2_do_link_42048 jffs2_do_link 6 42048 &dma_generic_alloc_coherent_42048
98754 +ps_poll_upsd_max_ap_turn_read_42050 ps_poll_upsd_max_ap_turn_read 3 42050 NULL
98755 +InterfaceTransmitPacket_42058 InterfaceTransmitPacket 3 42058 NULL
98756 +alloc_bitset_42085 alloc_bitset 1 42085 NULL
98757 +scsi_execute_req_42088 scsi_execute_req 5 42088 NULL
98758 +sk_chk_filter_42095 sk_chk_filter 2 42095 NULL
98759 +submit_inquiry_42108 submit_inquiry 3 42108 NULL
98760 +sysfs_read_file_42113 sysfs_read_file 3 42113 NULL nohasharray
98761 +dw_dma_cyclic_prep_42113 dw_dma_cyclic_prep 3-4 42113 &sysfs_read_file_42113
98762 +Read_hfc16_stable_42131 Read_hfc16_stable 0 42131 NULL
98763 +mmc_align_data_size_42161 mmc_align_data_size 0-2 42161 NULL
98764 +read_file_base_eeprom_42168 read_file_base_eeprom 3 42168 NULL
98765 +iwl_mvm_send_cmd_42173 iwl_mvm_send_cmd 0 42173 NULL
98766 +oprofilefs_str_to_user_42182 oprofilefs_str_to_user 3 42182 NULL
98767 +get_znodes_to_commit_42201 get_znodes_to_commit 0 42201 NULL
98768 +btmrvl_hsmode_write_42252 btmrvl_hsmode_write 3 42252 NULL
98769 +rx_defrag_need_decrypt_read_42253 rx_defrag_need_decrypt_read 3 42253 NULL
98770 +netxen_nic_map_indirect_address_128M_42257 netxen_nic_map_indirect_address_128M 2 42257 NULL
98771 +savu_sysfs_write_42273 savu_sysfs_write 6 42273 NULL
98772 +snd_pcm_hw_param_value_max_42280 snd_pcm_hw_param_value_max 0 42280 NULL
98773 +sel_read_perm_42302 sel_read_perm 3 42302 NULL
98774 +sctp_setsockopt_del_key_42304 sctp_setsockopt_del_key 3 42304 NULL nohasharray
98775 +ulong_read_file_42304 ulong_read_file 3 42304 &sctp_setsockopt_del_key_42304
98776 +gfn_to_hva_42305 gfn_to_hva 0-2 42305 NULL
98777 +xfs_vm_readpages_42308 xfs_vm_readpages 4 42308 NULL
98778 +free_cblock_42318 free_cblock 2 42318 NULL
98779 +hysdn_conf_read_42324 hysdn_conf_read 3 42324 NULL
98780 +tcp_sync_mss_42330 tcp_sync_mss 0-2 42330 NULL
98781 +snd_pcm_plug_alloc_42339 snd_pcm_plug_alloc 2 42339 NULL
98782 +ide_raw_taskfile_42355 ide_raw_taskfile 4 42355 NULL
98783 +il_dbgfs_disable_ht40_read_42386 il_dbgfs_disable_ht40_read 3 42386 NULL
98784 +msnd_fifo_read_42406 msnd_fifo_read 0-3 42406 NULL
98785 +krng_get_random_42420 krng_get_random 3 42420 NULL
98786 +gsm_data_alloc_42437 gsm_data_alloc 3 42437 NULL
98787 +key_conf_keyidx_read_42443 key_conf_keyidx_read 3 42443 NULL
98788 +snd_pcm_action_group_42452 snd_pcm_action_group 0 42452 NULL
98789 +tcm_loop_change_queue_depth_42454 tcm_loop_change_queue_depth 2 42454 NULL
98790 +tc3589x_gpio_irq_get_virq_42457 tc3589x_gpio_irq_get_virq 2 42457 NULL
98791 +ext3_valid_block_bitmap_42459 ext3_valid_block_bitmap 3 42459 NULL
98792 +__simple_xattr_set_42474 __simple_xattr_set 4 42474 NULL
98793 +follow_hugetlb_page_42486 follow_hugetlb_page 0-7 42486 NULL
98794 +omfs_readpages_42490 omfs_readpages 4 42490 NULL
98795 +brcmf_sdbrcm_bus_txctl_42492 brcmf_sdbrcm_bus_txctl 3 42492 NULL
98796 +kvm_write_wall_clock_42520 kvm_write_wall_clock 2 42520 NULL
98797 +smk_write_netlbladdr_42525 smk_write_netlbladdr 3 42525 NULL
98798 +snd_emux_create_port_42533 snd_emux_create_port 3 42533 NULL
98799 +dbAllocNear_42546 dbAllocNear 0 42546 NULL
98800 +i915_ring_stop_read_42549 i915_ring_stop_read 3 42549 NULL nohasharray
98801 +ath6kl_wmi_proc_events_vif_42549 ath6kl_wmi_proc_events_vif 5 42549 &i915_ring_stop_read_42549
98802 +iwl_print_event_log_42566 iwl_print_event_log 0-5-7 42566 NULL
98803 +xfrm_new_hash_mask_42579 xfrm_new_hash_mask 0-1 42579 NULL
98804 +oom_score_adj_write_42594 oom_score_adj_write 3 42594 NULL
98805 +map_state_42602 map_state 1 42602 NULL nohasharray
98806 +__pskb_pull_42602 __pskb_pull 2 42602 &map_state_42602
98807 +nd_get_link_42603 nd_get_link 0 42603 NULL
98808 +sys_move_pages_42626 sys_move_pages 2 42626 NULL
98809 +ieee80211_if_fmt_dot11MeshHWMPactivePathTimeout_42635 ieee80211_if_fmt_dot11MeshHWMPactivePathTimeout 3 42635 NULL
98810 +scsi_activate_tcq_42640 scsi_activate_tcq 2 42640 NULL
98811 +br_mdb_rehash_42643 br_mdb_rehash 2 42643 NULL
98812 +l2tp_xmit_skb_42672 l2tp_xmit_skb 3 42672 NULL
98813 +request_key_and_link_42693 request_key_and_link 4 42693 NULL
98814 +vb2_read_42703 vb2_read 3 42703 NULL
98815 +sierra_net_send_cmd_42708 sierra_net_send_cmd 3 42708 NULL
98816 +__ocfs2_decrease_refcount_42717 __ocfs2_decrease_refcount 4 42717 NULL
98817 +dvb_demux_ioctl_42733 dvb_demux_ioctl 2 42733 NULL
98818 +set_aoe_iflist_42737 set_aoe_iflist 2 42737 NULL
98819 +ax25_setsockopt_42740 ax25_setsockopt 5 42740 NULL
98820 +xen_bind_pirq_gsi_to_irq_42750 xen_bind_pirq_gsi_to_irq 1 42750 NULL
98821 +snd_midi_event_decode_42780 snd_midi_event_decode 0 42780 NULL
98822 +cryptd_hash_setkey_42781 cryptd_hash_setkey 3 42781 NULL
98823 +koneplus_sysfs_read_42792 koneplus_sysfs_read 6 42792 NULL
98824 +ntfs_attr_extend_allocation_42796 ntfs_attr_extend_allocation 0-2 42796 NULL
98825 +fw_device_op_compat_ioctl_42804 fw_device_op_compat_ioctl 2-3 42804 NULL
98826 +drm_ioctl_42813 drm_ioctl 2 42813 NULL
98827 +iwl_dbgfs_ucode_bt_stats_read_42820 iwl_dbgfs_ucode_bt_stats_read 3 42820 NULL
98828 +set_arg_42824 set_arg 3 42824 NULL
98829 +ocfs2_desc_bitmap_to_cluster_off_42831 ocfs2_desc_bitmap_to_cluster_off 2 42831 NULL
98830 +prandom_u32_42853 prandom_u32 0 42853 NULL
98831 +of_property_count_strings_42863 of_property_count_strings 0 42863 NULL
98832 +ocfs2_clusters_for_bytes_42872 ocfs2_clusters_for_bytes 0-2 42872 NULL
98833 +pskb_expand_head_42881 pskb_expand_head 2-3 42881 NULL
98834 +vt_compat_ioctl_42887 vt_compat_ioctl 3 42887 NULL
98835 +tipc_port_recv_sections_42890 tipc_port_recv_sections 4 42890 NULL
98836 +xpc_kmalloc_cacheline_aligned_42895 xpc_kmalloc_cacheline_aligned 1 42895 NULL
98837 +SendTxCommandPacket_42901 SendTxCommandPacket 3 42901 NULL
98838 +hd_end_request_42904 hd_end_request 2 42904 NULL
98839 +sta_last_rx_rate_read_42909 sta_last_rx_rate_read 3 42909 NULL
98840 +sctp_getsockopt_maxburst_42941 sctp_getsockopt_maxburst 2 42941 NULL
98841 +get_unmapped_area_42944 get_unmapped_area 0 42944 NULL
98842 +sys_sethostname_42962 sys_sethostname 2 42962 NULL
98843 +read_file_node_stat_42964 read_file_node_stat 3 42964 NULL
98844 +compat_udpv6_setsockopt_42981 compat_udpv6_setsockopt 5 42981 NULL
98845 +snd_timer_user_ioctl_compat_42985 snd_timer_user_ioctl_compat 3 42985 NULL
98846 +nfs_idmap_get_desc_42990 nfs_idmap_get_desc 4-2 42990 NULL
98847 +mlx4_qp_reserve_range_43000 mlx4_qp_reserve_range 2-3 43000 NULL
98848 +isr_rx_mem_overflow_read_43025 isr_rx_mem_overflow_read 3 43025 NULL
98849 +wep_default_key_count_read_43035 wep_default_key_count_read 3 43035 NULL
98850 +nouveau_gpuobj_create__43072 nouveau_gpuobj_create_ 9 43072 NULL
98851 +nfs_map_group_to_gid_43082 nfs_map_group_to_gid 3 43082 NULL
98852 +cpuset_sprintf_memlist_43088 cpuset_sprintf_memlist 0 43088 NULL
98853 +ieee80211_if_fmt_drop_unencrypted_43107 ieee80211_if_fmt_drop_unencrypted 3 43107 NULL
98854 +read_file_dfs_43145 read_file_dfs 3 43145 NULL
98855 +uuid_string_43154 uuid_string 0 43154 NULL
98856 +usb_string_sub_43164 usb_string_sub 0 43164 NULL
98857 +il_dbgfs_power_save_status_read_43165 il_dbgfs_power_save_status_read 3 43165 NULL
98858 +ath6kl_set_assoc_req_ies_43185 ath6kl_set_assoc_req_ies 3 43185 NULL
98859 +process_measurement_43190 process_measurement 0 43190 NULL
98860 +ext4_xattr_ibody_get_43200 ext4_xattr_ibody_get 0 43200 NULL
98861 +uio_write_43202 uio_write 3 43202 NULL
98862 +iso_callback_43208 iso_callback 3 43208 NULL
98863 +f2fs_acl_from_disk_43210 f2fs_acl_from_disk 2 43210 NULL
98864 +atomic_long_add_return_43217 atomic_long_add_return 1 43217 NULL
98865 +comedi_compat_ioctl_43218 comedi_compat_ioctl 3 43218 NULL
98866 +vmemmap_alloc_block_43245 vmemmap_alloc_block 1 43245 NULL
98867 +fixup_leb_43256 fixup_leb 3 43256 NULL
98868 +ide_end_rq_43269 ide_end_rq 4 43269 NULL
98869 +evtchn_write_43278 evtchn_write 3 43278 NULL
98870 +filemap_write_and_wait_range_43279 filemap_write_and_wait_range 0 43279 NULL
98871 +mpage_alloc_43299 mpage_alloc 3 43299 NULL
98872 +get_nr_irqs_gsi_43315 get_nr_irqs_gsi 0 43315 NULL
98873 +mmu_set_spte_43327 mmu_set_spte 6-7 43327 NULL
98874 +__ext4_get_inode_loc_43332 __ext4_get_inode_loc 0 43332 NULL
98875 +kvm_host_page_size_43348 kvm_host_page_size 2 43348 NULL
98876 +gart_free_coherent_43362 gart_free_coherent 4-2 43362 NULL
98877 +__alloc_bootmem_low_43423 __alloc_bootmem_low 1-2 43423 NULL nohasharray
98878 +gdm_wimax_netif_rx_43423 gdm_wimax_netif_rx 3 43423 &__alloc_bootmem_low_43423
98879 +usb_alloc_urb_43436 usb_alloc_urb 1 43436 NULL
98880 +ucs2_strsize_43438 ucs2_strsize 0 43438 NULL
98881 +ath6kl_wmi_roam_tbl_event_rx_43440 ath6kl_wmi_roam_tbl_event_rx 3 43440 NULL
98882 +usemap_size_43443 usemap_size 0-2-1 43443 NULL nohasharray
98883 +usb_string_43443 usb_string 0 43443 &usemap_size_43443
98884 +alloc_new_reservation_43480 alloc_new_reservation 4 43480 NULL
98885 +tx_tx_data_prepared_read_43497 tx_tx_data_prepared_read 3 43497 NULL
98886 +ieee80211_if_fmt_dot11MeshHWMPnetDiameterTraversalTime_43505 ieee80211_if_fmt_dot11MeshHWMPnetDiameterTraversalTime 3 43505 NULL
98887 +do_readlink_43518 do_readlink 2 43518 NULL
98888 +dvb_ca_en50221_io_write_43533 dvb_ca_en50221_io_write 3 43533 NULL
98889 +cachefiles_daemon_write_43535 cachefiles_daemon_write 3 43535 NULL
98890 +tx_frag_failed_read_43540 tx_frag_failed_read 3 43540 NULL nohasharray
98891 +ufs_alloccg_block_43540 ufs_alloccg_block 3-0 43540 &tx_frag_failed_read_43540
98892 +ath_rx_init_43564 ath_rx_init 2 43564 NULL
98893 +_fc_frame_alloc_43568 _fc_frame_alloc 1 43568 NULL
98894 +rpc_malloc_43573 rpc_malloc 2 43573 NULL
98895 +lpfc_idiag_drbacc_read_reg_43606 lpfc_idiag_drbacc_read_reg 0-3 43606 NULL
98896 +proc_read_43614 proc_read 3 43614 NULL
98897 +bio_integrity_tag_43658 bio_integrity_tag 3 43658 NULL
98898 +ext4_acl_count_43659 ext4_acl_count 0-1 43659 NULL
98899 +dmam_declare_coherent_memory_43679 dmam_declare_coherent_memory 4-2 43679 NULL
98900 +calgary_map_page_43686 calgary_map_page 3-4 43686 NULL
98901 +max77693_bulk_write_43698 max77693_bulk_write 2-3 43698 NULL
98902 +snd_rme32_playback_copy_43732 snd_rme32_playback_copy 5 43732 NULL
98903 +ocfs2_replace_clusters_43733 ocfs2_replace_clusters 5 43733 NULL
98904 +osdv1_attr_list_elem_size_43747 osdv1_attr_list_elem_size 0-1 43747 NULL
98905 +__bm_find_next_43748 __bm_find_next 2 43748 NULL
98906 +gigaset_initcs_43753 gigaset_initcs 2 43753 NULL
98907 +sctp_setsockopt_active_key_43755 sctp_setsockopt_active_key 3 43755 NULL
98908 +ocfs2_xattr_get_value_outside_43787 ocfs2_xattr_get_value_outside 0 43787 NULL nohasharray
98909 +byte_pos_43787 byte_pos 0-2 43787 &ocfs2_xattr_get_value_outside_43787
98910 +btrfs_copy_from_user_43806 btrfs_copy_from_user 3-1 43806 NULL
98911 +ext4_read_block_bitmap_43814 ext4_read_block_bitmap 2 43814 NULL
98912 +ieee80211_if_fmt_element_ttl_43825 ieee80211_if_fmt_element_ttl 3 43825 NULL
98913 +ieee80211_alloc_hw_43829 ieee80211_alloc_hw 1 43829 NULL
98914 +p54_download_eeprom_43842 p54_download_eeprom 4 43842 NULL
98915 +read_flush_43851 read_flush 3 43851 NULL
98916 +ocfs2_block_group_find_clear_bits_43874 ocfs2_block_group_find_clear_bits 4 43874 NULL
98917 +pm860x_bulk_write_43875 pm860x_bulk_write 2-3 43875 NULL
98918 +prism2_sta_send_mgmt_43916 prism2_sta_send_mgmt 5 43916 NULL
98919 +SendString_43928 SendString 3 43928 NULL
98920 +xen_register_gsi_43946 xen_register_gsi 1-2 43946 NULL
98921 +stats_dot11RTSFailureCount_read_43948 stats_dot11RTSFailureCount_read 3 43948 NULL
98922 +__get_required_blob_size_43980 __get_required_blob_size 0-2-3 43980 NULL
98923 +nla_reserve_43984 nla_reserve 3 43984 NULL
98924 +__clkdev_alloc_43990 __clkdev_alloc 1 43990 NULL
98925 +scsi_command_size_43992 scsi_command_size 0 43992 NULL nohasharray
98926 +bcm_recvmsg_43992 bcm_recvmsg 4 43992 &scsi_command_size_43992
98927 +emit_flags_44006 emit_flags 4-3 44006 NULL
98928 +write_flush_procfs_44011 write_flush_procfs 3 44011 NULL
98929 +swiotlb_unmap_page_44063 swiotlb_unmap_page 2 44063 NULL
98930 +load_discard_44083 load_discard 3 44083 NULL
98931 +xlog_recover_add_to_cont_trans_44102 xlog_recover_add_to_cont_trans 4 44102 NULL
98932 +tracing_set_trace_read_44122 tracing_set_trace_read 3 44122 NULL
98933 +vmw_gmr_bind_44130 vmw_gmr_bind 3 44130 NULL
98934 +scsi_get_resid_44147 scsi_get_resid 0 44147 NULL
98935 +ubifs_find_dirty_idx_leb_44169 ubifs_find_dirty_idx_leb 0 44169 NULL
98936 +ocfs2_xattr_bucket_find_44174 ocfs2_xattr_bucket_find 0 44174 NULL
98937 +handle_eviocgbit_44193 handle_eviocgbit 3 44193 NULL
98938 +IO_APIC_get_PCI_irq_vector_44198 IO_APIC_get_PCI_irq_vector 0 44198 NULL
98939 +__set_free_44211 __set_free 2 44211 NULL
98940 +claim_ptd_buffers_44213 claim_ptd_buffers 3 44213 NULL
98941 +srp_alloc_iu_44227 srp_alloc_iu 2 44227 NULL
98942 +ioapic_register_intr_44238 ioapic_register_intr 1 44238 NULL
98943 +scsi_track_queue_full_44239 scsi_track_queue_full 2 44239 NULL
98944 +tc3589x_gpio_irq_map_44245 tc3589x_gpio_irq_map 2 44245 NULL
98945 +enlarge_skb_44248 enlarge_skb 2 44248 NULL
98946 +ufs_clusteracct_44293 ufs_clusteracct 3 44293 NULL
98947 +ocfs2_zero_range_for_truncate_44294 ocfs2_zero_range_for_truncate 3 44294 NULL
98948 +ath6kl_keepalive_read_44303 ath6kl_keepalive_read 3 44303 NULL
98949 +bitmap_scnprintf_44318 bitmap_scnprintf 2 44318 NULL
98950 +dispatch_proc_write_44320 dispatch_proc_write 3 44320 NULL
98951 +ubi_eba_write_leb_st_44343 ubi_eba_write_leb_st 5 44343 NULL
98952 +nfs_fscache_get_super_cookie_44355 nfs_fscache_get_super_cookie 3 44355 NULL nohasharray
98953 +blk_queue_init_tags_44355 blk_queue_init_tags 2 44355 &nfs_fscache_get_super_cookie_44355
98954 +__is_discarded_44359 __is_discarded 2 44359 NULL
98955 +rts_threshold_read_44384 rts_threshold_read 3 44384 NULL
98956 +aoedev_flush_44398 aoedev_flush 2 44398 NULL
98957 +drm_buffer_alloc_44405 drm_buffer_alloc 2 44405 NULL
98958 +osst_do_scsi_44410 osst_do_scsi 4 44410 NULL
98959 +check_user_page_hwpoison_44412 check_user_page_hwpoison 1 44412 NULL
98960 +ieee80211_if_read_rc_rateidx_mcs_mask_5ghz_44423 ieee80211_if_read_rc_rateidx_mcs_mask_5ghz 3 44423 NULL
98961 +prandom_u32_state_44445 prandom_u32_state 0 44445 NULL
98962 +___alloc_bootmem_node_nopanic_44461 ___alloc_bootmem_node_nopanic 2-3 44461 NULL
98963 +btrfs_chunk_item_size_44478 btrfs_chunk_item_size 0-1 44478 NULL
98964 +sdio_align_size_44489 sdio_align_size 0-2 44489 NULL
98965 +ieee80211_if_read_dropped_frames_ttl_44500 ieee80211_if_read_dropped_frames_ttl 3 44500 NULL
98966 +security_getprocattr_44505 security_getprocattr 0 44505 NULL nohasharray
98967 +iwl_dbgfs_sram_read_44505 iwl_dbgfs_sram_read 3 44505 &security_getprocattr_44505
98968 +spidev_write_44510 spidev_write 3 44510 NULL
98969 +sys_msgsnd_44537 sys_msgsnd 3 44537 NULL nohasharray
98970 +comm_write_44537 comm_write 3 44537 &sys_msgsnd_44537
98971 +dgrp_config_proc_write_44571 dgrp_config_proc_write 3 44571 NULL
98972 +snd_pcm_alloc_vmalloc_buffer_44595 snd_pcm_alloc_vmalloc_buffer 2 44595 NULL
98973 +slip_compat_ioctl_44599 slip_compat_ioctl 4 44599 NULL
98974 +brcmf_sdbrcm_glom_len_44618 brcmf_sdbrcm_glom_len 0 44618 NULL
98975 +cfpkt_add_body_44630 cfpkt_add_body 3 44630 NULL
98976 +ext2_new_block_44645 ext2_new_block 2 44645 NULL
98977 +alloc_ctrl_packet_44667 alloc_ctrl_packet 1 44667 NULL
98978 +mpi_resize_44674 mpi_resize 2 44674 NULL
98979 +ts_read_44687 ts_read 3 44687 NULL
98980 +qib_get_user_pages_44689 qib_get_user_pages 1-2 44689 NULL
98981 +_zd_iowrite32v_locked_44725 _zd_iowrite32v_locked 3 44725 NULL
98982 +clusterip_proc_write_44729 clusterip_proc_write 3 44729 NULL
98983 +fib_count_nexthops_44730 fib_count_nexthops 0 44730 NULL
98984 +key_tx_rx_count_read_44742 key_tx_rx_count_read 3 44742 NULL
98985 +WIL_GET_BITS_44747 WIL_GET_BITS 0-1-2-3 44747 NULL
98986 +set_brk_44749 set_brk 1 44749 NULL
98987 +tnode_new_44757 tnode_new 3 44757 NULL nohasharray
98988 +pty_write_44757 pty_write 3 44757 &tnode_new_44757
98989 +__videobuf_copy_stream_44769 __videobuf_copy_stream 4 44769 NULL
98990 +handsfree_ramp_44777 handsfree_ramp 2 44777 NULL
98991 +sctp_setsockopt_44788 sctp_setsockopt 5 44788 NULL
98992 +rx_dropped_read_44799 rx_dropped_read 3 44799 NULL
98993 +qla4xxx_alloc_work_44813 qla4xxx_alloc_work 2 44813 NULL
98994 +rmap_write_protect_44833 rmap_write_protect 2 44833 NULL
98995 +sisusb_write_44834 sisusb_write 3 44834 NULL
98996 +nl80211_send_unprot_disassoc_44846 nl80211_send_unprot_disassoc 4 44846 NULL
98997 +kvm_read_hva_44847 kvm_read_hva 3 44847 NULL
98998 +skb_availroom_44883 skb_availroom 0 44883 NULL
98999 +nf_bridge_encap_header_len_44890 nf_bridge_encap_header_len 0 44890 NULL
99000 +do_tty_write_44896 do_tty_write 5 44896 NULL
99001 +tx_queue_status_read_44978 tx_queue_status_read 3 44978 NULL
99002 +nf_nat_seq_adjust_44989 nf_nat_seq_adjust 4 44989 NULL
99003 +bytepos_delta_45017 bytepos_delta 0 45017 NULL
99004 +read_block_bitmap_45021 read_block_bitmap 2 45021 NULL nohasharray
99005 +ptrace_writedata_45021 ptrace_writedata 4-3 45021 &read_block_bitmap_45021
99006 +vhci_get_user_45039 vhci_get_user 3 45039 NULL
99007 +sel_write_user_45060 sel_write_user 3 45060 NULL
99008 +snd_mixart_BA0_read_45069 snd_mixart_BA0_read 5 45069 NULL nohasharray
99009 +do_video_ioctl_45069 do_video_ioctl 3 45069 &snd_mixart_BA0_read_45069
99010 +kvm_mmu_page_get_gfn_45110 kvm_mmu_page_get_gfn 0-2 45110 NULL
99011 +pwr_missing_bcns_cnt_read_45113 pwr_missing_bcns_cnt_read 3 45113 NULL
99012 +usbdev_read_45114 usbdev_read 3 45114 NULL
99013 +send_to_tty_45141 send_to_tty 3 45141 NULL
99014 +stmpe_irq_map_45146 stmpe_irq_map 2 45146 NULL
99015 +crypto_aead_blocksize_45148 crypto_aead_blocksize 0 45148 NULL
99016 +gen_bitmask_string_45149 gen_bitmask_string 6 45149 NULL
99017 +ocfs2_remove_inode_range_45156 ocfs2_remove_inode_range 3-4 45156 NULL nohasharray
99018 +device_write_45156 device_write 3 45156 &ocfs2_remove_inode_range_45156
99019 +ocfs2_dq_frozen_trigger_45159 ocfs2_dq_frozen_trigger 4 45159 NULL
99020 +tomoyo_write_self_45161 tomoyo_write_self 3 45161 NULL
99021 +sta_agg_status_write_45164 sta_agg_status_write 3 45164 NULL
99022 +snd_sb_csp_load_user_45190 snd_sb_csp_load_user 3 45190 NULL
99023 +num_clusters_in_group_45194 num_clusters_in_group 2 45194 NULL
99024 +add_child_45201 add_child 4 45201 NULL
99025 +iso_alloc_urb_45206 iso_alloc_urb 4-5 45206 NULL
99026 +spi_alloc_master_45223 spi_alloc_master 2 45223 NULL
99027 +__dirty_45228 __dirty 2 45228 NULL
99028 +ieee80211_if_read_peer_45233 ieee80211_if_read_peer 3 45233 NULL
99029 +input_mt_init_slots_45279 input_mt_init_slots 2 45279 NULL
99030 +vcc_compat_ioctl_45291 vcc_compat_ioctl 3 45291 NULL
99031 +snd_pcm_oss_sync1_45298 snd_pcm_oss_sync1 2 45298 NULL
99032 +pte_val_45313 pte_val 0 45313 NULL
99033 +copy_vm86_regs_from_user_45340 copy_vm86_regs_from_user 3 45340 NULL
99034 +lane2_associate_req_45398 lane2_associate_req 4 45398 NULL
99035 +keymap_store_45406 keymap_store 4 45406 NULL
99036 +paging64_gva_to_gpa_45421 paging64_gva_to_gpa 2 45421 NULL nohasharray
99037 +ieee80211_if_fmt_dot11MeshHWMProotInterval_45421 ieee80211_if_fmt_dot11MeshHWMProotInterval 3 45421 &paging64_gva_to_gpa_45421
99038 +tty_buffer_alloc_45437 tty_buffer_alloc 2 45437 NULL
99039 +intel_render_ring_init_dri_45446 intel_render_ring_init_dri 2-3 45446 NULL
99040 +__node_remap_45458 __node_remap 4 45458 NULL
99041 +rds_ib_set_wr_signal_state_45463 rds_ib_set_wr_signal_state 0 45463 NULL
99042 +udp_manip_pkt_45467 udp_manip_pkt 4 45467 NULL
99043 +tracing_read_dyn_info_45468 tracing_read_dyn_info 3 45468 NULL
99044 +arizona_init_fll_45503 arizona_init_fll 5 45503 NULL
99045 +rds_message_copy_from_user_45510 rds_message_copy_from_user 3 45510 NULL
99046 +sys_lgetxattr_45531 sys_lgetxattr 4 45531 NULL
99047 +cgroup_read_u64_45532 cgroup_read_u64 5 45532 NULL
99048 +copy_macs_45534 copy_macs 4 45534 NULL
99049 +nla_attr_size_45545 nla_attr_size 0-1 45545 NULL
99050 +v9fs_direct_read_45546 v9fs_direct_read 3 45546 NULL
99051 +cx18_copy_mdl_to_user_45549 cx18_copy_mdl_to_user 4 45549 NULL
99052 +atomic_long_sub_return_45551 atomic_long_sub_return 1 45551 NULL
99053 +ext3_group_first_block_no_45555 ext3_group_first_block_no 0-2 45555 NULL
99054 +stats_dot11ACKFailureCount_read_45558 stats_dot11ACKFailureCount_read 3 45558 NULL
99055 +_regmap_bus_raw_write_45559 _regmap_bus_raw_write 2 45559 NULL
99056 +posix_acl_xattr_size_45561 posix_acl_xattr_size 0-1 45561 NULL
99057 +venus_rmdir_45564 venus_rmdir 4 45564 NULL
99058 +ipath_create_cq_45586 ipath_create_cq 2 45586 NULL
99059 +rdma_set_ib_paths_45592 rdma_set_ib_paths 3 45592 NULL
99060 +hidraw_get_report_45609 hidraw_get_report 3 45609 NULL
99061 +audit_log_n_hex_45617 audit_log_n_hex 3 45617 NULL
99062 +ebitmap_next_positive_45651 ebitmap_next_positive 3 45651 NULL
99063 +dma_map_cont_45668 dma_map_cont 5 45668 NULL
99064 +compat_mpctl_ioctl_45671 compat_mpctl_ioctl 2 45671 NULL
99065 +dgram_sendmsg_45679 dgram_sendmsg 4 45679 NULL
99066 +smk_write_ambient_45691 smk_write_ambient 3 45691 NULL
99067 +dm_compat_ctl_ioctl_45692 dm_compat_ctl_ioctl 3 45692 NULL
99068 +unix_dgram_sendmsg_45699 unix_dgram_sendmsg 4 45699 NULL nohasharray
99069 +bscnl_emit_45699 bscnl_emit 2-5-0 45699 &unix_dgram_sendmsg_45699
99070 +dvb_ca_en50221_init_45718 dvb_ca_en50221_init 4 45718 NULL
99071 +snd_cs46xx_io_read_45734 snd_cs46xx_io_read 5 45734 NULL
99072 +rw_copy_check_uvector_45748 rw_copy_check_uvector 3 45748 NULL nohasharray
99073 +v4l2_ctrl_new_std_45748 v4l2_ctrl_new_std 5 45748 &rw_copy_check_uvector_45748
99074 +lkdtm_debugfs_read_45752 lkdtm_debugfs_read 3 45752 NULL
99075 +nilfs_compat_ioctl_45769 nilfs_compat_ioctl 3 45769 NULL
99076 +alloc_ts_config_45775 alloc_ts_config 1 45775 NULL
99077 +raw_setsockopt_45800 raw_setsockopt 5 45800 NULL
99078 +lbs_rdbbp_read_45805 lbs_rdbbp_read 3 45805 NULL
99079 +pcpu_alloc_alloc_info_45813 pcpu_alloc_alloc_info 1-2 45813 NULL
99080 +fm_v4l2_init_video_device_45821 fm_v4l2_init_video_device 2 45821 NULL
99081 +memcg_update_cache_size_45828 memcg_update_cache_size 2 45828 NULL
99082 +x509_process_extension_45854 x509_process_extension 5 45854 NULL
99083 +isdn_write_45863 isdn_write 3 45863 NULL
99084 +unpack_orig_pfns_45867 unpack_orig_pfns 0 45867 NULL
99085 +get_rdac_req_45882 get_rdac_req 3 45882 NULL
99086 +ocfs2_xattr_block_find_45891 ocfs2_xattr_block_find 0 45891 NULL
99087 +wm_adsp_region_to_reg_45915 wm_adsp_region_to_reg 0-2 45915 NULL
99088 +dbgfs_frame_45917 dbgfs_frame 3 45917 NULL
99089 +nf_nat_ftp_fmt_cmd_45926 nf_nat_ftp_fmt_cmd 0 45926 NULL
99090 +smp_scan_config_45934 smp_scan_config 1 45934 NULL
99091 +alloc_mr_45935 alloc_mr 1 45935 NULL
99092 +split_large_page_45941 split_large_page 2 45941 NULL
99093 +rb_simple_read_45972 rb_simple_read 3 45972 NULL
99094 +ezusb_writememory_45976 ezusb_writememory 4 45976 NULL
99095 +ioat2_dca_count_dca_slots_45984 ioat2_dca_count_dca_slots 0 45984 NULL
99096 +sierra_setup_urb_46029 sierra_setup_urb 5 46029 NULL
99097 +get_free_entries_46030 get_free_entries 1 46030 NULL
99098 +__access_remote_vm_46031 __access_remote_vm 0-5-3 46031 NULL
99099 +snd_emu10k1x_ptr_read_46049 snd_emu10k1x_ptr_read 0 46049 NULL
99100 +acpi_register_gsi_xen_hvm_46052 acpi_register_gsi_xen_hvm 2 46052 NULL
99101 +line6_midibuf_bytes_used_46059 line6_midibuf_bytes_used 0 46059 NULL
99102 +__ocfs2_move_extent_46060 __ocfs2_move_extent 5-6 46060 NULL nohasharray
99103 +dma_tx_errors_read_46060 dma_tx_errors_read 3 46060 &__ocfs2_move_extent_46060
99104 +slhc_toss_46066 slhc_toss 0 46066 NULL
99105 +sel_commit_bools_write_46077 sel_commit_bools_write 3 46077 NULL
99106 +vfio_config_do_rw_46091 vfio_config_do_rw 3 46091 NULL
99107 +ata_host_alloc_46094 ata_host_alloc 2 46094 NULL
99108 +arizona_set_irq_wake_46101 arizona_set_irq_wake 2 46101 NULL
99109 +pkt_ctl_compat_ioctl_46110 pkt_ctl_compat_ioctl 3 46110 NULL
99110 +memcg_update_array_size_46111 memcg_update_array_size 1 46111 NULL nohasharray
99111 +il3945_ucode_general_stats_read_46111 il3945_ucode_general_stats_read 3 46111 &memcg_update_array_size_46111
99112 +mlx4_ib_alloc_fast_reg_page_list_46119 mlx4_ib_alloc_fast_reg_page_list 2 46119 NULL
99113 +paging32_walk_addr_nested_46121 paging32_walk_addr_nested 3 46121 NULL
99114 +__netlink_change_ngroups_46156 __netlink_change_ngroups 2 46156 NULL
99115 +twl_direction_out_46182 twl_direction_out 2 46182 NULL
99116 +vxge_os_dma_malloc_46184 vxge_os_dma_malloc 2 46184 NULL
99117 +add_conn_list_46197 add_conn_list 3 46197 NULL
99118 +i2400m_op_msg_from_user_46213 i2400m_op_msg_from_user 4 46213 NULL
99119 +tm6000_i2c_recv_regs_46215 tm6000_i2c_recv_regs 5 46215 NULL
99120 +dsp_write_46218 dsp_write 2 46218 NULL
99121 +mpi_read_raw_data_46248 mpi_read_raw_data 2 46248 NULL
99122 +nf_nat_ftp_46265 nf_nat_ftp 6 46265 NULL
99123 +ReadReg_46277 ReadReg 0 46277 NULL
99124 +batadv_iv_ogm_queue_add_46319 batadv_iv_ogm_queue_add 3 46319 NULL
99125 +__hwahc_dev_set_key_46328 __hwahc_dev_set_key 5 46328 NULL
99126 +iwl_dbgfs_chain_noise_read_46355 iwl_dbgfs_chain_noise_read 3 46355 NULL
99127 +smk_write_direct_46363 smk_write_direct 3 46363 NULL
99128 +__iommu_calculate_agaw_46366 __iommu_calculate_agaw 2 46366 NULL
99129 +ubi_dump_flash_46381 ubi_dump_flash 4 46381 NULL
99130 +fuse_file_aio_write_46399 fuse_file_aio_write 4 46399 NULL
99131 +crypto_ablkcipher_reqsize_46411 crypto_ablkcipher_reqsize 0 46411 NULL
99132 +cp210x_set_config_46447 cp210x_set_config 4 46447 NULL
99133 +filldir64_46469 filldir64 3 46469 NULL
99134 +fill_in_write_vector_46498 fill_in_write_vector 0 46498 NULL
99135 +pin_code_reply_46510 pin_code_reply 4 46510 NULL
99136 +mthca_alloc_cq_buf_46512 mthca_alloc_cq_buf 3 46512 NULL
99137 +kmsg_read_46514 kmsg_read 3 46514 NULL
99138 +bdx_rxdb_create_46525 bdx_rxdb_create 1 46525 NULL
99139 +nl80211_send_rx_assoc_46538 nl80211_send_rx_assoc 4 46538 NULL
99140 +pm860x_irq_domain_map_46553 pm860x_irq_domain_map 2 46553 NULL
99141 +mv_get_hc_count_46554 mv_get_hc_count 0 46554 NULL
99142 +link_send_sections_long_46556 link_send_sections_long 4 46556 NULL
99143 +irq_domain_associate_46564 irq_domain_associate 2 46564 NULL
99144 +dn_current_mss_46574 dn_current_mss 0 46574 NULL
99145 +serverworks_create_gatt_pages_46582 serverworks_create_gatt_pages 1 46582 NULL
99146 +snd_compr_write_data_46592 snd_compr_write_data 3 46592 NULL
99147 +il3945_stats_flag_46606 il3945_stats_flag 0-3 46606 NULL
99148 +vscnprintf_46617 vscnprintf 0-2 46617 NULL
99149 +__kfifo_out_r_46623 __kfifo_out_r 0-3 46623 NULL
99150 +request_key_async_with_auxdata_46624 request_key_async_with_auxdata 4 46624 NULL
99151 +vfs_getxattr_alloc_46649 vfs_getxattr_alloc 0 46649 NULL
99152 +av7110_ipack_init_46655 av7110_ipack_init 2 46655 NULL
99153 +alloc_data_packet_46698 alloc_data_packet 1 46698 NULL
99154 +__ilog2_u32_46706 __ilog2_u32 0 46706 NULL
99155 +erst_dbg_write_46715 erst_dbg_write 3 46715 NULL
99156 +wl1271_rx_filter_alloc_field_46721 wl1271_rx_filter_alloc_field 5 46721 NULL
99157 +prepare_copy_46725 prepare_copy 2 46725 NULL
99158 +irq_domain_add_simple_46734 irq_domain_add_simple 2-3 46734 NULL
99159 +set_memory_wc_46747 set_memory_wc 1 46747 NULL
99160 +ext4_count_free_46754 ext4_count_free 2 46754 NULL nohasharray
99161 +pte_pfn_46754 pte_pfn 0 46754 &ext4_count_free_46754
99162 +hest_ghes_dev_register_46766 hest_ghes_dev_register 1 46766 NULL
99163 +int_hw_irq_en_46776 int_hw_irq_en 3 46776 NULL
99164 +regcache_lzo_sync_46777 regcache_lzo_sync 2 46777 NULL
99165 +_sys_packet_req_46793 _sys_packet_req 4 46793 NULL
99166 +_xfs_buf_get_pages_46811 _xfs_buf_get_pages 2 46811 NULL
99167 +xfs_iroot_realloc_46826 xfs_iroot_realloc 2 46826 NULL
99168 +shmem_pwrite_fast_46842 shmem_pwrite_fast 3 46842 NULL
99169 +spi_async_46857 spi_async 0 46857 NULL
99170 +vsnprintf_46863 vsnprintf 0 46863 NULL
99171 +nvme_alloc_queue_46865 nvme_alloc_queue 3 46865 NULL
99172 +sip_sprintf_addr_46872 sip_sprintf_addr 0 46872 NULL
99173 +rvmalloc_46873 rvmalloc 1 46873 NULL
99174 +qp_memcpy_from_queue_iov_46874 qp_memcpy_from_queue_iov 4-5 46874 NULL
99175 +hpi_read_word_nolock_46881 hpi_read_word_nolock 0 46881 NULL
99176 +stmpe_gpio_irq_unmap_46884 stmpe_gpio_irq_unmap 2 46884 NULL
99177 +ixgbe_dbg_reg_ops_write_46895 ixgbe_dbg_reg_ops_write 3 46895 NULL
99178 +sk_mem_pages_46896 sk_mem_pages 0-1 46896 NULL
99179 +ol_dqblk_off_46904 ol_dqblk_off 3-2 46904 NULL
99180 +ieee80211_if_fmt_power_mode_46906 ieee80211_if_fmt_power_mode 3 46906 NULL
99181 +wlcore_alloc_hw_46917 wlcore_alloc_hw 1 46917 NULL
99182 +fb_write_46924 fb_write 3 46924 NULL
99183 +btmrvl_curpsmode_read_46939 btmrvl_curpsmode_read 3 46939 NULL
99184 +kvm_register_read_46948 kvm_register_read 0 46948 NULL
99185 +__sctp_setsockopt_connectx_46949 __sctp_setsockopt_connectx 3 46949 NULL
99186 +qla4xxx_post_aen_work_46953 qla4xxx_post_aen_work 3 46953 NULL
99187 +crypto_tfm_alg_alignmask_46971 crypto_tfm_alg_alignmask 0 46971 NULL
99188 +mgmt_pending_add_46976 mgmt_pending_add 5 46976 NULL
99189 +gfs2_xattr_system_set_46996 gfs2_xattr_system_set 4 46996 NULL nohasharray
99190 +sel_write_bool_46996 sel_write_bool 3 46996 &gfs2_xattr_system_set_46996
99191 +ttm_bo_io_47000 ttm_bo_io 5 47000 NULL
99192 +blk_rq_map_kern_47004 blk_rq_map_kern 4 47004 NULL
99193 +__map_single_47020 __map_single 3-4-7 47020 NULL
99194 +cx231xx_init_bulk_47024 cx231xx_init_bulk 3-2 47024 NULL
99195 +swiotlb_sync_single_47031 swiotlb_sync_single 2 47031 NULL
99196 +set_dis_bypass_pfs_47038 set_dis_bypass_pfs 3 47038 NULL
99197 +fs_path_len_47060 fs_path_len 0 47060 NULL
99198 +ufs_new_fragments_47070 ufs_new_fragments 3-5-4 47070 NULL
99199 +pipeline_dec_packet_in_read_47076 pipeline_dec_packet_in_read 3 47076 NULL
99200 +scsi_deactivate_tcq_47086 scsi_deactivate_tcq 2 47086 NULL
99201 +mousedev_read_47123 mousedev_read 3 47123 NULL
99202 +ses_recv_diag_47143 ses_recv_diag 4 47143 NULL nohasharray
99203 +acpi_ut_initialize_buffer_47143 acpi_ut_initialize_buffer 2 47143 &ses_recv_diag_47143
99204 +persistent_ram_iomap_47156 persistent_ram_iomap 1-2 47156 NULL
99205 +mxms_headerlen_47161 mxms_headerlen 0 47161 NULL
99206 +rs_sta_dbgfs_rate_scale_data_read_47165 rs_sta_dbgfs_rate_scale_data_read 3 47165 NULL
99207 +rts51x_ms_rw_47171 rts51x_ms_rw 3-4 47171 NULL
99208 +svc_pool_map_alloc_arrays_47181 svc_pool_map_alloc_arrays 2 47181 NULL
99209 +can_set_system_xattr_47182 can_set_system_xattr 4 47182 NULL
99210 +ioremap_cache_47189 ioremap_cache 1-2 47189 NULL
99211 +gnttab_set_map_op_47206 gnttab_set_map_op 2 47206 NULL
99212 +l2headersize_47238 l2headersize 0 47238 NULL
99213 +options_write_47243 options_write 3 47243 NULL
99214 +portcntrs_1_read_47253 portcntrs_1_read 3 47253 NULL
99215 +da9052_disable_irq_nosync_47260 da9052_disable_irq_nosync 2 47260 NULL
99216 +ablkcipher_next_slow_47274 ablkcipher_next_slow 4-3 47274 NULL
99217 +tty_audit_log_47280 tty_audit_log 8 47280 NULL
99218 +gfs2_readpages_47285 gfs2_readpages 4 47285 NULL
99219 +vsnprintf_47291 vsnprintf 0 47291 NULL
99220 +tx_internal_desc_overflow_read_47300 tx_internal_desc_overflow_read 3 47300 NULL
99221 +ieee80211_if_read_dot11MeshHoldingTimeout_47356 ieee80211_if_read_dot11MeshHoldingTimeout 3 47356 NULL
99222 +avc_get_hash_stats_47359 avc_get_hash_stats 0 47359 NULL
99223 +find_first_zero_bit_le_47369 find_first_zero_bit_le 2 47369 NULL
99224 +__bio_map_kern_47379 __bio_map_kern 3 47379 NULL
99225 +nv_rd32_47390 nv_rd32 0 47390 NULL nohasharray
99226 +trace_options_core_read_47390 trace_options_core_read 3 47390 &nv_rd32_47390
99227 +nametbl_list_47391 nametbl_list 2 47391 NULL
99228 +dgrp_net_write_47392 dgrp_net_write 3 47392 NULL
99229 +pfkey_sendmsg_47394 pfkey_sendmsg 4 47394 NULL
99230 +gfn_to_pfn_prot_47398 gfn_to_pfn_prot 2 47398 NULL
99231 +ocfs2_resv_end_47408 ocfs2_resv_end 0 47408 NULL
99232 +crypto_ablkcipher_alignmask_47410 crypto_ablkcipher_alignmask 0 47410 NULL
99233 +vzalloc_47421 vzalloc 1 47421 NULL
99234 +posix_acl_from_disk_47445 posix_acl_from_disk 2 47445 NULL
99235 +__load_mapping_47460 __load_mapping 2 47460 NULL
99236 +wb_force_mapping_47485 wb_force_mapping 2 47485 NULL nohasharray
99237 +newpart_47485 newpart 6 47485 &wb_force_mapping_47485
99238 +core_sys_select_47494 core_sys_select 1 47494 NULL
99239 +unlink_simple_47506 unlink_simple 3 47506 NULL
99240 +ufs_inode_getblock_47512 ufs_inode_getblock 4 47512 NULL
99241 +vscnprintf_47533 vscnprintf 0-2 47533 NULL nohasharray
99242 +process_vm_rw_47533 process_vm_rw 3-5 47533 &vscnprintf_47533
99243 +oz_events_read_47535 oz_events_read 3 47535 NULL
99244 +ieee80211_if_fmt_min_discovery_timeout_47539 ieee80211_if_fmt_min_discovery_timeout 3 47539 NULL
99245 +read_ldt_47570 read_ldt 2 47570 NULL
99246 +pci_iomap_47575 pci_iomap 3 47575 NULL
99247 +rpipe_get_idx_47579 rpipe_get_idx 2 47579 NULL
99248 +ext4_kvzalloc_47605 ext4_kvzalloc 1 47605 NULL
99249 +sctp_ssnmap_new_47608 sctp_ssnmap_new 1-2 47608 NULL
99250 +uea_request_47613 uea_request 4 47613 NULL
99251 +cache_read_pipefs_47615 cache_read_pipefs 3 47615 NULL
99252 +twl4030_clear_set_47624 twl4030_clear_set 4 47624 NULL
99253 +irq_set_chip_47638 irq_set_chip 1 47638 NULL
99254 +__build_packet_message_47643 __build_packet_message 3-9 47643 NULL
99255 +save_microcode_47717 save_microcode 3 47717 NULL
99256 +bits_to_user_47733 bits_to_user 2-3 47733 NULL
99257 +carl9170_debugfs_read_47738 carl9170_debugfs_read 3 47738 NULL
99258 +ir_prepare_write_buffer_47747 ir_prepare_write_buffer 3 47747 NULL
99259 +mvumi_alloc_mem_resource_47750 mvumi_alloc_mem_resource 3 47750 NULL
99260 +ext3_find_near_47752 ext3_find_near 0 47752 NULL
99261 +alloc_sched_domains_47756 alloc_sched_domains 1 47756 NULL
99262 +i915_wedged_write_47771 i915_wedged_write 3 47771 NULL
99263 +uwb_ie_dump_hex_47774 uwb_ie_dump_hex 4 47774 NULL
99264 +error_error_numll_frame_cts_start_read_47781 error_error_numll_frame_cts_start_read 3 47781 NULL
99265 +posix_acl_fix_xattr_from_user_47793 posix_acl_fix_xattr_from_user 2 47793 NULL
99266 +stmmac_set_bfsize_47834 stmmac_set_bfsize 0 47834 NULL
99267 +ubifs_unpack_nnode_47866 ubifs_unpack_nnode 0 47866 NULL
99268 +vhci_read_47878 vhci_read 3 47878 NULL
99269 +keyctl_instantiate_key_common_47889 keyctl_instantiate_key_common 4 47889 NULL
99270 +load_mapping_47904 load_mapping 3 47904 NULL
99271 +osd_req_read_sg_47905 osd_req_read_sg 5 47905 NULL
99272 +comedi_write_47926 comedi_write 3 47926 NULL
99273 +lp8788_irq_map_47964 lp8788_irq_map 2 47964 NULL
99274 +iwl_dbgfs_ucode_tracing_read_47983 iwl_dbgfs_ucode_tracing_read 3 47983 NULL nohasharray
99275 +mempool_resize_47983 mempool_resize 2 47983 &iwl_dbgfs_ucode_tracing_read_47983
99276 +dbg_port_buf_47990 dbg_port_buf 2 47990 NULL
99277 +ib_umad_write_47993 ib_umad_write 3 47993 NULL
99278 +ffs_epfile_write_48014 ffs_epfile_write 3 48014 NULL
99279 +bio_integrity_set_tag_48035 bio_integrity_set_tag 3 48035 NULL
99280 +pppoe_sendmsg_48039 pppoe_sendmsg 4 48039 NULL
99281 +wpan_phy_alloc_48056 wpan_phy_alloc 1 48056 NULL
99282 +posix_acl_alloc_48063 posix_acl_alloc 1 48063 NULL
99283 +palmas_bulk_write_48068 palmas_bulk_write 2-3-5 48068 NULL
99284 +mmc_alloc_host_48097 mmc_alloc_host 1 48097 NULL
99285 +skb_copy_datagram_const_iovec_48102 skb_copy_datagram_const_iovec 4-2-5 48102 NULL
99286 +radio_isa_common_probe_48107 radio_isa_common_probe 3 48107 NULL
99287 +vmw_framebuffer_surface_dirty_48132 vmw_framebuffer_surface_dirty 6 48132 NULL
99288 +set_discoverable_48141 set_discoverable 4 48141 NULL
99289 +dn_fib_count_nhs_48145 dn_fib_count_nhs 0 48145 NULL
99290 +bitmap_onto_48152 bitmap_onto 4 48152 NULL
99291 +isr_dma1_done_read_48159 isr_dma1_done_read 3 48159 NULL
99292 +c4iw_id_table_alloc_48163 c4iw_id_table_alloc 3 48163 NULL
99293 +ocfs2_find_next_zero_bit_unaligned_48170 ocfs2_find_next_zero_bit_unaligned 2-3 48170 NULL
99294 +alloc_cc770dev_48186 alloc_cc770dev 1 48186 NULL
99295 +init_ipath_48187 init_ipath 1 48187 NULL
99296 +snd_seq_dump_var_event_48209 snd_seq_dump_var_event 0 48209 NULL
99297 +is_block_in_journal_48223 is_block_in_journal 3 48223 NULL
99298 +uv_blade_nr_possible_cpus_48226 uv_blade_nr_possible_cpus 0 48226 NULL
99299 +nilfs_readpages_48229 nilfs_readpages 4 48229 NULL
99300 +read_file_recv_48232 read_file_recv 3 48232 NULL
99301 +unaccount_shadowed_48233 unaccount_shadowed 2 48233 NULL
99302 +nfsctl_transaction_read_48250 nfsctl_transaction_read 3 48250 NULL
99303 +cache_write_pipefs_48270 cache_write_pipefs 3 48270 NULL
99304 +send_set_info_48288 send_set_info 7 48288 NULL
99305 +set_disc_pwup_pfs_48300 set_disc_pwup_pfs 3 48300 NULL
99306 +lpfc_idiag_extacc_read_48301 lpfc_idiag_extacc_read 3 48301 NULL
99307 +timblogiw_read_48305 timblogiw_read 3 48305 NULL
99308 +hash_setkey_48310 hash_setkey 3 48310 NULL
99309 +__alloc_fd_48356 __alloc_fd 2 48356 NULL
99310 +skb_add_data_48363 skb_add_data 3 48363 NULL
99311 +tx_frag_init_called_read_48377 tx_frag_init_called_read 3 48377 NULL
99312 +ixgbe_pci_sriov_enable_48410 ixgbe_pci_sriov_enable 2 48410 NULL
99313 +lbs_debugfs_write_48413 lbs_debugfs_write 3 48413 NULL
99314 +pwr_tx_without_ps_read_48423 pwr_tx_without_ps_read 3 48423 NULL
99315 +nfs4_alloc_pages_48426 nfs4_alloc_pages 1 48426 NULL
99316 +tun_recvmsg_48463 tun_recvmsg 4 48463 NULL
99317 +r8712_usbctrl_vendorreq_48489 r8712_usbctrl_vendorreq 6 48489 NULL
99318 +send_control_msg_48498 send_control_msg 6 48498 NULL
99319 +mlx4_en_create_tx_ring_48501 mlx4_en_create_tx_ring 4 48501 NULL
99320 +count_masked_bytes_48507 count_masked_bytes 0-1 48507 NULL
99321 +diva_os_copy_to_user_48508 diva_os_copy_to_user 4 48508 NULL
99322 +brcmf_sdio_trap_info_48510 brcmf_sdio_trap_info 4 48510 NULL
99323 +phantom_get_free_48514 phantom_get_free 0 48514 NULL
99324 +wiimote_hid_send_48528 wiimote_hid_send 3 48528 NULL
99325 +ext3_splice_branch_48531 ext3_splice_branch 6 48531 NULL
99326 +named_distribute_48544 named_distribute 4 48544 NULL
99327 +raid10_size_48571 raid10_size 0-2-3 48571 NULL
99328 +ufs_dtogd_48616 ufs_dtogd 0-2 48616 NULL
99329 +do_ip_vs_set_ctl_48641 do_ip_vs_set_ctl 4 48641 NULL
99330 +mtd_read_48655 mtd_read 0 48655 NULL
99331 +aes_encrypt_packets_read_48666 aes_encrypt_packets_read 3 48666 NULL
99332 +sm501_create_subdev_48668 sm501_create_subdev 3-4 48668 NULL nohasharray
99333 +sys_setgroups_48668 sys_setgroups 1 48668 &sm501_create_subdev_48668
99334 +altera_drscan_48698 altera_drscan 2 48698 NULL
99335 +kvm_set_irq_routing_48704 kvm_set_irq_routing 3 48704 NULL
99336 +ath6kl_usb_bmi_read_48745 ath6kl_usb_bmi_read 3 48745 NULL
99337 +ath6kl_regwrite_read_48747 ath6kl_regwrite_read 3 48747 NULL
99338 +l2cap_segment_sdu_48772 l2cap_segment_sdu 4 48772 NULL
99339 +lua_sysfs_write_48797 lua_sysfs_write 6 48797 NULL
99340 +il3945_sta_dbgfs_stats_table_read_48802 il3945_sta_dbgfs_stats_table_read 3 48802 NULL
99341 +twa_change_queue_depth_48808 twa_change_queue_depth 2 48808 NULL
99342 +atomic_counters_read_48827 atomic_counters_read 3 48827 NULL
99343 +efi_memory_uc_48828 efi_memory_uc 1 48828 NULL
99344 +azx_get_position_48841 azx_get_position 0 48841 NULL
99345 +vc_do_resize_48842 vc_do_resize 3-4 48842 NULL
99346 +viafb_dvp1_proc_write_48864 viafb_dvp1_proc_write 3 48864 NULL
99347 +__ffs_ep0_read_events_48868 __ffs_ep0_read_events 3 48868 NULL
99348 +sys_setgroups16_48882 sys_setgroups16 1 48882 NULL
99349 +ext2_alloc_branch_48889 ext2_alloc_branch 4 48889 NULL
99350 +crypto_cipher_ctxsize_48890 crypto_cipher_ctxsize 0 48890 NULL
99351 +xdi_copy_to_user_48900 xdi_copy_to_user 4 48900 NULL
99352 +msg_hdr_sz_48908 msg_hdr_sz 0 48908 NULL
99353 +gdth_isa_probe_one_48925 gdth_isa_probe_one 1 48925 NULL
99354 +sep_crypto_dma_48937 sep_crypto_dma 0 48937 NULL
99355 +event_heart_beat_read_48961 event_heart_beat_read 3 48961 NULL
99356 +nand_ecc_test_run_48966 nand_ecc_test_run 1 48966 NULL
99357 +vmci_handle_arr_create_48971 vmci_handle_arr_create 1 48971 NULL
99358 +batadv_orig_hash_del_if_48972 batadv_orig_hash_del_if 2 48972 NULL
99359 +_alloc_set_attr_list_48991 _alloc_set_attr_list 4 48991 NULL
99360 +rds_rm_size_48996 rds_rm_size 0-2 48996 NULL
99361 +sel_write_enforce_48998 sel_write_enforce 3 48998 NULL
99362 +transient_status_49027 transient_status 4 49027 NULL
99363 +ipath_reg_user_mr_49038 ipath_reg_user_mr 2-3 49038 NULL
99364 +setup_msi_irq_49052 setup_msi_irq 3-4 49052 NULL
99365 +ubi_read_49061 ubi_read 0 49061 NULL
99366 +scsi_register_49094 scsi_register 2 49094 NULL
99367 +paging64_walk_addr_nested_49100 paging64_walk_addr_nested 3 49100 NULL
99368 +compat_do_readv_writev_49102 compat_do_readv_writev 4 49102 NULL
99369 +xfrm_replay_state_esn_len_49119 xfrm_replay_state_esn_len 0 49119 NULL
99370 +pt_read_49136 pt_read 3 49136 NULL
99371 +tipc_multicast_49144 tipc_multicast 5 49144 NULL
99372 +atyfb_setup_generic_49151 atyfb_setup_generic 3 49151 NULL
99373 +ipwireless_tty_received_49154 ipwireless_tty_received 3 49154 NULL
99374 +f2fs_acl_count_49155 f2fs_acl_count 0-1 49155 NULL
99375 +ipw_queue_tx_init_49161 ipw_queue_tx_init 3 49161 NULL
99376 +ext4_free_clusters_after_init_49174 ext4_free_clusters_after_init 2 49174 NULL
99377 +dvb_dvr_ioctl_49182 dvb_dvr_ioctl 2 49182 NULL
99378 +iwl_dbgfs_ucode_general_stats_read_49199 iwl_dbgfs_ucode_general_stats_read 3 49199 NULL
99379 +il4965_rs_sta_dbgfs_stats_table_read_49206 il4965_rs_sta_dbgfs_stats_table_read 3 49206 NULL
99380 +do_jffs2_getxattr_49210 do_jffs2_getxattr 0 49210 NULL
99381 +nouveau_therm_create__49228 nouveau_therm_create_ 4 49228 NULL
99382 +nouveau_i2c_port_create__49237 nouveau_i2c_port_create_ 6 49237 NULL
99383 +hugetlb_cgroup_read_49259 hugetlb_cgroup_read 5 49259 NULL
99384 +ieee80211_if_read_rssi_threshold_49260 ieee80211_if_read_rssi_threshold 3 49260 NULL
99385 +osd_req_add_get_attr_list_49278 osd_req_add_get_attr_list 3 49278 NULL
99386 +rx_filter_beacon_filter_read_49279 rx_filter_beacon_filter_read 3 49279 NULL
99387 +uio_read_49300 uio_read 3 49300 NULL
99388 +ocfs2_resmap_find_free_bits_49301 ocfs2_resmap_find_free_bits 3 49301 NULL
99389 +fwtty_port_handler_49327 fwtty_port_handler 9 49327 NULL
99390 +srpt_alloc_ioctx_ring_49330 srpt_alloc_ioctx_ring 2-3-4 49330 NULL
99391 +cfpkt_setlen_49343 cfpkt_setlen 2 49343 NULL
99392 +joydev_ioctl_common_49359 joydev_ioctl_common 2 49359 NULL
99393 +ocfs2_remove_btree_range_49370 ocfs2_remove_btree_range 4-5-3 49370 NULL
99394 +px_raw_event_49371 px_raw_event 4 49371 NULL
99395 +iscsi_alloc_session_49390 iscsi_alloc_session 3 49390 NULL
99396 +applesmc_create_nodes_49392 applesmc_create_nodes 2 49392 NULL
99397 +rx_streaming_always_read_49401 rx_streaming_always_read 3 49401 NULL
99398 +tnode_alloc_49407 tnode_alloc 1 49407 NULL
99399 +samples_to_bytes_49426 samples_to_bytes 0-2 49426 NULL
99400 +md_domain_init_49432 md_domain_init 2 49432 NULL
99401 +compat_do_msg_fill_49440 compat_do_msg_fill 3 49440 NULL
99402 +agp_3_5_isochronous_node_enable_49465 agp_3_5_isochronous_node_enable 3 49465 NULL
99403 +xfs_iformat_local_49472 xfs_iformat_local 4 49472 NULL
99404 +savu_sysfs_read_49473 savu_sysfs_read 6 49473 NULL
99405 +isr_decrypt_done_read_49490 isr_decrypt_done_read 3 49490 NULL
99406 +emulator_write_phys_49520 emulator_write_phys 2-4 49520 NULL
99407 +acpi_os_ioremap_49523 acpi_os_ioremap 1-2 49523 NULL
99408 +smk_write_access_49561 smk_write_access 3 49561 NULL
99409 +ntfs_malloc_nofs_49572 ntfs_malloc_nofs 1 49572 NULL
99410 +alloc_chunk_49575 alloc_chunk 1 49575 NULL
99411 +sctp_setsockopt_default_send_param_49578 sctp_setsockopt_default_send_param 3 49578 NULL
99412 +isr_wakeups_read_49607 isr_wakeups_read 3 49607 NULL
99413 +btrfs_mksubvol_49616 btrfs_mksubvol 3 49616 NULL
99414 +heap_init_49617 heap_init 2 49617 NULL
99415 +smk_write_doi_49621 smk_write_doi 3 49621 NULL
99416 +btrfsic_cmp_log_and_dev_bytenr_49628 btrfsic_cmp_log_and_dev_bytenr 2 49628 NULL
99417 +aa_simple_write_to_buffer_49683 aa_simple_write_to_buffer 3-4 49683 NULL
99418 +sys_gethostname_49698 sys_gethostname 2 49698 NULL
99419 +cx2341x_ctrl_new_menu_49700 cx2341x_ctrl_new_menu 3 49700 NULL
99420 +dm_thin_insert_block_49720 dm_thin_insert_block 2-3 49720 NULL
99421 +sep_create_dcb_dmatables_context_kernel_49728 sep_create_dcb_dmatables_context_kernel 6 49728 NULL
99422 +sys_fsetxattr_49736 sys_fsetxattr 4 49736 NULL
99423 +check_frame_49741 check_frame 0 49741 NULL
99424 +zd_usb_iowrite16v_49744 zd_usb_iowrite16v 3 49744 NULL
99425 +btrfs_chunk_num_stripes_49751 btrfs_chunk_num_stripes 0 49751 NULL
99426 +fuse_wr_pages_49753 fuse_wr_pages 0-1-2 49753 NULL
99427 +key_conf_keylen_read_49758 key_conf_keylen_read 3 49758 NULL
99428 +fuse_conn_waiting_read_49762 fuse_conn_waiting_read 3 49762 NULL
99429 +isku_sysfs_write_49767 isku_sysfs_write 6 49767 NULL
99430 +ceph_osdc_readpages_49789 ceph_osdc_readpages 10-4 49789 NULL
99431 +nfs4_acl_new_49806 nfs4_acl_new 1 49806 NULL
99432 +arch_gnttab_map_status_49812 arch_gnttab_map_status 3 49812 NULL
99433 +ntfs_copy_from_user_iovec_49829 ntfs_copy_from_user_iovec 3-6-0 49829 NULL
99434 +add_uuid_49831 add_uuid 4 49831 NULL
99435 +ath6kl_fwlog_block_read_49836 ath6kl_fwlog_block_read 3 49836 NULL
99436 +twl4030_write_49846 twl4030_write 2 49846 NULL
99437 +scsi_dispatch_cmd_entry_49848 scsi_dispatch_cmd_entry 3 49848 NULL
99438 +timeradd_entry_49850 timeradd_entry 3 49850 NULL
99439 +sctp_setsockopt_bindx_49870 sctp_setsockopt_bindx 3 49870 NULL
99440 +ceph_get_caps_49890 ceph_get_caps 0 49890 NULL
99441 +__cow_file_range_49901 __cow_file_range 5 49901 NULL
99442 +__copy_from_user_inatomic_nocache_49921 __copy_from_user_inatomic_nocache 3 49921 NULL
99443 +batadv_tt_realloc_packet_buff_49960 batadv_tt_realloc_packet_buff 4 49960 NULL
99444 +b43legacy_pio_read_49978 b43legacy_pio_read 0 49978 NULL
99445 +ieee80211_if_fmt_dtim_count_49987 ieee80211_if_fmt_dtim_count 3 49987 NULL
99446 +l2cap_chan_send_49995 l2cap_chan_send 3 49995 NULL
99447 +__module_alloc_50004 __module_alloc 1 50004 NULL
99448 +dn_mss_from_pmtu_50011 dn_mss_from_pmtu 0-2 50011 NULL
99449 +ptrace_readdata_50020 ptrace_readdata 2-4 50020 NULL
99450 +isdn_read_50021 isdn_read 3 50021 NULL
99451 +qp_alloc_queue_50028 qp_alloc_queue 1 50028 NULL
99452 +alloc_ebda_hpc_50046 alloc_ebda_hpc 1-2 50046 NULL
99453 +vmw_surface_destroy_size_50072 vmw_surface_destroy_size 0 50072 NULL
99454 +arch_setup_ht_irq_50073 arch_setup_ht_irq 1 50073 NULL
99455 +dev_set_alias_50084 dev_set_alias 3 50084 NULL
99456 +pcpu_get_vm_areas_50085 pcpu_get_vm_areas 3 50085 NULL
99457 +sock_setsockopt_50088 sock_setsockopt 5 50088 NULL
99458 +altera_swap_dr_50090 altera_swap_dr 2 50090 NULL
99459 +read_file_slot_50111 read_file_slot 3 50111 NULL
99460 +copy_items_50140 copy_items 6 50140 NULL
99461 +tx_frag_need_fragmentation_read_50153 tx_frag_need_fragmentation_read 3 50153 NULL
99462 +set_cmd_header_50155 set_cmd_header 0 50155 NULL
99463 +reiserfs_bmap_count_50160 reiserfs_bmap_count 0 50160 NULL
99464 +aac_nark_ioremap_50163 aac_nark_ioremap 2 50163 NULL nohasharray
99465 +kmalloc_node_50163 kmalloc_node 1 50163 &aac_nark_ioremap_50163
99466 +rx_filter_ibss_filter_read_50167 rx_filter_ibss_filter_read 3 50167 NULL
99467 +odev_update_50169 odev_update 2 50169 NULL
99468 +ieee80211_if_fmt_dot11MeshHWMPRannInterval_50172 ieee80211_if_fmt_dot11MeshHWMPRannInterval 3 50172 NULL nohasharray
99469 +ubi_resize_volume_50172 ubi_resize_volume 2 50172 &ieee80211_if_fmt_dot11MeshHWMPRannInterval_50172
99470 +ib_send_cm_drep_50186 ib_send_cm_drep 3 50186 NULL
99471 +cfg80211_roamed_bss_50198 cfg80211_roamed_bss 4-6 50198 NULL
99472 +rx_rx_timeout_wa_read_50204 rx_rx_timeout_wa_read 3 50204 NULL
99473 +ieee80211_skb_resize_50211 ieee80211_skb_resize 3 50211 NULL
99474 +mon_bin_compat_ioctl_50234 mon_bin_compat_ioctl 3 50234 NULL
99475 +sg_kmalloc_50240 sg_kmalloc 1 50240 NULL
99476 +afs_extract_data_50261 afs_extract_data 5 50261 NULL
99477 +rxrpc_setsockopt_50286 rxrpc_setsockopt 5 50286 NULL
99478 +soc_codec_reg_show_50302 soc_codec_reg_show 0 50302 NULL
99479 +soc_camera_read_50319 soc_camera_read 3 50319 NULL
99480 +do_launder_page_50329 do_launder_page 0 50329 NULL
99481 +nouveau_engine_create__50331 nouveau_engine_create_ 7 50331 NULL
99482 +lpfc_idiag_pcicfg_read_50334 lpfc_idiag_pcicfg_read 3 50334 NULL
99483 +ocfs2_block_to_cluster_group_50337 ocfs2_block_to_cluster_group 2 50337 NULL nohasharray
99484 +snd_pcm_lib_writev_50337 snd_pcm_lib_writev 0-3 50337 &ocfs2_block_to_cluster_group_50337
99485 +roccat_common2_send_with_status_50343 roccat_common2_send_with_status 4 50343 NULL
99486 +tpm_read_50344 tpm_read 3 50344 NULL
99487 +kvm_arch_create_memslot_50354 kvm_arch_create_memslot 2 50354 NULL
99488 +isdn_ppp_read_50356 isdn_ppp_read 4 50356 NULL
99489 +unpack_u16_chunk_50357 unpack_u16_chunk 0 50357 NULL
99490 +xfrm_send_migrate_50365 xfrm_send_migrate 5 50365 NULL
99491 +roccat_common2_receive_50369 roccat_common2_receive 4 50369 NULL
99492 +sl_alloc_bufs_50380 sl_alloc_bufs 2 50380 NULL
99493 +l2tp_ip_sendmsg_50411 l2tp_ip_sendmsg 4 50411 NULL
99494 +iscsi_create_conn_50425 iscsi_create_conn 2 50425 NULL
99495 +validate_acl_mac_addrs_50429 validate_acl_mac_addrs 0 50429 NULL
99496 +btrfs_error_discard_extent_50444 btrfs_error_discard_extent 2 50444 NULL
99497 +pgctrl_write_50453 pgctrl_write 3 50453 NULL
99498 +force_mapping_50464 force_mapping 2 50464 NULL
99499 +cdrom_read_cdda_50478 cdrom_read_cdda 4 50478 NULL
99500 +mei_io_cb_alloc_req_buf_50493 mei_io_cb_alloc_req_buf 2 50493 NULL
99501 +pwr_rcvd_awake_beacons_read_50505 pwr_rcvd_awake_beacons_read 3 50505 NULL
99502 +fwnet_receive_packet_50537 fwnet_receive_packet 9 50537 NULL
99503 +ath6kl_set_ap_probe_resp_ies_50539 ath6kl_set_ap_probe_resp_ies 3 50539 NULL
99504 +hme_read_desc32_50574 hme_read_desc32 0 50574 NULL
99505 +fat_readpages_50582 fat_readpages 4 50582 NULL
99506 +iwl_dbgfs_missed_beacon_read_50584 iwl_dbgfs_missed_beacon_read 3 50584 NULL
99507 +build_inv_iommu_pages_50589 build_inv_iommu_pages 2-3 50589 NULL
99508 +rx_rx_checksum_result_read_50617 rx_rx_checksum_result_read 3 50617 NULL
99509 +__ffs_50625 __ffs 0 50625 NULL
99510 +simple_transaction_get_50633 simple_transaction_get 3 50633 NULL
99511 +ath6kl_tm_rx_event_50664 ath6kl_tm_rx_event 3 50664 NULL nohasharray
99512 +sys_readv_50664 sys_readv 3 50664 &ath6kl_tm_rx_event_50664
99513 +bnad_debugfs_read_50665 bnad_debugfs_read 3 50665 NULL
99514 +ext2_try_to_allocate_with_rsv_50669 ext2_try_to_allocate_with_rsv 4-2 50669 NULL
99515 +btmrvl_psstate_read_50683 btmrvl_psstate_read 3 50683 NULL
99516 +swiotlb_free_coherent_50690 swiotlb_free_coherent 4 50690 NULL
99517 +paging32_gva_to_gpa_50696 paging32_gva_to_gpa 2 50696 NULL
99518 +xfs_growfs_get_hdr_buf_50697 xfs_growfs_get_hdr_buf 3 50697 NULL
99519 +blk_check_plugged_50736 blk_check_plugged 3 50736 NULL
99520 +__ext3_get_inode_loc_50744 __ext3_get_inode_loc 0 50744 NULL
99521 +skb_padto_50759 skb_padto 2 50759 NULL
99522 +ocfs2_xattr_block_get_50773 ocfs2_xattr_block_get 0 50773 NULL
99523 +tm6000_read_write_usb_50774 tm6000_read_write_usb 7 50774 NULL
99524 +bio_alloc_map_data_50782 bio_alloc_map_data 1-2 50782 NULL
99525 +tpm_write_50798 tpm_write 3 50798 NULL
99526 +write_flush_50803 write_flush 3 50803 NULL
99527 +dvb_play_50814 dvb_play 3 50814 NULL
99528 +dpcm_show_state_50827 dpcm_show_state 0 50827 NULL
99529 +acpi_ev_install_gpe_block_50829 acpi_ev_install_gpe_block 2 50829 NULL
99530 +SetArea_50835 SetArea 4 50835 NULL nohasharray
99531 +create_mem_extents_50835 create_mem_extents 0 50835 &SetArea_50835
99532 +videobuf_dma_init_user_50839 videobuf_dma_init_user 3 50839 NULL
99533 +self_check_write_50856 self_check_write 5 50856 NULL
99534 +carl9170_debugfs_write_50857 carl9170_debugfs_write 3 50857 NULL
99535 +netlbl_secattr_catmap_walk_rng_50894 netlbl_secattr_catmap_walk_rng 0-2 50894 NULL
99536 +osd_req_write_sg_50908 osd_req_write_sg 5 50908 NULL
99537 +xfs_iext_remove_50909 xfs_iext_remove 3 50909 NULL
99538 +blk_rq_cur_sectors_50910 blk_rq_cur_sectors 0 50910 NULL
99539 +hash_recvmsg_50924 hash_recvmsg 4 50924 NULL
99540 +chd_dec_fetch_cdata_50926 chd_dec_fetch_cdata 3 50926 NULL
99541 +ocfs2_add_refcount_flag_50952 ocfs2_add_refcount_flag 6 50952 NULL
99542 +iwl_statistics_flag_50981 iwl_statistics_flag 0-3 50981 NULL
99543 +timeout_write_50991 timeout_write 3 50991 NULL
99544 +wm831x_irq_map_50995 wm831x_irq_map 2 50995 NULL
99545 +proc_write_51003 proc_write 3 51003 NULL
99546 +snd_pcm_default_page_ops_51021 snd_pcm_default_page_ops 2 51021 NULL
99547 +lbs_dev_info_51023 lbs_dev_info 3 51023 NULL
99548 +ntfs_attr_find_51028 ntfs_attr_find 0 51028 NULL nohasharray
99549 +fuse_conn_congestion_threshold_read_51028 fuse_conn_congestion_threshold_read 3 51028 &ntfs_attr_find_51028
99550 +BcmGetSectionValEndOffset_51039 BcmGetSectionValEndOffset 0 51039 NULL
99551 +dump_midi_51040 dump_midi 3 51040 NULL
99552 +srpt_alloc_ioctx_51042 srpt_alloc_ioctx 2-3 51042 NULL
99553 +do_arpt_set_ctl_51053 do_arpt_set_ctl 4 51053 NULL
99554 +wusb_prf_64_51065 wusb_prf_64 7 51065 NULL
99555 +jbd2_journal_init_revoke_51088 jbd2_journal_init_revoke 2 51088 NULL
99556 +__ocfs2_find_path_51096 __ocfs2_find_path 0 51096 NULL
99557 +ti_recv_51110 ti_recv 3 51110 NULL
99558 +dgrp_net_read_51113 dgrp_net_read 3 51113 NULL
99559 +nfs_map_name_to_uid_51132 nfs_map_name_to_uid 3 51132 NULL
99560 +alloc_rtllib_51136 alloc_rtllib 1 51136 NULL
99561 +simple_xattr_set_51140 simple_xattr_set 4 51140 NULL
99562 +set_dirty_51144 set_dirty 3 51144 NULL
99563 +xfs_trans_get_efd_51148 xfs_trans_get_efd 3 51148 NULL
99564 +compat_sys_pwritev64_51151 compat_sys_pwritev64 3 51151 NULL
99565 +blk_bio_map_sg_51213 blk_bio_map_sg 0 51213 NULL
99566 +nf_ct_ext_create_51232 nf_ct_ext_create 3 51232 NULL
99567 +snd_pcm_write_51235 snd_pcm_write 3 51235 NULL
99568 +tipc_send_51238 tipc_send 4 51238 NULL
99569 +drm_property_create_51239 drm_property_create 4 51239 NULL
99570 +st_read_51251 st_read 3 51251 NULL
99571 +compat_dccp_setsockopt_51263 compat_dccp_setsockopt 5 51263 NULL
99572 +dvb_audio_write_51275 dvb_audio_write 3 51275 NULL
99573 +ipwireless_network_packet_received_51277 ipwireless_network_packet_received 4 51277 NULL
99574 +zone_reclaimable_pages_51283 zone_reclaimable_pages 0 51283 NULL
99575 +pvr2_std_id_to_str_51288 pvr2_std_id_to_str 2 51288 NULL
99576 +bnad_debugfs_read_regrd_51308 bnad_debugfs_read_regrd 3 51308 NULL
99577 +get_cell_51316 get_cell 2 51316 NULL
99578 +alloc_hippi_dev_51320 alloc_hippi_dev 1 51320 NULL
99579 +ext2_xattr_get_51327 ext2_xattr_get 0 51327 NULL
99580 +alloc_smp_req_51337 alloc_smp_req 1 51337 NULL nohasharray
99581 +compat_arch_ptrace_51337 compat_arch_ptrace 3-4 51337 &alloc_smp_req_51337
99582 +ipw_get_event_log_len_51341 ipw_get_event_log_len 0 51341 NULL
99583 +ieee80211_if_fmt_estab_plinks_51370 ieee80211_if_fmt_estab_plinks 3 51370 NULL
99584 +radeon_kms_compat_ioctl_51371 radeon_kms_compat_ioctl 2 51371 NULL
99585 +ieee80211_wx_set_gen_ie_51399 ieee80211_wx_set_gen_ie 3 51399 NULL
99586 +ceph_sync_read_51410 ceph_sync_read 3 51410 NULL
99587 +x86_swiotlb_free_coherent_51421 x86_swiotlb_free_coherent 4 51421 NULL
99588 +blk_register_region_51424 blk_register_region 1-2 51424 NULL
99589 +mwifiex_rdeeprom_read_51429 mwifiex_rdeeprom_read 3 51429 NULL
99590 +ieee80211_if_read_dot11MeshHWMPRootMode_51441 ieee80211_if_read_dot11MeshHWMPRootMode 3 51441 NULL
99591 +print_devstats_dot11ACKFailureCount_51443 print_devstats_dot11ACKFailureCount 3 51443 NULL
99592 +____alloc_ei_netdev_51475 ____alloc_ei_netdev 1 51475 NULL
99593 +xfs_buf_get_uncached_51477 xfs_buf_get_uncached 2 51477 NULL
99594 +vaddr_51480 vaddr 0 51480 NULL
99595 +__cpa_process_fault_51502 __cpa_process_fault 2 51502 NULL
99596 +ieee80211_if_write_uapsd_queues_51526 ieee80211_if_write_uapsd_queues 3 51526 NULL
99597 +load_pdptrs_51541 load_pdptrs 3 51541 NULL
99598 +__alloc_eip_netdev_51549 __alloc_eip_netdev 1 51549 NULL
99599 +icmp_manip_pkt_51560 icmp_manip_pkt 4 51560 NULL
99600 +ixgb_get_eeprom_len_51586 ixgb_get_eeprom_len 0 51586 NULL
99601 +aac_convert_sgraw2_51598 aac_convert_sgraw2 4 51598 NULL
99602 +raw_ioctl_51607 raw_ioctl 3 51607 NULL
99603 +table_size_to_number_of_entries_51613 table_size_to_number_of_entries 0-1 51613 NULL
99604 +gnttab_end_foreign_access_51617 gnttab_end_foreign_access 3 51617 NULL
99605 +dns_resolve_server_name_to_ip_51632 dns_resolve_server_name_to_ip 0 51632 NULL
99606 +sctp_auth_create_key_51641 sctp_auth_create_key 1 51641 NULL
99607 +iscsi_create_session_51647 iscsi_create_session 3 51647 NULL
99608 +get_new_cssid_51665 get_new_cssid 2 51665 NULL
99609 +ps_upsd_utilization_read_51669 ps_upsd_utilization_read 3 51669 NULL
99610 +sctp_setsockopt_associnfo_51684 sctp_setsockopt_associnfo 3 51684 NULL
99611 +sfi_sysfs_install_table_51688 sfi_sysfs_install_table 1 51688 NULL
99612 +host_mapping_level_51696 host_mapping_level 2 51696 NULL
99613 +sel_write_access_51704 sel_write_access 3 51704 NULL
99614 +tty_cdev_add_51714 tty_cdev_add 2-4 51714 NULL
99615 +v9fs_alloc_rdir_buf_51716 v9fs_alloc_rdir_buf 2 51716 NULL
99616 +drm_compat_ioctl_51717 drm_compat_ioctl 2 51717 NULL
99617 +sg_read_oxfer_51724 sg_read_oxfer 3 51724 NULL
99618 +hid_parse_report_51737 hid_parse_report 3 51737 NULL
99619 +get_user_pages_fast_51751 get_user_pages_fast 0-1-2 51751 NULL
99620 +ifx_spi_insert_flip_string_51752 ifx_spi_insert_flip_string 3 51752 NULL
99621 +if_write_51756 if_write 3 51756 NULL
99622 +ioremap_prot_51764 ioremap_prot 1-2 51764 NULL
99623 +iio_buffer_add_channel_sysfs_51766 iio_buffer_add_channel_sysfs 0 51766 NULL
99624 +qib_alloc_devdata_51819 qib_alloc_devdata 2 51819 NULL
99625 +buffer_from_user_51826 buffer_from_user 3 51826 NULL
99626 +ioread32_51847 ioread32 0 51847 NULL nohasharray
99627 +read_file_tgt_tx_stats_51847 read_file_tgt_tx_stats 3 51847 &ioread32_51847
99628 +do_readv_writev_51849 do_readv_writev 4 51849 NULL
99629 +pointer_size_read_51863 pointer_size_read 3 51863 NULL
99630 +mlx4_alloc_db_from_pgdir_51865 mlx4_alloc_db_from_pgdir 3 51865 NULL
99631 +get_indirect_ea_51869 get_indirect_ea 4 51869 NULL
99632 +user_read_51881 user_read 3 51881 NULL
99633 +memblock_alloc_51884 memblock_alloc 1-2 51884 NULL
99634 +dbAdjCtl_51888 dbAdjCtl 0 51888 NULL
99635 +virt_to_phys_51896 virt_to_phys 0 51896 NULL
99636 +wmi_set_ie_51919 wmi_set_ie 3 51919 NULL
99637 +dbg_status_buf_51930 dbg_status_buf 2 51930 NULL
99638 +__tcp_mtu_to_mss_51938 __tcp_mtu_to_mss 0-2 51938 NULL
99639 +xfrm_alg_len_51940 xfrm_alg_len 0 51940 NULL
99640 +irq_dispose_mapping_51941 irq_dispose_mapping 1 51941 NULL
99641 +scsi_get_vpd_page_51951 scsi_get_vpd_page 4 51951 NULL
99642 +arizona_free_irq_51969 arizona_free_irq 2 51969 NULL nohasharray
99643 +snd_mask_min_51969 snd_mask_min 0 51969 &arizona_free_irq_51969
99644 +ath6kl_sdio_alloc_prep_scat_req_51986 ath6kl_sdio_alloc_prep_scat_req 2 51986 NULL
99645 +skb_copy_datagram_from_iovec_52014 skb_copy_datagram_from_iovec 4-2-5 52014 NULL
99646 +rdmalt_52022 rdmalt 0 52022 NULL
99647 +vxge_rx_alloc_52024 vxge_rx_alloc 3 52024 NULL
99648 +override_release_52032 override_release 2 52032 NULL
99649 +end_port_52042 end_port 0 52042 NULL
99650 +dma_rx_errors_read_52045 dma_rx_errors_read 3 52045 NULL
99651 +msnd_fifo_write_52052 msnd_fifo_write 0-3 52052 NULL
99652 +dvb_ringbuffer_avail_52057 dvb_ringbuffer_avail 0 52057 NULL
99653 +__fuse_request_alloc_52060 __fuse_request_alloc 1 52060 NULL
99654 +isofs_readpages_52067 isofs_readpages 4 52067 NULL
99655 +nsm_get_handle_52089 nsm_get_handle 4 52089 NULL
99656 +o2net_debug_read_52105 o2net_debug_read 3 52105 NULL
99657 +retry_count_read_52129 retry_count_read 3 52129 NULL
99658 +zram_meta_alloc_52140 zram_meta_alloc 1 52140 NULL
99659 +hysdn_conf_write_52145 hysdn_conf_write 3 52145 NULL nohasharray
99660 +ext2_alloc_blocks_52145 ext2_alloc_blocks 2 52145 &hysdn_conf_write_52145
99661 +htable_size_52148 htable_size 0-1 52148 NULL
99662 +__le16_to_cpup_52155 __le16_to_cpup 0 52155 NULL nohasharray
99663 +smk_write_load2_52155 smk_write_load2 3 52155 &__le16_to_cpup_52155
99664 +alix_present_52165 alix_present 1 52165 NULL
99665 +ieee80211_if_read_dot11MeshRetryTimeout_52168 ieee80211_if_read_dot11MeshRetryTimeout 3 52168 NULL
99666 +mga_compat_ioctl_52170 mga_compat_ioctl 2 52170 NULL
99667 +print_prefix_52176 print_prefix 0 52176 NULL
99668 +proc_pid_readlink_52186 proc_pid_readlink 3 52186 NULL
99669 +vmci_qp_broker_alloc_52216 vmci_qp_broker_alloc 5-6 52216 NULL
99670 +do_dmabuf_dirty_ldu_52241 do_dmabuf_dirty_ldu 6 52241 NULL
99671 +fuse_request_alloc_52243 fuse_request_alloc 1 52243 NULL
99672 +pm80x_request_irq_52250 pm80x_request_irq 2 52250 NULL
99673 +mdiobus_alloc_size_52259 mdiobus_alloc_size 1 52259 NULL
99674 +shrink_slab_52261 shrink_slab 2-3 52261 NULL
99675 +hva_to_pfn_slow_52262 hva_to_pfn_slow 1 52262 NULL
99676 +sisusbcon_do_font_op_52271 sisusbcon_do_font_op 9 52271 NULL
99677 +ath6kl_wmi_get_new_buf_52304 ath6kl_wmi_get_new_buf 1 52304 NULL
99678 +read_file_reset_52310 read_file_reset 3 52310 NULL
99679 +request_asymmetric_key_52317 request_asymmetric_key 2-4 52317 NULL
99680 +hwflags_read_52318 hwflags_read 3 52318 NULL
99681 +ntfs_rl_split_52328 ntfs_rl_split 2-4 52328 NULL
99682 +test_unaligned_bulk_52333 test_unaligned_bulk 3 52333 NULL
99683 +bytes_to_frames_52362 bytes_to_frames 0-2 52362 NULL
99684 +copy_entries_to_user_52367 copy_entries_to_user 1 52367 NULL
99685 +mq_emit_config_values_52378 mq_emit_config_values 3 52378 NULL
99686 +isdn_writebuf_stub_52383 isdn_writebuf_stub 4 52383 NULL
99687 +jfs_setxattr_52389 jfs_setxattr 4 52389 NULL
99688 +aer_inject_write_52399 aer_inject_write 3 52399 NULL
99689 +aac_rx_ioremap_52410 aac_rx_ioremap 2 52410 NULL
99690 +cgroup_file_write_52417 cgroup_file_write 3 52417 NULL
99691 +line6_midibuf_init_52425 line6_midibuf_init 2 52425 NULL
99692 +delay_status_52431 delay_status 5 52431 NULL
99693 +ieee80211_if_fmt_num_sta_ps_52438 ieee80211_if_fmt_num_sta_ps 3 52438 NULL
99694 +nl80211_send_mgmt_tx_status_52445 nl80211_send_mgmt_tx_status 5 52445 NULL
99695 +ieee80211_alloc_txb_52477 ieee80211_alloc_txb 1-2 52477 NULL
99696 +ocfs2_extend_no_holes_52483 ocfs2_extend_no_holes 3-4 52483 NULL
99697 +fd_do_rw_52495 fd_do_rw 3 52495 NULL nohasharray
99698 +skb_cow_head_52495 skb_cow_head 2 52495 &fd_do_rw_52495
99699 +qib_user_sdma_pin_pages_52498 qib_user_sdma_pin_pages 3-5 52498 NULL
99700 +int_tasklet_entry_52500 int_tasklet_entry 3 52500 NULL
99701 +pm_qos_power_write_52513 pm_qos_power_write 3 52513 NULL
99702 +dup_variable_bug_52525 dup_variable_bug 3 52525 NULL
99703 +from_oblock_52546 from_oblock 0-1 52546 NULL
99704 +dccpprobe_read_52549 dccpprobe_read 3 52549 NULL
99705 +ocfs2_make_right_split_rec_52562 ocfs2_make_right_split_rec 3 52562 NULL
99706 +emit_code_52583 emit_code 0-3 52583 NULL
99707 +tps80031_writes_52638 tps80031_writes 3-4 52638 NULL
99708 +brcmf_sdio_assert_info_52653 brcmf_sdio_assert_info 4 52653 NULL
99709 +nvd0_disp_pioc_create__52693 nvd0_disp_pioc_create_ 5 52693 NULL
99710 +nouveau_client_create__52715 nouveau_client_create_ 5 52715 NULL
99711 +cx25840_ir_rx_read_52724 cx25840_ir_rx_read 3 52724 NULL
99712 +blkcipher_next_slow_52733 blkcipher_next_slow 3-4 52733 NULL
99713 +relay_alloc_page_array_52735 relay_alloc_page_array 1 52735 NULL
99714 +carl9170_debugfs_vif_dump_read_52755 carl9170_debugfs_vif_dump_read 3 52755 NULL
99715 +copy_ctr_args_52761 copy_ctr_args 2 52761 NULL
99716 +pwr_rcvd_beacons_read_52836 pwr_rcvd_beacons_read 3 52836 NULL
99717 +ext2_xattr_set_acl_52857 ext2_xattr_set_acl 4 52857 NULL
99718 +mon_bin_get_event_52863 mon_bin_get_event 4 52863 NULL
99719 +twlreg_write_52880 twlreg_write 3 52880 NULL
99720 +pvr2_ctrl_value_to_sym_internal_52881 pvr2_ctrl_value_to_sym_internal 5 52881 NULL
99721 +cache_read_procfs_52882 cache_read_procfs 3 52882 NULL
99722 +kvm_kvzalloc_52894 kvm_kvzalloc 1 52894 NULL
99723 +arizona_request_irq_52908 arizona_request_irq 2 52908 NULL
99724 +__kfifo_out_peek_r_52919 __kfifo_out_peek_r 3 52919 NULL
99725 +iblock_get_bio_52936 iblock_get_bio 3 52936 NULL nohasharray
99726 +__iio_device_attr_init_52936 __iio_device_attr_init 0 52936 &iblock_get_bio_52936
99727 +__nodes_remap_52951 __nodes_remap 5 52951 NULL
99728 +send_packet_52960 send_packet 4 52960 NULL
99729 +ieee80211_if_fmt_fwded_mcast_52961 ieee80211_if_fmt_fwded_mcast 3 52961 NULL
99730 +hx8357_spi_write_then_read_52964 hx8357_spi_write_then_read 3 52964 NULL nohasharray
99731 +compat_sock_ioctl_52964 compat_sock_ioctl 3 52964 &hx8357_spi_write_then_read_52964
99732 +tx_tx_exch_read_52986 tx_tx_exch_read 3 52986 NULL
99733 +num_node_state_52989 num_node_state 0 52989 NULL
99734 +batadv_check_management_packet_52993 batadv_check_management_packet 3 52993 NULL
99735 +efivarfs_file_write_53000 efivarfs_file_write 3 53000 NULL
99736 +btrfs_free_and_pin_reserved_extent_53016 btrfs_free_and_pin_reserved_extent 2 53016 NULL
99737 +tx_tx_exch_pending_read_53018 tx_tx_exch_pending_read 3 53018 NULL
99738 +ext4_meta_bg_first_group_53031 ext4_meta_bg_first_group 0-2 53031 NULL
99739 +bio_cur_bytes_53037 bio_cur_bytes 0 53037 NULL
99740 +regcache_lzo_block_count_53056 regcache_lzo_block_count 0 53056 NULL
99741 +cfi_read_query_53066 cfi_read_query 0 53066 NULL
99742 +mwifiex_debug_read_53074 mwifiex_debug_read 3 53074 NULL
99743 +qib_resize_cq_53090 qib_resize_cq 2 53090 NULL
99744 +verity_status_53120 verity_status 5 53120 NULL
99745 +brcmf_usb_dl_cmd_53130 brcmf_usb_dl_cmd 4 53130 NULL
99746 +ps_poll_ps_poll_max_ap_turn_read_53140 ps_poll_ps_poll_max_ap_turn_read 3 53140 NULL
99747 +ieee80211_bss_info_update_53170 ieee80211_bss_info_update 4 53170 NULL
99748 +clear_capture_buf_53192 clear_capture_buf 2 53192 NULL
99749 +mtdoops_erase_block_53206 mtdoops_erase_block 2 53206 NULL
99750 +fixup_user_fault_53210 fixup_user_fault 3 53210 NULL
99751 +tx_tx_start_data_read_53219 tx_tx_start_data_read 3 53219 NULL
99752 +rbd_obj_method_sync_53252 rbd_obj_method_sync 8 53252 NULL
99753 +xfs_trans_read_buf_map_53258 xfs_trans_read_buf_map 5 53258 NULL
99754 +wil_write_file_ssid_53266 wil_write_file_ssid 3 53266 NULL
99755 +btrfs_file_extent_num_bytes_53269 btrfs_file_extent_num_bytes 0 53269 NULL
99756 +batadv_interface_rx_53325 batadv_interface_rx 4 53325 NULL
99757 +gsm_control_reply_53333 gsm_control_reply 4 53333 NULL
99758 +vm_mmap_53339 vm_mmap 0 53339 NULL
99759 +sock_setbindtodevice_53369 sock_setbindtodevice 3 53369 NULL
99760 +get_random_bytes_arch_53370 get_random_bytes_arch 2 53370 NULL
99761 +iwl_pcie_txq_alloc_53413 iwl_pcie_txq_alloc 3 53413 NULL
99762 +isr_cmd_cmplt_read_53439 isr_cmd_cmplt_read 3 53439 NULL
99763 +mwifiex_info_read_53447 mwifiex_info_read 3 53447 NULL
99764 +apei_exec_run_optional_53452 apei_exec_run_optional 0 53452 NULL
99765 +acpi_tb_parse_root_table_53455 acpi_tb_parse_root_table 1 53455 NULL
99766 +n2_run_53459 n2_run 3 53459 NULL
99767 +paging64_prefetch_gpte_53468 paging64_prefetch_gpte 4 53468 NULL
99768 +rds_tcp_data_recv_53476 rds_tcp_data_recv 3 53476 NULL
99769 +iowarrior_read_53483 iowarrior_read 3 53483 NULL
99770 +osd_req_write_kern_53486 osd_req_write_kern 5 53486 NULL
99771 +do_verify_xattr_datum_53499 do_verify_xattr_datum 0 53499 NULL
99772 +snd_pcm_format_physical_width_53505 snd_pcm_format_physical_width 0 53505 NULL
99773 +dbAllocNext_53506 dbAllocNext 0 53506 NULL
99774 +ocfs2_xattr_set_acl_53508 ocfs2_xattr_set_acl 4 53508 NULL
99775 +check_acl_53512 check_acl 0 53512 NULL
99776 +alloc_pages_exact_nid_53515 alloc_pages_exact_nid 2 53515 NULL
99777 +set_registers_53582 set_registers 3 53582 NULL
99778 +cifs_utf16_bytes_53593 cifs_utf16_bytes 0 53593 NULL
99779 +gfn_to_pfn_async_53597 gfn_to_pfn_async 2 53597 NULL
99780 +___alloc_bootmem_nopanic_53626 ___alloc_bootmem_nopanic 1-2 53626 NULL
99781 +xd_write_multiple_pages_53633 xd_write_multiple_pages 6-5 53633 NULL
99782 +ccid_getsockopt_builtin_ccids_53634 ccid_getsockopt_builtin_ccids 2 53634 NULL
99783 +nr_sendmsg_53656 nr_sendmsg 4 53656 NULL
99784 +_preload_range_53676 _preload_range 2-3 53676 NULL
99785 +fuse_fill_write_pages_53682 fuse_fill_write_pages 4 53682 NULL
99786 +v4l2_event_subscribe_53687 v4l2_event_subscribe 3 53687 NULL
99787 +bdev_logical_block_size_53690 bdev_logical_block_size 0 53690 NULL nohasharray
99788 +igb_alloc_q_vector_53690 igb_alloc_q_vector 4-6 53690 &bdev_logical_block_size_53690
99789 +find_overflow_devnum_53711 find_overflow_devnum 0 53711 NULL
99790 +bio_integrity_split_53714 bio_integrity_split 3 53714 NULL
99791 +__ocfs2_resv_find_window_53721 __ocfs2_resv_find_window 3 53721 NULL
99792 +wdm_write_53735 wdm_write 3 53735 NULL
99793 +ext3_try_to_allocate_with_rsv_53737 ext3_try_to_allocate_with_rsv 5-3 53737 NULL
99794 +da9052_disable_irq_53745 da9052_disable_irq 2 53745 NULL
99795 +lpfc_idiag_queacc_read_qe_53755 lpfc_idiag_queacc_read_qe 0-2 53755 NULL nohasharray
99796 +amdtp_out_stream_get_max_payload_53755 amdtp_out_stream_get_max_payload 0 53755 &lpfc_idiag_queacc_read_qe_53755
99797 +ext2_acl_count_53773 ext2_acl_count 0-1 53773 NULL
99798 +__kfifo_dma_in_prepare_r_53792 __kfifo_dma_in_prepare_r 4-5 53792 NULL
99799 +qp_alloc_host_work_53798 qp_alloc_host_work 3-5 53798 NULL
99800 +__tty_alloc_driver_53799 __tty_alloc_driver 1 53799 NULL
99801 +regmap_raw_write_53803 regmap_raw_write 2-4 53803 NULL
99802 +lpfc_idiag_ctlacc_read_reg_53809 lpfc_idiag_ctlacc_read_reg 0-3 53809 NULL
99803 +nls_nullsize_53815 nls_nullsize 0 53815 NULL
99804 +pms_read_53873 pms_read 3 53873 NULL
99805 +ieee80211_if_fmt_dropped_frames_congestion_53883 ieee80211_if_fmt_dropped_frames_congestion 3 53883 NULL
99806 +ocfs2_rm_xattr_cluster_53900 ocfs2_rm_xattr_cluster 5-4-3 53900 NULL
99807 +proc_file_read_53905 proc_file_read 3 53905 NULL
99808 +early_reserve_e820_53915 early_reserve_e820 1-2 53915 NULL
99809 +ocfs2_make_clusters_writable_53938 ocfs2_make_clusters_writable 4 53938 NULL
99810 +mthca_setup_cmd_doorbells_53954 mthca_setup_cmd_doorbells 2 53954 NULL
99811 +mlx4_num_eq_uar_53965 mlx4_num_eq_uar 0 53965 NULL
99812 +idetape_chrdev_write_53976 idetape_chrdev_write 3 53976 NULL
99813 +mthca_reg_user_mr_53980 mthca_reg_user_mr 2-3 53980 NULL
99814 +__ocfs2_xattr_set_value_outside_53981 __ocfs2_xattr_set_value_outside 5 53981 NULL
99815 +ieee80211_if_fmt_dot11MeshHWMPperrMinInterval_53998 ieee80211_if_fmt_dot11MeshHWMPperrMinInterval 3 53998 NULL
99816 +snd_pcm_lib_write_transfer_54018 snd_pcm_lib_write_transfer 4-2-5 54018 NULL
99817 +cmpk_message_handle_tx_54024 cmpk_message_handle_tx 4 54024 NULL
99818 +ipxrtr_route_packet_54036 ipxrtr_route_packet 4 54036 NULL
99819 +pipeline_dec_packet_out_read_54052 pipeline_dec_packet_out_read 3 54052 NULL
99820 +nl80211_send_disconnected_54056 nl80211_send_disconnected 5 54056 NULL
99821 +rproc_state_read_54057 rproc_state_read 3 54057 NULL
99822 +_malloc_54077 _malloc 1 54077 NULL
99823 +bitmap_bitremap_54096 bitmap_bitremap 4 54096 NULL
99824 +altera_set_ir_pre_54103 altera_set_ir_pre 2 54103 NULL
99825 +create_xattr_54106 create_xattr 5 54106 NULL
99826 +strn_len_54122 strn_len 0 54122 NULL
99827 +isku_receive_54130 isku_receive 4 54130 NULL
99828 +isr_host_acknowledges_read_54136 isr_host_acknowledges_read 3 54136 NULL
99829 +i2400m_zrealloc_2x_54166 i2400m_zrealloc_2x 3 54166 NULL nohasharray
99830 +memcpy_toiovec_54166 memcpy_toiovec 3 54166 &i2400m_zrealloc_2x_54166
99831 +nouveau_falcon_create__54169 nouveau_falcon_create_ 8 54169 NULL
99832 +acpi_os_read_memory_54186 acpi_os_read_memory 1-3 54186 NULL
99833 +__register_chrdev_54223 __register_chrdev 2-3 54223 NULL
99834 +_format_mac_addr_54229 _format_mac_addr 2-0 54229 NULL
99835 +pi_read_regr_54231 pi_read_regr 0 54231 NULL
99836 +reada_add_block_54247 reada_add_block 2 54247 NULL
99837 +xfs_dir2_sf_addname_hard_54254 xfs_dir2_sf_addname_hard 3 54254 NULL
99838 +ceph_msgpool_get_54258 ceph_msgpool_get 2 54258 NULL
99839 +wusb_prf_54261 wusb_prf 7 54261 NULL nohasharray
99840 +audio_write_54261 audio_write 4 54261 &wusb_prf_54261
99841 +mwifiex_getlog_read_54269 mwifiex_getlog_read 3 54269 NULL
99842 +ubi_calc_data_len_54279 ubi_calc_data_len 0-3 54279 NULL
99843 +altera_set_dr_post_54291 altera_set_dr_post 2 54291 NULL
99844 +dlm_alloc_pagevec_54296 dlm_alloc_pagevec 1 54296 NULL
99845 +get_iovec_page_array_54298 get_iovec_page_array 6 54298 NULL
99846 +sprintf_54306 sprintf 0 54306 NULL
99847 +irq_domain_associate_many_54307 irq_domain_associate_many 2 54307 NULL
99848 +br_fdb_fillbuf_54339 br_fdb_fillbuf 0 54339 NULL
99849 +__alloc_dev_table_54343 __alloc_dev_table 2 54343 NULL
99850 +__get_free_pages_54352 __get_free_pages 0 54352 NULL nohasharray
99851 +_osd_realloc_seg_54352 _osd_realloc_seg 3 54352 &__get_free_pages_54352
99852 +tcf_hash_create_54360 tcf_hash_create 4 54360 NULL
99853 +read_file_credit_dist_stats_54367 read_file_credit_dist_stats 3 54367 NULL
99854 +vfs_readlink_54368 vfs_readlink 3 54368 NULL
99855 +do_dccp_setsockopt_54377 do_dccp_setsockopt 5 54377 NULL nohasharray
99856 +intel_sdvo_write_cmd_54377 intel_sdvo_write_cmd 4 54377 &do_dccp_setsockopt_54377
99857 +ah_alloc_tmp_54378 ah_alloc_tmp 3-2 54378 NULL
99858 +gart_unmap_page_54379 gart_unmap_page 2-3 54379 NULL
99859 +snd_pcm_oss_read2_54387 snd_pcm_oss_read2 0-3 54387 NULL
99860 +i386_mmap_check_54388 i386_mmap_check 0 54388 NULL
99861 +__do_krealloc_54389 __do_krealloc 2 54389 NULL
99862 +iwl_dbgfs_power_save_status_read_54392 iwl_dbgfs_power_save_status_read 3 54392 NULL
99863 +copy_gadget_strings_54417 copy_gadget_strings 2-3 54417 NULL
99864 +swiotlb_tbl_sync_single_54486 swiotlb_tbl_sync_single 2 54486 NULL
99865 +simple_strtoull_54493 simple_strtoull 0 54493 NULL
99866 +swiotlb_tbl_map_single_54495 swiotlb_tbl_map_single 3-0 54495 NULL
99867 +btrfs_ordered_sum_size_54509 btrfs_ordered_sum_size 0-2 54509 NULL
99868 +cgroup_write_X64_54514 cgroup_write_X64 5 54514 NULL nohasharray
99869 +xen_bus_to_phys_54514 xen_bus_to_phys 0 54514 &cgroup_write_X64_54514
99870 +rfc4106_set_key_54519 rfc4106_set_key 3 54519 NULL
99871 +vmci_transport_dgram_enqueue_54525 vmci_transport_dgram_enqueue 4 54525 NULL
99872 +viacam_read_54526 viacam_read 3 54526 NULL
99873 +unix_dgram_connect_54535 unix_dgram_connect 3 54535 NULL
99874 +setsockopt_54539 setsockopt 5 54539 NULL
99875 +mwifiex_usb_submit_rx_urb_54558 mwifiex_usb_submit_rx_urb 2 54558 NULL
99876 +nfsd_vfs_write_54577 nfsd_vfs_write 6 54577 NULL
99877 +fw_iso_buffer_init_54582 fw_iso_buffer_init 3 54582 NULL
99878 +nvme_npages_54601 nvme_npages 0-1 54601 NULL
99879 +fwSendNullPacket_54618 fwSendNullPacket 2 54618 NULL
99880 +irq_timeout_read_54653 irq_timeout_read 3 54653 NULL
99881 +dns_resolver_read_54658 dns_resolver_read 3 54658 NULL
99882 +twl6030_interrupt_mask_54659 twl6030_interrupt_mask 2 54659 NULL
99883 +kvm_read_cr3_54662 kvm_read_cr3 0 54662 NULL
99884 +bio_kmalloc_54672 bio_kmalloc 2 54672 NULL
99885 +vring_new_virtqueue_54673 vring_new_virtqueue 2 54673 NULL
99886 +evm_read_key_54674 evm_read_key 3 54674 NULL
99887 +resource_string_54699 resource_string 0 54699 NULL
99888 +platform_get_irq_byname_54700 platform_get_irq_byname 0 54700 NULL
99889 +rfkill_fop_read_54711 rfkill_fop_read 3 54711 NULL
99890 +_add_sg_continuation_descriptor_54721 _add_sg_continuation_descriptor 3 54721 NULL
99891 +ocfs2_control_write_54737 ocfs2_control_write 3 54737 NULL
99892 +kzalloc_54740 kzalloc 1 54740 NULL
99893 +wep_iv_read_54744 wep_iv_read 3 54744 NULL
99894 +iio_event_chrdev_read_54757 iio_event_chrdev_read 3 54757 NULL
99895 +batadv_iv_ogm_aggregate_new_54761 batadv_iv_ogm_aggregate_new 2 54761 NULL
99896 +adis16480_show_firmware_date_54762 adis16480_show_firmware_date 3 54762 NULL
99897 +flexcop_device_kmalloc_54793 flexcop_device_kmalloc 1 54793 NULL
99898 +domain_init_54797 domain_init 2 54797 NULL
99899 +ext3_find_goal_54801 ext3_find_goal 0 54801 NULL
99900 +get_dev_size_54807 get_dev_size 0 54807 NULL
99901 +nfsd_write_54809 nfsd_write 6 54809 NULL
99902 +aes_decrypt_fail_read_54815 aes_decrypt_fail_read 3 54815 NULL nohasharray
99903 +crypto_tfm_ctx_alignment_54815 crypto_tfm_ctx_alignment 0 54815 &aes_decrypt_fail_read_54815
99904 +generic_perform_write_54832 generic_perform_write 3 54832 NULL
99905 +write_rio_54837 write_rio 3 54837 NULL
99906 +nouveau_engctx_create__54839 nouveau_engctx_create_ 8 54839 NULL nohasharray
99907 +ext3_acl_from_disk_54839 ext3_acl_from_disk 2 54839 &nouveau_engctx_create__54839
99908 +ufx_ops_write_54848 ufx_ops_write 3 54848 NULL
99909 +printer_read_54851 printer_read 3 54851 NULL
99910 +qib_reg_user_mr_54858 qib_reg_user_mr 2-3 54858 NULL
99911 +alloc_ep_req_54860 alloc_ep_req 2 54860 NULL
99912 +broadsheet_spiflash_rewrite_sector_54864 broadsheet_spiflash_rewrite_sector 2 54864 NULL
99913 +prism_build_supp_rates_54865 prism_build_supp_rates 0 54865 NULL
99914 +tcf_csum_ipv6_tcp_54877 tcf_csum_ipv6_tcp 4 54877 NULL
99915 +iscsi_pool_init_54913 iscsi_pool_init 2-4 54913 NULL
99916 +btrfs_stack_chunk_num_stripes_54923 btrfs_stack_chunk_num_stripes 0 54923 NULL
99917 +mxms_structlen_54939 mxms_structlen 0 54939 NULL
99918 +add_port_54941 add_port 2 54941 NULL
99919 +virtblk_add_buf_wait_54943 virtblk_add_buf_wait 3-4 54943 NULL
99920 +wl12xx_cmd_build_probe_req_54946 wl12xx_cmd_build_probe_req 6-8 54946 NULL
99921 +ath9k_dump_btcoex_54949 ath9k_dump_btcoex 0 54949 NULL
99922 +c4_add_card_54968 c4_add_card 3 54968 NULL
99923 +iwl_pcie_dump_fh_54975 iwl_pcie_dump_fh 0 54975 NULL
99924 +__proc_file_read_54978 __proc_file_read 3 54978 NULL
99925 +ext3_xattr_get_54989 ext3_xattr_get 0 54989 NULL
99926 +Bus_to_Virtual_54991 Bus_to_Virtual 1 54991 NULL
99927 +cx231xx_v4l2_read_55014 cx231xx_v4l2_read 3 55014 NULL
99928 +paging32_get_level1_sp_gpa_55022 paging32_get_level1_sp_gpa 0 55022 NULL
99929 +error_error_null_Frame_tx_start_read_55024 error_error_null_Frame_tx_start_read 3 55024 NULL
99930 +__netdev_alloc_skb_ip_align_55067 __netdev_alloc_skb_ip_align 2 55067 NULL
99931 +apei_exec_run_55075 apei_exec_run 0 55075 NULL
99932 +bitmap_storage_alloc_55077 bitmap_storage_alloc 2 55077 NULL
99933 +hx8357_spi_write_array_55095 hx8357_spi_write_array 3 55095 NULL
99934 +rxpipe_beacon_buffer_thres_host_int_trig_rx_data_read_55106 rxpipe_beacon_buffer_thres_host_int_trig_rx_data_read 3 55106 NULL
99935 +corrupt_data_55120 corrupt_data 0 55120 NULL
99936 +crypto_ahash_setkey_55134 crypto_ahash_setkey 3 55134 NULL
99937 +ocfs2_prepare_refcount_change_for_del_55137 ocfs2_prepare_refcount_change_for_del 3 55137 NULL nohasharray
99938 +filldir_55137 filldir 3 55137 &ocfs2_prepare_refcount_change_for_del_55137
99939 +ocfs2_truncate_file_55148 ocfs2_truncate_file 3 55148 NULL
99940 +ieee80211_if_read_uapsd_queues_55150 ieee80211_if_read_uapsd_queues 3 55150 NULL
99941 +mtd_get_fact_prot_info_55186 mtd_get_fact_prot_info 0 55186 NULL
99942 +sel_write_relabel_55195 sel_write_relabel 3 55195 NULL
99943 +sched_feat_write_55202 sched_feat_write 3 55202 NULL
99944 +ht40allow_map_read_55209 ht40allow_map_read 3 55209 NULL
99945 +__kfifo_dma_out_prepare_r_55211 __kfifo_dma_out_prepare_r 4-5 55211 NULL
99946 +do_raw_setsockopt_55215 do_raw_setsockopt 5 55215 NULL
99947 +dump_command_55220 dump_command 1 55220 NULL
99948 +dbAllocDmap_55227 dbAllocDmap 0 55227 NULL
99949 +tipc_port_reject_sections_55229 tipc_port_reject_sections 5 55229 NULL
99950 +register_unifi_sdio_55239 register_unifi_sdio 2 55239 NULL
99951 +memcpy_fromiovec_55247 memcpy_fromiovec 3 55247 NULL
99952 +ptrace_request_55288 ptrace_request 3 55288 NULL
99953 +rx_streaming_interval_read_55291 rx_streaming_interval_read 3 55291 NULL
99954 +gsm_control_modem_55303 gsm_control_modem 3 55303 NULL
99955 +qp_alloc_guest_work_55305 qp_alloc_guest_work 3-5 55305 NULL nohasharray
99956 +__get_vm_area_node_55305 __get_vm_area_node 1 55305 &qp_alloc_guest_work_55305
99957 +do_shmat_55336 do_shmat 5 55336 NULL
99958 +vme_user_read_55338 vme_user_read 3 55338 NULL
99959 +sctp_datamsg_from_user_55342 sctp_datamsg_from_user 4 55342 NULL nohasharray
99960 +__wa_xfer_setup_sizes_55342 __wa_xfer_setup_sizes 0 55342 &sctp_datamsg_from_user_55342
99961 +__memblock_alloc_base_55359 __memblock_alloc_base 1-2 55359 NULL
99962 +acpi_system_read_event_55362 acpi_system_read_event 3 55362 NULL
99963 +nf_nat_ipv4_manip_pkt_55387 nf_nat_ipv4_manip_pkt 2 55387 NULL
99964 +iwl_dbgfs_plcp_delta_read_55407 iwl_dbgfs_plcp_delta_read 3 55407 NULL
99965 +alloc_skb_55439 alloc_skb 1 55439 NULL
99966 +__vxge_hw_channel_allocate_55462 __vxge_hw_channel_allocate 3 55462 NULL
99967 +isdnhdlc_decode_55466 isdnhdlc_decode 0 55466 NULL
99968 +cx23888_ir_rx_read_55473 cx23888_ir_rx_read 3 55473 NULL
99969 +batadv_unicast_push_and_fill_skb_55474 batadv_unicast_push_and_fill_skb 2 55474 NULL
99970 +snd_pcm_lib_write_55483 snd_pcm_lib_write 0-3 55483 NULL
99971 +i2o_pool_alloc_55485 i2o_pool_alloc 4 55485 NULL
99972 +ocfs2_rec_clusters_55501 ocfs2_rec_clusters 0 55501 NULL
99973 +ext4_flex_bg_size_55502 ext4_flex_bg_size 0 55502 NULL
99974 +cfpkt_pad_trail_55511 cfpkt_pad_trail 2 55511 NULL nohasharray
99975 +tx_tx_done_int_template_read_55511 tx_tx_done_int_template_read 3 55511 &cfpkt_pad_trail_55511
99976 +ea_get_55522 ea_get 0 55522 NULL
99977 +buffer_size_55534 buffer_size 0 55534 NULL
99978 +set_msr_interception_55538 set_msr_interception 2 55538 NULL
99979 +tty_port_register_device_55543 tty_port_register_device 3 55543 NULL
99980 +add_partition_55588 add_partition 2 55588 NULL
99981 +free_pages_55603 free_pages 1 55603 NULL
99982 +macvtap_put_user_55609 macvtap_put_user 4 55609 NULL
99983 +selinux_setprocattr_55611 selinux_setprocattr 4 55611 NULL
99984 +edge_tty_recv_55622 edge_tty_recv 3 55622 NULL
99985 +reiserfs_xattr_get_55628 reiserfs_xattr_get 0 55628 NULL nohasharray
99986 +pktgen_if_write_55628 pktgen_if_write 3 55628 &reiserfs_xattr_get_55628
99987 +dvb_dmxdev_set_buffer_size_55643 dvb_dmxdev_set_buffer_size 2 55643 NULL
99988 +mlx4_buddy_alloc_55647 mlx4_buddy_alloc 2 55647 NULL
99989 +xfs_bmbt_maxrecs_55649 xfs_bmbt_maxrecs 0-2 55649 NULL
99990 +ib_umad_compat_ioctl_55650 ib_umad_compat_ioctl 3 55650 NULL
99991 +cfg80211_send_rx_assoc_55651 cfg80211_send_rx_assoc 4 55651 NULL
99992 +read_oldmem_55658 read_oldmem 3 55658 NULL
99993 +lpfc_idiag_queinfo_read_55662 lpfc_idiag_queinfo_read 3 55662 NULL
99994 +il_dbgfs_tx_queue_read_55668 il_dbgfs_tx_queue_read 3 55668 NULL
99995 +get_info_55681 get_info 3 55681 NULL
99996 +wil_vring_alloc_skb_55703 wil_vring_alloc_skb 4 55703 NULL
99997 +__videobuf_alloc_uncached_55711 __videobuf_alloc_uncached 1 55711 NULL
99998 +pm8001_store_update_fw_55716 pm8001_store_update_fw 4 55716 NULL
99999 +mtdswap_init_55719 mtdswap_init 2 55719 NULL
100000 +__iio_allocate_kfifo_55738 __iio_allocate_kfifo 2 55738 NULL
100001 +set_local_name_55757 set_local_name 4 55757 NULL
100002 +strlen_55778 strlen 0 55778 NULL
100003 +set_spte_55783 set_spte 5-4 55783 NULL
100004 +req_bio_endio_55786 req_bio_endio 3 55786 NULL nohasharray
100005 +conf_read_55786 conf_read 3 55786 &req_bio_endio_55786
100006 +uwb_rc_neh_grok_event_55799 uwb_rc_neh_grok_event 3 55799 NULL
100007 +sb16_copy_from_user_55836 sb16_copy_from_user 10-6-7 55836 NULL
100008 +ip_hdrlen_55849 ip_hdrlen 0 55849 NULL
100009 +hcd_alloc_coherent_55862 hcd_alloc_coherent 5 55862 NULL
100010 +shmem_setxattr_55867 shmem_setxattr 4 55867 NULL
100011 +hsc_write_55875 hsc_write 3 55875 NULL
100012 +pm_qos_power_read_55891 pm_qos_power_read 3 55891 NULL
100013 +snd_pcm_hw_param_value_min_55917 snd_pcm_hw_param_value_min 0 55917 NULL
100014 +paging64_page_fault_55942 paging64_page_fault 2 55942 NULL
100015 +sel_read_policy_55947 sel_read_policy 3 55947 NULL
100016 +ceph_get_direct_page_vector_55956 ceph_get_direct_page_vector 2 55956 NULL
100017 +simple_read_from_buffer_55957 simple_read_from_buffer 2-5 55957 NULL
100018 +tx_tx_imm_resp_read_55964 tx_tx_imm_resp_read 3 55964 NULL
100019 +ssb_bus_pcmciabus_register_56020 ssb_bus_pcmciabus_register 3 56020 NULL
100020 +nvme_alloc_iod_56027 nvme_alloc_iod 1-2 56027 NULL
100021 +dccp_sendmsg_56058 dccp_sendmsg 4 56058 NULL
100022 +__set_discard_56081 __set_discard 2 56081 NULL
100023 +pscsi_get_bio_56103 pscsi_get_bio 1 56103 NULL
100024 +usb_alloc_stream_buffers_56123 usb_alloc_stream_buffers 3 56123 NULL
100025 +kmem_zalloc_large_56128 kmem_zalloc_large 1 56128 NULL
100026 +sel_read_handle_status_56139 sel_read_handle_status 3 56139 NULL
100027 +map_addr_56144 map_addr 7 56144 NULL
100028 +rawv6_setsockopt_56165 rawv6_setsockopt 5 56165 NULL
100029 +create_irq_nr_56180 create_irq_nr 1 56180 NULL
100030 +ath9k_dump_legacy_btcoex_56194 ath9k_dump_legacy_btcoex 0 56194 NULL
100031 +skb_headroom_56200 skb_headroom 0 56200 NULL
100032 +usb_dump_iad_descriptor_56204 usb_dump_iad_descriptor 0 56204 NULL
100033 +ncp_read_bounce_size_56221 ncp_read_bounce_size 0-1 56221 NULL
100034 +ocfs2_find_xe_in_bucket_56224 ocfs2_find_xe_in_bucket 0 56224 NULL
100035 +cp210x_get_config_56229 cp210x_get_config 4 56229 NULL
100036 +do_ipt_set_ctl_56238 do_ipt_set_ctl 4 56238 NULL
100037 +fd_copyin_56247 fd_copyin 3 56247 NULL
100038 +sk_rmem_schedule_56255 sk_rmem_schedule 3 56255 NULL
100039 +il4965_ucode_general_stats_read_56277 il4965_ucode_general_stats_read 3 56277 NULL
100040 +ieee80211_if_fmt_user_power_level_56283 ieee80211_if_fmt_user_power_level 3 56283 NULL
100041 +RESIZE_IF_NEEDED_56286 RESIZE_IF_NEEDED 2 56286 NULL
100042 +dvb_aplay_56296 dvb_aplay 3 56296 NULL
100043 +btmrvl_hscfgcmd_read_56303 btmrvl_hscfgcmd_read 3 56303 NULL
100044 +compat_cdrom_read_audio_56304 compat_cdrom_read_audio 4 56304 NULL
100045 +pipeline_pre_to_defrag_swi_read_56321 pipeline_pre_to_defrag_swi_read 3 56321 NULL
100046 +journal_init_revoke_table_56331 journal_init_revoke_table 1 56331 NULL
100047 +snd_rawmidi_read_56337 snd_rawmidi_read 3 56337 NULL
100048 +sixpack_compat_ioctl_56346 sixpack_compat_ioctl 4 56346 NULL
100049 +vxge_os_dma_malloc_async_56348 vxge_os_dma_malloc_async 3 56348 NULL
100050 +iov_iter_copy_from_user_atomic_56368 iov_iter_copy_from_user_atomic 4 56368 NULL
100051 +dev_read_56369 dev_read 3 56369 NULL
100052 +ocfs2_control_read_56405 ocfs2_control_read 3 56405 NULL
100053 +__get_vm_area_caller_56416 __get_vm_area_caller 1 56416 NULL nohasharray
100054 +acpi_os_write_memory_56416 acpi_os_write_memory 1-3 56416 &__get_vm_area_caller_56416
100055 +store_msg_56417 store_msg 3 56417 NULL
100056 +pppol2tp_sendmsg_56420 pppol2tp_sendmsg 4 56420 NULL
100057 +fl_create_56435 fl_create 5 56435 NULL
100058 +gnttab_map_56439 gnttab_map 2 56439 NULL
100059 +cx231xx_init_isoc_56453 cx231xx_init_isoc 3-2 56453 NULL
100060 +set_connectable_56458 set_connectable 4 56458 NULL
100061 +osd_req_list_partition_objects_56464 osd_req_list_partition_objects 5 56464 NULL
100062 +calc_linear_pos_56472 calc_linear_pos 0-3 56472 NULL
100063 +crypto_shash_alignmask_56486 crypto_shash_alignmask 0 56486 NULL
100064 +ieee80211_rx_mgmt_probe_beacon_56491 ieee80211_rx_mgmt_probe_beacon 3 56491 NULL
100065 +cfg80211_connect_result_56515 cfg80211_connect_result 4-6 56515 NULL
100066 +ip_options_get_56538 ip_options_get 4 56538 NULL
100067 +ocfs2_change_extent_flag_56549 ocfs2_change_extent_flag 5 56549 NULL
100068 +alloc_apertures_56561 alloc_apertures 1 56561 NULL
100069 +rs_sta_dbgfs_stats_table_read_56573 rs_sta_dbgfs_stats_table_read 3 56573 NULL
100070 +portcntrs_2_read_56586 portcntrs_2_read 3 56586 NULL
100071 +event_filter_write_56609 event_filter_write 3 56609 NULL
100072 +gather_array_56641 gather_array 3 56641 NULL
100073 +uvc_debugfs_stats_read_56651 uvc_debugfs_stats_read 3 56651 NULL
100074 +snd_gus_dram_read_56686 snd_gus_dram_read 4 56686 NULL nohasharray
100075 +da9055_gpio_to_irq_56686 da9055_gpio_to_irq 2 56686 &snd_gus_dram_read_56686
100076 +build_map_info_56696 build_map_info 2 56696 NULL
100077 +dvb_ringbuffer_read_user_56702 dvb_ringbuffer_read_user 3 56702 NULL
100078 +sta_flags_read_56710 sta_flags_read 3 56710 NULL
100079 +ipv6_getsockopt_sticky_56711 ipv6_getsockopt_sticky 5 56711 NULL
100080 +__wa_xfer_setup_segs_56725 __wa_xfer_setup_segs 2 56725 NULL
100081 +pcpu_populate_chunk_56741 pcpu_populate_chunk 2-3 56741 NULL
100082 +drm_agp_bind_pages_56748 drm_agp_bind_pages 3 56748 NULL
100083 +btrfsic_map_block_56751 btrfsic_map_block 2 56751 NULL
100084 +alloc_iommu_56778 alloc_iommu 2-3 56778 NULL
100085 +__carl9170_rx_56784 __carl9170_rx 3 56784 NULL
100086 +hash_lookup_56792 hash_lookup 2 56792 NULL
100087 +do_syslog_56807 do_syslog 3 56807 NULL
100088 +mtdchar_write_56831 mtdchar_write 3 56831 NULL nohasharray
100089 +ntfs_rl_realloc_56831 ntfs_rl_realloc 3 56831 &mtdchar_write_56831
100090 +snd_rawmidi_kernel_write1_56847 snd_rawmidi_kernel_write1 4 56847 NULL
100091 +wb_lookup_56858 wb_lookup 2 56858 NULL
100092 +ext3_xattr_ibody_get_56880 ext3_xattr_ibody_get 0 56880 NULL
100093 +pvr2_debugifc_print_status_56890 pvr2_debugifc_print_status 3 56890 NULL
100094 +debug_debug3_read_56894 debug_debug3_read 3 56894 NULL
100095 +batadv_tt_update_changes_56895 batadv_tt_update_changes 3 56895 NULL
100096 +strcspn_56913 strcspn 0 56913 NULL
100097 +__kfifo_out_56927 __kfifo_out 0-3 56927 NULL
100098 +check_header_56930 check_header 2 56930 NULL
100099 +journal_init_revoke_56933 journal_init_revoke 2 56933 NULL
100100 +diva_get_driver_info_56967 diva_get_driver_info 0 56967 NULL
100101 +nouveau_device_create__56984 nouveau_device_create_ 6 56984 NULL
100102 +vlsi_alloc_ring_57003 vlsi_alloc_ring 3-4 57003 NULL
100103 +btrfs_super_csum_size_57004 btrfs_super_csum_size 0 57004 NULL
100104 +aircable_process_packet_57027 aircable_process_packet 4 57027 NULL
100105 +skb_network_offset_57043 skb_network_offset 0 57043 NULL nohasharray
100106 +ieee80211_if_fmt_state_57043 ieee80211_if_fmt_state 3 57043 &skb_network_offset_57043
100107 +bytes_to_samples_57049 bytes_to_samples 0-2 57049 NULL
100108 +xfs_buf_read_map_57053 xfs_buf_read_map 3 57053 NULL
100109 +autofs_dev_ioctl_compat_57059 autofs_dev_ioctl_compat 3 57059 NULL
100110 +cx2341x_ctrl_new_std_57061 cx2341x_ctrl_new_std 4 57061 NULL
100111 +sca3000_read_data_57064 sca3000_read_data 4 57064 NULL
100112 +pcmcia_replace_cis_57066 pcmcia_replace_cis 3 57066 NULL
100113 +sis190_try_rx_copy_57069 sis190_try_rx_copy 3 57069 NULL
100114 +tracing_set_trace_write_57096 tracing_set_trace_write 3 57096 NULL
100115 +crypto_compress_ctxsize_57109 crypto_compress_ctxsize 0 57109 NULL
100116 +sysfs_write_file_57116 sysfs_write_file 3 57116 NULL
100117 +cipso_v4_gentag_loc_57119 cipso_v4_gentag_loc 0 57119 NULL
100118 +nl80211_send_deauth_57136 nl80211_send_deauth 4 57136 NULL nohasharray
100119 +rds_ib_sub_signaled_57136 rds_ib_sub_signaled 2 57136 &nl80211_send_deauth_57136 nohasharray
100120 +ima_show_htable_value_57136 ima_show_htable_value 2 57136 &rds_ib_sub_signaled_57136
100121 +snd_sonicvibes_getdmac_57140 snd_sonicvibes_getdmac 0 57140 NULL
100122 +udl_prime_create_57159 udl_prime_create 2 57159 NULL
100123 +__ipath_get_user_pages_57166 __ipath_get_user_pages 1-2 57166 NULL
100124 +stk_prepare_sio_buffers_57168 stk_prepare_sio_buffers 2 57168 NULL
100125 +rx_hw_stuck_read_57179 rx_hw_stuck_read 3 57179 NULL
100126 +tt3650_ci_msg_57219 tt3650_ci_msg 4 57219 NULL
100127 +dma_fifo_alloc_57236 dma_fifo_alloc 5-3-2 57236 NULL
100128 +ieee80211_if_fmt_tsf_57249 ieee80211_if_fmt_tsf 3 57249 NULL
100129 +oprofilefs_ulong_from_user_57251 oprofilefs_ulong_from_user 3 57251 NULL
100130 +alloc_flex_gd_57259 alloc_flex_gd 1 57259 NULL
100131 +security_mmap_file_57268 security_mmap_file 0 57268 NULL
100132 +pstore_file_read_57288 pstore_file_read 3 57288 NULL
100133 +snd_pcm_read_57289 snd_pcm_read 3 57289 NULL
100134 +ath6kl_buf_alloc_57304 ath6kl_buf_alloc 1 57304 NULL
100135 +fw_file_size_57307 fw_file_size 0 57307 NULL
100136 +ftdi_elan_write_57309 ftdi_elan_write 3 57309 NULL
100137 +__mxt_write_reg_57326 __mxt_write_reg 3 57326 NULL
100138 +ocfs2_xattr_shrink_size_57328 ocfs2_xattr_shrink_size 3 57328 NULL
100139 +check_mirror_57342 check_mirror 1-2 57342 NULL nohasharray
100140 +usblp_read_57342 usblp_read 3 57342 &check_mirror_57342
100141 +print_devstats_dot11RTSFailureCount_57347 print_devstats_dot11RTSFailureCount 3 57347 NULL
100142 +tipc_bclink_stats_57372 tipc_bclink_stats 2 57372 NULL
100143 +max8997_irq_domain_map_57375 max8997_irq_domain_map 2 57375 NULL
100144 +tty_register_device_attr_57381 tty_register_device_attr 2 57381 NULL
100145 +read_file_blob_57406 read_file_blob 3 57406 NULL
100146 +enclosure_register_57412 enclosure_register 3 57412 NULL
100147 +gre_manip_pkt_57416 gre_manip_pkt 4 57416 NULL
100148 +compat_keyctl_instantiate_key_iov_57431 compat_keyctl_instantiate_key_iov 3 57431 NULL nohasharray
100149 +alloc_ftrace_hash_57431 alloc_ftrace_hash 1 57431 &compat_keyctl_instantiate_key_iov_57431
100150 +copy_to_user_fromio_57432 copy_to_user_fromio 3 57432 NULL
100151 +sys_pselect6_57449 sys_pselect6 1 57449 NULL
100152 +ReadReg_57453 ReadReg 0 57453 NULL
100153 +__roundup_pow_of_two_57461 __roundup_pow_of_two 0 57461 NULL
100154 +crypto_tfm_alg_blocksize_57463 crypto_tfm_alg_blocksize 0 57463 NULL nohasharray
100155 +send_midi_async_57463 send_midi_async 3 57463 &crypto_tfm_alg_blocksize_57463
100156 +sisusb_clear_vram_57466 sisusb_clear_vram 3-2 57466 NULL
100157 +ieee80211_if_read_flags_57470 ieee80211_if_read_flags 3 57470 NULL nohasharray
100158 +sep_lock_user_pages_57470 sep_lock_user_pages 2-3 57470 &ieee80211_if_read_flags_57470
100159 +ocfs2_write_cluster_57483 ocfs2_write_cluster 8-2-9 57483 NULL
100160 +bnad_debugfs_write_regwr_57500 bnad_debugfs_write_regwr 3 57500 NULL
100161 +skb_headlen_57501 skb_headlen 0 57501 NULL
100162 +copy_in_user_57502 copy_in_user 3 57502 NULL
100163 +ks8842_read32_57505 ks8842_read32 0 57505 NULL nohasharray
100164 +ckhdid_printf_57505 ckhdid_printf 2 57505 &ks8842_read32_57505
100165 +init_tag_map_57515 init_tag_map 3 57515 NULL
100166 +wil_read_file_ssid_57517 wil_read_file_ssid 3 57517 NULL nohasharray
100167 +il_dbgfs_force_reset_read_57517 il_dbgfs_force_reset_read 3 57517 &wil_read_file_ssid_57517
100168 +inode_permission_57531 inode_permission 0 57531 NULL
100169 +acpi_dev_get_resources_57534 acpi_dev_get_resources 0 57534 NULL nohasharray
100170 +DoC_Probe_57534 DoC_Probe 1 57534 &acpi_dev_get_resources_57534
100171 +ext4_group_first_block_no_57559 ext4_group_first_block_no 0-2 57559 NULL
100172 +snd_pcm_playback_ioctl1_57569 snd_pcm_playback_ioctl1 0 57569 NULL
100173 +uio_find_mem_index_57584 uio_find_mem_index 0 57584 NULL
100174 +read_file_spectral_fft_period_57593 read_file_spectral_fft_period 3 57593 NULL
100175 +wm831x_gpio_to_irq_57614 wm831x_gpio_to_irq 2 57614 NULL
100176 +sk_stream_alloc_skb_57622 sk_stream_alloc_skb 2 57622 NULL
100177 +tx_tx_retry_template_read_57623 tx_tx_retry_template_read 3 57623 NULL
100178 +osdmap_set_max_osd_57630 osdmap_set_max_osd 2 57630 NULL nohasharray
100179 +sisusbcon_putcs_57630 sisusbcon_putcs 3 57630 &osdmap_set_max_osd_57630
100180 +mem_read_57631 mem_read 3 57631 NULL
100181 +tc3589x_irq_map_57639 tc3589x_irq_map 2 57639 NULL
100182 +sys_mq_timedsend_57661 sys_mq_timedsend 3 57661 NULL
100183 +r3964_write_57662 r3964_write 4 57662 NULL
100184 +proc_ns_readlink_57664 proc_ns_readlink 3 57664 NULL
100185 +__lgwrite_57669 __lgwrite 4 57669 NULL
100186 +ieee80211_MFIE_rate_len_57692 ieee80211_MFIE_rate_len 0 57692 NULL
100187 +f1x_match_to_this_node_57695 f1x_match_to_this_node 3 57695 NULL
100188 +check_prefree_segments_57702 check_prefree_segments 2 57702 NULL
100189 +i2400m_rx_stats_read_57706 i2400m_rx_stats_read 3 57706 NULL
100190 +ieee80211_if_read_dot11MeshHWMPconfirmationInterval_57722 ieee80211_if_read_dot11MeshHWMPconfirmationInterval 3 57722 NULL
100191 +nouveau_gpio_create__57735 nouveau_gpio_create_ 4-5 57735 NULL
100192 +compat_sys_set_mempolicy_57742 compat_sys_set_mempolicy 3 57742 NULL
100193 +ieee80211_if_fmt_dot11MeshHWMPpreqMinInterval_57762 ieee80211_if_fmt_dot11MeshHWMPpreqMinInterval 3 57762 NULL
100194 +ld2_57794 ld2 0 57794 NULL
100195 +ivtv_read_57796 ivtv_read 3 57796 NULL
100196 +generic_ptrace_peekdata_57806 generic_ptrace_peekdata 2 57806 NULL
100197 +ipath_user_sdma_num_pages_57813 ipath_user_sdma_num_pages 0 57813 NULL
100198 +usb_dump_config_57817 usb_dump_config 0 57817 NULL
100199 +bfad_debugfs_read_regrd_57830 bfad_debugfs_read_regrd 3 57830 NULL
100200 +copy_to_user_57835 copy_to_user 3 57835 NULL
100201 +flash_read_57843 flash_read 3 57843 NULL
100202 +xt_alloc_table_info_57903 xt_alloc_table_info 1 57903 NULL
100203 +emi26_writememory_57908 emi26_writememory 4 57908 NULL
100204 +iio_read_first_n_kfifo_57910 iio_read_first_n_kfifo 2 57910 NULL
100205 +memcg_caches_array_size_57918 memcg_caches_array_size 0-1 57918 NULL
100206 +twl_i2c_write_57923 twl_i2c_write 4-3 57923 NULL
100207 +__snd_gf1_look16_57925 __snd_gf1_look16 0 57925 NULL
100208 +sel_read_handle_unknown_57933 sel_read_handle_unknown 3 57933 NULL
100209 +key_algorithm_read_57946 key_algorithm_read 3 57946 NULL
100210 +ip_set_alloc_57953 ip_set_alloc 1 57953 NULL nohasharray
100211 +ioat3_dca_count_dca_slots_57953 ioat3_dca_count_dca_slots 0 57953 &ip_set_alloc_57953
100212 +i915_cache_sharing_write_57961 i915_cache_sharing_write 3 57961 NULL
100213 +hfc_empty_fifo_57972 hfc_empty_fifo 2 57972 NULL
100214 +c2_reg_user_mr_57982 c2_reg_user_mr 2-3 57982 NULL
100215 +rx_reset_counter_read_58001 rx_reset_counter_read 3 58001 NULL
100216 +regcache_rbtree_insert_to_block_58009 regcache_rbtree_insert_to_block 5 58009 NULL
100217 +iwl_dbgfs_ucode_rx_stats_read_58023 iwl_dbgfs_ucode_rx_stats_read 3 58023 NULL
100218 +io_playback_transfer_58030 io_playback_transfer 4 58030 NULL
100219 +mce_async_out_58056 mce_async_out 3 58056 NULL
100220 +ocfs2_find_leaf_58065 ocfs2_find_leaf 0 58065 NULL
100221 +dt3155_alloc_coherent_58073 dt3155_alloc_coherent 2 58073 NULL
100222 +cm4040_write_58079 cm4040_write 3 58079 NULL
100223 +udi_log_event_58105 udi_log_event 3 58105 NULL
100224 +savemem_58129 savemem 3 58129 NULL
100225 +ipv6_flowlabel_opt_58135 ipv6_flowlabel_opt 3 58135 NULL nohasharray
100226 +slhc_init_58135 slhc_init 1-2 58135 &ipv6_flowlabel_opt_58135
100227 +garmin_write_bulk_58191 garmin_write_bulk 3 58191 NULL
100228 +asix_write_cmd_58192 asix_write_cmd 5 58192 NULL
100229 +ieee80211_if_fmt_flags_58205 ieee80211_if_fmt_flags 3 58205 NULL
100230 +hva_to_pfn_58241 hva_to_pfn 1 58241 NULL
100231 +btrfsic_create_link_to_next_block_58246 btrfsic_create_link_to_next_block 4 58246 NULL
100232 +read_file_debug_58256 read_file_debug 3 58256 NULL
100233 +cfg80211_mgmt_tx_status_58266 cfg80211_mgmt_tx_status 4 58266 NULL
100234 +profile_load_58267 profile_load 3 58267 NULL
100235 +acpi_ds_build_internal_package_obj_58271 acpi_ds_build_internal_package_obj 3 58271 NULL
100236 +r100_mm_rreg_58276 r100_mm_rreg 0 58276 NULL
100237 +iscsi_decode_text_input_58292 iscsi_decode_text_input 4 58292 NULL
100238 +ieee80211_if_read_dot11MeshTTL_58307 ieee80211_if_read_dot11MeshTTL 3 58307 NULL
100239 +tx_tx_start_int_templates_read_58324 tx_tx_start_int_templates_read 3 58324 NULL
100240 +pcim_iomap_58334 pcim_iomap 3 58334 NULL
100241 +diva_init_dma_map_58336 diva_init_dma_map 3 58336 NULL
100242 +next_pidmap_58347 next_pidmap 2 58347 NULL
100243 +vmalloc_to_sg_58354 vmalloc_to_sg 2 58354 NULL
100244 +save_hint_58359 save_hint 2 58359 NULL
100245 +brcmf_debugfs_sdio_counter_read_58369 brcmf_debugfs_sdio_counter_read 3 58369 NULL
100246 +il_dbgfs_status_read_58388 il_dbgfs_status_read 3 58388 NULL
100247 +kvm_mmu_write_protect_pt_masked_58406 kvm_mmu_write_protect_pt_masked 3 58406 NULL
100248 +i2400m_pld_size_58415 i2400m_pld_size 0 58415 NULL
100249 +__mlx4_alloc_mtt_range_58418 __mlx4_alloc_mtt_range 2 58418 NULL
100250 +__iio_add_chan_devattr_58451 __iio_add_chan_devattr 0 58451 NULL
100251 +capabilities_read_58457 capabilities_read 3 58457 NULL
100252 +batadv_iv_ogm_aggr_packet_58462 batadv_iv_ogm_aggr_packet 3 58462 NULL
100253 +lpfc_idiag_baracc_read_58466 lpfc_idiag_baracc_read 3 58466 NULL nohasharray
100254 +compat_do_ipt_set_ctl_58466 compat_do_ipt_set_ctl 4 58466 &lpfc_idiag_baracc_read_58466
100255 +snd_gf1_read_addr_58483 snd_gf1_read_addr 0 58483 NULL
100256 +snd_rme96_capture_copy_58484 snd_rme96_capture_copy 5 58484 NULL
100257 +batadv_bla_is_backbone_gw_58488 batadv_bla_is_backbone_gw 3 58488 NULL
100258 +memblock_alloc_try_nid_58493 memblock_alloc_try_nid 1-2 58493 NULL
100259 +rndis_add_response_58544 rndis_add_response 2 58544 NULL
100260 +__clear_discard_58546 __clear_discard 2 58546 NULL
100261 +wep_decrypt_fail_read_58567 wep_decrypt_fail_read 3 58567 NULL
100262 +sip_sprintf_addr_port_58574 sip_sprintf_addr_port 0 58574 NULL
100263 +scnprint_mac_oui_58578 scnprint_mac_oui 3-0 58578 NULL
100264 +ea_read_inline_58589 ea_read_inline 0 58589 NULL
100265 +xip_file_read_58592 xip_file_read 3 58592 NULL
100266 +gdth_search_isa_58595 gdth_search_isa 1 58595 NULL
100267 +ebt_buf_count_58607 ebt_buf_count 0 58607 NULL
100268 +skb_copy_to_page_nocache_58624 skb_copy_to_page_nocache 6 58624 NULL
100269 +module_alloc_update_bounds_rx_58634 module_alloc_update_bounds_rx 1 58634 NULL nohasharray
100270 +efi_ioremap_58634 efi_ioremap 1-2 58634 &module_alloc_update_bounds_rx_58634
100271 +tx_tx_start_fw_gen_read_58648 tx_tx_start_fw_gen_read 3 58648 NULL
100272 +ocfs2_block_to_cluster_start_58653 ocfs2_block_to_cluster_start 2 58653 NULL
100273 +__gfn_to_pfn_58671 __gfn_to_pfn 2 58671 NULL
100274 +iwl_trans_send_cmd_58681 iwl_trans_send_cmd 0 58681 NULL
100275 +find_zero_58685 find_zero 0-1 58685 NULL nohasharray
100276 +mcs7830_set_reg_async_58685 mcs7830_set_reg_async 3 58685 &find_zero_58685
100277 +uwb_bce_print_IEs_58686 uwb_bce_print_IEs 4 58686 NULL
100278 +pci_alloc_consistent_58688 pci_alloc_consistent 0 58688 NULL
100279 +tps6586x_writes_58689 tps6586x_writes 3-2 58689 NULL
100280 +vmalloc_node_58700 vmalloc_node 1 58700 NULL
100281 +acpi_map_58725 acpi_map 1-2 58725 NULL
100282 +da9052_gpio_to_irq_58729 da9052_gpio_to_irq 2 58729 NULL
100283 +csum_exist_in_range_58730 csum_exist_in_range 2 58730 NULL
100284 +frames_to_bytes_58741 frames_to_bytes 0-2 58741 NULL
100285 +ieee80211_if_write_tkip_mic_test_58748 ieee80211_if_write_tkip_mic_test 3 58748 NULL
100286 +agp_allocate_memory_58761 agp_allocate_memory 2 58761 NULL
100287 +oblock_to_dblock_58762 oblock_to_dblock 0-2 58762 NULL
100288 +__do_config_autodelink_58763 __do_config_autodelink 3 58763 NULL
100289 +regmap_calc_reg_len_58795 regmap_calc_reg_len 0 58795 NULL
100290 +raw_send_hdrinc_58803 raw_send_hdrinc 4 58803 NULL
100291 +isku_sysfs_read_58806 isku_sysfs_read 6 58806 NULL
100292 +ep_read_58813 ep_read 3 58813 NULL
100293 +command_write_58841 command_write 3 58841 NULL
100294 +ocfs2_truncate_log_append_58850 ocfs2_truncate_log_append 3 58850 NULL
100295 +ath6kl_wmi_send_action_cmd_58860 ath6kl_wmi_send_action_cmd 7 58860 NULL
100296 +gs_alloc_req_58883 gs_alloc_req 2 58883 NULL
100297 +cs553x_init_one_58886 cs553x_init_one 3 58886 NULL
100298 +raw_ctl_compat_ioctl_58905 raw_ctl_compat_ioctl 3 58905 NULL
100299 +print_devstats_dot11FCSErrorCount_58919 print_devstats_dot11FCSErrorCount 3 58919 NULL
100300 +tun_chr_compat_ioctl_58921 tun_chr_compat_ioctl 3 58921 NULL
100301 +pipeline_cs_rx_packet_out_read_58926 pipeline_cs_rx_packet_out_read 3 58926 NULL
100302 +st5481_isoc_flatten_58952 st5481_isoc_flatten 0 58952 NULL
100303 +ieee80211_if_fmt_dot11MeshHWMPactivePathToRootTimeout_58965 ieee80211_if_fmt_dot11MeshHWMPactivePathToRootTimeout 3 58965 NULL
100304 +idx_to_kaddr_58968 idx_to_kaddr 0 58968 NULL
100305 +crypto_aead_ivsize_58970 crypto_aead_ivsize 0 58970 NULL
100306 +remap_to_cache_dirty_58991 remap_to_cache_dirty 4-3 58991 NULL
100307 +handle_rx_packet_58993 handle_rx_packet 3 58993 NULL
100308 +edac_align_ptr_59003 edac_align_ptr 0 59003 NULL
100309 +ep_write_59008 ep_write 3 59008 NULL
100310 +i915_ring_stop_write_59010 i915_ring_stop_write 3 59010 NULL
100311 +init_pci_cap_msi_perm_59033 init_pci_cap_msi_perm 2 59033 NULL
100312 +selinux_transaction_write_59038 selinux_transaction_write 3 59038 NULL
100313 +crypto_aead_reqsize_59039 crypto_aead_reqsize 0 59039 NULL
100314 +regmap_bulk_write_59049 regmap_bulk_write 4-2 59049 NULL
100315 +vfio_device_fops_compat_ioctl_59111 vfio_device_fops_compat_ioctl 3 59111 NULL
100316 +mmc_sd_num_wr_blocks_59112 mmc_sd_num_wr_blocks 0 59112 NULL
100317 +scsi_io_completion_59122 scsi_io_completion 2 59122 NULL
100318 +nfc_llcp_send_i_frame_59130 nfc_llcp_send_i_frame 3 59130 NULL
100319 +__iio_add_event_config_attrs_59136 __iio_add_event_config_attrs 0 59136 NULL
100320 +print_devstats_dot11RTSSuccessCount_59145 print_devstats_dot11RTSSuccessCount 3 59145 NULL nohasharray
100321 +framebuffer_alloc_59145 framebuffer_alloc 1 59145 &print_devstats_dot11RTSSuccessCount_59145
100322 +radeon_compat_ioctl_59150 radeon_compat_ioctl 2 59150 NULL
100323 +pvr2_hdw_report_clients_59152 pvr2_hdw_report_clients 3 59152 NULL
100324 +setup_window_59178 setup_window 4-2-5-7 59178 NULL
100325 +ocfs2_move_extent_59187 ocfs2_move_extent 3 59187 NULL
100326 +xfs_iext_realloc_indirect_59211 xfs_iext_realloc_indirect 2 59211 NULL
100327 +fast_rx_path_59214 fast_rx_path 3 59214 NULL
100328 +inftl_partscan_59216 inftl_partscan 0 59216 NULL
100329 +skb_transport_header_59223 skb_transport_header 0 59223 NULL
100330 +dt3155_read_59226 dt3155_read 3 59226 NULL
100331 +paging64_gpte_to_gfn_lvl_59229 paging64_gpte_to_gfn_lvl 0-1-2 59229 NULL
100332 +tty_prepare_flip_string_flags_59240 tty_prepare_flip_string_flags 4 59240 NULL
100333 +solo_v4l2_read_59247 solo_v4l2_read 3 59247 NULL
100334 +nla_len_59258 nla_len 0 59258 NULL
100335 +btrfs_insert_dir_item_59304 btrfs_insert_dir_item 4 59304 NULL
100336 +fd_copyout_59323 fd_copyout 3 59323 NULL
100337 +read_9287_modal_eeprom_59327 read_9287_modal_eeprom 3 59327 NULL
100338 +rx_defrag_in_process_called_read_59338 rx_defrag_in_process_called_read 3 59338 NULL
100339 +paging64_get_level1_sp_gpa_59346 paging64_get_level1_sp_gpa 0 59346 NULL nohasharray
100340 +xfs_attrmulti_attr_set_59346 xfs_attrmulti_attr_set 4 59346 &paging64_get_level1_sp_gpa_59346
100341 +xfs_dir2_sf_entsize_59366 xfs_dir2_sf_entsize 0-2 59366 NULL
100342 +pvr2_debugifc_print_info_59380 pvr2_debugifc_print_info 3 59380 NULL
100343 +fc_frame_alloc_fill_59394 fc_frame_alloc_fill 2 59394 NULL
100344 +vxge_hw_ring_rxds_per_block_get_59425 vxge_hw_ring_rxds_per_block_get 0 59425 NULL
100345 +squashfs_read_data_59440 squashfs_read_data 6 59440 NULL
100346 +fs_path_ensure_buf_59445 fs_path_ensure_buf 2 59445 NULL
100347 +descriptor_loc_59446 descriptor_loc 3 59446 NULL
100348 +do_compat_semctl_59449 do_compat_semctl 4 59449 NULL
100349 +virtqueue_add_buf_59470 virtqueue_add_buf 3-4 59470 NULL
100350 +ib_copy_from_udata_59502 ib_copy_from_udata 3 59502 NULL
100351 +nfsd_nrpools_59503 nfsd_nrpools 0 59503 NULL
100352 +rds_pin_pages_59507 rds_pin_pages 0-1-2 59507 NULL
100353 +mpi_get_nbits_59551 mpi_get_nbits 0 59551 NULL
100354 +tunables_write_59563 tunables_write 3 59563 NULL
100355 +memdup_user_59590 memdup_user 2 59590 NULL
100356 +tps6586x_irq_get_virq_59601 tps6586x_irq_get_virq 2 59601 NULL
100357 +mem_fwlog_free_mem_blks_read_59616 mem_fwlog_free_mem_blks_read 3 59616 NULL
100358 +mtrr_write_59622 mtrr_write 3 59622 NULL
100359 +find_first_zero_bit_59636 find_first_zero_bit 0-2 59636 NULL
100360 +ubifs_setxattr_59650 ubifs_setxattr 4 59650 NULL nohasharray
100361 +hidraw_read_59650 hidraw_read 3 59650 &ubifs_setxattr_59650
100362 +v9fs_xattr_set_acl_59651 v9fs_xattr_set_acl 4 59651 NULL
100363 +__devcgroup_check_permission_59665 __devcgroup_check_permission 0 59665 NULL
100364 +alloc_dca_provider_59670 alloc_dca_provider 2 59670 NULL
100365 +can_nocow_odirect_59681 can_nocow_odirect 3 59681 NULL
100366 +sriov_enable_59689 sriov_enable 2 59689 NULL
100367 +mic_calc_failure_read_59700 mic_calc_failure_read 3 59700 NULL
100368 +prism2_info_scanresults_59729 prism2_info_scanresults 3 59729 NULL
100369 +ieee80211_if_read_fwded_unicast_59740 ieee80211_if_read_fwded_unicast 3 59740 NULL
100370 +qib_decode_7220_sdma_errs_59745 qib_decode_7220_sdma_errs 4 59745 NULL
100371 +strnlen_59746 strnlen 0 59746 NULL
100372 +sctp_manip_pkt_59749 sctp_manip_pkt 4 59749 NULL
100373 +ext3_acl_count_59754 ext3_acl_count 0-1 59754 NULL
100374 +long_retry_limit_read_59766 long_retry_limit_read 3 59766 NULL
100375 +venus_remove_59781 venus_remove 4 59781 NULL
100376 +ipw_write_59807 ipw_write 3 59807 NULL
100377 +rtllib_wx_set_gen_ie_59808 rtllib_wx_set_gen_ie 3 59808 NULL
100378 +scsi_init_shared_tag_map_59812 scsi_init_shared_tag_map 2 59812 NULL
100379 +ieee80211_if_read_dot11MeshHWMPmaxPREQretries_59829 ieee80211_if_read_dot11MeshHWMPmaxPREQretries 3 59829 NULL
100380 +gspca_dev_probe2_59833 gspca_dev_probe2 4 59833 NULL
100381 +regmap_raw_write_async_59849 regmap_raw_write_async 2-4 59849 NULL
100382 +pvr2_ioread_set_sync_key_59882 pvr2_ioread_set_sync_key 3 59882 NULL
100383 +shmem_zero_setup_59885 shmem_zero_setup 0 59885 NULL
100384 +ffs_prepare_buffer_59892 ffs_prepare_buffer 2 59892 NULL
100385 +swiotlb_map_page_59909 swiotlb_map_page 3 59909 NULL
100386 +il_dbgfs_rxon_flags_read_59950 il_dbgfs_rxon_flags_read 3 59950 NULL nohasharray
100387 +dapm_widget_power_read_file_59950 dapm_widget_power_read_file 3 59950 &il_dbgfs_rxon_flags_read_59950
100388 +lookup_node_59953 lookup_node 2 59953 NULL
100389 +il_dbgfs_missed_beacon_read_59956 il_dbgfs_missed_beacon_read 3 59956 NULL nohasharray
100390 +compat_ipmi_ioctl_59956 compat_ipmi_ioctl 3 59956 &il_dbgfs_missed_beacon_read_59956
100391 +kvm_set_cr3_59965 kvm_set_cr3 2 59965 NULL
100392 +fb_getput_cmap_59971 fb_getput_cmap 3 59971 NULL
100393 +__arch_hweight16_59975 __arch_hweight16 0 59975 NULL
100394 +osd_req_read_kern_59990 osd_req_read_kern 5 59990 NULL
100395 +ghash_async_setkey_60001 ghash_async_setkey 3 60001 NULL
100396 +ieee80211_if_fmt_dot11MeshAwakeWindowDuration_60006 ieee80211_if_fmt_dot11MeshAwakeWindowDuration 3 60006 NULL
100397 +rawsock_sendmsg_60010 rawsock_sendmsg 4 60010 NULL
100398 +mthca_init_cq_60011 mthca_init_cq 2 60011 NULL
100399 +register_device_60015 register_device 2-3 60015 NULL
100400 +osd_req_list_dev_partitions_60027 osd_req_list_dev_partitions 4 60027 NULL
100401 +xlog_bread_offset_60030 xlog_bread_offset 3 60030 NULL
100402 +sys_sched_getaffinity_60033 sys_sched_getaffinity 2 60033 NULL
100403 +bio_integrity_hw_sectors_60039 bio_integrity_hw_sectors 0-2 60039 NULL
100404 +do_ip6t_set_ctl_60040 do_ip6t_set_ctl 4 60040 NULL
100405 +pin_2_irq_60050 pin_2_irq 0-3 60050 NULL nohasharray
100406 +vcs_size_60050 vcs_size 0 60050 &pin_2_irq_60050
100407 +gru_alloc_gts_60056 gru_alloc_gts 3-2 60056 NULL
100408 +compat_writev_60063 compat_writev 3 60063 NULL
100409 +ieee80211_build_probe_req_60064 ieee80211_build_probe_req 6-8 60064 NULL
100410 +c4iw_num_stags_60073 c4iw_num_stags 0 60073 NULL
100411 +mp_register_gsi_60079 mp_register_gsi 2 60079 NULL
100412 +rxrpc_kernel_send_data_60083 rxrpc_kernel_send_data 3 60083 NULL
100413 +ieee80211_if_fmt_fwded_frames_60103 ieee80211_if_fmt_fwded_frames 3 60103 NULL
100414 +ttm_bo_kmap_60118 ttm_bo_kmap 3-2 60118 NULL
100415 +jmb38x_ms_count_slots_60164 jmb38x_ms_count_slots 0 60164 NULL
100416 +init_state_60165 init_state 2 60165 NULL
100417 +sg_build_sgat_60179 sg_build_sgat 3 60179 NULL nohasharray
100418 +jffs2_alloc_full_dirent_60179 jffs2_alloc_full_dirent 1 60179 &sg_build_sgat_60179
100419 +rx_rx_tkip_replays_read_60193 rx_rx_tkip_replays_read 3 60193 NULL
100420 +svc_compat_ioctl_60194 svc_compat_ioctl 3 60194 NULL
100421 +ib_send_cm_mra_60202 ib_send_cm_mra 4 60202 NULL nohasharray
100422 +qib_reg_phys_mr_60202 qib_reg_phys_mr 3 60202 &ib_send_cm_mra_60202
100423 +set_tap_pfs_60203 set_tap_pfs 3 60203 NULL
100424 +ieee80211_mgmt_tx_60209 ieee80211_mgmt_tx 7 60209 NULL
100425 +btrfs_get_token_16_60220 btrfs_get_token_16 0 60220 NULL
100426 +arizona_map_irq_60230 arizona_map_irq 2 60230 NULL nohasharray
100427 +__phys_addr_nodebug_60230 __phys_addr_nodebug 0-1 60230 &arizona_map_irq_60230
100428 +wm831x_irq_60254 wm831x_irq 2 60254 NULL
100429 +compat_sys_fcntl64_60256 compat_sys_fcntl64 3 60256 NULL
100430 +printer_write_60276 printer_write 3 60276 NULL
100431 +__pskb_pull_tail_60287 __pskb_pull_tail 2 60287 NULL
100432 +do_xip_mapping_read_60297 do_xip_mapping_read 5 60297 NULL
100433 +getDataLength_60301 getDataLength 0 60301 NULL
100434 +ceph_parse_server_name_60318 ceph_parse_server_name 2 60318 NULL
100435 +__kfifo_from_user_r_60345 __kfifo_from_user_r 3-5 60345 NULL
100436 +dccp_setsockopt_60367 dccp_setsockopt 5 60367 NULL
100437 +ubi_eba_atomic_leb_change_60379 ubi_eba_atomic_leb_change 5 60379 NULL
100438 +instruction_pointer_60384 instruction_pointer 0 60384 NULL
100439 +mthca_alloc_resize_buf_60394 mthca_alloc_resize_buf 3 60394 NULL
100440 +ocfs2_zero_extend_60396 ocfs2_zero_extend 3 60396 NULL
100441 +driver_names_read_60399 driver_names_read 3 60399 NULL
100442 +paging32_walk_addr_generic_60415 paging32_walk_addr_generic 4 60415 NULL
100443 +simple_alloc_urb_60420 simple_alloc_urb 3 60420 NULL
100444 +excessive_retries_read_60425 excessive_retries_read 3 60425 NULL
100445 +tstats_write_60432 tstats_write 3 60432 NULL nohasharray
100446 +kmalloc_60432 kmalloc 1 60432 &tstats_write_60432
100447 +tipc_buf_acquire_60437 tipc_buf_acquire 1 60437 NULL
100448 +rx_data_60442 rx_data 4 60442 NULL
100449 +tcf_csum_ipv4_igmp_60446 tcf_csum_ipv4_igmp 3 60446 NULL
100450 +snd_hda_get_num_raw_conns_60462 snd_hda_get_num_raw_conns 0 60462 NULL
100451 +crypto_shash_setkey_60483 crypto_shash_setkey 3 60483 NULL
100452 +ath_tx_init_60515 ath_tx_init 2 60515 NULL
100453 +hysdn_sched_rx_60533 hysdn_sched_rx 3 60533 NULL
100454 +v9fs_fid_readn_60544 v9fs_fid_readn 4 60544 NULL
100455 +nonpaging_map_60551 nonpaging_map 4 60551 NULL
100456 +skb_transport_offset_60619 skb_transport_offset 0 60619 NULL
100457 +wl1273_fm_fops_write_60621 wl1273_fm_fops_write 3 60621 NULL
100458 +acl_alloc_stack_init_60630 acl_alloc_stack_init 1 60630 NULL
100459 +ubifs_recover_leb_60639 ubifs_recover_leb 3 60639 NULL
100460 +fb_get_fscreeninfo_60640 fb_get_fscreeninfo 3 60640 NULL
100461 +if_sdio_host_to_card_60666 if_sdio_host_to_card 4 60666 NULL
100462 +ieee80211_if_read_dot11MeshConfirmTimeout_60670 ieee80211_if_read_dot11MeshConfirmTimeout 3 60670 NULL
100463 +read_vbt_r10_60679 read_vbt_r10 1 60679 NULL
100464 +init_data_container_60709 init_data_container 1 60709 NULL
100465 +snd_ice1712_ds_read_60754 snd_ice1712_ds_read 0 60754 NULL
100466 +raid_status_60755 raid_status 5 60755 NULL
100467 +sel_write_checkreqprot_60774 sel_write_checkreqprot 3 60774 NULL
100468 +opticon_write_60775 opticon_write 4 60775 NULL
100469 +acl_alloc_num_60778 acl_alloc_num 1-2 60778 NULL
100470 +snd_pcm_oss_readv3_60792 snd_pcm_oss_readv3 3 60792 NULL
100471 +pwr_tx_with_ps_read_60851 pwr_tx_with_ps_read 3 60851 NULL
100472 +alloc_buf_60864 alloc_buf 3-2 60864 NULL
100473 +generic_writepages_60871 generic_writepages 0 60871 NULL
100474 +ext4_update_inline_data_60888 ext4_update_inline_data 3 60888 NULL
100475 +iio_debugfs_read_reg_60908 iio_debugfs_read_reg 3 60908 NULL
100476 +mgt_set_varlen_60916 mgt_set_varlen 4 60916 NULL
100477 +scrub_chunk_60926 scrub_chunk 5 60926 NULL
100478 +sys_mlock_60932 sys_mlock 1 60932 NULL
100479 +pti_char_write_60960 pti_char_write 3 60960 NULL
100480 +mwifiex_alloc_sdio_mpa_buffers_60961 mwifiex_alloc_sdio_mpa_buffers 2-3 60961 NULL
100481 +__a2mp_build_60987 __a2mp_build 3 60987 NULL
100482 +hsc_msg_alloc_60990 hsc_msg_alloc 1 60990 NULL
100483 +ath6kl_lrssi_roam_read_61022 ath6kl_lrssi_roam_read 3 61022 NULL
100484 +symtab_init_61050 symtab_init 2 61050 NULL
100485 +fuse_send_write_61053 fuse_send_write 0 61053 NULL
100486 +bitmap_scnlistprintf_61062 bitmap_scnlistprintf 0-4-2 61062 NULL
100487 +ahash_align_buffer_size_61070 ahash_align_buffer_size 0-1-2 61070 NULL
100488 +get_derived_key_61100 get_derived_key 4 61100 NULL
100489 +alloc_chrdev_region_61112 alloc_chrdev_region 0 61112 NULL
100490 +p80211_headerlen_61119 p80211_headerlen 0 61119 NULL nohasharray
100491 +__probe_kernel_read_61119 __probe_kernel_read 3 61119 &p80211_headerlen_61119
100492 +vmemmap_alloc_block_buf_61126 vmemmap_alloc_block_buf 1 61126 NULL
100493 +afs_proc_cells_write_61139 afs_proc_cells_write 3 61139 NULL
100494 +__vmalloc_61168 __vmalloc 1 61168 NULL
100495 +event_oom_late_read_61175 event_oom_late_read 3 61175 NULL nohasharray
100496 +pair_device_61175 pair_device 4 61175 &event_oom_late_read_61175
100497 +sys_lsetxattr_61177 sys_lsetxattr 4 61177 NULL
100498 +arch_hibernation_header_save_61212 arch_hibernation_header_save 0 61212 NULL
100499 +smk_read_ambient_61220 smk_read_ambient 3 61220 NULL
100500 +btrfs_bio_alloc_61270 btrfs_bio_alloc 3 61270 NULL
100501 +vortex_adbdma_getlinearpos_61283 vortex_adbdma_getlinearpos 0 61283 NULL
100502 +sys_add_key_61288 sys_add_key 4 61288 NULL
100503 +ext4_issue_discard_61305 ext4_issue_discard 2 61305 NULL
100504 +xfrm_user_sec_ctx_size_61320 xfrm_user_sec_ctx_size 0 61320 NULL
100505 +st5481_setup_isocpipes_61340 st5481_setup_isocpipes 6-4 61340 NULL
100506 +rx_rx_wa_ba_not_expected_read_61341 rx_rx_wa_ba_not_expected_read 3 61341 NULL
100507 +f1x_map_sysaddr_to_csrow_61344 f1x_map_sysaddr_to_csrow 2 61344 NULL
100508 +debug_debug4_read_61367 debug_debug4_read 3 61367 NULL
100509 +sys_ptrace_61369 sys_ptrace 3 61369 NULL
100510 +change_xattr_61390 change_xattr 5 61390 NULL
100511 +size_entry_mwt_61400 size_entry_mwt 0 61400 NULL
100512 +dma_ops_area_alloc_61440 dma_ops_area_alloc 3-4-5 61440 NULL
100513 +tc3589x_irq_unmap_61447 tc3589x_irq_unmap 2 61447 NULL
100514 +unix_stream_sendmsg_61455 unix_stream_sendmsg 4 61455 NULL
100515 +snd_pcm_lib_writev_transfer_61483 snd_pcm_lib_writev_transfer 4-2-5 61483 NULL
100516 +btrfs_item_size_61485 btrfs_item_size 0 61485 NULL
100517 +erst_errno_61526 erst_errno 0 61526 NULL
100518 +ntfs_attr_lookup_61539 ntfs_attr_lookup 0 61539 NULL
100519 +o2hb_pop_count_61553 o2hb_pop_count 2 61553 NULL
100520 +dvb_net_ioctl_61559 dvb_net_ioctl 2 61559 NULL
100521 +ieee80211_if_read_rc_rateidx_mask_2ghz_61570 ieee80211_if_read_rc_rateidx_mask_2ghz 3 61570 NULL
100522 +seq_open_private_61589 seq_open_private 3 61589 NULL
100523 +__get_vm_area_61599 __get_vm_area 1 61599 NULL
100524 +nfs4_init_uniform_client_string_61601 nfs4_init_uniform_client_string 3 61601 NULL
100525 +ncp_compat_ioctl_61608 ncp_compat_ioctl 3 61608 NULL
100526 +configfs_write_file_61621 configfs_write_file 3 61621 NULL
100527 +ieee80211_if_fmt_hw_queues_61629 ieee80211_if_fmt_hw_queues 3 61629 NULL
100528 +i2o_parm_table_get_61635 i2o_parm_table_get 6 61635 NULL
100529 +snd_pcm_oss_read3_61643 snd_pcm_oss_read3 0-3 61643 NULL
100530 +resize_stripes_61650 resize_stripes 2 61650 NULL
100531 +ttm_page_pool_free_61661 ttm_page_pool_free 2 61661 NULL
100532 +insert_one_name_61668 insert_one_name 7 61668 NULL
100533 +lock_loop_61681 lock_loop 1 61681 NULL
100534 +filter_read_61692 filter_read 3 61692 NULL
100535 +iov_length_61716 iov_length 0 61716 NULL
100536 +fragmentation_threshold_read_61718 fragmentation_threshold_read 3 61718 NULL
100537 +read_file_interrupt_61742 read_file_interrupt 3 61742 NULL nohasharray
100538 +read_file_regval_61742 read_file_regval 3 61742 &read_file_interrupt_61742
100539 +batadv_dat_snoop_incoming_arp_reply_61801 batadv_dat_snoop_incoming_arp_reply 3 61801 NULL
100540 +tps80031_irq_init_61830 tps80031_irq_init 3 61830 NULL
100541 +bfad_debugfs_write_regwr_61841 bfad_debugfs_write_regwr 3 61841 NULL
100542 +fs_path_prepare_for_add_61854 fs_path_prepare_for_add 2 61854 NULL
100543 +evdev_compute_buffer_size_61863 evdev_compute_buffer_size 0 61863 NULL
100544 +get_fw_name_61874 get_fw_name 3 61874 NULL
100545 +free_init_pages_61875 free_init_pages 2 61875 NULL
100546 +twl4030_sih_setup_61878 twl4030_sih_setup 3 61878 NULL
100547 +ieee80211_rtl_auth_challenge_61897 ieee80211_rtl_auth_challenge 3 61897 NULL
100548 +ax25_addr_size_61899 ax25_addr_size 0 61899 NULL nohasharray
100549 +cxgb4_pktgl_to_skb_61899 cxgb4_pktgl_to_skb 2 61899 &ax25_addr_size_61899
100550 +clear_refs_write_61904 clear_refs_write 3 61904 NULL
100551 +rx_filter_arp_filter_read_61914 rx_filter_arp_filter_read 3 61914 NULL
100552 +au0828_init_isoc_61917 au0828_init_isoc 3-2 61917 NULL
100553 +sctp_sendmsg_61919 sctp_sendmsg 4 61919 NULL
100554 +send_bulk_static_data_61932 send_bulk_static_data 3 61932 NULL
100555 +gfn_to_pfn_memslot_atomic_61947 gfn_to_pfn_memslot_atomic 2 61947 NULL
100556 +il4965_ucode_rx_stats_read_61948 il4965_ucode_rx_stats_read 3 61948 NULL
100557 +squashfs_read_id_index_table_61961 squashfs_read_id_index_table 4 61961 NULL
100558 +mlx4_alloc_mtt_range_61966 mlx4_alloc_mtt_range 2 61966 NULL
100559 +ocfs2_quota_write_61972 ocfs2_quota_write 5-4 61972 NULL
100560 +cow_file_range_61979 cow_file_range 3 61979 NULL
100561 +module_alloc_exec_61991 module_alloc_exec 1 61991 NULL
100562 +virtnet_send_command_61993 virtnet_send_command 5-6 61993 NULL
100563 +xt_compat_match_offset_62011 xt_compat_match_offset 0 62011 NULL
100564 +jffs2_do_unlink_62020 jffs2_do_unlink 4 62020 NULL
100565 +pmcraid_build_passthrough_ioadls_62034 pmcraid_build_passthrough_ioadls 2 62034 NULL
100566 +ppp_tx_cp_62044 ppp_tx_cp 5 62044 NULL
100567 +sctp_user_addto_chunk_62047 sctp_user_addto_chunk 2-3 62047 NULL
100568 +do_pselect_62061 do_pselect 1 62061 NULL
100569 +pcpu_alloc_bootmem_62074 pcpu_alloc_bootmem 2-3 62074 NULL
100570 +get_domain_for_dev_62099 get_domain_for_dev 2 62099 NULL
100571 +ipath_user_sdma_pin_pages_62100 ipath_user_sdma_pin_pages 3-5 62100 NULL
100572 +jffs2_security_setxattr_62107 jffs2_security_setxattr 4 62107 NULL
100573 +llc_ui_header_len_62131 llc_ui_header_len 0 62131 NULL
100574 +qib_diag_write_62133 qib_diag_write 3 62133 NULL
100575 +ql_status_62135 ql_status 5 62135 NULL
100576 +video_usercopy_62151 video_usercopy 2 62151 NULL
100577 +prism54_wpa_bss_ie_get_62173 prism54_wpa_bss_ie_get 0 62173 NULL
100578 +alloc_upcall_62186 alloc_upcall 2 62186 NULL
100579 +btrfs_xattr_acl_set_62203 btrfs_xattr_acl_set 4 62203 NULL
100580 +sock_kmalloc_62205 sock_kmalloc 2 62205 NULL
100581 +nfsd_read_file_62241 nfsd_read_file 6 62241 NULL
100582 +allocate_partition_62245 allocate_partition 4 62245 NULL
100583 +__qib_get_user_pages_62287 __qib_get_user_pages 1-2 62287 NULL
100584 +il_dbgfs_sram_read_62296 il_dbgfs_sram_read 3 62296 NULL
100585 +sparse_early_usemaps_alloc_pgdat_section_62304 sparse_early_usemaps_alloc_pgdat_section 2 62304 NULL
100586 +subsystem_filter_read_62310 subsystem_filter_read 3 62310 NULL
100587 +udf_sb_alloc_partition_maps_62313 udf_sb_alloc_partition_maps 2 62313 NULL
100588 +Wb35Reg_BurstWrite_62327 Wb35Reg_BurstWrite 4 62327 NULL
100589 +subseq_list_62332 subseq_list 3-0 62332 NULL
100590 +flash_write_62354 flash_write 3 62354 NULL
100591 +set_wd_exp_mode_pfs_62372 set_wd_exp_mode_pfs 3 62372 NULL
100592 +twl_get_num_slaves_62386 twl_get_num_slaves 0 62386 NULL
100593 +rx_rx_timeout_read_62389 rx_rx_timeout_read 3 62389 NULL
100594 +altera_irscan_62396 altera_irscan 2 62396 NULL
100595 +set_ssp_62411 set_ssp 4 62411 NULL
100596 +unmap_single_62423 unmap_single 2 62423 NULL
100597 +netdev_alloc_skb_62437 netdev_alloc_skb 2 62437 NULL
100598 +e1000_check_copybreak_62448 e1000_check_copybreak 3 62448 NULL
100599 +ip_vs_icmp_xmit_v6_62477 ip_vs_icmp_xmit_v6 4 62477 NULL
100600 +ceph_dns_resolve_name_62488 ceph_dns_resolve_name 2 62488 NULL
100601 +remove_mapping_62491 remove_mapping 2 62491 NULL
100602 +mlx4_en_create_rx_ring_62498 mlx4_en_create_rx_ring 3 62498 NULL
100603 +ext_rts51x_sd_execute_read_data_62501 ext_rts51x_sd_execute_read_data 9 62501 NULL
100604 +pep_sendmsg_62524 pep_sendmsg 4 62524 NULL nohasharray
100605 +i915_next_seqno_read_62524 i915_next_seqno_read 3 62524 &pep_sendmsg_62524
100606 +test_iso_queue_62534 test_iso_queue 5 62534 NULL
100607 +debugfs_read_62535 debugfs_read 3 62535 NULL
100608 +sco_sock_sendmsg_62542 sco_sock_sendmsg 4 62542 NULL
100609 +qib_refresh_qsfp_cache_62547 qib_refresh_qsfp_cache 0 62547 NULL
100610 +xfrm_user_policy_62573 xfrm_user_policy 4 62573 NULL
100611 +get_subdir_62581 get_subdir 3 62581 NULL
100612 +prism2_send_mgmt_62605 prism2_send_mgmt 4 62605 NULL nohasharray
100613 +nfsd_vfs_read_62605 nfsd_vfs_read 6 62605 &prism2_send_mgmt_62605
100614 +iommu_area_alloc_62619 iommu_area_alloc 2-3-4-7 62619 NULL
100615 +ems_pcmcia_add_card_62627 ems_pcmcia_add_card 2 62627 NULL
100616 +compat_rangeinfo_62630 compat_rangeinfo 2 62630 NULL
100617 +lpfc_sli4_queue_alloc_62646 lpfc_sli4_queue_alloc 3 62646 NULL
100618 +memblock_alloc_nid_62652 memblock_alloc_nid 1-2 62652 NULL
100619 +ima_file_mmap_62663 ima_file_mmap 0 62663 NULL
100620 +write_62671 write 3 62671 NULL
100621 +printer_req_alloc_62687 printer_req_alloc 2 62687 NULL
100622 +qla4_83xx_rd_reg_62693 qla4_83xx_rd_reg 0 62693 NULL
100623 +ioremap_wc_62695 ioremap_wc 1-2 62695 NULL
100624 +bioset_integrity_create_62708 bioset_integrity_create 2 62708 NULL
100625 +rdm_62719 rdm 0 62719 NULL
100626 +key_replays_read_62746 key_replays_read 3 62746 NULL
100627 +init_chip_wc_pat_62768 init_chip_wc_pat 2 62768 NULL
100628 +ax25_sendmsg_62770 ax25_sendmsg 4 62770 NULL
100629 +page_key_alloc_62771 page_key_alloc 0 62771 NULL
100630 +tracing_total_entries_read_62817 tracing_total_entries_read 3 62817 NULL
100631 +__rounddown_pow_of_two_62836 __rounddown_pow_of_two 0 62836 NULL
100632 +bio_get_nr_vecs_62838 bio_get_nr_vecs 0 62838 NULL
100633 +xlog_recover_add_to_trans_62839 xlog_recover_add_to_trans 4 62839 NULL
100634 +rx_fcs_err_read_62844 rx_fcs_err_read 3 62844 NULL
100635 +set_swbp_62853 set_swbp 3 62853 NULL
100636 +hpi_read_word_62862 hpi_read_word 0 62862 NULL
100637 +aoechr_write_62883 aoechr_write 3 62883 NULL
100638 +resize_info_buffer_62889 resize_info_buffer 2 62889 NULL
100639 +if_spi_host_to_card_62890 if_spi_host_to_card 4 62890 NULL
100640 +mempool_create_slab_pool_62907 mempool_create_slab_pool 1 62907 NULL
100641 +getdqbuf_62908 getdqbuf 1 62908 NULL
100642 +try_async_pf_62914 try_async_pf 3 62914 NULL
100643 +agp_create_user_memory_62955 agp_create_user_memory 1 62955 NULL
100644 +__vb2_perform_fileio_63033 __vb2_perform_fileio 3 63033 NULL
100645 +pipeline_defrag_to_csum_swi_read_63037 pipeline_defrag_to_csum_swi_read 3 63037 NULL
100646 +scsi_host_alloc_63041 scsi_host_alloc 2 63041 NULL
100647 +unlink1_63059 unlink1 3 63059 NULL
100648 +xen_set_nslabs_63066 xen_set_nslabs 0 63066 NULL
100649 +ocfs2_decrease_refcount_63078 ocfs2_decrease_refcount 3 63078 NULL
100650 +sep_prepare_input_output_dma_table_in_dcb_63087 sep_prepare_input_output_dma_table_in_dcb 4-5-2-3 63087 NULL
100651 +iwl_dbgfs_sensitivity_read_63116 iwl_dbgfs_sensitivity_read 3 63116 NULL
100652 +alloc_cblock_63133 alloc_cblock 2 63133 NULL
100653 +ib_send_cm_rtu_63138 ib_send_cm_rtu 3 63138 NULL
100654 +xen_zap_pfn_range_63149 xen_zap_pfn_range 1 63149 NULL
100655 +smk_write_revoke_subj_63173 smk_write_revoke_subj 3 63173 NULL
100656 +vme_master_read_63221 vme_master_read 0 63221 NULL
100657 +module_alloc_update_bounds_rw_63233 module_alloc_update_bounds_rw 1 63233 NULL
100658 +ptp_read_63251 ptp_read 4 63251 NULL
100659 +raid5_resize_63306 raid5_resize 2 63306 NULL
100660 +proc_info_read_63344 proc_info_read 3 63344 NULL
100661 +ps_upsd_max_sptime_read_63362 ps_upsd_max_sptime_read 3 63362 NULL
100662 +idmouse_read_63374 idmouse_read 3 63374 NULL
100663 +edac_pci_alloc_ctl_info_63388 edac_pci_alloc_ctl_info 1 63388 NULL nohasharray
100664 +usbnet_read_cmd_nopm_63388 usbnet_read_cmd_nopm 7 63388 &edac_pci_alloc_ctl_info_63388
100665 +rxpipe_missed_beacon_host_int_trig_rx_data_read_63405 rxpipe_missed_beacon_host_int_trig_rx_data_read 3 63405 NULL
100666 +nouveau_event_create_63411 nouveau_event_create 1 63411 NULL
100667 +l2cap_sock_sendmsg_63427 l2cap_sock_sendmsg 4 63427 NULL
100668 +sep_prepare_input_output_dma_table_63429 sep_prepare_input_output_dma_table 2-4-3 63429 NULL
100669 +kone_send_63435 kone_send 4 63435 NULL
100670 +gfn_to_hva_many_63437 gfn_to_hva_many 0-2 63437 NULL
100671 +nfsd_symlink_63442 nfsd_symlink 6 63442 NULL
100672 +ipv6_is_mld_63461 ipv6_is_mld 3 63461 NULL
100673 +snd_info_entry_write_63474 snd_info_entry_write 3 63474 NULL
100674 +reada_find_extent_63486 reada_find_extent 2 63486 NULL
100675 +read_kcore_63488 read_kcore 3 63488 NULL
100676 +save_hint_63497 save_hint 2 63497 NULL
100677 +snd_pcm_plug_write_transfer_63503 snd_pcm_plug_write_transfer 0-3 63503 NULL
100678 +ubi_more_leb_change_data_63534 ubi_more_leb_change_data 4 63534 NULL
100679 +if_sdio_read_scratch_63540 if_sdio_read_scratch 0 63540 NULL
100680 +append_to_buffer_63550 append_to_buffer 3 63550 NULL
100681 +dbg_leb_write_63555 dbg_leb_write 4-5 63555 NULL nohasharray
100682 +kvm_write_guest_page_63555 kvm_write_guest_page 5-2 63555 &dbg_leb_write_63555
100683 +ubifs_lpt_scan_nolock_63572 ubifs_lpt_scan_nolock 0 63572 NULL
100684 +iwch_reg_user_mr_63575 iwch_reg_user_mr 2-3 63575 NULL
100685 +ocfs2_calc_trunc_pos_63576 ocfs2_calc_trunc_pos 4 63576 NULL
100686 +rproc_alloc_63577 rproc_alloc 5 63577 NULL
100687 +ext3_clear_blocks_63597 ext3_clear_blocks 4-5 63597 NULL
100688 +module_alloc_63630 module_alloc 1 63630 NULL
100689 +ntfs_malloc_nofs_nofail_63631 ntfs_malloc_nofs_nofail 1 63631 NULL
100690 +symbol_build_supp_rates_63634 symbol_build_supp_rates 0 63634 NULL
100691 +_ubh_find_next_zero_bit__63640 _ubh_find_next_zero_bit_ 4-5-3 63640 NULL
100692 +proc_loginuid_write_63648 proc_loginuid_write 3 63648 NULL
100693 +ValidateDSDParamsChecksum_63654 ValidateDSDParamsChecksum 3 63654 NULL
100694 +hidraw_ioctl_63658 hidraw_ioctl 2 63658 NULL
100695 +vbi_read_63673 vbi_read 3 63673 NULL nohasharray
100696 +xen_register_pirq_63673 xen_register_pirq 1-2 63673 &vbi_read_63673
100697 +alloc_tty_driver_63681 alloc_tty_driver 1 63681 NULL
100698 +mkiss_compat_ioctl_63686 mkiss_compat_ioctl 4 63686 NULL
100699 +arizona_irq_map_63709 arizona_irq_map 2 63709 NULL
100700 +nouveau_object_create__63715 nouveau_object_create_ 5 63715 NULL
100701 +btrfs_insert_delayed_dir_index_63720 btrfs_insert_delayed_dir_index 4 63720 NULL
100702 +selinux_secctx_to_secid_63744 selinux_secctx_to_secid 2 63744 NULL
100703 +snd_pcm_oss_read1_63771 snd_pcm_oss_read1 3 63771 NULL
100704 +snd_opl4_mem_proc_read_63774 snd_opl4_mem_proc_read 5 63774 NULL
100705 +spidev_compat_ioctl_63778 spidev_compat_ioctl 2-3 63778 NULL
100706 +snapshot_compat_ioctl_63792 snapshot_compat_ioctl 3 63792 NULL
100707 +kovaplus_sysfs_write_63795 kovaplus_sysfs_write 6 63795 NULL
100708 +mwifiex_11n_create_rx_reorder_tbl_63806 mwifiex_11n_create_rx_reorder_tbl 4 63806 NULL
100709 +copy_nodes_to_user_63807 copy_nodes_to_user 2 63807 NULL
100710 +sel_write_load_63830 sel_write_load 3 63830 NULL
100711 +proc_pid_attr_write_63845 proc_pid_attr_write 3 63845 NULL
100712 +init_map_ipmac_63896 init_map_ipmac 4-3 63896 NULL
100713 +divas_write_63901 divas_write 3 63901 NULL
100714 +xhci_alloc_stream_info_63902 xhci_alloc_stream_info 3 63902 NULL
100715 +uvc_alloc_urb_buffers_63922 uvc_alloc_urb_buffers 0-3-2 63922 NULL
100716 +snd_compr_write_63923 snd_compr_write 3 63923 NULL
100717 +acpi_ev_get_gpe_xrupt_block_63924 acpi_ev_get_gpe_xrupt_block 1 63924 NULL
100718 +tipc_send2port_63935 tipc_send2port 5 63935 NULL
100719 +afs_send_simple_reply_63940 afs_send_simple_reply 3 63940 NULL
100720 +__team_options_register_63941 __team_options_register 3 63941 NULL
100721 +macvtap_recvmsg_63949 macvtap_recvmsg 4 63949 NULL
100722 +ieee80211_if_fmt_rc_rateidx_mcs_mask_2ghz_63968 ieee80211_if_fmt_rc_rateidx_mcs_mask_2ghz 3 63968 NULL
100723 +ieee80211_authentication_req_63973 ieee80211_authentication_req 3 63973 NULL
100724 +diva_xdi_write_63975 diva_xdi_write 4 63975 NULL
100725 +read_file_frameerrors_64001 read_file_frameerrors 3 64001 NULL
100726 +kmemdup_64015 kmemdup 2 64015 NULL
100727 +offset_to_vaddr_64025 offset_to_vaddr 0-2 64025 NULL nohasharray
100728 +tcf_csum_skb_nextlayer_64025 tcf_csum_skb_nextlayer 3 64025 &offset_to_vaddr_64025
100729 +dbAllocDmapLev_64030 dbAllocDmapLev 0 64030 NULL
100730 +resize_async_buffer_64031 resize_async_buffer 4 64031 NULL
100731 +sep_lli_table_secure_dma_64042 sep_lli_table_secure_dma 2-3 64042 NULL
100732 +get_u8_64076 get_u8 0 64076 NULL
100733 +sl_realloc_bufs_64086 sl_realloc_bufs 2 64086 NULL
100734 +vmci_handle_arr_get_size_64088 vmci_handle_arr_get_size 0 64088 NULL
100735 +lbs_highrssi_read_64089 lbs_highrssi_read 3 64089 NULL
100736 +do_load_xattr_datum_64118 do_load_xattr_datum 0 64118 NULL
100737 +ol_quota_entries_per_block_64122 ol_quota_entries_per_block 0 64122 NULL
100738 +ext4_prepare_inline_data_64124 ext4_prepare_inline_data 3 64124 NULL
100739 +init_bch_64130 init_bch 1-2 64130 NULL
100740 +uea_idma_write_64139 uea_idma_write 3 64139 NULL
100741 +ablkcipher_copy_iv_64140 ablkcipher_copy_iv 3 64140 NULL
100742 +dlfb_ops_write_64150 dlfb_ops_write 3 64150 NULL
100743 +__comedi_buf_alloc_64155 __comedi_buf_alloc 3 64155 NULL
100744 +cpumask_scnprintf_64170 cpumask_scnprintf 2 64170 NULL
100745 +read_pulse_64227 read_pulse 0-3 64227 NULL
100746 +header_len_64232 header_len 0 64232 NULL
100747 +redrat3_transmit_ir_64244 redrat3_transmit_ir 3 64244 NULL
100748 +io_capture_transfer_64276 io_capture_transfer 4 64276 NULL
100749 +btrfs_file_extent_offset_64278 btrfs_file_extent_offset 0 64278 NULL
100750 +sta_current_tx_rate_read_64286 sta_current_tx_rate_read 3 64286 NULL
100751 +event_id_read_64288 event_id_read 3 64288 NULL nohasharray
100752 +xfs_dir_cilookup_result_64288 xfs_dir_cilookup_result 3 64288 &event_id_read_64288
100753 +ocfs2_block_check_validate_bhs_64302 ocfs2_block_check_validate_bhs 0 64302 NULL
100754 +error_error_bar_retry_read_64305 error_error_bar_retry_read 3 64305 NULL
100755 +ffz_64324 ffz 0 64324 NULL
100756 +sisusbcon_clear_64329 sisusbcon_clear 4-3-5 64329 NULL
100757 +ts_write_64336 ts_write 3 64336 NULL
100758 +usbtmc_write_64340 usbtmc_write 3 64340 NULL
100759 +do_write_orph_node_64343 do_write_orph_node 2 64343 NULL
100760 +ft1000_read_reg_64352 ft1000_read_reg 0 64352 NULL
100761 +bnx2x_vfop_mcast_cmd_64354 bnx2x_vfop_mcast_cmd 5 64354 NULL
100762 +wlc_phy_loadsampletable_nphy_64367 wlc_phy_loadsampletable_nphy 3 64367 NULL
100763 +ilo_write_64378 ilo_write 3 64378 NULL
100764 +btrfs_map_block_64379 btrfs_map_block 3 64379 NULL
100765 +vmcs_readl_64381 vmcs_readl 0 64381 NULL
100766 +nilfs_alloc_seg_bio_64383 nilfs_alloc_seg_bio 3 64383 NULL
100767 +ir_lirc_transmit_ir_64403 ir_lirc_transmit_ir 3 64403 NULL
100768 +pidlist_allocate_64404 pidlist_allocate 1 64404 NULL
100769 +rx_hdr_overflow_read_64407 rx_hdr_overflow_read 3 64407 NULL
100770 +snd_card_create_64418 snd_card_create 4 64418 NULL nohasharray
100771 +keyctl_get_security_64418 keyctl_get_security 3 64418 &snd_card_create_64418
100772 +nl80211_send_mgmt_64419 nl80211_send_mgmt 7 64419 NULL
100773 +oom_adj_write_64428 oom_adj_write 3 64428 NULL
100774 +ext4_trim_extent_64431 ext4_trim_extent 4 64431 NULL nohasharray
100775 +read_file_spectral_short_repeat_64431 read_file_spectral_short_repeat 3 64431 &ext4_trim_extent_64431
100776 +cap_capable_64462 cap_capable 0 64462 NULL
100777 +ip_vs_create_timeout_table_64478 ip_vs_create_timeout_table 2 64478 NULL
100778 +p54_parse_rssical_64493 p54_parse_rssical 3 64493 NULL
100779 +msg_data_sz_64503 msg_data_sz 0 64503 NULL
100780 +remove_uuid_64505 remove_uuid 4 64505 NULL nohasharray
100781 +handle_abnormal_pfn_64505 handle_abnormal_pfn 3 64505 &remove_uuid_64505
100782 +crypto_blkcipher_alignmask_64520 crypto_blkcipher_alignmask 0 64520 NULL
100783 +opera1_usb_i2c_msgxfer_64521 opera1_usb_i2c_msgxfer 4 64521 NULL
100784 +ses_send_diag_64527 ses_send_diag 4 64527 NULL
100785 +prctl_set_mm_64538 prctl_set_mm 3 64538 NULL
100786 +__spi_sync_64561 __spi_sync 0 64561 NULL
100787 +__apei_exec_run_64563 __apei_exec_run 0 64563 NULL
100788 +fanotify_write_64623 fanotify_write 3 64623 NULL
100789 +to_dblock_64655 to_dblock 0-1 64655 NULL
100790 +regmap_read_debugfs_64658 regmap_read_debugfs 5 64658 NULL
100791 +ocfs2_read_xattr_block_64661 ocfs2_read_xattr_block 0 64661 NULL nohasharray
100792 +tlbflush_read_file_64661 tlbflush_read_file 3 64661 &ocfs2_read_xattr_block_64661
100793 +efx_tsoh_get_buffer_64664 efx_tsoh_get_buffer 3 64664 NULL
100794 +rx_rx_out_of_mpdu_nodes_read_64668 rx_rx_out_of_mpdu_nodes_read 3 64668 NULL
100795 +nr_free_zone_pages_64680 nr_free_zone_pages 0 64680 NULL
100796 +sec_bulk_write_64691 sec_bulk_write 2-3 64691 NULL
100797 +__feat_register_sp_64712 __feat_register_sp 6 64712 NULL
100798 +snd_pcm_oss_capture_position_fixup_64713 snd_pcm_oss_capture_position_fixup 0 64713 NULL
100799 +dapm_bias_read_file_64715 dapm_bias_read_file 3 64715 NULL
100800 +atomic_add_return_64720 atomic_add_return 0-1 64720 NULL
100801 +i2400m_msg_to_dev_64722 i2400m_msg_to_dev 3 64722 NULL
100802 +squashfs_read_inode_lookup_table_64739 squashfs_read_inode_lookup_table 4 64739 NULL
100803 +bio_map_kern_64751 bio_map_kern 3 64751 NULL
100804 +rt2x00debug_write_csr_64753 rt2x00debug_write_csr 3 64753 NULL
100805 +isr_low_rssi_read_64789 isr_low_rssi_read 3 64789 NULL
100806 +nfsctl_transaction_write_64800 nfsctl_transaction_write 3 64800 NULL
100807 +megaraid_change_queue_depth_64815 megaraid_change_queue_depth 2 64815 NULL
100808 +ecryptfs_send_miscdev_64816 ecryptfs_send_miscdev 2 64816 NULL
100809 +vaddr_get_pfn_64818 vaddr_get_pfn 1 64818 NULL
100810 +gfn_to_page_64826 gfn_to_page 2 64826 NULL
100811 +do_kimage_alloc_64827 do_kimage_alloc 3 64827 NULL
100812 +altera_set_dr_pre_64862 altera_set_dr_pre 2 64862 NULL
100813 +gfn_to_pfn_64870 gfn_to_pfn 2 64870 NULL
100814 +ffs_epfile_io_64886 ffs_epfile_io 3 64886 NULL
100815 +ieee80211_if_read_ave_beacon_64924 ieee80211_if_read_ave_beacon 3 64924 NULL
100816 +ubifs_wbuf_write_nolock_64946 ubifs_wbuf_write_nolock 3 64946 NULL
100817 +snd_rawmidi_ioctl_compat_64954 snd_rawmidi_ioctl_compat 3 64954 NULL
100818 +ip_options_get_from_user_64958 ip_options_get_from_user 4 64958 NULL
100819 +acpi_os_install_interrupt_handler_64968 acpi_os_install_interrupt_handler 1 64968 NULL
100820 +traceprobe_probes_write_64969 traceprobe_probes_write 3 64969 NULL
100821 +suspend_dtim_interval_read_64971 suspend_dtim_interval_read 3 64971 NULL
100822 +ext2_group_first_block_no_64972 ext2_group_first_block_no 0-2 64972 NULL
100823 +pskb_pull_65005 pskb_pull 2 65005 NULL
100824 +unifi_write_65012 unifi_write 3 65012 NULL
100825 +crypto_ahash_digestsize_65014 crypto_ahash_digestsize 0 65014 NULL
100826 +nfs_readdata_alloc_65015 nfs_readdata_alloc 2 65015 NULL
100827 +insert_dent_65034 insert_dent 7 65034 NULL
100828 +compat_put_ushort_65040 compat_put_ushort 1 65040 NULL
100829 +brcmf_sdcard_rwdata_65041 brcmf_sdcard_rwdata 5 65041 NULL
100830 +tty_audit_log_65043 tty_audit_log 8 65043 NULL
100831 +compat_cmdtest_65064 compat_cmdtest 2 65064 NULL
100832 +count_run_65072 count_run 0-2-4 65072 NULL nohasharray
100833 +bnx2fc_process_l2_frame_compl_65072 bnx2fc_process_l2_frame_compl 3 65072 &count_run_65072
100834 +__alloc_bootmem_node_high_65076 __alloc_bootmem_node_high 2-3 65076 NULL
100835 +ocfs2_truncate_cluster_pages_65086 ocfs2_truncate_cluster_pages 2 65086 NULL
100836 +ath9k_dump_mci_btcoex_65090 ath9k_dump_mci_btcoex 0 65090 NULL
100837 +ssb_bus_register_65183 ssb_bus_register 3 65183 NULL
100838 +rx_rx_done_read_65217 rx_rx_done_read 3 65217 NULL
100839 +print_endpoint_stat_65232 print_endpoint_stat 3-4-0 65232 NULL
100840 +whci_n_caps_65247 whci_n_caps 0 65247 NULL
100841 +kmem_zalloc_greedy_65268 kmem_zalloc_greedy 3-2 65268 NULL
100842 +kmalloc_parameter_65279 kmalloc_parameter 1 65279 NULL
100843 +compat_core_sys_select_65285 compat_core_sys_select 1 65285 NULL
100844 +mpi_set_buffer_65294 mpi_set_buffer 3 65294 NULL
100845 +redirected_tty_write_65297 redirected_tty_write 3 65297 NULL
100846 +get_var_len_65304 get_var_len 0 65304 NULL
100847 +unpack_array_65318 unpack_array 0 65318 NULL
100848 +pci_vpd_find_tag_65325 pci_vpd_find_tag 0-2 65325 NULL
100849 +dccp_setsockopt_service_65336 dccp_setsockopt_service 4 65336 NULL
100850 +dma_rx_requested_read_65354 dma_rx_requested_read 3 65354 NULL
100851 +batadv_tt_save_orig_buffer_65361 batadv_tt_save_orig_buffer 4 65361 NULL
100852 +alloc_cpu_rmap_65363 alloc_cpu_rmap 1 65363 NULL
100853 +__ext4_new_inode_65370 __ext4_new_inode 5 65370 NULL
100854 +strchr_65372 strchr 0 65372 NULL
100855 +__alloc_bootmem_nopanic_65397 __alloc_bootmem_nopanic 1-2 65397 NULL
100856 +trace_seq_to_user_65398 trace_seq_to_user 3 65398 NULL
100857 +mtd_get_device_size_65400 mtd_get_device_size 0 65400 NULL
100858 +iio_device_add_channel_sysfs_65406 iio_device_add_channel_sysfs 0 65406 NULL
100859 +ocfs2_write_begin_nolock_65410 ocfs2_write_begin_nolock 3-4 65410 NULL
100860 +drm_calloc_large_65421 drm_calloc_large 1-2 65421 NULL
100861 +xpc_kzalloc_cacheline_aligned_65433 xpc_kzalloc_cacheline_aligned 1 65433 NULL
100862 +usb_alloc_coherent_65444 usb_alloc_coherent 2 65444 NULL
100863 +ath_rx_edma_init_65483 ath_rx_edma_init 2 65483 NULL
100864 +dpcm_state_read_file_65489 dpcm_state_read_file 3 65489 NULL
100865 +alloc_dr_65495 alloc_dr 2 65495 NULL
100866 diff --git a/tools/gcc/size_overflow_plugin.c b/tools/gcc/size_overflow_plugin.c
100867 new file mode 100644
100868 index 0000000..9db0d0e
100869 --- /dev/null
100870 +++ b/tools/gcc/size_overflow_plugin.c
100871 @@ -0,0 +1,2114 @@
100872 +/*
100873 + * Copyright 2011, 2012, 2013 by Emese Revfy <re.emese@gmail.com>
100874 + * Licensed under the GPL v2, or (at your option) v3
100875 + *
100876 + * Homepage:
100877 + * http://www.grsecurity.net/~ephox/overflow_plugin/
100878 + *
100879 + * Documentation:
100880 + * http://forums.grsecurity.net/viewtopic.php?f=7&t=3043
100881 + *
100882 + * This plugin recomputes expressions of function arguments marked by a size_overflow attribute
100883 + * with double integer precision (DImode/TImode for 32/64 bit integer types).
100884 + * The recomputed argument is checked against TYPE_MAX and an event is logged on overflow and the triggering process is killed.
100885 + *
100886 + * Usage:
100887 + * $ 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
100888 + * $ gcc -fplugin=size_overflow_plugin.so test.c -O2
100889 + */
100890 +
100891 +#include "gcc-plugin.h"
100892 +#include "config.h"
100893 +#include "system.h"
100894 +#include "coretypes.h"
100895 +#include "tree.h"
100896 +#include "tree-pass.h"
100897 +#include "intl.h"
100898 +#include "plugin-version.h"
100899 +#include "tm.h"
100900 +#include "toplev.h"
100901 +#include "function.h"
100902 +#include "tree-flow.h"
100903 +#include "plugin.h"
100904 +#include "gimple.h"
100905 +#include "diagnostic.h"
100906 +#include "cfgloop.h"
100907 +
100908 +#if BUILDING_GCC_VERSION >= 4008
100909 +#define TODO_dump_func 0
100910 +#endif
100911 +
100912 +struct size_overflow_hash {
100913 + const struct size_overflow_hash * const next;
100914 + const char * const name;
100915 + const unsigned int param;
100916 +};
100917 +
100918 +#include "size_overflow_hash.h"
100919 +
100920 +enum mark {
100921 + MARK_NO, MARK_YES, MARK_NOT_INTENTIONAL, MARK_TURN_OFF
100922 +};
100923 +
100924 +enum err_code_conditions {
100925 + CAST_ONLY, FROM_CONST
100926 +};
100927 +
100928 +static unsigned int call_count = 0;
100929 +
100930 +#define __unused __attribute__((__unused__))
100931 +#define NAME(node) IDENTIFIER_POINTER(DECL_NAME(node))
100932 +#define NAME_LEN(node) IDENTIFIER_LENGTH(DECL_NAME(node))
100933 +#define BEFORE_STMT true
100934 +#define AFTER_STMT false
100935 +#define CREATE_NEW_VAR NULL_TREE
100936 +#define CODES_LIMIT 32
100937 +#define MAX_PARAM 31
100938 +#define MY_STMT GF_PLF_1
100939 +#define NO_CAST_CHECK GF_PLF_2
100940 +#define FROM_ARG true
100941 +#define FROM_RET false
100942 +
100943 +#if BUILDING_GCC_VERSION == 4005
100944 +#define DECL_CHAIN(NODE) (TREE_CHAIN(DECL_MINIMAL_CHECK(NODE)))
100945 +#endif
100946 +
100947 +int plugin_is_GPL_compatible;
100948 +void debug_gimple_stmt(gimple gs);
100949 +
100950 +static tree expand(struct pointer_set_t *visited, tree lhs);
100951 +static enum mark pre_expand(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs);
100952 +static tree report_size_overflow_decl;
100953 +static const_tree const_char_ptr_type_node;
100954 +static unsigned int handle_function(void);
100955 +static void check_size_overflow(gimple stmt, tree size_overflow_type, tree cast_rhs, tree rhs, bool before);
100956 +static tree get_size_overflow_type(gimple stmt, const_tree node);
100957 +static tree dup_assign(struct pointer_set_t *visited, gimple oldstmt, const_tree node, tree rhs1, tree rhs2, tree __unused rhs3);
100958 +static void print_missing_msg(tree func, unsigned int argnum);
100959 +
100960 +static struct plugin_info size_overflow_plugin_info = {
100961 + .version = "20130410beta",
100962 + .help = "no-size-overflow\tturn off size overflow checking\n",
100963 +};
100964 +
100965 +static tree handle_size_overflow_attribute(tree *node, tree __unused name, tree args, int __unused flags, bool *no_add_attrs)
100966 +{
100967 + unsigned int arg_count;
100968 + enum tree_code code = TREE_CODE(*node);
100969 +
100970 + switch (code) {
100971 + case FUNCTION_DECL:
100972 + arg_count = type_num_arguments(TREE_TYPE(*node));
100973 + break;
100974 + case FUNCTION_TYPE:
100975 + case METHOD_TYPE:
100976 + arg_count = type_num_arguments(*node);
100977 + break;
100978 + default:
100979 + *no_add_attrs = true;
100980 + error("%s: %qE attribute only applies to functions", __func__, name);
100981 + return NULL_TREE;
100982 + }
100983 +
100984 + for (; args; args = TREE_CHAIN(args)) {
100985 + tree position = TREE_VALUE(args);
100986 + if (TREE_CODE(position) != INTEGER_CST || TREE_INT_CST_LOW(position) > arg_count ) {
100987 + error("%s: parameter %u is outside range.", __func__, (unsigned int)TREE_INT_CST_LOW(position));
100988 + *no_add_attrs = true;
100989 + }
100990 + }
100991 + return NULL_TREE;
100992 +}
100993 +
100994 +static const char* get_asm_name(tree node)
100995 +{
100996 + return IDENTIFIER_POINTER(DECL_ASSEMBLER_NAME(node));
100997 +}
100998 +
100999 +static tree handle_intentional_overflow_attribute(tree *node, tree __unused name, tree args, int __unused flags, bool *no_add_attrs)
101000 +{
101001 + unsigned int arg_count, arg_num;
101002 + enum tree_code code = TREE_CODE(*node);
101003 +
101004 + switch (code) {
101005 + case FUNCTION_DECL:
101006 + arg_count = type_num_arguments(TREE_TYPE(*node));
101007 + break;
101008 + case FUNCTION_TYPE:
101009 + case METHOD_TYPE:
101010 + arg_count = type_num_arguments(*node);
101011 + break;
101012 + case FIELD_DECL:
101013 + arg_num = TREE_INT_CST_LOW(TREE_VALUE(args));
101014 + if (arg_num != 0) {
101015 + *no_add_attrs = true;
101016 + error("%s: %qE attribute parameter can only be 0 in structure fields", __func__, name);
101017 + }
101018 + return NULL_TREE;
101019 + default:
101020 + *no_add_attrs = true;
101021 + error("%qE attribute only applies to functions", name);
101022 + return NULL_TREE;
101023 + }
101024 +
101025 + if (TREE_INT_CST_HIGH(TREE_VALUE(args)) != 0)
101026 + return NULL_TREE;
101027 +
101028 + for (; args; args = TREE_CHAIN(args)) {
101029 + tree position = TREE_VALUE(args);
101030 + if (TREE_CODE(position) != INTEGER_CST || TREE_INT_CST_LOW(position) > arg_count ) {
101031 + error("%s: parameter %u is outside range.", __func__, (unsigned int)TREE_INT_CST_LOW(position));
101032 + *no_add_attrs = true;
101033 + }
101034 + }
101035 + return NULL_TREE;
101036 +}
101037 +
101038 +static struct attribute_spec size_overflow_attr = {
101039 + .name = "size_overflow",
101040 + .min_length = 1,
101041 + .max_length = -1,
101042 + .decl_required = true,
101043 + .type_required = false,
101044 + .function_type_required = false,
101045 + .handler = handle_size_overflow_attribute,
101046 +#if BUILDING_GCC_VERSION >= 4007
101047 + .affects_type_identity = false
101048 +#endif
101049 +};
101050 +
101051 +static struct attribute_spec intentional_overflow_attr = {
101052 + .name = "intentional_overflow",
101053 + .min_length = 1,
101054 + .max_length = -1,
101055 + .decl_required = true,
101056 + .type_required = false,
101057 + .function_type_required = false,
101058 + .handler = handle_intentional_overflow_attribute,
101059 +#if BUILDING_GCC_VERSION >= 4007
101060 + .affects_type_identity = false
101061 +#endif
101062 +};
101063 +
101064 +static void register_attributes(void __unused *event_data, void __unused *data)
101065 +{
101066 + register_attribute(&size_overflow_attr);
101067 + register_attribute(&intentional_overflow_attr);
101068 +}
101069 +
101070 +// http://www.team5150.com/~andrew/noncryptohashzoo2~/CrapWow.html
101071 +static unsigned int CrapWow(const char *key, unsigned int len, unsigned int seed)
101072 +{
101073 +#define cwfold( a, b, lo, hi ) { p = (unsigned int)(a) * (unsigned long long)(b); lo ^= (unsigned int)p; hi ^= (unsigned int)(p >> 32); }
101074 +#define cwmixa( in ) { cwfold( in, m, k, h ); }
101075 +#define cwmixb( in ) { cwfold( in, n, h, k ); }
101076 +
101077 + unsigned int m = 0x57559429;
101078 + unsigned int n = 0x5052acdb;
101079 + const unsigned int *key4 = (const unsigned int *)key;
101080 + unsigned int h = len;
101081 + unsigned int k = len + seed + n;
101082 + unsigned long long p;
101083 +
101084 + while (len >= 8) {
101085 + cwmixb(key4[0]) cwmixa(key4[1]) key4 += 2;
101086 + len -= 8;
101087 + }
101088 + if (len >= 4) {
101089 + cwmixb(key4[0]) key4 += 1;
101090 + len -= 4;
101091 + }
101092 + if (len)
101093 + cwmixa(key4[0] & ((1 << (len * 8)) - 1 ));
101094 + cwmixb(h ^ (k + n));
101095 + return k ^ h;
101096 +
101097 +#undef cwfold
101098 +#undef cwmixa
101099 +#undef cwmixb
101100 +}
101101 +
101102 +static inline unsigned int get_hash_num(const char *fndecl, const char *tree_codes, unsigned int len, unsigned int seed)
101103 +{
101104 + unsigned int fn = CrapWow(fndecl, strlen(fndecl), seed) & 0xffff;
101105 + unsigned int codes = CrapWow(tree_codes, len, seed) & 0xffff;
101106 + return fn ^ codes;
101107 +}
101108 +
101109 +static inline tree get_original_function_decl(tree fndecl)
101110 +{
101111 + if (DECL_ABSTRACT_ORIGIN(fndecl))
101112 + return DECL_ABSTRACT_ORIGIN(fndecl);
101113 + return fndecl;
101114 +}
101115 +
101116 +static inline gimple get_def_stmt(const_tree node)
101117 +{
101118 + gcc_assert(node != NULL_TREE);
101119 + if (TREE_CODE(node) != SSA_NAME)
101120 + return NULL;
101121 + return SSA_NAME_DEF_STMT(node);
101122 +}
101123 +
101124 +static unsigned char get_tree_code(const_tree type)
101125 +{
101126 + switch (TREE_CODE(type)) {
101127 + case ARRAY_TYPE:
101128 + return 0;
101129 + case BOOLEAN_TYPE:
101130 + return 1;
101131 + case ENUMERAL_TYPE:
101132 + return 2;
101133 + case FUNCTION_TYPE:
101134 + return 3;
101135 + case INTEGER_TYPE:
101136 + return 4;
101137 + case POINTER_TYPE:
101138 + return 5;
101139 + case RECORD_TYPE:
101140 + return 6;
101141 + case UNION_TYPE:
101142 + return 7;
101143 + case VOID_TYPE:
101144 + return 8;
101145 + case REAL_TYPE:
101146 + return 9;
101147 + case VECTOR_TYPE:
101148 + return 10;
101149 + case REFERENCE_TYPE:
101150 + return 11;
101151 + case OFFSET_TYPE:
101152 + return 12;
101153 + case COMPLEX_TYPE:
101154 + return 13;
101155 + default:
101156 + debug_tree((tree)type);
101157 + gcc_unreachable();
101158 + }
101159 +}
101160 +
101161 +static size_t add_type_codes(const_tree type, unsigned char *tree_codes, size_t len)
101162 +{
101163 + gcc_assert(type != NULL_TREE);
101164 +
101165 + while (type && len < CODES_LIMIT) {
101166 + tree_codes[len] = get_tree_code(type);
101167 + len++;
101168 + type = TREE_TYPE(type);
101169 + }
101170 + return len;
101171 +}
101172 +
101173 +static unsigned int get_function_decl(const_tree fndecl, unsigned char *tree_codes)
101174 +{
101175 + const_tree arg, result, arg_field, type = TREE_TYPE(fndecl);
101176 + enum tree_code code = TREE_CODE(type);
101177 + size_t len = 0;
101178 +
101179 + gcc_assert(code == FUNCTION_TYPE || code == METHOD_TYPE);
101180 +
101181 + arg = TYPE_ARG_TYPES(type);
101182 + // skip builtins __builtin_constant_p
101183 + if (!arg && DECL_BUILT_IN(fndecl))
101184 + return 0;
101185 +
101186 + if (TREE_CODE_CLASS(code) == tcc_type)
101187 + result = type;
101188 + else
101189 + result = DECL_RESULT(fndecl);
101190 +
101191 + gcc_assert(result != NULL_TREE);
101192 + len = add_type_codes(TREE_TYPE(result), tree_codes, len);
101193 +
101194 + if (arg == NULL_TREE) {
101195 + gcc_assert(CODE_CONTAINS_STRUCT(TREE_CODE(fndecl), TS_DECL_NON_COMMON));
101196 + arg_field = DECL_ARGUMENT_FLD(fndecl);
101197 + if (arg_field == NULL_TREE)
101198 + return 0;
101199 + arg = TREE_TYPE(arg_field);
101200 + len = add_type_codes(arg, tree_codes, len);
101201 + gcc_assert(len != 0);
101202 + return len;
101203 + }
101204 +
101205 + gcc_assert(arg != NULL_TREE && TREE_CODE(arg) == TREE_LIST);
101206 + while (arg && len < CODES_LIMIT) {
101207 + len = add_type_codes(TREE_VALUE(arg), tree_codes, len);
101208 + arg = TREE_CHAIN(arg);
101209 + }
101210 +
101211 + gcc_assert(len != 0);
101212 + return len;
101213 +}
101214 +
101215 +static const struct size_overflow_hash *get_function_hash(tree fndecl)
101216 +{
101217 + unsigned int hash;
101218 + const struct size_overflow_hash *entry;
101219 + unsigned char tree_codes[CODES_LIMIT];
101220 + size_t len;
101221 + const char *func_name;
101222 +
101223 + fndecl = get_original_function_decl(fndecl);
101224 + len = get_function_decl(fndecl, tree_codes);
101225 + if (len == 0)
101226 + return NULL;
101227 +
101228 + func_name = get_asm_name(fndecl);
101229 + hash = get_hash_num(func_name, (const char*) tree_codes, len, 0);
101230 +
101231 + entry = size_overflow_hash[hash];
101232 + while (entry) {
101233 + if (!strcmp(entry->name, func_name))
101234 + return entry;
101235 + entry = entry->next;
101236 + }
101237 +
101238 + return NULL;
101239 +}
101240 +
101241 +static bool is_bool(const_tree node)
101242 +{
101243 + const_tree type;
101244 +
101245 + if (node == NULL_TREE)
101246 + return false;
101247 +
101248 + type = TREE_TYPE(node);
101249 + if (!INTEGRAL_TYPE_P(type))
101250 + return false;
101251 + if (TREE_CODE(type) == BOOLEAN_TYPE)
101252 + return true;
101253 + if (TYPE_PRECISION(type) == 1)
101254 + return true;
101255 + return false;
101256 +}
101257 +
101258 +static bool skip_types(const_tree var)
101259 +{
101260 + tree type;
101261 +
101262 + if (is_gimple_constant(var))
101263 + return true;
101264 +
101265 + switch (TREE_CODE(var)) {
101266 + case ADDR_EXPR:
101267 +#if BUILDING_GCC_VERSION >= 4006
101268 + case MEM_REF:
101269 +#endif
101270 + case ARRAY_REF:
101271 + case BIT_FIELD_REF:
101272 + case INDIRECT_REF:
101273 + case TARGET_MEM_REF:
101274 + return true;
101275 + case PARM_DECL:
101276 + case VAR_DECL:
101277 + case COMPONENT_REF:
101278 + return false;
101279 + default:
101280 + break;
101281 + }
101282 +
101283 + gcc_assert(TREE_CODE(var) == SSA_NAME);
101284 +
101285 + type = TREE_TYPE(var);
101286 + switch (TREE_CODE(type)) {
101287 + case INTEGER_TYPE:
101288 + case ENUMERAL_TYPE:
101289 + return false;
101290 + case BOOLEAN_TYPE:
101291 + return is_bool(var);
101292 + default:
101293 + break;
101294 + }
101295 +
101296 + gcc_assert(TREE_CODE(type) == POINTER_TYPE);
101297 +
101298 + type = TREE_TYPE(type);
101299 + gcc_assert(type != NULL_TREE);
101300 + switch (TREE_CODE(type)) {
101301 + case RECORD_TYPE:
101302 + case POINTER_TYPE:
101303 + case ARRAY_TYPE:
101304 + return true;
101305 + case VOID_TYPE:
101306 + case INTEGER_TYPE:
101307 + case UNION_TYPE:
101308 + return false;
101309 + default:
101310 + break;
101311 + }
101312 +
101313 + debug_tree((tree)var);
101314 + gcc_unreachable();
101315 +}
101316 +
101317 +static unsigned int find_arg_number(const_tree arg, tree func)
101318 +{
101319 + tree var;
101320 + unsigned int argnum = 1;
101321 +
101322 + if (TREE_CODE(arg) == SSA_NAME)
101323 + arg = SSA_NAME_VAR(arg);
101324 +
101325 + for (var = DECL_ARGUMENTS(func); var; var = TREE_CHAIN(var), argnum++) {
101326 + if (!operand_equal_p(arg, var, 0) && strcmp(NAME(var), NAME(arg)))
101327 + continue;
101328 + if (!skip_types(var))
101329 + return argnum;
101330 + }
101331 +
101332 + return 0;
101333 +}
101334 +
101335 +static tree create_new_var(tree type)
101336 +{
101337 + tree new_var = create_tmp_var(type, "cicus");
101338 +
101339 +#if BUILDING_GCC_VERSION <= 4007
101340 + add_referenced_var(new_var);
101341 + mark_sym_for_renaming(new_var);
101342 +#endif
101343 + return new_var;
101344 +}
101345 +
101346 +static gimple create_binary_assign(enum tree_code code, gimple stmt, tree rhs1, tree rhs2)
101347 +{
101348 + gimple assign;
101349 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
101350 + tree type = TREE_TYPE(rhs1);
101351 + tree lhs = create_new_var(type);
101352 +
101353 + gcc_assert(types_compatible_p(type, TREE_TYPE(rhs2)));
101354 + assign = gimple_build_assign_with_ops(code, lhs, rhs1, rhs2);
101355 + gimple_set_lhs(assign, make_ssa_name(lhs, assign));
101356 +
101357 + gsi_insert_before(&gsi, assign, GSI_NEW_STMT);
101358 + update_stmt(assign);
101359 + gimple_set_plf(assign, MY_STMT, true);
101360 + return assign;
101361 +}
101362 +
101363 +static tree cast_a_tree(tree type, tree var)
101364 +{
101365 + gcc_assert(type != NULL_TREE);
101366 + gcc_assert(var != NULL_TREE);
101367 + gcc_assert(fold_convertible_p(type, var));
101368 +
101369 + return fold_convert(type, var);
101370 +}
101371 +
101372 +static tree get_lhs(const_gimple stmt)
101373 +{
101374 + switch (gimple_code(stmt)) {
101375 + case GIMPLE_ASSIGN:
101376 + return gimple_get_lhs(stmt);
101377 + case GIMPLE_PHI:
101378 + return gimple_phi_result(stmt);
101379 + case GIMPLE_CALL:
101380 + return gimple_call_lhs(stmt);
101381 + default:
101382 + return NULL_TREE;
101383 + }
101384 +}
101385 +
101386 +static bool skip_cast(tree dst_type, const_tree rhs, bool force)
101387 +{
101388 + const_gimple def_stmt = get_def_stmt(rhs);
101389 +
101390 + if (force)
101391 + return false;
101392 +
101393 + if (is_gimple_constant(rhs))
101394 + return false;
101395 +
101396 + if (!def_stmt || gimple_code(def_stmt) == GIMPLE_NOP)
101397 + return false;
101398 +
101399 + if (!types_compatible_p(dst_type, TREE_TYPE(rhs)))
101400 + return false;
101401 +
101402 + // DI type can be on 32 bit (from create_assign) but overflow type stays DI
101403 + if (LONG_TYPE_SIZE == GET_MODE_BITSIZE(SImode))
101404 + return false;
101405 +
101406 + return true;
101407 +}
101408 +
101409 +static gimple build_cast_stmt(tree dst_type, tree rhs, tree lhs, gimple_stmt_iterator *gsi, bool before, bool force)
101410 +{
101411 + gimple assign, def_stmt;
101412 +
101413 + gcc_assert(dst_type != NULL_TREE && rhs != NULL_TREE);
101414 + if (gsi_end_p(*gsi) && before == AFTER_STMT)
101415 + gcc_unreachable();
101416 +
101417 + def_stmt = get_def_stmt(rhs);
101418 + if (skip_cast(dst_type, rhs, force) && gimple_plf(def_stmt, MY_STMT))
101419 + return def_stmt;
101420 +
101421 + if (lhs == CREATE_NEW_VAR)
101422 + lhs = create_new_var(dst_type);
101423 +
101424 + assign = gimple_build_assign(lhs, cast_a_tree(dst_type, rhs));
101425 +
101426 + if (!gsi_end_p(*gsi)) {
101427 + location_t loc = gimple_location(gsi_stmt(*gsi));
101428 + gimple_set_location(assign, loc);
101429 + }
101430 +
101431 + gimple_set_lhs(assign, make_ssa_name(lhs, assign));
101432 +
101433 + if (before)
101434 + gsi_insert_before(gsi, assign, GSI_NEW_STMT);
101435 + else
101436 + gsi_insert_after(gsi, assign, GSI_NEW_STMT);
101437 + update_stmt(assign);
101438 + gimple_set_plf(assign, MY_STMT, true);
101439 +
101440 + return assign;
101441 +}
101442 +
101443 +static tree cast_to_new_size_overflow_type(gimple stmt, tree rhs, tree size_overflow_type, bool before)
101444 +{
101445 + gimple_stmt_iterator gsi;
101446 + tree lhs;
101447 + const_gimple new_stmt;
101448 +
101449 + if (rhs == NULL_TREE)
101450 + return NULL_TREE;
101451 +
101452 + gsi = gsi_for_stmt(stmt);
101453 + new_stmt = build_cast_stmt(size_overflow_type, rhs, CREATE_NEW_VAR, &gsi, before, false);
101454 +
101455 + lhs = get_lhs(new_stmt);
101456 + gcc_assert(lhs != NULL_TREE);
101457 + return lhs;
101458 +}
101459 +
101460 +static tree cast_to_TI_type(gimple stmt, tree node)
101461 +{
101462 + gimple_stmt_iterator gsi;
101463 + gimple cast_stmt;
101464 + tree type = TREE_TYPE(node);
101465 +
101466 + if (types_compatible_p(type, intTI_type_node))
101467 + return node;
101468 +
101469 + gsi = gsi_for_stmt(stmt);
101470 + cast_stmt = build_cast_stmt(intTI_type_node, node, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
101471 + return gimple_get_lhs(cast_stmt);
101472 +}
101473 +
101474 +static void check_function_hash(const_gimple stmt)
101475 +{
101476 + tree func;
101477 + const struct size_overflow_hash *hash;
101478 +
101479 + if (gimple_code(stmt) != GIMPLE_CALL)
101480 + return;
101481 +
101482 + func = gimple_call_fndecl(stmt);
101483 + //fs/xattr.c D.34222_15 = D.34219_14 (dentry_3(D), name_7(D), 0B, 0);
101484 + if (func == NULL_TREE)
101485 + return;
101486 +
101487 + hash = get_function_hash(func);
101488 + if (!hash)
101489 + print_missing_msg(func, 0);
101490 +}
101491 +
101492 +static tree create_assign(struct pointer_set_t *visited, gimple oldstmt, tree rhs1, bool before)
101493 +{
101494 + tree lhs, new_lhs;
101495 + gimple_stmt_iterator gsi;
101496 +
101497 + if (rhs1 == NULL_TREE) {
101498 + debug_gimple_stmt(oldstmt);
101499 + error("%s: rhs1 is NULL_TREE", __func__);
101500 + gcc_unreachable();
101501 + }
101502 +
101503 + switch (gimple_code(oldstmt)) {
101504 + case GIMPLE_ASM:
101505 + lhs = rhs1;
101506 + break;
101507 + case GIMPLE_CALL:
101508 + lhs = gimple_call_lhs(oldstmt);
101509 + break;
101510 + case GIMPLE_ASSIGN:
101511 + lhs = gimple_get_lhs(oldstmt);
101512 + break;
101513 + default:
101514 + debug_gimple_stmt(oldstmt);
101515 + gcc_unreachable();
101516 + }
101517 +
101518 + gsi = gsi_for_stmt(oldstmt);
101519 + pointer_set_insert(visited, oldstmt);
101520 + if (lookup_stmt_eh_lp(oldstmt) != 0) {
101521 + basic_block next_bb, cur_bb;
101522 + const_edge e;
101523 +
101524 + gcc_assert(before == false);
101525 + gcc_assert(stmt_can_throw_internal(oldstmt));
101526 + gcc_assert(gimple_code(oldstmt) == GIMPLE_CALL);
101527 + gcc_assert(!gsi_end_p(gsi));
101528 +
101529 + cur_bb = gimple_bb(oldstmt);
101530 + next_bb = cur_bb->next_bb;
101531 + e = find_edge(cur_bb, next_bb);
101532 + gcc_assert(e != NULL);
101533 + gcc_assert(e->flags & EDGE_FALLTHRU);
101534 +
101535 + gsi = gsi_after_labels(next_bb);
101536 + gcc_assert(!gsi_end_p(gsi));
101537 +
101538 + before = true;
101539 + oldstmt = gsi_stmt(gsi);
101540 + }
101541 +
101542 + new_lhs = cast_to_new_size_overflow_type(oldstmt, rhs1, get_size_overflow_type(oldstmt, lhs), before);
101543 + return new_lhs;
101544 +}
101545 +
101546 +static tree dup_assign(struct pointer_set_t *visited, gimple oldstmt, const_tree node, tree rhs1, tree rhs2, tree __unused rhs3)
101547 +{
101548 + gimple stmt;
101549 + gimple_stmt_iterator gsi;
101550 + tree size_overflow_type, new_var, lhs = gimple_get_lhs(oldstmt);
101551 +
101552 + if (gimple_plf(oldstmt, MY_STMT))
101553 + return lhs;
101554 +
101555 + if (gimple_num_ops(oldstmt) != 4 && rhs1 == NULL_TREE) {
101556 + rhs1 = gimple_assign_rhs1(oldstmt);
101557 + rhs1 = create_assign(visited, oldstmt, rhs1, BEFORE_STMT);
101558 + }
101559 + if (gimple_num_ops(oldstmt) == 3 && rhs2 == NULL_TREE) {
101560 + rhs2 = gimple_assign_rhs2(oldstmt);
101561 + rhs2 = create_assign(visited, oldstmt, rhs2, BEFORE_STMT);
101562 + }
101563 +
101564 + stmt = gimple_copy(oldstmt);
101565 + gimple_set_location(stmt, gimple_location(oldstmt));
101566 + gimple_set_plf(stmt, MY_STMT, true);
101567 +
101568 + if (gimple_assign_rhs_code(oldstmt) == WIDEN_MULT_EXPR)
101569 + gimple_assign_set_rhs_code(stmt, MULT_EXPR);
101570 +
101571 + size_overflow_type = get_size_overflow_type(oldstmt, node);
101572 +
101573 + new_var = create_new_var(size_overflow_type);
101574 + new_var = make_ssa_name(new_var, stmt);
101575 + gimple_set_lhs(stmt, new_var);
101576 +
101577 + if (rhs1 != NULL_TREE)
101578 + gimple_assign_set_rhs1(stmt, rhs1);
101579 +
101580 + if (rhs2 != NULL_TREE)
101581 + gimple_assign_set_rhs2(stmt, rhs2);
101582 +#if BUILDING_GCC_VERSION >= 4007
101583 + if (rhs3 != NULL_TREE)
101584 + gimple_assign_set_rhs3(stmt, rhs3);
101585 +#endif
101586 + gimple_set_vuse(stmt, gimple_vuse(oldstmt));
101587 + gimple_set_vdef(stmt, gimple_vdef(oldstmt));
101588 +
101589 + gsi = gsi_for_stmt(oldstmt);
101590 + gsi_insert_after(&gsi, stmt, GSI_SAME_STMT);
101591 + update_stmt(stmt);
101592 + pointer_set_insert(visited, oldstmt);
101593 + return gimple_get_lhs(stmt);
101594 +}
101595 +
101596 +static tree cast_parm_decl(tree phi_ssa_name, tree arg, tree size_overflow_type)
101597 +{
101598 + basic_block first_bb;
101599 + gimple assign;
101600 + gimple_stmt_iterator gsi;
101601 +
101602 + first_bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
101603 + gcc_assert(dom_info_available_p(CDI_DOMINATORS));
101604 + set_immediate_dominator(CDI_DOMINATORS, first_bb, ENTRY_BLOCK_PTR);
101605 +
101606 + gsi = gsi_start_bb(first_bb);
101607 + assign = build_cast_stmt(size_overflow_type, arg, phi_ssa_name, &gsi, BEFORE_STMT, false);
101608 + return gimple_get_lhs(assign);
101609 +}
101610 +
101611 +static tree use_phi_ssa_name(tree phi_ssa_name, tree new_arg)
101612 +{
101613 + gimple_stmt_iterator gsi;
101614 + const_gimple assign;
101615 + gimple def_stmt = get_def_stmt(new_arg);
101616 +
101617 + if (gimple_code(def_stmt) == GIMPLE_PHI) {
101618 + gsi = gsi_after_labels(gimple_bb(def_stmt));
101619 + assign = build_cast_stmt(TREE_TYPE(new_arg), new_arg, phi_ssa_name, &gsi, BEFORE_STMT, true);
101620 + } else {
101621 + gsi = gsi_for_stmt(def_stmt);
101622 + assign = build_cast_stmt(TREE_TYPE(new_arg), new_arg, phi_ssa_name, &gsi, AFTER_STMT, true);
101623 + }
101624 +
101625 + return gimple_get_lhs(assign);
101626 +}
101627 +
101628 +static tree cast_visited_phi_arg(tree phi_ssa_name, tree arg, tree size_overflow_type)
101629 +{
101630 + basic_block bb;
101631 + gimple_stmt_iterator gsi;
101632 + const_gimple assign, def_stmt;
101633 +
101634 + def_stmt = get_def_stmt(arg);
101635 + bb = gimple_bb(def_stmt);
101636 + gcc_assert(bb->index != 0);
101637 + gsi = gsi_after_labels(bb);
101638 +
101639 + assign = build_cast_stmt(size_overflow_type, arg, phi_ssa_name, &gsi, BEFORE_STMT, false);
101640 + return gimple_get_lhs(assign);
101641 +}
101642 +
101643 +static tree create_new_phi_arg(tree phi_ssa_name, tree new_arg, tree arg, gimple oldstmt)
101644 +{
101645 + tree size_overflow_type;
101646 + const_gimple def_stmt = get_def_stmt(arg);
101647 +
101648 + if (phi_ssa_name != NULL_TREE)
101649 + phi_ssa_name = SSA_NAME_VAR(phi_ssa_name);
101650 +
101651 + size_overflow_type = get_size_overflow_type(oldstmt, arg);
101652 +
101653 + if (new_arg != NULL_TREE) {
101654 + gcc_assert(types_compatible_p(TREE_TYPE(new_arg), size_overflow_type));
101655 + return use_phi_ssa_name(phi_ssa_name, new_arg);
101656 + }
101657 +
101658 + switch(gimple_code(def_stmt)) {
101659 + case GIMPLE_PHI:
101660 + return cast_visited_phi_arg(phi_ssa_name, arg, size_overflow_type);
101661 + case GIMPLE_NOP:
101662 + return cast_parm_decl(phi_ssa_name, arg, size_overflow_type);
101663 + default:
101664 + debug_gimple_stmt((gimple)def_stmt);
101665 + gcc_unreachable();
101666 + }
101667 +}
101668 +
101669 +static gimple overflow_create_phi_node(gimple oldstmt, tree result)
101670 +{
101671 + basic_block bb;
101672 + gimple phi;
101673 + gimple_seq seq;
101674 + gimple_stmt_iterator gsi = gsi_for_stmt(oldstmt);
101675 +
101676 + bb = gsi_bb(gsi);
101677 +
101678 + phi = create_phi_node(result, bb);
101679 + gimple_phi_set_result(phi, make_ssa_name(result, phi));
101680 + seq = phi_nodes(bb);
101681 + gsi = gsi_last(seq);
101682 + gsi_remove(&gsi, false);
101683 +
101684 + gsi = gsi_for_stmt(oldstmt);
101685 + gsi_insert_after(&gsi, phi, GSI_NEW_STMT);
101686 + gimple_set_bb(phi, bb);
101687 + gimple_set_plf(phi, MY_STMT, true);
101688 + return phi;
101689 +}
101690 +
101691 +static tree handle_phi(struct pointer_set_t *visited, tree orig_result)
101692 +{
101693 + gimple new_phi = NULL;
101694 + gimple oldstmt = get_def_stmt(orig_result);
101695 + tree phi_ssa_name = NULL_TREE;
101696 + unsigned int i;
101697 +
101698 + pointer_set_insert(visited, oldstmt);
101699 + for (i = 0; i < gimple_phi_num_args(oldstmt); i++) {
101700 + tree arg, new_arg;
101701 +
101702 + arg = gimple_phi_arg_def(oldstmt, i);
101703 +
101704 + new_arg = expand(visited, arg);
101705 + new_arg = create_new_phi_arg(phi_ssa_name, new_arg, arg, oldstmt);
101706 + if (i == 0) {
101707 + phi_ssa_name = new_arg;
101708 + new_phi = overflow_create_phi_node(oldstmt, SSA_NAME_VAR(phi_ssa_name));
101709 + }
101710 +
101711 + gcc_assert(new_phi != NULL);
101712 + add_phi_arg(new_phi, new_arg, gimple_phi_arg_edge(oldstmt, i), gimple_location(oldstmt));
101713 + }
101714 +
101715 + gcc_assert(new_phi != NULL);
101716 + update_stmt(new_phi);
101717 + return gimple_phi_result(new_phi);
101718 +}
101719 +
101720 +static tree change_assign_rhs(gimple stmt, const_tree orig_rhs, tree new_rhs)
101721 +{
101722 + const_gimple assign;
101723 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
101724 + tree origtype = TREE_TYPE(orig_rhs);
101725 +
101726 + gcc_assert(gimple_code(stmt) == GIMPLE_ASSIGN);
101727 +
101728 + assign = build_cast_stmt(origtype, new_rhs, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
101729 + return gimple_get_lhs(assign);
101730 +}
101731 +
101732 +static bool is_a_cast_and_const_overflow(const_tree no_const_rhs)
101733 +{
101734 + const_tree rhs1, lhs, rhs1_type, lhs_type;
101735 + enum machine_mode lhs_mode, rhs_mode;
101736 + gimple def_stmt = get_def_stmt(no_const_rhs);
101737 +
101738 + if (!gimple_assign_cast_p(def_stmt))
101739 + return false;
101740 +
101741 + rhs1 = gimple_assign_rhs1(def_stmt);
101742 + lhs = gimple_get_lhs(def_stmt);
101743 + rhs1_type = TREE_TYPE(rhs1);
101744 + lhs_type = TREE_TYPE(lhs);
101745 + rhs_mode = TYPE_MODE(rhs1_type);
101746 + lhs_mode = TYPE_MODE(lhs_type);
101747 + if (TYPE_UNSIGNED(lhs_type) == TYPE_UNSIGNED(rhs1_type) || lhs_mode != rhs_mode)
101748 + return false;
101749 +
101750 + return true;
101751 +}
101752 +
101753 +static tree create_cast_assign(struct pointer_set_t *visited, gimple stmt)
101754 +{
101755 + tree rhs1 = gimple_assign_rhs1(stmt);
101756 + tree lhs = gimple_get_lhs(stmt);
101757 + const_tree rhs1_type = TREE_TYPE(rhs1);
101758 + const_tree lhs_type = TREE_TYPE(lhs);
101759 +
101760 + if (TYPE_UNSIGNED(rhs1_type) == TYPE_UNSIGNED(lhs_type))
101761 + return create_assign(visited, stmt, lhs, AFTER_STMT);
101762 +
101763 + return create_assign(visited, stmt, rhs1, AFTER_STMT);
101764 +}
101765 +
101766 +static bool no_uses(tree node)
101767 +{
101768 + imm_use_iterator imm_iter;
101769 + use_operand_p use_p;
101770 +
101771 + FOR_EACH_IMM_USE_FAST(use_p, imm_iter, node) {
101772 + const_gimple use_stmt = USE_STMT(use_p);
101773 + if (use_stmt == NULL)
101774 + return true;
101775 + if (is_gimple_debug(use_stmt))
101776 + continue;
101777 + if (!(gimple_bb(use_stmt)->flags & BB_REACHABLE))
101778 + continue;
101779 + return false;
101780 + }
101781 + return true;
101782 +}
101783 +
101784 +// 3.8.5 mm/page-writeback.c __ilog2_u64(): ret, uint + uintmax; uint -> int; int max
101785 +static bool is_const_plus_unsigned_signed_truncation(const_tree lhs)
101786 +{
101787 + tree rhs1, lhs_type, rhs_type, rhs2, not_const_rhs;
101788 + gimple def_stmt = get_def_stmt(lhs);
101789 +
101790 + if (!def_stmt || !gimple_assign_cast_p(def_stmt))
101791 + return false;
101792 +
101793 + rhs1 = gimple_assign_rhs1(def_stmt);
101794 + rhs_type = TREE_TYPE(rhs1);
101795 + lhs_type = TREE_TYPE(lhs);
101796 + if (TYPE_UNSIGNED(lhs_type) || !TYPE_UNSIGNED(rhs_type))
101797 + return false;
101798 + if (TYPE_MODE(lhs_type) != TYPE_MODE(rhs_type))
101799 + return false;
101800 +
101801 + def_stmt = get_def_stmt(rhs1);
101802 + if (!def_stmt || gimple_code(def_stmt) != GIMPLE_ASSIGN || gimple_num_ops(def_stmt) != 3)
101803 + return false;
101804 +
101805 + if (gimple_assign_rhs_code(def_stmt) != PLUS_EXPR)
101806 + return false;
101807 +
101808 + rhs1 = gimple_assign_rhs1(def_stmt);
101809 + rhs2 = gimple_assign_rhs2(def_stmt);
101810 + if (!is_gimple_constant(rhs1) && !is_gimple_constant(rhs2))
101811 + return false;
101812 +
101813 + if (is_gimple_constant(rhs2))
101814 + not_const_rhs = rhs1;
101815 + else
101816 + not_const_rhs = rhs2;
101817 +
101818 + return no_uses(not_const_rhs);
101819 +}
101820 +
101821 +static bool skip_lhs_cast_check(const_gimple stmt)
101822 +{
101823 + const_tree rhs = gimple_assign_rhs1(stmt);
101824 + const_gimple def_stmt = get_def_stmt(rhs);
101825 +
101826 + // 3.8.2 kernel/futex_compat.c compat_exit_robust_list(): get_user() 64 ulong -> int (compat_long_t), int max
101827 + if (gimple_code(def_stmt) == GIMPLE_ASM)
101828 + return true;
101829 +
101830 + if (is_const_plus_unsigned_signed_truncation(rhs))
101831 + return true;
101832 +
101833 + return false;
101834 +}
101835 +
101836 +static tree create_cast_overflow_check(struct pointer_set_t *visited, tree new_rhs1, gimple stmt)
101837 +{
101838 + bool cast_lhs, cast_rhs;
101839 + tree lhs = gimple_get_lhs(stmt);
101840 + tree rhs = gimple_assign_rhs1(stmt);
101841 + const_tree lhs_type = TREE_TYPE(lhs);
101842 + const_tree rhs_type = TREE_TYPE(rhs);
101843 + enum machine_mode lhs_mode = TYPE_MODE(lhs_type);
101844 + enum machine_mode rhs_mode = TYPE_MODE(rhs_type);
101845 + unsigned int lhs_size = GET_MODE_BITSIZE(lhs_mode);
101846 + unsigned int rhs_size = GET_MODE_BITSIZE(rhs_mode);
101847 +
101848 + static bool check_lhs[3][4] = {
101849 + // ss su us uu
101850 + { false, true, true, false }, // lhs > rhs
101851 + { false, false, false, false }, // lhs = rhs
101852 + { true, true, true, true }, // lhs < rhs
101853 + };
101854 +
101855 + static bool check_rhs[3][4] = {
101856 + // ss su us uu
101857 + { true, false, true, true }, // lhs > rhs
101858 + { true, false, true, true }, // lhs = rhs
101859 + { true, false, true, true }, // lhs < rhs
101860 + };
101861 +
101862 + // skip lhs check on signed SI -> HI cast or signed SI -> QI cast !!!!
101863 + if (rhs_mode == SImode && !TYPE_UNSIGNED(rhs_type) && (lhs_mode == HImode || lhs_mode == QImode))
101864 + return create_assign(visited, stmt, lhs, AFTER_STMT);
101865 +
101866 + if (lhs_size > rhs_size) {
101867 + cast_lhs = check_lhs[0][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
101868 + cast_rhs = check_rhs[0][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
101869 + } else if (lhs_size == rhs_size) {
101870 + cast_lhs = check_lhs[1][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
101871 + cast_rhs = check_rhs[1][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
101872 + } else {
101873 + cast_lhs = check_lhs[2][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
101874 + cast_rhs = check_rhs[2][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
101875 + }
101876 +
101877 + if (!cast_lhs && !cast_rhs)
101878 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
101879 +
101880 + if (cast_lhs && !skip_lhs_cast_check(stmt))
101881 + check_size_overflow(stmt, TREE_TYPE(new_rhs1), new_rhs1, lhs, BEFORE_STMT);
101882 +
101883 + if (cast_rhs)
101884 + check_size_overflow(stmt, TREE_TYPE(new_rhs1), new_rhs1, rhs, BEFORE_STMT);
101885 +
101886 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
101887 +}
101888 +
101889 +static tree handle_unary_rhs(struct pointer_set_t *visited, gimple stmt)
101890 +{
101891 + tree rhs1, new_rhs1, lhs = gimple_get_lhs(stmt);
101892 +
101893 + if (gimple_plf(stmt, MY_STMT))
101894 + return lhs;
101895 +
101896 + rhs1 = gimple_assign_rhs1(stmt);
101897 + if (TREE_CODE(TREE_TYPE(rhs1)) == POINTER_TYPE)
101898 + return create_assign(visited, stmt, lhs, AFTER_STMT);
101899 +
101900 + new_rhs1 = expand(visited, rhs1);
101901 +
101902 + if (new_rhs1 == NULL_TREE)
101903 + return create_cast_assign(visited, stmt);
101904 +
101905 + if (gimple_plf(stmt, NO_CAST_CHECK))
101906 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
101907 +
101908 + if (gimple_assign_rhs_code(stmt) == BIT_NOT_EXPR) {
101909 + tree size_overflow_type = get_size_overflow_type(stmt, rhs1);
101910 +
101911 + new_rhs1 = cast_to_new_size_overflow_type(stmt, new_rhs1, size_overflow_type, BEFORE_STMT);
101912 + check_size_overflow(stmt, size_overflow_type, new_rhs1, rhs1, BEFORE_STMT);
101913 + return create_assign(visited, stmt, lhs, AFTER_STMT);
101914 + }
101915 +
101916 + if (!gimple_assign_cast_p(stmt))
101917 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
101918 +
101919 + return create_cast_overflow_check(visited, new_rhs1, stmt);
101920 +}
101921 +
101922 +static tree handle_unary_ops(struct pointer_set_t *visited, gimple stmt)
101923 +{
101924 + tree rhs1, lhs = gimple_get_lhs(stmt);
101925 + gimple def_stmt = get_def_stmt(lhs);
101926 +
101927 + gcc_assert(gimple_code(def_stmt) != GIMPLE_NOP);
101928 + rhs1 = gimple_assign_rhs1(def_stmt);
101929 +
101930 + if (is_gimple_constant(rhs1))
101931 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
101932 +
101933 + switch (TREE_CODE(rhs1)) {
101934 + case SSA_NAME:
101935 + return handle_unary_rhs(visited, def_stmt);
101936 + case ARRAY_REF:
101937 + case BIT_FIELD_REF:
101938 + case ADDR_EXPR:
101939 + case COMPONENT_REF:
101940 + case INDIRECT_REF:
101941 +#if BUILDING_GCC_VERSION >= 4006
101942 + case MEM_REF:
101943 +#endif
101944 + case TARGET_MEM_REF:
101945 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
101946 + case PARM_DECL:
101947 + case VAR_DECL:
101948 + return create_assign(visited, stmt, lhs, AFTER_STMT);
101949 +
101950 + default:
101951 + debug_gimple_stmt(def_stmt);
101952 + debug_tree(rhs1);
101953 + gcc_unreachable();
101954 + }
101955 +}
101956 +
101957 +static void insert_cond(basic_block cond_bb, tree arg, enum tree_code cond_code, tree type_value)
101958 +{
101959 + gimple cond_stmt;
101960 + gimple_stmt_iterator gsi = gsi_last_bb(cond_bb);
101961 +
101962 + cond_stmt = gimple_build_cond(cond_code, arg, type_value, NULL_TREE, NULL_TREE);
101963 + gsi_insert_after(&gsi, cond_stmt, GSI_CONTINUE_LINKING);
101964 + update_stmt(cond_stmt);
101965 +}
101966 +
101967 +static tree create_string_param(tree string)
101968 +{
101969 + tree i_type, a_type;
101970 + const int length = TREE_STRING_LENGTH(string);
101971 +
101972 + gcc_assert(length > 0);
101973 +
101974 + i_type = build_index_type(build_int_cst(NULL_TREE, length - 1));
101975 + a_type = build_array_type(char_type_node, i_type);
101976 +
101977 + TREE_TYPE(string) = a_type;
101978 + TREE_CONSTANT(string) = 1;
101979 + TREE_READONLY(string) = 1;
101980 +
101981 + return build1(ADDR_EXPR, ptr_type_node, string);
101982 +}
101983 +
101984 +static void insert_cond_result(basic_block bb_true, const_gimple stmt, const_tree arg, bool min)
101985 +{
101986 + gimple func_stmt;
101987 + const_gimple def_stmt;
101988 + const_tree loc_line;
101989 + tree loc_file, ssa_name, current_func;
101990 + expanded_location xloc;
101991 + char *ssa_name_buf;
101992 + int len;
101993 + gimple_stmt_iterator gsi = gsi_start_bb(bb_true);
101994 +
101995 + def_stmt = get_def_stmt(arg);
101996 + xloc = expand_location(gimple_location(def_stmt));
101997 +
101998 + if (!gimple_has_location(def_stmt)) {
101999 + xloc = expand_location(gimple_location(stmt));
102000 + if (!gimple_has_location(stmt))
102001 + xloc = expand_location(DECL_SOURCE_LOCATION(current_function_decl));
102002 + }
102003 +
102004 + loc_line = build_int_cstu(unsigned_type_node, xloc.line);
102005 +
102006 + loc_file = build_string(strlen(xloc.file) + 1, xloc.file);
102007 + loc_file = create_string_param(loc_file);
102008 +
102009 + current_func = build_string(NAME_LEN(current_function_decl) + 1, NAME(current_function_decl));
102010 + current_func = create_string_param(current_func);
102011 +
102012 + gcc_assert(DECL_NAME(SSA_NAME_VAR(arg)) != NULL);
102013 + call_count++;
102014 + 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);
102015 + gcc_assert(len > 0);
102016 + ssa_name = build_string(len + 1, ssa_name_buf);
102017 + free(ssa_name_buf);
102018 + ssa_name = create_string_param(ssa_name);
102019 +
102020 + // void report_size_overflow(const char *file, unsigned int line, const char *func, const char *ssa_name)
102021 + func_stmt = gimple_build_call(report_size_overflow_decl, 4, loc_file, loc_line, current_func, ssa_name);
102022 +
102023 + gsi_insert_after(&gsi, func_stmt, GSI_CONTINUE_LINKING);
102024 +}
102025 +
102026 +static void __unused print_the_code_insertions(const_gimple stmt)
102027 +{
102028 + location_t loc = gimple_location(stmt);
102029 +
102030 + inform(loc, "Integer size_overflow check applied here.");
102031 +}
102032 +
102033 +static void insert_check_size_overflow(gimple stmt, enum tree_code cond_code, tree arg, tree type_value, bool before, bool min)
102034 +{
102035 + basic_block cond_bb, join_bb, bb_true;
102036 + edge e;
102037 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
102038 +
102039 + cond_bb = gimple_bb(stmt);
102040 + if (before)
102041 + gsi_prev(&gsi);
102042 + if (gsi_end_p(gsi))
102043 + e = split_block_after_labels(cond_bb);
102044 + else
102045 + e = split_block(cond_bb, gsi_stmt(gsi));
102046 + cond_bb = e->src;
102047 + join_bb = e->dest;
102048 + e->flags = EDGE_FALSE_VALUE;
102049 + e->probability = REG_BR_PROB_BASE;
102050 +
102051 + bb_true = create_empty_bb(cond_bb);
102052 + make_edge(cond_bb, bb_true, EDGE_TRUE_VALUE);
102053 + make_edge(cond_bb, join_bb, EDGE_FALSE_VALUE);
102054 + make_edge(bb_true, join_bb, EDGE_FALLTHRU);
102055 +
102056 + gcc_assert(dom_info_available_p(CDI_DOMINATORS));
102057 + set_immediate_dominator(CDI_DOMINATORS, bb_true, cond_bb);
102058 + set_immediate_dominator(CDI_DOMINATORS, join_bb, cond_bb);
102059 +
102060 + if (current_loops != NULL) {
102061 + gcc_assert(cond_bb->loop_father == join_bb->loop_father);
102062 + add_bb_to_loop(bb_true, cond_bb->loop_father);
102063 + }
102064 +
102065 + insert_cond(cond_bb, arg, cond_code, type_value);
102066 + insert_cond_result(bb_true, stmt, arg, min);
102067 +
102068 +// print_the_code_insertions(stmt);
102069 +}
102070 +
102071 +static void check_size_overflow(gimple stmt, tree size_overflow_type, tree cast_rhs, tree rhs, bool before)
102072 +{
102073 + const_tree rhs_type = TREE_TYPE(rhs);
102074 + tree cast_rhs_type, type_max_type, type_min_type, type_max, type_min;
102075 +
102076 + gcc_assert(rhs_type != NULL_TREE);
102077 + if (TREE_CODE(rhs_type) == POINTER_TYPE)
102078 + return;
102079 +
102080 + gcc_assert(TREE_CODE(rhs_type) == INTEGER_TYPE || TREE_CODE(rhs_type) == ENUMERAL_TYPE);
102081 +
102082 + if (is_const_plus_unsigned_signed_truncation(rhs))
102083 + return;
102084 +
102085 + type_max = cast_a_tree(size_overflow_type, TYPE_MAX_VALUE(rhs_type));
102086 + // typemax (-1) < typemin (0)
102087 + if (TREE_OVERFLOW(type_max))
102088 + return;
102089 +
102090 + type_min = cast_a_tree(size_overflow_type, TYPE_MIN_VALUE(rhs_type));
102091 +
102092 + cast_rhs_type = TREE_TYPE(cast_rhs);
102093 + type_max_type = TREE_TYPE(type_max);
102094 + type_min_type = TREE_TYPE(type_min);
102095 + gcc_assert(types_compatible_p(cast_rhs_type, type_max_type));
102096 + gcc_assert(types_compatible_p(type_max_type, type_min_type));
102097 +
102098 + insert_check_size_overflow(stmt, GT_EXPR, cast_rhs, type_max, before, false);
102099 + insert_check_size_overflow(stmt, LT_EXPR, cast_rhs, type_min, before, true);
102100 +}
102101 +
102102 +static bool is_a_constant_overflow(const_gimple stmt, const_tree rhs)
102103 +{
102104 + if (gimple_assign_rhs_code(stmt) == MIN_EXPR)
102105 + return false;
102106 + if (!is_gimple_constant(rhs))
102107 + return false;
102108 + return true;
102109 +}
102110 +
102111 +static tree get_def_stmt_rhs(const_tree var)
102112 +{
102113 + tree rhs1, def_stmt_rhs1;
102114 + gimple rhs1_def_stmt, def_stmt_rhs1_def_stmt, def_stmt;
102115 +
102116 + def_stmt = get_def_stmt(var);
102117 + gcc_assert(gimple_code(def_stmt) != GIMPLE_NOP && gimple_plf(def_stmt, MY_STMT) && gimple_assign_cast_p(def_stmt));
102118 +
102119 + rhs1 = gimple_assign_rhs1(def_stmt);
102120 + rhs1_def_stmt = get_def_stmt(rhs1);
102121 + if (!gimple_assign_cast_p(rhs1_def_stmt))
102122 + return rhs1;
102123 +
102124 + def_stmt_rhs1 = gimple_assign_rhs1(rhs1_def_stmt);
102125 + def_stmt_rhs1_def_stmt = get_def_stmt(def_stmt_rhs1);
102126 +
102127 + switch (gimple_code(def_stmt_rhs1_def_stmt)) {
102128 + case GIMPLE_CALL:
102129 + case GIMPLE_NOP:
102130 + case GIMPLE_ASM:
102131 + case GIMPLE_PHI:
102132 + return def_stmt_rhs1;
102133 + case GIMPLE_ASSIGN:
102134 + return rhs1;
102135 + default:
102136 + debug_gimple_stmt(def_stmt_rhs1_def_stmt);
102137 + gcc_unreachable();
102138 + }
102139 +}
102140 +
102141 +static tree handle_intentional_overflow(struct pointer_set_t *visited, bool check_overflow, gimple stmt, tree change_rhs, tree new_rhs2)
102142 +{
102143 + tree new_rhs, orig_rhs;
102144 + void (*gimple_assign_set_rhs)(gimple, tree);
102145 + tree rhs1 = gimple_assign_rhs1(stmt);
102146 + tree rhs2 = gimple_assign_rhs2(stmt);
102147 + tree lhs = gimple_get_lhs(stmt);
102148 +
102149 + if (!check_overflow)
102150 + return create_assign(visited, stmt, lhs, AFTER_STMT);
102151 +
102152 + if (change_rhs == NULL_TREE)
102153 + return create_assign(visited, stmt, lhs, AFTER_STMT);
102154 +
102155 + if (new_rhs2 == NULL_TREE) {
102156 + orig_rhs = rhs1;
102157 + gimple_assign_set_rhs = &gimple_assign_set_rhs1;
102158 + } else {
102159 + orig_rhs = rhs2;
102160 + gimple_assign_set_rhs = &gimple_assign_set_rhs2;
102161 + }
102162 +
102163 + check_size_overflow(stmt, TREE_TYPE(change_rhs), change_rhs, orig_rhs, BEFORE_STMT);
102164 +
102165 + new_rhs = change_assign_rhs(stmt, orig_rhs, change_rhs);
102166 + gimple_assign_set_rhs(stmt, new_rhs);
102167 + update_stmt(stmt);
102168 +
102169 + return create_assign(visited, stmt, lhs, AFTER_STMT);
102170 +}
102171 +
102172 +static bool is_subtraction_special(const_gimple stmt)
102173 +{
102174 + gimple rhs1_def_stmt, rhs2_def_stmt;
102175 + const_tree rhs1_def_stmt_rhs1, rhs2_def_stmt_rhs1, rhs1_def_stmt_lhs, rhs2_def_stmt_lhs;
102176 + enum machine_mode rhs1_def_stmt_rhs1_mode, rhs2_def_stmt_rhs1_mode, rhs1_def_stmt_lhs_mode, rhs2_def_stmt_lhs_mode;
102177 + const_tree rhs1 = gimple_assign_rhs1(stmt);
102178 + const_tree rhs2 = gimple_assign_rhs2(stmt);
102179 +
102180 + if (is_gimple_constant(rhs1) || is_gimple_constant(rhs2))
102181 + return false;
102182 +
102183 + gcc_assert(TREE_CODE(rhs1) == SSA_NAME && TREE_CODE(rhs2) == SSA_NAME);
102184 +
102185 + if (gimple_assign_rhs_code(stmt) != MINUS_EXPR)
102186 + return false;
102187 +
102188 + rhs1_def_stmt = get_def_stmt(rhs1);
102189 + rhs2_def_stmt = get_def_stmt(rhs2);
102190 + if (!gimple_assign_cast_p(rhs1_def_stmt) || !gimple_assign_cast_p(rhs2_def_stmt))
102191 + return false;
102192 +
102193 + rhs1_def_stmt_rhs1 = gimple_assign_rhs1(rhs1_def_stmt);
102194 + rhs2_def_stmt_rhs1 = gimple_assign_rhs1(rhs2_def_stmt);
102195 + rhs1_def_stmt_lhs = gimple_get_lhs(rhs1_def_stmt);
102196 + rhs2_def_stmt_lhs = gimple_get_lhs(rhs2_def_stmt);
102197 + rhs1_def_stmt_rhs1_mode = TYPE_MODE(TREE_TYPE(rhs1_def_stmt_rhs1));
102198 + rhs2_def_stmt_rhs1_mode = TYPE_MODE(TREE_TYPE(rhs2_def_stmt_rhs1));
102199 + rhs1_def_stmt_lhs_mode = TYPE_MODE(TREE_TYPE(rhs1_def_stmt_lhs));
102200 + rhs2_def_stmt_lhs_mode = TYPE_MODE(TREE_TYPE(rhs2_def_stmt_lhs));
102201 + if (GET_MODE_BITSIZE(rhs1_def_stmt_rhs1_mode) <= GET_MODE_BITSIZE(rhs1_def_stmt_lhs_mode))
102202 + return false;
102203 + if (GET_MODE_BITSIZE(rhs2_def_stmt_rhs1_mode) <= GET_MODE_BITSIZE(rhs2_def_stmt_lhs_mode))
102204 + return false;
102205 +
102206 + gimple_set_plf(rhs1_def_stmt, NO_CAST_CHECK, true);
102207 + gimple_set_plf(rhs2_def_stmt, NO_CAST_CHECK, true);
102208 + return true;
102209 +}
102210 +
102211 +static tree handle_integer_truncation(struct pointer_set_t *visited, const_tree lhs)
102212 +{
102213 + tree new_rhs1, new_rhs2;
102214 + tree new_rhs1_def_stmt_rhs1, new_rhs2_def_stmt_rhs1, new_lhs;
102215 + gimple assign, stmt = get_def_stmt(lhs);
102216 + tree rhs1 = gimple_assign_rhs1(stmt);
102217 + tree rhs2 = gimple_assign_rhs2(stmt);
102218 +
102219 + if (!is_subtraction_special(stmt))
102220 + return NULL_TREE;
102221 +
102222 + new_rhs1 = expand(visited, rhs1);
102223 + new_rhs2 = expand(visited, rhs2);
102224 +
102225 + new_rhs1_def_stmt_rhs1 = get_def_stmt_rhs(new_rhs1);
102226 + new_rhs2_def_stmt_rhs1 = get_def_stmt_rhs(new_rhs2);
102227 +
102228 + if (!types_compatible_p(TREE_TYPE(new_rhs1_def_stmt_rhs1), TREE_TYPE(new_rhs2_def_stmt_rhs1))) {
102229 + new_rhs1_def_stmt_rhs1 = cast_to_TI_type(stmt, new_rhs1_def_stmt_rhs1);
102230 + new_rhs2_def_stmt_rhs1 = cast_to_TI_type(stmt, new_rhs2_def_stmt_rhs1);
102231 + }
102232 +
102233 + assign = create_binary_assign(MINUS_EXPR, stmt, new_rhs1_def_stmt_rhs1, new_rhs2_def_stmt_rhs1);
102234 + new_lhs = gimple_get_lhs(assign);
102235 + check_size_overflow(assign, TREE_TYPE(new_lhs), new_lhs, rhs1, AFTER_STMT);
102236 +
102237 + return dup_assign(visited, stmt, lhs, new_rhs1, new_rhs2, NULL_TREE);
102238 +}
102239 +
102240 +static bool is_a_neg_overflow(const_gimple stmt, const_tree rhs)
102241 +{
102242 + const_gimple def_stmt;
102243 +
102244 + if (TREE_CODE(rhs) != SSA_NAME)
102245 + return false;
102246 +
102247 + if (gimple_assign_rhs_code(stmt) != PLUS_EXPR)
102248 + return false;
102249 +
102250 + def_stmt = get_def_stmt(rhs);
102251 + if (gimple_code(def_stmt) != GIMPLE_ASSIGN || gimple_assign_rhs_code(def_stmt) != BIT_NOT_EXPR)
102252 + return false;
102253 +
102254 + return true;
102255 +}
102256 +
102257 +static tree handle_binary_ops(struct pointer_set_t *visited, tree lhs)
102258 +{
102259 + tree rhs1, rhs2, new_lhs;
102260 + gimple def_stmt = get_def_stmt(lhs);
102261 + tree new_rhs1 = NULL_TREE;
102262 + tree new_rhs2 = NULL_TREE;
102263 +
102264 + rhs1 = gimple_assign_rhs1(def_stmt);
102265 + rhs2 = gimple_assign_rhs2(def_stmt);
102266 +
102267 + /* no DImode/TImode division in the 32/64 bit kernel */
102268 + switch (gimple_assign_rhs_code(def_stmt)) {
102269 + case RDIV_EXPR:
102270 + case TRUNC_DIV_EXPR:
102271 + case CEIL_DIV_EXPR:
102272 + case FLOOR_DIV_EXPR:
102273 + case ROUND_DIV_EXPR:
102274 + case TRUNC_MOD_EXPR:
102275 + case CEIL_MOD_EXPR:
102276 + case FLOOR_MOD_EXPR:
102277 + case ROUND_MOD_EXPR:
102278 + case EXACT_DIV_EXPR:
102279 + case POINTER_PLUS_EXPR:
102280 + case BIT_AND_EXPR:
102281 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
102282 + default:
102283 + break;
102284 + }
102285 +
102286 + new_lhs = handle_integer_truncation(visited, lhs);
102287 + if (new_lhs != NULL_TREE)
102288 + return new_lhs;
102289 +
102290 + if (TREE_CODE(rhs1) == SSA_NAME)
102291 + new_rhs1 = expand(visited, rhs1);
102292 + if (TREE_CODE(rhs2) == SSA_NAME)
102293 + new_rhs2 = expand(visited, rhs2);
102294 +
102295 + if (is_a_neg_overflow(def_stmt, rhs2))
102296 + return handle_intentional_overflow(visited, true, def_stmt, new_rhs1, NULL_TREE);
102297 + if (is_a_neg_overflow(def_stmt, rhs1))
102298 + return handle_intentional_overflow(visited, true, def_stmt, new_rhs2, new_rhs2);
102299 +
102300 +
102301 + if (is_a_constant_overflow(def_stmt, rhs2))
102302 + return handle_intentional_overflow(visited, !is_a_cast_and_const_overflow(rhs1), def_stmt, new_rhs1, NULL_TREE);
102303 + if (is_a_constant_overflow(def_stmt, rhs1))
102304 + return handle_intentional_overflow(visited, !is_a_cast_and_const_overflow(rhs2), def_stmt, new_rhs2, new_rhs2);
102305 +
102306 + return dup_assign(visited, def_stmt, lhs, new_rhs1, new_rhs2, NULL_TREE);
102307 +}
102308 +
102309 +#if BUILDING_GCC_VERSION >= 4007
102310 +static tree get_new_rhs(struct pointer_set_t *visited, tree size_overflow_type, tree rhs)
102311 +{
102312 + if (is_gimple_constant(rhs))
102313 + return cast_a_tree(size_overflow_type, rhs);
102314 + if (TREE_CODE(rhs) != SSA_NAME)
102315 + return NULL_TREE;
102316 + return expand(visited, rhs);
102317 +}
102318 +
102319 +static tree handle_ternary_ops(struct pointer_set_t *visited, tree lhs)
102320 +{
102321 + tree rhs1, rhs2, rhs3, new_rhs1, new_rhs2, new_rhs3, size_overflow_type;
102322 + gimple def_stmt = get_def_stmt(lhs);
102323 +
102324 + size_overflow_type = get_size_overflow_type(def_stmt, lhs);
102325 +
102326 + rhs1 = gimple_assign_rhs1(def_stmt);
102327 + rhs2 = gimple_assign_rhs2(def_stmt);
102328 + rhs3 = gimple_assign_rhs3(def_stmt);
102329 + new_rhs1 = get_new_rhs(visited, size_overflow_type, rhs1);
102330 + new_rhs2 = get_new_rhs(visited, size_overflow_type, rhs2);
102331 + new_rhs3 = get_new_rhs(visited, size_overflow_type, rhs3);
102332 +
102333 + return dup_assign(visited, def_stmt, lhs, new_rhs1, new_rhs2, new_rhs3);
102334 +}
102335 +#endif
102336 +
102337 +static tree get_size_overflow_type(gimple stmt, const_tree node)
102338 +{
102339 + const_tree type;
102340 + tree new_type;
102341 +
102342 + gcc_assert(node != NULL_TREE);
102343 +
102344 + type = TREE_TYPE(node);
102345 +
102346 + if (gimple_plf(stmt, MY_STMT))
102347 + return TREE_TYPE(node);
102348 +
102349 + switch (TYPE_MODE(type)) {
102350 + case QImode:
102351 + new_type = intHI_type_node;
102352 + break;
102353 + case HImode:
102354 + new_type = intSI_type_node;
102355 + break;
102356 + case SImode:
102357 + new_type = intDI_type_node;
102358 + break;
102359 + case DImode:
102360 + if (LONG_TYPE_SIZE == GET_MODE_BITSIZE(SImode))
102361 + new_type = intDI_type_node;
102362 + else
102363 + new_type = intTI_type_node;
102364 + break;
102365 + default:
102366 + debug_tree((tree)node);
102367 + error("%s: unsupported gcc configuration.", __func__);
102368 + gcc_unreachable();
102369 + }
102370 +
102371 + if (TYPE_QUALS(type) != 0)
102372 + return build_qualified_type(new_type, TYPE_QUALS(type));
102373 + return new_type;
102374 +}
102375 +
102376 +static tree expand_visited(gimple def_stmt)
102377 +{
102378 + const_gimple next_stmt;
102379 + gimple_stmt_iterator gsi;
102380 + enum gimple_code code = gimple_code(def_stmt);
102381 +
102382 + if (code == GIMPLE_ASM)
102383 + return NULL_TREE;
102384 +
102385 + gsi = gsi_for_stmt(def_stmt);
102386 + gsi_next(&gsi);
102387 +
102388 + if (gimple_code(def_stmt) == GIMPLE_PHI && gsi_end_p(gsi))
102389 + return NULL_TREE;
102390 + gcc_assert(!gsi_end_p(gsi));
102391 + next_stmt = gsi_stmt(gsi);
102392 +
102393 + if (gimple_code(def_stmt) == GIMPLE_PHI && !gimple_plf((gimple)next_stmt, MY_STMT))
102394 + return NULL_TREE;
102395 + gcc_assert(gimple_plf((gimple)next_stmt, MY_STMT));
102396 +
102397 + return get_lhs(next_stmt);
102398 +}
102399 +
102400 +static tree expand(struct pointer_set_t *visited, tree lhs)
102401 +{
102402 + gimple def_stmt;
102403 +
102404 + if (skip_types(lhs))
102405 + return NULL_TREE;
102406 +
102407 + def_stmt = get_def_stmt(lhs);
102408 +
102409 + if (!def_stmt || gimple_code(def_stmt) == GIMPLE_NOP)
102410 + return NULL_TREE;
102411 +
102412 + if (gimple_plf(def_stmt, MY_STMT))
102413 + return lhs;
102414 +
102415 + if (pointer_set_contains(visited, def_stmt))
102416 + return expand_visited(def_stmt);
102417 +
102418 + switch (gimple_code(def_stmt)) {
102419 + case GIMPLE_PHI:
102420 + return handle_phi(visited, lhs);
102421 + case GIMPLE_CALL:
102422 + case GIMPLE_ASM:
102423 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
102424 + case GIMPLE_ASSIGN:
102425 + switch (gimple_num_ops(def_stmt)) {
102426 + case 2:
102427 + return handle_unary_ops(visited, def_stmt);
102428 + case 3:
102429 + return handle_binary_ops(visited, lhs);
102430 +#if BUILDING_GCC_VERSION >= 4007
102431 + case 4:
102432 + return handle_ternary_ops(visited, lhs);
102433 +#endif
102434 + }
102435 + default:
102436 + debug_gimple_stmt(def_stmt);
102437 + error("%s: unknown gimple code", __func__);
102438 + gcc_unreachable();
102439 + }
102440 +}
102441 +
102442 +static tree get_new_tree(gimple stmt, const_tree orig_node, tree new_node)
102443 +{
102444 + const_gimple assign;
102445 + tree orig_type = TREE_TYPE(orig_node);
102446 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
102447 +
102448 + assign = build_cast_stmt(orig_type, new_node, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
102449 + return gimple_get_lhs(assign);
102450 +}
102451 +
102452 +static void change_function_arg(gimple stmt, const_tree orig_arg, unsigned int argnum, tree new_arg)
102453 +{
102454 + gimple_call_set_arg(stmt, argnum, get_new_tree(stmt, orig_arg, new_arg));
102455 + update_stmt(stmt);
102456 +}
102457 +
102458 +static void change_function_return(gimple stmt, const_tree orig_ret, tree new_ret)
102459 +{
102460 + gimple_return_set_retval(stmt, get_new_tree(stmt, orig_ret, new_ret));
102461 + update_stmt(stmt);
102462 +}
102463 +
102464 +static bool get_function_arg(unsigned int* argnum, const_tree fndecl)
102465 +{
102466 + tree arg;
102467 + const_tree origarg;
102468 +
102469 + if (!DECL_ABSTRACT_ORIGIN(fndecl))
102470 + return true;
102471 +
102472 + origarg = DECL_ARGUMENTS(DECL_ABSTRACT_ORIGIN(fndecl));
102473 + while (origarg && *argnum) {
102474 + (*argnum)--;
102475 + origarg = TREE_CHAIN(origarg);
102476 + }
102477 +
102478 + gcc_assert(*argnum == 0);
102479 +
102480 + gcc_assert(origarg != NULL_TREE);
102481 + *argnum = 0;
102482 + for (arg = DECL_ARGUMENTS(fndecl); arg; arg = TREE_CHAIN(arg), (*argnum)++)
102483 + if (operand_equal_p(origarg, arg, 0) || !strcmp(NAME(origarg), NAME(arg)))
102484 + return true;
102485 + return false;
102486 +}
102487 +
102488 +static enum mark walk_phi(struct pointer_set_t *visited, bool *search_err_code, const_tree result)
102489 +{
102490 + gimple phi = get_def_stmt(result);
102491 + unsigned int i, n = gimple_phi_num_args(phi);
102492 +
102493 + if (!phi)
102494 + return MARK_NO;
102495 +
102496 + pointer_set_insert(visited, phi);
102497 + for (i = 0; i < n; i++) {
102498 + enum mark marked;
102499 + const_tree arg = gimple_phi_arg_def(phi, i);
102500 + marked = pre_expand(visited, search_err_code, arg);
102501 + if (marked != MARK_NO)
102502 + return marked;
102503 + }
102504 + return MARK_NO;
102505 +}
102506 +
102507 +static enum mark walk_unary_ops(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
102508 +{
102509 + gimple def_stmt = get_def_stmt(lhs);
102510 + const_tree rhs;
102511 +
102512 + if (!def_stmt)
102513 + return MARK_NO;
102514 +
102515 + rhs = gimple_assign_rhs1(def_stmt);
102516 +
102517 + def_stmt = get_def_stmt(rhs);
102518 + if (is_gimple_constant(rhs))
102519 + search_err_code[FROM_CONST] = true;
102520 +
102521 + return pre_expand(visited, search_err_code, rhs);
102522 +}
102523 +
102524 +static enum mark walk_binary_ops(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
102525 +{
102526 + gimple def_stmt = get_def_stmt(lhs);
102527 + const_tree rhs1, rhs2;
102528 + enum mark marked;
102529 +
102530 + if (!def_stmt)
102531 + return MARK_NO;
102532 +
102533 + search_err_code[CAST_ONLY] = false;
102534 +
102535 + rhs1 = gimple_assign_rhs1(def_stmt);
102536 + rhs2 = gimple_assign_rhs2(def_stmt);
102537 + marked = pre_expand(visited, search_err_code, rhs1);
102538 + if (marked != MARK_NO)
102539 + return marked;
102540 + return pre_expand(visited, search_err_code, rhs2);
102541 +}
102542 +
102543 +static const_tree search_field_decl(const_tree comp_ref)
102544 +{
102545 + const_tree field = NULL_TREE;
102546 + unsigned int i, len = TREE_OPERAND_LENGTH(comp_ref);
102547 +
102548 + for (i = 0; i < len; i++) {
102549 + field = TREE_OPERAND(comp_ref, i);
102550 + if (TREE_CODE(field) == FIELD_DECL)
102551 + break;
102552 + }
102553 + gcc_assert(TREE_CODE(field) == FIELD_DECL);
102554 + return field;
102555 +}
102556 +
102557 +static enum mark mark_status(const_tree fndecl, unsigned int argnum)
102558 +{
102559 + const_tree attr, p;
102560 +
102561 + // 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);
102562 + if (fndecl == NULL_TREE)
102563 + return MARK_NO;
102564 +
102565 + attr = lookup_attribute("intentional_overflow", DECL_ATTRIBUTES(fndecl));
102566 + if (!attr || !TREE_VALUE(attr))
102567 + return MARK_NO;
102568 +
102569 + p = TREE_VALUE(attr);
102570 + if (TREE_INT_CST_HIGH(TREE_VALUE(p)) == -1)
102571 + return MARK_TURN_OFF;
102572 + if (!TREE_INT_CST_LOW(TREE_VALUE(p)))
102573 + return MARK_NOT_INTENTIONAL;
102574 + if (argnum == 0) {
102575 + gcc_assert(current_function_decl == fndecl);
102576 + return MARK_NO;
102577 + }
102578 +
102579 + do {
102580 + if (argnum == TREE_INT_CST_LOW(TREE_VALUE(p)))
102581 + return MARK_YES;
102582 + p = TREE_CHAIN(p);
102583 + } while (p);
102584 +
102585 + return MARK_NO;
102586 +}
102587 +
102588 +static void print_missing_msg(tree func, unsigned int argnum)
102589 +{
102590 + unsigned int new_hash;
102591 + size_t len;
102592 + unsigned char tree_codes[CODES_LIMIT];
102593 + location_t loc;
102594 + const char *curfunc;
102595 +
102596 + func = get_original_function_decl(func);
102597 + loc = DECL_SOURCE_LOCATION(func);
102598 + curfunc = get_asm_name(func);
102599 +
102600 + len = get_function_decl(func, tree_codes);
102601 + new_hash = get_hash_num(curfunc, (const char *) tree_codes, len, 0);
102602 + inform(loc, "Function %s is missing from the size_overflow hash table +%s+%u+%u+", curfunc, curfunc, argnum, new_hash);
102603 +}
102604 +
102605 +static unsigned int search_missing_attribute(const_tree arg)
102606 +{
102607 + unsigned int argnum;
102608 + const struct size_overflow_hash *hash;
102609 + const_tree type = TREE_TYPE(arg);
102610 + tree func = get_original_function_decl(current_function_decl);
102611 +
102612 + gcc_assert(TREE_CODE(arg) != COMPONENT_REF);
102613 +
102614 + if (TREE_CODE(type) == POINTER_TYPE)
102615 + return 0;
102616 +
102617 + argnum = find_arg_number(arg, func);
102618 + if (argnum == 0)
102619 + return 0;
102620 +
102621 + if (lookup_attribute("size_overflow", DECL_ATTRIBUTES(func)))
102622 + return argnum;
102623 +
102624 + hash = get_function_hash(func);
102625 + if (!hash || !(hash->param & (1U << argnum))) {
102626 + print_missing_msg(func, argnum);
102627 + return 0;
102628 + }
102629 + return argnum;
102630 +}
102631 +
102632 +static enum mark is_already_marked(const_tree lhs)
102633 +{
102634 + unsigned int argnum;
102635 + const_tree fndecl;
102636 +
102637 + argnum = search_missing_attribute(lhs);
102638 + fndecl = get_original_function_decl(current_function_decl);
102639 + if (argnum && mark_status(fndecl, argnum) == MARK_YES)
102640 + return MARK_YES;
102641 + return MARK_NO;
102642 +}
102643 +
102644 +static enum mark pre_expand(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
102645 +{
102646 + const_gimple def_stmt;
102647 +
102648 + if (skip_types(lhs))
102649 + return MARK_NO;
102650 +
102651 + if (TREE_CODE(lhs) == PARM_DECL)
102652 + return is_already_marked(lhs);
102653 +
102654 + if (TREE_CODE(lhs) == COMPONENT_REF) {
102655 + const_tree field, attr;
102656 +
102657 + field = search_field_decl(lhs);
102658 + attr = lookup_attribute("intentional_overflow", DECL_ATTRIBUTES(field));
102659 + if (!attr || !TREE_VALUE(attr))
102660 + return MARK_NO;
102661 + return MARK_YES;
102662 + }
102663 +
102664 + def_stmt = get_def_stmt(lhs);
102665 +
102666 + if (!def_stmt)
102667 + return MARK_NO;
102668 +
102669 + if (pointer_set_contains(visited, def_stmt))
102670 + return MARK_NO;
102671 +
102672 + switch (gimple_code(def_stmt)) {
102673 + case GIMPLE_NOP:
102674 + if (TREE_CODE(SSA_NAME_VAR(lhs)) == PARM_DECL)
102675 + return is_already_marked(lhs);
102676 + return MARK_NO;
102677 + case GIMPLE_PHI:
102678 + return walk_phi(visited, search_err_code, lhs);
102679 + case GIMPLE_CALL:
102680 + if (mark_status((gimple_call_fndecl(def_stmt)), 0) == MARK_TURN_OFF)
102681 + return MARK_TURN_OFF;
102682 + check_function_hash(def_stmt);
102683 + return MARK_NO;
102684 + case GIMPLE_ASM:
102685 + search_err_code[CAST_ONLY] = false;
102686 + return MARK_NO;
102687 + case GIMPLE_ASSIGN:
102688 + switch (gimple_num_ops(def_stmt)) {
102689 + case 2:
102690 + return walk_unary_ops(visited, search_err_code, lhs);
102691 + case 3:
102692 + return walk_binary_ops(visited, search_err_code, lhs);
102693 + }
102694 + default:
102695 + debug_gimple_stmt((gimple)def_stmt);
102696 + error("%s: unknown gimple code", __func__);
102697 + gcc_unreachable();
102698 + }
102699 +}
102700 +
102701 +// e.g., 3.8.2, 64, arch/x86/ia32/ia32_signal.c copy_siginfo_from_user32(): compat_ptr() u32 max
102702 +static bool skip_asm(const_tree arg)
102703 +{
102704 + gimple def_stmt = get_def_stmt(arg);
102705 +
102706 + if (!def_stmt || !gimple_assign_cast_p(def_stmt))
102707 + return false;
102708 +
102709 + def_stmt = get_def_stmt(gimple_assign_rhs1(def_stmt));
102710 + return def_stmt && gimple_code(def_stmt) == GIMPLE_ASM;
102711 +}
102712 +
102713 +/*
102714 +0</MARK_YES: no dup, search attributes (so, int)
102715 +0/MARK_NOT_INTENTIONAL: no dup, search attribute (int)
102716 +-1/MARK_TURN_OFF: no dup, no search, current_function_decl -> no dup
102717 +*/
102718 +
102719 +static bool search_attributes(tree fndecl, const_tree arg, unsigned int argnum, bool where)
102720 +{
102721 + struct pointer_set_t *visited;
102722 + enum mark is_marked, is_found;
102723 + location_t loc;
102724 + bool search_err_code[2] = {true, false};
102725 +
102726 + is_marked = mark_status(current_function_decl, 0);
102727 + if (is_marked == MARK_TURN_OFF)
102728 + return true;
102729 +
102730 + is_marked = mark_status(fndecl, argnum + 1);
102731 + if (is_marked == MARK_TURN_OFF || is_marked == MARK_NOT_INTENTIONAL)
102732 + return true;
102733 +
102734 + visited = pointer_set_create();
102735 + is_found = pre_expand(visited, search_err_code, arg);
102736 + pointer_set_destroy(visited);
102737 +
102738 + if (where == FROM_RET && search_err_code[CAST_ONLY] && search_err_code[FROM_CONST])
102739 + return true;
102740 +
102741 + if (where == FROM_ARG && skip_asm(arg))
102742 + return true;
102743 +
102744 + if (is_found == MARK_TURN_OFF)
102745 + return true;
102746 +
102747 + if ((is_found == MARK_YES && is_marked == MARK_YES))
102748 + return true;
102749 +
102750 + if (is_found == MARK_YES) {
102751 + loc = DECL_SOURCE_LOCATION(fndecl);
102752 + inform(loc, "The intentional_overflow attribute is missing from +%s+%u+", get_asm_name(fndecl), argnum + 1);
102753 + return true;
102754 + }
102755 + return false;
102756 +}
102757 +
102758 +static void handle_function_arg(gimple stmt, tree fndecl, unsigned int argnum)
102759 +{
102760 + struct pointer_set_t *visited;
102761 + tree arg, new_arg;
102762 + bool match;
102763 +
102764 + if (argnum == 0)
102765 + return;
102766 +
102767 + argnum--;
102768 +
102769 + match = get_function_arg(&argnum, fndecl);
102770 + if (!match)
102771 + return;
102772 + gcc_assert(gimple_call_num_args(stmt) > argnum);
102773 + arg = gimple_call_arg(stmt, argnum);
102774 + if (arg == NULL_TREE)
102775 + return;
102776 +
102777 + if (skip_types(arg))
102778 + return;
102779 +
102780 + if (search_attributes(fndecl, arg, argnum, FROM_ARG))
102781 + return;
102782 +
102783 + visited = pointer_set_create();
102784 + new_arg = expand(visited, arg);
102785 + pointer_set_destroy(visited);
102786 +
102787 + if (new_arg == NULL_TREE)
102788 + return;
102789 +
102790 + change_function_arg(stmt, arg, argnum, new_arg);
102791 + check_size_overflow(stmt, TREE_TYPE(new_arg), new_arg, arg, BEFORE_STMT);
102792 +}
102793 +
102794 +static void handle_function_by_attribute(gimple stmt, const_tree attr, tree fndecl)
102795 +{
102796 + tree p = TREE_VALUE(attr);
102797 + do {
102798 + handle_function_arg(stmt, fndecl, TREE_INT_CST_LOW(TREE_VALUE(p)));
102799 + p = TREE_CHAIN(p);
102800 + } while (p);
102801 +}
102802 +
102803 +static void handle_function_by_hash(gimple stmt, tree fndecl)
102804 +{
102805 + unsigned int num;
102806 + const struct size_overflow_hash *hash;
102807 +
102808 + hash = get_function_hash(fndecl);
102809 + if (!hash)
102810 + return;
102811 +
102812 + for (num = 0; num <= MAX_PARAM; num++)
102813 + if (hash->param & (1U << num))
102814 + handle_function_arg(stmt, fndecl, num);
102815 +}
102816 +
102817 +static bool check_return_value(void)
102818 +{
102819 + const struct size_overflow_hash *hash;
102820 +
102821 + hash = get_function_hash(current_function_decl);
102822 + if (!hash || !(hash->param & 1U << 0))
102823 + return false;
102824 +
102825 + return true;
102826 +}
102827 +
102828 +static void handle_return_value(gimple ret_stmt)
102829 +{
102830 + struct pointer_set_t *visited;
102831 + tree ret, new_ret;
102832 +
102833 + if (gimple_code(ret_stmt) != GIMPLE_RETURN)
102834 + return;
102835 +
102836 + ret = gimple_return_retval(ret_stmt);
102837 +
102838 + if (skip_types(ret))
102839 + return;
102840 +
102841 + if (search_attributes(current_function_decl, ret, 0, FROM_RET))
102842 + return;
102843 +
102844 + visited = pointer_set_create();
102845 + new_ret = expand(visited, ret);
102846 + pointer_set_destroy(visited);
102847 +
102848 + change_function_return(ret_stmt, ret, new_ret);
102849 + check_size_overflow(ret_stmt, TREE_TYPE(new_ret), new_ret, ret, BEFORE_STMT);
102850 +}
102851 +
102852 +static void set_plf_false(void)
102853 +{
102854 + basic_block bb;
102855 +
102856 + FOR_ALL_BB(bb) {
102857 + gimple_stmt_iterator si;
102858 +
102859 + for (si = gsi_start_bb(bb); !gsi_end_p(si); gsi_next(&si))
102860 + gimple_set_plf(gsi_stmt(si), MY_STMT, false);
102861 + for (si = gsi_start_phis(bb); !gsi_end_p(si); gsi_next(&si))
102862 + gimple_set_plf(gsi_stmt(si), MY_STMT, false);
102863 + }
102864 +}
102865 +
102866 +static unsigned int handle_function(void)
102867 +{
102868 + basic_block next, bb = ENTRY_BLOCK_PTR->next_bb;
102869 + bool check_ret;
102870 +
102871 + set_plf_false();
102872 +
102873 + check_ret = check_return_value();
102874 +
102875 + do {
102876 + gimple_stmt_iterator gsi;
102877 + next = bb->next_bb;
102878 +
102879 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
102880 + tree fndecl, attr;
102881 + gimple stmt = gsi_stmt(gsi);
102882 +
102883 + if (check_ret)
102884 + handle_return_value(stmt);
102885 +
102886 + if (!(is_gimple_call(stmt)))
102887 + continue;
102888 + fndecl = gimple_call_fndecl(stmt);
102889 + if (fndecl == NULL_TREE)
102890 + continue;
102891 + if (gimple_call_num_args(stmt) == 0)
102892 + continue;
102893 + attr = lookup_attribute("size_overflow", DECL_ATTRIBUTES(fndecl));
102894 + if (!attr || !TREE_VALUE(attr))
102895 + handle_function_by_hash(stmt, fndecl);
102896 + else
102897 + handle_function_by_attribute(stmt, attr, fndecl);
102898 + gsi = gsi_for_stmt(stmt);
102899 + next = gimple_bb(stmt)->next_bb;
102900 + }
102901 + bb = next;
102902 + } while (bb);
102903 + return 0;
102904 +}
102905 +
102906 +static struct gimple_opt_pass size_overflow_pass = {
102907 + .pass = {
102908 + .type = GIMPLE_PASS,
102909 + .name = "size_overflow",
102910 +#if BUILDING_GCC_VERSION >= 4008
102911 + .optinfo_flags = OPTGROUP_NONE,
102912 +#endif
102913 + .gate = NULL,
102914 + .execute = handle_function,
102915 + .sub = NULL,
102916 + .next = NULL,
102917 + .static_pass_number = 0,
102918 + .tv_id = TV_NONE,
102919 + .properties_required = PROP_cfg,
102920 + .properties_provided = 0,
102921 + .properties_destroyed = 0,
102922 + .todo_flags_start = 0,
102923 + .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
102924 + }
102925 +};
102926 +
102927 +static void start_unit_callback(void __unused *gcc_data, void __unused *user_data)
102928 +{
102929 + tree fntype;
102930 +
102931 + const_char_ptr_type_node = build_pointer_type(build_type_variant(char_type_node, 1, 0));
102932 +
102933 + // void report_size_overflow(const char *loc_file, unsigned int loc_line, const char *current_func, const char *ssa_var)
102934 + fntype = build_function_type_list(void_type_node,
102935 + const_char_ptr_type_node,
102936 + unsigned_type_node,
102937 + const_char_ptr_type_node,
102938 + const_char_ptr_type_node,
102939 + NULL_TREE);
102940 + report_size_overflow_decl = build_fn_decl("report_size_overflow", fntype);
102941 +
102942 + DECL_ASSEMBLER_NAME(report_size_overflow_decl);
102943 + TREE_PUBLIC(report_size_overflow_decl) = 1;
102944 + DECL_EXTERNAL(report_size_overflow_decl) = 1;
102945 + DECL_ARTIFICIAL(report_size_overflow_decl) = 1;
102946 + TREE_THIS_VOLATILE(report_size_overflow_decl) = 1;
102947 +}
102948 +
102949 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
102950 +{
102951 + int i;
102952 + const char * const plugin_name = plugin_info->base_name;
102953 + const int argc = plugin_info->argc;
102954 + const struct plugin_argument * const argv = plugin_info->argv;
102955 + bool enable = true;
102956 +
102957 + struct register_pass_info size_overflow_pass_info = {
102958 + .pass = &size_overflow_pass.pass,
102959 + .reference_pass_name = "ssa",
102960 + .ref_pass_instance_number = 1,
102961 + .pos_op = PASS_POS_INSERT_AFTER
102962 + };
102963 +
102964 + if (!plugin_default_version_check(version, &gcc_version)) {
102965 + error(G_("incompatible gcc/plugin versions"));
102966 + return 1;
102967 + }
102968 +
102969 + for (i = 0; i < argc; ++i) {
102970 + if (!strcmp(argv[i].key, "no-size-overflow")) {
102971 + enable = false;
102972 + continue;
102973 + }
102974 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
102975 + }
102976 +
102977 + register_callback(plugin_name, PLUGIN_INFO, NULL, &size_overflow_plugin_info);
102978 + if (enable) {
102979 + register_callback("start_unit", PLUGIN_START_UNIT, &start_unit_callback, NULL);
102980 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &size_overflow_pass_info);
102981 + }
102982 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
102983 +
102984 + return 0;
102985 +}
102986 diff --git a/tools/gcc/stackleak_plugin.c b/tools/gcc/stackleak_plugin.c
102987 new file mode 100644
102988 index 0000000..ac2901e
102989 --- /dev/null
102990 +++ b/tools/gcc/stackleak_plugin.c
102991 @@ -0,0 +1,327 @@
102992 +/*
102993 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
102994 + * Licensed under the GPL v2
102995 + *
102996 + * Note: the choice of the license means that the compilation process is
102997 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
102998 + * but for the kernel it doesn't matter since it doesn't link against
102999 + * any of the gcc libraries
103000 + *
103001 + * gcc plugin to help implement various PaX features
103002 + *
103003 + * - track lowest stack pointer
103004 + *
103005 + * TODO:
103006 + * - initialize all local variables
103007 + *
103008 + * BUGS:
103009 + * - none known
103010 + */
103011 +#include "gcc-plugin.h"
103012 +#include "config.h"
103013 +#include "system.h"
103014 +#include "coretypes.h"
103015 +#include "tree.h"
103016 +#include "tree-pass.h"
103017 +#include "flags.h"
103018 +#include "intl.h"
103019 +#include "toplev.h"
103020 +#include "plugin.h"
103021 +//#include "expr.h" where are you...
103022 +#include "diagnostic.h"
103023 +#include "plugin-version.h"
103024 +#include "tm.h"
103025 +#include "function.h"
103026 +#include "basic-block.h"
103027 +#include "gimple.h"
103028 +#include "rtl.h"
103029 +#include "emit-rtl.h"
103030 +
103031 +#if BUILDING_GCC_VERSION >= 4008
103032 +#define TODO_dump_func 0
103033 +#endif
103034 +
103035 +extern void print_gimple_stmt(FILE *, gimple, int, int);
103036 +
103037 +int plugin_is_GPL_compatible;
103038 +
103039 +static int track_frame_size = -1;
103040 +static const char track_function[] = "pax_track_stack";
103041 +static const char check_function[] = "pax_check_alloca";
103042 +static bool init_locals;
103043 +
103044 +static struct plugin_info stackleak_plugin_info = {
103045 + .version = "201302112000",
103046 + .help = "track-lowest-sp=nn\ttrack sp in functions whose frame size is at least nn bytes\n"
103047 +// "initialize-locals\t\tforcibly initialize all stack frames\n"
103048 +};
103049 +
103050 +static bool gate_stackleak_track_stack(void);
103051 +static unsigned int execute_stackleak_tree_instrument(void);
103052 +static unsigned int execute_stackleak_final(void);
103053 +
103054 +static struct gimple_opt_pass stackleak_tree_instrument_pass = {
103055 + .pass = {
103056 + .type = GIMPLE_PASS,
103057 + .name = "stackleak_tree_instrument",
103058 +#if BUILDING_GCC_VERSION >= 4008
103059 + .optinfo_flags = OPTGROUP_NONE,
103060 +#endif
103061 + .gate = gate_stackleak_track_stack,
103062 + .execute = execute_stackleak_tree_instrument,
103063 + .sub = NULL,
103064 + .next = NULL,
103065 + .static_pass_number = 0,
103066 + .tv_id = TV_NONE,
103067 + .properties_required = PROP_gimple_leh | PROP_cfg,
103068 + .properties_provided = 0,
103069 + .properties_destroyed = 0,
103070 + .todo_flags_start = 0, //TODO_verify_ssa | TODO_verify_flow | TODO_verify_stmts,
103071 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_update_ssa
103072 + }
103073 +};
103074 +
103075 +static struct rtl_opt_pass stackleak_final_rtl_opt_pass = {
103076 + .pass = {
103077 + .type = RTL_PASS,
103078 + .name = "stackleak_final",
103079 +#if BUILDING_GCC_VERSION >= 4008
103080 + .optinfo_flags = OPTGROUP_NONE,
103081 +#endif
103082 + .gate = gate_stackleak_track_stack,
103083 + .execute = execute_stackleak_final,
103084 + .sub = NULL,
103085 + .next = NULL,
103086 + .static_pass_number = 0,
103087 + .tv_id = TV_NONE,
103088 + .properties_required = 0,
103089 + .properties_provided = 0,
103090 + .properties_destroyed = 0,
103091 + .todo_flags_start = 0,
103092 + .todo_flags_finish = TODO_dump_func
103093 + }
103094 +};
103095 +
103096 +static bool gate_stackleak_track_stack(void)
103097 +{
103098 + return track_frame_size >= 0;
103099 +}
103100 +
103101 +static void stackleak_check_alloca(gimple_stmt_iterator *gsi)
103102 +{
103103 + gimple check_alloca;
103104 + tree fntype, fndecl, alloca_size;
103105 +
103106 + fntype = build_function_type_list(void_type_node, long_unsigned_type_node, NULL_TREE);
103107 + fndecl = build_fn_decl(check_function, fntype);
103108 + DECL_ASSEMBLER_NAME(fndecl); // for LTO
103109 +
103110 + // insert call to void pax_check_alloca(unsigned long size)
103111 + alloca_size = gimple_call_arg(gsi_stmt(*gsi), 0);
103112 + check_alloca = gimple_build_call(fndecl, 1, alloca_size);
103113 + gsi_insert_before(gsi, check_alloca, GSI_SAME_STMT);
103114 +}
103115 +
103116 +static void stackleak_add_instrumentation(gimple_stmt_iterator *gsi)
103117 +{
103118 + gimple track_stack;
103119 + tree fntype, fndecl;
103120 +
103121 + fntype = build_function_type_list(void_type_node, NULL_TREE);
103122 + fndecl = build_fn_decl(track_function, fntype);
103123 + DECL_ASSEMBLER_NAME(fndecl); // for LTO
103124 +
103125 + // insert call to void pax_track_stack(void)
103126 + track_stack = gimple_build_call(fndecl, 0);
103127 + gsi_insert_after(gsi, track_stack, GSI_CONTINUE_LINKING);
103128 +}
103129 +
103130 +#if BUILDING_GCC_VERSION == 4005
103131 +static bool gimple_call_builtin_p(gimple stmt, enum built_in_function code)
103132 +{
103133 + tree fndecl;
103134 +
103135 + if (!is_gimple_call(stmt))
103136 + return false;
103137 + fndecl = gimple_call_fndecl(stmt);
103138 + if (!fndecl)
103139 + return false;
103140 + if (DECL_BUILT_IN_CLASS(fndecl) != BUILT_IN_NORMAL)
103141 + return false;
103142 +// print_node(stderr, "pax", fndecl, 4);
103143 + return DECL_FUNCTION_CODE(fndecl) == code;
103144 +}
103145 +#endif
103146 +
103147 +static bool is_alloca(gimple stmt)
103148 +{
103149 + if (gimple_call_builtin_p(stmt, BUILT_IN_ALLOCA))
103150 + return true;
103151 +
103152 +#if BUILDING_GCC_VERSION >= 4007
103153 + if (gimple_call_builtin_p(stmt, BUILT_IN_ALLOCA_WITH_ALIGN))
103154 + return true;
103155 +#endif
103156 +
103157 + return false;
103158 +}
103159 +
103160 +static unsigned int execute_stackleak_tree_instrument(void)
103161 +{
103162 + basic_block bb, entry_bb;
103163 + bool prologue_instrumented = false, is_leaf = true;
103164 +
103165 + entry_bb = ENTRY_BLOCK_PTR_FOR_FUNCTION(cfun)->next_bb;
103166 +
103167 + // 1. loop through BBs and GIMPLE statements
103168 + FOR_EACH_BB(bb) {
103169 + gimple_stmt_iterator gsi;
103170 +
103171 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
103172 + gimple stmt;
103173 +
103174 + stmt = gsi_stmt(gsi);
103175 +
103176 + if (is_gimple_call(stmt))
103177 + is_leaf = false;
103178 +
103179 + // gimple match: align 8 built-in BUILT_IN_NORMAL:BUILT_IN_ALLOCA attributes <tree_list 0xb7576450>
103180 + if (!is_alloca(stmt))
103181 + continue;
103182 +
103183 + // 2. insert stack overflow check before each __builtin_alloca call
103184 + stackleak_check_alloca(&gsi);
103185 +
103186 + // 3. insert track call after each __builtin_alloca call
103187 + stackleak_add_instrumentation(&gsi);
103188 + if (bb == entry_bb)
103189 + prologue_instrumented = true;
103190 + }
103191 + }
103192 +
103193 + // special cases for some bad linux code: taking the address of static inline functions will materialize them
103194 + // but we mustn't instrument some of them as the resulting stack alignment required by the function call ABI
103195 + // will break other assumptions regarding the expected (but not otherwise enforced) register clobbering ABI.
103196 + // case in point: native_save_fl on amd64 when optimized for size clobbers rdx if it were instrumented here.
103197 + if (is_leaf && !TREE_PUBLIC(current_function_decl) && DECL_DECLARED_INLINE_P(current_function_decl))
103198 + return 0;
103199 + if (is_leaf && !strncmp(IDENTIFIER_POINTER(DECL_NAME(current_function_decl)), "_paravirt_", 10))
103200 + return 0;
103201 +
103202 + // 4. insert track call at the beginning
103203 + if (!prologue_instrumented) {
103204 + gimple_stmt_iterator gsi;
103205 +
103206 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
103207 + if (dom_info_available_p(CDI_DOMINATORS))
103208 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
103209 + gsi = gsi_start_bb(bb);
103210 + stackleak_add_instrumentation(&gsi);
103211 + }
103212 +
103213 + return 0;
103214 +}
103215 +
103216 +static unsigned int execute_stackleak_final(void)
103217 +{
103218 + rtx insn, next;
103219 +
103220 + if (cfun->calls_alloca)
103221 + return 0;
103222 +
103223 + // keep calls only if function frame is big enough
103224 + if (get_frame_size() >= track_frame_size)
103225 + return 0;
103226 +
103227 + // 1. find pax_track_stack calls
103228 + for (insn = get_insns(); insn; insn = next) {
103229 + // 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))
103230 + rtx body;
103231 +
103232 + next = NEXT_INSN(insn);
103233 + if (!CALL_P(insn))
103234 + continue;
103235 + body = PATTERN(insn);
103236 + if (GET_CODE(body) != CALL)
103237 + continue;
103238 + body = XEXP(body, 0);
103239 + if (GET_CODE(body) != MEM)
103240 + continue;
103241 + body = XEXP(body, 0);
103242 + if (GET_CODE(body) != SYMBOL_REF)
103243 + continue;
103244 + if (strcmp(XSTR(body, 0), track_function))
103245 + continue;
103246 +// warning(0, "track_frame_size: %d %ld %d", cfun->calls_alloca, get_frame_size(), track_frame_size);
103247 + // 2. delete call
103248 + delete_insn_and_edges(insn);
103249 +#if BUILDING_GCC_VERSION >= 4007
103250 + if (GET_CODE(next) == NOTE && NOTE_KIND(next) == NOTE_INSN_CALL_ARG_LOCATION) {
103251 + insn = next;
103252 + next = NEXT_INSN(insn);
103253 + delete_insn_and_edges(insn);
103254 + }
103255 +#endif
103256 + }
103257 +
103258 +// print_simple_rtl(stderr, get_insns());
103259 +// print_rtl(stderr, get_insns());
103260 +// warning(0, "track_frame_size: %d %ld %d", cfun->calls_alloca, get_frame_size(), track_frame_size);
103261 +
103262 + return 0;
103263 +}
103264 +
103265 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
103266 +{
103267 + const char * const plugin_name = plugin_info->base_name;
103268 + const int argc = plugin_info->argc;
103269 + const struct plugin_argument * const argv = plugin_info->argv;
103270 + int i;
103271 + struct register_pass_info stackleak_tree_instrument_pass_info = {
103272 + .pass = &stackleak_tree_instrument_pass.pass,
103273 +// .reference_pass_name = "tree_profile",
103274 + .reference_pass_name = "optimized",
103275 + .ref_pass_instance_number = 1,
103276 + .pos_op = PASS_POS_INSERT_BEFORE
103277 + };
103278 + struct register_pass_info stackleak_final_pass_info = {
103279 + .pass = &stackleak_final_rtl_opt_pass.pass,
103280 + .reference_pass_name = "final",
103281 + .ref_pass_instance_number = 1,
103282 + .pos_op = PASS_POS_INSERT_BEFORE
103283 + };
103284 +
103285 + if (!plugin_default_version_check(version, &gcc_version)) {
103286 + error(G_("incompatible gcc/plugin versions"));
103287 + return 1;
103288 + }
103289 +
103290 + register_callback(plugin_name, PLUGIN_INFO, NULL, &stackleak_plugin_info);
103291 +
103292 + for (i = 0; i < argc; ++i) {
103293 + if (!strcmp(argv[i].key, "track-lowest-sp")) {
103294 + if (!argv[i].value) {
103295 + error(G_("no value supplied for option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
103296 + continue;
103297 + }
103298 + track_frame_size = atoi(argv[i].value);
103299 + if (argv[i].value[0] < '0' || argv[i].value[0] > '9' || track_frame_size < 0)
103300 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
103301 + continue;
103302 + }
103303 + if (!strcmp(argv[i].key, "initialize-locals")) {
103304 + if (argv[i].value) {
103305 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
103306 + continue;
103307 + }
103308 + init_locals = true;
103309 + continue;
103310 + }
103311 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
103312 + }
103313 +
103314 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &stackleak_tree_instrument_pass_info);
103315 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &stackleak_final_pass_info);
103316 +
103317 + return 0;
103318 +}
103319 diff --git a/tools/gcc/structleak_plugin.c b/tools/gcc/structleak_plugin.c
103320 new file mode 100644
103321 index 0000000..4fae911
103322 --- /dev/null
103323 +++ b/tools/gcc/structleak_plugin.c
103324 @@ -0,0 +1,277 @@
103325 +/*
103326 + * Copyright 2013 by PaX Team <pageexec@freemail.hu>
103327 + * Licensed under the GPL v2
103328 + *
103329 + * Note: the choice of the license means that the compilation process is
103330 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
103331 + * but for the kernel it doesn't matter since it doesn't link against
103332 + * any of the gcc libraries
103333 + *
103334 + * gcc plugin to forcibly initialize certain local variables that could
103335 + * otherwise leak kernel stack to userland if they aren't properly initialized
103336 + * by later code
103337 + *
103338 + * Homepage: http://pax.grsecurity.net/
103339 + *
103340 + * Usage:
103341 + * $ # for 4.5/4.6/C based 4.7
103342 + * $ 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
103343 + * $ # for C++ based 4.7/4.8+
103344 + * $ 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
103345 + * $ gcc -fplugin=./structleak_plugin.so test.c -O2
103346 + *
103347 + * TODO: eliminate redundant initializers
103348 + * increase type coverage
103349 + */
103350 +
103351 +#include "gcc-plugin.h"
103352 +#include "config.h"
103353 +#include "system.h"
103354 +#include "coretypes.h"
103355 +#include "tree.h"
103356 +#include "tree-pass.h"
103357 +#include "intl.h"
103358 +#include "plugin-version.h"
103359 +#include "tm.h"
103360 +#include "toplev.h"
103361 +#include "function.h"
103362 +#include "tree-flow.h"
103363 +#include "plugin.h"
103364 +#include "gimple.h"
103365 +#include "diagnostic.h"
103366 +#include "cfgloop.h"
103367 +#include "langhooks.h"
103368 +
103369 +#if BUILDING_GCC_VERSION >= 4008
103370 +#define TODO_dump_func 0
103371 +#endif
103372 +
103373 +#define NAME(node) IDENTIFIER_POINTER(DECL_NAME(node))
103374 +
103375 +// unused type flag in all versions 4.5-4.8
103376 +#define TYPE_USERSPACE(TYPE) TYPE_LANG_FLAG_3(TYPE)
103377 +
103378 +int plugin_is_GPL_compatible;
103379 +void debug_gimple_stmt(gimple gs);
103380 +
103381 +static struct plugin_info structleak_plugin_info = {
103382 + .version = "201304082245",
103383 + .help = "disable\tdo not activate plugin\n",
103384 +};
103385 +
103386 +static tree handle_user_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
103387 +{
103388 + *no_add_attrs = true;
103389 +
103390 + // check for types? for now accept everything linux has to offer
103391 + if (TREE_CODE(*node) != FIELD_DECL)
103392 + return NULL_TREE;
103393 +
103394 + *no_add_attrs = false;
103395 + return NULL_TREE;
103396 +}
103397 +
103398 +static struct attribute_spec user_attr = {
103399 + .name = "user",
103400 + .min_length = 0,
103401 + .max_length = 0,
103402 + .decl_required = false,
103403 + .type_required = false,
103404 + .function_type_required = false,
103405 + .handler = handle_user_attribute,
103406 +#if BUILDING_GCC_VERSION >= 4007
103407 + .affects_type_identity = true
103408 +#endif
103409 +};
103410 +
103411 +static void register_attributes(void *event_data, void *data)
103412 +{
103413 + register_attribute(&user_attr);
103414 +// register_attribute(&force_attr);
103415 +}
103416 +
103417 +static tree get_field_type(tree field)
103418 +{
103419 + return strip_array_types(TREE_TYPE(field));
103420 +}
103421 +
103422 +static bool is_userspace_type(tree type)
103423 +{
103424 + tree field;
103425 +
103426 + for (field = TYPE_FIELDS(type); field; field = TREE_CHAIN(field)) {
103427 + tree fieldtype = get_field_type(field);
103428 + enum tree_code code = TREE_CODE(fieldtype);
103429 +
103430 + if (code == RECORD_TYPE || code == UNION_TYPE)
103431 + if (is_userspace_type(fieldtype))
103432 + return true;
103433 +
103434 + if (lookup_attribute("user", DECL_ATTRIBUTES(field)))
103435 + return true;
103436 + }
103437 + return false;
103438 +}
103439 +
103440 +static void finish_type(void *event_data, void *data)
103441 +{
103442 + tree type = (tree)event_data;
103443 +
103444 + if (TYPE_USERSPACE(type))
103445 + return;
103446 +
103447 + if (is_userspace_type(type))
103448 + TYPE_USERSPACE(type) = 1;
103449 +}
103450 +
103451 +static void initialize(tree var)
103452 +{
103453 + basic_block bb;
103454 + gimple_stmt_iterator gsi;
103455 + tree initializer;
103456 + gimple init_stmt;
103457 +
103458 + // this is the original entry bb before the forced split
103459 + // TODO: check further BBs in case more splits occured before us
103460 + bb = ENTRY_BLOCK_PTR->next_bb->next_bb;
103461 +
103462 + // first check if the variable is already initialized, warn otherwise
103463 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
103464 + gimple stmt = gsi_stmt(gsi);
103465 + tree rhs1;
103466 +
103467 + // we're looking for an assignment of a single rhs...
103468 + if (!gimple_assign_single_p(stmt))
103469 + continue;
103470 + rhs1 = gimple_assign_rhs1(stmt);
103471 +#if BUILDING_GCC_VERSION >= 4007
103472 + // ... of a non-clobbering expression...
103473 + if (TREE_CLOBBER_P(rhs1))
103474 + continue;
103475 +#endif
103476 + // ... to our variable...
103477 + if (gimple_get_lhs(stmt) != var)
103478 + continue;
103479 + // if it's an initializer then we're good
103480 + if (TREE_CODE(rhs1) == CONSTRUCTOR)
103481 + return;
103482 + }
103483 +
103484 + // these aren't the 0days you're looking for
103485 +// inform(DECL_SOURCE_LOCATION(var), "userspace variable will be forcibly initialized");
103486 +
103487 + // build the initializer expression
103488 + initializer = build_constructor(TREE_TYPE(var), NULL);
103489 +
103490 + // build the initializer stmt
103491 + init_stmt = gimple_build_assign(var, initializer);
103492 + gsi = gsi_start_bb(ENTRY_BLOCK_PTR->next_bb);
103493 + gsi_insert_before(&gsi, init_stmt, GSI_NEW_STMT);
103494 + update_stmt(init_stmt);
103495 +}
103496 +
103497 +static unsigned int handle_function(void)
103498 +{
103499 + basic_block bb;
103500 + unsigned int ret = 0;
103501 + tree var;
103502 +
103503 +#if BUILDING_GCC_VERSION == 4005
103504 + tree vars;
103505 +#else
103506 + unsigned int i;
103507 +#endif
103508 +
103509 + // split the first bb where we can put the forced initializers
103510 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
103511 + if (dom_info_available_p(CDI_DOMINATORS))
103512 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
103513 +
103514 + // enumarate all local variables and forcibly initialize our targets
103515 +#if BUILDING_GCC_VERSION == 4005
103516 + for (vars = cfun->local_decls; vars; vars = TREE_CHAIN(vars)) {
103517 + var = TREE_VALUE(vars);
103518 +#else
103519 + FOR_EACH_LOCAL_DECL(cfun, i, var) {
103520 +#endif
103521 + tree type = TREE_TYPE(var);
103522 +
103523 + gcc_assert(DECL_P(var));
103524 + if (!auto_var_in_fn_p(var, current_function_decl))
103525 + continue;
103526 +
103527 + // only care about structure types
103528 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
103529 + continue;
103530 +
103531 + // if the type is of interest, examine the variable
103532 + if (TYPE_USERSPACE(type))
103533 + initialize(var);
103534 + }
103535 +
103536 + return ret;
103537 +}
103538 +
103539 +static struct gimple_opt_pass structleak_pass = {
103540 + .pass = {
103541 + .type = GIMPLE_PASS,
103542 + .name = "structleak",
103543 +#if BUILDING_GCC_VERSION >= 4008
103544 + .optinfo_flags = OPTGROUP_NONE,
103545 +#endif
103546 + .gate = NULL,
103547 + .execute = handle_function,
103548 + .sub = NULL,
103549 + .next = NULL,
103550 + .static_pass_number = 0,
103551 + .tv_id = TV_NONE,
103552 + .properties_required = PROP_cfg,
103553 + .properties_provided = 0,
103554 + .properties_destroyed = 0,
103555 + .todo_flags_start = 0,
103556 + .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
103557 + }
103558 +};
103559 +
103560 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
103561 +{
103562 + int i;
103563 + const char * const plugin_name = plugin_info->base_name;
103564 + const int argc = plugin_info->argc;
103565 + const struct plugin_argument * const argv = plugin_info->argv;
103566 + bool enable = true;
103567 +
103568 + struct register_pass_info structleak_pass_info = {
103569 + .pass = &structleak_pass.pass,
103570 + .reference_pass_name = "ssa",
103571 + .ref_pass_instance_number = 1,
103572 + .pos_op = PASS_POS_INSERT_AFTER
103573 + };
103574 +
103575 + if (!plugin_default_version_check(version, &gcc_version)) {
103576 + error(G_("incompatible gcc/plugin versions"));
103577 + return 1;
103578 + }
103579 +
103580 + if (strcmp(lang_hooks.name, "GNU C")) {
103581 + inform(UNKNOWN_LOCATION, G_("%s supports C only"), plugin_name);
103582 + enable = false;
103583 + }
103584 +
103585 + for (i = 0; i < argc; ++i) {
103586 + if (!strcmp(argv[i].key, "disable")) {
103587 + enable = false;
103588 + continue;
103589 + }
103590 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
103591 + }
103592 +
103593 + register_callback(plugin_name, PLUGIN_INFO, NULL, &structleak_plugin_info);
103594 + if (enable) {
103595 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &structleak_pass_info);
103596 + register_callback(plugin_name, PLUGIN_FINISH_TYPE, finish_type, NULL);
103597 + }
103598 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
103599 +
103600 + return 0;
103601 +}
103602 diff --git a/tools/perf/util/include/asm/alternative-asm.h b/tools/perf/util/include/asm/alternative-asm.h
103603 index 6789d78..4afd019e 100644
103604 --- a/tools/perf/util/include/asm/alternative-asm.h
103605 +++ b/tools/perf/util/include/asm/alternative-asm.h
103606 @@ -5,4 +5,7 @@
103607
103608 #define altinstruction_entry #
103609
103610 + .macro pax_force_retaddr rip=0, reload=0
103611 + .endm
103612 +
103613 #endif
103614 diff --git a/tools/perf/util/include/linux/compiler.h b/tools/perf/util/include/linux/compiler.h
103615 index 96b919d..c49bb74 100644
103616 --- a/tools/perf/util/include/linux/compiler.h
103617 +++ b/tools/perf/util/include/linux/compiler.h
103618 @@ -18,4 +18,12 @@
103619 #define __force
103620 #endif
103621
103622 +#ifndef __size_overflow
103623 +# define __size_overflow(...)
103624 +#endif
103625 +
103626 +#ifndef __intentional_overflow
103627 +# define __intentional_overflow(...)
103628 +#endif
103629 +
103630 #endif
103631 diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
103632 index f18013f..90421df 100644
103633 --- a/virt/kvm/kvm_main.c
103634 +++ b/virt/kvm/kvm_main.c
103635 @@ -75,12 +75,17 @@ LIST_HEAD(vm_list);
103636
103637 static cpumask_var_t cpus_hardware_enabled;
103638 static int kvm_usage_count = 0;
103639 -static atomic_t hardware_enable_failed;
103640 +static atomic_unchecked_t hardware_enable_failed;
103641
103642 struct kmem_cache *kvm_vcpu_cache;
103643 EXPORT_SYMBOL_GPL(kvm_vcpu_cache);
103644
103645 -static __read_mostly struct preempt_ops kvm_preempt_ops;
103646 +static void kvm_sched_in(struct preempt_notifier *pn, int cpu);
103647 +static void kvm_sched_out(struct preempt_notifier *pn, struct task_struct *next);
103648 +static struct preempt_ops kvm_preempt_ops = {
103649 + .sched_in = kvm_sched_in,
103650 + .sched_out = kvm_sched_out,
103651 +};
103652
103653 struct dentry *kvm_debugfs_dir;
103654
103655 @@ -769,7 +774,7 @@ int __kvm_set_memory_region(struct kvm *kvm,
103656 /* We can read the guest memory with __xxx_user() later on. */
103657 if (user_alloc &&
103658 ((mem->userspace_addr & (PAGE_SIZE - 1)) ||
103659 - !access_ok(VERIFY_WRITE,
103660 + !__access_ok(VERIFY_WRITE,
103661 (void __user *)(unsigned long)mem->userspace_addr,
103662 mem->memory_size)))
103663 goto out;
103664 @@ -1881,7 +1886,7 @@ static int kvm_vcpu_release(struct inode *inode, struct file *filp)
103665 return 0;
103666 }
103667
103668 -static struct file_operations kvm_vcpu_fops = {
103669 +static file_operations_no_const kvm_vcpu_fops __read_only = {
103670 .release = kvm_vcpu_release,
103671 .unlocked_ioctl = kvm_vcpu_ioctl,
103672 #ifdef CONFIG_COMPAT
103673 @@ -2402,7 +2407,7 @@ static int kvm_vm_mmap(struct file *file, struct vm_area_struct *vma)
103674 return 0;
103675 }
103676
103677 -static struct file_operations kvm_vm_fops = {
103678 +static file_operations_no_const kvm_vm_fops __read_only = {
103679 .release = kvm_vm_release,
103680 .unlocked_ioctl = kvm_vm_ioctl,
103681 #ifdef CONFIG_COMPAT
103682 @@ -2500,7 +2505,7 @@ out:
103683 return r;
103684 }
103685
103686 -static struct file_operations kvm_chardev_ops = {
103687 +static file_operations_no_const kvm_chardev_ops __read_only = {
103688 .unlocked_ioctl = kvm_dev_ioctl,
103689 .compat_ioctl = kvm_dev_ioctl,
103690 .llseek = noop_llseek,
103691 @@ -2526,7 +2531,7 @@ static void hardware_enable_nolock(void *junk)
103692
103693 if (r) {
103694 cpumask_clear_cpu(cpu, cpus_hardware_enabled);
103695 - atomic_inc(&hardware_enable_failed);
103696 + atomic_inc_unchecked(&hardware_enable_failed);
103697 printk(KERN_INFO "kvm: enabling virtualization on "
103698 "CPU%d failed\n", cpu);
103699 }
103700 @@ -2580,10 +2585,10 @@ static int hardware_enable_all(void)
103701
103702 kvm_usage_count++;
103703 if (kvm_usage_count == 1) {
103704 - atomic_set(&hardware_enable_failed, 0);
103705 + atomic_set_unchecked(&hardware_enable_failed, 0);
103706 on_each_cpu(hardware_enable_nolock, NULL, 1);
103707
103708 - if (atomic_read(&hardware_enable_failed)) {
103709 + if (atomic_read_unchecked(&hardware_enable_failed)) {
103710 hardware_disable_all_nolock();
103711 r = -EBUSY;
103712 }
103713 @@ -2941,7 +2946,7 @@ static void kvm_sched_out(struct preempt_notifier *pn,
103714 kvm_arch_vcpu_put(vcpu);
103715 }
103716
103717 -int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
103718 +int kvm_init(const void *opaque, unsigned vcpu_size, unsigned vcpu_align,
103719 struct module *module)
103720 {
103721 int r;
103722 @@ -2977,7 +2982,7 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
103723 if (!vcpu_align)
103724 vcpu_align = __alignof__(struct kvm_vcpu);
103725 kvm_vcpu_cache = kmem_cache_create("kvm_vcpu", vcpu_size, vcpu_align,
103726 - 0, NULL);
103727 + SLAB_USERCOPY, NULL);
103728 if (!kvm_vcpu_cache) {
103729 r = -ENOMEM;
103730 goto out_free_3;
103731 @@ -2987,9 +2992,11 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
103732 if (r)
103733 goto out_free;
103734
103735 + pax_open_kernel();
103736 kvm_chardev_ops.owner = module;
103737 kvm_vm_fops.owner = module;
103738 kvm_vcpu_fops.owner = module;
103739 + pax_close_kernel();
103740
103741 r = misc_register(&kvm_dev);
103742 if (r) {
103743 @@ -2999,9 +3006,6 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
103744
103745 register_syscore_ops(&kvm_syscore_ops);
103746
103747 - kvm_preempt_ops.sched_in = kvm_sched_in;
103748 - kvm_preempt_ops.sched_out = kvm_sched_out;
103749 -
103750 r = kvm_init_debug();
103751 if (r) {
103752 printk(KERN_ERR "kvm: create debugfs files failed\n");